summaryrefslogtreecommitdiff
path: root/core/pim/today/plugins/datebook/datebookpluginwidget.cpp
Unidiff
Diffstat (limited to 'core/pim/today/plugins/datebook/datebookpluginwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/today/plugins/datebook/datebookpluginwidget.cpp50
1 files changed, 34 insertions, 16 deletions
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
@@ -30,11 +30,6 @@ DatebookPluginWidget::DatebookPluginWidget( QWidget *parent, const char* name )
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 }
@@ -45,7 +40,6 @@ DatebookPluginWidget::DatebookPluginWidget( QWidget *parent, const char* name )
45 40
46 readConfig(); 41 readConfig();
47 getDates(); 42 getDates();
48 m_layoutDates->addStretch(5);
49} 43}
50 44
51DatebookPluginWidget::~DatebookPluginWidget() { 45DatebookPluginWidget::~DatebookPluginWidget() {
@@ -62,6 +56,12 @@ void DatebookPluginWidget::readConfig() {
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() {
@@ -74,7 +74,6 @@ void DatebookPluginWidget::refresh() {
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/**
@@ -82,6 +81,12 @@ void DatebookPluginWidget::refresh() {
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 );
@@ -94,18 +99,31 @@ void DatebookPluginWidget::getDates() {
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 );
99 l->show();
100 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 ) {
102 count++;
103 // show only later appointments
104 DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes );
105 m_eventsList.append( l ); 103 m_eventsList.append( l );
106 l->show(); 104 l->show();
107 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 & ) ) );
108 } 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 {
119 count++;
120 // show only later appointments
121 DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes, m_timeExtraLine );
122 m_eventsList.append( l );
123 l->show();
124 QObject::connect ( l, SIGNAL( editEvent( const Event & ) ), l, SLOT( editEventSlot( const Event & ) ) );
125 }
126 }
109 } 127 }
110 } 128 }
111 if ( m_onlyLater && count == 0 ) { 129 if ( m_onlyLater && count == 0 ) {