summaryrefslogtreecommitdiff
authoralwin <alwin>2005-03-19 13:44:30 (UTC)
committer alwin <alwin>2005-03-19 13:44:30 (UTC)
commit34e42590a8ef21c1377f89c7b82f25bcf0aec3cb (patch) (unidiff)
treef5afdae31945ca2bac7339a339499fa87ece50d9
parentd9e8b9e797e3162ab564bb3b0f04663ef1167541 (diff)
downloadopie-34e42590a8ef21c1377f89c7b82f25bcf0aec3cb.zip
opie-34e42590a8ef21c1377f89c7b82f25bcf0aec3cb.tar.gz
opie-34e42590a8ef21c1377f89c7b82f25bcf0aec3cb.tar.bz2
so....
I looked for a problem. could not found due the kind of code structure. so I had reorganized the code into a more sensefull structure so every one should be able to find some code sequences when searching for a bug. yes - now I found the problem and can thinking about resolving it.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp5
-rw-r--r--core/pim/datebook/datebook.h3
-rw-r--r--core/pim/datebook/datebook.pro18
-rw-r--r--core/pim/datebook/datebooktypes.h3
-rw-r--r--core/pim/datebook/datebookweeklst.cpp442
-rw-r--r--core/pim/datebook/datebookweeklst.h178
-rw-r--r--core/pim/datebook/modules/weeklst/.cvsignore4
-rw-r--r--core/pim/datebook/modules/weeklst/datebookweeklst.cpp138
-rw-r--r--core/pim/datebook/modules/weeklst/datebookweeklst.h65
-rw-r--r--core/pim/datebook/modules/weeklst/datebookweeklstdayhdr.cpp53
-rw-r--r--core/pim/datebook/modules/weeklst/datebookweeklstdayhdr.h26
-rw-r--r--core/pim/datebook/modules/weeklst/datebookweeklstdayhdrbase.ui (renamed from core/pim/datebook/datebookweeklstdayhdr.ui)0
-rw-r--r--core/pim/datebook/modules/weeklst/datebookweeklstdblview.cpp41
-rw-r--r--core/pim/datebook/modules/weeklst/datebookweeklstdblview.h31
-rw-r--r--core/pim/datebook/modules/weeklst/datebookweeklstevent.cpp85
-rw-r--r--core/pim/datebook/modules/weeklst/datebookweeklstevent.h34
-rw-r--r--core/pim/datebook/modules/weeklst/datebookweeklstheader.cpp96
-rw-r--r--core/pim/datebook/modules/weeklst/datebookweeklstheader.h34
-rw-r--r--core/pim/datebook/modules/weeklst/datebookweeklstheaderbase.ui (renamed from core/pim/datebook/datebookweeklstheader.ui)0
-rw-r--r--core/pim/datebook/modules/weeklst/datebookweeklstview.cpp73
-rw-r--r--core/pim/datebook/modules/weeklst/datebookweeklstview.h36
21 files changed, 736 insertions, 629 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index 70dd7b5..0579279 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -1,1212 +1,1213 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19** $Id$ 19** $Id$
20** 20**
21**********************************************************************/ 21**********************************************************************/
22 22
23#define QTOPIA_INTERNAL_FD 23#define QTOPIA_INTERNAL_FD
24 24
25#include "datebook.h" 25#include "datebook.h"
26#include "datebookday.h" 26#include "datebookday.h"
27#include "datebooksettings.h" 27#include "datebooksettings.h"
28#include "datebookweek.h" 28#include "datebookweek.h"
29#include "datebookweeklst.h" 29#include "modules/weeklst/datebookweeklst.h"
30#include "dateentryimpl.h" 30#include "dateentryimpl.h"
31 31
32#include <opie2/odebug.h> 32#include <opie2/odebug.h>
33#include <opie2/oholidaypluginif.h> 33#include <opie2/oholidaypluginif.h>
34#include <opie2/oholidayplugin.h> 34#include <opie2/oholidayplugin.h>
35#include <opie2/opluginloader.h> 35#include <opie2/opluginloader.h>
36#include <opie2/todayplugininterface.h> 36#include <opie2/todayplugininterface.h>
37 37
38#include <qpe/datebookmonth.h> 38#include <qpe/datebookmonth.h>
39#include <qpe/qpeapplication.h> 39#include <qpe/qpeapplication.h>
40#include <qpe/config.h> 40#include <qpe/config.h>
41#include <qpe/finddialog.h> 41#include <qpe/finddialog.h>
42#include <qpe/ir.h> 42#include <qpe/ir.h>
43#include <qpe/qpemessagebox.h> 43#include <qpe/qpemessagebox.h>
44#include <qpe/resource.h> 44#include <qpe/resource.h>
45#include <qpe/sound.h> 45#include <qpe/sound.h>
46#include <qpe/tzselect.h> 46#include <qpe/tzselect.h>
47#include <qtopia/qlibrary.h>
47 48
48#include <qaction.h> 49#include <qaction.h>
49#include <qcopchannel_qws.h> 50#include <qcopchannel_qws.h>
50#include <qlayout.h> 51#include <qlayout.h>
51#include <qmessagebox.h> 52#include <qmessagebox.h>
52#include <qtimer.h> 53#include <qtimer.h>
53#include <qtl.h> 54#include <qtl.h>
54#include <qtoolbar.h> 55#include <qtoolbar.h>
55#include <qwidgetstack.h> 56#include <qwidgetstack.h>
56#include <qdir.h> 57#include <qdir.h>
57#include <qtopia/qlibrary.h> 58#include <qlabel.h>
58 59
59#include <sys/stat.h> 60#include <sys/stat.h>
60#include <sys/types.h> 61#include <sys/types.h>
61#include <fcntl.h> 62#include <fcntl.h>
62#include <unistd.h> 63#include <unistd.h>
63 64
64#include <stdlib.h> 65#include <stdlib.h>
65 66
66DateBook::DateBook( QWidget *parent, const char *, WFlags f ) 67DateBook::DateBook( QWidget *parent, const char *, WFlags f )
67 : QMainWindow( parent, "datebook", f ), 68 : QMainWindow( parent, "datebook", f ),
68 aPreset( FALSE ), 69 aPreset( FALSE ),
69 presetTime( -1 ), 70 presetTime( -1 ),
70 startTime( 8 ), // an acceptable default 71 startTime( 8 ), // an acceptable default
71 rowStyle( 0 ), 72 rowStyle( 0 ),
72 bJumpToCurTime(FALSE), 73 bJumpToCurTime(FALSE),
73 syncing(FALSE), 74 syncing(FALSE),
74 inSearch(FALSE), 75 inSearch(FALSE),
75 alarmCounter(0) 76 alarmCounter(0)
76{ 77{
77 bool needEvilHack= false; // if we need an Evil Hack 78 bool needEvilHack= false; // if we need an Evil Hack
78 QTime t; 79 QTime t;
79 t.start(); 80 t.start();
80 db = new DateBookDBHoliday; 81 db = new DateBookDBHoliday;
81 odebug << "loading db t=" << t.elapsed() << oendl; 82 odebug << "loading db t=" << t.elapsed() << oendl;
82 db_holiday = new DateBookHoliday(); 83 db_holiday = new DateBookHoliday();
83 db->db_holiday=db_holiday; 84 db->db_holiday=db_holiday;
84 85
85 loadSettings(); 86 loadSettings();
86 setCaption( tr("Calendar") ); 87 setCaption( tr("Calendar") );
87 setIcon( Resource::loadPixmap( "datebook_icon" ) ); 88 setIcon( Resource::loadPixmap( "datebook_icon" ) );
88 89
89 setToolBarsMovable( FALSE ); 90 setToolBarsMovable( FALSE );
90 91
91 views = new QWidgetStack( this ); 92 views = new QWidgetStack( this );
92 setCentralWidget( views ); 93 setCentralWidget( views );
93 94
94 dayView = 0; 95 dayView = 0;
95 weekView = 0; 96 weekView = 0;
96 weekLstView = 0; 97 weekLstView = 0;
97 monthView = 0; 98 monthView = 0;
98 99
99// QToolBar *bar = new QToolBar( this ); 100// QToolBar *bar = new QToolBar( this );
100// bar->setHorizontalStretchable( TRUE ); 101// bar->setHorizontalStretchable( TRUE );
101 102
102// QMenuBar *mb = new QMenuBar( bar ); 103// QMenuBar *mb = new QMenuBar( bar );
103// mb->setMargin( 0 ); 104// mb->setMargin( 0 );
104 105
105// QPopupMenu *view = new QPopupMenu( this ); 106// QPopupMenu *view = new QPopupMenu( this );
106// mb->insertItem( tr( "View" ), view ); 107// mb->insertItem( tr( "View" ), view );
107 108
108 QToolBar *sub_bar = new QToolBar(this); 109 QToolBar *sub_bar = new QToolBar(this);
109 sub_bar->setHorizontalStretchable(TRUE); 110 sub_bar->setHorizontalStretchable(TRUE);
110 111
111 QActionGroup *g = new QActionGroup( this ); 112 QActionGroup *g = new QActionGroup( this );
112 g->setExclusive( TRUE ); 113 g->setExclusive( TRUE );
113 114
114 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); 115 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
115 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 116 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
116 a->addTo( sub_bar ); 117 a->addTo( sub_bar );
117 118
118 sub_bar->addSeparator(); 119 sub_bar->addSeparator();
119 120
120 a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 ); 121 a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 );
121 connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); 122 connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) );
122 a->addTo( sub_bar ); 123 a->addTo( sub_bar );
123// a->addTo( view ); 124// a->addTo( view );
124 125
125 sub_bar->addSeparator(); 126 sub_bar->addSeparator();
126 127
127 a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); 128 a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 );
128 connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); 129 connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) );
129 a->addTo( sub_bar ); 130 a->addTo( sub_bar );
130// a->addTo( view ); 131// a->addTo( view );
131 a->setToggleAction( TRUE ); 132 a->setToggleAction( TRUE );
132 a->setOn( TRUE ); 133 a->setOn( TRUE );
133 dayAction = a; 134 dayAction = a;
134 135
135 a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); 136 a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 );
136 connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); 137 connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) );
137 a->addTo( sub_bar ); 138 a->addTo( sub_bar );
138// a->addTo( view ); 139// a->addTo( view );
139 a->setToggleAction( TRUE ); 140 a->setToggleAction( TRUE );
140 weekAction = a; 141 weekAction = a;
141 142
142 a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 ); 143 a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 );
143 connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); 144 connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) );
144 a->addTo( sub_bar ); 145 a->addTo( sub_bar );
145// a->addTo( view ); 146// a->addTo( view );
146 a->setToggleAction( TRUE ); 147 a->setToggleAction( TRUE );
147 weekLstAction = a; 148 weekLstAction = a;
148 149
149 a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); 150 a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 );
150 connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); 151 connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) );
151 a->addTo( sub_bar ); 152 a->addTo( sub_bar );
152// a->addTo( view ); 153// a->addTo( view );
153 a->setToggleAction( TRUE ); 154 a->setToggleAction( TRUE );
154 monthAction = a; 155 monthAction = a;
155 156
156 sub_bar->addSeparator(); 157 sub_bar->addSeparator();
157 158
158 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 ); 159 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 );
159 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); 160 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) );
160 a->addTo( sub_bar ); 161 a->addTo( sub_bar );
161 162
162 a = new QAction( tr( "Edit..." ), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0 ); 163 a = new QAction( tr( "Edit..." ), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0 );
163 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); 164 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
164 a->addTo( sub_bar ); 165 a->addTo( sub_bar );
165 166
166 if(defaultView==DAY) viewDay(); 167 if(defaultView==DAY) viewDay();
167 if(defaultView==WEEK) needEvilHack=true; // viewWeek(); 168 if(defaultView==WEEK) needEvilHack=true; // viewWeek();
168 if(defaultView==WEEKLST) viewWeekLst(); 169 if(defaultView==WEEKLST) viewWeekLst();
169 if(defaultView==MONTH) viewMonth(); 170 if(defaultView==MONTH) viewMonth();
170 171
171 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); 172 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) );
172 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) ); 173 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) );
173 174
174#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 175#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
175 connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), this, SLOT(appMessage(const QCString&,const QByteArray&)) ); 176 connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), this, SLOT(appMessage(const QCString&,const QByteArray&)) );
176#endif 177#endif
177 178
178 // listen on QPE/System 179 // listen on QPE/System
179#if defined(Q_WS_QWS) 180#if defined(Q_WS_QWS)
180#if !defined(QT_NO_COP) 181#if !defined(QT_NO_COP)
181 QCopChannel *channel = new QCopChannel( "QPE/System", this ); 182 QCopChannel *channel = new QCopChannel( "QPE/System", this );
182 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) ); 183 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) );
183 channel = new QCopChannel( "QPE/Datebook", this ); 184 channel = new QCopChannel( "QPE/Datebook", this );
184 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) ); 185 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) );
185#endif 186#endif
186#endif 187#endif
187 188
188 odebug << "done t=" << t.elapsed() << oendl; 189 odebug << "done t=" << t.elapsed() << oendl;
189 190
190 connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); 191 connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) );
191 connect( qApp, SIGNAL( reload()), this, SLOT( reload() ) ); 192 connect( qApp, SIGNAL( reload()), this, SLOT( reload() ) );
192 /* 193 /*
193 * Here is a problem description: 194 * Here is a problem description:
194 * When Weekview is the default view 195 * When Weekview is the default view
195 * a DateBookWeekView get's created 196 * a DateBookWeekView get's created
196 * redraw() get's called. So what? 197 * redraw() get's called. So what?
197 * Remember that we're still in the c'tor 198 * Remember that we're still in the c'tor
198 * and no final layout has happened? Ok 199 * and no final layout has happened? Ok
199 * now all Events get arranged. Their x 200 * now all Events get arranged. Their x
200 * position get's determined by a QHeader 201 * position get's determined by a QHeader
201 * position. But the QHeader isn't layouted or 202 * position. But the QHeader isn't layouted or
202 * at the right position. redraw() is a slot 203 * at the right position. redraw() is a slot
203 * so we'll call it then via a singleShot 204 * so we'll call it then via a singleShot
204 * from view() 205 * from view()
205 */ 206 */
206 if( needEvilHack ){ 207 if( needEvilHack ){
207 QTimer::singleShot( 500, this, SLOT(viewWeek()) ); 208 QTimer::singleShot( 500, this, SLOT(viewWeek()) );
208 } 209 }
209} 210}
210 211
211void DateBook::receive( const QCString &msg, const QByteArray &data ) 212void DateBook::receive( const QCString &msg, const QByteArray &data )
212{ 213{
213 QDataStream stream( data, IO_ReadOnly ); 214 QDataStream stream( data, IO_ReadOnly );
214 if ( msg == "timeChange(QString)" ) { 215 if ( msg == "timeChange(QString)" ) {
215 // update active view! 216 // update active view!
216 if ( dayAction->isOn() ) 217 if ( dayAction->isOn() )
217 viewDay(); 218 viewDay();
218 else if ( weekAction->isOn() ) 219 else if ( weekAction->isOn() )
219 viewWeek(); 220 viewWeek();
220 else if ( monthAction->isOn() ) 221 else if ( monthAction->isOn() )
221 viewMonth(); 222 viewMonth();
222 } 223 }
223 else if (msg == "editEvent(int)") { 224 else if (msg == "editEvent(int)") {
224 int uid; 225 int uid;
225 stream >> uid; 226 stream >> uid;
226 Event e=db->eventByUID(uid); 227 Event e=db->eventByUID(uid);
227 editEvent(e); 228 editEvent(e);
228 }else if (msg == "viewDefault(QDate)"){ 229 }else if (msg == "viewDefault(QDate)"){
229 QDate day; 230 QDate day;
230 stream >> day; 231 stream >> day;
231 viewDefault(day); 232 viewDefault(day);
232 } 233 }
233} 234}
234 235
235DateBook::~DateBook() 236DateBook::~DateBook()
236{ 237{
237 delete db_holiday; 238 delete db_holiday;
238} 239}
239 240
240void DateBook::slotSettings() 241void DateBook::slotSettings()
241{ 242{
242 DateBookSettings frmSettings( ampm, this ); 243 DateBookSettings frmSettings( ampm, this );
243 frmSettings.setStartTime( startTime ); 244 frmSettings.setStartTime( startTime );
244 frmSettings.setAlarmPreset( aPreset, presetTime ); 245 frmSettings.setAlarmPreset( aPreset, presetTime );
245 frmSettings.setJumpToCurTime( bJumpToCurTime ); 246 frmSettings.setJumpToCurTime( bJumpToCurTime );
246 frmSettings.setRowStyle( rowStyle ); 247 frmSettings.setRowStyle( rowStyle );
247 frmSettings.comboDefaultView->setCurrentItem(defaultView-1); 248 frmSettings.comboDefaultView->setCurrentItem(defaultView-1);
248 frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig); 249 frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig);
249 frmSettings.setPluginList(db_holiday->pluginManager(),db_holiday->pluginLoader()); 250 frmSettings.setPluginList(db_holiday->pluginManager(),db_holiday->pluginLoader());
250 251
251 bool found=false; 252 bool found=false;
252 for (int i=0; i<(frmSettings.comboLocation->count()); i++) { 253 for (int i=0; i<(frmSettings.comboLocation->count()); i++) {
253 if ( frmSettings.comboLocation->text(i) == defaultLocation ) { 254 if ( frmSettings.comboLocation->text(i) == defaultLocation ) {
254 frmSettings.comboLocation->setCurrentItem(i); 255 frmSettings.comboLocation->setCurrentItem(i);
255 found=true; 256 found=true;
256 break; 257 break;
257 } 258 }
258 } 259 }
259 if(!found) { 260 if(!found) {
260 frmSettings.comboLocation->insertItem(defaultLocation); 261 frmSettings.comboLocation->insertItem(defaultLocation);
261 frmSettings.comboLocation->setCurrentItem(frmSettings.comboLocation->count()-1); 262 frmSettings.comboLocation->setCurrentItem(frmSettings.comboLocation->count()-1);
262 } 263 }
263 frmSettings.comboCategory->setCategories(defaultCategories,"Calendar", tr("Calendar")); 264 frmSettings.comboCategory->setCategories(defaultCategories,"Calendar", tr("Calendar"));
264 265
265 if ( QPEApplication::execDialog( &frmSettings ) ) { 266 if ( QPEApplication::execDialog( &frmSettings ) ) {
266 frmSettings.savePlugins(); 267 frmSettings.savePlugins();
267 db_holiday->pluginManager()->save(); 268 db_holiday->pluginManager()->save();
268 db_holiday->reloadPlugins(); 269 db_holiday->reloadPlugins();
269 270
270 aPreset = frmSettings.alarmPreset(); 271 aPreset = frmSettings.alarmPreset();
271 presetTime = frmSettings.presetTime(); 272 presetTime = frmSettings.presetTime();
272 startTime = frmSettings.startTime(); 273 startTime = frmSettings.startTime();
273 bJumpToCurTime = frmSettings.jumpToCurTime(); 274 bJumpToCurTime = frmSettings.jumpToCurTime();
274 rowStyle = frmSettings.rowStyle(); 275 rowStyle = frmSettings.rowStyle();
275 defaultView=frmSettings.comboDefaultView->currentItem()+1; 276 defaultView=frmSettings.comboDefaultView->currentItem()+1;
276 weeklistviewconfig=frmSettings.comboWeekListView->currentItem(); 277 weeklistviewconfig=frmSettings.comboWeekListView->currentItem();
277 defaultLocation=frmSettings.comboLocation->currentText(); 278 defaultLocation=frmSettings.comboLocation->currentText();
278 defaultCategories=frmSettings.comboCategory->currentCategories(); 279 defaultCategories=frmSettings.comboCategory->currentCategories();
279 280
280 if ( dayView ) { 281 if ( dayView ) {
281 dayView->setStartViewTime( startTime ); 282 dayView->setStartViewTime( startTime );
282 dayView->setJumpToCurTime( bJumpToCurTime ); 283 dayView->setJumpToCurTime( bJumpToCurTime );
283 dayView->setRowStyle( rowStyle ); 284 dayView->setRowStyle( rowStyle );
284 } 285 }
285 if ( weekView ) { 286 if ( weekView ) {
286 weekView->setStartViewTime( startTime ); 287 weekView->setStartViewTime( startTime );
287 } 288 }
288 saveSettings(); 289 saveSettings();
289 290
290 // make the change obvious 291 // make the change obvious
291 if ( views->visibleWidget() ) { 292 if ( views->visibleWidget() ) {
292 if ( views->visibleWidget() == dayView ) 293 if ( views->visibleWidget() == dayView )
293 dayView->redraw(); 294 dayView->redraw();
294 else if ( views->visibleWidget() == weekView ) 295 else if ( views->visibleWidget() == weekView )
295 weekView->redraw(); 296 weekView->redraw();
296 else if ( views->visibleWidget() == weekLstView ) 297 else if ( views->visibleWidget() == weekLstView )
297 weekLstView->redraw(); 298 weekLstView->redraw();
298 } 299 }
299 } 300 }
300} 301}
301 302
302void DateBook::fileNew() 303void DateBook::fileNew()
303{ 304{
304 slotNewEventFromKey(""); 305 slotNewEventFromKey("");
305} 306}
306 307
307QString DateBook::checkEvent(const Event &e) 308QString DateBook::checkEvent(const Event &e)
308{ 309{
309 /* check if overlaps with itself */ 310 /* check if overlaps with itself */
310 bool checkFailed = FALSE; 311 bool checkFailed = FALSE;
311 312
312 /* check the next 12 repeats. should catch most problems */ 313 /* check the next 12 repeats. should catch most problems */
313 QDate current_date = e.start().date(); 314 QDate current_date = e.start().date();
314 Event previous = e; 315 Event previous = e;
315 for(int i = 0; i < 12; i++) 316 for(int i = 0; i < 12; i++)
316 { 317 {
317 QDateTime next; 318 QDateTime next;
318 if (!nextOccurance(previous, current_date.addDays(1), next)) { 319 if (!nextOccurance(previous, current_date.addDays(1), next)) {
319 break; // no more repeats 320 break; // no more repeats
320 } 321 }
321 if(next < previous.end()) { 322 if(next < previous.end()) {
322 checkFailed = TRUE; 323 checkFailed = TRUE;
323 break; 324 break;
324 } 325 }
325 current_date = next.date(); 326 current_date = next.date();
326 } 327 }
327 328
328 if(checkFailed) 329 if(checkFailed)
329 return tr("Event duration is potentially longer\n" 330 return tr("Event duration is potentially longer\n"
330 "than interval between repeats."); 331 "than interval between repeats.");
331 332
332 return QString::null; 333 return QString::null;
333} 334}
334 335
335QDate DateBook::currentDate() 336QDate DateBook::currentDate()
336{ 337{
337 QDate d = QDate::currentDate(); 338 QDate d = QDate::currentDate();
338 339
339 if ( dayView && views->visibleWidget() == dayView ) { 340 if ( dayView && views->visibleWidget() == dayView ) {
340 d = dayView->date(); 341 d = dayView->date();
341 } else if ( weekView && views->visibleWidget() == weekView ) { 342 } else if ( weekView && views->visibleWidget() == weekView ) {
342 d = weekView->date(); 343 d = weekView->date();
343 } else if ( weekLstView && views->visibleWidget() == weekLstView ) { 344 } else if ( weekLstView && views->visibleWidget() == weekLstView ) {
344 d = weekLstView->date(); 345 d = weekLstView->date();
345 } else if ( monthView && views->visibleWidget() == monthView ) { 346 } else if ( monthView && views->visibleWidget() == monthView ) {
346 d = monthView->selectedDate(); 347 d = monthView->selectedDate();
347 } 348 }
348 349
349 return d; 350 return d;
350} 351}
351 352
352void DateBook::view(int v, const QDate &d) { 353void DateBook::view(int v, const QDate &d) {
353 if (v==DAY) { 354 if (v==DAY) {
354 initDay(); 355 initDay();
355 dayAction->setOn( TRUE ); 356 dayAction->setOn( TRUE );
356 dayView->setDate( d ); 357 dayView->setDate( d );
357 views->raiseWidget( dayView ); 358 views->raiseWidget( dayView );
358 dayView->redraw(); 359 dayView->redraw();
359 } else if (v==WEEK) { 360 } else if (v==WEEK) {
360 initWeek(); 361 initWeek();
361 weekAction->setOn( TRUE ); 362 weekAction->setOn( TRUE );
362 weekView->setDate( d ); 363 weekView->setDate( d );
363 views->raiseWidget( weekView ); 364 views->raiseWidget( weekView );
364 weekView->redraw(); 365 weekView->redraw();
365 } else if (v==WEEKLST) { 366 } else if (v==WEEKLST) {
366 initWeekLst(); 367 initWeekLst();
367 weekLstAction->setOn( TRUE ); 368 weekLstAction->setOn( TRUE );
368 weekLstView->setDate(d); 369 weekLstView->setDate(d);
369 views->raiseWidget( weekLstView ); 370 views->raiseWidget( weekLstView );
370 weekLstView->redraw(); 371 weekLstView->redraw();
371 } else if (v==MONTH) { 372 } else if (v==MONTH) {
372 initMonth(); 373 initMonth();
373 monthAction->setOn( TRUE ); 374 monthAction->setOn( TRUE );
374 monthView->setDate( d.year(), d.month(), d.day() ); 375 monthView->setDate( d.year(), d.month(), d.day() );
375 views->raiseWidget( monthView ); 376 views->raiseWidget( monthView );
376 monthView->redraw(); 377 monthView->redraw();
377 } 378 }
378} 379}
379 380
380void DateBook::viewDefault(const QDate &d) { 381void DateBook::viewDefault(const QDate &d) {
381 view(defaultView,d); 382 view(defaultView,d);
382} 383}
383 384
384void DateBook::viewDay() { 385void DateBook::viewDay() {
385 view(DAY,currentDate()); 386 view(DAY,currentDate());
386} 387}
387 388
388void DateBook::viewWeek() { 389void DateBook::viewWeek() {
389 view(WEEK,currentDate()); 390 view(WEEK,currentDate());
390} 391}
391 392
392void DateBook::viewWeekLst() { 393void DateBook::viewWeekLst() {
393 view(WEEKLST,currentDate()); 394 view(WEEKLST,currentDate());
394} 395}
395 396
396void DateBook::viewMonth() { 397void DateBook::viewMonth() {
397 view(MONTH,currentDate()); 398 view(MONTH,currentDate());
398} 399}
399 400
400void DateBook::insertEvent( const Event &e ) 401void DateBook::insertEvent( const Event &e )
401{ 402{
402 Event dupEvent=e; 403 Event dupEvent=e;
403 if(!dupEvent.isValidUid() ) // tkcRom seems to be different 404 if(!dupEvent.isValidUid() ) // tkcRom seems to be different
404 dupEvent.assignUid(); 405 dupEvent.assignUid();
405 dupEvent.setLocation(defaultLocation); 406 dupEvent.setLocation(defaultLocation);
406 dupEvent.setCategories(defaultCategories); 407 dupEvent.setCategories(defaultCategories);
407 db->addEvent(dupEvent); 408 db->addEvent(dupEvent);
408 emit newEvent(); 409 emit newEvent();
409} 410}
410 411
411void DateBook::duplicateEvent( const Event &e ) 412void DateBook::duplicateEvent( const Event &e )
412{ 413{
413 // Alot of code duplication, as this is almost like editEvent(); 414 // Alot of code duplication, as this is almost like editEvent();
414 if (syncing) { 415 if (syncing) {
415 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); 416 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
416 return; 417 return;
417 } 418 }
418 419
419 Event dupevent(e); // Make a duplicate. 420 Event dupevent(e); // Make a duplicate.
420 421
421 // workaround added for text input. 422 // workaround added for text input.
422 QDialog editDlg( this, 0, TRUE ); 423 QDialog editDlg( this, 0, TRUE );
423 DateEntry *entry; 424 DateEntry *entry;
424 editDlg.setCaption( tr("Duplicate Event") ); 425 editDlg.setCaption( tr("Duplicate Event") );
425 QVBoxLayout *vb = new QVBoxLayout( &editDlg ); 426 QVBoxLayout *vb = new QVBoxLayout( &editDlg );
426 QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); 427 QScrollView *sv = new QScrollView( &editDlg, "scrollview" );
427 sv->setResizePolicy( QScrollView::AutoOneFit ); 428 sv->setResizePolicy( QScrollView::AutoOneFit );
428 // KLUDGE!!! 429 // KLUDGE!!!
429 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 430 sv->setHScrollBarMode( QScrollView::AlwaysOff );
430 vb->addWidget( sv ); 431 vb->addWidget( sv );
431 entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" ); 432 entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" );
432 entry->timezone->setEnabled( FALSE ); 433 entry->timezone->setEnabled( FALSE );
433 sv->addChild( entry ); 434 sv->addChild( entry );
434 435
435 while ( QPEApplication::execDialog( &editDlg ) ) { 436 while ( QPEApplication::execDialog( &editDlg ) ) {
436 Event newEv = entry->event(); 437 Event newEv = entry->event();
437 QString error = checkEvent(newEv); 438 QString error = checkEvent(newEv);
438 if (!error.isNull()) { 439 if (!error.isNull()) {
439 if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) 440 if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0)
440 continue; 441 continue;
441 } 442 }
442 /* 443 /*
443 * The problem: 444 * The problem:
444 * DateBookDB does remove repeating events not by uid but by the time 445 * DateBookDB does remove repeating events not by uid but by the time
445 * the recurrence was created 446 * the recurrence was created
446 * so we need to update that time as well 447 * so we need to update that time as well
447 */ 448 */
448 Event::RepeatPattern rp = newEv.repeatPattern(); 449 Event::RepeatPattern rp = newEv.repeatPattern();
449 rp.createTime = ::time( NULL ); 450 rp.createTime = ::time( NULL );
450 newEv.setRepeat( TRUE, rp ); // has repeat and repeatPattern... 451 newEv.setRepeat( TRUE, rp ); // has repeat and repeatPattern...
451 if( newEv.uid() == e.uid() || !newEv.isValidUid() ) 452 if( newEv.uid() == e.uid() || !newEv.isValidUid() )
452 newEv.assignUid(); 453 newEv.assignUid();
453 454
454 db->addEvent(newEv); 455 db->addEvent(newEv);
455 emit newEvent(); 456 emit newEvent();
456 break; 457 break;
457 } 458 }
458} 459}
459 460
460void DateBook::editEvent( const Event &e ) 461void DateBook::editEvent( const Event &e )
461{ 462{
462 if (syncing) { 463 if (syncing) {
463 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); 464 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
464 return; 465 return;
465 } 466 }
466 467
467 // workaround added for text input. 468 // workaround added for text input.
468 QDialog editDlg( this, 0, TRUE ); 469 QDialog editDlg( this, 0, TRUE );
469 DateEntry *entry; 470 DateEntry *entry;
470 editDlg.setCaption( tr("Edit Event") ); 471 editDlg.setCaption( tr("Edit Event") );
471 QVBoxLayout *vb = new QVBoxLayout( &editDlg ); 472 QVBoxLayout *vb = new QVBoxLayout( &editDlg );
472 QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); 473 QScrollView *sv = new QScrollView( &editDlg, "scrollview" );
473 sv->setResizePolicy( QScrollView::AutoOneFit ); 474 sv->setResizePolicy( QScrollView::AutoOneFit );
474 // KLUDGE!!! 475 // KLUDGE!!!
475 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 476 sv->setHScrollBarMode( QScrollView::AlwaysOff );
476 vb->addWidget( sv ); 477 vb->addWidget( sv );
477 entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" ); 478 entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" );
478 entry->timezone->setEnabled( FALSE ); 479 entry->timezone->setEnabled( FALSE );
479 sv->addChild( entry ); 480 sv->addChild( entry );
480 481
481 while ( QPEApplication::execDialog( &editDlg ) ) { 482 while ( QPEApplication::execDialog( &editDlg ) ) {
482 Event newEv = entry->event(); 483 Event newEv = entry->event();
483 if(newEv.description().isEmpty() && newEv.notes().isEmpty() ) 484 if(newEv.description().isEmpty() && newEv.notes().isEmpty() )
484 break; 485 break;
485 newEv.setUid(e.uid()); // FIXME: Hack not to clear uid 486 newEv.setUid(e.uid()); // FIXME: Hack not to clear uid
486 QString error = checkEvent(newEv); 487 QString error = checkEvent(newEv);
487 if (!error.isNull()) { 488 if (!error.isNull()) {
488 if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) continue; 489 if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) continue;
489 } 490 }
490 db->editEvent(e, newEv); 491 db->editEvent(e, newEv);
491 emit newEvent(); 492 emit newEvent();
492 break; 493 break;
493 } 494 }
494} 495}
495 496
496void DateBook::removeEvent( const Event &e ) 497void DateBook::removeEvent( const Event &e )
497{ 498{
498 if (syncing) { 499 if (syncing) {
499 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); 500 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
500 return; 501 return;
501 } 502 }
502 503
503 QString strName = e.description(); 504 QString strName = e.description();
504 505
505 if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) 506 if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) )
506 return; 507 return;
507 508
508 db->removeEvent( e ); 509 db->removeEvent( e );
509 if ( views->visibleWidget() == dayView && dayView ) 510 if ( views->visibleWidget() == dayView && dayView )
510 dayView->redraw(); 511 dayView->redraw();
511 512
512} 513}
513 514
514void DateBook::addEvent( const Event &e ) 515void DateBook::addEvent( const Event &e )
515{ 516{
516 QDate d = e.start().date(); 517 QDate d = e.start().date();
517 initDay(); 518 initDay();
518 dayView->setDate( d ); 519 dayView->setDate( d );
519} 520}
520 521
521void DateBook::showDay( int year, int month, int day ) 522void DateBook::showDay( int year, int month, int day )
522{ 523{
523 QDate d(year, month, day); 524 QDate d(year, month, day);
524 view(DAY,d); 525 view(DAY,d);
525} 526}
526 527
527void DateBook::initDay() 528void DateBook::initDay()
528{ 529{
529 if ( !dayView ) { 530 if ( !dayView ) {
530 dayView = new DateBookDay( ampm, onMonday, db, db_holiday, views, "day view" ); 531 dayView = new DateBookDay( ampm, onMonday, db, db_holiday, views, "day view" );
531 views->addWidget( dayView, DAY ); 532 views->addWidget( dayView, DAY );
532 dayView->setJumpToCurTime( bJumpToCurTime ); 533 dayView->setJumpToCurTime( bJumpToCurTime );
533 dayView->setStartViewTime( startTime ); 534 dayView->setStartViewTime( startTime );
534 dayView->setRowStyle( rowStyle ); 535 dayView->setRowStyle( rowStyle );
535 connect( this, SIGNAL( newEvent() ), dayView, SLOT( redraw() ) ); 536 connect( this, SIGNAL( newEvent() ), dayView, SLOT( redraw() ) );
536 connect( dayView, SIGNAL( newEvent() ), this, SLOT( fileNew() ) ); 537 connect( dayView, SIGNAL( newEvent() ), this, SLOT( fileNew() ) );
537 connect( dayView, SIGNAL( removeEvent(const Event&) ), this, SLOT( removeEvent(const Event&) ) ); 538 connect( dayView, SIGNAL( removeEvent(const Event&) ), this, SLOT( removeEvent(const Event&) ) );
538 connect( dayView, SIGNAL( editEvent(const Event&) ), this, SLOT( editEvent(const Event&) ) ); 539 connect( dayView, SIGNAL( editEvent(const Event&) ), this, SLOT( editEvent(const Event&) ) );
539 connect( dayView, SIGNAL( duplicateEvent(const Event&) ), this, SLOT( duplicateEvent(const Event&) ) ); 540 connect( dayView, SIGNAL( duplicateEvent(const Event&) ), this, SLOT( duplicateEvent(const Event&) ) );
540 connect( dayView, SIGNAL( beamEvent(const Event&) ), this, SLOT( beamEvent(const Event&) ) ); 541 connect( dayView, SIGNAL( beamEvent(const Event&) ), this, SLOT( beamEvent(const Event&) ) );
541 connect( dayView, SIGNAL(sigNewEvent(const QString&)), this, SLOT(slotNewEventFromKey(const QString&)) ); 542 connect( dayView, SIGNAL(sigNewEvent(const QString&)), this, SLOT(slotNewEventFromKey(const QString&)) );
542 } 543 }
543} 544}
544 545
545void DateBook::initWeek() 546void DateBook::initWeek()
546{ 547{
547 if ( !weekView ) { 548 if ( !weekView ) {
548 weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); 549 weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" );
549 weekView->setStartViewTime( startTime ); 550 weekView->setStartViewTime( startTime );
550 views->addWidget( weekView, WEEK ); 551 views->addWidget( weekView, WEEK );
551 connect( weekView, SIGNAL( showDate(int,int,int) ), this, SLOT( showDay(int,int,int) ) ); 552 connect( weekView, SIGNAL( showDate(int,int,int) ), this, SLOT( showDay(int,int,int) ) );
552 connect( this, SIGNAL( newEvent() ), weekView, SLOT( redraw() ) ); 553 connect( this, SIGNAL( newEvent() ), weekView, SLOT( redraw() ) );
553 } 554 }
554 555
555 //But also get it right: the year that we display can be different 556 //But also get it right: the year that we display can be different
556 //from the year of the current date. So, first find the year 557 //from the year of the current date. So, first find the year
557 //number of the current week. 558 //number of the current week.
558 int yearNumber, totWeeks; 559 int yearNumber, totWeeks;
559 calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); 560 calcWeek( currentDate(), totWeeks, yearNumber, onMonday );
560 561
561 QDate d = QDate( yearNumber, 12, 31 ); 562 QDate d = QDate( yearNumber, 12, 31 );
562 calcWeek( d, totWeeks, yearNumber, onMonday ); 563 calcWeek( d, totWeeks, yearNumber, onMonday );
563 564
564 while ( totWeeks == 1 ) { 565 while ( totWeeks == 1 ) {
565 d = d.addDays( -1 ); 566 d = d.addDays( -1 );
566 calcWeek( d, totWeeks, yearNumber, onMonday ); 567 calcWeek( d, totWeeks, yearNumber, onMonday );
567 } 568 }
568} 569}
569 570
570void DateBook::initWeekLst() { 571void DateBook::initWeekLst() {
571 if ( !weekLstView ) { 572 if ( !weekLstView ) {
572 weekLstView = new DateBookWeekLst( ampm, onMonday, db, views, "weeklst view" ); 573 weekLstView = new DateBookWeekLst( ampm, onMonday, db, views, "weeklst view" );
573 views->addWidget( weekLstView, WEEKLST ); 574 views->addWidget( weekLstView, WEEKLST );
574 575
575 //weekLstView->setStartViewTime( startTime ); 576 //weekLstView->setStartViewTime( startTime );
576 connect( weekLstView, SIGNAL( showDate(int,int,int) ), this, SLOT( showDay(int,int,int) ) ); 577 connect( weekLstView, SIGNAL( showDate(int,int,int) ), this, SLOT( showDay(int,int,int) ) );
577 connect( weekLstView, SIGNAL( addEvent(const QDateTime&,const QDateTime&,const QString&, const QString&) ), 578 connect( weekLstView, SIGNAL( addEvent(const QDateTime&,const QDateTime&,const QString&, const QString&) ),
578 this, SLOT( slotNewEntry(const QDateTime&,const QDateTime&,const QString&, const QString&) ) ); 579 this, SLOT( slotNewEntry(const QDateTime&,const QDateTime&,const QString&, const QString&) ) );
579 connect( this, SIGNAL( newEvent() ), weekLstView, SLOT( redraw() ) ); 580 connect( this, SIGNAL( newEvent() ), weekLstView, SLOT( redraw() ) );
580 connect( weekLstView, SIGNAL( editEvent(const Event&) ), this, SLOT( editEvent(const Event&) ) ); 581 connect( weekLstView, SIGNAL( editEvent(const Event&) ), this, SLOT( editEvent(const Event&) ) );
581 connect( weekLstView, SIGNAL( duplicateEvent( const Event & ) ), this, SLOT( duplicateEvent( const Event & ) ) ); 582 connect( weekLstView, SIGNAL( duplicateEvent( const Event & ) ), this, SLOT( duplicateEvent( const Event & ) ) );
582 connect( weekLstView, SIGNAL( beamEvent(const Event&) ), this, SLOT( beamEvent(const Event&) ) ); 583 connect( weekLstView, SIGNAL( beamEvent(const Event&) ), this, SLOT( beamEvent(const Event&) ) );
583 connect( weekLstView, SIGNAL( removeEvent( const Event & ) ), this, SLOT( removeEvent( const Event & ) ) ); 584 connect( weekLstView, SIGNAL( removeEvent( const Event & ) ), this, SLOT( removeEvent( const Event & ) ) );
584 } 585 }
585} 586}
586 587
587 588
588void DateBook::initMonth() 589void DateBook::initMonth()
589{ 590{
590 if ( !monthView ) { 591 if ( !monthView ) {
591 monthView = new DateBookMonth( views, "month view", FALSE, db ); 592 monthView = new DateBookMonth( views, "month view", FALSE, db );
592 views->addWidget( monthView, MONTH ); 593 views->addWidget( monthView, MONTH );
593 connect( monthView, SIGNAL( dateClicked(int,int,int) ), this, SLOT( showDay(int,int,int) ) ); 594 connect( monthView, SIGNAL( dateClicked(int,int,int) ), this, SLOT( showDay(int,int,int) ) );
594 connect( this, SIGNAL( newEvent() ), monthView, SLOT( redraw() ) ); 595 connect( this, SIGNAL( newEvent() ), monthView, SLOT( redraw() ) );
595 qApp->processEvents(); 596 qApp->processEvents();
596 } 597 }
597} 598}
598 599
599void DateBook::loadSettings() 600void DateBook::loadSettings()
600{ 601{
601 Config qpeconfig( "qpe" ); 602 Config qpeconfig( "qpe" );
602 qpeconfig.setGroup("Time"); 603 qpeconfig.setGroup("Time");
603 ampm = qpeconfig.readBoolEntry( "AMPM", TRUE ); 604 ampm = qpeconfig.readBoolEntry( "AMPM", TRUE );
604 onMonday = qpeconfig.readBoolEntry( "MONDAY" ); 605 onMonday = qpeconfig.readBoolEntry( "MONDAY" );
605 606
606 Config config("DateBook"); 607 Config config("DateBook");
607 config.setGroup("Main"); 608 config.setGroup("Main");
608 startTime = config.readNumEntry("startviewtime", 8); 609 startTime = config.readNumEntry("startviewtime", 8);
609 aPreset = config.readBoolEntry("alarmpreset"); 610 aPreset = config.readBoolEntry("alarmpreset");
610 presetTime = config.readNumEntry("presettime"); 611 presetTime = config.readNumEntry("presettime");
611 bJumpToCurTime = config.readBoolEntry("jumptocurtime"); 612 bJumpToCurTime = config.readBoolEntry("jumptocurtime");
612 rowStyle = config.readNumEntry("rowstyle"); 613 rowStyle = config.readNumEntry("rowstyle");
613 defaultView = config.readNumEntry("defaultview",DAY); 614 defaultView = config.readNumEntry("defaultview",DAY);
614 weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL); 615 weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL);
615 616
616 defaultLocation=config.readEntry("defaultLocation"); 617 defaultLocation=config.readEntry("defaultLocation");
617 QString tmpString=config.readEntry("defaultCategories"); 618 QString tmpString=config.readEntry("defaultCategories");
618 QStringList tmpStringList=QStringList::split(",",tmpString); 619 QStringList tmpStringList=QStringList::split(",",tmpString);
619 defaultCategories.truncate(0); 620 defaultCategories.truncate(0);
620 621
621 for( QStringList::Iterator i=tmpStringList.begin(); i!=tmpStringList.end(); i++) { 622 for( QStringList::Iterator i=tmpStringList.begin(); i!=tmpStringList.end(); i++) {
622 defaultCategories.resize(defaultCategories.count()+1); 623 defaultCategories.resize(defaultCategories.count()+1);
623 defaultCategories[defaultCategories.count()-1]=(*i).toInt(); 624 defaultCategories[defaultCategories.count()-1]=(*i).toInt();
624 } 625 }
625} 626}
626 627
627void DateBook::saveSettings() 628void DateBook::saveSettings()
628{ 629{
629 Config config( "qpe" ); 630 Config config( "qpe" );
630 Config configDB( "DateBook" ); 631 Config configDB( "DateBook" );
631 configDB.setGroup( "Main" ); 632 configDB.setGroup( "Main" );
632 configDB.writeEntry("startviewtime",startTime); 633 configDB.writeEntry("startviewtime",startTime);
633 configDB.writeEntry("alarmpreset",aPreset); 634 configDB.writeEntry("alarmpreset",aPreset);
634 configDB.writeEntry("presettime",presetTime); 635 configDB.writeEntry("presettime",presetTime);
635 configDB.writeEntry("jumptocurtime", bJumpToCurTime); 636 configDB.writeEntry("jumptocurtime", bJumpToCurTime);
636 configDB.writeEntry("rowstyle", rowStyle); 637 configDB.writeEntry("rowstyle", rowStyle);
637 configDB.writeEntry("defaultview",defaultView); 638 configDB.writeEntry("defaultview",defaultView);
638 configDB.writeEntry("weeklistviewconfig",weeklistviewconfig); 639 configDB.writeEntry("weeklistviewconfig",weeklistviewconfig);
639 640
640 configDB.writeEntry("defaultLocation",defaultLocation); 641 configDB.writeEntry("defaultLocation",defaultLocation);
641 QStringList tmpStringList; 642 QStringList tmpStringList;
642 for( uint i=0; i<defaultCategories.count(); i++) { 643 for( uint i=0; i<defaultCategories.count(); i++) {
643 tmpStringList << QString::number(defaultCategories[i]); 644 tmpStringList << QString::number(defaultCategories[i]);
644 } 645 }
645 configDB.writeEntry("defaultCategories",tmpStringList.join(",")); 646 configDB.writeEntry("defaultCategories",tmpStringList.join(","));
646} 647}
647 648
648void DateBook::appMessage(const QCString& msg, const QByteArray& data) 649void DateBook::appMessage(const QCString& msg, const QByteArray& data)
649{ 650{
650 bool needShow = FALSE; 651 bool needShow = FALSE;
651 if ( msg == "alarm(QDateTime,int)" ) { 652 if ( msg == "alarm(QDateTime,int)" ) {
652 QDataStream ds(data,IO_ReadOnly); 653 QDataStream ds(data,IO_ReadOnly);
653 QDateTime when; int warn; 654 QDateTime when; int warn;
654 ds >> when >> warn; 655 ds >> when >> warn;
655 656
656 // check to make it's okay to continue, 657 // check to make it's okay to continue,
657 // this is the case that the time was set ahead, and 658 // this is the case that the time was set ahead, and
658 // we are forced given a stale alarm... 659 // we are forced given a stale alarm...
659 QDateTime current = QDateTime::currentDateTime(); 660 QDateTime current = QDateTime::currentDateTime();
660 if ( current.time().hour() != when.time().hour() && current.time().minute() != when.time().minute() ) 661 if ( current.time().hour() != when.time().hour() && current.time().minute() != when.time().minute() )
661 return; 662 return;
662 663
663 QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60)); 664 QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60));
664 if ( list.count() > 0 ) { 665 if ( list.count() > 0 ) {
665 QString msg; 666 QString msg;
666 bool bSound = FALSE; 667 bool bSound = FALSE;
667 int stopTimer = 0; 668 int stopTimer = 0;
668 bool found = FALSE; 669 bool found = FALSE;
669 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) { 670 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) {
670 if ( (*it).event().hasAlarm() ) { 671 if ( (*it).event().hasAlarm() ) {
671 found = TRUE; 672 found = TRUE;
672 msg += "<CENTER><B>" + (*it).description() + "</B>" 673 msg += "<CENTER><B>" + (*it).description() + "</B>"
673 + "<BR>" + (*it).location() + "<BR>" 674 + "<BR>" + (*it).location() + "<BR>"
674 + TimeString::dateString((*it).event().start(),ampm) 675 + TimeString::dateString((*it).event().start(),ampm)
675 + (warn 676 + (warn
676 ? tr(" (in " + QString::number(warn) 677 ? tr(" (in " + QString::number(warn)
677 + tr(" minutes)")) 678 + tr(" minutes)"))
678 : QString("")) 679 : QString(""))
679 + "<BR>" 680 + "<BR>"
680 + (*it).notes() + "</CENTER>"; 681 + (*it).notes() + "</CENTER>";
681 if ( (*it).event().alarmSound() != Event::Silent ) { 682 if ( (*it).event().alarmSound() != Event::Silent ) {
682 bSound = TRUE; 683 bSound = TRUE;
683 } 684 }
684 } 685 }
685 } 686 }
686 if ( found ) { 687 if ( found ) {
687 if ( bSound ) { 688 if ( bSound ) {
688 Sound::soundAlarm(); 689 Sound::soundAlarm();
689 alarmCounter = 0; 690 alarmCounter = 0;
690 stopTimer = startTimer( 5000 ); 691 stopTimer = startTimer( 5000 );
691 } 692 }
692 QDialog dlg( this, 0, TRUE ); 693 QDialog dlg( this, 0, TRUE );
693 QVBoxLayout *vb = new QVBoxLayout( &dlg ); 694 QVBoxLayout *vb = new QVBoxLayout( &dlg );
694 QScrollView *view = new QScrollView( &dlg, "scrollView"); 695 QScrollView *view = new QScrollView( &dlg, "scrollView");
695 view->setResizePolicy( QScrollView::AutoOneFit ); 696 view->setResizePolicy( QScrollView::AutoOneFit );
696 vb->addWidget( view ); 697 vb->addWidget( view );
697 QLabel *lblMsg = new QLabel( msg, &dlg ); 698 QLabel *lblMsg = new QLabel( msg, &dlg );
698 view->addChild( lblMsg ); 699 view->addChild( lblMsg );
699 QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg ); 700 QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg );
700 connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) ); 701 connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) );
701 vb->addWidget( cmdOk ); 702 vb->addWidget( cmdOk );
702 703
703 needShow = QPEApplication::execDialog( &dlg ); 704 needShow = QPEApplication::execDialog( &dlg );
704 705
705 if ( bSound ) 706 if ( bSound )
706 killTimer( stopTimer ); 707 killTimer( stopTimer );
707 } 708 }
708 } 709 }
709 } else if ( msg == "nextView()" ) { 710 } else if ( msg == "nextView()" ) {
710 needShow = true; 711 needShow = true;
711 if ( !qApp-> activeWindow ( )) { 712 if ( !qApp-> activeWindow ( )) {
712 needShow = TRUE; 713 needShow = TRUE;
713 } else { 714 } else {
714 QWidget* cur = views->visibleWidget(); 715 QWidget* cur = views->visibleWidget();
715 if ( cur ) { 716 if ( cur ) {
716 if ( cur == dayView ) 717 if ( cur == dayView )
717 viewWeek(); 718 viewWeek();
718 else if ( cur == weekView ) 719 else if ( cur == weekView )
719 viewWeekLst(); 720 viewWeekLst();
720 else if ( cur == weekLstView ) 721 else if ( cur == weekLstView )
721 viewMonth(); 722 viewMonth();
722 else if ( cur == monthView ) 723 else if ( cur == monthView )
723 viewDay(); 724 viewDay();
724 needShow = TRUE; 725 needShow = TRUE;
725 } 726 }
726 } 727 }
727 } else if (msg == "editEvent(int)") { 728 } else if (msg == "editEvent(int)") {
728 /* simple copy from receive */ 729 /* simple copy from receive */
729 QDataStream stream(data,IO_ReadOnly); 730 QDataStream stream(data,IO_ReadOnly);
730 int uid; 731 int uid;
731 stream >> uid; 732 stream >> uid;
732 Event e=db->eventByUID(uid); 733 Event e=db->eventByUID(uid);
733 editEvent(e); 734 editEvent(e);
734 } else if (msg == "viewDefault(QDate)"){ 735 } else if (msg == "viewDefault(QDate)"){
735 /* simple copy from receive */ 736 /* simple copy from receive */
736 QDataStream stream(data,IO_ReadOnly); 737 QDataStream stream(data,IO_ReadOnly);
737 QDate day; 738 QDate day;
738 stream >> day; 739 stream >> day;
739 viewDefault(day); 740 viewDefault(day);
740 needShow = true; 741 needShow = true;
741 } 742 }
742 743
743 if ( needShow ) { 744 if ( needShow ) {
744#if defined(Q_WS_QWS) || defined(_WS_QWS_) 745#if defined(Q_WS_QWS) || defined(_WS_QWS_)
745// showMaximized(); 746// showMaximized();
746#else 747#else
747// show(); 748// show();
748#endif 749#endif
749// raise(); 750// raise();
750 QPEApplication::setKeepRunning(); 751 QPEApplication::setKeepRunning();
751// setActiveWindow(); 752// setActiveWindow();
752 } 753 }
753} 754}
754 755
755void DateBook::reload() 756void DateBook::reload()
756{ 757{
757 db->reload(); 758 db->reload();
758 if ( dayAction->isOn() ) viewDay(); 759 if ( dayAction->isOn() ) viewDay();
759 else if ( weekAction->isOn() ) viewWeek(); 760 else if ( weekAction->isOn() ) viewWeek();
760 else if ( monthAction->isOn() ) viewMonth(); 761 else if ( monthAction->isOn() ) viewMonth();
761 syncing = FALSE; 762 syncing = FALSE;
762} 763}
763 764
764void DateBook::flush() 765void DateBook::flush()
765{ 766{
766 syncing = TRUE; 767 syncing = TRUE;
767 db->save(); 768 db->save();
768} 769}
769 770
770void DateBook::timerEvent( QTimerEvent *e ) 771void DateBook::timerEvent( QTimerEvent *e )
771{ 772{
772 if ( alarmCounter < 10 ) { 773 if ( alarmCounter < 10 ) {
773 alarmCounter++; 774 alarmCounter++;
774 Sound::soundAlarm(); 775 Sound::soundAlarm();
775 } else { 776 } else {
776 killTimer( e->timerId() ); 777 killTimer( e->timerId() );
777 } 778 }
778} 779}
779 780
780void DateBook::changeClock( bool newClock ) 781void DateBook::changeClock( bool newClock )
781{ 782{
782 ampm = newClock; 783 ampm = newClock;
783 // repaint the affected objects... 784 // repaint the affected objects...
784 if (dayView) dayView->redraw(); 785 if (dayView) dayView->redraw();
785 if (weekView) weekView->redraw(); 786 if (weekView) weekView->redraw();
786 if (weekLstView) weekLstView->redraw(); 787 if (weekLstView) weekLstView->redraw();
787} 788}
788 789
789void DateBook::changeWeek( bool m ) 790void DateBook::changeWeek( bool m )
790{ 791{
791 /* no need to redraw, each widget catches. Do need to 792 /* no need to redraw, each widget catches. Do need to
792 store though for widgets we haven't made yet */ 793 store though for widgets we haven't made yet */
793 onMonday = m; 794 onMonday = m;
794} 795}
795 796
796void DateBook::slotToday() 797void DateBook::slotToday()
797{ 798{
798 // we need to view today using default view 799 // we need to view today using default view
799 view(defaultView,QDate::currentDate()); 800 view(defaultView,QDate::currentDate());
800} 801}
801 802
802void DateBook::closeEvent( QCloseEvent *e ) 803void DateBook::closeEvent( QCloseEvent *e )
803{ 804{
804 if(syncing) { 805 if(syncing) {
805 /* no need to save, did that at flush */ 806 /* no need to save, did that at flush */
806 e->accept(); 807 e->accept();
807 return; 808 return;
808 } 809 }
809 810
810 // save settings will generate it's own error messages, no 811 // save settings will generate it's own error messages, no
811 // need to do checking ourselves. 812 // need to do checking ourselves.
812 saveSettings(); 813 saveSettings();
813 if ( db->save() ) { 814 if ( db->save() ) {
814 e->accept(); 815 e->accept();
815 } else { 816 } else {
816 if ( QMessageBox::critical( this, tr( "Out of space" ), 817 if ( QMessageBox::critical( this, tr( "Out of space" ),
817 tr("Calendar was unable to save\n" 818 tr("Calendar was unable to save\n"
818 "your changes.\n" 819 "your changes.\n"
819 "Free up some space and try again.\n" 820 "Free up some space and try again.\n"
820 "\nQuit anyway?"), 821 "\nQuit anyway?"),
821 QMessageBox::Yes|QMessageBox::Escape, 822 QMessageBox::Yes|QMessageBox::Escape,
822 QMessageBox::No|QMessageBox::Default ) 823 QMessageBox::No|QMessageBox::Default )
823 != QMessageBox::No ) 824 != QMessageBox::No )
824 e->accept(); 825 e->accept();
825 else 826 else
826 e->ignore(); 827 e->ignore();
827 } 828 }
828} 829}
829 830
830// Entering directly from the "keyboard" 831// Entering directly from the "keyboard"
831void DateBook::slotNewEventFromKey( const QString &str ) 832void DateBook::slotNewEventFromKey( const QString &str )
832{ 833{
833 if (syncing) { 834 if (syncing) {
834 QMessageBox::warning( this, tr("Calendar"), 835 QMessageBox::warning( this, tr("Calendar"),
835 tr( "Can not edit data, currently syncing") ); 836 tr( "Can not edit data, currently syncing") );
836 return; 837 return;
837 } 838 }
838 839
839 // We get to here from a key pressed in the Day View 840 // We get to here from a key pressed in the Day View
840 // So we can assume some things. We want the string 841 // So we can assume some things. We want the string
841 // passed in to be part of the description. 842 // passed in to be part of the description.
842 QDateTime start, end; 843 QDateTime start, end;
843 if ( views->visibleWidget() == dayView ) { 844 if ( views->visibleWidget() == dayView ) {
844 dayView->selectedDates( start, end ); 845 dayView->selectedDates( start, end );
845 } else if ( views->visibleWidget() == monthView ) { 846 } else if ( views->visibleWidget() == monthView ) {
846 QDate d = monthView->selectedDate(); 847 QDate d = monthView->selectedDate();
847 start = end = d; 848 start = end = d;
848 start.setTime( QTime( 10, 0 ) ); 849 start.setTime( QTime( 10, 0 ) );
849 end.setTime( QTime( 12, 0 ) ); 850 end.setTime( QTime( 12, 0 ) );
850 } else if ( views->visibleWidget() == weekView ) { 851 } else if ( views->visibleWidget() == weekView ) {
851 QDate d = weekView->date(); 852 QDate d = weekView->date();
852 start = end = d; 853 start = end = d;
853 start.setTime( QTime( 10, 0 ) ); 854 start.setTime( QTime( 10, 0 ) );
854 end.setTime( QTime( 12, 0 ) ); 855 end.setTime( QTime( 12, 0 ) );
855 } else if ( views->visibleWidget() == weekLstView ) { 856 } else if ( views->visibleWidget() == weekLstView ) {
856 QDate d = weekLstView->date(); 857 QDate d = weekLstView->date();
857 start = end = d; 858 start = end = d;
858 start.setTime( QTime( 10, 0 ) ); 859 start.setTime( QTime( 10, 0 ) );
859 end.setTime( QTime( 12, 0 ) ); 860 end.setTime( QTime( 12, 0 ) );
860 } 861 }
861 slotNewEntry(start, end, str); 862 slotNewEntry(start, end, str);
862} 863}
863void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location) { 864void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location) {
864 // argh! This really needs to be encapsulated in a class 865 // argh! This really needs to be encapsulated in a class
865 // or function. 866 // or function.
866 QDialog newDlg( this, 0, TRUE ); 867 QDialog newDlg( this, 0, TRUE );
867 newDlg.setCaption( DateEntryBase::tr("New Event") ); 868 newDlg.setCaption( DateEntryBase::tr("New Event") );
868 DateEntry *e; 869 DateEntry *e;
869 QVBoxLayout *vb = new QVBoxLayout( &newDlg ); 870 QVBoxLayout *vb = new QVBoxLayout( &newDlg );
870 QScrollView *sv = new QScrollView( &newDlg ); 871 QScrollView *sv = new QScrollView( &newDlg );
871 sv->setResizePolicy( QScrollView::AutoOneFit ); 872 sv->setResizePolicy( QScrollView::AutoOneFit );
872 sv->setFrameStyle( QFrame::NoFrame ); 873 sv->setFrameStyle( QFrame::NoFrame );
873 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 874 sv->setHScrollBarMode( QScrollView::AlwaysOff );
874 vb->addWidget( sv ); 875 vb->addWidget( sv );
875 876
876 Event ev; 877 Event ev;
877 ev.setDescription( str ); 878 ev.setDescription( str );
878 // When the new gui comes in, change this... 879 // When the new gui comes in, change this...
879 if(location==0) { 880 if(location==0) {
880 if(defaultLocation.isEmpty()) { 881 if(defaultLocation.isEmpty()) {
881 ev.setLocation(tr("(Unknown)")); 882 ev.setLocation(tr("(Unknown)"));
882 } else { 883 } else {
883 ev.setLocation( defaultLocation ); 884 ev.setLocation( defaultLocation );
884 } 885 }
885 } else { 886 } else {
886 ev.setLocation(location); 887 ev.setLocation(location);
887 } 888 }
888 ev.setCategories(defaultCategories); 889 ev.setCategories(defaultCategories);
889 ev.setStart( start ); 890 ev.setStart( start );
890 ev.setEnd( end ); 891 ev.setEnd( end );
891 892
892 e = new DateEntry( onMonday, ev, ampm, &newDlg ); 893 e = new DateEntry( onMonday, ev, ampm, &newDlg );
893 e->setAlarmEnabled( aPreset, presetTime, Event::Loud ); 894 e->setAlarmEnabled( aPreset, presetTime, Event::Loud );
894 sv->addChild( e ); 895 sv->addChild( e );
895 while ( QPEApplication::execDialog( &newDlg ) ) { 896 while ( QPEApplication::execDialog( &newDlg ) ) {
896 ev = e->event(); 897 ev = e->event();
897 ev.assignUid(); 898 ev.assignUid();
898 QString error = checkEvent( ev ); 899 QString error = checkEvent( ev );
899 if ( !error.isNull() ) { 900 if ( !error.isNull() ) {
900 if ( QMessageBox::warning( this, tr("Error!"), error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 ) 901 if ( QMessageBox::warning( this, tr("Error!"), error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 )
901 continue; 902 continue;
902 } 903 }
903 db->addEvent( ev ); 904 db->addEvent( ev );
904 emit newEvent(); 905 emit newEvent();
905 break; 906 break;
906 } 907 }
907} 908}
908 909
909void DateBook::setDocument( const QString &filename ) 910void DateBook::setDocument( const QString &filename )
910{ 911{
911 if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; 912 if ( filename.find(".vcs") != int(filename.length()) - 4 ) return;
912 913
913 QValueList<Event> tl = Event::readVCalendar( filename ); 914 QValueList<Event> tl = Event::readVCalendar( filename );
914 for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) { 915 for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) {
915 db->addEvent( *it ); 916 db->addEvent( *it );
916 } 917 }
917} 918}
918 919
919static const char * beamfile = "/tmp/obex/event.vcs"; 920static const char * beamfile = "/tmp/obex/event.vcs";
920 921
921void DateBook::beamEvent( const Event &e ) 922void DateBook::beamEvent( const Event &e )
922{ 923{
923 odebug << "trying to beam" << oendl; 924 odebug << "trying to beam" << oendl;
924 unlink( beamfile ); // delete if exists 925 unlink( beamfile ); // delete if exists
925 mkdir("/tmp/obex/", 0755); 926 mkdir("/tmp/obex/", 0755);
926 Event::writeVCalendar( beamfile, e ); 927 Event::writeVCalendar( beamfile, e );
927 Ir *ir = new Ir( this ); 928 Ir *ir = new Ir( this );
928 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 929 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
929 QString description = e.description(); 930 QString description = e.description();
930 ir->send( beamfile, description, "text/x-vCalendar" ); 931 ir->send( beamfile, description, "text/x-vCalendar" );
931} 932}
932 933
933void DateBook::beamDone( Ir *ir ) 934void DateBook::beamDone( Ir *ir )
934{ 935{
935 delete ir; 936 delete ir;
936 unlink( beamfile ); 937 unlink( beamfile );
937} 938}
938 939
939void DateBook::slotFind() 940void DateBook::slotFind()
940{ 941{
941 // move it to the day view... 942 // move it to the day view...
942 viewDay(); 943 viewDay();
943 FindDialog frmFind( "Calendar", this ); // no tr needed 944 FindDialog frmFind( "Calendar", this ); // no tr needed
944 frmFind.setUseDate( true ); 945 frmFind.setUseDate( true );
945 frmFind.setDate( currentDate() ); 946 frmFind.setDate( currentDate() );
946 QObject::connect( &frmFind, 947 QObject::connect( &frmFind,
947 SIGNAL(signalFindClicked(const QString&,const QDate&,bool,bool,int)), 948 SIGNAL(signalFindClicked(const QString&,const QDate&,bool,bool,int)),
948 this, 949 this,
949 SLOT(slotDoFind(const QString&,const QDate&,bool,bool,int)) ); 950 SLOT(slotDoFind(const QString&,const QDate&,bool,bool,int)) );
950 QObject::connect( this, 951 QObject::connect( this,
951 SIGNAL(signalNotFound()), 952 SIGNAL(signalNotFound()),
952 &frmFind, 953 &frmFind,
953 SLOT(slotNotFound()) ); 954 SLOT(slotNotFound()) );
954 QObject::connect( this, 955 QObject::connect( this,
955 SIGNAL(signalWrapAround()), 956 SIGNAL(signalWrapAround()),
956 &frmFind, 957 &frmFind,
957 SLOT(slotWrapAround()) ); 958 SLOT(slotWrapAround()) );
958 frmFind.move(0,0); 959 frmFind.move(0,0);
959 frmFind.exec(); 960 frmFind.exec();
960 inSearch = false; 961 inSearch = false;
961} 962}
962 963
963bool catComp( QArray<int> cats, int category ) 964bool catComp( QArray<int> cats, int category )
964{ 965{
965 bool returnMe; 966 bool returnMe;
966 int i, 967 int i,
967 count; 968 count;
968 969
969 count = int(cats.count()); 970 count = int(cats.count());
970 returnMe = false; 971 returnMe = false;
971 if ( (category == -1 && count == 0) || category == -2 ) 972 if ( (category == -1 && count == 0) || category == -2 )
972 returnMe = true; 973 returnMe = true;
973 else { 974 else {
974 for ( i = 0; i < count; i++ ) { 975 for ( i = 0; i < count; i++ ) {
975 if ( category == cats[i] ) { 976 if ( category == cats[i] ) {
976 returnMe = true; 977 returnMe = true;
977 break; 978 break;
978 } 979 }
979 } 980 }
980 } 981 }
981 return returnMe; 982 return returnMe;
982} 983}
983 984
984 985
985void DateBook::slotDoFind( const QString& txt, const QDate &dt, 986void DateBook::slotDoFind( const QString& txt, const QDate &dt,
986 bool caseSensitive, bool /*backwards*/, 987 bool caseSensitive, bool /*backwards*/,
987 int category ) 988 int category )
988{ 989{
989 QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ), 990 QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ),
990 next; 991 next;
991 992
992 QRegExp r( txt ); 993 QRegExp r( txt );
993 r.setCaseSensitive( caseSensitive ); 994 r.setCaseSensitive( caseSensitive );
994 995
995 996
996 static Event rev, nonrev; 997 static Event rev, nonrev;
997 if ( !inSearch ) { 998 if ( !inSearch ) {
998 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); 999 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) );
999 nonrev.setStart( rev.start() ); 1000 nonrev.setStart( rev.start() );
1000 inSearch = true; 1001 inSearch = true;
1001 } 1002 }
1002 static QDate searchDate = dt; 1003 static QDate searchDate = dt;
1003 // if true at the end we will start at the begin again and afterwards 1004 // if true at the end we will start at the begin again and afterwards
1004 // we will emit string not found 1005 // we will emit string not found
1005 static bool wrapAround = true; 1006 static bool wrapAround = true;
1006 bool candidtate; 1007 bool candidtate;
1007 candidtate = false; 1008 candidtate = false;
1008 1009
1009 QValueList<Event> repeats = db->getRawRepeats(); 1010 QValueList<Event> repeats = db->getRawRepeats();
1010 1011
1011 // find the candidate for the first repeat that matches... 1012 // find the candidate for the first repeat that matches...
1012 // first check if there can ever be a match and then compute 1013 // first check if there can ever be a match and then compute
1013 // the next occurence from start. See if this event is closer 1014 // the next occurence from start. See if this event is closer
1014 // to the beginning (start. next < dtEnd) and not smaller then the last 1015 // to the beginning (start. next < dtEnd) and not smaller then the last
1015 // result. If we find a canditate we set the dtEnd to the time 1016 // result. If we find a canditate we set the dtEnd to the time
1016 // of the ocurrence and rev to this occurence. 1017 // of the ocurrence and rev to this occurence.
1017 // set wrap around to true because there might be more events coming 1018 // set wrap around to true because there might be more events coming
1018 // and we're not at the end. 1019 // and we're not at the end.
1019 QValueListConstIterator<Event> it; 1020 QValueListConstIterator<Event> it;
1020 QDate start = dt; 1021 QDate start = dt;
1021 for ( it = repeats.begin(); it != repeats.end(); ++it ) { 1022 for ( it = repeats.begin(); it != repeats.end(); ++it ) {
1022 if ( catComp( (*it).categories(), category ) ) { 1023 if ( catComp( (*it).categories(), category ) ) {
1023 if ( (*it).match( r ) ) { 1024 if ( (*it).match( r ) ) {
1024 if ( nextOccurance( *it, start, next ) ) { 1025 if ( nextOccurance( *it, start, next ) ) {
1025 if ( next < dtEnd && !(next <= rev.start() ) ) { 1026 if ( next < dtEnd && !(next <= rev.start() ) ) {
1026 rev = *it; 1027 rev = *it;
1027 dtEnd = next; 1028 dtEnd = next;
1028 rev.setStart( next ); 1029 rev.setStart( next );
1029 candidtate = true; 1030 candidtate = true;
1030 wrapAround = true; 1031 wrapAround = true;
1031 } 1032 }
1032 } 1033 }
1033 } 1034 }
1034 } 1035 }
1035 } 1036 }
1036 1037
1037 // now the for first non repeat... 1038 // now the for first non repeat...
1038 // dtEnd is set by the previous iteration of repeatingEvents 1039 // dtEnd is set by the previous iteration of repeatingEvents
1039 // check if we find a closer item. Also set dtEnd to find even 1040 // check if we find a closer item. Also set dtEnd to find even
1040 // more close occurrence 1041 // more close occurrence
1041 QValueList<Event> nonRepeats = db->getNonRepeatingEvents( dt, dtEnd.date() ); 1042 QValueList<Event> nonRepeats = db->getNonRepeatingEvents( dt, dtEnd.date() );
1042 qHeapSort( nonRepeats.begin(), nonRepeats.end() ); 1043 qHeapSort( nonRepeats.begin(), nonRepeats.end() );
1043 for ( it = nonRepeats.begin(); it != nonRepeats.end(); ++it ) { 1044 for ( it = nonRepeats.begin(); it != nonRepeats.end(); ++it ) {
1044 if ( catComp( (*it).categories(), category ) ) { 1045 if ( catComp( (*it).categories(), category ) ) {
1045 if ( (*it).start() < dtEnd ) { 1046 if ( (*it).start() < dtEnd ) {
1046 if ( (*it).match( r ) && !(*it <= nonrev) ) { 1047 if ( (*it).match( r ) && !(*it <= nonrev) ) {
1047 nonrev = *it; 1048 nonrev = *it;
1048 dtEnd = nonrev.start(); 1049 dtEnd = nonrev.start();
1049 candidtate = true; 1050 candidtate = true;
1050 wrapAround = true; 1051 wrapAround = true;
1051 break; 1052 break;
1052 } 1053 }
1053 } 1054 }
1054 } 1055 }
1055 } 1056 }
1056 if ( candidtate ) { 1057 if ( candidtate ) {
1057 dayView->setStartViewTime( dtEnd.time().hour() ); 1058 dayView->setStartViewTime( dtEnd.time().hour() );
1058 dayView->setDate( dtEnd.date().year(), dtEnd.date().month(), 1059 dayView->setDate( dtEnd.date().year(), dtEnd.date().month(),
1059 dtEnd.date().day() ); 1060 dtEnd.date().day() );
1060 } else { 1061 } else {
1061 if ( wrapAround ) { 1062 if ( wrapAround ) {
1062 emit signalWrapAround(); 1063 emit signalWrapAround();
1063 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); 1064 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) );
1064 nonrev.setStart( rev.start() ); 1065 nonrev.setStart( rev.start() );
1065 } else 1066 } else
1066 emit signalNotFound(); 1067 emit signalNotFound();
1067 wrapAround = !wrapAround; 1068 wrapAround = !wrapAround;
1068 } 1069 }
1069} 1070}
1070 1071
1071Event DateBookDBHack::eventByUID(int uid) { 1072Event DateBookDBHack::eventByUID(int uid) {
1072 1073
1073 // FIXME: Dirty Hacks to get hold of the private event lists 1074 // FIXME: Dirty Hacks to get hold of the private event lists
1074 QDate start; 1075 QDate start;
1075 QDate end=start.addDays(-1); 1076 QDate end=start.addDays(-1);
1076 QValueList<Event> myEventList=getNonRepeatingEvents(start,end); 1077 QValueList<Event> myEventList=getNonRepeatingEvents(start,end);
1077 QValueList<Event> myRepeatEvents=getRawRepeats(); 1078 QValueList<Event> myRepeatEvents=getRawRepeats();
1078 1079
1079 QValueList<Event>::ConstIterator it; 1080 QValueList<Event>::ConstIterator it;
1080 1081
1081 for (it = myEventList.begin(); it != myEventList.end(); it++) { 1082 for (it = myEventList.begin(); it != myEventList.end(); it++) {
1082 if ((*it).uid() == uid) return *it; 1083 if ((*it).uid() == uid) return *it;
1083 } 1084 }
1084 for (it = myRepeatEvents.begin(); it != myRepeatEvents.end(); it++) { 1085 for (it = myRepeatEvents.begin(); it != myRepeatEvents.end(); it++) {
1085 if ((*it).uid() == uid) return *it; 1086 if ((*it).uid() == uid) return *it;
1086 } 1087 }
1087 1088
1088 Event ev; 1089 Event ev;
1089 return ev; // return at least 1090 return ev; // return at least
1090} 1091}
1091 1092
1092DateBookHoliday::DateBookHoliday() 1093DateBookHoliday::DateBookHoliday()
1093{ 1094{
1094 _pluginlist.clear(); 1095 _pluginlist.clear();
1095 m_pluginLoader = new Opie::Core::OPluginLoader("holidays",false); 1096 m_pluginLoader = new Opie::Core::OPluginLoader("holidays",false);
1096 m_pluginLoader->setAutoDelete(true); 1097 m_pluginLoader->setAutoDelete(true);
1097 m_pluginManager = new Opie::Core::OPluginManager(m_pluginLoader); 1098 m_pluginManager = new Opie::Core::OPluginManager(m_pluginLoader);
1098 m_pluginManager->load(); 1099 m_pluginManager->load();
1099 1100
1100 init(); 1101 init();
1101} 1102}
1102 1103
1103void DateBookHoliday::reloadPlugins() 1104void DateBookHoliday::reloadPlugins()
1104{ 1105{
1105 deinit(); 1106 deinit();
1106 init(); 1107 init();
1107} 1108}
1108 1109
1109DateBookHoliday::~DateBookHoliday() 1110DateBookHoliday::~DateBookHoliday()
1110{ 1111{
1111 deinit(); 1112 deinit();
1112 delete m_pluginLoader; 1113 delete m_pluginLoader;
1113 delete m_pluginManager; 1114 delete m_pluginManager;
1114} 1115}
1115 1116
1116void DateBookHoliday::deinit() 1117void DateBookHoliday::deinit()
1117{ 1118{
1118 QValueList<HPlugin*>::Iterator it; 1119 QValueList<HPlugin*>::Iterator it;
1119 for (it=_pluginlist.begin();it!=_pluginlist.end();++it) { 1120 for (it=_pluginlist.begin();it!=_pluginlist.end();++it) {
1120 HPlugin*_pl = *it; 1121 HPlugin*_pl = *it;
1121 *it = 0; 1122 *it = 0;
1122 delete _pl; 1123 delete _pl;
1123 } 1124 }
1124 _pluginlist.clear(); 1125 _pluginlist.clear();
1125} 1126}
1126 1127
1127#if 0 1128#if 0
1128void debugLst( const Opie::Core::OPluginItem::List& lst ) { 1129void debugLst( const Opie::Core::OPluginItem::List& lst ) {
1129 for ( Opie::Core::OPluginItem::List::ConstIterator it = lst.begin(); it != lst.end(); ++it ) 1130 for ( Opie::Core::OPluginItem::List::ConstIterator it = lst.begin(); it != lst.end(); ++it )
1130 odebug << "Name " << (*it).name() << " " << (*it).path() << " " << (*it).position() << oendl; 1131 odebug << "Name " << (*it).name() << " " << (*it).path() << " " << (*it).position() << oendl;
1131} 1132}
1132#endif 1133#endif
1133 1134
1134void DateBookHoliday::init() 1135void DateBookHoliday::init()
1135{ 1136{
1136 deinit(); 1137 deinit();
1137 1138
1138 Opie::Core::OPluginItem::List lst = m_pluginLoader->filtered(true); 1139 Opie::Core::OPluginItem::List lst = m_pluginLoader->filtered(true);
1139// debugLst( lst ); 1140// debugLst( lst );
1140 for( Opie::Core::OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ){ 1141 for( Opie::Core::OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ){
1141 Opie::Datebook::HolidayPluginIf*hif = m_pluginLoader->load<Opie::Datebook::HolidayPluginIf>(*it,IID_HOLIDAY_PLUGIN); 1142 Opie::Datebook::HolidayPluginIf*hif = m_pluginLoader->load<Opie::Datebook::HolidayPluginIf>(*it,IID_HOLIDAY_PLUGIN);
1142 if (hif) { 1143 if (hif) {
1143 Opie::Datebook::HolidayPlugin*pl = hif->plugin(); 1144 Opie::Datebook::HolidayPlugin*pl = hif->plugin();
1144 if (pl) { 1145 if (pl) {
1145 HPlugin*_pl=new HPlugin; 1146 HPlugin*_pl=new HPlugin;
1146 _pl->_plugin = pl; 1147 _pl->_plugin = pl;
1147 odebug << "Found holiday " << pl->description()<<oendl; 1148 odebug << "Found holiday " << pl->description()<<oendl;
1148 _pluginlist.append(_pl); 1149 _pluginlist.append(_pl);
1149 //_pl->_if = hif; 1150 //_pl->_if = hif;
1150 } 1151 }
1151 } 1152 }
1152 } 1153 }
1153} 1154}
1154 1155
1155QStringList DateBookHoliday::holidaylist(const QDate&aDate) 1156QStringList DateBookHoliday::holidaylist(const QDate&aDate)
1156{ 1157{
1157 QStringList ret; 1158 QStringList ret;
1158 QValueList<HPlugin*>::Iterator it; 1159 QValueList<HPlugin*>::Iterator it;
1159 for (it=_pluginlist.begin();it!=_pluginlist.end();++it) { 1160 for (it=_pluginlist.begin();it!=_pluginlist.end();++it) {
1160 HPlugin*_pl = *it; 1161 HPlugin*_pl = *it;
1161 ret+=_pl->_plugin->entries(aDate); 1162 ret+=_pl->_plugin->entries(aDate);
1162 } 1163 }
1163 return ret; 1164 return ret;
1164} 1165}
1165 1166
1166QStringList DateBookHoliday::holidaylist(unsigned year, unsigned month, unsigned day) 1167QStringList DateBookHoliday::holidaylist(unsigned year, unsigned month, unsigned day)
1167{ 1168{
1168 return holidaylist(QDate(year,month,day)); 1169 return holidaylist(QDate(year,month,day));
1169} 1170}
1170 1171
1171QValueList<EffectiveEvent> DateBookHoliday::getEffectiveEvents(const QDate &from,const QDate &to ) 1172QValueList<EffectiveEvent> DateBookHoliday::getEffectiveEvents(const QDate &from,const QDate &to )
1172{ 1173{
1173 QValueList<EffectiveEvent> ret; 1174 QValueList<EffectiveEvent> ret;
1174 QValueList<HPlugin*>::Iterator it; 1175 QValueList<HPlugin*>::Iterator it;
1175 for (it=_pluginlist.begin();it!=_pluginlist.end();++it) { 1176 for (it=_pluginlist.begin();it!=_pluginlist.end();++it) {
1176 HPlugin*_pl = *it; 1177 HPlugin*_pl = *it;
1177 ret+=_pl->_plugin->events(from,to); 1178 ret+=_pl->_plugin->events(from,to);
1178 } 1179 }
1179 return ret; 1180 return ret;
1180} 1181}
1181 1182
1182QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEventsNoHoliday(const QDate &from,const QDate &to ) 1183QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEventsNoHoliday(const QDate &from,const QDate &to )
1183{ 1184{
1184 return DateBookDBHack::getEffectiveEvents(from,to); 1185 return DateBookDBHack::getEffectiveEvents(from,to);
1185} 1186}
1186 1187
1187QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEventsNoHoliday(const QDateTime &start) 1188QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEventsNoHoliday(const QDateTime &start)
1188{ 1189{
1189 return DateBookDBHack::getEffectiveEvents(start); 1190 return DateBookDBHack::getEffectiveEvents(start);
1190} 1191}
1191 1192
1192QValueList<EffectiveEvent> DateBookHoliday::getEffectiveEvents(const QDateTime &start) 1193QValueList<EffectiveEvent> DateBookHoliday::getEffectiveEvents(const QDateTime &start)
1193{ 1194{
1194 return getEffectiveEvents(start.date(),start.date()); 1195 return getEffectiveEvents(start.date(),start.date());
1195} 1196}
1196 1197
1197QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEvents(const QDate &from,const QDate &to ) 1198QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEvents(const QDate &from,const QDate &to )
1198{ 1199{
1199 QValueList<EffectiveEvent> ret; 1200 QValueList<EffectiveEvent> ret;
1200 odebug << "Ueberlagert 1" << oendl; 1201 odebug << "Ueberlagert 1" << oendl;
1201 if (db_holiday) { 1202 if (db_holiday) {
1202 ret+=db_holiday->getEffectiveEvents(from,to); 1203 ret+=db_holiday->getEffectiveEvents(from,to);
1203 } 1204 }
1204 ret+=getEffectiveEventsNoHoliday(from,to); 1205 ret+=getEffectiveEventsNoHoliday(from,to);
1205 return ret; 1206 return ret;
1206} 1207}
1207 1208
1208QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEvents( const QDateTime &start) 1209QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEvents( const QDateTime &start)
1209{ 1210{
1210 odebug << "Ueberlagert 2" << oendl; 1211 odebug << "Ueberlagert 2" << oendl;
1211 return DateBookDBHack::getEffectiveEvents(start); 1212 return DateBookDBHack::getEffectiveEvents(start);
1212} 1213}
diff --git a/core/pim/datebook/datebook.h b/core/pim/datebook/datebook.h
index 3d7f5b5..fb8b083 100644
--- a/core/pim/datebook/datebook.h
+++ b/core/pim/datebook/datebook.h
@@ -1,137 +1,134 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef DATEBOOK_H 20#ifndef DATEBOOK_H
21#define DATEBOOK_H 21#define DATEBOOK_H
22 22
23#include "datebooktypes.h" 23#include "datebooktypes.h"
24 24
25#include <qpe/datebookdb.h> 25#include <qpe/datebookdb.h>
26 26
27#include <qmainwindow.h> 27#include <qmainwindow.h>
28 28
29enum { DAY=1,WEEK,WEEKLST,MONTH }; // defaultView values
30enum { NONE=0,NORMAL,EXTENDED }; // WeekLstView's modes.
31
32class QAction; 29class QAction;
33class QWidgetStack; 30class QWidgetStack;
34class DateBookDay; 31class DateBookDay;
35class DateBookWeek; 32class DateBookWeek;
36class DateBookWeekLst; 33class DateBookWeekLst;
37class DateBookMonth; 34class DateBookMonth;
38class Event; 35class Event;
39class QDate; 36class QDate;
40class Ir; 37class Ir;
41 38
42class DateBook : public QMainWindow 39class DateBook : public QMainWindow
43{ 40{
44 Q_OBJECT 41 Q_OBJECT
45 42
46public: 43public:
47 static QString appName() { return QString::fromLatin1("datebook"); } 44 static QString appName() { return QString::fromLatin1("datebook"); }
48 DateBook( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 45 DateBook( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
49 ~DateBook(); 46 ~DateBook();
50 47
51signals: 48signals:
52 void newEvent(); 49 void newEvent();
53 void signalNotFound(); 50 void signalNotFound();
54 void signalWrapAround(); 51 void signalWrapAround();
55 52
56protected: 53protected:
57 QDate currentDate(); 54 QDate currentDate();
58 void timerEvent( QTimerEvent *e ); 55 void timerEvent( QTimerEvent *e );
59 void closeEvent( QCloseEvent *e ); 56 void closeEvent( QCloseEvent *e );
60 57
61 void view(int v, const QDate &d); 58 void view(int v, const QDate &d);
62 59
63public slots: 60public slots:
64 void flush(); 61 void flush();
65 void reload(); 62 void reload();
66 63
67private slots: 64private slots:
68 void fileNew(); 65 void fileNew();
69 void slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location=0); 66 void slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location=0);
70 void slotSettings(); 67 void slotSettings();
71 void slotToday(); // view today 68 void slotToday(); // view today
72 void changeClock( bool newClock ); 69 void changeClock( bool newClock );
73 void changeWeek( bool newDay ); 70 void changeWeek( bool newDay );
74 void appMessage(const QCString& msg, const QByteArray& data); 71 void appMessage(const QCString& msg, const QByteArray& data);
75 // handle key events in the day view... 72 // handle key events in the day view...
76 void slotNewEventFromKey( const QString &str ); 73 void slotNewEventFromKey( const QString &str );
77 void slotFind(); 74 void slotFind();
78 void slotDoFind( const QString &, const QDate &, bool, bool, int ); 75 void slotDoFind( const QString &, const QDate &, bool, bool, int );
79 76
80 void viewDefault(const QDate &d); 77 void viewDefault(const QDate &d);
81 78
82 void viewDay(); 79 void viewDay();
83 void viewWeek(); 80 void viewWeek();
84 void viewWeekLst(); 81 void viewWeekLst();
85 void viewMonth(); 82 void viewMonth();
86 83
87 void showDay( int y, int m, int d ); 84 void showDay( int y, int m, int d );
88 85
89 void insertEvent( const Event &e ); 86 void insertEvent( const Event &e );
90 void editEvent( const Event &e ); 87 void editEvent( const Event &e );
91 void duplicateEvent( const Event &e ); 88 void duplicateEvent( const Event &e );
92 void removeEvent( const Event &e ); 89 void removeEvent( const Event &e );
93 90
94 void receive( const QCString &msg, const QByteArray &data ); 91 void receive( const QCString &msg, const QByteArray &data );
95 void setDocument( const QString & ); 92 void setDocument( const QString & );
96 void beamEvent( const Event &e ); 93 void beamEvent( const Event &e );
97 void beamDone( Ir *ir ); 94 void beamDone( Ir *ir );
98 95
99private: 96private:
100 void addEvent( const Event &e ); 97 void addEvent( const Event &e );
101 void initDay(); 98 void initDay();
102 void initWeek(); 99 void initWeek();
103 void initWeekLst(); 100 void initWeekLst();
104 void initMonth(); 101 void initMonth();
105 void loadSettings(); 102 void loadSettings();
106 void saveSettings(); 103 void saveSettings();
107 104
108private: 105private:
109 DateBookDBHoliday *db; 106 DateBookDBHoliday *db;
110 DateBookHoliday*db_holiday; 107 DateBookHoliday*db_holiday;
111 QWidgetStack *views; 108 QWidgetStack *views;
112 DateBookDay *dayView; 109 DateBookDay *dayView;
113 DateBookWeek *weekView; 110 DateBookWeek *weekView;
114 DateBookMonth *monthView; 111 DateBookMonth *monthView;
115 DateBookWeekLst *weekLstView; 112 DateBookWeekLst *weekLstView;
116 QAction *dayAction, *weekAction, *weekLstAction, *monthAction; 113 QAction *dayAction, *weekAction, *weekLstAction, *monthAction;
117 int weeklistviewconfig; 114 int weeklistviewconfig;
118 bool aPreset; // have everything set to alarm? 115 bool aPreset; // have everything set to alarm?
119 int presetTime; // the standard time for the alarm 116 int presetTime; // the standard time for the alarm
120 int startTime; 117 int startTime;
121 int rowStyle; 118 int rowStyle;
122 int defaultView; 119 int defaultView;
123 QArray<int> defaultCategories; 120 QArray<int> defaultCategories;
124 QString defaultLocation; 121 QString defaultLocation;
125 bool bJumpToCurTime; //should jump to current time in dayview? 122 bool bJumpToCurTime; //should jump to current time in dayview?
126 bool ampm; 123 bool ampm;
127 bool onMonday; 124 bool onMonday;
128 125
129 bool syncing; 126 bool syncing;
130 bool inSearch; 127 bool inSearch;
131 128
132 int alarmCounter; 129 int alarmCounter;
133 130
134 QString checkEvent(const Event &); 131 QString checkEvent(const Event &);
135}; 132};
136 133
137#endif 134#endif
diff --git a/core/pim/datebook/datebook.pro b/core/pim/datebook/datebook.pro
index 046bcdf..26f4d8d 100644
--- a/core/pim/datebook/datebook.pro
+++ b/core/pim/datebook/datebook.pro
@@ -1,42 +1,52 @@
1 CONFIG += qt warn_on quick-app 1 CONFIG += qt warn_on quick-app
2 HEADERS= datebookday.h \ 2 HEADERS= datebookday.h \
3 datebook.h \ 3 datebook.h \
4 dateentryimpl.h \ 4 dateentryimpl.h \
5 datebookdayheaderimpl.h \ 5 datebookdayheaderimpl.h \
6 datebooksettings.h \ 6 datebooksettings.h \
7 datebookweek.h \ 7 datebookweek.h \
8 datebookweeklst.h \ 8 modules/weeklst/datebookweeklst.h \
9 modules/weeklst/datebookweeklstdayhdr.h \
10 modules/weeklst/datebookweeklstheader.h \
11 modules/weeklst/datebookweeklstevent.h \
12 modules/weeklst/datebookweeklstview.h \
13 modules/weeklst/datebookweeklstdblview.h \
9 datebookweekheaderimpl.h \ 14 datebookweekheaderimpl.h \
10 repeatentry.h \ 15 repeatentry.h \
11 noteentryimpl.h \ 16 noteentryimpl.h \
12 onoteedit.h \ 17 onoteedit.h \
13 datebookdayallday.h \ 18 datebookdayallday.h \
14 namespace_hack.h \ 19 namespace_hack.h \
15 datebooktypes.h 20 datebooktypes.h
16 SOURCES= main.cpp \ 21 SOURCES= main.cpp \
17 datebookday.cpp \ 22 datebookday.cpp \
18 datebook.cpp \ 23 datebook.cpp \
19 dateentryimpl.cpp \ 24 dateentryimpl.cpp \
20 datebookdayheaderimpl.cpp \ 25 datebookdayheaderimpl.cpp \
21 datebooksettings.cpp \ 26 datebooksettings.cpp \
22 datebookweek.cpp \ 27 datebookweek.cpp \
23 datebookweeklst.cpp \ 28 modules/weeklst/datebookweeklst.cpp \
29 modules/weeklst/datebookweeklstdayhdr.cpp \
30 modules/weeklst/datebookweeklstheader.cpp \
31 modules/weeklst/datebookweeklstevent.cpp \
32 modules/weeklst/datebookweeklstview.cpp \
33 modules/weeklst/datebookweeklstdblview.cpp \
24 datebookweekheaderimpl.cpp \ 34 datebookweekheaderimpl.cpp \
25 repeatentry.cpp \ 35 repeatentry.cpp \
26 noteentryimpl.cpp \ 36 noteentryimpl.cpp \
27 onoteedit.cpp \ 37 onoteedit.cpp \
28 datebookdayallday.cpp 38 datebookdayallday.cpp
29 INTERFACES= dateentry.ui \ 39 INTERFACES= dateentry.ui \
30 datebookdayheader.ui \ 40 datebookdayheader.ui \
31 datebookweekheader.ui \ 41 datebookweekheader.ui \
32 datebookweeklstheader.ui \ 42 modules/weeklst/datebookweeklstheaderbase.ui \
33 datebookweeklstdayhdr.ui \ 43 modules/weeklst/datebookweeklstdayhdrbase.ui \
34 repeatentrybase.ui \ 44 repeatentrybase.ui \
35 datebooksettingsbase.ui \ 45 datebooksettingsbase.ui \
36 noteentry.ui 46 noteentry.ui
37INCLUDEPATH += $(OPIEDIR)/include 47INCLUDEPATH += $(OPIEDIR)/include
38 DEPENDPATH+= $(OPIEDIR)/include 48 DEPENDPATH+= $(OPIEDIR)/include
39LIBS += -lqpe -lopieui2 -lopiecore2 -lopiepim2 49LIBS += -lqpe -lopieui2 -lopiecore2 -lopiepim2
40 TARGET = datebook 50 TARGET = datebook
41 51
42include( $(OPIEDIR)/include.pro ) 52include( $(OPIEDIR)/include.pro )
diff --git a/core/pim/datebook/datebooktypes.h b/core/pim/datebook/datebooktypes.h
index 2966814..9453be8 100644
--- a/core/pim/datebook/datebooktypes.h
+++ b/core/pim/datebook/datebooktypes.h
@@ -1,70 +1,73 @@
1#ifndef _DATEBOOK_TYPES_H 1#ifndef _DATEBOOK_TYPES_H
2#define _DATEBOOK_TYPES_H 2#define _DATEBOOK_TYPES_H
3 3
4#include <qpe/datebookdb.h> 4#include <qpe/datebookdb.h>
5 5
6#include <qvaluelist.h> 6#include <qvaluelist.h>
7#include <qstringlist.h> 7#include <qstringlist.h>
8 8
9namespace Opie { 9namespace Opie {
10namespace Datebook { 10namespace Datebook {
11 class HolidayPlugin; 11 class HolidayPlugin;
12 class HolidayPluginIf; 12 class HolidayPluginIf;
13} 13}
14namespace Core { 14namespace Core {
15 class OPluginLoader; 15 class OPluginLoader;
16 class OPluginManager; 16 class OPluginManager;
17} 17}
18} 18}
19 19
20class QLibrary; 20class QLibrary;
21 21
22enum { DAY=1,WEEK,WEEKLST,MONTH }; // defaultView values
23enum { NONE=0,NORMAL,EXTENDED }; // WeekLstView's modes.
24
22class DateBookDBHack : virtual public DateBookDB { 25class DateBookDBHack : virtual public DateBookDB {
23 public: 26 public:
24 virtual ~DateBookDBHack(){} 27 virtual ~DateBookDBHack(){}
25 Event eventByUID(int id); 28 Event eventByUID(int id);
26}; 29};
27 30
28class DateBookHoliday 31class DateBookHoliday
29{ 32{
30public: 33public:
31 DateBookHoliday(); 34 DateBookHoliday();
32 virtual ~DateBookHoliday(); 35 virtual ~DateBookHoliday();
33 36
34 QStringList holidaylist(const QDate&); 37 QStringList holidaylist(const QDate&);
35 QStringList holidaylist(unsigned year, unsigned month, unsigned day); 38 QStringList holidaylist(unsigned year, unsigned month, unsigned day);
36 virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDate &from,const QDate &to ); 39 virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDate &from,const QDate &to );
37 virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDateTime &start); 40 virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDateTime &start);
38 41
39 void reloadPlugins(); 42 void reloadPlugins();
40 43
41 Opie::Core::OPluginLoader*pluginLoader(){return m_pluginLoader;} 44 Opie::Core::OPluginLoader*pluginLoader(){return m_pluginLoader;}
42 Opie::Core::OPluginManager*pluginManager(){return m_pluginManager;} 45 Opie::Core::OPluginManager*pluginManager(){return m_pluginManager;}
43 46
44protected: 47protected:
45 void init(); 48 void init();
46 void deinit(); 49 void deinit();
47 50
48 struct HPlugin { 51 struct HPlugin {
49 Opie::Datebook::HolidayPlugin*_plugin; 52 Opie::Datebook::HolidayPlugin*_plugin;
50 //QLibrary*_lib; 53 //QLibrary*_lib;
51 //Opie::Datebook::HolidayPluginIf*_if; 54 //Opie::Datebook::HolidayPluginIf*_if;
52 }; 55 };
53 QValueList<HPlugin*>_pluginlist; 56 QValueList<HPlugin*>_pluginlist;
54 Opie::Core::OPluginLoader*m_pluginLoader; 57 Opie::Core::OPluginLoader*m_pluginLoader;
55 Opie::Core::OPluginManager*m_pluginManager; 58 Opie::Core::OPluginManager*m_pluginManager;
56}; 59};
57 60
58class DateBookDBHoliday:virtual public DateBookDBHack { 61class DateBookDBHoliday:virtual public DateBookDBHack {
59public: 62public:
60 DateBookDBHoliday():DateBookDBHack(){db_holiday=0;} 63 DateBookDBHoliday():DateBookDBHack(){db_holiday=0;}
61 virtual ~DateBookDBHoliday(){} 64 virtual ~DateBookDBHoliday(){}
62 virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDate &from,const QDate &to ); 65 virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDate &from,const QDate &to );
63 virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDateTime &start); 66 virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDateTime &start);
64 virtual QValueList<EffectiveEvent> getEffectiveEventsNoHoliday(const QDate &from,const QDate &to ); 67 virtual QValueList<EffectiveEvent> getEffectiveEventsNoHoliday(const QDate &from,const QDate &to );
65 virtual QValueList<EffectiveEvent> getEffectiveEventsNoHoliday(const QDateTime &start); 68 virtual QValueList<EffectiveEvent> getEffectiveEventsNoHoliday(const QDateTime &start);
66 69
67 DateBookHoliday*db_holiday; 70 DateBookHoliday*db_holiday;
68}; 71};
69 72
70#endif 73#endif
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp
deleted file mode 100644
index 3c871ea..0000000
--- a/core/pim/datebook/datebookweeklst.cpp
+++ b/dev/null
@@ -1,442 +0,0 @@
1#include "namespace_hack.h"
2#include "datebookweeklst.h"
3
4#include "datebook.h"
5#include "datebooktypes.h"
6
7#include <opie2/odebug.h>
8
9#include <qpe/datebookmonth.h>
10#include <qpe/config.h>
11#include <qpe/ir.h>
12#include <qpe/resource.h>
13
14#include <qlayout.h>
15#include <qtoolbutton.h>
16#include <qtl.h>
17
18bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false);
19
20using namespace Opie::Ui;
21DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const char* name, WFlags fl)
22 : DateBookWeekLstHeaderBase(parent, name, fl)
23{
24 setBackgroundMode( PaletteButton );
25 labelDate->setBackgroundMode( PaletteButton );
26 forwardweek->setBackgroundMode( PaletteButton );
27 forwardweek->setPixmap( Resource::loadPixmap("forward") );
28 forwardmonth->setBackgroundMode( PaletteButton );
29 forwardmonth->setPixmap( Resource::loadPixmap("fastforward") );
30 backweek->setBackgroundMode( PaletteButton );
31 backweek->setPixmap( Resource::loadPixmap("back") );
32 backmonth->setBackgroundMode( PaletteButton );
33 backmonth->setPixmap( Resource::loadPixmap("fastback") );
34 DateBookWeekLstHeaderBaseLayout->setSpacing(0);
35 DateBookWeekLstHeaderBaseLayout->setMargin(0);
36 //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding));
37 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
38
39 connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth()));
40 connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek()));
41 connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek()));
42 connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth()));
43 connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate()));
44 connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool)));
45 bStartOnMonday=onM;
46}
47DateBookWeekLstHeader::~DateBookWeekLstHeader(){}
48
49void DateBookWeekLstHeader::setDate(const QDate &d) {
50 int year,week,dayofweek;
51 date=d;
52 dayofweek=d.dayOfWeek();
53 if(bStartOnMonday)
54 dayofweek--;
55 else if( dayofweek == 7 )
56 /* we already have the right day -7 would lead to the same week */
57 dayofweek = 0;
58
59 date=date.addDays(-dayofweek);
60
61 calcWeek(date,week,year,bStartOnMonday);
62 QDate start=date;
63 QDate stop=start.addDays(6);
64 labelDate->setText( QString::number(start.day()) + "." +
65 Calendar::nameOfMonth( start.month() ) + "-" +
66 QString::number(stop.day()) + "." +
67 Calendar::nameOfMonth( stop.month()) +" ("+
68 tr("w")+":"+QString::number( week ) +")");
69 date = d; // bugfix: 0001126 - date has to be the selected date, not monday!
70 emit dateChanged(date);
71}
72
73void DateBookWeekLstHeader::pickDate() {
74 static QPopupMenu *m1 = 0;
75 static DateBookMonth *picker = 0;
76 if ( !m1 ) {
77 m1 = new QPopupMenu( this );
78 picker = new DateBookMonth( m1, 0, TRUE );
79 m1->insertItem( picker );
80 connect( picker, SIGNAL( dateClicked(int,int,int) ),this, SLOT( setDate(int,int,int) ) );
81 //connect( m1, SIGNAL( aboutToHide() ),
82 //this, SLOT( gotHide() ) );
83 }
84 picker->setDate( date.year(), date.month(), date.day() );
85 m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height())));
86 picker->setFocus();
87}
88void DateBookWeekLstHeader::setDate(int y, int m, int d) {
89 setDate(QDate(y,m,d));
90}
91
92void DateBookWeekLstHeader::nextWeek() {
93 setDate(date.addDays(7));
94}
95void DateBookWeekLstHeader::prevWeek() {
96 setDate(date.addDays(-7));
97}
98void DateBookWeekLstHeader::nextMonth()
99{
100 setDate(date.addDays(28));
101}
102void DateBookWeekLstHeader::prevMonth()
103{
104 setDate(date.addDays(-28));
105}
106
107DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */,
108 QWidget* parent,
109 const char* name,
110 WFlags fl )
111 : DateBookWeekLstDayHdrBase(parent, name, fl) {
112
113 date=d;
114
115 static const QString wdays=tr("MTWTFSSM", "Week days");
116 char day=wdays[d.dayOfWeek()-1];
117
118 //dont use dayOfWeek() to save space !
119 label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) );
120
121 add->setText("+");
122
123 if (d == QDate::currentDate()) {
124 QPalette pal=label->palette();
125 pal.setColor(QColorGroup::Foreground, QColor(0,0,255));
126 label->setPalette(pal);
127
128 /*
129 QFont f=label->font();
130 f.setItalic(true);
131 label->setFont(f);
132 label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor()));
133 */
134 } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday
135 QPalette pal=label->palette();
136 pal.setColor(QColorGroup::Foreground, QColor(255,0,0));
137 label->setPalette(pal);
138 }
139
140 connect (label, SIGNAL(clicked()), this, SLOT(showDay()));
141 connect (add, SIGNAL(clicked()), this, SLOT(newEvent()));
142}
143
144void DateBookWeekLstDayHdr::showDay() {
145 emit showDate(date.year(), date.month(), date.day());
146}
147
148void DateBookWeekLstDayHdr::newEvent() {
149 QDateTime start, stop;
150 start=stop=date;
151 start.setTime(QTime(10,0));
152 stop.setTime(QTime(12,0));
153
154 emit addEvent(start,stop,"",0);
155}
156DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev,
157 int weeklistviewconfig,
158 QWidget* parent,
159 const char* name,
160 WFlags fl ) : OClickableLabel(parent,name,fl), event(ev)
161{
162 // old values... lastday = "__|__", middle=" |---", Firstday="00:00",
163 QString s,start,middle,end,day;
164
165 odebug << "weeklistviewconfig=" << weeklistviewconfig << oendl;
166 if(weeklistviewconfig==NONE) { // No times displayed.
167// start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute());
168// middle.sprintf("<--->");
169// end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute());
170// day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute());
171 } else if(weeklistviewconfig==NORMAL) { // "Normal", only display start time.
172 start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute());
173 middle.sprintf(" |---");
174 end.sprintf("__|__");
175 day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute());
176 } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times.
177 start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute());
178 middle.sprintf("<--->");
179 end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute());
180 day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute());
181 }
182
183 if(ev.event().type() == Event::Normal) {
184 if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) { // day event.
185 s=day;
186 } else if(ev.startDate()==ev.date()) { // start event.
187 s=start;
188 } else if(ev.endDate()==ev.date()) { // end event.
189 s=end;
190 } else { // middle day.
191 s=middle;
192 }
193 } else {
194 s="";
195 }
196 setText(QString(s) + " " + ev.description());
197// connect(this, SIGNAL(clicked()), this, SLOT(editMe()));
198 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) );
199}
200void DateBookWeekLstEvent::editMe() {
201 emit editEvent(event.event());
202}
203void DateBookWeekLstEvent::duplicateMe()
204{
205 emit duplicateEvent(event.event());
206}
207void DateBookWeekLstEvent::deleteMe()
208{
209 emit removeEvent(event.event());
210 emit redraw();
211}
212void DateBookWeekLstEvent::beamMe()
213{
214 emit beamEvent( event.event() );
215}
216void DateBookWeekLstEvent::mousePressEvent( QMouseEvent *e )
217{
218 if (!event.event().isValidUid()) {
219 // this is just such a holiday event.
220 return;
221 }
222 popmenue = new QPopupMenu;
223
224 popmenue->insertItem( tr( "Edit" ), this, SLOT(editMe()));
225 popmenue->insertItem( tr( "Duplicate" ), this, SLOT(duplicateMe()));
226 popmenue->insertItem( tr( "Delete" ), this, SLOT(deleteMe()));
227 if(Ir::supported())
228 popmenue->insertItem( tr( "Beam" ), this, SLOT(beamMe()));
229 popmenue->popup( mapToGlobal( e->pos() ));
230}
231
232DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
233 const QDate &d, bool onM,
234 QWidget* parent,
235 const char* name, WFlags fl)
236 : QWidget( parent, name, fl )
237{
238 Config config("DateBook");
239 config.setGroup("Main");
240 int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL);
241 odebug << "weeklistviewconfig: " << weeklistviewconfig << oendl;
242
243 bStartOnMonday=onM;
244 setPalette(white);
245 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
246
247 QVBoxLayout *layout = new QVBoxLayout( this );
248
249 qBubbleSort(ev);
250 QValueListIterator<EffectiveEvent> it;
251 it=ev.begin();
252
253 int dayOrder[7];
254 if (bStartOnMonday) {
255 for (int d=0; d<7; d++) dayOrder[d]=d+1;
256 } else {
257 for (int d=0; d<7; d++) dayOrder[d]=d;
258 dayOrder[0]=7;
259 }
260
261 // Calculate offset to first day of week.
262 int dayoffset=d.dayOfWeek();
263 if(bStartOnMonday) dayoffset--;
264 else if( dayoffset == 7 ) dayoffset = 0;
265
266 for (int i=0; i<7; i++) {
267 // Header
268 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this);
269 connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
270 connect(hdr, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
271 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
272 layout->addWidget(hdr);
273
274 // Events
275 while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) {
276 if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) { // Skip events ending at 00:00 starting at another day.
277 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this);
278 layout->addWidget(l);
279 connect (l, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
280 connect (l, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
281 connect (l, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
282 connect (l, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
283 connect (l, SIGNAL(redraw()), this, SIGNAL(redraw()));
284 }
285 it++;
286 }
287 layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding));
288 }
289}
290DateBookWeekLstView::~DateBookWeekLstView(){}
291void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();}
292
293DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
294 QValueList<EffectiveEvent> &ev2,
295 QDate &d, bool onM,
296 QWidget* parent,
297 const char* name, WFlags fl)
298 : QWidget( parent, name, fl )
299{
300 QHBoxLayout *layout = new QHBoxLayout( this );
301
302 DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this);
303 layout->addWidget(w);
304 connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
305 connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
306 connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
307 connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
308 connect (w, SIGNAL(redraw()), this, SIGNAL(redraw()));
309 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
310 connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
311 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
312
313
314 w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this);
315 layout->addWidget(w);
316 connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
317 connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
318 connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
319 connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
320 connect (w, SIGNAL(redraw()), this, SIGNAL(redraw()));
321 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
322 connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
323 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
324}
325
326DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDBHoliday *newDB,
327 QWidget *parent,
328 const char *name )
329 : QWidget( parent, name ),
330 db( newDB ),
331 startTime( 0 ),
332 ampm( ap ),
333 bStartOnMonday(onM)
334{
335 setFocusPolicy(StrongFocus);
336 layout = new QVBoxLayout( this );
337 layout->setMargin(0);
338
339 header=new DateBookWeekLstHeader(onM, this);
340 layout->addWidget( header );
341 connect(header, SIGNAL(dateChanged(QDate&)), this, SLOT(dateChanged(QDate&)));
342 connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool)));
343
344 scroll=new QScrollView(this);
345 scroll->setResizePolicy(QScrollView::AutoOneFit);
346 layout->addWidget(scroll);
347
348 view=NULL;
349 Config config("DateBook");
350 config.setGroup("Main");
351 dbl=config.readBoolEntry("weeklst_dbl", false);
352 header->dbl->setOn(dbl);
353}
354DateBookWeekLst::~DateBookWeekLst(){
355 Config config("DateBook");
356 config.setGroup("Main");
357 config.writeEntry("weeklst_dbl", dbl);
358}
359
360void DateBookWeekLst::setDate(const QDate &d) {
361 bdate=d;
362 header->setDate(d);
363}
364
365void DateBookWeekLst::setDbl(bool on) {
366 dbl=on;
367 redraw();
368}
369void DateBookWeekLst::redraw() {getEvents();}
370
371QDate DateBookWeekLst::date() {
372 return bdate;
373}
374
375// return the date at the beginning of the week...
376// copied from DateBookWeek
377QDate DateBookWeekLst::weekDate() const
378{
379 QDate d=bdate;
380
381 // Calculate offset to first day of week.
382 int dayoffset=d.dayOfWeek();
383 if(bStartOnMonday) dayoffset--;
384 else if( dayoffset == 7 )
385 dayoffset = 0;
386
387 return d.addDays(-dayoffset);
388}
389
390void DateBookWeekLst::getEvents() {
391 QDate start = weekDate(); //date();
392 QDate stop = start.addDays(6);
393 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop);
394
395 if (view) delete view;
396 if (dbl) {
397 QDate start2=start.addDays(7);
398 stop=start2.addDays(6);
399 QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop);
400 view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll);
401 } else {
402 view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll);
403 }
404
405 connect (view, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
406 connect (view, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
407 connect (view, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
408 connect (view, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
409 connect (view, SIGNAL(redraw()), this, SLOT(redraw()));
410 connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
411 connect (view, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
412 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
413
414 scroll->addChild(view);
415 view->show();
416 scroll->updateScrollBars();
417}
418
419void DateBookWeekLst::dateChanged(QDate &newdate) {
420 bdate=newdate;
421 getEvents();
422}
423
424void DateBookWeekLst::keyPressEvent(QKeyEvent *e)
425{
426 switch(e->key()) {
427 case Key_Up:
428 scroll->scrollBy(0, -20);
429 break;
430 case Key_Down:
431 scroll->scrollBy(0, 20);
432 break;
433 case Key_Left:
434 header->prevWeek();
435 break;
436 case Key_Right:
437 header->nextWeek();
438 break;
439 default:
440 e->ignore();
441 }
442}
diff --git a/core/pim/datebook/datebookweeklst.h b/core/pim/datebook/datebookweeklst.h
deleted file mode 100644
index 38d7777..0000000
--- a/core/pim/datebook/datebookweeklst.h
+++ b/dev/null
@@ -1,178 +0,0 @@
1#ifndef DATEBOOKWEEKLST
2#define DATEBOOKWEEKLST
3
4#include <qwidget.h>
5#include <qdatetime.h>
6#include <qpe/event.h>
7#include <qlabel.h>
8#include <qscrollview.h>
9
10#include "datebookweeklstheader.h"
11#include "datebookweeklstdayhdr.h"
12
13#include <opie2/oclickablelabel.h>
14
15class QDateTime;
16class DateBookDB;
17class DateBookDBHoliday;
18
19class DateBookWeekLstHeader: public DateBookWeekLstHeaderBase
20{
21 Q_OBJECT
22public:
23 DateBookWeekLstHeader(bool onM, QWidget* parent = 0, const char* name = 0,
24 WFlags fl = 0 );
25 ~DateBookWeekLstHeader();
26 void setDate(const QDate &d);
27
28public slots:
29 void nextWeek();
30 void prevWeek();
31 void nextMonth();
32 void prevMonth();
33 void pickDate();
34 void setDate(int y, int m, int d);
35signals:
36 void dateChanged(QDate &newdate);
37 void setDbl(bool on);
38private:
39 QDate date;
40// bool onMonday;
41 bool bStartOnMonday;
42};
43
44class DateBookWeekLstDayHdr: public DateBookWeekLstDayHdrBase
45{
46 Q_OBJECT
47public:
48 DateBookWeekLstDayHdr(const QDate &d, bool onM,
49 QWidget* parent = 0, const char* name = 0,
50 WFlags fl = 0 );
51public slots:
52 void showDay();
53 void newEvent();
54signals:
55 void showDate(int y, int m, int d);
56 void addEvent(const QDateTime &start, const QDateTime &stop,
57 const QString &str, const QString &location);
58private:
59 QDate date;
60};
61
62class DateBookWeekLstEvent: public Opie::Ui::OClickableLabel
63{
64 Q_OBJECT
65public:
66 DateBookWeekLstEvent(const EffectiveEvent &ev, int weeklistviewconfig =1,
67 QWidget* parent = 0, const char* name = 0,
68 WFlags fl = 0);
69signals:
70 void editEvent(const Event &e);
71 void duplicateEvent(const Event &e);
72 void removeEvent(const Event &e);
73 void beamEvent(const Event &e);
74 void redraw();
75private slots:
76 void editMe();
77 void duplicateMe();
78 void deleteMe();
79 void beamMe();
80private:
81 const EffectiveEvent event;
82 QPopupMenu* popmenue;
83protected:
84 void mousePressEvent( QMouseEvent *e );
85};
86
87class DateBookWeekLstView: public QWidget
88{
89 Q_OBJECT
90public:
91 DateBookWeekLstView(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM,
92 QWidget* parent = 0, const char* name = 0,
93 WFlags fl = 0 );
94 ~DateBookWeekLstView();
95signals:
96 void editEvent(const Event &e);
97 void duplicateEvent(const Event &e);
98 void removeEvent(const Event &e);
99 void beamEvent(const Event &e);
100 void redraw();
101 void showDate(int y, int m, int d);
102 void addEvent(const QDateTime &start, const QDateTime &stop,
103 const QString &str, const QString &location);
104private:
105 bool bStartOnMonday;
106protected slots:
107 void keyPressEvent(QKeyEvent *);
108};
109
110class DateBookWeekLstDblView: public QWidget {
111 Q_OBJECT
112public:
113 DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
114 QValueList<EffectiveEvent> &ev2,
115 QDate &d, bool onM,
116 QWidget* parent = 0, const char* name = 0,
117 WFlags fl = 0 );
118signals:
119 void editEvent(const Event &e);
120 void duplicateEvent(const Event &e);
121 void removeEvent(const Event &e);
122 void beamEvent(const Event &e);
123 void redraw();
124 void showDate(int y, int m, int d);
125 void addEvent(const QDateTime &start, const QDateTime &stop,
126 const QString &str, const QString &location);
127};
128
129class DateBookWeekLst : public QWidget
130{
131 Q_OBJECT
132
133public:
134 DateBookWeekLst( bool ampm, bool onM, DateBookDBHoliday *newDB,
135 QWidget *parent = 0,
136 const char *name = 0 );
137 ~DateBookWeekLst();
138 void setDate( int y, int w );
139 void setDate(const QDate &d );
140 int week() const { return _week; };
141 QDate date();
142 QDate weekDate() const;
143
144public slots:
145 void redraw();
146 void dateChanged(QDate &date);
147
148protected slots:
149 void keyPressEvent(QKeyEvent *);
150 void setDbl(bool on);
151
152signals:
153 void showDate(int y, int m, int d);
154 void addEvent(const QDateTime &start, const QDateTime &stop,
155 const QString &str, const QString &location);
156 void editEvent(const Event &e);
157 void duplicateEvent(const Event &e);
158 void removeEvent(const Event &e);
159 void beamEvent(const Event &e);
160
161private:
162 DateBookDBHoliday *db;
163 int startTime;
164 bool ampm;
165 bool bStartOnMonday;
166 bool dbl;
167 QDate bdate;
168 int year, _week,dow;
169 DateBookWeekLstHeader *header;
170 QWidget *view;
171 QVBoxLayout *layout;
172 QScrollView *scroll;
173
174 void getEvents();
175};
176
177#endif
178
diff --git a/core/pim/datebook/modules/weeklst/.cvsignore b/core/pim/datebook/modules/weeklst/.cvsignore
new file mode 100644
index 0000000..2da0b2b
--- a/dev/null
+++ b/core/pim/datebook/modules/weeklst/.cvsignore
@@ -0,0 +1,4 @@
1datebookweeklstdayhdrbase.cpp
2datebookweeklstdayhdrbase.h
3datebookweeklstheaderbase.cpp
4datebookweeklstheaderbase.h
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklst.cpp b/core/pim/datebook/modules/weeklst/datebookweeklst.cpp
new file mode 100644
index 0000000..47bc597
--- a/dev/null
+++ b/core/pim/datebook/modules/weeklst/datebookweeklst.cpp
@@ -0,0 +1,138 @@
1#include "namespace_hack.h"
2#include "datebookweeklst.h"
3#include "datebookweeklstheader.h"
4#include "datebookweeklstview.h"
5#include "datebookweeklstdblview.h"
6
7#include "datebook.h"
8
9#include <opie2/odebug.h>
10
11#include <qpe/datebookmonth.h>
12#include <qpe/config.h>
13#include <qpe/resource.h>
14
15#include <qlayout.h>
16#include <qtoolbutton.h>
17
18using namespace Opie::Ui;
19
20DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDBHoliday *newDB,
21 QWidget *parent,
22 const char *name )
23 : QWidget( parent, name ),
24 db( newDB ),
25 startTime( 0 ),
26 ampm( ap ),
27 bStartOnMonday(onM)
28{
29 setFocusPolicy(StrongFocus);
30 layout = new QVBoxLayout( this );
31 layout->setMargin(0);
32
33 header=new DateBookWeekLstHeader(onM, this);
34 layout->addWidget( header );
35 connect(header, SIGNAL(dateChanged(QDate&)), this, SLOT(dateChanged(QDate&)));
36 connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool)));
37
38 scroll=new QScrollView(this);
39 scroll->setResizePolicy(QScrollView::AutoOneFit);
40 layout->addWidget(scroll);
41
42 view=NULL;
43 Config config("DateBook");
44 config.setGroup("Main");
45 dbl=config.readBoolEntry("weeklst_dbl", false);
46 header->dbl->setOn(dbl);
47}
48DateBookWeekLst::~DateBookWeekLst(){
49 Config config("DateBook");
50 config.setGroup("Main");
51 config.writeEntry("weeklst_dbl", dbl);
52}
53
54void DateBookWeekLst::setDate(const QDate &d) {
55 bdate=d;
56 header->setDate(d);
57}
58
59void DateBookWeekLst::setDbl(bool on) {
60 dbl=on;
61 redraw();
62}
63void DateBookWeekLst::redraw() {getEvents();}
64
65QDate DateBookWeekLst::date() {
66 return bdate;
67}
68
69// return the date at the beginning of the week...
70// copied from DateBookWeek
71QDate DateBookWeekLst::weekDate() const
72{
73 QDate d=bdate;
74
75 // Calculate offset to first day of week.
76 int dayoffset=d.dayOfWeek();
77 if(bStartOnMonday) dayoffset--;
78 else if( dayoffset == 7 )
79 dayoffset = 0;
80
81 return d.addDays(-dayoffset);
82}
83
84void DateBookWeekLst::getEvents() {
85 QDate start = weekDate(); //date();
86 QDate stop = start.addDays(6);
87 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop);
88
89 setUpdatesEnabled(false);
90 if (view) delete view;
91 if (dbl) {
92 QDate start2=start.addDays(7);
93 stop=start2.addDays(6);
94 QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop);
95 view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll);
96 } else {
97 view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll);
98 }
99
100 connect (view, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
101 connect (view, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
102 connect (view, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
103 connect (view, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
104 connect (view, SIGNAL(redraw()), this, SLOT(redraw()));
105 connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
106 connect (view, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
107 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
108
109 scroll->addChild(view);
110 view->show();
111 scroll->updateScrollBars();
112 setUpdatesEnabled(true);
113}
114
115void DateBookWeekLst::dateChanged(QDate &newdate) {
116 bdate=newdate;
117 getEvents();
118}
119
120void DateBookWeekLst::keyPressEvent(QKeyEvent *e)
121{
122 switch(e->key()) {
123 case Key_Up:
124 scroll->scrollBy(0, -20);
125 break;
126 case Key_Down:
127 scroll->scrollBy(0, 20);
128 break;
129 case Key_Left:
130 header->prevWeek();
131 break;
132 case Key_Right:
133 header->nextWeek();
134 break;
135 default:
136 e->ignore();
137 }
138}
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklst.h b/core/pim/datebook/modules/weeklst/datebookweeklst.h
new file mode 100644
index 0000000..3922fa1
--- a/dev/null
+++ b/core/pim/datebook/modules/weeklst/datebookweeklst.h
@@ -0,0 +1,65 @@
1#ifndef DATEBOOKWEEKLST
2#define DATEBOOKWEEKLST
3
4#include <qpe/event.h>
5
6#include <qwidget.h>
7#include <qdatetime.h>
8
9class DateBookDB;
10class DateBookDBHoliday;
11class DateBookWeekLstHeader;
12class DateBookWeekLstEvent;
13class DateBookWeekLstView;
14class QVBoxLayout;
15class QScrollView;
16
17class DateBookWeekLst : public QWidget
18{
19 Q_OBJECT
20
21public:
22 DateBookWeekLst( bool ampm, bool onM, DateBookDBHoliday *newDB,
23 QWidget *parent = 0,
24 const char *name = 0 );
25 ~DateBookWeekLst();
26 void setDate( int y, int w );
27 void setDate(const QDate &d );
28 int week() const { return _week; };
29 QDate date();
30 QDate weekDate() const;
31
32public slots:
33 void redraw();
34 void dateChanged(QDate &date);
35
36protected slots:
37 void keyPressEvent(QKeyEvent *);
38 void setDbl(bool on);
39
40signals:
41 void showDate(int y, int m, int d);
42 void addEvent(const QDateTime &start, const QDateTime &stop,
43 const QString &str, const QString &location);
44 void editEvent(const Event &e);
45 void duplicateEvent(const Event &e);
46 void removeEvent(const Event &e);
47 void beamEvent(const Event &e);
48
49private:
50 DateBookDBHoliday *db;
51 int startTime;
52 bool ampm;
53 bool bStartOnMonday;
54 bool dbl;
55 QDate bdate;
56 int year, _week,dow;
57 DateBookWeekLstHeader *header;
58 QWidget *view;
59 QVBoxLayout *layout;
60 QScrollView *scroll;
61
62 void getEvents();
63};
64
65#endif
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstdayhdr.cpp b/core/pim/datebook/modules/weeklst/datebookweeklstdayhdr.cpp
new file mode 100644
index 0000000..d173444
--- a/dev/null
+++ b/core/pim/datebook/modules/weeklst/datebookweeklstdayhdr.cpp
@@ -0,0 +1,53 @@
1#include "datebookweeklstdayhdr.h"
2
3#include "namespace_hack.h"
4
5DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */,
6 QWidget* parent,
7 const char* name,
8 WFlags fl )
9 : DateBookWeekLstDayHdrBase(parent, name, fl) {
10
11 date=d;
12
13 static const QString wdays=tr("MTWTFSSM", "Week days");
14 char day=wdays[d.dayOfWeek()-1];
15
16 //dont use dayOfWeek() to save space !
17 label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) );
18
19 add->setText("+");
20
21 if (d == QDate::currentDate()) {
22 QPalette pal=label->palette();
23 pal.setColor(QColorGroup::Foreground, QColor(0,0,255));
24 label->setPalette(pal);
25
26 /*
27 QFont f=label->font();
28 f.setItalic(true);
29 label->setFont(f);
30 label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor()));
31 */
32 } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday
33 QPalette pal=label->palette();
34 pal.setColor(QColorGroup::Foreground, QColor(255,0,0));
35 label->setPalette(pal);
36 }
37
38 connect (label, SIGNAL(clicked()), this, SLOT(showDay()));
39 connect (add, SIGNAL(clicked()), this, SLOT(newEvent()));
40}
41
42void DateBookWeekLstDayHdr::showDay() {
43 emit showDate(date.year(), date.month(), date.day());
44}
45
46void DateBookWeekLstDayHdr::newEvent() {
47 QDateTime start, stop;
48 start=stop=date;
49 start.setTime(QTime(10,0));
50 stop.setTime(QTime(12,0));
51
52 emit addEvent(start,stop,"",0);
53}
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstdayhdr.h b/core/pim/datebook/modules/weeklst/datebookweeklstdayhdr.h
new file mode 100644
index 0000000..de046d8
--- a/dev/null
+++ b/core/pim/datebook/modules/weeklst/datebookweeklstdayhdr.h
@@ -0,0 +1,26 @@
1#ifndef _DATEBOOKWEEKLSTDAYHDR_H
2#define _DATEBOOKWEEKLSTDAYHDR_H
3
4#include "datebookweeklstdayhdrbase.h"
5
6#include <qdatetime.h>
7
8class DateBookWeekLstDayHdr: public DateBookWeekLstDayHdrBase
9{
10 Q_OBJECT
11public:
12 DateBookWeekLstDayHdr(const QDate &d, bool onM,
13 QWidget* parent = 0, const char* name = 0,
14 WFlags fl = 0 );
15public slots:
16 void showDay();
17 void newEvent();
18signals:
19 void showDate(int y, int m, int d);
20 void addEvent(const QDateTime &start, const QDateTime &stop,
21 const QString &str, const QString &location);
22private:
23 QDate date;
24};
25
26#endif
diff --git a/core/pim/datebook/datebookweeklstdayhdr.ui b/core/pim/datebook/modules/weeklst/datebookweeklstdayhdrbase.ui
index 74ea584..74ea584 100644
--- a/core/pim/datebook/datebookweeklstdayhdr.ui
+++ b/core/pim/datebook/modules/weeklst/datebookweeklstdayhdrbase.ui
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstdblview.cpp b/core/pim/datebook/modules/weeklst/datebookweeklstdblview.cpp
new file mode 100644
index 0000000..1cea602
--- a/dev/null
+++ b/core/pim/datebook/modules/weeklst/datebookweeklstdblview.cpp
@@ -0,0 +1,41 @@
1#include "datebookweeklstdblview.h"
2#include "datebookweeklstview.h"
3
4#include <qlayout.h>
5
6DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
7 QValueList<EffectiveEvent> &ev2,
8 QDate &d, bool onM,
9 QWidget* parent,
10 const char* name, WFlags fl)
11 : QWidget( parent, name, fl )
12{
13 QHBoxLayout *layout = new QHBoxLayout( this );
14
15 DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this);
16 layout->addWidget(w);
17 connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
18 connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
19 connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
20 connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
21 connect (w, SIGNAL(redraw()), this, SIGNAL(redraw()));
22 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
23 connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
24 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
25
26
27 w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this);
28 layout->addWidget(w);
29 connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
30 connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
31 connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
32 connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
33 connect (w, SIGNAL(redraw()), this, SIGNAL(redraw()));
34 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
35 connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
36 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
37}
38
39DateBookWeekLstDblView::~DateBookWeekLstDblView()
40{
41}
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstdblview.h b/core/pim/datebook/modules/weeklst/datebookweeklstdblview.h
new file mode 100644
index 0000000..57e9690
--- a/dev/null
+++ b/core/pim/datebook/modules/weeklst/datebookweeklstdblview.h
@@ -0,0 +1,31 @@
1#ifndef _DATEBOOKWEEKLSTDBLVIEW_H
2#define _DATEBOOKWEEKLSTDBLVIEW_H
3
4#include <qpe/event.h>
5
6#include <qwidget.h>
7#include <qvaluelist.h>
8#include <qdatetime.h>
9#include <qstring.h>
10
11class DateBookWeekLstDblView: public QWidget {
12 Q_OBJECT
13public:
14 DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
15 QValueList<EffectiveEvent> &ev2,
16 QDate &d, bool onM,
17 QWidget* parent = 0, const char* name = 0,
18 WFlags fl = 0 );
19 virtual ~DateBookWeekLstDblView();
20signals:
21 void editEvent(const Event &e);
22 void duplicateEvent(const Event &e);
23 void removeEvent(const Event &e);
24 void beamEvent(const Event &e);
25 void redraw();
26 void showDate(int y, int m, int d);
27 void addEvent(const QDateTime &start, const QDateTime &stop,
28 const QString &str, const QString &location);
29};
30
31#endif
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstevent.cpp b/core/pim/datebook/modules/weeklst/datebookweeklstevent.cpp
new file mode 100644
index 0000000..797f766
--- a/dev/null
+++ b/core/pim/datebook/modules/weeklst/datebookweeklstevent.cpp
@@ -0,0 +1,85 @@
1#include "datebookweeklstevent.h"
2#include "datebooktypes.h"
3
4#include <opie2/odebug.h>
5
6#include <qpe/ir.h>
7
8#include <qstring.h>
9#include <qpopupmenu.h>
10
11DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev,
12 int weeklistviewconfig,
13 QWidget* parent,
14 const char* name,
15 WFlags fl ) : OClickableLabel(parent,name,fl), event(ev)
16{
17 // old values... lastday = "__|__", middle=" |---", Firstday="00:00",
18 QString s,start,middle,end,day;
19
20 odebug << "weeklistviewconfig=" << weeklistviewconfig << oendl;
21 if(weeklistviewconfig==NONE) { // No times displayed.
22// start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute());
23// middle.sprintf("<--->");
24// end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute());
25// day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute());
26 } else if(weeklistviewconfig==NORMAL) { // "Normal", only display start time.
27 start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute());
28 middle.sprintf(" |---");
29 end.sprintf("__|__");
30 day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute());
31 } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times.
32 start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute());
33 middle.sprintf("<--->");
34 end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute());
35 day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute());
36 }
37
38 if(ev.event().type() == Event::Normal) {
39 if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) { // day event.
40 s=day;
41 } else if(ev.startDate()==ev.date()) { // start event.
42 s=start;
43 } else if(ev.endDate()==ev.date()) { // end event.
44 s=end;
45 } else { // middle day.
46 s=middle;
47 }
48 } else {
49 s="";
50 }
51 setText(QString(s) + " " + ev.description());
52// connect(this, SIGNAL(clicked()), this, SLOT(editMe()));
53 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) );
54}
55void DateBookWeekLstEvent::editMe() {
56 emit editEvent(event.event());
57}
58void DateBookWeekLstEvent::duplicateMe()
59{
60 emit duplicateEvent(event.event());
61}
62void DateBookWeekLstEvent::deleteMe()
63{
64 emit removeEvent(event.event());
65 emit redraw();
66}
67void DateBookWeekLstEvent::beamMe()
68{
69 emit beamEvent( event.event() );
70}
71void DateBookWeekLstEvent::mousePressEvent( QMouseEvent *e )
72{
73 if (!event.event().isValidUid()) {
74 // this is just such a holiday event.
75 return;
76 }
77 popmenue = new QPopupMenu;
78
79 popmenue->insertItem( tr( "Edit" ), this, SLOT(editMe()));
80 popmenue->insertItem( tr( "Duplicate" ), this, SLOT(duplicateMe()));
81 popmenue->insertItem( tr( "Delete" ), this, SLOT(deleteMe()));
82 if(Ir::supported())
83 popmenue->insertItem( tr( "Beam" ), this, SLOT(beamMe()));
84 popmenue->popup( mapToGlobal( e->pos() ));
85}
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstevent.h b/core/pim/datebook/modules/weeklst/datebookweeklstevent.h
new file mode 100644
index 0000000..77f6283
--- a/dev/null
+++ b/core/pim/datebook/modules/weeklst/datebookweeklstevent.h
@@ -0,0 +1,34 @@
1#ifndef _DATEBOOKWEEKLSTEVENT_H
2#define _DATEBOOKWEEKLSTEVENT_H
3
4#include <opie2/oclickablelabel.h>
5
6#include <qpe/event.h>
7
8class DateBookWeekLstEvent: public Opie::Ui::OClickableLabel
9{
10 Q_OBJECT
11public:
12 DateBookWeekLstEvent(const EffectiveEvent &ev, int weeklistviewconfig =1,
13 QWidget* parent = 0, const char* name = 0,
14 WFlags fl = 0);
15signals:
16 void editEvent(const Event &e);
17 void duplicateEvent(const Event &e);
18 void removeEvent(const Event &e);
19 void beamEvent(const Event &e);
20 void redraw();
21private slots:
22 void editMe();
23 void duplicateMe();
24 void deleteMe();
25 void beamMe();
26private:
27 const EffectiveEvent event;
28 QPopupMenu* popmenue;
29protected:
30 void mousePressEvent( QMouseEvent *e );
31};
32
33
34#endif
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstheader.cpp b/core/pim/datebook/modules/weeklst/datebookweeklstheader.cpp
new file mode 100644
index 0000000..81e0c31
--- a/dev/null
+++ b/core/pim/datebook/modules/weeklst/datebookweeklstheader.cpp
@@ -0,0 +1,96 @@
1#include "datebookweeklstheader.h"
2
3#include <qpe/resource.h>
4#include <qpe/datebookmonth.h>
5
6#include <qtoolbutton.h>
7#include <qlayout.h>
8
9/* implenented in datebookweek.cpp - HELL */
10bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false);
11
12DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const char* name, WFlags fl)
13 : DateBookWeekLstHeaderBase(parent, name, fl)
14{
15 setBackgroundMode( PaletteButton );
16 labelDate->setBackgroundMode( PaletteButton );
17 forwardweek->setBackgroundMode( PaletteButton );
18 forwardweek->setPixmap( Resource::loadPixmap("forward") );
19 forwardmonth->setBackgroundMode( PaletteButton );
20 forwardmonth->setPixmap( Resource::loadPixmap("fastforward") );
21 backweek->setBackgroundMode( PaletteButton );
22 backweek->setPixmap( Resource::loadPixmap("back") );
23 backmonth->setBackgroundMode( PaletteButton );
24 backmonth->setPixmap( Resource::loadPixmap("fastback") );
25 DateBookWeekLstHeaderBaseLayout->setSpacing(0);
26 DateBookWeekLstHeaderBaseLayout->setMargin(0);
27 //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding));
28 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
29
30 connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth()));
31 connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek()));
32 connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek()));
33 connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth()));
34 connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate()));
35 connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool)));
36 bStartOnMonday=onM;
37}
38DateBookWeekLstHeader::~DateBookWeekLstHeader(){}
39
40void DateBookWeekLstHeader::setDate(const QDate &d) {
41 int year,week,dayofweek;
42 date=d;
43 dayofweek=d.dayOfWeek();
44 if(bStartOnMonday)
45 dayofweek--;
46 else if( dayofweek == 7 )
47 /* we already have the right day -7 would lead to the same week */
48 dayofweek = 0;
49
50 date=date.addDays(-dayofweek);
51
52 calcWeek(date,week,year,bStartOnMonday);
53 QDate start=date;
54 QDate stop=start.addDays(6);
55 labelDate->setText( QString::number(start.day()) + "." +
56 Calendar::nameOfMonth( start.month() ) + "-" +
57 QString::number(stop.day()) + "." +
58 Calendar::nameOfMonth( stop.month()) +" ("+
59 tr("w")+":"+QString::number( week ) +")");
60 date = d; // bugfix: 0001126 - date has to be the selected date, not monday!
61 emit dateChanged(date);
62}
63
64void DateBookWeekLstHeader::pickDate() {
65 static QPopupMenu *m1 = 0;
66 static DateBookMonth *picker = 0;
67 if ( !m1 ) {
68 m1 = new QPopupMenu( this );
69 picker = new DateBookMonth( m1, 0, TRUE );
70 m1->insertItem( picker );
71 connect( picker, SIGNAL( dateClicked(int,int,int) ),this, SLOT( setDate(int,int,int) ) );
72 //connect( m1, SIGNAL( aboutToHide() ),
73 //this, SLOT( gotHide() ) );
74 }
75 picker->setDate( date.year(), date.month(), date.day() );
76 m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height())));
77 picker->setFocus();
78}
79void DateBookWeekLstHeader::setDate(int y, int m, int d) {
80 setDate(QDate(y,m,d));
81}
82
83void DateBookWeekLstHeader::nextWeek() {
84 setDate(date.addDays(7));
85}
86void DateBookWeekLstHeader::prevWeek() {
87 setDate(date.addDays(-7));
88}
89void DateBookWeekLstHeader::nextMonth()
90{
91 setDate(date.addDays(28));
92}
93void DateBookWeekLstHeader::prevMonth()
94{
95 setDate(date.addDays(-28));
96}
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstheader.h b/core/pim/datebook/modules/weeklst/datebookweeklstheader.h
new file mode 100644
index 0000000..818b825
--- a/dev/null
+++ b/core/pim/datebook/modules/weeklst/datebookweeklstheader.h
@@ -0,0 +1,34 @@
1#ifndef _DATEBOOKWEEKLSTHEADER_H
2#define _DATEBOOKWEEKLSTHEADER_H
3
4#include "datebookweeklstheaderbase.h"
5
6#include <qdatetime.h>
7
8class DateBookWeekLstHeader: public DateBookWeekLstHeaderBase
9{
10 Q_OBJECT
11public:
12 DateBookWeekLstHeader(bool onM, QWidget* parent = 0, const char* name = 0,
13 WFlags fl = 0 );
14 ~DateBookWeekLstHeader();
15 void setDate(const QDate &d);
16
17public slots:
18 void nextWeek();
19 void prevWeek();
20 void nextMonth();
21 void prevMonth();
22 void pickDate();
23 void setDate(int y, int m, int d);
24signals:
25 void dateChanged(QDate &newdate);
26 void setDbl(bool on);
27protected:
28 QDate date;
29// bool onMonday;
30 bool bStartOnMonday;
31
32};
33
34#endif
diff --git a/core/pim/datebook/datebookweeklstheader.ui b/core/pim/datebook/modules/weeklst/datebookweeklstheaderbase.ui
index e925ec3..e925ec3 100644
--- a/core/pim/datebook/datebookweeklstheader.ui
+++ b/core/pim/datebook/modules/weeklst/datebookweeklstheaderbase.ui
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstview.cpp b/core/pim/datebook/modules/weeklst/datebookweeklstview.cpp
new file mode 100644
index 0000000..efb4c01
--- a/dev/null
+++ b/core/pim/datebook/modules/weeklst/datebookweeklstview.cpp
@@ -0,0 +1,73 @@
1#include "datebookweeklstview.h"
2#include "datebooktypes.h"
3#include "datebookweeklstdayhdr.h"
4#include "datebookweeklstheader.h"
5#include "datebookweeklstevent.h"
6
7#include <opie2/odebug.h>
8
9#include <qpe/config.h>
10
11#include <qlayout.h>
12#include <qtl.h>
13
14DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
15 const QDate &d, bool onM,
16 QWidget* parent,
17 const char* name, WFlags fl)
18 : QWidget( parent, name, fl )
19{
20 Config config("DateBook");
21 config.setGroup("Main");
22 int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL);
23 odebug << "weeklistviewconfig: " << weeklistviewconfig << oendl;
24
25 bStartOnMonday=onM;
26 setPalette(white);
27 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
28
29 QVBoxLayout *layout = new QVBoxLayout( this );
30
31 qBubbleSort(ev);
32 QValueListIterator<EffectiveEvent> it;
33 it=ev.begin();
34
35 int dayOrder[7];
36 if (bStartOnMonday) {
37 for (int d=0; d<7; d++) dayOrder[d]=d+1;
38 } else {
39 for (int d=0; d<7; d++) dayOrder[d]=d;
40 dayOrder[0]=7;
41 }
42
43 // Calculate offset to first day of week.
44 int dayoffset=d.dayOfWeek();
45 if(bStartOnMonday) dayoffset--;
46 else if( dayoffset == 7 ) dayoffset = 0;
47
48 for (int i=0; i<7; i++) {
49 // Header
50 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this);
51 connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
52 connect(hdr, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
53 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
54 layout->addWidget(hdr);
55
56 // Events
57 while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) {
58 if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) { // Skip events ending at 00:00 starting at another day.
59 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this);
60 layout->addWidget(l);
61 connect (l, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
62 connect (l, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
63 connect (l, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
64 connect (l, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
65 connect (l, SIGNAL(redraw()), this, SIGNAL(redraw()));
66 }
67 it++;
68 }
69 layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding));
70 }
71}
72DateBookWeekLstView::~DateBookWeekLstView(){}
73void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();}
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstview.h b/core/pim/datebook/modules/weeklst/datebookweeklstview.h
new file mode 100644
index 0000000..2428f1f
--- a/dev/null
+++ b/core/pim/datebook/modules/weeklst/datebookweeklstview.h
@@ -0,0 +1,36 @@
1#ifndef _DATEBOOKWEEKLISTVIEW_H
2#define _DATEBOOKWEEKLISTVIEW_H
3
4#include <qpe/event.h>
5
6#include <qwidget.h>
7#include <qvaluelist.h>
8#include <qstring.h>
9#include <qdatetime.h>
10
11class QKeyEvent;
12
13class DateBookWeekLstView: public QWidget
14{
15 Q_OBJECT
16public:
17 DateBookWeekLstView(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM,
18 QWidget* parent = 0, const char* name = 0,
19 WFlags fl = 0 );
20 ~DateBookWeekLstView();
21signals:
22 void editEvent(const Event &e);
23 void duplicateEvent(const Event &e);
24 void removeEvent(const Event &e);
25 void beamEvent(const Event &e);
26 void redraw();
27 void showDate(int y, int m, int d);
28 void addEvent(const QDateTime &start, const QDateTime &stop,
29 const QString &str, const QString &location);
30private:
31 bool bStartOnMonday;
32protected slots:
33 void keyPressEvent(QKeyEvent *);
34};
35
36#endif