summaryrefslogtreecommitdiff
authoralwin <alwin>2005-03-18 12:49:14 (UTC)
committer alwin <alwin>2005-03-18 12:49:14 (UTC)
commitb7996a25adab32e6f2e4d278a9d9801ad66f90c7 (patch) (unidiff)
treef90bf3aa5cd274c467a8ff3e84566fdfa6a1a6c5
parentd7fdcc3dac4a1d8cbd823d17ea52d17cb67b16f8 (diff)
downloadopie-b7996a25adab32e6f2e4d278a9d9801ad66f90c7.zip
opie-b7996a25adab32e6f2e4d278a9d9801ad66f90c7.tar.gz
opie-b7996a25adab32e6f2e4d278a9d9801ad66f90c7.tar.bz2
made plugins configureable, eg, if them will load or not (or switch on/off
at runtime) events generated from plugins will not editable and so on (check for a wrong Uid) so them are just text inside datebook.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp50
-rw-r--r--core/pim/datebook/datebookday.cpp7
-rw-r--r--core/pim/datebook/datebookdayallday.cpp2
-rw-r--r--core/pim/datebook/datebooksettings.cpp124
-rw-r--r--core/pim/datebook/datebooksettings.h18
-rw-r--r--core/pim/datebook/datebooksettingsbase.ui59
-rw-r--r--core/pim/datebook/datebooktypes.h7
-rw-r--r--core/pim/datebook/datebookweeklst.cpp5
8 files changed, 188 insertions, 84 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index a7f6691..8ae4f84 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -153,208 +153,212 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f )
153 a->setToggleAction( TRUE ); 153 a->setToggleAction( TRUE );
154 monthAction = a; 154 monthAction = a;
155 155
156 sub_bar->addSeparator(); 156 sub_bar->addSeparator();
157 157
158 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 ); 158 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 );
159 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); 159 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) );
160 a->addTo( sub_bar ); 160 a->addTo( sub_bar );
161 161
162 a = new QAction( tr( "Edit..." ), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0 ); 162 a = new QAction( tr( "Edit..." ), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0 );
163 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); 163 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
164 a->addTo( sub_bar ); 164 a->addTo( sub_bar );
165 165
166 if(defaultView==DAY) viewDay(); 166 if(defaultView==DAY) viewDay();
167 if(defaultView==WEEK) needEvilHack=true; // viewWeek(); 167 if(defaultView==WEEK) needEvilHack=true; // viewWeek();
168 if(defaultView==WEEKLST) viewWeekLst(); 168 if(defaultView==WEEKLST) viewWeekLst();
169 if(defaultView==MONTH) viewMonth(); 169 if(defaultView==MONTH) viewMonth();
170 170
171 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); 171 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) );
172 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) ); 172 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) );
173 173
174#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 174#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
175 connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), this, SLOT(appMessage(const QCString&,const QByteArray&)) ); 175 connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), this, SLOT(appMessage(const QCString&,const QByteArray&)) );
176#endif 176#endif
177 177
178 // listen on QPE/System 178 // listen on QPE/System
179#if defined(Q_WS_QWS) 179#if defined(Q_WS_QWS)
180#if !defined(QT_NO_COP) 180#if !defined(QT_NO_COP)
181 QCopChannel *channel = new QCopChannel( "QPE/System", this ); 181 QCopChannel *channel = new QCopChannel( "QPE/System", this );
182 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) ); 182 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) );
183 channel = new QCopChannel( "QPE/Datebook", this ); 183 channel = new QCopChannel( "QPE/Datebook", this );
184 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) ); 184 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) );
185#endif 185#endif
186#endif 186#endif
187 187
188 odebug << "done t=" << t.elapsed() << oendl; 188 odebug << "done t=" << t.elapsed() << oendl;
189 189
190 connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); 190 connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) );
191 connect( qApp, SIGNAL( reload()), this, SLOT( reload() ) ); 191 connect( qApp, SIGNAL( reload()), this, SLOT( reload() ) );
192 /* 192 /*
193 * Here is a problem description: 193 * Here is a problem description:
194 * When Weekview is the default view 194 * When Weekview is the default view
195 * a DateBookWeekView get's created 195 * a DateBookWeekView get's created
196 * redraw() get's called. So what? 196 * redraw() get's called. So what?
197 * Remember that we're still in the c'tor 197 * Remember that we're still in the c'tor
198 * and no final layout has happened? Ok 198 * and no final layout has happened? Ok
199 * now all Events get arranged. Their x 199 * now all Events get arranged. Their x
200 * position get's determined by a QHeader 200 * position get's determined by a QHeader
201 * position. But the QHeader isn't layouted or 201 * position. But the QHeader isn't layouted or
202 * at the right position. redraw() is a slot 202 * at the right position. redraw() is a slot
203 * so we'll call it then via a singleShot 203 * so we'll call it then via a singleShot
204 * from view() 204 * from view()
205 */ 205 */
206 if( needEvilHack ){ 206 if( needEvilHack ){
207 QTimer::singleShot( 500, this, SLOT(viewWeek()) ); 207 QTimer::singleShot( 500, this, SLOT(viewWeek()) );
208 } 208 }
209} 209}
210 210
211void DateBook::receive( const QCString &msg, const QByteArray &data ) 211void DateBook::receive( const QCString &msg, const QByteArray &data )
212{ 212{
213 QDataStream stream( data, IO_ReadOnly ); 213 QDataStream stream( data, IO_ReadOnly );
214 if ( msg == "timeChange(QString)" ) { 214 if ( msg == "timeChange(QString)" ) {
215 // update active view! 215 // update active view!
216 if ( dayAction->isOn() ) 216 if ( dayAction->isOn() )
217 viewDay(); 217 viewDay();
218 else if ( weekAction->isOn() ) 218 else if ( weekAction->isOn() )
219 viewWeek(); 219 viewWeek();
220 else if ( monthAction->isOn() ) 220 else if ( monthAction->isOn() )
221 viewMonth(); 221 viewMonth();
222 } 222 }
223 else if (msg == "editEvent(int)") { 223 else if (msg == "editEvent(int)") {
224 int uid; 224 int uid;
225 stream >> uid; 225 stream >> uid;
226 Event e=db->eventByUID(uid); 226 Event e=db->eventByUID(uid);
227 editEvent(e); 227 editEvent(e);
228 }else if (msg == "viewDefault(QDate)"){ 228 }else if (msg == "viewDefault(QDate)"){
229 QDate day; 229 QDate day;
230 stream >> day; 230 stream >> day;
231 viewDefault(day); 231 viewDefault(day);
232 } 232 }
233} 233}
234 234
235DateBook::~DateBook() 235DateBook::~DateBook()
236{ 236{
237 delete db_holiday; 237 delete db_holiday;
238} 238}
239 239
240void DateBook::slotSettings() 240void DateBook::slotSettings()
241{ 241{
242 DateBookSettings frmSettings( ampm, this ); 242 DateBookSettings frmSettings( ampm, this );
243 frmSettings.setStartTime( startTime ); 243 frmSettings.setStartTime( startTime );
244 frmSettings.setAlarmPreset( aPreset, presetTime ); 244 frmSettings.setAlarmPreset( aPreset, presetTime );
245 frmSettings.setJumpToCurTime( bJumpToCurTime ); 245 frmSettings.setJumpToCurTime( bJumpToCurTime );
246 frmSettings.setRowStyle( rowStyle ); 246 frmSettings.setRowStyle( rowStyle );
247 frmSettings.comboDefaultView->setCurrentItem(defaultView-1); 247 frmSettings.comboDefaultView->setCurrentItem(defaultView-1);
248 frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig); 248 frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig);
249 frmSettings.setPluginList(db_holiday->pluginManager(),db_holiday->pluginLoader());
249 250
250 bool found=false; 251 bool found=false;
251 for (int i=0; i<(frmSettings.comboLocation->count()); i++) { 252 for (int i=0; i<(frmSettings.comboLocation->count()); i++) {
252 if ( frmSettings.comboLocation->text(i) == defaultLocation ) { 253 if ( frmSettings.comboLocation->text(i) == defaultLocation ) {
253 frmSettings.comboLocation->setCurrentItem(i); 254 frmSettings.comboLocation->setCurrentItem(i);
254 found=true; 255 found=true;
255 break; 256 break;
256 } 257 }
257 } 258 }
258 if(!found) { 259 if(!found) {
259 frmSettings.comboLocation->insertItem(defaultLocation); 260 frmSettings.comboLocation->insertItem(defaultLocation);
260 frmSettings.comboLocation->setCurrentItem(frmSettings.comboLocation->count()-1); 261 frmSettings.comboLocation->setCurrentItem(frmSettings.comboLocation->count()-1);
261 } 262 }
262 frmSettings.comboCategory->setCategories(defaultCategories,"Calendar", tr("Calendar")); 263 frmSettings.comboCategory->setCategories(defaultCategories,"Calendar", tr("Calendar"));
263 264
264 if ( QPEApplication::execDialog( &frmSettings ) ) { 265 if ( QPEApplication::execDialog( &frmSettings ) ) {
266 db_holiday->pluginManager()->save();
267 db_holiday->reloadPlugins();
268
265 aPreset = frmSettings.alarmPreset(); 269 aPreset = frmSettings.alarmPreset();
266 presetTime = frmSettings.presetTime(); 270 presetTime = frmSettings.presetTime();
267 startTime = frmSettings.startTime(); 271 startTime = frmSettings.startTime();
268 bJumpToCurTime = frmSettings.jumpToCurTime(); 272 bJumpToCurTime = frmSettings.jumpToCurTime();
269 rowStyle = frmSettings.rowStyle(); 273 rowStyle = frmSettings.rowStyle();
270 defaultView=frmSettings.comboDefaultView->currentItem()+1; 274 defaultView=frmSettings.comboDefaultView->currentItem()+1;
271 weeklistviewconfig=frmSettings.comboWeekListView->currentItem(); 275 weeklistviewconfig=frmSettings.comboWeekListView->currentItem();
272 defaultLocation=frmSettings.comboLocation->currentText(); 276 defaultLocation=frmSettings.comboLocation->currentText();
273 defaultCategories=frmSettings.comboCategory->currentCategories(); 277 defaultCategories=frmSettings.comboCategory->currentCategories();
274 278
275 if ( dayView ) { 279 if ( dayView ) {
276 dayView->setStartViewTime( startTime ); 280 dayView->setStartViewTime( startTime );
277 dayView->setJumpToCurTime( bJumpToCurTime ); 281 dayView->setJumpToCurTime( bJumpToCurTime );
278 dayView->setRowStyle( rowStyle ); 282 dayView->setRowStyle( rowStyle );
279 } 283 }
280 if ( weekView ) { 284 if ( weekView ) {
281 weekView->setStartViewTime( startTime ); 285 weekView->setStartViewTime( startTime );
282 } 286 }
283 saveSettings(); 287 saveSettings();
284 288
285 // make the change obvious 289 // make the change obvious
286 if ( views->visibleWidget() ) { 290 if ( views->visibleWidget() ) {
287 if ( views->visibleWidget() == dayView ) 291 if ( views->visibleWidget() == dayView )
288 dayView->redraw(); 292 dayView->redraw();
289 else if ( views->visibleWidget() == weekView ) 293 else if ( views->visibleWidget() == weekView )
290 weekView->redraw(); 294 weekView->redraw();
291 else if ( views->visibleWidget() == weekLstView ) 295 else if ( views->visibleWidget() == weekLstView )
292 weekLstView->redraw(); 296 weekLstView->redraw();
293 } 297 }
294 } 298 }
295} 299}
296 300
297void DateBook::fileNew() 301void DateBook::fileNew()
298{ 302{
299 slotNewEventFromKey(""); 303 slotNewEventFromKey("");
300} 304}
301 305
302QString DateBook::checkEvent(const Event &e) 306QString DateBook::checkEvent(const Event &e)
303{ 307{
304 /* check if overlaps with itself */ 308 /* check if overlaps with itself */
305 bool checkFailed = FALSE; 309 bool checkFailed = FALSE;
306 310
307 /* check the next 12 repeats. should catch most problems */ 311 /* check the next 12 repeats. should catch most problems */
308 QDate current_date = e.start().date(); 312 QDate current_date = e.start().date();
309 Event previous = e; 313 Event previous = e;
310 for(int i = 0; i < 12; i++) 314 for(int i = 0; i < 12; i++)
311 { 315 {
312 QDateTime next; 316 QDateTime next;
313 if (!nextOccurance(previous, current_date.addDays(1), next)) { 317 if (!nextOccurance(previous, current_date.addDays(1), next)) {
314 break; // no more repeats 318 break; // no more repeats
315 } 319 }
316 if(next < previous.end()) { 320 if(next < previous.end()) {
317 checkFailed = TRUE; 321 checkFailed = TRUE;
318 break; 322 break;
319 } 323 }
320 current_date = next.date(); 324 current_date = next.date();
321 } 325 }
322 326
323 if(checkFailed) 327 if(checkFailed)
324 return tr("Event duration is potentially longer\n" 328 return tr("Event duration is potentially longer\n"
325 "than interval between repeats."); 329 "than interval between repeats.");
326 330
327 return QString::null; 331 return QString::null;
328} 332}
329 333
330QDate DateBook::currentDate() 334QDate DateBook::currentDate()
331{ 335{
332 QDate d = QDate::currentDate(); 336 QDate d = QDate::currentDate();
333 337
334 if ( dayView && views->visibleWidget() == dayView ) { 338 if ( dayView && views->visibleWidget() == dayView ) {
335 d = dayView->date(); 339 d = dayView->date();
336 } else if ( weekView && views->visibleWidget() == weekView ) { 340 } else if ( weekView && views->visibleWidget() == weekView ) {
337 d = weekView->date(); 341 d = weekView->date();
338 } else if ( weekLstView && views->visibleWidget() == weekLstView ) { 342 } else if ( weekLstView && views->visibleWidget() == weekLstView ) {
339 d = weekLstView->date(); 343 d = weekLstView->date();
340 } else if ( monthView && views->visibleWidget() == monthView ) { 344 } else if ( monthView && views->visibleWidget() == monthView ) {
341 d = monthView->selectedDate(); 345 d = monthView->selectedDate();
342 } 346 }
343 347
344 return d; 348 return d;
345} 349}
346 350
347void DateBook::view(int v, const QDate &d) { 351void DateBook::view(int v, const QDate &d) {
348 if (v==DAY) { 352 if (v==DAY) {
349 initDay(); 353 initDay();
350 dayAction->setOn( TRUE ); 354 dayAction->setOn( TRUE );
351 dayView->setDate( d ); 355 dayView->setDate( d );
352 views->raiseWidget( dayView ); 356 views->raiseWidget( dayView );
353 dayView->redraw(); 357 dayView->redraw();
354 } else if (v==WEEK) { 358 } else if (v==WEEK) {
355 initWeek(); 359 initWeek();
356 weekAction->setOn( TRUE ); 360 weekAction->setOn( TRUE );
357 weekView->setDate( d ); 361 weekView->setDate( d );
358 views->raiseWidget( weekView ); 362 views->raiseWidget( weekView );
359 weekView->redraw(); 363 weekView->redraw();
360 } else if (v==WEEKLST) { 364 } else if (v==WEEKLST) {
@@ -996,232 +1000,212 @@ void DateBook::slotDoFind( const QString& txt, const QDate &dt,
996 } 1000 }
997 static QDate searchDate = dt; 1001 static QDate searchDate = dt;
998 // if true at the end we will start at the begin again and afterwards 1002 // if true at the end we will start at the begin again and afterwards
999 // we will emit string not found 1003 // we will emit string not found
1000 static bool wrapAround = true; 1004 static bool wrapAround = true;
1001 bool candidtate; 1005 bool candidtate;
1002 candidtate = false; 1006 candidtate = false;
1003 1007
1004 QValueList<Event> repeats = db->getRawRepeats(); 1008 QValueList<Event> repeats = db->getRawRepeats();
1005 1009
1006 // find the candidate for the first repeat that matches... 1010 // find the candidate for the first repeat that matches...
1007 // first check if there can ever be a match and then compute 1011 // first check if there can ever be a match and then compute
1008 // the next occurence from start. See if this event is closer 1012 // the next occurence from start. See if this event is closer
1009 // to the beginning (start. next < dtEnd) and not smaller then the last 1013 // to the beginning (start. next < dtEnd) and not smaller then the last
1010 // result. If we find a canditate we set the dtEnd to the time 1014 // result. If we find a canditate we set the dtEnd to the time
1011 // of the ocurrence and rev to this occurence. 1015 // of the ocurrence and rev to this occurence.
1012 // set wrap around to true because there might be more events coming 1016 // set wrap around to true because there might be more events coming
1013 // and we're not at the end. 1017 // and we're not at the end.
1014 QValueListConstIterator<Event> it; 1018 QValueListConstIterator<Event> it;
1015 QDate start = dt; 1019 QDate start = dt;
1016 for ( it = repeats.begin(); it != repeats.end(); ++it ) { 1020 for ( it = repeats.begin(); it != repeats.end(); ++it ) {
1017 if ( catComp( (*it).categories(), category ) ) { 1021 if ( catComp( (*it).categories(), category ) ) {
1018 if ( (*it).match( r ) ) { 1022 if ( (*it).match( r ) ) {
1019 if ( nextOccurance( *it, start, next ) ) { 1023 if ( nextOccurance( *it, start, next ) ) {
1020 if ( next < dtEnd && !(next <= rev.start() ) ) { 1024 if ( next < dtEnd && !(next <= rev.start() ) ) {
1021 rev = *it; 1025 rev = *it;
1022 dtEnd = next; 1026 dtEnd = next;
1023 rev.setStart( next ); 1027 rev.setStart( next );
1024 candidtate = true; 1028 candidtate = true;
1025 wrapAround = true; 1029 wrapAround = true;
1026 } 1030 }
1027 } 1031 }
1028 } 1032 }
1029 } 1033 }
1030 } 1034 }
1031 1035
1032 // now the for first non repeat... 1036 // now the for first non repeat...
1033 // dtEnd is set by the previous iteration of repeatingEvents 1037 // dtEnd is set by the previous iteration of repeatingEvents
1034 // check if we find a closer item. Also set dtEnd to find even 1038 // check if we find a closer item. Also set dtEnd to find even
1035 // more close occurrence 1039 // more close occurrence
1036 QValueList<Event> nonRepeats = db->getNonRepeatingEvents( dt, dtEnd.date() ); 1040 QValueList<Event> nonRepeats = db->getNonRepeatingEvents( dt, dtEnd.date() );
1037 qHeapSort( nonRepeats.begin(), nonRepeats.end() ); 1041 qHeapSort( nonRepeats.begin(), nonRepeats.end() );
1038 for ( it = nonRepeats.begin(); it != nonRepeats.end(); ++it ) { 1042 for ( it = nonRepeats.begin(); it != nonRepeats.end(); ++it ) {
1039 if ( catComp( (*it).categories(), category ) ) { 1043 if ( catComp( (*it).categories(), category ) ) {
1040 if ( (*it).start() < dtEnd ) { 1044 if ( (*it).start() < dtEnd ) {
1041 if ( (*it).match( r ) && !(*it <= nonrev) ) { 1045 if ( (*it).match( r ) && !(*it <= nonrev) ) {
1042 nonrev = *it; 1046 nonrev = *it;
1043 dtEnd = nonrev.start(); 1047 dtEnd = nonrev.start();
1044 candidtate = true; 1048 candidtate = true;
1045 wrapAround = true; 1049 wrapAround = true;
1046 break; 1050 break;
1047 } 1051 }
1048 } 1052 }
1049 } 1053 }
1050 } 1054 }
1051 if ( candidtate ) { 1055 if ( candidtate ) {
1052 dayView->setStartViewTime( dtEnd.time().hour() ); 1056 dayView->setStartViewTime( dtEnd.time().hour() );
1053 dayView->setDate( dtEnd.date().year(), dtEnd.date().month(), 1057 dayView->setDate( dtEnd.date().year(), dtEnd.date().month(),
1054 dtEnd.date().day() ); 1058 dtEnd.date().day() );
1055 } else { 1059 } else {
1056 if ( wrapAround ) { 1060 if ( wrapAround ) {
1057 emit signalWrapAround(); 1061 emit signalWrapAround();
1058 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); 1062 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) );
1059 nonrev.setStart( rev.start() ); 1063 nonrev.setStart( rev.start() );
1060 } else 1064 } else
1061 emit signalNotFound(); 1065 emit signalNotFound();
1062 wrapAround = !wrapAround; 1066 wrapAround = !wrapAround;
1063 } 1067 }
1064} 1068}
1065 1069
1066Event DateBookDBHack::eventByUID(int uid) { 1070Event DateBookDBHack::eventByUID(int uid) {
1067 1071
1068 // FIXME: Dirty Hacks to get hold of the private event lists 1072 // FIXME: Dirty Hacks to get hold of the private event lists
1069 QDate start; 1073 QDate start;
1070 QDate end=start.addDays(-1); 1074 QDate end=start.addDays(-1);
1071 QValueList<Event> myEventList=getNonRepeatingEvents(start,end); 1075 QValueList<Event> myEventList=getNonRepeatingEvents(start,end);
1072 QValueList<Event> myRepeatEvents=getRawRepeats(); 1076 QValueList<Event> myRepeatEvents=getRawRepeats();
1073 1077
1074 QValueList<Event>::ConstIterator it; 1078 QValueList<Event>::ConstIterator it;
1075 1079
1076 for (it = myEventList.begin(); it != myEventList.end(); it++) { 1080 for (it = myEventList.begin(); it != myEventList.end(); it++) {
1077 if ((*it).uid() == uid) return *it; 1081 if ((*it).uid() == uid) return *it;
1078 } 1082 }
1079 for (it = myRepeatEvents.begin(); it != myRepeatEvents.end(); it++) { 1083 for (it = myRepeatEvents.begin(); it != myRepeatEvents.end(); it++) {
1080 if ((*it).uid() == uid) return *it; 1084 if ((*it).uid() == uid) return *it;
1081 } 1085 }
1082 1086
1083 Event ev; 1087 Event ev;
1084 return ev; // return at least 1088 return ev; // return at least
1085} 1089}
1086 1090
1087DateBookHoliday::DateBookHoliday() 1091DateBookHoliday::DateBookHoliday()
1088{ 1092{
1089 _pluginlist.clear(); 1093 _pluginlist.clear();
1090 m_pluginLoader = new Opie::Core::OPluginLoader("holidays",false); 1094 m_pluginLoader = new Opie::Core::OPluginLoader("holidays",false);
1091 m_pluginLoader->setAutoDelete(true); 1095 m_pluginLoader->setAutoDelete(true);
1096 m_pluginManager = new Opie::Core::OPluginManager(m_pluginLoader);
1097 m_pluginManager->load();
1098
1099 init();
1100}
1101
1102void DateBookHoliday::reloadPlugins()
1103{
1104 deinit();
1092 init(); 1105 init();
1093} 1106}
1094 1107
1095DateBookHoliday::~DateBookHoliday() 1108DateBookHoliday::~DateBookHoliday()
1096{ 1109{
1097 deinit(); 1110 deinit();
1098 delete m_pluginLoader; 1111 delete m_pluginLoader;
1112 delete m_pluginManager;
1099} 1113}
1100 1114
1101void DateBookHoliday::deinit() 1115void DateBookHoliday::deinit()
1102{ 1116{
1103/*
1104 QValueList<HPlugin*>::Iterator it; 1117 QValueList<HPlugin*>::Iterator it;
1105 for (it=_pluginlist.begin();it!=_pluginlist.end();++it) { 1118 for (it=_pluginlist.begin();it!=_pluginlist.end();++it) {
1106 HPlugin*_pl = *it; 1119 HPlugin*_pl = *it;
1107 // destructs itself? 1120 *it = 0;
1108 _pl->_if->release();
1109 _pl->_lib->unload();
1110 delete _pl->_lib;
1111 delete _pl; 1121 delete _pl;
1112 } 1122 }
1113 _pluginlist.clear(); 1123 _pluginlist.clear();
1114*/
1115} 1124}
1116 1125
1117#if 0 1126#if 0
1118void debugLst( const Opie::Core::OPluginItem::List& lst ) { 1127void debugLst( const Opie::Core::OPluginItem::List& lst ) {
1119 for ( Opie::Core::OPluginItem::List::ConstIterator it = lst.begin(); it != lst.end(); ++it ) 1128 for ( Opie::Core::OPluginItem::List::ConstIterator it = lst.begin(); it != lst.end(); ++it )
1120 odebug << "Name " << (*it).name() << " " << (*it).path() << " " << (*it).position() << oendl; 1129 odebug << "Name " << (*it).name() << " " << (*it).path() << " " << (*it).position() << oendl;
1121} 1130}
1122#endif 1131#endif
1123 1132
1124void DateBookHoliday::init() 1133void DateBookHoliday::init()
1125{ 1134{
1126#if 0
1127 deinit(); 1135 deinit();
1128#endif 1136
1129 Opie::Core::OPluginItem::List lst = m_pluginLoader->allAvailable( false ); 1137 Opie::Core::OPluginItem::List lst = m_pluginLoader->filtered(true);
1130// debugLst( lst ); 1138// debugLst( lst );
1131 for( Opie::Core::OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ){ 1139 for( Opie::Core::OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ){
1132 Opie::Datebook::HolidayPluginIf*hif = m_pluginLoader->load<Opie::Datebook::HolidayPluginIf>(*it,IID_HOLIDAY_PLUGIN); 1140 Opie::Datebook::HolidayPluginIf*hif = m_pluginLoader->load<Opie::Datebook::HolidayPluginIf>(*it,IID_HOLIDAY_PLUGIN);
1133 if (hif) { 1141 if (hif) {
1134 Opie::Datebook::HolidayPlugin*pl = hif->plugin(); 1142 Opie::Datebook::HolidayPlugin*pl = hif->plugin();
1135 if (pl) { 1143 if (pl) {
1136 HPlugin*_pl=new HPlugin; 1144 HPlugin*_pl=new HPlugin;
1137 _pl->_plugin = pl; 1145 _pl->_plugin = pl;
1138 odebug << "Found holiday " << pl->description()<<oendl; 1146 odebug << "Found holiday " << pl->description()<<oendl;
1139 _pluginlist.append(_pl); 1147 _pluginlist.append(_pl);
1140 //_pl->_if = hif; 1148 //_pl->_if = hif;
1141 } 1149 }
1142 } 1150 }
1143 } 1151 }
1144#if 0
1145 QString path = QPEApplication::qpeDir() + "plugins/datebook/holiday";
1146 QDir dir( path, "lib*.so" );
1147 QStringList list = dir.entryList();
1148 QStringList::Iterator it;
1149 for (it=list.begin();it!=list.end();++it) {
1150 Opie::Datebook::HolidayPluginIf*hif = 0;
1151 QLibrary*lib=new QLibrary(path+"/"+*it);
1152 if ((lib->queryInterface(IID_HOLIDAY_PLUGIN,(QUnknownInterface**)&hif) == QS_OK) && hif) {
1153 Opie::Datebook::HolidayPlugin*pl = hif->plugin();
1154 if (pl) {
1155 HPlugin*_pl=new HPlugin;
1156 _pl->_plugin = pl;
1157 odebug << "Found holiday " << pl->description()<<oendl;
1158 _pl->_lib = lib;
1159 _pl->_if = hif;
1160 _pluginlist.append(_pl);
1161 } else {
1162 }
1163 } else {
1164 delete lib;
1165 }
1166 }
1167#endif
1168} 1152}
1169 1153
1170QStringList DateBookHoliday::holidaylist(const QDate&aDate) 1154QStringList DateBookHoliday::holidaylist(const QDate&aDate)
1171{ 1155{
1172 QStringList ret; 1156 QStringList ret;
1173 QValueList<HPlugin*>::Iterator it; 1157 QValueList<HPlugin*>::Iterator it;
1174 for (it=_pluginlist.begin();it!=_pluginlist.end();++it) { 1158 for (it=_pluginlist.begin();it!=_pluginlist.end();++it) {
1175 HPlugin*_pl = *it; 1159 HPlugin*_pl = *it;
1176 ret+=_pl->_plugin->entries(aDate); 1160 ret+=_pl->_plugin->entries(aDate);
1177 } 1161 }
1178 return ret; 1162 return ret;
1179} 1163}
1180 1164
1181QStringList DateBookHoliday::holidaylist(unsigned year, unsigned month, unsigned day) 1165QStringList DateBookHoliday::holidaylist(unsigned year, unsigned month, unsigned day)
1182{ 1166{
1183 return holidaylist(QDate(year,month,day)); 1167 return holidaylist(QDate(year,month,day));
1184} 1168}
1185 1169
1186QValueList<EffectiveEvent> DateBookHoliday::getEffectiveEvents(const QDate &from,const QDate &to ) 1170QValueList<EffectiveEvent> DateBookHoliday::getEffectiveEvents(const QDate &from,const QDate &to )
1187{ 1171{
1188 QValueList<EffectiveEvent> ret; 1172 QValueList<EffectiveEvent> ret;
1189 QValueList<HPlugin*>::Iterator it; 1173 QValueList<HPlugin*>::Iterator it;
1190 for (it=_pluginlist.begin();it!=_pluginlist.end();++it) { 1174 for (it=_pluginlist.begin();it!=_pluginlist.end();++it) {
1191 HPlugin*_pl = *it; 1175 HPlugin*_pl = *it;
1192 ret+=_pl->_plugin->events(from,to); 1176 ret+=_pl->_plugin->events(from,to);
1193 } 1177 }
1194 return ret; 1178 return ret;
1195} 1179}
1196 1180
1197QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEventsNoHoliday(const QDate &from,const QDate &to ) 1181QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEventsNoHoliday(const QDate &from,const QDate &to )
1198{ 1182{
1199 return DateBookDBHack::getEffectiveEvents(from,to); 1183 return DateBookDBHack::getEffectiveEvents(from,to);
1200} 1184}
1201 1185
1202QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEventsNoHoliday(const QDateTime &start) 1186QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEventsNoHoliday(const QDateTime &start)
1203{ 1187{
1204 return DateBookDBHack::getEffectiveEvents(start); 1188 return DateBookDBHack::getEffectiveEvents(start);
1205} 1189}
1206 1190
1207QValueList<EffectiveEvent> DateBookHoliday::getEffectiveEvents(const QDateTime &start) 1191QValueList<EffectiveEvent> DateBookHoliday::getEffectiveEvents(const QDateTime &start)
1208{ 1192{
1209 return getEffectiveEvents(start.date(),start.date()); 1193 return getEffectiveEvents(start.date(),start.date());
1210} 1194}
1211 1195
1212QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEvents(const QDate &from,const QDate &to ) 1196QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEvents(const QDate &from,const QDate &to )
1213{ 1197{
1214 QValueList<EffectiveEvent> ret; 1198 QValueList<EffectiveEvent> ret;
1215 odebug << "Ueberlagert 1" << oendl; 1199 odebug << "Ueberlagert 1" << oendl;
1216 if (db_holiday) { 1200 if (db_holiday) {
1217 ret+=db_holiday->getEffectiveEvents(from,to); 1201 ret+=db_holiday->getEffectiveEvents(from,to);
1218 } 1202 }
1219 ret+=getEffectiveEventsNoHoliday(from,to); 1203 ret+=getEffectiveEventsNoHoliday(from,to);
1220 return ret; 1204 return ret;
1221} 1205}
1222 1206
1223QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEvents( const QDateTime &start) 1207QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEvents( const QDateTime &start)
1224{ 1208{
1225 odebug << "Ueberlagert 2" << oendl; 1209 odebug << "Ueberlagert 2" << oendl;
1226 return DateBookDBHack::getEffectiveEvents(start); 1210 return DateBookDBHack::getEffectiveEvents(start);
1227} 1211}
diff --git a/core/pim/datebook/datebookday.cpp b/core/pim/datebook/datebookday.cpp
index 00ddd05..26f0303 100644
--- a/core/pim/datebook/datebookday.cpp
+++ b/core/pim/datebook/datebookday.cpp
@@ -270,196 +270,197 @@ void DateBookDay::setRowStyle( int style )
270 if (rowStyle != style) view->setRowStyle( style ); 270 if (rowStyle != style) view->setRowStyle( style );
271 rowStyle = style; 271 rowStyle = style;
272} 272}
273 273
274void DateBookDay::updateView( void ) 274void DateBookDay::updateView( void )
275{ 275{
276 timeMarker->setTime( QTime::currentTime() ); 276 timeMarker->setTime( QTime::currentTime() );
277 //need to find a way to update all DateBookDayWidgets 277 //need to find a way to update all DateBookDayWidgets
278} 278}
279 279
280void DateBookDay::setSelectedWidget( DateBookDayWidget *w ) 280void DateBookDay::setSelectedWidget( DateBookDayWidget *w )
281{ 281{
282 selectedWidget = w; 282 selectedWidget = w;
283} 283}
284 284
285DateBookDayWidget * DateBookDay::getSelectedWidget( void ) 285DateBookDayWidget * DateBookDay::getSelectedWidget( void )
286{ 286{
287 return selectedWidget; 287 return selectedWidget;
288} 288}
289 289
290void DateBookDay::selectedDates( QDateTime &start, QDateTime &end ) 290void DateBookDay::selectedDates( QDateTime &start, QDateTime &end )
291{ 291{
292 start.setDate( currDate ); 292 start.setDate( currDate );
293 end.setDate( currDate ); 293 end.setDate( currDate );
294 294
295 int sh=99,eh=-1; 295 int sh=99,eh=-1;
296 296
297 int n = dayView()->numSelections(); 297 int n = dayView()->numSelections();
298 298
299 for (int i=0; i<n; i++) { 299 for (int i=0; i<n; i++) {
300 QTableSelection sel = dayView()->selection( i ); 300 QTableSelection sel = dayView()->selection( i );
301 sh = QMIN(sh,sel.topRow()); 301 sh = QMIN(sh,sel.topRow());
302 eh = QMAX(sh,sel.bottomRow()+1); 302 eh = QMAX(sh,sel.bottomRow()+1);
303 } 303 }
304 304
305 if (sh > 23 || eh < 1) { 305 if (sh > 23 || eh < 1) {
306 sh=8; 306 sh=8;
307 eh=9; 307 eh=9;
308 } 308 }
309 309
310 start.setTime( QTime( sh, 0, 0 ) ); 310 start.setTime( QTime( sh, 0, 0 ) );
311 end.setTime( QTime( eh, 0, 0 ) ); 311 end.setTime( QTime( eh, 0, 0 ) );
312} 312}
313 313
314void DateBookDay::setDate( int y, int m, int d ) 314void DateBookDay::setDate( int y, int m, int d )
315{ 315{
316 header->setDate( y, m, d ); 316 header->setDate( y, m, d );
317 selectedWidget = 0; 317 selectedWidget = 0;
318} 318}
319 319
320void DateBookDay::setDate( QDate d) 320void DateBookDay::setDate( QDate d)
321{ 321{
322 header->setDate( d.year(), d.month(), d.day() ); 322 header->setDate( d.year(), d.month(), d.day() );
323 selectedWidget = 0; 323 selectedWidget = 0;
324} 324}
325 325
326void DateBookDay::dateChanged( int y, int m, int d ) 326void DateBookDay::dateChanged( int y, int m, int d )
327{ 327{
328 QDate date( y, m, d ); 328 QDate date( y, m, d );
329 if ( currDate == date ) 329 if ( currDate == date )
330 return; 330 return;
331 currDate.setYMD( y, m, d ); 331 currDate.setYMD( y, m, d );
332 relayoutPage(); 332 relayoutPage();
333 dayView()->clearSelection(); 333 dayView()->clearSelection();
334 QTableSelection ts; 334 QTableSelection ts;
335 335
336 if (jumpToCurTime && this->date() == QDate::currentDate()) 336 if (jumpToCurTime && this->date() == QDate::currentDate())
337 { 337 {
338 ts.init( QTime::currentTime().hour(), 0); 338 ts.init( QTime::currentTime().hour(), 0);
339 ts.expandTo( QTime::currentTime().hour(), 0); 339 ts.expandTo( QTime::currentTime().hour(), 0);
340 } else { 340 } else {
341 ts.init( startTime, 0 ); 341 ts.init( startTime, 0 );
342 ts.expandTo( startTime, 0 ); 342 ts.expandTo( startTime, 0 );
343 } 343 }
344 344
345 dayView()->addSelection( ts ); 345 dayView()->addSelection( ts );
346 selectedWidget = 0; 346 selectedWidget = 0;
347} 347}
348 348
349void DateBookDay::redraw() 349void DateBookDay::redraw()
350{ 350{
351 if ( isUpdatesEnabled() ) 351 if ( isUpdatesEnabled() )
352 relayoutPage(); 352 relayoutPage();
353} 353}
354 354
355void DateBookDay::getEvents() 355void DateBookDay::getEvents()
356{ 356{
357 widgetList.clear(); 357 widgetList.clear();
358 358
359 /* clear the AllDay List */ 359 /* clear the AllDay List */
360 m_allDays->hide(); // just in case 360 m_allDays->hide(); // just in case
361 m_allDays->removeAllEvents(); 361 m_allDays->removeAllEvents();
362 362
363 QStringList hdays = _holiday_db->holidaylist(currDate); 363 QStringList hdays = _holiday_db->holidaylist(currDate);
364 QStringList::Iterator sit; 364 QStringList::Iterator sit;
365 QObject* object = 0; 365 QObject* object = 0;
366
367 /* this way we make sure that holiday dummy events are always
368 on top of the widgetlist. */
366 for (sit=hdays.begin();sit!=hdays.end();++sit) { 369 for (sit=hdays.begin();sit!=hdays.end();++sit) {
367 object = m_allDays->addHoliday(*sit); 370 m_allDays->addHoliday(*sit);
368 if (!object) continue;
369 /* not to do something with it */
370 } 371 }
371 QValueList<EffectiveEvent> eventList = db->getEffectiveEventsNoHoliday( currDate, currDate ); 372 QValueList<EffectiveEvent> eventList = db->getEffectiveEventsNoHoliday( currDate, currDate );
372 QValueListIterator<EffectiveEvent> it; 373 QValueListIterator<EffectiveEvent> it;
373 374
374 for ( it = eventList.begin(); it != eventList.end(); ++it ) { 375 for ( it = eventList.begin(); it != eventList.end(); ++it ) {
375 EffectiveEvent ev=*it; 376 EffectiveEvent ev=*it;
376 if(!((ev.end().hour()==0) && (ev.end().minute()==0) && (ev.startDate()!=ev.date()))) { // Skip events ending at 00:00 starting at another day. 377 if(!((ev.end().hour()==0) && (ev.end().minute()==0) && (ev.startDate()!=ev.date()))) { // Skip events ending at 00:00 starting at another day.
377 if (ev.event().type() == Event::AllDay ) { 378 if (ev.event().type() == Event::AllDay ) {
378 object = m_allDays->addEvent( ev ); 379 object = m_allDays->addEvent( ev );
379 if (!object) 380 if (!object)
380 continue; 381 continue;
381 }else { 382 }else {
382 DateBookDayWidget* w = new DateBookDayWidget( *it, this ); 383 DateBookDayWidget* w = new DateBookDayWidget( *it, this );
383 widgetList.append( w ); 384 widgetList.append( w );
384 object = w; 385 object = w;
385 } 386 }
386 387
387 connect( object, SIGNAL( deleteMe(const Event&) ), this, SIGNAL( removeEvent(const Event&) ) ); 388 connect( object, SIGNAL( deleteMe(const Event&) ), this, SIGNAL( removeEvent(const Event&) ) );
388 connect( object, SIGNAL( duplicateMe(const Event&) ), this, SIGNAL( duplicateEvent(const Event&) ) ); 389 connect( object, SIGNAL( duplicateMe(const Event&) ), this, SIGNAL( duplicateEvent(const Event&) ) );
389 connect( object, SIGNAL( editMe(const Event&) ), this, SIGNAL( editEvent(const Event&) ) ); 390 connect( object, SIGNAL( editMe(const Event&) ), this, SIGNAL( editEvent(const Event&) ) );
390 connect( object, SIGNAL( beamMe(const Event&) ), this, SIGNAL( beamEvent(const Event&) ) ); 391 connect( object, SIGNAL( beamMe(const Event&) ), this, SIGNAL( beamEvent(const Event&) ) );
391 392
392 } 393 }
393 } 394 }
394} 395}
395 396
396static int place( const DateBookDayWidget *item, bool *used, int maxn ) 397static int place( const DateBookDayWidget *item, bool *used, int maxn )
397{ 398{
398 int place = 0; 399 int place = 0;
399 int start = item->event().start().hour(); 400 int start = item->event().start().hour();
400 QTime e = item->event().end(); 401 QTime e = item->event().end();
401 int end = e.hour(); 402 int end = e.hour();
402 if ( e.minute() < 5 ) 403 if ( e.minute() < 5 )
403 end--; 404 end--;
404 if ( end < start ) 405 if ( end < start )
405 end = start; 406 end = start;
406 while ( place < maxn ) { 407 while ( place < maxn ) {
407 bool free = TRUE; 408 bool free = TRUE;
408 int s = start; 409 int s = start;
409 while( s <= end ) { 410 while( s <= end ) {
410 if ( used[10*s+place] ) { 411 if ( used[10*s+place] ) {
411 free = FALSE; 412 free = FALSE;
412 break; 413 break;
413 } 414 }
414 s++; 415 s++;
415 } 416 }
416 if ( free ) 417 if ( free )
417 break; 418 break;
418 place++; 419 place++;
419 } 420 }
420 if ( place == maxn ) { 421 if ( place == maxn ) {
421 return -1; 422 return -1;
422 } 423 }
423 while( start <= end ) { 424 while( start <= end ) {
424 used[10*start+place] = TRUE; 425 used[10*start+place] = TRUE;
425 start++; 426 start++;
426 } 427 }
427 return place; 428 return place;
428} 429}
429 430
430 431
431void DateBookDay::relayoutPage( bool fromResize ) 432void DateBookDay::relayoutPage( bool fromResize )
432{ 433{
433 setUpdatesEnabled( FALSE ); 434 setUpdatesEnabled( FALSE );
434 if ( !fromResize ) { 435 if ( !fromResize ) {
435 getEvents(); // no need we already have them! 436 getEvents(); // no need we already have them!
436 437
437 if (m_allDays->items() > 0 ) 438 if (m_allDays->items() > 0 )
438 m_allDays->show(); 439 m_allDays->show();
439 /* 440 /*
440 * else if ( m_allDays->items() == 0 ) already hide in getEvents 441 * else if ( m_allDays->items() == 0 ) already hide in getEvents
441 */ 442 */
442 } 443 }
443 444
444 widgetList.sort(); 445 widgetList.sort();
445 //sorts the widgetList by the heights of the widget so that the tallest widgets are at the beginning 446 //sorts the widgetList by the heights of the widget so that the tallest widgets are at the beginning
446 //this is needed for the simple algo below to work correctly, otherwise some widgets would be drawn outside the view 447 //this is needed for the simple algo below to work correctly, otherwise some widgets would be drawn outside the view
447 448
448 int wCount = widgetList.count(); 449 int wCount = widgetList.count();
449 int wid = view->columnWidth(0)-1; 450 int wid = view->columnWidth(0)-1;
450 int wd; 451 int wd;
451 int n = 1; 452 int n = 1;
452 453
453 QArray<int> anzIntersect(wCount); //this stores the number of maximal intersections of each widget 454 QArray<int> anzIntersect(wCount); //this stores the number of maximal intersections of each widget
454 455
455 for (int i = 0; i<wCount; anzIntersect[i] = 1, i++); 456 for (int i = 0; i<wCount; anzIntersect[i] = 1, i++);
456 457
457 if ( wCount < 20 ) { 458 if ( wCount < 20 ) {
458 459
459 QArray<QRect> geometries(wCount); 460 QArray<QRect> geometries(wCount);
460 for (int i = 0; i < wCount; geometries[i] = widgetList.at(i)->geometry(), i++); //stores geometry for each widget in vector 461 for (int i = 0; i < wCount; geometries[i] = widgetList.at(i)->geometry(), i++); //stores geometry for each widget in vector
461 462
462 for ( int i = 0; i < wCount; i++) { 463 for ( int i = 0; i < wCount; i++) {
463 QValueList<int> intersectedWidgets; 464 QValueList<int> intersectedWidgets;
464 465
465 //find all widgets intersecting with widgetList.at(i) 466 //find all widgets intersecting with widgetList.at(i)
diff --git a/core/pim/datebook/datebookdayallday.cpp b/core/pim/datebook/datebookdayallday.cpp
index 5b40246..27fce44 100644
--- a/core/pim/datebook/datebookdayallday.cpp
+++ b/core/pim/datebook/datebookdayallday.cpp
@@ -99,171 +99,171 @@ DatebookAlldayDisp::DatebookAlldayDisp(DateBookDB *db,const EffectiveEvent& ev,
99 99
100 int s = QFontMetrics(font()).height()+4; 100 int s = QFontMetrics(font()).height()+4;
101 setMaximumHeight( s ); 101 setMaximumHeight( s );
102 setMinimumSize( QSize( 0, s ) ); 102 setMinimumSize( QSize( 0, s ) );
103 m_holiday = false; 103 m_holiday = false;
104} 104}
105 105
106DatebookAlldayDisp::DatebookAlldayDisp(const QString&aholiday,QWidget* parent,const char* name, WFlags fl) 106DatebookAlldayDisp::DatebookAlldayDisp(const QString&aholiday,QWidget* parent,const char* name, WFlags fl)
107 : QLabel(parent,name,fl),m_Ev(),dateBook(0) 107 : QLabel(parent,name,fl),m_Ev(),dateBook(0)
108{ 108{
109 QString strDesc = aholiday; 109 QString strDesc = aholiday;
110 strDesc = strDesc.replace(QRegExp("<"),"&#60;"); 110 strDesc = strDesc.replace(QRegExp("<"),"&#60;");
111 Event ev; 111 Event ev;
112 ev.setDescription(strDesc); 112 ev.setDescription(strDesc);
113 ev.setAllDay(true); 113 ev.setAllDay(true);
114 m_Ev.setEvent(ev); 114 m_Ev.setEvent(ev);
115 setText(strDesc); 115 setText(strDesc);
116 116
117 setAlignment(AlignHCenter); 117 setAlignment(AlignHCenter);
118 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum)); 118 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum));
119 119
120 //setFrameStyle(QFrame::Raised|QFrame::Panel); 120 //setFrameStyle(QFrame::Raised|QFrame::Panel);
121 //setBackgroundColor(yellow); 121 //setBackgroundColor(yellow);
122 122
123 int s = QFontMetrics(font()).height()+4; 123 int s = QFontMetrics(font()).height()+4;
124 setMaximumHeight( s ); 124 setMaximumHeight( s );
125 setMinimumSize( QSize( 0, s ) ); 125 setMinimumSize( QSize( 0, s ) );
126 126
127 m_holiday = true; 127 m_holiday = true;
128} 128}
129 129
130DatebookAlldayDisp::~DatebookAlldayDisp() 130DatebookAlldayDisp::~DatebookAlldayDisp()
131{ 131{
132} 132}
133 133
134void DatebookAlldayDisp::beam_single_event() 134void DatebookAlldayDisp::beam_single_event()
135{ 135{
136 if (m_holiday) return; 136 if (m_holiday) return;
137 // create an Event and beam it... 137 // create an Event and beam it...
138 /* 138 /*
139 * Start with the easy stuff. If start and end date is the same we can just use 139 * Start with the easy stuff. If start and end date is the same we can just use
140 * the values of effective m_Events 140 * 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... 141 * If it is a multi day m_Event we need to find the real start and end date...
142 */ 142 */
143 if ( m_Ev.event().start().date() == m_Ev.event().end().date() ) { 143 if ( m_Ev.event().start().date() == m_Ev.event().end().date() ) {
144 Event m_Event( m_Ev.event() ); 144 Event m_Event( m_Ev.event() );
145 145
146 QDateTime dt( m_Ev.date(), m_Ev.start() ); 146 QDateTime dt( m_Ev.date(), m_Ev.start() );
147 m_Event.setStart( dt ); 147 m_Event.setStart( dt );
148 148
149 dt.setTime( m_Ev.end() ); 149 dt.setTime( m_Ev.end() );
150 m_Event.setEnd( dt ); 150 m_Event.setEnd( dt );
151 emit beamMe( m_Event ); 151 emit beamMe( m_Event );
152 }else { 152 }else {
153 /* 153 /*
154 * at least the the Times are right now 154 * at least the the Times are right now
155 */ 155 */
156 QDateTime start( m_Ev.event().start() ); 156 QDateTime start( m_Ev.event().start() );
157 QDateTime end ( m_Ev.event().end () ); 157 QDateTime end ( m_Ev.event().end () );
158 158
159 /* 159 /*
160 * ok we know the start date or we need to find it 160 * ok we know the start date or we need to find it
161 */ 161 */
162 if ( m_Ev.start() != QTime( 0, 0, 0 ) ) { 162 if ( m_Ev.start() != QTime( 0, 0, 0 ) ) {
163 start.setDate( m_Ev.date() ); 163 start.setDate( m_Ev.date() );
164 }else { 164 }else {
165 QDate dt = DateBookDay::findRealStart( m_Ev.event().uid(), m_Ev.date(), dateBook ); 165 QDate dt = DateBookDay::findRealStart( m_Ev.event().uid(), m_Ev.date(), dateBook );
166 start.setDate( dt ); 166 start.setDate( dt );
167 } 167 }
168 168
169 /* 169 /*
170 * ok we know now the end date... 170 * ok we know now the end date...
171 * else 171 * else
172 * get to know the offset btw the real start and real end 172 * get to know the offset btw the real start and real end
173 * and then add it to the new start date... 173 * and then add it to the new start date...
174 */ 174 */
175 if ( m_Ev.end() != QTime(23, 59, 59 ) ) { 175 if ( m_Ev.end() != QTime(23, 59, 59 ) ) {
176 end.setDate( m_Ev.date() ); 176 end.setDate( m_Ev.date() );
177 }else{ 177 }else{
178 int days = m_Ev.event().start().date().daysTo( m_Ev.event().end().date() ); 178 int days = m_Ev.event().start().date().daysTo( m_Ev.event().end().date() );
179 end.setDate( start.date().addDays( days ) ); 179 end.setDate( start.date().addDays( days ) );
180 } 180 }
181 Event m_Event( m_Ev.event() ); 181 Event m_Event( m_Ev.event() );
182 m_Event.setStart( start ); 182 m_Event.setStart( start );
183 m_Event.setEnd ( end ); 183 m_Event.setEnd ( end );
184 emit beamMe( m_Event ); 184 emit beamMe( m_Event );
185 } 185 }
186} 186}
187 187
188void DatebookAlldayDisp::mousePressEvent(QMouseEvent*e) 188void DatebookAlldayDisp::mousePressEvent(QMouseEvent*e)
189{ 189{
190 Event ev = m_Ev.event(); 190 Event ev = m_Ev.event();
191 QColor b = backgroundColor(); 191 QColor b = backgroundColor();
192 setBackgroundColor(green); 192 setBackgroundColor(green);
193 update(); 193 update();
194 QPopupMenu m; 194 QPopupMenu m;
195 if (!m_holiday) { 195 if (ev.isValidUid()) {
196 m.insertItem( DateBookDayWidget::tr( "Edit" ), 1 ); 196 m.insertItem( DateBookDayWidget::tr( "Edit" ), 1 );
197 m.insertItem( DateBookDayWidget::tr( "Duplicate" ), 4 ); 197 m.insertItem( DateBookDayWidget::tr( "Duplicate" ), 4 );
198 m.insertItem( DateBookDayWidget::tr( "Delete" ), 2 ); 198 m.insertItem( DateBookDayWidget::tr( "Delete" ), 2 );
199 if(Ir::supported()) m.insertItem( DateBookDayWidget::tr( "Beam" ), 3 ); 199 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 ); 200 if(Ir::supported() && m_Ev.event().doRepeat() ) m.insertItem( DateBookDayWidget::tr( "Beam this occurence"), 5 );
201 } 201 }
202 m.insertItem( tr( "Info"),6); 202 m.insertItem( tr( "Info"),6);
203 int r = m.exec( e->globalPos() ); 203 int r = m.exec( e->globalPos() );
204 setBackgroundColor(b); 204 setBackgroundColor(b);
205 update(); 205 update();
206 switch (r) { 206 switch (r) {
207 case 1: 207 case 1:
208 emit editMe( ev ); 208 emit editMe( ev );
209 break; 209 break;
210 case 2: 210 case 2:
211 emit deleteMe( ev ); 211 emit deleteMe( ev );
212 break; 212 break;
213 case 3: 213 case 3:
214 emit beamMe( ev ); 214 emit beamMe( ev );
215 break; 215 break;
216 case 4: 216 case 4:
217 emit duplicateMe( ev ); 217 emit duplicateMe( ev );
218 break; 218 break;
219 case 5: 219 case 5:
220 beam_single_event(); 220 beam_single_event();
221 break; 221 break;
222 case 6: 222 case 6:
223 emit displayMe( ev ); 223 emit displayMe( ev );
224 break; 224 break;
225 default: 225 default:
226 break; 226 break;
227 } 227 }
228} 228}
229 229
230DatebookEventDesc::DatebookEventDesc(QWidget*parent,const char*name) 230DatebookEventDesc::DatebookEventDesc(QWidget*parent,const char*name)
231 :QLabel(parent,name) 231 :QLabel(parent,name)
232{ 232{
233 m_Timer=new QTimer(this); 233 m_Timer=new QTimer(this);
234 connect(m_Timer,SIGNAL(timeout()),this,SLOT(hide())); 234 connect(m_Timer,SIGNAL(timeout()),this,SLOT(hide()));
235 setFrameStyle(QFrame::Sunken|QFrame::Panel); 235 setFrameStyle(QFrame::Sunken|QFrame::Panel);
236 setTextFormat(RichText); 236 setTextFormat(RichText);
237} 237}
238 238
239DatebookEventDesc::~DatebookEventDesc() 239DatebookEventDesc::~DatebookEventDesc()
240{ 240{
241} 241}
242 242
243void DatebookEventDesc::mousePressEvent(QMouseEvent*) 243void DatebookEventDesc::mousePressEvent(QMouseEvent*)
244{ 244{
245 hide(); 245 hide();
246 if (m_Timer->isActive()) m_Timer->stop(); 246 if (m_Timer->isActive()) m_Timer->stop();
247} 247}
248 248
249void DatebookEventDesc::disp_event(const Event&e) 249void DatebookEventDesc::disp_event(const Event&e)
250{ 250{
251 if (m_Timer->isActive()) m_Timer->stop(); 251 if (m_Timer->isActive()) m_Timer->stop();
252 QString text; 252 QString text;
253 text = "<b><i>"+e.description()+"</i></b><br>"; 253 text = "<b><i>"+e.description()+"</i></b><br>";
254 if (e.notes().length()>0) { 254 if (e.notes().length()>0) {
255 text+="<b>"+e.notes()+"</b><br>"; 255 text+="<b>"+e.notes()+"</b><br>";
256 } 256 }
257 if (e.location().length()>0) { 257 if (e.location().length()>0) {
258 text+="<i>"+e.location()+"</i><br>"; 258 text+="<i>"+e.location()+"</i><br>";
259 } 259 }
260 text = text.replace(QRegExp("\n"),"<br>"); 260 text = text.replace(QRegExp("\n"),"<br>");
261 setText(text); 261 setText(text);
262 QSize s = sizeHint(); 262 QSize s = sizeHint();
263 s+=QSize(10,10); 263 s+=QSize(10,10);
264 resize(s); 264 resize(s);
265 move( QMAX(0,(parentWidget()->width()-width()) / 2), 265 move( QMAX(0,(parentWidget()->width()-width()) / 2),
266 (parentWidget()->height()-height())/2 ); 266 (parentWidget()->height()-height())/2 );
267 show(); 267 show();
268 m_Timer->start(2000,true); 268 m_Timer->start(2000,true);
269} 269}
diff --git a/core/pim/datebook/datebooksettings.cpp b/core/pim/datebook/datebooksettings.cpp
index cb4b73b..861e266 100644
--- a/core/pim/datebook/datebooksettings.cpp
+++ b/core/pim/datebook/datebooksettings.cpp
@@ -1,155 +1,191 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "datebooksettings.h" 21#include "datebooksettings.h"
22 22
23#include <opie2/opluginloader.h>
24#include <opie2/odebug.h>
25
23#include <qpe/qpeapplication.h> 26#include <qpe/qpeapplication.h>
24 27
25#include <qspinbox.h> 28#include <qspinbox.h>
26#include <qcheckbox.h> 29#include <qcheckbox.h>
30#include <qlistview.h>
31#include <qheader.h>
27 32
28DateBookSettings::DateBookSettings( bool whichClock, QWidget *parent, 33DateBookSettings::DateBookSettings( bool whichClock, QWidget *parent,
29 const char *name, bool modal, WFlags fl ) 34 const char *name, bool modal, WFlags fl )
30 : DateBookSettingsBase( parent, name, modal, fl ), 35 : DateBookSettingsBase( parent, name, modal, fl ),
31 ampm( whichClock ) 36 ampm( whichClock )
32{ 37{
33 init(); 38 init();
34 QObject::connect( qApp, SIGNAL( clockChanged(bool) ), this, SLOT( slotChangeClock(bool) ) ); 39 QObject::connect( qApp, SIGNAL( clockChanged(bool) ), this, SLOT( slotChangeClock(bool) ) );
35 QArray<int> categories; 40 QArray<int> categories;
36 comboCategory->setCategories( categories, "Calendar", tr("Calendar") ); 41 comboCategory->setCategories( categories, "Calendar", tr("Calendar") );
42 m_loader = 0;
43 m_manager = 0;
44 m_PluginListView->header()->hide();
45 m_PluginListView->setSorting(-1);
37} 46}
38 47
39DateBookSettings::~DateBookSettings() 48DateBookSettings::~DateBookSettings()
40{ 49{
41} 50}
42 51
43void DateBookSettings::setStartTime( int newStartViewTime ) 52void DateBookSettings::setStartTime( int newStartViewTime )
44{ 53{
45 if ( ampm ) { 54 if ( ampm ) {
46 if ( newStartViewTime >= 12 ) { 55 if ( newStartViewTime >= 12 ) {
47 newStartViewTime %= 12; 56 newStartViewTime %= 12;
48 if ( newStartViewTime == 0 ) 57 if ( newStartViewTime == 0 )
49 newStartViewTime = 12; 58 newStartViewTime = 12;
50 spinStart->setSuffix( tr(":00 PM") ); 59 spinStart->setSuffix( tr(":00 PM") );
51 } 60 }
52 else if ( newStartViewTime == 0 ) { 61 else if ( newStartViewTime == 0 ) {
53 newStartViewTime = 12; 62 newStartViewTime = 12;
54 spinStart->setSuffix( tr(":00 AM") ); 63 spinStart->setSuffix( tr(":00 AM") );
55 } 64 }
56 oldtime = newStartViewTime; 65 oldtime = newStartViewTime;
57 } 66 }
58 spinStart->setValue( newStartViewTime ); 67 spinStart->setValue( newStartViewTime );
59} 68}
60 69
61int DateBookSettings::startTime() const 70int DateBookSettings::startTime() const
62{ 71{
63 int returnMe = spinStart->value(); 72 int returnMe = spinStart->value();
64 if ( ampm ) { 73 if ( ampm ) {
65 if ( returnMe != 12 && spinStart->suffix().contains(tr("PM"), FALSE) ) 74 if ( returnMe != 12 && spinStart->suffix().contains(tr("PM"), FALSE) )
66 returnMe += 12; 75 returnMe += 12;
67 else if (returnMe == 12 && spinStart->suffix().contains(tr("AM"), TRUE)) 76 else if (returnMe == 12 && spinStart->suffix().contains(tr("AM"), TRUE))
68 returnMe = 0; 77 returnMe = 0;
69 } 78 }
70 return returnMe; 79 return returnMe;
71} 80}
72 81
82void DateBookSettings::setPluginList(Opie::Core::OPluginManager*aManager,Opie::Core::OPluginLoader*aLoader)
83{
84 m_manager = aManager;
85 m_loader = aLoader;
86 if (!aManager||!aLoader) return;
87 Opie::Core::OPluginItem::List inLst = m_loader->allAvailable(true);
88 QCheckListItem *pitem = 0;
89
90 for ( Opie::Core::OPluginItem::List::Iterator it = inLst.begin(); it != inLst.end(); ++it ) {
91 pitem = new QCheckListItem(m_PluginListView,(*it).name(),QCheckListItem::CheckBox);
92 pitem->setOn( (*it).isEnabled() );
93 }
94}
95
96void DateBookSettings::pluginItemClicked(QListViewItem *aItem)
97{
98 if (!aItem||!m_manager||!m_loader) return;
99 QCheckListItem*pitem = ((QCheckListItem*)aItem);
100
101 Opie::Core::OPluginItem::List lst = m_loader->allAvailable( true );
102 for ( Opie::Core::OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) {
103 if ( QString::compare( (*it).name() , pitem->text(0) ) == 0 ) {
104 m_manager->setEnabled((*it),pitem->isOn());
105 break;
106 }
107 }
108}
73 109
74void DateBookSettings::setAlarmPreset( bool bAlarm, int presetTime ) 110void DateBookSettings::setAlarmPreset( bool bAlarm, int presetTime )
75{ 111{
76 chkAlarmPreset->setChecked( bAlarm ); 112 chkAlarmPreset->setChecked( bAlarm );
77 if ( presetTime >=5 ) 113 if ( presetTime >=5 )
78 spinPreset->setValue( presetTime ); 114 spinPreset->setValue( presetTime );
79} 115}
80 116
81bool DateBookSettings::alarmPreset() const 117bool DateBookSettings::alarmPreset() const
82{ 118{
83 return chkAlarmPreset->isChecked(); 119 return chkAlarmPreset->isChecked();
84} 120}
85 121
86int DateBookSettings::presetTime() const 122int DateBookSettings::presetTime() const
87{ 123{
88 return spinPreset->value(); 124 return spinPreset->value();
89} 125}
90 126
91 127
92void DateBookSettings::slot12Hour( int i ) 128void DateBookSettings::slot12Hour( int i )
93{ 129{
94 if ( ampm ) { 130 if ( ampm ) {
95 if ( spinStart->suffix().contains( tr("AM"), FALSE ) ) { 131 if ( spinStart->suffix().contains( tr("AM"), FALSE ) ) {
96 if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 ) 132 if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 )
97 spinStart->setSuffix( tr(":00 PM") ); 133 spinStart->setSuffix( tr(":00 PM") );
98 } else { 134 } else {
99 if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 ) 135 if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 )
100 spinStart->setSuffix( tr(":00 AM") ); 136 spinStart->setSuffix( tr(":00 AM") );
101 } 137 }
102 oldtime = i; 138 oldtime = i;
103 } 139 }
104} 140}
105 141
106void DateBookSettings::init() 142void DateBookSettings::init()
107{ 143{
108 if ( ampm ) { 144 if ( ampm ) {
109 spinStart->setMinValue( 1 ); 145 spinStart->setMinValue( 1 );
110 spinStart->setMaxValue( 12 ); 146 spinStart->setMaxValue( 12 );
111 spinStart->setValue( 12 ); 147 spinStart->setValue( 12 );
112 spinStart->setSuffix( tr(":00 AM") ); 148 spinStart->setSuffix( tr(":00 AM") );
113 oldtime = 12; 149 oldtime = 12;
114 } else { 150 } else {
115 spinStart->setMinValue( 0 ); 151 spinStart->setMinValue( 0 );
116 spinStart->setMaxValue( 23 ); 152 spinStart->setMaxValue( 23 );
117 spinStart->setSuffix( tr(":00") ); 153 spinStart->setSuffix( tr(":00") );
118 } 154 }
119} 155}
120 156
121void DateBookSettings::slotChangeClock( bool whichClock ) 157void DateBookSettings::slotChangeClock( bool whichClock )
122{ 158{
123 int saveMe; 159 int saveMe;
124 saveMe = spinStart->value(); 160 saveMe = spinStart->value();
125 if ( ampm && spinStart->suffix().contains( tr("AM"), FALSE ) ) { 161 if ( ampm && spinStart->suffix().contains( tr("AM"), FALSE ) ) {
126 if ( saveMe == 12 ) 162 if ( saveMe == 12 )
127 saveMe = 0; 163 saveMe = 0;
128 } else if ( ampm && spinStart->suffix().contains( tr("PM"), FALSE ) ) { 164 } else if ( ampm && spinStart->suffix().contains( tr("PM"), FALSE ) ) {
129 if ( saveMe != 12 ) 165 if ( saveMe != 12 )
130 saveMe += 12; 166 saveMe += 12;
131 } 167 }
132 ampm = whichClock; 168 ampm = whichClock;
133 init(); 169 init();
134 setStartTime( saveMe ); 170 setStartTime( saveMe );
135} 171}
136 172
137void DateBookSettings::setJumpToCurTime( bool bJump ) 173void DateBookSettings::setJumpToCurTime( bool bJump )
138{ 174{
139 chkJumpToCurTime->setChecked( bJump ); 175 chkJumpToCurTime->setChecked( bJump );
140} 176}
141 177
142bool DateBookSettings::jumpToCurTime() const 178bool DateBookSettings::jumpToCurTime() const
143{ 179{
144 return chkJumpToCurTime->isChecked(); 180 return chkJumpToCurTime->isChecked();
145} 181}
146 182
147void DateBookSettings::setRowStyle( int style ) 183void DateBookSettings::setRowStyle( int style )
148{ 184{
149 comboRowStyle->setCurrentItem( style ); 185 comboRowStyle->setCurrentItem( style );
150} 186}
151 187
152int DateBookSettings::rowStyle() const 188int DateBookSettings::rowStyle() const
153{ 189{
154 return comboRowStyle->currentItem(); 190 return comboRowStyle->currentItem();
155} 191}
diff --git a/core/pim/datebook/datebooksettings.h b/core/pim/datebook/datebooksettings.h
index cf8a0ff..df7d32c 100644
--- a/core/pim/datebook/datebooksettings.h
+++ b/core/pim/datebook/datebooksettings.h
@@ -1,55 +1,71 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#ifndef DATEBOOKSETTINGS_H 21#ifndef DATEBOOKSETTINGS_H
22#define DATEBOOKSETTINGS_H 22#define DATEBOOKSETTINGS_H
23#include "datebooksettingsbase.h" 23#include "datebooksettingsbase.h"
24#include <qpe/categoryselect.h> 24#include <qpe/categoryselect.h>
25 25
26namespace Opie {
27namespace Core {
28 class OPluginManager;
29 class OGenericPluginLoader;
30 class OPluginLoader;
31}
32namespace Ui {
33 class OPluginConfigWidget;
34}
35}
36
26class DateBookSettings : public DateBookSettingsBase 37class DateBookSettings : public DateBookSettingsBase
27{ 38{
28 Q_OBJECT 39 Q_OBJECT
29public: 40public:
30 DateBookSettings( bool whichClock, QWidget *parent = 0, 41 DateBookSettings( bool whichClock, QWidget *parent = 0,
31 const char *name = 0, bool modal = TRUE, WFlags = 0 ); 42 const char *name = 0, bool modal = TRUE, WFlags = 0 );
32 ~DateBookSettings(); 43 ~DateBookSettings();
33 void setStartTime( int newStartViewTime ); 44 void setStartTime( int newStartViewTime );
34 int startTime() const; 45 int startTime() const;
35 void setAlarmPreset( bool bAlarm, int presetTime ); 46 void setAlarmPreset( bool bAlarm, int presetTime );
36 bool alarmPreset() const; 47 bool alarmPreset() const;
37 int presetTime() const; 48 int presetTime() const;
38 void setAlarmType( int alarmType ); 49 void setAlarmType( int alarmType );
39 int alarmType() const; 50 int alarmType() const;
40 51
41 void setJumpToCurTime( bool bJump ); 52 void setJumpToCurTime( bool bJump );
42 bool jumpToCurTime() const; 53 bool jumpToCurTime() const;
43 void setRowStyle( int style ); 54 void setRowStyle( int style );
44 int rowStyle() const; 55 int rowStyle() const;
45 56
57 void setPluginList(Opie::Core::OPluginManager*,Opie::Core::OPluginLoader*);
46private slots: 58private slots:
47 void slot12Hour( int ); 59 void slot12Hour( int );
48 void slotChangeClock( bool ); 60 void slotChangeClock( bool );
61protected slots:
62 virtual void pluginItemClicked(QListViewItem *);
49 63
50private: 64protected:
51 void init(); 65 void init();
52 bool ampm; 66 bool ampm;
53 int oldtime; 67 int oldtime;
68 Opie::Core::OPluginManager*m_manager;
69 Opie::Core::OPluginLoader*m_loader;
54}; 70};
55#endif 71#endif
diff --git a/core/pim/datebook/datebooksettingsbase.ui b/core/pim/datebook/datebooksettingsbase.ui
index e613db1..7b3e591 100644
--- a/core/pim/datebook/datebooksettingsbase.ui
+++ b/core/pim/datebook/datebooksettingsbase.ui
@@ -1,158 +1,164 @@
1<!DOCTYPE UI><UI> 1<!DOCTYPE UI><UI>
2<class>DateBookSettingsBase</class> 2<class>DateBookSettingsBase</class>
3<comment>********************************************************************** 3<comment>**********************************************************************
4** Copyright (C) 2000 Trolltech AS. All rights reserved. 4** Copyright (C) 2000 Trolltech AS. All rights reserved.
5** 5**
6** This file is part of Qtopia Environment. 6** This file is part of Qtopia Environment.
7** 7**
8** This file may be distributed and/or modified under the terms of the 8** This file may be distributed and/or modified under the terms of the
9** GNU General Public License version 2 as published by the Free Software 9** GNU General Public License version 2 as published by the Free Software
10** Foundation and appearing in the file LICENSE.GPL included in the 10** Foundation and appearing in the file LICENSE.GPL included in the
11** packaging of this file. 11** packaging of this file.
12** 12**
13** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 13** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
14** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 14** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
15** 15**
16** See http://www.trolltech.com/gpl/ for GPL licensing information. 16** See http://www.trolltech.com/gpl/ for GPL licensing information.
17** 17**
18** Contact info@trolltech.com if any conditions of this licensing are 18** Contact info@trolltech.com if any conditions of this licensing are
19** not clear to you. 19** not clear to you.
20** 20**
21** $Id$ 21** $Id$
22** 22**
23**********************************************************************</comment> 23**********************************************************************</comment>
24<widget> 24<widget>
25 <class>QDialog</class> 25 <class>QDialog</class>
26 <property stdset="1"> 26 <property stdset="1">
27 <name>name</name> 27 <name>name</name>
28 <cstring>DateBookSettingsBase</cstring> 28 <cstring>DateBookSettingsBase</cstring>
29 </property> 29 </property>
30 <property stdset="1"> 30 <property stdset="1">
31 <name>geometry</name> 31 <name>geometry</name>
32 <rect> 32 <rect>
33 <x>0</x> 33 <x>0</x>
34 <y>0</y> 34 <y>0</y>
35 <width>273</width> 35 <width>273</width>
36 <height>340</height> 36 <height>340</height>
37 </rect> 37 </rect>
38 </property> 38 </property>
39 <property stdset="1"> 39 <property stdset="1">
40 <name>caption</name> 40 <name>caption</name>
41 <string>Preferences</string> 41 <string>Preferences</string>
42 </property> 42 </property>
43 <property> 43 <property>
44 <name>layoutMargin</name> 44 <name>layoutMargin</name>
45 </property> 45 </property>
46 <property> 46 <property>
47 <name>layoutSpacing</name> 47 <name>layoutSpacing</name>
48 </property> 48 </property>
49 <vbox> 49 <vbox>
50 <property stdset="1"> 50 <property stdset="1">
51 <name>margin</name> 51 <name>margin</name>
52 <number>11</number> 52 <number>11</number>
53 </property> 53 </property>
54 <property stdset="1"> 54 <property stdset="1">
55 <name>spacing</name> 55 <name>spacing</name>
56 <number>6</number> 56 <number>6</number>
57 </property> 57 </property>
58 <widget> 58 <widget>
59 <class>QTabWidget</class> 59 <class>QTabWidget</class>
60 <property stdset="1"> 60 <property stdset="1">
61 <name>name</name> 61 <name>name</name>
62 <cstring>TabWidget2</cstring> 62 <cstring>TabWidget</cstring>
63 </property>
64 <property>
65 <name>layoutMargin</name>
66 </property>
67 <property>
68 <name>layoutSpacing</name>
63 </property> 69 </property>
64 <widget> 70 <widget>
65 <class>QWidget</class> 71 <class>QWidget</class>
66 <property stdset="1"> 72 <property stdset="1">
67 <name>name</name> 73 <name>name</name>
68 <cstring>tab</cstring> 74 <cstring>tab</cstring>
69 </property> 75 </property>
70 <attribute> 76 <attribute>
71 <name>title</name> 77 <name>title</name>
72 <string>Views</string> 78 <string>Views</string>
73 </attribute> 79 </attribute>
74 <vbox> 80 <vbox>
75 <property stdset="1"> 81 <property stdset="1">
76 <name>margin</name> 82 <name>margin</name>
77 <number>11</number> 83 <number>11</number>
78 </property> 84 </property>
79 <property stdset="1"> 85 <property stdset="1">
80 <name>spacing</name> 86 <name>spacing</name>
81 <number>6</number> 87 <number>6</number>
82 </property> 88 </property>
83 <widget> 89 <widget>
84 <class>QLayoutWidget</class> 90 <class>QLayoutWidget</class>
85 <property stdset="1"> 91 <property stdset="1">
86 <name>name</name> 92 <name>name</name>
87 <cstring>Layout5</cstring> 93 <cstring>Layout5</cstring>
88 </property> 94 </property>
89 <hbox> 95 <hbox>
90 <property stdset="1"> 96 <property stdset="1">
91 <name>margin</name> 97 <name>margin</name>
92 <number>0</number> 98 <number>0</number>
93 </property> 99 </property>
94 <property stdset="1"> 100 <property stdset="1">
95 <name>spacing</name> 101 <name>spacing</name>
96 <number>6</number> 102 <number>6</number>
97 </property> 103 </property>
98 <spacer> 104 <spacer>
99 <property> 105 <property>
100 <name>name</name> 106 <name>name</name>
101 <cstring>Spacer1</cstring> 107 <cstring>Spacer1</cstring>
102 </property> 108 </property>
103 <property stdset="1"> 109 <property stdset="1">
104 <name>orientation</name> 110 <name>orientation</name>
105 <enum>Horizontal</enum> 111 <enum>Horizontal</enum>
106 </property> 112 </property>
107 <property stdset="1"> 113 <property stdset="1">
108 <name>sizeType</name> 114 <name>sizeType</name>
109 <enum>Expanding</enum> 115 <enum>Expanding</enum>
110 </property> 116 </property>
111 <property> 117 <property>
112 <name>sizeHint</name> 118 <name>sizeHint</name>
113 <size> 119 <size>
114 <width>20</width> 120 <width>20</width>
115 <height>20</height> 121 <height>20</height>
116 </size> 122 </size>
117 </property> 123 </property>
118 </spacer> 124 </spacer>
119 <widget> 125 <widget>
120 <class>QLabel</class> 126 <class>QLabel</class>
121 <property stdset="1"> 127 <property stdset="1">
122 <name>name</name> 128 <name>name</name>
123 <cstring>TextLabel1_2</cstring> 129 <cstring>TextLabel1_2</cstring>
124 </property> 130 </property>
125 <property stdset="1"> 131 <property stdset="1">
126 <name>text</name> 132 <name>text</name>
127 <string>Default view:</string> 133 <string>Default view:</string>
128 </property> 134 </property>
129 </widget> 135 </widget>
130 <widget> 136 <widget>
131 <class>QComboBox</class> 137 <class>QComboBox</class>
132 <item> 138 <item>
133 <property> 139 <property>
134 <name>text</name> 140 <name>text</name>
135 <string>Day</string> 141 <string>Day</string>
136 </property> 142 </property>
137 </item> 143 </item>
138 <item> 144 <item>
139 <property> 145 <property>
140 <name>text</name> 146 <name>text</name>
141 <string>Week</string> 147 <string>Week</string>
142 </property> 148 </property>
143 </item> 149 </item>
144 <item> 150 <item>
145 <property> 151 <property>
146 <name>text</name> 152 <name>text</name>
147 <string>Week List</string> 153 <string>Week List</string>
148 </property> 154 </property>
149 </item> 155 </item>
150 <item> 156 <item>
151 <property> 157 <property>
152 <name>text</name> 158 <name>text</name>
153 <string>Month</string> 159 <string>Month</string>
154 </property> 160 </property>
155 </item> 161 </item>
156 <property stdset="1"> 162 <property stdset="1">
157 <name>name</name> 163 <name>name</name>
158 <cstring>comboDefaultView</cstring> 164 <cstring>comboDefaultView</cstring>
@@ -575,138 +581,187 @@
575 <enum>MShape</enum> 581 <enum>MShape</enum>
576 </property> 582 </property>
577 <property stdset="1"> 583 <property stdset="1">
578 <name>frameShadow</name> 584 <name>frameShadow</name>
579 <enum>MShadow</enum> 585 <enum>MShadow</enum>
580 </property> 586 </property>
581 <property stdset="1"> 587 <property stdset="1">
582 <name>text</name> 588 <name>text</name>
583 <string>Location:</string> 589 <string>Location:</string>
584 </property> 590 </property>
585 </widget> 591 </widget>
586 <widget> 592 <widget>
587 <class>QComboBox</class> 593 <class>QComboBox</class>
588 <item> 594 <item>
589 <property> 595 <property>
590 <name>text</name> 596 <name>text</name>
591 <string></string> 597 <string></string>
592 </property> 598 </property>
593 </item> 599 </item>
594 <item> 600 <item>
595 <property> 601 <property>
596 <name>text</name> 602 <name>text</name>
597 <string>Office</string> 603 <string>Office</string>
598 </property> 604 </property>
599 </item> 605 </item>
600 <item> 606 <item>
601 <property> 607 <property>
602 <name>text</name> 608 <name>text</name>
603 <string>Home</string> 609 <string>Home</string>
604 </property> 610 </property>
605 </item> 611 </item>
606 <property stdset="1"> 612 <property stdset="1">
607 <name>name</name> 613 <name>name</name>
608 <cstring>comboLocation</cstring> 614 <cstring>comboLocation</cstring>
609 </property> 615 </property>
610 <property stdset="1"> 616 <property stdset="1">
611 <name>sizePolicy</name> 617 <name>sizePolicy</name>
612 <sizepolicy> 618 <sizepolicy>
613 <hsizetype>7</hsizetype> 619 <hsizetype>7</hsizetype>
614 <vsizetype>0</vsizetype> 620 <vsizetype>0</vsizetype>
615 </sizepolicy> 621 </sizepolicy>
616 </property> 622 </property>
617 <property stdset="1"> 623 <property stdset="1">
618 <name>editable</name> 624 <name>editable</name>
619 <bool>true</bool> 625 <bool>true</bool>
620 </property> 626 </property>
621 <property stdset="1"> 627 <property stdset="1">
622 <name>currentItem</name> 628 <name>currentItem</name>
623 <number>0</number> 629 <number>0</number>
624 </property> 630 </property>
625 <property stdset="1"> 631 <property stdset="1">
626 <name>duplicatesEnabled</name> 632 <name>duplicatesEnabled</name>
627 <bool>false</bool> 633 <bool>false</bool>
628 </property> 634 </property>
629 </widget> 635 </widget>
630 </hbox> 636 </hbox>
631 </widget> 637 </widget>
632 <widget> 638 <widget>
633 <class>QLayoutWidget</class> 639 <class>QLayoutWidget</class>
634 <property stdset="1"> 640 <property stdset="1">
635 <name>name</name> 641 <name>name</name>
636 <cstring>Layout7_2</cstring> 642 <cstring>Layout7_2</cstring>
637 </property> 643 </property>
638 <hbox> 644 <hbox>
639 <property stdset="1"> 645 <property stdset="1">
640 <name>margin</name> 646 <name>margin</name>
641 <number>0</number> 647 <number>0</number>
642 </property> 648 </property>
643 <property stdset="1"> 649 <property stdset="1">
644 <name>spacing</name> 650 <name>spacing</name>
645 <number>6</number> 651 <number>6</number>
646 </property> 652 </property>
647 <widget> 653 <widget>
648 <class>QLabel</class> 654 <class>QLabel</class>
649 <property stdset="1"> 655 <property stdset="1">
650 <name>name</name> 656 <name>name</name>
651 <cstring>TextLabel2_2_2_2</cstring> 657 <cstring>TextLabel2_2_2_2</cstring>
652 </property> 658 </property>
653 <property stdset="1"> 659 <property stdset="1">
654 <name>text</name> 660 <name>text</name>
655 <string>Category:</string> 661 <string>Category:</string>
656 </property> 662 </property>
657 </widget> 663 </widget>
658 <widget> 664 <widget>
659 <class>CategorySelect</class> 665 <class>CategorySelect</class>
660 <property stdset="1"> 666 <property stdset="1">
661 <name>name</name> 667 <name>name</name>
662 <cstring>comboCategory</cstring> 668 <cstring>comboCategory</cstring>
663 </property> 669 </property>
664 </widget> 670 </widget>
665 </hbox> 671 </hbox>
666 </widget> 672 </widget>
667 </vbox> 673 </vbox>
668 </widget> 674 </widget>
669 </vbox> 675 </vbox>
670 </widget> 676 </widget>
677 <widget>
678 <class>QWidget</class>
679 <property stdset="1">
680 <name>name</name>
681 <cstring>plugintab</cstring>
682 </property>
683 <attribute>
684 <name>title</name>
685 <string>Plugins</string>
686 </attribute>
687 <vbox>
688 <property stdset="1">
689 <name>margin</name>
690 <number>2</number>
691 </property>
692 <property stdset="1">
693 <name>spacing</name>
694 <number>2</number>
695 </property>
696 <widget>
697 <class>QListView</class>
698 <column>
699 <property>
700 <name>text</name>
701 <string>Pluginlist</string>
702 </property>
703 <property>
704 <name>clickable</name>
705 <bool>true</bool>
706 </property>
707 <property>
708 <name>resizeable</name>
709 <bool>true</bool>
710 </property>
711 </column>
712 <property stdset="1">
713 <name>name</name>
714 <cstring>m_PluginListView</cstring>
715 </property>
716 </widget>
717 </vbox>
718 </widget>
671 </widget> 719 </widget>
672 </vbox> 720 </vbox>
673</widget> 721</widget>
674<customwidgets> 722<customwidgets>
675 <customwidget> 723 <customwidget>
676 <class>CategorySelect</class> 724 <class>CategorySelect</class>
677 <header location="global">qpe/categoryselect.h</header> 725 <header location="global">qpe/categoryselect.h</header>
678 <sizehint> 726 <sizehint>
679 <width>-1</width> 727 <width>-1</width>
680 <height>-1</height> 728 <height>-1</height>
681 </sizehint> 729 </sizehint>
682 <container>0</container> 730 <container>0</container>
683 <sizepolicy> 731 <sizepolicy>
684 <hordata>7</hordata> 732 <hordata>7</hordata>
685 <verdata>1</verdata> 733 <verdata>1</verdata>
686 </sizepolicy> 734 </sizepolicy>
687 <pixmap>image0</pixmap> 735 <pixmap>image0</pixmap>
688 </customwidget> 736 </customwidget>
689</customwidgets> 737</customwidgets>
690<images> 738<images>
691 <image> 739 <image>
692 <name>image0</name> 740 <name>image0</name>
693 <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data> 741 <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data>
694 </image> 742 </image>
695</images> 743</images>
696<connections> 744<connections>
697 <connection> 745 <connection>
698 <sender>chkAlarmPreset</sender> 746 <sender>chkAlarmPreset</sender>
699 <signal>toggled(bool)</signal> 747 <signal>toggled(bool)</signal>
700 <receiver>spinPreset</receiver> 748 <receiver>spinPreset</receiver>
701 <slot>setEnabled(bool)</slot> 749 <slot>setEnabled(bool)</slot>
702 </connection> 750 </connection>
703 <connection> 751 <connection>
704 <sender>spinStart</sender> 752 <sender>spinStart</sender>
705 <signal>valueChanged(int)</signal> 753 <signal>valueChanged(int)</signal>
706 <receiver>DateBookSettingsBase</receiver> 754 <receiver>DateBookSettingsBase</receiver>
707 <slot>slot12Hour( int )</slot> 755 <slot>slot12Hour( int )</slot>
708 </connection> 756 </connection>
709 <slot access="public">slotChangeClock( bool )</slot> 757 <connection>
758 <sender>m_PluginListView</sender>
759 <signal>clicked(QListViewItem*)</signal>
760 <receiver>DateBookSettingsBase</receiver>
761 <slot>pluginItemClicked(QListViewItem *)</slot>
762 </connection>
763 <slot access="protected">pluginItemClicked(QListViewItem *)</slot>
710 <slot access="public">slot12Hour( int )</slot> 764 <slot access="public">slot12Hour( int )</slot>
765 <slot access="public">slotChangeClock( bool )</slot>
711</connections> 766</connections>
712</UI> 767</UI>
diff --git a/core/pim/datebook/datebooktypes.h b/core/pim/datebook/datebooktypes.h
index f944e84..2966814 100644
--- a/core/pim/datebook/datebooktypes.h
+++ b/core/pim/datebook/datebooktypes.h
@@ -1,63 +1,70 @@
1#ifndef _DATEBOOK_TYPES_H 1#ifndef _DATEBOOK_TYPES_H
2#define _DATEBOOK_TYPES_H 2#define _DATEBOOK_TYPES_H
3 3
4#include <qpe/datebookdb.h> 4#include <qpe/datebookdb.h>
5 5
6#include <qvaluelist.h> 6#include <qvaluelist.h>
7#include <qstringlist.h> 7#include <qstringlist.h>
8 8
9namespace Opie { 9namespace Opie {
10namespace Datebook { 10namespace Datebook {
11 class HolidayPlugin; 11 class HolidayPlugin;
12 class HolidayPluginIf; 12 class HolidayPluginIf;
13} 13}
14namespace Core { 14namespace Core {
15 class OPluginLoader; 15 class OPluginLoader;
16 class OPluginManager;
16} 17}
17} 18}
18 19
19class QLibrary; 20class QLibrary;
20 21
21class DateBookDBHack : virtual public DateBookDB { 22class DateBookDBHack : virtual public DateBookDB {
22 public: 23 public:
23 virtual ~DateBookDBHack(){} 24 virtual ~DateBookDBHack(){}
24 Event eventByUID(int id); 25 Event eventByUID(int id);
25}; 26};
26 27
27class DateBookHoliday 28class DateBookHoliday
28{ 29{
29public: 30public:
30 DateBookHoliday(); 31 DateBookHoliday();
31 virtual ~DateBookHoliday(); 32 virtual ~DateBookHoliday();
32 33
33 QStringList holidaylist(const QDate&); 34 QStringList holidaylist(const QDate&);
34 QStringList holidaylist(unsigned year, unsigned month, unsigned day); 35 QStringList holidaylist(unsigned year, unsigned month, unsigned day);
35 virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDate &from,const QDate &to ); 36 virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDate &from,const QDate &to );
36 virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDateTime &start); 37 virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDateTime &start);
37 38
39 void reloadPlugins();
40
41 Opie::Core::OPluginLoader*pluginLoader(){return m_pluginLoader;}
42 Opie::Core::OPluginManager*pluginManager(){return m_pluginManager;}
43
38protected: 44protected:
39 void init(); 45 void init();
40 void deinit(); 46 void deinit();
41 47
42 struct HPlugin { 48 struct HPlugin {
43 Opie::Datebook::HolidayPlugin*_plugin; 49 Opie::Datebook::HolidayPlugin*_plugin;
44 //QLibrary*_lib; 50 //QLibrary*_lib;
45 //Opie::Datebook::HolidayPluginIf*_if; 51 //Opie::Datebook::HolidayPluginIf*_if;
46 }; 52 };
47 QValueList<HPlugin*>_pluginlist; 53 QValueList<HPlugin*>_pluginlist;
48 Opie::Core::OPluginLoader*m_pluginLoader; 54 Opie::Core::OPluginLoader*m_pluginLoader;
55 Opie::Core::OPluginManager*m_pluginManager;
49}; 56};
50 57
51class DateBookDBHoliday:virtual public DateBookDBHack { 58class DateBookDBHoliday:virtual public DateBookDBHack {
52public: 59public:
53 DateBookDBHoliday():DateBookDBHack(){db_holiday=0;} 60 DateBookDBHoliday():DateBookDBHack(){db_holiday=0;}
54 virtual ~DateBookDBHoliday(){} 61 virtual ~DateBookDBHoliday(){}
55 virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDate &from,const QDate &to ); 62 virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDate &from,const QDate &to );
56 virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDateTime &start); 63 virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDateTime &start);
57 virtual QValueList<EffectiveEvent> getEffectiveEventsNoHoliday(const QDate &from,const QDate &to ); 64 virtual QValueList<EffectiveEvent> getEffectiveEventsNoHoliday(const QDate &from,const QDate &to );
58 virtual QValueList<EffectiveEvent> getEffectiveEventsNoHoliday(const QDateTime &start); 65 virtual QValueList<EffectiveEvent> getEffectiveEventsNoHoliday(const QDateTime &start);
59 66
60 DateBookHoliday*db_holiday; 67 DateBookHoliday*db_holiday;
61}; 68};
62 69
63#endif 70#endif
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp
index b0e78f1..3c871ea 100644
--- a/core/pim/datebook/datebookweeklst.cpp
+++ b/core/pim/datebook/datebookweeklst.cpp
@@ -122,193 +122,198 @@ DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */,
122 122
123 if (d == QDate::currentDate()) { 123 if (d == QDate::currentDate()) {
124 QPalette pal=label->palette(); 124 QPalette pal=label->palette();
125 pal.setColor(QColorGroup::Foreground, QColor(0,0,255)); 125 pal.setColor(QColorGroup::Foreground, QColor(0,0,255));
126 label->setPalette(pal); 126 label->setPalette(pal);
127 127
128 /* 128 /*
129 QFont f=label->font(); 129 QFont f=label->font();
130 f.setItalic(true); 130 f.setItalic(true);
131 label->setFont(f); 131 label->setFont(f);
132 label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor())); 132 label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor()));
133 */ 133 */
134 } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday 134 } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday
135 QPalette pal=label->palette(); 135 QPalette pal=label->palette();
136 pal.setColor(QColorGroup::Foreground, QColor(255,0,0)); 136 pal.setColor(QColorGroup::Foreground, QColor(255,0,0));
137 label->setPalette(pal); 137 label->setPalette(pal);
138 } 138 }
139 139
140 connect (label, SIGNAL(clicked()), this, SLOT(showDay())); 140 connect (label, SIGNAL(clicked()), this, SLOT(showDay()));
141 connect (add, SIGNAL(clicked()), this, SLOT(newEvent())); 141 connect (add, SIGNAL(clicked()), this, SLOT(newEvent()));
142} 142}
143 143
144void DateBookWeekLstDayHdr::showDay() { 144void DateBookWeekLstDayHdr::showDay() {
145 emit showDate(date.year(), date.month(), date.day()); 145 emit showDate(date.year(), date.month(), date.day());
146} 146}
147 147
148void DateBookWeekLstDayHdr::newEvent() { 148void DateBookWeekLstDayHdr::newEvent() {
149 QDateTime start, stop; 149 QDateTime start, stop;
150 start=stop=date; 150 start=stop=date;
151 start.setTime(QTime(10,0)); 151 start.setTime(QTime(10,0));
152 stop.setTime(QTime(12,0)); 152 stop.setTime(QTime(12,0));
153 153
154 emit addEvent(start,stop,"",0); 154 emit addEvent(start,stop,"",0);
155} 155}
156DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, 156DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev,
157 int weeklistviewconfig, 157 int weeklistviewconfig,
158 QWidget* parent, 158 QWidget* parent,
159 const char* name, 159 const char* name,
160 WFlags fl ) : OClickableLabel(parent,name,fl), event(ev) 160 WFlags fl ) : OClickableLabel(parent,name,fl), event(ev)
161{ 161{
162 // old values... lastday = "__|__", middle=" |---", Firstday="00:00", 162 // old values... lastday = "__|__", middle=" |---", Firstday="00:00",
163 QString s,start,middle,end,day; 163 QString s,start,middle,end,day;
164 164
165 odebug << "weeklistviewconfig=" << weeklistviewconfig << oendl; 165 odebug << "weeklistviewconfig=" << weeklistviewconfig << oendl;
166 if(weeklistviewconfig==NONE) { // No times displayed. 166 if(weeklistviewconfig==NONE) { // No times displayed.
167// start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); 167// start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute());
168// middle.sprintf("<--->"); 168// middle.sprintf("<--->");
169// end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); 169// end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute());
170// day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); 170// day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute());
171 } else if(weeklistviewconfig==NORMAL) { // "Normal", only display start time. 171 } else if(weeklistviewconfig==NORMAL) { // "Normal", only display start time.
172 start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); 172 start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute());
173 middle.sprintf(" |---"); 173 middle.sprintf(" |---");
174 end.sprintf("__|__"); 174 end.sprintf("__|__");
175 day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); 175 day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute());
176 } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times. 176 } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times.
177 start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); 177 start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute());
178 middle.sprintf("<--->"); 178 middle.sprintf("<--->");
179 end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); 179 end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute());
180 day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); 180 day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute());
181 } 181 }
182 182
183 if(ev.event().type() == Event::Normal) { 183 if(ev.event().type() == Event::Normal) {
184 if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) { // day event. 184 if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) { // day event.
185 s=day; 185 s=day;
186 } else if(ev.startDate()==ev.date()) { // start event. 186 } else if(ev.startDate()==ev.date()) { // start event.
187 s=start; 187 s=start;
188 } else if(ev.endDate()==ev.date()) { // end event. 188 } else if(ev.endDate()==ev.date()) { // end event.
189 s=end; 189 s=end;
190 } else { // middle day. 190 } else { // middle day.
191 s=middle; 191 s=middle;
192 } 192 }
193 } else { 193 } else {
194 s=""; 194 s="";
195 } 195 }
196 setText(QString(s) + " " + ev.description()); 196 setText(QString(s) + " " + ev.description());
197// connect(this, SIGNAL(clicked()), this, SLOT(editMe())); 197// connect(this, SIGNAL(clicked()), this, SLOT(editMe()));
198 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); 198 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) );
199} 199}
200void DateBookWeekLstEvent::editMe() { 200void DateBookWeekLstEvent::editMe() {
201 emit editEvent(event.event()); 201 emit editEvent(event.event());
202} 202}
203void DateBookWeekLstEvent::duplicateMe() 203void DateBookWeekLstEvent::duplicateMe()
204{ 204{
205 emit duplicateEvent(event.event()); 205 emit duplicateEvent(event.event());
206} 206}
207void DateBookWeekLstEvent::deleteMe() 207void DateBookWeekLstEvent::deleteMe()
208{ 208{
209 emit removeEvent(event.event()); 209 emit removeEvent(event.event());
210 emit redraw(); 210 emit redraw();
211} 211}
212void DateBookWeekLstEvent::beamMe() 212void DateBookWeekLstEvent::beamMe()
213{ 213{
214 emit beamEvent( event.event() ); 214 emit beamEvent( event.event() );
215} 215}
216void DateBookWeekLstEvent::mousePressEvent( QMouseEvent *e ) 216void DateBookWeekLstEvent::mousePressEvent( QMouseEvent *e )
217{ 217{
218 if (!event.event().isValidUid()) {
219 // this is just such a holiday event.
220 return;
221 }
218 popmenue = new QPopupMenu; 222 popmenue = new QPopupMenu;
223
219 popmenue->insertItem( tr( "Edit" ), this, SLOT(editMe())); 224 popmenue->insertItem( tr( "Edit" ), this, SLOT(editMe()));
220 popmenue->insertItem( tr( "Duplicate" ), this, SLOT(duplicateMe())); 225 popmenue->insertItem( tr( "Duplicate" ), this, SLOT(duplicateMe()));
221 popmenue->insertItem( tr( "Delete" ), this, SLOT(deleteMe())); 226 popmenue->insertItem( tr( "Delete" ), this, SLOT(deleteMe()));
222 if(Ir::supported()) 227 if(Ir::supported())
223 popmenue->insertItem( tr( "Beam" ), this, SLOT(beamMe())); 228 popmenue->insertItem( tr( "Beam" ), this, SLOT(beamMe()));
224 popmenue->popup( mapToGlobal( e->pos() )); 229 popmenue->popup( mapToGlobal( e->pos() ));
225} 230}
226 231
227DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, 232DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
228 const QDate &d, bool onM, 233 const QDate &d, bool onM,
229 QWidget* parent, 234 QWidget* parent,
230 const char* name, WFlags fl) 235 const char* name, WFlags fl)
231 : QWidget( parent, name, fl ) 236 : QWidget( parent, name, fl )
232{ 237{
233 Config config("DateBook"); 238 Config config("DateBook");
234 config.setGroup("Main"); 239 config.setGroup("Main");
235 int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL); 240 int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL);
236 odebug << "weeklistviewconfig: " << weeklistviewconfig << oendl; 241 odebug << "weeklistviewconfig: " << weeklistviewconfig << oendl;
237 242
238 bStartOnMonday=onM; 243 bStartOnMonday=onM;
239 setPalette(white); 244 setPalette(white);
240 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); 245 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
241 246
242 QVBoxLayout *layout = new QVBoxLayout( this ); 247 QVBoxLayout *layout = new QVBoxLayout( this );
243 248
244 qBubbleSort(ev); 249 qBubbleSort(ev);
245 QValueListIterator<EffectiveEvent> it; 250 QValueListIterator<EffectiveEvent> it;
246 it=ev.begin(); 251 it=ev.begin();
247 252
248 int dayOrder[7]; 253 int dayOrder[7];
249 if (bStartOnMonday) { 254 if (bStartOnMonday) {
250 for (int d=0; d<7; d++) dayOrder[d]=d+1; 255 for (int d=0; d<7; d++) dayOrder[d]=d+1;
251 } else { 256 } else {
252 for (int d=0; d<7; d++) dayOrder[d]=d; 257 for (int d=0; d<7; d++) dayOrder[d]=d;
253 dayOrder[0]=7; 258 dayOrder[0]=7;
254 } 259 }
255 260
256 // Calculate offset to first day of week. 261 // Calculate offset to first day of week.
257 int dayoffset=d.dayOfWeek(); 262 int dayoffset=d.dayOfWeek();
258 if(bStartOnMonday) dayoffset--; 263 if(bStartOnMonday) dayoffset--;
259 else if( dayoffset == 7 ) dayoffset = 0; 264 else if( dayoffset == 7 ) dayoffset = 0;
260 265
261 for (int i=0; i<7; i++) { 266 for (int i=0; i<7; i++) {
262 // Header 267 // Header
263 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this); 268 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this);
264 connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 269 connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
265 connect(hdr, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), 270 connect(hdr, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
266 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); 271 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
267 layout->addWidget(hdr); 272 layout->addWidget(hdr);
268 273
269 // Events 274 // Events
270 while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { 275 while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) {
271 if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) { // Skip events ending at 00:00 starting at another day. 276 if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) { // Skip events ending at 00:00 starting at another day.
272 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this); 277 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this);
273 layout->addWidget(l); 278 layout->addWidget(l);
274 connect (l, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); 279 connect (l, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
275 connect (l, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); 280 connect (l, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
276 connect (l, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); 281 connect (l, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
277 connect (l, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); 282 connect (l, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
278 connect (l, SIGNAL(redraw()), this, SIGNAL(redraw())); 283 connect (l, SIGNAL(redraw()), this, SIGNAL(redraw()));
279 } 284 }
280 it++; 285 it++;
281 } 286 }
282 layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); 287 layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding));
283 } 288 }
284} 289}
285DateBookWeekLstView::~DateBookWeekLstView(){} 290DateBookWeekLstView::~DateBookWeekLstView(){}
286void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} 291void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();}
287 292
288DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, 293DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
289 QValueList<EffectiveEvent> &ev2, 294 QValueList<EffectiveEvent> &ev2,
290 QDate &d, bool onM, 295 QDate &d, bool onM,
291 QWidget* parent, 296 QWidget* parent,
292 const char* name, WFlags fl) 297 const char* name, WFlags fl)
293 : QWidget( parent, name, fl ) 298 : QWidget( parent, name, fl )
294{ 299{
295 QHBoxLayout *layout = new QHBoxLayout( this ); 300 QHBoxLayout *layout = new QHBoxLayout( this );
296 301
297 DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); 302 DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this);
298 layout->addWidget(w); 303 layout->addWidget(w);
299 connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); 304 connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
300 connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); 305 connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
301 connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); 306 connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
302 connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); 307 connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
303 connect (w, SIGNAL(redraw()), this, SIGNAL(redraw())); 308 connect (w, SIGNAL(redraw()), this, SIGNAL(redraw()));
304 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 309 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
305 connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), 310 connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
306 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); 311 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
307 312
308 313
309 w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); 314 w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this);
310 layout->addWidget(w); 315 layout->addWidget(w);
311 connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); 316 connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
312 connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); 317 connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
313 connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); 318 connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
314 connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); 319 connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));