[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-pim
Subject: [Kde-pim] [PATCH] Make KDateEdit using KDatePickerPopup
From: Bram Schoenmakers <bramschoenmakers () kde ! nl>
Date: 2005-01-31 22:09:38
Message-ID: 200501312309.22437.bramschoenmakers () kde ! nl
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
[Attachment #4 (multipart/mixed)]
Hi,
I attached a patch which makes the KDateEdit use the KDatePickerPopup instead
of a QFrame. The KDatePicker is still at the same place, but now there are
some new entries below it ("Today", "Tomorrow", etc.).
Can I commit this to HEAD? I'd like to commit this before Wednesday 23:59, so
it will be in Beta 2. If no one objects, I'll commit it Wednesday evening.
Kind regards,
--
Bram Schoenmakers
KDE Netherlands (www.kde.nl)
["diff" (text/x-diff)]
Index: kdateedit.h
===================================================================
RCS file: /home/kde/kdepim/libkdepim/kdateedit.h,v
retrieving revision 1.15
diff -B -b -p -u -3 -r1.15 kdateedit.h
--- kdateedit.h 9 Jan 2005 01:23:11 -0000 1.15
+++ kdateedit.h 31 Jan 2005 21:53:25 -0000
@@ -29,10 +29,9 @@
#include <kdepimmacros.h>
-class QEvent;
-class QVBox;
+#include "kdatepickerpopup.h"
-class KDatePicker;
+class QEvent;
/**
A date editing widget that consists of an editable combo box.
@@ -115,8 +114,7 @@ class KDE_EXPORT KDateEdit : public QCom
void updateView();
void assignDate( const QDate& );
- KDatePicker *mDatePicker;
- QVBox *mDateFrame;
+ KDatePickerPopup *mPopup;
QDate mDate;
bool mReadOnly;
Index: kdateedit.cpp
===================================================================
RCS file: /home/kde/kdepim/libkdepim/kdateedit.cpp,v
retrieving revision 1.35
diff -B -b -p -u -3 -r1.35 kdateedit.cpp
--- kdateedit.cpp 31 Jan 2005 11:12:32 -0000 1.35
+++ kdateedit.cpp 31 Jan 2005 21:53:25 -0000
@@ -25,10 +25,8 @@
#include <qlineedit.h>
#include <qlistbox.h>
#include <qvalidator.h>
-#include <qvbox.h>
#include <kcalendarsystem.h>
-#include <kdatepicker.h>
#include <kglobal.h>
#include <kglobalsettings.h>
#include <klocale.h>
@@ -81,22 +79,15 @@ KDateEdit::KDateEdit( QWidget *parent, c
changeItem( today, 0 );
setMinimumSize( sizeHint() );
- mDateFrame = new QVBox( 0, 0, WType_Popup );
- mDateFrame->setFrameStyle( QFrame::PopupPanel | QFrame::Raised );
- mDateFrame->setLineWidth( 3 );
- mDateFrame->hide();
- mDateFrame->installEventFilter( this );
-
- mDatePicker = new KDatePicker( mDateFrame, mDate );
-
connect( lineEdit(), SIGNAL( returnPressed() ),
this, SLOT( lineEnterPressed() ) );
connect( this, SIGNAL( textChanged( const QString& ) ),
SLOT( slotTextChanged( const QString& ) ) );
- connect( mDatePicker, SIGNAL( dateEntered( QDate ) ),
- SLOT( dateEntered( QDate ) ) );
- connect( mDatePicker, SIGNAL( dateSelected( QDate ) ),
+ mPopup = new KDatePickerPopup( KDatePickerPopup::DatePicker | KDatePickerPopup::Words );
+ mPopup->hide();
+
+ connect( mPopup, SIGNAL( dateChanged( QDate ) ),
SLOT( dateSelected( QDate ) ) );
// handle keyword entry
@@ -110,8 +101,8 @@ KDateEdit::KDateEdit( QWidget *parent, c
KDateEdit::~KDateEdit()
{
- delete mDateFrame;
- mDateFrame = 0;
+ delete mPopup;
+ mPopup = 0;
}
void KDateEdit::setDate( const QDate& date )
@@ -145,13 +136,13 @@ void KDateEdit::popup()
QPoint popupPoint = mapToGlobal( QPoint( 0,0 ) );
- int dateFrameHeight = mDateFrame->sizeHint().height();
+ int dateFrameHeight = mPopup->sizeHint().height();
if ( popupPoint.y() + height() + dateFrameHeight > desk.bottom() )
popupPoint.setY( popupPoint.y() - dateFrameHeight );
else
popupPoint.setY( popupPoint.y() + height() );
- int dateFrameWidth = mDateFrame->sizeHint().width();
+ int dateFrameWidth = mPopup->sizeHint().width();
if ( popupPoint.x() + dateFrameWidth > desk.right() )
popupPoint.setX( desk.right() - dateFrameWidth );
@@ -161,14 +152,12 @@ void KDateEdit::popup()
if ( popupPoint.y() < desk.top() )
popupPoint.setY( desk.top() );
- mDateFrame->move( popupPoint );
-
if ( mDate.isValid() )
- mDatePicker->setDate( mDate );
+ mPopup->setDate( mDate );
else
- mDatePicker->setDate( QDate::currentDate() );
+ mPopup->setDate( QDate::currentDate() );
- mDateFrame->show();
+ mPopup->popup( popupPoint );
}
void KDateEdit::dateSelected( QDate date )
@@ -178,7 +167,7 @@ void KDateEdit::dateSelected( QDate date
emit dateChanged( date );
if ( date.isValid() ) {
- mDateFrame->hide();
+ mPopup->hide();
// The combo box is now shown pressed. Make it show not pressed again
// by causing its (invisible) list box to emit a 'selected' signal.
@@ -289,8 +279,8 @@ bool KDateEdit::eventFilter( QObject *ob
case QEvent::MouseButtonDblClick:
case QEvent::MouseButtonPress: {
QMouseEvent *mouseEvent = (QMouseEvent*)event;
- if ( !mDateFrame->rect().contains( mouseEvent->pos() ) ) {
- QPoint globalPos = mDateFrame->mapToGlobal( mouseEvent->pos() );
+ if ( !mPopup->rect().contains( mouseEvent->pos() ) ) {
+ QPoint globalPos = mPopup->mapToGlobal( mouseEvent->pos() );
if ( QApplication::widgetAt( globalPos, true ) == this ) {
// The date picker is being closed by a click on the
// KDateEdit widget. Avoid popping it up again immediately.
[Attachment #8 (application/pgp-signature)]
_______________________________________________
kde-pim mailing list
kde-pim@kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
kde-pim home page at http://pim.kde.org/
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic