author | zautrix <zautrix> | 2005-04-09 17:18:57 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-09 17:18:57 (UTC) |
commit | 2c39ac46121e8796e780a5321ab777f08792e5ba (patch) (unidiff) | |
tree | 65625ab02b77ef197411935808aa1ee6ff9341f8 /korganizer | |
parent | d1982b1423417eb59c275bb09d4e3012a67ca086 (diff) | |
download | kdepimpi-2c39ac46121e8796e780a5321ab777f08792e5ba.zip kdepimpi-2c39ac46121e8796e780a5321ab777f08792e5ba.tar.gz kdepimpi-2c39ac46121e8796e780a5321ab777f08792e5ba.tar.bz2 |
nf
-rw-r--r-- | korganizer/koagendaview.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index f53e5d5..17f791d 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -1,1659 +1,1659 @@ | |||
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 | 437 | // FIX |
438 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); | 438 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); |
439 | #endif | 439 | #endif |
440 | mDayLabelsFrame = new QHBox(agendaFrame); | 440 | mDayLabelsFrame = new QHBox(agendaFrame); |
441 | //topLayout->addWidget(mDayLabelsFrame); | 441 | //topLayout->addWidget(mDayLabelsFrame); |
442 | mDayLabels = new QFrame (mDayLabelsFrame); | 442 | mDayLabels = new QFrame (mDayLabelsFrame); |
443 | mLayoutDayLabels = new QHBoxLayout(mDayLabels); | 443 | mLayoutDayLabels = new QHBoxLayout(mDayLabels); |
444 | agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); | 444 | agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); |
445 | agendaLayout->addWidget(mEventIndicatorTop,1,1); | 445 | agendaLayout->addWidget(mEventIndicatorTop,1,1); |
446 | 446 | ||
447 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, | 447 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, |
448 | agendaFrame); | 448 | agendaFrame); |
449 | agendaLayout->addWidget(mEventIndicatorBottom,3,1); | 449 | agendaLayout->addWidget(mEventIndicatorBottom,3,1); |
450 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); | 450 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); |
451 | agendaLayout->addWidget(dummyAgendaRight,1,2); | 451 | agendaLayout->addWidget(dummyAgendaRight,1,2); |
452 | 452 | ||
453 | // Create time labels | 453 | // Create time labels |
454 | mTimeLabels = new TimeLabels(24,agendaFrame); | 454 | mTimeLabels = new TimeLabels(24,agendaFrame); |
455 | agendaLayout->addWidget(mTimeLabels,2,0); | 455 | agendaLayout->addWidget(mTimeLabels,2,0); |
456 | connect(mTimeLabels,SIGNAL( scaleChanged()), | 456 | connect(mTimeLabels,SIGNAL( scaleChanged()), |
457 | this,SLOT(updateConfig())); | 457 | this,SLOT(updateConfig())); |
458 | 458 | ||
459 | // Create agenda | 459 | // Create agenda |
460 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); | 460 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); |
461 | agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); | 461 | agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); |
462 | agendaLayout->setColStretch(1,1); | 462 | agendaLayout->setColStretch(1,1); |
463 | mAgenda->setFocusPolicy(NoFocus); | 463 | mAgenda->setFocusPolicy(NoFocus); |
464 | // Create event context menu for agenda | 464 | // Create event context menu for agenda |
465 | mAllAgendaPopup = eventPopup(); | 465 | mAllAgendaPopup = eventPopup(); |
466 | 466 | ||
467 | #if 0 | 467 | #if 0 |
468 | mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), | 468 | mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), |
469 | i18n("Toggle Alarm"),mAgenda, | 469 | i18n("Toggle Alarm"),mAgenda, |
470 | SLOT(popupAlarm()),true); | 470 | SLOT(popupAlarm()),true); |
471 | 471 | ||
472 | #endif | 472 | #endif |
473 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 473 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
474 | mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 474 | mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
475 | 475 | ||
476 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 476 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
477 | mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 477 | mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
478 | mAgenda->setPopup( mAllAgendaPopup ); | 478 | mAgenda->setPopup( mAllAgendaPopup ); |
479 | mAllDayAgenda->setPopup( mAllAgendaPopup ); | 479 | mAllDayAgenda->setPopup( mAllAgendaPopup ); |
480 | // make connections between dependent widgets | 480 | // make connections between dependent widgets |
481 | mTimeLabels->setAgenda(mAgenda); | 481 | mTimeLabels->setAgenda(mAgenda); |
482 | 482 | ||
483 | // Update widgets to reflect user preferences | 483 | // Update widgets to reflect user preferences |
484 | // updateConfig(); | 484 | // updateConfig(); |
485 | 485 | ||
486 | // createDayLabels(); | 486 | // createDayLabels(); |
487 | 487 | ||
488 | // these blank widgets make the All Day Event box line up with the agenda | 488 | // these blank widgets make the All Day Event box line up with the agenda |
489 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 489 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
490 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 490 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
491 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 491 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
492 | 492 | ||
493 | // Scrolling | 493 | // Scrolling |
494 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), | 494 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), |
495 | mTimeLabels, SLOT(positionChanged())); | 495 | mTimeLabels, SLOT(positionChanged())); |
496 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), | 496 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), |
497 | SLOT(setContentsPos(int))); | 497 | SLOT(setContentsPos(int))); |
498 | 498 | ||
499 | connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); | 499 | connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); |
500 | connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); | 500 | connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); |
501 | 501 | ||
502 | // Create/Show/Edit/Delete Event | 502 | // Create/Show/Edit/Delete Event |
503 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), | 503 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), |
504 | SLOT(newEvent(int,int))); | 504 | SLOT(newEvent(int,int))); |
505 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), | 505 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), |
506 | SLOT(newTodo(int,int))); | 506 | SLOT(newTodo(int,int))); |
507 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 507 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
508 | SLOT(newEvent(int,int,int,int))); | 508 | SLOT(newEvent(int,int,int,int))); |
509 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), | 509 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), |
510 | SLOT(newEventAllDay(int,int))); | 510 | SLOT(newEventAllDay(int,int))); |
511 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), | 511 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), |
512 | SLOT(newTodoAllDay(int,int))); | 512 | SLOT(newTodoAllDay(int,int))); |
513 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 513 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
514 | SLOT(newEventAllDay(int,int))); | 514 | SLOT(newEventAllDay(int,int))); |
515 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 515 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
516 | SLOT(newTimeSpanSelected(int,int,int,int))); | 516 | SLOT(newTimeSpanSelected(int,int,int,int))); |
517 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 517 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
518 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); | 518 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); |
519 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 519 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
520 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 520 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
521 | 521 | ||
522 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 522 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
523 | SIGNAL(editIncidenceSignal(Incidence *))); | 523 | SIGNAL(editIncidenceSignal(Incidence *))); |
524 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 524 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
525 | SIGNAL(editIncidenceSignal(Incidence *))); | 525 | SIGNAL(editIncidenceSignal(Incidence *))); |
526 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 526 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
527 | SIGNAL(showIncidenceSignal(Incidence *))); | 527 | SIGNAL(showIncidenceSignal(Incidence *))); |
528 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 528 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
529 | SIGNAL(showIncidenceSignal(Incidence *))); | 529 | SIGNAL(showIncidenceSignal(Incidence *))); |
530 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 530 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
531 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 531 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
532 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 532 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
533 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 533 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
534 | 534 | ||
535 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 535 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
536 | SLOT(updateEventDates(KOAgendaItem *, int ))); | 536 | SLOT(updateEventDates(KOAgendaItem *, int ))); |
537 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 537 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
538 | SLOT(updateEventDates(KOAgendaItem *, int))); | 538 | SLOT(updateEventDates(KOAgendaItem *, int))); |
539 | 539 | ||
540 | // event indicator update | 540 | // event indicator update |
541 | connect(mAgenda,SIGNAL(lowerYChanged(int)), | 541 | connect(mAgenda,SIGNAL(lowerYChanged(int)), |
542 | SLOT(updateEventIndicatorTop(int))); | 542 | SLOT(updateEventIndicatorTop(int))); |
543 | connect(mAgenda,SIGNAL(upperYChanged(int)), | 543 | connect(mAgenda,SIGNAL(upperYChanged(int)), |
544 | SLOT(updateEventIndicatorBottom(int))); | 544 | SLOT(updateEventIndicatorBottom(int))); |
545 | // drag signals | 545 | // drag signals |
546 | /* | 546 | /* |
547 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), | 547 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), |
548 | SLOT(startDrag(Event *))); | 548 | SLOT(startDrag(Event *))); |
549 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), | 549 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), |
550 | SLOT(startDrag(Event *))); | 550 | SLOT(startDrag(Event *))); |
551 | */ | 551 | */ |
552 | // synchronize selections | 552 | // synchronize selections |
553 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 553 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
554 | mAllDayAgenda, SLOT( deselectItem() ) ); | 554 | mAllDayAgenda, SLOT( deselectItem() ) ); |
555 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 555 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
556 | mAgenda, SLOT( deselectItem() ) ); | 556 | mAgenda, SLOT( deselectItem() ) ); |
557 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 557 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
558 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 558 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
559 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 559 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
560 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 560 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
561 | connect( mAgenda, SIGNAL( resizedSignal() ), | 561 | connect( mAgenda, SIGNAL( resizedSignal() ), |
562 | SLOT( updateConfig( ) ) ); | 562 | SLOT( updateConfig( ) ) ); |
563 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), | 563 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), |
564 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); | 564 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); |
565 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), | 565 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), |
566 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); | 566 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); |
567 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 567 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
568 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 568 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
569 | 569 | ||
570 | 570 | ||
571 | } | 571 | } |
572 | 572 | ||
573 | void KOAgendaView::toggleAllDay() | 573 | void KOAgendaView::toggleAllDay() |
574 | { | 574 | { |
575 | if ( mSplitterAgenda->firstHandle() ) | 575 | if ( mSplitterAgenda->firstHandle() ) |
576 | mSplitterAgenda->firstHandle()->toggle(); | 576 | mSplitterAgenda->firstHandle()->toggle(); |
577 | } | 577 | } |
578 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) | 578 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) |
579 | { | 579 | { |
580 | calendar()->addIncidence( inc ); | 580 | calendar()->addIncidence( inc ); |
581 | 581 | ||
582 | if ( incOld ) { | 582 | if ( incOld ) { |
583 | if ( incOld->type() == "Todo" ) | 583 | if ( incOld->type() == "Todo" ) |
584 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); | 584 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); |
585 | else | 585 | else |
586 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); | 586 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); |
587 | } | 587 | } |
588 | 588 | ||
589 | } | 589 | } |
590 | 590 | ||
591 | KOAgendaView::~KOAgendaView() | 591 | KOAgendaView::~KOAgendaView() |
592 | { | 592 | { |
593 | delete mAllAgendaPopup; | 593 | delete mAllAgendaPopup; |
594 | //delete mAllDayAgendaPopup; | 594 | //delete mAllDayAgendaPopup; |
595 | delete KOAgendaItem::paintPix(); | 595 | delete KOAgendaItem::paintPix(); |
596 | delete KOAgendaItem::paintPixSel(); | 596 | delete KOAgendaItem::paintPixSel(); |
597 | } | 597 | } |
598 | void KOAgendaView::resizeEvent( QResizeEvent* e ) | 598 | void KOAgendaView::resizeEvent( QResizeEvent* e ) |
599 | { | 599 | { |
600 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); | 600 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); |
601 | bool uc = false; | 601 | bool uc = false; |
602 | int ow = e->oldSize().width(); | 602 | int ow = e->oldSize().width(); |
603 | int oh = e->oldSize().height(); | 603 | int oh = e->oldSize().height(); |
604 | int w = e->size().width(); | 604 | int w = e->size().width(); |
605 | int h = e->size().height(); | 605 | int h = e->size().height(); |
606 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { | 606 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { |
607 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) | 607 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) |
608 | uc = true; | 608 | uc = true; |
609 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); | 609 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); |
610 | } | 610 | } |
611 | mUpcomingWidth = e->size().width() ; | 611 | mUpcomingWidth = e->size().width() ; |
612 | if ( mBlockUpdating || uc ) { | 612 | if ( mBlockUpdating || uc ) { |
613 | mBlockUpdating = false; | 613 | mBlockUpdating = false; |
614 | //mAgenda->setMinimumSize(800 , 600 ); | 614 | //mAgenda->setMinimumSize(800 , 600 ); |
615 | //qDebug("mAgenda->resize+++++++++++++++ "); | 615 | //qDebug("mAgenda->resize+++++++++++++++ "); |
616 | updateConfig(); | 616 | updateConfig(); |
617 | //qDebug("KOAgendaView::Updating now possible "); | 617 | //qDebug("KOAgendaView::Updating now possible "); |
618 | } else | 618 | } else |
619 | createDayLabels(); | 619 | createDayLabels(); |
620 | //qDebug("resizeEvent end "); | 620 | //qDebug("resizeEvent end "); |
621 | 621 | ||
622 | } | 622 | } |
623 | void KOAgendaView::slotDaylabelClicked( int num ) | 623 | void KOAgendaView::slotDaylabelClicked( int num ) |
624 | { | 624 | { |
625 | 625 | ||
626 | QDate firstDate = mSelectedDates.first(); | 626 | QDate firstDate = mSelectedDates.first(); |
627 | if ( num == -1 ) | 627 | if ( num == -1 ) |
628 | emit showDateView( 6, firstDate ); | 628 | emit showDateView( 6, firstDate ); |
629 | else if (num >= 0 ) { | 629 | else if (num >= 0 ) { |
630 | if ( mSelectedDates.count() == 1) | 630 | if ( mSelectedDates.count() == 1) |
631 | emit showDateView( 9, firstDate.addDays( num ) ); | 631 | emit showDateView( 9, firstDate.addDays( num ) ); |
632 | else | 632 | else |
633 | emit showDateView( 3, firstDate.addDays( num ) ); | 633 | emit showDateView( 3, firstDate.addDays( num ) ); |
634 | } | 634 | } |
635 | else | 635 | else |
636 | showDateView( 10, firstDate.addDays(1) ); | 636 | showDateView( 10, firstDate.addDays(1) ); |
637 | } | 637 | } |
638 | 638 | ||
639 | KOAgendaButton* KOAgendaView::getNewDaylabel() | 639 | KOAgendaButton* KOAgendaView::getNewDaylabel() |
640 | { | 640 | { |
641 | 641 | ||
642 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); | 642 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); |
643 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); | 643 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); |
644 | mDayLabelsList.append( dayLabel ); | 644 | mDayLabelsList.append( dayLabel ); |
645 | mLayoutDayLabels->addWidget(dayLabel); | 645 | mLayoutDayLabels->addWidget(dayLabel); |
646 | return dayLabel ; | 646 | return dayLabel ; |
647 | } | 647 | } |
648 | 648 | ||
649 | void KOAgendaView::createDayLabels() | 649 | void KOAgendaView::createDayLabels() |
650 | { | 650 | { |
651 | 651 | ||
652 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { | 652 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { |
653 | // qDebug(" KOAgendaView::createDayLabels() blocked "); | 653 | // qDebug(" KOAgendaView::createDayLabels() blocked "); |
654 | return; | 654 | return; |
655 | 655 | ||
656 | } | 656 | } |
657 | int newHight; | 657 | int newHight; |
658 | if ( !mSelectedDates.count()) | 658 | if ( !mSelectedDates.count()) |
659 | return; | 659 | return; |
660 | 660 | ||
661 | // ### Before deleting and recreating we could check if mSelectedDates changed... | 661 | // ### Before deleting and recreating we could check if mSelectedDates changed... |
662 | // It would remove some flickering and gain speed (since this is called by | 662 | // It would remove some flickering and gain speed (since this is called by |
663 | // each updateView() call) | 663 | // each updateView() call) |
664 | 664 | ||
665 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; | 665 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; |
666 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); | 666 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); |
667 | if ( maxWid < 20 ) | 667 | if ( maxWid < 20 ) |
668 | maxWid = 20; | 668 | maxWid = 20; |
669 | 669 | ||
670 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; | 670 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; |
671 | QFontMetrics fm ( dlf ); | 671 | QFontMetrics fm ( dlf ); |
672 | int selCount = mSelectedDates.count(); | 672 | int selCount = mSelectedDates.count(); |
673 | int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1; | 673 | int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1; |
674 | QString dayTest = "Mon 20"; | 674 | QString dayTest = "Mon 20"; |
675 | //QString dayTest = "Mon 20"; | 675 | //QString dayTest = "Mon 20"; |
676 | int wid = fm.width( dayTest ); | 676 | int wid = fm.width( dayTest ); |
677 | //maxWid -= ( selCount * 3 ); //working for QLabels | 677 | //maxWid -= ( selCount * 3 ); //working for QLabels |
678 | if ( QApplication::desktop()->width() <= 320 ) | 678 | if ( QApplication::desktop()->width() <= 320 ) |
679 | maxWid -= ( selCount * 3 ); //working for QPushButton | 679 | maxWid -= ( selCount * 3 ); //working for QPushButton |
680 | else | 680 | else |
681 | maxWid -= ( selCount * 3 ); //working for QPushButton | 681 | maxWid -= ( selCount * 3 ); //working for QPushButton |
682 | if ( maxWid < 0 ) | 682 | if ( maxWid < 0 ) |
683 | maxWid = 20; | 683 | maxWid = 20; |
684 | int needWid = wid * selCount; | 684 | int needWid = wid * selCount; |
685 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); | 685 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); |
686 | //if ( needWid > maxWid ) | 686 | //if ( needWid > maxWid ) |
687 | // qDebug("DAYLABELS TOOOOOOO BIG "); | 687 | // qDebug("DAYLABELS TOOOOOOO BIG "); |
688 | while ( needWid > maxWid ) { | 688 | while ( needWid > maxWid ) { |
689 | dayTest = dayTest.left( dayTest.length() - 1 ); | 689 | dayTest = dayTest.left( dayTest.length() - 1 ); |
690 | wid = fm.width( dayTest ); | 690 | wid = fm.width( dayTest ); |
691 | needWid = wid * selCount; | 691 | needWid = wid * selCount; |
692 | } | 692 | } |
693 | int maxLen = dayTest.length(); | 693 | int maxLen = dayTest.length(); |
694 | int fontPoint = dlf.pointSize(); | 694 | int fontPoint = dlf.pointSize(); |
695 | if ( maxLen < 2 ) { | 695 | if ( maxLen < 2 ) { |
696 | int fontPoint = dlf.pointSize(); | 696 | int fontPoint = dlf.pointSize(); |
697 | while ( fontPoint > 4 ) { | 697 | while ( fontPoint > 4 ) { |
698 | --fontPoint; | 698 | --fontPoint; |
699 | dlf.setPointSize( fontPoint ); | 699 | dlf.setPointSize( fontPoint ); |
700 | QFontMetrics f( dlf ); | 700 | QFontMetrics f( dlf ); |
701 | wid = f.width( "30" ); | 701 | wid = f.width( "30" ); |
702 | needWid = wid * selCount; | 702 | needWid = wid * selCount; |
703 | if ( needWid < maxWid ) | 703 | if ( needWid < maxWid ) |
704 | break; | 704 | break; |
705 | } | 705 | } |
706 | maxLen = 2; | 706 | maxLen = 2; |
707 | } | 707 | } |
708 | //qDebug("Max len %d ", dayTest.length() ); | 708 | //qDebug("Max len %d ", dayTest.length() ); |
709 | 709 | ||
710 | QFontMetrics tempF( dlf ); | 710 | QFontMetrics tempF( dlf ); |
711 | newHight = tempF.height(); | 711 | newHight = tempF.height(); |
712 | mDayLabels->setFont( dlf ); | 712 | mDayLabels->setFont( dlf ); |
713 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; | 713 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; |
714 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); | 714 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); |
715 | //mLayoutDayLabels->addSpacing( 2 ); | 715 | //mLayoutDayLabels->addSpacing( 2 ); |
716 | // QFont lFont = dlf; | 716 | // QFont lFont = dlf; |
717 | bool appendLabels = false; | 717 | bool appendLabels = false; |
718 | KOAgendaButton *dayLabel; | 718 | KOAgendaButton *dayLabel; |
719 | dayLabel = mDayLabelsList.first(); | 719 | dayLabel = mDayLabelsList.first(); |
720 | if ( !dayLabel ) { | 720 | if ( !dayLabel ) { |
721 | appendLabels = true; | 721 | appendLabels = true; |
722 | dayLabel = getNewDaylabel(); | 722 | dayLabel = getNewDaylabel(); |
723 | } | 723 | } |
724 | dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); | 724 | dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); |
725 | dayLabel->setFont( dlf ); | 725 | dayLabel->setFont( dlf ); |
726 | dayLabel->setNum( -1 ); | 726 | dayLabel->setNum( -1 ); |
727 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 727 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
728 | #if 0 | 728 | #if 0 |
729 | if ( QApplication::desktop()->width() <= 320 ) | 729 | if ( QApplication::desktop()->width() <= 320 ) |
730 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ).left(2) ); | 730 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ).left(2) ); |
731 | else | 731 | else |
732 | #endif | 732 | #endif |
733 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); | 733 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); |
734 | dayLabel->show(); | 734 | dayLabel->show(); |
735 | DateList::ConstIterator dit; | 735 | DateList::ConstIterator dit; |
736 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); | 736 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); |
737 | int counter = -1; | 737 | int counter = -1; |
738 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 738 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
739 | ++counter; | 739 | ++counter; |
740 | QDate date = *dit; | 740 | QDate date = *dit; |
741 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); | 741 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); |
742 | if ( ! appendLabels ) { | 742 | if ( ! appendLabels ) { |
743 | dayLabel = mDayLabelsList.next(); | 743 | dayLabel = mDayLabelsList.next(); |
744 | if ( !dayLabel ) | 744 | if ( !dayLabel ) |
745 | appendLabels = true; | 745 | appendLabels = true; |
746 | } | 746 | } |
747 | if ( appendLabels ) { | 747 | if ( appendLabels ) { |
748 | dayLabel = getNewDaylabel(); | 748 | dayLabel = getNewDaylabel(); |
749 | } | 749 | } |
750 | dayLabel->setMinimumWidth( 1 ); | 750 | dayLabel->setMinimumWidth( 1 ); |
751 | dayLabel->setMaximumWidth( 10240 ); | 751 | dayLabel->setMaximumWidth( 10240 ); |
752 | dayLabel->setFont( dlf ); | 752 | dayLabel->setFont( dlf ); |
753 | dayLabel->show(); | 753 | dayLabel->show(); |
754 | dayLabel->setAutoRepeat( false ); | 754 | dayLabel->setAutoRepeat( false ); |
755 | dayLabel->setNum( counter ); | 755 | dayLabel->setNum( counter ); |
756 | QString str; | 756 | QString str; |
757 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); | 757 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); |
758 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); | 758 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); |
759 | switch ( maxLen ) { | 759 | switch ( maxLen ) { |
760 | case 2: | 760 | case 2: |
761 | str = QString::number( date.day() ); | 761 | str = QString::number( date.day() ); |
762 | break; | 762 | break; |
763 | 763 | ||
764 | case 3: | 764 | case 3: |
765 | str = dayName.left( 1 ) +QString::number( date.day()); | 765 | str = dayName.left( 1 ) +QString::number( date.day()); |
766 | 766 | ||
767 | break; | 767 | break; |
768 | case 4: | 768 | case 4: |
769 | str = dayName.left( 1 ) + " " +QString::number( date.day()); | 769 | str = dayName.left( 1 ) + " " +QString::number( date.day()); |
770 | 770 | ||
771 | break; | 771 | break; |
772 | case 5: | 772 | case 5: |
773 | str = dayName.left( 2 ) + " " +QString::number( date.day()); | 773 | str = dayName.left( 2 ) + " " +QString::number( date.day()); |
774 | 774 | ||
775 | break; | 775 | break; |
776 | case 6: | 776 | case 6: |
777 | str = dayName.left( 3 ) + " " +QString::number( date.day()); | 777 | str = dayName.left( 3 ) + " " +QString::number( date.day()); |
778 | break; | 778 | break; |
779 | 779 | ||
780 | default: | 780 | default: |
781 | break; | 781 | break; |
782 | } | 782 | } |
783 | if ( oneday ) { | 783 | if ( oneday ) { |
784 | QString addString; | 784 | QString addString; |
785 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) | 785 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) |
786 | addString = i18n("Today"); | 786 | addString = i18n("Today"); |
787 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 787 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
788 | addString = i18n("Tomorrow"); | 788 | addString = i18n("Tomorrow"); |
789 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 789 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
790 | addString = i18n("Yesterday"); | 790 | addString = i18n("Yesterday"); |
791 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | 791 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) |
792 | addString = i18n("Day before yesterday"); | 792 | addString = i18n("Day before yesterday"); |
793 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 793 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
794 | addString = i18n("Day after tomorrow"); | 794 | addString = i18n("Day after tomorrow"); |
795 | if ( !addString.isEmpty() ) { | 795 | if ( !addString.isEmpty() ) { |
796 | str = addString+", " + str; | 796 | str = addString+", " + str; |
797 | } else { | 797 | } else { |
798 | str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); | 798 | str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); |
799 | } | 799 | } |
800 | } | 800 | } |
801 | dayLabel->setText(str); | 801 | dayLabel->setText(str); |
802 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 802 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
803 | if (date == QDate::currentDate()) { | 803 | if (date == QDate::currentDate()) { |
804 | QFont bFont = dlf; | 804 | QFont bFont = dlf; |
805 | bFont.setBold( true ); | 805 | bFont.setBold( true ); |
806 | dayLabel->setFont(bFont); | 806 | dayLabel->setFont(bFont); |
807 | } | 807 | } |
808 | //dayLayout->addWidget(dayLabel); | 808 | //dayLayout->addWidget(dayLabel); |
809 | 809 | ||
810 | #ifndef KORG_NOPLUGINS | 810 | #ifndef KORG_NOPLUGINS |
811 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); | 811 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); |
812 | CalendarDecoration *it; | 812 | CalendarDecoration *it; |
813 | for(it = cds.first(); it; it = cds.next()) { | 813 | for(it = cds.first(); it; it = cds.next()) { |
814 | QString text = it->shortText( date ); | 814 | QString text = it->shortText( date ); |
815 | if ( !text.isEmpty() ) { | 815 | if ( !text.isEmpty() ) { |
816 | QLabel *label = new QLabel(text,mDayLabels); | 816 | QLabel *label = new QLabel(text,mDayLabels); |
817 | label->setAlignment(AlignCenter); | 817 | label->setAlignment(AlignCenter); |
818 | dayLayout->addWidget(label); | 818 | dayLayout->addWidget(label); |
819 | } | 819 | } |
820 | } | 820 | } |
821 | 821 | ||
822 | for(it = cds.first(); it; it = cds.next()) { | 822 | for(it = cds.first(); it; it = cds.next()) { |
823 | QWidget *wid = it->smallWidget(mDayLabels,date); | 823 | QWidget *wid = it->smallWidget(mDayLabels,date); |
824 | if ( wid ) { | 824 | if ( wid ) { |
825 | // wid->setHeight(20); | 825 | // wid->setHeight(20); |
826 | dayLayout->addWidget(wid); | 826 | dayLayout->addWidget(wid); |
827 | } | 827 | } |
828 | } | 828 | } |
829 | #endif | 829 | #endif |
830 | } | 830 | } |
831 | if ( ! appendLabels ) { | 831 | if ( ! appendLabels ) { |
832 | dayLabel = mDayLabelsList.next(); | 832 | dayLabel = mDayLabelsList.next(); |
833 | if ( !dayLabel ) | 833 | if ( !dayLabel ) |
834 | appendLabels = true; | 834 | appendLabels = true; |
835 | } | 835 | } |
836 | if ( appendLabels ) { | 836 | if ( appendLabels ) { |
837 | dayLabel = getNewDaylabel(); | 837 | dayLabel = getNewDaylabel(); |
838 | } | 838 | } |
839 | //dayLabel->hide();//test only | 839 | //dayLabel->hide();//test only |
840 | 840 | ||
841 | dayLabel->setText(">"); | 841 | dayLabel->setText(">"); |
842 | dayLabel->setFont( dlf ); | 842 | dayLabel->setFont( dlf ); |
843 | dayLabel->setAutoRepeat( true ); | 843 | dayLabel->setAutoRepeat( true ); |
844 | dayLabel->show(); | 844 | dayLabel->show(); |
845 | dayLabel->setNum( -2 ); | 845 | dayLabel->setNum( -2 ); |
846 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo ); | 846 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo ); |
847 | 847 | ||
848 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); | 848 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); |
849 | if ( !appendLabels ) { | 849 | if ( !appendLabels ) { |
850 | dayLabel = mDayLabelsList.next(); | 850 | dayLabel = mDayLabelsList.next(); |
851 | while ( dayLabel ) { | 851 | while ( dayLabel ) { |
852 | //qDebug("!dayLabel %d",dayLabel ); | 852 | //qDebug("!dayLabel %d",dayLabel ); |
853 | dayLabel->hide(); | 853 | dayLabel->hide(); |
854 | dayLabel = mDayLabelsList.next(); | 854 | dayLabel = mDayLabelsList.next(); |
855 | } | 855 | } |
856 | } | 856 | } |
857 | 857 | ||
858 | mDayLabelsFrame->setFixedHeight( newHight + 4 ); | 858 | mDayLabelsFrame->setFixedHeight( newHight + 4 ); |
859 | } | 859 | } |
860 | 860 | ||
861 | int KOAgendaView::maxDatesHint() | 861 | int KOAgendaView::maxDatesHint() |
862 | { | 862 | { |
863 | // Not sure about the max number of events, so return 0 for now. | 863 | // Not sure about the max number of events, so return 0 for now. |
864 | return 0; | 864 | return 0; |
865 | } | 865 | } |
866 | 866 | ||
867 | int KOAgendaView::currentDateCount() | 867 | int KOAgendaView::currentDateCount() |
868 | { | 868 | { |
869 | return mSelectedDates.count(); | 869 | return mSelectedDates.count(); |
870 | } | 870 | } |
871 | 871 | ||
872 | QPtrList<Incidence> KOAgendaView::selectedIncidences() | 872 | QPtrList<Incidence> KOAgendaView::selectedIncidences() |
873 | { | 873 | { |
874 | QPtrList<Incidence> selected; | 874 | QPtrList<Incidence> selected; |
875 | Incidence *incidence; | 875 | Incidence *incidence; |
876 | 876 | ||
877 | incidence = mAgenda->selectedIncidence(); | 877 | incidence = mAgenda->selectedIncidence(); |
878 | if (incidence) selected.append(incidence); | 878 | if (incidence) selected.append(incidence); |
879 | 879 | ||
880 | incidence = mAllDayAgenda->selectedIncidence(); | 880 | incidence = mAllDayAgenda->selectedIncidence(); |
881 | if (incidence) selected.append(incidence); | 881 | if (incidence) selected.append(incidence); |
882 | 882 | ||
883 | return selected; | 883 | return selected; |
884 | } | 884 | } |
885 | 885 | ||
886 | DateList KOAgendaView::selectedDates() | 886 | DateList KOAgendaView::selectedDates() |
887 | { | 887 | { |
888 | DateList selected; | 888 | DateList selected; |
889 | QDate qd; | 889 | QDate qd; |
890 | 890 | ||
891 | qd = mAgenda->selectedIncidenceDate(); | 891 | qd = mAgenda->selectedIncidenceDate(); |
892 | if (qd.isValid()) selected.append(qd); | 892 | if (qd.isValid()) selected.append(qd); |
893 | 893 | ||
894 | qd = mAllDayAgenda->selectedIncidenceDate(); | 894 | qd = mAllDayAgenda->selectedIncidenceDate(); |
895 | if (qd.isValid()) selected.append(qd); | 895 | if (qd.isValid()) selected.append(qd); |
896 | 896 | ||
897 | return selected; | 897 | return selected; |
898 | } | 898 | } |
899 | 899 | ||
900 | 900 | ||
901 | void KOAgendaView::updateView() | 901 | void KOAgendaView::updateView() |
902 | { | 902 | { |
903 | if ( mBlockUpdating ) | 903 | if ( mBlockUpdating ) |
904 | return; | 904 | return; |
905 | // kdDebug() << "KOAgendaView::updateView()" << endl; | 905 | // kdDebug() << "KOAgendaView::updateView()" << endl; |
906 | fillAgenda(); | 906 | fillAgenda(); |
907 | 907 | ||
908 | } | 908 | } |
909 | 909 | ||
910 | 910 | ||
911 | /* | 911 | /* |
912 | Update configuration settings for the agenda view. This method is not | 912 | Update configuration settings for the agenda view. This method is not |
913 | complete. | 913 | complete. |
914 | */ | 914 | */ |
915 | void KOAgendaView::updateConfig() | 915 | void KOAgendaView::updateConfig() |
916 | { | 916 | { |
917 | if ( mBlockUpdating ) | 917 | if ( mBlockUpdating ) |
918 | return; | 918 | return; |
919 | if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { | 919 | if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { |
920 | int old = KOPrefs::instance()->mHourSize; | 920 | int old = KOPrefs::instance()->mHourSize; |
921 | KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; | 921 | KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; |
922 | qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); | 922 | qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); |
923 | } | 923 | } |
924 | 924 | ||
925 | 925 | ||
926 | // update config for children | 926 | // update config for children |
927 | mTimeLabels->updateConfig(); | 927 | mTimeLabels->updateConfig(); |
928 | mAgenda->storePosition(); | 928 | mAgenda->storePosition(); |
929 | mAgenda->updateConfig(); | 929 | mAgenda->updateConfig(); |
930 | mAllDayAgenda->updateConfig(); | 930 | mAllDayAgenda->updateConfig(); |
931 | // widget synchronization | 931 | // widget synchronization |
932 | //TODO: find a better way, maybe signal/slot | 932 | //TODO: find a better way, maybe signal/slot |
933 | mTimeLabels->positionChanged(); | 933 | mTimeLabels->positionChanged(); |
934 | 934 | ||
935 | // for some reason, this needs to be called explicitly | 935 | // for some reason, this needs to be called explicitly |
936 | mTimeLabels->repaint(); | 936 | mTimeLabels->repaint(); |
937 | 937 | ||
938 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 938 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
939 | 939 | ||
940 | // ToolTips displaying summary of events | 940 | // ToolTips displaying summary of events |
941 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() | 941 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() |
942 | ->mEnableToolTips); | 942 | ->mEnableToolTips); |
943 | 943 | ||
944 | //setHolidayMasks(); | 944 | //setHolidayMasks(); |
945 | 945 | ||
946 | //createDayLabels(); called by via updateView(); | 946 | //createDayLabels(); called by via updateView(); |
947 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); | 947 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); |
948 | updateView(); | 948 | updateView(); |
949 | mAgenda->restorePosition(); | 949 | mAgenda->restorePosition(); |
950 | } | 950 | } |
951 | 951 | ||
952 | 952 | ||
953 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) | 953 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) |
954 | { | 954 | { |
955 | 955 | ||
956 | 956 | ||
957 | int xxx = item->cellX(); | 957 | int xxx = item->cellX(); |
958 | //qDebug("KOAgendaView::updateEventDates %d %d %d %d %d", xxx, mMinY.at(xxx),mMaxY.at(xxx),item->cellYTop(),item->cellYBottom() ); | 958 | //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() ) | 959 | if ( mMinY.at(xxx) > item->cellYTop() ) |
960 | mMinY.at(xxx) = item->cellYTop(); | 960 | mMinY.at(xxx) = item->cellYTop(); |
961 | if ( mMaxY.at(xxx) < item->cellYBottom() ) | 961 | if ( mMaxY.at(xxx) < item->cellYBottom() ) |
962 | mMaxY.at(xxx) = item->cellYBottom(); | 962 | mMaxY.at(xxx) = item->cellYBottom(); |
963 | 963 | ||
964 | QDateTime startDt,endDt; | 964 | QDateTime startDt,endDt; |
965 | QDate startDate; | 965 | QDate startDate; |
966 | int lenInSecs; | 966 | int lenInSecs; |
967 | // if ( type == KOAgenda::RESIZETOP ) | 967 | // if ( type == KOAgenda::RESIZETOP ) |
968 | // qDebug("RESIZETOP "); | 968 | // qDebug("RESIZETOP "); |
969 | // if ( type == KOAgenda::RESIZEBOTTOM ) | 969 | // if ( type == KOAgenda::RESIZEBOTTOM ) |
970 | // qDebug("RESIZEBOTTOM "); | 970 | // qDebug("RESIZEBOTTOM "); |
971 | // if ( type == KOAgenda::MOVE ) | 971 | // if ( type == KOAgenda::MOVE ) |
972 | // qDebug("MOVE "); | 972 | // qDebug("MOVE "); |
973 | if ( item->incidence()->type() == "Event" ) { | 973 | if ( item->incidence()->type() == "Event" ) { |
974 | startDt =item->incidence()->dtStart(); | 974 | startDt =item->incidence()->dtStart(); |
975 | endDt = item->incidence()->dtEnd(); | 975 | endDt = item->incidence()->dtEnd(); |
976 | lenInSecs = startDt.secsTo( endDt ); | 976 | lenInSecs = startDt.secsTo( endDt ); |
977 | } | 977 | } |
978 | 978 | ||
979 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); | 979 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); |
980 | 980 | ||
981 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { | 981 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { |
982 | startDate = mSelectedDates[item->mLastMoveXPos]; | 982 | startDate = mSelectedDates[item->mLastMoveXPos]; |
983 | } else { | 983 | } else { |
984 | if (item->cellX() < 0) { | 984 | if (item->cellX() < 0) { |
985 | startDate = (mSelectedDates.first()).addDays(item->cellX()); | 985 | startDate = (mSelectedDates.first()).addDays(item->cellX()); |
986 | } else { | 986 | } else { |
987 | startDate = mSelectedDates[item->cellX()]; | 987 | startDate = mSelectedDates[item->cellX()]; |
988 | } | 988 | } |
989 | } | 989 | } |
990 | startDt.setDate(startDate); | 990 | startDt.setDate(startDate); |
991 | 991 | ||
992 | if (item->incidence()->doesFloat()) { | 992 | if (item->incidence()->doesFloat()) { |
993 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); | 993 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); |
994 | } else { | 994 | } else { |
995 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) | 995 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) |
996 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); | 996 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); |
997 | if ( item->incidence()->type() == "Event" ) { | 997 | if ( item->incidence()->type() == "Event" ) { |
998 | if ( type == KOAgenda::MOVE ) { | 998 | if ( type == KOAgenda::MOVE ) { |
999 | endDt = startDt.addSecs(lenInSecs); | 999 | endDt = startDt.addSecs(lenInSecs); |
1000 | 1000 | ||
1001 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { | 1001 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { |
1002 | if (item->lastMultiItem()) { | 1002 | if (item->lastMultiItem()) { |
1003 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 1003 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
1004 | endDt.setDate(startDate. | 1004 | endDt.setDate(startDate. |
1005 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 1005 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
1006 | } else { | 1006 | } else { |
1007 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 1007 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
1008 | endDt.setDate(startDate); | 1008 | endDt.setDate(startDate); |
1009 | } | 1009 | } |
1010 | } | 1010 | } |
1011 | } else { | 1011 | } else { |
1012 | // todo | 1012 | // todo |
1013 | if (item->lastMultiItem()) { | 1013 | if (item->lastMultiItem()) { |
1014 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 1014 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
1015 | endDt.setDate(startDate. | 1015 | endDt.setDate(startDate. |
1016 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 1016 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
1017 | } else { | 1017 | } else { |
1018 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); | 1018 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); |
1019 | if ( item->cellYBottom() > 0 ) | 1019 | if ( item->cellYBottom() > 0 ) |
1020 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 1020 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
1021 | else | 1021 | else |
1022 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); | 1022 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); |
1023 | endDt.setDate(startDate); | 1023 | endDt.setDate(startDate); |
1024 | } | 1024 | } |
1025 | } | 1025 | } |
1026 | } | 1026 | } |
1027 | if ( item->incidence()->type() == "Event" ) { | 1027 | if ( item->incidence()->type() == "Event" ) { |
1028 | item->incidence()->setDtStart(startDt); | 1028 | item->incidence()->setDtStart(startDt); |
1029 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); | 1029 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); |
1030 | } else if ( item->incidence()->type() == "Todo" ) { | 1030 | } else if ( item->incidence()->type() == "Todo" ) { |
1031 | Todo* to = static_cast<Todo*>(item->incidence()); | 1031 | Todo* to = static_cast<Todo*>(item->incidence()); |
1032 | 1032 | ||
1033 | to->setDtDue(endDt); | 1033 | to->setDtDue(endDt); |
1034 | if ( to->hasStartDate() ) { | 1034 | if ( to->hasStartDate() ) { |
1035 | if (to->dtStart() >= to->dtDue() ) | 1035 | if (to->dtStart() >= to->dtDue() ) |
1036 | to->setDtStart(to->dtDue().addDays( -2 )); | 1036 | to->setDtStart(to->dtDue().addDays( -2 )); |
1037 | } | 1037 | } |
1038 | 1038 | ||
1039 | } | 1039 | } |
1040 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); | 1040 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); |
1041 | item->incidence()->setRevision(item->incidence()->revision()+1); | 1041 | item->incidence()->setRevision(item->incidence()->revision()+1); |
1042 | item->setItemDate(startDt.date()); | 1042 | item->setItemDate(startDt.date()); |
1043 | //item->updateItem(); | 1043 | //item->updateItem(); |
1044 | if ( item->incidence()->type() == "Todo" ) { | 1044 | if ( item->incidence()->type() == "Todo" ) { |
1045 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); | 1045 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); |
1046 | 1046 | ||
1047 | } | 1047 | } |
1048 | else | 1048 | else |
1049 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); | 1049 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); |
1050 | item->updateItem(); | 1050 | item->updateItem(); |
1051 | } | 1051 | } |
1052 | 1052 | ||
1053 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) | 1053 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) |
1054 | { | 1054 | { |
1055 | // kdDebug() << "KOAgendaView::selectDates" << endl; | 1055 | // kdDebug() << "KOAgendaView::selectDates" << endl; |
1056 | 1056 | ||
1057 | mSelectedDates.clear(); | 1057 | mSelectedDates.clear(); |
1058 | // qDebug("KOAgendaView::showDates "); | 1058 | // qDebug("KOAgendaView::showDates "); |
1059 | QDate d = start; | 1059 | QDate d = start; |
1060 | while (d <= end) { | 1060 | while (d <= end) { |
1061 | mSelectedDates.append(d); | 1061 | mSelectedDates.append(d); |
1062 | d = d.addDays( 1 ); | 1062 | d = d.addDays( 1 ); |
1063 | } | 1063 | } |
1064 | 1064 | ||
1065 | // and update the view | 1065 | // and update the view |
1066 | fillAgenda(); | 1066 | fillAgenda(); |
1067 | } | 1067 | } |
1068 | 1068 | ||
1069 | 1069 | ||
1070 | void KOAgendaView::showEvents(QPtrList<Event>) | 1070 | void KOAgendaView::showEvents(QPtrList<Event>) |
1071 | { | 1071 | { |
1072 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; | 1072 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; |
1073 | } | 1073 | } |
1074 | 1074 | ||
1075 | void KOAgendaView::changeEventDisplay(Event *, int) | 1075 | void KOAgendaView::changeEventDisplay(Event *, int) |
1076 | { | 1076 | { |
1077 | // qDebug("KOAgendaView::changeEventDisplay "); | 1077 | // qDebug("KOAgendaView::changeEventDisplay "); |
1078 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; | 1078 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; |
1079 | // this should be re-written to be MUCH smarter. Right now we | 1079 | // this should be re-written to be MUCH smarter. Right now we |
1080 | // are just playing dumb. | 1080 | // are just playing dumb. |
1081 | fillAgenda(); | 1081 | fillAgenda(); |
1082 | } | 1082 | } |
1083 | 1083 | ||
1084 | void KOAgendaView::fillAgenda(const QDate &) | 1084 | void KOAgendaView::fillAgenda(const QDate &) |
1085 | { | 1085 | { |
1086 | // qDebug("KOAgendaView::fillAgenda "); | 1086 | // qDebug("KOAgendaView::fillAgenda "); |
1087 | fillAgenda(); | 1087 | fillAgenda(); |
1088 | } | 1088 | } |
1089 | 1089 | ||
1090 | void KOAgendaView::fillAgenda() | 1090 | void KOAgendaView::fillAgenda() |
1091 | { | 1091 | { |
1092 | if ( globalFlagBlockStartup ) | 1092 | if ( globalFlagBlockStartup ) |
1093 | return; | 1093 | return; |
1094 | if ( globalFlagBlockAgenda == 1 ) | 1094 | if ( globalFlagBlockAgenda == 1 ) |
1095 | return; | 1095 | return; |
1096 | static bool onlyOne = false; | 1096 | static bool onlyOne = false; |
1097 | if ( onlyOne ) | 1097 | if ( onlyOne ) |
1098 | return; | 1098 | return; |
1099 | onlyOne = true; | 1099 | onlyOne = true; |
1100 | //if ( globalFlagBlockAgenda == 2 ) | 1100 | //if ( globalFlagBlockAgenda == 2 ) |
1101 | //globalFlagBlockAgenda = 0; | 1101 | //globalFlagBlockAgenda = 0; |
1102 | // globalFlagBlockPainting = false; | 1102 | // globalFlagBlockPainting = false; |
1103 | if ( globalFlagBlockAgenda == 0 ) | 1103 | if ( globalFlagBlockAgenda == 0 ) |
1104 | globalFlagBlockAgenda = 1; | 1104 | globalFlagBlockAgenda = 1; |
1105 | // clearView(); | 1105 | // clearView(); |
1106 | //qDebug("fillAgenda()++++ "); | 1106 | //qDebug("fillAgenda()++++ "); |
1107 | globalFlagBlockAgendaItemPaint = 1; | 1107 | globalFlagBlockAgendaItemPaint = 1; |
1108 | 1108 | ||
1109 | mAllDayAgenda->changeColumns(mSelectedDates.count()); | 1109 | mAllDayAgenda->changeColumns(mSelectedDates.count()); |
1110 | mAgenda->changeColumns(mSelectedDates.count()); | 1110 | mAgenda->changeColumns(mSelectedDates.count()); |
1111 | qApp->processEvents(); | 1111 | qApp->processEvents(); |
1112 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); | 1112 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); |
1113 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); | 1113 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); |
1114 | setHolidayMasks(); | 1114 | setHolidayMasks(); |
1115 | 1115 | ||
1116 | //mAgenda->hideUnused(); | 1116 | //mAgenda->hideUnused(); |
1117 | //mAllDayAgenda->hideUnused(); | 1117 | //mAllDayAgenda->hideUnused(); |
1118 | 1118 | ||
1119 | // mAgenda->blockNextRepaint( false ); | 1119 | // mAgenda->blockNextRepaint( false ); |
1120 | // mAgenda->viewport()->repaint(); | 1120 | // mAgenda->viewport()->repaint(); |
1121 | // mAgenda->blockNextRepaint( true ); | 1121 | // mAgenda->blockNextRepaint( true ); |
1122 | mMinY.resize(mSelectedDates.count()); | 1122 | mMinY.resize(mSelectedDates.count()); |
1123 | mMaxY.resize(mSelectedDates.count()); | 1123 | mMaxY.resize(mSelectedDates.count()); |
1124 | 1124 | ||
1125 | QPtrList<Event> dayEvents; | 1125 | QPtrList<Event> dayEvents; |
1126 | 1126 | ||
1127 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1127 | // 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. | 1128 | // Therefore, gtodoset all of them. |
1129 | QPtrList<Todo> todos = calendar()->todos(); | 1129 | QPtrList<Todo> todos = calendar()->todos(); |
1130 | 1130 | ||
1131 | mAgenda->setDateList(mSelectedDates); | 1131 | mAgenda->setDateList(mSelectedDates); |
1132 | 1132 | ||
1133 | QDate today = QDate::currentDate(); | 1133 | QDate today = QDate::currentDate(); |
1134 | 1134 | ||
1135 | DateList::ConstIterator dit; | 1135 | DateList::ConstIterator dit; |
1136 | int curCol = 0; | 1136 | int curCol = 0; |
1137 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 1137 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
1138 | QDate currentDate = *dit; | 1138 | QDate currentDate = *dit; |
1139 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() | 1139 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() |
1140 | // << endl; | 1140 | // << endl; |
1141 | 1141 | ||
1142 | dayEvents = calendar()->events(currentDate,true); | 1142 | dayEvents = calendar()->events(currentDate,true); |
1143 | 1143 | ||
1144 | // Default values, which can never be reached | 1144 | // Default values, which can never be reached |
1145 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; | 1145 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; |
1146 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; | 1146 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; |
1147 | 1147 | ||
1148 | unsigned int numEvent; | 1148 | unsigned int numEvent; |
1149 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { | 1149 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { |
1150 | Event *event = dayEvents.at(numEvent); | 1150 | Event *event = dayEvents.at(numEvent); |
1151 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) | 1151 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) |
1152 | if ( event->uid().left(15) == QString("last-syncEvent-") ) | 1152 | if ( event->uid().left(15) == QString("last-syncEvent-") ) |
1153 | continue; | 1153 | continue; |
1154 | // kdDebug() << " Event: " << event->summary() << endl; | 1154 | // kdDebug() << " Event: " << event->summary() << endl; |
1155 | 1155 | ||
1156 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; | 1156 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; |
1157 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; | 1157 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; |
1158 | 1158 | ||
1159 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; | 1159 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; |
1160 | 1160 | ||
1161 | if (event->doesFloat()) { | 1161 | if (event->doesFloat()) { |
1162 | if (event->recurrence()->doesRecur()) { | 1162 | if (event->recurrence()->doesRecur()) { |
1163 | if (event->isMultiDay() ) { | 1163 | if (event->isMultiDay() ) { |
1164 | endX = endX - beginX;// endX is now number of days | 1164 | endX = endX - beginX;// endX is now number of days |
1165 | if ( event->recursOn( currentDate ) ) { | 1165 | if ( event->recursOn( currentDate ) ) { |
1166 | endX += curCol; | 1166 | endX += curCol; |
1167 | beginX = curCol; | 1167 | beginX = curCol; |
1168 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1168 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1169 | } else { | 1169 | } else { |
1170 | //qDebug("days %d %s",endX , currentDate.toString().latin1()); | 1170 | qDebug("days %d %s",endX , currentDate.toString().latin1()); |
1171 | QDate dateit = currentDate.addDays( -endX ); | 1171 | QDate dateit = currentDate.addDays( -endX ); |
1172 | if ( event->recursOn( dateit ) ) { | 1172 | if ( event->recursOn( dateit ) ) { |
1173 | //qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() ); | 1173 | qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() ); |
1174 | if ( curCol-endX < 0 ) { | 1174 | if ( curCol-endX < 0 ) { |
1175 | mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol); | 1175 | mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol); |
1176 | } | 1176 | } |
1177 | } | 1177 | } |
1178 | } | 1178 | } |
1179 | } else { | 1179 | } else { |
1180 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); | 1180 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); |
1181 | } | 1181 | } |
1182 | #if 0 | 1182 | #if 0 |
1183 | if (beginX <= 0 && curCol == 0) { | 1183 | if (beginX <= 0 && curCol == 0) { |
1184 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1184 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1185 | } else if (beginX == curCol) { | 1185 | } else if (beginX == curCol) { |
1186 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1186 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1187 | } else { | 1187 | } else { |
1188 | qDebug("skipped %d %d %d ",beginX , endX, curCol); | 1188 | qDebug("skipped %d %d %d ",beginX , endX, curCol); |
1189 | } | 1189 | } |
1190 | #endif | 1190 | #endif |
1191 | //mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); | 1191 | //mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); |
1192 | } else { | 1192 | } else { |
1193 | if (beginX <= 0 && curCol == 0) { | 1193 | if (beginX <= 0 && curCol == 0) { |
1194 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1194 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1195 | } else if (beginX == curCol) { | 1195 | } else if (beginX == curCol) { |
1196 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1196 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1197 | } | 1197 | } |
1198 | } | 1198 | } |
1199 | } else if (event->isMultiDay()) { | 1199 | } else if (event->isMultiDay()) { |
1200 | if ( event->doesRecur () ) { | 1200 | if ( event->doesRecur () ) { |
1201 | QDate dateit = currentDate; | 1201 | QDate dateit = currentDate; |
1202 | int count = 0; | 1202 | int count = 0; |
1203 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; | 1203 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; |
1204 | while (! event->recursOn( dateit ) && count <= max ) { | 1204 | while (! event->recursOn( dateit ) && count <= max ) { |
1205 | ++count; | 1205 | ++count; |
1206 | dateit = dateit.addDays( -1 ); | 1206 | dateit = dateit.addDays( -1 ); |
1207 | } | 1207 | } |
1208 | bool ok; | 1208 | bool ok; |
1209 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); | 1209 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); |
1210 | if ( ok ) | 1210 | if ( ok ) |
1211 | { | 1211 | { |
1212 | int secs = event->dtStart().secsTo( event->dtEnd() ); | 1212 | int secs = event->dtStart().secsTo( event->dtEnd() ); |
1213 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; | 1213 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; |
1214 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; | 1214 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; |
1215 | endX = currentDate.daysTo(nextOcend.date()) + curCol; | 1215 | endX = currentDate.daysTo(nextOcend.date()) + curCol; |
1216 | 1216 | ||
1217 | } | 1217 | } |
1218 | } | 1218 | } |
1219 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1219 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1220 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1220 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1221 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); | 1221 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); |
1222 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { | 1222 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { |
1223 | //qDebug("insert!!! "); | 1223 | //qDebug("insert!!! "); |
1224 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); | 1224 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); |
1225 | } | 1225 | } |
1226 | if (beginX == curCol) { | 1226 | if (beginX == curCol) { |
1227 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1227 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1228 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1228 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1229 | } else if (endX == curCol) { | 1229 | } else if (endX == curCol) { |
1230 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1230 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1231 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1231 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1232 | } else { | 1232 | } else { |
1233 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1233 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1234 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1234 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1235 | } | 1235 | } |
1236 | } else { | 1236 | } else { |
1237 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1237 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1238 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1238 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1239 | if (endY < startY) endY = startY; | 1239 | if (endY < startY) endY = startY; |
1240 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); | 1240 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); |
1241 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1241 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1242 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1242 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1243 | } | 1243 | } |
1244 | } | 1244 | } |
1245 | // ---------- [display Todos -------------- | 1245 | // ---------- [display Todos -------------- |
1246 | unsigned int numTodo; | 1246 | unsigned int numTodo; |
1247 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { | 1247 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { |
1248 | Todo *todo = todos.at(numTodo); | 1248 | Todo *todo = todos.at(numTodo); |
1249 | 1249 | ||
1250 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date | 1250 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date |
1251 | 1251 | ||
1252 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1252 | // 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 | 1253 | // Already completed items can be displayed on their original due date |
1254 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda | 1254 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda |
1255 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; | 1255 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; |
1256 | bool fillIn = false; | 1256 | bool fillIn = false; |
1257 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) | 1257 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) |
1258 | fillIn = true; | 1258 | fillIn = true; |
1259 | if ( ! fillIn && !todo->hasCompletedDate() ) | 1259 | if ( ! fillIn && !todo->hasCompletedDate() ) |
1260 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); | 1260 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); |
1261 | if ( fillIn ) { | 1261 | if ( fillIn ) { |
1262 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue | 1262 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue |
1263 | if ( KOPrefs::instance()->mShowTodoInAgenda ) | 1263 | if ( KOPrefs::instance()->mShowTodoInAgenda ) |
1264 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); | 1264 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); |
1265 | } | 1265 | } |
1266 | else { | 1266 | else { |
1267 | QDateTime dt; | 1267 | QDateTime dt; |
1268 | if ( todo->hasCompletedDate() ) | 1268 | if ( todo->hasCompletedDate() ) |
1269 | dt = todo->completed(); | 1269 | dt = todo->completed(); |
1270 | else | 1270 | else |
1271 | dt = todo->dtDue();; | 1271 | dt = todo->dtDue();; |
1272 | 1272 | ||
1273 | 1273 | ||
1274 | int endY = mAgenda->timeToY(dt.time()) - 1; | 1274 | int endY = mAgenda->timeToY(dt.time()) - 1; |
1275 | int hi = (18/KOPrefs::instance()->mHourSize); | 1275 | int hi = (18/KOPrefs::instance()->mHourSize); |
1276 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); | 1276 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); |
1277 | int startY = endY -hi; | 1277 | int startY = endY -hi; |
1278 | 1278 | ||
1279 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); | 1279 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); |
1280 | 1280 | ||
1281 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1281 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1282 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1282 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1283 | } | 1283 | } |
1284 | } | 1284 | } |
1285 | } | 1285 | } |
1286 | // ---------- display Todos] -------------- | 1286 | // ---------- display Todos] -------------- |
1287 | 1287 | ||
1288 | ++curCol; | 1288 | ++curCol; |
1289 | } | 1289 | } |
1290 | mAgenda->hideUnused(); | 1290 | mAgenda->hideUnused(); |
1291 | mAllDayAgenda->hideUnused(); | 1291 | mAllDayAgenda->hideUnused(); |
1292 | mAgenda->checkScrollBoundaries(); | 1292 | mAgenda->checkScrollBoundaries(); |
1293 | 1293 | ||
1294 | deleteSelectedDateTime(); | 1294 | deleteSelectedDateTime(); |
1295 | 1295 | ||
1296 | createDayLabels(); | 1296 | createDayLabels(); |
1297 | emit incidenceSelected( 0 ); | 1297 | emit incidenceSelected( 0 ); |
1298 | 1298 | ||
1299 | if ( globalFlagBlockAgenda == 2 ) { | 1299 | if ( globalFlagBlockAgenda == 2 ) { |
1300 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) | 1300 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) |
1301 | setStartHour( KOPrefs::instance()->mDayBegins ); | 1301 | setStartHour( KOPrefs::instance()->mDayBegins ); |
1302 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 1302 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
1303 | setStartHour( QTime::currentTime ().hour() ); | 1303 | setStartHour( QTime::currentTime ().hour() ); |
1304 | // qApp->processEvents(); | 1304 | // qApp->processEvents(); |
1305 | } | 1305 | } |
1306 | qApp->processEvents(); | 1306 | qApp->processEvents(); |
1307 | //qDebug("qApp->processEvents(); END "); | 1307 | //qDebug("qApp->processEvents(); END "); |
1308 | globalFlagBlockAgenda = 0; | 1308 | globalFlagBlockAgenda = 0; |
1309 | 1309 | ||
1310 | // mAgenda->hideUnused(); | 1310 | // mAgenda->hideUnused(); |
1311 | //mAllDayAgenda->hideUnused(); | 1311 | //mAllDayAgenda->hideUnused(); |
1312 | mAllDayAgenda->drawContentsToPainter(); | 1312 | mAllDayAgenda->drawContentsToPainter(); |
1313 | mAgenda->drawContentsToPainter(); | 1313 | mAgenda->drawContentsToPainter(); |
1314 | repaintAgenda(); | 1314 | repaintAgenda(); |
1315 | onlyOne = false; | 1315 | onlyOne = false; |
1316 | // mAgenda->finishUpdate(); | 1316 | // mAgenda->finishUpdate(); |
1317 | //mAllDayAgenda->finishUpdate(); | 1317 | //mAllDayAgenda->finishUpdate(); |
1318 | 1318 | ||
1319 | // repaintAgenda(); | 1319 | // repaintAgenda(); |
1320 | //qApp->processEvents(); | 1320 | //qApp->processEvents(); |
1321 | // globalFlagBlockAgenda = 0; | 1321 | // globalFlagBlockAgenda = 0; |
1322 | } | 1322 | } |
1323 | void KOAgendaView::repaintAgenda() | 1323 | void KOAgendaView::repaintAgenda() |
1324 | { | 1324 | { |
1325 | // mAllDayAgenda->drawContentsToPainter(); | 1325 | // mAllDayAgenda->drawContentsToPainter(); |
1326 | // mAllDayAgenda->viewport()->repaint( false ); | 1326 | // mAllDayAgenda->viewport()->repaint( false ); |
1327 | // mAgenda->drawContentsToPainter(); | 1327 | // mAgenda->drawContentsToPainter(); |
1328 | // mAgenda->viewport()->repaint( false ); | 1328 | // mAgenda->viewport()->repaint( false ); |
1329 | // qApp->processEvents(); | 1329 | // qApp->processEvents(); |
1330 | 1330 | ||
1331 | //qDebug("KOAgendaView::repaintAgenda() "); | 1331 | //qDebug("KOAgendaView::repaintAgenda() "); |
1332 | //qApp->processEvents(); | 1332 | //qApp->processEvents(); |
1333 | mAgenda->viewport()->repaint( false ); | 1333 | mAgenda->viewport()->repaint( false ); |
1334 | mAllDayAgenda->viewport()->repaint( false ); | 1334 | mAllDayAgenda->viewport()->repaint( false ); |
1335 | mAgenda->finishUpdate(); | 1335 | mAgenda->finishUpdate(); |
1336 | mAllDayAgenda->finishUpdate(); | 1336 | mAllDayAgenda->finishUpdate(); |
1337 | } | 1337 | } |
1338 | 1338 | ||
1339 | 1339 | ||
1340 | void KOAgendaView::clearView() | 1340 | void KOAgendaView::clearView() |
1341 | { | 1341 | { |
1342 | // kdDebug() << "ClearView" << endl; | 1342 | // kdDebug() << "ClearView" << endl; |
1343 | mAllDayAgenda->clear(); | 1343 | mAllDayAgenda->clear(); |
1344 | mAgenda->clear(); | 1344 | mAgenda->clear(); |
1345 | } | 1345 | } |
1346 | 1346 | ||
1347 | void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1347 | void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1348 | const QDate &td) | 1348 | const QDate &td) |
1349 | { | 1349 | { |
1350 | #ifndef KORG_NOPRINTER | 1350 | #ifndef KORG_NOPRINTER |
1351 | if (fd == td) | 1351 | if (fd == td) |
1352 | calPrinter->preview(CalPrinter::Day, fd, td); | 1352 | calPrinter->preview(CalPrinter::Day, fd, td); |
1353 | else | 1353 | else |
1354 | calPrinter->preview(CalPrinter::Week, fd, td); | 1354 | calPrinter->preview(CalPrinter::Week, fd, td); |
1355 | #endif | 1355 | #endif |
1356 | } | 1356 | } |
1357 | 1357 | ||
1358 | // void KOAgendaView::updateMovedTodo() | 1358 | // void KOAgendaView::updateMovedTodo() |
1359 | // { | 1359 | // { |
1360 | // // updateConfig(); | 1360 | // // updateConfig(); |
1361 | // // emit updateTodoViews(); | 1361 | // // emit updateTodoViews(); |
1362 | // } | 1362 | // } |
1363 | 1363 | ||
1364 | void KOAgendaView::slotShowDateView( int mode , int d ) | 1364 | void KOAgendaView::slotShowDateView( int mode , int d ) |
1365 | { | 1365 | { |
1366 | if ( d >= mSelectedDates.count() ) { | 1366 | if ( d >= mSelectedDates.count() ) { |
1367 | qDebug("KOAgendaView::slotShowDateView datecounterror %d d ", d, mSelectedDates.count() ); | 1367 | qDebug("KOAgendaView::slotShowDateView datecounterror %d d ", d, mSelectedDates.count() ); |
1368 | 1368 | ||
1369 | } else { | 1369 | } else { |
1370 | QDate day = mSelectedDates[d]; | 1370 | QDate day = mSelectedDates[d]; |
1371 | emit showDateView(mode , day ); | 1371 | emit showDateView(mode , day ); |
1372 | } | 1372 | } |
1373 | 1373 | ||
1374 | } | 1374 | } |
1375 | void KOAgendaView::newEvent(int gx, int gy) | 1375 | void KOAgendaView::newEvent(int gx, int gy) |
1376 | { | 1376 | { |
1377 | if (!mSelectedDates.count()) return; | 1377 | if (!mSelectedDates.count()) return; |
1378 | 1378 | ||
1379 | QDate day = mSelectedDates[gx]; | 1379 | QDate day = mSelectedDates[gx]; |
1380 | 1380 | ||
1381 | QTime time = mAgenda->gyToTime(gy); | 1381 | QTime time = mAgenda->gyToTime(gy); |
1382 | QDateTime dt(day,time); | 1382 | QDateTime dt(day,time); |
1383 | // if ( dt < QDateTime::currentDateTime () ) | 1383 | // if ( dt < QDateTime::currentDateTime () ) |
1384 | // dt = QDateTime::currentDateTime ().addSecs( 3600 ); | 1384 | // dt = QDateTime::currentDateTime ().addSecs( 3600 ); |
1385 | emit newEventSignal(dt); | 1385 | emit newEventSignal(dt); |
1386 | } | 1386 | } |
1387 | 1387 | ||
1388 | void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) | 1388 | void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) |
1389 | { | 1389 | { |
1390 | if (!mSelectedDates.count()) return; | 1390 | if (!mSelectedDates.count()) return; |
1391 | 1391 | ||
1392 | QDate dayStart = mSelectedDates[gxStart]; | 1392 | QDate dayStart = mSelectedDates[gxStart]; |
1393 | QDate dayEnd = mSelectedDates[gxEnd]; | 1393 | QDate dayEnd = mSelectedDates[gxEnd]; |
1394 | 1394 | ||
1395 | QTime timeStart = mAgenda->gyToTime(gyStart); | 1395 | QTime timeStart = mAgenda->gyToTime(gyStart); |
1396 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); | 1396 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); |
1397 | 1397 | ||
1398 | QDateTime dtStart(dayStart,timeStart); | 1398 | QDateTime dtStart(dayStart,timeStart); |
1399 | QDateTime dtEnd(dayEnd,timeEnd); | 1399 | QDateTime dtEnd(dayEnd,timeEnd); |
1400 | 1400 | ||
1401 | emit newEventSignal(dtStart,dtEnd); | 1401 | emit newEventSignal(dtStart,dtEnd); |
1402 | } | 1402 | } |
1403 | 1403 | ||
1404 | void KOAgendaView::newEventAllDay(int gx, int ) | 1404 | void KOAgendaView::newEventAllDay(int gx, int ) |
1405 | { | 1405 | { |
1406 | if (!mSelectedDates.count()) return; | 1406 | if (!mSelectedDates.count()) return; |
1407 | 1407 | ||
1408 | QDate day = mSelectedDates[gx]; | 1408 | QDate day = mSelectedDates[gx]; |
1409 | 1409 | ||
1410 | emit newEventSignal(day); | 1410 | emit newEventSignal(day); |
1411 | } | 1411 | } |
1412 | void KOAgendaView::newTodoAllDay(int gx, int ) | 1412 | void KOAgendaView::newTodoAllDay(int gx, int ) |
1413 | { | 1413 | { |
1414 | if (!mSelectedDates.count()) return; | 1414 | if (!mSelectedDates.count()) return; |
1415 | 1415 | ||
1416 | QDateTime day (mSelectedDates[gx] ); | 1416 | QDateTime day (mSelectedDates[gx] ); |
1417 | emit newTodoSignal(day, true); | 1417 | emit newTodoSignal(day, true); |
1418 | } | 1418 | } |
1419 | void KOAgendaView::newTodo(int gx, int gy ) | 1419 | void KOAgendaView::newTodo(int gx, int gy ) |
1420 | { | 1420 | { |
1421 | if (!mSelectedDates.count()) return; | 1421 | if (!mSelectedDates.count()) return; |
1422 | QDate dayStart = mSelectedDates[gx]; | 1422 | QDate dayStart = mSelectedDates[gx]; |
1423 | QTime timeStart = mAgenda->gyToTime(gy); | 1423 | QTime timeStart = mAgenda->gyToTime(gy); |
1424 | QDateTime dt (dayStart,timeStart); | 1424 | QDateTime dt (dayStart,timeStart); |
1425 | emit newTodoSignal( dt, false ); | 1425 | emit newTodoSignal( dt, false ); |
1426 | } | 1426 | } |
1427 | 1427 | ||
1428 | void KOAgendaView::updateEventIndicatorTop(int newY) | 1428 | void KOAgendaView::updateEventIndicatorTop(int newY) |
1429 | { | 1429 | { |
1430 | uint i; | 1430 | uint i; |
1431 | for(i=0;i<mMinY.size();++i) { | 1431 | for(i=0;i<mMinY.size();++i) { |
1432 | if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); | 1432 | if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); |
1433 | else mEventIndicatorTop->enableColumn(i,false); | 1433 | else mEventIndicatorTop->enableColumn(i,false); |
1434 | } | 1434 | } |
1435 | 1435 | ||
1436 | mEventIndicatorTop->update(); | 1436 | mEventIndicatorTop->update(); |
1437 | } | 1437 | } |
1438 | 1438 | ||
1439 | void KOAgendaView::updateEventIndicatorBottom(int newY) | 1439 | void KOAgendaView::updateEventIndicatorBottom(int newY) |
1440 | { | 1440 | { |
1441 | uint i; | 1441 | uint i; |
1442 | for(i=0;i<mMaxY.size();++i) { | 1442 | for(i=0;i<mMaxY.size();++i) { |
1443 | if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); | 1443 | if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); |
1444 | else mEventIndicatorBottom->enableColumn(i,false); | 1444 | else mEventIndicatorBottom->enableColumn(i,false); |
1445 | } | 1445 | } |
1446 | 1446 | ||
1447 | mEventIndicatorBottom->update(); | 1447 | mEventIndicatorBottom->update(); |
1448 | } | 1448 | } |
1449 | 1449 | ||
1450 | void KOAgendaView::startDrag(Event *event) | 1450 | void KOAgendaView::startDrag(Event *event) |
1451 | { | 1451 | { |
1452 | #ifndef KORG_NODND | 1452 | #ifndef KORG_NODND |
1453 | DndFactory factory( calendar() ); | 1453 | DndFactory factory( calendar() ); |
1454 | ICalDrag *vd = factory.createDrag(event,this); | 1454 | ICalDrag *vd = factory.createDrag(event,this); |
1455 | if (vd->drag()) { | 1455 | if (vd->drag()) { |
1456 | kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; | 1456 | kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; |
1457 | } | 1457 | } |
1458 | #endif | 1458 | #endif |
1459 | } | 1459 | } |
1460 | 1460 | ||
1461 | void KOAgendaView::readSettings() | 1461 | void KOAgendaView::readSettings() |
1462 | { | 1462 | { |
1463 | readSettings(KOGlobals::config()); | 1463 | readSettings(KOGlobals::config()); |
1464 | } | 1464 | } |
1465 | 1465 | ||
1466 | void KOAgendaView::readSettings(KConfig *config) | 1466 | void KOAgendaView::readSettings(KConfig *config) |
1467 | { | 1467 | { |
1468 | // kdDebug() << "KOAgendaView::readSettings()" << endl; | 1468 | // kdDebug() << "KOAgendaView::readSettings()" << endl; |
1469 | 1469 | ||
1470 | config->setGroup("Views"); | 1470 | config->setGroup("Views"); |
1471 | 1471 | ||
1472 | //#ifndef KORG_NOSPLITTER | 1472 | //#ifndef KORG_NOSPLITTER |
1473 | QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); | 1473 | QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); |
1474 | if (sizes.count() == 2) { | 1474 | if (sizes.count() == 2) { |
1475 | if ( sizes[0] < 20 ) { | 1475 | if ( sizes[0] < 20 ) { |
1476 | sizes[1] = sizes[1] +20 - sizes[0]; | 1476 | sizes[1] = sizes[1] +20 - sizes[0]; |
1477 | sizes[0] = 20; | 1477 | sizes[0] = 20; |
1478 | } | 1478 | } |
1479 | mSplitterAgenda->setSizes(sizes); | 1479 | mSplitterAgenda->setSizes(sizes); |
1480 | // qDebug("read %d %d ",sizes[0],sizes[1] ); | 1480 | // qDebug("read %d %d ",sizes[0],sizes[1] ); |
1481 | } | 1481 | } |
1482 | //#endif | 1482 | //#endif |
1483 | 1483 | ||
1484 | // updateConfig(); | 1484 | // updateConfig(); |
1485 | } | 1485 | } |
1486 | 1486 | ||
1487 | void KOAgendaView::writeSettings(KConfig *config) | 1487 | void KOAgendaView::writeSettings(KConfig *config) |
1488 | { | 1488 | { |
1489 | // kdDebug() << "KOAgendaView::writeSettings()" << endl; | 1489 | // kdDebug() << "KOAgendaView::writeSettings()" << endl; |
1490 | 1490 | ||
1491 | config->setGroup("Views"); | 1491 | config->setGroup("Views"); |
1492 | 1492 | ||
1493 | //#ifndef KORG_NOSPLITTER | 1493 | //#ifndef KORG_NOSPLITTER |
1494 | QValueList<int> list = mSplitterAgenda->sizes(); | 1494 | QValueList<int> list = mSplitterAgenda->sizes(); |
1495 | config->writeEntry("Separator AgendaView",list); | 1495 | config->writeEntry("Separator AgendaView",list); |
1496 | //qDebug("write %d %d ", list[0],list[1] ); | 1496 | //qDebug("write %d %d ", list[0],list[1] ); |
1497 | //#endif | 1497 | //#endif |
1498 | } | 1498 | } |
1499 | 1499 | ||
1500 | void KOAgendaView::setHolidayMasks() | 1500 | void KOAgendaView::setHolidayMasks() |
1501 | { | 1501 | { |
1502 | mHolidayMask.resize(mSelectedDates.count()); | 1502 | mHolidayMask.resize(mSelectedDates.count()); |
1503 | 1503 | ||
1504 | uint i; | 1504 | uint i; |
1505 | for(i=0;i<mSelectedDates.count();++i) { | 1505 | for(i=0;i<mSelectedDates.count();++i) { |
1506 | QDate date = mSelectedDates[i]; | 1506 | QDate date = mSelectedDates[i]; |
1507 | bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); | 1507 | bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); |
1508 | bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); | 1508 | bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); |
1509 | bool showHoliday = false; | 1509 | bool showHoliday = false; |
1510 | if ( KOPrefs::instance()->mExcludeHolidays ) { | 1510 | if ( KOPrefs::instance()->mExcludeHolidays ) { |
1511 | QPtrList<Event> events = calendar()->events( date, true ); | 1511 | QPtrList<Event> events = calendar()->events( date, true ); |
1512 | Event *event; | 1512 | Event *event; |
1513 | for( event = events.first(); event; event = events.next() ) { | 1513 | for( event = events.first(); event; event = events.next() ) { |
1514 | if ( event->isHoliday()) { | 1514 | if ( event->isHoliday()) { |
1515 | showHoliday = true; | 1515 | showHoliday = true; |
1516 | break; | 1516 | break; |
1517 | } | 1517 | } |
1518 | } | 1518 | } |
1519 | 1519 | ||
1520 | } | 1520 | } |
1521 | 1521 | ||
1522 | #ifndef KORG_NOPLUGINS | 1522 | #ifndef KORG_NOPLUGINS |
1523 | bool showHoliday = KOPrefs::instance()->mExcludeHolidays && | 1523 | bool showHoliday = KOPrefs::instance()->mExcludeHolidays && |
1524 | !KOCore::self()->holiday(date).isEmpty(); | 1524 | !KOCore::self()->holiday(date).isEmpty(); |
1525 | #endif | 1525 | #endif |
1526 | bool showDay = showSaturday || showSunday || showHoliday; | 1526 | bool showDay = showSaturday || showSunday || showHoliday; |
1527 | 1527 | ||
1528 | if (showDay) { | 1528 | if (showDay) { |
1529 | mHolidayMask.at(i) = true; | 1529 | mHolidayMask.at(i) = true; |
1530 | } else { | 1530 | } else { |
1531 | mHolidayMask.at(i) = false; | 1531 | mHolidayMask.at(i) = false; |
1532 | } | 1532 | } |
1533 | } | 1533 | } |
1534 | 1534 | ||
1535 | mAgenda->setHolidayMask(&mHolidayMask); | 1535 | mAgenda->setHolidayMask(&mHolidayMask); |
1536 | mAllDayAgenda->setHolidayMask(&mHolidayMask); | 1536 | mAllDayAgenda->setHolidayMask(&mHolidayMask); |
1537 | } | 1537 | } |
1538 | 1538 | ||
1539 | void KOAgendaView::setContentsPos(int y) | 1539 | void KOAgendaView::setContentsPos(int y) |
1540 | { | 1540 | { |
1541 | mAgenda->setContentsPos(0,y); | 1541 | mAgenda->setContentsPos(0,y); |
1542 | } | 1542 | } |
1543 | 1543 | ||
1544 | void KOAgendaView::clearSelection() | 1544 | void KOAgendaView::clearSelection() |
1545 | { | 1545 | { |
1546 | mAgenda->deselectItem(); | 1546 | mAgenda->deselectItem(); |
1547 | mAllDayAgenda->deselectItem(); | 1547 | mAllDayAgenda->deselectItem(); |
1548 | } | 1548 | } |
1549 | 1549 | ||
1550 | void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, | 1550 | void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, |
1551 | int gxEnd, int gyEnd) | 1551 | int gxEnd, int gyEnd) |
1552 | { | 1552 | { |
1553 | mTimeSpanInAllDay = true; | 1553 | mTimeSpanInAllDay = true; |
1554 | newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); | 1554 | newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); |
1555 | } | 1555 | } |
1556 | 1556 | ||
1557 | 1557 | ||
1558 | 1558 | ||
1559 | 1559 | ||
1560 | void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, | 1560 | void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, |
1561 | int gxEnd, int gyEnd) | 1561 | int gxEnd, int gyEnd) |
1562 | { | 1562 | { |
1563 | if (!mSelectedDates.count()) return; | 1563 | if (!mSelectedDates.count()) return; |
1564 | 1564 | ||
1565 | QDate dayStart = mSelectedDates[gxStart]; | 1565 | QDate dayStart = mSelectedDates[gxStart]; |
1566 | QDate dayEnd = mSelectedDates[gxEnd]; | 1566 | QDate dayEnd = mSelectedDates[gxEnd]; |
1567 | 1567 | ||
1568 | QTime timeStart = mAgenda->gyToTime(gyStart); | 1568 | QTime timeStart = mAgenda->gyToTime(gyStart); |
1569 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); | 1569 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); |
1570 | 1570 | ||
1571 | QDateTime dtStart(dayStart,timeStart); | 1571 | QDateTime dtStart(dayStart,timeStart); |
1572 | QDateTime dtEnd(dayEnd,timeEnd); | 1572 | QDateTime dtEnd(dayEnd,timeEnd); |
1573 | 1573 | ||
1574 | mTimeSpanBegin = dtStart; | 1574 | mTimeSpanBegin = dtStart; |
1575 | mTimeSpanEnd = dtEnd; | 1575 | mTimeSpanEnd = dtEnd; |
1576 | 1576 | ||
1577 | } | 1577 | } |
1578 | 1578 | ||
1579 | void KOAgendaView::deleteSelectedDateTime() | 1579 | void KOAgendaView::deleteSelectedDateTime() |
1580 | { | 1580 | { |
1581 | mTimeSpanBegin.setDate(QDate()); | 1581 | mTimeSpanBegin.setDate(QDate()); |
1582 | mTimeSpanEnd.setDate(QDate()); | 1582 | mTimeSpanEnd.setDate(QDate()); |
1583 | mTimeSpanInAllDay = false; | 1583 | mTimeSpanInAllDay = false; |
1584 | } | 1584 | } |
1585 | 1585 | ||
1586 | void KOAgendaView::keyPressEvent ( QKeyEvent * e ) | 1586 | void KOAgendaView::keyPressEvent ( QKeyEvent * e ) |
1587 | { | 1587 | { |
1588 | e->ignore(); | 1588 | e->ignore(); |
1589 | } | 1589 | } |
1590 | 1590 | ||
1591 | void KOAgendaView::scrollOneHourUp() | 1591 | void KOAgendaView::scrollOneHourUp() |
1592 | { | 1592 | { |
1593 | 1593 | ||
1594 | mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); | 1594 | mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); |
1595 | } | 1595 | } |
1596 | void KOAgendaView::scrollOneHourDown() | 1596 | void KOAgendaView::scrollOneHourDown() |
1597 | { | 1597 | { |
1598 | mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); | 1598 | mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); |
1599 | } | 1599 | } |
1600 | 1600 | ||
1601 | void KOAgendaView::setStartHour( int h ) | 1601 | void KOAgendaView::setStartHour( int h ) |
1602 | { | 1602 | { |
1603 | mAgenda->setStartHour( h ); | 1603 | mAgenda->setStartHour( h ); |
1604 | 1604 | ||
1605 | } | 1605 | } |
1606 | void KOAgendaView::setInitStartHour() | 1606 | void KOAgendaView::setInitStartHour() |
1607 | { | 1607 | { |
1608 | 1608 | ||
1609 | if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 1609 | if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
1610 | setStartHour( QTime::currentTime ().hour() ); | 1610 | setStartHour( QTime::currentTime ().hour() ); |
1611 | else | 1611 | else |
1612 | setStartHour( KOPrefs::instance()->mDayBegins ); | 1612 | setStartHour( KOPrefs::instance()->mDayBegins ); |
1613 | 1613 | ||
1614 | } | 1614 | } |
1615 | 1615 | ||
1616 | 1616 | ||
1617 | void KOAgendaView::updateTodo( Todo * t, int ) | 1617 | void KOAgendaView::updateTodo( Todo * t, int ) |
1618 | { | 1618 | { |
1619 | if ( !isVisible() ) | 1619 | if ( !isVisible() ) |
1620 | return; | 1620 | return; |
1621 | bool remove = false; | 1621 | bool remove = false; |
1622 | bool removeAD = false; | 1622 | bool removeAD = false; |
1623 | QDate da; | 1623 | QDate da; |
1624 | if ( t->hasCompletedDate() ) | 1624 | if ( t->hasCompletedDate() ) |
1625 | da = t->completed().date(); | 1625 | da = t->completed().date(); |
1626 | else | 1626 | else |
1627 | da = t->dtDue().date(); | 1627 | da = t->dtDue().date(); |
1628 | if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { | 1628 | if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { |
1629 | remove = true; | 1629 | remove = true; |
1630 | removeAD = true; | 1630 | removeAD = true; |
1631 | } | 1631 | } |
1632 | else { | 1632 | else { |
1633 | bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; | 1633 | bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; |
1634 | if ( overdue && | 1634 | if ( overdue && |
1635 | QDate::currentDate() >= mSelectedDates.first() && | 1635 | QDate::currentDate() >= mSelectedDates.first() && |
1636 | QDate::currentDate() <= mSelectedDates.last()) { | 1636 | QDate::currentDate() <= mSelectedDates.last()) { |
1637 | removeAD = false; | 1637 | removeAD = false; |
1638 | remove = true; | 1638 | remove = true; |
1639 | } | 1639 | } |
1640 | else { | 1640 | else { |
1641 | 1641 | ||
1642 | if ( da < mSelectedDates.first() || | 1642 | if ( da < mSelectedDates.first() || |
1643 | da > mSelectedDates.last() ) { | 1643 | da > mSelectedDates.last() ) { |
1644 | remove = true; | 1644 | remove = true; |
1645 | removeAD = true; | 1645 | removeAD = true; |
1646 | } else { | 1646 | } else { |
1647 | remove = t->doesFloat() && !t->hasCompletedDate(); | 1647 | remove = t->doesFloat() && !t->hasCompletedDate(); |
1648 | removeAD = !remove; | 1648 | removeAD = !remove; |
1649 | } | 1649 | } |
1650 | } | 1650 | } |
1651 | } | 1651 | } |
1652 | int days = mSelectedDates.first().daysTo( da ); | 1652 | int days = mSelectedDates.first().daysTo( da ); |
1653 | //qDebug("daysto %d %d %d", days, remove,removeAD ); | 1653 | //qDebug("daysto %d %d %d", days, remove,removeAD ); |
1654 | mAgenda->updateTodo( t , days, remove); | 1654 | mAgenda->updateTodo( t , days, remove); |
1655 | if ( KOPrefs::instance()->mShowTodoInAgenda ) | 1655 | if ( KOPrefs::instance()->mShowTodoInAgenda ) |
1656 | mAllDayAgenda->updateTodo( t , days, removeAD); | 1656 | mAllDayAgenda->updateTodo( t , days, removeAD); |
1657 | //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); | 1657 | //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); |
1658 | 1658 | ||
1659 | } | 1659 | } |