-rw-r--r-- | korganizer/koagenda.cpp | 264 | ||||
-rw-r--r-- | korganizer/koagenda.h | 2 | ||||
-rw-r--r-- | korganizer/koagendaview.cpp | 22 |
3 files changed, 42 insertions, 246 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 114ed75..355f4bb 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -1,2316 +1,2122 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | Marcus Bains line. | 5 | Marcus Bains line. |
6 | Copyright (c) 2001 Ali Rahimi | 6 | Copyright (c) 2001 Ali Rahimi |
7 | 7 | ||
8 | This program is free software; you can redistribute it and/or modify | 8 | This program is free software; you can redistribute it and/or modify |
9 | it under the terms of the GNU General Public License as published by | 9 | it under the terms of the GNU General Public License as published by |
10 | the Free Software Foundation; either version 2 of the License, or | 10 | the Free Software Foundation; either version 2 of the License, or |
11 | (at your option) any later version. | 11 | (at your option) any later version. |
12 | 12 | ||
13 | This program is distributed in the hope that it will be useful, | 13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. | 16 | GNU General Public License for more details. |
17 | 17 | ||
18 | You should have received a copy of the GNU General Public License | 18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software | 19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 | 21 | ||
22 | As a special exception, permission is given to link this program | 22 | As a special exception, permission is given to link this program |
23 | with any edition of Qt, and distribute the resulting executable, | 23 | with any edition of Qt, and distribute the resulting executable, |
24 | without including the source code for Qt in the source distribution. | 24 | without including the source code for Qt in the source distribution. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #ifndef _WIN32_ | 27 | #ifndef _WIN32_ |
28 | #define protected public | 28 | #define protected public |
29 | #include <qwidget.h> | 29 | #include <qwidget.h> |
30 | #undef protected | 30 | #undef protected |
31 | #endif | 31 | #endif |
32 | #include <qintdict.h> | 32 | #include <qintdict.h> |
33 | #include <qdatetime.h> | 33 | #include <qdatetime.h> |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | #include <qpopupmenu.h> | 35 | #include <qpopupmenu.h> |
36 | #include <qcursor.h> | 36 | #include <qcursor.h> |
37 | #include <qpainter.h> | 37 | #include <qpainter.h> |
38 | 38 | ||
39 | #include <kdebug.h> | 39 | #include <kdebug.h> |
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | #include <kiconloader.h> | 41 | #include <kiconloader.h> |
42 | #include <kglobal.h> | 42 | #include <kglobal.h> |
43 | 43 | ||
44 | #include "koagendaitem.h" | 44 | #include "koagendaitem.h" |
45 | #include "koprefs.h" | 45 | #include "koprefs.h" |
46 | #include "koglobals.h" | 46 | #include "koglobals.h" |
47 | 47 | ||
48 | #include "koagenda.h" | 48 | #include "koagenda.h" |
49 | 49 | ||
50 | #include <libkcal/event.h> | 50 | #include <libkcal/event.h> |
51 | #include <libkcal/todo.h> | 51 | #include <libkcal/todo.h> |
52 | 52 | ||
53 | #ifndef DESKTOP_VERSION | 53 | #ifndef DESKTOP_VERSION |
54 | #include <qpe/qpeapplication.h> | 54 | #include <qpe/qpeapplication.h> |
55 | #endif | 55 | #endif |
56 | 56 | ||
57 | //extern bool globalFlagBlockPainting; | 57 | //extern bool globalFlagBlockPainting; |
58 | extern int globalFlagBlockAgenda; | 58 | extern int globalFlagBlockAgenda; |
59 | extern int globalFlagBlockAgendaItemPaint; | 59 | extern int globalFlagBlockAgendaItemPaint; |
60 | extern int globalFlagBlockAgendaItemUpdate; | 60 | extern int globalFlagBlockAgendaItemUpdate; |
61 | extern int globalFlagBlockStartup; | 61 | extern int globalFlagBlockStartup; |
62 | 62 | ||
63 | //////////////////////////////////////////////////////////////////////////// | 63 | //////////////////////////////////////////////////////////////////////////// |
64 | MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) | 64 | MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) |
65 | : QFrame(_agenda->viewport(),name), agenda(_agenda) | 65 | : QFrame(_agenda->viewport(),name), agenda(_agenda) |
66 | { | 66 | { |
67 | setLineWidth(0); | 67 | setLineWidth(0); |
68 | setMargin(0); | 68 | setMargin(0); |
69 | setBackgroundColor(Qt::red); | 69 | setBackgroundColor(Qt::red); |
70 | minutes = new QTimer(this); | 70 | minutes = new QTimer(this); |
71 | connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); | 71 | connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); |
72 | minutes->start(0, true); | 72 | minutes->start(0, true); |
73 | mTimeBox = new QLabel(this); | 73 | mTimeBox = new QLabel(this); |
74 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); | 74 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); |
75 | QPalette pal = mTimeBox->palette(); | 75 | QPalette pal = mTimeBox->palette(); |
76 | pal.setColor(QColorGroup::Foreground, Qt::red); | 76 | pal.setColor(QColorGroup::Foreground, Qt::red); |
77 | mTimeBox->setPalette(pal); | 77 | mTimeBox->setPalette(pal); |
78 | //mTimeBox->setAutoMask(true); | 78 | //mTimeBox->setAutoMask(true); |
79 | 79 | ||
80 | agenda->addChild(mTimeBox); | 80 | agenda->addChild(mTimeBox); |
81 | 81 | ||
82 | oldToday = -1; | 82 | oldToday = -1; |
83 | } | 83 | } |
84 | 84 | ||
85 | MarcusBains::~MarcusBains() | 85 | MarcusBains::~MarcusBains() |
86 | { | 86 | { |
87 | delete minutes; | 87 | delete minutes; |
88 | } | 88 | } |
89 | 89 | ||
90 | int MarcusBains::todayColumn() | 90 | int MarcusBains::todayColumn() |
91 | { | 91 | { |
92 | QDate currentDate = QDate::currentDate(); | 92 | QDate currentDate = QDate::currentDate(); |
93 | 93 | ||
94 | DateList dateList = agenda->dateList(); | 94 | DateList dateList = agenda->dateList(); |
95 | DateList::ConstIterator it; | 95 | DateList::ConstIterator it; |
96 | int col = 0; | 96 | int col = 0; |
97 | for(it = dateList.begin(); it != dateList.end(); ++it) { | 97 | for(it = dateList.begin(); it != dateList.end(); ++it) { |
98 | if((*it) == currentDate) | 98 | if((*it) == currentDate) |
99 | return KOGlobals::self()->reverseLayout() ? | 99 | return KOGlobals::self()->reverseLayout() ? |
100 | agenda->columns() - 1 - col : col; | 100 | agenda->columns() - 1 - col : col; |
101 | ++col; | 101 | ++col; |
102 | } | 102 | } |
103 | 103 | ||
104 | return -1; | 104 | return -1; |
105 | } | 105 | } |
106 | void MarcusBains::updateLoc() | 106 | void MarcusBains::updateLoc() |
107 | { | 107 | { |
108 | updateLocation(); | 108 | updateLocation(); |
109 | } | 109 | } |
110 | void MarcusBains::updateLocation(bool recalculate) | 110 | void MarcusBains::updateLocation(bool recalculate) |
111 | { | 111 | { |
112 | 112 | ||
113 | QTime tim = QTime::currentTime(); | 113 | QTime tim = QTime::currentTime(); |
114 | //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); | 114 | //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); |
115 | if((tim.hour() == 0) && (oldTime.hour()==23)) | 115 | if((tim.hour() == 0) && (oldTime.hour()==23)) |
116 | recalculate = true; | 116 | recalculate = true; |
117 | 117 | ||
118 | int mins = tim.hour()*60 + tim.minute(); | 118 | int mins = tim.hour()*60 + tim.minute(); |
119 | int minutesPerCell = 24 * 60 / agenda->rows(); | 119 | int minutesPerCell = 24 * 60 / agenda->rows(); |
120 | int y = mins*agenda->gridSpacingY()/minutesPerCell; | 120 | int y = mins*agenda->gridSpacingY()/minutesPerCell; |
121 | int today = recalculate ? todayColumn() : oldToday; | 121 | int today = recalculate ? todayColumn() : oldToday; |
122 | int x = agenda->gridSpacingX()*today; | 122 | int x = agenda->gridSpacingX()*today; |
123 | bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); | 123 | bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); |
124 | 124 | ||
125 | oldTime = tim; | 125 | oldTime = tim; |
126 | oldToday = today; | 126 | oldToday = today; |
127 | 127 | ||
128 | if(disabled || (today<0)) { | 128 | if(disabled || (today<0)) { |
129 | hide(); mTimeBox->hide(); | 129 | hide(); mTimeBox->hide(); |
130 | return; | 130 | return; |
131 | } else { | 131 | } else { |
132 | show(); mTimeBox->show(); | 132 | show(); mTimeBox->show(); |
133 | } | 133 | } |
134 | 134 | ||
135 | if(recalculate) | 135 | if(recalculate) |
136 | setFixedSize(agenda->gridSpacingX(),1); | 136 | setFixedSize(agenda->gridSpacingX(),1); |
137 | agenda->moveChild(this, x, y); | 137 | agenda->moveChild(this, x, y); |
138 | raise(); | 138 | raise(); |
139 | 139 | ||
140 | if(recalculate) | 140 | if(recalculate) |
141 | //mTimeBox->setFont(QFont("helvetica",10)); | 141 | //mTimeBox->setFont(QFont("helvetica",10)); |
142 | mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); | 142 | mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); |
143 | 143 | ||
144 | mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); | 144 | mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); |
145 | mTimeBox->adjustSize(); | 145 | mTimeBox->adjustSize(); |
146 | // the -2 below is there because there is a bug in this program | 146 | // the -2 below is there because there is a bug in this program |
147 | // somewhere, where the last column of this widget is a few pixels | 147 | // somewhere, where the last column of this widget is a few pixels |
148 | // narrower than the other columns. | 148 | // narrower than the other columns. |
149 | int offs = (today==agenda->columns()-1) ? -4 : 0; | 149 | int offs = (today==agenda->columns()-1) ? -4 : 0; |
150 | agenda->moveChild(mTimeBox, | 150 | agenda->moveChild(mTimeBox, |
151 | x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, | 151 | x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, |
152 | y-mTimeBox->height()); | 152 | y-mTimeBox->height()); |
153 | 153 | ||
154 | mTimeBox->raise(); | 154 | mTimeBox->raise(); |
155 | //mTimeBox->setAutoMask(true); | 155 | //mTimeBox->setAutoMask(true); |
156 | minutes->start(5000,true); | 156 | minutes->start(5000,true); |
157 | } | 157 | } |
158 | 158 | ||
159 | 159 | ||
160 | //////////////////////////////////////////////////////////////////////////// | 160 | //////////////////////////////////////////////////////////////////////////// |
161 | 161 | ||
162 | 162 | ||
163 | /* | 163 | /* |
164 | Create an agenda widget with rows rows and columns columns. | 164 | Create an agenda widget with rows rows and columns columns. |
165 | */ | 165 | */ |
166 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, | 166 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, |
167 | const char *name,WFlags f) : | 167 | const char *name,WFlags f) : |
168 | QScrollView(parent,name,f) | 168 | QScrollView(parent,name,f) |
169 | { | 169 | { |
170 | 170 | ||
171 | mAllAgendaPopup = 0; | 171 | mAllAgendaPopup = 0; |
172 | mColumns = columns; | 172 | mColumns = columns; |
173 | mRows = rows; | 173 | mRows = rows; |
174 | mGridSpacingY = rowSize; | 174 | mGridSpacingY = rowSize; |
175 | mAllDayMode = false; | 175 | mAllDayMode = false; |
176 | #ifndef DESKTOP_VERSION | 176 | #ifndef DESKTOP_VERSION |
177 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 177 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
178 | #endif | 178 | #endif |
179 | mHolidayMask = 0; | 179 | mHolidayMask = 0; |
180 | init(); | 180 | init(); |
181 | } | 181 | } |
182 | 182 | ||
183 | /* | 183 | /* |
184 | Create an agenda widget with columns columns and one row. This is used for | 184 | Create an agenda widget with columns columns and one row. This is used for |
185 | all-day events. | 185 | all-day events. |
186 | */ | 186 | */ |
187 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : | 187 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : |
188 | QScrollView(parent,name,f) | 188 | QScrollView(parent,name,f) |
189 | { | 189 | { |
190 | mAllAgendaPopup = 0; | 190 | mAllAgendaPopup = 0; |
191 | blockResize = false; | 191 | blockResize = false; |
192 | mColumns = columns; | 192 | mColumns = columns; |
193 | mRows = 1; | 193 | mRows = 1; |
194 | //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); | 194 | //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); |
195 | mGridSpacingY = KOPrefs::instance()->mAllDaySize; | 195 | mGridSpacingY = KOPrefs::instance()->mAllDaySize; |
196 | mAllDayMode = true; | 196 | mAllDayMode = true; |
197 | #ifndef DESKTOP_VERSION | 197 | #ifndef DESKTOP_VERSION |
198 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 198 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
199 | #endif | 199 | #endif |
200 | mHolidayMask = 0; | 200 | mHolidayMask = 0; |
201 | init(); | 201 | init(); |
202 | } | 202 | } |
203 | 203 | ||
204 | 204 | ||
205 | KOAgenda::~KOAgenda() | 205 | KOAgenda::~KOAgenda() |
206 | { | 206 | { |
207 | if(mMarcusBains) delete mMarcusBains; | 207 | if(mMarcusBains) delete mMarcusBains; |
208 | 208 | ||
209 | } | 209 | } |
210 | 210 | ||
211 | Incidence *KOAgenda::selectedIncidence() const | 211 | Incidence *KOAgenda::selectedIncidence() const |
212 | { | 212 | { |
213 | return (mSelectedItem ? mSelectedItem->incidence() : 0); | 213 | return (mSelectedItem ? mSelectedItem->incidence() : 0); |
214 | } | 214 | } |
215 | 215 | ||
216 | 216 | ||
217 | QDate KOAgenda::selectedIncidenceDate() const | 217 | QDate KOAgenda::selectedIncidenceDate() const |
218 | { | 218 | { |
219 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); | 219 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); |
220 | } | 220 | } |
221 | 221 | ||
222 | 222 | ||
223 | void KOAgenda::init() | 223 | void KOAgenda::init() |
224 | { | 224 | { |
225 | mPopupTimer = new QTimer(this); | 225 | mPopupTimer = new QTimer(this); |
226 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); | 226 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); |
227 | 227 | ||
228 | mNewItemPopup = new QPopupMenu( this ); | 228 | mNewItemPopup = new QPopupMenu( this ); |
229 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); | 229 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); |
230 | QString pathString = ""; | 230 | QString pathString = ""; |
231 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { | 231 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { |
232 | if ( QApplication::desktop()->width() < 480 ) | 232 | if ( QApplication::desktop()->width() < 480 ) |
233 | pathString += "icons16/"; | 233 | pathString += "icons16/"; |
234 | } else | 234 | } else |
235 | pathString += "iconsmini/"; | 235 | pathString += "iconsmini/"; |
236 | 236 | ||
237 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); | 237 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); |
238 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); | 238 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); |
239 | mNewItemPopup->insertSeparator ( ); | 239 | mNewItemPopup->insertSeparator ( ); |
240 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); | 240 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); |
241 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); | 241 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); |
242 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); | 242 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); |
243 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); | 243 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); |
244 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); | 244 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); |
245 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); | 245 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); |
246 | #ifndef _WIN32_ | 246 | #ifndef _WIN32_ |
247 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase | 247 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase |
248 | viewport()->setWFlags ( wflags); | 248 | viewport()->setWFlags ( wflags); |
249 | #endif | 249 | #endif |
250 | mGridSpacingX = 80; | 250 | mGridSpacingX = 80; |
251 | mResizeBorderWidth = 8; | 251 | mResizeBorderWidth = 8; |
252 | mScrollBorderWidth = 8; | 252 | mScrollBorderWidth = 8; |
253 | mScrollDelay = 30; | 253 | mScrollDelay = 30; |
254 | mScrollOffset = 10; | 254 | mScrollOffset = 10; |
255 | mPaintPixmap.resize( 20,20); | 255 | mPaintPixmap.resize( 20,20); |
256 | //enableClipper(true); | 256 | //enableClipper(true); |
257 | 257 | ||
258 | // Grab key strokes for keyboard navigation of agenda. Seems to have no | 258 | // Grab key strokes for keyboard navigation of agenda. Seems to have no |
259 | // effect. Has to be fixed. | 259 | // effect. Has to be fixed. |
260 | setFocusPolicy(WheelFocus); | 260 | setFocusPolicy(WheelFocus); |
261 | 261 | ||
262 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); | 262 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); |
263 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); | 263 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); |
264 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); | 264 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); |
265 | 265 | ||
266 | mStartCellX = 0; | 266 | mStartCellX = 0; |
267 | mStartCellY = 0; | 267 | mStartCellY = 0; |
268 | mCurrentCellX = 0; | 268 | mCurrentCellX = 0; |
269 | mCurrentCellY = 0; | 269 | mCurrentCellY = 0; |
270 | 270 | ||
271 | mSelectionCellX = 0; | 271 | mSelectionCellX = 0; |
272 | mSelectionYTop = 0; | 272 | mSelectionYTop = 0; |
273 | mSelectionHeight = 0; | 273 | mSelectionHeight = 0; |
274 | 274 | ||
275 | mOldLowerScrollValue = -1; | 275 | mOldLowerScrollValue = -1; |
276 | mOldUpperScrollValue = -1; | 276 | mOldUpperScrollValue = -1; |
277 | 277 | ||
278 | mClickedItem = 0; | 278 | mClickedItem = 0; |
279 | 279 | ||
280 | mActionItem = 0; | 280 | mActionItem = 0; |
281 | mActionType = NOP; | 281 | mActionType = NOP; |
282 | mItemMoved = false; | 282 | mItemMoved = false; |
283 | 283 | ||
284 | mSelectedItem = 0; | 284 | mSelectedItem = 0; |
285 | 285 | ||
286 | // mItems.setAutoDelete(true); | 286 | // mItems.setAutoDelete(true); |
287 | 287 | ||
288 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 288 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
289 | 289 | ||
290 | viewport()->update(); | 290 | viewport()->update(); |
291 | 291 | ||
292 | setMinimumSize(30, 1); | 292 | setMinimumSize(30, 1); |
293 | // setMaximumHeight(mGridSpacingY * mRows + 5); | 293 | // setMaximumHeight(mGridSpacingY * mRows + 5); |
294 | 294 | ||
295 | // Disable horizontal scrollbar. This is a hack. The geometry should be | 295 | // Disable horizontal scrollbar. This is a hack. The geometry should be |
296 | // controlled in a way that the contents horizontally always fits. Then it is | 296 | // controlled in a way that the contents horizontally always fits. Then it is |
297 | // not necessary to turn off the scrollbar. | 297 | // not necessary to turn off the scrollbar. |
298 | setHScrollBarMode(AlwaysOff); | 298 | setHScrollBarMode(AlwaysOff); |
299 | if ( ! mAllDayMode ) | 299 | if ( ! mAllDayMode ) |
300 | setVScrollBarMode(AlwaysOn); | 300 | setVScrollBarMode(AlwaysOn); |
301 | else | 301 | else |
302 | setVScrollBarMode(AlwaysOff); | 302 | setVScrollBarMode(AlwaysOff); |
303 | 303 | ||
304 | setStartHour(KOPrefs::instance()->mDayBegins); | 304 | setStartHour(KOPrefs::instance()->mDayBegins); |
305 | 305 | ||
306 | calculateWorkingHours(); | 306 | calculateWorkingHours(); |
307 | 307 | ||
308 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), | 308 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), |
309 | SLOT(checkScrollBoundaries(int))); | 309 | SLOT(checkScrollBoundaries(int))); |
310 | 310 | ||
311 | // Create the Marcus Bains line. | 311 | // Create the Marcus Bains line. |
312 | if(mAllDayMode) | 312 | if(mAllDayMode) |
313 | mMarcusBains = 0; | 313 | mMarcusBains = 0; |
314 | else { | 314 | else { |
315 | mMarcusBains = new MarcusBains(this); | 315 | mMarcusBains = new MarcusBains(this); |
316 | addChild(mMarcusBains); | 316 | addChild(mMarcusBains); |
317 | } | 317 | } |
318 | mPopupKind = 0; | 318 | mPopupKind = 0; |
319 | mPopupItem = 0; | 319 | mPopupItem = 0; |
320 | } | 320 | } |
321 | 321 | ||
322 | void KOAgenda::clear() | 322 | void KOAgenda::clear() |
323 | { | 323 | { |
324 | KOAgendaItem *item; | 324 | KOAgendaItem *item; |
325 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 325 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
326 | mUnusedItems.append( item ); | 326 | mUnusedItems.append( item ); |
327 | //item->hide(); | 327 | //item->hide(); |
328 | } | 328 | } |
329 | mItems.clear(); | 329 | mItems.clear(); |
330 | mSelectedItem = 0; | 330 | mSelectedItem = 0; |
331 | clearSelection(); | 331 | clearSelection(); |
332 | } | 332 | } |
333 | 333 | ||
334 | void KOAgenda::clearSelection() | 334 | void KOAgenda::clearSelection() |
335 | { | 335 | { |
336 | mSelectionCellX = 0; | 336 | mSelectionCellX = 0; |
337 | mSelectionYTop = 0; | 337 | mSelectionYTop = 0; |
338 | mSelectionHeight = 0; | 338 | mSelectionHeight = 0; |
339 | } | 339 | } |
340 | 340 | ||
341 | void KOAgenda::marcus_bains() | 341 | void KOAgenda::marcus_bains() |
342 | { | 342 | { |
343 | if(mMarcusBains) mMarcusBains->updateLocation(true); | 343 | if(mMarcusBains) mMarcusBains->updateLocation(true); |
344 | } | 344 | } |
345 | 345 | ||
346 | 346 | ||
347 | void KOAgenda::changeColumns(int columns) | 347 | void KOAgenda::changeColumns(int columns) |
348 | { | 348 | { |
349 | if (columns == 0) { | 349 | if (columns == 0) { |
350 | qDebug("KOAgenda::changeColumns() called with argument 0 "); | 350 | qDebug("KOAgenda::changeColumns() called with argument 0 "); |
351 | return; | 351 | return; |
352 | } | 352 | } |
353 | clear(); | 353 | clear(); |
354 | mColumns = columns; | 354 | mColumns = columns; |
355 | computeSizes(); | 355 | computeSizes(); |
356 | } | 356 | } |
357 | 357 | ||
358 | /* | 358 | /* |
359 | This is the eventFilter function, which gets all events from the KOAgendaItems | 359 | This is the eventFilter function, which gets all events from the KOAgendaItems |
360 | contained in the agenda. It has to handle moving and resizing for all items. | 360 | contained in the agenda. It has to handle moving and resizing for all items. |
361 | */ | 361 | */ |
362 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) | 362 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) |
363 | { | 363 | { |
364 | // kdDebug() << "KOAgenda::eventFilter" << endl; | 364 | // kdDebug() << "KOAgenda::eventFilter" << endl; |
365 | switch(event->type()) { | 365 | switch(event->type()) { |
366 | case QEvent::MouseButtonPress: | 366 | case QEvent::MouseButtonPress: |
367 | case QEvent::MouseButtonDblClick: | 367 | case QEvent::MouseButtonDblClick: |
368 | case QEvent::MouseButtonRelease: | 368 | case QEvent::MouseButtonRelease: |
369 | case QEvent::MouseMove: | 369 | case QEvent::MouseMove: |
370 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); | 370 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); |
371 | 371 | ||
372 | case (QEvent::Leave): | 372 | case (QEvent::Leave): |
373 | if (!mActionItem) | 373 | if (!mActionItem) |
374 | setCursor(arrowCursor); | 374 | setCursor(arrowCursor); |
375 | return true; | 375 | return true; |
376 | 376 | ||
377 | default: | 377 | default: |
378 | return QScrollView::eventFilter(object,event); | 378 | return QScrollView::eventFilter(object,event); |
379 | } | 379 | } |
380 | } | 380 | } |
381 | void KOAgenda::popupMenu() | 381 | void KOAgenda::popupMenu() |
382 | { | 382 | { |
383 | mPopupTimer->stop(); | 383 | mPopupTimer->stop(); |
384 | if ( mPopupKind == 1 ) { | 384 | if ( mPopupKind == 1 ) { |
385 | if (mActionItem ) { | 385 | if (mActionItem ) { |
386 | endItemAction(); | 386 | endItemAction(); |
387 | } | 387 | } |
388 | mLeftMouseDown = false; // no more leftMouse computation | 388 | mLeftMouseDown = false; // no more leftMouse computation |
389 | if (mPopupItem) { | 389 | if (mPopupItem) { |
390 | //mClickedItem = mPopupItem; | 390 | //mClickedItem = mPopupItem; |
391 | selectItem(mPopupItem); | 391 | selectItem(mPopupItem); |
392 | if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu ) | 392 | if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu ) |
393 | mAllAgendaPopup->installEventFilter( this ); | 393 | mAllAgendaPopup->installEventFilter( this ); |
394 | emit showIncidencePopupSignal(mPopupItem->incidence()); | 394 | emit showIncidencePopupSignal(mPopupItem->incidence()); |
395 | 395 | ||
396 | } | 396 | } |
397 | } else if ( mPopupKind == 2 ) { | 397 | } else if ( mPopupKind == 2 ) { |
398 | if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action | 398 | if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action |
399 | endSelectAction( false ); // do not emit new event signal | 399 | endSelectAction( false ); // do not emit new event signal |
400 | mLeftMouseDown = false; // no more leftMouse computation | 400 | mLeftMouseDown = false; // no more leftMouse computation |
401 | } | 401 | } |
402 | if ( KOPrefs::instance()->mBlockPopupMenu ) | 402 | if ( KOPrefs::instance()->mBlockPopupMenu ) |
403 | mNewItemPopup->installEventFilter( this ); | 403 | mNewItemPopup->installEventFilter( this ); |
404 | mNewItemPopup->popup( mPopupPos); | 404 | mNewItemPopup->popup( mPopupPos); |
405 | 405 | ||
406 | } | 406 | } |
407 | mLeftMouseDown = false; | 407 | mLeftMouseDown = false; |
408 | mPopupItem = 0; | 408 | mPopupItem = 0; |
409 | mPopupKind = 0; | 409 | mPopupKind = 0; |
410 | } | 410 | } |
411 | 411 | ||
412 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) | 412 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) |
413 | { | 413 | { |
414 | static int startX = 0; | 414 | static int startX = 0; |
415 | static int startY = 0; | 415 | static int startY = 0; |
416 | static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); | 416 | static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); |
417 | static bool blockMoving = true; | 417 | static bool blockMoving = true; |
418 | 418 | ||
419 | //qDebug("KOAgenda::eventFilter_mous "); | 419 | //qDebug("KOAgenda::eventFilter_mous "); |
420 | if ( object == mNewItemPopup ) { | 420 | if ( object == mNewItemPopup ) { |
421 | //qDebug("mNewItemPopup "); | 421 | //qDebug("mNewItemPopup "); |
422 | if ( me->type() == QEvent::MouseButtonRelease ) { | 422 | if ( me->type() == QEvent::MouseButtonRelease ) { |
423 | mNewItemPopup->removeEventFilter( this ); | 423 | mNewItemPopup->removeEventFilter( this ); |
424 | int dX = me->globalPos().x() - mPopupPos.x();; | 424 | int dX = me->globalPos().x() - mPopupPos.x();; |
425 | if ( dX < 0 ) | 425 | if ( dX < 0 ) |
426 | dX = -dX; | 426 | dX = -dX; |
427 | int dY = me->globalPos().y() - mPopupPos.y(); | 427 | int dY = me->globalPos().y() - mPopupPos.y(); |
428 | if ( dY < 0 ) | 428 | if ( dY < 0 ) |
429 | dY = -dY; | 429 | dY = -dY; |
430 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 430 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
431 | mNewItemPopup->hide(); | 431 | mNewItemPopup->hide(); |
432 | } | 432 | } |
433 | } | 433 | } |
434 | return true; | 434 | return true; |
435 | } | 435 | } |
436 | if ( object == mAllAgendaPopup ) { | 436 | if ( object == mAllAgendaPopup ) { |
437 | //qDebug(" mAllAgendaPopup "); | 437 | //qDebug(" mAllAgendaPopup "); |
438 | if ( me->type() == QEvent::MouseButtonRelease ) { | 438 | if ( me->type() == QEvent::MouseButtonRelease ) { |
439 | mAllAgendaPopup->removeEventFilter( this ); | 439 | mAllAgendaPopup->removeEventFilter( this ); |
440 | int dX = me->globalPos().x() - mPopupPos.x();; | 440 | int dX = me->globalPos().x() - mPopupPos.x();; |
441 | if ( dX < 0 ) | 441 | if ( dX < 0 ) |
442 | dX = -dX; | 442 | dX = -dX; |
443 | int dY = me->globalPos().y() - mPopupPos.y(); | 443 | int dY = me->globalPos().y() - mPopupPos.y(); |
444 | if ( dY < 0 ) | 444 | if ( dY < 0 ) |
445 | dY = -dY; | 445 | dY = -dY; |
446 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 446 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
447 | mAllAgendaPopup->hide(); | 447 | mAllAgendaPopup->hide(); |
448 | } | 448 | } |
449 | } | 449 | } |
450 | return true; | 450 | return true; |
451 | } | 451 | } |
452 | QPoint viewportPos; | 452 | QPoint viewportPos; |
453 | if (object != viewport()) { | 453 | if (object != viewport()) { |
454 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); | 454 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); |
455 | } else { | 455 | } else { |
456 | viewportPos = me->pos(); | 456 | viewportPos = me->pos(); |
457 | } | 457 | } |
458 | 458 | ||
459 | switch (me->type()) { | 459 | switch (me->type()) { |
460 | case QEvent::MouseButtonPress: | 460 | case QEvent::MouseButtonPress: |
461 | if (me->button() == LeftButton) { | 461 | if (me->button() == LeftButton) { |
462 | mPopupTimer->start( 600 ); | 462 | mPopupTimer->start( 600 ); |
463 | mLeftMouseDown = true; | 463 | mLeftMouseDown = true; |
464 | } | 464 | } |
465 | blockMoving = true; | 465 | blockMoving = true; |
466 | startX = viewportPos.x(); | 466 | startX = viewportPos.x(); |
467 | startY = viewportPos.y(); | 467 | startY = viewportPos.y(); |
468 | mPopupPos = me->globalPos(); | 468 | mPopupPos = me->globalPos(); |
469 | if (object != viewport()) { | 469 | if (object != viewport()) { |
470 | mPopupItem = (KOAgendaItem *)object; | 470 | mPopupItem = (KOAgendaItem *)object; |
471 | mPopupKind = 1; | 471 | mPopupKind = 1; |
472 | if (me->button() == RightButton) { | 472 | if (me->button() == RightButton) { |
473 | popupMenu(); | 473 | popupMenu(); |
474 | } else if (me->button() == LeftButton) { | 474 | } else if (me->button() == LeftButton) { |
475 | mActionItem = (KOAgendaItem *)object; | 475 | mActionItem = (KOAgendaItem *)object; |
476 | if (mActionItem) { | 476 | if (mActionItem) { |
477 | if ( mSelectionHeight > 0 ) { | 477 | emit signalClearSelection(); |
478 | int selectionCellX = mSelectionCellX * mGridSpacingX; | 478 | slotClearSelection(); |
479 | int selectionYTop = mSelectionYTop; | ||
480 | int gridSpacingX = mGridSpacingX; | ||
481 | int selectionHeight = mSelectionHeight; | ||
482 | clearSelection(); | ||
483 | repaintContents( selectionCellX, selectionYTop, | ||
484 | gridSpacingX, selectionHeight,false ); | ||
485 | } | ||
486 | selectItem(mActionItem); | 479 | selectItem(mActionItem); |
487 | Incidence *incidence = mActionItem->incidence(); | 480 | Incidence *incidence = mActionItem->incidence(); |
488 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { | 481 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { |
489 | mActionItem = 0; | 482 | mActionItem = 0; |
490 | } else { | 483 | } else { |
491 | startItemAction(viewportPos); | 484 | startItemAction(viewportPos); |
492 | } | 485 | } |
493 | } | 486 | } |
494 | } | 487 | } |
495 | } else { // ---------- viewport() | 488 | } else { // ---------- viewport() |
496 | mPopupItem = 0; | 489 | mPopupItem = 0; |
497 | mPopupKind = 2; | 490 | mPopupKind = 2; |
498 | selectItem(0); | 491 | selectItem(0); |
499 | mActionItem = 0; | 492 | mActionItem = 0; |
500 | if (me->button() == RightButton) { | 493 | if (me->button() == RightButton) { |
501 | int x,y; | 494 | int x,y; |
502 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 495 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
503 | int gx,gy; | 496 | int gx,gy; |
504 | contentsToGrid(x,y,gx,gy); | 497 | contentsToGrid(x,y,gx,gy); |
505 | mCurrentCellX = gx; | 498 | mCurrentCellX = gx; |
506 | mCurrentCellY = gy; | 499 | mCurrentCellY = gy; |
507 | mStartCellX = gx; | 500 | mStartCellX = gx; |
508 | mStartCellY = gy; | 501 | mStartCellY = gy; |
509 | popupMenu(); | 502 | popupMenu(); |
510 | } else if (me->button() == LeftButton) { | 503 | } else if (me->button() == LeftButton) { |
511 | setCursor(arrowCursor); | 504 | setCursor(arrowCursor); |
512 | startSelectAction(viewportPos); | 505 | startSelectAction(viewportPos); |
513 | } | 506 | } |
514 | } | 507 | } |
515 | break; | 508 | break; |
516 | 509 | ||
517 | case QEvent::MouseButtonRelease: | 510 | case QEvent::MouseButtonRelease: |
518 | if (me->button() == LeftButton ) { | 511 | if (me->button() == LeftButton ) { |
519 | mPopupTimer->stop(); | 512 | mPopupTimer->stop(); |
520 | } | 513 | } |
521 | if (object != viewport()) { | 514 | if (object != viewport()) { |
522 | if (me->button() == LeftButton && mLeftMouseDown) { | 515 | if (me->button() == LeftButton && mLeftMouseDown) { |
523 | if (mActionItem) { | 516 | if (mActionItem) { |
524 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 517 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
525 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); | 518 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); |
526 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { | 519 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { |
527 | mScrollUpTimer.stop(); | 520 | mScrollUpTimer.stop(); |
528 | mScrollDownTimer.stop(); | 521 | mScrollDownTimer.stop(); |
529 | mActionItem->resetMove(); | 522 | mActionItem->resetMove(); |
530 | placeSubCells( mActionItem ); | 523 | placeSubCells( mActionItem ); |
531 | // emit startDragSignal( mActionItem->incidence() ); | 524 | // emit startDragSignal( mActionItem->incidence() ); |
532 | setCursor( arrowCursor ); | 525 | setCursor( arrowCursor ); |
533 | mActionItem = 0; | 526 | mActionItem = 0; |
534 | mActionType = NOP; | 527 | mActionType = NOP; |
535 | mItemMoved = 0; | 528 | mItemMoved = 0; |
536 | mLeftMouseDown = false; | 529 | mLeftMouseDown = false; |
537 | return true; | 530 | return true; |
538 | } | 531 | } |
539 | endItemAction(); | 532 | endItemAction(); |
540 | } | 533 | } |
541 | } | 534 | } |
542 | 535 | ||
543 | } else { // ---------- viewport() | 536 | } else { // ---------- viewport() |
544 | if (me->button() == LeftButton && mLeftMouseDown ) { //left click | 537 | if (me->button() == LeftButton && mLeftMouseDown ) { //left click |
545 | endSelectAction( true ); // emit new event signal | 538 | endSelectAction( true ); // emit new event signal |
546 | } | 539 | } |
547 | } | 540 | } |
548 | if (me->button() == LeftButton) | 541 | if (me->button() == LeftButton) |
549 | mLeftMouseDown = false; | 542 | mLeftMouseDown = false; |
550 | 543 | ||
551 | break; | 544 | break; |
552 | 545 | ||
553 | case QEvent::MouseMove: | 546 | case QEvent::MouseMove: |
554 | //qDebug("mm "); | 547 | //qDebug("mm "); |
555 | if ( !mLeftMouseDown ) | 548 | if ( !mLeftMouseDown ) |
556 | return false; | 549 | return false; |
557 | if ( blockMoving ) { | 550 | if ( blockMoving ) { |
558 | int dX, dY; | 551 | int dX, dY; |
559 | dX = startX - viewportPos.x(); | 552 | dX = startX - viewportPos.x(); |
560 | if ( dX < 0 ) | 553 | if ( dX < 0 ) |
561 | dX = -dX; | 554 | dX = -dX; |
562 | dY = viewportPos.y() - startY; | 555 | dY = viewportPos.y() - startY; |
563 | if ( dY < 0 ) | 556 | if ( dY < 0 ) |
564 | dY = -dY; | 557 | dY = -dY; |
565 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); | 558 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); |
566 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 559 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
567 | blockMoving = false; | 560 | blockMoving = false; |
568 | } | 561 | } |
569 | } | 562 | } |
570 | if ( ! blockMoving ) | 563 | if ( ! blockMoving ) |
571 | mPopupTimer->stop(); | 564 | mPopupTimer->stop(); |
572 | if (object != viewport()) { | 565 | if (object != viewport()) { |
573 | KOAgendaItem *moveItem = (KOAgendaItem *)object; | 566 | KOAgendaItem *moveItem = (KOAgendaItem *)object; |
574 | if (!moveItem->incidence()->isReadOnly() ) { | 567 | if (!moveItem->incidence()->isReadOnly() ) { |
575 | if (!mActionItem) | 568 | if (!mActionItem) |
576 | setNoActionCursor(moveItem,viewportPos); | 569 | setNoActionCursor(moveItem,viewportPos); |
577 | else { | 570 | else { |
578 | if ( !blockMoving ) | 571 | if ( !blockMoving ) |
579 | performItemAction(viewportPos); | 572 | performItemAction(viewportPos); |
580 | } | 573 | } |
581 | } | 574 | } |
582 | } else { // ---------- viewport() | 575 | } else { // ---------- viewport() |
583 | mPopupPos = viewport()->mapToGlobal( me->pos() ); | 576 | mPopupPos = viewport()->mapToGlobal( me->pos() ); |
584 | if ( mActionType == SELECT ) { | 577 | if ( mActionType == SELECT ) { |
585 | performSelectAction( viewportPos ); | 578 | performSelectAction( viewportPos ); |
586 | } | 579 | } |
587 | } | 580 | } |
588 | break; | 581 | break; |
589 | 582 | ||
590 | case QEvent::MouseButtonDblClick: | 583 | case QEvent::MouseButtonDblClick: |
591 | mPopupTimer->stop(); | 584 | mPopupTimer->stop(); |
592 | if (object == viewport()) { | 585 | if (object == viewport()) { |
593 | selectItem(0); | 586 | selectItem(0); |
594 | int x,y; | 587 | int x,y; |
595 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 588 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
596 | int gx,gy; | 589 | int gx,gy; |
597 | contentsToGrid(x,y,gx,gy); | 590 | contentsToGrid(x,y,gx,gy); |
598 | emit newEventSignal(gx,gy); | 591 | emit newEventSignal(gx,gy); |
599 | } else { | 592 | } else { |
600 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; | 593 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; |
601 | selectItem(doubleClickedItem); | 594 | selectItem(doubleClickedItem); |
602 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 595 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
603 | emit editIncidenceSignal(doubleClickedItem->incidence()); | 596 | emit editIncidenceSignal(doubleClickedItem->incidence()); |
604 | else | 597 | else |
605 | emit showIncidenceSignal(doubleClickedItem->incidence()); | 598 | emit showIncidenceSignal(doubleClickedItem->incidence()); |
606 | } | 599 | } |
607 | break; | 600 | break; |
608 | 601 | ||
609 | default: | 602 | default: |
610 | break; | 603 | break; |
611 | } | 604 | } |
612 | return true; | 605 | return true; |
613 | #if 0 | ||
614 | //qDebug("KOAgenda::eventFilter_mous "); | ||
615 | QPoint viewportPos; | ||
616 | if (object != viewport()) { | ||
617 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); | ||
618 | } else { | ||
619 | viewportPos = me->pos(); | ||
620 | } | ||
621 | static int startX = 0; | ||
622 | static int startY = 0; | ||
623 | static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); | ||
624 | static bool blockMoving = true; | ||
625 | static bool leftMouseDown = false; | ||
626 | bool rightButtonPressed = false; | ||
627 | switch (me->type()) { | ||
628 | case QEvent::MouseButtonPress: | ||
629 | if (me->button() == LeftButton) { | ||
630 | leftMouseDown = true; | ||
631 | } | ||
632 | else if (me->button() == RightButton) { | ||
633 | leftMouseDown = false; | ||
634 | } | ||
635 | blockMoving = true; | ||
636 | startX = viewportPos.x(); | ||
637 | startY = viewportPos.y(); | ||
638 | if (object != viewport()) { // item clicked ************** | ||
639 | if (me->button() == RightButton) { | ||
640 | leftMouseDown = false; | ||
641 | mClickedItem = (KOAgendaItem *)object; | ||
642 | if (mActionItem ) { | ||
643 | endItemAction(); | ||
644 | } | ||
645 | if (mClickedItem) { | ||
646 | selectItem(mClickedItem); | ||
647 | emit showIncidencePopupSignal(mClickedItem->incidence()); | ||
648 | } | ||
649 | return true; | ||
650 | } else if (me->button() == LeftButton) { | ||
651 | mActionItem = (KOAgendaItem *)object; | ||
652 | if (mActionItem) { | ||
653 | if ( mSelectionHeight > 0 ) { | ||
654 | int selectionCellX = mSelectionCellX * mGridSpacingX; | ||
655 | int selectionYTop = mSelectionYTop; | ||
656 | int gridSpacingX = mGridSpacingX; | ||
657 | int selectionHeight = mSelectionHeight; | ||
658 | clearSelection(); | ||
659 | repaintContents( selectionCellX, selectionYTop, | ||
660 | gridSpacingX, selectionHeight,false ); | ||
661 | } | ||
662 | selectItem(mActionItem); | ||
663 | Incidence *incidence = mActionItem->incidence(); | ||
664 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { | ||
665 | mActionItem = 0; | ||
666 | } else { | ||
667 | startItemAction(viewportPos); | ||
668 | } | ||
669 | } | ||
670 | } | ||
671 | } else { // ---------- viewport() | ||
672 | selectItem(0); | ||
673 | mActionItem = 0; | ||
674 | if (me->button() == LeftButton ) { | ||
675 | setCursor(arrowCursor); | ||
676 | startSelectAction(viewportPos); | ||
677 | } else if (me->button() == RightButton ) { | ||
678 | setCursor(arrowCursor); | ||
679 | if ( leftMouseDown ) { // we have a simulated right click - clear left mouse action | ||
680 | endSelectAction( false ); // do not emit new event signal | ||
681 | leftMouseDown = false; // no more leftMouse computation | ||
682 | } | ||
683 | int x,y; | ||
684 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | ||
685 | int gx,gy; | ||
686 | contentsToGrid(x,y,gx,gy); | ||
687 | mCurrentCellX = gx; | ||
688 | mCurrentCellY = gy; | ||
689 | mStartCellX = gx; | ||
690 | mStartCellY = gy; | ||
691 | mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) ); | ||
692 | } | ||
693 | } | ||
694 | break; | ||
695 | |||
696 | case QEvent::MouseButtonRelease: | ||
697 | |||
698 | if (object != viewport()) { | ||
699 | if (me->button() == LeftButton && leftMouseDown) { | ||
700 | if (mActionItem) { | ||
701 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | ||
702 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); | ||
703 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { | ||
704 | mScrollUpTimer.stop(); | ||
705 | mScrollDownTimer.stop(); | ||
706 | mActionItem->resetMove(); | ||
707 | placeSubCells( mActionItem ); | ||
708 | // emit startDragSignal( mActionItem->incidence() ); | ||
709 | setCursor( arrowCursor ); | ||
710 | mActionItem = 0; | ||
711 | mActionType = NOP; | ||
712 | mItemMoved = 0; | ||
713 | leftMouseDown = false; | ||
714 | return true; | ||
715 | } | ||
716 | endItemAction(); | ||
717 | } | ||
718 | } | ||
719 | |||
720 | } else { // ---------- viewport() | ||
721 | if (me->button() == LeftButton && leftMouseDown ) { //left click | ||
722 | endSelectAction( true ); // emit new event signal | ||
723 | } | ||
724 | } | ||
725 | if (me->button() == LeftButton) | ||
726 | leftMouseDown = false; | ||
727 | |||
728 | break; | ||
729 | 606 | ||
730 | case QEvent::MouseMove: | ||
731 | if ( !leftMouseDown ) | ||
732 | return true; | ||
733 | if ( blockMoving ) { | ||
734 | int dX, dY; | ||
735 | dX = startX - viewportPos.x(); | ||
736 | if ( dX < 0 ) | ||
737 | dX = -dX; | ||
738 | dY = viewportPos.y() - startY; | ||
739 | if ( dY < 0 ) | ||
740 | dY = -dY; | ||
741 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); | ||
742 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | ||
743 | blockMoving = false; | ||
744 | } | ||
745 | } | ||
746 | if (object != viewport()) { | ||
747 | KOAgendaItem *moveItem = (KOAgendaItem *)object; | ||
748 | if (!moveItem->incidence()->isReadOnly() ) { | ||
749 | if (!mActionItem) | ||
750 | setNoActionCursor(moveItem,viewportPos); | ||
751 | else { | ||
752 | if ( !blockMoving ) | ||
753 | performItemAction(viewportPos); | ||
754 | } | ||
755 | } | ||
756 | } else { // ---------- viewport() | ||
757 | if ( mActionType == SELECT ) { | ||
758 | performSelectAction( viewportPos ); | ||
759 | } | ||
760 | } | ||
761 | break; | ||
762 | |||
763 | case QEvent::MouseButtonDblClick: | ||
764 | blockMoving = false; | ||
765 | leftMouseDown = false; | ||
766 | if (object == viewport()) { | ||
767 | selectItem(0); | ||
768 | int x,y; | ||
769 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | ||
770 | int gx,gy; | ||
771 | contentsToGrid(x,y,gx,gy); | ||
772 | emit newEventSignal(gx,gy); | ||
773 | } else { | ||
774 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; | ||
775 | selectItem(doubleClickedItem); | ||
776 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | ||
777 | emit editIncidenceSignal(doubleClickedItem->incidence()); | ||
778 | else | ||
779 | emit showIncidenceSignal(doubleClickedItem->incidence()); | ||
780 | } | ||
781 | break; | ||
782 | |||
783 | default: | ||
784 | break; | ||
785 | } | ||
786 | return true; | ||
787 | #endif | ||
788 | } | 607 | } |
789 | 608 | ||
790 | void KOAgenda::newItem( int item ) | 609 | void KOAgenda::newItem( int item ) |
791 | { | 610 | { |
792 | if ( item == 1 ) { //new event | 611 | if ( item == 1 ) { //new event |
793 | newEventSignal(mStartCellX ,mStartCellY ); | 612 | newEventSignal(mStartCellX ,mStartCellY ); |
794 | } else | 613 | } else |
795 | if ( item == 2 ) { //new event | 614 | if ( item == 2 ) { //new event |
796 | newTodoSignal(mStartCellX ,mStartCellY ); | 615 | newTodoSignal(mStartCellX ,mStartCellY ); |
797 | } else | 616 | } else |
798 | { | 617 | { |
799 | emit showDateView( item, mStartCellX ); | 618 | emit showDateView( item, mStartCellX ); |
800 | // 3Day view | 619 | // 3Day view |
801 | // 4Week view | 620 | // 4Week view |
802 | // 5Month view | 621 | // 5Month view |
803 | // 6Journal view | 622 | // 6Journal view |
804 | } | 623 | } |
805 | } | 624 | } |
625 | void KOAgenda::slotClearSelection() | ||
626 | { | ||
627 | if (mSelectionHeight) { | ||
628 | int selectionX = mSelectionCellX * mGridSpacingX; | ||
629 | int top = mSelectionYTop - 2 *mGridSpacingY; | ||
630 | int hei = mSelectionHeight + 4 *mGridSpacingY; | ||
631 | clearSelection(); | ||
632 | repaintContents( selectionX, top, | ||
633 | mGridSpacingX, hei ,false ); | ||
634 | } | ||
635 | |||
636 | } | ||
806 | void KOAgenda::startSelectAction(QPoint viewportPos) | 637 | void KOAgenda::startSelectAction(QPoint viewportPos) |
807 | { | 638 | { |
808 | //emit newStartSelectSignal(); | 639 | |
640 | emit signalClearSelection(); | ||
641 | slotClearSelection(); | ||
809 | 642 | ||
810 | mActionType = SELECT; | 643 | mActionType = SELECT; |
811 | 644 | ||
812 | int x,y; | 645 | int x,y; |
813 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 646 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
814 | int gx,gy; | 647 | int gx,gy; |
815 | contentsToGrid(x,y,gx,gy); | 648 | contentsToGrid(x,y,gx,gy); |
816 | 649 | ||
817 | mStartCellX = gx; | 650 | mStartCellX = gx; |
818 | mStartCellY = gy; | 651 | mStartCellY = gy; |
819 | mCurrentCellX = gx; | 652 | mCurrentCellX = gx; |
820 | mCurrentCellY = gy; | 653 | mCurrentCellY = gy; |
821 | |||
822 | // Store coordinates of old selection | ||
823 | int selectionX = mSelectionCellX * mGridSpacingX; | ||
824 | int selectionYTop = mSelectionYTop; | ||
825 | int selectionHeight = mSelectionHeight; | ||
826 | 654 | ||
827 | // Store new selection | 655 | // Store new selection |
828 | mSelectionCellX = gx; | 656 | mSelectionCellX = gx; |
829 | mSelectionYTop = gy * mGridSpacingY; | 657 | mSelectionYTop = gy * mGridSpacingY; |
830 | mSelectionHeight = mGridSpacingY; | 658 | mSelectionHeight = mGridSpacingY; |
831 | 659 | ||
832 | // Clear old selection | 660 | // Paint new selection |
833 | repaintContents( selectionX, selectionYTop, | 661 | repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop, |
834 | mGridSpacingX, selectionHeight,false ); | 662 | mGridSpacingX-1, mSelectionHeight ); |
835 | |||
836 | // Paint new selection | ||
837 | // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop, | ||
838 | // mGridSpacingX, mSelectionHeight ); | ||
839 | } | 663 | } |
840 | 664 | ||
841 | void KOAgenda::performSelectAction(QPoint viewportPos) | 665 | void KOAgenda::performSelectAction(QPoint viewportPos) |
842 | { | 666 | { |
843 | int x,y; | 667 | int x,y; |
844 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 668 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
845 | int gx,gy; | 669 | int gx,gy; |
846 | contentsToGrid(x,y,gx,gy); | 670 | contentsToGrid(x,y,gx,gy); |
847 | 671 | ||
848 | QPoint clipperPos = clipper()-> | 672 | QPoint clipperPos = clipper()-> |
849 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 673 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
850 | 674 | ||
851 | // Scroll if cursor was moved to upper or lower end of agenda. | 675 | // Scroll if cursor was moved to upper or lower end of agenda. |
852 | if (clipperPos.y() < mScrollBorderWidth) { | 676 | if (clipperPos.y() < mScrollBorderWidth) { |
853 | mScrollUpTimer.start(mScrollDelay); | 677 | mScrollUpTimer.start(mScrollDelay); |
854 | } else if (visibleHeight() - clipperPos.y() < | 678 | } else if (visibleHeight() - clipperPos.y() < |
855 | mScrollBorderWidth) { | 679 | mScrollBorderWidth) { |
856 | mScrollDownTimer.start(mScrollDelay); | 680 | mScrollDownTimer.start(mScrollDelay); |
857 | } else { | 681 | } else { |
858 | mScrollUpTimer.stop(); | 682 | mScrollUpTimer.stop(); |
859 | mScrollDownTimer.stop(); | 683 | mScrollDownTimer.stop(); |
860 | } | 684 | } |
861 | 685 | ||
862 | if ( gy > mCurrentCellY ) { | 686 | if ( gy > mCurrentCellY ) { |
863 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 687 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
864 | 688 | ||
865 | #if 0 | 689 | |
866 | // FIXME: Repaint only the newly selected region | ||
867 | repaintContents( mSelectionCellX * mGridSpacingX, | ||
868 | mCurrentCellY + mGridSpacingY, | ||
869 | mGridSpacingX, | ||
870 | mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY ); | ||
871 | #else | ||
872 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 690 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
873 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 691 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
874 | mGridSpacingX, mSelectionYTop, | 692 | mGridSpacingX, mSelectionYTop, |
875 | mGridSpacingX, mSelectionHeight , false); | 693 | mGridSpacingX, mSelectionHeight , false); |
876 | #endif | ||
877 | 694 | ||
878 | mCurrentCellY = gy; | 695 | mCurrentCellY = gy; |
879 | } else if ( gy < mCurrentCellY ) { | 696 | } else if ( gy < mCurrentCellY ) { |
880 | if ( gy >= mStartCellY ) { | 697 | if ( gy >= mStartCellY ) { |
881 | int selectionHeight = mSelectionHeight; | 698 | int selectionHeight = mSelectionHeight; |
882 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 699 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
883 | 700 | ||
884 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 701 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
885 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 702 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
886 | mGridSpacingX, mSelectionYTop, | 703 | mGridSpacingX, mSelectionYTop, |
887 | mGridSpacingX, selectionHeight,false ); | 704 | mGridSpacingX, selectionHeight,false ); |
888 | 705 | ||
889 | mCurrentCellY = gy; | 706 | mCurrentCellY = gy; |
890 | } else { | 707 | } else { |
891 | } | 708 | } |
892 | } | 709 | } |
893 | } | 710 | } |
894 | 711 | ||
895 | void KOAgenda::endSelectAction( bool emitNewEvent ) | 712 | void KOAgenda::endSelectAction( bool emitNewEvent ) |
896 | { | 713 | { |
897 | mActionType = NOP; | 714 | mActionType = NOP; |
898 | mScrollUpTimer.stop(); | 715 | mScrollUpTimer.stop(); |
899 | mScrollDownTimer.stop(); | 716 | mScrollDownTimer.stop(); |
900 | 717 | ||
901 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 718 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
902 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) { | 719 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) { |
903 | qDebug("ew event signal "); | ||
904 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 720 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
905 | } | 721 | } |
906 | } | 722 | } |
907 | 723 | ||
908 | void KOAgenda::startItemAction(QPoint viewportPos) | 724 | void KOAgenda::startItemAction(QPoint viewportPos) |
909 | { | 725 | { |
910 | int x,y; | 726 | int x,y; |
911 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 727 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
912 | int gx,gy; | 728 | int gx,gy; |
913 | contentsToGrid(x,y,gx,gy); | 729 | contentsToGrid(x,y,gx,gy); |
914 | 730 | ||
915 | mStartCellX = gx; | 731 | mStartCellX = gx; |
916 | mStartCellY = gy; | 732 | mStartCellY = gy; |
917 | mCurrentCellX = gx; | 733 | mCurrentCellX = gx; |
918 | mCurrentCellY = gy; | 734 | mCurrentCellY = gy; |
919 | 735 | ||
920 | if (mAllDayMode) { | 736 | if (mAllDayMode) { |
921 | int gridDistanceX = (x - gx * mGridSpacingX); | 737 | int gridDistanceX = (x - gx * mGridSpacingX); |
922 | if (gridDistanceX < mResizeBorderWidth && | 738 | if (gridDistanceX < mResizeBorderWidth && |
923 | mActionItem->cellX() == mCurrentCellX) { | 739 | mActionItem->cellX() == mCurrentCellX) { |
924 | mActionType = RESIZELEFT; | 740 | mActionType = RESIZELEFT; |
925 | setCursor(sizeHorCursor); | 741 | setCursor(sizeHorCursor); |
926 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 742 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
927 | mActionItem->cellXWidth() == mCurrentCellX) { | 743 | mActionItem->cellXWidth() == mCurrentCellX) { |
928 | mActionType = RESIZERIGHT; | 744 | mActionType = RESIZERIGHT; |
929 | setCursor(sizeHorCursor); | 745 | setCursor(sizeHorCursor); |
930 | } else { | 746 | } else { |
931 | mActionType = MOVE; | 747 | mActionType = MOVE; |
932 | mActionItem->startMove(); | 748 | mActionItem->startMove(); |
933 | setCursor(sizeAllCursor); | 749 | setCursor(sizeAllCursor); |
934 | } | 750 | } |
935 | } else { | 751 | } else { |
936 | int gridDistanceY = (y - gy * mGridSpacingY); | 752 | int gridDistanceY = (y - gy * mGridSpacingY); |
937 | bool allowResize = ( mActionItem->incidence()->type() != "Todo" ); | 753 | bool allowResize = ( mActionItem->incidence()->type() != "Todo" ); |
938 | if (allowResize && gridDistanceY < mResizeBorderWidth && | 754 | if (allowResize && gridDistanceY < mResizeBorderWidth && |
939 | mActionItem->cellYTop() == mCurrentCellY && | 755 | mActionItem->cellYTop() == mCurrentCellY && |
940 | !mActionItem->firstMultiItem()) { | 756 | !mActionItem->firstMultiItem()) { |
941 | mActionType = RESIZETOP; | 757 | mActionType = RESIZETOP; |
942 | setCursor(sizeVerCursor); | 758 | setCursor(sizeVerCursor); |
943 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 759 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
944 | mActionItem->cellYBottom() == mCurrentCellY && | 760 | mActionItem->cellYBottom() == mCurrentCellY && |
945 | !mActionItem->lastMultiItem()) { | 761 | !mActionItem->lastMultiItem()) { |
946 | mActionType = RESIZEBOTTOM; | 762 | mActionType = RESIZEBOTTOM; |
947 | setCursor(sizeVerCursor); | 763 | setCursor(sizeVerCursor); |
948 | } else { | 764 | } else { |
949 | mActionType = MOVE; | 765 | mActionType = MOVE; |
950 | mActionItem->startMove(); | 766 | mActionItem->startMove(); |
951 | setCursor(sizeAllCursor); | 767 | setCursor(sizeAllCursor); |
952 | } | 768 | } |
953 | } | 769 | } |
954 | } | 770 | } |
955 | 771 | ||
956 | void KOAgenda::performItemAction(QPoint viewportPos) | 772 | void KOAgenda::performItemAction(QPoint viewportPos) |
957 | { | 773 | { |
958 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 774 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
959 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 775 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
960 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 776 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
961 | // point = clipper()->mapFromGlobal(point); | 777 | // point = clipper()->mapFromGlobal(point); |
962 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 778 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
963 | // kdDebug() << "visible height: " << visibleHeight() << endl; | 779 | // kdDebug() << "visible height: " << visibleHeight() << endl; |
964 | int x,y; | 780 | int x,y; |
965 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 781 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
966 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 782 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
967 | int gx,gy; | 783 | int gx,gy; |
968 | contentsToGrid(x,y,gx,gy); | 784 | contentsToGrid(x,y,gx,gy); |
969 | QPoint clipperPos = clipper()-> | 785 | QPoint clipperPos = clipper()-> |
970 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 786 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
971 | 787 | ||
972 | // Cursor left active agenda area. | 788 | // Cursor left active agenda area. |
973 | // This starts a drag. | 789 | // This starts a drag. |
974 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ | 790 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ |
975 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { | 791 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { |
976 | if ( mActionType == MOVE ) { | 792 | if ( mActionType == MOVE ) { |
977 | mScrollUpTimer.stop(); | 793 | mScrollUpTimer.stop(); |
978 | mScrollDownTimer.stop(); | 794 | mScrollDownTimer.stop(); |
979 | mActionItem->resetMove(); | 795 | mActionItem->resetMove(); |
980 | placeSubCells( mActionItem ); | 796 | placeSubCells( mActionItem ); |
981 | // emit startDragSignal( mActionItem->incidence() ); | 797 | // emit startDragSignal( mActionItem->incidence() ); |
982 | setCursor( arrowCursor ); | 798 | setCursor( arrowCursor ); |
983 | mActionItem = 0; | 799 | mActionItem = 0; |
984 | mActionType = NOP; | 800 | mActionType = NOP; |
985 | mItemMoved = 0; | 801 | mItemMoved = 0; |
986 | return; | 802 | return; |
987 | } | 803 | } |
988 | } else { | 804 | } else { |
989 | switch ( mActionType ) { | 805 | switch ( mActionType ) { |
990 | case MOVE: | 806 | case MOVE: |
991 | setCursor( sizeAllCursor ); | 807 | setCursor( sizeAllCursor ); |
992 | break; | 808 | break; |
993 | case RESIZETOP: | 809 | case RESIZETOP: |
994 | case RESIZEBOTTOM: | 810 | case RESIZEBOTTOM: |
995 | setCursor( sizeVerCursor ); | 811 | setCursor( sizeVerCursor ); |
996 | break; | 812 | break; |
997 | case RESIZELEFT: | 813 | case RESIZELEFT: |
998 | case RESIZERIGHT: | 814 | case RESIZERIGHT: |
999 | setCursor( sizeHorCursor ); | 815 | setCursor( sizeHorCursor ); |
1000 | break; | 816 | break; |
1001 | default: | 817 | default: |
1002 | setCursor( arrowCursor ); | 818 | setCursor( arrowCursor ); |
1003 | } | 819 | } |
1004 | } | 820 | } |
1005 | 821 | ||
1006 | // Scroll if item was moved to upper or lower end of agenda. | 822 | // Scroll if item was moved to upper or lower end of agenda. |
1007 | if (clipperPos.y() < mScrollBorderWidth) { | 823 | if (clipperPos.y() < mScrollBorderWidth) { |
1008 | mScrollUpTimer.start(mScrollDelay); | 824 | mScrollUpTimer.start(mScrollDelay); |
1009 | } else if (visibleHeight() - clipperPos.y() < | 825 | } else if (visibleHeight() - clipperPos.y() < |
1010 | mScrollBorderWidth) { | 826 | mScrollBorderWidth) { |
1011 | mScrollDownTimer.start(mScrollDelay); | 827 | mScrollDownTimer.start(mScrollDelay); |
1012 | } else { | 828 | } else { |
1013 | mScrollUpTimer.stop(); | 829 | mScrollUpTimer.stop(); |
1014 | mScrollDownTimer.stop(); | 830 | mScrollDownTimer.stop(); |
1015 | } | 831 | } |
1016 | 832 | ||
1017 | // Move or resize item if necessary | 833 | // Move or resize item if necessary |
1018 | if (mCurrentCellX != gx || mCurrentCellY != gy) { | 834 | if (mCurrentCellX != gx || mCurrentCellY != gy) { |
1019 | mItemMoved = true; | 835 | mItemMoved = true; |
1020 | mActionItem->raise(); | 836 | mActionItem->raise(); |
1021 | if (mActionType == MOVE) { | 837 | if (mActionType == MOVE) { |
1022 | // Move all items belonging to a multi item | 838 | // Move all items belonging to a multi item |
1023 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); | 839 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); |
1024 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); | 840 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); |
1025 | if (!moveItem) moveItem = mActionItem; | 841 | if (!moveItem) moveItem = mActionItem; |
1026 | while (moveItem) { | 842 | while (moveItem) { |
1027 | int dy; | 843 | int dy; |
1028 | if (isMultiItem) dy = 0; | 844 | if (isMultiItem) dy = 0; |
1029 | else dy = gy - mCurrentCellY; | 845 | else dy = gy - mCurrentCellY; |
1030 | moveItem->moveRelative(gx - mCurrentCellX,dy); | 846 | moveItem->moveRelative(gx - mCurrentCellX,dy); |
1031 | int x,y; | 847 | int x,y; |
1032 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); | 848 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); |
1033 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), | 849 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), |
1034 | mGridSpacingY * moveItem->cellHeight()); | 850 | mGridSpacingY * moveItem->cellHeight()); |
1035 | moveChild(moveItem,x,y); | 851 | moveChild(moveItem,x,y); |
1036 | moveItem = moveItem->nextMultiItem(); | 852 | moveItem = moveItem->nextMultiItem(); |
1037 | } | 853 | } |
1038 | } else if (mActionType == RESIZETOP) { | 854 | } else if (mActionType == RESIZETOP) { |
1039 | if (mCurrentCellY <= mActionItem->cellYBottom()) { | 855 | if (mCurrentCellY <= mActionItem->cellYBottom()) { |
1040 | mActionItem->expandTop(gy - mCurrentCellY); | 856 | mActionItem->expandTop(gy - mCurrentCellY); |
1041 | mActionItem->resize(mActionItem->width(), | 857 | mActionItem->resize(mActionItem->width(), |
1042 | mGridSpacingY * mActionItem->cellHeight()); | 858 | mGridSpacingY * mActionItem->cellHeight()); |
1043 | int x,y; | 859 | int x,y; |
1044 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); | 860 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); |
1045 | //moveChild(mActionItem,childX(mActionItem),y); | 861 | //moveChild(mActionItem,childX(mActionItem),y); |
1046 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); | 862 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); |
1047 | } | 863 | } |
1048 | } else if (mActionType == RESIZEBOTTOM) { | 864 | } else if (mActionType == RESIZEBOTTOM) { |
1049 | if (mCurrentCellY >= mActionItem->cellYTop()) { | 865 | if (mCurrentCellY >= mActionItem->cellYTop()) { |
1050 | mActionItem->expandBottom(gy - mCurrentCellY); | 866 | mActionItem->expandBottom(gy - mCurrentCellY); |
1051 | mActionItem->resize(mActionItem->width(), | 867 | mActionItem->resize(mActionItem->width(), |
1052 | mGridSpacingY * mActionItem->cellHeight()); | 868 | mGridSpacingY * mActionItem->cellHeight()); |
1053 | } | 869 | } |
1054 | } else if (mActionType == RESIZELEFT) { | 870 | } else if (mActionType == RESIZELEFT) { |
1055 | if (mCurrentCellX <= mActionItem->cellXWidth()) { | 871 | if (mCurrentCellX <= mActionItem->cellXWidth()) { |
1056 | mActionItem->expandLeft(gx - mCurrentCellX); | 872 | mActionItem->expandLeft(gx - mCurrentCellX); |
1057 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 873 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
1058 | mActionItem->height()); | 874 | mActionItem->height()); |
1059 | int x,y; | 875 | int x,y; |
1060 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); | 876 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); |
1061 | moveChild(mActionItem,x,childY(mActionItem)); | 877 | moveChild(mActionItem,x,childY(mActionItem)); |
1062 | } | 878 | } |
1063 | } else if (mActionType == RESIZERIGHT) { | 879 | } else if (mActionType == RESIZERIGHT) { |
1064 | if (mCurrentCellX >= mActionItem->cellX()) { | 880 | if (mCurrentCellX >= mActionItem->cellX()) { |
1065 | mActionItem->expandRight(gx - mCurrentCellX); | 881 | mActionItem->expandRight(gx - mCurrentCellX); |
1066 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 882 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
1067 | mActionItem->height()); | 883 | mActionItem->height()); |
1068 | } | 884 | } |
1069 | } | 885 | } |
1070 | mCurrentCellX = gx; | 886 | mCurrentCellX = gx; |
1071 | mCurrentCellY = gy; | 887 | mCurrentCellY = gy; |
1072 | } | 888 | } |
1073 | } | 889 | } |
1074 | 890 | ||
1075 | void KOAgenda::endItemAction() | 891 | void KOAgenda::endItemAction() |
1076 | { | 892 | { |
1077 | 893 | ||
1078 | if ( mItemMoved ) { | 894 | if ( mItemMoved ) { |
1079 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); | 895 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); |
1080 | if ( !placeItem ) { | 896 | if ( !placeItem ) { |
1081 | placeItem = mActionItem; | 897 | placeItem = mActionItem; |
1082 | } | 898 | } |
1083 | if ( placeItem->incidence()->recurrence()->doesRecur() ) { | 899 | if ( placeItem->incidence()->recurrence()->doesRecur() ) { |
1084 | Incidence* oldInc = placeItem->incidence(); | 900 | Incidence* oldInc = placeItem->incidence(); |
1085 | placeItem->recreateIncidence(); | 901 | placeItem->recreateIncidence(); |
1086 | emit addToCalSignal(placeItem->incidence(), oldInc ); | 902 | emit addToCalSignal(placeItem->incidence(), oldInc ); |
1087 | } | 903 | } |
1088 | int type = mActionType; | 904 | int type = mActionType; |
1089 | if ( mAllDayMode ) | 905 | if ( mAllDayMode ) |
1090 | type = -1; | 906 | type = -1; |
1091 | KOAgendaItem *modifiedItem = placeItem; | 907 | KOAgendaItem *modifiedItem = placeItem; |
1092 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); | 908 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); |
1093 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); | 909 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); |
1094 | KOAgendaItem *item; | 910 | KOAgendaItem *item; |
1095 | 911 | ||
1096 | if ( placeItem->incidence()->type() == "Todo" ) { | 912 | if ( placeItem->incidence()->type() == "Todo" ) { |
1097 | mSelectedItem = 0; | 913 | mSelectedItem = 0; |
1098 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); | 914 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); |
1099 | modifiedItem->mLastMoveXPos = mCurrentCellX; | 915 | modifiedItem->mLastMoveXPos = mCurrentCellX; |
1100 | emit itemModified( modifiedItem, mActionType ); | 916 | emit itemModified( modifiedItem, mActionType ); |
1101 | } | 917 | } |
1102 | else { | 918 | else { |
1103 | #if 0 | 919 | |
1104 | for ( item=oldconflictItems.first(); item != 0; | ||
1105 | item=oldconflictItems.next() ) { | ||
1106 | placeSubCells(item); | ||
1107 | } | ||
1108 | while ( placeItem ) { | ||
1109 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | ||
1110 | placeSubCells( placeItem ); | ||
1111 | placeItem = placeItem->nextMultiItem(); | ||
1112 | } | ||
1113 | #endif | ||
1114 | 920 | ||
1115 | globalFlagBlockAgendaItemPaint = 1; | 921 | globalFlagBlockAgendaItemPaint = 1; |
1116 | for ( item=oldconflictItems.first(); item != 0; | 922 | for ( item=oldconflictItems.first(); item != 0; |
1117 | item=oldconflictItems.next() ) { | 923 | item=oldconflictItems.next() ) { |
1118 | placeSubCells(item); | 924 | placeSubCells(item); |
1119 | } | 925 | } |
1120 | while ( placeItem ) { | 926 | while ( placeItem ) { |
1121 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 927 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
1122 | oldconflictItems = placeItem->conflictItems(); | 928 | oldconflictItems = placeItem->conflictItems(); |
1123 | for ( item=oldconflictItems.first(); item != 0; | 929 | for ( item=oldconflictItems.first(); item != 0; |
1124 | item=oldconflictItems.next() ) { | 930 | item=oldconflictItems.next() ) { |
1125 | placeSubCells(item); | 931 | placeSubCells(item); |
1126 | } | 932 | } |
1127 | placeSubCells( placeItem ); | 933 | placeSubCells( placeItem ); |
1128 | placeItem = placeItem->nextMultiItem(); | 934 | placeItem = placeItem->nextMultiItem(); |
1129 | } | 935 | } |
1130 | globalFlagBlockAgendaItemPaint = 0; | 936 | globalFlagBlockAgendaItemPaint = 0; |
1131 | for ( item=oldconflictItems.first(); item != 0; | 937 | for ( item=oldconflictItems.first(); item != 0; |
1132 | item=oldconflictItems.next() ) { | 938 | item=oldconflictItems.next() ) { |
1133 | globalFlagBlockAgendaItemUpdate = 0; | 939 | globalFlagBlockAgendaItemUpdate = 0; |
1134 | item->repaintMe(); | 940 | item->repaintMe(); |
1135 | globalFlagBlockAgendaItemUpdate = 1; | 941 | globalFlagBlockAgendaItemUpdate = 1; |
1136 | item->repaint( false ); | 942 | item->repaint( false ); |
1137 | } | 943 | } |
1138 | placeItem = modifiedItem; | 944 | placeItem = modifiedItem; |
1139 | 945 | ||
1140 | while ( placeItem ) { | 946 | while ( placeItem ) { |
1141 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 947 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
1142 | globalFlagBlockAgendaItemUpdate = 0; | 948 | globalFlagBlockAgendaItemUpdate = 0; |
1143 | placeItem->repaintMe(); | 949 | placeItem->repaintMe(); |
1144 | globalFlagBlockAgendaItemUpdate = 1; | 950 | globalFlagBlockAgendaItemUpdate = 1; |
1145 | placeItem->repaint(false); | 951 | placeItem->repaint(false); |
1146 | placeItem = placeItem->nextMultiItem(); | 952 | placeItem = placeItem->nextMultiItem(); |
1147 | } | 953 | } |
1148 | emit itemModified( modifiedItem, mActionType ); | 954 | emit itemModified( modifiedItem, mActionType ); |
1149 | 955 | ||
1150 | 956 | ||
1151 | placeItem = modifiedItem; | 957 | placeItem = modifiedItem; |
1152 | while ( placeItem ) { | 958 | while ( placeItem ) { |
1153 | oldconflictItems = placeItem->conflictItems(); | 959 | oldconflictItems = placeItem->conflictItems(); |
1154 | for ( item=oldconflictItems.first(); item != 0; | 960 | for ( item=oldconflictItems.first(); item != 0; |
1155 | item=oldconflictItems.next() ) { | 961 | item=oldconflictItems.next() ) { |
1156 | placeSubCells(item); | 962 | placeSubCells(item); |
1157 | } | 963 | } |
1158 | placeSubCells( placeItem ); | 964 | placeSubCells( placeItem ); |
1159 | placeItem = placeItem->nextMultiItem(); | 965 | placeItem = placeItem->nextMultiItem(); |
1160 | 966 | ||
1161 | } | 967 | } |
1162 | placeItem = modifiedItem; | 968 | placeItem = modifiedItem; |
1163 | while ( placeItem ) { | 969 | while ( placeItem ) { |
1164 | oldconflictItems = placeItem->conflictItems(); | 970 | oldconflictItems = placeItem->conflictItems(); |
1165 | for ( item=oldconflictItems.first(); item != 0; | 971 | for ( item=oldconflictItems.first(); item != 0; |
1166 | item=oldconflictItems.next() ) { | 972 | item=oldconflictItems.next() ) { |
1167 | globalFlagBlockAgendaItemUpdate = 0; | 973 | globalFlagBlockAgendaItemUpdate = 0; |
1168 | item->repaintMe(); | 974 | item->repaintMe(); |
1169 | globalFlagBlockAgendaItemUpdate = 1; | 975 | globalFlagBlockAgendaItemUpdate = 1; |
1170 | item->repaint(false); | 976 | item->repaint(false); |
1171 | } | 977 | } |
1172 | placeItem = placeItem->nextMultiItem(); | 978 | placeItem = placeItem->nextMultiItem(); |
1173 | } | 979 | } |
1174 | /* | 980 | /* |
1175 | 981 | ||
1176 | oldconflictItems = modifiedItem->conflictItems(); | 982 | oldconflictItems = modifiedItem->conflictItems(); |
1177 | for ( item=oldconflictItems.first(); item != 0; | 983 | for ( item=oldconflictItems.first(); item != 0; |
1178 | item=oldconflictItems.next() ) { | 984 | item=oldconflictItems.next() ) { |
1179 | globalFlagBlockAgendaItemUpdate = 0; | 985 | globalFlagBlockAgendaItemUpdate = 0; |
1180 | item->paintMe(false); | 986 | item->paintMe(false); |
1181 | globalFlagBlockAgendaItemUpdate = 1; | 987 | globalFlagBlockAgendaItemUpdate = 1; |
1182 | item->repaint(false); | 988 | item->repaint(false); |
1183 | } | 989 | } |
1184 | */ | 990 | */ |
1185 | 991 | ||
1186 | 992 | ||
1187 | } | 993 | } |
1188 | 994 | ||
1189 | } | 995 | } |
1190 | 996 | ||
1191 | mScrollUpTimer.stop(); | 997 | mScrollUpTimer.stop(); |
1192 | mScrollDownTimer.stop(); | 998 | mScrollDownTimer.stop(); |
1193 | setCursor( arrowCursor ); | 999 | setCursor( arrowCursor ); |
1194 | mActionItem = 0; | 1000 | mActionItem = 0; |
1195 | mActionType = NOP; | 1001 | mActionType = NOP; |
1196 | mItemMoved = 0; | 1002 | mItemMoved = 0; |
1197 | 1003 | ||
1198 | } | 1004 | } |
1199 | 1005 | ||
1200 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) | 1006 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) |
1201 | { | 1007 | { |
1202 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 1008 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
1203 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 1009 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
1204 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 1010 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
1205 | // point = clipper()->mapFromGlobal(point); | 1011 | // point = clipper()->mapFromGlobal(point); |
1206 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 1012 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
1207 | 1013 | ||
1208 | int x,y; | 1014 | int x,y; |
1209 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 1015 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
1210 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 1016 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
1211 | int gx,gy; | 1017 | int gx,gy; |
1212 | contentsToGrid(x,y,gx,gy); | 1018 | contentsToGrid(x,y,gx,gy); |
1213 | 1019 | ||
1214 | // Change cursor to resize cursor if appropriate | 1020 | // Change cursor to resize cursor if appropriate |
1215 | if (mAllDayMode) { | 1021 | if (mAllDayMode) { |
1216 | int gridDistanceX = (x - gx * mGridSpacingX); | 1022 | int gridDistanceX = (x - gx * mGridSpacingX); |
1217 | if (gridDistanceX < mResizeBorderWidth && | 1023 | if (gridDistanceX < mResizeBorderWidth && |
1218 | moveItem->cellX() == gx) { | 1024 | moveItem->cellX() == gx) { |
1219 | setCursor(sizeHorCursor); | 1025 | setCursor(sizeHorCursor); |
1220 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 1026 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
1221 | moveItem->cellXWidth() == gx) { | 1027 | moveItem->cellXWidth() == gx) { |
1222 | setCursor(sizeHorCursor); | 1028 | setCursor(sizeHorCursor); |
1223 | } else { | 1029 | } else { |
1224 | setCursor(arrowCursor); | 1030 | setCursor(arrowCursor); |
1225 | } | 1031 | } |
1226 | } else { | 1032 | } else { |
1227 | int gridDistanceY = (y - gy * mGridSpacingY); | 1033 | int gridDistanceY = (y - gy * mGridSpacingY); |
1228 | if (gridDistanceY < mResizeBorderWidth && | 1034 | if (gridDistanceY < mResizeBorderWidth && |
1229 | moveItem->cellYTop() == gy && | 1035 | moveItem->cellYTop() == gy && |
1230 | !moveItem->firstMultiItem()) { | 1036 | !moveItem->firstMultiItem()) { |
1231 | setCursor(sizeVerCursor); | 1037 | setCursor(sizeVerCursor); |
1232 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 1038 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
1233 | moveItem->cellYBottom() == gy && | 1039 | moveItem->cellYBottom() == gy && |
1234 | !moveItem->lastMultiItem()) { | 1040 | !moveItem->lastMultiItem()) { |
1235 | setCursor(sizeVerCursor); | 1041 | setCursor(sizeVerCursor); |
1236 | } else { | 1042 | } else { |
1237 | setCursor(arrowCursor); | 1043 | setCursor(arrowCursor); |
1238 | } | 1044 | } |
1239 | } | 1045 | } |
1240 | } | 1046 | } |
1241 | 1047 | ||
1242 | 1048 | ||
1243 | /* | 1049 | /* |
1244 | Place item in cell and take care that multiple items using the same cell do | 1050 | Place item in cell and take care that multiple items using the same cell do |
1245 | not overlap. This method is not yet optimal. It doesn´t use the maximum space | 1051 | not overlap. This method is not yet optimal. It doesn´t use the maximum space |
1246 | it can get in all cases. | 1052 | it can get in all cases. |
1247 | At the moment the method has a bug: When an item is placed only the sub cell | 1053 | At the moment the method has a bug: When an item is placed only the sub cell |
1248 | widths of the items are changed, which are within the Y region the item to | 1054 | widths of the items are changed, which are within the Y region the item to |
1249 | place spans. When the sub cell width change of one of this items affects a | 1055 | place spans. When the sub cell width change of one of this items affects a |
1250 | cell, where other items are, which do not overlap in Y with the item to place, | 1056 | cell, where other items are, which do not overlap in Y with the item to place, |
1251 | the display gets corrupted, although the corruption looks quite nice. | 1057 | the display gets corrupted, although the corruption looks quite nice. |
1252 | */ | 1058 | */ |
1253 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) | 1059 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) |
1254 | { | 1060 | { |
1255 | 1061 | ||
1256 | QPtrList<KOAgendaItem> conflictItems; | 1062 | QPtrList<KOAgendaItem> conflictItems; |
1257 | int maxSubCells = 0; | 1063 | int maxSubCells = 0; |
1258 | QIntDict<KOAgendaItem> subCellDict(5); | 1064 | QIntDict<KOAgendaItem> subCellDict(5); |
1259 | 1065 | ||
1260 | KOAgendaItem *item; | 1066 | KOAgendaItem *item; |
1261 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1067 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1262 | if (item != placeItem) { | 1068 | if (item != placeItem) { |
1263 | if (placeItem->cellX() <= item->cellXWidth() && | 1069 | if (placeItem->cellX() <= item->cellXWidth() && |
1264 | placeItem->cellXWidth() >= item->cellX()) { | 1070 | placeItem->cellXWidth() >= item->cellX()) { |
1265 | if ((placeItem->cellYTop() <= item->cellYBottom()) && | 1071 | if ((placeItem->cellYTop() <= item->cellYBottom()) && |
1266 | (placeItem->cellYBottom() >= item->cellYTop())) { | 1072 | (placeItem->cellYBottom() >= item->cellYTop())) { |
1267 | conflictItems.append(item); | 1073 | conflictItems.append(item); |
1268 | if (item->subCells() > maxSubCells) | 1074 | if (item->subCells() > maxSubCells) |
1269 | maxSubCells = item->subCells(); | 1075 | maxSubCells = item->subCells(); |
1270 | subCellDict.insert(item->subCell(),item); | 1076 | subCellDict.insert(item->subCell(),item); |
1271 | } | 1077 | } |
1272 | } | 1078 | } |
1273 | } | 1079 | } |
1274 | } | 1080 | } |
1275 | 1081 | ||
1276 | if (conflictItems.count() > 0) { | 1082 | if (conflictItems.count() > 0) { |
1277 | // Look for unused sub cell and insert item | 1083 | // Look for unused sub cell and insert item |
1278 | int i; | 1084 | int i; |
1279 | for(i=0;i<maxSubCells;++i) { | 1085 | for(i=0;i<maxSubCells;++i) { |
1280 | if (!subCellDict.find(i)) { | 1086 | if (!subCellDict.find(i)) { |
1281 | placeItem->setSubCell(i); | 1087 | placeItem->setSubCell(i); |
1282 | break; | 1088 | break; |
1283 | } | 1089 | } |
1284 | } | 1090 | } |
1285 | if (i == maxSubCells) { | 1091 | if (i == maxSubCells) { |
1286 | placeItem->setSubCell(maxSubCells); | 1092 | placeItem->setSubCell(maxSubCells); |
1287 | maxSubCells++; // add new item to number of sub cells | 1093 | maxSubCells++; // add new item to number of sub cells |
1288 | } | 1094 | } |
1289 | 1095 | ||
1290 | // Prepare for sub cell geometry adjustment | 1096 | // Prepare for sub cell geometry adjustment |
1291 | int newSubCellWidth; | 1097 | int newSubCellWidth; |
1292 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; | 1098 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; |
1293 | else newSubCellWidth = mGridSpacingX / maxSubCells; | 1099 | else newSubCellWidth = mGridSpacingX / maxSubCells; |
1294 | conflictItems.append(placeItem); | 1100 | conflictItems.append(placeItem); |
1295 | 1101 | ||
1296 | 1102 | ||
1297 | // Adjust sub cell geometry of all direct conflict items | 1103 | // Adjust sub cell geometry of all direct conflict items |
1298 | for ( item=conflictItems.first(); item != 0; | 1104 | for ( item=conflictItems.first(); item != 0; |
1299 | item=conflictItems.next() ) { | 1105 | item=conflictItems.next() ) { |
1300 | item->setSubCells(maxSubCells); | 1106 | item->setSubCells(maxSubCells); |
1301 | if (mAllDayMode) { | 1107 | if (mAllDayMode) { |
1302 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1108 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1303 | } else { | 1109 | } else { |
1304 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1110 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1305 | } | 1111 | } |
1306 | int x,y; | 1112 | int x,y; |
1307 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1113 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1308 | if (mAllDayMode) { | 1114 | if (mAllDayMode) { |
1309 | y += item->subCell() * newSubCellWidth; | 1115 | y += item->subCell() * newSubCellWidth; |
1310 | } else { | 1116 | } else { |
1311 | x += item->subCell() * newSubCellWidth; | 1117 | x += item->subCell() * newSubCellWidth; |
1312 | } | 1118 | } |
1313 | moveChild(item,x,y); | 1119 | moveChild(item,x,y); |
1314 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); | 1120 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); |
1315 | //item->updateItem(); | 1121 | //item->updateItem(); |
1316 | } | 1122 | } |
1317 | // Adjust sub cell geometry of all conflict items of all conflict items | 1123 | // Adjust sub cell geometry of all conflict items of all conflict items |
1318 | for ( item=conflictItems.first(); item != 0; | 1124 | for ( item=conflictItems.first(); item != 0; |
1319 | item=conflictItems.next() ) { | 1125 | item=conflictItems.next() ) { |
1320 | if ( placeItem != item ) { | 1126 | if ( placeItem != item ) { |
1321 | KOAgendaItem *item2; | 1127 | KOAgendaItem *item2; |
1322 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); | 1128 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); |
1323 | for ( item2=conflictItems2.first(); item2 != 0; | 1129 | for ( item2=conflictItems2.first(); item2 != 0; |
1324 | item2=conflictItems2.next() ) { | 1130 | item2=conflictItems2.next() ) { |
1325 | if ( item2->subCells() != maxSubCells) { | 1131 | if ( item2->subCells() != maxSubCells) { |
1326 | item2->setSubCells(maxSubCells); | 1132 | item2->setSubCells(maxSubCells); |
1327 | if (mAllDayMode) { | 1133 | if (mAllDayMode) { |
1328 | item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); | 1134 | item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); |
1329 | } else { | 1135 | } else { |
1330 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); | 1136 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); |
1331 | } | 1137 | } |
1332 | int x,y; | 1138 | int x,y; |
1333 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); | 1139 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); |
1334 | if (mAllDayMode) { | 1140 | if (mAllDayMode) { |
1335 | y += item2->subCell() * newSubCellWidth; | 1141 | y += item2->subCell() * newSubCellWidth; |
1336 | } else { | 1142 | } else { |
1337 | x += item2->subCell() * newSubCellWidth; | 1143 | x += item2->subCell() * newSubCellWidth; |
1338 | } | 1144 | } |
1339 | moveChild(item2,x,y); | 1145 | moveChild(item2,x,y); |
1340 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); | 1146 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); |
1341 | } | 1147 | } |
1342 | } | 1148 | } |
1343 | } | 1149 | } |
1344 | } | 1150 | } |
1345 | } else { | 1151 | } else { |
1346 | placeItem->setSubCell(0); | 1152 | placeItem->setSubCell(0); |
1347 | placeItem->setSubCells(1); | 1153 | placeItem->setSubCells(1); |
1348 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); | 1154 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); |
1349 | else placeItem->resize(mGridSpacingX,placeItem->height()); | 1155 | else placeItem->resize(mGridSpacingX,placeItem->height()); |
1350 | int x,y; | 1156 | int x,y; |
1351 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); | 1157 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); |
1352 | moveChild(placeItem,x,y); | 1158 | moveChild(placeItem,x,y); |
1353 | } | 1159 | } |
1354 | placeItem->setConflictItems(conflictItems); | 1160 | placeItem->setConflictItems(conflictItems); |
1355 | // for ( item=conflictItems.first(); item != 0; | 1161 | // for ( item=conflictItems.first(); item != 0; |
1356 | // item=conflictItems.next() ) { | 1162 | // item=conflictItems.next() ) { |
1357 | // //item->updateItem(); | 1163 | // //item->updateItem(); |
1358 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); | 1164 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); |
1359 | // } | 1165 | // } |
1360 | // placeItem->updateItem(); | 1166 | // placeItem->updateItem(); |
1361 | } | 1167 | } |
1362 | 1168 | ||
1363 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) | 1169 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) |
1364 | { | 1170 | { |
1365 | if ( globalFlagBlockAgenda ) | 1171 | if ( globalFlagBlockAgenda ) |
1366 | return; | 1172 | return; |
1367 | if ( ! mAllDayMode ) { | 1173 | if ( ! mAllDayMode ) { |
1368 | // currently not working for | 1174 | // currently not working for |
1369 | 1175 | ||
1370 | //qDebug("KOAgenda::drawContents "); | 1176 | //qDebug("KOAgenda::drawContents "); |
1371 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) | 1177 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) |
1372 | ;//drawContentsToPainter(); | 1178 | ;//drawContentsToPainter(); |
1373 | 1179 | ||
1374 | QPaintDevice* pd = p->device(); | 1180 | QPaintDevice* pd = p->device(); |
1375 | p->end(); | 1181 | p->end(); |
1376 | int vx, vy; | 1182 | int vx, vy; |
1377 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1183 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1378 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1184 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1379 | mSelectionCellX * mGridSpacingX; | 1185 | mSelectionCellX * mGridSpacingX; |
1380 | contentsToViewport ( cx, cy, vx,vy); | 1186 | contentsToViewport ( cx, cy, vx,vy); |
1381 | //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; | 1187 | //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; |
1382 | 1188 | ||
1383 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { | 1189 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { |
1384 | if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1190 | if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1385 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { | 1191 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { |
1386 | 1192 | ||
1387 | int vxSel, vySel; | 1193 | int vxSel, vySel; |
1388 | contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); | 1194 | contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); |
1389 | int off = mSelectionHeight; | 1195 | int off = mSelectionHeight; |
1390 | if ( vySel < 0 ) | 1196 | if ( vySel < 0 ) |
1391 | off += vySel; | 1197 | off += vySel; |
1392 | //qDebug("OFF %d %d %d", off,vySel, vy ); | 1198 | //qDebug("OFF %d %d %d", off,vySel, vy ); |
1393 | bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); | 1199 | bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); |
1394 | } else { | 1200 | } else { |
1395 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1201 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1396 | } | 1202 | } |
1397 | } | 1203 | } |
1398 | if ( mSelectionHeight > 0 ) { | 1204 | if ( mSelectionHeight > 0 ) { |
1399 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1205 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1400 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1206 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1401 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1207 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1402 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1208 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1403 | bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1209 | bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1404 | } | 1210 | } |
1405 | } | 1211 | } |
1406 | p->begin( pd ); | 1212 | p->begin( pd ); |
1407 | } else { | 1213 | } else { |
1408 | 1214 | ||
1409 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) | 1215 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) |
1410 | ;//drawContentsToPainter(); | 1216 | ;//drawContentsToPainter(); |
1411 | 1217 | ||
1412 | QPaintDevice* pd = p->device(); | 1218 | QPaintDevice* pd = p->device(); |
1413 | p->end(); | 1219 | p->end(); |
1414 | int vx, vy; | 1220 | int vx, vy; |
1415 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1221 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1416 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1222 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1417 | mSelectionCellX * mGridSpacingX; | 1223 | mSelectionCellX * mGridSpacingX; |
1418 | contentsToViewport ( cx, cy, vx,vy); | 1224 | contentsToViewport ( cx, cy, vx,vy); |
1419 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; | 1225 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; |
1420 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) | 1226 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) |
1421 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1227 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1422 | 1228 | ||
1423 | if ( mSelectionHeight > 0 ) { | 1229 | if ( mSelectionHeight > 0 ) { |
1424 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1230 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1425 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1231 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1426 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1232 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1427 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1233 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1428 | bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1234 | bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1429 | } | 1235 | } |
1430 | } | 1236 | } |
1431 | p->begin( pd ); | 1237 | p->begin( pd ); |
1432 | } | 1238 | } |
1433 | 1239 | ||
1434 | } | 1240 | } |
1435 | 1241 | ||
1436 | void KOAgenda::finishUpdate() | 1242 | void KOAgenda::finishUpdate() |
1437 | { | 1243 | { |
1438 | 1244 | ||
1439 | KOAgendaItem *item; | 1245 | KOAgendaItem *item; |
1440 | globalFlagBlockAgendaItemPaint = 1; | 1246 | globalFlagBlockAgendaItemPaint = 1; |
1441 | // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems | 1247 | // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems |
1442 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1248 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1443 | if ( !item->checkLayout() ) { | 1249 | if ( !item->checkLayout() ) { |
1444 | //qDebug(" conflictitem found "); | 1250 | //qDebug(" conflictitem found "); |
1445 | int newSubCellWidth; | 1251 | int newSubCellWidth; |
1446 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); | 1252 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); |
1447 | else newSubCellWidth = mGridSpacingX / item->subCells(); | 1253 | else newSubCellWidth = mGridSpacingX / item->subCells(); |
1448 | 1254 | ||
1449 | if (mAllDayMode) { | 1255 | if (mAllDayMode) { |
1450 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1256 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1451 | } else { | 1257 | } else { |
1452 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1258 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1453 | } | 1259 | } |
1454 | int x,y; | 1260 | int x,y; |
1455 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1261 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1456 | if (mAllDayMode) { | 1262 | if (mAllDayMode) { |
1457 | y += item->subCell() * newSubCellWidth; | 1263 | y += item->subCell() * newSubCellWidth; |
1458 | } else { | 1264 | } else { |
1459 | x += item->subCell() * newSubCellWidth; | 1265 | x += item->subCell() * newSubCellWidth; |
1460 | } | 1266 | } |
1461 | moveChild(item,x,y); | 1267 | moveChild(item,x,y); |
1462 | } | 1268 | } |
1463 | } | 1269 | } |
1464 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1270 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1465 | if ( !item->isVisible() ) | 1271 | if ( !item->isVisible() ) |
1466 | item->show(); | 1272 | item->show(); |
1467 | 1273 | ||
1468 | } | 1274 | } |
1469 | globalFlagBlockAgendaItemUpdate = 0; | 1275 | globalFlagBlockAgendaItemUpdate = 0; |
1470 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1276 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1471 | item->repaintMe( ); | 1277 | item->repaintMe( ); |
1472 | } | 1278 | } |
1473 | globalFlagBlockAgendaItemUpdate = 1; | 1279 | globalFlagBlockAgendaItemUpdate = 1; |
1474 | qApp->processEvents(); | 1280 | qApp->processEvents(); |
1475 | globalFlagBlockAgendaItemPaint = 0; | 1281 | globalFlagBlockAgendaItemPaint = 0; |
1476 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1282 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1477 | item->repaint( false ); | 1283 | item->repaint( false ); |
1478 | } | 1284 | } |
1479 | 1285 | ||
1480 | } | 1286 | } |
1481 | 1287 | ||
1482 | /* | 1288 | /* |
1483 | Draw grid in the background of the agenda. | 1289 | Draw grid in the background of the agenda. |
1484 | */ | 1290 | */ |
1485 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) | 1291 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) |
1486 | { | 1292 | { |
1487 | 1293 | ||
1488 | 1294 | ||
1489 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) | 1295 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) |
1490 | return; | 1296 | return; |
1491 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) | 1297 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) |
1492 | return; | 1298 | return; |
1493 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); | 1299 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); |
1494 | if ( ch < 1 ) | 1300 | if ( ch < 1 ) |
1495 | ch = 1; | 1301 | ch = 1; |
1496 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { | 1302 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { |
1497 | mPaintPixmap.resize( contentsWidth()+42, ch ); | 1303 | mPaintPixmap.resize( contentsWidth()+42, ch ); |
1498 | } | 1304 | } |
1499 | mCurPixWid = contentsWidth(); | 1305 | mCurPixWid = contentsWidth(); |
1500 | mCurPixHei = ch; | 1306 | mCurPixHei = ch; |
1501 | if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) { | 1307 | if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) { |
1502 | mHighlightPixmap.resize( mGridSpacingX-1, ch ); | 1308 | mHighlightPixmap.resize( mGridSpacingX-1, ch ); |
1503 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); | 1309 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); |
1504 | } | 1310 | } |
1505 | mPixPainter.begin( &mPaintPixmap) ; | 1311 | mPixPainter.begin( &mPaintPixmap) ; |
1506 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); | 1312 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); |
1507 | QPainter * p ; | 1313 | QPainter * p ; |
1508 | if (paint == 0) { | 1314 | if (paint == 0) { |
1509 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); | 1315 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); |
1510 | p = &mPixPainter; | 1316 | p = &mPixPainter; |
1511 | } | 1317 | } |
1512 | else | 1318 | else |
1513 | p = paint ; | 1319 | p = paint ; |
1514 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); | 1320 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); |
1515 | 1321 | ||
1516 | //--cx;++cw; | 1322 | //--cx;++cw; |
1517 | int lGridSpacingY = mGridSpacingY*2; | 1323 | int lGridSpacingY = mGridSpacingY*2; |
1518 | int selDay; | 1324 | int selDay; |
1519 | if ( !backgroundOnly ) | 1325 | if ( !backgroundOnly ) |
1520 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) | 1326 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) |
1521 | { | 1327 | { |
1522 | if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) { | 1328 | if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) { |
1523 | int x1 = cx; | 1329 | int x1 = cx; |
1524 | int y1 = 0; | 1330 | int y1 = 0; |
1525 | if (y1 < cy) y1 = cy; | 1331 | if (y1 < cy) y1 = cy; |
1526 | int x2 = cx+cw-1; | 1332 | int x2 = cx+cw-1; |
1527 | int y2 = contentsHeight(); | 1333 | int y2 = contentsHeight(); |
1528 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1334 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1529 | if (x2 >= x1 && y2 >= y1) { | 1335 | if (x2 >= x1 && y2 >= y1) { |
1530 | int gxStart = selDay; | 1336 | int gxStart = selDay; |
1531 | int gxEnd = gxStart ; | 1337 | int gxEnd = gxStart ; |
1532 | int xStart = KOGlobals::self()->reverseLayout() ? | 1338 | int xStart = KOGlobals::self()->reverseLayout() ? |
1533 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1339 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1534 | gxStart*mGridSpacingX; | 1340 | gxStart*mGridSpacingX; |
1535 | if (xStart < x1) xStart = x1; | 1341 | if (xStart < x1) xStart = x1; |
1536 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1342 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1537 | (mColumns - gxStart)*mGridSpacingX-1 : | 1343 | (mColumns - gxStart)*mGridSpacingX-1 : |
1538 | (gxStart+1)*mGridSpacingX-1; | 1344 | (gxStart+1)*mGridSpacingX-1; |
1539 | if (xEnd > x2) xEnd = x2; | 1345 | if (xEnd > x2) xEnd = x2; |
1540 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1346 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1541 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1347 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1542 | KOPrefs::instance()->mAgendaBgColor.light()); | 1348 | KOPrefs::instance()->mAgendaBgColor.light()); |
1543 | else | 1349 | else |
1544 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1350 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1545 | KOPrefs::instance()->mAgendaBgColor.dark()); | 1351 | KOPrefs::instance()->mAgendaBgColor.dark()); |
1546 | 1352 | ||
1547 | } | 1353 | } |
1548 | } | 1354 | } |
1549 | } | 1355 | } |
1550 | // Highlight working hours | 1356 | // Highlight working hours |
1551 | 1357 | ||
1552 | if ( !backgroundOnly ) | 1358 | if ( !backgroundOnly ) |
1553 | if (mWorkingHoursEnable) { | 1359 | if (mWorkingHoursEnable) { |
1554 | int x1 = cx; | 1360 | int x1 = cx; |
1555 | int y1 = mWorkingHoursYTop; | 1361 | int y1 = mWorkingHoursYTop; |
1556 | if (y1 < cy) y1 = cy; | 1362 | if (y1 < cy) y1 = cy; |
1557 | int x2 = cx+cw-1; | 1363 | int x2 = cx+cw-1; |
1558 | // int x2 = mGridSpacingX * 5 - 1; | 1364 | // int x2 = mGridSpacingX * 5 - 1; |
1559 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; | 1365 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; |
1560 | int y2 = mWorkingHoursYBottom; | 1366 | int y2 = mWorkingHoursYBottom; |
1561 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1367 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1562 | 1368 | ||
1563 | if (x2 >= x1 && y2 >= y1) { | 1369 | if (x2 >= x1 && y2 >= y1) { |
1564 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); | 1370 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); |
1565 | int gxStart = x1/mGridSpacingX; | 1371 | int gxStart = x1/mGridSpacingX; |
1566 | int gxEnd = x2/mGridSpacingX; | 1372 | int gxEnd = x2/mGridSpacingX; |
1567 | while(gxStart <= gxEnd) { | 1373 | while(gxStart <= gxEnd) { |
1568 | if (gxStart < int(mHolidayMask->count()) && | 1374 | if (gxStart < int(mHolidayMask->count()) && |
1569 | !mHolidayMask->at(gxStart)) { | 1375 | !mHolidayMask->at(gxStart)) { |
1570 | int xStart = KOGlobals::self()->reverseLayout() ? | 1376 | int xStart = KOGlobals::self()->reverseLayout() ? |
1571 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1377 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1572 | gxStart*mGridSpacingX; | 1378 | gxStart*mGridSpacingX; |
1573 | if (xStart < x1) xStart = x1; | 1379 | if (xStart < x1) xStart = x1; |
1574 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1380 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1575 | (mColumns - gxStart)*mGridSpacingX-1 : | 1381 | (mColumns - gxStart)*mGridSpacingX-1 : |
1576 | (gxStart+1)*mGridSpacingX-1; | 1382 | (gxStart+1)*mGridSpacingX-1; |
1577 | if (xEnd > x2) xEnd = x2; | 1383 | if (xEnd > x2) xEnd = x2; |
1578 | if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) { | 1384 | if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) { |
1579 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1385 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1580 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1386 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1581 | KOPrefs::instance()->mWorkingHoursColor.light()); | 1387 | KOPrefs::instance()->mWorkingHoursColor.light()); |
1582 | else | 1388 | else |
1583 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1389 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1584 | KOPrefs::instance()->mWorkingHoursColor.dark()); | 1390 | KOPrefs::instance()->mWorkingHoursColor.dark()); |
1585 | } else { | 1391 | } else { |
1586 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1392 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1587 | KOPrefs::instance()->mWorkingHoursColor); | 1393 | KOPrefs::instance()->mWorkingHoursColor); |
1588 | } | 1394 | } |
1589 | } | 1395 | } |
1590 | ++gxStart; | 1396 | ++gxStart; |
1591 | } | 1397 | } |
1592 | } | 1398 | } |
1593 | } | 1399 | } |
1594 | /* | 1400 | /* |
1595 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1401 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1596 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1402 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1597 | mSelectionCellX * mGridSpacingX; | 1403 | mSelectionCellX * mGridSpacingX; |
1598 | 1404 | ||
1599 | // Draw selection | 1405 | // Draw selection |
1600 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1406 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1601 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1407 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1602 | // TODO: paint only part within cx,cy,cw,ch | 1408 | // TODO: paint only part within cx,cy,cw,ch |
1603 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, | 1409 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, |
1604 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); | 1410 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); |
1605 | } | 1411 | } |
1606 | */ | 1412 | */ |
1607 | // Draw vertical lines of grid | 1413 | // Draw vertical lines of grid |
1608 | 1414 | ||
1609 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; | 1415 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; |
1610 | if ( mGridSpacingX > 0 ) { | 1416 | if ( mGridSpacingX > 0 ) { |
1611 | while (x < cx + cw) { | 1417 | while (x < cx + cw) { |
1612 | p->drawLine(x,cy,x,cy+ch); | 1418 | p->drawLine(x,cy,x,cy+ch); |
1613 | x+=mGridSpacingX; | 1419 | x+=mGridSpacingX; |
1614 | } | 1420 | } |
1615 | } | 1421 | } |
1616 | // Draw horizontal lines of grid | 1422 | // Draw horizontal lines of grid |
1617 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; | 1423 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; |
1618 | if ( lGridSpacingY > 0 ) { | 1424 | if ( lGridSpacingY > 0 ) { |
1619 | while (y < cy + ch) { | 1425 | while (y < cy + ch) { |
1620 | p->setPen( SolidLine ); | 1426 | p->setPen( SolidLine ); |
1621 | p->drawLine(cx,y,cx+cw,y); | 1427 | p->drawLine(cx,y,cx+cw,y); |
1622 | y+=lGridSpacingY; | 1428 | y+=lGridSpacingY; |
1623 | p->setPen( DotLine ); | 1429 | p->setPen( DotLine ); |
1624 | p->drawLine(cx,y,cx+cw,y); | 1430 | p->drawLine(cx,y,cx+cw,y); |
1625 | y+=lGridSpacingY; | 1431 | y+=lGridSpacingY; |
1626 | } | 1432 | } |
1627 | p->setPen( SolidLine ); | 1433 | p->setPen( SolidLine ); |
1628 | } | 1434 | } |
1629 | mPixPainter.end() ; | 1435 | mPixPainter.end() ; |
1630 | } | 1436 | } |
1631 | 1437 | ||
1632 | /* | 1438 | /* |
1633 | Convert srcollview contents coordinates to agenda grid coordinates. | 1439 | Convert srcollview contents coordinates to agenda grid coordinates. |
1634 | */ | 1440 | */ |
1635 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) | 1441 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) |
1636 | { | 1442 | { |
1637 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : | 1443 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : |
1638 | x/mGridSpacingX; | 1444 | x/mGridSpacingX; |
1639 | gy = y/mGridSpacingY; | 1445 | gy = y/mGridSpacingY; |
1640 | } | 1446 | } |
1641 | 1447 | ||
1642 | /* | 1448 | /* |
1643 | Convert agenda grid coordinates to scrollview contents coordinates. | 1449 | Convert agenda grid coordinates to scrollview contents coordinates. |
1644 | */ | 1450 | */ |
1645 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) | 1451 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) |
1646 | { | 1452 | { |
1647 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: | 1453 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: |
1648 | gx*mGridSpacingX; | 1454 | gx*mGridSpacingX; |
1649 | y = gy*mGridSpacingY; | 1455 | y = gy*mGridSpacingY; |
1650 | } | 1456 | } |
1651 | 1457 | ||
1652 | 1458 | ||
1653 | /* | 1459 | /* |
1654 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into | 1460 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into |
1655 | the grid. | 1461 | the grid. |
1656 | */ | 1462 | */ |
1657 | int KOAgenda::timeToY(const QTime &time) | 1463 | int KOAgenda::timeToY(const QTime &time) |
1658 | { | 1464 | { |
1659 | int minutesPerCell = 24 * 60 / mRows; | 1465 | int minutesPerCell = 24 * 60 / mRows; |
1660 | int timeMinutes = time.hour() * 60 + time.minute(); | 1466 | int timeMinutes = time.hour() * 60 + time.minute(); |
1661 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; | 1467 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; |
1662 | return Y; | 1468 | return Y; |
1663 | } | 1469 | } |
1664 | 1470 | ||
1665 | 1471 | ||
1666 | /* | 1472 | /* |
1667 | Return time corresponding to cell y coordinate. Coordinates are rounded to | 1473 | Return time corresponding to cell y coordinate. Coordinates are rounded to |
1668 | fit into the grid. | 1474 | fit into the grid. |
1669 | */ | 1475 | */ |
1670 | QTime KOAgenda::gyToTime(int gy) | 1476 | QTime KOAgenda::gyToTime(int gy) |
1671 | { | 1477 | { |
1672 | 1478 | ||
1673 | int secondsPerCell = 24 * 60 * 60/ mRows; | 1479 | int secondsPerCell = 24 * 60 * 60/ mRows; |
1674 | 1480 | ||
1675 | int timeSeconds = secondsPerCell * gy; | 1481 | int timeSeconds = secondsPerCell * gy; |
1676 | 1482 | ||
1677 | QTime time( 0, 0, 0 ); | 1483 | QTime time( 0, 0, 0 ); |
1678 | if ( timeSeconds < 24 * 60 * 60 ) { | 1484 | if ( timeSeconds < 24 * 60 * 60 ) { |
1679 | time = time.addSecs(timeSeconds); | 1485 | time = time.addSecs(timeSeconds); |
1680 | } else { | 1486 | } else { |
1681 | time.setHMS( 23, 59, 59 ); | 1487 | time.setHMS( 23, 59, 59 ); |
1682 | } | 1488 | } |
1683 | 1489 | ||
1684 | return time; | 1490 | return time; |
1685 | } | 1491 | } |
1686 | 1492 | ||
1687 | void KOAgenda::setStartHour(int startHour) | 1493 | void KOAgenda::setStartHour(int startHour) |
1688 | { | 1494 | { |
1689 | int startCell = startHour * mRows / 24; | 1495 | int startCell = startHour * mRows / 24; |
1690 | setContentsPos(0,startCell * gridSpacingY()); | 1496 | setContentsPos(0,startCell * gridSpacingY()); |
1691 | } | 1497 | } |
1692 | void KOAgenda::hideUnused() | 1498 | void KOAgenda::hideUnused() |
1693 | { | 1499 | { |
1694 | // experimental only | 1500 | // experimental only |
1695 | // return; | 1501 | // return; |
1696 | KOAgendaItem *item; | 1502 | KOAgendaItem *item; |
1697 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { | 1503 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { |
1698 | item->hide(); | 1504 | item->hide(); |
1699 | } | 1505 | } |
1700 | } | 1506 | } |
1701 | 1507 | ||
1702 | 1508 | ||
1703 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) | 1509 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) |
1704 | { | 1510 | { |
1705 | 1511 | ||
1706 | KOAgendaItem *fi; | 1512 | KOAgendaItem *fi; |
1707 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { | 1513 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { |
1708 | if ( fi->incidence() == event ) { | 1514 | if ( fi->incidence() == event ) { |
1709 | mUnusedItems.remove(); | 1515 | mUnusedItems.remove(); |
1710 | fi->init( event, qd ); | 1516 | fi->init( event, qd ); |
1711 | return fi; | 1517 | return fi; |
1712 | } | 1518 | } |
1713 | } | 1519 | } |
1714 | fi=mUnusedItems.first(); | 1520 | fi=mUnusedItems.first(); |
1715 | if ( fi ) { | 1521 | if ( fi ) { |
1716 | mUnusedItems.remove(); | 1522 | mUnusedItems.remove(); |
1717 | fi->init( event, qd ); | 1523 | fi->init( event, qd ); |
1718 | return fi; | 1524 | return fi; |
1719 | } | 1525 | } |
1720 | // qDebug("new KOAgendaItem "); | 1526 | // qDebug("new KOAgendaItem "); |
1721 | 1527 | ||
1722 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); | 1528 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); |
1723 | agendaItem->installEventFilter(this); | 1529 | agendaItem->installEventFilter(this); |
1724 | addChild(agendaItem,0,0); | 1530 | addChild(agendaItem,0,0); |
1725 | return agendaItem; | 1531 | return agendaItem; |
1726 | } | 1532 | } |
1727 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) | 1533 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) |
1728 | { | 1534 | { |
1729 | KOAgendaItem *item; | 1535 | KOAgendaItem *item; |
1730 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1536 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1731 | if ( item->incidence() == todo ) { | 1537 | if ( item->incidence() == todo ) { |
1732 | mItems.remove(); | 1538 | mItems.remove(); |
1733 | return item; | 1539 | return item; |
1734 | } | 1540 | } |
1735 | } | 1541 | } |
1736 | return 0; | 1542 | return 0; |
1737 | } | 1543 | } |
1738 | 1544 | ||
1739 | 1545 | ||
1740 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) | 1546 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) |
1741 | { | 1547 | { |
1742 | // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| | 1548 | // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| |
1743 | KOAgendaItem *item; | 1549 | KOAgendaItem *item; |
1744 | item = getItemForTodo ( todo ); | 1550 | item = getItemForTodo ( todo ); |
1745 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); | 1551 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); |
1746 | if ( item ) { | 1552 | if ( item ) { |
1747 | blockSignals( true ); | 1553 | blockSignals( true ); |
1748 | //qDebug("item found "); | 1554 | //qDebug("item found "); |
1749 | item->hide(); | 1555 | item->hide(); |
1750 | item->setCellX(-2, -1 ); | 1556 | item->setCellX(-2, -1 ); |
1751 | item->select(false); | 1557 | item->select(false); |
1752 | mUnusedItems.append( item ); | 1558 | mUnusedItems.append( item ); |
1753 | mItems.remove( item ); | 1559 | mItems.remove( item ); |
1754 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1560 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1755 | KOAgendaItem *itemit; | 1561 | KOAgendaItem *itemit; |
1756 | //globalFlagBlockAgendaItemPaint = 1; | 1562 | //globalFlagBlockAgendaItemPaint = 1; |
1757 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1563 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1758 | itemit=oldconflictItems.next() ) { | 1564 | itemit=oldconflictItems.next() ) { |
1759 | if ( itemit != item ) | 1565 | if ( itemit != item ) |
1760 | placeSubCells(itemit); | 1566 | placeSubCells(itemit); |
1761 | } | 1567 | } |
1762 | qApp->processEvents(); | 1568 | qApp->processEvents(); |
1763 | //globalFlagBlockAgendaItemPaint = 0; | 1569 | //globalFlagBlockAgendaItemPaint = 0; |
1764 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1570 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1765 | itemit=oldconflictItems.next() ) { | 1571 | itemit=oldconflictItems.next() ) { |
1766 | globalFlagBlockAgendaItemUpdate = 0; | 1572 | globalFlagBlockAgendaItemUpdate = 0; |
1767 | if ( itemit != item ) | 1573 | if ( itemit != item ) |
1768 | itemit->repaintMe(); | 1574 | itemit->repaintMe(); |
1769 | globalFlagBlockAgendaItemUpdate = 1; | 1575 | globalFlagBlockAgendaItemUpdate = 1; |
1770 | itemit->repaint(); | 1576 | itemit->repaint(); |
1771 | } | 1577 | } |
1772 | blockSignals( false ); | 1578 | blockSignals( false ); |
1773 | } | 1579 | } |
1774 | if ( remove ) { | 1580 | if ( remove ) { |
1775 | //qDebug("remove****************************************** "); | 1581 | //qDebug("remove****************************************** "); |
1776 | return; | 1582 | return; |
1777 | } | 1583 | } |
1778 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); | 1584 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); |
1779 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda ); | 1585 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda ); |
1780 | QDate currentDate; | 1586 | QDate currentDate; |
1781 | QDateTime dt; | 1587 | QDateTime dt; |
1782 | if ( todo->hasCompletedDate() ) | 1588 | if ( todo->hasCompletedDate() ) |
1783 | dt = todo->completed(); | 1589 | dt = todo->completed(); |
1784 | else | 1590 | else |
1785 | dt = todo->dtDue(); | 1591 | dt = todo->dtDue(); |
1786 | if ( overdue ) { | 1592 | if ( overdue ) { |
1787 | currentDate = QDate::currentDate(); | 1593 | currentDate = QDate::currentDate(); |
1788 | days += todo->dtDue().date().daysTo( currentDate ); | 1594 | days += todo->dtDue().date().daysTo( currentDate ); |
1789 | } | 1595 | } |
1790 | else | 1596 | else |
1791 | currentDate = dt.date(); | 1597 | currentDate = dt.date(); |
1792 | 1598 | ||
1793 | if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { | 1599 | if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { |
1794 | if ( ! mAllDayMode ) return; | 1600 | if ( ! mAllDayMode ) return; |
1795 | // aldayagenda | 1601 | // aldayagenda |
1796 | globalFlagBlockAgendaItemPaint = 1; | 1602 | globalFlagBlockAgendaItemPaint = 1; |
1797 | item = insertAllDayItem(todo, currentDate,days, days); | 1603 | item = insertAllDayItem(todo, currentDate,days, days); |
1798 | item->show(); | 1604 | item->show(); |
1799 | 1605 | ||
1800 | } | 1606 | } |
1801 | else { | 1607 | else { |
1802 | if ( mAllDayMode ) return; | 1608 | if ( mAllDayMode ) return; |
1803 | // mAgenda | 1609 | // mAgenda |
1804 | globalFlagBlockAgendaItemPaint = 1; | 1610 | globalFlagBlockAgendaItemPaint = 1; |
1805 | int endY = timeToY(dt.time()) - 1; | 1611 | int endY = timeToY(dt.time()) - 1; |
1806 | int hi = 12/KOPrefs::instance()->mHourSize; | 1612 | int hi = 12/KOPrefs::instance()->mHourSize; |
1807 | int startY = endY - 1-hi; | 1613 | int startY = endY - 1-hi; |
1808 | item = insertItem(todo,currentDate,days,startY,endY); | 1614 | item = insertItem(todo,currentDate,days,startY,endY); |
1809 | item->show(); | 1615 | item->show(); |
1810 | } | 1616 | } |
1811 | qApp->processEvents(); | 1617 | qApp->processEvents(); |
1812 | globalFlagBlockAgendaItemPaint = 0; | 1618 | globalFlagBlockAgendaItemPaint = 0; |
1813 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1619 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1814 | KOAgendaItem *itemit; | 1620 | KOAgendaItem *itemit; |
1815 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1621 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1816 | itemit=oldconflictItems.next() ) { | 1622 | itemit=oldconflictItems.next() ) { |
1817 | globalFlagBlockAgendaItemUpdate = 0; | 1623 | globalFlagBlockAgendaItemUpdate = 0; |
1818 | itemit->repaintMe(); | 1624 | itemit->repaintMe(); |
1819 | globalFlagBlockAgendaItemUpdate = 1; | 1625 | globalFlagBlockAgendaItemUpdate = 1; |
1820 | itemit->repaint(); | 1626 | itemit->repaint(); |
1821 | } | 1627 | } |
1822 | globalFlagBlockAgendaItemUpdate = 0; | 1628 | globalFlagBlockAgendaItemUpdate = 0; |
1823 | item->repaintMe(); | 1629 | item->repaintMe(); |
1824 | globalFlagBlockAgendaItemUpdate = 1; | 1630 | globalFlagBlockAgendaItemUpdate = 1; |
1825 | item->repaint(); | 1631 | item->repaint(); |
1826 | } | 1632 | } |
1827 | /* | 1633 | /* |
1828 | Insert KOAgendaItem into agenda. | 1634 | Insert KOAgendaItem into agenda. |
1829 | */ | 1635 | */ |
1830 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) | 1636 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) |
1831 | { | 1637 | { |
1832 | if (mAllDayMode) { | 1638 | if (mAllDayMode) { |
1833 | qDebug("KOAgenda: calling insertItem in all-day mode is illegal. "); | 1639 | qDebug("KOAgenda: calling insertItem in all-day mode is illegal. "); |
1834 | return 0; | 1640 | return 0; |
1835 | } | 1641 | } |
1836 | 1642 | ||
1837 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1643 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1838 | //agendaItem->setFrameStyle(WinPanel|Raised); | 1644 | //agendaItem->setFrameStyle(WinPanel|Raised); |
1839 | 1645 | ||
1840 | int YSize = YBottom - YTop + 1; | 1646 | int YSize = YBottom - YTop + 1; |
1841 | if (YSize < 0) { | 1647 | if (YSize < 0) { |
1842 | YSize = 1; | 1648 | YSize = 1; |
1843 | } | 1649 | } |
1844 | int iheight = mGridSpacingY * YSize; | 1650 | int iheight = mGridSpacingY * YSize; |
1845 | 1651 | ||
1846 | agendaItem->resize(mGridSpacingX,iheight ); | 1652 | agendaItem->resize(mGridSpacingX,iheight ); |
1847 | agendaItem->setCellXY(X,YTop,YBottom); | 1653 | agendaItem->setCellXY(X,YTop,YBottom); |
1848 | agendaItem->setCellXWidth(X); | 1654 | agendaItem->setCellXWidth(X); |
1849 | 1655 | ||
1850 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); | 1656 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); |
1851 | mItems.append(agendaItem); | 1657 | mItems.append(agendaItem); |
1852 | 1658 | ||
1853 | placeSubCells(agendaItem); | 1659 | placeSubCells(agendaItem); |
1854 | 1660 | ||
1855 | //agendaItem->show(); | 1661 | //agendaItem->show(); |
1856 | 1662 | ||
1857 | marcus_bains(); | 1663 | marcus_bains(); |
1858 | 1664 | ||
1859 | return agendaItem; | 1665 | return agendaItem; |
1860 | } | 1666 | } |
1861 | 1667 | ||
1862 | 1668 | ||
1863 | /* | 1669 | /* |
1864 | Insert all-day KOAgendaItem into agenda. | 1670 | Insert all-day KOAgendaItem into agenda. |
1865 | */ | 1671 | */ |
1866 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) | 1672 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) |
1867 | { | 1673 | { |
1868 | if (!mAllDayMode) { | 1674 | if (!mAllDayMode) { |
1869 | return 0; | 1675 | return 0; |
1870 | } | 1676 | } |
1871 | 1677 | ||
1872 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1678 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1873 | 1679 | ||
1874 | agendaItem->setCellXY(XBegin,0,0); | 1680 | agendaItem->setCellXY(XBegin,0,0); |
1875 | agendaItem->setCellXWidth(XEnd); | 1681 | agendaItem->setCellXWidth(XEnd); |
1876 | agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); | 1682 | agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); |
1877 | 1683 | ||
1878 | //addChild(agendaItem,XBegin*mGridSpacingX,0); | 1684 | //addChild(agendaItem,XBegin*mGridSpacingX,0); |
1879 | mItems.append(agendaItem); | 1685 | mItems.append(agendaItem); |
1880 | 1686 | ||
1881 | placeSubCells(agendaItem); | 1687 | placeSubCells(agendaItem); |
1882 | 1688 | ||
1883 | //agendaItem->show(); | 1689 | //agendaItem->show(); |
1884 | 1690 | ||
1885 | return agendaItem; | 1691 | return agendaItem; |
1886 | } | 1692 | } |
1887 | 1693 | ||
1888 | 1694 | ||
1889 | void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, | 1695 | void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, |
1890 | int YTop,int YBottom) | 1696 | int YTop,int YBottom) |
1891 | { | 1697 | { |
1892 | if (mAllDayMode) { | 1698 | if (mAllDayMode) { |
1893 | ; | 1699 | ; |
1894 | return; | 1700 | return; |
1895 | } | 1701 | } |
1896 | 1702 | ||
1897 | int cellX,cellYTop,cellYBottom; | 1703 | int cellX,cellYTop,cellYBottom; |
1898 | QString newtext; | 1704 | QString newtext; |
1899 | int width = XEnd - XBegin + 1; | 1705 | int width = XEnd - XBegin + 1; |
1900 | int count = 0; | 1706 | int count = 0; |
1901 | KOAgendaItem *current = 0; | 1707 | KOAgendaItem *current = 0; |
1902 | QPtrList<KOAgendaItem> multiItems; | 1708 | QPtrList<KOAgendaItem> multiItems; |
1903 | for (cellX = XBegin;cellX <= XEnd;++cellX) { | 1709 | for (cellX = XBegin;cellX <= XEnd;++cellX) { |
1904 | if (cellX == XBegin) cellYTop = YTop; | 1710 | if (cellX == XBegin) cellYTop = YTop; |
1905 | else cellYTop = 0; | 1711 | else cellYTop = 0; |
1906 | if (cellX == XEnd) cellYBottom = YBottom; | 1712 | if (cellX == XEnd) cellYBottom = YBottom; |
1907 | else cellYBottom = rows() - 1; | 1713 | else cellYBottom = rows() - 1; |
1908 | newtext = QString("(%1/%2): ").arg(++count).arg(width); | 1714 | newtext = QString("(%1/%2): ").arg(++count).arg(width); |
1909 | newtext.append(event->summary()); | 1715 | newtext.append(event->summary()); |
1910 | current = insertItem(event,qd,cellX,cellYTop,cellYBottom); | 1716 | current = insertItem(event,qd,cellX,cellYTop,cellYBottom); |
1911 | current->setText(newtext); | 1717 | current->setText(newtext); |
1912 | multiItems.append(current); | 1718 | multiItems.append(current); |
1913 | } | 1719 | } |
1914 | 1720 | ||
1915 | KOAgendaItem *next = 0; | 1721 | KOAgendaItem *next = 0; |
1916 | KOAgendaItem *last = multiItems.last(); | 1722 | KOAgendaItem *last = multiItems.last(); |
1917 | KOAgendaItem *first = multiItems.first(); | 1723 | KOAgendaItem *first = multiItems.first(); |
1918 | KOAgendaItem *setFirst,*setLast; | 1724 | KOAgendaItem *setFirst,*setLast; |
1919 | current = first; | 1725 | current = first; |
1920 | while (current) { | 1726 | while (current) { |
1921 | next = multiItems.next(); | 1727 | next = multiItems.next(); |
1922 | if (current == first) setFirst = 0; | 1728 | if (current == first) setFirst = 0; |
1923 | else setFirst = first; | 1729 | else setFirst = first; |
1924 | if (current == last) setLast = 0; | 1730 | if (current == last) setLast = 0; |
1925 | else setLast = last; | 1731 | else setLast = last; |
1926 | 1732 | ||
1927 | current->setMultiItem(setFirst,next,setLast); | 1733 | current->setMultiItem(setFirst,next,setLast); |
1928 | current = next; | 1734 | current = next; |
1929 | } | 1735 | } |
1930 | 1736 | ||
1931 | marcus_bains(); | 1737 | marcus_bains(); |
1932 | } | 1738 | } |
1933 | 1739 | ||
1934 | 1740 | ||
1935 | //QSizePolicy KOAgenda::sizePolicy() const | 1741 | //QSizePolicy KOAgenda::sizePolicy() const |
1936 | //{ | 1742 | //{ |
1937 | // Thought this would make the all-day event agenda minimum size and the | 1743 | // Thought this would make the all-day event agenda minimum size and the |
1938 | // normal agenda take the remaining space. But it doesn´t work. The QSplitter | 1744 | // normal agenda take the remaining space. But it doesn´t work. The QSplitter |
1939 | // don´t seem to think that an Expanding widget needs more space than a | 1745 | // don´t seem to think that an Expanding widget needs more space than a |
1940 | // Preferred one. | 1746 | // Preferred one. |
1941 | // But it doesn´t hurt, so it stays. | 1747 | // But it doesn´t hurt, so it stays. |
1942 | // if (mAllDayMode) { | 1748 | // if (mAllDayMode) { |
1943 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); | 1749 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); |
1944 | // } else { | 1750 | // } else { |
1945 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); | 1751 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); |
1946 | // } | 1752 | // } |
1947 | //} | 1753 | //} |
1948 | void KOAgenda::finishResize ( ) | 1754 | void KOAgenda::finishResize ( ) |
1949 | { | 1755 | { |
1950 | //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); | 1756 | //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); |
1951 | if ( globalFlagBlockAgenda == 0 ) { | 1757 | if ( globalFlagBlockAgenda == 0 ) { |
1952 | finishUpdate(); | 1758 | finishUpdate(); |
1953 | //qDebug("finishUpdate() called "); | 1759 | //qDebug("finishUpdate() called "); |
1954 | } | 1760 | } |
1955 | } | 1761 | } |
1956 | /* | 1762 | /* |
1957 | Overridden from QScrollView to provide proper resizing of KOAgendaItems. | 1763 | Overridden from QScrollView to provide proper resizing of KOAgendaItems. |
1958 | */ | 1764 | */ |
1959 | void KOAgenda::resizeEvent ( QResizeEvent *ev ) | 1765 | void KOAgenda::resizeEvent ( QResizeEvent *ev ) |
1960 | { | 1766 | { |
1961 | mSelectionHeight = 0; | 1767 | mSelectionHeight = 0; |
1962 | mResizeTimer.start( 150 , true ); | 1768 | mResizeTimer.start( 150 , true ); |
1963 | computeSizes(); | 1769 | computeSizes(); |
1964 | return; | 1770 | return; |
1965 | 1771 | ||
1966 | } | 1772 | } |
1967 | void KOAgenda::computeSizes() | 1773 | void KOAgenda::computeSizes() |
1968 | { | 1774 | { |
1969 | if ( globalFlagBlockStartup ) | 1775 | if ( globalFlagBlockStartup ) |
1970 | return; | 1776 | return; |
1971 | int frameOffset = frameWidth() * 2 +1; | 1777 | int frameOffset = frameWidth() * 2 +1; |
1972 | if (mAllDayMode) { | 1778 | if (mAllDayMode) { |
1973 | mGridSpacingX = (width()-frameOffset) / mColumns; | 1779 | mGridSpacingX = (width()-frameOffset) / mColumns; |
1974 | mGridSpacingY = height() - 2 * frameWidth() - 1; | 1780 | mGridSpacingY = height() - 2 * frameWidth() - 1; |
1975 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); | 1781 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); |
1976 | // mGridSpacingY = height(); | 1782 | // mGridSpacingY = height(); |
1977 | // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1783 | // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1978 | 1784 | ||
1979 | KOAgendaItem *item; | 1785 | KOAgendaItem *item; |
1980 | int subCellWidth; | 1786 | int subCellWidth; |
1981 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1787 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1982 | subCellWidth = mGridSpacingY / item->subCells(); | 1788 | subCellWidth = mGridSpacingY / item->subCells(); |
1983 | item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); | 1789 | item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); |
1984 | moveChild(item,KOGlobals::self()->reverseLayout() ? | 1790 | moveChild(item,KOGlobals::self()->reverseLayout() ? |
1985 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | 1791 | (mColumns - 1 - item->cellX()) * mGridSpacingX : |
1986 | item->cellX() * mGridSpacingX, | 1792 | item->cellX() * mGridSpacingX, |
1987 | item->subCell() * subCellWidth); | 1793 | item->subCell() * subCellWidth); |
1988 | } | 1794 | } |
1989 | KOPrefs::instance()->mAllDaySize = mGridSpacingY; | 1795 | KOPrefs::instance()->mAllDaySize = mGridSpacingY; |
1990 | } else { | 1796 | } else { |
1991 | mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns; | 1797 | mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns; |
1992 | if (height() > mGridSpacingY * mRows + 1 ) { | 1798 | if (height() > mGridSpacingY * mRows + 1 ) { |
1993 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; | 1799 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; |
1994 | mGridSpacingY = KOPrefs::instance()->mHourSize ; | 1800 | mGridSpacingY = KOPrefs::instance()->mHourSize ; |
1995 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1801 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1996 | emit resizedSignal(); | 1802 | emit resizedSignal(); |
1997 | } else | 1803 | } else |
1998 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1804 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1999 | KOAgendaItem *item; | 1805 | KOAgendaItem *item; |
2000 | int subCellWidth; | 1806 | int subCellWidth; |
2001 | 1807 | ||
2002 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1808 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
2003 | subCellWidth = mGridSpacingX / item->subCells(); | 1809 | subCellWidth = mGridSpacingX / item->subCells(); |
2004 | item->resize(subCellWidth,item->height()); | 1810 | item->resize(subCellWidth,item->height()); |
2005 | moveChild(item,(KOGlobals::self()->reverseLayout() ? | 1811 | moveChild(item,(KOGlobals::self()->reverseLayout() ? |
2006 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | 1812 | (mColumns - 1 - item->cellX()) * mGridSpacingX : |
2007 | item->cellX() * mGridSpacingX) + | 1813 | item->cellX() * mGridSpacingX) + |
2008 | item->subCell() * subCellWidth,childY(item)); | 1814 | item->subCell() * subCellWidth,childY(item)); |
2009 | } | 1815 | } |
2010 | } | 1816 | } |
2011 | int cw = contentsWidth(); | 1817 | int cw = contentsWidth(); |
2012 | int ch = contentsHeight(); | 1818 | int ch = contentsHeight(); |
2013 | if ( mAllDayMode ) { | 1819 | if ( mAllDayMode ) { |
2014 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); | 1820 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); |
2015 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) | 1821 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) |
2016 | paintPixAll->resize( cw, ch ); | 1822 | paintPixAll->resize( cw, ch ); |
2017 | } else { | 1823 | } else { |
2018 | QPixmap* paintPix = KOAgendaItem::paintPix(); | 1824 | QPixmap* paintPix = KOAgendaItem::paintPix(); |
2019 | if ( paintPix->width() < cw || paintPix->height() < ch ) | 1825 | if ( paintPix->width() < cw || paintPix->height() < ch ) |
2020 | KOAgendaItem::resizePixmap( cw , ch ); | 1826 | KOAgendaItem::resizePixmap( cw , ch ); |
2021 | } | 1827 | } |
2022 | 1828 | ||
2023 | checkScrollBoundaries(); | 1829 | checkScrollBoundaries(); |
2024 | marcus_bains(); | 1830 | marcus_bains(); |
2025 | drawContentsToPainter(); | 1831 | drawContentsToPainter(); |
2026 | viewport()->repaint(false); | 1832 | viewport()->repaint(false); |
2027 | } | 1833 | } |
2028 | 1834 | ||
2029 | void KOAgenda::scrollUp() | 1835 | void KOAgenda::scrollUp() |
2030 | { | 1836 | { |
2031 | scrollBy(0,-mScrollOffset); | 1837 | scrollBy(0,-mScrollOffset); |
2032 | } | 1838 | } |
2033 | 1839 | ||
2034 | 1840 | ||
2035 | void KOAgenda::scrollDown() | 1841 | void KOAgenda::scrollDown() |
2036 | { | 1842 | { |
2037 | scrollBy(0,mScrollOffset); | 1843 | scrollBy(0,mScrollOffset); |
2038 | } | 1844 | } |
2039 | 1845 | ||
2040 | void KOAgenda::popupAlarm() | 1846 | void KOAgenda::popupAlarm() |
2041 | { | 1847 | { |
2042 | if (!mClickedItem) { | 1848 | if (!mClickedItem) { |
2043 | qDebug("KOAgenda::popupAlarm() called without having a clicked item "); | 1849 | qDebug("KOAgenda::popupAlarm() called without having a clicked item "); |
2044 | return; | 1850 | return; |
2045 | } | 1851 | } |
2046 | // TODO: deal correctly with multiple alarms | 1852 | // TODO: deal correctly with multiple alarms |
2047 | Alarm* alarm; | 1853 | Alarm* alarm; |
2048 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); | 1854 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); |
2049 | for(alarm=list.first();alarm;alarm=list.next()) { | 1855 | for(alarm=list.first();alarm;alarm=list.next()) { |
2050 | alarm->toggleAlarm(); | 1856 | alarm->toggleAlarm(); |
2051 | } | 1857 | } |
2052 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); | 1858 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); |
2053 | mClickedItem->paintMe( true ); | 1859 | mClickedItem->paintMe( true ); |
2054 | mClickedItem->repaint( false ); | 1860 | mClickedItem->repaint( false ); |
2055 | } | 1861 | } |
2056 | 1862 | ||
2057 | /* | 1863 | /* |
2058 | Calculates the minimum width | 1864 | Calculates the minimum width |
2059 | */ | 1865 | */ |
2060 | int KOAgenda::minimumWidth() const | 1866 | int KOAgenda::minimumWidth() const |
2061 | { | 1867 | { |
2062 | // TODO:: develop a way to dynamically determine the minimum width | 1868 | // TODO:: develop a way to dynamically determine the minimum width |
2063 | int min = 100; | 1869 | int min = 100; |
2064 | 1870 | ||
2065 | return min; | 1871 | return min; |
2066 | } | 1872 | } |
2067 | 1873 | ||
2068 | void KOAgenda::updateConfig() | 1874 | void KOAgenda::updateConfig() |
2069 | { | 1875 | { |
2070 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) | 1876 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) |
2071 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); | 1877 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); |
2072 | if ( mAllDayMode ) { | 1878 | if ( mAllDayMode ) { |
2073 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; | 1879 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; |
2074 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; | 1880 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; |
2075 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); | 1881 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); |
2076 | // setMaximumHeight( mGridSpacingY+1 ); | 1882 | // setMaximumHeight( mGridSpacingY+1 ); |
2077 | viewport()->repaint( false ); | 1883 | viewport()->repaint( false ); |
2078 | //setFixedHeight( mGridSpacingY+1 ); | 1884 | //setFixedHeight( mGridSpacingY+1 ); |
2079 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); | 1885 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); |
2080 | } | 1886 | } |
2081 | else { | 1887 | else { |
2082 | mGridSpacingY = KOPrefs::instance()->mHourSize; | 1888 | mGridSpacingY = KOPrefs::instance()->mHourSize; |
2083 | calculateWorkingHours(); | 1889 | calculateWorkingHours(); |
2084 | marcus_bains(); | 1890 | marcus_bains(); |
2085 | } | 1891 | } |
2086 | } | 1892 | } |
2087 | 1893 | ||
2088 | void KOAgenda::checkScrollBoundaries() | 1894 | void KOAgenda::checkScrollBoundaries() |
2089 | { | 1895 | { |
2090 | // Invalidate old values to force update | 1896 | // Invalidate old values to force update |
2091 | mOldLowerScrollValue = -1; | 1897 | mOldLowerScrollValue = -1; |
2092 | mOldUpperScrollValue = -1; | 1898 | mOldUpperScrollValue = -1; |
2093 | 1899 | ||
2094 | checkScrollBoundaries(verticalScrollBar()->value()); | 1900 | checkScrollBoundaries(verticalScrollBar()->value()); |
2095 | } | 1901 | } |
2096 | 1902 | ||
2097 | void KOAgenda::checkScrollBoundaries(int v) | 1903 | void KOAgenda::checkScrollBoundaries(int v) |
2098 | { | 1904 | { |
2099 | if ( mGridSpacingY == 0 ) | 1905 | if ( mGridSpacingY == 0 ) |
2100 | return; | 1906 | return; |
2101 | int yMin = v/mGridSpacingY; | 1907 | int yMin = v/mGridSpacingY; |
2102 | int yMax = (v+visibleHeight())/mGridSpacingY; | 1908 | int yMax = (v+visibleHeight())/mGridSpacingY; |
2103 | 1909 | ||
2104 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; | 1910 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; |
2105 | 1911 | ||
2106 | if (yMin != mOldLowerScrollValue) { | 1912 | if (yMin != mOldLowerScrollValue) { |
2107 | mOldLowerScrollValue = yMin; | 1913 | mOldLowerScrollValue = yMin; |
2108 | emit lowerYChanged(yMin); | 1914 | emit lowerYChanged(yMin); |
2109 | } | 1915 | } |
2110 | if (yMax != mOldUpperScrollValue) { | 1916 | if (yMax != mOldUpperScrollValue) { |
2111 | mOldUpperScrollValue = yMax; | 1917 | mOldUpperScrollValue = yMax; |
2112 | emit upperYChanged(yMax); | 1918 | emit upperYChanged(yMax); |
2113 | } | 1919 | } |
2114 | } | 1920 | } |
2115 | 1921 | ||
2116 | void KOAgenda::deselectItem() | 1922 | void KOAgenda::deselectItem() |
2117 | { | 1923 | { |
2118 | if (mSelectedItem.isNull()) return; | 1924 | if (mSelectedItem.isNull()) return; |
2119 | mSelectedItem->select(false); | 1925 | mSelectedItem->select(false); |
2120 | mSelectedItem = 0; | 1926 | mSelectedItem = 0; |
2121 | } | 1927 | } |
2122 | 1928 | ||
2123 | void KOAgenda::selectItem(KOAgendaItem *item) | 1929 | void KOAgenda::selectItem(KOAgendaItem *item) |
2124 | { | 1930 | { |
2125 | if ((KOAgendaItem *)mSelectedItem == item) return; | 1931 | if ((KOAgendaItem *)mSelectedItem == item) return; |
2126 | deselectItem(); | 1932 | deselectItem(); |
2127 | if (item == 0) { | 1933 | if (item == 0) { |
2128 | emit incidenceSelected( 0 ); | 1934 | emit incidenceSelected( 0 ); |
2129 | return; | 1935 | return; |
2130 | } | 1936 | } |
2131 | mSelectedItem = item; | 1937 | mSelectedItem = item; |
2132 | mSelectedItem->select(); | 1938 | mSelectedItem->select(); |
2133 | emit incidenceSelected( mSelectedItem->incidence() ); | 1939 | emit incidenceSelected( mSelectedItem->incidence() ); |
2134 | } | 1940 | } |
2135 | 1941 | ||
2136 | // This function seems never be called. | 1942 | // This function seems never be called. |
2137 | void KOAgenda::keyPressEvent( QKeyEvent *kev ) | 1943 | void KOAgenda::keyPressEvent( QKeyEvent *kev ) |
2138 | { | 1944 | { |
2139 | switch(kev->key()) { | 1945 | switch(kev->key()) { |
2140 | case Key_PageDown: | 1946 | case Key_PageDown: |
2141 | verticalScrollBar()->addPage(); | 1947 | verticalScrollBar()->addPage(); |
2142 | break; | 1948 | break; |
2143 | case Key_PageUp: | 1949 | case Key_PageUp: |
2144 | verticalScrollBar()->subtractPage(); | 1950 | verticalScrollBar()->subtractPage(); |
2145 | break; | 1951 | break; |
2146 | case Key_Down: | 1952 | case Key_Down: |
2147 | verticalScrollBar()->addLine(); | 1953 | verticalScrollBar()->addLine(); |
2148 | break; | 1954 | break; |
2149 | case Key_Up: | 1955 | case Key_Up: |
2150 | verticalScrollBar()->subtractLine(); | 1956 | verticalScrollBar()->subtractLine(); |
2151 | break; | 1957 | break; |
2152 | default: | 1958 | default: |
2153 | ; | 1959 | ; |
2154 | } | 1960 | } |
2155 | } | 1961 | } |
2156 | 1962 | ||
2157 | void KOAgenda::calculateWorkingHours() | 1963 | void KOAgenda::calculateWorkingHours() |
2158 | { | 1964 | { |
2159 | // mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; | 1965 | // mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; |
2160 | mWorkingHoursEnable = !mAllDayMode; | 1966 | mWorkingHoursEnable = !mAllDayMode; |
2161 | 1967 | ||
2162 | mWorkingHoursYTop = mGridSpacingY * | 1968 | mWorkingHoursYTop = mGridSpacingY * |
2163 | KOPrefs::instance()->mWorkingHoursStart * 4; | 1969 | KOPrefs::instance()->mWorkingHoursStart * 4; |
2164 | mWorkingHoursYBottom = mGridSpacingY * | 1970 | mWorkingHoursYBottom = mGridSpacingY * |
2165 | KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; | 1971 | KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; |
2166 | } | 1972 | } |
2167 | 1973 | ||
2168 | 1974 | ||
2169 | DateList KOAgenda::dateList() const | 1975 | DateList KOAgenda::dateList() const |
2170 | { | 1976 | { |
2171 | return mSelectedDates; | 1977 | return mSelectedDates; |
2172 | } | 1978 | } |
2173 | 1979 | ||
2174 | void KOAgenda::setDateList(const DateList &selectedDates) | 1980 | void KOAgenda::setDateList(const DateList &selectedDates) |
2175 | { | 1981 | { |
2176 | mSelectedDates = selectedDates; | 1982 | mSelectedDates = selectedDates; |
2177 | marcus_bains(); | 1983 | marcus_bains(); |
2178 | } | 1984 | } |
2179 | 1985 | ||
2180 | void KOAgenda::setHolidayMask(QMemArray<bool> *mask) | 1986 | void KOAgenda::setHolidayMask(QMemArray<bool> *mask) |
2181 | { | 1987 | { |
2182 | mHolidayMask = mask; | 1988 | mHolidayMask = mask; |
2183 | 1989 | ||
2184 | /* | 1990 | /* |
2185 | kdDebug() << "HolidayMask: "; | 1991 | kdDebug() << "HolidayMask: "; |
2186 | for(uint i=0;i<mask->count();++i) { | 1992 | for(uint i=0;i<mask->count();++i) { |
2187 | kdDebug() << (mask->at(i) ? "*" : "o"); | 1993 | kdDebug() << (mask->at(i) ? "*" : "o"); |
2188 | } | 1994 | } |
2189 | kdDebug() << endl; | 1995 | kdDebug() << endl; |
2190 | */ | 1996 | */ |
2191 | } | 1997 | } |
2192 | 1998 | ||
2193 | void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) | 1999 | void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) |
2194 | { | 2000 | { |
2195 | 2001 | ||
2196 | QScrollView::contentsMousePressEvent(event); | 2002 | QScrollView::contentsMousePressEvent(event); |
2197 | } | 2003 | } |
2198 | 2004 | ||
2199 | void KOAgenda::storePosition() | 2005 | void KOAgenda::storePosition() |
2200 | { | 2006 | { |
2201 | //mContentPosition | 2007 | //mContentPosition |
2202 | int max = mGridSpacingY*4*24; | 2008 | int max = mGridSpacingY*4*24; |
2203 | if ( contentsY() < 5 && max > viewport()->height()*3/2 ) | 2009 | if ( contentsY() < 5 && max > viewport()->height()*3/2 ) |
2204 | mContentPosition = 0; | 2010 | mContentPosition = 0; |
2205 | else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) | 2011 | else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) |
2206 | mContentPosition = -1.0; | 2012 | mContentPosition = -1.0; |
2207 | else | 2013 | else |
2208 | mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); | 2014 | mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); |
2209 | //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); | 2015 | //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); |
2210 | 2016 | ||
2211 | } | 2017 | } |
2212 | void KOAgenda::restorePosition() | 2018 | void KOAgenda::restorePosition() |
2213 | { | 2019 | { |
2214 | int posY; | 2020 | int posY; |
2215 | int max = mGridSpacingY*4*24; | 2021 | int max = mGridSpacingY*4*24; |
2216 | if ( mContentPosition < 0 ) | 2022 | if ( mContentPosition < 0 ) |
2217 | posY = max-viewport()->height(); | 2023 | posY = max-viewport()->height(); |
2218 | else | 2024 | else |
2219 | if ( mContentPosition == 0 ) | 2025 | if ( mContentPosition == 0 ) |
2220 | posY = 0; | 2026 | posY = 0; |
2221 | else | 2027 | else |
2222 | posY = (max/mContentPosition)-(viewport()->height()/2); | 2028 | posY = (max/mContentPosition)-(viewport()->height()/2); |
2223 | setContentsPos (0, posY ); | 2029 | setContentsPos (0, posY ); |
2224 | //qDebug("posY %d hei %d", posY, max); | 2030 | //qDebug("posY %d hei %d", posY, max); |
2225 | 2031 | ||
2226 | } | 2032 | } |
2227 | void KOAgenda::moveChild( QWidget *w, int x , int y ) | 2033 | void KOAgenda::moveChild( QWidget *w, int x , int y ) |
2228 | { | 2034 | { |
2229 | ++x; | 2035 | ++x; |
2230 | QScrollView::moveChild( w, x , y ); | 2036 | QScrollView::moveChild( w, x , y ); |
2231 | } | 2037 | } |
2232 | #include <qmessagebox.h> | 2038 | #include <qmessagebox.h> |
2233 | #ifdef DESKTOP_VERSION | 2039 | #ifdef DESKTOP_VERSION |
2234 | #include <qprinter.h> | 2040 | #include <qprinter.h> |
2235 | #include <qpainter.h> | 2041 | #include <qpainter.h> |
2236 | #include <qpaintdevicemetrics.h> | 2042 | #include <qpaintdevicemetrics.h> |
2237 | 2043 | ||
2238 | #endif | 2044 | #endif |
2239 | void KOAgenda::printSelection() | 2045 | void KOAgenda::printSelection() |
2240 | { | 2046 | { |
2241 | #ifdef DESKTOP_VERSION | 2047 | #ifdef DESKTOP_VERSION |
2242 | if ( mStartCellY == mCurrentCellY ) { | 2048 | if ( mStartCellY == mCurrentCellY ) { |
2243 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2049 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2244 | i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "), | 2050 | i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "), |
2245 | i18n("OK"), 0, 0, | 2051 | i18n("OK"), 0, 0, |
2246 | 0, 1 ); | 2052 | 0, 1 ); |
2247 | return; | 2053 | return; |
2248 | } | 2054 | } |
2249 | 2055 | ||
2250 | float dx, dy; | 2056 | float dx, dy; |
2251 | int x,y,w,h; | 2057 | int x,y,w,h; |
2252 | x= 0; | 2058 | x= 0; |
2253 | w= contentsWidth()+2; | 2059 | w= contentsWidth()+2; |
2254 | // h= contentsHeight(); | 2060 | // h= contentsHeight(); |
2255 | y = mGridSpacingY*mStartCellY; | 2061 | y = mGridSpacingY*mStartCellY; |
2256 | h = mGridSpacingY*(mCurrentCellY+1)-y+2; | 2062 | h = mGridSpacingY*(mCurrentCellY+1)-y+2; |
2257 | 2063 | ||
2258 | //return; | 2064 | //return; |
2259 | QPrinter* printer = new QPrinter(); | 2065 | QPrinter* printer = new QPrinter(); |
2260 | if ( !printer->setup()) { | 2066 | if ( !printer->setup()) { |
2261 | delete printer; | 2067 | delete printer; |
2262 | return; | 2068 | return; |
2263 | } | 2069 | } |
2264 | QPainter p( printer ); | 2070 | QPainter p( printer ); |
2265 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer ); | 2071 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer ); |
2266 | QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() ); | 2072 | QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() ); |
2267 | //date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true ); | 2073 | //date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true ); |
2268 | int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height(); | 2074 | int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height(); |
2269 | // p.drawText( 0, 0, date ); | 2075 | // p.drawText( 0, 0, date ); |
2270 | int offset = m.width()/8; | 2076 | int offset = m.width()/8; |
2271 | // compute the scale | 2077 | // compute the scale |
2272 | dx = ((float) m.width()-offset) / (float)w; | 2078 | dx = ((float) m.width()-offset) / (float)w; |
2273 | dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h; | 2079 | dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h; |
2274 | float scale; | 2080 | float scale; |
2275 | // scale to fit the width or height of the paper | 2081 | // scale to fit the width or height of the paper |
2276 | if ( dx < dy ) | 2082 | if ( dx < dy ) |
2277 | scale = dx; | 2083 | scale = dx; |
2278 | else | 2084 | else |
2279 | scale = dy; | 2085 | scale = dy; |
2280 | // set the scale | 2086 | // set the scale |
2281 | p.drawText( offset* scale, offset* scale*3/4, date ); | 2087 | p.drawText( offset* scale, offset* scale*3/4, date ); |
2282 | 2088 | ||
2283 | int selDay; | 2089 | int selDay; |
2284 | float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count())); | 2090 | float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count())); |
2285 | float startX = 1; | 2091 | float startX = 1; |
2286 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) | 2092 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) |
2287 | { | 2093 | { |
2288 | QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true ); | 2094 | QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true ); |
2289 | p.setClipRect(offset* scale+startX , 0, widOffset-4, offset* scale+(2*hei* scale) ); | 2095 | p.setClipRect(offset* scale+startX , 0, widOffset-4, offset* scale+(2*hei* scale) ); |
2290 | p.drawText( offset* scale+startX, (offset+hei)* scale, text ); | 2096 | p.drawText( offset* scale+startX, (offset+hei)* scale, text ); |
2291 | startX += widOffset; | 2097 | startX += widOffset; |
2292 | 2098 | ||
2293 | } | 2099 | } |
2294 | p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale)); | 2100 | p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale)); |
2295 | p.scale( scale, scale ); | 2101 | p.scale( scale, scale ); |
2296 | p.setClipRect( offset* scale, offset* scale+(2*hei* scale), w*scale, h*scale ); | 2102 | p.setClipRect( offset* scale, offset* scale+(2*hei* scale), w*scale, h*scale ); |
2297 | // now printing with y offset: 2 hei | 2103 | // now printing with y offset: 2 hei |
2298 | // p.translate( 0, -y*scale); | 2104 | // p.translate( 0, -y*scale); |
2299 | 2105 | ||
2300 | drawContentsToPainter(&p, true ); | 2106 | drawContentsToPainter(&p, true ); |
2301 | globalFlagBlockAgendaItemUpdate = false; | 2107 | globalFlagBlockAgendaItemUpdate = false; |
2302 | KOAgendaItem *item; | 2108 | KOAgendaItem *item; |
2303 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 2109 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
2304 | item->select(false); | 2110 | item->select(false); |
2305 | item->paintMe( false, &p ); | 2111 | item->paintMe( false, &p ); |
2306 | } | 2112 | } |
2307 | globalFlagBlockAgendaItemUpdate = true; | 2113 | globalFlagBlockAgendaItemUpdate = true; |
2308 | p.end(); | 2114 | p.end(); |
2309 | delete printer; | 2115 | delete printer; |
2310 | #else | 2116 | #else |
2311 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2117 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2312 | i18n("Not supported \non PDA!\n"), | 2118 | i18n("Not supported \non PDA!\n"), |
2313 | i18n("OK"), 0, 0, | 2119 | i18n("OK"), 0, 0, |
2314 | 0, 1 ); | 2120 | 0, 1 ); |
2315 | #endif | 2121 | #endif |
2316 | } | 2122 | } |
diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h index 4f1fdb9..fb9983e 100644 --- a/korganizer/koagenda.h +++ b/korganizer/koagenda.h | |||
@@ -1,298 +1,300 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef KOAGENDA_H | 23 | #ifndef KOAGENDA_H |
24 | #define KOAGENDA_H | 24 | #define KOAGENDA_H |
25 | 25 | ||
26 | #include <qscrollview.h> | 26 | #include <qscrollview.h> |
27 | #include <qtimer.h> | 27 | #include <qtimer.h> |
28 | #include <qmemarray.h> | 28 | #include <qmemarray.h> |
29 | #include <qpainter.h> | 29 | #include <qpainter.h> |
30 | #include <qpixmap.h> | 30 | #include <qpixmap.h> |
31 | #include <qguardedptr.h> | 31 | #include <qguardedptr.h> |
32 | 32 | ||
33 | #include "koagendaitem.h" | 33 | #include "koagendaitem.h" |
34 | #include "koeventview.h" | 34 | #include "koeventview.h" |
35 | 35 | ||
36 | class QPopupMenu; | 36 | class QPopupMenu; |
37 | class QTime; | 37 | class QTime; |
38 | class KConfig; | 38 | class KConfig; |
39 | class QFrame; | 39 | class QFrame; |
40 | class KOAgenda; | 40 | class KOAgenda; |
41 | class KCal::Event; | 41 | class KCal::Event; |
42 | class KCal::Todo; | 42 | class KCal::Todo; |
43 | 43 | ||
44 | using namespace KCal; | 44 | using namespace KCal; |
45 | 45 | ||
46 | class MarcusBains : public QFrame { | 46 | class MarcusBains : public QFrame { |
47 | Q_OBJECT | 47 | Q_OBJECT |
48 | public: | 48 | public: |
49 | MarcusBains(KOAgenda *agenda=0,const char *name=0); | 49 | MarcusBains(KOAgenda *agenda=0,const char *name=0); |
50 | virtual ~MarcusBains(); | 50 | virtual ~MarcusBains(); |
51 | 51 | ||
52 | public slots: | 52 | public slots: |
53 | void updateLocation(bool recalculate=false); | 53 | void updateLocation(bool recalculate=false); |
54 | void updateLoc(); | 54 | void updateLoc(); |
55 | 55 | ||
56 | private: | 56 | private: |
57 | int todayColumn(); | 57 | int todayColumn(); |
58 | QTimer *minutes; | 58 | QTimer *minutes; |
59 | QLabel *mTimeBox; | 59 | QLabel *mTimeBox; |
60 | KOAgenda *agenda; | 60 | KOAgenda *agenda; |
61 | QTime oldTime; | 61 | QTime oldTime; |
62 | int oldToday; | 62 | int oldToday; |
63 | }; | 63 | }; |
64 | 64 | ||
65 | 65 | ||
66 | class KOAgenda : public QScrollView | 66 | class KOAgenda : public QScrollView |
67 | { | 67 | { |
68 | Q_OBJECT | 68 | Q_OBJECT |
69 | public: | 69 | public: |
70 | enum MouseActionType { NOP, MOVE, SELECT, | 70 | enum MouseActionType { NOP, MOVE, SELECT, |
71 | RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT }; | 71 | RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT }; |
72 | 72 | ||
73 | KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0, | 73 | KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0, |
74 | const char * name=0, WFlags f=0 ); | 74 | const char * name=0, WFlags f=0 ); |
75 | KOAgenda ( int columns, QWidget * parent=0, | 75 | KOAgenda ( int columns, QWidget * parent=0, |
76 | const char * name=0, WFlags f=0 ); | 76 | const char * name=0, WFlags f=0 ); |
77 | virtual ~KOAgenda(); | 77 | virtual ~KOAgenda(); |
78 | 78 | ||
79 | Incidence *selectedIncidence() const; | 79 | Incidence *selectedIncidence() const; |
80 | QDate selectedIncidenceDate() const; | 80 | QDate selectedIncidenceDate() const; |
81 | 81 | ||
82 | virtual bool eventFilter ( QObject *, QEvent * ); | 82 | virtual bool eventFilter ( QObject *, QEvent * ); |
83 | 83 | ||
84 | void contentsToGrid (int x, int y, int& gx, int& gy); | 84 | void contentsToGrid (int x, int y, int& gx, int& gy); |
85 | void gridToContents (int gx, int gy, int& x, int& y); | 85 | void gridToContents (int gx, int gy, int& x, int& y); |
86 | 86 | ||
87 | int timeToY (const QTime &time); | 87 | int timeToY (const QTime &time); |
88 | QTime gyToTime (int y); | 88 | QTime gyToTime (int y); |
89 | 89 | ||
90 | void setStartHour(int startHour); | 90 | void setStartHour(int startHour); |
91 | 91 | ||
92 | KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom); | 92 | KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom); |
93 | KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd); | 93 | KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd); |
94 | void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, | 94 | void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, |
95 | int YTop,int YBottom); | 95 | int YTop,int YBottom); |
96 | 96 | ||
97 | void changeColumns(int columns); | 97 | void changeColumns(int columns); |
98 | 98 | ||
99 | int columns() { return mColumns; } | 99 | int columns() { return mColumns; } |
100 | int rows() { return mRows; } | 100 | int rows() { return mRows; } |
101 | 101 | ||
102 | int gridSpacingX() const { return mGridSpacingX; } | 102 | int gridSpacingX() const { return mGridSpacingX; } |
103 | int gridSpacingY() const { return mGridSpacingY; } | 103 | int gridSpacingY() const { return mGridSpacingY; } |
104 | 104 | ||
105 | // virtual QSizePolicy sizePolicy() const; | 105 | // virtual QSizePolicy sizePolicy() const; |
106 | 106 | ||
107 | void clear(); | 107 | void clear(); |
108 | 108 | ||
109 | void clearSelection(); | 109 | void clearSelection(); |
110 | void hideUnused(); | 110 | void hideUnused(); |
111 | 111 | ||
112 | /** Calculates the minimum width */ | 112 | /** Calculates the minimum width */ |
113 | virtual int minimumWidth() const; | 113 | virtual int minimumWidth() const; |
114 | /** Update configuration from preference settings */ | 114 | /** Update configuration from preference settings */ |
115 | void updateConfig(); | 115 | void updateConfig(); |
116 | 116 | ||
117 | void checkScrollBoundaries(); | 117 | void checkScrollBoundaries(); |
118 | 118 | ||
119 | void setHolidayMask(QMemArray<bool> *); | 119 | void setHolidayMask(QMemArray<bool> *); |
120 | void setDateList(const DateList &selectedDates); | 120 | void setDateList(const DateList &selectedDates); |
121 | DateList dateList() const; | 121 | DateList dateList() const; |
122 | void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false); | 122 | void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false); |
123 | void finishUpdate(); | 123 | void finishUpdate(); |
124 | void printSelection(); | 124 | void printSelection(); |
125 | void storePosition(); | 125 | void storePosition(); |
126 | void restorePosition(); | 126 | void restorePosition(); |
127 | void setPopup( KOEventPopupMenu * p ) { mAllAgendaPopup = p; } | 127 | void setPopup( KOEventPopupMenu * p ) { mAllAgendaPopup = p; } |
128 | 128 | ||
129 | public slots: | 129 | public slots: |
130 | void slotClearSelection(); | ||
130 | void popupMenu(); | 131 | void popupMenu(); |
131 | void newItem( int ); | 132 | void newItem( int ); |
132 | void moveChild( QWidget *, int, int ); | 133 | void moveChild( QWidget *, int, int ); |
133 | void scrollUp(); | 134 | void scrollUp(); |
134 | void scrollDown(); | 135 | void scrollDown(); |
135 | void updateTodo( Todo * t, int , bool ); | 136 | void updateTodo( Todo * t, int , bool ); |
136 | void popupAlarm(); | 137 | void popupAlarm(); |
137 | 138 | ||
138 | void checkScrollBoundaries(int); | 139 | void checkScrollBoundaries(int); |
139 | 140 | ||
140 | /** Deselect selected items. This function does not emit any signals. */ | 141 | /** Deselect selected items. This function does not emit any signals. */ |
141 | void deselectItem(); | 142 | void deselectItem(); |
142 | /** Select item. If the argument is 0, the currently selected item gets | 143 | /** Select item. If the argument is 0, the currently selected item gets |
143 | deselected. This function emits the itemSelected(bool) signal to inform | 144 | deselected. This function emits the itemSelected(bool) signal to inform |
144 | about selection/deseelction of events. */ | 145 | about selection/deseelction of events. */ |
145 | void selectItem(KOAgendaItem *); | 146 | void selectItem(KOAgendaItem *); |
146 | void finishResize(); | 147 | void finishResize(); |
147 | 148 | ||
148 | signals: | 149 | signals: |
150 | void signalClearSelection(); | ||
149 | void showDateView( int, int); | 151 | void showDateView( int, int); |
150 | void newEventSignal(); | 152 | void newEventSignal(); |
151 | void newEventSignal(int gx,int gy); | 153 | void newEventSignal(int gx,int gy); |
152 | void newTodoSignal(int gx,int gy); | 154 | void newTodoSignal(int gx,int gy); |
153 | void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); | 155 | void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); |
154 | void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); | 156 | void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); |
155 | void newStartSelectSignal(); | 157 | void newStartSelectSignal(); |
156 | void showIncidenceSignal(Incidence *); | 158 | void showIncidenceSignal(Incidence *); |
157 | void editIncidenceSignal(Incidence *); | 159 | void editIncidenceSignal(Incidence *); |
158 | void deleteIncidenceSignal(Incidence *); | 160 | void deleteIncidenceSignal(Incidence *); |
159 | void showIncidencePopupSignal(Incidence *); | 161 | void showIncidencePopupSignal(Incidence *); |
160 | 162 | ||
161 | void itemModified(KOAgendaItem *item, int ); | 163 | void itemModified(KOAgendaItem *item, int ); |
162 | void incidenceSelected(Incidence *); | 164 | void incidenceSelected(Incidence *); |
163 | 165 | ||
164 | void lowerYChanged(int); | 166 | void lowerYChanged(int); |
165 | void upperYChanged(int); | 167 | void upperYChanged(int); |
166 | 168 | ||
167 | void startDragSignal(Incidence *); | 169 | void startDragSignal(Incidence *); |
168 | void addToCalSignal(Incidence *, Incidence *); | 170 | void addToCalSignal(Incidence *, Incidence *); |
169 | void resizedSignal(); | 171 | void resizedSignal(); |
170 | 172 | ||
171 | protected: | 173 | protected: |
172 | KOEventPopupMenu * mAllAgendaPopup; | 174 | KOEventPopupMenu * mAllAgendaPopup; |
173 | QPainter mPixPainter; | 175 | QPainter mPixPainter; |
174 | QPixmap mPaintPixmap; | 176 | QPixmap mPaintPixmap; |
175 | QPixmap mHighlightPixmap; | 177 | QPixmap mHighlightPixmap; |
176 | void drawContents(QPainter *p,int cx, int cy, int cw, int ch); | 178 | void drawContents(QPainter *p,int cx, int cy, int cw, int ch); |
177 | virtual void resizeEvent ( QResizeEvent * ); | 179 | virtual void resizeEvent ( QResizeEvent * ); |
178 | 180 | ||
179 | /** Handles mouse events. Called from eventFilter */ | 181 | /** Handles mouse events. Called from eventFilter */ |
180 | virtual bool eventFilter_mouse ( QObject *, QMouseEvent * ); | 182 | virtual bool eventFilter_mouse ( QObject *, QMouseEvent * ); |
181 | 183 | ||
182 | /** Start selecting time span. */ | 184 | /** Start selecting time span. */ |
183 | void startSelectAction(QPoint viewportPos); | 185 | void startSelectAction(QPoint viewportPos); |
184 | 186 | ||
185 | /** Select time span. */ | 187 | /** Select time span. */ |
186 | void performSelectAction(QPoint viewportPos); | 188 | void performSelectAction(QPoint viewportPos); |
187 | 189 | ||
188 | /** Emd selecting time span. */ | 190 | /** Emd selecting time span. */ |
189 | void endSelectAction( bool emitNewEvent = false ); | 191 | void endSelectAction( bool emitNewEvent = false ); |
190 | 192 | ||
191 | /** Start moving/resizing agenda item */ | 193 | /** Start moving/resizing agenda item */ |
192 | void startItemAction(QPoint viewportPos); | 194 | void startItemAction(QPoint viewportPos); |
193 | 195 | ||
194 | /** Move/resize agenda item */ | 196 | /** Move/resize agenda item */ |
195 | void performItemAction(QPoint viewportPos); | 197 | void performItemAction(QPoint viewportPos); |
196 | 198 | ||
197 | /** End moving/resizing agenda item */ | 199 | /** End moving/resizing agenda item */ |
198 | void endItemAction(); | 200 | void endItemAction(); |
199 | 201 | ||
200 | /** Set cursor, when no item action is in progress */ | 202 | /** Set cursor, when no item action is in progress */ |
201 | void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos); | 203 | void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos); |
202 | 204 | ||
203 | /** Place agenda item in agenda and adjust other cells if necessary */ | 205 | /** Place agenda item in agenda and adjust other cells if necessary */ |
204 | void placeSubCells(KOAgendaItem *placeItem); | 206 | void placeSubCells(KOAgendaItem *placeItem); |
205 | 207 | ||
206 | /** Process the keyevent, including the ignored keyevents of eventwidgets. | 208 | /** Process the keyevent, including the ignored keyevents of eventwidgets. |
207 | * Implements pgup/pgdn and cursor key navigation in the view. | 209 | * Implements pgup/pgdn and cursor key navigation in the view. |
208 | */ | 210 | */ |
209 | void keyPressEvent( QKeyEvent * ); | 211 | void keyPressEvent( QKeyEvent * ); |
210 | 212 | ||
211 | void calculateWorkingHours(); | 213 | void calculateWorkingHours(); |
212 | 214 | ||
213 | virtual void contentsMousePressEvent ( QMouseEvent * ); | 215 | virtual void contentsMousePressEvent ( QMouseEvent * ); |
214 | 216 | ||
215 | private: | 217 | private: |
216 | void init(); | 218 | void init(); |
217 | void marcus_bains(); | 219 | void marcus_bains(); |
218 | bool mAllDayMode; | 220 | bool mAllDayMode; |
219 | bool blockResize; | 221 | bool blockResize; |
220 | bool mLeftMouseDown; | 222 | bool mLeftMouseDown; |
221 | KOAgendaItem *mPopupItem; | 223 | KOAgendaItem *mPopupItem; |
222 | QTimer* mPopupTimer; | 224 | QTimer* mPopupTimer; |
223 | int mPopupKind; | 225 | int mPopupKind; |
224 | QPoint mPopupPos; | 226 | QPoint mPopupPos; |
225 | QTimer mResizeTimer; | 227 | QTimer mResizeTimer; |
226 | double mContentPosition; | 228 | double mContentPosition; |
227 | 229 | ||
228 | // Width and height of agenda cells | 230 | // Width and height of agenda cells |
229 | int mGridSpacingX; | 231 | int mGridSpacingX; |
230 | int mGridSpacingY; | 232 | int mGridSpacingY; |
231 | 233 | ||
232 | // size of border, where mouse action will resize the KOAgendaItem | 234 | // size of border, where mouse action will resize the KOAgendaItem |
233 | int mResizeBorderWidth; | 235 | int mResizeBorderWidth; |
234 | 236 | ||
235 | // size of border, where mouse mve will cause a scroll of the agenda | 237 | // size of border, where mouse mve will cause a scroll of the agenda |
236 | int mScrollBorderWidth; | 238 | int mScrollBorderWidth; |
237 | int mScrollDelay; | 239 | int mScrollDelay; |
238 | int mScrollOffset; | 240 | int mScrollOffset; |
239 | 241 | ||
240 | QTimer mScrollUpTimer; | 242 | QTimer mScrollUpTimer; |
241 | QTimer mScrollDownTimer; | 243 | QTimer mScrollDownTimer; |
242 | 244 | ||
243 | // Number of Columns/Rows of agenda grid | 245 | // Number of Columns/Rows of agenda grid |
244 | int mColumns; | 246 | int mColumns; |
245 | int mRows; | 247 | int mRows; |
246 | 248 | ||
247 | // Cells to store Move and Resize coordiantes | 249 | // Cells to store Move and Resize coordiantes |
248 | int mStartCellX; | 250 | int mStartCellX; |
249 | int mStartCellY; | 251 | int mStartCellY; |
250 | int mCurrentCellX; | 252 | int mCurrentCellX; |
251 | int mCurrentCellY; | 253 | int mCurrentCellY; |
252 | 254 | ||
253 | // Working Hour coordiantes | 255 | // Working Hour coordiantes |
254 | bool mWorkingHoursEnable; | 256 | bool mWorkingHoursEnable; |
255 | int mWorkingHoursYTop; | 257 | int mWorkingHoursYTop; |
256 | int mWorkingHoursYBottom; | 258 | int mWorkingHoursYBottom; |
257 | 259 | ||
258 | // Selection | 260 | // Selection |
259 | int mSelectionCellX; | 261 | int mSelectionCellX; |
260 | int mSelectionYTop; | 262 | int mSelectionYTop; |
261 | int mSelectionHeight; | 263 | int mSelectionHeight; |
262 | 264 | ||
263 | // List of dates to be displayed | 265 | // List of dates to be displayed |
264 | DateList mSelectedDates; | 266 | DateList mSelectedDates; |
265 | 267 | ||
266 | // The KOAgendaItem, which has been right-clicked last | 268 | // The KOAgendaItem, which has been right-clicked last |
267 | KOAgendaItem *mClickedItem; | 269 | KOAgendaItem *mClickedItem; |
268 | 270 | ||
269 | // The KOAgendaItem, which is being moved/resized | 271 | // The KOAgendaItem, which is being moved/resized |
270 | QGuardedPtr<KOAgendaItem> mActionItem; | 272 | QGuardedPtr<KOAgendaItem> mActionItem; |
271 | 273 | ||
272 | // Currently selected item | 274 | // Currently selected item |
273 | QGuardedPtr<KOAgendaItem> mSelectedItem; | 275 | QGuardedPtr<KOAgendaItem> mSelectedItem; |
274 | 276 | ||
275 | // The Marcus Bains Line widget. | 277 | // The Marcus Bains Line widget. |
276 | MarcusBains *mMarcusBains; | 278 | MarcusBains *mMarcusBains; |
277 | void computeSizes(); | 279 | void computeSizes(); |
278 | 280 | ||
279 | MouseActionType mActionType; | 281 | MouseActionType mActionType; |
280 | 282 | ||
281 | bool mItemMoved; | 283 | bool mItemMoved; |
282 | 284 | ||
283 | // List of all Items contained in agenda | 285 | // List of all Items contained in agenda |
284 | QPtrList<KOAgendaItem> mItems; | 286 | QPtrList<KOAgendaItem> mItems; |
285 | QPtrList<KOAgendaItem> mUnusedItems; | 287 | QPtrList<KOAgendaItem> mUnusedItems; |
286 | KOAgendaItem* getNewItem(Incidence * event,QDate qd, QWidget* viewport); | 288 | KOAgendaItem* getNewItem(Incidence * event,QDate qd, QWidget* viewport); |
287 | QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems | 289 | QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems |
288 | QPopupMenu *mNewItemPopup; | 290 | QPopupMenu *mNewItemPopup; |
289 | 291 | ||
290 | int mOldLowerScrollValue; | 292 | int mOldLowerScrollValue; |
291 | int mOldUpperScrollValue; | 293 | int mOldUpperScrollValue; |
292 | KOAgendaItem * getItemForTodo ( Todo * todo ); | 294 | KOAgendaItem * getItemForTodo ( Todo * todo ); |
293 | QMemArray<bool> *mHolidayMask; | 295 | QMemArray<bool> *mHolidayMask; |
294 | int mCurPixWid; | 296 | int mCurPixWid; |
295 | int mCurPixHei; | 297 | int mCurPixHei; |
296 | }; | 298 | }; |
297 | 299 | ||
298 | #endif // KOAGENDA_H | 300 | #endif // KOAGENDA_H |
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index 17f791d..b43c40e 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -1,1659 +1,1647 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qhbox.h> | 24 | #include <qhbox.h> |
25 | #include <qvbox.h> | 25 | #include <qvbox.h> |
26 | #include <qlabel.h> | 26 | #include <qlabel.h> |
27 | #include <qframe.h> | 27 | #include <qframe.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #ifndef KORG_NOSPLITTER | 29 | #ifndef KORG_NOSPLITTER |
30 | #include <qsplitter.h> | 30 | #include <qsplitter.h> |
31 | #endif | 31 | #endif |
32 | #include <qfont.h> | 32 | #include <qfont.h> |
33 | #include <qfontmetrics.h> | 33 | #include <qfontmetrics.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <qtooltip.h> | 35 | #include <qtooltip.h> |
36 | #include <qpainter.h> | 36 | #include <qpainter.h> |
37 | #include <qpushbutton.h> | 37 | #include <qpushbutton.h> |
38 | #include <qapplication.h> | 38 | #include <qapplication.h> |
39 | 39 | ||
40 | #include <kapplication.h> | 40 | #include <kapplication.h> |
41 | #include <KDGanttMinimizeSplitter.h> | 41 | #include <KDGanttMinimizeSplitter.h> |
42 | #include <kdebug.h> | 42 | #include <kdebug.h> |
43 | #include <kstandarddirs.h> | 43 | #include <kstandarddirs.h> |
44 | #include <kiconloader.h> | 44 | #include <kiconloader.h> |
45 | #include <klocale.h> | 45 | #include <klocale.h> |
46 | #include <kconfig.h> | 46 | #include <kconfig.h> |
47 | #include <kglobal.h> | 47 | #include <kglobal.h> |
48 | #include "calendarview.h" | 48 | #include "calendarview.h" |
49 | #include "koviewmanager.h" | 49 | #include "koviewmanager.h" |
50 | 50 | ||
51 | #include <libkcal/calendar.h> | 51 | #include <libkcal/calendar.h> |
52 | #include <libkcal/icaldrag.h> | 52 | #include <libkcal/icaldrag.h> |
53 | #include <libkcal/dndfactory.h> | 53 | #include <libkcal/dndfactory.h> |
54 | 54 | ||
55 | #include <kcalendarsystem.h> | 55 | #include <kcalendarsystem.h> |
56 | 56 | ||
57 | #include "koglobals.h" | 57 | #include "koglobals.h" |
58 | #ifndef KORG_NOPLUGINS | 58 | #ifndef KORG_NOPLUGINS |
59 | #include "kocore.h" | 59 | #include "kocore.h" |
60 | #endif | 60 | #endif |
61 | #include "koprefs.h" | 61 | #include "koprefs.h" |
62 | #include "koagenda.h" | 62 | #include "koagenda.h" |
63 | #include "koagendaitem.h" | 63 | #include "koagendaitem.h" |
64 | #ifndef KORG_NOPRINTER | 64 | #ifndef KORG_NOPRINTER |
65 | #include "calprinter.h" | 65 | #include "calprinter.h" |
66 | #endif | 66 | #endif |
67 | 67 | ||
68 | #include "koagendaview.h" | 68 | #include "koagendaview.h" |
69 | //#include "koagendaview.moc" | 69 | //#include "koagendaview.moc" |
70 | 70 | ||
71 | //extern bool globalFlagBlockPainting; | 71 | //extern bool globalFlagBlockPainting; |
72 | extern int globalFlagBlockAgenda; | 72 | extern int globalFlagBlockAgenda; |
73 | extern int globalFlagBlockStartup; | 73 | extern int globalFlagBlockStartup; |
74 | extern int globalFlagBlockAgendaItemPaint; | 74 | extern int globalFlagBlockAgendaItemPaint; |
75 | extern int globalFlagBlockAgendaItemUpdate; | 75 | extern int globalFlagBlockAgendaItemUpdate; |
76 | extern int globalFlagBlockLabel; | 76 | extern int globalFlagBlockLabel; |
77 | using namespace KOrg; | 77 | using namespace KOrg; |
78 | 78 | ||
79 | 79 | ||
80 | 80 | ||
81 | TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : | 81 | TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : |
82 | QScrollView(parent,name,f) | 82 | QScrollView(parent,name,f) |
83 | { | 83 | { |
84 | myPix.resize( 1, 1 ); | 84 | myPix.resize( 1, 1 ); |
85 | mRows = rows; | 85 | mRows = rows; |
86 | 86 | ||
87 | mRedrawNeeded = true; | 87 | mRedrawNeeded = true; |
88 | setMinimumHeight( 20 ); | 88 | setMinimumHeight( 20 ); |
89 | mCellHeight = KOPrefs::instance()->mHourSize*4; | 89 | mCellHeight = KOPrefs::instance()->mHourSize*4; |
90 | 90 | ||
91 | enableClipper(true); | 91 | enableClipper(true); |
92 | 92 | ||
93 | setHScrollBarMode(AlwaysOff); | 93 | setHScrollBarMode(AlwaysOff); |
94 | setVScrollBarMode(AlwaysOff); | 94 | setVScrollBarMode(AlwaysOff); |
95 | 95 | ||
96 | resizeContents(50,mRows * mCellHeight); | 96 | resizeContents(50,mRows * mCellHeight); |
97 | 97 | ||
98 | viewport()->setBackgroundMode( PaletteBackground ); | 98 | viewport()->setBackgroundMode( PaletteBackground ); |
99 | } | 99 | } |
100 | 100 | ||
101 | void TimeLabels::setCellHeight(int height) | 101 | void TimeLabels::setCellHeight(int height) |
102 | { | 102 | { |
103 | mCellHeight = height; | 103 | mCellHeight = height; |
104 | } | 104 | } |
105 | 105 | ||
106 | /* | 106 | /* |
107 | Optimization so that only the "dirty" portion of the scroll view | 107 | Optimization so that only the "dirty" portion of the scroll view |
108 | is redrawn. Unfortunately, this is not called by default paintEvent() method. | 108 | is redrawn. Unfortunately, this is not called by default paintEvent() method. |
109 | */ | 109 | */ |
110 | void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) | 110 | void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) |
111 | { | 111 | { |
112 | 112 | ||
113 | cx = contentsX() + frameWidth()*2; | 113 | cx = contentsX() + frameWidth()*2; |
114 | cw = contentsWidth() ; | 114 | cw = contentsWidth() ; |
115 | // end of workaround | 115 | // end of workaround |
116 | 116 | ||
117 | int cell = ((int)(cy/mCellHeight)); | 117 | int cell = ((int)(cy/mCellHeight)); |
118 | int y = cell * mCellHeight; | 118 | int y = cell * mCellHeight; |
119 | QFontMetrics fm = fontMetrics(); | 119 | QFontMetrics fm = fontMetrics(); |
120 | QString hour; | 120 | QString hour; |
121 | QString suffix = "am"; | 121 | QString suffix = "am"; |
122 | int timeHeight = fm.ascent(); | 122 | int timeHeight = fm.ascent(); |
123 | QFont nFont = font(); | 123 | QFont nFont = font(); |
124 | p->setFont( font()); | 124 | p->setFont( font()); |
125 | 125 | ||
126 | if (!KGlobal::locale()->use12Clock()) { | 126 | if (!KGlobal::locale()->use12Clock()) { |
127 | suffix = "00"; | 127 | suffix = "00"; |
128 | } else | 128 | } else |
129 | if (cell > 11) suffix = "pm"; | 129 | if (cell > 11) suffix = "pm"; |
130 | 130 | ||
131 | if ( timeHeight > mCellHeight ) { | 131 | if ( timeHeight > mCellHeight ) { |
132 | timeHeight = mCellHeight-1; | 132 | timeHeight = mCellHeight-1; |
133 | int pointS = nFont.pointSize(); | 133 | int pointS = nFont.pointSize(); |
134 | while ( pointS > 4 ) { | 134 | while ( pointS > 4 ) { |
135 | nFont.setPointSize( pointS ); | 135 | nFont.setPointSize( pointS ); |
136 | fm = QFontMetrics( nFont ); | 136 | fm = QFontMetrics( nFont ); |
137 | if ( fm.ascent() < mCellHeight ) | 137 | if ( fm.ascent() < mCellHeight ) |
138 | break; | 138 | break; |
139 | -- pointS; | 139 | -- pointS; |
140 | } | 140 | } |
141 | fm = QFontMetrics( nFont ); | 141 | fm = QFontMetrics( nFont ); |
142 | timeHeight = fm.ascent(); | 142 | timeHeight = fm.ascent(); |
143 | } | 143 | } |
144 | //timeHeight -= (timeHeight/4-2); | 144 | //timeHeight -= (timeHeight/4-2); |
145 | QFont sFont = nFont; | 145 | QFont sFont = nFont; |
146 | sFont.setPointSize( sFont.pointSize()/2 ); | 146 | sFont.setPointSize( sFont.pointSize()/2 ); |
147 | QFontMetrics fmS( sFont ); | 147 | QFontMetrics fmS( sFont ); |
148 | int sHei = fmS.ascent() ; | 148 | int sHei = fmS.ascent() ; |
149 | //sHei -= (sHei/4-2); | 149 | //sHei -= (sHei/4-2); |
150 | int startW = mMiniWidth - frameWidth()-2 ; | 150 | int startW = mMiniWidth - frameWidth()-2 ; |
151 | int tw2 = fmS.width(suffix); | 151 | int tw2 = fmS.width(suffix); |
152 | timeHeight = (timeHeight-1) /2 -1; | 152 | timeHeight = (timeHeight-1) /2 -1; |
153 | //testline | 153 | //testline |
154 | //p->drawLine(0,0,0,contentsHeight()); | 154 | //p->drawLine(0,0,0,contentsHeight()); |
155 | while (y < cy + ch+mCellHeight) { | 155 | while (y < cy + ch+mCellHeight) { |
156 | p->drawLine(startW-tw2+1 ,y,cw+2,y); | 156 | p->drawLine(startW-tw2+1 ,y,cw+2,y); |
157 | hour.setNum(cell); | 157 | hour.setNum(cell); |
158 | // handle 24h and am/pm time formats | 158 | // handle 24h and am/pm time formats |
159 | if (KGlobal::locale()->use12Clock()) { | 159 | if (KGlobal::locale()->use12Clock()) { |
160 | if (cell == 12) suffix = "pm"; | 160 | if (cell == 12) suffix = "pm"; |
161 | if (cell == 0) hour.setNum(12); | 161 | if (cell == 0) hour.setNum(12); |
162 | if (cell > 12) hour.setNum(cell - 12); | 162 | if (cell > 12) hour.setNum(cell - 12); |
163 | } | 163 | } |
164 | 164 | ||
165 | // center and draw the time label | 165 | // center and draw the time label |
166 | int timeWidth = fm.width(hour); | 166 | int timeWidth = fm.width(hour); |
167 | int offset = startW - timeWidth - tw2 -1 ; | 167 | int offset = startW - timeWidth - tw2 -1 ; |
168 | p->setFont( nFont ); | 168 | p->setFont( nFont ); |
169 | p->drawText( offset, y+ timeHeight, hour); | 169 | p->drawText( offset, y+ timeHeight, hour); |
170 | p->setFont( sFont ); | 170 | p->setFont( sFont ); |
171 | offset = startW - tw2; | 171 | offset = startW - tw2; |
172 | p->drawText( offset, y -1, suffix); | 172 | p->drawText( offset, y -1, suffix); |
173 | 173 | ||
174 | // increment indices | 174 | // increment indices |
175 | y += mCellHeight; | 175 | y += mCellHeight; |
176 | cell++; | 176 | cell++; |
177 | } | 177 | } |
178 | 178 | ||
179 | 179 | ||
180 | 180 | ||
181 | 181 | ||
182 | } | 182 | } |
183 | 183 | ||
184 | /** | 184 | /** |
185 | Calculates the minimum width. | 185 | Calculates the minimum width. |
186 | */ | 186 | */ |
187 | int TimeLabels::minimumWidth() const | 187 | int TimeLabels::minimumWidth() const |
188 | { | 188 | { |
189 | return mMiniWidth; | 189 | return mMiniWidth; |
190 | } | 190 | } |
191 | 191 | ||
192 | /** updates widget's internal state */ | 192 | /** updates widget's internal state */ |
193 | void TimeLabels::updateConfig() | 193 | void TimeLabels::updateConfig() |
194 | { | 194 | { |
195 | mRedrawNeeded = true; | 195 | mRedrawNeeded = true; |
196 | // set the font | 196 | // set the font |
197 | // config->setGroup("Fonts"); | 197 | // config->setGroup("Fonts"); |
198 | // QFont font = config->readFontEntry("TimeBar Font"); | 198 | // QFont font = config->readFontEntry("TimeBar Font"); |
199 | setFont(KOPrefs::instance()->mTimeBarFont); | 199 | setFont(KOPrefs::instance()->mTimeBarFont); |
200 | QString test = "20"; | 200 | QString test = "20"; |
201 | if (KGlobal::locale()->use12Clock()) | 201 | if (KGlobal::locale()->use12Clock()) |
202 | test = "12"; | 202 | test = "12"; |
203 | mMiniWidth = fontMetrics().width(test); | 203 | mMiniWidth = fontMetrics().width(test); |
204 | if (KGlobal::locale()->use12Clock()) | 204 | if (KGlobal::locale()->use12Clock()) |
205 | test = "pm"; | 205 | test = "pm"; |
206 | else { | 206 | else { |
207 | test = "00"; | 207 | test = "00"; |
208 | } | 208 | } |
209 | QFont sFont = font(); | 209 | QFont sFont = font(); |
210 | sFont.setPointSize( sFont.pointSize()/2 ); | 210 | sFont.setPointSize( sFont.pointSize()/2 ); |
211 | QFontMetrics fmS( sFont ); | 211 | QFontMetrics fmS( sFont ); |
212 | mMiniWidth += fmS.width( test ) + frameWidth()*2+4 ; | 212 | mMiniWidth += fmS.width( test ) + frameWidth()*2+4 ; |
213 | // update geometry restrictions based on new settings | 213 | // update geometry restrictions based on new settings |
214 | setFixedWidth( mMiniWidth ); | 214 | setFixedWidth( mMiniWidth ); |
215 | 215 | ||
216 | // update HourSize | 216 | // update HourSize |
217 | mCellHeight = KOPrefs::instance()->mHourSize*4; | 217 | mCellHeight = KOPrefs::instance()->mHourSize*4; |
218 | resizeContents(mMiniWidth,mRows * mCellHeight+1); | 218 | resizeContents(mMiniWidth,mRows * mCellHeight+1); |
219 | } | 219 | } |
220 | 220 | ||
221 | /** update time label positions */ | 221 | /** update time label positions */ |
222 | void TimeLabels::positionChanged() | 222 | void TimeLabels::positionChanged() |
223 | { | 223 | { |
224 | int adjustment = mAgenda->contentsY(); | 224 | int adjustment = mAgenda->contentsY(); |
225 | setContentsPos(0, adjustment); | 225 | setContentsPos(0, adjustment); |
226 | } | 226 | } |
227 | 227 | ||
228 | /** */ | 228 | /** */ |
229 | void TimeLabels::setAgenda(KOAgenda* agenda) | 229 | void TimeLabels::setAgenda(KOAgenda* agenda) |
230 | { | 230 | { |
231 | mAgenda = agenda; | 231 | mAgenda = agenda; |
232 | } | 232 | } |
233 | 233 | ||
234 | void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) | 234 | void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) |
235 | { | 235 | { |
236 | mMouseDownY = e->pos().y(); | 236 | mMouseDownY = e->pos().y(); |
237 | mOrgCap = topLevelWidget()->caption(); | 237 | mOrgCap = topLevelWidget()->caption(); |
238 | } | 238 | } |
239 | 239 | ||
240 | void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) | 240 | void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) |
241 | { | 241 | { |
242 | int diff = mMouseDownY - e->pos().y(); | 242 | int diff = mMouseDownY - e->pos().y(); |
243 | if ( diff < 10 && diff > -10 ) | 243 | if ( diff < 10 && diff > -10 ) |
244 | return; | 244 | return; |
245 | int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; | 245 | int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; |
246 | if ( tSize < 4 ) | 246 | if ( tSize < 4 ) |
247 | tSize = 4; | 247 | tSize = 4; |
248 | if ( tSize > 22 ) | 248 | if ( tSize > 22 ) |
249 | tSize = 22; | 249 | tSize = 22; |
250 | tSize = (tSize-2)/2; | 250 | tSize = (tSize-2)/2; |
251 | topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); | 251 | topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); |
252 | 252 | ||
253 | } | 253 | } |
254 | void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) | 254 | void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) |
255 | { | 255 | { |
256 | topLevelWidget()->setCaption( mOrgCap ); | 256 | topLevelWidget()->setCaption( mOrgCap ); |
257 | int diff = mMouseDownY - e->pos().y(); | 257 | int diff = mMouseDownY - e->pos().y(); |
258 | if ( diff < 10 && diff > -10 ) | 258 | if ( diff < 10 && diff > -10 ) |
259 | return; | 259 | return; |
260 | int tSize = KOPrefs::instance()->mHourSize + (diff/10); | 260 | int tSize = KOPrefs::instance()->mHourSize + (diff/10); |
261 | if ( tSize < 4 ) | 261 | if ( tSize < 4 ) |
262 | tSize = 4; | 262 | tSize = 4; |
263 | if ( tSize > 22 ) | 263 | if ( tSize > 22 ) |
264 | tSize = 22; | 264 | tSize = 22; |
265 | tSize = (tSize/2)*2; | 265 | tSize = (tSize/2)*2; |
266 | if ( tSize == KOPrefs::instance()->mHourSize ) | 266 | if ( tSize == KOPrefs::instance()->mHourSize ) |
267 | return; | 267 | return; |
268 | KOPrefs::instance()->mHourSize = tSize; | 268 | KOPrefs::instance()->mHourSize = tSize; |
269 | emit scaleChanged(); | 269 | emit scaleChanged(); |
270 | } | 270 | } |
271 | 271 | ||
272 | /** This is called in response to repaint() */ | 272 | /** This is called in response to repaint() */ |
273 | void TimeLabels::paintEvent(QPaintEvent*) | 273 | void TimeLabels::paintEvent(QPaintEvent*) |
274 | { | 274 | { |
275 | 275 | ||
276 | // kdDebug() << "paintevent..." << endl; | 276 | // kdDebug() << "paintevent..." << endl; |
277 | // this is another hack! | 277 | // this is another hack! |
278 | // QPainter painter(this); | 278 | // QPainter painter(this); |
279 | //QString c | 279 | //QString c |
280 | repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); | 280 | repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); |
281 | } | 281 | } |
282 | 282 | ||
283 | //////////////////////////////////////////////////////////////////////////// | 283 | //////////////////////////////////////////////////////////////////////////// |
284 | 284 | ||
285 | EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) | 285 | EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) |
286 | : QFrame(parent,name) | 286 | : QFrame(parent,name) |
287 | { | 287 | { |
288 | mColumns = 1; | 288 | mColumns = 1; |
289 | mTopBox = 0; | 289 | mTopBox = 0; |
290 | mLocation = loc; | 290 | mLocation = loc; |
291 | mTopLayout = 0; | 291 | mTopLayout = 0; |
292 | mPaintWidget = 0; | 292 | mPaintWidget = 0; |
293 | mXOffset = 0; | 293 | mXOffset = 0; |
294 | if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); | 294 | if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); |
295 | else mPixmap = SmallIcon("1downarrow"); | 295 | else mPixmap = SmallIcon("1downarrow"); |
296 | mEnabled.resize(mColumns); | 296 | mEnabled.resize(mColumns); |
297 | mEnabled.fill( false ); | 297 | mEnabled.fill( false ); |
298 | setMinimumHeight(mPixmap.height()); | 298 | setMinimumHeight(mPixmap.height()); |
299 | } | 299 | } |
300 | 300 | ||
301 | EventIndicator::~EventIndicator() | 301 | EventIndicator::~EventIndicator() |
302 | { | 302 | { |
303 | } | 303 | } |
304 | 304 | ||
305 | void EventIndicator::drawContents(QPainter *p) | 305 | void EventIndicator::drawContents(QPainter *p) |
306 | { | 306 | { |
307 | 307 | ||
308 | // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; | 308 | // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; |
309 | KDGanttSplitterHandle* han = 0; | 309 | KDGanttSplitterHandle* han = 0; |
310 | if ( mPaintWidget ) | 310 | if ( mPaintWidget ) |
311 | han = mPaintWidget->firstHandle(); | 311 | han = mPaintWidget->firstHandle(); |
312 | if ( ! han ) { | 312 | if ( ! han ) { |
313 | int i; | 313 | int i; |
314 | for(i=0;i<mColumns;++i) { | 314 | for(i=0;i<mColumns;++i) { |
315 | if (mEnabled[i]) { | 315 | if (mEnabled[i]) { |
316 | int cellWidth = contentsRect().right()/mColumns; | 316 | int cellWidth = contentsRect().right()/mColumns; |
317 | int xOffset = KOGlobals::self()->reverseLayout() ? | 317 | int xOffset = KOGlobals::self()->reverseLayout() ? |
318 | (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 : | 318 | (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 : |
319 | i*cellWidth + (cellWidth -mPixmap.width()) /2; | 319 | i*cellWidth + (cellWidth -mPixmap.width()) /2; |
320 | p->drawPixmap(QPoint(1+xOffset,0),mPixmap); | 320 | p->drawPixmap(QPoint(1+xOffset,0),mPixmap); |
321 | } | 321 | } |
322 | } | 322 | } |
323 | } else { | 323 | } else { |
324 | han->repaint(); | 324 | han->repaint(); |
325 | //mPaintWidget->setBackgroundColor( red ); | 325 | //mPaintWidget->setBackgroundColor( red ); |
326 | 326 | ||
327 | QPainter pa( han ); | 327 | QPainter pa( han ); |
328 | int i; | 328 | int i; |
329 | bool setColor = false; | 329 | bool setColor = false; |
330 | for(i=0;i<mColumns;++i) { | 330 | for(i=0;i<mColumns;++i) { |
331 | if (mEnabled[i]) { | 331 | if (mEnabled[i]) { |
332 | setColor = true; | 332 | setColor = true; |
333 | 333 | ||
334 | int cellWidth = contentsRect().right()/mColumns; | 334 | int cellWidth = contentsRect().right()/mColumns; |
335 | int xOffset = KOGlobals::self()->reverseLayout() ? | 335 | int xOffset = KOGlobals::self()->reverseLayout() ? |
336 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : | 336 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : |
337 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; | 337 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; |
338 | pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); | 338 | pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); |
339 | //qDebug("222draw pix %d ",xOffset ); | 339 | //qDebug("222draw pix %d ",xOffset ); |
340 | 340 | ||
341 | } | 341 | } |
342 | 342 | ||
343 | } | 343 | } |
344 | pa.end(); | 344 | pa.end(); |
345 | 345 | ||
346 | } | 346 | } |
347 | } | 347 | } |
348 | 348 | ||
349 | void EventIndicator::setXOffset( int x ) | 349 | void EventIndicator::setXOffset( int x ) |
350 | { | 350 | { |
351 | mXOffset = x; | 351 | mXOffset = x; |
352 | } | 352 | } |
353 | void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) | 353 | void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) |
354 | { | 354 | { |
355 | mPaintWidget = w; | 355 | mPaintWidget = w; |
356 | setMaximumHeight(0); | 356 | setMaximumHeight(0); |
357 | setMinimumHeight(0); | 357 | setMinimumHeight(0); |
358 | } | 358 | } |
359 | void EventIndicator::changeColumns(int columns) | 359 | void EventIndicator::changeColumns(int columns) |
360 | { | 360 | { |
361 | mColumns = columns; | 361 | mColumns = columns; |
362 | mEnabled.resize(mColumns); | 362 | mEnabled.resize(mColumns); |
363 | 363 | ||
364 | update(); | 364 | update(); |
365 | } | 365 | } |
366 | 366 | ||
367 | void EventIndicator::enableColumn(int column, bool enable) | 367 | void EventIndicator::enableColumn(int column, bool enable) |
368 | { | 368 | { |
369 | mEnabled[column] = enable; | 369 | mEnabled[column] = enable; |
370 | } | 370 | } |
371 | 371 | ||
372 | 372 | ||
373 | //////////////////////////////////////////////////////////////////////////// | 373 | //////////////////////////////////////////////////////////////////////////// |
374 | //////////////////////////////////////////////////////////////////////////// | 374 | //////////////////////////////////////////////////////////////////////////// |
375 | //////////////////////////////////////////////////////////////////////////// | 375 | //////////////////////////////////////////////////////////////////////////// |
376 | 376 | ||
377 | KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : | 377 | KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : |
378 | KOEventView (cal,parent,name) | 378 | KOEventView (cal,parent,name) |
379 | { | 379 | { |
380 | mBlockUpdating = true; | 380 | mBlockUpdating = true; |
381 | mStartHour = 8; | 381 | mStartHour = 8; |
382 | mSelectedDates.append(QDate::currentDate()); | 382 | mSelectedDates.append(QDate::currentDate()); |
383 | 383 | ||
384 | mLayoutDayLabels = 0; | 384 | mLayoutDayLabels = 0; |
385 | mDayLabelsFrame = 0; | 385 | mDayLabelsFrame = 0; |
386 | mDayLabels = 0; | 386 | mDayLabels = 0; |
387 | bool isRTL = KOGlobals::self()->reverseLayout(); | 387 | bool isRTL = KOGlobals::self()->reverseLayout(); |
388 | QPixmap expandPix; | 388 | QPixmap expandPix; |
389 | if ( KOPrefs::instance()->mVerticalScreen ) { | 389 | if ( KOPrefs::instance()->mVerticalScreen ) { |
390 | expandPix = SmallIcon( "1updownarrow" ); | 390 | expandPix = SmallIcon( "1updownarrow" ); |
391 | } else { | 391 | } else { |
392 | expandPix = SmallIcon("1leftrightarrow" ); | 392 | expandPix = SmallIcon("1leftrightarrow" ); |
393 | } | 393 | } |
394 | 394 | ||
395 | QBoxLayout *topLayout = new QVBoxLayout(this); | 395 | QBoxLayout *topLayout = new QVBoxLayout(this); |
396 | 396 | ||
397 | // Create day name labels for agenda columns | 397 | // Create day name labels for agenda columns |
398 | // Create agenda splitter | 398 | // Create agenda splitter |
399 | 399 | ||
400 | mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 400 | mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
401 | mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 401 | mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
402 | topLayout->addWidget( mSplitterAgenda ); | 402 | topLayout->addWidget( mSplitterAgenda ); |
403 | mAllDayFrame = new QHBox(mSplitterAgenda); | 403 | mAllDayFrame = new QHBox(mSplitterAgenda); |
404 | mAllDayFrame->setFocusPolicy(NoFocus); | 404 | mAllDayFrame->setFocusPolicy(NoFocus); |
405 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); | 405 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); |
406 | agendaFrame->setFocusPolicy(NoFocus); | 406 | agendaFrame->setFocusPolicy(NoFocus); |
407 | 407 | ||
408 | // Create all-day agenda widget | 408 | // Create all-day agenda widget |
409 | mDummyAllDayLeft = new QVBox( mAllDayFrame ); | 409 | mDummyAllDayLeft = new QVBox( mAllDayFrame ); |
410 | 410 | ||
411 | mExpandButton = new QPushButton(mDummyAllDayLeft); | 411 | mExpandButton = new QPushButton(mDummyAllDayLeft); |
412 | mExpandButton->setPixmap( expandPix ); | 412 | mExpandButton->setPixmap( expandPix ); |
413 | int widebut = mExpandButton->sizeHint().width()+4; | 413 | int widebut = mExpandButton->sizeHint().width()+4; |
414 | int heibut = mExpandButton->sizeHint().height()+4; | 414 | int heibut = mExpandButton->sizeHint().height()+4; |
415 | if ( heibut > widebut ) | 415 | if ( heibut > widebut ) |
416 | widebut = heibut ; | 416 | widebut = heibut ; |
417 | 417 | ||
418 | //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, | 418 | //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, |
419 | // QSizePolicy::Fixed ) ); | 419 | // QSizePolicy::Fixed ) ); |
420 | mExpandButton->setFixedSize( widebut, widebut); | 420 | mExpandButton->setFixedSize( widebut, widebut); |
421 | connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); | 421 | connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); |
422 | mExpandButton->setFocusPolicy(NoFocus); | 422 | mExpandButton->setFocusPolicy(NoFocus); |
423 | mAllDayAgenda = new KOAgenda(1,mAllDayFrame); | 423 | mAllDayAgenda = new KOAgenda(1,mAllDayFrame); |
424 | mAllDayAgenda->setFocusPolicy(NoFocus); | 424 | mAllDayAgenda->setFocusPolicy(NoFocus); |
425 | QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); | 425 | QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); |
426 | 426 | ||
427 | // Create event context menu for all day agenda | 427 | // Create event context menu for all day agenda |
428 | //mAllDayAgendaPopup = eventPopup(); | 428 | //mAllDayAgendaPopup = eventPopup(); |
429 | 429 | ||
430 | // Create agenda frame | 430 | // Create agenda frame |
431 | QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); | 431 | QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); |
432 | // QHBox *agendaFrame = new QHBox(splitterAgenda); | 432 | // QHBox *agendaFrame = new QHBox(splitterAgenda); |
433 | 433 | ||
434 | // create event indicator bars | 434 | // create event indicator bars |
435 | mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); | 435 | mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); |
436 | #ifndef DESKTOP_VERSION | 436 | #ifndef DESKTOP_VERSION |
437 | // FIX | ||
438 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); | 437 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); |
439 | #endif | 438 | #endif |
440 | mDayLabelsFrame = new QHBox(agendaFrame); | 439 | mDayLabelsFrame = new QHBox(agendaFrame); |
441 | //topLayout->addWidget(mDayLabelsFrame); | 440 | //topLayout->addWidget(mDayLabelsFrame); |
442 | mDayLabels = new QFrame (mDayLabelsFrame); | 441 | mDayLabels = new QFrame (mDayLabelsFrame); |
443 | mLayoutDayLabels = new QHBoxLayout(mDayLabels); | 442 | mLayoutDayLabels = new QHBoxLayout(mDayLabels); |
444 | agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); | 443 | agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); |
445 | agendaLayout->addWidget(mEventIndicatorTop,1,1); | 444 | agendaLayout->addWidget(mEventIndicatorTop,1,1); |
446 | 445 | ||
447 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, | 446 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, |
448 | agendaFrame); | 447 | agendaFrame); |
449 | agendaLayout->addWidget(mEventIndicatorBottom,3,1); | 448 | agendaLayout->addWidget(mEventIndicatorBottom,3,1); |
450 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); | 449 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); |
451 | agendaLayout->addWidget(dummyAgendaRight,1,2); | 450 | agendaLayout->addWidget(dummyAgendaRight,1,2); |
452 | 451 | ||
453 | // Create time labels | 452 | // Create time labels |
454 | mTimeLabels = new TimeLabels(24,agendaFrame); | 453 | mTimeLabels = new TimeLabels(24,agendaFrame); |
455 | agendaLayout->addWidget(mTimeLabels,2,0); | 454 | agendaLayout->addWidget(mTimeLabels,2,0); |
456 | connect(mTimeLabels,SIGNAL( scaleChanged()), | 455 | connect(mTimeLabels,SIGNAL( scaleChanged()), |
457 | this,SLOT(updateConfig())); | 456 | this,SLOT(updateConfig())); |
458 | 457 | ||
459 | // Create agenda | 458 | // Create agenda |
460 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); | 459 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); |
461 | agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); | 460 | agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); |
462 | agendaLayout->setColStretch(1,1); | 461 | agendaLayout->setColStretch(1,1); |
463 | mAgenda->setFocusPolicy(NoFocus); | 462 | mAgenda->setFocusPolicy(NoFocus); |
464 | // Create event context menu for agenda | 463 | // Create event context menu for agenda |
465 | mAllAgendaPopup = eventPopup(); | 464 | mAllAgendaPopup = eventPopup(); |
466 | 465 | ||
467 | #if 0 | 466 | #if 0 |
468 | mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), | 467 | mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), |
469 | i18n("Toggle Alarm"),mAgenda, | 468 | i18n("Toggle Alarm"),mAgenda, |
470 | SLOT(popupAlarm()),true); | 469 | SLOT(popupAlarm()),true); |
471 | 470 | ||
472 | #endif | 471 | #endif |
473 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 472 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
474 | mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 473 | mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
475 | 474 | ||
476 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 475 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
477 | mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 476 | mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
478 | mAgenda->setPopup( mAllAgendaPopup ); | 477 | mAgenda->setPopup( mAllAgendaPopup ); |
479 | mAllDayAgenda->setPopup( mAllAgendaPopup ); | 478 | mAllDayAgenda->setPopup( mAllAgendaPopup ); |
480 | // make connections between dependent widgets | 479 | // make connections between dependent widgets |
481 | mTimeLabels->setAgenda(mAgenda); | 480 | mTimeLabels->setAgenda(mAgenda); |
482 | 481 | ||
483 | // Update widgets to reflect user preferences | 482 | // Update widgets to reflect user preferences |
484 | // updateConfig(); | 483 | // updateConfig(); |
485 | 484 | ||
486 | // createDayLabels(); | 485 | // createDayLabels(); |
487 | 486 | ||
488 | // these blank widgets make the All Day Event box line up with the agenda | 487 | // these blank widgets make the All Day Event box line up with the agenda |
489 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 488 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
490 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 489 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
491 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 490 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
492 | 491 | ||
493 | // Scrolling | 492 | // Scrolling |
494 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), | 493 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), |
495 | mTimeLabels, SLOT(positionChanged())); | 494 | mTimeLabels, SLOT(positionChanged())); |
496 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), | 495 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), |
497 | SLOT(setContentsPos(int))); | 496 | SLOT(setContentsPos(int))); |
498 | 497 | ||
499 | connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); | 498 | connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); |
500 | connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); | 499 | connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); |
501 | 500 | ||
502 | // Create/Show/Edit/Delete Event | 501 | // Create/Show/Edit/Delete Event |
503 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), | 502 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), |
504 | SLOT(newEvent(int,int))); | 503 | SLOT(newEvent(int,int))); |
505 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), | 504 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), |
506 | SLOT(newTodo(int,int))); | 505 | SLOT(newTodo(int,int))); |
507 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 506 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
508 | SLOT(newEvent(int,int,int,int))); | 507 | SLOT(newEvent(int,int,int,int))); |
509 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), | 508 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), |
510 | SLOT(newEventAllDay(int,int))); | 509 | SLOT(newEventAllDay(int,int))); |
511 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), | 510 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), |
512 | SLOT(newTodoAllDay(int,int))); | 511 | SLOT(newTodoAllDay(int,int))); |
513 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 512 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
514 | SLOT(newEventAllDay(int,int))); | 513 | SLOT(newEventAllDay(int,int))); |
515 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 514 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
516 | SLOT(newTimeSpanSelected(int,int,int,int))); | 515 | SLOT(newTimeSpanSelected(int,int,int,int))); |
517 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 516 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
518 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); | 517 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); |
519 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 518 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
520 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 519 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
521 | 520 | ||
522 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 521 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
523 | SIGNAL(editIncidenceSignal(Incidence *))); | 522 | SIGNAL(editIncidenceSignal(Incidence *))); |
524 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 523 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
525 | SIGNAL(editIncidenceSignal(Incidence *))); | 524 | SIGNAL(editIncidenceSignal(Incidence *))); |
526 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 525 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
527 | SIGNAL(showIncidenceSignal(Incidence *))); | 526 | SIGNAL(showIncidenceSignal(Incidence *))); |
528 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 527 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
529 | SIGNAL(showIncidenceSignal(Incidence *))); | 528 | SIGNAL(showIncidenceSignal(Incidence *))); |
530 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 529 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
531 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 530 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
532 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 531 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
533 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 532 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
534 | 533 | ||
535 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 534 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
536 | SLOT(updateEventDates(KOAgendaItem *, int ))); | 535 | SLOT(updateEventDates(KOAgendaItem *, int ))); |
537 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 536 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
538 | SLOT(updateEventDates(KOAgendaItem *, int))); | 537 | SLOT(updateEventDates(KOAgendaItem *, int))); |
539 | 538 | ||
540 | // event indicator update | 539 | // event indicator update |
541 | connect(mAgenda,SIGNAL(lowerYChanged(int)), | 540 | connect(mAgenda,SIGNAL(lowerYChanged(int)), |
542 | SLOT(updateEventIndicatorTop(int))); | 541 | SLOT(updateEventIndicatorTop(int))); |
543 | connect(mAgenda,SIGNAL(upperYChanged(int)), | 542 | connect(mAgenda,SIGNAL(upperYChanged(int)), |
544 | SLOT(updateEventIndicatorBottom(int))); | 543 | SLOT(updateEventIndicatorBottom(int))); |
545 | // drag signals | 544 | // drag signals |
546 | /* | 545 | /* |
547 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), | 546 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), |
548 | SLOT(startDrag(Event *))); | 547 | SLOT(startDrag(Event *))); |
549 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), | 548 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), |
550 | SLOT(startDrag(Event *))); | 549 | SLOT(startDrag(Event *))); |
551 | */ | 550 | */ |
552 | // synchronize selections | 551 | // synchronize selections |
553 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 552 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
554 | mAllDayAgenda, SLOT( deselectItem() ) ); | 553 | mAllDayAgenda, SLOT( deselectItem() ) ); |
555 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 554 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
556 | mAgenda, SLOT( deselectItem() ) ); | 555 | mAgenda, SLOT( deselectItem() ) ); |
557 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 556 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
558 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 557 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
559 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 558 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
560 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 559 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
561 | connect( mAgenda, SIGNAL( resizedSignal() ), | 560 | connect( mAgenda, SIGNAL( resizedSignal() ), |
562 | SLOT( updateConfig( ) ) ); | 561 | SLOT( updateConfig( ) ) ); |
563 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), | 562 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), |
564 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); | 563 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); |
565 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), | 564 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), |
566 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); | 565 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); |
567 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 566 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
568 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 567 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
569 | 568 | ||
569 | connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) ); | ||
570 | connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) ); | ||
570 | 571 | ||
571 | } | 572 | } |
572 | 573 | ||
573 | void KOAgendaView::toggleAllDay() | 574 | void KOAgendaView::toggleAllDay() |
574 | { | 575 | { |
575 | if ( mSplitterAgenda->firstHandle() ) | 576 | if ( mSplitterAgenda->firstHandle() ) |
576 | mSplitterAgenda->firstHandle()->toggle(); | 577 | mSplitterAgenda->firstHandle()->toggle(); |
577 | } | 578 | } |
578 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) | 579 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) |
579 | { | 580 | { |
580 | calendar()->addIncidence( inc ); | 581 | calendar()->addIncidence( inc ); |
581 | 582 | ||
582 | if ( incOld ) { | 583 | if ( incOld ) { |
583 | if ( incOld->type() == "Todo" ) | 584 | if ( incOld->type() == "Todo" ) |
584 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); | 585 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); |
585 | else | 586 | else |
586 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); | 587 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); |
587 | } | 588 | } |
588 | 589 | ||
589 | } | 590 | } |
590 | 591 | ||
591 | KOAgendaView::~KOAgendaView() | 592 | KOAgendaView::~KOAgendaView() |
592 | { | 593 | { |
593 | delete mAllAgendaPopup; | 594 | delete mAllAgendaPopup; |
594 | //delete mAllDayAgendaPopup; | 595 | //delete mAllDayAgendaPopup; |
595 | delete KOAgendaItem::paintPix(); | 596 | delete KOAgendaItem::paintPix(); |
596 | delete KOAgendaItem::paintPixSel(); | 597 | delete KOAgendaItem::paintPixSel(); |
597 | } | 598 | } |
598 | void KOAgendaView::resizeEvent( QResizeEvent* e ) | 599 | void KOAgendaView::resizeEvent( QResizeEvent* e ) |
599 | { | 600 | { |
600 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); | 601 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); |
601 | bool uc = false; | 602 | bool uc = false; |
602 | int ow = e->oldSize().width(); | 603 | int ow = e->oldSize().width(); |
603 | int oh = e->oldSize().height(); | 604 | int oh = e->oldSize().height(); |
604 | int w = e->size().width(); | 605 | int w = e->size().width(); |
605 | int h = e->size().height(); | 606 | int h = e->size().height(); |
606 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { | 607 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { |
607 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) | 608 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) |
608 | uc = true; | 609 | uc = true; |
609 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); | 610 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); |
610 | } | 611 | } |
611 | mUpcomingWidth = e->size().width() ; | 612 | mUpcomingWidth = e->size().width() ; |
612 | if ( mBlockUpdating || uc ) { | 613 | if ( mBlockUpdating || uc ) { |
613 | mBlockUpdating = false; | 614 | mBlockUpdating = false; |
614 | //mAgenda->setMinimumSize(800 , 600 ); | 615 | //mAgenda->setMinimumSize(800 , 600 ); |
615 | //qDebug("mAgenda->resize+++++++++++++++ "); | 616 | //qDebug("mAgenda->resize+++++++++++++++ "); |
616 | updateConfig(); | 617 | updateConfig(); |
617 | //qDebug("KOAgendaView::Updating now possible "); | 618 | //qDebug("KOAgendaView::Updating now possible "); |
618 | } else | 619 | } else |
619 | createDayLabels(); | 620 | createDayLabels(); |
620 | //qDebug("resizeEvent end "); | 621 | //qDebug("resizeEvent end "); |
621 | 622 | ||
622 | } | 623 | } |
623 | void KOAgendaView::slotDaylabelClicked( int num ) | 624 | void KOAgendaView::slotDaylabelClicked( int num ) |
624 | { | 625 | { |
625 | 626 | ||
626 | QDate firstDate = mSelectedDates.first(); | 627 | QDate firstDate = mSelectedDates.first(); |
627 | if ( num == -1 ) | 628 | if ( num == -1 ) |
628 | emit showDateView( 6, firstDate ); | 629 | emit showDateView( 6, firstDate ); |
629 | else if (num >= 0 ) { | 630 | else if (num >= 0 ) { |
630 | if ( mSelectedDates.count() == 1) | 631 | if ( mSelectedDates.count() == 1) |
631 | emit showDateView( 9, firstDate.addDays( num ) ); | 632 | emit showDateView( 9, firstDate.addDays( num ) ); |
632 | else | 633 | else |
633 | emit showDateView( 3, firstDate.addDays( num ) ); | 634 | emit showDateView( 3, firstDate.addDays( num ) ); |
634 | } | 635 | } |
635 | else | 636 | else |
636 | showDateView( 10, firstDate.addDays(1) ); | 637 | showDateView( 10, firstDate.addDays(1) ); |
637 | } | 638 | } |
638 | 639 | ||
639 | KOAgendaButton* KOAgendaView::getNewDaylabel() | 640 | KOAgendaButton* KOAgendaView::getNewDaylabel() |
640 | { | 641 | { |
641 | 642 | ||
642 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); | 643 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); |
643 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); | 644 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); |
644 | mDayLabelsList.append( dayLabel ); | 645 | mDayLabelsList.append( dayLabel ); |
645 | mLayoutDayLabels->addWidget(dayLabel); | 646 | mLayoutDayLabels->addWidget(dayLabel); |
646 | return dayLabel ; | 647 | return dayLabel ; |
647 | } | 648 | } |
648 | 649 | ||
649 | void KOAgendaView::createDayLabels() | 650 | void KOAgendaView::createDayLabels() |
650 | { | 651 | { |
651 | 652 | ||
652 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { | 653 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { |
653 | // qDebug(" KOAgendaView::createDayLabels() blocked "); | 654 | // qDebug(" KOAgendaView::createDayLabels() blocked "); |
654 | return; | 655 | return; |
655 | 656 | ||
656 | } | 657 | } |
657 | int newHight; | 658 | int newHight; |
658 | if ( !mSelectedDates.count()) | 659 | if ( !mSelectedDates.count()) |
659 | return; | 660 | return; |
660 | 661 | ||
661 | // ### Before deleting and recreating we could check if mSelectedDates changed... | 662 | // ### Before deleting and recreating we could check if mSelectedDates changed... |
662 | // It would remove some flickering and gain speed (since this is called by | 663 | // It would remove some flickering and gain speed (since this is called by |
663 | // each updateView() call) | 664 | // each updateView() call) |
664 | 665 | ||
665 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; | 666 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; |
666 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); | 667 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); |
667 | if ( maxWid < 20 ) | 668 | if ( maxWid < 20 ) |
668 | maxWid = 20; | 669 | maxWid = 20; |
669 | 670 | ||
670 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; | 671 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; |
671 | QFontMetrics fm ( dlf ); | 672 | QFontMetrics fm ( dlf ); |
672 | int selCount = mSelectedDates.count(); | 673 | int selCount = mSelectedDates.count(); |
673 | int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1; | 674 | int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1; |
674 | QString dayTest = "Mon 20"; | 675 | QString dayTest = "Mon 20"; |
675 | //QString dayTest = "Mon 20"; | 676 | //QString dayTest = "Mon 20"; |
676 | int wid = fm.width( dayTest ); | 677 | int wid = fm.width( dayTest ); |
677 | //maxWid -= ( selCount * 3 ); //working for QLabels | 678 | //maxWid -= ( selCount * 3 ); //working for QLabels |
678 | if ( QApplication::desktop()->width() <= 320 ) | 679 | if ( QApplication::desktop()->width() <= 320 ) |
679 | maxWid -= ( selCount * 3 ); //working for QPushButton | 680 | maxWid -= ( selCount * 3 ); //working for QPushButton |
680 | else | 681 | else |
681 | maxWid -= ( selCount * 3 ); //working for QPushButton | 682 | maxWid -= ( selCount * 3 ); //working for QPushButton |
682 | if ( maxWid < 0 ) | 683 | if ( maxWid < 0 ) |
683 | maxWid = 20; | 684 | maxWid = 20; |
684 | int needWid = wid * selCount; | 685 | int needWid = wid * selCount; |
685 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); | 686 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); |
686 | //if ( needWid > maxWid ) | 687 | //if ( needWid > maxWid ) |
687 | // qDebug("DAYLABELS TOOOOOOO BIG "); | 688 | // qDebug("DAYLABELS TOOOOOOO BIG "); |
688 | while ( needWid > maxWid ) { | 689 | while ( needWid > maxWid ) { |
689 | dayTest = dayTest.left( dayTest.length() - 1 ); | 690 | dayTest = dayTest.left( dayTest.length() - 1 ); |
690 | wid = fm.width( dayTest ); | 691 | wid = fm.width( dayTest ); |
691 | needWid = wid * selCount; | 692 | needWid = wid * selCount; |
692 | } | 693 | } |
693 | int maxLen = dayTest.length(); | 694 | int maxLen = dayTest.length(); |
694 | int fontPoint = dlf.pointSize(); | 695 | int fontPoint = dlf.pointSize(); |
695 | if ( maxLen < 2 ) { | 696 | if ( maxLen < 2 ) { |
696 | int fontPoint = dlf.pointSize(); | 697 | int fontPoint = dlf.pointSize(); |
697 | while ( fontPoint > 4 ) { | 698 | while ( fontPoint > 4 ) { |
698 | --fontPoint; | 699 | --fontPoint; |
699 | dlf.setPointSize( fontPoint ); | 700 | dlf.setPointSize( fontPoint ); |
700 | QFontMetrics f( dlf ); | 701 | QFontMetrics f( dlf ); |
701 | wid = f.width( "30" ); | 702 | wid = f.width( "30" ); |
702 | needWid = wid * selCount; | 703 | needWid = wid * selCount; |
703 | if ( needWid < maxWid ) | 704 | if ( needWid < maxWid ) |
704 | break; | 705 | break; |
705 | } | 706 | } |
706 | maxLen = 2; | 707 | maxLen = 2; |
707 | } | 708 | } |
708 | //qDebug("Max len %d ", dayTest.length() ); | 709 | //qDebug("Max len %d ", dayTest.length() ); |
709 | 710 | ||
710 | QFontMetrics tempF( dlf ); | 711 | QFontMetrics tempF( dlf ); |
711 | newHight = tempF.height(); | 712 | newHight = tempF.height(); |
712 | mDayLabels->setFont( dlf ); | 713 | mDayLabels->setFont( dlf ); |
713 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; | 714 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; |
714 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); | 715 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); |
715 | //mLayoutDayLabels->addSpacing( 2 ); | 716 | //mLayoutDayLabels->addSpacing( 2 ); |
716 | // QFont lFont = dlf; | 717 | // QFont lFont = dlf; |
717 | bool appendLabels = false; | 718 | bool appendLabels = false; |
718 | KOAgendaButton *dayLabel; | 719 | KOAgendaButton *dayLabel; |
719 | dayLabel = mDayLabelsList.first(); | 720 | dayLabel = mDayLabelsList.first(); |
720 | if ( !dayLabel ) { | 721 | if ( !dayLabel ) { |
721 | appendLabels = true; | 722 | appendLabels = true; |
722 | dayLabel = getNewDaylabel(); | 723 | dayLabel = getNewDaylabel(); |
723 | } | 724 | } |
724 | dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); | 725 | dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); |
725 | dayLabel->setFont( dlf ); | 726 | dayLabel->setFont( dlf ); |
726 | dayLabel->setNum( -1 ); | 727 | dayLabel->setNum( -1 ); |
727 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 728 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
728 | #if 0 | 729 | |
729 | if ( QApplication::desktop()->width() <= 320 ) | 730 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); |
730 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ).left(2) ); | ||
731 | else | ||
732 | #endif | ||
733 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); | ||
734 | dayLabel->show(); | 731 | dayLabel->show(); |
735 | DateList::ConstIterator dit; | 732 | DateList::ConstIterator dit; |
736 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); | 733 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); |
737 | int counter = -1; | 734 | int counter = -1; |
738 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 735 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
739 | ++counter; | 736 | ++counter; |
740 | QDate date = *dit; | 737 | QDate date = *dit; |
741 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); | 738 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); |
742 | if ( ! appendLabels ) { | 739 | if ( ! appendLabels ) { |
743 | dayLabel = mDayLabelsList.next(); | 740 | dayLabel = mDayLabelsList.next(); |
744 | if ( !dayLabel ) | 741 | if ( !dayLabel ) |
745 | appendLabels = true; | 742 | appendLabels = true; |
746 | } | 743 | } |
747 | if ( appendLabels ) { | 744 | if ( appendLabels ) { |
748 | dayLabel = getNewDaylabel(); | 745 | dayLabel = getNewDaylabel(); |
749 | } | 746 | } |
750 | dayLabel->setMinimumWidth( 1 ); | 747 | dayLabel->setMinimumWidth( 1 ); |
751 | dayLabel->setMaximumWidth( 10240 ); | 748 | dayLabel->setMaximumWidth( 10240 ); |
752 | dayLabel->setFont( dlf ); | 749 | dayLabel->setFont( dlf ); |
753 | dayLabel->show(); | 750 | dayLabel->show(); |
754 | dayLabel->setAutoRepeat( false ); | 751 | dayLabel->setAutoRepeat( false ); |
755 | dayLabel->setNum( counter ); | 752 | dayLabel->setNum( counter ); |
756 | QString str; | 753 | QString str; |
757 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); | 754 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); |
758 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); | 755 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); |
759 | switch ( maxLen ) { | 756 | switch ( maxLen ) { |
760 | case 2: | 757 | case 2: |
761 | str = QString::number( date.day() ); | 758 | str = QString::number( date.day() ); |
762 | break; | 759 | break; |
763 | 760 | ||
764 | case 3: | 761 | case 3: |
765 | str = dayName.left( 1 ) +QString::number( date.day()); | 762 | str = dayName.left( 1 ) +QString::number( date.day()); |
766 | 763 | ||
767 | break; | 764 | break; |
768 | case 4: | 765 | case 4: |
769 | str = dayName.left( 1 ) + " " +QString::number( date.day()); | 766 | str = dayName.left( 1 ) + " " +QString::number( date.day()); |
770 | 767 | ||
771 | break; | 768 | break; |
772 | case 5: | 769 | case 5: |
773 | str = dayName.left( 2 ) + " " +QString::number( date.day()); | 770 | str = dayName.left( 2 ) + " " +QString::number( date.day()); |
774 | 771 | ||
775 | break; | 772 | break; |
776 | case 6: | 773 | case 6: |
777 | str = dayName.left( 3 ) + " " +QString::number( date.day()); | 774 | str = dayName.left( 3 ) + " " +QString::number( date.day()); |
778 | break; | 775 | break; |
779 | 776 | ||
780 | default: | 777 | default: |
781 | break; | 778 | break; |
782 | } | 779 | } |
783 | if ( oneday ) { | 780 | if ( oneday ) { |
784 | QString addString; | 781 | QString addString; |
785 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) | 782 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) |
786 | addString = i18n("Today"); | 783 | addString = i18n("Today"); |
787 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 784 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
788 | addString = i18n("Tomorrow"); | 785 | addString = i18n("Tomorrow"); |
789 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 786 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
790 | addString = i18n("Yesterday"); | 787 | addString = i18n("Yesterday"); |
791 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | 788 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) |
792 | addString = i18n("Day before yesterday"); | 789 | addString = i18n("Day before yesterday"); |
793 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 790 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
794 | addString = i18n("Day after tomorrow"); | 791 | addString = i18n("Day after tomorrow"); |
795 | if ( !addString.isEmpty() ) { | 792 | if ( !addString.isEmpty() ) { |
796 | str = addString+", " + str; | 793 | str = addString+", " + str; |
797 | } else { | 794 | } else { |
798 | str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); | 795 | str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); |
799 | } | 796 | } |
800 | } | 797 | } |
801 | dayLabel->setText(str); | 798 | dayLabel->setText(str); |
802 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 799 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
803 | if (date == QDate::currentDate()) { | 800 | if (date == QDate::currentDate()) { |
804 | QFont bFont = dlf; | 801 | QFont bFont = dlf; |
805 | bFont.setBold( true ); | 802 | bFont.setBold( true ); |
806 | dayLabel->setFont(bFont); | 803 | dayLabel->setFont(bFont); |
807 | } | 804 | } |
808 | //dayLayout->addWidget(dayLabel); | 805 | //dayLayout->addWidget(dayLabel); |
809 | 806 | ||
810 | #ifndef KORG_NOPLUGINS | 807 | #ifndef KORG_NOPLUGINS |
811 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); | 808 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); |
812 | CalendarDecoration *it; | 809 | CalendarDecoration *it; |
813 | for(it = cds.first(); it; it = cds.next()) { | 810 | for(it = cds.first(); it; it = cds.next()) { |
814 | QString text = it->shortText( date ); | 811 | QString text = it->shortText( date ); |
815 | if ( !text.isEmpty() ) { | 812 | if ( !text.isEmpty() ) { |
816 | QLabel *label = new QLabel(text,mDayLabels); | 813 | QLabel *label = new QLabel(text,mDayLabels); |
817 | label->setAlignment(AlignCenter); | 814 | label->setAlignment(AlignCenter); |
818 | dayLayout->addWidget(label); | 815 | dayLayout->addWidget(label); |
819 | } | 816 | } |
820 | } | 817 | } |
821 | 818 | ||
822 | for(it = cds.first(); it; it = cds.next()) { | 819 | for(it = cds.first(); it; it = cds.next()) { |
823 | QWidget *wid = it->smallWidget(mDayLabels,date); | 820 | QWidget *wid = it->smallWidget(mDayLabels,date); |
824 | if ( wid ) { | 821 | if ( wid ) { |
825 | // wid->setHeight(20); | 822 | // wid->setHeight(20); |
826 | dayLayout->addWidget(wid); | 823 | dayLayout->addWidget(wid); |
827 | } | 824 | } |
828 | } | 825 | } |
829 | #endif | 826 | #endif |
830 | } | 827 | } |
831 | if ( ! appendLabels ) { | 828 | if ( ! appendLabels ) { |
832 | dayLabel = mDayLabelsList.next(); | 829 | dayLabel = mDayLabelsList.next(); |
833 | if ( !dayLabel ) | 830 | if ( !dayLabel ) |
834 | appendLabels = true; | 831 | appendLabels = true; |
835 | } | 832 | } |
836 | if ( appendLabels ) { | 833 | if ( appendLabels ) { |
837 | dayLabel = getNewDaylabel(); | 834 | dayLabel = getNewDaylabel(); |
838 | } | 835 | } |
839 | //dayLabel->hide();//test only | 836 | //dayLabel->hide();//test only |
840 | 837 | ||
841 | dayLabel->setText(">"); | 838 | dayLabel->setText(">"); |
842 | dayLabel->setFont( dlf ); | 839 | dayLabel->setFont( dlf ); |
843 | dayLabel->setAutoRepeat( true ); | 840 | dayLabel->setAutoRepeat( true ); |
844 | dayLabel->show(); | 841 | dayLabel->show(); |
845 | dayLabel->setNum( -2 ); | 842 | dayLabel->setNum( -2 ); |
846 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo ); | 843 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo ); |
847 | 844 | ||
848 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); | 845 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); |
849 | if ( !appendLabels ) { | 846 | if ( !appendLabels ) { |
850 | dayLabel = mDayLabelsList.next(); | 847 | dayLabel = mDayLabelsList.next(); |
851 | while ( dayLabel ) { | 848 | while ( dayLabel ) { |
852 | //qDebug("!dayLabel %d",dayLabel ); | 849 | //qDebug("!dayLabel %d",dayLabel ); |
853 | dayLabel->hide(); | 850 | dayLabel->hide(); |
854 | dayLabel = mDayLabelsList.next(); | 851 | dayLabel = mDayLabelsList.next(); |
855 | } | 852 | } |
856 | } | 853 | } |
857 | 854 | ||
858 | mDayLabelsFrame->setFixedHeight( newHight + 4 ); | 855 | mDayLabelsFrame->setFixedHeight( newHight + 4 ); |
859 | } | 856 | } |
860 | 857 | ||
861 | int KOAgendaView::maxDatesHint() | 858 | int KOAgendaView::maxDatesHint() |
862 | { | 859 | { |
863 | // Not sure about the max number of events, so return 0 for now. | 860 | // Not sure about the max number of events, so return 0 for now. |
864 | return 0; | 861 | return 0; |
865 | } | 862 | } |
866 | 863 | ||
867 | int KOAgendaView::currentDateCount() | 864 | int KOAgendaView::currentDateCount() |
868 | { | 865 | { |
869 | return mSelectedDates.count(); | 866 | return mSelectedDates.count(); |
870 | } | 867 | } |
871 | 868 | ||
872 | QPtrList<Incidence> KOAgendaView::selectedIncidences() | 869 | QPtrList<Incidence> KOAgendaView::selectedIncidences() |
873 | { | 870 | { |
874 | QPtrList<Incidence> selected; | 871 | QPtrList<Incidence> selected; |
875 | Incidence *incidence; | 872 | Incidence *incidence; |
876 | 873 | ||
877 | incidence = mAgenda->selectedIncidence(); | 874 | incidence = mAgenda->selectedIncidence(); |
878 | if (incidence) selected.append(incidence); | 875 | if (incidence) selected.append(incidence); |
879 | 876 | ||
880 | incidence = mAllDayAgenda->selectedIncidence(); | 877 | incidence = mAllDayAgenda->selectedIncidence(); |
881 | if (incidence) selected.append(incidence); | 878 | if (incidence) selected.append(incidence); |
882 | 879 | ||
883 | return selected; | 880 | return selected; |
884 | } | 881 | } |
885 | 882 | ||
886 | DateList KOAgendaView::selectedDates() | 883 | DateList KOAgendaView::selectedDates() |
887 | { | 884 | { |
888 | DateList selected; | 885 | DateList selected; |
889 | QDate qd; | 886 | QDate qd; |
890 | 887 | ||
891 | qd = mAgenda->selectedIncidenceDate(); | 888 | qd = mAgenda->selectedIncidenceDate(); |
892 | if (qd.isValid()) selected.append(qd); | 889 | if (qd.isValid()) selected.append(qd); |
893 | 890 | ||
894 | qd = mAllDayAgenda->selectedIncidenceDate(); | 891 | qd = mAllDayAgenda->selectedIncidenceDate(); |
895 | if (qd.isValid()) selected.append(qd); | 892 | if (qd.isValid()) selected.append(qd); |
896 | 893 | ||
897 | return selected; | 894 | return selected; |
898 | } | 895 | } |
899 | 896 | ||
900 | 897 | ||
901 | void KOAgendaView::updateView() | 898 | void KOAgendaView::updateView() |
902 | { | 899 | { |
903 | if ( mBlockUpdating ) | 900 | if ( mBlockUpdating ) |
904 | return; | 901 | return; |
905 | // kdDebug() << "KOAgendaView::updateView()" << endl; | 902 | // kdDebug() << "KOAgendaView::updateView()" << endl; |
906 | fillAgenda(); | 903 | fillAgenda(); |
907 | 904 | ||
908 | } | 905 | } |
909 | 906 | ||
910 | 907 | ||
911 | /* | 908 | /* |
912 | Update configuration settings for the agenda view. This method is not | 909 | Update configuration settings for the agenda view. This method is not |
913 | complete. | 910 | complete. |
914 | */ | 911 | */ |
915 | void KOAgendaView::updateConfig() | 912 | void KOAgendaView::updateConfig() |
916 | { | 913 | { |
917 | if ( mBlockUpdating ) | 914 | if ( mBlockUpdating ) |
918 | return; | 915 | return; |
919 | if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { | 916 | if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { |
920 | int old = KOPrefs::instance()->mHourSize; | 917 | int old = KOPrefs::instance()->mHourSize; |
921 | KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; | 918 | KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; |
922 | qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); | 919 | qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); |
923 | } | 920 | } |
924 | 921 | ||
925 | 922 | ||
926 | // update config for children | 923 | // update config for children |
927 | mTimeLabels->updateConfig(); | 924 | mTimeLabels->updateConfig(); |
928 | mAgenda->storePosition(); | 925 | mAgenda->storePosition(); |
929 | mAgenda->updateConfig(); | 926 | mAgenda->updateConfig(); |
930 | mAllDayAgenda->updateConfig(); | 927 | mAllDayAgenda->updateConfig(); |
931 | // widget synchronization | 928 | // widget synchronization |
932 | //TODO: find a better way, maybe signal/slot | 929 | //TODO: find a better way, maybe signal/slot |
933 | mTimeLabels->positionChanged(); | 930 | mTimeLabels->positionChanged(); |
934 | 931 | ||
935 | // for some reason, this needs to be called explicitly | 932 | // for some reason, this needs to be called explicitly |
936 | mTimeLabels->repaint(); | 933 | mTimeLabels->repaint(); |
937 | 934 | ||
938 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 935 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
939 | 936 | ||
940 | // ToolTips displaying summary of events | 937 | // ToolTips displaying summary of events |
941 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() | 938 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() |
942 | ->mEnableToolTips); | 939 | ->mEnableToolTips); |
943 | 940 | ||
944 | //setHolidayMasks(); | 941 | //setHolidayMasks(); |
945 | 942 | ||
946 | //createDayLabels(); called by via updateView(); | 943 | //createDayLabels(); called by via updateView(); |
947 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); | 944 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); |
948 | updateView(); | 945 | updateView(); |
949 | mAgenda->restorePosition(); | 946 | mAgenda->restorePosition(); |
950 | } | 947 | } |
951 | 948 | ||
952 | 949 | ||
953 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) | 950 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) |
954 | { | 951 | { |
955 | 952 | ||
956 | 953 | ||
957 | int xxx = item->cellX(); | 954 | int xxx = item->cellX(); |
958 | //qDebug("KOAgendaView::updateEventDates %d %d %d %d %d", xxx, mMinY.at(xxx),mMaxY.at(xxx),item->cellYTop(),item->cellYBottom() ); | 955 | //qDebug("KOAgendaView::updateEventDates %d %d %d %d %d", xxx, mMinY.at(xxx),mMaxY.at(xxx),item->cellYTop(),item->cellYBottom() ); |
959 | if ( mMinY.at(xxx) > item->cellYTop() ) | 956 | if ( mMinY.at(xxx) > item->cellYTop() ) |
960 | mMinY.at(xxx) = item->cellYTop(); | 957 | mMinY.at(xxx) = item->cellYTop(); |
961 | if ( mMaxY.at(xxx) < item->cellYBottom() ) | 958 | if ( mMaxY.at(xxx) < item->cellYBottom() ) |
962 | mMaxY.at(xxx) = item->cellYBottom(); | 959 | mMaxY.at(xxx) = item->cellYBottom(); |
963 | 960 | ||
964 | QDateTime startDt,endDt; | 961 | QDateTime startDt,endDt; |
965 | QDate startDate; | 962 | QDate startDate; |
966 | int lenInSecs; | 963 | int lenInSecs; |
967 | // if ( type == KOAgenda::RESIZETOP ) | 964 | // if ( type == KOAgenda::RESIZETOP ) |
968 | // qDebug("RESIZETOP "); | 965 | // qDebug("RESIZETOP "); |
969 | // if ( type == KOAgenda::RESIZEBOTTOM ) | 966 | // if ( type == KOAgenda::RESIZEBOTTOM ) |
970 | // qDebug("RESIZEBOTTOM "); | 967 | // qDebug("RESIZEBOTTOM "); |
971 | // if ( type == KOAgenda::MOVE ) | 968 | // if ( type == KOAgenda::MOVE ) |
972 | // qDebug("MOVE "); | 969 | // qDebug("MOVE "); |
973 | if ( item->incidence()->type() == "Event" ) { | 970 | if ( item->incidence()->type() == "Event" ) { |
974 | startDt =item->incidence()->dtStart(); | 971 | startDt =item->incidence()->dtStart(); |
975 | endDt = item->incidence()->dtEnd(); | 972 | endDt = item->incidence()->dtEnd(); |
976 | lenInSecs = startDt.secsTo( endDt ); | 973 | lenInSecs = startDt.secsTo( endDt ); |
977 | } | 974 | } |
978 | 975 | ||
979 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); | 976 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); |
980 | 977 | ||
981 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { | 978 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { |
982 | startDate = mSelectedDates[item->mLastMoveXPos]; | 979 | startDate = mSelectedDates[item->mLastMoveXPos]; |
983 | } else { | 980 | } else { |
984 | if (item->cellX() < 0) { | 981 | if (item->cellX() < 0) { |
985 | startDate = (mSelectedDates.first()).addDays(item->cellX()); | 982 | startDate = (mSelectedDates.first()).addDays(item->cellX()); |
986 | } else { | 983 | } else { |
987 | startDate = mSelectedDates[item->cellX()]; | 984 | startDate = mSelectedDates[item->cellX()]; |
988 | } | 985 | } |
989 | } | 986 | } |
990 | startDt.setDate(startDate); | 987 | startDt.setDate(startDate); |
991 | 988 | ||
992 | if (item->incidence()->doesFloat()) { | 989 | if (item->incidence()->doesFloat()) { |
993 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); | 990 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); |
994 | } else { | 991 | } else { |
995 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) | 992 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) |
996 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); | 993 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); |
997 | if ( item->incidence()->type() == "Event" ) { | 994 | if ( item->incidence()->type() == "Event" ) { |
998 | if ( type == KOAgenda::MOVE ) { | 995 | if ( type == KOAgenda::MOVE ) { |
999 | endDt = startDt.addSecs(lenInSecs); | 996 | endDt = startDt.addSecs(lenInSecs); |
1000 | 997 | ||
1001 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { | 998 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { |
1002 | if (item->lastMultiItem()) { | 999 | if (item->lastMultiItem()) { |
1003 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 1000 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
1004 | endDt.setDate(startDate. | 1001 | endDt.setDate(startDate. |
1005 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 1002 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
1006 | } else { | 1003 | } else { |
1007 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 1004 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
1008 | endDt.setDate(startDate); | 1005 | endDt.setDate(startDate); |
1009 | } | 1006 | } |
1010 | } | 1007 | } |
1011 | } else { | 1008 | } else { |
1012 | // todo | 1009 | // todo |
1013 | if (item->lastMultiItem()) { | 1010 | if (item->lastMultiItem()) { |
1014 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 1011 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
1015 | endDt.setDate(startDate. | 1012 | endDt.setDate(startDate. |
1016 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 1013 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
1017 | } else { | 1014 | } else { |
1018 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); | 1015 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); |
1019 | if ( item->cellYBottom() > 0 ) | 1016 | if ( item->cellYBottom() > 0 ) |
1020 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 1017 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
1021 | else | 1018 | else |
1022 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); | 1019 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); |
1023 | endDt.setDate(startDate); | 1020 | endDt.setDate(startDate); |
1024 | } | 1021 | } |
1025 | } | 1022 | } |
1026 | } | 1023 | } |
1027 | if ( item->incidence()->type() == "Event" ) { | 1024 | if ( item->incidence()->type() == "Event" ) { |
1028 | item->incidence()->setDtStart(startDt); | 1025 | item->incidence()->setDtStart(startDt); |
1029 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); | 1026 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); |
1030 | } else if ( item->incidence()->type() == "Todo" ) { | 1027 | } else if ( item->incidence()->type() == "Todo" ) { |
1031 | Todo* to = static_cast<Todo*>(item->incidence()); | 1028 | Todo* to = static_cast<Todo*>(item->incidence()); |
1032 | 1029 | ||
1033 | to->setDtDue(endDt); | 1030 | to->setDtDue(endDt); |
1034 | if ( to->hasStartDate() ) { | 1031 | if ( to->hasStartDate() ) { |
1035 | if (to->dtStart() >= to->dtDue() ) | 1032 | if (to->dtStart() >= to->dtDue() ) |
1036 | to->setDtStart(to->dtDue().addDays( -2 )); | 1033 | to->setDtStart(to->dtDue().addDays( -2 )); |
1037 | } | 1034 | } |
1038 | 1035 | ||
1039 | } | 1036 | } |
1040 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); | 1037 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); |
1041 | item->incidence()->setRevision(item->incidence()->revision()+1); | 1038 | item->incidence()->setRevision(item->incidence()->revision()+1); |
1042 | item->setItemDate(startDt.date()); | 1039 | item->setItemDate(startDt.date()); |
1043 | //item->updateItem(); | 1040 | //item->updateItem(); |
1044 | if ( item->incidence()->type() == "Todo" ) { | 1041 | if ( item->incidence()->type() == "Todo" ) { |
1045 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); | 1042 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); |
1046 | 1043 | ||
1047 | } | 1044 | } |
1048 | else | 1045 | else |
1049 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); | 1046 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); |
1050 | item->updateItem(); | 1047 | item->updateItem(); |
1051 | } | 1048 | } |
1052 | 1049 | ||
1053 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) | 1050 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) |
1054 | { | 1051 | { |
1055 | // kdDebug() << "KOAgendaView::selectDates" << endl; | 1052 | // kdDebug() << "KOAgendaView::selectDates" << endl; |
1056 | 1053 | ||
1057 | mSelectedDates.clear(); | 1054 | mSelectedDates.clear(); |
1058 | // qDebug("KOAgendaView::showDates "); | 1055 | // qDebug("KOAgendaView::showDates "); |
1059 | QDate d = start; | 1056 | QDate d = start; |
1060 | while (d <= end) { | 1057 | while (d <= end) { |
1061 | mSelectedDates.append(d); | 1058 | mSelectedDates.append(d); |
1062 | d = d.addDays( 1 ); | 1059 | d = d.addDays( 1 ); |
1063 | } | 1060 | } |
1064 | 1061 | ||
1065 | // and update the view | 1062 | // and update the view |
1066 | fillAgenda(); | 1063 | fillAgenda(); |
1067 | } | 1064 | } |
1068 | 1065 | ||
1069 | 1066 | ||
1070 | void KOAgendaView::showEvents(QPtrList<Event>) | 1067 | void KOAgendaView::showEvents(QPtrList<Event>) |
1071 | { | 1068 | { |
1072 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; | 1069 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; |
1073 | } | 1070 | } |
1074 | 1071 | ||
1075 | void KOAgendaView::changeEventDisplay(Event *, int) | 1072 | void KOAgendaView::changeEventDisplay(Event *, int) |
1076 | { | 1073 | { |
1077 | // qDebug("KOAgendaView::changeEventDisplay "); | 1074 | // qDebug("KOAgendaView::changeEventDisplay "); |
1078 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; | 1075 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; |
1079 | // this should be re-written to be MUCH smarter. Right now we | 1076 | // this should be re-written to be MUCH smarter. Right now we |
1080 | // are just playing dumb. | 1077 | // are just playing dumb. |
1081 | fillAgenda(); | 1078 | fillAgenda(); |
1082 | } | 1079 | } |
1083 | 1080 | ||
1084 | void KOAgendaView::fillAgenda(const QDate &) | 1081 | void KOAgendaView::fillAgenda(const QDate &) |
1085 | { | 1082 | { |
1086 | // qDebug("KOAgendaView::fillAgenda "); | 1083 | // qDebug("KOAgendaView::fillAgenda "); |
1087 | fillAgenda(); | 1084 | fillAgenda(); |
1088 | } | 1085 | } |
1089 | 1086 | ||
1090 | void KOAgendaView::fillAgenda() | 1087 | void KOAgendaView::fillAgenda() |
1091 | { | 1088 | { |
1092 | if ( globalFlagBlockStartup ) | 1089 | if ( globalFlagBlockStartup ) |
1093 | return; | 1090 | return; |
1094 | if ( globalFlagBlockAgenda == 1 ) | 1091 | if ( globalFlagBlockAgenda == 1 ) |
1095 | return; | 1092 | return; |
1096 | static bool onlyOne = false; | 1093 | static bool onlyOne = false; |
1097 | if ( onlyOne ) | 1094 | if ( onlyOne ) |
1098 | return; | 1095 | return; |
1099 | onlyOne = true; | 1096 | onlyOne = true; |
1100 | //if ( globalFlagBlockAgenda == 2 ) | 1097 | //if ( globalFlagBlockAgenda == 2 ) |
1101 | //globalFlagBlockAgenda = 0; | 1098 | //globalFlagBlockAgenda = 0; |
1102 | // globalFlagBlockPainting = false; | 1099 | // globalFlagBlockPainting = false; |
1103 | if ( globalFlagBlockAgenda == 0 ) | 1100 | if ( globalFlagBlockAgenda == 0 ) |
1104 | globalFlagBlockAgenda = 1; | 1101 | globalFlagBlockAgenda = 1; |
1105 | // clearView(); | 1102 | // clearView(); |
1106 | //qDebug("fillAgenda()++++ "); | 1103 | //qDebug("fillAgenda()++++ "); |
1107 | globalFlagBlockAgendaItemPaint = 1; | 1104 | globalFlagBlockAgendaItemPaint = 1; |
1108 | 1105 | ||
1109 | mAllDayAgenda->changeColumns(mSelectedDates.count()); | 1106 | mAllDayAgenda->changeColumns(mSelectedDates.count()); |
1110 | mAgenda->changeColumns(mSelectedDates.count()); | 1107 | mAgenda->changeColumns(mSelectedDates.count()); |
1111 | qApp->processEvents(); | 1108 | qApp->processEvents(); |
1112 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); | 1109 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); |
1113 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); | 1110 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); |
1114 | setHolidayMasks(); | 1111 | setHolidayMasks(); |
1115 | 1112 | ||
1116 | //mAgenda->hideUnused(); | 1113 | //mAgenda->hideUnused(); |
1117 | //mAllDayAgenda->hideUnused(); | 1114 | //mAllDayAgenda->hideUnused(); |
1118 | 1115 | ||
1119 | // mAgenda->blockNextRepaint( false ); | 1116 | // mAgenda->blockNextRepaint( false ); |
1120 | // mAgenda->viewport()->repaint(); | 1117 | // mAgenda->viewport()->repaint(); |
1121 | // mAgenda->blockNextRepaint( true ); | 1118 | // mAgenda->blockNextRepaint( true ); |
1122 | mMinY.resize(mSelectedDates.count()); | 1119 | mMinY.resize(mSelectedDates.count()); |
1123 | mMaxY.resize(mSelectedDates.count()); | 1120 | mMaxY.resize(mSelectedDates.count()); |
1124 | 1121 | ||
1125 | QPtrList<Event> dayEvents; | 1122 | QPtrList<Event> dayEvents; |
1126 | 1123 | ||
1127 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1124 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1128 | // Therefore, gtodoset all of them. | 1125 | // Therefore, gtodoset all of them. |
1129 | QPtrList<Todo> todos = calendar()->todos(); | 1126 | QPtrList<Todo> todos = calendar()->todos(); |
1130 | 1127 | ||
1131 | mAgenda->setDateList(mSelectedDates); | 1128 | mAgenda->setDateList(mSelectedDates); |
1132 | 1129 | ||
1133 | QDate today = QDate::currentDate(); | 1130 | QDate today = QDate::currentDate(); |
1134 | 1131 | ||
1135 | DateList::ConstIterator dit; | 1132 | DateList::ConstIterator dit; |
1136 | int curCol = 0; | 1133 | int curCol = 0; |
1137 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 1134 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
1138 | QDate currentDate = *dit; | 1135 | QDate currentDate = *dit; |
1139 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() | 1136 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() |
1140 | // << endl; | 1137 | // << endl; |
1141 | 1138 | ||
1142 | dayEvents = calendar()->events(currentDate,true); | 1139 | dayEvents = calendar()->events(currentDate,true); |
1143 | 1140 | ||
1144 | // Default values, which can never be reached | 1141 | // Default values, which can never be reached |
1145 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; | 1142 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; |
1146 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; | 1143 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; |
1147 | 1144 | ||
1148 | unsigned int numEvent; | 1145 | unsigned int numEvent; |
1149 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { | 1146 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { |
1150 | Event *event = dayEvents.at(numEvent); | 1147 | Event *event = dayEvents.at(numEvent); |
1151 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) | 1148 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) |
1152 | if ( event->uid().left(15) == QString("last-syncEvent-") ) | 1149 | if ( event->uid().left(15) == QString("last-syncEvent-") ) |
1153 | continue; | 1150 | continue; |
1154 | // kdDebug() << " Event: " << event->summary() << endl; | 1151 | // kdDebug() << " Event: " << event->summary() << endl; |
1155 | 1152 | ||
1156 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; | 1153 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; |
1157 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; | 1154 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; |
1158 | 1155 | ||
1159 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; | 1156 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; |
1160 | 1157 | ||
1161 | if (event->doesFloat()) { | 1158 | if (event->doesFloat()) { |
1162 | if (event->recurrence()->doesRecur()) { | 1159 | if (event->recurrence()->doesRecur()) { |
1163 | if (event->isMultiDay() ) { | 1160 | if (event->isMultiDay() ) { |
1164 | endX = endX - beginX;// endX is now number of days | 1161 | endX = endX - beginX;// endX is now number of days |
1165 | if ( event->recursOn( currentDate ) ) { | 1162 | if ( event->recursOn( currentDate ) ) { |
1166 | endX += curCol; | 1163 | endX += curCol; |
1167 | beginX = curCol; | 1164 | beginX = curCol; |
1168 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1165 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1169 | } else { | 1166 | } else { |
1170 | qDebug("days %d %s",endX , currentDate.toString().latin1()); | 1167 | qDebug("days %d %s",endX , currentDate.toString().latin1()); |
1171 | QDate dateit = currentDate.addDays( -endX ); | 1168 | QDate dateit = currentDate.addDays( -endX ); |
1172 | if ( event->recursOn( dateit ) ) { | 1169 | if ( event->recursOn( dateit ) ) { |
1173 | qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() ); | 1170 | qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() ); |
1174 | if ( curCol-endX < 0 ) { | 1171 | if ( curCol-endX < 0 ) { |
1175 | mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol); | 1172 | mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol); |
1176 | } | 1173 | } |
1177 | } | 1174 | } |
1178 | } | 1175 | } |
1179 | } else { | 1176 | } else { |
1180 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); | 1177 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); |
1181 | } | 1178 | } |
1182 | #if 0 | 1179 | |
1183 | if (beginX <= 0 && curCol == 0) { | ||
1184 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | ||
1185 | } else if (beginX == curCol) { | ||
1186 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | ||
1187 | } else { | ||
1188 | qDebug("skipped %d %d %d ",beginX , endX, curCol); | ||
1189 | } | ||
1190 | #endif | ||
1191 | //mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); | ||
1192 | } else { | 1180 | } else { |
1193 | if (beginX <= 0 && curCol == 0) { | 1181 | if (beginX <= 0 && curCol == 0) { |
1194 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1182 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1195 | } else if (beginX == curCol) { | 1183 | } else if (beginX == curCol) { |
1196 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1184 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1197 | } | 1185 | } |
1198 | } | 1186 | } |
1199 | } else if (event->isMultiDay()) { | 1187 | } else if (event->isMultiDay()) { |
1200 | if ( event->doesRecur () ) { | 1188 | if ( event->doesRecur () ) { |
1201 | QDate dateit = currentDate; | 1189 | QDate dateit = currentDate; |
1202 | int count = 0; | 1190 | int count = 0; |
1203 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; | 1191 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; |
1204 | while (! event->recursOn( dateit ) && count <= max ) { | 1192 | while (! event->recursOn( dateit ) && count <= max ) { |
1205 | ++count; | 1193 | ++count; |
1206 | dateit = dateit.addDays( -1 ); | 1194 | dateit = dateit.addDays( -1 ); |
1207 | } | 1195 | } |
1208 | bool ok; | 1196 | bool ok; |
1209 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); | 1197 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); |
1210 | if ( ok ) | 1198 | if ( ok ) |
1211 | { | 1199 | { |
1212 | int secs = event->dtStart().secsTo( event->dtEnd() ); | 1200 | int secs = event->dtStart().secsTo( event->dtEnd() ); |
1213 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; | 1201 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; |
1214 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; | 1202 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; |
1215 | endX = currentDate.daysTo(nextOcend.date()) + curCol; | 1203 | endX = currentDate.daysTo(nextOcend.date()) + curCol; |
1216 | 1204 | ||
1217 | } | 1205 | } |
1218 | } | 1206 | } |
1219 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1207 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1220 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1208 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1221 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); | 1209 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); |
1222 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { | 1210 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { |
1223 | //qDebug("insert!!! "); | 1211 | //qDebug("insert!!! "); |
1224 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); | 1212 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); |
1225 | } | 1213 | } |
1226 | if (beginX == curCol) { | 1214 | if (beginX == curCol) { |
1227 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1215 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1228 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1216 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1229 | } else if (endX == curCol) { | 1217 | } else if (endX == curCol) { |
1230 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1218 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1231 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1219 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1232 | } else { | 1220 | } else { |
1233 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1221 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1234 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1222 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1235 | } | 1223 | } |
1236 | } else { | 1224 | } else { |
1237 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1225 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1238 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1226 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1239 | if (endY < startY) endY = startY; | 1227 | if (endY < startY) endY = startY; |
1240 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); | 1228 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); |
1241 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1229 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1242 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1230 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1243 | } | 1231 | } |
1244 | } | 1232 | } |
1245 | // ---------- [display Todos -------------- | 1233 | // ---------- [display Todos -------------- |
1246 | unsigned int numTodo; | 1234 | unsigned int numTodo; |
1247 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { | 1235 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { |
1248 | Todo *todo = todos.at(numTodo); | 1236 | Todo *todo = todos.at(numTodo); |
1249 | 1237 | ||
1250 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date | 1238 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date |
1251 | 1239 | ||
1252 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1240 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1253 | // Already completed items can be displayed on their original due date | 1241 | // Already completed items can be displayed on their original due date |
1254 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda | 1242 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda |
1255 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; | 1243 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; |
1256 | bool fillIn = false; | 1244 | bool fillIn = false; |
1257 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) | 1245 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) |
1258 | fillIn = true; | 1246 | fillIn = true; |
1259 | if ( ! fillIn && !todo->hasCompletedDate() ) | 1247 | if ( ! fillIn && !todo->hasCompletedDate() ) |
1260 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); | 1248 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); |
1261 | if ( fillIn ) { | 1249 | if ( fillIn ) { |
1262 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue | 1250 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue |
1263 | if ( KOPrefs::instance()->mShowTodoInAgenda ) | 1251 | if ( KOPrefs::instance()->mShowTodoInAgenda ) |
1264 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); | 1252 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); |
1265 | } | 1253 | } |
1266 | else { | 1254 | else { |
1267 | QDateTime dt; | 1255 | QDateTime dt; |
1268 | if ( todo->hasCompletedDate() ) | 1256 | if ( todo->hasCompletedDate() ) |
1269 | dt = todo->completed(); | 1257 | dt = todo->completed(); |
1270 | else | 1258 | else |
1271 | dt = todo->dtDue();; | 1259 | dt = todo->dtDue();; |
1272 | 1260 | ||
1273 | 1261 | ||
1274 | int endY = mAgenda->timeToY(dt.time()) - 1; | 1262 | int endY = mAgenda->timeToY(dt.time()) - 1; |
1275 | int hi = (18/KOPrefs::instance()->mHourSize); | 1263 | int hi = (18/KOPrefs::instance()->mHourSize); |
1276 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); | 1264 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); |
1277 | int startY = endY -hi; | 1265 | int startY = endY -hi; |
1278 | 1266 | ||
1279 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); | 1267 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); |
1280 | 1268 | ||
1281 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1269 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1282 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1270 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1283 | } | 1271 | } |
1284 | } | 1272 | } |
1285 | } | 1273 | } |
1286 | // ---------- display Todos] -------------- | 1274 | // ---------- display Todos] -------------- |
1287 | 1275 | ||
1288 | ++curCol; | 1276 | ++curCol; |
1289 | } | 1277 | } |
1290 | mAgenda->hideUnused(); | 1278 | mAgenda->hideUnused(); |
1291 | mAllDayAgenda->hideUnused(); | 1279 | mAllDayAgenda->hideUnused(); |
1292 | mAgenda->checkScrollBoundaries(); | 1280 | mAgenda->checkScrollBoundaries(); |
1293 | 1281 | ||
1294 | deleteSelectedDateTime(); | 1282 | deleteSelectedDateTime(); |
1295 | 1283 | ||
1296 | createDayLabels(); | 1284 | createDayLabels(); |
1297 | emit incidenceSelected( 0 ); | 1285 | emit incidenceSelected( 0 ); |
1298 | 1286 | ||
1299 | if ( globalFlagBlockAgenda == 2 ) { | 1287 | if ( globalFlagBlockAgenda == 2 ) { |
1300 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) | 1288 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) |
1301 | setStartHour( KOPrefs::instance()->mDayBegins ); | 1289 | setStartHour( KOPrefs::instance()->mDayBegins ); |
1302 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 1290 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
1303 | setStartHour( QTime::currentTime ().hour() ); | 1291 | setStartHour( QTime::currentTime ().hour() ); |
1304 | // qApp->processEvents(); | 1292 | // qApp->processEvents(); |
1305 | } | 1293 | } |
1306 | qApp->processEvents(); | 1294 | qApp->processEvents(); |
1307 | //qDebug("qApp->processEvents(); END "); | 1295 | //qDebug("qApp->processEvents(); END "); |
1308 | globalFlagBlockAgenda = 0; | 1296 | globalFlagBlockAgenda = 0; |
1309 | 1297 | ||
1310 | // mAgenda->hideUnused(); | 1298 | // mAgenda->hideUnused(); |
1311 | //mAllDayAgenda->hideUnused(); | 1299 | //mAllDayAgenda->hideUnused(); |
1312 | mAllDayAgenda->drawContentsToPainter(); | 1300 | mAllDayAgenda->drawContentsToPainter(); |
1313 | mAgenda->drawContentsToPainter(); | 1301 | mAgenda->drawContentsToPainter(); |
1314 | repaintAgenda(); | 1302 | repaintAgenda(); |
1315 | onlyOne = false; | 1303 | onlyOne = false; |
1316 | // mAgenda->finishUpdate(); | 1304 | // mAgenda->finishUpdate(); |
1317 | //mAllDayAgenda->finishUpdate(); | 1305 | //mAllDayAgenda->finishUpdate(); |
1318 | 1306 | ||
1319 | // repaintAgenda(); | 1307 | // repaintAgenda(); |
1320 | //qApp->processEvents(); | 1308 | //qApp->processEvents(); |
1321 | // globalFlagBlockAgenda = 0; | 1309 | // globalFlagBlockAgenda = 0; |
1322 | } | 1310 | } |
1323 | void KOAgendaView::repaintAgenda() | 1311 | void KOAgendaView::repaintAgenda() |
1324 | { | 1312 | { |
1325 | // mAllDayAgenda->drawContentsToPainter(); | 1313 | // mAllDayAgenda->drawContentsToPainter(); |
1326 | // mAllDayAgenda->viewport()->repaint( false ); | 1314 | // mAllDayAgenda->viewport()->repaint( false ); |
1327 | // mAgenda->drawContentsToPainter(); | 1315 | // mAgenda->drawContentsToPainter(); |
1328 | // mAgenda->viewport()->repaint( false ); | 1316 | // mAgenda->viewport()->repaint( false ); |
1329 | // qApp->processEvents(); | 1317 | // qApp->processEvents(); |
1330 | 1318 | ||
1331 | //qDebug("KOAgendaView::repaintAgenda() "); | 1319 | //qDebug("KOAgendaView::repaintAgenda() "); |
1332 | //qApp->processEvents(); | 1320 | //qApp->processEvents(); |
1333 | mAgenda->viewport()->repaint( false ); | 1321 | mAgenda->viewport()->repaint( false ); |
1334 | mAllDayAgenda->viewport()->repaint( false ); | 1322 | mAllDayAgenda->viewport()->repaint( false ); |
1335 | mAgenda->finishUpdate(); | 1323 | mAgenda->finishUpdate(); |
1336 | mAllDayAgenda->finishUpdate(); | 1324 | mAllDayAgenda->finishUpdate(); |
1337 | } | 1325 | } |
1338 | 1326 | ||
1339 | 1327 | ||
1340 | void KOAgendaView::clearView() | 1328 | void KOAgendaView::clearView() |
1341 | { | 1329 | { |
1342 | // kdDebug() << "ClearView" << endl; | 1330 | // kdDebug() << "ClearView" << endl; |
1343 | mAllDayAgenda->clear(); | 1331 | mAllDayAgenda->clear(); |
1344 | mAgenda->clear(); | 1332 | mAgenda->clear(); |
1345 | } | 1333 | } |
1346 | 1334 | ||
1347 | void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1335 | void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1348 | const QDate &td) | 1336 | const QDate &td) |
1349 | { | 1337 | { |
1350 | #ifndef KORG_NOPRINTER | 1338 | #ifndef KORG_NOPRINTER |
1351 | if (fd == td) | 1339 | if (fd == td) |
1352 | calPrinter->preview(CalPrinter::Day, fd, td); | 1340 | calPrinter->preview(CalPrinter::Day, fd, td); |
1353 | else | 1341 | else |
1354 | calPrinter->preview(CalPrinter::Week, fd, td); | 1342 | calPrinter->preview(CalPrinter::Week, fd, td); |
1355 | #endif | 1343 | #endif |
1356 | } | 1344 | } |
1357 | 1345 | ||
1358 | // void KOAgendaView::updateMovedTodo() | 1346 | // void KOAgendaView::updateMovedTodo() |
1359 | // { | 1347 | // { |
1360 | // // updateConfig(); | 1348 | // // updateConfig(); |
1361 | // // emit updateTodoViews(); | 1349 | // // emit updateTodoViews(); |
1362 | // } | 1350 | // } |
1363 | 1351 | ||
1364 | void KOAgendaView::slotShowDateView( int mode , int d ) | 1352 | void KOAgendaView::slotShowDateView( int mode , int d ) |
1365 | { | 1353 | { |
1366 | if ( d >= mSelectedDates.count() ) { | 1354 | if ( d >= mSelectedDates.count() ) { |
1367 | qDebug("KOAgendaView::slotShowDateView datecounterror %d d ", d, mSelectedDates.count() ); | 1355 | qDebug("KOAgendaView::slotShowDateView datecounterror %d d ", d, mSelectedDates.count() ); |
1368 | 1356 | ||
1369 | } else { | 1357 | } else { |
1370 | QDate day = mSelectedDates[d]; | 1358 | QDate day = mSelectedDates[d]; |
1371 | emit showDateView(mode , day ); | 1359 | emit showDateView(mode , day ); |
1372 | } | 1360 | } |
1373 | 1361 | ||
1374 | } | 1362 | } |
1375 | void KOAgendaView::newEvent(int gx, int gy) | 1363 | void KOAgendaView::newEvent(int gx, int gy) |
1376 | { | 1364 | { |
1377 | if (!mSelectedDates.count()) return; | 1365 | if (!mSelectedDates.count()) return; |
1378 | 1366 | ||
1379 | QDate day = mSelectedDates[gx]; | 1367 | QDate day = mSelectedDates[gx]; |
1380 | 1368 | ||
1381 | QTime time = mAgenda->gyToTime(gy); | 1369 | QTime time = mAgenda->gyToTime(gy); |
1382 | QDateTime dt(day,time); | 1370 | QDateTime dt(day,time); |
1383 | // if ( dt < QDateTime::currentDateTime () ) | 1371 | // if ( dt < QDateTime::currentDateTime () ) |
1384 | // dt = QDateTime::currentDateTime ().addSecs( 3600 ); | 1372 | // dt = QDateTime::currentDateTime ().addSecs( 3600 ); |
1385 | emit newEventSignal(dt); | 1373 | emit newEventSignal(dt); |
1386 | } | 1374 | } |
1387 | 1375 | ||
1388 | void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) | 1376 | void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) |
1389 | { | 1377 | { |
1390 | if (!mSelectedDates.count()) return; | 1378 | if (!mSelectedDates.count()) return; |
1391 | 1379 | ||
1392 | QDate dayStart = mSelectedDates[gxStart]; | 1380 | QDate dayStart = mSelectedDates[gxStart]; |
1393 | QDate dayEnd = mSelectedDates[gxEnd]; | 1381 | QDate dayEnd = mSelectedDates[gxEnd]; |
1394 | 1382 | ||
1395 | QTime timeStart = mAgenda->gyToTime(gyStart); | 1383 | QTime timeStart = mAgenda->gyToTime(gyStart); |
1396 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); | 1384 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); |
1397 | 1385 | ||
1398 | QDateTime dtStart(dayStart,timeStart); | 1386 | QDateTime dtStart(dayStart,timeStart); |
1399 | QDateTime dtEnd(dayEnd,timeEnd); | 1387 | QDateTime dtEnd(dayEnd,timeEnd); |
1400 | 1388 | ||
1401 | emit newEventSignal(dtStart,dtEnd); | 1389 | emit newEventSignal(dtStart,dtEnd); |
1402 | } | 1390 | } |
1403 | 1391 | ||
1404 | void KOAgendaView::newEventAllDay(int gx, int ) | 1392 | void KOAgendaView::newEventAllDay(int gx, int ) |
1405 | { | 1393 | { |
1406 | if (!mSelectedDates.count()) return; | 1394 | if (!mSelectedDates.count()) return; |
1407 | 1395 | ||
1408 | QDate day = mSelectedDates[gx]; | 1396 | QDate day = mSelectedDates[gx]; |
1409 | 1397 | ||
1410 | emit newEventSignal(day); | 1398 | emit newEventSignal(day); |
1411 | } | 1399 | } |
1412 | void KOAgendaView::newTodoAllDay(int gx, int ) | 1400 | void KOAgendaView::newTodoAllDay(int gx, int ) |
1413 | { | 1401 | { |
1414 | if (!mSelectedDates.count()) return; | 1402 | if (!mSelectedDates.count()) return; |
1415 | 1403 | ||
1416 | QDateTime day (mSelectedDates[gx] ); | 1404 | QDateTime day (mSelectedDates[gx] ); |
1417 | emit newTodoSignal(day, true); | 1405 | emit newTodoSignal(day, true); |
1418 | } | 1406 | } |
1419 | void KOAgendaView::newTodo(int gx, int gy ) | 1407 | void KOAgendaView::newTodo(int gx, int gy ) |
1420 | { | 1408 | { |
1421 | if (!mSelectedDates.count()) return; | 1409 | if (!mSelectedDates.count()) return; |
1422 | QDate dayStart = mSelectedDates[gx]; | 1410 | QDate dayStart = mSelectedDates[gx]; |
1423 | QTime timeStart = mAgenda->gyToTime(gy); | 1411 | QTime timeStart = mAgenda->gyToTime(gy); |
1424 | QDateTime dt (dayStart,timeStart); | 1412 | QDateTime dt (dayStart,timeStart); |
1425 | emit newTodoSignal( dt, false ); | 1413 | emit newTodoSignal( dt, false ); |
1426 | } | 1414 | } |
1427 | 1415 | ||
1428 | void KOAgendaView::updateEventIndicatorTop(int newY) | 1416 | void KOAgendaView::updateEventIndicatorTop(int newY) |
1429 | { | 1417 | { |
1430 | uint i; | 1418 | uint i; |
1431 | for(i=0;i<mMinY.size();++i) { | 1419 | for(i=0;i<mMinY.size();++i) { |
1432 | if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); | 1420 | if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); |
1433 | else mEventIndicatorTop->enableColumn(i,false); | 1421 | else mEventIndicatorTop->enableColumn(i,false); |
1434 | } | 1422 | } |
1435 | 1423 | ||
1436 | mEventIndicatorTop->update(); | 1424 | mEventIndicatorTop->update(); |
1437 | } | 1425 | } |
1438 | 1426 | ||
1439 | void KOAgendaView::updateEventIndicatorBottom(int newY) | 1427 | void KOAgendaView::updateEventIndicatorBottom(int newY) |
1440 | { | 1428 | { |
1441 | uint i; | 1429 | uint i; |
1442 | for(i=0;i<mMaxY.size();++i) { | 1430 | for(i=0;i<mMaxY.size();++i) { |
1443 | if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); | 1431 | if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); |
1444 | else mEventIndicatorBottom->enableColumn(i,false); | 1432 | else mEventIndicatorBottom->enableColumn(i,false); |
1445 | } | 1433 | } |
1446 | 1434 | ||
1447 | mEventIndicatorBottom->update(); | 1435 | mEventIndicatorBottom->update(); |
1448 | } | 1436 | } |
1449 | 1437 | ||
1450 | void KOAgendaView::startDrag(Event *event) | 1438 | void KOAgendaView::startDrag(Event *event) |
1451 | { | 1439 | { |
1452 | #ifndef KORG_NODND | 1440 | #ifndef KORG_NODND |
1453 | DndFactory factory( calendar() ); | 1441 | DndFactory factory( calendar() ); |
1454 | ICalDrag *vd = factory.createDrag(event,this); | 1442 | ICalDrag *vd = factory.createDrag(event,this); |
1455 | if (vd->drag()) { | 1443 | if (vd->drag()) { |
1456 | kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; | 1444 | kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; |
1457 | } | 1445 | } |
1458 | #endif | 1446 | #endif |
1459 | } | 1447 | } |
1460 | 1448 | ||
1461 | void KOAgendaView::readSettings() | 1449 | void KOAgendaView::readSettings() |
1462 | { | 1450 | { |
1463 | readSettings(KOGlobals::config()); | 1451 | readSettings(KOGlobals::config()); |
1464 | } | 1452 | } |
1465 | 1453 | ||
1466 | void KOAgendaView::readSettings(KConfig *config) | 1454 | void KOAgendaView::readSettings(KConfig *config) |
1467 | { | 1455 | { |
1468 | // kdDebug() << "KOAgendaView::readSettings()" << endl; | 1456 | // kdDebug() << "KOAgendaView::readSettings()" << endl; |
1469 | 1457 | ||
1470 | config->setGroup("Views"); | 1458 | config->setGroup("Views"); |
1471 | 1459 | ||
1472 | //#ifndef KORG_NOSPLITTER | 1460 | //#ifndef KORG_NOSPLITTER |
1473 | QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); | 1461 | QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); |
1474 | if (sizes.count() == 2) { | 1462 | if (sizes.count() == 2) { |
1475 | if ( sizes[0] < 20 ) { | 1463 | if ( sizes[0] < 20 ) { |
1476 | sizes[1] = sizes[1] +20 - sizes[0]; | 1464 | sizes[1] = sizes[1] +20 - sizes[0]; |
1477 | sizes[0] = 20; | 1465 | sizes[0] = 20; |
1478 | } | 1466 | } |
1479 | mSplitterAgenda->setSizes(sizes); | 1467 | mSplitterAgenda->setSizes(sizes); |
1480 | // qDebug("read %d %d ",sizes[0],sizes[1] ); | 1468 | // qDebug("read %d %d ",sizes[0],sizes[1] ); |
1481 | } | 1469 | } |
1482 | //#endif | 1470 | //#endif |
1483 | 1471 | ||
1484 | // updateConfig(); | 1472 | // updateConfig(); |
1485 | } | 1473 | } |
1486 | 1474 | ||
1487 | void KOAgendaView::writeSettings(KConfig *config) | 1475 | void KOAgendaView::writeSettings(KConfig *config) |
1488 | { | 1476 | { |
1489 | // kdDebug() << "KOAgendaView::writeSettings()" << endl; | 1477 | // kdDebug() << "KOAgendaView::writeSettings()" << endl; |
1490 | 1478 | ||
1491 | config->setGroup("Views"); | 1479 | config->setGroup("Views"); |
1492 | 1480 | ||
1493 | //#ifndef KORG_NOSPLITTER | 1481 | //#ifndef KORG_NOSPLITTER |
1494 | QValueList<int> list = mSplitterAgenda->sizes(); | 1482 | QValueList<int> list = mSplitterAgenda->sizes(); |
1495 | config->writeEntry("Separator AgendaView",list); | 1483 | config->writeEntry("Separator AgendaView",list); |
1496 | //qDebug("write %d %d ", list[0],list[1] ); | 1484 | //qDebug("write %d %d ", list[0],list[1] ); |
1497 | //#endif | 1485 | //#endif |
1498 | } | 1486 | } |
1499 | 1487 | ||
1500 | void KOAgendaView::setHolidayMasks() | 1488 | void KOAgendaView::setHolidayMasks() |
1501 | { | 1489 | { |
1502 | mHolidayMask.resize(mSelectedDates.count()); | 1490 | mHolidayMask.resize(mSelectedDates.count()); |
1503 | 1491 | ||
1504 | uint i; | 1492 | uint i; |
1505 | for(i=0;i<mSelectedDates.count();++i) { | 1493 | for(i=0;i<mSelectedDates.count();++i) { |
1506 | QDate date = mSelectedDates[i]; | 1494 | QDate date = mSelectedDates[i]; |
1507 | bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); | 1495 | bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); |
1508 | bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); | 1496 | bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); |
1509 | bool showHoliday = false; | 1497 | bool showHoliday = false; |
1510 | if ( KOPrefs::instance()->mExcludeHolidays ) { | 1498 | if ( KOPrefs::instance()->mExcludeHolidays ) { |
1511 | QPtrList<Event> events = calendar()->events( date, true ); | 1499 | QPtrList<Event> events = calendar()->events( date, true ); |
1512 | Event *event; | 1500 | Event *event; |
1513 | for( event = events.first(); event; event = events.next() ) { | 1501 | for( event = events.first(); event; event = events.next() ) { |
1514 | if ( event->isHoliday()) { | 1502 | if ( event->isHoliday()) { |
1515 | showHoliday = true; | 1503 | showHoliday = true; |
1516 | break; | 1504 | break; |
1517 | } | 1505 | } |
1518 | } | 1506 | } |
1519 | 1507 | ||
1520 | } | 1508 | } |
1521 | 1509 | ||
1522 | #ifndef KORG_NOPLUGINS | 1510 | #ifndef KORG_NOPLUGINS |
1523 | bool showHoliday = KOPrefs::instance()->mExcludeHolidays && | 1511 | bool showHoliday = KOPrefs::instance()->mExcludeHolidays && |
1524 | !KOCore::self()->holiday(date).isEmpty(); | 1512 | !KOCore::self()->holiday(date).isEmpty(); |
1525 | #endif | 1513 | #endif |
1526 | bool showDay = showSaturday || showSunday || showHoliday; | 1514 | bool showDay = showSaturday || showSunday || showHoliday; |
1527 | 1515 | ||
1528 | if (showDay) { | 1516 | if (showDay) { |
1529 | mHolidayMask.at(i) = true; | 1517 | mHolidayMask.at(i) = true; |
1530 | } else { | 1518 | } else { |
1531 | mHolidayMask.at(i) = false; | 1519 | mHolidayMask.at(i) = false; |
1532 | } | 1520 | } |
1533 | } | 1521 | } |
1534 | 1522 | ||
1535 | mAgenda->setHolidayMask(&mHolidayMask); | 1523 | mAgenda->setHolidayMask(&mHolidayMask); |
1536 | mAllDayAgenda->setHolidayMask(&mHolidayMask); | 1524 | mAllDayAgenda->setHolidayMask(&mHolidayMask); |
1537 | } | 1525 | } |
1538 | 1526 | ||
1539 | void KOAgendaView::setContentsPos(int y) | 1527 | void KOAgendaView::setContentsPos(int y) |
1540 | { | 1528 | { |
1541 | mAgenda->setContentsPos(0,y); | 1529 | mAgenda->setContentsPos(0,y); |
1542 | } | 1530 | } |
1543 | 1531 | ||
1544 | void KOAgendaView::clearSelection() | 1532 | void KOAgendaView::clearSelection() |
1545 | { | 1533 | { |
1546 | mAgenda->deselectItem(); | 1534 | mAgenda->deselectItem(); |
1547 | mAllDayAgenda->deselectItem(); | 1535 | mAllDayAgenda->deselectItem(); |
1548 | } | 1536 | } |
1549 | 1537 | ||
1550 | void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, | 1538 | void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, |
1551 | int gxEnd, int gyEnd) | 1539 | int gxEnd, int gyEnd) |
1552 | { | 1540 | { |
1553 | mTimeSpanInAllDay = true; | 1541 | mTimeSpanInAllDay = true; |
1554 | newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); | 1542 | newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); |
1555 | } | 1543 | } |
1556 | 1544 | ||
1557 | 1545 | ||
1558 | 1546 | ||
1559 | 1547 | ||
1560 | void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, | 1548 | void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, |
1561 | int gxEnd, int gyEnd) | 1549 | int gxEnd, int gyEnd) |
1562 | { | 1550 | { |
1563 | if (!mSelectedDates.count()) return; | 1551 | if (!mSelectedDates.count()) return; |
1564 | 1552 | ||
1565 | QDate dayStart = mSelectedDates[gxStart]; | 1553 | QDate dayStart = mSelectedDates[gxStart]; |
1566 | QDate dayEnd = mSelectedDates[gxEnd]; | 1554 | QDate dayEnd = mSelectedDates[gxEnd]; |
1567 | 1555 | ||
1568 | QTime timeStart = mAgenda->gyToTime(gyStart); | 1556 | QTime timeStart = mAgenda->gyToTime(gyStart); |
1569 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); | 1557 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); |
1570 | 1558 | ||
1571 | QDateTime dtStart(dayStart,timeStart); | 1559 | QDateTime dtStart(dayStart,timeStart); |
1572 | QDateTime dtEnd(dayEnd,timeEnd); | 1560 | QDateTime dtEnd(dayEnd,timeEnd); |
1573 | 1561 | ||
1574 | mTimeSpanBegin = dtStart; | 1562 | mTimeSpanBegin = dtStart; |
1575 | mTimeSpanEnd = dtEnd; | 1563 | mTimeSpanEnd = dtEnd; |
1576 | 1564 | ||
1577 | } | 1565 | } |
1578 | 1566 | ||
1579 | void KOAgendaView::deleteSelectedDateTime() | 1567 | void KOAgendaView::deleteSelectedDateTime() |
1580 | { | 1568 | { |
1581 | mTimeSpanBegin.setDate(QDate()); | 1569 | mTimeSpanBegin.setDate(QDate()); |
1582 | mTimeSpanEnd.setDate(QDate()); | 1570 | mTimeSpanEnd.setDate(QDate()); |
1583 | mTimeSpanInAllDay = false; | 1571 | mTimeSpanInAllDay = false; |
1584 | } | 1572 | } |
1585 | 1573 | ||
1586 | void KOAgendaView::keyPressEvent ( QKeyEvent * e ) | 1574 | void KOAgendaView::keyPressEvent ( QKeyEvent * e ) |
1587 | { | 1575 | { |
1588 | e->ignore(); | 1576 | e->ignore(); |
1589 | } | 1577 | } |
1590 | 1578 | ||
1591 | void KOAgendaView::scrollOneHourUp() | 1579 | void KOAgendaView::scrollOneHourUp() |
1592 | { | 1580 | { |
1593 | 1581 | ||
1594 | mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); | 1582 | mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); |
1595 | } | 1583 | } |
1596 | void KOAgendaView::scrollOneHourDown() | 1584 | void KOAgendaView::scrollOneHourDown() |
1597 | { | 1585 | { |
1598 | mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); | 1586 | mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); |
1599 | } | 1587 | } |
1600 | 1588 | ||
1601 | void KOAgendaView::setStartHour( int h ) | 1589 | void KOAgendaView::setStartHour( int h ) |
1602 | { | 1590 | { |
1603 | mAgenda->setStartHour( h ); | 1591 | mAgenda->setStartHour( h ); |
1604 | 1592 | ||
1605 | } | 1593 | } |
1606 | void KOAgendaView::setInitStartHour() | 1594 | void KOAgendaView::setInitStartHour() |
1607 | { | 1595 | { |
1608 | 1596 | ||
1609 | if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 1597 | if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
1610 | setStartHour( QTime::currentTime ().hour() ); | 1598 | setStartHour( QTime::currentTime ().hour() ); |
1611 | else | 1599 | else |
1612 | setStartHour( KOPrefs::instance()->mDayBegins ); | 1600 | setStartHour( KOPrefs::instance()->mDayBegins ); |
1613 | 1601 | ||
1614 | } | 1602 | } |
1615 | 1603 | ||
1616 | 1604 | ||
1617 | void KOAgendaView::updateTodo( Todo * t, int ) | 1605 | void KOAgendaView::updateTodo( Todo * t, int ) |
1618 | { | 1606 | { |
1619 | if ( !isVisible() ) | 1607 | if ( !isVisible() ) |
1620 | return; | 1608 | return; |
1621 | bool remove = false; | 1609 | bool remove = false; |
1622 | bool removeAD = false; | 1610 | bool removeAD = false; |
1623 | QDate da; | 1611 | QDate da; |
1624 | if ( t->hasCompletedDate() ) | 1612 | if ( t->hasCompletedDate() ) |
1625 | da = t->completed().date(); | 1613 | da = t->completed().date(); |
1626 | else | 1614 | else |
1627 | da = t->dtDue().date(); | 1615 | da = t->dtDue().date(); |
1628 | if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { | 1616 | if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { |
1629 | remove = true; | 1617 | remove = true; |
1630 | removeAD = true; | 1618 | removeAD = true; |
1631 | } | 1619 | } |
1632 | else { | 1620 | else { |
1633 | bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; | 1621 | bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; |
1634 | if ( overdue && | 1622 | if ( overdue && |
1635 | QDate::currentDate() >= mSelectedDates.first() && | 1623 | QDate::currentDate() >= mSelectedDates.first() && |
1636 | QDate::currentDate() <= mSelectedDates.last()) { | 1624 | QDate::currentDate() <= mSelectedDates.last()) { |
1637 | removeAD = false; | 1625 | removeAD = false; |
1638 | remove = true; | 1626 | remove = true; |
1639 | } | 1627 | } |
1640 | else { | 1628 | else { |
1641 | 1629 | ||
1642 | if ( da < mSelectedDates.first() || | 1630 | if ( da < mSelectedDates.first() || |
1643 | da > mSelectedDates.last() ) { | 1631 | da > mSelectedDates.last() ) { |
1644 | remove = true; | 1632 | remove = true; |
1645 | removeAD = true; | 1633 | removeAD = true; |
1646 | } else { | 1634 | } else { |
1647 | remove = t->doesFloat() && !t->hasCompletedDate(); | 1635 | remove = t->doesFloat() && !t->hasCompletedDate(); |
1648 | removeAD = !remove; | 1636 | removeAD = !remove; |
1649 | } | 1637 | } |
1650 | } | 1638 | } |
1651 | } | 1639 | } |
1652 | int days = mSelectedDates.first().daysTo( da ); | 1640 | int days = mSelectedDates.first().daysTo( da ); |
1653 | //qDebug("daysto %d %d %d", days, remove,removeAD ); | 1641 | //qDebug("daysto %d %d %d", days, remove,removeAD ); |
1654 | mAgenda->updateTodo( t , days, remove); | 1642 | mAgenda->updateTodo( t , days, remove); |
1655 | if ( KOPrefs::instance()->mShowTodoInAgenda ) | 1643 | if ( KOPrefs::instance()->mShowTodoInAgenda ) |
1656 | mAllDayAgenda->updateTodo( t , days, removeAD); | 1644 | mAllDayAgenda->updateTodo( t , days, removeAD); |
1657 | //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); | 1645 | //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); |
1658 | 1646 | ||
1659 | } | 1647 | } |