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

kalarm

deferdlg.cpp

Go to the documentation of this file.
00001 /*
00002  *  deferdlg.cpp  -  dialog to defer an alarm
00003  *  Program:  kalarm
00004  *  Copyright © 2002-2008 by David Jarvie <djarvie@kde.org>
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License along
00017  *  with this program; if not, write to the Free Software Foundation, Inc.,
00018  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  */
00020 
00021 #include "kalarm.h"
00022 
00023 #include <QVBoxLayout>
00024 
00025 #include <kglobal.h>
00026 #include <klocale.h>
00027 #include <kmessagebox.h>
00028 #include <kdebug.h>
00029 
00030 #include <kcal/event.h>
00031 #include <kcal/recurrence.h>
00032 
00033 #include "alarmcalendar.h"
00034 #include "alarmevent.h"
00035 #include "alarmtimewidget.h"
00036 #include "datetime.h"
00037 #include "functions.h"
00038 #include "kalarmapp.h"
00039 #include "deferdlg.moc"
00040 
00041 
00042 DeferAlarmDlg::DeferAlarmDlg(const DateTime& initialDT, bool cancelButton, QWidget* parent)
00043     : KDialog(parent)
00044 {
00045     setWindowModality(Qt::WindowModal);
00046     setCaption(i18nc("@title:window", "Defer Alarm"));
00047     setButtons(Ok | Cancel | User1);
00048     setButtonGuiItem(User1, KGuiItem(i18nc("@action:button", "Cancel Deferral")));
00049     if (!cancelButton)
00050         showButton(User1, false);
00051     connect(this, SIGNAL(okClicked()), SLOT(slotOk()));
00052     connect(this, SIGNAL(user1Clicked()), SLOT(slotCancelDeferral()));
00053 
00054     QWidget* page = new QWidget(this);
00055     setMainWidget(page);
00056     QVBoxLayout* layout = new QVBoxLayout(page);
00057     layout->setMargin(0);
00058     layout->setSpacing(spacingHint());
00059 
00060     mTimeWidget = new AlarmTimeWidget(AlarmTimeWidget::DEFER_TIME, page);
00061     mTimeWidget->setDateTime(initialDT);
00062     mTimeWidget->setMinDateTimeIsCurrent();
00063     connect(mTimeWidget, SIGNAL(pastMax()), SLOT(slotPastLimit()));
00064     layout->addWidget(mTimeWidget);
00065     layout->addSpacing(spacingHint());
00066 
00067     setButtonWhatsThis(Ok, i18nc("@info:whatsthis", "Defer the alarm until the specified time."));
00068     setButtonWhatsThis(User1, i18nc("@info:whatsthis", "Cancel the deferred alarm. This does not affect future recurrences."));
00069 }
00070 
00071 
00072 /******************************************************************************
00073 *  Called when the OK button is clicked.
00074 */
00075 void DeferAlarmDlg::slotOk()
00076 {
00077     mAlarmDateTime = mTimeWidget->getDateTime(&mDeferMinutes);
00078     if (!mAlarmDateTime.isValid())
00079         return;
00080     KAEvent::DeferLimitType limitType;
00081     DateTime endTime;
00082     if (!mLimitEventID.isEmpty())
00083     {
00084         // Get the event being deferred
00085         const KAEvent* event = AlarmCalendar::getEvent(mLimitEventID);
00086         if (event)
00087             endTime = event->deferralLimit(&limitType);
00088     }
00089     else
00090     {
00091         endTime = mLimitDateTime;
00092         limitType = mLimitDateTime.isValid() ? KAEvent::LIMIT_MAIN : KAEvent::LIMIT_NONE;
00093     }
00094     if (endTime.isValid()  &&  mAlarmDateTime > endTime)
00095     {
00096         QString text;
00097         switch (limitType)
00098         {
00099             case KAEvent::LIMIT_REPETITION:
00100                 text = i18nc("@info", "Cannot defer past the alarm's next sub-repetition (currently %1)",
00101                              endTime.formatLocale());
00102                 break;
00103             case KAEvent::LIMIT_RECURRENCE:
00104                 text = i18nc("@info", "Cannot defer past the alarm's next recurrence (currently %1)",
00105                              endTime.formatLocale());
00106                 break;
00107             case KAEvent::LIMIT_REMINDER:
00108                 text = i18nc("@info", "Cannot defer past the alarm's next reminder (currently %1)",
00109                             endTime.formatLocale());
00110                 break;
00111             case KAEvent::LIMIT_MAIN:
00112                 text = i18nc("@info", "Cannot defer reminder past the main alarm time (%1)",
00113                             endTime.formatLocale());
00114                 break;
00115             case KAEvent::LIMIT_NONE:
00116                 break;   // can't happen with a valid endTime
00117         }
00118         KMessageBox::sorry(this, text);
00119     }
00120     else
00121         accept();
00122 }
00123 
00124 /******************************************************************************
00125 * Select the 'Time from now' radio button and preset its value.
00126 */
00127 void DeferAlarmDlg::setDeferMinutes(int minutes)
00128 {
00129     mTimeWidget->selectTimeFromNow(minutes);
00130 }
00131 
00132 /******************************************************************************
00133 *  Called the maximum date/time for the date/time edit widget has been passed.
00134 */
00135 void DeferAlarmDlg::slotPastLimit()
00136 {
00137     enableButtonOk(false);
00138 }
00139 
00140 /******************************************************************************
00141 *  Set the time limit for deferral based on the next occurrence of the alarm
00142 *  with the specified ID.
00143 */
00144 void DeferAlarmDlg::setLimit(const DateTime& limit)
00145 {
00146     mLimitEventID .clear();
00147     mLimitDateTime = limit;
00148     mTimeWidget->setMaxDateTime(mLimitDateTime);
00149 }
00150 
00151 /******************************************************************************
00152 *  Set the time limit for deferral based on the next occurrence of the alarm
00153 *  with the specified ID.
00154 */
00155 DateTime DeferAlarmDlg::setLimit(const QString& eventID)
00156 {
00157     mLimitEventID = eventID;
00158     const KAEvent* event = AlarmCalendar::getEvent(mLimitEventID);
00159     mLimitDateTime = event ? event->deferralLimit() : DateTime();
00160     mTimeWidget->setMaxDateTime(mLimitDateTime);
00161     return mLimitDateTime;
00162 }
00163 
00164 /******************************************************************************
00165 *  Called when the Cancel Deferral button is clicked.
00166 */
00167 void DeferAlarmDlg::slotCancelDeferral()
00168 {
00169     mAlarmDateTime = DateTime();
00170     accept();
00171 }

kalarm

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

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal