author | drw <drw> | 2005-03-07 16:52:17 (UTC) |
---|---|---|
committer | drw <drw> | 2005-03-07 16:52:17 (UTC) |
commit | 5ab00b78b199b1a03d3f27faa8b1dcffd9a86ff7 (patch) (side-by-side diff) | |
tree | bebec7df2d48f82b79a1ff3a98e05791dc444556 | |
parent | 61b9d5f646faa5bd84391318f6440bee6cbefcd8 (diff) | |
download | opie-5ab00b78b199b1a03d3f27faa8b1dcffd9a86ff7.zip opie-5ab00b78b199b1a03d3f27faa8b1dcffd9a86ff7.tar.gz opie-5ab00b78b199b1a03d3f27faa8b1dcffd9a86ff7.tar.bz2 |
Use popup menu for edit, duplicate, delete and beam in week list view - patch courtesy of Thomas Schnetzer
-rw-r--r-- | core/pim/datebook/datebook.cpp | 3 | ||||
-rw-r--r-- | core/pim/datebook/datebookweeklst.cpp | 43 | ||||
-rw-r--r-- | core/pim/datebook/datebookweeklst.h | 35 |
3 files changed, 72 insertions, 9 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp index 0a47bb8..a18a5b4 100644 --- a/core/pim/datebook/datebook.cpp +++ b/core/pim/datebook/datebook.cpp @@ -558,16 +558,19 @@ void DateBook::initWeekLst() { views->addWidget( weekLstView, WEEKLST ); //weekLstView->setStartViewTime( startTime ); connect( weekLstView, SIGNAL( showDate(int,int,int) ), this, SLOT( showDay(int,int,int) ) ); connect( weekLstView, SIGNAL( addEvent(const QDateTime&,const QDateTime&,const QString&, const QString&) ), this, SLOT( slotNewEntry(const QDateTime&,const QDateTime&,const QString&, const QString&) ) ); connect( this, SIGNAL( newEvent() ), weekLstView, SLOT( redraw() ) ); connect( weekLstView, SIGNAL( editEvent(const Event&) ), this, SLOT( editEvent(const Event&) ) ); + connect( weekLstView, SIGNAL( duplicateEvent( const Event & ) ), this, SLOT( duplicateEvent( const Event & ) ) ); + connect( weekLstView, SIGNAL( beamEvent(const Event&) ), this, SLOT( beamEvent(const Event&) ) ); + connect( weekLstView, SIGNAL( removeEvent( const Event & ) ), this, SLOT( removeEvent( const Event & ) ) ); } } void DateBook::initMonth() { if ( !monthView ) { monthView = new DateBookMonth( views, "month view", FALSE, db ); diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp index fe2ab51..771aa00 100644 --- a/core/pim/datebook/datebookweeklst.cpp +++ b/core/pim/datebook/datebookweeklst.cpp @@ -2,16 +2,17 @@ #include "datebookweeklst.h" #include "datebook.h" #include <opie2/odebug.h> #include <qpe/datebookmonth.h> #include <qpe/config.h> +#include <qpe/ir.h> #include <qpe/resource.h> #include <qlayout.h> #include <qtoolbutton.h> #include <qtl.h> bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false); @@ -187,23 +188,45 @@ DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, s=end; } else { // middle day. s=middle; } } else { s=""; } setText(QString(s) + " " + ev.description()); - connect(this, SIGNAL(clicked()), this, SLOT(editMe())); +// connect(this, SIGNAL(clicked()), this, SLOT(editMe())); setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); } void DateBookWeekLstEvent::editMe() { emit editEvent(event.event()); } - +void DateBookWeekLstEvent::duplicateMe() +{ + emit duplicateEvent(event.event()); +} +void DateBookWeekLstEvent::deleteMe() +{ + emit removeEvent(event.event()); + emit redraw(); +} +void DateBookWeekLstEvent::beamMe() +{ + emit beamEvent( event.event() ); +} +void DateBookWeekLstEvent::mousePressEvent( QMouseEvent *e ) +{ + popmenue = new QPopupMenu; + popmenue->insertItem( tr( "Edit" ), this, SLOT(editMe())); + popmenue->insertItem( tr( "Duplicate" ), this, SLOT(duplicateMe())); + popmenue->insertItem( tr( "Delete" ), this, SLOT(deleteMe())); + if(Ir::supported()) + popmenue->insertItem( tr( "Beam" ), this, SLOT(beamMe())); + popmenue->popup( mapToGlobal( e->pos() )); +} DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM, QWidget* parent, const char* name, WFlags fl) : QWidget( parent, name, fl ) { Config config("DateBook"); @@ -243,16 +266,20 @@ DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, layout->addWidget(hdr); // Events while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) { // Skip events ending at 00:00 starting at another day. DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this); layout->addWidget(l); connect (l, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); + connect (l, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); + connect (l, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); + connect (l, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); + connect (l, SIGNAL(redraw()), this, SIGNAL(redraw())); } it++; } layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); } } DateBookWeekLstView::~DateBookWeekLstView(){} void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} @@ -264,24 +291,32 @@ DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, const char* name, WFlags fl) : QWidget( parent, name, fl ) { QHBoxLayout *layout = new QHBoxLayout( this ); DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); layout->addWidget(w); connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); + connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); + connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); + connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); + connect (w, SIGNAL(redraw()), this, SIGNAL(redraw())); connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); layout->addWidget(w); connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); + connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); + connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); + connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); + connect (w, SIGNAL(redraw()), this, SIGNAL(redraw())); connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); } DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, QWidget *parent, const char *name ) @@ -357,16 +392,20 @@ void DateBookWeekLst::getEvents() { stop=start2.addDays(6); QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll); } else { view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll); } connect (view, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); + connect (view, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); + connect (view, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); + connect (view, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); + connect (view, SIGNAL(redraw()), this, SLOT(redraw())); connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); connect (view, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); scroll->addChild(view); view->show(); scroll->updateScrollBars(); } diff --git a/core/pim/datebook/datebookweeklst.h b/core/pim/datebook/datebookweeklst.h index 32fa23f..3bc7f2f 100644 --- a/core/pim/datebook/datebookweeklst.h +++ b/core/pim/datebook/datebookweeklst.h @@ -1,34 +1,34 @@ #ifndef DATEBOOKWEEKLST #define DATEBOOKWEEKLST #include <qwidget.h> -#include <qdatetime.h> +#include <qdatetime.h> #include <qpe/event.h> -#include <qlabel.h> +#include <qlabel.h> #include <qscrollview.h> #include "datebookweeklstheader.h" #include "datebookweeklstdayhdr.h" #include <opie2/oclickablelabel.h> class QDateTime; class DateBookDB; class DateBookWeekLstHeader: public DateBookWeekLstHeaderBase { Q_OBJECT public: - DateBookWeekLstHeader(bool onM, QWidget* parent = 0, const char* name = 0, + DateBookWeekLstHeader(bool onM, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~DateBookWeekLstHeader(); void setDate(const QDate &d); - + public slots: void nextWeek(); void prevWeek(); void nextMonth(); void prevMonth(); void pickDate(); void setDate(int y, int m, int d); signals: @@ -40,54 +40,68 @@ private: bool bStartOnMonday; }; class DateBookWeekLstDayHdr: public DateBookWeekLstDayHdrBase { Q_OBJECT public: DateBookWeekLstDayHdr(const QDate &d, bool onM, - QWidget* parent = 0, const char* name = 0, + QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); public slots: void showDay(); - void newEvent(); + void newEvent(); signals: void showDate(int y, int m, int d); void addEvent(const QDateTime &start, const QDateTime &stop, const QString &str, const QString &location); private: QDate date; }; -class DateBookWeekLstEvent: public Opie::Ui::OClickableLabel +class DateBookWeekLstEvent: public Opie::Ui::OClickableLabel { Q_OBJECT public: DateBookWeekLstEvent(const EffectiveEvent &ev, int weeklistviewconfig =1, QWidget* parent = 0, const char* name = 0, WFlags fl = 0); signals: void editEvent(const Event &e); + void duplicateEvent(const Event &e); + void removeEvent(const Event &e); + void beamEvent(const Event &e); + void redraw(); private slots: void editMe(); + void duplicateMe(); + void deleteMe(); + void beamMe(); private: const EffectiveEvent event; + QPopupMenu* popmenue; +protected: + void mousePressEvent( QMouseEvent *e ); }; class DateBookWeekLstView: public QWidget { Q_OBJECT public: DateBookWeekLstView(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~DateBookWeekLstView(); signals: void editEvent(const Event &e); + void duplicateEvent(const Event &e); + void removeEvent(const Event &e); + void beamEvent(const Event &e); + void redraw(); void showDate(int y, int m, int d); void addEvent(const QDateTime &start, const QDateTime &stop, const QString &str, const QString &location); private: bool bStartOnMonday; protected slots: void keyPressEvent(QKeyEvent *); }; @@ -97,16 +111,20 @@ class DateBookWeekLstDblView: public QWidget { public: DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, QValueList<EffectiveEvent> &ev2, QDate &d, bool onM, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); signals: void editEvent(const Event &e); + void duplicateEvent(const Event &e); + void removeEvent(const Event &e); + void beamEvent(const Event &e); + void redraw(); void showDate(int y, int m, int d); void addEvent(const QDateTime &start, const QDateTime &stop, const QString &str, const QString &location); }; class DateBookWeekLst : public QWidget { Q_OBJECT @@ -130,16 +148,19 @@ protected slots: void keyPressEvent(QKeyEvent *); void setDbl(bool on); signals: void showDate(int y, int m, int d); void addEvent(const QDateTime &start, const QDateTime &stop, const QString &str, const QString &location); void editEvent(const Event &e); + void duplicateEvent(const Event &e); + void removeEvent(const Event &e); + void beamEvent(const Event &e); private: DateBookDB *db; int startTime; bool ampm; bool bStartOnMonday; bool dbl; QDate bdate; |