summaryrefslogtreecommitdiff
authorharlekin <harlekin>2003-03-23 15:17:55 (UTC)
committer harlekin <harlekin>2003-03-23 15:17:55 (UTC)
commit34d831699c7a7be4bd81cd7d7336b66b53ef78d9 (patch) (unidiff)
treeb38d3e4377bdc47e8a78c070af2ca2ac62e48d70
parentfd1b86e8590b34efb38b82953e5bf897a8de1cdf (diff)
downloadopie-34d831699c7a7be4bd81cd7d7336b66b53ef78d9.zip
opie-34d831699c7a7be4bd81cd7d7336b66b53ef78d9.tar.gz
opie-34d831699c7a7be4bd81cd7d7336b66b53ef78d9.tar.bz2
if multiple days are selected and only later is on still show all events on next days ,)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/today/plugins/datebook/datebookpluginwidget.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/core/pim/today/plugins/datebook/datebookpluginwidget.cpp b/core/pim/today/plugins/datebook/datebookpluginwidget.cpp
index 896d41d..781e3a4 100644
--- a/core/pim/today/plugins/datebook/datebookpluginwidget.cpp
+++ b/core/pim/today/plugins/datebook/datebookpluginwidget.cpp
@@ -1,115 +1,125 @@
1 /* 1 /*
2 * datebookpluginwidget.cpp 2 * datebookpluginwidget.cpp
3 * 3 *
4 * copyright : (c) 2002,2003 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 *
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 19
20#include <qpe/timestring.h> 20#include <qpe/timestring.h>
21#include <qpe/config.h> 21#include <qpe/config.h>
22 22
23#include <qdatetime.h> 23#include <qdatetime.h>
24#include <qlabel.h> 24#include <qlabel.h>
25#include <qtl.h> 25#include <qtl.h>
26 26
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 ) { 33 if ( db ) {
34 delete db; 34 delete db;
35 } 35 }
36 db = new DateBookDB; 36 db = new DateBookDB;
37 37
38 if ( m_layoutDates ) { 38 if ( m_layoutDates ) {
39 delete m_layoutDates; 39 delete m_layoutDates;
40 } 40 }
41 m_layoutDates = new QVBoxLayout( this ); 41 m_layoutDates = new QVBoxLayout( this );
42 m_layoutDates->setAutoAdd( true ); 42 m_layoutDates->setAutoAdd( true );
43 43
44 m_eventsList.setAutoDelete( true ); 44 m_eventsList.setAutoDelete( true );
45 45
46 readConfig(); 46 readConfig();
47 getDates(); 47 getDates();
48 m_layoutDates->addStretch(5);
48} 49}
49 50
50DatebookPluginWidget::~DatebookPluginWidget() { 51DatebookPluginWidget::~DatebookPluginWidget() {
51 delete db; 52 delete db;
52 delete m_layoutDates; 53 delete m_layoutDates;
53} 54}
54 55
55 56
56void DatebookPluginWidget::readConfig() { 57void DatebookPluginWidget::readConfig() {
57 Config cfg( "todaydatebookplugin" ); 58 Config cfg( "todaydatebookplugin" );
58 cfg.setGroup( "config" ); 59 cfg.setGroup( "config" );
59 m_max_lines_meet = cfg.readNumEntry( "maxlinesmeet", 5 ); 60 m_max_lines_meet = cfg.readNumEntry( "maxlinesmeet", 5 );
60 m_show_location = cfg.readNumEntry( "showlocation", 1 ); 61 m_show_location = cfg.readNumEntry( "showlocation", 1 );
61 m_show_notes = cfg.readNumEntry( "shownotes", 0 ); 62 m_show_notes = cfg.readNumEntry( "shownotes", 0 );
62 m_onlyLater = cfg.readNumEntry( "onlylater", 1 ); 63 m_onlyLater = cfg.readNumEntry( "onlylater", 1 );
63 m_moreDays = cfg.readNumEntry( "moredays", 0 ); 64 m_moreDays = cfg.readNumEntry( "moredays", 0 );
64} 65}
65 66
66void DatebookPluginWidget::refresh() { 67void DatebookPluginWidget::refresh() {
67 m_eventsList.clear(); 68 m_eventsList.clear();
69
70 if ( m_layoutDates ) {
71 delete m_layoutDates;
72 }
73 m_layoutDates = new QVBoxLayout( this );
74 m_layoutDates->setAutoAdd( true );
75
68 getDates(); 76 getDates();
77 m_layoutDates->addStretch(5);
69} 78}
70 79
71/** 80/**
72 * Get all events that are in the datebook xml file for today 81 * Get all events that are in the datebook xml file for today
73 */ 82 */
74void DatebookPluginWidget::getDates() { 83void DatebookPluginWidget::getDates() {
75 84
76 QDate date = QDate::currentDate(); 85 QDate date = QDate::currentDate();
77 QValueList<EffectiveEvent> list = db->getEffectiveEvents( date, date.addDays( m_moreDays ) ); 86 QValueList<EffectiveEvent> list = db->getEffectiveEvents( date, date.addDays( m_moreDays ) );
78 qBubbleSort( list ); 87 qBubbleSort( list );
79 int count = 0; 88 int count = 0;
80 89
81 if ( list.count() > 0 ) { 90 if ( list.count() > 0 ) {
82 91
83 for ( QValueList<EffectiveEvent>::ConstIterator it = list.begin(); it != list.end(); ++it ) { 92 for ( QValueList<EffectiveEvent>::ConstIterator it = list.begin(); it != list.end(); ++it ) {
84 93
85 if ( count <= m_max_lines_meet ) { 94 if ( count <= m_max_lines_meet ) {
86 if ( !m_onlyLater ) { 95 if ( !m_onlyLater ) {
87 count++; 96 count++;
88 DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes ); 97 DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes );
89 m_eventsList.append( l ); 98 m_eventsList.append( l );
90 l->show(); 99 l->show();
91 QObject::connect ( l, SIGNAL( editEvent( const Event & ) ), l, SLOT( editEventSlot( const Event & ) ) ); 100 QObject::connect ( l, SIGNAL( editEvent( const Event & ) ), l, SLOT( editEventSlot( const Event & ) ) );
92 } else if ( QDateTime::currentDateTime() <= (*it).event().end() ) { 101 } else if ( QDateTime::currentDateTime() <= (*it).event().end() || (*it).event().start().date() != date ) {
93 count++; 102 count++;
94 // show only later appointments 103 // show only later appointments
95 DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes ); 104 DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes );
96 m_eventsList.append( l ); 105 m_eventsList.append( l );
97 l->show(); 106 l->show();
98 QObject::connect ( l, SIGNAL( editEvent( const Event & ) ), l, SLOT( editEventSlot( const Event & ) ) ); 107 QObject::connect ( l, SIGNAL( editEvent( const Event & ) ), l, SLOT( editEventSlot( const Event & ) ) );
99 } 108 }
100 } 109 }
101 } 110 }
102 if ( m_onlyLater && count == 0 ) { 111 if ( m_onlyLater && count == 0 ) {
103 QLabel* noMoreEvents = new QLabel( this ); 112 QLabel* noMoreEvents = new QLabel( this );
104 m_eventsList.append( noMoreEvents ); 113 m_eventsList.append( noMoreEvents );
105 noMoreEvents->show(); 114 noMoreEvents->show();
106 noMoreEvents->setText( QObject::tr( "No more appointments today" ) ); 115 noMoreEvents->setText( QObject::tr( "No more appointments today" ) );
107 } 116 }
108 } else { 117 } else {
109 QLabel* noEvents = new QLabel( this ); 118 QLabel* noEvents = new QLabel( this );
110 m_eventsList.append( noEvents ); 119 m_eventsList.append( noEvents );
111 noEvents->show(); 120 noEvents->show();
112 noEvents->setText( QObject::tr( "No appointments today" ) ); 121 noEvents->setText( QObject::tr( "No appointments today" ) );
113 } 122 }
114} 123}
115 124
125