summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-04-10 16:51:46 (UTC)
committer harlekin <harlekin>2002-04-10 16:51:46 (UTC)
commit34e0e7af48992314d461be1a5a573dc0967fe260 (patch) (unidiff)
treee3e8bbf44ebf767f28de3fe89eced38e785a7b55
parent1d32fda5b67e89321ecbd0c8700edb8292b9ca90 (diff)
downloadopie-34e0e7af48992314d461be1a5a573dc0967fe260.zip
opie-34e0e7af48992314d461be1a5a573dc0967fe260.tar.gz
opie-34e0e7af48992314d461be1a5a573dc0967fe260.tar.bz2
am/pm support, ugly
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/today/TODO2
-rw-r--r--core/pim/today/changelog2
-rw-r--r--core/pim/today/today.cpp186
-rw-r--r--core/pim/today/today.h42
-rw-r--r--core/pim/today/todaybase.cpp24
5 files changed, 155 insertions, 101 deletions
diff --git a/core/pim/today/TODO b/core/pim/today/TODO
index 48e8d20..6acbf5a 100644
--- a/core/pim/today/TODO
+++ b/core/pim/today/TODO
@@ -4,4 +4,2 @@ TODO for today:
4 4
5* add am/pm mode instead of 24 h, take system default
6
7* qcop integration for updating events? 5* qcop integration for updating events?
diff --git a/core/pim/today/changelog b/core/pim/today/changelog
index b3da1fb..f04ff78 100644
--- a/core/pim/today/changelog
+++ b/core/pim/today/changelog
@@ -1 +1,3 @@
1* am/pm time optinal (autodetect)
2
10.3.1 30.3.1
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 @@
23#include <qpe/config.h> 23#include <qpe/config.h>
24#include <qpe/qcopenvelope_qws.h> 24#include <qpe/qcopenvelope_qws.h>
25#include <qpe/qprocess.h> 25#include <qpe/qprocess.h>
@@ -32,3 +32,3 @@
32#include <qfile.h> 32#include <qfile.h>
33#include <qdatetime.h> 33#include <qdatetime.h>
34#include <qtextstream.h> 34#include <qtextstream.h>
@@ -58,5 +58,5 @@ int NEW_START=1;
58 58
59/* 59/*
60 * Constructs a Example which is a child of 'parent', with the 60 * Constructs a Example which is a child of 'parent', with the
61 * name 'name' and widget flags set to 'f' 61 * name 'name' and widget flags set to 'f'
62 */ 62 */
@@ -68,4 +68,4 @@ Today::Today( QWidget* parent, const char* name, WFlags fl )
68 QObject::connect( (QObject*)MailButton, SIGNAL( clicked() ), this, SLOT(startMail() ) ); 68 QObject::connect( (QObject*)MailButton, SIGNAL( clicked() ), this, SLOT(startMail() ) );
69 69
70#if defined(Q_WS_QWS) 70#if defined(Q_WS_QWS)
71#if !defined(QT_NO_COP) 71#if !defined(QT_NO_COP)
@@ -76,3 +76,5 @@ Today::Today( QWidget* parent, const char* name, WFlags fl )
76#endif 76#endif
77 77
78
79
78 db = NULL; 80 db = NULL;
@@ -100,3 +102,3 @@ void Today::channelReceived(const QCString &msg, const QByteArray & data) {
100 * Initialises the owner field with the default value, the username 102 * Initialises the owner field with the default value, the username
101 */ 103 */
102void Today::setOwnerField() { 104void Today::setOwnerField() {
@@ -119,3 +121,3 @@ void Today::setOwnerField(QString &message) {
119 } 121 }
120} 122}
121 123
@@ -127,3 +129,3 @@ void Today::autoStart() {
127 Config cfg("today"); 129 Config cfg("today");
128 cfg.setGroup("Autostart"); 130 cfg.setGroup("Autostart");
129 AUTOSTART = cfg.readNumEntry("autostart",1); 131 AUTOSTART = cfg.readNumEntry("autostart",1);
@@ -147,3 +149,3 @@ void Today::draw() {
147 getMail(); 149 getMail();
148 150
149 // if the todolist.xml file was not modified in between, do not parse it. 151 // if the todolist.xml file was not modified in between, do not parse it.
@@ -223,6 +225,6 @@ void Today::startConfig() {
223 Config cfg("today"); 225 Config cfg("today");
224 cfg.setGroup("BaseConfig"); 226 cfg.setGroup("BaseConfig");
225 227
226 //init(); 228 //init();
227 229
228 conf->SpinBox1->setValue(MAX_LINES_MEET); 230 conf->SpinBox1->setValue(MAX_LINES_MEET);
@@ -242,3 +244,3 @@ void Today::startConfig() {
242 conf->exec(); 244 conf->exec();
243 245
244 int maxlinestask = conf->SpinBox2->value(); 246 int maxlinestask = conf->SpinBox2->value();
@@ -250,5 +252,5 @@ void Today::startConfig() {
250 int autostart =conf->CheckBoxAuto->isChecked(); 252 int autostart =conf->CheckBoxAuto->isChecked();
251 253
252 cfg.writeEntry("maxlinestask",maxlinestask); 254 cfg.writeEntry("maxlinestask",maxlinestask);
253 cfg.writeEntry("maxcharclip", maxcharclip); 255 cfg.writeEntry("maxcharclip", maxcharclip);
254 cfg.writeEntry("maxlinesmeet",maxmeet); 256 cfg.writeEntry("maxlinesmeet",maxmeet);
@@ -259,5 +261,5 @@ void Today::startConfig() {
259 cfg.writeEntry("autostart", autostart); 261 cfg.writeEntry("autostart", autostart);
260 262
261 // sync it to "disk" 263 // sync it to "disk"
262 cfg.write(); 264 cfg.write();
263 NEW_START=1; 265 NEW_START=1;
@@ -281,3 +283,3 @@ void Today::getDates() {
281 } 283 }
282 db = new DateBookDB; 284 db = new DateBookDB;
283 285
@@ -291,11 +293,11 @@ void Today::getDates() {
291 //bool ampm = config.readBoolEntry( "AMPM", TRUE ); 293 //bool ampm = config.readBoolEntry( "AMPM", TRUE );
292 294
293 int count=0; 295 int count=0;
294 296
295 if ( list.count() > 0 ) { 297 if ( list.count() > 0 ) {
296 298
297 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); 299 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin();
298 it!=list.end(); ++it ) { 300 it!=list.end(); ++it ) {
299 301
300 302
301 if ( count <= MAX_LINES_MEET ) { 303 if ( count <= MAX_LINES_MEET ) {
@@ -303,3 +305,3 @@ void Today::getDates() {
303 QTime time = QTime::currentTime(); 305 QTime time = QTime::currentTime();
304 306
305 if (!ONLY_LATER) { 307 if (!ONLY_LATER) {
@@ -312,3 +314,3 @@ void Today::getDates() {
312 count++; 314 count++;
313 315
314 // show only later appointments 316 // show only later appointments
@@ -318,3 +320,3 @@ void Today::getDates() {
318 this, SLOT(editEvent(const Event &))); 320 this, SLOT(editEvent(const Event &)));
319 } 321 }
320 } 322 }
@@ -325,3 +327,3 @@ void Today::getDates() {
325 layoutDates->addWidget(noMoreEvents); 327 layoutDates->addWidget(noMoreEvents);
326 } 328 }
327 } else { 329 } else {
@@ -331,3 +333,3 @@ void Today::getDates() {
331 } 333 }
332 334
333 layoutDates->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); 335 layoutDates->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding));
@@ -336,3 +338,3 @@ void Today::getDates() {
336} 338}
337 339
338 340
@@ -340,4 +342,4 @@ void Today::getMail() {
340 Config cfg("opiemail"); 342 Config cfg("opiemail");
341 cfg.setGroup("today"); 343 cfg.setGroup("today");
342 344
343 // how many lines should be showed in the task section 345 // how many lines should be showed in the task section
@@ -345,5 +347,5 @@ void Today::getMail() {
345 int OUTGOING = cfg.readNumEntry("outgoing",0); 347 int OUTGOING = cfg.readNumEntry("outgoing",0);
346 348
347 QString output = tr("<b>%1</b> new mail(s), <b>%2</b> outgoing").arg(NEW_MAILS).arg(OUTGOING); 349 QString output = tr("<b>%1</b> new mail(s), <b>%2</b> outgoing").arg(NEW_MAILS).arg(OUTGOING);
348 350
349 MailField->setText(output); 351 MailField->setText(output);
@@ -356,3 +358,3 @@ void Today::getMail() {
356void Today::getTodo() { 358void Today::getTodo() {
357 359
358 QString output; 360 QString output;
@@ -372,3 +374,3 @@ void Today::getTodo() {
372 } 374 }
373 375
374 // get total number of still open todos 376 // get total number of still open todos
@@ -380,3 +382,3 @@ void Today::getTodo() {
380 count +=1; 382 count +=1;
381 // not the overdues, we allready got them, and not if we are 383 // not the overdues, we allready got them, and not if we are
382 // over the maxlines 384 // over the maxlines
@@ -388,4 +390,4 @@ void Today::getTodo() {
388 } 390 }
389 391
390 392
391 if (count > 0) { 393 if (count > 0) {
@@ -400,3 +402,3 @@ void Today::getTodo() {
400 } 402 }
401 403
402 TodoField->setText(tr(output)); 404 TodoField->setText(tr(output));
@@ -407,3 +409,3 @@ void Today::getTodo() {
407 */ 409 */
408void Today::startDatebook() { 410void Today::startDatebook() {
409 QCopEnvelope e("QPE/System", "execute(QString)"); 411 QCopEnvelope e("QPE/System", "execute(QString)");
@@ -414,3 +416,3 @@ void Today::startDatebook() {
414 * starts the edit dialog as known from datebook 416 * starts the edit dialog as known from datebook
415 */ 417 */
416 418
@@ -420,3 +422,3 @@ void Today::editEvent(const Event &e) {
420 startDatebook(); 422 startDatebook();
421 423
422 while(!QCopChannel::isRegistered("QPE/Datebook")) todayApp->processEvents(); 424 while(!QCopChannel::isRegistered("QPE/Datebook")) todayApp->processEvents();
@@ -428,3 +430,3 @@ void Today::editEvent(const Event &e) {
428 * launches todolist 430 * launches todolist
429 */ 431 */
430void Today::startTodo() { 432void Today::startTodo() {
@@ -446,18 +448,21 @@ Today::~Today() {
446 448
447
448
449/* 449/*
450 * Gets the events for the current day, if it should get all dates 450 * Gets the events for the current day, if it should get all dates
451 */ 451 */
452DateBookEvent::DateBookEvent(const EffectiveEvent &ev, 452DateBookEvent::DateBookEvent(const EffectiveEvent &ev,
453 QWidget* parent = 0, 453 QWidget* parent = 0,
454 int SHOW_LOCATION = 0, 454 int SHOW_LOCATION = 0,
455 int SHOW_NOTES = 0, 455 int SHOW_NOTES = 0,
456 const char* name = 0, 456 const char* name = 0,
457 WFlags fl = 0) : 457 WFlags fl = 0) :
458 ClickableLabel(parent,name,fl), event(ev) { 458 ClickableLabel(parent,name,fl), event(ev) {
459 459
460 QString msg; 460 QString msg;
461 //QTime time = QTime::currentTime(); 461 //QTime time = QTime::currentTime();
462 462
463 Config config( "qpe" );
464 // if 24 h format
465 ampm = config.readBoolEntry( "AMPM", TRUE );
466
467
463 if (!ONLY_LATER) { 468 if (!ONLY_LATER) {
@@ -471,3 +476,3 @@ DateBookEvent::DateBookEvent(const EffectiveEvent &ev,
471 } 476 }
472 477
473 if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { 478 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,
476 // start time of event 481 // start time of event
477 msg += "<br>" + TimeString::timeString(QTime((ev).event().start().time()) ) 482 msg += "<br>" + ampmTime(QTime((ev).event().start().time()) );
478 // end time of event 483 // end time of event
479 + "<b> - </b>" + TimeString::timeString(QTime((ev).event().end().time()) ); 484 + "<b> - </b>" + ampmTime(QTime((ev).event().end().time()) );
480 } 485 }
481 486
482 // include possible note or not 487 // include possible note or not
@@ -492,13 +497,38 @@ DateBookEvent::DateBookEvent(const EffectiveEvent &ev,
492 497
493DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev, 498QString DateBookEvent::ampmTime(QTime tm) {
494 QWidget* parent = 0, 499
500 QString s;
501 if( ampm ) {
502 int hour = tm.hour();
503 if (hour == 0)
504 hour = 12;
505 if (hour > 12)
506 hour -= 12;
507 s.sprintf( "%2d:%02d %s", hour, tm.minute(),
508 (tm.hour() >= 12) ? "PM" : "AM" );
509 return s;
510 } else {
511 s.sprintf( "%2d:%02d", tm.hour(), tm.minute() );
512 return s;
513 }
514
515}
516
517
518DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev,
519 QWidget* parent = 0,
495 int SHOW_LOCATION = 0, 520 int SHOW_LOCATION = 0,
496 int SHOW_NOTES = 0, 521 int SHOW_NOTES = 0,
497 const char* name = 0, 522 const char* name = 0,
498 WFlags fl = 0) : 523 WFlags fl = 0) :
499 ClickableLabel(parent,name,fl), event(ev) { 524 ClickableLabel(parent,name,fl), event(ev) {
500 525
501 QString msg; 526 QString msg;
502 QTime time = QTime::currentTime(); 527 QTime time = QTime::currentTime();
503 528
529 Config config( "qpe" );
530 // if 24 h format
531 ampm = config.readBoolEntry( "AMPM", TRUE );
532
533
504 if ((time.toString() <= TimeString::dateString((ev).event().end())) ) { 534 if ((time.toString() <= TimeString::dateString((ev).event().end())) ) {
@@ -513,3 +543,3 @@ DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev,
513 } 543 }
514 544
515 if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { 545 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,
518 // start time of event 548 // start time of event
519 msg += "<br>" + TimeString::timeString(QTime((ev).event().start().time()) ) 549 msg += "<br>" + ampmTime(QTime((ev).event().start().time()) )
520 // end time of event 550 // end time of event
521 + "<b> - </b>" + TimeString::timeString(QTime((ev).event().end().time()) ); 551 + "<b> - </b>" + ampmTime(QTime((ev).event().end().time()) );
522 } 552 }
@@ -526,4 +556,4 @@ DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev,
526 } 556 }
527 } 557 }
528 558
529 setText(msg); 559 setText(msg);
@@ -534,2 +564,22 @@ DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev,
534 564
565QString DateBookEventLater::ampmTime(QTime tm) {
566
567 QString s;
568 if( ampm ) {
569 int hour = tm.hour();
570 if (hour == 0)
571 hour = 12;
572 if (hour > 12)
573 hour -= 12;
574 s.sprintf( "%2d:%02d %s", hour, tm.minute(),
575 (tm.hour() >= 12) ? "PM" : "AM" );
576 return s;
577 } else {
578 s.sprintf( "%2d:%02d", tm.hour(), tm.minute() );
579 return s;
580 }
581
582}
583
584
535void DateBookEvent::editMe() { 585void DateBookEvent::editMe() {
diff --git a/core/pim/today/today.h b/core/pim/today/today.h
index 090e8f9..d265d67 100644
--- a/core/pim/today/today.h
+++ b/core/pim/today/today.h
@@ -29,3 +29,3 @@
29#include <qdatetime.h> 29#include <qdatetime.h>
30#include <qlist.h> 30#include <qlist.h>
31 31
@@ -38,8 +38,8 @@ class QVBoxLayout;
38class Today : public TodayBase { 38class Today : public TodayBase {
39 Q_OBJECT 39 Q_OBJECT
40 40
41 public: 41 public:
42 Today( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 42 Today( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
43 ~Today(); 43 ~Today();
44 44
45 private slots: 45 private slots:
@@ -60,5 +60,5 @@ class Today : public TodayBase {
60 void setOwnerField(QString &string); 60 void setOwnerField(QString &string);
61 private slots: 61 private slots:
62 void channelReceived(const QCString &msg, const QByteArray & data); 62 void channelReceived(const QCString &msg, const QByteArray & data);
63 63
64 private: 64 private:
@@ -72,3 +72,3 @@ class Today : public TodayBase {
72 int MAX_LINES_MEET; 72 int MAX_LINES_MEET;
73 int SHOW_LOCATION; 73 int SHOW_LOCATION;
74 int SHOW_NOTES; 74 int SHOW_NOTES;
@@ -79,8 +79,8 @@ class DateBookEvent: public ClickableLabel {
79public: 79public:
80 DateBookEvent(const EffectiveEvent &ev, 80 DateBookEvent(const EffectiveEvent &ev,
81 QWidget* parent = 0, 81 QWidget* parent = 0,
82 int SHOW_LOCATION = 0, 82 int SHOW_LOCATION = 0,
83 int SHOW_NOTES = 0, 83 int SHOW_NOTES = 0,
84 const char* name = 0, 84 const char* name = 0,
85 WFlags fl = 0); 85 WFlags fl = 0);
86signals: 86signals:
@@ -90,3 +90,5 @@ private slots:
90private: 90private:
91 QString ampmTime(QTime);
91 const EffectiveEvent event; 92 const EffectiveEvent event;
93 bool ampm;
92}; 94};
@@ -96,3 +98,3 @@ class DateBookEventLater: public ClickableLabel {
96public: 98public:
97 DateBookEventLater(const EffectiveEvent &ev, 99 DateBookEventLater(const EffectiveEvent &ev,
98 QWidget* parent = 0, 100 QWidget* parent = 0,
@@ -100,3 +102,3 @@ public:
100 int SHOW_NOTES = 0, 102 int SHOW_NOTES = 0,
101 const char* name = 0, 103 const char* name = 0,
102 WFlags fl = 0); 104 WFlags fl = 0);
@@ -107,3 +109,5 @@ private slots:
107private: 109private:
110 QString ampmTime(QTime);
108 const EffectiveEvent event; 111 const EffectiveEvent event;
112 bool ampm;
109}; 113};
diff --git a/core/pim/today/todaybase.cpp b/core/pim/today/todaybase.cpp
index 755c860..ae8763b 100644
--- a/core/pim/today/todaybase.cpp
+++ b/core/pim/today/todaybase.cpp
@@ -47,9 +47,9 @@ TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl )
47 47
48 QPalette pal = this->palette(); 48 //QPalette pal = this->palette();
49 QColor col = pal.color(QPalette::Active, QColorGroup::Background); 49 // QColor col = pal.color(QPalette::Active, QColorGroup::Background);
50 pal.setColor(QPalette::Active, QColorGroup::Button, col); 50 //pal.setColor(QPalette::Active, QColorGroup::Button, col);
51 pal.setColor(QPalette::Inactive, QColorGroup::Button, col); 51 //pal.setColor(QPalette::Inactive, QColorGroup::Button, col);
52 pal.setColor(QPalette::Normal, QColorGroup::Button, col); 52 //pal.setColor(QPalette::Normal, QColorGroup::Button, col);
53 pal.setColor(QPalette::Disabled, QColorGroup::Button, col); 53 //pal.setColor(QPalette::Disabled, QColorGroup::Button, col);
54 this->setPalette(pal); 54 //this->setPalette(pal);
55 55
@@ -97,3 +97,3 @@ TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl )
97 Frame4 = new QFrame( this, "Frame4" ); 97 Frame4 = new QFrame( this, "Frame4" );
98 Frame4->setPalette( pal ); 98// Frame4->setPalette( pal );
99 Frame4->setFrameShape( QScrollView::StyledPanel ); 99 Frame4->setFrameShape( QScrollView::StyledPanel );
@@ -114,3 +114,3 @@ TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl )
114 DatesButton->setBackgroundOrigin( QPushButton::WidgetOrigin ); 114 DatesButton->setBackgroundOrigin( QPushButton::WidgetOrigin );
115 DatesButton->setPalette( pal ); 115// DatesButton->setPalette( pal );
116 DatesButton->setPixmap( datebook ); 116 DatesButton->setPixmap( datebook );
@@ -130,3 +130,3 @@ TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl )
130 MailButton->setGeometry( QRect( 2, 3, 36, 19 ) ); 130 MailButton->setGeometry( QRect( 2, 3, 36, 19 ) );
131 MailButton->setPalette( pal ); 131// MailButton->setPalette( pal );
132 MailButton->setPixmap( mail ); 132 MailButton->setPixmap( mail );
@@ -152,3 +152,3 @@ TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl )
152 TodoButton->setGeometry( QRect( 2, 4, 36, 32 ) ); 152 TodoButton->setGeometry( QRect( 2, 4, 36, 32 ) );
153 TodoButton->setPalette( pal ); 153// TodoButton->setPalette( pal );
154 TodoButton->setPixmap( todo ); 154 TodoButton->setPixmap( todo );
@@ -171,3 +171,3 @@ TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl )
171 PushButton1->setPixmap( config ); 171 PushButton1->setPixmap( config );
172 PushButton1->setPalette( pal ); 172// PushButton1->setPalette( pal );
173 PushButton1->setAutoDefault( TRUE ); 173 PushButton1->setAutoDefault( TRUE );