summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-11-27 14:19:09 (UTC)
committer harlekin <harlekin>2002-11-27 14:19:09 (UTC)
commit5f0c90d4b6972c1ad22ba20b45cd1d3f88298099 (patch) (unidiff)
tree0cd24ab2ff259a76e06d7940b9de03a2b067d57a
parenta75b95fd9f89fc80e867c0efb5837178cab56cbb (diff)
downloadopie-5f0c90d4b6972c1ad22ba20b45cd1d3f88298099.zip
opie-5f0c90d4b6972c1ad22ba20b45cd1d3f88298099.tar.gz
opie-5f0c90d4b6972c1ad22ba20b45cd1d3f88298099.tar.bz2
ability to show next days too added
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/today/plugins/datebook/datebookevent.cpp24
-rw-r--r--core/pim/today/plugins/datebook/datebookevent.h21
-rw-r--r--core/pim/today/plugins/datebook/datebookpluginconfig.cpp19
-rw-r--r--core/pim/today/plugins/datebook/datebookpluginconfig.h7
-rw-r--r--core/pim/today/plugins/datebook/datebookpluginwidget.cpp3
-rw-r--r--core/pim/today/plugins/datebook/datebookpluginwidget.h1
6 files changed, 57 insertions, 18 deletions
diff --git a/core/pim/today/plugins/datebook/datebookevent.cpp b/core/pim/today/plugins/datebook/datebookevent.cpp
index 0a0d186..8277529 100644
--- a/core/pim/today/plugins/datebook/datebookevent.cpp
+++ b/core/pim/today/plugins/datebook/datebookevent.cpp
@@ -12,105 +12,125 @@
12 * the Free Software Foundation; either version 2 of the License, or * 12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. * 13 * (at your option) any later version. *
14 * * 14 * *
15 ***************************************************************************/ 15 ***************************************************************************/
16 16
17#include "datebookevent.h" 17#include "datebookevent.h"
18#include <qpe/config.h> 18#include <qpe/config.h>
19#include <qpe/timestring.h> 19#include <qpe/timestring.h>
20#include <qpe/qcopenvelope_qws.h> 20#include <qpe/qcopenvelope_qws.h>
21#include <qpe/qpeapplication.h> 21#include <qpe/qpeapplication.h>
22 22
23#include <opie/odevice.h> 23#include <opie/odevice.h>
24 24
25using namespace Opie; 25using namespace Opie;
26 26
27DateBookEvent::DateBookEvent(const EffectiveEvent &ev, 27DateBookEvent::DateBookEvent(const EffectiveEvent &ev,
28 QWidget* parent, 28 QWidget* parent,
29 bool show_location, 29 bool show_location,
30 bool show_notes, 30 bool show_notes,
31 int maxCharClip, 31 int maxCharClip,
32 const char* name, 32 const char* name,
33 WFlags fl) : 33 WFlags fl) :
34 OClickableLabel(parent,name,fl), event(ev) { 34 OClickableLabel(parent,name,fl), event(ev) {
35 35
36 setAlignment( AlignTop ); 36 setAlignment( AlignTop );
37 37
38 QString msg; 38 QString msg;
39 39
40 Config config( "qpe" ); 40 Config config( "qpe" );
41 config.setGroup( "Time" ); 41 config.setGroup( "Time" );
42 // if 24 h format 42 // if 24 h format
43 ampm = config.readBoolEntry( "AMPM", TRUE ); 43 ampm = config.readBoolEntry( "AMPM", TRUE );
44 44
45 msg += "<B>" + (ev).description() + "</B>"; 45 msg += "<B>" + (ev).description() + "</B>";
46 if ( (ev).event().hasAlarm() ) { 46 if ( (ev).event().hasAlarm() ) {
47 msg += " <b>[with alarm]</b>"; 47 msg += " <b>[with alarm]</b>";
48 } 48 }
49 49
50 // include location or not 50 // include location or not
51 if ( show_location ) { 51 if ( show_location ) {
52 msg += "<BR><i>" + (ev).location() + "</i>"; 52 msg += "<BR><i>" + (ev).location() + "</i>";
53 } 53 }
54 54
55 if ( ( TimeString::timeString( QTime( (ev).event().start().time() ) ) == "00:00" ) 55 if ( ( TimeString::timeString( QTime( (ev).event().start().time() ) ) == "00:00" )
56 && ( TimeString::timeString( QTime( (ev).event().end().time() ) ) == "23:59" ) ) { 56 && ( TimeString::timeString( QTime( (ev).event().end().time() ) ) == "23:59" ) ) {
57 msg += "<br>All day"; 57 msg += "<br>All day";
58 } else { 58 } else {
59 // start time of event 59 // start time of event
60 msg += "<br>" + ampmTime(QTime( (ev).event().start().time() ) ) 60 QDate tempDate = (ev).event().start().date();
61 msg += "<br>"
62 + ampmTime( QTime( (ev).event().start().time() ) )
61 // end time of event 63 // end time of event
62 + "<b> - </b>" + ampmTime(QTime( (ev).event().end().time() ) ); 64 + "<b> - </b>" + ampmTime( QTime( (ev).event().end().time() ) )
65 + differDate( tempDate );
63 } 66 }
64 67
65 // include possible note or not 68 // include possible note or not
66 if ( show_notes ) { 69 if ( show_notes ) {
67 msg += "<br> <i>note</i>:" +( (ev).notes() ).mid( 0, maxCharClip ); 70 msg += "<br> <i>note</i>:" +( (ev).notes() ).mid( 0, maxCharClip );
68 } 71 }
69 setText( msg ); 72 setText( msg );
70 connect( this, SIGNAL( clicked() ), this, SLOT( editMe() ) ); 73 connect( this, SIGNAL( clicked() ), this, SLOT( editMe() ) );
71} 74}
72 75
73 76
74/** 77/**
75 * AM/PM timestring conversion. 78 * AM/PM timestring conversion.
76 * @param tm the timestring 79 * @param tm the timestring
77 * @return formatted to am/pm is system is set to it 80 * @return formatted to am/pm is system is set to it
78 */ 81 */
79QString DateBookEvent::ampmTime( QTime tm ) { 82QString DateBookEvent::ampmTime( QTime tm ) {
80 QString s; 83 QString s;
81 if( ampm ) { 84 if( ampm ) {
82 int hour = tm.hour(); 85 int hour = tm.hour();
83 if ( hour == 0 ) { 86 if ( hour == 0 ) {
84 hour = 12; 87 hour = 12;
85 } 88 }
86 if ( hour > 12 ) { 89 if ( hour > 12 ) {
87 hour -= 12; 90 hour -= 12;
88 } 91 }
89 s.sprintf( "%2d:%02d %s", hour, tm.minute(), 92 s.sprintf( "%2d:%02d %s", hour, tm.minute(),
90 (tm.hour() >= 12) ? "PM" : "AM" ); 93 (tm.hour() >= 12) ? "PM" : "AM" );
91 return s; 94 return s;
92 } else { 95 } else {
93 s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); 96 s.sprintf( "%2d:%02d", tm.hour(), tm.minute() );
94 return s; 97 return s;
95 } 98 }
96} 99}
97 100
101QString DateBookEvent::differDate( QDate date ) {
102 QDate currentDate = QDate::currentDate();
103 QString returnText = "<font color = #407DD9><b> ";
104 int differDate = currentDate.daysTo( date );
105 if ( currentDate.dayOfWeek() == date.dayOfWeek() ) {
106 returnText += "" ;
107 // not working right for recurring events
108 //} else if ( differDate == 1 ) {
109 //returnText += tr( "tomorrow" );
110 } else {
111 //returnText += tr( "in %1 days" ).arg( differDate );
112 returnText += " [ " + date.dayName( date.dayOfWeek() ) + " ] ";
113 }
114 returnText += "</b></font>";
115 return returnText;
116}
117
98 118
99/** 119/**
100 * starts the edit dialog as known from datebook 120 * starts the edit dialog as known from datebook
101 */ 121 */
102void DateBookEvent::editEventSlot( const Event &e ) { 122void DateBookEvent::editEventSlot( const Event &e ) {
103 123
104 if ( ODevice::inst()->system() == System_Zaurus ) { 124 if ( ODevice::inst()->system() == System_Zaurus ) {
105 QCopEnvelope env( "QPE/Application/datebook", "raise()" ); 125 QCopEnvelope env( "QPE/Application/datebook", "raise()" );
106 } else { 126 } else {
107 QCopEnvelope env( "QPE/Datebook", "editEvent(int)" ); 127 QCopEnvelope env( "QPE/Datebook", "editEvent(int)" );
108 env << e.uid(); 128 env << e.uid();
109 } 129 }
110} 130}
111 131
112 132
113void DateBookEvent::editMe() { 133void DateBookEvent::editMe() {
114 emit editEvent( event.event() ); 134 emit editEvent( event.event() );
115} 135}
116 136
diff --git a/core/pim/today/plugins/datebook/datebookevent.h b/core/pim/today/plugins/datebook/datebookevent.h
index 7b0371a..f8a9c03 100644
--- a/core/pim/today/plugins/datebook/datebookevent.h
+++ b/core/pim/today/plugins/datebook/datebookevent.h
@@ -1,48 +1,49 @@
1/* 1/*
2 * datebookplugin.h 2 * datebookplugin.h
3 * 3 *
4 * copyright : (c) 2002 by Maximilian Reiß 4 * copyright : (c) 2002 by Maximilian Reiß
5 * email : harlekin@handhelds.org 5 * email : harlekin@handhelds.org
6 * 6 *
7 */ 7 */
8/*************************************************************************** 8/***************************************************************************
9 * * 9 * *
10 * This program is free software; you can redistribute it and/or modify * 10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by * 11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or * 12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. * 13 * (at your option) any later version. *
14 * * 14 * *
15 ***************************************************************************/ 15 ***************************************************************************/
16 16
17#ifndef DATEBOOKEVENT_PLUGIN_H 17#ifndef DATEBOOKEVENT_PLUGIN_H
18#define DATEBOOKEVENT_PLUGIN_H 18#define DATEBOOKEVENT_PLUGIN_H
19 19
20#include <opie/oclickablelabel.h> 20#include <opie/oclickablelabel.h>
21#include <qpe/datebookdb.h> 21#include <qpe/datebookdb.h>
22 22
23 23
24class DateBookEvent: public OClickableLabel { 24class DateBookEvent: public OClickableLabel {
25 25
26 Q_OBJECT 26 Q_OBJECT
27 27
28public: 28public:
29 DateBookEvent(const EffectiveEvent &ev, 29 DateBookEvent( const EffectiveEvent &ev,
30 QWidget* parent = 0, 30 QWidget* parent = 0,
31 bool show_location = 0, 31 bool show_location = 0,
32 bool show_notes = 0, 32 bool show_notes = 0,
33 int maxCharClip = 0, 33 int maxCharClip = 0,
34 const char* name = 0, 34 const char* name = 0,
35 WFlags fl = 0); 35 WFlags fl = 0 );
36signals: 36signals:
37 void editEvent(const Event &e); 37 void editEvent( const Event &e );
38private slots: 38private slots:
39 void editEventSlot(const Event &e); 39 void editEventSlot( const Event &e );
40 void editMe(); 40 void editMe();
41private: 41private:
42 DateBookDB *db; 42 DateBookDB *db;
43 QString ampmTime(QTime); 43 QString ampmTime( QTime );
44 QString differDate( QDate date );
44 const EffectiveEvent event; 45 const EffectiveEvent event;
45 bool ampm; 46 bool ampm;
46}; 47};
47 48
48#endif 49#endif
diff --git a/core/pim/today/plugins/datebook/datebookpluginconfig.cpp b/core/pim/today/plugins/datebook/datebookpluginconfig.cpp
index e93c82c..0fc38de 100644
--- a/core/pim/today/plugins/datebook/datebookpluginconfig.cpp
+++ b/core/pim/today/plugins/datebook/datebookpluginconfig.cpp
@@ -1,86 +1,103 @@
1 1
2 2
3#include "datebookpluginconfig.h" 3#include "datebookpluginconfig.h"
4 4
5#include <qpe/config.h> 5#include <qpe/config.h>
6 6
7#include <qlayout.h> 7#include <qlayout.h>
8#include <qtoolbutton.h> 8#include <qtoolbutton.h>
9#include <qlabel.h> 9#include <qlabel.h>
10#include <qhbox.h> 10#include <qhbox.h>
11#include <qwhatsthis.h> 11#include <qwhatsthis.h>
12#include <qvbox.h> 12#include <qvbox.h>
13 13
14DatebookPluginConfig::DatebookPluginConfig( QWidget* parent, const char* name) 14DatebookPluginConfig::DatebookPluginConfig( QWidget* parent, const char* name)
15 : TodayConfigWidget( parent, name ) { 15 : TodayConfigWidget( parent, name ) {
16 16
17 QVBoxLayout * layout = new QVBoxLayout( this ); 17 QVBoxLayout * layout = new QVBoxLayout( this );
18 layout->setMargin( 20 ); 18 layout->setMargin( 20 );
19 19
20 QHBox *box1 = new QHBox( this ); 20 QHBox *box1 = new QHBox( this );
21 QLabel* TextLabel4 = new QLabel( box1, "TextLabel4" ); 21 QLabel* TextLabel4 = new QLabel( box1, "TextLabel4" );
22 TextLabel4->setText( tr( "Show location" ) ); 22 TextLabel4->setText( tr( "Show location" ) );
23 CheckBox1 = new QCheckBox( box1, "CheckBox1" ); 23 CheckBox1 = new QCheckBox( box1, "CheckBox1" );
24 QWhatsThis::add( CheckBox1 , tr( "Check this if the location of an appointment should be shown for each one" ) ); 24 QWhatsThis::add( CheckBox1 , tr( "Check this if the location of an appointment should be shown for each one" ) );
25 25
26 QHBox *box2 = new QHBox( this ); 26 QHBox *box2 = new QHBox( this );
27 QLabel* TextLabel5 = new QLabel( box2 , "TextLabel5" ); 27 QLabel* TextLabel5 = new QLabel( box2 , "TextLabel5" );
28 TextLabel5->setText( tr( "Show notes" ) ); 28 TextLabel5->setText( tr( "Show notes" ) );
29 CheckBox2 = new QCheckBox( box2, "CheckBox2" ); 29 CheckBox2 = new QCheckBox( box2, "CheckBox2" );
30 QWhatsThis::add( CheckBox2 , tr( "Check this if the note attached to an appointment should be shown for each one" ) ); 30 QWhatsThis::add( CheckBox2 , tr( "Check this if the note attached to an appointment should be shown for each one" ) );
31 31
32 QHBox *box3 = new QHBox( this ); 32 QHBox *box3 = new QHBox( this );
33 QLabel* TextLabel6 = new QLabel( box3, "All Day"); 33 QLabel* TextLabel6 = new QLabel( box3, "All Day");
34 TextLabel6->setText( tr( "Show only later\n appointments") ); 34 TextLabel6->setText( tr( "Show only later\n appointments") );
35 CheckBox3 = new QCheckBox ( box3, "CheckBox3" ); 35 CheckBox3 = new QCheckBox ( box3, "CheckBox3" );
36 QWhatsThis::add( CheckBox3 , tr( "Check this if only appointments later then current time should be shown" ) ); 36 QWhatsThis::add( CheckBox3 , tr( "Check this if only appointments later then current time should be shown" ) );
37 37
38
39
38 QHBox *box4 = new QHBox( this ); 40 QHBox *box4 = new QHBox( this );
39 QLabel *TextLabel3 = new QLabel( box4, "TextLabel3" ); 41 QLabel *TextLabel3 = new QLabel( box4, "TextLabel3" );
40 TextLabel3->setText( tr( "How many \nappointment\n" 42 TextLabel3->setText( tr( "How many \nappointment\n"
41 "should be \nshown?" ) ); 43 "should be \nshown?" ) );
42 SpinBox1 = new QSpinBox( box4, "SpinBox1" ); 44 SpinBox1 = new QSpinBox( box4, "SpinBox1" );
43 QWhatsThis::add( SpinBox1 , tr( "How many appointments should be shown maximal. In chronical order" ) ); 45 QWhatsThis::add( SpinBox1 , tr( "How many appointments should be shown maximal. In chronical order" ) );
44 SpinBox1->setMaxValue( 10 ); 46 SpinBox1->setMaxValue( 10 );
45 SpinBox1->setValue( 5 ); 47 SpinBox1->setValue( 5 );
46 48
49
50 QHBox *box5 = new QHBox( this );
51 QLabel *TextLabelDays = new QLabel( box5 );
52 TextLabelDays->setText( tr( "How many more days" ) );
53 SpinBox2 = new QSpinBox( box5, "SpinBox2" );
54 QWhatsThis::add( SpinBox2 , tr( "How many more days should be in the range" ) );
55 SpinBox2->setMaxValue( 7 );
56 SpinBox2->setSuffix( tr( " day(s)" ) );
57 SpinBox2->setSpecialValueText ( tr("only today") );
58
47 layout->addWidget( box1 ); 59 layout->addWidget( box1 );
48 layout->addWidget( box2 ); 60 layout->addWidget( box2 );
49 layout->addWidget( box3 ); 61 layout->addWidget( box3 );
50 layout->addWidget( box4 ); 62 layout->addWidget( box4 );
63 layout->addWidget( box5 );
51 64
52 readConfig(); 65 readConfig();
53} 66}
54 67
55void DatebookPluginConfig::readConfig() { 68void DatebookPluginConfig::readConfig() {
56 Config cfg( "todaydatebookplugin" ); 69 Config cfg( "todaydatebookplugin" );
57 cfg.setGroup( "config" ); 70 cfg.setGroup( "config" );
58 71
59 m_max_lines_meet = cfg.readNumEntry( "maxlinesmeet", 5 ); 72 m_max_lines_meet = cfg.readNumEntry( "maxlinesmeet", 5 );
60 SpinBox1->setValue( m_max_lines_meet ); 73 SpinBox1->setValue( m_max_lines_meet );
61 m_show_location = cfg.readNumEntry( "showlocation", 1 ); 74 m_show_location = cfg.readNumEntry( "showlocation", 1 );
62 CheckBox1->setChecked( m_show_location ); 75 CheckBox1->setChecked( m_show_location );
63 m_show_notes = cfg.readNumEntry( "shownotes", 0 ); 76 m_show_notes = cfg.readNumEntry( "shownotes", 0 );
64 CheckBox2->setChecked( m_show_notes ); 77 CheckBox2->setChecked( m_show_notes );
65 m_only_later = cfg.readNumEntry( "onlylater", 1 ); 78 m_only_later = cfg.readNumEntry( "onlylater", 1 );
66 CheckBox3->setChecked( m_only_later ); 79 CheckBox3->setChecked( m_only_later );
80 m_more_days = cfg.readNumEntry( "moredays", 0 );
81 SpinBox2->setValue( m_more_days );
67} 82}
68 83
69 84
70void DatebookPluginConfig::writeConfig() { 85void DatebookPluginConfig::writeConfig() {
71 Config cfg( "todaydatebookplugin" ); 86 Config cfg( "todaydatebookplugin" );
72 cfg.setGroup( "config" ); 87 cfg.setGroup( "config" );
73 88
74 m_max_lines_meet = SpinBox1->value(); 89 m_max_lines_meet = SpinBox1->value();
75 cfg.writeEntry( "maxlinesmeet", m_max_lines_meet); 90 cfg.writeEntry( "maxlinesmeet", m_max_lines_meet);
76 m_show_location = CheckBox1->isChecked(); 91 m_show_location = CheckBox1->isChecked();
77 cfg.writeEntry( "showlocation", m_show_location); 92 cfg.writeEntry( "showlocation", m_show_location);
78 m_show_notes = CheckBox2->isChecked(); 93 m_show_notes = CheckBox2->isChecked();
79 cfg.writeEntry( "shownotes", m_show_notes ); 94 cfg.writeEntry( "shownotes", m_show_notes );
80 m_only_later = CheckBox3->isChecked(); 95 m_only_later = CheckBox3->isChecked();
81 cfg.writeEntry( "onlylater", m_only_later ); 96 cfg.writeEntry( "onlylater", m_only_later );
97 m_more_days = SpinBox2->value();
98 cfg.writeEntry( "moredays", m_more_days );
82 cfg.write(); 99 cfg.write();
83} 100}
84 101
85DatebookPluginConfig::~DatebookPluginConfig() { 102DatebookPluginConfig::~DatebookPluginConfig() {
86} 103}
diff --git a/core/pim/today/plugins/datebook/datebookpluginconfig.h b/core/pim/today/plugins/datebook/datebookpluginconfig.h
index feba9ee..6c32ae9 100644
--- a/core/pim/today/plugins/datebook/datebookpluginconfig.h
+++ b/core/pim/today/plugins/datebook/datebookpluginconfig.h
@@ -1,48 +1,47 @@
1 1
2#ifndef DATEBOOK_PLUGIN_CONFIG_H 2#ifndef DATEBOOK_PLUGIN_CONFIG_H
3#define DATEBOOK_PLUGIN_CONFIG_H 3#define DATEBOOK_PLUGIN_CONFIG_H
4 4
5 5
6#include <qcheckbox.h> 6#include <qcheckbox.h>
7#include <qspinbox.h> 7#include <qspinbox.h>
8 8
9#include <opie/todayconfigwidget.h> 9#include <opie/todayconfigwidget.h>
10 10
11class DatebookPluginConfig : public TodayConfigWidget { 11class DatebookPluginConfig : public TodayConfigWidget {
12 12
13 13
14 14
15public: 15public:
16 DatebookPluginConfig( QWidget *parent, const char *name ); 16 DatebookPluginConfig( QWidget *parent, const char *name );
17 ~DatebookPluginConfig(); 17 ~DatebookPluginConfig();
18 18
19 void writeConfig(); 19 void writeConfig();
20private: 20private:
21 /** 21 /**
22 * if changed then save 22 * if changed then save
23 */ 23 */
24 bool changed(); 24 bool changed();
25 void readConfig(); 25 void readConfig();
26 26
27 QCheckBox* CheckBox2; 27 QCheckBox* CheckBox2;
28 QCheckBox* CheckBox1; 28 QCheckBox* CheckBox1;
29 QCheckBox* CheckBox3; 29 QCheckBox* CheckBox3;
30 QSpinBox* SpinBox1; 30 QSpinBox* SpinBox1;
31 QSpinBox* SpinBox2;
32
31 33
32 // how many lines should be showed in the datebook section 34 // how many lines should be showed in the datebook section
33 int m_max_lines_meet; 35 int m_max_lines_meet;
34 // If location is to be showed too, 1 to activate it. 36 // If location is to be showed too, 1 to activate it.
35 int m_show_location; 37 int m_show_location;
36 // if notes should be shown 38 // if notes should be shown
37 int m_show_notes; 39 int m_show_notes;
38 // should only later appointments be shown or all for the current day. 40 // should only later appointments be shown or all for the current day.
39 int m_only_later; 41 int m_only_later;
40 42 int m_more_days;
41 43
42}; 44};
43 45
44 46
45
46
47
48#endif 47#endif
diff --git a/core/pim/today/plugins/datebook/datebookpluginwidget.cpp b/core/pim/today/plugins/datebook/datebookpluginwidget.cpp
index a8ce059..c6aa2a6 100644
--- a/core/pim/today/plugins/datebook/datebookpluginwidget.cpp
+++ b/core/pim/today/plugins/datebook/datebookpluginwidget.cpp
@@ -2,110 +2,111 @@
2 * datebookpluginwidget.cpp 2 * datebookpluginwidget.cpp
3 * 3 *
4 * copyright : (c) 2002 by Maximilian Reiß 4 * copyright : (c) 2002 by Maximilian Reiß
5 * email : harlekin@handhelds.org 5 * email : harlekin@handhelds.org
6 * 6 *
7 */ 7 */
8/*************************************************************************** 8/***************************************************************************
9 * * 9 * *
10 * This program is free software; you can redistribute it and/or modify * 10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by * 11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or * 12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. * 13 * (at your option) any later version. *
14 * * 14 * *
15 ***************************************************************************/ 15 ***************************************************************************/
16 16
17 17
18#include "datebookpluginwidget.h" 18#include "datebookpluginwidget.h"
19#include "datebookevent.h" 19#include "datebookevent.h"
20 20
21#include <qpe/timestring.h> 21#include <qpe/timestring.h>
22#include <qpe/config.h> 22#include <qpe/config.h>
23 23
24#include <qdatetime.h> 24#include <qdatetime.h>
25#include <qlabel.h> 25#include <qlabel.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qtl.h> 27#include <qtl.h>
28#include <qscrollview.h> 28#include <qscrollview.h>
29#include <qtimer.h> 29#include <qtimer.h>
30 30
31DatebookPluginWidget::DatebookPluginWidget( QWidget *parent, const char* name) 31DatebookPluginWidget::DatebookPluginWidget( QWidget *parent, const char* name)
32 : QWidget(parent, name ) { 32 : QWidget(parent, name ) {
33 db = 0l; 33 db = 0l;
34 readConfig(); 34 readConfig();
35 getDates(); 35 getDates();
36} 36}
37 37
38DatebookPluginWidget::~DatebookPluginWidget() { 38DatebookPluginWidget::~DatebookPluginWidget() {
39 delete db; 39 delete db;
40} 40}
41 41
42 42
43void DatebookPluginWidget::readConfig() { 43void DatebookPluginWidget::readConfig() {
44 Config cfg( "todaydatebookplugin" ); 44 Config cfg( "todaydatebookplugin" );
45 cfg.setGroup( "config" ); 45 cfg.setGroup( "config" );
46 m_max_lines_meet = cfg.readNumEntry( "maxlinesmeet", 5 ); 46 m_max_lines_meet = cfg.readNumEntry( "maxlinesmeet", 5 );
47 m_show_location = cfg.readNumEntry( "showlocation", 1 ); 47 m_show_location = cfg.readNumEntry( "showlocation", 1 );
48 m_show_notes = cfg.readNumEntry( "shownotes", 0 ); 48 m_show_notes = cfg.readNumEntry( "shownotes", 0 );
49 m_onlyLater = cfg.readNumEntry( "onlylater", 1 ); 49 m_onlyLater = cfg.readNumEntry( "onlylater", 1 );
50 m_moreDays = cfg.readNumEntry( "moredays", 0 );
50} 51}
51 52
52 53
53/** 54/**
54 * Get all events that are in the datebook xml file for today 55 * Get all events that are in the datebook xml file for today
55 */ 56 */
56void DatebookPluginWidget::getDates() { 57void DatebookPluginWidget::getDates() {
57 58
58 59
59 QDate date = QDate::currentDate(); 60 QDate date = QDate::currentDate();
60 61
61 QVBoxLayout* layoutDates = new QVBoxLayout( this ); 62 QVBoxLayout* layoutDates = new QVBoxLayout( this );
62 layoutDates->setSpacing( 1 ); 63 layoutDates->setSpacing( 1 );
63 layoutDates->setMargin( 1 ); 64 layoutDates->setMargin( 1 );
64 65
65 if ( db ) { 66 if ( db ) {
66 delete db; 67 delete db;
67 } 68 }
68 69
69 db = new DateBookDB; 70 db = new DateBookDB;
70 71
71 QValueList<EffectiveEvent> list = db->getEffectiveEvents( date, date ); 72 QValueList<EffectiveEvent> list = db->getEffectiveEvents( date, date.addDays( m_moreDays ) );
72 73
73 qBubbleSort( list ); 74 qBubbleSort( list );
74 75
75 Config config( "qpe" ); 76 Config config( "qpe" );
76 77
77 int count=0; 78 int count=0;
78 79
79 if ( list.count() > 0 ) { 80 if ( list.count() > 0 ) {
80 81
81 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) { 82 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) {
82 83
83 if ( count <= m_max_lines_meet ) { 84 if ( count <= m_max_lines_meet ) {
84 QTime time = QTime::currentTime(); 85 QTime time = QTime::currentTime();
85 86
86 if ( !m_onlyLater ) { 87 if ( !m_onlyLater ) {
87 count++; 88 count++;
88 DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes ); 89 DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes );
89 layoutDates->addWidget( l ); 90 layoutDates->addWidget( l );
90 QObject::connect ( l, SIGNAL( editEvent( const Event &) ), l, SLOT( editEventSlot( const Event &) ) ); 91 QObject::connect ( l, SIGNAL( editEvent( const Event &) ), l, SLOT( editEventSlot( const Event &) ) );
91 } else if ( ( time.toString() <= TimeString::dateString( (*it).event().end() ) ) ) { 92 } else if ( ( time.toString() <= TimeString::dateString( (*it).event().end() ) ) ) {
92 count++; 93 count++;
93 // show only later appointments 94 // show only later appointments
94 DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes ); 95 DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes );
95 layoutDates->addWidget( l ); 96 layoutDates->addWidget( l );
96 QObject::connect ( l, SIGNAL( editEvent( const Event &) ), l, SLOT( editEventSlot( const Event &) ) ); 97 QObject::connect ( l, SIGNAL( editEvent( const Event &) ), l, SLOT( editEventSlot( const Event &) ) );
97 } 98 }
98 } 99 }
99 } 100 }
100 if ( m_onlyLater && count == 0 ) { 101 if ( m_onlyLater && count == 0 ) {
101 QLabel* noMoreEvents = new QLabel( this ); 102 QLabel* noMoreEvents = new QLabel( this );
102 noMoreEvents->setText( QObject::tr( "No more appointments today" ) ); 103 noMoreEvents->setText( QObject::tr( "No more appointments today" ) );
103 layoutDates->addWidget( noMoreEvents ); 104 layoutDates->addWidget( noMoreEvents );
104 } 105 }
105 } else { 106 } else {
106 QLabel* noEvents = new QLabel( this ); 107 QLabel* noEvents = new QLabel( this );
107 noEvents->setText( QObject::tr( "No appointments today" ) ); 108 noEvents->setText( QObject::tr( "No appointments today" ) );
108 layoutDates->addWidget( noEvents ); 109 layoutDates->addWidget( noEvents );
109 } 110 }
110} 111}
111 112
diff --git a/core/pim/today/plugins/datebook/datebookpluginwidget.h b/core/pim/today/plugins/datebook/datebookpluginwidget.h
index 1720bb2..3ebbc3d 100644
--- a/core/pim/today/plugins/datebook/datebookpluginwidget.h
+++ b/core/pim/today/plugins/datebook/datebookpluginwidget.h
@@ -1,52 +1,53 @@
1/* 1/*
2 * datebookpluginwidget.h 2 * datebookpluginwidget.h
3 * 3 *
4 * copyright : (c) 2002 by Maximilian Reiß 4 * copyright : (c) 2002 by Maximilian Reiß
5 * email : harlekin@handhelds.org 5 * email : harlekin@handhelds.org
6 * 6 *
7 */ 7 */
8/*************************************************************************** 8/***************************************************************************
9 * * 9 * *
10 * This program is free software; you can redistribute it and/or modify * 10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by * 11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or * 12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. * 13 * (at your option) any later version. *
14 * * 14 * *
15 ***************************************************************************/ 15 ***************************************************************************/
16 16
17#ifndef DATEBOOK_PLUGIN_WIDGET_H 17#ifndef DATEBOOK_PLUGIN_WIDGET_H
18#define DATEBOOK_PLUGIN_WIDGET_H 18#define DATEBOOK_PLUGIN_WIDGET_H
19 19
20#include <qstring.h> 20#include <qstring.h>
21#include <qwidget.h> 21#include <qwidget.h>
22 22
23#include <qpe/datebookdb.h> 23#include <qpe/datebookdb.h>
24#include <opie/oclickablelabel.h> 24#include <opie/oclickablelabel.h>
25 25
26 26
27class DatebookPluginWidget : public QWidget { 27class DatebookPluginWidget : public QWidget {
28 28
29 Q_OBJECT 29 Q_OBJECT
30 30
31public: 31public:
32 DatebookPluginWidget( QWidget *parent, const char *name ); 32 DatebookPluginWidget( QWidget *parent, const char *name );
33 ~DatebookPluginWidget(); 33 ~DatebookPluginWidget();
34 34
35 35
36private: 36private:
37 DateBookDB* db; 37 DateBookDB* db;
38 void readConfig(); 38 void readConfig();
39 void getDates(); 39 void getDates();
40 40
41 // how many lines should be showed in the datebook section 41 // how many lines should be showed in the datebook section
42 int m_max_lines_meet; 42 int m_max_lines_meet;
43 // If location is to be showed too, 1 to activate it. 43 // If location is to be showed too, 1 to activate it.
44 bool m_show_location; 44 bool m_show_location;
45 // if notes should be shown 45 // if notes should be shown
46 bool m_show_notes; 46 bool m_show_notes;
47 // should only later appointments be shown or all for the current day. 47 // should only later appointments be shown or all for the current day.
48 bool m_onlyLater; 48 bool m_onlyLater;
49 int m_moreDays;
49 50
50}; 51};
51 52
52#endif 53#endif