diff --git a/akonadi/contact/editor/dateeditwidget.cpp b/akonadi/contact/editor/dateeditwidget.cpp index c17d2f16a..09f67c2d2 100644 --- a/akonadi/contact/editor/dateeditwidget.cpp +++ b/akonadi/contact/editor/dateeditwidget.cpp @@ -1,118 +1,119 @@ /* This file is part of Akonadi Contact. Copyright (c) 2009 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "dateeditwidget.h" #include #include #include -#include #include #include #include #include #include #include -DateLineEdit::DateLineEdit( QWidget *parent ) - : KLineEdit( parent ) +DateView::DateView( QWidget *parent ) + : QLabel( parent ) { - setReadOnly( true ); + setTextInteractionFlags( Qt::TextSelectableByMouse ); + setFrameShape( QFrame::Panel ); + setFrameShadow( QFrame::Sunken ); } -void DateLineEdit::contextMenuEvent( QContextMenuEvent *event ) +void DateView::contextMenuEvent( QContextMenuEvent *event ) { QMenu menu; menu.addAction( i18n( "Remove" ), this, SLOT( emitSignal() ) ); menu.exec( event->globalPos() ); } -void DateLineEdit::emitSignal() +void DateView::emitSignal() { emit resetDate(); } DateEditWidget::DateEditWidget( QWidget *parent ) : QWidget( parent ) { QHBoxLayout *layout = new QHBoxLayout( this ); layout->setMargin( 0 ); - mView = new DateLineEdit; + mView = new DateView; layout->addWidget( mView ); mButton = new QToolButton; mButton->setPopupMode(QToolButton::InstantPopup); mButton->setIcon( KIcon( QLatin1String( "view-calendar-day" ) ) ); layout->addWidget( mButton ); mMenu = new KPIM::KDatePickerPopup( KPIM::KDatePickerPopup::DatePicker, QDate(), this ); mButton->setMenu( mMenu ); connect( mMenu, SIGNAL( dateChanged( const QDate& ) ), SLOT( dateSelected( const QDate& ) ) ); connect( mView, SIGNAL( resetDate() ), SLOT( resetDate() ) ); updateView(); } DateEditWidget::~DateEditWidget() { } void DateEditWidget::setDate( const QDate &date ) { mDate = date; mMenu->setDate( mDate ); updateView(); } QDate DateEditWidget::date() const { return mDate; } void DateEditWidget::setReadOnly( bool readOnly ) { mButton->setEnabled( !readOnly ); } void DateEditWidget::dateSelected(const QDate &date) { mDate = date; updateView(); } void DateEditWidget::resetDate() { mDate = QDate(); updateView(); } void DateEditWidget::updateView() { if ( mDate.isValid() ) mView->setText( KGlobal::locale()->formatDate( mDate ) ); else mView->setText( QString() ); } #include "dateeditwidget.moc" diff --git a/akonadi/contact/editor/dateeditwidget.h b/akonadi/contact/editor/dateeditwidget.h index ca0b195a1..370b5e766 100644 --- a/akonadi/contact/editor/dateeditwidget.h +++ b/akonadi/contact/editor/dateeditwidget.h @@ -1,79 +1,78 @@ /* This file is part of Akonadi Contact. Copyright (c) 2009 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef DATEEDITWIDGET_H #define DATEEDITWIDGET_H #include +#include #include -#include - namespace KPIM { class KDatePickerPopup; } class QContextMenuEvent; class QToolButton; -class DateLineEdit : public KLineEdit +class DateView : public QLabel { Q_OBJECT public: - DateLineEdit( QWidget *parent = 0 ); + DateView( QWidget *parent = 0 ); Q_SIGNALS: void resetDate(); protected: virtual void contextMenuEvent( QContextMenuEvent* ); private Q_SLOTS: void emitSignal(); }; class DateEditWidget : public QWidget { Q_OBJECT public: DateEditWidget( QWidget *parent = 0 ); ~DateEditWidget(); void setDate( const QDate &date ); QDate date() const; void setReadOnly( bool readOnly ); private Q_SLOTS: void dateSelected( const QDate& ); void resetDate(); void updateView(); private: QDate mDate; - DateLineEdit *mView; + DateView *mView; QToolButton *mButton; KPIM::KDatePickerPopup *mMenu; }; #endif