knotes
knotealarmdlg.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include <qlabel.h>
00033 #include <qradiobutton.h>
00034 #include <qbuttongroup.h>
00035 #include <qvbox.h>
00036
00037 #include <klocale.h>
00038
00039 #include <libkdepim/kdateedit.h>
00040 #include <libkdepim/ktimeedit.h>
00041
00042 #include <libkcal/journal.h>
00043 #include <libkcal/alarm.h>
00044
00045 #include "knotealarmdlg.h"
00046
00047
00048 KNoteAlarmDlg::KNoteAlarmDlg( const QString& caption, QWidget *parent, const char *name )
00049 : KDialogBase( parent, name, true, caption, Ok|Cancel, Ok )
00050 {
00051 QVBox *page = makeVBoxMainWidget();
00052 QGroupBox *group = new QGroupBox( 3, Vertical, i18n("Scheduled Alarm"), page );
00053 m_buttons = new QButtonGroup( page );
00054 m_buttons->hide();
00055
00056 QRadioButton *none = new QRadioButton( i18n("&No alarm"), group );
00057 m_buttons->insert( none );
00058
00059 QHBox *at = new QHBox( group );
00060 QRadioButton *label_at = new QRadioButton( i18n("Alarm &at:"), at );
00061 m_buttons->insert( label_at );
00062 m_atDate = new KDateEdit( at );
00063 m_atTime = new KTimeEdit( at );
00064 at->setStretchFactor( m_atDate, 1 );
00065
00066 QHBox *in = new QHBox( group );
00067 QRadioButton *label_in = new QRadioButton( i18n("Alarm &in:"), in );
00068 m_buttons->insert( label_in );
00069 m_inTime = new KTimeEdit( in );
00070 QLabel *in_min = new QLabel( i18n("hours/minutes"), in );
00071
00072 label_in->setEnabled( false );
00073
00074 connect( m_buttons, SIGNAL(clicked( int )), SLOT(slotButtonChanged( int )) );
00075 }
00076
00077
00078 void KNoteAlarmDlg::setIncidence( KCal::Journal *journal )
00079 {
00080 m_journal = journal;
00081
00082 if ( !m_journal->alarms().isEmpty() )
00083 {
00084 KCal::Alarm *alarm = m_journal->alarms().first();
00085 if ( alarm->hasTime() )
00086 {
00087 m_buttons->setButton( 1 );
00088 m_atDate->setDate( alarm->time().date() );
00089 m_atTime->setTime( alarm->time().time() );
00090 }
00091 else if ( alarm->hasStartOffset() )
00092 m_buttons->setButton( 2 );
00093 else
00094 m_buttons->setButton( 0 );
00095 }
00096 else
00097 m_buttons->setButton( 0 );
00098
00099 slotButtonChanged( m_buttons->selectedId() );
00100 }
00101
00102 void KNoteAlarmDlg::slotButtonChanged( int id )
00103 {
00104 switch ( id )
00105 {
00106 case 0:
00107 m_atDate->setEnabled( false );
00108 m_atTime->setEnabled( false );
00109 m_inTime->setEnabled( false );
00110 break;
00111 case 1:
00112 m_atDate->setEnabled( true );
00113 m_atTime->setEnabled( true );
00114 m_inTime->setEnabled( false );
00115 break;
00116 case 2:
00117 m_atDate->setEnabled( false );
00118 m_atTime->setEnabled( false );
00119 m_inTime->setEnabled( true );
00120 }
00121 }
00122
00123 void KNoteAlarmDlg::slotOk()
00124 {
00125 if ( m_buttons->selectedId() == 0 )
00126 {
00127 m_journal->clearAlarms();
00128 KDialogBase::slotOk();
00129 return;
00130 }
00131
00132 KCal::Alarm *alarm;
00133 if ( m_journal->alarms().isEmpty() )
00134 {
00135 alarm = m_journal->newAlarm();
00136 alarm->setEnabled( true );
00137 alarm->setType( KCal::Alarm::Display );
00138 }
00139 else
00140 alarm = m_journal->alarms().first();
00141
00142 if ( m_buttons->selectedId() == 1 )
00143 alarm->setTime( QDateTime( m_atDate->date(), m_atTime->getTime() ) );
00144 else
00145 {
00146
00147 }
00148
00149 KDialogBase::slotOk();
00150 }
00151
00152 #include "knotealarmdlg.moc"
|