author | zautrix <zautrix> | 2005-04-01 22:32:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-01 22:32:18 (UTC) |
commit | 02bdd5a73feb7bd2431c5492c7bbf663f28efbd8 (patch) (unidiff) | |
tree | c87553742dfa351f4d4ae2308d68dd87cc400304 | |
parent | efb66afca923f23a94b19da1fa12555956e70844 (diff) | |
download | kdepimpi-02bdd5a73feb7bd2431c5492c7bbf663f28efbd8.zip kdepimpi-02bdd5a73feb7bd2431c5492c7bbf663f28efbd8.tar.gz kdepimpi-02bdd5a73feb7bd2431c5492c7bbf663f28efbd8.tar.bz2 |
nf
-rw-r--r-- | korganizer/koagendaview.cpp | 24 | ||||
-rw-r--r-- | korganizer/kodaymatrix.cpp | 6 | ||||
-rw-r--r-- | microkde/KDGanttMinimizeSplitter.cpp | 13 |
3 files changed, 33 insertions, 10 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index 1627dba..2b05d37 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -39,275 +39,282 @@ | |||
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 | if ( QApplication::desktop()->width() <= 320 ) |
137 | suffix = ""; | ||
138 | else | ||
139 | suffix = "00"; | ||
140 | } | ||
137 | 141 | ||
138 | if ( timeHeight > mCellHeight ) { | 142 | if ( timeHeight > mCellHeight ) { |
139 | timeHeight = mCellHeight-1; | 143 | timeHeight = mCellHeight-1; |
140 | int pointS = nFont.pointSize(); | 144 | int pointS = nFont.pointSize(); |
141 | while ( pointS > 4 ) { | 145 | while ( pointS > 4 ) { |
142 | nFont.setPointSize( pointS ); | 146 | nFont.setPointSize( pointS ); |
143 | fm = QFontMetrics( nFont ); | 147 | fm = QFontMetrics( nFont ); |
144 | if ( fm.ascent() < mCellHeight ) | 148 | if ( fm.ascent() < mCellHeight ) |
145 | break; | 149 | break; |
146 | -- pointS; | 150 | -- pointS; |
147 | } | 151 | } |
148 | fm = QFontMetrics( nFont ); | 152 | fm = QFontMetrics( nFont ); |
149 | timeHeight = fm.ascent(); | 153 | timeHeight = fm.ascent(); |
150 | } | 154 | } |
151 | //timeHeight -= (timeHeight/4-2); | 155 | //timeHeight -= (timeHeight/4-2); |
152 | QFont sFont = nFont; | 156 | QFont sFont = nFont; |
153 | sFont.setPointSize( sFont.pointSize()/2 ); | 157 | sFont.setPointSize( sFont.pointSize()/2 ); |
154 | QFontMetrics fmS( sFont ); | 158 | QFontMetrics fmS( sFont ); |
155 | int sHei = fmS.ascent() ; | 159 | int sHei = fmS.ascent() ; |
156 | //sHei -= (sHei/4-2); | 160 | //sHei -= (sHei/4-2); |
157 | int startW = this->width() - frameWidth()-2; | 161 | int startW = this->width() - frameWidth()-2; |
158 | int tw2 = fmS.width(suffix); | 162 | int tw2 = fmS.width(suffix); |
159 | while (y < cy + ch) { | 163 | while (y < cy + ch) { |
160 | p->drawLine(cx,y,cw,y); | 164 | p->drawLine(cx,y,cw,y); |
161 | hour.setNum(cell); | 165 | hour.setNum(cell); |
162 | |||
163 | // handle 24h and am/pm time formats | 166 | // handle 24h and am/pm time formats |
164 | if (KGlobal::locale()->use12Clock()) { | 167 | if (KGlobal::locale()->use12Clock()) { |
165 | if (cell > 11) suffix = "pm"; | 168 | if (cell > 11) suffix = "pm"; |
166 | else | 169 | else |
167 | suffix = "am"; | 170 | suffix = "am"; |
168 | if (cell == 0) hour.setNum(12); | 171 | if (cell == 0) hour.setNum(12); |
169 | if (cell > 12) hour.setNum(cell - 12); | 172 | if (cell > 12) hour.setNum(cell - 12); |
170 | tw2 = fmS.width(suffix); | 173 | tw2 = fmS.width(suffix); |
171 | } | 174 | } |
172 | 175 | ||
173 | // center and draw the time label | 176 | // center and draw the time label |
174 | int timeWidth = fm.width(hour); | 177 | int timeWidth = fm.width(hour); |
175 | int offset = startW - timeWidth - tw2 ; | 178 | int offset = startW - timeWidth - tw2 ; |
176 | p->setFont( nFont ); | 179 | p->setFont( nFont ); |
177 | p->drawText( offset, y+ timeHeight, hour); | 180 | p->drawText( offset, y+ timeHeight, hour); |
178 | p->setFont( sFont ); | 181 | p->setFont( sFont ); |
179 | offset = startW - tw2+1; | 182 | offset = startW - tw2+1; |
180 | p->drawText( offset, y+ sHei, suffix); | 183 | p->drawText( offset, y+ sHei, suffix); |
181 | 184 | ||
182 | // increment indices | 185 | // increment indices |
183 | y += mCellHeight; | 186 | y += mCellHeight; |
184 | cell++; | 187 | cell++; |
185 | } | 188 | } |
186 | } else { | 189 | } else { |
187 | //qDebug("NO redraw "); | 190 | //qDebug("NO redraw "); |
188 | } | 191 | } |
189 | // double buffer not yet implemented | 192 | // double buffer not yet implemented |
190 | //bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); | 193 | //bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); |
191 | //mRedrawNeeded = false; | 194 | //mRedrawNeeded = false; |
192 | } | 195 | } |
193 | 196 | ||
194 | /** | 197 | /** |
195 | Calculates the minimum width. | 198 | Calculates the minimum width. |
196 | */ | 199 | */ |
197 | int TimeLabels::minimumWidth() const | 200 | int TimeLabels::minimumWidth() const |
198 | { | 201 | { |
199 | return mMiniWidth; | 202 | return mMiniWidth; |
200 | } | 203 | } |
201 | 204 | ||
202 | /** updates widget's internal state */ | 205 | /** updates widget's internal state */ |
203 | void TimeLabels::updateConfig() | 206 | void TimeLabels::updateConfig() |
204 | { | 207 | { |
205 | mRedrawNeeded = true; | 208 | mRedrawNeeded = true; |
206 | // set the font | 209 | // set the font |
207 | // config->setGroup("Fonts"); | 210 | // config->setGroup("Fonts"); |
208 | // QFont font = config->readFontEntry("TimeBar Font"); | 211 | // QFont font = config->readFontEntry("TimeBar Font"); |
209 | setFont(KOPrefs::instance()->mTimeBarFont); | 212 | setFont(KOPrefs::instance()->mTimeBarFont); |
210 | QString test = "20"; | 213 | QString test = "20"; |
211 | if (KGlobal::locale()->use12Clock()) | 214 | if (KGlobal::locale()->use12Clock()) |
212 | test = "12"; | 215 | test = "12"; |
213 | mMiniWidth = fontMetrics().width(test); | 216 | mMiniWidth = fontMetrics().width(test); |
214 | if (KGlobal::locale()->use12Clock()) | 217 | if (KGlobal::locale()->use12Clock()) |
215 | test = "pm"; | 218 | test = "pm"; |
216 | else | 219 | else { |
217 | test = "00"; | 220 | if ( QApplication::desktop()->width() <= 320 ) |
221 | test = ""; | ||
222 | else | ||
223 | test = "00"; | ||
224 | } | ||
218 | QFont sFont = font(); | 225 | QFont sFont = font(); |
219 | sFont.setPointSize( sFont.pointSize()/2 ); | 226 | sFont.setPointSize( sFont.pointSize()/2 ); |
220 | QFontMetrics fmS( sFont ); | 227 | QFontMetrics fmS( sFont ); |
221 | mMiniWidth += fmS.width( test ) + frameWidth()*2 +4 ; | 228 | mMiniWidth += fmS.width( test ) + frameWidth()*2 +4 ; |
222 | // update geometry restrictions based on new settings | 229 | // update geometry restrictions based on new settings |
223 | setFixedWidth( mMiniWidth ); | 230 | setFixedWidth( mMiniWidth ); |
224 | 231 | ||
225 | // update HourSize | 232 | // update HourSize |
226 | mCellHeight = KOPrefs::instance()->mHourSize*4; | 233 | mCellHeight = KOPrefs::instance()->mHourSize*4; |
227 | resizeContents(50,mRows * mCellHeight); | 234 | resizeContents(50,mRows * mCellHeight); |
228 | } | 235 | } |
229 | 236 | ||
230 | /** update time label positions */ | 237 | /** update time label positions */ |
231 | void TimeLabels::positionChanged() | 238 | void TimeLabels::positionChanged() |
232 | { | 239 | { |
233 | int adjustment = mAgenda->contentsY(); | 240 | int adjustment = mAgenda->contentsY(); |
234 | setContentsPos(0, adjustment); | 241 | setContentsPos(0, adjustment); |
235 | } | 242 | } |
236 | 243 | ||
237 | /** */ | 244 | /** */ |
238 | void TimeLabels::setAgenda(KOAgenda* agenda) | 245 | void TimeLabels::setAgenda(KOAgenda* agenda) |
239 | { | 246 | { |
240 | mAgenda = agenda; | 247 | mAgenda = agenda; |
241 | } | 248 | } |
242 | 249 | ||
243 | void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) | 250 | void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) |
244 | { | 251 | { |
245 | mMouseDownY = e->pos().y(); | 252 | mMouseDownY = e->pos().y(); |
246 | mOrgCap = topLevelWidget()->caption(); | 253 | mOrgCap = topLevelWidget()->caption(); |
247 | } | 254 | } |
248 | 255 | ||
249 | void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) | 256 | void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) |
250 | { | 257 | { |
251 | int diff = mMouseDownY - e->pos().y(); | 258 | int diff = mMouseDownY - e->pos().y(); |
252 | if ( diff < 10 && diff > -10 ) | 259 | if ( diff < 10 && diff > -10 ) |
253 | return; | 260 | return; |
254 | int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; | 261 | int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; |
255 | if ( tSize < 4 ) | 262 | if ( tSize < 4 ) |
256 | tSize = 4; | 263 | tSize = 4; |
257 | if ( tSize > 22 ) | 264 | if ( tSize > 22 ) |
258 | tSize = 22; | 265 | tSize = 22; |
259 | tSize = (tSize-2)/2; | 266 | tSize = (tSize-2)/2; |
260 | topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); | 267 | topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); |
261 | 268 | ||
262 | } | 269 | } |
263 | void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) | 270 | void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) |
264 | { | 271 | { |
265 | topLevelWidget()->setCaption( mOrgCap ); | 272 | topLevelWidget()->setCaption( mOrgCap ); |
266 | int diff = mMouseDownY - e->pos().y(); | 273 | int diff = mMouseDownY - e->pos().y(); |
267 | if ( diff < 10 && diff > -10 ) | 274 | if ( diff < 10 && diff > -10 ) |
268 | return; | 275 | return; |
269 | int tSize = KOPrefs::instance()->mHourSize + (diff/10); | 276 | int tSize = KOPrefs::instance()->mHourSize + (diff/10); |
270 | if ( tSize < 4 ) | 277 | if ( tSize < 4 ) |
271 | tSize = 4; | 278 | tSize = 4; |
272 | if ( tSize > 22 ) | 279 | if ( tSize > 22 ) |
273 | tSize = 22; | 280 | tSize = 22; |
274 | tSize = (tSize/2)*2; | 281 | tSize = (tSize/2)*2; |
275 | if ( tSize == KOPrefs::instance()->mHourSize ) | 282 | if ( tSize == KOPrefs::instance()->mHourSize ) |
276 | return; | 283 | return; |
277 | KOPrefs::instance()->mHourSize = tSize; | 284 | KOPrefs::instance()->mHourSize = tSize; |
278 | emit scaleChanged(); | 285 | emit scaleChanged(); |
279 | } | 286 | } |
280 | 287 | ||
281 | /** This is called in response to repaint() */ | 288 | /** This is called in response to repaint() */ |
282 | void TimeLabels::paintEvent(QPaintEvent*) | 289 | void TimeLabels::paintEvent(QPaintEvent*) |
283 | { | 290 | { |
284 | 291 | ||
285 | // kdDebug() << "paintevent..." << endl; | 292 | // kdDebug() << "paintevent..." << endl; |
286 | // this is another hack! | 293 | // this is another hack! |
287 | // QPainter painter(this); | 294 | // QPainter painter(this); |
288 | //QString c | 295 | //QString c |
289 | repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); | 296 | repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); |
290 | } | 297 | } |
291 | 298 | ||
292 | //////////////////////////////////////////////////////////////////////////// | 299 | //////////////////////////////////////////////////////////////////////////// |
293 | 300 | ||
294 | EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) | 301 | EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) |
295 | : QFrame(parent,name) | 302 | : QFrame(parent,name) |
296 | { | 303 | { |
297 | mColumns = 1; | 304 | mColumns = 1; |
298 | mTopBox = 0; | 305 | mTopBox = 0; |
299 | mLocation = loc; | 306 | mLocation = loc; |
300 | mTopLayout = 0; | 307 | mTopLayout = 0; |
301 | mPaintWidget = 0; | 308 | mPaintWidget = 0; |
302 | mXOffset = 0; | 309 | mXOffset = 0; |
303 | if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); | 310 | if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); |
304 | else mPixmap = SmallIcon("1downarrow"); | 311 | else mPixmap = SmallIcon("1downarrow"); |
305 | mEnabled.resize(mColumns); | 312 | mEnabled.resize(mColumns); |
306 | mEnabled.fill( false ); | 313 | mEnabled.fill( false ); |
307 | setMinimumHeight(mPixmap.height()); | 314 | setMinimumHeight(mPixmap.height()); |
308 | } | 315 | } |
309 | 316 | ||
310 | EventIndicator::~EventIndicator() | 317 | EventIndicator::~EventIndicator() |
311 | { | 318 | { |
312 | } | 319 | } |
313 | 320 | ||
@@ -632,309 +639,312 @@ void KOAgendaView::slotDaylabelClicked( int num ) | |||
632 | QDate firstDate = mSelectedDates.first(); | 639 | QDate firstDate = mSelectedDates.first(); |
633 | if ( num == -1 ) | 640 | if ( num == -1 ) |
634 | emit showDateView( 6, firstDate ); | 641 | emit showDateView( 6, firstDate ); |
635 | else if (num >= 0 ) { | 642 | else if (num >= 0 ) { |
636 | if ( mSelectedDates.count() == 1) | 643 | if ( mSelectedDates.count() == 1) |
637 | emit showDateView( 9, firstDate.addDays( num ) ); | 644 | emit showDateView( 9, firstDate.addDays( num ) ); |
638 | else | 645 | else |
639 | emit showDateView( 3, firstDate.addDays( num ) ); | 646 | emit showDateView( 3, firstDate.addDays( num ) ); |
640 | } | 647 | } |
641 | else | 648 | else |
642 | showDateView( 10, firstDate.addDays(1) ); | 649 | showDateView( 10, firstDate.addDays(1) ); |
643 | } | 650 | } |
644 | 651 | ||
645 | KOAgendaButton* KOAgendaView::getNewDaylabel() | 652 | KOAgendaButton* KOAgendaView::getNewDaylabel() |
646 | { | 653 | { |
647 | 654 | ||
648 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); | 655 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); |
649 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); | 656 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); |
650 | mDayLabelsList.append( dayLabel ); | 657 | mDayLabelsList.append( dayLabel ); |
651 | mLayoutDayLabels->addWidget(dayLabel); | 658 | mLayoutDayLabels->addWidget(dayLabel); |
652 | return dayLabel ; | 659 | return dayLabel ; |
653 | } | 660 | } |
654 | 661 | ||
655 | void KOAgendaView::createDayLabels() | 662 | void KOAgendaView::createDayLabels() |
656 | { | 663 | { |
657 | 664 | ||
658 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { | 665 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { |
659 | // qDebug(" KOAgendaView::createDayLabels() blocked "); | 666 | // qDebug(" KOAgendaView::createDayLabels() blocked "); |
660 | return; | 667 | return; |
661 | 668 | ||
662 | } | 669 | } |
663 | int newHight; | 670 | int newHight; |
664 | 671 | ||
665 | // ### Before deleting and recreating we could check if mSelectedDates changed... | 672 | // ### Before deleting and recreating we could check if mSelectedDates changed... |
666 | // It would remove some flickering and gain speed (since this is called by | 673 | // It would remove some flickering and gain speed (since this is called by |
667 | // each updateView() call) | 674 | // each updateView() call) |
668 | 675 | ||
669 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; | 676 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; |
670 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); | 677 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); |
671 | if ( maxWid < 0 ) | 678 | if ( maxWid < 0 ) |
672 | maxWid = 20; | 679 | maxWid = 20; |
673 | 680 | ||
674 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; | 681 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; |
675 | QFontMetrics fm ( dlf ); | 682 | QFontMetrics fm ( dlf ); |
676 | int selCount = mSelectedDates.count(); | 683 | int selCount = mSelectedDates.count(); |
677 | QString dayTest = "Mon 20"; | 684 | QString dayTest = "Mon 20"; |
678 | //QString dayTest = "Mon 20"; | 685 | //QString dayTest = "Mon 20"; |
679 | int wid = fm.width( dayTest ); | 686 | int wid = fm.width( dayTest ); |
680 | //maxWid -= ( selCount * 3 ); //working for QLabels | 687 | //maxWid -= ( selCount * 3 ); //working for QLabels |
681 | maxWid -= ( selCount * 3 ); //working for QPushButton | 688 | maxWid -= ( selCount * 3 ); //working for QPushButton |
682 | if ( maxWid < 0 ) | 689 | if ( maxWid < 0 ) |
683 | maxWid = 20; | 690 | maxWid = 20; |
684 | int needWid = wid * selCount; | 691 | int needWid = wid * selCount; |
685 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); | 692 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); |
686 | //if ( needWid > maxWid ) | 693 | //if ( needWid > maxWid ) |
687 | // qDebug("DAYLABELS TOOOOOOO BIG "); | 694 | // qDebug("DAYLABELS TOOOOOOO BIG "); |
688 | while ( needWid > maxWid ) { | 695 | while ( needWid > maxWid ) { |
689 | dayTest = dayTest.left( dayTest.length() - 1 ); | 696 | dayTest = dayTest.left( dayTest.length() - 1 ); |
690 | wid = fm.width( dayTest ); | 697 | wid = fm.width( dayTest ); |
691 | needWid = wid * selCount; | 698 | needWid = wid * selCount; |
692 | } | 699 | } |
693 | int maxLen = dayTest.length(); | 700 | int maxLen = dayTest.length(); |
694 | int fontPoint = dlf.pointSize(); | 701 | int fontPoint = dlf.pointSize(); |
695 | if ( maxLen < 2 ) { | 702 | if ( maxLen < 2 ) { |
696 | int fontPoint = dlf.pointSize(); | 703 | int fontPoint = dlf.pointSize(); |
697 | while ( fontPoint > 4 ) { | 704 | while ( fontPoint > 4 ) { |
698 | --fontPoint; | 705 | --fontPoint; |
699 | dlf.setPointSize( fontPoint ); | 706 | dlf.setPointSize( fontPoint ); |
700 | QFontMetrics f( dlf ); | 707 | QFontMetrics f( dlf ); |
701 | wid = f.width( "30" ); | 708 | wid = f.width( "30" ); |
702 | needWid = wid * selCount; | 709 | needWid = wid * selCount; |
703 | if ( needWid < maxWid ) | 710 | if ( needWid < maxWid ) |
704 | break; | 711 | break; |
705 | } | 712 | } |
706 | maxLen = 2; | 713 | maxLen = 2; |
707 | } | 714 | } |
708 | //qDebug("Max len %d ", dayTest.length() ); | 715 | //qDebug("Max len %d ", dayTest.length() ); |
709 | 716 | ||
710 | QFontMetrics tempF( dlf ); | 717 | QFontMetrics tempF( dlf ); |
711 | newHight = tempF.height(); | 718 | newHight = tempF.height(); |
712 | mDayLabels->setFont( dlf ); | 719 | mDayLabels->setFont( dlf ); |
713 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; | 720 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; |
714 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); | 721 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); |
715 | //mLayoutDayLabels->addSpacing( 2 ); | 722 | //mLayoutDayLabels->addSpacing( 2 ); |
716 | // QFont lFont = dlf; | 723 | // QFont lFont = dlf; |
717 | bool appendLabels = false; | 724 | bool appendLabels = false; |
718 | KOAgendaButton *dayLabel; | 725 | KOAgendaButton *dayLabel; |
719 | dayLabel = mDayLabelsList.first(); | 726 | dayLabel = mDayLabelsList.first(); |
720 | if ( !dayLabel ) { | 727 | if ( !dayLabel ) { |
721 | appendLabels = true; | 728 | appendLabels = true; |
722 | dayLabel = getNewDaylabel(); | 729 | dayLabel = getNewDaylabel(); |
723 | } | 730 | } |
724 | dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); | 731 | dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); |
725 | dayLabel->setFont( dlf ); | 732 | dayLabel->setFont( dlf ); |
726 | dayLabel->setNum( -1 ); | 733 | dayLabel->setNum( -1 ); |
727 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 734 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
728 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); | 735 | if ( QApplication::desktop()->width() <= 320 ) |
736 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ).left(2) ); | ||
737 | else | ||
738 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); | ||
729 | dayLabel->show(); | 739 | dayLabel->show(); |
730 | DateList::ConstIterator dit; | 740 | DateList::ConstIterator dit; |
731 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); | 741 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); |
732 | int counter = -1; | 742 | int counter = -1; |
733 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 743 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
734 | ++counter; | 744 | ++counter; |
735 | QDate date = *dit; | 745 | QDate date = *dit; |
736 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); | 746 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); |
737 | if ( ! appendLabels ) { | 747 | if ( ! appendLabels ) { |
738 | dayLabel = mDayLabelsList.next(); | 748 | dayLabel = mDayLabelsList.next(); |
739 | if ( !dayLabel ) | 749 | if ( !dayLabel ) |
740 | appendLabels = true; | 750 | appendLabels = true; |
741 | } | 751 | } |
742 | if ( appendLabels ) { | 752 | if ( appendLabels ) { |
743 | dayLabel = getNewDaylabel(); | 753 | dayLabel = getNewDaylabel(); |
744 | } | 754 | } |
745 | dayLabel->setMinimumWidth( 1 ); | 755 | dayLabel->setMinimumWidth( 1 ); |
746 | dayLabel->setMaximumWidth( 10240 ); | 756 | dayLabel->setMaximumWidth( 10240 ); |
747 | dayLabel->setFont( dlf ); | 757 | dayLabel->setFont( dlf ); |
748 | dayLabel->show(); | 758 | dayLabel->show(); |
749 | dayLabel->setAutoRepeat( false ); | 759 | dayLabel->setAutoRepeat( false ); |
750 | dayLabel->setNum( counter ); | 760 | dayLabel->setNum( counter ); |
751 | QString str; | 761 | QString str; |
752 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); | 762 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); |
753 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); | 763 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); |
754 | switch ( maxLen ) { | 764 | switch ( maxLen ) { |
755 | case 2: | 765 | case 2: |
756 | str = QString::number( date.day() ); | 766 | str = QString::number( date.day() ); |
757 | break; | 767 | break; |
758 | 768 | ||
759 | case 3: | 769 | case 3: |
760 | str = dayName.left( 1 ) +QString::number( date.day()); | 770 | str = dayName.left( 1 ) +QString::number( date.day()); |
761 | 771 | ||
762 | break; | 772 | break; |
763 | case 4: | 773 | case 4: |
764 | str = dayName.left( 1 ) + " " +QString::number( date.day()); | 774 | str = dayName.left( 1 ) + " " +QString::number( date.day()); |
765 | 775 | ||
766 | break; | 776 | break; |
767 | case 5: | 777 | case 5: |
768 | str = dayName.left( 2 ) + " " +QString::number( date.day()); | 778 | str = dayName.left( 2 ) + " " +QString::number( date.day()); |
769 | 779 | ||
770 | break; | 780 | break; |
771 | case 6: | 781 | case 6: |
772 | str = dayName.left( 3 ) + " " +QString::number( date.day()); | 782 | str = dayName.left( 3 ) + " " +QString::number( date.day()); |
773 | break; | 783 | break; |
774 | 784 | ||
775 | default: | 785 | default: |
776 | break; | 786 | break; |
777 | } | 787 | } |
778 | if ( oneday ) { | 788 | if ( oneday ) { |
779 | QString addString; | 789 | QString addString; |
780 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) | 790 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) |
781 | addString = i18n("Today"); | 791 | addString = i18n("Today"); |
782 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 792 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
783 | addString = i18n("Tomorrow"); | 793 | addString = i18n("Tomorrow"); |
784 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 794 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
785 | addString = i18n("Yesterday"); | 795 | addString = i18n("Yesterday"); |
786 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | 796 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) |
787 | addString = i18n("Day before yesterday"); | 797 | addString = i18n("Day before yesterday"); |
788 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 798 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
789 | addString = i18n("Day after tomorrow"); | 799 | addString = i18n("Day after tomorrow"); |
790 | if ( !addString.isEmpty() ) { | 800 | if ( !addString.isEmpty() ) { |
791 | str = addString+", " + str; | 801 | str = addString+", " + str; |
792 | } else { | 802 | } else { |
793 | str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); | 803 | str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); |
794 | } | 804 | } |
795 | } | 805 | } |
796 | dayLabel->setText(str); | 806 | dayLabel->setText(str); |
797 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 807 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
798 | if (date == QDate::currentDate()) { | 808 | if (date == QDate::currentDate()) { |
799 | QFont bFont = dlf; | 809 | QFont bFont = dlf; |
800 | bFont.setBold( true ); | 810 | bFont.setBold( true ); |
801 | dayLabel->setFont(bFont); | 811 | dayLabel->setFont(bFont); |
802 | } | 812 | } |
803 | //dayLayout->addWidget(dayLabel); | 813 | //dayLayout->addWidget(dayLabel); |
804 | 814 | ||
805 | #ifndef KORG_NOPLUGINS | 815 | #ifndef KORG_NOPLUGINS |
806 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); | 816 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); |
807 | CalendarDecoration *it; | 817 | CalendarDecoration *it; |
808 | for(it = cds.first(); it; it = cds.next()) { | 818 | for(it = cds.first(); it; it = cds.next()) { |
809 | QString text = it->shortText( date ); | 819 | QString text = it->shortText( date ); |
810 | if ( !text.isEmpty() ) { | 820 | if ( !text.isEmpty() ) { |
811 | QLabel *label = new QLabel(text,mDayLabels); | 821 | QLabel *label = new QLabel(text,mDayLabels); |
812 | label->setAlignment(AlignCenter); | 822 | label->setAlignment(AlignCenter); |
813 | dayLayout->addWidget(label); | 823 | dayLayout->addWidget(label); |
814 | } | 824 | } |
815 | } | 825 | } |
816 | 826 | ||
817 | for(it = cds.first(); it; it = cds.next()) { | 827 | for(it = cds.first(); it; it = cds.next()) { |
818 | QWidget *wid = it->smallWidget(mDayLabels,date); | 828 | QWidget *wid = it->smallWidget(mDayLabels,date); |
819 | if ( wid ) { | 829 | if ( wid ) { |
820 | // wid->setHeight(20); | 830 | // wid->setHeight(20); |
821 | dayLayout->addWidget(wid); | 831 | dayLayout->addWidget(wid); |
822 | } | 832 | } |
823 | } | 833 | } |
824 | #endif | 834 | #endif |
825 | } | 835 | } |
826 | if ( ! appendLabels ) { | 836 | if ( ! appendLabels ) { |
827 | dayLabel = mDayLabelsList.next(); | 837 | dayLabel = mDayLabelsList.next(); |
828 | if ( !dayLabel ) | 838 | if ( !dayLabel ) |
829 | appendLabels = true; | 839 | appendLabels = true; |
830 | } | 840 | } |
831 | if ( appendLabels ) { | 841 | if ( appendLabels ) { |
832 | dayLabel = getNewDaylabel(); | 842 | dayLabel = getNewDaylabel(); |
833 | } | 843 | } |
834 | //dayLabel->hide();//test only | 844 | //dayLabel->hide();//test only |
835 | qDebug("fremwidd %d ", mAgenda->frameWidth()); | ||
836 | int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()- (mAgenda->frameWidth()*2) ) % mSelectedDates.count() ; | 845 | int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()- (mAgenda->frameWidth()*2) ) % mSelectedDates.count() ; |
837 | if ( offset < 0 ) offset = 0; | 846 | if ( offset < 0 ) offset = 0; |
838 | //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); | 847 | //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); |
839 | dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); | 848 | dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); |
840 | dayLabel->setFont( dlf ); | 849 | dayLabel->setFont( dlf ); |
841 | dayLabel->setAutoRepeat( true ); | 850 | dayLabel->setAutoRepeat( true ); |
842 | dayLabel->show(); | 851 | dayLabel->show(); |
843 | dayLabel->setNum( -2 ); | 852 | dayLabel->setNum( -2 ); |
844 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); | 853 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); |
854 | |||
845 | //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); | 855 | //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); |
846 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); | 856 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); |
847 | if ( !appendLabels ) { | 857 | if ( !appendLabels ) { |
848 | dayLabel = mDayLabelsList.next(); | 858 | dayLabel = mDayLabelsList.next(); |
849 | while ( dayLabel ) { | 859 | while ( dayLabel ) { |
850 | //qDebug("!dayLabel %d",dayLabel ); | 860 | //qDebug("!dayLabel %d",dayLabel ); |
851 | dayLabel->hide(); | 861 | dayLabel->hide(); |
852 | dayLabel = mDayLabelsList.next(); | 862 | dayLabel = mDayLabelsList.next(); |
853 | } | 863 | } |
854 | } | 864 | } |
855 | 865 | ||
856 | mDayLabelsFrame->setFixedHeight( newHight + 4 ); | 866 | mDayLabelsFrame->setFixedHeight( newHight + 4 ); |
857 | } | 867 | } |
858 | 868 | ||
859 | int KOAgendaView::maxDatesHint() | 869 | int KOAgendaView::maxDatesHint() |
860 | { | 870 | { |
861 | // Not sure about the max number of events, so return 0 for now. | 871 | // Not sure about the max number of events, so return 0 for now. |
862 | return 0; | 872 | return 0; |
863 | } | 873 | } |
864 | 874 | ||
865 | int KOAgendaView::currentDateCount() | 875 | int KOAgendaView::currentDateCount() |
866 | { | 876 | { |
867 | return mSelectedDates.count(); | 877 | return mSelectedDates.count(); |
868 | } | 878 | } |
869 | 879 | ||
870 | QPtrList<Incidence> KOAgendaView::selectedIncidences() | 880 | QPtrList<Incidence> KOAgendaView::selectedIncidences() |
871 | { | 881 | { |
872 | QPtrList<Incidence> selected; | 882 | QPtrList<Incidence> selected; |
873 | Incidence *incidence; | 883 | Incidence *incidence; |
874 | 884 | ||
875 | incidence = mAgenda->selectedIncidence(); | 885 | incidence = mAgenda->selectedIncidence(); |
876 | if (incidence) selected.append(incidence); | 886 | if (incidence) selected.append(incidence); |
877 | 887 | ||
878 | incidence = mAllDayAgenda->selectedIncidence(); | 888 | incidence = mAllDayAgenda->selectedIncidence(); |
879 | if (incidence) selected.append(incidence); | 889 | if (incidence) selected.append(incidence); |
880 | 890 | ||
881 | return selected; | 891 | return selected; |
882 | } | 892 | } |
883 | 893 | ||
884 | DateList KOAgendaView::selectedDates() | 894 | DateList KOAgendaView::selectedDates() |
885 | { | 895 | { |
886 | DateList selected; | 896 | DateList selected; |
887 | QDate qd; | 897 | QDate qd; |
888 | 898 | ||
889 | qd = mAgenda->selectedIncidenceDate(); | 899 | qd = mAgenda->selectedIncidenceDate(); |
890 | if (qd.isValid()) selected.append(qd); | 900 | if (qd.isValid()) selected.append(qd); |
891 | 901 | ||
892 | qd = mAllDayAgenda->selectedIncidenceDate(); | 902 | qd = mAllDayAgenda->selectedIncidenceDate(); |
893 | if (qd.isValid()) selected.append(qd); | 903 | if (qd.isValid()) selected.append(qd); |
894 | 904 | ||
895 | return selected; | 905 | return selected; |
896 | } | 906 | } |
897 | 907 | ||
898 | 908 | ||
899 | void KOAgendaView::updateView() | 909 | void KOAgendaView::updateView() |
900 | { | 910 | { |
901 | if ( mBlockUpdating ) | 911 | if ( mBlockUpdating ) |
902 | return; | 912 | return; |
903 | // kdDebug() << "KOAgendaView::updateView()" << endl; | 913 | // kdDebug() << "KOAgendaView::updateView()" << endl; |
904 | fillAgenda(); | 914 | fillAgenda(); |
905 | 915 | ||
906 | } | 916 | } |
907 | 917 | ||
908 | 918 | ||
909 | /* | 919 | /* |
910 | Update configuration settings for the agenda view. This method is not | 920 | Update configuration settings for the agenda view. This method is not |
911 | complete. | 921 | complete. |
912 | */ | 922 | */ |
913 | void KOAgendaView::updateConfig() | 923 | void KOAgendaView::updateConfig() |
914 | { | 924 | { |
915 | if ( mBlockUpdating ) | 925 | if ( mBlockUpdating ) |
916 | return; | 926 | return; |
917 | if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { | 927 | if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { |
918 | int old = KOPrefs::instance()->mHourSize; | 928 | int old = KOPrefs::instance()->mHourSize; |
919 | KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; | 929 | KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; |
920 | qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); | 930 | qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); |
921 | } | 931 | } |
922 | 932 | ||
923 | 933 | ||
924 | // update config for children | 934 | // update config for children |
925 | mTimeLabels->updateConfig(); | 935 | mTimeLabels->updateConfig(); |
926 | mAgenda->storePosition(); | 936 | mAgenda->storePosition(); |
927 | mAgenda->updateConfig(); | 937 | mAgenda->updateConfig(); |
928 | mAllDayAgenda->updateConfig(); | 938 | mAllDayAgenda->updateConfig(); |
929 | // widget synchronization | 939 | // widget synchronization |
930 | //TODO: find a better way, maybe signal/slot | 940 | //TODO: find a better way, maybe signal/slot |
931 | mTimeLabels->positionChanged(); | 941 | mTimeLabels->positionChanged(); |
932 | 942 | ||
933 | // for some reason, this needs to be called explicitly | 943 | // for some reason, this needs to be called explicitly |
934 | mTimeLabels->repaint(); | 944 | mTimeLabels->repaint(); |
935 | 945 | ||
936 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 946 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
937 | 947 | ||
938 | // ToolTips displaying summary of events | 948 | // ToolTips displaying summary of events |
939 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() | 949 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() |
940 | ->mEnableToolTips); | 950 | ->mEnableToolTips); |
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index 5b5703f..b8a0f09 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp | |||
@@ -700,194 +700,198 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent) | |||
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 ); | ||
797 | int addrow2 = addRow-selh+1; | ||
798 | if ( addrow2 < 0 ) | ||
799 | addrow2 = 0; | ||
796 | if (selh > 1) { | 800 | if (selh > 1) { |
797 | p.fillRect(1, (row+1)*dheight, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol); | 801 | p.fillRect(1, (row+1)*dheight+addrow2, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol); |
798 | } | 802 | } |
799 | // draw last block from left to mSelEndT | 803 | // draw last block from left to mSelEndT |
800 | selw = mSelEndT-7*(mSelEndT/7)+1; | 804 | selw = mSelEndT-7*(mSelEndT/7)+1; |
801 | //qDebug("esl %d ",selw ); | 805 | //qDebug("esl %d ",selw ); |
802 | int add = 0; | 806 | int add = 0; |
803 | if ( colModulo ) { | 807 | if ( colModulo ) { |
804 | add = 7 - colModulo; | 808 | add = 7 - colModulo; |
805 | if ( selw > add ) | 809 | if ( selw > add ) |
806 | add = selw - add; | 810 | add = selw - add; |
807 | else | 811 | else |
808 | add = 0; | 812 | add = 0; |
809 | } | 813 | } |
810 | //qDebug("add %d ", add); | 814 | //qDebug("add %d ", add); |
811 | p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow, | 815 | p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow, |
812 | selw*dwidth+add, dheight+1, selcol); | 816 | selw*dwidth+add, dheight+1, selcol); |
813 | } | 817 | } |
814 | } | 818 | } |
815 | } | 819 | } |
816 | 820 | ||
817 | // 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 |
818 | QColor actcol = mDefaultTextColorShaded; | 822 | QColor actcol = mDefaultTextColorShaded; |
819 | p.setPen(actcol); | 823 | p.setPen(actcol); |
820 | QPen tmppen; | 824 | QPen tmppen; |
821 | for(int i = 0; i < NUMDAYS; i++) { | 825 | for(int i = 0; i < NUMDAYS; i++) { |
822 | row = i/7; | 826 | row = i/7; |
823 | col = isRTL ? 6-(i-row*7) : i-row*7; | 827 | col = isRTL ? 6-(i-row*7) : i-row*7; |
824 | 828 | ||
825 | // 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 |
826 | if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { | 830 | if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { |
827 | if (actcol == mDefaultTextColorShaded) { | 831 | if (actcol == mDefaultTextColorShaded) { |
828 | actcol = mDefaultTextColor; | 832 | actcol = mDefaultTextColor; |
829 | } else { | 833 | } else { |
830 | actcol = mDefaultTextColorShaded; | 834 | actcol = mDefaultTextColorShaded; |
831 | } | 835 | } |
832 | p.setPen(actcol); | 836 | p.setPen(actcol); |
833 | } | 837 | } |
834 | if (actcol == mDefaultTextColorShaded) { | 838 | if (actcol == mDefaultTextColorShaded) { |
835 | if ( ! mouseDown ) { | 839 | if ( ! mouseDown ) { |
836 | continue; | 840 | continue; |
837 | } | 841 | } |
838 | } | 842 | } |
839 | //Reset pen color after selected days block | 843 | //Reset pen color after selected days block |
840 | if (i == mSelEndT+1) { | 844 | if (i == mSelEndT+1) { |
841 | p.setPen(actcol); | 845 | p.setPen(actcol); |
842 | } | 846 | } |
843 | 847 | ||
844 | // if today then draw rectangle around day | 848 | // if today then draw rectangle around day |
845 | if (today == i) { | 849 | if (today == i) { |
846 | tmppen = p.pen(); | 850 | tmppen = p.pen(); |
847 | QPen mTodayPen(p.pen()); | 851 | QPen mTodayPen(p.pen()); |
848 | if ( daysize.width() < 20 ) | 852 | if ( daysize.width() < 20 ) |
849 | mTodayPen.setWidth(1); | 853 | mTodayPen.setWidth(1); |
850 | else | 854 | else |
851 | mTodayPen.setWidth(mTodayMarginWidth); | 855 | mTodayPen.setWidth(mTodayMarginWidth); |
852 | //draw red rectangle for holidays | 856 | //draw red rectangle for holidays |
853 | if (!mHolidays[i].isNull()) { | 857 | if (!mHolidays[i].isNull()) { |
854 | if (actcol == mDefaultTextColor) { | 858 | if (actcol == mDefaultTextColor) { |
855 | mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); | 859 | mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); |
856 | } else { | 860 | } else { |
857 | mTodayPen.setColor(mHolidayColorShaded); | 861 | mTodayPen.setColor(mHolidayColorShaded); |
858 | } | 862 | } |
859 | } | 863 | } |
860 | //draw gray rectangle for today if in selection | 864 | //draw gray rectangle for today if in selection |
861 | if (i >= mSelStartT && i <= mSelEndT) { | 865 | if (i >= mSelStartT && i <= mSelEndT) { |
862 | QColor grey("grey"); | 866 | QColor grey("grey"); |
863 | mTodayPen.setColor(grey); | 867 | mTodayPen.setColor(grey); |
864 | } | 868 | } |
865 | p.setPen(mTodayPen); | 869 | p.setPen(mTodayPen); |
866 | 870 | ||
867 | 871 | ||
868 | int addCol = 0; | 872 | int addCol = 0; |
869 | int addRow = 0; | 873 | int addRow = 0; |
870 | if (rowModulo) { | 874 | if (rowModulo) { |
871 | if ( row >= 6 - rowModulo ) | 875 | if ( row >= 6 - rowModulo ) |
872 | addRow = row - 5 + rowModulo; | 876 | addRow = row - 5 + rowModulo; |
873 | } | 877 | } |
874 | if ( colModulo ) { | 878 | if ( colModulo ) { |
875 | if ( col >= 7 - colModulo ) | 879 | if ( col >= 7 - colModulo ) |
876 | addCol = col - 6 + colModulo-1; | 880 | addCol = col - 6 + colModulo-1; |
877 | } | 881 | } |
878 | 882 | ||
879 | addCol += 1; | 883 | addCol += 1; |
880 | if ( row == 0 ) | 884 | if ( row == 0 ) |
881 | addRow = 1; | 885 | addRow = 1; |
882 | 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); |
883 | p.setPen(tmppen); | 887 | p.setPen(tmppen); |
884 | } | 888 | } |
885 | 889 | ||
886 | // 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 |
887 | if ( eDays.testBit(i) ) { | 891 | if ( eDays.testBit(i) ) { |
888 | QFont myFont = font(); | 892 | QFont myFont = font(); |
889 | myFont.setBold(true); | 893 | myFont.setBold(true); |
890 | p.setFont(myFont); | 894 | p.setFont(myFont); |
891 | } | 895 | } |
892 | 896 | ||
893 | // if it is a holiday then use the default holiday color | 897 | // if it is a holiday then use the default holiday color |
diff --git a/microkde/KDGanttMinimizeSplitter.cpp b/microkde/KDGanttMinimizeSplitter.cpp index 6cb1f31..253175e 100644 --- a/microkde/KDGanttMinimizeSplitter.cpp +++ b/microkde/KDGanttMinimizeSplitter.cpp | |||
@@ -178,205 +178,214 @@ void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e ) | |||
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 | buffer.fill( colorGroup().background() ); | 274 | #ifndef DESKTOP_VERSION |
275 | if ( mMouseDown ) | ||
276 | buffer.fill( QColor( 242,27,255 ) ); | ||
277 | else | ||
278 | #endif | ||
279 | buffer.fill( colorGroup().background() ); | ||
275 | //buffer.fill( backgroundColor() ); | 280 | //buffer.fill( backgroundColor() ); |
276 | // parentWidget()->style().drawPrimitive( QStyle::PE_Panel, &p, rect(), parentWidget()->colorGroup()); | 281 | // parentWidget()->style().drawPrimitive( QStyle::PE_Panel, &p, rect(), parentWidget()->colorGroup()); |
277 | 282 | ||
278 | 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 |
279 | 284 | ||
280 | // arrow color | 285 | // arrow color |
281 | QColor col; | 286 | QColor col; |
282 | if ( _activeButton ) | 287 | if ( _activeButton ) |
283 | col = colorGroup().background().dark( 250 ); | 288 | col = colorGroup().background().dark( 250 ); |
284 | else { | 289 | else { |
285 | if ( mMouseDown ) | 290 | if ( mMouseDown ) |
286 | col = Qt::white; | 291 | #ifndef DESKTOP_VERSION |
292 | col = QColor( 178,18,188);//QColor( 242,27,255 );//Qt::white; | ||
293 | #else | ||
294 | col = Qt::white; | ||
295 | #endif | ||
287 | else | 296 | else |
288 | col = colorGroup().background().dark( 150 ); | 297 | col = colorGroup().background().dark( 150 ); |
289 | } | 298 | } |
290 | //QColor col = backgroundColor().dark( 130 ); | 299 | //QColor col = backgroundColor().dark( 130 ); |
291 | p.setBrush( col ); | 300 | p.setBrush( col ); |
292 | p.setPen( col ); | 301 | p.setPen( col ); |
293 | 302 | ||
294 | QValueList<QPointArray> list = buttonRegions(); | 303 | QValueList<QPointArray> list = buttonRegions(); |
295 | int index = 1; | 304 | int index = 1; |
296 | if ( mUseOffset ) | 305 | if ( mUseOffset ) |
297 | p.translate( 0, 1 ); | 306 | p.translate( 0, 1 ); |
298 | for ( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { | 307 | for ( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { |
299 | if ( index == _activeButton ) { | 308 | if ( index == _activeButton ) { |
300 | 309 | ||
301 | /* | 310 | /* |
302 | if ( ! _collapsed ) { | 311 | if ( ! _collapsed ) { |
303 | p.save(); | 312 | p.save(); |
304 | // p.translate( parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftHorizontal ), | 313 | // p.translate( parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftHorizontal ), |
305 | // parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftVertical ) ); | 314 | // parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftVertical ) ); |
306 | p.translate( -1, 0 ); | 315 | p.translate( -1, 0 ); |
307 | p.drawPolygon( *it, true ); | 316 | p.drawPolygon( *it, true ); |
308 | p.restore(); } else | 317 | p.restore(); } else |
309 | */ | 318 | */ |
310 | p.drawPolygon( *it, true ); | 319 | p.drawPolygon( *it, true ); |
311 | 320 | ||
312 | } | 321 | } |
313 | else { | 322 | else { |
314 | /* | 323 | /* |
315 | if ( ! _collapsed ) { | 324 | if ( ! _collapsed ) { |
316 | p.save(); | 325 | p.save(); |
317 | p.translate( -1, 0 ); | 326 | p.translate( -1, 0 ); |
318 | p.drawPolygon( *it, true ); | 327 | p.drawPolygon( *it, true ); |
319 | p.restore(); | 328 | p.restore(); |
320 | } else | 329 | } else |
321 | */ | 330 | */ |
322 | p.drawPolygon( *it, true ); | 331 | p.drawPolygon( *it, true ); |
323 | 332 | ||
324 | } | 333 | } |
325 | index++; | 334 | index++; |
326 | } | 335 | } |
327 | 336 | ||
328 | // Draw the lines between the arrows | 337 | // Draw the lines between the arrows |
329 | if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left || | 338 | if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left || |
330 | s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { | 339 | s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { |
331 | int mid = height()/2; | 340 | int mid = height()/2; |
332 | p.drawLine ( 1, mid - sw, 1, mid + sw ); | 341 | p.drawLine ( 1, mid - sw, 1, mid + sw ); |
333 | p.drawLine ( 3, mid - sw, 3, mid + sw ); | 342 | p.drawLine ( 3, mid - sw, 3, mid + sw ); |
334 | } | 343 | } |
335 | else if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Up || | 344 | else if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Up || |
336 | s->minimizeDirection() == KDGanttMinimizeSplitter::Down ) { | 345 | s->minimizeDirection() == KDGanttMinimizeSplitter::Down ) { |
337 | int mid = width()/2; | 346 | int mid = width()/2; |
338 | p.drawLine( mid -sw, 1, mid +sw, 1 ); | 347 | p.drawLine( mid -sw, 1, mid +sw, 1 ); |
339 | p.drawLine( mid -sw, 3, mid +sw, 3 ); | 348 | p.drawLine( mid -sw, 3, mid +sw, 3 ); |
340 | } | 349 | } |
341 | bitBlt( this, 0, 0, &buffer ); | 350 | bitBlt( this, 0, 0, &buffer ); |
342 | 351 | ||
343 | } | 352 | } |
344 | #endif | 353 | #endif |
345 | 354 | ||
346 | class QSplitterLayoutStruct | 355 | class QSplitterLayoutStruct |
347 | { | 356 | { |
348 | public: | 357 | public: |
349 | KDGanttMinimizeSplitter::ResizeMode mode; | 358 | KDGanttMinimizeSplitter::ResizeMode mode; |
350 | QCOORD sizer; | 359 | QCOORD sizer; |
351 | bool isSplitter; | 360 | bool isSplitter; |
352 | QWidget *wid; | 361 | QWidget *wid; |
353 | }; | 362 | }; |
354 | 363 | ||
355 | class QSplitterData | 364 | class QSplitterData |
356 | { | 365 | { |
357 | public: | 366 | public: |
358 | QSplitterData() : opaque( FALSE ), firstShow( TRUE ) {} | 367 | QSplitterData() : opaque( FALSE ), firstShow( TRUE ) {} |
359 | 368 | ||
360 | QPtrList<QSplitterLayoutStruct> list; | 369 | QPtrList<QSplitterLayoutStruct> list; |
361 | bool opaque; | 370 | bool opaque; |
362 | bool firstShow; | 371 | bool firstShow; |
363 | }; | 372 | }; |
364 | 373 | ||
365 | void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos, | 374 | void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos, |
366 | int space, int spacer ); | 375 | int space, int spacer ); |
367 | #endif // DOXYGEN_SKIP_INTERNAL | 376 | #endif // DOXYGEN_SKIP_INTERNAL |
368 | 377 | ||
369 | 378 | ||
370 | /*! | 379 | /*! |
371 | \class KDGanttMinimizeSplitter KDGanttMinimizeSplitter.h | 380 | \class KDGanttMinimizeSplitter KDGanttMinimizeSplitter.h |
372 | \brief The KDGanttMinimizeSplitter class implements a splitter | 381 | \brief The KDGanttMinimizeSplitter class implements a splitter |
373 | widget with minimize buttons. | 382 | widget with minimize buttons. |
374 | 383 | ||
375 | This class (and its documentation) is largely a copy of Qt's | 384 | This class (and its documentation) is largely a copy of Qt's |
376 | QSplitter; the copying was necessary because QSplitter is not | 385 | QSplitter; the copying was necessary because QSplitter is not |
377 | extensible at all. QSplitter and its documentation are licensed | 386 | extensible at all. QSplitter and its documentation are licensed |
378 | according to the GPL and the Qt Professional License (if you hold | 387 | according to the GPL and the Qt Professional License (if you hold |
379 | such a license) and are (C) Trolltech AS. | 388 | such a license) and are (C) Trolltech AS. |
380 | 389 | ||
381 | A splitter lets the user control the size of child widgets by | 390 | A splitter lets the user control the size of child widgets by |
382 | dragging the boundary between the children. Any number of widgets | 391 | dragging the boundary between the children. Any number of widgets |