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