-rw-r--r-- | microkde/kdatetbl.cpp | 26 | ||||
-rw-r--r-- | microkde/kglobalsettings.cpp | 10 |
2 files changed, 26 insertions, 10 deletions
diff --git a/microkde/kdatetbl.cpp b/microkde/kdatetbl.cpp index fce0e5a..e827412 100644 --- a/microkde/kdatetbl.cpp +++ b/microkde/kdatetbl.cpp | |||
@@ -73,502 +73,512 @@ KDateValidator::date(const QString& text, QDate& d) const | |||
73 | } | 73 | } |
74 | 74 | ||
75 | void | 75 | void |
76 | KDateValidator::fixup( QString& ) const | 76 | KDateValidator::fixup( QString& ) const |
77 | { | 77 | { |
78 | 78 | ||
79 | } | 79 | } |
80 | 80 | ||
81 | KDateTable::KDateTable(QWidget *parent, QDate date_, const char* name, WFlags f) | 81 | KDateTable::KDateTable(QWidget *parent, QDate date_, const char* name, WFlags f) |
82 | : QGridView(parent, name, f) | 82 | : QGridView(parent, name, f) |
83 | { | 83 | { |
84 | setFontSize(10); | 84 | setFontSize(10); |
85 | if(!date_.isValid()) | 85 | if(!date_.isValid()) |
86 | { | 86 | { |
87 | date_=QDate::currentDate(); | 87 | date_=QDate::currentDate(); |
88 | } | 88 | } |
89 | setFocusPolicy( QWidget::StrongFocus ); | 89 | setFocusPolicy( QWidget::StrongFocus ); |
90 | setNumRows(7); // 6 weeks max + headline | 90 | setNumRows(7); // 6 weeks max + headline |
91 | setNumCols(7); // 7 days a week | 91 | setNumCols(7); // 7 days a week |
92 | setHScrollBarMode(AlwaysOff); | 92 | setHScrollBarMode(AlwaysOff); |
93 | setVScrollBarMode(AlwaysOff); | 93 | setVScrollBarMode(AlwaysOff); |
94 | viewport()->setBackgroundColor(QColor(220,245,255)); | 94 | viewport()->setBackgroundColor(QColor(220,245,255)); |
95 | #if 0 | 95 | #if 0 |
96 | viewport()->setEraseColor(lightGray); | 96 | viewport()->setEraseColor(lightGray); |
97 | #endif | 97 | #endif |
98 | mMarkCurrent = false; | 98 | mMarkCurrent = false; |
99 | setDate(date_); // this initializes firstday, numdays, numDaysPrevMonth | 99 | setDate(date_); // this initializes firstday, numdays, numDaysPrevMonth |
100 | } | 100 | } |
101 | 101 | ||
102 | void | 102 | void |
103 | KDateTable::paintCell(QPainter *painter, int row, int col) | 103 | KDateTable::paintCell(QPainter *painter, int row, int col) |
104 | { | 104 | { |
105 | QRect rect; | 105 | QRect rect; |
106 | QString text; | 106 | QString text; |
107 | QPen pen; | 107 | QPen pen; |
108 | int w=cellWidth(); | 108 | int w=cellWidth(); |
109 | int h=cellHeight(); | 109 | int h=cellHeight(); |
110 | int pos; | 110 | int pos; |
111 | QBrush brushBlue(blue); | 111 | QBrush brushBlue(blue); |
112 | QBrush brushLightblue(QColor(220,245,255)); | 112 | QBrush brushLightblue(QColor(220,245,255)); |
113 | QFont font=KGlobalSettings::generalFont(); | 113 | QFont font=KGlobalSettings::generalFont(); |
114 | // ----- | 114 | // ----- |
115 | font.setPointSize(fontsize); | 115 | font.setPointSize(fontsize); |
116 | if(row==0) | 116 | if(row==0) |
117 | { // we are drawing the headline | 117 | { // we are drawing the headline |
118 | font.setBold(true); | 118 | font.setBold(true); |
119 | painter->setFont(font); | 119 | painter->setFont(font); |
120 | bool normalday = true; | 120 | bool normalday = true; |
121 | QString daystr; | 121 | QString daystr; |
122 | if (KGlobal::locale()->weekStartsMonday()) | 122 | if (KGlobal::locale()->weekStartsMonday()) |
123 | { | 123 | { |
124 | daystr = KGlobal::locale()->weekDayName(col+1, true); | 124 | daystr = KGlobal::locale()->weekDayName(col+1, true); |
125 | if (col == 5 || col == 6) | 125 | if (col == 5 || col == 6) |
126 | normalday = false; | 126 | normalday = false; |
127 | } else { | 127 | } else { |
128 | daystr = KGlobal::locale()->weekDayName(col==0? 7 : col, true); | 128 | daystr = KGlobal::locale()->weekDayName(col==0? 7 : col, true); |
129 | if (col == 0 || col == 6) | 129 | if (col == 0 || col == 6) |
130 | normalday = false; | 130 | normalday = false; |
131 | } | 131 | } |
132 | if (!normalday) | 132 | if (!normalday) |
133 | { | 133 | { |
134 | painter->setPen(QColor(220,245,255)); | 134 | painter->setPen(QColor(220,245,255)); |
135 | painter->setBrush(brushLightblue); | 135 | painter->setBrush(brushLightblue); |
136 | painter->drawRect(0, 0, w, h); | 136 | painter->drawRect(0, 0, w, h); |
137 | painter->setPen(blue); | 137 | painter->setPen(blue); |
138 | } else { | 138 | } else { |
139 | painter->setPen(blue); | 139 | painter->setPen(blue); |
140 | painter->setBrush(brushBlue); | 140 | painter->setBrush(brushBlue); |
141 | painter->drawRect(0, 0, w, h); | 141 | painter->drawRect(0, 0, w, h); |
142 | painter->setPen(white); | 142 | painter->setPen(white); |
143 | } | 143 | } |
144 | painter->drawText(0, 0, w, h-1, AlignCenter, | 144 | painter->drawText(0, 0, w, h-1, AlignCenter, |
145 | daystr, -1, &rect); | 145 | daystr, -1, &rect); |
146 | painter->setPen(black); | 146 | painter->setPen(black); |
147 | painter->moveTo(0, h-1); | 147 | painter->moveTo(0, h-1); |
148 | painter->lineTo(w-1, h-1); | 148 | painter->lineTo(w-1, h-1); |
149 | // ----- draw the weekday: | 149 | // ----- draw the weekday: |
150 | } else { | 150 | } else { |
151 | painter->setFont(font); | 151 | painter->setFont(font); |
152 | pos=7*(row-1)+col; | 152 | pos=7*(row-1)+col; |
153 | if (KGlobal::locale()->weekStartsMonday()) | 153 | if (KGlobal::locale()->weekStartsMonday()) |
154 | pos++; | 154 | pos++; |
155 | if(pos<firstday || (firstday+numdays<=pos)) | 155 | if(pos<firstday || (firstday+numdays<=pos)) |
156 | { // we are either | 156 | { // we are either |
157 | // ° painting a day of the previous month or | 157 | // ° painting a day of the previous month or |
158 | // ° painting a day of the following month | 158 | // ° painting a day of the following month |
159 | if(pos<firstday) | 159 | if(pos<firstday) |
160 | { // previous month | 160 | { // previous month |
161 | text.setNum(numDaysPrevMonth+pos-firstday+1); | 161 | text.setNum(numDaysPrevMonth+pos-firstday+1); |
162 | } else { // following month | 162 | } else { // following month |
163 | text.setNum(pos-firstday-numdays+1); | 163 | text.setNum(pos-firstday-numdays+1); |
164 | } | 164 | } |
165 | painter->setPen(gray); | 165 | painter->setPen(gray); |
166 | } else { // paint a day of the current month | 166 | } else { // paint a day of the current month |
167 | text.setNum(pos-firstday+1); | 167 | text.setNum(pos-firstday+1); |
168 | painter->setPen(black); | 168 | painter->setPen(black); |
169 | } | 169 | } |
170 | 170 | ||
171 | pen=painter->pen(); | 171 | pen=painter->pen(); |
172 | if(firstday+date.day()-1==pos) | 172 | if(firstday+date.day()-1==pos) |
173 | { | 173 | { |
174 | if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos) | 174 | if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos) |
175 | painter->setPen(green); | 175 | painter->setPen(green); |
176 | else | 176 | else |
177 | painter->setPen(red); | 177 | painter->setPen(red); |
178 | if(hasFocus()) | 178 | if(hasFocus()) |
179 | { | 179 | { |
180 | painter->setBrush(darkRed); | 180 | painter->setBrush(darkRed); |
181 | pen=white; | 181 | pen=white; |
182 | } else { | 182 | } else { |
183 | painter->setBrush(darkGray); | 183 | painter->setBrush(darkGray); |
184 | pen=white; | 184 | pen=white; |
185 | } | 185 | } |
186 | } else { | 186 | } else { |
187 | if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos) | 187 | if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos) |
188 | { | 188 | { |
189 | painter->setPen(green); | 189 | painter->setPen(green); |
190 | painter->setBrush(darkGreen); | 190 | painter->setBrush(darkGreen); |
191 | pen=white; | 191 | pen=white; |
192 | } else { | 192 | } else { |
193 | painter->setBrush(QColor(220,245,255)); | 193 | painter->setBrush(QColor(220,245,255)); |
194 | painter->setPen(QColor(220,245,255)); | 194 | painter->setPen(QColor(220,245,255)); |
195 | } | 195 | } |
196 | } | 196 | } |
197 | painter->drawRect(0, 0, w, h); | 197 | painter->drawRect(0, 0, w, h); |
198 | painter->setPen(pen); | 198 | painter->setPen(pen); |
199 | painter->drawText(0, 0, w, h, AlignCenter, text, -1, &rect); | 199 | painter->drawText(0, 0, w, h, AlignCenter, text, -1, &rect); |
200 | } | 200 | } |
201 | if(rect.width()>maxCell.width()) maxCell.setWidth(rect.width()); | 201 | /* |
202 | if(rect.height()>maxCell.height()) maxCell.setHeight(rect.height()); | 202 | if(rect.width()>maxCell.width()) maxCell.setWidth(rect.width()); |
203 | if(rect.height()>maxCell.height()) { | ||
204 | maxCell.setHeight(rect.height()); | ||
205 | } | ||
206 | */ | ||
203 | } | 207 | } |
204 | 208 | ||
205 | void | 209 | void |
206 | KDateTable::keyPressEvent( QKeyEvent *e ) | 210 | KDateTable::keyPressEvent( QKeyEvent *e ) |
207 | { | 211 | { |
208 | /* | 212 | /* |
209 | // not working properly | 213 | // not working properly |
210 | if ( e->key() == Qt::Key_Prior ) { | 214 | if ( e->key() == Qt::Key_Prior ) { |
211 | if ( date.month() == 1 ) { | 215 | if ( date.month() == 1 ) { |
212 | KNotifyClient::beep(); | 216 | KNotifyClient::beep(); |
213 | return; | 217 | return; |
214 | } | 218 | } |
215 | int day = date.day(); | 219 | int day = date.day(); |
216 | if ( day > 27 ) | 220 | if ( day > 27 ) |
217 | while ( !QDate::isValid( date.year(), date.month()-1, day ) ) | 221 | while ( !QDate::isValid( date.year(), date.month()-1, day ) ) |
218 | day--; | 222 | day--; |
219 | setDate(QDate(date.year(), date.month()-1, day)); | 223 | setDate(QDate(date.year(), date.month()-1, day)); |
220 | return; | 224 | return; |
221 | } | 225 | } |
222 | if ( e->key() == Qt::Key_Next ) { | 226 | if ( e->key() == Qt::Key_Next ) { |
223 | if ( date.month() == 12 ) { | 227 | if ( date.month() == 12 ) { |
224 | KNotifyClient::beep(); | 228 | KNotifyClient::beep(); |
225 | return; | 229 | return; |
226 | } | 230 | } |
227 | int day = date.day(); | 231 | int day = date.day(); |
228 | if ( day > 27 ) | 232 | if ( day > 27 ) |
229 | while ( !QDate::isValid( date.year(), date.month()+1, day ) ) | 233 | while ( !QDate::isValid( date.year(), date.month()+1, day ) ) |
230 | day--; | 234 | day--; |
231 | setDate(QDate(date.year(), date.month()+1, day)); | 235 | setDate(QDate(date.year(), date.month()+1, day)); |
232 | return; | 236 | return; |
233 | } | 237 | } |
234 | */ | 238 | */ |
235 | int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0; | 239 | int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0; |
236 | 240 | ||
237 | int temp=firstday+date.day()-dayoff; | 241 | int temp=firstday+date.day()-dayoff; |
238 | int pos = temp; | 242 | int pos = temp; |
239 | bool irgnore = true; | 243 | bool irgnore = true; |
240 | if ( e->state() != Qt::ControlButton ) { | 244 | if ( e->state() != Qt::ControlButton ) { |
241 | if ( e->key() == Qt::Key_Up ) { | 245 | if ( e->key() == Qt::Key_Up ) { |
242 | pos -= 7; | 246 | pos -= 7; |
243 | irgnore = false; | 247 | irgnore = false; |
244 | } | 248 | } |
245 | if ( e->key() == Qt::Key_Down ) { | 249 | if ( e->key() == Qt::Key_Down ) { |
246 | pos += 7; | 250 | pos += 7; |
247 | irgnore = false; | 251 | irgnore = false; |
248 | } | 252 | } |
249 | if ( e->key() == Qt::Key_Left ) { | 253 | if ( e->key() == Qt::Key_Left ) { |
250 | pos--; | 254 | pos--; |
251 | irgnore = false; | 255 | irgnore = false; |
252 | } | 256 | } |
253 | if ( e->key() == Qt::Key_Right ) { | 257 | if ( e->key() == Qt::Key_Right ) { |
254 | pos++; | 258 | pos++; |
255 | irgnore = false; | 259 | irgnore = false; |
256 | } | 260 | } |
257 | } | 261 | } |
258 | if ( irgnore ) | 262 | if ( irgnore ) |
259 | e->ignore(); | 263 | e->ignore(); |
260 | 264 | ||
261 | if(pos+dayoff<=firstday) | 265 | if(pos+dayoff<=firstday) |
262 | { // this day is in the previous month | 266 | { // this day is in the previous month |
263 | KNotifyClient::beep(); | 267 | KNotifyClient::beep(); |
264 | return; | 268 | return; |
265 | } | 269 | } |
266 | if(firstday+numdays<pos+dayoff) | 270 | if(firstday+numdays<pos+dayoff) |
267 | { // this date is in the next month | 271 | { // this date is in the next month |
268 | KNotifyClient::beep(i18n( "Month not long enough" )); | 272 | KNotifyClient::beep(i18n( "Month not long enough" )); |
269 | return; | 273 | return; |
270 | } | 274 | } |
271 | 275 | ||
272 | if ( pos == temp ) | 276 | if ( pos == temp ) |
273 | return; | 277 | return; |
274 | 278 | ||
275 | setDate(QDate(date.year(), date.month(), pos-firstday+dayoff)); | 279 | setDate(QDate(date.year(), date.month(), pos-firstday+dayoff)); |
276 | updateCell(temp/7+1, temp%7); // Update the previously selected cell | 280 | updateCell(temp/7+1, temp%7); // Update the previously selected cell |
277 | updateCell(pos/7+1, pos%7); // Update the selected cell | 281 | updateCell(pos/7+1, pos%7); // Update the selected cell |
278 | assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid()); | 282 | assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid()); |
279 | 283 | ||
280 | 284 | ||
281 | } | 285 | } |
282 | 286 | ||
283 | void | 287 | void |
284 | KDateTable::viewportResizeEvent(QResizeEvent * e) | 288 | KDateTable::viewportResizeEvent(QResizeEvent * e) |
285 | { | 289 | { |
286 | QGridView::viewportResizeEvent(e); | 290 | QGridView::viewportResizeEvent(e); |
287 | 291 | ||
288 | setCellWidth(viewport()->width()/7); | 292 | setCellWidth(viewport()->width()/7); |
289 | setCellHeight(viewport()->height()/7); | 293 | setCellHeight(viewport()->height()/7); |
290 | } | 294 | } |
291 | 295 | ||
292 | void | 296 | void |
293 | KDateTable::setFontSize(int size) | 297 | KDateTable::setFontSize(int size) |
294 | { | 298 | { |
295 | int count; | 299 | int count; |
296 | QRect rect; | 300 | QRect rect; |
297 | // ----- store rectangles: | 301 | // ----- store rectangles: |
298 | fontsize=size; | 302 | fontsize=size; |
299 | QFont font = KGlobalSettings::generalFont(); | 303 | QFont font = KGlobalSettings::generalFont(); |
300 | font.setPointSize(fontsize); | 304 | font.setPointSize(fontsize); |
301 | font.setBold( true ); | 305 | font.setBold( true ); |
302 | QFontMetrics metrics(font); | 306 | QFontMetrics metrics(font); |
303 | 307 | ||
304 | // ----- find largest day name: | 308 | // ----- find largest day name: |
305 | maxCell.setWidth(0); | 309 | maxCell.setWidth(0); |
306 | maxCell.setHeight(0); | 310 | maxCell.setHeight(0); |
307 | for(count=0; count<7; ++count) | 311 | for(count=0; count<7; ++count) |
308 | { | 312 | { |
309 | rect=metrics.boundingRect(KGlobal::locale()->weekDayName(count+1, true)); | 313 | rect=metrics.boundingRect(KGlobal::locale()->weekDayName(count+1, true)); |
310 | maxCell.setWidth(QMAX(maxCell.width(), rect.width())); | 314 | maxCell.setWidth(QMAX(maxCell.width(), rect.width())); |
311 | maxCell.setHeight(QMAX(maxCell.height(), rect.height())); | 315 | maxCell.setHeight(QMAX(maxCell.height(), rect.height())); |
312 | } | 316 | } |
313 | // ----- compare with a real wide number and add some space: | 317 | // ----- compare with a real wide number and add some space: |
314 | rect=metrics.boundingRect(QString::fromLatin1("88")); | 318 | rect=metrics.boundingRect(QString::fromLatin1("88")); |
315 | maxCell.setWidth(QMAX(maxCell.width()+2, rect.width())); | 319 | maxCell.setWidth(QMAX(maxCell.width()+2, rect.width())); |
320 | #ifdef DESKTOP_VERSION | ||
321 | maxCell.setHeight(QMAX(maxCell.height()+8, rect.height())); | ||
322 | #else | ||
316 | maxCell.setHeight(QMAX(maxCell.height()+4, rect.height())); | 323 | maxCell.setHeight(QMAX(maxCell.height()+4, rect.height())); |
317 | if ( maxCell.width() * 1000 / maxCell.height() > 1900 ) | 324 | #endif |
325 | if ( maxCell.width() * 1000 / maxCell.height() > 1900 ) { | ||
318 | maxCell.setHeight(maxCell.width() * 1000 / 1900 ); | 326 | maxCell.setHeight(maxCell.width() * 1000 / 1900 ); |
327 | qDebug("setmax "); | ||
328 | } | ||
319 | } | 329 | } |
320 | 330 | ||
321 | void | 331 | void |
322 | KDateTable::contentsMousePressEvent(QMouseEvent *e) | 332 | KDateTable::contentsMousePressEvent(QMouseEvent *e) |
323 | { | 333 | { |
324 | if(e->type()!=QEvent::MouseButtonPress) | 334 | if(e->type()!=QEvent::MouseButtonPress) |
325 | { // the KDatePicker only reacts on mouse press events: | 335 | { // the KDatePicker only reacts on mouse press events: |
326 | return; | 336 | return; |
327 | } | 337 | } |
328 | if(!isEnabled()) | 338 | if(!isEnabled()) |
329 | { | 339 | { |
330 | KNotifyClient::beep(); | 340 | KNotifyClient::beep(); |
331 | return; | 341 | return; |
332 | } | 342 | } |
333 | 343 | ||
334 | int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0; | 344 | int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0; |
335 | // ----- | 345 | // ----- |
336 | int row, col, pos, temp; | 346 | int row, col, pos, temp; |
337 | QPoint mouseCoord; | 347 | QPoint mouseCoord; |
338 | // ----- | 348 | // ----- |
339 | mouseCoord = e->pos(); | 349 | mouseCoord = e->pos(); |
340 | row=rowAt(mouseCoord.y()); | 350 | row=rowAt(mouseCoord.y()); |
341 | col=columnAt(mouseCoord.x()); | 351 | col=columnAt(mouseCoord.x()); |
342 | if(row<0 || col<0) | 352 | if(row<0 || col<0) |
343 | { // the user clicked on the frame of the table | 353 | { // the user clicked on the frame of the table |
344 | return; | 354 | return; |
345 | } | 355 | } |
346 | pos=7*(row-1)+col+1; | 356 | pos=7*(row-1)+col+1; |
347 | #if 0 | 357 | #if 0 |
348 | if(pos+dayoff<=firstday) | 358 | if(pos+dayoff<=firstday) |
349 | { // this day is in the previous month | 359 | { // this day is in the previous month |
350 | KNotifyClient::beep(); | 360 | KNotifyClient::beep(); |
351 | return; | 361 | return; |
352 | } | 362 | } |
353 | if(firstday+numdays<pos+dayoff) | 363 | if(firstday+numdays<pos+dayoff) |
354 | { // this date is in the next month | 364 | { // this date is in the next month |
355 | KNotifyClient::beep(); | 365 | KNotifyClient::beep(); |
356 | return; | 366 | return; |
357 | } | 367 | } |
358 | #endif | 368 | #endif |
359 | temp=firstday+date.day()-dayoff-1; | 369 | temp=firstday+date.day()-dayoff-1; |
360 | QDate da = QDate(date.year(), date.month(),1); | 370 | QDate da = QDate(date.year(), date.month(),1); |
361 | setDate(da.addDays( pos-firstday+dayoff-1)); | 371 | setDate(da.addDays( pos-firstday+dayoff-1)); |
362 | updateCell(temp/7+1, temp%7); // Update the previously selected cell | 372 | updateCell(temp/7+1, temp%7); // Update the previously selected cell |
363 | updateCell(row, col); // Update the selected cell | 373 | updateCell(row, col); // Update the selected cell |
364 | // assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid()); | 374 | // assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid()); |
365 | emit(tableClicked()); | 375 | emit(tableClicked()); |
366 | } | 376 | } |
367 | 377 | ||
368 | bool | 378 | bool |
369 | KDateTable::setDate(const QDate& date_) | 379 | KDateTable::setDate(const QDate& date_) |
370 | { | 380 | { |
371 | bool changed=false; | 381 | bool changed=false; |
372 | QDate temp; | 382 | QDate temp; |
373 | mMarkCurrent = false; | 383 | mMarkCurrent = false; |
374 | // ----- | 384 | // ----- |
375 | if(!date_.isValid()) | 385 | if(!date_.isValid()) |
376 | { | 386 | { |
377 | kdDebug() << "KDateTable::setDate: refusing to set invalid date." << endl; | 387 | kdDebug() << "KDateTable::setDate: refusing to set invalid date." << endl; |
378 | return false; | 388 | return false; |
379 | } | 389 | } |
380 | if(date!=date_) | 390 | if(date!=date_) |
381 | { | 391 | { |
382 | date=date_; | 392 | date=date_; |
383 | changed=true; | 393 | changed=true; |
384 | } | 394 | } |
385 | mMarkCurrent = ( date.month() == QDate::currentDate().month() && date.year() == QDate::currentDate().year() ); | 395 | mMarkCurrent = ( date.month() == QDate::currentDate().month() && date.year() == QDate::currentDate().year() ); |
386 | temp.setYMD(date.year(), date.month(), 1); | 396 | temp.setYMD(date.year(), date.month(), 1); |
387 | firstday=temp.dayOfWeek(); | 397 | firstday=temp.dayOfWeek(); |
388 | if(firstday==1) firstday=8; | 398 | if(firstday==1) firstday=8; |
389 | numdays=date.daysInMonth(); | 399 | numdays=date.daysInMonth(); |
390 | if(date.month()==1) | 400 | if(date.month()==1) |
391 | { // set to december of previous year | 401 | { // set to december of previous year |
392 | temp.setYMD(date.year()-1, 12, 1); | 402 | temp.setYMD(date.year()-1, 12, 1); |
393 | } else { // set to previous month | 403 | } else { // set to previous month |
394 | temp.setYMD(date.year(), date.month()-1, 1); | 404 | temp.setYMD(date.year(), date.month()-1, 1); |
395 | } | 405 | } |
396 | numDaysPrevMonth=temp.daysInMonth(); | 406 | numDaysPrevMonth=temp.daysInMonth(); |
397 | if(changed) | 407 | if(changed) |
398 | { | 408 | { |
399 | repaintContents(false); | 409 | repaintContents(false); |
400 | } | 410 | } |
401 | emit(dateChanged(date)); | 411 | emit(dateChanged(date)); |
402 | return true; | 412 | return true; |
403 | } | 413 | } |
404 | 414 | ||
405 | const QDate& | 415 | const QDate& |
406 | KDateTable::getDate() const | 416 | KDateTable::getDate() const |
407 | { | 417 | { |
408 | return date; | 418 | return date; |
409 | } | 419 | } |
410 | 420 | ||
411 | void KDateTable::focusInEvent( QFocusEvent *e ) | 421 | void KDateTable::focusInEvent( QFocusEvent *e ) |
412 | { | 422 | { |
413 | repaintContents(false); | 423 | repaintContents(false); |
414 | QGridView::focusInEvent( e ); | 424 | QGridView::focusInEvent( e ); |
415 | } | 425 | } |
416 | 426 | ||
417 | void KDateTable::focusOutEvent( QFocusEvent *e ) | 427 | void KDateTable::focusOutEvent( QFocusEvent *e ) |
418 | { | 428 | { |
419 | repaintContents(false); | 429 | repaintContents(false); |
420 | QGridView::focusOutEvent( e ); | 430 | QGridView::focusOutEvent( e ); |
421 | } | 431 | } |
422 | 432 | ||
423 | QSize | 433 | QSize |
424 | KDateTable::sizeHint() const | 434 | KDateTable::sizeHint() const |
425 | { | 435 | { |
426 | if(maxCell.height()>0 && maxCell.width()>0) | 436 | if(maxCell.height()>0 && maxCell.width()>0) |
427 | { | 437 | { |
428 | return QSize((maxCell.width()+2)*numCols()+2*frameWidth(), | 438 | return QSize((maxCell.width()+2)*numCols()+2*frameWidth(), |
429 | (maxCell.height()+4)*numRows()+2*frameWidth()); | 439 | (maxCell.height()+4)*numRows()+2*frameWidth()); |
430 | } else { | 440 | } else { |
431 | return QSize(-1, -1); | 441 | return QSize(-1, -1); |
432 | } | 442 | } |
433 | } | 443 | } |
434 | 444 | ||
435 | KDateInternalMonthPicker::KDateInternalMonthPicker | 445 | KDateInternalMonthPicker::KDateInternalMonthPicker |
436 | (int fontsize, QWidget* parent, const char* name) | 446 | (int fontsize, QWidget* parent, const char* name) |
437 | : QGridView(parent, name), | 447 | : QGridView(parent, name), |
438 | result(0) // invalid | 448 | result(0) // invalid |
439 | { | 449 | { |
440 | QRect rect; | 450 | QRect rect; |
441 | QFont font; | 451 | QFont font; |
442 | // ----- | 452 | // ----- |
443 | activeCol = -1; | 453 | activeCol = -1; |
444 | activeRow = -1; | 454 | activeRow = -1; |
445 | font=KGlobalSettings::generalFont(); | 455 | font=KGlobalSettings::generalFont(); |
446 | font.setPointSize(fontsize); | 456 | //font.setPointSize(fontsize); |
447 | setFont(font); | 457 | setFont(font); |
448 | setHScrollBarMode(AlwaysOff); | 458 | setHScrollBarMode(AlwaysOff); |
449 | setVScrollBarMode(AlwaysOff); | 459 | setVScrollBarMode(AlwaysOff); |
450 | setFrameStyle(QFrame::NoFrame); | 460 | setFrameStyle(QFrame::NoFrame); |
451 | setNumRows(4); | 461 | setNumRows(4); |
452 | setNumCols(3); | 462 | setNumCols(3); |
453 | // enable to find drawing failures: | 463 | // enable to find drawing failures: |
454 | // setTableFlags(Tbl_clipCellPainting); | 464 | // setTableFlags(Tbl_clipCellPainting); |
455 | #if 0 | 465 | #if 0 |
456 | viewport()->setEraseColor(lightGray); // for consistency with the datepicker | 466 | viewport()->setEraseColor(lightGray); // for consistency with the datepicker |
457 | #endif | 467 | #endif |
458 | // ----- find the preferred size | 468 | // ----- find the preferred size |
459 | // (this is slow, possibly, but unfortunatly it is needed here): | 469 | // (this is slow, possibly, but unfortunatly it is needed here): |
460 | QFontMetrics metrics(font); | 470 | QFontMetrics metrics(font); |
461 | for(int i=1; i <= 12; ++i) | 471 | for(int i=1; i <= 12; ++i) |
462 | { | 472 | { |
463 | rect=metrics.boundingRect(KGlobal::locale()->monthName(i, false)); | 473 | rect=metrics.boundingRect(KGlobal::locale()->monthName(i, false)); |
464 | if(max.width()<rect.width()) max.setWidth(rect.width()); | 474 | if(max.width()<rect.width()) max.setWidth(rect.width()); |
465 | if(max.height()<rect.height()) max.setHeight(rect.height()); | 475 | if(max.height()<rect.height()) max.setHeight(rect.height()); |
466 | } | 476 | } |
467 | 477 | ||
468 | } | 478 | } |
469 | 479 | ||
470 | QSize | 480 | QSize |
471 | KDateInternalMonthPicker::sizeHint() const | 481 | KDateInternalMonthPicker::sizeHint() const |
472 | { | 482 | { |
473 | return QSize((max.width()+6)*numCols()+2*frameWidth(), | 483 | return QSize((max.width()+6)*numCols()+2*frameWidth(), |
474 | (max.height()+6)*numRows()+2*frameWidth()); | 484 | (max.height()+6)*numRows()+2*frameWidth()); |
475 | } | 485 | } |
476 | 486 | ||
477 | int | 487 | int |
478 | KDateInternalMonthPicker::getResult() const | 488 | KDateInternalMonthPicker::getResult() const |
479 | { | 489 | { |
480 | return result; | 490 | return result; |
481 | } | 491 | } |
482 | 492 | ||
483 | void | 493 | void |
484 | KDateInternalMonthPicker::setupPainter(QPainter *p) | 494 | KDateInternalMonthPicker::setupPainter(QPainter *p) |
485 | { | 495 | { |
486 | p->setPen(black); | 496 | p->setPen(black); |
487 | } | 497 | } |
488 | 498 | ||
489 | void | 499 | void |
490 | KDateInternalMonthPicker::viewportResizeEvent(QResizeEvent*) | 500 | KDateInternalMonthPicker::viewportResizeEvent(QResizeEvent*) |
491 | { | 501 | { |
492 | setCellWidth(width()/3); | 502 | setCellWidth(width()/3); |
493 | setCellHeight(height()/4); | 503 | setCellHeight(height()/4); |
494 | } | 504 | } |
495 | 505 | ||
496 | void | 506 | void |
497 | KDateInternalMonthPicker::paintCell(QPainter* painter, int row, int col) | 507 | KDateInternalMonthPicker::paintCell(QPainter* painter, int row, int col) |
498 | { | 508 | { |
499 | int index; | 509 | int index; |
500 | QString text; | 510 | QString text; |
501 | // ----- find the number of the cell: | 511 | // ----- find the number of the cell: |
502 | index=3*row+col+1; | 512 | index=3*row+col+1; |
503 | text=KGlobal::locale()->monthName(index, false); | 513 | text=KGlobal::locale()->monthName(index, false); |
504 | painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text); | 514 | painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text); |
505 | if ( activeCol == col && activeRow == row ) | 515 | if ( activeCol == col && activeRow == row ) |
506 | painter->drawRect( 0, 0, cellWidth(), cellHeight() ); | 516 | painter->drawRect( 0, 0, cellWidth(), cellHeight() ); |
507 | } | 517 | } |
508 | 518 | ||
509 | void | 519 | void |
510 | KDateInternalMonthPicker::contentsMousePressEvent(QMouseEvent *e) | 520 | KDateInternalMonthPicker::contentsMousePressEvent(QMouseEvent *e) |
511 | { | 521 | { |
512 | if(!isEnabled() || e->button() != LeftButton) | 522 | if(!isEnabled() || e->button() != LeftButton) |
513 | { | 523 | { |
514 | KNotifyClient::beep(); | 524 | KNotifyClient::beep(); |
515 | return; | 525 | return; |
516 | } | 526 | } |
517 | // ----- | 527 | // ----- |
518 | int row, col; | 528 | int row, col; |
519 | QPoint mouseCoord; | 529 | QPoint mouseCoord; |
520 | // ----- | 530 | // ----- |
521 | mouseCoord = e->pos(); | 531 | mouseCoord = e->pos(); |
522 | row=rowAt(mouseCoord.y()); | 532 | row=rowAt(mouseCoord.y()); |
523 | col=columnAt(mouseCoord.x()); | 533 | col=columnAt(mouseCoord.x()); |
524 | 534 | ||
525 | if(row<0 || col<0) | 535 | if(row<0 || col<0) |
526 | { // the user clicked on the frame of the table | 536 | { // the user clicked on the frame of the table |
527 | activeCol = -1; | 537 | activeCol = -1; |
528 | activeRow = -1; | 538 | activeRow = -1; |
529 | } else { | 539 | } else { |
530 | activeCol = col; | 540 | activeCol = col; |
531 | activeRow = row; | 541 | activeRow = row; |
532 | updateCell( row, col /*, false */ ); | 542 | updateCell( row, col /*, false */ ); |
533 | } | 543 | } |
534 | } | 544 | } |
535 | 545 | ||
536 | void | 546 | void |
537 | KDateInternalMonthPicker::contentsMouseMoveEvent(QMouseEvent *e) | 547 | KDateInternalMonthPicker::contentsMouseMoveEvent(QMouseEvent *e) |
538 | { | 548 | { |
539 | if (e->state() & LeftButton) | 549 | if (e->state() & LeftButton) |
540 | { | 550 | { |
541 | int row, col; | 551 | int row, col; |
542 | QPoint mouseCoord; | 552 | QPoint mouseCoord; |
543 | // ----- | 553 | // ----- |
544 | mouseCoord = e->pos(); | 554 | mouseCoord = e->pos(); |
545 | row=rowAt(mouseCoord.y()); | 555 | row=rowAt(mouseCoord.y()); |
546 | col=columnAt(mouseCoord.x()); | 556 | col=columnAt(mouseCoord.x()); |
547 | int tmpRow = -1, tmpCol = -1; | 557 | int tmpRow = -1, tmpCol = -1; |
548 | if(row<0 || col<0) | 558 | if(row<0 || col<0) |
549 | { // the user clicked on the frame of the table | 559 | { // the user clicked on the frame of the table |
550 | if ( activeCol > -1 ) | 560 | if ( activeCol > -1 ) |
551 | { | 561 | { |
552 | tmpRow = activeRow; | 562 | tmpRow = activeRow; |
553 | tmpCol = activeCol; | 563 | tmpCol = activeCol; |
554 | } | 564 | } |
555 | activeCol = -1; | 565 | activeCol = -1; |
556 | activeRow = -1; | 566 | activeRow = -1; |
557 | } else { | 567 | } else { |
558 | bool differentCell = (activeRow != row || activeCol != col); | 568 | bool differentCell = (activeRow != row || activeCol != col); |
559 | if ( activeCol > -1 && differentCell) | 569 | if ( activeCol > -1 && differentCell) |
560 | { | 570 | { |
561 | tmpRow = activeRow; | 571 | tmpRow = activeRow; |
562 | tmpCol = activeCol; | 572 | tmpCol = activeCol; |
563 | } | 573 | } |
564 | if ( differentCell) | 574 | if ( differentCell) |
565 | { | 575 | { |
566 | activeRow = row; | 576 | activeRow = row; |
567 | activeCol = col; | 577 | activeCol = col; |
568 | updateCell( row, col /*, false */ ); // mark the new active cell | 578 | updateCell( row, col /*, false */ ); // mark the new active cell |
569 | } | 579 | } |
570 | } | 580 | } |
571 | if ( tmpRow > -1 ) // repaint the former active cell | 581 | if ( tmpRow > -1 ) // repaint the former active cell |
572 | updateCell( tmpRow, tmpCol /*, true */ ); | 582 | updateCell( tmpRow, tmpCol /*, true */ ); |
573 | } | 583 | } |
574 | } | 584 | } |
@@ -636,278 +646,282 @@ KDateInternalYearSelector::yearEnteredSlot() | |||
636 | { | 646 | { |
637 | KNotifyClient::beep(); | 647 | KNotifyClient::beep(); |
638 | return; | 648 | return; |
639 | } | 649 | } |
640 | result=year; | 650 | result=year; |
641 | emit(closeMe(1)); | 651 | emit(closeMe(1)); |
642 | } | 652 | } |
643 | 653 | ||
644 | int | 654 | int |
645 | KDateInternalYearSelector::getYear() | 655 | KDateInternalYearSelector::getYear() |
646 | { | 656 | { |
647 | return result; | 657 | return result; |
648 | } | 658 | } |
649 | 659 | ||
650 | void | 660 | void |
651 | KDateInternalYearSelector::setYear(int year) | 661 | KDateInternalYearSelector::setYear(int year) |
652 | { | 662 | { |
653 | QString temp; | 663 | QString temp; |
654 | // ----- | 664 | // ----- |
655 | temp.setNum(year); | 665 | temp.setNum(year); |
656 | setText(temp); | 666 | setText(temp); |
657 | } | 667 | } |
658 | 668 | ||
659 | KPopupFrame::KPopupFrame(QWidget* parent, const char* name) | 669 | KPopupFrame::KPopupFrame(QWidget* parent, const char* name) |
660 | : QFrame(parent, name, WType_Popup), | 670 | : QFrame(parent, name, WType_Popup), |
661 | result(0), // rejected | 671 | result(0), // rejected |
662 | main(0) | 672 | main(0) |
663 | { | 673 | { |
664 | setFrameStyle(QFrame::Box|QFrame::Raised); | 674 | setFrameStyle(QFrame::Box|QFrame::Raised); |
665 | setMidLineWidth(2); | 675 | setMidLineWidth(2); |
666 | } | 676 | } |
667 | 677 | ||
668 | void | 678 | void |
669 | KPopupFrame::keyPressEvent(QKeyEvent* e) | 679 | KPopupFrame::keyPressEvent(QKeyEvent* e) |
670 | { | 680 | { |
671 | if(e->key()==Key_Escape) | 681 | if(e->key()==Key_Escape) |
672 | { | 682 | { |
673 | result=0; // rejected | 683 | result=0; // rejected |
674 | qApp->exit_loop(); | 684 | qApp->exit_loop(); |
675 | } | 685 | } |
676 | } | 686 | } |
677 | 687 | ||
678 | void | 688 | void |
679 | KPopupFrame::close(int r) | 689 | KPopupFrame::close(int r) |
680 | { | 690 | { |
681 | result=r; | 691 | result=r; |
682 | qApp->exit_loop(); | 692 | qApp->exit_loop(); |
683 | } | 693 | } |
684 | 694 | ||
685 | void | 695 | void |
686 | KPopupFrame::setMainWidget(QWidget* m) | 696 | KPopupFrame::setMainWidget(QWidget* m) |
687 | { | 697 | { |
688 | main=m; | 698 | main=m; |
689 | if(main!=0) | 699 | if(main!=0) |
690 | { | 700 | { |
691 | resize(main->width()+2*frameWidth(), main->height()+2*frameWidth()); | 701 | resize(main->width()+2*frameWidth(), main->height()+2*frameWidth()); |
692 | } | 702 | } |
693 | } | 703 | } |
694 | 704 | ||
695 | void | 705 | void |
696 | KPopupFrame::resizeEvent(QResizeEvent*) | 706 | KPopupFrame::resizeEvent(QResizeEvent*) |
697 | { | 707 | { |
698 | if(main!=0) | 708 | if(main!=0) |
699 | { | 709 | { |
700 | main->setGeometry(frameWidth(), frameWidth(), | 710 | main->setGeometry(frameWidth(), frameWidth(), |
701 | width()-2*frameWidth(), height()-2*frameWidth()); | 711 | width()-2*frameWidth(), height()-2*frameWidth()); |
702 | } | 712 | } |
703 | } | 713 | } |
704 | 714 | ||
705 | void | 715 | void |
706 | KPopupFrame::popup(const QPoint &pos) | 716 | KPopupFrame::popup(const QPoint &pos) |
707 | { | 717 | { |
708 | // Make sure the whole popup is visible. | 718 | // Make sure the whole popup is visible. |
709 | QRect d = QApplication::desktop()->frameGeometry(); | 719 | QRect d = QApplication::desktop()->frameGeometry(); |
710 | int x = pos.x(); | 720 | int x = pos.x(); |
711 | int y = pos.y(); | 721 | int y = pos.y(); |
712 | int w = width(); | 722 | int w = width(); |
713 | int h = height(); | 723 | int h = height(); |
714 | if (x+w > d.x()+d.width()) | 724 | if (x+w > d.x()+d.width()) |
715 | x = d.width() - w; | 725 | x = d.width() - w; |
716 | if (y+h > d.y()+d.height()) | 726 | if (y+h > d.y()+d.height()) |
717 | y = d.height() - h; | 727 | y = d.height() - h; |
718 | if (x < d.x()) | 728 | if (x < d.x()) |
719 | x = 0; | 729 | x = 0; |
720 | if (y < d.y()) | 730 | if (y < d.y()) |
721 | y = 0; | 731 | y = 0; |
722 | 732 | ||
723 | // Pop the thingy up. | 733 | // Pop the thingy up. |
724 | move(x, y); | 734 | move(x, y); |
725 | show(); | 735 | show(); |
726 | } | 736 | } |
727 | 737 | ||
728 | int | 738 | int |
729 | KPopupFrame::exec(QPoint pos) | 739 | KPopupFrame::exec(QPoint pos) |
730 | { | 740 | { |
731 | popup(pos); | 741 | popup(pos); |
732 | repaint(); | 742 | repaint(); |
733 | qApp->enter_loop(); | 743 | qApp->enter_loop(); |
734 | hide(); | 744 | hide(); |
735 | return result; | 745 | return result; |
736 | } | 746 | } |
737 | 747 | ||
738 | int | 748 | int |
739 | KPopupFrame::exec(int x, int y) | 749 | KPopupFrame::exec(int x, int y) |
740 | { | 750 | { |
741 | return exec(QPoint(x, y)); | 751 | return exec(QPoint(x, y)); |
742 | } | 752 | } |
743 | 753 | ||
744 | void KPopupFrame::virtual_hook( int, void* ) | 754 | void KPopupFrame::virtual_hook( int, void* ) |
745 | { /*BASE::virtual_hook( id, data );*/ } | 755 | { /*BASE::virtual_hook( id, data );*/ } |
746 | 756 | ||
747 | void KDateTable::virtual_hook( int, void* ) | 757 | void KDateTable::virtual_hook( int, void* ) |
748 | { /*BASE::virtual_hook( id, data );*/ } | 758 | { /*BASE::virtual_hook( id, data );*/ } |
749 | 759 | ||
750 | //#include "kdatetbl.moc" | 760 | //#include "kdatetbl.moc" |
751 | 761 | ||
752 | 762 | ||
753 | KDateInternalWeekPicker::KDateInternalWeekPicker | 763 | KDateInternalWeekPicker::KDateInternalWeekPicker |
754 | (int fontsize, QWidget* parent, const char* name) | 764 | (int fontsize, QWidget* parent, const char* name) |
755 | : QGridView(parent, name), | 765 | : QGridView(parent, name), |
756 | result(0) // invalid | 766 | result(0) // invalid |
757 | { | 767 | { |
758 | QRect rect; | 768 | QRect rect; |
759 | QFont font; | 769 | QFont font; |
760 | // ----- | 770 | // ----- |
761 | activeCol = -1; | 771 | activeCol = -1; |
762 | activeRow = -1; | 772 | activeRow = -1; |
763 | font=KGlobalSettings::generalFont(); | 773 | font=KGlobalSettings::generalFont(); |
764 | font.setPointSize(fontsize); | 774 | //font.setPointSize(fontsize); |
765 | setFont(font); | 775 | setFont(font); |
766 | setHScrollBarMode(AlwaysOff); | 776 | setHScrollBarMode(AlwaysOff); |
767 | setVScrollBarMode(AlwaysOff); | 777 | setVScrollBarMode(AlwaysOff); |
768 | setFrameStyle(QFrame::NoFrame); | 778 | setFrameStyle(QFrame::NoFrame); |
769 | setNumRows(13); | 779 | setNumRows(13); |
770 | setNumCols(4); | 780 | setNumCols(4); |
771 | // enable to find drawing failures: | 781 | // enable to find drawing failures: |
772 | // setTableFlags(Tbl_clipCellPainting); | 782 | // setTableFlags(Tbl_clipCellPainting); |
773 | #if 0 | 783 | #if 0 |
774 | viewport()->setEraseColor(lightGray); // for consistency with the datepicker | 784 | viewport()->setEraseColor(lightGray); // for consistency with the datepicker |
775 | #endif | 785 | #endif |
776 | // ----- find the preferred size | 786 | // ----- find the preferred size |
777 | // (this is slow, possibly, but unfortunatly it is needed here): | 787 | // (this is slow, possibly, but unfortunatly it is needed here): |
778 | QFontMetrics metrics(font); | 788 | QFontMetrics metrics(font); |
779 | for(int i=1; i <= 52; ++i) | 789 | for(int i=1; i <= 52; ++i) |
780 | { | 790 | { |
781 | rect=metrics.boundingRect(QString::number( i )); | 791 | rect=metrics.boundingRect(QString::number( i )); |
782 | if(max.width()<rect.width()) max.setWidth(rect.width()); | 792 | if(max.width()<rect.width()) max.setWidth(rect.width()); |
783 | if(max.height()<rect.height()) max.setHeight(rect.height()); | 793 | if(max.height()<rect.height()) max.setHeight(rect.height()); |
784 | } | 794 | } |
785 | 795 | if ( QApplication::desktop()->width() > 640 ) { | |
796 | |||
797 | max.setWidth(max.width()+6); | ||
798 | max.setHeight(max.height()+8); | ||
799 | } | ||
786 | } | 800 | } |
787 | 801 | ||
788 | QSize | 802 | QSize |
789 | KDateInternalWeekPicker::sizeHint() const | 803 | KDateInternalWeekPicker::sizeHint() const |
790 | { | 804 | { |
791 | return QSize((max.width()+6)*numCols()+2*frameWidth(), | 805 | return QSize((max.width()+6)*numCols()+2*frameWidth(), |
792 | (max.height()+6)*numRows()+2*frameWidth()); | 806 | (max.height()+6)*numRows()+2*frameWidth()); |
793 | } | 807 | } |
794 | 808 | ||
795 | int | 809 | int |
796 | KDateInternalWeekPicker::getResult() const | 810 | KDateInternalWeekPicker::getResult() const |
797 | { | 811 | { |
798 | return result; | 812 | return result; |
799 | } | 813 | } |
800 | 814 | ||
801 | void | 815 | void |
802 | KDateInternalWeekPicker::setupPainter(QPainter *p) | 816 | KDateInternalWeekPicker::setupPainter(QPainter *p) |
803 | { | 817 | { |
804 | p->setPen(black); | 818 | p->setPen(black); |
805 | } | 819 | } |
806 | 820 | ||
807 | void | 821 | void |
808 | KDateInternalWeekPicker::viewportResizeEvent(QResizeEvent*) | 822 | KDateInternalWeekPicker::viewportResizeEvent(QResizeEvent*) |
809 | { | 823 | { |
810 | setCellWidth(width()/4); | 824 | setCellWidth(width()/4); |
811 | setCellHeight(height()/13); | 825 | setCellHeight(height()/13); |
812 | } | 826 | } |
813 | 827 | ||
814 | void | 828 | void |
815 | KDateInternalWeekPicker::paintCell(QPainter* painter, int row, int col) | 829 | KDateInternalWeekPicker::paintCell(QPainter* painter, int row, int col) |
816 | { | 830 | { |
817 | int index; | 831 | int index; |
818 | QString text; | 832 | QString text; |
819 | // ----- find the number of the cell: | 833 | // ----- find the number of the cell: |
820 | index=4*row+col+1; | 834 | index=4*row+col+1; |
821 | text=QString::number( index ); | 835 | text=QString::number( index ); |
822 | painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text); | 836 | painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text); |
823 | if ( activeCol == col && activeRow == row ) | 837 | if ( activeCol == col && activeRow == row ) |
824 | painter->drawRect( 0, 0, cellWidth(), cellHeight() ); | 838 | painter->drawRect( 0, 0, cellWidth(), cellHeight() ); |
825 | } | 839 | } |
826 | 840 | ||
827 | void | 841 | void |
828 | KDateInternalWeekPicker::contentsMousePressEvent(QMouseEvent *e) | 842 | KDateInternalWeekPicker::contentsMousePressEvent(QMouseEvent *e) |
829 | { | 843 | { |
830 | if(!isEnabled() || e->button() != LeftButton) | 844 | if(!isEnabled() || e->button() != LeftButton) |
831 | { | 845 | { |
832 | KNotifyClient::beep(); | 846 | KNotifyClient::beep(); |
833 | return; | 847 | return; |
834 | } | 848 | } |
835 | // ----- | 849 | // ----- |
836 | int row, col; | 850 | int row, col; |
837 | QPoint mouseCoord; | 851 | QPoint mouseCoord; |
838 | // ----- | 852 | // ----- |
839 | mouseCoord = e->pos(); | 853 | mouseCoord = e->pos(); |
840 | row=rowAt(mouseCoord.y()); | 854 | row=rowAt(mouseCoord.y()); |
841 | col=columnAt(mouseCoord.x()); | 855 | col=columnAt(mouseCoord.x()); |
842 | 856 | ||
843 | if(row<0 || col<0) | 857 | if(row<0 || col<0) |
844 | { // the user clicked on the frame of the table | 858 | { // the user clicked on the frame of the table |
845 | activeCol = -1; | 859 | activeCol = -1; |
846 | activeRow = -1; | 860 | activeRow = -1; |
847 | } else { | 861 | } else { |
848 | activeCol = col; | 862 | activeCol = col; |
849 | activeRow = row; | 863 | activeRow = row; |
850 | updateCell( row, col /*, false */ ); | 864 | updateCell( row, col /*, false */ ); |
851 | } | 865 | } |
852 | } | 866 | } |
853 | 867 | ||
854 | void | 868 | void |
855 | KDateInternalWeekPicker::contentsMouseMoveEvent(QMouseEvent *e) | 869 | KDateInternalWeekPicker::contentsMouseMoveEvent(QMouseEvent *e) |
856 | { | 870 | { |
857 | if (e->state() & LeftButton) | 871 | if (e->state() & LeftButton) |
858 | { | 872 | { |
859 | int row, col; | 873 | int row, col; |
860 | QPoint mouseCoord; | 874 | QPoint mouseCoord; |
861 | // ----- | 875 | // ----- |
862 | mouseCoord = e->pos(); | 876 | mouseCoord = e->pos(); |
863 | row=rowAt(mouseCoord.y()); | 877 | row=rowAt(mouseCoord.y()); |
864 | col=columnAt(mouseCoord.x()); | 878 | col=columnAt(mouseCoord.x()); |
865 | int tmpRow = -1, tmpCol = -1; | 879 | int tmpRow = -1, tmpCol = -1; |
866 | if(row<0 || col<0) | 880 | if(row<0 || col<0) |
867 | { // the user clicked on the frame of the table | 881 | { // the user clicked on the frame of the table |
868 | if ( activeCol > -1 ) | 882 | if ( activeCol > -1 ) |
869 | { | 883 | { |
870 | tmpRow = activeRow; | 884 | tmpRow = activeRow; |
871 | tmpCol = activeCol; | 885 | tmpCol = activeCol; |
872 | } | 886 | } |
873 | activeCol = -1; | 887 | activeCol = -1; |
874 | activeRow = -1; | 888 | activeRow = -1; |
875 | } else { | 889 | } else { |
876 | bool differentCell = (activeRow != row || activeCol != col); | 890 | bool differentCell = (activeRow != row || activeCol != col); |
877 | if ( activeCol > -1 && differentCell) | 891 | if ( activeCol > -1 && differentCell) |
878 | { | 892 | { |
879 | tmpRow = activeRow; | 893 | tmpRow = activeRow; |
880 | tmpCol = activeCol; | 894 | tmpCol = activeCol; |
881 | } | 895 | } |
882 | if ( differentCell) | 896 | if ( differentCell) |
883 | { | 897 | { |
884 | activeRow = row; | 898 | activeRow = row; |
885 | activeCol = col; | 899 | activeCol = col; |
886 | updateCell( row, col /*, false */ ); // mark the new active cell | 900 | updateCell( row, col /*, false */ ); // mark the new active cell |
887 | } | 901 | } |
888 | } | 902 | } |
889 | if ( tmpRow > -1 ) // repaint the former active cell | 903 | if ( tmpRow > -1 ) // repaint the former active cell |
890 | updateCell( tmpRow, tmpCol /*, true */ ); | 904 | updateCell( tmpRow, tmpCol /*, true */ ); |
891 | } | 905 | } |
892 | } | 906 | } |
893 | 907 | ||
894 | void | 908 | void |
895 | KDateInternalWeekPicker::contentsMouseReleaseEvent(QMouseEvent *e) | 909 | KDateInternalWeekPicker::contentsMouseReleaseEvent(QMouseEvent *e) |
896 | { | 910 | { |
897 | if(!isEnabled()) | 911 | if(!isEnabled()) |
898 | { | 912 | { |
899 | return; | 913 | return; |
900 | } | 914 | } |
901 | // ----- | 915 | // ----- |
902 | int row, col, pos; | 916 | int row, col, pos; |
903 | QPoint mouseCoord; | 917 | QPoint mouseCoord; |
904 | // ----- | 918 | // ----- |
905 | mouseCoord = e->pos(); | 919 | mouseCoord = e->pos(); |
906 | row=rowAt(mouseCoord.y()); | 920 | row=rowAt(mouseCoord.y()); |
907 | col=columnAt(mouseCoord.x()); | 921 | col=columnAt(mouseCoord.x()); |
908 | if(row<0 || col<0) | 922 | if(row<0 || col<0) |
909 | { // the user clicked on the frame of the table | 923 | { // the user clicked on the frame of the table |
910 | emit(closeMe(0)); | 924 | emit(closeMe(0)); |
911 | } | 925 | } |
912 | pos=4*row+col+1; | 926 | pos=4*row+col+1; |
913 | result=pos; | 927 | result=pos; |
diff --git a/microkde/kglobalsettings.cpp b/microkde/kglobalsettings.cpp index 2fff8fc..30e793f 100644 --- a/microkde/kglobalsettings.cpp +++ b/microkde/kglobalsettings.cpp | |||
@@ -1,41 +1,43 @@ | |||
1 | #include "kglobalsettings.h" | 1 | #include "kglobalsettings.h" |
2 | #include "kconfig.h" | 2 | #include "kconfig.h" |
3 | #include "kglobal.h" | 3 | #include "kglobal.h" |
4 | #include "kconfigbase.h" | 4 | #include "kconfigbase.h" |
5 | 5 | ||
6 | #include <qapplication.h> | 6 | #include <qapplication.h> |
7 | 7 | ||
8 | QFont KGlobalSettings::generalFont() | 8 | QFont KGlobalSettings::generalFont() |
9 | { | 9 | { |
10 | int size = 12; | 10 | int size = 12; |
11 | if (QApplication::desktop()->width() < 480 ) | 11 | if (QApplication::desktop()->width() < 480 ) |
12 | size = 10; | 12 | size = 10; |
13 | return QFont("helvetica",size); | 13 | QFont f = QApplication::font(); |
14 | f.setPointSize( size ); | ||
15 | return f; | ||
14 | } | 16 | } |
15 | QFont KGlobalSettings::toolBarFont() | 17 | QFont KGlobalSettings::toolBarFont() |
16 | { | 18 | { |
17 | return QFont("helevetica",12); | 19 | return QApplication::font(); |
18 | } | 20 | } |
19 | 21 | ||
20 | QColor KGlobalSettings::toolBarHighlightColor() | 22 | QColor KGlobalSettings::toolBarHighlightColor() |
21 | { | 23 | { |
22 | return QColor("black"); | 24 | return QColor( "black" ); |
23 | } | 25 | } |
24 | 26 | ||
25 | QRect KGlobalSettings::desktopGeometry( QWidget * ) | 27 | QRect KGlobalSettings::desktopGeometry( QWidget * ) |
26 | { | 28 | { |
27 | return QApplication::desktop()->rect(); | 29 | return QApplication::desktop()->rect(); |
28 | } | 30 | } |
29 | 31 | ||
30 | /** | 32 | /** |
31 | * Returns whether KDE runs in single (default) or double click | 33 | * Returns whether KDE runs in single (default) or double click |
32 | * mode. | 34 | * mode. |
33 | * see http://developer.kde.org/documentation/standards/kde/style/mouse/index.html | 35 | * see http://developer.kde.org/documentation/standards/kde/style/mouse/index.html |
34 | * @return true if single click mode, or false if double click mode. | 36 | * @return true if single click mode, or false if double click mode. |
35 | **/ | 37 | **/ |
36 | bool KGlobalSettings::singleClick() | 38 | bool KGlobalSettings::singleClick() |
37 | { | 39 | { |
38 | KConfig *c = KGlobal::config(); | 40 | KConfig *c = KGlobal::config(); |
39 | KConfigGroupSaver cgs( c, "KDE" ); | 41 | KConfigGroupSaver cgs( c, "KDE" ); |
40 | return c->readBoolEntry("SingleClick", KDE_DEFAULT_SINGLECLICK); | 42 | return c->readBoolEntry("SingleClick", KDE_DEFAULT_SINGLECLICK); |
41 | } | 43 | } |