-rw-r--r-- | core/pim/today/today.cpp | 186 |
1 files changed, 118 insertions, 68 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index 7cef035..028947d 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp @@ -23,3 +23,3 @@ #include <qpe/config.h> -#include <qpe/qcopenvelope_qws.h> +#include <qpe/qcopenvelope_qws.h> #include <qpe/qprocess.h> @@ -32,3 +32,3 @@ #include <qfile.h> -#include <qdatetime.h> +#include <qdatetime.h> #include <qtextstream.h> @@ -58,5 +58,5 @@ int NEW_START=1; -/* - * Constructs a Example which is a child of 'parent', with the - * name 'name' and widget flags set to 'f' +/* + * Constructs a Example which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' */ @@ -68,4 +68,4 @@ Today::Today( QWidget* parent, const char* name, WFlags fl ) QObject::connect( (QObject*)MailButton, SIGNAL( clicked() ), this, SLOT(startMail() ) ); - -#if defined(Q_WS_QWS) + +#if defined(Q_WS_QWS) #if !defined(QT_NO_COP) @@ -76,3 +76,5 @@ Today::Today( QWidget* parent, const char* name, WFlags fl ) #endif - + + + db = NULL; @@ -100,3 +102,3 @@ void Today::channelReceived(const QCString &msg, const QByteArray & data) { * Initialises the owner field with the default value, the username - */ + */ void Today::setOwnerField() { @@ -119,3 +121,3 @@ void Today::setOwnerField(QString &message) { } -} +} @@ -127,3 +129,3 @@ void Today::autoStart() { Config cfg("today"); - cfg.setGroup("Autostart"); + cfg.setGroup("Autostart"); AUTOSTART = cfg.readNumEntry("autostart",1); @@ -147,3 +149,3 @@ void Today::draw() { getMail(); - + // if the todolist.xml file was not modified in between, do not parse it. @@ -223,6 +225,6 @@ void Today::startConfig() { Config cfg("today"); - cfg.setGroup("BaseConfig"); - + cfg.setGroup("BaseConfig"); + //init(); - + conf->SpinBox1->setValue(MAX_LINES_MEET); @@ -242,3 +244,3 @@ void Today::startConfig() { conf->exec(); - + int maxlinestask = conf->SpinBox2->value(); @@ -250,5 +252,5 @@ void Today::startConfig() { int autostart =conf->CheckBoxAuto->isChecked(); - + cfg.writeEntry("maxlinestask",maxlinestask); - cfg.writeEntry("maxcharclip", maxcharclip); + cfg.writeEntry("maxcharclip", maxcharclip); cfg.writeEntry("maxlinesmeet",maxmeet); @@ -259,5 +261,5 @@ void Today::startConfig() { cfg.writeEntry("autostart", autostart); - + // sync it to "disk" - cfg.write(); + cfg.write(); NEW_START=1; @@ -281,3 +283,3 @@ void Today::getDates() { } - db = new DateBookDB; + db = new DateBookDB; @@ -291,11 +293,11 @@ void Today::getDates() { //bool ampm = config.readBoolEntry( "AMPM", TRUE ); - + int count=0; - + if ( list.count() > 0 ) { - + for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) { - - + + if ( count <= MAX_LINES_MEET ) { @@ -303,3 +305,3 @@ void Today::getDates() { QTime time = QTime::currentTime(); - + if (!ONLY_LATER) { @@ -312,3 +314,3 @@ void Today::getDates() { count++; - + // show only later appointments @@ -318,3 +320,3 @@ void Today::getDates() { this, SLOT(editEvent(const Event &))); - } + } } @@ -325,3 +327,3 @@ void Today::getDates() { layoutDates->addWidget(noMoreEvents); - } + } } else { @@ -331,3 +333,3 @@ void Today::getDates() { } - + layoutDates->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); @@ -336,3 +338,3 @@ void Today::getDates() { } - + @@ -340,4 +342,4 @@ void Today::getMail() { Config cfg("opiemail"); - cfg.setGroup("today"); - + cfg.setGroup("today"); + // how many lines should be showed in the task section @@ -345,5 +347,5 @@ void Today::getMail() { int OUTGOING = cfg.readNumEntry("outgoing",0); - + QString output = tr("<b>%1</b> new mail(s), <b>%2</b> outgoing").arg(NEW_MAILS).arg(OUTGOING); - + MailField->setText(output); @@ -356,3 +358,3 @@ void Today::getMail() { void Today::getTodo() { - + QString output; @@ -372,3 +374,3 @@ void Today::getTodo() { } - + // get total number of still open todos @@ -380,3 +382,3 @@ void Today::getTodo() { count +=1; - // not the overdues, we allready got them, and not if we are + // not the overdues, we allready got them, and not if we are // over the maxlines @@ -388,4 +390,4 @@ void Today::getTodo() { } - - + + if (count > 0) { @@ -400,3 +402,3 @@ void Today::getTodo() { } - + TodoField->setText(tr(output)); @@ -407,3 +409,3 @@ void Today::getTodo() { */ -void Today::startDatebook() { +void Today::startDatebook() { QCopEnvelope e("QPE/System", "execute(QString)"); @@ -414,3 +416,3 @@ void Today::startDatebook() { * starts the edit dialog as known from datebook - */ + */ @@ -420,3 +422,3 @@ void Today::editEvent(const Event &e) { startDatebook(); - + while(!QCopChannel::isRegistered("QPE/Datebook")) todayApp->processEvents(); @@ -428,3 +430,3 @@ void Today::editEvent(const Event &e) { * launches todolist - */ + */ void Today::startTodo() { @@ -446,18 +448,21 @@ Today::~Today() { - - /* - * Gets the events for the current day, if it should get all dates + * Gets the events for the current day, if it should get all dates */ -DateBookEvent::DateBookEvent(const EffectiveEvent &ev, - QWidget* parent = 0, +DateBookEvent::DateBookEvent(const EffectiveEvent &ev, + QWidget* parent = 0, int SHOW_LOCATION = 0, int SHOW_NOTES = 0, - const char* name = 0, + const char* name = 0, WFlags fl = 0) : ClickableLabel(parent,name,fl), event(ev) { - + QString msg; //QTime time = QTime::currentTime(); - + + Config config( "qpe" ); + // if 24 h format + ampm = config.readBoolEntry( "AMPM", TRUE ); + + if (!ONLY_LATER) { @@ -471,3 +476,3 @@ DateBookEvent::DateBookEvent(const EffectiveEvent &ev, } - + if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { @@ -476,7 +481,7 @@ DateBookEvent::DateBookEvent(const EffectiveEvent &ev, // start time of event - msg += "<br>" + TimeString::timeString(QTime((ev).event().start().time()) ) + msg += "<br>" + ampmTime(QTime((ev).event().start().time()) ); // end time of event - + "<b> - </b>" + TimeString::timeString(QTime((ev).event().end().time()) ); + + "<b> - </b>" + ampmTime(QTime((ev).event().end().time()) ); } - + // include possible note or not @@ -492,13 +497,38 @@ DateBookEvent::DateBookEvent(const EffectiveEvent &ev, -DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev, - QWidget* parent = 0, +QString DateBookEvent::ampmTime(QTime tm) { + + QString s; + if( ampm ) { + int hour = tm.hour(); + if (hour == 0) + hour = 12; + if (hour > 12) + hour -= 12; + s.sprintf( "%2d:%02d %s", hour, tm.minute(), + (tm.hour() >= 12) ? "PM" : "AM" ); + return s; + } else { + s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); + return s; + } + +} + + +DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev, + QWidget* parent = 0, int SHOW_LOCATION = 0, int SHOW_NOTES = 0, - const char* name = 0, + const char* name = 0, WFlags fl = 0) : ClickableLabel(parent,name,fl), event(ev) { - + QString msg; QTime time = QTime::currentTime(); - + + Config config( "qpe" ); + // if 24 h format + ampm = config.readBoolEntry( "AMPM", TRUE ); + + if ((time.toString() <= TimeString::dateString((ev).event().end())) ) { @@ -513,3 +543,3 @@ DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev, } - + if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { @@ -518,5 +548,5 @@ DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev, // start time of event - msg += "<br>" + TimeString::timeString(QTime((ev).event().start().time()) ) + msg += "<br>" + ampmTime(QTime((ev).event().start().time()) ) // end time of event - + "<b> - </b>" + TimeString::timeString(QTime((ev).event().end().time()) ); + + "<b> - </b>" + ampmTime(QTime((ev).event().end().time()) ); } @@ -526,4 +556,4 @@ DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev, } - } - + } + setText(msg); @@ -534,2 +564,22 @@ DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev, +QString DateBookEventLater::ampmTime(QTime tm) { + + QString s; + if( ampm ) { + int hour = tm.hour(); + if (hour == 0) + hour = 12; + if (hour > 12) + hour -= 12; + s.sprintf( "%2d:%02d %s", hour, tm.minute(), + (tm.hour() >= 12) ? "PM" : "AM" ); + return s; + } else { + s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); + return s; + } + +} + + void DateBookEvent::editMe() { |