author | zautrix <zautrix> | 2004-08-09 18:02:44 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-08-09 18:02:44 (UTC) |
commit | 4f05a9fcbb9e54184aef93883886aaf865104463 (patch) (unidiff) | |
tree | f5e94f7694b74dca3b11e1e74a94058a4526dafe | |
parent | e1909ade2188e53feee65089d5f2882563876c58 (diff) | |
download | kdepimpi-4f05a9fcbb9e54184aef93883886aaf865104463.zip kdepimpi-4f05a9fcbb9e54184aef93883886aaf865104463.tar.gz kdepimpi-4f05a9fcbb9e54184aef93883886aaf865104463.tar.bz2 |
more syncing
-rw-r--r-- | korganizer/mainwindow.cpp | 21 | ||||
-rw-r--r-- | libkcal/phoneformat.cpp | 60 | ||||
-rw-r--r-- | libkcal/phoneformat.h | 2 | ||||
-rw-r--r-- | libkcal/vcalformat.cpp | 19 | ||||
-rw-r--r-- | libkcal/vcalformat.h | 2 |
5 files changed, 52 insertions, 52 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index cce182a..6c0aa9b 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -816,515 +816,534 @@ void MainWindow::initActions() | |||
816 | if (!p-> mShowIconStretch) | 816 | if (!p-> mShowIconStretch) |
817 | iconToolBar->setStretchableWidget ( dummy ) ; | 817 | iconToolBar->setStretchableWidget ( dummy ) ; |
818 | else | 818 | else |
819 | configureToolBarMenu->setItemChecked( 5, true ); | 819 | configureToolBarMenu->setItemChecked( 5, true ); |
820 | if (p-> mShowIconWhatsThis) | 820 | if (p-> mShowIconWhatsThis) |
821 | QWhatsThis::whatsThisButton ( iconToolBar ); | 821 | QWhatsThis::whatsThisButton ( iconToolBar ); |
822 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); | 822 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); |
823 | configureAgenda( p->mHourSize ); | 823 | configureAgenda( p->mHourSize ); |
824 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); | 824 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); |
825 | } | 825 | } |
826 | void MainWindow::fillSyncMenu() | 826 | void MainWindow::fillSyncMenu() |
827 | { | 827 | { |
828 | syncMenu->clear(); | 828 | syncMenu->clear(); |
829 | syncMenu->insertItem( i18n("Configure..."), 0 ); | 829 | syncMenu->insertItem( i18n("Configure..."), 0 ); |
830 | syncMenu->insertSeparator(); | 830 | syncMenu->insertSeparator(); |
831 | syncMenu->insertItem( i18n("Multiple sync"), 1 ); | 831 | syncMenu->insertItem( i18n("Multiple sync"), 1 ); |
832 | syncMenu->insertSeparator(); | 832 | syncMenu->insertSeparator(); |
833 | KConfig config ( locateLocal( "config","syncprofilesrc" ) ); | 833 | KConfig config ( locateLocal( "config","syncprofilesrc" ) ); |
834 | config.setGroup("General"); | 834 | config.setGroup("General"); |
835 | QStringList prof = config.readListEntry("SyncProfileNames"); | 835 | QStringList prof = config.readListEntry("SyncProfileNames"); |
836 | KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); | 836 | KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); |
837 | if ( prof.count() < 3 ) { | 837 | if ( prof.count() < 3 ) { |
838 | prof.clear(); | 838 | prof.clear(); |
839 | prof << i18n("Sharp_DTM"); | 839 | prof << i18n("Sharp_DTM"); |
840 | prof << i18n("Local_file"); | 840 | prof << i18n("Local_file"); |
841 | prof << i18n("Last_file"); | 841 | prof << i18n("Last_file"); |
842 | KSyncProfile* temp = new KSyncProfile (); | 842 | KSyncProfile* temp = new KSyncProfile (); |
843 | temp->setName( prof[0] ); | 843 | temp->setName( prof[0] ); |
844 | temp->writeConfig(&config); | 844 | temp->writeConfig(&config); |
845 | temp->setName( prof[1] ); | 845 | temp->setName( prof[1] ); |
846 | temp->writeConfig(&config); | 846 | temp->writeConfig(&config); |
847 | temp->setName( prof[2] ); | 847 | temp->setName( prof[2] ); |
848 | temp->writeConfig(&config); | 848 | temp->writeConfig(&config); |
849 | config.setGroup("General"); | 849 | config.setGroup("General"); |
850 | config.writeEntry("SyncProfileNames",prof); | 850 | config.writeEntry("SyncProfileNames",prof); |
851 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); | 851 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); |
852 | config.sync(); | 852 | config.sync(); |
853 | delete temp; | 853 | delete temp; |
854 | } | 854 | } |
855 | KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | 855 | KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); |
856 | KOPrefs::instance()->mSyncProfileNames = prof; | 856 | KOPrefs::instance()->mSyncProfileNames = prof; |
857 | int i; | 857 | int i; |
858 | for ( i = 0; i < prof.count(); ++i ) { | 858 | for ( i = 0; i < prof.count(); ++i ) { |
859 | 859 | ||
860 | syncMenu->insertItem( prof[i], 1000+i ); | 860 | syncMenu->insertItem( prof[i], 1000+i ); |
861 | if ( i == 2 ) | 861 | if ( i == 2 ) |
862 | syncMenu->insertSeparator(); | 862 | syncMenu->insertSeparator(); |
863 | } | 863 | } |
864 | QDir app_dir; | 864 | QDir app_dir; |
865 | if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | 865 | if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { |
866 | syncMenu->setItemEnabled( false , 1000 ); | 866 | syncMenu->setItemEnabled( false , 1000 ); |
867 | } | 867 | } |
868 | mView->setupExternSyncProfiles(); | 868 | mView->setupExternSyncProfiles(); |
869 | } | 869 | } |
870 | 870 | ||
871 | int MainWindow::ringSync() | 871 | int MainWindow::ringSync() |
872 | { | 872 | { |
873 | int syncedProfiles = 0; | 873 | int syncedProfiles = 0; |
874 | int i; | 874 | int i; |
875 | QTime timer; | 875 | QTime timer; |
876 | KConfig config ( locateLocal( "config","syncprofilesrc" ) ); | 876 | KConfig config ( locateLocal( "config","syncprofilesrc" ) ); |
877 | QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; | 877 | QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; |
878 | KSyncProfile* temp = new KSyncProfile (); | 878 | KSyncProfile* temp = new KSyncProfile (); |
879 | KOPrefs::instance()->mAskForPreferences = false; | 879 | KOPrefs::instance()->mAskForPreferences = false; |
880 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 880 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
881 | mCurrentSyncProfile = i; | 881 | mCurrentSyncProfile = i; |
882 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 882 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
883 | temp->readConfig(&config); | 883 | temp->readConfig(&config); |
884 | if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { | 884 | if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { |
885 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 885 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
886 | ++syncedProfiles; | 886 | ++syncedProfiles; |
887 | // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 887 | // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
888 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 888 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
889 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 889 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
890 | KOPrefs::instance()->mShowSyncSummary = false; | 890 | KOPrefs::instance()->mShowSyncSummary = false; |
891 | mView->setSyncDevice(syncProfileNames[i] ); | 891 | mView->setSyncDevice(syncProfileNames[i] ); |
892 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); | 892 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); |
893 | if ( i == 0 ) { | 893 | if ( i == 0 ) { |
894 | syncSharp(); | 894 | syncSharp(); |
895 | } else { | 895 | } else { |
896 | if ( temp->getIsLocalFileSync() ) { | 896 | if ( temp->getIsLocalFileSync() ) { |
897 | if ( syncWithFile( temp->getRemoteFileName( ), true ) ) | 897 | if ( syncWithFile( temp->getRemoteFileName( ), true ) ) |
898 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); | 898 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); |
899 | } else { | 899 | } else { |
900 | if ( temp->getIsPhoneSync() ) { | 900 | if ( temp->getIsPhoneSync() ) { |
901 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | 901 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; |
902 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | 902 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); |
903 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | 903 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); |
904 | syncPhone(); | 904 | syncPhone(); |
905 | } else | 905 | } else |
906 | syncRemote( temp, false ); | 906 | syncRemote( temp, false ); |
907 | 907 | ||
908 | } | 908 | } |
909 | } | 909 | } |
910 | timer.start(); | 910 | timer.start(); |
911 | setCaption(i18n("Multiple sync in progress ... please wait!") ); | 911 | setCaption(i18n("Multiple sync in progress ... please wait!") ); |
912 | while ( timer.elapsed () < 2000 ) { | 912 | while ( timer.elapsed () < 2000 ) { |
913 | qApp->processEvents(); | 913 | qApp->processEvents(); |
914 | #ifndef _WIN32_ | 914 | #ifndef _WIN32_ |
915 | sleep (1); | 915 | sleep (1); |
916 | #endif | 916 | #endif |
917 | } | 917 | } |
918 | 918 | ||
919 | } | 919 | } |
920 | 920 | ||
921 | } | 921 | } |
922 | delete temp; | 922 | delete temp; |
923 | return syncedProfiles; | 923 | return syncedProfiles; |
924 | } | 924 | } |
925 | 925 | ||
926 | void MainWindow::multiSync( bool askforPrefs ) | 926 | void MainWindow::multiSync( bool askforPrefs ) |
927 | { | 927 | { |
928 | if (mBlockSaveFlag) | 928 | if (mBlockSaveFlag) |
929 | return; | 929 | return; |
930 | mBlockSaveFlag = true; | 930 | mBlockSaveFlag = true; |
931 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 931 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
932 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | 932 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), |
933 | question, | 933 | question, |
934 | i18n("Yes"), i18n("No"), | 934 | i18n("Yes"), i18n("No"), |
935 | 0, 0 ) != 0 ) { | 935 | 0, 0 ) != 0 ) { |
936 | mBlockSaveFlag = false; | 936 | mBlockSaveFlag = false; |
937 | setCaption(i18n("Aborted! Nothing synced!")); | 937 | setCaption(i18n("Aborted! Nothing synced!")); |
938 | return; | 938 | return; |
939 | } | 939 | } |
940 | mView->setSyncDevice(i18n("Multiple profiles") ); | 940 | mView->setSyncDevice(i18n("Multiple profiles") ); |
941 | KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; | 941 | KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; |
942 | if ( askforPrefs ) { | 942 | if ( askforPrefs ) { |
943 | mView->edit_sync_options(); | 943 | mView->edit_sync_options(); |
944 | KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; | 944 | KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; |
945 | } | 945 | } |
946 | setCaption(i18n("Multiple sync started.") ); | 946 | setCaption(i18n("Multiple sync started.") ); |
947 | qApp->processEvents(); | 947 | qApp->processEvents(); |
948 | int num = ringSync() ; | 948 | int num = ringSync() ; |
949 | if ( num > 1 ) | 949 | if ( num > 1 ) |
950 | ringSync(); | 950 | ringSync(); |
951 | mBlockSaveFlag = false; | 951 | mBlockSaveFlag = false; |
952 | if ( num ) | 952 | if ( num ) |
953 | save(); | 953 | save(); |
954 | if ( num ) | 954 | if ( num ) |
955 | setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); | 955 | setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); |
956 | else | 956 | else |
957 | setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 957 | setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
958 | return; | 958 | return; |
959 | } | 959 | } |
960 | void MainWindow::slotSyncMenu( int action ) | 960 | void MainWindow::slotSyncMenu( int action ) |
961 | { | 961 | { |
962 | //qDebug("syncaction %d ", action); | 962 | //qDebug("syncaction %d ", action); |
963 | if ( action == 0 ) { | 963 | if ( action == 0 ) { |
964 | 964 | ||
965 | confSync(); | 965 | confSync(); |
966 | 966 | ||
967 | return; | 967 | return; |
968 | } | 968 | } |
969 | if ( action == 1 ) { | 969 | if ( action == 1 ) { |
970 | multiSync( true ); | 970 | multiSync( true ); |
971 | return; | 971 | return; |
972 | } | 972 | } |
973 | 973 | ||
974 | if (mBlockSaveFlag) | 974 | if (mBlockSaveFlag) |
975 | return; | 975 | return; |
976 | mBlockSaveFlag = true; | 976 | mBlockSaveFlag = true; |
977 | mCurrentSyncProfile = action - 1000 ; | 977 | mCurrentSyncProfile = action - 1000 ; |
978 | mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); | 978 | mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); |
979 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); | 979 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); |
980 | KConfig config ( locateLocal( "config","syncprofilesrc" ) ); | 980 | KConfig config ( locateLocal( "config","syncprofilesrc" ) ); |
981 | KSyncProfile* temp = new KSyncProfile (); | 981 | KSyncProfile* temp = new KSyncProfile (); |
982 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 982 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
983 | temp->readConfig(&config); | 983 | temp->readConfig(&config); |
984 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 984 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
985 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); | 985 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); |
986 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 986 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
987 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 987 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
988 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); | 988 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); |
989 | if ( action == 1000 ) { | 989 | if ( action == 1000 ) { |
990 | syncSharp(); | 990 | syncSharp(); |
991 | 991 | ||
992 | } else if ( action == 1001 ) { | 992 | } else if ( action == 1001 ) { |
993 | syncLocalFile(); | 993 | syncLocalFile(); |
994 | 994 | ||
995 | } else if ( action == 1002 ) { | 995 | } else if ( action == 1002 ) { |
996 | quickSyncLocalFile(); | 996 | quickSyncLocalFile(); |
997 | 997 | ||
998 | } else if ( action >= 1003 ) { | 998 | } else if ( action >= 1003 ) { |
999 | if ( temp->getIsLocalFileSync() ) { | 999 | if ( temp->getIsLocalFileSync() ) { |
1000 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 1000 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
1001 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); | 1001 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); |
1002 | } else { | 1002 | } else { |
1003 | if ( temp->getIsPhoneSync() ) { | 1003 | if ( temp->getIsPhoneSync() ) { |
1004 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | 1004 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; |
1005 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | 1005 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); |
1006 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | 1006 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); |
1007 | syncPhone(); | 1007 | syncPhone(); |
1008 | } else | 1008 | } else |
1009 | syncRemote( temp ); | 1009 | syncRemote( temp ); |
1010 | 1010 | ||
1011 | } | 1011 | } |
1012 | } | 1012 | } |
1013 | delete temp; | 1013 | delete temp; |
1014 | mBlockSaveFlag = false; | 1014 | mBlockSaveFlag = false; |
1015 | } | 1015 | } |
1016 | void MainWindow::setDefaultPreferences() | 1016 | void MainWindow::setDefaultPreferences() |
1017 | { | 1017 | { |
1018 | KOPrefs *p = KOPrefs::instance(); | 1018 | KOPrefs *p = KOPrefs::instance(); |
1019 | 1019 | ||
1020 | p->mCompactDialogs = true; | 1020 | p->mCompactDialogs = true; |
1021 | p->mConfirm = true; | 1021 | p->mConfirm = true; |
1022 | // p->mEnableQuickTodo = false; | 1022 | // p->mEnableQuickTodo = false; |
1023 | } | 1023 | } |
1024 | 1024 | ||
1025 | QString MainWindow::resourcePath() | 1025 | QString MainWindow::resourcePath() |
1026 | { | 1026 | { |
1027 | return KGlobal::iconLoader()->iconPath(); | 1027 | return KGlobal::iconLoader()->iconPath(); |
1028 | } | 1028 | } |
1029 | 1029 | ||
1030 | void MainWindow::displayText( QString text ,QString cap ) | 1030 | void MainWindow::displayText( QString text ,QString cap ) |
1031 | { | 1031 | { |
1032 | QDialog dia( this, "name", true ); ; | 1032 | QDialog dia( this, "name", true ); ; |
1033 | dia.setCaption( cap ); | 1033 | dia.setCaption( cap ); |
1034 | QVBoxLayout* lay = new QVBoxLayout( &dia ); | 1034 | QVBoxLayout* lay = new QVBoxLayout( &dia ); |
1035 | lay->setSpacing( 3 ); | 1035 | lay->setSpacing( 3 ); |
1036 | lay->setMargin( 3 ); | 1036 | lay->setMargin( 3 ); |
1037 | QTextBrowser tb ( &dia ); | 1037 | QTextBrowser tb ( &dia ); |
1038 | lay->addWidget( &tb ); | 1038 | lay->addWidget( &tb ); |
1039 | tb.setText( text ); | 1039 | tb.setText( text ); |
1040 | #ifdef DESKTOP_VERSION | 1040 | #ifdef DESKTOP_VERSION |
1041 | dia.resize( 640, 480); | 1041 | dia.resize( 640, 480); |
1042 | #else | 1042 | #else |
1043 | dia.showMaximized(); | 1043 | dia.showMaximized(); |
1044 | #endif | 1044 | #endif |
1045 | dia.exec(); | 1045 | dia.exec(); |
1046 | } | 1046 | } |
1047 | void MainWindow::displayFile( QString fn, QString cap ) | 1047 | void MainWindow::displayFile( QString fn, QString cap ) |
1048 | { | 1048 | { |
1049 | QString fileName = resourcePath() + fn; | 1049 | QString fileName = resourcePath() + fn; |
1050 | QString text; | 1050 | QString text; |
1051 | QFile file( fileName ); | 1051 | QFile file( fileName ); |
1052 | if (!file.open( IO_ReadOnly ) ) { | 1052 | if (!file.open( IO_ReadOnly ) ) { |
1053 | return ; | 1053 | return ; |
1054 | 1054 | ||
1055 | } | 1055 | } |
1056 | QTextStream ts( &file ); | 1056 | QTextStream ts( &file ); |
1057 | text = ts.read(); | 1057 | text = ts.read(); |
1058 | file.close(); | 1058 | file.close(); |
1059 | displayText( text, cap); | 1059 | displayText( text, cap); |
1060 | } | 1060 | } |
1061 | void MainWindow::features() | 1061 | void MainWindow::features() |
1062 | { | 1062 | { |
1063 | 1063 | ||
1064 | displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); | 1064 | displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); |
1065 | } | 1065 | } |
1066 | 1066 | ||
1067 | void MainWindow::usertrans() | 1067 | void MainWindow::usertrans() |
1068 | { | 1068 | { |
1069 | 1069 | ||
1070 | displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); | 1070 | displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); |
1071 | } | 1071 | } |
1072 | #if 0 | ||
1073 | #include <libkcal/vcalformat.h> | ||
1074 | #include <libkcal/event.h> | ||
1075 | #include <libkcal/todo.h> | ||
1076 | #include <libkcal/incidence.h> | ||
1077 | #endif | ||
1072 | void MainWindow::synchowto() | 1078 | void MainWindow::synchowto() |
1073 | { | 1079 | { |
1074 | 1080 | #if 0 | |
1081 | QPtrList<Incidence> er = mCalendar->rawIncidences(); | ||
1082 | Incidence* inR = er.first(); | ||
1083 | VCalFormat vf; | ||
1084 | QString strout; | ||
1085 | while ( inR ) { | ||
1086 | if ( inR->type() == "Todo" ) | ||
1087 | strout = vf.todoToString( (Todo *) inR ); | ||
1088 | if ( inR->type() == "Event" ) | ||
1089 | strout = vf.eventToString( (Event *) inR ); | ||
1090 | qDebug("incidence: \n%s\n ente\n\n",strout.latin1() ); | ||
1091 | inR = er.next(); | ||
1092 | } | ||
1093 | #endif | ||
1075 | displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); | 1094 | displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); |
1076 | } | 1095 | } |
1077 | void MainWindow::faq() | 1096 | void MainWindow::faq() |
1078 | { | 1097 | { |
1079 | displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); | 1098 | displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); |
1080 | 1099 | ||
1081 | } | 1100 | } |
1082 | void MainWindow::whatsNew() | 1101 | void MainWindow::whatsNew() |
1083 | { | 1102 | { |
1084 | displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); | 1103 | displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); |
1085 | 1104 | ||
1086 | } | 1105 | } |
1087 | void MainWindow::licence() | 1106 | void MainWindow::licence() |
1088 | { | 1107 | { |
1089 | KApplication::showLicence(); | 1108 | KApplication::showLicence(); |
1090 | 1109 | ||
1091 | } | 1110 | } |
1092 | void MainWindow::about() | 1111 | void MainWindow::about() |
1093 | { | 1112 | { |
1094 | QString version; | 1113 | QString version; |
1095 | #include <../version> | 1114 | #include <../version> |
1096 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), | 1115 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), |
1097 | i18n("KOrganizer/Platform-independent\n") + | 1116 | i18n("KOrganizer/Platform-independent\n") + |
1098 | "(KO/Pi) " + version + " - " + | 1117 | "(KO/Pi) " + version + " - " + |
1099 | 1118 | ||
1100 | #ifdef DESKTOP_VERSION | 1119 | #ifdef DESKTOP_VERSION |
1101 | i18n("Desktop Edition\n") + | 1120 | i18n("Desktop Edition\n") + |
1102 | #else | 1121 | #else |
1103 | i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + | 1122 | i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + |
1104 | #endif | 1123 | #endif |
1105 | i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); | 1124 | i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); |
1106 | } | 1125 | } |
1107 | void MainWindow::keyBindings() | 1126 | void MainWindow::keyBindings() |
1108 | { | 1127 | { |
1109 | QString cap = i18n("Key bindings KOrganizer/Pi"); | 1128 | QString cap = i18n("Key bindings KOrganizer/Pi"); |
1110 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + | 1129 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + |
1111 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ | 1130 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ |
1112 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + | 1131 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + |
1113 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ | 1132 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ |
1114 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ | 1133 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ |
1115 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ | 1134 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ |
1116 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ | 1135 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ |
1117 | i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ | 1136 | i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ |
1118 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ | 1137 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ |
1119 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ | 1138 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ |
1120 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ | 1139 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ |
1121 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ | 1140 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ |
1122 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ | 1141 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ |
1123 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ | 1142 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ |
1124 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ | 1143 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ |
1125 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ | 1144 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ |
1126 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ | 1145 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ |
1127 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ | 1146 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ |
1128 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ | 1147 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ |
1129 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ | 1148 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ |
1130 | i18n("<p><h3>In agenda view:</h3></p>\n") + | 1149 | i18n("<p><h3>In agenda view:</h3></p>\n") + |
1131 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ | 1150 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ |
1132 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ | 1151 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ |
1133 | i18n("<p><h3>In todo view:</h3></p>\n") + | 1152 | i18n("<p><h3>In todo view:</h3></p>\n") + |
1134 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ | 1153 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ |
1135 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1154 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1136 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ | 1155 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ |
1137 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ | 1156 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ |
1138 | i18n("<p><h3>In list view:</h3></p>\n") + | 1157 | i18n("<p><h3>In list view:</h3></p>\n") + |
1139 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1158 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1140 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ | 1159 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ |
1141 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ | 1160 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ |
1142 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ | 1161 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ |
1143 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ | 1162 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ |
1144 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ | 1163 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ |
1145 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + | 1164 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + |
1146 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ | 1165 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ |
1147 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ | 1166 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ |
1148 | i18n("<p><b>E</b>: Edit item</p>\n") + | 1167 | i18n("<p><b>E</b>: Edit item</p>\n") + |
1149 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + | 1168 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + |
1150 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + | 1169 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + |
1151 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ | 1170 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ |
1152 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ | 1171 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ |
1153 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ | 1172 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ |
1154 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ | 1173 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ |
1155 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ | 1174 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ |
1156 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + | 1175 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + |
1157 | i18n("<p><b>White</b>: Item readonly</p>\n"); | 1176 | i18n("<p><b>White</b>: Item readonly</p>\n"); |
1158 | displayText( text, cap); | 1177 | displayText( text, cap); |
1159 | 1178 | ||
1160 | } | 1179 | } |
1161 | void MainWindow::aboutAutoSaving() | 1180 | void MainWindow::aboutAutoSaving() |
1162 | { | 1181 | { |
1163 | QMessageBox* msg; | 1182 | QMessageBox* msg; |
1164 | msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), | 1183 | msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), |
1165 | i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon, | 1184 | i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon, |
1166 | QMessageBox::Ok, | 1185 | QMessageBox::Ok, |
1167 | QMessageBox::NoButton, | 1186 | QMessageBox::NoButton, |
1168 | QMessageBox::NoButton); | 1187 | QMessageBox::NoButton); |
1169 | msg->exec(); | 1188 | msg->exec(); |
1170 | delete msg; | 1189 | delete msg; |
1171 | 1190 | ||
1172 | 1191 | ||
1173 | } | 1192 | } |
1174 | void MainWindow::aboutKnownBugs() | 1193 | void MainWindow::aboutKnownBugs() |
1175 | { | 1194 | { |
1176 | QMessageBox* msg; | 1195 | QMessageBox* msg; |
1177 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), | 1196 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), |
1178 | i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ | 1197 | i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ |
1179 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ | 1198 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ |
1180 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + | 1199 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + |
1181 | i18n("\nor report them in the bugtracker on\n") + | 1200 | i18n("\nor report them in the bugtracker on\n") + |
1182 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), | 1201 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), |
1183 | QMessageBox::NoIcon, | 1202 | QMessageBox::NoIcon, |
1184 | QMessageBox::Ok, | 1203 | QMessageBox::Ok, |
1185 | QMessageBox::NoButton, | 1204 | QMessageBox::NoButton, |
1186 | QMessageBox::NoButton); | 1205 | QMessageBox::NoButton); |
1187 | msg->exec(); | 1206 | msg->exec(); |
1188 | delete msg; | 1207 | delete msg; |
1189 | 1208 | ||
1190 | } | 1209 | } |
1191 | 1210 | ||
1192 | QString MainWindow::defaultFileName() | 1211 | QString MainWindow::defaultFileName() |
1193 | { | 1212 | { |
1194 | return locateLocal( "data", "korganizer/mycalendar.ics" ); | 1213 | return locateLocal( "data", "korganizer/mycalendar.ics" ); |
1195 | } | 1214 | } |
1196 | 1215 | ||
1197 | void MainWindow::processIncidenceSelection( Incidence *incidence ) | 1216 | void MainWindow::processIncidenceSelection( Incidence *incidence ) |
1198 | { | 1217 | { |
1199 | if ( !incidence ) { | 1218 | if ( !incidence ) { |
1200 | enableIncidenceActions( false ); | 1219 | enableIncidenceActions( false ); |
1201 | 1220 | ||
1202 | mNewSubTodoAction->setEnabled( false ); | 1221 | mNewSubTodoAction->setEnabled( false ); |
1203 | setCaptionToDates(); | 1222 | setCaptionToDates(); |
1204 | return; | 1223 | return; |
1205 | 1224 | ||
1206 | } | 1225 | } |
1207 | 1226 | ||
1208 | //KGlobal::locale()->formatDateTime(nextA, true); | 1227 | //KGlobal::locale()->formatDateTime(nextA, true); |
1209 | QString startString = ""; | 1228 | QString startString = ""; |
1210 | if ( incidence->type() != "Todo" ) { | 1229 | if ( incidence->type() != "Todo" ) { |
1211 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { | 1230 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { |
1212 | if ( incidence->doesFloat() ) { | 1231 | if ( incidence->doesFloat() ) { |
1213 | startString += ": "+incidence->dtStartDateStr( true ); | 1232 | startString += ": "+incidence->dtStartDateStr( true ); |
1214 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); | 1233 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); |
1215 | 1234 | ||
1216 | } else { | 1235 | } else { |
1217 | startString = ": "+incidence->dtStartStr(true); | 1236 | startString = ": "+incidence->dtStartStr(true); |
1218 | startString += " --- "+((Event*)incidence)->dtEndStr(true); | 1237 | startString += " --- "+((Event*)incidence)->dtEndStr(true); |
1219 | 1238 | ||
1220 | } | 1239 | } |
1221 | 1240 | ||
1222 | } else { | 1241 | } else { |
1223 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) | 1242 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) |
1224 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ | 1243 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ |
1225 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); | 1244 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); |
1226 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); | 1245 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); |
1227 | } | 1246 | } |
1228 | 1247 | ||
1229 | } | 1248 | } |
1230 | else | 1249 | else |
1231 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); | 1250 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); |
1232 | if ( !incidence->location().isEmpty() ) | 1251 | if ( !incidence->location().isEmpty() ) |
1233 | startString += " (" +incidence->location()+")"; | 1252 | startString += " (" +incidence->location()+")"; |
1234 | setCaption( incidence->summary()+startString); | 1253 | setCaption( incidence->summary()+startString); |
1235 | 1254 | ||
1236 | enableIncidenceActions( true ); | 1255 | enableIncidenceActions( true ); |
1237 | 1256 | ||
1238 | if ( incidence->type() == "Event" ) { | 1257 | if ( incidence->type() == "Event" ) { |
1239 | mShowAction->setText( i18n("Show Event...") ); | 1258 | mShowAction->setText( i18n("Show Event...") ); |
1240 | mEditAction->setText( i18n("Edit Event...") ); | 1259 | mEditAction->setText( i18n("Edit Event...") ); |
1241 | mDeleteAction->setText( i18n("Delete Event...") ); | 1260 | mDeleteAction->setText( i18n("Delete Event...") ); |
1242 | 1261 | ||
1243 | mNewSubTodoAction->setEnabled( false ); | 1262 | mNewSubTodoAction->setEnabled( false ); |
1244 | } else if ( incidence->type() == "Todo" ) { | 1263 | } else if ( incidence->type() == "Todo" ) { |
1245 | mShowAction->setText( i18n("Show Todo...") ); | 1264 | mShowAction->setText( i18n("Show Todo...") ); |
1246 | mEditAction->setText( i18n("Edit Todo...") ); | 1265 | mEditAction->setText( i18n("Edit Todo...") ); |
1247 | mDeleteAction->setText( i18n("Delete Todo...") ); | 1266 | mDeleteAction->setText( i18n("Delete Todo...") ); |
1248 | 1267 | ||
1249 | mNewSubTodoAction->setEnabled( true ); | 1268 | mNewSubTodoAction->setEnabled( true ); |
1250 | } else { | 1269 | } else { |
1251 | mShowAction->setText( i18n("Show...") ); | 1270 | mShowAction->setText( i18n("Show...") ); |
1252 | mShowAction->setText( i18n("Edit...") ); | 1271 | mShowAction->setText( i18n("Edit...") ); |
1253 | mShowAction->setText( i18n("Delete...") ); | 1272 | mShowAction->setText( i18n("Delete...") ); |
1254 | 1273 | ||
1255 | mNewSubTodoAction->setEnabled( false ); | 1274 | mNewSubTodoAction->setEnabled( false ); |
1256 | } | 1275 | } |
1257 | } | 1276 | } |
1258 | 1277 | ||
1259 | void MainWindow::enableIncidenceActions( bool enabled ) | 1278 | void MainWindow::enableIncidenceActions( bool enabled ) |
1260 | { | 1279 | { |
1261 | mShowAction->setEnabled( enabled ); | 1280 | mShowAction->setEnabled( enabled ); |
1262 | mEditAction->setEnabled( enabled ); | 1281 | mEditAction->setEnabled( enabled ); |
1263 | mDeleteAction->setEnabled( enabled ); | 1282 | mDeleteAction->setEnabled( enabled ); |
1264 | } | 1283 | } |
1265 | 1284 | ||
1266 | void MainWindow::importOL() | 1285 | void MainWindow::importOL() |
1267 | { | 1286 | { |
1268 | #ifdef _WIN32_ | 1287 | #ifdef _WIN32_ |
1269 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); | 1288 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); |
1270 | id->exec(); | 1289 | id->exec(); |
1271 | delete id; | 1290 | delete id; |
1272 | mView->updateView(); | 1291 | mView->updateView(); |
1273 | #endif | 1292 | #endif |
1274 | } | 1293 | } |
1275 | void MainWindow::importBday() | 1294 | void MainWindow::importBday() |
1276 | { | 1295 | { |
1277 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1296 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1278 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), | 1297 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), |
1279 | i18n("Import!"), i18n("Cancel"), 0, | 1298 | i18n("Import!"), i18n("Cancel"), 0, |
1280 | 0, 1 ); | 1299 | 0, 1 ); |
1281 | if ( result == 0 ) { | 1300 | if ( result == 0 ) { |
1282 | mView->importBday(); | 1301 | mView->importBday(); |
1283 | 1302 | ||
1284 | } | 1303 | } |
1285 | 1304 | ||
1286 | 1305 | ||
1287 | } | 1306 | } |
1288 | void MainWindow::importQtopia() | 1307 | void MainWindow::importQtopia() |
1289 | { | 1308 | { |
1290 | #ifndef DESKTOP_VERSION | 1309 | #ifndef DESKTOP_VERSION |
1291 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1310 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1292 | i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), | 1311 | i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), |
1293 | i18n("Import!"), i18n("Cancel"), 0, | 1312 | i18n("Import!"), i18n("Cancel"), 0, |
1294 | 0, 1 ); | 1313 | 0, 1 ); |
1295 | if ( result == 0 ) { | 1314 | if ( result == 0 ) { |
1296 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); | 1315 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); |
1297 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); | 1316 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); |
1298 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; | 1317 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; |
1299 | mView->importQtopia( categories, datebook, todolist ); | 1318 | mView->importQtopia( categories, datebook, todolist ); |
1300 | } | 1319 | } |
1301 | #else | 1320 | #else |
1302 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1321 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1303 | i18n("Not supported \non desktop!\n"), | 1322 | i18n("Not supported \non desktop!\n"), |
1304 | i18n("Ok"), i18n("Cancel"), 0, | 1323 | i18n("Ok"), i18n("Cancel"), 0, |
1305 | 0, 1 ); | 1324 | 0, 1 ); |
1306 | 1325 | ||
1307 | #endif | 1326 | #endif |
1308 | } | 1327 | } |
1309 | 1328 | ||
1310 | void MainWindow::saveOnClose() | 1329 | void MainWindow::saveOnClose() |
1311 | { | 1330 | { |
1312 | KOPrefs *p = KOPrefs::instance(); | 1331 | KOPrefs *p = KOPrefs::instance(); |
1313 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); | 1332 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); |
1314 | p->mToolBarUp = iconToolBar->x() > width()/2 || | 1333 | p->mToolBarUp = iconToolBar->x() > width()/2 || |
1315 | iconToolBar->y() > height()/2; | 1334 | iconToolBar->y() > height()/2; |
1316 | mView->writeSettings(); | 1335 | mView->writeSettings(); |
1317 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) | 1336 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) |
1318 | save(); | 1337 | save(); |
1319 | } | 1338 | } |
1320 | void MainWindow::slotModifiedChanged( bool changed ) | 1339 | void MainWindow::slotModifiedChanged( bool changed ) |
1321 | { | 1340 | { |
1322 | if ( mBlockAtStartup ) | 1341 | if ( mBlockAtStartup ) |
1323 | return; | 1342 | return; |
1324 | int msec; | 1343 | int msec; |
1325 | // we store the changes after 1 minute, | 1344 | // we store the changes after 1 minute, |
1326 | // and for safety reasons after 10 minutes again | 1345 | // and for safety reasons after 10 minutes again |
1327 | if ( !mBlockSaveFlag ) | 1346 | if ( !mBlockSaveFlag ) |
1328 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; | 1347 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; |
1329 | else | 1348 | else |
1330 | msec = 1000 * 600; | 1349 | msec = 1000 * 600; |
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index 11c68c5..e6d4879 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp | |||
@@ -617,565 +617,523 @@ ulong PhoneFormat::getCsumTodo( Todo* todo ) | |||
617 | completedString = "yes"; | 617 | completedString = "yes"; |
618 | attList << completedString; | 618 | attList << completedString; |
619 | attList << QString::number( todo->priority() ); | 619 | attList << QString::number( todo->priority() ); |
620 | QString alarmString = "na"; | 620 | QString alarmString = "na"; |
621 | Alarm *alarm; | 621 | Alarm *alarm; |
622 | if ( todo->alarms().count() > 0 ) { | 622 | if ( todo->alarms().count() > 0 ) { |
623 | alarm = todo->alarms().first(); | 623 | alarm = todo->alarms().first(); |
624 | if ( alarm->enabled() ) { | 624 | if ( alarm->enabled() ) { |
625 | alarmString = QString::number(alarm->startOffset().asSeconds() ); | 625 | alarmString = QString::number(alarm->startOffset().asSeconds() ); |
626 | } | 626 | } |
627 | } | 627 | } |
628 | attList << alarmString; | 628 | attList << alarmString; |
629 | attList << todo->categoriesStr(); | 629 | attList << todo->categoriesStr(); |
630 | attList << todo->secrecyStr(); | 630 | attList << todo->secrecyStr(); |
631 | return PhoneFormat::getCsum(attList ); | 631 | return PhoneFormat::getCsum(attList ); |
632 | 632 | ||
633 | } | 633 | } |
634 | ulong PhoneFormat::getCsumEvent( Event* event ) | 634 | ulong PhoneFormat::getCsumEvent( Event* event ) |
635 | { | 635 | { |
636 | QStringList attList; | 636 | QStringList attList; |
637 | attList << PhoneParser::dtToString ( event->dtStart() ); | 637 | attList << PhoneParser::dtToString ( event->dtStart() ); |
638 | attList << PhoneParser::dtToString ( event->dtEnd() ); | 638 | attList << PhoneParser::dtToString ( event->dtEnd() ); |
639 | attList << event->summary(); | 639 | attList << event->summary(); |
640 | attList << event->location(); | 640 | attList << event->location(); |
641 | QString alarmString = "na"; | 641 | QString alarmString = "na"; |
642 | Alarm *alarm; | 642 | Alarm *alarm; |
643 | if ( event->alarms().count() > 0 ) { | 643 | if ( event->alarms().count() > 0 ) { |
644 | alarm = event->alarms().first(); | 644 | alarm = event->alarms().first(); |
645 | if ( alarm->enabled() ) { | 645 | if ( alarm->enabled() ) { |
646 | alarmString = QString::number( alarm->startOffset().asSeconds() ); | 646 | alarmString = QString::number( alarm->startOffset().asSeconds() ); |
647 | } | 647 | } |
648 | } | 648 | } |
649 | attList << alarmString; | 649 | attList << alarmString; |
650 | Recurrence* rec = event->recurrence(); | 650 | Recurrence* rec = event->recurrence(); |
651 | QStringList list; | 651 | QStringList list; |
652 | bool writeEndDate = false; | 652 | bool writeEndDate = false; |
653 | switch ( rec->doesRecur() ) | 653 | switch ( rec->doesRecur() ) |
654 | { | 654 | { |
655 | case Recurrence::rDaily: // 0 | 655 | case Recurrence::rDaily: // 0 |
656 | list.append( "0" ); | 656 | list.append( "0" ); |
657 | list.append( QString::number( rec->frequency() ));//12 | 657 | list.append( QString::number( rec->frequency() ));//12 |
658 | list.append( "0" ); | 658 | list.append( "0" ); |
659 | list.append( "0" ); | 659 | list.append( "0" ); |
660 | writeEndDate = true; | 660 | writeEndDate = true; |
661 | break; | 661 | break; |
662 | case Recurrence::rWeekly:// 1 | 662 | case Recurrence::rWeekly:// 1 |
663 | list.append( "1" ); | 663 | list.append( "1" ); |
664 | list.append( QString::number( rec->frequency()) );//12 | 664 | list.append( QString::number( rec->frequency()) );//12 |
665 | list.append( "0" ); | 665 | list.append( "0" ); |
666 | { | 666 | { |
667 | int days = 0; | 667 | int days = 0; |
668 | QBitArray weekDays = rec->days(); | 668 | QBitArray weekDays = rec->days(); |
669 | int i; | 669 | int i; |
670 | for( i = 1; i <= 7; ++i ) { | 670 | for( i = 1; i <= 7; ++i ) { |
671 | if ( weekDays[i-1] ) { | 671 | if ( weekDays[i-1] ) { |
672 | days += 1 << (i-1); | 672 | days += 1 << (i-1); |
673 | } | 673 | } |
674 | } | 674 | } |
675 | list.append( QString::number( days ) ); | 675 | list.append( QString::number( days ) ); |
676 | } | 676 | } |
677 | //pending weekdays | 677 | //pending weekdays |
678 | writeEndDate = true; | 678 | writeEndDate = true; |
679 | 679 | ||
680 | break; | 680 | break; |
681 | case Recurrence::rMonthlyPos:// 2 | 681 | case Recurrence::rMonthlyPos:// 2 |
682 | list.append( "2" ); | 682 | list.append( "2" ); |
683 | list.append( QString::number( rec->frequency()) );//12 | 683 | list.append( QString::number( rec->frequency()) );//12 |
684 | 684 | ||
685 | writeEndDate = true; | 685 | writeEndDate = true; |
686 | { | 686 | { |
687 | int count = 1; | 687 | int count = 1; |
688 | QPtrList<Recurrence::rMonthPos> rmp; | 688 | QPtrList<Recurrence::rMonthPos> rmp; |
689 | rmp = rec->monthPositions(); | 689 | rmp = rec->monthPositions(); |
690 | if ( rmp.first()->negative ) | 690 | if ( rmp.first()->negative ) |
691 | count = 5 - rmp.first()->rPos - 1; | 691 | count = 5 - rmp.first()->rPos - 1; |
692 | else | 692 | else |
693 | count = rmp.first()->rPos - 1; | 693 | count = rmp.first()->rPos - 1; |
694 | list.append( QString::number( count ) ); | 694 | list.append( QString::number( count ) ); |
695 | 695 | ||
696 | } | 696 | } |
697 | 697 | ||
698 | list.append( "0" ); | 698 | list.append( "0" ); |
699 | break; | 699 | break; |
700 | case Recurrence::rMonthlyDay:// 3 | 700 | case Recurrence::rMonthlyDay:// 3 |
701 | list.append( "3" ); | 701 | list.append( "3" ); |
702 | list.append( QString::number( rec->frequency()) );//12 | 702 | list.append( QString::number( rec->frequency()) );//12 |
703 | list.append( "0" ); | 703 | list.append( "0" ); |
704 | list.append( "0" ); | 704 | list.append( "0" ); |
705 | writeEndDate = true; | 705 | writeEndDate = true; |
706 | break; | 706 | break; |
707 | case Recurrence::rYearlyMonth://4 | 707 | case Recurrence::rYearlyMonth://4 |
708 | list.append( "4" ); | 708 | list.append( "4" ); |
709 | list.append( QString::number( rec->frequency()) );//12 | 709 | list.append( QString::number( rec->frequency()) );//12 |
710 | list.append( "0" ); | 710 | list.append( "0" ); |
711 | list.append( "0" ); | 711 | list.append( "0" ); |
712 | writeEndDate = true; | 712 | writeEndDate = true; |
713 | break; | 713 | break; |
714 | 714 | ||
715 | default: | 715 | default: |
716 | list.append( "255" ); | 716 | list.append( "255" ); |
717 | list.append( QString() ); | 717 | list.append( QString() ); |
718 | list.append( "0" ); | 718 | list.append( "0" ); |
719 | list.append( QString() ); | 719 | list.append( QString() ); |
720 | list.append( "0" ); | 720 | list.append( "0" ); |
721 | list.append( "20991231T000000" ); | 721 | list.append( "20991231T000000" ); |
722 | break; | 722 | break; |
723 | } | 723 | } |
724 | if ( writeEndDate ) { | 724 | if ( writeEndDate ) { |
725 | 725 | ||
726 | if ( rec->endDate().isValid() ) { // 15 + 16 | 726 | if ( rec->endDate().isValid() ) { // 15 + 16 |
727 | list.append( "1" ); | 727 | list.append( "1" ); |
728 | list.append( PhoneParser::dtToString( rec->endDate()) ); | 728 | list.append( PhoneParser::dtToString( rec->endDate()) ); |
729 | } else { | 729 | } else { |
730 | list.append( "0" ); | 730 | list.append( "0" ); |
731 | list.append( "20991231T000000" ); | 731 | list.append( "20991231T000000" ); |
732 | } | 732 | } |
733 | 733 | ||
734 | } | 734 | } |
735 | attList << list.join(""); | 735 | attList << list.join(""); |
736 | attList << event->categoriesStr(); | 736 | attList << event->categoriesStr(); |
737 | attList << event->secrecyStr(); | 737 | attList << event->secrecyStr(); |
738 | return PhoneFormat::getCsum(attList ); | 738 | return PhoneFormat::getCsum(attList ); |
739 | } | 739 | } |
740 | ulong PhoneFormat::getCsum( const QStringList & attList) | 740 | ulong PhoneFormat::getCsum( const QStringList & attList) |
741 | { | 741 | { |
742 | int max = attList.count() -1; | 742 | int max = attList.count() -1; |
743 | ulong cSum = 0; | 743 | ulong cSum = 0; |
744 | int j,k,i; | 744 | int j,k,i; |
745 | int add; | 745 | int add; |
746 | for ( i = 1; i < max ; ++i ) { | 746 | for ( i = 1; i < max ; ++i ) { |
747 | QString s = attList[i]; | 747 | QString s = attList[i]; |
748 | if ( ! s.isEmpty() ){ | 748 | if ( ! s.isEmpty() ){ |
749 | j = s.length(); | 749 | j = s.length(); |
750 | for ( k = 0; k < j; ++k ) { | 750 | for ( k = 0; k < j; ++k ) { |
751 | int mul = k +1; | 751 | int mul = k +1; |
752 | add = s[k].unicode (); | 752 | add = s[k].unicode (); |
753 | if ( k < 16 ) | 753 | if ( k < 16 ) |
754 | mul = mul * mul; | 754 | mul = mul * mul; |
755 | add = add * mul *i*i*i; | 755 | add = add * mul *i*i*i; |
756 | cSum += add; | 756 | cSum += add; |
757 | } | 757 | } |
758 | } | 758 | } |
759 | } | 759 | } |
760 | return cSum; | 760 | return cSum; |
761 | 761 | ||
762 | } | 762 | } |
763 | //extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); | 763 | //extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); |
764 | #include <stdlib.h> | 764 | #include <stdlib.h> |
765 | #define DEBUGMODE false | 765 | #define DEBUGMODE false |
766 | bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) | 766 | bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) |
767 | { | 767 | { |
768 | GSM_StateMachines; | 768 | GSM_StateMachines; |
769 | qDebug(" load "); | 769 | qDebug(" load "); |
770 | s.opened = false; | 770 | s.opened = false; |
771 | s.msg = NULL; | 771 | s.msg = NULL; |
772 | s.ConfigNum = 0; | 772 | s.ConfigNum = 0; |
773 | QLabel status ( i18n("Reading data. Opening device ..."), 0 ); | 773 | QLabel status ( i18n("Reading data. Opening device ..."), 0 ); |
774 | int w = status.sizeHint().width()+20 ; | 774 | int w = status.sizeHint().width()+20 ; |
775 | if ( w < 200 ) w = 200; | 775 | if ( w < 200 ) w = 200; |
776 | int h = status.sizeHint().height()+20 ; | 776 | int h = status.sizeHint().height()+20 ; |
777 | int dw = QApplication::desktop()->width(); | 777 | int dw = QApplication::desktop()->width(); |
778 | int dh = QApplication::desktop()->height(); | 778 | int dh = QApplication::desktop()->height(); |
779 | status.setCaption(i18n("Reading Phone Data") ); | 779 | status.setCaption(i18n("Reading Phone Data") ); |
780 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 780 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
781 | status.show(); | 781 | status.show(); |
782 | status.raise(); | 782 | status.raise(); |
783 | qApp->processEvents(); | 783 | qApp->processEvents(); |
784 | #if 0 | 784 | #if 0 |
785 | static char*cp; | 785 | static char*cp; |
786 | static INI_Section *cfg = NULL; | 786 | static INI_Section *cfg = NULL; |
787 | cfg=GSM_FindGammuRC(); | 787 | cfg=GSM_FindGammuRC(); |
788 | int i; | 788 | int i; |
789 | for (i = 0; i <= MAX_CONFIG_NUM; i++) { | 789 | for (i = 0; i <= MAX_CONFIG_NUM; i++) { |
790 | if (cfg!=NULL) { | 790 | if (cfg!=NULL) { |
791 | cp = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*)"gammucoding", false); | 791 | cp = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*)"gammucoding", false); |
792 | if (cp) di.coding = cp; | 792 | if (cp) di.coding = cp; |
793 | 793 | ||
794 | s.Config[i].Localize = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*) "gammuloc", false); | 794 | s.Config[i].Localize = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*) "gammuloc", false); |
795 | if (s.Config[i].Localize) { | 795 | if (s.Config[i].Localize) { |
796 | s.msg=INI_ReadFile(s.Config[i].Localize, true); | 796 | s.msg=INI_ReadFile(s.Config[i].Localize, true); |
797 | } else { | 797 | } else { |
798 | #if !defined(WIN32) && defined(LOCALE_PATH) | 798 | #if !defined(WIN32) && defined(LOCALE_PATH) |
799 | locale = setlocale(LC_MESSAGES, NULL); | 799 | locale = setlocale(LC_MESSAGES, NULL); |
800 | if (locale != NULL) { | 800 | if (locale != NULL) { |
801 | snprintf(locale_file, 200, "%s/gammu_%c%c.txt", | 801 | snprintf(locale_file, 200, "%s/gammu_%c%c.txt", |
802 | LOCALE_PATH, | 802 | LOCALE_PATH, |
803 | tolower(locale[0]), | 803 | tolower(locale[0]), |
804 | tolower(locale[1])); | 804 | tolower(locale[1])); |
805 | s.msg = INI_ReadFile(locale_file, true); | 805 | s.msg = INI_ReadFile(locale_file, true); |
806 | } | 806 | } |
807 | #endif | 807 | #endif |
808 | } | 808 | } |
809 | } | 809 | } |
810 | 810 | ||
811 | /* Wanted user specific configuration? */ | 811 | /* Wanted user specific configuration? */ |
812 | 812 | ||
813 | if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break; | 813 | if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break; |
814 | 814 | ||
815 | s.ConfigNum++; | 815 | s.ConfigNum++; |
816 | 816 | ||
817 | /* We want to use only one file descriptor for global and state machine debug output */ | 817 | /* We want to use only one file descriptor for global and state machine debug output */ |
818 | s.Config[i].UseGlobalDebugFile = true; | 818 | s.Config[i].UseGlobalDebugFile = true; |
819 | 819 | ||
820 | 820 | ||
821 | 821 | ||
822 | /* We wanted to read just user specified configuration. */ | 822 | /* We wanted to read just user specified configuration. */ |
823 | {break;} | 823 | {break;} |
824 | } | 824 | } |
825 | 825 | ||
826 | #endif | 826 | #endif |
827 | int error=initDevice(&s); | 827 | int error=initDevice(&s); |
828 | qDebug("GSM Init %d (no error is %d)", error, ERR_NONE); | 828 | qDebug("GSM Init %d (no error is %d)", error, ERR_NONE); |
829 | if ( error != ERR_NONE ) | 829 | if ( error != ERR_NONE ) |
830 | return false; | 830 | return false; |
831 | GSM_Phone_Functions*Phone; | 831 | GSM_Phone_Functions*Phone; |
832 | GSM_CalendarEntrynote; | 832 | GSM_CalendarEntrynote; |
833 | bool start = true; | 833 | bool start = true; |
834 | Phone=s.Phone.Functions; | 834 | Phone=s.Phone.Functions; |
835 | bool gshutdown = false; | 835 | bool gshutdown = false; |
836 | PhoneParser handler( calendar, mProfileName ); | 836 | PhoneParser handler( calendar, mProfileName ); |
837 | int ccc = 0; | 837 | int ccc = 0; |
838 | QString message = i18n("Processing event # "); | 838 | QString message = i18n("Processing event # "); |
839 | int procCount = 0; | 839 | int procCount = 0; |
840 | qDebug("Debug: only 10 calender items are downloaded "); | 840 | qDebug("Debug: only 10 calender items are downloaded "); |
841 | while (!gshutdown && ccc++ < 10) { | 841 | while (!gshutdown && ccc++ < 10) { |
842 | status.setText ( message + QString::number ( ++procCount ) ); | 842 | status.setText ( message + QString::number ( ++procCount ) ); |
843 | qApp->processEvents(); | 843 | qApp->processEvents(); |
844 | qDebug("readEvent %d ", ccc); | 844 | qDebug("readEvent %d ", ccc); |
845 | error=Phone->GetNextCalendar(&s,¬e,start); | 845 | error=Phone->GetNextCalendar(&s,¬e,start); |
846 | if (error == ERR_EMPTY) break; | 846 | if (error == ERR_EMPTY) break; |
847 | start = false; | 847 | start = false; |
848 | handler.readEvent( existingCal, ¬e ); | 848 | handler.readEvent( existingCal, ¬e ); |
849 | } | 849 | } |
850 | 850 | ||
851 | start = true; | 851 | start = true; |
852 | GSM_ToDoEntry ToDo; | 852 | GSM_ToDoEntry ToDo; |
853 | ccc = 0; | 853 | ccc = 0; |
854 | message = i18n("Processing todo # "); | 854 | message = i18n("Processing todo # "); |
855 | procCount = 0; | 855 | procCount = 0; |
856 | while (!gshutdown) { | 856 | while (!gshutdown) { |
857 | status.setText ( message + QString::number ( ++procCount ) ); | 857 | status.setText ( message + QString::number ( ++procCount ) ); |
858 | qApp->processEvents(); | 858 | qApp->processEvents(); |
859 | error = Phone->GetNextToDo(&s, &ToDo, start); | 859 | error = Phone->GetNextToDo(&s, &ToDo, start); |
860 | if (error == ERR_EMPTY) break; | 860 | if (error == ERR_EMPTY) break; |
861 | start = false; | 861 | start = false; |
862 | qDebug("ReadTodo %d ", ++ccc); | 862 | qDebug("ReadTodo %d ", ++ccc); |
863 | handler.readTodo( existingCal, &ToDo, &s); | 863 | handler.readTodo( existingCal, &ToDo, &s); |
864 | 864 | ||
865 | } | 865 | } |
866 | 866 | ||
867 | error=GSM_TerminateConnection(&s); | 867 | error=GSM_TerminateConnection(&s); |
868 | 868 | ||
869 | return true; | 869 | return true; |
870 | } | 870 | } |
871 | void PhoneFormat::event2GSM( Event* ev, GSM_CalendarEntry*Note ) | 871 | void PhoneFormat::event2GSM( Event* ev, GSM_CalendarEntry*Note ) |
872 | { | 872 | { |
873 | 873 | QString eText = vfconverter.eventToString( ev ); | |
874 | int pos = 0; | ||
875 | GSM_ToDoEntry dummy; | ||
876 | GSM_DecodeVCALENDAR_VTODO( (unsigned char*)eText.latin1(), &pos, Note , &dummy, Nokia_VCalendar, Nokia_VToDo ); | ||
874 | } | 877 | } |
875 | void PhoneFormat::todo2GSM( Todo* todo, GSM_ToDoEntry *gsm ) | 878 | void PhoneFormat::todo2GSM( Todo* todo, GSM_ToDoEntry *gsmTodo ) |
876 | { | 879 | { |
877 | #if 0 | 880 | QString tText = vfconverter.todoToString( todo ); |
878 | QStringList list; | 881 | int pos = 0; |
879 | list.append( QString::number( todo->zaurusId() ) ); | 882 | GSM_CalendarEntry dummy; |
880 | list.append( todo->categories().join(",") ); | 883 | GSM_DecodeVCALENDAR_VTODO( (unsigned char*)tText.latin1(), &pos, &dummy, gsmTodo, Nokia_VCalendar, Nokia_VToDo ); |
881 | |||
882 | if ( todo->hasStartDate() ) { | ||
883 | list.append( dtToString( todo->dtStart()) ); | ||
884 | } else | ||
885 | list.append( QString() ); | ||
886 | |||
887 | if ( todo->hasDueDate() ) { | ||
888 | QTime tim; | ||
889 | if ( todo->doesFloat()) { | ||
890 | list.append( dtToString( QDateTime(todo->dtDue().date(),QTime( 0,0,0 )), false)) ; | ||
891 | } else { | ||
892 | list.append( dtToString(todo->dtDue() ) ); | ||
893 | } | ||
894 | } else | ||
895 | list.append( QString() ); | ||
896 | |||
897 | if ( todo->isCompleted() ) { | ||
898 | list.append( dtToString( todo->completed()) ); | ||
899 | list.append( "0" ); // yes 0 == completed | ||
900 | } else { | ||
901 | list.append( dtToString( todo->completed()) ); | ||
902 | list.append( "1" ); | ||
903 | } | ||
904 | list.append( QString::number( todo->priority() )); | ||
905 | if( ! todo->summary().isEmpty() ) | ||
906 | list.append( todo->summary() ); | ||
907 | else | ||
908 | list.append( "" ); | ||
909 | if (! todo->description().isEmpty() ) | ||
910 | list.append( todo->description() ); | ||
911 | else | ||
912 | list.append( "" ); | ||
913 | for(QStringList::Iterator it=list.begin(); | ||
914 | it!=list.end(); ++it){ | ||
915 | QString& s = (*it); | ||
916 | s.replace(QRegExp("\""), "\"\""); | ||
917 | if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){ | ||
918 | s.prepend('\"'); | ||
919 | s.append('\"'); | ||
920 | } else if(s.isEmpty() && !s.isNull()){ | ||
921 | s = "\"\""; | ||
922 | } | ||
923 | } | ||
924 | return list.join(","); | ||
925 | #endif | ||
926 | } | 884 | } |
927 | void PhoneFormat::afterSave( Incidence* inc) | 885 | void PhoneFormat::afterSave( Incidence* inc) |
928 | { | 886 | { |
929 | uint csum; | 887 | uint csum; |
930 | if ( inc->type() == "Event") | 888 | if ( inc->type() == "Event") |
931 | csum = PhoneFormat::getCsumEvent( (Event*) inc ); | 889 | csum = PhoneFormat::getCsumEvent( (Event*) inc ); |
932 | else | 890 | else |
933 | csum = PhoneFormat::getCsumTodo( (Todo*) inc ); | 891 | csum = PhoneFormat::getCsumTodo( (Todo*) inc ); |
934 | inc->setCsum( mProfileName, QString::number( csum )); | 892 | inc->setCsum( mProfileName, QString::number( csum )); |
935 | inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 893 | inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
936 | 894 | ||
937 | } | 895 | } |
938 | bool PhoneFormat::save( Calendar *calendar) | 896 | bool PhoneFormat::save( Calendar *calendar) |
939 | { | 897 | { |
940 | GSM_StateMachines; | 898 | GSM_StateMachines; |
941 | qDebug(" save "); | 899 | qDebug(" save "); |
942 | s.opened = false; | 900 | s.opened = false; |
943 | s.msg = NULL; | 901 | s.msg = NULL; |
944 | s.ConfigNum = 0; | 902 | s.ConfigNum = 0; |
945 | QLabel status ( i18n("Writing data. Opening device ..."), 0 ); | 903 | QLabel status ( i18n("Writing data. Opening device ..."), 0 ); |
946 | int w = status.sizeHint().width()+20 ; | 904 | int w = status.sizeHint().width()+20 ; |
947 | if ( w < 200 ) w = 200; | 905 | if ( w < 200 ) w = 200; |
948 | int h = status.sizeHint().height()+20 ; | 906 | int h = status.sizeHint().height()+20 ; |
949 | int dw = QApplication::desktop()->width(); | 907 | int dw = QApplication::desktop()->width(); |
950 | int dh = QApplication::desktop()->height(); | 908 | int dh = QApplication::desktop()->height(); |
951 | status.setCaption(i18n("Writing Phone Data") ); | 909 | status.setCaption(i18n("Writing Phone Data") ); |
952 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 910 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
953 | status.show(); | 911 | status.show(); |
954 | status.raise(); | 912 | status.raise(); |
955 | qApp->processEvents(); | 913 | qApp->processEvents(); |
956 | 914 | ||
957 | int error=initDevice(&s); | 915 | int error=initDevice(&s); |
958 | qDebug("GSM Init %d (no error is %d)", error, ERR_NONE); | 916 | qDebug("GSM Init %d (no error is %d)", error, ERR_NONE); |
959 | if ( error != ERR_NONE ) | 917 | if ( error != ERR_NONE ) |
960 | return false; | 918 | return false; |
961 | GSM_Phone_Functions*Phone; | 919 | GSM_Phone_Functions*Phone; |
962 | GSM_CalendarEntryNote; | 920 | GSM_CalendarEntryNote; |
963 | bool start = true; | 921 | bool start = true; |
964 | Phone=s.Phone.Functions; | 922 | Phone=s.Phone.Functions; |
965 | bool gshutdown = false; | 923 | bool gshutdown = false; |
966 | QPtrList<Event> er = calendar->rawEvents(); | 924 | QPtrList<Event> er = calendar->rawEvents(); |
967 | Event* ev = er.first(); | 925 | Event* ev = er.first(); |
968 | QString message = i18n("Processing event # "); | 926 | QString message = i18n("Processing event # "); |
969 | int procCount = 0; | 927 | int procCount = 0; |
970 | while ( ev ) { | 928 | while ( ev ) { |
971 | //qDebug("i %d ", ++i); | 929 | //qDebug("i %d ", ++i); |
972 | if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { // event was changed during sync or is a new one | 930 | if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { // event was changed during sync or is a new one |
973 | 931 | ||
974 | status.setText ( message + QString::number ( ++procCount ) ); | 932 | status.setText ( message + QString::number ( ++procCount ) ); |
975 | qApp->processEvents(); | 933 | qApp->processEvents(); |
976 | event2GSM( ev, &Note ); | 934 | event2GSM( ev, &Note ); |
977 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete | 935 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete |
978 | error = Phone->DeleteCalendar(&s, &Note); | 936 | error = Phone->DeleteCalendar(&s, &Note); |
979 | } | 937 | } |
980 | else if ( ev->getID(mProfileName).isEmpty() ) { // add new | 938 | else if ( ev->getID(mProfileName).isEmpty() ) { // add new |
981 | // we have to do this later after deleting | 939 | // we have to do this later after deleting |
982 | 940 | ||
983 | } | 941 | } |
984 | else { // change existing | 942 | else { // change existing |
985 | error = Phone->SetCalendar(&s, &Note); | 943 | error = Phone->SetCalendar(&s, &Note); |
986 | } | 944 | } |
987 | } | 945 | } |
988 | ev = er.next(); | 946 | ev = er.next(); |
989 | } | 947 | } |
990 | ev = er.first(); | 948 | ev = er.first(); |
991 | // pending get empty slots | 949 | // pending get empty slots |
992 | while ( ev ) { | 950 | while ( ev ) { |
993 | if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && ev->tempSyncStat() != SYNC_TEMPSTATE_DELETE) { | 951 | if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && ev->tempSyncStat() != SYNC_TEMPSTATE_DELETE) { |
994 | if ( ev->getID(mProfileName).isEmpty() ) { | 952 | if ( ev->getID(mProfileName).isEmpty() ) { |
995 | status.setText ( message + QString::number ( ++procCount ) ); | 953 | status.setText ( message + QString::number ( ++procCount ) ); |
996 | qApp->processEvents(); | 954 | qApp->processEvents(); |
997 | //int newID ;//= pending | 955 | //int newID ;//= pending |
998 | //ev->setID(mProfileName, QString::number( newID )); | 956 | //ev->setID(mProfileName, QString::number( newID )); |
999 | event2GSM( ev, &Note ); | 957 | event2GSM( ev, &Note ); |
1000 | Note.Location = 0; | 958 | Note.Location = 0; |
1001 | error = Phone->AddCalendar(&s, &Note); | 959 | error = Phone->AddCalendar(&s, &Note); |
1002 | ev->setID( mProfileName, QString::number( Note.Location ) ); | 960 | ev->setID( mProfileName, QString::number( Note.Location ) ); |
1003 | qDebug("New Calendar. Location %d ",Note.Location ); | 961 | qDebug("New Calendar. Location %d ",Note.Location ); |
1004 | afterSave( ev ); | 962 | afterSave( ev ); |
1005 | } else { | 963 | } else { |
1006 | afterSave( ev ); // setting temp sync stat for changed items | 964 | afterSave( ev ); // setting temp sync stat for changed items |
1007 | } | 965 | } |
1008 | } | 966 | } |
1009 | ev = er.next(); | 967 | ev = er.next(); |
1010 | } | 968 | } |
1011 | GSM_ToDoEntry ToDoEntry; | 969 | GSM_ToDoEntry ToDoEntry; |
1012 | QPtrList<Todo> tl = calendar->rawTodos(); | 970 | QPtrList<Todo> tl = calendar->rawTodos(); |
1013 | Todo* to = tl.first(); | 971 | Todo* to = tl.first(); |
1014 | 972 | ||
1015 | message = i18n("Processing todo # "); | 973 | message = i18n("Processing todo # "); |
1016 | procCount = 0; | 974 | procCount = 0; |
1017 | while ( to ) { | 975 | while ( to ) { |
1018 | if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { | 976 | if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { |
1019 | status.setText ( message + QString::number ( ++procCount ) ); | 977 | status.setText ( message + QString::number ( ++procCount ) ); |
1020 | qApp->processEvents(); | 978 | qApp->processEvents(); |
1021 | todo2GSM( to, &ToDoEntry ); | 979 | todo2GSM( to, &ToDoEntry ); |
1022 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete | 980 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete |
1023 | error=Phone->DeleteToDo(&s,&ToDoEntry); | 981 | error=Phone->DeleteToDo(&s,&ToDoEntry); |
1024 | } | 982 | } |
1025 | else if ( to->getID("Sharp_DTM").isEmpty() ) { // add new | 983 | else if ( to->getID("Sharp_DTM").isEmpty() ) { // add new |
1026 | ; | 984 | ; |
1027 | } | 985 | } |
1028 | else { // change existing | 986 | else { // change existing |
1029 | error=Phone->SetToDo(&s,&ToDoEntry); | 987 | error=Phone->SetToDo(&s,&ToDoEntry); |
1030 | } | 988 | } |
1031 | } | 989 | } |
1032 | to = tl.next(); | 990 | to = tl.next(); |
1033 | } | 991 | } |
1034 | 992 | ||
1035 | // pending get empty slots | 993 | // pending get empty slots |
1036 | to = tl.first(); | 994 | to = tl.first(); |
1037 | while ( to ) { | 995 | while ( to ) { |
1038 | if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && to->tempSyncStat() != SYNC_TEMPSTATE_DELETE) { | 996 | if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && to->tempSyncStat() != SYNC_TEMPSTATE_DELETE) { |
1039 | if ( to->getID(mProfileName).isEmpty() ) { | 997 | if ( to->getID(mProfileName).isEmpty() ) { |
1040 | status.setText ( message + QString::number ( ++procCount ) ); | 998 | status.setText ( message + QString::number ( ++procCount ) ); |
1041 | qApp->processEvents(); | 999 | qApp->processEvents(); |
1042 | //int newID ;//= pending | 1000 | //int newID ;//= pending |
1043 | //to->setID(mProfileName, QString::number( newID )); | 1001 | //to->setID(mProfileName, QString::number( newID )); |
1044 | todo2GSM( to, &ToDoEntry ); | 1002 | todo2GSM( to, &ToDoEntry ); |
1045 | ToDoEntry.Location = 0; | 1003 | ToDoEntry.Location = 0; |
1046 | error=Phone->AddToDo(&s,&ToDoEntry); | 1004 | error=Phone->AddToDo(&s,&ToDoEntry); |
1047 | to->setID(mProfileName, QString::number( ToDoEntry.Location )); | 1005 | to->setID(mProfileName, QString::number( ToDoEntry.Location )); |
1048 | afterSave( to ); | 1006 | afterSave( to ); |
1049 | qDebug("New Todo. Location %d ",ToDoEntry.Location ); | 1007 | qDebug("New Todo. Location %d ",ToDoEntry.Location ); |
1050 | } else { | 1008 | } else { |
1051 | afterSave( to ); | 1009 | afterSave( to ); |
1052 | } | 1010 | } |
1053 | } | 1011 | } |
1054 | to = tl.next(); | 1012 | to = tl.next(); |
1055 | } | 1013 | } |
1056 | return true; | 1014 | return true; |
1057 | } | 1015 | } |
1058 | QString PhoneFormat::dtToGSM( const QDateTime& dti, bool useTZ ) | 1016 | QString PhoneFormat::dtToGSM( const QDateTime& dti, bool useTZ ) |
1059 | { | 1017 | { |
1060 | QString datestr; | 1018 | QString datestr; |
1061 | QString timestr; | 1019 | QString timestr; |
1062 | int offset = KGlobal::locale()->localTimeOffset( dti ); | 1020 | int offset = KGlobal::locale()->localTimeOffset( dti ); |
1063 | QDateTime dt; | 1021 | QDateTime dt; |
1064 | if (useTZ) | 1022 | if (useTZ) |
1065 | dt = dti.addSecs ( -(offset*60)); | 1023 | dt = dti.addSecs ( -(offset*60)); |
1066 | else | 1024 | else |
1067 | dt = dti; | 1025 | dt = dti; |
1068 | if(dt.date().isValid()){ | 1026 | if(dt.date().isValid()){ |
1069 | const QDate& date = dt.date(); | 1027 | const QDate& date = dt.date(); |
1070 | datestr.sprintf("%04d%02d%02d", | 1028 | datestr.sprintf("%04d%02d%02d", |
1071 | date.year(), date.month(), date.day()); | 1029 | date.year(), date.month(), date.day()); |
1072 | } | 1030 | } |
1073 | if(dt.time().isValid()){ | 1031 | if(dt.time().isValid()){ |
1074 | const QTime& time = dt.time(); | 1032 | const QTime& time = dt.time(); |
1075 | timestr.sprintf("T%02d%02d%02d", | 1033 | timestr.sprintf("T%02d%02d%02d", |
1076 | time.hour(), time.minute(), time.second()); | 1034 | time.hour(), time.minute(), time.second()); |
1077 | } | 1035 | } |
1078 | return datestr + timestr; | 1036 | return datestr + timestr; |
1079 | } | 1037 | } |
1080 | QString PhoneFormat::getEventString( Event* event ) | 1038 | QString PhoneFormat::getEventString( Event* event ) |
1081 | { | 1039 | { |
1082 | #if 0 | 1040 | #if 0 |
1083 | QStringList list; | 1041 | QStringList list; |
1084 | list.append( QString::number(event->zaurusId() ) ); | 1042 | list.append( QString::number(event->zaurusId() ) ); |
1085 | list.append( event->categories().join(",") ); | 1043 | list.append( event->categories().join(",") ); |
1086 | if ( !event->summary().isEmpty() ) | 1044 | if ( !event->summary().isEmpty() ) |
1087 | list.append( event->summary() ); | 1045 | list.append( event->summary() ); |
1088 | else | 1046 | else |
1089 | list.append("" ); | 1047 | list.append("" ); |
1090 | if ( !event->location().isEmpty() ) | 1048 | if ( !event->location().isEmpty() ) |
1091 | list.append( event->location() ); | 1049 | list.append( event->location() ); |
1092 | else | 1050 | else |
1093 | list.append("" ); | 1051 | list.append("" ); |
1094 | if ( !event->description().isEmpty() ) | 1052 | if ( !event->description().isEmpty() ) |
1095 | list.append( event->description() ); | 1053 | list.append( event->description() ); |
1096 | else | 1054 | else |
1097 | list.append( "" ); | 1055 | list.append( "" ); |
1098 | if ( event->doesFloat () ) { | 1056 | if ( event->doesFloat () ) { |
1099 | list.append( dtToString( QDateTime(event->dtStart().date(), QTime(0,0,0)), false )); | 1057 | list.append( dtToString( QDateTime(event->dtStart().date(), QTime(0,0,0)), false )); |
1100 | list.append( dtToString( QDateTime(event->dtEnd().date(),QTime(23,59,59)), false )); //6 | 1058 | list.append( dtToString( QDateTime(event->dtEnd().date(),QTime(23,59,59)), false )); //6 |
1101 | list.append( "1" ); | 1059 | list.append( "1" ); |
1102 | 1060 | ||
1103 | } | 1061 | } |
1104 | else { | 1062 | else { |
1105 | list.append( dtToString( event->dtStart()) ); | 1063 | list.append( dtToString( event->dtStart()) ); |
1106 | list.append( dtToString( event->dtEnd()) ); //6 | 1064 | list.append( dtToString( event->dtEnd()) ); //6 |
1107 | list.append( "0" ); | 1065 | list.append( "0" ); |
1108 | } | 1066 | } |
1109 | bool noAlarm = true; | 1067 | bool noAlarm = true; |
1110 | if ( event->alarms().count() > 0 ) { | 1068 | if ( event->alarms().count() > 0 ) { |
1111 | Alarm * al = event->alarms().first(); | 1069 | Alarm * al = event->alarms().first(); |
1112 | if ( al->enabled() ) { | 1070 | if ( al->enabled() ) { |
1113 | noAlarm = false; | 1071 | noAlarm = false; |
1114 | list.append( "0" ); // yes, 0 == alarm | 1072 | list.append( "0" ); // yes, 0 == alarm |
1115 | list.append( QString::number( al->startOffset().asSeconds()/(-60) ) ); | 1073 | list.append( QString::number( al->startOffset().asSeconds()/(-60) ) ); |
1116 | if ( al->type() == Alarm::Audio ) | 1074 | if ( al->type() == Alarm::Audio ) |
1117 | list.append( "1" ); // type audio | 1075 | list.append( "1" ); // type audio |
1118 | else | 1076 | else |
1119 | list.append( "0" ); // type silent | 1077 | list.append( "0" ); // type silent |
1120 | } | 1078 | } |
1121 | } | 1079 | } |
1122 | if ( noAlarm ) { | 1080 | if ( noAlarm ) { |
1123 | list.append( "1" ); // yes, 1 == no alarm | 1081 | list.append( "1" ); // yes, 1 == no alarm |
1124 | list.append( "0" ); // no alarm offset | 1082 | list.append( "0" ); // no alarm offset |
1125 | list.append( "1" ); // type | 1083 | list.append( "1" ); // type |
1126 | } | 1084 | } |
1127 | // next is: 11 | 1085 | // next is: 11 |
1128 | // next is: 11-16 are recurrence | 1086 | // next is: 11-16 are recurrence |
1129 | Recurrence* rec = event->recurrence(); | 1087 | Recurrence* rec = event->recurrence(); |
1130 | 1088 | ||
1131 | bool writeEndDate = false; | 1089 | bool writeEndDate = false; |
1132 | switch ( rec->doesRecur() ) | 1090 | switch ( rec->doesRecur() ) |
1133 | { | 1091 | { |
1134 | case Recurrence::rDaily: // 0 | 1092 | case Recurrence::rDaily: // 0 |
1135 | list.append( "0" ); | 1093 | list.append( "0" ); |
1136 | list.append( QString::number( rec->frequency() ));//12 | 1094 | list.append( QString::number( rec->frequency() ));//12 |
1137 | list.append( "0" ); | 1095 | list.append( "0" ); |
1138 | list.append( "0" ); | 1096 | list.append( "0" ); |
1139 | writeEndDate = true; | 1097 | writeEndDate = true; |
1140 | break; | 1098 | break; |
1141 | case Recurrence::rWeekly:// 1 | 1099 | case Recurrence::rWeekly:// 1 |
1142 | list.append( "1" ); | 1100 | list.append( "1" ); |
1143 | list.append( QString::number( rec->frequency()) );//12 | 1101 | list.append( QString::number( rec->frequency()) );//12 |
1144 | list.append( "0" ); | 1102 | list.append( "0" ); |
1145 | { | 1103 | { |
1146 | int days = 0; | 1104 | int days = 0; |
1147 | QBitArray weekDays = rec->days(); | 1105 | QBitArray weekDays = rec->days(); |
1148 | int i; | 1106 | int i; |
1149 | for( i = 1; i <= 7; ++i ) { | 1107 | for( i = 1; i <= 7; ++i ) { |
1150 | if ( weekDays[i-1] ) { | 1108 | if ( weekDays[i-1] ) { |
1151 | days += 1 << (i-1); | 1109 | days += 1 << (i-1); |
1152 | } | 1110 | } |
1153 | } | 1111 | } |
1154 | list.append( QString::number( days ) ); | 1112 | list.append( QString::number( days ) ); |
1155 | } | 1113 | } |
1156 | //pending weekdays | 1114 | //pending weekdays |
1157 | writeEndDate = true; | 1115 | writeEndDate = true; |
1158 | 1116 | ||
1159 | break; | 1117 | break; |
1160 | case Recurrence::rMonthlyPos:// 2 | 1118 | case Recurrence::rMonthlyPos:// 2 |
1161 | list.append( "2" ); | 1119 | list.append( "2" ); |
1162 | list.append( QString::number( rec->frequency()) );//12 | 1120 | list.append( QString::number( rec->frequency()) );//12 |
1163 | 1121 | ||
1164 | writeEndDate = true; | 1122 | writeEndDate = true; |
1165 | { | 1123 | { |
1166 | int count = 1; | 1124 | int count = 1; |
1167 | QPtrList<Recurrence::rMonthPos> rmp; | 1125 | QPtrList<Recurrence::rMonthPos> rmp; |
1168 | rmp = rec->monthPositions(); | 1126 | rmp = rec->monthPositions(); |
1169 | if ( rmp.first()->negative ) | 1127 | if ( rmp.first()->negative ) |
1170 | count = 5 - rmp.first()->rPos - 1; | 1128 | count = 5 - rmp.first()->rPos - 1; |
1171 | else | 1129 | else |
1172 | count = rmp.first()->rPos - 1; | 1130 | count = rmp.first()->rPos - 1; |
1173 | list.append( QString::number( count ) ); | 1131 | list.append( QString::number( count ) ); |
1174 | 1132 | ||
1175 | } | 1133 | } |
1176 | 1134 | ||
1177 | list.append( "0" ); | 1135 | list.append( "0" ); |
1178 | break; | 1136 | break; |
1179 | case Recurrence::rMonthlyDay:// 3 | 1137 | case Recurrence::rMonthlyDay:// 3 |
1180 | list.append( "3" ); | 1138 | list.append( "3" ); |
1181 | list.append( QString::number( rec->frequency()) );//12 | 1139 | list.append( QString::number( rec->frequency()) );//12 |
diff --git a/libkcal/phoneformat.h b/libkcal/phoneformat.h index 7b7dd04..33b2091 100644 --- a/libkcal/phoneformat.h +++ b/libkcal/phoneformat.h | |||
@@ -1,65 +1,67 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | 3 | ||
4 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | #ifndef PHONEFORMAT_H | 21 | #ifndef PHONEFORMAT_H |
22 | #define PHONEFORMAT_H | 22 | #define PHONEFORMAT_H |
23 | 23 | ||
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | 25 | ||
26 | #include "scheduler.h" | 26 | #include "scheduler.h" |
27 | 27 | ||
28 | #include "vcalformat.h" | ||
28 | #include "calformat.h" | 29 | #include "calformat.h" |
29 | extern "C" { | 30 | extern "C" { |
30 | #include "../gammu/emb/common/gammu.h" | 31 | #include "../gammu/emb/common/gammu.h" |
31 | } | 32 | } |
32 | namespace KCal { | 33 | namespace KCal { |
33 | 34 | ||
34 | /** | 35 | /** |
35 | This class implements the calendar format used by Phone. | 36 | This class implements the calendar format used by Phone. |
36 | */ | 37 | */ |
37 | class Event; | 38 | class Event; |
38 | class Todo; | 39 | class Todo; |
39 | class PhoneFormat : public QObject { | 40 | class PhoneFormat : public QObject { |
40 | public: | 41 | public: |
41 | /** Create new iCalendar format. */ | 42 | /** Create new iCalendar format. */ |
42 | PhoneFormat(QString profileName, QString device,QString connection, QString model); | 43 | PhoneFormat(QString profileName, QString device,QString connection, QString model); |
43 | virtual ~PhoneFormat(); | 44 | virtual ~PhoneFormat(); |
44 | 45 | ||
45 | bool load( Calendar * ,Calendar * ); | 46 | bool load( Calendar * ,Calendar * ); |
46 | bool save( Calendar * ); | 47 | bool save( Calendar * ); |
47 | bool fromString( Calendar *, const QString & ); | 48 | bool fromString( Calendar *, const QString & ); |
48 | QString toString( Calendar * ); | 49 | QString toString( Calendar * ); |
49 | static ulong getCsum( const QStringList & ); | 50 | static ulong getCsum( const QStringList & ); |
50 | static ulong getCsumTodo( Todo* to ); | 51 | static ulong getCsumTodo( Todo* to ); |
51 | static ulong getCsumEvent( Event* ev ); | 52 | static ulong getCsumEvent( Event* ev ); |
52 | private: | 53 | private: |
54 | VCalFormat vfconverter; | ||
53 | void event2GSM( Event* ev, GSM_CalendarEntry*Note ); | 55 | void event2GSM( Event* ev, GSM_CalendarEntry*Note ); |
54 | void todo2GSM( Todo* ev, GSM_ToDoEntry *ToDo ); | 56 | void todo2GSM( Todo* ev, GSM_ToDoEntry *ToDo ); |
55 | int initDevice(GSM_StateMachine *s); | 57 | int initDevice(GSM_StateMachine *s); |
56 | QString getEventString( Event* ); | 58 | QString getEventString( Event* ); |
57 | QString getTodoString( Todo* ); | 59 | QString getTodoString( Todo* ); |
58 | QString dtToGSM( const QDateTime& dt, bool useTZ = true ); | 60 | QString dtToGSM( const QDateTime& dt, bool useTZ = true ); |
59 | QString mProfileName, mDevice, mConnection, mModel; | 61 | QString mProfileName, mDevice, mConnection, mModel; |
60 | void afterSave( Incidence* ); | 62 | void afterSave( Incidence* ); |
61 | }; | 63 | }; |
62 | 64 | ||
63 | } | 65 | } |
64 | 66 | ||
65 | #endif | 67 | #endif |
diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp index 72a781a..1167e58 100644 --- a/libkcal/vcalformat.cpp +++ b/libkcal/vcalformat.cpp | |||
@@ -1,423 +1,442 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 1998 Preston Brwon | 3 | Copyright (c) 1998 Preston Brwon |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <qapplication.h> | 22 | #include <qapplication.h> |
23 | #include <qdatetime.h> | 23 | #include <qdatetime.h> |
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qptrlist.h> | 25 | #include <qptrlist.h> |
26 | #include <qregexp.h> | 26 | #include <qregexp.h> |
27 | #include <qclipboard.h> | 27 | #include <qclipboard.h> |
28 | #include <qdialog.h> | 28 | #include <qdialog.h> |
29 | #include <qfile.h> | 29 | #include <qfile.h> |
30 | 30 | ||
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include <kmessagebox.h> | 32 | #include <kmessagebox.h> |
33 | #include <kiconloader.h> | 33 | #include <kiconloader.h> |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | 35 | ||
36 | #include "vcc.h" | 36 | #include "vcc.h" |
37 | #include "vobject.h" | 37 | #include "vobject.h" |
38 | 38 | ||
39 | #include "vcaldrag.h" | 39 | #include "vcaldrag.h" |
40 | #include "calendar.h" | 40 | #include "calendar.h" |
41 | 41 | ||
42 | #include "vcalformat.h" | 42 | #include "vcalformat.h" |
43 | 43 | ||
44 | using namespace KCal; | 44 | using namespace KCal; |
45 | 45 | ||
46 | VCalFormat::VCalFormat() | 46 | VCalFormat::VCalFormat() |
47 | { | 47 | { |
48 | } | 48 | } |
49 | 49 | ||
50 | VCalFormat::~VCalFormat() | 50 | VCalFormat::~VCalFormat() |
51 | { | 51 | { |
52 | } | 52 | } |
53 | 53 | ||
54 | bool VCalFormat::load(Calendar *calendar, const QString &fileName) | 54 | bool VCalFormat::load(Calendar *calendar, const QString &fileName) |
55 | { | 55 | { |
56 | mCalendar = calendar; | 56 | mCalendar = calendar; |
57 | 57 | ||
58 | clearException(); | 58 | clearException(); |
59 | 59 | ||
60 | kdDebug(5800) << "VCalFormat::load() " << fileName << endl; | 60 | kdDebug(5800) << "VCalFormat::load() " << fileName << endl; |
61 | 61 | ||
62 | VObject *vcal = 0; | 62 | VObject *vcal = 0; |
63 | 63 | ||
64 | // this is not necessarily only 1 vcal. Could be many vcals, or include | 64 | // this is not necessarily only 1 vcal. Could be many vcals, or include |
65 | // a vcard... | 65 | // a vcard... |
66 | vcal = Parse_MIME_FromFileName(const_cast<char *>(QFile::encodeName(fileName).data())); | 66 | vcal = Parse_MIME_FromFileName(const_cast<char *>(QFile::encodeName(fileName).data())); |
67 | 67 | ||
68 | if (!vcal) { | 68 | if (!vcal) { |
69 | setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); | 69 | setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); |
70 | return FALSE; | 70 | return FALSE; |
71 | } | 71 | } |
72 | 72 | ||
73 | // any other top-level calendar stuff should be added/initialized here | 73 | // any other top-level calendar stuff should be added/initialized here |
74 | 74 | ||
75 | // put all vobjects into their proper places | 75 | // put all vobjects into their proper places |
76 | populate(vcal); | 76 | populate(vcal); |
77 | 77 | ||
78 | // clean up from vcal API stuff | 78 | // clean up from vcal API stuff |
79 | cleanVObjects(vcal); | 79 | cleanVObjects(vcal); |
80 | cleanStrTbl(); | 80 | cleanStrTbl(); |
81 | 81 | ||
82 | return true; | 82 | return true; |
83 | } | 83 | } |
84 | 84 | ||
85 | 85 | ||
86 | bool VCalFormat::save(Calendar *calendar, const QString &fileName) | 86 | bool VCalFormat::save(Calendar *calendar, const QString &fileName) |
87 | { | 87 | { |
88 | mCalendar = calendar; | 88 | mCalendar = calendar; |
89 | 89 | ||
90 | QString tmpStr; | 90 | QString tmpStr; |
91 | VObject *vcal, *vo; | 91 | VObject *vcal, *vo; |
92 | 92 | ||
93 | kdDebug(5800) << "VCalFormat::save(): " << fileName << endl; | 93 | kdDebug(5800) << "VCalFormat::save(): " << fileName << endl; |
94 | 94 | ||
95 | vcal = newVObject(VCCalProp); | 95 | vcal = newVObject(VCCalProp); |
96 | 96 | ||
97 | // addPropValue(vcal,VCLocationProp, "0.0"); | 97 | // addPropValue(vcal,VCLocationProp, "0.0"); |
98 | addPropValue(vcal,VCProdIdProp, productId()); | 98 | addPropValue(vcal,VCProdIdProp, productId()); |
99 | tmpStr = mCalendar->getTimeZoneStr(); | 99 | tmpStr = mCalendar->getTimeZoneStr(); |
100 | //qDebug("mCalendar->getTimeZoneStr() %s",tmpStr.latin1() ); | 100 | //qDebug("mCalendar->getTimeZoneStr() %s",tmpStr.latin1() ); |
101 | addPropValue(vcal,VCTimeZoneProp, tmpStr.local8Bit()); | 101 | addPropValue(vcal,VCTimeZoneProp, tmpStr.local8Bit()); |
102 | addPropValue(vcal,VCVersionProp, _VCAL_VERSION); | 102 | addPropValue(vcal,VCVersionProp, _VCAL_VERSION); |
103 | 103 | ||
104 | // TODO STUFF | 104 | // TODO STUFF |
105 | QPtrList<Todo> todoList = mCalendar->rawTodos(); | 105 | QPtrList<Todo> todoList = mCalendar->rawTodos(); |
106 | QPtrListIterator<Todo> qlt(todoList); | 106 | QPtrListIterator<Todo> qlt(todoList); |
107 | for (; qlt.current(); ++qlt) { | 107 | for (; qlt.current(); ++qlt) { |
108 | vo = eventToVTodo(qlt.current()); | 108 | vo = eventToVTodo(qlt.current()); |
109 | addVObjectProp(vcal, vo); | 109 | addVObjectProp(vcal, vo); |
110 | } | 110 | } |
111 | 111 | ||
112 | // EVENT STUFF | 112 | // EVENT STUFF |
113 | QPtrList<Event> events = mCalendar->rawEvents(); | 113 | QPtrList<Event> events = mCalendar->rawEvents(); |
114 | Event *ev; | 114 | Event *ev; |
115 | for(ev=events.first();ev;ev=events.next()) { | 115 | for(ev=events.first();ev;ev=events.next()) { |
116 | vo = eventToVEvent(ev); | 116 | vo = eventToVEvent(ev); |
117 | addVObjectProp(vcal, vo); | 117 | addVObjectProp(vcal, vo); |
118 | } | 118 | } |
119 | 119 | ||
120 | writeVObjectToFile(QFile::encodeName(fileName).data() ,vcal); | 120 | writeVObjectToFile(QFile::encodeName(fileName).data() ,vcal); |
121 | cleanVObjects(vcal); | 121 | cleanVObjects(vcal); |
122 | cleanStrTbl(); | 122 | cleanStrTbl(); |
123 | 123 | ||
124 | if (QFile::exists(fileName)) { | 124 | if (QFile::exists(fileName)) { |
125 | kdDebug(5800) << "No error" << endl; | 125 | kdDebug(5800) << "No error" << endl; |
126 | return true; | 126 | return true; |
127 | } else { | 127 | } else { |
128 | kdDebug(5800) << "Error" << endl; | 128 | kdDebug(5800) << "Error" << endl; |
129 | return false; // error | 129 | return false; // error |
130 | } | 130 | } |
131 | } | 131 | } |
132 | 132 | ||
133 | bool VCalFormat::fromString( Calendar *calendar, const QString &text ) | 133 | bool VCalFormat::fromString( Calendar *calendar, const QString &text ) |
134 | { | 134 | { |
135 | // TODO: Factor out VCalFormat::fromString() | 135 | // TODO: Factor out VCalFormat::fromString() |
136 | 136 | ||
137 | QCString data = text.utf8(); | 137 | QCString data = text.utf8(); |
138 | 138 | ||
139 | if ( !data.size() ) return false; | 139 | if ( !data.size() ) return false; |
140 | 140 | ||
141 | VObject *vcal = Parse_MIME( data.data(), data.size()); | 141 | VObject *vcal = Parse_MIME( data.data(), data.size()); |
142 | if ( !vcal ) return false; | 142 | if ( !vcal ) return false; |
143 | 143 | ||
144 | VObjectIterator i; | 144 | VObjectIterator i; |
145 | VObject *curvo; | 145 | VObject *curvo; |
146 | initPropIterator( &i, vcal ); | 146 | initPropIterator( &i, vcal ); |
147 | 147 | ||
148 | // we only take the first object. TODO: parse all incidences. | 148 | // we only take the first object. TODO: parse all incidences. |
149 | do { | 149 | do { |
150 | curvo = nextVObject( &i ); | 150 | curvo = nextVObject( &i ); |
151 | } while ( strcmp( vObjectName( curvo ), VCEventProp ) && | 151 | } while ( strcmp( vObjectName( curvo ), VCEventProp ) && |
152 | strcmp( vObjectName( curvo ), VCTodoProp ) ); | 152 | strcmp( vObjectName( curvo ), VCTodoProp ) ); |
153 | 153 | ||
154 | if ( strcmp( vObjectName( curvo ), VCEventProp ) == 0 ) { | 154 | if ( strcmp( vObjectName( curvo ), VCEventProp ) == 0 ) { |
155 | Event *event = VEventToEvent( curvo ); | 155 | Event *event = VEventToEvent( curvo ); |
156 | calendar->addEvent( event ); | 156 | calendar->addEvent( event ); |
157 | } else { | 157 | } else { |
158 | kdDebug(5800) << "VCalFormat::fromString(): Unknown object type." << endl; | 158 | kdDebug(5800) << "VCalFormat::fromString(): Unknown object type." << endl; |
159 | deleteVObject( vcal ); | 159 | deleteVObject( vcal ); |
160 | return false; | 160 | return false; |
161 | } | 161 | } |
162 | 162 | ||
163 | deleteVObject( vcal ); | 163 | deleteVObject( vcal ); |
164 | 164 | ||
165 | return true; | 165 | return true; |
166 | } | 166 | } |
167 | 167 | ||
168 | QString VCalFormat::eventToString( Event * event) | ||
169 | { | ||
170 | if ( !event ) return QString::null; | ||
171 | VObject *vevent = eventToVEvent( event ); | ||
172 | char *buf = writeMemVObject( 0, 0, vevent ); | ||
173 | QString result( buf ); | ||
174 | cleanVObject( vevent ); | ||
175 | return result; | ||
176 | } | ||
177 | QString VCalFormat::todoToString( Todo * todo ) | ||
178 | { | ||
179 | if ( !todo ) return QString::null; | ||
180 | VObject *vevent = eventToVTodo( todo ); | ||
181 | char *buf = writeMemVObject( 0, 0, vevent ); | ||
182 | QString result( buf ); | ||
183 | cleanVObject( vevent ); | ||
184 | return result; | ||
185 | } | ||
186 | |||
168 | QString VCalFormat::toString( Calendar *calendar ) | 187 | QString VCalFormat::toString( Calendar *calendar ) |
169 | { | 188 | { |
170 | // TODO: Factor out VCalFormat::asString() | 189 | // TODO: Factor out VCalFormat::asString() |
171 | 190 | ||
172 | VObject *vcal = newVObject(VCCalProp); | 191 | VObject *vcal = newVObject(VCCalProp); |
173 | 192 | ||
174 | addPropValue( vcal, VCProdIdProp, CalFormat::productId() ); | 193 | addPropValue( vcal, VCProdIdProp, CalFormat::productId() ); |
175 | QString tmpStr = mCalendar->getTimeZoneStr(); | 194 | QString tmpStr = mCalendar->getTimeZoneStr(); |
176 | addPropValue( vcal, VCTimeZoneProp, tmpStr.local8Bit() ); | 195 | addPropValue( vcal, VCTimeZoneProp, tmpStr.local8Bit() ); |
177 | addPropValue( vcal, VCVersionProp, _VCAL_VERSION ); | 196 | addPropValue( vcal, VCVersionProp, _VCAL_VERSION ); |
178 | 197 | ||
179 | // TODO: Use all data. | 198 | // TODO: Use all data. |
180 | QPtrList<Event> events = calendar->events(); | 199 | QPtrList<Event> events = calendar->events(); |
181 | Event *event = events.first(); | 200 | Event *event = events.first(); |
182 | if ( !event ) return QString::null; | 201 | if ( !event ) return QString::null; |
183 | 202 | ||
184 | VObject *vevent = eventToVEvent( event ); | 203 | VObject *vevent = eventToVEvent( event ); |
185 | 204 | ||
186 | addVObjectProp( vcal, vevent ); | 205 | addVObjectProp( vcal, vevent ); |
187 | 206 | ||
188 | char *buf = writeMemVObject( 0, 0, vcal ); | 207 | char *buf = writeMemVObject( 0, 0, vcal ); |
189 | 208 | ||
190 | QString result( buf ); | 209 | QString result( buf ); |
191 | 210 | ||
192 | cleanVObject( vcal ); | 211 | cleanVObject( vcal ); |
193 | 212 | ||
194 | return result; | 213 | return result; |
195 | } | 214 | } |
196 | 215 | ||
197 | VObject *VCalFormat::eventToVTodo(const Todo *anEvent) | 216 | VObject *VCalFormat::eventToVTodo(const Todo *anEvent) |
198 | { | 217 | { |
199 | VObject *vtodo; | 218 | VObject *vtodo; |
200 | QString tmpStr; | 219 | QString tmpStr; |
201 | QStringList tmpStrList; | 220 | QStringList tmpStrList; |
202 | 221 | ||
203 | vtodo = newVObject(VCTodoProp); | 222 | vtodo = newVObject(VCTodoProp); |
204 | 223 | ||
205 | // due date | 224 | // due date |
206 | if (anEvent->hasDueDate()) { | 225 | if (anEvent->hasDueDate()) { |
207 | tmpStr = qDateTimeToISO(anEvent->dtDue(), | 226 | tmpStr = qDateTimeToISO(anEvent->dtDue(), |
208 | !anEvent->doesFloat()); | 227 | !anEvent->doesFloat()); |
209 | addPropValue(vtodo, VCDueProp, tmpStr.local8Bit()); | 228 | addPropValue(vtodo, VCDueProp, tmpStr.local8Bit()); |
210 | } | 229 | } |
211 | 230 | ||
212 | // start date | 231 | // start date |
213 | if (anEvent->hasStartDate()) { | 232 | if (anEvent->hasStartDate()) { |
214 | tmpStr = qDateTimeToISO(anEvent->dtStart(), | 233 | tmpStr = qDateTimeToISO(anEvent->dtStart(), |
215 | !anEvent->doesFloat()); | 234 | !anEvent->doesFloat()); |
216 | addPropValue(vtodo, VCDTstartProp, tmpStr.local8Bit()); | 235 | addPropValue(vtodo, VCDTstartProp, tmpStr.local8Bit()); |
217 | } | 236 | } |
218 | 237 | ||
219 | // creation date | 238 | // creation date |
220 | tmpStr = qDateTimeToISO(anEvent->created()); | 239 | tmpStr = qDateTimeToISO(anEvent->created()); |
221 | addPropValue(vtodo, VCDCreatedProp, tmpStr.local8Bit()); | 240 | addPropValue(vtodo, VCDCreatedProp, tmpStr.local8Bit()); |
222 | 241 | ||
223 | // unique id | 242 | // unique id |
224 | addPropValue(vtodo, VCUniqueStringProp, | 243 | addPropValue(vtodo, VCUniqueStringProp, |
225 | anEvent->uid().local8Bit()); | 244 | anEvent->uid().local8Bit()); |
226 | 245 | ||
227 | // revision | 246 | // revision |
228 | tmpStr.sprintf("%i", anEvent->revision()); | 247 | tmpStr.sprintf("%i", anEvent->revision()); |
229 | addPropValue(vtodo, VCSequenceProp, tmpStr.local8Bit()); | 248 | addPropValue(vtodo, VCSequenceProp, tmpStr.local8Bit()); |
230 | 249 | ||
231 | // last modification date | 250 | // last modification date |
232 | tmpStr = qDateTimeToISO(anEvent->lastModified()); | 251 | tmpStr = qDateTimeToISO(anEvent->lastModified()); |
233 | addPropValue(vtodo, VCLastModifiedProp, tmpStr.local8Bit()); | 252 | addPropValue(vtodo, VCLastModifiedProp, tmpStr.local8Bit()); |
234 | 253 | ||
235 | // organizer stuff | 254 | // organizer stuff |
236 | tmpStr = "MAILTO:" + anEvent->organizer(); | 255 | tmpStr = "MAILTO:" + anEvent->organizer(); |
237 | addPropValue(vtodo, ICOrganizerProp, tmpStr.local8Bit()); | 256 | addPropValue(vtodo, ICOrganizerProp, tmpStr.local8Bit()); |
238 | 257 | ||
239 | // attendees | 258 | // attendees |
240 | if (anEvent->attendeeCount() != 0) { | 259 | if (anEvent->attendeeCount() != 0) { |
241 | QPtrList<Attendee> al = anEvent->attendees(); | 260 | QPtrList<Attendee> al = anEvent->attendees(); |
242 | QPtrListIterator<Attendee> ai(al); | 261 | QPtrListIterator<Attendee> ai(al); |
243 | Attendee *curAttendee; | 262 | Attendee *curAttendee; |
244 | 263 | ||
245 | for (; ai.current(); ++ai) { | 264 | for (; ai.current(); ++ai) { |
246 | curAttendee = ai.current(); | 265 | curAttendee = ai.current(); |
247 | if (!curAttendee->email().isEmpty() && | 266 | if (!curAttendee->email().isEmpty() && |
248 | !curAttendee->name().isEmpty()) | 267 | !curAttendee->name().isEmpty()) |
249 | tmpStr = "MAILTO:" + curAttendee->name() + " <" + | 268 | tmpStr = "MAILTO:" + curAttendee->name() + " <" + |
250 | curAttendee->email() + ">"; | 269 | curAttendee->email() + ">"; |
251 | else if (curAttendee->name().isEmpty()) | 270 | else if (curAttendee->name().isEmpty()) |
252 | tmpStr = "MAILTO: " + curAttendee->email(); | 271 | tmpStr = "MAILTO: " + curAttendee->email(); |
253 | else if (curAttendee->email().isEmpty()) | 272 | else if (curAttendee->email().isEmpty()) |
254 | tmpStr = "MAILTO: " + curAttendee->name(); | 273 | tmpStr = "MAILTO: " + curAttendee->name(); |
255 | else if (curAttendee->name().isEmpty() && | 274 | else if (curAttendee->name().isEmpty() && |
256 | curAttendee->email().isEmpty()) | 275 | curAttendee->email().isEmpty()) |
257 | kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl; | 276 | kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl; |
258 | VObject *aProp = addPropValue(vtodo, VCAttendeeProp, tmpStr.local8Bit()); | 277 | VObject *aProp = addPropValue(vtodo, VCAttendeeProp, tmpStr.local8Bit()); |
259 | addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE"); | 278 | addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE"); |
260 | addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); | 279 | addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); |
261 | } | 280 | } |
262 | } | 281 | } |
263 | 282 | ||
264 | // description BL: | 283 | // description BL: |
265 | if (!anEvent->description().isEmpty()) { | 284 | if (!anEvent->description().isEmpty()) { |
266 | VObject *d = addPropValue(vtodo, VCDescriptionProp, | 285 | VObject *d = addPropValue(vtodo, VCDescriptionProp, |
267 | anEvent->description().local8Bit()); | 286 | anEvent->description().local8Bit()); |
268 | if (anEvent->description().find('\n') != -1) | 287 | if (anEvent->description().find('\n') != -1) |
269 | addProp(d, VCQuotedPrintableProp); | 288 | addProp(d, VCQuotedPrintableProp); |
270 | } | 289 | } |
271 | 290 | ||
272 | // summary | 291 | // summary |
273 | if (!anEvent->summary().isEmpty()) | 292 | if (!anEvent->summary().isEmpty()) |
274 | addPropValue(vtodo, VCSummaryProp, anEvent->summary().local8Bit()); | 293 | addPropValue(vtodo, VCSummaryProp, anEvent->summary().local8Bit()); |
275 | 294 | ||
276 | if (!anEvent->location().isEmpty()) | 295 | if (!anEvent->location().isEmpty()) |
277 | addPropValue(vtodo, VCLocationProp, anEvent->location().local8Bit()); | 296 | addPropValue(vtodo, VCLocationProp, anEvent->location().local8Bit()); |
278 | 297 | ||
279 | // completed | 298 | // completed |
280 | // status | 299 | // status |
281 | // backward compatibility, KOrganizer used to interpret only these two values | 300 | // backward compatibility, KOrganizer used to interpret only these two values |
282 | addPropValue(vtodo, VCStatusProp, anEvent->isCompleted() ? "COMPLETED" : | 301 | addPropValue(vtodo, VCStatusProp, anEvent->isCompleted() ? "COMPLETED" : |
283 | "NEEDS_ACTION"); | 302 | "NEEDS_ACTION"); |
284 | // completion date | 303 | // completion date |
285 | if (anEvent->hasCompletedDate()) { | 304 | if (anEvent->hasCompletedDate()) { |
286 | tmpStr = qDateTimeToISO(anEvent->completed()); | 305 | tmpStr = qDateTimeToISO(anEvent->completed()); |
287 | addPropValue(vtodo, VCCompletedProp, tmpStr.local8Bit()); | 306 | addPropValue(vtodo, VCCompletedProp, tmpStr.local8Bit()); |
288 | } | 307 | } |
289 | 308 | ||
290 | // priority | 309 | // priority |
291 | tmpStr.sprintf("%i",anEvent->priority()); | 310 | tmpStr.sprintf("%i",anEvent->priority()); |
292 | addPropValue(vtodo, VCPriorityProp, tmpStr.local8Bit()); | 311 | addPropValue(vtodo, VCPriorityProp, tmpStr.local8Bit()); |
293 | 312 | ||
294 | // related event | 313 | // related event |
295 | if (anEvent->relatedTo()) { | 314 | if (anEvent->relatedTo()) { |
296 | addPropValue(vtodo, VCRelatedToProp, | 315 | addPropValue(vtodo, VCRelatedToProp, |
297 | anEvent->relatedTo()->uid().local8Bit()); | 316 | anEvent->relatedTo()->uid().local8Bit()); |
298 | } | 317 | } |
299 | 318 | ||
300 | // categories | 319 | // categories |
301 | tmpStrList = anEvent->categories(); | 320 | tmpStrList = anEvent->categories(); |
302 | tmpStr = ""; | 321 | tmpStr = ""; |
303 | QString catStr; | 322 | QString catStr; |
304 | for ( QStringList::Iterator it = tmpStrList.begin(); | 323 | for ( QStringList::Iterator it = tmpStrList.begin(); |
305 | it != tmpStrList.end(); | 324 | it != tmpStrList.end(); |
306 | ++it ) { | 325 | ++it ) { |
307 | catStr = *it; | 326 | catStr = *it; |
308 | if (catStr[0] == ' ') | 327 | if (catStr[0] == ' ') |
309 | tmpStr += catStr.mid(1); | 328 | tmpStr += catStr.mid(1); |
310 | else | 329 | else |
311 | tmpStr += catStr; | 330 | tmpStr += catStr; |
312 | // this must be a ';' character as the vCalendar specification requires! | 331 | // this must be a ';' character as the vCalendar specification requires! |
313 | // vcc.y has been hacked to translate the ';' to a ',' when the vcal is | 332 | // vcc.y has been hacked to translate the ';' to a ',' when the vcal is |
314 | // read in. | 333 | // read in. |
315 | tmpStr += ";"; | 334 | tmpStr += ";"; |
316 | } | 335 | } |
317 | if (!tmpStr.isEmpty()) { | 336 | if (!tmpStr.isEmpty()) { |
318 | tmpStr.truncate(tmpStr.length()-1); | 337 | tmpStr.truncate(tmpStr.length()-1); |
319 | addPropValue(vtodo, VCCategoriesProp, tmpStr.local8Bit()); | 338 | addPropValue(vtodo, VCCategoriesProp, tmpStr.local8Bit()); |
320 | } | 339 | } |
321 | 340 | ||
322 | // alarm stuff | 341 | // alarm stuff |
323 | kdDebug(5800) << "vcalformat::eventToVTodo was called" << endl; | 342 | kdDebug(5800) << "vcalformat::eventToVTodo was called" << endl; |
324 | QPtrList<Alarm> alarms = anEvent->alarms(); | 343 | QPtrList<Alarm> alarms = anEvent->alarms(); |
325 | Alarm* alarm; | 344 | Alarm* alarm; |
326 | for (alarm = alarms.first(); alarm; alarm = alarms.next()) { | 345 | for (alarm = alarms.first(); alarm; alarm = alarms.next()) { |
327 | if (alarm->enabled()) { | 346 | if (alarm->enabled()) { |
328 | VObject *a = addProp(vtodo, VCDAlarmProp); | 347 | VObject *a = addProp(vtodo, VCDAlarmProp); |
329 | tmpStr = qDateTimeToISO(alarm->time()); | 348 | tmpStr = qDateTimeToISO(alarm->time()); |
330 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 349 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
331 | addPropValue(a, VCRepeatCountProp, "1"); | 350 | addPropValue(a, VCRepeatCountProp, "1"); |
332 | addPropValue(a, VCDisplayStringProp, "beep!"); | 351 | addPropValue(a, VCDisplayStringProp, "beep!"); |
333 | if (alarm->type() == Alarm::Audio) { | 352 | if (alarm->type() == Alarm::Audio) { |
334 | a = addProp(vtodo, VCAAlarmProp); | 353 | a = addProp(vtodo, VCAAlarmProp); |
335 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 354 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
336 | addPropValue(a, VCRepeatCountProp, "1"); | 355 | addPropValue(a, VCRepeatCountProp, "1"); |
337 | addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); | 356 | addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); |
338 | } | 357 | } |
339 | else if (alarm->type() == Alarm::Procedure) { | 358 | else if (alarm->type() == Alarm::Procedure) { |
340 | a = addProp(vtodo, VCPAlarmProp); | 359 | a = addProp(vtodo, VCPAlarmProp); |
341 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 360 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
342 | addPropValue(a, VCRepeatCountProp, "1"); | 361 | addPropValue(a, VCRepeatCountProp, "1"); |
343 | addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); | 362 | addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); |
344 | } | 363 | } |
345 | } | 364 | } |
346 | } | 365 | } |
347 | 366 | ||
348 | if (anEvent->pilotId()) { | 367 | if (anEvent->pilotId()) { |
349 | // pilot sync stuff | 368 | // pilot sync stuff |
350 | tmpStr.sprintf("%i",anEvent->pilotId()); | 369 | tmpStr.sprintf("%i",anEvent->pilotId()); |
351 | addPropValue(vtodo, XPilotIdProp, tmpStr.local8Bit()); | 370 | addPropValue(vtodo, XPilotIdProp, tmpStr.local8Bit()); |
352 | tmpStr.sprintf("%i",anEvent->syncStatus()); | 371 | tmpStr.sprintf("%i",anEvent->syncStatus()); |
353 | addPropValue(vtodo, XPilotStatusProp, tmpStr.local8Bit()); | 372 | addPropValue(vtodo, XPilotStatusProp, tmpStr.local8Bit()); |
354 | } | 373 | } |
355 | 374 | ||
356 | return vtodo; | 375 | return vtodo; |
357 | } | 376 | } |
358 | 377 | ||
359 | VObject* VCalFormat::eventToVEvent(const Event *anEvent) | 378 | VObject* VCalFormat::eventToVEvent(const Event *anEvent) |
360 | { | 379 | { |
361 | VObject *vevent; | 380 | VObject *vevent; |
362 | QString tmpStr; | 381 | QString tmpStr; |
363 | QStringList tmpStrList; | 382 | QStringList tmpStrList; |
364 | 383 | ||
365 | vevent = newVObject(VCEventProp); | 384 | vevent = newVObject(VCEventProp); |
366 | 385 | ||
367 | // start and end time | 386 | // start and end time |
368 | tmpStr = qDateTimeToISO(anEvent->dtStart(), | 387 | tmpStr = qDateTimeToISO(anEvent->dtStart(), |
369 | !anEvent->doesFloat()); | 388 | !anEvent->doesFloat()); |
370 | addPropValue(vevent, VCDTstartProp, tmpStr.local8Bit()); | 389 | addPropValue(vevent, VCDTstartProp, tmpStr.local8Bit()); |
371 | 390 | ||
372 | // events that have time associated but take up no time should | 391 | // events that have time associated but take up no time should |
373 | // not have both DTSTART and DTEND. | 392 | // not have both DTSTART and DTEND. |
374 | if (anEvent->dtStart() != anEvent->dtEnd()) { | 393 | if (anEvent->dtStart() != anEvent->dtEnd()) { |
375 | tmpStr = qDateTimeToISO(anEvent->dtEnd(), | 394 | tmpStr = qDateTimeToISO(anEvent->dtEnd(), |
376 | !anEvent->doesFloat()); | 395 | !anEvent->doesFloat()); |
377 | addPropValue(vevent, VCDTendProp, tmpStr.local8Bit()); | 396 | addPropValue(vevent, VCDTendProp, tmpStr.local8Bit()); |
378 | } | 397 | } |
379 | 398 | ||
380 | // creation date | 399 | // creation date |
381 | tmpStr = qDateTimeToISO(anEvent->created()); | 400 | tmpStr = qDateTimeToISO(anEvent->created()); |
382 | addPropValue(vevent, VCDCreatedProp, tmpStr.local8Bit()); | 401 | addPropValue(vevent, VCDCreatedProp, tmpStr.local8Bit()); |
383 | 402 | ||
384 | // unique id | 403 | // unique id |
385 | addPropValue(vevent, VCUniqueStringProp, | 404 | addPropValue(vevent, VCUniqueStringProp, |
386 | anEvent->uid().local8Bit()); | 405 | anEvent->uid().local8Bit()); |
387 | 406 | ||
388 | // revision | 407 | // revision |
389 | tmpStr.sprintf("%i", anEvent->revision()); | 408 | tmpStr.sprintf("%i", anEvent->revision()); |
390 | addPropValue(vevent, VCSequenceProp, tmpStr.local8Bit()); | 409 | addPropValue(vevent, VCSequenceProp, tmpStr.local8Bit()); |
391 | 410 | ||
392 | // last modification date | 411 | // last modification date |
393 | tmpStr = qDateTimeToISO(anEvent->lastModified()); | 412 | tmpStr = qDateTimeToISO(anEvent->lastModified()); |
394 | addPropValue(vevent, VCLastModifiedProp, tmpStr.local8Bit()); | 413 | addPropValue(vevent, VCLastModifiedProp, tmpStr.local8Bit()); |
395 | 414 | ||
396 | // attendee and organizer stuff | 415 | // attendee and organizer stuff |
397 | tmpStr = "MAILTO:" + anEvent->organizer(); | 416 | tmpStr = "MAILTO:" + anEvent->organizer(); |
398 | addPropValue(vevent, ICOrganizerProp, tmpStr.local8Bit()); | 417 | addPropValue(vevent, ICOrganizerProp, tmpStr.local8Bit()); |
399 | 418 | ||
400 | if (anEvent->attendeeCount() != 0) { | 419 | if (anEvent->attendeeCount() != 0) { |
401 | QPtrList<Attendee> al = anEvent->attendees(); | 420 | QPtrList<Attendee> al = anEvent->attendees(); |
402 | QPtrListIterator<Attendee> ai(al); | 421 | QPtrListIterator<Attendee> ai(al); |
403 | Attendee *curAttendee; | 422 | Attendee *curAttendee; |
404 | 423 | ||
405 | // TODO: Put this functionality into Attendee class | 424 | // TODO: Put this functionality into Attendee class |
406 | for (; ai.current(); ++ai) { | 425 | for (; ai.current(); ++ai) { |
407 | curAttendee = ai.current(); | 426 | curAttendee = ai.current(); |
408 | if (!curAttendee->email().isEmpty() && | 427 | if (!curAttendee->email().isEmpty() && |
409 | !curAttendee->name().isEmpty()) | 428 | !curAttendee->name().isEmpty()) |
410 | tmpStr = "MAILTO:" + curAttendee->name() + " <" + | 429 | tmpStr = "MAILTO:" + curAttendee->name() + " <" + |
411 | curAttendee->email() + ">"; | 430 | curAttendee->email() + ">"; |
412 | else if (curAttendee->name().isEmpty()) | 431 | else if (curAttendee->name().isEmpty()) |
413 | tmpStr = "MAILTO: " + curAttendee->email(); | 432 | tmpStr = "MAILTO: " + curAttendee->email(); |
414 | else if (curAttendee->email().isEmpty()) | 433 | else if (curAttendee->email().isEmpty()) |
415 | tmpStr = "MAILTO: " + curAttendee->name(); | 434 | tmpStr = "MAILTO: " + curAttendee->name(); |
416 | else if (curAttendee->name().isEmpty() && | 435 | else if (curAttendee->name().isEmpty() && |
417 | curAttendee->email().isEmpty()) | 436 | curAttendee->email().isEmpty()) |
418 | kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl; | 437 | kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl; |
419 | VObject *aProp = addPropValue(vevent, VCAttendeeProp, tmpStr.local8Bit()); | 438 | VObject *aProp = addPropValue(vevent, VCAttendeeProp, tmpStr.local8Bit()); |
420 | addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE");; | 439 | addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE");; |
421 | addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); | 440 | addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); |
422 | } | 441 | } |
423 | } | 442 | } |
diff --git a/libkcal/vcalformat.h b/libkcal/vcalformat.h index d4cecbc..8490125 100644 --- a/libkcal/vcalformat.h +++ b/libkcal/vcalformat.h | |||
@@ -1,108 +1,110 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 1998 Preston Brown | 3 | Copyright (c) 1998 Preston Brown |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #ifndef _VCALFORMAT_H | 22 | #ifndef _VCALFORMAT_H |
23 | #define _VCALFORMAT_H | 23 | #define _VCALFORMAT_H |
24 | 24 | ||
25 | #include "calformat.h" | 25 | #include "calformat.h" |
26 | 26 | ||
27 | #define _VCAL_VERSION "1.0" | 27 | #define _VCAL_VERSION "1.0" |
28 | 28 | ||
29 | class VObject; | 29 | class VObject; |
30 | 30 | ||
31 | namespace KCal { | 31 | namespace KCal { |
32 | 32 | ||
33 | /** | 33 | /** |
34 | This class implements the vCalendar format. It provides methods for | 34 | This class implements the vCalendar format. It provides methods for |
35 | loading/saving/converting vCalendar format data into the internal KOrganizer | 35 | loading/saving/converting vCalendar format data into the internal KOrganizer |
36 | representation as Calendar and Events. | 36 | representation as Calendar and Events. |
37 | 37 | ||
38 | @short vCalendar format implementation | 38 | @short vCalendar format implementation |
39 | */ | 39 | */ |
40 | class VCalFormat : public CalFormat { | 40 | class VCalFormat : public CalFormat { |
41 | public: | 41 | public: |
42 | VCalFormat(); | 42 | VCalFormat(); |
43 | virtual ~VCalFormat(); | 43 | virtual ~VCalFormat(); |
44 | 44 | ||
45 | /** loads a calendar on disk in vCalendar format into the current calendar. | 45 | /** loads a calendar on disk in vCalendar format into the current calendar. |
46 | * any information already present is lost. Returns TRUE if successful, | 46 | * any information already present is lost. Returns TRUE if successful, |
47 | * else returns FALSE. | 47 | * else returns FALSE. |
48 | * @param fileName the name of the calendar on disk. | 48 | * @param fileName the name of the calendar on disk. |
49 | */ | 49 | */ |
50 | bool load(Calendar *,const QString &fileName); | 50 | bool load(Calendar *,const QString &fileName); |
51 | /** writes out the calendar to disk in vCalendar format. Returns true if | 51 | /** writes out the calendar to disk in vCalendar format. Returns true if |
52 | * successful and false on error. | 52 | * successful and false on error. |
53 | * @param fileName the name of the file | 53 | * @param fileName the name of the file |
54 | */ | 54 | */ |
55 | bool save(Calendar *,const QString &fileName); | 55 | bool save(Calendar *,const QString &fileName); |
56 | 56 | ||
57 | /** | 57 | /** |
58 | Parse string and populate calendar with that information. | 58 | Parse string and populate calendar with that information. |
59 | */ | 59 | */ |
60 | bool fromString( Calendar *, const QString & ); | 60 | bool fromString( Calendar *, const QString & ); |
61 | /** | 61 | /** |
62 | Return calendar information as string. | 62 | Return calendar information as string. |
63 | */ | 63 | */ |
64 | QString toString( Calendar * ); | 64 | QString toString( Calendar * ); |
65 | QString eventToString( Event * ); | ||
66 | QString todoToString( Todo * ); | ||
65 | 67 | ||
66 | protected: | 68 | protected: |
67 | /** translates a VObject of the TODO type into a Event */ | 69 | /** translates a VObject of the TODO type into a Event */ |
68 | Todo *VTodoToEvent(VObject *vtodo); | 70 | Todo *VTodoToEvent(VObject *vtodo); |
69 | /** translates a VObject into a Event and returns a pointer to it. */ | 71 | /** translates a VObject into a Event and returns a pointer to it. */ |
70 | Event *VEventToEvent(VObject *vevent); | 72 | Event *VEventToEvent(VObject *vevent); |
71 | /** translate a Event into a VTodo-type VObject and return pointer */ | 73 | /** translate a Event into a VTodo-type VObject and return pointer */ |
72 | VObject *eventToVTodo(const Todo *anEvent); | 74 | VObject *eventToVTodo(const Todo *anEvent); |
73 | /** translate a Event into a VObject and returns a pointer to it. */ | 75 | /** translate a Event into a VObject and returns a pointer to it. */ |
74 | VObject* eventToVEvent(const Event *anEvent); | 76 | VObject* eventToVEvent(const Event *anEvent); |
75 | 77 | ||
76 | /** takes a QDate and returns a string in the format YYYYMMDDTHHMMSS */ | 78 | /** takes a QDate and returns a string in the format YYYYMMDDTHHMMSS */ |
77 | QString qDateToISO(const QDate &); | 79 | QString qDateToISO(const QDate &); |
78 | /** takes a QDateTime and returns a string in format YYYYMMDDTHHMMSS */ | 80 | /** takes a QDateTime and returns a string in format YYYYMMDDTHHMMSS */ |
79 | QString qDateTimeToISO(const QDateTime &, bool zulu=TRUE); | 81 | QString qDateTimeToISO(const QDateTime &, bool zulu=TRUE); |
80 | /** takes a string in the format YYYYMMDDTHHMMSS and returns a | 82 | /** takes a string in the format YYYYMMDDTHHMMSS and returns a |
81 | * valid QDateTime. */ | 83 | * valid QDateTime. */ |
82 | QDateTime ISOToQDateTime(const QString & dtStr); | 84 | QDateTime ISOToQDateTime(const QString & dtStr); |
83 | /** takes a string in the format YYYYMMDD and returns a | 85 | /** takes a string in the format YYYYMMDD and returns a |
84 | * valid QDate. */ | 86 | * valid QDate. */ |
85 | QDate ISOToQDate(const QString & dtStr); | 87 | QDate ISOToQDate(const QString & dtStr); |
86 | /** takes a vCalendar tree of VObjects, and puts all of them that have | 88 | /** takes a vCalendar tree of VObjects, and puts all of them that have |
87 | * the "event" property into the dictionary, todos in the todo-list, etc. */ | 89 | * the "event" property into the dictionary, todos in the todo-list, etc. */ |
88 | void populate(VObject *vcal); | 90 | void populate(VObject *vcal); |
89 | 91 | ||
90 | /** takes a number 0 - 6 and returns the two letter string of that day, | 92 | /** takes a number 0 - 6 and returns the two letter string of that day, |
91 | * i.e. MO, TU, WE, etc. */ | 93 | * i.e. MO, TU, WE, etc. */ |
92 | const char *dayFromNum(int day); | 94 | const char *dayFromNum(int day); |
93 | /** the reverse of the above function. */ | 95 | /** the reverse of the above function. */ |
94 | int numFromDay(const QString &day); | 96 | int numFromDay(const QString &day); |
95 | 97 | ||
96 | Attendee::PartStat readStatus(const char *s) const; | 98 | Attendee::PartStat readStatus(const char *s) const; |
97 | QCString writeStatus(Attendee::PartStat status) const; | 99 | QCString writeStatus(Attendee::PartStat status) const; |
98 | 100 | ||
99 | private: | 101 | private: |
100 | Calendar *mCalendar; | 102 | Calendar *mCalendar; |
101 | 103 | ||
102 | QPtrList<Event> mEventsRelate; // events with relations | 104 | QPtrList<Event> mEventsRelate; // events with relations |
103 | QPtrList<Todo> mTodosRelate; // todos with relations | 105 | QPtrList<Todo> mTodosRelate; // todos with relations |
104 | }; | 106 | }; |
105 | 107 | ||
106 | } | 108 | } |
107 | 109 | ||
108 | #endif | 110 | #endif |