--Boundary-00=_ojPP/z4gtJsw10D Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Description: clearsigned data Content-Disposition: inline =2D----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Thursday 14 August 2003 23:45, Aaron J. Seigo wrote: > On Thursday 14 August 2003 02:35, Martin Koller wrote: > > General question: What is the policy regarding modification of the API > > from 3.1 to 3.2 ? > > http://developer.kde.org/documentation/library/kdeqt/kde3arch/devel- > binarycompatibility.html Thanks. > > > In this case I would change a protected slot (e.g. selectWeekClicked()) > > to selectWeekClicked(const QString &) > > Or shall I (to be code compatible) leave the old slot, which then does > > nothing ? > > hrm... well, personally i wouldn't use a KComboBox, i'd keep it a > pushbutton and simply add a popup to it using setPopup(QPopup*)... > comboboxes tend to take up more space; the button is a good UI element > IMHO, it just needs a popup menu rather than a popup lineedit... > > regardless, the existing slot needs to remain. perhaps it would be best if > it were called prior to showing the menu (e.g. aboutToShow()) in case > someone has subclassed it and reimplemented the slot to do some > pre-processing? of course, if anyone has subclassed it and reimplemented > the slot without calling the parent's implementation (in order to do their > own selection stuff), then that would be problematic, i suppose. > perhaps one way to do it would be to connect QPushButton::aboutToShow() to > selectWeekClicked() and set up the menu in there? The slot is not virtual. So I leave it as an empty function. Here is the patch which includes: 1) Added the Today Button with the today icon (without autoraise) 2) Changed the week selection to a QComboBox (without autoraise) 3) Changed the month selection to a standard popup menu I'll leave the year selection for now as it is. Maybe I find time to change this also. If OK, please commit. Thanks =2D --=20 Best regards/Sch=F6ne Gr=FC=DFe Martin Public key at: http://blackhole.pca.dfn.de:11371/pks/lookup?op=3Dget&search=3D0x8DFB0F86 =2D----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE/PPjoHmdPoI37D4YRAjSuAKCCaW8l5aGpJ3WRuRqZUHsZmfuVvQCfX1RD 29rkTvqc0x24mwnWB5QrBqY=3D =3D3oEA =2D----END PGP SIGNATURE----- --Boundary-00=_ojPP/z4gtJsw10D Content-Type: application/octet-stream; name="patch.2" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="patch.2" Index: kdatepicker.cpp =================================================================== RCS file: /home/kde/kdelibs/kdeui/kdatepicker.cpp,v retrieving revision 1.60 diff -u -3 -p -r1.60 kdatepicker.cpp --- kdatepicker.cpp 17 Jul 2003 21:02:04 -0000 1.60 +++ kdatepicker.cpp 15 Aug 2003 15:07:09 -0000 @@ -24,9 +24,11 @@ #include #include #include +#include #include #include #include +#include #include "kdatepicker.h" #include @@ -45,14 +47,30 @@ class KDatePicker::KDatePickerPrivate { public: - KDatePickerPrivate() : closeButton(0L), selectWeek(0L), navigationLayout(0) {} + KDatePickerPrivate() : closeButton(0L), selectWeek(0L), todayButton(0), navigationLayout(0) {} + + void fillWeeksCombo(const QDate &date); KToolBar *tb; QToolButton *closeButton; - QToolButton *selectWeek; + QComboBox *selectWeek; + QToolButton *todayButton; QBoxLayout *navigationLayout; }; +void KDatePicker::KDatePickerPrivate::fillWeeksCombo(const QDate &date) +{ + // every year can have a different number of weeks + const KCalendarSystem * calendar = KGlobal::locale()->calendar(); + int i, weeks = calendar->weeksInYear(calendar->year(date)); + + if ( selectWeek->count() == weeks ) return; // we already have the correct number + + selectWeek->clear(); + + for (i = 1; i <= weeks; i++) + selectWeek->insertItem(i18n("Week %1").arg(i)); +} KDatePicker::KDatePicker(QWidget *parent, QDate dt, const char *name) : QFrame(parent,name) @@ -93,8 +111,9 @@ void KDatePicker::init( const QDate &dt fontsize++; // Make a little bigger - d->selectWeek = new QToolButton( this ); - d->selectWeek->setAutoRaise(true); + d->selectWeek = new QComboBox(false, this); // read only week selection + d->todayButton = new QToolButton(this); + d->todayButton->setPixmap(SmallIcon("today")); QToolTip::add(yearForward, i18n("Next year")); QToolTip::add(yearBackward, i18n("Previous year")); @@ -103,6 +122,7 @@ void KDatePicker::init( const QDate &dt QToolTip::add(d->selectWeek, i18n("Select a week")); QToolTip::add(selectMonth, i18n("Select a month")); QToolTip::add(selectYear, i18n("Select a year")); + QToolTip::add(d->todayButton, i18n("Select the current day")); // ----- setFontSize(fontsize); @@ -119,7 +139,8 @@ void KDatePicker::init( const QDate &dt connect(monthBackward, SIGNAL(clicked()), SLOT(monthBackwardClicked())); connect(yearForward, SIGNAL(clicked()), SLOT(yearForwardClicked())); connect(yearBackward, SIGNAL(clicked()), SLOT(yearBackwardClicked())); - connect(d->selectWeek, SIGNAL(clicked()), SLOT(selectWeekClicked())); + connect(d->selectWeek, SIGNAL(activated(int)), SLOT(weekSelected(int))); + connect(d->todayButton, SIGNAL(clicked()), SLOT(todayButtonClicked())); connect(selectMonth, SIGNAL(clicked()), SLOT(selectMonthClicked())); connect(selectYear, SIGNAL(clicked()), SLOT(selectYearClicked())); connect(line, SIGNAL(returnPressed()), SLOT(lineEnterPressed())); @@ -133,6 +154,7 @@ void KDatePicker::init( const QDate &dt topLayout->addWidget(table); QBoxLayout * bottomLayout = new QHBoxLayout(topLayout); + bottomLayout->addWidget(d->todayButton); bottomLayout->addWidget(line); bottomLayout->addWidget(d->selectWeek); } @@ -175,8 +197,9 @@ KDatePicker::dateChangedSlot(QDate date) const KCalendarSystem * calendar = KGlobal::locale()->calendar(); line->setText(KGlobal::locale()->formatDate(date, true)); - d->selectWeek->setText(i18n("Week %1").arg(calendar->weekNumber(date))); selectMonth->setText(calendar->monthName(date, false)); + d->fillWeeksCombo(date); + d->selectWeek->setCurrentItem(calendar->weekNumber(date) - 1); selectYear->setText(QString().setNum(calendar->year(date))); emit(dateChanged(date)); @@ -211,8 +234,9 @@ KDatePicker::setDate(const QDate& date) QString temp; // ----- table->setDate(date); - d->selectWeek->setText(i18n("Week %1").arg(calendar->weekNumber(date))); - selectMonth->setText(calendar->monthName(date, false)); + selectMonth->setText(calendar->monthName(date, false)); + d->fillWeeksCombo(date); + d->selectWeek->setCurrentItem(calendar->weekNumber(date) - 1); temp.setNum(calendar->year(date)); selectYear->setText(temp); line->setText(KGlobal::locale()->formatDate(date, true)); @@ -259,75 +283,55 @@ KDatePicker::yearBackwardClicked() setDate( temp ); } +void KDatePicker::selectWeekClicked() {} // ### in 3.2 obsolete; kept for binary compatibility + void -KDatePicker::selectWeekClicked() +KDatePicker::weekSelected(int week) { + week++; // week number starts with 1 + const KCalendarSystem * calendar = KGlobal::locale()->calendar(); QDate date = table->getDate(); + int year = calendar->year(date); - KPopupFrame* popup = new KPopupFrame(this); - KDateInternalWeekSelector* picker = new KDateInternalWeekSelector(popup); - picker->setMaxWeek(calendar->weeksInYear(calendar->year(date))); - // ----- - picker->resize(picker->sizeHint()); - popup->setMainWidget(picker); - connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); - picker->setFocus(); - if(popup->exec(d->selectWeek->mapToGlobal(QPoint(0, d->selectWeek->height())))) - { - int week = picker->getWeek(); - int year = calendar->year(date); + calendar->setYMD(date, year, 1, 1); + date = calendar->addDays(date, -7); + while (calendar->weekNumber(date) != 1) + date = calendar->addDays(date, 1); - calendar->setYMD(date, year, 1, 1); - date = calendar->addDays(date, -7); - while (calendar->weekNumber(date) != 1) - date = calendar->addDays(date, 1); + // date is now first day in week 1 some day in week 1 + date = calendar->addDays(date, (week - calendar->weekNumber(date)) * 7); - // date is now first day in week 1 some day in week 1 - date = calendar->addDays(date, (week - calendar->weekNumber(date)) * 7); - - setDate(date); - } - else - { - KNotifyClient::beep(); - } - - delete popup; + setDate(date); } void KDatePicker::selectMonthClicked() { + // every year can have different month names (in some calendar systems) const KCalendarSystem * calendar = KGlobal::locale()->calendar(); + QDate date = table->getDate(); + int i, month, months = calendar->monthsInYear(date); + + QPopupMenu *popup = new QPopupMenu(selectMonth); + + for (i = 1; i <= months; i++) + popup->insertItem(calendar->monthName(i, calendar->year(date)), i); + + popup->setActiveItem(calendar->month(date) - 1); + + if ( (month = popup->exec(selectMonth->mapToGlobal(QPoint(0, 0)), calendar->month(date) - 1)) == -1 ) return; // cancelled + + int day = calendar->day(date); + // ----- construct a valid date in this month: + //date.setYMD(date.year(), month, 1); + //date.setYMD(date.year(), month, QMIN(day, date.daysInMonth())); + calendar->setYMD(date, calendar->year(date), month, + QMIN(day, calendar->daysInMonth(date))); + // ----- set this month + setDate(date); - int month; - KPopupFrame* popup = new KPopupFrame(this); - KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(table->getDate(), popup); - // ----- - picker->resize(picker->sizeHint()); - popup->setMainWidget(picker); - picker->setFocus(); - connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); - if(popup->exec(selectMonth->mapToGlobal(QPoint(0, selectMonth->height())))) - { - QDate date; - int day; - // ----- - month=picker->getResult(); - date=table->getDate(); - day=calendar->day(date); - // ----- construct a valid date in this month: - //date.setYMD(date.year(), month, 1); - //date.setYMD(date.year(), month, QMIN(day, date.daysInMonth())); - calendar->setYMD(date, calendar->year(date), month, - QMIN(day, calendar->daysInMonth(date))); - // ----- set this month - setDate(date); - } else { - KNotifyClient::beep(); - } delete popup; } @@ -395,6 +399,12 @@ KDatePicker::lineEnterPressed() KNotifyClient::beep(); kdDebug(298) << "KDatePicker::lineEnterPressed: invalid date entered." << endl; } +} + +void +KDatePicker::todayButtonClicked() +{ + setDate(QDate::currentDate()); } QSize Index: kdatepicker.h =================================================================== RCS file: /home/kde/kdelibs/kdeui/kdatepicker.h,v retrieving revision 1.34 diff -u -3 -p -r1.34 kdatepicker.h --- kdatepicker.h 15 Feb 2003 03:14:01 -0000 1.34 +++ kdatepicker.h 15 Aug 2003 15:07:09 -0000 @@ -184,10 +184,14 @@ protected slots: void yearForwardClicked(); void yearBackwardClicked(); /// @since 3.1 - void selectWeekClicked(); + void selectWeekClicked(); // ### in 3.2 obsolete; kept for binary compatibility void selectMonthClicked(); void selectYearClicked(); void lineEnterPressed(); + /// @since 3.2 + void todayButtonClicked(); + void weekSelected(int); + signals: /** This signal is emitted each time the selected date is changed. * Usually, this does not mean that the date has been entered, --Boundary-00=_ojPP/z4gtJsw10D Content-Type: image/png; name="today.png" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="today.png" iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAZiS0dE AEQARQBFJNe/wgAAAAlwSFlzAAALEAAACxABrSO9dQAAAAd0SU1FB9ELFw0zB81/WN0AAAG1SURB VHicrZM/aFNRFMZ/777ra8FApUNG6aBY7B4CxWAJmEYsKgT/wNuLCkJUeApCGoRSXLJ3zuKkg8WI xkUkksWp0EIHyWZH9abv3PLedaiNxNgh6geXj+/COXznOxz4R3gAtVrNjVtYr9c9AKIocnvOjf2i KHIAWkRIxLB4r0Gvr0mCDGgNSoGv8HwffPVT+7h0j+2VG4gIURShDy09e3Kbr3YfI/skyehEvlJM akVm8tjgT0TQsQipNXTevCIIAp6/fMu1q2WMMQRBgLV2hC9cLBOLAKBEhMQa+t+/ca6QB+B1+8NA /4kTaxCRAwcSx9y5+xiA1rsO2WyWRqPhVatVBxs83BQevX+Bm06BDQBSMUgcH6zRuaM3WKlU3MfM POrUSdKdHp9W5mm1uywWc9x68BTA05eWloY6nJiaotlsemEYusvl83Q2hXSnh5tOabW7AwdDGayv LnP9Son11WW+7O4ShqErLeQp5mZYm5uge/80a3MTFHMzAKMZpNYA0O5+BqC0kB/Sv3Nqf2WgYxES 26dw9jgAhfrNIzM5RGL7gxE8gDOzs2PfAuBtb239Rdn/xg+jYxfZNjZyrgAAAABJRU5ErkJggg== --Boundary-00=_ojPP/z4gtJsw10D Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe << --Boundary-00=_ojPP/z4gtJsw10D--