[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdepim/knotes
From: Michael Brade <brade () kde ! org>
Date: 2005-01-30 15:17:13
Message-ID: 20050130151713.48FAB1CF40 () office ! kde ! org
[Download RAW message or body]
CVS commit by brade:
Further work on the alarm dialog.
M +1 -0 knote.cpp 1.144
M +66 -21 knotealarmdlg.cpp 1.2
M +19 -2 knotealarmdlg.h 1.2
--- kdepim/knotes/knote.cpp #1.143:1.144
@@ -578,4 +578,5 @@ void KNote::slotSetAlarm()
{
KNoteAlarmDlg dlg( name(), this );
+ dlg.setIncidence( m_journal );
if ( dlg.exec() != QDialog::Accepted )
--- kdepim/knotes/knotealarmdlg.cpp #1.1:1.2
@@ -40,4 +40,7 @@
#include <libkdepim/ktimeedit.h>
+#include <libkcal/journal.h>
+#include <libkcal/alarm.h>
+
#include "knotealarmdlg.h"
@@ -46,25 +49,23 @@ KNoteAlarmDlg::KNoteAlarmDlg( const QStr
: KDialogBase( parent, name, true, caption, Ok|Cancel, Ok )
{
- //enableButtonSeparator( true );
-
QVBox *page = makeVBoxMainWidget();
- QGroupBox *buttons = new QGroupBox( 3, Vertical, i18n("Scheduled Alarm"), page );
- QButtonGroup *group = new QButtonGroup( page );
- group->hide();
+ QGroupBox *group = new QGroupBox( 3, Vertical, i18n("Scheduled Alarm"), page );
+ m_buttons = new QButtonGroup( page );
+ m_buttons->hide();
- QRadioButton *none = new QRadioButton( i18n("No alarm"), buttons );
- group->insert( none );
+ QRadioButton *none = new QRadioButton( i18n("&No alarm"), group );
+ m_buttons->insert( none );
- QHBox *at = new QHBox( buttons );
- QRadioButton *label_at = new QRadioButton( i18n("Alarm at:"), at );
- group->insert( label_at );
- KDateEdit *at_date = new KDateEdit( at );
- KTimeEdit *at_time = new KTimeEdit( at );
- at->setStretchFactor( at_date, 1 );
+ QHBox *at = new QHBox( group );
+ QRadioButton *label_at = new QRadioButton( i18n("Alarm &at:"), at );
+ m_buttons->insert( label_at );
+ m_atDate = new KDateEdit( at );
+ m_atTime = new KTimeEdit( at );
+ at->setStretchFactor( m_atDate, 1 );
- QHBox *in = new QHBox( buttons );
- QRadioButton *label_in = new QRadioButton( i18n("Alarm in:"), in );
- group->insert( label_in );
- KTimeEdit *in_time = new KTimeEdit( in );
+ QHBox *in = new QHBox( group );
+ QRadioButton *label_in = new QRadioButton( i18n("Alarm &in:"), in );
+ m_buttons->insert( label_in );
+ m_inTime = new KTimeEdit( in );
QLabel *in_min = new QLabel( i18n("hours/minutes"), in );
}
@@ -75,4 +75,49 @@ KNoteAlarmDlg::~KNoteAlarmDlg()
}
+void KNoteAlarmDlg::setIncidence( KCal::Journal *journal )
+{
+ m_journal = journal;
+
+ if ( !m_journal->alarms().isEmpty() )
+ {
+ KCal::Alarm *alarm = m_journal->alarms().first();
+ if ( alarm->hasTime() )
+ {
+ m_buttons->setButton( 1 );
+ m_atDate->setDate( alarm->time().date() );
+ m_atTime->setTime( alarm->time().time() );
+ }
+ else if ( alarm->hasStartOffset() )
+ m_buttons->setButton( 2 );
+ else
+ m_buttons->setButton( 0 );
+ }
+ else
+ m_buttons->setButton( 0 );
+}
+
+void KNoteAlarmDlg::slotOk()
+{
+ if ( m_buttons->selectedId() == 0 )
+ {
+ m_journal->clearAlarms();
+ return;
+ }
+
+ KCal::Alarm *alarm;
+ if ( m_journal->alarms().isEmpty() )
+ alarm = m_journal->newAlarm();
+ else
+ alarm = m_journal->alarms().first();
+
+ if ( m_buttons->selectedId() == 1 )
+ alarm->setTime( QDateTime( m_atDate->date(), m_atTime->getTime() ) );
+ else
+ {
+ // TODO
+ }
+
+ KDialogBase::slotOk();
+}
#include "knotealarmdlg.moc"
--- kdepim/knotes/knotealarmdlg.h #1.1:1.2
@@ -35,4 +35,12 @@
#include <kdialogbase.h>
+class QButtonGroup;
+class KDateEdit;
+class KTimeEdit;
+
+namespace KCal {
+ class Journal;
+}
+
class KNoteAlarmDlg : public KDialogBase
@@ -43,6 +51,15 @@ public:
~KNoteAlarmDlg();
-// signals:
-// void newAlarm( Alarm );
+ void setIncidence( KCal::Journal *journal );
+
+protected:
+ virtual void slotOk();
+
+private:
+ QButtonGroup *m_buttons;
+ KCal::Journal *m_journal;
+
+ KDateEdit *m_atDate;
+ KTimeEdit *m_atTime, *m_inTime;
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic