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

knotes

  • sources
  • kde-4.12
  • kdepim
  • knotes
  • alarms
knotealarmdialog.cpp
Go to the documentation of this file.
1 /*******************************************************************
2  KNotes -- Notes for the KDE project
3 
4  Copyright (c) 2005, Michael Brade <brade@kde.org>
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License
8  as published by the Free Software Foundation; either version 2
9  of the License, or (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 
20  In addition, as a special exception, the copyright holders give
21  permission to link the code of this program with any edition of
22  the Qt library by Trolltech AS, Norway (or with modified versions
23  of Qt that use the same license as Qt), and distribute linked
24  combinations including the two. You must obey the GNU General
25  Public License in all respects for all of the code used other than
26  Qt. If you modify this file, you may extend this exception to
27  your version of the file, but you are not obligated to do so. If
28  you do not wish to do so, delete this exception statement from
29  your version.
30 *******************************************************************/
31 
32 #include "knotealarmdialog.h"
33 
34 #include <kcal/alarm.h>
35 #include <kcal/journal.h>
36 
37 #include <KDateComboBox>
38 #include <KLocale>
39 #include <KTimeComboBox>
40 #include <KVBox>
41 
42 #include <QButtonGroup>
43 #include <QGroupBox>
44 #include <QRadioButton>
45 #include <QVBoxLayout>
46 
47 KNoteAlarmDialog::KNoteAlarmDialog( const QString &caption, QWidget *parent )
48  : KDialog( parent )
49 {
50  setCaption( caption );
51  setButtons( Ok | Cancel );
52  KVBox *page = new KVBox( this );
53  setMainWidget( page );
54 
55  m_buttons = new QButtonGroup( this );
56  QGroupBox *group = new QGroupBox( i18n( "Scheduled Alarm" ), page );
57  QVBoxLayout *layout = new QVBoxLayout;
58  QRadioButton *none = new QRadioButton( i18n( "&No alarm" ) );
59  layout->addWidget( none );
60  m_buttons->addButton( none, 0 );
61 
62  group->setLayout( layout );
63 
64  KHBox *at = new KHBox;
65  QRadioButton *label_at = new QRadioButton( i18n( "Alarm &at:" ), at );
66  m_atDate = new KDateComboBox( at );
67  m_atTime = new KTimeComboBox( at );
68  at->setStretchFactor( m_atDate, 1 );
69  layout->addWidget( at );
70  m_buttons->addButton( label_at, 1 );
71 
72  connect( m_buttons, SIGNAL(buttonClicked(int)),
73  SLOT(slotButtonChanged(int)) );
74  connect( this, SIGNAL(okClicked()), SLOT(slotOk()) );
75 }
76 
77 
78 void KNoteAlarmDialog::setIncidence( KCal::Journal *journal )
79 {
80  m_journal = journal;
81 
82  if ( !m_journal->alarms().isEmpty() ) {
83  KCal::Alarm *alarm = m_journal->alarms().first();
84  if ( alarm->hasTime() ) {
85  m_buttons->button( 1 )->setChecked( true );
86  m_atDate->setDate( alarm->time().date() );
87  m_atTime->setTime( alarm->time().time() );
88  } else {
89  m_buttons->button( 0 )->setChecked( true );
90  }
91  } else {
92  m_buttons->button( 0 )->setChecked( true );
93  slotButtonChanged( m_buttons->checkedId() );
94  }
95 }
96 
97 void KNoteAlarmDialog::slotButtonChanged( int id )
98 {
99  switch ( id ) {
100 
101  case 0:
102  m_atDate->setEnabled( false );
103  m_atTime->setEnabled( false );
104  break;
105 
106  case 1:
107  m_atDate->setEnabled( true );
108  m_atTime->setEnabled( true );
109  break;
110  }
111 }
112 
113 void KNoteAlarmDialog::slotOk()
114 {
115  if ( m_buttons->checkedId() == 0 ) {
116  m_journal->clearAlarms();
117  return;
118  }
119 
120  KCal::Alarm *alarm;
121  if ( m_journal->alarms().isEmpty() ) {
122  alarm = m_journal->newAlarm();
123  alarm->setEnabled( true );
124  alarm->setType( KCal::Alarm::Display );
125  } else {
126  alarm = m_journal->alarms().first();
127  }
128 
129  if ( m_buttons->checkedId() == 1 ) {
130  alarm->setTime( KDateTime( m_atDate->date(), m_atTime->time(),
131  KDateTime::LocalZone ) );
132  }
133 }
134 
135 #include "knotealarmdialog.moc"
knotealarmdialog.h
QWidget
KDialog
KNoteAlarmDialog::KNoteAlarmDialog
KNoteAlarmDialog(const QString &caption, QWidget *parent=0)
Definition: knotealarmdialog.cpp:47
KNoteAlarmDialog::setIncidence
void setIncidence(KCal::Journal *journal)
Definition: knotealarmdialog.cpp:78
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:56:33 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

knotes

Skip menu "knotes"
  • 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

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