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

knotes

knotealarmdlg.cpp

Go to the documentation of this file.
00001 /*******************************************************************
00002  KNotes -- Notes for the KDE project
00003 
00004  Copyright (c) 2005, Michael Brade <brade@kde.org>
00005 
00006  This program is free software; you can redistribute it and/or
00007  modify it under the terms of the GNU General Public License
00008  as published by the Free Software Foundation; either version 2
00009  of the License, or (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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019 
00020  In addition, as a special exception, the copyright holders give
00021  permission to link the code of this program with any edition of
00022  the Qt library by Trolltech AS, Norway (or with modified versions
00023  of Qt that use the same license as Qt), and distribute linked
00024  combinations including the two.  You must obey the GNU General
00025  Public License in all respects for all of the code used other than
00026  Qt.  If you modify this file, you may extend this exception to
00027  your version of the file, but you are not obligated to do so.  If
00028  you do not wish to do so, delete this exception statement from
00029  your version.
00030 *******************************************************************/
00031 
00032 #include <QButtonGroup>
00033 #include <QGroupBox>
00034 #include <QRadioButton>
00035 #include <QVBoxLayout>
00036 
00037 #include <klocale.h>
00038 #include <kvbox.h>
00039 
00040 #include <libkdepim/kdateedit.h>
00041 #include <libkdepim/ktimeedit.h>
00042 
00043 #include <kcal/alarm.h>
00044 #include <kcal/journal.h>
00045 
00046 #include "knotealarmdlg.h"
00047 
00048 using namespace KPIM;
00049 
00050 
00051 KNoteAlarmDlg::KNoteAlarmDlg( const QString &caption, QWidget *parent )
00052   : KDialog( parent )
00053 {
00054   setCaption( caption );
00055   setButtons( Ok | Cancel );
00056   KVBox *page = new KVBox( this );
00057   setMainWidget( page );
00058   
00059   m_buttons = new QButtonGroup( this );
00060   QGroupBox *group = new QGroupBox( i18n( "Scheduled Alarm" ), page );
00061   QVBoxLayout *layout = new QVBoxLayout;
00062   QRadioButton *none = new QRadioButton( i18n( "&No alarm" ) );
00063   layout->addWidget( none );
00064   m_buttons->addButton( none, 0 );
00065   
00066   group->setLayout( layout );
00067   
00068   KHBox *at = new KHBox;
00069   QRadioButton *label_at = new QRadioButton( i18n( "Alarm &at:" ), at );
00070   m_atDate = new KDateEdit( at );
00071   m_atTime = new KTimeEdit( at );
00072   at->setStretchFactor( m_atDate, 1 );
00073   layout->addWidget( at );
00074   m_buttons->addButton( label_at, 1 );
00075   
00076   KHBox *in = new KHBox;
00077   QRadioButton *label_in = new QRadioButton( i18n( "Alarm &in:" ), in );
00078   m_inTime = new KTimeEdit( in );
00079   label_in->setEnabled( false ); // TODO
00080   layout->addWidget( in );
00081   m_buttons->addButton( label_in, 2 );
00082   
00083   connect( m_buttons, SIGNAL( buttonClicked( int ) ),
00084            SLOT( slotButtonChanged( int ) ) );
00085   connect( this, SIGNAL( okClicked() ), SLOT( slotOk() ) );
00086 }
00087 
00088 
00089 void KNoteAlarmDlg::setIncidence( KCal::Journal *journal )
00090 {
00091   m_journal = journal;
00092   
00093   if ( !m_journal->alarms().isEmpty() ) {
00094     KCal::Alarm *alarm = m_journal->alarms().first();
00095     if ( alarm->hasTime() ) {
00096       m_buttons->button( 1 )->setChecked( true );
00097       m_atDate->setDate( alarm->time().date() );
00098       m_atTime->setTime( alarm->time().time() );
00099     } else if ( alarm->hasStartOffset() ) {
00100       m_buttons->button( 2 )->setChecked( true );
00101     } else {
00102       m_buttons->button( 0 )->setChecked( true );
00103     }
00104   } else {
00105     m_buttons->button( 0 )->setChecked( true );
00106     slotButtonChanged( m_buttons->checkedId() );
00107   }
00108 }
00109 
00110 void KNoteAlarmDlg::slotButtonChanged( int id )
00111 {
00112   switch ( id ) {
00113     
00114     case 0:
00115       m_atDate->setEnabled( false );
00116       m_atTime->setEnabled( false );
00117       m_inTime->setEnabled( false );
00118       break;
00119     
00120     case 1:
00121       m_atDate->setEnabled( true );
00122       m_atTime->setEnabled( true );
00123       m_inTime->setEnabled( false );
00124       break;
00125     
00126     case 2:
00127       m_atDate->setEnabled( false );
00128       m_atTime->setEnabled( false );
00129       m_inTime->setEnabled( true );
00130       break;
00131   }
00132 }
00133 
00134 void KNoteAlarmDlg::slotOk()
00135 {
00136   if ( m_buttons->checkedId() == 0 ) {
00137     m_journal->clearAlarms();
00138     return;
00139   }
00140   
00141   KCal::Alarm *alarm;
00142   if ( m_journal->alarms().isEmpty() ) {
00143     alarm = m_journal->newAlarm();
00144     alarm->setEnabled( true );
00145     alarm->setType( KCal::Alarm::Display );
00146   } else {
00147     alarm = m_journal->alarms().first();
00148   }
00149   
00150   if ( m_buttons->checkedId() == 1 ) {
00151     alarm->setTime( KDateTime( m_atDate->date(), m_atTime->getTime(),
00152                                KDateTime::LocalZone ) );
00153   } else {
00154     // TODO
00155   }
00156 }
00157 
00158 #include "knotealarmdlg.moc"

knotes

Skip menu "knotes"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • 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