summaryrefslogtreecommitdiff
authorumopapisdn <umopapisdn>2003-05-05 21:44:39 (UTC)
committer umopapisdn <umopapisdn>2003-05-05 21:44:39 (UTC)
commit3b193b852133a82b5c1708b68a7e460c63629768 (patch) (unidiff)
tree8cd0ff3adc14f0b937d24ab99fca327fb3f16875
parent12a700f8903eedeba03d3aba7990b9d660410045 (diff)
downloadopie-3b193b852133a82b5c1708b68a7e460c63629768.zip
opie-3b193b852133a82b5c1708b68a7e460c63629768.tar.gz
opie-3b193b852133a82b5c1708b68a7e460c63629768.tar.bz2
UI and code cleanup. Both UI and code is now more consistent. Also removed menus in favor of toolbuttons. (why were they even available as menus in the first place?)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp276
-rw-r--r--core/pim/datebook/datebookweek.cpp179
-rw-r--r--core/pim/datebook/datebookweek.h2
-rw-r--r--core/pim/datebook/datebookweekheader.ui62
-rw-r--r--core/pim/datebook/datebookweekheaderimpl.cpp137
-rw-r--r--core/pim/datebook/datebookweekheaderimpl.h19
-rw-r--r--core/pim/datebook/datebookweeklst.cpp212
-rw-r--r--core/pim/datebook/datebookweeklst.h41
-rw-r--r--core/pim/datebook/datebookweeklstheader.ui127
9 files changed, 453 insertions, 602 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index cf1eeca..b7e89b0 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -1,1015 +1,991 @@
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// QPopupMenu *view = new QPopupMenu( this );
110 110// mb->insertItem( tr( "View" ), view );
111 QPopupMenu *view = new QPopupMenu( this ); 111
112 QPopupMenu *settings = new QPopupMenu( this ); 112 QPEToolBar *sub_bar = new QPEToolBar(this);
113 113 sub_bar->setHorizontalStretchable(TRUE);
114 mb->insertItem( tr( "View" ), view ); 114
115 mb->insertItem( tr( "Settings" ), settings ); 115 QActionGroup *g = new QActionGroup( this );
116 116 g->setExclusive( TRUE );
117 QActionGroup *g = new QActionGroup( this ); 117
118 g->setExclusive( TRUE ); 118 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
119 119 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
120 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), 120 a->addTo( sub_bar );
121 QString::null, 0, this, 0 ); 121
122 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 122 sub_bar->addSeparator();
123 a->addTo( sub_bar ); 123
124 124 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 ); 125 connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) );
126 connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); 126 a->addTo( sub_bar );
127 a->addTo( sub_bar ); 127 //a->addTo( view );
128 a->addTo( view ); 128
129 129 sub_bar->addSeparator();
130 a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); 130
131 connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); 131 a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 );
132 a->addTo( sub_bar ); 132 connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) );
133 a->addTo( view ); 133 a->addTo( sub_bar );
134 a->setToggleAction( TRUE ); 134// a->addTo( view );
135 a->setOn( TRUE ); 135 a->setToggleAction( TRUE );
136 dayAction = a; 136 a->setOn( TRUE );
137 137 dayAction = a;
138 a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); 138
139 connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); 139 a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 );
140 a->addTo( sub_bar ); 140 connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) );
141 a->addTo( view ); 141 a->addTo( sub_bar );
142 a->setToggleAction( TRUE ); 142// a->addTo( view );
143 weekAction = a; 143 a->setToggleAction( TRUE );
144 144 weekAction = a;
145 a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 ); 145
146 connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); 146 a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 );
147 a->addTo( sub_bar ); 147 connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) );
148 a->addTo( view ); 148 a->addTo( sub_bar );
149 a->setToggleAction( TRUE ); 149// a->addTo( view );
150 weekLstAction = a; 150 a->setToggleAction( TRUE );
151 151 weekLstAction = a;
152 a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); 152
153 connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); 153 a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 );
154 a->addTo( sub_bar ); 154 connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) );
155 a->addTo( view ); 155 a->addTo( sub_bar );
156 a->setToggleAction( TRUE ); 156// a->addTo( view );
157 monthAction = a; 157 a->setToggleAction( TRUE );
158 158 monthAction = a;
159 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, g, 0 ); 159
160 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); 160 sub_bar->addSeparator();
161 a->addTo( sub_bar ); 161
162 162 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 );
163 a = new QAction( tr( "Edit..." ), QString::null, 0, 0 ); 163 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) );
164 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); 164 a->addTo( sub_bar );
165 a->addTo( settings ); 165
166 a = new QAction( tr( "Edit..." ), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0 );
167 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
168 a->addTo( sub_bar );
166 169
167 if(defaultView==DAY) viewDay(); 170 if(defaultView==DAY) viewDay();
168 if(defaultView==WEEK) needEvilHack=true;// viewWeek(); 171 if(defaultView==WEEK) needEvilHack=true;// viewWeek();
169 if(defaultView==WEEKLST) viewWeekLst(); 172 if(defaultView==WEEKLST) viewWeekLst();
170 if(defaultView==MONTH) viewMonth(); 173 if(defaultView==MONTH) viewMonth();
171 174
172 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); 175 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) );
173 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) ); 176 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) );
174 177
175#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 178#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&)) ); 179 connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), this, SLOT(appMessage(const QCString&, const QByteArray&)) );
177#endif 180#endif
178 181
179 // listen on QPE/System 182 // listen on QPE/System
180#if defined(Q_WS_QWS) 183#if defined(Q_WS_QWS)
181#if !defined(QT_NO_COP) 184#if !defined(QT_NO_COP)
182 QCopChannel *channel = new QCopChannel( "QPE/System", this ); 185 QCopChannel *channel = new QCopChannel( "QPE/System", this );
183 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); 186 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) );
184 channel = new QCopChannel( "QPE/Datebook", this ); 187 channel = new QCopChannel( "QPE/Datebook", this );
185 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); 188 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) );
186 qDebug("olle\n"); 189 qDebug("olle\n");
187#endif 190#endif
188#endif 191#endif
189 192
190 qDebug("done t=%d", t.elapsed() ); 193 qDebug("done t=%d", t.elapsed() );
191 194
192 /* 195 /*
193 * Here is a problem description: 196 * Here is a problem description:
194 * When Weekview is the default view 197 * When Weekview is the default view
195 * a DateBookWeekView get's created 198 * a DateBookWeekView get's created
196 * redraw() get's called. So what? 199 * redraw() get's called. So what?
197 * Remember that we're still in the c'tor 200 * Remember that we're still in the c'tor
198 * and no final layout has happened? Ok 201 * and no final layout has happened? Ok
199 * now all Events get arranged. Their x 202 * now all Events get arranged. Their x
200 * position get's determined by a QHeader 203 * position get's determined by a QHeader
201 * position. But the QHeader isn't layouted or 204 * position. But the QHeader isn't layouted or
202 * at the right position. redraw() is a slot 205 * at the right position. redraw() is a slot
203 * so we'll call it then via a singleShot 206 * so we'll call it then via a singleShot
204 * from view() 207 * from view()
205 */ 208 */
206 if( needEvilHack ){ 209 if( needEvilHack ){
207 QTimer::singleShot( 500, this, SLOT(viewWeek()) ); 210 QTimer::singleShot( 500, this, SLOT(viewWeek()) );
208 } 211 }
209} 212}
210 213
211void DateBook::receive( const QCString &msg, const QByteArray &data ) 214void DateBook::receive( const QCString &msg, const QByteArray &data )
212{ 215{
213 QDataStream stream( data, IO_ReadOnly ); 216 QDataStream stream( data, IO_ReadOnly );
214 if ( msg == "timeChange(QString)" ) { 217 if ( msg == "timeChange(QString)" ) {
215 // update active view! 218 // update active view!
216 if ( dayAction->isOn() ) 219 if ( dayAction->isOn() )
217 viewDay(); 220 viewDay();
218 else if ( weekAction->isOn() ) 221 else if ( weekAction->isOn() )
219 viewWeek(); 222 viewWeek();
220 else if ( monthAction->isOn() ) 223 else if ( monthAction->isOn() )
221 viewMonth(); 224 viewMonth();
222 } 225 }
223 else if (msg == "editEvent(int)") { 226 else if (msg == "editEvent(int)") {
224 int uid; 227 int uid;
225 stream >> uid; 228 stream >> uid;
226 Event e=db->eventByUID(uid); 229 Event e=db->eventByUID(uid);
227 editEvent(e); 230 editEvent(e);
228 } 231 }
229} 232}
230 233
231DateBook::~DateBook() 234DateBook::~DateBook()
232{ 235{
233} 236}
234 237
235void DateBook::slotSettings() 238void DateBook::slotSettings()
236{ 239{
237 DateBookSettings frmSettings( ampm, this ); 240 DateBookSettings frmSettings( ampm, this );
238 frmSettings.setStartTime( startTime ); 241 frmSettings.setStartTime( startTime );
239 frmSettings.setAlarmPreset( aPreset, presetTime ); 242 frmSettings.setAlarmPreset( aPreset, presetTime );
240 frmSettings.setJumpToCurTime( bJumpToCurTime ); 243 frmSettings.setJumpToCurTime( bJumpToCurTime );
241 frmSettings.setRowStyle( rowStyle ); 244 frmSettings.setRowStyle( rowStyle );
242 frmSettings.comboDefaultView->setCurrentItem(defaultView-1); 245 frmSettings.comboDefaultView->setCurrentItem(defaultView-1);
243 frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig); 246 frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig);
244 247
245 bool found=false; 248 bool found=false;
246 for (int i=0; i<(frmSettings.comboLocation->count()); i++) { 249 for (int i=0; i<(frmSettings.comboLocation->count()); i++) {
247 if ( frmSettings.comboLocation->text(i) == defaultLocation ) { 250 if ( frmSettings.comboLocation->text(i) == defaultLocation ) {
248 frmSettings.comboLocation->setCurrentItem(i); 251 frmSettings.comboLocation->setCurrentItem(i);
249 found=true; 252 found=true;
250 break; 253 break;
251 } 254 }
252 } 255 }
253 if(!found) { 256 if(!found) {
254 frmSettings.comboLocation->insertItem(defaultLocation); 257 frmSettings.comboLocation->insertItem(defaultLocation);
255 frmSettings.comboLocation->setCurrentItem(frmSettings.comboLocation->count()-1); 258 frmSettings.comboLocation->setCurrentItem(frmSettings.comboLocation->count()-1);
256 } 259 }
257 frmSettings.comboCategory->setCategories(defaultCategories,"Calendar", tr("Calendar")); 260 frmSettings.comboCategory->setCategories(defaultCategories,"Calendar", tr("Calendar"));
258 261
259#if defined (Q_WS_QWS) || defined(_WS_QWS_) 262#if defined (Q_WS_QWS) || defined(_WS_QWS_)
260 frmSettings.showMaximized(); 263 frmSettings.showMaximized();
261#endif 264#endif
262 265
263 if ( frmSettings.exec() ) { 266 if ( frmSettings.exec() ) {
264 267
265 aPreset = frmSettings.alarmPreset(); 268 aPreset = frmSettings.alarmPreset();
266 presetTime = frmSettings.presetTime(); 269 presetTime = frmSettings.presetTime();
267 startTime = frmSettings.startTime(); 270 startTime = frmSettings.startTime();
268 bJumpToCurTime = frmSettings.jumpToCurTime(); 271 bJumpToCurTime = frmSettings.jumpToCurTime();
269 rowStyle = frmSettings.rowStyle(); 272 rowStyle = frmSettings.rowStyle();
270 defaultView=frmSettings.comboDefaultView->currentItem()+1; 273 defaultView=frmSettings.comboDefaultView->currentItem()+1;
271 weeklistviewconfig=frmSettings.comboWeekListView->currentItem(); 274 weeklistviewconfig=frmSettings.comboWeekListView->currentItem();
272 defaultLocation=frmSettings.comboLocation->currentText(); 275 defaultLocation=frmSettings.comboLocation->currentText();
273 defaultCategories=frmSettings.comboCategory->currentCategories(); 276 defaultCategories=frmSettings.comboCategory->currentCategories();
274 277
275 if ( dayView ) { 278 if ( dayView ) {
276 dayView->setStartViewTime( startTime ); 279 dayView->setStartViewTime( startTime );
277 dayView->setJumpToCurTime( bJumpToCurTime ); 280 dayView->setJumpToCurTime( bJumpToCurTime );
278 dayView->setRowStyle( rowStyle ); 281 dayView->setRowStyle( rowStyle );
279 } 282 }
280 if ( weekView ) { 283 if ( weekView ) {
281 weekView->setStartViewTime( startTime ); 284 weekView->setStartViewTime( startTime );
282 } 285 }
283 saveSettings(); 286 saveSettings();
284 287
285 // make the change obvious 288 // make the change obvious
286 if ( views->visibleWidget() ) { 289 if ( views->visibleWidget() ) {
287 if ( views->visibleWidget() == dayView ) 290 if ( views->visibleWidget() == dayView )
288 dayView->redraw(); 291 dayView->redraw();
289 else if ( views->visibleWidget() == weekView ) 292 else if ( views->visibleWidget() == weekView )
290 weekView->redraw(); 293 weekView->redraw();
291 else if ( views->visibleWidget() == weekLstView ) 294 else if ( views->visibleWidget() == weekLstView )
292 weekLstView->redraw(); 295 weekLstView->redraw();
293 } 296 }
294 } 297 }
295} 298}
296 299
297void DateBook::fileNew() 300void DateBook::fileNew()
298{ 301{
299 slotNewEventFromKey(""); 302 slotNewEventFromKey("");
300} 303}
301 304
302QString DateBook::checkEvent(const Event &e) 305QString DateBook::checkEvent(const Event &e)
303{ 306{
304 /* check if overlaps with itself */ 307 /* check if overlaps with itself */
305 bool checkFailed = FALSE; 308 bool checkFailed = FALSE;
306 309
307 /* check the next 12 repeats. should catch most problems */ 310 /* check the next 12 repeats. should catch most problems */
308 QDate current_date = e.start().date(); 311 QDate current_date = e.start().date();
309 Event previous = e; 312 Event previous = e;
310 for(int i = 0; i < 12; i++) 313 for(int i = 0; i < 12; i++)
311 { 314 {
312 QDateTime next; 315 QDateTime next;
313 if (!nextOccurance(previous, current_date.addDays(1), next)) { 316 if (!nextOccurance(previous, current_date.addDays(1), next)) {
314 break; // no more repeats 317 break; // no more repeats
315 } 318 }
316 if(next < previous.end()) { 319 if(next < previous.end()) {
317 checkFailed = TRUE; 320 checkFailed = TRUE;
318 break; 321 break;
319 } 322 }
320 current_date = next.date(); 323 current_date = next.date();
321 } 324 }
322 325
323 if(checkFailed) 326 if(checkFailed)
324 return tr("Event duration is potentially longer\n" 327 return tr("Event duration is potentially longer\n"
325 "than interval between repeats."); 328 "than interval between repeats.");
326 329
327 return QString::null; 330 return QString::null;
328} 331}
329 332
330QDate DateBook::currentDate() 333QDate DateBook::currentDate()
331{ 334{
332 QDate d = QDate::currentDate(); 335 QDate d = QDate::currentDate();
333 336
334 if ( dayView && views->visibleWidget() == dayView ) { 337 if ( dayView && views->visibleWidget() == dayView ) {
335 d = dayView->date(); 338 d = dayView->date();
336 } else if ( weekView && views->visibleWidget() == weekView ) { 339 } else if ( weekView && views->visibleWidget() == weekView ) {
337 d = weekView->date(); 340 d = weekView->date();
338 } else if ( weekLstView && views->visibleWidget() == weekLstView ) { 341 } else if ( weekLstView && views->visibleWidget() == weekLstView ) {
339 d = weekLstView->date(); 342 d = weekLstView->date();
340 } else if ( monthView && views->visibleWidget() == monthView ) { 343 } else if ( monthView && views->visibleWidget() == monthView ) {
341 d = monthView->selectedDate(); 344 d = monthView->selectedDate();
342 } 345 }
343 346
344 return d; 347 return d;
345} 348}
346 349
347void DateBook::view(int v, const QDate &d) { 350void DateBook::view(int v, const QDate &d) {
348 if (v==DAY) { 351 if (v==DAY) {
349 initDay(); 352 initDay();
350 dayAction->setOn( TRUE ); 353 dayAction->setOn( TRUE );
351 dayView->setDate( d ); 354 dayView->setDate( d );
352 views->raiseWidget( dayView ); 355 views->raiseWidget( dayView );
353 dayView->redraw(); 356 dayView->redraw();
354 } else if (v==WEEK) { 357 } else if (v==WEEK) {
355 initWeek(); 358 initWeek();
356 weekAction->setOn( TRUE ); 359 weekAction->setOn( TRUE );
357 weekView->setDate( d ); 360 weekView->setDate( d );
358 views->raiseWidget( weekView ); 361 views->raiseWidget( weekView );
359 weekView->redraw(); 362 weekView->redraw();
360 } else if (v==WEEKLST) { 363 } else if (v==WEEKLST) {
361 initWeekLst(); 364 initWeekLst();
362 weekLstAction->setOn( TRUE ); 365 weekLstAction->setOn( TRUE );
363 weekLstView->setDate(d); 366 weekLstView->setDate(d);
364 views->raiseWidget( weekLstView ); 367 views->raiseWidget( weekLstView );
365 weekLstView->redraw(); 368 weekLstView->redraw();
366 } else if (v==MONTH) { 369 } else if (v==MONTH) {
367 initMonth(); 370 initMonth();
368 monthAction->setOn( TRUE ); 371 monthAction->setOn( TRUE );
369 monthView->setDate( d.year(), d.month(), d.day() ); 372 monthView->setDate( d.year(), d.month(), d.day() );
370 views->raiseWidget( monthView ); 373 views->raiseWidget( monthView );
371 monthView->redraw(); 374 monthView->redraw();
372 } 375 }
373} 376}
374 377
375void DateBook::viewDefault(const QDate &d) { 378void DateBook::viewDefault(const QDate &d) {
376/*
377 Config config("DateBook");
378 config.setGroup("Main");
379 int current=config.readNumEntry("defaultview", DAY);
380
381 view(current,d);
382*/
383 view(defaultView,d); 379 view(defaultView,d);
384} 380}
385 381
386void DateBook::viewDay() { 382void DateBook::viewDay() {
387 view(DAY,currentDate()); 383 view(DAY,currentDate());
388} 384}
389 385
390void DateBook::viewWeek() { 386void DateBook::viewWeek() {
391 view(WEEK,currentDate()); 387 view(WEEK,currentDate());
392} 388}
393 389
394void DateBook::viewWeekLst() { 390void DateBook::viewWeekLst() {
395 view(WEEKLST,currentDate()); 391 view(WEEKLST,currentDate());
396} 392}
397 393
398void DateBook::viewMonth() { 394void DateBook::viewMonth() {
399 view(MONTH,currentDate()); 395 view(MONTH,currentDate());
400} 396}
401 397
402void DateBook::insertEvent( const Event &e ) 398void DateBook::insertEvent( const Event &e )
403{ 399{
404 Event dupEvent=e; 400 Event dupEvent=e;
405 dupEvent.setLocation(defaultLocation); 401 dupEvent.setLocation(defaultLocation);
406 dupEvent.setCategories(defaultCategories); 402 dupEvent.setCategories(defaultCategories);
407 db->addEvent(dupEvent); 403 db->addEvent(dupEvent);
408 emit newEvent(); 404 emit newEvent();
409} 405}
410 406
411void DateBook::duplicateEvent( const Event &e ) 407void DateBook::duplicateEvent( const Event &e )
412{ 408{
413 qWarning("Hmmm..."); 409 qWarning("Hmmm...");
414 // Alot of code duplication, as this is almost like editEvent(); 410 // Alot of code duplication, as this is almost like editEvent();
415 if (syncing) { 411 if (syncing) {
416 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); 412 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
417 return; 413 return;
418 } 414 }
419 415
420 Event dupevent(e);// Make a duplicate. 416 Event dupevent(e);// Make a duplicate.
421 417
422 // workaround added for text input. 418 // workaround added for text input.
423 QDialog editDlg( this, 0, TRUE ); 419 QDialog editDlg( this, 0, TRUE );
424 DateEntry *entry; 420 DateEntry *entry;
425 editDlg.setCaption( tr("Duplicate Event") ); 421 editDlg.setCaption( tr("Duplicate Event") );
426 QVBoxLayout *vb = new QVBoxLayout( &editDlg ); 422 QVBoxLayout *vb = new QVBoxLayout( &editDlg );
427 QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); 423 QScrollView *sv = new QScrollView( &editDlg, "scrollview" );
428 sv->setResizePolicy( QScrollView::AutoOneFit ); 424 sv->setResizePolicy( QScrollView::AutoOneFit );
429 // KLUDGE!!! 425 // KLUDGE!!!
430 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 426 sv->setHScrollBarMode( QScrollView::AlwaysOff );
431 vb->addWidget( sv ); 427 vb->addWidget( sv );
432 entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" ); 428 entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" );
433 entry->timezone->setEnabled( FALSE ); 429 entry->timezone->setEnabled( FALSE );
434 sv->addChild( entry ); 430 sv->addChild( entry );
435 431
436#if defined(Q_WS_QWS) || defined(_WS_QWS_) 432#if defined(Q_WS_QWS) || defined(_WS_QWS_)
437 editDlg.showMaximized(); 433 editDlg.showMaximized();
438#endif 434#endif
439 while (editDlg.exec() ) { 435 while (editDlg.exec() ) {
440 Event newEv = entry->event(); 436 Event newEv = entry->event();
441 QString error = checkEvent(newEv); 437 QString error = checkEvent(newEv);
442 if (!error.isNull()) { 438 if (!error.isNull()) {
443 if (QMessageBox::warning(this, "error box", error, "Fix it", "Continue", 0, 0, 1) == 0) 439 if (QMessageBox::warning(this, "error box", error, "Fix it", "Continue", 0, 0, 1) == 0)
444 continue; 440 continue;
445 } 441 }
446 db->addEvent(newEv); 442 db->addEvent(newEv);
447 emit newEvent(); 443 emit newEvent();
448 break; 444 break;
449 } 445 }
450} 446}
451 447
452void DateBook::editEvent( const Event &e ) 448void DateBook::editEvent( const Event &e )
453{ 449{
454 if (syncing) { 450 if (syncing) {
455 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); 451 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
456 return; 452 return;
457 } 453 }
458 454
459 // workaround added for text input. 455 // workaround added for text input.
460 QDialog editDlg( this, 0, TRUE ); 456 QDialog editDlg( this, 0, TRUE );
461 DateEntry *entry; 457 DateEntry *entry;
462 editDlg.setCaption( tr("Edit Event") ); 458 editDlg.setCaption( tr("Edit Event") );
463 QVBoxLayout *vb = new QVBoxLayout( &editDlg ); 459 QVBoxLayout *vb = new QVBoxLayout( &editDlg );
464 QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); 460 QScrollView *sv = new QScrollView( &editDlg, "scrollview" );
465 sv->setResizePolicy( QScrollView::AutoOneFit ); 461 sv->setResizePolicy( QScrollView::AutoOneFit );
466 // KLUDGE!!! 462 // KLUDGE!!!
467 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 463 sv->setHScrollBarMode( QScrollView::AlwaysOff );
468 vb->addWidget( sv ); 464 vb->addWidget( sv );
469 entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" ); 465 entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" );
470 entry->timezone->setEnabled( FALSE ); 466 entry->timezone->setEnabled( FALSE );
471 sv->addChild( entry ); 467 sv->addChild( entry );
472 468
473#if defined(Q_WS_QWS) || defined(_WS_QWS_) 469#if defined(Q_WS_QWS) || defined(_WS_QWS_)
474 editDlg.showMaximized(); 470 editDlg.showMaximized();
475#endif 471#endif
476 while (editDlg.exec() ) { 472 while (editDlg.exec() ) {
477 Event newEv = entry->event(); 473 Event newEv = entry->event();
478 if(newEv.description().isEmpty() && newEv.notes().isEmpty() ) 474 if(newEv.description().isEmpty() && newEv.notes().isEmpty() )
479 break; 475 break;
480 newEv.setUid(e.uid()); // FIXME: Hack not to clear uid 476 newEv.setUid(e.uid()); // FIXME: Hack not to clear uid
481 QString error = checkEvent(newEv); 477 QString error = checkEvent(newEv);
482 if (!error.isNull()) { 478 if (!error.isNull()) {
483 if (QMessageBox::warning(this, "error box", error, "Fix it", "Continue", 0, 0, 1) == 0) continue; 479 if (QMessageBox::warning(this, "error box", error, "Fix it", "Continue", 0, 0, 1) == 0) continue;
484 } 480 }
485 db->editEvent(e, newEv); 481 db->editEvent(e, newEv);
486 emit newEvent(); 482 emit newEvent();
487 break; 483 break;
488 } 484 }
489} 485}
490 486
491void DateBook::removeEvent( const Event &e ) 487void DateBook::removeEvent( const Event &e )
492{ 488{
493 if (syncing) { 489 if (syncing) {
494 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); 490 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
495 return; 491 return;
496 } 492 }
497 493
498 QString strName = e.description(); 494 QString strName = e.description();
499 495
500 if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) 496 if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) )
501 return; 497 return;
502 498
503 db->removeEvent( e ); 499 db->removeEvent( e );
504 if ( views->visibleWidget() == dayView && dayView ) 500 if ( views->visibleWidget() == dayView && dayView )
505 dayView->redraw(); 501 dayView->redraw();
506} 502}
507 503
508void DateBook::addEvent( const Event &e ) 504void DateBook::addEvent( const Event &e )
509{ 505{
510 QDate d = e.start().date(); 506 QDate d = e.start().date();
511 initDay(); 507 initDay();
512 dayView->setDate( d ); 508 dayView->setDate( d );
513} 509}
514 510
515void DateBook::showDay( int year, int month, int day ) 511void DateBook::showDay( int year, int month, int day )
516{ 512{
517 QDate d(year, month, day); 513 QDate d(year, month, day);
518 view(DAY,d); 514 view(DAY,d);
519} 515}
520 516
521void DateBook::initDay() 517void DateBook::initDay()
522{ 518{
523 if ( !dayView ) { 519 if ( !dayView ) {
524 dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); 520 dayView = new DateBookDay( ampm, onMonday, db, views, "day view" );
525 views->addWidget( dayView, DAY ); 521 views->addWidget( dayView, DAY );
526 dayView->setStartViewTime( startTime ); 522 dayView->setStartViewTime( startTime );
527 dayView->setJumpToCurTime( bJumpToCurTime ); 523 dayView->setJumpToCurTime( bJumpToCurTime );
528 dayView->setRowStyle( rowStyle ); 524 dayView->setRowStyle( rowStyle );
529 connect( this, SIGNAL( newEvent() ), 525 connect( this, SIGNAL( newEvent() ), dayView, SLOT( redraw() ) );
530 dayView, SLOT( redraw() ) ); 526 connect( dayView, SIGNAL( newEvent() ), this, SLOT( fileNew() ) );
531 connect( dayView, SIGNAL( newEvent() ), 527 connect( dayView, SIGNAL( removeEvent( const Event & ) ), this, SLOT( removeEvent( const Event & ) ) );
532 this, SLOT( fileNew() ) ); 528 connect( dayView, SIGNAL( editEvent( const Event & ) ), this, SLOT( editEvent( const Event & ) ) );
533 connect( dayView, SIGNAL( removeEvent( const Event & ) ), 529 connect( dayView, SIGNAL( duplicateEvent( const Event & ) ), this, SLOT( duplicateEvent( const Event & ) ) );
534 this, SLOT( removeEvent( const Event & ) ) ); 530 connect( dayView, SIGNAL( beamEvent( const Event & ) ), this, SLOT( beamEvent( const Event & ) ) );
535 connect( dayView, SIGNAL( editEvent( const Event & ) ), 531 connect( dayView, SIGNAL(sigNewEvent(const QString &)), this, SLOT(slotNewEventFromKey(const QString &)) );
536 this, SLOT( editEvent( const Event & ) ) ); 532 }
537 connect( dayView, SIGNAL( duplicateEvent( const Event & ) ),
538 this, SLOT( duplicateEvent( const Event & ) ) );
539 connect( dayView, SIGNAL( beamEvent( const Event & ) ),
540 this, SLOT( beamEvent( const Event & ) ) );
541 connect( dayView, SIGNAL(sigNewEvent(const QString &)),
542 this, SLOT(slotNewEventFromKey(const QString &)) );
543 }
544} 533}
545 534
546void DateBook::initWeek() 535void DateBook::initWeek()
547{ 536{
548 if ( !weekView ) { 537 if ( !weekView ) {
549 weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); 538 weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" );
550 weekView->setStartViewTime( startTime ); 539 weekView->setStartViewTime( startTime );
551 views->addWidget( weekView, WEEK ); 540 views->addWidget( weekView, WEEK );
552 connect( weekView, SIGNAL( showDate( int, int, int ) ), 541 connect( weekView, SIGNAL( showDate( int, int, int ) ), this, SLOT( showDay( int, int, int ) ) );
553 this, SLOT( showDay( int, int, int ) ) ); 542 connect( this, SIGNAL( newEvent() ), weekView, SLOT( redraw() ) );
554 connect( this, SIGNAL( newEvent() ),
555 weekView, SLOT( redraw() ) );
556 } 543 }
557 544
558 //But also get it right: the year that we display can be different 545 //But also get it right: the year that we display can be different
559 //from the year of the current date. So, first find the year 546 //from the year of the current date. So, first find the year
560 //number of the current week. 547 //number of the current week.
561 int yearNumber, totWeeks; 548 int yearNumber, totWeeks;
562 calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); 549 calcWeek( currentDate(), totWeeks, yearNumber, onMonday );
563 550
564 QDate d = QDate( yearNumber, 12, 31 ); 551 QDate d = QDate( yearNumber, 12, 31 );
565 calcWeek( d, totWeeks, yearNumber, onMonday ); 552 calcWeek( d, totWeeks, yearNumber, onMonday );
566 553
567 while ( totWeeks == 1 ) { 554 while ( totWeeks == 1 ) {
568 d = d.addDays( -1 ); 555 d = d.addDays( -1 );
569 calcWeek( d, totWeeks, yearNumber, onMonday ); 556 calcWeek( d, totWeeks, yearNumber, onMonday );
570 } 557 }
571 if ( totWeeks != weekView->totalWeeks() )
572 weekView->setTotalWeeks( totWeeks );
573} 558}
574 559
575void DateBook::initWeekLst() { 560void DateBook::initWeekLst() {
576 if ( !weekLstView ) { 561 if ( !weekLstView ) {
577 weekLstView = new DateBookWeekLst( ampm, onMonday, db, 562 weekLstView = new DateBookWeekLst( ampm, onMonday, db, views, "weeklst view" );
578 views, "weeklst view" ); 563 views->addWidget( weekLstView, WEEKLST );
579 views->addWidget( weekLstView, WEEKLST ); 564
580 565 //weekLstView->setStartViewTime( startTime );
581 //weekLstView->setStartViewTime( startTime ); 566 connect( weekLstView, SIGNAL( showDate( int, int, int ) ), this, SLOT( showDay( int, int, int ) ) );
582 connect( weekLstView, SIGNAL( showDate( int, int, int ) ), 567 connect( weekLstView, SIGNAL( addEvent( const QDateTime &, const QDateTime &, const QString & , const QString &) ),
583 this, SLOT( showDay( int, int, int ) ) ); 568 this, SLOT( slotNewEntry( const QDateTime &, const QDateTime &, const QString & , const QString &) ) );
584 connect( weekLstView, SIGNAL( addEvent( const QDateTime &, 569 connect( this, SIGNAL( newEvent() ), weekLstView, SLOT( redraw() ) );
585 const QDateTime &, 570 connect( weekLstView, SIGNAL( editEvent( const Event & ) ), this, SLOT( editEvent( const Event & ) ) );
586 const QString & , const QString &) ), 571 }
587 this, SLOT( slotNewEntry( const QDateTime &,
588 const QDateTime &,
589 const QString & , const QString &) ) );
590 connect( this, SIGNAL( newEvent() ),
591 weekLstView, SLOT( redraw() ) );
592 connect( weekLstView, SIGNAL( editEvent( const Event & ) ),
593 this, SLOT( editEvent( const Event & ) ) );
594 }
595} 572}
596 573
597 574
598void DateBook::initMonth() 575void DateBook::initMonth()
599{ 576{
600 if ( !monthView ) { 577 if ( !monthView ) {
601 monthView = new DateBookMonth( views, "month view", FALSE, db ); 578 monthView = new DateBookMonth( views, "month view", FALSE, db );
602 views->addWidget( monthView, MONTH ); 579 views->addWidget( monthView, MONTH );
603 connect( monthView, SIGNAL( dateClicked( int, int, int ) ), 580 connect( monthView, SIGNAL( dateClicked( int, int, int ) ), this, SLOT( showDay( int, int, int ) ) );
604 this, SLOT( showDay( int, int, int ) ) ); 581 connect( this, SIGNAL( newEvent() ), monthView, SLOT( redraw() ) );
605 connect( this, SIGNAL( newEvent() ), 582 qApp->processEvents();
606 monthView, SLOT( redraw() ) ); 583 }
607 qApp->processEvents();
608 }
609} 584}
610 585
611void DateBook::loadSettings() 586void DateBook::loadSettings()
612{ 587{
613 Config qpeconfig( "qpe" ); 588 Config qpeconfig( "qpe" );
614 qpeconfig.setGroup("Time"); 589 qpeconfig.setGroup("Time");
615 ampm = qpeconfig.readBoolEntry( "AMPM", TRUE ); 590 ampm = qpeconfig.readBoolEntry( "AMPM", TRUE );
616 onMonday = qpeconfig.readBoolEntry( "MONDAY" ); 591 onMonday = qpeconfig.readBoolEntry( "MONDAY" );
617 592
618 Config config("DateBook"); 593 Config config("DateBook");
619 config.setGroup("Main"); 594 config.setGroup("Main");
620 startTime = config.readNumEntry("startviewtime", 8); 595 startTime = config.readNumEntry("startviewtime", 8);
621 aPreset = config.readBoolEntry("alarmpreset"); 596 aPreset = config.readBoolEntry("alarmpreset");
622 presetTime = config.readNumEntry("presettime"); 597 presetTime = config.readNumEntry("presettime");
623 bJumpToCurTime = config.readBoolEntry("jumptocurtime"); 598 bJumpToCurTime = config.readBoolEntry("jumptocurtime");
624 rowStyle = config.readNumEntry("rowstyle"); 599 rowStyle = config.readNumEntry("rowstyle");
625 defaultView = config.readNumEntry("defaultview",DAY); 600 defaultView = config.readNumEntry("defaultview",DAY);
626 weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL); 601 weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL);
627 602
628 defaultLocation=config.readEntry("defaultLocation"); 603 defaultLocation=config.readEntry("defaultLocation");
629 QString tmpString=config.readEntry("defaultCategories"); 604 QString tmpString=config.readEntry("defaultCategories");
630 QStringList tmpStringList=QStringList::split(",",tmpString); 605 QStringList tmpStringList=QStringList::split(",",tmpString);
631 defaultCategories.truncate(0); 606 defaultCategories.truncate(0);
607
632 for( QStringList::Iterator i=tmpStringList.begin(); i!=tmpStringList.end(); i++) { 608 for( QStringList::Iterator i=tmpStringList.begin(); i!=tmpStringList.end(); i++) {
633 defaultCategories.resize(defaultCategories.count()+1); 609 defaultCategories.resize(defaultCategories.count()+1);
634 defaultCategories[defaultCategories.count()-1]=(*i).toInt(); 610 defaultCategories[defaultCategories.count()-1]=(*i).toInt();
635 } 611 }
636} 612}
637 613
638void DateBook::saveSettings() 614void DateBook::saveSettings()
639{ 615{
640 Config config( "qpe" ); 616 Config config( "qpe" );
641 Config configDB( "DateBook" ); 617 Config configDB( "DateBook" );
642 configDB.setGroup( "Main" ); 618 configDB.setGroup( "Main" );
643 configDB.writeEntry("startviewtime",startTime); 619 configDB.writeEntry("startviewtime",startTime);
644 configDB.writeEntry("alarmpreset",aPreset); 620 configDB.writeEntry("alarmpreset",aPreset);
645 configDB.writeEntry("presettime",presetTime); 621 configDB.writeEntry("presettime",presetTime);
646 configDB.writeEntry("jumptocurtime", bJumpToCurTime); 622 configDB.writeEntry("jumptocurtime", bJumpToCurTime);
647 configDB.writeEntry("rowstyle", rowStyle); 623 configDB.writeEntry("rowstyle", rowStyle);
648 configDB.writeEntry("defaultview",defaultView); 624 configDB.writeEntry("defaultview",defaultView);
649 configDB.writeEntry("weeklistviewconfig",weeklistviewconfig); 625 configDB.writeEntry("weeklistviewconfig",weeklistviewconfig);
650 626
651 configDB.writeEntry("defaultLocation",defaultLocation); 627 configDB.writeEntry("defaultLocation",defaultLocation);
652 QStringList tmpStringList; 628 QStringList tmpStringList;
653 for( uint i=0; i<defaultCategories.count(); i++) { 629 for( uint i=0; i<defaultCategories.count(); i++) {
654 tmpStringList << QString::number(defaultCategories[i]); 630 tmpStringList << QString::number(defaultCategories[i]);
655 } 631 }
656 configDB.writeEntry("defaultCategories",tmpStringList.join(",")); 632 configDB.writeEntry("defaultCategories",tmpStringList.join(","));
657} 633}
658 634
659void DateBook::appMessage(const QCString& msg, const QByteArray& data) 635void DateBook::appMessage(const QCString& msg, const QByteArray& data)
660{ 636{
661 bool needShow = FALSE; 637 bool needShow = FALSE;
662 if ( msg == "alarm(QDateTime,int)" ) { 638 if ( msg == "alarm(QDateTime,int)" ) {
663 QDataStream ds(data,IO_ReadOnly); 639 QDataStream ds(data,IO_ReadOnly);
664 QDateTime when; int warn; 640 QDateTime when; int warn;
665 ds >> when >> warn; 641 ds >> when >> warn;
666 642
667 // check to make it's okay to continue, 643 // check to make it's okay to continue,
668 // this is the case that the time was set ahead, and 644 // this is the case that the time was set ahead, and
669 // we are forced given a stale alarm... 645 // we are forced given a stale alarm...
670 QDateTime current = QDateTime::currentDateTime(); 646 QDateTime current = QDateTime::currentDateTime();
671 if ( current.time().hour() != when.time().hour() && current.time().minute() != when.time().minute() ) 647 if ( current.time().hour() != when.time().hour() && current.time().minute() != when.time().minute() )
672 return; 648 return;
673 649
674 QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60)); 650 QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60));
675 if ( list.count() > 0 ) { 651 if ( list.count() > 0 ) {
676 QString msg; 652 QString msg;
677 bool bSound = FALSE; 653 bool bSound = FALSE;
678 int stopTimer = 0; 654 int stopTimer = 0;
679 bool found = FALSE; 655 bool found = FALSE;
680 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) { 656 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) {
681 if ( (*it).event().hasAlarm() ) { 657 if ( (*it).event().hasAlarm() ) {
682 found = TRUE; 658 found = TRUE;
683 msg += "<CENTER><B>" + (*it).description() + "</B>" 659 msg += "<CENTER><B>" + (*it).description() + "</B>"
684 + "<BR>" + (*it).location() + "<BR>" 660 + "<BR>" + (*it).location() + "<BR>"
685 + TimeString::dateString((*it).event().start(),ampm) 661 + TimeString::dateString((*it).event().start(),ampm)
686 + (warn 662 + (warn
687 ? tr(" (in " + QString::number(warn) 663 ? tr(" (in " + QString::number(warn)
688 + tr(" minutes)")) 664 + tr(" minutes)"))
689 : QString("")) 665 : QString(""))
690 + "<BR>" 666 + "<BR>"
691 + (*it).notes() + "</CENTER>"; 667 + (*it).notes() + "</CENTER>";
692 if ( (*it).event().alarmSound() != Event::Silent ) { 668 if ( (*it).event().alarmSound() != Event::Silent ) {
693 bSound = TRUE; 669 bSound = TRUE;
694 } 670 }
695 } 671 }
696 } 672 }
697 if ( found ) { 673 if ( found ) {
698 if ( bSound ) { 674 if ( bSound ) {
699 Sound::soundAlarm(); 675 Sound::soundAlarm();
700 alarmCounter = 0; 676 alarmCounter = 0;
701 stopTimer = startTimer( 5000 ); 677 stopTimer = startTimer( 5000 );
702 } 678 }
703 QDialog dlg( this, 0, TRUE ); 679 QDialog dlg( this, 0, TRUE );
704 QVBoxLayout *vb = new QVBoxLayout( &dlg ); 680 QVBoxLayout *vb = new QVBoxLayout( &dlg );
705 QScrollView *view = new QScrollView( &dlg, "scrollView"); 681 QScrollView *view = new QScrollView( &dlg, "scrollView");
706 view->setResizePolicy( QScrollView::AutoOneFit ); 682 view->setResizePolicy( QScrollView::AutoOneFit );
707 vb->addWidget( view ); 683 vb->addWidget( view );
708 QLabel *lblMsg = new QLabel( msg, &dlg ); 684 QLabel *lblMsg = new QLabel( msg, &dlg );
709 view->addChild( lblMsg ); 685 view->addChild( lblMsg );
710 QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg ); 686 QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg );
711 connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) ); 687 connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) );
712 vb->addWidget( cmdOk ); 688 vb->addWidget( cmdOk );
713 689
714#if defined(Q_WS_QWS) || defined(_WS_QWS_) 690#if defined(Q_WS_QWS) || defined(_WS_QWS_)
715 dlg.showMaximized(); 691 dlg.showMaximized();
716#endif 692#endif
717 needShow = dlg.exec(); 693 needShow = dlg.exec();
718 694
719 if ( bSound ) 695 if ( bSound )
720 killTimer( stopTimer ); 696 killTimer( stopTimer );
721 } 697 }
722 } 698 }
723 } else if ( msg == "nextView()" ) { 699 } else if ( msg == "nextView()" ) {
724 if ( !qApp-> activeWindow ( )) { 700 if ( !qApp-> activeWindow ( )) {
725 needShow = TRUE; 701 needShow = TRUE;
726 } else { 702 } else {
727 QWidget* cur = views->visibleWidget(); 703 QWidget* cur = views->visibleWidget();
728 if ( cur ) { 704 if ( cur ) {
729 if ( cur == dayView ) 705 if ( cur == dayView )
730 viewWeek(); 706 viewWeek();
731 else if ( cur == weekView ) 707 else if ( cur == weekView )
732 viewWeekLst(); 708 viewWeekLst();
733 else if ( cur == weekLstView ) 709 else if ( cur == weekLstView )
734 viewMonth(); 710 viewMonth();
735 else if ( cur == monthView ) 711 else if ( cur == monthView )
736 viewDay(); 712 viewDay();
737 needShow = TRUE; 713 needShow = TRUE;
738 } 714 }
739 } 715 }
740 } 716 }
741 if ( needShow ) { 717 if ( needShow ) {
742#if defined(Q_WS_QWS) || defined(_WS_QWS_) 718#if defined(Q_WS_QWS) || defined(_WS_QWS_)
743 showMaximized(); 719 showMaximized();
744#else 720#else
745 show(); 721 show();
746#endif 722#endif
747 raise(); 723 raise();
748 QPEApplication::setKeepRunning(); 724 QPEApplication::setKeepRunning();
749 setActiveWindow(); 725 setActiveWindow();
750 } 726 }
751} 727}
752 728
753void DateBook::reload() 729void DateBook::reload()
754{ 730{
755 db->reload(); 731 db->reload();
756 if ( dayAction->isOn() ) viewDay(); 732 if ( dayAction->isOn() ) viewDay();
757 else if ( weekAction->isOn() ) viewWeek(); 733 else if ( weekAction->isOn() ) viewWeek();
758 else if ( monthAction->isOn() ) viewMonth(); 734 else if ( monthAction->isOn() ) viewMonth();
759 syncing = FALSE; 735 syncing = FALSE;
760} 736}
761 737
762void DateBook::flush() 738void DateBook::flush()
763{ 739{
764 syncing = TRUE; 740 syncing = TRUE;
765 db->save(); 741 db->save();
766} 742}
767 743
768void DateBook::timerEvent( QTimerEvent *e ) 744void DateBook::timerEvent( QTimerEvent *e )
769{ 745{
770 if ( alarmCounter < 10 ) { 746 if ( alarmCounter < 10 ) {
771 alarmCounter++; 747 alarmCounter++;
772 Sound::soundAlarm(); 748 Sound::soundAlarm();
773 } else { 749 } else {
774 killTimer( e->timerId() ); 750 killTimer( e->timerId() );
775 } 751 }
776} 752}
777 753
778void DateBook::changeClock( bool newClock ) 754void DateBook::changeClock( bool newClock )
779{ 755{
780 ampm = newClock; 756 ampm = newClock;
781 // repaint the affected objects... 757 // repaint the affected objects...
782 if (dayView) dayView->redraw(); 758 if (dayView) dayView->redraw();
783 if (weekView) weekView->redraw(); 759 if (weekView) weekView->redraw();
784 if (weekLstView) weekLstView->redraw(); 760 if (weekLstView) weekLstView->redraw();
785} 761}
786 762
787void DateBook::changeWeek( bool m ) 763void DateBook::changeWeek( bool m )
788{ 764{
789 /* no need to redraw, each widget catches. Do need to 765 /* no need to redraw, each widget catches. Do need to
790 store though for widgets we haven't made yet */ 766 store though for widgets we haven't made yet */
791 onMonday = m; 767 onMonday = m;
792} 768}
793 769
794void DateBook::slotToday() 770void DateBook::slotToday()
795{ 771{
796 // we need to view today using default view 772 // we need to view today using default view
797 view(defaultView,QDate::currentDate()); 773 view(defaultView,QDate::currentDate());
798} 774}
799 775
800void DateBook::closeEvent( QCloseEvent *e ) 776void DateBook::closeEvent( QCloseEvent *e )
801{ 777{
802 if(syncing) { 778 if(syncing) {
803 /* no need to save, did that at flush */ 779 /* no need to save, did that at flush */
804 e->accept(); 780 e->accept();
805 return; 781 return;
806 } 782 }
807 783
808 // save settings will generate it's own error messages, no 784 // save settings will generate it's own error messages, no
809 // need to do checking ourselves. 785 // need to do checking ourselves.
810 saveSettings(); 786 saveSettings();
811 if ( db->save() ) { 787 if ( db->save() ) {
812 e->accept(); 788 e->accept();
813 } else { 789 } else {
814 if ( QMessageBox::critical( this, tr( "Out of space" ), 790 if ( QMessageBox::critical( this, tr( "Out of space" ),
815 tr("Calendar was unable to save\n" 791 tr("Calendar was unable to save\n"
816 "your changes.\n" 792 "your changes.\n"
817 "Free up some space and try again.\n" 793 "Free up some space and try again.\n"
818 "\nQuit anyway?"), 794 "\nQuit anyway?"),
819 QMessageBox::Yes|QMessageBox::Escape, 795 QMessageBox::Yes|QMessageBox::Escape,
820 QMessageBox::No|QMessageBox::Default ) 796 QMessageBox::No|QMessageBox::Default )
821 != QMessageBox::No ) 797 != QMessageBox::No )
822 e->accept(); 798 e->accept();
823 else 799 else
824 e->ignore(); 800 e->ignore();
825 } 801 }
826} 802}
827 803
828// Entering directly from the "keyboard" 804// Entering directly from the "keyboard"
829void DateBook::slotNewEventFromKey( const QString &str ) 805void DateBook::slotNewEventFromKey( const QString &str )
830{ 806{
831 if (syncing) { 807 if (syncing) {
832 QMessageBox::warning( this, tr("Calendar"), 808 QMessageBox::warning( this, tr("Calendar"),
833 tr( "Can not edit data, currently syncing") ); 809 tr( "Can not edit data, currently syncing") );
834 return; 810 return;
835 } 811 }
836 812
837 // We get to here from a key pressed in the Day View 813 // We get to here from a key pressed in the Day View
838 // So we can assume some things. We want the string 814 // So we can assume some things. We want the string
839 // passed in to be part of the description. 815 // passed in to be part of the description.
840 QDateTime start, end; 816 QDateTime start, end;
841 if ( views->visibleWidget() == dayView ) { 817 if ( views->visibleWidget() == dayView ) {
842 dayView->selectedDates( start, end ); 818 dayView->selectedDates( start, end );
843 } else if ( views->visibleWidget() == monthView ) { 819 } else if ( views->visibleWidget() == monthView ) {
844 QDate d = monthView->selectedDate(); 820 QDate d = monthView->selectedDate();
845 start = end = d; 821 start = end = d;
846 start.setTime( QTime( 10, 0 ) ); 822 start.setTime( QTime( 10, 0 ) );
847 end.setTime( QTime( 12, 0 ) ); 823 end.setTime( QTime( 12, 0 ) );
848 } else if ( views->visibleWidget() == weekView ) { 824 } else if ( views->visibleWidget() == weekView ) {
849 QDate d = weekView->date(); 825 QDate d = weekView->date();
850 start = end = d; 826 start = end = d;
851 start.setTime( QTime( 10, 0 ) ); 827 start.setTime( QTime( 10, 0 ) );
852 end.setTime( QTime( 12, 0 ) ); 828 end.setTime( QTime( 12, 0 ) );
853 } else if ( views->visibleWidget() == weekLstView ) { 829 } else if ( views->visibleWidget() == weekLstView ) {
854 QDate d = weekLstView->date(); 830 QDate d = weekLstView->date();
855 start = end = d; 831 start = end = d;
856 start.setTime( QTime( 10, 0 ) ); 832 start.setTime( QTime( 10, 0 ) );
857 end.setTime( QTime( 12, 0 ) ); 833 end.setTime( QTime( 12, 0 ) );
858 } 834 }
859 slotNewEntry(start, end, str); 835 slotNewEntry(start, end, str);
860} 836}
861void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location) { 837void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location) {
862 // argh! This really needs to be encapsulated in a class 838 // argh! This really needs to be encapsulated in a class
863 // or function. 839 // or function.
864 QDialog newDlg( this, 0, TRUE ); 840 QDialog newDlg( this, 0, TRUE );
865 newDlg.setCaption( DateEntryBase::tr("New Event") ); 841 newDlg.setCaption( DateEntryBase::tr("New Event") );
866 DateEntry *e; 842 DateEntry *e;
867 QVBoxLayout *vb = new QVBoxLayout( &newDlg ); 843 QVBoxLayout *vb = new QVBoxLayout( &newDlg );
868 QScrollView *sv = new QScrollView( &newDlg ); 844 QScrollView *sv = new QScrollView( &newDlg );
869 sv->setResizePolicy( QScrollView::AutoOneFit ); 845 sv->setResizePolicy( QScrollView::AutoOneFit );
870 sv->setFrameStyle( QFrame::NoFrame ); 846 sv->setFrameStyle( QFrame::NoFrame );
871 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 847 sv->setHScrollBarMode( QScrollView::AlwaysOff );
872 vb->addWidget( sv ); 848 vb->addWidget( sv );
873 849
874 Event ev; 850 Event ev;
875 ev.setDescription( str ); 851 ev.setDescription( str );
876 // When the new gui comes in, change this... 852 // When the new gui comes in, change this...
877 if(location==0) { 853 if(location==0) {
878 if(defaultLocation.isEmpty()) { 854 if(defaultLocation.isEmpty()) {
879 ev.setLocation(tr("(Unknown)")); 855 ev.setLocation(tr("(Unknown)"));
880 } else { 856 } else {
881 ev.setLocation( defaultLocation ); 857 ev.setLocation( defaultLocation );
882 } 858 }
883 } else { 859 } else {
884 ev.setLocation(location); 860 ev.setLocation(location);
885 } 861 }
886 ev.setCategories(defaultCategories); 862 ev.setCategories(defaultCategories);
887 ev.setStart( start ); 863 ev.setStart( start );
888 ev.setEnd( end ); 864 ev.setEnd( end );
889 865
890 e = new DateEntry( onMonday, ev, ampm, &newDlg ); 866 e = new DateEntry( onMonday, ev, ampm, &newDlg );
891 e->setAlarmEnabled( aPreset, presetTime, Event::Loud ); 867 e->setAlarmEnabled( aPreset, presetTime, Event::Loud );
892 sv->addChild( e ); 868 sv->addChild( e );
893#if defined(Q_WS_QWS) || defined(_WS_QWS_) 869#if defined(Q_WS_QWS) || defined(_WS_QWS_)
894 newDlg.showMaximized(); 870 newDlg.showMaximized();
895#endif 871#endif
896 while (newDlg.exec()) { 872 while (newDlg.exec()) {
897 ev = e->event(); 873 ev = e->event();
898 ev.assignUid(); 874 ev.assignUid();
899 QString error = checkEvent( ev ); 875 QString error = checkEvent( ev );
900 if ( !error.isNull() ) { 876 if ( !error.isNull() ) {
901 if ( QMessageBox::warning( this, tr("Error!"), error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 ) 877 if ( QMessageBox::warning( this, tr("Error!"), error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 )
902 continue; 878 continue;
903 } 879 }
904 db->addEvent( ev ); 880 db->addEvent( ev );
905 emit newEvent(); 881 emit newEvent();
906 break; 882 break;
907 } 883 }
908} 884}
909 885
910void DateBook::setDocument( const QString &filename ) 886void DateBook::setDocument( const QString &filename )
911{ 887{
912 if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; 888 if ( filename.find(".vcs") != int(filename.length()) - 4 ) return;
913 889
914 QValueList<Event> tl = Event::readVCalendar( filename ); 890 QValueList<Event> tl = Event::readVCalendar( filename );
915 for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) { 891 for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) {
916 db->addEvent( *it ); 892 db->addEvent( *it );
917 } 893 }
918} 894}
919 895
920static const char * beamfile = "/tmp/obex/event.vcs"; 896static const char * beamfile = "/tmp/obex/event.vcs";
921 897
922void DateBook::beamEvent( const Event &e ) 898void DateBook::beamEvent( const Event &e )
923{ 899{
924 qDebug("trying to beamn"); 900 qDebug("trying to beamn");
925 unlink( beamfile ); // delete if exists 901 unlink( beamfile ); // delete if exists
926 mkdir("/tmp/obex/", 0755); 902 mkdir("/tmp/obex/", 0755);
927 Event::writeVCalendar( beamfile, e ); 903 Event::writeVCalendar( beamfile, e );
928 Ir *ir = new Ir( this ); 904 Ir *ir = new Ir( this );
929 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 905 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
930 QString description = e.description(); 906 QString description = e.description();
931 ir->send( beamfile, description, "text/x-vCalendar" ); 907 ir->send( beamfile, description, "text/x-vCalendar" );
932} 908}
933 909
934void DateBook::beamDone( Ir *ir ) 910void DateBook::beamDone( Ir *ir )
935{ 911{
936 delete ir; 912 delete ir;
937 unlink( beamfile ); 913 unlink( beamfile );
938} 914}
939 915
940void DateBook::slotFind() 916void DateBook::slotFind()
941{ 917{
942 // move it to the day view... 918 // move it to the day view...
943 viewDay(); 919 viewDay();
944 FindDialog frmFind( "Calendar", this ); 920 FindDialog frmFind( "Calendar", this );
945 frmFind.setUseDate( true ); 921 frmFind.setUseDate( true );
946 frmFind.setDate( currentDate() ); 922 frmFind.setDate( currentDate() );
947 QObject::connect( &frmFind, 923 QObject::connect( &frmFind,
948 SIGNAL(signalFindClicked(const QString&, const QDate&, 924 SIGNAL(signalFindClicked(const QString&, const QDate&,
949 bool, bool, int)), 925 bool, bool, int)),
950 this, 926 this,
951 SLOT(slotDoFind(const QString&, const QDate&, 927 SLOT(slotDoFind(const QString&, const QDate&,
952 bool, bool, int)) ); 928 bool, bool, int)) );
953 QObject::connect( this, 929 QObject::connect( this,
954 SIGNAL(signalNotFound()), 930 SIGNAL(signalNotFound()),
955 &frmFind, 931 &frmFind,
956 SLOT(slotNotFound()) ); 932 SLOT(slotNotFound()) );
957 QObject::connect( this, 933 QObject::connect( this,
958 SIGNAL(signalWrapAround()), 934 SIGNAL(signalWrapAround()),
959 &frmFind, 935 &frmFind,
960 SLOT(slotWrapAround()) ); 936 SLOT(slotWrapAround()) );
961 frmFind.move(0,0); 937 frmFind.move(0,0);
962 frmFind.exec(); 938 frmFind.exec();
963 inSearch = false; 939 inSearch = false;
964} 940}
965 941
966bool catComp( QArray<int> cats, int category ) 942bool catComp( QArray<int> cats, int category )
967{ 943{
968 bool returnMe; 944 bool returnMe;
969 int i, 945 int i,
970 count; 946 count;
971 947
972 count = int(cats.count()); 948 count = int(cats.count());
973 returnMe = false; 949 returnMe = false;
974 if ( (category == -1 && count == 0) || category == -2 ) 950 if ( (category == -1 && count == 0) || category == -2 )
975 returnMe = true; 951 returnMe = true;
976 else { 952 else {
977 for ( i = 0; i < count; i++ ) { 953 for ( i = 0; i < count; i++ ) {
978 if ( category == cats[i] ) { 954 if ( category == cats[i] ) {
979 returnMe = true; 955 returnMe = true;
980 break; 956 break;
981 } 957 }
982 } 958 }
983 } 959 }
984 return returnMe; 960 return returnMe;
985} 961}
986 962
987 963
988void DateBook::slotDoFind( const QString& txt, const QDate &dt, 964void DateBook::slotDoFind( const QString& txt, const QDate &dt,
989 bool caseSensitive, bool /*backwards*/, 965 bool caseSensitive, bool /*backwards*/,
990 int category ) 966 int category )
991{ 967{
992 QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ), 968 QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ),
993 next; 969 next;
994 970
995 QRegExp r( txt ); 971 QRegExp r( txt );
996 r.setCaseSensitive( caseSensitive ); 972 r.setCaseSensitive( caseSensitive );
997 973
998 974
999 static Event rev, 975 static Event rev,
1000 nonrev; 976 nonrev;
1001 if ( !inSearch ) { 977 if ( !inSearch ) {
1002 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); 978 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) );
1003 nonrev.setStart( rev.start() ); 979 nonrev.setStart( rev.start() );
1004 inSearch = true; 980 inSearch = true;
1005 } 981 }
1006 static QDate searchDate = dt; 982 static QDate searchDate = dt;
1007 static bool wrapAround = true; 983 static bool wrapAround = true;
1008 bool candidtate; 984 bool candidtate;
1009 candidtate = false; 985 candidtate = false;
1010 986
1011 QValueList<Event> repeats = db->getRawRepeats(); 987 QValueList<Event> repeats = db->getRawRepeats();
1012 988
1013 // find the candidate for the first repeat that matches... 989 // find the candidate for the first repeat that matches...
1014 QValueListConstIterator<Event> it; 990 QValueListConstIterator<Event> it;
1015 QDate start = dt; 991 QDate start = dt;
diff --git a/core/pim/datebook/datebookweek.cpp b/core/pim/datebook/datebookweek.cpp
index 8241655..3ae4610 100644
--- a/core/pim/datebook/datebookweek.cpp
+++ b/core/pim/datebook/datebookweek.cpp
@@ -1,706 +1,679 @@
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 "datebookweek.h" 20#include "datebookweek.h"
21#include "datebookweekheaderimpl.h" 21#include "datebookweekheaderimpl.h"
22 22
23#include <qpe/calendar.h> 23#include <qpe/calendar.h>
24#include <qpe/datebookdb.h> 24#include <qpe/datebookdb.h>
25#include <qpe/event.h> 25#include <qpe/event.h>
26#include <qpe/qpeapplication.h> 26#include <qpe/qpeapplication.h>
27#include <qpe/timestring.h> 27#include <qpe/timestring.h>
28 28
29#include <qdatetime.h> 29#include <qdatetime.h>
30#include <qheader.h> 30#include <qheader.h>
31#include <qlabel.h> 31#include <qlabel.h>
32#include <qlayout.h> 32#include <qlayout.h>
33#include <qpainter.h> 33#include <qpainter.h>
34#include <qpopupmenu.h> 34#include <qpopupmenu.h>
35#include <qtimer.h> 35#include <qtimer.h>
36#include <qspinbox.h> 36#include <qspinbox.h>
37#include <qstyle.h> 37#include <qstyle.h>
38 38
39//----------------------------------------------------------------- 39//-----------------------------------------------------------------
40 40
41 41
42DateBookWeekItem::DateBookWeekItem( const EffectiveEvent e ) 42DateBookWeekItem::DateBookWeekItem( const EffectiveEvent e )
43 : ev( e ) 43 : ev( e )
44{ 44{
45 // with the current implementation change the color for all day events 45 // with the current implementation change the color for all day events
46 if ( ev.event().type() == Event::AllDay && !ev.event().hasAlarm() ) { 46 if ( ev.event().type() == Event::AllDay && !ev.event().hasAlarm() ) {
47 c = Qt::green; 47 c = Qt::green;
48 } else { 48 } else {
49 c = ev.event().hasAlarm() ? Qt::red : Qt::blue; 49 c = ev.event().hasAlarm() ? Qt::red : Qt::blue;
50 } 50 }
51} 51}
52 52
53void DateBookWeekItem::setGeometry( int x, int y, int w, int h ) 53void DateBookWeekItem::setGeometry( int x, int y, int w, int h )
54{ 54{
55 r.setRect( x, y, w, h ); 55 r.setRect( x, y, w, h );
56} 56}
57 57
58 58
59//------------------=--------------------------------------------- 59//------------------=---------------------------------------------
60 60
61DateBookWeekView::DateBookWeekView( bool ap, bool startOnMonday, 61DateBookWeekView::DateBookWeekView( bool ap, bool startOnMonday,
62 QWidget *parent, const char *name ) 62 QWidget *parent, const char *name )
63 : QScrollView( parent, name ), ampm( ap ), bOnMonday( startOnMonday ), 63 : QScrollView( parent, name ), ampm( ap ), bOnMonday( startOnMonday ),
64 showingEvent( false ) 64 showingEvent( false )
65{ 65{
66 items.setAutoDelete( true ); 66 items.setAutoDelete( true );
67 67
68 viewport()->setBackgroundMode( PaletteBase ); 68 viewport()->setBackgroundMode( PaletteBase );
69 69
70 header = new QHeader( this ); 70 header = new QHeader( this );
71 header->addLabel( "" ); 71 header->addLabel( "" );
72 72
73 header->setMovingEnabled( false ); 73 header->setMovingEnabled( false );
74 header->setResizeEnabled( false ); 74 header->setResizeEnabled( false );
75 header->setClickEnabled( false, 0 ); 75 header->setClickEnabled( false, 0 );
76 initNames(); 76 initNames();
77 77
78 78
79 connect( header, SIGNAL(clicked(int)), this, SIGNAL(showDay(int)) ); 79 connect( header, SIGNAL(clicked(int)), this, SIGNAL(showDay(int)) );
80 80
81 QObject::connect(qApp, SIGNAL(clockChanged(bool)), 81 QObject::connect(qApp, SIGNAL(clockChanged(bool)),
82 this, SLOT(slotChangeClock(bool))); 82 this, SLOT(slotChangeClock(bool)));
83 83
84 QFontMetrics fm( font() ); 84 QFontMetrics fm( font() );
85 rowHeight = fm.height()+2; 85 rowHeight = fm.height()+2;
86 86
87 resizeContents( width(), 24*rowHeight ); 87 resizeContents( width(), 24*rowHeight );
88} 88}
89 89
90void DateBookWeekView::initNames() 90void DateBookWeekView::initNames()
91{ 91{
92 static bool bFirst = true; 92 static bool bFirst = true;
93 if ( bFirst ) { 93 if ( bFirst ) {
94 if ( bOnMonday ) { 94 if ( bOnMonday ) {
95 header->addLabel( tr("M", "Monday" ) ); 95 header->addLabel( tr("M", "Monday" ) );
96 header->addLabel( tr("T", "Tuesday") ); 96 header->addLabel( tr("T", "Tuesday") );
97 header->addLabel( tr("W", "Wednesday" ) ); 97 header->addLabel( tr("W", "Wednesday" ) );
98 header->addLabel( tr("T", "Thursday" ) ); 98 header->addLabel( tr("T", "Thursday" ) );
99 header->addLabel( tr("F", "Friday" ) ); 99 header->addLabel( tr("F", "Friday" ) );
100 header->addLabel( tr("S", "Saturday" ) ); 100 header->addLabel( tr("S", "Saturday" ) );
101 header->addLabel( tr("S", "Sunday" ) ); 101 header->addLabel( tr("S", "Sunday" ) );
102 } else { 102 } else {
103 header->addLabel( tr("S", "Sunday" ) ); 103 header->addLabel( tr("S", "Sunday" ) );
104 header->addLabel( tr("M", "Monday") ); 104 header->addLabel( tr("M", "Monday") );
105 header->addLabel( tr("T", "Tuesday") ); 105 header->addLabel( tr("T", "Tuesday") );
106 header->addLabel( tr("W", "Wednesday" ) ); 106 header->addLabel( tr("W", "Wednesday" ) );
107 header->addLabel( tr("T", "Thursday" ) ); 107 header->addLabel( tr("T", "Thursday" ) );
108 header->addLabel( tr("F", "Friday" ) ); 108 header->addLabel( tr("F", "Friday" ) );
109 header->addLabel( tr("S", "Saturday" ) ); 109 header->addLabel( tr("S", "Saturday" ) );
110 } 110 }
111 bFirst = false; 111 bFirst = false;
112 } else { 112 } else {
113 // we are change things... 113 // we are change things...
114 if ( bOnMonday ) { 114 if ( bOnMonday ) {
115 header->setLabel( 1, tr("M", "Monday") ); 115 header->setLabel( 1, tr("M", "Monday") );
116 header->setLabel( 2, tr("T", "Tuesday") ); 116 header->setLabel( 2, tr("T", "Tuesday") );
117 header->setLabel( 3, tr("W", "Wednesday" ) ); 117 header->setLabel( 3, tr("W", "Wednesday" ) );
118 header->setLabel( 4, tr("T", "Thursday" ) ); 118 header->setLabel( 4, tr("T", "Thursday" ) );
119 header->setLabel( 5, tr("F", "Friday" ) ); 119 header->setLabel( 5, tr("F", "Friday" ) );
120 header->setLabel( 6, tr("S", "Saturday" ) ); 120 header->setLabel( 6, tr("S", "Saturday" ) );
121 header->setLabel( 7, tr("S", "Sunday" ) ); 121 header->setLabel( 7, tr("S", "Sunday" ) );
122 } else { 122 } else {
123 header->setLabel( 1, tr("S", "Sunday" ) ); 123 header->setLabel( 1, tr("S", "Sunday" ) );
124 header->setLabel( 2, tr("M", "Monday") ); 124 header->setLabel( 2, tr("M", "Monday") );
125 header->setLabel( 3, tr("T", "Tuesday") ); 125 header->setLabel( 3, tr("T", "Tuesday") );
126 header->setLabel( 4, tr("W", "Wednesday" ) ); 126 header->setLabel( 4, tr("W", "Wednesday" ) );
127 header->setLabel( 5, tr("T", "Thursday" ) ); 127 header->setLabel( 5, tr("T", "Thursday" ) );
128 header->setLabel( 6, tr("F", "Friday" ) ); 128 header->setLabel( 6, tr("F", "Friday" ) );
129 header->setLabel( 7, tr("S", "Saturday" ) ); 129 header->setLabel( 7, tr("S", "Saturday" ) );
130 } 130 }
131 } 131 }
132} 132}
133 133
134 134
135 135
136void DateBookWeekView::showEvents( QValueList<EffectiveEvent> &ev ) 136void DateBookWeekView::showEvents( QValueList<EffectiveEvent> &ev )
137{ 137{
138 items.clear(); 138 items.clear();
139 QValueListIterator<EffectiveEvent> it; 139 QValueListIterator<EffectiveEvent> it;
140 for ( it = ev.begin(); it != ev.end(); ++it ) { 140 for ( it = ev.begin(); it != ev.end(); ++it ) {
141 DateBookWeekItem *i = new DateBookWeekItem( *it ); 141 DateBookWeekItem *i = new DateBookWeekItem( *it );
142 if(!((i->event().end().hour()==0) && (i->event().end().minute()==0) && (i->event().startDate()!=i->event().date()))) {// Skip events ending at 00:00 starting at another day. 142 if(!((i->event().end().hour()==0) && (i->event().end().minute()==0) && (i->event().startDate()!=i->event().date()))) {// Skip events ending at 00:00 starting at another day.
143 positionItem( i ); 143 positionItem( i );
144 items.append( i ); 144 items.append( i );
145 } 145 }
146 } 146 }
147 viewport()->update(); 147 viewport()->update();
148} 148}
149 149
150void DateBookWeekView::moveToHour( int h ) 150void DateBookWeekView::moveToHour( int h )
151{ 151{
152 int offset = h*rowHeight; 152 int offset = h*rowHeight;
153 setContentsPos( 0, offset ); 153 setContentsPos( 0, offset );
154} 154}
155 155
156void DateBookWeekView::keyPressEvent( QKeyEvent *e ) 156void DateBookWeekView::keyPressEvent( QKeyEvent *e )
157{ 157{
158 e->ignore(); 158 e->ignore();
159} 159}
160 160
161void DateBookWeekView::slotChangeClock( bool c ) 161void DateBookWeekView::slotChangeClock( bool c )
162{ 162{
163 ampm = c; 163 ampm = c;
164 viewport()->update(); 164 viewport()->update();
165} 165}
166 166
167static inline int db_round30min( int m ) 167static inline int db_round30min( int m )
168{ 168{
169 if ( m < 15 ) 169 if ( m < 15 )
170 m = 0; 170 m = 0;
171 else if ( m < 45 ) 171 else if ( m < 45 )
172 m = 1; 172 m = 1;
173 else 173 else
174 m = 2; 174 m = 2;
175 175
176 return m; 176 return m;
177} 177}
178 178
179void DateBookWeekView::alterDay( int day ) 179void DateBookWeekView::alterDay( int day )
180{ 180{
181 if ( !bOnMonday ) { 181 if ( !bOnMonday ) {
182 day--; 182 day--;
183 } 183 }
184 emit showDay( day ); 184 emit showDay( day );
185} 185}
186 186
187void DateBookWeekView::positionItem( DateBookWeekItem *i ) 187void DateBookWeekView::positionItem( DateBookWeekItem *i )
188{ 188{
189 const int Width = 8; 189 const int Width = 8;
190 const EffectiveEvent ev = i->event(); 190 const EffectiveEvent ev = i->event();
191 191
192 // 30 minute intervals 192 // 30 minute intervals
193 int y = ev.start().hour() * 2; 193 int y = ev.start().hour() * 2;
194 y += db_round30min( ev.start().minute() ); 194 y += db_round30min( ev.start().minute() );
195 int y2 = ev.end().hour() * 2; 195 int y2 = ev.end().hour() * 2;
196 y2 += db_round30min( ev.end().minute() ); 196 y2 += db_round30min( ev.end().minute() );
197 if ( y > 47 ) y = 47; 197 if ( y > 47 ) y = 47;
198 if ( y2 > 48 ) y2 = 48; 198 if ( y2 > 48 ) y2 = 48;
199 y = (y * rowHeight) / 2; 199 y = (y * rowHeight) / 2;
200 y2 = (y2 * rowHeight) / 2; 200 y2 = (y2 * rowHeight) / 2;
201 201
202 int h; 202 int h;
203 if ( ev.event().type() == Event::AllDay ) { 203 if ( ev.event().type() == Event::AllDay ) {
204 h = (48 * rowHeight) / 2; 204 h = (48 * rowHeight) / 2;
205 y = 0; 205 y = 0;
206 } else { 206 } else {
207 h=y2-y; 207 h=y2-y;
208 if ( h < (1*rowHeight)/2 ) h = (1*rowHeight)/2; 208 if ( h < (1*rowHeight)/2 ) h = (1*rowHeight)/2;
209 } 209 }
210 210
211 int dow = ev.date().dayOfWeek(); 211 int dow = ev.date().dayOfWeek();
212 if ( !bOnMonday ) { 212 if ( !bOnMonday ) {
213 if ( dow == 7 ) 213 if ( dow == 7 )
214 dow = 1; 214 dow = 1;
215 else 215 else
216 dow++; 216 dow++;
217 } 217 }
218 int x = header->sectionPos( dow ) - 1; 218 int x = header->sectionPos( dow ) - 1;
219 int xlim = header->sectionPos( dow ) + header->sectionSize( dow ); 219 int xlim = header->sectionPos( dow ) + header->sectionSize( dow );
220 DateBookWeekItem *isect = 0; 220 DateBookWeekItem *isect = 0;
221 do { 221 do {
222 i->setGeometry( x, y, Width, h ); 222 i->setGeometry( x, y, Width, h );
223 isect = intersects( i ); 223 isect = intersects( i );
224 x += Width - 1; 224 x += Width - 1;
225 } while ( isect && x < xlim ); 225 } while ( isect && x < xlim );
226} 226}
227 227
228DateBookWeekItem *DateBookWeekView::intersects( const DateBookWeekItem *item ) 228DateBookWeekItem *DateBookWeekView::intersects( const DateBookWeekItem *item )
229{ 229{
230 QRect geom = item->geometry(); 230 QRect geom = item->geometry();
231 231
232 // We allow the edges to overlap 232 // We allow the edges to overlap
233 geom.moveBy( 1, 1 ); 233 geom.moveBy( 1, 1 );
234 geom.setSize( geom.size()-QSize(2,2) ); 234 geom.setSize( geom.size()-QSize(2,2) );
235 235
236 QListIterator<DateBookWeekItem> it(items); 236 QListIterator<DateBookWeekItem> it(items);
237 for ( ; it.current(); ++it ) { 237 for ( ; it.current(); ++it ) {
238 DateBookWeekItem *i = it.current(); 238 DateBookWeekItem *i = it.current();
239 if ( i != item ) { 239 if ( i != item ) {
240 if ( i->geometry().intersects( geom ) ) { 240 if ( i->geometry().intersects( geom ) ) {
241 return i; 241 return i;
242 } 242 }
243 } 243 }
244 } 244 }
245 245
246 return 0; 246 return 0;
247} 247}
248 248
249void DateBookWeekView::contentsMousePressEvent( QMouseEvent *e ) 249void DateBookWeekView::contentsMousePressEvent( QMouseEvent *e )
250{ 250{
251 QListIterator<DateBookWeekItem> it(items); 251 QListIterator<DateBookWeekItem> it(items);
252 for ( ; it.current(); ++it ) { 252 for ( ; it.current(); ++it ) {
253 DateBookWeekItem *i = it.current(); 253 DateBookWeekItem *i = it.current();
254 if ( i->geometry().contains( e->pos() ) ) { 254 if ( i->geometry().contains( e->pos() ) ) {
255 showingEvent = true; 255 showingEvent = true;
256 emit signalShowEvent( i->event() ); 256 emit signalShowEvent( i->event() );
257 break; 257 break;
258 } 258 }
259 } 259 }
260} 260}
261 261
262void DateBookWeekView::contentsMouseReleaseEvent( QMouseEvent *e ) 262void DateBookWeekView::contentsMouseReleaseEvent( QMouseEvent *e )
263{ 263{
264 if ( showingEvent ) { 264 if ( showingEvent ) {
265 showingEvent = false; 265 showingEvent = false;
266 emit signalHideEvent(); 266 emit signalHideEvent();
267 } else { 267 } else {
268 int d = header->sectionAt( e->pos().x() ); 268 int d = header->sectionAt( e->pos().x() );
269 if ( d > 0 ) { 269 if ( d > 0 ) {
270 // if ( !bOnMonday ) 270 // if ( !bOnMonday )
271 // d--; 271 // d--;
272 emit showDay( d ); 272 emit showDay( d );
273 } 273 }
274 } 274 }
275} 275}
276 276
277void DateBookWeekView::drawContents( QPainter *p, int cx, int cy, int cw, int ch ) 277void DateBookWeekView::drawContents( QPainter *p, int cx, int cy, int cw, int ch )
278{ 278{
279 QRect ur( cx, cy, cw, ch ); 279 QRect ur( cx, cy, cw, ch );
280 p->setPen( lightGray ); 280 p->setPen( lightGray );
281 for ( int i = 1; i <= 7; i++ ) 281 for ( int i = 1; i <= 7; i++ )
282 p->drawLine( header->sectionPos(i)-2, cy, header->sectionPos(i)-2, cy+ch ); 282 p->drawLine( header->sectionPos(i)-2, cy, header->sectionPos(i)-2, cy+ch );
283 283
284 p->setPen( black ); 284 p->setPen( black );
285 for ( int t = 0; t < 24; t++ ) { 285 for ( int t = 0; t < 24; t++ ) {
286 int y = t*rowHeight; 286 int y = t*rowHeight;
287 if ( QRect( 1, y, 20, rowHeight ).intersects( ur ) ) { 287 if ( QRect( 1, y, 20, rowHeight ).intersects( ur ) ) {
288 QString s; 288 QString s;
289 if ( ampm ) { 289 if ( ampm ) {
290 if ( t == 0 ) 290 if ( t == 0 )
291 s = QString::number( 12 ); 291 s = QString::number( 12 );
292 else if ( t == 12 ) 292 else if ( t == 12 )
293 s = QString::number(12) + tr( "p" ); 293 s = QString::number(12) + tr( "p" );
294 else if ( t > 12 ) { 294 else if ( t > 12 ) {
295 if ( t - 12 < 10 ) 295 if ( t - 12 < 10 )
296 s = " "; 296 s = " ";
297 else 297 else
298 s = ""; 298 s = "";
299 s += QString::number( t - 12 ) + tr("p"); 299 s += QString::number( t - 12 ) + tr("p");
300 } else { 300 } else {
301 if ( 12 - t < 3 ) 301 if ( 12 - t < 3 )
302 s = ""; 302 s = "";
303 else 303 else
304 s = " "; 304 s = " ";
305 s += QString::number( t ); 305 s += QString::number( t );
306 } 306 }
307 } else { 307 } else {
308 s = QString::number( t ); 308 s = QString::number( t );
309 if ( s.length() == 1 ) 309 if ( s.length() == 1 )
310 s.prepend( "0" ); 310 s.prepend( "0" );
311 } 311 }
312 p->drawText( 1, y+p->fontMetrics().ascent()+1, s ); 312 p->drawText( 1, y+p->fontMetrics().ascent()+1, s );
313 } 313 }
314 } 314 }
315 315
316 QListIterator<DateBookWeekItem> it(items); 316 QListIterator<DateBookWeekItem> it(items);
317 for ( ; it.current(); ++it ) { 317 for ( ; it.current(); ++it ) {
318 DateBookWeekItem *i = it.current(); 318 DateBookWeekItem *i = it.current();
319 if ( i->geometry().intersects( ur ) ) { 319 if ( i->geometry().intersects( ur ) ) {
320 p->setBrush( i->color() ); 320 p->setBrush( i->color() );
321 p->drawRect( i->geometry() ); 321 p->drawRect( i->geometry() );
322 } 322 }
323 } 323 }
324} 324}
325 325
326void DateBookWeekView::resizeEvent( QResizeEvent *e ) 326void DateBookWeekView::resizeEvent( QResizeEvent *e )
327{ 327{
328 const int hourWidth = 20; 328 const int hourWidth = 20;
329 QScrollView::resizeEvent( e ); 329 QScrollView::resizeEvent( e );
330 int avail = width()-qApp->style().scrollBarExtent().width()-1; 330 int avail = width()-qApp->style().scrollBarExtent().width()-1;
331 header->setGeometry( 0, 0, avail, header->sizeHint().height() ); 331 header->setGeometry( 0, 0, avail, header->sizeHint().height() );
332 setMargins( 0, header->height(), 0, 0 ); 332 setMargins( 0, header->height(), 0, 0 );
333 header->resizeSection( 0, hourWidth ); 333 header->resizeSection( 0, hourWidth );
334 int sw = (avail - hourWidth) / 7; 334 int sw = (avail - hourWidth) / 7;
335 for ( int i = 1; i < 7; i++ ) 335 for ( int i = 1; i < 7; i++ )
336 header->resizeSection( i, sw ); 336 header->resizeSection( i, sw );
337 header->resizeSection( 7, avail - hourWidth - sw*6 ); 337 header->resizeSection( 7, avail - hourWidth - sw*6 );
338} 338}
339 339
340void DateBookWeekView::setStartOfWeek( bool bStartOnMonday ) 340void DateBookWeekView::setStartOfWeek( bool bStartOnMonday )
341{ 341{
342 bOnMonday = bStartOnMonday; 342 bOnMonday = bStartOnMonday;
343 initNames(); 343 initNames();
344} 344}
345 345
346//------------------------------------------------------------------- 346//-------------------------------------------------------------------
347 347
348DateBookWeek::DateBookWeek( bool ap, bool startOnMonday, DateBookDB *newDB, 348DateBookWeek::DateBookWeek( bool ap, bool startOnMonday, DateBookDB *newDB,
349 QWidget *parent, const char *name ) 349 QWidget *parent, const char *name )
350 : QWidget( parent, name ), 350 : QWidget( parent, name ),
351 db( newDB ), 351 db( newDB ),
352 startTime( 0 ), 352 startTime( 0 ),
353 ampm( ap ), 353 ampm( ap ),
354 bStartOnMonday( startOnMonday ) 354 bStartOnMonday( startOnMonday )
355{ 355{
356 setFocusPolicy(StrongFocus); 356 setFocusPolicy(StrongFocus);
357 QVBoxLayout *vb = new QVBoxLayout( this ); 357 QVBoxLayout *vb = new QVBoxLayout( this );
358 header = new DateBookWeekHeader( bStartOnMonday, this ); 358 header = new DateBookWeekHeader( bStartOnMonday, this );
359 view = new DateBookWeekView( ampm, startOnMonday, this ); 359 view = new DateBookWeekView( ampm, startOnMonday, this );
360 vb->addWidget( header ); 360 vb->addWidget( header );
361 vb->addWidget( view ); 361 vb->addWidget( view );
362 362
363 lblDesc = new QLabel( this, "event label" ); 363 lblDesc = new QLabel( this, "event label" );
364 lblDesc->setFrameStyle( QFrame::Plain | QFrame::Box ); 364 lblDesc->setFrameStyle( QFrame::Plain | QFrame::Box );
365 lblDesc->setBackgroundColor( yellow ); 365 lblDesc->setBackgroundColor( yellow );
366 lblDesc->hide(); 366 lblDesc->hide();
367 367
368 tHide = new QTimer( this ); 368 tHide = new QTimer( this );
369 369
370 connect( view, SIGNAL( showDay( int ) ), 370 connect( view, SIGNAL( showDay( int ) ), this, SLOT( showDay( int ) ) );
371 this, SLOT( showDay( int ) ) ); 371 connect( view, SIGNAL(signalShowEvent(const EffectiveEvent&)), this, SLOT(slotShowEvent(const EffectiveEvent&)) );
372 connect( view, SIGNAL(signalShowEvent(const EffectiveEvent&)), 372 connect( view, SIGNAL(signalHideEvent()), this, SLOT(slotHideEvent()) );
373 this, SLOT(slotShowEvent(const EffectiveEvent&)) ); 373 connect( header, SIGNAL( dateChanged( int, int ) ), this, SLOT( dateChanged( int, int ) ) );
374 connect( view, SIGNAL(signalHideEvent()), 374 connect( tHide, SIGNAL( timeout() ), lblDesc, SLOT( hide() ) );
375 this, SLOT(slotHideEvent()) ); 375 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) );
376 connect( header, SIGNAL( dateChanged( int, int ) ), 376 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotClockChanged(bool)));
377 this, SLOT( dateChanged( int, int ) ) ); 377 setDate(QDate::currentDate());
378 connect( tHide, SIGNAL( timeout() ),
379 lblDesc, SLOT( hide() ) );
380 connect( header->spinYear, SIGNAL(valueChanged(int)),
381 this, SLOT(slotYearChanged(int)) );
382 connect( qApp, SIGNAL(weekChanged(bool)),
383 this, SLOT(slotWeekChanged(bool)) );
384 connect( qApp, SIGNAL(clockChanged(bool)),
385 this, SLOT(slotClockChanged(bool)));
386 setDate(QDate::currentDate());
387
388} 378}
389 379
390void DateBookWeek::keyPressEvent(QKeyEvent *e) 380void DateBookWeek::keyPressEvent(QKeyEvent *e)
391{ 381{
392 switch(e->key()) { 382 switch(e->key()) {
393 case Key_Up: 383 case Key_Up:
394 view->scrollBy(0, -20); 384 view->scrollBy(0, -20);
395 break; 385 break;
396 case Key_Down: 386 case Key_Down:
397 view->scrollBy(0, 20); 387 view->scrollBy(0, 20);
398 break; 388 break;
399 case Key_Left: 389 case Key_Left:
400 setDate(date().addDays(-7)); 390 setDate(date().addDays(-7));
401 break; 391 break;
402 case Key_Right: 392 case Key_Right:
403 setDate(date().addDays(7)); 393 setDate(date().addDays(7));
404 break; 394 break;
405 default: 395 default:
406 e->ignore(); 396 e->ignore();
407 } 397 }
408} 398}
409 399
410void DateBookWeek::showDay( int day ) 400void DateBookWeek::showDay( int day )
411{ 401{
412 QDate d; 402 QDate d;
413 d = dateFromWeek( _week, year, bStartOnMonday ); 403 d = dateFromWeek( _week, year, bStartOnMonday );
414 day--; 404 day--;
415 d = d.addDays( day ); 405 d = d.addDays( day );
416 emit showDate( d.year(), d.month(), d.day() ); 406 emit showDate( d.year(), d.month(), d.day() );
417} 407}
418 408
419void DateBookWeek::setDate( int y, int m, int d ) 409void DateBookWeek::setDate( int y, int m, int d )
420{ 410{
421 QDate date; 411 setDate(QDate(y, m, d));
422 date.setYMD( y, m, d );
423 setDate(QDate(y, m, d));
424} 412}
425 413
426void DateBookWeek::setDate(QDate date) 414void DateBookWeek::setDate(QDate date)
427{ 415{
428 dow = date.dayOfWeek(); 416 dow = date.dayOfWeek();
429 int w, y; 417 int w, y;
430 calcWeek( date, w, y, bStartOnMonday ); 418 calcWeek( date, w, y, bStartOnMonday );
431 header->setDate( y, w ); 419 header->setDate( date );
432} 420}
433 421
434void DateBookWeek::dateChanged( int y, int w ) 422void DateBookWeek::dateChanged( int y, int w )
435{ 423{
436 year = y; 424 year = y;
437 _week = w; 425 _week = w;
438 getEvents(); 426 getEvents();
439} 427}
440 428
441QDate DateBookWeek::date() const 429QDate DateBookWeek::date() const
442{ 430{
443 QDate d; 431 QDate d;
444 d = dateFromWeek( _week - 1, year, bStartOnMonday ); 432 d = dateFromWeek( _week - 1, year, bStartOnMonday );
445 if ( bStartOnMonday ) 433 if ( bStartOnMonday )
446 d = d.addDays( 7 + dow - 1 ); 434 d = d.addDays( 7 + dow - 1 );
447 else { 435 else {
448 if ( dow == 7 ) 436 if ( dow == 7 )
449 d = d.addDays( dow ); 437 d = d.addDays( dow );
450 else 438 else
451 d = d.addDays( 7 + dow ); 439 d = d.addDays( 7 + dow );
452 } 440 }
453 return d; 441 return d;
454} 442}
455 443
456void DateBookWeek::getEvents() 444void DateBookWeek::getEvents()
457{ 445{
458 QDate startWeek = weekDate(); 446 QDate startWeek = weekDate();
459 447
460 QDate endWeek = startWeek.addDays( 6 ); 448 QDate endWeek = startWeek.addDays( 6 );
461 QValueList<EffectiveEvent> eventList = db->getEffectiveEvents(startWeek, 449 QValueList<EffectiveEvent> eventList = db->getEffectiveEvents(startWeek, endWeek);
462 endWeek); 450 view->showEvents( eventList );
463 view->showEvents( eventList ); 451 view->moveToHour( startTime );
464 view->moveToHour( startTime );
465} 452}
466 453
467void DateBookWeek::generateAllDayTooltext( QString& text ) { 454void DateBookWeek::generateAllDayTooltext( QString& text ) {
468 text += "<b>" + tr("This is an all day event.") + "</b><br>"; 455 text += "<b>" + tr("This is an all day event.") + "</b><br>";
469} 456}
470 457
471void DateBookWeek::generateNormalTooltext( QString& str, 458void DateBookWeek::generateNormalTooltext( QString& str, const EffectiveEvent &ev ) {
472 const EffectiveEvent &ev ) { 459 str += "<b>" + QObject::tr("Start") + "</b>: ";
473 str += "<b>" + QObject::tr("Start") + "</b>: "; 460 str += TimeString::timeString( ev.event().start().time(), ampm, FALSE );
474 str += TimeString::timeString( ev.event().start().time(), ampm, FALSE ); 461 if( ev.startDate()!=ev.endDate() ) {
475 if( ev.startDate()!=ev.endDate() ) { 462 str += " <i>" + TimeString::longDateString( ev.startDate() )+"</i>";
476 str += " <i>" + TimeString::longDateString( ev.startDate() )+"</i>"; 463 }
477 } 464 str += "<br>";
478 str += "<br>"; 465 str += "<b>" + QObject::tr("End") + "</b>: ";
479 str += "<b>" + QObject::tr("End") + "</b>: "; 466 str += TimeString::timeString( ev.event().end().time(), ampm, FALSE );
480 str += TimeString::timeString( ev.event().end().time(), ampm, FALSE ); 467 if( ev.startDate()!=ev.endDate() ) {
481 if( ev.startDate()!=ev.endDate() ) { 468 str += " <i>" + TimeString::longDateString( ev.endDate() ) + "</i>";
482 str += " <i>" + TimeString::longDateString( ev.endDate() ) + "</i>"; 469 }
483 }
484} 470}
485 471
486void DateBookWeek::slotShowEvent( const EffectiveEvent &ev ) 472void DateBookWeek::slotShowEvent( const EffectiveEvent &ev )
487{ 473{
488 if ( tHide->isActive() ) 474 if ( tHide->isActive() )
489 tHide->stop(); 475 tHide->stop();
490 476
491 // why would someone use "<"? Oh well, fix it up... 477 // why would someone use "<"? Oh well, fix it up...
492 // I wonder what other things may be messed up... 478 // I wonder what other things may be messed up...
493 QString strDesc = ev.description(); 479 QString strDesc = ev.description();
494 int where = strDesc.find( "<" ); 480 int where = strDesc.find( "<" );
495 while ( where != -1 ) { 481 while ( where != -1 ) {
496 strDesc.remove( where, 1 ); 482 strDesc.remove( where, 1 );
497 strDesc.insert( where, "&#60;" ); 483 strDesc.insert( where, "&#60;" );
498 where = strDesc.find( "<", where ); 484 where = strDesc.find( "<", where );
499 } 485 }
500 486
501 QString strCat; 487 QString strCat;
502 // ### FIX later... 488 // ### FIX later...
503// QString strCat = ev.category(); 489// QString strCat = ev.category();
504// where = strCat.find( "<" ); 490// where = strCat.find( "<" );
505// while ( where != -1 ) { 491// while ( where != -1 ) {
506 // strCat.remove( where, 1 ); 492 // strCat.remove( where, 1 );
507 // strCat.insert( where, "&#60;" ); 493 // strCat.insert( where, "&#60;" );
508 // where = strCat.find( "<", where ); 494 // where = strCat.find( "<", where );
509// } 495// }
510 496
511 QString strLocation = ev.location(); 497 QString strLocation = ev.location();
512 while ( where != -1 ) { 498 while ( where != -1 ) {
513 strLocation.remove( where, 1 ); 499 strLocation.remove( where, 1 );
514 strLocation.insert( where, "&#60;" ); 500 strLocation.insert( where, "&#60;" );
515 where = strLocation.find( "<", where ); 501 where = strLocation.find( "<", where );
516 } 502 }
517 503
518 QString strNote = ev.notes(); 504 QString strNote = ev.notes();
519 where = strNote.find( "<" ); 505 where = strNote.find( "<" );
520 while ( where != -1 ) { 506 while ( where != -1 ) {
521 strNote.remove( where, 1 ); 507 strNote.remove( where, 1 );
522 strNote.insert( where, "&#60;" ); 508 strNote.insert( where, "&#60;" );
523 where = strNote.find( "<", where ); 509 where = strNote.find( "<", where );
524 } 510 }
525 511
526 QString str = "<b>" + strDesc + "</b><br>" 512 QString str = "<b>" + strDesc + "</b><br>"
527 + strLocation + "<br>" 513 + strLocation + "<br>"
528 + "<i>" + strCat + "</i>" 514 + "<i>" + strCat + "</i>"
529 + "<br>" + TimeString::longDateString( ev.date() ) 515 + "<br>" + TimeString::longDateString( ev.date() )
530 + "<br>"; 516 + "<br>";
531 517
532 if (ev.event().type() == Event::Normal ) 518 if (ev.event().type() == Event::Normal )
533 generateNormalTooltext( str, ev ); 519 generateNormalTooltext( str, ev );
534 else 520 else
535 generateAllDayTooltext( str ); 521 generateAllDayTooltext( str );
536 522
537 str += "<br><br>" + strNote; 523 str += "<br><br>" + strNote;
538 524
539 lblDesc->setText( str ); 525 lblDesc->setText( str );
540 lblDesc->resize( lblDesc->sizeHint() ); 526 lblDesc->resize( lblDesc->sizeHint() );
541 // move the label so it is "centerd" horizontally... 527 // move the label so it is "centerd" horizontally...
542 lblDesc->move( QMAX(0,(width() - lblDesc->width()) / 2), 0 ); 528 lblDesc->move( QMAX(0,(width() - lblDesc->width()) / 2), 0 );
543 lblDesc->show(); 529 lblDesc->show();
544} 530}
545 531
546void DateBookWeek::slotHideEvent() 532void DateBookWeek::slotHideEvent()
547{ 533{
548 tHide->start( 2000, true ); 534 tHide->start( 2000, true );
549} 535}
550 536
551void DateBookWeek::setStartViewTime( int startHere ) 537void DateBookWeek::setStartViewTime( int startHere )
552{ 538{
553 startTime = startHere; 539 startTime = startHere;
554 view->moveToHour( startTime ); 540 view->moveToHour( startTime );
555} 541}
556 542
557int DateBookWeek::startViewTime() const 543int DateBookWeek::startViewTime() const
558{ 544{
559 return startTime; 545 return startTime;
560} 546}
561 547
562void DateBookWeek::redraw() 548void DateBookWeek::redraw()
563{ 549{
564 getEvents(); 550 getEvents();
565} 551}
566 552
567void DateBookWeek::slotYearChanged( int y ) 553void DateBookWeek::slotYearChanged( int y )
568{ 554{
569 int totWeek; 555 int totWeek;
570 QDate d( y, 12, 31 ); 556 QDate d( y, 12, 31 );
571 int throwAway; 557 int throwAway;
572 calcWeek( d, totWeek, throwAway, bStartOnMonday );
573 while ( totWeek == 1 ) {
574 d = d.addDays( -1 );
575 calcWeek( d, totWeek, throwAway, bStartOnMonday ); 558 calcWeek( d, totWeek, throwAway, bStartOnMonday );
576 } 559 while ( totWeek == 1 ) {
577 if ( totWeek != totalWeeks() ) 560 d = d.addDays( -1 );
578 setTotalWeeks( totWeek ); 561 calcWeek( d, totWeek, throwAway, bStartOnMonday );
579} 562 }
580
581
582void DateBookWeek::setTotalWeeks( int numWeeks )
583{
584 header->spinWeek->setMaxValue( numWeeks );
585}
586
587int DateBookWeek::totalWeeks() const
588{
589 return header->spinWeek->maxValue();
590} 563}
591 564
592void DateBookWeek::slotWeekChanged( bool onMonday ) 565void DateBookWeek::slotWeekChanged( bool onMonday )
593{ 566{
594 bStartOnMonday = onMonday; 567 bStartOnMonday = onMonday;
595 view->setStartOfWeek( bStartOnMonday ); 568 view->setStartOfWeek( bStartOnMonday );
596 header->setStartOfWeek( bStartOnMonday ); 569 header->setStartOfWeek( bStartOnMonday );
597 redraw(); 570 redraw();
598} 571}
599 572
600void DateBookWeek::slotClockChanged( bool ap ) 573void DateBookWeek::slotClockChanged( bool ap )
601{ 574{
602 ampm = ap; 575 ampm = ap;
603} 576}
604 577
605// return the date at the beginning of the week... 578// return the date at the beginning of the week...
606QDate DateBookWeek::weekDate() const 579QDate DateBookWeek::weekDate() const
607{ 580{
608 return dateFromWeek( _week, year, bStartOnMonday ); 581 return dateFromWeek( _week, year, bStartOnMonday );
609} 582}
610 583
611// this used to only be needed by datebook.cpp, but now we need it inside 584// this used to only be needed by datebook.cpp, but now we need it inside
612// week view since 585// week view since
613// we need to be able to figure out our total number of weeks on the fly... 586// we need to be able to figure out our total number of weeks on the fly...
614// this is probably the best place to put it.. 587// this is probably the best place to put it..
615 588
616// For Weeks that start on Monday... (EASY!) 589// For Weeks that start on Monday... (EASY!)
617// At the moment we will use ISO 8601 method for computing 590// At the moment we will use ISO 8601 method for computing
618// the week. Granted, other countries use other methods, 591// the week. Granted, other countries use other methods,
619// bet we aren't doing any Locale stuff at the moment. So, 592// bet we aren't doing any Locale stuff at the moment. So,
620// this should pass. This Algorithim is public domain and 593// this should pass. This Algorithim is public domain and
621// available at: 594// available at:
622// http://personal.ecu.edu/mccartyr/ISOwdALG.txt 595// http://personal.ecu.edu/mccartyr/ISOwdALG.txt
623// the week number is return, and the year number is returned in year 596// the week number is return, and the year number is returned in year
624// for Instance 2001/12/31 is actually the first week in 2002. 597// for Instance 2001/12/31 is actually the first week in 2002.
625// There is a more mathematical definition, but I will implement it when 598// There is a more mathematical definition, but I will implement it when
626// we are pass our deadline. 599// we are pass our deadline.
627 600
628// For Weeks that start on Sunday... (ahh... home rolled) 601// For Weeks that start on Sunday... (ahh... home rolled)
629// okay, if Jan 1 is on Friday or Saturday, 602// okay, if Jan 1 is on Friday or Saturday,
630// it will go to the pervious 603// it will go to the pervious
631// week... 604// week...
632 605
633bool calcWeek( const QDate &d, int &week, int &year, 606bool calcWeek( const QDate &d, int &week, int &year,
634 bool startOnMonday ) 607 bool startOnMonday )
635{ 608{
636 int weekNumber; 609 int weekNumber;
637 int yearNumber; 610 int yearNumber;
638 611
639 // remove a pesky warning, (Optimizations on g++) 612 // remove a pesky warning, (Optimizations on g++)
640 weekNumber = -1; 613 weekNumber = -1;
641 int jan1WeekDay = QDate(d.year(), 1, 1).dayOfWeek(); 614 int jan1WeekDay = QDate(d.year(), 1, 1).dayOfWeek();
642 int dayOfWeek = d.dayOfWeek(); 615 int dayOfWeek = d.dayOfWeek();
643 616
644 if ( !d.isValid() ) 617 if ( !d.isValid() )
645 return false; 618 return false;
646 619
647 if ( startOnMonday ) { 620 if ( startOnMonday ) {
648 // find the Jan1Weekday; 621 // find the Jan1Weekday;
649 if ( d.dayOfYear() <= ( 8 - jan1WeekDay) && jan1WeekDay > 4 ) { 622 if ( d.dayOfYear() <= ( 8 - jan1WeekDay) && jan1WeekDay > 4 ) {
650 yearNumber = d.year() - 1; 623 yearNumber = d.year() - 1;
651 if ( jan1WeekDay == 5 || ( jan1WeekDay == 6 && QDate::leapYear(yearNumber) ) ) 624 if ( jan1WeekDay == 5 || ( jan1WeekDay == 6 && QDate::leapYear(yearNumber) ) )
652 weekNumber = 53; 625 weekNumber = 53;
653 else 626 else
654 weekNumber = 52; 627 weekNumber = 52;
655 } else 628 } else
656 yearNumber = d.year(); 629 yearNumber = d.year();
657 if ( yearNumber == d.year() ) { 630 if ( yearNumber == d.year() ) {
658 int totalDays = 365; 631 int totalDays = 365;
659 if ( QDate::leapYear(yearNumber) ) 632 if ( QDate::leapYear(yearNumber) )
660 totalDays++; 633 totalDays++;
661 if ( ((totalDays - d.dayOfYear()) < (4 - dayOfWeek) ) 634 if ( ((totalDays - d.dayOfYear()) < (4 - dayOfWeek) )
662 || (jan1WeekDay == 7) && (totalDays - d.dayOfYear()) < 3) { 635 || (jan1WeekDay == 7) && (totalDays - d.dayOfYear()) < 3) {
663 yearNumber++; 636 yearNumber++;
664 weekNumber = 1; 637 weekNumber = 1;
665 } 638 }
666 } 639 }
667 if ( yearNumber == d.year() ) { 640 if ( yearNumber == d.year() ) {
668 int j = d.dayOfYear() + (7 - dayOfWeek) + ( jan1WeekDay - 1 ); 641 int j = d.dayOfYear() + (7 - dayOfWeek) + ( jan1WeekDay - 1 );
669 weekNumber = j / 7; 642 weekNumber = j / 7;
670 if ( jan1WeekDay > 4 ) 643 if ( jan1WeekDay > 4 )
671 weekNumber--; 644 weekNumber--;
672 } 645 }
673 } else { 646 } else {
674 // it's better to keep these cases separate... 647 // it's better to keep these cases separate...
675 if ( d.dayOfYear() <= (7 - jan1WeekDay) && jan1WeekDay > 4 648 if ( d.dayOfYear() <= (7 - jan1WeekDay) && jan1WeekDay > 4
676 && jan1WeekDay != 7 ) { 649 && jan1WeekDay != 7 ) {
677 yearNumber = d.year() - 1; 650 yearNumber = d.year() - 1;
678 if ( jan1WeekDay == 6 651 if ( jan1WeekDay == 6
679 || (jan1WeekDay == 7 && QDate::leapYear(yearNumber) ) ) { 652 || (jan1WeekDay == 7 && QDate::leapYear(yearNumber) ) ) {
680 weekNumber = 53; 653 weekNumber = 53;
681 }else 654 }else
682 weekNumber = 52; 655 weekNumber = 52;
683 } else 656 } else
684 yearNumber = d.year(); 657 yearNumber = d.year();
685 if ( yearNumber == d.year() ) { 658 if ( yearNumber == d.year() ) {
686 int totalDays = 365; 659 int totalDays = 365;
687 if ( QDate::leapYear( yearNumber ) ) 660 if ( QDate::leapYear( yearNumber ) )
688 totalDays++; 661 totalDays++;
689 if ( ((totalDays - d.dayOfYear()) < (4 - dayOfWeek % 7)) ) { 662 if ( ((totalDays - d.dayOfYear()) < (4 - dayOfWeek % 7)) ) {
690 yearNumber++; 663 yearNumber++;
691 weekNumber = 1; 664 weekNumber = 1;
692 } 665 }
693 } 666 }
694 if ( yearNumber == d.year() ) { 667 if ( yearNumber == d.year() ) {
695 int j = d.dayOfYear() + (7 - dayOfWeek % 7) + ( jan1WeekDay - 1 ); 668 int j = d.dayOfYear() + (7 - dayOfWeek % 7) + ( jan1WeekDay - 1 );
696 weekNumber = j / 7; 669 weekNumber = j / 7;
697 if ( jan1WeekDay > 4 ) { 670 if ( jan1WeekDay > 4 ) {
698 weekNumber--; 671 weekNumber--;
699 } 672 }
700 } 673 }
701 } 674 }
702 year = yearNumber; 675 year = yearNumber;
703 week = weekNumber; 676 week = weekNumber;
704 return true; 677 return true;
705} 678}
706 679
diff --git a/core/pim/datebook/datebookweek.h b/core/pim/datebook/datebookweek.h
index acbc2c7..8c5e06d 100644
--- a/core/pim/datebook/datebookweek.h
+++ b/core/pim/datebook/datebookweek.h
@@ -1,168 +1,166 @@
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 DATEBOOKWEEK 20#ifndef DATEBOOKWEEK
21#define DATEBOOKWEEK 21#define DATEBOOKWEEK
22 22
23#include <qpe/event.h> 23#include <qpe/event.h>
24 24
25#include <qlist.h> 25#include <qlist.h>
26#include <qscrollview.h> 26#include <qscrollview.h>
27#include <qstring.h> 27#include <qstring.h>
28#include <qvaluelist.h> 28#include <qvaluelist.h>
29 29
30class DateBookDB; 30class DateBookDB;
31class DateBookWeekHeader; 31class DateBookWeekHeader;
32class QDate; 32class QDate;
33class QLabel; 33class QLabel;
34class QResizeEvent; 34class QResizeEvent;
35class QSpinBox; 35class QSpinBox;
36class QTimer; 36class QTimer;
37class QHeader; 37class QHeader;
38 38
39class DateBookWeekItem 39class DateBookWeekItem
40{ 40{
41public: 41public:
42 DateBookWeekItem( const EffectiveEvent e ); 42 DateBookWeekItem( const EffectiveEvent e );
43 43
44 void setGeometry( int x, int y, int w, int h ); 44 void setGeometry( int x, int y, int w, int h );
45 QRect geometry() const { return r; } 45 QRect geometry() const { return r; }
46 46
47 const QColor &color() const { return c; } 47 const QColor &color() const { return c; }
48 const EffectiveEvent event() const { return ev; } 48 const EffectiveEvent event() const { return ev; }
49 49
50private: 50private:
51 const EffectiveEvent ev; 51 const EffectiveEvent ev;
52 QRect r; 52 QRect r;
53 QColor c; 53 QColor c;
54}; 54};
55 55
56class DateBookWeekView : public QScrollView 56class DateBookWeekView : public QScrollView
57{ 57{
58 Q_OBJECT 58 Q_OBJECT
59public: 59public:
60 DateBookWeekView( bool ampm, bool weekOnMonday, QWidget *parent = 0, 60 DateBookWeekView( bool ampm, bool weekOnMonday, QWidget *parent = 0,
61 const char *name = 0 ); 61 const char *name = 0 );
62 62
63 bool whichClock() const; 63 bool whichClock() const;
64 void showEvents( QValueList<EffectiveEvent> &ev ); 64 void showEvents( QValueList<EffectiveEvent> &ev );
65 void moveToHour( int h ); 65 void moveToHour( int h );
66 void setStartOfWeek( bool bOnMonday ); 66 void setStartOfWeek( bool bOnMonday );
67 67
68signals: 68signals:
69 void showDay( int d ); 69 void showDay( int d );
70 void signalShowEvent( const EffectiveEvent & ); 70 void signalShowEvent( const EffectiveEvent & );
71 void signalHideEvent(); 71 void signalHideEvent();
72 72
73protected slots: 73protected slots:
74 void keyPressEvent(QKeyEvent *); 74 void keyPressEvent(QKeyEvent *);
75 75
76private slots: 76private slots:
77 void slotChangeClock( bool ); 77 void slotChangeClock( bool );
78 void alterDay( int ); 78 void alterDay( int );
79 79
80private: 80private:
81 void positionItem( DateBookWeekItem *i ); 81 void positionItem( DateBookWeekItem *i );
82 DateBookWeekItem *intersects( const DateBookWeekItem * ); 82 DateBookWeekItem *intersects( const DateBookWeekItem * );
83 void drawContents( QPainter *p, int cx, int cy, int cw, int ch ); 83 void drawContents( QPainter *p, int cx, int cy, int cw, int ch );
84 void contentsMousePressEvent( QMouseEvent * ); 84 void contentsMousePressEvent( QMouseEvent * );
85 void contentsMouseReleaseEvent( QMouseEvent * ); 85 void contentsMouseReleaseEvent( QMouseEvent * );
86 void resizeEvent( QResizeEvent * ); 86 void resizeEvent( QResizeEvent * );
87 void initNames(); 87 void initNames();
88 88
89private: 89private:
90 bool ampm; 90 bool ampm;
91 bool bOnMonday; 91 bool bOnMonday;
92 QHeader *header; 92 QHeader *header;
93 QList<DateBookWeekItem> items; 93 QList<DateBookWeekItem> items;
94 int rowHeight; 94 int rowHeight;
95 bool showingEvent; 95 bool showingEvent;
96}; 96};
97 97
98class DateBookWeek : public QWidget 98class DateBookWeek : public QWidget
99{ 99{
100 Q_OBJECT 100 Q_OBJECT
101 101
102public: 102public:
103 DateBookWeek( bool ampm, bool weekOnMonday, DateBookDB *newDB, 103 DateBookWeek( bool ampm, bool weekOnMonday, DateBookDB *newDB,
104 QWidget *parent = 0, const char *name = 0 ); 104 QWidget *parent = 0, const char *name = 0 );
105 void setDate( int y, int m, int d ); 105 void setDate( int y, int m, int d );
106 void setDate( QDate d ); 106 void setDate( QDate d );
107 QDate date() const; 107 QDate date() const;
108 DateBookWeekView *weekView() const { return view; } 108 DateBookWeekView *weekView() const { return view; }
109 void setStartViewTime( int startHere ); 109 void setStartViewTime( int startHere );
110 int startViewTime() const; 110 int startViewTime() const;
111 int week() const { return _week; }; 111 int week() const { return _week; };
112 void setTotalWeeks( int totalWeeks );
113 int totalWeeks() const;
114 QDate weekDate() const; 112 QDate weekDate() const;
115 113
116public slots: 114public slots:
117 void redraw(); 115 void redraw();
118 void slotWeekChanged( bool bStartOnMonday ); 116 void slotWeekChanged( bool bStartOnMonday );
119 void slotClockChanged( bool a ); 117 void slotClockChanged( bool a );
120 118
121signals: 119signals:
122 void showDate( int y, int m, int d ); 120 void showDate( int y, int m, int d );
123 121
124protected slots: 122protected slots:
125 void keyPressEvent(QKeyEvent *); 123 void keyPressEvent(QKeyEvent *);
126 124
127private slots: 125private slots:
128 void showDay( int day ); 126 void showDay( int day );
129 void dateChanged( int y, int w ); 127 void dateChanged( int y, int w );
130 void slotShowEvent( const EffectiveEvent & ); 128 void slotShowEvent( const EffectiveEvent & );
131 void slotHideEvent(); 129 void slotHideEvent();
132 void slotYearChanged( int ); 130 void slotYearChanged( int );
133 131
134private: 132private:
135 void getEvents(); 133 void getEvents();
136 134
137 /** 135 /**
138 * Wow that's a hell lot of code duplication 136 * Wow that's a hell lot of code duplication
139 * in datebook. I vote for a common base class 137 * in datebook. I vote for a common base class
140 * but never the less. This add a note 138 * but never the less. This add a note
141 * that the Event is an all day event 139 * that the Event is an all day event
142 * 140 *
143 */ 141 */
144 void generateAllDayTooltext( QString& text ); 142 void generateAllDayTooltext( QString& text );
145 143
146 /** 144 /**
147 * This will add the times to the text 145 * This will add the times to the text
148 * It will be shown in the Tooltip bubble 146 * It will be shown in the Tooltip bubble
149 */ 147 */
150 void generateNormalTooltext( QString& text, 148 void generateNormalTooltext( QString& text,
151 const EffectiveEvent &ev); 149 const EffectiveEvent &ev);
152 int year; 150 int year;
153 int _week; 151 int _week;
154 int dow; 152 int dow;
155 DateBookWeekHeader *header; 153 DateBookWeekHeader *header;
156 DateBookWeekView *view; 154 DateBookWeekView *view;
157 DateBookDB *db; 155 DateBookDB *db;
158 QLabel *lblDesc; 156 QLabel *lblDesc;
159 QTimer *tHide; 157 QTimer *tHide;
160 int startTime; 158 int startTime;
161 bool ampm; 159 bool ampm;
162 bool bStartOnMonday; 160 bool bStartOnMonday;
163}; 161};
164 162
165 163
166bool calcWeek( const QDate &d, int &week, int &year, 164bool calcWeek( const QDate &d, int &week, int &year,
167 bool startOnMonday = false ); 165 bool startOnMonday = false );
168#endif 166#endif
diff --git a/core/pim/datebook/datebookweekheader.ui b/core/pim/datebook/datebookweekheader.ui
index 591b625..b2e0e36 100644
--- a/core/pim/datebook/datebookweekheader.ui
+++ b/core/pim/datebook/datebookweekheader.ui
@@ -1,335 +1,275 @@
1<!DOCTYPE UI><UI> 1<!DOCTYPE UI><UI>
2<class>DateBookWeekHeaderBase</class> 2<class>DateBookWeekHeaderBase</class>
3<comment>********************************************************************* 3<comment>*********************************************************************
4** Copyright (C) 2000 Trolltech AS. All rights reserved. 4** Copyright (C) 2000 Trolltech AS. All rights reserved.
5** 5**
6** This file is part of Qtopia Environment. 6** This file is part of Qtopia Environment.
7** 7**
8** This file may be distributed and/or modified under the terms of the 8** This file may be distributed and/or modified under the terms of the
9** GNU General Public License version 2 as published by the Free Software 9** GNU General Public License version 2 as published by the Free Software
10** Foundation and appearing in the file LICENSE.GPL included in the 10** Foundation and appearing in the file LICENSE.GPL included in the
11** packaging of this file. 11** packaging of this file.
12** 12**
13** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 13** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
14** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 14** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
15** 15**
16** See http://www.trolltech.com/gpl/ for GPL licensing information. 16** See http://www.trolltech.com/gpl/ for GPL licensing information.
17** 17**
18** Contact info@trolltech.com if any conditions of this licensing are 18** Contact info@trolltech.com if any conditions of this licensing are
19** not clear to you. 19** not clear to you.
20** 20**
21*********************************************************************</comment> 21*********************************************************************</comment>
22<widget> 22<widget>
23 <class>QWidget</class> 23 <class>QWidget</class>
24 <property stdset="1"> 24 <property stdset="1">
25 <name>name</name> 25 <name>name</name>
26 <cstring>DateBookWeekHeaderBase</cstring> 26 <cstring>DateBookWeekHeaderBase</cstring>
27 </property> 27 </property>
28 <property stdset="1"> 28 <property stdset="1">
29 <name>geometry</name> 29 <name>geometry</name>
30 <rect> 30 <rect>
31 <x>0</x> 31 <x>0</x>
32 <y>0</y> 32 <y>0</y>
33 <width>249</width> 33 <width>249</width>
34 <height>26</height> 34 <height>26</height>
35 </rect> 35 </rect>
36 </property> 36 </property>
37 <property> 37 <property>
38 <name>layoutMargin</name> 38 <name>layoutMargin</name>
39 </property> 39 </property>
40 <property> 40 <property>
41 <name>layoutSpacing</name> 41 <name>layoutSpacing</name>
42 </property> 42 </property>
43 <hbox> 43 <hbox>
44 <property stdset="1"> 44 <property stdset="1">
45 <name>margin</name> 45 <name>margin</name>
46 <number>0</number> 46 <number>0</number>
47 </property> 47 </property>
48 <property stdset="1"> 48 <property stdset="1">
49 <name>spacing</name> 49 <name>spacing</name>
50 <number>0</number> 50 <number>0</number>
51 </property> 51 </property>
52 <widget> 52 <widget>
53 <class>QToolButton</class> 53 <class>QToolButton</class>
54 <property stdset="1"> 54 <property stdset="1">
55 <name>name</name> 55 <name>name</name>
56 <cstring>backmonth</cstring> 56 <cstring>backmonth</cstring>
57 </property> 57 </property>
58 <property stdset="1"> 58 <property stdset="1">
59 <name>text</name> 59 <name>text</name>
60 <string></string> 60 <string></string>
61 </property> 61 </property>
62 <property stdset="1"> 62 <property stdset="1">
63 <name>pixmap</name> 63 <name>pixmap</name>
64 <pixmap></pixmap> 64 <pixmap></pixmap>
65 </property> 65 </property>
66 <property stdset="1"> 66 <property stdset="1">
67 <name>toggleButton</name> 67 <name>toggleButton</name>
68 <bool>false</bool> 68 <bool>false</bool>
69 </property> 69 </property>
70 <property stdset="1"> 70 <property stdset="1">
71 <name>autoRepeat</name> 71 <name>autoRepeat</name>
72 <bool>true</bool> 72 <bool>true</bool>
73 </property> 73 </property>
74 <property stdset="1"> 74 <property stdset="1">
75 <name>autoRaise</name> 75 <name>autoRaise</name>
76 <bool>true</bool> 76 <bool>true</bool>
77 </property> 77 </property>
78 <property stdset="1"> 78 <property stdset="1">
79 <name>toggleButton</name> 79 <name>toggleButton</name>
80 <bool>false</bool> 80 <bool>false</bool>
81 </property> 81 </property>
82 <property> 82 <property>
83 <name>toolTip</name> 83 <name>toolTip</name>
84 <string></string> 84 <string></string>
85 </property> 85 </property>
86 </widget> 86 </widget>
87 <widget> 87 <widget>
88 <class>QToolButton</class> 88 <class>QToolButton</class>
89 <property stdset="1"> 89 <property stdset="1">
90 <name>name</name> 90 <name>name</name>
91 <cstring>backweek</cstring> 91 <cstring>backweek</cstring>
92 </property> 92 </property>
93 <property stdset="1"> 93 <property stdset="1">
94 <name>text</name> 94 <name>text</name>
95 <string></string> 95 <string></string>
96 </property> 96 </property>
97 <property stdset="1"> 97 <property stdset="1">
98 <name>pixmap</name> 98 <name>pixmap</name>
99 <pixmap></pixmap> 99 <pixmap></pixmap>
100 </property> 100 </property>
101 <property stdset="1"> 101 <property stdset="1">
102 <name>toggleButton</name> 102 <name>toggleButton</name>
103 <bool>false</bool> 103 <bool>false</bool>
104 </property> 104 </property>
105 <property stdset="1"> 105 <property stdset="1">
106 <name>autoRepeat</name> 106 <name>autoRepeat</name>
107 <bool>true</bool> 107 <bool>true</bool>
108 </property> 108 </property>
109 <property stdset="1"> 109 <property stdset="1">
110 <name>autoRaise</name> 110 <name>autoRaise</name>
111 <bool>true</bool> 111 <bool>true</bool>
112 </property> 112 </property>
113 <property stdset="1"> 113 <property stdset="1">
114 <name>toggleButton</name> 114 <name>toggleButton</name>
115 <bool>false</bool> 115 <bool>false</bool>
116 </property> 116 </property>
117 <property> 117 <property>
118 <name>toolTip</name> 118 <name>toolTip</name>
119 <string></string> 119 <string></string>
120 </property> 120 </property>
121 </widget> 121 </widget>
122 <widget>
123 <class>QSpinBox</class>
124 <property stdset="1">
125 <name>name</name>
126 <cstring>spinYear</cstring>
127 </property>
128 <property stdset="1">
129 <name>sizePolicy</name>
130 <sizepolicy>
131 <hsizetype>0</hsizetype>
132 <vsizetype>0</vsizetype>
133 </sizepolicy>
134 </property>
135 <property stdset="1">
136 <name>prefix</name>
137 <string>Y: </string>
138 </property>
139 <property stdset="1">
140 <name>maxValue</name>
141 <number>2037</number>
142 </property>
143 <property stdset="1">
144 <name>minValue</name>
145 <number>1970</number>
146 </property>
147 <property stdset="1">
148 <name>value</name>
149 <number>2002</number>
150 </property>
151 </widget>
152 <widget>
153 <class>QSpinBox</class>
154 <property stdset="1">
155 <name>name</name>
156 <cstring>spinWeek</cstring>
157 </property>
158 <property stdset="1">
159 <name>sizePolicy</name>
160 <sizepolicy>
161 <hsizetype>0</hsizetype>
162 <vsizetype>0</vsizetype>
163 </sizepolicy>
164 </property>
165 <property stdset="1">
166 <name>prefix</name>
167 <string>W: </string>
168 </property>
169 <property stdset="1">
170 <name>maxValue</name>
171 <number>52</number>
172 </property>
173 <property stdset="1">
174 <name>minValue</name>
175 <number>1</number>
176 </property>
177 <property stdset="1">
178 <name>value</name>
179 <number>1</number>
180 </property>
181 </widget>
182 <spacer> 122 <spacer>
183 <property> 123 <property>
184 <name>name</name> 124 <name>name</name>
185 <cstring>Spacer1_1</cstring> 125 <cstring>Spacer1_1</cstring>
186 </property> 126 </property>
187 <property stdset="1"> 127 <property stdset="1">
188 <name>orientation</name> 128 <name>orientation</name>
189 <enum>Horizontal</enum> 129 <enum>Horizontal</enum>
190 </property> 130 </property>
191 <property stdset="1"> 131 <property stdset="1">
192 <name>sizeType</name> 132 <name>sizeType</name>
193 <enum>Expanding</enum> 133 <enum>Expanding</enum>
194 </property> 134 </property>
195 <property> 135 <property>
196 <name>sizeHint</name> 136 <name>sizeHint</name>
197 <size> 137 <size>
198 <width>20</width> 138 <width>20</width>
199 <height>20</height> 139 <height>20</height>
200 </size> 140 </size>
201 </property> 141 </property>
202 </spacer> 142 </spacer>
203 <widget> 143 <widget>
204 <class>QToolButton</class> 144 <class>QToolButton</class>
205 <property stdset="1"> 145 <property stdset="1">
206 <name>name</name> 146 <name>name</name>
207 <cstring>labelDate</cstring> 147 <cstring>labelDate</cstring>
208 </property> 148 </property>
209 <property stdset="1"> 149 <property stdset="1">
210 <name>sizePolicy</name> 150 <name>sizePolicy</name>
211 <sizepolicy> 151 <sizepolicy>
212 <hsizetype>3</hsizetype> 152 <hsizetype>3</hsizetype>
213 <vsizetype>1</vsizetype> 153 <vsizetype>1</vsizetype>
214 </sizepolicy> 154 </sizepolicy>
215 </property> 155 </property>
216 <property stdset="1"> 156 <property stdset="1">
217 <name>font</name> 157 <name>font</name>
218 <font> 158 <font>
219 <bold>1</bold> 159 <bold>1</bold>
220 </font> 160 </font>
221 </property> 161 </property>
222 <property stdset="1"> 162 <property stdset="1">
223 <name>text</name> 163 <name>text</name>
224 <string>00. Jan-00. Jan</string> 164 <string>00. Jan-00. Jan</string>
225 </property> 165 </property>
226 </widget> 166 </widget>
227 <spacer> 167 <spacer>
228 <property> 168 <property>
229 <name>name</name> 169 <name>name</name>
230 <cstring>Spacer1_2</cstring> 170 <cstring>Spacer1_2</cstring>
231 </property> 171 </property>
232 <property stdset="1"> 172 <property stdset="1">
233 <name>orientation</name> 173 <name>orientation</name>
234 <enum>Horizontal</enum> 174 <enum>Horizontal</enum>
235 </property> 175 </property>
236 <property stdset="1"> 176 <property stdset="1">
237 <name>sizeType</name> 177 <name>sizeType</name>
238 <enum>Expanding</enum> 178 <enum>Expanding</enum>
239 </property> 179 </property>
240 <property> 180 <property>
241 <name>sizeHint</name> 181 <name>sizeHint</name>
242 <size> 182 <size>
243 <width>20</width> 183 <width>20</width>
244 <height>20</height> 184 <height>20</height>
245 </size> 185 </size>
246 </property> 186 </property>
247 </spacer> 187 </spacer>
248 <widget> 188 <widget>
249 <class>QToolButton</class> 189 <class>QToolButton</class>
250 <property stdset="1"> 190 <property stdset="1">
251 <name>name</name> 191 <name>name</name>
252 <cstring>forwardweek</cstring> 192 <cstring>forwardweek</cstring>
253 </property> 193 </property>
254 <property stdset="1"> 194 <property stdset="1">
255 <name>text</name> 195 <name>text</name>
256 <string></string> 196 <string></string>
257 </property> 197 </property>
258 <property stdset="1"> 198 <property stdset="1">
259 <name>pixmap</name> 199 <name>pixmap</name>
260 <pixmap></pixmap> 200 <pixmap></pixmap>
261 </property> 201 </property>
262 <property stdset="1"> 202 <property stdset="1">
263 <name>autoRepeat</name> 203 <name>autoRepeat</name>
264 <bool>true</bool> 204 <bool>true</bool>
265 </property> 205 </property>
266 <property stdset="1"> 206 <property stdset="1">
267 <name>autoRaise</name> 207 <name>autoRaise</name>
268 <bool>true</bool> 208 <bool>true</bool>
269 </property> 209 </property>
270 </widget> 210 </widget>
271 <widget> 211 <widget>
272 <class>QToolButton</class> 212 <class>QToolButton</class>
273 <property stdset="1"> 213 <property stdset="1">
274 <name>name</name> 214 <name>name</name>
275 <cstring>forwardmonth</cstring> 215 <cstring>forwardmonth</cstring>
276 </property> 216 </property>
277 <property stdset="1"> 217 <property stdset="1">
278 <name>text</name> 218 <name>text</name>
279 <string></string> 219 <string></string>
280 </property> 220 </property>
281 <property stdset="1"> 221 <property stdset="1">
282 <name>pixmap</name> 222 <name>pixmap</name>
283 <pixmap></pixmap> 223 <pixmap></pixmap>
284 </property> 224 </property>
285 <property stdset="1"> 225 <property stdset="1">
286 <name>autoRepeat</name> 226 <name>autoRepeat</name>
287 <bool>true</bool> 227 <bool>true</bool>
288 </property> 228 </property>
289 <property stdset="1"> 229 <property stdset="1">
290 <name>autoRaise</name> 230 <name>autoRaise</name>
291 <bool>true</bool> 231 <bool>true</bool>
292 </property> 232 </property>
293 </widget> 233 </widget>
294 </hbox> 234 </hbox>
295</widget> 235</widget>
296<connections> 236<connections>
297 <connection> 237 <connection>
298 <sender>backmonth</sender> 238 <sender>backmonth</sender>
299 <signal>clicked()</signal> 239 <signal>clicked()</signal>
300 <receiver>DateBookWeekHeaderBase</receiver> 240 <receiver>DateBookWeekHeaderBase</receiver>
301 <slot>prevMonth()</slot> 241 <slot>prevMonth()</slot>
302 </connection> 242 </connection>
303 <connection> 243 <connection>
304 <sender>backweek</sender> 244 <sender>backweek</sender>
305 <signal>clicked()</signal> 245 <signal>clicked()</signal>
306 <receiver>DateBookWeekHeaderBase</receiver> 246 <receiver>DateBookWeekHeaderBase</receiver>
307 <slot>prevWeek()</slot> 247 <slot>prevWeek()</slot>
308 </connection> 248 </connection>
309 <connection> 249 <connection>
310 <sender>forwardweek</sender> 250 <sender>forwardweek</sender>
311 <signal>clicked()</signal> 251 <signal>clicked()</signal>
312 <receiver>DateBookWeekHeaderBase</receiver> 252 <receiver>DateBookWeekHeaderBase</receiver>
313 <slot>nextWeek()</slot> 253 <slot>nextWeek()</slot>
314 </connection> 254 </connection>
315 <connection> 255 <connection>
316 <sender>forwardmonth</sender> 256 <sender>forwardmonth</sender>
317 <signal>clicked()</signal> 257 <signal>clicked()</signal>
318 <receiver>DateBookWeekHeaderBase</receiver> 258 <receiver>DateBookWeekHeaderBase</receiver>
319 <slot>nextMonth()</slot> 259 <slot>nextMonth()</slot>
320 </connection> 260 </connection>
321 <connection> 261 <connection>
322 <sender>labelDate</sender> 262 <sender>labelDate</sender>
323 <signal>clicked()</signal> 263 <signal>clicked()</signal>
324 <receiver>DateBookWeekHeaderBase</receiver> 264 <receiver>DateBookWeekHeaderBase</receiver>
325 <slot>pickDate()</slot> 265 <slot>pickDate()</slot>
326 </connection> 266 </connection>
327 <slot access="public">yearChanged( int )</slot> 267 <slot access="public">yearChanged( int )</slot>
328 <slot access="public">nextWeek()</slot> 268 <slot access="public">nextWeek()</slot>
329 <slot access="public">prevWeek()</slot> 269 <slot access="public">prevWeek()</slot>
330 <slot access="public">weekChanged( int )</slot> 270 <slot access="public">weekChanged( int )</slot>
331 <slot access="public">nextMonth()</slot> 271 <slot access="public">nextMonth()</slot>
332 <slot access="public">prevMonth()</slot> 272 <slot access="public">prevMonth()</slot>
333 <slot access="public">pickDate()</slot> 273 <slot access="public">pickDate()</slot>
334</connections> 274</connections>
335</UI> 275</UI>
diff --git a/core/pim/datebook/datebookweekheaderimpl.cpp b/core/pim/datebook/datebookweekheaderimpl.cpp
index 5f555d5..fd792e2 100644
--- a/core/pim/datebook/datebookweekheaderimpl.cpp
+++ b/core/pim/datebook/datebookweekheaderimpl.cpp
@@ -1,180 +1,139 @@
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 "datebookweekheaderimpl.h" 20#include "datebookweekheaderimpl.h"
21#include "datebookweekheader.h" 21#include "datebookweekheader.h"
22#include "datebookweek.h" 22#include "datebookweek.h"
23#include <qlabel.h> 23#include <qlabel.h>
24#include <qspinbox.h> 24#include <qspinbox.h>
25#include <qdatetime.h> 25#include <qdatetime.h>
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27#include <qpe/datebookmonth.h> 27#include <qpe/datebookmonth.h>
28 28
29#include <qtoolbutton.h> 29#include <qtoolbutton.h>
30 30
31/* 31/*
32 * Constructs a DateBookWeekHeader which is a child of 'parent', with the 32 * Constructs a DateBookWeekHeader which is a child of 'parent', with the
33 * name 'name' and widget flags set to 'f' 33 * name 'name' and widget flags set to 'f'
34 */ 34 */
35DateBookWeekHeader::DateBookWeekHeader( bool startOnMonday, QWidget* parent, 35DateBookWeekHeader::DateBookWeekHeader( bool startOnMonday, QWidget* parent, const char* name, WFlags fl )
36 const char* name, WFlags fl )
37 : DateBookWeekHeaderBase( parent, name, fl ), 36 : DateBookWeekHeaderBase( parent, name, fl ),
38 bStartOnMonday( startOnMonday ) 37 bStartOnMonday( startOnMonday )
39{ 38{
40 setBackgroundMode( PaletteButton ); 39 setBackgroundMode( PaletteButton );
41 labelDate->setBackgroundMode( PaletteButton ); 40 labelDate->setBackgroundMode( PaletteButton );
42 41 backmonth->setPixmap( Resource::loadPixmap("fastback") );
43 backmonth->setPixmap( Resource::loadPixmap("fastback") ); 42 backweek->setPixmap( Resource::loadPixmap("back") );
44 backweek->setPixmap( Resource::loadPixmap("back") ); 43 forwardweek->setPixmap( Resource::loadPixmap("forward") );
45 forwardweek->setPixmap( Resource::loadPixmap("forward") ); 44 forwardmonth->setPixmap( Resource::loadPixmap("fastforward") );
46 forwardmonth->setPixmap( Resource::loadPixmap("fastforward") );
47 spinYear->hide();
48 spinWeek->hide();
49} 45}
50 46
51/* 47/*
52 * Destroys the object and frees any allocated resources 48 * Destroys the object and frees any allocated resources
53 */ 49 */
54DateBookWeekHeader::~DateBookWeekHeader() 50DateBookWeekHeader::~DateBookWeekHeader()
55{ 51{
56 // no need to delete child widgets, Qt does it all for us 52 // no need to delete child widgets, Qt does it all for us
57} 53}
58 54
59void DateBookWeekHeader::pickDate() 55void DateBookWeekHeader::pickDate()
60{ 56{
61 static QPopupMenu *m1 = 0; 57 static QPopupMenu *m1 = 0;
62 static DateBookMonth *picker = 0; 58 static DateBookMonth *picker = 0;
63 QDate currDate = dateFromWeek( week, year, bStartOnMonday );
64 if ( !m1 ) { 59 if ( !m1 ) {
65 m1 = new QPopupMenu( this ); 60 m1 = new QPopupMenu( this );
66 picker = new DateBookMonth( m1, 0, TRUE ); 61 picker = new DateBookMonth( m1, 0, TRUE );
67 m1->insertItem( picker ); 62 m1->insertItem( picker );
68 connect( picker, SIGNAL( dateClicked( int, int, int ) ), 63 connect( picker, SIGNAL( dateClicked( int, int, int ) ), this, SLOT( setDate( int, int, int ) ) );
69 this, SLOT( setDate( int, int, int ) ) ); 64 // connect( m1, SIGNAL( aboutToHide() ), this, SLOT( gotHide() ) );
70 // connect( m1, SIGNAL( aboutToHide() ),
71 // this, SLOT( gotHide() ) );
72 } 65 }
73 picker->setDate( currDate.year(), currDate.month(), currDate.day() ); 66 picker->setDate( date.year(), date.month(), date.day() );
74 m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); 67 m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height())));
75 picker->setFocus(); 68 picker->setFocus();
76} 69}
77/* 70
78 * public slot
79 */
80void DateBookWeekHeader::yearChanged( int y )
81{
82 setDate( y, week );
83}
84void DateBookWeekHeader::nextMonth() 71void DateBookWeekHeader::nextMonth()
85{ 72{
86 QDate mydate = dateFromWeek( week, year, bStartOnMonday ); // Get current week 73 setDate(date.addDays(28));
87 calcWeek( mydate.addDays(28), week, year, bStartOnMonday ); // Add 4 weeks.
88 setDate( year, week ); // update view
89} 74}
90void DateBookWeekHeader::prevMonth() 75void DateBookWeekHeader::prevMonth()
91{ 76{
92 QDate mydate = dateFromWeek( week, year, bStartOnMonday ); // Get current week 77 setDate(date.addDays(-28));
93 calcWeek( mydate.addDays(-28), week, year, bStartOnMonday ); // Subtract 4 weeks
94 setDate( year, week ); // update view
95} 78}
96/*
97 * public slot
98 */
99void DateBookWeekHeader::nextWeek() 79void DateBookWeekHeader::nextWeek()
100{ 80{
101 QDate mydate = dateFromWeek( week, year, bStartOnMonday ); // Get current week 81 setDate(date.addDays(7));
102 calcWeek( mydate.addDays(7), week, year, bStartOnMonday); // Add 1 week
103// if ( week < 52 )
104 //week++;
105 setDate( year, week );
106} 82}
107/*
108 * public slot
109 */
110void DateBookWeekHeader::prevWeek() 83void DateBookWeekHeader::prevWeek()
111{ 84{
112 QDate mydate = dateFromWeek( week, year, bStartOnMonday ); // Get current week 85 setDate(date.addDays(-7));
113 calcWeek( mydate.addDays(-7), week, year, bStartOnMonday); // Add 1 week
114// if ( week > 1 )
115 //week--;
116 setDate( year, week );
117}
118/*
119 * public slot
120 */
121void DateBookWeekHeader::weekChanged( int w )
122{
123 setDate( year, w );
124} 86}
125 87
126void DateBookWeekHeader::setDate( int y, int m, int d ) 88void DateBookWeekHeader::setDate( int y, int m, int d )
127{ 89{
128 calcWeek( QDate(y,m,d), week, year, bStartOnMonday ); 90 setDate(QDate(y,m,d));
129 setDate( year, week );
130} 91}
131 92
132void DateBookWeekHeader::setDate( int y, int w ) 93void DateBookWeekHeader::setDate(const QDate &d) {
133{ 94 int year,week,dayofweek;
134 year = y; 95 date=d;
135 week = w; 96 dayofweek=d.dayOfWeek();
136 spinYear->setValue( y ); 97 if(bStartOnMonday) dayofweek--;
137 spinWeek->setValue( w ); 98 date=date.addDays(-dayofweek);
138
139 QDate d = dateFromWeek( week, year, bStartOnMonday );
140
141 QString s = QString::number( d.day() ) + ". " + d.monthName( d.month() )
142 + "-";
143 d = d.addDays( 6 );
144 s += QString::number( d.day() ) + ". " + d.monthName( d.month() );
145 s += " ("+tr("week")+":"+QString::number( w )+")";
146 labelDate->setText( s );
147 99
148 emit dateChanged( y, w ); 100 calcWeek(date,week,year,bStartOnMonday);
101 QDate start=date;
102 QDate stop=start.addDays(6);
103 labelDate->setText( QString::number(start.day()) + "." +
104 start.monthName(start.month()) + "-" +
105 QString::number(stop.day()) + "." +
106 start.monthName(stop.month()) +" ("+
107 tr("w")+":"+QString::number( week ) +")");
108 emit dateChanged(year,week);
149} 109}
150 110
151void DateBookWeekHeader::setStartOfWeek( bool onMonday ) 111void DateBookWeekHeader::setStartOfWeek( bool onMonday )
152{ 112{
153 bStartOnMonday = onMonday; 113 bStartOnMonday = onMonday;
154 setDate( year, week ); 114 setDate( date );
155} 115}
156 116
157// dateFromWeek 117// dateFromWeek
158// compute the date from the week in the year 118// compute the date from the week in the year
159
160QDate dateFromWeek( int week, int year, bool startOnMonday ) 119QDate dateFromWeek( int week, int year, bool startOnMonday )
161{ 120{
162 QDate d; 121 QDate d;
163 d.setYMD( year, 1, 1 ); 122 d.setYMD( year, 1, 1 );
164 int dayOfWeek = d.dayOfWeek(); 123 int dayOfWeek = d.dayOfWeek();
165 if ( startOnMonday ) { 124 if ( startOnMonday ) {
166 if ( dayOfWeek <= 4 ) { 125 if ( dayOfWeek <= 4 ) {
167 d = d.addDays( ( week - 1 ) * 7 - dayOfWeek + 1 ); 126 d = d.addDays( ( week - 1 ) * 7 - dayOfWeek + 1 );
168 } else { 127 } else {
169 d = d.addDays( (week) * 7 - dayOfWeek + 1 ); 128 d = d.addDays( (week) * 7 - dayOfWeek + 1 );
170 } 129 }
171 } else {
172 if ( dayOfWeek <= 4 || dayOfWeek == 7) {
173 d = d.addDays( ( week - 1 ) * 7 - dayOfWeek % 7 );
174 } else { 130 } else {
175 d = d.addDays( ( week ) * 7 - dayOfWeek % 7 ); 131 if ( dayOfWeek <= 4 || dayOfWeek == 7) {
132 d = d.addDays( ( week - 1 ) * 7 - dayOfWeek % 7 );
133 } else {
134 d = d.addDays( ( week ) * 7 - dayOfWeek % 7 );
135 }
176 } 136 }
177 } 137 return d;
178 return d;
179} 138}
180 139
diff --git a/core/pim/datebook/datebookweekheaderimpl.h b/core/pim/datebook/datebookweekheaderimpl.h
index 2e5a6ca..1ab1d52 100644
--- a/core/pim/datebook/datebookweekheaderimpl.h
+++ b/core/pim/datebook/datebookweekheaderimpl.h
@@ -1,66 +1,59 @@
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 DATEBOOKDAYHEADER_H 20#ifndef DATEBOOKDAYHEADER_H
21#define DATEBOOKDAYHEADER_H 21#define DATEBOOKDAYHEADER_H
22#include <qdatetime.h> 22#include <qdatetime.h>
23#include "datebookweekheader.h" 23#include "datebookweekheader.h"
24 24
25 25
26class DateBookWeekHeader : public DateBookWeekHeaderBase 26class DateBookWeekHeader : public DateBookWeekHeaderBase
27{ 27{
28 Q_OBJECT 28 Q_OBJECT
29 29
30public: 30public:
31 DateBookWeekHeader( bool startOnMonday, QWidget* parent = 0, 31 DateBookWeekHeader( bool startOnMonday, QWidget* parent = 0,
32 const char* name = 0, WFlags fl = 0 ); 32 const char* name = 0, WFlags fl = 0 );
33 ~DateBookWeekHeader(); 33 ~DateBookWeekHeader();
34 34
35 void setDate( int y, int w ); 35 void setDate(const QDate &d);
36 void setStartOfWeek( bool onMonday ); 36 void setStartOfWeek( bool onMonday );
37 37
38signals: 38signals:
39 void dateChanged( int y, int w ); 39 void dateChanged( int y, int w );
40 40
41public slots: 41public slots:
42 void pickDate(); 42 void pickDate();
43 void yearChanged( int );
44 void nextMonth(); 43 void nextMonth();
45 void prevMonth(); 44 void prevMonth();
46 void nextWeek(); 45 void nextWeek();
47 void prevWeek(); 46 void prevWeek();
48 void weekChanged( int );
49 void setDate( int y, int m, int d); 47 void setDate( int y, int m, int d);
50 48
51protected slots: 49protected slots:
52 void keyPressEvent(QKeyEvent *e) 50 void keyPressEvent(QKeyEvent *e) { e->ignore(); }
53 {
54 e->ignore();
55 }
56 51
57private: 52private:
58 int year, 53 QDate date;
59 week; 54 bool bStartOnMonday;
60 bool bStartOnMonday;
61
62}; 55};
63 56
64QDate dateFromWeek( int week, int year, bool startOnMonday ); 57QDate dateFromWeek( int week, int year, bool startOnMonday );
65 58
66#endif // DATEBOOKDAYHEADER_H 59#endif // DATEBOOKDAYHEADER_H
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp
index 3c8fc89..a39ff40 100644
--- a/core/pim/datebook/datebookweeklst.cpp
+++ b/core/pim/datebook/datebookweeklst.cpp
@@ -1,390 +1,398 @@
1#include "datebookweeklst.h" 1#include "datebookweeklst.h"
2 2
3#include "datebookweekheaderimpl.h" 3#include "datebookweekheaderimpl.h"
4 4
5#include "datebook.h" 5#include "datebook.h"
6 6
7#include <qpe/calendar.h> 7#include <qpe/calendar.h>
8#include <qpe/datebookdb.h> 8#include <qpe/datebookdb.h>
9#include <qpe/event.h> 9#include <qpe/event.h>
10#include <qpe/qpeapplication.h> 10#include <qpe/qpeapplication.h>
11#include <qpe/timestring.h> 11#include <qpe/timestring.h>
12#include <qpe/datebookmonth.h> 12#include <qpe/datebookmonth.h>
13#include <qpe/config.h> 13#include <qpe/config.h>
14#include <qpe/resource.h> 14#include <qpe/resource.h>
15 15
16#include <qdatetime.h> 16#include <qdatetime.h>
17#include <qheader.h> 17#include <qheader.h>
18#include <qlabel.h> 18#include <qlabel.h>
19#include <qlayout.h> 19#include <qlayout.h>
20#include <qpainter.h> 20#include <qpainter.h>
21#include <qpopupmenu.h> 21#include <qpopupmenu.h>
22#include <qtimer.h> 22#include <qtimer.h>
23#include <qstyle.h> 23#include <qstyle.h>
24#include <qtoolbutton.h> 24#include <qtoolbutton.h>
25#include <qvbox.h> 25#include <qvbox.h>
26#include <qsizepolicy.h> 26#include <qsizepolicy.h>
27#include <qabstractlayout.h> 27#include <qabstractlayout.h>
28#include <qtl.h> 28#include <qtl.h>
29 29
30bool calcWeek(const QDate &d, int &week, int &year, 30bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false);
31 bool startOnMonday = false);
32 31
33DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, 32DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const char* name, WFlags fl)
34 const char* name, WFlags fl)
35 : DateBookWeekLstHeaderBase(parent, name, fl) 33 : DateBookWeekLstHeaderBase(parent, name, fl)
36{ 34{
37 setBackgroundMode( PaletteButton ); 35 setBackgroundMode( PaletteButton );
38 labelDate->setBackgroundMode( PaletteButton ); 36 labelDate->setBackgroundMode( PaletteButton );
39 labelWeek->setBackgroundMode( PaletteButton ); 37 forwardweek->setBackgroundMode( PaletteButton );
40 forward->setBackgroundMode( PaletteButton ); 38 forwardweek->setPixmap( Resource::loadPixmap("forward") );
41 forward->setPixmap( Resource::loadPixmap("forward") ); 39 forwardmonth->setBackgroundMode( PaletteButton );
42 back->setBackgroundMode( PaletteButton ); 40 forwardmonth->setPixmap( Resource::loadPixmap("fastforward") );
43 back->setPixmap( Resource::loadPixmap("back") ); 41 backweek->setBackgroundMode( PaletteButton );
44 DateBookWeekLstHeaderBaseLayout->setSpacing(0); 42 backweek->setPixmap( Resource::loadPixmap("back") );
45 DateBookWeekLstHeaderBaseLayout->setMargin(0); 43 backmonth->setBackgroundMode( PaletteButton );
46 //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding)); 44 backmonth->setPixmap( Resource::loadPixmap("fastback") );
47 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); 45 DateBookWeekLstHeaderBaseLayout->setSpacing(0);
48 46 DateBookWeekLstHeaderBaseLayout->setMargin(0);
49 connect(back, SIGNAL(clicked()), this, SLOT(prevWeek())); 47 //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding));
50 connect(forward, SIGNAL(clicked()), this, SLOT(nextWeek())); 48 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
51 connect(labelWeek, SIGNAL(clicked()), this, SLOT(pickDate())); 49
52 connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool))); 50 connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth()));
53 onMonday=onM; 51 connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek()));
52 connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek()));
53 connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth()));
54 connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate()));
55 connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool)));
56 bStartOnMonday=onM;
54} 57}
55DateBookWeekLstHeader::~DateBookWeekLstHeader(){} 58DateBookWeekLstHeader::~DateBookWeekLstHeader(){}
59
56void DateBookWeekLstHeader::setDate(const QDate &d) { 60void DateBookWeekLstHeader::setDate(const QDate &d) {
57 date=d; 61 int year,week,dayofweek;
58 62 date=d;
59 int year,week; 63 dayofweek=d.dayOfWeek();
60 calcWeek(d,week,year,onMonday); 64 if(bStartOnMonday) dayofweek--;
61 labelWeek->setText(tr( "W: %1" ).arg( ( QString::number(week)) ) ); 65 date=date.addDays(-dayofweek);
62 66
63 QDate start=date; 67 calcWeek(date,week,year,bStartOnMonday);
64 QDate stop=start.addDays(6); 68 QDate start=date;
65 labelDate->setText( QString::number(start.day()) + " " + 69 QDate stop=start.addDays(6);
66 start.monthName(start.month()) + " - " + 70 labelDate->setText( QString::number(start.day()) + "." +
67 QString::number(stop.day()) + " " + 71 start.monthName(start.month()) + "-" +
68 start.monthName(stop.month()) ); 72 QString::number(stop.day()) + "." +
69 emit dateChanged(year,week); 73 start.monthName(stop.month()) +" ("+
74 tr("w")+":"+QString::number( week ) +")");
75 emit dateChanged(year,week);
70} 76}
77
71void DateBookWeekLstHeader::pickDate() { 78void DateBookWeekLstHeader::pickDate() {
72 static QPopupMenu *m1 = 0; 79 static QPopupMenu *m1 = 0;
73 static DateBookMonth *picker = 0; 80 static DateBookMonth *picker = 0;
74 if ( !m1 ) { 81 if ( !m1 ) {
75 m1 = new QPopupMenu( this ); 82 m1 = new QPopupMenu( this );
76 picker = new DateBookMonth( m1, 0, TRUE ); 83 picker = new DateBookMonth( m1, 0, TRUE );
77 m1->insertItem( picker ); 84 m1->insertItem( picker );
78 connect( picker, SIGNAL( dateClicked( int, int, int ) ), 85 connect( picker, SIGNAL( dateClicked( int, int, int ) ),this, SLOT( setDate( int, int, int ) ) );
79 this, SLOT( setDate( int, int, int ) ) ); 86 //connect( m1, SIGNAL( aboutToHide() ),
80 //connect( m1, SIGNAL( aboutToHide() ), 87 //this, SLOT( gotHide() ) );
81 //this, SLOT( gotHide() ) ); 88 }
82 } 89 picker->setDate( date.year(), date.month(), date.day() );
83 picker->setDate( date.year(), date.month(), date.day() ); 90 m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height())));
84 m1->popup(mapToGlobal(labelWeek->pos()+QPoint(0,labelWeek->height()))); 91 picker->setFocus();
85 picker->setFocus();
86} 92}
87void DateBookWeekLstHeader::setDate(int y, int m, int d) { 93void DateBookWeekLstHeader::setDate(int y, int m, int d) {
88 QDate new_date(y,m,d); 94 setDate(QDate(y,m,d));
89 setDate(new_date);
90} 95}
91 96
92void DateBookWeekLstHeader::nextWeek() { 97void DateBookWeekLstHeader::nextWeek() {
93 setDate(date.addDays(7)); 98 setDate(date.addDays(7));
94} 99}
95void DateBookWeekLstHeader::prevWeek() { 100void DateBookWeekLstHeader::prevWeek() {
96 setDate(date.addDays(-7)); 101 setDate(date.addDays(-7));
102}
103void DateBookWeekLstHeader::nextMonth()
104{
105 setDate(date.addDays(28));
106}
107void DateBookWeekLstHeader::prevMonth()
108{
109 setDate(date.addDays(-28));
97} 110}
98 111
99DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /*onM*/, 112DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /*onM*/,
100 QWidget* parent, 113 QWidget* parent,
101 const char* name, 114 const char* name,
102 WFlags fl ) 115 WFlags fl )
103 : DateBookWeekLstDayHdrBase(parent, name, fl) { 116 : DateBookWeekLstDayHdrBase(parent, name, fl) {
104 117
105 date=d; 118 date=d;
106 119
107 static const char *wdays={"MTWTFSS"}; 120 static const char *wdays={"MTWTFSS"};
108 char day=wdays[d.dayOfWeek()-1]; 121 char day=wdays[d.dayOfWeek()-1];
109 122
110 label->setText( QString(QObject::tr(QString(QChar(day)))) + " " + 123 label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) );
111 QString::number(d.day()) ); 124 add->setText("+");
112 add->setText("+"); 125
113 126 if (d == QDate::currentDate()) {
114 if (d == QDate::currentDate()) { 127 QPalette pal=label->palette();
115 QPalette pal=label->palette(); 128 pal.setColor(QColorGroup::Foreground, QColor(0,0,255));
116 pal.setColor(QColorGroup::Foreground, QColor(0,0,255)); 129 label->setPalette(pal);
117 label->setPalette(pal); 130
118 131 /*
119 /* 132 QFont f=label->font();
120 QFont f=label->font(); 133 f.setItalic(true);
121 f.setItalic(true); 134 label->setFont(f);
122 label->setFont(f); 135 label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor()));
123 label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor())); 136 */
124 */ 137 } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday
125 } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday 138 QPalette pal=label->palette();
126 QPalette pal=label->palette(); 139 pal.setColor(QColorGroup::Foreground, QColor(255,0,0));
127 pal.setColor(QColorGroup::Foreground, QColor(255,0,0)); 140 label->setPalette(pal);
128 label->setPalette(pal); 141 }
129 }
130
131 142
132 connect (label, SIGNAL(clicked()), this, SLOT(showDay())); 143 connect (label, SIGNAL(clicked()), this, SLOT(showDay()));
133 connect (add, SIGNAL(clicked()), this, SLOT(newEvent())); 144 connect (add, SIGNAL(clicked()), this, SLOT(newEvent()));
134} 145}
135 146
136void DateBookWeekLstDayHdr::showDay() { 147void DateBookWeekLstDayHdr::showDay() {
137 emit showDate(date.year(), date.month(), date.day()); 148 emit showDate(date.year(), date.month(), date.day());
138} 149}
150
139void DateBookWeekLstDayHdr::newEvent() { 151void DateBookWeekLstDayHdr::newEvent() {
140 QDateTime start, stop; 152 QDateTime start, stop;
141 start=stop=date; 153 start=stop=date;
142 start.setTime(QTime(10,0)); 154 start.setTime(QTime(10,0));
143 stop.setTime(QTime(12,0)); 155 stop.setTime(QTime(12,0));
144 156
145 emit addEvent(start,stop,"",0); 157 emit addEvent(start,stop,"",0);
146} 158}
147DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, 159DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev,
148 int weeklistviewconfig, 160 int weeklistviewconfig,
149 QWidget* parent, 161 QWidget* parent,
150 const char* name, 162 const char* name,
151 WFlags fl ) : OClickableLabel(parent,name,fl), event(ev) 163 WFlags fl ) : OClickableLabel(parent,name,fl), event(ev)
152{ 164{
153 // old values... lastday = "__|__", middle=" |---", Firstday="00:00", 165 // old values... lastday = "__|__", middle=" |---", Firstday="00:00",
154 QString s,start,middle,end,day; 166 QString s,start,middle,end,day;
155 167
156 qDebug("weeklistviewconfig=%d",weeklistviewconfig); 168 qDebug("weeklistviewconfig=%d",weeklistviewconfig);
157 if(weeklistviewconfig==NONE) {// No times displayed. 169 if(weeklistviewconfig==NONE) {// No times displayed.
158 // start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); 170 // start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute());
159 // middle.sprintf("<--->"); 171 // middle.sprintf("<--->");
160 // end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); 172 // end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute());
161 // day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); 173 // day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute());
162 } else if(weeklistviewconfig==NORMAL) {// "Normal", only display start time. 174 } else if(weeklistviewconfig==NORMAL) {// "Normal", only display start time.
163 start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); 175 start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute());
164 middle.sprintf(" |---"); 176 middle.sprintf(" |---");
165 end.sprintf("__|__"); 177 end.sprintf("__|__");
166 day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); 178 day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute());
167 } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times. 179 } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times.
168 start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); 180 start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute());
169 middle.sprintf("<--->"); 181 middle.sprintf("<--->");
170 end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); 182 end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute());
171 day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); 183 day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute());
172 } 184 }
173 185
174 if(ev.event().type() == Event::Normal) { 186 if(ev.event().type() == Event::Normal) {
175 if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) {// day event. 187 if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) {// day event.
176 s=day; 188 s=day;
177 } else if(ev.startDate()==ev.date()) {// start event. 189 } else if(ev.startDate()==ev.date()) {// start event.
178 s=start; 190 s=start;
179 } else if(ev.endDate()==ev.date()) { // end event. 191 } else if(ev.endDate()==ev.date()) { // end event.
180 s=end; 192 s=end;
181 } else {// middle day. 193 } else {// middle day.
182 s=middle; 194 s=middle;
183 } 195 }
184 } else { 196 } else {
185 s=""; 197 s="";
186 } 198 }
187 setText(QString(s) + " " + ev.description()); 199 setText(QString(s) + " " + ev.description());
188 connect(this, SIGNAL(clicked()), this, SLOT(editMe())); 200 connect(this, SIGNAL(clicked()), this, SLOT(editMe()));
189 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); 201 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) );
190} 202}
191void DateBookWeekLstEvent::editMe() { 203void DateBookWeekLstEvent::editMe() {
192 emit editEvent(event.event()); 204 emit editEvent(event.event());
193} 205}
194 206
195 207
196DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, 208DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
197 const QDate &d, bool onM, 209 const QDate &d, bool onM,
198 QWidget* parent, 210 QWidget* parent,
199 const char* name, WFlags fl) 211 const char* name, WFlags fl)
200 : QWidget( parent, name, fl ) 212 : QWidget( parent, name, fl )
201{ 213{
202 Config config("DateBook"); 214 Config config("DateBook");
203 config.setGroup("Main"); 215 config.setGroup("Main");
204 int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL); 216 int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL);
205 qDebug("Read weeklistviewconfig: %d",weeklistviewconfig); 217 qDebug("Read weeklistviewconfig: %d",weeklistviewconfig);
206 218
207 onMonday=onM; 219 bStartOnMonday=onM;
208 setPalette(white); 220 setPalette(white);
209 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); 221 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
210 222
211 QVBoxLayout *layout = new QVBoxLayout( this ); 223 QVBoxLayout *layout = new QVBoxLayout( this );
212 224
213 qBubbleSort(ev); 225 qBubbleSort(ev);
214 QValueListIterator<EffectiveEvent> it; 226 QValueListIterator<EffectiveEvent> it;
215 it=ev.begin(); 227 it=ev.begin();
216 228
217 int dayOrder[7]; 229 int dayOrder[7];
218 if (onMonday) { 230 if (bStartOnMonday) {
219 for (int d=0; d<7; d++) dayOrder[d]=d+1; 231 for (int d=0; d<7; d++) dayOrder[d]=d+1;
220 } else { 232 } else {
221 for (int d=0; d<7; d++) dayOrder[d]=d; 233 for (int d=0; d<7; d++) dayOrder[d]=d;
222 dayOrder[0]=7; 234 dayOrder[0]=7;
223 } 235 }
224 236
225 for (int i=0; i<7; i++) { 237 for (int i=0; i<7; i++) {
226 // Header 238 // Header
227 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i), onMonday,this); 239 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i), bStartOnMonday,this);
228 connect(hdr, SIGNAL(showDate(int,int,int)), 240 connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
229 this, SIGNAL(showDate(int,int,int)));
230 connect(hdr, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), 241 connect(hdr, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)),
231 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); 242 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)));
232 layout->addWidget(hdr); 243 layout->addWidget(hdr);
233 244
234 // Events 245 // Events
235 while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { 246 while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) {
236 if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) {// Skip events ending at 00:00 starting at another day. 247 if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) {// Skip events ending at 00:00 starting at another day.
237 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this); 248 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this);
238 layout->addWidget(l); 249 layout->addWidget(l);
239 connect (l, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); 250 connect (l, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &)));
240 } 251 }
241 it++; 252 it++;
242 } 253 }
243 254
244 layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); 255 layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding));
245 } 256 }
246} 257}
247DateBookWeekLstView::~DateBookWeekLstView(){} 258DateBookWeekLstView::~DateBookWeekLstView(){}
248void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} 259void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();}
249 260
250DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, 261DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
251 QValueList<EffectiveEvent> &ev2, 262 QValueList<EffectiveEvent> &ev2,
252 QDate &d, bool onM, 263 QDate &d, bool onM,
253 QWidget* parent, 264 QWidget* parent,
254 const char* name, WFlags fl) 265 const char* name, WFlags fl)
255 : QWidget( parent, name, fl ) 266 : QWidget( parent, name, fl )
256{ 267{
257 QHBoxLayout *layout = new QHBoxLayout( this ); 268 QHBoxLayout *layout = new QHBoxLayout( this );
258 269
259 DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); 270 DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this);
260 layout->addWidget(w); 271 layout->addWidget(w);
261 connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); 272 connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &)));
262 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 273 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
263 connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &,const QString &)), 274 connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &,const QString &)),
264 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); 275 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)));
265 276
266 277
267 w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); 278 w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this);
268 layout->addWidget(w); 279 layout->addWidget(w);
269 connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); 280 connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &)));
270 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 281 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
271 connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), 282 connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)),
272 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); 283 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)));
273} 284}
274 285
275DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, 286DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB,
276 QWidget *parent, 287 QWidget *parent,
277 const char *name ) 288 const char *name )
278 : QWidget( parent, name ), 289 : QWidget( parent, name ),
279 db( newDB ), 290 db( newDB ),
280 startTime( 0 ), 291 startTime( 0 ),
281 ampm( ap ), 292 ampm( ap ),
282 onMonday(onM) 293 bStartOnMonday(onM)
283{ 294{
284 setFocusPolicy(StrongFocus); 295 setFocusPolicy(StrongFocus);
285 layout = new QVBoxLayout( this ); 296 layout = new QVBoxLayout( this );
286 layout->setMargin(0); 297 layout->setMargin(0);
287 298
288 header=new DateBookWeekLstHeader(onM, this); 299 header=new DateBookWeekLstHeader(onM, this);
289 layout->addWidget( header ); 300 layout->addWidget( header );
290 connect(header, SIGNAL(dateChanged(int,int)), this, SLOT(dateChanged(int,int))); 301 connect(header, SIGNAL(dateChanged(int,int)), this, SLOT(dateChanged(int,int)));
291 connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool))); 302 connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool)));
292 303
293 scroll=new QScrollView(this); 304 scroll=new QScrollView(this);
294 //scroll->setVScrollBarMode(QScrollView::AlwaysOn);
295 //scroll->setHScrollBarMode(QScrollView::AlwaysOff);
296 scroll->setResizePolicy(QScrollView::AutoOneFit); 305 scroll->setResizePolicy(QScrollView::AutoOneFit);
297 layout->addWidget(scroll); 306 layout->addWidget(scroll);
298 307
299 view=NULL; 308 view=NULL;
300 Config config("DateBook"); 309 Config config("DateBook");
301 config.setGroup("Main"); 310 config.setGroup("Main");
302 dbl=config.readBoolEntry("weeklst_dbl", false); 311 dbl=config.readBoolEntry("weeklst_dbl", false);
303 header->dbl->setOn(dbl); 312 header->dbl->setOn(dbl);
304} 313}
305DateBookWeekLst::~DateBookWeekLst(){ 314DateBookWeekLst::~DateBookWeekLst(){
306 Config config("DateBook"); 315 Config config("DateBook");
307 config.setGroup("Main"); 316 config.setGroup("Main");
308 config.writeEntry("weeklst_dbl", dbl); 317 config.writeEntry("weeklst_dbl", dbl);
309} 318}
310 319
311void DateBookWeekLst::setDate(const QDate &d) { 320void DateBookWeekLst::setDate(const QDate &d) {
312 int w,y; 321 int w,y;
313 calcWeek(d,w,y,onMonday); 322 calcWeek(d,w,y,bStartOnMonday);
314 year=y; 323 year=y;
315 _week=w; 324 _week=w;
316 header->setDate(date()); 325 header->setDate(date());
317} 326}
318void DateBookWeekLst::setDbl(bool on) { 327void DateBookWeekLst::setDbl(bool on) {
319 dbl=on; 328 dbl=on;
320 redraw(); 329 redraw();
321} 330}
322void DateBookWeekLst::redraw() {getEvents();} 331void DateBookWeekLst::redraw() {getEvents();}
323 332
324QDate DateBookWeekLst::date() const { 333QDate DateBookWeekLst::date() const {
325 QDate d; 334 QDate d;
326 d.setYMD(year,1,1); 335 d.setYMD(year,1,1);
327 336
328 int dow= d.dayOfWeek(); 337 int dow= d.dayOfWeek();
329 if (!onMonday) 338 if (!bStartOnMonday)
330 if (dow==7) { 339 if (dow==7) {
331 dow=1; 340 dow=1;
332 } else { 341 } else {
333 dow++; 342 dow++;
334 } 343 }
335 344
336 d=d.addDays( (_week-1)*7 - dow + 1 ); 345 d=d.addDays( (_week-1)*7 - dow + 1 );
337 return d; 346 return d;
338} 347}
339 348
340void DateBookWeekLst::getEvents() { 349void DateBookWeekLst::getEvents() {
341 QDate start = date(); 350 QDate start = date();
342 QDate stop = start.addDays(6); 351 QDate stop = start.addDays(6);
343 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); 352 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop);
344 353
345 if (view) delete view; 354 if (view) delete view;
346 if (dbl) { 355 if (dbl) {
347 QDate start2=start.addDays(7); 356 QDate start2=start.addDays(7);
348 stop=start2.addDays(6); 357 stop=start2.addDays(6);
349 QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); 358 QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop);
350 view=new DateBookWeekLstDblView(el,el2,start,onMonday,scroll); 359 view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll);
351 } else { 360 } else {
352 view=new DateBookWeekLstView(el,start,onMonday,scroll); 361 view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll);
353 } 362 }
354 363
355 connect (view, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); 364 connect (view, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &)));
356 connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 365 connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
357 connect (view, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), 366 connect (view, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)),
358 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); 367 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)));
359 368
360 scroll->addChild(view); 369 scroll->addChild(view);
361 view->show(); 370 view->show();
362 scroll->updateScrollBars(); 371 scroll->updateScrollBars();
363} 372}
364 373
365void DateBookWeekLst::dateChanged(int y, int w) { 374void DateBookWeekLst::dateChanged(int y, int w) {
366 year=y; 375 year=y;
367 _week=w; 376 _week=w;
368 getEvents(); 377 getEvents();
369} 378}
370 379
371void DateBookWeekLst::keyPressEvent(QKeyEvent *e) 380void DateBookWeekLst::keyPressEvent(QKeyEvent *e)
372{ 381{
373 switch(e->key()) { 382 switch(e->key()) {
374 case Key_Up: 383 case Key_Up:
375 scroll->scrollBy(0, -20); 384 scroll->scrollBy(0, -20);
376 break; 385 break;
377 case Key_Down: 386 case Key_Down:
378 scroll->scrollBy(0, 20); 387 scroll->scrollBy(0, 20);
379 break; 388 break;
380 case Key_Left: 389 case Key_Left:
381 header->prevWeek(); 390 header->prevWeek();
382 break; 391 break;
383 case Key_Right: 392 case Key_Right:
384 header->nextWeek(); 393 header->nextWeek();
385 break; 394 break;
386 default: 395 default:
387 e->ignore(); 396 e->ignore();
388 } 397 }
389} 398} \ No newline at end of file
390
diff --git a/core/pim/datebook/datebookweeklst.h b/core/pim/datebook/datebookweeklst.h
index 17dc01f..f858c4f 100644
--- a/core/pim/datebook/datebookweeklst.h
+++ b/core/pim/datebook/datebookweeklst.h
@@ -1,151 +1,154 @@
1#ifndef DATEBOOKWEEKLST 1#ifndef DATEBOOKWEEKLST
2#define DATEBOOKWEEKLST 2#define DATEBOOKWEEKLST
3 3
4#include <qwidget.h> 4#include <qwidget.h>
5#include <qdatetime.h> 5#include <qdatetime.h>
6#include <qpe/event.h> 6#include <qpe/event.h>
7#include <qlabel.h> 7#include <qlabel.h>
8#include <qscrollview.h> 8#include <qscrollview.h>
9 9
10#include "datebookweeklstheader.h" 10#include "datebookweeklstheader.h"
11#include "datebookweeklstdayhdr.h" 11#include "datebookweeklstdayhdr.h"
12 12
13#include <opie/oclickablelabel.h> 13#include <opie/oclickablelabel.h>
14 14
15class QDateTime; 15class QDateTime;
16class DateBookDB; 16class DateBookDB;
17 17
18class DateBookWeekLstHeader: public DateBookWeekLstHeaderBase 18class DateBookWeekLstHeader: public DateBookWeekLstHeaderBase
19{ 19{
20 Q_OBJECT 20 Q_OBJECT
21public: 21public:
22 DateBookWeekLstHeader(bool onM, QWidget* parent = 0, const char* name = 0, 22 DateBookWeekLstHeader(bool onM, QWidget* parent = 0, const char* name = 0,
23 WFlags fl = 0 ); 23 WFlags fl = 0 );
24 ~DateBookWeekLstHeader(); 24 ~DateBookWeekLstHeader();
25 void setDate(const QDate &d); 25 void setDate(const QDate &d);
26 26
27public slots: 27public slots:
28 void nextWeek(); 28 void nextWeek();
29 void prevWeek(); 29 void prevWeek();
30 void pickDate(); 30 void nextMonth();
31 void setDate(int y, int m, int d); 31 void prevMonth();
32 void pickDate();
33 void setDate(int y, int m, int d);
32signals: 34signals:
33 void dateChanged(int y, int w); 35 void dateChanged(int y, int w);
34 void setDbl(bool on); 36 void setDbl(bool on);
35private: 37private:
36 QDate date; 38 QDate date;
37 bool onMonday; 39 //bool onMonday;
40 bool bStartOnMonday;
38}; 41};
39 42
40class DateBookWeekLstDayHdr: public DateBookWeekLstDayHdrBase 43class DateBookWeekLstDayHdr: public DateBookWeekLstDayHdrBase
41{ 44{
42 Q_OBJECT 45 Q_OBJECT
43public: 46public:
44 DateBookWeekLstDayHdr(const QDate &d, bool onM, 47 DateBookWeekLstDayHdr(const QDate &d, bool onM,
45 QWidget* parent = 0, const char* name = 0, 48 QWidget* parent = 0, const char* name = 0,
46 WFlags fl = 0 ); 49 WFlags fl = 0 );
47public slots: 50public slots:
48 void showDay(); 51 void showDay();
49 void newEvent(); 52 void newEvent();
50signals: 53signals:
51 void showDate(int y, int m, int d); 54 void showDate(int y, int m, int d);
52 void addEvent(const QDateTime &start, const QDateTime &stop, 55 void addEvent(const QDateTime &start, const QDateTime &stop,
53 const QString &str, const QString &location); 56 const QString &str, const QString &location);
54private: 57private:
55 QDate date; 58 QDate date;
56}; 59};
57 60
58class DateBookWeekLstEvent: public OClickableLabel 61class DateBookWeekLstEvent: public OClickableLabel
59{ 62{
60 Q_OBJECT 63 Q_OBJECT
61public: 64public:
62 DateBookWeekLstEvent(const EffectiveEvent &ev, int weeklistviewconfig =1, 65 DateBookWeekLstEvent(const EffectiveEvent &ev, int weeklistviewconfig =1,
63 QWidget* parent = 0, const char* name = 0, 66 QWidget* parent = 0, const char* name = 0,
64 WFlags fl = 0); 67 WFlags fl = 0);
65signals: 68signals:
66 void editEvent(const Event &e); 69 void editEvent(const Event &e);
67private slots: 70private slots:
68 void editMe(); 71 void editMe();
69private: 72private:
70 const EffectiveEvent event; 73 const EffectiveEvent event;
71}; 74};
72 75
73class DateBookWeekLstView: public QWidget 76class DateBookWeekLstView: public QWidget
74{ 77{
75 Q_OBJECT 78 Q_OBJECT
76public: 79public:
77 DateBookWeekLstView(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM, 80 DateBookWeekLstView(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM,
78 QWidget* parent = 0, const char* name = 0, 81 QWidget* parent = 0, const char* name = 0,
79 WFlags fl = 0 ); 82 WFlags fl = 0 );
80 ~DateBookWeekLstView(); 83 ~DateBookWeekLstView();
81signals: 84signals:
82 void editEvent(const Event &e); 85 void editEvent(const Event &e);
83 void showDate(int y, int m, int d); 86 void showDate(int y, int m, int d);
84 void addEvent(const QDateTime &start, const QDateTime &stop, 87 void addEvent(const QDateTime &start, const QDateTime &stop,
85 const QString &str, const QString &location); 88 const QString &str, const QString &location);
86private: 89private:
87 bool onMonday; 90 bool bStartOnMonday;
88protected slots: 91protected slots:
89 void keyPressEvent(QKeyEvent *); 92 void keyPressEvent(QKeyEvent *);
90}; 93};
91 94
92class DateBookWeekLstDblView: public QWidget { 95class DateBookWeekLstDblView: public QWidget {
93 Q_OBJECT 96 Q_OBJECT
94public: 97public:
95 DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, 98 DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
96 QValueList<EffectiveEvent> &ev2, 99 QValueList<EffectiveEvent> &ev2,
97 QDate &d, bool onM, 100 QDate &d, bool onM,
98 QWidget* parent = 0, const char* name = 0, 101 QWidget* parent = 0, const char* name = 0,
99 WFlags fl = 0 ); 102 WFlags fl = 0 );
100signals: 103signals:
101 void editEvent(const Event &e); 104 void editEvent(const Event &e);
102 void showDate(int y, int m, int d); 105 void showDate(int y, int m, int d);
103 void addEvent(const QDateTime &start, const QDateTime &stop, 106 void addEvent(const QDateTime &start, const QDateTime &stop,
104 const QString &str, const QString &location); 107 const QString &str, const QString &location);
105}; 108};
106 109
107class DateBookWeekLst : public QWidget 110class DateBookWeekLst : public QWidget
108{ 111{
109 Q_OBJECT 112 Q_OBJECT
110 113
111public: 114public:
112 DateBookWeekLst( bool ampm, bool onM, DateBookDB *newDB, 115 DateBookWeekLst( bool ampm, bool onM, DateBookDB *newDB,
113 QWidget *parent = 0, 116 QWidget *parent = 0,
114 const char *name = 0 ); 117 const char *name = 0 );
115 ~DateBookWeekLst(); 118 ~DateBookWeekLst();
116 void setDate( int y, int w ); 119 void setDate( int y, int w );
117 void setDate(const QDate &d ); 120 void setDate(const QDate &d );
118 int week() const { return _week; }; 121 int week() const { return _week; };
119 QDate date() const; 122 QDate date() const;
120 123
121public slots: 124public slots:
122 void redraw(); 125 void redraw();
123 void dateChanged(int y, int w); 126 void dateChanged(int y, int w);
124 127
125protected slots: 128protected slots:
126 void keyPressEvent(QKeyEvent *); 129 void keyPressEvent(QKeyEvent *);
127 void setDbl(bool on); 130 void setDbl(bool on);
128 131
129signals: 132signals:
130 void showDate(int y, int m, int d); 133 void showDate(int y, int m, int d);
131 void addEvent(const QDateTime &start, const QDateTime &stop, 134 void addEvent(const QDateTime &start, const QDateTime &stop,
132 const QString &str, const QString &location); 135 const QString &str, const QString &location);
133 void editEvent(const Event &e); 136 void editEvent(const Event &e);
134 137
135private: 138private:
136 DateBookDB *db; 139 DateBookDB *db;
137 int startTime; 140 int startTime;
138 bool ampm; 141 bool ampm;
139 bool onMonday; 142 bool bStartOnMonday;
140 bool dbl; 143 bool dbl;
141 int year, _week; 144 int year, _week;
142 DateBookWeekLstHeader *header; 145 DateBookWeekLstHeader *header;
143 QWidget *view; 146 QWidget *view;
144 QVBoxLayout *layout; 147 QVBoxLayout *layout;
145 QScrollView *scroll; 148 QScrollView *scroll;
146 149
147 void getEvents(); 150 void getEvents();
148}; 151};
149 152
150#endif 153#endif
151 154
diff --git a/core/pim/datebook/datebookweeklstheader.ui b/core/pim/datebook/datebookweeklstheader.ui
index c71e046..e925ec3 100644
--- a/core/pim/datebook/datebookweeklstheader.ui
+++ b/core/pim/datebook/datebookweeklstheader.ui
@@ -1,305 +1,306 @@
1<!DOCTYPE UI><UI> 1<!DOCTYPE UI><UI>
2<class>DateBookWeekLstHeaderBase</class> 2<class>DateBookWeekLstHeaderBase</class>
3<widget> 3<widget>
4 <class>QWidget</class> 4 <class>QWidget</class>
5 <property stdset="1"> 5 <property stdset="1">
6 <name>name</name> 6 <name>name</name>
7 <cstring>DateBookWeekLstHeaderBase</cstring> 7 <cstring>DateBookWeekLstHeaderBase</cstring>
8 </property> 8 </property>
9 <property stdset="1"> 9 <property stdset="1">
10 <name>geometry</name> 10 <name>geometry</name>
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>183</y> 13 <y>183</y>
14 <width>447</width> 14 <width>447</width>
15 <height>45</height> 15 <height>45</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>sizePolicy</name> 19 <name>sizePolicy</name>
20 <sizepolicy> 20 <sizepolicy>
21 <hsizetype>7</hsizetype> 21 <hsizetype>7</hsizetype>
22 <vsizetype>0</vsizetype> 22 <vsizetype>0</vsizetype>
23 </sizepolicy> 23 </sizepolicy>
24 </property> 24 </property>
25 <property> 25 <property>
26 <name>layoutMargin</name> 26 <name>layoutMargin</name>
27 </property> 27 </property>
28 <property> 28 <property>
29 <name>layoutSpacing</name> 29 <name>layoutSpacing</name>
30 </property> 30 </property>
31 <hbox> 31 <hbox>
32 <property stdset="1"> 32 <property stdset="1">
33 <name>margin</name> 33 <name>margin</name>
34 <number>11</number> 34 <number>11</number>
35 </property> 35 </property>
36 <property stdset="1"> 36 <property stdset="1">
37 <name>spacing</name> 37 <name>spacing</name>
38 <number>6</number> 38 <number>6</number>
39 </property> 39 </property>
40 <widget> 40 <widget>
41 <class>QToolButton</class> 41 <class>QToolButton</class>
42 <property stdset="1"> 42 <property stdset="1">
43 <name>name</name> 43 <name>name</name>
44 <cstring>back</cstring> 44 <cstring>backmonth</cstring>
45 </property>
46 <property stdset="1">
47 <name>text</name>
48 <string></string>
49 </property>
50 <property stdset="1">
51 <name>pixmap</name>
52 <pixmap></pixmap>
53 </property>
54 <property stdset="1">
55 <name>toggleButton</name>
56 <bool>false</bool>
57 </property>
58 <property stdset="1">
59 <name>autoRepeat</name>
60 <bool>true</bool>
61 </property>
62 <property stdset="1">
63 <name>autoRaise</name>
64 <bool>true</bool>
65 </property>
66 <property stdset="1">
67 <name>toggleButton</name>
68 <bool>false</bool>
69 </property>
70 <property>
71 <name>toolTip</name>
72 <string></string>
73 </property>
74 </widget>
75 <widget>
76 <class>QToolButton</class>
77 <property stdset="1">
78 <name>name</name>
79 <cstring>backweek</cstring>
45 </property> 80 </property>
46 <property stdset="1"> 81 <property stdset="1">
47 <name>sizePolicy</name> 82 <name>sizePolicy</name>
48 <sizepolicy> 83 <sizepolicy>
49 <hsizetype>7</hsizetype> 84 <hsizetype>7</hsizetype>
50 <vsizetype>0</vsizetype> 85 <vsizetype>0</vsizetype>
51 </sizepolicy> 86 </sizepolicy>
52 </property> 87 </property>
53 <property stdset="1"> 88 <property stdset="1">
54 <name>text</name> 89 <name>text</name>
55 <string></string> 90 <string></string>
56 </property> 91 </property>
57 <property stdset="1"> 92 <property stdset="1">
58 <name>pixmap</name> 93 <name>pixmap</name>
59 <pixmap></pixmap> 94 <pixmap></pixmap>
60 </property> 95 </property>
61 <property stdset="1"> 96 <property stdset="1">
62 <name>toggleButton</name> 97 <name>toggleButton</name>
63 <bool>false</bool> 98 <bool>false</bool>
64 </property> 99 </property>
65 <property stdset="1"> 100 <property stdset="1">
66 <name>autoRepeat</name> 101 <name>autoRepeat</name>
67 <bool>true</bool> 102 <bool>true</bool>
68 </property> 103 </property>
69 <property stdset="1"> 104 <property stdset="1">
70 <name>autoRaise</name> 105 <name>autoRaise</name>
71 <bool>true</bool> 106 <bool>true</bool>
72 </property> 107 </property>
73 <property stdset="1"> 108 <property stdset="1">
74 <name>toggleButton</name> 109 <name>toggleButton</name>
75 <bool>false</bool> 110 <bool>false</bool>
76 </property> 111 </property>
77 <property> 112 <property>
78 <name>toolTip</name> 113 <name>toolTip</name>
79 <string></string> 114 <string></string>
80 </property> 115 </property>
81 </widget> 116 </widget>
82 <spacer> 117 <spacer>
83 <property> 118 <property>
84 <name>name</name> 119 <name>name</name>
85 <cstring>Spacer1_3</cstring> 120 <cstring>Spacer1_3</cstring>
86 </property> 121 </property>
87 <property stdset="1"> 122 <property stdset="1">
88 <name>orientation</name> 123 <name>orientation</name>
89 <enum>Horizontal</enum> 124 <enum>Horizontal</enum>
90 </property> 125 </property>
91 <property stdset="1"> 126 <property stdset="1">
92 <name>sizeType</name> 127 <name>sizeType</name>
93 <enum>Expanding</enum> 128 <enum>Expanding</enum>
94 </property> 129 </property>
95 <property> 130 <property>
96 <name>sizeHint</name> 131 <name>sizeHint</name>
97 <size> 132 <size>
98 <width>20</width> 133 <width>20</width>
99 <height>20</height> 134 <height>20</height>
100 </size> 135 </size>
101 </property> 136 </property>
102 </spacer> 137 </spacer>
103 <widget> 138 <widget>
104 <class>QToolButton</class> 139 <class>QToolButton</class>
105 <property stdset="1"> 140 <property stdset="1">
106 <name>name</name> 141 <name>name</name>
107 <cstring>labelWeek</cstring> 142 <cstring>labelDate</cstring>
108 </property> 143 </property>
109 <property stdset="1"> 144 <property stdset="1">
110 <name>sizePolicy</name> 145 <name>sizePolicy</name>
111 <sizepolicy> 146 <sizepolicy>
112 <hsizetype>7</hsizetype> 147 <hsizetype>7</hsizetype>
113 <vsizetype>0</vsizetype> 148 <vsizetype>0</vsizetype>
114 </sizepolicy> 149 </sizepolicy>
115 </property> 150 </property>
116 <property stdset="1"> 151 <property stdset="1">
117 <name>font</name> 152 <name>font</name>
118 <font> 153 <font>
119 <bold>1</bold> 154 <bold>1</bold>
120 </font> 155 </font>
121 </property> 156 </property>
122 <property stdset="1"> 157 <property stdset="1">
123 <name>text</name> 158 <name>text</name>
124 <string>W: 00,00</string> 159 <string>W: 00,00</string>
125 </property> 160 </property>
126 <property stdset="1"> 161 <property stdset="1">
127 <name>toggleButton</name> 162 <name>toggleButton</name>
128 <bool>false</bool> 163 <bool>false</bool>
129 </property> 164 </property>
130 <property stdset="1"> 165 <property stdset="1">
131 <name>autoRaise</name> 166 <name>autoRaise</name>
132 <bool>false</bool> 167 <bool>false</bool>
133 </property> 168 </property>
134 <property stdset="1"> 169 <property stdset="1">
135 <name>toggleButton</name> 170 <name>toggleButton</name>
136 <bool>false</bool> 171 <bool>false</bool>
137 </property> 172 </property>
138 <property> 173 <property>
139 <name>toolTip</name> 174 <name>toolTip</name>
140 <string></string> 175 <string></string>
141 </property> 176 </property>
142 </widget> 177 </widget>
143 <spacer>
144 <property>
145 <name>name</name>
146 <cstring>Spacer1</cstring>
147 </property>
148 <property stdset="1">
149 <name>orientation</name>
150 <enum>Horizontal</enum>
151 </property>
152 <property stdset="1">
153 <name>sizeType</name>
154 <enum>Expanding</enum>
155 </property>
156 <property>
157 <name>sizeHint</name>
158 <size>
159 <width>20</width>
160 <height>20</height>
161 </size>
162 </property>
163 </spacer>
164 <widget> 178 <widget>
165 <class>QToolButton</class> 179 <class>QToolButton</class>
166 <property stdset="1"> 180 <property stdset="1">
167 <name>name</name> 181 <name>name</name>
168 <cstring>dbl</cstring> 182 <cstring>dbl</cstring>
169 </property> 183 </property>
170 <property stdset="1"> 184 <property stdset="1">
171 <name>sizePolicy</name> 185 <name>sizePolicy</name>
172 <sizepolicy> 186 <sizepolicy>
173 <hsizetype>3</hsizetype> 187 <hsizetype>3</hsizetype>
174 <vsizetype>0</vsizetype> 188 <vsizetype>0</vsizetype>
175 </sizepolicy> 189 </sizepolicy>
176 </property> 190 </property>
177 <property stdset="1"> 191 <property stdset="1">
178 <name>font</name> 192 <name>font</name>
179 <font> 193 <font>
180 <bold>1</bold> 194 <bold>1</bold>
181 </font> 195 </font>
182 </property> 196 </property>
183 <property stdset="1"> 197 <property stdset="1">
184 <name>text</name> 198 <name>text</name>
185 <string>2</string> 199 <string>2</string>
186 </property> 200 </property>
187 <property stdset="1"> 201 <property stdset="1">
188 <name>toggleButton</name> 202 <name>toggleButton</name>
189 <bool>true</bool> 203 <bool>true</bool>
190 </property> 204 </property>
191 <property stdset="1"> 205 <property stdset="1">
192 <name>autoRaise</name> 206 <name>autoRaise</name>
193 <bool>false</bool> 207 <bool>false</bool>
194 </property> 208 </property>
195 <property stdset="1"> 209 <property stdset="1">
196 <name>toggleButton</name> 210 <name>toggleButton</name>
197 <bool>true</bool> 211 <bool>true</bool>
198 </property> 212 </property>
199 <property> 213 <property>
200 <name>toolTip</name> 214 <name>toolTip</name>
201 <string></string> 215 <string></string>
202 </property> 216 </property>
203 </widget> 217 </widget>
204 <spacer> 218 <spacer>
205 <property> 219 <property>
206 <name>name</name> 220 <name>name</name>
207 <cstring>Spacer1_3_2</cstring> 221 <cstring>Spacer1_3_2</cstring>
208 </property> 222 </property>
209 <property stdset="1"> 223 <property stdset="1">
210 <name>orientation</name> 224 <name>orientation</name>
211 <enum>Horizontal</enum> 225 <enum>Horizontal</enum>
212 </property> 226 </property>
213 <property stdset="1"> 227 <property stdset="1">
214 <name>sizeType</name> 228 <name>sizeType</name>
215 <enum>Expanding</enum> 229 <enum>Expanding</enum>
216 </property> 230 </property>
217 <property> 231 <property>
218 <name>sizeHint</name> 232 <name>sizeHint</name>
219 <size> 233 <size>
220 <width>20</width> 234 <width>20</width>
221 <height>20</height> 235 <height>20</height>
222 </size> 236 </size>
223 </property> 237 </property>
224 </spacer> 238 </spacer>
225 <widget> 239 <widget>
226 <class>QLabel</class> 240 <class>QToolButton</class>
227 <property stdset="1"> 241 <property stdset="1">
228 <name>name</name> 242 <name>name</name>
229 <cstring>labelDate</cstring> 243 <cstring>forwardweek</cstring>
230 </property> 244 </property>
231 <property stdset="1"> 245 <property stdset="1">
232 <name>sizePolicy</name> 246 <name>sizePolicy</name>
233 <sizepolicy> 247 <sizepolicy>
234 <hsizetype>3</hsizetype> 248 <hsizetype>1</hsizetype>
235 <vsizetype>7</vsizetype> 249 <vsizetype>0</vsizetype>
236 </sizepolicy> 250 </sizepolicy>
237 </property> 251 </property>
238 <property stdset="1"> 252 <property stdset="1">
239 <name>font</name>
240 <font>
241 <bold>1</bold>
242 </font>
243 </property>
244 <property stdset="1">
245 <name>text</name> 253 <name>text</name>
246 <string>00 Jan-00 Jan</string> 254 <string></string>
247 </property>
248 <property>
249 <name>hAlign</name>
250 </property>
251 </widget>
252 <spacer>
253 <property>
254 <name>name</name>
255 <cstring>Spacer1_2</cstring>
256 </property> 255 </property>
257 <property stdset="1"> 256 <property stdset="1">
258 <name>orientation</name> 257 <name>pixmap</name>
259 <enum>Horizontal</enum> 258 <pixmap></pixmap>
260 </property> 259 </property>
261 <property stdset="1"> 260 <property stdset="1">
262 <name>sizeType</name> 261 <name>autoRepeat</name>
263 <enum>Expanding</enum> 262 <bool>true</bool>
264 </property> 263 </property>
265 <property> 264 <property stdset="1">
266 <name>sizeHint</name> 265 <name>autoRaise</name>
267 <size> 266 <bool>true</bool>
268 <width>20</width>
269 <height>20</height>
270 </size>
271 </property> 267 </property>
272 </spacer> 268 </widget>
273 <widget> 269 <widget>
274 <class>QToolButton</class> 270 <class>QToolButton</class>
275 <property stdset="1"> 271 <property stdset="1">
276 <name>name</name> 272 <name>name</name>
277 <cstring>forward</cstring> 273 <cstring>forwardmonth</cstring>
278 </property>
279 <property stdset="1">
280 <name>sizePolicy</name>
281 <sizepolicy>
282 <hsizetype>1</hsizetype>
283 <vsizetype>0</vsizetype>
284 </sizepolicy>
285 </property> 274 </property>
286 <property stdset="1"> 275 <property stdset="1">
287 <name>text</name> 276 <name>text</name>
288 <string></string> 277 <string></string>
289 </property> 278 </property>
290 <property stdset="1"> 279 <property stdset="1">
291 <name>pixmap</name> 280 <name>pixmap</name>
292 <pixmap></pixmap> 281 <pixmap></pixmap>
293 </property> 282 </property>
294 <property stdset="1"> 283 <property stdset="1">
284 <name>toggleButton</name>
285 <bool>false</bool>
286 </property>
287 <property stdset="1">
295 <name>autoRepeat</name> 288 <name>autoRepeat</name>
296 <bool>true</bool> 289 <bool>true</bool>
297 </property> 290 </property>
298 <property stdset="1"> 291 <property stdset="1">
299 <name>autoRaise</name> 292 <name>autoRaise</name>
300 <bool>true</bool> 293 <bool>true</bool>
301 </property> 294 </property>
295 <property stdset="1">
296 <name>toggleButton</name>
297 <bool>false</bool>
298 </property>
299 <property>
300 <name>toolTip</name>
301 <string></string>
302 </property>
302 </widget> 303 </widget>
303 </hbox> 304 </hbox>
304</widget> 305</widget>
305</UI> 306</UI>