author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /microkde/kdatepickernew.cpp | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2 |
initial public commit of qt4 portp1
-rw-r--r-- | microkde/kdatepickernew.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/microkde/kdatepickernew.cpp b/microkde/kdatepickernew.cpp index f60a422..8f8001e 100644 --- a/microkde/kdatepickernew.cpp +++ b/microkde/kdatepickernew.cpp | |||
@@ -124,362 +124,362 @@ void KDatePicker::init( const QDate &dt ) | |||
124 | QToolTip::add(d->todayButton, i18n("Select the current day")); | 124 | QToolTip::add(d->todayButton, i18n("Select the current day")); |
125 | 125 | ||
126 | // ----- | 126 | // ----- |
127 | setFontSize(fontsize); | 127 | setFontSize(fontsize); |
128 | line->setValidator(val); | 128 | line->setValidator(val); |
129 | line->installEventFilter( this ); | 129 | line->installEventFilter( this ); |
130 | // yearForward->setIconSet(BarIconSet(QString::fromLatin1("2rightarrow"))); | 130 | // yearForward->setIconSet(BarIconSet(QString::fromLatin1("2rightarrow"))); |
131 | // yearBackward->setIconSet(BarIconSet(QString::fromLatin1("2leftarrow"))); | 131 | // yearBackward->setIconSet(BarIconSet(QString::fromLatin1("2leftarrow"))); |
132 | // monthForward->setIconSet(BarIconSet(QString::fromLatin1("1rightarrow"))); | 132 | // monthForward->setIconSet(BarIconSet(QString::fromLatin1("1rightarrow"))); |
133 | // monthBackward->setIconSet(BarIconSet(QString::fromLatin1("1leftarrow"))); | 133 | // monthBackward->setIconSet(BarIconSet(QString::fromLatin1("1leftarrow"))); |
134 | setDate(dt); // set button texts | 134 | setDate(dt); // set button texts |
135 | connect(table, SIGNAL(dateChanged(QDate)), SLOT(dateChangedSlot(QDate))); | 135 | connect(table, SIGNAL(dateChanged(QDate)), SLOT(dateChangedSlot(QDate))); |
136 | connect(table, SIGNAL(tableClicked()), SLOT(tableClickedSlot())); | 136 | connect(table, SIGNAL(tableClicked()), SLOT(tableClickedSlot())); |
137 | connect(monthForward, SIGNAL(clicked()), SLOT(monthForwardClicked())); | 137 | connect(monthForward, SIGNAL(clicked()), SLOT(monthForwardClicked())); |
138 | connect(monthBackward, SIGNAL(clicked()), SLOT(monthBackwardClicked())); | 138 | connect(monthBackward, SIGNAL(clicked()), SLOT(monthBackwardClicked())); |
139 | connect(yearForward, SIGNAL(clicked()), SLOT(yearForwardClicked())); | 139 | connect(yearForward, SIGNAL(clicked()), SLOT(yearForwardClicked())); |
140 | connect(yearBackward, SIGNAL(clicked()), SLOT(yearBackwardClicked())); | 140 | connect(yearBackward, SIGNAL(clicked()), SLOT(yearBackwardClicked())); |
141 | connect(d->selectWeek, SIGNAL(activated(int)), SLOT(weekSelected(int))); | 141 | connect(d->selectWeek, SIGNAL(activated(int)), SLOT(weekSelected(int))); |
142 | connect(d->todayButton, SIGNAL(clicked()), SLOT(todayButtonClicked())); | 142 | connect(d->todayButton, SIGNAL(clicked()), SLOT(todayButtonClicked())); |
143 | connect(selectMonth, SIGNAL(clicked()), SLOT(selectMonthClicked())); | 143 | connect(selectMonth, SIGNAL(clicked()), SLOT(selectMonthClicked())); |
144 | connect(selectYear, SIGNAL(clicked()), SLOT(selectYearClicked())); | 144 | connect(selectYear, SIGNAL(clicked()), SLOT(selectYearClicked())); |
145 | connect(line, SIGNAL(returnPressed()), SLOT(lineEnterPressed())); | 145 | connect(line, SIGNAL(returnPressed()), SLOT(lineEnterPressed())); |
146 | table->setFocus(); | 146 | table->setFocus(); |
147 | 147 | ||
148 | QBoxLayout * topLayout = new QVBoxLayout(this); | 148 | QBoxLayout * topLayout = new QVBoxLayout(this); |
149 | 149 | ||
150 | d->navigationLayout = new QHBoxLayout(topLayout); | 150 | d->navigationLayout = new QHBoxLayout(topLayout); |
151 | d->navigationLayout->addWidget(d->tb); | 151 | d->navigationLayout->addWidget(d->tb); |
152 | 152 | ||
153 | topLayout->addWidget(table); | 153 | topLayout->addWidget(table); |
154 | 154 | ||
155 | QBoxLayout * bottomLayout = new QHBoxLayout(topLayout); | 155 | QBoxLayout * bottomLayout = new QHBoxLayout(topLayout); |
156 | bottomLayout->addWidget(d->todayButton); | 156 | bottomLayout->addWidget(d->todayButton); |
157 | bottomLayout->addWidget(line); | 157 | bottomLayout->addWidget(line); |
158 | bottomLayout->addWidget(d->selectWeek); | 158 | bottomLayout->addWidget(d->selectWeek); |
159 | } | 159 | } |
160 | 160 | ||
161 | KDatePicker::~KDatePicker() | 161 | KDatePicker::~KDatePicker() |
162 | { | 162 | { |
163 | delete d; | 163 | delete d; |
164 | } | 164 | } |
165 | 165 | ||
166 | bool | 166 | bool |
167 | KDatePicker::eventFilter(QObject *o, QEvent *e ) | 167 | KDatePicker::eventFilter(QObject *o, QEvent *e ) |
168 | { | 168 | { |
169 | if ( e->type() == QEvent::KeyPress ) { | 169 | if ( e->type() == QEvent::KeyPress ) { |
170 | QKeyEvent *k = (QKeyEvent *)e; | 170 | QKeyEvent *k = (QKeyEvent *)e; |
171 | 171 | ||
172 | if ( (k->key() == Qt::Key_Prior) || | 172 | if ( (k->key() == Qt::Key_Prior) || |
173 | (k->key() == Qt::Key_Next) || | 173 | (k->key() == Qt::Key_Next) || |
174 | (k->key() == Qt::Key_Up) || | 174 | (k->key() == Qt::Key_Up) || |
175 | (k->key() == Qt::Key_Down) ) | 175 | (k->key() == Qt::Key_Down) ) |
176 | { | 176 | { |
177 | QApplication::sendEvent( table, e ); | 177 | QApplication::sendEvent( table, e ); |
178 | table->setFocus(); | 178 | table->setFocus(); |
179 | return true; // eat event | 179 | return true; // eat event |
180 | } | 180 | } |
181 | } | 181 | } |
182 | return QFrame::eventFilter( o, e ); | 182 | return QFrame::eventFilter( o, e ); |
183 | } | 183 | } |
184 | 184 | ||
185 | void | 185 | void |
186 | KDatePicker::resizeEvent(QResizeEvent* e) | 186 | KDatePicker::resizeEvent(QResizeEvent* e) |
187 | { | 187 | { |
188 | QWidget::resizeEvent(e); | 188 | QWidget::resizeEvent(e); |
189 | } | 189 | } |
190 | 190 | ||
191 | void | 191 | void |
192 | KDatePicker::dateChangedSlot(QDate date) | 192 | KDatePicker::dateChangedSlot(QDate date) |
193 | { | 193 | { |
194 | kdDebug(298) << "KDatePicker::dateChangedSlot: date changed (" << date.year() << "/" << date.month() << "/" << date.day() << ")." << endl; | 194 | kdDebug(298) << "KDatePicker::dateChangedSlot: date changed (" << date.year() << "/" << date.month() << "/" << date.day() << ")." << endl; |
195 | 195 | ||
196 | const KCalendarSystem * calendar = KGlobal::locale()->calendar(); | 196 | const KCalendarSystem * calendar = KGlobal::locale()->calendar(); |
197 | 197 | ||
198 | line->setText(KGlobal::locale()->formatDate(date, true)); | 198 | line->setText(KGlobal::locale()->formatDate(date, true)); |
199 | selectMonth->setText(calendar->monthName(date, false)); | 199 | selectMonth->setText(calendar->monthName(date, false)); |
200 | fillWeeksCombo(date); | 200 | fillWeeksCombo(date); |
201 | d->selectWeek->setCurrentItem(calendar->weekNumber(date) - 1); | 201 | d->selectWeek->setCurrentItem(calendar->weekNumber(date) - 1); |
202 | selectYear->setText(calendar->yearString(date, false)); | 202 | selectYear->setText(calendar->yearString(date, false)); |
203 | 203 | ||
204 | emit(dateChanged(date)); | 204 | emit(dateChanged(date)); |
205 | } | 205 | } |
206 | 206 | ||
207 | void | 207 | void |
208 | KDatePicker::tableClickedSlot() | 208 | KDatePicker::tableClickedSlot() |
209 | { | 209 | { |
210 | kdDebug(298) << "KDatePicker::tableClickedSlot: table clicked." << endl; | 210 | kdDebug(298) << "KDatePicker::tableClickedSlot: table clicked." << endl; |
211 | emit(dateSelected(table->getDate())); | 211 | emit(dateSelected(table->getDate())); |
212 | emit(tableClicked()); | 212 | emit(tableClicked()); |
213 | } | 213 | } |
214 | 214 | ||
215 | const QDate& | 215 | const QDate& |
216 | KDatePicker::getDate() const | 216 | KDatePicker::getDate() const |
217 | { | 217 | { |
218 | return table->getDate(); | 218 | return table->getDate(); |
219 | } | 219 | } |
220 | 220 | ||
221 | const QDate & | 221 | const QDate & |
222 | KDatePicker::date() const | 222 | KDatePicker::date() const |
223 | { | 223 | { |
224 | return table->getDate(); | 224 | return table->getDate(); |
225 | } | 225 | } |
226 | 226 | ||
227 | bool | 227 | bool |
228 | KDatePicker::setDate(const QDate& date) | 228 | KDatePicker::setDate(const QDate& date) |
229 | { | 229 | { |
230 | if(date.isValid()) | 230 | if(date.isValid()) |
231 | { | 231 | { |
232 | const KCalendarSystem * calendar = KGlobal::locale()->calendar(); | 232 | const KCalendarSystem * calendar = KGlobal::locale()->calendar(); |
233 | 233 | ||
234 | table->setDate(date); | 234 | table->setDate(date); |
235 | fillWeeksCombo(date); | 235 | fillWeeksCombo(date); |
236 | d->selectWeek->setCurrentItem(calendar->weekNumber(date) - 1); | 236 | d->selectWeek->setCurrentItem(calendar->weekNumber(date) - 1); |
237 | selectMonth->setText(calendar->monthName(date, false)); | 237 | selectMonth->setText(calendar->monthName(date, false)); |
238 | selectYear->setText(calendar->yearString(date, true)); | 238 | selectYear->setText(calendar->yearString(date, true)); |
239 | line->setText(KGlobal::locale()->formatDate(date, true)); | 239 | line->setText(KGlobal::locale()->formatDate(date, true)); |
240 | return true; | 240 | return true; |
241 | } | 241 | } |
242 | else | 242 | else |
243 | { | 243 | { |
244 | kdDebug(298) << "KDatePicker::setDate: refusing to set invalid date." << endl; | 244 | kdDebug(298) << "KDatePicker::setDate: refusing to set invalid date." << endl; |
245 | return false; | 245 | return false; |
246 | } | 246 | } |
247 | } | 247 | } |
248 | 248 | ||
249 | void | 249 | void |
250 | KDatePicker::monthForwardClicked() | 250 | KDatePicker::monthForwardClicked() |
251 | { | 251 | { |
252 | QDate temp; | 252 | QDate temp; |
253 | temp = KGlobal::locale()->calendar()->addMonths( table->getDate(), 1 ); | 253 | temp = KGlobal::locale()->calendar()->addMonths( table->getDate(), 1 ); |
254 | 254 | ||
255 | setDate( temp ); | 255 | setDate( temp ); |
256 | } | 256 | } |
257 | 257 | ||
258 | void | 258 | void |
259 | KDatePicker::monthBackwardClicked() | 259 | KDatePicker::monthBackwardClicked() |
260 | { | 260 | { |
261 | QDate temp; | 261 | QDate temp; |
262 | temp = KGlobal::locale()->calendar()->addMonths( table->getDate(), -1 ); | 262 | temp = KGlobal::locale()->calendar()->addMonths( table->getDate(), -1 ); |
263 | 263 | ||
264 | setDate( temp ); | 264 | setDate( temp ); |
265 | } | 265 | } |
266 | 266 | ||
267 | void | 267 | void |
268 | KDatePicker::yearForwardClicked() | 268 | KDatePicker::yearForwardClicked() |
269 | { | 269 | { |
270 | QDate temp; | 270 | QDate temp; |
271 | temp = KGlobal::locale()->calendar()->addYears( table->getDate(), 1 ); | 271 | temp = KGlobal::locale()->calendar()->addYears( table->getDate(), 1 ); |
272 | 272 | ||
273 | setDate( temp ); | 273 | setDate( temp ); |
274 | } | 274 | } |
275 | 275 | ||
276 | void | 276 | void |
277 | KDatePicker::yearBackwardClicked() | 277 | KDatePicker::yearBackwardClicked() |
278 | { | 278 | { |
279 | QDate temp; | 279 | QDate temp; |
280 | temp = KGlobal::locale()->calendar()->addYears( table->getDate(), -1 ); | 280 | temp = KGlobal::locale()->calendar()->addYears( table->getDate(), -1 ); |
281 | 281 | ||
282 | setDate( temp ); | 282 | setDate( temp ); |
283 | } | 283 | } |
284 | 284 | ||
285 | void KDatePicker::selectWeekClicked() {} // ### in 3.2 obsolete; kept for binary compatibility | 285 | void KDatePicker::selectWeekClicked() {} // ### in 3.2 obsolete; kept for binary compatibility |
286 | 286 | ||
287 | void | 287 | void |
288 | KDatePicker::weekSelected(int week) | 288 | KDatePicker::weekSelected(int week) |
289 | { | 289 | { |
290 | week++; // week number starts with 1 | 290 | week++; // week number starts with 1 |
291 | 291 | ||
292 | const KCalendarSystem * calendar = KGlobal::locale()->calendar(); | 292 | const KCalendarSystem * calendar = KGlobal::locale()->calendar(); |
293 | 293 | ||
294 | QDate date = table->getDate(); | 294 | QDate date = table->getDate(); |
295 | int year = calendar->year(date); | 295 | int year = calendar->year(date); |
296 | 296 | ||
297 | calendar->setYMD(date, year, 1, 1); | 297 | calendar->setYMD(date, year, 1, 1); |
298 | date = calendar->addDays(date, -7); | 298 | date = calendar->addDays(date, -7); |
299 | while (calendar->weekNumber(date) != 1) | 299 | while (calendar->weekNumber(date) != 1) |
300 | date = calendar->addDays(date, 1); | 300 | date = calendar->addDays(date, 1); |
301 | 301 | ||
302 | // date is now first day in week 1 some day in week 1 | 302 | // date is now first day in week 1 some day in week 1 |
303 | date = calendar->addDays(date, (week - calendar->weekNumber(date)) * 7); | 303 | date = calendar->addDays(date, (week - calendar->weekNumber(date)) * 7); |
304 | 304 | ||
305 | setDate(date); | 305 | setDate(date); |
306 | } | 306 | } |
307 | 307 | ||
308 | void | 308 | void |
309 | KDatePicker::selectMonthClicked() | 309 | KDatePicker::selectMonthClicked() |
310 | { | 310 | { |
311 | // every year can have different month names (in some calendar systems) | 311 | // every year can have different month names (in some calendar systems) |
312 | const KCalendarSystem * calendar = KGlobal::locale()->calendar(); | 312 | const KCalendarSystem * calendar = KGlobal::locale()->calendar(); |
313 | QDate date = table->getDate(); | 313 | QDate date = table->getDate(); |
314 | int i, month, months = calendar->monthsInYear(date); | 314 | int i, month, months = calendar->monthsInYear(date); |
315 | 315 | ||
316 | QPopupMenu popup(selectMonth); | 316 | Q3PopupMenu popup(selectMonth); |
317 | 317 | ||
318 | for (i = 1; i <= months; i++) | 318 | for (i = 1; i <= months; i++) |
319 | popup.insertItem(calendar->monthName(i, calendar->year(date)), i); | 319 | popup.insertItem(calendar->monthName(i, calendar->year(date)), i); |
320 | 320 | ||
321 | popup.setActiveItem(calendar->month(date) - 1); | 321 | popup.setActiveItem(calendar->month(date) - 1); |
322 | 322 | ||
323 | if ( (month = popup.exec(selectMonth->mapToGlobal(QPoint(0, 0)), calendar->month(date) - 1)) == -1 ) return; // canceled | 323 | if ( (month = popup.exec(selectMonth->mapToGlobal(QPoint(0, 0)), calendar->month(date) - 1)) == -1 ) return; // canceled |
324 | 324 | ||
325 | int day = calendar->day(date); | 325 | int day = calendar->day(date); |
326 | // ----- construct a valid date in this month: | 326 | // ----- construct a valid date in this month: |
327 | //date.setYMD(date.year(), month, 1); | 327 | //date.setYMD(date.year(), month, 1); |
328 | //date.setYMD(date.year(), month, QMIN(day, date.daysInMonth())); | 328 | //date.setYMD(date.year(), month, QMIN(day, date.daysInMonth())); |
329 | calendar->setYMD(date, calendar->year(date), month, | 329 | calendar->setYMD(date, calendar->year(date), month, |
330 | QMIN(day, calendar->daysInMonth(date))); | 330 | QMIN(day, calendar->daysInMonth(date))); |
331 | // ----- set this month | 331 | // ----- set this month |
332 | setDate(date); | 332 | setDate(date); |
333 | } | 333 | } |
334 | 334 | ||
335 | void | 335 | void |
336 | KDatePicker::selectYearClicked() | 336 | KDatePicker::selectYearClicked() |
337 | { | 337 | { |
338 | const KCalendarSystem * calendar = KGlobal::locale()->calendar(); | 338 | const KCalendarSystem * calendar = KGlobal::locale()->calendar(); |
339 | 339 | ||
340 | int year; | 340 | int year; |
341 | KPopupFrame* popup = new KPopupFrame(this); | 341 | KPopupFrame* popup = new KPopupFrame(this); |
342 | KDateInternalYearSelector* picker = new KDateInternalYearSelector(popup); | 342 | KDateInternalYearSelector* picker = new KDateInternalYearSelector(popup); |
343 | // ----- | 343 | // ----- |
344 | picker->resize(picker->sizeHint()); | 344 | picker->resize(picker->sizeHint()); |
345 | popup->setMainWidget(picker); | 345 | popup->setMainWidget(picker); |
346 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); | 346 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); |
347 | picker->setFocus(); | 347 | picker->setFocus(); |
348 | if(popup->exec(selectYear->mapToGlobal(QPoint(0, selectMonth->height())))) | 348 | if(popup->exec(selectYear->mapToGlobal(QPoint(0, selectMonth->height())))) |
349 | { | 349 | { |
350 | QDate date; | 350 | QDate date; |
351 | int day; | 351 | int day; |
352 | // ----- | 352 | // ----- |
353 | year=picker->getYear(); | 353 | year=picker->getYear(); |
354 | date=table->getDate(); | 354 | date=table->getDate(); |
355 | day=calendar->day(date); | 355 | day=calendar->day(date); |
356 | // ----- construct a valid date in this month: | 356 | // ----- construct a valid date in this month: |
357 | //date.setYMD(year, date.month(), 1); | 357 | //date.setYMD(year, date.month(), 1); |
358 | //date.setYMD(year, date.month(), QMIN(day, date.daysInMonth())); | 358 | //date.setYMD(year, date.month(), QMIN(day, date.daysInMonth())); |
359 | calendar->setYMD(date, year, calendar->month(date), | 359 | calendar->setYMD(date, year, calendar->month(date), |
360 | QMIN(day, calendar->daysInMonth(date))); | 360 | QMIN(day, calendar->daysInMonth(date))); |
361 | // ----- set this month | 361 | // ----- set this month |
362 | setDate(date); | 362 | setDate(date); |
363 | } else { | 363 | } else { |
364 | KNotifyClient::beep(); | 364 | KNotifyClient::beep(); |
365 | } | 365 | } |
366 | delete popup; | 366 | delete popup; |
367 | } | 367 | } |
368 | 368 | ||
369 | void | 369 | void |
370 | KDatePicker::setEnabled(bool enable) | 370 | KDatePicker::setEnabled(bool enable) |
371 | { | 371 | { |
372 | QWidget *widgets[]= { | 372 | QWidget *widgets[]= { |
373 | yearForward, yearBackward, monthForward, monthBackward, | 373 | yearForward, yearBackward, monthForward, monthBackward, |
374 | selectMonth, selectYear, | 374 | selectMonth, selectYear, |
375 | line, table, d->selectWeek, d->todayButton }; | 375 | line, table, d->selectWeek, d->todayButton }; |
376 | const int Size=sizeof(widgets)/sizeof(widgets[0]); | 376 | const int Size=sizeof(widgets)/sizeof(widgets[0]); |
377 | int count; | 377 | int count; |
378 | // ----- | 378 | // ----- |
379 | for(count=0; count<Size; ++count) | 379 | for(count=0; count<Size; ++count) |
380 | { | 380 | { |
381 | widgets[count]->setEnabled(enable); | 381 | widgets[count]->setEnabled(enable); |
382 | } | 382 | } |
383 | } | 383 | } |
384 | 384 | ||
385 | void | 385 | void |
386 | KDatePicker::lineEnterPressed() | 386 | KDatePicker::lineEnterPressed() |
387 | { | 387 | { |
388 | QDate temp; | 388 | QDate temp; |
389 | // ----- | 389 | // ----- |
390 | if(val->date(line->text(), temp)==QValidator::Acceptable) | 390 | if(val->date(line->text(), temp)==QValidator::Acceptable) |
391 | { | 391 | { |
392 | kdDebug(298) << "KDatePicker::lineEnterPressed: valid date entered." << endl; | 392 | kdDebug(298) << "KDatePicker::lineEnterPressed: valid date entered." << endl; |
393 | emit(dateEntered(temp)); | 393 | emit(dateEntered(temp)); |
394 | setDate(temp); | 394 | setDate(temp); |
395 | } else { | 395 | } else { |
396 | KNotifyClient::beep(); | 396 | KNotifyClient::beep(); |
397 | kdDebug(298) << "KDatePicker::lineEnterPressed: invalid date entered." << endl; | 397 | kdDebug(298) << "KDatePicker::lineEnterPressed: invalid date entered." << endl; |
398 | } | 398 | } |
399 | } | 399 | } |
400 | 400 | ||
401 | void | 401 | void |
402 | KDatePicker::todayButtonClicked() | 402 | KDatePicker::todayButtonClicked() |
403 | { | 403 | { |
404 | setDate(QDate::currentDate()); | 404 | setDate(QDate::currentDate()); |
405 | } | 405 | } |
406 | 406 | ||
407 | QSize | 407 | QSize |
408 | KDatePicker::sizeHint() const | 408 | KDatePicker::sizeHint() const |
409 | { | 409 | { |
410 | return QWidget::sizeHint(); | 410 | return QWidget::sizeHint(); |
411 | } | 411 | } |
412 | 412 | ||
413 | void | 413 | void |
414 | KDatePicker::setFontSize(int s) | 414 | KDatePicker::setFontSize(int s) |
415 | { | 415 | { |
416 | QWidget *buttons[]= { | 416 | QWidget *buttons[]= { |
417 | // yearBackward, | 417 | // yearBackward, |
418 | // monthBackward, | 418 | // monthBackward, |
419 | selectMonth, | 419 | selectMonth, |
420 | selectYear, | 420 | selectYear, |
421 | // monthForward, | 421 | // monthForward, |
422 | // yearForward | 422 | // yearForward |
423 | }; | 423 | }; |
424 | const int NoOfButtons=sizeof(buttons)/sizeof(buttons[0]); | 424 | const int NoOfButtons=sizeof(buttons)/sizeof(buttons[0]); |
425 | int count; | 425 | int count; |
426 | QFont font; | 426 | QFont font; |
427 | QRect r; | 427 | QRect r; |
428 | // ----- | 428 | // ----- |
429 | fontsize=s; | 429 | fontsize=s; |
430 | for(count=0; count<NoOfButtons; ++count) | 430 | for(count=0; count<NoOfButtons; ++count) |
431 | { | 431 | { |
432 | font=buttons[count]->font(); | 432 | font=buttons[count]->font(); |
433 | font.setPointSize(s); | 433 | font.setPointSize(s); |
434 | buttons[count]->setFont(font); | 434 | buttons[count]->setFont(font); |
435 | } | 435 | } |
436 | QFontMetrics metrics(selectMonth->fontMetrics()); | 436 | QFontMetrics metrics(selectMonth->fontMetrics()); |
437 | 437 | ||
438 | for (int i = 1; ; ++i) | 438 | for (int i = 1; ; ++i) |
439 | { | 439 | { |
440 | QString str = KGlobal::locale()->calendar()->monthName(i, | 440 | QString str = KGlobal::locale()->calendar()->monthName(i, |
441 | KGlobal::locale()->calendar()->year(table->getDate()), false); | 441 | KGlobal::locale()->calendar()->year(table->getDate()), false); |
442 | if (str.isNull()) break; | 442 | if (str.isNull()) break; |
443 | r=metrics.boundingRect(str); | 443 | r=metrics.boundingRect(str); |
444 | maxMonthRect.setWidth(QMAX(r.width(), maxMonthRect.width())); | 444 | maxMonthRect.setWidth(QMAX(r.width(), maxMonthRect.width())); |
445 | maxMonthRect.setHeight(QMAX(r.height(), maxMonthRect.height())); | 445 | maxMonthRect.setHeight(QMAX(r.height(), maxMonthRect.height())); |
446 | } | 446 | } |
447 | 447 | ||
448 | QSize metricBound = style().sizeFromContents(QStyle::CT_ToolButton, | 448 | QSize metricBound = style().sizeFromContents(QStyle::CT_ToolButton, |
449 | selectMonth, | 449 | selectMonth, |
450 | maxMonthRect); | 450 | maxMonthRect); |
451 | selectMonth->setMinimumSize(metricBound); | 451 | selectMonth->setMinimumSize(metricBound); |
452 | 452 | ||
453 | table->setFontSize(s); | 453 | table->setFontSize(s); |
454 | } | 454 | } |
455 | 455 | ||
456 | void | 456 | void |
457 | KDatePicker::setCloseButton( bool enable ) | 457 | KDatePicker::setCloseButton( bool enable ) |
458 | { | 458 | { |
459 | if ( enable == (d->closeButton != 0L) ) | 459 | if ( enable == (d->closeButton != 0L) ) |
460 | return; | 460 | return; |
461 | 461 | ||
462 | if ( enable ) { | 462 | if ( enable ) { |
463 | d->closeButton = new QToolButton( d->tb ); | 463 | d->closeButton = new QToolButton( d->tb ); |
464 | d->navigationLayout->addWidget(d->closeButton); | 464 | d->navigationLayout->addWidget(d->closeButton); |
465 | QToolTip::add(d->closeButton, i18n("Close")); | 465 | QToolTip::add(d->closeButton, i18n("Close")); |
466 | d->closeButton->setPixmap( SmallIcon("remove") ); | 466 | d->closeButton->setPixmap( SmallIcon("remove") ); |
467 | connect( d->closeButton, SIGNAL( clicked() ), | 467 | connect( d->closeButton, SIGNAL( clicked() ), |
468 | topLevelWidget(), SLOT( close() ) ); | 468 | topLevelWidget(), SLOT( close() ) ); |
469 | } | 469 | } |
470 | else { | 470 | else { |
471 | delete d->closeButton; | 471 | delete d->closeButton; |
472 | d->closeButton = 0L; | 472 | d->closeButton = 0L; |
473 | } | 473 | } |
474 | 474 | ||
475 | updateGeometry(); | 475 | updateGeometry(); |
476 | } | 476 | } |
477 | 477 | ||
478 | bool KDatePicker::hasCloseButton() const | 478 | bool KDatePicker::hasCloseButton() const |
479 | { | 479 | { |
480 | return (d->closeButton != 0L); | 480 | return (d->closeButton != 0L); |
481 | } | 481 | } |
482 | 482 | ||
483 | void KDatePicker::virtual_hook( int /*id*/, void* /*data*/ ) | 483 | void KDatePicker::virtual_hook( int /*id*/, void* /*data*/ ) |
484 | { /*BASE::virtual_hook( id, data );*/ } | 484 | { /*BASE::virtual_hook( id, data );*/ } |
485 | 485 | ||