author | hakan <hakan> | 2002-03-09 11:39:21 (UTC) |
---|---|---|
committer | hakan <hakan> | 2002-03-09 11:39:21 (UTC) |
commit | 603e969bb8cef91534a1785e27106ba71eb03ba6 (patch) (side-by-side diff) | |
tree | 20642ed29acb08ab0cecc1dffd1d63baa8914ae2 /core | |
parent | 3d03d0e3f679578080bbbf7d8b7f9eba1b9560db (diff) | |
download | opie-603e969bb8cef91534a1785e27106ba71eb03ba6.zip opie-603e969bb8cef91534a1785e27106ba71eb03ba6.tar.gz opie-603e969bb8cef91534a1785e27106ba71eb03ba6.tar.bz2 |
Added a WeekLst view showing an entire week and appointment descriptions and made default view configurable
-rw-r--r-- | core/pim/datebook/clickablelabel.cpp | 31 | ||||
-rw-r--r-- | core/pim/datebook/clickablelabel.h | 20 | ||||
-rw-r--r-- | core/pim/datebook/datebook.cpp | 106 | ||||
-rw-r--r-- | core/pim/datebook/datebook.h | 8 | ||||
-rw-r--r-- | core/pim/datebook/datebook.pro | 10 | ||||
-rw-r--r-- | core/pim/datebook/datebookweeklst.cpp | 314 | ||||
-rw-r--r-- | core/pim/datebook/datebookweeklst.h | 131 | ||||
-rw-r--r-- | core/pim/datebook/datebookweeklstdayhdr.ui | 149 | ||||
-rw-r--r-- | core/pim/datebook/datebookweeklstheader.ui | 238 | ||||
-rw-r--r-- | core/pim/datebook/dateentry.ui | 4 | ||||
-rw-r--r-- | core/pim/datebook/dateentryimpl.cpp | 8 |
11 files changed, 1006 insertions, 13 deletions
diff --git a/core/pim/datebook/clickablelabel.cpp b/core/pim/datebook/clickablelabel.cpp new file mode 100644 index 0000000..6912c34 --- a/dev/null +++ b/core/pim/datebook/clickablelabel.cpp @@ -0,0 +1,31 @@ +#include "clickablelabel.h" + +ClickableLabel::ClickableLabel(QWidget* parent = 0, + const char* name = 0, + WFlags fl = 0) : + QLabel(parent,name,fl) +{ + setFrameShape(NoFrame); + setFrameShadow(Sunken); +} + +void ClickableLabel::mousePressEvent( QMouseEvent *e ) { + setFrameShape(Panel); + repaint(); +} + +void ClickableLabel::mouseReleaseEvent( QMouseEvent *e ) { + setFrameShape(NoFrame); + repaint(); + if (rect().contains(e->pos())) { + emit clicked(); + } +} + +void ClickableLabel::mouseMoveEvent( QMouseEvent *e ) { + if (rect().contains(e->pos())) { + setFrameShape(Panel); + } else { + setFrameShape(NoFrame); + } +} diff --git a/core/pim/datebook/clickablelabel.h b/core/pim/datebook/clickablelabel.h new file mode 100644 index 0000000..b6d33ad --- a/dev/null +++ b/core/pim/datebook/clickablelabel.h @@ -0,0 +1,20 @@ +#ifndef CLICKABLELABEL +#define CLICKABLELABEL + +#include <qlabel.h> + +class ClickableLabel: public QLabel +{ + Q_OBJECT +public: + ClickableLabel(QWidget* parent = 0, const char* name = 0, + WFlags fl = 0); + protected: + void mousePressEvent( QMouseEvent *e ); + void mouseReleaseEvent( QMouseEvent *e ); + void mouseMoveEvent( QMouseEvent *e ); + signals: + void clicked(); +}; + +#endif diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp index e8d808f..9880e2d 100644 --- a/core/pim/datebook/datebook.cpp +++ b/core/pim/datebook/datebook.cpp @@ -13,32 +13,33 @@ ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** ** $Id$ ** **********************************************************************/ #define QTOPIA_INTERNAL_FD #include "datebook.h" #include "datebookday.h" #include "datebooksettings.h" #include "datebookweek.h" +#include "datebookweeklst.h" #include "dateentryimpl.h" #include <qpe/datebookmonth.h> #include <qpe/qpeapplication.h> #include <qpe/config.h> #include <qpe/qpedebug.h> #include <qpe/event.h> #include <qpe/finddialog.h> #include <qpe/ir.h> #include <qpe/qpemenubar.h> #include <qpe/qpemessagebox.h> #include <qpe/resource.h> #include <qpe/sound.h> #include <qpe/timestring.h> #include <qpe/qpetoolbar.h> #include <qpe/tzselect.h> @@ -56,53 +57,62 @@ #include <qpushbutton.h> #include <qtextcodec.h> #include <qtextstream.h> #include <qtl.h> #include <qwidgetstack.h> #include <qwindowsystem_qws.h> #include <sys/stat.h> #include <sys/types.h> #include <fcntl.h> #include <unistd.h> #include <stdlib.h> #define DAY 1 #define WEEK 2 +#define WEEKLST 4 #define MONTH 3 DateBook::DateBook( QWidget *parent, const char *, WFlags f ) : QMainWindow( parent, "datebook", f ), aPreset( FALSE ), presetTime( -1 ), startTime( 8 ), // an acceptable default syncing(FALSE), inSearch(FALSE) { QTime t; t.start(); db = new DateBookDB; qDebug("loading db t=%d", t.elapsed() ); loadSettings(); setCaption( tr("Calendar") ); setIcon( Resource::loadPixmap( "datebook_icon" ) ); setToolBarsMovable( FALSE ); + views = new QWidgetStack( this ); + setCentralWidget( views ); + + dayView = 0; + weekView = 0; + weekLstView = 0; + monthView = 0; + QPEToolBar *bar = new QPEToolBar( this ); bar->setHorizontalStretchable( TRUE ); QPEMenuBar *mb = new QPEMenuBar( bar ); mb->setMargin( 0 ); QPEToolBar *sub_bar = new QPEToolBar(this); QPopupMenu *view = new QPopupMenu( this ); QPopupMenu *settings = new QPopupMenu( this ); mb->insertItem( tr( "View" ), view ); mb->insertItem( tr( "Settings" ), settings ); QActionGroup *g = new QActionGroup( this ); g->setExclusive( TRUE ); @@ -111,61 +121,90 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f ) QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); a->addTo( sub_bar ); a = new QAction( tr( "Today" ), Resource::loadPixmap( "to_day" ), QString::null, 0, g, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); a->addTo( sub_bar ); a->addTo( view ); a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); a->addTo( sub_bar ); a->addTo( view ); a->setToggleAction( TRUE ); a->setOn( TRUE ); dayAction = a; + a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); a->addTo( sub_bar ); a->addTo( view ); a->setToggleAction( TRUE ); weekAction = a; + + a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "weeklst" ), QString::null, 0, g, 0 ); + connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); + a->addTo( sub_bar ); + a->addTo( view ); + a->setToggleAction( TRUE ); + weekLstAction = a; + a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); a->addTo( sub_bar ); a->addTo( view ); a->setToggleAction( TRUE ); monthAction = a; a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, g, 0 ); connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); a->addTo( sub_bar ); a = new QAction( tr( "Alarm and Start Time..." ), QString::null, 0, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); a->addTo( settings ); - views = new QWidgetStack( this ); - setCentralWidget( views ); + QPopupMenu *default_view = new QPopupMenu(this); + settings->insertItem( tr( "Default View" ),default_view ); + default_view->setCheckable(TRUE); - dayView = 0; - weekView = 0; - monthView = 0; - viewDay(); + Config config("DateBook"); + config.setGroup("Main"); + int current=config.readNumEntry("defaultview", DAY); + + QActionGroup *ag = new QActionGroup(this); + a = new QAction( tr( "Day" ), QString::null, 0, 0, 0, true ); + if (current==DAY) a->setOn(true), viewDay(); + ag->insert(a); + a = new QAction( tr( "Week" ), QString::null, 0, 0, 0, true ); + if (current==WEEK) a->setOn(true), viewWeek(); + ag->insert(a); + a = new QAction( tr( "WeekLst" ), QString::null, 0, 0, 0, true ); + if (current==WEEKLST) a->setOn(true), viewWeekLst(); + ag->insert(a); + a = new QAction( tr( "Month" ), QString::null, 0, 0, 0, true ); + if (current==MONTH) a->setOn(true), viewMonth(); + ag->insert(a); + + ag->addTo(default_view); + connect(ag, SIGNAL( selected ( QAction * ) ), + this, SLOT( newDefaultView(QAction *) ) + ); + connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) ); #if defined(Q_WS_QWS) && !defined(QT_NO_COP) connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), this, SLOT(appMessage(const QCString&, const QByteArray&)) ); #endif // listen on QPE/System #if defined(Q_WS_QWS) #if !defined(QT_NO_COP) QCopChannel *channel = new QCopChannel( "QPE/System", this ); connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); @@ -251,59 +290,70 @@ QString DateBook::checkEvent(const Event &e) if(checkFailed) return tr("Event duration is potentially longer\n" "than interval between repeats."); return QString::null; } QDate DateBook::currentDate() { QDate d = QDate::currentDate(); if ( dayView && views->visibleWidget() == dayView ) { d = dayView->date(); } else if ( weekView && views->visibleWidget() == weekView ) { d = weekView->date(); + } else if ( weekLstView && views->visibleWidget() == weekLstView ) { + d = weekLstView->date(); } else if ( monthView && views->visibleWidget() == monthView ) { d = monthView->selectedDate(); } return d; } void DateBook::viewDay() { initDay(); dayAction->setOn( TRUE ); QDate d = currentDate(); dayView->setDate( d ); views->raiseWidget( dayView ); dayView->redraw(); } void DateBook::viewWeek() { initWeek(); weekAction->setOn( TRUE ); QDate d = currentDate(); weekView->setDate( d ); views->raiseWidget( weekView ); weekView->redraw(); } +void DateBook::viewWeekLst() { + initWeekLst(); + weekLstAction->setOn( TRUE ); + QDate d=currentDate(); + weekLstView->setDate(d); + views->raiseWidget( weekLstView ); + weekLstView->redraw(); +} + void DateBook::viewMonth() { initMonth(); monthAction->setOn( TRUE ); QDate d = currentDate(); monthView->setDate( d.year(), d.month(), d.day() ); views->raiseWidget( monthView ); monthView->redraw(); } void DateBook::editEvent( const Event &e ) { if (syncing) { QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); return; @@ -318,33 +368,34 @@ void DateBook::editEvent( const Event &e ) sv->setResizePolicy( QScrollView::AutoOneFit ); // KLUDGE!!! sv->setHScrollBarMode( QScrollView::AlwaysOff ); vb->addWidget( sv ); entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" ); entry->timezone->setEnabled( FALSE ); sv->addChild( entry ); #if defined(Q_WS_QWS) || defined(_WS_QWS_) editDlg.showMaximized(); #endif while (editDlg.exec() ) { Event newEv = entry->event(); QString error = checkEvent(newEv); if (!error.isNull()) { if (QMessageBox::warning(this, "error box", - error, "Fix it", "Continue", 0, 0, 1) == 0) + error, "Fix it", "Continue", + 0, 0, 1) == 0) continue; } db->editEvent(e, newEv); emit newEvent(); break; } } void DateBook::removeEvent( const Event &e ) { if (syncing) { QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); return; } @@ -409,32 +460,54 @@ void DateBook::initWeek() //from the year of the current date. So, first find the year //number of the current week. int yearNumber, totWeeks; calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); QDate d = QDate( yearNumber, 12, 31 ); calcWeek( d, totWeeks, yearNumber, onMonday ); while ( totWeeks == 1 ) { d = d.addDays( -1 ); calcWeek( d, totWeeks, yearNumber, onMonday ); } if ( totWeeks != weekView->totalWeeks() ) weekView->setTotalWeeks( totWeeks ); } +void DateBook::initWeekLst() { + if ( !weekLstView ) { + weekLstView = new DateBookWeekLst( ampm, onMonday, db, + views, "weeklst view" ); + 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 & ) ), + this, SLOT( slotNewEntry( const QDateTime &, + const QDateTime &, + const QString & ) ) ); + connect( this, SIGNAL( newEvent() ), + weekLstView, SLOT( redraw() ) ); + connect( weekLstView, SIGNAL( editEvent( const Event & ) ), + this, SLOT( editEvent( const Event & ) ) ); + } +} + void DateBook::initMonth() { if ( !monthView ) { monthView = new DateBookMonth( views, "month view", FALSE, db ); views->addWidget( monthView, MONTH ); connect( monthView, SIGNAL( dateClicked( int, int, int ) ), this, SLOT( showDay( int, int, int ) ) ); connect( this, SIGNAL( newEvent() ), monthView, SLOT( redraw() ) ); qApp->processEvents(); } } void DateBook::loadSettings() { @@ -451,32 +524,44 @@ void DateBook::loadSettings() startTime = config.readNumEntry("startviewtime", 8); aPreset = config.readBoolEntry("alarmpreset"); presetTime = config.readNumEntry("presettime"); } } void DateBook::saveSettings() { Config config( "qpe" ); Config configDB( "DateBook" ); configDB.setGroup( "Main" ); configDB.writeEntry("startviewtime",startTime); configDB.writeEntry("alarmpreset",aPreset); configDB.writeEntry("presettime",presetTime); } +void DateBook::newDefaultView(QAction *a) { + int val=DAY; + if (a->text() == "Day") val=DAY; + if (a->text() == "Week") val=WEEK; + if (a->text() == "WeekLst") val=WEEKLST; + if (a->text() == "Month") val=MONTH; + + Config configDB( "DateBook" ); + configDB.setGroup( "Main" ); + configDB.writeEntry("defaultview",val); +} + void DateBook::appMessage(const QCString& msg, const QByteArray& data) { bool needShow = FALSE; if ( msg == "alarm(QDateTime,int)" ) { QDataStream ds(data,IO_ReadOnly); QDateTime when; int warn; ds >> when >> warn; // check to make it's okay to continue, // this is the case that the time was set ahead, and // we are forced given a stale alarm... QDateTime current = QDateTime::currentDateTime(); if ( current.time().hour() != when.time().hour() && current.time().minute() != when.time().minute() ) return; @@ -523,32 +608,34 @@ void DateBook::appMessage(const QCString& msg, const QByteArray& data) #if defined(Q_WS_QWS) || defined(_WS_QWS_) dlg.showMaximized(); #endif needShow = dlg.exec(); if ( bSound ) killTimer( stopTimer ); } } } else if ( msg == "nextView()" ) { QWidget* cur = views->visibleWidget(); if ( cur ) { if ( cur == dayView ) viewWeek(); else if ( cur == weekView ) + viewWeekLst(); + else if ( cur == weekLstView ) viewMonth(); else if ( cur == monthView ) viewDay(); needShow = TRUE; } } if ( needShow ) { #if defined(Q_WS_QWS) || defined(_WS_QWS_) showMaximized(); #else show(); #endif raise(); QPEApplication::setKeepRunning(); setActiveWindow(); } @@ -577,32 +664,33 @@ void DateBook::timerEvent( QTimerEvent *e ) static int stop = 0; if ( stop < 10 ) { Sound::soundAlarm(); stop++; } else { stop = 0; killTimer( e->timerId() ); } } void DateBook::changeClock( bool newClock ) { ampm = newClock; // repaint the affected objects... if (dayView) dayView->redraw(); if (weekView) weekView->redraw(); + if (weekLstView) weekLstView->redraw(); } void DateBook::changeWeek( bool m ) { /* no need to redraw, each widget catches. Do need to store though for widgets we haven't made yet */ onMonday = m; } void DateBook::slotToday() { // we need to view today QDate dt = QDate::currentDate(); showDay( dt.year(), dt.month(), dt.day() ); } @@ -647,33 +735,35 @@ void DateBook::slotNewEventFromKey( const QString &str ) // So we can assume some things. We want the string // passed in to be part of the description. QDateTime start, end; if ( views->visibleWidget() == dayView ) { dayView->selectedDates( start, end ); } else if ( views->visibleWidget() == monthView ) { QDate d = monthView->selectedDate(); start = end = d; start.setTime( QTime( 10, 0 ) ); end.setTime( QTime( 12, 0 ) ); } else if ( views->visibleWidget() == weekView ) { QDate d = weekView->date(); start = end = d; start.setTime( QTime( 10, 0 ) ); end.setTime( QTime( 12, 0 ) ); } - + slotNewEntry(start, end, str); +} +void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str) { // argh! This really needs to be encapsulated in a class // or function. QDialog newDlg( this, 0, TRUE ); newDlg.setCaption( DateEntryBase::tr("New Event") ); DateEntry *e; QVBoxLayout *vb = new QVBoxLayout( &newDlg ); QScrollView *sv = new QScrollView( &newDlg ); sv->setResizePolicy( QScrollView::AutoOneFit ); sv->setFrameStyle( QFrame::NoFrame ); sv->setHScrollBarMode( QScrollView::AlwaysOff ); vb->addWidget( sv ); Event ev; ev.setDescription( str ); // When the new gui comes in, change this... ev.setLocation( tr("(Unknown)") ); diff --git a/core/pim/datebook/datebook.h b/core/pim/datebook/datebook.h index 44627bb..fcdbfec 100644 --- a/core/pim/datebook/datebook.h +++ b/core/pim/datebook/datebook.h @@ -15,97 +15,103 @@ ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef DATEBOOK_H #define DATEBOOK_H #include <qpe/datebookdb.h> #include <qmainwindow.h> class QAction; class QWidgetStack; class DateBookDay; class DateBookWeek; +class DateBookWeekLst; class DateBookMonth; class Event; class QDate; class Ir; class DateBook : public QMainWindow { Q_OBJECT public: DateBook( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); ~DateBook(); signals: void newEvent(); void signalNotFound(); void signalWrapAround(); protected: QDate currentDate(); void timerEvent( QTimerEvent *e ); void closeEvent( QCloseEvent *e ); public slots: void flush(); void reload(); private slots: void fileNew(); + void slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str); void slotSettings(); + void newDefaultView(QAction *a); void slotToday(); // view today void changeClock( bool newClock ); void changeWeek( bool newDay ); void appMessage(const QCString& msg, const QByteArray& data); // handle key events in the day view... void slotNewEventFromKey( const QString &str ); void slotFind(); void slotDoFind( const QString &, const QDate &, bool, bool, int ); void viewDay(); void viewWeek(); + void viewWeekLst(); void viewMonth(); void showDay( int y, int m, int d ); void editEvent( const Event &e ); void removeEvent( const Event &e ); void receive( const QCString &msg, const QByteArray &data ); void setDocument( const QString & ); void beamEvent( const Event &e ); void beamDone( Ir *ir ); private: void addEvent( const Event &e ); void initDay(); void initWeek(); + void initWeekLst(); void initMonth(); void loadSettings(); void saveSettings(); private: DateBookDB *db; QWidgetStack *views; DateBookDay *dayView; DateBookWeek *weekView; DateBookMonth *monthView; - QAction *dayAction, *weekAction, *monthAction; + DateBookWeekLst *weekLstView; + QAction *dayAction, *weekAction, *weekLstAction, *monthAction; bool aPreset; // have everything set to alarm? int presetTime; // the standard time for the alarm int startTime; bool ampm; bool onMonday; bool syncing; bool inSearch; QString checkEvent(const Event &); }; #endif diff --git a/core/pim/datebook/datebook.pro b/core/pim/datebook/datebook.pro index fae5d2b..bbe07af 100644 --- a/core/pim/datebook/datebook.pro +++ b/core/pim/datebook/datebook.pro @@ -1,36 +1,42 @@ TEMPLATE = app CONFIG += qt warn_on release DESTDIR = $(OPIEDIR)/bin HEADERS = datebookday.h \ datebook.h \ dateentryimpl.h \ datebookdayheaderimpl.h \ datebooksettings.h \ datebookweek.h \ + datebookweeklst.h \ datebookweekheaderimpl.h \ - repeatentry.h + repeatentry.h \ + clickablelabel.h SOURCES = main.cpp \ datebookday.cpp \ datebook.cpp \ dateentryimpl.cpp \ datebookdayheaderimpl.cpp \ datebooksettings.cpp \ datebookweek.cpp \ + datebookweeklst.cpp \ datebookweekheaderimpl.cpp \ - repeatentry.cpp + repeatentry.cpp \ + clickablelabel.cpp INTERFACES = dateentry.ui \ datebookdayheader.ui \ datebooksettingsbase.ui \ datebookweekheader.ui \ + datebookweeklstheader.ui \ + datebookweeklstdayhdr.ui \ repeatentrybase.ui INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe TARGET = datebook TRANSLATIONS = ../i18n/de/datebook.ts diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp new file mode 100644 index 0000000..05e36be --- a/dev/null +++ b/core/pim/datebook/datebookweeklst.cpp @@ -0,0 +1,314 @@ +#include "datebookweeklst.h" + +#include "datebookweekheaderimpl.h" + +#include <qpe/calendar.h> +#include <qpe/datebookdb.h> +#include <qpe/event.h> +#include <qpe/qpeapplication.h> +#include <qpe/timestring.h> +#include <qpe/datebookmonth.h> + +#include <qdatetime.h> +#include <qheader.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qpainter.h> +#include <qpopupmenu.h> +#include <qtimer.h> +#include <qstyle.h> +#include <qtoolbutton.h> +#include <qvbox.h> +#include <qsizepolicy.h> +#include <qabstractlayout.h> +#include <qtl.h> + +bool calcWeek(const QDate &d, int &week, int &year, + bool startOnMonday = false); + +DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, + const char* name, WFlags fl) + : DateBookWeekLstHeaderBase(parent, name, fl) +{ + setBackgroundMode( PaletteButton ); + labelDate->setBackgroundMode( PaletteButton ); + labelWeek->setBackgroundMode( PaletteButton ); + forward->setBackgroundMode( PaletteButton ); + back->setBackgroundMode( PaletteButton ); + DateBookWeekLstHeaderBaseLayout->setSpacing(0); + DateBookWeekLstHeaderBaseLayout->setMargin(0); + //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding)); + setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); + + connect(back, SIGNAL(clicked()), this, SLOT(prevWeek())); + connect(forward, SIGNAL(clicked()), this, SLOT(nextWeek())); + connect(labelWeek, SIGNAL(clicked()), this, SLOT(pickDate())); + onMonday=onM; +} +DateBookWeekLstHeader::~DateBookWeekLstHeader(){} +void DateBookWeekLstHeader::setDate(QDate d) { + date=d; + + int year,week; + calcWeek(d,week,year,onMonday); + labelWeek->setText("W: " + QString::number(week)); + + QDate start=date; + QDate stop=start.addDays(6); + labelDate->setText( QString::number(start.day()) + " " + + start.monthName(start.month()) + " - " + + QString::number(stop.day()) + " " + + start.monthName(stop.month()) ); + emit dateChanged(year,week); +} +void DateBookWeekLstHeader::pickDate() { + static QPopupMenu *m1 = 0; + static DateBookMonth *picker = 0; + if ( !m1 ) { + m1 = new QPopupMenu( this ); + picker = new DateBookMonth( m1, 0, TRUE ); + m1->insertItem( picker ); + connect( picker, SIGNAL( dateClicked( int, int, int ) ), + this, SLOT( setDate( int, int, int ) ) ); + //connect( m1, SIGNAL( aboutToHide() ), + //this, SLOT( gotHide() ) ); + } + picker->setDate( date.year(), date.month(), date.day() ); + m1->popup(mapToGlobal(labelWeek->pos()+QPoint(0,labelWeek->height()))); + picker->setFocus(); +} +void DateBookWeekLstHeader::setDate(int y, int m, int d) { + QDate new_date(y,m,d); + setDate(new_date); +} + +void DateBookWeekLstHeader::nextWeek() { + setDate(date.addDays(7)); +} +void DateBookWeekLstHeader::prevWeek() { + setDate(date.addDays(-7)); +} + +DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool onM, + QWidget* parent = 0, + const char* name = 0, + WFlags fl = 0 ) + : DateBookWeekLstDayHdrBase(parent, name, fl) { + + date=d; + + static const char *wdays="MTWTFSS"; + char day=wdays[d.dayOfWeek()-1]; + + label->setText( QString(QChar(day)) + " " + + QString::number(d.day()) ); + add->setText("+"); + + if (d == QDate::currentDate()) { + QPalette pal=label->palette(); + pal.setColor(QColorGroup::Foreground, QColor(0,0,255)); + label->setPalette(pal); + + /* + QFont f=label->font(); + f.setItalic(true); + label->setFont(f); + label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor())); + */ + } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday + QPalette pal=label->palette(); + pal.setColor(QColorGroup::Foreground, QColor(255,0,0)); + label->setPalette(pal); + } + + + connect (label, SIGNAL(clicked()), this, SLOT(showDay())); + connect (add, SIGNAL(clicked()), this, SLOT(newEvent())); +} + +void DateBookWeekLstDayHdr::showDay() { + emit showDate(date.year(), date.month(), date.day()); +} +void DateBookWeekLstDayHdr::newEvent() { + QDateTime start, stop; + start=stop=date; + start.setTime(QTime(10,0)); + stop.setTime(QTime(12,0)); + + emit addEvent(start,stop,""); +} +DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, + QWidget* parent = 0, + const char* name = 0, + WFlags fl = 0) : + ClickableLabel(parent,name,fl), + event(ev) +{ + char s[10]; + if ( ev.startDate() != ev.date() ) { // multiday event (not first day) + if ( ev.endDate() == ev.date() ) { // last day + strcpy(s, "__|__"); + } else { + strcpy(s, " |---"); + } + } else { + sprintf(s,"%.2d:%.2d",ev.start().hour(),ev.start().minute()); + } + setText(QString(s) + " " + ev.description()); + connect(this, SIGNAL(clicked()), this, SLOT(editMe())); +} +void DateBookWeekLstEvent::editMe() { + emit editEvent(event.event()); +} + + +DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, + QDate &d, bool onM, + QWidget* parent, + const char* name, WFlags fl) + : QWidget( parent, name, fl ) +{ + onMonday=onM; + setPalette(white); + setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); + + QVBoxLayout *layout = new QVBoxLayout( this ); + + qBubbleSort(ev); + QValueListIterator<EffectiveEvent> it; + it=ev.begin(); + + int dayOrder[7]; + if (onMonday) + for (int d=0; d<7; d++) dayOrder[d]=d+1; + else { + for (int d=0; d<7; d++) dayOrder[d]=d; + dayOrder[0]=7; + } + + for (int i=0; i<7; i++) { + // Header + DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i), + onMonday,this); + connect(hdr, SIGNAL(showDate(int,int,int)), + this, SIGNAL(showDate(int,int,int))); + connect(hdr, SIGNAL(addEvent(const QDateTime &, + const QDateTime &, + const QString &)), + this, SIGNAL(addEvent(const QDateTime &, + const QDateTime &, + const QString &))); + layout->addWidget(hdr); + + // Events + while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { + DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,this); + layout->addWidget(l); + connect (l, SIGNAL(editEvent(const Event &)), + this, SIGNAL(editEvent(const Event &))); + it++; + } + + layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); + } +} +DateBookWeekLstView::~DateBookWeekLstView(){} +void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} + +DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, + QWidget *parent, + const char *name ) + : QWidget( parent, name ), + db( newDB ), + startTime( 0 ), + ampm( ap ), + onMonday(onM) +{ + setFocusPolicy(StrongFocus); + layout = new QVBoxLayout( this ); + layout->setMargin(0); + + header=new DateBookWeekLstHeader(onM, this); + layout->addWidget( header ); + connect(header, SIGNAL(dateChanged(int,int)), this, SLOT(dateChanged(int,int))); + + scroll=new QScrollView(this); + //scroll->setVScrollBarMode(QScrollView::AlwaysOn); + //scroll->setHScrollBarMode(QScrollView::AlwaysOff); + scroll->setResizePolicy(QScrollView::AutoOneFit); + layout->addWidget(scroll); + + view=NULL; +} + + +void DateBookWeekLst::setDate( QDate &d ) { + int w,y; + calcWeek(d,w,y,onMonday); + year=y; + _week=w; + header->setDate(date()); +} +void DateBookWeekLst::redraw() {getEvents();} + +QDate DateBookWeekLst::date() const { + QDate d; + d.setYMD(year,1,1); + + int dow= d.dayOfWeek(); + if (!onMonday) + if (dow==7) dow=1; + else dow++; + + d=d.addDays( (_week-1)*7 - dow + 1 ); + return d; +} + +void DateBookWeekLst::getEvents() { + QDate start = date(); + QDate stop = start.addDays(6); + QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); + + if (view) delete view; + view=new DateBookWeekLstView(el,start,onMonday,scroll); + + connect (view, SIGNAL(editEvent(const Event &)), + this, SIGNAL(editEvent(const Event &))); + connect (view, SIGNAL(showDate(int,int,int)), + this, SIGNAL(showDate(int,int,int))); + connect (view, SIGNAL(addEvent(const QDateTime &, const QDateTime &, + const QString &)), + this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, + const QString &))); + + scroll->addChild(view); + view->show(); + scroll->updateScrollBars(); +} + +void DateBookWeekLst::dateChanged(int y, int w) { + year=y; + _week=w; + getEvents(); +} + +void DateBookWeekLst::keyPressEvent(QKeyEvent *e) +{ + switch(e->key()) { + case Key_Up: + scroll->scrollBy(0, -20); + break; + case Key_Down: + scroll->scrollBy(0, 20); + break; + case Key_Left: + header->prevWeek(); + break; + case Key_Right: + header->nextWeek(); + break; + default: + e->ignore(); + } +} + diff --git a/core/pim/datebook/datebookweeklst.h b/core/pim/datebook/datebookweeklst.h new file mode 100644 index 0000000..d2a07cc --- a/dev/null +++ b/core/pim/datebook/datebookweeklst.h @@ -0,0 +1,131 @@ +#ifndef DATEBOOKWEEKLST +#define DATEBOOKWEEKLST + +#include <qwidget.h> +#include <qdatetime.h> +#include <qpe/event.h> +#include <qlabel.h> +#include <qscrollview.h> + +#include "datebookweeklstheader.h" +#include "datebookweeklstdayhdr.h" + +#include "clickablelabel.h" + +class QDateTime; +class DateBookDB; + +class DateBookWeekLstHeader: public DateBookWeekLstHeaderBase +{ + Q_OBJECT +public: + DateBookWeekLstHeader(bool onM, QWidget* parent = 0, const char* name = 0, + WFlags fl = 0 ); + ~DateBookWeekLstHeader(); + void setDate(QDate d); + +public slots: + void nextWeek(); + void prevWeek(); + void pickDate(); + void setDate(int y, int m, int d); +signals: + void dateChanged(int y, int w); +private: + QDate date; + bool onMonday; +}; + +class DateBookWeekLstDayHdr: public DateBookWeekLstDayHdrBase +{ + Q_OBJECT +public: + DateBookWeekLstDayHdr(const QDate &d, bool onM, + QWidget* parent = 0, const char* name = 0, + WFlags fl = 0 ); +public slots: + void showDay(); + void newEvent(); +signals: + void showDate(int y, int m, int d); + void addEvent(const QDateTime &start, const QDateTime &stop, + const QString &str); +private: + QDate date; +}; + +class DateBookWeekLstEvent: public ClickableLabel +{ + Q_OBJECT +public: + DateBookWeekLstEvent(const EffectiveEvent &ev, + QWidget* parent = 0, const char* name = 0, + WFlags fl = 0); +signals: + void editEvent(const Event &e); +private slots: + void editMe(); +private: + const EffectiveEvent event; +}; + +class DateBookWeekLstView: public QWidget +{ + Q_OBJECT +public: + DateBookWeekLstView(QValueList<EffectiveEvent> &ev, QDate &d, bool onM, + QWidget* parent = 0, const char* name = 0, + WFlags fl = 0 ); + ~DateBookWeekLstView(); +signals: + void editEvent(const Event &e); + void showDate(int y, int m, int d); + void addEvent(const QDateTime &start, const QDateTime &stop, + const QString &str); +private: + bool onMonday; +protected slots: + void keyPressEvent(QKeyEvent *); +}; + +class DateBookWeekLst : public QWidget +{ + Q_OBJECT + +public: + DateBookWeekLst( bool ampm, bool onM, DateBookDB *newDB, + QWidget *parent = 0, + const char *name = 0 ); + void setDate( int y, int w ); + void setDate( QDate &d ); + int week() const { return _week; }; + QDate date() const; + +public slots: + void redraw(); + void dateChanged(int y, int w); +protected slots: + void keyPressEvent(QKeyEvent *); + +signals: + void showDate(int y, int m, int d); + void addEvent(const QDateTime &start, const QDateTime &stop, + const QString &str); + void editEvent(const Event &e); + +private: + DateBookDB *db; + int startTime; + bool ampm; + bool onMonday; + int year, _week; + DateBookWeekLstHeader *header; + DateBookWeekLstView *view; + QVBoxLayout *layout; + QScrollView *scroll; + + void getEvents(); +}; + +#endif + diff --git a/core/pim/datebook/datebookweeklstdayhdr.ui b/core/pim/datebook/datebookweeklstdayhdr.ui new file mode 100644 index 0000000..3b88495 --- a/dev/null +++ b/core/pim/datebook/datebookweeklstdayhdr.ui @@ -0,0 +1,149 @@ +<!DOCTYPE UI><UI> +<class>DateBookWeekLstDayHdrBase</class> +<widget> + <class>QWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>DateBookWeekLstDayHdrBase</cstring> + </property> + <property stdset="1"> + <name>geometry</name> + <rect> + <x>0</x> + <y>106</y> + <width>621</width> + <height>5</height> + </rect> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>0</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>caption</name> + <string>Form1</string> + </property> + <property> + <name>layoutMargin</name> + </property> + <hbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>Line</class> + <property stdset="1"> + <name>name</name> + <cstring>Line1</cstring> + </property> + <property stdset="1"> + <name>minimumSize</name> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + <property stdset="1"> + <name>maximumSize</name> + <size> + <width>32767</width> + <height>32767</height> + </size> + </property> + <property stdset="1"> + <name>orientation</name> + <enum>Horizontal</enum> + </property> + </widget> + <widget> + <class>ClickableLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>label</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>0</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>font</name> + <font> + <bold>1</bold> + </font> + </property> + </widget> + <widget> + <class>Line</class> + <property stdset="1"> + <name>name</name> + <cstring>Line1_2</cstring> + </property> + <property stdset="1"> + <name>minimumSize</name> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + <property stdset="1"> + <name>maximumSize</name> + <size> + <width>32767</width> + <height>32767</height> + </size> + </property> + <property stdset="1"> + <name>orientation</name> + <enum>Horizontal</enum> + </property> + </widget> + <widget> + <class>ClickableLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>add</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>0</vsizetype> + </sizepolicy> + </property> + </widget> + </hbox> +</widget> +<customwidgets> + <customwidget> + <class>ClickableLabel</class> + <header location="local">clickablelabel.h</header> + <sizehint> + <width>-1</width> + <height>-1</height> + </sizehint> + <container>0</container> + <sizepolicy> + <hordata>5</hordata> + <verdata>5</verdata> + </sizepolicy> + <pixmap>image0</pixmap> + </customwidget> +</customwidgets> +<images> + <image> + <name>image0</name> + <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1ddec44f503c0ae2a154410f53d0ed20e2bf6bdb656dd6861dd23d9a66591b0587fd1654235ebded6f0edcd53e419d87ae7b1f4f9b8f906d0bfe012317426a70b07bdc2f3ec77f8ed6b89559061a0343d06a124cc105596482585094bc0ae599b04646c9018926491b2205e140c485cace25755c175d0a967b622ff900b8cc9c7d29af594ea722d589167f813aa852ba07d94b9dce296e883fe7bb163f23896753</data> + </image> +</images> +</UI> diff --git a/core/pim/datebook/datebookweeklstheader.ui b/core/pim/datebook/datebookweeklstheader.ui new file mode 100644 index 0000000..666e896 --- a/dev/null +++ b/core/pim/datebook/datebookweeklstheader.ui @@ -0,0 +1,238 @@ +<!DOCTYPE UI><UI> +<class>DateBookWeekLstHeaderBase</class> +<widget> + <class>QWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>DateBookWeekLstHeaderBase</cstring> + </property> + <property stdset="1"> + <name>geometry</name> + <rect> + <x>0</x> + <y>51</y> + <width>535</width> + <height>25</height> + </rect> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>0</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>caption</name> + <string>Form2</string> + </property> + <property> + <name>layoutMargin</name> + </property> + <property> + <name>layoutSpacing</name> + </property> + <hbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QToolButton</class> + <property stdset="1"> + <name>name</name> + <cstring>back</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>text</name> + <string></string> + </property> + <property stdset="1"> + <name>pixmap</name> + <pixmap>image0</pixmap> + </property> + <property stdset="1"> + <name>autoRepeat</name> + <bool>true</bool> + </property> + <property stdset="1"> + <name>autoRaise</name> + <bool>true</bool> + </property> + </widget> + <spacer> + <property> + <name>name</name> + <cstring>Spacer1_3</cstring> + </property> + <property stdset="1"> + <name>orientation</name> + <enum>Horizontal</enum> + </property> + <property stdset="1"> + <name>sizeType</name> + <enum>Expanding</enum> + </property> + <property> + <name>sizeHint</name> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget> + <class>QToolButton</class> + <property stdset="1"> + <name>name</name> + <cstring>labelWeek</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>0</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>font</name> + <font> + <bold>1</bold> + </font> + </property> + <property stdset="1"> + <name>text</name> + <string>W: 00,00</string> + </property> + <property stdset="1"> + <name>autoRaise</name> + <bool>false</bool> + </property> + </widget> + <spacer> + <property> + <name>name</name> + <cstring>Spacer1</cstring> + </property> + <property stdset="1"> + <name>orientation</name> + <enum>Horizontal</enum> + </property> + <property stdset="1"> + <name>sizeType</name> + <enum>Expanding</enum> + </property> + <property> + <name>sizeHint</name> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>labelDate</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>3</hsizetype> + <vsizetype>7</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>font</name> + <font> + <bold>1</bold> + </font> + </property> + <property stdset="1"> + <name>text</name> + <string>00 Jan-00 Jan</string> + </property> + <property stdset="1"> + <name>alignment</name> + <set>AlignCenter</set> + </property> + <property> + <name>hAlign</name> + </property> + </widget> + <spacer> + <property> + <name>name</name> + <cstring>Spacer1_2</cstring> + </property> + <property stdset="1"> + <name>orientation</name> + <enum>Horizontal</enum> + </property> + <property stdset="1"> + <name>sizeType</name> + <enum>Expanding</enum> + </property> + <property> + <name>sizeHint</name> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget> + <class>QToolButton</class> + <property stdset="1"> + <name>name</name> + <cstring>forward</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>text</name> + <string></string> + </property> + <property stdset="1"> + <name>pixmap</name> + <pixmap>image1</pixmap> + </property> + <property stdset="1"> + <name>autoRepeat</name> + <bool>true</bool> + </property> + <property stdset="1"> + <name>autoRaise</name> + <bool>true</bool> + </property> + </widget> + </hbox> +</widget> +<images> + <image> + <name>image0</name> + <data format="XPM.GZ" length="582">789c6dcfcd4e843010c0f13b4fd1d01b31bb6cb325211b1f41e3d1c4789876a60bcbd7aeae07637c773b6d5985d870e0f7ef50605b88e7a707516cb3f72b5c5b2b6c036fa2c08f61f87c79bdffcaf2dd5ef0558b5d7e97e51b61c5e33412df4b7f2fcbb09896a94ab557817063cd744cad74a915734aac35308740d018d9332d5ab0c8ec1229f2c2448d156a661b489ee1ab4e4cf2a08a790e24020abb0dd355442eec8e914e45526215790c749e8e89891069125de466b1fe14295705ccaa5863e2d05cc01894925b2a7e8217dd8a631eb169fd509af10fd1a9ebfbdf32008d9d0c07cd274f70ee162773ba2cdfee935c977ffe6b2edf87ec07796f81cd</data> + </image> + <image> + <name>image1</name> + <data format="XPM.GZ" length="627">789c7dcfc94ec3301006e07b9ec28a6f114a13cbb1a8108f00e28884387819676993340b07847877329ea8697a60ec83bfdf232f8784bdbfbdb0e4104db39e6bcb6ca54796b8afb6fdfef87cfe89e25cb2650ac1f2f8218a5366d96bdf01aef9b2e65928a4458a0c07b25c29890352e63293e19c53a0968f52230159e8c22981744495133552097554a1f982b4ce6aeb9013d215165c81ec894e109b4070ca85378f2b35f18c04050214b20d04d010762ba457003eecd6442f88f34a45f4817ea147762b35d1acf4c47457d784737d9f18ebee1363614bf852c6f812b6c460f90abb6e93ba694ed7c49fdbaeee2f76b83da71ba772e0db5d9ccf4b07dfdd5e858edd9b2948fff9d796fc3e457f660e8d47</data> + </image> +</images> +</UI> diff --git a/core/pim/datebook/dateentry.ui b/core/pim/datebook/dateentry.ui index 0c363a4..eac4e23 100644 --- a/core/pim/datebook/dateentry.ui +++ b/core/pim/datebook/dateentry.ui @@ -81,33 +81,33 @@ <cstring>TextLabel2_2</cstring> </property> <property stdset="1"> <name>text</name> <string>Category</string> </property> <property> <name>buddy</name> <cstring>comboPriority</cstring> </property> </widget> <widget row="0" column="1" rowspan="1" colspan="3" > <class>QComboBox</class> <item> <property> <name>text</name> - <string>(None)</string> + <string></string> </property> </item> <item> <property> <name>text</name> <string>Meeting</string> </property> </item> <item> <property> <name>text</name> <string>Lunch</string> </property> </item> <item> <property> @@ -148,33 +148,33 @@ <widget row="0" column="0" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel1</cstring> </property> <property stdset="1"> <name>text</name> <string>Description:</string> </property> </widget> <widget row="1" column="1" rowspan="1" colspan="3" > <class>QComboBox</class> <item> <property> <name>text</name> - <string>(Unknown)</string> + <string></string> </property> </item> <item> <property> <name>text</name> <string>Office</string> </property> </item> <item> <property> <name>text</name> <string>Home</string> </property> </item> <property stdset="1"> <name>name</name> diff --git a/core/pim/datebook/dateentryimpl.cpp b/core/pim/datebook/dateentryimpl.cpp index 1122f79..b2e3e3a 100644 --- a/core/pim/datebook/dateentryimpl.cpp +++ b/core/pim/datebook/dateentryimpl.cpp @@ -28,49 +28,52 @@ #include <qpe/timeconversion.h> #include <qpe/timestring.h> #include <qpe/tzselect.h> #include <qcheckbox.h> #include <qcombobox.h> #include <qlayout.h> #include <qlineedit.h> #include <qmultilineedit.h> #include <qpopupmenu.h> #include <qscrollview.h> #include <qspinbox.h> #include <qtoolbutton.h> #include <stdlib.h> +#include <stdiostream.h> + /* * Constructs a DateEntry which is a child of 'parent', with the * name 'name' and widget flags set to 'f' * * The dialog will by default be modeless, unless you set 'modal' to * TRUE to construct a modal dialog. */ DateEntry::DateEntry( bool startOnMonday, const QDateTime &start, const QDateTime &end, bool whichClock, QWidget* parent, const char* name ) : DateEntryBase( parent, name ), ampm( whichClock ), startWeekOnMonday( startOnMonday ) { init(); setDates(start,end); + setFocusProxy(comboDescription); } static void addOrPick( QComboBox* combo, const QString& t ) { for (int i=0; i<combo->count(); i++) { if ( combo->text(i) == t ) { combo->setCurrentItem(i); return; } } combo->setEditText(t); } DateEntry::DateEntry( bool startOnMonday, const Event &event, bool whichClock, QWidget* parent, const char* name ) : DateEntryBase( parent, name ), @@ -163,32 +166,33 @@ void DateEntry::init() this, SLOT(slotChangeStartOfWeek(bool)) ); QPopupMenu *m2 = new QPopupMenu( this ); endPicker = new DateBookMonth( m2, 0, TRUE ); m2->insertItem( endPicker ); buttonEnd->setPopup( m2 ); connect( endPicker, SIGNAL( dateClicked( int, int, int ) ), this, SLOT( endDateChanged( int, int, int ) ) ); } /* * Destroys the object and frees any allocated resources */ DateEntry::~DateEntry() { // no need to delete child widgets, Qt does it all for us + //cout << "Del: " << comboStart->currentText() << endl; } /* * public slot */ void DateEntry::endDateChanged( int y, int m, int d ) { endDate.setYMD( y, m, d ); if ( endDate < startDate ) { endDate = startDate; } buttonEnd->setText( TimeString::shortDate( endDate ) ); endPicker->setDate( endDate.year(), endDate.month(), endDate.day() ); } @@ -257,32 +261,33 @@ void DateEntry::startDateChanged( int y, int m, int d ) } buttonStart->setText( TimeString::shortDate( startDate ) ); // our pickers must be reset... startPicker->setDate( y, m, d ); endPicker->setDate( y, m, d ); } /* * public slot */ void DateEntry::startTimeChanged( int index ) { startTime = parseTime(comboStart->text(index),ampm); changeEndCombo( index ); + //cout << "Start: " << comboStart->currentText() << endl; } /* * public slot */ void DateEntry::typeChanged( const QString &s ) { bool b = s != "All Day"; buttonStart->setEnabled( b ); comboStart->setEnabled( b ); comboEnd->setEnabled( b ); } /* * public slot */ void DateEntry::changeEndCombo( int change ) { @@ -369,32 +374,35 @@ Event DateEntry::event() if ( setenv( "TZ", realTZ, true ) != 0 ) qWarning( "There was a problem setting the timezone." ); // convert UTC to local time (calling tzset internally) ev.setStart( TimeConversion::fromUTC( start_utc ) ); ev.setEnd( TimeConversion::fromUTC( end_utc ) ); // we only have one type of sound at the moment... LOUD!!! if ( comboSound->currentItem() != 0 ) st = Event::Loud; else st = Event::Silent; ev.setAlarm( checkAlarm->isChecked(), spinAlarm->value(), st ); if ( rp.type != Event::NoRepeat ) ev.setRepeat( TRUE, rp ); ev.setNotes( editNote->text() ); + + //cout << "Start: " << comboStart->currentText() << endl; + return ev; } void DateEntry::setRepeatLabel() { switch( rp.type ) { case Event::Daily: cmdRepeat->setText( tr("Daily...") ); break; case Event::Weekly: cmdRepeat->setText( tr("Weekly...") ); break; case Event::MonthlyDay: case Event::MonthlyDate: cmdRepeat->setText( tr("Monthly...") ); |