-rw-r--r-- | korganizer/koagendaview.cpp | 86 | ||||
-rw-r--r-- | korganizer/kodaymatrix.cpp | 8 | ||||
-rw-r--r-- | microkde/KDGanttMinimizeSplitter.cpp | 10 | ||||
-rw-r--r-- | microkde/kdialogbase.cpp | 8 |
4 files changed, 88 insertions, 24 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index 2b05d37..8d32152 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -1,1505 +1,1573 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qhbox.h> | 24 | #include <qhbox.h> |
25 | #include <qvbox.h> | 25 | #include <qvbox.h> |
26 | #include <qlabel.h> | 26 | #include <qlabel.h> |
27 | #include <qframe.h> | 27 | #include <qframe.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #ifndef KORG_NOSPLITTER | 29 | #ifndef KORG_NOSPLITTER |
30 | #include <qsplitter.h> | 30 | #include <qsplitter.h> |
31 | #endif | 31 | #endif |
32 | #include <qfont.h> | 32 | #include <qfont.h> |
33 | #include <qfontmetrics.h> | 33 | #include <qfontmetrics.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <qtooltip.h> | 35 | #include <qtooltip.h> |
36 | #include <qpainter.h> | 36 | #include <qpainter.h> |
37 | #include <qpushbutton.h> | 37 | #include <qpushbutton.h> |
38 | #include <qapplication.h> | 38 | #include <qapplication.h> |
39 | 39 | ||
40 | #include <kapplication.h> | 40 | #include <kapplication.h> |
41 | #include <KDGanttMinimizeSplitter.h> | 41 | #include <KDGanttMinimizeSplitter.h> |
42 | #include <kdebug.h> | 42 | #include <kdebug.h> |
43 | #include <kstandarddirs.h> | 43 | #include <kstandarddirs.h> |
44 | #include <kiconloader.h> | 44 | #include <kiconloader.h> |
45 | #include <klocale.h> | 45 | #include <klocale.h> |
46 | #include <kconfig.h> | 46 | #include <kconfig.h> |
47 | #include <kglobal.h> | 47 | #include <kglobal.h> |
48 | #include "calendarview.h" | 48 | #include "calendarview.h" |
49 | #include "koviewmanager.h" | 49 | #include "koviewmanager.h" |
50 | 50 | ||
51 | #include <libkcal/calendar.h> | 51 | #include <libkcal/calendar.h> |
52 | #include <libkcal/icaldrag.h> | 52 | #include <libkcal/icaldrag.h> |
53 | #include <libkcal/dndfactory.h> | 53 | #include <libkcal/dndfactory.h> |
54 | 54 | ||
55 | #include <kcalendarsystem.h> | 55 | #include <kcalendarsystem.h> |
56 | 56 | ||
57 | #include "koglobals.h" | 57 | #include "koglobals.h" |
58 | #ifndef KORG_NOPLUGINS | 58 | #ifndef KORG_NOPLUGINS |
59 | #include "kocore.h" | 59 | #include "kocore.h" |
60 | #endif | 60 | #endif |
61 | #include "koprefs.h" | 61 | #include "koprefs.h" |
62 | #include "koagenda.h" | 62 | #include "koagenda.h" |
63 | #include "koagendaitem.h" | 63 | #include "koagendaitem.h" |
64 | #ifndef KORG_NOPRINTER | 64 | #ifndef KORG_NOPRINTER |
65 | #include "calprinter.h" | 65 | #include "calprinter.h" |
66 | #endif | 66 | #endif |
67 | 67 | ||
68 | #include "koagendaview.h" | 68 | #include "koagendaview.h" |
69 | //#include "koagendaview.moc" | 69 | //#include "koagendaview.moc" |
70 | 70 | ||
71 | //extern bool globalFlagBlockPainting; | 71 | //extern bool globalFlagBlockPainting; |
72 | extern int globalFlagBlockAgenda; | 72 | extern int globalFlagBlockAgenda; |
73 | extern int globalFlagBlockStartup; | 73 | extern int globalFlagBlockStartup; |
74 | extern int globalFlagBlockAgendaItemPaint; | 74 | extern int globalFlagBlockAgendaItemPaint; |
75 | extern int globalFlagBlockAgendaItemUpdate; | 75 | extern int globalFlagBlockAgendaItemUpdate; |
76 | extern int globalFlagBlockLabel; | 76 | extern int globalFlagBlockLabel; |
77 | using namespace KOrg; | 77 | using namespace KOrg; |
78 | 78 | ||
79 | 79 | ||
80 | 80 | ||
81 | TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : | 81 | TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : |
82 | QScrollView(parent,name,f) | 82 | QScrollView(parent,name,f) |
83 | { | 83 | { |
84 | myPix.resize( 1, 1 ); | 84 | myPix.resize( 1, 1 ); |
85 | mRows = rows; | 85 | mRows = rows; |
86 | 86 | ||
87 | mRedrawNeeded = true; | 87 | mRedrawNeeded = true; |
88 | setMinimumHeight( 20 ); | 88 | setMinimumHeight( 20 ); |
89 | mCellHeight = KOPrefs::instance()->mHourSize*4; | 89 | mCellHeight = KOPrefs::instance()->mHourSize*4; |
90 | 90 | ||
91 | enableClipper(true); | 91 | enableClipper(true); |
92 | 92 | ||
93 | setHScrollBarMode(AlwaysOff); | 93 | setHScrollBarMode(AlwaysOff); |
94 | setVScrollBarMode(AlwaysOff); | 94 | setVScrollBarMode(AlwaysOff); |
95 | 95 | ||
96 | resizeContents(50,mRows * mCellHeight); | 96 | resizeContents(50,mRows * mCellHeight); |
97 | 97 | ||
98 | viewport()->setBackgroundMode( PaletteBackground ); | 98 | viewport()->setBackgroundMode( PaletteBackground ); |
99 | } | 99 | } |
100 | 100 | ||
101 | void TimeLabels::setCellHeight(int height) | 101 | void TimeLabels::setCellHeight(int height) |
102 | { | 102 | { |
103 | mCellHeight = height; | 103 | mCellHeight = height; |
104 | } | 104 | } |
105 | 105 | ||
106 | /* | 106 | /* |
107 | Optimization so that only the "dirty" portion of the scroll view | 107 | Optimization so that only the "dirty" portion of the scroll view |
108 | is redrawn. Unfortunately, this is not called by default paintEvent() method. | 108 | is redrawn. Unfortunately, this is not called by default paintEvent() method. |
109 | */ | 109 | */ |
110 | void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) | 110 | void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) |
111 | { | 111 | { |
112 | 112 | ||
113 | // if ( globalFlagBlockAgenda ) | 113 | cx = contentsX() + frameWidth()*2; |
114 | // return; | 114 | cw = contentsWidth() ; |
115 | // bug: the parameters cx, cy, cw, ch are the areas that need to be | 115 | // end of workaround |
116 | // redrawn, not the area of the widget. unfortunately, this | 116 | |
117 | // code assumes the latter... | 117 | int cell = ((int)(cy/mCellHeight)); |
118 | 118 | int y = cell * mCellHeight; | |
119 | // now, for a workaround... | 119 | QFontMetrics fm = fontMetrics(); |
120 | // these two assignments fix the weird redraw bug | 120 | QString hour; |
121 | QString suffix = "am"; | ||
122 | int timeHeight = fm.ascent(); | ||
123 | QFont nFont = p->font(); | ||
124 | |||
125 | if (!KGlobal::locale()->use12Clock()) { | ||
126 | if ( QApplication::desktop()->width() <= 320 ) | ||
127 | suffix = "00"; | ||
128 | else | ||
129 | suffix = "00"; | ||
130 | } | ||
131 | |||
132 | if ( timeHeight > mCellHeight ) { | ||
133 | timeHeight = mCellHeight-1; | ||
134 | int pointS = nFont.pointSize(); | ||
135 | while ( pointS > 4 ) { | ||
136 | nFont.setPointSize( pointS ); | ||
137 | fm = QFontMetrics( nFont ); | ||
138 | if ( fm.ascent() < mCellHeight ) | ||
139 | break; | ||
140 | -- pointS; | ||
141 | } | ||
142 | fm = QFontMetrics( nFont ); | ||
143 | timeHeight = fm.ascent(); | ||
144 | } | ||
145 | //timeHeight -= (timeHeight/4-2); | ||
146 | QFont sFont = nFont; | ||
147 | sFont.setPointSize( sFont.pointSize()/2 ); | ||
148 | QFontMetrics fmS( sFont ); | ||
149 | int sHei = fmS.ascent() ; | ||
150 | //sHei -= (sHei/4-2); | ||
151 | int startW = this->width() - frameWidth()-2; | ||
152 | int tw2 = fmS.width(suffix); | ||
153 | timeHeight = (timeHeight-1) /2 -1; | ||
154 | while (y < cy + ch+mCellHeight) { | ||
155 | p->drawLine(startW-tw2+1 ,y,cw,y); | ||
156 | hour.setNum(cell); | ||
157 | // handle 24h and am/pm time formats | ||
158 | if (KGlobal::locale()->use12Clock()) { | ||
159 | if (cell > 11) suffix = "pm"; | ||
160 | else | ||
161 | suffix = "am"; | ||
162 | if (cell == 0) hour.setNum(12); | ||
163 | if (cell > 12) hour.setNum(cell - 12); | ||
164 | } | ||
165 | |||
166 | // center and draw the time label | ||
167 | int timeWidth = fm.width(hour); | ||
168 | int offset = startW - timeWidth - tw2 ; | ||
169 | p->setFont( nFont ); | ||
170 | p->drawText( offset, y+ timeHeight, hour); | ||
171 | p->setFont( sFont ); | ||
172 | offset = startW - tw2+1; | ||
173 | p->drawText( offset, y -1, suffix); | ||
174 | |||
175 | // increment indices | ||
176 | y += mCellHeight; | ||
177 | cell++; | ||
178 | } | ||
179 | |||
180 | |||
181 | |||
182 | |||
183 | #if 0 | ||
121 | mRedrawNeeded = true; | 184 | mRedrawNeeded = true; |
122 | if ( mRedrawNeeded ) { | 185 | if ( mRedrawNeeded ) { |
123 | cx = contentsX() + frameWidth()*2; | 186 | cx = contentsX() + frameWidth()*2; |
124 | cw = contentsWidth() ; | 187 | cw = contentsWidth() ; |
125 | // end of workaround | 188 | // end of workaround |
126 | 189 | ||
127 | int cell = ((int)(cy/mCellHeight)); | 190 | int cell = ((int)(cy/mCellHeight)); |
128 | int y = cell * mCellHeight; | 191 | int y = cell * mCellHeight; |
129 | QFontMetrics fm = fontMetrics(); | 192 | QFontMetrics fm = fontMetrics(); |
130 | QString hour; | 193 | QString hour; |
131 | QString suffix; | 194 | QString suffix; |
132 | int timeHeight = fm.ascent(); | 195 | int timeHeight = fm.ascent(); |
133 | QFont nFont = p->font(); | 196 | QFont nFont = p->font(); |
134 | 197 | ||
135 | if (!KGlobal::locale()->use12Clock()) { | 198 | if (!KGlobal::locale()->use12Clock()) { |
136 | if ( QApplication::desktop()->width() <= 320 ) | 199 | if ( QApplication::desktop()->width() <= 320 ) |
137 | suffix = ""; | 200 | suffix = ""; |
138 | else | 201 | else |
139 | suffix = "00"; | 202 | suffix = "00"; |
140 | } | 203 | } |
141 | 204 | ||
142 | if ( timeHeight > mCellHeight ) { | 205 | if ( timeHeight > mCellHeight ) { |
143 | timeHeight = mCellHeight-1; | 206 | timeHeight = mCellHeight-1; |
144 | int pointS = nFont.pointSize(); | 207 | int pointS = nFont.pointSize(); |
145 | while ( pointS > 4 ) { | 208 | while ( pointS > 4 ) { |
146 | nFont.setPointSize( pointS ); | 209 | nFont.setPointSize( pointS ); |
147 | fm = QFontMetrics( nFont ); | 210 | fm = QFontMetrics( nFont ); |
148 | if ( fm.ascent() < mCellHeight ) | 211 | if ( fm.ascent() < mCellHeight ) |
149 | break; | 212 | break; |
150 | -- pointS; | 213 | -- pointS; |
151 | } | 214 | } |
152 | fm = QFontMetrics( nFont ); | 215 | fm = QFontMetrics( nFont ); |
153 | timeHeight = fm.ascent(); | 216 | timeHeight = fm.ascent(); |
154 | } | 217 | } |
155 | //timeHeight -= (timeHeight/4-2); | 218 | //timeHeight -= (timeHeight/4-2); |
156 | QFont sFont = nFont; | 219 | QFont sFont = nFont; |
157 | sFont.setPointSize( sFont.pointSize()/2 ); | 220 | sFont.setPointSize( sFont.pointSize()/2 ); |
158 | QFontMetrics fmS( sFont ); | 221 | QFontMetrics fmS( sFont ); |
159 | int sHei = fmS.ascent() ; | 222 | int sHei = fmS.ascent() ; |
160 | //sHei -= (sHei/4-2); | 223 | //sHei -= (sHei/4-2); |
161 | int startW = this->width() - frameWidth()-2; | 224 | int startW = this->width() - frameWidth()-2; |
162 | int tw2 = fmS.width(suffix); | 225 | int tw2 = fmS.width(suffix); |
163 | while (y < cy + ch) { | 226 | while (y < cy + ch) { |
164 | p->drawLine(cx,y,cw,y); | 227 | p->drawLine(cx,y,cw,y); |
165 | hour.setNum(cell); | 228 | hour.setNum(cell); |
166 | // handle 24h and am/pm time formats | 229 | // handle 24h and am/pm time formats |
167 | if (KGlobal::locale()->use12Clock()) { | 230 | if (KGlobal::locale()->use12Clock()) { |
168 | if (cell > 11) suffix = "pm"; | 231 | if (cell > 11) suffix = "pm"; |
169 | else | 232 | else |
170 | suffix = "am"; | 233 | suffix = "am"; |
171 | if (cell == 0) hour.setNum(12); | 234 | if (cell == 0) hour.setNum(12); |
172 | if (cell > 12) hour.setNum(cell - 12); | 235 | if (cell > 12) hour.setNum(cell - 12); |
173 | tw2 = fmS.width(suffix); | 236 | tw2 = fmS.width(suffix); |
174 | } | 237 | } |
175 | 238 | ||
176 | // center and draw the time label | 239 | // center and draw the time label |
177 | int timeWidth = fm.width(hour); | 240 | int timeWidth = fm.width(hour); |
178 | int offset = startW - timeWidth - tw2 ; | 241 | int offset = startW - timeWidth - tw2 ; |
179 | p->setFont( nFont ); | 242 | p->setFont( nFont ); |
180 | p->drawText( offset, y+ timeHeight, hour); | 243 | p->drawText( offset, y+ timeHeight, hour); |
181 | p->setFont( sFont ); | 244 | p->setFont( sFont ); |
182 | offset = startW - tw2+1; | 245 | offset = startW - tw2+1; |
183 | p->drawText( offset, y+ sHei, suffix); | 246 | p->drawText( offset, y+ sHei, suffix); |
184 | 247 | ||
185 | // increment indices | 248 | // increment indices |
186 | y += mCellHeight; | 249 | y += mCellHeight; |
187 | cell++; | 250 | cell++; |
188 | } | 251 | } |
189 | } else { | 252 | } else { |
190 | //qDebug("NO redraw "); | 253 | //qDebug("NO redraw "); |
191 | } | 254 | } |
192 | // double buffer not yet implemented | 255 | // double buffer not yet implemented |
193 | //bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); | 256 | //bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); |
194 | //mRedrawNeeded = false; | 257 | //mRedrawNeeded = false; |
258 | #endif | ||
195 | } | 259 | } |
196 | 260 | ||
197 | /** | 261 | /** |
198 | Calculates the minimum width. | 262 | Calculates the minimum width. |
199 | */ | 263 | */ |
200 | int TimeLabels::minimumWidth() const | 264 | int TimeLabels::minimumWidth() const |
201 | { | 265 | { |
202 | return mMiniWidth; | 266 | return mMiniWidth; |
203 | } | 267 | } |
204 | 268 | ||
205 | /** updates widget's internal state */ | 269 | /** updates widget's internal state */ |
206 | void TimeLabels::updateConfig() | 270 | void TimeLabels::updateConfig() |
207 | { | 271 | { |
208 | mRedrawNeeded = true; | 272 | mRedrawNeeded = true; |
209 | // set the font | 273 | // set the font |
210 | // config->setGroup("Fonts"); | 274 | // config->setGroup("Fonts"); |
211 | // QFont font = config->readFontEntry("TimeBar Font"); | 275 | // QFont font = config->readFontEntry("TimeBar Font"); |
212 | setFont(KOPrefs::instance()->mTimeBarFont); | 276 | setFont(KOPrefs::instance()->mTimeBarFont); |
213 | QString test = "20"; | 277 | QString test = "20"; |
214 | if (KGlobal::locale()->use12Clock()) | 278 | if (KGlobal::locale()->use12Clock()) |
215 | test = "12"; | 279 | test = "12"; |
216 | mMiniWidth = fontMetrics().width(test); | 280 | mMiniWidth = fontMetrics().width(test); |
217 | if (KGlobal::locale()->use12Clock()) | 281 | if (KGlobal::locale()->use12Clock()) |
218 | test = "pm"; | 282 | test = "pm"; |
219 | else { | 283 | else { |
220 | if ( QApplication::desktop()->width() <= 320 ) | 284 | if ( QApplication::desktop()->width() <= 320 ) |
221 | test = ""; | 285 | test = "00"; |
222 | else | 286 | else |
223 | test = "00"; | 287 | test = "00"; |
224 | } | 288 | } |
225 | QFont sFont = font(); | 289 | QFont sFont = font(); |
226 | sFont.setPointSize( sFont.pointSize()/2 ); | 290 | sFont.setPointSize( sFont.pointSize()/2 ); |
227 | QFontMetrics fmS( sFont ); | 291 | QFontMetrics fmS( sFont ); |
228 | mMiniWidth += fmS.width( test ) + frameWidth()*2 +4 ; | 292 | mMiniWidth += fmS.width( test ) + frameWidth()*2 +4 ; |
229 | // update geometry restrictions based on new settings | 293 | // update geometry restrictions based on new settings |
230 | setFixedWidth( mMiniWidth ); | 294 | setFixedWidth( mMiniWidth ); |
231 | 295 | ||
232 | // update HourSize | 296 | // update HourSize |
233 | mCellHeight = KOPrefs::instance()->mHourSize*4; | 297 | mCellHeight = KOPrefs::instance()->mHourSize*4; |
234 | resizeContents(50,mRows * mCellHeight); | 298 | resizeContents(50,mRows * mCellHeight); |
235 | } | 299 | } |
236 | 300 | ||
237 | /** update time label positions */ | 301 | /** update time label positions */ |
238 | void TimeLabels::positionChanged() | 302 | void TimeLabels::positionChanged() |
239 | { | 303 | { |
240 | int adjustment = mAgenda->contentsY(); | 304 | int adjustment = mAgenda->contentsY(); |
241 | setContentsPos(0, adjustment); | 305 | setContentsPos(0, adjustment); |
242 | } | 306 | } |
243 | 307 | ||
244 | /** */ | 308 | /** */ |
245 | void TimeLabels::setAgenda(KOAgenda* agenda) | 309 | void TimeLabels::setAgenda(KOAgenda* agenda) |
246 | { | 310 | { |
247 | mAgenda = agenda; | 311 | mAgenda = agenda; |
248 | } | 312 | } |
249 | 313 | ||
250 | void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) | 314 | void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) |
251 | { | 315 | { |
252 | mMouseDownY = e->pos().y(); | 316 | mMouseDownY = e->pos().y(); |
253 | mOrgCap = topLevelWidget()->caption(); | 317 | mOrgCap = topLevelWidget()->caption(); |
254 | } | 318 | } |
255 | 319 | ||
256 | void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) | 320 | void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) |
257 | { | 321 | { |
258 | int diff = mMouseDownY - e->pos().y(); | 322 | int diff = mMouseDownY - e->pos().y(); |
259 | if ( diff < 10 && diff > -10 ) | 323 | if ( diff < 10 && diff > -10 ) |
260 | return; | 324 | return; |
261 | int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; | 325 | int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; |
262 | if ( tSize < 4 ) | 326 | if ( tSize < 4 ) |
263 | tSize = 4; | 327 | tSize = 4; |
264 | if ( tSize > 22 ) | 328 | if ( tSize > 22 ) |
265 | tSize = 22; | 329 | tSize = 22; |
266 | tSize = (tSize-2)/2; | 330 | tSize = (tSize-2)/2; |
267 | topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); | 331 | topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); |
268 | 332 | ||
269 | } | 333 | } |
270 | void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) | 334 | void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) |
271 | { | 335 | { |
272 | topLevelWidget()->setCaption( mOrgCap ); | 336 | topLevelWidget()->setCaption( mOrgCap ); |
273 | int diff = mMouseDownY - e->pos().y(); | 337 | int diff = mMouseDownY - e->pos().y(); |
274 | if ( diff < 10 && diff > -10 ) | 338 | if ( diff < 10 && diff > -10 ) |
275 | return; | 339 | return; |
276 | int tSize = KOPrefs::instance()->mHourSize + (diff/10); | 340 | int tSize = KOPrefs::instance()->mHourSize + (diff/10); |
277 | if ( tSize < 4 ) | 341 | if ( tSize < 4 ) |
278 | tSize = 4; | 342 | tSize = 4; |
279 | if ( tSize > 22 ) | 343 | if ( tSize > 22 ) |
280 | tSize = 22; | 344 | tSize = 22; |
281 | tSize = (tSize/2)*2; | 345 | tSize = (tSize/2)*2; |
282 | if ( tSize == KOPrefs::instance()->mHourSize ) | 346 | if ( tSize == KOPrefs::instance()->mHourSize ) |
283 | return; | 347 | return; |
284 | KOPrefs::instance()->mHourSize = tSize; | 348 | KOPrefs::instance()->mHourSize = tSize; |
285 | emit scaleChanged(); | 349 | emit scaleChanged(); |
286 | } | 350 | } |
287 | 351 | ||
288 | /** This is called in response to repaint() */ | 352 | /** This is called in response to repaint() */ |
289 | void TimeLabels::paintEvent(QPaintEvent*) | 353 | void TimeLabels::paintEvent(QPaintEvent*) |
290 | { | 354 | { |
291 | 355 | ||
292 | // kdDebug() << "paintevent..." << endl; | 356 | // kdDebug() << "paintevent..." << endl; |
293 | // this is another hack! | 357 | // this is another hack! |
294 | // QPainter painter(this); | 358 | // QPainter painter(this); |
295 | //QString c | 359 | //QString c |
296 | repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); | 360 | repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); |
297 | } | 361 | } |
298 | 362 | ||
299 | //////////////////////////////////////////////////////////////////////////// | 363 | //////////////////////////////////////////////////////////////////////////// |
300 | 364 | ||
301 | EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) | 365 | EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) |
302 | : QFrame(parent,name) | 366 | : QFrame(parent,name) |
303 | { | 367 | { |
304 | mColumns = 1; | 368 | mColumns = 1; |
305 | mTopBox = 0; | 369 | mTopBox = 0; |
306 | mLocation = loc; | 370 | mLocation = loc; |
307 | mTopLayout = 0; | 371 | mTopLayout = 0; |
308 | mPaintWidget = 0; | 372 | mPaintWidget = 0; |
309 | mXOffset = 0; | 373 | mXOffset = 0; |
310 | if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); | 374 | if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); |
311 | else mPixmap = SmallIcon("1downarrow"); | 375 | else mPixmap = SmallIcon("1downarrow"); |
312 | mEnabled.resize(mColumns); | 376 | mEnabled.resize(mColumns); |
313 | mEnabled.fill( false ); | 377 | mEnabled.fill( false ); |
314 | setMinimumHeight(mPixmap.height()); | 378 | setMinimumHeight(mPixmap.height()); |
315 | } | 379 | } |
316 | 380 | ||
317 | EventIndicator::~EventIndicator() | 381 | EventIndicator::~EventIndicator() |
318 | { | 382 | { |
319 | } | 383 | } |
320 | 384 | ||
321 | void EventIndicator::drawContents(QPainter *p) | 385 | void EventIndicator::drawContents(QPainter *p) |
322 | { | 386 | { |
323 | 387 | ||
324 | // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; | 388 | // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; |
325 | KDGanttSplitterHandle* han = 0; | 389 | KDGanttSplitterHandle* han = 0; |
326 | if ( mPaintWidget ) | 390 | if ( mPaintWidget ) |
327 | han = mPaintWidget->firstHandle(); | 391 | han = mPaintWidget->firstHandle(); |
328 | if ( ! han ) { | 392 | if ( ! han ) { |
329 | int i; | 393 | int i; |
330 | for(i=0;i<mColumns;++i) { | 394 | for(i=0;i<mColumns;++i) { |
331 | if (mEnabled[i]) { | 395 | if (mEnabled[i]) { |
332 | int cellWidth = contentsRect().right()/mColumns; | 396 | int cellWidth = contentsRect().right()/mColumns; |
333 | int xOffset = KOGlobals::self()->reverseLayout() ? | 397 | int xOffset = KOGlobals::self()->reverseLayout() ? |
334 | (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 : | 398 | (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 : |
335 | i*cellWidth + (cellWidth -mPixmap.width()) /2; | 399 | i*cellWidth + (cellWidth -mPixmap.width()) /2; |
336 | p->drawPixmap(QPoint(1+xOffset,0),mPixmap); | 400 | p->drawPixmap(QPoint(1+xOffset,0),mPixmap); |
337 | } | 401 | } |
338 | } | 402 | } |
339 | } else { | 403 | } else { |
340 | han->repaint(); | 404 | han->repaint(); |
341 | //mPaintWidget->setBackgroundColor( red ); | 405 | //mPaintWidget->setBackgroundColor( red ); |
342 | 406 | ||
343 | QPainter pa( han ); | 407 | QPainter pa( han ); |
344 | int i; | 408 | int i; |
345 | bool setColor = false; | 409 | bool setColor = false; |
346 | for(i=0;i<mColumns;++i) { | 410 | for(i=0;i<mColumns;++i) { |
347 | if (mEnabled[i]) { | 411 | if (mEnabled[i]) { |
348 | setColor = true; | 412 | setColor = true; |
349 | 413 | ||
350 | int cellWidth = contentsRect().right()/mColumns; | 414 | int cellWidth = contentsRect().right()/mColumns; |
351 | int xOffset = KOGlobals::self()->reverseLayout() ? | 415 | int xOffset = KOGlobals::self()->reverseLayout() ? |
352 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : | 416 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : |
353 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; | 417 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; |
354 | pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); | 418 | pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); |
355 | //qDebug("222draw pix %d ",xOffset ); | 419 | //qDebug("222draw pix %d ",xOffset ); |
356 | 420 | ||
357 | } | 421 | } |
358 | 422 | ||
359 | } | 423 | } |
360 | pa.end(); | 424 | pa.end(); |
361 | 425 | ||
362 | } | 426 | } |
363 | } | 427 | } |
364 | 428 | ||
365 | void EventIndicator::setXOffset( int x ) | 429 | void EventIndicator::setXOffset( int x ) |
366 | { | 430 | { |
367 | mXOffset = x; | 431 | mXOffset = x; |
368 | } | 432 | } |
369 | void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) | 433 | void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) |
370 | { | 434 | { |
371 | mPaintWidget = w; | 435 | mPaintWidget = w; |
372 | setMaximumHeight(0); | 436 | setMaximumHeight(0); |
373 | setMinimumHeight(0); | 437 | setMinimumHeight(0); |
374 | } | 438 | } |
375 | void EventIndicator::changeColumns(int columns) | 439 | void EventIndicator::changeColumns(int columns) |
376 | { | 440 | { |
377 | mColumns = columns; | 441 | mColumns = columns; |
378 | mEnabled.resize(mColumns); | 442 | mEnabled.resize(mColumns); |
379 | 443 | ||
380 | update(); | 444 | update(); |
381 | } | 445 | } |
382 | 446 | ||
383 | void EventIndicator::enableColumn(int column, bool enable) | 447 | void EventIndicator::enableColumn(int column, bool enable) |
384 | { | 448 | { |
385 | mEnabled[column] = enable; | 449 | mEnabled[column] = enable; |
386 | } | 450 | } |
387 | 451 | ||
388 | 452 | ||
389 | //////////////////////////////////////////////////////////////////////////// | 453 | //////////////////////////////////////////////////////////////////////////// |
390 | //////////////////////////////////////////////////////////////////////////// | 454 | //////////////////////////////////////////////////////////////////////////// |
391 | //////////////////////////////////////////////////////////////////////////// | 455 | //////////////////////////////////////////////////////////////////////////// |
392 | 456 | ||
393 | KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : | 457 | KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : |
394 | KOEventView (cal,parent,name) | 458 | KOEventView (cal,parent,name) |
395 | { | 459 | { |
396 | mBlockUpdating = true; | 460 | mBlockUpdating = true; |
397 | mStartHour = 8; | 461 | mStartHour = 8; |
398 | mSelectedDates.append(QDate::currentDate()); | 462 | mSelectedDates.append(QDate::currentDate()); |
399 | 463 | ||
400 | mLayoutDayLabels = 0; | 464 | mLayoutDayLabels = 0; |
401 | mDayLabelsFrame = 0; | 465 | mDayLabelsFrame = 0; |
402 | mDayLabels = 0; | 466 | mDayLabels = 0; |
403 | bool isRTL = KOGlobals::self()->reverseLayout(); | 467 | bool isRTL = KOGlobals::self()->reverseLayout(); |
404 | QPixmap expandPix; | 468 | QPixmap expandPix; |
405 | if ( KOPrefs::instance()->mVerticalScreen ) { | 469 | if ( KOPrefs::instance()->mVerticalScreen ) { |
406 | expandPix = SmallIcon( "1updownarrow" ); | 470 | expandPix = SmallIcon( "1updownarrow" ); |
407 | } else { | 471 | } else { |
408 | expandPix = SmallIcon("1leftrightarrow" ); | 472 | expandPix = SmallIcon("1leftrightarrow" ); |
409 | } | 473 | } |
410 | 474 | ||
411 | QBoxLayout *topLayout = new QVBoxLayout(this); | 475 | QBoxLayout *topLayout = new QVBoxLayout(this); |
412 | 476 | ||
413 | // Create day name labels for agenda columns | 477 | // Create day name labels for agenda columns |
414 | // Create agenda splitter | 478 | // Create agenda splitter |
415 | 479 | ||
416 | mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 480 | mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
417 | mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 481 | mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
418 | topLayout->addWidget( mSplitterAgenda ); | 482 | topLayout->addWidget( mSplitterAgenda ); |
419 | mAllDayFrame = new QHBox(mSplitterAgenda); | 483 | mAllDayFrame = new QHBox(mSplitterAgenda); |
420 | mAllDayFrame->setFocusPolicy(NoFocus); | 484 | mAllDayFrame->setFocusPolicy(NoFocus); |
421 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); | 485 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); |
422 | agendaFrame->setFocusPolicy(NoFocus); | 486 | agendaFrame->setFocusPolicy(NoFocus); |
423 | 487 | ||
424 | // Create all-day agenda widget | 488 | // Create all-day agenda widget |
425 | mDummyAllDayLeft = new QVBox( mAllDayFrame ); | 489 | mDummyAllDayLeft = new QVBox( mAllDayFrame ); |
426 | 490 | ||
427 | mExpandButton = new QPushButton(mDummyAllDayLeft); | 491 | mExpandButton = new QPushButton(mDummyAllDayLeft); |
428 | mExpandButton->setPixmap( expandPix ); | 492 | mExpandButton->setPixmap( expandPix ); |
429 | int widebut = mExpandButton->sizeHint().width()+4; | 493 | int widebut = mExpandButton->sizeHint().width()+4; |
430 | int heibut = mExpandButton->sizeHint().height()+4; | 494 | int heibut = mExpandButton->sizeHint().height()+4; |
431 | if ( heibut > widebut ) | 495 | if ( heibut > widebut ) |
432 | widebut = heibut ; | 496 | widebut = heibut ; |
433 | 497 | ||
434 | //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, | 498 | //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, |
435 | // QSizePolicy::Fixed ) ); | 499 | // QSizePolicy::Fixed ) ); |
436 | mExpandButton->setFixedSize( widebut, widebut); | 500 | mExpandButton->setFixedSize( widebut, widebut); |
437 | connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); | 501 | connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); |
438 | mExpandButton->setFocusPolicy(NoFocus); | 502 | mExpandButton->setFocusPolicy(NoFocus); |
439 | mAllDayAgenda = new KOAgenda(1,mAllDayFrame); | 503 | mAllDayAgenda = new KOAgenda(1,mAllDayFrame); |
440 | mAllDayAgenda->setFocusPolicy(NoFocus); | 504 | mAllDayAgenda->setFocusPolicy(NoFocus); |
441 | QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); | 505 | QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); |
442 | 506 | ||
443 | // Create event context menu for all day agenda | 507 | // Create event context menu for all day agenda |
444 | mAllDayAgendaPopup = eventPopup(); | 508 | mAllDayAgendaPopup = eventPopup(); |
445 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 509 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
446 | mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 510 | mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
447 | 511 | ||
448 | // Create agenda frame | 512 | // Create agenda frame |
449 | QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); | 513 | QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); |
450 | // QHBox *agendaFrame = new QHBox(splitterAgenda); | 514 | // QHBox *agendaFrame = new QHBox(splitterAgenda); |
451 | 515 | ||
452 | // create event indicator bars | 516 | // create event indicator bars |
453 | mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); | 517 | mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); |
454 | #ifndef DESKTOP_VERSION | 518 | #ifndef DESKTOP_VERSION |
455 | // FIX | 519 | // FIX |
456 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); | 520 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); |
457 | #endif | 521 | #endif |
458 | mDayLabelsFrame = new QHBox(agendaFrame); | 522 | mDayLabelsFrame = new QHBox(agendaFrame); |
459 | //topLayout->addWidget(mDayLabelsFrame); | 523 | //topLayout->addWidget(mDayLabelsFrame); |
460 | mDayLabels = new QFrame (mDayLabelsFrame); | 524 | mDayLabels = new QFrame (mDayLabelsFrame); |
461 | mLayoutDayLabels = new QHBoxLayout(mDayLabels); | 525 | mLayoutDayLabels = new QHBoxLayout(mDayLabels); |
462 | agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); | 526 | agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); |
463 | agendaLayout->addWidget(mEventIndicatorTop,1,1); | 527 | agendaLayout->addWidget(mEventIndicatorTop,1,1); |
464 | 528 | ||
465 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, | 529 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, |
466 | agendaFrame); | 530 | agendaFrame); |
467 | agendaLayout->addWidget(mEventIndicatorBottom,3,1); | 531 | agendaLayout->addWidget(mEventIndicatorBottom,3,1); |
468 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); | 532 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); |
469 | agendaLayout->addWidget(dummyAgendaRight,1,2); | 533 | agendaLayout->addWidget(dummyAgendaRight,1,2); |
470 | 534 | ||
471 | // Create time labels | 535 | // Create time labels |
472 | mTimeLabels = new TimeLabels(24,agendaFrame); | 536 | mTimeLabels = new TimeLabels(24,agendaFrame); |
473 | agendaLayout->addWidget(mTimeLabels,2,0); | 537 | agendaLayout->addWidget(mTimeLabels,2,0); |
474 | connect(mTimeLabels,SIGNAL( scaleChanged()), | 538 | connect(mTimeLabels,SIGNAL( scaleChanged()), |
475 | this,SLOT(updateConfig())); | 539 | this,SLOT(updateConfig())); |
476 | 540 | ||
477 | // Create agenda | 541 | // Create agenda |
478 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); | 542 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); |
479 | agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); | 543 | agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); |
480 | agendaLayout->setColStretch(1,1); | 544 | agendaLayout->setColStretch(1,1); |
481 | mAgenda->setFocusPolicy(NoFocus); | 545 | mAgenda->setFocusPolicy(NoFocus); |
482 | // Create event context menu for agenda | 546 | // Create event context menu for agenda |
483 | mAgendaPopup = eventPopup(); | 547 | mAgendaPopup = eventPopup(); |
484 | 548 | ||
485 | mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), | 549 | mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), |
486 | i18n("Toggle Alarm"),mAgenda, | 550 | i18n("Toggle Alarm"),mAgenda, |
487 | SLOT(popupAlarm()),true); | 551 | SLOT(popupAlarm()),true); |
488 | 552 | ||
489 | 553 | ||
490 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 554 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
491 | mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 555 | mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
492 | 556 | ||
493 | // make connections between dependent widgets | 557 | // make connections between dependent widgets |
494 | mTimeLabels->setAgenda(mAgenda); | 558 | mTimeLabels->setAgenda(mAgenda); |
495 | 559 | ||
496 | // Update widgets to reflect user preferences | 560 | // Update widgets to reflect user preferences |
497 | // updateConfig(); | 561 | // updateConfig(); |
498 | 562 | ||
499 | // createDayLabels(); | 563 | // createDayLabels(); |
500 | 564 | ||
501 | // these blank widgets make the All Day Event box line up with the agenda | 565 | // these blank widgets make the All Day Event box line up with the agenda |
502 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 566 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
503 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 567 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
504 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 568 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
505 | 569 | ||
506 | // Scrolling | 570 | // Scrolling |
507 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), | 571 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), |
508 | mTimeLabels, SLOT(positionChanged())); | 572 | mTimeLabels, SLOT(positionChanged())); |
509 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), | 573 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), |
510 | SLOT(setContentsPos(int))); | 574 | SLOT(setContentsPos(int))); |
511 | 575 | ||
512 | connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); | 576 | connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); |
513 | connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); | 577 | connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); |
514 | 578 | ||
515 | // Create/Show/Edit/Delete Event | 579 | // Create/Show/Edit/Delete Event |
516 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), | 580 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), |
517 | SLOT(newEvent(int,int))); | 581 | SLOT(newEvent(int,int))); |
518 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), | 582 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), |
519 | SLOT(newTodo(int,int))); | 583 | SLOT(newTodo(int,int))); |
520 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 584 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
521 | SLOT(newEvent(int,int,int,int))); | 585 | SLOT(newEvent(int,int,int,int))); |
522 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), | 586 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), |
523 | SLOT(newEventAllDay(int,int))); | 587 | SLOT(newEventAllDay(int,int))); |
524 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), | 588 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), |
525 | SLOT(newTodoAllDay(int,int))); | 589 | SLOT(newTodoAllDay(int,int))); |
526 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 590 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
527 | SLOT(newEventAllDay(int,int))); | 591 | SLOT(newEventAllDay(int,int))); |
528 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 592 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
529 | SLOT(newTimeSpanSelected(int,int,int,int))); | 593 | SLOT(newTimeSpanSelected(int,int,int,int))); |
530 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 594 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
531 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); | 595 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); |
532 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 596 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
533 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 597 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
534 | 598 | ||
535 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 599 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
536 | SIGNAL(editIncidenceSignal(Incidence *))); | 600 | SIGNAL(editIncidenceSignal(Incidence *))); |
537 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 601 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
538 | SIGNAL(editIncidenceSignal(Incidence *))); | 602 | SIGNAL(editIncidenceSignal(Incidence *))); |
539 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 603 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
540 | SIGNAL(showIncidenceSignal(Incidence *))); | 604 | SIGNAL(showIncidenceSignal(Incidence *))); |
541 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 605 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
542 | SIGNAL(showIncidenceSignal(Incidence *))); | 606 | SIGNAL(showIncidenceSignal(Incidence *))); |
543 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 607 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
544 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 608 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
545 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 609 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
546 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 610 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
547 | 611 | ||
548 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 612 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
549 | SLOT(updateEventDates(KOAgendaItem *, int ))); | 613 | SLOT(updateEventDates(KOAgendaItem *, int ))); |
550 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 614 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
551 | SLOT(updateEventDates(KOAgendaItem *, int))); | 615 | SLOT(updateEventDates(KOAgendaItem *, int))); |
552 | 616 | ||
553 | // event indicator update | 617 | // event indicator update |
554 | connect(mAgenda,SIGNAL(lowerYChanged(int)), | 618 | connect(mAgenda,SIGNAL(lowerYChanged(int)), |
555 | SLOT(updateEventIndicatorTop(int))); | 619 | SLOT(updateEventIndicatorTop(int))); |
556 | connect(mAgenda,SIGNAL(upperYChanged(int)), | 620 | connect(mAgenda,SIGNAL(upperYChanged(int)), |
557 | SLOT(updateEventIndicatorBottom(int))); | 621 | SLOT(updateEventIndicatorBottom(int))); |
558 | // drag signals | 622 | // drag signals |
559 | /* | 623 | /* |
560 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), | 624 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), |
561 | SLOT(startDrag(Event *))); | 625 | SLOT(startDrag(Event *))); |
562 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), | 626 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), |
563 | SLOT(startDrag(Event *))); | 627 | SLOT(startDrag(Event *))); |
564 | */ | 628 | */ |
565 | // synchronize selections | 629 | // synchronize selections |
566 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 630 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
567 | mAllDayAgenda, SLOT( deselectItem() ) ); | 631 | mAllDayAgenda, SLOT( deselectItem() ) ); |
568 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 632 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
569 | mAgenda, SLOT( deselectItem() ) ); | 633 | mAgenda, SLOT( deselectItem() ) ); |
570 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 634 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
571 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 635 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
572 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 636 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
573 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 637 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
574 | connect( mAgenda, SIGNAL( resizedSignal() ), | 638 | connect( mAgenda, SIGNAL( resizedSignal() ), |
575 | SLOT( updateConfig( ) ) ); | 639 | SLOT( updateConfig( ) ) ); |
576 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), | 640 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), |
577 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); | 641 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); |
578 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), | 642 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), |
579 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); | 643 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); |
580 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 644 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
581 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 645 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
582 | 646 | ||
583 | 647 | ||
584 | } | 648 | } |
585 | 649 | ||
586 | void KOAgendaView::toggleAllDay() | 650 | void KOAgendaView::toggleAllDay() |
587 | { | 651 | { |
588 | if ( mSplitterAgenda->firstHandle() ) | 652 | if ( mSplitterAgenda->firstHandle() ) |
589 | mSplitterAgenda->firstHandle()->toggle(); | 653 | mSplitterAgenda->firstHandle()->toggle(); |
590 | } | 654 | } |
591 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) | 655 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) |
592 | { | 656 | { |
593 | calendar()->addIncidence( inc ); | 657 | calendar()->addIncidence( inc ); |
594 | 658 | ||
595 | if ( incOld ) { | 659 | if ( incOld ) { |
596 | if ( incOld->type() == "Todo" ) | 660 | if ( incOld->type() == "Todo" ) |
597 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); | 661 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); |
598 | else | 662 | else |
599 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); | 663 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); |
600 | } | 664 | } |
601 | 665 | ||
602 | } | 666 | } |
603 | 667 | ||
604 | KOAgendaView::~KOAgendaView() | 668 | KOAgendaView::~KOAgendaView() |
605 | { | 669 | { |
606 | delete mAgendaPopup; | 670 | delete mAgendaPopup; |
607 | delete mAllDayAgendaPopup; | 671 | delete mAllDayAgendaPopup; |
608 | delete KOAgendaItem::paintPix(); | 672 | delete KOAgendaItem::paintPix(); |
609 | delete KOAgendaItem::paintPixSel(); | 673 | delete KOAgendaItem::paintPixSel(); |
610 | } | 674 | } |
611 | void KOAgendaView::resizeEvent( QResizeEvent* e ) | 675 | void KOAgendaView::resizeEvent( QResizeEvent* e ) |
612 | { | 676 | { |
613 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); | 677 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); |
614 | bool uc = false; | 678 | bool uc = false; |
615 | int ow = e->oldSize().width(); | 679 | int ow = e->oldSize().width(); |
616 | int oh = e->oldSize().height(); | 680 | int oh = e->oldSize().height(); |
617 | int w = e->size().width(); | 681 | int w = e->size().width(); |
618 | int h = e->size().height(); | 682 | int h = e->size().height(); |
619 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { | 683 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { |
620 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) | 684 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) |
621 | uc = true; | 685 | uc = true; |
622 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); | 686 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); |
623 | } | 687 | } |
624 | mUpcomingWidth = e->size().width() ; | 688 | mUpcomingWidth = e->size().width() ; |
625 | if ( mBlockUpdating || uc ) { | 689 | if ( mBlockUpdating || uc ) { |
626 | mBlockUpdating = false; | 690 | mBlockUpdating = false; |
627 | //mAgenda->setMinimumSize(800 , 600 ); | 691 | //mAgenda->setMinimumSize(800 , 600 ); |
628 | //qDebug("mAgenda->resize+++++++++++++++ "); | 692 | //qDebug("mAgenda->resize+++++++++++++++ "); |
629 | updateConfig(); | 693 | updateConfig(); |
630 | //qDebug("KOAgendaView::Updating now possible "); | 694 | //qDebug("KOAgendaView::Updating now possible "); |
631 | } else | 695 | } else |
632 | createDayLabels(); | 696 | createDayLabels(); |
633 | //qDebug("resizeEvent end "); | 697 | //qDebug("resizeEvent end "); |
634 | 698 | ||
635 | } | 699 | } |
636 | void KOAgendaView::slotDaylabelClicked( int num ) | 700 | void KOAgendaView::slotDaylabelClicked( int num ) |
637 | { | 701 | { |
638 | 702 | ||
639 | QDate firstDate = mSelectedDates.first(); | 703 | QDate firstDate = mSelectedDates.first(); |
640 | if ( num == -1 ) | 704 | if ( num == -1 ) |
641 | emit showDateView( 6, firstDate ); | 705 | emit showDateView( 6, firstDate ); |
642 | else if (num >= 0 ) { | 706 | else if (num >= 0 ) { |
643 | if ( mSelectedDates.count() == 1) | 707 | if ( mSelectedDates.count() == 1) |
644 | emit showDateView( 9, firstDate.addDays( num ) ); | 708 | emit showDateView( 9, firstDate.addDays( num ) ); |
645 | else | 709 | else |
646 | emit showDateView( 3, firstDate.addDays( num ) ); | 710 | emit showDateView( 3, firstDate.addDays( num ) ); |
647 | } | 711 | } |
648 | else | 712 | else |
649 | showDateView( 10, firstDate.addDays(1) ); | 713 | showDateView( 10, firstDate.addDays(1) ); |
650 | } | 714 | } |
651 | 715 | ||
652 | KOAgendaButton* KOAgendaView::getNewDaylabel() | 716 | KOAgendaButton* KOAgendaView::getNewDaylabel() |
653 | { | 717 | { |
654 | 718 | ||
655 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); | 719 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); |
656 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); | 720 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); |
657 | mDayLabelsList.append( dayLabel ); | 721 | mDayLabelsList.append( dayLabel ); |
658 | mLayoutDayLabels->addWidget(dayLabel); | 722 | mLayoutDayLabels->addWidget(dayLabel); |
659 | return dayLabel ; | 723 | return dayLabel ; |
660 | } | 724 | } |
661 | 725 | ||
662 | void KOAgendaView::createDayLabels() | 726 | void KOAgendaView::createDayLabels() |
663 | { | 727 | { |
664 | 728 | ||
665 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { | 729 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { |
666 | // qDebug(" KOAgendaView::createDayLabels() blocked "); | 730 | // qDebug(" KOAgendaView::createDayLabels() blocked "); |
667 | return; | 731 | return; |
668 | 732 | ||
669 | } | 733 | } |
670 | int newHight; | 734 | int newHight; |
671 | 735 | ||
672 | // ### Before deleting and recreating we could check if mSelectedDates changed... | 736 | // ### Before deleting and recreating we could check if mSelectedDates changed... |
673 | // It would remove some flickering and gain speed (since this is called by | 737 | // It would remove some flickering and gain speed (since this is called by |
674 | // each updateView() call) | 738 | // each updateView() call) |
675 | 739 | ||
676 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; | 740 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; |
741 | if ( QApplication::desktop()->width() <= 320 ) | ||
742 | maxWid -= 10; | ||
677 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); | 743 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); |
678 | if ( maxWid < 0 ) | 744 | if ( maxWid < 0 ) |
679 | maxWid = 20; | 745 | maxWid = 20; |
680 | 746 | ||
681 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; | 747 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; |
682 | QFontMetrics fm ( dlf ); | 748 | QFontMetrics fm ( dlf ); |
683 | int selCount = mSelectedDates.count(); | 749 | int selCount = mSelectedDates.count(); |
684 | QString dayTest = "Mon 20"; | 750 | QString dayTest = "Mon 20"; |
685 | //QString dayTest = "Mon 20"; | 751 | //QString dayTest = "Mon 20"; |
686 | int wid = fm.width( dayTest ); | 752 | int wid = fm.width( dayTest ); |
687 | //maxWid -= ( selCount * 3 ); //working for QLabels | 753 | //maxWid -= ( selCount * 3 ); //working for QLabels |
688 | maxWid -= ( selCount * 3 ); //working for QPushButton | 754 | maxWid -= ( selCount * 3 ); //working for QPushButton |
689 | if ( maxWid < 0 ) | 755 | if ( maxWid < 0 ) |
690 | maxWid = 20; | 756 | maxWid = 20; |
691 | int needWid = wid * selCount; | 757 | int needWid = wid * selCount; |
692 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); | 758 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); |
693 | //if ( needWid > maxWid ) | 759 | //if ( needWid > maxWid ) |
694 | // qDebug("DAYLABELS TOOOOOOO BIG "); | 760 | // qDebug("DAYLABELS TOOOOOOO BIG "); |
695 | while ( needWid > maxWid ) { | 761 | while ( needWid > maxWid ) { |
696 | dayTest = dayTest.left( dayTest.length() - 1 ); | 762 | dayTest = dayTest.left( dayTest.length() - 1 ); |
697 | wid = fm.width( dayTest ); | 763 | wid = fm.width( dayTest ); |
698 | needWid = wid * selCount; | 764 | needWid = wid * selCount; |
699 | } | 765 | } |
700 | int maxLen = dayTest.length(); | 766 | int maxLen = dayTest.length(); |
701 | int fontPoint = dlf.pointSize(); | 767 | int fontPoint = dlf.pointSize(); |
702 | if ( maxLen < 2 ) { | 768 | if ( maxLen < 2 ) { |
703 | int fontPoint = dlf.pointSize(); | 769 | int fontPoint = dlf.pointSize(); |
704 | while ( fontPoint > 4 ) { | 770 | while ( fontPoint > 4 ) { |
705 | --fontPoint; | 771 | --fontPoint; |
706 | dlf.setPointSize( fontPoint ); | 772 | dlf.setPointSize( fontPoint ); |
707 | QFontMetrics f( dlf ); | 773 | QFontMetrics f( dlf ); |
708 | wid = f.width( "30" ); | 774 | wid = f.width( "30" ); |
709 | needWid = wid * selCount; | 775 | needWid = wid * selCount; |
710 | if ( needWid < maxWid ) | 776 | if ( needWid < maxWid ) |
711 | break; | 777 | break; |
712 | } | 778 | } |
713 | maxLen = 2; | 779 | maxLen = 2; |
714 | } | 780 | } |
715 | //qDebug("Max len %d ", dayTest.length() ); | 781 | //qDebug("Max len %d ", dayTest.length() ); |
716 | 782 | ||
717 | QFontMetrics tempF( dlf ); | 783 | QFontMetrics tempF( dlf ); |
718 | newHight = tempF.height(); | 784 | newHight = tempF.height(); |
719 | mDayLabels->setFont( dlf ); | 785 | mDayLabels->setFont( dlf ); |
720 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; | 786 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; |
721 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); | 787 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); |
722 | //mLayoutDayLabels->addSpacing( 2 ); | 788 | //mLayoutDayLabels->addSpacing( 2 ); |
723 | // QFont lFont = dlf; | 789 | // QFont lFont = dlf; |
724 | bool appendLabels = false; | 790 | bool appendLabels = false; |
725 | KOAgendaButton *dayLabel; | 791 | KOAgendaButton *dayLabel; |
726 | dayLabel = mDayLabelsList.first(); | 792 | dayLabel = mDayLabelsList.first(); |
727 | if ( !dayLabel ) { | 793 | if ( !dayLabel ) { |
728 | appendLabels = true; | 794 | appendLabels = true; |
729 | dayLabel = getNewDaylabel(); | 795 | dayLabel = getNewDaylabel(); |
730 | } | 796 | } |
731 | dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); | 797 | dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); |
732 | dayLabel->setFont( dlf ); | 798 | dayLabel->setFont( dlf ); |
733 | dayLabel->setNum( -1 ); | 799 | dayLabel->setNum( -1 ); |
734 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 800 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
801 | #if 0 | ||
735 | if ( QApplication::desktop()->width() <= 320 ) | 802 | if ( QApplication::desktop()->width() <= 320 ) |
736 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ).left(2) ); | 803 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ).left(2) ); |
737 | else | 804 | else |
805 | #endif | ||
738 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); | 806 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); |
739 | dayLabel->show(); | 807 | dayLabel->show(); |
740 | DateList::ConstIterator dit; | 808 | DateList::ConstIterator dit; |
741 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); | 809 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); |
742 | int counter = -1; | 810 | int counter = -1; |
743 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 811 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
744 | ++counter; | 812 | ++counter; |
745 | QDate date = *dit; | 813 | QDate date = *dit; |
746 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); | 814 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); |
747 | if ( ! appendLabels ) { | 815 | if ( ! appendLabels ) { |
748 | dayLabel = mDayLabelsList.next(); | 816 | dayLabel = mDayLabelsList.next(); |
749 | if ( !dayLabel ) | 817 | if ( !dayLabel ) |
750 | appendLabels = true; | 818 | appendLabels = true; |
751 | } | 819 | } |
752 | if ( appendLabels ) { | 820 | if ( appendLabels ) { |
753 | dayLabel = getNewDaylabel(); | 821 | dayLabel = getNewDaylabel(); |
754 | } | 822 | } |
755 | dayLabel->setMinimumWidth( 1 ); | 823 | dayLabel->setMinimumWidth( 1 ); |
756 | dayLabel->setMaximumWidth( 10240 ); | 824 | dayLabel->setMaximumWidth( 10240 ); |
757 | dayLabel->setFont( dlf ); | 825 | dayLabel->setFont( dlf ); |
758 | dayLabel->show(); | 826 | dayLabel->show(); |
759 | dayLabel->setAutoRepeat( false ); | 827 | dayLabel->setAutoRepeat( false ); |
760 | dayLabel->setNum( counter ); | 828 | dayLabel->setNum( counter ); |
761 | QString str; | 829 | QString str; |
762 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); | 830 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); |
763 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); | 831 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); |
764 | switch ( maxLen ) { | 832 | switch ( maxLen ) { |
765 | case 2: | 833 | case 2: |
766 | str = QString::number( date.day() ); | 834 | str = QString::number( date.day() ); |
767 | break; | 835 | break; |
768 | 836 | ||
769 | case 3: | 837 | case 3: |
770 | str = dayName.left( 1 ) +QString::number( date.day()); | 838 | str = dayName.left( 1 ) +QString::number( date.day()); |
771 | 839 | ||
772 | break; | 840 | break; |
773 | case 4: | 841 | case 4: |
774 | str = dayName.left( 1 ) + " " +QString::number( date.day()); | 842 | str = dayName.left( 1 ) + " " +QString::number( date.day()); |
775 | 843 | ||
776 | break; | 844 | break; |
777 | case 5: | 845 | case 5: |
778 | str = dayName.left( 2 ) + " " +QString::number( date.day()); | 846 | str = dayName.left( 2 ) + " " +QString::number( date.day()); |
779 | 847 | ||
780 | break; | 848 | break; |
781 | case 6: | 849 | case 6: |
782 | str = dayName.left( 3 ) + " " +QString::number( date.day()); | 850 | str = dayName.left( 3 ) + " " +QString::number( date.day()); |
783 | break; | 851 | break; |
784 | 852 | ||
785 | default: | 853 | default: |
786 | break; | 854 | break; |
787 | } | 855 | } |
788 | if ( oneday ) { | 856 | if ( oneday ) { |
789 | QString addString; | 857 | QString addString; |
790 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) | 858 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) |
791 | addString = i18n("Today"); | 859 | addString = i18n("Today"); |
792 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 860 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
793 | addString = i18n("Tomorrow"); | 861 | addString = i18n("Tomorrow"); |
794 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 862 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
795 | addString = i18n("Yesterday"); | 863 | addString = i18n("Yesterday"); |
796 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | 864 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) |
797 | addString = i18n("Day before yesterday"); | 865 | addString = i18n("Day before yesterday"); |
798 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 866 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
799 | addString = i18n("Day after tomorrow"); | 867 | addString = i18n("Day after tomorrow"); |
800 | if ( !addString.isEmpty() ) { | 868 | if ( !addString.isEmpty() ) { |
801 | str = addString+", " + str; | 869 | str = addString+", " + str; |
802 | } else { | 870 | } else { |
803 | str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); | 871 | str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); |
804 | } | 872 | } |
805 | } | 873 | } |
806 | dayLabel->setText(str); | 874 | dayLabel->setText(str); |
807 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 875 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
808 | if (date == QDate::currentDate()) { | 876 | if (date == QDate::currentDate()) { |
809 | QFont bFont = dlf; | 877 | QFont bFont = dlf; |
810 | bFont.setBold( true ); | 878 | bFont.setBold( true ); |
811 | dayLabel->setFont(bFont); | 879 | dayLabel->setFont(bFont); |
812 | } | 880 | } |
813 | //dayLayout->addWidget(dayLabel); | 881 | //dayLayout->addWidget(dayLabel); |
814 | 882 | ||
815 | #ifndef KORG_NOPLUGINS | 883 | #ifndef KORG_NOPLUGINS |
816 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); | 884 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); |
817 | CalendarDecoration *it; | 885 | CalendarDecoration *it; |
818 | for(it = cds.first(); it; it = cds.next()) { | 886 | for(it = cds.first(); it; it = cds.next()) { |
819 | QString text = it->shortText( date ); | 887 | QString text = it->shortText( date ); |
820 | if ( !text.isEmpty() ) { | 888 | if ( !text.isEmpty() ) { |
821 | QLabel *label = new QLabel(text,mDayLabels); | 889 | QLabel *label = new QLabel(text,mDayLabels); |
822 | label->setAlignment(AlignCenter); | 890 | label->setAlignment(AlignCenter); |
823 | dayLayout->addWidget(label); | 891 | dayLayout->addWidget(label); |
824 | } | 892 | } |
825 | } | 893 | } |
826 | 894 | ||
827 | for(it = cds.first(); it; it = cds.next()) { | 895 | for(it = cds.first(); it; it = cds.next()) { |
828 | QWidget *wid = it->smallWidget(mDayLabels,date); | 896 | QWidget *wid = it->smallWidget(mDayLabels,date); |
829 | if ( wid ) { | 897 | if ( wid ) { |
830 | // wid->setHeight(20); | 898 | // wid->setHeight(20); |
831 | dayLayout->addWidget(wid); | 899 | dayLayout->addWidget(wid); |
832 | } | 900 | } |
833 | } | 901 | } |
834 | #endif | 902 | #endif |
835 | } | 903 | } |
836 | if ( ! appendLabels ) { | 904 | if ( ! appendLabels ) { |
837 | dayLabel = mDayLabelsList.next(); | 905 | dayLabel = mDayLabelsList.next(); |
838 | if ( !dayLabel ) | 906 | if ( !dayLabel ) |
839 | appendLabels = true; | 907 | appendLabels = true; |
840 | } | 908 | } |
841 | if ( appendLabels ) { | 909 | if ( appendLabels ) { |
842 | dayLabel = getNewDaylabel(); | 910 | dayLabel = getNewDaylabel(); |
843 | } | 911 | } |
844 | //dayLabel->hide();//test only | 912 | //dayLabel->hide();//test only |
845 | int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()- (mAgenda->frameWidth()*2) ) % mSelectedDates.count() ; | 913 | int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()- (mAgenda->frameWidth()*2) ) % mSelectedDates.count() ; |
846 | if ( offset < 0 ) offset = 0; | 914 | if ( offset < 0 ) offset = 0; |
847 | //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); | 915 | //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); |
848 | dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); | 916 | dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); |
849 | dayLabel->setFont( dlf ); | 917 | dayLabel->setFont( dlf ); |
850 | dayLabel->setAutoRepeat( true ); | 918 | dayLabel->setAutoRepeat( true ); |
851 | dayLabel->show(); | 919 | dayLabel->show(); |
852 | dayLabel->setNum( -2 ); | 920 | dayLabel->setNum( -2 ); |
853 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); | 921 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); |
854 | 922 | ||
855 | //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); | 923 | //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); |
856 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); | 924 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); |
857 | if ( !appendLabels ) { | 925 | if ( !appendLabels ) { |
858 | dayLabel = mDayLabelsList.next(); | 926 | dayLabel = mDayLabelsList.next(); |
859 | while ( dayLabel ) { | 927 | while ( dayLabel ) { |
860 | //qDebug("!dayLabel %d",dayLabel ); | 928 | //qDebug("!dayLabel %d",dayLabel ); |
861 | dayLabel->hide(); | 929 | dayLabel->hide(); |
862 | dayLabel = mDayLabelsList.next(); | 930 | dayLabel = mDayLabelsList.next(); |
863 | } | 931 | } |
864 | } | 932 | } |
865 | 933 | ||
866 | mDayLabelsFrame->setFixedHeight( newHight + 4 ); | 934 | mDayLabelsFrame->setFixedHeight( newHight + 4 ); |
867 | } | 935 | } |
868 | 936 | ||
869 | int KOAgendaView::maxDatesHint() | 937 | int KOAgendaView::maxDatesHint() |
870 | { | 938 | { |
871 | // Not sure about the max number of events, so return 0 for now. | 939 | // Not sure about the max number of events, so return 0 for now. |
872 | return 0; | 940 | return 0; |
873 | } | 941 | } |
874 | 942 | ||
875 | int KOAgendaView::currentDateCount() | 943 | int KOAgendaView::currentDateCount() |
876 | { | 944 | { |
877 | return mSelectedDates.count(); | 945 | return mSelectedDates.count(); |
878 | } | 946 | } |
879 | 947 | ||
880 | QPtrList<Incidence> KOAgendaView::selectedIncidences() | 948 | QPtrList<Incidence> KOAgendaView::selectedIncidences() |
881 | { | 949 | { |
882 | QPtrList<Incidence> selected; | 950 | QPtrList<Incidence> selected; |
883 | Incidence *incidence; | 951 | Incidence *incidence; |
884 | 952 | ||
885 | incidence = mAgenda->selectedIncidence(); | 953 | incidence = mAgenda->selectedIncidence(); |
886 | if (incidence) selected.append(incidence); | 954 | if (incidence) selected.append(incidence); |
887 | 955 | ||
888 | incidence = mAllDayAgenda->selectedIncidence(); | 956 | incidence = mAllDayAgenda->selectedIncidence(); |
889 | if (incidence) selected.append(incidence); | 957 | if (incidence) selected.append(incidence); |
890 | 958 | ||
891 | return selected; | 959 | return selected; |
892 | } | 960 | } |
893 | 961 | ||
894 | DateList KOAgendaView::selectedDates() | 962 | DateList KOAgendaView::selectedDates() |
895 | { | 963 | { |
896 | DateList selected; | 964 | DateList selected; |
897 | QDate qd; | 965 | QDate qd; |
898 | 966 | ||
899 | qd = mAgenda->selectedIncidenceDate(); | 967 | qd = mAgenda->selectedIncidenceDate(); |
900 | if (qd.isValid()) selected.append(qd); | 968 | if (qd.isValid()) selected.append(qd); |
901 | 969 | ||
902 | qd = mAllDayAgenda->selectedIncidenceDate(); | 970 | qd = mAllDayAgenda->selectedIncidenceDate(); |
903 | if (qd.isValid()) selected.append(qd); | 971 | if (qd.isValid()) selected.append(qd); |
904 | 972 | ||
905 | return selected; | 973 | return selected; |
906 | } | 974 | } |
907 | 975 | ||
908 | 976 | ||
909 | void KOAgendaView::updateView() | 977 | void KOAgendaView::updateView() |
910 | { | 978 | { |
911 | if ( mBlockUpdating ) | 979 | if ( mBlockUpdating ) |
912 | return; | 980 | return; |
913 | // kdDebug() << "KOAgendaView::updateView()" << endl; | 981 | // kdDebug() << "KOAgendaView::updateView()" << endl; |
914 | fillAgenda(); | 982 | fillAgenda(); |
915 | 983 | ||
916 | } | 984 | } |
917 | 985 | ||
918 | 986 | ||
919 | /* | 987 | /* |
920 | Update configuration settings for the agenda view. This method is not | 988 | Update configuration settings for the agenda view. This method is not |
921 | complete. | 989 | complete. |
922 | */ | 990 | */ |
923 | void KOAgendaView::updateConfig() | 991 | void KOAgendaView::updateConfig() |
924 | { | 992 | { |
925 | if ( mBlockUpdating ) | 993 | if ( mBlockUpdating ) |
926 | return; | 994 | return; |
927 | if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { | 995 | if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { |
928 | int old = KOPrefs::instance()->mHourSize; | 996 | int old = KOPrefs::instance()->mHourSize; |
929 | KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; | 997 | KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; |
930 | qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); | 998 | qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); |
931 | } | 999 | } |
932 | 1000 | ||
933 | 1001 | ||
934 | // update config for children | 1002 | // update config for children |
935 | mTimeLabels->updateConfig(); | 1003 | mTimeLabels->updateConfig(); |
936 | mAgenda->storePosition(); | 1004 | mAgenda->storePosition(); |
937 | mAgenda->updateConfig(); | 1005 | mAgenda->updateConfig(); |
938 | mAllDayAgenda->updateConfig(); | 1006 | mAllDayAgenda->updateConfig(); |
939 | // widget synchronization | 1007 | // widget synchronization |
940 | //TODO: find a better way, maybe signal/slot | 1008 | //TODO: find a better way, maybe signal/slot |
941 | mTimeLabels->positionChanged(); | 1009 | mTimeLabels->positionChanged(); |
942 | 1010 | ||
943 | // for some reason, this needs to be called explicitly | 1011 | // for some reason, this needs to be called explicitly |
944 | mTimeLabels->repaint(); | 1012 | mTimeLabels->repaint(); |
945 | 1013 | ||
946 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 1014 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
947 | 1015 | ||
948 | // ToolTips displaying summary of events | 1016 | // ToolTips displaying summary of events |
949 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() | 1017 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() |
950 | ->mEnableToolTips); | 1018 | ->mEnableToolTips); |
951 | 1019 | ||
952 | //setHolidayMasks(); | 1020 | //setHolidayMasks(); |
953 | 1021 | ||
954 | //createDayLabels(); called by via updateView(); | 1022 | //createDayLabels(); called by via updateView(); |
955 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); | 1023 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); |
956 | updateView(); | 1024 | updateView(); |
957 | mAgenda->restorePosition(); | 1025 | mAgenda->restorePosition(); |
958 | } | 1026 | } |
959 | 1027 | ||
960 | 1028 | ||
961 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) | 1029 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) |
962 | { | 1030 | { |
963 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; | 1031 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; |
964 | //qDebug("KOAgendaView::updateEventDates "); | 1032 | //qDebug("KOAgendaView::updateEventDates "); |
965 | QDateTime startDt,endDt; | 1033 | QDateTime startDt,endDt; |
966 | QDate startDate; | 1034 | QDate startDate; |
967 | int lenInSecs; | 1035 | int lenInSecs; |
968 | // if ( type == KOAgenda::RESIZETOP ) | 1036 | // if ( type == KOAgenda::RESIZETOP ) |
969 | // qDebug("RESIZETOP "); | 1037 | // qDebug("RESIZETOP "); |
970 | // if ( type == KOAgenda::RESIZEBOTTOM ) | 1038 | // if ( type == KOAgenda::RESIZEBOTTOM ) |
971 | // qDebug("RESIZEBOTTOM "); | 1039 | // qDebug("RESIZEBOTTOM "); |
972 | // if ( type == KOAgenda::MOVE ) | 1040 | // if ( type == KOAgenda::MOVE ) |
973 | // qDebug("MOVE "); | 1041 | // qDebug("MOVE "); |
974 | if ( item->incidence()->type() == "Event" ) { | 1042 | if ( item->incidence()->type() == "Event" ) { |
975 | startDt =item->incidence()->dtStart(); | 1043 | startDt =item->incidence()->dtStart(); |
976 | endDt = item->incidence()->dtEnd(); | 1044 | endDt = item->incidence()->dtEnd(); |
977 | lenInSecs = startDt.secsTo( endDt ); | 1045 | lenInSecs = startDt.secsTo( endDt ); |
978 | } | 1046 | } |
979 | 1047 | ||
980 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); | 1048 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); |
981 | 1049 | ||
982 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { | 1050 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { |
983 | startDate = mSelectedDates[item->mLastMoveXPos]; | 1051 | startDate = mSelectedDates[item->mLastMoveXPos]; |
984 | } else { | 1052 | } else { |
985 | if (item->cellX() < 0) { | 1053 | if (item->cellX() < 0) { |
986 | startDate = (mSelectedDates.first()).addDays(item->cellX()); | 1054 | startDate = (mSelectedDates.first()).addDays(item->cellX()); |
987 | } else { | 1055 | } else { |
988 | startDate = mSelectedDates[item->cellX()]; | 1056 | startDate = mSelectedDates[item->cellX()]; |
989 | } | 1057 | } |
990 | } | 1058 | } |
991 | startDt.setDate(startDate); | 1059 | startDt.setDate(startDate); |
992 | 1060 | ||
993 | if (item->incidence()->doesFloat()) { | 1061 | if (item->incidence()->doesFloat()) { |
994 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); | 1062 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); |
995 | } else { | 1063 | } else { |
996 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) | 1064 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) |
997 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); | 1065 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); |
998 | if ( item->incidence()->type() == "Event" ) { | 1066 | if ( item->incidence()->type() == "Event" ) { |
999 | if ( type == KOAgenda::MOVE ) { | 1067 | if ( type == KOAgenda::MOVE ) { |
1000 | endDt = startDt.addSecs(lenInSecs); | 1068 | endDt = startDt.addSecs(lenInSecs); |
1001 | 1069 | ||
1002 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { | 1070 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { |
1003 | if (item->lastMultiItem()) { | 1071 | if (item->lastMultiItem()) { |
1004 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 1072 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
1005 | endDt.setDate(startDate. | 1073 | endDt.setDate(startDate. |
1006 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 1074 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
1007 | } else { | 1075 | } else { |
1008 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 1076 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
1009 | endDt.setDate(startDate); | 1077 | endDt.setDate(startDate); |
1010 | } | 1078 | } |
1011 | } | 1079 | } |
1012 | } else { | 1080 | } else { |
1013 | // todo | 1081 | // todo |
1014 | if (item->lastMultiItem()) { | 1082 | if (item->lastMultiItem()) { |
1015 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 1083 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
1016 | endDt.setDate(startDate. | 1084 | endDt.setDate(startDate. |
1017 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 1085 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
1018 | } else { | 1086 | } else { |
1019 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); | 1087 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); |
1020 | if ( item->cellYBottom() > 0 ) | 1088 | if ( item->cellYBottom() > 0 ) |
1021 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 1089 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
1022 | else | 1090 | else |
1023 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); | 1091 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); |
1024 | endDt.setDate(startDate); | 1092 | endDt.setDate(startDate); |
1025 | } | 1093 | } |
1026 | } | 1094 | } |
1027 | } | 1095 | } |
1028 | if ( item->incidence()->type() == "Event" ) { | 1096 | if ( item->incidence()->type() == "Event" ) { |
1029 | item->incidence()->setDtStart(startDt); | 1097 | item->incidence()->setDtStart(startDt); |
1030 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); | 1098 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); |
1031 | } else if ( item->incidence()->type() == "Todo" ) { | 1099 | } else if ( item->incidence()->type() == "Todo" ) { |
1032 | Todo* to = static_cast<Todo*>(item->incidence()); | 1100 | Todo* to = static_cast<Todo*>(item->incidence()); |
1033 | 1101 | ||
1034 | to->setDtDue(endDt); | 1102 | to->setDtDue(endDt); |
1035 | if ( to->hasStartDate() ) { | 1103 | if ( to->hasStartDate() ) { |
1036 | if (to->dtStart() >= to->dtDue() ) | 1104 | if (to->dtStart() >= to->dtDue() ) |
1037 | to->setDtStart(to->dtDue().addDays( -2 )); | 1105 | to->setDtStart(to->dtDue().addDays( -2 )); |
1038 | } | 1106 | } |
1039 | 1107 | ||
1040 | } | 1108 | } |
1041 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); | 1109 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); |
1042 | item->incidence()->setRevision(item->incidence()->revision()+1); | 1110 | item->incidence()->setRevision(item->incidence()->revision()+1); |
1043 | item->setItemDate(startDt.date()); | 1111 | item->setItemDate(startDt.date()); |
1044 | //item->updateItem(); | 1112 | //item->updateItem(); |
1045 | if ( item->incidence()->type() == "Todo" ) { | 1113 | if ( item->incidence()->type() == "Todo" ) { |
1046 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); | 1114 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); |
1047 | 1115 | ||
1048 | } | 1116 | } |
1049 | else | 1117 | else |
1050 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); | 1118 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); |
1051 | item->updateItem(); | 1119 | item->updateItem(); |
1052 | } | 1120 | } |
1053 | 1121 | ||
1054 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) | 1122 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) |
1055 | { | 1123 | { |
1056 | // kdDebug() << "KOAgendaView::selectDates" << endl; | 1124 | // kdDebug() << "KOAgendaView::selectDates" << endl; |
1057 | 1125 | ||
1058 | mSelectedDates.clear(); | 1126 | mSelectedDates.clear(); |
1059 | // qDebug("KOAgendaView::showDates "); | 1127 | // qDebug("KOAgendaView::showDates "); |
1060 | QDate d = start; | 1128 | QDate d = start; |
1061 | while (d <= end) { | 1129 | while (d <= end) { |
1062 | mSelectedDates.append(d); | 1130 | mSelectedDates.append(d); |
1063 | d = d.addDays( 1 ); | 1131 | d = d.addDays( 1 ); |
1064 | } | 1132 | } |
1065 | 1133 | ||
1066 | // and update the view | 1134 | // and update the view |
1067 | fillAgenda(); | 1135 | fillAgenda(); |
1068 | } | 1136 | } |
1069 | 1137 | ||
1070 | 1138 | ||
1071 | void KOAgendaView::showEvents(QPtrList<Event>) | 1139 | void KOAgendaView::showEvents(QPtrList<Event>) |
1072 | { | 1140 | { |
1073 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; | 1141 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; |
1074 | } | 1142 | } |
1075 | 1143 | ||
1076 | void KOAgendaView::changeEventDisplay(Event *, int) | 1144 | void KOAgendaView::changeEventDisplay(Event *, int) |
1077 | { | 1145 | { |
1078 | // qDebug("KOAgendaView::changeEventDisplay "); | 1146 | // qDebug("KOAgendaView::changeEventDisplay "); |
1079 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; | 1147 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; |
1080 | // this should be re-written to be MUCH smarter. Right now we | 1148 | // this should be re-written to be MUCH smarter. Right now we |
1081 | // are just playing dumb. | 1149 | // are just playing dumb. |
1082 | fillAgenda(); | 1150 | fillAgenda(); |
1083 | } | 1151 | } |
1084 | 1152 | ||
1085 | void KOAgendaView::fillAgenda(const QDate &) | 1153 | void KOAgendaView::fillAgenda(const QDate &) |
1086 | { | 1154 | { |
1087 | // qDebug("KOAgendaView::fillAgenda "); | 1155 | // qDebug("KOAgendaView::fillAgenda "); |
1088 | fillAgenda(); | 1156 | fillAgenda(); |
1089 | } | 1157 | } |
1090 | 1158 | ||
1091 | void KOAgendaView::fillAgenda() | 1159 | void KOAgendaView::fillAgenda() |
1092 | { | 1160 | { |
1093 | if ( globalFlagBlockStartup ) | 1161 | if ( globalFlagBlockStartup ) |
1094 | return; | 1162 | return; |
1095 | if ( globalFlagBlockAgenda == 1 ) | 1163 | if ( globalFlagBlockAgenda == 1 ) |
1096 | return; | 1164 | return; |
1097 | static bool onlyOne = false; | 1165 | static bool onlyOne = false; |
1098 | if ( onlyOne ) | 1166 | if ( onlyOne ) |
1099 | return; | 1167 | return; |
1100 | onlyOne = true; | 1168 | onlyOne = true; |
1101 | //if ( globalFlagBlockAgenda == 2 ) | 1169 | //if ( globalFlagBlockAgenda == 2 ) |
1102 | //globalFlagBlockAgenda = 0; | 1170 | //globalFlagBlockAgenda = 0; |
1103 | // globalFlagBlockPainting = false; | 1171 | // globalFlagBlockPainting = false; |
1104 | if ( globalFlagBlockAgenda == 0 ) | 1172 | if ( globalFlagBlockAgenda == 0 ) |
1105 | globalFlagBlockAgenda = 1; | 1173 | globalFlagBlockAgenda = 1; |
1106 | // clearView(); | 1174 | // clearView(); |
1107 | //qDebug("fillAgenda()++++ "); | 1175 | //qDebug("fillAgenda()++++ "); |
1108 | globalFlagBlockAgendaItemPaint = 1; | 1176 | globalFlagBlockAgendaItemPaint = 1; |
1109 | 1177 | ||
1110 | mAllDayAgenda->changeColumns(mSelectedDates.count()); | 1178 | mAllDayAgenda->changeColumns(mSelectedDates.count()); |
1111 | mAgenda->changeColumns(mSelectedDates.count()); | 1179 | mAgenda->changeColumns(mSelectedDates.count()); |
1112 | qApp->processEvents(); | 1180 | qApp->processEvents(); |
1113 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); | 1181 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); |
1114 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); | 1182 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); |
1115 | setHolidayMasks(); | 1183 | setHolidayMasks(); |
1116 | 1184 | ||
1117 | //mAgenda->hideUnused(); | 1185 | //mAgenda->hideUnused(); |
1118 | //mAllDayAgenda->hideUnused(); | 1186 | //mAllDayAgenda->hideUnused(); |
1119 | 1187 | ||
1120 | // mAgenda->blockNextRepaint( false ); | 1188 | // mAgenda->blockNextRepaint( false ); |
1121 | // mAgenda->viewport()->repaint(); | 1189 | // mAgenda->viewport()->repaint(); |
1122 | // mAgenda->blockNextRepaint( true ); | 1190 | // mAgenda->blockNextRepaint( true ); |
1123 | mMinY.resize(mSelectedDates.count()); | 1191 | mMinY.resize(mSelectedDates.count()); |
1124 | mMaxY.resize(mSelectedDates.count()); | 1192 | mMaxY.resize(mSelectedDates.count()); |
1125 | 1193 | ||
1126 | QPtrList<Event> dayEvents; | 1194 | QPtrList<Event> dayEvents; |
1127 | 1195 | ||
1128 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1196 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1129 | // Therefore, gtodoset all of them. | 1197 | // Therefore, gtodoset all of them. |
1130 | QPtrList<Todo> todos = calendar()->todos(); | 1198 | QPtrList<Todo> todos = calendar()->todos(); |
1131 | 1199 | ||
1132 | mAgenda->setDateList(mSelectedDates); | 1200 | mAgenda->setDateList(mSelectedDates); |
1133 | 1201 | ||
1134 | QDate today = QDate::currentDate(); | 1202 | QDate today = QDate::currentDate(); |
1135 | 1203 | ||
1136 | DateList::ConstIterator dit; | 1204 | DateList::ConstIterator dit; |
1137 | int curCol = 0; | 1205 | int curCol = 0; |
1138 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 1206 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
1139 | QDate currentDate = *dit; | 1207 | QDate currentDate = *dit; |
1140 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() | 1208 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() |
1141 | // << endl; | 1209 | // << endl; |
1142 | 1210 | ||
1143 | dayEvents = calendar()->events(currentDate,true); | 1211 | dayEvents = calendar()->events(currentDate,true); |
1144 | 1212 | ||
1145 | // Default values, which can never be reached | 1213 | // Default values, which can never be reached |
1146 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; | 1214 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; |
1147 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; | 1215 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; |
1148 | 1216 | ||
1149 | unsigned int numEvent; | 1217 | unsigned int numEvent; |
1150 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { | 1218 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { |
1151 | Event *event = dayEvents.at(numEvent); | 1219 | Event *event = dayEvents.at(numEvent); |
1152 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) | 1220 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) |
1153 | if ( event->uid().left(15) == QString("last-syncEvent-") ) | 1221 | if ( event->uid().left(15) == QString("last-syncEvent-") ) |
1154 | continue; | 1222 | continue; |
1155 | // kdDebug() << " Event: " << event->summary() << endl; | 1223 | // kdDebug() << " Event: " << event->summary() << endl; |
1156 | 1224 | ||
1157 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; | 1225 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; |
1158 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; | 1226 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; |
1159 | 1227 | ||
1160 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; | 1228 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; |
1161 | 1229 | ||
1162 | if (event->doesFloat()) { | 1230 | if (event->doesFloat()) { |
1163 | if (event->recurrence()->doesRecur()) { | 1231 | if (event->recurrence()->doesRecur()) { |
1164 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); | 1232 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); |
1165 | } else { | 1233 | } else { |
1166 | if (beginX <= 0 && curCol == 0) { | 1234 | if (beginX <= 0 && curCol == 0) { |
1167 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1235 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1168 | } else if (beginX == curCol) { | 1236 | } else if (beginX == curCol) { |
1169 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1237 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1170 | } | 1238 | } |
1171 | } | 1239 | } |
1172 | } else if (event->isMultiDay()) { | 1240 | } else if (event->isMultiDay()) { |
1173 | if ( event->doesRecur () ) { | 1241 | if ( event->doesRecur () ) { |
1174 | QDate dateit = currentDate; | 1242 | QDate dateit = currentDate; |
1175 | int count = 0; | 1243 | int count = 0; |
1176 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; | 1244 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; |
1177 | while (! event->recursOn( dateit ) && count <= max ) { | 1245 | while (! event->recursOn( dateit ) && count <= max ) { |
1178 | ++count; | 1246 | ++count; |
1179 | dateit = dateit.addDays( -1 ); | 1247 | dateit = dateit.addDays( -1 ); |
1180 | } | 1248 | } |
1181 | bool ok; | 1249 | bool ok; |
1182 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); | 1250 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); |
1183 | if ( ok ) | 1251 | if ( ok ) |
1184 | { | 1252 | { |
1185 | int secs = event->dtStart().secsTo( event->dtEnd() ); | 1253 | int secs = event->dtStart().secsTo( event->dtEnd() ); |
1186 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; | 1254 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; |
1187 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; | 1255 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; |
1188 | endX = currentDate.daysTo(nextOcend.date()) + curCol; | 1256 | endX = currentDate.daysTo(nextOcend.date()) + curCol; |
1189 | 1257 | ||
1190 | } | 1258 | } |
1191 | } | 1259 | } |
1192 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1260 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1193 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1261 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1194 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); | 1262 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); |
1195 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { | 1263 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { |
1196 | //qDebug("insert!!! "); | 1264 | //qDebug("insert!!! "); |
1197 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); | 1265 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); |
1198 | } | 1266 | } |
1199 | if (beginX == curCol) { | 1267 | if (beginX == curCol) { |
1200 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1268 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1201 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1269 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1202 | } else if (endX == curCol) { | 1270 | } else if (endX == curCol) { |
1203 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1271 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1204 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1272 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1205 | } else { | 1273 | } else { |
1206 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1274 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1207 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1275 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1208 | } | 1276 | } |
1209 | } else { | 1277 | } else { |
1210 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1278 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1211 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1279 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1212 | if (endY < startY) endY = startY; | 1280 | if (endY < startY) endY = startY; |
1213 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); | 1281 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); |
1214 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1282 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1215 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1283 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1216 | } | 1284 | } |
1217 | } | 1285 | } |
1218 | // ---------- [display Todos -------------- | 1286 | // ---------- [display Todos -------------- |
1219 | unsigned int numTodo; | 1287 | unsigned int numTodo; |
1220 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { | 1288 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { |
1221 | Todo *todo = todos.at(numTodo); | 1289 | Todo *todo = todos.at(numTodo); |
1222 | 1290 | ||
1223 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date | 1291 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date |
1224 | 1292 | ||
1225 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1293 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1226 | // Already completed items can be displayed on their original due date | 1294 | // Already completed items can be displayed on their original due date |
1227 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda | 1295 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda |
1228 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; | 1296 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; |
1229 | bool fillIn = false; | 1297 | bool fillIn = false; |
1230 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) | 1298 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) |
1231 | fillIn = true; | 1299 | fillIn = true; |
1232 | if ( ! fillIn && !todo->hasCompletedDate() ) | 1300 | if ( ! fillIn && !todo->hasCompletedDate() ) |
1233 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); | 1301 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); |
1234 | if ( fillIn ) { | 1302 | if ( fillIn ) { |
1235 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue | 1303 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue |
1236 | if ( KOPrefs::instance()->mShowTodoInAgenda ) | 1304 | if ( KOPrefs::instance()->mShowTodoInAgenda ) |
1237 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); | 1305 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); |
1238 | } | 1306 | } |
1239 | else { | 1307 | else { |
1240 | QDateTime dt; | 1308 | QDateTime dt; |
1241 | if ( todo->hasCompletedDate() ) | 1309 | if ( todo->hasCompletedDate() ) |
1242 | dt = todo->completed(); | 1310 | dt = todo->completed(); |
1243 | else | 1311 | else |
1244 | dt = todo->dtDue();; | 1312 | dt = todo->dtDue();; |
1245 | 1313 | ||
1246 | 1314 | ||
1247 | int endY = mAgenda->timeToY(dt.time()) - 1; | 1315 | int endY = mAgenda->timeToY(dt.time()) - 1; |
1248 | int hi = (18/KOPrefs::instance()->mHourSize); | 1316 | int hi = (18/KOPrefs::instance()->mHourSize); |
1249 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); | 1317 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); |
1250 | int startY = endY -hi; | 1318 | int startY = endY -hi; |
1251 | 1319 | ||
1252 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); | 1320 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); |
1253 | 1321 | ||
1254 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1322 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1255 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1323 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1256 | } | 1324 | } |
1257 | } | 1325 | } |
1258 | } | 1326 | } |
1259 | // ---------- display Todos] -------------- | 1327 | // ---------- display Todos] -------------- |
1260 | 1328 | ||
1261 | ++curCol; | 1329 | ++curCol; |
1262 | } | 1330 | } |
1263 | mAgenda->hideUnused(); | 1331 | mAgenda->hideUnused(); |
1264 | mAllDayAgenda->hideUnused(); | 1332 | mAllDayAgenda->hideUnused(); |
1265 | mAgenda->checkScrollBoundaries(); | 1333 | mAgenda->checkScrollBoundaries(); |
1266 | 1334 | ||
1267 | deleteSelectedDateTime(); | 1335 | deleteSelectedDateTime(); |
1268 | 1336 | ||
1269 | createDayLabels(); | 1337 | createDayLabels(); |
1270 | emit incidenceSelected( 0 ); | 1338 | emit incidenceSelected( 0 ); |
1271 | 1339 | ||
1272 | if ( globalFlagBlockAgenda == 2 ) { | 1340 | if ( globalFlagBlockAgenda == 2 ) { |
1273 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) | 1341 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) |
1274 | setStartHour( KOPrefs::instance()->mDayBegins ); | 1342 | setStartHour( KOPrefs::instance()->mDayBegins ); |
1275 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 1343 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
1276 | setStartHour( QTime::currentTime ().hour() ); | 1344 | setStartHour( QTime::currentTime ().hour() ); |
1277 | // qApp->processEvents(); | 1345 | // qApp->processEvents(); |
1278 | } | 1346 | } |
1279 | qApp->processEvents(); | 1347 | qApp->processEvents(); |
1280 | //qDebug("qApp->processEvents(); END "); | 1348 | //qDebug("qApp->processEvents(); END "); |
1281 | globalFlagBlockAgenda = 0; | 1349 | globalFlagBlockAgenda = 0; |
1282 | 1350 | ||
1283 | // mAgenda->hideUnused(); | 1351 | // mAgenda->hideUnused(); |
1284 | //mAllDayAgenda->hideUnused(); | 1352 | //mAllDayAgenda->hideUnused(); |
1285 | mAllDayAgenda->drawContentsToPainter(); | 1353 | mAllDayAgenda->drawContentsToPainter(); |
1286 | mAgenda->drawContentsToPainter(); | 1354 | mAgenda->drawContentsToPainter(); |
1287 | repaintAgenda(); | 1355 | repaintAgenda(); |
1288 | onlyOne = false; | 1356 | onlyOne = false; |
1289 | // mAgenda->finishUpdate(); | 1357 | // mAgenda->finishUpdate(); |
1290 | //mAllDayAgenda->finishUpdate(); | 1358 | //mAllDayAgenda->finishUpdate(); |
1291 | 1359 | ||
1292 | // repaintAgenda(); | 1360 | // repaintAgenda(); |
1293 | //qApp->processEvents(); | 1361 | //qApp->processEvents(); |
1294 | // globalFlagBlockAgenda = 0; | 1362 | // globalFlagBlockAgenda = 0; |
1295 | } | 1363 | } |
1296 | void KOAgendaView::repaintAgenda() | 1364 | void KOAgendaView::repaintAgenda() |
1297 | { | 1365 | { |
1298 | // mAllDayAgenda->drawContentsToPainter(); | 1366 | // mAllDayAgenda->drawContentsToPainter(); |
1299 | // mAllDayAgenda->viewport()->repaint( false ); | 1367 | // mAllDayAgenda->viewport()->repaint( false ); |
1300 | // mAgenda->drawContentsToPainter(); | 1368 | // mAgenda->drawContentsToPainter(); |
1301 | // mAgenda->viewport()->repaint( false ); | 1369 | // mAgenda->viewport()->repaint( false ); |
1302 | // qApp->processEvents(); | 1370 | // qApp->processEvents(); |
1303 | 1371 | ||
1304 | //qDebug("KOAgendaView::repaintAgenda() "); | 1372 | //qDebug("KOAgendaView::repaintAgenda() "); |
1305 | //qApp->processEvents(); | 1373 | //qApp->processEvents(); |
1306 | mAgenda->viewport()->repaint( false ); | 1374 | mAgenda->viewport()->repaint( false ); |
1307 | mAllDayAgenda->viewport()->repaint( false ); | 1375 | mAllDayAgenda->viewport()->repaint( false ); |
1308 | mAgenda->finishUpdate(); | 1376 | mAgenda->finishUpdate(); |
1309 | mAllDayAgenda->finishUpdate(); | 1377 | mAllDayAgenda->finishUpdate(); |
1310 | } | 1378 | } |
1311 | 1379 | ||
1312 | 1380 | ||
1313 | void KOAgendaView::clearView() | 1381 | void KOAgendaView::clearView() |
1314 | { | 1382 | { |
1315 | // kdDebug() << "ClearView" << endl; | 1383 | // kdDebug() << "ClearView" << endl; |
1316 | mAllDayAgenda->clear(); | 1384 | mAllDayAgenda->clear(); |
1317 | mAgenda->clear(); | 1385 | mAgenda->clear(); |
1318 | } | 1386 | } |
1319 | 1387 | ||
1320 | void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1388 | void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1321 | const QDate &td) | 1389 | const QDate &td) |
1322 | { | 1390 | { |
1323 | #ifndef KORG_NOPRINTER | 1391 | #ifndef KORG_NOPRINTER |
1324 | if (fd == td) | 1392 | if (fd == td) |
1325 | calPrinter->preview(CalPrinter::Day, fd, td); | 1393 | calPrinter->preview(CalPrinter::Day, fd, td); |
1326 | else | 1394 | else |
1327 | calPrinter->preview(CalPrinter::Week, fd, td); | 1395 | calPrinter->preview(CalPrinter::Week, fd, td); |
1328 | #endif | 1396 | #endif |
1329 | } | 1397 | } |
1330 | 1398 | ||
1331 | // void KOAgendaView::updateMovedTodo() | 1399 | // void KOAgendaView::updateMovedTodo() |
1332 | // { | 1400 | // { |
1333 | // // updateConfig(); | 1401 | // // updateConfig(); |
1334 | // // emit updateTodoViews(); | 1402 | // // emit updateTodoViews(); |
1335 | // } | 1403 | // } |
1336 | 1404 | ||
1337 | void KOAgendaView::slotShowDateView( int mode , int d ) | 1405 | void KOAgendaView::slotShowDateView( int mode , int d ) |
1338 | { | 1406 | { |
1339 | if ( d >= mSelectedDates.count() ) { | 1407 | if ( d >= mSelectedDates.count() ) { |
1340 | qDebug("KOAgendaView::slotShowDateView datecounterror %d d ", d, mSelectedDates.count() ); | 1408 | qDebug("KOAgendaView::slotShowDateView datecounterror %d d ", d, mSelectedDates.count() ); |
1341 | 1409 | ||
1342 | } else { | 1410 | } else { |
1343 | QDate day = mSelectedDates[d]; | 1411 | QDate day = mSelectedDates[d]; |
1344 | emit showDateView(mode , day ); | 1412 | emit showDateView(mode , day ); |
1345 | } | 1413 | } |
1346 | 1414 | ||
1347 | } | 1415 | } |
1348 | void KOAgendaView::newEvent(int gx, int gy) | 1416 | void KOAgendaView::newEvent(int gx, int gy) |
1349 | { | 1417 | { |
1350 | if (!mSelectedDates.count()) return; | 1418 | if (!mSelectedDates.count()) return; |
1351 | 1419 | ||
1352 | QDate day = mSelectedDates[gx]; | 1420 | QDate day = mSelectedDates[gx]; |
1353 | 1421 | ||
1354 | QTime time = mAgenda->gyToTime(gy); | 1422 | QTime time = mAgenda->gyToTime(gy); |
1355 | QDateTime dt(day,time); | 1423 | QDateTime dt(day,time); |
1356 | // if ( dt < QDateTime::currentDateTime () ) | 1424 | // if ( dt < QDateTime::currentDateTime () ) |
1357 | // dt = QDateTime::currentDateTime ().addSecs( 3600 ); | 1425 | // dt = QDateTime::currentDateTime ().addSecs( 3600 ); |
1358 | emit newEventSignal(dt); | 1426 | emit newEventSignal(dt); |
1359 | } | 1427 | } |
1360 | 1428 | ||
1361 | void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) | 1429 | void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) |
1362 | { | 1430 | { |
1363 | if (!mSelectedDates.count()) return; | 1431 | if (!mSelectedDates.count()) return; |
1364 | 1432 | ||
1365 | QDate dayStart = mSelectedDates[gxStart]; | 1433 | QDate dayStart = mSelectedDates[gxStart]; |
1366 | QDate dayEnd = mSelectedDates[gxEnd]; | 1434 | QDate dayEnd = mSelectedDates[gxEnd]; |
1367 | 1435 | ||
1368 | QTime timeStart = mAgenda->gyToTime(gyStart); | 1436 | QTime timeStart = mAgenda->gyToTime(gyStart); |
1369 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); | 1437 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); |
1370 | 1438 | ||
1371 | QDateTime dtStart(dayStart,timeStart); | 1439 | QDateTime dtStart(dayStart,timeStart); |
1372 | QDateTime dtEnd(dayEnd,timeEnd); | 1440 | QDateTime dtEnd(dayEnd,timeEnd); |
1373 | 1441 | ||
1374 | emit newEventSignal(dtStart,dtEnd); | 1442 | emit newEventSignal(dtStart,dtEnd); |
1375 | } | 1443 | } |
1376 | 1444 | ||
1377 | void KOAgendaView::newEventAllDay(int gx, int ) | 1445 | void KOAgendaView::newEventAllDay(int gx, int ) |
1378 | { | 1446 | { |
1379 | if (!mSelectedDates.count()) return; | 1447 | if (!mSelectedDates.count()) return; |
1380 | 1448 | ||
1381 | QDate day = mSelectedDates[gx]; | 1449 | QDate day = mSelectedDates[gx]; |
1382 | 1450 | ||
1383 | emit newEventSignal(day); | 1451 | emit newEventSignal(day); |
1384 | } | 1452 | } |
1385 | void KOAgendaView::newTodoAllDay(int gx, int ) | 1453 | void KOAgendaView::newTodoAllDay(int gx, int ) |
1386 | { | 1454 | { |
1387 | if (!mSelectedDates.count()) return; | 1455 | if (!mSelectedDates.count()) return; |
1388 | 1456 | ||
1389 | QDateTime day (mSelectedDates[gx] ); | 1457 | QDateTime day (mSelectedDates[gx] ); |
1390 | emit newTodoSignal(day, true); | 1458 | emit newTodoSignal(day, true); |
1391 | } | 1459 | } |
1392 | void KOAgendaView::newTodo(int gx, int gy ) | 1460 | void KOAgendaView::newTodo(int gx, int gy ) |
1393 | { | 1461 | { |
1394 | if (!mSelectedDates.count()) return; | 1462 | if (!mSelectedDates.count()) return; |
1395 | QDate dayStart = mSelectedDates[gx]; | 1463 | QDate dayStart = mSelectedDates[gx]; |
1396 | QTime timeStart = mAgenda->gyToTime(gy); | 1464 | QTime timeStart = mAgenda->gyToTime(gy); |
1397 | QDateTime dt (dayStart,timeStart); | 1465 | QDateTime dt (dayStart,timeStart); |
1398 | emit newTodoSignal( dt, false ); | 1466 | emit newTodoSignal( dt, false ); |
1399 | } | 1467 | } |
1400 | 1468 | ||
1401 | void KOAgendaView::updateEventIndicatorTop(int newY) | 1469 | void KOAgendaView::updateEventIndicatorTop(int newY) |
1402 | { | 1470 | { |
1403 | uint i; | 1471 | uint i; |
1404 | for(i=0;i<mMinY.size();++i) { | 1472 | for(i=0;i<mMinY.size();++i) { |
1405 | if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); | 1473 | if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); |
1406 | else mEventIndicatorTop->enableColumn(i,false); | 1474 | else mEventIndicatorTop->enableColumn(i,false); |
1407 | } | 1475 | } |
1408 | 1476 | ||
1409 | mEventIndicatorTop->update(); | 1477 | mEventIndicatorTop->update(); |
1410 | } | 1478 | } |
1411 | 1479 | ||
1412 | void KOAgendaView::updateEventIndicatorBottom(int newY) | 1480 | void KOAgendaView::updateEventIndicatorBottom(int newY) |
1413 | { | 1481 | { |
1414 | uint i; | 1482 | uint i; |
1415 | for(i=0;i<mMaxY.size();++i) { | 1483 | for(i=0;i<mMaxY.size();++i) { |
1416 | if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); | 1484 | if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); |
1417 | else mEventIndicatorBottom->enableColumn(i,false); | 1485 | else mEventIndicatorBottom->enableColumn(i,false); |
1418 | } | 1486 | } |
1419 | 1487 | ||
1420 | mEventIndicatorBottom->update(); | 1488 | mEventIndicatorBottom->update(); |
1421 | } | 1489 | } |
1422 | 1490 | ||
1423 | void KOAgendaView::startDrag(Event *event) | 1491 | void KOAgendaView::startDrag(Event *event) |
1424 | { | 1492 | { |
1425 | #ifndef KORG_NODND | 1493 | #ifndef KORG_NODND |
1426 | DndFactory factory( calendar() ); | 1494 | DndFactory factory( calendar() ); |
1427 | ICalDrag *vd = factory.createDrag(event,this); | 1495 | ICalDrag *vd = factory.createDrag(event,this); |
1428 | if (vd->drag()) { | 1496 | if (vd->drag()) { |
1429 | kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; | 1497 | kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; |
1430 | } | 1498 | } |
1431 | #endif | 1499 | #endif |
1432 | } | 1500 | } |
1433 | 1501 | ||
1434 | void KOAgendaView::readSettings() | 1502 | void KOAgendaView::readSettings() |
1435 | { | 1503 | { |
1436 | readSettings(KOGlobals::config()); | 1504 | readSettings(KOGlobals::config()); |
1437 | } | 1505 | } |
1438 | 1506 | ||
1439 | void KOAgendaView::readSettings(KConfig *config) | 1507 | void KOAgendaView::readSettings(KConfig *config) |
1440 | { | 1508 | { |
1441 | // kdDebug() << "KOAgendaView::readSettings()" << endl; | 1509 | // kdDebug() << "KOAgendaView::readSettings()" << endl; |
1442 | 1510 | ||
1443 | config->setGroup("Views"); | 1511 | config->setGroup("Views"); |
1444 | 1512 | ||
1445 | //#ifndef KORG_NOSPLITTER | 1513 | //#ifndef KORG_NOSPLITTER |
1446 | QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); | 1514 | QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); |
1447 | if (sizes.count() == 2) { | 1515 | if (sizes.count() == 2) { |
1448 | if ( sizes[0] < 20 ) { | 1516 | if ( sizes[0] < 20 ) { |
1449 | sizes[1] = sizes[1] +20 - sizes[0]; | 1517 | sizes[1] = sizes[1] +20 - sizes[0]; |
1450 | sizes[0] = 20; | 1518 | sizes[0] = 20; |
1451 | } | 1519 | } |
1452 | mSplitterAgenda->setSizes(sizes); | 1520 | mSplitterAgenda->setSizes(sizes); |
1453 | // qDebug("read %d %d ",sizes[0],sizes[1] ); | 1521 | // qDebug("read %d %d ",sizes[0],sizes[1] ); |
1454 | } | 1522 | } |
1455 | //#endif | 1523 | //#endif |
1456 | 1524 | ||
1457 | // updateConfig(); | 1525 | // updateConfig(); |
1458 | } | 1526 | } |
1459 | 1527 | ||
1460 | void KOAgendaView::writeSettings(KConfig *config) | 1528 | void KOAgendaView::writeSettings(KConfig *config) |
1461 | { | 1529 | { |
1462 | // kdDebug() << "KOAgendaView::writeSettings()" << endl; | 1530 | // kdDebug() << "KOAgendaView::writeSettings()" << endl; |
1463 | 1531 | ||
1464 | config->setGroup("Views"); | 1532 | config->setGroup("Views"); |
1465 | 1533 | ||
1466 | //#ifndef KORG_NOSPLITTER | 1534 | //#ifndef KORG_NOSPLITTER |
1467 | QValueList<int> list = mSplitterAgenda->sizes(); | 1535 | QValueList<int> list = mSplitterAgenda->sizes(); |
1468 | config->writeEntry("Separator AgendaView",list); | 1536 | config->writeEntry("Separator AgendaView",list); |
1469 | //qDebug("write %d %d ", list[0],list[1] ); | 1537 | //qDebug("write %d %d ", list[0],list[1] ); |
1470 | //#endif | 1538 | //#endif |
1471 | } | 1539 | } |
1472 | 1540 | ||
1473 | void KOAgendaView::setHolidayMasks() | 1541 | void KOAgendaView::setHolidayMasks() |
1474 | { | 1542 | { |
1475 | mHolidayMask.resize(mSelectedDates.count()); | 1543 | mHolidayMask.resize(mSelectedDates.count()); |
1476 | 1544 | ||
1477 | uint i; | 1545 | uint i; |
1478 | for(i=0;i<mSelectedDates.count();++i) { | 1546 | for(i=0;i<mSelectedDates.count();++i) { |
1479 | QDate date = mSelectedDates[i]; | 1547 | QDate date = mSelectedDates[i]; |
1480 | bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); | 1548 | bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); |
1481 | bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); | 1549 | bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); |
1482 | bool showHoliday = false; | 1550 | bool showHoliday = false; |
1483 | if ( KOPrefs::instance()->mExcludeHolidays ) { | 1551 | if ( KOPrefs::instance()->mExcludeHolidays ) { |
1484 | QPtrList<Event> events = calendar()->events( date, true ); | 1552 | QPtrList<Event> events = calendar()->events( date, true ); |
1485 | Event *event; | 1553 | Event *event; |
1486 | for( event = events.first(); event; event = events.next() ) { | 1554 | for( event = events.first(); event; event = events.next() ) { |
1487 | if ( event->isHoliday()) { | 1555 | if ( event->isHoliday()) { |
1488 | showHoliday = true; | 1556 | showHoliday = true; |
1489 | break; | 1557 | break; |
1490 | } | 1558 | } |
1491 | } | 1559 | } |
1492 | 1560 | ||
1493 | } | 1561 | } |
1494 | 1562 | ||
1495 | #ifndef KORG_NOPLUGINS | 1563 | #ifndef KORG_NOPLUGINS |
1496 | bool showHoliday = KOPrefs::instance()->mExcludeHolidays && | 1564 | bool showHoliday = KOPrefs::instance()->mExcludeHolidays && |
1497 | !KOCore::self()->holiday(date).isEmpty(); | 1565 | !KOCore::self()->holiday(date).isEmpty(); |
1498 | #endif | 1566 | #endif |
1499 | bool showDay = showSaturday || showSunday || showHoliday; | 1567 | bool showDay = showSaturday || showSunday || showHoliday; |
1500 | 1568 | ||
1501 | if (showDay) { | 1569 | if (showDay) { |
1502 | mHolidayMask.at(i) = true; | 1570 | mHolidayMask.at(i) = true; |
1503 | } else { | 1571 | } else { |
1504 | mHolidayMask.at(i) = false; | 1572 | mHolidayMask.at(i) = false; |
1505 | } | 1573 | } |
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index b8a0f09..8affe50 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp | |||
@@ -2,973 +2,973 @@ | |||
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> | 3 | Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> |
4 | Parts of the source code have been copied from kdpdatebutton.cpp | 4 | Parts of the source code have been copied from kdpdatebutton.cpp |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source ode for Qt in the source distribution. | 22 | without including the source ode for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <qevent.h> | 25 | #include <qevent.h> |
26 | #include <qpainter.h> | 26 | #include <qpainter.h> |
27 | #include <qptrlist.h> | 27 | #include <qptrlist.h> |
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | #include <qwhatsthis.h> | 29 | #include <qwhatsthis.h> |
30 | 30 | ||
31 | #include <kglobal.h> | 31 | #include <kglobal.h> |
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | 34 | ||
35 | #include <libkcal/vcaldrag.h> | 35 | #include <libkcal/vcaldrag.h> |
36 | #include <libkcal/icaldrag.h> | 36 | #include <libkcal/icaldrag.h> |
37 | #include <libkcal/dndfactory.h> | 37 | #include <libkcal/dndfactory.h> |
38 | #include <libkcal/calendarresources.h> | 38 | #include <libkcal/calendarresources.h> |
39 | #include <libkcal/resourcecalendar.h> | 39 | #include <libkcal/resourcecalendar.h> |
40 | #include <kresources/resourceselectdialog.h> | 40 | #include <kresources/resourceselectdialog.h> |
41 | 41 | ||
42 | #include <kcalendarsystem.h> | 42 | #include <kcalendarsystem.h> |
43 | 43 | ||
44 | #ifndef KORG_NOPLUGINS | 44 | #ifndef KORG_NOPLUGINS |
45 | #include "kocore.h" | 45 | #include "kocore.h" |
46 | #endif | 46 | #endif |
47 | #include "koprefs.h" | 47 | #include "koprefs.h" |
48 | #include "koglobals.h" | 48 | #include "koglobals.h" |
49 | 49 | ||
50 | #include "kodaymatrix.h" | 50 | #include "kodaymatrix.h" |
51 | 51 | ||
52 | // ============================================================================ | 52 | // ============================================================================ |
53 | // D Y N A M I C T I P | 53 | // D Y N A M I C T I P |
54 | // ============================================================================ | 54 | // ============================================================================ |
55 | 55 | ||
56 | DynamicTip::DynamicTip( QWidget * parent ) | 56 | DynamicTip::DynamicTip( QWidget * parent ) |
57 | : QToolTip( parent ) | 57 | : QToolTip( parent ) |
58 | { | 58 | { |
59 | matrix = (KODayMatrix*)parent; | 59 | matrix = (KODayMatrix*)parent; |
60 | } | 60 | } |
61 | 61 | ||
62 | class KODaymatrixWhatsThis :public QWhatsThis | 62 | class KODaymatrixWhatsThis :public QWhatsThis |
63 | { | 63 | { |
64 | public: | 64 | public: |
65 | KODaymatrixWhatsThis( KODayMatrix* view ) : QWhatsThis( view ),_view (view) { ;}; | 65 | KODaymatrixWhatsThis( KODayMatrix* view ) : QWhatsThis( view ),_view (view) { ;}; |
66 | ~KODaymatrixWhatsThis() { ; }; | 66 | ~KODaymatrixWhatsThis() { ; }; |
67 | 67 | ||
68 | protected: | 68 | protected: |
69 | virtual QString text( const QPoint& p ) | 69 | virtual QString text( const QPoint& p ) |
70 | { | 70 | { |
71 | return _view->getWhatsThisText( p ) ; | 71 | return _view->getWhatsThisText( p ) ; |
72 | } | 72 | } |
73 | private: | 73 | private: |
74 | KODayMatrix * _view; | 74 | KODayMatrix * _view; |
75 | }; | 75 | }; |
76 | 76 | ||
77 | void DynamicTip::maybeTip( const QPoint &pos ) | 77 | void DynamicTip::maybeTip( const QPoint &pos ) |
78 | { | 78 | { |
79 | //calculate which cell of the matrix the mouse is in | 79 | //calculate which cell of the matrix the mouse is in |
80 | QRect sz = matrix->frameRect(); | 80 | QRect sz = matrix->frameRect(); |
81 | int dheight = sz.height()*7 / 42; | 81 | int dheight = sz.height()*7 / 42; |
82 | int dwidth = sz.width() / 7; | 82 | int dwidth = sz.width() / 7; |
83 | int row = pos.y()/dheight; | 83 | int row = pos.y()/dheight; |
84 | int col = pos.x()/dwidth; | 84 | int col = pos.x()/dwidth; |
85 | 85 | ||
86 | QRect rct(col*dwidth, row*dheight, dwidth, dheight); | 86 | QRect rct(col*dwidth, row*dheight, dwidth, dheight); |
87 | 87 | ||
88 | // kdDebug() << "DynamicTip::maybeTip matrix cell index [" << | 88 | // kdDebug() << "DynamicTip::maybeTip matrix cell index [" << |
89 | // col << "][" << row << "] => " <<(col+row*7) << endl; | 89 | // col << "][" << row << "] => " <<(col+row*7) << endl; |
90 | 90 | ||
91 | //show holiday names only | 91 | //show holiday names only |
92 | QString str = matrix->getHolidayLabel(col+row*7); | 92 | QString str = matrix->getHolidayLabel(col+row*7); |
93 | if (str.isEmpty()) return; | 93 | if (str.isEmpty()) return; |
94 | tip(rct, str); | 94 | tip(rct, str); |
95 | } | 95 | } |
96 | 96 | ||
97 | 97 | ||
98 | // ============================================================================ | 98 | // ============================================================================ |
99 | // K O D A Y M A T R I X | 99 | // K O D A Y M A T R I X |
100 | // ============================================================================ | 100 | // ============================================================================ |
101 | 101 | ||
102 | const int KODayMatrix::NOSELECTION = -1000; | 102 | const int KODayMatrix::NOSELECTION = -1000; |
103 | const int KODayMatrix::NUMDAYS = 42; | 103 | const int KODayMatrix::NUMDAYS = 42; |
104 | 104 | ||
105 | KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) | 105 | KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) |
106 | : QFrame( parent, name , Qt::WRepaintNoErase ), mCalendar( 0 ) | 106 | : QFrame( parent, name , Qt::WRepaintNoErase ), mCalendar( 0 ) |
107 | 107 | ||
108 | #if 0 | 108 | #if 0 |
109 | KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : | 109 | KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : |
110 | QFrame(parent, name) | 110 | QFrame(parent, name) |
111 | #endif | 111 | #endif |
112 | { | 112 | { |
113 | mRedrawNeeded = true; | 113 | mRedrawNeeded = true; |
114 | mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this); | 114 | mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this); |
115 | mPendingUpdateBeforeRepaint = false; | 115 | mPendingUpdateBeforeRepaint = false; |
116 | mouseDown = false; | 116 | mouseDown = false; |
117 | // initialize dynamic arrays | 117 | // initialize dynamic arrays |
118 | bDays.resize ( NUMDAYS ); | 118 | bDays.resize ( NUMDAYS ); |
119 | hDays.resize ( NUMDAYS );; | 119 | hDays.resize ( NUMDAYS );; |
120 | eDays.resize ( NUMDAYS );; | 120 | eDays.resize ( NUMDAYS );; |
121 | days = new QDate[NUMDAYS]; | 121 | days = new QDate[NUMDAYS]; |
122 | daylbls = new QString[NUMDAYS]; | 122 | daylbls = new QString[NUMDAYS]; |
123 | //events = new int[NUMDAYS]; | 123 | //events = new int[NUMDAYS]; |
124 | mToolTip = new DynamicTip(this); | 124 | mToolTip = new DynamicTip(this); |
125 | 125 | ||
126 | // set default values used for drawing the matrix | 126 | // set default values used for drawing the matrix |
127 | mDefaultBackColor = palette().active().base(); | 127 | mDefaultBackColor = palette().active().base(); |
128 | mDefaultTextColor = palette().active().foreground(); | 128 | mDefaultTextColor = palette().active().foreground(); |
129 | mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); | 129 | mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); |
130 | mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); | 130 | mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); |
131 | mSelectedDaysColor = QColor("white"); | 131 | mSelectedDaysColor = QColor("white"); |
132 | mTodayMarginWidth = 2; | 132 | mTodayMarginWidth = 2; |
133 | mSelEnd = mSelStart = NOSELECTION; | 133 | mSelEnd = mSelStart = NOSELECTION; |
134 | 134 | ||
135 | setAcceptDrops(true); | 135 | setAcceptDrops(true); |
136 | //setFont( QFont("Arial", 10) ); | 136 | //setFont( QFont("Arial", 10) ); |
137 | 137 | ||
138 | mUpdateTimer = new QTimer( this ); | 138 | mUpdateTimer = new QTimer( this ); |
139 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); | 139 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); |
140 | mRepaintTimer = new QTimer( this ); | 140 | mRepaintTimer = new QTimer( this ); |
141 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); | 141 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); |
142 | mDayChanged = false; | 142 | mDayChanged = false; |
143 | updateView(); | 143 | updateView(); |
144 | } | 144 | } |
145 | QString KODayMatrix::getWhatsThisText( QPoint p ) | 145 | QString KODayMatrix::getWhatsThisText( QPoint p ) |
146 | { | 146 | { |
147 | 147 | ||
148 | int tmp = getDayIndexFrom(p.x(), p.y()); | 148 | int tmp = getDayIndexFrom(p.x(), p.y()); |
149 | if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar ) | 149 | if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar ) |
150 | return QString(); | 150 | return QString(); |
151 | QDate mDate = days[tmp]; | 151 | QDate mDate = days[tmp]; |
152 | QPtrList<Event> eventlist = mCalendar->events(mDate); | 152 | QPtrList<Event> eventlist = mCalendar->events(mDate); |
153 | Event *event; | 153 | Event *event; |
154 | QStringList mToolTip; | 154 | QStringList mToolTip; |
155 | for(event=eventlist.first();event != 0;event=eventlist.next()) { | 155 | for(event=eventlist.first();event != 0;event=eventlist.next()) { |
156 | QString mToolTipText; | 156 | QString mToolTipText; |
157 | QString text; | 157 | QString text; |
158 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day | 158 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day |
159 | if (event->isMultiDay()) { | 159 | if (event->isMultiDay()) { |
160 | QString prefix = "<->";multiday = 2; | 160 | QString prefix = "<->";multiday = 2; |
161 | QString time; | 161 | QString time; |
162 | if ( event->doesRecur() ) { | 162 | if ( event->doesRecur() ) { |
163 | if ( event->recursOn( mDate) ) { | 163 | if ( event->recursOn( mDate) ) { |
164 | prefix ="->" ;multiday = 1; | 164 | prefix ="->" ;multiday = 1; |
165 | } | 165 | } |
166 | else { | 166 | else { |
167 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 167 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
168 | if ( event->recursOn( mDate.addDays( -days)) ) { | 168 | if ( event->recursOn( mDate.addDays( -days)) ) { |
169 | prefix ="<-" ;multiday = 3; | 169 | prefix ="<-" ;multiday = 3; |
170 | } | 170 | } |
171 | } | 171 | } |
172 | } else { | 172 | } else { |
173 | if (mDate == event->dtStart().date()) { | 173 | if (mDate == event->dtStart().date()) { |
174 | prefix ="->" ;multiday = 1; | 174 | prefix ="->" ;multiday = 1; |
175 | } else if (mDate == event->dtEnd().date()) { | 175 | } else if (mDate == event->dtEnd().date()) { |
176 | prefix ="<-" ;multiday = 3; | 176 | prefix ="<-" ;multiday = 3; |
177 | } | 177 | } |
178 | } | 178 | } |
179 | if ( !event->doesFloat() ) { | 179 | if ( !event->doesFloat() ) { |
180 | if ( mDate == event->dtStart().date () ) | 180 | if ( mDate == event->dtStart().date () ) |
181 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; | 181 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; |
182 | else if ( mDate == event->dtEnd().date () ) | 182 | else if ( mDate == event->dtEnd().date () ) |
183 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; | 183 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; |
184 | 184 | ||
185 | } | 185 | } |
186 | text = time + event->summary(); | 186 | text = time + event->summary(); |
187 | mToolTipText += prefix + text; | 187 | mToolTipText += prefix + text; |
188 | } else { | 188 | } else { |
189 | if (event->doesFloat()) { | 189 | if (event->doesFloat()) { |
190 | text = event->summary(); | 190 | text = event->summary(); |
191 | mToolTipText += text; | 191 | mToolTipText += text; |
192 | } | 192 | } |
193 | else { | 193 | else { |
194 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 194 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
195 | text += " " + event->summary(); | 195 | text += " " + event->summary(); |
196 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 196 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
197 | } | 197 | } |
198 | } | 198 | } |
199 | if ( !event->location().isEmpty() ) | 199 | if ( !event->location().isEmpty() ) |
200 | mToolTipText += " (" + event->location() + ")"; | 200 | mToolTipText += " (" + event->location() + ")"; |
201 | #if QT_VERSION >= 0x030000 | 201 | #if QT_VERSION >= 0x030000 |
202 | mToolTipText.replace( '<' , "<" ); | 202 | mToolTipText.replace( '<' , "<" ); |
203 | mToolTipText.replace( '>' , ">" ); | 203 | mToolTipText.replace( '>' , ">" ); |
204 | #else | 204 | #else |
205 | if ( mToolTipText.find ('<') >= 0 ) { | 205 | if ( mToolTipText.find ('<') >= 0 ) { |
206 | mToolTipText.replace( QRegExp("<") , "<" ); | 206 | mToolTipText.replace( QRegExp("<") , "<" ); |
207 | } | 207 | } |
208 | if ( mToolTipText.find ('>') >= 0 ) { | 208 | if ( mToolTipText.find ('>') >= 0 ) { |
209 | mToolTipText.replace( QRegExp(">") , ">" ); | 209 | mToolTipText.replace( QRegExp(">") , ">" ); |
210 | } | 210 | } |
211 | #endif | 211 | #endif |
212 | //qDebug("TTT: %s ", mToolTipText.latin1()); | 212 | //qDebug("TTT: %s ", mToolTipText.latin1()); |
213 | mToolTip.append( mToolTipText ); | 213 | mToolTip.append( mToolTipText ); |
214 | } | 214 | } |
215 | mToolTip.sort(); | 215 | mToolTip.sort(); |
216 | return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>"); | 216 | return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>"); |
217 | } | 217 | } |
218 | void KODayMatrix::setCalendar( Calendar *cal ) | 218 | void KODayMatrix::setCalendar( Calendar *cal ) |
219 | { | 219 | { |
220 | mCalendar = cal; | 220 | mCalendar = cal; |
221 | 221 | ||
222 | setAcceptDrops( mCalendar ); | 222 | setAcceptDrops( mCalendar ); |
223 | 223 | ||
224 | updateEvents(); | 224 | updateEvents(); |
225 | } | 225 | } |
226 | 226 | ||
227 | QColor KODayMatrix::getShadedColor(QColor color) | 227 | QColor KODayMatrix::getShadedColor(QColor color) |
228 | { | 228 | { |
229 | QColor shaded; | 229 | QColor shaded; |
230 | int h=0; | 230 | int h=0; |
231 | int s=0; | 231 | int s=0; |
232 | int v=0; | 232 | int v=0; |
233 | color.hsv(&h,&s,&v); | 233 | color.hsv(&h,&s,&v); |
234 | s = s/4; | 234 | s = s/4; |
235 | v = 192+v/4; | 235 | v = 192+v/4; |
236 | shaded.setHsv(h,s,v); | 236 | shaded.setHsv(h,s,v); |
237 | 237 | ||
238 | return shaded; | 238 | return shaded; |
239 | } | 239 | } |
240 | 240 | ||
241 | KODayMatrix::~KODayMatrix() | 241 | KODayMatrix::~KODayMatrix() |
242 | { | 242 | { |
243 | // delete mKODaymatrixWhatsThis; | 243 | // delete mKODaymatrixWhatsThis; |
244 | delete [] days; | 244 | delete [] days; |
245 | delete [] daylbls; | 245 | delete [] daylbls; |
246 | //delete [] events; | 246 | //delete [] events; |
247 | delete mToolTip; | 247 | delete mToolTip; |
248 | } | 248 | } |
249 | 249 | ||
250 | /* | 250 | /* |
251 | void KODayMatrix::setStartDate(QDate start) | 251 | void KODayMatrix::setStartDate(QDate start) |
252 | { | 252 | { |
253 | updateView(start); | 253 | updateView(start); |
254 | } | 254 | } |
255 | */ | 255 | */ |
256 | 256 | ||
257 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) | 257 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) |
258 | { | 258 | { |
259 | 259 | ||
260 | if (mSelStart == NOSELECTION) { | 260 | if (mSelStart == NOSELECTION) { |
261 | return; | 261 | return; |
262 | } | 262 | } |
263 | 263 | ||
264 | //cope with selection being out of matrix limits at top (< 0) | 264 | //cope with selection being out of matrix limits at top (< 0) |
265 | int i0 = mSelStart; | 265 | int i0 = mSelStart; |
266 | if (i0 < 0) { | 266 | if (i0 < 0) { |
267 | for (int i = i0; i < 0; i++) { | 267 | for (int i = i0; i < 0; i++) { |
268 | selDays.append(days[0].addDays(i)); | 268 | selDays.append(days[0].addDays(i)); |
269 | } | 269 | } |
270 | i0 = 0; | 270 | i0 = 0; |
271 | } | 271 | } |
272 | 272 | ||
273 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) | 273 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) |
274 | if (mSelEnd > NUMDAYS-1) { | 274 | if (mSelEnd > NUMDAYS-1) { |
275 | for (int i = i0; i <= NUMDAYS-1; i++) { | 275 | for (int i = i0; i <= NUMDAYS-1; i++) { |
276 | selDays.append(days[i]); | 276 | selDays.append(days[i]); |
277 | } | 277 | } |
278 | for (int i = NUMDAYS; i < mSelEnd; i++) { | 278 | for (int i = NUMDAYS; i < mSelEnd; i++) { |
279 | selDays.append(days[0].addDays(i)); | 279 | selDays.append(days[0].addDays(i)); |
280 | } | 280 | } |
281 | 281 | ||
282 | // apply normal routine to selection being entirely within matrix limits | 282 | // apply normal routine to selection being entirely within matrix limits |
283 | } else { | 283 | } else { |
284 | for (int i = i0; i <= mSelEnd; i++) { | 284 | for (int i = i0; i <= mSelEnd; i++) { |
285 | selDays.append(days[i]); | 285 | selDays.append(days[i]); |
286 | } | 286 | } |
287 | } | 287 | } |
288 | } | 288 | } |
289 | 289 | ||
290 | bool KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) | 290 | bool KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) |
291 | { | 291 | { |
292 | mRedrawNeeded = true; | 292 | mRedrawNeeded = true; |
293 | bool noSel = (mSelEnd == NOSELECTION && mSelStart == NOSELECTION ); | 293 | bool noSel = (mSelEnd == NOSELECTION && mSelStart == NOSELECTION ); |
294 | mSelStart = startdate.daysTo(start); | 294 | mSelStart = startdate.daysTo(start); |
295 | if ( mSelStart < 0 ) | 295 | if ( mSelStart < 0 ) |
296 | mSelStart = 0; | 296 | mSelStart = 0; |
297 | mSelEnd = startdate.daysTo(end); | 297 | mSelEnd = startdate.daysTo(end); |
298 | if ( mSelEnd > NUMDAYS-1 ) | 298 | if ( mSelEnd > NUMDAYS-1 ) |
299 | mSelEnd = NUMDAYS-1; | 299 | mSelEnd = NUMDAYS-1; |
300 | if ( mSelEnd < 0 || mSelStart > NUMDAYS-1 ) { | 300 | if ( mSelEnd < 0 || mSelStart > NUMDAYS-1 ) { |
301 | clearSelection(); | 301 | clearSelection(); |
302 | if ( noSel ) | 302 | if ( noSel ) |
303 | return false; | 303 | return false; |
304 | } | 304 | } |
305 | 305 | ||
306 | return true; | 306 | return true; |
307 | } | 307 | } |
308 | void KODayMatrix::clearSelection() | 308 | void KODayMatrix::clearSelection() |
309 | { | 309 | { |
310 | mSelEnd = mSelStart = NOSELECTION; | 310 | mSelEnd = mSelStart = NOSELECTION; |
311 | } | 311 | } |
312 | 312 | ||
313 | 313 | ||
314 | void KODayMatrix::recalculateToday() | 314 | void KODayMatrix::recalculateToday() |
315 | { | 315 | { |
316 | today = -1; | 316 | today = -1; |
317 | for (int i=0; i<NUMDAYS; i++) { | 317 | for (int i=0; i<NUMDAYS; i++) { |
318 | //events[i] = 0; | 318 | //events[i] = 0; |
319 | days[i] = startdate.addDays(i); | 319 | days[i] = startdate.addDays(i); |
320 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); | 320 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); |
321 | 321 | ||
322 | // if today is in the currently displayed month, hilight today | 322 | // if today is in the currently displayed month, hilight today |
323 | if (days[i].year() == QDate::currentDate().year() && | 323 | if (days[i].year() == QDate::currentDate().year() && |
324 | days[i].month() == QDate::currentDate().month() && | 324 | days[i].month() == QDate::currentDate().month() && |
325 | days[i].day() == QDate::currentDate().day()) { | 325 | days[i].day() == QDate::currentDate().day()) { |
326 | today = i; | 326 | today = i; |
327 | } | 327 | } |
328 | } | 328 | } |
329 | // qDebug(QString("Today is visible at %1.").arg(today)); | 329 | // qDebug(QString("Today is visible at %1.").arg(today)); |
330 | } | 330 | } |
331 | 331 | ||
332 | void KODayMatrix::updateView() | 332 | void KODayMatrix::updateView() |
333 | { | 333 | { |
334 | updateView(startdate); | 334 | updateView(startdate); |
335 | } | 335 | } |
336 | void KODayMatrix::repaintViewTimed() | 336 | void KODayMatrix::repaintViewTimed() |
337 | { | 337 | { |
338 | mRepaintTimer->stop(); | 338 | mRepaintTimer->stop(); |
339 | repaint(false); | 339 | repaint(false); |
340 | } | 340 | } |
341 | void KODayMatrix::updateViewTimed() | 341 | void KODayMatrix::updateViewTimed() |
342 | { | 342 | { |
343 | mUpdateTimer->stop(); | 343 | mUpdateTimer->stop(); |
344 | if ( !mCalendar ) { | 344 | if ( !mCalendar ) { |
345 | qDebug("NOT CAL "); | 345 | qDebug("NOT CAL "); |
346 | return; | 346 | return; |
347 | } | 347 | } |
348 | //qDebug("KODayMatrix::updateViewTimed "); | 348 | //qDebug("KODayMatrix::updateViewTimed "); |
349 | for(int i = 0; i < NUMDAYS; i++) { | 349 | for(int i = 0; i < NUMDAYS; i++) { |
350 | // if events are set for the day then remember to draw it bold | 350 | // if events are set for the day then remember to draw it bold |
351 | QPtrList<Event> eventlist = mCalendar->events(days[i]); | 351 | QPtrList<Event> eventlist = mCalendar->events(days[i]); |
352 | Event *event; | 352 | Event *event; |
353 | int numEvents = eventlist.count(); | 353 | int numEvents = eventlist.count(); |
354 | QString holiStr = ""; | 354 | QString holiStr = ""; |
355 | bDays.clearBit(i); | 355 | bDays.clearBit(i); |
356 | hDays.clearBit(i); | 356 | hDays.clearBit(i); |
357 | eDays.clearBit(i); | 357 | eDays.clearBit(i); |
358 | for(event=eventlist.first();event != 0;event=eventlist.next()) { | 358 | for(event=eventlist.first();event != 0;event=eventlist.next()) { |
359 | ushort recurType = event->recurrence()->doesRecur(); | 359 | ushort recurType = event->recurrence()->doesRecur(); |
360 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || | 360 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || |
361 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { | 361 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { |
362 | numEvents--; | 362 | numEvents--; |
363 | } | 363 | } |
364 | if ( event->isHoliday()) { | 364 | if ( event->isHoliday()) { |
365 | hDays.setBit(i); | 365 | hDays.setBit(i); |
366 | if ( !holiStr.isEmpty() ) | 366 | if ( !holiStr.isEmpty() ) |
367 | holiStr += "\n"; | 367 | holiStr += "\n"; |
368 | holiStr += event->summary(); | 368 | holiStr += event->summary(); |
369 | if ( !event->location().isEmpty() ) | 369 | if ( !event->location().isEmpty() ) |
370 | holiStr += " (" + event->location() + ")"; | 370 | holiStr += " (" + event->location() + ")"; |
371 | } | 371 | } |
372 | if ( event->isBirthday()) { | 372 | if ( event->isBirthday()) { |
373 | if ( !holiStr.isEmpty() ) | 373 | if ( !holiStr.isEmpty() ) |
374 | holiStr += "\n"; | 374 | holiStr += "\n"; |
375 | holiStr += i18n("Birthday") + ": "+event->summary(); | 375 | holiStr += i18n("Birthday") + ": "+event->summary(); |
376 | if ( !event->location().isEmpty() ) | 376 | if ( !event->location().isEmpty() ) |
377 | holiStr += " (" + event->location() + ")"; | 377 | holiStr += " (" + event->location() + ")"; |
378 | bDays.setBit(i); | 378 | bDays.setBit(i); |
379 | } | 379 | } |
380 | } | 380 | } |
381 | if ( numEvents ) | 381 | if ( numEvents ) |
382 | eDays.setBit(i); | 382 | eDays.setBit(i); |
383 | //if it is a holy day then draw it red. Sundays are consider holidays, too | 383 | //if it is a holy day then draw it red. Sundays are consider holidays, too |
384 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || | 384 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || |
385 | !holiStr.isEmpty()) { | 385 | !holiStr.isEmpty()) { |
386 | mHolidays[i] = holiStr; | 386 | mHolidays[i] = holiStr; |
387 | } else { | 387 | } else { |
388 | mHolidays[i] = QString::null; | 388 | mHolidays[i] = QString::null; |
389 | } | 389 | } |
390 | } | 390 | } |
391 | mRedrawNeeded = true; | 391 | mRedrawNeeded = true; |
392 | if ( ! mPendingUpdateBeforeRepaint ) | 392 | if ( ! mPendingUpdateBeforeRepaint ) |
393 | repaint(false); | 393 | repaint(false); |
394 | } | 394 | } |
395 | void KODayMatrix::updateView(QDate actdate) | 395 | void KODayMatrix::updateView(QDate actdate) |
396 | { | 396 | { |
397 | 397 | ||
398 | if ( ! actdate.isValid() ) { | 398 | if ( ! actdate.isValid() ) { |
399 | //qDebug("date not valid "); | 399 | //qDebug("date not valid "); |
400 | return; | 400 | return; |
401 | } | 401 | } |
402 | mDayChanged = false; | 402 | mDayChanged = false; |
403 | //flag to indicate if the starting day of the matrix has changed by this call | 403 | //flag to indicate if the starting day of the matrix has changed by this call |
404 | //mDayChanged = false; | 404 | //mDayChanged = false; |
405 | // if a new startdate is to be set then apply Cornelius's calculation | 405 | // if a new startdate is to be set then apply Cornelius's calculation |
406 | // of the first day to be shown | 406 | // of the first day to be shown |
407 | if (actdate != startdate) { | 407 | if (actdate != startdate) { |
408 | // reset index of selection according to shift of starting date from startdate to actdate | 408 | // reset index of selection according to shift of starting date from startdate to actdate |
409 | if (mSelStart != NOSELECTION) { | 409 | if (mSelStart != NOSELECTION) { |
410 | int tmp = actdate.daysTo(startdate); | 410 | int tmp = actdate.daysTo(startdate); |
411 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; | 411 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; |
412 | // shift selection if new one would be visible at least partly ! | 412 | // shift selection if new one would be visible at least partly ! |
413 | 413 | ||
414 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { | 414 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { |
415 | // nested if is required for next X display pushed from a different month - correction required | 415 | // nested if is required for next X display pushed from a different month - correction required |
416 | // otherwise, for month forward and backward, it must be avoided | 416 | // otherwise, for month forward and backward, it must be avoided |
417 | if( mSelStart > NUMDAYS || mSelStart < 0 ) | 417 | if( mSelStart > NUMDAYS || mSelStart < 0 ) |
418 | mSelStart = mSelStart + tmp; | 418 | mSelStart = mSelStart + tmp; |
419 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) | 419 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) |
420 | mSelEnd = mSelEnd + tmp; | 420 | mSelEnd = mSelEnd + tmp; |
421 | } | 421 | } |
422 | } | 422 | } |
423 | startdate = actdate; | 423 | startdate = actdate; |
424 | mDayChanged = true; | 424 | mDayChanged = true; |
425 | recalculateToday(); | 425 | recalculateToday(); |
426 | mRedrawNeeded = true; | 426 | mRedrawNeeded = true; |
427 | } | 427 | } |
428 | //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); | 428 | //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); |
429 | if ( !isVisible() ) { | 429 | if ( !isVisible() ) { |
430 | mPendingUpdateBeforeRepaint = true; | 430 | mPendingUpdateBeforeRepaint = true; |
431 | } else { | 431 | } else { |
432 | #ifdef DESKTOP_VERSION | 432 | #ifdef DESKTOP_VERSION |
433 | //mRepaintTimer->start( 100 ); | 433 | //mRepaintTimer->start( 100 ); |
434 | //updateViewTimed(); | 434 | //updateViewTimed(); |
435 | mUpdateTimer->start( 50 ); | 435 | mUpdateTimer->start( 50 ); |
436 | #else | 436 | #else |
437 | mRepaintTimer->start( 350 ); | 437 | mRepaintTimer->start( 350 ); |
438 | mUpdateTimer->start( 1200 ); | 438 | mUpdateTimer->start( 1200 ); |
439 | #endif | 439 | #endif |
440 | } | 440 | } |
441 | } | 441 | } |
442 | void KODayMatrix::updateEvents() | 442 | void KODayMatrix::updateEvents() |
443 | { | 443 | { |
444 | if ( !mCalendar ) return; | 444 | if ( !mCalendar ) return; |
445 | 445 | ||
446 | for( int i = 0; i < NUMDAYS; i++ ) { | 446 | for( int i = 0; i < NUMDAYS; i++ ) { |
447 | // if events are set for the day then remember to draw it bold | 447 | // if events are set for the day then remember to draw it bold |
448 | QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); | 448 | QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); |
449 | int numEvents = eventlist.count(); | 449 | int numEvents = eventlist.count(); |
450 | Event *event; | 450 | Event *event; |
451 | for( event = eventlist.first(); event != 0;event=eventlist.next()) { | 451 | for( event = eventlist.first(); event != 0;event=eventlist.next()) { |
452 | ushort recurType = event->doesRecur(); | 452 | ushort recurType = event->doesRecur(); |
453 | 453 | ||
454 | if ( ( recurType == Recurrence::rDaily && | 454 | if ( ( recurType == Recurrence::rDaily && |
455 | !KOPrefs::instance()->mDailyRecur ) || | 455 | !KOPrefs::instance()->mDailyRecur ) || |
456 | ( recurType == Recurrence::rWeekly && | 456 | ( recurType == Recurrence::rWeekly && |
457 | !KOPrefs::instance()->mWeeklyRecur ) ) { | 457 | !KOPrefs::instance()->mWeeklyRecur ) ) { |
458 | numEvents--; | 458 | numEvents--; |
459 | } | 459 | } |
460 | } | 460 | } |
461 | if ( numEvents ) | 461 | if ( numEvents ) |
462 | eDays.setBit(i); | 462 | eDays.setBit(i); |
463 | else | 463 | else |
464 | eDays.clearBit(i); | 464 | eDays.clearBit(i); |
465 | } | 465 | } |
466 | } | 466 | } |
467 | 467 | ||
468 | const QDate& KODayMatrix::getDate(int offset) | 468 | const QDate& KODayMatrix::getDate(int offset) |
469 | { | 469 | { |
470 | if (offset < 0 || offset > NUMDAYS-1) { | 470 | if (offset < 0 || offset > NUMDAYS-1) { |
471 | qDebug("Wrong offset2 %d", offset); | 471 | qDebug("Wrong offset2 %d", offset); |
472 | return days[0]; | 472 | return days[0]; |
473 | } | 473 | } |
474 | return days[offset]; | 474 | return days[offset]; |
475 | } | 475 | } |
476 | 476 | ||
477 | QString KODayMatrix::getHolidayLabel(int offset) | 477 | QString KODayMatrix::getHolidayLabel(int offset) |
478 | { | 478 | { |
479 | if (offset < 0 || offset > NUMDAYS-1) { | 479 | if (offset < 0 || offset > NUMDAYS-1) { |
480 | qDebug("Wrong offset1 %d", offset); | 480 | qDebug("Wrong offset1 %d", offset); |
481 | return QString(); | 481 | return QString(); |
482 | } | 482 | } |
483 | return mHolidays[offset]; | 483 | return mHolidays[offset]; |
484 | } | 484 | } |
485 | 485 | ||
486 | int KODayMatrix::getDayIndexFrom(int x, int y) | 486 | int KODayMatrix::getDayIndexFrom(int x, int y) |
487 | { | 487 | { |
488 | int colModulo = (width()-2) % 7; | 488 | int colModulo = (width()-2) % 7; |
489 | int rowModulo = (height()-2) % 6; | 489 | int rowModulo = (height()-2) % 6; |
490 | #if 0 | 490 | #if 0 |
491 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? | 491 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? |
492 | 6 - x/daysize.width() : x/daysize.width()); | 492 | 6 - x/daysize.width() : x/daysize.width()); |
493 | #endif | 493 | #endif |
494 | int xVal = (x-colModulo/2-2)/daysize.width(); | 494 | int xVal = (x-colModulo/2-2)/daysize.width(); |
495 | int yVal = (y-rowModulo/2-2)/daysize.height(); | 495 | int yVal = (y-rowModulo/2-2)/daysize.height(); |
496 | 496 | ||
497 | 497 | ||
498 | return 7*(yVal) + xVal; | 498 | return 7*(yVal) + xVal; |
499 | 499 | ||
500 | } | 500 | } |
501 | 501 | ||
502 | // ---------------------------------------------------------------------------- | 502 | // ---------------------------------------------------------------------------- |
503 | // M O U S E E V E N T H A N D L I N G | 503 | // M O U S E E V E N T H A N D L I N G |
504 | // ---------------------------------------------------------------------------- | 504 | // ---------------------------------------------------------------------------- |
505 | 505 | ||
506 | void KODayMatrix::mousePressEvent (QMouseEvent* e) | 506 | void KODayMatrix::mousePressEvent (QMouseEvent* e) |
507 | { | 507 | { |
508 | 508 | ||
509 | if ( e->button() == LeftButton ) | 509 | if ( e->button() == LeftButton ) |
510 | mouseDown = true; | 510 | mouseDown = true; |
511 | mSelStart = getDayIndexFrom(e->x(), e->y()); | 511 | mSelStart = getDayIndexFrom(e->x(), e->y()); |
512 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; | 512 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; |
513 | mSelInit = mSelStart; | 513 | mSelInit = mSelStart; |
514 | mSelEnd = mSelStart; | 514 | mSelEnd = mSelStart; |
515 | mRedrawNeeded = true; | 515 | mRedrawNeeded = true; |
516 | repaint(false); | 516 | repaint(false); |
517 | } | 517 | } |
518 | 518 | ||
519 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) | 519 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) |
520 | { | 520 | { |
521 | mRedrawNeeded = true; | 521 | mRedrawNeeded = true; |
522 | if ( e->button() == LeftButton ) | 522 | if ( e->button() == LeftButton ) |
523 | if ( ! mouseDown ) { | 523 | if ( ! mouseDown ) { |
524 | return; | 524 | return; |
525 | } | 525 | } |
526 | else | 526 | else |
527 | mouseDown = false; | 527 | mouseDown = false; |
528 | int tmp = getDayIndexFrom(e->x(), e->y()); | 528 | int tmp = getDayIndexFrom(e->x(), e->y()); |
529 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 529 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
530 | 530 | ||
531 | if (mSelInit > tmp) { | 531 | if (mSelInit > tmp) { |
532 | mSelEnd = mSelInit; | 532 | mSelEnd = mSelInit; |
533 | if (tmp != mSelStart) { | 533 | if (tmp != mSelStart) { |
534 | mSelStart = tmp; | 534 | mSelStart = tmp; |
535 | repaint(false); | 535 | repaint(false); |
536 | } | 536 | } |
537 | } else { | 537 | } else { |
538 | mSelStart = mSelInit; | 538 | mSelStart = mSelInit; |
539 | 539 | ||
540 | //repaint only if selection has changed | 540 | //repaint only if selection has changed |
541 | if (tmp != mSelEnd) { | 541 | if (tmp != mSelEnd) { |
542 | mSelEnd = tmp; | 542 | mSelEnd = tmp; |
543 | repaint(false); | 543 | repaint(false); |
544 | } | 544 | } |
545 | } | 545 | } |
546 | 546 | ||
547 | DateList daylist; | 547 | DateList daylist; |
548 | if ( mSelStart < 0 ) | 548 | if ( mSelStart < 0 ) |
549 | mSelStart = 0; | 549 | mSelStart = 0; |
550 | for (int i = mSelStart; i <= mSelEnd; i++) { | 550 | for (int i = mSelStart; i <= mSelEnd; i++) { |
551 | daylist.append(days[i]); | 551 | daylist.append(days[i]); |
552 | } | 552 | } |
553 | emit selected((const DateList)daylist); | 553 | emit selected((const DateList)daylist); |
554 | 554 | ||
555 | } | 555 | } |
556 | 556 | ||
557 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) | 557 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) |
558 | { | 558 | { |
559 | if ( ! mouseDown ) { | 559 | if ( ! mouseDown ) { |
560 | return; | 560 | return; |
561 | } | 561 | } |
562 | mRedrawNeeded = true; | 562 | mRedrawNeeded = true; |
563 | int tmp = getDayIndexFrom(e->x(), e->y()); | 563 | int tmp = getDayIndexFrom(e->x(), e->y()); |
564 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 564 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
565 | 565 | ||
566 | if (mSelInit > tmp) { | 566 | if (mSelInit > tmp) { |
567 | mSelEnd = mSelInit; | 567 | mSelEnd = mSelInit; |
568 | if (tmp != mSelStart) { | 568 | if (tmp != mSelStart) { |
569 | mSelStart = tmp; | 569 | mSelStart = tmp; |
570 | repaint(false); | 570 | repaint(false); |
571 | } | 571 | } |
572 | } else { | 572 | } else { |
573 | mSelStart = mSelInit; | 573 | mSelStart = mSelInit; |
574 | 574 | ||
575 | //repaint only if selection has changed | 575 | //repaint only if selection has changed |
576 | if (tmp != mSelEnd) { | 576 | if (tmp != mSelEnd) { |
577 | mSelEnd = tmp; | 577 | mSelEnd = tmp; |
578 | repaint(false); | 578 | repaint(false); |
579 | } | 579 | } |
580 | } | 580 | } |
581 | } | 581 | } |
582 | 582 | ||
583 | // ---------------------------------------------------------------------------- | 583 | // ---------------------------------------------------------------------------- |
584 | // D R A G ' N D R O P H A N D L I N G | 584 | // D R A G ' N D R O P H A N D L I N G |
585 | // ---------------------------------------------------------------------------- | 585 | // ---------------------------------------------------------------------------- |
586 | 586 | ||
587 | void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) | 587 | void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) |
588 | { | 588 | { |
589 | #ifndef KORG_NODND | 589 | #ifndef KORG_NODND |
590 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 590 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
591 | e->ignore(); | 591 | e->ignore(); |
592 | return; | 592 | return; |
593 | } | 593 | } |
594 | 594 | ||
595 | // some visual feedback | 595 | // some visual feedback |
596 | // oldPalette = palette(); | 596 | // oldPalette = palette(); |
597 | // setPalette(my_HilitePalette); | 597 | // setPalette(my_HilitePalette); |
598 | // update(); | 598 | // update(); |
599 | #endif | 599 | #endif |
600 | } | 600 | } |
601 | 601 | ||
602 | void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) | 602 | void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) |
603 | { | 603 | { |
604 | #ifndef KORG_NODND | 604 | #ifndef KORG_NODND |
605 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 605 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
606 | e->ignore(); | 606 | e->ignore(); |
607 | return; | 607 | return; |
608 | } | 608 | } |
609 | 609 | ||
610 | e->accept(); | 610 | e->accept(); |
611 | #endif | 611 | #endif |
612 | } | 612 | } |
613 | 613 | ||
614 | void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) | 614 | void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) |
615 | { | 615 | { |
616 | #ifndef KORG_NODND | 616 | #ifndef KORG_NODND |
617 | // setPalette(oldPalette); | 617 | // setPalette(oldPalette); |
618 | // update(); | 618 | // update(); |
619 | #endif | 619 | #endif |
620 | } | 620 | } |
621 | 621 | ||
622 | void KODayMatrix::dropEvent(QDropEvent *e) | 622 | void KODayMatrix::dropEvent(QDropEvent *e) |
623 | { | 623 | { |
624 | #ifndef KORG_NODND | 624 | #ifndef KORG_NODND |
625 | // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; | 625 | // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; |
626 | 626 | ||
627 | if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 627 | if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
628 | e->ignore(); | 628 | e->ignore(); |
629 | return; | 629 | return; |
630 | } | 630 | } |
631 | 631 | ||
632 | DndFactory factory( mCalendar ); | 632 | DndFactory factory( mCalendar ); |
633 | Event *event = factory.createDrop(e); | 633 | Event *event = factory.createDrop(e); |
634 | 634 | ||
635 | if (event) { | 635 | if (event) { |
636 | e->acceptAction(); | 636 | e->acceptAction(); |
637 | 637 | ||
638 | Event *existingEvent = mCalendar->event(event->uid()); | 638 | Event *existingEvent = mCalendar->event(event->uid()); |
639 | 639 | ||
640 | if(existingEvent) { | 640 | if(existingEvent) { |
641 | // uniquify event | 641 | // uniquify event |
642 | event->recreate(); | 642 | event->recreate(); |
643 | /* | 643 | /* |
644 | KMessageBox::sorry(this, | 644 | KMessageBox::sorry(this, |
645 | i18n("Event already exists in this calendar."), | 645 | i18n("Event already exists in this calendar."), |
646 | i18n("Drop Event")); | 646 | i18n("Drop Event")); |
647 | delete event; | 647 | delete event; |
648 | return; | 648 | return; |
649 | */ | 649 | */ |
650 | } | 650 | } |
651 | // kdDebug() << "Drop new Event" << endl; | 651 | // kdDebug() << "Drop new Event" << endl; |
652 | // Adjust date | 652 | // Adjust date |
653 | QDateTime start = event->dtStart(); | 653 | QDateTime start = event->dtStart(); |
654 | QDateTime end = event->dtEnd(); | 654 | QDateTime end = event->dtEnd(); |
655 | int duration = start.daysTo(end); | 655 | int duration = start.daysTo(end); |
656 | int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); | 656 | int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); |
657 | 657 | ||
658 | start.setDate(days[idx]); | 658 | start.setDate(days[idx]); |
659 | end.setDate(days[idx].addDays(duration)); | 659 | end.setDate(days[idx].addDays(duration)); |
660 | 660 | ||
661 | event->setDtStart(start); | 661 | event->setDtStart(start); |
662 | event->setDtEnd(end); | 662 | event->setDtEnd(end); |
663 | mCalendar->addEvent(event); | 663 | mCalendar->addEvent(event); |
664 | 664 | ||
665 | emit eventDropped(event); | 665 | emit eventDropped(event); |
666 | } else { | 666 | } else { |
667 | // kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; | 667 | // kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; |
668 | e->ignore(); | 668 | e->ignore(); |
669 | } | 669 | } |
670 | #endif | 670 | #endif |
671 | } | 671 | } |
672 | 672 | ||
673 | // ---------------------------------------------------------------------------- | 673 | // ---------------------------------------------------------------------------- |
674 | // P A I N T E V E N T H A N D L I N G | 674 | // P A I N T E V E N T H A N D L I N G |
675 | // ---------------------------------------------------------------------------- | 675 | // ---------------------------------------------------------------------------- |
676 | 676 | ||
677 | void KODayMatrix::paintEvent(QPaintEvent * pevent) | 677 | void KODayMatrix::paintEvent(QPaintEvent * pevent) |
678 | { | 678 | { |
679 | 679 | ||
680 | if ( width() <= 0 || height() <= 0 ) | 680 | if ( width() <= 0 || height() <= 0 ) |
681 | return; | 681 | return; |
682 | if ( mPendingUpdateBeforeRepaint ) { | 682 | if ( mPendingUpdateBeforeRepaint ) { |
683 | updateViewTimed(); | 683 | updateViewTimed(); |
684 | mPendingUpdateBeforeRepaint = false; | 684 | mPendingUpdateBeforeRepaint = false; |
685 | } | 685 | } |
686 | if ( myPix.width() != width() || myPix.height()!=height() ) { | 686 | if ( myPix.width() != width() || myPix.height()!=height() ) { |
687 | myPix.resize(size() ); | 687 | myPix.resize(size() ); |
688 | mRedrawNeeded = true; | 688 | mRedrawNeeded = true; |
689 | } | 689 | } |
690 | 690 | ||
691 | if ( mRedrawNeeded ) { | 691 | if ( mRedrawNeeded ) { |
692 | //qDebug("REDRAW "); | 692 | //qDebug("REDRAW "); |
693 | QPainter p(&myPix); | 693 | QPainter p(&myPix); |
694 | p.setFont(font()); | 694 | p.setFont(font()); |
695 | 695 | ||
696 | 696 | ||
697 | int dheight = daysize.height(); | 697 | int dheight = daysize.height(); |
698 | int dwidth = daysize.width(); | 698 | int dwidth = daysize.width(); |
699 | int row,col; | 699 | int row,col; |
700 | int selw, selh; | 700 | int selw, selh; |
701 | int xyOff = frameWidth(); | 701 | int xyOff = frameWidth(); |
702 | int colModulo = (width()-2) % 7; | 702 | int colModulo = (width()-2) % 7; |
703 | int rowModulo = (height()-2) % 6; | 703 | int rowModulo = (height()-2) % 6; |
704 | //qDebug("col %d row %d ",colModulo,rowModulo ); | 704 | //qDebug("col %d row %d ",colModulo,rowModulo ); |
705 | 705 | ||
706 | bool isRTL = KOGlobals::self()->reverseLayout(); | 706 | bool isRTL = KOGlobals::self()->reverseLayout(); |
707 | 707 | ||
708 | // draw background and topleft frame | 708 | // draw background and topleft frame |
709 | p.fillRect(0,0,width(),height(), mDefaultBackColor); | 709 | p.fillRect(0,0,width(),height(), mDefaultBackColor); |
710 | p.setPen(mDefaultTextColor); | 710 | p.setPen(mDefaultTextColor); |
711 | p.drawRect(0, 0, width(), height()); | 711 | p.drawRect(0, 0, width(), height()); |
712 | int mSelStartT = mSelStart; | 712 | int mSelStartT = mSelStart; |
713 | int mSelEndT = mSelEnd; | 713 | int mSelEndT = mSelEnd; |
714 | if ( mSelEndT >= NUMDAYS ) | 714 | if ( mSelEndT >= NUMDAYS ) |
715 | mSelEndT = NUMDAYS-1; | 715 | mSelEndT = NUMDAYS-1; |
716 | // draw selected days with highlighted background color | 716 | // draw selected days with highlighted background color |
717 | if (mSelStart != NOSELECTION) { | 717 | if (mSelStart != NOSELECTION) { |
718 | bool skip = false; | 718 | bool skip = false; |
719 | if ( ! mouseDown ) { | 719 | if ( ! mouseDown ) { |
720 | int mo = days[20].month(); | 720 | int mo = days[20].month(); |
721 | //qDebug("-- %d %d ", mSelStartT, mSelEndT); | 721 | //qDebug("-- %d %d ", mSelStartT, mSelEndT); |
722 | //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() ); | 722 | //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() ); |
723 | int startMo = days[mSelStartT].month(); | 723 | int startMo = days[mSelStartT].month(); |
724 | int endMo = days[mSelEndT].month(); | 724 | int endMo = days[mSelEndT].month(); |
725 | if ( startMo == 12 && mo == 1 && endMo <= 2 ) | 725 | if ( startMo == 12 && mo == 1 && endMo <= 2 ) |
726 | startMo = 1; | 726 | startMo = 1; |
727 | if ( endMo == 1 && mo == 12 ) | 727 | if ( endMo == 1 && mo == 12 ) |
728 | endMo = 12; | 728 | endMo = 12; |
729 | if ( mo == 12 && startMo == 1 ) | 729 | if ( mo == 12 && startMo == 1 ) |
730 | startMo = 13; | 730 | startMo = 13; |
731 | if ( (startMo > mo || endMo < mo) ) { | 731 | if ( (startMo > mo || endMo < mo) ) { |
732 | skip = true; | 732 | skip = true; |
733 | } else { | 733 | } else { |
734 | if ( days[mSelStartT].month() != mo ) { | 734 | if ( days[mSelStartT].month() != mo ) { |
735 | int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day(); | 735 | int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day(); |
736 | mSelStartT += add +1; | 736 | mSelStartT += add +1; |
737 | } | 737 | } |
738 | if ( days[mSelEndT].month() != mo ) { | 738 | if ( days[mSelEndT].month() != mo ) { |
739 | int sub = days[mSelEndT].day(); | 739 | int sub = days[mSelEndT].day(); |
740 | mSelEndT -= sub ; | 740 | mSelEndT -= sub ; |
741 | } | 741 | } |
742 | } | 742 | } |
743 | } | 743 | } |
744 | //qDebug("SKIP %d ", skip); | 744 | //qDebug("SKIP %d ", skip); |
745 | if ( ! skip ) { | 745 | if ( ! skip ) { |
746 | row = mSelStartT/7; | 746 | row = mSelStartT/7; |
747 | col = mSelStartT -row*7; | 747 | col = mSelStartT -row*7; |
748 | QColor selcol = KOPrefs::instance()->mHighlightColor; | 748 | QColor selcol = KOPrefs::instance()->mHighlightColor; |
749 | int addCol = 0; | 749 | int addCol = 0; |
750 | int addRow = 0; | 750 | int addRow = 0; |
751 | int addRow2 = 0; | 751 | int addRow2 = 0; |
752 | int addCol2 = 0; | 752 | int addCol2 = 0; |
753 | if (row == mSelEndT/7) { | 753 | if (row == mSelEndT/7) { |
754 | if ( rowModulo ) { | 754 | if ( rowModulo ) { |
755 | if ( row >= 6 - rowModulo ) | 755 | if ( row >= 6 - rowModulo ) |
756 | addRow = row - 5 + rowModulo; | 756 | addRow = row - 5 + rowModulo; |
757 | } | 757 | } |
758 | if ( colModulo ) { | 758 | if ( colModulo ) { |
759 | int colt1 = mSelEndT%7; | 759 | int colt1 = mSelEndT%7; |
760 | //qDebug("colt1 %d ", colt1 ); | 760 | //qDebug("colt1 %d ", colt1 ); |
761 | if ( colt1 >= 7 - colModulo ) | 761 | if ( colt1 >= 7 - colModulo ) |
762 | addCol = colt1 - 7 + colModulo+1; | 762 | addCol = colt1 - 7 + colModulo+1; |
763 | int colt = mSelStartT%7; | 763 | int colt = mSelStartT%7; |
764 | if ( colt >= 7 - colModulo ) | 764 | if ( colt >= 7 - colModulo ) |
765 | addCol2 = colt - 7 + colModulo; | 765 | addCol2 = colt - 7 + colModulo; |
766 | addCol -= addCol2; | 766 | addCol -= addCol2; |
767 | //qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 ); | 767 | //qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 ); |
768 | } | 768 | } |
769 | // Single row selection | 769 | // Single row selection |
770 | if ( row == 0) | 770 | //if ( row == 0) |
771 | addRow = 1; | 771 | // addRow = 1; |
772 | p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2, | 772 | p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2, |
773 | row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol); | 773 | row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol); |
774 | } else { | 774 | } else { |
775 | // draw first row to the right | 775 | // draw first row to the right |
776 | if ( colModulo ) { | 776 | if ( colModulo ) { |
777 | if ( col >= 7 - colModulo ) | 777 | if ( col >= 7 - colModulo ) |
778 | addCol2 = col - 7 + colModulo; | 778 | addCol2 = col - 7 + colModulo; |
779 | } | 779 | } |
780 | if ( rowModulo ) { | 780 | if ( rowModulo ) { |
781 | if ( row >= 6 - rowModulo ) | 781 | if ( row >= 6 - rowModulo ) |
782 | addRow = row - 5 + rowModulo; | 782 | addRow = row - 5 + rowModulo; |
783 | } | 783 | } |
784 | if ( row == 0) | 784 | //if ( row == 0) |
785 | addRow = 1; | 785 | // addRow = 1; |
786 | int drawWid = width()-(col*dwidth+1+addCol2)-1; | 786 | int drawWid = width()-(col*dwidth+1+addCol2)-1; |
787 | p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, drawWid, | 787 | p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, drawWid, |
788 | dheight+1, selcol); | 788 | dheight+1, selcol); |
789 | // draw full block till last line | 789 | // draw full block till last line |
790 | selh = mSelEndT/7-row; | 790 | selh = mSelEndT/7-row; |
791 | addRow = 0; | 791 | addRow = 0; |
792 | if ( rowModulo ) { | 792 | if ( rowModulo ) { |
793 | if ( mSelEndT/7 >= 6 - rowModulo ) | 793 | if ( mSelEndT/7 >= 6 - rowModulo ) |
794 | addRow = mSelEndT/7 - 5 + rowModulo; | 794 | addRow = mSelEndT/7 - 5 + rowModulo; |
795 | } | 795 | } |
796 | //qDebug("%d %d %d ",selh, row, addRow ); | 796 | //qDebug("%d %d %d ",selh, row, addRow ); |
797 | int addrow2 = addRow-selh+1; | 797 | int addrow2 = addRow-selh+1; |
798 | if ( addrow2 < 0 ) | 798 | if ( addrow2 < 0 ) |
799 | addrow2 = 0; | 799 | addrow2 = 0; |
800 | if (selh > 1) { | 800 | if (selh > 1) { |
801 | p.fillRect(1, (row+1)*dheight+addrow2, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol); | 801 | p.fillRect(1, (row+1)*dheight+addrow2, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol); |
802 | } | 802 | } |
803 | // draw last block from left to mSelEndT | 803 | // draw last block from left to mSelEndT |
804 | selw = mSelEndT-7*(mSelEndT/7)+1; | 804 | selw = mSelEndT-7*(mSelEndT/7)+1; |
805 | //qDebug("esl %d ",selw ); | 805 | //qDebug("esl %d ",selw ); |
806 | int add = 0; | 806 | int add = 0; |
807 | if ( colModulo ) { | 807 | if ( colModulo ) { |
808 | add = 7 - colModulo; | 808 | add = 7 - colModulo; |
809 | if ( selw > add ) | 809 | if ( selw > add ) |
810 | add = selw - add; | 810 | add = selw - add; |
811 | else | 811 | else |
812 | add = 0; | 812 | add = 0; |
813 | } | 813 | } |
814 | //qDebug("add %d ", add); | 814 | //qDebug("add %d ", add); |
815 | p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow, | 815 | p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow, |
816 | selw*dwidth+add, dheight+1, selcol); | 816 | selw*dwidth+add, dheight+1, selcol); |
817 | } | 817 | } |
818 | } | 818 | } |
819 | } | 819 | } |
820 | 820 | ||
821 | // iterate over all days in the matrix and draw the day label in appropriate colors | 821 | // iterate over all days in the matrix and draw the day label in appropriate colors |
822 | QColor actcol = mDefaultTextColorShaded; | 822 | QColor actcol = mDefaultTextColorShaded; |
823 | p.setPen(actcol); | 823 | p.setPen(actcol); |
824 | QPen tmppen; | 824 | QPen tmppen; |
825 | for(int i = 0; i < NUMDAYS; i++) { | 825 | for(int i = 0; i < NUMDAYS; i++) { |
826 | row = i/7; | 826 | row = i/7; |
827 | col = isRTL ? 6-(i-row*7) : i-row*7; | 827 | col = isRTL ? 6-(i-row*7) : i-row*7; |
828 | 828 | ||
829 | // if it is the first day of a month switch color from normal to shaded and vice versa | 829 | // if it is the first day of a month switch color from normal to shaded and vice versa |
830 | if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { | 830 | if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { |
831 | if (actcol == mDefaultTextColorShaded) { | 831 | if (actcol == mDefaultTextColorShaded) { |
832 | actcol = mDefaultTextColor; | 832 | actcol = mDefaultTextColor; |
833 | } else { | 833 | } else { |
834 | actcol = mDefaultTextColorShaded; | 834 | actcol = mDefaultTextColorShaded; |
835 | } | 835 | } |
836 | p.setPen(actcol); | 836 | p.setPen(actcol); |
837 | } | 837 | } |
838 | if (actcol == mDefaultTextColorShaded) { | 838 | if (actcol == mDefaultTextColorShaded) { |
839 | if ( ! mouseDown ) { | 839 | if ( ! mouseDown ) { |
840 | continue; | 840 | continue; |
841 | } | 841 | } |
842 | } | 842 | } |
843 | //Reset pen color after selected days block | 843 | //Reset pen color after selected days block |
844 | if (i == mSelEndT+1) { | 844 | if (i == mSelEndT+1) { |
845 | p.setPen(actcol); | 845 | p.setPen(actcol); |
846 | } | 846 | } |
847 | 847 | ||
848 | // if today then draw rectangle around day | 848 | // if today then draw rectangle around day |
849 | if (today == i) { | 849 | if (today == i) { |
850 | tmppen = p.pen(); | 850 | tmppen = p.pen(); |
851 | QPen mTodayPen(p.pen()); | 851 | QPen mTodayPen(p.pen()); |
852 | if ( daysize.width() < 20 ) | 852 | if ( daysize.width() < 20 ) |
853 | mTodayPen.setWidth(1); | 853 | mTodayPen.setWidth(1); |
854 | else | 854 | else |
855 | mTodayPen.setWidth(mTodayMarginWidth); | 855 | mTodayPen.setWidth(mTodayMarginWidth); |
856 | //draw red rectangle for holidays | 856 | //draw red rectangle for holidays |
857 | if (!mHolidays[i].isNull()) { | 857 | if (!mHolidays[i].isNull()) { |
858 | if (actcol == mDefaultTextColor) { | 858 | if (actcol == mDefaultTextColor) { |
859 | mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); | 859 | mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); |
860 | } else { | 860 | } else { |
861 | mTodayPen.setColor(mHolidayColorShaded); | 861 | mTodayPen.setColor(mHolidayColorShaded); |
862 | } | 862 | } |
863 | } | 863 | } |
864 | //draw gray rectangle for today if in selection | 864 | //draw gray rectangle for today if in selection |
865 | if (i >= mSelStartT && i <= mSelEndT) { | 865 | if (i >= mSelStartT && i <= mSelEndT) { |
866 | QColor grey("grey"); | 866 | QColor grey("grey"); |
867 | mTodayPen.setColor(grey); | 867 | mTodayPen.setColor(grey); |
868 | } | 868 | } |
869 | p.setPen(mTodayPen); | 869 | p.setPen(mTodayPen); |
870 | 870 | ||
871 | 871 | ||
872 | int addCol = 0; | 872 | int addCol = 0; |
873 | int addRow = 0; | 873 | int addRow = 0; |
874 | if (rowModulo) { | 874 | if (rowModulo) { |
875 | if ( row >= 6 - rowModulo ) | 875 | if ( row >= 6 - rowModulo ) |
876 | addRow = row - 5 + rowModulo; | 876 | addRow = row - 5 + rowModulo; |
877 | } | 877 | } |
878 | if ( colModulo ) { | 878 | if ( colModulo ) { |
879 | if ( col >= 7 - colModulo ) | 879 | if ( col >= 7 - colModulo ) |
880 | addCol = col - 6 + colModulo-1; | 880 | addCol = col - 6 + colModulo-1; |
881 | } | 881 | } |
882 | 882 | ||
883 | addCol += 1; | 883 | addCol += 1; |
884 | if ( row == 0 ) | 884 | if ( row == 0 ) |
885 | addRow = 1; | 885 | addRow = 1; |
886 | p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth+1, dheight+1); | 886 | p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth+1, dheight+1); |
887 | p.setPen(tmppen); | 887 | p.setPen(tmppen); |
888 | } | 888 | } |
889 | 889 | ||
890 | // if any events are on that day then draw it using a bold font | 890 | // if any events are on that day then draw it using a bold font |
891 | if ( eDays.testBit(i) ) { | 891 | if ( eDays.testBit(i) ) { |
892 | QFont myFont = font(); | 892 | QFont myFont = font(); |
893 | myFont.setBold(true); | 893 | myFont.setBold(true); |
894 | p.setFont(myFont); | 894 | p.setFont(myFont); |
895 | } | 895 | } |
896 | 896 | ||
897 | // if it is a holiday then use the default holiday color | 897 | // if it is a holiday then use the default holiday color |
898 | if ( !mHolidays[i].isNull()) { | 898 | if ( !mHolidays[i].isNull()) { |
899 | if ( bDays.testBit(i) ) { | 899 | if ( bDays.testBit(i) ) { |
900 | if ( hDays.testBit(i) ) | 900 | if ( hDays.testBit(i) ) |
901 | p.setPen(QColor(Qt::green)); | 901 | p.setPen(QColor(Qt::green)); |
902 | else | 902 | else |
903 | p.setPen(QColor(Qt::green).dark()); | 903 | p.setPen(QColor(Qt::green).dark()); |
904 | } else { | 904 | } else { |
905 | if (actcol == mDefaultTextColor ) { | 905 | if (actcol == mDefaultTextColor ) { |
906 | p.setPen(KOPrefs::instance()->mHolidayColor); | 906 | p.setPen(KOPrefs::instance()->mHolidayColor); |
907 | } else { | 907 | } else { |
908 | p.setPen(mHolidayColorShaded); | 908 | p.setPen(mHolidayColorShaded); |
909 | } | 909 | } |
910 | } | 910 | } |
911 | } | 911 | } |
912 | 912 | ||
913 | // draw selected days with special color | 913 | // draw selected days with special color |
914 | // DO NOT specially highlight holidays in selection ! | 914 | // DO NOT specially highlight holidays in selection ! |
915 | if (i >= mSelStartT && i <= mSelEndT) { | 915 | if (i >= mSelStartT && i <= mSelEndT) { |
916 | ;//p.setPen(mSelectedDaysColor); | 916 | ;//p.setPen(mSelectedDaysColor); |
917 | } | 917 | } |
918 | 918 | ||
919 | int addCol = 0; | 919 | int addCol = 0; |
920 | int addRow = 0; | 920 | int addRow = 0; |
921 | if ( colModulo ) { | 921 | if ( colModulo ) { |
922 | if ( col >= 7 - colModulo ) | 922 | if ( col >= 7 - colModulo ) |
923 | addCol = col - 7 + colModulo; | 923 | addCol = col - 7 + colModulo; |
924 | } | 924 | } |
925 | if ( rowModulo ) { | 925 | if ( rowModulo ) { |
926 | if ( row >= 6 - rowModulo ) | 926 | if ( row >= 6 - rowModulo ) |
927 | addRow = row - 5 + rowModulo; | 927 | addRow = row - 5 + rowModulo; |
928 | } | 928 | } |
929 | //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow); | 929 | //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow); |
930 | ++addCol;//++addCol; | 930 | ++addCol;//++addCol; |
931 | if ( row == 0) | 931 | if ( row == 0) |
932 | addRow = 1; | 932 | addRow = 1; |
933 | p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight, | 933 | p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight, |
934 | Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); | 934 | Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); |
935 | 935 | ||
936 | // reset color to actual color | 936 | // reset color to actual color |
937 | if (!mHolidays[i].isNull()) { | 937 | if (!mHolidays[i].isNull()) { |
938 | p.setPen(actcol); | 938 | p.setPen(actcol); |
939 | } | 939 | } |
940 | // reset bold font to plain font | 940 | // reset bold font to plain font |
941 | if ( eDays.testBit(i)) { | 941 | if ( eDays.testBit(i)) { |
942 | QFont myFont = font(); | 942 | QFont myFont = font(); |
943 | myFont.setBold(false); | 943 | myFont.setBold(false); |
944 | p.setFont(myFont); | 944 | p.setFont(myFont); |
945 | } | 945 | } |
946 | } | 946 | } |
947 | } else { | 947 | } else { |
948 | //qDebug("NO redraw "); | 948 | //qDebug("NO redraw "); |
949 | } | 949 | } |
950 | bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); | 950 | bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); |
951 | mRedrawNeeded = false; | 951 | mRedrawNeeded = false; |
952 | } | 952 | } |
953 | 953 | ||
954 | // ---------------------------------------------------------------------------- | 954 | // ---------------------------------------------------------------------------- |
955 | // R E SI Z E E V E N T H A N D L I N G | 955 | // R E SI Z E E V E N T H A N D L I N G |
956 | // ---------------------------------------------------------------------------- | 956 | // ---------------------------------------------------------------------------- |
957 | 957 | ||
958 | void KODayMatrix::resizeEvent(QResizeEvent *) | 958 | void KODayMatrix::resizeEvent(QResizeEvent *) |
959 | { | 959 | { |
960 | QRect sz = frameRect(); | 960 | QRect sz = frameRect(); |
961 | daysize.setHeight(sz.height()*7 / NUMDAYS); | 961 | daysize.setHeight(sz.height()*7 / NUMDAYS); |
962 | daysize.setWidth(sz.width() / 7); | 962 | daysize.setWidth(sz.width() / 7); |
963 | } | 963 | } |
964 | 964 | ||
965 | QSize KODayMatrix::sizeHint() const | 965 | QSize KODayMatrix::sizeHint() const |
966 | { | 966 | { |
967 | 967 | ||
968 | QFontMetrics fm ( font() ); | 968 | QFontMetrics fm ( font() ); |
969 | int wid = fm.width( "30") *7+3; | 969 | int wid = fm.width( "30") *7+3; |
970 | int hei = fm.height() * 6+3; | 970 | int hei = fm.height() * 6+3; |
971 | //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei); | 971 | //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei); |
972 | return QSize ( wid, hei ); | 972 | return QSize ( wid, hei ); |
973 | 973 | ||
974 | } | 974 | } |
diff --git a/microkde/KDGanttMinimizeSplitter.cpp b/microkde/KDGanttMinimizeSplitter.cpp index 253175e..2a30346 100644 --- a/microkde/KDGanttMinimizeSplitter.cpp +++ b/microkde/KDGanttMinimizeSplitter.cpp | |||
@@ -1,1459 +1,1455 @@ | |||
1 | /* -*- Mode: C++ -*- | 1 | /* -*- Mode: C++ -*- |
2 | $Id$ | 2 | $Id$ |
3 | */ | 3 | */ |
4 | 4 | ||
5 | /**************************************************************************** | 5 | /**************************************************************************** |
6 | ** Copyright (C) 2002-2004 Klarälvdalens Datakonsult AB. All rights reserved. | 6 | ** Copyright (C) 2002-2004 Klarälvdalens Datakonsult AB. All rights reserved. |
7 | ** | 7 | ** |
8 | ** This file is part of the KDGantt library. | 8 | ** This file is part of the KDGantt library. |
9 | ** | 9 | ** |
10 | ** This file may be distributed and/or modified under the terms of the | 10 | ** This file may be distributed and/or modified under the terms of the |
11 | ** GNU General Public License version 2 as published by the Free Software | 11 | ** GNU General Public License version 2 as published by the Free Software |
12 | ** Foundation and appearing in the file LICENSE.GPL included in the | 12 | ** Foundation and appearing in the file LICENSE.GPL included in the |
13 | ** packaging of this file. | 13 | ** packaging of this file. |
14 | ** | 14 | ** |
15 | ** Licensees holding valid commercial KDGantt licenses may use this file in | 15 | ** Licensees holding valid commercial KDGantt licenses may use this file in |
16 | ** accordance with the KDGantt Commercial License Agreement provided with | 16 | ** accordance with the KDGantt Commercial License Agreement provided with |
17 | ** the Software. | 17 | ** the Software. |
18 | ** | 18 | ** |
19 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 19 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
20 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 20 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
21 | ** | 21 | ** |
22 | ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for | 22 | ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for |
23 | ** information about KDGantt Commercial License Agreements. | 23 | ** information about KDGantt Commercial License Agreements. |
24 | ** | 24 | ** |
25 | ** Contact info@klaralvdalens-datakonsult.se if any conditions of this | 25 | ** Contact info@klaralvdalens-datakonsult.se if any conditions of this |
26 | ** licensing are not clear to you. | 26 | ** licensing are not clear to you. |
27 | ** | 27 | ** |
28 | ** As a special exception, permission is given to link this program | 28 | ** As a special exception, permission is given to link this program |
29 | ** with any edition of Qt, and distribute the resulting executable, | 29 | ** with any edition of Qt, and distribute the resulting executable, |
30 | ** without including the source code for Qt in the source distribution. | 30 | ** without including the source code for Qt in the source distribution. |
31 | ** | 31 | ** |
32 | **********************************************************************/ | 32 | **********************************************************************/ |
33 | 33 | ||
34 | #include "KDGanttMinimizeSplitter.h" | 34 | #include "KDGanttMinimizeSplitter.h" |
35 | #ifndef QT_NO_SPLITTER___ | 35 | #ifndef QT_NO_SPLITTER___ |
36 | 36 | ||
37 | #include "qpainter.h" | 37 | #include "qpainter.h" |
38 | #include "qdrawutil.h" | 38 | #include "qdrawutil.h" |
39 | #include "qbitmap.h" | 39 | #include "qbitmap.h" |
40 | #if QT_VERSION >= 0x030000 | 40 | #if QT_VERSION >= 0x030000 |
41 | #include "qptrlist.h" | 41 | #include "qptrlist.h" |
42 | #include "qmemarray.h" | 42 | #include "qmemarray.h" |
43 | #else | 43 | #else |
44 | #include <qlist.h> | 44 | #include <qlist.h> |
45 | #include <qarray.h> | 45 | #include <qarray.h> |
46 | #define QPtrList QList | 46 | #define QPtrList QList |
47 | #define QMemArray QArray | 47 | #define QMemArray QArray |
48 | #endif | 48 | #endif |
49 | #include "qlayoutengine_p.h" | 49 | #include "qlayoutengine_p.h" |
50 | #include "qobjectlist.h" | 50 | #include "qobjectlist.h" |
51 | #include "qstyle.h" | 51 | #include "qstyle.h" |
52 | #include "qapplication.h" //sendPostedEvents | 52 | #include "qapplication.h" //sendPostedEvents |
53 | #include <qvaluelist.h> | 53 | #include <qvaluelist.h> |
54 | #include <qcursor.h> | 54 | #include <qcursor.h> |
55 | #ifndef KDGANTT_MASTER_CVS | 55 | #ifndef KDGANTT_MASTER_CVS |
56 | //#include "KDGanttMinimizeSplitter.moc" | 56 | //#include "KDGanttMinimizeSplitter.moc" |
57 | #endif | 57 | #endif |
58 | 58 | ||
59 | 59 | ||
60 | 60 | ||
61 | #ifndef DOXYGEN_SKIP_INTERNAL | 61 | #ifndef DOXYGEN_SKIP_INTERNAL |
62 | 62 | ||
63 | #if QT_VERSION >= 232 | 63 | #if QT_VERSION >= 232 |
64 | static int mouseOffset; | 64 | static int mouseOffset; |
65 | static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit risky | 65 | static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit risky |
66 | 66 | ||
67 | 67 | ||
68 | KDGanttSplitterHandle::KDGanttSplitterHandle( Qt::Orientation o, | 68 | KDGanttSplitterHandle::KDGanttSplitterHandle( Qt::Orientation o, |
69 | KDGanttMinimizeSplitter *parent, const char * name ) | 69 | KDGanttMinimizeSplitter *parent, const char * name ) |
70 | : QWidget( parent, name ), _activeButton( 0 ), _collapsed( false ) | 70 | : QWidget( parent, name ), _activeButton( 0 ), _collapsed( false ) |
71 | { | 71 | { |
72 | 72 | ||
73 | if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->width() < 650 ) { | 73 | if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->width() < 650 ) { |
74 | mSizeHint = QSize(7,7); | 74 | mSizeHint = QSize(7,7); |
75 | mUseOffset = true; | 75 | mUseOffset = true; |
76 | } else { | 76 | } else { |
77 | mSizeHint = QSize(6,6); | 77 | mSizeHint = QSize(6,6); |
78 | mUseOffset = false; | 78 | mUseOffset = false; |
79 | } | 79 | } |
80 | s = parent; | 80 | s = parent; |
81 | setOrientation(o); | 81 | setOrientation(o); |
82 | setMouseTracking( true ); | 82 | setMouseTracking( true ); |
83 | mMouseDown = false; | 83 | mMouseDown = false; |
84 | //setMaximumHeight( 5 ); // test only | 84 | //setMaximumHeight( 5 ); // test only |
85 | } | 85 | } |
86 | 86 | ||
87 | QSize KDGanttSplitterHandle::sizeHint() const | 87 | QSize KDGanttSplitterHandle::sizeHint() const |
88 | { | 88 | { |
89 | return mSizeHint; | 89 | return mSizeHint; |
90 | } | 90 | } |
91 | 91 | ||
92 | void KDGanttSplitterHandle::setOrientation( Qt::Orientation o ) | 92 | void KDGanttSplitterHandle::setOrientation( Qt::Orientation o ) |
93 | { | 93 | { |
94 | orient = o; | 94 | orient = o; |
95 | #ifndef QT_NO_CURSOR | 95 | #ifndef QT_NO_CURSOR |
96 | if ( o == KDGanttMinimizeSplitter::Horizontal ) | 96 | if ( o == KDGanttMinimizeSplitter::Horizontal ) |
97 | setCursor( splitHCursor ); | 97 | setCursor( splitHCursor ); |
98 | else | 98 | else |
99 | setCursor( splitVCursor ); | 99 | setCursor( splitVCursor ); |
100 | #endif | 100 | #endif |
101 | } | 101 | } |
102 | 102 | ||
103 | 103 | ||
104 | void KDGanttSplitterHandle::mouseMoveEvent( QMouseEvent *e ) | 104 | void KDGanttSplitterHandle::mouseMoveEvent( QMouseEvent *e ) |
105 | { | 105 | { |
106 | updateCursor( e->pos() ); | 106 | updateCursor( e->pos() ); |
107 | if ( !(e->state()&LeftButton) ) | 107 | if ( !(e->state()&LeftButton) ) |
108 | return; | 108 | return; |
109 | 109 | ||
110 | if ( _activeButton != 0) | 110 | if ( _activeButton != 0) |
111 | return; | 111 | return; |
112 | 112 | ||
113 | QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) | 113 | QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) |
114 | - mouseOffset; | 114 | - mouseOffset; |
115 | if ( opaque() ) { | 115 | if ( opaque() ) { |
116 | s->moveSplitter( pos, id() ); | 116 | s->moveSplitter( pos, id() ); |
117 | } else { | 117 | } else { |
118 | int min = pos; int max = pos; | 118 | int min = pos; int max = pos; |
119 | s->getRange( id(), &min, &max ); | 119 | s->getRange( id(), &min, &max ); |
120 | s->setRubberband( QMAX( min, QMIN(max, pos ))); | 120 | s->setRubberband( QMAX( min, QMIN(max, pos ))); |
121 | } | 121 | } |
122 | _collapsed = false; | 122 | _collapsed = false; |
123 | } | 123 | } |
124 | 124 | ||
125 | void KDGanttSplitterHandle::mousePressEvent( QMouseEvent *e ) | 125 | void KDGanttSplitterHandle::mousePressEvent( QMouseEvent *e ) |
126 | { | 126 | { |
127 | if ( e->button() == LeftButton ) { | 127 | if ( e->button() == LeftButton ) { |
128 | _activeButton = onButton( e->pos() ); | 128 | _activeButton = onButton( e->pos() ); |
129 | mouseOffset = s->pick(e->pos()); | 129 | mouseOffset = s->pick(e->pos()); |
130 | mMouseDown = true; | 130 | mMouseDown = true; |
131 | repaint(); | 131 | repaint(); |
132 | updateCursor( e->pos() ); | 132 | updateCursor( e->pos() ); |
133 | } | 133 | } |
134 | } | 134 | } |
135 | 135 | ||
136 | void KDGanttSplitterHandle::updateCursor( const QPoint& p) | 136 | void KDGanttSplitterHandle::updateCursor( const QPoint& p) |
137 | { | 137 | { |
138 | if ( onButton( p ) != 0 ) { | 138 | if ( onButton( p ) != 0 ) { |
139 | setCursor( arrowCursor ); | 139 | setCursor( arrowCursor ); |
140 | } | 140 | } |
141 | else { | 141 | else { |
142 | if ( orient == KDGanttMinimizeSplitter::Horizontal ) | 142 | if ( orient == KDGanttMinimizeSplitter::Horizontal ) |
143 | setCursor( splitHCursor ); | 143 | setCursor( splitHCursor ); |
144 | else | 144 | else |
145 | setCursor( splitVCursor ); | 145 | setCursor( splitVCursor ); |
146 | } | 146 | } |
147 | } | 147 | } |
148 | void KDGanttSplitterHandle::toggle() | 148 | void KDGanttSplitterHandle::toggle() |
149 | { | 149 | { |
150 | int pos; | 150 | int pos; |
151 | int min, max; | 151 | int min, max; |
152 | if ( !_collapsed ) { | 152 | if ( !_collapsed ) { |
153 | s->expandPos( id(), &min, &max ); | 153 | s->expandPos( id(), &min, &max ); |
154 | if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left | 154 | if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left |
155 | || s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { | 155 | || s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { |
156 | pos = min; | 156 | pos = min; |
157 | } | 157 | } |
158 | else { | 158 | else { |
159 | pos = max; | 159 | pos = max; |
160 | } | 160 | } |
161 | 161 | ||
162 | _origPos = s->pick(mapToParent( QPoint( 0,0 ) )); | 162 | _origPos = s->pick(mapToParent( QPoint( 0,0 ) )); |
163 | s->moveSplitter( pos, id() ); | 163 | s->moveSplitter( pos, id() ); |
164 | _collapsed = true; | 164 | _collapsed = true; |
165 | } | 165 | } |
166 | else { | 166 | else { |
167 | s->moveSplitter( _origPos, id() ); | 167 | s->moveSplitter( _origPos, id() ); |
168 | _collapsed = false; | 168 | _collapsed = false; |
169 | } | 169 | } |
170 | repaint(); | 170 | repaint(); |
171 | } | 171 | } |
172 | 172 | ||
173 | void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e ) | 173 | void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e ) |
174 | { | 174 | { |
175 | mMouseDown = false; | 175 | mMouseDown = false; |
176 | if ( _activeButton != 0 ) { | 176 | if ( _activeButton != 0 ) { |
177 | if ( onButton( e->pos() ) == _activeButton ) | 177 | if ( onButton( e->pos() ) == _activeButton ) |
178 | { | 178 | { |
179 | toggle(); | 179 | toggle(); |
180 | } | 180 | } |
181 | _activeButton = 0; | 181 | _activeButton = 0; |
182 | updateCursor( e->pos() ); | 182 | updateCursor( e->pos() ); |
183 | } | 183 | } |
184 | else { | 184 | else { |
185 | if ( !opaque() && e->button() == LeftButton ) { | 185 | if ( !opaque() && e->button() == LeftButton ) { |
186 | QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) | 186 | QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) |
187 | - mouseOffset; | 187 | - mouseOffset; |
188 | s->setRubberband( -1 ); | 188 | s->setRubberband( -1 ); |
189 | s->moveSplitter( pos, id() ); | 189 | s->moveSplitter( pos, id() ); |
190 | } | 190 | } |
191 | } | 191 | } |
192 | if ( s->rubberBand() ) | 192 | if ( s->rubberBand() ) |
193 | s->rubberBand()->hide(); | 193 | s->rubberBand()->hide(); |
194 | repaint(); | 194 | repaint(); |
195 | } | 195 | } |
196 | 196 | ||
197 | int KDGanttSplitterHandle::onButton( const QPoint& p ) | 197 | int KDGanttSplitterHandle::onButton( const QPoint& p ) |
198 | { | 198 | { |
199 | QValueList<QPointArray> list = buttonRegions(); | 199 | QValueList<QPointArray> list = buttonRegions(); |
200 | int index = 1; | 200 | int index = 1; |
201 | int add = 12; | 201 | int add = 12; |
202 | for( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { | 202 | for( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { |
203 | QRect rect = (*it).boundingRect(); | 203 | QRect rect = (*it).boundingRect(); |
204 | rect.setLeft( rect.left()- add ); | 204 | rect.setLeft( rect.left()- add ); |
205 | rect.setRight( rect.right() + add); | 205 | rect.setRight( rect.right() + add); |
206 | rect.setTop( rect.top()- add ); | 206 | rect.setTop( rect.top()- add ); |
207 | rect.setBottom( rect.bottom() + add); | 207 | rect.setBottom( rect.bottom() + add); |
208 | if ( rect.contains( p ) ) { | 208 | if ( rect.contains( p ) ) { |
209 | return index; | 209 | return index; |
210 | } | 210 | } |
211 | index++; | 211 | index++; |
212 | } | 212 | } |
213 | return 0; | 213 | return 0; |
214 | } | 214 | } |
215 | 215 | ||
216 | 216 | ||
217 | QValueList<QPointArray> KDGanttSplitterHandle::buttonRegions() | 217 | QValueList<QPointArray> KDGanttSplitterHandle::buttonRegions() |
218 | { | 218 | { |
219 | QValueList<QPointArray> list; | 219 | QValueList<QPointArray> list; |
220 | 220 | ||
221 | int sw = 8; | 221 | int sw = 8; |
222 | int yyy = 1; | 222 | int yyy = 1; |
223 | int xxx = 1; | 223 | int xxx = 1; |
224 | int voffset[] = { (int) -sw*3, (int) sw*3 }; | 224 | int voffset[] = { (int) -sw*3, (int) sw*3 }; |
225 | for ( int i = 0; i < 2; i++ ) { | 225 | for ( int i = 0; i < 2; i++ ) { |
226 | QPointArray arr; | 226 | QPointArray arr; |
227 | if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right || | 227 | if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right || |
228 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left) { | 228 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left) { |
229 | int mid = height()/2 + voffset[i]; | 229 | int mid = height()/2 + voffset[i]; |
230 | arr.setPoints( 3, | 230 | arr.setPoints( 3, |
231 | 1-xxx, mid - sw + 4, | 231 | 1-xxx, mid - sw + 4, |
232 | sw-3-xxx, mid, | 232 | sw-3-xxx, mid, |
233 | 1-xxx, mid + sw -4); | 233 | 1-xxx, mid + sw -4); |
234 | } | 234 | } |
235 | else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left || | 235 | else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left || |
236 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { | 236 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { |
237 | int mid = height()/2 + voffset[i]; | 237 | int mid = height()/2 + voffset[i]; |
238 | arr.setPoints( 3, | 238 | arr.setPoints( 3, |
239 | sw-4, mid - sw + 4, | 239 | sw-4, mid - sw + 4, |
240 | 0, mid, | 240 | 0, mid, |
241 | sw-4, mid + sw - 4); | 241 | sw-4, mid + sw - 4); |
242 | } | 242 | } |
243 | else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up || | 243 | else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up || |
244 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down) { | 244 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down) { |
245 | int mid = width()/2 + voffset[i]; | 245 | int mid = width()/2 + voffset[i]; |
246 | arr.setPoints( 3, | 246 | arr.setPoints( 3, |
247 | mid - sw + 4, sw-4, | 247 | mid - sw + 4, sw-4, |
248 | mid, 0, | 248 | mid, 0, |
249 | mid + sw - 4, sw-4 ); | 249 | mid + sw - 4, sw-4 ); |
250 | } | 250 | } |
251 | else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down || | 251 | else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down || |
252 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { | 252 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { |
253 | int mid = width()/2 + voffset[i]; | 253 | int mid = width()/2 + voffset[i]; |
254 | arr.setPoints( 3, | 254 | arr.setPoints( 3, |
255 | mid - sw + 4, 1-yyy, | 255 | mid - sw + 4, 1-yyy, |
256 | mid, sw-3-yyy, | 256 | mid, sw-3-yyy, |
257 | mid + sw -4, 1-yyy); | 257 | mid + sw -4, 1-yyy); |
258 | } | 258 | } |
259 | list.append( arr ); | 259 | list.append( arr ); |
260 | } | 260 | } |
261 | return list; | 261 | return list; |
262 | } | 262 | } |
263 | 263 | ||
264 | void KDGanttSplitterHandle::paintEvent( QPaintEvent * ) | 264 | void KDGanttSplitterHandle::paintEvent( QPaintEvent * ) |
265 | { | 265 | { |
266 | QPixmap buffer( size() ); | 266 | QPixmap buffer( size() ); |
267 | QPainter p( &buffer ); | 267 | QPainter p( &buffer ); |
268 | 268 | ||
269 | //LR | 269 | //LR |
270 | // Draw the splitter rectangle | 270 | // Draw the splitter rectangle |
271 | p.setBrush( colorGroup().background() ); | 271 | p.setBrush( colorGroup().background() ); |
272 | p.setPen( colorGroup().foreground() ); | 272 | p.setPen( colorGroup().foreground() ); |
273 | //p.drawRect( rect() ); | 273 | //p.drawRect( rect() ); |
274 | #ifndef DESKTOP_VERSION | 274 | #ifndef DESKTOP_VERSION |
275 | if ( mMouseDown ) | 275 | if ( mMouseDown ) |
276 | buffer.fill( QColor( 242,27,255 ) ); | 276 | buffer.fill( colorGroup().background().dark() ); |
277 | else | 277 | else |
278 | #endif | 278 | #endif |
279 | buffer.fill( colorGroup().background() ); | 279 | buffer.fill( colorGroup().background() ); |
280 | //buffer.fill( backgroundColor() ); | 280 | //buffer.fill( backgroundColor() ); |
281 | // parentWidget()->style().drawPrimitive( QStyle::PE_Panel, &p, rect(), parentWidget()->colorGroup()); | 281 | // parentWidget()->style().drawPrimitive( QStyle::PE_Panel, &p, rect(), parentWidget()->colorGroup()); |
282 | 282 | ||
283 | int sw = 8; // Hardcoded, given I didn't use styles anymore, I didn't like to use their size | 283 | int sw = 8; // Hardcoded, given I didn't use styles anymore, I didn't like to use their size |
284 | 284 | ||
285 | // arrow color | 285 | // arrow color |
286 | QColor col; | 286 | QColor col; |
287 | if ( _activeButton ) | 287 | if ( _activeButton ) |
288 | col = colorGroup().background().dark( 250 ); | 288 | col = colorGroup().background().dark( 250 ); |
289 | else { | 289 | else { |
290 | if ( mMouseDown ) | 290 | if ( mMouseDown ) |
291 | #ifndef DESKTOP_VERSION | 291 | col = Qt::white; |
292 | col = QColor( 178,18,188);//QColor( 242,27,255 );//Qt::white; | ||
293 | #else | ||
294 | col = Qt::white; | ||
295 | #endif | ||
296 | else | 292 | else |
297 | col = colorGroup().background().dark( 150 ); | 293 | col = colorGroup().background().dark( 150 ); |
298 | } | 294 | } |
299 | //QColor col = backgroundColor().dark( 130 ); | 295 | //QColor col = backgroundColor().dark( 130 ); |
300 | p.setBrush( col ); | 296 | p.setBrush( col ); |
301 | p.setPen( col ); | 297 | p.setPen( col ); |
302 | 298 | ||
303 | QValueList<QPointArray> list = buttonRegions(); | 299 | QValueList<QPointArray> list = buttonRegions(); |
304 | int index = 1; | 300 | int index = 1; |
305 | if ( mUseOffset ) | 301 | if ( mUseOffset ) |
306 | p.translate( 0, 1 ); | 302 | p.translate( 0, 1 ); |
307 | for ( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { | 303 | for ( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { |
308 | if ( index == _activeButton ) { | 304 | if ( index == _activeButton ) { |
309 | 305 | ||
310 | /* | 306 | /* |
311 | if ( ! _collapsed ) { | 307 | if ( ! _collapsed ) { |
312 | p.save(); | 308 | p.save(); |
313 | // p.translate( parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftHorizontal ), | 309 | // p.translate( parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftHorizontal ), |
314 | // parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftVertical ) ); | 310 | // parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftVertical ) ); |
315 | p.translate( -1, 0 ); | 311 | p.translate( -1, 0 ); |
316 | p.drawPolygon( *it, true ); | 312 | p.drawPolygon( *it, true ); |
317 | p.restore(); } else | 313 | p.restore(); } else |
318 | */ | 314 | */ |
319 | p.drawPolygon( *it, true ); | 315 | p.drawPolygon( *it, true ); |
320 | 316 | ||
321 | } | 317 | } |
322 | else { | 318 | else { |
323 | /* | 319 | /* |
324 | if ( ! _collapsed ) { | 320 | if ( ! _collapsed ) { |
325 | p.save(); | 321 | p.save(); |
326 | p.translate( -1, 0 ); | 322 | p.translate( -1, 0 ); |
327 | p.drawPolygon( *it, true ); | 323 | p.drawPolygon( *it, true ); |
328 | p.restore(); | 324 | p.restore(); |
329 | } else | 325 | } else |
330 | */ | 326 | */ |
331 | p.drawPolygon( *it, true ); | 327 | p.drawPolygon( *it, true ); |
332 | 328 | ||
333 | } | 329 | } |
334 | index++; | 330 | index++; |
335 | } | 331 | } |
336 | 332 | ||
337 | // Draw the lines between the arrows | 333 | // Draw the lines between the arrows |
338 | if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left || | 334 | if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left || |
339 | s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { | 335 | s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { |
340 | int mid = height()/2; | 336 | int mid = height()/2; |
341 | p.drawLine ( 1, mid - sw, 1, mid + sw ); | 337 | p.drawLine ( 1, mid - sw, 1, mid + sw ); |
342 | p.drawLine ( 3, mid - sw, 3, mid + sw ); | 338 | p.drawLine ( 3, mid - sw, 3, mid + sw ); |
343 | } | 339 | } |
344 | else if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Up || | 340 | else if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Up || |
345 | s->minimizeDirection() == KDGanttMinimizeSplitter::Down ) { | 341 | s->minimizeDirection() == KDGanttMinimizeSplitter::Down ) { |
346 | int mid = width()/2; | 342 | int mid = width()/2; |
347 | p.drawLine( mid -sw, 1, mid +sw, 1 ); | 343 | p.drawLine( mid -sw, 1, mid +sw, 1 ); |
348 | p.drawLine( mid -sw, 3, mid +sw, 3 ); | 344 | p.drawLine( mid -sw, 3, mid +sw, 3 ); |
349 | } | 345 | } |
350 | bitBlt( this, 0, 0, &buffer ); | 346 | bitBlt( this, 0, 0, &buffer ); |
351 | 347 | ||
352 | } | 348 | } |
353 | #endif | 349 | #endif |
354 | 350 | ||
355 | class QSplitterLayoutStruct | 351 | class QSplitterLayoutStruct |
356 | { | 352 | { |
357 | public: | 353 | public: |
358 | KDGanttMinimizeSplitter::ResizeMode mode; | 354 | KDGanttMinimizeSplitter::ResizeMode mode; |
359 | QCOORD sizer; | 355 | QCOORD sizer; |
360 | bool isSplitter; | 356 | bool isSplitter; |
361 | QWidget *wid; | 357 | QWidget *wid; |
362 | }; | 358 | }; |
363 | 359 | ||
364 | class QSplitterData | 360 | class QSplitterData |
365 | { | 361 | { |
366 | public: | 362 | public: |
367 | QSplitterData() : opaque( FALSE ), firstShow( TRUE ) {} | 363 | QSplitterData() : opaque( FALSE ), firstShow( TRUE ) {} |
368 | 364 | ||
369 | QPtrList<QSplitterLayoutStruct> list; | 365 | QPtrList<QSplitterLayoutStruct> list; |
370 | bool opaque; | 366 | bool opaque; |
371 | bool firstShow; | 367 | bool firstShow; |
372 | }; | 368 | }; |
373 | 369 | ||
374 | void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos, | 370 | void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos, |
375 | int space, int spacer ); | 371 | int space, int spacer ); |
376 | #endif // DOXYGEN_SKIP_INTERNAL | 372 | #endif // DOXYGEN_SKIP_INTERNAL |
377 | 373 | ||
378 | 374 | ||
379 | /*! | 375 | /*! |
380 | \class KDGanttMinimizeSplitter KDGanttMinimizeSplitter.h | 376 | \class KDGanttMinimizeSplitter KDGanttMinimizeSplitter.h |
381 | \brief The KDGanttMinimizeSplitter class implements a splitter | 377 | \brief The KDGanttMinimizeSplitter class implements a splitter |
382 | widget with minimize buttons. | 378 | widget with minimize buttons. |
383 | 379 | ||
384 | This class (and its documentation) is largely a copy of Qt's | 380 | This class (and its documentation) is largely a copy of Qt's |
385 | QSplitter; the copying was necessary because QSplitter is not | 381 | QSplitter; the copying was necessary because QSplitter is not |
386 | extensible at all. QSplitter and its documentation are licensed | 382 | extensible at all. QSplitter and its documentation are licensed |
387 | according to the GPL and the Qt Professional License (if you hold | 383 | according to the GPL and the Qt Professional License (if you hold |
388 | such a license) and are (C) Trolltech AS. | 384 | such a license) and are (C) Trolltech AS. |
389 | 385 | ||
390 | A splitter lets the user control the size of child widgets by | 386 | A splitter lets the user control the size of child widgets by |
391 | dragging the boundary between the children. Any number of widgets | 387 | dragging the boundary between the children. Any number of widgets |
392 | may be controlled. | 388 | may be controlled. |
393 | 389 | ||
394 | To show a QListBox, a QListView and a QTextEdit side by side: | 390 | To show a QListBox, a QListView and a QTextEdit side by side: |
395 | 391 | ||
396 | \code | 392 | \code |
397 | KDGanttMinimizeSplitter *split = new KDGanttMinimizeSplitter( parent ); | 393 | KDGanttMinimizeSplitter *split = new KDGanttMinimizeSplitter( parent ); |
398 | QListBox *lb = new QListBox( split ); | 394 | QListBox *lb = new QListBox( split ); |
399 | QListView *lv = new QListView( split ); | 395 | QListView *lv = new QListView( split ); |
400 | QTextEdit *ed = new QTextEdit( split ); | 396 | QTextEdit *ed = new QTextEdit( split ); |
401 | \endcode | 397 | \endcode |
402 | 398 | ||
403 | In KDGanttMinimizeSplitter, the boundary can be either horizontal or | 399 | In KDGanttMinimizeSplitter, the boundary can be either horizontal or |
404 | vertical. The default is horizontal (the children are side by side) | 400 | vertical. The default is horizontal (the children are side by side) |
405 | but you can use setOrientation( QSplitter::Vertical ) to set it to | 401 | but you can use setOrientation( QSplitter::Vertical ) to set it to |
406 | vertical. | 402 | vertical. |
407 | 403 | ||
408 | Use setResizeMode() to specify | 404 | Use setResizeMode() to specify |
409 | that a widget should keep its size when the splitter is resized. | 405 | that a widget should keep its size when the splitter is resized. |
410 | 406 | ||
411 | Although KDGanttMinimizeSplitter normally resizes the children only | 407 | Although KDGanttMinimizeSplitter normally resizes the children only |
412 | at the end of a resize operation, if you call setOpaqueResize( TRUE | 408 | at the end of a resize operation, if you call setOpaqueResize( TRUE |
413 | ) the widgets are resized as often as possible. | 409 | ) the widgets are resized as often as possible. |
414 | 410 | ||
415 | The initial distribution of size between the widgets is determined | 411 | The initial distribution of size between the widgets is determined |
416 | by the initial size of each widget. You can also use setSizes() to | 412 | by the initial size of each widget. You can also use setSizes() to |
417 | set the sizes of all the widgets. The function sizes() returns the | 413 | set the sizes of all the widgets. The function sizes() returns the |
418 | sizes set by the user. | 414 | sizes set by the user. |
419 | 415 | ||
420 | If you hide() a child, its space will be distributed among the other | 416 | If you hide() a child, its space will be distributed among the other |
421 | children. It will be reinstated when you show() it again. It is also | 417 | children. It will be reinstated when you show() it again. It is also |
422 | possible to reorder the widgets within the splitter using | 418 | possible to reorder the widgets within the splitter using |
423 | moveToFirst() and moveToLast(). | 419 | moveToFirst() and moveToLast(). |
424 | */ | 420 | */ |
425 | 421 | ||
426 | 422 | ||
427 | 423 | ||
428 | static QSize minSize( const QWidget* /*w*/ ) | 424 | static QSize minSize( const QWidget* /*w*/ ) |
429 | { | 425 | { |
430 | return QSize(0,0); | 426 | return QSize(0,0); |
431 | } | 427 | } |
432 | 428 | ||
433 | // This is the original version of minSize | 429 | // This is the original version of minSize |
434 | static QSize minSizeHint( const QWidget* w ) | 430 | static QSize minSizeHint( const QWidget* w ) |
435 | { | 431 | { |
436 | QSize min = w->minimumSize(); | 432 | QSize min = w->minimumSize(); |
437 | QSize s; | 433 | QSize s; |
438 | if ( min.height() <= 0 || min.width() <= 0 ) | 434 | if ( min.height() <= 0 || min.width() <= 0 ) |
439 | s = w->minimumSizeHint(); | 435 | s = w->minimumSizeHint(); |
440 | if ( min.height() > 0 ) | 436 | if ( min.height() > 0 ) |
441 | s.setHeight( min.height() ); | 437 | s.setHeight( min.height() ); |
442 | if ( min.width() > 0 ) | 438 | if ( min.width() > 0 ) |
443 | s.setWidth( min.width() ); | 439 | s.setWidth( min.width() ); |
444 | return s.expandedTo(QSize(0,0)); | 440 | return s.expandedTo(QSize(0,0)); |
445 | } | 441 | } |
446 | 442 | ||
447 | 443 | ||
448 | /*! | 444 | /*! |
449 | Constructs a horizontal splitter with the \a parent and \a | 445 | Constructs a horizontal splitter with the \a parent and \a |
450 | name arguments being passed on to the QFrame constructor. | 446 | name arguments being passed on to the QFrame constructor. |
451 | */ | 447 | */ |
452 | KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( QWidget *parent, const char *name ) | 448 | KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( QWidget *parent, const char *name ) |
453 | :QFrame(parent,name,WPaintUnclipped) | 449 | :QFrame(parent,name,WPaintUnclipped) |
454 | { | 450 | { |
455 | mRubberBand = 0; | 451 | mRubberBand = 0; |
456 | mFirstHandle = 0; | 452 | mFirstHandle = 0; |
457 | #if QT_VERSION >= 232 | 453 | #if QT_VERSION >= 232 |
458 | orient = Horizontal; | 454 | orient = Horizontal; |
459 | init(); | 455 | init(); |
460 | #endif | 456 | #endif |
461 | } | 457 | } |
462 | 458 | ||
463 | /*! | 459 | /*! |
464 | Constructs a splitter with orientation \a o with the \a parent | 460 | Constructs a splitter with orientation \a o with the \a parent |
465 | and \a name arguments being passed on to the QFrame constructor. | 461 | and \a name arguments being passed on to the QFrame constructor. |
466 | */ | 462 | */ |
467 | KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( Orientation o, QWidget *parent, const char *name ) | 463 | KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( Orientation o, QWidget *parent, const char *name ) |
468 | :QFrame(parent,name,WPaintUnclipped) | 464 | :QFrame(parent,name,WPaintUnclipped) |
469 | { | 465 | { |
470 | 466 | ||
471 | mRubberBand = 0; | 467 | mRubberBand = 0; |
472 | mFirstHandle = 0; | 468 | mFirstHandle = 0; |
473 | #if QT_VERSION >= 232 | 469 | #if QT_VERSION >= 232 |
474 | orient = o; | 470 | orient = o; |
475 | init(); | 471 | init(); |
476 | #endif | 472 | #endif |
477 | } | 473 | } |
478 | 474 | ||
479 | /*! | 475 | /*! |
480 | Destroys the splitter and any children. | 476 | Destroys the splitter and any children. |
481 | */ | 477 | */ |
482 | KDGanttMinimizeSplitter::~KDGanttMinimizeSplitter() | 478 | KDGanttMinimizeSplitter::~KDGanttMinimizeSplitter() |
483 | { | 479 | { |
484 | #if QT_VERSION >= 232 | 480 | #if QT_VERSION >= 232 |
485 | data->list.setAutoDelete( TRUE ); | 481 | data->list.setAutoDelete( TRUE ); |
486 | delete data; | 482 | delete data; |
487 | #endif | 483 | #endif |
488 | if ( mRubberBand ) | 484 | if ( mRubberBand ) |
489 | delete mRubberBand; | 485 | delete mRubberBand; |
490 | } | 486 | } |
491 | 487 | ||
492 | 488 | ||
493 | #if QT_VERSION >= 232 | 489 | #if QT_VERSION >= 232 |
494 | void KDGanttMinimizeSplitter::init() | 490 | void KDGanttMinimizeSplitter::init() |
495 | { | 491 | { |
496 | data = new QSplitterData; | 492 | data = new QSplitterData; |
497 | if ( orient == Horizontal ) | 493 | if ( orient == Horizontal ) |
498 | setSizePolicy( QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum) ); | 494 | setSizePolicy( QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum) ); |
499 | else | 495 | else |
500 | setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding) ); | 496 | setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding) ); |
501 | #ifndef DESKTOP_VERSION | 497 | #ifndef DESKTOP_VERSION |
502 | setOpaqueResize( false ); | 498 | setOpaqueResize( false ); |
503 | #else | 499 | #else |
504 | setOpaqueResize( true ); | 500 | setOpaqueResize( true ); |
505 | #endif | 501 | #endif |
506 | } | 502 | } |
507 | #endif | 503 | #endif |
508 | 504 | ||
509 | 505 | ||
510 | void KDGanttMinimizeSplitter::toggle() | 506 | void KDGanttMinimizeSplitter::toggle() |
511 | { | 507 | { |
512 | if ( mFirstHandle ) | 508 | if ( mFirstHandle ) |
513 | mFirstHandle->toggle(); | 509 | mFirstHandle->toggle(); |
514 | else | 510 | else |
515 | qDebug("KDGanttMinimizeSplitter::toggle::sorry, handle not available "); | 511 | qDebug("KDGanttMinimizeSplitter::toggle::sorry, handle not available "); |
516 | 512 | ||
517 | } | 513 | } |
518 | 514 | ||
519 | 515 | ||
520 | /*! | 516 | /*! |
521 | \brief the orientation of the splitter | 517 | \brief the orientation of the splitter |
522 | 518 | ||
523 | By default the orientation is horizontal (the widgets are side by side). | 519 | By default the orientation is horizontal (the widgets are side by side). |
524 | The possible orientations are Qt:Vertical and Qt::Horizontal (the default). | 520 | The possible orientations are Qt:Vertical and Qt::Horizontal (the default). |
525 | */ | 521 | */ |
526 | void KDGanttMinimizeSplitter::setOrientation( Orientation o ) | 522 | void KDGanttMinimizeSplitter::setOrientation( Orientation o ) |
527 | { | 523 | { |
528 | #if QT_VERSION >= 232 | 524 | #if QT_VERSION >= 232 |
529 | if ( orient == o ) | 525 | if ( orient == o ) |
530 | return; | 526 | return; |
531 | orient = o; | 527 | orient = o; |
532 | 528 | ||
533 | if ( orient == Horizontal ) | 529 | if ( orient == Horizontal ) |
534 | setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); | 530 | setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); |
535 | else | 531 | else |
536 | setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); | 532 | setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); |
537 | 533 | ||
538 | QSplitterLayoutStruct *s = data->list.first(); | 534 | QSplitterLayoutStruct *s = data->list.first(); |
539 | while ( s ) { | 535 | while ( s ) { |
540 | if ( s->isSplitter ) | 536 | if ( s->isSplitter ) |
541 | ((KDGanttSplitterHandle*)s->wid)->setOrientation( o ); | 537 | ((KDGanttSplitterHandle*)s->wid)->setOrientation( o ); |
542 | s = data->list.next(); // ### next at end of loop, no iterator | 538 | s = data->list.next(); // ### next at end of loop, no iterator |
543 | } | 539 | } |
544 | recalc( isVisible() ); | 540 | recalc( isVisible() ); |
545 | #endif | 541 | #endif |
546 | } | 542 | } |
547 | 543 | ||
548 | 544 | ||
549 | #if QT_VERSION >= 232 | 545 | #if QT_VERSION >= 232 |
550 | /*! | 546 | /*! |
551 | \reimp | 547 | \reimp |
552 | */ | 548 | */ |
553 | void KDGanttMinimizeSplitter::resizeEvent( QResizeEvent * ) | 549 | void KDGanttMinimizeSplitter::resizeEvent( QResizeEvent * ) |
554 | { | 550 | { |
555 | doResize(); | 551 | doResize(); |
556 | } | 552 | } |
557 | 553 | ||
558 | 554 | ||
559 | /* | 555 | /* |
560 | Inserts the widget \a w at the end (or at the beginning if \a first | 556 | Inserts the widget \a w at the end (or at the beginning if \a first |
561 | is TRUE) of the splitter's list of widgets. | 557 | is TRUE) of the splitter's list of widgets. |
562 | 558 | ||
563 | It is the responsibility of the caller of this function to make sure | 559 | It is the responsibility of the caller of this function to make sure |
564 | that \a w is not already in the splitter and to call recalcId if | 560 | that \a w is not already in the splitter and to call recalcId if |
565 | needed. (If \a first is TRUE, then recalcId is very probably | 561 | needed. (If \a first is TRUE, then recalcId is very probably |
566 | needed.) | 562 | needed.) |
567 | */ | 563 | */ |
568 | QSplitterLayoutStruct *KDGanttMinimizeSplitter::addWidget( QWidget *w, bool first ) | 564 | QSplitterLayoutStruct *KDGanttMinimizeSplitter::addWidget( QWidget *w, bool first ) |
569 | { | 565 | { |
570 | QSplitterLayoutStruct *s; | 566 | QSplitterLayoutStruct *s; |
571 | KDGanttSplitterHandle *newHandle = 0; | 567 | KDGanttSplitterHandle *newHandle = 0; |
572 | if ( data->list.count() > 0 ) { | 568 | if ( data->list.count() > 0 ) { |
573 | s = new QSplitterLayoutStruct; | 569 | s = new QSplitterLayoutStruct; |
574 | s->mode = KeepSize; | 570 | s->mode = KeepSize; |
575 | QString tmp = "qt_splithandle_"; | 571 | QString tmp = "qt_splithandle_"; |
576 | tmp += w->name(); | 572 | tmp += w->name(); |
577 | newHandle = new KDGanttSplitterHandle( orientation(), this, tmp.latin1() ); | 573 | newHandle = new KDGanttSplitterHandle( orientation(), this, tmp.latin1() ); |
578 | if ( ! mFirstHandle ) | 574 | if ( ! mFirstHandle ) |
579 | mFirstHandle = newHandle; | 575 | mFirstHandle = newHandle; |
580 | s->wid = newHandle; | 576 | s->wid = newHandle; |
581 | newHandle->setId(data->list.count()); | 577 | newHandle->setId(data->list.count()); |
582 | s->isSplitter = TRUE; | 578 | s->isSplitter = TRUE; |
583 | s->sizer = pick( newHandle->sizeHint() ); | 579 | s->sizer = pick( newHandle->sizeHint() ); |
584 | if ( first ) | 580 | if ( first ) |
585 | data->list.insert( 0, s ); | 581 | data->list.insert( 0, s ); |
586 | else | 582 | else |
587 | data->list.append( s ); | 583 | data->list.append( s ); |
588 | } | 584 | } |
589 | s = new QSplitterLayoutStruct; | 585 | s = new QSplitterLayoutStruct; |
590 | s->mode = Stretch; | 586 | s->mode = Stretch; |
591 | s->wid = w; | 587 | s->wid = w; |
592 | if ( !testWState( WState_Resized ) && w->sizeHint().isValid() ) | 588 | if ( !testWState( WState_Resized ) && w->sizeHint().isValid() ) |
593 | s->sizer = pick( w->sizeHint() ); | 589 | s->sizer = pick( w->sizeHint() ); |
594 | else | 590 | else |
595 | s->sizer = pick( w->size() ); | 591 | s->sizer = pick( w->size() ); |
596 | s->isSplitter = FALSE; | 592 | s->isSplitter = FALSE; |
597 | if ( first ) | 593 | if ( first ) |
598 | data->list.insert( 0, s ); | 594 | data->list.insert( 0, s ); |
599 | else | 595 | else |
600 | data->list.append( s ); | 596 | data->list.append( s ); |
601 | if ( newHandle && isVisible() ) | 597 | if ( newHandle && isVisible() ) |
602 | newHandle->show(); //will trigger sending of post events | 598 | newHandle->show(); //will trigger sending of post events |
603 | return s; | 599 | return s; |
604 | } | 600 | } |
605 | 601 | ||
606 | 602 | ||
607 | /*! | 603 | /*! |
608 | Tells the splitter that a child widget has been inserted or removed. | 604 | Tells the splitter that a child widget has been inserted or removed. |
609 | The event is passed in \a c. | 605 | The event is passed in \a c. |
610 | */ | 606 | */ |
611 | void KDGanttMinimizeSplitter::childEvent( QChildEvent *c ) | 607 | void KDGanttMinimizeSplitter::childEvent( QChildEvent *c ) |
612 | { | 608 | { |
613 | if ( c->type() == QEvent::ChildInserted ) { | 609 | if ( c->type() == QEvent::ChildInserted ) { |
614 | if ( !c->child()->isWidgetType() ) | 610 | if ( !c->child()->isWidgetType() ) |
615 | return; | 611 | return; |
616 | 612 | ||
617 | if ( ((QWidget*)c->child())->testWFlags( WType_TopLevel ) ) | 613 | if ( ((QWidget*)c->child())->testWFlags( WType_TopLevel ) ) |
618 | return; | 614 | return; |
619 | 615 | ||
620 | QSplitterLayoutStruct *s = data->list.first(); | 616 | QSplitterLayoutStruct *s = data->list.first(); |
621 | while ( s ) { | 617 | while ( s ) { |
622 | if ( s->wid == c->child() ) | 618 | if ( s->wid == c->child() ) |
623 | return; | 619 | return; |
624 | s = data->list.next(); | 620 | s = data->list.next(); |
625 | } | 621 | } |
626 | addWidget( (QWidget*)c->child() ); | 622 | addWidget( (QWidget*)c->child() ); |
627 | recalc( isVisible() ); | 623 | recalc( isVisible() ); |
628 | 624 | ||
629 | } else if ( c->type() == QEvent::ChildRemoved ) { | 625 | } else if ( c->type() == QEvent::ChildRemoved ) { |
630 | QSplitterLayoutStruct *p = 0; | 626 | QSplitterLayoutStruct *p = 0; |
631 | if ( data->list.count() > 1 ) | 627 | if ( data->list.count() > 1 ) |
632 | p = data->list.at(1); //remove handle _after_ first widget. | 628 | p = data->list.at(1); //remove handle _after_ first widget. |
633 | QSplitterLayoutStruct *s = data->list.first(); | 629 | QSplitterLayoutStruct *s = data->list.first(); |
634 | while ( s ) { | 630 | while ( s ) { |
635 | if ( s->wid == c->child() ) { | 631 | if ( s->wid == c->child() ) { |
636 | data->list.removeRef( s ); | 632 | data->list.removeRef( s ); |
637 | delete s; | 633 | delete s; |
638 | if ( p && p->isSplitter ) { | 634 | if ( p && p->isSplitter ) { |
639 | data->list.removeRef( p ); | 635 | data->list.removeRef( p ); |
640 | delete p->wid; //will call childEvent | 636 | delete p->wid; //will call childEvent |
641 | delete p; | 637 | delete p; |
642 | } | 638 | } |
643 | recalcId(); | 639 | recalcId(); |
644 | doResize(); | 640 | doResize(); |
645 | return; | 641 | return; |
646 | } | 642 | } |
647 | p = s; | 643 | p = s; |
648 | s = data->list.next(); | 644 | s = data->list.next(); |
649 | } | 645 | } |
650 | } | 646 | } |
651 | } | 647 | } |
652 | 648 | ||
653 | 649 | ||
654 | /*! | 650 | /*! |
655 | Shows a rubber band at position \a p. If \a p is negative, the | 651 | Shows a rubber band at position \a p. If \a p is negative, the |
656 | rubber band is removed. | 652 | rubber band is removed. |
657 | */ | 653 | */ |
658 | void KDGanttMinimizeSplitter::setRubberband( int p ) | 654 | void KDGanttMinimizeSplitter::setRubberband( int p ) |
659 | { | 655 | { |
660 | #ifdef DESKTOP_VERSION | 656 | #ifdef DESKTOP_VERSION |
661 | QPainter paint( this ); | 657 | QPainter paint( this ); |
662 | paint.setPen( gray ); | 658 | paint.setPen( gray ); |
663 | paint.setBrush( gray ); | 659 | paint.setBrush( gray ); |
664 | paint.setRasterOp( XorROP ); | 660 | paint.setRasterOp( XorROP ); |
665 | QRect r = contentsRect(); | 661 | QRect r = contentsRect(); |
666 | const int rBord = 3; //Themable???? | 662 | const int rBord = 3; //Themable???? |
667 | #if QT_VERSION >= 0x030000 | 663 | #if QT_VERSION >= 0x030000 |
668 | int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); | 664 | int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); |
669 | #else | 665 | #else |
670 | int sw = style().splitterWidth(); | 666 | int sw = style().splitterWidth(); |
671 | #endif | 667 | #endif |
672 | if ( orient == Horizontal ) { | 668 | if ( orient == Horizontal ) { |
673 | if ( opaqueOldPos >= 0 ) | 669 | if ( opaqueOldPos >= 0 ) |
674 | paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(), | 670 | paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(), |
675 | 2*rBord, r.height() ); | 671 | 2*rBord, r.height() ); |
676 | if ( p >= 0 ) | 672 | if ( p >= 0 ) |
677 | paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() ); | 673 | paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() ); |
678 | } else { | 674 | } else { |
679 | if ( opaqueOldPos >= 0 ) | 675 | if ( opaqueOldPos >= 0 ) |
680 | paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord, | 676 | paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord, |
681 | r.width(), 2*rBord ); | 677 | r.width(), 2*rBord ); |
682 | if ( p >= 0 ) | 678 | if ( p >= 0 ) |
683 | paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord ); | 679 | paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord ); |
684 | } | 680 | } |
685 | opaqueOldPos = p; | 681 | opaqueOldPos = p; |
686 | #else | 682 | #else |
687 | if ( !mRubberBand ) { | 683 | if ( !mRubberBand ) { |
688 | mRubberBand = new QFrame( 0, "rubber", WStyle_NoBorder | WStyle_Customize | WStyle_StaysOnTop); | 684 | mRubberBand = new QFrame( 0, "rubber", WStyle_NoBorder | WStyle_Customize | WStyle_StaysOnTop); |
689 | mRubberBand->setFrameStyle( Box | Raised ); | 685 | mRubberBand->setFrameStyle( Box | Raised ); |
690 | //mRubberBand->setPalette( QPalette ( Qt::red.light(),Qt::red.dark() ) ); | 686 | //mRubberBand->setPalette( QPalette ( Qt::red.light(),Qt::red.dark() ) ); |
691 | mRubberBand->setPalette( QPalette ( QColor( 178,18,188), QColor( 242,27,255 ) )); | 687 | mRubberBand->setPalette( QPalette ( colorGroup().background().light(), colorGroup().background().dark() )); |
692 | } | 688 | } |
693 | QRect r = contentsRect(); | 689 | QRect r = contentsRect(); |
694 | static int rBord = 0; //Themable???? | 690 | static int rBord = 0; //Themable???? |
695 | if ( !rBord ) { | 691 | if ( !rBord ) { |
696 | if (QApplication::desktop()->width() <= 320 ) | 692 | if (QApplication::desktop()->width() <= 320 ) |
697 | rBord = 3; | 693 | rBord = 3; |
698 | else | 694 | else |
699 | rBord = 4; | 695 | rBord = 4; |
700 | } | 696 | } |
701 | int sw = style().splitterWidth(); | 697 | int sw = style().splitterWidth(); |
702 | if ( orient == Horizontal ) { | 698 | if ( orient == Horizontal ) { |
703 | if ( p >= 0 ) { | 699 | if ( p >= 0 ) { |
704 | QPoint geo = mapToGlobal (QPoint ( p + sw/2 - rBord, r.y())); | 700 | QPoint geo = mapToGlobal (QPoint ( p + sw/2 - rBord, r.y())); |
705 | mRubberBand->setGeometry( geo.x(), geo.y(), 2*rBord, r.height() ); | 701 | mRubberBand->setGeometry( geo.x(), geo.y(), 2*rBord, r.height() ); |
706 | } | 702 | } |
707 | } else { | 703 | } else { |
708 | if ( p >= 0 ) { | 704 | if ( p >= 0 ) { |
709 | QPoint geo = mapToGlobal (QPoint ( r.x(), p + sw/2 - rBord)); | 705 | QPoint geo = mapToGlobal (QPoint ( r.x(), p + sw/2 - rBord)); |
710 | mRubberBand->setGeometry( geo.x(), geo.y(), r.width(), 2*rBord); | 706 | mRubberBand->setGeometry( geo.x(), geo.y(), r.width(), 2*rBord); |
711 | } | 707 | } |
712 | } | 708 | } |
713 | opaqueOldPos = p; | 709 | opaqueOldPos = p; |
714 | if ( ! mRubberBand->isVisible() ) { | 710 | if ( ! mRubberBand->isVisible() ) { |
715 | mRubberBand->show(); | 711 | mRubberBand->show(); |
716 | } | 712 | } |
717 | #endif | 713 | #endif |
718 | } | 714 | } |
719 | 715 | ||
720 | 716 | ||
721 | /*! \reimp */ | 717 | /*! \reimp */ |
722 | bool KDGanttMinimizeSplitter::event( QEvent *e ) | 718 | bool KDGanttMinimizeSplitter::event( QEvent *e ) |
723 | { | 719 | { |
724 | if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) { | 720 | if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) { |
725 | recalc( isVisible() ); | 721 | recalc( isVisible() ); |
726 | if ( e->type() == QEvent::Show ) | 722 | if ( e->type() == QEvent::Show ) |
727 | data->firstShow = FALSE; | 723 | data->firstShow = FALSE; |
728 | } | 724 | } |
729 | return QWidget::event( e ); | 725 | return QWidget::event( e ); |
730 | } | 726 | } |
731 | 727 | ||
732 | 728 | ||
733 | /*! | 729 | /*! |
734 | \obsolete | 730 | \obsolete |
735 | 731 | ||
736 | Draws the splitter handle in the rectangle described by \a x, \a y, | 732 | Draws the splitter handle in the rectangle described by \a x, \a y, |
737 | \a w, \a h using painter \a p. | 733 | \a w, \a h using painter \a p. |
738 | \sa QStyle::drawPrimitive() | 734 | \sa QStyle::drawPrimitive() |
739 | */ | 735 | */ |
740 | void KDGanttMinimizeSplitter::drawSplitter( QPainter *p, | 736 | void KDGanttMinimizeSplitter::drawSplitter( QPainter *p, |
741 | QCOORD x, QCOORD y, QCOORD w, QCOORD h ) | 737 | QCOORD x, QCOORD y, QCOORD w, QCOORD h ) |
742 | { | 738 | { |
743 | #if 0 | 739 | #if 0 |
744 | // LR | 740 | // LR |
745 | style().drawPrimitive(QStyle::PE_Splitter, p, QRect(x, y, w, h), colorGroup(), | 741 | style().drawPrimitive(QStyle::PE_Splitter, p, QRect(x, y, w, h), colorGroup(), |
746 | (orientation() == Qt::Horizontal ? | 742 | (orientation() == Qt::Horizontal ? |
747 | QStyle::Style_Horizontal : 0)); | 743 | QStyle::Style_Horizontal : 0)); |
748 | #endif | 744 | #endif |
749 | } | 745 | } |
750 | 746 | ||
751 | 747 | ||
752 | /*! | 748 | /*! |
753 | Returns the id of the splitter to the right of or below the widget \a w, | 749 | Returns the id of the splitter to the right of or below the widget \a w, |
754 | or 0 if there is no such splitter | 750 | or 0 if there is no such splitter |
755 | (i.e. it is either not in this KDGanttMinimizeSplitter or it is at the end). | 751 | (i.e. it is either not in this KDGanttMinimizeSplitter or it is at the end). |
756 | */ | 752 | */ |
757 | int KDGanttMinimizeSplitter::idAfter( QWidget* w ) const | 753 | int KDGanttMinimizeSplitter::idAfter( QWidget* w ) const |
758 | { | 754 | { |
759 | QSplitterLayoutStruct *s = data->list.first(); | 755 | QSplitterLayoutStruct *s = data->list.first(); |
760 | bool seen_w = FALSE; | 756 | bool seen_w = FALSE; |
761 | while ( s ) { | 757 | while ( s ) { |
762 | if ( s->isSplitter && seen_w ) | 758 | if ( s->isSplitter && seen_w ) |
763 | return data->list.at(); | 759 | return data->list.at(); |
764 | if ( !s->isSplitter && s->wid == w ) | 760 | if ( !s->isSplitter && s->wid == w ) |
765 | seen_w = TRUE; | 761 | seen_w = TRUE; |
766 | s = data->list.next(); | 762 | s = data->list.next(); |
767 | } | 763 | } |
768 | return 0; | 764 | return 0; |
769 | } | 765 | } |
770 | 766 | ||
771 | 767 | ||
772 | /*! | 768 | /*! |
773 | Moves the left/top edge of the splitter handle with id \a id as | 769 | Moves the left/top edge of the splitter handle with id \a id as |
774 | close as possible to position \a p, which is the distance from the | 770 | close as possible to position \a p, which is the distance from the |
775 | left (or top) edge of the widget. | 771 | left (or top) edge of the widget. |
776 | 772 | ||
777 | For Arabic and Hebrew the layout is reversed, and using this | 773 | For Arabic and Hebrew the layout is reversed, and using this |
778 | function to set the position of the splitter might lead to | 774 | function to set the position of the splitter might lead to |
779 | unexpected results, since in Arabic and Hebrew the position of | 775 | unexpected results, since in Arabic and Hebrew the position of |
780 | splitter one is to the left of the position of splitter zero. | 776 | splitter one is to the left of the position of splitter zero. |
781 | 777 | ||
782 | \sa idAfter() | 778 | \sa idAfter() |
783 | */ | 779 | */ |
784 | void KDGanttMinimizeSplitter::moveSplitter( QCOORD p, int id ) | 780 | void KDGanttMinimizeSplitter::moveSplitter( QCOORD p, int id ) |
785 | { | 781 | { |
786 | p = adjustPos( p, id ); | 782 | p = adjustPos( p, id ); |
787 | QSplitterLayoutStruct *s = data->list.at(id); | 783 | QSplitterLayoutStruct *s = data->list.at(id); |
788 | int oldP = orient == Horizontal ? s->wid->x() : s->wid->y(); | 784 | int oldP = orient == Horizontal ? s->wid->x() : s->wid->y(); |
789 | bool upLeft; | 785 | bool upLeft; |
790 | if ( false && orient == Horizontal ) { | 786 | if ( false && orient == Horizontal ) { |
791 | p += s->wid->width(); | 787 | p += s->wid->width(); |
792 | upLeft = p > oldP; | 788 | upLeft = p > oldP; |
793 | } else | 789 | } else |
794 | upLeft = p < oldP; | 790 | upLeft = p < oldP; |
795 | 791 | ||
796 | moveAfter( p, id, upLeft ); | 792 | moveAfter( p, id, upLeft ); |
797 | moveBefore( p-1, id-1, upLeft ); | 793 | moveBefore( p-1, id-1, upLeft ); |
798 | 794 | ||
799 | storeSizes(); | 795 | storeSizes(); |
800 | } | 796 | } |
801 | 797 | ||
802 | 798 | ||
803 | void KDGanttMinimizeSplitter::setG( QWidget *w, int p, int s, bool isSplitter ) | 799 | void KDGanttMinimizeSplitter::setG( QWidget *w, int p, int s, bool isSplitter ) |
804 | { | 800 | { |
805 | if ( orient == Horizontal ) { | 801 | if ( orient == Horizontal ) { |
806 | if ( false && orient == Horizontal && !isSplitter ) | 802 | if ( false && orient == Horizontal && !isSplitter ) |
807 | p = contentsRect().width() - p - s; | 803 | p = contentsRect().width() - p - s; |
808 | w->setGeometry( p, contentsRect().y(), s, contentsRect().height() ); | 804 | w->setGeometry( p, contentsRect().y(), s, contentsRect().height() ); |
809 | } else | 805 | } else |
810 | w->setGeometry( contentsRect().x(), p, contentsRect().width(), s ); | 806 | w->setGeometry( contentsRect().x(), p, contentsRect().width(), s ); |
811 | } | 807 | } |
812 | 808 | ||
813 | 809 | ||
814 | /* | 810 | /* |
815 | Places the right/bottom edge of the widget at \a id at position \a pos. | 811 | Places the right/bottom edge of the widget at \a id at position \a pos. |
816 | 812 | ||
817 | \sa idAfter() | 813 | \sa idAfter() |
818 | */ | 814 | */ |
819 | void KDGanttMinimizeSplitter::moveBefore( int pos, int id, bool upLeft ) | 815 | void KDGanttMinimizeSplitter::moveBefore( int pos, int id, bool upLeft ) |
820 | { | 816 | { |
821 | if( id < 0 ) | 817 | if( id < 0 ) |
822 | return; | 818 | return; |
823 | QSplitterLayoutStruct *s = data->list.at(id); | 819 | QSplitterLayoutStruct *s = data->list.at(id); |
824 | if ( !s ) | 820 | if ( !s ) |
825 | return; | 821 | return; |
826 | QWidget *w = s->wid; | 822 | QWidget *w = s->wid; |
827 | if ( w->isHidden() ) { | 823 | if ( w->isHidden() ) { |
828 | moveBefore( pos, id-1, upLeft ); | 824 | moveBefore( pos, id-1, upLeft ); |
829 | } else if ( s->isSplitter ) { | 825 | } else if ( s->isSplitter ) { |
830 | int pos1, pos2; | 826 | int pos1, pos2; |
831 | int dd = s->sizer; | 827 | int dd = s->sizer; |
832 | if( false && orient == Horizontal ) { | 828 | if( false && orient == Horizontal ) { |
833 | pos1 = pos; | 829 | pos1 = pos; |
834 | pos2 = pos + dd; | 830 | pos2 = pos + dd; |
835 | } else { | 831 | } else { |
836 | pos2 = pos - dd; | 832 | pos2 = pos - dd; |
837 | pos1 = pos2 + 1; | 833 | pos1 = pos2 + 1; |
838 | } | 834 | } |
839 | if ( upLeft ) { | 835 | if ( upLeft ) { |
840 | setG( w, pos1, dd, TRUE ); | 836 | setG( w, pos1, dd, TRUE ); |
841 | moveBefore( pos2, id-1, upLeft ); | 837 | moveBefore( pos2, id-1, upLeft ); |
842 | } else { | 838 | } else { |
843 | moveBefore( pos2, id-1, upLeft ); | 839 | moveBefore( pos2, id-1, upLeft ); |
844 | setG( w, pos1, dd, TRUE ); | 840 | setG( w, pos1, dd, TRUE ); |
845 | } | 841 | } |
846 | } else { | 842 | } else { |
847 | int dd, newLeft, nextPos; | 843 | int dd, newLeft, nextPos; |
848 | if( false && orient == Horizontal ) { | 844 | if( false && orient == Horizontal ) { |
849 | dd = w->geometry().right() - pos; | 845 | dd = w->geometry().right() - pos; |
850 | dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); | 846 | dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); |
851 | newLeft = pos+1; | 847 | newLeft = pos+1; |
852 | nextPos = newLeft + dd; | 848 | nextPos = newLeft + dd; |
853 | } else { | 849 | } else { |
854 | dd = pos - pick( w->pos() ) + 1; | 850 | dd = pos - pick( w->pos() ) + 1; |
855 | dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); | 851 | dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); |
856 | newLeft = pos-dd+1; | 852 | newLeft = pos-dd+1; |
857 | nextPos = newLeft - 1; | 853 | nextPos = newLeft - 1; |
858 | } | 854 | } |
859 | setG( w, newLeft, dd, TRUE ); | 855 | setG( w, newLeft, dd, TRUE ); |
860 | moveBefore( nextPos, id-1, upLeft ); | 856 | moveBefore( nextPos, id-1, upLeft ); |
861 | } | 857 | } |
862 | } | 858 | } |
863 | 859 | ||
864 | 860 | ||
865 | /* | 861 | /* |
866 | Places the left/top edge of the widget at \a id at position \a pos. | 862 | Places the left/top edge of the widget at \a id at position \a pos. |
867 | 863 | ||
868 | \sa idAfter() | 864 | \sa idAfter() |
869 | */ | 865 | */ |
870 | void KDGanttMinimizeSplitter::moveAfter( int pos, int id, bool upLeft ) | 866 | void KDGanttMinimizeSplitter::moveAfter( int pos, int id, bool upLeft ) |
871 | { | 867 | { |
872 | QSplitterLayoutStruct *s = id < int(data->list.count()) ? | 868 | QSplitterLayoutStruct *s = id < int(data->list.count()) ? |
873 | data->list.at(id) : 0; | 869 | data->list.at(id) : 0; |
874 | if ( !s ) | 870 | if ( !s ) |
875 | return; | 871 | return; |
876 | QWidget *w = s->wid; | 872 | QWidget *w = s->wid; |
877 | if ( w->isHidden() ) { | 873 | if ( w->isHidden() ) { |
878 | moveAfter( pos, id+1, upLeft ); | 874 | moveAfter( pos, id+1, upLeft ); |
879 | } else if ( pick( w->pos() ) == pos ) { | 875 | } else if ( pick( w->pos() ) == pos ) { |
880 | //No need to do anything if it's already there. | 876 | //No need to do anything if it's already there. |
881 | return; | 877 | return; |
882 | } else if ( s->isSplitter ) { | 878 | } else if ( s->isSplitter ) { |
883 | int dd = s->sizer; | 879 | int dd = s->sizer; |
884 | int pos1, pos2; | 880 | int pos1, pos2; |
885 | if( false && orient == Horizontal ) { | 881 | if( false && orient == Horizontal ) { |
886 | pos2 = pos - dd; | 882 | pos2 = pos - dd; |
887 | pos1 = pos2 + 1; | 883 | pos1 = pos2 + 1; |
888 | } else { | 884 | } else { |
889 | pos1 = pos; | 885 | pos1 = pos; |
890 | pos2 = pos + dd; | 886 | pos2 = pos + dd; |
891 | } | 887 | } |
892 | if ( upLeft ) { | 888 | if ( upLeft ) { |
893 | setG( w, pos1, dd, TRUE ); | 889 | setG( w, pos1, dd, TRUE ); |
894 | moveAfter( pos2, id+1, upLeft ); | 890 | moveAfter( pos2, id+1, upLeft ); |
895 | } else { | 891 | } else { |
896 | moveAfter( pos2, id+1, upLeft ); | 892 | moveAfter( pos2, id+1, upLeft ); |
897 | setG( w, pos1, dd, TRUE ); | 893 | setG( w, pos1, dd, TRUE ); |
898 | } | 894 | } |
899 | } else { | 895 | } else { |
900 | int left = pick( w->pos() ); | 896 | int left = pick( w->pos() ); |
901 | int right, dd,/* newRight,*/ newLeft, nextPos; | 897 | int right, dd,/* newRight,*/ newLeft, nextPos; |
902 | if ( false && orient == Horizontal ) { | 898 | if ( false && orient == Horizontal ) { |
903 | dd = pos - left + 1; | 899 | dd = pos - left + 1; |
904 | dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); | 900 | dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); |
905 | newLeft = pos-dd+1; | 901 | newLeft = pos-dd+1; |
906 | nextPos = newLeft - 1; | 902 | nextPos = newLeft - 1; |
907 | } else { | 903 | } else { |
908 | right = pick( w->geometry().bottomRight() ); | 904 | right = pick( w->geometry().bottomRight() ); |
909 | dd = right - pos + 1; | 905 | dd = right - pos + 1; |
910 | dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); | 906 | dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); |
911 | /*newRight = pos+dd-1;*/ | 907 | /*newRight = pos+dd-1;*/ |
912 | newLeft = pos; | 908 | newLeft = pos; |
913 | nextPos = newLeft + dd; | 909 | nextPos = newLeft + dd; |
914 | } | 910 | } |
915 | setG( w, newLeft, dd, TRUE ); | 911 | setG( w, newLeft, dd, TRUE ); |
916 | /*if( right != newRight )*/ | 912 | /*if( right != newRight )*/ |
917 | moveAfter( nextPos, id+1, upLeft ); | 913 | moveAfter( nextPos, id+1, upLeft ); |
918 | } | 914 | } |
919 | } | 915 | } |
920 | 916 | ||
921 | 917 | ||
922 | void KDGanttMinimizeSplitter::expandPos( int id, int* min, int* max ) | 918 | void KDGanttMinimizeSplitter::expandPos( int id, int* min, int* max ) |
923 | { | 919 | { |
924 | QSplitterLayoutStruct *s = data->list.at(id-1); | 920 | QSplitterLayoutStruct *s = data->list.at(id-1); |
925 | QWidget* w = s->wid; | 921 | QWidget* w = s->wid; |
926 | *min = pick( w->mapToParent( QPoint(0,0) ) ); | 922 | *min = pick( w->mapToParent( QPoint(0,0) ) ); |
927 | 923 | ||
928 | if ( (uint) id == data->list.count() ) { | 924 | if ( (uint) id == data->list.count() ) { |
929 | pick( size() ); | 925 | pick( size() ); |
930 | } | 926 | } |
931 | else { | 927 | else { |
932 | QSplitterLayoutStruct *s = data->list.at(id+1); | 928 | QSplitterLayoutStruct *s = data->list.at(id+1); |
933 | QWidget* w = s->wid; | 929 | QWidget* w = s->wid; |
934 | *max = pick( w->mapToParent( QPoint( w->width(), w->height() ) ) ) -8; | 930 | *max = pick( w->mapToParent( QPoint( w->width(), w->height() ) ) ) -8; |
935 | } | 931 | } |
936 | } | 932 | } |
937 | 933 | ||
938 | 934 | ||
939 | /*! | 935 | /*! |
940 | Returns the valid range of the splitter with id \a id in \a *min and \a *max. | 936 | Returns the valid range of the splitter with id \a id in \a *min and \a *max. |
941 | 937 | ||
942 | \sa idAfter() | 938 | \sa idAfter() |
943 | */ | 939 | */ |
944 | 940 | ||
945 | void KDGanttMinimizeSplitter::getRange( int id, int *min, int *max ) | 941 | void KDGanttMinimizeSplitter::getRange( int id, int *min, int *max ) |
946 | { | 942 | { |
947 | int minB = 0;//before | 943 | int minB = 0;//before |
948 | int maxB = 0; | 944 | int maxB = 0; |
949 | int minA = 0; | 945 | int minA = 0; |
950 | int maxA = 0;//after | 946 | int maxA = 0;//after |
951 | int n = data->list.count(); | 947 | int n = data->list.count(); |
952 | if ( id < 0 || id >= n ) | 948 | if ( id < 0 || id >= n ) |
953 | return; | 949 | return; |
954 | int i; | 950 | int i; |
955 | for ( i = 0; i < id; i++ ) { | 951 | for ( i = 0; i < id; i++ ) { |
956 | QSplitterLayoutStruct *s = data->list.at(i); | 952 | QSplitterLayoutStruct *s = data->list.at(i); |
957 | if ( s->wid->isHidden() ) { | 953 | if ( s->wid->isHidden() ) { |
958 | //ignore | 954 | //ignore |
959 | } else if ( s->isSplitter ) { | 955 | } else if ( s->isSplitter ) { |
960 | minB += s->sizer; | 956 | minB += s->sizer; |
961 | maxB += s->sizer; | 957 | maxB += s->sizer; |
962 | } else { | 958 | } else { |
963 | minB += pick( minSize(s->wid) ); | 959 | minB += pick( minSize(s->wid) ); |
964 | maxB += pick( s->wid->maximumSize() ); | 960 | maxB += pick( s->wid->maximumSize() ); |
965 | } | 961 | } |
966 | } | 962 | } |
967 | for ( i = id; i < n; i++ ) { | 963 | for ( i = id; i < n; i++ ) { |
968 | QSplitterLayoutStruct *s = data->list.at(i); | 964 | QSplitterLayoutStruct *s = data->list.at(i); |
969 | if ( s->wid->isHidden() ) { | 965 | if ( s->wid->isHidden() ) { |
970 | //ignore | 966 | //ignore |
971 | } else if ( s->isSplitter ) { | 967 | } else if ( s->isSplitter ) { |
972 | minA += s->sizer; | 968 | minA += s->sizer; |
973 | maxA += s->sizer; | 969 | maxA += s->sizer; |
974 | } else { | 970 | } else { |
975 | minA += pick( minSize(s->wid) ); | 971 | minA += pick( minSize(s->wid) ); |
976 | maxA += pick( s->wid->maximumSize() ); | 972 | maxA += pick( s->wid->maximumSize() ); |
977 | } | 973 | } |
978 | } | 974 | } |
979 | QRect r = contentsRect(); | 975 | QRect r = contentsRect(); |
980 | if ( orient == Horizontal && false ) { | 976 | if ( orient == Horizontal && false ) { |
981 | #if QT_VERSION >= 0x030000 | 977 | #if QT_VERSION >= 0x030000 |
982 | int splitterWidth = style().pixelMetric(QStyle::PM_SplitterWidth, this); | 978 | int splitterWidth = style().pixelMetric(QStyle::PM_SplitterWidth, this); |
983 | #else | 979 | #else |
984 | int splitterWidth = style().splitterWidth(); | 980 | int splitterWidth = style().splitterWidth(); |
985 | #endif | 981 | #endif |
986 | 982 | ||
987 | if ( min ) | 983 | if ( min ) |
988 | *min = pick(r.topRight()) - QMIN( maxB, pick(r.size())-minA ) - splitterWidth; | 984 | *min = pick(r.topRight()) - QMIN( maxB, pick(r.size())-minA ) - splitterWidth; |
989 | if ( max ) | 985 | if ( max ) |
990 | *max = pick(r.topRight()) - QMAX( minB, pick(r.size())-maxA ) - splitterWidth; | 986 | *max = pick(r.topRight()) - QMAX( minB, pick(r.size())-maxA ) - splitterWidth; |
991 | } else { | 987 | } else { |
992 | if ( min ) | 988 | if ( min ) |
993 | *min = pick(r.topLeft()) + QMAX( minB, pick(r.size())-maxA ); | 989 | *min = pick(r.topLeft()) + QMAX( minB, pick(r.size())-maxA ); |
994 | if ( max ) | 990 | if ( max ) |
995 | *max = pick(r.topLeft()) + QMIN( maxB, pick(r.size())-minA ); | 991 | *max = pick(r.topLeft()) + QMIN( maxB, pick(r.size())-minA ); |
996 | } | 992 | } |
997 | } | 993 | } |
998 | 994 | ||
999 | 995 | ||
1000 | /*! | 996 | /*! |
1001 | Returns the closest legal position to \a p of the splitter with id \a id. | 997 | Returns the closest legal position to \a p of the splitter with id \a id. |
1002 | 998 | ||
1003 | \sa idAfter() | 999 | \sa idAfter() |
1004 | */ | 1000 | */ |
1005 | 1001 | ||
1006 | int KDGanttMinimizeSplitter::adjustPos( int p, int id ) | 1002 | int KDGanttMinimizeSplitter::adjustPos( int p, int id ) |
1007 | { | 1003 | { |
1008 | int min = 0; | 1004 | int min = 0; |
1009 | int max = 0; | 1005 | int max = 0; |
1010 | getRange( id, &min, &max ); | 1006 | getRange( id, &min, &max ); |
1011 | p = QMAX( min, QMIN( p, max ) ); | 1007 | p = QMAX( min, QMIN( p, max ) ); |
1012 | 1008 | ||
1013 | return p; | 1009 | return p; |
1014 | } | 1010 | } |
1015 | 1011 | ||
1016 | 1012 | ||
1017 | void KDGanttMinimizeSplitter::doResize() | 1013 | void KDGanttMinimizeSplitter::doResize() |
1018 | { | 1014 | { |
1019 | QRect r = contentsRect(); | 1015 | QRect r = contentsRect(); |
1020 | int i; | 1016 | int i; |
1021 | int n = data->list.count(); | 1017 | int n = data->list.count(); |
1022 | QMemArray<QLayoutStruct> a( n ); | 1018 | QMemArray<QLayoutStruct> a( n ); |
1023 | for ( i = 0; i< n; i++ ) { | 1019 | for ( i = 0; i< n; i++ ) { |
1024 | a[i].init(); | 1020 | a[i].init(); |
1025 | QSplitterLayoutStruct *s = data->list.at(i); | 1021 | QSplitterLayoutStruct *s = data->list.at(i); |
1026 | if ( s->wid->isHidden() ) { | 1022 | if ( s->wid->isHidden() ) { |
1027 | a[i].stretch = 0; | 1023 | a[i].stretch = 0; |
1028 | a[i].sizeHint = a[i].minimumSize = 0; | 1024 | a[i].sizeHint = a[i].minimumSize = 0; |
1029 | a[i].maximumSize = 0; | 1025 | a[i].maximumSize = 0; |
1030 | } else if ( s->isSplitter ) { | 1026 | } else if ( s->isSplitter ) { |
1031 | a[i].stretch = 0; | 1027 | a[i].stretch = 0; |
1032 | a[i].sizeHint = a[i].minimumSize = a[i].maximumSize = s->sizer; | 1028 | a[i].sizeHint = a[i].minimumSize = a[i].maximumSize = s->sizer; |
1033 | a[i].empty = FALSE; | 1029 | a[i].empty = FALSE; |
1034 | } else if ( s->mode == KeepSize ) { | 1030 | } else if ( s->mode == KeepSize ) { |
1035 | a[i].stretch = 0; | 1031 | a[i].stretch = 0; |
1036 | a[i].minimumSize = pick( minSize(s->wid) ); | 1032 | a[i].minimumSize = pick( minSize(s->wid) ); |
1037 | a[i].sizeHint = s->sizer; | 1033 | a[i].sizeHint = s->sizer; |
1038 | a[i].maximumSize = pick( s->wid->maximumSize() ); | 1034 | a[i].maximumSize = pick( s->wid->maximumSize() ); |
1039 | a[i].empty = FALSE; | 1035 | a[i].empty = FALSE; |
1040 | } else if ( s->mode == FollowSizeHint ) { | 1036 | } else if ( s->mode == FollowSizeHint ) { |
1041 | a[i].stretch = 0; | 1037 | a[i].stretch = 0; |
1042 | a[i].minimumSize = a[i].sizeHint = pick( s->wid->sizeHint() ); | 1038 | a[i].minimumSize = a[i].sizeHint = pick( s->wid->sizeHint() ); |
1043 | a[i].maximumSize = pick( s->wid->maximumSize() ); | 1039 | a[i].maximumSize = pick( s->wid->maximumSize() ); |
1044 | a[i].empty = FALSE; | 1040 | a[i].empty = FALSE; |
1045 | } else { //proportional | 1041 | } else { //proportional |
1046 | a[i].stretch = s->sizer; | 1042 | a[i].stretch = s->sizer; |
1047 | a[i].maximumSize = pick( s->wid->maximumSize() ); | 1043 | a[i].maximumSize = pick( s->wid->maximumSize() ); |
1048 | a[i].sizeHint = a[i].minimumSize = pick( minSize(s->wid) ); | 1044 | a[i].sizeHint = a[i].minimumSize = pick( minSize(s->wid) ); |
1049 | a[i].empty = FALSE; | 1045 | a[i].empty = FALSE; |
1050 | } | 1046 | } |
1051 | } | 1047 | } |
1052 | 1048 | ||
1053 | kdganttGeomCalc( a, 0, n, pick( r.topLeft() ), pick( r.size() ), 0 ); | 1049 | kdganttGeomCalc( a, 0, n, pick( r.topLeft() ), pick( r.size() ), 0 ); |
1054 | 1050 | ||
1055 | for ( i = 0; i< n; i++ ) { | 1051 | for ( i = 0; i< n; i++ ) { |
1056 | QSplitterLayoutStruct *s = data->list.at(i); | 1052 | QSplitterLayoutStruct *s = data->list.at(i); |
1057 | setG( s->wid, a[i].pos, a[i].size ); | 1053 | setG( s->wid, a[i].pos, a[i].size ); |
1058 | } | 1054 | } |
1059 | 1055 | ||
1060 | } | 1056 | } |
1061 | 1057 | ||
1062 | 1058 | ||
1063 | void KDGanttMinimizeSplitter::recalc( bool update ) | 1059 | void KDGanttMinimizeSplitter::recalc( bool update ) |
1064 | { | 1060 | { |
1065 | int fi = 2*frameWidth(); | 1061 | int fi = 2*frameWidth(); |
1066 | int maxl = fi; | 1062 | int maxl = fi; |
1067 | int minl = fi; | 1063 | int minl = fi; |
1068 | int maxt = QWIDGETSIZE_MAX; | 1064 | int maxt = QWIDGETSIZE_MAX; |
1069 | int mint = fi; | 1065 | int mint = fi; |
1070 | int n = data->list.count(); | 1066 | int n = data->list.count(); |
1071 | bool first = TRUE; | 1067 | bool first = TRUE; |
1072 | /* | 1068 | /* |
1073 | The splitter before a hidden widget is always hidden. | 1069 | The splitter before a hidden widget is always hidden. |
1074 | The splitter before the first visible widget is hidden. | 1070 | The splitter before the first visible widget is hidden. |
1075 | The splitter before any other visible widget is visible. | 1071 | The splitter before any other visible widget is visible. |
1076 | */ | 1072 | */ |
1077 | for ( int i = 0; i< n; i++ ) { | 1073 | for ( int i = 0; i< n; i++ ) { |
1078 | QSplitterLayoutStruct *s = data->list.at(i); | 1074 | QSplitterLayoutStruct *s = data->list.at(i); |
1079 | if ( !s->isSplitter ) { | 1075 | if ( !s->isSplitter ) { |
1080 | QSplitterLayoutStruct *p = (i > 0) ? p = data->list.at( i-1 ) : 0; | 1076 | QSplitterLayoutStruct *p = (i > 0) ? p = data->list.at( i-1 ) : 0; |
1081 | if ( p && p->isSplitter ) | 1077 | if ( p && p->isSplitter ) |
1082 | if ( first || s->wid->isHidden() ) | 1078 | if ( first || s->wid->isHidden() ) |
1083 | p->wid->hide(); //may trigger new recalc | 1079 | p->wid->hide(); //may trigger new recalc |
1084 | else | 1080 | else |
1085 | p->wid->show(); //may trigger new recalc | 1081 | p->wid->show(); //may trigger new recalc |
1086 | if ( !s->wid->isHidden() ) | 1082 | if ( !s->wid->isHidden() ) |
1087 | first = FALSE; | 1083 | first = FALSE; |
1088 | } | 1084 | } |
1089 | } | 1085 | } |
1090 | 1086 | ||
1091 | bool empty=TRUE; | 1087 | bool empty=TRUE; |
1092 | for ( int j = 0; j< n; j++ ) { | 1088 | for ( int j = 0; j< n; j++ ) { |
1093 | QSplitterLayoutStruct *s = data->list.at(j); | 1089 | QSplitterLayoutStruct *s = data->list.at(j); |
1094 | if ( !s->wid->isHidden() ) { | 1090 | if ( !s->wid->isHidden() ) { |
1095 | empty = FALSE; | 1091 | empty = FALSE; |
1096 | if ( s->isSplitter ) { | 1092 | if ( s->isSplitter ) { |
1097 | minl += s->sizer; | 1093 | minl += s->sizer; |
1098 | maxl += s->sizer; | 1094 | maxl += s->sizer; |
1099 | } else { | 1095 | } else { |
1100 | QSize minS = minSize(s->wid); | 1096 | QSize minS = minSize(s->wid); |
1101 | minl += pick( minS ); | 1097 | minl += pick( minS ); |
1102 | maxl += pick( s->wid->maximumSize() ); | 1098 | maxl += pick( s->wid->maximumSize() ); |
1103 | mint = QMAX( mint, trans( minS )); | 1099 | mint = QMAX( mint, trans( minS )); |
1104 | int tm = trans( s->wid->maximumSize() ); | 1100 | int tm = trans( s->wid->maximumSize() ); |
1105 | if ( tm > 0 ) | 1101 | if ( tm > 0 ) |
1106 | maxt = QMIN( maxt, tm ); | 1102 | maxt = QMIN( maxt, tm ); |
1107 | } | 1103 | } |
1108 | } | 1104 | } |
1109 | } | 1105 | } |
1110 | if ( empty ) { | 1106 | if ( empty ) { |
1111 | if ( parentWidget() != 0 && parentWidget()->inherits("KDGanttMinimizeSplitter") ) { | 1107 | if ( parentWidget() != 0 && parentWidget()->inherits("KDGanttMinimizeSplitter") ) { |
1112 | // nested splitters; be nice | 1108 | // nested splitters; be nice |
1113 | maxl = maxt = 0; | 1109 | maxl = maxt = 0; |
1114 | } else { | 1110 | } else { |
1115 | // KDGanttMinimizeSplitter with no children yet | 1111 | // KDGanttMinimizeSplitter with no children yet |
1116 | maxl = QWIDGETSIZE_MAX; | 1112 | maxl = QWIDGETSIZE_MAX; |
1117 | } | 1113 | } |
1118 | } else { | 1114 | } else { |
1119 | maxl = QMIN( maxl, QWIDGETSIZE_MAX ); | 1115 | maxl = QMIN( maxl, QWIDGETSIZE_MAX ); |
1120 | } | 1116 | } |
1121 | if ( maxt < mint ) | 1117 | if ( maxt < mint ) |
1122 | maxt = mint; | 1118 | maxt = mint; |
1123 | 1119 | ||
1124 | if ( orient == Horizontal ) { | 1120 | if ( orient == Horizontal ) { |
1125 | setMaximumSize( maxl, maxt ); | 1121 | setMaximumSize( maxl, maxt ); |
1126 | setMinimumSize( minl, mint ); | 1122 | setMinimumSize( minl, mint ); |
1127 | } else { | 1123 | } else { |
1128 | setMaximumSize( maxt, maxl ); | 1124 | setMaximumSize( maxt, maxl ); |
1129 | setMinimumSize( mint, minl ); | 1125 | setMinimumSize( mint, minl ); |
1130 | } | 1126 | } |
1131 | if ( update ) | 1127 | if ( update ) |
1132 | doResize(); | 1128 | doResize(); |
1133 | } | 1129 | } |
1134 | 1130 | ||
1135 | /*! | 1131 | /*! |
1136 | Sets resize mode of \a w to \a mode. | 1132 | Sets resize mode of \a w to \a mode. |
1137 | 1133 | ||
1138 | \sa ResizeMode | 1134 | \sa ResizeMode |
1139 | */ | 1135 | */ |
1140 | 1136 | ||
1141 | void KDGanttMinimizeSplitter::setResizeMode( QWidget *w, ResizeMode mode ) | 1137 | void KDGanttMinimizeSplitter::setResizeMode( QWidget *w, ResizeMode mode ) |
1142 | { | 1138 | { |
1143 | processChildEvents(); | 1139 | processChildEvents(); |
1144 | QSplitterLayoutStruct *s = data->list.first(); | 1140 | QSplitterLayoutStruct *s = data->list.first(); |
1145 | while ( s ) { | 1141 | while ( s ) { |
1146 | if ( s->wid == w ) { | 1142 | if ( s->wid == w ) { |
1147 | s->mode = mode; | 1143 | s->mode = mode; |
1148 | return; | 1144 | return; |
1149 | } | 1145 | } |
1150 | s = data->list.next(); | 1146 | s = data->list.next(); |
1151 | } | 1147 | } |
1152 | s = addWidget( w, TRUE ); | 1148 | s = addWidget( w, TRUE ); |
1153 | s->mode = mode; | 1149 | s->mode = mode; |
1154 | } | 1150 | } |
1155 | 1151 | ||
1156 | 1152 | ||
1157 | /*! | 1153 | /*! |
1158 | Returns TRUE if opaque resize is on; otherwise returns FALSE. | 1154 | Returns TRUE if opaque resize is on; otherwise returns FALSE. |
1159 | 1155 | ||
1160 | \sa setOpaqueResize() | 1156 | \sa setOpaqueResize() |
1161 | */ | 1157 | */ |
1162 | 1158 | ||
1163 | bool KDGanttMinimizeSplitter::opaqueResize() const | 1159 | bool KDGanttMinimizeSplitter::opaqueResize() const |
1164 | { | 1160 | { |
1165 | return data->opaque; | 1161 | return data->opaque; |
1166 | } | 1162 | } |
1167 | 1163 | ||
1168 | 1164 | ||
1169 | /*! | 1165 | /*! |
1170 | If \a on is TRUE then opaque resizing is turned on; otherwise | 1166 | If \a on is TRUE then opaque resizing is turned on; otherwise |
1171 | opaque resizing is turned off. | 1167 | opaque resizing is turned off. |
1172 | Opaque resizing is initially turned off. | 1168 | Opaque resizing is initially turned off. |
1173 | 1169 | ||
1174 | \sa opaqueResize() | 1170 | \sa opaqueResize() |
1175 | */ | 1171 | */ |
1176 | 1172 | ||
1177 | void KDGanttMinimizeSplitter::setOpaqueResize( bool on ) | 1173 | void KDGanttMinimizeSplitter::setOpaqueResize( bool on ) |
1178 | { | 1174 | { |
1179 | data->opaque = on; | 1175 | data->opaque = on; |
1180 | } | 1176 | } |
1181 | 1177 | ||
1182 | 1178 | ||
1183 | /*! | 1179 | /*! |
1184 | Moves widget \a w to the leftmost/top position. | 1180 | Moves widget \a w to the leftmost/top position. |
1185 | */ | 1181 | */ |
1186 | 1182 | ||
1187 | void KDGanttMinimizeSplitter::moveToFirst( QWidget *w ) | 1183 | void KDGanttMinimizeSplitter::moveToFirst( QWidget *w ) |
1188 | { | 1184 | { |
1189 | processChildEvents(); | 1185 | processChildEvents(); |
1190 | bool found = FALSE; | 1186 | bool found = FALSE; |
1191 | QSplitterLayoutStruct *s = data->list.first(); | 1187 | QSplitterLayoutStruct *s = data->list.first(); |
1192 | while ( s ) { | 1188 | while ( s ) { |
1193 | if ( s->wid == w ) { | 1189 | if ( s->wid == w ) { |
1194 | found = TRUE; | 1190 | found = TRUE; |
1195 | QSplitterLayoutStruct *p = data->list.prev(); | 1191 | QSplitterLayoutStruct *p = data->list.prev(); |
1196 | if ( p ) { // not already at first place | 1192 | if ( p ) { // not already at first place |
1197 | data->list.take(); //take p | 1193 | data->list.take(); //take p |
1198 | data->list.take(); // take s | 1194 | data->list.take(); // take s |
1199 | data->list.insert( 0, p ); | 1195 | data->list.insert( 0, p ); |
1200 | data->list.insert( 0, s ); | 1196 | data->list.insert( 0, s ); |
1201 | } | 1197 | } |
1202 | break; | 1198 | break; |
1203 | } | 1199 | } |
1204 | s = data->list.next(); | 1200 | s = data->list.next(); |
1205 | } | 1201 | } |
1206 | if ( !found ) | 1202 | if ( !found ) |
1207 | addWidget( w, TRUE ); | 1203 | addWidget( w, TRUE ); |
1208 | recalcId(); | 1204 | recalcId(); |
1209 | } | 1205 | } |
1210 | 1206 | ||
1211 | 1207 | ||
1212 | /*! | 1208 | /*! |
1213 | Moves widget \a w to the rightmost/bottom position. | 1209 | Moves widget \a w to the rightmost/bottom position. |
1214 | */ | 1210 | */ |
1215 | 1211 | ||
1216 | void KDGanttMinimizeSplitter::moveToLast( QWidget *w ) | 1212 | void KDGanttMinimizeSplitter::moveToLast( QWidget *w ) |
1217 | { | 1213 | { |
1218 | processChildEvents(); | 1214 | processChildEvents(); |
1219 | bool found = FALSE; | 1215 | bool found = FALSE; |
1220 | QSplitterLayoutStruct *s = data->list.first(); | 1216 | QSplitterLayoutStruct *s = data->list.first(); |
1221 | while ( s ) { | 1217 | while ( s ) { |
1222 | if ( s->wid == w ) { | 1218 | if ( s->wid == w ) { |
1223 | found = TRUE; | 1219 | found = TRUE; |
1224 | data->list.take(); // take s | 1220 | data->list.take(); // take s |
1225 | QSplitterLayoutStruct *p = data->list.current(); | 1221 | QSplitterLayoutStruct *p = data->list.current(); |
1226 | if ( p ) { // the splitter handle after s | 1222 | if ( p ) { // the splitter handle after s |
1227 | data->list.take(); //take p | 1223 | data->list.take(); //take p |
1228 | data->list.append( p ); | 1224 | data->list.append( p ); |
1229 | } | 1225 | } |
1230 | data->list.append( s ); | 1226 | data->list.append( s ); |
1231 | break; | 1227 | break; |
1232 | } | 1228 | } |
1233 | s = data->list.next(); | 1229 | s = data->list.next(); |
1234 | } | 1230 | } |
1235 | if ( !found ) | 1231 | if ( !found ) |
1236 | addWidget( w); | 1232 | addWidget( w); |
1237 | recalcId(); | 1233 | recalcId(); |
1238 | } | 1234 | } |
1239 | 1235 | ||
1240 | 1236 | ||
1241 | void KDGanttMinimizeSplitter::recalcId() | 1237 | void KDGanttMinimizeSplitter::recalcId() |
1242 | { | 1238 | { |
1243 | int n = data->list.count(); | 1239 | int n = data->list.count(); |
1244 | for ( int i = 0; i < n; i++ ) { | 1240 | for ( int i = 0; i < n; i++ ) { |
1245 | QSplitterLayoutStruct *s = data->list.at(i); | 1241 | QSplitterLayoutStruct *s = data->list.at(i); |
1246 | if ( s->isSplitter ) | 1242 | if ( s->isSplitter ) |
1247 | ((KDGanttSplitterHandle*)s->wid)->setId(i); | 1243 | ((KDGanttSplitterHandle*)s->wid)->setId(i); |
1248 | } | 1244 | } |
1249 | } | 1245 | } |
1250 | 1246 | ||
1251 | 1247 | ||
1252 | /*!\reimp | 1248 | /*!\reimp |
1253 | */ | 1249 | */ |
1254 | QSize KDGanttMinimizeSplitter::sizeHint() const | 1250 | QSize KDGanttMinimizeSplitter::sizeHint() const |
1255 | { | 1251 | { |
1256 | constPolish(); | 1252 | constPolish(); |
1257 | int l = 0; | 1253 | int l = 0; |
1258 | int t = 0; | 1254 | int t = 0; |
1259 | if ( children() ) { | 1255 | if ( children() ) { |
1260 | const QObjectList * c = children(); | 1256 | const QObjectList * c = children(); |
1261 | QObjectListIt it( *c ); | 1257 | QObjectListIt it( *c ); |
1262 | QObject * o; | 1258 | QObject * o; |
1263 | 1259 | ||
1264 | while( (o=it.current()) != 0 ) { | 1260 | while( (o=it.current()) != 0 ) { |
1265 | ++it; | 1261 | ++it; |
1266 | if ( o->isWidgetType() && | 1262 | if ( o->isWidgetType() && |
1267 | !((QWidget*)o)->isHidden() ) { | 1263 | !((QWidget*)o)->isHidden() ) { |
1268 | QSize s = ((QWidget*)o)->sizeHint(); | 1264 | QSize s = ((QWidget*)o)->sizeHint(); |
1269 | if ( s.isValid() ) { | 1265 | if ( s.isValid() ) { |
1270 | l += pick( s ); | 1266 | l += pick( s ); |
1271 | t = QMAX( t, trans( s ) ); | 1267 | t = QMAX( t, trans( s ) ); |
1272 | } | 1268 | } |
1273 | } | 1269 | } |
1274 | } | 1270 | } |
1275 | } | 1271 | } |
1276 | return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l ); | 1272 | return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l ); |
1277 | } | 1273 | } |
1278 | 1274 | ||
1279 | 1275 | ||
1280 | /*! | 1276 | /*! |
1281 | \reimp | 1277 | \reimp |
1282 | */ | 1278 | */ |
1283 | 1279 | ||
1284 | QSize KDGanttMinimizeSplitter::minimumSizeHint() const | 1280 | QSize KDGanttMinimizeSplitter::minimumSizeHint() const |
1285 | { | 1281 | { |
1286 | constPolish(); | 1282 | constPolish(); |
1287 | int l = 0; | 1283 | int l = 0; |
1288 | int t = 0; | 1284 | int t = 0; |
1289 | if ( children() ) { | 1285 | if ( children() ) { |
1290 | const QObjectList * c = children(); | 1286 | const QObjectList * c = children(); |
1291 | QObjectListIt it( *c ); | 1287 | QObjectListIt it( *c ); |
1292 | QObject * o; | 1288 | QObject * o; |
1293 | 1289 | ||
1294 | while( (o=it.current()) != 0 ) { | 1290 | while( (o=it.current()) != 0 ) { |
1295 | ++it; | 1291 | ++it; |
1296 | if ( o->isWidgetType() && | 1292 | if ( o->isWidgetType() && |
1297 | !((QWidget*)o)->isHidden() ) { | 1293 | !((QWidget*)o)->isHidden() ) { |
1298 | QSize s = minSizeHint((QWidget*)o); | 1294 | QSize s = minSizeHint((QWidget*)o); |
1299 | if ( s.isValid() ) { | 1295 | if ( s.isValid() ) { |
1300 | l += pick( s ); | 1296 | l += pick( s ); |
1301 | t = QMAX( t, trans( s ) ); | 1297 | t = QMAX( t, trans( s ) ); |
1302 | } | 1298 | } |
1303 | } | 1299 | } |
1304 | } | 1300 | } |
1305 | } | 1301 | } |
1306 | return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l ); | 1302 | return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l ); |
1307 | } | 1303 | } |
1308 | 1304 | ||
1309 | 1305 | ||
1310 | /* | 1306 | /* |
1311 | Calculates stretch parameters from current sizes | 1307 | Calculates stretch parameters from current sizes |
1312 | */ | 1308 | */ |
1313 | 1309 | ||
1314 | void KDGanttMinimizeSplitter::storeSizes() | 1310 | void KDGanttMinimizeSplitter::storeSizes() |
1315 | { | 1311 | { |
1316 | QSplitterLayoutStruct *s = data->list.first(); | 1312 | QSplitterLayoutStruct *s = data->list.first(); |
1317 | while ( s ) { | 1313 | while ( s ) { |
1318 | if ( !s->isSplitter ) | 1314 | if ( !s->isSplitter ) |
1319 | s->sizer = pick( s->wid->size() ); | 1315 | s->sizer = pick( s->wid->size() ); |
1320 | s = data->list.next(); | 1316 | s = data->list.next(); |
1321 | } | 1317 | } |
1322 | } | 1318 | } |
1323 | 1319 | ||
1324 | 1320 | ||
1325 | #if 0 // ### remove this code ASAP | 1321 | #if 0 // ### remove this code ASAP |
1326 | 1322 | ||
1327 | /*! | 1323 | /*! |
1328 | Hides \a w if \a hide is TRUE and updates the splitter. | 1324 | Hides \a w if \a hide is TRUE and updates the splitter. |
1329 | 1325 | ||
1330 | \warning Due to a limitation in the current implementation, | 1326 | \warning Due to a limitation in the current implementation, |
1331 | calling QWidget::hide() will not work. | 1327 | calling QWidget::hide() will not work. |
1332 | */ | 1328 | */ |
1333 | 1329 | ||
1334 | void KDGanttMinimizeSplitter::setHidden( QWidget *w, bool hide ) | 1330 | void KDGanttMinimizeSplitter::setHidden( QWidget *w, bool hide ) |
1335 | { | 1331 | { |
1336 | if ( w == w1 ) { | 1332 | if ( w == w1 ) { |
1337 | w1show = !hide; | 1333 | w1show = !hide; |
1338 | } else if ( w == w2 ) { | 1334 | } else if ( w == w2 ) { |
1339 | w2show = !hide; | 1335 | w2show = !hide; |
1340 | } else { | 1336 | } else { |
1341 | #ifdef QT_CHECK_RANGE | 1337 | #ifdef QT_CHECK_RANGE |
1342 | qWarning( "KDGanttMinimizeSplitter::setHidden(), unknown widget" ); | 1338 | qWarning( "KDGanttMinimizeSplitter::setHidden(), unknown widget" ); |
1343 | #endif | 1339 | #endif |
1344 | return; | 1340 | return; |
1345 | } | 1341 | } |
1346 | if ( hide ) | 1342 | if ( hide ) |
1347 | w->hide(); | 1343 | w->hide(); |
1348 | else | 1344 | else |
1349 | w->show(); | 1345 | w->show(); |
1350 | recalc( TRUE ); | 1346 | recalc( TRUE ); |
1351 | } | 1347 | } |
1352 | 1348 | ||
1353 | 1349 | ||
1354 | /*! | 1350 | /*! |
1355 | Returns the hidden status of \a w | 1351 | Returns the hidden status of \a w |
1356 | */ | 1352 | */ |
1357 | 1353 | ||
1358 | bool KDGanttMinimizeSplitter::isHidden( QWidget *w ) const | 1354 | bool KDGanttMinimizeSplitter::isHidden( QWidget *w ) const |
1359 | { | 1355 | { |
1360 | if ( w == w1 ) | 1356 | if ( w == w1 ) |
1361 | return !w1show; | 1357 | return !w1show; |
1362 | else if ( w == w2 ) | 1358 | else if ( w == w2 ) |
1363 | return !w2show; | 1359 | return !w2show; |
1364 | #ifdef QT_CHECK_RANGE | 1360 | #ifdef QT_CHECK_RANGE |
1365 | else | 1361 | else |
1366 | qWarning( "KDGanttMinimizeSplitter::isHidden(), unknown widget" ); | 1362 | qWarning( "KDGanttMinimizeSplitter::isHidden(), unknown widget" ); |
1367 | #endif | 1363 | #endif |
1368 | return FALSE; | 1364 | return FALSE; |
1369 | } | 1365 | } |
1370 | #endif | 1366 | #endif |
1371 | 1367 | ||
1372 | 1368 | ||
1373 | /*! | 1369 | /*! |
1374 | Returns a list of the size parameters of all the widgets in this | 1370 | Returns a list of the size parameters of all the widgets in this |
1375 | splitter. | 1371 | splitter. |
1376 | 1372 | ||
1377 | Giving the values to another splitter's setSizes() function will | 1373 | Giving the values to another splitter's setSizes() function will |
1378 | produce a splitter with the same layout as this one. | 1374 | produce a splitter with the same layout as this one. |
1379 | 1375 | ||
1380 | Note that if you want to iterate over the list, you should | 1376 | Note that if you want to iterate over the list, you should |
1381 | iterate over a copy, e.g. | 1377 | iterate over a copy, e.g. |
1382 | \code | 1378 | \code |
1383 | QValueList<int> list = mySplitter.sizes(); | 1379 | QValueList<int> list = mySplitter.sizes(); |
1384 | QValueList<int>::Iterator it = list.begin(); | 1380 | QValueList<int>::Iterator it = list.begin(); |
1385 | while( it != list.end() ) { | 1381 | while( it != list.end() ) { |
1386 | myProcessing( *it ); | 1382 | myProcessing( *it ); |
1387 | ++it; | 1383 | ++it; |
1388 | } | 1384 | } |
1389 | \endcode | 1385 | \endcode |
1390 | 1386 | ||
1391 | \sa setSizes() | 1387 | \sa setSizes() |
1392 | */ | 1388 | */ |
1393 | 1389 | ||
1394 | QValueList<int> KDGanttMinimizeSplitter::sizes() const | 1390 | QValueList<int> KDGanttMinimizeSplitter::sizes() const |
1395 | { | 1391 | { |
1396 | if ( !testWState(WState_Polished) ) { | 1392 | if ( !testWState(WState_Polished) ) { |
1397 | QWidget* that = (QWidget*) this; | 1393 | QWidget* that = (QWidget*) this; |
1398 | that->polish(); | 1394 | that->polish(); |
1399 | } | 1395 | } |
1400 | QValueList<int> list; | 1396 | QValueList<int> list; |
1401 | QSplitterLayoutStruct *s = data->list.first(); | 1397 | QSplitterLayoutStruct *s = data->list.first(); |
1402 | while ( s ) { | 1398 | while ( s ) { |
1403 | if ( !s->isSplitter ) | 1399 | if ( !s->isSplitter ) |
1404 | list.append( s->sizer ); | 1400 | list.append( s->sizer ); |
1405 | s = data->list.next(); | 1401 | s = data->list.next(); |
1406 | } | 1402 | } |
1407 | return list; | 1403 | return list; |
1408 | } | 1404 | } |
1409 | 1405 | ||
1410 | 1406 | ||
1411 | 1407 | ||
1412 | /*! | 1408 | /*! |
1413 | Sets the size parameters to the values given in \a list. | 1409 | Sets the size parameters to the values given in \a list. |
1414 | If the splitter is horizontal, the values set the sizes from | 1410 | If the splitter is horizontal, the values set the sizes from |
1415 | left to right. If it is vertical, the sizes are applied from | 1411 | left to right. If it is vertical, the sizes are applied from |
1416 | top to bottom. | 1412 | top to bottom. |
1417 | Extra values in \a list are ignored. | 1413 | Extra values in \a list are ignored. |
1418 | 1414 | ||
1419 | If \a list contains too few values, the result is undefined | 1415 | If \a list contains too few values, the result is undefined |
1420 | but the program will still be well-behaved. | 1416 | but the program will still be well-behaved. |
1421 | 1417 | ||
1422 | \sa sizes() | 1418 | \sa sizes() |
1423 | */ | 1419 | */ |
1424 | 1420 | ||
1425 | void KDGanttMinimizeSplitter::setSizes( QValueList<int> list ) | 1421 | void KDGanttMinimizeSplitter::setSizes( QValueList<int> list ) |
1426 | { | 1422 | { |
1427 | processChildEvents(); | 1423 | processChildEvents(); |
1428 | QValueList<int>::Iterator it = list.begin(); | 1424 | QValueList<int>::Iterator it = list.begin(); |
1429 | QSplitterLayoutStruct *s = data->list.first(); | 1425 | QSplitterLayoutStruct *s = data->list.first(); |
1430 | while ( s && it != list.end() ) { | 1426 | while ( s && it != list.end() ) { |
1431 | if ( !s->isSplitter ) { | 1427 | if ( !s->isSplitter ) { |
1432 | s->sizer = *it; | 1428 | s->sizer = *it; |
1433 | ++it; | 1429 | ++it; |
1434 | } | 1430 | } |
1435 | s = data->list.next(); | 1431 | s = data->list.next(); |
1436 | } | 1432 | } |
1437 | doResize(); | 1433 | doResize(); |
1438 | } | 1434 | } |
1439 | 1435 | ||
1440 | 1436 | ||
1441 | /*! | 1437 | /*! |
1442 | Gets all posted child events, ensuring that the internal state of | 1438 | Gets all posted child events, ensuring that the internal state of |
1443 | the splitter is consistent. | 1439 | the splitter is consistent. |
1444 | */ | 1440 | */ |
1445 | 1441 | ||
1446 | void KDGanttMinimizeSplitter::processChildEvents() | 1442 | void KDGanttMinimizeSplitter::processChildEvents() |
1447 | { | 1443 | { |
1448 | QApplication::sendPostedEvents( this, QEvent::ChildInserted ); | 1444 | QApplication::sendPostedEvents( this, QEvent::ChildInserted ); |
1449 | } | 1445 | } |
1450 | 1446 | ||
1451 | 1447 | ||
1452 | /*! | 1448 | /*! |
1453 | \reimp | 1449 | \reimp |
1454 | */ | 1450 | */ |
1455 | 1451 | ||
1456 | void KDGanttMinimizeSplitter::styleChange( QStyle& old ) | 1452 | void KDGanttMinimizeSplitter::styleChange( QStyle& old ) |
1457 | { | 1453 | { |
1458 | 1454 | ||
1459 | #if QT_VERSION >= 0x030000 | 1455 | #if QT_VERSION >= 0x030000 |
diff --git a/microkde/kdialogbase.cpp b/microkde/kdialogbase.cpp index e6144de..11635e1 100644 --- a/microkde/kdialogbase.cpp +++ b/microkde/kdialogbase.cpp | |||
@@ -1,296 +1,296 @@ | |||
1 | #include <qtabwidget.h> | 1 | #include <qtabwidget.h> |
2 | #include <qpushbutton.h> | 2 | #include <qpushbutton.h> |
3 | #include <qlayout.h> | 3 | #include <qlayout.h> |
4 | #include <qframe.h> | 4 | #include <qframe.h> |
5 | 5 | ||
6 | 6 | ||
7 | #include "klocale.h" | 7 | #include "klocale.h" |
8 | #include "kdebug.h" | 8 | #include "kdebug.h" |
9 | 9 | ||
10 | #include "kdialogbase.h" | 10 | #include "kdialogbase.h" |
11 | 11 | ||
12 | KDialogBase::KDialogBase() | 12 | KDialogBase::KDialogBase() |
13 | { | 13 | { |
14 | } | 14 | } |
15 | 15 | ||
16 | KDialogBase::KDialogBase( QWidget *parent, const char *name, bool modal, | 16 | KDialogBase::KDialogBase( QWidget *parent, const char *name, bool modal, |
17 | const QString &caption, | 17 | const QString &caption, |
18 | int buttonMask, ButtonCode defaultButton, | 18 | int buttonMask, ButtonCode defaultButton, |
19 | bool separator, | 19 | bool separator, |
20 | const QString &user1, | 20 | const QString &user1, |
21 | const QString &user2, | 21 | const QString &user2, |
22 | const QString &user3) : | 22 | const QString &user3) : |
23 | KDialog( parent, name, modal ) | 23 | KDialog( parent, name, modal ) |
24 | { | 24 | { |
25 | init( caption, buttonMask, user1, user2 ); | 25 | init( caption, buttonMask, user1, user2 ); |
26 | if (findButton( defaultButton ) ) { | 26 | if (findButton( defaultButton ) ) { |
27 | (findButton( defaultButton ) )->setFocus(); | 27 | (findButton( defaultButton ) )->setFocus(); |
28 | (findButton( defaultButton ) )->setDefault( true ); | 28 | (findButton( defaultButton ) )->setDefault( true ); |
29 | } | 29 | } |
30 | 30 | ||
31 | } | 31 | } |
32 | 32 | ||
33 | KDialogBase::KDialogBase( int dialogFace, const QString &caption, | 33 | KDialogBase::KDialogBase( int dialogFace, const QString &caption, |
34 | int buttonMask, ButtonCode defaultButton, | 34 | int buttonMask, ButtonCode defaultButton, |
35 | QWidget *parent, const char *name, bool modal, | 35 | QWidget *parent, const char *name, bool modal, |
36 | bool separator, | 36 | bool separator, |
37 | const QString &user1, | 37 | const QString &user1, |
38 | const QString &user2, | 38 | const QString &user2, |
39 | const QString &user3) : | 39 | const QString &user3) : |
40 | KDialog( parent, name, modal ) | 40 | KDialog( parent, name, modal ) |
41 | { | 41 | { |
42 | init( caption, buttonMask, user1, user2 ); | 42 | init( caption, buttonMask, user1, user2 ); |
43 | if (findButton( defaultButton ) ) { | 43 | if (findButton( defaultButton ) ) { |
44 | (findButton( defaultButton ) )->setFocus(); | 44 | (findButton( defaultButton ) )->setFocus(); |
45 | (findButton( defaultButton ) )->setDefault( true ); | 45 | (findButton( defaultButton ) )->setDefault( true ); |
46 | } | 46 | } |
47 | 47 | ||
48 | } | 48 | } |
49 | 49 | ||
50 | KDialogBase::~KDialogBase() | 50 | KDialogBase::~KDialogBase() |
51 | { | 51 | { |
52 | } | 52 | } |
53 | 53 | ||
54 | void KDialogBase::init( const QString &caption, int buttonMask, | 54 | void KDialogBase::init( const QString &caption, int buttonMask, |
55 | const QString &user1 ,const QString &user2 ) | 55 | const QString &user1 ,const QString &user2 ) |
56 | { | 56 | { |
57 | mMainWidget = 0; | 57 | mMainWidget = 0; |
58 | mTabWidget = 0; | 58 | mTabWidget = 0; |
59 | mPlainPage = 0; | 59 | mPlainPage = 0; |
60 | mTopLayout = 0; | 60 | mTopLayout = 0; |
61 | if ( !caption.isEmpty() ) { | 61 | if ( !caption.isEmpty() ) { |
62 | setCaption( caption ); | 62 | setCaption( caption ); |
63 | } | 63 | } |
64 | 64 | ||
65 | if ( buttonMask & User1 ) { | 65 | if ( buttonMask & User1 ) { |
66 | mUser1Button = new QPushButton( user1, this ); | 66 | mUser1Button = new QPushButton( user1, this ); |
67 | connect( mUser1Button, SIGNAL( clicked() ), SLOT( slotUser1() ) ); | 67 | connect( mUser1Button, SIGNAL( clicked() ), SLOT( slotUser1() ) ); |
68 | } else { | 68 | } else { |
69 | mUser1Button = 0; | 69 | mUser1Button = 0; |
70 | } | 70 | } |
71 | if ( buttonMask & User2 ) { | 71 | if ( buttonMask & User2 ) { |
72 | mUser2Button = new QPushButton( user2, this ); | 72 | mUser2Button = new QPushButton( user2, this ); |
73 | connect( mUser2Button, SIGNAL( clicked() ), SLOT( slotUser2() ) ); | 73 | connect( mUser2Button, SIGNAL( clicked() ), SLOT( slotUser2() ) ); |
74 | } else { | 74 | } else { |
75 | mUser2Button = 0; | 75 | mUser2Button = 0; |
76 | } | 76 | } |
77 | 77 | ||
78 | if ( buttonMask & Ok ) { | 78 | if ( buttonMask & Ok ) { |
79 | mOkButton = new QPushButton( i18n("Ok"), this ); | 79 | mOkButton = new QPushButton( i18n("Ok"), this ); |
80 | connect( mOkButton, SIGNAL( clicked() ), SLOT( slotOk() ) ); | 80 | connect( mOkButton, SIGNAL( clicked() ), SLOT( slotOk() ) ); |
81 | //mOkButton->setDefault( true ); | 81 | //mOkButton->setDefault( true ); |
82 | } else { | 82 | } else { |
83 | mOkButton = 0; | 83 | mOkButton = 0; |
84 | } | 84 | } |
85 | if ( buttonMask & Default ) { | 85 | if ( buttonMask & Default ) { |
86 | mDefaultButton = new QPushButton( i18n("Default"), this ); | 86 | mDefaultButton = new QPushButton( i18n("Default"), this ); |
87 | connect( mDefaultButton, SIGNAL( clicked() ), SIGNAL( defaultClicked() ) ); | 87 | connect( mDefaultButton, SIGNAL( clicked() ), SIGNAL( defaultClicked() ) ); |
88 | } else { | 88 | } else { |
89 | mDefaultButton = 0; | 89 | mDefaultButton = 0; |
90 | } | 90 | } |
91 | 91 | ||
92 | if ( buttonMask & Apply ) { | 92 | if ( buttonMask & Apply ) { |
93 | mApplyButton = new QPushButton( i18n("Apply"), this ); | 93 | mApplyButton = new QPushButton( i18n("Apply"), this ); |
94 | connect( mApplyButton, SIGNAL( clicked() ), SLOT( slotApply() ) ); | 94 | connect( mApplyButton, SIGNAL( clicked() ), SLOT( slotApply() ) ); |
95 | } else { | 95 | } else { |
96 | mApplyButton = 0; | 96 | mApplyButton = 0; |
97 | } | 97 | } |
98 | 98 | ||
99 | if ( buttonMask & Cancel ) { | 99 | if ( buttonMask & Cancel ) { |
100 | mCancelButton = new QPushButton( i18n("Cancel"), this ); | 100 | mCancelButton = new QPushButton( i18n("Cancel"), this ); |
101 | connect( mCancelButton, SIGNAL( clicked() ), SLOT( slotCancel() ) ); | 101 | connect( mCancelButton, SIGNAL( clicked() ), SLOT( slotCancel() ) ); |
102 | } else { | 102 | } else { |
103 | mCancelButton = 0; | 103 | mCancelButton = 0; |
104 | } | 104 | } |
105 | 105 | ||
106 | if ( buttonMask & Close ) { | 106 | if ( buttonMask & Close ) { |
107 | mCloseButton = new QPushButton( i18n("Close"), this ); | 107 | mCloseButton = new QPushButton( i18n("Close"), this ); |
108 | connect( mCloseButton, SIGNAL( clicked() ), SLOT( slotClose() ) ); | 108 | connect( mCloseButton, SIGNAL( clicked() ), SLOT( slotClose() ) ); |
109 | } else { | 109 | } else { |
110 | mCloseButton = 0; | 110 | mCloseButton = 0; |
111 | } | 111 | } |
112 | } | 112 | } |
113 | 113 | ||
114 | QTabWidget *KDialogBase::tabWidget() | 114 | QTabWidget *KDialogBase::tabWidget() |
115 | { | 115 | { |
116 | if ( !mTabWidget ) { | 116 | if ( !mTabWidget ) { |
117 | mTabWidget = new QTabWidget( this ); | 117 | mTabWidget = new QTabWidget( this ); |
118 | setMainWidget( mTabWidget ); | 118 | setMainWidget( mTabWidget ); |
119 | } | 119 | } |
120 | return mTabWidget; | 120 | return mTabWidget; |
121 | } | 121 | } |
122 | 122 | ||
123 | void KDialogBase::hideButtons() | 123 | void KDialogBase::hideButtons() |
124 | { | 124 | { |
125 | if ( mUser1Button ) mUser1Button->hide() ; | 125 | if ( mUser1Button ) mUser1Button->hide() ; |
126 | if ( mUser2Button ) mUser2Button->hide() ; | 126 | if ( mUser2Button ) mUser2Button->hide() ; |
127 | if ( mOkButton ) mOkButton->hide() ; | 127 | if ( mOkButton ) mOkButton->hide() ; |
128 | if ( mApplyButton ) mApplyButton->hide() ; | 128 | if ( mApplyButton ) mApplyButton->hide() ; |
129 | if ( mDefaultButton ) mDefaultButton->hide(); | 129 | if ( mDefaultButton ) mDefaultButton->hide(); |
130 | if ( mCancelButton ) mCancelButton->hide() ; | 130 | if ( mCancelButton ) mCancelButton->hide() ; |
131 | if ( mCloseButton ) mCloseButton->hide() ; | 131 | if ( mCloseButton ) mCloseButton->hide() ; |
132 | 132 | ||
133 | } | 133 | } |
134 | void KDialogBase::initLayout() | 134 | void KDialogBase::initLayout() |
135 | { | 135 | { |
136 | 136 | ||
137 | delete mTopLayout; | 137 | delete mTopLayout; |
138 | mTopLayout = new QVBoxLayout( this ); | 138 | mTopLayout = new QVBoxLayout( this ); |
139 | mTopLayout->setMargin( marginHint() ); | 139 | mTopLayout->setMargin( marginHintSmall() ); |
140 | mTopLayout->setSpacing( spacingHint() ); | 140 | mTopLayout->setSpacing( spacingHintSmall() ); |
141 | 141 | ||
142 | mTopLayout->addWidget( mMainWidget ); | 142 | mTopLayout->addWidget( mMainWidget ); |
143 | 143 | ||
144 | QBoxLayout *buttonLayout = new QHBoxLayout; | 144 | QBoxLayout *buttonLayout = new QHBoxLayout; |
145 | mTopLayout->addLayout( buttonLayout ); | 145 | mTopLayout->addLayout( buttonLayout ); |
146 | 146 | ||
147 | if ( mUser1Button ) buttonLayout->addWidget( mUser1Button ); | 147 | if ( mUser1Button ) buttonLayout->addWidget( mUser1Button ); |
148 | if ( mUser2Button ) buttonLayout->addWidget( mUser2Button ); | 148 | if ( mUser2Button ) buttonLayout->addWidget( mUser2Button ); |
149 | if ( mOkButton ) buttonLayout->addWidget( mOkButton ); | 149 | if ( mOkButton ) buttonLayout->addWidget( mOkButton ); |
150 | if ( mApplyButton ) buttonLayout->addWidget( mApplyButton ); | 150 | if ( mApplyButton ) buttonLayout->addWidget( mApplyButton ); |
151 | if ( mDefaultButton ) buttonLayout->addWidget( mDefaultButton ); | 151 | if ( mDefaultButton ) buttonLayout->addWidget( mDefaultButton ); |
152 | if ( mCancelButton ) buttonLayout->addWidget( mCancelButton ); | 152 | if ( mCancelButton ) buttonLayout->addWidget( mCancelButton ); |
153 | if ( mCloseButton ) buttonLayout->addWidget( mCloseButton ); | 153 | if ( mCloseButton ) buttonLayout->addWidget( mCloseButton ); |
154 | buttonLayout->setMargin( 0 ); | 154 | buttonLayout->setMargin( marginHintSmall() ); |
155 | buttonLayout->setSpacing( spacingHint() ); | 155 | buttonLayout->setSpacing( spacingHintSmall() ); |
156 | } | 156 | } |
157 | 157 | ||
158 | QFrame *KDialogBase::addPage( const QString &name ) | 158 | QFrame *KDialogBase::addPage( const QString &name ) |
159 | { | 159 | { |
160 | // kdDebug() << "KDialogBase::addPage(): " << name << endl; | 160 | // kdDebug() << "KDialogBase::addPage(): " << name << endl; |
161 | QFrame *frame = new QFrame( tabWidget() ); | 161 | QFrame *frame = new QFrame( tabWidget() ); |
162 | tabWidget()->addTab( frame, name ); | 162 | tabWidget()->addTab( frame, name ); |
163 | return frame; | 163 | return frame; |
164 | } | 164 | } |
165 | 165 | ||
166 | QFrame *KDialogBase::addPage( const QString &name, int, const QPixmap & ) | 166 | QFrame *KDialogBase::addPage( const QString &name, int, const QPixmap & ) |
167 | { | 167 | { |
168 | return addPage( name ); | 168 | return addPage( name ); |
169 | } | 169 | } |
170 | 170 | ||
171 | 171 | ||
172 | void KDialogBase::setMainWidget( QWidget *widget ) | 172 | void KDialogBase::setMainWidget( QWidget *widget ) |
173 | { | 173 | { |
174 | kdDebug() << "KDialogBase::setMainWidget()" << endl; | 174 | kdDebug() << "KDialogBase::setMainWidget()" << endl; |
175 | 175 | ||
176 | mMainWidget = widget; | 176 | mMainWidget = widget; |
177 | initLayout(); | 177 | initLayout(); |
178 | } | 178 | } |
179 | 179 | ||
180 | void KDialogBase::setButtonText( ButtonCode id, const QString &text ) | 180 | void KDialogBase::setButtonText( ButtonCode id, const QString &text ) |
181 | { | 181 | { |
182 | QPushButton *button = findButton( id ); | 182 | QPushButton *button = findButton( id ); |
183 | if ( button ) { | 183 | if ( button ) { |
184 | button->setText( text ); | 184 | button->setText( text ); |
185 | } | 185 | } |
186 | } | 186 | } |
187 | 187 | ||
188 | void KDialogBase::enableButton( ButtonCode id, bool state ) | 188 | void KDialogBase::enableButton( ButtonCode id, bool state ) |
189 | { | 189 | { |
190 | QPushButton *button = findButton( id ); | 190 | QPushButton *button = findButton( id ); |
191 | if ( button ) { | 191 | if ( button ) { |
192 | button->setEnabled( state ); | 192 | button->setEnabled( state ); |
193 | } | 193 | } |
194 | } | 194 | } |
195 | 195 | ||
196 | QPushButton *KDialogBase::findButton( ButtonCode id ) | 196 | QPushButton *KDialogBase::findButton( ButtonCode id ) |
197 | { | 197 | { |
198 | QPushButton *button = 0; | 198 | QPushButton *button = 0; |
199 | switch ( id ) { | 199 | switch ( id ) { |
200 | case Ok: | 200 | case Ok: |
201 | button = mOkButton; | 201 | button = mOkButton; |
202 | break; | 202 | break; |
203 | case Apply: | 203 | case Apply: |
204 | button = mApplyButton; | 204 | button = mApplyButton; |
205 | break; | 205 | break; |
206 | case User1: | 206 | case User1: |
207 | button = mUser1Button; | 207 | button = mUser1Button; |
208 | break; | 208 | break; |
209 | case User2: | 209 | case User2: |
210 | button = mUser2Button; | 210 | button = mUser2Button; |
211 | break; | 211 | break; |
212 | case Cancel: | 212 | case Cancel: |
213 | button = mCancelButton; | 213 | button = mCancelButton; |
214 | break; | 214 | break; |
215 | case Default: | 215 | case Default: |
216 | button = mDefaultButton; | 216 | button = mDefaultButton; |
217 | break; | 217 | break; |
218 | case Close: | 218 | case Close: |
219 | button = mCloseButton; | 219 | button = mCloseButton; |
220 | break; | 220 | break; |
221 | default: | 221 | default: |
222 | break; | 222 | break; |
223 | } | 223 | } |
224 | return button; | 224 | return button; |
225 | } | 225 | } |
226 | 226 | ||
227 | void KDialogBase::enableButtonOK( bool state ) | 227 | void KDialogBase::enableButtonOK( bool state ) |
228 | { | 228 | { |
229 | enableButton( Ok, state ); | 229 | enableButton( Ok, state ); |
230 | } | 230 | } |
231 | 231 | ||
232 | void KDialogBase::enableButtonApply( bool state ) | 232 | void KDialogBase::enableButtonApply( bool state ) |
233 | { | 233 | { |
234 | enableButton( Apply, state ); | 234 | enableButton( Apply, state ); |
235 | } | 235 | } |
236 | 236 | ||
237 | void KDialogBase::showButton( ButtonCode id, bool show ) | 237 | void KDialogBase::showButton( ButtonCode id, bool show ) |
238 | { | 238 | { |
239 | QPushButton *button = findButton( id ); | 239 | QPushButton *button = findButton( id ); |
240 | if ( button ) { | 240 | if ( button ) { |
241 | if ( show ) button->show(); | 241 | if ( show ) button->show(); |
242 | else button->hide(); | 242 | else button->hide(); |
243 | } | 243 | } |
244 | } | 244 | } |
245 | 245 | ||
246 | int KDialogBase::pageIndex( QWidget *widget ) const | 246 | int KDialogBase::pageIndex( QWidget *widget ) const |
247 | { | 247 | { |
248 | return 0; | 248 | return 0; |
249 | } | 249 | } |
250 | 250 | ||
251 | 251 | ||
252 | bool KDialogBase::showPage( int index ) | 252 | bool KDialogBase::showPage( int index ) |
253 | { | 253 | { |
254 | tabWidget()->setCurrentPage( index );return false; | 254 | tabWidget()->setCurrentPage( index );return false; |
255 | } | 255 | } |
256 | 256 | ||
257 | QFrame *KDialogBase::plainPage() | 257 | QFrame *KDialogBase::plainPage() |
258 | { | 258 | { |
259 | if ( !mPlainPage ) { | 259 | if ( !mPlainPage ) { |
260 | mPlainPage = new QFrame( this ); | 260 | mPlainPage = new QFrame( this ); |
261 | setMainWidget( mPlainPage ); | 261 | setMainWidget( mPlainPage ); |
262 | } | 262 | } |
263 | return mPlainPage; | 263 | return mPlainPage; |
264 | } | 264 | } |
265 | 265 | ||
266 | void KDialogBase::slotOk() | 266 | void KDialogBase::slotOk() |
267 | { | 267 | { |
268 | emit okClicked(); | 268 | emit okClicked(); |
269 | accept(); | 269 | accept(); |
270 | } | 270 | } |
271 | 271 | ||
272 | void KDialogBase::slotApply() | 272 | void KDialogBase::slotApply() |
273 | { | 273 | { |
274 | emit applyClicked(); | 274 | emit applyClicked(); |
275 | } | 275 | } |
276 | 276 | ||
277 | void KDialogBase::slotCancel() | 277 | void KDialogBase::slotCancel() |
278 | { | 278 | { |
279 | emit cancelClicked(); | 279 | emit cancelClicked(); |
280 | reject(); | 280 | reject(); |
281 | } | 281 | } |
282 | 282 | ||
283 | void KDialogBase::slotClose() | 283 | void KDialogBase::slotClose() |
284 | { | 284 | { |
285 | emit closeClicked(); | 285 | emit closeClicked(); |
286 | reject(); | 286 | reject(); |
287 | } | 287 | } |
288 | 288 | ||
289 | void KDialogBase::slotUser1() | 289 | void KDialogBase::slotUser1() |
290 | { | 290 | { |
291 | emit user1Clicked(); | 291 | emit user1Clicked(); |
292 | } | 292 | } |
293 | void KDialogBase::slotUser2() | 293 | void KDialogBase::slotUser2() |
294 | { | 294 | { |
295 | emit user2Clicked(); | 295 | emit user2Clicked(); |
296 | } | 296 | } |