summaryrefslogtreecommitdiff
path: root/core/pim/today/plugins/datebook
Unidiff
Diffstat (limited to 'core/pim/today/plugins/datebook') (more/less context) (show whitespace changes)
-rw-r--r--core/pim/today/plugins/datebook/.cvsignore1
-rw-r--r--core/pim/today/plugins/datebook/config.in2
-rw-r--r--core/pim/today/plugins/datebook/datebook.pro19
-rw-r--r--core/pim/today/plugins/datebook/datebookevent.cpp48
-rw-r--r--core/pim/today/plugins/datebook/datebookevent.h5
-rw-r--r--core/pim/today/plugins/datebook/datebookplugin.cpp7
-rw-r--r--core/pim/today/plugins/datebook/datebookplugin.h1
-rw-r--r--core/pim/today/plugins/datebook/datebookpluginwidget.cpp38
-rw-r--r--core/pim/today/plugins/datebook/datebookpluginwidget.h4
9 files changed, 93 insertions, 32 deletions
diff --git a/core/pim/today/plugins/datebook/.cvsignore b/core/pim/today/plugins/datebook/.cvsignore
index 2888d4a..10cf625 100644
--- a/core/pim/today/plugins/datebook/.cvsignore
+++ b/core/pim/today/plugins/datebook/.cvsignore
@@ -1,2 +1,3 @@
1Makefile* 1Makefile*
2datebookpluginconfigbase*
2moc* 3moc*
diff --git a/core/pim/today/plugins/datebook/config.in b/core/pim/today/plugins/datebook/config.in
index 621510f..7a14438 100644
--- a/core/pim/today/plugins/datebook/config.in
+++ b/core/pim/today/plugins/datebook/config.in
@@ -1,4 +1,4 @@
1 config TODAY_DATEBOOK 1 config TODAY_DATEBOOK
2 boolean "opie-today-datebookplugin (datebook plugin)" 2 boolean "datebook"
3 default "y" 3 default "y"
4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE 4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE
diff --git a/core/pim/today/plugins/datebook/datebook.pro b/core/pim/today/plugins/datebook/datebook.pro
index bd45f71..1f75964 100644
--- a/core/pim/today/plugins/datebook/datebook.pro
+++ b/core/pim/today/plugins/datebook/datebook.pro
@@ -15,7 +15,26 @@ DEPENDPATH += $(OPIEDIR)/include \
15 15
16LIBS+= -lqpe -lopie 16LIBS+= -lqpe -lopie
17 17
18DESTDIR = $(OPIEDIR)/plugins/today 18DESTDIR = $(OPIEDIR)/plugins/today
19TARGET = todaydatebookplugin 19TARGET = todaydatebookplugin
20 20
21TRANSLATIONS = ../../../../../i18n/de/libtodaydatebookplugin.ts \
22 ../../../../../i18n/nl/libtodaydatebookplugin.ts \
23 ../../../../../i18n/xx/libtodaydatebookplugin.ts \
24 ../../../../../i18n/en/libtodaydatebookplugin.ts \
25 ../../../../../i18n/es/libtodaydatebookplugin.ts \
26 ../../../../../i18n/fr/libtodaydatebookplugin.ts \
27 ../../../../../i18n/hu/libtodaydatebookplugin.ts \
28 ../../../../../i18n/ja/libtodaydatebookplugin.ts \
29 ../../../../../i18n/ko/libtodaydatebookplugin.ts \
30 ../../../../../i18n/no/libtodaydatebookplugin.ts \
31 ../../../../../i18n/pl/libtodaydatebookplugin.ts \
32 ../../../../../i18n/pt/libtodaydatebookplugin.ts \
33 ../../../../../i18n/pt_BR/libtodaydatebookplugin.ts \
34 ../../../../../i18n/sl/libtodaydatebookplugin.ts \
35 ../../../../../i18n/zh_CN/libtodaydatebookplugin.ts \
36 ../../../../../i18n/zh_TW/libtodaydatebookplugin.ts \
37 ../../../../../i18n/it/libtodaydatebookplugin.ts \
38 ../../../../../i18n/da/libtodaydatebookplugin.ts
39
21include ( $(OPIEDIR)/include.pro ) 40include ( $(OPIEDIR)/include.pro )
diff --git a/core/pim/today/plugins/datebook/datebookevent.cpp b/core/pim/today/plugins/datebook/datebookevent.cpp
index 3c1e97a..e595047 100644
--- a/core/pim/today/plugins/datebook/datebookevent.cpp
+++ b/core/pim/today/plugins/datebook/datebookevent.cpp
@@ -1,10 +1,10 @@
1/* 1/*
2 * datebookevent.cpp 2 * datebookevent.cpp
3 * 3 *
4 * copyright : (c) 2002 by Maximilian Reiß 4 * copyright : (c) 2002, 2003 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 *
@@ -16,21 +16,23 @@
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#include <qpe/calendar.h>
22 23
23#include <opie/odevice.h> 24#include <opie/odevice.h>
24 25
25using namespace Opie; 26using namespace Opie;
26 27
27DateBookEvent::DateBookEvent(const EffectiveEvent &ev, 28DateBookEvent::DateBookEvent(const EffectiveEvent &ev,
28 QWidget* parent, 29 QWidget* parent,
29 bool show_location, 30 bool show_location,
30 bool show_notes, 31 bool show_notes,
32 bool timeExtraLine,
31 int maxCharClip, 33 int maxCharClip,
32 const char* name, 34 const char* name,
33 WFlags fl) : 35 WFlags fl) :
34 OClickableLabel(parent,name,fl), event(ev) { 36 OClickableLabel(parent,name,fl), event(ev) {
35 37
36 // setAlignment( AlignTop ); 38 // setAlignment( AlignTop );
@@ -49,23 +51,31 @@ DateBookEvent::DateBookEvent(const EffectiveEvent &ev,
49 51
50 // include location or not 52 // include location or not
51 if ( show_location ) { 53 if ( show_location ) {
52 msg += "<BR><i>" + (ev).location() + "</i>"; 54 msg += "<BR><i>" + (ev).location() + "</i>";
53 } 55 }
54 56
57 QString timeSpacer = " ";
58 if ( timeExtraLine ) {
59 timeSpacer = "<br>";
60 }
61
55 if ( ( TimeString::timeString( QTime( (ev).event().start().time() ) ) == "00:00" ) 62 if ( ( TimeString::timeString( QTime( (ev).event().start().time() ) ) == "00:00" )
56 && ( TimeString::timeString( QTime( (ev).event().end().time() ) ) == "23:59" ) ) { 63 && ( TimeString::timeString( QTime( (ev).event().end().time() ) ) == "23:59" ) ) {
57 msg += "<br>All day"; 64 msg += tr ( "All day" );
58 } else { 65 } else {
59 // start time of event 66 // start time of event
60 QDate tempDate = (ev).event().start().date(); 67// QDate tempDate = (ev).event().start().date();
61 msg += "<br>" 68 msg += timeSpacer;
62 + ampmTime( QTime( (ev).event().start().time() ) ) 69 msg += ampmTime( QTime( (ev).event().start().time() ) )
63 // end time of event 70 // end time of event
64 + "<b> - </b>" + ampmTime( QTime( (ev).event().end().time() ) ) 71 + "<b> - </b>" + ampmTime( QTime( (ev).event().end().time() ) );
65 + differDate( tempDate ); 72 }
73
74 if ( (ev).date() != QDate::currentDate() ) {
75 msg += differDate( (ev).date() /* tempDate*/ );
66 } 76 }
67 77
68 // include possible note or not 78 // include possible note or not
69 if ( show_notes ) { 79 if ( show_notes ) {
70 msg += "<br> <i>" + tr("note") + "</i>:" +( (ev).notes() ).mid( 0, maxCharClip ); 80 msg += "<br> <i>" + tr("note") + "</i>:" +( (ev).notes() ).mid( 0, maxCharClip );
71 } 81 }
@@ -98,24 +108,24 @@ QString DateBookEvent::ampmTime( QTime tm ) {
98 s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); 108 s.sprintf( "%2d:%02d", tm.hour(), tm.minute() );
99 return s; 109 return s;
100 } 110 }
101} 111}
102 112
103QString DateBookEvent::differDate( QDate date ) { 113QString DateBookEvent::differDate( QDate date ) {
104 QDate currentDate = QDate::currentDate(); 114// QDate currentDate = QDate::currentDate();
105 QString returnText = "<font color = #407DD9><b> "; 115 QString returnText = "<font color = #407DD9><b> ";
106 int differDate = currentDate.daysTo( date ); 116// int differDate = currentDate.daysTo( date );
107 if ( currentDate.dayOfWeek() == date.dayOfWeek() ) { 117// if ( currentDate.dayOfWeek() == date.dayOfWeek() ) {
108 returnText += "" ; 118// returnText += "" ;
109 // not working right for recurring events 119// // not working right for recurring events
110 //} else if ( differDate == 1 ) { 120// //} else if ( differDate == 1 ) {
111 //returnText += tr( "tomorrow" ); 121// //returnText += tr( "tomorrow" );
112 } else { 122// } else {
113 //returnText += tr( "in %1 days" ).arg( differDate ); 123// returnText += " [ " + Calendar::nameOfDay( date.dayOfWeek() ) + " ] ";
114 returnText += " [ " + date.dayName( date.dayOfWeek() ) + " ] "; 124// }
115 } 125 returnText += " [ " + Calendar::nameOfDay( date.dayOfWeek() ) + " ] ";
116 returnText += "</b></font>"; 126 returnText += "</b></font>";
117 return returnText; 127 return returnText;
118} 128}
119 129
120 130
121/** 131/**
@@ -123,13 +133,13 @@ QString DateBookEvent::differDate( QDate date ) {
123 */ 133 */
124void DateBookEvent::editEventSlot( const Event &e ) { 134void DateBookEvent::editEventSlot( const Event &e ) {
125 135
126 if ( ODevice::inst()->system() == System_Zaurus ) { 136 if ( ODevice::inst()->system() == System_Zaurus ) {
127 QCopEnvelope env( "QPE/Application/datebook", "raise()" ); 137 QCopEnvelope env( "QPE/Application/datebook", "raise()" );
128 } else { 138 } else {
129 QCopEnvelope env( "QPE/Datebook", "editEvent(int)" ); 139 QCopEnvelope env( "QPE/Application/datebook", "editEvent(int)" );
130 env << e.uid(); 140 env << e.uid();
131 } 141 }
132} 142}
133 143
134 144
135void DateBookEvent::editMe() { 145void DateBookEvent::editMe() {
diff --git a/core/pim/today/plugins/datebook/datebookevent.h b/core/pim/today/plugins/datebook/datebookevent.h
index 8027809..1a090e3 100644
--- a/core/pim/today/plugins/datebook/datebookevent.h
+++ b/core/pim/today/plugins/datebook/datebookevent.h
@@ -1,10 +1,10 @@
1/* 1/*
2 * datebookplugin.h 2 * datebookplugin.h
3 * 3 *
4 * copyright : (c) 2002 by Maximilian Reiß 4 * copyright : (c) 2002, 2003 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 *
@@ -27,22 +27,25 @@ class DateBookEvent: public OClickableLabel {
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 bool timeExtraLine = 0,
33 int maxCharClip = 0, 34 int maxCharClip = 0,
34 const char* name = 0, 35 const char* name = 0,
35 WFlags fl = 0 ); 36 WFlags fl = 0 );
36 ~DateBookEvent(); 37 ~DateBookEvent();
38
37 signals: 39 signals:
38 void editEvent( const Event &e ); 40 void editEvent( const Event &e );
39 41
40private slots: 42private slots:
41 void editEventSlot( const Event &e ); 43 void editEventSlot( const Event &e );
42 void editMe(); 44 void editMe();
45
43 private: 46 private:
44 47
45 QString ampmTime( QTime ); 48 QString ampmTime( QTime );
46 QString differDate( QDate date ); 49 QString differDate( QDate date );
47 const EffectiveEvent event; 50 const EffectiveEvent event;
48 bool ampm; 51 bool ampm;
diff --git a/core/pim/today/plugins/datebook/datebookplugin.cpp b/core/pim/today/plugins/datebook/datebookplugin.cpp
index 4e650ee..f77e440 100644
--- a/core/pim/today/plugins/datebook/datebookplugin.cpp
+++ b/core/pim/today/plugins/datebook/datebookplugin.cpp
@@ -66,6 +66,13 @@ bool DatebookPlugin::excludeFromRefresh() const {
66 66
67void DatebookPlugin::refresh() { 67void DatebookPlugin::refresh() {
68 if ( m_widget ) { 68 if ( m_widget ) {
69 m_widget->refresh(); 69 m_widget->refresh();
70 } 70 }
71} 71}
72
73void DatebookPlugin::reinitialize() {
74 if ( m_widget ) {
75 m_widget->reinitialize();
76 }
77}
78
diff --git a/core/pim/today/plugins/datebook/datebookplugin.h b/core/pim/today/plugins/datebook/datebookplugin.h
index db899e8..890c59b 100644
--- a/core/pim/today/plugins/datebook/datebookplugin.h
+++ b/core/pim/today/plugins/datebook/datebookplugin.h
@@ -36,12 +36,13 @@ public:
36 QWidget* widget( QWidget *); 36 QWidget* widget( QWidget *);
37 QString pixmapNameConfig() const; 37 QString pixmapNameConfig() const;
38 TodayConfigWidget* configWidget( QWidget *); 38 TodayConfigWidget* configWidget( QWidget *);
39 QString appName() const; 39 QString appName() const;
40 bool excludeFromRefresh() const; 40 bool excludeFromRefresh() const;
41 void refresh(); 41 void refresh();
42 void reinitialize();
42 43
43 private: 44 private:
44 QGuardedPtr<DatebookPluginWidget> m_widget; 45 QGuardedPtr<DatebookPluginWidget> m_widget;
45}; 46};
46 47
47 48
diff --git a/core/pim/today/plugins/datebook/datebookpluginwidget.cpp b/core/pim/today/plugins/datebook/datebookpluginwidget.cpp
index 1970654..9e95bcd 100644
--- a/core/pim/today/plugins/datebook/datebookpluginwidget.cpp
+++ b/core/pim/today/plugins/datebook/datebookpluginwidget.cpp
@@ -27,28 +27,22 @@
27DatebookPluginWidget::DatebookPluginWidget( QWidget *parent, const char* name ) 27DatebookPluginWidget::DatebookPluginWidget( QWidget *parent, const char* name )
28 : QWidget(parent, name ) { 28 : QWidget(parent, name ) {
29 29
30 db = 0l; 30 db = 0l;
31 m_layoutDates = 0l; 31 m_layoutDates = 0l;
32 32
33 if ( db ) {
34 delete db;
35 }
36 db = new DateBookDB;
37
38 if ( m_layoutDates ) { 33 if ( m_layoutDates ) {
39 delete m_layoutDates; 34 delete m_layoutDates;
40 } 35 }
41 m_layoutDates = new QVBoxLayout( this ); 36 m_layoutDates = new QVBoxLayout( this );
42 m_layoutDates->setAutoAdd( true ); 37 m_layoutDates->setAutoAdd( true );
43 38
44 m_eventsList.setAutoDelete( true ); 39 m_eventsList.setAutoDelete( true );
45 40
46 readConfig(); 41 readConfig();
47 getDates(); 42 getDates();
48 m_layoutDates->addStretch(5);
49} 43}
50 44
51DatebookPluginWidget::~DatebookPluginWidget() { 45DatebookPluginWidget::~DatebookPluginWidget() {
52 delete db; 46 delete db;
53 delete m_layoutDates; 47 delete m_layoutDates;
54} 48}
@@ -59,58 +53,82 @@ void DatebookPluginWidget::readConfig() {
59 cfg.setGroup( "config" ); 53 cfg.setGroup( "config" );
60 m_max_lines_meet = cfg.readNumEntry( "maxlinesmeet", 5 ); 54 m_max_lines_meet = cfg.readNumEntry( "maxlinesmeet", 5 );
61 m_show_location = cfg.readNumEntry( "showlocation", 1 ); 55 m_show_location = cfg.readNumEntry( "showlocation", 1 );
62 m_show_notes = cfg.readNumEntry( "shownotes", 0 ); 56 m_show_notes = cfg.readNumEntry( "shownotes", 0 );
63 m_onlyLater = cfg.readNumEntry( "onlylater", 1 ); 57 m_onlyLater = cfg.readNumEntry( "onlylater", 1 );
64 m_moreDays = cfg.readNumEntry( "moredays", 0 ); 58 m_moreDays = cfg.readNumEntry( "moredays", 0 );
59 m_timeExtraLine = cfg.readNumEntry( "timeextraline", 1 );
60}
61
62void DatebookPluginWidget::reinitialize() {
63 readConfig();
64 refresh();
65} 65}
66 66
67void DatebookPluginWidget::refresh() { 67void DatebookPluginWidget::refresh() {
68 m_eventsList.clear(); 68 m_eventsList.clear();
69 69
70 if ( m_layoutDates ) { 70 if ( m_layoutDates ) {
71 delete m_layoutDates; 71 delete m_layoutDates;
72 } 72 }
73 m_layoutDates = new QVBoxLayout( this ); 73 m_layoutDates = new QVBoxLayout( this );
74 m_layoutDates->setAutoAdd( true ); 74 m_layoutDates->setAutoAdd( true );
75 75
76 getDates(); 76 getDates();
77 m_layoutDates->addStretch(5);
78} 77}
79 78
80/** 79/**
81 * Get all events that are in the datebook xml file for today 80 * Get all events that are in the datebook xml file for today
82 */ 81 */
83void DatebookPluginWidget::getDates() { 82void DatebookPluginWidget::getDates() {
84 83
84
85 if ( db ) {
86 delete db;
87 }
88 db = new DateBookDB;
89
85 QDate date = QDate::currentDate(); 90 QDate date = QDate::currentDate();
86 QValueList<EffectiveEvent> list = db->getEffectiveEvents( date, date.addDays( m_moreDays ) ); 91 QValueList<EffectiveEvent> list = db->getEffectiveEvents( date, date.addDays( m_moreDays ) );
87 qBubbleSort( list ); 92 qBubbleSort( list );
88 int count = 0; 93 int count = 0;
89 94
90 if ( list.count() > 0 ) { 95 if ( list.count() > 0 ) {
91 96
92 for ( QValueList<EffectiveEvent>::ConstIterator it = list.begin(); it != list.end(); ++it ) { 97 for ( QValueList<EffectiveEvent>::ConstIterator it = list.begin(); it != list.end(); ++it ) {
93 98
94 if ( count < m_max_lines_meet ) { 99 if ( count < m_max_lines_meet ) {
95 if ( !m_onlyLater ) { 100 if ( !m_onlyLater ) {
96 count++; 101 count++;
97 DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes ); 102 DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes, m_timeExtraLine );
98 m_eventsList.append( l ); 103 m_eventsList.append( l );
99 l->show(); 104 l->show();
100 QObject::connect ( l, SIGNAL( editEvent( const Event & ) ), l, SLOT( editEventSlot( const Event & ) ) ); 105 QObject::connect ( l, SIGNAL( editEvent( const Event & ) ), l, SLOT( editEventSlot( const Event & ) ) );
101 } else if ( QDateTime::currentDateTime() <= (*it).event().end() || (*it).event().start().date() != date ) { 106 } else {
107 if ( ( QDateTime::currentDateTime() <= (*it).event().end() )
108 // Show events which span over many days and are not elapsed.
109 || ( ( (*it).event().start().date() != date ) && ( QDateTime::currentDateTime() <= (*it).event().end() ) )
110 // Show repeated event for today that is not elapsed.
111 || ( ( (*it).event().repeatType() != Event::NoRepeat )
112 && ( ( date.dayOfWeek() == (*it).date().dayOfWeek() )
113 && ( QTime::currentTime() < (*it).event().start().time() ) ) )
114 // Show repeated event for next days.
115 || ( ( (*it).event().repeatType() != Event::NoRepeat )
116 && ( date.dayOfWeek() != (*it).date().dayOfWeek() ) )
117 )
118 {
102 count++; 119 count++;
103 // show only later appointments 120 // show only later appointments
104 DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes ); 121 DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes, m_timeExtraLine );
105 m_eventsList.append( l ); 122 m_eventsList.append( l );
106 l->show(); 123 l->show();
107 QObject::connect ( l, SIGNAL( editEvent( const Event & ) ), l, SLOT( editEventSlot( const Event & ) ) ); 124 QObject::connect ( l, SIGNAL( editEvent( const Event & ) ), l, SLOT( editEventSlot( const Event & ) ) );
108 } 125 }
109 } 126 }
110 } 127 }
128 }
111 if ( m_onlyLater && count == 0 ) { 129 if ( m_onlyLater && count == 0 ) {
112 QLabel* noMoreEvents = new QLabel( this ); 130 QLabel* noMoreEvents = new QLabel( this );
113 m_eventsList.append( noMoreEvents ); 131 m_eventsList.append( noMoreEvents );
114 noMoreEvents->show(); 132 noMoreEvents->show();
115 noMoreEvents->setText( QObject::tr( "No more appointments today" ) ); 133 noMoreEvents->setText( QObject::tr( "No more appointments today" ) );
116 } 134 }
diff --git a/core/pim/today/plugins/datebook/datebookpluginwidget.h b/core/pim/today/plugins/datebook/datebookpluginwidget.h
index 35d43cd..8988073 100644
--- a/core/pim/today/plugins/datebook/datebookpluginwidget.h
+++ b/core/pim/today/plugins/datebook/datebookpluginwidget.h
@@ -31,12 +31,13 @@ class DatebookPluginWidget : public QWidget {
31 Q_OBJECT 31 Q_OBJECT
32 32
33public: 33public:
34 DatebookPluginWidget( QWidget *parent, const char *name ); 34 DatebookPluginWidget( QWidget *parent, const char *name );
35 ~DatebookPluginWidget(); 35 ~DatebookPluginWidget();
36 void refresh(); 36 void refresh();
37 void reinitialize();
37 38
38private: 39private:
39 DateBookDB* db; 40 DateBookDB* db;
40 QGuardedPtr<QVBoxLayout> m_layoutDates; 41 QGuardedPtr<QVBoxLayout> m_layoutDates;
41 QList<QWidget> m_eventsList; 42 QList<QWidget> m_eventsList;
42 void readConfig(); 43 void readConfig();
@@ -49,10 +50,11 @@ private:
49 bool m_show_location; 50 bool m_show_location;
50 // if notes should be shown 51 // if notes should be shown
51 bool m_show_notes; 52 bool m_show_notes;
52 // should only later appointments be shown or all for the current day. 53 // should only later appointments be shown or all for the current day.
53 bool m_onlyLater; 54 bool m_onlyLater;
54 int m_moreDays; 55 int m_moreDays;
55 56 // true if time of an appointment should be an extra line
57 bool m_timeExtraLine;
56}; 58};
57 59
58#endif 60#endif