summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp78
-rw-r--r--core/pim/datebook/datebook.h49
-rw-r--r--core/pim/datebook/datebookday.cpp64
-rw-r--r--core/pim/datebook/datebookday.h49
-rw-r--r--core/pim/datebook/datebookdayallday.cpp39
-rw-r--r--core/pim/datebook/datebookdayallday.h31
-rw-r--r--core/pim/datebook/datebookdayheaderimpl.cpp60
-rw-r--r--core/pim/datebook/datebookdayheaderimpl.h49
-rw-r--r--core/pim/datebook/datebooksettings.cpp48
-rw-r--r--core/pim/datebook/datebooksettings.h48
-rw-r--r--core/pim/datebook/datebooktypes.h30
-rw-r--r--core/pim/datebook/datebookweek.cpp49
-rw-r--r--core/pim/datebook/datebookweek.h49
-rw-r--r--core/pim/datebook/datebookweekheaderimpl.cpp59
-rw-r--r--core/pim/datebook/datebookweekheaderimpl.h49
-rw-r--r--core/pim/datebook/dateentryimpl.cpp48
-rw-r--r--core/pim/datebook/dateentryimpl.h49
-rw-r--r--core/pim/datebook/main.cpp50
-rw-r--r--core/pim/datebook/modules/weeklst/datebookweeklst.cpp1
-rw-r--r--core/pim/datebook/modules/weeklst/datebookweeklstheader.cpp11
-rw-r--r--core/pim/datebook/namespace_hack.h32
-rw-r--r--core/pim/datebook/noteentryimpl.cpp30
-rw-r--r--core/pim/datebook/noteentryimpl.h34
-rw-r--r--core/pim/datebook/onoteedit.cpp32
-rw-r--r--core/pim/datebook/onoteedit.h32
-rw-r--r--core/pim/datebook/repeatentry.cpp48
-rw-r--r--core/pim/datebook/repeatentry.h48
27 files changed, 795 insertions, 371 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index cc7bf4b..68ab07a 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -1,1214 +1,1230 @@
1/********************************************************************** 1/*
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2                 This file is part of the Opie Project
3** 3
4** This file is part of Qtopia Environment. 4 Copyright (C) Opie Team <opie-devel@handhelds.org>
5** 5 =.
6** This file may be distributed and/or modified under the terms of the 6 .=l.
7** GNU General Public License version 2 as published by the Free Software 7           .>+-=
8** Foundation and appearing in the file LICENSE.GPL included in the 8 _;:,     .>    :=|. This program is free software; you can
9** packaging of this file. 9.> <`_,   >  .   <= redistribute it and/or modify it under
10** 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11.="- .-=="i,     .._ License as published by the Free Software
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13** 13     ._= =}       : or (at your option) any later version.
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14    .%`+i>       _;_.
15** 15    .i_,=:_.      -<s. This program is distributed in the hope that
16** Contact info@trolltech.com if any conditions of this licensing are 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17** not clear to you. 17 : ..    .:,     . . . without even the implied warranty of
18** 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19** $Id$ 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20** 20..}^=.=       =       ; Library General Public License for more
21**********************************************************************/ 21++=   -.     .`     .: details.
22:     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA.
29*/
22 30
23#define QTOPIA_INTERNAL_FD 31#define QTOPIA_INTERNAL_FD
24 32
25#include "datebook.h" 33#include "datebook.h"
26#include "datebookday.h" 34#include "datebookday.h"
27#include "datebooksettings.h" 35#include "datebooksettings.h"
28#include "datebookweek.h" 36#include "datebookweek.h"
29#include "modules/weeklst/datebookweeklst.h" 37#include "modules/weeklst/datebookweeklst.h"
30#include "modules/monthview/odatebookmonth.h" 38#include "modules/monthview/odatebookmonth.h"
31#include "dateentryimpl.h" 39#include "dateentryimpl.h"
32 40
33#include <opie2/odebug.h> 41#include <opie2/odebug.h>
34#include <opie2/oholidaypluginif.h> 42#include <opie2/oholidaypluginif.h>
35#include <opie2/oholidayplugin.h> 43#include <opie2/oholidayplugin.h>
36#include <opie2/opluginloader.h> 44#include <opie2/opluginloader.h>
45#include <opie2/oresource.h>
37#include <opie2/todayplugininterface.h> 46#include <opie2/todayplugininterface.h>
38 47
39//#include <qpe/datebookmonth.h> 48//#include <qpe/datebookmonth.h>
40#include <qpe/qpeapplication.h> 49#include <qpe/qpeapplication.h>
41#include <qpe/config.h> 50#include <qpe/config.h>
42#include <qpe/finddialog.h> 51#include <qpe/finddialog.h>
43#include <qpe/ir.h> 52#include <qpe/ir.h>
44#include <qpe/qpemessagebox.h> 53#include <qpe/qpemessagebox.h>
45#include <qpe/resource.h>
46#include <qpe/sound.h> 54#include <qpe/sound.h>
47#include <qpe/tzselect.h> 55#include <qpe/tzselect.h>
48#include <qtopia/qlibrary.h> 56#include <qtopia/qlibrary.h>
49 57
50#include <qaction.h> 58#include <qaction.h>
51#include <qcopchannel_qws.h> 59#include <qcopchannel_qws.h>
52#include <qlayout.h> 60#include <qlayout.h>
53#include <qmessagebox.h> 61#include <qmessagebox.h>
54#include <qtimer.h> 62#include <qtimer.h>
55#include <qtl.h> 63#include <qtl.h>
56#include <qtoolbar.h> 64#include <qtoolbar.h>
57#include <qwidgetstack.h> 65#include <qwidgetstack.h>
58#include <qdir.h> 66#include <qdir.h>
59#include <qlabel.h> 67#include <qlabel.h>
60 68
61#include <sys/stat.h> 69#include <sys/stat.h>
62#include <sys/types.h> 70#include <sys/types.h>
63#include <fcntl.h> 71#include <fcntl.h>
64#include <unistd.h> 72#include <unistd.h>
65 73
66#include <stdlib.h> 74#include <stdlib.h>
67 75
68DateBook::DateBook( QWidget *parent, const char *, WFlags f ) 76DateBook::DateBook( QWidget *parent, const char *, WFlags f )
69 : QMainWindow( parent, "datebook", f ), 77 : QMainWindow( parent, "datebook", f ),
70 aPreset( FALSE ), 78 aPreset( FALSE ),
71 presetTime( -1 ), 79 presetTime( -1 ),
72 startTime( 8 ), // an acceptable default 80 startTime( 8 ), // an acceptable default
73 rowStyle( 0 ), 81 rowStyle( 0 ),
74 bJumpToCurTime(FALSE), 82 bJumpToCurTime(FALSE),
75 syncing(FALSE), 83 syncing(FALSE),
76 inSearch(FALSE), 84 inSearch(FALSE),
77 alarmCounter(0) 85 alarmCounter(0)
78{ 86{
79 bool needEvilHack= false; // if we need an Evil Hack 87 bool needEvilHack= false; // if we need an Evil Hack
80 QTime t; 88 QTime t;
81 t.start(); 89 t.start();
82 db = new DateBookDBHoliday; 90 db = new DateBookDBHoliday;
83 odebug << "loading db t=" << t.elapsed() << oendl; 91 odebug << "loading db t=" << t.elapsed() << oendl;
84 db_holiday = new DateBookHoliday(); 92 db_holiday = new DateBookHoliday();
85 db->db_holiday=db_holiday; 93 db->db_holiday=db_holiday;
86 94
87 loadSettings(); 95 loadSettings();
88 setCaption( tr("Calendar") ); 96 setCaption( tr("Calendar") );
89 setIcon( Resource::loadPixmap( "datebook_icon" ) ); 97 setIcon( Opie::Core::OResource::loadPixmap( "datebook_icon" ) );
90 98
91 setToolBarsMovable( FALSE ); 99 setToolBarsMovable( FALSE );
92 100
93 views = new QWidgetStack( this ); 101 views = new QWidgetStack( this );
94 setCentralWidget( views ); 102 setCentralWidget( views );
95 103
96 dayView = 0; 104 dayView = 0;
97 weekView = 0; 105 weekView = 0;
98 weekLstView = 0; 106 weekLstView = 0;
99 monthView = 0; 107 monthView = 0;
100 108
101// QToolBar *bar = new QToolBar( this ); 109// QToolBar *bar = new QToolBar( this );
102// bar->setHorizontalStretchable( TRUE ); 110// bar->setHorizontalStretchable( TRUE );
103 111
104// QMenuBar *mb = new QMenuBar( bar ); 112// QMenuBar *mb = new QMenuBar( bar );
105// mb->setMargin( 0 ); 113// mb->setMargin( 0 );
106 114
107// QPopupMenu *view = new QPopupMenu( this ); 115// QPopupMenu *view = new QPopupMenu( this );
108// mb->insertItem( tr( "View" ), view ); 116// mb->insertItem( tr( "View" ), view );
109 117
110 QToolBar *sub_bar = new QToolBar(this); 118 QToolBar *sub_bar = new QToolBar(this);
111 sub_bar->setHorizontalStretchable(TRUE); 119 sub_bar->setHorizontalStretchable(TRUE);
112 120
113 QActionGroup *g = new QActionGroup( this ); 121 QActionGroup *g = new QActionGroup( this );
114 g->setExclusive( TRUE ); 122 g->setExclusive( TRUE );
115 123
116 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); 124 QAction *a = new QAction( tr( "New" ), Opie::Core::OResource::loadPixmap( "new", Opie::Core::OResource::SmallIcon ),
125 QString::null, 0, this, 0 );
117 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 126 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
118 a->addTo( sub_bar ); 127 a->addTo( sub_bar );
119 128
120 sub_bar->addSeparator(); 129 sub_bar->addSeparator();
121 130
122 a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 ); 131 a = new QAction( tr( "Today" ), Opie::Core::OResource::loadPixmap( "datebook/to_day", Opie::Core::OResource::SmallIcon ),
132 QString::null, 0, g, 0 );
123 connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); 133 connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) );
124 a->addTo( sub_bar ); 134 a->addTo( sub_bar );
125// a->addTo( view ); 135// a->addTo( view );
126 136
127 sub_bar->addSeparator(); 137 sub_bar->addSeparator();
128 138
129 a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); 139 a = new QAction( tr( "Day" ), Opie::Core::OResource::loadPixmap( "day", Opie::Core::OResource::SmallIcon ),
140 QString::null, 0, g, 0 );
130 connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); 141 connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) );
131 a->addTo( sub_bar ); 142 a->addTo( sub_bar );
132// a->addTo( view ); 143// a->addTo( view );
133 a->setToggleAction( TRUE ); 144 a->setToggleAction( TRUE );
134 a->setOn( TRUE ); 145 a->setOn( TRUE );
135 dayAction = a; 146 dayAction = a;
136 147
137 a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); 148 a = new QAction( tr( "Week" ), Opie::Core::OResource::loadPixmap( "week", Opie::Core::OResource::SmallIcon ),
149 QString::null, 0, g, 0 );
138 connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); 150 connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) );
139 a->addTo( sub_bar ); 151 a->addTo( sub_bar );
140// a->addTo( view ); 152// a->addTo( view );
141 a->setToggleAction( TRUE ); 153 a->setToggleAction( TRUE );
142 weekAction = a; 154 weekAction = a;
143 155
144 a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 ); 156 a = new QAction( tr( "WeekLst" ), Opie::Core::OResource::loadPixmap( "datebook/weeklst", Opie::Core::OResource::SmallIcon ),
157 QString::null, 0, g, 0 );
145 connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); 158 connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) );
146 a->addTo( sub_bar ); 159 a->addTo( sub_bar );
147// a->addTo( view ); 160// a->addTo( view );
148 a->setToggleAction( TRUE ); 161 a->setToggleAction( TRUE );
149 weekLstAction = a; 162 weekLstAction = a;
150 163
151 a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); 164 a = new QAction( tr( "Month" ), Opie::Core::OResource::loadPixmap( "month", Opie::Core::OResource::SmallIcon ),
165 QString::null, 0, g, 0 );
152 connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); 166 connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) );
153 a->addTo( sub_bar ); 167 a->addTo( sub_bar );
154// a->addTo( view ); 168// a->addTo( view );
155 a->setToggleAction( TRUE ); 169 a->setToggleAction( TRUE );
156 monthAction = a; 170 monthAction = a;
157 171
158 sub_bar->addSeparator(); 172 sub_bar->addSeparator();
159 173
160 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 ); 174 a = new QAction( tr( "Find" ), Opie::Core::OResource::loadPixmap( "mag", Opie::Core::OResource::SmallIcon ),
175 QString::null, 0, this, 0 );
161 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); 176 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) );
162 a->addTo( sub_bar ); 177 a->addTo( sub_bar );
163 178
164 a = new QAction( tr( "Edit..." ), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0 ); 179 a = new QAction( tr( "Edit..." ), Opie::Core::OResource::loadPixmap( "SettingsIcon", Opie::Core::OResource::SmallIcon ),
180 QString::null, 0, this, 0 );
165 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); 181 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
166 a->addTo( sub_bar ); 182 a->addTo( sub_bar );
167 183
168 if(defaultView==DAY) viewDay(); 184 if(defaultView==DAY) viewDay();
169 if(defaultView==WEEK) needEvilHack=true; // viewWeek(); 185 if(defaultView==WEEK) needEvilHack=true; // viewWeek();
170 if(defaultView==WEEKLST) viewWeekLst(); 186 if(defaultView==WEEKLST) viewWeekLst();
171 if(defaultView==MONTH) viewMonth(); 187 if(defaultView==MONTH) viewMonth();
172 188
173 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); 189 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) );
174 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) ); 190 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) );
175 191
176#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 192#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
177 connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), this, SLOT(appMessage(const QCString&,const QByteArray&)) ); 193 connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), this, SLOT(appMessage(const QCString&,const QByteArray&)) );
178#endif 194#endif
179 195
180 // listen on QPE/System 196 // listen on QPE/System
181#if defined(Q_WS_QWS) 197#if defined(Q_WS_QWS)
182#if !defined(QT_NO_COP) 198#if !defined(QT_NO_COP)
183 QCopChannel *channel = new QCopChannel( "QPE/System", this ); 199 QCopChannel *channel = new QCopChannel( "QPE/System", this );
184 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) ); 200 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) );
185 channel = new QCopChannel( "QPE/Datebook", this ); 201 channel = new QCopChannel( "QPE/Datebook", this );
186 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) ); 202 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) );
187#endif 203#endif
188#endif 204#endif
189 205
190 odebug << "done t=" << t.elapsed() << oendl; 206 odebug << "done t=" << t.elapsed() << oendl;
191 207
192 connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); 208 connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) );
193 connect( qApp, SIGNAL( reload()), this, SLOT( reload() ) ); 209 connect( qApp, SIGNAL( reload()), this, SLOT( reload() ) );
194 /* 210 /*
195 * Here is a problem description: 211 * Here is a problem description:
196 * When Weekview is the default view 212 * When Weekview is the default view
197 * a DateBookWeekView get's created 213 * a DateBookWeekView get's created
198 * redraw() get's called. So what? 214 * redraw() get's called. So what?
199 * Remember that we're still in the c'tor 215 * Remember that we're still in the c'tor
200 * and no final layout has happened? Ok 216 * and no final layout has happened? Ok
201 * now all Events get arranged. Their x 217 * now all Events get arranged. Their x
202 * position get's determined by a QHeader 218 * position get's determined by a QHeader
203 * position. But the QHeader isn't layouted or 219 * position. But the QHeader isn't layouted or
204 * at the right position. redraw() is a slot 220 * at the right position. redraw() is a slot
205 * so we'll call it then via a singleShot 221 * so we'll call it then via a singleShot
206 * from view() 222 * from view()
207 */ 223 */
208 if( needEvilHack ){ 224 if( needEvilHack ){
209 QTimer::singleShot( 500, this, SLOT(viewWeek()) ); 225 QTimer::singleShot( 500, this, SLOT(viewWeek()) );
210 } 226 }
211} 227}
212 228
213void DateBook::receive( const QCString &msg, const QByteArray &data ) 229void DateBook::receive( const QCString &msg, const QByteArray &data )
214{ 230{
215 QDataStream stream( data, IO_ReadOnly ); 231 QDataStream stream( data, IO_ReadOnly );
216 if ( msg == "timeChange(QString)" ) { 232 if ( msg == "timeChange(QString)" ) {
217 // update active view! 233 // update active view!
218 if ( dayAction->isOn() ) 234 if ( dayAction->isOn() )
219 viewDay(); 235 viewDay();
220 else if ( weekAction->isOn() ) 236 else if ( weekAction->isOn() )
221 viewWeek(); 237 viewWeek();
222 else if ( monthAction->isOn() ) 238 else if ( monthAction->isOn() )
223 viewMonth(); 239 viewMonth();
224 } 240 }
225 else if (msg == "editEvent(int)") { 241 else if (msg == "editEvent(int)") {
226 int uid; 242 int uid;
227 stream >> uid; 243 stream >> uid;
228 Event e=db->eventByUID(uid); 244 Event e=db->eventByUID(uid);
229 editEvent(e); 245 editEvent(e);
230 }else if (msg == "viewDefault(QDate)"){ 246 }else if (msg == "viewDefault(QDate)"){
231 QDate day; 247 QDate day;
232 stream >> day; 248 stream >> day;
233 viewDefault(day); 249 viewDefault(day);
234 } 250 }
235} 251}
236 252
237DateBook::~DateBook() 253DateBook::~DateBook()
238{ 254{
239 delete db_holiday; 255 delete db_holiday;
240} 256}
241 257
242void DateBook::slotSettings() 258void DateBook::slotSettings()
243{ 259{
244 DateBookSettings frmSettings( ampm, this ); 260 DateBookSettings frmSettings( ampm, this );
245 frmSettings.setStartTime( startTime ); 261 frmSettings.setStartTime( startTime );
246 frmSettings.setAlarmPreset( aPreset, presetTime ); 262 frmSettings.setAlarmPreset( aPreset, presetTime );
247 frmSettings.setJumpToCurTime( bJumpToCurTime ); 263 frmSettings.setJumpToCurTime( bJumpToCurTime );
248 frmSettings.setRowStyle( rowStyle ); 264 frmSettings.setRowStyle( rowStyle );
249 frmSettings.comboDefaultView->setCurrentItem(defaultView-1); 265 frmSettings.comboDefaultView->setCurrentItem(defaultView-1);
250 frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig); 266 frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig);
251 frmSettings.setPluginList(db_holiday->pluginManager(),db_holiday->pluginLoader()); 267 frmSettings.setPluginList(db_holiday->pluginManager(),db_holiday->pluginLoader());
252 268
253 bool found=false; 269 bool found=false;
254 for (int i=0; i<(frmSettings.comboLocation->count()); i++) { 270 for (int i=0; i<(frmSettings.comboLocation->count()); i++) {
255 if ( frmSettings.comboLocation->text(i) == defaultLocation ) { 271 if ( frmSettings.comboLocation->text(i) == defaultLocation ) {
256 frmSettings.comboLocation->setCurrentItem(i); 272 frmSettings.comboLocation->setCurrentItem(i);
257 found=true; 273 found=true;
258 break; 274 break;
259 } 275 }
260 } 276 }
261 if(!found) { 277 if(!found) {
262 frmSettings.comboLocation->insertItem(defaultLocation); 278 frmSettings.comboLocation->insertItem(defaultLocation);
263 frmSettings.comboLocation->setCurrentItem(frmSettings.comboLocation->count()-1); 279 frmSettings.comboLocation->setCurrentItem(frmSettings.comboLocation->count()-1);
264 } 280 }
265 frmSettings.comboCategory->setCategories(defaultCategories,"Calendar", tr("Calendar")); 281 frmSettings.comboCategory->setCategories(defaultCategories,"Calendar", tr("Calendar"));
266 282
267 if ( QPEApplication::execDialog( &frmSettings ) ) { 283 if ( QPEApplication::execDialog( &frmSettings ) ) {
268 frmSettings.savePlugins(); 284 frmSettings.savePlugins();
269 db_holiday->pluginManager()->save(); 285 db_holiday->pluginManager()->save();
270 db_holiday->reloadPlugins(); 286 db_holiday->reloadPlugins();
271 287
272 aPreset = frmSettings.alarmPreset(); 288 aPreset = frmSettings.alarmPreset();
273 presetTime = frmSettings.presetTime(); 289 presetTime = frmSettings.presetTime();
274 startTime = frmSettings.startTime(); 290 startTime = frmSettings.startTime();
275 bJumpToCurTime = frmSettings.jumpToCurTime(); 291 bJumpToCurTime = frmSettings.jumpToCurTime();
276 rowStyle = frmSettings.rowStyle(); 292 rowStyle = frmSettings.rowStyle();
277 defaultView=frmSettings.comboDefaultView->currentItem()+1; 293 defaultView=frmSettings.comboDefaultView->currentItem()+1;
278 weeklistviewconfig=frmSettings.comboWeekListView->currentItem(); 294 weeklistviewconfig=frmSettings.comboWeekListView->currentItem();
279 defaultLocation=frmSettings.comboLocation->currentText(); 295 defaultLocation=frmSettings.comboLocation->currentText();
280 defaultCategories=frmSettings.comboCategory->currentCategories(); 296 defaultCategories=frmSettings.comboCategory->currentCategories();
281 297
282 if ( dayView ) { 298 if ( dayView ) {
283 dayView->setStartViewTime( startTime ); 299 dayView->setStartViewTime( startTime );
284 dayView->setJumpToCurTime( bJumpToCurTime ); 300 dayView->setJumpToCurTime( bJumpToCurTime );
285 dayView->setRowStyle( rowStyle ); 301 dayView->setRowStyle( rowStyle );
286 } 302 }
287 if ( weekView ) { 303 if ( weekView ) {
288 weekView->setStartViewTime( startTime ); 304 weekView->setStartViewTime( startTime );
289 } 305 }
290 saveSettings(); 306 saveSettings();
291 307
292 // make the change obvious 308 // make the change obvious
293 if ( views->visibleWidget() ) { 309 if ( views->visibleWidget() ) {
294 if ( views->visibleWidget() == dayView ) 310 if ( views->visibleWidget() == dayView )
295 dayView->redraw(); 311 dayView->redraw();
296 else if ( views->visibleWidget() == weekView ) 312 else if ( views->visibleWidget() == weekView )
297 weekView->redraw(); 313 weekView->redraw();
298 else if ( views->visibleWidget() == weekLstView ) 314 else if ( views->visibleWidget() == weekLstView )
299 weekLstView->redraw(); 315 weekLstView->redraw();
300 } 316 }
301 } 317 }
302} 318}
303 319
304void DateBook::fileNew() 320void DateBook::fileNew()
305{ 321{
306 slotNewEventFromKey(""); 322 slotNewEventFromKey("");
307} 323}
308 324
309QString DateBook::checkEvent(const Event &e) 325QString DateBook::checkEvent(const Event &e)
310{ 326{
311 /* check if overlaps with itself */ 327 /* check if overlaps with itself */
312 bool checkFailed = FALSE; 328 bool checkFailed = FALSE;
313 329
314 /* check the next 12 repeats. should catch most problems */ 330 /* check the next 12 repeats. should catch most problems */
315 QDate current_date = e.start().date(); 331 QDate current_date = e.start().date();
316 Event previous = e; 332 Event previous = e;
317 for(int i = 0; i < 12; i++) 333 for(int i = 0; i < 12; i++)
318 { 334 {
319 QDateTime next; 335 QDateTime next;
320 if (!nextOccurance(previous, current_date.addDays(1), next)) { 336 if (!nextOccurance(previous, current_date.addDays(1), next)) {
321 break; // no more repeats 337 break; // no more repeats
322 } 338 }
323 if(next < previous.end()) { 339 if(next < previous.end()) {
324 checkFailed = TRUE; 340 checkFailed = TRUE;
325 break; 341 break;
326 } 342 }
327 current_date = next.date(); 343 current_date = next.date();
328 } 344 }
329 345
330 if(checkFailed) 346 if(checkFailed)
331 return tr("Event duration is potentially longer\n" 347 return tr("Event duration is potentially longer\n"
332 "than interval between repeats."); 348 "than interval between repeats.");
333 349
334 return QString::null; 350 return QString::null;
335} 351}
336 352
337QDate DateBook::currentDate() 353QDate DateBook::currentDate()
338{ 354{
339 QDate d = QDate::currentDate(); 355 QDate d = QDate::currentDate();
340 356
341 if ( dayView && views->visibleWidget() == dayView ) { 357 if ( dayView && views->visibleWidget() == dayView ) {
342 d = dayView->date(); 358 d = dayView->date();
343 } else if ( weekView && views->visibleWidget() == weekView ) { 359 } else if ( weekView && views->visibleWidget() == weekView ) {
344 d = weekView->date(); 360 d = weekView->date();
345 } else if ( weekLstView && views->visibleWidget() == weekLstView ) { 361 } else if ( weekLstView && views->visibleWidget() == weekLstView ) {
346 d = weekLstView->date(); 362 d = weekLstView->date();
347 } else if ( monthView && views->visibleWidget() == monthView ) { 363 } else if ( monthView && views->visibleWidget() == monthView ) {
348 d = monthView->selectedDate(); 364 d = monthView->selectedDate();
349 } 365 }
350 366
351 return d; 367 return d;
352} 368}
353 369
354void DateBook::view(int v, const QDate &d) { 370void DateBook::view(int v, const QDate &d) {
355 if (v==DAY) { 371 if (v==DAY) {
356 initDay(); 372 initDay();
357 dayAction->setOn( TRUE ); 373 dayAction->setOn( TRUE );
358 dayView->setDate( d ); 374 dayView->setDate( d );
359 views->raiseWidget( dayView ); 375 views->raiseWidget( dayView );
360 dayView->redraw(); 376 dayView->redraw();
361 } else if (v==WEEK) { 377 } else if (v==WEEK) {
362 initWeek(); 378 initWeek();
363 weekAction->setOn( TRUE ); 379 weekAction->setOn( TRUE );
364 weekView->setDate( d ); 380 weekView->setDate( d );
365 views->raiseWidget( weekView ); 381 views->raiseWidget( weekView );
366 weekView->redraw(); 382 weekView->redraw();
367 } else if (v==WEEKLST) { 383 } else if (v==WEEKLST) {
368 initWeekLst(); 384 initWeekLst();
369 weekLstAction->setOn( TRUE ); 385 weekLstAction->setOn( TRUE );
370 weekLstView->setDate(d); 386 weekLstView->setDate(d);
371 views->raiseWidget( weekLstView ); 387 views->raiseWidget( weekLstView );
372 weekLstView->redraw(); 388 weekLstView->redraw();
373 } else if (v==MONTH) { 389 } else if (v==MONTH) {
374 initMonth(); 390 initMonth();
375 monthAction->setOn( TRUE ); 391 monthAction->setOn( TRUE );
376 monthView->setDate( d.year(), d.month(), d.day() ); 392 monthView->setDate( d.year(), d.month(), d.day() );
377 views->raiseWidget( monthView ); 393 views->raiseWidget( monthView );
378 monthView->redraw(); 394 monthView->redraw();
379 } 395 }
380} 396}
381 397
382void DateBook::viewDefault(const QDate &d) { 398void DateBook::viewDefault(const QDate &d) {
383 view(defaultView,d); 399 view(defaultView,d);
384} 400}
385 401
386void DateBook::viewDay() { 402void DateBook::viewDay() {
387 view(DAY,currentDate()); 403 view(DAY,currentDate());
388} 404}
389 405
390void DateBook::viewWeek() { 406void DateBook::viewWeek() {
391 view(WEEK,currentDate()); 407 view(WEEK,currentDate());
392} 408}
393 409
394void DateBook::viewWeekLst() { 410void DateBook::viewWeekLst() {
395 view(WEEKLST,currentDate()); 411 view(WEEKLST,currentDate());
396} 412}
397 413
398void DateBook::viewMonth() { 414void DateBook::viewMonth() {
399 view(MONTH,currentDate()); 415 view(MONTH,currentDate());
400} 416}
401 417
402void DateBook::insertEvent( const Event &e ) 418void DateBook::insertEvent( const Event &e )
403{ 419{
404 Event dupEvent=e; 420 Event dupEvent=e;
405 if(!dupEvent.isValidUid() ) // tkcRom seems to be different 421 if(!dupEvent.isValidUid() ) // tkcRom seems to be different
406 dupEvent.assignUid(); 422 dupEvent.assignUid();
407 dupEvent.setLocation(defaultLocation); 423 dupEvent.setLocation(defaultLocation);
408 dupEvent.setCategories(defaultCategories); 424 dupEvent.setCategories(defaultCategories);
409 db->addEvent(dupEvent); 425 db->addEvent(dupEvent);
410 emit newEvent(); 426 emit newEvent();
411} 427}
412 428
413void DateBook::duplicateEvent( const Event &e ) 429void DateBook::duplicateEvent( const Event &e )
414{ 430{
415 // Alot of code duplication, as this is almost like editEvent(); 431 // Alot of code duplication, as this is almost like editEvent();
416 if (syncing) { 432 if (syncing) {
417 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); 433 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
418 return; 434 return;
419 } 435 }
420 436
421 Event dupevent(e); // Make a duplicate. 437 Event dupevent(e); // Make a duplicate.
422 438
423 // workaround added for text input. 439 // workaround added for text input.
424 QDialog editDlg( this, 0, TRUE ); 440 QDialog editDlg( this, 0, TRUE );
425 DateEntry *entry; 441 DateEntry *entry;
426 editDlg.setCaption( tr("Duplicate Event") ); 442 editDlg.setCaption( tr("Duplicate Event") );
427 QVBoxLayout *vb = new QVBoxLayout( &editDlg ); 443 QVBoxLayout *vb = new QVBoxLayout( &editDlg );
428 QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); 444 QScrollView *sv = new QScrollView( &editDlg, "scrollview" );
429 sv->setResizePolicy( QScrollView::AutoOneFit ); 445 sv->setResizePolicy( QScrollView::AutoOneFit );
430 // KLUDGE!!! 446 // KLUDGE!!!
431 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 447 sv->setHScrollBarMode( QScrollView::AlwaysOff );
432 vb->addWidget( sv ); 448 vb->addWidget( sv );
433 entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" ); 449 entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" );
434 entry->timezone->setEnabled( FALSE ); 450 entry->timezone->setEnabled( FALSE );
435 sv->addChild( entry ); 451 sv->addChild( entry );
436 452
437 while ( QPEApplication::execDialog( &editDlg ) ) { 453 while ( QPEApplication::execDialog( &editDlg ) ) {
438 Event newEv = entry->event(); 454 Event newEv = entry->event();
439 QString error = checkEvent(newEv); 455 QString error = checkEvent(newEv);
440 if (!error.isNull()) { 456 if (!error.isNull()) {
441 if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) 457 if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0)
442 continue; 458 continue;
443 } 459 }
444 /* 460 /*
445 * The problem: 461 * The problem:
446 * DateBookDB does remove repeating events not by uid but by the time 462 * DateBookDB does remove repeating events not by uid but by the time
447 * the recurrence was created 463 * the recurrence was created
448 * so we need to update that time as well 464 * so we need to update that time as well
449 */ 465 */
450 Event::RepeatPattern rp = newEv.repeatPattern(); 466 Event::RepeatPattern rp = newEv.repeatPattern();
451 rp.createTime = ::time( NULL ); 467 rp.createTime = ::time( NULL );
452 newEv.setRepeat( TRUE, rp ); // has repeat and repeatPattern... 468 newEv.setRepeat( TRUE, rp ); // has repeat and repeatPattern...
453 if( newEv.uid() == e.uid() || !newEv.isValidUid() ) 469 if( newEv.uid() == e.uid() || !newEv.isValidUid() )
454 newEv.assignUid(); 470 newEv.assignUid();
455 471
456 db->addEvent(newEv); 472 db->addEvent(newEv);
457 emit newEvent(); 473 emit newEvent();
458 break; 474 break;
459 } 475 }
460} 476}
461 477
462void DateBook::editEvent( const Event &e ) 478void DateBook::editEvent( const Event &e )
463{ 479{
464 if (syncing) { 480 if (syncing) {
465 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); 481 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
466 return; 482 return;
467 } 483 }
468 484
469 // workaround added for text input. 485 // workaround added for text input.
470 QDialog editDlg( this, 0, TRUE ); 486 QDialog editDlg( this, 0, TRUE );
471 DateEntry *entry; 487 DateEntry *entry;
472 editDlg.setCaption( tr("Edit Event") ); 488 editDlg.setCaption( tr("Edit Event") );
473 QVBoxLayout *vb = new QVBoxLayout( &editDlg ); 489 QVBoxLayout *vb = new QVBoxLayout( &editDlg );
474 QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); 490 QScrollView *sv = new QScrollView( &editDlg, "scrollview" );
475 sv->setResizePolicy( QScrollView::AutoOneFit ); 491 sv->setResizePolicy( QScrollView::AutoOneFit );
476 // KLUDGE!!! 492 // KLUDGE!!!
477 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 493 sv->setHScrollBarMode( QScrollView::AlwaysOff );
478 vb->addWidget( sv ); 494 vb->addWidget( sv );
479 entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" ); 495 entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" );
480 entry->timezone->setEnabled( FALSE ); 496 entry->timezone->setEnabled( FALSE );
481 sv->addChild( entry ); 497 sv->addChild( entry );
482 498
483 while ( QPEApplication::execDialog( &editDlg ) ) { 499 while ( QPEApplication::execDialog( &editDlg ) ) {
484 Event newEv = entry->event(); 500 Event newEv = entry->event();
485 if(newEv.description().isEmpty() && newEv.notes().isEmpty() ) 501 if(newEv.description().isEmpty() && newEv.notes().isEmpty() )
486 break; 502 break;
487 newEv.setUid(e.uid()); // FIXME: Hack not to clear uid 503 newEv.setUid(e.uid()); // FIXME: Hack not to clear uid
488 QString error = checkEvent(newEv); 504 QString error = checkEvent(newEv);
489 if (!error.isNull()) { 505 if (!error.isNull()) {
490 if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) continue; 506 if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) continue;
491 } 507 }
492 db->editEvent(e, newEv); 508 db->editEvent(e, newEv);
493 emit newEvent(); 509 emit newEvent();
494 break; 510 break;
495 } 511 }
496} 512}
497 513
498void DateBook::removeEvent( const Event &e ) 514void DateBook::removeEvent( const Event &e )
499{ 515{
500 if (syncing) { 516 if (syncing) {
501 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); 517 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
502 return; 518 return;
503 } 519 }
504 520
505 QString strName = e.description(); 521 QString strName = e.description();
506 522
507 if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) 523 if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) )
508 return; 524 return;
509 525
510 db->removeEvent( e ); 526 db->removeEvent( e );
511 if ( views->visibleWidget() == dayView && dayView ) 527 if ( views->visibleWidget() == dayView && dayView )
512 dayView->redraw(); 528 dayView->redraw();
513 529
514} 530}
515 531
516void DateBook::addEvent( const Event &e ) 532void DateBook::addEvent( const Event &e )
517{ 533{
518 QDate d = e.start().date(); 534 QDate d = e.start().date();
519 initDay(); 535 initDay();
520 dayView->setDate( d ); 536 dayView->setDate( d );
521} 537}
522 538
523void DateBook::showDay( int year, int month, int day ) 539void DateBook::showDay( int year, int month, int day )
524{ 540{
525 QDate d(year, month, day); 541 QDate d(year, month, day);
526 view(DAY,d); 542 view(DAY,d);
527} 543}
528 544
529void DateBook::initDay() 545void DateBook::initDay()
530{ 546{
531 if ( !dayView ) { 547 if ( !dayView ) {
532 dayView = new DateBookDay( ampm, onMonday, db, db_holiday, views, "day view" ); 548 dayView = new DateBookDay( ampm, onMonday, db, db_holiday, views, "day view" );
533 views->addWidget( dayView, DAY ); 549 views->addWidget( dayView, DAY );
534 dayView->setJumpToCurTime( bJumpToCurTime ); 550 dayView->setJumpToCurTime( bJumpToCurTime );
535 dayView->setStartViewTime( startTime ); 551 dayView->setStartViewTime( startTime );
536 dayView->setRowStyle( rowStyle ); 552 dayView->setRowStyle( rowStyle );
537 connect( this, SIGNAL( newEvent() ), dayView, SLOT( redraw() ) ); 553 connect( this, SIGNAL( newEvent() ), dayView, SLOT( redraw() ) );
538 connect( dayView, SIGNAL( newEvent() ), this, SLOT( fileNew() ) ); 554 connect( dayView, SIGNAL( newEvent() ), this, SLOT( fileNew() ) );
539 connect( dayView, SIGNAL( removeEvent(const Event&) ), this, SLOT( removeEvent(const Event&) ) ); 555 connect( dayView, SIGNAL( removeEvent(const Event&) ), this, SLOT( removeEvent(const Event&) ) );
540 connect( dayView, SIGNAL( editEvent(const Event&) ), this, SLOT( editEvent(const Event&) ) ); 556 connect( dayView, SIGNAL( editEvent(const Event&) ), this, SLOT( editEvent(const Event&) ) );
541 connect( dayView, SIGNAL( duplicateEvent(const Event&) ), this, SLOT( duplicateEvent(const Event&) ) ); 557 connect( dayView, SIGNAL( duplicateEvent(const Event&) ), this, SLOT( duplicateEvent(const Event&) ) );
542 connect( dayView, SIGNAL( beamEvent(const Event&) ), this, SLOT( beamEvent(const Event&) ) ); 558 connect( dayView, SIGNAL( beamEvent(const Event&) ), this, SLOT( beamEvent(const Event&) ) );
543 connect( dayView, SIGNAL(sigNewEvent(const QString&)), this, SLOT(slotNewEventFromKey(const QString&)) ); 559 connect( dayView, SIGNAL(sigNewEvent(const QString&)), this, SLOT(slotNewEventFromKey(const QString&)) );
544 } 560 }
545} 561}
546 562
547void DateBook::initWeek() 563void DateBook::initWeek()
548{ 564{
549 if ( !weekView ) { 565 if ( !weekView ) {
550 weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); 566 weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" );
551 weekView->setStartViewTime( startTime ); 567 weekView->setStartViewTime( startTime );
552 views->addWidget( weekView, WEEK ); 568 views->addWidget( weekView, WEEK );
553 connect( weekView, SIGNAL( showDate(int,int,int) ), this, SLOT( showDay(int,int,int) ) ); 569 connect( weekView, SIGNAL( showDate(int,int,int) ), this, SLOT( showDay(int,int,int) ) );
554 connect( this, SIGNAL( newEvent() ), weekView, SLOT( redraw() ) ); 570 connect( this, SIGNAL( newEvent() ), weekView, SLOT( redraw() ) );
555 } 571 }
556 572
557 //But also get it right: the year that we display can be different 573 //But also get it right: the year that we display can be different
558 //from the year of the current date. So, first find the year 574 //from the year of the current date. So, first find the year
559 //number of the current week. 575 //number of the current week.
560 int yearNumber, totWeeks; 576 int yearNumber, totWeeks;
561 calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); 577 calcWeek( currentDate(), totWeeks, yearNumber, onMonday );
562 578
563 QDate d = QDate( yearNumber, 12, 31 ); 579 QDate d = QDate( yearNumber, 12, 31 );
564 calcWeek( d, totWeeks, yearNumber, onMonday ); 580 calcWeek( d, totWeeks, yearNumber, onMonday );
565 581
566 while ( totWeeks == 1 ) { 582 while ( totWeeks == 1 ) {
567 d = d.addDays( -1 ); 583 d = d.addDays( -1 );
568 calcWeek( d, totWeeks, yearNumber, onMonday ); 584 calcWeek( d, totWeeks, yearNumber, onMonday );
569 } 585 }
570} 586}
571 587
572void DateBook::initWeekLst() { 588void DateBook::initWeekLst() {
573 if ( !weekLstView ) { 589 if ( !weekLstView ) {
574 weekLstView = new DateBookWeekLst( ampm, onMonday, db, views, "weeklst view" ); 590 weekLstView = new DateBookWeekLst( ampm, onMonday, db, views, "weeklst view" );
575 views->addWidget( weekLstView, WEEKLST ); 591 views->addWidget( weekLstView, WEEKLST );
576 592
577 //weekLstView->setStartViewTime( startTime ); 593 //weekLstView->setStartViewTime( startTime );
578 connect( weekLstView, SIGNAL( showDate(int,int,int) ), this, SLOT( showDay(int,int,int) ) ); 594 connect( weekLstView, SIGNAL( showDate(int,int,int) ), this, SLOT( showDay(int,int,int) ) );
579 connect( weekLstView, SIGNAL( addEvent(const QDateTime&,const QDateTime&,const QString&, const QString&) ), 595 connect( weekLstView, SIGNAL( addEvent(const QDateTime&,const QDateTime&,const QString&, const QString&) ),
580 this, SLOT( slotNewEntry(const QDateTime&,const QDateTime&,const QString&, const QString&) ) ); 596 this, SLOT( slotNewEntry(const QDateTime&,const QDateTime&,const QString&, const QString&) ) );
581 connect( this, SIGNAL( newEvent() ), weekLstView, SLOT( redraw() ) ); 597 connect( this, SIGNAL( newEvent() ), weekLstView, SLOT( redraw() ) );
582 connect( weekLstView, SIGNAL( editEvent(const Event&) ), this, SLOT( editEvent(const Event&) ) ); 598 connect( weekLstView, SIGNAL( editEvent(const Event&) ), this, SLOT( editEvent(const Event&) ) );
583 connect( weekLstView, SIGNAL( duplicateEvent( const Event & ) ), this, SLOT( duplicateEvent( const Event & ) ) ); 599 connect( weekLstView, SIGNAL( duplicateEvent( const Event & ) ), this, SLOT( duplicateEvent( const Event & ) ) );
584 connect( weekLstView, SIGNAL( beamEvent(const Event&) ), this, SLOT( beamEvent(const Event&) ) ); 600 connect( weekLstView, SIGNAL( beamEvent(const Event&) ), this, SLOT( beamEvent(const Event&) ) );
585 connect( weekLstView, SIGNAL( removeEvent( const Event & ) ), this, SLOT( removeEvent( const Event & ) ) ); 601 connect( weekLstView, SIGNAL( removeEvent( const Event & ) ), this, SLOT( removeEvent( const Event & ) ) );
586 } 602 }
587} 603}
588 604
589 605
590void DateBook::initMonth() 606void DateBook::initMonth()
591{ 607{
592 if ( !monthView ) { 608 if ( !monthView ) {
593 monthView = new ODateBookMonth( views, "month view", FALSE, db ); 609 monthView = new ODateBookMonth( views, "month view", FALSE, db );
594 views->addWidget( monthView, MONTH ); 610 views->addWidget( monthView, MONTH );
595 connect( monthView, SIGNAL( dateClicked(int,int,int) ), this, SLOT( showDay(int,int,int) ) ); 611 connect( monthView, SIGNAL( dateClicked(int,int,int) ), this, SLOT( showDay(int,int,int) ) );
596 connect( this, SIGNAL( newEvent() ), monthView, SLOT( redraw() ) ); 612 connect( this, SIGNAL( newEvent() ), monthView, SLOT( redraw() ) );
597 qApp->processEvents(); 613 qApp->processEvents();
598 } 614 }
599} 615}
600 616
601void DateBook::loadSettings() 617void DateBook::loadSettings()
602{ 618{
603 Config qpeconfig( "qpe" ); 619 Config qpeconfig( "qpe" );
604 qpeconfig.setGroup("Time"); 620 qpeconfig.setGroup("Time");
605 ampm = qpeconfig.readBoolEntry( "AMPM", TRUE ); 621 ampm = qpeconfig.readBoolEntry( "AMPM", TRUE );
606 onMonday = qpeconfig.readBoolEntry( "MONDAY" ); 622 onMonday = qpeconfig.readBoolEntry( "MONDAY" );
607 623
608 Config config("DateBook"); 624 Config config("DateBook");
609 config.setGroup("Main"); 625 config.setGroup("Main");
610 startTime = config.readNumEntry("startviewtime", 8); 626 startTime = config.readNumEntry("startviewtime", 8);
611 aPreset = config.readBoolEntry("alarmpreset"); 627 aPreset = config.readBoolEntry("alarmpreset");
612 presetTime = config.readNumEntry("presettime"); 628 presetTime = config.readNumEntry("presettime");
613 bJumpToCurTime = config.readBoolEntry("jumptocurtime"); 629 bJumpToCurTime = config.readBoolEntry("jumptocurtime");
614 rowStyle = config.readNumEntry("rowstyle"); 630 rowStyle = config.readNumEntry("rowstyle");
615 defaultView = config.readNumEntry("defaultview",DAY); 631 defaultView = config.readNumEntry("defaultview",DAY);
616 weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL); 632 weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL);
617 633
618 defaultLocation=config.readEntry("defaultLocation"); 634 defaultLocation=config.readEntry("defaultLocation");
619 QString tmpString=config.readEntry("defaultCategories"); 635 QString tmpString=config.readEntry("defaultCategories");
620 QStringList tmpStringList=QStringList::split(",",tmpString); 636 QStringList tmpStringList=QStringList::split(",",tmpString);
621 defaultCategories.truncate(0); 637 defaultCategories.truncate(0);
622 638
623 for( QStringList::Iterator i=tmpStringList.begin(); i!=tmpStringList.end(); i++) { 639 for( QStringList::Iterator i=tmpStringList.begin(); i!=tmpStringList.end(); i++) {
624 defaultCategories.resize(defaultCategories.count()+1); 640 defaultCategories.resize(defaultCategories.count()+1);
625 defaultCategories[defaultCategories.count()-1]=(*i).toInt(); 641 defaultCategories[defaultCategories.count()-1]=(*i).toInt();
626 } 642 }
627} 643}
628 644
629void DateBook::saveSettings() 645void DateBook::saveSettings()
630{ 646{
631 Config config( "qpe" ); 647 Config config( "qpe" );
632 Config configDB( "DateBook" ); 648 Config configDB( "DateBook" );
633 configDB.setGroup( "Main" ); 649 configDB.setGroup( "Main" );
634 configDB.writeEntry("startviewtime",startTime); 650 configDB.writeEntry("startviewtime",startTime);
635 configDB.writeEntry("alarmpreset",aPreset); 651 configDB.writeEntry("alarmpreset",aPreset);
636 configDB.writeEntry("presettime",presetTime); 652 configDB.writeEntry("presettime",presetTime);
637 configDB.writeEntry("jumptocurtime", bJumpToCurTime); 653 configDB.writeEntry("jumptocurtime", bJumpToCurTime);
638 configDB.writeEntry("rowstyle", rowStyle); 654 configDB.writeEntry("rowstyle", rowStyle);
639 configDB.writeEntry("defaultview",defaultView); 655 configDB.writeEntry("defaultview",defaultView);
640 configDB.writeEntry("weeklistviewconfig",weeklistviewconfig); 656 configDB.writeEntry("weeklistviewconfig",weeklistviewconfig);
641 657
642 configDB.writeEntry("defaultLocation",defaultLocation); 658 configDB.writeEntry("defaultLocation",defaultLocation);
643 QStringList tmpStringList; 659 QStringList tmpStringList;
644 for( uint i=0; i<defaultCategories.count(); i++) { 660 for( uint i=0; i<defaultCategories.count(); i++) {
645 tmpStringList << QString::number(defaultCategories[i]); 661 tmpStringList << QString::number(defaultCategories[i]);
646 } 662 }
647 configDB.writeEntry("defaultCategories",tmpStringList.join(",")); 663 configDB.writeEntry("defaultCategories",tmpStringList.join(","));
648} 664}
649 665
650void DateBook::appMessage(const QCString& msg, const QByteArray& data) 666void DateBook::appMessage(const QCString& msg, const QByteArray& data)
651{ 667{
652 bool needShow = FALSE; 668 bool needShow = FALSE;
653 if ( msg == "alarm(QDateTime,int)" ) { 669 if ( msg == "alarm(QDateTime,int)" ) {
654 QDataStream ds(data,IO_ReadOnly); 670 QDataStream ds(data,IO_ReadOnly);
655 QDateTime when; int warn; 671 QDateTime when; int warn;
656 ds >> when >> warn; 672 ds >> when >> warn;
657 673
658 // check to make it's okay to continue, 674 // check to make it's okay to continue,
659 // this is the case that the time was set ahead, and 675 // this is the case that the time was set ahead, and
660 // we are forced given a stale alarm... 676 // we are forced given a stale alarm...
661 QDateTime current = QDateTime::currentDateTime(); 677 QDateTime current = QDateTime::currentDateTime();
662 if ( current.time().hour() != when.time().hour() && current.time().minute() != when.time().minute() ) 678 if ( current.time().hour() != when.time().hour() && current.time().minute() != when.time().minute() )
663 return; 679 return;
664 680
665 QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60)); 681 QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60));
666 if ( list.count() > 0 ) { 682 if ( list.count() > 0 ) {
667 QString msg; 683 QString msg;
668 bool bSound = FALSE; 684 bool bSound = FALSE;
669 int stopTimer = 0; 685 int stopTimer = 0;
670 bool found = FALSE; 686 bool found = FALSE;
671 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) { 687 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) {
672 if ( (*it).event().hasAlarm() ) { 688 if ( (*it).event().hasAlarm() ) {
673 found = TRUE; 689 found = TRUE;
674 msg += "<CENTER><B>" + (*it).description() + "</B>" 690 msg += "<CENTER><B>" + (*it).description() + "</B>"
675 + "<BR>" + (*it).location() + "<BR>" 691 + "<BR>" + (*it).location() + "<BR>"
676 + TimeString::dateString((*it).event().start(),ampm) 692 + TimeString::dateString((*it).event().start(),ampm)
677 + (warn 693 + (warn
678 ? tr(" (in " + QString::number(warn) 694 ? tr(" (in " + QString::number(warn)
679 + tr(" minutes)")) 695 + tr(" minutes)"))
680 : QString("")) 696 : QString(""))
681 + "<BR>" 697 + "<BR>"
682 + (*it).notes() + "</CENTER>"; 698 + (*it).notes() + "</CENTER>";
683 if ( (*it).event().alarmSound() != Event::Silent ) { 699 if ( (*it).event().alarmSound() != Event::Silent ) {
684 bSound = TRUE; 700 bSound = TRUE;
685 } 701 }
686 } 702 }
687 } 703 }
688 if ( found ) { 704 if ( found ) {
689 if ( bSound ) { 705 if ( bSound ) {
690 Sound::soundAlarm(); 706 Sound::soundAlarm();
691 alarmCounter = 0; 707 alarmCounter = 0;
692 stopTimer = startTimer( 5000 ); 708 stopTimer = startTimer( 5000 );
693 } 709 }
694 QDialog dlg( this, 0, TRUE ); 710 QDialog dlg( this, 0, TRUE );
695 QVBoxLayout *vb = new QVBoxLayout( &dlg ); 711 QVBoxLayout *vb = new QVBoxLayout( &dlg );
696 QScrollView *view = new QScrollView( &dlg, "scrollView"); 712 QScrollView *view = new QScrollView( &dlg, "scrollView");
697 view->setResizePolicy( QScrollView::AutoOneFit ); 713 view->setResizePolicy( QScrollView::AutoOneFit );
698 vb->addWidget( view ); 714 vb->addWidget( view );
699 QLabel *lblMsg = new QLabel( msg, &dlg ); 715 QLabel *lblMsg = new QLabel( msg, &dlg );
700 view->addChild( lblMsg ); 716 view->addChild( lblMsg );
701 QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg ); 717 QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg );
702 connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) ); 718 connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) );
703 vb->addWidget( cmdOk ); 719 vb->addWidget( cmdOk );
704 720
705 needShow = QPEApplication::execDialog( &dlg ); 721 needShow = QPEApplication::execDialog( &dlg );
706 722
707 if ( bSound ) 723 if ( bSound )
708 killTimer( stopTimer ); 724 killTimer( stopTimer );
709 } 725 }
710 } 726 }
711 } else if ( msg == "nextView()" ) { 727 } else if ( msg == "nextView()" ) {
712 needShow = true; 728 needShow = true;
713 if ( !qApp-> activeWindow ( )) { 729 if ( !qApp-> activeWindow ( )) {
714 needShow = TRUE; 730 needShow = TRUE;
715 } else { 731 } else {
716 QWidget* cur = views->visibleWidget(); 732 QWidget* cur = views->visibleWidget();
717 if ( cur ) { 733 if ( cur ) {
718 if ( cur == dayView ) 734 if ( cur == dayView )
719 viewWeek(); 735 viewWeek();
720 else if ( cur == weekView ) 736 else if ( cur == weekView )
721 viewWeekLst(); 737 viewWeekLst();
722 else if ( cur == weekLstView ) 738 else if ( cur == weekLstView )
723 viewMonth(); 739 viewMonth();
724 else if ( cur == monthView ) 740 else if ( cur == monthView )
725 viewDay(); 741 viewDay();
726 needShow = TRUE; 742 needShow = TRUE;
727 } 743 }
728 } 744 }
729 } else if (msg == "editEvent(int)") { 745 } else if (msg == "editEvent(int)") {
730 /* simple copy from receive */ 746 /* simple copy from receive */
731 QDataStream stream(data,IO_ReadOnly); 747 QDataStream stream(data,IO_ReadOnly);
732 int uid; 748 int uid;
733 stream >> uid; 749 stream >> uid;
734 Event e=db->eventByUID(uid); 750 Event e=db->eventByUID(uid);
735 editEvent(e); 751 editEvent(e);
736 } else if (msg == "viewDefault(QDate)"){ 752 } else if (msg == "viewDefault(QDate)"){
737 /* simple copy from receive */ 753 /* simple copy from receive */
738 QDataStream stream(data,IO_ReadOnly); 754 QDataStream stream(data,IO_ReadOnly);
739 QDate day; 755 QDate day;
740 stream >> day; 756 stream >> day;
741 viewDefault(day); 757 viewDefault(day);
742 needShow = true; 758 needShow = true;
743 } 759 }
744 760
745 if ( needShow ) { 761 if ( needShow ) {
746#if defined(Q_WS_QWS) || defined(_WS_QWS_) 762#if defined(Q_WS_QWS) || defined(_WS_QWS_)
747// showMaximized(); 763// showMaximized();
748#else 764#else
749// show(); 765// show();
750#endif 766#endif
751// raise(); 767// raise();
752 QPEApplication::setKeepRunning(); 768 QPEApplication::setKeepRunning();
753// setActiveWindow(); 769// setActiveWindow();
754 } 770 }
755} 771}
756 772
757void DateBook::reload() 773void DateBook::reload()
758{ 774{
759 db->reload(); 775 db->reload();
760 if ( dayAction->isOn() ) viewDay(); 776 if ( dayAction->isOn() ) viewDay();
761 else if ( weekAction->isOn() ) viewWeek(); 777 else if ( weekAction->isOn() ) viewWeek();
762 else if ( monthAction->isOn() ) viewMonth(); 778 else if ( monthAction->isOn() ) viewMonth();
763 syncing = FALSE; 779 syncing = FALSE;
764} 780}
765 781
766void DateBook::flush() 782void DateBook::flush()
767{ 783{
768 syncing = TRUE; 784 syncing = TRUE;
769 db->save(); 785 db->save();
770} 786}
771 787
772void DateBook::timerEvent( QTimerEvent *e ) 788void DateBook::timerEvent( QTimerEvent *e )
773{ 789{
774 if ( alarmCounter < 10 ) { 790 if ( alarmCounter < 10 ) {
775 alarmCounter++; 791 alarmCounter++;
776 Sound::soundAlarm(); 792 Sound::soundAlarm();
777 } else { 793 } else {
778 killTimer( e->timerId() ); 794 killTimer( e->timerId() );
779 } 795 }
780} 796}
781 797
782void DateBook::changeClock( bool newClock ) 798void DateBook::changeClock( bool newClock )
783{ 799{
784 ampm = newClock; 800 ampm = newClock;
785 // repaint the affected objects... 801 // repaint the affected objects...
786 if (dayView) dayView->redraw(); 802 if (dayView) dayView->redraw();
787 if (weekView) weekView->redraw(); 803 if (weekView) weekView->redraw();
788 if (weekLstView) weekLstView->redraw(); 804 if (weekLstView) weekLstView->redraw();
789} 805}
790 806
791void DateBook::changeWeek( bool m ) 807void DateBook::changeWeek( bool m )
792{ 808{
793 /* no need to redraw, each widget catches. Do need to 809 /* no need to redraw, each widget catches. Do need to
794 store though for widgets we haven't made yet */ 810 store though for widgets we haven't made yet */
795 onMonday = m; 811 onMonday = m;
796} 812}
797 813
798void DateBook::slotToday() 814void DateBook::slotToday()
799{ 815{
800 // we need to view today using default view 816 // we need to view today using default view
801 view(defaultView,QDate::currentDate()); 817 view(defaultView,QDate::currentDate());
802} 818}
803 819
804void DateBook::closeEvent( QCloseEvent *e ) 820void DateBook::closeEvent( QCloseEvent *e )
805{ 821{
806 if(syncing) { 822 if(syncing) {
807 /* no need to save, did that at flush */ 823 /* no need to save, did that at flush */
808 e->accept(); 824 e->accept();
809 return; 825 return;
810 } 826 }
811 827
812 // save settings will generate it's own error messages, no 828 // save settings will generate it's own error messages, no
813 // need to do checking ourselves. 829 // need to do checking ourselves.
814 saveSettings(); 830 saveSettings();
815 if ( db->save() ) { 831 if ( db->save() ) {
816 e->accept(); 832 e->accept();
817 } else { 833 } else {
818 if ( QMessageBox::critical( this, tr( "Out of space" ), 834 if ( QMessageBox::critical( this, tr( "Out of space" ),
819 tr("Calendar was unable to save\n" 835 tr("Calendar was unable to save\n"
820 "your changes.\n" 836 "your changes.\n"
821 "Free up some space and try again.\n" 837 "Free up some space and try again.\n"
822 "\nQuit anyway?"), 838 "\nQuit anyway?"),
823 QMessageBox::Yes|QMessageBox::Escape, 839 QMessageBox::Yes|QMessageBox::Escape,
824 QMessageBox::No|QMessageBox::Default ) 840 QMessageBox::No|QMessageBox::Default )
825 != QMessageBox::No ) 841 != QMessageBox::No )
826 e->accept(); 842 e->accept();
827 else 843 else
828 e->ignore(); 844 e->ignore();
829 } 845 }
830} 846}
831 847
832// Entering directly from the "keyboard" 848// Entering directly from the "keyboard"
833void DateBook::slotNewEventFromKey( const QString &str ) 849void DateBook::slotNewEventFromKey( const QString &str )
834{ 850{
835 if (syncing) { 851 if (syncing) {
836 QMessageBox::warning( this, tr("Calendar"), 852 QMessageBox::warning( this, tr("Calendar"),
837 tr( "Can not edit data, currently syncing") ); 853 tr( "Can not edit data, currently syncing") );
838 return; 854 return;
839 } 855 }
840 856
841 // We get to here from a key pressed in the Day View 857 // We get to here from a key pressed in the Day View
842 // So we can assume some things. We want the string 858 // So we can assume some things. We want the string
843 // passed in to be part of the description. 859 // passed in to be part of the description.
844 QDateTime start, end; 860 QDateTime start, end;
845 if ( views->visibleWidget() == dayView ) { 861 if ( views->visibleWidget() == dayView ) {
846 dayView->selectedDates( start, end ); 862 dayView->selectedDates( start, end );
847 } else if ( views->visibleWidget() == monthView ) { 863 } else if ( views->visibleWidget() == monthView ) {
848 QDate d = monthView->selectedDate(); 864 QDate d = monthView->selectedDate();
849 start = end = d; 865 start = end = d;
850 start.setTime( QTime( 10, 0 ) ); 866 start.setTime( QTime( 10, 0 ) );
851 end.setTime( QTime( 12, 0 ) ); 867 end.setTime( QTime( 12, 0 ) );
852 } else if ( views->visibleWidget() == weekView ) { 868 } else if ( views->visibleWidget() == weekView ) {
853 QDate d = weekView->date(); 869 QDate d = weekView->date();
854 start = end = d; 870 start = end = d;
855 start.setTime( QTime( 10, 0 ) ); 871 start.setTime( QTime( 10, 0 ) );
856 end.setTime( QTime( 12, 0 ) ); 872 end.setTime( QTime( 12, 0 ) );
857 } else if ( views->visibleWidget() == weekLstView ) { 873 } else if ( views->visibleWidget() == weekLstView ) {
858 QDate d = weekLstView->date(); 874 QDate d = weekLstView->date();
859 start = end = d; 875 start = end = d;
860 start.setTime( QTime( 10, 0 ) ); 876 start.setTime( QTime( 10, 0 ) );
861 end.setTime( QTime( 12, 0 ) ); 877 end.setTime( QTime( 12, 0 ) );
862 } 878 }
863 slotNewEntry(start, end, str); 879 slotNewEntry(start, end, str);
864} 880}
865void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location) { 881void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location) {
866 // argh! This really needs to be encapsulated in a class 882 // argh! This really needs to be encapsulated in a class
867 // or function. 883 // or function.
868 QDialog newDlg( this, 0, TRUE ); 884 QDialog newDlg( this, 0, TRUE );
869 newDlg.setCaption( DateEntryBase::tr("New Event") ); 885 newDlg.setCaption( DateEntryBase::tr("New Event") );
870 DateEntry *e; 886 DateEntry *e;
871 QVBoxLayout *vb = new QVBoxLayout( &newDlg ); 887 QVBoxLayout *vb = new QVBoxLayout( &newDlg );
872 QScrollView *sv = new QScrollView( &newDlg ); 888 QScrollView *sv = new QScrollView( &newDlg );
873 sv->setResizePolicy( QScrollView::AutoOneFit ); 889 sv->setResizePolicy( QScrollView::AutoOneFit );
874 sv->setFrameStyle( QFrame::NoFrame ); 890 sv->setFrameStyle( QFrame::NoFrame );
875 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 891 sv->setHScrollBarMode( QScrollView::AlwaysOff );
876 vb->addWidget( sv ); 892 vb->addWidget( sv );
877 893
878 Event ev; 894 Event ev;
879 ev.setDescription( str ); 895 ev.setDescription( str );
880 // When the new gui comes in, change this... 896 // When the new gui comes in, change this...
881 if(location==0) { 897 if(location==0) {
882 if(defaultLocation.isEmpty()) { 898 if(defaultLocation.isEmpty()) {
883 ev.setLocation(tr("(Unknown)")); 899 ev.setLocation(tr("(Unknown)"));
884 } else { 900 } else {
885 ev.setLocation( defaultLocation ); 901 ev.setLocation( defaultLocation );
886 } 902 }
887 } else { 903 } else {
888 ev.setLocation(location); 904 ev.setLocation(location);
889 } 905 }
890 ev.setCategories(defaultCategories); 906 ev.setCategories(defaultCategories);
891 ev.setStart( start ); 907 ev.setStart( start );
892 ev.setEnd( end ); 908 ev.setEnd( end );
893 909
894 e = new DateEntry( onMonday, ev, ampm, &newDlg ); 910 e = new DateEntry( onMonday, ev, ampm, &newDlg );
895 e->setAlarmEnabled( aPreset, presetTime, Event::Loud ); 911 e->setAlarmEnabled( aPreset, presetTime, Event::Loud );
896 sv->addChild( e ); 912 sv->addChild( e );
897 while ( QPEApplication::execDialog( &newDlg ) ) { 913 while ( QPEApplication::execDialog( &newDlg ) ) {
898 ev = e->event(); 914 ev = e->event();
899 ev.assignUid(); 915 ev.assignUid();
900 QString error = checkEvent( ev ); 916 QString error = checkEvent( ev );
901 if ( !error.isNull() ) { 917 if ( !error.isNull() ) {
902 if ( QMessageBox::warning( this, tr("Error!"), error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 ) 918 if ( QMessageBox::warning( this, tr("Error!"), error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 )
903 continue; 919 continue;
904 } 920 }
905 db->addEvent( ev ); 921 db->addEvent( ev );
906 emit newEvent(); 922 emit newEvent();
907 break; 923 break;
908 } 924 }
909} 925}
910 926
911void DateBook::setDocument( const QString &filename ) 927void DateBook::setDocument( const QString &filename )
912{ 928{
913 if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; 929 if ( filename.find(".vcs") != int(filename.length()) - 4 ) return;
914 930
915 QValueList<Event> tl = Event::readVCalendar( filename ); 931 QValueList<Event> tl = Event::readVCalendar( filename );
916 for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) { 932 for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) {
917 db->addEvent( *it ); 933 db->addEvent( *it );
918 } 934 }
919} 935}
920 936
921static const char * beamfile = "/tmp/obex/event.vcs"; 937static const char * beamfile = "/tmp/obex/event.vcs";
922 938
923void DateBook::beamEvent( const Event &e ) 939void DateBook::beamEvent( const Event &e )
924{ 940{
925 odebug << "trying to beam" << oendl; 941 odebug << "trying to beam" << oendl;
926 unlink( beamfile ); // delete if exists 942 unlink( beamfile ); // delete if exists
927 mkdir("/tmp/obex/", 0755); 943 mkdir("/tmp/obex/", 0755);
928 Event::writeVCalendar( beamfile, e ); 944 Event::writeVCalendar( beamfile, e );
929 Ir *ir = new Ir( this ); 945 Ir *ir = new Ir( this );
930 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 946 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
931 QString description = e.description(); 947 QString description = e.description();
932 ir->send( beamfile, description, "text/x-vCalendar" ); 948 ir->send( beamfile, description, "text/x-vCalendar" );
933} 949}
934 950
935void DateBook::beamDone( Ir *ir ) 951void DateBook::beamDone( Ir *ir )
936{ 952{
937 delete ir; 953 delete ir;
938 unlink( beamfile ); 954 unlink( beamfile );
939} 955}
940 956
941void DateBook::slotFind() 957void DateBook::slotFind()
942{ 958{
943 // move it to the day view... 959 // move it to the day view...
944 viewDay(); 960 viewDay();
945 FindDialog frmFind( "Calendar", this ); // no tr needed 961 FindDialog frmFind( "Calendar", this ); // no tr needed
946 frmFind.setUseDate( true ); 962 frmFind.setUseDate( true );
947 frmFind.setDate( currentDate() ); 963 frmFind.setDate( currentDate() );
948 QObject::connect( &frmFind, 964 QObject::connect( &frmFind,
949 SIGNAL(signalFindClicked(const QString&,const QDate&,bool,bool,int)), 965 SIGNAL(signalFindClicked(const QString&,const QDate&,bool,bool,int)),
950 this, 966 this,
951 SLOT(slotDoFind(const QString&,const QDate&,bool,bool,int)) ); 967 SLOT(slotDoFind(const QString&,const QDate&,bool,bool,int)) );
952 QObject::connect( this, 968 QObject::connect( this,
953 SIGNAL(signalNotFound()), 969 SIGNAL(signalNotFound()),
954 &frmFind, 970 &frmFind,
955 SLOT(slotNotFound()) ); 971 SLOT(slotNotFound()) );
956 QObject::connect( this, 972 QObject::connect( this,
957 SIGNAL(signalWrapAround()), 973 SIGNAL(signalWrapAround()),
958 &frmFind, 974 &frmFind,
959 SLOT(slotWrapAround()) ); 975 SLOT(slotWrapAround()) );
960 frmFind.move(0,0); 976 frmFind.move(0,0);
961 frmFind.exec(); 977 frmFind.exec();
962 inSearch = false; 978 inSearch = false;
963} 979}
964 980
965bool catComp( QArray<int> cats, int category ) 981bool catComp( QArray<int> cats, int category )
966{ 982{
967 bool returnMe; 983 bool returnMe;
968 int i, 984 int i,
969 count; 985 count;
970 986
971 count = int(cats.count()); 987 count = int(cats.count());
972 returnMe = false; 988 returnMe = false;
973 if ( (category == -1 && count == 0) || category == -2 ) 989 if ( (category == -1 && count == 0) || category == -2 )
974 returnMe = true; 990 returnMe = true;
975 else { 991 else {
976 for ( i = 0; i < count; i++ ) { 992 for ( i = 0; i < count; i++ ) {
977 if ( category == cats[i] ) { 993 if ( category == cats[i] ) {
978 returnMe = true; 994 returnMe = true;
979 break; 995 break;
980 } 996 }
981 } 997 }
982 } 998 }
983 return returnMe; 999 return returnMe;
984} 1000}
985 1001
986 1002
987void DateBook::slotDoFind( const QString& txt, const QDate &dt, 1003void DateBook::slotDoFind( const QString& txt, const QDate &dt,
988 bool caseSensitive, bool /*backwards*/, 1004 bool caseSensitive, bool /*backwards*/,
989 int category ) 1005 int category )
990{ 1006{
991 QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ), 1007 QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ),
992 next; 1008 next;
993 1009
994 QRegExp r( txt ); 1010 QRegExp r( txt );
995 r.setCaseSensitive( caseSensitive ); 1011 r.setCaseSensitive( caseSensitive );
996 1012
997 1013
998 static Event rev, nonrev; 1014 static Event rev, nonrev;
999 if ( !inSearch ) { 1015 if ( !inSearch ) {
1000 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); 1016 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) );
1001 nonrev.setStart( rev.start() ); 1017 nonrev.setStart( rev.start() );
1002 inSearch = true; 1018 inSearch = true;
1003 } 1019 }
1004 static QDate searchDate = dt; 1020 static QDate searchDate = dt;
1005 // if true at the end we will start at the begin again and afterwards 1021 // if true at the end we will start at the begin again and afterwards
1006 // we will emit string not found 1022 // we will emit string not found
1007 static bool wrapAround = true; 1023 static bool wrapAround = true;
1008 bool candidtate; 1024 bool candidtate;
1009 candidtate = false; 1025 candidtate = false;
1010 1026
1011 QValueList<Event> repeats = db->getRawRepeats(); 1027 QValueList<Event> repeats = db->getRawRepeats();
1012 1028
1013 // find the candidate for the first repeat that matches... 1029 // find the candidate for the first repeat that matches...
1014 // first check if there can ever be a match and then compute 1030 // first check if there can ever be a match and then compute
1015 // the next occurence from start. See if this event is closer 1031 // the next occurence from start. See if this event is closer
1016 // to the beginning (start. next < dtEnd) and not smaller then the last 1032 // to the beginning (start. next < dtEnd) and not smaller then the last
1017 // result. If we find a canditate we set the dtEnd to the time 1033 // result. If we find a canditate we set the dtEnd to the time
1018 // of the ocurrence and rev to this occurence. 1034 // of the ocurrence and rev to this occurence.
1019 // set wrap around to true because there might be more events coming 1035 // set wrap around to true because there might be more events coming
1020 // and we're not at the end. 1036 // and we're not at the end.
1021 QValueListConstIterator<Event> it; 1037 QValueListConstIterator<Event> it;
1022 QDate start = dt; 1038 QDate start = dt;
1023 for ( it = repeats.begin(); it != repeats.end(); ++it ) { 1039 for ( it = repeats.begin(); it != repeats.end(); ++it ) {
1024 if ( catComp( (*it).categories(), category ) ) { 1040 if ( catComp( (*it).categories(), category ) ) {
1025 if ( (*it).match( r ) ) { 1041 if ( (*it).match( r ) ) {
1026 if ( nextOccurance( *it, start, next ) ) { 1042 if ( nextOccurance( *it, start, next ) ) {
1027 if ( next < dtEnd && !(next <= rev.start() ) ) { 1043 if ( next < dtEnd && !(next <= rev.start() ) ) {
1028 rev = *it; 1044 rev = *it;
1029 dtEnd = next; 1045 dtEnd = next;
1030 rev.setStart( next ); 1046 rev.setStart( next );
1031 candidtate = true; 1047 candidtate = true;
1032 wrapAround = true; 1048 wrapAround = true;
1033 } 1049 }
1034 } 1050 }
1035 } 1051 }
1036 } 1052 }
1037 } 1053 }
1038 1054
1039 // now the for first non repeat... 1055 // now the for first non repeat...
1040 // dtEnd is set by the previous iteration of repeatingEvents 1056 // dtEnd is set by the previous iteration of repeatingEvents
1041 // check if we find a closer item. Also set dtEnd to find even 1057 // check if we find a closer item. Also set dtEnd to find even
1042 // more close occurrence 1058 // more close occurrence
1043 QValueList<Event> nonRepeats = db->getNonRepeatingEvents( dt, dtEnd.date() ); 1059 QValueList<Event> nonRepeats = db->getNonRepeatingEvents( dt, dtEnd.date() );
1044 qHeapSort( nonRepeats.begin(), nonRepeats.end() ); 1060 qHeapSort( nonRepeats.begin(), nonRepeats.end() );
1045 for ( it = nonRepeats.begin(); it != nonRepeats.end(); ++it ) { 1061 for ( it = nonRepeats.begin(); it != nonRepeats.end(); ++it ) {
1046 if ( catComp( (*it).categories(), category ) ) { 1062 if ( catComp( (*it).categories(), category ) ) {
1047 if ( (*it).start() < dtEnd ) { 1063 if ( (*it).start() < dtEnd ) {
1048 if ( (*it).match( r ) && !(*it <= nonrev) ) { 1064 if ( (*it).match( r ) && !(*it <= nonrev) ) {
1049 nonrev = *it; 1065 nonrev = *it;
1050 dtEnd = nonrev.start(); 1066 dtEnd = nonrev.start();
1051 candidtate = true; 1067 candidtate = true;
1052 wrapAround = true; 1068 wrapAround = true;
1053 break; 1069 break;
1054 } 1070 }
1055 } 1071 }
1056 } 1072 }
1057 } 1073 }
1058 if ( candidtate ) { 1074 if ( candidtate ) {
1059 dayView->setStartViewTime( dtEnd.time().hour() ); 1075 dayView->setStartViewTime( dtEnd.time().hour() );
1060 dayView->setDate( dtEnd.date().year(), dtEnd.date().month(), 1076 dayView->setDate( dtEnd.date().year(), dtEnd.date().month(),
1061 dtEnd.date().day() ); 1077 dtEnd.date().day() );
1062 } else { 1078 } else {
1063 if ( wrapAround ) { 1079 if ( wrapAround ) {
1064 emit signalWrapAround(); 1080 emit signalWrapAround();
1065 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); 1081 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) );
1066 nonrev.setStart( rev.start() ); 1082 nonrev.setStart( rev.start() );
1067 } else 1083 } else
1068 emit signalNotFound(); 1084 emit signalNotFound();
1069 wrapAround = !wrapAround; 1085 wrapAround = !wrapAround;
1070 } 1086 }
1071} 1087}
1072 1088
1073Event DateBookDBHack::eventByUID(int uid) { 1089Event DateBookDBHack::eventByUID(int uid) {
1074 1090
1075 // FIXME: Dirty Hacks to get hold of the private event lists 1091 // FIXME: Dirty Hacks to get hold of the private event lists
1076 QDate start; 1092 QDate start;
1077 QDate end=start.addDays(-1); 1093 QDate end=start.addDays(-1);
1078 QValueList<Event> myEventList=getNonRepeatingEvents(start,end); 1094 QValueList<Event> myEventList=getNonRepeatingEvents(start,end);
1079 QValueList<Event> myRepeatEvents=getRawRepeats(); 1095 QValueList<Event> myRepeatEvents=getRawRepeats();
1080 1096
1081 QValueList<Event>::ConstIterator it; 1097 QValueList<Event>::ConstIterator it;
1082 1098
1083 for (it = myEventList.begin(); it != myEventList.end(); it++) { 1099 for (it = myEventList.begin(); it != myEventList.end(); it++) {
1084 if ((*it).uid() == uid) return *it; 1100 if ((*it).uid() == uid) return *it;
1085 } 1101 }
1086 for (it = myRepeatEvents.begin(); it != myRepeatEvents.end(); it++) { 1102 for (it = myRepeatEvents.begin(); it != myRepeatEvents.end(); it++) {
1087 if ((*it).uid() == uid) return *it; 1103 if ((*it).uid() == uid) return *it;
1088 } 1104 }
1089 1105
1090 Event ev; 1106 Event ev;
1091 return ev; // return at least 1107 return ev; // return at least
1092} 1108}
1093 1109
1094DateBookHoliday::DateBookHoliday() 1110DateBookHoliday::DateBookHoliday()
1095{ 1111{
1096 _pluginlist.clear(); 1112 _pluginlist.clear();
1097 m_pluginLoader = new Opie::Core::OPluginLoader("holidays",false); 1113 m_pluginLoader = new Opie::Core::OPluginLoader("holidays",false);
1098 m_pluginLoader->setAutoDelete(true); 1114 m_pluginLoader->setAutoDelete(true);
1099 m_pluginManager = new Opie::Core::OPluginManager(m_pluginLoader); 1115 m_pluginManager = new Opie::Core::OPluginManager(m_pluginLoader);
1100 m_pluginManager->load(); 1116 m_pluginManager->load();
1101 1117
1102 init(); 1118 init();
1103} 1119}
1104 1120
1105void DateBookHoliday::reloadPlugins() 1121void DateBookHoliday::reloadPlugins()
1106{ 1122{
1107 deinit(); 1123 deinit();
1108 init(); 1124 init();
1109} 1125}
1110 1126
1111DateBookHoliday::~DateBookHoliday() 1127DateBookHoliday::~DateBookHoliday()
1112{ 1128{
1113 deinit(); 1129 deinit();
1114 delete m_pluginLoader; 1130 delete m_pluginLoader;
1115 delete m_pluginManager; 1131 delete m_pluginManager;
1116} 1132}
1117 1133
1118void DateBookHoliday::deinit() 1134void DateBookHoliday::deinit()
1119{ 1135{
1120 QValueList<HPlugin*>::Iterator it; 1136 QValueList<HPlugin*>::Iterator it;
1121 for (it=_pluginlist.begin();it!=_pluginlist.end();++it) { 1137 for (it=_pluginlist.begin();it!=_pluginlist.end();++it) {
1122 HPlugin*_pl = *it; 1138 HPlugin*_pl = *it;
1123 *it = 0; 1139 *it = 0;
1124 delete _pl; 1140 delete _pl;
1125 } 1141 }
1126 _pluginlist.clear(); 1142 _pluginlist.clear();
1127} 1143}
1128 1144
1129#if 0 1145#if 0
1130void debugLst( const Opie::Core::OPluginItem::List& lst ) { 1146void debugLst( const Opie::Core::OPluginItem::List& lst ) {
1131 for ( Opie::Core::OPluginItem::List::ConstIterator it = lst.begin(); it != lst.end(); ++it ) 1147 for ( Opie::Core::OPluginItem::List::ConstIterator it = lst.begin(); it != lst.end(); ++it )
1132 odebug << "Name " << (*it).name() << " " << (*it).path() << " " << (*it).position() << oendl; 1148 odebug << "Name " << (*it).name() << " " << (*it).path() << " " << (*it).position() << oendl;
1133} 1149}
1134#endif 1150#endif
1135 1151
1136void DateBookHoliday::init() 1152void DateBookHoliday::init()
1137{ 1153{
1138 deinit(); 1154 deinit();
1139 1155
1140 Opie::Core::OPluginItem::List lst = m_pluginLoader->filtered(true); 1156 Opie::Core::OPluginItem::List lst = m_pluginLoader->filtered(true);
1141// debugLst( lst ); 1157// debugLst( lst );
1142 for( Opie::Core::OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ){ 1158 for( Opie::Core::OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ){
1143 Opie::Datebook::HolidayPluginIf*hif = m_pluginLoader->load<Opie::Datebook::HolidayPluginIf>(*it,IID_HOLIDAY_PLUGIN); 1159 Opie::Datebook::HolidayPluginIf*hif = m_pluginLoader->load<Opie::Datebook::HolidayPluginIf>(*it,IID_HOLIDAY_PLUGIN);
1144 if (hif) { 1160 if (hif) {
1145 Opie::Datebook::HolidayPlugin*pl = hif->plugin(); 1161 Opie::Datebook::HolidayPlugin*pl = hif->plugin();
1146 if (pl) { 1162 if (pl) {
1147 HPlugin*_pl=new HPlugin; 1163 HPlugin*_pl=new HPlugin;
1148 _pl->_plugin = pl; 1164 _pl->_plugin = pl;
1149 odebug << "Found holiday " << pl->description()<<oendl; 1165 odebug << "Found holiday " << pl->description()<<oendl;
1150 _pluginlist.append(_pl); 1166 _pluginlist.append(_pl);
1151 //_pl->_if = hif; 1167 //_pl->_if = hif;
1152 } 1168 }
1153 } 1169 }
1154 } 1170 }
1155} 1171}
1156 1172
1157QStringList DateBookHoliday::holidaylist(const QDate&aDate) 1173QStringList DateBookHoliday::holidaylist(const QDate&aDate)
1158{ 1174{
1159 QStringList ret; 1175 QStringList ret;
1160 QValueList<HPlugin*>::Iterator it; 1176 QValueList<HPlugin*>::Iterator it;
1161 for (it=_pluginlist.begin();it!=_pluginlist.end();++it) { 1177 for (it=_pluginlist.begin();it!=_pluginlist.end();++it) {
1162 HPlugin*_pl = *it; 1178 HPlugin*_pl = *it;
1163 ret+=_pl->_plugin->entries(aDate); 1179 ret+=_pl->_plugin->entries(aDate);
1164 } 1180 }
1165 return ret; 1181 return ret;
1166} 1182}
1167 1183
1168QStringList DateBookHoliday::holidaylist(unsigned year, unsigned month, unsigned day) 1184QStringList DateBookHoliday::holidaylist(unsigned year, unsigned month, unsigned day)
1169{ 1185{
1170 return holidaylist(QDate(year,month,day)); 1186 return holidaylist(QDate(year,month,day));
1171} 1187}
1172 1188
1173QValueList<EffectiveEvent> DateBookHoliday::getEffectiveEvents(const QDate &from,const QDate &to ) 1189QValueList<EffectiveEvent> DateBookHoliday::getEffectiveEvents(const QDate &from,const QDate &to )
1174{ 1190{
1175 QValueList<EffectiveEvent> ret; 1191 QValueList<EffectiveEvent> ret;
1176 QValueList<HPlugin*>::Iterator it; 1192 QValueList<HPlugin*>::Iterator it;
1177 for (it=_pluginlist.begin();it!=_pluginlist.end();++it) { 1193 for (it=_pluginlist.begin();it!=_pluginlist.end();++it) {
1178 HPlugin*_pl = *it; 1194 HPlugin*_pl = *it;
1179 ret+=_pl->_plugin->events(from,to); 1195 ret+=_pl->_plugin->events(from,to);
1180 } 1196 }
1181 return ret; 1197 return ret;
1182} 1198}
1183 1199
1184QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEventsNoHoliday(const QDate &from,const QDate &to ) 1200QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEventsNoHoliday(const QDate &from,const QDate &to )
1185{ 1201{
1186 return DateBookDBHack::getEffectiveEvents(from,to); 1202 return DateBookDBHack::getEffectiveEvents(from,to);
1187} 1203}
1188 1204
1189QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEventsNoHoliday(const QDateTime &start) 1205QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEventsNoHoliday(const QDateTime &start)
1190{ 1206{
1191 return DateBookDBHack::getEffectiveEvents(start); 1207 return DateBookDBHack::getEffectiveEvents(start);
1192} 1208}
1193 1209
1194QValueList<EffectiveEvent> DateBookHoliday::getEffectiveEvents(const QDateTime &start) 1210QValueList<EffectiveEvent> DateBookHoliday::getEffectiveEvents(const QDateTime &start)
1195{ 1211{
1196 return getEffectiveEvents(start.date(),start.date()); 1212 return getEffectiveEvents(start.date(),start.date());
1197} 1213}
1198 1214
1199QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEvents(const QDate &from,const QDate &to ) 1215QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEvents(const QDate &from,const QDate &to )
1200{ 1216{
1201 QValueList<EffectiveEvent> ret; 1217 QValueList<EffectiveEvent> ret;
1202 odebug << "Ueberlagert 1" << oendl; 1218 odebug << "Ueberlagert 1" << oendl;
1203 if (db_holiday) { 1219 if (db_holiday) {
1204 ret+=db_holiday->getEffectiveEvents(from,to); 1220 ret+=db_holiday->getEffectiveEvents(from,to);
1205 } 1221 }
1206 ret+=getEffectiveEventsNoHoliday(from,to); 1222 ret+=getEffectiveEventsNoHoliday(from,to);
1207 return ret; 1223 return ret;
1208} 1224}
1209 1225
1210QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEvents( const QDateTime &start) 1226QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEvents( const QDateTime &start)
1211{ 1227{
1212 odebug << "Ueberlagert 2" << oendl; 1228 odebug << "Ueberlagert 2" << oendl;
1213 return DateBookDBHack::getEffectiveEvents(start); 1229 return DateBookDBHack::getEffectiveEvents(start);
1214} 1230}
diff --git a/core/pim/datebook/datebook.h b/core/pim/datebook/datebook.h
index 05ab781..c12f5c4 100644
--- a/core/pim/datebook/datebook.h
+++ b/core/pim/datebook/datebook.h
@@ -1,134 +1,145 @@
1/********************************************************************** 1/*
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2                 This file is part of the Opie Project
3** 3
4** This file is part of Qtopia Environment. 4 Copyright (C) Opie Team <opie-devel@handhelds.org>
5** 5 =.
6** This file may be distributed and/or modified under the terms of the 6 .=l.
7** GNU General Public License version 2 as published by the Free Software 7           .>+-=
8** Foundation and appearing in the file LICENSE.GPL included in the 8 _;:,     .>    :=|. This program is free software; you can
9** packaging of this file. 9.> <`_,   >  .   <= redistribute it and/or modify it under
10** 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11.="- .-=="i,     .._ License as published by the Free Software
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13** 13     ._= =}       : or (at your option) any later version.
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14    .%`+i>       _;_.
15** 15    .i_,=:_.      -<s. This program is distributed in the hope that
16** Contact info@trolltech.com if any conditions of this licensing are 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17** not clear to you. 17 : ..    .:,     . . . without even the implied warranty of
18** 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19**********************************************************************/ 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details.
22:     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA.
29*/
30
20#ifndef DATEBOOK_H 31#ifndef DATEBOOK_H
21#define DATEBOOK_H 32#define DATEBOOK_H
22 33
23#include "datebooktypes.h" 34#include "datebooktypes.h"
24 35
25#include <qpe/datebookdb.h> 36#include <qpe/datebookdb.h>
26 37
27#include <qmainwindow.h> 38#include <qmainwindow.h>
28 39
29class QAction; 40class QAction;
30class QWidgetStack; 41class QWidgetStack;
31class DateBookDay; 42class DateBookDay;
32class DateBookWeek; 43class DateBookWeek;
33class DateBookWeekLst; 44class DateBookWeekLst;
34class ODateBookMonth; 45class ODateBookMonth;
35class Event; 46class Event;
36class QDate; 47class QDate;
37class Ir; 48class Ir;
38 49
39class DateBook : public QMainWindow 50class DateBook : public QMainWindow
40{ 51{
41 Q_OBJECT 52 Q_OBJECT
42 53
43public: 54public:
44 static QString appName() { return QString::fromLatin1("datebook"); } 55 static QString appName() { return QString::fromLatin1("datebook"); }
45 DateBook( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 56 DateBook( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
46 ~DateBook(); 57 ~DateBook();
47 58
48signals: 59signals:
49 void newEvent(); 60 void newEvent();
50 void signalNotFound(); 61 void signalNotFound();
51 void signalWrapAround(); 62 void signalWrapAround();
52 63
53protected: 64protected:
54 QDate currentDate(); 65 QDate currentDate();
55 void timerEvent( QTimerEvent *e ); 66 void timerEvent( QTimerEvent *e );
56 void closeEvent( QCloseEvent *e ); 67 void closeEvent( QCloseEvent *e );
57 68
58 void view(int v, const QDate &d); 69 void view(int v, const QDate &d);
59 70
60public slots: 71public slots:
61 void flush(); 72 void flush();
62 void reload(); 73 void reload();
63 74
64private slots: 75private slots:
65 void fileNew(); 76 void fileNew();
66 void slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location=0); 77 void slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location=0);
67 void slotSettings(); 78 void slotSettings();
68 void slotToday(); // view today 79 void slotToday(); // view today
69 void changeClock( bool newClock ); 80 void changeClock( bool newClock );
70 void changeWeek( bool newDay ); 81 void changeWeek( bool newDay );
71 void appMessage(const QCString& msg, const QByteArray& data); 82 void appMessage(const QCString& msg, const QByteArray& data);
72 // handle key events in the day view... 83 // handle key events in the day view...
73 void slotNewEventFromKey( const QString &str ); 84 void slotNewEventFromKey( const QString &str );
74 void slotFind(); 85 void slotFind();
75 void slotDoFind( const QString &, const QDate &, bool, bool, int ); 86 void slotDoFind( const QString &, const QDate &, bool, bool, int );
76 87
77 void viewDefault(const QDate &d); 88 void viewDefault(const QDate &d);
78 89
79 void viewDay(); 90 void viewDay();
80 void viewWeek(); 91 void viewWeek();
81 void viewWeekLst(); 92 void viewWeekLst();
82 void viewMonth(); 93 void viewMonth();
83 94
84 void showDay( int y, int m, int d ); 95 void showDay( int y, int m, int d );
85 96
86 void insertEvent( const Event &e ); 97 void insertEvent( const Event &e );
87 void editEvent( const Event &e ); 98 void editEvent( const Event &e );
88 void duplicateEvent( const Event &e ); 99 void duplicateEvent( const Event &e );
89 void removeEvent( const Event &e ); 100 void removeEvent( const Event &e );
90 101
91 void receive( const QCString &msg, const QByteArray &data ); 102 void receive( const QCString &msg, const QByteArray &data );
92 void setDocument( const QString & ); 103 void setDocument( const QString & );
93 void beamEvent( const Event &e ); 104 void beamEvent( const Event &e );
94 void beamDone( Ir *ir ); 105 void beamDone( Ir *ir );
95 106
96private: 107private:
97 void addEvent( const Event &e ); 108 void addEvent( const Event &e );
98 void initDay(); 109 void initDay();
99 void initWeek(); 110 void initWeek();
100 void initWeekLst(); 111 void initWeekLst();
101 void initMonth(); 112 void initMonth();
102 void loadSettings(); 113 void loadSettings();
103 void saveSettings(); 114 void saveSettings();
104 115
105private: 116private:
106 DateBookDBHoliday *db; 117 DateBookDBHoliday *db;
107 DateBookHoliday*db_holiday; 118 DateBookHoliday*db_holiday;
108 QWidgetStack *views; 119 QWidgetStack *views;
109 DateBookDay *dayView; 120 DateBookDay *dayView;
110 DateBookWeek *weekView; 121 DateBookWeek *weekView;
111 ODateBookMonth *monthView; 122 ODateBookMonth *monthView;
112 DateBookWeekLst *weekLstView; 123 DateBookWeekLst *weekLstView;
113 QAction *dayAction, *weekAction, *weekLstAction, *monthAction; 124 QAction *dayAction, *weekAction, *weekLstAction, *monthAction;
114 int weeklistviewconfig; 125 int weeklistviewconfig;
115 bool aPreset; // have everything set to alarm? 126 bool aPreset; // have everything set to alarm?
116 int presetTime; // the standard time for the alarm 127 int presetTime; // the standard time for the alarm
117 int startTime; 128 int startTime;
118 int rowStyle; 129 int rowStyle;
119 int defaultView; 130 int defaultView;
120 QArray<int> defaultCategories; 131 QArray<int> defaultCategories;
121 QString defaultLocation; 132 QString defaultLocation;
122 bool bJumpToCurTime; //should jump to current time in dayview? 133 bool bJumpToCurTime; //should jump to current time in dayview?
123 bool ampm; 134 bool ampm;
124 bool onMonday; 135 bool onMonday;
125 136
126 bool syncing; 137 bool syncing;
127 bool inSearch; 138 bool inSearch;
128 139
129 int alarmCounter; 140 int alarmCounter;
130 141
131 QString checkEvent(const Event &); 142 QString checkEvent(const Event &);
132}; 143};
133 144
134#endif 145#endif
diff --git a/core/pim/datebook/datebookday.cpp b/core/pim/datebook/datebookday.cpp
index 26f0303..b8385aa 100644
--- a/core/pim/datebook/datebookday.cpp
+++ b/core/pim/datebook/datebookday.cpp
@@ -1,947 +1,961 @@
1/********************************************************************** 1/*
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2                 This file is part of the Opie Project
3** 3
4** This file is part of Qtopia Environment. 4 Copyright (C) Opie Team <opie-devel@handhelds.org>
5** 5 =.
6** This file may be distributed and/or modified under the terms of the 6 .=l.
7** GNU General Public License version 2 as published by the Free Software 7           .>+-=
8** Foundation and appearing in the file LICENSE.GPL included in the 8 _;:,     .>    :=|. This program is free software; you can
9** packaging of this file. 9.> <`_,   >  .   <= redistribute it and/or modify it under
10** 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11.="- .-=="i,     .._ License as published by the Free Software
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13** 13     ._= =}       : or (at your option) any later version.
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14    .%`+i>       _;_.
15** 15    .i_,=:_.      -<s. This program is distributed in the hope that
16** Contact info@trolltech.com if any conditions of this licensing are 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17** not clear to you. 17 : ..    .:,     . . . without even the implied warranty of
18** 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19**********************************************************************/ 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details.
22:     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA.
29*/
20 30
21#include "datebookday.h" 31#include "datebookday.h"
22#include "datebooktypes.h" 32#include "datebooktypes.h"
23#include "datebookdayheaderimpl.h" 33#include "datebookdayheaderimpl.h"
24#include "datebookdayallday.h" 34#include "datebookdayallday.h"
25 35
26#include <opie2/oholidayplugin.h> 36#include <opie2/oholidayplugin.h>
27#include <qpe/resource.h> 37#include <opie2/oresource.h>
28#include <qpe/qpeapplication.h> 38
39#include <qpe/applnk.h>
29#include <qpe/ir.h> 40#include <qpe/ir.h>
41#include <qpe/qpeapplication.h>
30 42
31#include <qsimplerichtext.h> 43#include <qsimplerichtext.h>
32#include <qpopupmenu.h> 44#include <qpopupmenu.h>
33 45
34 46
35#include <qtimer.h> 47#include <qtimer.h>
36 48
37DateBookDayView::DateBookDayView( bool whichClock, QWidget *parent, const char *name ) 49DateBookDayView::DateBookDayView( bool whichClock, QWidget *parent, const char *name )
38 : QTable( 24, 1, parent, name ), ampm( whichClock ), currDate( QDate::currentDate() ) 50 : QTable( 24, 1, parent, name ), ampm( whichClock ), currDate( QDate::currentDate() )
39{ 51{
40 enableClipper(TRUE); 52 enableClipper(TRUE);
41 setTopMargin( 0 ); 53 setTopMargin( 0 );
42 horizontalHeader()->hide(); 54 horizontalHeader()->hide();
43 setLeftMargin(38); 55 setLeftMargin(38);
44 setColumnStretchable( 0, TRUE ); 56 setColumnStretchable( 0, TRUE );
45 setHScrollBarMode( QScrollView::AlwaysOff ); 57 setHScrollBarMode( QScrollView::AlwaysOff );
46 verticalHeader()->setPalette(white); 58 verticalHeader()->setPalette(white);
47 verticalHeader()->setResizeEnabled(FALSE); 59 verticalHeader()->setResizeEnabled(FALSE);
48 setSelectionMode( Single ); 60 setSelectionMode( Single );
49 61
50 // get rid of being able to edit things... 62 // get rid of being able to edit things...
51 QTableItem *tmp; 63 QTableItem *tmp;
52 int row; 64 int row;
53 for ( row = 0; row < numRows(); row++ ) { 65 for ( row = 0; row < numRows(); row++ ) {
54 tmp = new QTableItem( this, QTableItem::Never, QString::null); 66 tmp = new QTableItem( this, QTableItem::Never, QString::null);
55 setItem( row, 0, tmp ); 67 setItem( row, 0, tmp );
56 //setRowHeight( row, 40); 68 //setRowHeight( row, 40);
57 } 69 }
58 70
59 initHeader(); 71 initHeader();
60 QObject::connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotChangeClock(bool)) ); 72 QObject::connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotChangeClock(bool)) );
61} 73}
62 74
63void DateBookDayView::initHeader() 75void DateBookDayView::initHeader()
64{ 76{
65 QString strTmp; 77 QString strTmp;
66 int preferredWidth = 0; 78 int preferredWidth = 0;
67 for ( int i = 0; i < 24; ++i ) { 79 for ( int i = 0; i < 24; ++i ) {
68 if ( ampm ) { 80 if ( ampm ) {
69 if ( i == 0 ) 81 if ( i == 0 )
70 strTmp = QString::number(12) + ":00"; 82 strTmp = QString::number(12) + ":00";
71 else if ( i == 12 ) 83 else if ( i == 12 )
72 strTmp = QString::number(12) + tr(":00p"); 84 strTmp = QString::number(12) + tr(":00p");
73 else if ( i > 12 ) 85 else if ( i > 12 )
74 strTmp = QString::number( i - 12 ) + tr(":00p"); 86 strTmp = QString::number( i - 12 ) + tr(":00p");
75 else 87 else
76 strTmp = QString::number(i) + ":00"; 88 strTmp = QString::number(i) + ":00";
77 } else { 89 } else {
78 if ( i < 10 ) 90 if ( i < 10 )
79 strTmp = "0" + QString::number(i) + ":00"; 91 strTmp = "0" + QString::number(i) + ":00";
80 else 92 else
81 strTmp = QString::number(i) + ":00"; 93 strTmp = QString::number(i) + ":00";
82 } 94 }
83 strTmp = strTmp.rightJustify( 6, ' ' ); 95 strTmp = strTmp.rightJustify( 6, ' ' );
84 verticalHeader()->setLabel( i, strTmp ); 96 verticalHeader()->setLabel( i, strTmp );
85 97
86 // Compute correct width for current Font (Add some space right) 98 // Compute correct width for current Font (Add some space right)
87 int actWidth = QFontMetrics( QFont::defaultFont() ).width( strTmp + QString(" ") ); 99 int actWidth = QFontMetrics( QFont::defaultFont() ).width( strTmp + QString(" ") );
88 if ( preferredWidth < actWidth ) 100 if ( preferredWidth < actWidth )
89 preferredWidth = actWidth; 101 preferredWidth = actWidth;
90 setRowStretchable( i, FALSE ); 102 setRowStretchable( i, FALSE );
91 } 103 }
92 104
93 // It seems as if the header has a bug. It does not resize 105 // It seems as if the header has a bug. It does not resize
94 // correct horizontally if it is used vertical.. 106 // correct horizontally if it is used vertical..
95 // Thus, we do it manually.. 107 // Thus, we do it manually..
96 setLeftMargin( preferredWidth ); 108 setLeftMargin( preferredWidth );
97} 109}
98 110
99void DateBookDayView::slotDateChanged( int y, int m, int d ) 111void DateBookDayView::slotDateChanged( int y, int m, int d )
100{ 112{
101 currDate.setYMD(y,m,d); 113 currDate.setYMD(y,m,d);
102} 114}
103 115
104void DateBookDayView::slotChangeClock( bool newClock ) 116void DateBookDayView::slotChangeClock( bool newClock )
105{ 117{
106 ampm = newClock; 118 ampm = newClock;
107 initHeader(); 119 initHeader();
108} 120}
109 121
110bool DateBookDayView::whichClock() const 122bool DateBookDayView::whichClock() const
111{ 123{
112 return ampm; 124 return ampm;
113} 125}
114 126
115void DateBookDayView::moveUp() 127void DateBookDayView::moveUp()
116{ 128{
117 scrollBy(0, -20); 129 scrollBy(0, -20);
118} 130}
119 131
120void DateBookDayView::moveDown() 132void DateBookDayView::moveDown()
121{ 133{
122 scrollBy(0, 20); 134 scrollBy(0, 20);
123} 135}
124 136
125void DateBookDayView::paintCell( QPainter *p, int, int, const QRect &cr, bool ) 137void DateBookDayView::paintCell( QPainter *p, int, int, const QRect &cr, bool )
126{ 138{
127 int w = cr.width(); 139 int w = cr.width();
128 int h = cr.height(); 140 int h = cr.height();
129 p->fillRect( 0, 0, w, h, colorGroup().brush( QColorGroup::Base ) ); 141 p->fillRect( 0, 0, w, h, colorGroup().brush( QColorGroup::Base ) );
130 if ( showGrid() ) { 142 if ( showGrid() ) {
131 // Draw our lines 143 // Draw our lines
132 int x2 = w - 1; 144 int x2 = w - 1;
133 int y2 = h - 1; 145 int y2 = h - 1;
134 QPen pen( p->pen() ); 146 QPen pen( p->pen() );
135 p->setPen( colorGroup().dark() ); 147 p->setPen( colorGroup().dark() );
136 p->drawLine( x2, 0, x2, y2 ); 148 p->drawLine( x2, 0, x2, y2 );
137 p->drawLine( 0, y2, x2, y2 ); 149 p->drawLine( 0, y2, x2, y2 );
138 150
139 p->setPen( colorGroup().midlight() ); 151 p->setPen( colorGroup().midlight() );
140 p->drawLine( 0, y2 - h/2, x2, y2 - h/2); 152 p->drawLine( 0, y2 - h/2, x2, y2 - h/2);
141 153
142 p->setPen( pen ); 154 p->setPen( pen );
143 } 155 }
144} 156}
145 157
146void DateBookDayView::paintFocus( QPainter *, const QRect & ) 158void DateBookDayView::paintFocus( QPainter *, const QRect & )
147{ 159{
148} 160}
149 161
150void DateBookDayView::resizeEvent( QResizeEvent *e ) 162void DateBookDayView::resizeEvent( QResizeEvent *e )
151{ 163{
152 QTable::resizeEvent( e ); 164 QTable::resizeEvent( e );
153 columnWidthChanged( 0 ); 165 columnWidthChanged( 0 );
154 emit sigColWidthChanged(); 166 emit sigColWidthChanged();
155} 167}
156 168
157void DateBookDayView::keyPressEvent( QKeyEvent *e ) 169void DateBookDayView::keyPressEvent( QKeyEvent *e )
158{ 170{
159 QString txt = e->text(); 171 QString txt = e->text();
160 if ( !txt.isNull() && txt[0] > ' ' && e->key() < 0x1000 ) { 172 if ( !txt.isNull() && txt[0] > ' ' && e->key() < 0x1000 ) {
161 // we this is some sort of thing we know about... 173 // we this is some sort of thing we know about...
162 e->accept(); 174 e->accept();
163 emit sigCapturedKey( txt ); 175 emit sigCapturedKey( txt );
164 } else { 176 } else {
165 // I don't know what this key is, do you? 177 // I don't know what this key is, do you?
166 e->ignore(); 178 e->ignore();
167 } 179 }
168} 180}
169 181
170void DateBookDayView::setRowStyle( int style ) 182void DateBookDayView::setRowStyle( int style )
171{ 183{
172 if (style<0) style = 0; 184 if (style<0) style = 0;
173 185
174 for (int i=0; i<numRows(); i++) 186 for (int i=0; i<numRows(); i++)
175 setRowHeight(i, style*10+20); 187 setRowHeight(i, style*10+20);
176} 188}
177 189
178void DateBookDayView::contentsMouseReleaseEvent( QMouseEvent* /* e */ ) 190void DateBookDayView::contentsMouseReleaseEvent( QMouseEvent* /* e */ )
179{ 191{
180 int sh=99,eh=-1; 192 int sh=99,eh=-1;
181 193
182 for(int i=0;i<this->numSelections();i++) { 194 for(int i=0;i<this->numSelections();i++) {
183 QTableSelection sel = this->selection( i ); 195 QTableSelection sel = this->selection( i );
184 sh = QMIN(sh,sel.topRow()); 196 sh = QMIN(sh,sel.topRow());
185 eh = QMAX(sh,sel.bottomRow()+1); 197 eh = QMAX(sh,sel.bottomRow()+1);
186 } 198 }
187 if (sh > 23 || eh < 1) { 199 if (sh > 23 || eh < 1) {
188 sh=8; 200 sh=8;
189 eh=9; 201 eh=9;
190 } 202 }
191 203
192 quickLineEdit=new DateBookDayViewQuickLineEdit(QDateTime(currDate,QTime(sh,0,0,0)),QDateTime(currDate,QTime(eh,0,0,0)),this->viewport(),"quickedit"); 204 quickLineEdit=new DateBookDayViewQuickLineEdit(QDateTime(currDate,QTime(sh,0,0,0)),QDateTime(currDate,QTime(eh,0,0,0)),this->viewport(),"quickedit");
193 quickLineEdit->setGeometry(0,0,this->columnWidth(0)-1,this->rowHeight(0)); 205 quickLineEdit->setGeometry(0,0,this->columnWidth(0)-1,this->rowHeight(0));
194 this->moveChild(quickLineEdit,0,sh*this->rowHeight(0)); 206 this->moveChild(quickLineEdit,0,sh*this->rowHeight(0));
195 quickLineEdit->setFocus(); 207 quickLineEdit->setFocus();
196 quickLineEdit->show(); 208 quickLineEdit->show();
197} 209}
198 210
199//=========================================================================== 211//===========================================================================
200 212
201DateBookDayViewQuickLineEdit::DateBookDayViewQuickLineEdit(const QDateTime &start, const QDateTime &end,QWidget * parent, const char *name) : QLineEdit(parent,name) 213DateBookDayViewQuickLineEdit::DateBookDayViewQuickLineEdit(const QDateTime &start, const QDateTime &end,QWidget * parent, const char *name) : QLineEdit(parent,name)
202{ 214{
203 active=1; 215 active=1;
204 quickEvent.setStart(start); 216 quickEvent.setStart(start);
205 quickEvent.setEnd(end); 217 quickEvent.setEnd(end);
206 connect(this,SIGNAL(returnPressed()),this,SLOT(slotReturnPressed())); 218 connect(this,SIGNAL(returnPressed()),this,SLOT(slotReturnPressed()));
207} 219}
208 220
209void DateBookDayViewQuickLineEdit::slotReturnPressed() 221void DateBookDayViewQuickLineEdit::slotReturnPressed()
210{ 222{
211 if(active && (!this->text().isEmpty())) { // Fix to avoid having this event beeing added multiple times. 223 if(active && (!this->text().isEmpty())) { // Fix to avoid having this event beeing added multiple times.
212 quickEvent.setDescription(this->text()); 224 quickEvent.setDescription(this->text());
213 connect(this,SIGNAL(insertEvent(const Event&)),this->topLevelWidget(),SLOT(insertEvent(const Event&))); 225 connect(this,SIGNAL(insertEvent(const Event&)),this->topLevelWidget(),SLOT(insertEvent(const Event&)));
214 emit(insertEvent(quickEvent)); 226 emit(insertEvent(quickEvent));
215 active=0; 227 active=0;
216 } 228 }
217 /* we need to return to this object.. */ 229 /* we need to return to this object.. */
218 QTimer::singleShot(500, this, SLOT(finallyCallClose()) ); // Close and also delete this widget 230 QTimer::singleShot(500, this, SLOT(finallyCallClose()) ); // Close and also delete this widget
219} 231}
220void DateBookDayViewQuickLineEdit::finallyCallClose() { 232void DateBookDayViewQuickLineEdit::finallyCallClose() {
221 close(true); // also deletes this widget... 233 close(true); // also deletes this widget...
222} 234}
223 235
224void DateBookDayViewQuickLineEdit::focusOutEvent ( QFocusEvent* /* e */) 236void DateBookDayViewQuickLineEdit::focusOutEvent ( QFocusEvent* /* e */)
225{ 237{
226 slotReturnPressed(); // Reuse code to add event and close this widget. 238 slotReturnPressed(); // Reuse code to add event and close this widget.
227} 239}
228 240
229//=========================================================================== 241//===========================================================================
230 242
231DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDBHoliday *newDb, DateBookHoliday*newHdb, QWidget *parent, const char *name ) 243DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDBHoliday *newDb, DateBookHoliday*newHdb, QWidget *parent, const char *name )
232 : QVBox( parent, name ), currDate( QDate::currentDate() ), db( newDb ), startTime( 0 ) 244 : QVBox( parent, name ), currDate( QDate::currentDate() ), db( newDb ), startTime( 0 )
233{ 245{
234 widgetList.setAutoDelete( true ); 246 widgetList.setAutoDelete( true );
235 _holiday_db = newHdb; 247 _holiday_db = newHdb;
236 header = new DateBookDayHeader( startOnMonday, this, "day header" ); 248 header = new DateBookDayHeader( startOnMonday, this, "day header" );
237 header->setDate( currDate.year(), currDate.month(), currDate.day() ); 249 header->setDate( currDate.year(), currDate.month(), currDate.day() );
238 250
239 m_allDays = new DatebookdayAllday(newDb, this, "all day event list" ); 251 m_allDays = new DatebookdayAllday(newDb, this, "all day event list" );
240 m_allDays->hide(); 252 m_allDays->hide();
241 253
242 view = new DateBookDayView( ampm, this, "day view" ); 254 view = new DateBookDayView( ampm, this, "day view" );
243 255
244 connect( header, SIGNAL( dateChanged(int,int,int) ), this, SLOT( dateChanged(int,int,int) ) ); 256 connect( header, SIGNAL( dateChanged(int,int,int) ), this, SLOT( dateChanged(int,int,int) ) );
245 connect( header, SIGNAL( dateChanged(int,int,int) ), view, SLOT( slotDateChanged(int,int,int) ) ); 257 connect( header, SIGNAL( dateChanged(int,int,int) ), view, SLOT( slotDateChanged(int,int,int) ) );
246 connect( view, SIGNAL( sigColWidthChanged() ), this, SLOT( slotColWidthChanged() ) ); 258 connect( view, SIGNAL( sigColWidthChanged() ), this, SLOT( slotColWidthChanged() ) );
247 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) ); 259 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) );
248 connect( view, SIGNAL(sigCapturedKey(const QString&)), this, SIGNAL(sigNewEvent(const QString&)) ); 260 connect( view, SIGNAL(sigCapturedKey(const QString&)), this, SIGNAL(sigNewEvent(const QString&)) );
249 261
250 QTimer *timer = new QTimer( this ); 262 QTimer *timer = new QTimer( this );
251 263
252 connect( timer, SIGNAL(timeout()), this, SLOT(updateView()) ); //connect timer for updating timeMarker & daywidgetcolors 264 connect( timer, SIGNAL(timeout()), this, SLOT(updateView()) ); //connect timer for updating timeMarker & daywidgetcolors
253 timer->start( 1000*60*5, FALSE ); //update every 5min 265 timer->start( 1000*60*5, FALSE ); //update every 5min
254 266
255 selectedWidget = 0; 267 selectedWidget = 0;
256 268
257 timeMarker = new DateBookDayTimeMarker( this ); 269 timeMarker = new DateBookDayTimeMarker( this );
258 timeMarker->setTime( QTime::currentTime() ); 270 timeMarker->setTime( QTime::currentTime() );
259 rowStyle = -1; // initialize with bogus values 271 rowStyle = -1; // initialize with bogus values
260 jumpToCurTime = false; 272 jumpToCurTime = false;
261} 273}
262 274
263void DateBookDay::setJumpToCurTime( bool bJump ) 275void DateBookDay::setJumpToCurTime( bool bJump )
264{ 276{
265 jumpToCurTime = bJump; 277 jumpToCurTime = bJump;
266} 278}
267 279
268void DateBookDay::setRowStyle( int style ) 280void DateBookDay::setRowStyle( int style )
269{ 281{
270 if (rowStyle != style) view->setRowStyle( style ); 282 if (rowStyle != style) view->setRowStyle( style );
271 rowStyle = style; 283 rowStyle = style;
272} 284}
273 285
274void DateBookDay::updateView( void ) 286void DateBookDay::updateView( void )
275{ 287{
276 timeMarker->setTime( QTime::currentTime() ); 288 timeMarker->setTime( QTime::currentTime() );
277 //need to find a way to update all DateBookDayWidgets 289 //need to find a way to update all DateBookDayWidgets
278} 290}
279 291
280void DateBookDay::setSelectedWidget( DateBookDayWidget *w ) 292void DateBookDay::setSelectedWidget( DateBookDayWidget *w )
281{ 293{
282 selectedWidget = w; 294 selectedWidget = w;
283} 295}
284 296
285DateBookDayWidget * DateBookDay::getSelectedWidget( void ) 297DateBookDayWidget * DateBookDay::getSelectedWidget( void )
286{ 298{
287 return selectedWidget; 299 return selectedWidget;
288} 300}
289 301
290void DateBookDay::selectedDates( QDateTime &start, QDateTime &end ) 302void DateBookDay::selectedDates( QDateTime &start, QDateTime &end )
291{ 303{
292 start.setDate( currDate ); 304 start.setDate( currDate );
293 end.setDate( currDate ); 305 end.setDate( currDate );
294 306
295 int sh=99,eh=-1; 307 int sh=99,eh=-1;
296 308
297 int n = dayView()->numSelections(); 309 int n = dayView()->numSelections();
298 310
299 for (int i=0; i<n; i++) { 311 for (int i=0; i<n; i++) {
300 QTableSelection sel = dayView()->selection( i ); 312 QTableSelection sel = dayView()->selection( i );
301 sh = QMIN(sh,sel.topRow()); 313 sh = QMIN(sh,sel.topRow());
302 eh = QMAX(sh,sel.bottomRow()+1); 314 eh = QMAX(sh,sel.bottomRow()+1);
303 } 315 }
304 316
305 if (sh > 23 || eh < 1) { 317 if (sh > 23 || eh < 1) {
306 sh=8; 318 sh=8;
307 eh=9; 319 eh=9;
308 } 320 }
309 321
310 start.setTime( QTime( sh, 0, 0 ) ); 322 start.setTime( QTime( sh, 0, 0 ) );
311 end.setTime( QTime( eh, 0, 0 ) ); 323 end.setTime( QTime( eh, 0, 0 ) );
312} 324}
313 325
314void DateBookDay::setDate( int y, int m, int d ) 326void DateBookDay::setDate( int y, int m, int d )
315{ 327{
316 header->setDate( y, m, d ); 328 header->setDate( y, m, d );
317 selectedWidget = 0; 329 selectedWidget = 0;
318} 330}
319 331
320void DateBookDay::setDate( QDate d) 332void DateBookDay::setDate( QDate d)
321{ 333{
322 header->setDate( d.year(), d.month(), d.day() ); 334 header->setDate( d.year(), d.month(), d.day() );
323 selectedWidget = 0; 335 selectedWidget = 0;
324} 336}
325 337
326void DateBookDay::dateChanged( int y, int m, int d ) 338void DateBookDay::dateChanged( int y, int m, int d )
327{ 339{
328 QDate date( y, m, d ); 340 QDate date( y, m, d );
329 if ( currDate == date ) 341 if ( currDate == date )
330 return; 342 return;
331 currDate.setYMD( y, m, d ); 343 currDate.setYMD( y, m, d );
332 relayoutPage(); 344 relayoutPage();
333 dayView()->clearSelection(); 345 dayView()->clearSelection();
334 QTableSelection ts; 346 QTableSelection ts;
335 347
336 if (jumpToCurTime && this->date() == QDate::currentDate()) 348 if (jumpToCurTime && this->date() == QDate::currentDate())
337 { 349 {
338 ts.init( QTime::currentTime().hour(), 0); 350 ts.init( QTime::currentTime().hour(), 0);
339 ts.expandTo( QTime::currentTime().hour(), 0); 351 ts.expandTo( QTime::currentTime().hour(), 0);
340 } else { 352 } else {
341 ts.init( startTime, 0 ); 353 ts.init( startTime, 0 );
342 ts.expandTo( startTime, 0 ); 354 ts.expandTo( startTime, 0 );
343 } 355 }
344 356
345 dayView()->addSelection( ts ); 357 dayView()->addSelection( ts );
346 selectedWidget = 0; 358 selectedWidget = 0;
347} 359}
348 360
349void DateBookDay::redraw() 361void DateBookDay::redraw()
350{ 362{
351 if ( isUpdatesEnabled() ) 363 if ( isUpdatesEnabled() )
352 relayoutPage(); 364 relayoutPage();
353} 365}
354 366
355void DateBookDay::getEvents() 367void DateBookDay::getEvents()
356{ 368{
357 widgetList.clear(); 369 widgetList.clear();
358 370
359 /* clear the AllDay List */ 371 /* clear the AllDay List */
360 m_allDays->hide(); // just in case 372 m_allDays->hide(); // just in case
361 m_allDays->removeAllEvents(); 373 m_allDays->removeAllEvents();
362 374
363 QStringList hdays = _holiday_db->holidaylist(currDate); 375 QStringList hdays = _holiday_db->holidaylist(currDate);
364 QStringList::Iterator sit; 376 QStringList::Iterator sit;
365 QObject* object = 0; 377 QObject* object = 0;
366 378
367 /* this way we make sure that holiday dummy events are always 379 /* this way we make sure that holiday dummy events are always
368 on top of the widgetlist. */ 380 on top of the widgetlist. */
369 for (sit=hdays.begin();sit!=hdays.end();++sit) { 381 for (sit=hdays.begin();sit!=hdays.end();++sit) {
370 m_allDays->addHoliday(*sit); 382 m_allDays->addHoliday(*sit);
371 } 383 }
372 QValueList<EffectiveEvent> eventList = db->getEffectiveEventsNoHoliday( currDate, currDate ); 384 QValueList<EffectiveEvent> eventList = db->getEffectiveEventsNoHoliday( currDate, currDate );
373 QValueListIterator<EffectiveEvent> it; 385 QValueListIterator<EffectiveEvent> it;
374 386
375 for ( it = eventList.begin(); it != eventList.end(); ++it ) { 387 for ( it = eventList.begin(); it != eventList.end(); ++it ) {
376 EffectiveEvent ev=*it; 388 EffectiveEvent ev=*it;
377 if(!((ev.end().hour()==0) && (ev.end().minute()==0) && (ev.startDate()!=ev.date()))) { // Skip events ending at 00:00 starting at another day. 389 if(!((ev.end().hour()==0) && (ev.end().minute()==0) && (ev.startDate()!=ev.date()))) { // Skip events ending at 00:00 starting at another day.
378 if (ev.event().type() == Event::AllDay ) { 390 if (ev.event().type() == Event::AllDay ) {
379 object = m_allDays->addEvent( ev ); 391 object = m_allDays->addEvent( ev );
380 if (!object) 392 if (!object)
381 continue; 393 continue;
382 }else { 394 }else {
383 DateBookDayWidget* w = new DateBookDayWidget( *it, this ); 395 DateBookDayWidget* w = new DateBookDayWidget( *it, this );
384 widgetList.append( w ); 396 widgetList.append( w );
385 object = w; 397 object = w;
386 } 398 }
387 399
388 connect( object, SIGNAL( deleteMe(const Event&) ), this, SIGNAL( removeEvent(const Event&) ) ); 400 connect( object, SIGNAL( deleteMe(const Event&) ), this, SIGNAL( removeEvent(const Event&) ) );
389 connect( object, SIGNAL( duplicateMe(const Event&) ), this, SIGNAL( duplicateEvent(const Event&) ) ); 401 connect( object, SIGNAL( duplicateMe(const Event&) ), this, SIGNAL( duplicateEvent(const Event&) ) );
390 connect( object, SIGNAL( editMe(const Event&) ), this, SIGNAL( editEvent(const Event&) ) ); 402 connect( object, SIGNAL( editMe(const Event&) ), this, SIGNAL( editEvent(const Event&) ) );
391 connect( object, SIGNAL( beamMe(const Event&) ), this, SIGNAL( beamEvent(const Event&) ) ); 403 connect( object, SIGNAL( beamMe(const Event&) ), this, SIGNAL( beamEvent(const Event&) ) );
392 404
393 } 405 }
394 } 406 }
395} 407}
396 408
397static int place( const DateBookDayWidget *item, bool *used, int maxn ) 409static int place( const DateBookDayWidget *item, bool *used, int maxn )
398{ 410{
399 int place = 0; 411 int place = 0;
400 int start = item->event().start().hour(); 412 int start = item->event().start().hour();
401 QTime e = item->event().end(); 413 QTime e = item->event().end();
402 int end = e.hour(); 414 int end = e.hour();
403 if ( e.minute() < 5 ) 415 if ( e.minute() < 5 )
404 end--; 416 end--;
405 if ( end < start ) 417 if ( end < start )
406 end = start; 418 end = start;
407 while ( place < maxn ) { 419 while ( place < maxn ) {
408 bool free = TRUE; 420 bool free = TRUE;
409 int s = start; 421 int s = start;
410 while( s <= end ) { 422 while( s <= end ) {
411 if ( used[10*s+place] ) { 423 if ( used[10*s+place] ) {
412 free = FALSE; 424 free = FALSE;
413 break; 425 break;
414 } 426 }
415 s++; 427 s++;
416 } 428 }
417 if ( free ) 429 if ( free )
418 break; 430 break;
419 place++; 431 place++;
420 } 432 }
421 if ( place == maxn ) { 433 if ( place == maxn ) {
422 return -1; 434 return -1;
423 } 435 }
424 while( start <= end ) { 436 while( start <= end ) {
425 used[10*start+place] = TRUE; 437 used[10*start+place] = TRUE;
426 start++; 438 start++;
427 } 439 }
428 return place; 440 return place;
429} 441}
430 442
431 443
432void DateBookDay::relayoutPage( bool fromResize ) 444void DateBookDay::relayoutPage( bool fromResize )
433{ 445{
434 setUpdatesEnabled( FALSE ); 446 setUpdatesEnabled( FALSE );
435 if ( !fromResize ) { 447 if ( !fromResize ) {
436 getEvents(); // no need we already have them! 448 getEvents(); // no need we already have them!
437 449
438 if (m_allDays->items() > 0 ) 450 if (m_allDays->items() > 0 )
439 m_allDays->show(); 451 m_allDays->show();
440 /* 452 /*
441 * else if ( m_allDays->items() == 0 ) already hide in getEvents 453 * else if ( m_allDays->items() == 0 ) already hide in getEvents
442 */ 454 */
443 } 455 }
444 456
445 widgetList.sort(); 457 widgetList.sort();
446 //sorts the widgetList by the heights of the widget so that the tallest widgets are at the beginning 458 //sorts the widgetList by the heights of the widget so that the tallest widgets are at the beginning
447 //this is needed for the simple algo below to work correctly, otherwise some widgets would be drawn outside the view 459 //this is needed for the simple algo below to work correctly, otherwise some widgets would be drawn outside the view
448 460
449 int wCount = widgetList.count(); 461 int wCount = widgetList.count();
450 int wid = view->columnWidth(0)-1; 462 int wid = view->columnWidth(0)-1;
451 int wd; 463 int wd;
452 int n = 1; 464 int n = 1;
453 465
454 QArray<int> anzIntersect(wCount); //this stores the number of maximal intersections of each widget 466 QArray<int> anzIntersect(wCount); //this stores the number of maximal intersections of each widget
455 467
456 for (int i = 0; i<wCount; anzIntersect[i] = 1, i++); 468 for (int i = 0; i<wCount; anzIntersect[i] = 1, i++);
457 469
458 if ( wCount < 20 ) { 470 if ( wCount < 20 ) {
459 471
460 QArray<QRect> geometries(wCount); 472 QArray<QRect> geometries(wCount);
461 for (int i = 0; i < wCount; geometries[i] = widgetList.at(i)->geometry(), i++); //stores geometry for each widget in vector 473 for (int i = 0; i < wCount; geometries[i] = widgetList.at(i)->geometry(), i++); //stores geometry for each widget in vector
462 474
463 for ( int i = 0; i < wCount; i++) { 475 for ( int i = 0; i < wCount; i++) {
464 QValueList<int> intersectedWidgets; 476 QValueList<int> intersectedWidgets;
465 477
466 //find all widgets intersecting with widgetList.at(i) 478 //find all widgets intersecting with widgetList.at(i)
467 for ( int j = 0; j < wCount; j++) { 479 for ( int j = 0; j < wCount; j++) {
468 if (i != j) 480 if (i != j)
469 if (geometries[j].intersects(geometries[i])) 481 if (geometries[j].intersects(geometries[i]))
470 intersectedWidgets.append(j); 482 intersectedWidgets.append(j);
471 } 483 }
472 484
473 //for each of these intersecting widgets find out how many widgets are they intersecting with 485 //for each of these intersecting widgets find out how many widgets are they intersecting with
474 for ( uint j = 0; j < intersectedWidgets.count(); j++) 486 for ( uint j = 0; j < intersectedWidgets.count(); j++)
475 { 487 {
476 QArray<int> inter(wCount); 488 QArray<int> inter(wCount);
477 inter[j]=1; 489 inter[j]=1;
478 490
479 if (intersectedWidgets[j] != -1) 491 if (intersectedWidgets[j] != -1)
480 for ( uint k = j; k < intersectedWidgets.count(); k++) { 492 for ( uint k = j; k < intersectedWidgets.count(); k++) {
481 if (j != k && intersectedWidgets[k] != -1) 493 if (j != k && intersectedWidgets[k] != -1)
482 if (geometries[intersectedWidgets[k]].intersects(geometries[intersectedWidgets[j]])) { 494 if (geometries[intersectedWidgets[k]].intersects(geometries[intersectedWidgets[j]])) {
483 inter[j]++; 495 inter[j]++;
484 intersectedWidgets[k] = -1; 496 intersectedWidgets[k] = -1;
485 } 497 }
486 if (inter[j] > anzIntersect[i]) anzIntersect[i] = inter[j] + 1; 498 if (inter[j] > anzIntersect[i]) anzIntersect[i] = inter[j] + 1;
487 } 499 }
488 } 500 }
489 if (anzIntersect[i] == 1 && intersectedWidgets.count()) anzIntersect[i]++; 501 if (anzIntersect[i] == 1 && intersectedWidgets.count()) anzIntersect[i]++;
490 } 502 }
491 503
492 504
493 for ( int i = 0; i < wCount; i++) { 505 for ( int i = 0; i < wCount; i++) {
494 DateBookDayWidget *w = widgetList.at(i); 506 DateBookDayWidget *w = widgetList.at(i);
495 QRect geom = w->geometry(); 507 QRect geom = w->geometry();
496 geom.setX( 0 ); 508 geom.setX( 0 );
497 wd = (view->columnWidth(0)-1) / anzIntersect[i] - (anzIntersect[i]>1?2:0); 509 wd = (view->columnWidth(0)-1) / anzIntersect[i] - (anzIntersect[i]>1?2:0);
498 geom.setWidth( wd ); 510 geom.setWidth( wd );
499 while ( intersects( w, geom ) ) { 511 while ( intersects( w, geom ) ) {
500 geom.moveBy( wd + 2 + 1, 0 ); 512 geom.moveBy( wd + 2 + 1, 0 );
501 } 513 }
502 w->setGeometry( geom ); 514 w->setGeometry( geom );
503 } 515 }
504 516
505 if (jumpToCurTime && this->date() == QDate::currentDate()) { 517 if (jumpToCurTime && this->date() == QDate::currentDate()) {
506 view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour 518 view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour
507 } else { 519 } else {
508 view->setContentsPos( 0, startTime * view->rowHeight(0) ); 520 view->setContentsPos( 0, startTime * view->rowHeight(0) );
509 } 521 }
510 } else { 522 } else {
511 int hours[24]; 523 int hours[24];
512 memset( hours, 0, 24*sizeof( int ) ); 524 memset( hours, 0, 24*sizeof( int ) );
513 bool overFlow = FALSE; 525 bool overFlow = FALSE;
514 for ( int i = 0; i < wCount; i++ ) { 526 for ( int i = 0; i < wCount; i++ ) {
515 DateBookDayWidget *w = widgetList.at(i); 527 DateBookDayWidget *w = widgetList.at(i);
516 int start = w->event().start().hour(); 528 int start = w->event().start().hour();
517 QTime e = w->event().end(); 529 QTime e = w->event().end();
518 int end = e.hour(); 530 int end = e.hour();
519 if ( e.minute() < 5 ) 531 if ( e.minute() < 5 )
520 end--; 532 end--;
521 if ( end < start ) 533 if ( end < start )
522 end = start; 534 end = start;
523 while( start <= end ) { 535 while( start <= end ) {
524 hours[start]++; 536 hours[start]++;
525 if ( hours[start] >= 10 ) 537 if ( hours[start] >= 10 )
526 overFlow = TRUE; 538 overFlow = TRUE;
527 ++start; 539 ++start;
528 } 540 }
529 if ( overFlow ) 541 if ( overFlow )
530 break; 542 break;
531 } 543 }
532 for ( int i = 0; i < 24; i++ ) { 544 for ( int i = 0; i < 24; i++ ) {
533 n = QMAX( n, hours[i] ); 545 n = QMAX( n, hours[i] );
534 } 546 }
535 wid = ( view->columnWidth(0)-1 ) / n; 547 wid = ( view->columnWidth(0)-1 ) / n;
536 548
537 bool used[24*10]; 549 bool used[24*10];
538 memset( used, FALSE, 24*10*sizeof( bool ) ); 550 memset( used, FALSE, 24*10*sizeof( bool ) );
539 551
540 for ( int i = 0; i < wCount; i++ ) { 552 for ( int i = 0; i < wCount; i++ ) {
541 DateBookDayWidget *w = widgetList.at(i); 553 DateBookDayWidget *w = widgetList.at(i);
542 int xp = place( w, used, n ); 554 int xp = place( w, used, n );
543 if ( xp != -1 ) { 555 if ( xp != -1 ) {
544 QRect geom = w->geometry(); 556 QRect geom = w->geometry();
545 geom.setX( xp*(wid+2) ); 557 geom.setX( xp*(wid+2) );
546 geom.setWidth( wid ); 558 geom.setWidth( wid );
547 w->setGeometry( geom ); 559 w->setGeometry( geom );
548 } 560 }
549 } 561 }
550 562
551 if (jumpToCurTime && this->date() == QDate::currentDate()) { 563 if (jumpToCurTime && this->date() == QDate::currentDate()) {
552 view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour 564 view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour
553 } else { 565 } else {
554 view->setContentsPos( 0, startTime * view->rowHeight(0) ); 566 view->setContentsPos( 0, startTime * view->rowHeight(0) );
555 } 567 }
556 } 568 }
557 569
558 timeMarker->setTime( QTime::currentTime() ); //display timeMarker 570 timeMarker->setTime( QTime::currentTime() ); //display timeMarker
559 timeMarker->raise(); //on top of all widgets 571 timeMarker->raise(); //on top of all widgets
560 if (this->date() == QDate::currentDate()) { //only show timeMarker on current day 572 if (this->date() == QDate::currentDate()) { //only show timeMarker on current day
561 timeMarker->show(); 573 timeMarker->show();
562 } else { 574 } else {
563 timeMarker->hide(); 575 timeMarker->hide();
564 } 576 }
565 setUpdatesEnabled( TRUE ); 577 setUpdatesEnabled( TRUE );
566 return; 578 return;
567} 579}
568 580
569DateBookDayWidget *DateBookDay::intersects( const DateBookDayWidget *item, const QRect &geom ) 581DateBookDayWidget *DateBookDay::intersects( const DateBookDayWidget *item, const QRect &geom )
570{ 582{
571 int i = 0; 583 int i = 0;
572 DateBookDayWidget *w = widgetList.at(i); 584 DateBookDayWidget *w = widgetList.at(i);
573 int wCount = widgetList.count(); 585 int wCount = widgetList.count();
574 while ( i < wCount && w != item ) { 586 while ( i < wCount && w != item ) {
575 if ( w->geometry().intersects( geom ) ) { 587 if ( w->geometry().intersects( geom ) ) {
576 return w; 588 return w;
577 } 589 }
578 w = widgetList.at(++i); 590 w = widgetList.at(++i);
579 } 591 }
580 592
581 return 0; 593 return 0;
582} 594}
583 595
584 596
585QDate DateBookDay::date() const 597QDate DateBookDay::date() const
586{ 598{
587 return currDate; 599 return currDate;
588} 600}
589 601
590void DateBookDay::setStartViewTime( int startHere ) 602void DateBookDay::setStartViewTime( int startHere )
591{ 603{
592 startTime = startHere; 604 startTime = startHere;
593 dayView()->clearSelection(); 605 dayView()->clearSelection();
594 QTableSelection ts; 606 QTableSelection ts;
595 607
596 if (jumpToCurTime && this->date() == QDate::currentDate()) { //this should probably be in datebook.cpp where it's called? 608 if (jumpToCurTime && this->date() == QDate::currentDate()) { //this should probably be in datebook.cpp where it's called?
597 ts.init( QTime::currentTime().hour(), 0); 609 ts.init( QTime::currentTime().hour(), 0);
598 ts.expandTo( QTime::currentTime().hour(), 0); 610 ts.expandTo( QTime::currentTime().hour(), 0);
599 } else { 611 } else {
600 ts.init( startTime, 0 ); 612 ts.init( startTime, 0 );
601 ts.expandTo( startTime, 0 ); 613 ts.expandTo( startTime, 0 );
602 } 614 }
603 615
604 dayView()->addSelection( ts ); 616 dayView()->addSelection( ts );
605} 617}
606 618
607int DateBookDay::startViewTime() const 619int DateBookDay::startViewTime() const
608{ 620{
609 return startTime; 621 return startTime;
610} 622}
611 623
612void DateBookDay::slotWeekChanged( bool bStartOnMonday ) 624void DateBookDay::slotWeekChanged( bool bStartOnMonday )
613{ 625{
614 header->setStartOfWeek( bStartOnMonday ); 626 header->setStartOfWeek( bStartOnMonday );
615// redraw(); 627// redraw();
616} 628}
617 629
618void DateBookDay::keyPressEvent(QKeyEvent *e) 630void DateBookDay::keyPressEvent(QKeyEvent *e)
619{ 631{
620 switch(e->key()) { 632 switch(e->key()) {
621 case Key_Up: 633 case Key_Up:
622 view->moveUp(); 634 view->moveUp();
623 break; 635 break;
624 case Key_Down: 636 case Key_Down:
625 view->moveDown(); 637 view->moveDown();
626 break; 638 break;
627 case Key_Left: 639 case Key_Left:
628 setDate(QDate(currDate).addDays(-1)); 640 setDate(QDate(currDate).addDays(-1));
629 break; 641 break;
630 case Key_Right: 642 case Key_Right:
631 setDate(QDate(currDate).addDays(1)); 643 setDate(QDate(currDate).addDays(1));
632 break; 644 break;
633 default: 645 default:
634 e->ignore(); 646 e->ignore();
635 } 647 }
636} 648}
637 649
638//=========================================================================== 650//===========================================================================
639 651
640DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, DateBookDay *db ) 652DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, DateBookDay *db )
641 : QWidget( db->dayView()->viewport() ), ev( e ), dateBook( db ) 653 : QWidget( db->dayView()->viewport() ), ev( e ), dateBook( db )
642{ 654{
643 // why would someone use "<"? Oh well, fix it up... 655 // why would someone use "<"? Oh well, fix it up...
644 // I wonder what other things may be messed up... 656 // I wonder what other things may be messed up...
645 QString strDesc = ev.description(); 657 QString strDesc = ev.description();
646 int where = strDesc.find( "<" ); 658 int where = strDesc.find( "<" );
647 while ( where != -1 ) { 659 while ( where != -1 ) {
648 strDesc.remove( where, 1 ); 660 strDesc.remove( where, 1 );
649 strDesc.insert( where, "&#60;" ); 661 strDesc.insert( where, "&#60;" );
650 where = strDesc.find( "<", where ); 662 where = strDesc.find( "<", where );
651 } 663 }
652 664
653 QString strCat; 665 QString strCat;
654// ### Fix later... 666// ### Fix later...
655// QString strCat = ev.category(); 667// QString strCat = ev.category();
656// where = strCat.find( "<" ); 668// where = strCat.find( "<" );
657// while ( where != -1 ) { 669// while ( where != -1 ) {
658// strCat.remove( where, 1 ); 670// strCat.remove( where, 1 );
659// strCat.insert( where, "&#60;" ); 671// strCat.insert( where, "&#60;" );
660// where = strCat.find( "<", where ); 672// where = strCat.find( "<", where );
661// } 673// }
662 674
663 QString strNote = ev.notes(); 675 QString strNote = ev.notes();
664 where = strNote.find( "<" ); 676 where = strNote.find( "<" );
665 while ( where != -1 ) { 677 while ( where != -1 ) {
666 strNote.remove( where, 1 ); 678 strNote.remove( where, 1 );
667 strNote.insert( where, "&#60;" ); 679 strNote.insert( where, "&#60;" );
668 where = strNote.find( "<", where ); 680 where = strNote.find( "<", where );
669 } 681 }
670 682
671 text = "<b>" + strDesc + "</b><br>" + "<i>"; 683 text = "<b>" + strDesc + "</b><br>" + "<i>";
672 if ( !strCat.isEmpty() ) { 684 if ( !strCat.isEmpty() ) {
673 text += strCat + "</i><br>"; 685 text += strCat + "</i><br>";
674 } 686 }
675 if (ev.event().type() == Event::Normal ) { 687 if (ev.event().type() == Event::Normal ) {
676 setEventText( text ); 688 setEventText( text );
677 } else { 689 } else {
678 setAllDayText( text ); 690 setAllDayText( text );
679 } 691 }
680 692
681 text += "<br><br>" + strNote; 693 text += "<br><br>" + strNote;
682 694
683 setBackgroundMode( PaletteBase ); 695 setBackgroundMode( PaletteBase );
684 696
685 QTime start = ev.start(); 697 QTime start = ev.start();
686 QTime end = ev.end(); 698 QTime end = ev.end();
687 int y = start.hour()*60+start.minute(); 699 int y = start.hour()*60+start.minute();
688 int h = end.hour()*60+end.minute()-y; 700 int h = end.hour()*60+end.minute()-y;
689 int rh = dateBook->dayView()->rowHeight(0); 701 int rh = dateBook->dayView()->rowHeight(0);
690 y = y*rh/60; 702 y = y*rh/60;
691 h = h*rh/60; 703 h = h*rh/60;
692 704
693 if ( h < 12 ) h = 12; // Make sure the widget is no smaller than 12 pixels high, so that it's possible to read atleast the first line. 705 if ( h < 12 ) h = 12; // Make sure the widget is no smaller than 12 pixels high, so that it's possible to read atleast the first line.
694 if ( y > ((24*rh)-12) ) y=(24*rh)-12; // Make sure the widget fits inside the dayview. 706 if ( y > ((24*rh)-12) ) y=(24*rh)-12; // Make sure the widget fits inside the dayview.
695 geom.setY( y ); 707 geom.setY( y );
696 geom.setHeight( h ); 708 geom.setHeight( h );
697 geom.setX( 0 ); 709 geom.setX( 0 );
698 geom.setWidth(dateBook->dayView()->columnWidth(0)-1); 710 geom.setWidth(dateBook->dayView()->columnWidth(0)-1);
699 711
700} 712}
701 713
702void DateBookDayWidget::setAllDayText( QString &text ) { 714void DateBookDayWidget::setAllDayText( QString &text ) {
703 text += "<b>" + tr("This is an all day event.") + "</b>"; 715 text += "<b>" + tr("This is an all day event.") + "</b>";
704} 716}
705 717
706void DateBookDayWidget::setEventText( QString& text ) { 718void DateBookDayWidget::setEventText( QString& text ) {
707 bool whichClock = dateBook->dayView()->whichClock(); 719 bool whichClock = dateBook->dayView()->whichClock();
708 if ( ev.startDate() != ev.endDate() ) { 720 if ( ev.startDate() != ev.endDate() ) {
709 text += "<b>" + tr("Start") + "</b>: "; 721 text += "<b>" + tr("Start") + "</b>: ";
710 text += TimeString::timeString( ev.event().start().time(), whichClock, FALSE ); 722 text += TimeString::timeString( ev.event().start().time(), whichClock, FALSE );
711 text += " - " + TimeString::longDateString( ev.startDate() ) + "<br>"; 723 text += " - " + TimeString::longDateString( ev.startDate() ) + "<br>";
712 text += "<b>" + tr("End") + "</b>: "; 724 text += "<b>" + tr("End") + "</b>: ";
713 text += TimeString::timeString( ev.event().end().time(), whichClock, FALSE ); 725 text += TimeString::timeString( ev.event().end().time(), whichClock, FALSE );
714 text += " - " + TimeString::longDateString( ev.endDate() ); 726 text += " - " + TimeString::longDateString( ev.endDate() );
715 } else { 727 } else {
716 text += "<b>" + tr("Time") + "</b>: "; 728 text += "<b>" + tr("Time") + "</b>: ";
717 text += TimeString::timeString( ev.start(), whichClock, FALSE ); 729 text += TimeString::timeString( ev.start(), whichClock, FALSE );
718 text += "<b>" + tr(" - ") + "</b>"; 730 text += "<b>" + tr(" - ") + "</b>";
719 text += TimeString::timeString( ev.end(), whichClock, FALSE ); 731 text += TimeString::timeString( ev.end(), whichClock, FALSE );
720 } 732 }
721} 733}
722 734
723DateBookDayWidget::~DateBookDayWidget() 735DateBookDayWidget::~DateBookDayWidget()
724{ 736{
725} 737}
726 738
727void DateBookDayWidget::paintEvent( QPaintEvent *e ) 739void DateBookDayWidget::paintEvent( QPaintEvent *e )
728{ 740{
729 QPainter p( this ); 741 QPainter p( this );
730 742
731 if (dateBook->getSelectedWidget() == this) { 743 if (dateBook->getSelectedWidget() == this) {
732 p.setBrush( QColor( 155, 240, 230 ) ); // selected item 744 p.setBrush( QColor( 155, 240, 230 ) ); // selected item
733 } else { 745 } else {
734 if (dateBook->date() == QDate::currentDate()) { 746 if (dateBook->date() == QDate::currentDate()) {
735 QTime curTime = QTime::currentTime(); 747 QTime curTime = QTime::currentTime();
736 if (ev.end() < curTime) { 748 if (ev.end() < curTime) {
737 p.setBrush( QColor( 180, 180, 180 ) ); // grey, inactive 749 p.setBrush( QColor( 180, 180, 180 ) ); // grey, inactive
738 } else { 750 } else {
739 //change color in dependence of the time till the event starts 751 //change color in dependence of the time till the event starts
740 int duration = curTime.secsTo(ev.start()); 752 int duration = curTime.secsTo(ev.start());
741 if (duration < 0) duration = 0; 753 if (duration < 0) duration = 0;
742 int colChange = duration*160/86400; //86400: secs per day, 160: max color shift 754 int colChange = duration*160/86400; //86400: secs per day, 160: max color shift
743 p.setBrush( QColor( 200-colChange, 200-colChange, 255 ) ); //blue 755 p.setBrush( QColor( 200-colChange, 200-colChange, 255 ) ); //blue
744 } 756 }
745 } else { 757 } else {
746 p.setBrush( QColor( 220, 220, 220 ) ); //light grey, inactive (not current date) 758 p.setBrush( QColor( 220, 220, 220 ) ); //light grey, inactive (not current date)
747 //perhaps make a distinction between future/past dates 759 //perhaps make a distinction between future/past dates
748 } 760 }
749 } 761 }
750 762
751 p.setPen( QColor(100, 100, 100) ); 763 p.setPen( QColor(100, 100, 100) );
752 p.drawRect(rect()); 764 p.drawRect(rect());
753 765
754 // p.drawRect(0,0, 5, height()); 766 // p.drawRect(0,0, 5, height());
755 767
756 int y = 0; 768 int y = 0;
757 int d = 0; 769 int d = 0;
758 770
759 if ( ev.event().hasAlarm() ) { 771 if ( ev.event().hasAlarm() ) {
760 p.drawPixmap( width() - 16, 0, Resource::loadPixmap( "bell" ) ); 772 p.drawPixmap( width() - AppLnk::smallIconSize(), 0,
761 y = 20; 773 Opie::Core::OResource::loadPixmap( "bell", Opie::Core::OResource::SmallIcon ) );
774 y = AppLnk::smallIconSize() + 2;
762 d = 20; 775 d = 20;
763 } 776 }
764 777
765 if ( ev.event().hasRepeat() ) { 778 if ( ev.event().hasRepeat() ) {
766 p.drawPixmap( width() - 16, y, Resource::loadPixmap( "repeat" ) ); 779 p.drawPixmap( width() - AppLnk::smallIconSize(), y,
780 Opie::Core::OResource::loadPixmap( "repeat", Opie::Core::OResource::SmallIcon ) );
767 d = 20; 781 d = 20;
768 y += 20; 782 y += AppLnk::smallIconSize() + 2;
769 } 783 }
770 784
771 QSimpleRichText rt( text, font() ); 785 QSimpleRichText rt( text, font() );
772 rt.setWidth( geom.width() - d - 6 ); 786 rt.setWidth( geom.width() - d - 6 );
773 rt.draw( &p, 7, 0, e->region(), colorGroup() ); 787 rt.draw( &p, 7, 0, e->region(), colorGroup() );
774} 788}
775 789
776/* 790/*
777 * we need to find the real start date for a uid 791 * we need to find the real start date for a uid
778 * we need to check from one day to another... 792 * we need to check from one day to another...
779 */ 793 */
780QDate DateBookDay::findRealStart( int uid, const QDate& isIncluded , DateBookDB* db) { 794QDate DateBookDay::findRealStart( int uid, const QDate& isIncluded , DateBookDB* db) {
781 QDate dt( isIncluded ); 795 QDate dt( isIncluded );
782 QDate fnd = dt; 796 QDate fnd = dt;
783 797
784 bool doAgain = true; 798 bool doAgain = true;
785 do{ 799 do{
786 dt = dt.addDays( -1 ); 800 dt = dt.addDays( -1 );
787 QValueList<EffectiveEvent> events = db->getEffectiveEvents( dt, dt ); 801 QValueList<EffectiveEvent> events = db->getEffectiveEvents( dt, dt );
788 for (QValueList<EffectiveEvent>::Iterator it = events.begin(); it != events.end(); ++it ) { 802 for (QValueList<EffectiveEvent>::Iterator it = events.begin(); it != events.end(); ++it ) {
789 EffectiveEvent ev = (*it); 803 EffectiveEvent ev = (*it);
790 if ( uid == ev.event().uid() && ev.start() != QTime(0, 0, 0 ) ) 804 if ( uid == ev.event().uid() && ev.start() != QTime(0, 0, 0 ) )
791 return ev.date(); 805 return ev.date();
792 } 806 }
793 }while (doAgain ); 807 }while (doAgain );
794 808
795 return fnd; 809 return fnd;
796} 810}
797 811
798void DateBookDayWidget::mousePressEvent( QMouseEvent *e ) 812void DateBookDayWidget::mousePressEvent( QMouseEvent *e )
799{ 813{
800 DateBookDayWidget *item; 814 DateBookDayWidget *item;
801 815
802 item = dateBook->getSelectedWidget(); 816 item = dateBook->getSelectedWidget();
803 if (item) 817 if (item)
804 item->update(); 818 item->update();
805 819
806 dateBook->setSelectedWidget(this); 820 dateBook->setSelectedWidget(this);
807 update(); 821 update();
808 dateBook->repaint(); 822 dateBook->repaint();
809 823
810 Event eve = ev.event(); 824 Event eve = ev.event();
811 825
812 QPopupMenu m; 826 QPopupMenu m;
813 m.insertItem( tr( "Edit" ), 1 ); 827 m.insertItem( tr( "Edit" ), 1 );
814 m.insertItem( tr( "Duplicate" ), 4 ); 828 m.insertItem( tr( "Duplicate" ), 4 );
815 m.insertItem( tr( "Delete" ), 2 ); 829 m.insertItem( tr( "Delete" ), 2 );
816 if(Ir::supported()) m.insertItem( tr( "Beam" ), 3 ); 830 if(Ir::supported()) m.insertItem( tr( "Beam" ), 3 );
817 if(Ir::supported() && ev.event().doRepeat() ) m.insertItem( tr( "Beam this occurence"), 5 ); 831 if(Ir::supported() && ev.event().doRepeat() ) m.insertItem( tr( "Beam this occurence"), 5 );
818 int r = m.exec( e->globalPos() ); 832 int r = m.exec( e->globalPos() );
819 if ( r == 1 ) { 833 if ( r == 1 ) {
820 emit editMe( eve ); 834 emit editMe( eve );
821 } else if ( r == 2 ) { 835 } else if ( r == 2 ) {
822 emit deleteMe( eve ); 836 emit deleteMe( eve );
823 } else if ( r == 3 ) { 837 } else if ( r == 3 ) {
824 emit beamMe( eve ); 838 emit beamMe( eve );
825 } else if ( r == 4 ) { 839 } else if ( r == 4 ) {
826 emit duplicateMe( eve ); 840 emit duplicateMe( eve );
827 } else if ( r == 5 ) { 841 } else if ( r == 5 ) {
828 // create an Event and beam it... 842 // create an Event and beam it...
829 /* 843 /*
830 * Start with the easy stuff. If start and end date is the same we can just use 844 * Start with the easy stuff. If start and end date is the same we can just use
831 * the values of effective events 845 * the values of effective events
832 * If it is a multi day event we need to find the real start and end date... 846 * If it is a multi day event we need to find the real start and end date...
833 */ 847 */
834 if ( ev.event().start().date() == ev.event().end().date() ) { 848 if ( ev.event().start().date() == ev.event().end().date() ) {
835 Event event( ev.event() ); 849 Event event( ev.event() );
836 850
837 QDateTime dt( ev.date(), ev.start() ); 851 QDateTime dt( ev.date(), ev.start() );
838 event.setStart( dt ); 852 event.setStart( dt );
839 853
840 dt.setTime( ev.end() ); 854 dt.setTime( ev.end() );
841 event.setEnd( dt ); 855 event.setEnd( dt );
842 emit beamMe( event ); 856 emit beamMe( event );
843 }else { 857 }else {
844 /* 858 /*
845 * at least the the Times are right now 859 * at least the the Times are right now
846 */ 860 */
847 QDateTime start( ev.event().start() ); 861 QDateTime start( ev.event().start() );
848 QDateTime end ( ev.event().end () ); 862 QDateTime end ( ev.event().end () );
849 863
850 864
851 /* 865 /*
852 * ok we know the start date or we need to find it 866 * ok we know the start date or we need to find it
853 */ 867 */
854 if ( ev.start() != QTime( 0, 0, 0 ) ) { 868 if ( ev.start() != QTime( 0, 0, 0 ) ) {
855 start.setDate( ev.date() ); 869 start.setDate( ev.date() );
856 }else { 870 }else {
857 QDate dt = DateBookDay::findRealStart( ev.event().uid(), ev.date(), dateBook->db ); 871 QDate dt = DateBookDay::findRealStart( ev.event().uid(), ev.date(), dateBook->db );
858 start.setDate( dt ); 872 start.setDate( dt );
859 } 873 }
860 874
861 875
862 /* 876 /*
863 * ok we know now the end date... 877 * ok we know now the end date...
864 * else 878 * else
865 * get to know the offset btw the real start and real end 879 * get to know the offset btw the real start and real end
866 * and then add it to the new start date... 880 * and then add it to the new start date...
867 */ 881 */
868 if ( ev.end() != QTime(23, 59, 59 ) ) { 882 if ( ev.end() != QTime(23, 59, 59 ) ) {
869 end.setDate( ev.date() ); 883 end.setDate( ev.date() );
870 }else{ 884 }else{
871 int days = ev.event().start().date().daysTo( ev.event().end().date() ); 885 int days = ev.event().start().date().daysTo( ev.event().end().date() );
872 end.setDate( start.date().addDays( days ) ); 886 end.setDate( start.date().addDays( days ) );
873 } 887 }
874 888
875 889
876 890
877 Event event( ev.event() ); 891 Event event( ev.event() );
878 event.setStart( start ); 892 event.setStart( start );
879 event.setEnd ( end ); 893 event.setEnd ( end );
880 894
881 895
882 emit beamMe( event ); 896 emit beamMe( event );
883 } 897 }
884 } 898 }
885} 899}
886 900
887void DateBookDayWidget::setGeometry( const QRect &r ) 901void DateBookDayWidget::setGeometry( const QRect &r )
888{ 902{
889 geom = r; 903 geom = r;
890 setFixedSize( r.width()+1, r.height()+1 ); 904 setFixedSize( r.width()+1, r.height()+1 );
891 dateBook->dayView()->moveChild( this, r.x(), r.y()-1 ); 905 dateBook->dayView()->moveChild( this, r.x(), r.y()-1 );
892 show(); 906 show();
893} 907}
894 908
895 909
896//--------------------------------------------------------------------------------------------- 910//---------------------------------------------------------------------------------------------
897//--------------------------------------------------------------------------------------------- 911//---------------------------------------------------------------------------------------------
898 912
899 913
900DateBookDayTimeMarker::DateBookDayTimeMarker( DateBookDay *db ) 914DateBookDayTimeMarker::DateBookDayTimeMarker( DateBookDay *db )
901 : QWidget( db->dayView()->viewport() ), dateBook( db ) 915 : QWidget( db->dayView()->viewport() ), dateBook( db )
902{ 916{
903 setBackgroundMode( PaletteBase ); 917 setBackgroundMode( PaletteBase );
904} 918}
905 919
906DateBookDayTimeMarker::~DateBookDayTimeMarker() 920DateBookDayTimeMarker::~DateBookDayTimeMarker()
907{ 921{
908} 922}
909 923
910void DateBookDayTimeMarker::paintEvent( QPaintEvent */*e*/ ) 924void DateBookDayTimeMarker::paintEvent( QPaintEvent */*e*/ )
911{ 925{
912 QPainter p( this ); 926 QPainter p( this );
913 p.setBrush( QColor( 255, 0, 0 ) ); 927 p.setBrush( QColor( 255, 0, 0 ) );
914 928
915 QPen pen; 929 QPen pen;
916 pen.setStyle(NoPen); 930 pen.setStyle(NoPen);
917 931
918 p.setPen( pen ); 932 p.setPen( pen );
919 p.drawRect(rect()); 933 p.drawRect(rect());
920} 934}
921 935
922void DateBookDayTimeMarker::setTime( const QTime &t ) 936void DateBookDayTimeMarker::setTime( const QTime &t )
923{ 937{
924 int y = t.hour()*60+t.minute(); 938 int y = t.hour()*60+t.minute();
925 int rh = dateBook->dayView()->rowHeight(0); 939 int rh = dateBook->dayView()->rowHeight(0);
926 y = y*rh/60; 940 y = y*rh/60;
927 941
928 geom.setX( 0 ); 942 geom.setX( 0 );
929 943
930 int x = dateBook->dayView()->columnWidth(0)-1; 944 int x = dateBook->dayView()->columnWidth(0)-1;
931 geom.setWidth( x ); 945 geom.setWidth( x );
932 946
933 geom.setY( y ); 947 geom.setY( y );
934 geom.setHeight( 1 ); 948 geom.setHeight( 1 );
935 949
936 setGeometry( geom ); 950 setGeometry( geom );
937 951
938 time = t; 952 time = t;
939} 953}
940 954
941void DateBookDayTimeMarker::setGeometry( const QRect &r ) 955void DateBookDayTimeMarker::setGeometry( const QRect &r )
942{ 956{
943 geom = r; 957 geom = r;
944 setFixedSize( r.width()+1, r.height()+1 ); 958 setFixedSize( r.width()+1, r.height()+1 );
945 dateBook->dayView()->moveChild( this, r.x(), r.y()-1 ); 959 dateBook->dayView()->moveChild( this, r.x(), r.y()-1 );
946 show(); 960 show();
947} 961}
diff --git a/core/pim/datebook/datebookday.h b/core/pim/datebook/datebookday.h
index 3b75eba..82021af 100644
--- a/core/pim/datebook/datebookday.h
+++ b/core/pim/datebook/datebookday.h
@@ -1,240 +1,251 @@
1/********************************************************************** 1/*
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2                 This file is part of the Opie Project
3** 3
4** This file is part of Qtopia Environment. 4 Copyright (C) Opie Team <opie-devel@handhelds.org>
5** 5 =.
6** This file may be distributed and/or modified under the terms of the 6 .=l.
7** GNU General Public License version 2 as published by the Free Software 7           .>+-=
8** Foundation and appearing in the file LICENSE.GPL included in the 8 _;:,     .>    :=|. This program is free software; you can
9** packaging of this file. 9.> <`_,   >  .   <= redistribute it and/or modify it under
10** 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11.="- .-=="i,     .._ License as published by the Free Software
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13** 13     ._= =}       : or (at your option) any later version.
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14    .%`+i>       _;_.
15** 15    .i_,=:_.      -<s. This program is distributed in the hope that
16** Contact info@trolltech.com if any conditions of this licensing are 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17** not clear to you. 17 : ..    .:,     . . . without even the implied warranty of
18** 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19**********************************************************************/ 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details.
22:     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA.
29*/
30
20#ifndef DATEBOOKDAY_H 31#ifndef DATEBOOKDAY_H
21#define DATEBOOKDAY_H 32#define DATEBOOKDAY_H
22 33
23#include <qpe/event.h> 34#include <qpe/event.h>
24 35
25#include <qdatetime.h> 36#include <qdatetime.h>
26#include <qtable.h> 37#include <qtable.h>
27#include <qvbox.h> 38#include <qvbox.h>
28#include <qlist.h> 39#include <qlist.h>
29 40
30#include "datebook.h" 41#include "datebook.h"
31#include "datebooktypes.h" 42#include "datebooktypes.h"
32#include <qlineedit.h> 43#include <qlineedit.h>
33 44
34class DateBookDayHeader; 45class DateBookDayHeader;
35class DateBookDB; 46class DateBookDB;
36class DateBookDBHoliday; 47class DateBookDBHoliday;
37class DatebookdayAllday; 48class DatebookdayAllday;
38class QDateTime; 49class QDateTime;
39class QMouseEvent; 50class QMouseEvent;
40class QPaintEvent; 51class QPaintEvent;
41class QResizeEvent; 52class QResizeEvent;
42 53
43class DateBookDayViewQuickLineEdit : public QLineEdit 54class DateBookDayViewQuickLineEdit : public QLineEdit
44{ 55{
45 Q_OBJECT 56 Q_OBJECT
46public: 57public:
47 DateBookDayViewQuickLineEdit(const QDateTime &start, const QDateTime &end,QWidget * parent, const char *name=0); 58 DateBookDayViewQuickLineEdit(const QDateTime &start, const QDateTime &end,QWidget * parent, const char *name=0);
48protected: 59protected:
49 Event quickEvent; 60 Event quickEvent;
50 int active; 61 int active;
51 void focusOutEvent( QFocusEvent *e ); 62 void focusOutEvent( QFocusEvent *e );
52protected slots: 63protected slots:
53 void slotReturnPressed(void); 64 void slotReturnPressed(void);
54 void finallyCallClose(); 65 void finallyCallClose();
55signals: 66signals:
56 void insertEvent(const Event &e); 67 void insertEvent(const Event &e);
57}; 68};
58 69
59 70
60class DateBookDayView : public QTable 71class DateBookDayView : public QTable
61{ 72{
62 Q_OBJECT 73 Q_OBJECT
63public: 74public:
64 DateBookDayView( bool hourClock, QWidget *parent, const char *name ); 75 DateBookDayView( bool hourClock, QWidget *parent, const char *name );
65 bool whichClock() const; 76 bool whichClock() const;
66 77
67 void setRowStyle( int style ); 78 void setRowStyle( int style );
68 79
69public slots: 80public slots:
70 void moveUp(); 81 void moveUp();
71 void moveDown(); 82 void moveDown();
72 void slotDateChanged( int year, int month, int day ); 83 void slotDateChanged( int year, int month, int day );
73 84
74signals: 85signals:
75 void sigColWidthChanged(); 86 void sigColWidthChanged();
76 void sigCapturedKey( const QString &txt ); 87 void sigCapturedKey( const QString &txt );
77protected slots: 88protected slots:
78 void slotChangeClock( bool ); 89 void slotChangeClock( bool );
79protected: 90protected:
80 virtual void paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected ); 91 virtual void paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected );
81 virtual void paintFocus( QPainter *p, const QRect &cr ); 92 virtual void paintFocus( QPainter *p, const QRect &cr );
82 93
83 virtual void resizeEvent( QResizeEvent *e ); 94 virtual void resizeEvent( QResizeEvent *e );
84 void keyPressEvent( QKeyEvent *e ); 95 void keyPressEvent( QKeyEvent *e );
85 void contentsMouseReleaseEvent( QMouseEvent *e ); 96 void contentsMouseReleaseEvent( QMouseEvent *e );
86 void initHeader(); 97 void initHeader();
87private: 98private:
88 bool ampm; 99 bool ampm;
89 QDate currDate; 100 QDate currDate;
90 DateBookDayViewQuickLineEdit *quickLineEdit; 101 DateBookDayViewQuickLineEdit *quickLineEdit;
91}; 102};
92 103
93class DateBookDay; 104class DateBookDay;
94class DateBookDayWidget : public QWidget 105class DateBookDayWidget : public QWidget
95{ 106{
96 Q_OBJECT 107 Q_OBJECT
97 108
98public: 109public:
99 DateBookDayWidget( const EffectiveEvent &e, DateBookDay *db ); 110 DateBookDayWidget( const EffectiveEvent &e, DateBookDay *db );
100 ~DateBookDayWidget(); 111 ~DateBookDayWidget();
101 112
102 const QRect &geometry() { return geom; } 113 const QRect &geometry() { return geom; }
103 void setGeometry( const QRect &r ); 114 void setGeometry( const QRect &r );
104 115
105 const EffectiveEvent &event() const { return ev; } 116 const EffectiveEvent &event() const { return ev; }
106 117
107signals: 118signals:
108 void deleteMe( const Event &e ); 119 void deleteMe( const Event &e );
109 void duplicateMe( const Event &e ); 120 void duplicateMe( const Event &e );
110 void editMe( const Event &e ); 121 void editMe( const Event &e );
111 void beamMe( const Event &e ); 122 void beamMe( const Event &e );
112 123
113protected: 124protected:
114 void paintEvent( QPaintEvent *e ); 125 void paintEvent( QPaintEvent *e );
115 void mousePressEvent( QMouseEvent *e ); 126 void mousePressEvent( QMouseEvent *e );
116 127
117private: 128private:
118 /** 129 /**
119 * Sets the text for an all day Event 130 * Sets the text for an all day Event
120 * All day events have no time associated 131 * All day events have no time associated
121 */ 132 */
122 void setAllDayText( QString& text ); 133 void setAllDayText( QString& text );
123 134
124 /** 135 /**
125 * Sets the EventText 136 * Sets the EventText
126 * it got a start and an end Time 137 * it got a start and an end Time
127 */ 138 */
128 void setEventText( QString& text ); 139 void setEventText( QString& text );
129 EffectiveEvent ev; 140 EffectiveEvent ev;
130 DateBookDay *dateBook; 141 DateBookDay *dateBook;
131 QString text; 142 QString text;
132 QRect geom; 143 QRect geom;
133}; 144};
134 145
135//Marker for current time in the dayview 146//Marker for current time in the dayview
136class DateBookDayTimeMarker : public QWidget 147class DateBookDayTimeMarker : public QWidget
137{ 148{
138 Q_OBJECT 149 Q_OBJECT
139 150
140public: 151public:
141 DateBookDayTimeMarker( DateBookDay *db ); 152 DateBookDayTimeMarker( DateBookDay *db );
142 ~DateBookDayTimeMarker(); 153 ~DateBookDayTimeMarker();
143 154
144 const QRect &geometry() { return geom; } 155 const QRect &geometry() { return geom; }
145 void setGeometry( const QRect &r ); 156 void setGeometry( const QRect &r );
146 void setTime( const QTime &t ); 157 void setTime( const QTime &t );
147 158
148signals: 159signals:
149 160
150protected: 161protected:
151 void paintEvent( QPaintEvent *e ); 162 void paintEvent( QPaintEvent *e );
152 163
153private: 164private:
154 QRect geom; 165 QRect geom;
155 QTime time; 166 QTime time;
156 DateBookDay *dateBook; 167 DateBookDay *dateBook;
157}; 168};
158 169
159//reimplemented the compareItems function so that it sorts DayWidgets by geometry heights 170//reimplemented the compareItems function so that it sorts DayWidgets by geometry heights
160class WidgetListClass : public QList<DateBookDayWidget> 171class WidgetListClass : public QList<DateBookDayWidget>
161{ 172{
162 private: 173 private:
163 174
164 int compareItems( QCollection::Item s1, QCollection::Item s2 ) 175 int compareItems( QCollection::Item s1, QCollection::Item s2 )
165 { 176 {
166 //hmm, don't punish me for that ;) 177 //hmm, don't punish me for that ;)
167 if (reinterpret_cast<DateBookDayWidget*>(s1)->geometry().height() > reinterpret_cast<DateBookDayWidget*>(s2)->geometry().height()) 178 if (reinterpret_cast<DateBookDayWidget*>(s1)->geometry().height() > reinterpret_cast<DateBookDayWidget*>(s2)->geometry().height())
168 { 179 {
169 return -1; 180 return -1;
170 } else 181 } else
171 { 182 {
172 return 1; 183 return 1;
173 } 184 }
174 } 185 }
175 186
176 187
177}; 188};
178 189
179class DateBookDay : public QVBox 190class DateBookDay : public QVBox
180{ 191{
181 Q_OBJECT 192 Q_OBJECT
182 193
183 friend class DateBookDayWidget; // for beam this occurence and access to DateBookDB 194 friend class DateBookDayWidget; // for beam this occurence and access to DateBookDB
184public: 195public:
185 DateBookDay( bool ampm, bool startOnMonday, DateBookDBHoliday *newDb,DateBookHoliday*newHdb, 196 DateBookDay( bool ampm, bool startOnMonday, DateBookDBHoliday *newDb,DateBookHoliday*newHdb,
186 QWidget *parent, const char *name ); 197 QWidget *parent, const char *name );
187 void selectedDates( QDateTime &start, QDateTime &end ); 198 void selectedDates( QDateTime &start, QDateTime &end );
188 199
189 QDate date() const; 200 QDate date() const;
190 DateBookDayView *dayView() const { return view; } 201 DateBookDayView *dayView() const { return view; }
191 void setStartViewTime( int startHere ); 202 void setStartViewTime( int startHere );
192 int startViewTime() const; 203 int startViewTime() const;
193 void setSelectedWidget( DateBookDayWidget * ); 204 void setSelectedWidget( DateBookDayWidget * );
194 DateBookDayWidget * getSelectedWidget( void ); 205 DateBookDayWidget * getSelectedWidget( void );
195 void setJumpToCurTime( bool bJump ); 206 void setJumpToCurTime( bool bJump );
196 void setRowStyle( int style ); 207 void setRowStyle( int style );
197 static QDate findRealStart( int uid, const QDate& isIncluded, 208 static QDate findRealStart( int uid, const QDate& isIncluded,
198 DateBookDB* ); 209 DateBookDB* );
199 210
200public slots: 211public slots:
201 void setDate( int y, int m, int d ); 212 void setDate( int y, int m, int d );
202 void setDate( QDate ); 213 void setDate( QDate );
203 void redraw(); 214 void redraw();
204 void slotWeekChanged( bool bStartOnMonday ); 215 void slotWeekChanged( bool bStartOnMonday );
205 void updateView(); //updates TimeMarker and DayWidget-colors 216 void updateView(); //updates TimeMarker and DayWidget-colors
206 217
207signals: 218signals:
208 void removeEvent( const Event& ); 219 void removeEvent( const Event& );
209 void editEvent( const Event& ); 220 void editEvent( const Event& );
210 void duplicateEvent( const Event& ); 221 void duplicateEvent( const Event& );
211 void beamEvent( const Event& ); 222 void beamEvent( const Event& );
212 void newEvent(); 223 void newEvent();
213 void sigNewEvent( const QString & ); 224 void sigNewEvent( const QString & );
214 225
215protected slots: 226protected slots:
216 void keyPressEvent(QKeyEvent *); 227 void keyPressEvent(QKeyEvent *);
217 228
218private slots: 229private slots:
219 void dateChanged( int y, int m, int d ); 230 void dateChanged( int y, int m, int d );
220 void slotColWidthChanged() { relayoutPage(); }; 231 void slotColWidthChanged() { relayoutPage(); };
221 232
222private: 233private:
223 void getEvents(); 234 void getEvents();
224 void relayoutPage( bool fromResize = false ); 235 void relayoutPage( bool fromResize = false );
225 DateBookDayWidget *intersects( const DateBookDayWidget *item, const QRect &geom ); 236 DateBookDayWidget *intersects( const DateBookDayWidget *item, const QRect &geom );
226 QDate currDate; 237 QDate currDate;
227 DateBookDayView *view; 238 DateBookDayView *view;
228 DateBookDayHeader *header; 239 DateBookDayHeader *header;
229 DatebookdayAllday *m_allDays; 240 DatebookdayAllday *m_allDays;
230 DateBookDBHoliday *db; 241 DateBookDBHoliday *db;
231 WidgetListClass widgetList; //reimplemented QList for sorting widgets by height 242 WidgetListClass widgetList; //reimplemented QList for sorting widgets by height
232 int startTime; 243 int startTime;
233 bool jumpToCurTime; //should we jump to current time in dayview? 244 bool jumpToCurTime; //should we jump to current time in dayview?
234 int rowStyle; 245 int rowStyle;
235 DateBookDayWidget *selectedWidget; //actual selected widget (obviously) 246 DateBookDayWidget *selectedWidget; //actual selected widget (obviously)
236 DateBookDayTimeMarker *timeMarker; //marker for current time 247 DateBookDayTimeMarker *timeMarker; //marker for current time
237 DateBookHoliday*_holiday_db; 248 DateBookHoliday*_holiday_db;
238}; 249};
239 250
240#endif 251#endif
diff --git a/core/pim/datebook/datebookdayallday.cpp b/core/pim/datebook/datebookdayallday.cpp
index 27fce44..3807542 100644
--- a/core/pim/datebook/datebookdayallday.cpp
+++ b/core/pim/datebook/datebookdayallday.cpp
@@ -1,269 +1,292 @@
1/**************************************************************************** 1/*
2** GPL by Rajko Albrecht 2                 This file is part of the Opie Project
3** 3
4** 4 Copyright (C) Rajko Albrecht <>
5** 5 Copyright (C) Opie Team <opie-devel@handhelds.org>
6** 6 =.
7** 7 .=l.
8****************************************************************************/ 8           .>+-=
9 _;:,     .>    :=|. This program is free software; you can
10.> <`_,   >  .   <= redistribute it and/or modify it under
11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
12.="- .-=="i,     .._ License as published by the Free Software
13 - .   .-<_>     .<> Foundation; either version 2 of the License,
14     ._= =}       : or (at your option) any later version.
15    .%`+i>       _;_.
16    .i_,=:_.      -<s. This program is distributed in the hope that
17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
18 : ..    .:,     . . . without even the implied warranty of
19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
21..}^=.=       =       ; Library General Public License for more
22++=   -.     .`     .: details.
23:     =  ...= . :.=-
24 -.   .:....=;==+<; You should have received a copy of the GNU
25  -_. . .   )=.  = Library General Public License along with
26    --        :-=` this library; see the file COPYING.LIB.
27 If not, write to the Free Software Foundation,
28 Inc., 59 Temple Place - Suite 330,
29 Boston, MA 02111-1307, USA.
30*/
31
9#include "datebookdayallday.h" 32#include "datebookdayallday.h"
10 33
11#include <qlayout.h> 34#include <qlayout.h>
12#include <qpe/ir.h> 35#include <qpe/ir.h>
13#include <qpopupmenu.h> 36#include <qpopupmenu.h>
14#include <qtimer.h> 37#include <qtimer.h>
15 38
16#include "datebookday.h" 39#include "datebookday.h"
17 40
18/* 41/*
19 * Constructs a DatebookdayAllday which is a child of 'parent', with the 42 * Constructs a DatebookdayAllday which is a child of 'parent', with the
20 * name 'name' and widget flags set to 'f' 43 * name 'name' and widget flags set to 'f'
21 */ 44 */
22DatebookdayAllday::DatebookdayAllday(DateBookDB* db, QWidget* parent, const char* name, WFlags ) 45DatebookdayAllday::DatebookdayAllday(DateBookDB* db, QWidget* parent, const char* name, WFlags )
23 : QScrollView( parent, name ),item_count(0),dateBook(db) 46 : QScrollView( parent, name ),item_count(0),dateBook(db)
24{ 47{
25 if ( !name ) 48 if ( !name )
26 setName( "DatebookdayAllday" ); 49 setName( "DatebookdayAllday" );
27 setMinimumSize( QSize( 0, 0 ) ); 50 setMinimumSize( QSize( 0, 0 ) );
28 setMaximumHeight(3* (QFontMetrics(font()).height()+4) ); 51 setMaximumHeight(3* (QFontMetrics(font()).height()+4) );
29 52
30 m_MainFrame = new QFrame(viewport()); 53 m_MainFrame = new QFrame(viewport());
31 m_MainFrame->setFrameStyle(QFrame::NoFrame|QFrame::Plain); 54 m_MainFrame->setFrameStyle(QFrame::NoFrame|QFrame::Plain);
32 setFrameStyle(QFrame::NoFrame|QFrame::Plain); 55 setFrameStyle(QFrame::NoFrame|QFrame::Plain);
33 //setResizePolicy( QScrollView::Default ); 56 //setResizePolicy( QScrollView::Default );
34 setResizePolicy(QScrollView::AutoOneFit); 57 setResizePolicy(QScrollView::AutoOneFit);
35 setHScrollBarMode( AlwaysOff ); 58 setHScrollBarMode( AlwaysOff );
36 addChild(m_MainFrame); 59 addChild(m_MainFrame);
37 60
38 datebookdayalldayLayout = new QVBoxLayout( m_MainFrame ); 61 datebookdayalldayLayout = new QVBoxLayout( m_MainFrame );
39 datebookdayalldayLayout->setSpacing( 0 ); 62 datebookdayalldayLayout->setSpacing( 0 );
40 datebookdayalldayLayout->setMargin( 0 ); 63 datebookdayalldayLayout->setMargin( 0 );
41 64
42 lblDesc = new DatebookEventDesc(parent->parentWidget(),""); 65 lblDesc = new DatebookEventDesc(parent->parentWidget(),"");
43 lblDesc->setBackgroundColor(Qt::yellow); 66 lblDesc->setBackgroundColor(Qt::yellow);
44 lblDesc->hide(); 67 lblDesc->hide();
45 subWidgets.setAutoDelete(true); 68 subWidgets.setAutoDelete(true);
46} 69}
47 70
48/* 71/*
49 * Destroys the object and frees any allocated resources 72 * Destroys the object and frees any allocated resources
50 */ 73 */
51DatebookdayAllday::~DatebookdayAllday() 74DatebookdayAllday::~DatebookdayAllday()
52{ 75{
53 // no need to delete child widgets, Qt does it all for us 76 // no need to delete child widgets, Qt does it all for us
54} 77}
55 78
56DatebookAlldayDisp* DatebookdayAllday::addEvent(const EffectiveEvent&ev) 79DatebookAlldayDisp* DatebookdayAllday::addEvent(const EffectiveEvent&ev)
57{ 80{
58 DatebookAlldayDisp * lb; 81 DatebookAlldayDisp * lb;
59 lb = new DatebookAlldayDisp(dateBook,ev,m_MainFrame,NULL); 82 lb = new DatebookAlldayDisp(dateBook,ev,m_MainFrame,NULL);
60 lb->show(); 83 lb->show();
61 datebookdayalldayLayout->addWidget(lb); 84 datebookdayalldayLayout->addWidget(lb);
62 subWidgets.append(lb); 85 subWidgets.append(lb);
63 86
64 connect(lb,SIGNAL(displayMe(const Event&)),lblDesc,SLOT(disp_event(const Event&))); 87 connect(lb,SIGNAL(displayMe(const Event&)),lblDesc,SLOT(disp_event(const Event&)));
65 ++item_count; 88 ++item_count;
66 89
67 return lb; 90 return lb;
68} 91}
69 92
70DatebookAlldayDisp* DatebookdayAllday::addHoliday(const QString&e) 93DatebookAlldayDisp* DatebookdayAllday::addHoliday(const QString&e)
71{ 94{
72 DatebookAlldayDisp * lb; 95 DatebookAlldayDisp * lb;
73 lb = new DatebookAlldayDisp(e,m_MainFrame,NULL); 96 lb = new DatebookAlldayDisp(e,m_MainFrame,NULL);
74 lb->show(); 97 lb->show();
75 datebookdayalldayLayout->addWidget(lb); 98 datebookdayalldayLayout->addWidget(lb);
76 subWidgets.append(lb); 99 subWidgets.append(lb);
77 100
78 connect(lb,SIGNAL(displayMe(const Event&)),lblDesc,SLOT(disp_event(const Event&))); 101 connect(lb,SIGNAL(displayMe(const Event&)),lblDesc,SLOT(disp_event(const Event&)));
79 ++item_count; 102 ++item_count;
80 103
81 return lb; 104 return lb;
82} 105}
83 106
84void DatebookdayAllday::removeAllEvents() 107void DatebookdayAllday::removeAllEvents()
85{ 108{
86 subWidgets.clear(); 109 subWidgets.clear();
87 item_count = 0; 110 item_count = 0;
88} 111}
89 112
90DatebookAlldayDisp::DatebookAlldayDisp(DateBookDB *db,const EffectiveEvent& ev, 113DatebookAlldayDisp::DatebookAlldayDisp(DateBookDB *db,const EffectiveEvent& ev,
91 QWidget* parent,const char* name,WFlags f) 114 QWidget* parent,const char* name,WFlags f)
92 : QLabel(parent,name,f),m_Ev(ev),dateBook(db) 115 : QLabel(parent,name,f),m_Ev(ev),dateBook(db)
93{ 116{
94 QString strDesc = m_Ev.description(); 117 QString strDesc = m_Ev.description();
95 strDesc = strDesc.replace(QRegExp("<"),"&#60;"); 118 strDesc = strDesc.replace(QRegExp("<"),"&#60;");
96 setBackgroundColor(yellow); 119 setBackgroundColor(yellow);
97 setText(strDesc); 120 setText(strDesc);
98 setFrameStyle(QFrame::Raised|QFrame::Panel); 121 setFrameStyle(QFrame::Raised|QFrame::Panel);
99 122
100 int s = QFontMetrics(font()).height()+4; 123 int s = QFontMetrics(font()).height()+4;
101 setMaximumHeight( s ); 124 setMaximumHeight( s );
102 setMinimumSize( QSize( 0, s ) ); 125 setMinimumSize( QSize( 0, s ) );
103 m_holiday = false; 126 m_holiday = false;
104} 127}
105 128
106DatebookAlldayDisp::DatebookAlldayDisp(const QString&aholiday,QWidget* parent,const char* name, WFlags fl) 129DatebookAlldayDisp::DatebookAlldayDisp(const QString&aholiday,QWidget* parent,const char* name, WFlags fl)
107 : QLabel(parent,name,fl),m_Ev(),dateBook(0) 130 : QLabel(parent,name,fl),m_Ev(),dateBook(0)
108{ 131{
109 QString strDesc = aholiday; 132 QString strDesc = aholiday;
110 strDesc = strDesc.replace(QRegExp("<"),"&#60;"); 133 strDesc = strDesc.replace(QRegExp("<"),"&#60;");
111 Event ev; 134 Event ev;
112 ev.setDescription(strDesc); 135 ev.setDescription(strDesc);
113 ev.setAllDay(true); 136 ev.setAllDay(true);
114 m_Ev.setEvent(ev); 137 m_Ev.setEvent(ev);
115 setText(strDesc); 138 setText(strDesc);
116 139
117 setAlignment(AlignHCenter); 140 setAlignment(AlignHCenter);
118 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum)); 141 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum));
119 142
120 //setFrameStyle(QFrame::Raised|QFrame::Panel); 143 //setFrameStyle(QFrame::Raised|QFrame::Panel);
121 //setBackgroundColor(yellow); 144 //setBackgroundColor(yellow);
122 145
123 int s = QFontMetrics(font()).height()+4; 146 int s = QFontMetrics(font()).height()+4;
124 setMaximumHeight( s ); 147 setMaximumHeight( s );
125 setMinimumSize( QSize( 0, s ) ); 148 setMinimumSize( QSize( 0, s ) );
126 149
127 m_holiday = true; 150 m_holiday = true;
128} 151}
129 152
130DatebookAlldayDisp::~DatebookAlldayDisp() 153DatebookAlldayDisp::~DatebookAlldayDisp()
131{ 154{
132} 155}
133 156
134void DatebookAlldayDisp::beam_single_event() 157void DatebookAlldayDisp::beam_single_event()
135{ 158{
136 if (m_holiday) return; 159 if (m_holiday) return;
137 // create an Event and beam it... 160 // create an Event and beam it...
138 /* 161 /*
139 * Start with the easy stuff. If start and end date is the same we can just use 162 * Start with the easy stuff. If start and end date is the same we can just use
140 * the values of effective m_Events 163 * the values of effective m_Events
141 * If it is a multi day m_Event we need to find the real start and end date... 164 * If it is a multi day m_Event we need to find the real start and end date...
142 */ 165 */
143 if ( m_Ev.event().start().date() == m_Ev.event().end().date() ) { 166 if ( m_Ev.event().start().date() == m_Ev.event().end().date() ) {
144 Event m_Event( m_Ev.event() ); 167 Event m_Event( m_Ev.event() );
145 168
146 QDateTime dt( m_Ev.date(), m_Ev.start() ); 169 QDateTime dt( m_Ev.date(), m_Ev.start() );
147 m_Event.setStart( dt ); 170 m_Event.setStart( dt );
148 171
149 dt.setTime( m_Ev.end() ); 172 dt.setTime( m_Ev.end() );
150 m_Event.setEnd( dt ); 173 m_Event.setEnd( dt );
151 emit beamMe( m_Event ); 174 emit beamMe( m_Event );
152 }else { 175 }else {
153 /* 176 /*
154 * at least the the Times are right now 177 * at least the the Times are right now
155 */ 178 */
156 QDateTime start( m_Ev.event().start() ); 179 QDateTime start( m_Ev.event().start() );
157 QDateTime end ( m_Ev.event().end () ); 180 QDateTime end ( m_Ev.event().end () );
158 181
159 /* 182 /*
160 * ok we know the start date or we need to find it 183 * ok we know the start date or we need to find it
161 */ 184 */
162 if ( m_Ev.start() != QTime( 0, 0, 0 ) ) { 185 if ( m_Ev.start() != QTime( 0, 0, 0 ) ) {
163 start.setDate( m_Ev.date() ); 186 start.setDate( m_Ev.date() );
164 }else { 187 }else {
165 QDate dt = DateBookDay::findRealStart( m_Ev.event().uid(), m_Ev.date(), dateBook ); 188 QDate dt = DateBookDay::findRealStart( m_Ev.event().uid(), m_Ev.date(), dateBook );
166 start.setDate( dt ); 189 start.setDate( dt );
167 } 190 }
168 191
169 /* 192 /*
170 * ok we know now the end date... 193 * ok we know now the end date...
171 * else 194 * else
172 * get to know the offset btw the real start and real end 195 * get to know the offset btw the real start and real end
173 * and then add it to the new start date... 196 * and then add it to the new start date...
174 */ 197 */
175 if ( m_Ev.end() != QTime(23, 59, 59 ) ) { 198 if ( m_Ev.end() != QTime(23, 59, 59 ) ) {
176 end.setDate( m_Ev.date() ); 199 end.setDate( m_Ev.date() );
177 }else{ 200 }else{
178 int days = m_Ev.event().start().date().daysTo( m_Ev.event().end().date() ); 201 int days = m_Ev.event().start().date().daysTo( m_Ev.event().end().date() );
179 end.setDate( start.date().addDays( days ) ); 202 end.setDate( start.date().addDays( days ) );
180 } 203 }
181 Event m_Event( m_Ev.event() ); 204 Event m_Event( m_Ev.event() );
182 m_Event.setStart( start ); 205 m_Event.setStart( start );
183 m_Event.setEnd ( end ); 206 m_Event.setEnd ( end );
184 emit beamMe( m_Event ); 207 emit beamMe( m_Event );
185 } 208 }
186} 209}
187 210
188void DatebookAlldayDisp::mousePressEvent(QMouseEvent*e) 211void DatebookAlldayDisp::mousePressEvent(QMouseEvent*e)
189{ 212{
190 Event ev = m_Ev.event(); 213 Event ev = m_Ev.event();
191 QColor b = backgroundColor(); 214 QColor b = backgroundColor();
192 setBackgroundColor(green); 215 setBackgroundColor(green);
193 update(); 216 update();
194 QPopupMenu m; 217 QPopupMenu m;
195 if (ev.isValidUid()) { 218 if (ev.isValidUid()) {
196 m.insertItem( DateBookDayWidget::tr( "Edit" ), 1 ); 219 m.insertItem( DateBookDayWidget::tr( "Edit" ), 1 );
197 m.insertItem( DateBookDayWidget::tr( "Duplicate" ), 4 ); 220 m.insertItem( DateBookDayWidget::tr( "Duplicate" ), 4 );
198 m.insertItem( DateBookDayWidget::tr( "Delete" ), 2 ); 221 m.insertItem( DateBookDayWidget::tr( "Delete" ), 2 );
199 if(Ir::supported()) m.insertItem( DateBookDayWidget::tr( "Beam" ), 3 ); 222 if(Ir::supported()) m.insertItem( DateBookDayWidget::tr( "Beam" ), 3 );
200 if(Ir::supported() && m_Ev.event().doRepeat() ) m.insertItem( DateBookDayWidget::tr( "Beam this occurence"), 5 ); 223 if(Ir::supported() && m_Ev.event().doRepeat() ) m.insertItem( DateBookDayWidget::tr( "Beam this occurence"), 5 );
201 } 224 }
202 m.insertItem( tr( "Info"),6); 225 m.insertItem( tr( "Info"),6);
203 int r = m.exec( e->globalPos() ); 226 int r = m.exec( e->globalPos() );
204 setBackgroundColor(b); 227 setBackgroundColor(b);
205 update(); 228 update();
206 switch (r) { 229 switch (r) {
207 case 1: 230 case 1:
208 emit editMe( ev ); 231 emit editMe( ev );
209 break; 232 break;
210 case 2: 233 case 2:
211 emit deleteMe( ev ); 234 emit deleteMe( ev );
212 break; 235 break;
213 case 3: 236 case 3:
214 emit beamMe( ev ); 237 emit beamMe( ev );
215 break; 238 break;
216 case 4: 239 case 4:
217 emit duplicateMe( ev ); 240 emit duplicateMe( ev );
218 break; 241 break;
219 case 5: 242 case 5:
220 beam_single_event(); 243 beam_single_event();
221 break; 244 break;
222 case 6: 245 case 6:
223 emit displayMe( ev ); 246 emit displayMe( ev );
224 break; 247 break;
225 default: 248 default:
226 break; 249 break;
227 } 250 }
228} 251}
229 252
230DatebookEventDesc::DatebookEventDesc(QWidget*parent,const char*name) 253DatebookEventDesc::DatebookEventDesc(QWidget*parent,const char*name)
231 :QLabel(parent,name) 254 :QLabel(parent,name)
232{ 255{
233 m_Timer=new QTimer(this); 256 m_Timer=new QTimer(this);
234 connect(m_Timer,SIGNAL(timeout()),this,SLOT(hide())); 257 connect(m_Timer,SIGNAL(timeout()),this,SLOT(hide()));
235 setFrameStyle(QFrame::Sunken|QFrame::Panel); 258 setFrameStyle(QFrame::Sunken|QFrame::Panel);
236 setTextFormat(RichText); 259 setTextFormat(RichText);
237} 260}
238 261
239DatebookEventDesc::~DatebookEventDesc() 262DatebookEventDesc::~DatebookEventDesc()
240{ 263{
241} 264}
242 265
243void DatebookEventDesc::mousePressEvent(QMouseEvent*) 266void DatebookEventDesc::mousePressEvent(QMouseEvent*)
244{ 267{
245 hide(); 268 hide();
246 if (m_Timer->isActive()) m_Timer->stop(); 269 if (m_Timer->isActive()) m_Timer->stop();
247} 270}
248 271
249void DatebookEventDesc::disp_event(const Event&e) 272void DatebookEventDesc::disp_event(const Event&e)
250{ 273{
251 if (m_Timer->isActive()) m_Timer->stop(); 274 if (m_Timer->isActive()) m_Timer->stop();
252 QString text; 275 QString text;
253 text = "<b><i>"+e.description()+"</i></b><br>"; 276 text = "<b><i>"+e.description()+"</i></b><br>";
254 if (e.notes().length()>0) { 277 if (e.notes().length()>0) {
255 text+="<b>"+e.notes()+"</b><br>"; 278 text+="<b>"+e.notes()+"</b><br>";
256 } 279 }
257 if (e.location().length()>0) { 280 if (e.location().length()>0) {
258 text+="<i>"+e.location()+"</i><br>"; 281 text+="<i>"+e.location()+"</i><br>";
259 } 282 }
260 text = text.replace(QRegExp("\n"),"<br>"); 283 text = text.replace(QRegExp("\n"),"<br>");
261 setText(text); 284 setText(text);
262 QSize s = sizeHint(); 285 QSize s = sizeHint();
263 s+=QSize(10,10); 286 s+=QSize(10,10);
264 resize(s); 287 resize(s);
265 move( QMAX(0,(parentWidget()->width()-width()) / 2), 288 move( QMAX(0,(parentWidget()->width()-width()) / 2),
266 (parentWidget()->height()-height())/2 ); 289 (parentWidget()->height()-height())/2 );
267 show(); 290 show();
268 m_Timer->start(2000,true); 291 m_Timer->start(2000,true);
269} 292}
diff --git a/core/pim/datebook/datebookdayallday.h b/core/pim/datebook/datebookdayallday.h
index 4f5cffa..5395dcf 100644
--- a/core/pim/datebook/datebookdayallday.h
+++ b/core/pim/datebook/datebookdayallday.h
@@ -1,86 +1,117 @@
1/*
2                 This file is part of the Opie Project
3
4 Copyright (C) Rajko Albrecht <>
5 Copyright (C) Opie Team <opie-devel@handhelds.org>
6 =.
7 .=l.
8           .>+-=
9 _;:,     .>    :=|. This program is free software; you can
10.> <`_,   >  .   <= redistribute it and/or modify it under
11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
12.="- .-=="i,     .._ License as published by the Free Software
13 - .   .-<_>     .<> Foundation; either version 2 of the License,
14     ._= =}       : or (at your option) any later version.
15    .%`+i>       _;_.
16    .i_,=:_.      -<s. This program is distributed in the hope that
17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
18 : ..    .:,     . . . without even the implied warranty of
19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
21..}^=.=       =       ; Library General Public License for more
22++=   -.     .`     .: details.
23:     =  ...= . :.=-
24 -.   .:....=;==+<; You should have received a copy of the GNU
25  -_. . .   )=.  = Library General Public License along with
26    --        :-=` this library; see the file COPYING.LIB.
27 If not, write to the Free Software Foundation,
28 Inc., 59 Temple Place - Suite 330,
29 Boston, MA 02111-1307, USA.
30*/
31
1#ifndef DATEBOOKDAYALLDAYBASE_H 32#ifndef DATEBOOKDAYALLDAYBASE_H
2#define DATEBOOKDAYALLDAYBASE_H 33#define DATEBOOKDAYALLDAYBASE_H
3 34
4#include <qvariant.h> 35#include <qvariant.h>
5#include <qframe.h> 36#include <qframe.h>
6#include <qscrollview.h> 37#include <qscrollview.h>
7#include <qlabel.h> 38#include <qlabel.h>
8#include <qlist.h> 39#include <qlist.h>
9#include <qpe/event.h> 40#include <qpe/event.h>
10 41
11class QVBoxLayout; 42class QVBoxLayout;
12class QHBoxLayout; 43class QHBoxLayout;
13class QGridLayout; 44class QGridLayout;
14class DatebookAlldayDisp; 45class DatebookAlldayDisp;
15class DatebookEventDesc; 46class DatebookEventDesc;
16class DateBookDB; 47class DateBookDB;
17 48
18class DatebookdayAllday : public QScrollView 49class DatebookdayAllday : public QScrollView
19{ 50{
20 Q_OBJECT 51 Q_OBJECT
21 52
22public: 53public:
23 DatebookdayAllday(DateBookDB* db, 54 DatebookdayAllday(DateBookDB* db,
24 QWidget* parent = 0, const char* name = 0, WFlags fl = 0); 55 QWidget* parent = 0, const char* name = 0, WFlags fl = 0);
25 ~DatebookdayAllday(); 56 ~DatebookdayAllday();
26 DatebookAlldayDisp* addEvent(const EffectiveEvent&e); 57 DatebookAlldayDisp* addEvent(const EffectiveEvent&e);
27 DatebookAlldayDisp* addHoliday(const QString&e); 58 DatebookAlldayDisp* addHoliday(const QString&e);
28 const unsigned int items()const{return item_count;} 59 const unsigned int items()const{return item_count;}
29 60
30public slots: 61public slots:
31 void removeAllEvents(); 62 void removeAllEvents();
32 63
33protected: 64protected:
34 QFrame * m_MainFrame; 65 QFrame * m_MainFrame;
35 QVBoxLayout* datebookdayalldayLayout; 66 QVBoxLayout* datebookdayalldayLayout;
36 DatebookEventDesc * lblDesc; 67 DatebookEventDesc * lblDesc;
37 unsigned int item_count; 68 unsigned int item_count;
38 QList<DatebookAlldayDisp> subWidgets; 69 QList<DatebookAlldayDisp> subWidgets;
39 DateBookDB *dateBook; 70 DateBookDB *dateBook;
40}; 71};
41 72
42class DatebookAlldayDisp : public QLabel 73class DatebookAlldayDisp : public QLabel
43{ 74{
44 Q_OBJECT 75 Q_OBJECT
45 76
46public: 77public:
47 DatebookAlldayDisp(DateBookDB* db,const EffectiveEvent& e, 78 DatebookAlldayDisp(DateBookDB* db,const EffectiveEvent& e,
48 QWidget* parent=0,const char* name = 0, WFlags fl=0); 79 QWidget* parent=0,const char* name = 0, WFlags fl=0);
49 DatebookAlldayDisp(const QString&aholiday, 80 DatebookAlldayDisp(const QString&aholiday,
50 QWidget* parent=0,const char* name = 0, WFlags fl=0); 81 QWidget* parent=0,const char* name = 0, WFlags fl=0);
51 virtual ~DatebookAlldayDisp(); 82 virtual ~DatebookAlldayDisp();
52 83
53signals: 84signals:
54 void deleteMe( const Event &e ); 85 void deleteMe( const Event &e );
55 void duplicateMe( const Event &e ); 86 void duplicateMe( const Event &e );
56 void editMe( const Event &e ); 87 void editMe( const Event &e );
57 void beamMe( const Event &e ); 88 void beamMe( const Event &e );
58 void displayMe(const Event &e); 89 void displayMe(const Event &e);
59 90
60public slots: 91public slots:
61 92
62protected: 93protected:
63 EffectiveEvent m_Ev; 94 EffectiveEvent m_Ev;
64 DateBookDB* dateBook; 95 DateBookDB* dateBook;
65 void mousePressEvent( QMouseEvent *e ); 96 void mousePressEvent( QMouseEvent *e );
66 void beam_single_event(); 97 void beam_single_event();
67 bool m_holiday:1; 98 bool m_holiday:1;
68}; 99};
69 100
70class DatebookEventDesc: public QLabel 101class DatebookEventDesc: public QLabel
71{ 102{
72 Q_OBJECT 103 Q_OBJECT
73 104
74public: 105public:
75 DatebookEventDesc(QWidget* Parent=0,const char* name = 0); 106 DatebookEventDesc(QWidget* Parent=0,const char* name = 0);
76 virtual ~DatebookEventDesc(); 107 virtual ~DatebookEventDesc();
77 108
78public slots: 109public slots:
79 void disp_event(const Event&e); 110 void disp_event(const Event&e);
80 111
81protected: 112protected:
82 void mousePressEvent(QMouseEvent*e); 113 void mousePressEvent(QMouseEvent*e);
83 QTimer* m_Timer; 114 QTimer* m_Timer;
84}; 115};
85 116
86#endif // DATEBOOKDAYALLDAYBASE_H 117#endif // DATEBOOKDAYALLDAYBASE_H
diff --git a/core/pim/datebook/datebookdayheaderimpl.cpp b/core/pim/datebook/datebookdayheaderimpl.cpp
index 51b78ca..0df1bfe 100644
--- a/core/pim/datebook/datebookdayheaderimpl.cpp
+++ b/core/pim/datebook/datebookdayheaderimpl.cpp
@@ -1,200 +1,212 @@
1/********************************************************************** 1/*
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2                 This file is part of the Opie Project
3** 3
4** This file is part of Qtopia Environment. 4 Copyright (C) Opie Team <opie-devel@handhelds.org>
5** 5 =.
6** This file may be distributed and/or modified under the terms of the 6 .=l.
7** GNU General Public License version 2 as published by the Free Software 7           .>+-=
8** Foundation and appearing in the file LICENSE.GPL included in the 8 _;:,     .>    :=|. This program is free software; you can
9** packaging of this file. 9.> <`_,   >  .   <= redistribute it and/or modify it under
10** 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11.="- .-=="i,     .._ License as published by the Free Software
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13** 13     ._= =}       : or (at your option) any later version.
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14    .%`+i>       _;_.
15** 15    .i_,=:_.      -<s. This program is distributed in the hope that
16** Contact info@trolltech.com if any conditions of this licensing are 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17** not clear to you. 17 : ..    .:,     . . . without even the implied warranty of
18** 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19**********************************************************************/ 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details.
22:     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA.
29*/
30
20#include "datebookdayheaderimpl.h" 31#include "datebookdayheaderimpl.h"
21 32
33#include <opie2/oresource.h>
34
22#include <qpe/datebookmonth.h> 35#include <qpe/datebookmonth.h>
23#include <qpe/resource.h>
24 36
25#include <qbuttongroup.h> 37#include <qbuttongroup.h>
26#include <qtoolbutton.h> 38#include <qtoolbutton.h>
27 39
28 40
29/* 41/*
30 * Constructs a DateBookDayHeader which is a child of 'parent', with the 42 * Constructs a DateBookDayHeader which is a child of 'parent', with the
31 * name 'name' and widget flags set to 'f' 43 * name 'name' and widget flags set to 'f'
32 * 44 *
33 * The dialog will by default be modeless, unless you set 'modal' to 45 * The dialog will by default be modeless, unless you set 'modal' to
34 * TRUE to construct a modal dialog. 46 * TRUE to construct a modal dialog.
35 */ 47 */
36DateBookDayHeader::DateBookDayHeader( bool useMonday, 48DateBookDayHeader::DateBookDayHeader( bool useMonday,
37 QWidget* parent, const char* name ) 49 QWidget* parent, const char* name )
38 : DateBookDayHeaderBase( parent, name ), 50 : DateBookDayHeaderBase( parent, name ),
39 bUseMonday( useMonday ) 51 bUseMonday( useMonday )
40{ 52{
41 connect(date,SIGNAL(pressed()),this,SLOT(pickDate())); 53 connect(date,SIGNAL(pressed()),this,SLOT(pickDate()));
42 54
43 setupNames(); 55 setupNames();
44 56
45 forward->setPixmap( Resource::loadPixmap( "forward" ) ); 57 forward->setPixmap( Opie::Core::OResource::loadPixmap( "forward" ) );
46 back->setPixmap( Resource::loadPixmap( "back" ) ); 58 back->setPixmap( Opie::Core::OResource::loadPixmap( "back" ) );
47 forwardweek->setPixmap( Resource::loadPixmap( "fastforward" ) ); 59 forwardweek->setPixmap( Opie::Core::OResource::loadPixmap( "fastforward" ) );
48 backweek->setPixmap( Resource::loadPixmap( "fastback" ) ); 60 backweek->setPixmap( Opie::Core::OResource::loadPixmap( "fastback" ) );
49 61
50 setBackgroundMode( PaletteButton ); 62 setBackgroundMode( PaletteButton );
51 grpDays->setBackgroundMode( PaletteButton ); 63 grpDays->setBackgroundMode( PaletteButton );
52} 64}
53 65
54/* 66/*
55 * Destroys the object and frees any allocated resources 67 * Destroys the object and frees any allocated resources
56 */ 68 */
57DateBookDayHeader::~DateBookDayHeader() 69DateBookDayHeader::~DateBookDayHeader()
58{ 70{
59 // no need to delete child widgets, Qt does it all for us 71 // no need to delete child widgets, Qt does it all for us
60} 72}
61 73
62void DateBookDayHeader::setStartOfWeek( bool onMonday ) 74void DateBookDayHeader::setStartOfWeek( bool onMonday )
63{ 75{
64 bUseMonday = onMonday; 76 bUseMonday = onMonday;
65 setupNames(); 77 setupNames();
66 setDate( currDate.year(), currDate.month(), currDate.day() ); 78 setDate( currDate.year(), currDate.month(), currDate.day() );
67} 79}
68 80
69void DateBookDayHeader::setupNames() 81void DateBookDayHeader::setupNames()
70{ 82{
71 if ( bUseMonday ) { 83 if ( bUseMonday ) {
72 cmdDay1->setText( DateBookDayHeaderBase::tr("Monday").left(1) ); 84 cmdDay1->setText( DateBookDayHeaderBase::tr("Monday").left(1) );
73 cmdDay2->setText( DateBookDayHeaderBase::tr("Tuesday").left(1) ); 85 cmdDay2->setText( DateBookDayHeaderBase::tr("Tuesday").left(1) );
74 cmdDay3->setText( DateBookDayHeaderBase::tr("Wednesday").left(1) ); 86 cmdDay3->setText( DateBookDayHeaderBase::tr("Wednesday").left(1) );
75 cmdDay4->setText( DateBookDayHeaderBase::tr("Thursday").left(1) ); 87 cmdDay4->setText( DateBookDayHeaderBase::tr("Thursday").left(1) );
76 cmdDay5->setText( DateBookDayHeaderBase::tr("Friday").left(1) ); 88 cmdDay5->setText( DateBookDayHeaderBase::tr("Friday").left(1) );
77 cmdDay6->setText( DateBookDayHeaderBase::tr("Saturday").left(1) ); 89 cmdDay6->setText( DateBookDayHeaderBase::tr("Saturday").left(1) );
78 cmdDay7->setText( DateBookDayHeaderBase::tr("Sunday").left(1) ); 90 cmdDay7->setText( DateBookDayHeaderBase::tr("Sunday").left(1) );
79 } else { 91 } else {
80 cmdDay1->setText( DateBookDayHeaderBase::tr("Sunday").left(1) ); 92 cmdDay1->setText( DateBookDayHeaderBase::tr("Sunday").left(1) );
81 cmdDay2->setText( DateBookDayHeaderBase::tr("Monday").left(1) ); 93 cmdDay2->setText( DateBookDayHeaderBase::tr("Monday").left(1) );
82 cmdDay3->setText( DateBookDayHeaderBase::tr("Tuesday").left(1) ); 94 cmdDay3->setText( DateBookDayHeaderBase::tr("Tuesday").left(1) );
83 cmdDay4->setText( DateBookDayHeaderBase::tr("Wednesday").left(1) ); 95 cmdDay4->setText( DateBookDayHeaderBase::tr("Wednesday").left(1) );
84 cmdDay5->setText( DateBookDayHeaderBase::tr("Thursday").left(1) ); 96 cmdDay5->setText( DateBookDayHeaderBase::tr("Thursday").left(1) );
85 cmdDay6->setText( DateBookDayHeaderBase::tr("Friday").left(1) ); 97 cmdDay6->setText( DateBookDayHeaderBase::tr("Friday").left(1) );
86 cmdDay7->setText( DateBookDayHeaderBase::tr("Saturday").left(1) ); 98 cmdDay7->setText( DateBookDayHeaderBase::tr("Saturday").left(1) );
87 } 99 }
88} 100}
89 101
90 102
91void DateBookDayHeader::pickDate() 103void DateBookDayHeader::pickDate()
92{ 104{
93 static QPopupMenu *m1 = 0; 105 static QPopupMenu *m1 = 0;
94 static DateBookMonth *picker = 0; 106 static DateBookMonth *picker = 0;
95 if ( !m1 ) { 107 if ( !m1 ) {
96 m1 = new QPopupMenu( this ); 108 m1 = new QPopupMenu( this );
97 picker = new DateBookMonth( m1, 0, TRUE ); 109 picker = new DateBookMonth( m1, 0, TRUE );
98 m1->insertItem( picker ); 110 m1->insertItem( picker );
99 connect( picker, SIGNAL( dateClicked(int,int,int) ), 111 connect( picker, SIGNAL( dateClicked(int,int,int) ),
100 this, SLOT( setDate(int,int,int) ) ); 112 this, SLOT( setDate(int,int,int) ) );
101 connect( m1, SIGNAL( aboutToHide() ), 113 connect( m1, SIGNAL( aboutToHide() ),
102 this, SLOT( gotHide() ) ); 114 this, SLOT( gotHide() ) );
103 } 115 }
104 picker->setDate( currDate.year(), currDate.month(), currDate.day() ); 116 picker->setDate( currDate.year(), currDate.month(), currDate.day() );
105 m1->popup(mapToGlobal(date->pos()+QPoint(0,date->height()))); 117 m1->popup(mapToGlobal(date->pos()+QPoint(0,date->height())));
106 picker->setFocus(); 118 picker->setFocus();
107} 119}
108 120
109void DateBookDayHeader::gotHide() 121void DateBookDayHeader::gotHide()
110{ 122{
111 // we have to redo the button... 123 // we have to redo the button...
112 date->setDown( false ); 124 date->setDown( false );
113} 125}
114 126
115/* 127/*
116 * public slot 128 * public slot
117 */ 129 */
118void DateBookDayHeader::goBack() 130void DateBookDayHeader::goBack()
119{ 131{
120 currDate = currDate.addDays( -1 ); 132 currDate = currDate.addDays( -1 );
121 setDate( currDate.year(), currDate.month(), currDate.day() ); 133 setDate( currDate.year(), currDate.month(), currDate.day() );
122} 134}
123/* 135/*
124 * public slot 136 * public slot
125 */ 137 */
126void DateBookDayHeader::goForward() 138void DateBookDayHeader::goForward()
127{ 139{
128 currDate = currDate.addDays( 1 ); 140 currDate = currDate.addDays( 1 );
129 setDate( currDate.year(), currDate.month(), currDate.day() ); 141 setDate( currDate.year(), currDate.month(), currDate.day() );
130} 142}
131/* 143/*
132 * public slot 144 * public slot
133 */ 145 */
134void DateBookDayHeader::goBackWeek() 146void DateBookDayHeader::goBackWeek()
135{ 147{
136 currDate = currDate.addDays( -7 ); 148 currDate = currDate.addDays( -7 );
137 setDate( currDate.year(), currDate.month(), currDate.day() ); 149 setDate( currDate.year(), currDate.month(), currDate.day() );
138} 150}
139/* 151/*
140 * public slot 152 * public slot
141 */ 153 */
142void DateBookDayHeader::goForwardWeek() 154void DateBookDayHeader::goForwardWeek()
143{ 155{
144 currDate = currDate.addDays( 7 ); 156 currDate = currDate.addDays( 7 );
145 setDate( currDate.year(), currDate.month(), currDate.day() ); 157 setDate( currDate.year(), currDate.month(), currDate.day() );
146} 158}
147 159
148 160
149/* 161/*
150 * public slot 162 * public slot
151 */ 163 */
152void DateBookDayHeader::setDate( int y, int m, int d ) 164void DateBookDayHeader::setDate( int y, int m, int d )
153{ 165{
154 currDate.setYMD( y, m, d ); 166 currDate.setYMD( y, m, d );
155 date->setText( TimeString::shortDate( currDate ) ); 167 date->setText( TimeString::shortDate( currDate ) );
156 168
157 int iDayOfWeek = currDate.dayOfWeek(); 169 int iDayOfWeek = currDate.dayOfWeek();
158 // cleverly adjust the day depending on how we start the week 170 // cleverly adjust the day depending on how we start the week
159 if ( bUseMonday ) 171 if ( bUseMonday )
160 iDayOfWeek--; 172 iDayOfWeek--;
161 else { 173 else {
162 if ( iDayOfWeek == 7 ) // Sunday 174 if ( iDayOfWeek == 7 ) // Sunday
163 iDayOfWeek = 0; 175 iDayOfWeek = 0;
164 } 176 }
165 grpDays->setButton( iDayOfWeek ); 177 grpDays->setButton( iDayOfWeek );
166 emit dateChanged( y, m, d ); 178 emit dateChanged( y, m, d );
167} 179}
168 180
169/* 181/*
170 * public slot 182 * public slot
171 */ 183 */
172void DateBookDayHeader::setDay( int day ) 184void DateBookDayHeader::setDay( int day )
173{ 185{
174 int realDay; 186 int realDay;
175 int dayOfWeek = currDate.dayOfWeek(); 187 int dayOfWeek = currDate.dayOfWeek();
176 188
177 // a little adjustment is needed... 189 // a little adjustment is needed...
178 if ( bUseMonday ) 190 if ( bUseMonday )
179 realDay = day + 1 ; 191 realDay = day + 1 ;
180 else if ( !bUseMonday && day == 0 ) // sunday 192 else if ( !bUseMonday && day == 0 ) // sunday
181 realDay = 7; 193 realDay = 7;
182 else 194 else
183 realDay = day; 195 realDay = day;
184 // special cases first... 196 // special cases first...
185 if ( realDay == 7 && !bUseMonday ) { 197 if ( realDay == 7 && !bUseMonday ) {
186 while ( currDate.dayOfWeek() != realDay ) 198 while ( currDate.dayOfWeek() != realDay )
187 currDate = currDate.addDays( -1 ); 199 currDate = currDate.addDays( -1 );
188 } else if ( !bUseMonday && dayOfWeek == 7 && dayOfWeek > realDay ) { 200 } else if ( !bUseMonday && dayOfWeek == 7 && dayOfWeek > realDay ) {
189 while ( currDate.dayOfWeek() != realDay ) 201 while ( currDate.dayOfWeek() != realDay )
190 currDate = currDate.addDays( 1 ); 202 currDate = currDate.addDays( 1 );
191 } else if ( dayOfWeek < realDay ) { 203 } else if ( dayOfWeek < realDay ) {
192 while ( currDate.dayOfWeek() < realDay ) 204 while ( currDate.dayOfWeek() < realDay )
193 currDate = currDate.addDays( 1 ); 205 currDate = currDate.addDays( 1 );
194 } else if ( dayOfWeek > realDay ) { 206 } else if ( dayOfWeek > realDay ) {
195 while ( currDate.dayOfWeek() > realDay ) 207 while ( currDate.dayOfWeek() > realDay )
196 currDate = currDate.addDays( -1 ); 208 currDate = currDate.addDays( -1 );
197 } 209 }
198 // update the date... 210 // update the date...
199 setDate( currDate.year(), currDate.month(), currDate.day() ); 211 setDate( currDate.year(), currDate.month(), currDate.day() );
200} 212}
diff --git a/core/pim/datebook/datebookdayheaderimpl.h b/core/pim/datebook/datebookdayheaderimpl.h
index a07bd67..ea9f917 100644
--- a/core/pim/datebook/datebookdayheaderimpl.h
+++ b/core/pim/datebook/datebookdayheaderimpl.h
@@ -1,59 +1,70 @@
1/********************************************************************** 1/*
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2                 This file is part of the Opie Project
3** 3
4** This file is part of Qtopia Environment. 4 Copyright (C) Opie Team <opie-devel@handhelds.org>
5** 5 =.
6** This file may be distributed and/or modified under the terms of the 6 .=l.
7** GNU General Public License version 2 as published by the Free Software 7           .>+-=
8** Foundation and appearing in the file LICENSE.GPL included in the 8 _;:,     .>    :=|. This program is free software; you can
9** packaging of this file. 9.> <`_,   >  .   <= redistribute it and/or modify it under
10** 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11.="- .-=="i,     .._ License as published by the Free Software
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13** 13     ._= =}       : or (at your option) any later version.
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14    .%`+i>       _;_.
15** 15    .i_,=:_.      -<s. This program is distributed in the hope that
16** Contact info@trolltech.com if any conditions of this licensing are 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17** not clear to you. 17 : ..    .:,     . . . without even the implied warranty of
18** 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19**********************************************************************/ 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details.
22:     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA.
29*/
30
20#ifndef DATEBOOKDAYHEADER_H 31#ifndef DATEBOOKDAYHEADER_H
21#define DATEBOOKDAYHEADER_H 32#define DATEBOOKDAYHEADER_H
22#include "datebookdayheader.h" 33#include "datebookdayheader.h"
23 34
24#include <qdatetime.h> 35#include <qdatetime.h>
25 36
26class DateBookDayHeader : public DateBookDayHeaderBase 37class DateBookDayHeader : public DateBookDayHeaderBase
27{ 38{
28 Q_OBJECT 39 Q_OBJECT
29 40
30public: 41public:
31 DateBookDayHeader( bool bUseMonday, QWidget* parent = 0, 42 DateBookDayHeader( bool bUseMonday, QWidget* parent = 0,
32 const char* name = 0 ); 43 const char* name = 0 );
33 ~DateBookDayHeader(); 44 ~DateBookDayHeader();
34 void setStartOfWeek( bool onMonday ); 45 void setStartOfWeek( bool onMonday );
35 46
36public slots: 47public slots:
37 void goBack(); 48 void goBack();
38 void goForward(); 49 void goForward();
39 void goBackWeek(); 50 void goBackWeek();
40 void goForwardWeek(); 51 void goForwardWeek();
41 void setDate( int, int, int ); 52 void setDate( int, int, int );
42 void setDay( int ); 53 void setDay( int );
43 void gotHide(); 54 void gotHide();
44 55
45signals: 56signals:
46 void dateChanged( int y, int m, int d ); 57 void dateChanged( int y, int m, int d );
47 58
48private slots: 59private slots:
49 void pickDate(); 60 void pickDate();
50 61
51 62
52private: 63private:
53 QDate currDate; 64 QDate currDate;
54 bool bUseMonday; 65 bool bUseMonday;
55 void setupNames(); 66 void setupNames();
56 67
57}; 68};
58 69
59#endif // DATEBOOKDAYHEADER_H 70#endif // DATEBOOKDAYHEADER_H
diff --git a/core/pim/datebook/datebooksettings.cpp b/core/pim/datebook/datebooksettings.cpp
index 561dc38..c72cd59 100644
--- a/core/pim/datebook/datebooksettings.cpp
+++ b/core/pim/datebook/datebooksettings.cpp
@@ -1,219 +1,229 @@
1/********************************************************************** 1/*
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2                 This file is part of the Opie Project
3** 3
4** This file is part of Qtopia Environment. 4 Copyright (C) Opie Team <opie-devel@handhelds.org>
5** 5 =.
6** This file may be distributed and/or modified under the terms of the 6 .=l.
7** GNU General Public License version 2 as published by the Free Software 7           .>+-=
8** Foundation and appearing in the file LICENSE.GPL included in the 8 _;:,     .>    :=|. This program is free software; you can
9** packaging of this file. 9.> <`_,   >  .   <= redistribute it and/or modify it under
10** 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11.="- .-=="i,     .._ License as published by the Free Software
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13** 13     ._= =}       : or (at your option) any later version.
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14    .%`+i>       _;_.
15** 15    .i_,=:_.      -<s. This program is distributed in the hope that
16** Contact info@trolltech.com if any conditions of this licensing are 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17** not clear to you. 17 : ..    .:,     . . . without even the implied warranty of
18** 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19**********************************************************************/ 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details.
22:     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA.
29*/
20 30
21#include "datebooksettings.h" 31#include "datebooksettings.h"
22 32
23#include <opie2/opluginloader.h> 33#include <opie2/opluginloader.h>
24#include <opie2/odebug.h> 34#include <opie2/odebug.h>
25#include <opie2/oholidaypluginif.h> 35#include <opie2/oholidaypluginif.h>
26#include <opie2/oholidayplugin.h> 36#include <opie2/oholidayplugin.h>
27#include <opie2/oholidayplugincfgwidget.h> 37#include <opie2/oholidayplugincfgwidget.h>
28 38
29#include <qpe/qpeapplication.h> 39#include <qpe/qpeapplication.h>
30 40
31#include <qspinbox.h> 41#include <qspinbox.h>
32#include <qcheckbox.h> 42#include <qcheckbox.h>
33#include <qlistview.h> 43#include <qlistview.h>
34#include <qheader.h> 44#include <qheader.h>
35#include <qtabwidget.h> 45#include <qtabwidget.h>
36#include <qlayout.h> 46#include <qlayout.h>
37 47
38DateBookSettings::DateBookSettings( bool whichClock, QWidget *parent, 48DateBookSettings::DateBookSettings( bool whichClock, QWidget *parent,
39 const char *name, bool modal, WFlags fl ) 49 const char *name, bool modal, WFlags fl )
40 : DateBookSettingsBase( parent, name, modal, fl ), 50 : DateBookSettingsBase( parent, name, modal, fl ),
41 ampm( whichClock ) 51 ampm( whichClock )
42{ 52{
43 init(); 53 init();
44 QObject::connect( qApp, SIGNAL( clockChanged(bool) ), this, SLOT( slotChangeClock(bool) ) ); 54 QObject::connect( qApp, SIGNAL( clockChanged(bool) ), this, SLOT( slotChangeClock(bool) ) );
45 QArray<int> categories; 55 QArray<int> categories;
46 comboCategory->setCategories( categories, "Calendar", tr("Calendar") ); 56 comboCategory->setCategories( categories, "Calendar", tr("Calendar") );
47 m_loader = 0; 57 m_loader = 0;
48 m_manager = 0; 58 m_manager = 0;
49 m_PluginListView->header()->hide(); 59 m_PluginListView->header()->hide();
50 m_PluginListView->setSorting(-1); 60 m_PluginListView->setSorting(-1);
51} 61}
52 62
53DateBookSettings::~DateBookSettings() 63DateBookSettings::~DateBookSettings()
54{ 64{
55} 65}
56 66
57void DateBookSettings::setStartTime( int newStartViewTime ) 67void DateBookSettings::setStartTime( int newStartViewTime )
58{ 68{
59 if ( ampm ) { 69 if ( ampm ) {
60 if ( newStartViewTime >= 12 ) { 70 if ( newStartViewTime >= 12 ) {
61 newStartViewTime %= 12; 71 newStartViewTime %= 12;
62 if ( newStartViewTime == 0 ) 72 if ( newStartViewTime == 0 )
63 newStartViewTime = 12; 73 newStartViewTime = 12;
64 spinStart->setSuffix( tr(":00 PM") ); 74 spinStart->setSuffix( tr(":00 PM") );
65 } 75 }
66 else if ( newStartViewTime == 0 ) { 76 else if ( newStartViewTime == 0 ) {
67 newStartViewTime = 12; 77 newStartViewTime = 12;
68 spinStart->setSuffix( tr(":00 AM") ); 78 spinStart->setSuffix( tr(":00 AM") );
69 } 79 }
70 oldtime = newStartViewTime; 80 oldtime = newStartViewTime;
71 } 81 }
72 spinStart->setValue( newStartViewTime ); 82 spinStart->setValue( newStartViewTime );
73} 83}
74 84
75int DateBookSettings::startTime() const 85int DateBookSettings::startTime() const
76{ 86{
77 int returnMe = spinStart->value(); 87 int returnMe = spinStart->value();
78 if ( ampm ) { 88 if ( ampm ) {
79 if ( returnMe != 12 && spinStart->suffix().contains(tr("PM"), FALSE) ) 89 if ( returnMe != 12 && spinStart->suffix().contains(tr("PM"), FALSE) )
80 returnMe += 12; 90 returnMe += 12;
81 else if (returnMe == 12 && spinStart->suffix().contains(tr("AM"), TRUE)) 91 else if (returnMe == 12 && spinStart->suffix().contains(tr("AM"), TRUE))
82 returnMe = 0; 92 returnMe = 0;
83 } 93 }
84 return returnMe; 94 return returnMe;
85} 95}
86 96
87void DateBookSettings::setPluginList(Opie::Core::OPluginManager*aManager,Opie::Core::OPluginLoader*aLoader) 97void DateBookSettings::setPluginList(Opie::Core::OPluginManager*aManager,Opie::Core::OPluginLoader*aLoader)
88{ 98{
89 m_manager = aManager; 99 m_manager = aManager;
90 m_loader = aLoader; 100 m_loader = aLoader;
91 if (!aManager||!aLoader) return; 101 if (!aManager||!aLoader) return;
92 Opie::Core::OPluginItem::List inLst = m_loader->allAvailable(true); 102 Opie::Core::OPluginItem::List inLst = m_loader->allAvailable(true);
93 QCheckListItem *pitem = 0; 103 QCheckListItem *pitem = 0;
94 104
95 for ( Opie::Core::OPluginItem::List::Iterator it = inLst.begin(); it != inLst.end(); ++it ) { 105 for ( Opie::Core::OPluginItem::List::Iterator it = inLst.begin(); it != inLst.end(); ++it ) {
96 pitem = new QCheckListItem(m_PluginListView,(*it).name(),QCheckListItem::CheckBox); 106 pitem = new QCheckListItem(m_PluginListView,(*it).name(),QCheckListItem::CheckBox);
97 pitem->setOn( (*it).isEnabled() ); 107 pitem->setOn( (*it).isEnabled() );
98 108
99 Opie::Datebook::HolidayPluginIf*hif = m_loader->load<Opie::Datebook::HolidayPluginIf>(*it,IID_HOLIDAY_PLUGIN); 109 Opie::Datebook::HolidayPluginIf*hif = m_loader->load<Opie::Datebook::HolidayPluginIf>(*it,IID_HOLIDAY_PLUGIN);
100 if (!hif) continue; 110 if (!hif) continue;
101 Opie::Datebook::HolidayPlugin*pl = hif->plugin(); 111 Opie::Datebook::HolidayPlugin*pl = hif->plugin();
102 if (!pl) continue; 112 if (!pl) continue;
103 Opie::Datebook::HolidayPluginConfigWidget*cfg = pl->configWidget(); 113 Opie::Datebook::HolidayPluginConfigWidget*cfg = pl->configWidget();
104 if (!cfg) continue; 114 if (!cfg) continue;
105 QWidget * dtab = new QWidget(TabWidget,pl->description()); 115 QWidget * dtab = new QWidget(TabWidget,pl->description());
106 QVBoxLayout*dlayout = new QVBoxLayout(dtab); 116 QVBoxLayout*dlayout = new QVBoxLayout(dtab);
107 dlayout->setMargin(2); 117 dlayout->setMargin(2);
108 dlayout->setSpacing(2); 118 dlayout->setSpacing(2);
109 cfg->reparent(dtab,0,QPoint(0,0)); 119 cfg->reparent(dtab,0,QPoint(0,0));
110 dlayout->addWidget(cfg); 120 dlayout->addWidget(cfg);
111 TabWidget->insertTab(dtab,pl->description()); 121 TabWidget->insertTab(dtab,pl->description());
112 122
113 m_cfgWidgets.append(cfg); 123 m_cfgWidgets.append(cfg);
114 } 124 }
115} 125}
116void DateBookSettings::savePlugins() 126void DateBookSettings::savePlugins()
117{ 127{
118 QValueList<Opie::Datebook::HolidayPluginConfigWidget*>::Iterator it; 128 QValueList<Opie::Datebook::HolidayPluginConfigWidget*>::Iterator it;
119 for (it=m_cfgWidgets.begin();it!=m_cfgWidgets.end();++it) { 129 for (it=m_cfgWidgets.begin();it!=m_cfgWidgets.end();++it) {
120 (*it)->saveConfig(); 130 (*it)->saveConfig();
121 } 131 }
122} 132}
123 133
124void DateBookSettings::pluginItemClicked(QListViewItem *aItem) 134void DateBookSettings::pluginItemClicked(QListViewItem *aItem)
125{ 135{
126 if (!aItem||!m_manager||!m_loader) return; 136 if (!aItem||!m_manager||!m_loader) return;
127 QCheckListItem*pitem = ((QCheckListItem*)aItem); 137 QCheckListItem*pitem = ((QCheckListItem*)aItem);
128 138
129 Opie::Core::OPluginItem::List lst = m_loader->allAvailable( true ); 139 Opie::Core::OPluginItem::List lst = m_loader->allAvailable( true );
130 for ( Opie::Core::OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) { 140 for ( Opie::Core::OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) {
131 if ( QString::compare( (*it).name() , pitem->text(0) ) == 0 ) { 141 if ( QString::compare( (*it).name() , pitem->text(0) ) == 0 ) {
132 m_manager->setEnabled((*it),pitem->isOn()); 142 m_manager->setEnabled((*it),pitem->isOn());
133 break; 143 break;
134 } 144 }
135 } 145 }
136} 146}
137 147
138void DateBookSettings::setAlarmPreset( bool bAlarm, int presetTime ) 148void DateBookSettings::setAlarmPreset( bool bAlarm, int presetTime )
139{ 149{
140 chkAlarmPreset->setChecked( bAlarm ); 150 chkAlarmPreset->setChecked( bAlarm );
141 if ( presetTime >=5 ) 151 if ( presetTime >=5 )
142 spinPreset->setValue( presetTime ); 152 spinPreset->setValue( presetTime );
143} 153}
144 154
145bool DateBookSettings::alarmPreset() const 155bool DateBookSettings::alarmPreset() const
146{ 156{
147 return chkAlarmPreset->isChecked(); 157 return chkAlarmPreset->isChecked();
148} 158}
149 159
150int DateBookSettings::presetTime() const 160int DateBookSettings::presetTime() const
151{ 161{
152 return spinPreset->value(); 162 return spinPreset->value();
153} 163}
154 164
155 165
156void DateBookSettings::slot12Hour( int i ) 166void DateBookSettings::slot12Hour( int i )
157{ 167{
158 if ( ampm ) { 168 if ( ampm ) {
159 if ( spinStart->suffix().contains( tr("AM"), FALSE ) ) { 169 if ( spinStart->suffix().contains( tr("AM"), FALSE ) ) {
160 if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 ) 170 if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 )
161 spinStart->setSuffix( tr(":00 PM") ); 171 spinStart->setSuffix( tr(":00 PM") );
162 } else { 172 } else {
163 if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 ) 173 if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 )
164 spinStart->setSuffix( tr(":00 AM") ); 174 spinStart->setSuffix( tr(":00 AM") );
165 } 175 }
166 oldtime = i; 176 oldtime = i;
167 } 177 }
168} 178}
169 179
170void DateBookSettings::init() 180void DateBookSettings::init()
171{ 181{
172 if ( ampm ) { 182 if ( ampm ) {
173 spinStart->setMinValue( 1 ); 183 spinStart->setMinValue( 1 );
174 spinStart->setMaxValue( 12 ); 184 spinStart->setMaxValue( 12 );
175 spinStart->setValue( 12 ); 185 spinStart->setValue( 12 );
176 spinStart->setSuffix( tr(":00 AM") ); 186 spinStart->setSuffix( tr(":00 AM") );
177 oldtime = 12; 187 oldtime = 12;
178 } else { 188 } else {
179 spinStart->setMinValue( 0 ); 189 spinStart->setMinValue( 0 );
180 spinStart->setMaxValue( 23 ); 190 spinStart->setMaxValue( 23 );
181 spinStart->setSuffix( tr(":00") ); 191 spinStart->setSuffix( tr(":00") );
182 } 192 }
183} 193}
184 194
185void DateBookSettings::slotChangeClock( bool whichClock ) 195void DateBookSettings::slotChangeClock( bool whichClock )
186{ 196{
187 int saveMe; 197 int saveMe;
188 saveMe = spinStart->value(); 198 saveMe = spinStart->value();
189 if ( ampm && spinStart->suffix().contains( tr("AM"), FALSE ) ) { 199 if ( ampm && spinStart->suffix().contains( tr("AM"), FALSE ) ) {
190 if ( saveMe == 12 ) 200 if ( saveMe == 12 )
191 saveMe = 0; 201 saveMe = 0;
192 } else if ( ampm && spinStart->suffix().contains( tr("PM"), FALSE ) ) { 202 } else if ( ampm && spinStart->suffix().contains( tr("PM"), FALSE ) ) {
193 if ( saveMe != 12 ) 203 if ( saveMe != 12 )
194 saveMe += 12; 204 saveMe += 12;
195 } 205 }
196 ampm = whichClock; 206 ampm = whichClock;
197 init(); 207 init();
198 setStartTime( saveMe ); 208 setStartTime( saveMe );
199} 209}
200 210
201void DateBookSettings::setJumpToCurTime( bool bJump ) 211void DateBookSettings::setJumpToCurTime( bool bJump )
202{ 212{
203 chkJumpToCurTime->setChecked( bJump ); 213 chkJumpToCurTime->setChecked( bJump );
204} 214}
205 215
206bool DateBookSettings::jumpToCurTime() const 216bool DateBookSettings::jumpToCurTime() const
207{ 217{
208 return chkJumpToCurTime->isChecked(); 218 return chkJumpToCurTime->isChecked();
209} 219}
210 220
211void DateBookSettings::setRowStyle( int style ) 221void DateBookSettings::setRowStyle( int style )
212{ 222{
213 comboRowStyle->setCurrentItem( style ); 223 comboRowStyle->setCurrentItem( style );
214} 224}
215 225
216int DateBookSettings::rowStyle() const 226int DateBookSettings::rowStyle() const
217{ 227{
218 return comboRowStyle->currentItem(); 228 return comboRowStyle->currentItem();
219} 229}
diff --git a/core/pim/datebook/datebooksettings.h b/core/pim/datebook/datebooksettings.h
index 912088f..d3aca85 100644
--- a/core/pim/datebook/datebooksettings.h
+++ b/core/pim/datebook/datebooksettings.h
@@ -1,77 +1,87 @@
1/********************************************************************** 1/*
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2                 This file is part of the Opie Project
3** 3
4** This file is part of Qtopia Environment. 4 Copyright (C) Opie Team <opie-devel@handhelds.org>
5** 5 =.
6** This file may be distributed and/or modified under the terms of the 6 .=l.
7** GNU General Public License version 2 as published by the Free Software 7           .>+-=
8** Foundation and appearing in the file LICENSE.GPL included in the 8 _;:,     .>    :=|. This program is free software; you can
9** packaging of this file. 9.> <`_,   >  .   <= redistribute it and/or modify it under
10** 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11.="- .-=="i,     .._ License as published by the Free Software
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13** 13     ._= =}       : or (at your option) any later version.
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14    .%`+i>       _;_.
15** 15    .i_,=:_.      -<s. This program is distributed in the hope that
16** Contact info@trolltech.com if any conditions of this licensing are 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17** not clear to you. 17 : ..    .:,     . . . without even the implied warranty of
18** 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19**********************************************************************/ 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details.
22:     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA.
29*/
20 30
21#ifndef DATEBOOKSETTINGS_H 31#ifndef DATEBOOKSETTINGS_H
22#define DATEBOOKSETTINGS_H 32#define DATEBOOKSETTINGS_H
23#include "datebooksettingsbase.h" 33#include "datebooksettingsbase.h"
24#include <qpe/categoryselect.h> 34#include <qpe/categoryselect.h>
25#include <qvaluelist.h> 35#include <qvaluelist.h>
26 36
27namespace Opie { 37namespace Opie {
28namespace Core { 38namespace Core {
29 class OPluginManager; 39 class OPluginManager;
30 class OGenericPluginLoader; 40 class OGenericPluginLoader;
31 class OPluginLoader; 41 class OPluginLoader;
32} 42}
33namespace Ui { 43namespace Ui {
34 class OPluginConfigWidget; 44 class OPluginConfigWidget;
35} 45}
36namespace Datebook { 46namespace Datebook {
37 class HolidayPluginConfigWidget; 47 class HolidayPluginConfigWidget;
38} 48}
39} 49}
40 50
41class DateBookSettings : public DateBookSettingsBase 51class DateBookSettings : public DateBookSettingsBase
42{ 52{
43 Q_OBJECT 53 Q_OBJECT
44public: 54public:
45 DateBookSettings( bool whichClock, QWidget *parent = 0, 55 DateBookSettings( bool whichClock, QWidget *parent = 0,
46 const char *name = 0, bool modal = TRUE, WFlags = 0 ); 56 const char *name = 0, bool modal = TRUE, WFlags = 0 );
47 ~DateBookSettings(); 57 ~DateBookSettings();
48 void setStartTime( int newStartViewTime ); 58 void setStartTime( int newStartViewTime );
49 int startTime() const; 59 int startTime() const;
50 void setAlarmPreset( bool bAlarm, int presetTime ); 60 void setAlarmPreset( bool bAlarm, int presetTime );
51 bool alarmPreset() const; 61 bool alarmPreset() const;
52 int presetTime() const; 62 int presetTime() const;
53 void setAlarmType( int alarmType ); 63 void setAlarmType( int alarmType );
54 int alarmType() const; 64 int alarmType() const;
55 65
56 void setJumpToCurTime( bool bJump ); 66 void setJumpToCurTime( bool bJump );
57 bool jumpToCurTime() const; 67 bool jumpToCurTime() const;
58 void setRowStyle( int style ); 68 void setRowStyle( int style );
59 int rowStyle() const; 69 int rowStyle() const;
60 70
61 void setPluginList(Opie::Core::OPluginManager*,Opie::Core::OPluginLoader*); 71 void setPluginList(Opie::Core::OPluginManager*,Opie::Core::OPluginLoader*);
62 void savePlugins(); 72 void savePlugins();
63private slots: 73private slots:
64 void slot12Hour( int ); 74 void slot12Hour( int );
65 void slotChangeClock( bool ); 75 void slotChangeClock( bool );
66protected slots: 76protected slots:
67 virtual void pluginItemClicked(QListViewItem *); 77 virtual void pluginItemClicked(QListViewItem *);
68 78
69protected: 79protected:
70 void init(); 80 void init();
71 bool ampm; 81 bool ampm;
72 int oldtime; 82 int oldtime;
73 Opie::Core::OPluginManager*m_manager; 83 Opie::Core::OPluginManager*m_manager;
74 Opie::Core::OPluginLoader*m_loader; 84 Opie::Core::OPluginLoader*m_loader;
75 QValueList<Opie::Datebook::HolidayPluginConfigWidget*> m_cfgWidgets; 85 QValueList<Opie::Datebook::HolidayPluginConfigWidget*> m_cfgWidgets;
76}; 86};
77#endif 87#endif
diff --git a/core/pim/datebook/datebooktypes.h b/core/pim/datebook/datebooktypes.h
index 9453be8..bc94561 100644
--- a/core/pim/datebook/datebooktypes.h
+++ b/core/pim/datebook/datebooktypes.h
@@ -1,73 +1,103 @@
1/*
2                 This file is part of the Opie Project
3
4 Copyright (C) Opie Team <opie-devel@handhelds.org>
5 =.
6 .=l.
7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17 : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details.
22:     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA.
29*/
30
1#ifndef _DATEBOOK_TYPES_H 31#ifndef _DATEBOOK_TYPES_H
2#define _DATEBOOK_TYPES_H 32#define _DATEBOOK_TYPES_H
3 33
4#include <qpe/datebookdb.h> 34#include <qpe/datebookdb.h>
5 35
6#include <qvaluelist.h> 36#include <qvaluelist.h>
7#include <qstringlist.h> 37#include <qstringlist.h>
8 38
9namespace Opie { 39namespace Opie {
10namespace Datebook { 40namespace Datebook {
11 class HolidayPlugin; 41 class HolidayPlugin;
12 class HolidayPluginIf; 42 class HolidayPluginIf;
13} 43}
14namespace Core { 44namespace Core {
15 class OPluginLoader; 45 class OPluginLoader;
16 class OPluginManager; 46 class OPluginManager;
17} 47}
18} 48}
19 49
20class QLibrary; 50class QLibrary;
21 51
22enum { DAY=1,WEEK,WEEKLST,MONTH }; // defaultView values 52enum { DAY=1,WEEK,WEEKLST,MONTH }; // defaultView values
23enum { NONE=0,NORMAL,EXTENDED }; // WeekLstView's modes. 53enum { NONE=0,NORMAL,EXTENDED }; // WeekLstView's modes.
24 54
25class DateBookDBHack : virtual public DateBookDB { 55class DateBookDBHack : virtual public DateBookDB {
26 public: 56 public:
27 virtual ~DateBookDBHack(){} 57 virtual ~DateBookDBHack(){}
28 Event eventByUID(int id); 58 Event eventByUID(int id);
29}; 59};
30 60
31class DateBookHoliday 61class DateBookHoliday
32{ 62{
33public: 63public:
34 DateBookHoliday(); 64 DateBookHoliday();
35 virtual ~DateBookHoliday(); 65 virtual ~DateBookHoliday();
36 66
37 QStringList holidaylist(const QDate&); 67 QStringList holidaylist(const QDate&);
38 QStringList holidaylist(unsigned year, unsigned month, unsigned day); 68 QStringList holidaylist(unsigned year, unsigned month, unsigned day);
39 virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDate &from,const QDate &to ); 69 virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDate &from,const QDate &to );
40 virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDateTime &start); 70 virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDateTime &start);
41 71
42 void reloadPlugins(); 72 void reloadPlugins();
43 73
44 Opie::Core::OPluginLoader*pluginLoader(){return m_pluginLoader;} 74 Opie::Core::OPluginLoader*pluginLoader(){return m_pluginLoader;}
45 Opie::Core::OPluginManager*pluginManager(){return m_pluginManager;} 75 Opie::Core::OPluginManager*pluginManager(){return m_pluginManager;}
46 76
47protected: 77protected:
48 void init(); 78 void init();
49 void deinit(); 79 void deinit();
50 80
51 struct HPlugin { 81 struct HPlugin {
52 Opie::Datebook::HolidayPlugin*_plugin; 82 Opie::Datebook::HolidayPlugin*_plugin;
53 //QLibrary*_lib; 83 //QLibrary*_lib;
54 //Opie::Datebook::HolidayPluginIf*_if; 84 //Opie::Datebook::HolidayPluginIf*_if;
55 }; 85 };
56 QValueList<HPlugin*>_pluginlist; 86 QValueList<HPlugin*>_pluginlist;
57 Opie::Core::OPluginLoader*m_pluginLoader; 87 Opie::Core::OPluginLoader*m_pluginLoader;
58 Opie::Core::OPluginManager*m_pluginManager; 88 Opie::Core::OPluginManager*m_pluginManager;
59}; 89};
60 90
61class DateBookDBHoliday:virtual public DateBookDBHack { 91class DateBookDBHoliday:virtual public DateBookDBHack {
62public: 92public:
63 DateBookDBHoliday():DateBookDBHack(){db_holiday=0;} 93 DateBookDBHoliday():DateBookDBHack(){db_holiday=0;}
64 virtual ~DateBookDBHoliday(){} 94 virtual ~DateBookDBHoliday(){}
65 virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDate &from,const QDate &to ); 95 virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDate &from,const QDate &to );
66 virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDateTime &start); 96 virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDateTime &start);
67 virtual QValueList<EffectiveEvent> getEffectiveEventsNoHoliday(const QDate &from,const QDate &to ); 97 virtual QValueList<EffectiveEvent> getEffectiveEventsNoHoliday(const QDate &from,const QDate &to );
68 virtual QValueList<EffectiveEvent> getEffectiveEventsNoHoliday(const QDateTime &start); 98 virtual QValueList<EffectiveEvent> getEffectiveEventsNoHoliday(const QDateTime &start);
69 99
70 DateBookHoliday*db_holiday; 100 DateBookHoliday*db_holiday;
71}; 101};
72 102
73#endif 103#endif
diff --git a/core/pim/datebook/datebookweek.cpp b/core/pim/datebook/datebookweek.cpp
index a509d89..ce0b10b 100644
--- a/core/pim/datebook/datebookweek.cpp
+++ b/core/pim/datebook/datebookweek.cpp
@@ -1,676 +1,687 @@
1/********************************************************************** 1/*
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2                 This file is part of the Opie Project
3** 3
4** This file is part of Qtopia Environment. 4 Copyright (C) Opie Team <opie-devel@handhelds.org>
5** 5 =.
6** This file may be distributed and/or modified under the terms of the 6 .=l.
7** GNU General Public License version 2 as published by the Free Software 7           .>+-=
8** Foundation and appearing in the file LICENSE.GPL included in the 8 _;:,     .>    :=|. This program is free software; you can
9** packaging of this file. 9.> <`_,   >  .   <= redistribute it and/or modify it under
10** 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11.="- .-=="i,     .._ License as published by the Free Software
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13** 13     ._= =}       : or (at your option) any later version.
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14    .%`+i>       _;_.
15** 15    .i_,=:_.      -<s. This program is distributed in the hope that
16** Contact info@trolltech.com if any conditions of this licensing are 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17** not clear to you. 17 : ..    .:,     . . . without even the implied warranty of
18** 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19**********************************************************************/ 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details.
22:     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA.
29*/
30
20#include "datebookweek.h" 31#include "datebookweek.h"
21#include "datebookweekheaderimpl.h" 32#include "datebookweekheaderimpl.h"
22#include "datebooktypes.h" 33#include "datebooktypes.h"
23 34
24#include <qpe/datebookdb.h> 35#include <qpe/datebookdb.h>
25#include <qpe/qpeapplication.h> 36#include <qpe/qpeapplication.h>
26#include <qpe/calendar.h> 37#include <qpe/calendar.h>
27 38
28#include <qheader.h> 39#include <qheader.h>
29#include <qlabel.h> 40#include <qlabel.h>
30#include <qlayout.h> 41#include <qlayout.h>
31#include <qtimer.h> 42#include <qtimer.h>
32 43
33//----------------------------------------------------------------- 44//-----------------------------------------------------------------
34 45
35 46
36DateBookWeekItem::DateBookWeekItem( const EffectiveEvent e ) 47DateBookWeekItem::DateBookWeekItem( const EffectiveEvent e )
37 : ev( e ) 48 : ev( e )
38{ 49{
39 // with the current implementation change the color for all day events 50 // with the current implementation change the color for all day events
40 if ( ev.event().type() == Event::AllDay && !ev.event().hasAlarm() ) { 51 if ( ev.event().type() == Event::AllDay && !ev.event().hasAlarm() ) {
41 c = Qt::green; 52 c = Qt::green;
42 } else { 53 } else {
43 c = ev.event().hasAlarm() ? Qt::red : Qt::blue; 54 c = ev.event().hasAlarm() ? Qt::red : Qt::blue;
44 } 55 }
45} 56}
46 57
47void DateBookWeekItem::setGeometry( int x, int y, int w, int h ) 58void DateBookWeekItem::setGeometry( int x, int y, int w, int h )
48{ 59{
49 r.setRect( x, y, w, h ); 60 r.setRect( x, y, w, h );
50} 61}
51 62
52 63
53//------------------=--------------------------------------------- 64//------------------=---------------------------------------------
54 65
55DateBookWeekView::DateBookWeekView( bool ap, bool startOnMonday, 66DateBookWeekView::DateBookWeekView( bool ap, bool startOnMonday,
56 QWidget *parent, const char *name ) 67 QWidget *parent, const char *name )
57 : QScrollView( parent, name ), ampm( ap ), bOnMonday( startOnMonday ), 68 : QScrollView( parent, name ), ampm( ap ), bOnMonday( startOnMonday ),
58 showingEvent( false ) 69 showingEvent( false )
59{ 70{
60 items.setAutoDelete( true ); 71 items.setAutoDelete( true );
61 72
62 viewport()->setBackgroundMode( PaletteBase ); 73 viewport()->setBackgroundMode( PaletteBase );
63 74
64 header = new QHeader( this ); 75 header = new QHeader( this );
65 header->addLabel( "" ); 76 header->addLabel( "" );
66 77
67 header->setMovingEnabled( false ); 78 header->setMovingEnabled( false );
68 header->setResizeEnabled( false ); 79 header->setResizeEnabled( false );
69 header->setClickEnabled( false, 0 ); 80 header->setClickEnabled( false, 0 );
70 initNames(); 81 initNames();
71 82
72 83
73 connect( header, SIGNAL(clicked(int)), this, SIGNAL(showDay(int)) ); 84 connect( header, SIGNAL(clicked(int)), this, SIGNAL(showDay(int)) );
74 85
75 QObject::connect(qApp, SIGNAL(clockChanged(bool)), 86 QObject::connect(qApp, SIGNAL(clockChanged(bool)),
76 this, SLOT(slotChangeClock(bool))); 87 this, SLOT(slotChangeClock(bool)));
77 88
78 QFontMetrics fm( font() ); 89 QFontMetrics fm( font() );
79 rowHeight = fm.height()+2; 90 rowHeight = fm.height()+2;
80 91
81 resizeContents( width(), 24*rowHeight ); 92 resizeContents( width(), 24*rowHeight );
82} 93}
83 94
84void DateBookWeekView::initNames() 95void DateBookWeekView::initNames()
85{ 96{
86 97
87 static bool bFirst = true; 98 static bool bFirst = true;
88 if ( bFirst ) { 99 if ( bFirst ) {
89 if ( bOnMonday ) { 100 if ( bOnMonday ) {
90 for ( int i = 1; i<=7; i++ ) { 101 for ( int i = 1; i<=7; i++ ) {
91 header->addLabel( Calendar::nameOfDay( i ) ); 102 header->addLabel( Calendar::nameOfDay( i ) );
92 } 103 }
93 104
94 } else { 105 } else {
95 header->addLabel( Calendar::nameOfDay( 7 ) ); 106 header->addLabel( Calendar::nameOfDay( 7 ) );
96 for ( int i = 1; i<7; i++ ) { 107 for ( int i = 1; i<7; i++ ) {
97 header->addLabel( Calendar::nameOfDay( i ) ); 108 header->addLabel( Calendar::nameOfDay( i ) );
98 } 109 }
99 } 110 }
100 bFirst = false; 111 bFirst = false;
101 } else { 112 } else {
102 // we are change things... 113 // we are change things...
103 if ( bOnMonday ) { 114 if ( bOnMonday ) {
104 for ( int i = 1; i<=7; i++ ) { 115 for ( int i = 1; i<=7; i++ ) {
105 header->setLabel( i, Calendar::nameOfDay( i ) ); 116 header->setLabel( i, Calendar::nameOfDay( i ) );
106 } 117 }
107 118
108 } else { 119 } else {
109 header->setLabel( 1, Calendar::nameOfDay( 7 ) ); 120 header->setLabel( 1, Calendar::nameOfDay( 7 ) );
110 for ( int i = 1; i<7; i++ ) { 121 for ( int i = 1; i<7; i++ ) {
111 header->setLabel( i+1, Calendar::nameOfDay( i ) ); 122 header->setLabel( i+1, Calendar::nameOfDay( i ) );
112 } 123 }
113 124
114 } 125 }
115 } 126 }
116} 127}
117 128
118 129
119 130
120void DateBookWeekView::showEvents( QValueList<EffectiveEvent> &ev ) 131void DateBookWeekView::showEvents( QValueList<EffectiveEvent> &ev )
121{ 132{
122 items.clear(); 133 items.clear();
123 QValueListIterator<EffectiveEvent> it; 134 QValueListIterator<EffectiveEvent> it;
124 for ( it = ev.begin(); it != ev.end(); ++it ) { 135 for ( it = ev.begin(); it != ev.end(); ++it ) {
125 DateBookWeekItem *i = new DateBookWeekItem( *it ); 136 DateBookWeekItem *i = new DateBookWeekItem( *it );
126 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. 137 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.
127 positionItem( i ); 138 positionItem( i );
128 items.append( i ); 139 items.append( i );
129 } 140 }
130 } 141 }
131 viewport()->update(); 142 viewport()->update();
132} 143}
133 144
134void DateBookWeekView::moveToHour( int h ) 145void DateBookWeekView::moveToHour( int h )
135{ 146{
136 int offset = h*rowHeight; 147 int offset = h*rowHeight;
137 setContentsPos( 0, offset ); 148 setContentsPos( 0, offset );
138} 149}
139 150
140void DateBookWeekView::keyPressEvent( QKeyEvent *e ) 151void DateBookWeekView::keyPressEvent( QKeyEvent *e )
141{ 152{
142 e->ignore(); 153 e->ignore();
143} 154}
144 155
145void DateBookWeekView::slotChangeClock( bool c ) 156void DateBookWeekView::slotChangeClock( bool c )
146{ 157{
147 ampm = c; 158 ampm = c;
148 viewport()->update(); 159 viewport()->update();
149} 160}
150 161
151static inline int db_round30min( int m ) 162static inline int db_round30min( int m )
152{ 163{
153 if ( m < 15 ) 164 if ( m < 15 )
154 m = 0; 165 m = 0;
155 else if ( m < 45 ) 166 else if ( m < 45 )
156 m = 1; 167 m = 1;
157 else 168 else
158 m = 2; 169 m = 2;
159 170
160 return m; 171 return m;
161} 172}
162 173
163void DateBookWeekView::alterDay( int day ) 174void DateBookWeekView::alterDay( int day )
164{ 175{
165 if ( !bOnMonday ) { 176 if ( !bOnMonday ) {
166 day--; 177 day--;
167 } 178 }
168 emit showDay( day ); 179 emit showDay( day );
169} 180}
170 181
171void DateBookWeekView::positionItem( DateBookWeekItem *i ) 182void DateBookWeekView::positionItem( DateBookWeekItem *i )
172{ 183{
173 const int Width = 8; 184 const int Width = 8;
174 const EffectiveEvent ev = i->event(); 185 const EffectiveEvent ev = i->event();
175 186
176 // 30 minute intervals 187 // 30 minute intervals
177 int y = ev.start().hour() * 2; 188 int y = ev.start().hour() * 2;
178 y += db_round30min( ev.start().minute() ); 189 y += db_round30min( ev.start().minute() );
179 int y2 = ev.end().hour() * 2; 190 int y2 = ev.end().hour() * 2;
180 y2 += db_round30min( ev.end().minute() ); 191 y2 += db_round30min( ev.end().minute() );
181 if ( y > 47 ) y = 47; 192 if ( y > 47 ) y = 47;
182 if ( y2 > 48 ) y2 = 48; 193 if ( y2 > 48 ) y2 = 48;
183 y = (y * rowHeight) / 2; 194 y = (y * rowHeight) / 2;
184 y2 = (y2 * rowHeight) / 2; 195 y2 = (y2 * rowHeight) / 2;
185 196
186 int h; 197 int h;
187 if ( ev.event().type() == Event::AllDay ) { 198 if ( ev.event().type() == Event::AllDay ) {
188 h = (48 * rowHeight) / 2; 199 h = (48 * rowHeight) / 2;
189 y = 0; 200 y = 0;
190 } else { 201 } else {
191 h=y2-y; 202 h=y2-y;
192 if ( h < (1*rowHeight)/2 ) h = (1*rowHeight)/2; 203 if ( h < (1*rowHeight)/2 ) h = (1*rowHeight)/2;
193 } 204 }
194 205
195 int dow = ev.date().dayOfWeek(); 206 int dow = ev.date().dayOfWeek();
196 if ( !bOnMonday ) { 207 if ( !bOnMonday ) {
197 if ( dow == 7 ) 208 if ( dow == 7 )
198 dow = 1; 209 dow = 1;
199 else 210 else
200 dow++; 211 dow++;
201 } 212 }
202 int x = header->sectionPos( dow ) - 1; 213 int x = header->sectionPos( dow ) - 1;
203 int xlim = header->sectionPos( dow ) + header->sectionSize( dow ); 214 int xlim = header->sectionPos( dow ) + header->sectionSize( dow );
204 DateBookWeekItem *isect = 0; 215 DateBookWeekItem *isect = 0;
205 do { 216 do {
206 i->setGeometry( x, y, Width, h ); 217 i->setGeometry( x, y, Width, h );
207 isect = intersects( i ); 218 isect = intersects( i );
208 x += Width - 1; 219 x += Width - 1;
209 } while ( isect && x < xlim ); 220 } while ( isect && x < xlim );
210} 221}
211 222
212DateBookWeekItem *DateBookWeekView::intersects( const DateBookWeekItem *item ) 223DateBookWeekItem *DateBookWeekView::intersects( const DateBookWeekItem *item )
213{ 224{
214 QRect geom = item->geometry(); 225 QRect geom = item->geometry();
215 226
216 // We allow the edges to overlap 227 // We allow the edges to overlap
217 geom.moveBy( 1, 1 ); 228 geom.moveBy( 1, 1 );
218 geom.setSize( geom.size()-QSize(2,2) ); 229 geom.setSize( geom.size()-QSize(2,2) );
219 230
220 QListIterator<DateBookWeekItem> it(items); 231 QListIterator<DateBookWeekItem> it(items);
221 for ( ; it.current(); ++it ) { 232 for ( ; it.current(); ++it ) {
222 DateBookWeekItem *i = it.current(); 233 DateBookWeekItem *i = it.current();
223 if ( i != item ) { 234 if ( i != item ) {
224 if ( i->geometry().intersects( geom ) ) { 235 if ( i->geometry().intersects( geom ) ) {
225 return i; 236 return i;
226 } 237 }
227 } 238 }
228 } 239 }
229 240
230 return 0; 241 return 0;
231} 242}
232 243
233void DateBookWeekView::contentsMousePressEvent( QMouseEvent *e ) 244void DateBookWeekView::contentsMousePressEvent( QMouseEvent *e )
234{ 245{
235 QListIterator<DateBookWeekItem> it(items); 246 QListIterator<DateBookWeekItem> it(items);
236 for ( ; it.current(); ++it ) { 247 for ( ; it.current(); ++it ) {
237 DateBookWeekItem *i = it.current(); 248 DateBookWeekItem *i = it.current();
238 if ( i->geometry().contains( e->pos() ) ) { 249 if ( i->geometry().contains( e->pos() ) ) {
239 showingEvent = true; 250 showingEvent = true;
240 emit signalShowEvent( i->event() ); 251 emit signalShowEvent( i->event() );
241 break; 252 break;
242 } 253 }
243 } 254 }
244} 255}
245 256
246void DateBookWeekView::contentsMouseReleaseEvent( QMouseEvent *e ) 257void DateBookWeekView::contentsMouseReleaseEvent( QMouseEvent *e )
247{ 258{
248 if ( showingEvent ) { 259 if ( showingEvent ) {
249 showingEvent = false; 260 showingEvent = false;
250 emit signalHideEvent(); 261 emit signalHideEvent();
251 } else { 262 } else {
252 int d = header->sectionAt( e->pos().x() ); 263 int d = header->sectionAt( e->pos().x() );
253 if ( d > 0 ) { 264 if ( d > 0 ) {
254// if ( !bOnMonday ) 265// if ( !bOnMonday )
255// d--; 266// d--;
256 emit showDay( d ); 267 emit showDay( d );
257 } 268 }
258 } 269 }
259} 270}
260 271
261void DateBookWeekView::drawContents( QPainter *p, int cx, int cy, int cw, int ch ) 272void DateBookWeekView::drawContents( QPainter *p, int cx, int cy, int cw, int ch )
262{ 273{
263 QRect ur( cx, cy, cw, ch ); 274 QRect ur( cx, cy, cw, ch );
264 p->setPen( lightGray ); 275 p->setPen( lightGray );
265 for ( int i = 1; i <= 7; i++ ) 276 for ( int i = 1; i <= 7; i++ )
266 p->drawLine( header->sectionPos(i)-2, cy, header->sectionPos(i)-2, cy+ch ); 277 p->drawLine( header->sectionPos(i)-2, cy, header->sectionPos(i)-2, cy+ch );
267 278
268 p->setPen( black ); 279 p->setPen( black );
269 for ( int t = 0; t < 24; t++ ) { 280 for ( int t = 0; t < 24; t++ ) {
270 int y = t*rowHeight; 281 int y = t*rowHeight;
271 if ( QRect( 1, y, 20, rowHeight ).intersects( ur ) ) { 282 if ( QRect( 1, y, 20, rowHeight ).intersects( ur ) ) {
272 QString s; 283 QString s;
273 if ( ampm ) { 284 if ( ampm ) {
274 if ( t == 0 ) 285 if ( t == 0 )
275 s = QString::number( 12 ); 286 s = QString::number( 12 );
276 else if ( t == 12 ) 287 else if ( t == 12 )
277 s = QString::number(12) + tr( "p" ); 288 s = QString::number(12) + tr( "p" );
278 else if ( t > 12 ) { 289 else if ( t > 12 ) {
279 if ( t - 12 < 10 ) 290 if ( t - 12 < 10 )
280 s = " "; 291 s = " ";
281 else 292 else
282 s = ""; 293 s = "";
283 s += QString::number( t - 12 ) + tr("p"); 294 s += QString::number( t - 12 ) + tr("p");
284 } else { 295 } else {
285 if ( 12 - t < 3 ) 296 if ( 12 - t < 3 )
286 s = ""; 297 s = "";
287 else 298 else
288 s = " "; 299 s = " ";
289 s += QString::number( t ); 300 s += QString::number( t );
290 } 301 }
291 } else { 302 } else {
292 s = QString::number( t ); 303 s = QString::number( t );
293 if ( s.length() == 1 ) 304 if ( s.length() == 1 )
294 s.prepend( "0" ); 305 s.prepend( "0" );
295 } 306 }
296 p->drawText( 1, y+p->fontMetrics().ascent()+1, s ); 307 p->drawText( 1, y+p->fontMetrics().ascent()+1, s );
297 } 308 }
298 } 309 }
299 310
300 QListIterator<DateBookWeekItem> it(items); 311 QListIterator<DateBookWeekItem> it(items);
301 for ( ; it.current(); ++it ) { 312 for ( ; it.current(); ++it ) {
302 DateBookWeekItem *i = it.current(); 313 DateBookWeekItem *i = it.current();
303 if ( i->geometry().intersects( ur ) ) { 314 if ( i->geometry().intersects( ur ) ) {
304 p->setBrush( i->color() ); 315 p->setBrush( i->color() );
305 p->drawRect( i->geometry() ); 316 p->drawRect( i->geometry() );
306 } 317 }
307 } 318 }
308} 319}
309 320
310void DateBookWeekView::resizeEvent( QResizeEvent *e ) 321void DateBookWeekView::resizeEvent( QResizeEvent *e )
311{ 322{
312 const int hourWidth = 20; 323 const int hourWidth = 20;
313 QScrollView::resizeEvent( e ); 324 QScrollView::resizeEvent( e );
314 325
315 326
316 //HEAD 327 //HEAD
317 /* 328 /*
318 int avail = visibleWidth(); 329 int avail = visibleWidth();
319 header->setGeometry( leftMargin()+frameWidth()+frameRect().left() , frameWidth(), 330 header->setGeometry( leftMargin()+frameWidth()+frameRect().left() , frameWidth(),
320 visibleWidth(), header->sizeHint().height() ); 331 visibleWidth(), header->sizeHint().height() );
321 setMargins( 0, header->sizeHint().height(), 0, 0 ); 332 setMargins( 0, header->sizeHint().height(), 0, 0 );
322 */ 333 */
323 //BRANCH_1_0 334 //BRANCH_1_0
324 int avail = width()-qApp->style().scrollBarExtent().width()-1; 335 int avail = width()-qApp->style().scrollBarExtent().width()-1;
325 header->setGeometry( 0, 0, avail, header->sizeHint().height() ); 336 header->setGeometry( 0, 0, avail, header->sizeHint().height() );
326 setMargins( 0, header->height(), 0, 0 ); 337 setMargins( 0, header->height(), 0, 0 );
327 338
328 339
329 header->resizeSection( 0, hourWidth ); 340 header->resizeSection( 0, hourWidth );
330 int sw = (avail - hourWidth) / 7; 341 int sw = (avail - hourWidth) / 7;
331 for ( int i = 1; i < 7; i++ ) 342 for ( int i = 1; i < 7; i++ )
332 header->resizeSection( i, sw ); 343 header->resizeSection( i, sw );
333 header->resizeSection( 7, avail - hourWidth - sw*6 ); 344 header->resizeSection( 7, avail - hourWidth - sw*6 );
334} 345}
335 346
336void DateBookWeekView::setStartOfWeek( bool bStartOnMonday ) 347void DateBookWeekView::setStartOfWeek( bool bStartOnMonday )
337{ 348{
338 bOnMonday = bStartOnMonday; 349 bOnMonday = bStartOnMonday;
339 initNames(); 350 initNames();
340} 351}
341 352
342//------------------------------------------------------------------- 353//-------------------------------------------------------------------
343 354
344DateBookWeek::DateBookWeek( bool ap, bool startOnMonday, DateBookDBHoliday *newDB, 355DateBookWeek::DateBookWeek( bool ap, bool startOnMonday, DateBookDBHoliday *newDB,
345 QWidget *parent, const char *name ) 356 QWidget *parent, const char *name )
346 : QWidget( parent, name ), 357 : QWidget( parent, name ),
347 db( newDB ), 358 db( newDB ),
348 startTime( 0 ), 359 startTime( 0 ),
349 ampm( ap ), 360 ampm( ap ),
350 bStartOnMonday( startOnMonday ) 361 bStartOnMonday( startOnMonday )
351{ 362{
352 setFocusPolicy(StrongFocus); 363 setFocusPolicy(StrongFocus);
353 QVBoxLayout *vb = new QVBoxLayout( this ); 364 QVBoxLayout *vb = new QVBoxLayout( this );
354 header = new DateBookWeekHeader( bStartOnMonday, this ); 365 header = new DateBookWeekHeader( bStartOnMonday, this );
355 view = new DateBookWeekView( ampm, startOnMonday, this ); 366 view = new DateBookWeekView( ampm, startOnMonday, this );
356 vb->addWidget( header ); 367 vb->addWidget( header );
357 vb->addWidget( view ); 368 vb->addWidget( view );
358 369
359 lblDesc = new QLabel( this, "event label" ); 370 lblDesc = new QLabel( this, "event label" );
360 lblDesc->setFrameStyle( QFrame::Plain | QFrame::Box ); 371 lblDesc->setFrameStyle( QFrame::Plain | QFrame::Box );
361 lblDesc->setBackgroundColor( yellow ); 372 lblDesc->setBackgroundColor( yellow );
362 lblDesc->hide(); 373 lblDesc->hide();
363 374
364 tHide = new QTimer( this ); 375 tHide = new QTimer( this );
365 376
366 connect( view, SIGNAL( showDay(int) ), this, SLOT( showDay(int) ) ); 377 connect( view, SIGNAL( showDay(int) ), this, SLOT( showDay(int) ) );
367 connect( view, SIGNAL(signalShowEvent(const EffectiveEvent&)), this, SLOT(slotShowEvent(const EffectiveEvent&)) ); 378 connect( view, SIGNAL(signalShowEvent(const EffectiveEvent&)), this, SLOT(slotShowEvent(const EffectiveEvent&)) );
368 connect( view, SIGNAL(signalHideEvent()), this, SLOT(slotHideEvent()) ); 379 connect( view, SIGNAL(signalHideEvent()), this, SLOT(slotHideEvent()) );
369 connect( header, SIGNAL( dateChanged(QDate&) ), this, SLOT( dateChanged(QDate&) ) ); 380 connect( header, SIGNAL( dateChanged(QDate&) ), this, SLOT( dateChanged(QDate&) ) );
370 connect( tHide, SIGNAL( timeout() ), lblDesc, SLOT( hide() ) ); 381 connect( tHide, SIGNAL( timeout() ), lblDesc, SLOT( hide() ) );
371 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) ); 382 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) );
372 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotClockChanged(bool))); 383 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotClockChanged(bool)));
373 setDate(QDate::currentDate()); 384 setDate(QDate::currentDate());
374} 385}
375 386
376void DateBookWeek::keyPressEvent(QKeyEvent *e) 387void DateBookWeek::keyPressEvent(QKeyEvent *e)
377{ 388{
378 switch(e->key()) { 389 switch(e->key()) {
379 case Key_Up: 390 case Key_Up:
380 view->scrollBy(0, -20); 391 view->scrollBy(0, -20);
381 break; 392 break;
382 case Key_Down: 393 case Key_Down:
383 view->scrollBy(0, 20); 394 view->scrollBy(0, 20);
384 break; 395 break;
385 case Key_Left: 396 case Key_Left:
386 setDate(date().addDays(-7)); 397 setDate(date().addDays(-7));
387 break; 398 break;
388 case Key_Right: 399 case Key_Right:
389 setDate(date().addDays(7)); 400 setDate(date().addDays(7));
390 break; 401 break;
391 default: 402 default:
392 e->ignore(); 403 e->ignore();
393 } 404 }
394} 405}
395 406
396void DateBookWeek::showDay( int day ) 407void DateBookWeek::showDay( int day )
397{ 408{
398 QDate d=bdate; 409 QDate d=bdate;
399 410
400 // Calculate offset to first day of week. 411 // Calculate offset to first day of week.
401 int dayoffset=d.dayOfWeek() % 7; 412 int dayoffset=d.dayOfWeek() % 7;
402 413
403 if(bStartOnMonday) dayoffset--; 414 if(bStartOnMonday) dayoffset--;
404 415
405 day--; 416 day--;
406 d=d.addDays(day-dayoffset); 417 d=d.addDays(day-dayoffset);
407 emit showDate( d.year(), d.month(), d.day() ); 418 emit showDate( d.year(), d.month(), d.day() );
408} 419}
409 420
410void DateBookWeek::setDate( int y, int m, int d ) 421void DateBookWeek::setDate( int y, int m, int d )
411{ 422{
412 setDate(QDate(y, m, d)); 423 setDate(QDate(y, m, d));
413} 424}
414 425
415void DateBookWeek::setDate(QDate newdate) 426void DateBookWeek::setDate(QDate newdate)
416{ 427{
417 bdate=newdate; 428 bdate=newdate;
418 dow = newdate.dayOfWeek(); 429 dow = newdate.dayOfWeek();
419 header->setDate( newdate ); 430 header->setDate( newdate );
420} 431}
421 432
422void DateBookWeek::dateChanged( QDate &newdate ) 433void DateBookWeek::dateChanged( QDate &newdate )
423{ 434{
424 bdate=newdate; 435 bdate=newdate;
425 getEvents(); 436 getEvents();
426} 437}
427 438
428QDate DateBookWeek::date() const 439QDate DateBookWeek::date() const
429{ 440{
430 return bdate; 441 return bdate;
431} 442}
432 443
433void DateBookWeek::getEvents() 444void DateBookWeek::getEvents()
434{ 445{
435 QDate startWeek = weekDate(); 446 QDate startWeek = weekDate();
436 447
437 QDate endWeek = startWeek.addDays( 6 ); 448 QDate endWeek = startWeek.addDays( 6 );
438 QValueList<EffectiveEvent> eventList = db->getEffectiveEvents(startWeek, endWeek); 449 QValueList<EffectiveEvent> eventList = db->getEffectiveEvents(startWeek, endWeek);
439 view->showEvents( eventList ); 450 view->showEvents( eventList );
440 view->moveToHour( startTime ); 451 view->moveToHour( startTime );
441} 452}
442 453
443void DateBookWeek::generateAllDayTooltext( QString& text ) { 454void DateBookWeek::generateAllDayTooltext( QString& text ) {
444 text += "<b>" + tr("This is an all day event.") + "</b><br>"; 455 text += "<b>" + tr("This is an all day event.") + "</b><br>";
445} 456}
446 457
447void DateBookWeek::generateNormalTooltext( QString& str, const EffectiveEvent &ev ) { 458void DateBookWeek::generateNormalTooltext( QString& str, const EffectiveEvent &ev ) {
448 str += "<b>" + QObject::tr("Start") + "</b>: "; 459 str += "<b>" + QObject::tr("Start") + "</b>: ";
449 str += TimeString::timeString( ev.event().start().time(), ampm, FALSE ); 460 str += TimeString::timeString( ev.event().start().time(), ampm, FALSE );
450 if( ev.startDate()!=ev.endDate() ) { 461 if( ev.startDate()!=ev.endDate() ) {
451 str += " <i>" + TimeString::longDateString( ev.startDate() )+"</i>"; 462 str += " <i>" + TimeString::longDateString( ev.startDate() )+"</i>";
452 } 463 }
453 str += "<br>"; 464 str += "<br>";
454 str += "<b>" + QObject::tr("End") + "</b>: "; 465 str += "<b>" + QObject::tr("End") + "</b>: ";
455 str += TimeString::timeString( ev.event().end().time(), ampm, FALSE ); 466 str += TimeString::timeString( ev.event().end().time(), ampm, FALSE );
456 if( ev.startDate()!=ev.endDate() ) { 467 if( ev.startDate()!=ev.endDate() ) {
457 str += " <i>" + TimeString::longDateString( ev.endDate() ) + "</i>"; 468 str += " <i>" + TimeString::longDateString( ev.endDate() ) + "</i>";
458 } 469 }
459} 470}
460 471
461void DateBookWeek::slotShowEvent( const EffectiveEvent &ev ) 472void DateBookWeek::slotShowEvent( const EffectiveEvent &ev )
462{ 473{
463 if ( tHide->isActive() ) 474 if ( tHide->isActive() )
464 tHide->stop(); 475 tHide->stop();
465 476
466 // why would someone use "<"? Oh well, fix it up... 477 // why would someone use "<"? Oh well, fix it up...
467 // I wonder what other things may be messed up... 478 // I wonder what other things may be messed up...
468 QString strDesc = ev.description(); 479 QString strDesc = ev.description();
469 int where = strDesc.find( "<" ); 480 int where = strDesc.find( "<" );
470 while ( where != -1 ) { 481 while ( where != -1 ) {
471 strDesc.remove( where, 1 ); 482 strDesc.remove( where, 1 );
472 strDesc.insert( where, "&#60;" ); 483 strDesc.insert( where, "&#60;" );
473 where = strDesc.find( "<", where ); 484 where = strDesc.find( "<", where );
474 } 485 }
475 486
476 QString strCat; 487 QString strCat;
477 // ### FIX later... 488 // ### FIX later...
478// QString strCat = ev.category(); 489// QString strCat = ev.category();
479// where = strCat.find( "<" ); 490// where = strCat.find( "<" );
480// while ( where != -1 ) { 491// while ( where != -1 ) {
481// strCat.remove( where, 1 ); 492// strCat.remove( where, 1 );
482// strCat.insert( where, "&#60;" ); 493// strCat.insert( where, "&#60;" );
483// where = strCat.find( "<", where ); 494// where = strCat.find( "<", where );
484// } 495// }
485 496
486 QString strLocation = ev.location(); 497 QString strLocation = ev.location();
487 while ( where != -1 ) { 498 while ( where != -1 ) {
488 strLocation.remove( where, 1 ); 499 strLocation.remove( where, 1 );
489 strLocation.insert( where, "&#60;" ); 500 strLocation.insert( where, "&#60;" );
490 where = strLocation.find( "<", where ); 501 where = strLocation.find( "<", where );
491 } 502 }
492 503
493 QString strNote = ev.notes(); 504 QString strNote = ev.notes();
494 where = strNote.find( "<" ); 505 where = strNote.find( "<" );
495 while ( where != -1 ) { 506 while ( where != -1 ) {
496 strNote.remove( where, 1 ); 507 strNote.remove( where, 1 );
497 strNote.insert( where, "&#60;" ); 508 strNote.insert( where, "&#60;" );
498 where = strNote.find( "<", where ); 509 where = strNote.find( "<", where );
499 } 510 }
500 511
501 QString str = "<b>" + strDesc + "</b><br>" 512 QString str = "<b>" + strDesc + "</b><br>"
502 + strLocation + "<br>" 513 + strLocation + "<br>"
503 + "<i>" + strCat + "</i>" 514 + "<i>" + strCat + "</i>"
504 + "<br>" + TimeString::longDateString( ev.date() ) 515 + "<br>" + TimeString::longDateString( ev.date() )
505 + "<br>"; 516 + "<br>";
506 517
507 if (ev.event().type() == Event::Normal ) 518 if (ev.event().type() == Event::Normal )
508 generateNormalTooltext( str, ev ); 519 generateNormalTooltext( str, ev );
509 else 520 else
510 generateAllDayTooltext( str ); 521 generateAllDayTooltext( str );
511 522
512 str += "<br><br>" + strNote; 523 str += "<br><br>" + strNote;
513 524
514 lblDesc->setText( str ); 525 lblDesc->setText( str );
515 lblDesc->resize( lblDesc->sizeHint() ); 526 lblDesc->resize( lblDesc->sizeHint() );
516 // move the label so it is "centerd" horizontally... 527 // move the label so it is "centerd" horizontally...
517 lblDesc->move( QMAX(0,(width() - lblDesc->width()) / 2), 0 ); 528 lblDesc->move( QMAX(0,(width() - lblDesc->width()) / 2), 0 );
518 lblDesc->show(); 529 lblDesc->show();
519} 530}
520 531
521void DateBookWeek::slotHideEvent() 532void DateBookWeek::slotHideEvent()
522{ 533{
523 tHide->start( 2000, true ); 534 tHide->start( 2000, true );
524} 535}
525 536
526void DateBookWeek::setStartViewTime( int startHere ) 537void DateBookWeek::setStartViewTime( int startHere )
527{ 538{
528 startTime = startHere; 539 startTime = startHere;
529 view->moveToHour( startTime ); 540 view->moveToHour( startTime );
530} 541}
531 542
532int DateBookWeek::startViewTime() const 543int DateBookWeek::startViewTime() const
533{ 544{
534 return startTime; 545 return startTime;
535} 546}
536 547
537void DateBookWeek::redraw() 548void DateBookWeek::redraw()
538{ 549{
539 getEvents(); 550 getEvents();
540} 551}
541 552
542void DateBookWeek::slotYearChanged( int y ) 553void DateBookWeek::slotYearChanged( int y )
543{ 554{
544 int totWeek; 555 int totWeek;
545 QDate d( y, 12, 31 ); 556 QDate d( y, 12, 31 );
546 int throwAway; 557 int throwAway;
547 calcWeek( d, totWeek, throwAway, bStartOnMonday ); 558 calcWeek( d, totWeek, throwAway, bStartOnMonday );
548 while ( totWeek == 1 ) { 559 while ( totWeek == 1 ) {
549 d = d.addDays( -1 ); 560 d = d.addDays( -1 );
550 calcWeek( d, totWeek, throwAway, bStartOnMonday ); 561 calcWeek( d, totWeek, throwAway, bStartOnMonday );
551 } 562 }
552} 563}
553 564
554void DateBookWeek::slotWeekChanged( bool onMonday ) 565void DateBookWeek::slotWeekChanged( bool onMonday )
555{ 566{
556 bStartOnMonday = onMonday; 567 bStartOnMonday = onMonday;
557 view->setStartOfWeek( bStartOnMonday ); 568 view->setStartOfWeek( bStartOnMonday );
558 header->setStartOfWeek( bStartOnMonday ); 569 header->setStartOfWeek( bStartOnMonday );
559 redraw(); 570 redraw();
560} 571}
561 572
562void DateBookWeek::slotClockChanged( bool ap ) 573void DateBookWeek::slotClockChanged( bool ap )
563{ 574{
564 ampm = ap; 575 ampm = ap;
565} 576}
566 577
567// return the date at the beginning of the week... 578// return the date at the beginning of the week...
568QDate DateBookWeek::weekDate() const 579QDate DateBookWeek::weekDate() const
569{ 580{
570 QDate d=bdate; 581 QDate d=bdate;
571 582
572 // Calculate offset to first day of week. 583 // Calculate offset to first day of week.
573 int dayoffset=d.dayOfWeek(); 584 int dayoffset=d.dayOfWeek();
574 if(bStartOnMonday) dayoffset--; 585 if(bStartOnMonday) dayoffset--;
575 else if( dayoffset == 7 ) 586 else if( dayoffset == 7 )
576 dayoffset = 0; 587 dayoffset = 0;
577 588
578 return d.addDays(-dayoffset); 589 return d.addDays(-dayoffset);
579} 590}
580 591
581// this used to only be needed by datebook.cpp, but now we need it inside 592// this used to only be needed by datebook.cpp, but now we need it inside
582// week view since 593// week view since
583// we need to be able to figure out our total number of weeks on the fly... 594// we need to be able to figure out our total number of weeks on the fly...
584// this is probably the best place to put it.. 595// this is probably the best place to put it..
585 596
586// For Weeks that start on Monday... (EASY!) 597// For Weeks that start on Monday... (EASY!)
587// At the moment we will use ISO 8601 method for computing 598// At the moment we will use ISO 8601 method for computing
588// the week. Granted, other countries use other methods, 599// the week. Granted, other countries use other methods,
589// bet we aren't doing any Locale stuff at the moment. So, 600// bet we aren't doing any Locale stuff at the moment. So,
590// this should pass. This Algorithim is public domain and 601// this should pass. This Algorithim is public domain and
591// available at: 602// available at:
592// http://personal.ecu.edu/mccartyr/ISOwdALG.txt 603// http://personal.ecu.edu/mccartyr/ISOwdALG.txt
593// the week number is return, and the year number is returned in year 604// the week number is return, and the year number is returned in year
594// for Instance 2001/12/31 is actually the first week in 2002. 605// for Instance 2001/12/31 is actually the first week in 2002.
595// There is a more mathematical definition, but I will implement it when 606// There is a more mathematical definition, but I will implement it when
596// we are pass our deadline. 607// we are pass our deadline.
597 608
598// For Weeks that start on Sunday... (ahh... home rolled) 609// For Weeks that start on Sunday... (ahh... home rolled)
599// okay, if Jan 1 is on Friday or Saturday, 610// okay, if Jan 1 is on Friday or Saturday,
600// it will go to the pervious 611// it will go to the pervious
601// week... 612// week...
602 613
603bool calcWeek( const QDate &d, int &week, int &year, 614bool calcWeek( const QDate &d, int &week, int &year,
604 bool startOnMonday ) 615 bool startOnMonday )
605{ 616{
606 int weekNumber; 617 int weekNumber;
607 int yearNumber; 618 int yearNumber;
608 619
609 // remove a pesky warning, (Optimizations on g++) 620 // remove a pesky warning, (Optimizations on g++)
610 weekNumber = -1; 621 weekNumber = -1;
611 int jan1WeekDay = QDate(d.year(), 1, 1).dayOfWeek(); 622 int jan1WeekDay = QDate(d.year(), 1, 1).dayOfWeek();
612 int dayOfWeek = d.dayOfWeek(); 623 int dayOfWeek = d.dayOfWeek();
613 624
614 if ( !d.isValid() ) 625 if ( !d.isValid() )
615 return false; 626 return false;
616 627
617 if ( startOnMonday ) { 628 if ( startOnMonday ) {
618 // find the Jan1Weekday; 629 // find the Jan1Weekday;
619 if ( d.dayOfYear() <= ( 8 - jan1WeekDay) && jan1WeekDay > 4 ) { 630 if ( d.dayOfYear() <= ( 8 - jan1WeekDay) && jan1WeekDay > 4 ) {
620 yearNumber = d.year() - 1; 631 yearNumber = d.year() - 1;
621 if ( jan1WeekDay == 5 || ( jan1WeekDay == 6 && QDate::leapYear(yearNumber) ) ) 632 if ( jan1WeekDay == 5 || ( jan1WeekDay == 6 && QDate::leapYear(yearNumber) ) )
622 weekNumber = 53; 633 weekNumber = 53;
623 else 634 else
624 weekNumber = 52; 635 weekNumber = 52;
625 } else 636 } else
626 yearNumber = d.year(); 637 yearNumber = d.year();
627 if ( yearNumber == d.year() ) { 638 if ( yearNumber == d.year() ) {
628 int totalDays = 365; 639 int totalDays = 365;
629 if ( QDate::leapYear(yearNumber) ) 640 if ( QDate::leapYear(yearNumber) )
630 totalDays++; 641 totalDays++;
631 if ( ((totalDays - d.dayOfYear()) < (4 - dayOfWeek) ) 642 if ( ((totalDays - d.dayOfYear()) < (4 - dayOfWeek) )
632 || (jan1WeekDay == 7) && (totalDays - d.dayOfYear()) < 3) { 643 || (jan1WeekDay == 7) && (totalDays - d.dayOfYear()) < 3) {
633 yearNumber++; 644 yearNumber++;
634 weekNumber = 1; 645 weekNumber = 1;
635 } 646 }
636 } 647 }
637 if ( yearNumber == d.year() ) { 648 if ( yearNumber == d.year() ) {
638 int j = d.dayOfYear() + (7 - dayOfWeek) + ( jan1WeekDay - 1 ); 649 int j = d.dayOfYear() + (7 - dayOfWeek) + ( jan1WeekDay - 1 );
639 weekNumber = j / 7; 650 weekNumber = j / 7;
640 if ( jan1WeekDay > 4 ) 651 if ( jan1WeekDay > 4 )
641 weekNumber--; 652 weekNumber--;
642 } 653 }
643 } else { 654 } else {
644 // it's better to keep these cases separate... 655 // it's better to keep these cases separate...
645 if ( d.dayOfYear() <= (7 - jan1WeekDay) && jan1WeekDay > 4 656 if ( d.dayOfYear() <= (7 - jan1WeekDay) && jan1WeekDay > 4
646 && jan1WeekDay != 7 ) { 657 && jan1WeekDay != 7 ) {
647 yearNumber = d.year() - 1; 658 yearNumber = d.year() - 1;
648 if ( jan1WeekDay == 6 659 if ( jan1WeekDay == 6
649 || (jan1WeekDay == 7 && QDate::leapYear(yearNumber) ) ) { 660 || (jan1WeekDay == 7 && QDate::leapYear(yearNumber) ) ) {
650 weekNumber = 53; 661 weekNumber = 53;
651 }else 662 }else
652 weekNumber = 52; 663 weekNumber = 52;
653 } else 664 } else
654 yearNumber = d.year(); 665 yearNumber = d.year();
655 if ( yearNumber == d.year() ) { 666 if ( yearNumber == d.year() ) {
656 int totalDays = 365; 667 int totalDays = 365;
657 if ( QDate::leapYear( yearNumber ) ) 668 if ( QDate::leapYear( yearNumber ) )
658 totalDays++; 669 totalDays++;
659 if ( ((totalDays - d.dayOfYear()) < (4 - dayOfWeek % 7)) ) { 670 if ( ((totalDays - d.dayOfYear()) < (4 - dayOfWeek % 7)) ) {
660 yearNumber++; 671 yearNumber++;
661 weekNumber = 1; 672 weekNumber = 1;
662 } 673 }
663 } 674 }
664 if ( yearNumber == d.year() ) { 675 if ( yearNumber == d.year() ) {
665 int j = d.dayOfYear() + (7 - dayOfWeek % 7) + ( jan1WeekDay - 1 ); 676 int j = d.dayOfYear() + (7 - dayOfWeek % 7) + ( jan1WeekDay - 1 );
666 weekNumber = j / 7; 677 weekNumber = j / 7;
667 if ( jan1WeekDay > 4 ) { 678 if ( jan1WeekDay > 4 ) {
668 weekNumber--; 679 weekNumber--;
669 } 680 }
670 } 681 }
671 } 682 }
672 year = yearNumber; 683 year = yearNumber;
673 week = weekNumber; 684 week = weekNumber;
674 return true; 685 return true;
675} 686}
676 687
diff --git a/core/pim/datebook/datebookweek.h b/core/pim/datebook/datebookweek.h
index ddf54ed..2d25f10 100644
--- a/core/pim/datebook/datebookweek.h
+++ b/core/pim/datebook/datebookweek.h
@@ -1,167 +1,178 @@
1/********************************************************************** 1/*
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2                 This file is part of the Opie Project
3** 3
4** This file is part of Qtopia Environment. 4 Copyright (C) Opie Team <opie-devel@handhelds.org>
5** 5 =.
6** This file may be distributed and/or modified under the terms of the 6 .=l.
7** GNU General Public License version 2 as published by the Free Software 7           .>+-=
8** Foundation and appearing in the file LICENSE.GPL included in the 8 _;:,     .>    :=|. This program is free software; you can
9** packaging of this file. 9.> <`_,   >  .   <= redistribute it and/or modify it under
10** 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11.="- .-=="i,     .._ License as published by the Free Software
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13** 13     ._= =}       : or (at your option) any later version.
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14    .%`+i>       _;_.
15** 15    .i_,=:_.      -<s. This program is distributed in the hope that
16** Contact info@trolltech.com if any conditions of this licensing are 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17** not clear to you. 17 : ..    .:,     . . . without even the implied warranty of
18** 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19**********************************************************************/ 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details.
22:     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA.
29*/
30
20#ifndef DATEBOOKWEEK 31#ifndef DATEBOOKWEEK
21#define DATEBOOKWEEK 32#define DATEBOOKWEEK
22 33
23#include <qpe/event.h> 34#include <qpe/event.h>
24 35
25#include <qlist.h> 36#include <qlist.h>
26#include <qscrollview.h> 37#include <qscrollview.h>
27#include <qstring.h> 38#include <qstring.h>
28#include <qvaluelist.h> 39#include <qvaluelist.h>
29 40
30class DateBookDB; 41class DateBookDB;
31class DateBookDBHoliday; 42class DateBookDBHoliday;
32class DateBookWeekHeader; 43class DateBookWeekHeader;
33class QDate; 44class QDate;
34class QLabel; 45class QLabel;
35class QResizeEvent; 46class QResizeEvent;
36class QSpinBox; 47class QSpinBox;
37class QTimer; 48class QTimer;
38class QHeader; 49class QHeader;
39 50
40class DateBookWeekItem 51class DateBookWeekItem
41{ 52{
42public: 53public:
43 DateBookWeekItem( const EffectiveEvent e ); 54 DateBookWeekItem( const EffectiveEvent e );
44 55
45 void setGeometry( int x, int y, int w, int h ); 56 void setGeometry( int x, int y, int w, int h );
46 QRect geometry() const { return r; } 57 QRect geometry() const { return r; }
47 58
48 const QColor &color() const { return c; } 59 const QColor &color() const { return c; }
49 const EffectiveEvent event() const { return ev; } 60 const EffectiveEvent event() const { return ev; }
50 61
51private: 62private:
52 const EffectiveEvent ev; 63 const EffectiveEvent ev;
53 QRect r; 64 QRect r;
54 QColor c; 65 QColor c;
55}; 66};
56 67
57class DateBookWeekView : public QScrollView 68class DateBookWeekView : public QScrollView
58{ 69{
59 Q_OBJECT 70 Q_OBJECT
60public: 71public:
61 DateBookWeekView( bool ampm, bool weekOnMonday, QWidget *parent = 0, 72 DateBookWeekView( bool ampm, bool weekOnMonday, QWidget *parent = 0,
62 const char *name = 0 ); 73 const char *name = 0 );
63 74
64 bool whichClock() const; 75 bool whichClock() const;
65 void showEvents( QValueList<EffectiveEvent> &ev ); 76 void showEvents( QValueList<EffectiveEvent> &ev );
66 void moveToHour( int h ); 77 void moveToHour( int h );
67 void setStartOfWeek( bool bOnMonday ); 78 void setStartOfWeek( bool bOnMonday );
68 79
69signals: 80signals:
70 void showDay( int d ); 81 void showDay( int d );
71 void signalShowEvent( const EffectiveEvent & ); 82 void signalShowEvent( const EffectiveEvent & );
72 void signalHideEvent(); 83 void signalHideEvent();
73 84
74protected slots: 85protected slots:
75 void keyPressEvent(QKeyEvent *); 86 void keyPressEvent(QKeyEvent *);
76 87
77private slots: 88private slots:
78 void slotChangeClock( bool ); 89 void slotChangeClock( bool );
79 void alterDay( int ); 90 void alterDay( int );
80 91
81private: 92private:
82 void positionItem( DateBookWeekItem *i ); 93 void positionItem( DateBookWeekItem *i );
83 DateBookWeekItem *intersects( const DateBookWeekItem * ); 94 DateBookWeekItem *intersects( const DateBookWeekItem * );
84 void drawContents( QPainter *p, int cx, int cy, int cw, int ch ); 95 void drawContents( QPainter *p, int cx, int cy, int cw, int ch );
85 void contentsMousePressEvent( QMouseEvent * ); 96 void contentsMousePressEvent( QMouseEvent * );
86 void contentsMouseReleaseEvent( QMouseEvent * ); 97 void contentsMouseReleaseEvent( QMouseEvent * );
87 void resizeEvent( QResizeEvent * ); 98 void resizeEvent( QResizeEvent * );
88 void initNames(); 99 void initNames();
89 100
90private: 101private:
91 bool ampm; 102 bool ampm;
92 bool bOnMonday; 103 bool bOnMonday;
93 QHeader *header; 104 QHeader *header;
94 QList<DateBookWeekItem> items; 105 QList<DateBookWeekItem> items;
95 int rowHeight; 106 int rowHeight;
96 bool showingEvent; 107 bool showingEvent;
97}; 108};
98 109
99class DateBookWeek : public QWidget 110class DateBookWeek : public QWidget
100{ 111{
101 Q_OBJECT 112 Q_OBJECT
102 113
103public: 114public:
104 DateBookWeek( bool ampm, bool weekOnMonday, DateBookDBHoliday *newDB, 115 DateBookWeek( bool ampm, bool weekOnMonday, DateBookDBHoliday *newDB,
105 QWidget *parent = 0, const char *name = 0 ); 116 QWidget *parent = 0, const char *name = 0 );
106 void setDate( int y, int m, int d ); 117 void setDate( int y, int m, int d );
107 void setDate( QDate d ); 118 void setDate( QDate d );
108 QDate date() const; 119 QDate date() const;
109 DateBookWeekView *weekView() const { return view; } 120 DateBookWeekView *weekView() const { return view; }
110 void setStartViewTime( int startHere ); 121 void setStartViewTime( int startHere );
111 int startViewTime() const; 122 int startViewTime() const;
112 int week() const { return _week; }; 123 int week() const { return _week; };
113 QDate weekDate() const; 124 QDate weekDate() const;
114 125
115public slots: 126public slots:
116 void redraw(); 127 void redraw();
117 void slotWeekChanged( bool bStartOnMonday ); 128 void slotWeekChanged( bool bStartOnMonday );
118 void slotClockChanged( bool a ); 129 void slotClockChanged( bool a );
119 130
120signals: 131signals:
121 void showDate( int y, int m, int d ); 132 void showDate( int y, int m, int d );
122 133
123protected slots: 134protected slots:
124 void keyPressEvent(QKeyEvent *); 135 void keyPressEvent(QKeyEvent *);
125 136
126private slots: 137private slots:
127 void showDay( int day ); 138 void showDay( int day );
128 void dateChanged( QDate &newdate ); 139 void dateChanged( QDate &newdate );
129 void slotShowEvent( const EffectiveEvent & ); 140 void slotShowEvent( const EffectiveEvent & );
130 void slotHideEvent(); 141 void slotHideEvent();
131 void slotYearChanged( int ); 142 void slotYearChanged( int );
132 143
133private: 144private:
134 void getEvents(); 145 void getEvents();
135 146
136 /** 147 /**
137 * Wow that's a hell lot of code duplication 148 * Wow that's a hell lot of code duplication
138 * in datebook. I vote for a common base class 149 * in datebook. I vote for a common base class
139 * but never the less. This add a note 150 * but never the less. This add a note
140 * that the Event is an all day event 151 * that the Event is an all day event
141 * 152 *
142 */ 153 */
143 void generateAllDayTooltext( QString& text ); 154 void generateAllDayTooltext( QString& text );
144 155
145 /** 156 /**
146 * This will add the times to the text 157 * This will add the times to the text
147 * It will be shown in the Tooltip bubble 158 * It will be shown in the Tooltip bubble
148 */ 159 */
149 void generateNormalTooltext( QString& text, 160 void generateNormalTooltext( QString& text,
150 const EffectiveEvent &ev); 161 const EffectiveEvent &ev);
151 int year; 162 int year;
152 int _week; 163 int _week;
153 int dow; 164 int dow;
154 QDate bdate; 165 QDate bdate;
155 DateBookWeekHeader *header; 166 DateBookWeekHeader *header;
156 DateBookWeekView *view; 167 DateBookWeekView *view;
157 DateBookDBHoliday *db; 168 DateBookDBHoliday *db;
158 QLabel *lblDesc; 169 QLabel *lblDesc;
159 QTimer *tHide; 170 QTimer *tHide;
160 int startTime; 171 int startTime;
161 bool ampm; 172 bool ampm;
162 bool bStartOnMonday; 173 bool bStartOnMonday;
163}; 174};
164 175
165 176
166bool calcWeek( const QDate &d, int &week, int &year, bool startOnMonday = false ); 177bool calcWeek( const QDate &d, int &week, int &year, bool startOnMonday = false );
167#endif 178#endif
diff --git a/core/pim/datebook/datebookweekheaderimpl.cpp b/core/pim/datebook/datebookweekheaderimpl.cpp
index 7462de7..9922778 100644
--- a/core/pim/datebook/datebookweekheaderimpl.cpp
+++ b/core/pim/datebook/datebookweekheaderimpl.cpp
@@ -1,123 +1,134 @@
1/********************************************************************** 1/*
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2                 This file is part of the Opie Project
3** 3
4** This file is part of Qtopia Environment. 4 Copyright (C) Opie Team <opie-devel@handhelds.org>
5** 5 =.
6** This file may be distributed and/or modified under the terms of the 6 .=l.
7** GNU General Public License version 2 as published by the Free Software 7           .>+-=
8** Foundation and appearing in the file LICENSE.GPL included in the 8 _;:,     .>    :=|. This program is free software; you can
9** packaging of this file. 9.> <`_,   >  .   <= redistribute it and/or modify it under
10** 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11.="- .-=="i,     .._ License as published by the Free Software
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13** 13     ._= =}       : or (at your option) any later version.
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14    .%`+i>       _;_.
15** 15    .i_,=:_.      -<s. This program is distributed in the hope that
16** Contact info@trolltech.com if any conditions of this licensing are 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17** not clear to you. 17 : ..    .:,     . . . without even the implied warranty of
18** 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19**********************************************************************/ 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details.
22:     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA.
29*/
30
20#include "datebookweekheaderimpl.h" 31#include "datebookweekheaderimpl.h"
21#include "datebookweek.h" 32#include "datebookweek.h"
22 33
23#include <opie2/odebug.h> 34#include <opie2/odebug.h>
35#include <opie2/oresource.h>
24 36
25#include <qpe/resource.h>
26#include <qpe/datebookmonth.h> 37#include <qpe/datebookmonth.h>
27 38
28#include <qtoolbutton.h> 39#include <qtoolbutton.h>
29 40
30/* 41/*
31 * Constructs a DateBookWeekHeader which is a child of 'parent', with the 42 * Constructs a DateBookWeekHeader which is a child of 'parent', with the
32 * name 'name' and widget flags set to 'f' 43 * name 'name' and widget flags set to 'f'
33 */ 44 */
34DateBookWeekHeader::DateBookWeekHeader( bool startOnMonday, QWidget* parent, const char* name, WFlags fl ) 45DateBookWeekHeader::DateBookWeekHeader( bool startOnMonday, QWidget* parent, const char* name, WFlags fl )
35 : DateBookWeekHeaderBase( parent, name, fl ), 46 : DateBookWeekHeaderBase( parent, name, fl ),
36 bStartOnMonday( startOnMonday ) 47 bStartOnMonday( startOnMonday )
37{ 48{
38 setBackgroundMode( PaletteButton ); 49 setBackgroundMode( PaletteButton );
39 labelDate->setBackgroundMode( PaletteButton ); 50 labelDate->setBackgroundMode( PaletteButton );
40 backmonth->setPixmap( Resource::loadPixmap("fastback") ); 51 backmonth->setPixmap( Opie::Core::OResource::loadPixmap( "fastback", Opie::Core::OResource::SmallIcon ) );
41 backweek->setPixmap( Resource::loadPixmap("back") ); 52 backweek->setPixmap( Opie::Core::OResource::loadPixmap( "back", Opie::Core::OResource::SmallIcon ) );
42 forwardweek->setPixmap( Resource::loadPixmap("forward") ); 53 forwardweek->setPixmap( Opie::Core::OResource::loadPixmap( "forward", Opie::Core::OResource::SmallIcon ) );
43 forwardmonth->setPixmap( Resource::loadPixmap("fastforward") ); 54 forwardmonth->setPixmap( Opie::Core::OResource::loadPixmap( "fastforward", Opie::Core::OResource::SmallIcon ) );
44} 55}
45 56
46/* 57/*
47 * Destroys the object and frees any allocated resources 58 * Destroys the object and frees any allocated resources
48 */ 59 */
49DateBookWeekHeader::~DateBookWeekHeader() 60DateBookWeekHeader::~DateBookWeekHeader()
50{ 61{
51 // no need to delete child widgets, Qt does it all for us 62 // no need to delete child widgets, Qt does it all for us
52} 63}
53 64
54void DateBookWeekHeader::pickDate() 65void DateBookWeekHeader::pickDate()
55{ 66{
56 static QPopupMenu *m1 = 0; 67 static QPopupMenu *m1 = 0;
57 static DateBookMonth *picker = 0; 68 static DateBookMonth *picker = 0;
58 if ( !m1 ) { 69 if ( !m1 ) {
59 m1 = new QPopupMenu( this ); 70 m1 = new QPopupMenu( this );
60 picker = new DateBookMonth( m1, 0, TRUE ); 71 picker = new DateBookMonth( m1, 0, TRUE );
61 m1->insertItem( picker ); 72 m1->insertItem( picker );
62 connect( picker, SIGNAL( dateClicked(int,int,int) ), this, SLOT( setDate(int,int,int) ) ); 73 connect( picker, SIGNAL( dateClicked(int,int,int) ), this, SLOT( setDate(int,int,int) ) );
63 // connect( m1, SIGNAL( aboutToHide() ), this, SLOT( gotHide() ) ); 74 // connect( m1, SIGNAL( aboutToHide() ), this, SLOT( gotHide() ) );
64 } 75 }
65 picker->setDate( date.year(), date.month(), date.day() ); 76 picker->setDate( date.year(), date.month(), date.day() );
66 m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); 77 m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height())));
67 picker->setFocus(); 78 picker->setFocus();
68} 79}
69 80
70void DateBookWeekHeader::nextMonth() 81void DateBookWeekHeader::nextMonth()
71{ 82{
72 owarn << "nextMonth()" << oendl; 83 owarn << "nextMonth()" << oendl;
73 setDate(date.addDays(28)); 84 setDate(date.addDays(28));
74} 85}
75void DateBookWeekHeader::prevMonth() 86void DateBookWeekHeader::prevMonth()
76{ 87{
77 owarn << "prevMonth()" << oendl; 88 owarn << "prevMonth()" << oendl;
78 setDate(date.addDays(-28)); 89 setDate(date.addDays(-28));
79} 90}
80void DateBookWeekHeader::nextWeek() 91void DateBookWeekHeader::nextWeek()
81{ 92{
82 owarn << "nextWeek()" << oendl; 93 owarn << "nextWeek()" << oendl;
83 setDate(date.addDays(7)); 94 setDate(date.addDays(7));
84} 95}
85void DateBookWeekHeader::prevWeek() 96void DateBookWeekHeader::prevWeek()
86{ 97{
87 owarn << "prevWeek()" << oendl; 98 owarn << "prevWeek()" << oendl;
88 setDate(date.addDays(-7)); 99 setDate(date.addDays(-7));
89} 100}
90 101
91void DateBookWeekHeader::setDate( int y, int m, int d ) 102void DateBookWeekHeader::setDate( int y, int m, int d )
92{ 103{
93 setDate(QDate(y,m,d)); 104 setDate(QDate(y,m,d));
94} 105}
95 106
96void DateBookWeekHeader::setDate(const QDate &d) { 107void DateBookWeekHeader::setDate(const QDate &d) {
97 int year,week,dayofweek; 108 int year,week,dayofweek;
98 date=d; 109 date=d;
99 dayofweek=d.dayOfWeek(); 110 dayofweek=d.dayOfWeek();
100 if(bStartOnMonday) 111 if(bStartOnMonday)
101 dayofweek--; 112 dayofweek--;
102 else if( dayofweek == 7 ) 113 else if( dayofweek == 7 )
103 // we already have the right day -7 would lead to the current week.. 114 // we already have the right day -7 would lead to the current week..
104 dayofweek = 0; 115 dayofweek = 0;
105 116
106 date=date.addDays(-dayofweek); 117 date=date.addDays(-dayofweek);
107 calcWeek(date,week,year,bStartOnMonday); 118 calcWeek(date,week,year,bStartOnMonday);
108 QDate start=date; 119 QDate start=date;
109 QDate stop=start.addDays(6); 120 QDate stop=start.addDays(6);
110 labelDate->setText( QString::number(start.day()) + "." + 121 labelDate->setText( QString::number(start.day()) + "." +
111 Calendar::nameOfMonth( start.month()) + "-" + 122 Calendar::nameOfMonth( start.month()) + "-" +
112 QString::number(stop.day()) + "." + 123 QString::number(stop.day()) + "." +
113 Calendar::nameOfMonth( stop.month()) +" ("+ 124 Calendar::nameOfMonth( stop.month()) +" ("+
114 tr("w")+":"+QString::number( week ) +")"); 125 tr("w")+":"+QString::number( week ) +")");
115 date = d; // bugfix: 0001126 - date has to be the selected date, not monday! 126 date = d; // bugfix: 0001126 - date has to be the selected date, not monday!
116 emit dateChanged(date); 127 emit dateChanged(date);
117} 128}
118 129
119void DateBookWeekHeader::setStartOfWeek( bool onMonday ) 130void DateBookWeekHeader::setStartOfWeek( bool onMonday )
120{ 131{
121 bStartOnMonday = onMonday; 132 bStartOnMonday = onMonday;
122 setDate( date ); 133 setDate( date );
123} 134}
diff --git a/core/pim/datebook/datebookweekheaderimpl.h b/core/pim/datebook/datebookweekheaderimpl.h
index d8dce90..0b388b4 100644
--- a/core/pim/datebook/datebookweekheaderimpl.h
+++ b/core/pim/datebook/datebookweekheaderimpl.h
@@ -1,57 +1,68 @@
1/********************************************************************** 1/*
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2                 This file is part of the Opie Project
3** 3
4** This file is part of Qtopia Environment. 4 Copyright (C) Opie Team <opie-devel@handhelds.org>
5** 5 =.
6** This file may be distributed and/or modified under the terms of the 6 .=l.
7** GNU General Public License version 2 as published by the Free Software 7           .>+-=
8** Foundation and appearing in the file LICENSE.GPL included in the 8 _;:,     .>    :=|. This program is free software; you can
9** packaging of this file. 9.> <`_,   >  .   <= redistribute it and/or modify it under
10** 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11.="- .-=="i,     .._ License as published by the Free Software
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13** 13     ._= =}       : or (at your option) any later version.
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14    .%`+i>       _;_.
15** 15    .i_,=:_.      -<s. This program is distributed in the hope that
16** Contact info@trolltech.com if any conditions of this licensing are 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17** not clear to you. 17 : ..    .:,     . . . without even the implied warranty of
18** 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19**********************************************************************/ 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details.
22:     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA.
29*/
30
20#ifndef DATEBOOKDAYHEADER_H 31#ifndef DATEBOOKDAYHEADER_H
21#define DATEBOOKDAYHEADER_H 32#define DATEBOOKDAYHEADER_H
22#include <qdatetime.h> 33#include <qdatetime.h>
23#include "datebookweekheader.h" 34#include "datebookweekheader.h"
24 35
25 36
26class DateBookWeekHeader : public DateBookWeekHeaderBase 37class DateBookWeekHeader : public DateBookWeekHeaderBase
27{ 38{
28 Q_OBJECT 39 Q_OBJECT
29 40
30public: 41public:
31 DateBookWeekHeader( bool startOnMonday, QWidget* parent = 0, 42 DateBookWeekHeader( bool startOnMonday, QWidget* parent = 0,
32 const char* name = 0, WFlags fl = 0 ); 43 const char* name = 0, WFlags fl = 0 );
33 ~DateBookWeekHeader(); 44 ~DateBookWeekHeader();
34 45
35 void setDate(const QDate &d); 46 void setDate(const QDate &d);
36 void setStartOfWeek( bool onMonday ); 47 void setStartOfWeek( bool onMonday );
37 48
38signals: 49signals:
39 void dateChanged( QDate &date ); 50 void dateChanged( QDate &date );
40 51
41public slots: 52public slots:
42 void pickDate(); 53 void pickDate();
43 void nextMonth(); 54 void nextMonth();
44 void prevMonth(); 55 void prevMonth();
45 void nextWeek(); 56 void nextWeek();
46 void prevWeek(); 57 void prevWeek();
47 void setDate( int y, int m, int d); 58 void setDate( int y, int m, int d);
48 59
49protected slots: 60protected slots:
50 void keyPressEvent(QKeyEvent *e) { e->ignore(); } 61 void keyPressEvent(QKeyEvent *e) { e->ignore(); }
51 62
52private: 63private:
53 QDate date; 64 QDate date;
54 bool bStartOnMonday; 65 bool bStartOnMonday;
55}; 66};
56 67
57#endif // DATEBOOKDAYHEADER_H 68#endif // DATEBOOKDAYHEADER_H
diff --git a/core/pim/datebook/dateentryimpl.cpp b/core/pim/datebook/dateentryimpl.cpp
index 297da94..adfa33f 100644
--- a/core/pim/datebook/dateentryimpl.cpp
+++ b/core/pim/datebook/dateentryimpl.cpp
@@ -1,562 +1,572 @@
1/********************************************************************** 1/*
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2                 This file is part of the Opie Project
3** 3
4** This file is part of Qtopia Environment. 4 Copyright (C) Opie Team <opie-devel@handhelds.org>
5** 5 =.
6** This file may be distributed and/or modified under the terms of the 6 .=l.
7** GNU General Public License version 2 as published by the Free Software 7           .>+-=
8** Foundation and appearing in the file LICENSE.GPL included in the 8 _;:,     .>    :=|. This program is free software; you can
9** packaging of this file. 9.> <`_,   >  .   <= redistribute it and/or modify it under
10** 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11.="- .-=="i,     .._ License as published by the Free Software
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13** 13     ._= =}       : or (at your option) any later version.
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14    .%`+i>       _;_.
15** 15    .i_,=:_.      -<s. This program is distributed in the hope that
16** Contact info@trolltech.com if any conditions of this licensing are 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17** not clear to you. 17 : ..    .:,     . . . without even the implied warranty of
18** 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19**********************************************************************/ 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details.
22:     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA.
29*/
20 30
21#include "namespace_hack.h" 31#include "namespace_hack.h"
22#include "dateentryimpl.h" 32#include "dateentryimpl.h"
23#include "repeatentry.h" 33#include "repeatentry.h"
24 34
25#include <opie2/odebug.h> 35#include <opie2/odebug.h>
26#include <opie2/otimepicker.h> 36#include <opie2/otimepicker.h>
27 37
28#include <qpe/qpeapplication.h> 38#include <qpe/qpeapplication.h>
29#include <qpe/categoryselect.h> 39#include <qpe/categoryselect.h>
30#include <qpe/datebookmonth.h> 40#include <qpe/datebookmonth.h>
31#include <qpe/tzselect.h> 41#include <qpe/tzselect.h>
32 42
33#include <qlineedit.h> 43#include <qlineedit.h>
34#include <qspinbox.h> 44#include <qspinbox.h>
35 45
36#include "onoteedit.h" 46#include "onoteedit.h"
37 47
38#include <stdlib.h> 48#include <stdlib.h>
39#include <stdio.h> 49#include <stdio.h>
40 50
41/* 51/*
42 * Constructs a DateEntry which is a child of 'parent', with the 52 * Constructs a DateEntry which is a child of 'parent', with the
43 * name 'name' and widget flags set to 'f' 53 * name 'name' and widget flags set to 'f'
44 * 54 *
45 * The dialog will by default be modeless, unless you set 'modal' to 55 * The dialog will by default be modeless, unless you set 'modal' to
46 * TRUE to construct a modal dialog. 56 * TRUE to construct a modal dialog.
47 */ 57 */
48 58
49DateEntry::DateEntry( bool startOnMonday, const QDateTime &start, 59DateEntry::DateEntry( bool startOnMonday, const QDateTime &start,
50 const QDateTime &end, bool whichClock, QWidget* parent, 60 const QDateTime &end, bool whichClock, QWidget* parent,
51 const char* name ) 61 const char* name )
52 : DateEntryBase( parent, name ), 62 : DateEntryBase( parent, name ),
53 ampm( whichClock ), 63 ampm( whichClock ),
54 startWeekOnMonday( startOnMonday ), 64 startWeekOnMonday( startOnMonday ),
55 m_showStart(true) 65 m_showStart(true)
56{ 66{
57 init(); 67 init();
58 setDates(start,end); 68 setDates(start,end);
59 setFocusProxy(comboDescription); 69 setFocusProxy(comboDescription);
60} 70}
61 71
62bool DateEntry::eventFilter(QObject *obj, QEvent *ev ) 72bool DateEntry::eventFilter(QObject *obj, QEvent *ev )
63{ 73{
64 if( ev->type() == QEvent::FocusIn ){ 74 if( ev->type() == QEvent::FocusIn ){
65 if( obj == comboStart ){ 75 if( obj == comboStart ){
66 timePickerStart->setHour(startTime.hour()); 76 timePickerStart->setHour(startTime.hour());
67 timePickerStart->setMinute(startTime.minute()); 77 timePickerStart->setMinute(startTime.minute());
68 TimePickerLabel->setText( tr("Start Time" ) ); 78 TimePickerLabel->setText( tr("Start Time" ) );
69 m_showStart= true; 79 m_showStart= true;
70 }else if( obj == comboEnd ){ 80 }else if( obj == comboEnd ){
71 timePickerStart->setHour(endTime.hour()); 81 timePickerStart->setHour(endTime.hour());
72 timePickerStart->setMinute(endTime.minute()); 82 timePickerStart->setMinute(endTime.minute());
73 TimePickerLabel->setText( tr("End Time") ); 83 TimePickerLabel->setText( tr("End Time") );
74 m_showStart = false; 84 m_showStart = false;
75 } 85 }
76 } else if( ev->type() == QEvent::FocusOut ){ 86 } else if( ev->type() == QEvent::FocusOut ){
77// if( obj == comboEnd ){ 87// if( obj == comboEnd ){
78// QString s; 88// QString s;
79// s.sprintf("%.2d:%.2d",endTime.hour(), endTime.minute()); 89// s.sprintf("%.2d:%.2d",endTime.hour(), endTime.minute());
80// comboEnd->setText(s); 90// comboEnd->setText(s);
81// } 91// }
82// else if( obj == comboStart ){ 92// else if( obj == comboStart ){
83// QString s; 93// QString s;
84// s.sprintf("%.2d:%.2d",startTime.hour(), startTime.minute()); 94// s.sprintf("%.2d:%.2d",startTime.hour(), startTime.minute());
85// comboStart->setText(s); 95// comboStart->setText(s);
86// } 96// }
87 } 97 }
88 98
89 return false; 99 return false;
90} 100}
91 101
92static void addOrPick( QComboBox* combo, const QString& t ) 102static void addOrPick( QComboBox* combo, const QString& t )
93{ 103{
94 // Pick an item if one excists 104 // Pick an item if one excists
95 for (int i=0; i<combo->count(); i++) { 105 for (int i=0; i<combo->count(); i++) {
96 if ( combo->text(i) == t ) { 106 if ( combo->text(i) == t ) {
97 combo->setCurrentItem(i); 107 combo->setCurrentItem(i);
98 return; 108 return;
99 } 109 }
100 } 110 }
101 111
102 // Else add one 112 // Else add one
103 combo->insertItem(t); 113 combo->insertItem(t);
104 combo->setCurrentItem(combo->count()-1); 114 combo->setCurrentItem(combo->count()-1);
105} 115}
106 116
107DateEntry::DateEntry( bool startOnMonday, const Event &event, bool whichClock, 117DateEntry::DateEntry( bool startOnMonday, const Event &event, bool whichClock,
108 QWidget* parent, const char* name ) 118 QWidget* parent, const char* name )
109 : DateEntryBase( parent, name ), 119 : DateEntryBase( parent, name ),
110 ampm( whichClock ), 120 ampm( whichClock ),
111 startWeekOnMonday( startOnMonday ), 121 startWeekOnMonday( startOnMonday ),
112 m_showStart(true) 122 m_showStart(true)
113 123
114{ 124{
115 init(); 125 init();
116 setDates(event.start(),event.end()); 126 setDates(event.start(),event.end());
117 comboCategory->setCategories( event.categories(), "Calendar", tr("Calendar") ); 127 comboCategory->setCategories( event.categories(), "Calendar", tr("Calendar") );
118 if(!event.description().isEmpty()) 128 if(!event.description().isEmpty())
119 addOrPick( comboDescription, event.description() ); 129 addOrPick( comboDescription, event.description() );
120 if(!event.location().isEmpty()) 130 if(!event.location().isEmpty())
121 addOrPick( comboLocation, event.location() ); 131 addOrPick( comboLocation, event.location() );
122 checkAlarm->setChecked( event.hasAlarm() ); 132 checkAlarm->setChecked( event.hasAlarm() );
123 checkAllDay->setChecked( event.type() == Event::AllDay ); 133 checkAllDay->setChecked( event.type() == Event::AllDay );
124 if(!event.notes().isEmpty()) noteStr=event.notes(); 134 if(!event.notes().isEmpty()) noteStr=event.notes();
125 else noteStr=""; 135 else noteStr="";
126 spinAlarm->setValue(event.alarmTime()); 136 spinAlarm->setValue(event.alarmTime());
127 if ( event.alarmSound() != Event::Silent ) 137 if ( event.alarmSound() != Event::Silent )
128 comboSound->setCurrentItem( 1 ); 138 comboSound->setCurrentItem( 1 );
129 if ( event.hasRepeat() ) { 139 if ( event.hasRepeat() ) {
130 rp = event.repeatPattern(); 140 rp = event.repeatPattern();
131 cmdRepeat->setText( tr("Repeat...") ); 141 cmdRepeat->setText( tr("Repeat...") );
132 } 142 }
133 setRepeatLabel(); 143 setRepeatLabel();
134} 144}
135 145
136void DateEntry::setDates( const QDateTime& s, const QDateTime& e ) 146void DateEntry::setDates( const QDateTime& s, const QDateTime& e )
137{ 147{
138 startDate = s.date(); 148 startDate = s.date();
139 endDate = e.date(); 149 endDate = e.date();
140 startTime = s.time(); 150 startTime = s.time();
141 endTime = e.time(); 151 endTime = e.time();
142 152
143 startDateChanged( s.date().year(), s.date().month(), s.date().day() ); 153 startDateChanged( s.date().year(), s.date().month(), s.date().day() );
144 endDateChanged( e.date().year(), e.date().month(), e.date().day() ); 154 endDateChanged( e.date().year(), e.date().month(), e.date().day() );
145 155
146 updateTimeEdit(true,true); 156 updateTimeEdit(true,true);
147} 157}
148 158
149void DateEntry::updateTimeEdit(bool s, bool e) { 159void DateEntry::updateTimeEdit(bool s, bool e) {
150 160
151 // Comboboxes 161 // Comboboxes
152 QString strStart, strEnd; 162 QString strStart, strEnd;
153 int shour, ehour; 163 int shour, ehour;
154 if ( ampm ) { 164 if ( ampm ) {
155 shour = startTime.hour(); 165 shour = startTime.hour();
156 ehour = endTime.hour(); 166 ehour = endTime.hour();
157 if ( shour >= 12 ) { 167 if ( shour >= 12 ) {
158 if ( shour > 12 ) 168 if ( shour > 12 )
159 shour -= 12; 169 shour -= 12;
160 strStart.sprintf( "%d:%02d PM", shour, startTime.minute() ); 170 strStart.sprintf( "%d:%02d PM", shour, startTime.minute() );
161 } else { 171 } else {
162 if ( shour == 0 ) 172 if ( shour == 0 )
163 shour = 12; 173 shour = 12;
164 strStart.sprintf( "%d:%02d AM", shour, startTime.minute() ); 174 strStart.sprintf( "%d:%02d AM", shour, startTime.minute() );
165 } 175 }
166 if ( ehour == 24 && endTime.minute() == 0 ) { 176 if ( ehour == 24 && endTime.minute() == 0 ) {
167 strEnd = "11:59 PM"; // or "midnight" 177 strEnd = "11:59 PM"; // or "midnight"
168 } else if ( ehour >= 12 ) { 178 } else if ( ehour >= 12 ) {
169 if ( ehour > 12 ) 179 if ( ehour > 12 )
170 ehour -= 12; 180 ehour -= 12;
171 strEnd.sprintf( "%d:%02d PM", ehour, endTime.minute() ); 181 strEnd.sprintf( "%d:%02d PM", ehour, endTime.minute() );
172 } else { 182 } else {
173 if ( ehour == 0 ) 183 if ( ehour == 0 )
174 ehour = 12; 184 ehour = 12;
175 strEnd.sprintf( "%d:%02d AM", ehour, endTime.minute() ); 185 strEnd.sprintf( "%d:%02d AM", ehour, endTime.minute() );
176 } 186 }
177 } else { 187 } else {
178 strStart.sprintf( "%02d:%02d", startTime.hour(), startTime.minute() ); 188 strStart.sprintf( "%02d:%02d", startTime.hour(), startTime.minute() );
179 strEnd.sprintf( "%02d:%02d", endTime.hour(), endTime.minute() ); 189 strEnd.sprintf( "%02d:%02d", endTime.hour(), endTime.minute() );
180 } 190 }
181 191
182 if (s) comboStart->setText(strStart); 192 if (s) comboStart->setText(strStart);
183 if (e) comboEnd->setText(strEnd); 193 if (e) comboEnd->setText(strEnd);
184} 194}
185 195
186void DateEntry::init() 196void DateEntry::init()
187{ 197{
188 comboDescription->setInsertionPolicy(QComboBox::AtCurrent); 198 comboDescription->setInsertionPolicy(QComboBox::AtCurrent);
189 comboLocation->setInsertionPolicy(QComboBox::AtCurrent); 199 comboLocation->setInsertionPolicy(QComboBox::AtCurrent);
190 200
191 initCombos(); 201 initCombos();
192 QPopupMenu *m1 = new QPopupMenu( this ); 202 QPopupMenu *m1 = new QPopupMenu( this );
193 startPicker = new DateBookMonth( m1, 0, TRUE ); 203 startPicker = new DateBookMonth( m1, 0, TRUE );
194 m1->insertItem( startPicker ); 204 m1->insertItem( startPicker );
195 buttonStart->setPopup( m1 ); 205 buttonStart->setPopup( m1 );
196 connect( startPicker, SIGNAL( dateClicked(int,int,int) ), 206 connect( startPicker, SIGNAL( dateClicked(int,int,int) ),
197 this, SLOT( startDateChanged(int,int,int) ) ); 207 this, SLOT( startDateChanged(int,int,int) ) );
198 208
199 //Let start button change both start and end dates 209 //Let start button change both start and end dates
200 connect( startPicker, SIGNAL( dateClicked(int,int,int) ), 210 connect( startPicker, SIGNAL( dateClicked(int,int,int) ),
201 this, SLOT( endDateChanged(int,int,int) ) ); 211 this, SLOT( endDateChanged(int,int,int) ) );
202 connect( qApp, SIGNAL( clockChanged(bool) ), 212 connect( qApp, SIGNAL( clockChanged(bool) ),
203 this, SLOT( slotChangeClock(bool) ) ); 213 this, SLOT( slotChangeClock(bool) ) );
204 connect( qApp, SIGNAL(weekChanged(bool)), 214 connect( qApp, SIGNAL(weekChanged(bool)),
205 this, SLOT(slotChangeStartOfWeek(bool)) ); 215 this, SLOT(slotChangeStartOfWeek(bool)) );
206 216
207 connect( editNote, SIGNAL(clicked()), 217 connect( editNote, SIGNAL(clicked()),
208 this, SLOT(slotEditNote()) ); 218 this, SLOT(slotEditNote()) );
209 219
210 QPopupMenu *m2 = new QPopupMenu( this ); 220 QPopupMenu *m2 = new QPopupMenu( this );
211 endPicker = new DateBookMonth( m2, 0, TRUE ); 221 endPicker = new DateBookMonth( m2, 0, TRUE );
212 m2->insertItem( endPicker ); 222 m2->insertItem( endPicker );
213 buttonEnd->setPopup( m2 ); 223 buttonEnd->setPopup( m2 );
214 connect( endPicker, SIGNAL( dateClicked(int,int,int) ), 224 connect( endPicker, SIGNAL( dateClicked(int,int,int) ),
215 this, SLOT( endDateChanged(int,int,int) ) ); 225 this, SLOT( endDateChanged(int,int,int) ) );
216 226
217 connect(timePickerStart, SIGNAL( timeChanged(const QTime&) ), 227 connect(timePickerStart, SIGNAL( timeChanged(const QTime&) ),
218 this, SLOT( startTimePicked(const QTime&) )); 228 this, SLOT( startTimePicked(const QTime&) ));
219 // install eventFilters 229 // install eventFilters
220 comboEnd->installEventFilter( this ); 230 comboEnd->installEventFilter( this );
221 comboStart->installEventFilter( this ); 231 comboStart->installEventFilter( this );
222} 232}
223 233
224/* 234/*
225 * Destroys the object and frees any allocated resources 235 * Destroys the object and frees any allocated resources
226 */ 236 */
227DateEntry::~DateEntry() 237DateEntry::~DateEntry()
228{ 238{
229 // no need to delete child widgets, Qt does it all for us 239 // no need to delete child widgets, Qt does it all for us
230 //cout << "Del: " << comboStart->currentText() << endl; 240 //cout << "Del: " << comboStart->currentText() << endl;
231} 241}
232 242
233/* 243/*
234 * public slot 244 * public slot
235 */ 245 */
236 246
237void DateEntry::slotEditNote() { 247void DateEntry::slotEditNote() {
238 QString s; 248 QString s;
239 s = "<B>"+ TimeString::longDateString( startDate ) + "</B>"; 249 s = "<B>"+ TimeString::longDateString( startDate ) + "</B>";
240// s.sprintf("<B>%d/%d</B> ", startDate.day(), startDate.month()); 250// s.sprintf("<B>%d/%d</B> ", startDate.day(), startDate.month());
241 NoteEntry noteDlg(s+comboDescription->currentText(), noteStr, 251 NoteEntry noteDlg(s+comboDescription->currentText(), noteStr,
242 this,0,TRUE); 252 this,0,TRUE);
243 253
244 if ( QPEApplication::execDialog( &noteDlg ) ) { 254 if ( QPEApplication::execDialog( &noteDlg ) ) {
245 noteStr=noteDlg.note->text(); 255 noteStr=noteDlg.note->text();
246 } 256 }
247 257
248} 258}
249 259
250void DateEntry::endDateChanged( int y, int m, int d ) 260void DateEntry::endDateChanged( int y, int m, int d )
251{ 261{
252 endDate.setYMD( y, m, d ); 262 endDate.setYMD( y, m, d );
253 if ( endDate < startDate ) { 263 if ( endDate < startDate ) {
254 endDate = startDate; 264 endDate = startDate;
255 } 265 }
256 266
257 buttonEnd->setText( TimeString::shortDate( endDate ) ); 267 buttonEnd->setText( TimeString::shortDate( endDate ) );
258 268
259 endPicker->setDate( endDate.year(), endDate.month(), endDate.day() ); 269 endPicker->setDate( endDate.year(), endDate.month(), endDate.day() );
260} 270}
261 271
262static QTime parseTime( const QString& s, bool ampm ) 272static QTime parseTime( const QString& s, bool ampm )
263{ 273{
264 QTime tmpTime; 274 QTime tmpTime;
265 QStringList l = QStringList::split( ':', s ); 275 QStringList l = QStringList::split( ':', s );
266 int hour = l[0].toInt(); 276 int hour = l[0].toInt();
267 if ( ampm ) { 277 if ( ampm ) {
268 int i=0; 278 int i=0;
269 while (i<int(l[1].length()) && l[1][i]>='0' && l[1][i]<='9') 279 while (i<int(l[1].length()) && l[1][i]>='0' && l[1][i]<='9')
270 i++; 280 i++;
271 QString digits = l[1].left(i); 281 QString digits = l[1].left(i);
272 if ( l[1].contains( "PM", FALSE ) ) { 282 if ( l[1].contains( "PM", FALSE ) ) {
273 if ( hour != 12 ) 283 if ( hour != 12 )
274 hour += 12; 284 hour += 12;
275 } else { 285 } else {
276 if ( hour == 12 ) 286 if ( hour == 12 )
277 hour = 0; 287 hour = 0;
278 } 288 }
279 l[1] = digits; 289 l[1] = digits;
280 } 290 }
281 int minute = l[1].toInt(); 291 int minute = l[1].toInt();
282 if ( minute > 59 ) 292 if ( minute > 59 )
283 minute = 59; 293 minute = 59;
284 else if ( minute < 0 ) 294 else if ( minute < 0 )
285 minute = 0; 295 minute = 0;
286 if ( hour > 23 ) { 296 if ( hour > 23 ) {
287 hour = 23; 297 hour = 23;
288 minute = 59; 298 minute = 59;
289 } else if ( hour < 0 ) 299 } else if ( hour < 0 )
290 hour = 0; 300 hour = 0;
291 tmpTime.setHMS( hour, minute, 0 ); 301 tmpTime.setHMS( hour, minute, 0 );
292 return tmpTime; 302 return tmpTime;
293} 303}
294 304
295/* 305/*
296 * public slot 306 * public slot
297 */ 307 */
298void DateEntry::endTimeChanged( const QString &s ) 308void DateEntry::endTimeChanged( const QString &s )
299{ 309{
300 endTimeChanged( parseTime(s,ampm) ); 310 endTimeChanged( parseTime(s,ampm) );
301} 311}
302 312
303void DateEntry::endTimeChanged( const QTime &t ) { 313void DateEntry::endTimeChanged( const QTime &t ) {
304 if ( endDate > startDate || t >= startTime ) { 314 if ( endDate > startDate || t >= startTime ) {
305 endTime = t; 315 endTime = t;
306 } else { 316 } else {
307 endTime = startTime; 317 endTime = startTime;
308 //comboEnd->setCurrentItem( comboStart->currentItem() ); 318 //comboEnd->setCurrentItem( comboStart->currentItem() );
309 } 319 }
310 timePickerStart->setHour(endTime.hour()); 320 timePickerStart->setHour(endTime.hour());
311 timePickerStart->setMinute(endTime.minute()); 321 timePickerStart->setMinute(endTime.minute());
312} 322}
313 323
314/* 324/*
315 * public slot 325 * public slot
316 */ 326 */
317void DateEntry::startDateChanged( int y, int m, int d ) 327void DateEntry::startDateChanged( int y, int m, int d )
318{ 328{
319 QDate prev = startDate; 329 QDate prev = startDate;
320 startDate.setYMD( y, m, d ); 330 startDate.setYMD( y, m, d );
321 if ( rp.type == Event::Weekly && 331 if ( rp.type == Event::Weekly &&
322 startDate.dayOfWeek() != prev.dayOfWeek() ) { 332 startDate.dayOfWeek() != prev.dayOfWeek() ) {
323 // if we change the start of a weekly repeating event 333 // if we change the start of a weekly repeating event
324 // set the repeating day appropriately 334 // set the repeating day appropriately
325 char mask = 1 << (prev.dayOfWeek()-1); 335 char mask = 1 << (prev.dayOfWeek()-1);
326 rp.days &= (~mask); 336 rp.days &= (~mask);
327 rp.days |= 1 << (startDate.dayOfWeek()-1); 337 rp.days |= 1 << (startDate.dayOfWeek()-1);
328 } 338 }
329 339
330 buttonStart->setText( TimeString::shortDate( startDate ) ); 340 buttonStart->setText( TimeString::shortDate( startDate ) );
331 341
332 // our pickers must be reset... 342 // our pickers must be reset...
333 startPicker->setDate( y, m, d ); 343 startPicker->setDate( y, m, d );
334 endPicker->setDate( y, m, d ); 344 endPicker->setDate( y, m, d );
335} 345}
336 346
337/* 347/*
338 * public slot 348 * public slot
339 */ 349 */
340void DateEntry::startTimeEdited( const QString &s ) 350void DateEntry::startTimeEdited( const QString &s )
341{ 351{
342 startTimeChanged(parseTime(s,ampm)); 352 startTimeChanged(parseTime(s,ampm));
343 updateTimeEdit(false,true); 353 updateTimeEdit(false,true);
344 timePickerStart->setHour(startTime.hour()); 354 timePickerStart->setHour(startTime.hour());
345 timePickerStart->setMinute(startTime.minute()); 355 timePickerStart->setMinute(startTime.minute());
346} 356}
347 357
348void DateEntry::startTimeChanged( const QTime &t ) 358void DateEntry::startTimeChanged( const QTime &t )
349{ 359{
350 int duration=startTime.secsTo(endTime); 360 int duration=startTime.secsTo(endTime);
351 startTime = t; 361 startTime = t;
352 endTime=t.addSecs(duration); 362 endTime=t.addSecs(duration);
353} 363}
354void DateEntry::startTimePicked( const QTime &t ) { 364void DateEntry::startTimePicked( const QTime &t ) {
355 if(m_showStart ){ 365 if(m_showStart ){
356 startTimeChanged(t); 366 startTimeChanged(t);
357 updateTimeEdit(true,true); 367 updateTimeEdit(true,true);
358 }else{ 368 }else{
359 endTimeChanged(t); 369 endTimeChanged(t);
360 updateTimeEdit(false, true ); 370 updateTimeEdit(false, true );
361 } 371 }
362} 372}
363 373
364/* 374/*
365 * public slot 375 * public slot
366 */ 376 */
367void DateEntry::typeChanged( const QString &s ) 377void DateEntry::typeChanged( const QString &s )
368{ 378{
369 bool b = s != "All Day"; 379 bool b = s != "All Day";
370 buttonStart->setEnabled( b ); 380 buttonStart->setEnabled( b );
371 comboStart->setEnabled( b ); 381 comboStart->setEnabled( b );
372 comboEnd->setEnabled( b ); 382 comboEnd->setEnabled( b );
373} 383}
374 384
375void DateEntry::slotRepeat() 385void DateEntry::slotRepeat()
376{ 386{
377 // Work around for compiler Bug.. 387 // Work around for compiler Bug..
378 RepeatEntry *e; 388 RepeatEntry *e;
379 389
380 // it is better in my opinion to just grab this from the mother, 390 // it is better in my opinion to just grab this from the mother,
381 // since, this dialog doesn't need to keep track of it... 391 // since, this dialog doesn't need to keep track of it...
382 if ( rp.type != Event::NoRepeat ) 392 if ( rp.type != Event::NoRepeat )
383 e = new RepeatEntry( startWeekOnMonday, rp, startDate, this); 393 e = new RepeatEntry( startWeekOnMonday, rp, startDate, this);
384 else 394 else
385 e = new RepeatEntry( startWeekOnMonday, startDate, this ); 395 e = new RepeatEntry( startWeekOnMonday, startDate, this );
386 396
387 if ( QPEApplication::execDialog( e ) ) { 397 if ( QPEApplication::execDialog( e ) ) {
388 rp = e->repeatPattern(); 398 rp = e->repeatPattern();
389 setRepeatLabel(); 399 setRepeatLabel();
390 } 400 }
391 // deleting sounds like a nice idea... 401 // deleting sounds like a nice idea...
392 delete e; 402 delete e;
393} 403}
394 404
395void DateEntry::slotChangeStartOfWeek( bool onMonday ) 405void DateEntry::slotChangeStartOfWeek( bool onMonday )
396{ 406{
397 startWeekOnMonday = onMonday; 407 startWeekOnMonday = onMonday;
398} 408}
399 409
400Event DateEntry::event() 410Event DateEntry::event()
401{ 411{
402 Event ev; 412 Event ev;
403 Event::SoundTypeChoice st; 413 Event::SoundTypeChoice st;
404 ev.setDescription( comboDescription->currentText() ); 414 ev.setDescription( comboDescription->currentText() );
405 ev.setLocation( comboLocation->currentText() ); 415 ev.setLocation( comboLocation->currentText() );
406 ev.setCategories( comboCategory->currentCategories() ); 416 ev.setCategories( comboCategory->currentCategories() );
407 ev.setType( checkAllDay->isChecked() ? Event::AllDay : Event::Normal ); 417 ev.setType( checkAllDay->isChecked() ? Event::AllDay : Event::Normal );
408 if ( startDate > endDate ) { 418 if ( startDate > endDate ) {
409 QDate tmp = endDate; 419 QDate tmp = endDate;
410 endDate = startDate; 420 endDate = startDate;
411 startDate = tmp; 421 startDate = tmp;
412 } 422 }
413 423
414 // This is now done in the changed slots 424 // This is now done in the changed slots
415 // startTime = parseTime( comboStart->text(), ampm ); 425 // startTime = parseTime( comboStart->text(), ampm );
416 //endTime = parseTime( comboEnd->text(), ampm ); 426 //endTime = parseTime( comboEnd->text(), ampm );
417 427
418 if ( startTime > endTime && endDate == startDate ) { 428 if ( startTime > endTime && endDate == startDate ) {
419 QTime tmp = endTime; 429 QTime tmp = endTime;
420 endTime = startTime; 430 endTime = startTime;
421 startTime = tmp; 431 startTime = tmp;
422 } 432 }
423 // don't set the time if theres no need too 433 // don't set the time if theres no need too
424 if ( ev.type() == Event::AllDay ) { 434 if ( ev.type() == Event::AllDay ) {
425 startTime.setHMS( 0, 0, 0 ); 435 startTime.setHMS( 0, 0, 0 );
426 endTime.setHMS( 23, 59, 59 ); 436 endTime.setHMS( 23, 59, 59 );
427 } 437 }
428 438
429 // adjust start and end times based on timezone 439 // adjust start and end times based on timezone
430 QDateTime start( startDate, startTime ); 440 QDateTime start( startDate, startTime );
431 QDateTime end( endDate, endTime ); 441 QDateTime end( endDate, endTime );
432 time_t start_utc, end_utc; 442 time_t start_utc, end_utc;
433 443
434 //odebug << "tz: " << timezone->currentZone() << oendl; 444 //odebug << "tz: " << timezone->currentZone() << oendl;
435 445
436 // get real timezone 446 // get real timezone
437 QString realTZ; 447 QString realTZ;
438 realTZ = QString::fromLocal8Bit( getenv("TZ") ); 448 realTZ = QString::fromLocal8Bit( getenv("TZ") );
439 449
440 // set timezone 450 // set timezone
441 if ( setenv( "TZ", timezone->currentZone(), true ) != 0 ) 451 if ( setenv( "TZ", timezone->currentZone(), true ) != 0 )
442 owarn << "There was a problem setting the timezone." << oendl; 452 owarn << "There was a problem setting the timezone." << oendl;
443 453
444 // convert to UTC based on selected TZ (calling tzset internally) 454 // convert to UTC based on selected TZ (calling tzset internally)
445 start_utc = TimeConversion::toUTC( start ); 455 start_utc = TimeConversion::toUTC( start );
446 end_utc = TimeConversion::toUTC( end ); 456 end_utc = TimeConversion::toUTC( end );
447 457
448 // done playing around... put it all back 458 // done playing around... put it all back
449 unsetenv( "TZ" ); 459 unsetenv( "TZ" );
450 if ( !realTZ.isNull() ) 460 if ( !realTZ.isNull() )
451 if ( setenv( "TZ", realTZ, true ) != 0 ) 461 if ( setenv( "TZ", realTZ, true ) != 0 )
452 owarn << "There was a problem setting the timezone." << oendl; 462 owarn << "There was a problem setting the timezone." << oendl;
453 463
454 // convert UTC to local time (calling tzset internally) 464 // convert UTC to local time (calling tzset internally)
455 ev.setStart( TimeConversion::fromUTC( start_utc ) ); 465 ev.setStart( TimeConversion::fromUTC( start_utc ) );
456 ev.setEnd( TimeConversion::fromUTC( end_utc ) ); 466 ev.setEnd( TimeConversion::fromUTC( end_utc ) );
457 467
458 // we only have one type of sound at the moment... LOUD!!! 468 // we only have one type of sound at the moment... LOUD!!!
459 if ( comboSound->currentItem() != 0 ) 469 if ( comboSound->currentItem() != 0 )
460 st = Event::Loud; 470 st = Event::Loud;
461 else 471 else
462 st = Event::Silent; 472 st = Event::Silent;
463 ev.setAlarm( checkAlarm->isChecked(), spinAlarm->value(), st ); 473 ev.setAlarm( checkAlarm->isChecked(), spinAlarm->value(), st );
464 if ( rp.type != Event::NoRepeat ) 474 if ( rp.type != Event::NoRepeat )
465 ev.setRepeat( TRUE, rp ); 475 ev.setRepeat( TRUE, rp );
466 ev.setNotes( noteStr ); 476 ev.setNotes( noteStr );
467 477
468 //cout << "Start: " << comboStart->currentText() << endl; 478 //cout << "Start: " << comboStart->currentText() << endl;
469 479
470 return ev; 480 return ev;
471} 481}
472 482
473void DateEntry::setRepeatLabel() 483void DateEntry::setRepeatLabel()
474{ 484{
475 485
476 switch( rp.type ) { 486 switch( rp.type ) {
477 case Event::Daily: 487 case Event::Daily:
478 cmdRepeat->setText( tr("Daily...") ); 488 cmdRepeat->setText( tr("Daily...") );
479 break; 489 break;
480 case Event::Weekly: 490 case Event::Weekly:
481 cmdRepeat->setText( tr("Weekly...") ); 491 cmdRepeat->setText( tr("Weekly...") );
482 break; 492 break;
483 case Event::MonthlyDay: 493 case Event::MonthlyDay:
484 case Event::MonthlyDate: 494 case Event::MonthlyDate:
485 cmdRepeat->setText( tr("Monthly...") ); 495 cmdRepeat->setText( tr("Monthly...") );
486 break; 496 break;
487 case Event::Yearly: 497 case Event::Yearly:
488 cmdRepeat->setText( tr("Yearly...") ); 498 cmdRepeat->setText( tr("Yearly...") );
489 break; 499 break;
490 default: 500 default:
491 cmdRepeat->setText( tr("No Repeat...") ); 501 cmdRepeat->setText( tr("No Repeat...") );
492 } 502 }
493} 503}
494 504
495void DateEntry::setAlarmEnabled( bool alarmPreset, int presetTime, Event::SoundTypeChoice sound ) 505void DateEntry::setAlarmEnabled( bool alarmPreset, int presetTime, Event::SoundTypeChoice sound )
496{ 506{
497 checkAlarm->setChecked( alarmPreset ); 507 checkAlarm->setChecked( alarmPreset );
498 spinAlarm->setValue( presetTime ); 508 spinAlarm->setValue( presetTime );
499 if ( sound != Event::Silent ) 509 if ( sound != Event::Silent )
500 comboSound->setCurrentItem( 1 ); 510 comboSound->setCurrentItem( 1 );
501 else 511 else
502 comboSound->setCurrentItem( 0 ); 512 comboSound->setCurrentItem( 0 );
503} 513}
504 514
505void DateEntry::initCombos() 515void DateEntry::initCombos()
506{ 516{
507 /* 517 /*
508 comboStart->clear(); 518 comboStart->clear();
509 comboEnd->clear(); 519 comboEnd->clear();
510 if ( ampm ) { 520 if ( ampm ) {
511 for ( int i = 0; i < 24; i++ ) { 521 for ( int i = 0; i < 24; i++ ) {
512 if ( i == 0 ) { 522 if ( i == 0 ) {
513 comboStart->insertItem( "12:00 AM" ); 523 comboStart->insertItem( "12:00 AM" );
514 comboStart->insertItem( "12:30 AM" ); 524 comboStart->insertItem( "12:30 AM" );
515 comboEnd->insertItem( "12:00 AM" ); 525 comboEnd->insertItem( "12:00 AM" );
516 comboEnd->insertItem( "12:30 AM" ); 526 comboEnd->insertItem( "12:30 AM" );
517 } else if ( i == 12 ) { 527 } else if ( i == 12 ) {
518 comboStart->insertItem( "12:00 PM" ); 528 comboStart->insertItem( "12:00 PM" );
519 comboStart->insertItem( "12:30 PM" ); 529 comboStart->insertItem( "12:30 PM" );
520 comboEnd->insertItem( "12:00 PM" ); 530 comboEnd->insertItem( "12:00 PM" );
521 comboEnd->insertItem( "12:30 PM" ); 531 comboEnd->insertItem( "12:30 PM" );
522 } else if ( i > 12 ) { 532 } else if ( i > 12 ) {
523 comboStart->insertItem( QString::number( i - 12 ) + ":00 PM" ); 533 comboStart->insertItem( QString::number( i - 12 ) + ":00 PM" );
524 comboStart->insertItem( QString::number( i - 12 ) + ":30 PM" ); 534 comboStart->insertItem( QString::number( i - 12 ) + ":30 PM" );
525 comboEnd->insertItem( QString::number( i - 12 ) + ":00 PM" ); 535 comboEnd->insertItem( QString::number( i - 12 ) + ":00 PM" );
526 comboEnd->insertItem( QString::number( i - 12 ) + ":30 PM" ); 536 comboEnd->insertItem( QString::number( i - 12 ) + ":30 PM" );
527 } else { 537 } else {
528 comboStart->insertItem( QString::number( i) + ":00 AM" ); 538 comboStart->insertItem( QString::number( i) + ":00 AM" );
529 comboStart->insertItem( QString::number( i ) + ":30 AM" ); 539 comboStart->insertItem( QString::number( i ) + ":30 AM" );
530 comboEnd->insertItem( QString::number( i ) + ":00 AM" ); 540 comboEnd->insertItem( QString::number( i ) + ":00 AM" );
531 comboEnd->insertItem( QString::number( i ) + ":30 AM" ); 541 comboEnd->insertItem( QString::number( i ) + ":30 AM" );
532 } 542 }
533 } 543 }
534 } else { 544 } else {
535 for ( int i = 0; i < 24; i++ ) { 545 for ( int i = 0; i < 24; i++ ) {
536 if ( i < 10 ) { 546 if ( i < 10 ) {
537 comboStart->insertItem( QString("0") 547 comboStart->insertItem( QString("0")
538 + QString::number(i) + ":00" ); 548 + QString::number(i) + ":00" );
539 comboStart->insertItem( QString("0") 549 comboStart->insertItem( QString("0")
540 + QString::number(i) + ":30" ); 550 + QString::number(i) + ":30" );
541 comboEnd->insertItem( QString("0") 551 comboEnd->insertItem( QString("0")
542 + QString::number(i) + ":00" ); 552 + QString::number(i) + ":00" );
543 comboEnd->insertItem( QString("0") 553 comboEnd->insertItem( QString("0")
544 + QString::number(i) + ":30" ); 554 + QString::number(i) + ":30" );
545 } else { 555 } else {
546 comboStart->insertItem( QString::number(i) + ":00" ); 556 comboStart->insertItem( QString::number(i) + ":00" );
547 comboStart->insertItem( QString::number(i) + ":30" ); 557 comboStart->insertItem( QString::number(i) + ":30" );
548 comboEnd->insertItem( QString::number(i) + ":00" ); 558 comboEnd->insertItem( QString::number(i) + ":00" );
549 comboEnd->insertItem( QString::number(i) + ":30" ); 559 comboEnd->insertItem( QString::number(i) + ":30" );
550 } 560 }
551 } 561 }
552 } 562 }
553 */ 563 */
554} 564}
555 565
556void DateEntry::slotChangeClock( bool whichClock ) 566void DateEntry::slotChangeClock( bool whichClock )
557{ 567{
558 ampm = whichClock; 568 ampm = whichClock;
559 initCombos(); 569 initCombos();
560 setDates( QDateTime( startDate, startTime ), QDateTime( endDate, endTime ) ); 570 setDates( QDateTime( startDate, startTime ), QDateTime( endDate, endTime ) );
561} 571}
562 572
diff --git a/core/pim/datebook/dateentryimpl.h b/core/pim/datebook/dateentryimpl.h
index a3c4668..2d23ed1 100644
--- a/core/pim/datebook/dateentryimpl.h
+++ b/core/pim/datebook/dateentryimpl.h
@@ -1,79 +1,90 @@
1/********************************************************************** 1/*
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2                 This file is part of the Opie Project
3** 3
4** This file is part of Qtopia Environment. 4 Copyright (C) Opie Team <opie-devel@handhelds.org>
5** 5 =.
6** This file may be distributed and/or modified under the terms of the 6 .=l.
7** GNU General Public License version 2 as published by the Free Software 7           .>+-=
8** Foundation and appearing in the file LICENSE.GPL included in the 8 _;:,     .>    :=|. This program is free software; you can
9** packaging of this file. 9.> <`_,   >  .   <= redistribute it and/or modify it under
10** 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11.="- .-=="i,     .._ License as published by the Free Software
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13** 13     ._= =}       : or (at your option) any later version.
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14    .%`+i>       _;_.
15** 15    .i_,=:_.      -<s. This program is distributed in the hope that
16** Contact info@trolltech.com if any conditions of this licensing are 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17** not clear to you. 17 : ..    .:,     . . . without even the implied warranty of
18** 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19**********************************************************************/ 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details.
22:     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA.
29*/
30
20#ifndef DATEENTRY_H 31#ifndef DATEENTRY_H
21#define DATEENTRY_H 32#define DATEENTRY_H
22 33
23#include "dateentry.h" 34#include "dateentry.h"
24#include "noteentryimpl.h" 35#include "noteentryimpl.h"
25 36
26#include <qpe/event.h> 37#include <qpe/event.h>
27 38
28#include <qdatetime.h> 39#include <qdatetime.h>
29 40
30class DateBookMonth; 41class DateBookMonth;
31 42
32class DateEntry : public DateEntryBase 43class DateEntry : public DateEntryBase
33{ 44{
34 Q_OBJECT 45 Q_OBJECT
35 46
36public: 47public:
37 DateEntry( bool startOnMonday, const QDateTime &start, 48 DateEntry( bool startOnMonday, const QDateTime &start,
38 const QDateTime &end, bool whichClock = FALSE, 49 const QDateTime &end, bool whichClock = FALSE,
39 QWidget* parent = 0, const char* name = 0 ); 50 QWidget* parent = 0, const char* name = 0 );
40 DateEntry( bool startOnMonday, const Event &event, bool whichCLock = FALSE, 51 DateEntry( bool startOnMonday, const Event &event, bool whichCLock = FALSE,
41 QWidget* parent = 0, const char* name = 0 ); 52 QWidget* parent = 0, const char* name = 0 );
42 ~DateEntry(); 53 ~DateEntry();
43 54
44 Event event(); 55 Event event();
45 void setAlarmEnabled( bool alarmPreset, int presetTime, Event::SoundTypeChoice ); 56 void setAlarmEnabled( bool alarmPreset, int presetTime, Event::SoundTypeChoice );
46 virtual bool eventFilter( QObject *, QEvent * ); 57 virtual bool eventFilter( QObject *, QEvent * );
47public slots: 58public slots:
48 void endDateChanged( int, int, int ); 59 void endDateChanged( int, int, int );
49 void endTimeChanged( const QString & ); 60 void endTimeChanged( const QString & );
50 void endTimeChanged( const QTime & ); 61 void endTimeChanged( const QTime & );
51 void startDateChanged(int, int, int); 62 void startDateChanged(int, int, int);
52 void startTimeEdited( const QString & ); 63 void startTimeEdited( const QString & );
53 void startTimeChanged( const QTime & ); 64 void startTimeChanged( const QTime & );
54 void startTimePicked( const QTime & ); 65 void startTimePicked( const QTime & );
55 void typeChanged( const QString & ); 66 void typeChanged( const QString & );
56 void slotRepeat(); 67 void slotRepeat();
57 void slotChangeClock( bool ); 68 void slotChangeClock( bool );
58 void slotChangeStartOfWeek( bool ); 69 void slotChangeStartOfWeek( bool );
59 void slotEditNote(); 70 void slotEditNote();
60 71
61private: 72private:
62 void init(); 73 void init();
63 void initCombos(); 74 void initCombos();
64 void setDates( const QDateTime& s, const QDateTime& e ); 75 void setDates( const QDateTime& s, const QDateTime& e );
65 void setRepeatLabel(); 76 void setRepeatLabel();
66 void updateTimeEdit(bool,bool); 77 void updateTimeEdit(bool,bool);
67 78
68 DateBookMonth *startPicker, *endPicker; 79 DateBookMonth *startPicker, *endPicker;
69 QDate startDate, endDate; 80 QDate startDate, endDate;
70 QTime startTime, endTime; 81 QTime startTime, endTime;
71 Event::RepeatPattern rp; 82 Event::RepeatPattern rp;
72 bool ampm:1; 83 bool ampm:1;
73 bool startWeekOnMonday:1; 84 bool startWeekOnMonday:1;
74 bool m_showStart:1; 85 bool m_showStart:1;
75 86
76 QString noteStr; 87 QString noteStr;
77}; 88};
78 89
79#endif // DATEENTRY_H 90#endif // DATEENTRY_H
diff --git a/core/pim/datebook/main.cpp b/core/pim/datebook/main.cpp
index 3cb60af..e96e769 100644
--- a/core/pim/datebook/main.cpp
+++ b/core/pim/datebook/main.cpp
@@ -1,25 +1,35 @@
1/********************************************************************** 1/*
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2                 This file is part of the Opie Project
3** 3
4** This file is part of Qtopia Environment. 4 Copyright (C) Opie Team <opie-devel@handhelds.org>
5** 5 =.
6** This file may be distributed and/or modified under the terms of the 6 .=l.
7** GNU General Public License version 2 as published by the Free Software 7           .>+-=
8** Foundation and appearing in the file LICENSE.GPL included in the 8 _;:,     .>    :=|. This program is free software; you can
9** packaging of this file. 9.> <`_,   >  .   <= redistribute it and/or modify it under
10** 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11.="- .-=="i,     .._ License as published by the Free Software
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13** 13     ._= =}       : or (at your option) any later version.
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14    .%`+i>       _;_.
15** 15    .i_,=:_.      -<s. This program is distributed in the hope that
16** Contact info@trolltech.com if any conditions of this licensing are 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17** not clear to you. 17 : ..    .:,     . . . without even the implied warranty of
18** 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19**********************************************************************/ 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details.
22:     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA.
29*/
20 30
21#include "datebook.h" 31#include "datebook.h"
22#include <opie2/oapplicationfactory.h> 32#include <opie2/oapplicationfactory.h>
23 33
24using namespace Opie::Core; 34using namespace Opie::Core;
25OPIE_EXPORT_APP( OApplicationFactory<DateBook> ) 35OPIE_EXPORT_APP( OApplicationFactory<DateBook> )
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklst.cpp b/core/pim/datebook/modules/weeklst/datebookweeklst.cpp
index 6556373..b36bf6d 100644
--- a/core/pim/datebook/modules/weeklst/datebookweeklst.cpp
+++ b/core/pim/datebook/modules/weeklst/datebookweeklst.cpp
@@ -1,159 +1,158 @@
1#include "namespace_hack.h" 1#include "namespace_hack.h"
2#include "datebookweeklst.h" 2#include "datebookweeklst.h"
3#include "datebookweeklstheader.h" 3#include "datebookweeklstheader.h"
4#include "datebookweeklstview.h" 4#include "datebookweeklstview.h"
5#include "datebookweeklstdblview.h" 5#include "datebookweeklstdblview.h"
6 6
7#include "datebook.h" 7#include "datebook.h"
8 8
9#include <opie2/odebug.h> 9#include <opie2/odebug.h>
10 10
11#include <qpe/datebookmonth.h> 11#include <qpe/datebookmonth.h>
12#include <qpe/config.h> 12#include <qpe/config.h>
13#include <qpe/resource.h>
14 13
15#include <qlayout.h> 14#include <qlayout.h>
16#include <qtoolbutton.h> 15#include <qtoolbutton.h>
17 16
18using namespace Opie::Ui; 17using namespace Opie::Ui;
19 18
20DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDBHoliday *newDB, 19DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDBHoliday *newDB,
21 QWidget *parent, 20 QWidget *parent,
22 const char *name ) 21 const char *name )
23 : QWidget( parent, name ), 22 : QWidget( parent, name ),
24 db( newDB ), 23 db( newDB ),
25 startTime( 0 ), 24 startTime( 0 ),
26 ampm( ap ), 25 ampm( ap ),
27 bStartOnMonday(onM) 26 bStartOnMonday(onM)
28{ 27{
29 setFocusPolicy(StrongFocus); 28 setFocusPolicy(StrongFocus);
30 dateset = false; 29 dateset = false;
31 layout = new QVBoxLayout( this ); 30 layout = new QVBoxLayout( this );
32 layout->setMargin(0); 31 layout->setMargin(0);
33 32
34 header=new DateBookWeekLstHeader(onM, this); 33 header=new DateBookWeekLstHeader(onM, this);
35 layout->addWidget( header ); 34 layout->addWidget( header );
36 connect(header, SIGNAL(dateChanged(QDate&)), this, SLOT(dateChanged(QDate&))); 35 connect(header, SIGNAL(dateChanged(QDate&)), this, SLOT(dateChanged(QDate&)));
37 connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool))); 36 connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool)));
38 37
39 scroll=new QScrollView(this); 38 scroll=new QScrollView(this);
40 scroll->setResizePolicy(QScrollView::AutoOneFit); 39 scroll->setResizePolicy(QScrollView::AutoOneFit);
41 layout->addWidget(scroll); 40 layout->addWidget(scroll);
42 41
43 m_CurrentView=NULL; 42 m_CurrentView=NULL;
44 Config config("DateBook"); 43 Config config("DateBook");
45 config.setGroup("Main"); 44 config.setGroup("Main");
46 dbl=config.readBoolEntry("weeklst_dbl", false); 45 dbl=config.readBoolEntry("weeklst_dbl", false);
47 header->dbl->setOn(dbl); 46 header->dbl->setOn(dbl);
48} 47}
49 48
50DateBookWeekLst::~DateBookWeekLst(){ 49DateBookWeekLst::~DateBookWeekLst(){
51 Config config("DateBook"); 50 Config config("DateBook");
52 config.setGroup("Main"); 51 config.setGroup("Main");
53 config.writeEntry("weeklst_dbl", dbl); 52 config.writeEntry("weeklst_dbl", dbl);
54} 53}
55 54
56void DateBookWeekLst::setDate(const QDate &d) { 55void DateBookWeekLst::setDate(const QDate &d) {
57 bdate=d; 56 bdate=d;
58 header->setDate(d); 57 header->setDate(d);
59} 58}
60 59
61void DateBookWeekLst::setDbl(bool on) { 60void DateBookWeekLst::setDbl(bool on) {
62 dbl=on; 61 dbl=on;
63 bool displayed = false; 62 bool displayed = false;
64 if (m_CurrentView) { 63 if (m_CurrentView) {
65 displayed = m_CurrentView->toggleDoubleView(on); 64 displayed = m_CurrentView->toggleDoubleView(on);
66 } 65 }
67 if (!displayed||dbl) { 66 if (!displayed||dbl) {
68 getEvents(); 67 getEvents();
69 } 68 }
70} 69}
71 70
72void DateBookWeekLst::redraw() {getEvents();} 71void DateBookWeekLst::redraw() {getEvents();}
73 72
74QDate DateBookWeekLst::date() { 73QDate DateBookWeekLst::date() {
75 return bdate; 74 return bdate;
76} 75}
77 76
78// return the date at the beginning of the week... 77// return the date at the beginning of the week...
79// copied from DateBookWeek 78// copied from DateBookWeek
80QDate DateBookWeekLst::weekDate() const 79QDate DateBookWeekLst::weekDate() const
81{ 80{
82 QDate d=bdate; 81 QDate d=bdate;
83 82
84 // Calculate offset to first day of week. 83 // Calculate offset to first day of week.
85 int dayoffset=d.dayOfWeek(); 84 int dayoffset=d.dayOfWeek();
86 if(bStartOnMonday) dayoffset--; 85 if(bStartOnMonday) dayoffset--;
87 else if( dayoffset == 7 ) 86 else if( dayoffset == 7 )
88 dayoffset = 0; 87 dayoffset = 0;
89 88
90 return d.addDays(-dayoffset); 89 return d.addDays(-dayoffset);
91} 90}
92 91
93void DateBookWeekLst::getEvents() { 92void DateBookWeekLst::getEvents() {
94 if (!dateset) return; 93 if (!dateset) return;
95 QDate start = weekDate(); //date(); 94 QDate start = weekDate(); //date();
96 QDate stop = start.addDays(6); 95 QDate stop = start.addDays(6);
97 QDate start2; 96 QDate start2;
98 97
99 98
100 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); 99 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop);
101 QValueList<EffectiveEvent> el2; 100 QValueList<EffectiveEvent> el2;
102 101
103 if (dbl) { 102 if (dbl) {
104 start2 = start.addDays(7); 103 start2 = start.addDays(7);
105 stop = start2.addDays(6); 104 stop = start2.addDays(6);
106 el2 = db->getEffectiveEvents(start2, stop); 105 el2 = db->getEffectiveEvents(start2, stop);
107 } 106 }
108 if (!m_CurrentView) { 107 if (!m_CurrentView) {
109 if (dbl) { 108 if (dbl) {
110 m_CurrentView=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll); 109 m_CurrentView=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll);
111 } else { 110 } else {
112 m_CurrentView=new DateBookWeekLstDblView(el,start,bStartOnMonday,scroll); 111 m_CurrentView=new DateBookWeekLstDblView(el,start,bStartOnMonday,scroll);
113 } 112 }
114 m_CurrentView->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); 113 m_CurrentView->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
115 connect (m_CurrentView, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); 114 connect (m_CurrentView, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
116 connect (m_CurrentView, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); 115 connect (m_CurrentView, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
117 connect (m_CurrentView, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); 116 connect (m_CurrentView, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
118 connect (m_CurrentView, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); 117 connect (m_CurrentView, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
119 connect (m_CurrentView, SIGNAL(redraw()), this, SLOT(redraw())); 118 connect (m_CurrentView, SIGNAL(redraw()), this, SLOT(redraw()));
120 connect (m_CurrentView, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 119 connect (m_CurrentView, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
121 connect (m_CurrentView, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), 120 connect (m_CurrentView, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
122 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); 121 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
123 scroll->addChild(m_CurrentView); 122 scroll->addChild(m_CurrentView);
124 } else { 123 } else {
125 if (dbl) { 124 if (dbl) {
126 m_CurrentView->setEvents(el,el2,start,bStartOnMonday); 125 m_CurrentView->setEvents(el,el2,start,bStartOnMonday);
127 } else { 126 } else {
128 m_CurrentView->setEvents(el,start,bStartOnMonday); 127 m_CurrentView->setEvents(el,start,bStartOnMonday);
129 } 128 }
130 } 129 }
131 scroll->updateScrollBars(); 130 scroll->updateScrollBars();
132} 131}
133 132
134void DateBookWeekLst::dateChanged(QDate &newdate) { 133void DateBookWeekLst::dateChanged(QDate &newdate) {
135 dateset = true; 134 dateset = true;
136 bdate=newdate; 135 bdate=newdate;
137 odebug << "Date changed " << oendl; 136 odebug << "Date changed " << oendl;
138 getEvents(); 137 getEvents();
139} 138}
140 139
141void DateBookWeekLst::keyPressEvent(QKeyEvent *e) 140void DateBookWeekLst::keyPressEvent(QKeyEvent *e)
142{ 141{
143 switch(e->key()) { 142 switch(e->key()) {
144 case Key_Up: 143 case Key_Up:
145 scroll->scrollBy(0, -20); 144 scroll->scrollBy(0, -20);
146 break; 145 break;
147 case Key_Down: 146 case Key_Down:
148 scroll->scrollBy(0, 20); 147 scroll->scrollBy(0, 20);
149 break; 148 break;
150 case Key_Left: 149 case Key_Left:
151 header->prevWeek(); 150 header->prevWeek();
152 break; 151 break;
153 case Key_Right: 152 case Key_Right:
154 header->nextWeek(); 153 header->nextWeek();
155 break; 154 break;
156 default: 155 default:
157 e->ignore(); 156 e->ignore();
158 } 157 }
159} 158}
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstheader.cpp b/core/pim/datebook/modules/weeklst/datebookweeklstheader.cpp
index 81e0c31..2da9c22 100644
--- a/core/pim/datebook/modules/weeklst/datebookweeklstheader.cpp
+++ b/core/pim/datebook/modules/weeklst/datebookweeklstheader.cpp
@@ -1,96 +1,97 @@
1#include "datebookweeklstheader.h" 1#include "datebookweeklstheader.h"
2 2
3#include <qpe/resource.h> 3#include <opie2/oresource.h>
4
4#include <qpe/datebookmonth.h> 5#include <qpe/datebookmonth.h>
5 6
6#include <qtoolbutton.h> 7#include <qtoolbutton.h>
7#include <qlayout.h> 8#include <qlayout.h>
8 9
9/* implenented in datebookweek.cpp - HELL */ 10/* implenented in datebookweek.cpp - HELL */
10bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false); 11bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false);
11 12
12DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const char* name, WFlags fl) 13DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const char* name, WFlags fl)
13 : DateBookWeekLstHeaderBase(parent, name, fl) 14 : DateBookWeekLstHeaderBase(parent, name, fl)
14{ 15{
15 setBackgroundMode( PaletteButton ); 16 setBackgroundMode( PaletteButton );
16 labelDate->setBackgroundMode( PaletteButton ); 17 labelDate->setBackgroundMode( PaletteButton );
17 forwardweek->setBackgroundMode( PaletteButton ); 18 forwardweek->setBackgroundMode( PaletteButton );
18 forwardweek->setPixmap( Resource::loadPixmap("forward") ); 19 forwardweek->setPixmap( Opie::Core::OResource::loadPixmap( "forward", Opie::Core::OResource::SmallIcon ) );
19 forwardmonth->setBackgroundMode( PaletteButton ); 20 forwardmonth->setBackgroundMode( PaletteButton );
20 forwardmonth->setPixmap( Resource::loadPixmap("fastforward") ); 21 forwardmonth->setPixmap( Opie::Core::OResource::loadPixmap( "fastforward", Opie::Core::OResource::SmallIcon ) );
21 backweek->setBackgroundMode( PaletteButton ); 22 backweek->setBackgroundMode( PaletteButton );
22 backweek->setPixmap( Resource::loadPixmap("back") ); 23 backweek->setPixmap( Opie::Core::OResource::loadPixmap( "back", Opie::Core::OResource::SmallIcon ) );
23 backmonth->setBackgroundMode( PaletteButton ); 24 backmonth->setBackgroundMode( PaletteButton );
24 backmonth->setPixmap( Resource::loadPixmap("fastback") ); 25 backmonth->setPixmap( Opie::Core::OResource::loadPixmap( "fastback", Opie::Core::OResource::SmallIcon ) );
25 DateBookWeekLstHeaderBaseLayout->setSpacing(0); 26 DateBookWeekLstHeaderBaseLayout->setSpacing(0);
26 DateBookWeekLstHeaderBaseLayout->setMargin(0); 27 DateBookWeekLstHeaderBaseLayout->setMargin(0);
27 //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding)); 28 //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding));
28 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); 29 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
29 30
30 connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth())); 31 connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth()));
31 connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek())); 32 connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek()));
32 connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek())); 33 connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek()));
33 connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth())); 34 connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth()));
34 connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate())); 35 connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate()));
35 connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool))); 36 connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool)));
36 bStartOnMonday=onM; 37 bStartOnMonday=onM;
37} 38}
38DateBookWeekLstHeader::~DateBookWeekLstHeader(){} 39DateBookWeekLstHeader::~DateBookWeekLstHeader(){}
39 40
40void DateBookWeekLstHeader::setDate(const QDate &d) { 41void DateBookWeekLstHeader::setDate(const QDate &d) {
41 int year,week,dayofweek; 42 int year,week,dayofweek;
42 date=d; 43 date=d;
43 dayofweek=d.dayOfWeek(); 44 dayofweek=d.dayOfWeek();
44 if(bStartOnMonday) 45 if(bStartOnMonday)
45 dayofweek--; 46 dayofweek--;
46 else if( dayofweek == 7 ) 47 else if( dayofweek == 7 )
47 /* we already have the right day -7 would lead to the same week */ 48 /* we already have the right day -7 would lead to the same week */
48 dayofweek = 0; 49 dayofweek = 0;
49 50
50 date=date.addDays(-dayofweek); 51 date=date.addDays(-dayofweek);
51 52
52 calcWeek(date,week,year,bStartOnMonday); 53 calcWeek(date,week,year,bStartOnMonday);
53 QDate start=date; 54 QDate start=date;
54 QDate stop=start.addDays(6); 55 QDate stop=start.addDays(6);
55 labelDate->setText( QString::number(start.day()) + "." + 56 labelDate->setText( QString::number(start.day()) + "." +
56 Calendar::nameOfMonth( start.month() ) + "-" + 57 Calendar::nameOfMonth( start.month() ) + "-" +
57 QString::number(stop.day()) + "." + 58 QString::number(stop.day()) + "." +
58 Calendar::nameOfMonth( stop.month()) +" ("+ 59 Calendar::nameOfMonth( stop.month()) +" ("+
59 tr("w")+":"+QString::number( week ) +")"); 60 tr("w")+":"+QString::number( week ) +")");
60 date = d; // bugfix: 0001126 - date has to be the selected date, not monday! 61 date = d; // bugfix: 0001126 - date has to be the selected date, not monday!
61 emit dateChanged(date); 62 emit dateChanged(date);
62} 63}
63 64
64void DateBookWeekLstHeader::pickDate() { 65void DateBookWeekLstHeader::pickDate() {
65 static QPopupMenu *m1 = 0; 66 static QPopupMenu *m1 = 0;
66 static DateBookMonth *picker = 0; 67 static DateBookMonth *picker = 0;
67 if ( !m1 ) { 68 if ( !m1 ) {
68 m1 = new QPopupMenu( this ); 69 m1 = new QPopupMenu( this );
69 picker = new DateBookMonth( m1, 0, TRUE ); 70 picker = new DateBookMonth( m1, 0, TRUE );
70 m1->insertItem( picker ); 71 m1->insertItem( picker );
71 connect( picker, SIGNAL( dateClicked(int,int,int) ),this, SLOT( setDate(int,int,int) ) ); 72 connect( picker, SIGNAL( dateClicked(int,int,int) ),this, SLOT( setDate(int,int,int) ) );
72 //connect( m1, SIGNAL( aboutToHide() ), 73 //connect( m1, SIGNAL( aboutToHide() ),
73 //this, SLOT( gotHide() ) ); 74 //this, SLOT( gotHide() ) );
74 } 75 }
75 picker->setDate( date.year(), date.month(), date.day() ); 76 picker->setDate( date.year(), date.month(), date.day() );
76 m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); 77 m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height())));
77 picker->setFocus(); 78 picker->setFocus();
78} 79}
79void DateBookWeekLstHeader::setDate(int y, int m, int d) { 80void DateBookWeekLstHeader::setDate(int y, int m, int d) {
80 setDate(QDate(y,m,d)); 81 setDate(QDate(y,m,d));
81} 82}
82 83
83void DateBookWeekLstHeader::nextWeek() { 84void DateBookWeekLstHeader::nextWeek() {
84 setDate(date.addDays(7)); 85 setDate(date.addDays(7));
85} 86}
86void DateBookWeekLstHeader::prevWeek() { 87void DateBookWeekLstHeader::prevWeek() {
87 setDate(date.addDays(-7)); 88 setDate(date.addDays(-7));
88} 89}
89void DateBookWeekLstHeader::nextMonth() 90void DateBookWeekLstHeader::nextMonth()
90{ 91{
91 setDate(date.addDays(28)); 92 setDate(date.addDays(28));
92} 93}
93void DateBookWeekLstHeader::prevMonth() 94void DateBookWeekLstHeader::prevMonth()
94{ 95{
95 setDate(date.addDays(-28)); 96 setDate(date.addDays(-28));
96} 97}
diff --git a/core/pim/datebook/namespace_hack.h b/core/pim/datebook/namespace_hack.h
index c15b5ed..2ed674c 100644
--- a/core/pim/datebook/namespace_hack.h
+++ b/core/pim/datebook/namespace_hack.h
@@ -1,20 +1,50 @@
1/*
2                 This file is part of the Opie Project
3
4 Copyright (C) Opie Team <opie-devel@handhelds.org>
5 =.
6 .=l.
7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17 : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details.
22:     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA.
29*/
30
1#ifndef NAME_SPACE_HACK_H 31#ifndef NAME_SPACE_HACK_H
2#define NAME_SPACE_HACK_H 32#define NAME_SPACE_HACK_H
3 33
4#include <opie2/otimepicker.h> 34#include <opie2/otimepicker.h>
5#include <opie2/oclickablelabel.h> 35#include <opie2/oclickablelabel.h>
6 36
7class TimePicker : public Opie::Ui::OTimePicker { 37class TimePicker : public Opie::Ui::OTimePicker {
8public: 38public:
9 TimePicker( QWidget* p = 0, const char* name = 0, WFlags fl = 0 ) 39 TimePicker( QWidget* p = 0, const char* name = 0, WFlags fl = 0 )
10 : Opie::Ui::OTimePicker(p,name,fl){} 40 : Opie::Ui::OTimePicker(p,name,fl){}
11 41
12}; 42};
13class ClickableLabel : public Opie::Ui::OClickableLabel { 43class ClickableLabel : public Opie::Ui::OClickableLabel {
14public: 44public:
15 ClickableLabel(QWidget *p=0,const char* name=0, WFlags fl = 0 ) 45 ClickableLabel(QWidget *p=0,const char* name=0, WFlags fl = 0 )
16 : Opie::Ui::OClickableLabel(p,name,fl){} 46 : Opie::Ui::OClickableLabel(p,name,fl){}
17}; 47};
18 48
19 49
20#endif 50#endif
diff --git a/core/pim/datebook/noteentryimpl.cpp b/core/pim/datebook/noteentryimpl.cpp
index 14fe98e..f967ab2 100644
--- a/core/pim/datebook/noteentryimpl.cpp
+++ b/core/pim/datebook/noteentryimpl.cpp
@@ -1,15 +1,45 @@
1/*
2                 This file is part of the Opie Project
3
4 Copyright (C) Opie Team <opie-devel@handhelds.org>
5 =.
6 .=l.
7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17 : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details.
22:     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA.
29*/
30
1#include "noteentryimpl.h" 31#include "noteentryimpl.h"
2#include "qlabel.h" 32#include "qlabel.h"
3#include "onoteedit.h" 33#include "onoteedit.h"
4 34
5NoteEntry::NoteEntry(const QString &title, const QString &noteStr, 35NoteEntry::NoteEntry(const QString &title, const QString &noteStr,
6 QWidget* parent, const char* name, bool modal, 36 QWidget* parent, const char* name, bool modal,
7 WFlags fl) : 37 WFlags fl) :
8 NoteEntryBase(parent, name, modal, fl) { 38 NoteEntryBase(parent, name, modal, fl) {
9 39
10 40
11 eventLabel->setText(title); 41 eventLabel->setText(title);
12 note->setText(noteStr); 42 note->setText(noteStr);
13 int l=note->length(); 43 int l=note->length();
14 note->setCursorPosition(l,l,false); 44 note->setCursorPosition(l,l,false);
15} 45}
diff --git a/core/pim/datebook/noteentryimpl.h b/core/pim/datebook/noteentryimpl.h
index f3adfa6..86ea0ee 100644
--- a/core/pim/datebook/noteentryimpl.h
+++ b/core/pim/datebook/noteentryimpl.h
@@ -1,18 +1,48 @@
1/*
2                 This file is part of the Opie Project
3
4 Copyright (C) Opie Team <opie-devel@handhelds.org>
5 =.
6 .=l.
7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17 : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details.
22:     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA.
29*/
30
1#ifndef noteentryimpl_h 31#ifndef noteentryimpl_h
2#define noteentryimpl_h 32#define noteentryimpl_h
3 33
4#include "noteentry.h" 34#include "noteentry.h"
5 35
6class QString; 36class QString;
7 37
8class NoteEntry : public NoteEntryBase 38class NoteEntry : public NoteEntryBase
9{ 39{
10 Q_OBJECT 40 Q_OBJECT
11 41
12public: 42public:
13 NoteEntry(const QString &title, const QString &noteStr, 43 NoteEntry(const QString &title, const QString &noteStr,
14 QWidget* parent = 0, const char* name = 0, 44 QWidget* parent = 0, const char* name = 0,
15 bool modal=TRUE, WFlags fl=0); 45 bool modal=TRUE, WFlags fl=0);
16}; 46};
17 47
18#endif 48#endif
diff --git a/core/pim/datebook/onoteedit.cpp b/core/pim/datebook/onoteedit.cpp
index d66ad86..a5f468d 100644
--- a/core/pim/datebook/onoteedit.cpp
+++ b/core/pim/datebook/onoteedit.cpp
@@ -1,19 +1,49 @@
1/*
2                 This file is part of the Opie Project
3
4 Copyright (C) Opie Team <opie-devel@handhelds.org>
5 =.
6 .=l.
7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17 : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details.
22:     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA.
29*/
30
1#include "onoteedit.h" 31#include "onoteedit.h"
2 32
3ONoteEdit::ONoteEdit (QWidget * parent, const char * name) : 33ONoteEdit::ONoteEdit (QWidget * parent, const char * name) :
4 QMultiLineEdit(parent,name) { 34 QMultiLineEdit(parent,name) {
5 setDefaultTabStop(2); 35 setDefaultTabStop(2);
6 setWordWrap(WidgetWidth); 36 setWordWrap(WidgetWidth);
7} 37}
8 38
9// Copy indentation from previous line 39// Copy indentation from previous line
10void ONoteEdit::newLine() { 40void ONoteEdit::newLine() {
11 int l,c; 41 int l,c;
12 getCursorPosition(&l,&c); 42 getCursorPosition(&l,&c);
13 QString s=textLine(l); 43 QString s=textLine(l);
14 44
15 insert("\n"); 45 insert("\n");
16 46
17 int i=0; 47 int i=0;
18 while (s[i]==' ' || s[i]=='\t') insert(QString(s[i])), i++; 48 while (s[i]==' ' || s[i]=='\t') insert(QString(s[i])), i++;
19} 49}
diff --git a/core/pim/datebook/onoteedit.h b/core/pim/datebook/onoteedit.h
index 2f71d0d..390b837 100644
--- a/core/pim/datebook/onoteedit.h
+++ b/core/pim/datebook/onoteedit.h
@@ -1,19 +1,49 @@
1/*
2                 This file is part of the Opie Project
3
4 Copyright (C) Opie Team <opie-devel@handhelds.org>
5 =.
6 .=l.
7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17 : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details.
22:     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA.
29*/
30
1#ifndef ONOTEEDIT_H 31#ifndef ONOTEEDIT_H
2#define ONOTEEDIT_H 32#define ONOTEEDIT_H
3 33
4#include <qmultilineedit.h> 34#include <qmultilineedit.h>
5 35
6class ONoteEdit: public QMultiLineEdit { 36class ONoteEdit: public QMultiLineEdit {
7 37
8 Q_OBJECT 38 Q_OBJECT
9 39
10 public: 40 public:
11 41
12 ONoteEdit (QWidget * parent=0, const char * name=0); 42 ONoteEdit (QWidget * parent=0, const char * name=0);
13 43
14 protected: 44 protected:
15 45
16 virtual void newLine (); 46 virtual void newLine ();
17}; 47};
18 48
19#endif 49#endif
diff --git a/core/pim/datebook/repeatentry.cpp b/core/pim/datebook/repeatentry.cpp
index 04c3cf3..30e296c 100644
--- a/core/pim/datebook/repeatentry.cpp
+++ b/core/pim/datebook/repeatentry.cpp
@@ -1,613 +1,623 @@
1/********************************************************************** 1/*
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2                 This file is part of the Opie Project
3** 3
4** This file is part of Qtopia Environment. 4 Copyright (C) Opie Team <opie-devel@handhelds.org>
5** 5 =.
6** This file may be distributed and/or modified under the terms of the 6 .=l.
7** GNU General Public License version 2 as published by the Free Software 7           .>+-=
8** Foundation and appearing in the file LICENSE.GPL included in the 8 _;:,     .>    :=|. This program is free software; you can
9** packaging of this file. 9.> <`_,   >  .   <= redistribute it and/or modify it under
10** 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11.="- .-=="i,     .._ License as published by the Free Software
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13** 13     ._= =}       : or (at your option) any later version.
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14    .%`+i>       _;_.
15** 15    .i_,=:_.      -<s. This program is distributed in the hope that
16** Contact info@trolltech.com if any conditions of this licensing are 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17** not clear to you. 17 : ..    .:,     . . . without even the implied warranty of
18** 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19**********************************************************************/ 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details.
22:     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA.
29*/
20 30
21#include "repeatentry.h" 31#include "repeatentry.h"
22 32
23#include <qpe/datebookmonth.h> 33#include <qpe/datebookmonth.h>
24#include <qpe/qpeapplication.h> 34#include <qpe/qpeapplication.h>
25 35
26#include <qlabel.h> 36#include <qlabel.h>
27#include <qspinbox.h> 37#include <qspinbox.h>
28 38
29#include <time.h> 39#include <time.h>
30 40
31// Global Templates for use in setting up the repeat label... 41// Global Templates for use in setting up the repeat label...
32// the problem is these strings get initialized before QPEApplication can install the translator -zecke 42// the problem is these strings get initialized before QPEApplication can install the translator -zecke
33namespace { 43namespace {
34QString strDayTemplate; 44QString strDayTemplate;
35QString strYearTemplate; 45QString strYearTemplate;
36QString strMonthDateTemplate; 46QString strMonthDateTemplate;
37QString strMonthDayTemplate; 47QString strMonthDayTemplate;
38QString strWeekTemplate; 48QString strWeekTemplate;
39QString dayLabel[7]; 49QString dayLabel[7];
40} 50}
41 51
42/* 52/*
43 * static linkage to not polute the symbol table... 53 * static linkage to not polute the symbol table...
44 * The problem is that const and static linkage are resolved prior to installing a translator 54 * The problem is that const and static linkage are resolved prior to installing a translator
45 * leading to that the above strings are translted but to the original we delay the init of these strings... 55 * leading to that the above strings are translted but to the original we delay the init of these strings...
46 * -zecke 56 * -zecke
47 */ 57 */
48static void fillStrings() { 58static void fillStrings() {
49 strDayTemplate = QObject::tr("Every"); 59 strDayTemplate = QObject::tr("Every");
50 strYearTemplate = QObject::tr("%1 %2 every "); 60 strYearTemplate = QObject::tr("%1 %2 every ");
51 strMonthDateTemplate = QObject::tr("The %1 every "); 61 strMonthDateTemplate = QObject::tr("The %1 every ");
52 strMonthDayTemplate = QObject::tr("The %1 %1 of every"); 62 strMonthDayTemplate = QObject::tr("The %1 %1 of every");
53 strWeekTemplate = QObject::tr("Every "); 63 strWeekTemplate = QObject::tr("Every ");
54 dayLabel[0] = QObject::tr("Monday"); 64 dayLabel[0] = QObject::tr("Monday");
55 dayLabel[1] = QObject::tr("Tuesday"); 65 dayLabel[1] = QObject::tr("Tuesday");
56 dayLabel[2] = QObject::tr("Wednesday"); 66 dayLabel[2] = QObject::tr("Wednesday");
57 dayLabel[3] = QObject::tr("Thursday"); 67 dayLabel[3] = QObject::tr("Thursday");
58 dayLabel[4] = QObject::tr("Friday"); 68 dayLabel[4] = QObject::tr("Friday");
59 dayLabel[5] = QObject::tr("Saturday"); 69 dayLabel[5] = QObject::tr("Saturday");
60 dayLabel[6] = QObject::tr("Sunday"); 70 dayLabel[6] = QObject::tr("Sunday");
61} 71}
62 72
63 static QString numberPlacing( int x );// return the proper word format for 73 static QString numberPlacing( int x );// return the proper word format for
64 // x (1st, 2nd, etc) 74 // x (1st, 2nd, etc)
65static int week( const QDate &dt ); // what week in the month is dt? 75static int week( const QDate &dt ); // what week in the month is dt?
66 76
67RepeatEntry::RepeatEntry( bool startOnMonday, 77RepeatEntry::RepeatEntry( bool startOnMonday,
68 const QDate &newStart, QWidget *parent, 78 const QDate &newStart, QWidget *parent,
69 const char *name, bool modal, WFlags fl ) 79 const char *name, bool modal, WFlags fl )
70 : RepeatEntryBase( parent, name, modal, fl ), 80 : RepeatEntryBase( parent, name, modal, fl ),
71 start( newStart ), 81 start( newStart ),
72 currInterval( NONE ), 82 currInterval( NONE ),
73 startWeekOnMonday( startOnMonday ) 83 startWeekOnMonday( startOnMonday )
74{ 84{
75 if (strDayTemplate.isEmpty() ) 85 if (strDayTemplate.isEmpty() )
76 fillStrings(); 86 fillStrings();
77 87
78 init(); 88 init();
79 fraType->setButton( currInterval ); 89 fraType->setButton( currInterval );
80 chkNoEnd->setChecked( TRUE ); 90 chkNoEnd->setChecked( TRUE );
81 setupNone(); 91 setupNone();
82} 92}
83 93
84RepeatEntry::RepeatEntry( bool startOnMonday, const Event::RepeatPattern &rp, 94RepeatEntry::RepeatEntry( bool startOnMonday, const Event::RepeatPattern &rp,
85 const QDate &startDate, 95 const QDate &startDate,
86 QWidget *parent, const char *name, bool modal, 96 QWidget *parent, const char *name, bool modal,
87 WFlags fl ) 97 WFlags fl )
88 : RepeatEntryBase( parent, name, modal, fl ), 98 : RepeatEntryBase( parent, name, modal, fl ),
89 start( startDate ), 99 start( startDate ),
90 end( rp.endDate() ), 100 end( rp.endDate() ),
91 startWeekOnMonday( startOnMonday ) 101 startWeekOnMonday( startOnMonday )
92{ 102{
93 if (strDayTemplate.isEmpty() ) 103 if (strDayTemplate.isEmpty() )
94 fillStrings(); 104 fillStrings();
95 // do some stuff with the repeat pattern 105 // do some stuff with the repeat pattern
96 init(); 106 init();
97 switch ( rp.type ) { 107 switch ( rp.type ) {
98 default: 108 default:
99 case Event::NoRepeat: 109 case Event::NoRepeat:
100 currInterval = NONE; 110 currInterval = NONE;
101 setupNone(); 111 setupNone();
102 break; 112 break;
103 case Event::Daily: 113 case Event::Daily:
104 currInterval = DAY; 114 currInterval = DAY;
105 setupDaily(); 115 setupDaily();
106 break; 116 break;
107 case Event::Weekly: 117 case Event::Weekly:
108 currInterval = WEEK; 118 currInterval = WEEK;
109 setupWeekly(); 119 setupWeekly();
110 int day, buttons; 120 int day, buttons;
111 for ( day = 0x01, buttons = 0; buttons < 7; 121 for ( day = 0x01, buttons = 0; buttons < 7;
112 day = day << 1, buttons++ ) { 122 day = day << 1, buttons++ ) {
113 if ( rp.days & day ) { 123 if ( rp.days & day ) {
114 if ( startWeekOnMonday ) 124 if ( startWeekOnMonday )
115 fraExtra->setButton( buttons ); 125 fraExtra->setButton( buttons );
116 else { 126 else {
117 if ( buttons == 7 ) 127 if ( buttons == 7 )
118 fraExtra->setButton( 0 ); 128 fraExtra->setButton( 0 );
119 else 129 else
120 fraExtra->setButton( buttons + 1 ); 130 fraExtra->setButton( buttons + 1 );
121 } 131 }
122 } 132 }
123 } 133 }
124 slotWeekLabel(); 134 slotWeekLabel();
125 break; 135 break;
126 case Event::MonthlyDay: 136 case Event::MonthlyDay:
127 currInterval = MONTH; 137 currInterval = MONTH;
128 setupMonthly(); 138 setupMonthly();
129 fraExtra->setButton( 0 ); 139 fraExtra->setButton( 0 );
130 slotMonthLabel( 0 ); 140 slotMonthLabel( 0 );
131 break; 141 break;
132 case Event::MonthlyDate: 142 case Event::MonthlyDate:
133 currInterval = MONTH; 143 currInterval = MONTH;
134 setupMonthly(); 144 setupMonthly();
135 fraExtra->setButton( 1 ); 145 fraExtra->setButton( 1 );
136 slotMonthLabel( 1 ); 146 slotMonthLabel( 1 );
137 break; 147 break;
138 case Event::Yearly: 148 case Event::Yearly:
139 currInterval = YEAR; 149 currInterval = YEAR;
140 setupYearly(); 150 setupYearly();
141 break; 151 break;
142 } 152 }
143 fraType->setButton( currInterval ); 153 fraType->setButton( currInterval );
144 spinFreq->setValue( rp.frequency ); 154 spinFreq->setValue( rp.frequency );
145 if ( !rp.hasEndDate ) { 155 if ( !rp.hasEndDate ) {
146 cmdEnd->setText( RepeatEntryBase::tr("No End Date") ); 156 cmdEnd->setText( RepeatEntryBase::tr("No End Date") );
147 chkNoEnd->setChecked( TRUE ); 157 chkNoEnd->setChecked( TRUE );
148 } else 158 } else
149 cmdEnd->setText( TimeString::shortDate( end ) ); 159 cmdEnd->setText( TimeString::shortDate( end ) );
150} 160}
151 161
152RepeatEntry::~RepeatEntry() 162RepeatEntry::~RepeatEntry()
153{ 163{
154} 164}
155 165
156Event::RepeatPattern RepeatEntry::repeatPattern() 166Event::RepeatPattern RepeatEntry::repeatPattern()
157{ 167{
158 QListIterator<QToolButton> it( listRTypeButtons ); 168 QListIterator<QToolButton> it( listRTypeButtons );
159 QListIterator<QToolButton> itExtra( listExtra ); 169 QListIterator<QToolButton> itExtra( listExtra );
160 Event::RepeatPattern rpTmp; 170 Event::RepeatPattern rpTmp;
161 int i; 171 int i;
162 for ( i = 0; *it; ++it, i++ ) { 172 for ( i = 0; *it; ++it, i++ ) {
163 if ( (*it)->isOn() ) { 173 if ( (*it)->isOn() ) {
164 switch ( i ) { 174 switch ( i ) {
165 case NONE: 175 case NONE:
166 rpTmp.type = Event::NoRepeat; 176 rpTmp.type = Event::NoRepeat;
167 break; 177 break;
168 case DAY: 178 case DAY:
169 rpTmp.type = Event::Daily; 179 rpTmp.type = Event::Daily;
170 break; 180 break;
171 case WEEK: 181 case WEEK:
172 rpTmp.type = Event::Weekly; 182 rpTmp.type = Event::Weekly;
173 rpTmp.days = 0; 183 rpTmp.days = 0;
174 int day; 184 int day;
175 for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) { 185 for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) {
176 if ( (*itExtra)->isOn() ) { 186 if ( (*itExtra)->isOn() ) {
177 if ( startWeekOnMonday ) 187 if ( startWeekOnMonday )
178 rpTmp.days |= day; 188 rpTmp.days |= day;
179 else { 189 else {
180 if ( day == 1 ) 190 if ( day == 1 )
181 rpTmp.days |= Event::SUN; 191 rpTmp.days |= Event::SUN;
182 else 192 else
183 rpTmp.days |= day >> 1; 193 rpTmp.days |= day >> 1;
184 } 194 }
185 } 195 }
186 } 196 }
187 break; 197 break;
188 case MONTH: 198 case MONTH:
189 if ( cmdExtra1->isOn() ) 199 if ( cmdExtra1->isOn() )
190 rpTmp.type = Event::MonthlyDay; 200 rpTmp.type = Event::MonthlyDay;
191 else if ( cmdExtra2->isOn() ) 201 else if ( cmdExtra2->isOn() )
192 rpTmp.type = Event::MonthlyDate; 202 rpTmp.type = Event::MonthlyDate;
193 // figure out the montly day... 203 // figure out the montly day...
194 rpTmp.position = week( start ); 204 rpTmp.position = week( start );
195 break; 205 break;
196 case YEAR: 206 case YEAR:
197 rpTmp.type = Event::Yearly; 207 rpTmp.type = Event::Yearly;
198 break; 208 break;
199 } 209 }
200 break; // no need to keep looking! 210 break; // no need to keep looking!
201 } 211 }
202 } 212 }
203 rpTmp.frequency = spinFreq->value(); 213 rpTmp.frequency = spinFreq->value();
204 rpTmp.hasEndDate = !chkNoEnd->isChecked(); 214 rpTmp.hasEndDate = !chkNoEnd->isChecked();
205 if ( rpTmp.hasEndDate ) { 215 if ( rpTmp.hasEndDate ) {
206 rpTmp.setEndDate( end ); 216 rpTmp.setEndDate( end );
207 } 217 }
208 // timestamp it... 218 // timestamp it...
209 rpTmp.createTime = time( NULL ); 219 rpTmp.createTime = time( NULL );
210 return rpTmp; 220 return rpTmp;
211} 221}
212 222
213void RepeatEntry::slotSetRType( int rtype ) 223void RepeatEntry::slotSetRType( int rtype )
214{ 224{
215 // now call the right function based on the type... 225 // now call the right function based on the type...
216 currInterval = static_cast<repeatButtons>(rtype); 226 currInterval = static_cast<repeatButtons>(rtype);
217 switch ( currInterval ) { 227 switch ( currInterval ) {
218 case NONE: 228 case NONE:
219 setupNone(); 229 setupNone();
220 break; 230 break;
221 case DAY: 231 case DAY:
222 setupDaily(); 232 setupDaily();
223 break; 233 break;
224 case WEEK: 234 case WEEK:
225 setupWeekly(); 235 setupWeekly();
226 slotWeekLabel(); 236 slotWeekLabel();
227 break; 237 break;
228 case MONTH: 238 case MONTH:
229 setupMonthly(); 239 setupMonthly();
230 cmdExtra2->setOn( TRUE ); 240 cmdExtra2->setOn( TRUE );
231 slotMonthLabel( 1 ); 241 slotMonthLabel( 1 );
232 break; 242 break;
233 case YEAR: 243 case YEAR:
234 setupYearly(); 244 setupYearly();
235 break; 245 break;
236 } 246 }
237} 247}
238 248
239void RepeatEntry::setupNone() 249void RepeatEntry::setupNone()
240{ 250{
241 lblRepeat->setText( tr("No Repeat") ); 251 lblRepeat->setText( tr("No Repeat") );
242 lblVar1->hide(); 252 lblVar1->hide();
243 lblVar2->hide(); 253 lblVar2->hide();
244 hideExtras(); 254 hideExtras();
245 cmdEnd->hide(); 255 cmdEnd->hide();
246 lblFreq->hide(); 256 lblFreq->hide();
247 lblEvery->hide(); 257 lblEvery->hide();
248 lblFreq->hide(); 258 lblFreq->hide();
249 spinFreq->hide(); 259 spinFreq->hide();
250 lblEnd->hide(); 260 lblEnd->hide();
251 lblWeekVar->hide(); 261 lblWeekVar->hide();
252} 262}
253 263
254void RepeatEntry::setupDaily() 264void RepeatEntry::setupDaily()
255{ 265{
256 hideExtras(); 266 hideExtras();
257 lblWeekVar->hide(); 267 lblWeekVar->hide();
258 spinFreq->setValue( 1 ); 268 spinFreq->setValue( 1 );
259 lblFreq->setText( tr("day(s)") ); 269 lblFreq->setText( tr("day(s)") );
260 lblVar2->show(); 270 lblVar2->show();
261 showRepeatStuff(); 271 showRepeatStuff();
262 lblRepeat->setText( strDayTemplate ); 272 lblRepeat->setText( strDayTemplate );
263 setupRepeatLabel( 1 ); 273 setupRepeatLabel( 1 );
264} 274}
265 275
266void RepeatEntry::setupWeekly() 276void RepeatEntry::setupWeekly()
267{ 277{
268 // reshow the buttons... 278 // reshow the buttons...
269 fraExtra->setTitle( RepeatEntryBase::tr("Repeat On") ); 279 fraExtra->setTitle( RepeatEntryBase::tr("Repeat On") );
270 fraExtra->setExclusive( FALSE ); 280 fraExtra->setExclusive( FALSE );
271 fraExtra->show(); 281 fraExtra->show();
272 if ( startWeekOnMonday ) { 282 if ( startWeekOnMonday ) {
273 cmdExtra1->setText( RepeatEntryBase::tr("Mon") ); 283 cmdExtra1->setText( RepeatEntryBase::tr("Mon") );
274 cmdExtra2->setText( RepeatEntryBase::tr("Tue") ); 284 cmdExtra2->setText( RepeatEntryBase::tr("Tue") );
275 cmdExtra3->setText( RepeatEntryBase::tr("Wed") ); 285 cmdExtra3->setText( RepeatEntryBase::tr("Wed") );
276 cmdExtra4->setText( RepeatEntryBase::tr("Thu") ); 286 cmdExtra4->setText( RepeatEntryBase::tr("Thu") );
277 cmdExtra5->setText( RepeatEntryBase::tr("Fri") ); 287 cmdExtra5->setText( RepeatEntryBase::tr("Fri") );
278 cmdExtra6->setText( RepeatEntryBase::tr("Sat") ); 288 cmdExtra6->setText( RepeatEntryBase::tr("Sat") );
279 cmdExtra7->setText( RepeatEntryBase::tr("Sun") ); 289 cmdExtra7->setText( RepeatEntryBase::tr("Sun") );
280 } else { 290 } else {
281 cmdExtra1->setText( RepeatEntryBase::tr("Sun") ); 291 cmdExtra1->setText( RepeatEntryBase::tr("Sun") );
282 cmdExtra2->setText( RepeatEntryBase::tr("Mon") ); 292 cmdExtra2->setText( RepeatEntryBase::tr("Mon") );
283 cmdExtra3->setText( RepeatEntryBase::tr("Tue") ); 293 cmdExtra3->setText( RepeatEntryBase::tr("Tue") );
284 cmdExtra4->setText( RepeatEntryBase::tr("Wed") ); 294 cmdExtra4->setText( RepeatEntryBase::tr("Wed") );
285 cmdExtra5->setText( RepeatEntryBase::tr("Thu") ); 295 cmdExtra5->setText( RepeatEntryBase::tr("Thu") );
286 cmdExtra6->setText( RepeatEntryBase::tr("Fri") ); 296 cmdExtra6->setText( RepeatEntryBase::tr("Fri") );
287 cmdExtra7->setText( RepeatEntryBase::tr("Sat") ); 297 cmdExtra7->setText( RepeatEntryBase::tr("Sat") );
288 } 298 }
289 // I hope clustering these improve performance.... 299 // I hope clustering these improve performance....
290 cmdExtra1->setOn( FALSE ); 300 cmdExtra1->setOn( FALSE );
291 cmdExtra2->setOn( FALSE ); 301 cmdExtra2->setOn( FALSE );
292 cmdExtra3->setOn( FALSE ); 302 cmdExtra3->setOn( FALSE );
293 cmdExtra4->setOn( FALSE ); 303 cmdExtra4->setOn( FALSE );
294 cmdExtra5->setOn( FALSE ); 304 cmdExtra5->setOn( FALSE );
295 cmdExtra6->setOn( FALSE ); 305 cmdExtra6->setOn( FALSE );
296 cmdExtra7->setOn( FALSE ); 306 cmdExtra7->setOn( FALSE );
297 307
298 cmdExtra1->show(); 308 cmdExtra1->show();
299 cmdExtra2->show(); 309 cmdExtra2->show();
300 cmdExtra3->show(); 310 cmdExtra3->show();
301 cmdExtra4->show(); 311 cmdExtra4->show();
302 cmdExtra5->show(); 312 cmdExtra5->show();
303 cmdExtra6->show(); 313 cmdExtra6->show();
304 cmdExtra7->show(); 314 cmdExtra7->show();
305 315
306 lblWeekVar->show(); 316 lblWeekVar->show();
307 spinFreq->setValue( 1 ); 317 spinFreq->setValue( 1 );
308 // might as well set the day too... 318 // might as well set the day too...
309 if ( startWeekOnMonday ) { 319 if ( startWeekOnMonday ) {
310 fraExtra->setButton( start.dayOfWeek() - 1 ); 320 fraExtra->setButton( start.dayOfWeek() - 1 );
311 } else { 321 } else {
312 fraExtra->setButton( start.dayOfWeek() % 7 ); 322 fraExtra->setButton( start.dayOfWeek() % 7 );
313 } 323 }
314 lblFreq->setText( tr("week(s)") ); 324 lblFreq->setText( tr("week(s)") );
315 lblVar2->show(); 325 lblVar2->show();
316 showRepeatStuff(); 326 showRepeatStuff();
317 setupRepeatLabel( 1 ); 327 setupRepeatLabel( 1 );
318} 328}
319 329
320void RepeatEntry::setupMonthly() 330void RepeatEntry::setupMonthly()
321{ 331{
322 hideExtras(); 332 hideExtras();
323 lblWeekVar->hide(); 333 lblWeekVar->hide();
324 fraExtra->setTitle( tr("Repeat By") ); 334 fraExtra->setTitle( tr("Repeat By") );
325 fraExtra->setExclusive( TRUE ); 335 fraExtra->setExclusive( TRUE );
326 fraExtra->show(); 336 fraExtra->show();
327 cmdExtra1->setText( tr("Day") ); 337 cmdExtra1->setText( tr("Day") );
328 cmdExtra1->show(); 338 cmdExtra1->show();
329 cmdExtra2->setText( tr("Date") ); 339 cmdExtra2->setText( tr("Date") );
330 cmdExtra2->show(); 340 cmdExtra2->show();
331 spinFreq->setValue( 1 ); 341 spinFreq->setValue( 1 );
332 lblFreq->setText( tr("month(s)") ); 342 lblFreq->setText( tr("month(s)") );
333 lblVar2->show(); 343 lblVar2->show();
334 showRepeatStuff(); 344 showRepeatStuff();
335 setupRepeatLabel( 1 ); 345 setupRepeatLabel( 1 );
336} 346}
337 347
338void RepeatEntry::setupYearly() 348void RepeatEntry::setupYearly()
339{ 349{
340 hideExtras(); 350 hideExtras();
341 lblWeekVar->hide(); 351 lblWeekVar->hide();
342 spinFreq->setValue( 1 ); 352 spinFreq->setValue( 1 );
343 lblFreq->setText( tr("year(s)") ); 353 lblFreq->setText( tr("year(s)") );
344 lblFreq->show(); 354 lblFreq->show();
345 lblFreq->show(); 355 lblFreq->show();
346 showRepeatStuff(); 356 showRepeatStuff();
347 lblVar2->show(); 357 lblVar2->show();
348 QString strEvery = strYearTemplate.arg( start.monthName(start.month()) ).arg( numberPlacing(start.day()) ); 358 QString strEvery = strYearTemplate.arg( start.monthName(start.month()) ).arg( numberPlacing(start.day()) );
349 lblRepeat->setText( strEvery ); 359 lblRepeat->setText( strEvery );
350 setupRepeatLabel( 1 ); 360 setupRepeatLabel( 1 );
351 361
352} 362}
353 363
354void RepeatEntry::init() 364void RepeatEntry::init()
355{ 365{
356 QPopupMenu *m1 = new QPopupMenu( this ); 366 QPopupMenu *m1 = new QPopupMenu( this );
357 repeatPicker = new DateBookMonth( m1, 0, TRUE ); 367 repeatPicker = new DateBookMonth( m1, 0, TRUE );
358 m1->insertItem( repeatPicker ); 368 m1->insertItem( repeatPicker );
359 cmdEnd->setPopup( m1 ); 369 cmdEnd->setPopup( m1 );
360 cmdEnd->setPopupDelay( 0 ); 370 cmdEnd->setPopupDelay( 0 );
361 371
362 QObject::connect( repeatPicker, SIGNAL(dateClicked(int,int,int)), 372 QObject::connect( repeatPicker, SIGNAL(dateClicked(int,int,int)),
363 this, SLOT(endDateChanged(int,int,int)) ); 373 this, SLOT(endDateChanged(int,int,int)) );
364 QObject::connect( qApp, SIGNAL(weekChanged(bool)), 374 QObject::connect( qApp, SIGNAL(weekChanged(bool)),
365 this, SLOT(slotChangeStartOfWeek(bool)) ); 375 this, SLOT(slotChangeStartOfWeek(bool)) );
366 376
367 listRTypeButtons.setAutoDelete( TRUE ); 377 listRTypeButtons.setAutoDelete( TRUE );
368 listRTypeButtons.append( cmdNone ); 378 listRTypeButtons.append( cmdNone );
369 listRTypeButtons.append( cmdDay ); 379 listRTypeButtons.append( cmdDay );
370 listRTypeButtons.append( cmdWeek ); 380 listRTypeButtons.append( cmdWeek );
371 listRTypeButtons.append( cmdMonth ); 381 listRTypeButtons.append( cmdMonth );
372 listRTypeButtons.append( cmdYear ); 382 listRTypeButtons.append( cmdYear );
373 383
374 listExtra.setAutoDelete( TRUE ); 384 listExtra.setAutoDelete( TRUE );
375 listExtra.append( cmdExtra1 ); 385 listExtra.append( cmdExtra1 );
376 listExtra.append( cmdExtra2 ); 386 listExtra.append( cmdExtra2 );
377 listExtra.append( cmdExtra3 ); 387 listExtra.append( cmdExtra3 );
378 listExtra.append( cmdExtra4 ); 388 listExtra.append( cmdExtra4 );
379 listExtra.append( cmdExtra5 ); 389 listExtra.append( cmdExtra5 );
380 listExtra.append( cmdExtra6 ); 390 listExtra.append( cmdExtra6 );
381 listExtra.append( cmdExtra7 ); 391 listExtra.append( cmdExtra7 );
382} 392}
383 393
384void RepeatEntry::slotNoEnd( bool unused ) 394void RepeatEntry::slotNoEnd( bool unused )
385{ 395{
386 // if the item was toggled, then go ahead and set it to the maximum date 396 // if the item was toggled, then go ahead and set it to the maximum date
387 if ( unused ) { 397 if ( unused ) {
388 end.setYMD( 3000, 12, 31 ); 398 end.setYMD( 3000, 12, 31 );
389 cmdEnd->setText( RepeatEntryBase::tr("No End Date") ); 399 cmdEnd->setText( RepeatEntryBase::tr("No End Date") );
390 } else { 400 } else {
391 end = start; 401 end = start;
392 cmdEnd->setText( TimeString::shortDate(end) ); 402 cmdEnd->setText( TimeString::shortDate(end) );
393 } 403 }
394} 404}
395 405
396void RepeatEntry::endDateChanged( int y, int m, int d ) 406void RepeatEntry::endDateChanged( int y, int m, int d )
397{ 407{
398 end.setYMD( y, m, d ); 408 end.setYMD( y, m, d );
399 if ( end < start ) 409 if ( end < start )
400 end = start; 410 end = start;
401 cmdEnd->setText( TimeString::shortDate( end ) ); 411 cmdEnd->setText( TimeString::shortDate( end ) );
402 repeatPicker->setDate( end.year(), end.month(), end.day() ); 412 repeatPicker->setDate( end.year(), end.month(), end.day() );
403} 413}
404 414
405void RepeatEntry::setupRepeatLabel( const QString &s ) 415void RepeatEntry::setupRepeatLabel( const QString &s )
406{ 416{
407 lblVar1->setText( s ); 417 lblVar1->setText( s );
408} 418}
409 419
410void RepeatEntry::setupRepeatLabel( int x ) 420void RepeatEntry::setupRepeatLabel( int x )
411{ 421{
412 // change the spelling based on the value of x 422 // change the spelling based on the value of x
413 QString strVar2; 423 QString strVar2;
414 424
415 if ( x > 1 ) 425 if ( x > 1 )
416 lblVar1->show(); 426 lblVar1->show();
417 else 427 else
418 lblVar1->hide(); 428 lblVar1->hide();
419 429
420 switch ( currInterval ) { 430 switch ( currInterval ) {
421 case NONE: 431 case NONE:
422 break; 432 break;
423 case DAY: 433 case DAY:
424 if ( x > 1 ) 434 if ( x > 1 )
425 strVar2 = tr( "days" ); 435 strVar2 = tr( "days" );
426 else 436 else
427 strVar2 = tr( "day" ); 437 strVar2 = tr( "day" );
428 break; 438 break;
429 case WEEK: 439 case WEEK:
430 if ( x > 1 ) 440 if ( x > 1 )
431 strVar2 = tr( "weeks" ); 441 strVar2 = tr( "weeks" );
432 else 442 else
433 strVar2 = tr( "week" ); 443 strVar2 = tr( "week" );
434 break; 444 break;
435 case MONTH: 445 case MONTH:
436 if ( x > 1 ) 446 if ( x > 1 )
437 strVar2 = RepeatEntryBase::tr( "months" ); 447 strVar2 = RepeatEntryBase::tr( "months" );
438 else 448 else
439 strVar2 = tr( "month" ); 449 strVar2 = tr( "month" );
440 break; 450 break;
441 case YEAR: 451 case YEAR:
442 if ( x > 1 ) 452 if ( x > 1 )
443 strVar2 = RepeatEntryBase::tr( "years" ); 453 strVar2 = RepeatEntryBase::tr( "years" );
444 else 454 else
445 strVar2 = tr( "year" ); 455 strVar2 = tr( "year" );
446 break; 456 break;
447 } 457 }
448 if ( !strVar2.isNull() ) 458 if ( !strVar2.isNull() )
449 lblVar2->setText( strVar2 ); 459 lblVar2->setText( strVar2 );
450} 460}
451 461
452void RepeatEntry::showRepeatStuff() 462void RepeatEntry::showRepeatStuff()
453{ 463{
454 cmdEnd->show(); 464 cmdEnd->show();
455 chkNoEnd->show(); 465 chkNoEnd->show();
456 lblFreq->show(); 466 lblFreq->show();
457 lblEvery->show(); 467 lblEvery->show();
458 lblFreq->show(); 468 lblFreq->show();
459 spinFreq->show(); 469 spinFreq->show();
460 lblEnd->show(); 470 lblEnd->show();
461 lblRepeat->setText( RepeatEntryBase::tr("Every") ); 471 lblRepeat->setText( RepeatEntryBase::tr("Every") );
462} 472}
463 473
464void RepeatEntry::slotWeekLabel() 474void RepeatEntry::slotWeekLabel()
465{ 475{
466 QString str; 476 QString str;
467 QListIterator<QToolButton> it( listExtra ); 477 QListIterator<QToolButton> it( listExtra );
468 unsigned int i; 478 unsigned int i;
469 unsigned int keepMe; 479 unsigned int keepMe;
470 bool bNeedCarriage = FALSE; 480 bool bNeedCarriage = FALSE;
471 // don't do something we'll regret!!! 481 // don't do something we'll regret!!!
472 if ( currInterval != WEEK ) 482 if ( currInterval != WEEK )
473 return; 483 return;
474 484
475 if ( startWeekOnMonday ) 485 if ( startWeekOnMonday )
476 keepMe = start.dayOfWeek() - 1; 486 keepMe = start.dayOfWeek() - 1;
477 else 487 else
478 keepMe = start.dayOfWeek() % 7; 488 keepMe = start.dayOfWeek() % 7;
479 489
480 QStringList list; 490 QStringList list;
481 for ( i = 0; *it; ++it, i++ ) { 491 for ( i = 0; *it; ++it, i++ ) {
482 // a crazy check, if you are repeating weekly, the current day 492 // a crazy check, if you are repeating weekly, the current day
483 // must be selected!!! 493 // must be selected!!!
484 if ( i == keepMe && !( (*it)->isOn() ) ) 494 if ( i == keepMe && !( (*it)->isOn() ) )
485 (*it)->setOn( TRUE ); 495 (*it)->setOn( TRUE );
486 if ( (*it)->isOn() ) { 496 if ( (*it)->isOn() ) {
487 if ( startWeekOnMonday ) 497 if ( startWeekOnMonday )
488 list.append( dayLabel[i] ); 498 list.append( dayLabel[i] );
489 else { 499 else {
490 if ( i == 0 ) 500 if ( i == 0 )
491 list.append( dayLabel[6] ); 501 list.append( dayLabel[6] );
492 else 502 else
493 list.append( dayLabel[i - 1] ); 503 list.append( dayLabel[i - 1] );
494 } 504 }
495 } 505 }
496 } 506 }
497 QStringList::Iterator itStr; 507 QStringList::Iterator itStr;
498 for ( i = 0, itStr = list.begin(); itStr != list.end(); ++itStr, i++ ) { 508 for ( i = 0, itStr = list.begin(); itStr != list.end(); ++itStr, i++ ) {
499 if ( i == 3 ) 509 if ( i == 3 )
500 bNeedCarriage = TRUE; 510 bNeedCarriage = TRUE;
501 else 511 else
502 bNeedCarriage = FALSE; 512 bNeedCarriage = FALSE;
503 if ( str.isNull() ) 513 if ( str.isNull() )
504 str = *itStr; 514 str = *itStr;
505 else if ( i == list.count() - 1 ) { 515 else if ( i == list.count() - 1 ) {
506 if ( i < 2 ) 516 if ( i < 2 )
507 str += tr(" and ") + *itStr; 517 str += tr(" and ") + *itStr;
508 else { 518 else {
509 if ( bNeedCarriage ) 519 if ( bNeedCarriage )
510 str += tr( ",\nand " ) + *itStr; 520 str += tr( ",\nand " ) + *itStr;
511 else 521 else
512 str += tr( ", and " ) + *itStr; 522 str += tr( ", and " ) + *itStr;
513 } 523 }
514 } else { 524 } else {
515 if ( bNeedCarriage ) 525 if ( bNeedCarriage )
516 str += ",\n" + *itStr; 526 str += ",\n" + *itStr;
517 else 527 else
518 str += ", " + *itStr; 528 str += ", " + *itStr;
519 } 529 }
520 } 530 }
521 str = str.prepend( tr("on ") ); 531 str = str.prepend( tr("on ") );
522 lblWeekVar->setText( str ); 532 lblWeekVar->setText( str );
523} 533}
524 534
525void RepeatEntry::slotMonthLabel( int type ) 535void RepeatEntry::slotMonthLabel( int type )
526{ 536{
527 QString str; 537 QString str;
528 if ( currInterval != MONTH || type > 1 ) 538 if ( currInterval != MONTH || type > 1 )
529 return; 539 return;
530 if ( type == 1 ) 540 if ( type == 1 )
531 str = strMonthDateTemplate.arg( numberPlacing(start.day()) ); 541 str = strMonthDateTemplate.arg( numberPlacing(start.day()) );
532 else 542 else
533 str = strMonthDayTemplate.arg( numberPlacing(week(start))) 543 str = strMonthDayTemplate.arg( numberPlacing(week(start)))
534 .arg( dayLabel[start.dayOfWeek() - 1] ); 544 .arg( dayLabel[start.dayOfWeek() - 1] );
535 lblRepeat->setText( str ); 545 lblRepeat->setText( str );
536} 546}
537 547
538void RepeatEntry::slotChangeStartOfWeek( bool onMonday ) 548void RepeatEntry::slotChangeStartOfWeek( bool onMonday )
539{ 549{
540 startWeekOnMonday = onMonday; 550 startWeekOnMonday = onMonday;
541 // we need to make this unintrusive as possible... 551 // we need to make this unintrusive as possible...
542 int saveSpin = spinFreq->value(); 552 int saveSpin = spinFreq->value();
543 char days = 0; 553 char days = 0;
544 int day; 554 int day;
545 QListIterator<QToolButton> itExtra( listExtra ); 555 QListIterator<QToolButton> itExtra( listExtra );
546 for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) { 556 for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) {
547 if ( (*itExtra)->isOn() ) { 557 if ( (*itExtra)->isOn() ) {
548 if ( !startWeekOnMonday ) 558 if ( !startWeekOnMonday )
549 days |= day; 559 days |= day;
550 else { 560 else {
551 if ( day == 1 ) 561 if ( day == 1 )
552 days |= Event::SUN; 562 days |= Event::SUN;
553 else 563 else
554 days |= day >> 1; 564 days |= day >> 1;
555 } 565 }
556 } 566 }
557 } 567 }
558 setupWeekly(); 568 setupWeekly();
559 spinFreq->setValue( saveSpin ); 569 spinFreq->setValue( saveSpin );
560 int buttons; 570 int buttons;
561 for ( day = 0x01, buttons = 0; buttons < 7; 571 for ( day = 0x01, buttons = 0; buttons < 7;
562 day = day << 1, buttons++ ) { 572 day = day << 1, buttons++ ) {
563 if ( days & day ) { 573 if ( days & day ) {
564 if ( startWeekOnMonday ) 574 if ( startWeekOnMonday )
565 fraExtra->setButton( buttons ); 575 fraExtra->setButton( buttons );
566 else { 576 else {
567 if ( buttons == 7 ) 577 if ( buttons == 7 )
568 fraExtra->setButton( 0 ); 578 fraExtra->setButton( 0 );
569 else 579 else
570 fraExtra->setButton( buttons + 1 ); 580 fraExtra->setButton( buttons + 1 );
571 } 581 }
572 } 582 }
573 } 583 }
574 slotWeekLabel(); 584 slotWeekLabel();
575} 585}
576 586
577static int week( const QDate &start ) 587static int week( const QDate &start )
578{ 588{
579 // figure out the week... 589 // figure out the week...
580 int stop = start.day(), 590 int stop = start.day(),
581 sentinel = start.dayOfWeek(), 591 sentinel = start.dayOfWeek(),
582 dayOfWeek = QDate( start.year(), start.month(), 1 ).dayOfWeek(), 592 dayOfWeek = QDate( start.year(), start.month(), 1 ).dayOfWeek(),
583 week = 1, 593 week = 1,
584 i; 594 i;
585 for ( i = 1; i < stop; i++ ) { 595 for ( i = 1; i < stop; i++ ) {
586 if ( dayOfWeek++ == sentinel ) 596 if ( dayOfWeek++ == sentinel )
587 week++; 597 week++;
588 if ( dayOfWeek > 7 ) 598 if ( dayOfWeek > 7 )
589 dayOfWeek = 0; 599 dayOfWeek = 0;
590 } 600 }
591 return week; 601 return week;
592} 602}
593 603
594static QString numberPlacing( int x ) 604static QString numberPlacing( int x )
595{ 605{
596 // I hope this works in other languages besides english... 606 // I hope this works in other languages besides english...
597 QString str = QString::number( x ); 607 QString str = QString::number( x );
598 switch ( x % 10 ) { 608 switch ( x % 10 ) {
599 case 1: 609 case 1:
600 str += QWidget::tr( "st" ); 610 str += QWidget::tr( "st" );
601 break; 611 break;
602 case 2: 612 case 2:
603 str += QWidget::tr( "nd" ); 613 str += QWidget::tr( "nd" );
604 break; 614 break;
605 case 3: 615 case 3:
606 str += QWidget::tr( "rd" ); 616 str += QWidget::tr( "rd" );
607 break; 617 break;
608 default: 618 default:
609 str += QWidget::tr( "th" ); 619 str += QWidget::tr( "th" );
610 break; 620 break;
611 } 621 }
612 return str; 622 return str;
613} 623}
diff --git a/core/pim/datebook/repeatentry.h b/core/pim/datebook/repeatentry.h
index 949fecd..d75af3c 100644
--- a/core/pim/datebook/repeatentry.h
+++ b/core/pim/datebook/repeatentry.h
@@ -1,98 +1,108 @@
1/********************************************************************** 1/*
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2                 This file is part of the Opie Project
3** 3
4** This file is part of Qtopia Environment. 4 Copyright (C) Opie Team <opie-devel@handhelds.org>
5** 5 =.
6** This file may be distributed and/or modified under the terms of the 6 .=l.
7** GNU General Public License version 2 as published by the Free Software 7           .>+-=
8** Foundation and appearing in the file LICENSE.GPL included in the 8 _;:,     .>    :=|. This program is free software; you can
9** packaging of this file. 9.> <`_,   >  .   <= redistribute it and/or modify it under
10** 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11.="- .-=="i,     .._ License as published by the Free Software
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13** 13     ._= =}       : or (at your option) any later version.
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14    .%`+i>       _;_.
15** 15    .i_,=:_.      -<s. This program is distributed in the hope that
16** Contact info@trolltech.com if any conditions of this licensing are 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17** not clear to you. 17 : ..    .:,     . . . without even the implied warranty of
18** 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19**********************************************************************/ 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details.
22:     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA.
29*/
20 30
21#ifndef REPEATENTRY_H 31#ifndef REPEATENTRY_H
22#define REPEATENTRY_H 32#define REPEATENTRY_H
23 33
24#include "repeatentrybase.h" 34#include "repeatentrybase.h"
25 35
26#include <qpe/event.h> 36#include <qpe/event.h>
27 37
28#include <qcheckbox.h> 38#include <qcheckbox.h>
29#include <qbuttongroup.h> 39#include <qbuttongroup.h>
30#include <qdatetime.h> 40#include <qdatetime.h>
31#include <qlist.h> 41#include <qlist.h>
32#include <qtoolbutton.h> 42#include <qtoolbutton.h>
33 43
34class DateBookMonth; 44class DateBookMonth;
35 45
36class RepeatEntry : public RepeatEntryBase 46class RepeatEntry : public RepeatEntryBase
37{ 47{
38 Q_OBJECT 48 Q_OBJECT
39public: 49public:
40 RepeatEntry( bool startOnMonday, 50 RepeatEntry( bool startOnMonday,
41 const QDate &start, QWidget *parent = 0, const char *name = 0, 51 const QDate &start, QWidget *parent = 0, const char *name = 0,
42 bool modal = TRUE, WFlags fl = 0 ); 52 bool modal = TRUE, WFlags fl = 0 );
43 RepeatEntry( bool startOnMonday, 53 RepeatEntry( bool startOnMonday,
44 const Event::RepeatPattern &rp, const QDate &start, 54 const Event::RepeatPattern &rp, const QDate &start,
45 QWidget *parent = 0, const char *name = 0, bool modal = TRUE, 55 QWidget *parent = 0, const char *name = 0, bool modal = TRUE,
46 WFlags fl = 0 ); 56 WFlags fl = 0 );
47 ~RepeatEntry(); 57 ~RepeatEntry();
48 58
49 Event::RepeatPattern repeatPattern(); 59 Event::RepeatPattern repeatPattern();
50 QDate endDate() { return end; }; 60 QDate endDate() { return end; };
51 61
52public slots: 62public slots:
53 void slotSetRType( int ); 63 void slotSetRType( int );
54 void endDateChanged( int, int, int ); 64 void endDateChanged( int, int, int );
55 void slotNoEnd( bool unused ); 65 void slotNoEnd( bool unused );
56 66
57private slots: 67private slots:
58 void setupRepeatLabel( const QString& ); 68 void setupRepeatLabel( const QString& );
59 void setupRepeatLabel( int ); 69 void setupRepeatLabel( int );
60 void slotWeekLabel(); 70 void slotWeekLabel();
61 void slotMonthLabel( int ); 71 void slotMonthLabel( int );
62 void slotChangeStartOfWeek( bool onMonday ); 72 void slotChangeStartOfWeek( bool onMonday );
63 73
64private: 74private:
65 void setupNone(); 75 void setupNone();
66 void setupDaily(); 76 void setupDaily();
67 void setupWeekly(); 77 void setupWeekly();
68 void setupMonthly(); 78 void setupMonthly();
69 void setupYearly(); 79 void setupYearly();
70 80
71 enum repeatButtons { NONE, DAY, WEEK, MONTH, YEAR }; 81 enum repeatButtons { NONE, DAY, WEEK, MONTH, YEAR };
72 void init(); 82 void init();
73 inline void hideExtras(); 83 inline void hideExtras();
74 void showRepeatStuff(); 84 void showRepeatStuff();
75 85
76 QList<QToolButton> listRTypeButtons; 86 QList<QToolButton> listRTypeButtons;
77 QList<QToolButton> listExtra; 87 QList<QToolButton> listExtra;
78 QDate start; // only used in one spot... 88 QDate start; // only used in one spot...
79 QDate end; 89 QDate end;
80 repeatButtons currInterval; 90 repeatButtons currInterval;
81 bool startWeekOnMonday; 91 bool startWeekOnMonday;
82 DateBookMonth *repeatPicker; 92 DateBookMonth *repeatPicker;
83}; 93};
84 94
85inline void RepeatEntry::hideExtras() 95inline void RepeatEntry::hideExtras()
86{ 96{
87 // hide the extra buttons... 97 // hide the extra buttons...
88 fraExtra->hide(); 98 fraExtra->hide();
89 chkNoEnd->hide(); 99 chkNoEnd->hide();
90 QListIterator<QToolButton> it( listExtra ); 100 QListIterator<QToolButton> it( listExtra );
91 for ( ; *it; ++it ) { 101 for ( ; *it; ++it ) {
92 (*it)->hide(); 102 (*it)->hide();
93 (*it)->setOn( FALSE ); 103 (*it)->setOn( FALSE );
94 } 104 }
95 105
96} 106}
97 107
98#endif 108#endif