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