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

kalarm

templatepickdlg.cpp

Go to the documentation of this file.
00001 /*
00002  *  templatepickdlg.cpp  -  dialog to choose an alarm template
00003  *  Program:  kalarm
00004  *  Copyright © 2004,2006-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 #include <QResizeEvent>
00025 
00026 #include <klocale.h>
00027 #include <kdebug.h>
00028 
00029 #include "eventlistmodel.h"
00030 #include "functions.h"
00031 #include "shellprocess.h"
00032 #include "templatelistfiltermodel.h"
00033 #include "templatelistview.h"
00034 #include "templatepickdlg.moc"
00035 
00036 static const char TMPL_PICK_DIALOG_NAME[] = "TemplatePickDialog";
00037 
00038 
00039 TemplatePickDlg::TemplatePickDlg(QWidget* parent)
00040     : KDialog(parent)
00041 {
00042     QWidget* topWidget = new QWidget(this);
00043     setMainWidget(topWidget);
00044     setCaption(i18nc("@title:window", "Choose Alarm Template"));
00045     setButtons(Ok|Cancel);
00046     setDefaultButton(Ok);
00047     QVBoxLayout* topLayout = new QVBoxLayout(topWidget);
00048     topLayout->setMargin(0);
00049     topLayout->setSpacing(spacingHint());
00050 
00051     // Display the list of templates, but exclude command alarms if in kiosk mode.
00052     bool includeCmdAlarms = ShellProcess::authorised();
00053     mListFilterModel = new TemplateListFilterModel(EventListModel::templates());
00054     mListFilterModel->setTypeFilter(!includeCmdAlarms);
00055     mListView = new TemplateListView(topWidget);
00056     mListView->setModel(mListFilterModel);
00057     mListView->sortByColumn(TemplateListFilterModel::TemplateNameColumn, Qt::AscendingOrder);
00058     mListView->setSelectionMode(QAbstractItemView::SingleSelection);
00059     mListView->setWhatsThis(i18nc("@info:whatsthis", "Select a template to base the new alarm on."));
00060     connect(mListView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&,const QItemSelection&)), SLOT(slotSelectionChanged()));
00061     // Require a real double click (even if KDE is in single-click mode) to accept the selection
00062     connect(mListView, SIGNAL(doubleClicked(const QModelIndex&)), SLOT(accept()));
00063     topLayout->addWidget(mListView);
00064 
00065     slotSelectionChanged();        // enable or disable the OK button
00066 
00067     QSize s;
00068     if (KAlarm::readConfigWindowSize(TMPL_PICK_DIALOG_NAME, s))
00069         resize(s);
00070 }
00071 
00072 /******************************************************************************
00073 * Return the currently selected alarm template, or 0 if none.
00074 */
00075 const KAEvent* TemplatePickDlg::selectedTemplate() const
00076 {
00077     return mListView->selectedEvent();
00078 }
00079 
00080 /******************************************************************************
00081 * Called when the template selection changes.
00082 * Enable/disable the OK button depending on whether anything is selected.
00083 */
00084 void TemplatePickDlg::slotSelectionChanged()
00085 {
00086     enableButtonOk(!mListView->selectionModel()->selectedRows().isEmpty());
00087 }
00088 
00089 /******************************************************************************
00090 *  Called when the dialog's size has changed.
00091 *  Records the new size in the config file.
00092 */
00093 void TemplatePickDlg::resizeEvent(QResizeEvent* re)
00094 {
00095     if (isVisible())
00096         KAlarm::writeConfigWindowSize(TMPL_PICK_DIALOG_NAME, re->size());
00097     KDialog::resizeEvent(re);
00098 }

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