summaryrefslogtreecommitdiff
path: root/core/pim/todo/taskeditoralarms.cpp
authorzecke <zecke>2003-05-12 13:21:59 (UTC)
committer zecke <zecke>2003-05-12 13:21:59 (UTC)
commit9a4c9544a59f8395f2ec5e7c99028570f8bd8bd1 (patch) (side-by-side diff)
tree8af13b984750f743b7f9f06bbf04b531b1a10ff2 /core/pim/todo/taskeditoralarms.cpp
parenta4c8b8912c9e87a2fd76103193e6b4f91c2a2c5d (diff)
downloadopie-9a4c9544a59f8395f2ec5e7c99028570f8bd8bd1.zip
opie-9a4c9544a59f8395f2ec5e7c99028570f8bd8bd1.tar.gz
opie-9a4c9544a59f8395f2ec5e7c99028570f8bd8bd1.tar.bz2
Hospital Hacking Session
make more translatable fix up GUI for Opie1.0 in regards what is implemnted implement setting and removing of Alarms!!!! Show Alarms once they got fired...
Diffstat (limited to 'core/pim/todo/taskeditoralarms.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/taskeditoralarms.cpp190
1 files changed, 176 insertions, 14 deletions
diff --git a/core/pim/todo/taskeditoralarms.cpp b/core/pim/todo/taskeditoralarms.cpp
index 3cb5576..bff3338 100644
--- a/core/pim/todo/taskeditoralarms.cpp
+++ b/core/pim/todo/taskeditoralarms.cpp
@@ -28,49 +28,211 @@
#include "taskeditoralarms.h"
+#include <opie/otodo.h>
+#include <opie/opimnotifymanager.h>
+#include <opie/otimepicker.h>
+
+#include <qpe/datebookmonth.h>
#include <qpe/resource.h>
+#include <qpe/timestring.h>
+#include <qdatetime.h>
#include <qlistview.h>
#include <qpushbutton.h>
+#include <qpopupmenu.h>
#include <qlayout.h>
#include <qwhatsthis.h>
-TaskEditorAlarms::TaskEditorAlarms( QWidget* parent, const char* name, WFlags fl )
+
+class AlarmItem : public QListViewItem {
+public:
+ AlarmItem( QListView*, const OPimAlarm& );
+ ~AlarmItem();
+
+ OPimAlarm alarm()const;
+ void setAlarm( const OPimAlarm& );
+private:
+ QDateTime m_dt;
+ int m_type;
+};
+AlarmItem::AlarmItem( QListView* view, const OPimAlarm& dt)
+ : QListViewItem(view) {
+ setAlarm( dt );
+}
+void AlarmItem::setAlarm( const OPimAlarm& dt ) {
+ m_dt = dt.dateTime();
+ m_type = dt.sound();
+ setText( 0, TimeString::dateString( m_dt.date() ) );
+ setText( 1, TimeString::timeString( m_dt.time() ) );
+ setText( 2, m_type == 0 ? QObject::tr("silent") : QObject::tr("loud") );
+}
+AlarmItem::~AlarmItem() {
+}
+OPimAlarm AlarmItem::alarm()const{
+ OPimAlarm al( m_type, m_dt );
+
+ return al;
+}
+
+TaskEditorAlarms::TaskEditorAlarms( QWidget* parent, int, const char* name, WFlags fl )
: QWidget( parent, name, fl )
{
- QGridLayout *layout = new QGridLayout( this, 2, 3, 4, 4 );
+ m_date = m_type = m_time = 0;
+ QGridLayout *layout = new QGridLayout( this, 2, 2, 4, 4 );
lstAlarms = new QListView( this );
+ lstAlarms->addColumn( tr("Date") );
+ lstAlarms->addColumn( tr("Time") );
+ lstAlarms->addColumn( tr("Type") );
+
+ connect( lstAlarms, SIGNAL(clicked ( QListViewItem *, const QPoint &, int ) ),
+ this, SLOT(inlineEdit(QListViewItem*, const QPoint&, int ) ) );
+
layout->addMultiCellWidget( lstAlarms, 0, 0, 0, 2 );
QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), this );
//QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) );
- //connect( btn, SIGNAL( clicked() ), this, SLOT( slotNew() ) );
+ connect( btn, SIGNAL( clicked() ), this, SLOT( slotNew() ) );
layout->addWidget( btn, 1, 0 );
-
+/* use when we've reminders too */
+#if 0
btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), this );
//QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) );
- //connect( btn, SIGNAL( clicked() ), this, SLOT( slotEdit() ) );
+ connect( btn, SIGNAL( clicked() ), this, SLOT( slotEdit() ) );
layout->addWidget( btn, 1, 1 );
+#endif
btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), this );
//QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) );
- //connect( btn, SIGNAL( clicked() ), this, SLOT( slotDelete() ) );
+ connect( btn, SIGNAL( clicked() ), this, SLOT( slotDelete() ) );
layout->addWidget( btn, 1, 2 );
}
-TaskEditorAlarms::~TaskEditorAlarms()
-{
+TaskEditorAlarms::~TaskEditorAlarms(){
}
-void TaskEditorAlarms::slotNew()
-{
+void TaskEditorAlarms::slotNew(){
+ (void)new AlarmItem(lstAlarms, OPimAlarm(0, QDateTime::currentDateTime() ) );
}
-void TaskEditorAlarms::slotEdit()
-{
+void TaskEditorAlarms::slotEdit(){
}
-void TaskEditorAlarms::slotDelete()
-{
+void TaskEditorAlarms::slotDelete(){
+ QListViewItem* item = lstAlarms->currentItem();
+ if (!item) return;
+
+ lstAlarms->takeItem( item ); delete item;
+
+
+}
+
+void TaskEditorAlarms::load( const OTodo& todo) {
+ lstAlarms->clear();
+ if (!todo.hasNotifiers() ) return;
+
+ OPimNotifyManager::Alarms als = todo.notifiers().alarms();
+
+ if (als.isEmpty() ) return;
+
+ OPimNotifyManager::Alarms::Iterator it = als.begin();
+ for ( ; it != als.end(); ++it )
+ (void)new AlarmItem( lstAlarms, (*it) );
+
+
+}
+void TaskEditorAlarms::save( OTodo& todo ) {
+ if (lstAlarms->childCount() <= 0 ) return;
+
+ OPimNotifyManager::Alarms alarms;
+
+ for ( QListViewItem* item = lstAlarms->firstChild(); item; item = item->nextSibling() ) {
+ AlarmItem *alItem = static_cast<AlarmItem*>(item);
+ alarms.append( alItem->alarm() );
+ }
+
+ OPimNotifyManager& manager = todo.notifiers();
+ manager.setAlarms( alarms );
+}
+void TaskEditorAlarms::inlineEdit( QListViewItem* alarm, const QPoint& p, int col ) {
+ if (!alarm) return;
+
+ AlarmItem* item = static_cast<AlarmItem*>(alarm);
+ switch( col ) {
+ // date
+ case 0:
+ return inlineSetDate( item, p );
+ // time
+ case 1:
+ return inlineSetTime( item );
+ // type
+ case 2:
+ return inlineSetType( item, p );
+ }
+}
+void TaskEditorAlarms::inlineSetDate( AlarmItem* item, const QPoint& p ) {
+ QPopupMenu* pop = popup( 0 );
+ m_dbMonth->setDate( item->alarm().dateTime().date() );
+ pop->exec(p);
+
+ OPimAlarm al = item->alarm();
+ QDateTime dt = al.dateTime();
+ dt.setDate( m_dbMonth->selectedDate() );
+ al.setDateTime( dt );
+ item->setAlarm( al );
+}
+void TaskEditorAlarms::inlineSetType( AlarmItem* item, const QPoint& p ) {
+ int type;
+ QPopupMenu* pop = popup( 2 );
+ switch( pop->exec(p) ) {
+ case 10:
+ type = 1;
+ break;
+ case 20:
+ default:
+ type = 0;
+ }
+ OPimAlarm al = item->alarm();
+ al.setSound( type );
+ item->setAlarm( al );
+}
+void TaskEditorAlarms::inlineSetTime( AlarmItem* item ) {
+ OPimAlarm al = item->alarm();
+ QDateTime dt = al.dateTime();
+
+ OTimePickerDialog dialog;
+ dialog.setTime( dt.time() );
+ if ( dialog.exec() == QDialog::Accepted ) {
+ dt.setTime( dialog.time() );
+ al.setDateTime( dt );
+ item->setAlarm( al );
+ }
+}
+QPopupMenu* TaskEditorAlarms::popup( int column ) {
+ QPopupMenu* pop = 0;
+ switch( column ) {
+ case 0:{
+ if (!m_date) {
+ m_date = new QPopupMenu(this);
+ m_dbMonth = new DateBookMonth(m_date, 0, TRUE);
+ m_date->insertItem(m_dbMonth);
+ }
+ pop = m_date;
+ }
+ break;
+ case 1:
+ break;
+ case 2:{
+ if (!m_type) {
+ m_type = new QPopupMenu(this);
+ m_type->insertItem( QObject::tr("loud"), 10 );
+ m_type->insertItem( QObject::tr("silent"), 20 );
+ }
+ pop = m_type;
+ }
+ break;
+ default:
+ break;
+ }
+ return pop;
}