summaryrefslogtreecommitdiff
authorzecke <zecke>2003-04-16 10:57:59 (UTC)
committer zecke <zecke>2003-04-16 10:57:59 (UTC)
commiteeb29547890a2d162de66d7d5b98d3840a7e2d79 (patch) (unidiff)
tree973c6de7aae2fd5ba368efb87fa24234f0e12aa3
parentdfa2d294b3af09bf3757a3c2294a925093e72fc6 (diff)
downloadopie-eeb29547890a2d162de66d7d5b98d3840a7e2d79.zip
opie-eeb29547890a2d162de66d7d5b98d3840a7e2d79.tar.gz
opie-eeb29547890a2d162de66d7d5b98d3840a7e2d79.tar.bz2
Fix API docu
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/applnk.cpp16
-rw-r--r--library/backend/categories.cpp9
-rw-r--r--library/backend/categories.h2
-rw-r--r--library/backend/event.cpp4
-rw-r--r--library/backend/palmtoprecord.h12
-rw-r--r--library/datebookdb.cpp12
-rw-r--r--library/finddialog.cpp7
-rw-r--r--library/global.cpp28
-rw-r--r--library/qpeapplication.cpp3
-rw-r--r--library/storage.cpp6
10 files changed, 65 insertions, 34 deletions
diff --git a/library/applnk.cpp b/library/applnk.cpp
index 35822dd..00030e8 100644
--- a/library/applnk.cpp
+++ b/library/applnk.cpp
@@ -271,129 +271,145 @@ int AppLnk::bigIconSize()
271 document or application, not the filename. 271 document or application, not the filename.
272 272
273 See \link #files-and-links Files and Links\endlink. 273 See \link #files-and-links Files and Links\endlink.
274 274
275 \sa setName() 275 \sa setName()
276*/ 276*/
277/*! 277/*!
278 \fn QString AppLnk::exec() const 278 \fn QString AppLnk::exec() const
279 279
280 Returns the Exec property. This is the name of the executable 280 Returns the Exec property. This is the name of the executable
281 program associated with the AppLnk. 281 program associated with the AppLnk.
282 282
283 \sa setExec() 283 \sa setExec()
284*/ 284*/
285/*! 285/*!
286 \fn QString AppLnk::rotation() const 286 \fn QString AppLnk::rotation() const
287 287
288 Returns the Rotation property. The value is 0, 90, 180 or 270 288 Returns the Rotation property. The value is 0, 90, 180 or 270
289 degrees. 289 degrees.
290*/ 290*/
291/*! 291/*!
292 \fn QString AppLnk::comment() const 292 \fn QString AppLnk::comment() const
293 293
294 Returns the Comment property. 294 Returns the Comment property.
295 295
296 \sa setComment() 296 \sa setComment()
297*/ 297*/
298/*! 298/*!
299 \fn QStringList AppLnk::mimeTypes() const 299 \fn QStringList AppLnk::mimeTypes() const
300 300
301 Returns the MimeTypes property. This is the list of MIME types 301 Returns the MimeTypes property. This is the list of MIME types
302 that the application can view or edit. 302 that the application can view or edit.
303*/ 303*/
304/*! 304/*!
305 \fn const QArray<int>& AppLnk::categories() const 305 \fn const QArray<int>& AppLnk::categories() const
306 306
307 Returns the Categories property. 307 Returns the Categories property.
308 308
309 See the CategoryWidget for more details. 309 See the CategoryWidget for more details.
310 310
311 \sa setCategories() 311 \sa setCategories()
312*/ 312*/
313 313
314const QArray<int>& AppLnk::categories() const 314const QArray<int>& AppLnk::categories() const
315{ 315{
316 d->ensureCatArray(); 316 d->ensureCatArray();
317 return d->mCat; 317 return d->mCat;
318} 318}
319 319
320/*! 320/*!
321 \fn int AppLnk::id() const 321 \fn int AppLnk::id() const
322 322
323 Returns the id of the AppLnk. If the AppLnk is not in an AppLnkSet, 323 Returns the id of the AppLnk. If the AppLnk is not in an AppLnkSet,
324 this value is 0, otherwise it is a value that is unique for the 324 this value is 0, otherwise it is a value that is unique for the
325 duration of the current process. 325 duration of the current process.
326 326
327 \sa AppLnkSet::find() 327 \sa AppLnkSet::find()
328*/ 328*/
329 329
330/*! 330/*!
331 \fn bool AppLnk::isValid() const 331 \fn bool AppLnk::isValid() const
332 332
333 Returns TRUE if this AppLnk is valid; otherwise returns FALSE. 333 Returns TRUE if this AppLnk is valid; otherwise returns FALSE.
334*/ 334*/
335/*!
336 \fn bool AppLnk::fileKnown() const
337
338 If the with the AppLnk associated file is not equal to QString::null
339*/
340/*!
341 \fn bool AppLnk::linkFileKnown()const
342
343 The filename of the AppLnk
335 344
345*/
346/*!
347 \fn void AppLnk::setRotation( const QString& )
348
349 The default rotation of the associated application. This
350 function is included inline for binary compatible issues
351*/
336/*! 352/*!
337 Creates an invalid AppLnk. 353 Creates an invalid AppLnk.
338 354
339 \sa isValid() 355 \sa isValid()
340*/ 356*/
341AppLnk::AppLnk() 357AppLnk::AppLnk()
342{ 358{
343 mId = 0; 359 mId = 0;
344 d = new AppLnkPrivate(); 360 d = new AppLnkPrivate();
345} 361}
346 362
347/*! 363/*!
348 Loads \a file (e.g. \e app.desktop) as an AppLnk. 364 Loads \a file (e.g. \e app.desktop) as an AppLnk.
349 365
350 \sa writeLink() 366 \sa writeLink()
351*/ 367*/
352AppLnk::AppLnk( const QString &file ) 368AppLnk::AppLnk( const QString &file )
353{ 369{
354 QStringList sl; 370 QStringList sl;
355 d = new AppLnkPrivate(); 371 d = new AppLnkPrivate();
356 if ( !file.isNull() ) { 372 if ( !file.isNull() ) {
357 Config config( file, Config::File ); 373 Config config( file, Config::File );
358 374
359 if ( config.isValid() ) { 375 if ( config.isValid() ) {
360 config.setGroup( "Desktop Entry" ); 376 config.setGroup( "Desktop Entry" );
361 377
362 mName = config.readEntry( "Name", file ); 378 mName = config.readEntry( "Name", file );
363 mExec = config.readEntry( "Exec" ); 379 mExec = config.readEntry( "Exec" );
364 mType = config.readEntry( "Type", QString::null ); 380 mType = config.readEntry( "Type", QString::null );
365 mIconFile = config.readEntry( "Icon", QString::null ); 381 mIconFile = config.readEntry( "Icon", QString::null );
366 mRotation = config.readEntry( "Rotation", "" ); 382 mRotation = config.readEntry( "Rotation", "" );
367 mComment = config.readEntry( "Comment", QString::null ); 383 mComment = config.readEntry( "Comment", QString::null );
368 // MIME types are case-insensitive. 384 // MIME types are case-insensitive.
369 mMimeTypes = config.readListEntry( "MimeType", ';' ); 385 mMimeTypes = config.readListEntry( "MimeType", ';' );
370 for (QStringList::Iterator it=mMimeTypes.begin(); it!=mMimeTypes.end(); ++it) 386 for (QStringList::Iterator it=mMimeTypes.begin(); it!=mMimeTypes.end(); ++it)
371 *it = (*it).lower(); 387 *it = (*it).lower();
372 mMimeTypeIcons = config.readListEntry( "MimeTypeIcons", ';' ); 388 mMimeTypeIcons = config.readListEntry( "MimeTypeIcons", ';' );
373 mLinkFile = file; 389 mLinkFile = file;
374 mFile = config.readEntry("File", QString::null); 390 mFile = config.readEntry("File", QString::null);
375 if ( !mExec. isEmpty ( )) { 391 if ( !mExec. isEmpty ( )) {
376 mFile = QString::null; 392 mFile = QString::null;
377 } 393 }
378 else if ( mFile[0] != '/' ) { 394 else if ( mFile[0] != '/' ) {
379 int slash = file.findRev('/'); 395 int slash = file.findRev('/');
380 if ( slash >= 0 ) { 396 if ( slash >= 0 ) {
381 mFile = file.left(slash) + '/' + mFile; 397 mFile = file.left(slash) + '/' + mFile;
382 } 398 }
383 } 399 }
384 d->mCatList = config.readListEntry("Categories", ';'); 400 d->mCatList = config.readListEntry("Categories", ';');
385 if ( d->mCatList[0].toInt() < -1 ) { 401 if ( d->mCatList[0].toInt() < -1 ) {
386 // numeric cats in file! convert to text 402 // numeric cats in file! convert to text
387 Categories cat( 0 ); 403 Categories cat( 0 );
388 cat.load( categoryFileName() ); 404 cat.load( categoryFileName() );
389 d->mCat.resize( d->mCatList.count() ); 405 d->mCat.resize( d->mCatList.count() );
390 int i; 406 int i;
391 QStringList::ConstIterator it; 407 QStringList::ConstIterator it;
392 for ( i = 0, it = d->mCatList.begin(); it != d->mCatList.end(); 408 for ( i = 0, it = d->mCatList.begin(); it != d->mCatList.end();
393 ++it, i++ ) { 409 ++it, i++ ) {
394 bool number; 410 bool number;
395 int id = (*it).toInt( &number ); 411 int id = (*it).toInt( &number );
396 if ( !number ) { 412 if ( !number ) {
397 // convert from text 413 // convert from text
398 id = cat.id( "Document View", *it ); 414 id = cat.id( "Document View", *it );
399 if ( id == 0 ) 415 if ( id == 0 )
diff --git a/library/backend/categories.cpp b/library/backend/categories.cpp
index 2e84089..cce9f38 100644
--- a/library/backend/categories.cpp
+++ b/library/backend/categories.cpp
@@ -426,129 +426,129 @@ QStringList Categories::labels( const QString &app,
426 switch ( extra ) { 426 switch ( extra ) {
427 case NoExtra: break; 427 case NoExtra: break;
428 case AllUnfiled: 428 case AllUnfiled:
429 cats.append( tr("All") ); 429 cats.append( tr("All") );
430 cats.append( tr("Unfiled") ); 430 cats.append( tr("Unfiled") );
431 break; 431 break;
432 case AllLabel: 432 case AllLabel:
433 cats.append( tr("All") ); 433 cats.append( tr("All") );
434 break; 434 break;
435 case UnfiledLabel: 435 case UnfiledLabel:
436 cats.append( tr("Unfiled") ); 436 cats.append( tr("Unfiled") );
437 break; 437 break;
438 } 438 }
439 439
440 return cats; 440 return cats;
441} 441}
442 442
443/*! 443/*!
444 Returns the label associated with the id 444 Returns the label associated with the id
445*/ 445*/
446QString Categories::label( const QString &app, int id ) const 446QString Categories::label( const QString &app, int id ) const
447{ 447{
448 if ( mGlobalCats.contains( id ) ) 448 if ( mGlobalCats.contains( id ) )
449 return mGlobalCats.label( id ); 449 return mGlobalCats.label( id );
450 QMap< QString, CategoryGroup >::ConstIterator 450 QMap< QString, CategoryGroup >::ConstIterator
451 appIt = mAppCats.find( app ); 451 appIt = mAppCats.find( app );
452 if ( appIt == mAppCats.end() ) 452 if ( appIt == mAppCats.end() )
453 return QString::null; 453 return QString::null;
454 return (*appIt).label( id ); 454 return (*appIt).label( id );
455} 455}
456 456
457/*! 457/*!
458 Returns a single string associated with \a catids for display in a 458 Returns a single string associated with \a catids for display in a
459 combobox or any area that requires one string. If \a catids are empty 459 combobox or any area that requires one string. If \a catids are empty
460 then "Unfiled" will be returned. If multiple categories are 460 then "Unfiled" will be returned. If multiple categories are
461 assigned then the behavior depends on the DisplaySingle type. 461 assigned then the behavior depends on the DisplaySingle type.
462 462
463 If \a display is set to ShowMulti then " (multi)" appended to the 463 If \a display is set to ShowMulti then " (multi)" appended to the
464 first string. If \a display is set to ShowAll, then a space 464 first string. If \a display is set to ShowAll, then a space
465 seperated string is returned with all categories. If ShowFirst is 465 seperated string is returned with all categories. If ShowFirst is
466 set, the just the first string is returned. 466 set, the just the first string is returned.
467*/ 467*/
468QString Categories::displaySingle( const QString &app, 468QString Categories::displaySingle( const QString &app,
469 const QArray<int> &catids, 469 const QArray<int> &catids,
470 DisplaySingle display ) const 470 DisplaySingle display ) const
471{ 471{
472 QStringList strs = labels( app, catids ); 472 QStringList strs = labels( app, catids );
473 if ( !strs.count() ) 473 if ( !strs.count() )
474 return tr("Unfiled"); 474 return tr("Unfiled");
475 strs.sort(); 475 strs.sort();
476 QString r; 476 QString r;
477 if ( strs.count() > 1 ) { 477 if ( strs.count() > 1 ) {
478 switch ( display ) { 478 switch ( display ) {
479 case ShowFirst: 479 case ShowFirst:
480 r = strs.first(); 480 r = strs.first();
481 break; 481 break;
482 case ShowMulti: 482 case ShowMulti:
483 r = strs.first() + tr(" (multi.)"); 483 r = strs.first() + tr(" (multi.)");
484 break; 484 break;
485 case ShowAll: 485 case ShowAll:
486 r = strs.join(" "); 486 r = strs.join(" ");
487 break; 487 break;
488 } 488 }
489 } 489 }
490 else r = strs.first(); 490 else r = strs.first();
491 return r; 491 return r;
492} 492}
493 493
494/*! 494/*!
495 495
496 Returns all ids associated with the application CategoryGroup \a app 496 Returns all ids associated with the application CategoryGroup \a app
497 and the passed in \a labels in that group. 497 and the passed in \a labels in that group.
498*/ 498*/
499QArray<int> Categories::ids( const QString &app, const QStringList &labels) const 499QArray<int> Categories::ids( const QString &app, const QStringList &labels) const
500{ 500{
501 QArray<int> results; 501 QArray<int> results;
502 QStringList::ConstIterator it; 502 QStringList::ConstIterator it;
503 int i; 503 int i;
504 504
505 for ( i=0, it=labels.begin(); it!=labels.end(); i++, ++it ) { 505 for ( i=0, it=labels.begin(); it!=labels.end(); i++, ++it ) {
506 int value = id( app, *it ); 506 int value = id( app, *it );
507 if ( value != 0 ) { 507 if ( value != 0 ) {
508 int tmp = results.size(); 508 int tmp = results.size();
509 results.resize( tmp + 1 ); 509 results.resize( tmp + 1 );
510 results[ tmp ] = value; 510 results[ tmp ] = value;
511 } 511 }
512 } 512 }
513 return results; 513 return results;
514} 514}
515 515
516/*! 516/*!
517 Returns the id associated with the app. If the id is not found in the 517 Returns the id associated with the app. If the id is not found in the
518 application CategoryGroup, then it searches the global CategoryGroup. 518 application CategoryGroup, then it searches the global CategoryGroup.
519 If it is not found it either, 0 is returned. 519 If it is not found it either, 0 is returned.
520*/ 520*/
521int Categories::id( const QString &app, const QString &cat ) const 521int Categories::id( const QString &app, const QString &cat ) const
522{ 522{
523 if ( cat == tr("Unfiled") || cat.contains( tr(" (multi.)") ) ) 523 if ( cat == tr("Unfiled") || cat.contains( tr(" (multi.)") ) )
524 return 0; 524 return 0;
525 int uid = mGlobalCats.id( cat ); 525 int uid = mGlobalCats.id( cat );
526 if ( uid != 0 ) 526 if ( uid != 0 )
527 return uid; 527 return uid;
528 return mAppCats[app].id( cat ); 528 return mAppCats[app].id( cat );
529} 529}
530 530
531 531
532/*! 532/*!
533 Return TRUE if renaming succeeded; FALSE if \a appname or \a oldName 533 Return TRUE if renaming succeeded; FALSE if \a appname or \a oldName
534 is not found, or if \a newName conflicts with an existing category 534 is not found, or if \a newName conflicts with an existing category
535 in the CategoryGroup. 535 in the CategoryGroup.
536 536
537 It will first search the CategoryGroup associated with \a appname 537 It will first search the CategoryGroup associated with \a appname
538 and if not found it will try to replace in global CategoryGroup. 538 and if not found it will try to replace in global CategoryGroup.
539 */ 539 */
540bool Categories::renameCategory( const QString &appname, 540bool Categories::renameCategory( const QString &appname,
541 const QString &oldName, 541 const QString &oldName,
542 const QString &newName ) 542 const QString &newName )
543{ 543{
544 QMap< QString, CategoryGroup >::Iterator 544 QMap< QString, CategoryGroup >::Iterator
545 appIt = mAppCats.find( appname ); 545 appIt = mAppCats.find( appname );
546 546
547 if ( appIt != mAppCats.end() ) { 547 if ( appIt != mAppCats.end() ) {
548 CategoryGroup &cats = *appIt; 548 CategoryGroup &cats = *appIt;
549 int id = cats.id( oldName ); 549 int id = cats.id( oldName );
550 if ( id != 0 && cats.rename( id, newName ) ) { 550 if ( id != 0 && cats.rename( id, newName ) ) {
551 emit categoryRenamed( *this, appname, id ); 551 emit categoryRenamed( *this, appname, id );
552 return TRUE; 552 return TRUE;
553 } 553 }
554 } 554 }
@@ -787,150 +787,145 @@ void Categories::clear()
787 mGlobalCats.clear(); 787 mGlobalCats.clear();
788 mAppCats.clear(); 788 mAppCats.clear();
789} 789}
790 790
791/*! 791/*!
792 Dump the contents to standard out. Used for debugging only. 792 Dump the contents to standard out. Used for debugging only.
793*/ 793*/
794void Categories::dump() const 794void Categories::dump() const
795{ 795{
796 qDebug("\tglobal categories = %s", mGlobalCats.labels().join(", ").latin1() ); 796 qDebug("\tglobal categories = %s", mGlobalCats.labels().join(", ").latin1() );
797 for ( QMap<QString, CategoryGroup>::ConstIterator appsIt = mAppCats.begin(); appsIt != mAppCats.end(); ++appsIt ) { 797 for ( QMap<QString, CategoryGroup>::ConstIterator appsIt = mAppCats.begin(); appsIt != mAppCats.end(); ++appsIt ) {
798 const QString &app = appsIt.key(); 798 const QString &app = appsIt.key();
799 QStringList appcats = (*appsIt).labels(); 799 QStringList appcats = (*appsIt).labels();
800 qDebug("\tapp = %s\tcategories = %s", app.latin1(), 800 qDebug("\tapp = %s\tcategories = %s", app.latin1(),
801 appcats.join(", ").latin1() ); 801 appcats.join(", ").latin1() );
802 802
803 } 803 }
804} 804}
805 805
806QStringList CheckedListView::checked() const 806QStringList CheckedListView::checked() const
807{ 807{
808 QStringList strs; 808 QStringList strs;
809 for ( QCheckListItem *i = (QCheckListItem *) firstChild(); 809 for ( QCheckListItem *i = (QCheckListItem *) firstChild();
810 i; i = (QCheckListItem *)i->nextSibling() ) 810 i; i = (QCheckListItem *)i->nextSibling() )
811 if ( i->isOn() ) 811 if ( i->isOn() )
812 strs += i->text( 0 ); 812 strs += i->text( 0 );
813 return strs; 813 return strs;
814} 814}
815 815
816void CheckedListView::addCheckableList( const QStringList &options ) 816void CheckedListView::addCheckableList( const QStringList &options )
817{ 817{
818 for ( QStringList::ConstIterator it = options.begin(); 818 for ( QStringList::ConstIterator it = options.begin();
819 it != options.end(); ++it ) { 819 it != options.end(); ++it ) {
820 (void) new QCheckListItem( this, *it, 820 (void) new QCheckListItem( this, *it,
821 QCheckListItem::CheckBox ); 821 QCheckListItem::CheckBox );
822 } 822 }
823} 823}
824 824
825void CheckedListView::setChecked( const QStringList &checked ) 825void CheckedListView::setChecked( const QStringList &checked )
826{ 826{
827 // iterate over all items 827 // iterate over all items
828 bool showingChecked = FALSE; 828 bool showingChecked = FALSE;
829 for ( QCheckListItem *i = (QCheckListItem *) firstChild(); 829 for ( QCheckListItem *i = (QCheckListItem *) firstChild();
830 i; i = (QCheckListItem *)i->nextSibling() ) 830 i; i = (QCheckListItem *)i->nextSibling() )
831 // see if the item should be checked by searching the 831 // see if the item should be checked by searching the
832 // checked list 832 // checked list
833 if ( checked.find( i->text( 0 ) ) != checked.end() ) { 833 if ( checked.find( i->text( 0 ) ) != checked.end() ) {
834 i->setOn( TRUE ); 834 i->setOn( TRUE );
835 // make sure it is showing at least one checked item 835 // make sure it is showing at least one checked item
836 if ( !showingChecked ) { 836 if ( !showingChecked ) {
837 ensureItemVisible( i ); 837 ensureItemVisible( i );
838 showingChecked = TRUE; 838 showingChecked = TRUE;
839 } 839 }
840 } 840 }
841 else 841 else
842 i->setOn( FALSE ); 842 i->setOn( FALSE );
843} 843}
844 844
845/*! \fn Categories &Categories::operator= ( const Categories &c ) 845/*! \fn Categories &Categories::operator= ( const Categories &c )
846 846
847 Performs deep copy. 847 Performs deep copy.
848 */ 848 */
849 849
850 850
851/*! \fn QStringList Categories::labels( const QString & app, const QArray<int> &catids ) const
852
853 Returns list of labels associated with the application and catids
854*/
855
856/*! \fn QStringList Categories::globalCategories() const 851/*! \fn QStringList Categories::globalCategories() const
857 852
858 Returns list of all global category labels 853 Returns list of all global category labels
859*/ 854*/
860 855
861/*! \fn const QMap<QString, CategoryGroup> &Categories::appGroupMap() const 856/*! \fn const QMap<QString, CategoryGroup> &Categories::appGroupMap() const
862 857
863 Returns a map of application names to CategoryGroup. The CategoryGroup 858 Returns a map of application names to CategoryGroup. The CategoryGroup
864 class defines a map of ids to category labels and category labels to ids. 859 class defines a map of ids to category labels and category labels to ids.
865*/ 860*/
866 861
867/*! \fn const CategoryGroup &Categories::globalGroup() const 862/*! \fn const CategoryGroup &Categories::globalGroup() const
868 863
869 Returns the global CategoryGroup. The CategoryGroup 864 Returns the global CategoryGroup. The CategoryGroup
870 class defines a map of ids to category labels and category labels to ids. 865 class defines a map of ids to category labels and category labels to ids.
871*/ 866*/
872 867
873/*! \fn void Categories::categoryAdded( const Categories &cats, const QString &appname, int uid) 868/*! \fn void Categories::categoryAdded( const Categories &cats, const QString &appname, int uid)
874 869
875 Emitted if a category is added. 870 Emitted if a category is added.
876 871
877 \a cats is a const reference to this object 872 \a cats is a const reference to this object
878 \a appname is the CategoryGroup application name that the category was added to or QString::null if it was global 873 \a appname is the CategoryGroup application name that the category was added to or QString::null if it was global
879 \a uid is the unique identifier associated with the added category 874 \a uid is the unique identifier associated with the added category
880 */ 875*/
881 876
882/*! \fn void Categories::categoryRemoved( const Categories &cats, const QString &appname, 877/*! \fn void Categories::categoryRemoved( const Categories &cats, const QString &appname,
883 int uid) 878 int uid)
884 879
885 Emitted if removed category is removed. 880 Emitted if removed category is removed.
886 881
887 \a cats is a const reference to this object 882 \a cats is a const reference to this object
888 \a appname is the CategoryGroup application name that the category was removed from or QString::null if it was the global CategoryGroup 883 \a appname is the CategoryGroup application name that the category was removed from or QString::null if it was the global CategoryGroup
889 \a uid is the unique identifier associated with the removed category 884 \a uid is the unique identifier associated with the removed category
890*/ 885*/
891 886
892 887
893/*! \fn void Categories::categoryRenamed( const Categories &cats, const QString &appname, 888/*! \fn void Categories::categoryRenamed( const Categories &cats, const QString &appname,
894 int uid) 889 int uid)
895 890
896 Emitted if \a uid in the \a appname CategoryGroup is renamed in \a cats 891 Emitted if \a uid in the \a appname CategoryGroup is renamed in \a cats
897 object. 892 object.
898 893
899 \a cats is a const reference to this object 894 \a cats is a const reference to this object
900 \a appname is the CategoryGroup application name that the category was renamed in or QString::null if it was the global CategoryGroup 895 \a appname is the CategoryGroup application name that the category was renamed in or QString::null if it was the global CategoryGroup
901 \a uid is the unique identifier associated with the renamed category 896 \a uid is the unique identifier associated with the renamed category
902*/ 897*/
903 898
904/*! \fn Categories::Categories( QObject *parent=0, const char *name = 0 ) 899/*! \fn Categories::Categories( QObject *parent=0, const char *name = 0 )
905 900
906 Constructor for an empty Categories object. 901 Constructor for an empty Categories object.
907*/ 902*/
908 903
909/*! \fn Categories::Categories( const Categories &copyFrom ) 904/*! \fn Categories::Categories( const Categories &copyFrom )
910 905
911 Deep copy constructor 906 Deep copy constructor
912*/ 907*/
913 908
914/*! \fn Categories::~Categories() 909/*! \fn Categories::~Categories()
915 910
916 Empty destructor. Call save() before destruction if there are changes 911 Empty destructor. Call save() before destruction if there are changes
917 that need to be saved. 912 that need to be saved.
918*/ 913*/
919 914
920/*! \fn CategoryGroup::clear() 915/*! \fn CategoryGroup::clear()
921 \internal 916 \internal
922*/ 917*/
923 918
924/*! \fn const QMap<int, QString> &CategoryGroup::idMap() const 919/*! \fn const QMap<int, QString> &CategoryGroup::idMap() const
925 920
926 Returns a const reference to the id to label QMap 921 Returns a const reference to the id to label QMap
927*/ 922*/
928 923
929/*! \fn CategoryGroup::CategoryGroup() 924/*! \fn CategoryGroup::CategoryGroup()
930 \internal 925 \internal
931*/ 926*/
932 927
933/*! \fn CategoryGroup::CategoryGroup(const CategoryGroup &c) 928/*! \fn CategoryGroup::CategoryGroup(const CategoryGroup &c)
934 \internal 929 \internal
935*/ 930*/
936 931
diff --git a/library/backend/categories.h b/library/backend/categories.h
index ba65ee3..d5b3669 100644
--- a/library/backend/categories.h
+++ b/library/backend/categories.h
@@ -24,129 +24,129 @@
24 24
25#include <qstring.h> 25#include <qstring.h>
26#include <qstringlist.h> 26#include <qstringlist.h>
27#include <qmap.h> 27#include <qmap.h>
28#include <qlistview.h> 28#include <qlistview.h>
29#include <qarray.h> 29#include <qarray.h>
30#include "qpcglobal.h" 30#include "qpcglobal.h"
31#include "palmtopuidgen.h" 31#include "palmtopuidgen.h"
32 32
33class CategoryGroup; 33class CategoryGroup;
34 34
35#if defined(QPC_TEMPLATEDLL) 35#if defined(QPC_TEMPLATEDLL)
36// MOC_SKIP_BEGIN 36// MOC_SKIP_BEGIN
37template class QPC_EXPORT QMap<int, QString>; 37template class QPC_EXPORT QMap<int, QString>;
38template class QPC_EXPORT QMap<QString, int>; 38template class QPC_EXPORT QMap<QString, int>;
39template class QPC_EXPORT QMap< QString, CategoryGroup >; 39template class QPC_EXPORT QMap< QString, CategoryGroup >;
40// MOC_SKIP_END 40// MOC_SKIP_END
41#endif 41#endif
42 42
43class QPC_EXPORT CategoryGroup 43class QPC_EXPORT CategoryGroup
44{ 44{
45 friend class Categories; 45 friend class Categories;
46public: 46public:
47 CategoryGroup(): mIdLabelMap(), mLabelIdMap() { } 47 CategoryGroup(): mIdLabelMap(), mLabelIdMap() { }
48 CategoryGroup( const CategoryGroup &c ) : 48 CategoryGroup( const CategoryGroup &c ) :
49 mIdLabelMap( c.mIdLabelMap), mLabelIdMap( c.mLabelIdMap ) { } 49 mIdLabelMap( c.mIdLabelMap), mLabelIdMap( c.mLabelIdMap ) { }
50 50
51 void clear() { mIdLabelMap.clear(); mLabelIdMap.clear(); } 51 void clear() { mIdLabelMap.clear(); mLabelIdMap.clear(); }
52 52
53 int add( const QString &label ); 53 int add( const QString &label );
54 bool add( int uid, const QString &label ); 54 bool add( int uid, const QString &label );
55 55
56 bool remove( const QString &label ); 56 bool remove( const QString &label );
57 bool remove( int uid ); 57 bool remove( int uid );
58 58
59 bool rename( int uid, const QString &newLabel ); 59 bool rename( int uid, const QString &newLabel );
60 bool rename( const QString &oldLabel, const QString &newLabel ); 60 bool rename( const QString &oldLabel, const QString &newLabel );
61 61
62 bool contains(int id) const; 62 bool contains(int id) const;
63 bool contains(const QString &label) const; 63 bool contains(const QString &label) const;
64 64
65 /** Returns label associated with the uid or QString::null if 65 /** Returns label associated with the uid or QString::null if
66 * not found 66 * not found
67 */ 67 */
68 const QString &label(int id) const; 68 const QString &label(int id) const;
69 /** Returns the uid associated with label or 0 if not found */ 69 /** Returns the uid associated with label or 0 if not found */
70 int id(const QString &label) const; 70 int id(const QString &label) const;
71 71
72 /** Returns a sorted list of labels */ 72 /** Returns a sorted list of labels */
73 QStringList labels() const; 73 QStringList labels() const;
74 74
75 QStringList labels( const QArray<int> &catids ) const; 75 QStringList labels( const QArray<int> &catids ) const;
76 76
77 const QMap<int, QString> &idMap() const { return mIdLabelMap; } 77 const QMap<int, QString> &idMap() const { return mIdLabelMap; }
78 78
79private: 79private:
80 void insert( int uid, const QString &label ); 80 void insert( int uid, const QString &label );
81 QMap<int, QString> mIdLabelMap; 81 QMap<int, QString> mIdLabelMap;
82 QMap<QString, int> mLabelIdMap; 82 QMap<QString, int> mLabelIdMap;
83 83
84 static Qtopia::UidGen &uidGen() { return sUidGen; } 84 static Qtopia::UidGen &uidGen() { return sUidGen; }
85 static Qtopia::UidGen sUidGen; 85 static Qtopia::UidGen sUidGen;
86}; 86};
87 87
88/** Map from application name to categories */ 88/* Map from application name to categories */
89class QPC_EXPORT Categories : public QObject 89class QPC_EXPORT Categories : public QObject
90{ 90{
91 Q_OBJECT 91 Q_OBJECT
92public: 92public:
93 Categories( QObject *parent=0, const char *name = 0 ) 93 Categories( QObject *parent=0, const char *name = 0 )
94 : QObject( parent, name ), mGlobalCats(), mAppCats() { } 94 : QObject( parent, name ), mGlobalCats(), mAppCats() { }
95 Categories( const Categories &copyFrom ) : QObject( copyFrom.parent() ), 95 Categories( const Categories &copyFrom ) : QObject( copyFrom.parent() ),
96 mGlobalCats( copyFrom.mGlobalCats ), 96 mGlobalCats( copyFrom.mGlobalCats ),
97 mAppCats( copyFrom.mAppCats ) { } 97 mAppCats( copyFrom.mAppCats ) { }
98 virtual ~Categories() { } 98 virtual ~Categories() { }
99 99
100 Categories &operator= ( const Categories &c ) 100 Categories &operator= ( const Categories &c )
101{ mAppCats = c.mAppCats; mGlobalCats = c.mGlobalCats; return *this; } 101{ mAppCats = c.mAppCats; mGlobalCats = c.mGlobalCats; return *this; }
102 102
103 void clear(); 103 void clear();
104 104
105 /** Add the category name as long as it doesn't already exist 105 /** Add the category name as long as it doesn't already exist
106 * locally or globally. Return UID if added, 0 if conflicts 106 * locally or globally. Return UID if added, 0 if conflicts
107 * (error). 107 * (error).
108 */ 108 */
109 int addCategory( const QString &appname, const QString &catname); 109 int addCategory( const QString &appname, const QString &catname);
110 /** Add the category name as long as it doesn't already exist 110 /** Add the category name as long as it doesn't already exist
111 * locally or globally. Return UID if added, 0 if conflicts 111 * locally or globally. Return UID if added, 0 if conflicts
112 * (error). 112 * (error).
113 */ 113 */
114 int addCategory( const QString &appname, const QString &catname, int uid); 114 int addCategory( const QString &appname, const QString &catname, int uid);
115 /** Add the global category just checking that it doesn't 115 /** Add the global category just checking that it doesn't
116 * already exist globally. Return UID if added, 0 if conflicts. 116 * already exist globally. Return UID if added, 0 if conflicts.
117 */ 117 */
118 int addGlobalCategory( const QString &catname ); 118 int addGlobalCategory( const QString &catname );
119 /** Add the global category just checking that it doesn't 119 /** Add the global category just checking that it doesn't
120 * already exist globally. Return UID if added, 0 if conflicts. 120 * already exist globally. Return UID if added, 0 if conflicts.
121 */ 121 */
122 int addGlobalCategory( const QString &catname, int uid ); 122 int addGlobalCategory( const QString &catname, int uid );
123 /** Removes the category from the application; if it is not found 123 /** Removes the category from the application; if it is not found
124 * in the application, then it removes it from the global list 124 * in the application, then it removes it from the global list
125 */ 125 */
126 bool removeCategory( const QString &appName, const QString &catName, 126 bool removeCategory( const QString &appName, const QString &catName,
127 bool checkGlobal = TRUE); 127 bool checkGlobal = TRUE);
128 bool removeCategory( const QString &appName, int uid ); 128 bool removeCategory( const QString &appName, int uid );
129 bool removeGlobalCategory( const QString &catName ); 129 bool removeGlobalCategory( const QString &catName );
130 bool removeGlobalCategory( int uid ); 130 bool removeGlobalCategory( int uid );
131 131
132 QArray<int> ids( const QString &app, const QStringList &labels) const; 132 QArray<int> ids( const QString &app, const QStringList &labels) const;
133 133
134 /** Returns the id associated with the app */ 134 /** Returns the id associated with the app */
135 int id( const QString &app, const QString &cat ) const; 135 int id( const QString &app, const QString &cat ) const;
136 /** Returns the label associated with the id */ 136 /** Returns the label associated with the id */
137 QString label( const QString &app, int id ) const; 137 QString label( const QString &app, int id ) const;
138 138
139 enum ExtraLabels { NoExtra, AllUnfiled, AllLabel, UnfiledLabel }; 139 enum ExtraLabels { NoExtra, AllUnfiled, AllLabel, UnfiledLabel };
140 /** Returns the sorted list of all categories that are 140 /** Returns the sorted list of all categories that are
141 * associated with the app. 141 * associated with the app.
142 * If includeGlobal parameter is TRUE then the returned 142 * If includeGlobal parameter is TRUE then the returned
143 * categories will include the global category items. 143 * categories will include the global category items.
144 * If extra = NoExtra, then 144 * If extra = NoExtra, then
145 * If extra = AllUnfiled, then All and Unfiled will be prepended to 145 * If extra = AllUnfiled, then All and Unfiled will be prepended to
146 * the list 146 * the list
147 * If extra = AllLabel, then All is prepended 147 * If extra = AllLabel, then All is prepended
148 * If extra = UnfiledLabel, then Unfiled is prepended 148 * If extra = UnfiledLabel, then Unfiled is prepended
149 */ 149 */
150 QStringList labels( const QString &app, 150 QStringList labels( const QString &app,
151 bool includeGlobal = TRUE, 151 bool includeGlobal = TRUE,
152 ExtraLabels extra = NoExtra ) const; 152 ExtraLabels extra = NoExtra ) const;
diff --git a/library/backend/event.cpp b/library/backend/event.cpp
index d906f19..4c24ab3 100644
--- a/library/backend/event.cpp
+++ b/library/backend/event.cpp
@@ -106,135 +106,135 @@ Qtopia::UidGen Event::sUidGen( Qtopia::UidGen::Qtopia );
106 <ul> 106 <ul>
107 <li>\c Silent - No sound is produced. 107 <li>\c Silent - No sound is produced.
108 <li>\c Loud - A loud sound is produced. 108 <li>\c Loud - A loud sound is produced.
109 </ul> 109 </ul>
110*/ 110*/
111 111
112/*! 112/*!
113 \fn bool Event::operator<( const Event & ) const 113 \fn bool Event::operator<( const Event & ) const
114 \internal 114 \internal
115*/ 115*/
116 116
117/*! 117/*!
118 \fn bool Event::operator<=( const Event & ) const 118 \fn bool Event::operator<=( const Event & ) const
119 \internal 119 \internal
120*/ 120*/
121 121
122/*! 122/*!
123 \fn bool Event::operator!=( const Event & ) const 123 \fn bool Event::operator!=( const Event & ) const
124 \internal 124 \internal
125*/ 125*/
126 126
127/*! 127/*!
128 \fn bool Event::operator>( const Event & ) const 128 \fn bool Event::operator>( const Event & ) const
129 \internal 129 \internal
130*/ 130*/
131 131
132/*! 132/*!
133 \fn bool Event::operator>=( const Event & ) const 133 \fn bool Event::operator>=( const Event & ) const
134 \internal 134 \internal
135*/ 135*/
136 136
137/*! 137/*!
138 \enum Event::RepeatType 138 \enum Event::RepeatType
139 139
140 This enum defines how a event will repeat, if at all. 140 This enum defines how a event will repeat, if at all.
141 141
142 <ul> 142 <ul>
143 <li>\c NoRepeat - Event does not repeat. 143 <li>\c NoRepeat - Event does not repeat.
144 <li>\c Daily - Event occurs every n days. 144 <li>\c Daily - Event occurs every n days.
145 <li>\c Weekly - Event occurs every n weeks. 145 <li>\c Weekly - Event occurs every n weeks.
146 <li>\c MonthlyDay - Event occurs every n months. Event will always occur in 146 <li>\c MonthlyDay - Event occurs every n months. Event will always occur in
147 the same week and same day of week as the first event. 147 the same week and same day of week as the first event.
148 <li>\c MonthlyDate - Event occurs every n months. Event will always occur 148 <li>\c MonthlyDate - Event occurs every n months. Event will always occur
149 on the same day of the month as the first event. 149 on the same day of the month as the first event.
150 <li>\c Yearly - Event occurs every n years. 150 <li>\c Yearly - Event occurs every n years.
151 </ul> 151 </ul>
152*/ 152*/
153 153
154/*! 154/*!
155 \fn bool Event::isAllDay() const 155 \fn bool Event::isAllDay() const
156 156
157 Returns TRUE if the event is an all day event. Otherwise returns FALSE. 157 Returns TRUE if the event is an all day event. Otherwise returns FALSE.
158*/ 158*/
159 159
160/*! 160/*!
161 \fn void Event::setAllDay(bool allday) 161 \fn void Event::setAllDay(bool allday)
162 162
163 If \a allday is TRUE, will set the event to be an all day event. 163 If \a allday is TRUE, will set the event to be an all day event.
164 Otherwise sets the event to not be an all day event. 164 Otherwise sets the event to not be an all day event.
165 165
166 \warning This function may affect the start and end times of the event. 166 \warning This function may affect the start and end times of the event.
167*/ 167*/
168 168
169/*! 169/*!
170 \fn QDateTime Event::start() const 170 \fn QDateTime Event::start(bool) const
171 171
172 Returns the start date and time of the first occurance of the event. 172 Returns the start date and time of the first occurance of the event.
173*/ 173*/
174 174
175/*! 175/*!
176 \fn QDateTime Event::end() const 176 \fn QDateTime Event::end(bool) const
177 177
178 Returns the end date and time of the first occurance of the event. 178 Returns the end date and time of the first occurance of the event.
179*/ 179*/
180 180
181/*! 181/*!
182 \fn time_t Event::startTime() const 182 \fn time_t Event::startTime() const
183 \internal 183 \internal
184*/ 184*/
185 185
186/*! 186/*!
187 \fn time_t Event::endTime() const 187 \fn time_t Event::endTime() const
188 \internal 188 \internal
189*/ 189*/
190 190
191/*! 191/*!
192 \fn void Event::setAlarm(int delay, SoundTypeChoice s) 192 \fn void Event::setAlarm(int delay, SoundTypeChoice s)
193 193
194 Sets the alarm delay of the event to \a delay and the sound type of the 194 Sets the alarm delay of the event to \a delay and the sound type of the
195 alarm to \a s. 195 alarm to \a s.
196*/ 196*/
197 197
198/*! 198/*!
199 \fn void Event::clearAlarm() 199 \fn void Event::clearAlarm()
200 200
201 Clears the alarm for the event. 201 Clears the alarm for the event.
202*/ 202*/
203 203
204/*! 204/*!
205 \fn int Event::alarmDelay() const 205 \fn int Event::alarmDelay() const
206 206
207 Returns the delay in minutes between the alarm for an event and the 207 Returns the delay in minutes between the alarm for an event and the
208 start of the event. 208 start of the event.
209*/ 209*/
210 210
211/*! 211/*!
212 \fn Event::RepeatType Event::repeatType() const 212 \fn Event::RepeatType Event::repeatType() const
213 213
214 Returns the repeat pattern type for the event. 214 Returns the repeat pattern type for the event.
215 215
216 \sa frequency() 216 \sa frequency()
217*/ 217*/
218 218
219/*! 219/*!
220 \fn int Event::weekOffset() const 220 \fn int Event::weekOffset() const
221 221
222 Returns the number of weeks from the start of the month that this event 222 Returns the number of weeks from the start of the month that this event
223 occurs. 223 occurs.
224*/ 224*/
225 225
226/*! 226/*!
227 \fn QDate Event::repeatTill() const 227 \fn QDate Event::repeatTill() const
228 228
229 Returns the date that the event will continue to repeat until. If the event 229 Returns the date that the event will continue to repeat until. If the event
230 repeats forever the value returned is undefined. 230 repeats forever the value returned is undefined.
231 231
232 \sa repeatForever() 232 \sa repeatForever()
233*/ 233*/
234 234
235/*! 235/*!
236 \fn bool Event::repeatForever() const 236 \fn bool Event::repeatForever() const
237 237
238 Returns FALSE if there is a date set for the event to continue until. 238 Returns FALSE if there is a date set for the event to continue until.
239 Otherwise returns TRUE. 239 Otherwise returns TRUE.
240*/ 240*/
diff --git a/library/backend/palmtoprecord.h b/library/backend/palmtoprecord.h
index 72f7d1c..15cdd6a 100644
--- a/library/backend/palmtoprecord.h
+++ b/library/backend/palmtoprecord.h
@@ -1,95 +1,107 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef QTPALMTOP_RECORD_H 20#ifndef QTPALMTOP_RECORD_H
21#define QTPALMTOP_RECORD_H 21#define QTPALMTOP_RECORD_H
22#include <qglobal.h> 22#include <qglobal.h>
23#include "qpcglobal.h" 23#include "qpcglobal.h"
24#include "palmtopuidgen.h" 24#include "palmtopuidgen.h"
25#include <qarray.h> 25#include <qarray.h>
26#include <qmap.h> 26#include <qmap.h>
27 27
28#if defined(QPC_TEMPLATEDLL) 28#if defined(QPC_TEMPLATEDLL)
29// MOC_SKIP_BEGIN 29// MOC_SKIP_BEGIN
30QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<QString, QString>; 30QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<QString, QString>;
31// MOC_SKIP_END 31// MOC_SKIP_END
32#endif 32#endif
33 33
34class QRegExp; 34class QRegExp;
35/**
36 * @short Qtopia namespace
37 * The namespace of Qtopia
38 */
35namespace Qtopia { 39namespace Qtopia {
36 40
37class RecordPrivate; 41class RecordPrivate;
42/**
43 * @short The base class of all Records
44 *
45 * The base class for Records in Qtopia
46 * @see Task
47 * @see Event
48 * @see Contact
49 */
38class QPC_EXPORT Record 50class QPC_EXPORT Record
39{ 51{
40public: 52public:
41 Record() : mUid(0), mCats() { } 53 Record() : mUid(0), mCats() { }
42 Record( const Record &c ) :mUid( c.mUid ), mCats ( c.mCats ), customMap(c.customMap) { } 54 Record( const Record &c ) :mUid( c.mUid ), mCats ( c.mCats ), customMap(c.customMap) { }
43 virtual ~Record() { } 55 virtual ~Record() { }
44 56
45 Record &operator=( const Record &c ); 57 Record &operator=( const Record &c );
46 58
47 virtual bool match( const QRegExp & ) const { return FALSE; } 59 virtual bool match( const QRegExp & ) const { return FALSE; }
48 60
49 void setCategories( const QArray<int> &v ) { mCats = v; mCats.sort(); } 61 void setCategories( const QArray<int> &v ) { mCats = v; mCats.sort(); }
50 void setCategories( int single ); 62 void setCategories( int single );
51 const QArray<int> &categories() const { return mCats; } 63 const QArray<int> &categories() const { return mCats; }
52 64
53 void reassignCategoryId( int oldId, int newId ) 65 void reassignCategoryId( int oldId, int newId )
54 { 66 {
55 int index = mCats.find( oldId ); 67 int index = mCats.find( oldId );
56 if ( index >= 0 ) 68 if ( index >= 0 )
57 mCats[index] = newId; 69 mCats[index] = newId;
58 } 70 }
59 71
60 int uid() const { return mUid; }; 72 int uid() const { return mUid; };
61 virtual void setUid( int i ) { mUid = i; uidGen().store( mUid ); } 73 virtual void setUid( int i ) { mUid = i; uidGen().store( mUid ); }
62 bool isValidUid() const { return mUid != 0; } 74 bool isValidUid() const { return mUid != 0; }
63 void assignUid() { setUid( uidGen().generate() ); } 75 void assignUid() { setUid( uidGen().generate() ); }
64 76
65 virtual QString customField(const QString &) const; 77 virtual QString customField(const QString &) const;
66 virtual void setCustomField(const QString &, const QString &); 78 virtual void setCustomField(const QString &, const QString &);
67 virtual void removeCustomField(const QString &); 79 virtual void removeCustomField(const QString &);
68 80
69 virtual bool operator == ( const Record &r ) const 81 virtual bool operator == ( const Record &r ) const
70{ return mUid == r.mUid; } 82{ return mUid == r.mUid; }
71 virtual bool operator != ( const Record &r ) const 83 virtual bool operator != ( const Record &r ) const
72{ return mUid != r.mUid; } 84{ return mUid != r.mUid; }
73 85
74 // convenience methods provided for loading and saving to xml 86 // convenience methods provided for loading and saving to xml
75 static QString idsToString( const QArray<int> &ids ); 87 static QString idsToString( const QArray<int> &ids );
76 // convenience methods provided for loading and saving to xml 88 // convenience methods provided for loading and saving to xml
77 static QArray<int> idsFromString( const QString &str ); 89 static QArray<int> idsFromString( const QString &str );
78 90
79 // for debugging 91 // for debugging
80 static void dump( const QMap<int, QString> &map ); 92 static void dump( const QMap<int, QString> &map );
81 93
82protected: 94protected:
83 virtual UidGen &uidGen() = 0; 95 virtual UidGen &uidGen() = 0;
84 virtual QString customToXml() const; 96 virtual QString customToXml() const;
85private: 97private:
86 int mUid; 98 int mUid;
87 QArray<int> mCats; 99 QArray<int> mCats;
88 QMap<QString, QString> customMap; 100 QMap<QString, QString> customMap;
89 RecordPrivate *d; 101 RecordPrivate *d;
90}; 102};
91 103
92} 104}
93 105
94#endif 106#endif
95 107
diff --git a/library/datebookdb.cpp b/library/datebookdb.cpp
index 0fedfa8..2f33255 100644
--- a/library/datebookdb.cpp
+++ b/library/datebookdb.cpp
@@ -10,129 +10,129 @@
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 <qasciidict.h> 21#include <qasciidict.h>
22#include <qfile.h> 22#include <qfile.h>
23#include <qmessagebox.h> 23#include <qmessagebox.h>
24#include <qstring.h> 24#include <qstring.h>
25#include <qtextcodec.h> 25#include <qtextcodec.h>
26#include <qtextstream.h> 26#include <qtextstream.h>
27#include <qtl.h> 27#include <qtl.h>
28 28
29#include <qpe/alarmserver.h> 29#include <qpe/alarmserver.h>
30#include <qpe/global.h> 30#include <qpe/global.h>
31#include "datebookdb.h" 31#include "datebookdb.h"
32#include <qpe/stringutil.h> 32#include <qpe/stringutil.h>
33#include <qpe/timeconversion.h> 33#include <qpe/timeconversion.h>
34 34
35#include <errno.h> 35#include <errno.h>
36#include <stdlib.h> 36#include <stdlib.h>
37 37
38 38
39class DateBookDBPrivate 39class DateBookDBPrivate
40{ 40{
41public: 41public:
42 bool clean; // indcate whether we need to write to disk... 42 bool clean; // indcate whether we need to write to disk...
43}; 43};
44 44
45 45
46// Helper functions 46// Helper functions
47 47
48static QString dateBookJournalFile() 48static QString dateBookJournalFile()
49{ 49{
50 QString str = getenv("HOME"); 50 QString str = getenv("HOME");
51 return QString( str +"/.caljournal" ); 51 return QString( str +"/.caljournal" );
52} 52}
53 53
54static QString dateBookFilename() 54static QString dateBookFilename()
55{ 55{
56 return Global::applicationFileName("datebook","datebook.xml"); 56 return Global::applicationFileName("datebook","datebook.xml");
57} 57}
58 58
59/* Calculating the next event of a recuring event is actually 59/* Calculating the next event of a recuring event is actually
60 computationally inexpensive, esp. compared to checking each day 60 computationally inexpensive, esp. compared to checking each day
61 individually. There are bad worse cases for say the 29th of 61 individually. There are bad worse cases for say the 29th of
62 february or the 31st of some other months. However 62 february or the 31st of some other months. However
63 these are still bounded */ 63 these are still bounded */
64bool nextOccurance(const Event &e, const QDate &from, QDateTime &next) 64bool nextOccurance(const Event &e, const QDate &from, QDateTime &next)
65{ 65{
66 // easy checks, first are we too far in the future or too far in the past? 66 // easy checks, first are we too far in the future or too far in the past?
67 QDate tmpDate; 67 QDate tmpDate;
68 int freq = e.repeatPattern().frequency; 68 int freq = e.repeatPattern().frequency;
69 int diff, diff2, a; 69 int diff, diff2, a;
70 int iday, imonth, iyear; 70 int iday, imonth, iyear;
71 int dayOfWeek = 0; 71 int dayOfWeek = 0;
72 int firstOfWeek = 0; 72 int firstOfWeek = 0;
73 int weekOfMonth; 73 int weekOfMonth;
74 74
75 75
76 if (e.repeatPattern().hasEndDate && e.repeatPattern().endDate() < from) 76 if (e.repeatPattern().hasEndDate && e.repeatPattern().endDate() < from)
77 return FALSE; 77 return FALSE;
78 78
79 if (e.start() >= from) { 79 if (e.start() >= from) {
80 next = e.start(); 80 next = e.start();
81 return TRUE; 81 return TRUE;
82 } 82 }
83 83
84 switch ( e.repeatPattern().type ) { 84 switch ( e.repeatPattern().type ) {
85 case Event::Weekly: 85 case Event::Weekly:
86 /* weekly is just daily by 7 */ 86 /* weekly is just daily by 7 */
87 /* first convert the repeatPattern.Days() mask to the next 87 /* first convert the repeatPattern.Days() mask to the next
88 day of week valid after from */ 88 day of week valid after from */
89 dayOfWeek = from.dayOfWeek(); 89 dayOfWeek = from.dayOfWeek();
90 dayOfWeek--; /* we want 0-6, doco for above specs 1-7 */ 90 dayOfWeek--; /* we want 0-6, doco for above specs 1-7 */
91 91
92 /* this is done in case freq > 1 and from in week not 92 /* this is done in case freq > 1 and from in week not
93 for this round */ 93 for this round */
94 // firstOfWeek = 0; this is already done at decl. 94 // firstOfWeek = 0; this is already done at decl.
95 while(!((1 << firstOfWeek) & e.repeatPattern().days)) 95 while(!((1 << firstOfWeek) & e.repeatPattern().days))
96 firstOfWeek++; 96 firstOfWeek++;
97 97
98 /* there is at least one 'day', or there would be no event */ 98 /* there is at least one 'day', or there would be no event */
99 while(!((1 << (dayOfWeek % 7)) & e.repeatPattern().days)) 99 while(!((1 << (dayOfWeek % 7)) & e.repeatPattern().days))
100 dayOfWeek++; 100 dayOfWeek++;
101 101
102 dayOfWeek = dayOfWeek % 7; /* the actual day of week */ 102 dayOfWeek = dayOfWeek % 7; /* the actual day of week */
103 dayOfWeek -= e.start().date().dayOfWeek() -1; 103 dayOfWeek -= e.start().date().dayOfWeek() -1;
104 104
105 firstOfWeek = firstOfWeek % 7; /* the actual first of week */ 105 firstOfWeek = firstOfWeek % 7; /* the actual first of week */
106 firstOfWeek -= e.start().date().dayOfWeek() -1; 106 firstOfWeek -= e.start().date().dayOfWeek() -1;
107 107
108 // dayOfWeek may be negitive now 108 // dayOfWeek may be negitive now
109 // day of week is number of days to add to start day 109 // day of week is number of days to add to start day
110 110
111 freq *= 7; 111 freq *= 7;
112 // FALL-THROUGH !!!!! 112 // FALL-THROUGH !!!!!
113 case Event::Daily: 113 case Event::Daily:
114 // the add is for the possible fall through from weekly */ 114 // the add is for the possible fall through from weekly */
115 if(e.start().date().addDays(dayOfWeek) > from) { 115 if(e.start().date().addDays(dayOfWeek) > from) {
116 /* first week exception */ 116 /* first week exception */
117 next = QDateTime(e.start().date().addDays(dayOfWeek), 117 next = QDateTime(e.start().date().addDays(dayOfWeek),
118 e.start().time()); 118 e.start().time());
119 if ((next.date() > e.repeatPattern().endDate()) 119 if ((next.date() > e.repeatPattern().endDate())
120 && e.repeatPattern().hasEndDate) 120 && e.repeatPattern().hasEndDate)
121 return FALSE; 121 return FALSE;
122 return TRUE; 122 return TRUE;
123 } 123 }
124 /* if from is middle of a non-week */ 124 /* if from is middle of a non-week */
125 125
126 diff = e.start().date().addDays(dayOfWeek).daysTo(from) % freq; 126 diff = e.start().date().addDays(dayOfWeek).daysTo(from) % freq;
127 diff2 = e.start().date().addDays(firstOfWeek).daysTo(from) % freq; 127 diff2 = e.start().date().addDays(firstOfWeek).daysTo(from) % freq;
128 128
129 if(diff != 0) 129 if(diff != 0)
130 diff = freq - diff; 130 diff = freq - diff;
131 if(diff2 != 0) 131 if(diff2 != 0)
132 diff2 = freq - diff2; 132 diff2 = freq - diff2;
133 diff = QMIN(diff, diff2); 133 diff = QMIN(diff, diff2);
134 134
135 next = QDateTime(from.addDays(diff), e.start().time()); 135 next = QDateTime(from.addDays(diff), e.start().time());
136 if ( (next.date() > e.repeatPattern().endDate()) 136 if ( (next.date() > e.repeatPattern().endDate())
137 && e.repeatPattern().hasEndDate ) 137 && e.repeatPattern().hasEndDate )
138 return FALSE; 138 return FALSE;
@@ -400,391 +400,391 @@ DateBookDB::~DateBookDB()
400QValueList<Event> DateBookDB::getEvents( const QDate &from, const QDate &to ) 400QValueList<Event> DateBookDB::getEvents( const QDate &from, const QDate &to )
401{ 401{
402 QValueList<Event> tmpList; 402 QValueList<Event> tmpList;
403 tmpList = getNonRepeatingEvents( from, to ); 403 tmpList = getNonRepeatingEvents( from, to );
404 404
405 // check for repeating events... 405 // check for repeating events...
406 for (QValueList<Event>::ConstIterator it = repeatEvents.begin(); 406 for (QValueList<Event>::ConstIterator it = repeatEvents.begin();
407 it != repeatEvents.end(); ++it) { 407 it != repeatEvents.end(); ++it) {
408 QDate itDate = from; 408 QDate itDate = from;
409 QDateTime due; 409 QDateTime due;
410 410
411 /* create a false end date, to short circuit on hard 411 /* create a false end date, to short circuit on hard
412 MonthlyDay recurences */ 412 MonthlyDay recurences */
413 Event dummy_event = *it; 413 Event dummy_event = *it;
414 Event::RepeatPattern r = dummy_event.repeatPattern(); 414 Event::RepeatPattern r = dummy_event.repeatPattern();
415 if ( !r.hasEndDate || r.endDate() > to ) { 415 if ( !r.hasEndDate || r.endDate() > to ) {
416 r.setEndDate( to ); 416 r.setEndDate( to );
417 r.hasEndDate = TRUE; 417 r.hasEndDate = TRUE;
418 } 418 }
419 dummy_event.setRepeat(TRUE, r); 419 dummy_event.setRepeat(TRUE, r);
420 420
421 while (nextOccurance(dummy_event, itDate, due)) { 421 while (nextOccurance(dummy_event, itDate, due)) {
422 if (due.date() > to) 422 if (due.date() > to)
423 break; 423 break;
424 Event newEvent = *it; 424 Event newEvent = *it;
425 newEvent.setStart(due); 425 newEvent.setStart(due);
426 newEvent.setEnd(due.addSecs((*it).start().secsTo((*it).end()))); 426 newEvent.setEnd(due.addSecs((*it).start().secsTo((*it).end())));
427 427
428 tmpList.append(newEvent); 428 tmpList.append(newEvent);
429 itDate = due.date().addDays(1); /* the next event */ 429 itDate = due.date().addDays(1); /* the next event */
430 } 430 }
431 } 431 }
432 qHeapSort(tmpList); 432 qHeapSort(tmpList);
433 return tmpList; 433 return tmpList;
434} 434}
435 435
436QValueList<Event> DateBookDB::getEvents( const QDateTime &start ) 436QValueList<Event> DateBookDB::getEvents( const QDateTime &start )
437{ 437{
438 QValueList<Event> day = getEvents(start.date(),start.date()); 438 QValueList<Event> day = getEvents(start.date(),start.date());
439 439
440 QValueListConstIterator<Event> it; 440 QValueListConstIterator<Event> it;
441 QDateTime dtTmp; 441 QDateTime dtTmp;
442 QValueList<Event> tmpList; 442 QValueList<Event> tmpList;
443 for (it = day.begin(); it != day.end(); ++it ) { 443 for (it = day.begin(); it != day.end(); ++it ) {
444 dtTmp = (*it).start(TRUE); 444 dtTmp = (*it).start(TRUE);
445 if ( dtTmp == start ) 445 if ( dtTmp == start )
446 tmpList.append( *it ); 446 tmpList.append( *it );
447 } 447 }
448 return tmpList; 448 return tmpList;
449} 449}
450 450
451//#### Why is this code duplicated in getEvents ????? 451//#### Why is this code duplicated in getEvents ?????
452 452
453QValueList<EffectiveEvent> DateBookDB::getEffectiveEvents( const QDate &from, 453QValueList<EffectiveEvent> DateBookDB::getEffectiveEvents( const QDate &from,
454 const QDate &to ) 454 const QDate &to )
455{ 455{
456 QValueList<EffectiveEvent> tmpList; 456 QValueList<EffectiveEvent> tmpList;
457 QValueListIterator<Event> it; 457 QValueListIterator<Event> it;
458 458
459 EffectiveEvent effEv; 459 EffectiveEvent effEv;
460 QDateTime dtTmp, 460 QDateTime dtTmp,
461 dtEnd; 461 dtEnd;
462 462
463 for (it = eventList.begin(); it != eventList.end(); ++it ) { 463 for (it = eventList.begin(); it != eventList.end(); ++it ) {
464 if (!(*it).isValidUid()) 464 if (!(*it).isValidUid())
465 (*it).assignUid(); // FIXME: Hack to restore cleared uids 465 (*it).assignUid(); // FIXME: Hack to restore cleared uids
466 466
467 dtTmp = (*it).start(TRUE); 467 dtTmp = (*it).start(TRUE);
468 dtEnd = (*it).end(TRUE); 468 dtEnd = (*it).end(TRUE);
469 469
470 if ( dtTmp.date() >= from && dtTmp.date() <= to ) { 470 if ( dtTmp.date() >= from && dtTmp.date() <= to ) {
471 Event tmpEv = *it; 471 Event tmpEv = *it;
472 effEv.setEvent(tmpEv); 472 effEv.setEvent(tmpEv);
473 effEv.setDate( dtTmp.date() ); 473 effEv.setDate( dtTmp.date() );
474 effEv.setStart( dtTmp.time() ); 474 effEv.setStart( dtTmp.time() );
475 if ( dtTmp.date() != dtEnd.date() ) 475 if ( dtTmp.date() != dtEnd.date() )
476 effEv.setEnd( QTime(23, 59, 0) ); 476 effEv.setEnd( QTime(23, 59, 0) );
477 else 477 else
478 effEv.setEnd( dtEnd.time() ); 478 effEv.setEnd( dtEnd.time() );
479 tmpList.append( effEv ); 479 tmpList.append( effEv );
480 } 480 }
481 // we must also check for end date information... 481 // we must also check for end date information...
482 if ( dtEnd.date() != dtTmp.date() && dtEnd.date() >= from ) { 482 if ( dtEnd.date() != dtTmp.date() && dtEnd.date() >= from ) {
483 QDateTime dt = dtTmp.addDays( 1 ); 483 QDateTime dt = dtTmp.addDays( 1 );
484 dt.setTime( QTime(0, 0, 0) ); 484 dt.setTime( QTime(0, 0, 0) );
485 QDateTime dtStop; 485 QDateTime dtStop;
486 if ( dtEnd > to ) { 486 if ( dtEnd > to ) {
487 dtStop = to; 487 dtStop = to;
488 } else 488 } else
489 dtStop = dtEnd; 489 dtStop = dtEnd;
490 while ( dt <= dtStop ) { 490 while ( dt <= dtStop ) {
491 Event tmpEv = *it; 491 Event tmpEv = *it;
492 effEv.setEvent( tmpEv ); 492 effEv.setEvent( tmpEv );
493 effEv.setDate( dt.date() ); 493 effEv.setDate( dt.date() );
494 if ( dt >= from ) { 494 if ( dt >= from ) {
495 effEv.setStart( QTime(0, 0, 0) ); 495 effEv.setStart( QTime(0, 0, 0) );
496 if ( dt.date() == dtEnd.date() ) 496 if ( dt.date() == dtEnd.date() )
497 effEv.setEnd( dtEnd.time() ); 497 effEv.setEnd( dtEnd.time() );
498 else 498 else
499 effEv.setEnd( QTime(23, 59, 59) ); 499 effEv.setEnd( QTime(23, 59, 59) );
500 tmpList.append( effEv ); 500 tmpList.append( effEv );
501 } 501 }
502 dt = dt.addDays( 1 ); 502 dt = dt.addDays( 1 );
503 } 503 }
504 } 504 }
505 } 505 }
506 // check for repeating events... 506 // check for repeating events...
507 QDateTime repeat; 507 QDateTime repeat;
508 for ( it = repeatEvents.begin(); it != repeatEvents.end(); ++it ) { 508 for ( it = repeatEvents.begin(); it != repeatEvents.end(); ++it ) {
509 if (!(*it).isValidUid()) 509 if (!(*it).isValidUid())
510 (*it).assignUid(); // FIXME: Hack to restore cleared uids 510 (*it).assignUid(); // FIXME: Hack to restore cleared uids
511 511
512 /* create a false end date, to short circuit on hard 512 /* create a false end date, to short circuit on hard
513 MonthlyDay recurences */ 513 MonthlyDay recurences */
514 Event dummy_event = *it; 514 Event dummy_event = *it;
515 int duration = (*it).start().date().daysTo( (*it).end().date() ); 515 int duration = (*it).start().date().daysTo( (*it).end().date() );
516 QDate itDate = from.addDays(-duration); 516 QDate itDate = from.addDays(-duration);
517 517
518 Event::RepeatPattern r = dummy_event.repeatPattern(); 518 Event::RepeatPattern r = dummy_event.repeatPattern();
519 if ( !r.hasEndDate || r.endDate() > to ) { 519 if ( !r.hasEndDate || r.endDate() > to ) {
520 r.setEndDate( to ); 520 r.setEndDate( to );
521 r.hasEndDate = TRUE; 521 r.hasEndDate = TRUE;
522 } 522 }
523 dummy_event.setRepeat(TRUE, r); 523 dummy_event.setRepeat(TRUE, r);
524 524
525 while (nextOccurance(dummy_event, itDate, repeat)) { 525 while (nextOccurance(dummy_event, itDate, repeat)) {
526 if(repeat.date() > to) 526 if(repeat.date() > to)
527 break; 527 break;
528 effEv.setDate( repeat.date() ); 528 effEv.setDate( repeat.date() );
529 if ((*it).type() == Event::AllDay) { 529 if ((*it).type() == Event::AllDay) {
530 effEv.setStart( QTime(0,0,0) ); 530 effEv.setStart( QTime(0,0,0) );
531 effEv.setEnd( QTime(23,59,59) ); 531 effEv.setEnd( QTime(23,59,59) );
532 } else { 532 } else {
533 /* we only occur by days, not hours/minutes/seconds. Hence 533 /* we only occur by days, not hours/minutes/seconds. Hence
534 the actual end and start times will be the same for 534 the actual end and start times will be the same for
535 every repeated event. For multi day events this is 535 every repeated event. For multi day events this is
536 fixed up later if on wronge day span */ 536 fixed up later if on wronge day span */
537 effEv.setStart( (*it).start().time() ); 537 effEv.setStart( (*it).start().time() );
538 effEv.setEnd( (*it).end().time() ); 538 effEv.setEnd( (*it).end().time() );
539 } 539 }
540 if ( duration != 0 ) { 540 if ( duration != 0 ) {
541 // multi-day repeating events 541 // multi-day repeating events
542 QDate sub_it = QMAX( repeat.date(), from ); 542 QDate sub_it = QMAX( repeat.date(), from );
543 QDate startDate = repeat.date(); 543 QDate startDate = repeat.date();
544 QDate endDate = startDate.addDays( duration ); 544 QDate endDate = startDate.addDays( duration );
545 545
546 while ( sub_it <= endDate && sub_it <= to ) { 546 while ( sub_it <= endDate && sub_it <= to ) {
547 EffectiveEvent tmpEffEv = effEv; 547 EffectiveEvent tmpEffEv = effEv;
548 Event tmpEv = *it; 548 Event tmpEv = *it;
549 tmpEffEv.setEvent( tmpEv ); 549 tmpEffEv.setEvent( tmpEv );
550 550
551 if ( sub_it != startDate ) 551 if ( sub_it != startDate )
552 tmpEffEv.setStart( QTime(0,0,0) ); 552 tmpEffEv.setStart( QTime(0,0,0) );
553 if ( sub_it != endDate ) 553 if ( sub_it != endDate )
554 tmpEffEv.setEnd( QTime(23,59,59) ); 554 tmpEffEv.setEnd( QTime(23,59,59) );
555 tmpEffEv.setDate( sub_it ); 555 tmpEffEv.setDate( sub_it );
556 tmpEffEv.setEffectiveDates( startDate, endDate ); 556 tmpEffEv.setEffectiveDates( startDate, endDate );
557 tmpList.append( tmpEffEv ); 557 tmpList.append( tmpEffEv );
558 sub_it = sub_it.addDays( 1 ); 558 sub_it = sub_it.addDays( 1 );
559 } 559 }
560 itDate = endDate; 560 itDate = endDate;
561 } else { 561 } else {
562 Event tmpEv = *it; 562 Event tmpEv = *it;
563 effEv.setEvent( tmpEv ); 563 effEv.setEvent( tmpEv );
564 tmpList.append( effEv ); 564 tmpList.append( effEv );
565 itDate = repeat.date().addDays( 1 ); 565 itDate = repeat.date().addDays( 1 );
566 } 566 }
567 } 567 }
568 } 568 }
569 569
570 qHeapSort( tmpList ); 570 qHeapSort( tmpList );
571 return tmpList; 571 return tmpList;
572} 572}
573 573
574QValueList<EffectiveEvent> DateBookDB::getEffectiveEvents( const QDateTime &dt) 574QValueList<EffectiveEvent> DateBookDB::getEffectiveEvents( const QDateTime &dt)
575{ 575{
576 QValueList<EffectiveEvent> day = getEffectiveEvents(dt.date(), dt.date()); 576 QValueList<EffectiveEvent> day = getEffectiveEvents(dt.date(), dt.date());
577 QValueListConstIterator<EffectiveEvent> it; 577 QValueListConstIterator<EffectiveEvent> it;
578 QValueList<EffectiveEvent> tmpList; 578 QValueList<EffectiveEvent> tmpList;
579 QDateTime dtTmp; 579 QDateTime dtTmp;
580 580
581 for (it = day.begin(); it != day.end(); ++it ) { 581 for (it = day.begin(); it != day.end(); ++it ) {
582 dtTmp = QDateTime( (*it).date(), (*it).start() ); 582 dtTmp = QDateTime( (*it).date(), (*it).start() );
583 // at the moment we don't have second granularity, be nice about that.. 583 // at the moment we don't have second granularity, be nice about that..
584 if ( QABS(dt.secsTo(dtTmp)) < 60 ) 584 if ( QABS(dt.secsTo(dtTmp)) < 60 )
585 tmpList.append( *it ); 585 tmpList.append( *it );
586 } 586 }
587 return tmpList; 587 return tmpList;
588} 588}
589 589
590void DateBookDB::addEvent( const Event &ev, bool doalarm ) 590void DateBookDB::addEvent( const Event &ev, bool doalarm )
591{ 591{
592 // write to the journal... 592 // write to the journal...
593 saveJournalEntry( ev, ACTION_ADD, -1, false ); 593 saveJournalEntry( ev, ACTION_ADD, -1, false );
594 addJFEvent( ev, doalarm ); 594 addJFEvent( ev, doalarm );
595 d->clean = false; 595 d->clean = false;
596} 596}
597 597
598void DateBookDB::addJFEvent( const Event &ev, bool doalarm ) 598void DateBookDB::addJFEvent( const Event &ev, bool doalarm )
599{ 599{
600 if ( doalarm && ev.hasAlarm() ) 600 if ( doalarm && ev.hasAlarm() )
601 addEventAlarm( ev ); 601 addEventAlarm( ev );
602 if ( ev.hasRepeat() ) 602 if ( ev.hasRepeat() )
603 repeatEvents.append( ev ); 603 repeatEvents.append( ev );
604 else 604 else
605 eventList.append( ev ); 605 eventList.append( ev );
606} 606}
607 607
608void DateBookDB::editEvent( const Event &old, Event &editedEv ) 608void DateBookDB::editEvent( const Event &old, Event &editedEv )
609{ 609{
610 int oldIndex=0; 610 int oldIndex=0;
611 bool oldHadRepeat = old.hasRepeat(); 611 bool oldHadRepeat = old.hasRepeat();
612 Event orig; 612 Event orig;
613 613
614 // write to the journal... 614 // write to the journal...
615 if ( oldHadRepeat ) { 615 if ( oldHadRepeat ) {
616 if ( origRepeat( old, orig ) ) // should work always... 616 if ( origRepeat( old, orig ) ) // should work always...
617 oldIndex = repeatEvents.findIndex( orig ); 617 oldIndex = repeatEvents.findIndex( orig );
618 } else 618 } else
619 oldIndex = eventList.findIndex( old ); 619 oldIndex = eventList.findIndex( old );
620 saveJournalEntry( editedEv, ACTION_REPLACE, oldIndex, oldHadRepeat ); 620 saveJournalEntry( editedEv, ACTION_REPLACE, oldIndex, oldHadRepeat );
621 621
622 // Delete old event 622 // Delete old event
623 if ( old.hasAlarm() ) 623 if ( old.hasAlarm() )
624 delEventAlarm( old ); 624 delEventAlarm( old );
625 if ( oldHadRepeat ) { 625 if ( oldHadRepeat ) {
626 if ( editedEv.hasRepeat() ) { // This mean that origRepeat was run above and 626 if ( editedEv.hasRepeat() ) { // This mean that origRepeat was run above and
627 // orig is initialized 627 // orig is initialized
628 // assumption, when someone edits a repeating event, they 628 // assumption, when someone edits a repeating event, they
629 // want to change them all, maybe not perfect, but it works 629 // want to change them all, maybe not perfect, but it works
630 // for the moment... 630 // for the moment...
631 repeatEvents.remove( orig ); 631 repeatEvents.remove( orig );
632 } else 632 } else
633 removeRepeat( old ); 633 removeRepeat( old );
634 } else { 634 } else {
635 QValueList<Event>::Iterator it = eventList.find( old ); 635 QValueList<Event>::Iterator it = eventList.find( old );
636 if ( it != eventList.end() ) 636 if ( it != eventList.end() )
637 eventList.remove( it ); 637 eventList.remove( it );
638 } 638 }
639 639
640 // Add new event 640 // Add new event
641 if ( editedEv.hasAlarm() ) 641 if ( editedEv.hasAlarm() )
642 addEventAlarm( editedEv ); 642 addEventAlarm( editedEv );
643 if ( editedEv.hasRepeat() ) 643 if ( editedEv.hasRepeat() )
644 repeatEvents.append( editedEv ); 644 repeatEvents.append( editedEv );
645 else 645 else
646 eventList.append( editedEv ); 646 eventList.append( editedEv );
647 647
648 d->clean = false; 648 d->clean = false;
649} 649}
650 650
651void DateBookDB::removeEvent( const Event &ev ) 651void DateBookDB::removeEvent( const Event &ev )
652{ 652{
653 // write to the journal... 653 // write to the journal...
654 saveJournalEntry( ev, ACTION_REMOVE, -1, false ); 654 saveJournalEntry( ev, ACTION_REMOVE, -1, false );
655 removeJFEvent( ev ); 655 removeJFEvent( ev );
656 d->clean = false; 656 d->clean = false;
657} 657}
658 658
659void DateBookDB::removeJFEvent( const Event&ev ) 659void DateBookDB::removeJFEvent( const Event&ev )
660{ 660{
661 if ( ev.hasAlarm() ) 661 if ( ev.hasAlarm() )
662 delEventAlarm( ev ); 662 delEventAlarm( ev );
663 if ( ev.hasRepeat() ) { 663 if ( ev.hasRepeat() ) {
664 removeRepeat( ev ); 664 removeRepeat( ev );
665 } else { 665 } else {
666 QValueList<Event>::Iterator it = eventList.find( ev ); 666 QValueList<Event>::Iterator it = eventList.find( ev );
667 if ( it != eventList.end() ) 667 if ( it != eventList.end() )
668 eventList.remove( it ); 668 eventList.remove( it );
669 } 669 }
670} 670}
671 671
672// also handles journaling... 672// also handles journaling...
673void DateBookDB::loadFile( const QString &strFile ) 673void DateBookDB::loadFile( const QString &strFile )
674{ 674{
675 675
676 QFile f( strFile ); 676 QFile f( strFile );
677 if ( !f.open( IO_ReadOnly ) ) 677 if ( !f.open( IO_ReadOnly ) )
678 return; 678 return;
679 679
680 enum Attribute { 680 enum Attribute {
681 FDescription = 0, 681 FDescription = 0,
682 FLocation, 682 FLocation,
683 FCategories, 683 FCategories,
684 FUid, 684 FUid,
685 FType, 685 FType,
686 FAlarm, 686 FAlarm,
687 FSound, 687 FSound,
688 FRType, 688 FRType,
689 FRWeekdays, 689 FRWeekdays,
690 FRPosition, 690 FRPosition,
691 FRFreq, 691 FRFreq,
692 FRHasEndDate, 692 FRHasEndDate,
693 FREndDate, 693 FREndDate,
694 FRStart, 694 FRStart,
695 FREnd, 695 FREnd,
696 FNote, 696 FNote,
697 FCreated, 697 FCreated,
698 FAction, 698 FAction,
699 FActionKey, 699 FActionKey,
700 FJournalOrigHadRepeat 700 FJournalOrigHadRepeat
701 }; 701 };
702 702
703 QAsciiDict<int> dict( 97 ); 703 QAsciiDict<int> dict( 97 );
704 dict.setAutoDelete( TRUE ); 704 dict.setAutoDelete( TRUE );
705 dict.insert( "description", new int(FDescription) ); 705 dict.insert( "description", new int(FDescription) );
706 dict.insert( "location", new int(FLocation) ); 706 dict.insert( "location", new int(FLocation) );
707 dict.insert( "categories", new int(FCategories) ); 707 dict.insert( "categories", new int(FCategories) );
708 dict.insert( "uid", new int(FUid) ); 708 dict.insert( "uid", new int(FUid) );
709 dict.insert( "type", new int(FType) ); 709 dict.insert( "type", new int(FType) );
710 dict.insert( "alarm", new int(FAlarm) ); 710 dict.insert( "alarm", new int(FAlarm) );
711 dict.insert( "sound", new int(FSound) ); 711 dict.insert( "sound", new int(FSound) );
712 dict.insert( "rtype", new int(FRType) ); 712 dict.insert( "rtype", new int(FRType) );
713 dict.insert( "rweekdays", new int(FRWeekdays) ); 713 dict.insert( "rweekdays", new int(FRWeekdays) );
714 dict.insert( "rposition", new int(FRPosition) ); 714 dict.insert( "rposition", new int(FRPosition) );
715 dict.insert( "rfreq", new int(FRFreq) ); 715 dict.insert( "rfreq", new int(FRFreq) );
716 dict.insert( "rhasenddate", new int(FRHasEndDate) ); 716 dict.insert( "rhasenddate", new int(FRHasEndDate) );
717 dict.insert( "enddt", new int(FREndDate) ); 717 dict.insert( "enddt", new int(FREndDate) );
718 dict.insert( "start", new int(FRStart) ); 718 dict.insert( "start", new int(FRStart) );
719 dict.insert( "end", new int(FREnd) ); 719 dict.insert( "end", new int(FREnd) );
720 dict.insert( "note", new int(FNote) ); 720 dict.insert( "note", new int(FNote) );
721 dict.insert( "created", new int(FCreated) ); 721 dict.insert( "created", new int(FCreated) );
722 dict.insert( "action", new int(FAction) ); 722 dict.insert( "action", new int(FAction) );
723 dict.insert( "actionkey", new int(FActionKey) ); 723 dict.insert( "actionkey", new int(FActionKey) );
724 dict.insert( "actionorig", new int (FJournalOrigHadRepeat) ); 724 dict.insert( "actionorig", new int (FJournalOrigHadRepeat) );
725 725
726 726
727 QByteArray ba = f.readAll(); 727 QByteArray ba = f.readAll();
728 char* dt = ba.data(); 728 char* dt = ba.data();
729 int len = ba.size(); 729 int len = ba.size();
730 int currentAction, 730 int currentAction,
731 journalKey, 731 journalKey,
732 origHadRepeat; // should be bool, but we need tri-state(not being used) 732 origHadRepeat; // should be bool, but we need tri-state(not being used)
733 733
734 int i = 0; 734 int i = 0;
735 char *point; 735 char *point;
736 // hack to get rid of segfaults after reading </DATEBOOK> 736 // hack to get rid of segfaults after reading </DATEBOOK>
737 while ( (dt+i != 0) && (( point = strstr( dt+i, "<event " ) ) != 0 )) { 737 while ( (dt+i != 0) && (( point = strstr( dt+i, "<event " ) ) != 0 )) {
738 i = point - dt; 738 i = point - dt;
739 // if we are reading in events in the general case, 739 // if we are reading in events in the general case,
740 // we are just adding them, so let the actions represent that... 740 // we are just adding them, so let the actions represent that...
741 currentAction = ACTION_ADD; 741 currentAction = ACTION_ADD;
742 journalKey = -1; 742 journalKey = -1;
743 origHadRepeat = -1; 743 origHadRepeat = -1;
744 // some temporary variables for dates and times ... 744 // some temporary variables for dates and times ...
745 //int startY = 0, startM = 0, startD = 0, starth = 0, startm = 0, starts = 0; 745 //int startY = 0, startM = 0, startD = 0, starth = 0, startm = 0, starts = 0;
746 //int endY = 0, endM = 0, endD = 0, endh = 0, endm = 0, ends = 0; 746 //int endY = 0, endM = 0, endD = 0, endh = 0, endm = 0, ends = 0;
747 //int enddtY = 0, enddtM = 0, enddtD = 0; 747 //int enddtY = 0, enddtM = 0, enddtD = 0;
748 748
749 // ... for the alarm settings ... 749 // ... for the alarm settings ...
750 int alarmTime = -1; Event::SoundTypeChoice alarmSound = Event::Silent; 750 int alarmTime = -1; Event::SoundTypeChoice alarmSound = Event::Silent;
751 // ... and for the recurrence 751 // ... and for the recurrence
752 Event::RepeatPattern rp; 752 Event::RepeatPattern rp;
753 Event e; 753 Event e;
754 754
755 i += 7; 755 i += 7;
756 756
757 while( 1 ) { 757 while( 1 ) {
758 while ( i < len && (dt[i] == ' ' || dt[i] == '\n' || dt[i] == '\r') ) 758 while ( i < len && (dt[i] == ' ' || dt[i] == '\n' || dt[i] == '\r') )
759 ++i; 759 ++i;
760 if ( i >= len-2 || (dt[i] == '/' && dt[i+1] == '>') ) 760 if ( i >= len-2 || (dt[i] == '/' && dt[i+1] == '>') )
761 break; 761 break;
762 // we have another attribute, read it. 762 // we have another attribute, read it.
763 int j = i; 763 int j = i;
764 while ( j < len && dt[j] != '=' ) 764 while ( j < len && dt[j] != '=' )
765 ++j; 765 ++j;
766 char *attr = dt+i; 766 char *attr = dt+i;
767 dt[j] = '\0'; 767 dt[j] = '\0';
768 i = ++j; // skip = 768 i = ++j; // skip =
769 while ( i < len && dt[i] != '"' ) 769 while ( i < len && dt[i] != '"' )
770 ++i; 770 ++i;
771 j = ++i; 771 j = ++i;
772 bool haveAmp = FALSE; 772 bool haveAmp = FALSE;
773 bool haveUtf = FALSE; 773 bool haveUtf = FALSE;
774 while ( j < len && dt[j] != '"' ) { 774 while ( j < len && dt[j] != '"' ) {
775 if ( dt[j] == '&' ) 775 if ( dt[j] == '&' )
776 haveAmp = TRUE; 776 haveAmp = TRUE;
777 if ( ((unsigned char)dt[j]) > 0x7f ) 777 if ( ((unsigned char)dt[j]) > 0x7f )
778 haveUtf = TRUE; 778 haveUtf = TRUE;
779 ++j; 779 ++j;
780 } 780 }
781 781
782 if ( i == j ) { 782 if ( i == j ) {
783 // leave out empty attributes 783 // leave out empty attributes
784 i = j + 1; 784 i = j + 1;
785 continue; 785 continue;
786 } 786 }
787 787
788 QString value = haveUtf ? QString::fromUtf8( dt+i, j-i ) 788 QString value = haveUtf ? QString::fromUtf8( dt+i, j-i )
789 : QString::fromLatin1( dt+i, j-i ); 789 : QString::fromLatin1( dt+i, j-i );
790 if ( haveAmp ) 790 if ( haveAmp )
diff --git a/library/finddialog.cpp b/library/finddialog.cpp
index d9f430a..ddf41a7 100644
--- a/library/finddialog.cpp
+++ b/library/finddialog.cpp
@@ -1,78 +1,85 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the 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// WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT 21// WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT
22// have this class. 22// have this class.
23#define QTOPIA_INTERNAL_FD 23#define QTOPIA_INTERNAL_FD
24 24
25#include "finddialog.h" 25#include "finddialog.h"
26#include "findwidget_p.h" 26#include "findwidget_p.h"
27 27
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qpushbutton.h> 29#include <qpushbutton.h>
30 30
31/*!
32 \class FindDialog finddialog.h
33 \brief A simple FindDialog
34
35 A find dialog. FIXME!!!!
36
37*/
31FindDialog::FindDialog( const QString &appName, QWidget *parent, 38FindDialog::FindDialog( const QString &appName, QWidget *parent,
32 const char *name, bool modal ) 39 const char *name, bool modal )
33 : QDialog( parent, name, modal ) 40 : QDialog( parent, name, modal )
34{ 41{
35 setCaption( tr("Find") ); 42 setCaption( tr("Find") );
36 QVBoxLayout *vb; 43 QVBoxLayout *vb;
37 vb = new QVBoxLayout( this ); 44 vb = new QVBoxLayout( this );
38 fw = new FindWidget( appName, this, "Find Widget" ); 45 fw = new FindWidget( appName, this, "Find Widget" );
39 vb->addWidget( fw ); 46 vb->addWidget( fw );
40 QObject::connect( fw, SIGNAL(signalFindClicked(const QString&, 47 QObject::connect( fw, SIGNAL(signalFindClicked(const QString&,
41 bool,bool,int)), 48 bool,bool,int)),
42 this, SIGNAL(signalFindClicked(const QString&, 49 this, SIGNAL(signalFindClicked(const QString&,
43 bool,bool,int)) ); 50 bool,bool,int)) );
44 QObject::connect( fw, SIGNAL(signalFindClicked(const QString&,const QDate&, 51 QObject::connect( fw, SIGNAL(signalFindClicked(const QString&,const QDate&,
45 bool,bool,int)), 52 bool,bool,int)),
46 this, SIGNAL(signalFindClicked(const QString&, 53 this, SIGNAL(signalFindClicked(const QString&,
47 const QDate&,bool,bool,int)) ); 54 const QDate&,bool,bool,int)) );
48 d = 0; 55 d = 0;
49} 56}
50 57
51FindDialog::~FindDialog() 58FindDialog::~FindDialog()
52{ 59{
53} 60}
54 61
55QString FindDialog::findText() const 62QString FindDialog::findText() const
56{ 63{
57 return fw->findText(); 64 return fw->findText();
58} 65}
59 66
60void FindDialog::setUseDate( bool show ) 67void FindDialog::setUseDate( bool show )
61{ 68{
62 fw->setUseDate( show ); 69 fw->setUseDate( show );
63} 70}
64 71
65void FindDialog::setDate( const QDate &dt ) 72void FindDialog::setDate( const QDate &dt )
66{ 73{
67 fw->setDate( dt ); 74 fw->setDate( dt );
68} 75}
69 76
70void FindDialog::slotNotFound() 77void FindDialog::slotNotFound()
71{ 78{
72 fw->slotNotFound(); 79 fw->slotNotFound();
73} 80}
74 81
75void FindDialog::slotWrapAround() 82void FindDialog::slotWrapAround()
76{ 83{
77 fw->slotWrapAround(); 84 fw->slotWrapAround();
78} 85}
diff --git a/library/global.cpp b/library/global.cpp
index 68a3a75..ce39751 100644
--- a/library/global.cpp
+++ b/library/global.cpp
@@ -49,129 +49,129 @@
49 49
50#include <qfile.h> 50#include <qfile.h>
51 51
52namespace { 52namespace {
53 // checks if the storage should be searched 53 // checks if the storage should be searched
54 bool checkStorage(const QString &path ){ // this is a small Config replacement cause config is too limited -zecke 54 bool checkStorage(const QString &path ){ // this is a small Config replacement cause config is too limited -zecke
55 QFile file(path ); 55 QFile file(path );
56 if(!file.open(IO_ReadOnly ) ) 56 if(!file.open(IO_ReadOnly ) )
57 return true; 57 return true;
58 58
59 QByteArray array = file.readAll(); 59 QByteArray array = file.readAll();
60 QStringList list = QStringList::split('\n', QString( array ) ); 60 QStringList list = QStringList::split('\n', QString( array ) );
61 for(QStringList::Iterator it = list.begin(); it != list.end(); ++it ){ 61 for(QStringList::Iterator it = list.begin(); it != list.end(); ++it ){
62 if( (*it).startsWith("autocheck = 0" ) ){ 62 if( (*it).startsWith("autocheck = 0" ) ){
63 return false; 63 return false;
64 }else if( (*it).startsWith("autocheck = 1" ) ){ 64 }else if( (*it).startsWith("autocheck = 1" ) ){
65 return true; 65 return true;
66 } 66 }
67 } 67 }
68 return true; 68 return true;
69 } 69 }
70} 70}
71 71
72//#include "quickexec_p.h" 72//#include "quickexec_p.h"
73 73
74class Emitter : public QObject { 74class Emitter : public QObject {
75 Q_OBJECT 75 Q_OBJECT
76public: 76public:
77 Emitter( QWidget* receiver, const QString& document ) 77 Emitter( QWidget* receiver, const QString& document )
78 { 78 {
79 connect(this, SIGNAL(setDocument(const QString&)), 79 connect(this, SIGNAL(setDocument(const QString&)),
80 receiver, SLOT(setDocument(const QString&))); 80 receiver, SLOT(setDocument(const QString&)));
81 emit setDocument(document); 81 emit setDocument(document);
82 disconnect(this, SIGNAL(setDocument(const QString&)), 82 disconnect(this, SIGNAL(setDocument(const QString&)),
83 receiver, SLOT(setDocument(const QString&))); 83 receiver, SLOT(setDocument(const QString&)));
84 } 84 }
85 85
86signals: 86signals:
87 void setDocument(const QString&); 87 void setDocument(const QString&);
88}; 88};
89 89
90 90
91class StartingAppList : public QObject { 91class StartingAppList : public QObject {
92 Q_OBJECT 92 Q_OBJECT
93public: 93public:
94 static void add( const QString& name ); 94 static void add( const QString& name );
95 static bool isStarting( const QString name ); 95 static bool isStarting( const QString name );
96private slots: 96private slots:
97 void handleNewChannel( const QString &); 97 void handleNewChannel( const QString &);
98private: 98private:
99 StartingAppList( QObject *parent=0, const char* name=0 ) ; 99 StartingAppList( QObject *parent=0, const char* name=0 ) ;
100 100
101 QDict<QTime> dict; 101 QDict<QTime> dict;
102 static StartingAppList *appl; 102 static StartingAppList *appl;
103}; 103};
104 104
105StartingAppList* StartingAppList::appl = 0; 105StartingAppList* StartingAppList::appl = 0;
106 106
107StartingAppList::StartingAppList( QObject *parent, const char* name ) 107StartingAppList::StartingAppList( QObject *parent, const char* name )
108 :QObject( parent, name ) 108 :QObject( parent, name )
109{ 109{
110#if QT_VERSION >= 232 && defined(QWS) 110#if QT_VERSION >= 232 && defined(QWS)
111 connect( qwsServer, SIGNAL( newChannel(const QString&)), 111 connect( qwsServer, SIGNAL( newChannel(const QString&)),
112 this, SLOT( handleNewChannel(const QString&)) ); 112 this, SLOT( handleNewChannel(const QString&)) );
113 #endif 113#endif
114 dict.setAutoDelete( TRUE ); 114 dict.setAutoDelete( TRUE );
115} 115}
116 116
117void StartingAppList::add( const QString& name ) 117void StartingAppList::add( const QString& name )
118{ 118{
119#if QT_VERSION >= 232 && !defined(QT_NO_COP) 119#if QT_VERSION >= 232 && !defined(QT_NO_COP)
120 if ( !appl ) 120 if ( !appl )
121 appl = new StartingAppList; 121 appl = new StartingAppList;
122 QTime *t = new QTime; 122 QTime *t = new QTime;
123 t->start(); 123 t->start();
124 appl->dict.insert( "QPE/Application/" + name, t ); 124 appl->dict.insert( "QPE/Application/" + name, t );
125#endif 125#endif
126} 126}
127 127
128bool StartingAppList::isStarting( const QString name ) 128bool StartingAppList::isStarting( const QString name )
129{ 129{
130#if QT_VERSION >= 232 && !defined(QT_NO_COP) 130#if QT_VERSION >= 232 && !defined(QT_NO_COP)
131 if ( appl ) { 131 if ( appl ) {
132 QTime *t = appl->dict.find( "QPE/Application/" + name ); 132 QTime *t = appl->dict.find( "QPE/Application/" + name );
133 if ( !t ) 133 if ( !t )
134 return FALSE; 134 return FALSE;
135 if ( t->elapsed() > 10000 ) { 135 if ( t->elapsed() > 10000 ) {
136 // timeout in case of crash or something 136 // timeout in case of crash or something
137 appl->dict.remove( "QPE/Application/" + name ); 137 appl->dict.remove( "QPE/Application/" + name );
138 return FALSE; 138 return FALSE;
139 } 139 }
140 return TRUE; 140 return TRUE;
141 } 141 }
142#endif 142#endif
143 return FALSE; 143 return FALSE;
144} 144}
145 145
146void StartingAppList::handleNewChannel( const QString & name ) 146void StartingAppList::handleNewChannel( const QString & name )
147{ 147{
148#if QT_VERSION >= 232 && !defined(QT_NO_COP) 148#if QT_VERSION >= 232 && !defined(QT_NO_COP)
149 dict.remove( name ); 149 dict.remove( name );
150#endif 150#endif
151} 151}
152 152
153static bool docDirCreated = FALSE; 153static bool docDirCreated = FALSE;
154static QDawg* fixed_dawg = 0; 154static QDawg* fixed_dawg = 0;
155static QDict<QDawg> *named_dawg = 0; 155static QDict<QDawg> *named_dawg = 0;
156 156
157static QString qpeDir() 157static QString qpeDir()
158{ 158{
159 QString dir = getenv("OPIEDIR"); 159 QString dir = getenv("OPIEDIR");
160 if ( dir.isEmpty() ) dir = ".."; 160 if ( dir.isEmpty() ) dir = "..";
161 return dir; 161 return dir;
162} 162}
163 163
164static QString dictDir() 164static QString dictDir()
165{ 165{
166 return qpeDir() + "/etc/dict"; 166 return qpeDir() + "/etc/dict";
167} 167}
168 168
169/*! 169/*!
170 \class Global global.h 170 \class Global global.h
171 \brief The Global class provides application-wide global functions. 171 \brief The Global class provides application-wide global functions.
172 172
173 The Global functions are grouped as follows: 173 The Global functions are grouped as follows:
174 \tableofcontents 174 \tableofcontents
175 175
176 \section1 User Interface 176 \section1 User Interface
177 177
@@ -327,129 +327,129 @@ void Global::addWords(const QStringList& wordlist)
327 Note that the addition of words persists between program executions 327 Note that the addition of words persists between program executions
328 (they are saved in the dictionary files), so you should confirm the 328 (they are saved in the dictionary files), so you should confirm the
329 words with the user before adding them. 329 words with the user before adding them.
330*/ 330*/
331void Global::addWords(const QString& dictname, const QStringList& wordlist) 331void Global::addWords(const QString& dictname, const QStringList& wordlist)
332{ 332{
333 QDawg& d = (QDawg&)dawg(dictname); 333 QDawg& d = (QDawg&)dawg(dictname);
334 QStringList all = d.allWords() + wordlist; 334 QStringList all = d.allWords() + wordlist;
335 d.createFromWords(all); 335 d.createFromWords(all);
336 336
337 QString dawgfilename = applicationFileName("Dictionary", dictname) + ".dawg"; 337 QString dawgfilename = applicationFileName("Dictionary", dictname) + ".dawg";
338 QFile dawgfile(dawgfilename); 338 QFile dawgfile(dawgfilename);
339 if ( dawgfile.open(IO_WriteOnly) ) { 339 if ( dawgfile.open(IO_WriteOnly) ) {
340 d.write(&dawgfile); 340 d.write(&dawgfile);
341 dawgfile.close(); 341 dawgfile.close();
342 } 342 }
343 343
344 // #### Re-read the dawg here if we use mmap(). 344 // #### Re-read the dawg here if we use mmap().
345 345
346 // #### Signal other processes to re-read. 346 // #### Signal other processes to re-read.
347} 347}
348 348
349 349
350/*! 350/*!
351 Returns the full path for the application called \a appname, with the 351 Returns the full path for the application called \a appname, with the
352 given \a filename. Returns QString::null if there was a problem creating 352 given \a filename. Returns QString::null if there was a problem creating
353 the directory tree for \a appname. 353 the directory tree for \a appname.
354 If \a filename contains "/", it is the caller's responsibility to 354 If \a filename contains "/", it is the caller's responsibility to
355 ensure that those directories exist. 355 ensure that those directories exist.
356*/ 356*/
357QString Global::applicationFileName(const QString& appname, const QString& filename) 357QString Global::applicationFileName(const QString& appname, const QString& filename)
358{ 358{
359 QDir d; 359 QDir d;
360 QString r = getenv("HOME"); 360 QString r = getenv("HOME");
361 r += "/Applications/"; 361 r += "/Applications/";
362 if ( !QFile::exists( r ) ) 362 if ( !QFile::exists( r ) )
363 if ( d.mkdir(r) == false ) 363 if ( d.mkdir(r) == false )
364 return QString::null; 364 return QString::null;
365 r += appname; 365 r += appname;
366 if ( !QFile::exists( r ) ) 366 if ( !QFile::exists( r ) )
367 if ( d.mkdir(r) == false ) 367 if ( d.mkdir(r) == false )
368 return QString::null; 368 return QString::null;
369 r += "/"; r += filename; 369 r += "/"; r += filename;
370 return r; 370 return r;
371} 371}
372 372
373/*! 373/*!
374 \internal 374 \internal
375*/ 375*/
376void Global::createDocDir() 376void Global::createDocDir()
377{ 377{
378 if ( !docDirCreated ) { 378 if ( !docDirCreated ) {
379 docDirCreated = TRUE; 379 docDirCreated = TRUE;
380 mkdir( QPEApplication::documentDir().latin1(), 0755 ); 380 mkdir( QPEApplication::documentDir().latin1(), 0755 );
381 } 381 }
382} 382}
383 383
384 384
385/*! 385/*!
386 Displays a status \a message to the user. This usually appears 386 Displays a status \a message to the user. This usually appears
387 in the taskbar for a short amount of time, then disappears. 387 in the taskbar for a short amount of time, then disappears.
388*/ 388*/
389void Global::statusMessage(const QString& message) 389void Global::statusMessage(const QString& message)
390{ 390{
391#if!defined(QT_NO_COP) 391#if !defined(QT_NO_COP)
392 QCopEnvelope e( "QPE/TaskBar", "message(QString)" ); 392 QCopEnvelope e( "QPE/TaskBar", "message(QString)" );
393 e << message; 393 e << message;
394#endif 394#endif
395} 395}
396 396
397/*! 397/*!
398 \internal 398 \internal
399*/ 399*/
400void Global::applyStyle() 400void Global::applyStyle()
401{ 401{
402#if !defined(QT_NO_COP) 402#if !defined(QT_NO_COP)
403 QCopChannel::send( "QPE/System", "applyStyle()" ); 403 QCopChannel::send( "QPE/System", "applyStyle()" );
404#else 404#else
405 ((QPEApplication *)qApp)->applyStyle(); // apply without needing QCop for floppy version 405 ((QPEApplication *)qApp)->applyStyle(); // apply without needing QCop for floppy version
406#endif 406#endif
407} 407}
408 408
409/*! 409/*!
410 \internal 410 \internal
411*/ 411*/
412QWidget *Global::shutdown( bool ) 412QWidget *Global::shutdown( bool )
413{ 413{
414#if !defined(QT_NO_COP) 414#if !defined(QT_NO_COP)
415 QCopChannel::send( "QPE/System", "shutdown()" ); 415 QCopChannel::send( "QPE/System", "shutdown()" );
416#endif 416#endif
417 return 0; 417 return 0;
418} 418}
419 419
420/*! 420/*!
421 \internal 421 \internal
422*/ 422*/
423QWidget *Global::restart( bool ) 423QWidget *Global::restart( bool )
424{ 424{
425#if !defined(QT_NO_COP) 425#if !defined(QT_NO_COP)
426 QCopChannel::send( "QPE/System", "restart()" ); 426 QCopChannel::send( "QPE/System", "restart()" );
427#endif 427#endif
428 return 0; 428 return 0;
429} 429}
430 430
431/*! 431/*!
432 Explicitly show the current input method. 432 Explicitly show the current input method.
433 433
434 Input methods are indicated in the taskbar by a small icon. If the 434 Input methods are indicated in the taskbar by a small icon. If the
435 input method is activated (shown) then it takes up some proportion 435 input method is activated (shown) then it takes up some proportion
436 of the bottom of the screen, to allow the user to interact (input 436 of the bottom of the screen, to allow the user to interact (input
437 characters) with it. 437 characters) with it.
438 438
439 \sa hideInputMethod() 439 \sa hideInputMethod()
440*/ 440*/
441void Global::showInputMethod() 441void Global::showInputMethod()
442{ 442{
443#if !defined(QT_NO_COP) 443#if !defined(QT_NO_COP)
444 QCopChannel::send( "QPE/TaskBar", "showInputMethod()" ); 444 QCopChannel::send( "QPE/TaskBar", "showInputMethod()" );
445#endif 445#endif
446} 446}
447 447
448/*! 448/*!
449 Explicitly hide the current input method. 449 Explicitly hide the current input method.
450 450
451 The current input method is still indicated in the taskbar, but no 451 The current input method is still indicated in the taskbar, but no
452 longer takes up screen space, and can no longer be interacted with. 452 longer takes up screen space, and can no longer be interacted with.
453 453
454 \sa showInputMethod() 454 \sa showInputMethod()
455*/ 455*/
@@ -500,221 +500,221 @@ void Global::setBuiltinCommands( Command* list )
500 while ( builtin[count].file ) 500 while ( builtin[count].file )
501 count++; 501 count++;
502 502
503 running = new QGuardedPtr<QWidget> [ count ]; 503 running = new QGuardedPtr<QWidget> [ count ];
504} 504}
505 505
506/*! 506/*!
507 \internal 507 \internal
508*/ 508*/
509void Global::setDocument( QWidget* receiver, const QString& document ) 509void Global::setDocument( QWidget* receiver, const QString& document )
510{ 510{
511 Emitter emitter(receiver,document); 511 Emitter emitter(receiver,document);
512} 512}
513 513
514/*! 514/*!
515 \internal 515 \internal
516*/ 516*/
517bool Global::terminateBuiltin( const QString& n ) 517bool Global::terminateBuiltin( const QString& n )
518{ 518{
519 if (!builtin) 519 if (!builtin)
520 return FALSE; 520 return FALSE;
521 for (int i = 0; builtin[i].file; i++) { 521 for (int i = 0; builtin[i].file; i++) {
522 if ( builtin[i].file == n ) { 522 if ( builtin[i].file == n ) {
523 delete running[i]; 523 delete running[i];
524 return TRUE; 524 return TRUE;
525 } 525 }
526 } 526 }
527 return FALSE; 527 return FALSE;
528} 528}
529 529
530/*! 530/*!
531 \internal 531 \internal
532*/ 532*/
533void Global::terminate( const AppLnk* app ) 533void Global::terminate( const AppLnk* app )
534{ 534{
535 //if ( terminateBuiltin(app->exec()) ) return; // maybe? haven't tried this 535 //if ( terminateBuiltin(app->exec()) ) return; // maybe? haven't tried this
536 536
537#ifndef QT_NO_COP 537#ifndef QT_NO_COP
538 QCString channel = "QPE/Application/" + app->exec().utf8(); 538 QCString channel = "QPE/Application/" + app->exec().utf8();
539 if ( QCopChannel::isRegistered(channel) ) { 539 if ( QCopChannel::isRegistered(channel) ) {
540 QCopEnvelope e(channel, "quit()"); 540 QCopEnvelope e(channel, "quit()");
541 } 541 }
542#endif 542#endif
543} 543}
544 544
545/*! 545/*!
546 Low-level function to run command \a c. 546 Low-level function to run command \a c.
547 547
548 \warning Do not use this function. Use execute instead. 548 \warning Do not use this function. Use execute instead.
549 549
550 \sa execute() 550 \sa execute()
551*/ 551*/
552void Global::invoke(const QString &c) 552void Global::invoke(const QString &c)
553{ 553{
554 // Convert the command line in to a list of arguments 554 // Convert the command line in to a list of arguments
555 QStringList list = QStringList::split(QRegExp(" *"),c); 555 QStringList list = QStringList::split(QRegExp(" *"),c);
556 556
557#if !defined(QT_NO_COP) 557#if !defined(QT_NO_COP)
558 QString ap=list[0]; 558 QString ap=list[0];
559 // see if the application is already running 559 // see if the application is already running
560 // XXX should lock file /tmp/qcop-msg-ap 560 // XXX should lock file /tmp/qcop-msg-ap
561 if ( QCopChannel::isRegistered( ("QPE/Application/" + ap).latin1() ) ) { 561 if ( QCopChannel::isRegistered( ("QPE/Application/" + ap).latin1() ) ) {
562 // If the channel is already register, the app is already running, so show it. 562 // If the channel is already register, the app is already running, so show it.
563 { QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); } 563 { QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); }
564 564
565 QCopEnvelope e("QPE/System", "notBusy(QString)" ); 565 QCopEnvelope e("QPE/System", "notBusy(QString)" );
566 e << ap; 566 e << ap;
567 return; 567 return;
568 } 568 }
569 // XXX should unlock file /tmp/qcop-msg-ap 569 // XXX should unlock file /tmp/qcop-msg-ap
570 //see if it is being started 570 //see if it is being started
571 if ( StartingAppList::isStarting( ap ) ) { 571 if ( StartingAppList::isStarting( ap ) ) {
572 QCopEnvelope e("QPE/System", "notBusy(QString)" ); 572 QCopEnvelope e("QPE/System", "notBusy(QString)" );
573 e << ap; 573 e << ap;
574 return; 574 return;
575 } 575 }
576 576
577#endif 577#endif
578 578
579#ifdef QT_NO_QWS_MULTIPROCESS 579#ifdef QT_NO_QWS_MULTIPROCESS
580 QMessageBox::warning( 0, "Error", "Could not find the application " + c, "Ok", 0, 0, 0, 1 ); 580 QMessageBox::warning( 0, "Error", "Could not find the application " + c, "Ok", 0, 0, 0, 1 );
581#else 581#else
582 582
583 QStrList slist; 583 QStrList slist;
584 unsigned int j; 584 unsigned int j;
585 for ( j = 0; j < list.count(); j++ ) 585 for ( j = 0; j < list.count(); j++ )
586 slist.append( list[j].utf8() ); 586 slist.append( list[j].utf8() );
587 587
588 const char **args = new (const char *)[slist.count() + 1]; 588 const char **args = new (const char *)[slist.count() + 1];
589 for ( j = 0; j < slist.count(); j++ ) 589 for ( j = 0; j < slist.count(); j++ )
590 args[j] = slist.at(j); 590 args[j] = slist.at(j);
591 args[j] = NULL; 591 args[j] = NULL;
592 592
593#if !defined(QT_NO_COP) 593#if !defined(QT_NO_COP)
594 // an attempt to show a wait... 594 // an attempt to show a wait...
595 // more logic should be used, but this will be fine for the moment... 595 // more logic should be used, but this will be fine for the moment...
596 QCopEnvelope ( "QPE/System", "busy()" ); 596 QCopEnvelope ( "QPE/System", "busy()" );
597#endif 597#endif
598 598
599#ifdef HAVE_QUICKEXEC 599#ifdef HAVE_QUICKEXEC
600 QString libexe = qpeDir()+"/binlib/lib"+args[0] + ".so"; 600 QString libexe = qpeDir()+"/binlib/lib"+args[0] + ".so";
601 qDebug("libfile = %s", libexe.latin1() ); 601 qDebug("libfile = %s", libexe.latin1() );
602 if ( QFile::exists( libexe ) ) { 602 if ( QFile::exists( libexe ) ) {
603 qDebug("calling quickexec %s", libexe.latin1() ); 603 qDebug("calling quickexec %s", libexe.latin1() );
604 quickexecv( libexe.utf8().data(), (const char **)args ); 604 quickexecv( libexe.utf8().data(), (const char **)args );
605 } else 605 } else
606#endif 606#endif
607 { 607 {
608 bool success = false; 608 bool success = false;
609 int pfd [2]; 609 int pfd [2];
610 if ( ::pipe ( pfd ) < 0 ) 610 if ( ::pipe ( pfd ) < 0 )
611 pfd [0] = pfd [1] = -1; 611 pfd [0] = pfd [1] = -1;
612 612
613 pid_t pid = ::fork ( ); 613 pid_t pid = ::fork ( );
614 614
615 if ( pid == 0 ) { // child 615 if ( pid == 0 ) { // child
616 for ( int fd = 3; fd < 100; fd++ ) { 616 for ( int fd = 3; fd < 100; fd++ ) {
617 if ( fd != pfd [1] ) 617 if ( fd != pfd [1] )
618 ::close ( fd ); 618 ::close ( fd );
619 } 619 }
620 ::setpgid ( ::getpid ( ), ::getppid ( )); 620 ::setpgid ( ::getpid ( ), ::getppid ( ));
621 621
622 // Closing of fd[1] indicates that the execvp succeeded! 622 // Closing of fd[1] indicates that the execvp succeeded!
623 if ( pfd [1] >= 0 ) 623 if ( pfd [1] >= 0 )
624 ::fcntl ( pfd [1], F_SETFD, FD_CLOEXEC ); 624 ::fcntl ( pfd [1], F_SETFD, FD_CLOEXEC );
625 625
626 // Try bindir first, so that foo/bar works too 626 // Try bindir first, so that foo/bar works too
627 ::execv ( qpeDir ( ) + "/bin/" + args [0], (char * const *) args ); 627 ::execv ( qpeDir ( ) + "/bin/" + args [0], (char * const *) args );
628 ::execvp ( args [0], (char * const *) args ); 628 ::execvp ( args [0], (char * const *) args );
629 629
630 char resultByte = 1; 630 char resultByte = 1;
631 if ( pfd [1] >= 0 ) 631 if ( pfd [1] >= 0 )
632 ::write ( pfd [1], &resultByte, 1 ); 632 ::write ( pfd [1], &resultByte, 1 );
633 ::_exit ( -1 ); 633 ::_exit ( -1 );
634 } 634 }
635 else if ( pid > 0 ) { 635 else if ( pid > 0 ) {
636 success = true; 636 success = true;
637 637
638 if ( pfd [1] >= 0 ) 638 if ( pfd [1] >= 0 )
639 ::close ( pfd [1] ); 639 ::close ( pfd [1] );
640 if ( pfd [0] >= 0 ) { 640 if ( pfd [0] >= 0 ) {
641 while ( true ) { 641 while ( true ) {
642 char resultByte; 642 char resultByte;
643 int n = ::read ( pfd [0], &resultByte, 1 ); 643 int n = ::read ( pfd [0], &resultByte, 1 );
644 if ( n == 1 ) { 644 if ( n == 1 ) {
645 success = false; 645 success = false;
646 break; 646 break;
647 } 647 }
648 if (( n == -1 ) && (( errno == ECHILD ) || ( errno == EINTR ))) 648 if (( n == -1 ) && (( errno == ECHILD ) || ( errno == EINTR )))
649 continue; 649 continue;
650 650
651 break; // success 651 break; // success
652 } 652 }
653 ::close ( pfd [0] ); 653 ::close ( pfd [0] );
654 } 654 }
655 } 655 }
656 if ( success ) 656 if ( success )
657 StartingAppList::add( list[0] ); 657 StartingAppList::add( list[0] );
658 else 658 else
659 QMessageBox::warning( 0, "Error", "Could not start the application " + c, "Ok", 0, 0, 0, 1 ); 659 QMessageBox::warning( 0, "Error", "Could not start the application " + c, "Ok", 0, 0, 0, 1 );
660 } 660 }
661#endif //QT_NO_QWS_MULTIPROCESS 661#endif //QT_NO_QWS_MULTIPROCESS
662} 662}
663 663
664 664
665/*! 665/*!
666 Executes the application identfied by \a c, passing \a 666 Executes the application identfied by \a c, passing \a
667 document if it isn't null. 667 document if it isn't null.
668 668
669 Note that a better approach might be to send a QCop message to the 669 Note that a better approach might be to send a QCop message to the
670 application's QPE/Application/\e{appname} channel. 670 application's QPE/Application/\e{appname} channel.
671*/ 671*/
672void Global::execute( const QString &c, const QString& document ) 672void Global::execute( const QString &c, const QString& document )
673{ 673{
674 if ( qApp->type() != QApplication::GuiServer ) { 674 if ( qApp->type() != QApplication::GuiServer ) {
675 // ask the server to do the work 675 // ask the server to do the work
676#if !defined(QT_NO_COP) 676#if !defined(QT_NO_COP)
677 if ( document.isNull() ) { 677 if ( document.isNull() ) {
678 QCopEnvelope e( "QPE/System", "execute(QString)" ); 678 QCopEnvelope e( "QPE/System", "execute(QString)" );
679 e << c; 679 e << c;
680 } else { 680 } else {
681 QCopEnvelope e( "QPE/System", "execute(QString,QString)" ); 681 QCopEnvelope e( "QPE/System", "execute(QString,QString)" );
682 e << c << document; 682 e << c << document;
683 } 683 }
684#endif 684#endif
685 return; 685 return;
686 } 686 }
687 687
688 // Attempt to execute the app using a builtin class for the app first 688 // Attempt to execute the app using a builtin class for the app first
689 // else try and find it in the bin directory 689 // else try and find it in the bin directory
690 if (builtin) { 690 if (builtin) {
691 for (int i = 0; builtin[i].file; i++) { 691 for (int i = 0; builtin[i].file; i++) {
692 if ( builtin[i].file == c ) { 692 if ( builtin[i].file == c ) {
693 if ( running[i] ) { 693 if ( running[i] ) {
694 if ( !document.isNull() && builtin[i].documentary ) 694 if ( !document.isNull() && builtin[i].documentary )
695 setDocument(running[i], document); 695 setDocument(running[i], document);
696 running[i]->raise(); 696 running[i]->raise();
697 running[i]->show(); 697 running[i]->show();
698 running[i]->setActiveWindow(); 698 running[i]->setActiveWindow();
699 } else { 699 } else {
700 running[i] = builtin[i].func( builtin[i].maximized ); 700 running[i] = builtin[i].func( builtin[i].maximized );
701 } 701 }
702#ifndef QT_NO_COP 702#ifndef QT_NO_COP
703 QCopEnvelope e("QPE/System", "notBusy(QString)" ); 703 QCopEnvelope e("QPE/System", "notBusy(QString)" );
704 e << c; // that was quick ;-) 704 e << c; // that was quick ;-)
705#endif 705#endif
706 return; 706 return;
707 } 707 }
708 } 708 }
709 } 709 }
710 710
711 //Global::invoke(c, document); 711 //Global::invoke(c, document);
712 712
713 // Convert the command line in to a list of arguments 713 // Convert the command line in to a list of arguments
714 QStringList list = QStringList::split(QRegExp(" *"),c); 714 QStringList list = QStringList::split(QRegExp(" *"),c);
715 715
716#if !defined(QT_NO_COP) 716#if !defined(QT_NO_COP)
717 QString ap=list[0]; 717 QString ap=list[0];
718 718
719 qDebug("executing %s", ap.latin1() ); 719 qDebug("executing %s", ap.latin1() );
720 720
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index c562f6c..2ef60d5 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -389,129 +389,129 @@ static void setTreble( int t = 0, int percent = -1 )
389 keepRunning() function indicates whether the application will 389 keepRunning() function indicates whether the application will
390 continue running after it's processed the last \link qcop.html 390 continue running after it's processed the last \link qcop.html
391 QCop\endlink message. This can be changed using setKeepRunning(). 391 QCop\endlink message. This can be changed using setKeepRunning().
392 392
393 A variety of signals are emitted when certain events occur, for 393 A variety of signals are emitted when certain events occur, for
394 example, timeChanged(), clockChanged(), weekChanged(), 394 example, timeChanged(), clockChanged(), weekChanged(),
395 dateFormatChanged() and volumeChanged(). If the application receives 395 dateFormatChanged() and volumeChanged(). If the application receives
396 a \link qcop.html QCop\endlink message on the application's 396 a \link qcop.html QCop\endlink message on the application's
397 QPE/Application/\e{appname} channel, the appMessage() signal is 397 QPE/Application/\e{appname} channel, the appMessage() signal is
398 emitted. There are also flush() and reload() signals, which 398 emitted. There are also flush() and reload() signals, which
399 are emitted when synching begins and ends respectively - upon these 399 are emitted when synching begins and ends respectively - upon these
400 signals, the application should save and reload any data 400 signals, the application should save and reload any data
401 files that are involved in synching. Most of these signals will initially 401 files that are involved in synching. Most of these signals will initially
402 be received and unfiltered through the appMessage() signal. 402 be received and unfiltered through the appMessage() signal.
403 403
404 This class also provides a set of useful static functions. The 404 This class also provides a set of useful static functions. The
405 qpeDir() and documentDir() functions return the respective paths. 405 qpeDir() and documentDir() functions return the respective paths.
406 The grabKeyboard() and ungrabKeyboard() functions are used to 406 The grabKeyboard() and ungrabKeyboard() functions are used to
407 control whether the application takes control of the device's 407 control whether the application takes control of the device's
408 physical buttons (e.g. application launch keys). The stylus' mode of 408 physical buttons (e.g. application launch keys). The stylus' mode of
409 operation is set with setStylusOperation() and retrieved with 409 operation is set with setStylusOperation() and retrieved with
410 stylusOperation(). There are also setInputMethodHint() and 410 stylusOperation(). There are also setInputMethodHint() and
411 inputMethodHint() functions. 411 inputMethodHint() functions.
412 412
413 \ingroup qtopiaemb 413 \ingroup qtopiaemb
414*/ 414*/
415 415
416/*! 416/*!
417 \fn void QPEApplication::clientMoused() 417 \fn void QPEApplication::clientMoused()
418 418
419 \internal 419 \internal
420*/ 420*/
421 421
422/*! 422/*!
423 \fn void QPEApplication::timeChanged(); 423 \fn void QPEApplication::timeChanged();
424 This signal is emitted when the time changes outside the normal 424 This signal is emitted when the time changes outside the normal
425 passage of time, i.e. if the time is set backwards or forwards. 425 passage of time, i.e. if the time is set backwards or forwards.
426*/ 426*/
427 427
428/*! 428/*!
429 \fn void QPEApplication::clockChanged( bool ampm ); 429 \fn void QPEApplication::clockChanged( bool ampm );
430 430
431 This signal is emitted when the user changes the clock's style. If 431 This signal is emitted when the user changes the clock's style. If
432 \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, 432 \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise,
433 they want a 24-hour clock. 433 they want a 24-hour clock.
434*/ 434*/
435 435
436/*! 436/*!
437 \fn void QPEApplication::volumeChanged( bool muted ) 437 \fn void QPEApplication::volumeChanged( bool muted )
438 438
439 This signal is emitted whenever the mute state is changed. If \a 439 This signal is emitted whenever the mute state is changed. If \a
440 muted is TRUE, then sound output has been muted. 440 muted is TRUE, then sound output has been muted.
441*/ 441*/
442 442
443/*! 443/*!
444 \fn void QPEApplication::weekChanged( bool startOnMonday ) 444 \fn void QPEApplication::weekChanged( bool startOnMonday )
445 445
446 This signal is emitted if the week start day is changed. If \a 446 This signal is emitted if the week start day is changed. If \a
447 startOnMonday is TRUE then the first day of the week is Monday; if 447 startOnMonday is TRUE then the first day of the week is Monday; if
448 \a startOnMonday is FALSE then the first day of the week is 448 \a startOnMonday is FALSE then the first day of the week is
449 Sunday. 449 Sunday.
450*/ 450*/
451 451
452/*! 452/*!
453 \fn void QPEApplication::dateFormatChanged() 453 \fn void QPEApplication::dateFormatChanged(DateFormat)
454 454
455 This signal is emitted whenever the date format is changed. 455 This signal is emitted whenever the date format is changed.
456*/ 456*/
457 457
458/*! 458/*!
459 \fn void QPEApplication::flush() 459 \fn void QPEApplication::flush()
460 460
461 ### 461 ###
462*/ 462*/
463 463
464/*! 464/*!
465 \fn void QPEApplication::reload() 465 \fn void QPEApplication::reload()
466 466
467*/ 467*/
468 468
469/*! 469/*!
470 \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) 470 \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data )
471 471
472 This signal is emitted when a message is received on this 472 This signal is emitted when a message is received on this
473 application's QPE/Application/<i>appname</i> \link qcop.html 473 application's QPE/Application/<i>appname</i> \link qcop.html
474 QCop\endlink channel. 474 QCop\endlink channel.
475 475
476 The slot to which you connect this signal uses \a msg and \a data 476 The slot to which you connect this signal uses \a msg and \a data
477 in the following way: 477 in the following way:
478 478
479\code 479\code
480 void MyWidget::receive( const QCString& msg, const QByteArray& data ) 480 void MyWidget::receive( const QCString& msg, const QByteArray& data )
481 { 481 {
482 QDataStream stream( data, IO_ReadOnly ); 482 QDataStream stream( data, IO_ReadOnly );
483 if ( msg == "someMessage(int,int,int)" ) { 483 if ( msg == "someMessage(int,int,int)" ) {
484 int a,b,c; 484 int a,b,c;
485 stream >> a >> b >> c; 485 stream >> a >> b >> c;
486 ... 486 ...
487 } else if ( msg == "otherMessage(QString)" ) { 487 } else if ( msg == "otherMessage(QString)" ) {
488 ... 488 ...
489 } 489 }
490 } 490 }
491\endcode 491\endcode
492 492
493 \sa qcop.html 493 \sa qcop.html
494 Note that messages received here may be processed by qpe application 494 Note that messages received here may be processed by qpe application
495 and emitted as signals, such as flush() and reload(). 495 and emitted as signals, such as flush() and reload().
496*/ 496*/
497 497
498/*! 498/*!
499 Constructs a QPEApplication just as you would construct 499 Constructs a QPEApplication just as you would construct
500 a QApplication, passing \a argc, \a argv, and \a t. 500 a QApplication, passing \a argc, \a argv, and \a t.
501 501
502 For applications, \a t should be the default, GuiClient. Only 502 For applications, \a t should be the default, GuiClient. Only
503 the Qtopia server passes GuiServer. 503 the Qtopia server passes GuiServer.
504*/ 504*/
505QPEApplication::QPEApplication( int & argc, char **argv, Type t ) 505QPEApplication::QPEApplication( int & argc, char **argv, Type t )
506 : QApplication( argc, argv, t ) 506 : QApplication( argc, argv, t )
507{ 507{
508 d = new QPEApplicationData; 508 d = new QPEApplicationData;
509 d->loadTextCodecs(); 509 d->loadTextCodecs();
510 d->loadImageCodecs(); 510 d->loadImageCodecs();
511 int dw = desktop() ->width(); 511 int dw = desktop() ->width();
512 512
513 if ( dw < 200 ) { 513 if ( dw < 200 ) {
514 setFont( QFont( "helvetica", 8 ) ); 514 setFont( QFont( "helvetica", 8 ) );
515 AppLnk::setSmallIconSize( 10 ); 515 AppLnk::setSmallIconSize( 10 );
516 AppLnk::setBigIconSize( 28 ); 516 AppLnk::setBigIconSize( 28 );
517 } 517 }
@@ -1707,100 +1707,101 @@ void QPEApplication::tryQuit()
1707 1707
1708 { 1708 {
1709 QCopEnvelope e( "QPE/System", "closing(QString)" ); 1709 QCopEnvelope e( "QPE/System", "closing(QString)" );
1710 e << d->appName; 1710 e << d->appName;
1711 } 1711 }
1712#endif 1712#endif
1713 processEvents(); 1713 processEvents();
1714 1714
1715 quit(); 1715 quit();
1716} 1716}
1717 1717
1718/*! 1718/*!
1719 \internal 1719 \internal
1720 User initiated quit. Makes the window 'Go Away'. If preloaded this means 1720 User initiated quit. Makes the window 'Go Away'. If preloaded this means
1721 hiding the window. If not it means quitting the application. 1721 hiding the window. If not it means quitting the application.
1722 As this is user initiated we don't need to check state. 1722 As this is user initiated we don't need to check state.
1723*/ 1723*/
1724void QPEApplication::hideOrQuit() 1724void QPEApplication::hideOrQuit()
1725{ 1725{
1726 processEvents(); 1726 processEvents();
1727 1727
1728 // If we are a preloaded application we don't actually quit, so emit 1728 // If we are a preloaded application we don't actually quit, so emit
1729 // a System message indicating we're quasi-closing. 1729 // a System message indicating we're quasi-closing.
1730 if ( d->preloaded && d->qpe_main_widget ) 1730 if ( d->preloaded && d->qpe_main_widget )
1731#ifndef QT_NO_COP 1731#ifndef QT_NO_COP
1732 1732
1733 { 1733 {
1734 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); 1734 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" );
1735 e << d->appName; 1735 e << d->appName;
1736 d->qpe_main_widget->hide(); 1736 d->qpe_main_widget->hide();
1737 } 1737 }
1738#endif 1738#endif
1739 else 1739 else
1740 quit(); 1740 quit();
1741} 1741}
1742 1742
1743 1743
1744#if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX) 1744#if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX)
1745 1745
1746// The libraries with the skiff package (and possibly others) have 1746// The libraries with the skiff package (and possibly others) have
1747// completely useless implementations of builtin new and delete that 1747// completely useless implementations of builtin new and delete that
1748// use about 50% of your CPU. Here we revert to the simple libc 1748// use about 50% of your CPU. Here we revert to the simple libc
1749// functions. 1749// functions.
1750 1750
1751void* operator new[]( size_t size ) 1751void* operator new[]( size_t size )
1752{ 1752{
1753 return malloc( size ); 1753 return malloc( size );
1754} 1754}
1755 1755
1756void* operator new( size_t size ) 1756void* operator new( size_t size )
1757{ 1757{
1758 return malloc( size ); 1758 return malloc( size );
1759} 1759}
1760 1760
1761void operator delete[]( void* p ) 1761void operator delete[]( void* p )
1762{ 1762{
1763 free( p ); 1763 free( p );
1764} 1764}
1765 1765
1766void operator delete[]( void* p, size_t /*size*/ ) 1766void operator delete[]( void* p, size_t /*size*/ )
1767{ 1767{
1768 free( p ); 1768 free( p );
1769} 1769}
1770 1770
1771
1771void operator delete( void* p ) 1772void operator delete( void* p )
1772{ 1773{
1773 free( p ); 1774 free( p );
1774} 1775}
1775 1776
1776void operator delete( void* p, size_t /*size*/ ) 1777void operator delete( void* p, size_t /*size*/ )
1777{ 1778{
1778 free( p ); 1779 free( p );
1779} 1780}
1780 1781
1781#endif 1782#endif
1782 1783
1783#if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) 1784#if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP)
1784#include <qwidgetlist.h> 1785#include <qwidgetlist.h>
1785#ifdef QWS 1786#ifdef QWS
1786#include <qgfx_qws.h> 1787#include <qgfx_qws.h>
1787extern QRect qt_maxWindowRect; 1788extern QRect qt_maxWindowRect;
1788void qt_setMaxWindowRect(const QRect& r ) 1789void qt_setMaxWindowRect(const QRect& r )
1789{ 1790{
1790 qt_maxWindowRect = qt_screen->mapFromDevice( r, 1791 qt_maxWindowRect = qt_screen->mapFromDevice( r,
1791 qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); 1792 qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) );
1792 // Re-resize any maximized windows 1793 // Re-resize any maximized windows
1793 QWidgetList* l = QApplication::topLevelWidgets(); 1794 QWidgetList* l = QApplication::topLevelWidgets();
1794 if ( l ) { 1795 if ( l ) {
1795 QWidget * w = l->first(); 1796 QWidget * w = l->first();
1796 while ( w ) { 1797 while ( w ) {
1797 if ( w->isVisible() && w->isMaximized() ) { 1798 if ( w->isVisible() && w->isMaximized() ) {
1798 w->showMaximized(); 1799 w->showMaximized();
1799 } 1800 }
1800 w = l->next(); 1801 w = l->next();
1801 } 1802 }
1802 delete l; 1803 delete l;
1803 } 1804 }
1804} 1805}
1805#endif 1806#endif
1806#endif 1807#endif
diff --git a/library/storage.cpp b/library/storage.cpp
index f4c1c02..12f9df9 100644
--- a/library/storage.cpp
+++ b/library/storage.cpp
@@ -139,123 +139,123 @@ void StorageInfo::update()
139 for (; it!=curdisks.end(); ++it, ++fsit, ++optsIt) { 139 for (; it!=curdisks.end(); ++it, ++fsit, ++optsIt) {
140 QString opts = *optsIt; 140 QString opts = *optsIt;
141 141
142 QString disk = *it; 142 QString disk = *it;
143 QString humanname; 143 QString humanname;
144 bool removable = FALSE; 144 bool removable = FALSE;
145 if ( isCF(disk) ) { 145 if ( isCF(disk) ) {
146 humanname = tr("CF Card"); 146 humanname = tr("CF Card");
147 removable = TRUE; 147 removable = TRUE;
148 } else if ( disk == "/dev/hda1" ) { 148 } else if ( disk == "/dev/hda1" ) {
149 humanname = tr("Hard Disk"); 149 humanname = tr("Hard Disk");
150 } else if ( disk.left(9) == "/dev/mmcd" ) { 150 } else if ( disk.left(9) == "/dev/mmcd" ) {
151 humanname = tr("SD Card"); 151 humanname = tr("SD Card");
152 removable = TRUE; 152 removable = TRUE;
153 } else if ( disk.left( 14 ) == "/dev/mmc/part1" ) { 153 } else if ( disk.left( 14 ) == "/dev/mmc/part1" ) {
154 humanname = tr("MMC Card"); 154 humanname = tr("MMC Card");
155 removable = TRUE; 155 removable = TRUE;
156 } else if ( disk.left(7) == "/dev/hd" ) 156 } else if ( disk.left(7) == "/dev/hd" )
157 humanname = tr("Hard Disk") + " " + disk; 157 humanname = tr("Hard Disk") + " " + disk;
158 else if ( disk.left(7) == "/dev/sd" ) 158 else if ( disk.left(7) == "/dev/sd" )
159 humanname = tr("SCSI Hard Disk") + " " + disk; 159 humanname = tr("SCSI Hard Disk") + " " + disk;
160 else if ( disk.left(14) == "/dev/mtdblock6" ) //openzaurus ramfs 160 else if ( disk.left(14) == "/dev/mtdblock6" ) //openzaurus ramfs
161 humanname = tr("Internal Memory"); 161 humanname = tr("Internal Memory");
162 else if ( disk == "/dev/mtdblock1" || humanname == "/dev/mtdblock/1" ) 162 else if ( disk == "/dev/mtdblock1" || humanname == "/dev/mtdblock/1" )
163 humanname = tr("Internal Storage"); 163 humanname = tr("Internal Storage");
164 else if ( disk.left(14) == "/dev/mtdblock/" ) 164 else if ( disk.left(14) == "/dev/mtdblock/" )
165 humanname = tr("Internal Storage") + " " + disk; 165 humanname = tr("Internal Storage") + " " + disk;
166 else if ( disk.left(13) == "/dev/mtdblock" ) 166 else if ( disk.left(13) == "/dev/mtdblock" )
167 humanname = tr("Internal Storage") + " " + disk; 167 humanname = tr("Internal Storage") + " " + disk;
168 else if ( disk.left(9) == "/dev/root" ) 168 else if ( disk.left(9) == "/dev/root" )
169 humanname = tr("Internal Storage") + " " + disk; 169 humanname = tr("Internal Storage") + " " + disk;
170 else if ( disk.left(5) == "tmpfs" ) //ipaqs /mnt/ramfs 170 else if ( disk.left(5) == "tmpfs" ) //ipaqs /mnt/ramfs
171 humanname = tr("Internal Memory"); 171 humanname = tr("Internal Memory");
172 FileSystem *fs = new FileSystem( disk, *fsit, humanname, removable, opts ); 172 FileSystem *fs = new FileSystem( disk, *fsit, humanname, removable, opts );
173 mFileSystems.append( fs ); 173 mFileSystems.append( fs );
174 } 174 }
175 emit disksChanged(); 175 emit disksChanged();
176 } else { 176 } else {
177 // just update them 177 // just update them
178 for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) 178 for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i)
179 i.current()->update(); 179 i.current()->update();
180 } 180 }
181#endif 181#endif
182} 182}
183 183
184bool deviceTab( const char *device) { 184bool deviceTab( const char *device) {
185 QString name = device; 185 QString name = device;
186 bool hasDevice=false; 186 bool hasDevice=false;
187 struct mntent *me; 187 struct mntent *me;
188 FILE *mntfp = setmntent( "/etc/mtab", "r" ); 188 FILE *mntfp = setmntent( "/etc/mtab", "r" );
189 if ( mntfp ) { 189 if ( mntfp ) {
190 while ( (me = getmntent( mntfp )) != 0 ) { 190 while ( (me = getmntent( mntfp )) != 0 ) {
191 QString deviceName = me->mnt_fsname; 191 QString deviceName = me->mnt_fsname;
192// qDebug(deviceName); 192// qDebug(deviceName);
193 if( deviceName.left(name.length()) == name) { 193 if( deviceName.left(name.length()) == name) {
194 hasDevice = true; 194 hasDevice = true;
195 } 195 }
196 } 196 }
197 } 197 }
198 endmntent( mntfp ); 198 endmntent( mntfp );
199 return hasDevice; 199 return hasDevice;
200} 200}
201 201
202/*! 202/*!
203 * @fn hasCf() 203 * @fn static bool StorageInfo::hasCf()
204 * @brief returns whether device has Cf mounted 204 * @brief returns whether device has Cf mounted
205 * 205 *
206 */ 206 */
207bool StorageInfo::hasCf() 207bool StorageInfo::hasCf()
208{ 208{
209 return deviceTab("/dev/hd"); 209 return deviceTab("/dev/hd");
210} 210}
211 211
212/*! 212/*!
213 * @fn hasSd() 213 * @fn static bool StorageInfo::hasSd()
214 * @brief returns whether device has SD mounted 214 * @brief returns whether device has SD mounted
215 * 215 *
216 */ 216 */
217bool StorageInfo::hasSd() 217bool StorageInfo::hasSd()
218{ 218{
219 return deviceTab("/dev/mmcd"); 219 return deviceTab("/dev/mmcd");
220} 220}
221 221
222/*! 222/*!
223 * @fn hasMmc() 223 * @fn static bool StorageInfo::hasMmc()
224 * @brief reutrns whether device has mmc mounted 224 * @brief reutrns whether device has mmc mounted
225 * 225 *
226 */ 226 */
227bool StorageInfo::hasMmc() 227bool StorageInfo::hasMmc()
228{ 228{
229 bool hasMmc=false; 229 bool hasMmc=false;
230 if( deviceTab("/dev/mmc/part")) 230 if( deviceTab("/dev/mmc/part"))
231 hasMmc=true; 231 hasMmc=true;
232 if( deviceTab("/dev/mmcd")) 232 if( deviceTab("/dev/mmcd"))
233 hasMmc=true; 233 hasMmc=true;
234 return hasMmc; 234 return hasMmc;
235} 235}
236 236
237 237
238//--------------------------------------------------------------------------- 238//---------------------------------------------------------------------------
239 239
240FileSystem::FileSystem( const QString &disk, const QString &path, const QString &name, bool rem, const QString &o ) 240FileSystem::FileSystem( const QString &disk, const QString &path, const QString &name, bool rem, const QString &o )
241 : fsdisk( disk ), fspath( path ), humanname( name ), blkSize(512), totalBlks(0), availBlks(0), removable( rem ), opts( o ) 241 : fsdisk( disk ), fspath( path ), humanname( name ), blkSize(512), totalBlks(0), availBlks(0), removable( rem ), opts( o )
242{ 242{
243 update(); 243 update();
244} 244}
245 245
246void FileSystem::update() 246void FileSystem::update()
247{ 247{
248#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 248#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
249 struct statfs fs; 249 struct statfs fs;
250 if ( !statfs( fspath.latin1(), &fs ) ) { 250 if ( !statfs( fspath.latin1(), &fs ) ) {
251 blkSize = fs.f_bsize; 251 blkSize = fs.f_bsize;
252 totalBlks = fs.f_blocks; 252 totalBlks = fs.f_blocks;
253 availBlks = fs.f_bavail; 253 availBlks = fs.f_bavail;
254 } else { 254 } else {
255 blkSize = 0; 255 blkSize = 0;
256 totalBlks = 0; 256 totalBlks = 0;
257 availBlks = 0; 257 availBlks = 0;
258 } 258 }
259#endif 259#endif
260} 260}
261 261