[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: [Patch] #48264: added a Today button in kdatepicker
From:       Martin Koller <m.koller () surfeu ! at>
Date:       2003-08-26 21:03:39
[Download RAW message or body]

-----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 become 
obsolete: KDateInternalWeekSelector and KDateInternalMonthPicker

The patch removes these two classes.
- -- 
Best regards/Schöne Grüße

Martin

Public key at:
http://blackhole.pca.dfn.de:11371/pks/lookup?op=get&search=0x8DFB0F86
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE/S8srHmdPoI37D4YRAjs6AJ9QsolMIu/2vJBFmg7Hu9PwIp4OsgCggcSZ
nZbcFuYLzCBqSPEs9poCDwY=
=bJ8t
-----END PGP SIGNATURE-----

["datepick.patch" (text/x-diff)]

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()<rect.width()) max.setWidth(rect.width());
-      if(max.height()<rect.height()) max.setHeight(rect.height());
-    }
-}
-
-QSize
-KDateInternalMonthPicker::sizeHint() const
-{
-  return QSize((max.width()+6)*numCols()+2*frameWidth(),
-         (max.height()+6)*numRows()+2*frameWidth());
-}
-
-int
-KDateInternalMonthPicker::getResult() const
-{
-  return result;
-}
-
-void
-KDateInternalMonthPicker::setupPainter(QPainter *p)
-{
-  p->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 $


>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic