kalarm Library API Documentation

deferdlg.cpp

00001 /*
00002  *  deferdlg.cpp  -  dialogue to defer an alarm
00003  *  Program:  kalarm
00004  *  (C) 2002 by David Jarvie  software@astrojar.org.uk
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
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  *
00020  *  As a special exception, permission is given to link this program
00021  *  with any edition of Qt, and distribute the resulting executable,
00022  *  without including the source code for Qt in the source distribution.
00023  */
00024 
00025 #include "kalarm.h"
00026 
00027 #include <qlayout.h>
00028 
00029 #include <kglobal.h>
00030 #include <klocale.h>
00031 #include <kmessagebox.h>
00032 
00033 #include "datetime.h"
00034 #include "deferdlg.moc"
00035 
00036 
00037 DeferAlarmDlg::DeferAlarmDlg(const QString& caption, const QDateTime& initialDT, const QDateTime& limitDT,
00038                              bool cancelButton, QWidget* parent, const char* name)
00039         : KDialogBase(parent, name, true, caption, Ok|Cancel|User1, Ok, false, i18n("Cancel &Deferral")),
00040           limitDateTime(limitDT)
00041 {
00042         if (!cancelButton)
00043                 showButton(User1, false);
00044 
00045         QWidget* page = new QWidget(this);
00046         setMainWidget(page);
00047         QVBoxLayout* layout = new QVBoxLayout(page, marginKDE2, spacingHint());
00048 
00049         timeWidget = new AlarmTimeWidget(AlarmTimeWidget::DEFER_TIME, page, "timeGroup");
00050         timeWidget->setDateTime(initialDT);
00051         layout->addWidget(timeWidget);
00052         layout->addSpacing(KDialog::spacingHint());
00053 
00054         setButtonWhatsThis(Ok, i18n("Defer the alarm until the specified time."));
00055         setButtonWhatsThis(User1, i18n("Cancel the deferred alarm. This does not affect future recurrences."));
00056 }
00057 
00058 
00059 DeferAlarmDlg::~DeferAlarmDlg()
00060 {
00061 }
00062 
00063 
00064 /******************************************************************************
00065 *  Called when the OK button is clicked.
00066 */
00067 void DeferAlarmDlg::slotOk()
00068 {
00069         bool anyTime;
00070         if (!timeWidget->getDateTime(alarmDateTime, anyTime))
00071         {
00072                 if (limitDateTime.isValid()  &&  alarmDateTime >= limitDateTime)
00073                         KMessageBox::sorry(this, i18n("Cannot defer past the alarm's next recurrence (currently %1)")
00074                                                           .arg(KGlobal::locale()->formatDateTime(limitDateTime)));
00075                 else
00076                         accept();
00077         }
00078 }
00079 
00080 /******************************************************************************
00081 *  Called when the Cancel Deferral button is clicked.
00082 */
00083 void DeferAlarmDlg::slotUser1()
00084 {
00085         alarmDateTime = QDateTime();
00086         accept();
00087 }
00088 
00089 /******************************************************************************
00090 *  Called when the Cancel button is clicked.
00091 */
00092 void DeferAlarmDlg::slotCancel()
00093 {
00094         reject();
00095 }
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.4.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sat Oct 18 02:47:26 2003 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001