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

List:       kde-commits
Subject:    =?utf-8?q?=5Bknipptasch=5D_/=3A_move_DateEdit_and_DatePickerPopu?=
From:       Stefan_Böhmann <kde () hilefoks ! org>
Date:       2011-01-31 23:37:22
Message-ID: 20110131233722.ED291A60C6 () git ! kde ! org
[Download RAW message or body]

Git commit 2e7cb6a55710fa7dae74163cdbf49d239afe07e4 by Stefan Böhmann.
Pushed by sboehmann into branch 'master'.

move DateEdit and DatePickerPopup from gui/ to core/widgets

M  +2    -2    CMakeLists.txt     
M  +17   -4    core/CMakeLists.txt     
A  +1    -0    core/include/Knipptasch/DateEdit         [License: Trivial file]
A  +1    -0    core/include/Knipptasch/DateValidator         [License: Trivial file]
A  +614  -0    core/widgets/dateedit.cpp         [License: LGPL (v2.1+)]
A  +247  -0    core/widgets/dateedit.h         [License: LGPL (v2.1+)]
A  +258  -0    core/widgets/datepickerpopup.cpp         [License: LGPL (v2.1+)]
A  +113  -0    core/widgets/datepickerpopup.h         [License: LGPL (v2.1+)]
A  +140  -0    core/widgets/datevalidator.cpp         [License: GPL (v2+)]
A  +65   -0    core/widgets/datevalidator.h         [License: GPL (v2+)]
M  +0    -4    gui/CMakeLists.txt     
D  +0    -623  gui/dateedit.cpp     
D  +0    -236  gui/dateedit.h     
D  +0    -258  gui/datepickerpopup.cpp     
D  +0    -113  gui/datepickerpopup.h     
M  +2    -2    gui/delegate/datedelegate.cpp     

http://commits.kde.org/knipptasch/2e7cb6a55710fa7dae74163cdbf49d239afe07e4

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1d8dada..3bb967c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -143,10 +143,10 @@ macro_optional_add_subdirectory( cmake )
 macro_optional_add_subdirectory( strigi-analyzer )
 add_subdirectory( 3rdparty )
 add_subdirectory( data )
-add_subdirectory( core )
 add_subdirectory( compat )
+add_subdirectory( core )
 add_subdirectory( gui )
-add_subdirectory( plugins )
+#add_subdirectory( plugins )
 
 macro_display_feature_log()
 
diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt
index ee11e65..891b642 100644
--- a/core/CMakeLists.txt
+++ b/core/CMakeLists.txt
@@ -17,6 +17,10 @@ set( knipptasch_core_SOURCES
     exportplugin.cpp
     importplugin.cpp
 
+    widgets/dateedit.cpp
+    widgets/datevalidator.cpp
+    widgets/datepickerpopup.cpp
+
     backend/object.cpp
     backend/category.cpp
     backend/account.cpp
@@ -34,6 +38,10 @@ set( knipptasch_core_HEADERS
     exportplugin.h
     importplugin.h
 
+    widgets/dateedit.h
+    widgets/datevalidator.h
+    widgets/datepickerpopup.h
+
     backend/object.h
     backend/category.h
     backend/account.h
@@ -46,10 +54,14 @@ set( knipptasch_core_HEADERS
  )
 
 
-qt4_wrap_cpp( knipptasch_core_SOURCES ${knipptasch_core_HEADERS} )
-add_library( knipptasch SHARED ${knipptasch_core_SOURCES} )
-
-target_link_libraries( knipptasch ${QT_LIBRARIES} modeltest )
+if( HAVE_KDE )
+  kde4_add_library( knipptasch SHARED ${knipptasch_core_SOURCES} )
+  target_link_libraries( knipptasch ${QT_LIBRARIES} modeltest compat )
+else( HAVE_KDE )
+  qt4_wrap_cpp( knipptasch_core_SOURCES ${knipptasch_core_HEADERS} )
+  add_library( knipptasch SHARED ${knipptasch_core_SOURCES} )
+  target_link_libraries( knipptasch ${QT_LIBRARIES} ${KDE4_KDECORE_LIBS} \
${KDE4_KDEUI_LIBS} modeltest compat ) +endif( HAVE_KDE )
 
 set_target_properties(
     knipptasch
@@ -58,4 +70,5 @@ set_target_properties(
     SOVERSION "${knipptasch_core_MAJOR_VERSION}.${knipptasch_core_MINOR_VERSION}"
 )
 
+
 install( TARGETS knipptasch DESTINATION ${INSTALL_TARGETS_DEFAULT_ARGS} )
diff --git a/core/include/Knipptasch/DateEdit b/core/include/Knipptasch/DateEdit
new file mode 100644
index 0000000..fe90ef3
--- /dev/null
+++ b/core/include/Knipptasch/DateEdit
@@ -0,0 +1 @@
+#include <widgets/dateedit.h> 
diff --git a/core/include/Knipptasch/DateValidator \
b/core/include/Knipptasch/DateValidator new file mode 100644
index 0000000..7565ac8
--- /dev/null
+++ b/core/include/Knipptasch/DateValidator
@@ -0,0 +1 @@
+#include <widgets/datevalidator.h> 
diff --git a/core/widgets/dateedit.cpp b/core/widgets/dateedit.cpp
new file mode 100644
index 0000000..fc58109
--- /dev/null
+++ b/core/widgets/dateedit.cpp
@@ -0,0 +1,614 @@
+/*
+ * Copyright 2010 by Stefan Böhmann <kde@hilefoks.org>
+ *
+ * Based on KDateEdit (part of libkdepim)
+ *   Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
+ *   Copyright (c) 2002,2010 David Jarvie <djarvie@kde.org>
+ *   Copyright (c) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
+ *   Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
+ */
+#include "dateedit.h"
+
+#include "datevalidator.h"
+#include "datepickerpopup.h"
+
+#include "compat/utils.h"
+
+#if defined(HAVE_KDE)
+#include <KMessageBox>
+#include <KCalendarSystem>
+#include <KGlobal>
+#include <KGlobalSettings>
+#include <KLocale>
+#include <KLocalizedString>
+#else
+#include <QtGui/QMessageBox>
+#include <QtGui/QDesktopWidget>
+#endif
+
+#include <QtCore/QEvent>
+#include <QtGui/QAbstractItemView>
+#include <QtGui/QApplication>
+#include <QtGui/QKeyEvent>
+#include <QtGui/QLineEdit>
+#include <QtGui/QMouseEvent>
+#include <QtGui/QValidator>
+
+#include <QtCore/QDebug>
+
+
+
+class DateEdit::Private
+{
+    public:
+        Private(DateEdit *qq)
+          : q( qq ),
+            mPopup( 0 ),
+            mReadOnly( false ),
+            mDiscardNextMousePress( false )
+        {
+        }
+
+        QDate parseDate(bool *replaced = 0) const;
+        void updateView();
+        void setupKeywords();
+        bool newDateEntered(const QDate &newDate);
+
+    public:
+        // slots
+        void lineEnterPressed();
+        void slotTextChanged(const QString &str);
+        void dateSelected(const QDate &dt);
+
+        DateEdit *q;
+        DatePickerPopup *mPopup;
+
+        QDate mDate;
+        QDate mMinDate;               // minimum allowed date, or invalid for no \
minimum +        QDate mMaxDate;               // maximum allowed date, or invalid \
for no maximum +        QString mMinDateErrString;    // error message when entered \
date < mMinDate +        QString mMaxDateErrString;    // error message when entered \
date > mMaxDate +        bool mReadOnly;
+        bool mTextChanged;
+        bool mDiscardNextMousePress;
+
+        QMap<QString, int> mKeywordMap;
+};
+
+
+QDate DateEdit::Private::parseDate(bool *replaced) const
+{
+    const QString text = q->currentText();
+
+    if( replaced ) {
+        (*replaced) = false;
+    }
+
+    QDate result;
+    if( text.isEmpty() ) {
+        result = QDate();
+    }
+    else if( mKeywordMap.contains( text.toLower() ) ) {
+        const QDate today = QDate::currentDate();
+        int i = mKeywordMap[ text.toLower() ];
+
+        if ( i >= 100 ) {
+            /* A day name has been entered. Convert to offset from today.
+             * This uses some math tricks to figure out the offset in days
+             * to the next date the given day of the week occurs. There
+             * are two cases, that the new day is >= the current day, which means
+             * the new day has not occurred yet or that the new day < the current \
day, +             * which means the new day is already passed (so we need to find \
the +             * day in the next week).
+             */
+            i -= 100;
+
+            const int currentDay = today.dayOfWeek();
+            if( i >= currentDay ) {
+                i -= currentDay;
+            }
+            else {
+                i += 7 - currentDay;
+            }
+        }
+
+        result = today.addDays( i );
+        if( replaced ) {
+            (*replaced) = true;
+        }
+    }
+    else {
+        result = readDate( text );
+    }
+
+    return result;
+}
+
+
+void DateEdit::Private::updateView()
+{
+    QString dateString;
+    if( mDate.isValid() ) {
+        dateString = formatShortDate( mDate );
+    }
+
+    // We do not want to generate a signal here,
+    // since we explicitly setting the date
+    const bool blocked = q->signalsBlocked();
+    q->blockSignals( true );
+    q->removeItem( 0 );
+    q->insertItem( 0, dateString );
+    q->blockSignals( blocked );
+}
+
+
+void DateEdit::Private::setupKeywords()
+{
+    // Create the keyword list. This will be used to match against when the user
+    // enters information.
+    mKeywordMap.insert( tr( "tomorrow" ), 1 );
+    mKeywordMap.insert( tr( "today" ), 0 );
+    mKeywordMap.insert( tr( "yesterday" ), -1 );
+
+    QString dayName;
+    for ( int i = 1; i <= 7; ++i ) {
+#if defined(HAVE_KDE)
+        dayName = KGlobal::locale()->calendar()->weekDayName( i ).toLower();
+#else
+        dayName = QDate::longDayName( i ).toLower();
+#endif
+        mKeywordMap.insert( dayName, i + 100 );
+    }
+}
+
+
+// Check a new date against any minimum or maximum date.
+bool DateEdit::Private::newDateEntered(const QDate &newDate)
+{
+    QDate date = newDate;
+    if( newDate.isValid() ) {
+        QString errString;
+        QString message;
+        if( mMinDate.isValid()  &&  newDate < mMinDate ) {
+            message = tr( "Date cannot be earlier than %1" )
+                            .arg( mMinDate == QDate::currentDate()
+                                    ? tr( "today" )
+                                    : formatShortDate( mMinDate ) );
+
+            errString = mMinDateErrString;
+            date = mMinDate;
+        }
+        else if( mMaxDate.isValid()  &&  newDate > mMaxDate ) {
+            message = tr( "Date cannot be later than %1" )
+                            .arg( mMinDate == QDate::currentDate()
+                                    ? tr( "today" )
+                                    : formatShortDate( mMinDate ) );
+
+            errString = mMaxDateErrString;
+            date = mMaxDate;
+        }
+
+        if( !message.isEmpty() ) {
+            q->assignDate( date );
+            updateView();
+
+#if defined(HAVE_KDE)
+            KMessageBox::sorry( q, errString );
+#else
+            QMessageBox::information( q, tr( "Sorry" ), errString );
+#endif
+        }
+    }
+
+    emit q->dateChanged( date );
+    emit q->dateEdited( date );
+    emit q->dateEntered( date );
+
+    return date.isValid();
+}
+
+
+void DateEdit::Private::lineEnterPressed()
+{
+    bool replaced = false;
+    const QDate date = parseDate( &replaced );
+
+    if( q->assignDate( date ) ) {
+        if( replaced ) {
+            updateView();
+        }
+
+        newDateEntered( date );
+    }
+}
+
+
+void DateEdit::Private::slotTextChanged(const QString &str)
+{
+    Q_UNUSED( str );
+    const QDate date = parseDate();
+
+    if( q->assignDate( date ) ) {
+        emit q->dateEdited( date );
+        emit q->dateChanged( date );
+    }
+
+    mTextChanged = true;
+}
+
+
+void DateEdit::Private::dateSelected(const QDate &date)
+{
+    if( q->assignDate( date ) ) {
+        updateView();
+        if( newDateEntered( date ) ) {
+            mPopup->hide();
+        }
+    }
+}
+
+
+DateEdit::DateEdit(QWidget *parent)
+#if defined( HAVE_KDE )
+  : KComboBox( parent ),
+#else
+  : QComboBox( parent ),
+#endif
+    d( new Private( this ) )
+{
+    // need at least one entry for popup to work
+    setMaxCount( 1 );
+    setEditable( true );
+
+    const QString today = formatShortDate( d->mDate );
+
+    addItem( today );
+    setCurrentIndex( 0 );
+
+    connect( lineEdit(), SIGNAL( returnPressed() ),
+            this, SLOT( lineEnterPressed() ) );
+    connect( this, SIGNAL( editTextChanged( const QString& ) ),
+             this, SLOT( slotTextChanged( const QString& ) ) );
+
+    d->mPopup = new DatePickerPopup(
+                            DatePickerPopup::NoDate
+                          | DatePickerPopup::DatePicker
+                          | DatePickerPopup::Words,
+                        QDate::currentDate(), this );
+
+    d->mPopup->hide();
+    d->mPopup->installEventFilter( this );
+
+    connect( d->mPopup, SIGNAL( dateChanged(const QDate&) ), this, SLOT( \
dateSelected(const QDate&) ) ); +
+    // handle keyword entry
+    d->setupKeywords();
+    lineEdit()->installEventFilter( this );
+
+    setValidator( new DateValidator( QString(), d->mKeywordMap.keys(), this ) );
+
+    d->mTextChanged = false;
+}
+
+
+DateEdit::DateEdit(const QString &dateFormat, QWidget *parent)
+#if defined( HAVE_KDE )
+  : KComboBox( parent ),
+#else
+  : QComboBox( parent ),
+#endif
+    d( new Private( this ) )
+{
+    // need at least one entry for popup to work
+    setMaxCount( 1 );
+    setEditable( true );
+
+    const QString today = formatShortDate( d->mDate );
+
+    addItem( today );
+    setCurrentIndex( 0 );
+
+    connect( lineEdit(), SIGNAL( returnPressed() ),
+            this, SLOT( lineEnterPressed() ) );
+    connect( this, SIGNAL( editTextChanged( const QString& ) ),
+             this, SLOT( slotTextChanged( const QString& ) ) );
+
+    d->mPopup = new DatePickerPopup(
+                            DatePickerPopup::NoDate
+                          | DatePickerPopup::DatePicker
+                          | DatePickerPopup::Words,
+                        QDate::currentDate(), this );
+
+    d->mPopup->hide();
+    d->mPopup->installEventFilter( this );
+
+    connect( d->mPopup, SIGNAL( dateChanged(const QDate&) ), this, SLOT( \
dateSelected(const QDate&) ) ); +
+    // handle keyword entry
+    d->setupKeywords();
+    lineEdit()->installEventFilter( this );
+
+    setValidator( new DateValidator( dateFormat, d->mKeywordMap.keys(), this ) );
+
+    d->mTextChanged = false;
+}
+
+
+DateEdit::~DateEdit()
+{
+    delete d;
+}
+
+
+void DateEdit::setDate(const QDate &date)
+{
+    assignDate( date );
+    d->updateView();
+
+    if( date.isValid() ) {
+        emit dateChanged( date );
+    }
+}
+
+
+QDate DateEdit::date() const
+{
+    return d->mDate;
+}
+
+
+void DateEdit::setMinimumDate(const QDate &minDate, const QString &errorMsg)
+{
+    d->mMinDate = minDate;
+
+    if( d->mMinDate.isValid() && date().isValid() && date() < d->mMinDate ) {
+        setDate( d->mMinDate );
+    }
+
+    d->mMinDateErrString = errorMsg;
+}
+
+
+QDate DateEdit::minimumDate() const
+{
+    return d->mMinDate;
+}
+
+
+void DateEdit::setMaximumDate(const QDate& maxDate, const QString& errorMsg)
+{
+    d->mMaxDate = maxDate;
+
+    if( d->mMaxDate.isValid() && date().isValid() && date() > d->mMaxDate ) {
+        setDate( d->mMaxDate );
+    }
+
+    d->mMaxDateErrString = errorMsg;
+}
+
+
+QDate DateEdit::maximumDate() const
+{
+    return d->mMaxDate;
+}
+
+
+void DateEdit::setDateRange(const QDate& earliest, const QDate& latest,
+                            const QString& earlyErrorMsg, const QString& \
lateErrorMsg) +{
+    setMinimumDate( earliest, earlyErrorMsg );
+    setMaximumDate( latest, lateErrorMsg );
+}
+
+
+void DateEdit::setReadOnly(bool readOnly)
+{
+    d->mReadOnly = readOnly;
+    lineEdit()->setReadOnly( readOnly );
+}
+
+
+bool DateEdit::isReadOnly() const
+{
+    return d->mReadOnly;
+}
+
+
+void DateEdit::showPopup()
+{
+    if( d->mReadOnly ) {
+        return;
+    }
+
+    const QRect desk =
+#if defined(HAVE_KDE)
+            KGlobalSettings::desktopGeometry( this );
+#else
+            QApplication::desktop()->screenGeometry( this );
+#endif
+
+    QPoint popupPoint = mapToGlobal( QPoint( 0, 0 ) );
+
+    const int dateFrameHeight = d->mPopup->sizeHint().height();
+
+    if( popupPoint.y() + height() + dateFrameHeight > desk.bottom() ) {
+        popupPoint.setY( popupPoint.y() - dateFrameHeight );
+    }
+    else {
+        popupPoint.setY( popupPoint.y() + height() );
+    }
+
+    const int dateFrameWidth = d->mPopup->sizeHint().width();
+    if( popupPoint.x() + dateFrameWidth > desk.right() ) {
+        popupPoint.setX( desk.right() - dateFrameWidth );
+    }
+
+    if( popupPoint.x() < desk.left() ) {
+        popupPoint.setX( desk.left() );
+    }
+
+    if( popupPoint.y() < desk.top() ) {
+        popupPoint.setY( desk.top() );
+    }
+
+    if( d->mDate.isValid() ) {
+        d->mPopup->setDate( d->mDate );
+    }
+    else {
+        d->mPopup->setDate( QDate::currentDate() );
+    }
+
+    d->mPopup->popup( popupPoint );
+
+    // The combo box is now shown pressed. Make it show not pressed again
+    // by causing its (invisible) list box to emit a 'selected' signal.
+    // First, ensure that the list box contains the date currently displayed.
+    const QDate date = d->parseDate();
+    assignDate( date );
+    d->updateView();
+
+    // Now, simulate an Enter to unpress it
+    QAbstractItemView *lb = view();
+    if( lb ) {
+        lb->setCurrentIndex( lb->model()->index( 0, 0 ) );
+        QKeyEvent *keyEvent = new QKeyEvent( QEvent::KeyPress, Qt::Key_Enter, \
Qt::NoModifier ); +        QApplication::postEvent( lb, keyEvent );
+    }
+}
+
+
+void DateEdit::focusOutEvent(QFocusEvent *event)
+{
+    if( d->mTextChanged ) {
+        d->lineEnterPressed();
+        d->mTextChanged = false;
+    }
+
+    QComboBox::focusOutEvent( event );
+}
+
+
+void DateEdit::keyPressEvent(QKeyEvent *event)
+{
+    int step = 0;
+
+    if( event->key() == Qt::Key_Up ) {
+        step = 1;
+    }
+    else if( event->key() == Qt::Key_Down ) {
+        step = -1;
+    }
+
+    if( step && !d->mReadOnly ) {
+        QDate date = d->parseDate();
+        if( date.isValid() ) {
+            date = date.addDays( step );
+            if( assignDate( date ) ) {
+                d->updateView();
+                d->newDateEntered( date );
+            }
+        }
+    }
+
+    QComboBox::keyPressEvent( event );
+}
+
+
+bool DateEdit::eventFilter(QObject *object, QEvent *event)
+{
+    if( object == lineEdit() ) {
+        // We only process the focus out event if the text has changed
+        // since we got focus
+        if( (event->type() == QEvent::FocusOut) && d->mTextChanged ) {
+            d->lineEnterPressed();
+            d->mTextChanged = false;
+        }
+        else if ( event->type() == QEvent::KeyPress ) {
+            // Up and down arrow keys step the date
+            QKeyEvent *keyEvent = (QKeyEvent *)event;
+
+            if( keyEvent->key() == Qt::Key_Return ) {
+                d->lineEnterPressed();
+                return true;
+            }
+        }
+    }
+    else {
+        // It's a date picker event
+        switch( event->type() ) {
+            case QEvent::MouseButtonDblClick:
+            case QEvent::MouseButtonPress:
+            {
+                QMouseEvent *mouseEvent = (QMouseEvent*)event;
+                if( !d->mPopup->rect().contains( mouseEvent->pos() ) ) {
+                    const QPoint globalPos = d->mPopup->mapToGlobal( \
mouseEvent->pos() ); +
+                    if( QApplication::widgetAt( globalPos ) == this ) {
+                        // The date picker is being closed by a click on the
+                        // DateEdit widget. Avoid popping it up again immediately.
+                        d->mDiscardNextMousePress = true;
+                    }
+                }
+            }
+            default:
+                break;
+        }
+    }
+
+    return false;
+}
+
+
+void DateEdit::mousePressEvent(QMouseEvent *event)
+{
+    if( event->button() == Qt::LeftButton && d->mDiscardNextMousePress ) {
+        d->mDiscardNextMousePress = false;
+        return;
+    }
+
+    QComboBox::mousePressEvent( event );
+}
+
+
+bool DateEdit::assignDate(const QDate &date)
+{
+    d->mDate = date;
+    d->mTextChanged = false;
+
+    return true;
+}
+
+
+void DateEdit::lineEnterPressed()
+{
+    d->lineEnterPressed();
+}
+
+
+void DateEdit::slotTextChanged(const QString &str)
+{
+    d->slotTextChanged( str );
+}
+
+
+void DateEdit::dateSelected(const QDate &dt)
+{
+    d->dateSelected( dt );
+}
+
+
+// kate: word-wrap off; encoding utf-8; indent-width 4; tab-width 4; line-numbers \
on; mixed-indent off; remove-trailing-space-save on; replace-tabs-save on; \
replace-tabs on; space-indent on; +// vim:set spell et sw=4 ts=4 nowrap \
                cino=l1,cs,U1:
diff --git a/core/widgets/dateedit.h b/core/widgets/dateedit.h
new file mode 100644
index 0000000..3af3b08
--- /dev/null
+++ b/core/widgets/dateedit.h
@@ -0,0 +1,247 @@
+/*
+ * Copyright 2010 by Stefan Böhmann <kde@hilefoks.org>
+ *
+ * Based on KDateEdit (part of libkdepim)
+ *   Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
+ *   Copyright (c) 2002,2010 David Jarvie <djarvie@kde.org>
+ *   Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef KNIPPTASCH_KDEPIM_KDATEEDIT_H
+#define KNIPPTASCH_KDEPIM_KDATEEDIT_H
+
+#include "knipptasch_core_export.h"
+
+#include <QtCore/QDate>
+
+
+#if defined( HAVE_KDE )
+#include <KComboBox>
+#else
+#include <QComboBox>
+#endif
+
+
+class QEvent;
+class QMouseEvent;
+class QStatusBar;
+
+
+/**
+  @short A date editing widget that consists of an editable combo box.
+
+  The combo box contains the date in text form, and clicking the combo
+  box arrow will display a 'popup' style date picker.
+
+  This widget also supports advanced features like allowing the user
+  to type in the day name to get the date. The following keywords
+  are supported (in the native language): tomorrow, yesterday, today,
+  monday, tuesday, wednesday, thursday, friday, saturday, sunday.
+  The user may also use the up and down arrow on the keyboard to
+  increment and decrement the date.
+
+  Upper and/or lower limits may be set on the range of dates which the
+  user is allowed to enter.
+
+  @image html kdateedit.png "This is how it looks"
+
+  @author Cornelius Schumacher <schumacher@kde.org>
+  @author Mike Pilone <mpilone@slac.com>
+  @author David Jarvie <djarvie@kde.org>
+  @author Tobias Koenig <tokoe@kde.org>
+  @author Stefan Böhmann <kde@hilefoks.org>
+*/
+
+#if defined( HAVE_KDE )
+class KNIPPTASCH_CORE_EXPORT DateEdit : public KComboBox
+#else
+class KNIPPTASCH_CORE_EXPORT DateEdit : public QComboBox
+#endif
+{
+    Q_OBJECT
+    Q_PROPERTY(QDate date READ date WRITE setDate USER true)
+
+    public:
+        /**
+         * Creates a new date edit.
+         *
+         * @param parent The parent widget.
+         */
+        explicit DateEdit(QWidget *parent = 0);
+
+        /**
+         * Creates a new date edit.
+         *
+         * @param dateFormat own date format string
+         * @param parent The parent widget.
+         */
+        explicit DateEdit(const QString &dateFormat, QWidget *parent = 0);
+
+        /**
+         * Destroys the date edit.
+         */
+        virtual ~DateEdit();
+
+        /**
+         * Returns the date entered.
+         *
+         * @note This date could be invalid, you have to check validity yourself.
+         */
+        QDate date() const;
+
+        /**
+         * Sets the earliest date which can be entered.
+         *
+         * @param date Earliest date allowed, or invalid to remove the minimum \
limit. +         * @param errorMsg Error message to be displayed when a date earlier \
than +         *                 @p date is entered. Set to QString() to use the \
default +         *                 error message.
+         *
+         * @see setDateRange()
+         */
+        void setMinimumDate(const QDate &date, const QString &errorMsg = QString());
+
+        /**
+         * Returns the earliest date which can be entered.
+         * If there is no minimum date, returns an invalid date.
+         */
+        QDate minimumDate() const;
+
+        /**
+         * Sets the latest date which can be entered.
+         *
+         * @param date Latest date allowed, or invalid to remove the maximum limit.
+         * @param errorMsg Error message to be displayed when a date later than
+         *                 @p date is entered. Set to QString() to use the default
+         *                 error message.
+         *
+         * @see setDateRange()
+         */
+        void setMaximumDate(const QDate& date, const QString& errorMsg = QString());
+
+        /**
+         * Returns the latest date which can be entered.
+         * If there is no maximum date, returns an invalid date.
+         */
+        QDate maximumDate() const;
+
+        /**
+         * Sets the range of dates which can be entered.
+         *
+         * @param earliest Earliest date allowed, or invalid to remove the minimum \
limit. +         * @param latest   Latest date allowed, or invalid to remove the \
maximum limit. +         * @param earlyErrorMsg Error message to be displayed when a \
date earlier than +         *                  @p earliest is entered. Set to \
QString() to use the default +         *                  error message.
+         * @param lateErrorMsg Error message to be displayed when a date later than
+         *                  @p latest is entered. Set to QString() to use the \
default +         *                  error message.
+         *
+         * @see setMinimumDate(), setMaximumDate()
+         */
+        void setDateRange(const QDate &earliest, const QDate &latest,
+                            const QString &earlyErrorMsg = QString(),
+                            const QString &lateErrorMsg = QString());
+
+        /**
+         * Sets whether the widget is read-only for the user. If read-only, the
+         * date pop-up is inactive, and the displayed date cannot be edited.
+         *
+         * @param readOnly True to set the widget read-only, false to set it \
read-write. +         */
+        void setReadOnly(bool readOnly);
+
+        /**
+         * Returns whether the widget is read-only.
+         */
+        bool isReadOnly() const;
+
+        /**
+         * Shows the date picker popup menu.
+         */
+        virtual void showPopup();
+
+    Q_SIGNALS:
+        /**
+         * This signal is emitted whenever the user has entered a new date.
+         * When the user changes the date by editing the line edit field,
+         * the signal is not emitted until focus leaves the line edit field.
+         * The passed date can be invalid.
+         */
+        void dateEntered(const QDate &date);
+
+        /**
+         * This signal is emitted whenever date is changed.
+         * Unlike dateEdited(), this signal is also emitted when the date is changed
+         * programmatically.
+         *
+         * The passed date can be invalid.
+         */
+        void dateChanged(const QDate &date);
+
+        /**
+         * This signal is emitted whenever the date is edited by the user.
+         * Unlike dateChanged(), this signal is not emitted when the date is changed
+         * programmatically.
+         *
+         * The passed date can be invalid.
+         */
+        void dateEdited(const QDate &date);
+
+    public Q_SLOTS:
+        /**
+         * Sets the date.
+         *
+         * @param date The new date to display. This date must be valid or
+         *             it will not be set
+         */
+        void setDate(const QDate &date);
+
+    protected:
+        virtual bool eventFilter(QObject *obj, QEvent *ev);
+        virtual void mousePressEvent(QMouseEvent *ev);
+        virtual void focusOutEvent(QFocusEvent *ev);
+        virtual void keyPressEvent(QKeyEvent *ev);
+
+        /**
+         * Sets the date, without altering the display.
+         * This method is used internally to set the widget's date value.
+         * As a virtual method, it allows derived classes to perform additional
+         * validation on the date value before it is set. Derived classes should
+         * return true if QDate::isValid(@p date) returns false.
+         *
+         * @param date The new date to set.
+         * @return True if the date was set, false if it was considered invalid
+         *         and remains unchanged.
+         */
+        virtual bool assignDate(const QDate &date);
+
+    private slots:
+        void lineEnterPressed();
+        void slotTextChanged(const QString &str);
+        void dateSelected(const QDate &dt);
+
+    private:
+        //@cond PRIVATE
+        class Private;
+        Private* const d;
+        //@endcond
+};
+
+
+#endif
+
+// kate: word-wrap off; encoding utf-8; indent-width 4; tab-width 4; line-numbers \
on; mixed-indent off; remove-trailing-space-save on; replace-tabs-save on; \
replace-tabs on; space-indent on; +// vim:set spell et sw=4 ts=4 nowrap \
                cino=l1,cs,U1:
diff --git a/core/widgets/datepickerpopup.cpp b/core/widgets/datepickerpopup.cpp
new file mode 100644
index 0000000..fbec80c
--- /dev/null
+++ b/core/widgets/datepickerpopup.cpp
@@ -0,0 +1,258 @@
+/*
+ * Copyright 2010 by Stefan Böhmann <kde@hilefoks.org>
+ *
+ * Based on KDateEdit (part of libkdepim)
+ *   Copyright (c) 2004 Bram Schoenmakers <bramschoenmakers@kde.nl>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
+ */
+#include "datepickerpopup.h"
+
+#if defined(HAVE_KDE)
+#include <KDatePicker>
+#include <KLocale>
+#else
+#include <QCalendarWidget>
+#endif
+
+#include <QDateTime>
+#include <QWidgetAction>
+
+
+
+class DatePickerAction : public QWidgetAction
+{
+    public:
+#if defined(HAVE_KDE)
+        DatePickerAction(KDatePicker *widget, QObject *parent)
+#else
+        DatePickerAction(QCalendarWidget *widget, QObject *parent)
+#endif
+          : QWidgetAction( parent ),
+            mDatePicker( widget ),
+            mOriginalParent( widget->parentWidget() )
+        {
+        }
+
+    protected:
+        QWidget *createWidget(QWidget *parent)
+        {
+            mDatePicker->setParent( parent );
+            return mDatePicker;
+        }
+
+        void deleteWidget(QWidget *widget)
+        {
+            if( widget != mDatePicker ) {
+                return;
+            }
+
+            mDatePicker->setParent( mOriginalParent );
+        }
+
+    private:
+#if defined(HAVE_KDE)
+        KDatePicker *mDatePicker;
+#else
+        QCalendarWidget *mDatePicker;
+#endif
+
+        QWidget *mOriginalParent;
+};
+
+
+class DatePickerPopup::Private
+{
+    public:
+        Private(DatePickerPopup *qq)
+          : q( qq ),
+            mDatePicker( 0 )
+        {
+        }
+
+        void buildMenu();
+
+        void slotDateChanged(const QDate &dt);
+        void slotToday();
+        void slotTomorrow();
+        void slotNextWeek();
+        void slotNextMonth();
+        void slotNoDate();
+
+        DatePickerPopup *q;
+
+#if defined(HAVE_KDE)
+        KDatePicker *mDatePicker;
+#else
+        QCalendarWidget *mDatePicker;
+#endif
+        Modes mModes;
+};
+
+
+void DatePickerPopup::Private::buildMenu()
+{
+    if( q->isVisible() ) {
+        return;
+    }
+
+    q->clear();
+
+    if( mModes & DatePicker ) {
+        q->addAction( new DatePickerAction( mDatePicker, q ) );
+
+        if( (mModes & NoDate) || (mModes & Words) ) {
+            q->addSeparator();
+        }
+    }
+
+    if( mModes & Words ) {
+        q->addAction( tr( "&Today" ), q, SLOT( slotToday() ) );
+        q->addAction( tr( "To&morrow" ), q, SLOT( slotTomorrow() ) );
+        q->addAction( tr( "Next &Week" ), q, SLOT( slotNextWeek() ) );
+        q->addAction( tr( "Next M&onth" ), q, SLOT( slotNextMonth() ) );
+
+        if( mModes & NoDate ) {
+            q->addSeparator();
+        }
+    }
+
+    if( mModes & NoDate ) {
+        q->addAction( tr( "No Date" ), q, SLOT( slotNoDate() ) );
+    }
+}
+
+
+void DatePickerPopup::Private::slotDateChanged(const QDate &date)
+{
+    emit q->dateChanged( date );
+    q->hide();
+}
+
+
+void DatePickerPopup::Private::slotToday()
+{
+    emit q->dateChanged( QDate::currentDate() );
+}
+
+
+void DatePickerPopup::Private::slotTomorrow()
+{
+    emit q->dateChanged( QDate::currentDate().addDays( 1 ) );
+}
+
+
+void DatePickerPopup::Private::slotNoDate()
+{
+    emit q->dateChanged( QDate() );
+}
+
+
+void DatePickerPopup::Private::slotNextWeek()
+{
+    emit q->dateChanged( QDate::currentDate().addDays( 7 ) );
+}
+
+
+void DatePickerPopup::Private::slotNextMonth()
+{
+    emit q->dateChanged( QDate::currentDate().addMonths( 1 ) );
+}
+
+
+
+DatePickerPopup::DatePickerPopup(Modes modes, const QDate &date, QWidget *parent)
+  : QMenu( parent ),
+    d( new Private( this ) )
+{
+    d->mModes = modes;
+
+#if defined(HAVE_KDE)
+    d->mDatePicker = new KDatePicker( this );
+    d->mDatePicker->setCloseButton( false );
+
+    connect( d->mDatePicker, SIGNAL( dateEntered( const QDate& ) ),
+            this, SLOT( slotDateChanged( const QDate& ) ) );
+    connect( d->mDatePicker, SIGNAL( dateSelected( const QDate& ) ),
+            this, SLOT( slotDateChanged( const QDate& ) ) );
+#else
+    d->mDatePicker = new QCalendarWidget( this );
+
+    connect( d->mDatePicker, SIGNAL( activated( const QDate& ) ),
+            this, SLOT( slotDateChanged( const QDate& ) ) );
+    connect( d->mDatePicker, SIGNAL( clicked( const QDate& ) ),
+            this, SLOT( slotDateChanged( const QDate& ) ) );
+#endif
+
+    setDate( date );
+    d->buildMenu();
+}
+
+
+DatePickerPopup::~DatePickerPopup()
+{
+    delete d;
+}
+
+
+void DatePickerPopup::setDate(const QDate &date)
+{
+#if defined(HAVE_KDE)
+    d->mDatePicker->setDate( date );
+#else
+    d->mDatePicker->setSelectedDate( date );
+#endif
+}
+
+
+void DatePickerPopup::slotDateChanged(const QDate &date)
+{
+    d->slotDateChanged( date );
+}
+
+
+void DatePickerPopup::slotToday()
+{
+    d->slotToday();
+}
+
+
+void DatePickerPopup::slotTomorrow()
+{
+    d->slotTomorrow();
+}
+
+
+void DatePickerPopup::slotNextWeek()
+{
+    d->slotNextWeek();
+}
+
+
+void DatePickerPopup::slotNextMonth()
+{
+    d->slotNextMonth();
+}
+
+
+void DatePickerPopup::slotNoDate()
+{
+    d->slotNoDate();
+}
+
+
+//#include "datepickerpopup.moc"
+
+// kate: word-wrap off; encoding utf-8; indent-width 4; tab-width 4; line-numbers \
on; mixed-indent off; remove-trailing-space-save on; replace-tabs-save on; \
replace-tabs on; space-indent on; +// vim:set spell et sw=4 ts=4 nowrap \
                cino=l1,cs,U1:
diff --git a/core/widgets/datepickerpopup.h b/core/widgets/datepickerpopup.h
new file mode 100644
index 0000000..ccea129
--- /dev/null
+++ b/core/widgets/datepickerpopup.h
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2010 by Stefan Böhmann <kde@hilefoks.org>
+ *
+ * Based on KDateEdit (part of libkdepim)
+ *   Copyright (c) 2004 Bram Schoenmakers <bramschoenmakers@kde.nl>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef KNIPPTASCH_CORE_DATEPICKERPOPUP_H
+#define KNIPPTASCH_CORE_DATEPICKERPOPUP_H
+
+#include <QtCore/QDate>
+#include <QtGui/QMenu>
+
+
+/**
+ * @short This menu helps the user to select a date quickly.
+ *
+ * This menu helps the user to select a date quickly. It offers various
+ * modes of selecting, e.g. with a DatePicker or with words like "Tomorrow".
+ *
+ * The available modes are:
+ *
+ * @li NoDate: A menu-item with "No Date". If chosen, the datepicker will emit
+ *     a null QDate.
+ * @li DatePicker: Shows a DatePicker-widget.
+ * @li Words: Shows items like "Today", "Tomorrow" or "Next Week".
+ *
+ * @author Bram Schoenmakers <bram_s@softhome.net>
+ */
+class DatePickerPopup: public QMenu
+{
+    Q_OBJECT
+
+    public:
+        /**
+         * Describes the available selection modes.
+         */
+        enum Mode
+        {
+            NoDate = 1,     ///< A menu-item with "No Date". Will always return an \
invalid date. +            DatePicker = 2, ///< A menu-item with a DatePicker.
+            Words = 4       ///< A menu-item with list of words that describe a \
date. +        };
+
+        /**
+         * Describes the a set of combined modes.
+         */
+        Q_DECLARE_FLAGS( Modes, Mode )
+
+        /**
+         * Creates a new date picker popup.
+         *
+         * @param modes The selection modes that shall be offered
+         * @param date The initial date of date picker widget.
+         * @param parent The parent object.
+         */
+        explicit DatePickerPopup(Modes modes = DatePicker,
+                                 const QDate &date = QDate::currentDate(),
+                                 QWidget *parent = 0);
+
+        /**
+         * Destroys the date picker popup.
+         */
+        ~DatePickerPopup();
+
+    public Q_SLOTS:
+        /**
+         * Sets the current @p date.
+         */
+        void setDate(const QDate &date);
+
+    Q_SIGNALS:
+        /**
+         * This signal is emitted whenever the user has selected a new date.
+         *
+         * @param date The new date.
+         */
+        void dateChanged(const QDate &date);
+
+    private slots:
+        void slotDateChanged(const QDate &dt);
+        void slotToday();
+        void slotTomorrow();
+        void slotNextWeek();
+        void slotNextMonth();
+        void slotNoDate();
+
+    private:
+        //@cond PRIVATE
+        class Private;
+        Private* const d;
+        //@endcond
+};
+
+
+Q_DECLARE_OPERATORS_FOR_FLAGS( DatePickerPopup::Modes )
+
+#endif
+
+// kate: word-wrap off; encoding utf-8; indent-width 4; tab-width 4; line-numbers \
on; mixed-indent off; remove-trailing-space-save on; replace-tabs-save on; \
replace-tabs on; space-indent on; +// vim:set spell et sw=4 ts=4 nowrap \
                cino=l1,cs,U1:
diff --git a/core/widgets/datevalidator.cpp b/core/widgets/datevalidator.cpp
new file mode 100644
index 0000000..03d15ba
--- /dev/null
+++ b/core/widgets/datevalidator.cpp
@@ -0,0 +1,140 @@
+/*
+ * Copyright 2011 by Stefan Böhmann <kde@hilefoks.org>
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+#include "datevalidator.h"
+
+#include "compat/utils.h"
+
+#include <QtCore/QDate>
+#include <QtGui/QValidator>
+#include <QtGui/QApplication>
+#include <QtGui/QStatusTipEvent>
+
+
+
+DateValidator::DateValidator(QWidget *parent)
+  : QValidator( parent ),
+    m_statusTipEnabled( true )
+{
+}
+
+
+DateValidator::DateValidator(const QString &dateFormat, QWidget *parent)
+  : QValidator( parent ),
+    m_dateFormat( dateFormat ),
+    m_statusTipEnabled( true )
+{
+}
+
+
+DateValidator::DateValidator(const QString &dateFormat, const QStringList &keywords, \
QWidget *parent) +  : QValidator( parent ),
+    m_keywords( keywords ),
+    m_dateFormat( dateFormat ),
+    m_statusTipEnabled( true )
+{
+}
+
+
+DateValidator::~DateValidator()
+{
+    if( m_statusTipEnabled ) {
+        QStatusTipEvent *event = new QStatusTipEvent( "" );
+        qApp->sendEvent( parent(), event );
+    }
+}
+
+
+QValidator::State DateValidator::validate(QString &str, int &value) const
+{
+    Q_UNUSED( value );
+
+    if( m_statusTipEnabled ) {
+        QStatusTipEvent *event = new QStatusTipEvent( "" );
+        qApp->sendEvent( parent(), event );
+    }
+
+    // empty string is intermediate so one can clear the
+    // edit line and start from scratch
+    if( str.isEmpty() ) {
+        return Intermediate;
+    }
+
+    if( m_keywords.contains( str.toLower() ) ) {
+        return Acceptable;
+    }
+
+    bool ok = false;
+    QDate date = readDate( str, m_dateFormat, &ok );
+
+    if( ok ) {
+        if( m_statusTipEnabled ) {
+            QStatusTipEvent *event = new QStatusTipEvent( formatLongDate( date ) );
+            qApp->sendEvent( parent(), event );
+        }
+
+        return Acceptable;
+    }
+
+    return Intermediate;
+}
+
+
+QStringList DateValidator::keywordList() const
+{
+    return m_keywords;
+}
+
+
+void DateValidator::setKeywordList(const QStringList &list)
+{
+    m_keywords = list;
+}
+
+
+QString DateValidator::dateFormat() const
+{
+    return m_dateFormat;
+}
+
+
+void DateValidator::setDateFormat(const QString &dateFormat)
+{
+    m_dateFormat = dateFormat;
+}
+
+
+bool DateValidator::statusTipEnabled() const
+{
+    return m_statusTipEnabled;
+}
+
+
+void DateValidator::setStatusTipEnabled(bool enabled)
+{
+    if( m_statusTipEnabled != enabled ) {
+        if( m_statusTipEnabled ) {
+            QStatusTipEvent *event = new QStatusTipEvent( "" );
+            qApp->sendEvent( parent(), event );
+        }
+
+        m_statusTipEnabled = enabled;
+    }
+}
+
+
+// kate: word-wrap off; encoding utf-8; indent-width 4; tab-width 4; line-numbers \
on; mixed-indent off; remove-trailing-space-save on; replace-tabs-save on; \
replace-tabs on; space-indent on; +// vim:set spell et sw=4 ts=4 nowrap \
                cino=l1,cs,U1:
diff --git a/core/widgets/datevalidator.h b/core/widgets/datevalidator.h
new file mode 100644
index 0000000..aa1c4a7
--- /dev/null
+++ b/core/widgets/datevalidator.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2011 by Stefan Böhmann <kde@hilefoks.org>
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef KNIPPTASCH_DATEVALIDATOR_H
+#define KNIPPTASCH_DATEVALIDATOR_H
+
+#include "knipptasch_core_export.h"
+
+#include <QtCore/QStringList>
+#include <QtGui/QValidator>
+
+
+/**
+ * @class DateValidator
+ * @brief
+ *
+ * @author Stefan Böhmann <kde@hilefoks.org>
+ */
+class KNIPPTASCH_CORE_EXPORT DateValidator : public QValidator
+{
+    Q_OBJECT
+
+    public:
+        explicit DateValidator(QWidget *parent = 0);
+        explicit DateValidator(const QString &dateFormat, QWidget *parent = 0);
+        DateValidator(const QString &dateFormat, const QStringList &keywords, \
QWidget *parent = 0); +
+        ~DateValidator();
+
+        State validate(QString &str, int &value) const;
+
+        QStringList keywordList() const;
+        QString dateFormat() const;
+
+        bool statusTipEnabled() const;
+
+    public slots:
+        void setKeywordList(const QStringList &list);
+        void setDateFormat(const QString &dateFormat);
+        void setStatusTipEnabled(bool enabled);
+
+    private:
+        QStringList m_keywords;
+        QString m_dateFormat;
+        bool m_statusTipEnabled;
+};
+
+
+#endif
+
+// kate: word-wrap off; encoding utf-8; indent-width 4; tab-width 4; line-numbers \
on; mixed-indent off; remove-trailing-space-save on; replace-tabs-save on; \
replace-tabs on; space-indent on; +// vim:set spell et sw=4 ts=4 nowrap \
                cino=l1,cs,U1:
diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt
index 41991ef..2f33598 100644
--- a/gui/CMakeLists.txt
+++ b/gui/CMakeLists.txt
@@ -11,10 +11,8 @@ set(knipptasch_SOURCES
     quickreportpopup.cpp
     quickreportwidget.cpp
     passworddialog.cpp
-    datepickerpopup.cpp
     categorycombobox.cpp
     categorymodel.cpp
-    dateedit.cpp
     main.cpp
 
     config/configdialog.cpp
@@ -56,10 +54,8 @@ set( knipptasch_HEADERS
     quickreportpopup.h
     quickreportwidget.h
     passworddialog.h
-    datepickerpopup.h
     categorycombobox.h
     categorymodel.h
-    dateedit.h
 
     config/configdialog.h
     config/configwidget.h
diff --git a/gui/dateedit.cpp b/gui/dateedit.cpp
deleted file mode 100644
index 02ad300..0000000
--- a/gui/dateedit.cpp
+++ /dev/null
@@ -1,623 +0,0 @@
-/*
- * Copyright 2010 by Stefan Böhmann <kde@hilefoks.org>
- *
- * Based on KDateEdit (part of libkdepim)
- *   Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
- *   Copyright (c) 2002,2010 David Jarvie <djarvie@kde.org>
- *   Copyright (c) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
- *   Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
- */
-#include "dateedit.h"
-
-#include "datepickerpopup.h"
-
-#include "preferences.h"
-
-#include "compat/utils.h"
-
-#if defined(HAVE_KDE)
-#include <KMessageBox>
-#include <KCalendarSystem>
-#include <KGlobal>
-#include <KGlobalSettings>
-#include <KLocale>
-#include <KLocalizedString>
-#else
-#include <QMessageBox>
-#include <QDesktopWidget>
-#endif
-
-#include <QtCore/QEvent>
-#include <QtGui/QAbstractItemView>
-#include <QtGui/QApplication>
-#include <QtGui/QKeyEvent>
-#include <QtGui/QLineEdit>
-#include <QtGui/QMouseEvent>
-#include <QtGui/QValidator>
-
-#include <QtCore/QDebug>
-
-
-class DateValidator : public QValidator
-{
-    public:
-        DateValidator(const QStringList &keywords, QWidget *parent)
-          : QValidator( parent ),
-            mKeywords( keywords )
-        {
-        }
-
-        ~DateValidator()
-        {
-            QStatusTipEvent *event = new QStatusTipEvent( "" );
-            qApp->sendEvent( parent(), event );
-        }
-
-
-        virtual State validate(QString &str, int &value) const
-        {
-            Q_UNUSED( value );
-
-            QStatusTipEvent *event = new QStatusTipEvent( "" );
-            qApp->sendEvent( parent(), event );
-
-            // empty string is intermediate so one can clear the
-            // edit line and start from scratch
-            if( str.isEmpty() ) {
-                return Intermediate;
-            }
-
-            if( mKeywords.contains( str.toLower() ) ) {
-                return Acceptable;
-            }
-
-            bool ok = false;
-            QDate date = readDate( str, \
                Preferences::self()->userDefinedDateFormat(), &ok );
-
-            if( ok ) {
-                QStatusTipEvent *event = new QStatusTipEvent( formatLongDate( date ) \
                );
-                qApp->sendEvent( parent(), event );
-
-                return Acceptable;
-            }
-
-            return Intermediate;
-        }
-
-    private:
-        QStringList mKeywords;
-};
-
-
-class DateEdit::Private
-{
-    public:
-        Private(DateEdit *qq)
-          : q( qq ),
-            mPopup( 0 ),
-            mReadOnly( false ),
-            mDiscardNextMousePress( false )
-        {
-        }
-
-        QDate parseDate(bool *replaced = 0) const;
-        void updateView();
-        void setupKeywords();
-        bool newDateEntered(const QDate &newDate);
-
-    public:
-        // slots
-        void lineEnterPressed();
-        void slotTextChanged(const QString &str);
-        void dateSelected(const QDate &dt);
-
-        DateEdit *q;
-        DatePickerPopup *mPopup;
-
-        QDate mDate;
-        QDate mMinDate;               // minimum allowed date, or invalid for no \
                minimum
-        QDate mMaxDate;               // maximum allowed date, or invalid for no \
                maximum
-        QString mMinDateErrString;    // error message when entered date < mMinDate
-        QString mMaxDateErrString;    // error message when entered date > mMaxDate
-        bool mReadOnly;
-        bool mTextChanged;
-        bool mDiscardNextMousePress;
-
-        QMap<QString, int> mKeywordMap;
-};
-
-
-QDate DateEdit::Private::parseDate(bool *replaced) const
-{
-    const QString text = q->currentText();
-
-    if( replaced ) {
-        (*replaced) = false;
-    }
-
-    QDate result;
-    if( text.isEmpty() ) {
-        result = QDate();
-    }
-    else if( mKeywordMap.contains( text.toLower() ) ) {
-        const QDate today = QDate::currentDate();
-        int i = mKeywordMap[ text.toLower() ];
-
-        if ( i >= 100 ) {
-            /* A day name has been entered. Convert to offset from today.
-             * This uses some math tricks to figure out the offset in days
-             * to the next date the given day of the week occurs. There
-             * are two cases, that the new day is >= the current day, which means
-             * the new day has not occurred yet or that the new day < the current \
                day,
-             * which means the new day is already passed (so we need to find the
-             * day in the next week).
-             */
-            i -= 100;
-
-            const int currentDay = today.dayOfWeek();
-            if( i >= currentDay ) {
-                i -= currentDay;
-            }
-            else {
-                i += 7 - currentDay;
-            }
-        }
-
-        result = today.addDays( i );
-        if( replaced ) {
-            (*replaced) = true;
-        }
-    }
-    else {
-        result = readDate( text );
-    }
-
-    return result;
-}
-
-
-void DateEdit::Private::updateView()
-{
-    QString dateString;
-    if( mDate.isValid() ) {
-        dateString = formatShortDate( mDate );
-    }
-
-    // We do not want to generate a signal here,
-    // since we explicitly setting the date
-    const bool blocked = q->signalsBlocked();
-    q->blockSignals( true );
-    q->removeItem( 0 );
-    q->insertItem( 0, dateString );
-    q->blockSignals( blocked );
-}
-
-
-void DateEdit::Private::setupKeywords()
-{
-    // Create the keyword list. This will be used to match against when the user
-    // enters information.
-    mKeywordMap.insert( tr( "tomorrow" ), 1 );
-    mKeywordMap.insert( tr( "today" ), 0 );
-    mKeywordMap.insert( tr( "yesterday" ), -1 );
-
-    QString dayName;
-    for ( int i = 1; i <= 7; ++i ) {
-#if defined(HAVE_KDE)
-        dayName = KGlobal::locale()->calendar()->weekDayName( i ).toLower();
-#else
-        dayName = QDate::longDayName( i ).toLower();
-#endif
-        mKeywordMap.insert( dayName, i + 100 );
-    }
-}
-
-
-// Check a new date against any minimum or maximum date.
-bool DateEdit::Private::newDateEntered(const QDate &newDate)
-{
-    QDate date = newDate;
-    if( newDate.isValid() ) {
-        QString errString;
-        QString message;
-        if( mMinDate.isValid()  &&  newDate < mMinDate ) {
-            message = tr( "Date cannot be earlier than %1" )
-                            .arg( mMinDate == QDate::currentDate()
-                                    ? tr( "today" )
-                                    : formatShortDate( mMinDate ) );
-
-            errString = mMinDateErrString;
-            date = mMinDate;
-        }
-        else if( mMaxDate.isValid()  &&  newDate > mMaxDate ) {
-            message = tr( "Date cannot be later than %1" )
-                            .arg( mMinDate == QDate::currentDate()
-                                    ? tr( "today" )
-                                    : formatShortDate( mMinDate ) );
-
-            errString = mMaxDateErrString;
-            date = mMaxDate;
-        }
-
-        if( !message.isEmpty() ) {
-            q->assignDate( date );
-            updateView();
-
-#if defined(HAVE_KDE)
-            KMessageBox::sorry( q, errString );
-#else
-            QMessageBox::information( q, tr( "Sorry" ), errString );
-#endif
-        }
-    }
-
-    emit q->dateChanged( date );
-    emit q->dateEdited( date );
-    emit q->dateEntered( date );
-
-    return date.isValid();
-}
-
-
-void DateEdit::Private::lineEnterPressed()
-{
-    bool replaced = false;
-    const QDate date = parseDate( &replaced );
-
-    if( q->assignDate( date ) ) {
-        if( replaced ) {
-            updateView();
-        }
-
-        newDateEntered( date );
-    }
-}
-
-
-void DateEdit::Private::slotTextChanged(const QString &str)
-{
-    Q_UNUSED( str );
-    const QDate date = parseDate();
-
-    if( q->assignDate( date ) ) {
-        emit q->dateEdited( date );
-        emit q->dateChanged( date );
-    }
-
-    mTextChanged = true;
-}
-
-
-void DateEdit::Private::dateSelected(const QDate &date)
-{
-    if( q->assignDate( date ) ) {
-        updateView();
-        if( newDateEntered( date ) ) {
-            mPopup->hide();
-        }
-    }
-}
-
-
-DateEdit::DateEdit(QWidget *parent)
-#if defined( HAVE_KDE )
-  : KComboBox( parent ),
-#else
-  : QComboBox( parent ),
-#endif
-  d( new Private( this ) )
-{
-
-    // need at least one entry for popup to work
-    setMaxCount( 1 );
-    setEditable( true );
-
-    const QString today = formatShortDate( d->mDate );
-
-    addItem( today );
-    setCurrentIndex( 0 );
-
-    connect( lineEdit(), SIGNAL( returnPressed() ),
-            this, SLOT( lineEnterPressed() ) );
-    connect( this, SIGNAL( editTextChanged( const QString& ) ),
-             this, SLOT( slotTextChanged( const QString& ) ) );
-
-    d->mPopup = new DatePickerPopup(
-                            DatePickerPopup::NoDate
-                          | DatePickerPopup::DatePicker
-                          | DatePickerPopup::Words,
-                        QDate::currentDate(), this );
-
-    d->mPopup->hide();
-    d->mPopup->installEventFilter( this );
-
-    connect( d->mPopup, SIGNAL( dateChanged(const QDate&) ), this, SLOT( \
                dateSelected(const QDate&) ) );
-
-    // handle keyword entry
-    d->setupKeywords();
-    lineEdit()->installEventFilter( this );
-
-    setValidator( new DateValidator( d->mKeywordMap.keys(), this ) );
-
-    d->mTextChanged = false;
-}
-
-
-DateEdit::~DateEdit()
-{
-    delete d;
-}
-
-
-void DateEdit::setDate(const QDate &date)
-{
-    assignDate( date );
-    d->updateView();
-
-    if( date.isValid() ) {
-        emit dateChanged( date );
-    }
-}
-
-
-QDate DateEdit::date() const
-{
-    return d->mDate;
-}
-
-
-void DateEdit::setMinimumDate(const QDate &minDate, const QString &errorMsg)
-{
-    d->mMinDate = minDate;
-
-    if( d->mMinDate.isValid() && date().isValid() && date() < d->mMinDate ) {
-        setDate( d->mMinDate );
-    }
-
-    d->mMinDateErrString = errorMsg;
-}
-
-
-QDate DateEdit::minimumDate() const
-{
-    return d->mMinDate;
-}
-
-
-void DateEdit::setMaximumDate(const QDate& maxDate, const QString& errorMsg)
-{
-    d->mMaxDate = maxDate;
-
-    if( d->mMaxDate.isValid() && date().isValid() && date() > d->mMaxDate ) {
-        setDate( d->mMaxDate );
-    }
-
-    d->mMaxDateErrString = errorMsg;
-}
-
-
-QDate DateEdit::maximumDate() const
-{
-    return d->mMaxDate;
-}
-
-
-void DateEdit::setDateRange(const QDate& earliest, const QDate& latest,
-                            const QString& earlyErrorMsg, const QString& \
                lateErrorMsg)
-{
-    setMinimumDate( earliest, earlyErrorMsg );
-    setMaximumDate( latest, lateErrorMsg );
-}
-
-
-void DateEdit::setReadOnly(bool readOnly)
-{
-    d->mReadOnly = readOnly;
-    lineEdit()->setReadOnly( readOnly );
-}
-
-
-bool DateEdit::isReadOnly() const
-{
-    return d->mReadOnly;
-}
-
-
-void DateEdit::showPopup()
-{
-    if( d->mReadOnly ) {
-        return;
-    }
-
-    const QRect desk =
-#if defined(HAVE_KDE)
-            KGlobalSettings::desktopGeometry( this );
-#else
-            QApplication::desktop()->screenGeometry( this );
-#endif
-
-    QPoint popupPoint = mapToGlobal( QPoint( 0, 0 ) );
-
-    const int dateFrameHeight = d->mPopup->sizeHint().height();
-
-    if( popupPoint.y() + height() + dateFrameHeight > desk.bottom() ) {
-        popupPoint.setY( popupPoint.y() - dateFrameHeight );
-    }
-    else {
-        popupPoint.setY( popupPoint.y() + height() );
-    }
-
-    const int dateFrameWidth = d->mPopup->sizeHint().width();
-    if( popupPoint.x() + dateFrameWidth > desk.right() ) {
-        popupPoint.setX( desk.right() - dateFrameWidth );
-    }
-
-    if( popupPoint.x() < desk.left() ) {
-        popupPoint.setX( desk.left() );
-    }
-
-    if( popupPoint.y() < desk.top() ) {
-        popupPoint.setY( desk.top() );
-    }
-
-    if( d->mDate.isValid() ) {
-        d->mPopup->setDate( d->mDate );
-    }
-    else {
-        d->mPopup->setDate( QDate::currentDate() );
-    }
-
-    d->mPopup->popup( popupPoint );
-
-    // The combo box is now shown pressed. Make it show not pressed again
-    // by causing its (invisible) list box to emit a 'selected' signal.
-    // First, ensure that the list box contains the date currently displayed.
-    const QDate date = d->parseDate();
-    assignDate( date );
-    d->updateView();
-
-    // Now, simulate an Enter to unpress it
-    QAbstractItemView *lb = view();
-    if( lb ) {
-        lb->setCurrentIndex( lb->model()->index( 0, 0 ) );
-        QKeyEvent *keyEvent = new QKeyEvent( QEvent::KeyPress, Qt::Key_Enter, \
                Qt::NoModifier );
-        QApplication::postEvent( lb, keyEvent );
-    }
-}
-
-
-void DateEdit::focusOutEvent(QFocusEvent *event)
-{
-    if( d->mTextChanged ) {
-        d->lineEnterPressed();
-        d->mTextChanged = false;
-    }
-
-    QComboBox::focusOutEvent( event );
-}
-
-
-void DateEdit::keyPressEvent(QKeyEvent *event)
-{
-    int step = 0;
-
-    if( event->key() == Qt::Key_Up ) {
-        step = 1;
-    }
-    else if( event->key() == Qt::Key_Down ) {
-        step = -1;
-    }
-
-    if( step && !d->mReadOnly ) {
-        QDate date = d->parseDate();
-        if( date.isValid() ) {
-            date = date.addDays( step );
-            if( assignDate( date ) ) {
-                d->updateView();
-                d->newDateEntered( date );
-            }
-        }
-    }
-
-    QComboBox::keyPressEvent( event );
-}
-
-
-bool DateEdit::eventFilter(QObject *object, QEvent *event)
-{
-    if( object == lineEdit() ) {
-        // We only process the focus out event if the text has changed
-        // since we got focus
-        if( (event->type() == QEvent::FocusOut) && d->mTextChanged ) {
-            d->lineEnterPressed();
-            d->mTextChanged = false;
-        }
-        else if ( event->type() == QEvent::KeyPress ) {
-            // Up and down arrow keys step the date
-            QKeyEvent *keyEvent = (QKeyEvent *)event;
-
-            if( keyEvent->key() == Qt::Key_Return ) {
-                d->lineEnterPressed();
-                return true;
-            }
-        }
-    }
-    else {
-        // It's a date picker event
-        switch( event->type() ) {
-            case QEvent::MouseButtonDblClick:
-            case QEvent::MouseButtonPress:
-            {
-                QMouseEvent *mouseEvent = (QMouseEvent*)event;
-                if( !d->mPopup->rect().contains( mouseEvent->pos() ) ) {
-                    const QPoint globalPos = d->mPopup->mapToGlobal( \
                mouseEvent->pos() );
-
-                    if( QApplication::widgetAt( globalPos ) == this ) {
-                        // The date picker is being closed by a click on the
-                        // DateEdit widget. Avoid popping it up again immediately.
-                        d->mDiscardNextMousePress = true;
-                    }
-                }
-            }
-            default:
-                break;
-        }
-    }
-
-    return false;
-}
-
-
-void DateEdit::mousePressEvent(QMouseEvent *event)
-{
-    if( event->button() == Qt::LeftButton && d->mDiscardNextMousePress ) {
-        d->mDiscardNextMousePress = false;
-        return;
-    }
-
-    QComboBox::mousePressEvent( event );
-}
-
-
-bool DateEdit::assignDate(const QDate &date)
-{
-    d->mDate = date;
-    d->mTextChanged = false;
-
-    return true;
-}
-
-
-void DateEdit::lineEnterPressed()
-{
-    d->lineEnterPressed();
-}
-
-
-void DateEdit::slotTextChanged(const QString &str)
-{
-    d->slotTextChanged( str );
-}
-
-
-void DateEdit::dateSelected(const QDate &dt)
-{
-    d->dateSelected( dt );
-}
-
-
-// kate: word-wrap off; encoding utf-8; indent-width 4; tab-width 4; line-numbers \
on; mixed-indent off; remove-trailing-space-save on; replace-tabs-save on; \
                replace-tabs on; space-indent on;
-// vim:set spell et sw=4 ts=4 nowrap cino=l1,cs,U1:
diff --git a/gui/dateedit.h b/gui/dateedit.h
deleted file mode 100644
index d37a7f4..0000000
--- a/gui/dateedit.h
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- * Copyright 2010 by Stefan Böhmann <kde@hilefoks.org>
- *
- * Based on KDateEdit (part of libkdepim)
- *   Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
- *   Copyright (c) 2002,2010 David Jarvie <djarvie@kde.org>
- *   Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
- */
-#ifndef KNIPPTASCH_KDEPIM_KDATEEDIT_H
-#define KNIPPTASCH_KDEPIM_KDATEEDIT_H
-
-#include <QtCore/QDate>
-
-#if defined( HAVE_KDE )
-#include <KComboBox>
-#else
-#include <QComboBox>
-#endif
-
-
-class QEvent;
-class QMouseEvent;
-class QStatusBar;
-
-
-/**
-  @short A date editing widget that consists of an editable combo box.
-
-  The combo box contains the date in text form, and clicking the combo
-  box arrow will display a 'popup' style date picker.
-
-  This widget also supports advanced features like allowing the user
-  to type in the day name to get the date. The following keywords
-  are supported (in the native language): tomorrow, yesterday, today,
-  monday, tuesday, wednesday, thursday, friday, saturday, sunday.
-  The user may also use the up and down arrow on the keyboard to
-  increment and decrement the date.
-
-  Upper and/or lower limits may be set on the range of dates which the
-  user is allowed to enter.
-
-  @image html kdateedit.png "This is how it looks"
-
-  @author Cornelius Schumacher <schumacher@kde.org>
-  @author Mike Pilone <mpilone@slac.com>
-  @author David Jarvie <djarvie@kde.org>
-  @author Tobias Koenig <tokoe@kde.org>
-  @author Stefan Böhmann <kde@hilefoks.org>
-*/
-
-#if defined( HAVE_KDE )
-class DateEdit : public KComboBox
-#else
-class DateEdit : public QComboBox
-#endif
-{
-    Q_OBJECT
-    Q_PROPERTY(QDate date READ date WRITE setDate USER true)
-
-    public:
-        /**
-         * Creates a new date edit.
-         *
-         * @param parent The parent widget.
-         */
-        explicit DateEdit(QWidget *parent = 0);
-
-        /**
-         * Destroys the date edit.
-         */
-        virtual ~DateEdit();
-
-        /**
-         * Returns the date entered.
-         *
-         * @note This date could be invalid, you have to check validity yourself.
-         */
-        QDate date() const;
-
-        /**
-         * Sets the earliest date which can be entered.
-         *
-         * @param date Earliest date allowed, or invalid to remove the minimum \
                limit.
-         * @param errorMsg Error message to be displayed when a date earlier than
-         *                 @p date is entered. Set to QString() to use the default
-         *                 error message.
-         *
-         * @see setDateRange()
-         */
-        void setMinimumDate(const QDate &date, const QString &errorMsg = QString());
-
-        /**
-         * Returns the earliest date which can be entered.
-         * If there is no minimum date, returns an invalid date.
-         */
-        QDate minimumDate() const;
-
-        /**
-         * Sets the latest date which can be entered.
-         *
-         * @param date Latest date allowed, or invalid to remove the maximum limit.
-         * @param errorMsg Error message to be displayed when a date later than
-         *                 @p date is entered. Set to QString() to use the default
-         *                 error message.
-         *
-         * @see setDateRange()
-         */
-        void setMaximumDate(const QDate& date, const QString& errorMsg = QString());
-
-        /**
-         * Returns the latest date which can be entered.
-         * If there is no maximum date, returns an invalid date.
-         */
-        QDate maximumDate() const;
-
-        /**
-         * Sets the range of dates which can be entered.
-         *
-         * @param earliest Earliest date allowed, or invalid to remove the minimum \
                limit.
-         * @param latest   Latest date allowed, or invalid to remove the maximum \
                limit.
-         * @param earlyErrorMsg Error message to be displayed when a date earlier \
                than
-         *                  @p earliest is entered. Set to QString() to use the \
                default
-         *                  error message.
-         * @param lateErrorMsg Error message to be displayed when a date later than
-         *                  @p latest is entered. Set to QString() to use the \
                default
-         *                  error message.
-         *
-         * @see setMinimumDate(), setMaximumDate()
-         */
-        void setDateRange(const QDate &earliest, const QDate &latest,
-                            const QString &earlyErrorMsg = QString(),
-                            const QString &lateErrorMsg = QString());
-
-        /**
-         * Sets whether the widget is read-only for the user. If read-only, the
-         * date pop-up is inactive, and the displayed date cannot be edited.
-         *
-         * @param readOnly True to set the widget read-only, false to set it \
                read-write.
-         */
-        void setReadOnly(bool readOnly);
-
-        /**
-         * Returns whether the widget is read-only.
-         */
-        bool isReadOnly() const;
-
-        /**
-         * Shows the date picker popup menu.
-         */
-        virtual void showPopup();
-
-    Q_SIGNALS:
-        /**
-         * This signal is emitted whenever the user has entered a new date.
-         * When the user changes the date by editing the line edit field,
-         * the signal is not emitted until focus leaves the line edit field.
-         * The passed date can be invalid.
-         */
-        void dateEntered(const QDate &date);
-
-        /**
-         * This signal is emitted whenever date is changed.
-         * Unlike dateEdited(), this signal is also emitted when the date is changed
-         * programmatically.
-         *
-         * The passed date can be invalid.
-         */
-        void dateChanged(const QDate &date);
-
-        /**
-         * This signal is emitted whenever the date is edited by the user.
-         * Unlike dateChanged(), this signal is not emitted when the date is changed
-         * programmatically.
-         *
-         * The passed date can be invalid.
-         */
-        void dateEdited(const QDate &date);
-
-    public Q_SLOTS:
-        /**
-         * Sets the date.
-         *
-         * @param date The new date to display. This date must be valid or
-         *             it will not be set
-         */
-        void setDate(const QDate &date);
-
-    protected:
-        virtual bool eventFilter(QObject *obj, QEvent *ev);
-        virtual void mousePressEvent(QMouseEvent *ev);
-        virtual void focusOutEvent(QFocusEvent *ev);
-        virtual void keyPressEvent(QKeyEvent *ev);
-
-        /**
-         * Sets the date, without altering the display.
-         * This method is used internally to set the widget's date value.
-         * As a virtual method, it allows derived classes to perform additional
-         * validation on the date value before it is set. Derived classes should
-         * return true if QDate::isValid(@p date) returns false.
-         *
-         * @param date The new date to set.
-         * @return True if the date was set, false if it was considered invalid
-         *         and remains unchanged.
-         */
-        virtual bool assignDate(const QDate &date);
-
-    private slots:
-        void lineEnterPressed();
-        void slotTextChanged(const QString &str);
-        void dateSelected(const QDate &dt);
-
-    private:
-        //@cond PRIVATE
-        class Private;
-        Private* const d;
-        //@endcond
-};
-
-
-#endif
-
-// kate: word-wrap off; encoding utf-8; indent-width 4; tab-width 4; line-numbers \
on; mixed-indent off; remove-trailing-space-save on; replace-tabs-save on; \
                replace-tabs on; space-indent on;
-// vim:set spell et sw=4 ts=4 nowrap cino=l1,cs,U1:
diff --git a/gui/datepickerpopup.cpp b/gui/datepickerpopup.cpp
deleted file mode 100644
index fbec80c..0000000
--- a/gui/datepickerpopup.cpp
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * Copyright 2010 by Stefan Böhmann <kde@hilefoks.org>
- *
- * Based on KDateEdit (part of libkdepim)
- *   Copyright (c) 2004 Bram Schoenmakers <bramschoenmakers@kde.nl>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
- */
-#include "datepickerpopup.h"
-
-#if defined(HAVE_KDE)
-#include <KDatePicker>
-#include <KLocale>
-#else
-#include <QCalendarWidget>
-#endif
-
-#include <QDateTime>
-#include <QWidgetAction>
-
-
-
-class DatePickerAction : public QWidgetAction
-{
-    public:
-#if defined(HAVE_KDE)
-        DatePickerAction(KDatePicker *widget, QObject *parent)
-#else
-        DatePickerAction(QCalendarWidget *widget, QObject *parent)
-#endif
-          : QWidgetAction( parent ),
-            mDatePicker( widget ),
-            mOriginalParent( widget->parentWidget() )
-        {
-        }
-
-    protected:
-        QWidget *createWidget(QWidget *parent)
-        {
-            mDatePicker->setParent( parent );
-            return mDatePicker;
-        }
-
-        void deleteWidget(QWidget *widget)
-        {
-            if( widget != mDatePicker ) {
-                return;
-            }
-
-            mDatePicker->setParent( mOriginalParent );
-        }
-
-    private:
-#if defined(HAVE_KDE)
-        KDatePicker *mDatePicker;
-#else
-        QCalendarWidget *mDatePicker;
-#endif
-
-        QWidget *mOriginalParent;
-};
-
-
-class DatePickerPopup::Private
-{
-    public:
-        Private(DatePickerPopup *qq)
-          : q( qq ),
-            mDatePicker( 0 )
-        {
-        }
-
-        void buildMenu();
-
-        void slotDateChanged(const QDate &dt);
-        void slotToday();
-        void slotTomorrow();
-        void slotNextWeek();
-        void slotNextMonth();
-        void slotNoDate();
-
-        DatePickerPopup *q;
-
-#if defined(HAVE_KDE)
-        KDatePicker *mDatePicker;
-#else
-        QCalendarWidget *mDatePicker;
-#endif
-        Modes mModes;
-};
-
-
-void DatePickerPopup::Private::buildMenu()
-{
-    if( q->isVisible() ) {
-        return;
-    }
-
-    q->clear();
-
-    if( mModes & DatePicker ) {
-        q->addAction( new DatePickerAction( mDatePicker, q ) );
-
-        if( (mModes & NoDate) || (mModes & Words) ) {
-            q->addSeparator();
-        }
-    }
-
-    if( mModes & Words ) {
-        q->addAction( tr( "&Today" ), q, SLOT( slotToday() ) );
-        q->addAction( tr( "To&morrow" ), q, SLOT( slotTomorrow() ) );
-        q->addAction( tr( "Next &Week" ), q, SLOT( slotNextWeek() ) );
-        q->addAction( tr( "Next M&onth" ), q, SLOT( slotNextMonth() ) );
-
-        if( mModes & NoDate ) {
-            q->addSeparator();
-        }
-    }
-
-    if( mModes & NoDate ) {
-        q->addAction( tr( "No Date" ), q, SLOT( slotNoDate() ) );
-    }
-}
-
-
-void DatePickerPopup::Private::slotDateChanged(const QDate &date)
-{
-    emit q->dateChanged( date );
-    q->hide();
-}
-
-
-void DatePickerPopup::Private::slotToday()
-{
-    emit q->dateChanged( QDate::currentDate() );
-}
-
-
-void DatePickerPopup::Private::slotTomorrow()
-{
-    emit q->dateChanged( QDate::currentDate().addDays( 1 ) );
-}
-
-
-void DatePickerPopup::Private::slotNoDate()
-{
-    emit q->dateChanged( QDate() );
-}
-
-
-void DatePickerPopup::Private::slotNextWeek()
-{
-    emit q->dateChanged( QDate::currentDate().addDays( 7 ) );
-}
-
-
-void DatePickerPopup::Private::slotNextMonth()
-{
-    emit q->dateChanged( QDate::currentDate().addMonths( 1 ) );
-}
-
-
-
-DatePickerPopup::DatePickerPopup(Modes modes, const QDate &date, QWidget *parent)
-  : QMenu( parent ),
-    d( new Private( this ) )
-{
-    d->mModes = modes;
-
-#if defined(HAVE_KDE)
-    d->mDatePicker = new KDatePicker( this );
-    d->mDatePicker->setCloseButton( false );
-
-    connect( d->mDatePicker, SIGNAL( dateEntered( const QDate& ) ),
-            this, SLOT( slotDateChanged( const QDate& ) ) );
-    connect( d->mDatePicker, SIGNAL( dateSelected( const QDate& ) ),
-            this, SLOT( slotDateChanged( const QDate& ) ) );
-#else
-    d->mDatePicker = new QCalendarWidget( this );
-
-    connect( d->mDatePicker, SIGNAL( activated( const QDate& ) ),
-            this, SLOT( slotDateChanged( const QDate& ) ) );
-    connect( d->mDatePicker, SIGNAL( clicked( const QDate& ) ),
-            this, SLOT( slotDateChanged( const QDate& ) ) );
-#endif
-
-    setDate( date );
-    d->buildMenu();
-}
-
-
-DatePickerPopup::~DatePickerPopup()
-{
-    delete d;
-}
-
-
-void DatePickerPopup::setDate(const QDate &date)
-{
-#if defined(HAVE_KDE)
-    d->mDatePicker->setDate( date );
-#else
-    d->mDatePicker->setSelectedDate( date );
-#endif
-}
-
-
-void DatePickerPopup::slotDateChanged(const QDate &date)
-{
-    d->slotDateChanged( date );
-}
-
-
-void DatePickerPopup::slotToday()
-{
-    d->slotToday();
-}
-
-
-void DatePickerPopup::slotTomorrow()
-{
-    d->slotTomorrow();
-}
-
-
-void DatePickerPopup::slotNextWeek()
-{
-    d->slotNextWeek();
-}
-
-
-void DatePickerPopup::slotNextMonth()
-{
-    d->slotNextMonth();
-}
-
-
-void DatePickerPopup::slotNoDate()
-{
-    d->slotNoDate();
-}
-
-
-//#include "datepickerpopup.moc"
-
-// kate: word-wrap off; encoding utf-8; indent-width 4; tab-width 4; line-numbers \
on; mixed-indent off; remove-trailing-space-save on; replace-tabs-save on; \
                replace-tabs on; space-indent on;
-// vim:set spell et sw=4 ts=4 nowrap cino=l1,cs,U1:
diff --git a/gui/datepickerpopup.h b/gui/datepickerpopup.h
deleted file mode 100644
index dc50c1e..0000000
--- a/gui/datepickerpopup.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright 2010 by Stefan Böhmann <kde@hilefoks.org>
- *
- * Based on KDateEdit (part of libkdepim)
- *   Copyright (c) 2004 Bram Schoenmakers <bramschoenmakers@kde.nl>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
- */
-#ifndef KNIPPTASCH_DATEPICKERPOPUP_H
-#define KNIPPTASCH_DATEPICKERPOPUP_H
-
-#include <QtCore/QDate>
-#include <QtGui/QMenu>
-
-
-/**
- * @short This menu helps the user to select a date quickly.
- *
- * This menu helps the user to select a date quickly. It offers various
- * modes of selecting, e.g. with a DatePicker or with words like "Tomorrow".
- *
- * The available modes are:
- *
- * @li NoDate: A menu-item with "No Date". If chosen, the datepicker will emit
- *     a null QDate.
- * @li DatePicker: Shows a DatePicker-widget.
- * @li Words: Shows items like "Today", "Tomorrow" or "Next Week".
- *
- * @author Bram Schoenmakers <bram_s@softhome.net>
- */
-class DatePickerPopup: public QMenu
-{
-    Q_OBJECT
-
-    public:
-        /**
-         * Describes the available selection modes.
-         */
-        enum Mode
-        {
-            NoDate = 1,     ///< A menu-item with "No Date". Will always return an \
                invalid date.
-            DatePicker = 2, ///< A menu-item with a DatePicker.
-            Words = 4       ///< A menu-item with list of words that describe a \
                date.
-        };
-
-        /**
-         * Describes the a set of combined modes.
-         */
-        Q_DECLARE_FLAGS( Modes, Mode )
-
-        /**
-         * Creates a new date picker popup.
-         *
-         * @param modes The selection modes that shall be offered
-         * @param date The initial date of date picker widget.
-         * @param parent The parent object.
-         */
-        explicit DatePickerPopup(Modes modes = DatePicker,
-                                 const QDate &date = QDate::currentDate(),
-                                 QWidget *parent = 0);
-
-        /**
-         * Destroys the date picker popup.
-         */
-        ~DatePickerPopup();
-
-    public Q_SLOTS:
-        /**
-         * Sets the current @p date.
-         */
-        void setDate(const QDate &date);
-
-    Q_SIGNALS:
-        /**
-         * This signal is emitted whenever the user has selected a new date.
-         *
-         * @param date The new date.
-         */
-        void dateChanged(const QDate &date);
-
-    private slots:
-        void slotDateChanged(const QDate &dt);
-        void slotToday();
-        void slotTomorrow();
-        void slotNextWeek();
-        void slotNextMonth();
-        void slotNoDate();
-
-    private:
-        //@cond PRIVATE
-        class Private;
-        Private* const d;
-        //@endcond
-};
-
-
-Q_DECLARE_OPERATORS_FOR_FLAGS( DatePickerPopup::Modes )
-
-#endif
-
-// kate: word-wrap off; encoding utf-8; indent-width 4; tab-width 4; line-numbers \
on; mixed-indent off; remove-trailing-space-save on; replace-tabs-save on; \
                replace-tabs on; space-indent on;
-// vim:set spell et sw=4 ts=4 nowrap cino=l1,cs,U1:
diff --git a/gui/delegate/datedelegate.cpp b/gui/delegate/datedelegate.cpp
index 36fa459..138399e 100644
--- a/gui/delegate/datedelegate.cpp
+++ b/gui/delegate/datedelegate.cpp
@@ -19,7 +19,7 @@
 #include "accountmodel.h"
 #include "preferences.h"
 
-#include "dateedit.h"
+#include <Knipptasch/DateEdit>
 
 #include <compat/utils.h>
 
@@ -44,7 +44,7 @@ QWidget* DateDelegate::createEditor(QWidget *parent, const \
                QStyleOptionViewItem
         return QStyledItemDelegate::createEditor( parent, option, index );
     }
 
-    DateEdit *input = new DateEdit( parent );
+    DateEdit *input = new DateEdit( Preferences::self()->userDefinedDateFormat(), \
parent );  //    input->setCalendarPopup( true );
 //    input->setCorrectionMode( DateEdit::CorrectToNearestValue );
     input->setFrame( false );


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

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