author | hakan <hakan> | 2002-03-26 19:05:31 (UTC) |
---|---|---|
committer | hakan <hakan> | 2002-03-26 19:05:31 (UTC) |
commit | 78211642003f70797a5faa1767a5ab2f5f83606f (patch) (side-by-side diff) | |
tree | 703df6b1f8a98dbd00066ab3c21419b7f97e41b4 | |
parent | dbbbe1c0600422e4bd2d6a6aba271476f457ed97 (diff) | |
download | opie-78211642003f70797a5faa1767a5ab2f5f83606f.zip opie-78211642003f70797a5faa1767a5ab2f5f83606f.tar.gz opie-78211642003f70797a5faa1767a5ab2f5f83606f.tar.bz2 |
Added shortcut buttons to set the start time
-rw-r--r-- | core/pim/datebook/clickablelabel.cpp | 71 | ||||
-rw-r--r-- | core/pim/datebook/clickablelabel.h | 10 | ||||
-rw-r--r-- | core/pim/datebook/datebook.cpp | 11 | ||||
-rw-r--r-- | core/pim/datebook/datebook.pro | 6 | ||||
-rw-r--r-- | core/pim/datebook/dateentry.ui | 639 | ||||
-rw-r--r-- | core/pim/datebook/dateentryimpl.cpp | 95 | ||||
-rw-r--r-- | core/pim/datebook/dateentryimpl.h | 7 | ||||
-rw-r--r-- | core/pim/datebook/timepicker.cpp | 119 | ||||
-rw-r--r-- | core/pim/datebook/timepicker.h | 32 |
9 files changed, 340 insertions, 650 deletions
diff --git a/core/pim/datebook/clickablelabel.cpp b/core/pim/datebook/clickablelabel.cpp index 6912c34..1dd0d15 100644 --- a/core/pim/datebook/clickablelabel.cpp +++ b/core/pim/datebook/clickablelabel.cpp @@ -1,31 +1,88 @@ #include "clickablelabel.h" +#include <stdio.h> ClickableLabel::ClickableLabel(QWidget* parent = 0, const char* name = 0, WFlags fl = 0) : QLabel(parent,name,fl) { - setFrameShape(NoFrame); + textInverted=false; + isToggle=false; + isDown=false; + showState(false); setFrameShadow(Sunken); } +void ClickableLabel::setToggleButton(bool t) { + isToggle=t; +} + void ClickableLabel::mousePressEvent( QMouseEvent *e ) { - setFrameShape(Panel); - repaint(); + if (isToggle && isDown) { + showState(false); + } else { + showState(true); + } } void ClickableLabel::mouseReleaseEvent( QMouseEvent *e ) { - setFrameShape(NoFrame); - repaint(); + if (rect().contains(e->pos()) && isToggle) isDown=!isDown; + + if (isToggle && isDown) { + showState(true); + } else { + showState(false); + } + if (rect().contains(e->pos())) { + if (isToggle) { + emit toggled(isDown); + } emit clicked(); } } void ClickableLabel::mouseMoveEvent( QMouseEvent *e ) { if (rect().contains(e->pos())) { - setFrameShape(Panel); + if (isToggle && isDown) { + showState(false); } else { - setFrameShape(NoFrame); + showState(true); } + } else { + if (isToggle && isDown) { + showState(true); + } else { + showState(false); + } + } +} + +void ClickableLabel::showState(bool on) { + if (on) { + //setFrameShape(Panel); + setInverted(true); + setBackgroundMode(PaletteHighlight); + } else { + //setFrameShape(NoFrame); + setInverted(false); + setBackgroundMode(PaletteBackground); + } + repaint(); +} + +void ClickableLabel::setInverted(bool on) { + if ( (!textInverted && on) || (textInverted && !on) ) { + QPalette pal=palette(); + QColor col=pal.color(QPalette::Normal, QColorGroup::Foreground); + col.setRgb(255-col.red(),255-col.green(),255-col.blue()); + pal.setColor(QPalette::Normal, QColorGroup::Foreground, col); + setPalette(pal); + textInverted=!textInverted; + } +} + +void ClickableLabel::setOn(bool on) { + isDown=on; + showState(isDown); } diff --git a/core/pim/datebook/clickablelabel.h b/core/pim/datebook/clickablelabel.h index b6d33ad..d00fee6 100644 --- a/core/pim/datebook/clickablelabel.h +++ b/core/pim/datebook/clickablelabel.h @@ -1,20 +1,30 @@ #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); + void setToggleButton(bool t); protected: void mousePressEvent( QMouseEvent *e ); void mouseReleaseEvent( QMouseEvent *e ); void mouseMoveEvent( QMouseEvent *e ); + public slots: + void setOn(bool on); signals: void clicked(); + void toggled(bool on); + private: + bool isToggle; + bool isDown; + void showState(bool on); + bool textInverted; + void setInverted(bool on); }; #endif diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp index 92dbdc8..2deb96f 100644 --- a/core/pim/datebook/datebook.cpp +++ b/core/pim/datebook/datebook.cpp @@ -1,956 +1,967 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** 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> #include <qpe/xmlreader.h> #include <qaction.h> #include <qcopchannel_qws.h> #include <qdatetime.h> #include <qdialog.h> #include <qfile.h> #include <qlabel.h> #include <qlayout.h> #include <qmessagebox.h> #include <qpopupmenu.h> #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 ); QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), 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 ); QPopupMenu *default_view = new QPopupMenu(this); settings->insertItem( tr( "Default View" ),default_view ); default_view->setCheckable(TRUE); 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&)) ); + channel = new QCopChannel( "QPE/Datebook", this ); + connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), + this, SLOT(receive(const QCString&, const QByteArray&)) ); #endif #endif qDebug("done t=%d", t.elapsed() ); } void DateBook::receive( const QCString &msg, const QByteArray &data ) { QDataStream stream( data, IO_ReadOnly ); if ( msg == "timeChange(QString)" ) { // update active view! if ( dayAction->isOn() ) viewDay(); else if ( weekAction->isOn() ) viewWeek(); else if ( monthAction->isOn() ) viewMonth(); } + else if (msg == "editEvent(int)") { + /* Not yet working... + int uid; + stream >> uid; + Event e=db->getEvent(uid); + editEvent(e); + */ + } } DateBook::~DateBook() { } void DateBook::slotSettings() { DateBookSettings frmSettings( ampm, this ); frmSettings.setStartTime( startTime ); frmSettings.setAlarmPreset( aPreset, presetTime ); #if defined (Q_WS_QWS) || defined(_WS_QWS_) frmSettings.showMaximized(); #endif if ( frmSettings.exec() ) { aPreset = frmSettings.alarmPreset(); presetTime = frmSettings.presetTime(); startTime = frmSettings.startTime(); if ( dayView ) dayView->setStartViewTime( startTime ); if ( weekView ) weekView->setStartViewTime( startTime ); saveSettings(); // make the change obvious if ( views->visibleWidget() ) { if ( views->visibleWidget() == dayView ) dayView->redraw(); else if ( views->visibleWidget() == weekView ) weekView->redraw(); } } } void DateBook::fileNew() { slotNewEventFromKey(""); } QString DateBook::checkEvent(const Event &e) { /* check if overlaps with itself */ bool checkFailed = FALSE; /* check the next 12 repeats. should catch most problems */ QDate current_date = e.start().date(); Event previous = e; for(int i = 0; i < 12; i++) { QDateTime next; if (!nextOccurance(previous, current_date.addDays(1), next)) { break; // no more repeats } if(next < previous.end()) { checkFailed = TRUE; break; } current_date = next.date(); } 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::view(int v, const QDate &d) { if (v==DAY) { initDay(); dayAction->setOn( TRUE ); dayView->setDate( d ); views->raiseWidget( dayView ); dayView->redraw(); } else if (v==WEEK) { initWeek(); weekAction->setOn( TRUE ); weekView->setDate( d ); views->raiseWidget( weekView ); weekView->redraw(); } else if (v==WEEKLST) { initWeekLst(); weekLstAction->setOn( TRUE ); weekLstView->setDate(d); views->raiseWidget( weekLstView ); weekLstView->redraw(); } else if (v==MONTH) { initMonth(); monthAction->setOn( TRUE ); monthView->setDate( d.year(), d.month(), d.day() ); views->raiseWidget( monthView ); monthView->redraw(); } } void DateBook::viewDefault(const QDate &d) { Config config("DateBook"); config.setGroup("Main"); int current=config.readNumEntry("defaultview", DAY); view(current,d); } void DateBook::viewDay() { view(DAY,currentDate()); } void DateBook::viewWeek() { view(WEEK,currentDate()); } void DateBook::viewWeekLst() { view(WEEKLST,currentDate()); } void DateBook::viewMonth() { view(MONTH,currentDate()); } void DateBook::editEvent( const Event &e ) { if (syncing) { QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); return; } // workaround added for text input. QDialog editDlg( this, 0, TRUE ); DateEntry *entry; editDlg.setCaption( tr("Edit Event") ); QVBoxLayout *vb = new QVBoxLayout( &editDlg ); QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); 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) 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; } QString strName = e.description(); if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) return; db->removeEvent( e ); if ( views->visibleWidget() == dayView && dayView ) dayView->redraw(); } void DateBook::addEvent( const Event &e ) { QDate d = e.start().date(); initDay(); dayView->setDate( d ); } void DateBook::showDay( int year, int month, int day ) { QDate d(year, month, day); view(DAY,d); } void DateBook::initDay() { if ( !dayView ) { dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); views->addWidget( dayView, DAY ); dayView->setStartViewTime( startTime ); connect( this, SIGNAL( newEvent() ), dayView, SLOT( redraw() ) ); connect( dayView, SIGNAL( newEvent() ), this, SLOT( fileNew() ) ); connect( dayView, SIGNAL( removeEvent( const Event & ) ), this, SLOT( removeEvent( const Event & ) ) ); connect( dayView, SIGNAL( editEvent( const Event & ) ), this, SLOT( editEvent( const Event & ) ) ); connect( dayView, SIGNAL( beamEvent( const Event & ) ), this, SLOT( beamEvent( const Event & ) ) ); connect( dayView, SIGNAL(sigNewEvent(const QString &)), this, SLOT(slotNewEventFromKey(const QString &)) ); } } void DateBook::initWeek() { if ( !weekView ) { weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); weekView->setStartViewTime( startTime ); views->addWidget( weekView, WEEK ); connect( weekView, SIGNAL( showDate( int, int, int ) ), this, SLOT( showDay( int, int, int ) ) ); connect( this, SIGNAL( newEvent() ), weekView, SLOT( redraw() ) ); } //But also get it right: the year that we display can be different //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() { { Config config( "qpe" ); config.setGroup("Time"); ampm = config.readBoolEntry( "AMPM", TRUE ); onMonday = config.readBoolEntry( "MONDAY" ); } { Config config("DateBook"); config.setGroup("Main"); 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; QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60)); if ( list.count() > 0 ) { QString msg; bool bSound = FALSE; int stopTimer = 0; bool found = FALSE; for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) { if ( (*it).event().hasAlarm() ) { found = TRUE; msg += "<CENTER><B>" + (*it).description() + "</B>" + "<BR>" + (*it).location() + "<BR>" + TimeString::dateString((*it).event().start(),ampm) + (warn ? tr(" (in " + QString::number(warn) + tr(" minutes)")) : QString("")) + "<BR>" + (*it).notes() + "</CENTER>"; if ( (*it).event().alarmSound() != Event::Silent ) { bSound = TRUE; } } } if ( found ) { if ( bSound ) { Sound::soundAlarm(); stopTimer = startTimer( 5000 ); } QDialog dlg( this, 0, TRUE ); QVBoxLayout *vb = new QVBoxLayout( &dlg ); QScrollView *view = new QScrollView( &dlg, "scrollView"); view->setResizePolicy( QScrollView::AutoOneFit ); vb->addWidget( view ); QLabel *lblMsg = new QLabel( msg, &dlg ); view->addChild( lblMsg ); QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg ); connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) ); vb->addWidget( cmdOk ); #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(); } } void DateBook::reload() { db->reload(); if ( dayAction->isOn() ) viewDay(); else if ( weekAction->isOn() ) viewWeek(); else if ( monthAction->isOn() ) viewMonth(); syncing = FALSE; } void DateBook::flush() { syncing = TRUE; db->save(); } 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 using default view viewDefault(QDate::currentDate()); } void DateBook::closeEvent( QCloseEvent *e ) { if(syncing) { /* no need to save, did that at flush */ e->accept(); return; } // save settings will generate it's own error messages, no // need to do checking ourselves. saveSettings(); if ( db->save() ) e->accept(); else { if ( QMessageBox::critical( this, tr( "Out of space" ), tr("Calendar was unable to save\n" "your changes.\n" "Free up some space and try again.\n" "\nQuit anyway?"), QMessageBox::Yes|QMessageBox::Escape, QMessageBox::No|QMessageBox::Default ) != QMessageBox::No ) e->accept(); else e->ignore(); } } // Entering directly from the "keyboard" void DateBook::slotNewEventFromKey( const QString &str ) { if (syncing) { QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); return; } // We get to here from a key pressed in the Day View // 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)") ); ev.setStart( start ); ev.setEnd( end ); e = new DateEntry( onMonday, ev, ampm, &newDlg ); e->setAlarmEnabled( aPreset, presetTime, Event::Loud ); sv->addChild( e ); #if defined(Q_WS_QWS) || defined(_WS_QWS_) newDlg.showMaximized(); #endif while (newDlg.exec()) { ev = e->event(); ev.assignUid(); QString error = checkEvent( ev ); if ( !error.isNull() ) { if ( QMessageBox::warning( this, tr("Error!"), error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 ) continue; } db->addEvent( ev ); emit newEvent(); break; } } void DateBook::setDocument( const QString &filename ) { if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; QValueList<Event> tl = Event::readVCalendar( filename ); for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) { db->addEvent( *it ); } } static const char * beamfile = "/tmp/obex/event.vcs"; void DateBook::beamEvent( const Event &e ) { qDebug("trying to beamn"); unlink( beamfile ); // delete if exists mkdir("/tmp/obex/", 0755); Event::writeVCalendar( beamfile, e ); Ir *ir = new Ir( this ); connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); QString description = e.description(); ir->send( beamfile, description, "text/x-vCalendar" ); } void DateBook::beamDone( Ir *ir ) { delete ir; unlink( beamfile ); } void DateBook::slotFind() { // move it to the day view... viewDay(); FindDialog frmFind( "Calendar", this ); frmFind.setUseDate( true ); frmFind.setDate( currentDate() ); QObject::connect( &frmFind, SIGNAL(signalFindClicked(const QString&, const QDate&, bool, bool, int)), this, SLOT(slotDoFind(const QString&, const QDate&, bool, bool, int)) ); QObject::connect( this, SIGNAL(signalNotFound()), &frmFind, SLOT(slotNotFound()) ); QObject::connect( this, SIGNAL(signalWrapAround()), &frmFind, SLOT(slotWrapAround()) ); frmFind.exec(); inSearch = false; } bool catComp( QArray<int> cats, int category ) { bool returnMe; int i, count; count = int(cats.count()); returnMe = false; if ( (category == -1 && count == 0) || category == -2 ) returnMe = true; else { for ( i = 0; i < count; i++ ) { if ( category == cats[i] ) { returnMe = true; break; } } } return returnMe; } void DateBook::slotDoFind( const QString& txt, const QDate &dt, bool caseSensitive, bool /*backwards*/, int category ) { QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ), next; QRegExp r( txt ); r.setCaseSensitive( caseSensitive ); static Event rev, nonrev; if ( !inSearch ) { rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); nonrev.setStart( rev.start() ); inSearch = true; } static QDate searchDate = dt; static bool wrapAround = true; bool candidtate; candidtate = false; QValueList<Event> repeats = db->getRawRepeats(); // find the candidate for the first repeat that matches... QValueListConstIterator<Event> it; QDate start = dt; for ( it = repeats.begin(); it != repeats.end(); ++it ) { if ( catComp( (*it).categories(), category ) ) { while ( nextOccurance( *it, start, next ) ) { if ( next < dtEnd ) { if ( (*it).match( r ) && !(next <= rev.start()) ) { rev = *it; dtEnd = next; rev.setStart( next ); candidtate = true; wrapAround = true; start = dt; break; } else start = next.date().addDays( 1 ); } } } } // now the for first non repeat... QValueList<Event> nonRepeats = db->getNonRepeatingEvents( dt, dtEnd.date() ); qHeapSort( nonRepeats.begin(), nonRepeats.end() ); for ( it = nonRepeats.begin(); it != nonRepeats.end(); ++it ) { if ( catComp( (*it).categories(), category ) ) { if ( (*it).start() < dtEnd ) { if ( (*it).match( r ) && !(*it <= nonrev) ) { nonrev = *it; dtEnd = nonrev.start(); candidtate = true; wrapAround = true; break; } } } } if ( candidtate ) { dayView->setStartViewTime( dtEnd.time().hour() ); dayView->setDate( dtEnd.date().year(), dtEnd.date().month(), dtEnd.date().day() ); } else { if ( wrapAround ) { emit signalWrapAround(); rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); nonrev.setStart( rev.start() ); } else emit signalNotFound(); wrapAround = !wrapAround; } } diff --git a/core/pim/datebook/datebook.pro b/core/pim/datebook/datebook.pro index 314a56a..09d5c2d 100644 --- a/core/pim/datebook/datebook.pro +++ b/core/pim/datebook/datebook.pro @@ -1,43 +1,45 @@ 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 \ - clickablelabel.h + clickablelabel.h \ + timepicker.h SOURCES = main.cpp \ datebookday.cpp \ datebook.cpp \ dateentryimpl.cpp \ datebookdayheaderimpl.cpp \ datebooksettings.cpp \ datebookweek.cpp \ datebookweeklst.cpp \ datebookweekheaderimpl.cpp \ repeatentry.cpp \ - clickablelabel.cpp + clickablelabel.cpp \ + timepicker.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 TRANSLATIONS += ../i18n/pt_BR/datebook.ts diff --git a/core/pim/datebook/dateentry.ui b/core/pim/datebook/dateentry.ui index eac4e23..22ff32d 100644 --- a/core/pim/datebook/dateentry.ui +++ b/core/pim/datebook/dateentry.ui @@ -1,1095 +1,524 @@ <!DOCTYPE UI><UI> <class>DateEntryBase</class> <comment>********************************************************************* ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** 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$ ** *********************************************************************</comment> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>DateEntryBase</cstring> </property> <property stdset="1"> <name>geometry</name> <rect> <x>0</x> <y>0</y> <width>242</width> <height>339</height> </rect> </property> <property stdset="1"> <name>caption</name> <string>New Event</string> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> </property> <grid> <property stdset="1"> <name>margin</name> <number>0</number> </property> <property stdset="1"> <name>spacing</name> <number>0</number> </property> <widget row="1" column="0" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel2</cstring> </property> <property stdset="1"> <name>frameShape</name> <enum>MShape</enum> </property> <property stdset="1"> <name>frameShadow</name> <enum>MShadow</enum> </property> <property stdset="1"> <name>text</name> <string>Location</string> </property> </widget> <widget row="2" column="0" > <class>QLabel</class> <property stdset="1"> <name>name</name> <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></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> <name>text</name> <string>Dinner</string> </property> </item> <item> <property> <name>text</name> <string>Travel</string> </property> </item> <property stdset="1"> <name>name</name> <cstring>comboDescription</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>7</hsizetype> <vsizetype>0</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>editable</name> <bool>true</bool> </property> <property stdset="1"> <name>currentItem</name> <number>0</number> </property> <property stdset="1"> <name>duplicatesEnabled</name> <bool>false</bool> </property> </widget> <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></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> <cstring>comboLocation</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>7</hsizetype> <vsizetype>0</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>editable</name> <bool>true</bool> </property> <property stdset="1"> <name>currentItem</name> <number>0</number> </property> <property stdset="1"> <name>duplicatesEnabled</name> <bool>false</bool> </property> </widget> <widget row="2" column="1" rowspan="1" colspan="3" > <class>CategorySelect</class> <property stdset="1"> <name>name</name> <cstring>comboCategory</cstring> </property> </widget> <widget row="3" column="0" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel3</cstring> </property> <property stdset="1"> <name>text</name> <string>Start</string> </property> </widget> <widget row="3" column="1" > <class>QPushButton</class> <property stdset="1"> <name>name</name> <cstring>buttonStart</cstring> </property> <property stdset="1"> <name>text</name> <string>Jan 02 00</string> </property> </widget> <widget row="3" column="2" rowspan="1" colspan="2" > - <class>QComboBox</class> - <item> - <property> - <name>text</name> - <string>00:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>00:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>01:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>01:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>02:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>02:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>03:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>03:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>04:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>04:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>05:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>05:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>06:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>06:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>07:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>07:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>08:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>08:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>09:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>09:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>10:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>10:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>11:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>11:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>12:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>12:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>13:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>13:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>14:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>14:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>15:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>15:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>16:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>16:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>17:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>17:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>18:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>18:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>19:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>19:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>20:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>20:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>21:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>21:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>22:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>22:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>23:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>23:30</string> - </property> - </item> + <class>QLineEdit</class> <property stdset="1"> <name>name</name> <cstring>comboStart</cstring> </property> + </widget> + <widget row="5" column="1" colspan="3"> + <class>TimePicker</class> <property stdset="1"> - <name>editable</name> - <bool>true</bool> - </property> - <property stdset="1"> - <name>duplicatesEnabled</name> - <bool>false</bool> + <name>name</name> + <cstring>timePickerStart</cstring> </property> </widget> <widget row="4" column="1" > <class>QPushButton</class> <property stdset="1"> <name>name</name> <cstring>buttonEnd</cstring> </property> <property stdset="1"> <name>text</name> <string>Jan 02 00</string> </property> </widget> <widget row="4" column="2" rowspan="1" colspan="2" > - <class>QComboBox</class> - <item> - <property> - <name>text</name> - <string>00:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>00:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>01:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>01:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>02:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>02:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>03:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>03:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>04:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>04:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>05:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>05:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>06:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>06:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>07:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>07:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>08:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>08:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>09:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>09:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>10:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>10:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>11:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>11:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>12:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>12:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>13:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>13:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>14:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>14:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>15:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>15:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>16:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>16:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>17:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>17:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>18:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>18:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>19:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>19:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>20:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>20:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>21:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>21:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>22:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>22:30</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>23:00</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>23:30</string> - </property> - </item> + <class>QLineEdit</class> <property stdset="1"> <name>name</name> <cstring>comboEnd</cstring> </property> - <property stdset="1"> - <name>editable</name> - <bool>true</bool> - </property> - <property stdset="1"> - <name>duplicatesEnabled</name> - <bool>false</bool> - </property> </widget> <widget row="4" column="0" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel3_2</cstring> </property> <property stdset="1"> <name>text</name> <string>End</string> </property> </widget> - <widget row="5" column="0" > + <widget row="6" column="0" > <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>checkAllDay</cstring> </property> <property stdset="1"> <name>text</name> <string>All day</string> </property> </widget> - <widget row="6" column="0" > + <widget row="7" column="0" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel3_2_2</cstring> </property> <property stdset="1"> <name>text</name> <string>Time zone:</string> </property> </widget> - <widget row="6" column="1" rowspan="1" colspan="3" > + <widget row="7" column="1" rowspan="1" colspan="3" > <class>TimeZoneSelector</class> <property stdset="1"> <name>name</name> <cstring>timezone</cstring> </property> </widget> - <widget row="7" column="0" > + <widget row="8" column="0" > <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>checkAlarm</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>true</bool> </property> <property stdset="1"> <name>autoMask</name> <bool>false</bool> </property> <property stdset="1"> <name>text</name> <string>&Alarm</string> </property> <property stdset="1"> <name>checked</name> <bool>false</bool> </property> </widget> - <widget row="7" column="1" rowspan="1" colspan="2" > + <widget row="8" column="1" rowspan="1" colspan="2" > <class>QSpinBox</class> <property stdset="1"> <name>name</name> <cstring>spinAlarm</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>false</bool> </property> <property stdset="1"> <name>suffix</name> <string> minutes</string> </property> <property stdset="1"> <name>maxValue</name> <number>180</number> </property> <property stdset="1"> <name>minValue</name> <number>0</number> </property> <property stdset="1"> <name>lineStep</name> <number>5</number> </property> <property stdset="1"> <name>value</name> <number>5</number> </property> </widget> - <widget row="7" column="3" > + <widget row="8" column="3" > <class>QComboBox</class> <item> <property> <name>text</name> <string>Silent</string> </property> </item> <item> <property> <name>text</name> <string>Loud</string> </property> </item> <property stdset="1"> <name>name</name> <cstring>comboSound</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>false</bool> </property> </widget> - <widget row="8" column="0" > + <widget row="9" column="0" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>lblRepeat</cstring> </property> <property stdset="1"> <name>text</name> <string>Repeat</string> </property> </widget> - <widget row="8" column="1" rowspan="1" colspan="3" > + <widget row="9" column="1" rowspan="1" colspan="3" > <class>QToolButton</class> <property stdset="1"> <name>name</name> <cstring>cmdRepeat</cstring> </property> <property stdset="1"> <name>focusPolicy</name> <enum>TabFocus</enum> </property> <property stdset="1"> <name>text</name> <string>No Repeat...</string> </property> </widget> - <widget row="9" column="0" rowspan="1" colspan="4" > + <widget row="10" column="0" rowspan="1" colspan="4" > <class>QMultiLineEdit</class> <property stdset="1"> <name>name</name> <cstring>editNote</cstring> </property> </widget> </grid> </widget> <customwidgets> <customwidget> <class>TimeZoneSelector</class> <header location="global">qpe/tzselect.h</header> <sizehint> <width>21</width> <height>10</height> </sizehint> <container>0</container> <sizepolicy> <hordata>7</hordata> <verdata>1</verdata> </sizepolicy> <pixmap>image0</pixmap> </customwidget> <customwidget> <class>CategorySelect</class> <header location="global">qpe/categoryselect.h</header> <sizehint> <width>-1</width> <height>-1</height> </sizehint> <container>0</container> <sizepolicy> <hordata>7</hordata> <verdata>1</verdata> </sizepolicy> <pixmap>image1</pixmap> </customwidget> + <customwidget> + <class>TimePicker</class> + <header location="local">timepicker.h</header> + <sizehint> + <width>-1</width> + <height>-1</height> + </sizehint> + <container>0</container> + <sizepolicy> + <hordata>7</hordata> + <verdata>1</verdata> + </sizepolicy> + <pixmap>image1</pixmap> + </customwidget> </customwidgets> <images> <image> <name>image0</name> <data format="XPM.GZ" length="45">789cd3d7528808f055d0d2e72a2e492cc94c5648ce482c52d04a29cdcdad8c8eb5ade6523250004143a55a6b2e0026630c4f</data> </image> <image> <name>image1</name> <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data> </image> </images> <connections> <connection> <sender>checkAlarm</sender> <signal>toggled(bool)</signal> <receiver>spinAlarm</receiver> <slot>setEnabled(bool)</slot> </connection> <connection> <sender>comboEnd</sender> - <signal>activated(const QString&)</signal> + <signal>textChanged(const QString&)</signal> <receiver>DateEntryBase</receiver> <slot>endTimeChanged( const QString & )</slot> </connection> <connection> <sender>cmdRepeat</sender> <signal>clicked()</signal> <receiver>DateEntryBase</receiver> <slot>slotRepeat()</slot> </connection> <connection> <sender>comboStart</sender> - <signal>activated(int)</signal> + <signal>textChanged(const QString &)</signal> <receiver>DateEntryBase</receiver> - <slot>startTimeChanged( int )</slot> + <slot>startTimeEdited( const QString & )</slot> </connection> <connection> <sender>checkAllDay</sender> <signal>toggled(bool)</signal> <receiver>comboEnd</receiver> <slot>setDisabled(bool)</slot> </connection> <connection> <sender>checkAlarm</sender> <signal>toggled(bool)</signal> <receiver>comboSound</receiver> <slot>setEnabled(bool)</slot> </connection> <connection> <sender>checkAllDay</sender> <signal>toggled(bool)</signal> <receiver>comboStart</receiver> <slot>setDisabled(bool)</slot> </connection> <slot access="public">endDateChanged( const QString & )</slot> <slot access="public">endDateChanged( int, int, int )</slot> <slot access="public">endTimeChanged( const QString & )</slot> <slot access="public">slotRepeat()</slot> <slot access="public">slotWait( int )</slot> <slot access="public">startDateChanged( const QString & )</slot> <slot access="public">startDateChanged(int, int, int)</slot> - <slot access="public">startTimeChanged( int )</slot> + <slot access="public">startTimeEdited( const QString & )</slot> <slot access="public">typeChanged( const QString & )</slot> <slot access="public">tzexecute(void)</slot> </connections> </UI> diff --git a/core/pim/datebook/dateentryimpl.cpp b/core/pim/datebook/dateentryimpl.cpp index b2e3e3a..1c43363 100644 --- a/core/pim/datebook/dateentryimpl.cpp +++ b/core/pim/datebook/dateentryimpl.cpp @@ -1,482 +1,509 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** 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. ** **********************************************************************/ #include "dateentryimpl.h" #include "repeatentry.h" #include <qpe/qpeapplication.h> #include <qpe/categoryselect.h> #include <qpe/datebookmonth.h> #include <qpe/global.h> #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 "timepicker.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 ) { + // Pick an item if one excists for (int i=0; i<combo->count(); i++) { if ( combo->text(i) == t ) { combo->setCurrentItem(i); return; } } - combo->setEditText(t); + + // Else add one + combo->insertItem(t); + combo->setCurrentItem(combo->count()-1); } DateEntry::DateEntry( bool startOnMonday, const Event &event, bool whichClock, QWidget* parent, const char* name ) : DateEntryBase( parent, name ), ampm( whichClock ), startWeekOnMonday( startOnMonday ) { init(); setDates(event.start(),event.end()); comboCategory->setCategories( event.categories(), "Calendar", tr("Calendar") ); if(!event.description().isEmpty()) addOrPick( comboDescription, event.description() ); if(!event.location().isEmpty()) addOrPick( comboLocation, event.location() ); checkAlarm->setChecked( event.hasAlarm() ); checkAllDay->setChecked( event.type() == Event::AllDay ); if(!event.notes().isEmpty()) editNote->setText(event.notes()); spinAlarm->setValue(event.alarmTime()); if ( event.alarmSound() != Event::Silent ) comboSound->setCurrentItem( 1 ); if ( event.hasRepeat() ) { rp = event.repeatPattern(); cmdRepeat->setText( tr("Repeat...") ); } setRepeatLabel(); } void DateEntry::setDates( const QDateTime& s, const QDateTime& e ) { - int shour, - ehour; - QString strStart, - strEnd; startDate = s.date(); endDate = e.date(); startTime = s.time(); endTime = e.time(); startDateChanged( s.date().year(), s.date().month(), s.date().day() ); + endDateChanged( e.date().year(), e.date().month(), e.date().day() ); + updateTimeEdit(true,true); +} + +void DateEntry::updateTimeEdit(bool s, bool e) { + + // Comboboxes + QString strStart, strEnd; + int shour, ehour; if ( ampm ) { - shour = s.time().hour(); - ehour = e.time().hour(); + shour = startTime.hour(); + ehour = endTime.hour(); if ( shour >= 12 ) { if ( shour > 12 ) shour -= 12; - strStart.sprintf( "%d:%02d PM", shour, s.time().minute() ); + strStart.sprintf( "%d:%02d PM", shour, startTime.minute() ); } else { if ( shour == 0 ) shour = 12; - strStart.sprintf( "%d:%02d AM", shour, s.time().minute() ); + strStart.sprintf( "%d:%02d AM", shour, startTime.minute() ); } - if ( ehour == 24 && e.time().minute() == 0 ) { + if ( ehour == 24 && endTime.minute() == 0 ) { strEnd = "11:59 PM"; // or "midnight" } else if ( ehour >= 12 ) { if ( ehour > 12 ) ehour -= 12; - strEnd.sprintf( "%d:%02d PM", ehour, e.time().minute() ); + strEnd.sprintf( "%d:%02d PM", ehour, endTime.minute() ); } else { if ( ehour == 0 ) ehour = 12; - strEnd.sprintf( "%d:%02d AM", ehour, e.time().minute() ); + strEnd.sprintf( "%d:%02d AM", ehour, endTime.minute() ); } } else { - strStart.sprintf( "%02d:%02d", s.time().hour(), s.time().minute() ); - strEnd.sprintf( "%02d:%02d", e.time().hour(), e.time().minute() ); + strStart.sprintf( "%02d:%02d", startTime.hour(), startTime.minute() ); + strEnd.sprintf( "%02d:%02d", endTime.hour(), endTime.minute() ); } - addOrPick(comboStart, strStart ); - endDateChanged( e.date().year(), e.date().month(), e.date().day() ); - addOrPick(comboEnd, strEnd ); + + if (s) comboStart->setText(strStart); + if (e) comboEnd->setText(strEnd); } void DateEntry::init() { comboDescription->setInsertionPolicy(QComboBox::AtCurrent); comboLocation->setInsertionPolicy(QComboBox::AtCurrent); initCombos(); QPopupMenu *m1 = new QPopupMenu( this ); startPicker = new DateBookMonth( m1, 0, TRUE ); m1->insertItem( startPicker ); buttonStart->setPopup( m1 ); connect( startPicker, SIGNAL( dateClicked( int, int, int ) ), this, SLOT( startDateChanged( int, int, int ) ) ); //Let start button change both start and end dates connect( startPicker, SIGNAL( dateClicked( int, int, int ) ), this, SLOT( endDateChanged( int, int, int ) ) ); connect( qApp, SIGNAL( clockChanged( bool ) ), this, SLOT( slotChangeClock( bool ) ) ); connect( qApp, SIGNAL(weekChanged(bool)), 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 ) ) ); + + connect(timePickerStart, SIGNAL( timeChanged(const QTime &) ), + this, SLOT( startTimePicked(const QTime &) )); + editNote->setFixedVisibleLines(3); } /* * 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() ); } static QTime parseTime( const QString& s, bool ampm ) { QTime tmpTime; QStringList l = QStringList::split( ':', s ); int hour = l[0].toInt(); if ( ampm ) { int i=0; while (i<int(l[1].length()) && l[1][i]>='0' && l[1][i]<='9') i++; QString digits = l[1].left(i); if ( l[1].contains( "PM", FALSE ) ) { if ( hour != 12 ) hour += 12; } else { if ( hour == 12 ) hour = 0; } l[1] = digits; } int minute = l[1].toInt(); if ( minute > 59 ) minute = 59; else if ( minute < 0 ) minute = 0; if ( hour > 23 ) { hour = 23; minute = 59; } else if ( hour < 0 ) hour = 0; tmpTime.setHMS( hour, minute, 0 ); return tmpTime; } /* * public slot */ void DateEntry::endTimeChanged( const QString &s ) { QTime tmpTime = parseTime(s,ampm); if ( endDate > startDate || tmpTime >= startTime ) { endTime = tmpTime; } else { endTime = startTime; - comboEnd->setCurrentItem( comboStart->currentItem() ); + //comboEnd->setCurrentItem( comboStart->currentItem() ); } + +} + +void DateEntry::endTimeChanged( const QTime &t ) { } /* * public slot */ void DateEntry::startDateChanged( int y, int m, int d ) { QDate prev = startDate; startDate.setYMD( y, m, d ); if ( rp.type == Event::Weekly && startDate.dayOfWeek() != prev.dayOfWeek() ) { // if we change the start of a weekly repeating event // set the repeating day appropriately char mask = 1 << (prev.dayOfWeek()-1); rp.days &= (~mask); rp.days |= 1 << (startDate.dayOfWeek()-1); } 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 ) +void DateEntry::startTimeEdited( const QString &s ) { - startTime = parseTime(comboStart->text(index),ampm); - changeEndCombo( index ); - //cout << "Start: " << comboStart->currentText() << endl; + startTimeChanged(parseTime(s,ampm)); + updateTimeEdit(false,true); + timePickerStart->setHour(startTime.hour()); + timePickerStart->setMinute(startTime.minute()); } + +void DateEntry::startTimeChanged( const QTime &t ) +{ + int duration=startTime.secsTo(endTime); + startTime = t; + endTime=t.addSecs(duration); +} +void DateEntry::startTimePicked( const QTime &t ) { + startTimeChanged(t); + updateTimeEdit(true,true); +} + /* * 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 ) -{ - if ( change + 2 < comboEnd->count() ) - change += 2; - comboEnd->setCurrentItem( change ); - endTimeChanged( comboEnd->currentText() ); -} void DateEntry::slotRepeat() { // Work around for compiler Bug.. RepeatEntry *e; // it is better in my opinion to just grab this from the mother, // since, this dialog doesn't need to keep track of it... if ( rp.type != Event::NoRepeat ) e = new RepeatEntry( startWeekOnMonday, rp, startDate, this); else e = new RepeatEntry( startWeekOnMonday, startDate, this ); #if defined(Q_WS_QWS) || defined(_WS_QWS_) e->showMaximized(); #endif if ( e->exec() ) { rp = e->repeatPattern(); setRepeatLabel(); } } void DateEntry::slotChangeStartOfWeek( bool onMonday ) { startWeekOnMonday = onMonday; } Event DateEntry::event() { Event ev; Event::SoundTypeChoice st; ev.setDescription( comboDescription->currentText() ); ev.setLocation( comboLocation->currentText() ); ev.setCategories( comboCategory->currentCategories() ); ev.setType( checkAllDay->isChecked() ? Event::AllDay : Event::Normal ); if ( startDate > endDate ) { QDate tmp = endDate; endDate = startDate; startDate = tmp; } - startTime = parseTime( comboStart->currentText(), ampm ); - endTime = parseTime( comboEnd->currentText(), ampm ); + + // This is now done in the changed slots + // startTime = parseTime( comboStart->text(), ampm ); + //endTime = parseTime( comboEnd->text(), ampm ); + if ( startTime > endTime && endDate == startDate ) { QTime tmp = endTime; endTime = startTime; startTime = tmp; } // don't set the time if theres no need too if ( ev.type() == Event::AllDay ) { startTime.setHMS( 0, 0, 0 ); endTime.setHMS( 23, 59, 59 ); } // adjust start and end times based on timezone QDateTime start( startDate, startTime ); QDateTime end( endDate, endTime ); time_t start_utc, end_utc; // qDebug( "tz: %s", timezone->currentZone().latin1() ); // get real timezone QString realTZ; realTZ = QString::fromLocal8Bit( getenv("TZ") ); // set timezone if ( setenv( "TZ", timezone->currentZone(), true ) != 0 ) qWarning( "There was a problem setting the timezone." ); // convert to UTC based on selected TZ (calling tzset internally) start_utc = TimeConversion::toUTC( start ); end_utc = TimeConversion::toUTC( end ); // done playing around... put it all back unsetenv( "TZ" ); if ( !realTZ.isNull() ) 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...") ); break; case Event::Yearly: cmdRepeat->setText( tr("Yearly...") ); break; default: cmdRepeat->setText( tr("No Repeat...") ); } } void DateEntry::setAlarmEnabled( bool alarmPreset, int presetTime, Event::SoundTypeChoice sound ) { checkAlarm->setChecked( alarmPreset ); spinAlarm->setValue( presetTime ); if ( sound != Event::Silent ) comboSound->setCurrentItem( 1 ); else comboSound->setCurrentItem( 0 ); } void DateEntry::initCombos() { + /* comboStart->clear(); comboEnd->clear(); if ( ampm ) { for ( int i = 0; i < 24; i++ ) { if ( i == 0 ) { comboStart->insertItem( "12:00 AM" ); comboStart->insertItem( "12:30 AM" ); comboEnd->insertItem( "12:00 AM" ); comboEnd->insertItem( "12:30 AM" ); } else if ( i == 12 ) { comboStart->insertItem( "12:00 PM" ); comboStart->insertItem( "12:30 PM" ); comboEnd->insertItem( "12:00 PM" ); comboEnd->insertItem( "12:30 PM" ); } else if ( i > 12 ) { comboStart->insertItem( QString::number( i - 12 ) + ":00 PM" ); comboStart->insertItem( QString::number( i - 12 ) + ":30 PM" ); comboEnd->insertItem( QString::number( i - 12 ) + ":00 PM" ); comboEnd->insertItem( QString::number( i - 12 ) + ":30 PM" ); } else { comboStart->insertItem( QString::number( i) + ":00 AM" ); comboStart->insertItem( QString::number( i ) + ":30 AM" ); comboEnd->insertItem( QString::number( i ) + ":00 AM" ); comboEnd->insertItem( QString::number( i ) + ":30 AM" ); } } } else { for ( int i = 0; i < 24; i++ ) { if ( i < 10 ) { comboStart->insertItem( QString("0") + QString::number(i) + ":00" ); comboStart->insertItem( QString("0") + QString::number(i) + ":30" ); comboEnd->insertItem( QString("0") + QString::number(i) + ":00" ); comboEnd->insertItem( QString("0") + QString::number(i) + ":30" ); } else { comboStart->insertItem( QString::number(i) + ":00" ); comboStart->insertItem( QString::number(i) + ":30" ); comboEnd->insertItem( QString::number(i) + ":00" ); comboEnd->insertItem( QString::number(i) + ":30" ); } } } + */ } void DateEntry::slotChangeClock( bool whichClock ) { ampm = whichClock; initCombos(); setDates( QDateTime( startDate, startTime ), QDateTime( endDate, endTime ) ); } diff --git a/core/pim/datebook/dateentryimpl.h b/core/pim/datebook/dateentryimpl.h index 785af7a..bde3119 100644 --- a/core/pim/datebook/dateentryimpl.h +++ b/core/pim/datebook/dateentryimpl.h @@ -1,71 +1,74 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** 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. ** **********************************************************************/ #ifndef DATEENTRY_H #define DATEENTRY_H #include "dateentry.h" #include <qpe/event.h> #include <qdatetime.h> class DateBookMonth; class DateEntry : public DateEntryBase { Q_OBJECT public: DateEntry( bool startOnMonday, const QDateTime &start, const QDateTime &end, bool whichClock = FALSE, QWidget* parent = 0, const char* name = 0 ); DateEntry( bool startOnMonday, const Event &event, bool whichCLock = FALSE, QWidget* parent = 0, const char* name = 0 ); ~DateEntry(); Event event(); void setAlarmEnabled( bool alarmPreset, int presetTime, Event::SoundTypeChoice ); public slots: void endDateChanged( int, int, int ); void endTimeChanged( const QString & ); + void endTimeChanged( const QTime & ); void startDateChanged(int, int, int); - void startTimeChanged( int index ); + void startTimeEdited( const QString & ); + void startTimeChanged( const QTime & ); + void startTimePicked( const QTime & ); void typeChanged( const QString & ); - void changeEndCombo( int change ); void slotRepeat(); void slotChangeClock( bool ); void slotChangeStartOfWeek( bool ); private: void init(); void initCombos(); void setDates( const QDateTime& s, const QDateTime& e ); void setRepeatLabel(); + void updateTimeEdit(bool,bool); DateBookMonth *startPicker, *endPicker; QDate startDate, endDate; QTime startTime, endTime; Event::RepeatPattern rp; bool ampm; bool startWeekOnMonday; }; #endif // DATEENTRY_H diff --git a/core/pim/datebook/timepicker.cpp b/core/pim/datebook/timepicker.cpp new file mode 100644 index 0000000..5f08a05 --- a/dev/null +++ b/core/pim/datebook/timepicker.cpp @@ -0,0 +1,119 @@ +#include "timepicker.h" + +#include <qbuttongroup.h> +#include <qtoolbutton.h> +#include <qlayout.h> +#include "clickablelabel.h" +#include <qstring.h> + +TimePicker::TimePicker(QWidget* parent = 0, const char* name = 0, + WFlags fl = 0) : + QWidget(parent,name,fl) +{ + QVBoxLayout *vbox=new QVBoxLayout(this); + + ClickableLabel *r; + QString s; + + // Hour Row + QWidget *row=new QWidget(this); + QHBoxLayout *l=new QHBoxLayout(row); + vbox->addWidget(row); + + + for (int i=0; i<24; i++) { + r=new ClickableLabel(row); + hourLst.append(r); + s.sprintf("%.2d",i); + r->setText(s); + r->setToggleButton(true); + r->setAlignment(AlignHCenter | AlignVCenter); + l->addWidget(r); + connect(r, SIGNAL(toggled(bool)), + this, SLOT(slotHour(bool))); + + if (i==11) { // Second row + row=new QWidget(this); + l=new QHBoxLayout(row); + vbox->addWidget(row); + } + } + + // Minute Row + row=new QWidget(this); + l=new QHBoxLayout(row); + vbox->addWidget(row); + + for (int i=0; i<60; i+=5) { + r=new ClickableLabel(row); + minuteLst.append(r); + s.sprintf("%.2d",i); + r->setText(s); + r->setToggleButton(true); + r->setAlignment(AlignHCenter | AlignVCenter); + l->addWidget(r); + connect(r, SIGNAL(toggled(bool)), + this, SLOT(slotMinute(bool))); + } +} + +void TimePicker::slotHour(bool b) { + + ClickableLabel *r = (ClickableLabel *) sender(); + + if (b) { + QValueListIterator<ClickableLabel *> it; + for (it=hourLst.begin(); it!=hourLst.end(); it++) { + if (*it != r) (*it)->setOn(false); + else tm.setHMS((*it)->text().toInt(), tm.minute(), 0); + } + emit timeChanged(tm); + } else { + r->setOn(true); + } + +} + +void TimePicker::slotMinute(bool b) { + + ClickableLabel *r = (ClickableLabel *) sender(); + + if (b) { + QValueListIterator<ClickableLabel *> it; + for (it=minuteLst.begin(); it!=minuteLst.end(); it++) { + if (*it != r) (*it)->setOn(false); + else tm.setHMS(tm.hour(),(*it)->text().toInt(), 0); + } + emit timeChanged(tm); + } else { + r->setOn(true); + } + +} + +void TimePicker::setMinute(int m) { + + QString minute; + minute.sprintf("%.2d",m); + + QValueListIterator<ClickableLabel *> it; + for (it=minuteLst.begin(); it!=minuteLst.end(); it++) { + if ((*it)->text() == minute) (*it)->setOn(true); + else (*it)->setOn(false); + } + + tm.setHMS(tm.hour(),m,0); +} + +void TimePicker::setHour(int h) { + + QString hour; + hour.sprintf("%.2d",h); + + QValueListIterator<ClickableLabel *> it; + for (it=hourLst.begin(); it!=hourLst.end(); it++) { + if ((*it)->text() == hour) (*it)->setOn(true); + else (*it)->setOn(false); + } + tm.setHMS(h,tm.minute(),0); +} diff --git a/core/pim/datebook/timepicker.h b/core/pim/datebook/timepicker.h new file mode 100644 index 0000000..0acadcb --- a/dev/null +++ b/core/pim/datebook/timepicker.h @@ -0,0 +1,32 @@ +#ifndef TIMEPICKER_H +#define TIMEPICKER_H + +#include <qwidget.h> +#include <qvaluelist.h> +#include "clickablelabel.h" +#include <qdatetime.h> + +class TimePicker: public QWidget { + Q_OBJECT + + public: + TimePicker(QWidget* parent = 0, const char* name = 0, + WFlags fl = 0); + void setHour(int h); + void setMinute(int m); + + private: + QValueList<ClickableLabel *> hourLst; + QValueList<ClickableLabel *> minuteLst; + QTime tm; + + private slots: + void slotHour(bool b); + void slotMinute(bool b); + + signals: + void timeChanged(const QTime &); +}; + + +#endif |