author | zautrix <zautrix> | 2005-04-01 19:24:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-01 19:24:18 (UTC) |
commit | b1e3bf53b1c4cc46ef0a2ded04338bc38a640161 (patch) (unidiff) | |
tree | 7f6aecc33d464e28d18e07b0663450e917ea594b | |
parent | 1022d8763a5185c74d1fb1fba9857d6e3afd9ff5 (diff) | |
download | kdepimpi-b1e3bf53b1c4cc46ef0a2ded04338bc38a640161.zip kdepimpi-b1e3bf53b1c4cc46ef0a2ded04338bc38a640161.tar.gz kdepimpi-b1e3bf53b1c4cc46ef0a2ded04338bc38a640161.tar.bz2 |
fix
-rw-r--r-- | korganizer/koagendaview.cpp | 16 | ||||
-rw-r--r-- | microkde/KDGanttMinimizeSplitter.cpp | 7 |
2 files changed, 16 insertions, 7 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index 99f547a..667ff2a 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -1,405 +1,413 @@ | |||
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 | // if ( globalFlagBlockAgenda ) |
114 | // return; | 114 | // return; |
115 | // bug: the parameters cx, cy, cw, ch are the areas that need to be | 115 | // bug: the parameters cx, cy, cw, ch are the areas that need to be |
116 | // redrawn, not the area of the widget. unfortunately, this | 116 | // redrawn, not the area of the widget. unfortunately, this |
117 | // code assumes the latter... | 117 | // code assumes the latter... |
118 | 118 | ||
119 | // now, for a workaround... | 119 | // now, for a workaround... |
120 | // these two assignments fix the weird redraw bug | 120 | // these two assignments fix the weird redraw bug |
121 | mRedrawNeeded = true; | 121 | mRedrawNeeded = true; |
122 | if ( mRedrawNeeded ) { | 122 | if ( mRedrawNeeded ) { |
123 | cx = contentsX() + frameWidth()*2; | 123 | cx = contentsX() + frameWidth()*2; |
124 | cw = contentsWidth() ; | 124 | cw = contentsWidth() ; |
125 | // end of workaround | 125 | // end of workaround |
126 | 126 | ||
127 | int cell = ((int)(cy/mCellHeight)); | 127 | int cell = ((int)(cy/mCellHeight)); |
128 | int y = cell * mCellHeight; | 128 | int y = cell * mCellHeight; |
129 | QFontMetrics fm = fontMetrics(); | 129 | QFontMetrics fm = fontMetrics(); |
130 | QString hour; | 130 | QString hour; |
131 | QString suffix; | 131 | QString suffix; |
132 | int timeHeight = fm.ascent(); | 132 | int timeHeight = fm.ascent(); |
133 | QFont nFont = p->font(); | 133 | QFont nFont = p->font(); |
134 | 134 | ||
135 | if (!KGlobal::locale()->use12Clock()) | 135 | if (!KGlobal::locale()->use12Clock()) |
136 | suffix = "00"; | 136 | suffix = "00"; |
137 | 137 | ||
138 | if ( timeHeight > mCellHeight ) { | 138 | if ( timeHeight > mCellHeight ) { |
139 | timeHeight = mCellHeight-1; | 139 | timeHeight = mCellHeight-1; |
140 | int pointS = nFont.pointSize(); | 140 | int pointS = nFont.pointSize(); |
141 | while ( pointS > 4 ) { | 141 | while ( pointS > 4 ) { |
142 | nFont.setPointSize( pointS ); | 142 | nFont.setPointSize( pointS ); |
143 | fm = QFontMetrics( nFont ); | 143 | fm = QFontMetrics( nFont ); |
144 | if ( fm.ascent() < mCellHeight ) | 144 | if ( fm.ascent() < mCellHeight ) |
145 | break; | 145 | break; |
146 | -- pointS; | 146 | -- pointS; |
147 | } | 147 | } |
148 | fm = QFontMetrics( nFont ); | 148 | fm = QFontMetrics( nFont ); |
149 | timeHeight = fm.ascent(); | 149 | timeHeight = fm.ascent(); |
150 | } | 150 | } |
151 | //timeHeight -= (timeHeight/4-2); | 151 | //timeHeight -= (timeHeight/4-2); |
152 | QFont sFont = nFont; | 152 | QFont sFont = nFont; |
153 | sFont.setPointSize( sFont.pointSize()/2 ); | 153 | sFont.setPointSize( sFont.pointSize()/2 ); |
154 | QFontMetrics fmS( sFont ); | 154 | QFontMetrics fmS( sFont ); |
155 | int sHei = fmS.ascent() ; | 155 | int sHei = fmS.ascent() ; |
156 | //sHei -= (sHei/4-2); | 156 | //sHei -= (sHei/4-2); |
157 | int startW = this->width() - 2*frameWidth()-1; | 157 | int startW = this->width() - frameWidth()-2; |
158 | int tw2 = fmS.width(suffix); | 158 | int tw2 = fmS.width(suffix); |
159 | while (y < cy + ch) { | 159 | while (y < cy + ch) { |
160 | p->drawLine(cx,y,cw,y); | 160 | p->drawLine(cx,y,cw,y); |
161 | hour.setNum(cell); | 161 | hour.setNum(cell); |
162 | 162 | ||
163 | // handle 24h and am/pm time formats | 163 | // handle 24h and am/pm time formats |
164 | if (KGlobal::locale()->use12Clock()) { | 164 | if (KGlobal::locale()->use12Clock()) { |
165 | if (cell > 11) suffix = "pm"; | 165 | if (cell > 11) suffix = "pm"; |
166 | else | 166 | else |
167 | suffix = "am"; | 167 | suffix = "am"; |
168 | if (cell == 0) hour.setNum(12); | 168 | if (cell == 0) hour.setNum(12); |
169 | if (cell > 12) hour.setNum(cell - 12); | 169 | if (cell > 12) hour.setNum(cell - 12); |
170 | tw2 = fmS.width(suffix); | 170 | tw2 = fmS.width(suffix); |
171 | } | 171 | } |
172 | 172 | ||
173 | // center and draw the time label | 173 | // center and draw the time label |
174 | int timeWidth = fm.width(hour); | 174 | int timeWidth = fm.width(hour); |
175 | int offset = startW - timeWidth - tw2 ; | 175 | int offset = startW - timeWidth - tw2 ; |
176 | p->setFont( nFont ); | 176 | p->setFont( nFont ); |
177 | p->drawText( offset, y+ timeHeight, hour); | 177 | p->drawText( offset, y+ timeHeight, hour); |
178 | p->setFont( sFont ); | 178 | p->setFont( sFont ); |
179 | offset = startW - tw2+1; | 179 | offset = startW - tw2+1; |
180 | p->drawText( offset, y+ sHei, suffix); | 180 | p->drawText( offset, y+ sHei, suffix); |
181 | 181 | ||
182 | // increment indices | 182 | // increment indices |
183 | y += mCellHeight; | 183 | y += mCellHeight; |
184 | cell++; | 184 | cell++; |
185 | } | 185 | } |
186 | } else { | 186 | } else { |
187 | //qDebug("NO redraw "); | 187 | //qDebug("NO redraw "); |
188 | } | 188 | } |
189 | // double buffer not yet implemented | 189 | // double buffer not yet implemented |
190 | //bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); | 190 | //bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); |
191 | //mRedrawNeeded = false; | 191 | //mRedrawNeeded = false; |
192 | } | 192 | } |
193 | 193 | ||
194 | /** | 194 | /** |
195 | Calculates the minimum width. | 195 | Calculates the minimum width. |
196 | */ | 196 | */ |
197 | int TimeLabels::minimumWidth() const | 197 | int TimeLabels::minimumWidth() const |
198 | { | 198 | { |
199 | return mMiniWidth; | 199 | return mMiniWidth; |
200 | } | 200 | } |
201 | 201 | ||
202 | /** updates widget's internal state */ | 202 | /** updates widget's internal state */ |
203 | void TimeLabels::updateConfig() | 203 | void TimeLabels::updateConfig() |
204 | { | 204 | { |
205 | mRedrawNeeded = true; | 205 | mRedrawNeeded = true; |
206 | // set the font | 206 | // set the font |
207 | // config->setGroup("Fonts"); | 207 | // config->setGroup("Fonts"); |
208 | // QFont font = config->readFontEntry("TimeBar Font"); | 208 | // QFont font = config->readFontEntry("TimeBar Font"); |
209 | setFont(KOPrefs::instance()->mTimeBarFont); | 209 | setFont(KOPrefs::instance()->mTimeBarFont); |
210 | QString test = "20oo"; | 210 | QString test = "20"; |
211 | if (KGlobal::locale()->use12Clock()) | 211 | if (KGlobal::locale()->use12Clock()) |
212 | test = "12mi"; | 212 | test = "12"; |
213 | mMiniWidth = fontMetrics().width(test) + frameWidth()*2 +1 ; | 213 | mMiniWidth = fontMetrics().width(test); |
214 | if (KGlobal::locale()->use12Clock()) | ||
215 | test = "pm"; | ||
216 | else | ||
217 | test = "00"; | ||
218 | QFont sFont = font(); | ||
219 | sFont.setPointSize( sFont.pointSize()/2 ); | ||
220 | QFontMetrics fmS( sFont ); | ||
221 | mMiniWidth += fmS.width( test ) + frameWidth()*2 +4 ; | ||
214 | // update geometry restrictions based on new settings | 222 | // update geometry restrictions based on new settings |
215 | setFixedWidth( mMiniWidth ); | 223 | setFixedWidth( mMiniWidth ); |
216 | 224 | ||
217 | // update HourSize | 225 | // update HourSize |
218 | mCellHeight = KOPrefs::instance()->mHourSize*4; | 226 | mCellHeight = KOPrefs::instance()->mHourSize*4; |
219 | resizeContents(50,mRows * mCellHeight); | 227 | resizeContents(50,mRows * mCellHeight); |
220 | } | 228 | } |
221 | 229 | ||
222 | /** update time label positions */ | 230 | /** update time label positions */ |
223 | void TimeLabels::positionChanged() | 231 | void TimeLabels::positionChanged() |
224 | { | 232 | { |
225 | int adjustment = mAgenda->contentsY(); | 233 | int adjustment = mAgenda->contentsY(); |
226 | setContentsPos(0, adjustment); | 234 | setContentsPos(0, adjustment); |
227 | } | 235 | } |
228 | 236 | ||
229 | /** */ | 237 | /** */ |
230 | void TimeLabels::setAgenda(KOAgenda* agenda) | 238 | void TimeLabels::setAgenda(KOAgenda* agenda) |
231 | { | 239 | { |
232 | mAgenda = agenda; | 240 | mAgenda = agenda; |
233 | } | 241 | } |
234 | 242 | ||
235 | void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) | 243 | void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) |
236 | { | 244 | { |
237 | mMouseDownY = e->pos().y(); | 245 | mMouseDownY = e->pos().y(); |
238 | mOrgCap = topLevelWidget()->caption(); | 246 | mOrgCap = topLevelWidget()->caption(); |
239 | } | 247 | } |
240 | 248 | ||
241 | void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) | 249 | void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) |
242 | { | 250 | { |
243 | int diff = mMouseDownY - e->pos().y(); | 251 | int diff = mMouseDownY - e->pos().y(); |
244 | if ( diff < 10 && diff > -10 ) | 252 | if ( diff < 10 && diff > -10 ) |
245 | return; | 253 | return; |
246 | int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; | 254 | int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; |
247 | if ( tSize < 4 ) | 255 | if ( tSize < 4 ) |
248 | tSize = 4; | 256 | tSize = 4; |
249 | if ( tSize > 22 ) | 257 | if ( tSize > 22 ) |
250 | tSize = 22; | 258 | tSize = 22; |
251 | tSize = (tSize-2)/2; | 259 | tSize = (tSize-2)/2; |
252 | topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); | 260 | topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); |
253 | 261 | ||
254 | } | 262 | } |
255 | void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) | 263 | void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) |
256 | { | 264 | { |
257 | topLevelWidget()->setCaption( mOrgCap ); | 265 | topLevelWidget()->setCaption( mOrgCap ); |
258 | int diff = mMouseDownY - e->pos().y(); | 266 | int diff = mMouseDownY - e->pos().y(); |
259 | if ( diff < 10 && diff > -10 ) | 267 | if ( diff < 10 && diff > -10 ) |
260 | return; | 268 | return; |
261 | int tSize = KOPrefs::instance()->mHourSize + (diff/10); | 269 | int tSize = KOPrefs::instance()->mHourSize + (diff/10); |
262 | if ( tSize < 4 ) | 270 | if ( tSize < 4 ) |
263 | tSize = 4; | 271 | tSize = 4; |
264 | if ( tSize > 22 ) | 272 | if ( tSize > 22 ) |
265 | tSize = 22; | 273 | tSize = 22; |
266 | tSize = (tSize/2)*2; | 274 | tSize = (tSize/2)*2; |
267 | if ( tSize == KOPrefs::instance()->mHourSize ) | 275 | if ( tSize == KOPrefs::instance()->mHourSize ) |
268 | return; | 276 | return; |
269 | KOPrefs::instance()->mHourSize = tSize; | 277 | KOPrefs::instance()->mHourSize = tSize; |
270 | emit scaleChanged(); | 278 | emit scaleChanged(); |
271 | } | 279 | } |
272 | 280 | ||
273 | /** This is called in response to repaint() */ | 281 | /** This is called in response to repaint() */ |
274 | void TimeLabels::paintEvent(QPaintEvent*) | 282 | void TimeLabels::paintEvent(QPaintEvent*) |
275 | { | 283 | { |
276 | 284 | ||
277 | // kdDebug() << "paintevent..." << endl; | 285 | // kdDebug() << "paintevent..." << endl; |
278 | // this is another hack! | 286 | // this is another hack! |
279 | // QPainter painter(this); | 287 | // QPainter painter(this); |
280 | //QString c | 288 | //QString c |
281 | repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); | 289 | repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); |
282 | } | 290 | } |
283 | 291 | ||
284 | //////////////////////////////////////////////////////////////////////////// | 292 | //////////////////////////////////////////////////////////////////////////// |
285 | 293 | ||
286 | EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) | 294 | EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) |
287 | : QFrame(parent,name) | 295 | : QFrame(parent,name) |
288 | { | 296 | { |
289 | mColumns = 1; | 297 | mColumns = 1; |
290 | mTopBox = 0; | 298 | mTopBox = 0; |
291 | mLocation = loc; | 299 | mLocation = loc; |
292 | mTopLayout = 0; | 300 | mTopLayout = 0; |
293 | mPaintWidget = 0; | 301 | mPaintWidget = 0; |
294 | mXOffset = 0; | 302 | mXOffset = 0; |
295 | if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); | 303 | if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); |
296 | else mPixmap = SmallIcon("1downarrow"); | 304 | else mPixmap = SmallIcon("1downarrow"); |
297 | mEnabled.resize(mColumns); | 305 | mEnabled.resize(mColumns); |
298 | mEnabled.fill( false ); | 306 | mEnabled.fill( false ); |
299 | setMinimumHeight(mPixmap.height()); | 307 | setMinimumHeight(mPixmap.height()); |
300 | } | 308 | } |
301 | 309 | ||
302 | EventIndicator::~EventIndicator() | 310 | EventIndicator::~EventIndicator() |
303 | { | 311 | { |
304 | } | 312 | } |
305 | 313 | ||
306 | void EventIndicator::drawContents(QPainter *p) | 314 | void EventIndicator::drawContents(QPainter *p) |
307 | { | 315 | { |
308 | 316 | ||
309 | // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; | 317 | // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; |
310 | KDGanttSplitterHandle* han = 0; | 318 | KDGanttSplitterHandle* han = 0; |
311 | if ( mPaintWidget ) | 319 | if ( mPaintWidget ) |
312 | han = mPaintWidget->firstHandle(); | 320 | han = mPaintWidget->firstHandle(); |
313 | if ( ! han ) { | 321 | if ( ! han ) { |
314 | int i; | 322 | int i; |
315 | for(i=0;i<mColumns;++i) { | 323 | for(i=0;i<mColumns;++i) { |
316 | if (mEnabled[i]) { | 324 | if (mEnabled[i]) { |
317 | int cellWidth = contentsRect().right()/mColumns; | 325 | int cellWidth = contentsRect().right()/mColumns; |
318 | int xOffset = KOGlobals::self()->reverseLayout() ? | 326 | int xOffset = KOGlobals::self()->reverseLayout() ? |
319 | (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 : | 327 | (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 : |
320 | i*cellWidth + (cellWidth -mPixmap.width()) /2; | 328 | i*cellWidth + (cellWidth -mPixmap.width()) /2; |
321 | p->drawPixmap(QPoint(1+xOffset,0),mPixmap); | 329 | p->drawPixmap(QPoint(1+xOffset,0),mPixmap); |
322 | } | 330 | } |
323 | } | 331 | } |
324 | } else { | 332 | } else { |
325 | han->repaint(); | 333 | han->repaint(); |
326 | //mPaintWidget->setBackgroundColor( red ); | 334 | //mPaintWidget->setBackgroundColor( red ); |
327 | 335 | ||
328 | QPainter pa( han ); | 336 | QPainter pa( han ); |
329 | int i; | 337 | int i; |
330 | bool setColor = false; | 338 | bool setColor = false; |
331 | for(i=0;i<mColumns;++i) { | 339 | for(i=0;i<mColumns;++i) { |
332 | if (mEnabled[i]) { | 340 | if (mEnabled[i]) { |
333 | setColor = true; | 341 | setColor = true; |
334 | 342 | ||
335 | int cellWidth = contentsRect().right()/mColumns; | 343 | int cellWidth = contentsRect().right()/mColumns; |
336 | int xOffset = KOGlobals::self()->reverseLayout() ? | 344 | int xOffset = KOGlobals::self()->reverseLayout() ? |
337 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : | 345 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : |
338 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; | 346 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; |
339 | pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); | 347 | pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); |
340 | //qDebug("222draw pix %d ",xOffset ); | 348 | //qDebug("222draw pix %d ",xOffset ); |
341 | 349 | ||
342 | } | 350 | } |
343 | 351 | ||
344 | } | 352 | } |
345 | pa.end(); | 353 | pa.end(); |
346 | 354 | ||
347 | } | 355 | } |
348 | } | 356 | } |
349 | 357 | ||
350 | void EventIndicator::setXOffset( int x ) | 358 | void EventIndicator::setXOffset( int x ) |
351 | { | 359 | { |
352 | mXOffset = x; | 360 | mXOffset = x; |
353 | } | 361 | } |
354 | void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) | 362 | void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) |
355 | { | 363 | { |
356 | mPaintWidget = w; | 364 | mPaintWidget = w; |
357 | setMaximumHeight(0); | 365 | setMaximumHeight(0); |
358 | setMinimumHeight(0); | 366 | setMinimumHeight(0); |
359 | } | 367 | } |
360 | void EventIndicator::changeColumns(int columns) | 368 | void EventIndicator::changeColumns(int columns) |
361 | { | 369 | { |
362 | mColumns = columns; | 370 | mColumns = columns; |
363 | mEnabled.resize(mColumns); | 371 | mEnabled.resize(mColumns); |
364 | 372 | ||
365 | update(); | 373 | update(); |
366 | } | 374 | } |
367 | 375 | ||
368 | void EventIndicator::enableColumn(int column, bool enable) | 376 | void EventIndicator::enableColumn(int column, bool enable) |
369 | { | 377 | { |
370 | mEnabled[column] = enable; | 378 | mEnabled[column] = enable; |
371 | } | 379 | } |
372 | 380 | ||
373 | 381 | ||
374 | //////////////////////////////////////////////////////////////////////////// | 382 | //////////////////////////////////////////////////////////////////////////// |
375 | //////////////////////////////////////////////////////////////////////////// | 383 | //////////////////////////////////////////////////////////////////////////// |
376 | //////////////////////////////////////////////////////////////////////////// | 384 | //////////////////////////////////////////////////////////////////////////// |
377 | 385 | ||
378 | KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : | 386 | KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : |
379 | KOEventView (cal,parent,name) | 387 | KOEventView (cal,parent,name) |
380 | { | 388 | { |
381 | mBlockUpdating = true; | 389 | mBlockUpdating = true; |
382 | mStartHour = 8; | 390 | mStartHour = 8; |
383 | mSelectedDates.append(QDate::currentDate()); | 391 | mSelectedDates.append(QDate::currentDate()); |
384 | 392 | ||
385 | mLayoutDayLabels = 0; | 393 | mLayoutDayLabels = 0; |
386 | mDayLabelsFrame = 0; | 394 | mDayLabelsFrame = 0; |
387 | mDayLabels = 0; | 395 | mDayLabels = 0; |
388 | bool isRTL = KOGlobals::self()->reverseLayout(); | 396 | bool isRTL = KOGlobals::self()->reverseLayout(); |
389 | QPixmap expandPix; | 397 | QPixmap expandPix; |
390 | if ( KOPrefs::instance()->mVerticalScreen ) { | 398 | if ( KOPrefs::instance()->mVerticalScreen ) { |
391 | expandPix = SmallIcon( "1updownarrow" ); | 399 | expandPix = SmallIcon( "1updownarrow" ); |
392 | } else { | 400 | } else { |
393 | expandPix = SmallIcon("1leftrightarrow" ); | 401 | expandPix = SmallIcon("1leftrightarrow" ); |
394 | } | 402 | } |
395 | 403 | ||
396 | QBoxLayout *topLayout = new QVBoxLayout(this); | 404 | QBoxLayout *topLayout = new QVBoxLayout(this); |
397 | 405 | ||
398 | // Create day name labels for agenda columns | 406 | // Create day name labels for agenda columns |
399 | // Create agenda splitter | 407 | // Create agenda splitter |
400 | 408 | ||
401 | mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 409 | mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
402 | mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 410 | mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
403 | topLayout->addWidget( mSplitterAgenda ); | 411 | topLayout->addWidget( mSplitterAgenda ); |
404 | mAllDayFrame = new QHBox(mSplitterAgenda); | 412 | mAllDayFrame = new QHBox(mSplitterAgenda); |
405 | mAllDayFrame->setFocusPolicy(NoFocus); | 413 | mAllDayFrame->setFocusPolicy(NoFocus); |
diff --git a/microkde/KDGanttMinimizeSplitter.cpp b/microkde/KDGanttMinimizeSplitter.cpp index d675517..6cb1f31 100644 --- a/microkde/KDGanttMinimizeSplitter.cpp +++ b/microkde/KDGanttMinimizeSplitter.cpp | |||
@@ -489,393 +489,394 @@ void KDGanttMinimizeSplitter::init() | |||
489 | setSizePolicy( QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum) ); | 489 | setSizePolicy( QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum) ); |
490 | else | 490 | else |
491 | setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding) ); | 491 | setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding) ); |
492 | #ifndef DESKTOP_VERSION | 492 | #ifndef DESKTOP_VERSION |
493 | setOpaqueResize( false ); | 493 | setOpaqueResize( false ); |
494 | #else | 494 | #else |
495 | setOpaqueResize( true ); | 495 | setOpaqueResize( true ); |
496 | #endif | 496 | #endif |
497 | } | 497 | } |
498 | #endif | 498 | #endif |
499 | 499 | ||
500 | 500 | ||
501 | void KDGanttMinimizeSplitter::toggle() | 501 | void KDGanttMinimizeSplitter::toggle() |
502 | { | 502 | { |
503 | if ( mFirstHandle ) | 503 | if ( mFirstHandle ) |
504 | mFirstHandle->toggle(); | 504 | mFirstHandle->toggle(); |
505 | else | 505 | else |
506 | qDebug("KDGanttMinimizeSplitter::toggle::sorry, handle not available "); | 506 | qDebug("KDGanttMinimizeSplitter::toggle::sorry, handle not available "); |
507 | 507 | ||
508 | } | 508 | } |
509 | 509 | ||
510 | 510 | ||
511 | /*! | 511 | /*! |
512 | \brief the orientation of the splitter | 512 | \brief the orientation of the splitter |
513 | 513 | ||
514 | By default the orientation is horizontal (the widgets are side by side). | 514 | By default the orientation is horizontal (the widgets are side by side). |
515 | The possible orientations are Qt:Vertical and Qt::Horizontal (the default). | 515 | The possible orientations are Qt:Vertical and Qt::Horizontal (the default). |
516 | */ | 516 | */ |
517 | void KDGanttMinimizeSplitter::setOrientation( Orientation o ) | 517 | void KDGanttMinimizeSplitter::setOrientation( Orientation o ) |
518 | { | 518 | { |
519 | #if QT_VERSION >= 232 | 519 | #if QT_VERSION >= 232 |
520 | if ( orient == o ) | 520 | if ( orient == o ) |
521 | return; | 521 | return; |
522 | orient = o; | 522 | orient = o; |
523 | 523 | ||
524 | if ( orient == Horizontal ) | 524 | if ( orient == Horizontal ) |
525 | setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); | 525 | setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); |
526 | else | 526 | else |
527 | setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); | 527 | setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); |
528 | 528 | ||
529 | QSplitterLayoutStruct *s = data->list.first(); | 529 | QSplitterLayoutStruct *s = data->list.first(); |
530 | while ( s ) { | 530 | while ( s ) { |
531 | if ( s->isSplitter ) | 531 | if ( s->isSplitter ) |
532 | ((KDGanttSplitterHandle*)s->wid)->setOrientation( o ); | 532 | ((KDGanttSplitterHandle*)s->wid)->setOrientation( o ); |
533 | s = data->list.next(); // ### next at end of loop, no iterator | 533 | s = data->list.next(); // ### next at end of loop, no iterator |
534 | } | 534 | } |
535 | recalc( isVisible() ); | 535 | recalc( isVisible() ); |
536 | #endif | 536 | #endif |
537 | } | 537 | } |
538 | 538 | ||
539 | 539 | ||
540 | #if QT_VERSION >= 232 | 540 | #if QT_VERSION >= 232 |
541 | /*! | 541 | /*! |
542 | \reimp | 542 | \reimp |
543 | */ | 543 | */ |
544 | void KDGanttMinimizeSplitter::resizeEvent( QResizeEvent * ) | 544 | void KDGanttMinimizeSplitter::resizeEvent( QResizeEvent * ) |
545 | { | 545 | { |
546 | doResize(); | 546 | doResize(); |
547 | } | 547 | } |
548 | 548 | ||
549 | 549 | ||
550 | /* | 550 | /* |
551 | Inserts the widget \a w at the end (or at the beginning if \a first | 551 | Inserts the widget \a w at the end (or at the beginning if \a first |
552 | is TRUE) of the splitter's list of widgets. | 552 | is TRUE) of the splitter's list of widgets. |
553 | 553 | ||
554 | It is the responsibility of the caller of this function to make sure | 554 | It is the responsibility of the caller of this function to make sure |
555 | that \a w is not already in the splitter and to call recalcId if | 555 | that \a w is not already in the splitter and to call recalcId if |
556 | needed. (If \a first is TRUE, then recalcId is very probably | 556 | needed. (If \a first is TRUE, then recalcId is very probably |
557 | needed.) | 557 | needed.) |
558 | */ | 558 | */ |
559 | QSplitterLayoutStruct *KDGanttMinimizeSplitter::addWidget( QWidget *w, bool first ) | 559 | QSplitterLayoutStruct *KDGanttMinimizeSplitter::addWidget( QWidget *w, bool first ) |
560 | { | 560 | { |
561 | QSplitterLayoutStruct *s; | 561 | QSplitterLayoutStruct *s; |
562 | KDGanttSplitterHandle *newHandle = 0; | 562 | KDGanttSplitterHandle *newHandle = 0; |
563 | if ( data->list.count() > 0 ) { | 563 | if ( data->list.count() > 0 ) { |
564 | s = new QSplitterLayoutStruct; | 564 | s = new QSplitterLayoutStruct; |
565 | s->mode = KeepSize; | 565 | s->mode = KeepSize; |
566 | QString tmp = "qt_splithandle_"; | 566 | QString tmp = "qt_splithandle_"; |
567 | tmp += w->name(); | 567 | tmp += w->name(); |
568 | newHandle = new KDGanttSplitterHandle( orientation(), this, tmp.latin1() ); | 568 | newHandle = new KDGanttSplitterHandle( orientation(), this, tmp.latin1() ); |
569 | if ( ! mFirstHandle ) | 569 | if ( ! mFirstHandle ) |
570 | mFirstHandle = newHandle; | 570 | mFirstHandle = newHandle; |
571 | s->wid = newHandle; | 571 | s->wid = newHandle; |
572 | newHandle->setId(data->list.count()); | 572 | newHandle->setId(data->list.count()); |
573 | s->isSplitter = TRUE; | 573 | s->isSplitter = TRUE; |
574 | s->sizer = pick( newHandle->sizeHint() ); | 574 | s->sizer = pick( newHandle->sizeHint() ); |
575 | if ( first ) | 575 | if ( first ) |
576 | data->list.insert( 0, s ); | 576 | data->list.insert( 0, s ); |
577 | else | 577 | else |
578 | data->list.append( s ); | 578 | data->list.append( s ); |
579 | } | 579 | } |
580 | s = new QSplitterLayoutStruct; | 580 | s = new QSplitterLayoutStruct; |
581 | s->mode = Stretch; | 581 | s->mode = Stretch; |
582 | s->wid = w; | 582 | s->wid = w; |
583 | if ( !testWState( WState_Resized ) && w->sizeHint().isValid() ) | 583 | if ( !testWState( WState_Resized ) && w->sizeHint().isValid() ) |
584 | s->sizer = pick( w->sizeHint() ); | 584 | s->sizer = pick( w->sizeHint() ); |
585 | else | 585 | else |
586 | s->sizer = pick( w->size() ); | 586 | s->sizer = pick( w->size() ); |
587 | s->isSplitter = FALSE; | 587 | s->isSplitter = FALSE; |
588 | if ( first ) | 588 | if ( first ) |
589 | data->list.insert( 0, s ); | 589 | data->list.insert( 0, s ); |
590 | else | 590 | else |
591 | data->list.append( s ); | 591 | data->list.append( s ); |
592 | if ( newHandle && isVisible() ) | 592 | if ( newHandle && isVisible() ) |
593 | newHandle->show(); //will trigger sending of post events | 593 | newHandle->show(); //will trigger sending of post events |
594 | return s; | 594 | return s; |
595 | } | 595 | } |
596 | 596 | ||
597 | 597 | ||
598 | /*! | 598 | /*! |
599 | Tells the splitter that a child widget has been inserted or removed. | 599 | Tells the splitter that a child widget has been inserted or removed. |
600 | The event is passed in \a c. | 600 | The event is passed in \a c. |
601 | */ | 601 | */ |
602 | void KDGanttMinimizeSplitter::childEvent( QChildEvent *c ) | 602 | void KDGanttMinimizeSplitter::childEvent( QChildEvent *c ) |
603 | { | 603 | { |
604 | if ( c->type() == QEvent::ChildInserted ) { | 604 | if ( c->type() == QEvent::ChildInserted ) { |
605 | if ( !c->child()->isWidgetType() ) | 605 | if ( !c->child()->isWidgetType() ) |
606 | return; | 606 | return; |
607 | 607 | ||
608 | if ( ((QWidget*)c->child())->testWFlags( WType_TopLevel ) ) | 608 | if ( ((QWidget*)c->child())->testWFlags( WType_TopLevel ) ) |
609 | return; | 609 | return; |
610 | 610 | ||
611 | QSplitterLayoutStruct *s = data->list.first(); | 611 | QSplitterLayoutStruct *s = data->list.first(); |
612 | while ( s ) { | 612 | while ( s ) { |
613 | if ( s->wid == c->child() ) | 613 | if ( s->wid == c->child() ) |
614 | return; | 614 | return; |
615 | s = data->list.next(); | 615 | s = data->list.next(); |
616 | } | 616 | } |
617 | addWidget( (QWidget*)c->child() ); | 617 | addWidget( (QWidget*)c->child() ); |
618 | recalc( isVisible() ); | 618 | recalc( isVisible() ); |
619 | 619 | ||
620 | } else if ( c->type() == QEvent::ChildRemoved ) { | 620 | } else if ( c->type() == QEvent::ChildRemoved ) { |
621 | QSplitterLayoutStruct *p = 0; | 621 | QSplitterLayoutStruct *p = 0; |
622 | if ( data->list.count() > 1 ) | 622 | if ( data->list.count() > 1 ) |
623 | p = data->list.at(1); //remove handle _after_ first widget. | 623 | p = data->list.at(1); //remove handle _after_ first widget. |
624 | QSplitterLayoutStruct *s = data->list.first(); | 624 | QSplitterLayoutStruct *s = data->list.first(); |
625 | while ( s ) { | 625 | while ( s ) { |
626 | if ( s->wid == c->child() ) { | 626 | if ( s->wid == c->child() ) { |
627 | data->list.removeRef( s ); | 627 | data->list.removeRef( s ); |
628 | delete s; | 628 | delete s; |
629 | if ( p && p->isSplitter ) { | 629 | if ( p && p->isSplitter ) { |
630 | data->list.removeRef( p ); | 630 | data->list.removeRef( p ); |
631 | delete p->wid; //will call childEvent | 631 | delete p->wid; //will call childEvent |
632 | delete p; | 632 | delete p; |
633 | } | 633 | } |
634 | recalcId(); | 634 | recalcId(); |
635 | doResize(); | 635 | doResize(); |
636 | return; | 636 | return; |
637 | } | 637 | } |
638 | p = s; | 638 | p = s; |
639 | s = data->list.next(); | 639 | s = data->list.next(); |
640 | } | 640 | } |
641 | } | 641 | } |
642 | } | 642 | } |
643 | 643 | ||
644 | 644 | ||
645 | /*! | 645 | /*! |
646 | Shows a rubber band at position \a p. If \a p is negative, the | 646 | Shows a rubber band at position \a p. If \a p is negative, the |
647 | rubber band is removed. | 647 | rubber band is removed. |
648 | */ | 648 | */ |
649 | void KDGanttMinimizeSplitter::setRubberband( int p ) | 649 | void KDGanttMinimizeSplitter::setRubberband( int p ) |
650 | { | 650 | { |
651 | #ifdef DESKTOP_VERSION | 651 | #ifdef DESKTOP_VERSION |
652 | QPainter paint( this ); | 652 | QPainter paint( this ); |
653 | paint.setPen( gray ); | 653 | paint.setPen( gray ); |
654 | paint.setBrush( gray ); | 654 | paint.setBrush( gray ); |
655 | paint.setRasterOp( XorROP ); | 655 | paint.setRasterOp( XorROP ); |
656 | QRect r = contentsRect(); | 656 | QRect r = contentsRect(); |
657 | const int rBord = 3; //Themable???? | 657 | const int rBord = 3; //Themable???? |
658 | #if QT_VERSION >= 0x030000 | 658 | #if QT_VERSION >= 0x030000 |
659 | int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); | 659 | int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); |
660 | #else | 660 | #else |
661 | int sw = style().splitterWidth(); | 661 | int sw = style().splitterWidth(); |
662 | #endif | 662 | #endif |
663 | if ( orient == Horizontal ) { | 663 | if ( orient == Horizontal ) { |
664 | if ( opaqueOldPos >= 0 ) | 664 | if ( opaqueOldPos >= 0 ) |
665 | paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(), | 665 | paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(), |
666 | 2*rBord, r.height() ); | 666 | 2*rBord, r.height() ); |
667 | if ( p >= 0 ) | 667 | if ( p >= 0 ) |
668 | paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() ); | 668 | paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() ); |
669 | } else { | 669 | } else { |
670 | if ( opaqueOldPos >= 0 ) | 670 | if ( opaqueOldPos >= 0 ) |
671 | paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord, | 671 | paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord, |
672 | r.width(), 2*rBord ); | 672 | r.width(), 2*rBord ); |
673 | if ( p >= 0 ) | 673 | if ( p >= 0 ) |
674 | paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord ); | 674 | paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord ); |
675 | } | 675 | } |
676 | opaqueOldPos = p; | 676 | opaqueOldPos = p; |
677 | #else | 677 | #else |
678 | if ( !mRubberBand ) { | 678 | if ( !mRubberBand ) { |
679 | mRubberBand = new QFrame( 0, "rubber", WStyle_NoBorder | WStyle_Customize | WStyle_StaysOnTop); | 679 | mRubberBand = new QFrame( 0, "rubber", WStyle_NoBorder | WStyle_Customize | WStyle_StaysOnTop); |
680 | mRubberBand->setFrameStyle( Box | Raised ); | 680 | mRubberBand->setFrameStyle( Box | Raised ); |
681 | mRubberBand->setPalette( QPalette ( Qt::red.light(),Qt::red.dark() ) ); | 681 | //mRubberBand->setPalette( QPalette ( Qt::red.light(),Qt::red.dark() ) ); |
682 | mRubberBand->setPalette( QPalette ( QColor( 178,18,188), QColor( 242,27,255 ) )); | ||
682 | } | 683 | } |
683 | QRect r = contentsRect(); | 684 | QRect r = contentsRect(); |
684 | static int rBord = 0; //Themable???? | 685 | static int rBord = 0; //Themable???? |
685 | if ( !rBord ) { | 686 | if ( !rBord ) { |
686 | if (QApplication::desktop()->width() <= 320 ) | 687 | if (QApplication::desktop()->width() <= 320 ) |
687 | rBord = 4; | 688 | rBord = 3; |
688 | else | 689 | else |
689 | rBord = 5; | 690 | rBord = 4; |
690 | } | 691 | } |
691 | int sw = style().splitterWidth(); | 692 | int sw = style().splitterWidth(); |
692 | if ( orient == Horizontal ) { | 693 | if ( orient == Horizontal ) { |
693 | if ( p >= 0 ) { | 694 | if ( p >= 0 ) { |
694 | QPoint geo = mapToGlobal (QPoint ( p + sw/2 - rBord, r.y())); | 695 | QPoint geo = mapToGlobal (QPoint ( p + sw/2 - rBord, r.y())); |
695 | mRubberBand->setGeometry( geo.x(), geo.y(), 2*rBord, r.height() ); | 696 | mRubberBand->setGeometry( geo.x(), geo.y(), 2*rBord, r.height() ); |
696 | } | 697 | } |
697 | } else { | 698 | } else { |
698 | if ( p >= 0 ) { | 699 | if ( p >= 0 ) { |
699 | QPoint geo = mapToGlobal (QPoint ( r.x(), p + sw/2 - rBord)); | 700 | QPoint geo = mapToGlobal (QPoint ( r.x(), p + sw/2 - rBord)); |
700 | mRubberBand->setGeometry( geo.x(), geo.y(), r.width(), 2*rBord); | 701 | mRubberBand->setGeometry( geo.x(), geo.y(), r.width(), 2*rBord); |
701 | } | 702 | } |
702 | } | 703 | } |
703 | opaqueOldPos = p; | 704 | opaqueOldPos = p; |
704 | if ( ! mRubberBand->isVisible() ) { | 705 | if ( ! mRubberBand->isVisible() ) { |
705 | mRubberBand->show(); | 706 | mRubberBand->show(); |
706 | } | 707 | } |
707 | #endif | 708 | #endif |
708 | } | 709 | } |
709 | 710 | ||
710 | 711 | ||
711 | /*! \reimp */ | 712 | /*! \reimp */ |
712 | bool KDGanttMinimizeSplitter::event( QEvent *e ) | 713 | bool KDGanttMinimizeSplitter::event( QEvent *e ) |
713 | { | 714 | { |
714 | if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) { | 715 | if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) { |
715 | recalc( isVisible() ); | 716 | recalc( isVisible() ); |
716 | if ( e->type() == QEvent::Show ) | 717 | if ( e->type() == QEvent::Show ) |
717 | data->firstShow = FALSE; | 718 | data->firstShow = FALSE; |
718 | } | 719 | } |
719 | return QWidget::event( e ); | 720 | return QWidget::event( e ); |
720 | } | 721 | } |
721 | 722 | ||
722 | 723 | ||
723 | /*! | 724 | /*! |
724 | \obsolete | 725 | \obsolete |
725 | 726 | ||
726 | Draws the splitter handle in the rectangle described by \a x, \a y, | 727 | Draws the splitter handle in the rectangle described by \a x, \a y, |
727 | \a w, \a h using painter \a p. | 728 | \a w, \a h using painter \a p. |
728 | \sa QStyle::drawPrimitive() | 729 | \sa QStyle::drawPrimitive() |
729 | */ | 730 | */ |
730 | void KDGanttMinimizeSplitter::drawSplitter( QPainter *p, | 731 | void KDGanttMinimizeSplitter::drawSplitter( QPainter *p, |
731 | QCOORD x, QCOORD y, QCOORD w, QCOORD h ) | 732 | QCOORD x, QCOORD y, QCOORD w, QCOORD h ) |
732 | { | 733 | { |
733 | #if 0 | 734 | #if 0 |
734 | // LR | 735 | // LR |
735 | style().drawPrimitive(QStyle::PE_Splitter, p, QRect(x, y, w, h), colorGroup(), | 736 | style().drawPrimitive(QStyle::PE_Splitter, p, QRect(x, y, w, h), colorGroup(), |
736 | (orientation() == Qt::Horizontal ? | 737 | (orientation() == Qt::Horizontal ? |
737 | QStyle::Style_Horizontal : 0)); | 738 | QStyle::Style_Horizontal : 0)); |
738 | #endif | 739 | #endif |
739 | } | 740 | } |
740 | 741 | ||
741 | 742 | ||
742 | /*! | 743 | /*! |
743 | Returns the id of the splitter to the right of or below the widget \a w, | 744 | Returns the id of the splitter to the right of or below the widget \a w, |
744 | or 0 if there is no such splitter | 745 | or 0 if there is no such splitter |
745 | (i.e. it is either not in this KDGanttMinimizeSplitter or it is at the end). | 746 | (i.e. it is either not in this KDGanttMinimizeSplitter or it is at the end). |
746 | */ | 747 | */ |
747 | int KDGanttMinimizeSplitter::idAfter( QWidget* w ) const | 748 | int KDGanttMinimizeSplitter::idAfter( QWidget* w ) const |
748 | { | 749 | { |
749 | QSplitterLayoutStruct *s = data->list.first(); | 750 | QSplitterLayoutStruct *s = data->list.first(); |
750 | bool seen_w = FALSE; | 751 | bool seen_w = FALSE; |
751 | while ( s ) { | 752 | while ( s ) { |
752 | if ( s->isSplitter && seen_w ) | 753 | if ( s->isSplitter && seen_w ) |
753 | return data->list.at(); | 754 | return data->list.at(); |
754 | if ( !s->isSplitter && s->wid == w ) | 755 | if ( !s->isSplitter && s->wid == w ) |
755 | seen_w = TRUE; | 756 | seen_w = TRUE; |
756 | s = data->list.next(); | 757 | s = data->list.next(); |
757 | } | 758 | } |
758 | return 0; | 759 | return 0; |
759 | } | 760 | } |
760 | 761 | ||
761 | 762 | ||
762 | /*! | 763 | /*! |
763 | Moves the left/top edge of the splitter handle with id \a id as | 764 | Moves the left/top edge of the splitter handle with id \a id as |
764 | close as possible to position \a p, which is the distance from the | 765 | close as possible to position \a p, which is the distance from the |
765 | left (or top) edge of the widget. | 766 | left (or top) edge of the widget. |
766 | 767 | ||
767 | For Arabic and Hebrew the layout is reversed, and using this | 768 | For Arabic and Hebrew the layout is reversed, and using this |
768 | function to set the position of the splitter might lead to | 769 | function to set the position of the splitter might lead to |
769 | unexpected results, since in Arabic and Hebrew the position of | 770 | unexpected results, since in Arabic and Hebrew the position of |
770 | splitter one is to the left of the position of splitter zero. | 771 | splitter one is to the left of the position of splitter zero. |
771 | 772 | ||
772 | \sa idAfter() | 773 | \sa idAfter() |
773 | */ | 774 | */ |
774 | void KDGanttMinimizeSplitter::moveSplitter( QCOORD p, int id ) | 775 | void KDGanttMinimizeSplitter::moveSplitter( QCOORD p, int id ) |
775 | { | 776 | { |
776 | p = adjustPos( p, id ); | 777 | p = adjustPos( p, id ); |
777 | QSplitterLayoutStruct *s = data->list.at(id); | 778 | QSplitterLayoutStruct *s = data->list.at(id); |
778 | int oldP = orient == Horizontal ? s->wid->x() : s->wid->y(); | 779 | int oldP = orient == Horizontal ? s->wid->x() : s->wid->y(); |
779 | bool upLeft; | 780 | bool upLeft; |
780 | if ( false && orient == Horizontal ) { | 781 | if ( false && orient == Horizontal ) { |
781 | p += s->wid->width(); | 782 | p += s->wid->width(); |
782 | upLeft = p > oldP; | 783 | upLeft = p > oldP; |
783 | } else | 784 | } else |
784 | upLeft = p < oldP; | 785 | upLeft = p < oldP; |
785 | 786 | ||
786 | moveAfter( p, id, upLeft ); | 787 | moveAfter( p, id, upLeft ); |
787 | moveBefore( p-1, id-1, upLeft ); | 788 | moveBefore( p-1, id-1, upLeft ); |
788 | 789 | ||
789 | storeSizes(); | 790 | storeSizes(); |
790 | } | 791 | } |
791 | 792 | ||
792 | 793 | ||
793 | void KDGanttMinimizeSplitter::setG( QWidget *w, int p, int s, bool isSplitter ) | 794 | void KDGanttMinimizeSplitter::setG( QWidget *w, int p, int s, bool isSplitter ) |
794 | { | 795 | { |
795 | if ( orient == Horizontal ) { | 796 | if ( orient == Horizontal ) { |
796 | if ( false && orient == Horizontal && !isSplitter ) | 797 | if ( false && orient == Horizontal && !isSplitter ) |
797 | p = contentsRect().width() - p - s; | 798 | p = contentsRect().width() - p - s; |
798 | w->setGeometry( p, contentsRect().y(), s, contentsRect().height() ); | 799 | w->setGeometry( p, contentsRect().y(), s, contentsRect().height() ); |
799 | } else | 800 | } else |
800 | w->setGeometry( contentsRect().x(), p, contentsRect().width(), s ); | 801 | w->setGeometry( contentsRect().x(), p, contentsRect().width(), s ); |
801 | } | 802 | } |
802 | 803 | ||
803 | 804 | ||
804 | /* | 805 | /* |
805 | Places the right/bottom edge of the widget at \a id at position \a pos. | 806 | Places the right/bottom edge of the widget at \a id at position \a pos. |
806 | 807 | ||
807 | \sa idAfter() | 808 | \sa idAfter() |
808 | */ | 809 | */ |
809 | void KDGanttMinimizeSplitter::moveBefore( int pos, int id, bool upLeft ) | 810 | void KDGanttMinimizeSplitter::moveBefore( int pos, int id, bool upLeft ) |
810 | { | 811 | { |
811 | if( id < 0 ) | 812 | if( id < 0 ) |
812 | return; | 813 | return; |
813 | QSplitterLayoutStruct *s = data->list.at(id); | 814 | QSplitterLayoutStruct *s = data->list.at(id); |
814 | if ( !s ) | 815 | if ( !s ) |
815 | return; | 816 | return; |
816 | QWidget *w = s->wid; | 817 | QWidget *w = s->wid; |
817 | if ( w->isHidden() ) { | 818 | if ( w->isHidden() ) { |
818 | moveBefore( pos, id-1, upLeft ); | 819 | moveBefore( pos, id-1, upLeft ); |
819 | } else if ( s->isSplitter ) { | 820 | } else if ( s->isSplitter ) { |
820 | int pos1, pos2; | 821 | int pos1, pos2; |
821 | int dd = s->sizer; | 822 | int dd = s->sizer; |
822 | if( false && orient == Horizontal ) { | 823 | if( false && orient == Horizontal ) { |
823 | pos1 = pos; | 824 | pos1 = pos; |
824 | pos2 = pos + dd; | 825 | pos2 = pos + dd; |
825 | } else { | 826 | } else { |
826 | pos2 = pos - dd; | 827 | pos2 = pos - dd; |
827 | pos1 = pos2 + 1; | 828 | pos1 = pos2 + 1; |
828 | } | 829 | } |
829 | if ( upLeft ) { | 830 | if ( upLeft ) { |
830 | setG( w, pos1, dd, TRUE ); | 831 | setG( w, pos1, dd, TRUE ); |
831 | moveBefore( pos2, id-1, upLeft ); | 832 | moveBefore( pos2, id-1, upLeft ); |
832 | } else { | 833 | } else { |
833 | moveBefore( pos2, id-1, upLeft ); | 834 | moveBefore( pos2, id-1, upLeft ); |
834 | setG( w, pos1, dd, TRUE ); | 835 | setG( w, pos1, dd, TRUE ); |
835 | } | 836 | } |
836 | } else { | 837 | } else { |
837 | int dd, newLeft, nextPos; | 838 | int dd, newLeft, nextPos; |
838 | if( false && orient == Horizontal ) { | 839 | if( false && orient == Horizontal ) { |
839 | dd = w->geometry().right() - pos; | 840 | dd = w->geometry().right() - pos; |
840 | dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); | 841 | dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); |
841 | newLeft = pos+1; | 842 | newLeft = pos+1; |
842 | nextPos = newLeft + dd; | 843 | nextPos = newLeft + dd; |
843 | } else { | 844 | } else { |
844 | dd = pos - pick( w->pos() ) + 1; | 845 | dd = pos - pick( w->pos() ) + 1; |
845 | dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); | 846 | dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); |
846 | newLeft = pos-dd+1; | 847 | newLeft = pos-dd+1; |
847 | nextPos = newLeft - 1; | 848 | nextPos = newLeft - 1; |
848 | } | 849 | } |
849 | setG( w, newLeft, dd, TRUE ); | 850 | setG( w, newLeft, dd, TRUE ); |
850 | moveBefore( nextPos, id-1, upLeft ); | 851 | moveBefore( nextPos, id-1, upLeft ); |
851 | } | 852 | } |
852 | } | 853 | } |
853 | 854 | ||
854 | 855 | ||
855 | /* | 856 | /* |
856 | Places the left/top edge of the widget at \a id at position \a pos. | 857 | Places the left/top edge of the widget at \a id at position \a pos. |
857 | 858 | ||
858 | \sa idAfter() | 859 | \sa idAfter() |
859 | */ | 860 | */ |
860 | void KDGanttMinimizeSplitter::moveAfter( int pos, int id, bool upLeft ) | 861 | void KDGanttMinimizeSplitter::moveAfter( int pos, int id, bool upLeft ) |
861 | { | 862 | { |
862 | QSplitterLayoutStruct *s = id < int(data->list.count()) ? | 863 | QSplitterLayoutStruct *s = id < int(data->list.count()) ? |
863 | data->list.at(id) : 0; | 864 | data->list.at(id) : 0; |
864 | if ( !s ) | 865 | if ( !s ) |
865 | return; | 866 | return; |
866 | QWidget *w = s->wid; | 867 | QWidget *w = s->wid; |
867 | if ( w->isHidden() ) { | 868 | if ( w->isHidden() ) { |
868 | moveAfter( pos, id+1, upLeft ); | 869 | moveAfter( pos, id+1, upLeft ); |
869 | } else if ( pick( w->pos() ) == pos ) { | 870 | } else if ( pick( w->pos() ) == pos ) { |
870 | //No need to do anything if it's already there. | 871 | //No need to do anything if it's already there. |
871 | return; | 872 | return; |
872 | } else if ( s->isSplitter ) { | 873 | } else if ( s->isSplitter ) { |
873 | int dd = s->sizer; | 874 | int dd = s->sizer; |
874 | int pos1, pos2; | 875 | int pos1, pos2; |
875 | if( false && orient == Horizontal ) { | 876 | if( false && orient == Horizontal ) { |
876 | pos2 = pos - dd; | 877 | pos2 = pos - dd; |
877 | pos1 = pos2 + 1; | 878 | pos1 = pos2 + 1; |
878 | } else { | 879 | } else { |
879 | pos1 = pos; | 880 | pos1 = pos; |
880 | pos2 = pos + dd; | 881 | pos2 = pos + dd; |
881 | } | 882 | } |