summaryrefslogtreecommitdiff
path: root/core/pim/today/plugins/datebook/datebookpluginwidget.cpp
Unidiff
Diffstat (limited to 'core/pim/today/plugins/datebook/datebookpluginwidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/pim/today/plugins/datebook/datebookpluginwidget.cpp38
1 files changed, 28 insertions, 10 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
@@ -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 }