Commit b105f385 authored by Laurent Montel's avatar Laurent Montel 😁

Allow to select collection where we can store task

parent e363ac34
......@@ -23,7 +23,14 @@
#include <KDatePicker>
#include <KMessageBox>
#include <akonadi/collectioncombobox.h>
#include <KCalCore/Todo>
#include <QVBoxLayout>
#include <QFormLayout>
#include <QLabel>
FollowUpReminderSelectDateDialog::FollowUpReminderSelectDateDialog(QWidget *parent)
: KDialog(parent)
......@@ -37,12 +44,24 @@ FollowUpReminderSelectDateDialog::FollowUpReminderSelectDateDialog(QWidget *pare
QVBoxLayout *mainLayout = new QVBoxLayout( mainWidget );
mainLayout->setSpacing( KDialog::spacingHint() );
mainLayout->setMargin( KDialog::marginHint() );
QFormLayout *formLayout = new QFormLayout;
mainLayout->addLayout(formLayout);
mDatePicker = new KDatePicker;
mDatePicker->setObjectName(QLatin1String("datepicker"));
QDate currentDate = QDate::currentDate();
currentDate = currentDate.addDays(1);
mDatePicker->setDate(currentDate);
mainLayout->addWidget(mDatePicker);
formLayout->addRow(i18n("Date:"), mDatePicker);
mCollectionCombobox = new Akonadi::CollectionComboBox;
mCollectionCombobox->setAccessRightsFilter(Akonadi::Collection::CanCreateItem);
mCollectionCombobox->setMimeTypeFilter( QStringList() << KCalCore::Todo::todoMimeType() );
mCollectionCombobox->setObjectName(QLatin1String("collectioncombobox"));
formLayout->addRow(i18n("Store ToDo in:"), mCollectionCombobox);
setMainWidget( mainWidget );
readConfig();
......@@ -73,6 +92,11 @@ QDate FollowUpReminderSelectDateDialog::selectedDate() const
return mDatePicker->date();
}
Akonadi::Collection FollowUpReminderSelectDateDialog::collection() const
{
return mCollectionCombobox->currentCollection();
}
void FollowUpReminderSelectDateDialog::accept()
{
const QDate date = selectedDate();
......
......@@ -19,6 +19,10 @@
#define FOLLOWUPREMINDERSELECTDATEDIALOG_H
#include <KDialog>
#include <Akonadi/Collection>
namespace Akonadi {
class CollectionComboBox;
}
class KDatePicker;
class FollowUpReminderSelectDateDialog : public KDialog
{
......@@ -31,10 +35,12 @@ public:
void accept();
Akonadi::Collection collection() const;
private:
void readConfig();
void writeConfig();
KDatePicker *mDatePicker;
Akonadi::CollectionComboBox *mCollectionCombobox;
};
#endif // FOLLOWUPREMINDERSELECTDATEDIALOG_H
......@@ -25,5 +25,6 @@ target_link_libraries( identityaddvcarddialogtest ${QT_QTTEST_LIBRARY} ${KDE4_KD
set( kmail_followupreminderselectdatedialog_source followupreminderselectdatedialogtest.cpp ../followupreminder/followupreminderselectdatedialog.cpp )
kde4_add_unit_test( followupreminderselectdatedialogtest ${kmail_followupreminderselectdatedialog_source})
target_link_libraries( followupreminderselectdatedialogtest ${QT_QTTEST_LIBRARY} ${KDE4_KDEUI_LIBS} )
target_link_libraries( followupreminderselectdatedialogtest ${QT_QTTEST_LIBRARY} ${KDE4_KDEUI_LIBS} ${KDEPIMLIBS_AKONADI_LIBS} ${KDEPIMLIBS_AKONADI_CALENDAR_LIBS} ${KDEPIMLIBS_KCALCORE_LIBS})
......@@ -19,6 +19,7 @@
#include "../followupreminder/followupreminderselectdatedialog.h"
#include <KDatePicker>
#include <qtest_kde.h>
#include <Akonadi/CollectionComboBox>
FollowupReminderSelectDateDialogTest::FollowupReminderSelectDateDialogTest(QObject *parent)
......@@ -38,6 +39,8 @@ void FollowupReminderSelectDateDialogTest::shouldHaveDefaultValue()
KDatePicker *datepicker = qFindChild<KDatePicker *>(&dlg, QLatin1String("datepicker"));
QVERIFY(datepicker);
Akonadi::CollectionComboBox *combobox = qFindChild<Akonadi::CollectionComboBox *>(&dlg, QLatin1String("collectioncombobox"));
QVERIFY(combobox);
QDate currentDate = QDate::currentDate();
QCOMPARE(datepicker->date(), currentDate.addDays(1));
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment