From kde-devel Tue Aug 26 21:03:39 2003 From: Martin Koller Date: Tue, 26 Aug 2003 21:03:39 +0000 To: kde-devel Subject: Re: [Patch] #48264: added a Today button in kdatepicker X-MARC-Message: https://marc.info/?l=kde-devel&m=106193312510745 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--Boundary-00=_rs8S/myQPUx0UA2" --Boundary-00=_rs8S/myQPUx0UA2 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 Saturday 23 August 2003 22:22, Aaron J. Seigo wrote: > On Friday 15 August 2003 09:14, Martin Koller wrote: > > If OK, please commit. > > will be committing today... thanks for the patch! Thanks. As the datepicker now uses some other widgets as before, 2 classes have bec= ome=20 obsolete: KDateInternalWeekSelector and KDateInternalMonthPicker The patch removes these two classes. =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/S8srHmdPoI37D4YRAjs6AJ9QsolMIu/2vJBFmg7Hu9PwIp4OsgCggcSZ nZbcFuYLzCBqSPEs9poCDwY=3D =3DbJ8t =2D----END PGP SIGNATURE----- --Boundary-00=_rs8S/myQPUx0UA2 Content-Type: text/x-diff; charset="iso-8859-1"; name="datepick.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="datepick.patch" Index: kdatetbl.cpp =================================================================== RCS file: /home/kde/kdelibs/kdeui/kdatetbl.cpp,v retrieving revision 1.67 diff -u -3 -p -r1.67 kdatetbl.cpp --- kdatetbl.cpp 24 Aug 2003 15:51:06 -0000 1.67 +++ kdatetbl.cpp 26 Aug 2003 20:58:26 -0000 @@ -549,244 +549,6 @@ void KDateTable::unsetCustomDatePainting d->customPaintingModes.remove( date.toString() ); } -KDateInternalWeekSelector::KDateInternalWeekSelector -(QWidget* parent, const char* name) - : QLineEdit(parent, name), - val(new QIntValidator(this)), - result(0) -{ - QFont font; - // ----- - font=KGlobalSettings::generalFont(); - setFont(font); - setFrameStyle(QFrame::NoFrame); - setValidator(val); - connect(this, SIGNAL(returnPressed()), SLOT(weekEnteredSlot())); -} - -void -KDateInternalWeekSelector::weekEnteredSlot() -{ - bool ok; - int week; - // ----- check if this is a valid week: - week=text().toInt(&ok); - if(!ok) - { - KNotifyClient::beep(); - return; - } - result=week; - emit(closeMe(1)); -} - -int -KDateInternalWeekSelector::getWeek() -{ - return result; -} - -void -KDateInternalWeekSelector::setWeek(int week) -{ - QString temp; - // ----- - temp.setNum(week); - setText(temp); -} - -void -KDateInternalWeekSelector::setMaxWeek(int max) -{ - val->setRange(1, max); -} - -// ### CFM To avoid binary incompatibility. -// In future releases, remove this and replace by a QDate -// private member, needed in KDateInternalMonthPicker::paintCell -class KDateInternalMonthPicker::KDateInternalMonthPrivate { -public: - KDateInternalMonthPrivate (int y, int m, int d) - : year(y), month(m), day(d) - {}; - int year; - int month; - int day; -}; - -KDateInternalMonthPicker::~KDateInternalMonthPicker() { - delete d; -} - -KDateInternalMonthPicker::KDateInternalMonthPicker -(const QDate & date, QWidget* parent, const char* name) - : QGridView(parent, name), - result(0) // invalid -{ - QRect rect; - QFont font; - // ----- - activeCol = -1; - activeRow = -1; - font=KGlobalSettings::generalFont(); - setFont(font); - setHScrollBarMode(AlwaysOff); - setVScrollBarMode(AlwaysOff); - setFrameStyle(QFrame::NoFrame); - setNumCols(3); - d = new KDateInternalMonthPrivate(date.year(), date.month(), date.day()); - // For monthsInYear != 12 - setNumRows( (KGlobal::locale()->calendar()->monthsInYear(date) + 2) / 3); - // enable to find drawing failures: - // setTableFlags(Tbl_clipCellPainting); - viewport()->setEraseColor(KGlobalSettings::baseColor()); // for consistency with the datepicker - // ----- find the preferred size - // (this is slow, possibly, but unfortunately it is needed here): - QFontMetrics metrics(font); - for(int i = 1; ; ++i) - { - QString str = KGlobal::locale()->calendar()->monthName(i, - KGlobal::locale()->calendar()->year(date), false); - if (str.isNull()) break; - rect=metrics.boundingRect(str); - if(max.width()setPen(KGlobalSettings::textColor()); -} - -void -KDateInternalMonthPicker::viewportResizeEvent(QResizeEvent*) -{ - setCellWidth(width() / numCols()); - setCellHeight(height() / numRows()); -} - -void -KDateInternalMonthPicker::paintCell(QPainter* painter, int row, int col) -{ - int index; - QString text; - // ----- find the number of the cell: - index=3*row+col+1; - text=KGlobal::locale()->calendar()->monthName(index, - KGlobal::locale()->calendar()->year(QDate(d->year, d->month, - d->day)), false); - painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text); - if ( activeCol == col && activeRow == row ) - painter->drawRect( 0, 0, cellWidth(), cellHeight() ); -} - -void -KDateInternalMonthPicker::contentsMousePressEvent(QMouseEvent *e) -{ - if(!isEnabled() || e->button() != LeftButton) - { - KNotifyClient::beep(); - return; - } - // ----- - int row, col; - QPoint mouseCoord; - // ----- - mouseCoord = e->pos(); - row=rowAt(mouseCoord.y()); - col=columnAt(mouseCoord.x()); - - if(row<0 || col<0) - { // the user clicked on the frame of the table - activeCol = -1; - activeRow = -1; - } else { - activeCol = col; - activeRow = row; - updateCell( row, col /*, false */ ); - } -} - -void -KDateInternalMonthPicker::contentsMouseMoveEvent(QMouseEvent *e) -{ - if (e->state() & LeftButton) - { - int row, col; - QPoint mouseCoord; - // ----- - mouseCoord = e->pos(); - row=rowAt(mouseCoord.y()); - col=columnAt(mouseCoord.x()); - int tmpRow = -1, tmpCol = -1; - if(row<0 || col<0) - { // the user clicked on the frame of the table - if ( activeCol > -1 ) - { - tmpRow = activeRow; - tmpCol = activeCol; - } - activeCol = -1; - activeRow = -1; - } else { - bool differentCell = (activeRow != row || activeCol != col); - if ( activeCol > -1 && differentCell) - { - tmpRow = activeRow; - tmpCol = activeCol; - } - if ( differentCell) - { - activeRow = row; - activeCol = col; - updateCell( row, col /*, false */ ); // mark the new active cell - } - } - if ( tmpRow > -1 ) // repaint the former active cell - updateCell( tmpRow, tmpCol /*, true */ ); - } -} - -void -KDateInternalMonthPicker::contentsMouseReleaseEvent(QMouseEvent *e) -{ - if(!isEnabled()) - { - return; - } - // ----- - int row, col, pos; - QPoint mouseCoord; - // ----- - mouseCoord = e->pos(); - row=rowAt(mouseCoord.y()); - col=columnAt(mouseCoord.x()); - if(row<0 || col<0) - { // the user clicked on the frame of the table - emit(closeMe(0)); - } - - pos=3*row+col+1; - result=pos; - emit(closeMe(1)); -} - - KDateInternalYearSelector::KDateInternalYearSelector (QWidget* parent, const char* name) Index: kdatetbl.h =================================================================== RCS file: /home/kde/kdelibs/kdeui/kdatetbl.h,v retrieving revision 1.40 diff -u -3 -p -r1.40 kdatetbl.h --- kdatetbl.h 8 Jun 2003 19:58:33 -0000 1.40 +++ kdatetbl.h 26 Aug 2003 20:58:27 -0000 @@ -28,106 +28,6 @@ class KPopupMenu; -/** Week selection widget. -* @internal -* @version $Id: kdatetbl.h,v 1.40 2003/06/08 19:58:33 nhasan Exp $ -* @author Stephan Binner -*/ -class KDateInternalWeekSelector : public QLineEdit -{ - Q_OBJECT -protected: - QIntValidator *val; - int result; -public slots: - void weekEnteredSlot(); - void setMaxWeek(int max); -signals: - void closeMe(int); -public: - KDateInternalWeekSelector( QWidget* parent=0, const char* name=0); - int getWeek(); - void setWeek(int week); - -private: - class KDateInternalWeekPrivate; - KDateInternalWeekPrivate *d; -}; - -/** -* A table containing month names. It is used to pick a month directly. -* @internal -* @version $Id: kdatetbl.h,v 1.40 2003/06/08 19:58:33 nhasan Exp $ -* @author Tim Gilman, Mirko Boehm -*/ -class KDateInternalMonthPicker : public QGridView -{ - Q_OBJECT -protected: - /** - * Store the month that has been clicked [1..12]. - */ - int result; - /** - * the cell under mouse cursor when LBM is pressed - */ - short int activeCol; - short int activeRow; - /** - * Contains the largest rectangle needed by the month names. - */ - QRect max; -signals: - /** - * This is send from the mouse click event handler. - */ - void closeMe(int); -public: - /** - * The constructor. - */ - KDateInternalMonthPicker(const QDate& date, QWidget* parent, const char* name=0); - /** - * The destructor. - */ - ~KDateInternalMonthPicker(); - /** - * The size hint. - */ - QSize sizeHint() const; - /** - * Return the result. 0 means no selection (reject()), 1..12 are the - * months. - */ - int getResult() const; -protected: - /** - * Set up the painter. - */ - void setupPainter(QPainter *p); - /** - * The resize event. - */ - virtual void viewportResizeEvent(QResizeEvent*); - /** - * Paint a cell. This simply draws the month names in it. - */ - virtual void paintCell(QPainter* painter, int row, int col); - /** - * Catch mouse click and move events to paint a rectangle around the item. - */ - virtual void contentsMousePressEvent(QMouseEvent *e); - virtual void contentsMouseMoveEvent(QMouseEvent *e); - /** - * Emit monthSelected(int) when a cell has been released. - */ - virtual void contentsMouseReleaseEvent(QMouseEvent *e); - -private: - class KDateInternalMonthPrivate; - KDateInternalMonthPrivate *d; -}; - /** Year selection widget. * @internal * @version $Id: kdatetbl.h,v 1.40 2003/06/08 19:58:33 nhasan Exp $ --Boundary-00=_rs8S/myQPUx0UA2 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=_rs8S/myQPUx0UA2--