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