• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

kmail

  • sources
  • kde-4.14
  • kdepim
  • kmail
  • followupreminder
followupreminderselectdatedialog.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2014-2015 Montel Laurent <montel@kde.org>
3 
4  This program is free software; you can redistribute it and/or modify it
5  under the terms of the GNU General Public License, version 2, as
6  published by the Free Software Foundation.
7 
8  This program is distributed in the hope that it will be useful, but
9  WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License along
14  with this program; if not, write to the Free Software Foundation, Inc.,
15  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 
19 #include "followupreminderselectdatedialog.h"
20 
21 #include <KLocalizedString>
22 #include <KSharedConfig>
23 #include <KDatePicker>
24 #include <KMessageBox>
25 
26 #include <akonadi/collectioncombobox.h>
27 
28 #include <KCalCore/Todo>
29 
30 #include <QVBoxLayout>
31 #include <QFormLayout>
32 #include <QLabel>
33 #include <QLineEdit>
34 #include <kdatecombobox.h>
35 
36 
37 FollowUpReminderSelectDateDialog::FollowUpReminderSelectDateDialog(QWidget *parent, QAbstractItemModel *model)
38  : KDialog(parent)
39 {
40  setCaption( i18n( "Select Date" ) );
41  setButtons( Ok|Cancel );
42  setDefaultButton( Ok );
43  setModal( true );
44 
45  QWidget *mainWidget = new QWidget( this );
46  QVBoxLayout *mainLayout = new QVBoxLayout( mainWidget );
47  mainLayout->setSpacing( KDialog::spacingHint() );
48  mainLayout->setMargin( KDialog::marginHint() );
49  QFormLayout *formLayout = new QFormLayout;
50  mainLayout->addLayout(formLayout);
51 
52  mDateComboBox = new KDateComboBox;
53  mDateComboBox->setMinimumDate(QDate::currentDate());
54  mDateComboBox->setObjectName(QLatin1String("datecombobox"));
55 
56  QDate currentDate = QDate::currentDate();
57  currentDate = currentDate.addDays(1);
58  mDateComboBox->setDate(currentDate);
59 
60  formLayout->addRow(i18n("Date:"), mDateComboBox);
61 
62  mCollectionCombobox = new Akonadi::CollectionComboBox(model);
63  mCollectionCombobox->setMinimumWidth(250);
64  mCollectionCombobox->setAccessRightsFilter(Akonadi::Collection::CanCreateItem);
65  mCollectionCombobox->setMimeTypeFilter( QStringList() << KCalCore::Todo::todoMimeType() );
66  mCollectionCombobox->setObjectName(QLatin1String("collectioncombobox"));
67  connect(mCollectionCombobox, SIGNAL(currentIndexChanged(int)), SLOT(updateOkButton()));
68 
69 
70  formLayout->addRow(i18n("Store ToDo in:"), mCollectionCombobox);
71 
72  connect(mDateComboBox->lineEdit(), SIGNAL(textChanged(QString)), SLOT(slotDateChanged()));
73  setMainWidget( mainWidget );
74 }
75 
76 FollowUpReminderSelectDateDialog::~FollowUpReminderSelectDateDialog()
77 {
78 }
79 
80 void FollowUpReminderSelectDateDialog::updateOkButton()
81 {
82  enableButtonOk( !mDateComboBox->lineEdit()->text().isEmpty()
83  && mDateComboBox->date().isValid()
84  && (mCollectionCombobox->count() > 0)
85  && mCollectionCombobox->currentCollection().isValid());
86 }
87 
88 void FollowUpReminderSelectDateDialog::slotDateChanged()
89 {
90  updateOkButton();
91 }
92 
93 QDate FollowUpReminderSelectDateDialog::selectedDate() const
94 {
95  return mDateComboBox->date();
96 }
97 
98 Akonadi::Collection FollowUpReminderSelectDateDialog::collection() const
99 {
100  return mCollectionCombobox->currentCollection();
101 }
102 
103 void FollowUpReminderSelectDateDialog::accept()
104 {
105  const QDate date = selectedDate();
106  if (date <= QDate::currentDate()) {
107  KMessageBox::error(this, i18n("The selected date must be greater than the current date."), i18n("Invalid date"));
108  return;
109  }
110  KDialog::accept();
111 }
followupreminderselectdatedialog.h
QWidget
date
time_t date() const
KDialog
FollowUpReminderSelectDateDialog::~FollowUpReminderSelectDateDialog
~FollowUpReminderSelectDateDialog()
Definition: followupreminderselectdatedialog.cpp:76
FollowUpReminderSelectDateDialog::FollowUpReminderSelectDateDialog
FollowUpReminderSelectDateDialog(QWidget *parent=0, QAbstractItemModel *model=0)
Definition: followupreminderselectdatedialog.cpp:37
FollowUpReminderSelectDateDialog::collection
Akonadi::Collection collection() const
Definition: followupreminderselectdatedialog.cpp:98
QVBoxLayout
FollowUpReminderSelectDateDialog::accept
void accept()
Definition: followupreminderselectdatedialog.cpp:103
QDate
QString
FollowUpReminderSelectDateDialog::selectedDate
QDate selectedDate() const
Definition: followupreminderselectdatedialog.cpp:93
QLayout::setMargin
void setMargin(int margin)
QFormLayout::addRow
void addRow(QWidget *label, QWidget *field)
QStringList
QLatin1String
QDate::currentDate
QDate currentDate()
QAbstractItemModel
QDate::addDays
QDate addDays(int ndays) const
QBoxLayout::setSpacing
void setSpacing(int spacing)
QBoxLayout::addLayout
void addLayout(QLayout *layout, int stretch)
QFormLayout
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:34:33 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kmail

Skip menu "kmail"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal