author | zautrix <zautrix> | 2005-03-27 10:47:39 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-27 10:47:39 (UTC) |
commit | 1800cf5f3af1f666dddcbfffe3171adcd467ae3d (patch) (unidiff) | |
tree | 64b69e4bfbeacf5a036f027dd099c82c6c77e299 /korganizer | |
parent | b170a7414ff72016285ea207caa7ccf786530e77 (diff) | |
download | kdepimpi-1800cf5f3af1f666dddcbfffe3171adcd467ae3d.zip kdepimpi-1800cf5f3af1f666dddcbfffe3171adcd467ae3d.tar.gz kdepimpi-1800cf5f3af1f666dddcbfffe3171adcd467ae3d.tar.bz2 |
fixxx
-rw-r--r-- | korganizer/koagendaview.cpp | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index fa6b951..18f242c 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -1,1575 +1,1593 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qhbox.h> | 24 | #include <qhbox.h> |
25 | #include <qvbox.h> | 25 | #include <qvbox.h> |
26 | #include <qlabel.h> | 26 | #include <qlabel.h> |
27 | #include <qframe.h> | 27 | #include <qframe.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #ifndef KORG_NOSPLITTER | 29 | #ifndef KORG_NOSPLITTER |
30 | #include <qsplitter.h> | 30 | #include <qsplitter.h> |
31 | #endif | 31 | #endif |
32 | #include <qfont.h> | 32 | #include <qfont.h> |
33 | #include <qfontmetrics.h> | 33 | #include <qfontmetrics.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <qtooltip.h> | 35 | #include <qtooltip.h> |
36 | #include <qpainter.h> | 36 | #include <qpainter.h> |
37 | #include <qpushbutton.h> | 37 | #include <qpushbutton.h> |
38 | #include <qapplication.h> | 38 | #include <qapplication.h> |
39 | 39 | ||
40 | #include <kapplication.h> | 40 | #include <kapplication.h> |
41 | #include <KDGanttMinimizeSplitter.h> | 41 | #include <KDGanttMinimizeSplitter.h> |
42 | #include <kdebug.h> | 42 | #include <kdebug.h> |
43 | #include <kstandarddirs.h> | 43 | #include <kstandarddirs.h> |
44 | #include <kiconloader.h> | 44 | #include <kiconloader.h> |
45 | #include <klocale.h> | 45 | #include <klocale.h> |
46 | #include <kconfig.h> | 46 | #include <kconfig.h> |
47 | #include <kglobal.h> | 47 | #include <kglobal.h> |
48 | #include "calendarview.h" | 48 | #include "calendarview.h" |
49 | #include "koviewmanager.h" | 49 | #include "koviewmanager.h" |
50 | 50 | ||
51 | #include <libkcal/calendar.h> | 51 | #include <libkcal/calendar.h> |
52 | #include <libkcal/icaldrag.h> | 52 | #include <libkcal/icaldrag.h> |
53 | #include <libkcal/dndfactory.h> | 53 | #include <libkcal/dndfactory.h> |
54 | 54 | ||
55 | #include <kcalendarsystem.h> | 55 | #include <kcalendarsystem.h> |
56 | 56 | ||
57 | #include "koglobals.h" | 57 | #include "koglobals.h" |
58 | #ifndef KORG_NOPLUGINS | 58 | #ifndef KORG_NOPLUGINS |
59 | #include "kocore.h" | 59 | #include "kocore.h" |
60 | #endif | 60 | #endif |
61 | #include "koprefs.h" | 61 | #include "koprefs.h" |
62 | #include "koagenda.h" | 62 | #include "koagenda.h" |
63 | #include "koagendaitem.h" | 63 | #include "koagendaitem.h" |
64 | #ifndef KORG_NOPRINTER | 64 | #ifndef KORG_NOPRINTER |
65 | #include "calprinter.h" | 65 | #include "calprinter.h" |
66 | #endif | 66 | #endif |
67 | 67 | ||
68 | #include "koagendaview.h" | 68 | #include "koagendaview.h" |
69 | //#include "koagendaview.moc" | 69 | //#include "koagendaview.moc" |
70 | 70 | ||
71 | //extern bool globalFlagBlockPainting; | 71 | //extern bool globalFlagBlockPainting; |
72 | extern int globalFlagBlockAgenda; | 72 | extern int globalFlagBlockAgenda; |
73 | extern int globalFlagBlockStartup; | 73 | extern int globalFlagBlockStartup; |
74 | extern int globalFlagBlockAgendaItemPaint; | 74 | extern int globalFlagBlockAgendaItemPaint; |
75 | extern int globalFlagBlockAgendaItemUpdate; | 75 | extern int globalFlagBlockAgendaItemUpdate; |
76 | extern int globalFlagBlockLabel; | 76 | extern int globalFlagBlockLabel; |
77 | using namespace KOrg; | 77 | using namespace KOrg; |
78 | 78 | ||
79 | 79 | ||
80 | 80 | ||
81 | TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : | 81 | TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : |
82 | QScrollView(parent,name,f) | 82 | QScrollView(parent,name,f) |
83 | { | 83 | { |
84 | mRows = rows; | 84 | mRows = rows; |
85 | 85 | ||
86 | setMinimumHeight( 20 ); | 86 | setMinimumHeight( 20 ); |
87 | mCellHeight = KOPrefs::instance()->mHourSize*4; | 87 | mCellHeight = KOPrefs::instance()->mHourSize*4; |
88 | 88 | ||
89 | enableClipper(true); | 89 | enableClipper(true); |
90 | 90 | ||
91 | setHScrollBarMode(AlwaysOff); | 91 | setHScrollBarMode(AlwaysOff); |
92 | setVScrollBarMode(AlwaysOff); | 92 | setVScrollBarMode(AlwaysOff); |
93 | 93 | ||
94 | resizeContents(50,mRows * mCellHeight); | 94 | resizeContents(50,mRows * mCellHeight); |
95 | 95 | ||
96 | viewport()->setBackgroundMode( PaletteBackground ); | 96 | viewport()->setBackgroundMode( PaletteBackground ); |
97 | } | 97 | } |
98 | 98 | ||
99 | void TimeLabels::setCellHeight(int height) | 99 | void TimeLabels::setCellHeight(int height) |
100 | { | 100 | { |
101 | mCellHeight = height; | 101 | mCellHeight = height; |
102 | } | 102 | } |
103 | 103 | ||
104 | /* | 104 | /* |
105 | Optimization so that only the "dirty" portion of the scroll view | 105 | Optimization so that only the "dirty" portion of the scroll view |
106 | is redrawn. Unfortunately, this is not called by default paintEvent() method. | 106 | is redrawn. Unfortunately, this is not called by default paintEvent() method. |
107 | */ | 107 | */ |
108 | void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) | 108 | void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) |
109 | { | 109 | { |
110 | 110 | ||
111 | // if ( globalFlagBlockAgenda ) | 111 | // if ( globalFlagBlockAgenda ) |
112 | // return; | 112 | // return; |
113 | // bug: the parameters cx, cy, cw, ch are the areas that need to be | 113 | // bug: the parameters cx, cy, cw, ch are the areas that need to be |
114 | // redrawn, not the area of the widget. unfortunately, this | 114 | // redrawn, not the area of the widget. unfortunately, this |
115 | // code assumes the latter... | 115 | // code assumes the latter... |
116 | 116 | ||
117 | // now, for a workaround... | 117 | // now, for a workaround... |
118 | // these two assignments fix the weird redraw bug | 118 | // these two assignments fix the weird redraw bug |
119 | cx = contentsX() + 2; | 119 | cx = contentsX() + 2; |
120 | cw = contentsWidth() - 2; | 120 | cw = contentsWidth() - 2; |
121 | // end of workaround | 121 | // end of workaround |
122 | 122 | ||
123 | int cell = ((int)(cy/mCellHeight)); | 123 | int cell = ((int)(cy/mCellHeight)); |
124 | int y = cell * mCellHeight; | 124 | int y = cell * mCellHeight; |
125 | QFontMetrics fm = fontMetrics(); | 125 | QFontMetrics fm = fontMetrics(); |
126 | QString hour; | 126 | QString hour; |
127 | QString suffix; | 127 | QString suffix; |
128 | QString fullTime; | 128 | QString fullTime; |
129 | int tW = fm.width("24:00i"); | 129 | int tW = fm.width("24:00i"); |
130 | int timeHeight = fm.height(); | 130 | int timeHeight = fm.height(); |
131 | timeHeight -= (timeHeight/4-2); | 131 | //timeHeight -= (timeHeight/4-2); |
132 | int borderWidth = 0; | 132 | int borderWidth = 0; |
133 | QFont nFont = p->font(); | 133 | QFont nFont = p->font(); |
134 | QFont sFont = nFont; | 134 | |
135 | sFont.setPointSize( sFont.pointSize()/2+2 ); | ||
136 | if (!KGlobal::locale()->use12Clock()) | 135 | if (!KGlobal::locale()->use12Clock()) |
137 | suffix = "00"; | 136 | suffix = "00"; |
138 | else | 137 | else |
139 | borderWidth = 0; | 138 | borderWidth = 0; |
140 | QFontMetrics fmS( sFont ); | ||
141 | int sHei = fmS.height(); | ||
142 | if ( timeHeight > mCellHeight ) { | 139 | if ( timeHeight > mCellHeight ) { |
143 | timeHeight = mCellHeight-1; | 140 | timeHeight = mCellHeight-1; |
144 | sHei -= 2; | 141 | int pointS = nFont.pointSize(); |
142 | while ( pointS > 4 ) { | ||
143 | nFont.setPointSize( pointS ); | ||
144 | fm = QFontMetrics( nFont ); | ||
145 | if ( fm.height() < mCellHeight ) | ||
146 | break; | ||
147 | -- pointS; | ||
148 | } | ||
149 | fm = QFontMetrics( nFont ); | ||
150 | borderWidth = 4; | ||
151 | timeHeight = fm.height(); | ||
145 | } | 152 | } |
153 | timeHeight -= (timeHeight/4-2); | ||
154 | QFont sFont = nFont; | ||
155 | sFont.setPointSize( sFont.pointSize()/2+2 ); | ||
156 | QFontMetrics fmS( sFont ); | ||
157 | int sHei = fmS.height(); | ||
146 | 158 | ||
147 | while (y < cy + ch) { | 159 | while (y < cy + ch) { |
148 | p->drawLine(cx,y,cx+tW,y); | 160 | p->drawLine(cx,y,cx+tW,y); |
149 | hour.setNum(cell); | 161 | hour.setNum(cell); |
150 | 162 | ||
151 | // handle 24h and am/pm time formats | 163 | // handle 24h and am/pm time formats |
152 | if (KGlobal::locale()->use12Clock()) { | 164 | if (KGlobal::locale()->use12Clock()) { |
153 | if (cell > 11) suffix = "pm"; | 165 | if (cell > 11) suffix = "pm"; |
154 | else | 166 | else |
155 | suffix = "am"; | 167 | suffix = "am"; |
156 | if (cell == 0) hour.setNum(12); | 168 | if (cell == 0) hour.setNum(12); |
157 | if (cell > 12) hour.setNum(cell - 12); | 169 | if (cell > 12) hour.setNum(cell - 12); |
158 | } | 170 | } |
159 | 171 | ||
160 | // create string in format of "XX:XX" or "XXpm/am" | 172 | // create string in format of "XX:XX" or "XXpm/am" |
161 | fullTime = hour;// + suffix; | 173 | fullTime = hour;// + suffix; |
162 | 174 | ||
163 | // center and draw the time label | 175 | // center and draw the time label |
164 | int timeWidth = fm.width(fullTime+"i"); | 176 | int timeWidth = fm.width(fullTime+"i"); |
165 | int tw2 = fm.width(suffix); | 177 | int tw2 = fm.width(suffix); |
166 | int offset = this->width() - timeWidth - tw2; | 178 | int offset = this->width() - timeWidth - tw2; |
167 | p->setFont( nFont ); | 179 | p->setFont( nFont ); |
168 | p->drawText(cx - borderWidth + offset, y+ timeHeight, fullTime); | 180 | p->drawText(cx - borderWidth + offset, y+ timeHeight, fullTime); |
169 | p->setFont( sFont ); | 181 | p->setFont( sFont ); |
170 | offset += timeWidth; | 182 | offset += timeWidth; |
171 | p->drawText(cx - borderWidth + offset, y+ sHei, suffix); | 183 | p->drawText(cx - borderWidth + offset, y+ sHei, suffix); |
172 | 184 | ||
173 | // increment indices | 185 | // increment indices |
174 | y += mCellHeight; | 186 | y += mCellHeight; |
175 | cell++; | 187 | cell++; |
176 | } | 188 | } |
177 | } | 189 | } |
178 | 190 | ||
179 | /** | 191 | /** |
180 | Calculates the minimum width. | 192 | Calculates the minimum width. |
181 | */ | 193 | */ |
182 | int TimeLabels::minimumWidth() const | 194 | int TimeLabels::minimumWidth() const |
183 | { | 195 | { |
184 | return mMiniWidth; | 196 | return mMiniWidth; |
185 | } | 197 | } |
186 | 198 | ||
187 | /** updates widget's internal state */ | 199 | /** updates widget's internal state */ |
188 | void TimeLabels::updateConfig() | 200 | void TimeLabels::updateConfig() |
189 | { | 201 | { |
190 | // set the font | 202 | // set the font |
191 | // config->setGroup("Fonts"); | 203 | // config->setGroup("Fonts"); |
192 | // QFont font = config->readFontEntry("TimeBar Font"); | 204 | // QFont font = config->readFontEntry("TimeBar Font"); |
193 | setFont(KOPrefs::instance()->mTimeBarFont); | 205 | setFont(KOPrefs::instance()->mTimeBarFont); |
194 | mMiniWidth = fontMetrics().width("88:88") + 2 ; | 206 | mMiniWidth = fontMetrics().width("88:88") + 2 ; |
195 | // update geometry restrictions based on new settings | 207 | // update geometry restrictions based on new settings |
196 | setFixedWidth(minimumWidth()); | 208 | setFixedWidth(minimumWidth()); |
197 | 209 | ||
198 | // update HourSize | 210 | // update HourSize |
199 | mCellHeight = KOPrefs::instance()->mHourSize*4; | 211 | mCellHeight = KOPrefs::instance()->mHourSize*4; |
200 | resizeContents(50,mRows * mCellHeight); | 212 | resizeContents(50,mRows * mCellHeight); |
201 | } | 213 | } |
202 | 214 | ||
203 | /** update time label positions */ | 215 | /** update time label positions */ |
204 | void TimeLabels::positionChanged() | 216 | void TimeLabels::positionChanged() |
205 | { | 217 | { |
206 | int adjustment = mAgenda->contentsY(); | 218 | int adjustment = mAgenda->contentsY(); |
207 | setContentsPos(0, adjustment); | 219 | setContentsPos(0, adjustment); |
208 | } | 220 | } |
209 | 221 | ||
210 | /** */ | 222 | /** */ |
211 | void TimeLabels::setAgenda(KOAgenda* agenda) | 223 | void TimeLabels::setAgenda(KOAgenda* agenda) |
212 | { | 224 | { |
213 | mAgenda = agenda; | 225 | mAgenda = agenda; |
214 | } | 226 | } |
215 | 227 | ||
216 | void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) | 228 | void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) |
217 | { | 229 | { |
218 | mMouseDownY = e->pos().y(); | 230 | mMouseDownY = e->pos().y(); |
219 | mOrgCap = topLevelWidget()->caption(); | 231 | mOrgCap = topLevelWidget()->caption(); |
220 | } | 232 | } |
221 | 233 | ||
222 | void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) | 234 | void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) |
223 | { | 235 | { |
224 | int diff = mMouseDownY - e->pos().y(); | 236 | int diff = mMouseDownY - e->pos().y(); |
225 | if ( diff < 10 && diff > -10 ) | 237 | if ( diff < 10 && diff > -10 ) |
226 | return; | 238 | return; |
227 | int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; | 239 | int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; |
228 | if ( tSize < 4 ) | 240 | if ( tSize < 4 ) |
229 | tSize = 4; | 241 | tSize = 4; |
230 | if ( tSize > 22 ) | 242 | if ( tSize > 22 ) |
231 | tSize = 22; | 243 | tSize = 22; |
232 | tSize = (tSize-2)/2; | 244 | tSize = (tSize-2)/2; |
233 | topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); | 245 | topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); |
234 | 246 | ||
235 | } | 247 | } |
236 | void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) | 248 | void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) |
237 | { | 249 | { |
238 | topLevelWidget()->setCaption( mOrgCap ); | 250 | topLevelWidget()->setCaption( mOrgCap ); |
239 | int diff = mMouseDownY - e->pos().y(); | 251 | int diff = mMouseDownY - e->pos().y(); |
240 | if ( diff < 10 && diff > -10 ) | 252 | if ( diff < 10 && diff > -10 ) |
241 | return; | 253 | return; |
242 | int tSize = KOPrefs::instance()->mHourSize + (diff/10); | 254 | int tSize = KOPrefs::instance()->mHourSize + (diff/10); |
243 | if ( tSize < 4 ) | 255 | if ( tSize < 4 ) |
244 | tSize = 4; | 256 | tSize = 4; |
245 | if ( tSize > 22 ) | 257 | if ( tSize > 22 ) |
246 | tSize = 22; | 258 | tSize = 22; |
247 | tSize = (tSize/2)*2; | 259 | tSize = (tSize/2)*2; |
248 | if ( tSize == KOPrefs::instance()->mHourSize ) | 260 | if ( tSize == KOPrefs::instance()->mHourSize ) |
249 | return; | 261 | return; |
250 | KOPrefs::instance()->mHourSize = tSize; | 262 | KOPrefs::instance()->mHourSize = tSize; |
251 | emit scaleChanged(); | 263 | emit scaleChanged(); |
252 | } | 264 | } |
253 | 265 | ||
254 | /** This is called in response to repaint() */ | 266 | /** This is called in response to repaint() */ |
255 | void TimeLabels::paintEvent(QPaintEvent*) | 267 | void TimeLabels::paintEvent(QPaintEvent*) |
256 | { | 268 | { |
257 | 269 | ||
258 | // kdDebug() << "paintevent..." << endl; | 270 | // kdDebug() << "paintevent..." << endl; |
259 | // this is another hack! | 271 | // this is another hack! |
260 | // QPainter painter(this); | 272 | // QPainter painter(this); |
261 | //QString c | 273 | //QString c |
262 | repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); | 274 | repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); |
263 | } | 275 | } |
264 | 276 | ||
265 | //////////////////////////////////////////////////////////////////////////// | 277 | //////////////////////////////////////////////////////////////////////////// |
266 | 278 | ||
267 | EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) | 279 | EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) |
268 | : QFrame(parent,name) | 280 | : QFrame(parent,name) |
269 | { | 281 | { |
270 | mColumns = 1; | 282 | mColumns = 1; |
271 | mTopBox = 0; | 283 | mTopBox = 0; |
272 | mLocation = loc; | 284 | mLocation = loc; |
273 | mTopLayout = 0; | 285 | mTopLayout = 0; |
274 | mPaintWidget = 0; | 286 | mPaintWidget = 0; |
275 | mXOffset = 0; | 287 | mXOffset = 0; |
276 | if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); | 288 | if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); |
277 | else mPixmap = SmallIcon("1downarrow"); | 289 | else mPixmap = SmallIcon("1downarrow"); |
278 | mEnabled.resize(mColumns); | 290 | mEnabled.resize(mColumns); |
279 | mEnabled.fill( false ); | 291 | mEnabled.fill( false ); |
280 | setMinimumHeight(mPixmap.height()); | 292 | setMinimumHeight(mPixmap.height()); |
281 | } | 293 | } |
282 | 294 | ||
283 | EventIndicator::~EventIndicator() | 295 | EventIndicator::~EventIndicator() |
284 | { | 296 | { |
285 | } | 297 | } |
286 | 298 | ||
287 | void EventIndicator::drawContents(QPainter *p) | 299 | void EventIndicator::drawContents(QPainter *p) |
288 | { | 300 | { |
289 | 301 | ||
290 | // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; | 302 | // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; |
291 | KDGanttSplitterHandle* han = 0; | 303 | KDGanttSplitterHandle* han = 0; |
292 | if ( mPaintWidget ) | 304 | if ( mPaintWidget ) |
293 | han = mPaintWidget->firstHandle(); | 305 | han = mPaintWidget->firstHandle(); |
294 | if ( ! han ) { | 306 | if ( ! han ) { |
295 | int i; | 307 | int i; |
296 | for(i=0;i<mColumns;++i) { | 308 | for(i=0;i<mColumns;++i) { |
297 | if (mEnabled[i]) { | 309 | if (mEnabled[i]) { |
298 | int cellWidth = contentsRect().right()/mColumns; | 310 | int cellWidth = contentsRect().right()/mColumns; |
299 | int xOffset = KOGlobals::self()->reverseLayout() ? | 311 | int xOffset = KOGlobals::self()->reverseLayout() ? |
300 | (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 : | 312 | (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 : |
301 | i*cellWidth + (cellWidth -mPixmap.width()) /2; | 313 | i*cellWidth + (cellWidth -mPixmap.width()) /2; |
302 | p->drawPixmap(QPoint(1+xOffset,0),mPixmap); | 314 | p->drawPixmap(QPoint(1+xOffset,0),mPixmap); |
303 | } | 315 | } |
304 | } | 316 | } |
305 | } else { | 317 | } else { |
306 | han->repaint(); | 318 | han->repaint(); |
307 | //mPaintWidget->setBackgroundColor( red ); | 319 | //mPaintWidget->setBackgroundColor( red ); |
308 | 320 | ||
309 | QPainter pa( han ); | 321 | QPainter pa( han ); |
310 | int i; | 322 | int i; |
311 | bool setColor = false; | 323 | bool setColor = false; |
312 | for(i=0;i<mColumns;++i) { | 324 | for(i=0;i<mColumns;++i) { |
313 | if (mEnabled[i]) { | 325 | if (mEnabled[i]) { |
314 | setColor = true; | 326 | setColor = true; |
315 | 327 | ||
316 | int cellWidth = contentsRect().right()/mColumns; | 328 | int cellWidth = contentsRect().right()/mColumns; |
317 | int xOffset = KOGlobals::self()->reverseLayout() ? | 329 | int xOffset = KOGlobals::self()->reverseLayout() ? |
318 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : | 330 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : |
319 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; | 331 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; |
320 | pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); | 332 | pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); |
321 | //qDebug("222draw pix %d ",xOffset ); | 333 | //qDebug("222draw pix %d ",xOffset ); |
322 | 334 | ||
323 | } | 335 | } |
324 | 336 | ||
325 | } | 337 | } |
326 | pa.end(); | 338 | pa.end(); |
327 | 339 | ||
328 | } | 340 | } |
329 | } | 341 | } |
330 | 342 | ||
331 | void EventIndicator::setXOffset( int x ) | 343 | void EventIndicator::setXOffset( int x ) |
332 | { | 344 | { |
333 | mXOffset = x; | 345 | mXOffset = x; |
334 | } | 346 | } |
335 | void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) | 347 | void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) |
336 | { | 348 | { |
337 | mPaintWidget = w; | 349 | mPaintWidget = w; |
338 | setMaximumHeight(0); | 350 | setMaximumHeight(0); |
339 | setMinimumHeight(0); | 351 | setMinimumHeight(0); |
340 | } | 352 | } |
341 | void EventIndicator::changeColumns(int columns) | 353 | void EventIndicator::changeColumns(int columns) |
342 | { | 354 | { |
343 | mColumns = columns; | 355 | mColumns = columns; |
344 | mEnabled.resize(mColumns); | 356 | mEnabled.resize(mColumns); |
345 | 357 | ||
346 | update(); | 358 | update(); |
347 | } | 359 | } |
348 | 360 | ||
349 | void EventIndicator::enableColumn(int column, bool enable) | 361 | void EventIndicator::enableColumn(int column, bool enable) |
350 | { | 362 | { |
351 | mEnabled[column] = enable; | 363 | mEnabled[column] = enable; |
352 | } | 364 | } |
353 | 365 | ||
354 | 366 | ||
355 | //////////////////////////////////////////////////////////////////////////// | 367 | //////////////////////////////////////////////////////////////////////////// |
356 | //////////////////////////////////////////////////////////////////////////// | 368 | //////////////////////////////////////////////////////////////////////////// |
357 | //////////////////////////////////////////////////////////////////////////// | 369 | //////////////////////////////////////////////////////////////////////////// |
358 | 370 | ||
359 | KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : | 371 | KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : |
360 | KOEventView (cal,parent,name) | 372 | KOEventView (cal,parent,name) |
361 | { | 373 | { |
362 | mBlockUpdating = true; | 374 | mBlockUpdating = true; |
363 | mStartHour = 8; | 375 | mStartHour = 8; |
364 | mSelectedDates.append(QDate::currentDate()); | 376 | mSelectedDates.append(QDate::currentDate()); |
365 | 377 | ||
366 | mLayoutDayLabels = 0; | 378 | mLayoutDayLabels = 0; |
367 | mDayLabelsFrame = 0; | 379 | mDayLabelsFrame = 0; |
368 | mDayLabels = 0; | 380 | mDayLabels = 0; |
369 | bool isRTL = KOGlobals::self()->reverseLayout(); | 381 | bool isRTL = KOGlobals::self()->reverseLayout(); |
370 | QPixmap expandPix; | 382 | QPixmap expandPix; |
371 | if ( KOPrefs::instance()->mVerticalScreen ) { | 383 | if ( KOPrefs::instance()->mVerticalScreen ) { |
372 | expandPix = SmallIcon( "1updownarrow" ); | 384 | expandPix = SmallIcon( "1updownarrow" ); |
373 | } else { | 385 | } else { |
374 | expandPix = SmallIcon("1leftrightarrow" ); | 386 | expandPix = SmallIcon("1leftrightarrow" ); |
375 | } | 387 | } |
376 | 388 | ||
377 | QBoxLayout *topLayout = new QVBoxLayout(this); | 389 | QBoxLayout *topLayout = new QVBoxLayout(this); |
378 | 390 | ||
379 | // Create day name labels for agenda columns | 391 | // Create day name labels for agenda columns |
380 | // Create agenda splitter | 392 | // Create agenda splitter |
381 | 393 | ||
382 | mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 394 | mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
383 | mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 395 | mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
384 | topLayout->addWidget( mSplitterAgenda ); | 396 | topLayout->addWidget( mSplitterAgenda ); |
385 | mAllDayFrame = new QHBox(mSplitterAgenda); | 397 | mAllDayFrame = new QHBox(mSplitterAgenda); |
386 | mAllDayFrame->setFocusPolicy(NoFocus); | 398 | mAllDayFrame->setFocusPolicy(NoFocus); |
387 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); | 399 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); |
388 | agendaFrame->setFocusPolicy(NoFocus); | 400 | agendaFrame->setFocusPolicy(NoFocus); |
389 | 401 | ||
390 | // Create all-day agenda widget | 402 | // Create all-day agenda widget |
391 | mDummyAllDayLeft = new QVBox( mAllDayFrame ); | 403 | mDummyAllDayLeft = new QVBox( mAllDayFrame ); |
392 | 404 | ||
393 | mExpandButton = new QPushButton(mDummyAllDayLeft); | 405 | mExpandButton = new QPushButton(mDummyAllDayLeft); |
394 | mExpandButton->setPixmap( expandPix ); | 406 | mExpandButton->setPixmap( expandPix ); |
395 | int widebut = mExpandButton->sizeHint().width()+4; | 407 | int widebut = mExpandButton->sizeHint().width()+4; |
396 | int heibut = mExpandButton->sizeHint().height()+4; | 408 | int heibut = mExpandButton->sizeHint().height()+4; |
397 | if ( heibut > widebut ) | 409 | if ( heibut > widebut ) |
398 | widebut = heibut ; | 410 | widebut = heibut ; |
399 | if ( QApplication::desktop()->width() < 480 ) | 411 | if ( QApplication::desktop()->width() < 480 ) |
400 | widebut = widebut*3/2; | 412 | widebut = widebut*3/2; |
401 | //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, | 413 | //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, |
402 | // QSizePolicy::Fixed ) ); | 414 | // QSizePolicy::Fixed ) ); |
403 | mExpandButton->setFixedSize( widebut, widebut); | 415 | mExpandButton->setFixedSize( widebut, widebut); |
404 | connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); | 416 | connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); |
405 | mExpandButton->setFocusPolicy(NoFocus); | 417 | mExpandButton->setFocusPolicy(NoFocus); |
406 | mAllDayAgenda = new KOAgenda(1,mAllDayFrame); | 418 | mAllDayAgenda = new KOAgenda(1,mAllDayFrame); |
407 | mAllDayAgenda->setFocusPolicy(NoFocus); | 419 | mAllDayAgenda->setFocusPolicy(NoFocus); |
408 | QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); | 420 | QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); |
409 | 421 | ||
410 | // Create event context menu for all day agenda | 422 | // Create event context menu for all day agenda |
411 | mAllDayAgendaPopup = eventPopup(); | 423 | mAllDayAgendaPopup = eventPopup(); |
412 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 424 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
413 | mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 425 | mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
414 | 426 | ||
415 | // Create agenda frame | 427 | // Create agenda frame |
416 | QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); | 428 | QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); |
417 | // QHBox *agendaFrame = new QHBox(splitterAgenda); | 429 | // QHBox *agendaFrame = new QHBox(splitterAgenda); |
418 | 430 | ||
419 | // create event indicator bars | 431 | // create event indicator bars |
420 | mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); | 432 | mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); |
421 | #ifndef DESKTOP_VERSION | 433 | #ifndef DESKTOP_VERSION |
422 | // FIX | 434 | // FIX |
423 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); | 435 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); |
424 | #endif | 436 | #endif |
425 | mDayLabelsFrame = new QHBox(agendaFrame); | 437 | mDayLabelsFrame = new QHBox(agendaFrame); |
426 | //topLayout->addWidget(mDayLabelsFrame); | 438 | //topLayout->addWidget(mDayLabelsFrame); |
427 | mDayLabels = new QFrame (mDayLabelsFrame); | 439 | mDayLabels = new QFrame (mDayLabelsFrame); |
428 | mLayoutDayLabels = new QHBoxLayout(mDayLabels); | 440 | mLayoutDayLabels = new QHBoxLayout(mDayLabels); |
429 | agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); | 441 | agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); |
430 | agendaLayout->addWidget(mEventIndicatorTop,1,1); | 442 | agendaLayout->addWidget(mEventIndicatorTop,1,1); |
431 | 443 | ||
432 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, | 444 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, |
433 | agendaFrame); | 445 | agendaFrame); |
434 | agendaLayout->addWidget(mEventIndicatorBottom,3,1); | 446 | agendaLayout->addWidget(mEventIndicatorBottom,3,1); |
435 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); | 447 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); |
436 | agendaLayout->addWidget(dummyAgendaRight,1,2); | 448 | agendaLayout->addWidget(dummyAgendaRight,1,2); |
437 | 449 | ||
438 | // Create time labels | 450 | // Create time labels |
439 | mTimeLabels = new TimeLabels(24,agendaFrame); | 451 | mTimeLabels = new TimeLabels(24,agendaFrame); |
440 | agendaLayout->addWidget(mTimeLabels,2,0); | 452 | agendaLayout->addWidget(mTimeLabels,2,0); |
441 | connect(mTimeLabels,SIGNAL( scaleChanged()), | 453 | connect(mTimeLabels,SIGNAL( scaleChanged()), |
442 | this,SLOT(updateConfig())); | 454 | this,SLOT(updateConfig())); |
443 | 455 | ||
444 | // Create agenda | 456 | // Create agenda |
445 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); | 457 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); |
446 | agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); | 458 | agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); |
447 | agendaLayout->setColStretch(1,1); | 459 | agendaLayout->setColStretch(1,1); |
448 | mAgenda->setFocusPolicy(NoFocus); | 460 | mAgenda->setFocusPolicy(NoFocus); |
449 | // Create event context menu for agenda | 461 | // Create event context menu for agenda |
450 | mAgendaPopup = eventPopup(); | 462 | mAgendaPopup = eventPopup(); |
451 | 463 | ||
452 | mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), | 464 | mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), |
453 | i18n("Toggle Alarm"),mAgenda, | 465 | i18n("Toggle Alarm"),mAgenda, |
454 | SLOT(popupAlarm()),true); | 466 | SLOT(popupAlarm()),true); |
455 | 467 | ||
456 | 468 | ||
457 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 469 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
458 | mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 470 | mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
459 | 471 | ||
460 | // make connections between dependent widgets | 472 | // make connections between dependent widgets |
461 | mTimeLabels->setAgenda(mAgenda); | 473 | mTimeLabels->setAgenda(mAgenda); |
462 | 474 | ||
463 | // Update widgets to reflect user preferences | 475 | // Update widgets to reflect user preferences |
464 | // updateConfig(); | 476 | // updateConfig(); |
465 | 477 | ||
466 | // createDayLabels(); | 478 | // createDayLabels(); |
467 | 479 | ||
468 | // these blank widgets make the All Day Event box line up with the agenda | 480 | // these blank widgets make the All Day Event box line up with the agenda |
469 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 481 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
470 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 482 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
471 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 483 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
472 | 484 | ||
473 | // Scrolling | 485 | // Scrolling |
474 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), | 486 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), |
475 | mTimeLabels, SLOT(positionChanged())); | 487 | mTimeLabels, SLOT(positionChanged())); |
476 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), | 488 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), |
477 | SLOT(setContentsPos(int))); | 489 | SLOT(setContentsPos(int))); |
478 | 490 | ||
479 | connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); | 491 | connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); |
480 | connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); | 492 | connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); |
481 | 493 | ||
482 | // Create/Show/Edit/Delete Event | 494 | // Create/Show/Edit/Delete Event |
483 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), | 495 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), |
484 | SLOT(newEvent(int,int))); | 496 | SLOT(newEvent(int,int))); |
485 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), | 497 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), |
486 | SLOT(newTodo(int,int))); | 498 | SLOT(newTodo(int,int))); |
487 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 499 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
488 | SLOT(newEvent(int,int,int,int))); | 500 | SLOT(newEvent(int,int,int,int))); |
489 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), | 501 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), |
490 | SLOT(newEventAllDay(int,int))); | 502 | SLOT(newEventAllDay(int,int))); |
491 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), | 503 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), |
492 | SLOT(newTodoAllDay(int,int))); | 504 | SLOT(newTodoAllDay(int,int))); |
493 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 505 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
494 | SLOT(newEventAllDay(int,int))); | 506 | SLOT(newEventAllDay(int,int))); |
495 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 507 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
496 | SLOT(newTimeSpanSelected(int,int,int,int))); | 508 | SLOT(newTimeSpanSelected(int,int,int,int))); |
497 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 509 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
498 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); | 510 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); |
499 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 511 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
500 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 512 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
501 | 513 | ||
502 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 514 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
503 | SIGNAL(editIncidenceSignal(Incidence *))); | 515 | SIGNAL(editIncidenceSignal(Incidence *))); |
504 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 516 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
505 | SIGNAL(editIncidenceSignal(Incidence *))); | 517 | SIGNAL(editIncidenceSignal(Incidence *))); |
506 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 518 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
507 | SIGNAL(showIncidenceSignal(Incidence *))); | 519 | SIGNAL(showIncidenceSignal(Incidence *))); |
508 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 520 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
509 | SIGNAL(showIncidenceSignal(Incidence *))); | 521 | SIGNAL(showIncidenceSignal(Incidence *))); |
510 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 522 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
511 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 523 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
512 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 524 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
513 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 525 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
514 | 526 | ||
515 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 527 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
516 | SLOT(updateEventDates(KOAgendaItem *, int ))); | 528 | SLOT(updateEventDates(KOAgendaItem *, int ))); |
517 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 529 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
518 | SLOT(updateEventDates(KOAgendaItem *, int))); | 530 | SLOT(updateEventDates(KOAgendaItem *, int))); |
519 | 531 | ||
520 | // event indicator update | 532 | // event indicator update |
521 | connect(mAgenda,SIGNAL(lowerYChanged(int)), | 533 | connect(mAgenda,SIGNAL(lowerYChanged(int)), |
522 | SLOT(updateEventIndicatorTop(int))); | 534 | SLOT(updateEventIndicatorTop(int))); |
523 | connect(mAgenda,SIGNAL(upperYChanged(int)), | 535 | connect(mAgenda,SIGNAL(upperYChanged(int)), |
524 | SLOT(updateEventIndicatorBottom(int))); | 536 | SLOT(updateEventIndicatorBottom(int))); |
525 | // drag signals | 537 | // drag signals |
526 | /* | 538 | /* |
527 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), | 539 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), |
528 | SLOT(startDrag(Event *))); | 540 | SLOT(startDrag(Event *))); |
529 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), | 541 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), |
530 | SLOT(startDrag(Event *))); | 542 | SLOT(startDrag(Event *))); |
531 | */ | 543 | */ |
532 | // synchronize selections | 544 | // synchronize selections |
533 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 545 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
534 | mAllDayAgenda, SLOT( deselectItem() ) ); | 546 | mAllDayAgenda, SLOT( deselectItem() ) ); |
535 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 547 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
536 | mAgenda, SLOT( deselectItem() ) ); | 548 | mAgenda, SLOT( deselectItem() ) ); |
537 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 549 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
538 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 550 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
539 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 551 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
540 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 552 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
541 | connect( mAgenda, SIGNAL( resizedSignal() ), | 553 | connect( mAgenda, SIGNAL( resizedSignal() ), |
542 | SLOT( updateConfig( ) ) ); | 554 | SLOT( updateConfig( ) ) ); |
543 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), | 555 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), |
544 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); | 556 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); |
545 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), | 557 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), |
546 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); | 558 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); |
547 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 559 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
548 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 560 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
549 | 561 | ||
550 | 562 | ||
551 | } | 563 | } |
552 | 564 | ||
553 | void KOAgendaView::toggleAllDay() | 565 | void KOAgendaView::toggleAllDay() |
554 | { | 566 | { |
555 | if ( mSplitterAgenda->firstHandle() ) | 567 | if ( mSplitterAgenda->firstHandle() ) |
556 | mSplitterAgenda->firstHandle()->toggle(); | 568 | mSplitterAgenda->firstHandle()->toggle(); |
557 | } | 569 | } |
558 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) | 570 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) |
559 | { | 571 | { |
560 | calendar()->addIncidence( inc ); | 572 | calendar()->addIncidence( inc ); |
561 | 573 | ||
562 | if ( incOld ) { | 574 | if ( incOld ) { |
563 | if ( incOld->type() == "Todo" ) | 575 | if ( incOld->type() == "Todo" ) |
564 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); | 576 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); |
565 | else | 577 | else |
566 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); | 578 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); |
567 | } | 579 | } |
568 | 580 | ||
569 | } | 581 | } |
570 | 582 | ||
571 | KOAgendaView::~KOAgendaView() | 583 | KOAgendaView::~KOAgendaView() |
572 | { | 584 | { |
573 | delete mAgendaPopup; | 585 | delete mAgendaPopup; |
574 | delete mAllDayAgendaPopup; | 586 | delete mAllDayAgendaPopup; |
575 | delete KOAgendaItem::paintPix(); | 587 | delete KOAgendaItem::paintPix(); |
576 | delete KOAgendaItem::paintPixSel(); | 588 | delete KOAgendaItem::paintPixSel(); |
577 | } | 589 | } |
578 | void KOAgendaView::resizeEvent( QResizeEvent* e ) | 590 | void KOAgendaView::resizeEvent( QResizeEvent* e ) |
579 | { | 591 | { |
580 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); | 592 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); |
581 | bool uc = false; | 593 | bool uc = false; |
582 | int ow = e->oldSize().width(); | 594 | int ow = e->oldSize().width(); |
583 | int oh = e->oldSize().height(); | 595 | int oh = e->oldSize().height(); |
584 | int w = e->size().width(); | 596 | int w = e->size().width(); |
585 | int h = e->size().height(); | 597 | int h = e->size().height(); |
586 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { | 598 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { |
587 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) | 599 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) |
588 | uc = true; | 600 | uc = true; |
589 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); | 601 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); |
590 | } | 602 | } |
591 | mUpcomingWidth = e->size().width() ; | 603 | mUpcomingWidth = e->size().width() ; |
592 | if ( mBlockUpdating || uc ) { | 604 | if ( mBlockUpdating || uc ) { |
593 | mBlockUpdating = false; | 605 | mBlockUpdating = false; |
594 | //mAgenda->setMinimumSize(800 , 600 ); | 606 | //mAgenda->setMinimumSize(800 , 600 ); |
595 | //qDebug("mAgenda->resize+++++++++++++++ "); | 607 | //qDebug("mAgenda->resize+++++++++++++++ "); |
596 | updateConfig(); | 608 | updateConfig(); |
597 | //qDebug("KOAgendaView::Updating now possible "); | 609 | //qDebug("KOAgendaView::Updating now possible "); |
598 | } else | 610 | } else |
599 | createDayLabels(); | 611 | createDayLabels(); |
600 | //qDebug("resizeEvent end "); | 612 | //qDebug("resizeEvent end "); |
601 | 613 | ||
602 | } | 614 | } |
603 | void KOAgendaView::slotDaylabelClicked( int num ) | 615 | void KOAgendaView::slotDaylabelClicked( int num ) |
604 | { | 616 | { |
605 | 617 | ||
606 | QDate firstDate = mSelectedDates.first(); | 618 | QDate firstDate = mSelectedDates.first(); |
607 | if ( num == -1 ) | 619 | if ( num == -1 ) |
608 | emit showDateView( 6, firstDate ); | 620 | emit showDateView( 6, firstDate ); |
609 | else if (num >= 0 ) { | 621 | else if (num >= 0 ) { |
610 | if ( mSelectedDates.count() == 1) | 622 | if ( mSelectedDates.count() == 1) |
611 | emit showDateView( 9, firstDate.addDays( num ) ); | 623 | emit showDateView( 9, firstDate.addDays( num ) ); |
612 | else | 624 | else |
613 | emit showDateView( 3, firstDate.addDays( num ) ); | 625 | emit showDateView( 3, firstDate.addDays( num ) ); |
614 | } | 626 | } |
615 | else | 627 | else |
616 | showDateView( 10, firstDate.addDays(1) ); | 628 | showDateView( 10, firstDate.addDays(1) ); |
617 | } | 629 | } |
618 | 630 | ||
619 | KOAgendaButton* KOAgendaView::getNewDaylabel() | 631 | KOAgendaButton* KOAgendaView::getNewDaylabel() |
620 | { | 632 | { |
621 | 633 | ||
622 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); | 634 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); |
623 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); | 635 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); |
624 | mDayLabelsList.append( dayLabel ); | 636 | mDayLabelsList.append( dayLabel ); |
625 | mLayoutDayLabels->addWidget(dayLabel); | 637 | mLayoutDayLabels->addWidget(dayLabel); |
626 | return dayLabel ; | 638 | return dayLabel ; |
627 | } | 639 | } |
628 | 640 | ||
629 | void KOAgendaView::createDayLabels() | 641 | void KOAgendaView::createDayLabels() |
630 | { | 642 | { |
631 | 643 | ||
632 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { | 644 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { |
633 | // qDebug(" KOAgendaView::createDayLabels() blocked "); | 645 | // qDebug(" KOAgendaView::createDayLabels() blocked "); |
634 | return; | 646 | return; |
635 | 647 | ||
636 | } | 648 | } |
637 | int newHight; | 649 | int newHight; |
638 | 650 | ||
639 | // ### Before deleting and recreating we could check if mSelectedDates changed... | 651 | // ### Before deleting and recreating we could check if mSelectedDates changed... |
640 | // It would remove some flickering and gain speed (since this is called by | 652 | // It would remove some flickering and gain speed (since this is called by |
641 | // each updateView() call) | 653 | // each updateView() call) |
642 | 654 | ||
643 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; | 655 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; |
644 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); | 656 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); |
645 | if ( maxWid < 0 ) | 657 | if ( maxWid < 0 ) |
646 | maxWid = 20; | 658 | maxWid = 20; |
647 | 659 | ||
648 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; | 660 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; |
649 | QFontMetrics fm ( dlf ); | 661 | QFontMetrics fm ( dlf ); |
650 | int selCount = mSelectedDates.count(); | 662 | int selCount = mSelectedDates.count(); |
651 | QString dayTest = "Mon 20"; | 663 | QString dayTest = "Mon 20"; |
652 | //QString dayTest = "Mon 20"; | 664 | //QString dayTest = "Mon 20"; |
653 | int wid = fm.width( dayTest ); | 665 | int wid = fm.width( dayTest ); |
654 | //maxWid -= ( selCount * 3 ); //working for QLabels | 666 | //maxWid -= ( selCount * 3 ); //working for QLabels |
655 | maxWid -= ( selCount * 3 ); //working for QPushButton | 667 | maxWid -= ( selCount * 3 ); //working for QPushButton |
656 | if ( maxWid < 0 ) | 668 | if ( maxWid < 0 ) |
657 | maxWid = 20; | 669 | maxWid = 20; |
658 | int needWid = wid * selCount; | 670 | int needWid = wid * selCount; |
659 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); | 671 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); |
660 | //if ( needWid > maxWid ) | 672 | //if ( needWid > maxWid ) |
661 | // qDebug("DAYLABELS TOOOOOOO BIG "); | 673 | // qDebug("DAYLABELS TOOOOOOO BIG "); |
662 | while ( needWid > maxWid ) { | 674 | while ( needWid > maxWid ) { |
663 | dayTest = dayTest.left( dayTest.length() - 1 ); | 675 | dayTest = dayTest.left( dayTest.length() - 1 ); |
664 | wid = fm.width( dayTest ); | 676 | wid = fm.width( dayTest ); |
665 | needWid = wid * selCount; | 677 | needWid = wid * selCount; |
666 | } | 678 | } |
667 | int maxLen = dayTest.length(); | 679 | int maxLen = dayTest.length(); |
668 | int fontPoint = dlf.pointSize(); | 680 | int fontPoint = dlf.pointSize(); |
669 | if ( maxLen < 2 ) { | 681 | if ( maxLen < 2 ) { |
670 | int fontPoint = dlf.pointSize(); | 682 | int fontPoint = dlf.pointSize(); |
671 | while ( fontPoint > 4 ) { | 683 | while ( fontPoint > 4 ) { |
672 | --fontPoint; | 684 | --fontPoint; |
673 | dlf.setPointSize( fontPoint ); | 685 | dlf.setPointSize( fontPoint ); |
674 | QFontMetrics f( dlf ); | 686 | QFontMetrics f( dlf ); |
675 | wid = f.width( "30" ); | 687 | wid = f.width( "30" ); |
676 | needWid = wid * selCount; | 688 | needWid = wid * selCount; |
677 | if ( needWid < maxWid ) | 689 | if ( needWid < maxWid ) |
678 | break; | 690 | break; |
679 | } | 691 | } |
680 | maxLen = 2; | 692 | maxLen = 2; |
681 | } | 693 | } |
682 | //qDebug("Max len %d ", dayTest.length() ); | 694 | //qDebug("Max len %d ", dayTest.length() ); |
683 | 695 | ||
684 | QFontMetrics tempF( dlf ); | 696 | QFontMetrics tempF( dlf ); |
685 | newHight = tempF.height(); | 697 | newHight = tempF.height(); |
686 | mDayLabels->setFont( dlf ); | 698 | mDayLabels->setFont( dlf ); |
687 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; | 699 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; |
688 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); | 700 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); |
689 | //mLayoutDayLabels->addSpacing( 2 ); | 701 | //mLayoutDayLabels->addSpacing( 2 ); |
690 | // QFont lFont = dlf; | 702 | // QFont lFont = dlf; |
691 | bool appendLabels = false; | 703 | bool appendLabels = false; |
692 | KOAgendaButton *dayLabel; | 704 | KOAgendaButton *dayLabel; |
693 | dayLabel = mDayLabelsList.first(); | 705 | dayLabel = mDayLabelsList.first(); |
694 | if ( !dayLabel ) { | 706 | if ( !dayLabel ) { |
695 | appendLabels = true; | 707 | appendLabels = true; |
696 | dayLabel = getNewDaylabel(); | 708 | dayLabel = getNewDaylabel(); |
697 | } | 709 | } |
698 | dayLabel->setFixedWidth( mTimeLabels->width()+2 ); | 710 | dayLabel->setFixedWidth( mTimeLabels->width()+2 ); |
699 | dayLabel->setFont( dlf ); | 711 | dayLabel->setFont( dlf ); |
700 | dayLabel->setNum( -1 ); | 712 | dayLabel->setNum( -1 ); |
701 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 713 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
702 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); | 714 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); |
703 | dayLabel->show(); | 715 | dayLabel->show(); |
704 | DateList::ConstIterator dit; | 716 | DateList::ConstIterator dit; |
705 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); | 717 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); |
706 | int counter = -1; | 718 | int counter = -1; |
707 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 719 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
708 | ++counter; | 720 | ++counter; |
709 | QDate date = *dit; | 721 | QDate date = *dit; |
710 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); | 722 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); |
711 | if ( ! appendLabels ) { | 723 | if ( ! appendLabels ) { |
712 | dayLabel = mDayLabelsList.next(); | 724 | dayLabel = mDayLabelsList.next(); |
713 | if ( !dayLabel ) | 725 | if ( !dayLabel ) |
714 | appendLabels = true; | 726 | appendLabels = true; |
715 | } | 727 | } |
716 | if ( appendLabels ) { | 728 | if ( appendLabels ) { |
717 | dayLabel = getNewDaylabel(); | 729 | dayLabel = getNewDaylabel(); |
718 | } | 730 | } |
719 | dayLabel->setMinimumWidth( 1 ); | 731 | dayLabel->setMinimumWidth( 1 ); |
720 | dayLabel->setMaximumWidth( 10240 ); | 732 | dayLabel->setMaximumWidth( 10240 ); |
721 | dayLabel->setFont( dlf ); | 733 | dayLabel->setFont( dlf ); |
722 | dayLabel->show(); | 734 | dayLabel->show(); |
723 | dayLabel->setNum( counter ); | 735 | dayLabel->setNum( counter ); |
724 | QString str; | 736 | QString str; |
725 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); | 737 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); |
726 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); | 738 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); |
727 | switch ( maxLen ) { | 739 | switch ( maxLen ) { |
728 | case 2: | 740 | case 2: |
729 | str = QString::number( date.day() ); | 741 | str = QString::number( date.day() ); |
730 | break; | 742 | break; |
731 | 743 | ||
732 | case 3: | 744 | case 3: |
733 | str = dayName.left( 1 ) +QString::number( date.day()); | 745 | str = dayName.left( 1 ) +QString::number( date.day()); |
734 | 746 | ||
735 | break; | 747 | break; |
736 | case 4: | 748 | case 4: |
737 | str = dayName.left( 1 ) + " " +QString::number( date.day()); | 749 | str = dayName.left( 1 ) + " " +QString::number( date.day()); |
738 | 750 | ||
739 | break; | 751 | break; |
740 | case 5: | 752 | case 5: |
741 | str = dayName.left( 2 ) + " " +QString::number( date.day()); | 753 | str = dayName.left( 2 ) + " " +QString::number( date.day()); |
742 | 754 | ||
743 | break; | 755 | break; |
744 | case 6: | 756 | case 6: |
745 | str = dayName.left( 3 ) + " " +QString::number( date.day()); | 757 | str = dayName.left( 3 ) + " " +QString::number( date.day()); |
746 | break; | 758 | break; |
747 | 759 | ||
748 | default: | 760 | default: |
749 | break; | 761 | break; |
750 | } | 762 | } |
751 | if ( oneday ) { | 763 | if ( oneday ) { |
752 | QString addString; | 764 | QString addString; |
753 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) | 765 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) |
754 | addString = i18n("Today"); | 766 | addString = i18n("Today"); |
755 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 767 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
756 | addString = i18n("Tomorrow"); | 768 | addString = i18n("Tomorrow"); |
757 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 769 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
758 | addString = i18n("Yesterday"); | 770 | addString = i18n("Yesterday"); |
759 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | 771 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) |
760 | addString = i18n("Day before yesterday"); | 772 | addString = i18n("Day before yesterday"); |
761 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 773 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
762 | addString = i18n("Day after tomorrow"); | 774 | addString = i18n("Day after tomorrow"); |
763 | if ( !addString.isEmpty() ) { | 775 | if ( !addString.isEmpty() ) { |
764 | str = addString+", " + str; | 776 | str = addString+", " + str; |
765 | } else { | 777 | } else { |
766 | str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); | 778 | str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); |
767 | } | 779 | } |
768 | } | 780 | } |
769 | dayLabel->setText(str); | 781 | dayLabel->setText(str); |
770 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 782 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
771 | if (date == QDate::currentDate()) { | 783 | if (date == QDate::currentDate()) { |
772 | QFont bFont = dlf; | 784 | QFont bFont = dlf; |
773 | bFont.setBold( true ); | 785 | bFont.setBold( true ); |
774 | dayLabel->setFont(bFont); | 786 | dayLabel->setFont(bFont); |
775 | } | 787 | } |
776 | //dayLayout->addWidget(dayLabel); | 788 | //dayLayout->addWidget(dayLabel); |
777 | 789 | ||
778 | #ifndef KORG_NOPLUGINS | 790 | #ifndef KORG_NOPLUGINS |
779 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); | 791 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); |
780 | CalendarDecoration *it; | 792 | CalendarDecoration *it; |
781 | for(it = cds.first(); it; it = cds.next()) { | 793 | for(it = cds.first(); it; it = cds.next()) { |
782 | QString text = it->shortText( date ); | 794 | QString text = it->shortText( date ); |
783 | if ( !text.isEmpty() ) { | 795 | if ( !text.isEmpty() ) { |
784 | QLabel *label = new QLabel(text,mDayLabels); | 796 | QLabel *label = new QLabel(text,mDayLabels); |
785 | label->setAlignment(AlignCenter); | 797 | label->setAlignment(AlignCenter); |
786 | dayLayout->addWidget(label); | 798 | dayLayout->addWidget(label); |
787 | } | 799 | } |
788 | } | 800 | } |
789 | 801 | ||
790 | for(it = cds.first(); it; it = cds.next()) { | 802 | for(it = cds.first(); it; it = cds.next()) { |
791 | QWidget *wid = it->smallWidget(mDayLabels,date); | 803 | QWidget *wid = it->smallWidget(mDayLabels,date); |
792 | if ( wid ) { | 804 | if ( wid ) { |
793 | // wid->setHeight(20); | 805 | // wid->setHeight(20); |
794 | dayLayout->addWidget(wid); | 806 | dayLayout->addWidget(wid); |
795 | } | 807 | } |
796 | } | 808 | } |
797 | #endif | 809 | #endif |
798 | } | 810 | } |
799 | if ( ! appendLabels ) { | 811 | if ( ! appendLabels ) { |
800 | dayLabel = mDayLabelsList.next(); | 812 | dayLabel = mDayLabelsList.next(); |
801 | if ( !dayLabel ) | 813 | if ( !dayLabel ) |
802 | appendLabels = true; | 814 | appendLabels = true; |
803 | } | 815 | } |
804 | if ( appendLabels ) { | 816 | if ( appendLabels ) { |
805 | dayLabel = getNewDaylabel(); | 817 | dayLabel = getNewDaylabel(); |
806 | } | 818 | } |
807 | //dayLabel->hide();//test only | 819 | //dayLabel->hide();//test only |
808 | 820 | ||
809 | int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; | 821 | int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; |
810 | if ( offset < 0 ) offset = 0; | 822 | if ( offset < 0 ) offset = 0; |
811 | //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); | 823 | //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); |
812 | dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); | 824 | dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); |
813 | dayLabel->setFont( dlf ); | 825 | dayLabel->setFont( dlf ); |
814 | dayLabel->show(); | 826 | dayLabel->show(); |
815 | dayLabel->setNum( -2 ); | 827 | dayLabel->setNum( -2 ); |
816 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); | 828 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); |
817 | //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); | 829 | //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); |
818 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); | 830 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); |
819 | if ( !appendLabels ) { | 831 | if ( !appendLabels ) { |
820 | dayLabel = mDayLabelsList.next(); | 832 | dayLabel = mDayLabelsList.next(); |
821 | while ( dayLabel ) { | 833 | while ( dayLabel ) { |
822 | //qDebug("!dayLabel %d",dayLabel ); | 834 | //qDebug("!dayLabel %d",dayLabel ); |
823 | dayLabel->hide(); | 835 | dayLabel->hide(); |
824 | dayLabel = mDayLabelsList.next(); | 836 | dayLabel = mDayLabelsList.next(); |
825 | } | 837 | } |
826 | } | 838 | } |
827 | //mDayLabelsFrame->show(); | 839 | //mDayLabelsFrame->show(); |
828 | //mDayLabels->show(); | 840 | //mDayLabels->show(); |
829 | //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); | 841 | //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); |
830 | //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); | 842 | //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); |
831 | mDayLabelsFrame->setFixedHeight( newHight ); | 843 | mDayLabelsFrame->setFixedHeight( newHight ); |
832 | } | 844 | } |
833 | 845 | ||
834 | int KOAgendaView::maxDatesHint() | 846 | int KOAgendaView::maxDatesHint() |
835 | { | 847 | { |
836 | // Not sure about the max number of events, so return 0 for now. | 848 | // Not sure about the max number of events, so return 0 for now. |
837 | return 0; | 849 | return 0; |
838 | } | 850 | } |
839 | 851 | ||
840 | int KOAgendaView::currentDateCount() | 852 | int KOAgendaView::currentDateCount() |
841 | { | 853 | { |
842 | return mSelectedDates.count(); | 854 | return mSelectedDates.count(); |
843 | } | 855 | } |
844 | 856 | ||
845 | QPtrList<Incidence> KOAgendaView::selectedIncidences() | 857 | QPtrList<Incidence> KOAgendaView::selectedIncidences() |
846 | { | 858 | { |
847 | QPtrList<Incidence> selected; | 859 | QPtrList<Incidence> selected; |
848 | Incidence *incidence; | 860 | Incidence *incidence; |
849 | 861 | ||
850 | incidence = mAgenda->selectedIncidence(); | 862 | incidence = mAgenda->selectedIncidence(); |
851 | if (incidence) selected.append(incidence); | 863 | if (incidence) selected.append(incidence); |
852 | 864 | ||
853 | incidence = mAllDayAgenda->selectedIncidence(); | 865 | incidence = mAllDayAgenda->selectedIncidence(); |
854 | if (incidence) selected.append(incidence); | 866 | if (incidence) selected.append(incidence); |
855 | 867 | ||
856 | return selected; | 868 | return selected; |
857 | } | 869 | } |
858 | 870 | ||
859 | DateList KOAgendaView::selectedDates() | 871 | DateList KOAgendaView::selectedDates() |
860 | { | 872 | { |
861 | DateList selected; | 873 | DateList selected; |
862 | QDate qd; | 874 | QDate qd; |
863 | 875 | ||
864 | qd = mAgenda->selectedIncidenceDate(); | 876 | qd = mAgenda->selectedIncidenceDate(); |
865 | if (qd.isValid()) selected.append(qd); | 877 | if (qd.isValid()) selected.append(qd); |
866 | 878 | ||
867 | qd = mAllDayAgenda->selectedIncidenceDate(); | 879 | qd = mAllDayAgenda->selectedIncidenceDate(); |
868 | if (qd.isValid()) selected.append(qd); | 880 | if (qd.isValid()) selected.append(qd); |
869 | 881 | ||
870 | return selected; | 882 | return selected; |
871 | } | 883 | } |
872 | 884 | ||
873 | 885 | ||
874 | void KOAgendaView::updateView() | 886 | void KOAgendaView::updateView() |
875 | { | 887 | { |
876 | if ( mBlockUpdating ) | 888 | if ( mBlockUpdating ) |
877 | return; | 889 | return; |
878 | // kdDebug() << "KOAgendaView::updateView()" << endl; | 890 | // kdDebug() << "KOAgendaView::updateView()" << endl; |
879 | fillAgenda(); | 891 | fillAgenda(); |
880 | 892 | ||
881 | } | 893 | } |
882 | 894 | ||
883 | 895 | ||
884 | /* | 896 | /* |
885 | Update configuration settings for the agenda view. This method is not | 897 | Update configuration settings for the agenda view. This method is not |
886 | complete. | 898 | complete. |
887 | */ | 899 | */ |
888 | void KOAgendaView::updateConfig() | 900 | void KOAgendaView::updateConfig() |
889 | { | 901 | { |
890 | if ( mBlockUpdating ) | 902 | if ( mBlockUpdating ) |
891 | return; | 903 | return; |
904 | if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { | ||
905 | int old = KOPrefs::instance()->mHourSize; | ||
906 | KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; | ||
907 | qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); | ||
908 | } | ||
909 | |||
892 | 910 | ||
893 | // update config for children | 911 | // update config for children |
894 | mTimeLabels->updateConfig(); | 912 | mTimeLabels->updateConfig(); |
895 | mAgenda->storePosition(); | 913 | mAgenda->storePosition(); |
896 | mAgenda->updateConfig(); | 914 | mAgenda->updateConfig(); |
897 | mAllDayAgenda->updateConfig(); | 915 | mAllDayAgenda->updateConfig(); |
898 | // widget synchronization | 916 | // widget synchronization |
899 | //TODO: find a better way, maybe signal/slot | 917 | //TODO: find a better way, maybe signal/slot |
900 | mTimeLabels->positionChanged(); | 918 | mTimeLabels->positionChanged(); |
901 | 919 | ||
902 | // for some reason, this needs to be called explicitly | 920 | // for some reason, this needs to be called explicitly |
903 | mTimeLabels->repaint(); | 921 | mTimeLabels->repaint(); |
904 | 922 | ||
905 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 923 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
906 | 924 | ||
907 | // ToolTips displaying summary of events | 925 | // ToolTips displaying summary of events |
908 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() | 926 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() |
909 | ->mEnableToolTips); | 927 | ->mEnableToolTips); |
910 | 928 | ||
911 | //setHolidayMasks(); | 929 | //setHolidayMasks(); |
912 | 930 | ||
913 | //createDayLabels(); called by via updateView(); | 931 | //createDayLabels(); called by via updateView(); |
914 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); | 932 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); |
915 | updateView(); | 933 | updateView(); |
916 | mAgenda->restorePosition(); | 934 | mAgenda->restorePosition(); |
917 | } | 935 | } |
918 | 936 | ||
919 | 937 | ||
920 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) | 938 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) |
921 | { | 939 | { |
922 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; | 940 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; |
923 | //qDebug("KOAgendaView::updateEventDates "); | 941 | //qDebug("KOAgendaView::updateEventDates "); |
924 | QDateTime startDt,endDt; | 942 | QDateTime startDt,endDt; |
925 | QDate startDate; | 943 | QDate startDate; |
926 | int lenInSecs; | 944 | int lenInSecs; |
927 | // if ( type == KOAgenda::RESIZETOP ) | 945 | // if ( type == KOAgenda::RESIZETOP ) |
928 | // qDebug("RESIZETOP "); | 946 | // qDebug("RESIZETOP "); |
929 | // if ( type == KOAgenda::RESIZEBOTTOM ) | 947 | // if ( type == KOAgenda::RESIZEBOTTOM ) |
930 | // qDebug("RESIZEBOTTOM "); | 948 | // qDebug("RESIZEBOTTOM "); |
931 | // if ( type == KOAgenda::MOVE ) | 949 | // if ( type == KOAgenda::MOVE ) |
932 | // qDebug("MOVE "); | 950 | // qDebug("MOVE "); |
933 | if ( item->incidence()->type() == "Event" ) { | 951 | if ( item->incidence()->type() == "Event" ) { |
934 | startDt =item->incidence()->dtStart(); | 952 | startDt =item->incidence()->dtStart(); |
935 | endDt = item->incidence()->dtEnd(); | 953 | endDt = item->incidence()->dtEnd(); |
936 | lenInSecs = startDt.secsTo( endDt ); | 954 | lenInSecs = startDt.secsTo( endDt ); |
937 | } | 955 | } |
938 | 956 | ||
939 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); | 957 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); |
940 | 958 | ||
941 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { | 959 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { |
942 | startDate = mSelectedDates[item->mLastMoveXPos]; | 960 | startDate = mSelectedDates[item->mLastMoveXPos]; |
943 | } else { | 961 | } else { |
944 | if (item->cellX() < 0) { | 962 | if (item->cellX() < 0) { |
945 | startDate = (mSelectedDates.first()).addDays(item->cellX()); | 963 | startDate = (mSelectedDates.first()).addDays(item->cellX()); |
946 | } else { | 964 | } else { |
947 | startDate = mSelectedDates[item->cellX()]; | 965 | startDate = mSelectedDates[item->cellX()]; |
948 | } | 966 | } |
949 | } | 967 | } |
950 | startDt.setDate(startDate); | 968 | startDt.setDate(startDate); |
951 | 969 | ||
952 | if (item->incidence()->doesFloat()) { | 970 | if (item->incidence()->doesFloat()) { |
953 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); | 971 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); |
954 | } else { | 972 | } else { |
955 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) | 973 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) |
956 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); | 974 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); |
957 | if ( item->incidence()->type() == "Event" ) { | 975 | if ( item->incidence()->type() == "Event" ) { |
958 | if ( type == KOAgenda::MOVE ) { | 976 | if ( type == KOAgenda::MOVE ) { |
959 | endDt = startDt.addSecs(lenInSecs); | 977 | endDt = startDt.addSecs(lenInSecs); |
960 | 978 | ||
961 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { | 979 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { |
962 | if (item->lastMultiItem()) { | 980 | if (item->lastMultiItem()) { |
963 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 981 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
964 | endDt.setDate(startDate. | 982 | endDt.setDate(startDate. |
965 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 983 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
966 | } else { | 984 | } else { |
967 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 985 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
968 | endDt.setDate(startDate); | 986 | endDt.setDate(startDate); |
969 | } | 987 | } |
970 | } | 988 | } |
971 | } else { | 989 | } else { |
972 | // todo | 990 | // todo |
973 | if (item->lastMultiItem()) { | 991 | if (item->lastMultiItem()) { |
974 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 992 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
975 | endDt.setDate(startDate. | 993 | endDt.setDate(startDate. |
976 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 994 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
977 | } else { | 995 | } else { |
978 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); | 996 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); |
979 | if ( item->cellYBottom() > 0 ) | 997 | if ( item->cellYBottom() > 0 ) |
980 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 998 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
981 | else | 999 | else |
982 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); | 1000 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); |
983 | endDt.setDate(startDate); | 1001 | endDt.setDate(startDate); |
984 | } | 1002 | } |
985 | } | 1003 | } |
986 | } | 1004 | } |
987 | if ( item->incidence()->type() == "Event" ) { | 1005 | if ( item->incidence()->type() == "Event" ) { |
988 | item->incidence()->setDtStart(startDt); | 1006 | item->incidence()->setDtStart(startDt); |
989 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); | 1007 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); |
990 | } else if ( item->incidence()->type() == "Todo" ) { | 1008 | } else if ( item->incidence()->type() == "Todo" ) { |
991 | Todo* to = static_cast<Todo*>(item->incidence()); | 1009 | Todo* to = static_cast<Todo*>(item->incidence()); |
992 | 1010 | ||
993 | to->setDtDue(endDt); | 1011 | to->setDtDue(endDt); |
994 | if ( to->hasStartDate() ) { | 1012 | if ( to->hasStartDate() ) { |
995 | if (to->dtStart() >= to->dtDue() ) | 1013 | if (to->dtStart() >= to->dtDue() ) |
996 | to->setDtStart(to->dtDue().addDays( -2 )); | 1014 | to->setDtStart(to->dtDue().addDays( -2 )); |
997 | } | 1015 | } |
998 | 1016 | ||
999 | } | 1017 | } |
1000 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); | 1018 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); |
1001 | item->incidence()->setRevision(item->incidence()->revision()+1); | 1019 | item->incidence()->setRevision(item->incidence()->revision()+1); |
1002 | item->setItemDate(startDt.date()); | 1020 | item->setItemDate(startDt.date()); |
1003 | //item->updateItem(); | 1021 | //item->updateItem(); |
1004 | if ( item->incidence()->type() == "Todo" ) { | 1022 | if ( item->incidence()->type() == "Todo" ) { |
1005 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); | 1023 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); |
1006 | 1024 | ||
1007 | } | 1025 | } |
1008 | else | 1026 | else |
1009 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); | 1027 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); |
1010 | item->updateItem(); | 1028 | item->updateItem(); |
1011 | } | 1029 | } |
1012 | 1030 | ||
1013 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) | 1031 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) |
1014 | { | 1032 | { |
1015 | // kdDebug() << "KOAgendaView::selectDates" << endl; | 1033 | // kdDebug() << "KOAgendaView::selectDates" << endl; |
1016 | 1034 | ||
1017 | mSelectedDates.clear(); | 1035 | mSelectedDates.clear(); |
1018 | // qDebug("KOAgendaView::showDates "); | 1036 | // qDebug("KOAgendaView::showDates "); |
1019 | QDate d = start; | 1037 | QDate d = start; |
1020 | while (d <= end) { | 1038 | while (d <= end) { |
1021 | mSelectedDates.append(d); | 1039 | mSelectedDates.append(d); |
1022 | d = d.addDays( 1 ); | 1040 | d = d.addDays( 1 ); |
1023 | } | 1041 | } |
1024 | 1042 | ||
1025 | // and update the view | 1043 | // and update the view |
1026 | fillAgenda(); | 1044 | fillAgenda(); |
1027 | } | 1045 | } |
1028 | 1046 | ||
1029 | 1047 | ||
1030 | void KOAgendaView::showEvents(QPtrList<Event>) | 1048 | void KOAgendaView::showEvents(QPtrList<Event>) |
1031 | { | 1049 | { |
1032 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; | 1050 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; |
1033 | } | 1051 | } |
1034 | 1052 | ||
1035 | void KOAgendaView::changeEventDisplay(Event *, int) | 1053 | void KOAgendaView::changeEventDisplay(Event *, int) |
1036 | { | 1054 | { |
1037 | // qDebug("KOAgendaView::changeEventDisplay "); | 1055 | // qDebug("KOAgendaView::changeEventDisplay "); |
1038 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; | 1056 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; |
1039 | // this should be re-written to be MUCH smarter. Right now we | 1057 | // this should be re-written to be MUCH smarter. Right now we |
1040 | // are just playing dumb. | 1058 | // are just playing dumb. |
1041 | fillAgenda(); | 1059 | fillAgenda(); |
1042 | } | 1060 | } |
1043 | 1061 | ||
1044 | void KOAgendaView::fillAgenda(const QDate &) | 1062 | void KOAgendaView::fillAgenda(const QDate &) |
1045 | { | 1063 | { |
1046 | // qDebug("KOAgendaView::fillAgenda "); | 1064 | // qDebug("KOAgendaView::fillAgenda "); |
1047 | fillAgenda(); | 1065 | fillAgenda(); |
1048 | } | 1066 | } |
1049 | 1067 | ||
1050 | void KOAgendaView::fillAgenda() | 1068 | void KOAgendaView::fillAgenda() |
1051 | { | 1069 | { |
1052 | if ( globalFlagBlockStartup ) | 1070 | if ( globalFlagBlockStartup ) |
1053 | return; | 1071 | return; |
1054 | if ( globalFlagBlockAgenda == 1 ) | 1072 | if ( globalFlagBlockAgenda == 1 ) |
1055 | return; | 1073 | return; |
1056 | //if ( globalFlagBlockAgenda == 2 ) | 1074 | //if ( globalFlagBlockAgenda == 2 ) |
1057 | //globalFlagBlockAgenda = 0; | 1075 | //globalFlagBlockAgenda = 0; |
1058 | // globalFlagBlockPainting = false; | 1076 | // globalFlagBlockPainting = false; |
1059 | if ( globalFlagBlockAgenda == 0 ) | 1077 | if ( globalFlagBlockAgenda == 0 ) |
1060 | globalFlagBlockAgenda = 1; | 1078 | globalFlagBlockAgenda = 1; |
1061 | // clearView(); | 1079 | // clearView(); |
1062 | //qDebug("fillAgenda()++++ "); | 1080 | //qDebug("fillAgenda()++++ "); |
1063 | globalFlagBlockAgendaItemPaint = 1; | 1081 | globalFlagBlockAgendaItemPaint = 1; |
1064 | 1082 | ||
1065 | mAllDayAgenda->changeColumns(mSelectedDates.count()); | 1083 | mAllDayAgenda->changeColumns(mSelectedDates.count()); |
1066 | mAgenda->changeColumns(mSelectedDates.count()); | 1084 | mAgenda->changeColumns(mSelectedDates.count()); |
1067 | qApp->processEvents(); | 1085 | qApp->processEvents(); |
1068 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); | 1086 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); |
1069 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); | 1087 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); |
1070 | setHolidayMasks(); | 1088 | setHolidayMasks(); |
1071 | 1089 | ||
1072 | //mAgenda->hideUnused(); | 1090 | //mAgenda->hideUnused(); |
1073 | //mAllDayAgenda->hideUnused(); | 1091 | //mAllDayAgenda->hideUnused(); |
1074 | 1092 | ||
1075 | // mAgenda->blockNextRepaint( false ); | 1093 | // mAgenda->blockNextRepaint( false ); |
1076 | // mAgenda->viewport()->repaint(); | 1094 | // mAgenda->viewport()->repaint(); |
1077 | // mAgenda->blockNextRepaint( true ); | 1095 | // mAgenda->blockNextRepaint( true ); |
1078 | mMinY.resize(mSelectedDates.count()); | 1096 | mMinY.resize(mSelectedDates.count()); |
1079 | mMaxY.resize(mSelectedDates.count()); | 1097 | mMaxY.resize(mSelectedDates.count()); |
1080 | 1098 | ||
1081 | QPtrList<Event> dayEvents; | 1099 | QPtrList<Event> dayEvents; |
1082 | 1100 | ||
1083 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1101 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1084 | // Therefore, gtodoset all of them. | 1102 | // Therefore, gtodoset all of them. |
1085 | QPtrList<Todo> todos = calendar()->todos(); | 1103 | QPtrList<Todo> todos = calendar()->todos(); |
1086 | 1104 | ||
1087 | mAgenda->setDateList(mSelectedDates); | 1105 | mAgenda->setDateList(mSelectedDates); |
1088 | 1106 | ||
1089 | QDate today = QDate::currentDate(); | 1107 | QDate today = QDate::currentDate(); |
1090 | 1108 | ||
1091 | DateList::ConstIterator dit; | 1109 | DateList::ConstIterator dit; |
1092 | int curCol = 0; | 1110 | int curCol = 0; |
1093 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 1111 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
1094 | QDate currentDate = *dit; | 1112 | QDate currentDate = *dit; |
1095 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() | 1113 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() |
1096 | // << endl; | 1114 | // << endl; |
1097 | 1115 | ||
1098 | dayEvents = calendar()->events(currentDate,true); | 1116 | dayEvents = calendar()->events(currentDate,true); |
1099 | 1117 | ||
1100 | // Default values, which can never be reached | 1118 | // Default values, which can never be reached |
1101 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; | 1119 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; |
1102 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; | 1120 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; |
1103 | 1121 | ||
1104 | unsigned int numEvent; | 1122 | unsigned int numEvent; |
1105 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { | 1123 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { |
1106 | Event *event = dayEvents.at(numEvent); | 1124 | Event *event = dayEvents.at(numEvent); |
1107 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) | 1125 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) |
1108 | if ( event->uid().left(15) == QString("last-syncEvent-") ) | 1126 | if ( event->uid().left(15) == QString("last-syncEvent-") ) |
1109 | continue; | 1127 | continue; |
1110 | // kdDebug() << " Event: " << event->summary() << endl; | 1128 | // kdDebug() << " Event: " << event->summary() << endl; |
1111 | 1129 | ||
1112 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; | 1130 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; |
1113 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; | 1131 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; |
1114 | 1132 | ||
1115 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; | 1133 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; |
1116 | 1134 | ||
1117 | if (event->doesFloat()) { | 1135 | if (event->doesFloat()) { |
1118 | if (event->recurrence()->doesRecur()) { | 1136 | if (event->recurrence()->doesRecur()) { |
1119 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); | 1137 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); |
1120 | } else { | 1138 | } else { |
1121 | if (beginX <= 0 && curCol == 0) { | 1139 | if (beginX <= 0 && curCol == 0) { |
1122 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1140 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1123 | } else if (beginX == curCol) { | 1141 | } else if (beginX == curCol) { |
1124 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1142 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1125 | } | 1143 | } |
1126 | } | 1144 | } |
1127 | } else if (event->isMultiDay()) { | 1145 | } else if (event->isMultiDay()) { |
1128 | if ( event->doesRecur () ) { | 1146 | if ( event->doesRecur () ) { |
1129 | QDate dateit = currentDate; | 1147 | QDate dateit = currentDate; |
1130 | int count = 0; | 1148 | int count = 0; |
1131 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; | 1149 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; |
1132 | while (! event->recursOn( dateit ) && count <= max ) { | 1150 | while (! event->recursOn( dateit ) && count <= max ) { |
1133 | ++count; | 1151 | ++count; |
1134 | dateit = dateit.addDays( -1 ); | 1152 | dateit = dateit.addDays( -1 ); |
1135 | } | 1153 | } |
1136 | bool ok; | 1154 | bool ok; |
1137 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); | 1155 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); |
1138 | if ( ok ) | 1156 | if ( ok ) |
1139 | { | 1157 | { |
1140 | int secs = event->dtStart().secsTo( event->dtEnd() ); | 1158 | int secs = event->dtStart().secsTo( event->dtEnd() ); |
1141 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; | 1159 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; |
1142 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; | 1160 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; |
1143 | endX = currentDate.daysTo(nextOcend.date()) + curCol; | 1161 | endX = currentDate.daysTo(nextOcend.date()) + curCol; |
1144 | 1162 | ||
1145 | } | 1163 | } |
1146 | } | 1164 | } |
1147 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1165 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1148 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1166 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1149 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); | 1167 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); |
1150 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { | 1168 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { |
1151 | //qDebug("insert!!! "); | 1169 | //qDebug("insert!!! "); |
1152 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); | 1170 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); |
1153 | } | 1171 | } |
1154 | if (beginX == curCol) { | 1172 | if (beginX == curCol) { |
1155 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1173 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1156 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1174 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1157 | } else if (endX == curCol) { | 1175 | } else if (endX == curCol) { |
1158 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1176 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1159 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1177 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1160 | } else { | 1178 | } else { |
1161 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1179 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1162 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1180 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1163 | } | 1181 | } |
1164 | } else { | 1182 | } else { |
1165 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1183 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1166 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1184 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1167 | if (endY < startY) endY = startY; | 1185 | if (endY < startY) endY = startY; |
1168 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); | 1186 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); |
1169 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1187 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1170 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1188 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1171 | } | 1189 | } |
1172 | } | 1190 | } |
1173 | // ---------- [display Todos -------------- | 1191 | // ---------- [display Todos -------------- |
1174 | unsigned int numTodo; | 1192 | unsigned int numTodo; |
1175 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { | 1193 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { |
1176 | Todo *todo = todos.at(numTodo); | 1194 | Todo *todo = todos.at(numTodo); |
1177 | 1195 | ||
1178 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date | 1196 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date |
1179 | 1197 | ||
1180 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1198 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1181 | // Already completed items can be displayed on their original due date | 1199 | // Already completed items can be displayed on their original due date |
1182 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda | 1200 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda |
1183 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; | 1201 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; |
1184 | bool fillIn = false; | 1202 | bool fillIn = false; |
1185 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) | 1203 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) |
1186 | fillIn = true; | 1204 | fillIn = true; |
1187 | if ( ! fillIn && !todo->hasCompletedDate() ) | 1205 | if ( ! fillIn && !todo->hasCompletedDate() ) |
1188 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); | 1206 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); |
1189 | if ( fillIn ) { | 1207 | if ( fillIn ) { |
1190 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue | 1208 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue |
1191 | if ( KOPrefs::instance()->mShowTodoInAgenda ) | 1209 | if ( KOPrefs::instance()->mShowTodoInAgenda ) |
1192 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); | 1210 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); |
1193 | } | 1211 | } |
1194 | else { | 1212 | else { |
1195 | QDateTime dt; | 1213 | QDateTime dt; |
1196 | if ( todo->hasCompletedDate() ) | 1214 | if ( todo->hasCompletedDate() ) |
1197 | dt = todo->completed(); | 1215 | dt = todo->completed(); |
1198 | else | 1216 | else |
1199 | dt = todo->dtDue();; | 1217 | dt = todo->dtDue();; |
1200 | 1218 | ||
1201 | 1219 | ||
1202 | int endY = mAgenda->timeToY(dt.time()) - 1; | 1220 | int endY = mAgenda->timeToY(dt.time()) - 1; |
1203 | int hi = (18/KOPrefs::instance()->mHourSize); | 1221 | int hi = (18/KOPrefs::instance()->mHourSize); |
1204 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); | 1222 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); |
1205 | int startY = endY -hi; | 1223 | int startY = endY -hi; |
1206 | 1224 | ||
1207 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); | 1225 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); |
1208 | 1226 | ||
1209 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1227 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1210 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1228 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1211 | } | 1229 | } |
1212 | } | 1230 | } |
1213 | } | 1231 | } |
1214 | // ---------- display Todos] -------------- | 1232 | // ---------- display Todos] -------------- |
1215 | 1233 | ||
1216 | ++curCol; | 1234 | ++curCol; |
1217 | } | 1235 | } |
1218 | mAgenda->hideUnused(); | 1236 | mAgenda->hideUnused(); |
1219 | mAllDayAgenda->hideUnused(); | 1237 | mAllDayAgenda->hideUnused(); |
1220 | mAgenda->checkScrollBoundaries(); | 1238 | mAgenda->checkScrollBoundaries(); |
1221 | 1239 | ||
1222 | deleteSelectedDateTime(); | 1240 | deleteSelectedDateTime(); |
1223 | 1241 | ||
1224 | createDayLabels(); | 1242 | createDayLabels(); |
1225 | emit incidenceSelected( 0 ); | 1243 | emit incidenceSelected( 0 ); |
1226 | 1244 | ||
1227 | if ( globalFlagBlockAgenda == 2 ) { | 1245 | if ( globalFlagBlockAgenda == 2 ) { |
1228 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) | 1246 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) |
1229 | setStartHour( KOPrefs::instance()->mDayBegins ); | 1247 | setStartHour( KOPrefs::instance()->mDayBegins ); |
1230 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 1248 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
1231 | setStartHour( QTime::currentTime ().hour() ); | 1249 | setStartHour( QTime::currentTime ().hour() ); |
1232 | // qApp->processEvents(); | 1250 | // qApp->processEvents(); |
1233 | } | 1251 | } |
1234 | qApp->processEvents(); | 1252 | qApp->processEvents(); |
1235 | //qDebug("qApp->processEvents(); END "); | 1253 | //qDebug("qApp->processEvents(); END "); |
1236 | globalFlagBlockAgenda = 0; | 1254 | globalFlagBlockAgenda = 0; |
1237 | 1255 | ||
1238 | // mAgenda->hideUnused(); | 1256 | // mAgenda->hideUnused(); |
1239 | //mAllDayAgenda->hideUnused(); | 1257 | //mAllDayAgenda->hideUnused(); |
1240 | mAllDayAgenda->drawContentsToPainter(); | 1258 | mAllDayAgenda->drawContentsToPainter(); |
1241 | mAgenda->drawContentsToPainter(); | 1259 | mAgenda->drawContentsToPainter(); |
1242 | repaintAgenda(); | 1260 | repaintAgenda(); |
1243 | // mAgenda->finishUpdate(); | 1261 | // mAgenda->finishUpdate(); |
1244 | //mAllDayAgenda->finishUpdate(); | 1262 | //mAllDayAgenda->finishUpdate(); |
1245 | 1263 | ||
1246 | // repaintAgenda(); | 1264 | // repaintAgenda(); |
1247 | //qApp->processEvents(); | 1265 | //qApp->processEvents(); |
1248 | // globalFlagBlockAgenda = 0; | 1266 | // globalFlagBlockAgenda = 0; |
1249 | } | 1267 | } |
1250 | void KOAgendaView::repaintAgenda() | 1268 | void KOAgendaView::repaintAgenda() |
1251 | { | 1269 | { |
1252 | // mAllDayAgenda->drawContentsToPainter(); | 1270 | // mAllDayAgenda->drawContentsToPainter(); |
1253 | // mAllDayAgenda->viewport()->repaint( false ); | 1271 | // mAllDayAgenda->viewport()->repaint( false ); |
1254 | // mAgenda->drawContentsToPainter(); | 1272 | // mAgenda->drawContentsToPainter(); |
1255 | // mAgenda->viewport()->repaint( false ); | 1273 | // mAgenda->viewport()->repaint( false ); |
1256 | // qApp->processEvents(); | 1274 | // qApp->processEvents(); |
1257 | 1275 | ||
1258 | //qDebug("KOAgendaView::repaintAgenda() "); | 1276 | //qDebug("KOAgendaView::repaintAgenda() "); |
1259 | //qApp->processEvents(); | 1277 | //qApp->processEvents(); |
1260 | mAgenda->viewport()->repaint( false ); | 1278 | mAgenda->viewport()->repaint( false ); |
1261 | mAllDayAgenda->viewport()->repaint( false ); | 1279 | mAllDayAgenda->viewport()->repaint( false ); |
1262 | mAgenda->finishUpdate(); | 1280 | mAgenda->finishUpdate(); |
1263 | mAllDayAgenda->finishUpdate(); | 1281 | mAllDayAgenda->finishUpdate(); |
1264 | } | 1282 | } |
1265 | 1283 | ||
1266 | 1284 | ||
1267 | void KOAgendaView::clearView() | 1285 | void KOAgendaView::clearView() |
1268 | { | 1286 | { |
1269 | // kdDebug() << "ClearView" << endl; | 1287 | // kdDebug() << "ClearView" << endl; |
1270 | mAllDayAgenda->clear(); | 1288 | mAllDayAgenda->clear(); |
1271 | mAgenda->clear(); | 1289 | mAgenda->clear(); |
1272 | } | 1290 | } |
1273 | 1291 | ||
1274 | void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1292 | void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1275 | const QDate &td) | 1293 | const QDate &td) |
1276 | { | 1294 | { |
1277 | #ifndef KORG_NOPRINTER | 1295 | #ifndef KORG_NOPRINTER |
1278 | if (fd == td) | 1296 | if (fd == td) |
1279 | calPrinter->preview(CalPrinter::Day, fd, td); | 1297 | calPrinter->preview(CalPrinter::Day, fd, td); |
1280 | else | 1298 | else |
1281 | calPrinter->preview(CalPrinter::Week, fd, td); | 1299 | calPrinter->preview(CalPrinter::Week, fd, td); |
1282 | #endif | 1300 | #endif |
1283 | } | 1301 | } |
1284 | 1302 | ||
1285 | // void KOAgendaView::updateMovedTodo() | 1303 | // void KOAgendaView::updateMovedTodo() |
1286 | // { | 1304 | // { |
1287 | // // updateConfig(); | 1305 | // // updateConfig(); |
1288 | // // emit updateTodoViews(); | 1306 | // // emit updateTodoViews(); |
1289 | // } | 1307 | // } |
1290 | 1308 | ||
1291 | void KOAgendaView::newEvent(int gx, int gy) | 1309 | void KOAgendaView::newEvent(int gx, int gy) |
1292 | { | 1310 | { |
1293 | if (!mSelectedDates.count()) return; | 1311 | if (!mSelectedDates.count()) return; |
1294 | 1312 | ||
1295 | QDate day = mSelectedDates[gx]; | 1313 | QDate day = mSelectedDates[gx]; |
1296 | 1314 | ||
1297 | QTime time = mAgenda->gyToTime(gy); | 1315 | QTime time = mAgenda->gyToTime(gy); |
1298 | QDateTime dt(day,time); | 1316 | QDateTime dt(day,time); |
1299 | // if ( dt < QDateTime::currentDateTime () ) | 1317 | // if ( dt < QDateTime::currentDateTime () ) |
1300 | // dt = QDateTime::currentDateTime ().addSecs( 3600 ); | 1318 | // dt = QDateTime::currentDateTime ().addSecs( 3600 ); |
1301 | emit newEventSignal(dt); | 1319 | emit newEventSignal(dt); |
1302 | } | 1320 | } |
1303 | 1321 | ||
1304 | void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) | 1322 | void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) |
1305 | { | 1323 | { |
1306 | if (!mSelectedDates.count()) return; | 1324 | if (!mSelectedDates.count()) return; |
1307 | 1325 | ||
1308 | QDate dayStart = mSelectedDates[gxStart]; | 1326 | QDate dayStart = mSelectedDates[gxStart]; |
1309 | QDate dayEnd = mSelectedDates[gxEnd]; | 1327 | QDate dayEnd = mSelectedDates[gxEnd]; |
1310 | 1328 | ||
1311 | QTime timeStart = mAgenda->gyToTime(gyStart); | 1329 | QTime timeStart = mAgenda->gyToTime(gyStart); |
1312 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); | 1330 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); |
1313 | 1331 | ||
1314 | QDateTime dtStart(dayStart,timeStart); | 1332 | QDateTime dtStart(dayStart,timeStart); |
1315 | QDateTime dtEnd(dayEnd,timeEnd); | 1333 | QDateTime dtEnd(dayEnd,timeEnd); |
1316 | 1334 | ||
1317 | emit newEventSignal(dtStart,dtEnd); | 1335 | emit newEventSignal(dtStart,dtEnd); |
1318 | } | 1336 | } |
1319 | 1337 | ||
1320 | void KOAgendaView::newEventAllDay(int gx, int ) | 1338 | void KOAgendaView::newEventAllDay(int gx, int ) |
1321 | { | 1339 | { |
1322 | if (!mSelectedDates.count()) return; | 1340 | if (!mSelectedDates.count()) return; |
1323 | 1341 | ||
1324 | QDate day = mSelectedDates[gx]; | 1342 | QDate day = mSelectedDates[gx]; |
1325 | 1343 | ||
1326 | emit newEventSignal(day); | 1344 | emit newEventSignal(day); |
1327 | } | 1345 | } |
1328 | void KOAgendaView::newTodoAllDay(int gx, int ) | 1346 | void KOAgendaView::newTodoAllDay(int gx, int ) |
1329 | { | 1347 | { |
1330 | if (!mSelectedDates.count()) return; | 1348 | if (!mSelectedDates.count()) return; |
1331 | 1349 | ||
1332 | QDateTime day (mSelectedDates[gx] ); | 1350 | QDateTime day (mSelectedDates[gx] ); |
1333 | emit newTodoSignal(day, true); | 1351 | emit newTodoSignal(day, true); |
1334 | } | 1352 | } |
1335 | void KOAgendaView::newTodo(int gx, int gy ) | 1353 | void KOAgendaView::newTodo(int gx, int gy ) |
1336 | { | 1354 | { |
1337 | if (!mSelectedDates.count()) return; | 1355 | if (!mSelectedDates.count()) return; |
1338 | QDate dayStart = mSelectedDates[gx]; | 1356 | QDate dayStart = mSelectedDates[gx]; |
1339 | QTime timeStart = mAgenda->gyToTime(gy); | 1357 | QTime timeStart = mAgenda->gyToTime(gy); |
1340 | QDateTime dt (dayStart,timeStart); | 1358 | QDateTime dt (dayStart,timeStart); |
1341 | emit newTodoSignal( dt, false ); | 1359 | emit newTodoSignal( dt, false ); |
1342 | } | 1360 | } |
1343 | 1361 | ||
1344 | void KOAgendaView::updateEventIndicatorTop(int newY) | 1362 | void KOAgendaView::updateEventIndicatorTop(int newY) |
1345 | { | 1363 | { |
1346 | uint i; | 1364 | uint i; |
1347 | for(i=0;i<mMinY.size();++i) { | 1365 | for(i=0;i<mMinY.size();++i) { |
1348 | if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); | 1366 | if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); |
1349 | else mEventIndicatorTop->enableColumn(i,false); | 1367 | else mEventIndicatorTop->enableColumn(i,false); |
1350 | } | 1368 | } |
1351 | 1369 | ||
1352 | mEventIndicatorTop->update(); | 1370 | mEventIndicatorTop->update(); |
1353 | } | 1371 | } |
1354 | 1372 | ||
1355 | void KOAgendaView::updateEventIndicatorBottom(int newY) | 1373 | void KOAgendaView::updateEventIndicatorBottom(int newY) |
1356 | { | 1374 | { |
1357 | uint i; | 1375 | uint i; |
1358 | for(i=0;i<mMaxY.size();++i) { | 1376 | for(i=0;i<mMaxY.size();++i) { |
1359 | if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); | 1377 | if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); |
1360 | else mEventIndicatorBottom->enableColumn(i,false); | 1378 | else mEventIndicatorBottom->enableColumn(i,false); |
1361 | } | 1379 | } |
1362 | 1380 | ||
1363 | mEventIndicatorBottom->update(); | 1381 | mEventIndicatorBottom->update(); |
1364 | } | 1382 | } |
1365 | 1383 | ||
1366 | void KOAgendaView::startDrag(Event *event) | 1384 | void KOAgendaView::startDrag(Event *event) |
1367 | { | 1385 | { |
1368 | #ifndef KORG_NODND | 1386 | #ifndef KORG_NODND |
1369 | DndFactory factory( calendar() ); | 1387 | DndFactory factory( calendar() ); |
1370 | ICalDrag *vd = factory.createDrag(event,this); | 1388 | ICalDrag *vd = factory.createDrag(event,this); |
1371 | if (vd->drag()) { | 1389 | if (vd->drag()) { |
1372 | kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; | 1390 | kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; |
1373 | } | 1391 | } |
1374 | #endif | 1392 | #endif |
1375 | } | 1393 | } |
1376 | 1394 | ||
1377 | void KOAgendaView::readSettings() | 1395 | void KOAgendaView::readSettings() |
1378 | { | 1396 | { |
1379 | readSettings(KOGlobals::config()); | 1397 | readSettings(KOGlobals::config()); |
1380 | } | 1398 | } |
1381 | 1399 | ||
1382 | void KOAgendaView::readSettings(KConfig *config) | 1400 | void KOAgendaView::readSettings(KConfig *config) |
1383 | { | 1401 | { |
1384 | // kdDebug() << "KOAgendaView::readSettings()" << endl; | 1402 | // kdDebug() << "KOAgendaView::readSettings()" << endl; |
1385 | 1403 | ||
1386 | config->setGroup("Views"); | 1404 | config->setGroup("Views"); |
1387 | 1405 | ||
1388 | //#ifndef KORG_NOSPLITTER | 1406 | //#ifndef KORG_NOSPLITTER |
1389 | QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); | 1407 | QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); |
1390 | if (sizes.count() == 2) { | 1408 | if (sizes.count() == 2) { |
1391 | if ( sizes[0] < 20 ) { | 1409 | if ( sizes[0] < 20 ) { |
1392 | sizes[1] = sizes[1] +20 - sizes[0]; | 1410 | sizes[1] = sizes[1] +20 - sizes[0]; |
1393 | sizes[0] = 20; | 1411 | sizes[0] = 20; |
1394 | } | 1412 | } |
1395 | mSplitterAgenda->setSizes(sizes); | 1413 | mSplitterAgenda->setSizes(sizes); |
1396 | // qDebug("read %d %d ",sizes[0],sizes[1] ); | 1414 | // qDebug("read %d %d ",sizes[0],sizes[1] ); |
1397 | } | 1415 | } |
1398 | //#endif | 1416 | //#endif |
1399 | 1417 | ||
1400 | // updateConfig(); | 1418 | // updateConfig(); |
1401 | } | 1419 | } |
1402 | 1420 | ||
1403 | void KOAgendaView::writeSettings(KConfig *config) | 1421 | void KOAgendaView::writeSettings(KConfig *config) |
1404 | { | 1422 | { |
1405 | // kdDebug() << "KOAgendaView::writeSettings()" << endl; | 1423 | // kdDebug() << "KOAgendaView::writeSettings()" << endl; |
1406 | 1424 | ||
1407 | config->setGroup("Views"); | 1425 | config->setGroup("Views"); |
1408 | 1426 | ||
1409 | //#ifndef KORG_NOSPLITTER | 1427 | //#ifndef KORG_NOSPLITTER |
1410 | QValueList<int> list = mSplitterAgenda->sizes(); | 1428 | QValueList<int> list = mSplitterAgenda->sizes(); |
1411 | config->writeEntry("Separator AgendaView",list); | 1429 | config->writeEntry("Separator AgendaView",list); |
1412 | //qDebug("write %d %d ", list[0],list[1] ); | 1430 | //qDebug("write %d %d ", list[0],list[1] ); |
1413 | //#endif | 1431 | //#endif |
1414 | } | 1432 | } |
1415 | 1433 | ||
1416 | void KOAgendaView::setHolidayMasks() | 1434 | void KOAgendaView::setHolidayMasks() |
1417 | { | 1435 | { |
1418 | mHolidayMask.resize(mSelectedDates.count()); | 1436 | mHolidayMask.resize(mSelectedDates.count()); |
1419 | 1437 | ||
1420 | uint i; | 1438 | uint i; |
1421 | for(i=0;i<mSelectedDates.count();++i) { | 1439 | for(i=0;i<mSelectedDates.count();++i) { |
1422 | QDate date = mSelectedDates[i]; | 1440 | QDate date = mSelectedDates[i]; |
1423 | bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); | 1441 | bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); |
1424 | bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); | 1442 | bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); |
1425 | bool showHoliday = false; | 1443 | bool showHoliday = false; |
1426 | if ( KOPrefs::instance()->mExcludeHolidays ) { | 1444 | if ( KOPrefs::instance()->mExcludeHolidays ) { |
1427 | QPtrList<Event> events = calendar()->events( date, true ); | 1445 | QPtrList<Event> events = calendar()->events( date, true ); |
1428 | Event *event; | 1446 | Event *event; |
1429 | for( event = events.first(); event; event = events.next() ) { | 1447 | for( event = events.first(); event; event = events.next() ) { |
1430 | if ( event->isHoliday()) { | 1448 | if ( event->isHoliday()) { |
1431 | showHoliday = true; | 1449 | showHoliday = true; |
1432 | break; | 1450 | break; |
1433 | } | 1451 | } |
1434 | } | 1452 | } |
1435 | 1453 | ||
1436 | } | 1454 | } |
1437 | 1455 | ||
1438 | #ifndef KORG_NOPLUGINS | 1456 | #ifndef KORG_NOPLUGINS |
1439 | bool showHoliday = KOPrefs::instance()->mExcludeHolidays && | 1457 | bool showHoliday = KOPrefs::instance()->mExcludeHolidays && |
1440 | !KOCore::self()->holiday(date).isEmpty(); | 1458 | !KOCore::self()->holiday(date).isEmpty(); |
1441 | #endif | 1459 | #endif |
1442 | bool showDay = showSaturday || showSunday || showHoliday; | 1460 | bool showDay = showSaturday || showSunday || showHoliday; |
1443 | 1461 | ||
1444 | if (showDay) { | 1462 | if (showDay) { |
1445 | mHolidayMask.at(i) = true; | 1463 | mHolidayMask.at(i) = true; |
1446 | } else { | 1464 | } else { |
1447 | mHolidayMask.at(i) = false; | 1465 | mHolidayMask.at(i) = false; |
1448 | } | 1466 | } |
1449 | } | 1467 | } |
1450 | 1468 | ||
1451 | mAgenda->setHolidayMask(&mHolidayMask); | 1469 | mAgenda->setHolidayMask(&mHolidayMask); |
1452 | mAllDayAgenda->setHolidayMask(&mHolidayMask); | 1470 | mAllDayAgenda->setHolidayMask(&mHolidayMask); |
1453 | } | 1471 | } |
1454 | 1472 | ||
1455 | void KOAgendaView::setContentsPos(int y) | 1473 | void KOAgendaView::setContentsPos(int y) |
1456 | { | 1474 | { |
1457 | mAgenda->setContentsPos(0,y); | 1475 | mAgenda->setContentsPos(0,y); |
1458 | } | 1476 | } |
1459 | 1477 | ||
1460 | void KOAgendaView::clearSelection() | 1478 | void KOAgendaView::clearSelection() |
1461 | { | 1479 | { |
1462 | mAgenda->deselectItem(); | 1480 | mAgenda->deselectItem(); |
1463 | mAllDayAgenda->deselectItem(); | 1481 | mAllDayAgenda->deselectItem(); |
1464 | } | 1482 | } |
1465 | 1483 | ||
1466 | void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, | 1484 | void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, |
1467 | int gxEnd, int gyEnd) | 1485 | int gxEnd, int gyEnd) |
1468 | { | 1486 | { |
1469 | mTimeSpanInAllDay = true; | 1487 | mTimeSpanInAllDay = true; |
1470 | newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); | 1488 | newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); |
1471 | } | 1489 | } |
1472 | 1490 | ||
1473 | 1491 | ||
1474 | 1492 | ||
1475 | 1493 | ||
1476 | void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, | 1494 | void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, |
1477 | int gxEnd, int gyEnd) | 1495 | int gxEnd, int gyEnd) |
1478 | { | 1496 | { |
1479 | if (!mSelectedDates.count()) return; | 1497 | if (!mSelectedDates.count()) return; |
1480 | 1498 | ||
1481 | QDate dayStart = mSelectedDates[gxStart]; | 1499 | QDate dayStart = mSelectedDates[gxStart]; |
1482 | QDate dayEnd = mSelectedDates[gxEnd]; | 1500 | QDate dayEnd = mSelectedDates[gxEnd]; |
1483 | 1501 | ||
1484 | QTime timeStart = mAgenda->gyToTime(gyStart); | 1502 | QTime timeStart = mAgenda->gyToTime(gyStart); |
1485 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); | 1503 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); |
1486 | 1504 | ||
1487 | QDateTime dtStart(dayStart,timeStart); | 1505 | QDateTime dtStart(dayStart,timeStart); |
1488 | QDateTime dtEnd(dayEnd,timeEnd); | 1506 | QDateTime dtEnd(dayEnd,timeEnd); |
1489 | 1507 | ||
1490 | mTimeSpanBegin = dtStart; | 1508 | mTimeSpanBegin = dtStart; |
1491 | mTimeSpanEnd = dtEnd; | 1509 | mTimeSpanEnd = dtEnd; |
1492 | 1510 | ||
1493 | } | 1511 | } |
1494 | 1512 | ||
1495 | void KOAgendaView::deleteSelectedDateTime() | 1513 | void KOAgendaView::deleteSelectedDateTime() |
1496 | { | 1514 | { |
1497 | mTimeSpanBegin.setDate(QDate()); | 1515 | mTimeSpanBegin.setDate(QDate()); |
1498 | mTimeSpanEnd.setDate(QDate()); | 1516 | mTimeSpanEnd.setDate(QDate()); |
1499 | mTimeSpanInAllDay = false; | 1517 | mTimeSpanInAllDay = false; |
1500 | } | 1518 | } |
1501 | 1519 | ||
1502 | void KOAgendaView::keyPressEvent ( QKeyEvent * e ) | 1520 | void KOAgendaView::keyPressEvent ( QKeyEvent * e ) |
1503 | { | 1521 | { |
1504 | e->ignore(); | 1522 | e->ignore(); |
1505 | } | 1523 | } |
1506 | 1524 | ||
1507 | void KOAgendaView::scrollOneHourUp() | 1525 | void KOAgendaView::scrollOneHourUp() |
1508 | { | 1526 | { |
1509 | 1527 | ||
1510 | mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); | 1528 | mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); |
1511 | } | 1529 | } |
1512 | void KOAgendaView::scrollOneHourDown() | 1530 | void KOAgendaView::scrollOneHourDown() |
1513 | { | 1531 | { |
1514 | mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); | 1532 | mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); |
1515 | } | 1533 | } |
1516 | 1534 | ||
1517 | void KOAgendaView::setStartHour( int h ) | 1535 | void KOAgendaView::setStartHour( int h ) |
1518 | { | 1536 | { |
1519 | mAgenda->setStartHour( h ); | 1537 | mAgenda->setStartHour( h ); |
1520 | 1538 | ||
1521 | } | 1539 | } |
1522 | void KOAgendaView::setInitStartHour() | 1540 | void KOAgendaView::setInitStartHour() |
1523 | { | 1541 | { |
1524 | 1542 | ||
1525 | if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 1543 | if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
1526 | setStartHour( QTime::currentTime ().hour() ); | 1544 | setStartHour( QTime::currentTime ().hour() ); |
1527 | else | 1545 | else |
1528 | setStartHour( KOPrefs::instance()->mDayBegins ); | 1546 | setStartHour( KOPrefs::instance()->mDayBegins ); |
1529 | 1547 | ||
1530 | } | 1548 | } |
1531 | 1549 | ||
1532 | 1550 | ||
1533 | void KOAgendaView::updateTodo( Todo * t, int ) | 1551 | void KOAgendaView::updateTodo( Todo * t, int ) |
1534 | { | 1552 | { |
1535 | if ( !isVisible() ) | 1553 | if ( !isVisible() ) |
1536 | return; | 1554 | return; |
1537 | bool remove = false; | 1555 | bool remove = false; |
1538 | bool removeAD = false; | 1556 | bool removeAD = false; |
1539 | QDate da; | 1557 | QDate da; |
1540 | if ( t->hasCompletedDate() ) | 1558 | if ( t->hasCompletedDate() ) |
1541 | da = t->completed().date(); | 1559 | da = t->completed().date(); |
1542 | else | 1560 | else |
1543 | da = t->dtDue().date(); | 1561 | da = t->dtDue().date(); |
1544 | if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { | 1562 | if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { |
1545 | remove = true; | 1563 | remove = true; |
1546 | removeAD = true; | 1564 | removeAD = true; |
1547 | } | 1565 | } |
1548 | else { | 1566 | else { |
1549 | bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; | 1567 | bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; |
1550 | if ( overdue && | 1568 | if ( overdue && |
1551 | QDate::currentDate() >= mSelectedDates.first() && | 1569 | QDate::currentDate() >= mSelectedDates.first() && |
1552 | QDate::currentDate() <= mSelectedDates.last()) { | 1570 | QDate::currentDate() <= mSelectedDates.last()) { |
1553 | removeAD = false; | 1571 | removeAD = false; |
1554 | remove = true; | 1572 | remove = true; |
1555 | } | 1573 | } |
1556 | else { | 1574 | else { |
1557 | 1575 | ||
1558 | if ( da < mSelectedDates.first() || | 1576 | if ( da < mSelectedDates.first() || |
1559 | da > mSelectedDates.last() ) { | 1577 | da > mSelectedDates.last() ) { |
1560 | remove = true; | 1578 | remove = true; |
1561 | removeAD = true; | 1579 | removeAD = true; |
1562 | } else { | 1580 | } else { |
1563 | remove = t->doesFloat() && !t->hasCompletedDate(); | 1581 | remove = t->doesFloat() && !t->hasCompletedDate(); |
1564 | removeAD = !remove; | 1582 | removeAD = !remove; |
1565 | } | 1583 | } |
1566 | } | 1584 | } |
1567 | } | 1585 | } |
1568 | int days = mSelectedDates.first().daysTo( da ); | 1586 | int days = mSelectedDates.first().daysTo( da ); |
1569 | //qDebug("daysto %d %d %d", days, remove,removeAD ); | 1587 | //qDebug("daysto %d %d %d", days, remove,removeAD ); |
1570 | mAgenda->updateTodo( t , days, remove); | 1588 | mAgenda->updateTodo( t , days, remove); |
1571 | if ( KOPrefs::instance()->mShowTodoInAgenda ) | 1589 | if ( KOPrefs::instance()->mShowTodoInAgenda ) |
1572 | mAllDayAgenda->updateTodo( t , days, removeAD); | 1590 | mAllDayAgenda->updateTodo( t , days, removeAD); |
1573 | //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); | 1591 | //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); |
1574 | 1592 | ||
1575 | } | 1593 | } |