summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp7
-rw-r--r--core/pim/datebook/datebook.h3
-rw-r--r--core/pim/datebook/datebookday.cpp863
-rw-r--r--core/pim/datebook/datebookday.h25
4 files changed, 469 insertions, 429 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index 4fbcb10..6dd8918 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -1,1042 +1,1049 @@
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 "datebookweeklst.h"
30#include "dateentryimpl.h" 30#include "dateentryimpl.h"
31 31
32#include <qpe/datebookmonth.h> 32#include <qpe/datebookmonth.h>
33#include <qpe/qpeapplication.h> 33#include <qpe/qpeapplication.h>
34#include <qpe/config.h> 34#include <qpe/config.h>
35#include <qpe/qpedebug.h> 35#include <qpe/qpedebug.h>
36#include <qpe/event.h> 36#include <qpe/event.h>
37#include <qpe/finddialog.h> 37#include <qpe/finddialog.h>
38#include <qpe/ir.h> 38#include <qpe/ir.h>
39#include <qpe/qpemenubar.h> 39#include <qpe/qpemenubar.h>
40#include <qpe/qpemessagebox.h> 40#include <qpe/qpemessagebox.h>
41#include <qpe/resource.h> 41#include <qpe/resource.h>
42#include <qpe/sound.h> 42#include <qpe/sound.h>
43#include <qpe/timestring.h> 43#include <qpe/timestring.h>
44#include <qpe/qpetoolbar.h> 44#include <qpe/qpetoolbar.h>
45#include <qpe/tzselect.h> 45#include <qpe/tzselect.h>
46#include <qpe/xmlreader.h> 46#include <qpe/xmlreader.h>
47 47
48#include <qaction.h> 48#include <qaction.h>
49#include <qcopchannel_qws.h> 49#include <qcopchannel_qws.h>
50#include <qdatetime.h> 50#include <qdatetime.h>
51#include <qdialog.h> 51#include <qdialog.h>
52#include <qfile.h> 52#include <qfile.h>
53#include <qlabel.h> 53#include <qlabel.h>
54#include <qlayout.h> 54#include <qlayout.h>
55#include <qmessagebox.h> 55#include <qmessagebox.h>
56#include <qpopupmenu.h> 56#include <qpopupmenu.h>
57#include <qpushbutton.h> 57#include <qpushbutton.h>
58#include <qregexp.h> 58#include <qregexp.h>
59#include <qtextcodec.h> 59#include <qtextcodec.h>
60#include <qtextstream.h> 60#include <qtextstream.h>
61#include <qtimer.h> 61#include <qtimer.h>
62#include <qtl.h> 62#include <qtl.h>
63#include <qwidgetstack.h> 63#include <qwidgetstack.h>
64#include <qwindowsystem_qws.h> 64#include <qwindowsystem_qws.h>
65 65
66#include <sys/stat.h> 66#include <sys/stat.h>
67#include <sys/types.h> 67#include <sys/types.h>
68#include <fcntl.h> 68#include <fcntl.h>
69#include <unistd.h> 69#include <unistd.h>
70 70
71#include <stdlib.h> 71#include <stdlib.h>
72 72
73DateBook::DateBook( QWidget *parent, const char *, WFlags f ) 73DateBook::DateBook( QWidget *parent, const char *, WFlags f )
74 : QMainWindow( parent, "datebook", f ), 74 : QMainWindow( parent, "datebook", f ),
75 aPreset( FALSE ), 75 aPreset( FALSE ),
76 presetTime( -1 ), 76 presetTime( -1 ),
77 startTime( 8 ), // an acceptable default 77 startTime( 8 ), // an acceptable default
78 rowStyle( 0 ), 78 rowStyle( 0 ),
79 bJumpToCurTime(FALSE), 79 bJumpToCurTime(FALSE),
80 syncing(FALSE), 80 syncing(FALSE),
81 inSearch(FALSE), 81 inSearch(FALSE),
82 alarmCounter(0) 82 alarmCounter(0)
83{ 83{
84 bool needEvilHack= false; // if we need an Evil Hack 84 bool needEvilHack= false; // if we need an Evil Hack
85 QTime t; 85 QTime t;
86 t.start(); 86 t.start();
87 db = new DateBookDBHack; 87 db = new DateBookDBHack;
88 qDebug("loading db t=%d", t.elapsed() ); 88 qDebug("loading db t=%d", t.elapsed() );
89 loadSettings(); 89 loadSettings();
90 setCaption( tr("Calendar") ); 90 setCaption( tr("Calendar") );
91 setIcon( Resource::loadPixmap( "datebook_icon" ) ); 91 setIcon( Resource::loadPixmap( "datebook_icon" ) );
92 92
93 setToolBarsMovable( FALSE ); 93 setToolBarsMovable( FALSE );
94 94
95 views = new QWidgetStack( this ); 95 views = new QWidgetStack( this );
96 setCentralWidget( views ); 96 setCentralWidget( views );
97 97
98 dayView = 0; 98 dayView = 0;
99 weekView = 0; 99 weekView = 0;
100 weekLstView = 0; 100 weekLstView = 0;
101 monthView = 0; 101 monthView = 0;
102 102
103 QPEToolBar *bar = new QPEToolBar( this ); 103 QPEToolBar *bar = new QPEToolBar( this );
104 bar->setHorizontalStretchable( TRUE ); 104 bar->setHorizontalStretchable( TRUE );
105 105
106 QPEMenuBar *mb = new QPEMenuBar( bar ); 106 QPEMenuBar *mb = new QPEMenuBar( bar );
107 mb->setMargin( 0 ); 107 mb->setMargin( 0 );
108 108
109 QPEToolBar *sub_bar = new QPEToolBar(this); 109 QPEToolBar *sub_bar = new QPEToolBar(this);
110 110
111 QPopupMenu *view = new QPopupMenu( this ); 111 QPopupMenu *view = new QPopupMenu( this );
112 QPopupMenu *settings = new QPopupMenu( this ); 112 QPopupMenu *settings = new QPopupMenu( this );
113 113
114 mb->insertItem( tr( "View" ), view ); 114 mb->insertItem( tr( "View" ), view );
115 mb->insertItem( tr( "Settings" ), settings ); 115 mb->insertItem( tr( "Settings" ), settings );
116 116
117 QActionGroup *g = new QActionGroup( this ); 117 QActionGroup *g = new QActionGroup( this );
118 g->setExclusive( TRUE ); 118 g->setExclusive( TRUE );
119 119
120 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), 120 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ),
121 QString::null, 0, this, 0 ); 121 QString::null, 0, this, 0 );
122 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 122 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
123 a->addTo( sub_bar ); 123 a->addTo( sub_bar );
124 124
125 a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 ); 125 a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 );
126 connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); 126 connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) );
127 a->addTo( sub_bar ); 127 a->addTo( sub_bar );
128 a->addTo( view ); 128 a->addTo( view );
129 129
130 a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); 130 a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 );
131 connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); 131 connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) );
132 a->addTo( sub_bar ); 132 a->addTo( sub_bar );
133 a->addTo( view ); 133 a->addTo( view );
134 a->setToggleAction( TRUE ); 134 a->setToggleAction( TRUE );
135 a->setOn( TRUE ); 135 a->setOn( TRUE );
136 dayAction = a; 136 dayAction = a;
137 137
138 a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); 138 a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 );
139 connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); 139 connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) );
140 a->addTo( sub_bar ); 140 a->addTo( sub_bar );
141 a->addTo( view ); 141 a->addTo( view );
142 a->setToggleAction( TRUE ); 142 a->setToggleAction( TRUE );
143 weekAction = a; 143 weekAction = a;
144 144
145 a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 ); 145 a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 );
146 connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); 146 connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) );
147 a->addTo( sub_bar ); 147 a->addTo( sub_bar );
148 a->addTo( view ); 148 a->addTo( view );
149 a->setToggleAction( TRUE ); 149 a->setToggleAction( TRUE );
150 weekLstAction = a; 150 weekLstAction = a;
151 151
152 a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); 152 a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 );
153 connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); 153 connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) );
154 a->addTo( sub_bar ); 154 a->addTo( sub_bar );
155 a->addTo( view ); 155 a->addTo( view );
156 a->setToggleAction( TRUE ); 156 a->setToggleAction( TRUE );
157 monthAction = a; 157 monthAction = a;
158 158
159 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, g, 0 ); 159 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, g, 0 );
160 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); 160 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) );
161 a->addTo( sub_bar ); 161 a->addTo( sub_bar );
162 162
163 a = new QAction( tr( "Edit..." ), QString::null, 0, 0 ); 163 a = new QAction( tr( "Edit..." ), QString::null, 0, 0 );
164 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); 164 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
165 a->addTo( settings ); 165 a->addTo( settings );
166 166
167 if(defaultView==DAY) viewDay(); 167 if(defaultView==DAY) viewDay();
168 if(defaultView==WEEK) needEvilHack=true;// viewWeek(); 168 if(defaultView==WEEK) needEvilHack=true;// viewWeek();
169 if(defaultView==WEEKLST) viewWeekLst(); 169 if(defaultView==WEEKLST) viewWeekLst();
170 if(defaultView==MONTH) viewMonth(); 170 if(defaultView==MONTH) viewMonth();
171 171
172 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); 172 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) );
173 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) ); 173 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) );
174 174
175#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 175#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
176 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&)) );
177#endif 177#endif
178 178
179 // listen on QPE/System 179 // listen on QPE/System
180#if defined(Q_WS_QWS) 180#if defined(Q_WS_QWS)
181#if !defined(QT_NO_COP) 181#if !defined(QT_NO_COP)
182 QCopChannel *channel = new QCopChannel( "QPE/System", this ); 182 QCopChannel *channel = new QCopChannel( "QPE/System", this );
183 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&)) );
184 channel = new QCopChannel( "QPE/Datebook", this ); 184 channel = new QCopChannel( "QPE/Datebook", this );
185 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&)) );
186 qDebug("olle\n"); 186 qDebug("olle\n");
187#endif 187#endif
188#endif 188#endif
189 189
190 qDebug("done t=%d", t.elapsed() ); 190 qDebug("done t=%d", t.elapsed() );
191 191
192 /* 192 /*
193 * Here is a problem description: 193 * Here is a problem description:
194 * When Weekview is the default view 194 * When Weekview is the default view
195 * a DateBookWeekView get's created 195 * a DateBookWeekView get's created
196 * redraw() get's called. So what? 196 * redraw() get's called. So what?
197 * Remember that we're still in the c'tor 197 * Remember that we're still in the c'tor
198 * and no final layout has happened? Ok 198 * and no final layout has happened? Ok
199 * now all Events get arranged. Their x 199 * now all Events get arranged. Their x
200 * position get's determined by a QHeader 200 * position get's determined by a QHeader
201 * position. But the QHeader isn't layouted or 201 * position. But the QHeader isn't layouted or
202 * at the right position. redraw() is a slot 202 * at the right position. redraw() is a slot
203 * so we'll call it then via a singleShot 203 * so we'll call it then via a singleShot
204 * from view() 204 * from view()
205 */ 205 */
206 if( needEvilHack ){ 206 if( needEvilHack ){
207 QTimer::singleShot( 500, this, SLOT(viewWeek()) ); 207 QTimer::singleShot( 500, this, SLOT(viewWeek()) );
208 } 208 }
209} 209}
210 210
211void DateBook::receive( const QCString &msg, const QByteArray &data ) 211void DateBook::receive( const QCString &msg, const QByteArray &data )
212{ 212{
213 QDataStream stream( data, IO_ReadOnly ); 213 QDataStream stream( data, IO_ReadOnly );
214 if ( msg == "timeChange(QString)" ) { 214 if ( msg == "timeChange(QString)" ) {
215 // update active view! 215 // update active view!
216 if ( dayAction->isOn() ) 216 if ( dayAction->isOn() )
217 viewDay(); 217 viewDay();
218 else if ( weekAction->isOn() ) 218 else if ( weekAction->isOn() )
219 viewWeek(); 219 viewWeek();
220 else if ( monthAction->isOn() ) 220 else if ( monthAction->isOn() )
221 viewMonth(); 221 viewMonth();
222 } 222 }
223 else if (msg == "editEvent(int)") { 223 else if (msg == "editEvent(int)") {
224 int uid; 224 int uid;
225 stream >> uid; 225 stream >> uid;
226 Event e=db->eventByUID(uid); 226 Event e=db->eventByUID(uid);
227 editEvent(e); 227 editEvent(e);
228 } 228 }
229} 229}
230 230
231DateBook::~DateBook() 231DateBook::~DateBook()
232{ 232{
233} 233}
234 234
235void DateBook::slotSettings() 235void DateBook::slotSettings()
236{ 236{
237 DateBookSettings frmSettings( ampm, this ); 237 DateBookSettings frmSettings( ampm, this );
238 frmSettings.setStartTime( startTime ); 238 frmSettings.setStartTime( startTime );
239 frmSettings.setAlarmPreset( aPreset, presetTime ); 239 frmSettings.setAlarmPreset( aPreset, presetTime );
240 frmSettings.setJumpToCurTime( bJumpToCurTime ); 240 frmSettings.setJumpToCurTime( bJumpToCurTime );
241 frmSettings.setRowStyle( rowStyle ); 241 frmSettings.setRowStyle( rowStyle );
242 frmSettings.comboDefaultView->setCurrentItem(defaultView-1); 242 frmSettings.comboDefaultView->setCurrentItem(defaultView-1);
243 frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig); 243 frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig);
244 244
245#if defined (Q_WS_QWS) || defined(_WS_QWS_) 245#if defined (Q_WS_QWS) || defined(_WS_QWS_)
246 frmSettings.showMaximized(); 246 frmSettings.showMaximized();
247#endif 247#endif
248 248
249 if ( frmSettings.exec() ) { 249 if ( frmSettings.exec() ) {
250 250
251 aPreset = frmSettings.alarmPreset(); 251 aPreset = frmSettings.alarmPreset();
252 presetTime = frmSettings.presetTime(); 252 presetTime = frmSettings.presetTime();
253 startTime = frmSettings.startTime(); 253 startTime = frmSettings.startTime();
254 bJumpToCurTime = frmSettings.jumpToCurTime(); 254 bJumpToCurTime = frmSettings.jumpToCurTime();
255 rowStyle = frmSettings.rowStyle(); 255 rowStyle = frmSettings.rowStyle();
256 defaultView=frmSettings.comboDefaultView->currentItem()+1; 256 defaultView=frmSettings.comboDefaultView->currentItem()+1;
257 weeklistviewconfig=frmSettings.comboWeekListView->currentItem(); 257 weeklistviewconfig=frmSettings.comboWeekListView->currentItem();
258 258
259 if ( dayView ) { 259 if ( dayView ) {
260 dayView->setStartViewTime( startTime ); 260 dayView->setStartViewTime( startTime );
261 dayView->setJumpToCurTime( bJumpToCurTime ); 261 dayView->setJumpToCurTime( bJumpToCurTime );
262 dayView->setRowStyle( rowStyle ); 262 dayView->setRowStyle( rowStyle );
263 } 263 }
264 if ( weekView ) { 264 if ( weekView ) {
265 weekView->setStartViewTime( startTime ); 265 weekView->setStartViewTime( startTime );
266 } 266 }
267 saveSettings(); 267 saveSettings();
268 268
269 // make the change obvious 269 // make the change obvious
270 if ( views->visibleWidget() ) { 270 if ( views->visibleWidget() ) {
271 if ( views->visibleWidget() == dayView ) 271 if ( views->visibleWidget() == dayView )
272 dayView->redraw(); 272 dayView->redraw();
273 else if ( views->visibleWidget() == weekView ) 273 else if ( views->visibleWidget() == weekView )
274 weekView->redraw(); 274 weekView->redraw();
275 else if ( views->visibleWidget() == weekLstView ) 275 else if ( views->visibleWidget() == weekLstView )
276 weekLstView->redraw(); 276 weekLstView->redraw();
277 } 277 }
278 } 278 }
279} 279}
280 280
281void DateBook::fileNew() 281void DateBook::fileNew()
282{ 282{
283 slotNewEventFromKey(""); 283 slotNewEventFromKey("");
284} 284}
285 285
286QString DateBook::checkEvent(const Event &e) 286QString DateBook::checkEvent(const Event &e)
287{ 287{
288 /* check if overlaps with itself */ 288 /* check if overlaps with itself */
289 bool checkFailed = FALSE; 289 bool checkFailed = FALSE;
290 290
291 /* check the next 12 repeats. should catch most problems */ 291 /* check the next 12 repeats. should catch most problems */
292 QDate current_date = e.start().date(); 292 QDate current_date = e.start().date();
293 Event previous = e; 293 Event previous = e;
294 for(int i = 0; i < 12; i++) 294 for(int i = 0; i < 12; i++)
295 { 295 {
296 QDateTime next; 296 QDateTime next;
297 if (!nextOccurance(previous, current_date.addDays(1), next)) { 297 if (!nextOccurance(previous, current_date.addDays(1), next)) {
298 break; // no more repeats 298 break; // no more repeats
299 } 299 }
300 if(next < previous.end()) { 300 if(next < previous.end()) {
301 checkFailed = TRUE; 301 checkFailed = TRUE;
302 break; 302 break;
303 } 303 }
304 current_date = next.date(); 304 current_date = next.date();
305 } 305 }
306 306
307 if(checkFailed) 307 if(checkFailed)
308 return tr("Event duration is potentially longer\n" 308 return tr("Event duration is potentially longer\n"
309 "than interval between repeats."); 309 "than interval between repeats.");
310 310
311 return QString::null; 311 return QString::null;
312} 312}
313 313
314QDate DateBook::currentDate() 314QDate DateBook::currentDate()
315{ 315{
316 QDate d = QDate::currentDate(); 316 QDate d = QDate::currentDate();
317 317
318 if ( dayView && views->visibleWidget() == dayView ) { 318 if ( dayView && views->visibleWidget() == dayView ) {
319 d = dayView->date(); 319 d = dayView->date();
320 } else if ( weekView && views->visibleWidget() == weekView ) { 320 } else if ( weekView && views->visibleWidget() == weekView ) {
321 d = weekView->date(); 321 d = weekView->date();
322 } else if ( weekLstView && views->visibleWidget() == weekLstView ) { 322 } else if ( weekLstView && views->visibleWidget() == weekLstView ) {
323 d = weekLstView->date(); 323 d = weekLstView->date();
324 } else if ( monthView && views->visibleWidget() == monthView ) { 324 } else if ( monthView && views->visibleWidget() == monthView ) {
325 d = monthView->selectedDate(); 325 d = monthView->selectedDate();
326 } 326 }
327 327
328 return d; 328 return d;
329} 329}
330 330
331void DateBook::view(int v, const QDate &d) { 331void DateBook::view(int v, const QDate &d) {
332 if (v==DAY) { 332 if (v==DAY) {
333 initDay(); 333 initDay();
334 dayAction->setOn( TRUE ); 334 dayAction->setOn( TRUE );
335 dayView->setDate( d ); 335 dayView->setDate( d );
336 views->raiseWidget( dayView ); 336 views->raiseWidget( dayView );
337 dayView->redraw(); 337 dayView->redraw();
338 } else if (v==WEEK) { 338 } else if (v==WEEK) {
339 initWeek(); 339 initWeek();
340 weekAction->setOn( TRUE ); 340 weekAction->setOn( TRUE );
341 weekView->setDate( d ); 341 weekView->setDate( d );
342 views->raiseWidget( weekView ); 342 views->raiseWidget( weekView );
343 weekView->redraw(); 343 weekView->redraw();
344 } else if (v==WEEKLST) { 344 } else if (v==WEEKLST) {
345 initWeekLst(); 345 initWeekLst();
346 weekLstAction->setOn( TRUE ); 346 weekLstAction->setOn( TRUE );
347 weekLstView->setDate(d); 347 weekLstView->setDate(d);
348 views->raiseWidget( weekLstView ); 348 views->raiseWidget( weekLstView );
349 weekLstView->redraw(); 349 weekLstView->redraw();
350 } else if (v==MONTH) { 350 } else if (v==MONTH) {
351 initMonth(); 351 initMonth();
352 monthAction->setOn( TRUE ); 352 monthAction->setOn( TRUE );
353 monthView->setDate( d.year(), d.month(), d.day() ); 353 monthView->setDate( d.year(), d.month(), d.day() );
354 views->raiseWidget( monthView ); 354 views->raiseWidget( monthView );
355 monthView->redraw(); 355 monthView->redraw();
356 } 356 }
357} 357}
358 358
359void DateBook::viewDefault(const QDate &d) { 359void DateBook::viewDefault(const QDate &d) {
360/* 360/*
361 Config config("DateBook"); 361 Config config("DateBook");
362 config.setGroup("Main"); 362 config.setGroup("Main");
363 int current=config.readNumEntry("defaultview", DAY); 363 int current=config.readNumEntry("defaultview", DAY);
364 364
365 view(current,d); 365 view(current,d);
366*/ 366*/
367 view(defaultView,d); 367 view(defaultView,d);
368} 368}
369 369
370void DateBook::viewDay() { 370void DateBook::viewDay() {
371 view(DAY,currentDate()); 371 view(DAY,currentDate());
372} 372}
373 373
374void DateBook::viewWeek() { 374void DateBook::viewWeek() {
375 view(WEEK,currentDate()); 375 view(WEEK,currentDate());
376} 376}
377 377
378void DateBook::viewWeekLst() { 378void DateBook::viewWeekLst() {
379 view(WEEKLST,currentDate()); 379 view(WEEKLST,currentDate());
380} 380}
381 381
382void DateBook::viewMonth() { 382void DateBook::viewMonth() {
383 view(MONTH,currentDate()); 383 view(MONTH,currentDate());
384} 384}
385 385
386void DateBook::insertEvent( const Event &e )
387{
388 qWarning("Adding Event!");
389 db->addEvent(e);
390 emit newEvent();
391}
392
386void DateBook::duplicateEvent( const Event &e ) 393void DateBook::duplicateEvent( const Event &e )
387{ 394{
388 qWarning("Hmmm..."); 395 qWarning("Hmmm...");
389 // Alot of code duplication, as this is almost like editEvent(); 396 // Alot of code duplication, as this is almost like editEvent();
390 if (syncing) { 397 if (syncing) {
391 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); 398 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
392 return; 399 return;
393 } 400 }
394 401
395 Event dupevent(e);// Make a duplicate. 402 Event dupevent(e);// Make a duplicate.
396 403
397 // workaround added for text input. 404 // workaround added for text input.
398 QDialog editDlg( this, 0, TRUE ); 405 QDialog editDlg( this, 0, TRUE );
399 DateEntry *entry; 406 DateEntry *entry;
400 editDlg.setCaption( tr("Duplicate Event") ); 407 editDlg.setCaption( tr("Duplicate Event") );
401 QVBoxLayout *vb = new QVBoxLayout( &editDlg ); 408 QVBoxLayout *vb = new QVBoxLayout( &editDlg );
402 QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); 409 QScrollView *sv = new QScrollView( &editDlg, "scrollview" );
403 sv->setResizePolicy( QScrollView::AutoOneFit ); 410 sv->setResizePolicy( QScrollView::AutoOneFit );
404 // KLUDGE!!! 411 // KLUDGE!!!
405 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 412 sv->setHScrollBarMode( QScrollView::AlwaysOff );
406 vb->addWidget( sv ); 413 vb->addWidget( sv );
407 entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" ); 414 entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" );
408 entry->timezone->setEnabled( FALSE ); 415 entry->timezone->setEnabled( FALSE );
409 sv->addChild( entry ); 416 sv->addChild( entry );
410 417
411#if defined(Q_WS_QWS) || defined(_WS_QWS_) 418#if defined(Q_WS_QWS) || defined(_WS_QWS_)
412 editDlg.showMaximized(); 419 editDlg.showMaximized();
413#endif 420#endif
414 while (editDlg.exec() ) { 421 while (editDlg.exec() ) {
415 Event newEv = entry->event(); 422 Event newEv = entry->event();
416 QString error = checkEvent(newEv); 423 QString error = checkEvent(newEv);
417 if (!error.isNull()) { 424 if (!error.isNull()) {
418 if (QMessageBox::warning(this, "error box", error, "Fix it", "Continue", 0, 0, 1) == 0) 425 if (QMessageBox::warning(this, "error box", error, "Fix it", "Continue", 0, 0, 1) == 0)
419 continue; 426 continue;
420 } 427 }
421 db->addEvent(newEv); 428 db->addEvent(newEv);
422 emit newEvent(); 429 emit newEvent();
423 break; 430 break;
424 } 431 }
425} 432}
426 433
427void DateBook::editEvent( const Event &e ) 434void DateBook::editEvent( const Event &e )
428{ 435{
429 if (syncing) { 436 if (syncing) {
430 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); 437 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
431 return; 438 return;
432 } 439 }
433 440
434 // workaround added for text input. 441 // workaround added for text input.
435 QDialog editDlg( this, 0, TRUE ); 442 QDialog editDlg( this, 0, TRUE );
436 DateEntry *entry; 443 DateEntry *entry;
437 editDlg.setCaption( tr("Edit Event") ); 444 editDlg.setCaption( tr("Edit Event") );
438 QVBoxLayout *vb = new QVBoxLayout( &editDlg ); 445 QVBoxLayout *vb = new QVBoxLayout( &editDlg );
439 QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); 446 QScrollView *sv = new QScrollView( &editDlg, "scrollview" );
440 sv->setResizePolicy( QScrollView::AutoOneFit ); 447 sv->setResizePolicy( QScrollView::AutoOneFit );
441 // KLUDGE!!! 448 // KLUDGE!!!
442 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 449 sv->setHScrollBarMode( QScrollView::AlwaysOff );
443 vb->addWidget( sv ); 450 vb->addWidget( sv );
444 entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" ); 451 entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" );
445 entry->timezone->setEnabled( FALSE ); 452 entry->timezone->setEnabled( FALSE );
446 sv->addChild( entry ); 453 sv->addChild( entry );
447 454
448#if defined(Q_WS_QWS) || defined(_WS_QWS_) 455#if defined(Q_WS_QWS) || defined(_WS_QWS_)
449 editDlg.showMaximized(); 456 editDlg.showMaximized();
450#endif 457#endif
451 while (editDlg.exec() ) { 458 while (editDlg.exec() ) {
452 Event newEv = entry->event(); 459 Event newEv = entry->event();
453 if(newEv.description().isEmpty() && newEv.notes().isEmpty() ) 460 if(newEv.description().isEmpty() && newEv.notes().isEmpty() )
454 break; 461 break;
455 newEv.setUid(e.uid()); // FIXME: Hack not to clear uid 462 newEv.setUid(e.uid()); // FIXME: Hack not to clear uid
456 QString error = checkEvent(newEv); 463 QString error = checkEvent(newEv);
457 if (!error.isNull()) { 464 if (!error.isNull()) {
458 if (QMessageBox::warning(this, "error box", error, "Fix it", "Continue", 0, 0, 1) == 0) continue; 465 if (QMessageBox::warning(this, "error box", error, "Fix it", "Continue", 0, 0, 1) == 0) continue;
459 } 466 }
460 db->editEvent(e, newEv); 467 db->editEvent(e, newEv);
461 emit newEvent(); 468 emit newEvent();
462 break; 469 break;
463 } 470 }
464} 471}
465 472
466void DateBook::removeEvent( const Event &e ) 473void DateBook::removeEvent( const Event &e )
467{ 474{
468 if (syncing) { 475 if (syncing) {
469 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); 476 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
470 return; 477 return;
471 } 478 }
472 479
473 QString strName = e.description(); 480 QString strName = e.description();
474 481
475 if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) 482 if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) )
476 return; 483 return;
477 484
478 db->removeEvent( e ); 485 db->removeEvent( e );
479 if ( views->visibleWidget() == dayView && dayView ) 486 if ( views->visibleWidget() == dayView && dayView )
480 dayView->redraw(); 487 dayView->redraw();
481} 488}
482 489
483void DateBook::addEvent( const Event &e ) 490void DateBook::addEvent( const Event &e )
484{ 491{
485 QDate d = e.start().date(); 492 QDate d = e.start().date();
486 initDay(); 493 initDay();
487 dayView->setDate( d ); 494 dayView->setDate( d );
488} 495}
489 496
490void DateBook::showDay( int year, int month, int day ) 497void DateBook::showDay( int year, int month, int day )
491{ 498{
492 QDate d(year, month, day); 499 QDate d(year, month, day);
493 view(DAY,d); 500 view(DAY,d);
494} 501}
495 502
496void DateBook::initDay() 503void DateBook::initDay()
497{ 504{
498 if ( !dayView ) { 505 if ( !dayView ) {
499 dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); 506 dayView = new DateBookDay( ampm, onMonday, db, views, "day view" );
500 views->addWidget( dayView, DAY ); 507 views->addWidget( dayView, DAY );
501 dayView->setStartViewTime( startTime ); 508 dayView->setStartViewTime( startTime );
502 dayView->setJumpToCurTime( bJumpToCurTime ); 509 dayView->setJumpToCurTime( bJumpToCurTime );
503 dayView->setRowStyle( rowStyle ); 510 dayView->setRowStyle( rowStyle );
504 connect( this, SIGNAL( newEvent() ), 511 connect( this, SIGNAL( newEvent() ),
505 dayView, SLOT( redraw() ) ); 512 dayView, SLOT( redraw() ) );
506 connect( dayView, SIGNAL( newEvent() ), 513 connect( dayView, SIGNAL( newEvent() ),
507 this, SLOT( fileNew() ) ); 514 this, SLOT( fileNew() ) );
508 connect( dayView, SIGNAL( removeEvent( const Event & ) ), 515 connect( dayView, SIGNAL( removeEvent( const Event & ) ),
509 this, SLOT( removeEvent( const Event & ) ) ); 516 this, SLOT( removeEvent( const Event & ) ) );
510 connect( dayView, SIGNAL( editEvent( const Event & ) ), 517 connect( dayView, SIGNAL( editEvent( const Event & ) ),
511 this, SLOT( editEvent( const Event & ) ) ); 518 this, SLOT( editEvent( const Event & ) ) );
512 connect( dayView, SIGNAL( duplicateEvent( const Event & ) ), 519 connect( dayView, SIGNAL( duplicateEvent( const Event & ) ),
513 this, SLOT( duplicateEvent( const Event & ) ) ); 520 this, SLOT( duplicateEvent( const Event & ) ) );
514 connect( dayView, SIGNAL( beamEvent( const Event & ) ), 521 connect( dayView, SIGNAL( beamEvent( const Event & ) ),
515 this, SLOT( beamEvent( const Event & ) ) ); 522 this, SLOT( beamEvent( const Event & ) ) );
516 connect( dayView, SIGNAL(sigNewEvent(const QString &)), 523 connect( dayView, SIGNAL(sigNewEvent(const QString &)),
517 this, SLOT(slotNewEventFromKey(const QString &)) ); 524 this, SLOT(slotNewEventFromKey(const QString &)) );
518 } 525 }
519} 526}
520 527
521void DateBook::initWeek() 528void DateBook::initWeek()
522{ 529{
523 if ( !weekView ) { 530 if ( !weekView ) {
524 weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); 531 weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" );
525 weekView->setStartViewTime( startTime ); 532 weekView->setStartViewTime( startTime );
526 views->addWidget( weekView, WEEK ); 533 views->addWidget( weekView, WEEK );
527 connect( weekView, SIGNAL( showDate( int, int, int ) ), 534 connect( weekView, SIGNAL( showDate( int, int, int ) ),
528 this, SLOT( showDay( int, int, int ) ) ); 535 this, SLOT( showDay( int, int, int ) ) );
529 connect( this, SIGNAL( newEvent() ), 536 connect( this, SIGNAL( newEvent() ),
530 weekView, SLOT( redraw() ) ); 537 weekView, SLOT( redraw() ) );
531 } 538 }
532 539
533 //But also get it right: the year that we display can be different 540 //But also get it right: the year that we display can be different
534 //from the year of the current date. So, first find the year 541 //from the year of the current date. So, first find the year
535 //number of the current week. 542 //number of the current week.
536 int yearNumber, totWeeks; 543 int yearNumber, totWeeks;
537 calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); 544 calcWeek( currentDate(), totWeeks, yearNumber, onMonday );
538 545
539 QDate d = QDate( yearNumber, 12, 31 ); 546 QDate d = QDate( yearNumber, 12, 31 );
540 calcWeek( d, totWeeks, yearNumber, onMonday ); 547 calcWeek( d, totWeeks, yearNumber, onMonday );
541 548
542 while ( totWeeks == 1 ) { 549 while ( totWeeks == 1 ) {
543 d = d.addDays( -1 ); 550 d = d.addDays( -1 );
544 calcWeek( d, totWeeks, yearNumber, onMonday ); 551 calcWeek( d, totWeeks, yearNumber, onMonday );
545 } 552 }
546 if ( totWeeks != weekView->totalWeeks() ) 553 if ( totWeeks != weekView->totalWeeks() )
547 weekView->setTotalWeeks( totWeeks ); 554 weekView->setTotalWeeks( totWeeks );
548} 555}
549 556
550void DateBook::initWeekLst() { 557void DateBook::initWeekLst() {
551 if ( !weekLstView ) { 558 if ( !weekLstView ) {
552 weekLstView = new DateBookWeekLst( ampm, onMonday, db, 559 weekLstView = new DateBookWeekLst( ampm, onMonday, db,
553 views, "weeklst view" ); 560 views, "weeklst view" );
554 views->addWidget( weekLstView, WEEKLST ); 561 views->addWidget( weekLstView, WEEKLST );
555 562
556 //weekLstView->setStartViewTime( startTime ); 563 //weekLstView->setStartViewTime( startTime );
557 connect( weekLstView, SIGNAL( showDate( int, int, int ) ), 564 connect( weekLstView, SIGNAL( showDate( int, int, int ) ),
558 this, SLOT( showDay( int, int, int ) ) ); 565 this, SLOT( showDay( int, int, int ) ) );
559 connect( weekLstView, SIGNAL( addEvent( const QDateTime &, 566 connect( weekLstView, SIGNAL( addEvent( const QDateTime &,
560 const QDateTime &, 567 const QDateTime &,
561 const QString & , const QString &) ), 568 const QString & , const QString &) ),
562 this, SLOT( slotNewEntry( const QDateTime &, 569 this, SLOT( slotNewEntry( const QDateTime &,
563 const QDateTime &, 570 const QDateTime &,
564 const QString & , const QString &) ) ); 571 const QString & , const QString &) ) );
565 connect( this, SIGNAL( newEvent() ), 572 connect( this, SIGNAL( newEvent() ),
566 weekLstView, SLOT( redraw() ) ); 573 weekLstView, SLOT( redraw() ) );
567 connect( weekLstView, SIGNAL( editEvent( const Event & ) ), 574 connect( weekLstView, SIGNAL( editEvent( const Event & ) ),
568 this, SLOT( editEvent( const Event & ) ) ); 575 this, SLOT( editEvent( const Event & ) ) );
569 } 576 }
570} 577}
571 578
572 579
573void DateBook::initMonth() 580void DateBook::initMonth()
574{ 581{
575 if ( !monthView ) { 582 if ( !monthView ) {
576 monthView = new DateBookMonth( views, "month view", FALSE, db ); 583 monthView = new DateBookMonth( views, "month view", FALSE, db );
577 views->addWidget( monthView, MONTH ); 584 views->addWidget( monthView, MONTH );
578 connect( monthView, SIGNAL( dateClicked( int, int, int ) ), 585 connect( monthView, SIGNAL( dateClicked( int, int, int ) ),
579 this, SLOT( showDay( int, int, int ) ) ); 586 this, SLOT( showDay( int, int, int ) ) );
580 connect( this, SIGNAL( newEvent() ), 587 connect( this, SIGNAL( newEvent() ),
581 monthView, SLOT( redraw() ) ); 588 monthView, SLOT( redraw() ) );
582 qApp->processEvents(); 589 qApp->processEvents();
583 } 590 }
584} 591}
585 592
586void DateBook::loadSettings() 593void DateBook::loadSettings()
587{ 594{
588 Config qpeconfig( "qpe" ); 595 Config qpeconfig( "qpe" );
589 qpeconfig.setGroup("Time"); 596 qpeconfig.setGroup("Time");
590 ampm = qpeconfig.readBoolEntry( "AMPM", TRUE ); 597 ampm = qpeconfig.readBoolEntry( "AMPM", TRUE );
591 onMonday = qpeconfig.readBoolEntry( "MONDAY" ); 598 onMonday = qpeconfig.readBoolEntry( "MONDAY" );
592 599
593 Config config("DateBook"); 600 Config config("DateBook");
594 config.setGroup("Main"); 601 config.setGroup("Main");
595 startTime = config.readNumEntry("startviewtime", 8); 602 startTime = config.readNumEntry("startviewtime", 8);
596 aPreset = config.readBoolEntry("alarmpreset"); 603 aPreset = config.readBoolEntry("alarmpreset");
597 presetTime = config.readNumEntry("presettime"); 604 presetTime = config.readNumEntry("presettime");
598 bJumpToCurTime = config.readBoolEntry("jumptocurtime"); 605 bJumpToCurTime = config.readBoolEntry("jumptocurtime");
599 rowStyle = config.readNumEntry("rowstyle"); 606 rowStyle = config.readNumEntry("rowstyle");
600 defaultView = config.readNumEntry("defaultview",DAY); 607 defaultView = config.readNumEntry("defaultview",DAY);
601 weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL); 608 weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL);
602} 609}
603 610
604void DateBook::saveSettings() 611void DateBook::saveSettings()
605{ 612{
606 Config config( "qpe" ); 613 Config config( "qpe" );
607 Config configDB( "DateBook" ); 614 Config configDB( "DateBook" );
608 configDB.setGroup( "Main" ); 615 configDB.setGroup( "Main" );
609 configDB.writeEntry("startviewtime",startTime); 616 configDB.writeEntry("startviewtime",startTime);
610 configDB.writeEntry("alarmpreset",aPreset); 617 configDB.writeEntry("alarmpreset",aPreset);
611 configDB.writeEntry("presettime",presetTime); 618 configDB.writeEntry("presettime",presetTime);
612 configDB.writeEntry("jumptocurtime", bJumpToCurTime); 619 configDB.writeEntry("jumptocurtime", bJumpToCurTime);
613 configDB.writeEntry("rowstyle", rowStyle); 620 configDB.writeEntry("rowstyle", rowStyle);
614 configDB.writeEntry("defaultview",defaultView); 621 configDB.writeEntry("defaultview",defaultView);
615 configDB.writeEntry("weeklistviewconfig",weeklistviewconfig); 622 configDB.writeEntry("weeklistviewconfig",weeklistviewconfig);
616} 623}
617 624
618void DateBook::appMessage(const QCString& msg, const QByteArray& data) 625void DateBook::appMessage(const QCString& msg, const QByteArray& data)
619{ 626{
620 bool needShow = FALSE; 627 bool needShow = FALSE;
621 if ( msg == "alarm(QDateTime,int)" ) { 628 if ( msg == "alarm(QDateTime,int)" ) {
622 QDataStream ds(data,IO_ReadOnly); 629 QDataStream ds(data,IO_ReadOnly);
623 QDateTime when; int warn; 630 QDateTime when; int warn;
624 ds >> when >> warn; 631 ds >> when >> warn;
625 632
626 // check to make it's okay to continue, 633 // check to make it's okay to continue,
627 // this is the case that the time was set ahead, and 634 // this is the case that the time was set ahead, and
628 // we are forced given a stale alarm... 635 // we are forced given a stale alarm...
629 QDateTime current = QDateTime::currentDateTime(); 636 QDateTime current = QDateTime::currentDateTime();
630 if ( current.time().hour() != when.time().hour() && current.time().minute() != when.time().minute() ) 637 if ( current.time().hour() != when.time().hour() && current.time().minute() != when.time().minute() )
631 return; 638 return;
632 639
633 QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60)); 640 QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60));
634 if ( list.count() > 0 ) { 641 if ( list.count() > 0 ) {
635 QString msg; 642 QString msg;
636 bool bSound = FALSE; 643 bool bSound = FALSE;
637 int stopTimer = 0; 644 int stopTimer = 0;
638 bool found = FALSE; 645 bool found = FALSE;
639 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) { 646 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) {
640 if ( (*it).event().hasAlarm() ) { 647 if ( (*it).event().hasAlarm() ) {
641 found = TRUE; 648 found = TRUE;
642 msg += "<CENTER><B>" + (*it).description() + "</B>" 649 msg += "<CENTER><B>" + (*it).description() + "</B>"
643 + "<BR>" + (*it).location() + "<BR>" 650 + "<BR>" + (*it).location() + "<BR>"
644 + TimeString::dateString((*it).event().start(),ampm) 651 + TimeString::dateString((*it).event().start(),ampm)
645 + (warn 652 + (warn
646 ? tr(" (in " + QString::number(warn) 653 ? tr(" (in " + QString::number(warn)
647 + tr(" minutes)")) 654 + tr(" minutes)"))
648 : QString("")) 655 : QString(""))
649 + "<BR>" 656 + "<BR>"
650 + (*it).notes() + "</CENTER>"; 657 + (*it).notes() + "</CENTER>";
651 if ( (*it).event().alarmSound() != Event::Silent ) { 658 if ( (*it).event().alarmSound() != Event::Silent ) {
652 bSound = TRUE; 659 bSound = TRUE;
653 } 660 }
654 } 661 }
655 } 662 }
656 if ( found ) { 663 if ( found ) {
657 if ( bSound ) { 664 if ( bSound ) {
658 Sound::soundAlarm(); 665 Sound::soundAlarm();
659 alarmCounter = 0; 666 alarmCounter = 0;
660 stopTimer = startTimer( 5000 ); 667 stopTimer = startTimer( 5000 );
661 } 668 }
662 QDialog dlg( this, 0, TRUE ); 669 QDialog dlg( this, 0, TRUE );
663 QVBoxLayout *vb = new QVBoxLayout( &dlg ); 670 QVBoxLayout *vb = new QVBoxLayout( &dlg );
664 QScrollView *view = new QScrollView( &dlg, "scrollView"); 671 QScrollView *view = new QScrollView( &dlg, "scrollView");
665 view->setResizePolicy( QScrollView::AutoOneFit ); 672 view->setResizePolicy( QScrollView::AutoOneFit );
666 vb->addWidget( view ); 673 vb->addWidget( view );
667 QLabel *lblMsg = new QLabel( msg, &dlg ); 674 QLabel *lblMsg = new QLabel( msg, &dlg );
668 view->addChild( lblMsg ); 675 view->addChild( lblMsg );
669 QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg ); 676 QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg );
670 connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) ); 677 connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) );
671 vb->addWidget( cmdOk ); 678 vb->addWidget( cmdOk );
672 679
673#if defined(Q_WS_QWS) || defined(_WS_QWS_) 680#if defined(Q_WS_QWS) || defined(_WS_QWS_)
674 dlg.showMaximized(); 681 dlg.showMaximized();
675#endif 682#endif
676 needShow = dlg.exec(); 683 needShow = dlg.exec();
677 684
678 if ( bSound ) 685 if ( bSound )
679 killTimer( stopTimer ); 686 killTimer( stopTimer );
680 } 687 }
681 } 688 }
682 } else if ( msg == "nextView()" ) { 689 } else if ( msg == "nextView()" ) {
683 if ( !qApp-> activeWindow ( )) { 690 if ( !qApp-> activeWindow ( )) {
684 needShow = TRUE; 691 needShow = TRUE;
685 } else { 692 } else {
686 QWidget* cur = views->visibleWidget(); 693 QWidget* cur = views->visibleWidget();
687 if ( cur ) { 694 if ( cur ) {
688 if ( cur == dayView ) 695 if ( cur == dayView )
689 viewWeek(); 696 viewWeek();
690 else if ( cur == weekView ) 697 else if ( cur == weekView )
691 viewWeekLst(); 698 viewWeekLst();
692 else if ( cur == weekLstView ) 699 else if ( cur == weekLstView )
693 viewMonth(); 700 viewMonth();
694 else if ( cur == monthView ) 701 else if ( cur == monthView )
695 viewDay(); 702 viewDay();
696 needShow = TRUE; 703 needShow = TRUE;
697 } 704 }
698 } 705 }
699 } 706 }
700 if ( needShow ) { 707 if ( needShow ) {
701#if defined(Q_WS_QWS) || defined(_WS_QWS_) 708#if defined(Q_WS_QWS) || defined(_WS_QWS_)
702 showMaximized(); 709 showMaximized();
703#else 710#else
704 show(); 711 show();
705#endif 712#endif
706 raise(); 713 raise();
707 QPEApplication::setKeepRunning(); 714 QPEApplication::setKeepRunning();
708 setActiveWindow(); 715 setActiveWindow();
709 } 716 }
710} 717}
711 718
712void DateBook::reload() 719void DateBook::reload()
713{ 720{
714 db->reload(); 721 db->reload();
715 if ( dayAction->isOn() ) viewDay(); 722 if ( dayAction->isOn() ) viewDay();
716 else if ( weekAction->isOn() ) viewWeek(); 723 else if ( weekAction->isOn() ) viewWeek();
717 else if ( monthAction->isOn() ) viewMonth(); 724 else if ( monthAction->isOn() ) viewMonth();
718 syncing = FALSE; 725 syncing = FALSE;
719} 726}
720 727
721void DateBook::flush() 728void DateBook::flush()
722{ 729{
723 syncing = TRUE; 730 syncing = TRUE;
724 db->save(); 731 db->save();
725} 732}
726 733
727void DateBook::timerEvent( QTimerEvent *e ) 734void DateBook::timerEvent( QTimerEvent *e )
728{ 735{
729 if ( alarmCounter < 10 ) { 736 if ( alarmCounter < 10 ) {
730 alarmCounter++; 737 alarmCounter++;
731 Sound::soundAlarm(); 738 Sound::soundAlarm();
732 } else { 739 } else {
733 killTimer( e->timerId() ); 740 killTimer( e->timerId() );
734 } 741 }
735} 742}
736 743
737void DateBook::changeClock( bool newClock ) 744void DateBook::changeClock( bool newClock )
738{ 745{
739 ampm = newClock; 746 ampm = newClock;
740 // repaint the affected objects... 747 // repaint the affected objects...
741 if (dayView) dayView->redraw(); 748 if (dayView) dayView->redraw();
742 if (weekView) weekView->redraw(); 749 if (weekView) weekView->redraw();
743 if (weekLstView) weekLstView->redraw(); 750 if (weekLstView) weekLstView->redraw();
744} 751}
745 752
746void DateBook::changeWeek( bool m ) 753void DateBook::changeWeek( bool m )
747{ 754{
748 /* no need to redraw, each widget catches. Do need to 755 /* no need to redraw, each widget catches. Do need to
749 store though for widgets we haven't made yet */ 756 store though for widgets we haven't made yet */
750 onMonday = m; 757 onMonday = m;
751} 758}
752 759
753void DateBook::slotToday() 760void DateBook::slotToday()
754{ 761{
755 // we need to view today using default view 762 // we need to view today using default view
756 view(defaultView,QDate::currentDate()); 763 view(defaultView,QDate::currentDate());
757} 764}
758 765
759void DateBook::closeEvent( QCloseEvent *e ) 766void DateBook::closeEvent( QCloseEvent *e )
760{ 767{
761 if(syncing) { 768 if(syncing) {
762 /* no need to save, did that at flush */ 769 /* no need to save, did that at flush */
763 e->accept(); 770 e->accept();
764 return; 771 return;
765 } 772 }
766 773
767 // save settings will generate it's own error messages, no 774 // save settings will generate it's own error messages, no
768 // need to do checking ourselves. 775 // need to do checking ourselves.
769 saveSettings(); 776 saveSettings();
770 if ( db->save() ) { 777 if ( db->save() ) {
771 e->accept(); 778 e->accept();
772 } else { 779 } else {
773 if ( QMessageBox::critical( this, tr( "Out of space" ), 780 if ( QMessageBox::critical( this, tr( "Out of space" ),
774 tr("Calendar was unable to save\n" 781 tr("Calendar was unable to save\n"
775 "your changes.\n" 782 "your changes.\n"
776 "Free up some space and try again.\n" 783 "Free up some space and try again.\n"
777 "\nQuit anyway?"), 784 "\nQuit anyway?"),
778 QMessageBox::Yes|QMessageBox::Escape, 785 QMessageBox::Yes|QMessageBox::Escape,
779 QMessageBox::No|QMessageBox::Default ) 786 QMessageBox::No|QMessageBox::Default )
780 != QMessageBox::No ) 787 != QMessageBox::No )
781 e->accept(); 788 e->accept();
782 else 789 else
783 e->ignore(); 790 e->ignore();
784 } 791 }
785} 792}
786 793
787// Entering directly from the "keyboard" 794// Entering directly from the "keyboard"
788void DateBook::slotNewEventFromKey( const QString &str ) 795void DateBook::slotNewEventFromKey( const QString &str )
789{ 796{
790 if (syncing) { 797 if (syncing) {
791 QMessageBox::warning( this, tr("Calendar"), 798 QMessageBox::warning( this, tr("Calendar"),
792 tr( "Can not edit data, currently syncing") ); 799 tr( "Can not edit data, currently syncing") );
793 return; 800 return;
794 } 801 }
795 802
796 // We get to here from a key pressed in the Day View 803 // We get to here from a key pressed in the Day View
797 // So we can assume some things. We want the string 804 // So we can assume some things. We want the string
798 // passed in to be part of the description. 805 // passed in to be part of the description.
799 QDateTime start, end; 806 QDateTime start, end;
800 if ( views->visibleWidget() == dayView ) { 807 if ( views->visibleWidget() == dayView ) {
801 dayView->selectedDates( start, end ); 808 dayView->selectedDates( start, end );
802 } else if ( views->visibleWidget() == monthView ) { 809 } else if ( views->visibleWidget() == monthView ) {
803 QDate d = monthView->selectedDate(); 810 QDate d = monthView->selectedDate();
804 start = end = d; 811 start = end = d;
805 start.setTime( QTime( 10, 0 ) ); 812 start.setTime( QTime( 10, 0 ) );
806 end.setTime( QTime( 12, 0 ) ); 813 end.setTime( QTime( 12, 0 ) );
807 } else if ( views->visibleWidget() == weekView ) { 814 } else if ( views->visibleWidget() == weekView ) {
808 QDate d = weekView->date(); 815 QDate d = weekView->date();
809 start = end = d; 816 start = end = d;
810 start.setTime( QTime( 10, 0 ) ); 817 start.setTime( QTime( 10, 0 ) );
811 end.setTime( QTime( 12, 0 ) ); 818 end.setTime( QTime( 12, 0 ) );
812 } else if ( views->visibleWidget() == weekLstView ) { 819 } else if ( views->visibleWidget() == weekLstView ) {
813 QDate d = weekLstView->date(); 820 QDate d = weekLstView->date();
814 start = end = d; 821 start = end = d;
815 start.setTime( QTime( 10, 0 ) ); 822 start.setTime( QTime( 10, 0 ) );
816 end.setTime( QTime( 12, 0 ) ); 823 end.setTime( QTime( 12, 0 ) );
817 } 824 }
818 slotNewEntry(start, end, str); 825 slotNewEntry(start, end, str);
819} 826}
820void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location) { 827void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location) {
821 // argh! This really needs to be encapsulated in a class 828 // argh! This really needs to be encapsulated in a class
822 // or function. 829 // or function.
823 QDialog newDlg( this, 0, TRUE ); 830 QDialog newDlg( this, 0, TRUE );
824 newDlg.setCaption( DateEntryBase::tr("New Event") ); 831 newDlg.setCaption( DateEntryBase::tr("New Event") );
825 DateEntry *e; 832 DateEntry *e;
826 QVBoxLayout *vb = new QVBoxLayout( &newDlg ); 833 QVBoxLayout *vb = new QVBoxLayout( &newDlg );
827 QScrollView *sv = new QScrollView( &newDlg ); 834 QScrollView *sv = new QScrollView( &newDlg );
828 sv->setResizePolicy( QScrollView::AutoOneFit ); 835 sv->setResizePolicy( QScrollView::AutoOneFit );
829 sv->setFrameStyle( QFrame::NoFrame ); 836 sv->setFrameStyle( QFrame::NoFrame );
830 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 837 sv->setHScrollBarMode( QScrollView::AlwaysOff );
831 vb->addWidget( sv ); 838 vb->addWidget( sv );
832 839
833 Event ev; 840 Event ev;
834 ev.setDescription( str ); 841 ev.setDescription( str );
835 // When the new gui comes in, change this... 842 // When the new gui comes in, change this...
836 if(location==0) { 843 if(location==0) {
837 ev.setLocation( tr("(Unknown)") ); 844 ev.setLocation( tr("(Unknown)") );
838 } else { 845 } else {
839 ev.setLocation(location); 846 ev.setLocation(location);
840 } 847 }
841 ev.setStart( start ); 848 ev.setStart( start );
842 ev.setEnd( end ); 849 ev.setEnd( end );
843 850
844 e = new DateEntry( onMonday, ev, ampm, &newDlg ); 851 e = new DateEntry( onMonday, ev, ampm, &newDlg );
845 e->setAlarmEnabled( aPreset, presetTime, Event::Loud ); 852 e->setAlarmEnabled( aPreset, presetTime, Event::Loud );
846 sv->addChild( e ); 853 sv->addChild( e );
847#if defined(Q_WS_QWS) || defined(_WS_QWS_) 854#if defined(Q_WS_QWS) || defined(_WS_QWS_)
848 newDlg.showMaximized(); 855 newDlg.showMaximized();
849#endif 856#endif
850 while (newDlg.exec()) { 857 while (newDlg.exec()) {
851 ev = e->event(); 858 ev = e->event();
852 ev.assignUid(); 859 ev.assignUid();
853 QString error = checkEvent( ev ); 860 QString error = checkEvent( ev );
854 if ( !error.isNull() ) { 861 if ( !error.isNull() ) {
855 if ( QMessageBox::warning( this, tr("Error!"), 862 if ( QMessageBox::warning( this, tr("Error!"),
856 error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 ) 863 error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 )
857 continue; 864 continue;
858 } 865 }
859 db->addEvent( ev ); 866 db->addEvent( ev );
860 emit newEvent(); 867 emit newEvent();
861 break; 868 break;
862 } 869 }
863} 870}
864 871
865void DateBook::setDocument( const QString &filename ) 872void DateBook::setDocument( const QString &filename )
866{ 873{
867 if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; 874 if ( filename.find(".vcs") != int(filename.length()) - 4 ) return;
868 875
869 QValueList<Event> tl = Event::readVCalendar( filename ); 876 QValueList<Event> tl = Event::readVCalendar( filename );
870 for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) { 877 for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) {
871 db->addEvent( *it ); 878 db->addEvent( *it );
872 } 879 }
873} 880}
874 881
875static const char * beamfile = "/tmp/obex/event.vcs"; 882static const char * beamfile = "/tmp/obex/event.vcs";
876 883
877void DateBook::beamEvent( const Event &e ) 884void DateBook::beamEvent( const Event &e )
878{ 885{
879 qDebug("trying to beamn"); 886 qDebug("trying to beamn");
880 unlink( beamfile ); // delete if exists 887 unlink( beamfile ); // delete if exists
881 mkdir("/tmp/obex/", 0755); 888 mkdir("/tmp/obex/", 0755);
882 Event::writeVCalendar( beamfile, e ); 889 Event::writeVCalendar( beamfile, e );
883 Ir *ir = new Ir( this ); 890 Ir *ir = new Ir( this );
884 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 891 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
885 QString description = e.description(); 892 QString description = e.description();
886 ir->send( beamfile, description, "text/x-vCalendar" ); 893 ir->send( beamfile, description, "text/x-vCalendar" );
887} 894}
888 895
889void DateBook::beamDone( Ir *ir ) 896void DateBook::beamDone( Ir *ir )
890{ 897{
891 delete ir; 898 delete ir;
892 unlink( beamfile ); 899 unlink( beamfile );
893} 900}
894 901
895void DateBook::slotFind() 902void DateBook::slotFind()
896{ 903{
897 // move it to the day view... 904 // move it to the day view...
898 viewDay(); 905 viewDay();
899 FindDialog frmFind( "Calendar", this ); 906 FindDialog frmFind( "Calendar", this );
900 frmFind.setUseDate( true ); 907 frmFind.setUseDate( true );
901 frmFind.setDate( currentDate() ); 908 frmFind.setDate( currentDate() );
902 QObject::connect( &frmFind, 909 QObject::connect( &frmFind,
903 SIGNAL(signalFindClicked(const QString&, const QDate&, 910 SIGNAL(signalFindClicked(const QString&, const QDate&,
904 bool, bool, int)), 911 bool, bool, int)),
905 this, 912 this,
906 SLOT(slotDoFind(const QString&, const QDate&, 913 SLOT(slotDoFind(const QString&, const QDate&,
907 bool, bool, int)) ); 914 bool, bool, int)) );
908 QObject::connect( this, 915 QObject::connect( this,
909 SIGNAL(signalNotFound()), 916 SIGNAL(signalNotFound()),
910 &frmFind, 917 &frmFind,
911 SLOT(slotNotFound()) ); 918 SLOT(slotNotFound()) );
912 QObject::connect( this, 919 QObject::connect( this,
913 SIGNAL(signalWrapAround()), 920 SIGNAL(signalWrapAround()),
914 &frmFind, 921 &frmFind,
915 SLOT(slotWrapAround()) ); 922 SLOT(slotWrapAround()) );
916 frmFind.move(0,0); 923 frmFind.move(0,0);
917 frmFind.exec(); 924 frmFind.exec();
918 inSearch = false; 925 inSearch = false;
919} 926}
920 927
921bool catComp( QArray<int> cats, int category ) 928bool catComp( QArray<int> cats, int category )
922{ 929{
923 bool returnMe; 930 bool returnMe;
924 int i, 931 int i,
925 count; 932 count;
926 933
927 count = int(cats.count()); 934 count = int(cats.count());
928 returnMe = false; 935 returnMe = false;
929 if ( (category == -1 && count == 0) || category == -2 ) 936 if ( (category == -1 && count == 0) || category == -2 )
930 returnMe = true; 937 returnMe = true;
931 else { 938 else {
932 for ( i = 0; i < count; i++ ) { 939 for ( i = 0; i < count; i++ ) {
933 if ( category == cats[i] ) { 940 if ( category == cats[i] ) {
934 returnMe = true; 941 returnMe = true;
935 break; 942 break;
936 } 943 }
937 } 944 }
938 } 945 }
939 return returnMe; 946 return returnMe;
940} 947}
941 948
942 949
943void DateBook::slotDoFind( const QString& txt, const QDate &dt, 950void DateBook::slotDoFind( const QString& txt, const QDate &dt,
944 bool caseSensitive, bool /*backwards*/, 951 bool caseSensitive, bool /*backwards*/,
945 int category ) 952 int category )
946{ 953{
947 QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ), 954 QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ),
948 next; 955 next;
949 956
950 QRegExp r( txt ); 957 QRegExp r( txt );
951 r.setCaseSensitive( caseSensitive ); 958 r.setCaseSensitive( caseSensitive );
952 959
953 960
954 static Event rev, 961 static Event rev,
955 nonrev; 962 nonrev;
956 if ( !inSearch ) { 963 if ( !inSearch ) {
957 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); 964 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) );
958 nonrev.setStart( rev.start() ); 965 nonrev.setStart( rev.start() );
959 inSearch = true; 966 inSearch = true;
960 } 967 }
961 static QDate searchDate = dt; 968 static QDate searchDate = dt;
962 static bool wrapAround = true; 969 static bool wrapAround = true;
963 bool candidtate; 970 bool candidtate;
964 candidtate = false; 971 candidtate = false;
965 972
966 QValueList<Event> repeats = db->getRawRepeats(); 973 QValueList<Event> repeats = db->getRawRepeats();
967 974
968 // find the candidate for the first repeat that matches... 975 // find the candidate for the first repeat that matches...
969 QValueListConstIterator<Event> it; 976 QValueListConstIterator<Event> it;
970 QDate start = dt; 977 QDate start = dt;
971 for ( it = repeats.begin(); it != repeats.end(); ++it ) { 978 for ( it = repeats.begin(); it != repeats.end(); ++it ) {
972 if ( catComp( (*it).categories(), category ) ) { 979 if ( catComp( (*it).categories(), category ) ) {
973 while ( nextOccurance( *it, start, next ) ) { 980 while ( nextOccurance( *it, start, next ) ) {
974 if ( next < dtEnd ) { 981 if ( next < dtEnd ) {
975 if ( (*it).match( r ) && !(next <= rev.start()) ) { 982 if ( (*it).match( r ) && !(next <= rev.start()) ) {
976 rev = *it; 983 rev = *it;
977 dtEnd = next; 984 dtEnd = next;
978 rev.setStart( next ); 985 rev.setStart( next );
979 candidtate = true; 986 candidtate = true;
980 wrapAround = true; 987 wrapAround = true;
981 start = dt; 988 start = dt;
982 break; 989 break;
983 } else 990 } else
984 start = next.date().addDays( 1 ); 991 start = next.date().addDays( 1 );
985 } 992 }
986 } 993 }
987 } 994 }
988 } 995 }
989 996
990 // now the for first non repeat... 997 // now the for first non repeat...
991 QValueList<Event> nonRepeats = db->getNonRepeatingEvents( dt, dtEnd.date() ); 998 QValueList<Event> nonRepeats = db->getNonRepeatingEvents( dt, dtEnd.date() );
992 qHeapSort( nonRepeats.begin(), nonRepeats.end() ); 999 qHeapSort( nonRepeats.begin(), nonRepeats.end() );
993 for ( it = nonRepeats.begin(); it != nonRepeats.end(); ++it ) { 1000 for ( it = nonRepeats.begin(); it != nonRepeats.end(); ++it ) {
994 if ( catComp( (*it).categories(), category ) ) { 1001 if ( catComp( (*it).categories(), category ) ) {
995 if ( (*it).start() < dtEnd ) { 1002 if ( (*it).start() < dtEnd ) {
996 if ( (*it).match( r ) && !(*it <= nonrev) ) { 1003 if ( (*it).match( r ) && !(*it <= nonrev) ) {
997 nonrev = *it; 1004 nonrev = *it;
998 dtEnd = nonrev.start(); 1005 dtEnd = nonrev.start();
999 candidtate = true; 1006 candidtate = true;
1000 wrapAround = true; 1007 wrapAround = true;
1001 break; 1008 break;
1002 } 1009 }
1003 } 1010 }
1004 } 1011 }
1005 } 1012 }
1006 if ( candidtate ) { 1013 if ( candidtate ) {
1007 dayView->setStartViewTime( dtEnd.time().hour() ); 1014 dayView->setStartViewTime( dtEnd.time().hour() );
1008 dayView->setDate( dtEnd.date().year(), dtEnd.date().month(), 1015 dayView->setDate( dtEnd.date().year(), dtEnd.date().month(),
1009 dtEnd.date().day() ); 1016 dtEnd.date().day() );
1010 } else { 1017 } else {
1011 if ( wrapAround ) { 1018 if ( wrapAround ) {
1012 emit signalWrapAround(); 1019 emit signalWrapAround();
1013 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); 1020 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) );
1014 nonrev.setStart( rev.start() ); 1021 nonrev.setStart( rev.start() );
1015 } else 1022 } else
1016 emit signalNotFound(); 1023 emit signalNotFound();
1017 wrapAround = !wrapAround; 1024 wrapAround = !wrapAround;
1018 } 1025 }
1019} 1026}
1020 1027
1021Event DateBookDBHack::eventByUID(int uid) { 1028Event DateBookDBHack::eventByUID(int uid) {
1022 1029
1023 // FIXME: Dirty Hacks to get hold of the private event lists 1030 // FIXME: Dirty Hacks to get hold of the private event lists
1024 QDate start; 1031 QDate start;
1025 QDate end=start.addDays(-1); 1032 QDate end=start.addDays(-1);
1026 QValueList<Event> myEventList=getNonRepeatingEvents(start,end); 1033 QValueList<Event> myEventList=getNonRepeatingEvents(start,end);
1027 QValueList<Event> myRepeatEvents=getRawRepeats(); 1034 QValueList<Event> myRepeatEvents=getRawRepeats();
1028 1035
1029 QValueList<Event>::ConstIterator it; 1036 QValueList<Event>::ConstIterator it;
1030 1037
1031 for (it = myEventList.begin(); it != myEventList.end(); it++) { 1038 for (it = myEventList.begin(); it != myEventList.end(); it++) {
1032 if ((*it).uid() == uid) return *it; 1039 if ((*it).uid() == uid) return *it;
1033 } 1040 }
1034 for (it = myRepeatEvents.begin(); it != myRepeatEvents.end(); it++) { 1041 for (it = myRepeatEvents.begin(); it != myRepeatEvents.end(); it++) {
1035 if ((*it).uid() == uid) return *it; 1042 if ((*it).uid() == uid) return *it;
1036 } 1043 }
1037 1044
1038 qDebug("Event not found: uid=%d\n", uid); 1045 qDebug("Event not found: uid=%d\n", uid);
1039 Event ev; 1046 Event ev;
1040 return ev; // return at least 1047 return ev; // return at least
1041} 1048}
1042 1049
diff --git a/core/pim/datebook/datebook.h b/core/pim/datebook/datebook.h
index 5216770..3f57d4a 100644
--- a/core/pim/datebook/datebook.h
+++ b/core/pim/datebook/datebook.h
@@ -1,135 +1,136 @@
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 <qpe/datebookdb.h> 23#include <qpe/datebookdb.h>
24 24
25#include <qmainwindow.h> 25#include <qmainwindow.h>
26 26
27 enum { DAY=1,WEEK,WEEKLST,MONTH };// defaultView values 27 enum { DAY=1,WEEK,WEEKLST,MONTH };// defaultView values
28 enum { NONE=0,NORMAL,EXTENDED };// WeekLstView's modes. 28 enum { NONE=0,NORMAL,EXTENDED };// WeekLstView's modes.
29 29
30class QAction; 30class QAction;
31class QWidgetStack; 31class QWidgetStack;
32class DateBookDay; 32class DateBookDay;
33class DateBookWeek; 33class DateBookWeek;
34class DateBookWeekLst; 34class DateBookWeekLst;
35class DateBookMonth; 35class DateBookMonth;
36class Event; 36class Event;
37class QDate; 37class QDate;
38class Ir; 38class Ir;
39 39
40class DateBookDBHack : public DateBookDB { 40class DateBookDBHack : public DateBookDB {
41 public: 41 public:
42 Event eventByUID(int id); 42 Event eventByUID(int id);
43}; 43};
44 44
45class DateBook : public QMainWindow 45class DateBook : public QMainWindow
46{ 46{
47 Q_OBJECT 47 Q_OBJECT
48 48
49public: 49public:
50 DateBook( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 50 DateBook( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
51 ~DateBook(); 51 ~DateBook();
52 52
53signals: 53signals:
54 void newEvent(); 54 void newEvent();
55 void signalNotFound(); 55 void signalNotFound();
56 void signalWrapAround(); 56 void signalWrapAround();
57 57
58protected: 58protected:
59 QDate currentDate(); 59 QDate currentDate();
60 void timerEvent( QTimerEvent *e ); 60 void timerEvent( QTimerEvent *e );
61 void closeEvent( QCloseEvent *e ); 61 void closeEvent( QCloseEvent *e );
62 62
63 void view(int v, const QDate &d); 63 void view(int v, const QDate &d);
64 64
65public slots: 65public slots:
66 void flush(); 66 void flush();
67 void reload(); 67 void reload();
68 68
69private slots: 69private slots:
70 void fileNew(); 70 void fileNew();
71 void slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location=0); 71 void slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location=0);
72 void slotSettings(); 72 void slotSettings();
73 void slotToday();// view today 73 void slotToday();// view today
74 void changeClock( bool newClock ); 74 void changeClock( bool newClock );
75 void changeWeek( bool newDay ); 75 void changeWeek( bool newDay );
76 void appMessage(const QCString& msg, const QByteArray& data); 76 void appMessage(const QCString& msg, const QByteArray& data);
77 // handle key events in the day view... 77 // handle key events in the day view...
78 void slotNewEventFromKey( const QString &str ); 78 void slotNewEventFromKey( const QString &str );
79 void slotFind(); 79 void slotFind();
80 void slotDoFind( const QString &, const QDate &, bool, bool, int ); 80 void slotDoFind( const QString &, const QDate &, bool, bool, int );
81 81
82 void viewDefault(const QDate &d); 82 void viewDefault(const QDate &d);
83 83
84 void viewDay(); 84 void viewDay();
85 void viewWeek(); 85 void viewWeek();
86 void viewWeekLst(); 86 void viewWeekLst();
87 void viewMonth(); 87 void viewMonth();
88 88
89 void showDay( int y, int m, int d ); 89 void showDay( int y, int m, int d );
90 90
91 void editEvent( const Event &e ); 91 void insertEvent( const Event &e );
92 void editEvent( const Event &e );
92 void duplicateEvent( const Event &e ); 93 void duplicateEvent( const Event &e );
93 void removeEvent( const Event &e ); 94 void removeEvent( const Event &e );
94 95
95 void receive( const QCString &msg, const QByteArray &data ); 96 void receive( const QCString &msg, const QByteArray &data );
96 void setDocument( const QString & ); 97 void setDocument( const QString & );
97 void beamEvent( const Event &e ); 98 void beamEvent( const Event &e );
98 void beamDone( Ir *ir ); 99 void beamDone( Ir *ir );
99 100
100private: 101private:
101 void addEvent( const Event &e ); 102 void addEvent( const Event &e );
102 void initDay(); 103 void initDay();
103 void initWeek(); 104 void initWeek();
104 void initWeekLst(); 105 void initWeekLst();
105 void initMonth(); 106 void initMonth();
106 void loadSettings(); 107 void loadSettings();
107 void saveSettings(); 108 void saveSettings();
108 109
109private: 110private:
110 DateBookDBHack *db; 111 DateBookDBHack *db;
111 QWidgetStack *views; 112 QWidgetStack *views;
112 DateBookDay *dayView; 113 DateBookDay *dayView;
113 DateBookWeek *weekView; 114 DateBookWeek *weekView;
114 DateBookMonth *monthView; 115 DateBookMonth *monthView;
115 DateBookWeekLst *weekLstView; 116 DateBookWeekLst *weekLstView;
116 QAction *dayAction, *weekAction, *weekLstAction, *monthAction; 117 QAction *dayAction, *weekAction, *weekLstAction, *monthAction;
117 int weeklistviewconfig; 118 int weeklistviewconfig;
118 bool aPreset; // have everything set to alarm? 119 bool aPreset; // have everything set to alarm?
119 int presetTime; // the standard time for the alarm 120 int presetTime; // the standard time for the alarm
120 int startTime; 121 int startTime;
121 int rowStyle; 122 int rowStyle;
122 int defaultView; 123 int defaultView;
123 bool bJumpToCurTime; //should jump to current time in dayview? 124 bool bJumpToCurTime; //should jump to current time in dayview?
124 bool ampm; 125 bool ampm;
125 bool onMonday; 126 bool onMonday;
126 127
127 bool syncing; 128 bool syncing;
128 bool inSearch; 129 bool inSearch;
129 130
130 int alarmCounter; 131 int alarmCounter;
131 132
132 QString checkEvent(const Event &); 133 QString checkEvent(const Event &);
133}; 134};
134 135
135#endif 136#endif
diff --git a/core/pim/datebook/datebookday.cpp b/core/pim/datebook/datebookday.cpp
index db4c2fd..0a40ea9 100644
--- a/core/pim/datebook/datebookday.cpp
+++ b/core/pim/datebook/datebookday.cpp
@@ -1,802 +1,811 @@
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#include <qmessagebox.h> 20#include <qmessagebox.h>
21 21
22#include "datebookday.h" 22#include "datebookday.h"
23#include "datebookdayheaderimpl.h" 23#include "datebookdayheaderimpl.h"
24 24
25#include <qpe/datebookdb.h> 25#include <qpe/datebookdb.h>
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27#include <qpe/event.h> 27#include <qpe/event.h>
28#include <qpe/qpeapplication.h> 28#include <qpe/qpeapplication.h>
29#include <qpe/timestring.h> 29#include <qpe/timestring.h>
30#include <qpe/qpedebug.h> 30#include <qpe/qpedebug.h>
31#include <qpe/ir.h> 31#include <qpe/ir.h>
32 32
33#include <qheader.h> 33#include <qheader.h>
34#include <qdatetime.h> 34#include <qdatetime.h>
35#include <qpainter.h> 35#include <qpainter.h>
36#include <qsimplerichtext.h> 36#include <qsimplerichtext.h>
37#include <qpopupmenu.h> 37#include <qpopupmenu.h>
38#include <qtextcodec.h> 38#include <qtextcodec.h>
39#include <qpalette.h> 39#include <qpalette.h>
40 40
41#include <qlineedit.h>
42
41#include <qtimer.h> 43#include <qtimer.h>
42 44
43DateBookDayView::DateBookDayView( bool whichClock, QWidget *parent, 45DateBookDayView::DateBookDayView( bool whichClock, QWidget *parent, const char *name )
44 const char *name ) 46 : QTable( 24, 1, parent, name ), ampm( whichClock ), currDate( QDate::currentDate() )
45 : QTable( 24, 1, parent, name ), 47{
46 ampm( whichClock ) 48 enableClipper(TRUE);
47{ 49 setTopMargin( 0 );
48 enableClipper(TRUE); 50 horizontalHeader()->hide();
49 setTopMargin( 0 ); 51 setLeftMargin(38);
50 horizontalHeader()->hide(); 52 setColumnStretchable( 0, TRUE );
51 setLeftMargin(38); 53 setHScrollBarMode( QScrollView::AlwaysOff );
52 setColumnStretchable( 0, TRUE ); 54 verticalHeader()->setPalette(white);
53 setHScrollBarMode( QScrollView::AlwaysOff ); 55 verticalHeader()->setResizeEnabled(FALSE);
54 verticalHeader()->setPalette(white); 56 setSelectionMode( Single );
55 verticalHeader()->setResizeEnabled(FALSE); 57
56 setSelectionMode( Single ); 58 // get rid of being able to edit things...
57 59 QTableItem *tmp;
58 // get rid of being able to edit things... 60 int row;
59 QTableItem *tmp; 61 for ( row = 0; row < numRows(); row++ ) {
60 int row; 62 tmp = new QTableItem( this, QTableItem::Never, QString::null);
61 for ( row = 0; row < numRows(); row++ ) { 63 setItem( row, 0, tmp );
62 tmp = new QTableItem( this, QTableItem::Never, QString::null); 64 //setRowHeight( row, 40);
63 setItem( row, 0, tmp ); 65 }
64 //setRowHeight( row, 40); 66
65 } 67 initHeader();
66 initHeader(); 68 QObject::connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotChangeClock(bool)) );
67 QObject::connect( qApp, SIGNAL(clockChanged(bool)),
68 this, SLOT(slotChangeClock(bool)) );
69} 69}
70 70
71void DateBookDayView::initHeader() 71void DateBookDayView::initHeader()
72{ 72{
73 QString strTmp; 73 QString strTmp;
74 for ( int i = 0; i < 24; ++i ) { 74 for ( int i = 0; i < 24; ++i ) {
75 if ( ampm ) { 75 if ( ampm ) {
76 if ( i == 0 ) 76 if ( i == 0 )
77 strTmp = QString::number(12) + ":00"; 77 strTmp = QString::number(12) + ":00";
78 else if ( i == 12 ) 78 else if ( i == 12 )
79 strTmp = QString::number(12) + tr(":00p"); 79 strTmp = QString::number(12) + tr(":00p");
80 else if ( i > 12 ) 80 else if ( i > 12 )
81 strTmp = QString::number( i - 12 ) + tr(":00p"); 81 strTmp = QString::number( i - 12 ) + tr(":00p");
82 else 82 else
83 strTmp = QString::number(i) + ":00"; 83 strTmp = QString::number(i) + ":00";
84 } else { 84 } else {
85 if ( i < 10 ) 85 if ( i < 10 )
86 strTmp = "0" + QString::number(i) + ":00"; 86 strTmp = "0" + QString::number(i) + ":00";
87 else 87 else
88 strTmp = QString::number(i) + ":00"; 88 strTmp = QString::number(i) + ":00";
89 }
90 strTmp = strTmp.rightJustify( 6, ' ' );
91 verticalHeader()->setLabel( i, strTmp );
92 setRowStretchable( i, FALSE );
89 } 93 }
90 strTmp = strTmp.rightJustify( 6, ' ' ); 94}
91 verticalHeader()->setLabel( i, strTmp ); 95
92 setRowStretchable( i, FALSE ); 96void DateBookDayView::slotDateChanged( int y, int m, int d )
93 } 97{
98 currDate.setYMD(y,m,d);
94} 99}
95 100
96void DateBookDayView::slotChangeClock( bool newClock ) 101void DateBookDayView::slotChangeClock( bool newClock )
97{ 102{
98 ampm = newClock; 103 ampm = newClock;
99 initHeader(); 104 initHeader();
100} 105}
101 106
102bool DateBookDayView::whichClock() const 107bool DateBookDayView::whichClock() const
103{ 108{
104 return ampm; 109 return ampm;
105} 110}
106 111
107void DateBookDayView::moveUp() 112void DateBookDayView::moveUp()
108{ 113{
109 scrollBy(0, -20); 114 scrollBy(0, -20);
110} 115}
111 116
112void DateBookDayView::moveDown() 117void DateBookDayView::moveDown()
113{ 118{
114 scrollBy(0, 20); 119 scrollBy(0, 20);
115} 120}
116 121
117void DateBookDayView::paintCell( QPainter *p, int, int, const QRect &cr, bool ) 122void DateBookDayView::paintCell( QPainter *p, int, int, const QRect &cr, bool )
118{ 123{
119 int w = cr.width(); 124 int w = cr.width();
120 int h = cr.height(); 125 int h = cr.height();
121 p->fillRect( 0, 0, w, h, colorGroup().brush( QColorGroup::Base ) ); 126 p->fillRect( 0, 0, w, h, colorGroup().brush( QColorGroup::Base ) );
122 if ( showGrid() ) { 127 if ( showGrid() ) {
123 // Draw our lines 128 // Draw our lines
124 int x2 = w - 1; 129 int x2 = w - 1;
125 int y2 = h - 1; 130 int y2 = h - 1;
126 QPen pen( p->pen() ); 131 QPen pen( p->pen() );
127 p->setPen( colorGroup().dark() ); 132 p->setPen( colorGroup().dark() );
128 p->drawLine( x2, 0, x2, y2 ); 133 p->drawLine( x2, 0, x2, y2 );
129 p->drawLine( 0, y2, x2, y2 ); 134 p->drawLine( 0, y2, x2, y2 );
130 135
131 p->setPen( colorGroup().midlight() ); 136 p->setPen( colorGroup().midlight() );
132 p->drawLine( 0, y2 - h/2, x2, y2 - h/2); 137 p->drawLine( 0, y2 - h/2, x2, y2 - h/2);
133 138
134 p->setPen( pen ); 139 p->setPen( pen );
135 } 140 }
136} 141}
137 142
138void DateBookDayView::paintFocus( QPainter *, const QRect & ) 143void DateBookDayView::paintFocus( QPainter *, const QRect & )
139{ 144{
140} 145}
141 146
142
143void DateBookDayView::resizeEvent( QResizeEvent *e ) 147void DateBookDayView::resizeEvent( QResizeEvent *e )
144{ 148{
145 QTable::resizeEvent( e ); 149 QTable::resizeEvent( e );
146 columnWidthChanged( 0 ); 150 columnWidthChanged( 0 );
147 emit sigColWidthChanged(); 151 emit sigColWidthChanged();
148} 152}
149 153
150void DateBookDayView::keyPressEvent( QKeyEvent *e ) 154void DateBookDayView::keyPressEvent( QKeyEvent *e )
151{ 155{
152 QString txt = e->text(); 156 QString txt = e->text();
153 if ( !txt.isNull() && txt[0] > ' ' && e->key() < 0x1000 ) { 157 if ( !txt.isNull() && txt[0] > ' ' && e->key() < 0x1000 ) {
154 // we this is some sort of thing we know about... 158 // we this is some sort of thing we know about...
155 e->accept(); 159 e->accept();
156 emit sigCapturedKey( txt ); 160 emit sigCapturedKey( txt );
157 } else { 161 } else {
158 // I don't know what this key is, do you? 162 // I don't know what this key is, do you?
159 e->ignore(); 163 e->ignore();
160 } 164 }
161} 165}
162 166
163void DateBookDayView::setRowStyle( int style ) 167void DateBookDayView::setRowStyle( int style )
164{ 168{
165 if (style<0) style = 0; 169 if (style<0) style = 0;
166 170
167 for (int i=0; i<numRows(); i++) 171 for (int i=0; i<numRows(); i++)
168 setRowHeight(i, style*10+20); 172 setRowHeight(i, style*10+20);
169} 173}
170 174
175void DateBookDayView::contentsMouseReleaseEvent( QMouseEvent *e )
176{
177 int y=e->y();
178 int diff=y%(this->rowHeight(0));
179 int hour=y/this->rowHeight(0);
180 quickLineEdit=new DateBookDayViewQuickLineEdit(QDateTime(currDate,QTime(hour,0,0,0)),QDateTime(currDate,QTime(hour,59,0,0)),this->viewport(),"quickedit");
181 quickLineEdit->setGeometry(0,0,this->columnWidth(0)-1,this->rowHeight(0));
182 this->moveChild(quickLineEdit,0,y-diff);
183 quickLineEdit->setFocus();
184 quickLineEdit->show();
185}
186
171//=========================================================================== 187//===========================================================================
172 188
173DateBookDay::DateBookDay( bool ampm, bool startOnMonday, 189DateBookDayViewQuickLineEdit::DateBookDayViewQuickLineEdit(const QDateTime &start, const QDateTime &end,QWidget * parent, const char *name=0) : QLineEdit(parent,name)
174 DateBookDB *newDb, QWidget *parent,
175 const char *name )
176 : QVBox( parent, name ),
177 currDate( QDate::currentDate() ),
178 db( newDb ),
179 startTime( 0 )
180{ 190{
181 widgetList.setAutoDelete( true ); 191 active=1;
182 header = new DateBookDayHeader( startOnMonday, this, "day header" ); 192 quickEvent.setStart(start);
183 header->setDate( currDate.year(), currDate.month(), currDate.day() ); 193 quickEvent.setEnd(end);
184 view = new DateBookDayView( ampm, this, "day view" ); 194 connect(this,SIGNAL(returnPressed()),this,SLOT(slotReturnPressed()));
195}
185 196
186 connect( header, SIGNAL( dateChanged( int, int, int ) ), 197void DateBookDayViewQuickLineEdit::slotReturnPressed()
187 this, SLOT( dateChanged( int, int, int ) ) ); 198{
188 connect( view, SIGNAL( sigColWidthChanged() ), 199 if(active && (!this->text().isEmpty())) {// Fix to avoid having this event beeing added multiple times.
189 this, SLOT( slotColWidthChanged() ) ); 200 quickEvent.setDescription(this->text());
190 connect( qApp, SIGNAL(weekChanged(bool)), 201 connect(this,SIGNAL(insertEvent(const Event &)),this->topLevelWidget(),SLOT(insertEvent(const Event &)));
191 this, SLOT(slotWeekChanged(bool)) ); 202 emit(insertEvent(quickEvent));
192 connect( view, SIGNAL(sigCapturedKey(const QString &)), 203 active=0;
193 this, SIGNAL(sigNewEvent(const QString&)) ); 204 }
205 this->close(true);// Close and also delete this widget
206}
194 207
195 QTimer *timer = new QTimer( this ); 208void DateBookDayViewQuickLineEdit::focusOutEvent ( QFocusEvent * e )
209{
210 slotReturnPressed(); // Reuse code to add event and close this widget.
211}
196 212
197 connect( timer, SIGNAL(timeout()), 213//===========================================================================
198 this, SLOT(updateView()) );//connect timer for updating timeMarker & daywidgetcolors
199 timer->start( 1000*60*5, FALSE ); //update every 5min
200 214
201 selectedWidget = 0; 215DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, QWidget *parent, const char *name )
216 : QVBox( parent, name ), currDate( QDate::currentDate() ), db( newDb ), startTime( 0 )
217{
218 widgetList.setAutoDelete( true );
219 header = new DateBookDayHeader( startOnMonday, this, "day header" );
220 header->setDate( currDate.year(), currDate.month(), currDate.day() );
221 view = new DateBookDayView( ampm, this, "day view" );
222
223 connect( header, SIGNAL( dateChanged( int, int, int ) ), this, SLOT( dateChanged( int, int, int ) ) );
224 connect( header, SIGNAL( dateChanged( int, int, int ) ), view, SLOT( slotDateChanged( int, int, int ) ) );
225 connect( view, SIGNAL( sigColWidthChanged() ), this, SLOT( slotColWidthChanged() ) );
226 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) );
227 connect( view, SIGNAL(sigCapturedKey(const QString &)), this, SIGNAL(sigNewEvent(const QString&)) );
228
229 QTimer *timer = new QTimer( this );
230
231 connect( timer, SIGNAL(timeout()), this, SLOT(updateView()) );//connect timer for updating timeMarker & daywidgetcolors
232 timer->start( 1000*60*5, FALSE ); //update every 5min
202 233
203 timeMarker = new DateBookDayTimeMarker( this ); 234 selectedWidget = 0;
204 timeMarker->setTime( QTime::currentTime() ); 235
205 rowStyle = -1; // initialize with bogus values 236 timeMarker = new DateBookDayTimeMarker( this );
237 timeMarker->setTime( QTime::currentTime() );
238 rowStyle = -1; // initialize with bogus values
206} 239}
207 240
208void DateBookDay::setJumpToCurTime( bool bJump ) 241void DateBookDay::setJumpToCurTime( bool bJump )
209{ 242{
210 jumpToCurTime = bJump; 243 jumpToCurTime = bJump;
211} 244}
212 245
213void DateBookDay::setRowStyle( int style ) 246void DateBookDay::setRowStyle( int style )
214{ 247{
215 if (rowStyle != style) view->setRowStyle( style ); 248 if (rowStyle != style) view->setRowStyle( style );
216 rowStyle = style; 249 rowStyle = style;
217} 250}
218 251
219void DateBookDay::updateView( void ) 252void DateBookDay::updateView( void )
220{ 253{
221 timeMarker->setTime( QTime::currentTime() ); 254 timeMarker->setTime( QTime::currentTime() );
222 //need to find a way to update all DateBookDayWidgets 255 //need to find a way to update all DateBookDayWidgets
223} 256}
224 257
225void DateBookDay::setSelectedWidget( DateBookDayWidget *w ) 258void DateBookDay::setSelectedWidget( DateBookDayWidget *w )
226{ 259{
227 selectedWidget = w; 260 selectedWidget = w;
228} 261}
229 262
230DateBookDayWidget * DateBookDay::getSelectedWidget( void ) 263DateBookDayWidget * DateBookDay::getSelectedWidget( void )
231{ 264{
232 return selectedWidget; 265 return selectedWidget;
233} 266}
234 267
235void DateBookDay::selectedDates( QDateTime &start, QDateTime &end ) 268void DateBookDay::selectedDates( QDateTime &start, QDateTime &end )
236{ 269{
237 start.setDate( currDate ); 270 start.setDate( currDate );
238 end.setDate( currDate ); 271 end.setDate( currDate );
239 272
240 int sh=99,eh=-1; 273 int sh=99,eh=-1;
241 274
242 int n = dayView()->numSelections(); 275 int n = dayView()->numSelections();
243 276
244 for (int i=0; i<n; i++) { 277 for (int i=0; i<n; i++) {
245 QTableSelection sel = dayView()->selection( i ); 278 QTableSelection sel = dayView()->selection( i );
246 sh = QMIN(sh,sel.topRow()); 279 sh = QMIN(sh,sel.topRow());
247 eh = QMAX(sh,sel.bottomRow()+1); 280 eh = QMAX(sh,sel.bottomRow()+1);
248 } 281 }
249 if (sh > 23 || eh < 1) { 282
250 sh=8; 283 if (sh > 23 || eh < 1) {
251 eh=9; 284 sh=8;
252 } 285 eh=9;
286 }
253 287
254 start.setTime( QTime( sh, 0, 0 ) ); 288 start.setTime( QTime( sh, 0, 0 ) );
255 end.setTime( QTime( eh, 0, 0 ) ); 289 end.setTime( QTime( eh, 0, 0 ) );
256} 290}
257 291
258void DateBookDay::setDate( int y, int m, int d ) 292void DateBookDay::setDate( int y, int m, int d )
259{ 293{
260 header->setDate( y, m, d ); 294 header->setDate( y, m, d );
261 295 selectedWidget = 0;
262 selectedWidget = 0;
263} 296}
264 297
265void DateBookDay::setDate( QDate d) 298void DateBookDay::setDate( QDate d)
266{ 299{
267 header->setDate( d.year(), d.month(), d.day() ); 300 header->setDate( d.year(), d.month(), d.day() );
268 301 selectedWidget = 0;
269 selectedWidget = 0;
270} 302}
271 303
272void DateBookDay::dateChanged( int y, int m, int d ) 304void DateBookDay::dateChanged( int y, int m, int d )
273{ 305{
274 QDate date( y, m, d ); 306 QDate date( y, m, d );
275 if ( currDate == date ) 307 if ( currDate == date )
276 return; 308 return;
277 currDate.setYMD( y, m, d ); 309 currDate.setYMD( y, m, d );
278 relayoutPage(); 310 relayoutPage();
279 dayView()->clearSelection(); 311 dayView()->clearSelection();
280 QTableSelection ts; 312 QTableSelection ts;
281
282 if (jumpToCurTime && this->date() == QDate::currentDate())
283 {
284 ts.init( QTime::currentTime().hour(), 0);
285 ts.expandTo( QTime::currentTime().hour(), 0);
286 } else
287 {
288 ts.init( startTime, 0 );
289 ts.expandTo( startTime, 0 );
290 }
291
292 dayView()->addSelection( ts );
293 313
294 selectedWidget = 0; 314 if (jumpToCurTime && this->date() == QDate::currentDate())
315 {
316 ts.init( QTime::currentTime().hour(), 0);
317 ts.expandTo( QTime::currentTime().hour(), 0);
318 } else {
319 ts.init( startTime, 0 );
320 ts.expandTo( startTime, 0 );
321 }
295 322
323 dayView()->addSelection( ts );
324 selectedWidget = 0;
296} 325}
297 326
298void DateBookDay::redraw() 327void DateBookDay::redraw()
299{ 328{
300 if ( isUpdatesEnabled() ) 329 if ( isUpdatesEnabled() )
301 relayoutPage(); 330 relayoutPage();
302} 331}
303 332
304void DateBookDay::getEvents() 333void DateBookDay::getEvents()
305{ 334{
306 widgetList.clear(); 335 widgetList.clear();
307 336
308 QValueList<EffectiveEvent> eventList = db->getEffectiveEvents( currDate, currDate ); 337 QValueList<EffectiveEvent> eventList = db->getEffectiveEvents( currDate, currDate );
309 QValueListIterator<EffectiveEvent> it; 338 QValueListIterator<EffectiveEvent> it;
310 for ( it = eventList.begin(); it != eventList.end(); ++it ) { 339 for ( it = eventList.begin(); it != eventList.end(); ++it ) {
311 EffectiveEvent ev=*it; 340 EffectiveEvent ev=*it;
312 if(!((ev.end().hour()==0) && (ev.end().minute()==0) && (ev.startDate()!=ev.date()))) {// Skip events ending at 00:00 starting at another day. 341 if(!((ev.end().hour()==0) && (ev.end().minute()==0) && (ev.startDate()!=ev.date()))) {// Skip events ending at 00:00 starting at another day.
313 DateBookDayWidget* w = new DateBookDayWidget( *it, this ); 342 DateBookDayWidget* w = new DateBookDayWidget( *it, this );
314 connect( w, SIGNAL( deleteMe( const Event & ) ), 343 connect( w, SIGNAL( deleteMe( const Event & ) ), this, SIGNAL( removeEvent( const Event & ) ) );
315 this, SIGNAL( removeEvent( const Event & ) ) ); 344 connect( w, SIGNAL( duplicateMe( const Event & ) ), this, SIGNAL( duplicateEvent( const Event & ) ) );
316 connect( w, SIGNAL( duplicateMe( const Event & ) ), 345 connect( w, SIGNAL( editMe( const Event & ) ), this, SIGNAL( editEvent( const Event & ) ) );
317 this, SIGNAL( duplicateEvent( const Event & ) ) ); 346 connect( w, SIGNAL( beamMe( const Event & ) ), this, SIGNAL( beamEvent( const Event & ) ) );
318 connect( w, SIGNAL( editMe( const Event & ) ),
319 this, SIGNAL( editEvent( const Event & ) ) );
320 connect( w, SIGNAL( beamMe( const Event & ) ),
321 this, SIGNAL( beamEvent( const Event & ) ) );
322 widgetList.append( w ); 347 widgetList.append( w );
323 } 348 }
324 } 349 }
325
326} 350}
327 351
328static int place( const DateBookDayWidget *item, bool *used, int maxn ) 352static int place( const DateBookDayWidget *item, bool *used, int maxn )
329{ 353{
330 int place = 0; 354 int place = 0;
331 int start = item->event().start().hour(); 355 int start = item->event().start().hour();
332 QTime e = item->event().end(); 356 QTime e = item->event().end();
333 int end = e.hour(); 357 int end = e.hour();
334 if ( e.minute() < 5 ) 358 if ( e.minute() < 5 )
335 end--; 359 end--;
336 if ( end < start ) 360 if ( end < start )
337 end = start; 361 end = start;
338 while ( place < maxn ) { 362 while ( place < maxn ) {
339 bool free = TRUE; 363 bool free = TRUE;
340 int s = start; 364 int s = start;
341 while( s <= end ) { 365 while( s <= end ) {
342 if ( used[10*s+place] ) { 366 if ( used[10*s+place] ) {
343 free = FALSE; 367 free = FALSE;
344 break; 368 break;
345 } 369 }
346 s++; 370 s++;
371 }
372 if ( free )
373 break;
374 place++;
347 } 375 }
348 if ( free ) break; 376 if ( place == maxn ) {
349 place++; 377 return -1;
350 } 378 }
351 if ( place == maxn ) { 379 while( start <= end ) {
352 return -1; 380 used[10*start+place] = TRUE;
353 } 381 start++;
354 while( start <= end ) { 382 }
355 used[10*start+place] = TRUE; 383 return place;
356 start++;
357 }
358 return place;
359} 384}
360 385
361 386
362void DateBookDay::relayoutPage( bool fromResize ) 387void DateBookDay::relayoutPage( bool fromResize )
363{ 388{
364 setUpdatesEnabled( FALSE ); 389 setUpdatesEnabled( FALSE );
365 if ( !fromResize ) 390 if ( !fromResize )
366 getEvents(); // no need we already have them! 391 getEvents(); // no need we already have them!
367 392
368 widgetList.sort(); 393 widgetList.sort();
369 //sorts the widgetList by the heights of the widget so that the tallest widgets are at the beginning 394 //sorts the widgetList by the heights of the widget so that the tallest widgets are at the beginning
370 //this is needed for the simple algo below to work correctly, otherwise some widgets would be drawn outside the view 395 //this is needed for the simple algo below to work correctly, otherwise some widgets would be drawn outside the view
371 396
372 int wCount = widgetList.count(); 397 int wCount = widgetList.count();
373 int wid = view->columnWidth(0)-1; 398 int wid = view->columnWidth(0)-1;
374 int wd; 399 int wd;
375 int n = 1; 400 int n = 1;
376 401
377 QArray<int> anzIntersect(wCount); //this stores the number of maximal intersections of each widget 402 QArray<int> anzIntersect(wCount); //this stores the number of maximal intersections of each widget
378 403
379 for (int i = 0; i<wCount; anzIntersect[i] = 1, i++); 404 for (int i = 0; i<wCount; anzIntersect[i] = 1, i++);
380 405
381 if ( wCount < 20 ) { 406 if ( wCount < 20 ) {
382 407
383 QArray<QRect> geometries(wCount); 408 QArray<QRect> geometries(wCount);
384 for (int i = 0; i < wCount; geometries[i] = widgetList.at(i)->geometry(), i++);//stores geometry for each widget in vector 409 for (int i = 0; i < wCount; geometries[i] = widgetList.at(i)->geometry(), i++);//stores geometry for each widget in vector
385 410
386 for ( int i = 0; i < wCount; i++) 411 for ( int i = 0; i < wCount; i++) {
387 { 412 QValueList<int> intersectedWidgets;
388 QValueList<int> intersectedWidgets; 413
389 414 //find all widgets intersecting with widgetList.at(i)
390 //find all widgets intersecting with widgetList.at(i) 415 for ( int j = 0; j < wCount; j++) {
391 for ( int j = 0; j < wCount; j++) 416 if (i != j)
392 if (i != j) 417 if (geometries[j].intersects(geometries[i]))
393 if (geometries[j].intersects(geometries[i])) 418 intersectedWidgets.append(j);
394 intersectedWidgets.append(j); 419 }
395 420
396 //for each of these intersecting widgets find out how many widgets are they intersecting with 421 //for each of these intersecting widgets find out how many widgets are they intersecting with
397 for ( uint j = 0; j < intersectedWidgets.count(); j++) 422 for ( uint j = 0; j < intersectedWidgets.count(); j++)
398 { 423 {
399 QArray<int> inter(wCount); 424 QArray<int> inter(wCount);
400 inter[j]=1; 425 inter[j]=1;
401 426
402 if (intersectedWidgets[j] != -1) 427 if (intersectedWidgets[j] != -1)
403 for ( uint k = j; k < intersectedWidgets.count(); k++) 428 for ( uint k = j; k < intersectedWidgets.count(); k++) {
404 if (j != k && intersectedWidgets[k] != -1) 429 if (j != k && intersectedWidgets[k] != -1)
405 if (geometries[intersectedWidgets[k]].intersects(geometries[intersectedWidgets[j]])) 430 if (geometries[intersectedWidgets[k]].intersects(geometries[intersectedWidgets[j]])) {
406 { 431 inter[j]++;
407 inter[j]++; 432 intersectedWidgets[k] = -1;
408 intersectedWidgets[k] = -1; 433 }
409 } 434 if (inter[j] > anzIntersect[i]) anzIntersect[i] = inter[j] + 1;
410 if (inter[j] > anzIntersect[i]) anzIntersect[i] = inter[j] + 1; 435 }
436 }
437 if (anzIntersect[i] == 1 && intersectedWidgets.count()) anzIntersect[i]++;
411 } 438 }
412 439
413 if (anzIntersect[i] == 1 && intersectedWidgets.count()) anzIntersect[i]++;
414 }
415
416
417 for ( int i = 0; i < wCount; i++) {
418 DateBookDayWidget *w = widgetList.at(i);
419 QRect geom = w->geometry();
420
421 geom.setX( 0 );
422
423 wd = (view->columnWidth(0)-1) / anzIntersect[i] - (anzIntersect[i]>1?2:0);
424 440
425 geom.setWidth( wd ); 441 for ( int i = 0; i < wCount; i++) {
426 442 DateBookDayWidget *w = widgetList.at(i);
427 while ( intersects( w, geom ) ) { 443 QRect geom = w->geometry();
428 geom.moveBy( wd + 2 + 1, 0 ); 444 geom.setX( 0 );
429 } 445 wd = (view->columnWidth(0)-1) / anzIntersect[i] - (anzIntersect[i]>1?2:0);
430 w->setGeometry( geom ); 446 geom.setWidth( wd );
431 } 447 while ( intersects( w, geom ) ) {
432 448 geom.moveBy( wd + 2 + 1, 0 );
433 if (jumpToCurTime && this->date() == QDate::currentDate()) 449 }
434 view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour 450 w->setGeometry( geom );
435 else 451 }
436 view->setContentsPos( 0, startTime * view->rowHeight(0) );
437
438
439 } else {
440 452
453 if (jumpToCurTime && this->date() == QDate::currentDate()) {
454 view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour
455 } else {
456 view->setContentsPos( 0, startTime * view->rowHeight(0) );
457 }
458 } else {
459 int hours[24];
460 memset( hours, 0, 24*sizeof( int ) );
461 bool overFlow = FALSE;
462 for ( int i = 0; i < wCount; i++ ) {
463 DateBookDayWidget *w = widgetList.at(i);
464 int start = w->event().start().hour();
465 QTime e = w->event().end();
466 int end = e.hour();
467 if ( e.minute() < 5 )
468 end--;
469 if ( end < start )
470 end = start;
471 while( start <= end ) {
472 hours[start]++;
473 if ( hours[start] >= 10 )
474 overFlow = TRUE;
475 ++start;
476 }
477 if ( overFlow )
478 break;
479 }
480 for ( int i = 0; i < 24; i++ ) {
481 n = QMAX( n, hours[i] );
482 }
483 wid = ( view->columnWidth(0)-1 ) / n;
484
485 bool used[24*10];
486 memset( used, FALSE, 24*10*sizeof( bool ) );
487
488 for ( int i = 0; i < wCount; i++ ) {
489 DateBookDayWidget *w = widgetList.at(i);
490 int xp = place( w, used, n );
491 if ( xp != -1 ) {
492 QRect geom = w->geometry();
493 geom.setX( xp*(wid+2) );
494 geom.setWidth( wid );
495 w->setGeometry( geom );
496 }
497 }
441 498
442 int hours[24]; 499 if (jumpToCurTime && this->date() == QDate::currentDate()) {
443 memset( hours, 0, 24*sizeof( int ) ); 500 view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour
444 bool overFlow = FALSE; 501 } else {
445 for ( int i = 0; i < wCount; i++ ) { 502 view->setContentsPos( 0, startTime * view->rowHeight(0) );
446 DateBookDayWidget *w = widgetList.at(i); 503 }
447 int start = w->event().start().hour();
448 QTime e = w->event().end();
449 int end = e.hour();
450 if ( e.minute() < 5 )
451 end--;
452 if ( end < start )
453 end = start;
454 while( start <= end ) {
455 hours[start]++;
456 if ( hours[start] >= 10 )
457 overFlow = TRUE;
458 ++start;
459 }
460 if ( overFlow )
461 break;
462 }
463 for ( int i = 0; i < 24; i++ ) {
464 n = QMAX( n, hours[i] );
465 }
466 wid = ( view->columnWidth(0)-1 ) / n;
467
468 bool used[24*10];
469 memset( used, FALSE, 24*10*sizeof( bool ) );
470
471 for ( int i = 0; i < wCount; i++ ) {
472 DateBookDayWidget *w = widgetList.at(i);
473 int xp = place( w, used, n );
474 if ( xp != -1 ) {
475 QRect geom = w->geometry();
476 geom.setX( xp*(wid+2) );
477 geom.setWidth( wid );
478 w->setGeometry( geom );
479 }
480 } 504 }
481 505
482 if (jumpToCurTime && this->date() == QDate::currentDate()) 506 timeMarker->setTime( QTime::currentTime() );//display timeMarker
483 view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour 507 timeMarker->raise(); //on top of all widgets
484 else 508 if (this->date() == QDate::currentDate()) //only show timeMarker on current day
485 view->setContentsPos( 0, startTime * view->rowHeight(0) ); 509 timeMarker->show(); else timeMarker->hide();
486 }
487
488 timeMarker->setTime( QTime::currentTime() );//display timeMarker
489 timeMarker->raise(); //on top of all widgets
490 if (this->date() == QDate::currentDate()) //only show timeMarker on current day
491 timeMarker->show(); else timeMarker->hide();
492 510
493 setUpdatesEnabled( TRUE ); 511 setUpdatesEnabled( TRUE );
494 return; 512 return;
495} 513}
496 514
497DateBookDayWidget *DateBookDay::intersects( const DateBookDayWidget *item, const QRect &geom ) 515DateBookDayWidget *DateBookDay::intersects( const DateBookDayWidget *item, const QRect &geom )
498{ 516{
499 int i = 0; 517 int i = 0;
500 DateBookDayWidget *w = widgetList.at(i); 518 DateBookDayWidget *w = widgetList.at(i);
501 int wCount = widgetList.count(); 519 int wCount = widgetList.count();
502 while ( i < wCount && w != item ) { 520 while ( i < wCount && w != item ) {
503 if ( w->geometry().intersects( geom ) ) { 521 if ( w->geometry().intersects( geom ) ) {
504 return w; 522 return w;
523 }
524 w = widgetList.at(++i);
505 } 525 }
506 w = widgetList.at(++i);
507 }
508 526
509 return 0; 527 return 0;
510} 528}
511 529
512 530
513QDate DateBookDay::date() const 531QDate DateBookDay::date() const
514{ 532{
515 return currDate; 533 return currDate;
516} 534}
517 535
518void DateBookDay::setStartViewTime( int startHere ) 536void DateBookDay::setStartViewTime( int startHere )
519{ 537{
520 startTime = startHere; 538 startTime = startHere;
521 dayView()->clearSelection(); 539 dayView()->clearSelection();
522 QTableSelection ts; 540 QTableSelection ts;
523 541
524 if (jumpToCurTime && this->date() == QDate::currentDate())//this should probably be in datebook.cpp where it's called? 542 if (jumpToCurTime && this->date() == QDate::currentDate()) {//this should probably be in datebook.cpp where it's called?
525 { 543 ts.init( QTime::currentTime().hour(), 0);
526 ts.init( QTime::currentTime().hour(), 0); 544 ts.expandTo( QTime::currentTime().hour(), 0);
527 ts.expandTo( QTime::currentTime().hour(), 0); 545 } else {
528 } else 546 ts.init( startTime, 0 );
529 { 547 ts.expandTo( startTime, 0 );
530 ts.init( startTime, 0 ); 548 }
531 ts.expandTo( startTime, 0 );
532 }
533 549
534 dayView()->addSelection( ts ); 550 dayView()->addSelection( ts );
535} 551}
536 552
537int DateBookDay::startViewTime() const 553int DateBookDay::startViewTime() const
538{ 554{
539 return startTime; 555 return startTime;
540} 556}
541 557
542void DateBookDay::slotWeekChanged( bool bStartOnMonday ) 558void DateBookDay::slotWeekChanged( bool bStartOnMonday )
543{ 559{
544 header->setStartOfWeek( bStartOnMonday ); 560 header->setStartOfWeek( bStartOnMonday );
545 // redraw(); 561 //redraw();
546} 562}
547 563
548void DateBookDay::keyPressEvent(QKeyEvent *e) 564void DateBookDay::keyPressEvent(QKeyEvent *e)
549{ 565{
550 switch(e->key()) { 566 switch(e->key()) {
551 case Key_Up: 567 case Key_Up:
552 view->moveUp(); 568 view->moveUp();
553 break; 569 break;
554 case Key_Down: 570 case Key_Down:
555 view->moveDown(); 571 view->moveDown();
556 break; 572 break;
557 case Key_Left: 573 case Key_Left:
558 setDate(QDate(currDate).addDays(-1)); 574 setDate(QDate(currDate).addDays(-1));
559 break; 575 break;
560 case Key_Right: 576 case Key_Right:
561 setDate(QDate(currDate).addDays(1)); 577 setDate(QDate(currDate).addDays(1));
562 break; 578 break;
563 default: 579 default:
564 e->ignore(); 580 e->ignore();
565 } 581 }
566} 582}
567 583
568//=========================================================================== 584//===========================================================================
569 585
570DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, 586DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, DateBookDay *db )
571 DateBookDay *db ) 587 : QWidget( db->dayView()->viewport() ), ev( e ), dateBook( db )
572 : QWidget( db->dayView()->viewport() ), ev( e ), dateBook( db )
573{ 588{
574
575
576 // why would someone use "<"? Oh well, fix it up... 589 // why would someone use "<"? Oh well, fix it up...
577 // I wonder what other things may be messed up... 590 // I wonder what other things may be messed up...
578 QString strDesc = ev.description(); 591 QString strDesc = ev.description();
579 int where = strDesc.find( "<" ); 592 int where = strDesc.find( "<" );
580 while ( where != -1 ) { 593 while ( where != -1 ) {
581 strDesc.remove( where, 1 ); 594 strDesc.remove( where, 1 );
582 strDesc.insert( where, "&#60;" ); 595 strDesc.insert( where, "&#60;" );
583 where = strDesc.find( "<", where ); 596 where = strDesc.find( "<", where );
584 } 597 }
585 598
586 QString strCat; 599 QString strCat;
587 // ### Fix later... 600// ### Fix later...
588// QString strCat = ev.category(); 601// QString strCat = ev.category();
589// where = strCat.find( "<" ); 602// where = strCat.find( "<" );
590// while ( where != -1 ) { 603// while ( where != -1 ) {
591 // strCat.remove( where, 1 ); 604 // strCat.remove( where, 1 );
592 // strCat.insert( where, "&#60;" ); 605 // strCat.insert( where, "&#60;" );
593 // where = strCat.find( "<", where ); 606 // where = strCat.find( "<", where );
594// } 607// }
595 608
596 QString strNote = ev.notes(); 609 QString strNote = ev.notes();
597 where = strNote.find( "<" ); 610 where = strNote.find( "<" );
598 while ( where != -1 ) { 611 while ( where != -1 ) {
599 strNote.remove( where, 1 ); 612 strNote.remove( where, 1 );
600 strNote.insert( where, "&#60;" ); 613 strNote.insert( where, "&#60;" );
601 where = strNote.find( "<", where ); 614 where = strNote.find( "<", where );
602 } 615 }
603 616
604 text = "<b>" + strDesc + "</b><br>" + "<i>"; 617 text = "<b>" + strDesc + "</b><br>" + "<i>";
605 if ( !strCat.isEmpty() ) { 618 if ( !strCat.isEmpty() ) {
606 text += strCat + "</i><br>"; 619 text += strCat + "</i><br>";
607 } 620 }
608 if (ev.event().type() == Event::Normal ) 621 if (ev.event().type() == Event::Normal ) {
609 setEventText( text ); 622 setEventText( text );
610 else 623 } else {
611 setAllDayText( text ); 624 setAllDayText( text );
625 }
612 626
613 text += "<br><br>" + strNote; 627 text += "<br><br>" + strNote;
614 628
615 setBackgroundMode( PaletteBase ); 629 setBackgroundMode( PaletteBase );
616 630
617 QTime start = ev.start(); 631 QTime start = ev.start();
618 QTime end = ev.end(); 632 QTime end = ev.end();
619 int y = start.hour()*60+start.minute(); 633 int y = start.hour()*60+start.minute();
620 int h = end.hour()*60+end.minute()-y; 634 int h = end.hour()*60+end.minute()-y;
621 int rh = dateBook->dayView()->rowHeight(0); 635 int rh = dateBook->dayView()->rowHeight(0);
622 y = y*rh/60; 636 y = y*rh/60;
623 h = h*rh/60; 637 h = h*rh/60;
624 638
625 if ( h < 12 ) h = 12;// Make sure the widget is no smaller than 12 pixels high, so that it's possible to read atleast the first line. 639 if ( h < 12 ) h = 12;// Make sure the widget is no smaller than 12 pixels high, so that it's possible to read atleast the first line.
626 if ( y > ((24*rh)-12) ) y=(24*rh)-12;// Make sure the widget fits inside the dayview. 640 if ( y > ((24*rh)-12) ) y=(24*rh)-12;// Make sure the widget fits inside the dayview.
627 geom.setY( y ); 641 geom.setY( y );
628 geom.setHeight( h ); 642 geom.setHeight( h );
629 geom.setX( 0 ); 643 geom.setX( 0 );
630 geom.setWidth(dateBook->dayView()->columnWidth(0)-1); 644 geom.setWidth(dateBook->dayView()->columnWidth(0)-1);
631 645
632} 646}
647
633void DateBookDayWidget::setAllDayText( QString &text ) { 648void DateBookDayWidget::setAllDayText( QString &text ) {
634 text += "<b>" + tr("This is an all day event.") + "</b>"; 649 text += "<b>" + tr("This is an all day event.") + "</b>";
635} 650}
651
636void DateBookDayWidget::setEventText( QString& text ) { 652void DateBookDayWidget::setEventText( QString& text ) {
637 bool whichClock = dateBook->dayView()->whichClock(); 653 bool whichClock = dateBook->dayView()->whichClock();
638 if ( ev.startDate() != ev.endDate() ) { 654 if ( ev.startDate() != ev.endDate() ) {
639 text += "<b>" + tr("Start") + "</b>: "; 655 text += "<b>" + tr("Start") + "</b>: ";
640 text += TimeString::timeString( ev.event().start().time(), whichClock, FALSE ); 656 text += TimeString::timeString( ev.event().start().time(), whichClock, FALSE );
641 text += " - " + TimeString::longDateString( ev.startDate() ) + "<br>"; 657 text += " - " + TimeString::longDateString( ev.startDate() ) + "<br>";
642 text += "<b>" + tr("End") + "</b>: "; 658 text += "<b>" + tr("End") + "</b>: ";
643 text += TimeString::timeString( ev.event().end().time(), whichClock, FALSE ); 659 text += TimeString::timeString( ev.event().end().time(), whichClock, FALSE );
644 text += " - " + TimeString::longDateString( ev.endDate() ); 660 text += " - " + TimeString::longDateString( ev.endDate() );
645 } else { 661 } else {
646 text += "<b>" + tr("Time") + "</b>: "; 662 text += "<b>" + tr("Time") + "</b>: ";
647 text += TimeString::timeString( ev.start(), whichClock, FALSE ); 663 text += TimeString::timeString( ev.start(), whichClock, FALSE );
648 text += "<b>" + tr(" - ") + "</b>"; 664 text += "<b>" + tr(" - ") + "</b>";
649 text += TimeString::timeString( ev.end(), whichClock, FALSE ); 665 text += TimeString::timeString( ev.end(), whichClock, FALSE );
650 } 666 }
651} 667}
652 668
653DateBookDayWidget::~DateBookDayWidget() 669DateBookDayWidget::~DateBookDayWidget()
654{ 670{
655} 671}
656 672
657void DateBookDayWidget::paintEvent( QPaintEvent *e ) 673void DateBookDayWidget::paintEvent( QPaintEvent *e )
658{ 674{
659 QPainter p( this ); 675 QPainter p( this );
660 676
661 if (dateBook->getSelectedWidget() == this) 677 if (dateBook->getSelectedWidget() == this) {
662 { 678 p.setBrush( QColor( 155, 240, 230 ) ); // selected item
663 p.setBrush( QColor( 155, 240, 230 ) ); // selected item 679 } else {
664 } else 680 if (dateBook->date() == QDate::currentDate()) {
665 { 681 QTime curTime = QTime::currentTime();
666 if (dateBook->date() == QDate::currentDate()) 682 if (ev.end() < curTime) {
667 { 683 p.setBrush( QColor( 180, 180, 180 ) ); // grey, inactive
668 QTime curTime = QTime::currentTime(); 684 } else {
669 685 //change color in dependence of the time till the event starts
670 if (ev.end() < curTime) 686 int duration = curTime.secsTo(ev.start());
671 { 687 if (duration < 0) duration = 0;
672 p.setBrush( QColor( 180, 180, 180 ) ); // grey, inactive 688 int colChange = duration*160/86400; //86400: secs per day, 160: max color shift
673 } else 689 p.setBrush( QColor( 200-colChange, 200-colChange, 255 ) ); //blue
674 { 690 }
675 //change color in dependence of the time till the event starts 691 } else {
676 int duration = curTime.secsTo(ev.start()); 692 p.setBrush( QColor( 220, 220, 220 ) ); //light grey, inactive (not current date)
677 if (duration < 0) duration = 0; 693 //perhaps make a distinction between future/past dates
678 int colChange = duration*160/86400; //86400: secs per day, 160: max color shift 694 }
679 695 }
680 p.setBrush( QColor( 200-colChange, 200-colChange, 255 ) ); //blue
681 }
682 } else
683 {
684 p.setBrush( QColor( 220, 220, 220 ) ); //light grey, inactive (not current date)
685 //perhaps make a distinction between future/past dates
686 }
687 }
688 696
689 p.setPen( QColor(100, 100, 100) ); 697 p.setPen( QColor(100, 100, 100) );
690 p.drawRect(rect()); 698 p.drawRect(rect());
691 699
692 // p.drawRect(0,0, 5, height()); 700 // p.drawRect(0,0, 5, height());
693 701
694 int y = 0; 702 int y = 0;
695 int d = 0; 703 int d = 0;
696 704
697 if ( ev.event().hasAlarm() ) { 705 if ( ev.event().hasAlarm() ) {
698 p.drawPixmap( width() - 16, 0, Resource::loadPixmap( "bell" ) ); 706 p.drawPixmap( width() - 16, 0, Resource::loadPixmap( "bell" ) );
699 y = 20; 707 y = 20;
700 d = 20; 708 d = 20;
701 } 709 }
702 710
703 if ( ev.event().hasRepeat() ) { 711 if ( ev.event().hasRepeat() ) {
704 p.drawPixmap( width() - 16, y, Resource::loadPixmap( "repeat" ) ); 712 p.drawPixmap( width() - 16, y, Resource::loadPixmap( "repeat" ) );
705 d = 20; 713 d = 20;
706 y += 20; 714 y += 20;
707 } 715 }
708 716
709 QSimpleRichText rt( text, font() ); 717 QSimpleRichText rt( text, font() );
710 rt.setWidth( geom.width() - d - 6 ); 718 rt.setWidth( geom.width() - d - 6 );
711 rt.draw( &p, 7, 0, e->region(), colorGroup() ); 719 rt.draw( &p, 7, 0, e->region(), colorGroup() );
712} 720}
713 721
714void DateBookDayWidget::mousePressEvent( QMouseEvent *e ) 722void DateBookDayWidget::mousePressEvent( QMouseEvent *e )
715{ 723{
716 DateBookDayWidget *item; 724 DateBookDayWidget *item;
717 725
718 item = dateBook->getSelectedWidget(); 726 item = dateBook->getSelectedWidget();
719 if (item) item->update(); 727 if (item)
728 item->update();
720 729
721 dateBook->setSelectedWidget(this); 730 dateBook->setSelectedWidget(this);
722 update(); 731 update();
723 dateBook->repaint(); 732 dateBook->repaint();
724 733
725 QPopupMenu m; 734 QPopupMenu m;
726 m.insertItem( tr( "Edit" ), 1 ); 735 m.insertItem( tr( "Edit" ), 1 );
727 m.insertItem( tr( "Duplicate" ), 4 ); 736 m.insertItem( tr( "Duplicate" ), 4 );
728 m.insertItem( tr( "Delete" ), 2 ); 737 m.insertItem( tr( "Delete" ), 2 );
729 if(Ir::supported()) m.insertItem( tr( "Beam" ), 3 ); 738 if(Ir::supported()) m.insertItem( tr( "Beam" ), 3 );
730 int r = m.exec( e->globalPos() ); 739 int r = m.exec( e->globalPos() );
731 if ( r == 1 ) { 740 if ( r == 1 ) {
732 emit editMe( ev.event() ); 741 emit editMe( ev.event() );
733 } else if ( r == 2 ) { 742 } else if ( r == 2 ) {
734 emit deleteMe( ev.event() ); 743 emit deleteMe( ev.event() );
735 } else if ( r == 3 ) { 744 } else if ( r == 3 ) {
736 emit beamMe( ev.event() ); 745 emit beamMe( ev.event() );
737 } else if ( r == 4 ) { 746 } else if ( r == 4 ) {
738 emit duplicateMe( ev.event() ); 747 emit duplicateMe( ev.event() );
739 } 748 }
740} 749}
741 750
742void DateBookDayWidget::setGeometry( const QRect &r ) 751void DateBookDayWidget::setGeometry( const QRect &r )
743{ 752{
744 geom = r; 753 geom = r;
745 setFixedSize( r.width()+1, r.height()+1 ); 754 setFixedSize( r.width()+1, r.height()+1 );
746 dateBook->dayView()->moveChild( this, r.x(), r.y()-1 ); 755 dateBook->dayView()->moveChild( this, r.x(), r.y()-1 );
747 show(); 756 show();
748} 757}
749 758
750 759
751//--------------------------------------------------------------------------------------------- 760//---------------------------------------------------------------------------------------------
752//--------------------------------------------------------------------------------------------- 761//---------------------------------------------------------------------------------------------
753 762
754 763
755DateBookDayTimeMarker::DateBookDayTimeMarker( DateBookDay *db ) 764DateBookDayTimeMarker::DateBookDayTimeMarker( DateBookDay *db )
756 : QWidget( db->dayView()->viewport() ), dateBook( db ) 765 : QWidget( db->dayView()->viewport() ), dateBook( db )
757{ 766{
758 setBackgroundMode( PaletteBase ); 767 setBackgroundMode( PaletteBase );
759} 768}
760 769
761DateBookDayTimeMarker::~DateBookDayTimeMarker() 770DateBookDayTimeMarker::~DateBookDayTimeMarker()
762{ 771{
763} 772}
764 773
765void DateBookDayTimeMarker::paintEvent( QPaintEvent */*e*/ ) 774void DateBookDayTimeMarker::paintEvent( QPaintEvent */*e*/ )
766{ 775{
767 QPainter p( this ); 776 QPainter p( this );
768 p.setBrush( QColor( 255, 0, 0 ) ); 777 p.setBrush( QColor( 255, 0, 0 ) );
769 778
770 QPen pen; 779 QPen pen;
771 pen.setStyle(NoPen); 780 pen.setStyle(NoPen);
772 781
773 p.setPen( pen ); 782 p.setPen( pen );
774 p.drawRect(rect()); 783 p.drawRect(rect());
775} 784}
776 785
777void DateBookDayTimeMarker::setTime( const QTime &t ) 786void DateBookDayTimeMarker::setTime( const QTime &t )
778{ 787{
779 int y = t.hour()*60+t.minute(); 788 int y = t.hour()*60+t.minute();
780 int rh = dateBook->dayView()->rowHeight(0); 789 int rh = dateBook->dayView()->rowHeight(0);
781 y = y*rh/60; 790 y = y*rh/60;
782 791
783 geom.setX( 0 ); 792 geom.setX( 0 );
784 793
785 int x = dateBook->dayView()->columnWidth(0)-1; 794 int x = dateBook->dayView()->columnWidth(0)-1;
786 geom.setWidth( x ); 795 geom.setWidth( x );
787 796
788 geom.setY( y ); 797 geom.setY( y );
789 geom.setHeight( 1 ); 798 geom.setHeight( 1 );
790 799
791 setGeometry( geom ); 800 setGeometry( geom );
792 801
793 time = t; 802 time = t;
794} 803}
795 804
796void DateBookDayTimeMarker::setGeometry( const QRect &r ) 805void DateBookDayTimeMarker::setGeometry( const QRect &r )
797{ 806{
798 geom = r; 807 geom = r;
799 setFixedSize( r.width()+1, r.height()+1 ); 808 setFixedSize( r.width()+1, r.height()+1 );
800 dateBook->dayView()->moveChild( this, r.x(), r.y()-1 ); 809 dateBook->dayView()->moveChild( this, r.x(), r.y()-1 );
801 show(); 810 show();
802} 811}
diff --git a/core/pim/datebook/datebookday.h b/core/pim/datebook/datebookday.h
index 2faf24e..961f60f 100644
--- a/core/pim/datebook/datebookday.h
+++ b/core/pim/datebook/datebookday.h
@@ -1,207 +1,230 @@
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 DATEBOOKDAY_H 20#ifndef DATEBOOKDAY_H
21#define DATEBOOKDAY_H 21#define DATEBOOKDAY_H
22 22
23#include <qpe/event.h> 23#include <qpe/event.h>
24 24
25#include <qdatetime.h> 25#include <qdatetime.h>
26#include <qtable.h> 26#include <qtable.h>
27#include <qvbox.h> 27#include <qvbox.h>
28#include <qlist.h> 28#include <qlist.h>
29 29
30#include "datebook.h"
31#include <qlineedit.h>
32
30class DateBookDayHeader; 33class DateBookDayHeader;
31class DateBookDB; 34class DateBookDB;
32class QDateTime; 35class QDateTime;
33class QMouseEvent; 36class QMouseEvent;
34class QPaintEvent; 37class QPaintEvent;
35class QResizeEvent; 38class QResizeEvent;
36 39
40class DateBookDayViewQuickLineEdit : public QLineEdit
41{
42 Q_OBJECT
43public:
44 DateBookDayViewQuickLineEdit(const QDateTime &start, const QDateTime &end,QWidget * parent, const char *name=0);
45protected:
46 Event quickEvent;
47 int active;
48 void focusOutEvent( QFocusEvent *e );
49protected slots:
50 void slotReturnPressed(void);
51signals:
52 void insertEvent(const Event &e);
53};
54
55
37class DateBookDayView : public QTable 56class DateBookDayView : public QTable
38{ 57{
39 Q_OBJECT 58 Q_OBJECT
40public: 59public:
41 DateBookDayView( bool hourClock, QWidget *parent, const char *name ); 60 DateBookDayView( bool hourClock, QWidget *parent, const char *name );
42 bool whichClock() const; 61 bool whichClock() const;
43 62
44 void setRowStyle( int style ); 63 void setRowStyle( int style );
45 64
46public slots: 65public slots:
47 void moveUp(); 66 void moveUp();
48 void moveDown(); 67 void moveDown();
68 void slotDateChanged( int year, int month, int day );
49 69
50signals: 70signals:
51 void sigColWidthChanged(); 71 void sigColWidthChanged();
52 void sigCapturedKey( const QString &txt ); 72 void sigCapturedKey( const QString &txt );
53protected slots: 73protected slots:
54 void slotChangeClock( bool ); 74 void slotChangeClock( bool );
55protected: 75protected:
56 virtual void paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected ); 76 virtual void paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected );
57 virtual void paintFocus( QPainter *p, const QRect &cr ); 77 virtual void paintFocus( QPainter *p, const QRect &cr );
58 78
59 virtual void resizeEvent( QResizeEvent *e ); 79 virtual void resizeEvent( QResizeEvent *e );
60 void keyPressEvent( QKeyEvent *e ); 80 void keyPressEvent( QKeyEvent *e );
81 void contentsMouseReleaseEvent( QMouseEvent *e );
61 void initHeader(); 82 void initHeader();
62private: 83private:
63 bool ampm; 84 bool ampm;
85 QDate currDate;
86 DateBookDayViewQuickLineEdit *quickLineEdit;
64}; 87};
65 88
66class DateBookDay; 89class DateBookDay;
67class DateBookDayWidget : public QWidget 90class DateBookDayWidget : public QWidget
68{ 91{
69 Q_OBJECT 92 Q_OBJECT
70 93
71public: 94public:
72 DateBookDayWidget( const EffectiveEvent &e, DateBookDay *db ); 95 DateBookDayWidget( const EffectiveEvent &e, DateBookDay *db );
73 ~DateBookDayWidget(); 96 ~DateBookDayWidget();
74 97
75 const QRect &geometry() { return geom; } 98 const QRect &geometry() { return geom; }
76 void setGeometry( const QRect &r ); 99 void setGeometry( const QRect &r );
77 100
78 const EffectiveEvent &event() const { return ev; } 101 const EffectiveEvent &event() const { return ev; }
79 102
80signals: 103signals:
81 void deleteMe( const Event &e ); 104 void deleteMe( const Event &e );
82 void duplicateMe( const Event &e ); 105 void duplicateMe( const Event &e );
83 void editMe( const Event &e ); 106 void editMe( const Event &e );
84 void beamMe( const Event &e ); 107 void beamMe( const Event &e );
85 108
86protected: 109protected:
87 void paintEvent( QPaintEvent *e ); 110 void paintEvent( QPaintEvent *e );
88 void mousePressEvent( QMouseEvent *e ); 111 void mousePressEvent( QMouseEvent *e );
89 112
90private: 113private:
91 /** 114 /**
92 * Sets the text for an all day Event 115 * Sets the text for an all day Event
93 * All day events have no time associated 116 * All day events have no time associated
94 */ 117 */
95 void setAllDayText( QString& text ); 118 void setAllDayText( QString& text );
96 119
97 /** 120 /**
98 * Sets the EventText 121 * Sets the EventText
99 * it got a start and an end Time 122 * it got a start and an end Time
100 */ 123 */
101 void setEventText( QString& text ); 124 void setEventText( QString& text );
102 const EffectiveEvent ev; 125 const EffectiveEvent ev;
103 DateBookDay *dateBook; 126 DateBookDay *dateBook;
104 QString text; 127 QString text;
105 QRect geom; 128 QRect geom;
106}; 129};
107 130
108//Marker for current time in the dayview 131//Marker for current time in the dayview
109class DateBookDayTimeMarker : public QWidget 132class DateBookDayTimeMarker : public QWidget
110{ 133{
111 Q_OBJECT 134 Q_OBJECT
112 135
113public: 136public:
114 DateBookDayTimeMarker( DateBookDay *db ); 137 DateBookDayTimeMarker( DateBookDay *db );
115 ~DateBookDayTimeMarker(); 138 ~DateBookDayTimeMarker();
116 139
117 const QRect &geometry() { return geom; } 140 const QRect &geometry() { return geom; }
118 void setGeometry( const QRect &r ); 141 void setGeometry( const QRect &r );
119 void setTime( const QTime &t ); 142 void setTime( const QTime &t );
120 143
121signals: 144signals:
122 145
123protected: 146protected:
124 void paintEvent( QPaintEvent *e ); 147 void paintEvent( QPaintEvent *e );
125 148
126private: 149private:
127 QRect geom; 150 QRect geom;
128 QTime time; 151 QTime time;
129 DateBookDay *dateBook; 152 DateBookDay *dateBook;
130}; 153};
131 154
132//reimplemented the compareItems function so that it sorts DayWidgets by geometry heights 155//reimplemented the compareItems function so that it sorts DayWidgets by geometry heights
133class WidgetListClass : public QList<DateBookDayWidget> 156class WidgetListClass : public QList<DateBookDayWidget>
134{ 157{
135 private: 158 private:
136 159
137 int compareItems( QCollection::Item s1, QCollection::Item s2 ) 160 int compareItems( QCollection::Item s1, QCollection::Item s2 )
138 { 161 {
139 //hmm, don't punish me for that ;) 162 //hmm, don't punish me for that ;)
140 if (reinterpret_cast<DateBookDayWidget*>(s1)->geometry().height() > reinterpret_cast<DateBookDayWidget*>(s2)->geometry().height()) 163 if (reinterpret_cast<DateBookDayWidget*>(s1)->geometry().height() > reinterpret_cast<DateBookDayWidget*>(s2)->geometry().height())
141 { 164 {
142 return -1; 165 return -1;
143 } else 166 } else
144 { 167 {
145 return 1; 168 return 1;
146 } 169 }
147 } 170 }
148 171
149 172
150}; 173};
151 174
152class DateBookDay : public QVBox 175class DateBookDay : public QVBox
153{ 176{
154 Q_OBJECT 177 Q_OBJECT
155 178
156public: 179public:
157 DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, 180 DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb,
158 QWidget *parent, const char *name ); 181 QWidget *parent, const char *name );
159 void selectedDates( QDateTime &start, QDateTime &end ); 182 void selectedDates( QDateTime &start, QDateTime &end );
160 QDate date() const; 183 QDate date() const;
161 DateBookDayView *dayView() const { return view; } 184 DateBookDayView *dayView() const { return view; }
162 void setStartViewTime( int startHere ); 185 void setStartViewTime( int startHere );
163 int startViewTime() const; 186 int startViewTime() const;
164 void setSelectedWidget( DateBookDayWidget * ); 187 void setSelectedWidget( DateBookDayWidget * );
165 DateBookDayWidget * getSelectedWidget( void ); 188 DateBookDayWidget * getSelectedWidget( void );
166 void setJumpToCurTime( bool bJump ); 189 void setJumpToCurTime( bool bJump );
167 void setRowStyle( int style ); 190 void setRowStyle( int style );
168 191
169public slots: 192public slots:
170 void setDate( int y, int m, int d ); 193 void setDate( int y, int m, int d );
171 void setDate( QDate ); 194 void setDate( QDate );
172 void redraw(); 195 void redraw();
173 void slotWeekChanged( bool bStartOnMonday ); 196 void slotWeekChanged( bool bStartOnMonday );
174 void updateView();//updates TimeMarker and DayWidget-colors 197 void updateView();//updates TimeMarker and DayWidget-colors
175 198
176signals: 199signals:
177 void removeEvent( const Event& ); 200 void removeEvent( const Event& );
178 void editEvent( const Event& ); 201 void editEvent( const Event& );
179 void duplicateEvent( const Event& ); 202 void duplicateEvent( const Event& );
180 void beamEvent( const Event& ); 203 void beamEvent( const Event& );
181 void newEvent(); 204 void newEvent();
182 void sigNewEvent( const QString & ); 205 void sigNewEvent( const QString & );
183 206
184protected slots: 207protected slots:
185 void keyPressEvent(QKeyEvent *); 208 void keyPressEvent(QKeyEvent *);
186 209
187private slots: 210private slots:
188 void dateChanged( int y, int m, int d ); 211 void dateChanged( int y, int m, int d );
189 void slotColWidthChanged() { relayoutPage(); }; 212 void slotColWidthChanged() { relayoutPage(); };
190 213
191private: 214private:
192 void getEvents(); 215 void getEvents();
193 void relayoutPage( bool fromResize = false ); 216 void relayoutPage( bool fromResize = false );
194 DateBookDayWidget *intersects( const DateBookDayWidget *item, const QRect &geom ); 217 DateBookDayWidget *intersects( const DateBookDayWidget *item, const QRect &geom );
195 QDate currDate; 218 QDate currDate;
196 DateBookDayView *view; 219 DateBookDayView *view;
197 DateBookDayHeader *header; 220 DateBookDayHeader *header;
198 DateBookDB *db; 221 DateBookDB *db;
199 WidgetListClass widgetList;//reimplemented QList for sorting widgets by height 222 WidgetListClass widgetList;//reimplemented QList for sorting widgets by height
200 int startTime; 223 int startTime;
201 bool jumpToCurTime;//should we jump to current time in dayview? 224 bool jumpToCurTime;//should we jump to current time in dayview?
202 int rowStyle; 225 int rowStyle;
203 DateBookDayWidget *selectedWidget; //actual selected widget (obviously) 226 DateBookDayWidget *selectedWidget; //actual selected widget (obviously)
204 DateBookDayTimeMarker *timeMarker;//marker for current time 227 DateBookDayTimeMarker *timeMarker;//marker for current time
205}; 228};
206 229
207#endif 230#endif