author | harlekin <harlekin> | 2002-09-15 21:13:47 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-09-15 21:13:47 (UTC) |
commit | 87cd421d72df1d7706925285a48c008007471310 (patch) (unidiff) | |
tree | eb7805bd6702f2820aac159baa4a9c5592a52ee4 /core/pim/today/plugins/datebook/datebookpluginwidget.cpp | |
parent | 251fd5b1687994c30e8bea1091e893468086223f (diff) | |
download | opie-87cd421d72df1d7706925285a48c008007471310.zip opie-87cd421d72df1d7706925285a48c008007471310.tar.gz opie-87cd421d72df1d7706925285a48c008007471310.tar.bz2 |
plugins for the new today
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.cpp | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/core/pim/today/plugins/datebook/datebookpluginwidget.cpp b/core/pim/today/plugins/datebook/datebookpluginwidget.cpp new file mode 100644 index 0000000..e4667ae --- a/dev/null +++ b/core/pim/today/plugins/datebook/datebookpluginwidget.cpp | |||
@@ -0,0 +1,114 @@ | |||
1 | /* | ||
2 | * datebookpluginwidget.cpp | ||
3 | * | ||
4 | * copyright : (c) 2002 by Maximilian Reiß | ||
5 | * email : harlekin@handhelds.org | ||
6 | * | ||
7 | */ | ||
8 | /*************************************************************************** | ||
9 | * * | ||
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 * | ||
12 | * the Free Software Foundation; either version 2 of the License, or * | ||
13 | * (at your option) any later version. * | ||
14 | * * | ||
15 | ***************************************************************************/ | ||
16 | |||
17 | |||
18 | #include "datebookpluginwidget.h" | ||
19 | #include "datebookevent.h" | ||
20 | |||
21 | #include <qpe/timestring.h> | ||
22 | #include <qpe/config.h> | ||
23 | |||
24 | #include <qdatetime.h> | ||
25 | #include <qlabel.h> | ||
26 | #include <qlayout.h> | ||
27 | #include <qtl.h> | ||
28 | #include <qscrollview.h> | ||
29 | #include <qtimer.h> | ||
30 | |||
31 | DatebookPluginWidget::DatebookPluginWidget( QWidget *parent, const char* name) | ||
32 | : QWidget(parent, name ) { | ||
33 | db = 0l; | ||
34 | readConfig(); | ||
35 | getDates(); | ||
36 | } | ||
37 | |||
38 | DatebookPluginWidget::~DatebookPluginWidget() { | ||
39 | delete db; | ||
40 | } | ||
41 | |||
42 | |||
43 | void DatebookPluginWidget::readConfig() { | ||
44 | Config cfg( "todaydatebookplugin" ); | ||
45 | cfg.setGroup( "config" ); | ||
46 | m_max_lines_meet = cfg.readNumEntry( "maxlinesmeet", 5 ); | ||
47 | m_show_location = cfg.readNumEntry( "showlocation", 1 ); | ||
48 | m_show_notes = cfg.readNumEntry( "shownotes", 0 ); | ||
49 | m_onlyLater = cfg.readNumEntry( "onlylater", 1 ); | ||
50 | } | ||
51 | |||
52 | |||
53 | /** | ||
54 | * Get all events that are in the datebook xml file for today | ||
55 | */ | ||
56 | void DatebookPluginWidget::getDates() { | ||
57 | |||
58 | |||
59 | QDate date = QDate::currentDate(); | ||
60 | |||
61 | QVBoxLayout* layoutDates = new QVBoxLayout( this ); | ||
62 | |||
63 | if ( db ) { | ||
64 | delete db; | ||
65 | } | ||
66 | |||
67 | db = new DateBookDB; | ||
68 | |||
69 | QValueList<EffectiveEvent> list = db->getEffectiveEvents( date, date ); | ||
70 | |||
71 | qBubbleSort( list ); | ||
72 | |||
73 | Config config( "qpe" ); | ||
74 | |||
75 | int count=0; | ||
76 | |||
77 | if ( list.count() > 0 ) { | ||
78 | |||
79 | for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) { | ||
80 | |||
81 | if ( count <= m_max_lines_meet ) { | ||
82 | QTime time = QTime::currentTime(); | ||
83 | |||
84 | if ( !m_onlyLater ) { | ||
85 | count++; | ||
86 | DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes ); | ||
87 | layoutDates->addWidget( l ); | ||
88 | QObject::connect ( l, SIGNAL( editEvent( const Event &) ), l, SLOT( editEventSlot( const Event &) ) ); | ||
89 | } else if ( ( time.toString() <= TimeString::dateString( (*it).event().end() ) ) ) { | ||
90 | count++; | ||
91 | // show only later appointments | ||
92 | DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes ); | ||
93 | layoutDates->addWidget( l ); | ||
94 | QObject::connect ( l, SIGNAL( editEvent( const Event &) ), l, SLOT( editEventSlot( const Event &) ) ); | ||
95 | } | ||
96 | } | ||
97 | } | ||
98 | if ( m_onlyLater && count == 0 ) { | ||
99 | QLabel* noMoreEvents = new QLabel( this ); | ||
100 | noMoreEvents->setText( QObject::tr( "No more appointments today" ) ); | ||
101 | layoutDates->addWidget( noMoreEvents ); | ||
102 | } | ||
103 | } else { | ||
104 | QLabel* noEvents = new QLabel( this ); | ||
105 | noEvents->setText( QObject::tr( "No appointments today" ) ); | ||
106 | layoutDates->addWidget( noEvents ); | ||
107 | } | ||
108 | |||
109 | layoutDates->addItem( new QSpacerItem( 1,1, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); | ||
110 | |||
111 | // how often refresh - later have qcop update calls in *db | ||
112 | //QTimer::singleShot( 20*1000, this , SLOT( getDates() ) ); | ||
113 | } | ||
114 | |||