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

kalarm

latecancel.cpp

Go to the documentation of this file.
00001 /*
00002  *  latecancel.cpp  -  widget to specify cancellation if late
00003  *  Program:  kalarm
00004  *  Copyright © 2004,2005,2007,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 <QStackedWidget>
00024 #include <QVBoxLayout>
00025 #include <QHBoxLayout>
00026 
00027 #include <klocale.h>
00028 #include <kdialog.h>
00029 #include <kcal/duration.h>
00030 
00031 #include "checkbox.h"
00032 #include "latecancel.moc"
00033 
00034 
00035 // Collect these widget labels together to ensure consistent wording and
00036 // translations across different modules.
00037 QString LateCancelSelector::i18n_chk_CancelIfLate()    { return i18nc("@option:check", "Cancel if late"); }
00038 QString LateCancelSelector::i18n_chk_AutoCloseWin()    { return i18nc("@option:check", "Auto-close window after this time"); }
00039 QString LateCancelSelector::i18n_chk_AutoCloseWinLC()  { return i18nc("@option:check", "Auto-close window after late-cancellation time"); }
00040 
00041 
00042 LateCancelSelector::LateCancelSelector(bool allowHourMinute, QWidget* parent)
00043     : QFrame(parent),
00044       mDateOnly(false),
00045       mReadOnly(false),
00046       mAutoCloseShown(false)
00047 {
00048     QString whatsThis = i18nc("@info:whatsthis",
00049                               "<para>If checked, the alarm will be canceled if it cannot be triggered within the "
00050                              "specified period after its scheduled time. Possible reasons for not triggering "
00051                              "include your being logged off, X not running, or <application>KAlarm</application> not running.</para>"
00052                              "<para>If unchecked, the alarm will be triggered at the first opportunity after "
00053                              "its scheduled time, regardless of how late it is.</para>");
00054 
00055     QVBoxLayout* topLayout = new QVBoxLayout(this);
00056     topLayout->setMargin(0);
00057     topLayout->setSpacing(KDialog::spacingHint());
00058 
00059     mStack = new QStackedWidget(this);
00060     topLayout->addWidget(mStack, 0, Qt::AlignLeft);
00061     mCheckboxFrame = new QFrame();
00062     mStack->addWidget(mCheckboxFrame);
00063     QHBoxLayout* hlayout = new QHBoxLayout(mCheckboxFrame);
00064     hlayout->setMargin(0);
00065     mCheckbox = new CheckBox(i18n_chk_CancelIfLate(), mCheckboxFrame);
00066     connect(mCheckbox, SIGNAL(toggled(bool)), SLOT(slotToggled(bool)));
00067     mCheckbox->setWhatsThis(whatsThis);
00068     hlayout->addWidget(mCheckbox, 0, Qt::AlignLeft);
00069 
00070     mTimeSelectorFrame = new QFrame();
00071     mStack->addWidget(mTimeSelectorFrame);
00072     hlayout = new QHBoxLayout(mTimeSelectorFrame);
00073     hlayout->setMargin(0);
00074     mTimeSelector = new TimeSelector(i18nc("@option:check Cancel if late by 10 minutes", "Cancel if late by"), QString(),
00075                                      whatsThis, i18nc("@info:whatsthis", "Enter how late will cause the alarm to be canceled"),
00076                                      allowHourMinute, mTimeSelectorFrame);
00077     connect(mTimeSelector, SIGNAL(toggled(bool)), SLOT(slotToggled(bool)));
00078     hlayout->addWidget(mTimeSelector, 0, Qt::AlignLeft);
00079 
00080     hlayout = new QHBoxLayout();
00081     hlayout->setMargin(0);
00082     hlayout->addSpacing(3*KDialog::spacingHint());
00083     topLayout->addLayout(hlayout);
00084     mAutoClose = new CheckBox(i18n_chk_AutoCloseWin(), this);
00085     mAutoClose->setWhatsThis(i18nc("@info:whatsthis", "Automatically close the alarm window after the expiry of the late-cancellation period"));
00086     hlayout->addWidget(mAutoClose);
00087     hlayout->addStretch();
00088 
00089     mAutoClose->hide();
00090     mAutoClose->setEnabled(false);
00091 }
00092 
00093 /******************************************************************************
00094 *  Set the read-only status.
00095 */
00096 void LateCancelSelector::setReadOnly(bool ro)
00097 {
00098     if ((int)ro != (int)mReadOnly)
00099     {
00100         mReadOnly = ro;
00101         mCheckbox->setReadOnly(mReadOnly);
00102         mTimeSelector->setReadOnly(mReadOnly);
00103         mAutoClose->setReadOnly(mReadOnly);
00104     }
00105 }
00106 
00107 int LateCancelSelector::minutes() const
00108 {
00109     return mTimeSelector->period().asSeconds() / 60;
00110 }
00111 
00112 void LateCancelSelector::setMinutes(int minutes, bool dateOnly, TimePeriod::Units defaultUnits)
00113 {
00114     slotToggled(minutes);
00115     KCal::Duration period;
00116     if (minutes % (24*60))
00117         period = KCal::Duration(minutes * 60, KCal::Duration::Seconds);
00118     else
00119         period = KCal::Duration(minutes / (24*60), KCal::Duration::Days);
00120     mTimeSelector->setPeriod(period, dateOnly, defaultUnits);
00121 }
00122 
00123 void LateCancelSelector::setDateOnly(bool dateOnly)
00124 {
00125     if (dateOnly != mDateOnly)
00126     {
00127         mDateOnly = dateOnly;
00128         if (mTimeSelector->isChecked())      // don't change when it's not visible
00129             mTimeSelector->setDateOnly(dateOnly);
00130     }
00131 }
00132 
00133 void LateCancelSelector::showAutoClose(bool show)
00134 {
00135     if (show)
00136         mAutoClose->show();
00137     else
00138         mAutoClose->hide();
00139     mAutoCloseShown = show;
00140     updateGeometry();
00141 }
00142 
00143 bool LateCancelSelector::isAutoClose() const
00144 {
00145     return mAutoCloseShown  &&  mAutoClose->isEnabled()  &&  mAutoClose->isChecked();
00146 }
00147 
00148 void LateCancelSelector::setAutoClose(bool autoClose)
00149 {
00150     mAutoClose->setChecked(autoClose);
00151 }
00152 
00153 /******************************************************************************
00154 *  Called when either of the checkboxes is toggled.
00155 */
00156 void LateCancelSelector::slotToggled(bool on)
00157 {
00158     mCheckbox->setChecked(on);
00159     mTimeSelector->setChecked(on);
00160     if (on)
00161     {
00162         mTimeSelector->setDateOnly(mDateOnly);
00163         mStack->setCurrentWidget(mTimeSelectorFrame);
00164     }
00165     else
00166         mStack->setCurrentWidget(mCheckboxFrame);
00167     mAutoClose->setEnabled(on);
00168 }

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
  •   doc
  • 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