summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-06-12 22:36:41 (UTC)
committer zautrix <zautrix>2005-06-12 22:36:41 (UTC)
commit5e4f16e92a96bdf89f82be3b231d18ae9e257486 (patch) (unidiff)
tree6bf55a0ae92e95dc598a813ed7b7eef5c00dfb4f
parent8cfca2b9b7ece646229a72843cf8d6d63e7b8af9 (diff)
downloadkdepimpi-5e4f16e92a96bdf89f82be3b231d18ae9e257486.zip
kdepimpi-5e4f16e92a96bdf89f82be3b231d18ae9e257486.tar.gz
kdepimpi-5e4f16e92a96bdf89f82be3b231d18ae9e257486.tar.bz2
fixxxx
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp7
-rw-r--r--korganizer/kofilterview.cpp255
-rw-r--r--korganizer/kofilterview.h118
-rw-r--r--korganizer/koprefs.cpp7
-rw-r--r--korganizer/koprefs.h1
-rw-r--r--libkdepim/kcmconfigs/kdepimconfigwidget.cpp1
-rw-r--r--microkde/kcolorbutton.cpp7
-rw-r--r--microkde/kcolorbutton.h3
8 files changed, 323 insertions, 76 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 753d81f..1024b4e 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -871,3525 +871,3528 @@ void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
871{ 871{
872 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 872 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
873 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 873 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
874#ifndef DESKTOP_VERSION 874#ifndef DESKTOP_VERSION
875 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 875 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
876#endif 876#endif
877 return; 877 return;
878 } 878 }
879 mAlarmTimer->stop(); 879 mAlarmTimer->stop();
880} 880}
881void CalendarView::selectWeekNum ( int num ) 881void CalendarView::selectWeekNum ( int num )
882{ 882{
883 dateNavigator()->blockSignals( true ); 883 dateNavigator()->blockSignals( true );
884 dateNavigator()->selectWeek( num ); 884 dateNavigator()->selectWeek( num );
885 dateNavigator()->blockSignals( false ); 885 dateNavigator()->blockSignals( false );
886 mViewManager->showWeekView(); 886 mViewManager->showWeekView();
887} 887}
888KOViewManager *CalendarView::viewManager() 888KOViewManager *CalendarView::viewManager()
889{ 889{
890 return mViewManager; 890 return mViewManager;
891} 891}
892 892
893KODialogManager *CalendarView::dialogManager() 893KODialogManager *CalendarView::dialogManager()
894{ 894{
895 return mDialogManager; 895 return mDialogManager;
896} 896}
897 897
898QDate CalendarView::startDate() 898QDate CalendarView::startDate()
899{ 899{
900 DateList dates = mNavigator->selectedDates(); 900 DateList dates = mNavigator->selectedDates();
901 901
902 return dates.first(); 902 return dates.first();
903} 903}
904 904
905QDate CalendarView::endDate() 905QDate CalendarView::endDate()
906{ 906{
907 DateList dates = mNavigator->selectedDates(); 907 DateList dates = mNavigator->selectedDates();
908 908
909 return dates.last(); 909 return dates.last();
910} 910}
911 911
912 912
913void CalendarView::createPrinter() 913void CalendarView::createPrinter()
914{ 914{
915#ifndef KORG_NOPRINTER 915#ifndef KORG_NOPRINTER
916 if (!mCalPrinter) { 916 if (!mCalPrinter) {
917 mCalPrinter = new CalPrinter(this, mCalendar); 917 mCalPrinter = new CalPrinter(this, mCalendar);
918 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 918 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
919 } 919 }
920#endif 920#endif
921} 921}
922 922
923 923
924//KOPrefs::instance()->mWriteBackFile 924//KOPrefs::instance()->mWriteBackFile
925//KOPrefs::instance()->mWriteBackExistingOnly 925//KOPrefs::instance()->mWriteBackExistingOnly
926 926
927// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 927// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
928// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 928// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
929// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 929// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
930// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 930// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
931// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 931// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
932// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 932// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
933 933
934int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 934int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
935{ 935{
936 936
937 // 0 equal 937 // 0 equal
938 // 1 take local 938 // 1 take local
939 // 2 take remote 939 // 2 take remote
940 // 3 cancel 940 // 3 cancel
941 QDateTime lastSync = mLastCalendarSync; 941 QDateTime lastSync = mLastCalendarSync;
942 QDateTime localMod = local->lastModified(); 942 QDateTime localMod = local->lastModified();
943 QDateTime remoteMod = remote->lastModified(); 943 QDateTime remoteMod = remote->lastModified();
944 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 944 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
945 bool remCh, locCh; 945 bool remCh, locCh;
946 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 946 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
947 //if ( remCh ) 947 //if ( remCh )
948 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 948 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
949 locCh = ( localMod > mLastCalendarSync ); 949 locCh = ( localMod > mLastCalendarSync );
950 if ( !remCh && ! locCh ) { 950 if ( !remCh && ! locCh ) {
951 //qDebug("both not changed "); 951 //qDebug("both not changed ");
952 lastSync = localMod.addDays(1); 952 lastSync = localMod.addDays(1);
953 if ( mode <= SYNC_PREF_ASK ) 953 if ( mode <= SYNC_PREF_ASK )
954 return 0; 954 return 0;
955 } else { 955 } else {
956 if ( locCh ) { 956 if ( locCh ) {
957 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 957 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
958 lastSync = localMod.addDays( -1 ); 958 lastSync = localMod.addDays( -1 );
959 if ( !remCh ) 959 if ( !remCh )
960 remoteMod = ( lastSync.addDays( -1 ) ); 960 remoteMod = ( lastSync.addDays( -1 ) );
961 } else { 961 } else {
962 //qDebug(" not loc changed "); 962 //qDebug(" not loc changed ");
963 lastSync = localMod.addDays( 1 ); 963 lastSync = localMod.addDays( 1 );
964 if ( remCh ) 964 if ( remCh )
965 remoteMod =( lastSync.addDays( 1 ) ); 965 remoteMod =( lastSync.addDays( 1 ) );
966 966
967 } 967 }
968 } 968 }
969 full = true; 969 full = true;
970 if ( mode < SYNC_PREF_ASK ) 970 if ( mode < SYNC_PREF_ASK )
971 mode = SYNC_PREF_ASK; 971 mode = SYNC_PREF_ASK;
972 } else { 972 } else {
973 if ( localMod == remoteMod ) 973 if ( localMod == remoteMod )
974 // if ( local->revision() == remote->revision() ) 974 // if ( local->revision() == remote->revision() )
975 return 0; 975 return 0;
976 976
977 } 977 }
978 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 978 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
979 979
980 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 980 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
981 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 981 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
982 //full = true; //debug only 982 //full = true; //debug only
983 if ( full ) { 983 if ( full ) {
984 bool equ = false; 984 bool equ = false;
985 if ( local->typeID() == eventID ) { 985 if ( local->typeID() == eventID ) {
986 equ = (*((Event*) local) == *((Event*) remote)); 986 equ = (*((Event*) local) == *((Event*) remote));
987 } 987 }
988 else if ( local->typeID() == todoID ) 988 else if ( local->typeID() == todoID )
989 equ = (*((Todo*) local) == (*(Todo*) remote)); 989 equ = (*((Todo*) local) == (*(Todo*) remote));
990 else if ( local->typeID() == journalID ) 990 else if ( local->typeID() == journalID )
991 equ = (*((Journal*) local) == *((Journal*) remote)); 991 equ = (*((Journal*) local) == *((Journal*) remote));
992 if ( equ ) { 992 if ( equ ) {
993 //qDebug("equal "); 993 //qDebug("equal ");
994 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 994 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
995 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 995 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
996 } 996 }
997 if ( mode < SYNC_PREF_FORCE_LOCAL ) 997 if ( mode < SYNC_PREF_FORCE_LOCAL )
998 return 0; 998 return 0;
999 999
1000 }//else //debug only 1000 }//else //debug only
1001 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 1001 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
1002 } 1002 }
1003 int result; 1003 int result;
1004 bool localIsNew; 1004 bool localIsNew;
1005 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); 1005 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() );
1006 1006
1007 1007
1008 // ************************************************ 1008 // ************************************************
1009 // ************************************************ 1009 // ************************************************
1010 // ************************************************ 1010 // ************************************************
1011 // We may have that lastSync > remoteMod AND lastSync > localMod 1011 // We may have that lastSync > remoteMod AND lastSync > localMod
1012 // BUT remoteMod != localMod 1012 // BUT remoteMod != localMod
1013 1013
1014 1014
1015 if ( full && mode < SYNC_PREF_NEWEST ) 1015 if ( full && mode < SYNC_PREF_NEWEST )
1016 mode = SYNC_PREF_ASK; 1016 mode = SYNC_PREF_ASK;
1017 1017
1018 switch( mode ) { 1018 switch( mode ) {
1019 case SYNC_PREF_LOCAL: 1019 case SYNC_PREF_LOCAL:
1020 if ( lastSync > remoteMod ) 1020 if ( lastSync > remoteMod )
1021 return 1; 1021 return 1;
1022 if ( lastSync > localMod ) 1022 if ( lastSync > localMod )
1023 return 2; 1023 return 2;
1024 return 1; 1024 return 1;
1025 break; 1025 break;
1026 case SYNC_PREF_REMOTE: 1026 case SYNC_PREF_REMOTE:
1027 if ( lastSync > localMod ) 1027 if ( lastSync > localMod )
1028 return 2; 1028 return 2;
1029 if ( lastSync > remoteMod ) 1029 if ( lastSync > remoteMod )
1030 return 1; 1030 return 1;
1031 return 2; 1031 return 2;
1032 break; 1032 break;
1033 case SYNC_PREF_NEWEST: 1033 case SYNC_PREF_NEWEST:
1034 if ( localMod >= remoteMod ) 1034 if ( localMod >= remoteMod )
1035 return 1; 1035 return 1;
1036 else 1036 else
1037 return 2; 1037 return 2;
1038 break; 1038 break;
1039 case SYNC_PREF_ASK: 1039 case SYNC_PREF_ASK:
1040 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1040 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1041 if ( lastSync > remoteMod && lastSync > localMod) 1041 if ( lastSync > remoteMod && lastSync > localMod)
1042 return 0; 1042 return 0;
1043 if ( lastSync > remoteMod ) 1043 if ( lastSync > remoteMod )
1044 return 1; 1044 return 1;
1045 if ( lastSync > localMod ) 1045 if ( lastSync > localMod )
1046 return 2; 1046 return 2;
1047 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1047 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1048 localIsNew = localMod >= remoteMod; 1048 localIsNew = localMod >= remoteMod;
1049 if ( localIsNew ) 1049 if ( localIsNew )
1050 getEventViewerDialog()->setColorMode( 1 ); 1050 getEventViewerDialog()->setColorMode( 1 );
1051 else 1051 else
1052 getEventViewerDialog()->setColorMode( 2 ); 1052 getEventViewerDialog()->setColorMode( 2 );
1053 getEventViewerDialog()->setIncidence(local); 1053 getEventViewerDialog()->setIncidence(local);
1054 if ( localIsNew ) 1054 if ( localIsNew )
1055 getEventViewerDialog()->setColorMode( 2 ); 1055 getEventViewerDialog()->setColorMode( 2 );
1056 else 1056 else
1057 getEventViewerDialog()->setColorMode( 1 ); 1057 getEventViewerDialog()->setColorMode( 1 );
1058 getEventViewerDialog()->addIncidence(remote); 1058 getEventViewerDialog()->addIncidence(remote);
1059 getEventViewerDialog()->setColorMode( 0 ); 1059 getEventViewerDialog()->setColorMode( 0 );
1060 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 1060 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
1061 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 1061 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
1062 getEventViewerDialog()->showMe(); 1062 getEventViewerDialog()->showMe();
1063 result = getEventViewerDialog()->executeS( localIsNew ); 1063 result = getEventViewerDialog()->executeS( localIsNew );
1064 return result; 1064 return result;
1065 1065
1066 break; 1066 break;
1067 case SYNC_PREF_FORCE_LOCAL: 1067 case SYNC_PREF_FORCE_LOCAL:
1068 return 1; 1068 return 1;
1069 break; 1069 break;
1070 case SYNC_PREF_FORCE_REMOTE: 1070 case SYNC_PREF_FORCE_REMOTE:
1071 return 2; 1071 return 2;
1072 break; 1072 break;
1073 1073
1074 default: 1074 default:
1075 // SYNC_PREF_TAKE_BOTH not implemented 1075 // SYNC_PREF_TAKE_BOTH not implemented
1076 break; 1076 break;
1077 } 1077 }
1078 return 0; 1078 return 0;
1079} 1079}
1080Event* CalendarView::getLastSyncEvent() 1080Event* CalendarView::getLastSyncEvent()
1081{ 1081{
1082 Event* lse; 1082 Event* lse;
1083 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 1083 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
1084 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 1084 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
1085 if (!lse) { 1085 if (!lse) {
1086 lse = new Event(); 1086 lse = new Event();
1087 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 1087 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
1088 QString sum = ""; 1088 QString sum = "";
1089 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 1089 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
1090 sum = "E: "; 1090 sum = "E: ";
1091 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 1091 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
1092 lse->setDtStart( mLastCalendarSync ); 1092 lse->setDtStart( mLastCalendarSync );
1093 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1093 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1094 lse->setCategories( i18n("SyncEvent") ); 1094 lse->setCategories( i18n("SyncEvent") );
1095 lse->setReadOnly( true ); 1095 lse->setReadOnly( true );
1096 mCalendar->addEvent( lse ); 1096 mCalendar->addEvent( lse );
1097 } 1097 }
1098 1098
1099 return lse; 1099 return lse;
1100 1100
1101} 1101}
1102 1102
1103// we check, if the to delete event has a id for a profile 1103// we check, if the to delete event has a id for a profile
1104// if yes, we set this id in the profile to delete 1104// if yes, we set this id in the profile to delete
1105void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 1105void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
1106{ 1106{
1107 if ( lastSync.count() == 0 ) { 1107 if ( lastSync.count() == 0 ) {
1108 //qDebug(" lastSync.count() == 0"); 1108 //qDebug(" lastSync.count() == 0");
1109 return; 1109 return;
1110 } 1110 }
1111 if ( toDelete->typeID() == journalID ) 1111 if ( toDelete->typeID() == journalID )
1112 return; 1112 return;
1113 1113
1114 Event* eve = lastSync.first(); 1114 Event* eve = lastSync.first();
1115 1115
1116 while ( eve ) { 1116 while ( eve ) {
1117 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 1117 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
1118 if ( !id.isEmpty() ) { 1118 if ( !id.isEmpty() ) {
1119 QString des = eve->description(); 1119 QString des = eve->description();
1120 QString pref = "e"; 1120 QString pref = "e";
1121 if ( toDelete->typeID() == todoID ) 1121 if ( toDelete->typeID() == todoID )
1122 pref = "t"; 1122 pref = "t";
1123 des += pref+ id + ","; 1123 des += pref+ id + ",";
1124 eve->setReadOnly( false ); 1124 eve->setReadOnly( false );
1125 eve->setDescription( des ); 1125 eve->setDescription( des );
1126 //qDebug("setdes %s ", des.latin1()); 1126 //qDebug("setdes %s ", des.latin1());
1127 eve->setReadOnly( true ); 1127 eve->setReadOnly( true );
1128 } 1128 }
1129 eve = lastSync.next(); 1129 eve = lastSync.next();
1130 } 1130 }
1131 1131
1132} 1132}
1133void CalendarView::checkExternalId( Incidence * inc ) 1133void CalendarView::checkExternalId( Incidence * inc )
1134{ 1134{
1135 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 1135 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
1136 checkExternSyncEvent( lastSync, inc ); 1136 checkExternSyncEvent( lastSync, inc );
1137 1137
1138} 1138}
1139bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 1139bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
1140{ 1140{
1141 bool syncOK = true; 1141 bool syncOK = true;
1142 int addedEvent = 0; 1142 int addedEvent = 0;
1143 int addedEventR = 0; 1143 int addedEventR = 0;
1144 int deletedEventR = 0; 1144 int deletedEventR = 0;
1145 int deletedEventL = 0; 1145 int deletedEventL = 0;
1146 int changedLocal = 0; 1146 int changedLocal = 0;
1147 int changedRemote = 0; 1147 int changedRemote = 0;
1148 int filteredIN = 0; 1148 int filteredIN = 0;
1149 int filteredOUT = 0; 1149 int filteredOUT = 0;
1150 //QPtrList<Event> el = local->rawEvents(); 1150 //QPtrList<Event> el = local->rawEvents();
1151 Event* eventR; 1151 Event* eventR;
1152 QString uid; 1152 QString uid;
1153 int take; 1153 int take;
1154 Event* eventL; 1154 Event* eventL;
1155 Event* eventRSync; 1155 Event* eventRSync;
1156 Event* eventLSync; 1156 Event* eventLSync;
1157 clearAllViews(); 1157 clearAllViews();
1158 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 1158 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
1159 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 1159 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
1160 bool fullDateRange = false; 1160 bool fullDateRange = false;
1161 local->resetTempSyncStat(); 1161 local->resetTempSyncStat();
1162 mLastCalendarSync = QDateTime::currentDateTime(); 1162 mLastCalendarSync = QDateTime::currentDateTime();
1163 if ( mSyncManager->syncWithDesktop() ) { 1163 if ( mSyncManager->syncWithDesktop() ) {
1164 remote->resetPilotStat(1); 1164 remote->resetPilotStat(1);
1165 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 1165 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1166 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 1166 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
1167 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 1167 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
1168 } else { 1168 } else {
1169 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 1169 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
1170 } 1170 }
1171 } 1171 }
1172 QDateTime modifiedCalendar = mLastCalendarSync; 1172 QDateTime modifiedCalendar = mLastCalendarSync;
1173 eventLSync = getLastSyncEvent(); 1173 eventLSync = getLastSyncEvent();
1174 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 1174 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
1175 if ( eventR ) { 1175 if ( eventR ) {
1176 eventRSync = (Event*) eventR->clone(); 1176 eventRSync = (Event*) eventR->clone();
1177 remote->deleteEvent(eventR ); 1177 remote->deleteEvent(eventR );
1178 1178
1179 } else { 1179 } else {
1180 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 1180 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
1181 eventRSync = (Event*)eventLSync->clone(); 1181 eventRSync = (Event*)eventLSync->clone();
1182 } else { 1182 } else {
1183 fullDateRange = true; 1183 fullDateRange = true;
1184 eventRSync = new Event(); 1184 eventRSync = new Event();
1185 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 1185 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
1186 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 1186 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
1187 eventRSync->setDtStart( mLastCalendarSync ); 1187 eventRSync->setDtStart( mLastCalendarSync );
1188 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1188 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1189 eventRSync->setCategories( i18n("SyncEvent") ); 1189 eventRSync->setCategories( i18n("SyncEvent") );
1190 } 1190 }
1191 } 1191 }
1192 if ( eventLSync->dtStart() == mLastCalendarSync ) 1192 if ( eventLSync->dtStart() == mLastCalendarSync )
1193 fullDateRange = true; 1193 fullDateRange = true;
1194 1194
1195 if ( ! fullDateRange ) { 1195 if ( ! fullDateRange ) {
1196 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 1196 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
1197 1197
1198 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 1198 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
1199 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 1199 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
1200 fullDateRange = true; 1200 fullDateRange = true;
1201 } 1201 }
1202 } 1202 }
1203 if ( mSyncManager->syncWithDesktop() ) { 1203 if ( mSyncManager->syncWithDesktop() ) {
1204 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 1204 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
1205 } 1205 }
1206 if ( fullDateRange ) 1206 if ( fullDateRange )
1207 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 1207 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
1208 else 1208 else
1209 mLastCalendarSync = eventLSync->dtStart(); 1209 mLastCalendarSync = eventLSync->dtStart();
1210 // for resyncing if own file has changed 1210 // for resyncing if own file has changed
1211 if ( mCurrentSyncDevice == "deleteaftersync" ) { 1211 if ( mCurrentSyncDevice == "deleteaftersync" ) {
1212 mLastCalendarSync = loadedFileVersion; 1212 mLastCalendarSync = loadedFileVersion;
1213 //qDebug("setting mLastCalendarSync "); 1213 //qDebug("setting mLastCalendarSync ");
1214 } 1214 }
1215 //qDebug("*************************** "); 1215 //qDebug("*************************** ");
1216 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 1216 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
1217 QPtrList<Incidence> er = remote->rawIncidences(); 1217 QPtrList<Incidence> er = remote->rawIncidences();
1218 Incidence* inR = er.first(); 1218 Incidence* inR = er.first();
1219 Incidence* inL; 1219 Incidence* inL;
1220 QProgressBar bar( er.count(),0 ); 1220 QProgressBar bar( er.count(),0 );
1221 bar.setCaption (i18n("Syncing - close to abort!") ); 1221 bar.setCaption (i18n("Syncing - close to abort!") );
1222 1222
1223 // ************** setting up filter ************* 1223 // ************** setting up filter *************
1224 CalFilter *filterIN = 0; 1224 CalFilter *filterIN = 0;
1225 CalFilter *filterOUT = 0; 1225 CalFilter *filterOUT = 0;
1226 CalFilter *filter = mFilters.first(); 1226 CalFilter *filter = mFilters.first();
1227 while(filter) { 1227 while(filter) {
1228 if ( filter->name() == mSyncManager->mFilterInCal ) 1228 if ( filter->name() == mSyncManager->mFilterInCal )
1229 filterIN = filter; 1229 filterIN = filter;
1230 if ( filter->name() == mSyncManager->mFilterOutCal ) 1230 if ( filter->name() == mSyncManager->mFilterOutCal )
1231 filterOUT = filter; 1231 filterOUT = filter;
1232 filter = mFilters.next(); 1232 filter = mFilters.next();
1233 } 1233 }
1234 int w = 300; 1234 int w = 300;
1235 if ( QApplication::desktop()->width() < 320 ) 1235 if ( QApplication::desktop()->width() < 320 )
1236 w = 220; 1236 w = 220;
1237 int h = bar.sizeHint().height() ; 1237 int h = bar.sizeHint().height() ;
1238 int dw = QApplication::desktop()->width(); 1238 int dw = QApplication::desktop()->width();
1239 int dh = QApplication::desktop()->height(); 1239 int dh = QApplication::desktop()->height();
1240 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1240 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1241 bar.show(); 1241 bar.show();
1242 int modulo = (er.count()/10)+1; 1242 int modulo = (er.count()/10)+1;
1243 int incCounter = 0; 1243 int incCounter = 0;
1244 while ( inR ) { 1244 while ( inR ) {
1245 if ( ! bar.isVisible() ) 1245 if ( ! bar.isVisible() )
1246 return false; 1246 return false;
1247 if ( incCounter % modulo == 0 ) 1247 if ( incCounter % modulo == 0 )
1248 bar.setProgress( incCounter ); 1248 bar.setProgress( incCounter );
1249 ++incCounter; 1249 ++incCounter;
1250 uid = inR->uid(); 1250 uid = inR->uid();
1251 bool skipIncidence = false; 1251 bool skipIncidence = false;
1252 if ( uid.left(15) == QString("last-syncEvent-") ) 1252 if ( uid.left(15) == QString("last-syncEvent-") )
1253 skipIncidence = true; 1253 skipIncidence = true;
1254 QString idS; 1254 QString idS;
1255 qApp->processEvents(); 1255 qApp->processEvents();
1256 if ( !skipIncidence ) { 1256 if ( !skipIncidence ) {
1257 inL = local->incidence( uid ); 1257 inL = local->incidence( uid );
1258 if ( inL ) { // maybe conflict - same uid in both calendars 1258 if ( inL ) { // maybe conflict - same uid in both calendars
1259 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1259 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1260 //qDebug("take %d %s ", take, inL->summary().latin1()); 1260 //qDebug("take %d %s ", take, inL->summary().latin1());
1261 if ( take == 3 ) 1261 if ( take == 3 )
1262 return false; 1262 return false;
1263 if ( take == 1 ) {// take local ********************** 1263 if ( take == 1 ) {// take local **********************
1264 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1264 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1265 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1265 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1266 else 1266 else
1267 idS = inR->IDStr(); 1267 idS = inR->IDStr();
1268 remote->deleteIncidence( inR ); 1268 remote->deleteIncidence( inR );
1269 inR = inL->clone(); 1269 inR = inL->clone();
1270 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1270 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1271 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1271 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1272 inR->setIDStr( idS ); 1272 inR->setIDStr( idS );
1273 remote->addIncidence( inR ); 1273 remote->addIncidence( inR );
1274 if ( mSyncManager->syncWithDesktop() ) 1274 if ( mSyncManager->syncWithDesktop() )
1275 inR->setPilotId( 2 ); 1275 inR->setPilotId( 2 );
1276 ++changedRemote; 1276 ++changedRemote;
1277 } else {// take remote ********************** 1277 } else {// take remote **********************
1278 idS = inL->IDStr(); 1278 idS = inL->IDStr();
1279 int pid = inL->pilotId(); 1279 int pid = inL->pilotId();
1280 local->deleteIncidence( inL ); 1280 local->deleteIncidence( inL );
1281 inL = inR->clone(); 1281 inL = inR->clone();
1282 if ( mSyncManager->syncWithDesktop() ) 1282 if ( mSyncManager->syncWithDesktop() )
1283 inL->setPilotId( pid ); 1283 inL->setPilotId( pid );
1284 inL->setIDStr( idS ); 1284 inL->setIDStr( idS );
1285 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1285 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1286 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1286 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1287 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1287 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1288 } 1288 }
1289 local->addIncidence( inL ); 1289 local->addIncidence( inL );
1290 ++changedLocal; 1290 ++changedLocal;
1291 } 1291 }
1292 } 1292 }
1293 } else { // no conflict ********** add or delete remote 1293 } else { // no conflict ********** add or delete remote
1294 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ 1294 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1295 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1295 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1296 QString des = eventLSync->description(); 1296 QString des = eventLSync->description();
1297 QString pref = "e"; 1297 QString pref = "e";
1298 if ( inR->typeID() == todoID ) 1298 if ( inR->typeID() == todoID )
1299 pref = "t"; 1299 pref = "t";
1300 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1300 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1301 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1301 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1302 //remote->deleteIncidence( inR ); 1302 //remote->deleteIncidence( inR );
1303 ++deletedEventR; 1303 ++deletedEventR;
1304 } else { 1304 } else {
1305 inR->setLastModified( modifiedCalendar ); 1305 inR->setLastModified( modifiedCalendar );
1306 inL = inR->clone(); 1306 inL = inR->clone();
1307 inL->setIDStr( ":" ); 1307 inL->setIDStr( ":" );
1308 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1308 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1309 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1309 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1310 local->addIncidence( inL ); 1310 local->addIncidence( inL );
1311 ++addedEvent; 1311 ++addedEvent;
1312 1312
1313 } 1313 }
1314 } else { 1314 } else {
1315 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1315 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1316 inR->setLastModified( modifiedCalendar ); 1316 inR->setLastModified( modifiedCalendar );
1317 inL = inR->clone(); 1317 inL = inR->clone();
1318 inL->setIDStr( ":" ); 1318 inL->setIDStr( ":" );
1319 local->addIncidence( inL ); 1319 local->addIncidence( inL );
1320 ++addedEvent; 1320 ++addedEvent;
1321 1321
1322 } else { 1322 } else {
1323 checkExternSyncEvent(eventRSyncSharp, inR); 1323 checkExternSyncEvent(eventRSyncSharp, inR);
1324 remote->deleteIncidence( inR ); 1324 remote->deleteIncidence( inR );
1325 ++deletedEventR; 1325 ++deletedEventR;
1326 } 1326 }
1327 } 1327 }
1328 } else { 1328 } else {
1329 ++filteredIN; 1329 ++filteredIN;
1330 } 1330 }
1331 } 1331 }
1332 } 1332 }
1333 inR = er.next(); 1333 inR = er.next();
1334 } 1334 }
1335 QPtrList<Incidence> el = local->rawIncidences(); 1335 QPtrList<Incidence> el = local->rawIncidences();
1336 inL = el.first(); 1336 inL = el.first();
1337 modulo = (el.count()/10)+1; 1337 modulo = (el.count()/10)+1;
1338 bar.setCaption (i18n("Add / remove events") ); 1338 bar.setCaption (i18n("Add / remove events") );
1339 bar.setTotalSteps ( el.count() ) ; 1339 bar.setTotalSteps ( el.count() ) ;
1340 bar.show(); 1340 bar.show();
1341 incCounter = 0; 1341 incCounter = 0;
1342 1342
1343 while ( inL ) { 1343 while ( inL ) {
1344 1344
1345 qApp->processEvents(); 1345 qApp->processEvents();
1346 if ( ! bar.isVisible() ) 1346 if ( ! bar.isVisible() )
1347 return false; 1347 return false;
1348 if ( incCounter % modulo == 0 ) 1348 if ( incCounter % modulo == 0 )
1349 bar.setProgress( incCounter ); 1349 bar.setProgress( incCounter );
1350 ++incCounter; 1350 ++incCounter;
1351 uid = inL->uid(); 1351 uid = inL->uid();
1352 bool skipIncidence = false; 1352 bool skipIncidence = false;
1353 if ( uid.left(15) == QString("last-syncEvent-") ) 1353 if ( uid.left(15) == QString("last-syncEvent-") )
1354 skipIncidence = true; 1354 skipIncidence = true;
1355 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) 1355 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID )
1356 skipIncidence = true; 1356 skipIncidence = true;
1357 if ( !skipIncidence ) { 1357 if ( !skipIncidence ) {
1358 inR = remote->incidence( uid ); 1358 inR = remote->incidence( uid );
1359 if ( ! inR ) { 1359 if ( ! inR ) {
1360 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ 1360 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1361 // no conflict ********** add or delete local 1361 // no conflict ********** add or delete local
1362 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1362 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1363 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1363 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1364 checkExternSyncEvent(eventLSyncSharp, inL); 1364 checkExternSyncEvent(eventLSyncSharp, inL);
1365 local->deleteIncidence( inL ); 1365 local->deleteIncidence( inL );
1366 ++deletedEventL; 1366 ++deletedEventL;
1367 } else { 1367 } else {
1368 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1368 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1369 inL->removeID(mCurrentSyncDevice ); 1369 inL->removeID(mCurrentSyncDevice );
1370 ++addedEventR; 1370 ++addedEventR;
1371 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1371 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1372 inL->setLastModified( modifiedCalendar ); 1372 inL->setLastModified( modifiedCalendar );
1373 inR = inL->clone(); 1373 inR = inL->clone();
1374 inR->setIDStr( ":" ); 1374 inR->setIDStr( ":" );
1375 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1375 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1376 remote->addIncidence( inR ); 1376 remote->addIncidence( inR );
1377 } 1377 }
1378 } 1378 }
1379 } else { 1379 } else {
1380 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1380 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1381 checkExternSyncEvent(eventLSyncSharp, inL); 1381 checkExternSyncEvent(eventLSyncSharp, inL);
1382 local->deleteIncidence( inL ); 1382 local->deleteIncidence( inL );
1383 ++deletedEventL; 1383 ++deletedEventL;
1384 } else { 1384 } else {
1385 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1385 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1386 ++addedEventR; 1386 ++addedEventR;
1387 inL->setLastModified( modifiedCalendar ); 1387 inL->setLastModified( modifiedCalendar );
1388 inR = inL->clone(); 1388 inR = inL->clone();
1389 inR->setIDStr( ":" ); 1389 inR->setIDStr( ":" );
1390 remote->addIncidence( inR ); 1390 remote->addIncidence( inR );
1391 } 1391 }
1392 } 1392 }
1393 } 1393 }
1394 } else { 1394 } else {
1395 ++filteredOUT; 1395 ++filteredOUT;
1396 } 1396 }
1397 } 1397 }
1398 } 1398 }
1399 inL = el.next(); 1399 inL = el.next();
1400 } 1400 }
1401 int delFut = 0; 1401 int delFut = 0;
1402 int remRem = 0; 1402 int remRem = 0;
1403 if ( mSyncManager->mWriteBackInFuture ) { 1403 if ( mSyncManager->mWriteBackInFuture ) {
1404 er = remote->rawIncidences(); 1404 er = remote->rawIncidences();
1405 remRem = er.count(); 1405 remRem = er.count();
1406 inR = er.first(); 1406 inR = er.first();
1407 QDateTime dt; 1407 QDateTime dt;
1408 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1408 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1409 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1409 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1410 while ( inR ) { 1410 while ( inR ) {
1411 if ( inR->typeID() == todoID ) { 1411 if ( inR->typeID() == todoID ) {
1412 Todo * t = (Todo*)inR; 1412 Todo * t = (Todo*)inR;
1413 if ( t->hasDueDate() ) 1413 if ( t->hasDueDate() )
1414 dt = t->dtDue(); 1414 dt = t->dtDue();
1415 else 1415 else
1416 dt = cur.addSecs( 62 ); 1416 dt = cur.addSecs( 62 );
1417 } 1417 }
1418 else if (inR->typeID() == eventID ) { 1418 else if (inR->typeID() == eventID ) {
1419 bool ok; 1419 bool ok;
1420 dt = inR->getNextOccurence( cur, &ok ); 1420 dt = inR->getNextOccurence( cur, &ok );
1421 if ( !ok ) 1421 if ( !ok )
1422 dt = cur.addSecs( -62 ); 1422 dt = cur.addSecs( -62 );
1423 } 1423 }
1424 else 1424 else
1425 dt = inR->dtStart(); 1425 dt = inR->dtStart();
1426 if ( dt < cur || dt > end ) { 1426 if ( dt < cur || dt > end ) {
1427 remote->deleteIncidence( inR ); 1427 remote->deleteIncidence( inR );
1428 ++delFut; 1428 ++delFut;
1429 } 1429 }
1430 inR = er.next(); 1430 inR = er.next();
1431 } 1431 }
1432 } 1432 }
1433 bar.hide(); 1433 bar.hide();
1434 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1434 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1435 eventLSync->setReadOnly( false ); 1435 eventLSync->setReadOnly( false );
1436 eventLSync->setDtStart( mLastCalendarSync ); 1436 eventLSync->setDtStart( mLastCalendarSync );
1437 eventRSync->setDtStart( mLastCalendarSync ); 1437 eventRSync->setDtStart( mLastCalendarSync );
1438 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1438 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1439 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1439 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1440 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1440 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1441 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1441 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1442 eventLSync->setReadOnly( true ); 1442 eventLSync->setReadOnly( true );
1443 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); 1443 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL );
1444 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1444 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1445 remote->addEvent( eventRSync ); 1445 remote->addEvent( eventRSync );
1446 else 1446 else
1447 delete eventRSync; 1447 delete eventRSync;
1448 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); 1448 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() );
1449 QString mes; 1449 QString mes;
1450 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); 1450 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT );
1451 QString delmess; 1451 QString delmess;
1452 if ( delFut ) { 1452 if ( delFut ) {
1453 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); 1453 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut);
1454 mes += delmess; 1454 mes += delmess;
1455 } 1455 }
1456 mes = i18n("Local calendar changed!\n") +mes; 1456 mes = i18n("Local calendar changed!\n") +mes;
1457 mCalendar->checkAlarmForIncidence( 0, true ); 1457 mCalendar->checkAlarmForIncidence( 0, true );
1458 qDebug( mes ); 1458 qDebug( mes );
1459 if ( mSyncManager->mShowSyncSummary ) { 1459 if ( mSyncManager->mShowSyncSummary ) {
1460 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1460 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1461 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1461 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1462 qDebug("KO: WB cancelled "); 1462 qDebug("KO: WB cancelled ");
1463 mSyncManager->mWriteBackFile = false; 1463 mSyncManager->mWriteBackFile = false;
1464 return syncOK; 1464 return syncOK;
1465 } 1465 }
1466 } 1466 }
1467 return syncOK; 1467 return syncOK;
1468} 1468}
1469 1469
1470void CalendarView::setSyncDevice( QString s ) 1470void CalendarView::setSyncDevice( QString s )
1471{ 1471{
1472 mCurrentSyncDevice= s; 1472 mCurrentSyncDevice= s;
1473} 1473}
1474void CalendarView::setSyncName( QString s ) 1474void CalendarView::setSyncName( QString s )
1475{ 1475{
1476 mCurrentSyncName= s; 1476 mCurrentSyncName= s;
1477} 1477}
1478bool CalendarView::syncCalendar(QString filename, int mode) 1478bool CalendarView::syncCalendar(QString filename, int mode)
1479{ 1479{
1480 //qDebug("syncCalendar %s ", filename.latin1()); 1480 //qDebug("syncCalendar %s ", filename.latin1());
1481 mGlobalSyncMode = SYNC_MODE_NORMAL; 1481 mGlobalSyncMode = SYNC_MODE_NORMAL;
1482 CalendarLocal* calendar = new CalendarLocal(); 1482 CalendarLocal* calendar = new CalendarLocal();
1483 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1483 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1484 FileStorage* storage = new FileStorage( calendar ); 1484 FileStorage* storage = new FileStorage( calendar );
1485 bool syncOK = false; 1485 bool syncOK = false;
1486 storage->setFileName( filename ); 1486 storage->setFileName( filename );
1487 // qDebug("loading ... "); 1487 // qDebug("loading ... ");
1488 if ( storage->load() ) { 1488 if ( storage->load() ) {
1489 getEventViewerDialog()->setSyncMode( true ); 1489 getEventViewerDialog()->setSyncMode( true );
1490 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1490 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1491 getEventViewerDialog()->setSyncMode( false ); 1491 getEventViewerDialog()->setSyncMode( false );
1492 if ( syncOK ) { 1492 if ( syncOK ) {
1493 if ( mSyncManager->mWriteBackFile ) 1493 if ( mSyncManager->mWriteBackFile )
1494 { 1494 {
1495 storage->setSaveFormat( new ICalFormat() ); 1495 storage->setSaveFormat( new ICalFormat() );
1496 storage->save(); 1496 storage->save();
1497 } 1497 }
1498 } 1498 }
1499 setModified( true ); 1499 setModified( true );
1500 } 1500 }
1501 delete storage; 1501 delete storage;
1502 delete calendar; 1502 delete calendar;
1503 if ( syncOK ) 1503 if ( syncOK )
1504 updateView(); 1504 updateView();
1505 return syncOK; 1505 return syncOK;
1506} 1506}
1507 1507
1508void CalendarView::syncExternal( int mode ) 1508void CalendarView::syncExternal( int mode )
1509{ 1509{
1510 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1510 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1511 1511
1512 qApp->processEvents(); 1512 qApp->processEvents();
1513 CalendarLocal* calendar = new CalendarLocal(); 1513 CalendarLocal* calendar = new CalendarLocal();
1514 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1514 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1515 bool syncOK = false; 1515 bool syncOK = false;
1516 bool loadSuccess = false; 1516 bool loadSuccess = false;
1517 PhoneFormat* phoneFormat = 0; 1517 PhoneFormat* phoneFormat = 0;
1518 emit tempDisableBR(true); 1518 emit tempDisableBR(true);
1519#ifndef DESKTOP_VERSION 1519#ifndef DESKTOP_VERSION
1520 SharpFormat* sharpFormat = 0; 1520 SharpFormat* sharpFormat = 0;
1521 if ( mode == 0 ) { // sharp 1521 if ( mode == 0 ) { // sharp
1522 sharpFormat = new SharpFormat () ; 1522 sharpFormat = new SharpFormat () ;
1523 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1523 loadSuccess = sharpFormat->load( calendar, mCalendar );
1524 1524
1525 } else 1525 } else
1526#endif 1526#endif
1527 if ( mode == 1 ) { // phone 1527 if ( mode == 1 ) { // phone
1528 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1528 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1529 mSyncManager->mPhoneDevice, 1529 mSyncManager->mPhoneDevice,
1530 mSyncManager->mPhoneConnection, 1530 mSyncManager->mPhoneConnection,
1531 mSyncManager->mPhoneModel); 1531 mSyncManager->mPhoneModel);
1532 loadSuccess = phoneFormat->load( calendar,mCalendar); 1532 loadSuccess = phoneFormat->load( calendar,mCalendar);
1533 1533
1534 } else { 1534 } else {
1535 emit tempDisableBR(false); 1535 emit tempDisableBR(false);
1536 return; 1536 return;
1537 } 1537 }
1538 if ( loadSuccess ) { 1538 if ( loadSuccess ) {
1539 getEventViewerDialog()->setSyncMode( true ); 1539 getEventViewerDialog()->setSyncMode( true );
1540 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1540 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1541 getEventViewerDialog()->setSyncMode( false ); 1541 getEventViewerDialog()->setSyncMode( false );
1542 qApp->processEvents(); 1542 qApp->processEvents();
1543 if ( syncOK ) { 1543 if ( syncOK ) {
1544 if ( mSyncManager->mWriteBackFile ) 1544 if ( mSyncManager->mWriteBackFile )
1545 { 1545 {
1546 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1546 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1547 Incidence* inc = iL.first(); 1547 Incidence* inc = iL.first();
1548 if ( phoneFormat ) { 1548 if ( phoneFormat ) {
1549 while ( inc ) { 1549 while ( inc ) {
1550 inc->removeID(mCurrentSyncDevice); 1550 inc->removeID(mCurrentSyncDevice);
1551 inc = iL.next(); 1551 inc = iL.next();
1552 } 1552 }
1553 } 1553 }
1554#ifndef DESKTOP_VERSION 1554#ifndef DESKTOP_VERSION
1555 if ( sharpFormat ) 1555 if ( sharpFormat )
1556 sharpFormat->save(calendar); 1556 sharpFormat->save(calendar);
1557#endif 1557#endif
1558 if ( phoneFormat ) 1558 if ( phoneFormat )
1559 phoneFormat->save(calendar); 1559 phoneFormat->save(calendar);
1560 iL = calendar->rawIncidences(); 1560 iL = calendar->rawIncidences();
1561 inc = iL.first(); 1561 inc = iL.first();
1562 Incidence* loc; 1562 Incidence* loc;
1563 while ( inc ) { 1563 while ( inc ) {
1564 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1564 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1565 loc = mCalendar->incidence(inc->uid() ); 1565 loc = mCalendar->incidence(inc->uid() );
1566 if ( loc ) { 1566 if ( loc ) {
1567 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1567 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1568 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1568 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1569 } 1569 }
1570 } 1570 }
1571 inc = iL.next(); 1571 inc = iL.next();
1572 } 1572 }
1573 Incidence* lse = getLastSyncEvent(); 1573 Incidence* lse = getLastSyncEvent();
1574 if ( lse ) { 1574 if ( lse ) {
1575 lse->setReadOnly( false ); 1575 lse->setReadOnly( false );
1576 lse->setDescription( "" ); 1576 lse->setDescription( "" );
1577 lse->setReadOnly( true ); 1577 lse->setReadOnly( true );
1578 } 1578 }
1579 } 1579 }
1580 } else { 1580 } else {
1581 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 1581 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
1582 } 1582 }
1583 setModified( true ); 1583 setModified( true );
1584 } else { 1584 } else {
1585 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1585 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1586 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1586 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1587 question, i18n("Ok")) ; 1587 question, i18n("Ok")) ;
1588 1588
1589 } 1589 }
1590 delete calendar; 1590 delete calendar;
1591 updateView(); 1591 updateView();
1592 emit tempDisableBR(false); 1592 emit tempDisableBR(false);
1593 return ;//syncOK; 1593 return ;//syncOK;
1594 1594
1595} 1595}
1596 1596
1597bool CalendarView::importBday() 1597bool CalendarView::importBday()
1598{ 1598{
1599#ifndef KORG_NOKABC 1599#ifndef KORG_NOKABC
1600 1600
1601#ifdef DESKTOP_VERSION 1601#ifdef DESKTOP_VERSION
1602 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1602 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1603 KABC::AddressBook::Iterator it; 1603 KABC::AddressBook::Iterator it;
1604 int count = 0; 1604 int count = 0;
1605 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1605 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1606 ++count; 1606 ++count;
1607 } 1607 }
1608 QProgressBar bar(count,0 ); 1608 QProgressBar bar(count,0 );
1609 int w = 300; 1609 int w = 300;
1610 if ( QApplication::desktop()->width() < 320 ) 1610 if ( QApplication::desktop()->width() < 320 )
1611 w = 220; 1611 w = 220;
1612 int h = bar.sizeHint().height() ; 1612 int h = bar.sizeHint().height() ;
1613 int dw = QApplication::desktop()->width(); 1613 int dw = QApplication::desktop()->width();
1614 int dh = QApplication::desktop()->height(); 1614 int dh = QApplication::desktop()->height();
1615 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1615 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1616 bar.show(); 1616 bar.show();
1617 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1617 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1618 qApp->processEvents(); 1618 qApp->processEvents();
1619 count = 0; 1619 count = 0;
1620 int addCount = 0; 1620 int addCount = 0;
1621 KCal::Attendee* a = 0; 1621 KCal::Attendee* a = 0;
1622 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1622 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1623 if ( ! bar.isVisible() ) 1623 if ( ! bar.isVisible() )
1624 return false; 1624 return false;
1625 bar.setProgress( count++ ); 1625 bar.setProgress( count++ );
1626 qApp->processEvents(); 1626 qApp->processEvents();
1627 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1627 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1628 if ( (*it).birthday().date().isValid() ){ 1628 if ( (*it).birthday().date().isValid() ){
1629 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1629 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1630 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1630 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1631 ++addCount; 1631 ++addCount;
1632 } 1632 }
1633 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1633 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1634 if ( anni.isValid() ){ 1634 if ( anni.isValid() ){
1635 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1635 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1636 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1636 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1637 ++addCount; 1637 ++addCount;
1638 } 1638 }
1639 } 1639 }
1640 updateView(); 1640 updateView();
1641 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1641 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1642#else //DESKTOP_VERSION 1642#else //DESKTOP_VERSION
1643 1643
1644 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1644 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1645 // the result should now arrive through method insertBirthdays 1645 // the result should now arrive through method insertBirthdays
1646 1646
1647#endif //DESKTOP_VERSION 1647#endif //DESKTOP_VERSION
1648 1648
1649#endif //KORG_NOKABC 1649#endif //KORG_NOKABC
1650 1650
1651 1651
1652 return true; 1652 return true;
1653} 1653}
1654 1654
1655// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1655// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1656void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1656void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1657 const QStringList& anniversaryList, const QStringList& realNameList, 1657 const QStringList& anniversaryList, const QStringList& realNameList,
1658 const QStringList& emailList, const QStringList& assembledNameList, 1658 const QStringList& emailList, const QStringList& assembledNameList,
1659 const QStringList& uidList) 1659 const QStringList& uidList)
1660{ 1660{
1661 //qDebug("KO::CalendarView::insertBirthdays"); 1661 //qDebug("KO::CalendarView::insertBirthdays");
1662 if (uid == this->name()) 1662 if (uid == this->name())
1663 { 1663 {
1664 int count = birthdayList.count(); 1664 int count = birthdayList.count();
1665 int addCount = 0; 1665 int addCount = 0;
1666 KCal::Attendee* a = 0; 1666 KCal::Attendee* a = 0;
1667 1667
1668 //qDebug("CalView 1 %i", count); 1668 //qDebug("CalView 1 %i", count);
1669 1669
1670 QProgressBar bar(count,0 ); 1670 QProgressBar bar(count,0 );
1671 int w = 300; 1671 int w = 300;
1672 if ( QApplication::desktop()->width() < 320 ) 1672 if ( QApplication::desktop()->width() < 320 )
1673 w = 220; 1673 w = 220;
1674 int h = bar.sizeHint().height() ; 1674 int h = bar.sizeHint().height() ;
1675 int dw = QApplication::desktop()->width(); 1675 int dw = QApplication::desktop()->width();
1676 int dh = QApplication::desktop()->height(); 1676 int dh = QApplication::desktop()->height();
1677 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1677 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1678 bar.show(); 1678 bar.show();
1679 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1679 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1680 qApp->processEvents(); 1680 qApp->processEvents();
1681 1681
1682 QDate birthday; 1682 QDate birthday;
1683 QDate anniversary; 1683 QDate anniversary;
1684 QString realName; 1684 QString realName;
1685 QString email; 1685 QString email;
1686 QString assembledName; 1686 QString assembledName;
1687 QString uid; 1687 QString uid;
1688 bool ok = true; 1688 bool ok = true;
1689 for ( int i = 0; i < count; i++) 1689 for ( int i = 0; i < count; i++)
1690 { 1690 {
1691 if ( ! bar.isVisible() ) 1691 if ( ! bar.isVisible() )
1692 return; 1692 return;
1693 bar.setProgress( i ); 1693 bar.setProgress( i );
1694 qApp->processEvents(); 1694 qApp->processEvents();
1695 1695
1696 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1696 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1697 if (!ok) { 1697 if (!ok) {
1698 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1698 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1699 } 1699 }
1700 1700
1701 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1701 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1702 if (!ok) { 1702 if (!ok) {
1703 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1703 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1704 } 1704 }
1705 realName = realNameList[i]; 1705 realName = realNameList[i];
1706 email = emailList[i]; 1706 email = emailList[i];
1707 assembledName = assembledNameList[i]; 1707 assembledName = assembledNameList[i];
1708 uid = uidList[i]; 1708 uid = uidList[i];
1709 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); 1709 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() );
1710 1710
1711 if ( birthday.isValid() ){ 1711 if ( birthday.isValid() ){
1712 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1712 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1713 KCal::Attendee::ReqParticipant,uid) ; 1713 KCal::Attendee::ReqParticipant,uid) ;
1714 if ( addAnniversary( birthday, assembledName, a, true ) ) 1714 if ( addAnniversary( birthday, assembledName, a, true ) )
1715 ++addCount; 1715 ++addCount;
1716 } 1716 }
1717 1717
1718 if ( anniversary.isValid() ){ 1718 if ( anniversary.isValid() ){
1719 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1719 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1720 KCal::Attendee::ReqParticipant,uid) ; 1720 KCal::Attendee::ReqParticipant,uid) ;
1721 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1721 if ( addAnniversary( anniversary, assembledName, a, false ) )
1722 ++addCount; 1722 ++addCount;
1723 } 1723 }
1724 } 1724 }
1725 1725
1726 updateView(); 1726 updateView();
1727 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1727 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1728 1728
1729 } 1729 }
1730 1730
1731} 1731}
1732 1732
1733 1733
1734 1734
1735bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1735bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1736{ 1736{
1737 //qDebug("addAnni "); 1737 //qDebug("addAnni ");
1738 Event * ev = new Event(); 1738 Event * ev = new Event();
1739 ev->setOrganizer(KOPrefs::instance()->email()); 1739 ev->setOrganizer(KOPrefs::instance()->email());
1740 if ( a ) { 1740 if ( a ) {
1741 ev->addAttendee( a ); 1741 ev->addAttendee( a );
1742 } 1742 }
1743 QString kind; 1743 QString kind;
1744 if ( birthday ) { 1744 if ( birthday ) {
1745 kind = i18n( "Birthday" ); 1745 kind = i18n( "Birthday" );
1746 ev->setSummary( name + " (" + QString::number(date.year()) +")"); 1746 ev->setSummary( name + " (" + QString::number(date.year()) +")");
1747 } 1747 }
1748 else { 1748 else {
1749 kind = i18n( "Anniversary" ); 1749 kind = i18n( "Anniversary" );
1750 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); 1750 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
1751 } 1751 }
1752 ev->setCategories( kind ); 1752 ev->setCategories( kind );
1753 ev->setDtStart( QDateTime(date) ); 1753 ev->setDtStart( QDateTime(date) );
1754 ev->setDtEnd( QDateTime(date) ); 1754 ev->setDtEnd( QDateTime(date) );
1755 ev->setFloats( true ); 1755 ev->setFloats( true );
1756 Recurrence * rec = ev->recurrence(); 1756 Recurrence * rec = ev->recurrence();
1757 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1757 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1758 rec->addYearlyNum( date.month() ); 1758 rec->addYearlyNum( date.month() );
1759 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1759 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1760 delete ev; 1760 delete ev;
1761 return false; 1761 return false;
1762 } 1762 }
1763 return true; 1763 return true;
1764 1764
1765} 1765}
1766bool CalendarView::importQtopia( const QString &categories, 1766bool CalendarView::importQtopia( const QString &categories,
1767 const QString &datebook, 1767 const QString &datebook,
1768 const QString &todolist ) 1768 const QString &todolist )
1769{ 1769{
1770 1770
1771 QtopiaFormat qtopiaFormat; 1771 QtopiaFormat qtopiaFormat;
1772 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1772 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1773 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1773 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1774 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1774 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1775 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1775 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1776 1776
1777 updateView(); 1777 updateView();
1778 return true; 1778 return true;
1779 1779
1780#if 0 1780#if 0
1781 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1781 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1782 mCurrentSyncDevice = "qtopia-XML"; 1782 mCurrentSyncDevice = "qtopia-XML";
1783 if ( mSyncManager->mAskForPreferences ) 1783 if ( mSyncManager->mAskForPreferences )
1784 edit_sync_options(); 1784 edit_sync_options();
1785 qApp->processEvents(); 1785 qApp->processEvents();
1786 CalendarLocal* calendar = new CalendarLocal(); 1786 CalendarLocal* calendar = new CalendarLocal();
1787 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1787 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1788 bool syncOK = false; 1788 bool syncOK = false;
1789 QtopiaFormat qtopiaFormat; 1789 QtopiaFormat qtopiaFormat;
1790 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1790 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1791 bool loadOk = true; 1791 bool loadOk = true;
1792 if ( !categories.isEmpty() ) 1792 if ( !categories.isEmpty() )
1793 loadOk = qtopiaFormat.load( calendar, categories ); 1793 loadOk = qtopiaFormat.load( calendar, categories );
1794 if ( loadOk && !datebook.isEmpty() ) 1794 if ( loadOk && !datebook.isEmpty() )
1795 loadOk = qtopiaFormat.load( calendar, datebook ); 1795 loadOk = qtopiaFormat.load( calendar, datebook );
1796 if ( loadOk && !todolist.isEmpty() ) 1796 if ( loadOk && !todolist.isEmpty() )
1797 loadOk = qtopiaFormat.load( calendar, todolist ); 1797 loadOk = qtopiaFormat.load( calendar, todolist );
1798 1798
1799 if ( loadOk ) { 1799 if ( loadOk ) {
1800 getEventViewerDialog()->setSyncMode( true ); 1800 getEventViewerDialog()->setSyncMode( true );
1801 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1801 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1802 getEventViewerDialog()->setSyncMode( false ); 1802 getEventViewerDialog()->setSyncMode( false );
1803 qApp->processEvents(); 1803 qApp->processEvents();
1804 if ( syncOK ) { 1804 if ( syncOK ) {
1805 if ( mSyncManager->mWriteBackFile ) 1805 if ( mSyncManager->mWriteBackFile )
1806 { 1806 {
1807 // write back XML file 1807 // write back XML file
1808 1808
1809 } 1809 }
1810 setModified( true ); 1810 setModified( true );
1811 } 1811 }
1812 } else { 1812 } else {
1813 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1813 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1814 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1814 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1815 question, i18n("Ok")) ; 1815 question, i18n("Ok")) ;
1816 } 1816 }
1817 delete calendar; 1817 delete calendar;
1818 updateView(); 1818 updateView();
1819 return syncOK; 1819 return syncOK;
1820 1820
1821 1821
1822#endif 1822#endif
1823 1823
1824} 1824}
1825 1825
1826void CalendarView::setSyncEventsReadOnly() 1826void CalendarView::setSyncEventsReadOnly()
1827{ 1827{
1828 Event * ev; 1828 Event * ev;
1829 QPtrList<Event> eL = mCalendar->rawEvents(); 1829 QPtrList<Event> eL = mCalendar->rawEvents();
1830 ev = eL.first(); 1830 ev = eL.first();
1831 while ( ev ) { 1831 while ( ev ) {
1832 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1832 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1833 ev->setReadOnly( true ); 1833 ev->setReadOnly( true );
1834 ev = eL.next(); 1834 ev = eL.next();
1835 } 1835 }
1836} 1836}
1837bool CalendarView::openCalendar(QString filename, bool merge) 1837bool CalendarView::openCalendar(QString filename, bool merge)
1838{ 1838{
1839 1839
1840 if (filename.isEmpty()) { 1840 if (filename.isEmpty()) {
1841 return false; 1841 return false;
1842 } 1842 }
1843 1843
1844 if (!QFile::exists(filename)) { 1844 if (!QFile::exists(filename)) {
1845 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1845 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1846 return false; 1846 return false;
1847 } 1847 }
1848 1848
1849 globalFlagBlockAgenda = 1; 1849 globalFlagBlockAgenda = 1;
1850 clearAllViews(); 1850 clearAllViews();
1851 if (!merge) { 1851 if (!merge) {
1852 mViewManager->setDocumentId( filename ); 1852 mViewManager->setDocumentId( filename );
1853 mCalendar->close(); 1853 mCalendar->close();
1854 } 1854 }
1855 mStorage->setFileName( filename ); 1855 mStorage->setFileName( filename );
1856 1856
1857 if ( mStorage->load() ) { 1857 if ( mStorage->load() ) {
1858 if ( merge ) ;//setModified( true ); 1858 if ( merge ) ;//setModified( true );
1859 else { 1859 else {
1860 //setModified( true ); 1860 //setModified( true );
1861 mViewManager->setDocumentId( filename ); 1861 mViewManager->setDocumentId( filename );
1862 mDialogManager->setDocumentId( filename ); 1862 mDialogManager->setDocumentId( filename );
1863 mTodoList->setDocumentId( filename ); 1863 mTodoList->setDocumentId( filename );
1864 } 1864 }
1865 globalFlagBlockAgenda = 2; 1865 globalFlagBlockAgenda = 2;
1866 // if ( getLastSyncEvent() ) 1866 // if ( getLastSyncEvent() )
1867 // getLastSyncEvent()->setReadOnly( true ); 1867 // getLastSyncEvent()->setReadOnly( true );
1868 mCalendar->reInitAlarmSettings(); 1868 mCalendar->reInitAlarmSettings();
1869 setSyncEventsReadOnly(); 1869 setSyncEventsReadOnly();
1870 updateUnmanagedViews(); 1870 updateUnmanagedViews();
1871 updateView(); 1871 updateView();
1872 if ( filename != MainWindow::defaultFileName() ) { 1872 if ( filename != MainWindow::defaultFileName() ) {
1873 saveCalendar( MainWindow::defaultFileName() ); 1873 saveCalendar( MainWindow::defaultFileName() );
1874 } else { 1874 } else {
1875 QFileInfo finf ( MainWindow::defaultFileName()); 1875 QFileInfo finf ( MainWindow::defaultFileName());
1876 if ( finf.exists() ) { 1876 if ( finf.exists() ) {
1877 setLoadedFileVersion( finf.lastModified () ); 1877 setLoadedFileVersion( finf.lastModified () );
1878 } 1878 }
1879 } 1879 }
1880 return true; 1880 return true;
1881 } else { 1881 } else {
1882 // while failing to load, the calendar object could 1882 // while failing to load, the calendar object could
1883 // have become partially populated. Clear it out. 1883 // have become partially populated. Clear it out.
1884 if ( !merge ) { 1884 if ( !merge ) {
1885 mCalendar->close(); 1885 mCalendar->close();
1886 mViewManager->setDocumentId( filename ); 1886 mViewManager->setDocumentId( filename );
1887 mDialogManager->setDocumentId( filename ); 1887 mDialogManager->setDocumentId( filename );
1888 mTodoList->setDocumentId( filename ); 1888 mTodoList->setDocumentId( filename );
1889 } 1889 }
1890 1890
1891 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1891 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1892 1892
1893 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1893 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1894 globalFlagBlockAgenda = 2; 1894 globalFlagBlockAgenda = 2;
1895 mCalendar->reInitAlarmSettings(); 1895 mCalendar->reInitAlarmSettings();
1896 setSyncEventsReadOnly(); 1896 setSyncEventsReadOnly();
1897 updateUnmanagedViews(); 1897 updateUnmanagedViews();
1898 updateView(); 1898 updateView();
1899 } 1899 }
1900 return false; 1900 return false;
1901} 1901}
1902void CalendarView::showOpenError() 1902void CalendarView::showOpenError()
1903{ 1903{
1904 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1904 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1905} 1905}
1906void CalendarView::setLoadedFileVersion(QDateTime dt) 1906void CalendarView::setLoadedFileVersion(QDateTime dt)
1907{ 1907{
1908 loadedFileVersion = dt; 1908 loadedFileVersion = dt;
1909} 1909}
1910bool CalendarView::checkFileChanged(QString fn) 1910bool CalendarView::checkFileChanged(QString fn)
1911{ 1911{
1912 QFileInfo finf ( fn ); 1912 QFileInfo finf ( fn );
1913 if ( !finf.exists() ) 1913 if ( !finf.exists() )
1914 return true; 1914 return true;
1915 QDateTime dt = finf.lastModified (); 1915 QDateTime dt = finf.lastModified ();
1916 if ( dt <= loadedFileVersion ) 1916 if ( dt <= loadedFileVersion )
1917 return false; 1917 return false;
1918 return true; 1918 return true;
1919 1919
1920} 1920}
1921void CalendarView::watchSavedFile() 1921void CalendarView::watchSavedFile()
1922{ 1922{
1923 QFileInfo finf ( MainWindow::defaultFileName()); 1923 QFileInfo finf ( MainWindow::defaultFileName());
1924 if ( !finf.exists() ) 1924 if ( !finf.exists() )
1925 return; 1925 return;
1926 QDateTime dt = finf.lastModified (); 1926 QDateTime dt = finf.lastModified ();
1927 if ( dt < loadedFileVersion ) { 1927 if ( dt < loadedFileVersion ) {
1928 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1928 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1929 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1929 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1930 return; 1930 return;
1931 } 1931 }
1932 loadedFileVersion = dt; 1932 loadedFileVersion = dt;
1933} 1933}
1934 1934
1935bool CalendarView::checkFileVersion(QString fn) 1935bool CalendarView::checkFileVersion(QString fn)
1936{ 1936{
1937 QFileInfo finf ( fn ); 1937 QFileInfo finf ( fn );
1938 if ( !finf.exists() ) 1938 if ( !finf.exists() )
1939 return true; 1939 return true;
1940 QDateTime dt = finf.lastModified (); 1940 QDateTime dt = finf.lastModified ();
1941 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1941 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1942 //qDebug("file on disk version %s",dt.toString().latin1()); 1942 //qDebug("file on disk version %s",dt.toString().latin1());
1943 if ( dt <= loadedFileVersion ) 1943 if ( dt <= loadedFileVersion )
1944 return true; 1944 return true;
1945 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 1945 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
1946 i18n("KO/Pi Warning"),i18n("Overwrite"), 1946 i18n("KO/Pi Warning"),i18n("Overwrite"),
1947 i18n("Sync+save")); 1947 i18n("Sync+save"));
1948 1948
1949 if ( km == KMessageBox::Cancel ) 1949 if ( km == KMessageBox::Cancel )
1950 return false; 1950 return false;
1951 if ( km == KMessageBox::Yes ) 1951 if ( km == KMessageBox::Yes )
1952 return true; 1952 return true;
1953 1953
1954 setSyncDevice("deleteaftersync" ); 1954 setSyncDevice("deleteaftersync" );
1955 mSyncManager->mAskForPreferences = true; 1955 mSyncManager->mAskForPreferences = true;
1956 mSyncManager->mSyncAlgoPrefs = 3; 1956 mSyncManager->mSyncAlgoPrefs = 3;
1957 mSyncManager->mWriteBackFile = false; 1957 mSyncManager->mWriteBackFile = false;
1958 mSyncManager->mWriteBackExistingOnly = false; 1958 mSyncManager->mWriteBackExistingOnly = false;
1959 mSyncManager->mShowSyncSummary = false; 1959 mSyncManager->mShowSyncSummary = false;
1960 syncCalendar( fn, 3 ); 1960 syncCalendar( fn, 3 );
1961 Event * e = getLastSyncEvent(); 1961 Event * e = getLastSyncEvent();
1962 if ( e ) 1962 if ( e )
1963 deleteEvent ( e ); 1963 deleteEvent ( e );
1964 updateView(); 1964 updateView();
1965 return true; 1965 return true;
1966} 1966}
1967 1967
1968bool CalendarView::saveCalendar( QString filename ) 1968bool CalendarView::saveCalendar( QString filename )
1969{ 1969{
1970 1970
1971 // Store back all unsaved data into calendar object 1971 // Store back all unsaved data into calendar object
1972 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1972 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1973 if ( mViewManager->currentView() ) 1973 if ( mViewManager->currentView() )
1974 mViewManager->currentView()->flushView(); 1974 mViewManager->currentView()->flushView();
1975 1975
1976 1976
1977 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 1977 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
1978 mStorage->setSaveFormat( new ICalFormat() ); 1978 mStorage->setSaveFormat( new ICalFormat() );
1979 mStorage->setFileName( filename ); 1979 mStorage->setFileName( filename );
1980 bool success; 1980 bool success;
1981 success = mStorage->save(); 1981 success = mStorage->save();
1982 if ( !success ) { 1982 if ( !success ) {
1983 return false; 1983 return false;
1984 } 1984 }
1985 if ( filename == MainWindow::defaultFileName() ) { 1985 if ( filename == MainWindow::defaultFileName() ) {
1986 setLoadedFileVersion( lfv ); 1986 setLoadedFileVersion( lfv );
1987 watchSavedFile(); 1987 watchSavedFile();
1988 } 1988 }
1989 return true; 1989 return true;
1990} 1990}
1991 1991
1992void CalendarView::closeCalendar() 1992void CalendarView::closeCalendar()
1993{ 1993{
1994 1994
1995 // child windows no longer valid 1995 // child windows no longer valid
1996 clearAllViews(); 1996 clearAllViews();
1997 emit closingDown(); 1997 emit closingDown();
1998 1998
1999 mCalendar->close(); 1999 mCalendar->close();
2000 setModified(false); 2000 setModified(false);
2001 updateView(); 2001 updateView();
2002} 2002}
2003 2003
2004void CalendarView::archiveCalendar() 2004void CalendarView::archiveCalendar()
2005{ 2005{
2006 mDialogManager->showArchiveDialog(); 2006 mDialogManager->showArchiveDialog();
2007} 2007}
2008 2008
2009 2009
2010void CalendarView::readSettings() 2010void CalendarView::readSettings()
2011{ 2011{
2012 2012
2013 2013
2014 // mViewManager->showAgendaView(); 2014 // mViewManager->showAgendaView();
2015 QString str; 2015 QString str;
2016 //qDebug("CalendarView::readSettings() "); 2016 //qDebug("CalendarView::readSettings() ");
2017 // read settings from the KConfig, supplying reasonable 2017 // read settings from the KConfig, supplying reasonable
2018 // defaults where none are to be found 2018 // defaults where none are to be found
2019 KConfig *config = KOGlobals::config(); 2019 KConfig *config = KOGlobals::config();
2020#ifndef KORG_NOSPLITTER 2020#ifndef KORG_NOSPLITTER
2021 config->setGroup("KOrganizer Geometry"); 2021 config->setGroup("KOrganizer Geometry");
2022 2022
2023 QValueList<int> sizes = config->readIntListEntry("Separator1"); 2023 QValueList<int> sizes = config->readIntListEntry("Separator1");
2024 if (sizes.count() != 2) { 2024 if (sizes.count() != 2) {
2025 sizes << mDateNavigator->minimumSizeHint().width(); 2025 sizes << mDateNavigator->minimumSizeHint().width();
2026 sizes << 300; 2026 sizes << 300;
2027 } 2027 }
2028 mPanner->setSizes(sizes); 2028 mPanner->setSizes(sizes);
2029 2029
2030 sizes = config->readIntListEntry("Separator2"); 2030 sizes = config->readIntListEntry("Separator2");
2031 if ( ( mResourceView && sizes.count() == 4 ) || 2031 if ( ( mResourceView && sizes.count() == 4 ) ||
2032 ( !mResourceView && sizes.count() == 3 ) ) { 2032 ( !mResourceView && sizes.count() == 3 ) ) {
2033 mLeftSplitter->setSizes(sizes); 2033 mLeftSplitter->setSizes(sizes);
2034 } 2034 }
2035#endif 2035#endif
2036 globalFlagBlockAgenda = 1; 2036 globalFlagBlockAgenda = 1;
2037 mViewManager->showAgendaView(); 2037 mViewManager->showAgendaView();
2038 //mViewManager->readSettings( config ); 2038 //mViewManager->readSettings( config );
2039 mTodoList->restoreLayout(config,QString("Todo Layout")); 2039 mTodoList->restoreLayout(config,QString("Todo Layout"));
2040 readFilterSettings(config); 2040 readFilterSettings(config);
2041 2041
2042#ifdef DESKTOP_VERSION 2042#ifdef DESKTOP_VERSION
2043 config->setGroup("WidgetLayout"); 2043 config->setGroup("WidgetLayout");
2044 QStringList list; 2044 QStringList list;
2045 list = config->readListEntry("MainLayout"); 2045 list = config->readListEntry("MainLayout");
2046 int x,y,w,h; 2046 int x,y,w,h;
2047 if ( ! list.isEmpty() ) { 2047 if ( ! list.isEmpty() ) {
2048 x = list[0].toInt(); 2048 x = list[0].toInt();
2049 y = list[1].toInt(); 2049 y = list[1].toInt();
2050 w = list[2].toInt(); 2050 w = list[2].toInt();
2051 h = list[3].toInt(); 2051 h = list[3].toInt();
2052 KApplication::testCoords( &x,&y,&w,&h ); 2052 KApplication::testCoords( &x,&y,&w,&h );
2053 topLevelWidget()->setGeometry(x,y,w,h); 2053 topLevelWidget()->setGeometry(x,y,w,h);
2054 2054
2055 } else { 2055 } else {
2056 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 2056 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
2057 } 2057 }
2058 list = config->readListEntry("EditEventLayout"); 2058 list = config->readListEntry("EditEventLayout");
2059 if ( ! list.isEmpty() ) { 2059 if ( ! list.isEmpty() ) {
2060 x = list[0].toInt(); 2060 x = list[0].toInt();
2061 y = list[1].toInt(); 2061 y = list[1].toInt();
2062 w = list[2].toInt(); 2062 w = list[2].toInt();
2063 h = list[3].toInt(); 2063 h = list[3].toInt();
2064 KApplication::testCoords( &x,&y,&w,&h ); 2064 KApplication::testCoords( &x,&y,&w,&h );
2065 mEventEditor->setGeometry(x,y,w,h); 2065 mEventEditor->setGeometry(x,y,w,h);
2066 2066
2067 } 2067 }
2068 list = config->readListEntry("EditTodoLayout"); 2068 list = config->readListEntry("EditTodoLayout");
2069 if ( ! list.isEmpty() ) { 2069 if ( ! list.isEmpty() ) {
2070 x = list[0].toInt(); 2070 x = list[0].toInt();
2071 y = list[1].toInt(); 2071 y = list[1].toInt();
2072 w = list[2].toInt(); 2072 w = list[2].toInt();
2073 h = list[3].toInt(); 2073 h = list[3].toInt();
2074 KApplication::testCoords( &x,&y,&w,&h ); 2074 KApplication::testCoords( &x,&y,&w,&h );
2075 mTodoEditor->setGeometry(x,y,w,h); 2075 mTodoEditor->setGeometry(x,y,w,h);
2076 2076
2077 } 2077 }
2078 list = config->readListEntry("ViewerLayout"); 2078 list = config->readListEntry("ViewerLayout");
2079 if ( ! list.isEmpty() ) { 2079 if ( ! list.isEmpty() ) {
2080 x = list[0].toInt(); 2080 x = list[0].toInt();
2081 y = list[1].toInt(); 2081 y = list[1].toInt();
2082 w = list[2].toInt(); 2082 w = list[2].toInt();
2083 h = list[3].toInt(); 2083 h = list[3].toInt();
2084 KApplication::testCoords( &x,&y,&w,&h ); 2084 KApplication::testCoords( &x,&y,&w,&h );
2085 getEventViewerDialog()->setGeometry(x,y,w,h); 2085 getEventViewerDialog()->setGeometry(x,y,w,h);
2086 } 2086 }
2087#endif 2087#endif
2088 config->setGroup( "Views" ); 2088 config->setGroup( "Views" );
2089 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 2089 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
2090 2090
2091 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); 2091 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame");
2092 2092
2093 int resetval = 0; 2093 int resetval = 0;
2094 int maxVal = 0; 2094 int maxVal = 0;
2095 if (sizes.count() != 3) { 2095 if (sizes.count() != 3) {
2096 if ( KOPrefs::instance()->mVerticalScreen ) { 2096 if ( KOPrefs::instance()->mVerticalScreen ) {
2097 resetval = mDateNavigator->sizeHint().width()+2; 2097 resetval = mDateNavigator->sizeHint().width()+2;
2098 } else { 2098 } else {
2099 resetval = mDateNavigator->sizeHint().height()+2; 2099 resetval = mDateNavigator->sizeHint().height()+2;
2100 } 2100 }
2101 } 2101 }
2102 if ( resetval ) { 2102 if ( resetval ) {
2103 sizes.clear(); 2103 sizes.clear();
2104 if ( KOPrefs::instance()->mVerticalScreen ) { 2104 if ( KOPrefs::instance()->mVerticalScreen ) {
2105 maxVal = QApplication::desktop()->width() -10; 2105 maxVal = QApplication::desktop()->width() -10;
2106 } else { 2106 } else {
2107 maxVal = QApplication::desktop()->height()-10; 2107 maxVal = QApplication::desktop()->height()-10;
2108 } 2108 }
2109 sizes << resetval; 2109 sizes << resetval;
2110 if ( maxVal < resetval + resetval) 2110 if ( maxVal < resetval + resetval)
2111 resetval = maxVal - resetval; 2111 resetval = maxVal - resetval;
2112 sizes << resetval; 2112 sizes << resetval;
2113 sizes << 100; 2113 sizes << 100;
2114 } 2114 }
2115 mLeftFrame->setSizes(sizes); 2115 mLeftFrame->setSizes(sizes);
2116 sizes = config->readIntListEntry("Main Splitter Frame"); 2116 sizes = config->readIntListEntry("Main Splitter Frame");
2117 resetval = 0; 2117 resetval = 0;
2118 maxVal = 0; 2118 maxVal = 0;
2119 if (sizes.count() != 2) { 2119 if (sizes.count() != 2) {
2120 if ( !KOPrefs::instance()->mVerticalScreen ) { 2120 if ( !KOPrefs::instance()->mVerticalScreen ) {
2121 resetval = mDateNavigator->sizeHint().width()+2; 2121 resetval = mDateNavigator->sizeHint().width()+2;
2122 } else { 2122 } else {
2123 resetval = mDateNavigator->sizeHint().height()+2; 2123 resetval = mDateNavigator->sizeHint().height()+2;
2124 } 2124 }
2125 } 2125 }
2126 if ( resetval ) { 2126 if ( resetval ) {
2127 sizes.clear(); 2127 sizes.clear();
2128 if ( !KOPrefs::instance()->mVerticalScreen ) { 2128 if ( !KOPrefs::instance()->mVerticalScreen ) {
2129 maxVal = QApplication::desktop()->width() -10; 2129 maxVal = QApplication::desktop()->width() -10;
2130 } else { 2130 } else {
2131 maxVal = QApplication::desktop()->height()-10; 2131 maxVal = QApplication::desktop()->height()-10;
2132 } 2132 }
2133 sizes << resetval; 2133 sizes << resetval;
2134 if ( maxVal < resetval + resetval) 2134 if ( maxVal < resetval + resetval)
2135 resetval = maxVal - resetval; 2135 resetval = maxVal - resetval;
2136 sizes << resetval; 2136 sizes << resetval;
2137 } 2137 }
2138 mMainFrame->setSizes(sizes); 2138 mMainFrame->setSizes(sizes);
2139 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 2139 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
2140 else if ( dateCount == 7 ) mNavigator->selectWeek(); 2140 else if ( dateCount == 7 ) mNavigator->selectWeek();
2141 else mNavigator->selectDates( dateCount ); 2141 else mNavigator->selectDates( dateCount );
2142 // mViewManager->readSettings( config ); 2142 // mViewManager->readSettings( config );
2143 updateConfig(); 2143 updateConfig();
2144 globalFlagBlockAgenda = 2; 2144 globalFlagBlockAgenda = 2;
2145 mViewManager->readSettings( config ); 2145 mViewManager->readSettings( config );
2146 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); 2146 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) );
2147} 2147}
2148 2148
2149 2149
2150void CalendarView::writeSettings() 2150void CalendarView::writeSettings()
2151{ 2151{
2152 // kdDebug() << "CalendarView::writeSettings" << endl; 2152 // kdDebug() << "CalendarView::writeSettings" << endl;
2153 2153
2154 KConfig *config = KOGlobals::config(); 2154 KConfig *config = KOGlobals::config();
2155 2155
2156 mViewManager->writeSettings( config ); 2156 mViewManager->writeSettings( config );
2157 mTodoList->saveLayout(config,QString("Todo Layout")); 2157 mTodoList->saveLayout(config,QString("Todo Layout"));
2158 mDialogManager->writeSettings( config ); 2158 mDialogManager->writeSettings( config );
2159 //KOPrefs::instance()->usrWriteConfig(); 2159 //KOPrefs::instance()->usrWriteConfig();
2160 KOPrefs::instance()->writeConfig(); 2160 KOPrefs::instance()->writeConfig();
2161 2161
2162 writeFilterSettings(config); 2162 writeFilterSettings(config);
2163 config->setGroup( "AppRun" ); 2163 config->setGroup( "AppRun" );
2164 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 2164 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
2165 int days = dt.daysTo( QDate::currentDate() ); 2165 int days = dt.daysTo( QDate::currentDate() );
2166 dt = dt.addDays( days ); 2166 dt = dt.addDays( days );
2167 int secs = dt.secsTo( QDateTime::currentDateTime() ); 2167 int secs = dt.secsTo( QDateTime::currentDateTime() );
2168 config->writeEntry( "LatestProgramStopDays", days ); 2168 config->writeEntry( "LatestProgramStopDays", days );
2169 config->writeEntry( "LatestProgramStopSecs", secs ); 2169 config->writeEntry( "LatestProgramStopSecs", secs );
2170 //qDebug("KO: Writing stop time: %d ", secs); 2170 //qDebug("KO: Writing stop time: %d ", secs);
2171 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 2171 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
2172 //QDateTime latest = dt.addSecs ( secs ); 2172 //QDateTime latest = dt.addSecs ( secs );
2173 //qDebug("KO: Termination on %s ", latest.toString().latin1()); 2173 //qDebug("KO: Termination on %s ", latest.toString().latin1());
2174 config->setGroup( "Views" ); 2174 config->setGroup( "Views" );
2175 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 2175 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
2176 2176
2177#if 0 2177#if 0
2178 qDebug("********************* "); 2178 qDebug("********************* ");
2179 qDebug("Testcode secsto "); 2179 qDebug("Testcode secsto ");
2180 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); 2180 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) );
2181 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); 2181 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) );
2182 int secsto = dt_nodaylight.secsTo( dt_daylight ); 2182 int secsto = dt_nodaylight.secsTo( dt_daylight );
2183 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); 2183 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto );
2184 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); 2184 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() );
2185 qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); 2185 qDebug("dt daylight %s ",dt_daylight.toString().latin1() );
2186 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); 2186 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() );
2187 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); 2187 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600);
2188 qDebug("********************* testcode end"); 2188 qDebug("********************* testcode end");
2189 2189
2190#endif 2190#endif
2191 2191
2192 QValueList<int> listINT = mLeftFrame->sizes(); 2192 QValueList<int> listINT = mLeftFrame->sizes();
2193 config->writeEntry("Left Splitter Frame",listINT); 2193 config->writeEntry("Left Splitter Frame",listINT);
2194 QValueList<int> listINT2 = mMainFrame->sizes(); 2194 QValueList<int> listINT2 = mMainFrame->sizes();
2195 config->writeEntry("Main Splitter Frame",listINT2); 2195 config->writeEntry("Main Splitter Frame",listINT2);
2196#ifdef DESKTOP_VERSION 2196#ifdef DESKTOP_VERSION
2197 config->setGroup("WidgetLayout"); 2197 config->setGroup("WidgetLayout");
2198 QStringList list ;//= config->readListEntry("MainLayout"); 2198 QStringList list ;//= config->readListEntry("MainLayout");
2199 int x,y,w,h; 2199 int x,y,w,h;
2200 QWidget* wid; 2200 QWidget* wid;
2201 wid = topLevelWidget(); 2201 wid = topLevelWidget();
2202 x = wid->geometry().x(); 2202 x = wid->geometry().x();
2203 y = wid->geometry().y(); 2203 y = wid->geometry().y();
2204 w = wid->width(); 2204 w = wid->width();
2205 h = wid->height(); 2205 h = wid->height();
2206 list.clear(); 2206 list.clear();
2207 list << QString::number( x ); 2207 list << QString::number( x );
2208 list << QString::number( y ); 2208 list << QString::number( y );
2209 list << QString::number( w ); 2209 list << QString::number( w );
2210 list << QString::number( h ); 2210 list << QString::number( h );
2211 config->writeEntry("MainLayout",list ); 2211 config->writeEntry("MainLayout",list );
2212 2212
2213 wid = mEventEditor; 2213 wid = mEventEditor;
2214 x = wid->geometry().x(); 2214 x = wid->geometry().x();
2215 y = wid->geometry().y(); 2215 y = wid->geometry().y();
2216 w = wid->width(); 2216 w = wid->width();
2217 h = wid->height(); 2217 h = wid->height();
2218 list.clear(); 2218 list.clear();
2219 list << QString::number( x ); 2219 list << QString::number( x );
2220 list << QString::number( y ); 2220 list << QString::number( y );
2221 list << QString::number( w ); 2221 list << QString::number( w );
2222 list << QString::number( h ); 2222 list << QString::number( h );
2223 config->writeEntry("EditEventLayout",list ); 2223 config->writeEntry("EditEventLayout",list );
2224 2224
2225 wid = mTodoEditor; 2225 wid = mTodoEditor;
2226 x = wid->geometry().x(); 2226 x = wid->geometry().x();
2227 y = wid->geometry().y(); 2227 y = wid->geometry().y();
2228 w = wid->width(); 2228 w = wid->width();
2229 h = wid->height(); 2229 h = wid->height();
2230 list.clear(); 2230 list.clear();
2231 list << QString::number( x ); 2231 list << QString::number( x );
2232 list << QString::number( y ); 2232 list << QString::number( y );
2233 list << QString::number( w ); 2233 list << QString::number( w );
2234 list << QString::number( h ); 2234 list << QString::number( h );
2235 config->writeEntry("EditTodoLayout",list ); 2235 config->writeEntry("EditTodoLayout",list );
2236 wid = getEventViewerDialog(); 2236 wid = getEventViewerDialog();
2237 x = wid->geometry().x(); 2237 x = wid->geometry().x();
2238 y = wid->geometry().y(); 2238 y = wid->geometry().y();
2239 w = wid->width(); 2239 w = wid->width();
2240 h = wid->height(); 2240 h = wid->height();
2241 list.clear(); 2241 list.clear();
2242 list << QString::number( x ); 2242 list << QString::number( x );
2243 list << QString::number( y ); 2243 list << QString::number( y );
2244 list << QString::number( w ); 2244 list << QString::number( w );
2245 list << QString::number( h ); 2245 list << QString::number( h );
2246 config->writeEntry("ViewerLayout",list ); 2246 config->writeEntry("ViewerLayout",list );
2247 wid = mDialogManager->getSearchDialog(); 2247 wid = mDialogManager->getSearchDialog();
2248 if ( wid ) { 2248 if ( wid ) {
2249 x = wid->geometry().x(); 2249 x = wid->geometry().x();
2250 y = wid->geometry().y(); 2250 y = wid->geometry().y();
2251 w = wid->width(); 2251 w = wid->width();
2252 h = wid->height(); 2252 h = wid->height();
2253 list.clear(); 2253 list.clear();
2254 list << QString::number( x ); 2254 list << QString::number( x );
2255 list << QString::number( y ); 2255 list << QString::number( y );
2256 list << QString::number( w ); 2256 list << QString::number( w );
2257 list << QString::number( h ); 2257 list << QString::number( h );
2258 config->writeEntry("SearchLayout",list ); 2258 config->writeEntry("SearchLayout",list );
2259 } 2259 }
2260#endif 2260#endif
2261 2261
2262 2262
2263 config->sync(); 2263 config->sync();
2264} 2264}
2265 2265
2266void CalendarView::readFilterSettings(KConfig *config) 2266void CalendarView::readFilterSettings(KConfig *config)
2267{ 2267{
2268 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 2268 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
2269 2269
2270 mFilters.clear(); 2270 mFilters.clear();
2271 2271
2272 config->setGroup("General"); 2272 config->setGroup("General");
2273 QStringList filterList = config->readListEntry("CalendarFilters"); 2273 QStringList filterList = config->readListEntry("CalendarFilters");
2274 2274
2275 QStringList::ConstIterator it = filterList.begin(); 2275 QStringList::ConstIterator it = filterList.begin();
2276 QStringList::ConstIterator end = filterList.end(); 2276 QStringList::ConstIterator end = filterList.end();
2277 while(it != end) { 2277 while(it != end) {
2278 // kdDebug() << " filter: " << (*it) << endl; 2278 // kdDebug() << " filter: " << (*it) << endl;
2279 2279
2280 CalFilter *filter; 2280 CalFilter *filter;
2281 filter = new CalFilter(*it); 2281 filter = new CalFilter(*it);
2282 config->setGroup("Filter_" + (*it).utf8()); 2282 config->setGroup("Filter_" + (*it).utf8());
2283 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 2283 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
2284 filter->setCriteria(config->readNumEntry("Criteria",0)); 2284 filter->setCriteria(config->readNumEntry("Criteria",0));
2285 filter->setCategoryList(config->readListEntry("CategoryList")); 2285 filter->setCategoryList(config->readListEntry("CategoryList"));
2286 mFilters.append(filter); 2286 mFilters.append(filter);
2287 2287
2288 ++it; 2288 ++it;
2289 } 2289 }
2290 2290
2291 if (mFilters.count() == 0) { 2291 if (mFilters.count() == 0) {
2292 CalFilter *filter = new CalFilter(i18n("Default")); 2292 CalFilter *filter = new CalFilter(i18n("Default"));
2293 mFilters.append(filter); 2293 mFilters.append(filter);
2294 } 2294 }
2295 mFilterView->updateFilters(); 2295 mFilterView->updateFilters();
2296 config->setGroup("FilterView"); 2296 config->setGroup("FilterView");
2297 2297
2298 mFilterView->blockSignals(true); 2298 mFilterView->blockSignals(true);
2299 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 2299 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
2300 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 2300 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
2301 mFilterView->blockSignals(false); 2301 mFilterView->blockSignals(false);
2302 // We do it manually to avoid it being done twice by the above calls 2302 // We do it manually to avoid it being done twice by the above calls
2303 updateFilter(); 2303 updateFilter();
2304} 2304}
2305 2305
2306void CalendarView::writeFilterSettings(KConfig *config) 2306void CalendarView::writeFilterSettings(KConfig *config)
2307{ 2307{
2308 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 2308 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
2309 2309
2310 QStringList filterList; 2310 QStringList filterList;
2311 2311
2312 CalFilter *filter = mFilters.first(); 2312 CalFilter *filter = mFilters.first();
2313 while(filter) { 2313 while(filter) {
2314 // kdDebug() << " fn: " << filter->name() << endl; 2314 // kdDebug() << " fn: " << filter->name() << endl;
2315 filterList << filter->name(); 2315 filterList << filter->name();
2316 config->setGroup("Filter_" + filter->name().utf8()); 2316 config->setGroup("Filter_" + filter->name().utf8());
2317 config->writeEntry("Criteria",filter->criteria()); 2317 config->writeEntry("Criteria",filter->criteria());
2318 config->writeEntry("CategoryList",filter->categoryList()); 2318 config->writeEntry("CategoryList",filter->categoryList());
2319 filter = mFilters.next(); 2319 filter = mFilters.next();
2320 } 2320 }
2321 config->setGroup("General"); 2321 config->setGroup("General");
2322 config->writeEntry("CalendarFilters",filterList); 2322 config->writeEntry("CalendarFilters",filterList);
2323 2323
2324 config->setGroup("FilterView"); 2324 config->setGroup("FilterView");
2325 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2325 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
2326 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2326 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
2327} 2327}
2328 2328
2329 2329
2330void CalendarView::goToday() 2330void CalendarView::goToday()
2331{ 2331{
2332 if ( mViewManager->currentView()->isMonthView() ) 2332 if ( mViewManager->currentView()->isMonthView() )
2333 mNavigator->selectTodayMonth(); 2333 mNavigator->selectTodayMonth();
2334 else 2334 else
2335 mNavigator->selectToday(); 2335 mNavigator->selectToday();
2336} 2336}
2337 2337
2338void CalendarView::goNext() 2338void CalendarView::goNext()
2339{ 2339{
2340 mNavigator->selectNext(); 2340 mNavigator->selectNext();
2341} 2341}
2342 2342
2343void CalendarView::goPrevious() 2343void CalendarView::goPrevious()
2344{ 2344{
2345 mNavigator->selectPrevious(); 2345 mNavigator->selectPrevious();
2346} 2346}
2347void CalendarView::goNextMonth() 2347void CalendarView::goNextMonth()
2348{ 2348{
2349 mNavigator->selectNextMonth(); 2349 mNavigator->selectNextMonth();
2350} 2350}
2351 2351
2352void CalendarView::goPreviousMonth() 2352void CalendarView::goPreviousMonth()
2353{ 2353{
2354 mNavigator->selectPreviousMonth(); 2354 mNavigator->selectPreviousMonth();
2355} 2355}
2356void CalendarView::writeLocale() 2356void CalendarView::writeLocale()
2357{ 2357{
2358 //KPimGlobalPrefs::instance()->setGlobalConfig(); 2358 //KPimGlobalPrefs::instance()->setGlobalConfig();
2359#if 0 2359#if 0
2360 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 2360 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
2361 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 2361 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
2362 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 2362 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
2363 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 2363 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
2364 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 2364 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
2365 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 2365 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
2366 dummy = KOPrefs::instance()->mUserDateFormatShort; 2366 dummy = KOPrefs::instance()->mUserDateFormatShort;
2367 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 2367 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
2368 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 2368 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
2369 KOPrefs::instance()->mDaylightsavingStart, 2369 KOPrefs::instance()->mDaylightsavingStart,
2370 KOPrefs::instance()->mDaylightsavingEnd ); 2370 KOPrefs::instance()->mDaylightsavingEnd );
2371 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); 2371 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId );
2372#endif 2372#endif
2373} 2373}
2374void CalendarView::updateConfig() 2374void CalendarView::updateConfig()
2375{ 2375{
2376 writeLocale(); 2376 writeLocale();
2377 if ( KOPrefs::instance()->mUseAppColors ) 2377 if ( KOPrefs::instance()->mUseAppColors )
2378 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2378 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2379 emit configChanged(); 2379 emit configChanged();
2380 mTodoList->updateConfig(); 2380 mTodoList->updateConfig();
2381 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2381 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2382 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2382 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2383 // To make the "fill window" configurations work 2383 // To make the "fill window" configurations work
2384 //mViewManager->raiseCurrentView(); 2384 //mViewManager->raiseCurrentView();
2385} 2385}
2386 2386
2387 2387
2388void CalendarView::eventChanged(Event *event) 2388void CalendarView::eventChanged(Event *event)
2389{ 2389{
2390 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2390 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2391 //updateUnmanagedViews(); 2391 //updateUnmanagedViews();
2392} 2392}
2393 2393
2394void CalendarView::eventAdded(Event *event) 2394void CalendarView::eventAdded(Event *event)
2395{ 2395{
2396 changeEventDisplay(event,KOGlobals::EVENTADDED); 2396 changeEventDisplay(event,KOGlobals::EVENTADDED);
2397} 2397}
2398 2398
2399void CalendarView::eventToBeDeleted(Event *) 2399void CalendarView::eventToBeDeleted(Event *)
2400{ 2400{
2401 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2401 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2402} 2402}
2403 2403
2404void CalendarView::eventDeleted() 2404void CalendarView::eventDeleted()
2405{ 2405{
2406 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2406 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2407} 2407}
2408void CalendarView::changeTodoDisplay(Todo *which, int action) 2408void CalendarView::changeTodoDisplay(Todo *which, int action)
2409{ 2409{
2410 changeIncidenceDisplay((Incidence *)which, action); 2410 changeIncidenceDisplay((Incidence *)which, action);
2411 mDateNavigator->updateView(); //LR 2411 mDateNavigator->updateView(); //LR
2412 //mDialogManager->updateSearchDialog(); 2412 //mDialogManager->updateSearchDialog();
2413 2413
2414 if (which) { 2414 if (which) {
2415 mViewManager->updateWNview(); 2415 mViewManager->updateWNview();
2416 //mTodoList->updateView(); 2416 //mTodoList->updateView();
2417 } 2417 }
2418 2418
2419} 2419}
2420 2420
2421void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2421void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2422{ 2422{
2423 updateUnmanagedViews(); 2423 updateUnmanagedViews();
2424 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2424 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2425 if ( action == KOGlobals::EVENTDELETED ) { //delete 2425 if ( action == KOGlobals::EVENTDELETED ) { //delete
2426 mCalendar->checkAlarmForIncidence( 0, true ); 2426 mCalendar->checkAlarmForIncidence( 0, true );
2427 if ( mEventViewerDialog ) 2427 if ( mEventViewerDialog )
2428 mEventViewerDialog->hide(); 2428 mEventViewerDialog->hide();
2429 } 2429 }
2430 else 2430 else
2431 mCalendar->checkAlarmForIncidence( which , false ); 2431 mCalendar->checkAlarmForIncidence( which , false );
2432} 2432}
2433 2433
2434// most of the changeEventDisplays() right now just call the view's 2434// most of the changeEventDisplays() right now just call the view's
2435// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2435// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2436void CalendarView::changeEventDisplay(Event *which, int action) 2436void CalendarView::changeEventDisplay(Event *which, int action)
2437{ 2437{
2438 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2438 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2439 changeIncidenceDisplay((Incidence *)which, action); 2439 changeIncidenceDisplay((Incidence *)which, action);
2440 mDateNavigator->updateView(); 2440 mDateNavigator->updateView();
2441 //mDialogManager->updateSearchDialog(); 2441 //mDialogManager->updateSearchDialog();
2442 2442
2443 if (which) { 2443 if (which) {
2444 // If there is an event view visible update the display 2444 // If there is an event view visible update the display
2445 mViewManager->currentView()->changeEventDisplay(which,action); 2445 mViewManager->currentView()->changeEventDisplay(which,action);
2446 // TODO: check, if update needed 2446 // TODO: check, if update needed
2447 // if (which->getTodoStatus()) { 2447 // if (which->getTodoStatus()) {
2448 mTodoList->updateView(); 2448 mTodoList->updateView();
2449 // } 2449 // }
2450 } else { 2450 } else {
2451 mViewManager->currentView()->updateView(); 2451 mViewManager->currentView()->updateView();
2452 } 2452 }
2453} 2453}
2454 2454
2455 2455
2456void CalendarView::updateTodoViews() 2456void CalendarView::updateTodoViews()
2457{ 2457{
2458 mTodoList->updateView(); 2458 mTodoList->updateView();
2459 mViewManager->currentView()->updateView(); 2459 mViewManager->currentView()->updateView();
2460 2460
2461} 2461}
2462 2462
2463 2463
2464void CalendarView::updateView(const QDate &start, const QDate &end) 2464void CalendarView::updateView(const QDate &start, const QDate &end)
2465{ 2465{
2466 mTodoList->updateView(); 2466 mTodoList->updateView();
2467 mViewManager->updateView(start, end); 2467 mViewManager->updateView(start, end);
2468 //mDateNavigator->updateView(); 2468 //mDateNavigator->updateView();
2469} 2469}
2470 2470
2471void CalendarView::clearAllViews() 2471void CalendarView::clearAllViews()
2472{ 2472{
2473 mTodoList->clearList(); 2473 mTodoList->clearList();
2474 mViewManager->clearAllViews(); 2474 mViewManager->clearAllViews();
2475 SearchDialog * sd = mDialogManager->getSearchDialog(); 2475 SearchDialog * sd = mDialogManager->getSearchDialog();
2476 if ( sd ) { 2476 if ( sd ) {
2477 KOListView* kol = sd->listview(); 2477 KOListView* kol = sd->listview();
2478 if ( kol ) 2478 if ( kol )
2479 kol->clearList(); 2479 kol->clearList();
2480 } 2480 }
2481} 2481}
2482void CalendarView::updateView() 2482void CalendarView::updateView()
2483{ 2483{
2484 DateList tmpList = mNavigator->selectedDates(); 2484 DateList tmpList = mNavigator->selectedDates();
2485 2485
2486 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2486 if ( KOPrefs::instance()->mHideNonStartedTodos )
2487 mTodoList->updateView(); 2487 mTodoList->updateView();
2488 // We assume that the navigator only selects consecutive days. 2488 // We assume that the navigator only selects consecutive days.
2489 updateView( tmpList.first(), tmpList.last() ); 2489 updateView( tmpList.first(), tmpList.last() );
2490} 2490}
2491 2491
2492void CalendarView::updateUnmanagedViews() 2492void CalendarView::updateUnmanagedViews()
2493{ 2493{
2494 mDateNavigator->updateDayMatrix(); 2494 mDateNavigator->updateDayMatrix();
2495} 2495}
2496 2496
2497int CalendarView::msgItemDelete(const QString name) 2497int CalendarView::msgItemDelete(const QString name)
2498{ 2498{
2499 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 2499 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
2500 i18n("This item will be\npermanently deleted."), 2500 i18n("This item will be\npermanently deleted."),
2501 i18n("KO/Pi Confirmation"),i18n("Delete")); 2501 i18n("KO/Pi Confirmation"),i18n("Delete"));
2502} 2502}
2503 2503
2504 2504
2505void CalendarView::edit_cut() 2505void CalendarView::edit_cut()
2506{ 2506{
2507 Event *anEvent=0; 2507 Event *anEvent=0;
2508 2508
2509 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2509 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2510 2510
2511 if (mViewManager->currentView()->isEventView()) { 2511 if (mViewManager->currentView()->isEventView()) {
2512 if ( incidence && incidence->typeID() == eventID ) { 2512 if ( incidence && incidence->typeID() == eventID ) {
2513 anEvent = static_cast<Event *>(incidence); 2513 anEvent = static_cast<Event *>(incidence);
2514 } 2514 }
2515 } 2515 }
2516 2516
2517 if (!anEvent) { 2517 if (!anEvent) {
2518 KNotifyClient::beep(); 2518 KNotifyClient::beep();
2519 return; 2519 return;
2520 } 2520 }
2521 DndFactory factory( mCalendar ); 2521 DndFactory factory( mCalendar );
2522 factory.cutIncidence(anEvent); 2522 factory.cutIncidence(anEvent);
2523 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2523 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2524} 2524}
2525 2525
2526void CalendarView::edit_copy() 2526void CalendarView::edit_copy()
2527{ 2527{
2528 Event *anEvent=0; 2528 Event *anEvent=0;
2529 2529
2530 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2530 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2531 2531
2532 if (mViewManager->currentView()->isEventView()) { 2532 if (mViewManager->currentView()->isEventView()) {
2533 if ( incidence && incidence->typeID() == eventID ) { 2533 if ( incidence && incidence->typeID() == eventID ) {
2534 anEvent = static_cast<Event *>(incidence); 2534 anEvent = static_cast<Event *>(incidence);
2535 } 2535 }
2536 } 2536 }
2537 2537
2538 if (!anEvent) { 2538 if (!anEvent) {
2539 KNotifyClient::beep(); 2539 KNotifyClient::beep();
2540 return; 2540 return;
2541 } 2541 }
2542 DndFactory factory( mCalendar ); 2542 DndFactory factory( mCalendar );
2543 factory.copyIncidence(anEvent); 2543 factory.copyIncidence(anEvent);
2544} 2544}
2545 2545
2546void CalendarView::edit_paste() 2546void CalendarView::edit_paste()
2547{ 2547{
2548 QDate date = mNavigator->selectedDates().first(); 2548 QDate date = mNavigator->selectedDates().first();
2549 2549
2550 DndFactory factory( mCalendar ); 2550 DndFactory factory( mCalendar );
2551 Event *pastedEvent = (Event *)factory.pasteIncidence( date ); 2551 Event *pastedEvent = (Event *)factory.pasteIncidence( date );
2552 2552
2553 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2553 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2554} 2554}
2555void CalendarView::edit_global_options() 2555void CalendarView::edit_global_options()
2556{ 2556{
2557 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; 2557 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId;
2558 emit save(); 2558 emit save();
2559 emit saveStopTimer(); 2559 emit saveStopTimer();
2560 mDialogManager->showGlobalOptionsDialog(); 2560 mDialogManager->showGlobalOptionsDialog();
2561 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { 2561 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
2562 emit saveStopTimer(); 2562 emit saveStopTimer();
2563 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), 2563 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"),
2564 i18n("Timezone settings"),i18n("Reload"))) { 2564 i18n("Timezone settings"),i18n("Reload"))) {
2565 qDebug("KO: TZ reload cancelled "); 2565 qDebug("KO: TZ reload cancelled ");
2566 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2566 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2567 return; 2567 return;
2568 } 2568 }
2569 qDebug("KO: Timezone change "); 2569 qDebug("KO: Timezone change ");
2570 openCalendar( MainWindow::defaultFileName() ); 2570 openCalendar( MainWindow::defaultFileName() );
2571 setModified(true); 2571 setModified(true);
2572 } 2572 }
2573 else 2573 else
2574 qDebug("KO: No tz change "); 2574 qDebug("KO: No tz change ");
2575} 2575}
2576void CalendarView::edit_options() 2576void CalendarView::edit_options()
2577{ 2577{
2578 mDialogManager->showOptionsDialog(); 2578 mDialogManager->showOptionsDialog();
2579} 2579}
2580 2580
2581 2581
2582void CalendarView::slotSelectPickerDate( QDate d) 2582void CalendarView::slotSelectPickerDate( QDate d)
2583{ 2583{
2584 mDateFrame->hide(); 2584 mDateFrame->hide();
2585 if ( mDatePickerMode == 1 ) { 2585 if ( mDatePickerMode == 1 ) {
2586 mNavigator->slotDaySelect( d ); 2586 mNavigator->slotDaySelect( d );
2587 } else if ( mDatePickerMode == 2 ) { 2587 } else if ( mDatePickerMode == 2 ) {
2588 if ( mMoveIncidence->typeID() == todoID ) { 2588 if ( mMoveIncidence->typeID() == todoID ) {
2589 Todo * to = (Todo *) mMoveIncidence; 2589 Todo * to = (Todo *) mMoveIncidence;
2590 QTime tim; 2590 QTime tim;
2591 int len = 0; 2591 int len = 0;
2592 if ( to->hasStartDate() && to->hasDueDate() ) 2592 if ( to->hasStartDate() && to->hasDueDate() )
2593 len = to->dtStart().secsTo( to->dtDue()); 2593 len = to->dtStart().secsTo( to->dtDue());
2594 if ( to->hasDueDate() ) 2594 if ( to->hasDueDate() )
2595 tim = to->dtDue().time(); 2595 tim = to->dtDue().time();
2596 else { 2596 else {
2597 tim = QTime ( 0,0,0 ); 2597 tim = QTime ( 0,0,0 );
2598 to->setFloats( true ); 2598 to->setFloats( true );
2599 to->setHasDueDate( true ); 2599 to->setHasDueDate( true );
2600 } 2600 }
2601 QDateTime dt ( d,tim ); 2601 QDateTime dt ( d,tim );
2602 to->setDtDue( dt ); 2602 to->setDtDue( dt );
2603 2603
2604 if ( to->hasStartDate() ) { 2604 if ( to->hasStartDate() ) {
2605 if ( len>0 ) 2605 if ( len>0 )
2606 to->setDtStart(to->dtDue().addSecs( -len )); 2606 to->setDtStart(to->dtDue().addSecs( -len ));
2607 else 2607 else
2608 if (to->dtStart() > to->dtDue() ) 2608 if (to->dtStart() > to->dtDue() )
2609 to->setDtStart(to->dtDue().addDays( -3 )); 2609 to->setDtStart(to->dtDue().addDays( -3 ));
2610 } 2610 }
2611 2611
2612 todoChanged( to ); 2612 todoChanged( to );
2613 } else { 2613 } else {
2614 if ( mMoveIncidence->doesRecur() ) { 2614 if ( mMoveIncidence->doesRecur() ) {
2615#if 0 2615#if 0
2616 // PENDING implement this 2616 // PENDING implement this
2617 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 2617 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
2618 mCalendar()->addIncidence( newInc ); 2618 mCalendar()->addIncidence( newInc );
2619 if ( mMoveIncidence->typeID() == todoID ) 2619 if ( mMoveIncidence->typeID() == todoID )
2620 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 2620 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
2621 else 2621 else
2622 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 2622 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
2623 mMoveIncidence = newInc; 2623 mMoveIncidence = newInc;
2624 2624
2625#endif 2625#endif
2626 } 2626 }
2627 QTime tim = mMoveIncidence->dtStart().time(); 2627 QTime tim = mMoveIncidence->dtStart().time();
2628 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2628 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2629 QDateTime dt ( d,tim ); 2629 QDateTime dt ( d,tim );
2630 mMoveIncidence->setDtStart( dt ); 2630 mMoveIncidence->setDtStart( dt );
2631 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2631 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2632 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2632 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2633 } 2633 }
2634 2634
2635 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2635 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2636 } 2636 }
2637} 2637}
2638 2638
2639void CalendarView::removeCategories() 2639void CalendarView::removeCategories()
2640{ 2640{
2641 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2641 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2642 QStringList catList = KOPrefs::instance()->mCustomCategories; 2642 QStringList catList = KOPrefs::instance()->mCustomCategories;
2643 QStringList catIncList; 2643 QStringList catIncList;
2644 QStringList newCatList; 2644 QStringList newCatList;
2645 Incidence* inc = incList.first(); 2645 Incidence* inc = incList.first();
2646 int i; 2646 int i;
2647 int count = 0; 2647 int count = 0;
2648 while ( inc ) { 2648 while ( inc ) {
2649 newCatList.clear(); 2649 newCatList.clear();
2650 catIncList = inc->categories() ; 2650 catIncList = inc->categories() ;
2651 for( i = 0; i< catIncList.count(); ++i ) { 2651 for( i = 0; i< catIncList.count(); ++i ) {
2652 if ( catList.contains (catIncList[i])) 2652 if ( catList.contains (catIncList[i]))
2653 newCatList.append( catIncList[i] ); 2653 newCatList.append( catIncList[i] );
2654 } 2654 }
2655 newCatList.sort(); 2655 newCatList.sort();
2656 inc->setCategories( newCatList.join(",") ); 2656 inc->setCategories( newCatList.join(",") );
2657 inc = incList.next(); 2657 inc = incList.next();
2658 } 2658 }
2659} 2659}
2660 2660
2661int CalendarView::addCategories() 2661int CalendarView::addCategories()
2662{ 2662{
2663 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2663 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2664 QStringList catList = KOPrefs::instance()->mCustomCategories; 2664 QStringList catList = KOPrefs::instance()->mCustomCategories;
2665 QStringList catIncList; 2665 QStringList catIncList;
2666 Incidence* inc = incList.first(); 2666 Incidence* inc = incList.first();
2667 int i; 2667 int i;
2668 int count = 0; 2668 int count = 0;
2669 while ( inc ) { 2669 while ( inc ) {
2670 catIncList = inc->categories() ; 2670 catIncList = inc->categories() ;
2671 for( i = 0; i< catIncList.count(); ++i ) { 2671 for( i = 0; i< catIncList.count(); ++i ) {
2672 if ( !catList.contains (catIncList[i])) { 2672 if ( !catList.contains (catIncList[i])) {
2673 catList.append( catIncList[i] ); 2673 catList.append( catIncList[i] );
2674 //qDebug("add cat %s ", catIncList[i].latin1()); 2674 //qDebug("add cat %s ", catIncList[i].latin1());
2675 ++count; 2675 ++count;
2676 } 2676 }
2677 } 2677 }
2678 inc = incList.next(); 2678 inc = incList.next();
2679 } 2679 }
2680 catList.sort(); 2680 catList.sort();
2681 KOPrefs::instance()->mCustomCategories = catList; 2681 KOPrefs::instance()->mCustomCategories = catList;
2682 return count; 2682 return count;
2683} 2683}
2684 2684
2685void CalendarView::manageCategories() 2685void CalendarView::manageCategories()
2686{ 2686{
2687 KOCatPrefs* cp = new KOCatPrefs(); 2687 KOCatPrefs* cp = new KOCatPrefs();
2688 cp->show(); 2688 cp->show();
2689 int w =cp->sizeHint().width() ; 2689 int w =cp->sizeHint().width() ;
2690 int h = cp->sizeHint().height() ; 2690 int h = cp->sizeHint().height() ;
2691 int dw = QApplication::desktop()->width(); 2691 int dw = QApplication::desktop()->width();
2692 int dh = QApplication::desktop()->height(); 2692 int dh = QApplication::desktop()->height();
2693 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2693 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2694 if ( !cp->exec() ) { 2694 if ( !cp->exec() ) {
2695 delete cp; 2695 delete cp;
2696 return; 2696 return;
2697 } 2697 }
2698 int count = 0; 2698 int count = 0;
2699 if ( cp->addCat() ) { 2699 if ( cp->addCat() ) {
2700 count = addCategories(); 2700 count = addCategories();
2701 if ( count ) { 2701 if ( count ) {
2702 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2702 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2703 writeSettings(); 2703 writeSettings();
2704 } else 2704 } else
2705 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 2705 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
2706 } else { 2706 } else {
2707 removeCategories(); 2707 removeCategories();
2708 updateView(); 2708 updateView();
2709 } 2709 }
2710 delete cp; 2710 delete cp;
2711} 2711}
2712 2712
2713void CalendarView::beamIncidence(Incidence * Inc) 2713void CalendarView::beamIncidence(Incidence * Inc)
2714{ 2714{
2715 QPtrList<Incidence> delSel ; 2715 QPtrList<Incidence> delSel ;
2716 delSel.append(Inc); 2716 delSel.append(Inc);
2717 beamIncidenceList( delSel ); 2717 beamIncidenceList( delSel );
2718} 2718}
2719void CalendarView::beamCalendar() 2719void CalendarView::beamCalendar()
2720{ 2720{
2721 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2721 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2722 //qDebug("beamCalendar() "); 2722 //qDebug("beamCalendar() ");
2723 beamIncidenceList( delSel ); 2723 beamIncidenceList( delSel );
2724} 2724}
2725void CalendarView::beamFilteredCalendar() 2725void CalendarView::beamFilteredCalendar()
2726{ 2726{
2727 QPtrList<Incidence> delSel = mCalendar->incidences(); 2727 QPtrList<Incidence> delSel = mCalendar->incidences();
2728 //qDebug("beamFilteredCalendar() "); 2728 //qDebug("beamFilteredCalendar() ");
2729 beamIncidenceList( delSel ); 2729 beamIncidenceList( delSel );
2730} 2730}
2731void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2731void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2732{ 2732{
2733 if ( beamDialog->exec () == QDialog::Rejected ) 2733 if ( beamDialog->exec () == QDialog::Rejected )
2734 return; 2734 return;
2735#ifdef DESKTOP_VERSION 2735#ifdef DESKTOP_VERSION
2736 QString fn = locateLocal( "tmp", "kopibeamfile" ); 2736 QString fn = locateLocal( "tmp", "kopibeamfile" );
2737#else 2737#else
2738 QString fn = "/tmp/kopibeamfile"; 2738 QString fn = "/tmp/kopibeamfile";
2739#endif 2739#endif
2740 QString mes; 2740 QString mes;
2741 bool createbup = true; 2741 bool createbup = true;
2742 if ( createbup ) { 2742 if ( createbup ) {
2743 QString description = "\n"; 2743 QString description = "\n";
2744 CalendarLocal* cal = new CalendarLocal(); 2744 CalendarLocal* cal = new CalendarLocal();
2745 if ( beamDialog->beamLocal() ) 2745 if ( beamDialog->beamLocal() )
2746 cal->setLocalTime(); 2746 cal->setLocalTime();
2747 else 2747 else
2748 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2748 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2749 Incidence *incidence = delSel.first(); 2749 Incidence *incidence = delSel.first();
2750 bool addText = false; 2750 bool addText = false;
2751 if ( delSel.count() < 10 ) 2751 if ( delSel.count() < 10 )
2752 addText = true; 2752 addText = true;
2753 else { 2753 else {
2754 description.sprintf(i18n(" %d items?"),delSel.count() ); 2754 description.sprintf(i18n(" %d items?"),delSel.count() );
2755 } 2755 }
2756 while ( incidence ) { 2756 while ( incidence ) {
2757 Incidence *in = incidence->clone(); 2757 Incidence *in = incidence->clone();
2758 if ( ! in->summary().isEmpty() ) { 2758 if ( ! in->summary().isEmpty() ) {
2759 in->setDescription(""); 2759 in->setDescription("");
2760 } else { 2760 } else {
2761 in->setSummary( in->description().left(20)); 2761 in->setSummary( in->description().left(20));
2762 in->setDescription(""); 2762 in->setDescription("");
2763 } 2763 }
2764 if ( addText ) 2764 if ( addText )
2765 description += in->summary() + "\n"; 2765 description += in->summary() + "\n";
2766 cal->addIncidence( in ); 2766 cal->addIncidence( in );
2767 incidence = delSel.next(); 2767 incidence = delSel.next();
2768 } 2768 }
2769 if ( beamDialog->beamVcal() ) { 2769 if ( beamDialog->beamVcal() ) {
2770 fn += ".vcs"; 2770 fn += ".vcs";
2771 FileStorage storage( cal, fn, new VCalFormat ); 2771 FileStorage storage( cal, fn, new VCalFormat );
2772 storage.save(); 2772 storage.save();
2773 } else { 2773 } else {
2774 fn += ".ics"; 2774 fn += ".ics";
2775 FileStorage storage( cal, fn, new ICalFormat( ) ); 2775 FileStorage storage( cal, fn, new ICalFormat( ) );
2776 storage.save(); 2776 storage.save();
2777 } 2777 }
2778 delete cal; 2778 delete cal;
2779 mes = i18n("KO/Pi: Ready for beaming"); 2779 mes = i18n("KO/Pi: Ready for beaming");
2780 topLevelWidget()->setCaption(mes); 2780 topLevelWidget()->setCaption(mes);
2781 KApplication::convert2latin1( fn ); 2781 KApplication::convert2latin1( fn );
2782#ifndef DESKTOP_VERSION 2782#ifndef DESKTOP_VERSION
2783 Ir *ir = new Ir( this ); 2783 Ir *ir = new Ir( this );
2784 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2784 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2785 ir->send( fn, description, "text/x-vCalendar" ); 2785 ir->send( fn, description, "text/x-vCalendar" );
2786#endif 2786#endif
2787 } 2787 }
2788} 2788}
2789void CalendarView::beamDone( Ir *ir ) 2789void CalendarView::beamDone( Ir *ir )
2790{ 2790{
2791#ifndef DESKTOP_VERSION 2791#ifndef DESKTOP_VERSION
2792 delete ir; 2792 delete ir;
2793#endif 2793#endif
2794 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 2794 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2795 topLevelWidget()->raise(); 2795 topLevelWidget()->raise();
2796} 2796}
2797 2797
2798void CalendarView::moveIncidence(Incidence * inc ) 2798void CalendarView::moveIncidence(Incidence * inc )
2799{ 2799{
2800 if ( !inc ) return; 2800 if ( !inc ) return;
2801 showDatePickerPopup(); 2801 showDatePickerPopup();
2802 mDatePickerMode = 2; 2802 mDatePickerMode = 2;
2803 mMoveIncidence = inc ; 2803 mMoveIncidence = inc ;
2804 QDate da; 2804 QDate da;
2805 if ( mMoveIncidence->typeID() == todoID ) { 2805 if ( mMoveIncidence->typeID() == todoID ) {
2806 Todo * to = (Todo *) mMoveIncidence; 2806 Todo * to = (Todo *) mMoveIncidence;
2807 if ( to->hasDueDate() ) 2807 if ( to->hasDueDate() )
2808 da = to->dtDue().date(); 2808 da = to->dtDue().date();
2809 else 2809 else
2810 da = QDate::currentDate(); 2810 da = QDate::currentDate();
2811 } else { 2811 } else {
2812 da = mMoveIncidence->dtStart().date(); 2812 da = mMoveIncidence->dtStart().date();
2813 } 2813 }
2814 //PENDING set date for recurring incidence to date of recurrence 2814 //PENDING set date for recurring incidence to date of recurrence
2815 //mMoveIncidenceOldDate; 2815 //mMoveIncidenceOldDate;
2816 mDatePicker->setDate( da ); 2816 mDatePicker->setDate( da );
2817} 2817}
2818void CalendarView::showDatePickerPopup() 2818void CalendarView::showDatePickerPopup()
2819{ 2819{
2820 if ( mDateFrame->isVisible() ) 2820 if ( mDateFrame->isVisible() )
2821 mDateFrame->hide(); 2821 mDateFrame->hide();
2822 else { 2822 else {
2823 int offX = 0, offY = 0; 2823 int offX = 0, offY = 0;
2824#ifdef DESKTOP_VERSION 2824#ifdef DESKTOP_VERSION
2825 int w =mDatePicker->sizeHint().width() ; 2825 int w =mDatePicker->sizeHint().width() ;
2826 int h = mDatePicker->sizeHint().height() ; 2826 int h = mDatePicker->sizeHint().height() ;
2827 int dw = topLevelWidget()->width(); 2827 int dw = topLevelWidget()->width();
2828 int dh = topLevelWidget()->height(); 2828 int dh = topLevelWidget()->height();
2829 offX = topLevelWidget()->x(); 2829 offX = topLevelWidget()->x();
2830 offY = topLevelWidget()->y(); 2830 offY = topLevelWidget()->y();
2831#else 2831#else
2832 int w =mDatePicker->sizeHint().width() ; 2832 int w =mDatePicker->sizeHint().width() ;
2833 int h = mDatePicker->sizeHint().height() ; 2833 int h = mDatePicker->sizeHint().height() ;
2834 int dw = QApplication::desktop()->width(); 2834 int dw = QApplication::desktop()->width();
2835 int dh = QApplication::desktop()->height(); 2835 int dh = QApplication::desktop()->height();
2836#endif 2836#endif
2837 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); 2837 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h );
2838 mDateFrame->show(); 2838 mDateFrame->show();
2839 } 2839 }
2840} 2840}
2841void CalendarView::showDatePicker( ) 2841void CalendarView::showDatePicker( )
2842{ 2842{
2843 showDatePickerPopup(); 2843 showDatePickerPopup();
2844 mDatePickerMode = 1; 2844 mDatePickerMode = 1;
2845 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2845 mDatePicker->setDate( mNavigator->selectedDates().first() );
2846} 2846}
2847 2847
2848void CalendarView::showEventEditor() 2848void CalendarView::showEventEditor()
2849{ 2849{
2850#ifdef DESKTOP_VERSION 2850#ifdef DESKTOP_VERSION
2851 int x,y,w,h; 2851 int x,y,w,h;
2852 x = mEventEditor->geometry().x(); 2852 x = mEventEditor->geometry().x();
2853 y = mEventEditor->geometry().y(); 2853 y = mEventEditor->geometry().y();
2854 w = mEventEditor->width(); 2854 w = mEventEditor->width();
2855 h = mEventEditor->height(); 2855 h = mEventEditor->height();
2856 mEventEditor->show(); 2856 mEventEditor->show();
2857 mEventEditor->setGeometry(x,y,w,h); 2857 mEventEditor->setGeometry(x,y,w,h);
2858#else 2858#else
2859 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 2859 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
2860 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2860 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2861 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 2861 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
2862 qApp->processEvents(); 2862 qApp->processEvents();
2863 delete mEventEditor; 2863 delete mEventEditor;
2864 mEventEditor = mDialogManager->getEventEditor(); 2864 mEventEditor = mDialogManager->getEventEditor();
2865 topLevelWidget()->setCaption( i18n("") ); 2865 topLevelWidget()->setCaption( i18n("") );
2866 } 2866 }
2867 mEventEditor->showMaximized(); 2867 mEventEditor->showMaximized();
2868#endif 2868#endif
2869} 2869}
2870void CalendarView::showTodoEditor() 2870void CalendarView::showTodoEditor()
2871{ 2871{
2872#ifdef DESKTOP_VERSION 2872#ifdef DESKTOP_VERSION
2873 int x,y,w,h; 2873 int x,y,w,h;
2874 x = mTodoEditor->geometry().x(); 2874 x = mTodoEditor->geometry().x();
2875 y = mTodoEditor->geometry().y(); 2875 y = mTodoEditor->geometry().y();
2876 w = mTodoEditor->width(); 2876 w = mTodoEditor->width();
2877 h = mTodoEditor->height(); 2877 h = mTodoEditor->height();
2878 mTodoEditor->show(); 2878 mTodoEditor->show();
2879 mTodoEditor->setGeometry(x,y,w,h); 2879 mTodoEditor->setGeometry(x,y,w,h);
2880#else 2880#else
2881 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 2881 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
2882 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2882 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2883 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 2883 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
2884 qApp->processEvents(); 2884 qApp->processEvents();
2885 delete mTodoEditor; 2885 delete mTodoEditor;
2886 mTodoEditor = mDialogManager->getTodoEditor(); 2886 mTodoEditor = mDialogManager->getTodoEditor();
2887 topLevelWidget()->setCaption( i18n("") ); 2887 topLevelWidget()->setCaption( i18n("") );
2888 } 2888 }
2889 mTodoEditor->showMaximized(); 2889 mTodoEditor->showMaximized();
2890#endif 2890#endif
2891} 2891}
2892 2892
2893void CalendarView::cloneIncidence() 2893void CalendarView::cloneIncidence()
2894{ 2894{
2895 Incidence *incidence = currentSelection(); 2895 Incidence *incidence = currentSelection();
2896 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2896 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2897 if ( incidence ) { 2897 if ( incidence ) {
2898 cloneIncidence(incidence); 2898 cloneIncidence(incidence);
2899 } 2899 }
2900} 2900}
2901void CalendarView::moveIncidence() 2901void CalendarView::moveIncidence()
2902{ 2902{
2903 Incidence *incidence = currentSelection(); 2903 Incidence *incidence = currentSelection();
2904 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2904 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2905 if ( incidence ) { 2905 if ( incidence ) {
2906 moveIncidence(incidence); 2906 moveIncidence(incidence);
2907 } 2907 }
2908} 2908}
2909void CalendarView::beamIncidence() 2909void CalendarView::beamIncidence()
2910{ 2910{
2911 Incidence *incidence = currentSelection(); 2911 Incidence *incidence = currentSelection();
2912 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2912 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2913 if ( incidence ) { 2913 if ( incidence ) {
2914 beamIncidence(incidence); 2914 beamIncidence(incidence);
2915 } 2915 }
2916} 2916}
2917void CalendarView::toggleCancelIncidence() 2917void CalendarView::toggleCancelIncidence()
2918{ 2918{
2919 Incidence *incidence = currentSelection(); 2919 Incidence *incidence = currentSelection();
2920 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2920 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2921 if ( incidence ) { 2921 if ( incidence ) {
2922 cancelIncidence(incidence); 2922 cancelIncidence(incidence);
2923 } 2923 }
2924} 2924}
2925 2925
2926 2926
2927void CalendarView::cancelIncidence(Incidence * inc ) 2927void CalendarView::cancelIncidence(Incidence * inc )
2928{ 2928{
2929 inc->setCancelled( ! inc->cancelled() ); 2929 inc->setCancelled( ! inc->cancelled() );
2930 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2930 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2931 updateView(); 2931 updateView();
2932} 2932}
2933void CalendarView::cloneIncidence(Incidence * orgInc ) 2933void CalendarView::cloneIncidence(Incidence * orgInc )
2934{ 2934{
2935 Incidence * newInc = orgInc->clone(); 2935 Incidence * newInc = orgInc->clone();
2936 newInc->recreate(); 2936 newInc->recreate();
2937 2937
2938 if ( newInc->typeID() == todoID ) { 2938 if ( newInc->typeID() == todoID ) {
2939 Todo* t = (Todo*) newInc; 2939 Todo* t = (Todo*) newInc;
2940 bool cloneSub = false; 2940 bool cloneSub = false;
2941 if ( orgInc->relations().count() ) { 2941 if ( orgInc->relations().count() ) {
2942 int result = KMessageBox::warningYesNoCancel(this, 2942 int result = KMessageBox::warningYesNoCancel(this,
2943 i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( newInc->summary().left ( 25 ) ), 2943 i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( newInc->summary().left ( 25 ) ),
2944 i18n("Todo has subtodos"), 2944 i18n("Todo has subtodos"),
2945 i18n("Yes"), 2945 i18n("Yes"),
2946 i18n("No")); 2946 i18n("No"));
2947 2947
2948 if ( result == KMessageBox::Cancel ) { 2948 if ( result == KMessageBox::Cancel ) {
2949 delete t; 2949 delete t;
2950 return; 2950 return;
2951 } 2951 }
2952 if (result == KMessageBox::Yes) cloneSub = true; 2952 if (result == KMessageBox::Yes) cloneSub = true;
2953 } 2953 }
2954 showTodoEditor(); 2954 showTodoEditor();
2955 mTodoEditor->editTodo( t ); 2955 mTodoEditor->editTodo( t );
2956 if ( mTodoEditor->exec() ) { 2956 if ( mTodoEditor->exec() ) {
2957 if ( cloneSub ) { 2957 if ( cloneSub ) {
2958 orgInc->cloneRelations( t ); 2958 orgInc->cloneRelations( t );
2959 mCalendar->addIncidenceBranch( t ); 2959 mCalendar->addIncidenceBranch( t );
2960 updateView(); 2960 updateView();
2961 2961
2962 } else { 2962 } else {
2963 mCalendar->addTodo( t ); 2963 mCalendar->addTodo( t );
2964 updateView(); 2964 updateView();
2965 } 2965 }
2966 } else { 2966 } else {
2967 delete t; 2967 delete t;
2968 } 2968 }
2969 } 2969 }
2970 else { 2970 else {
2971 Event* e = (Event*) newInc; 2971 Event* e = (Event*) newInc;
2972 showEventEditor(); 2972 showEventEditor();
2973 mEventEditor->editEvent( e ); 2973 mEventEditor->editEvent( e );
2974 if ( mEventEditor->exec() ) { 2974 if ( mEventEditor->exec() ) {
2975 mCalendar->addEvent( e ); 2975 mCalendar->addEvent( e );
2976 updateView(); 2976 updateView();
2977 } else { 2977 } else {
2978 delete e; 2978 delete e;
2979 } 2979 }
2980 } 2980 }
2981 setActiveWindow(); 2981 setActiveWindow();
2982} 2982}
2983 2983
2984void CalendarView::newEvent() 2984void CalendarView::newEvent()
2985{ 2985{
2986 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2986 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2987 KOAgendaView *aView = mViewManager->agendaView(); 2987 KOAgendaView *aView = mViewManager->agendaView();
2988 if (aView) { 2988 if (aView) {
2989 if (aView->selectionStart().isValid()) { 2989 if (aView->selectionStart().isValid()) {
2990 if (aView->selectedIsAllDay()) { 2990 if (aView->selectedIsAllDay()) {
2991 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2991 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2992 } else { 2992 } else {
2993 newEvent(aView->selectionStart(),aView->selectionEnd()); 2993 newEvent(aView->selectionStart(),aView->selectionEnd());
2994 } 2994 }
2995 return; 2995 return;
2996 } 2996 }
2997 } 2997 }
2998 2998
2999 QDate date = mNavigator->selectedDates().first(); 2999 QDate date = mNavigator->selectedDates().first();
3000 QDateTime current = QDateTime::currentDateTime(); 3000 QDateTime current = QDateTime::currentDateTime();
3001 if ( date <= current.date() ) { 3001 if ( date <= current.date() ) {
3002 int hour = current.time().hour() +1; 3002 int hour = current.time().hour() +1;
3003 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 3003 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
3004 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 3004 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
3005 } else 3005 } else
3006 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 3006 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
3007 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 3007 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
3008 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 3008 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
3009} 3009}
3010 3010
3011void CalendarView::newEvent(QDateTime fh) 3011void CalendarView::newEvent(QDateTime fh)
3012{ 3012{
3013 newEvent(fh, 3013 newEvent(fh,
3014 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 3014 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
3015} 3015}
3016 3016
3017void CalendarView::newEvent(QDate dt) 3017void CalendarView::newEvent(QDate dt)
3018{ 3018{
3019 newEvent(QDateTime(dt, QTime(0,0,0)), 3019 newEvent(QDateTime(dt, QTime(0,0,0)),
3020 QDateTime(dt, QTime(0,0,0)), true); 3020 QDateTime(dt, QTime(0,0,0)), true);
3021} 3021}
3022void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) 3022void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint)
3023{ 3023{
3024 newEvent(fromHint, toHint, false); 3024 newEvent(fromHint, toHint, false);
3025} 3025}
3026void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 3026void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
3027{ 3027{
3028 3028
3029 showEventEditor(); 3029 showEventEditor();
3030 mEventEditor->newEvent(fromHint,toHint,allDay); 3030 mEventEditor->newEvent(fromHint,toHint,allDay);
3031 if ( mFilterView->filtersEnabled() ) { 3031 if ( mFilterView->filtersEnabled() ) {
3032 CalFilter *filter = mFilterView->selectedFilter(); 3032 CalFilter *filter = mFilterView->selectedFilter();
3033 if (filter && filter->showCategories()) { 3033 if (filter && filter->showCategories()) {
3034 mEventEditor->setCategories(filter->categoryList().join(",") ); 3034 mEventEditor->setCategories(filter->categoryList().join(",") );
3035 } 3035 }
3036 if ( filter ) 3036 if ( filter )
3037 mEventEditor->setSecrecy( filter->getSecrecy() ); 3037 mEventEditor->setSecrecy( filter->getSecrecy() );
3038 } 3038 }
3039 mEventEditor->exec(); 3039 mEventEditor->exec();
3040 setActiveWindow(); 3040 setActiveWindow();
3041} 3041}
3042void CalendarView::todoAdded(Todo * t) 3042void CalendarView::todoAdded(Todo * t)
3043{ 3043{
3044 3044
3045 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 3045 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
3046 updateTodoViews(); 3046 updateTodoViews();
3047} 3047}
3048void CalendarView::todoChanged(Todo * t) 3048void CalendarView::todoChanged(Todo * t)
3049{ 3049{
3050 emit todoModified( t, 4 ); 3050 emit todoModified( t, 4 );
3051 // updateTodoViews(); 3051 // updateTodoViews();
3052} 3052}
3053void CalendarView::todoToBeDeleted(Todo *) 3053void CalendarView::todoToBeDeleted(Todo *)
3054{ 3054{
3055 //qDebug("todoToBeDeleted(Todo *) "); 3055 //qDebug("todoToBeDeleted(Todo *) ");
3056 updateTodoViews(); 3056 updateTodoViews();
3057} 3057}
3058void CalendarView::todoDeleted() 3058void CalendarView::todoDeleted()
3059{ 3059{
3060 //qDebug(" todoDeleted()"); 3060 //qDebug(" todoDeleted()");
3061 updateTodoViews(); 3061 updateTodoViews();
3062} 3062}
3063 3063
3064 3064
3065void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) 3065void CalendarView::newTodoDateTime( QDateTime dt, bool allday )
3066{ 3066{
3067 showTodoEditor(); 3067 showTodoEditor();
3068 mTodoEditor->newTodo(dt,0,allday); 3068 mTodoEditor->newTodo(dt,0,allday);
3069 if ( mFilterView->filtersEnabled() ) { 3069 if ( mFilterView->filtersEnabled() ) {
3070 CalFilter *filter = mFilterView->selectedFilter(); 3070 CalFilter *filter = mFilterView->selectedFilter();
3071 if (filter && filter->showCategories()) { 3071 if (filter && filter->showCategories()) {
3072 mTodoEditor->setCategories(filter->categoryList().join(",") ); 3072 mTodoEditor->setCategories(filter->categoryList().join(",") );
3073 } 3073 }
3074 if ( filter ) 3074 if ( filter )
3075 mTodoEditor->setSecrecy( filter->getSecrecy() ); 3075 mTodoEditor->setSecrecy( filter->getSecrecy() );
3076 } 3076 }
3077 mTodoEditor->exec(); 3077 mTodoEditor->exec();
3078 setActiveWindow(); 3078 setActiveWindow();
3079} 3079}
3080 3080
3081void CalendarView::newTodo() 3081void CalendarView::newTodo()
3082{ 3082{
3083 newTodoDateTime( QDateTime(),true ); 3083 newTodoDateTime( QDateTime(),true );
3084} 3084}
3085 3085
3086void CalendarView::newSubTodo() 3086void CalendarView::newSubTodo()
3087{ 3087{
3088 Todo *todo = selectedTodo(); 3088 Todo *todo = selectedTodo();
3089 if ( todo ) newSubTodo( todo ); 3089 if ( todo ) newSubTodo( todo );
3090} 3090}
3091 3091
3092void CalendarView::newSubTodo(Todo *parentEvent) 3092void CalendarView::newSubTodo(Todo *parentEvent)
3093{ 3093{
3094 3094
3095 showTodoEditor(); 3095 showTodoEditor();
3096 mTodoEditor->newTodo(QDateTime(),parentEvent,true); 3096 mTodoEditor->newTodo(QDateTime(),parentEvent,true);
3097 mTodoEditor->exec(); 3097 mTodoEditor->exec();
3098 setActiveWindow(); 3098 setActiveWindow();
3099} 3099}
3100 3100
3101void CalendarView::newFloatingEvent() 3101void CalendarView::newFloatingEvent()
3102{ 3102{
3103 DateList tmpList = mNavigator->selectedDates(); 3103 DateList tmpList = mNavigator->selectedDates();
3104 QDate date = tmpList.first(); 3104 QDate date = tmpList.first();
3105 3105
3106 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 3106 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
3107 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 3107 QDateTime( date, QTime( 12, 0, 0 ) ), true );
3108} 3108}
3109 3109
3110 3110
3111void CalendarView::editEvent( Event *event ) 3111void CalendarView::editEvent( Event *event )
3112{ 3112{
3113 3113
3114 if ( !event ) return; 3114 if ( !event ) return;
3115 if ( event->isReadOnly() ) { 3115 if ( event->isReadOnly() ) {
3116 showEvent( event ); 3116 showEvent( event );
3117 return; 3117 return;
3118 } 3118 }
3119 showEventEditor(); 3119 showEventEditor();
3120 mEventEditor->editEvent( event , mFlagEditDescription); 3120 mEventEditor->editEvent( event , mFlagEditDescription);
3121 mEventEditor->exec(); 3121 mEventEditor->exec();
3122 setActiveWindow(); 3122 setActiveWindow();
3123 3123
3124} 3124}
3125void CalendarView::editJournal( Journal *jour ) 3125void CalendarView::editJournal( Journal *jour )
3126{ 3126{
3127 if ( !jour ) return; 3127 if ( !jour ) return;
3128 mDialogManager->hideSearchDialog(); 3128 mDialogManager->hideSearchDialog();
3129 mViewManager->showJournalView(); 3129 mViewManager->showJournalView();
3130 mNavigator->slotDaySelect( jour->dtStart().date() ); 3130 mNavigator->slotDaySelect( jour->dtStart().date() );
3131} 3131}
3132void CalendarView::editTodo( Todo *todo ) 3132void CalendarView::editTodo( Todo *todo )
3133{ 3133{
3134 if ( !todo ) return; 3134 if ( !todo ) return;
3135 3135
3136 if ( todo->isReadOnly() ) { 3136 if ( todo->isReadOnly() ) {
3137 showTodo( todo ); 3137 showTodo( todo );
3138 return; 3138 return;
3139 } 3139 }
3140 showTodoEditor(); 3140 showTodoEditor();
3141 mTodoEditor->editTodo( todo ,mFlagEditDescription); 3141 mTodoEditor->editTodo( todo ,mFlagEditDescription);
3142 mTodoEditor->exec(); 3142 mTodoEditor->exec();
3143 setActiveWindow(); 3143 setActiveWindow();
3144 3144
3145} 3145}
3146 3146
3147KOEventViewerDialog* CalendarView::getEventViewerDialog() 3147KOEventViewerDialog* CalendarView::getEventViewerDialog()
3148{ 3148{
3149 if ( !mEventViewerDialog ) { 3149 if ( !mEventViewerDialog ) {
3150 mEventViewerDialog = new KOEventViewerDialog(0); 3150 mEventViewerDialog = new KOEventViewerDialog(0);
3151 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 3151 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
3152 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 3152 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
3153 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 3153 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
3154 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 3154 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
3155 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 3155 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
3156 viewManager(), SLOT( showAgendaView( bool ) ) ); 3156 viewManager(), SLOT( showAgendaView( bool ) ) );
3157 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), 3157 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()),
3158 this, SLOT( slotViewerClosed() ) ); 3158 this, SLOT( slotViewerClosed() ) );
3159 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), 3159 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ),
3160 this, SLOT( todoChanged(Todo *) ) ); 3160 this, SLOT( todoChanged(Todo *) ) );
3161 mEventViewerDialog->resize( 640, 480 ); 3161 mEventViewerDialog->resize( 640, 480 );
3162 3162
3163 } 3163 }
3164 return mEventViewerDialog; 3164 return mEventViewerDialog;
3165} 3165}
3166void CalendarView::showEvent(Event *event) 3166void CalendarView::showEvent(Event *event)
3167{ 3167{
3168 getEventViewerDialog()->setEvent(event); 3168 getEventViewerDialog()->setEvent(event);
3169 getEventViewerDialog()->showMe(); 3169 getEventViewerDialog()->showMe();
3170} 3170}
3171 3171
3172void CalendarView::showTodo(Todo *event) 3172void CalendarView::showTodo(Todo *event)
3173{ 3173{
3174 getEventViewerDialog()->setTodo(event); 3174 getEventViewerDialog()->setTodo(event);
3175 getEventViewerDialog()->showMe(); 3175 getEventViewerDialog()->showMe();
3176} 3176}
3177void CalendarView::showJournal( Journal *jour ) 3177void CalendarView::showJournal( Journal *jour )
3178{ 3178{
3179 getEventViewerDialog()->setJournal(jour); 3179 getEventViewerDialog()->setJournal(jour);
3180 getEventViewerDialog()->showMe(); 3180 getEventViewerDialog()->showMe();
3181 3181
3182} 3182}
3183// void CalendarView::todoModified (Todo *event, int changed) 3183// void CalendarView::todoModified (Todo *event, int changed)
3184// { 3184// {
3185// // if (mDialogList.find (event) != mDialogList.end ()) { 3185// // if (mDialogList.find (event) != mDialogList.end ()) {
3186// // kdDebug() << "Todo modified and open" << endl; 3186// // kdDebug() << "Todo modified and open" << endl;
3187// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 3187// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
3188// // temp->modified (changed); 3188// // temp->modified (changed);
3189 3189
3190// // } 3190// // }
3191 3191
3192// mViewManager->updateView(); 3192// mViewManager->updateView();
3193// } 3193// }
3194 3194
3195void CalendarView::appointment_show() 3195void CalendarView::appointment_show()
3196{ 3196{
3197 Event *anEvent = 0; 3197 Event *anEvent = 0;
3198 3198
3199 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3199 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3200 3200
3201 if (mViewManager->currentView()->isEventView()) { 3201 if (mViewManager->currentView()->isEventView()) {
3202 if ( incidence && incidence->typeID() == eventID ) { 3202 if ( incidence && incidence->typeID() == eventID ) {
3203 anEvent = static_cast<Event *>(incidence); 3203 anEvent = static_cast<Event *>(incidence);
3204 } 3204 }
3205 } 3205 }
3206 3206
3207 if (!anEvent) { 3207 if (!anEvent) {
3208 KNotifyClient::beep(); 3208 KNotifyClient::beep();
3209 return; 3209 return;
3210 } 3210 }
3211 3211
3212 showEvent(anEvent); 3212 showEvent(anEvent);
3213} 3213}
3214 3214
3215void CalendarView::appointment_edit() 3215void CalendarView::appointment_edit()
3216{ 3216{
3217 Event *anEvent = 0; 3217 Event *anEvent = 0;
3218 3218
3219 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3219 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3220 3220
3221 if (mViewManager->currentView()->isEventView()) { 3221 if (mViewManager->currentView()->isEventView()) {
3222 if ( incidence && incidence->typeID() == eventID ) { 3222 if ( incidence && incidence->typeID() == eventID ) {
3223 anEvent = static_cast<Event *>(incidence); 3223 anEvent = static_cast<Event *>(incidence);
3224 } 3224 }
3225 } 3225 }
3226 3226
3227 if (!anEvent) { 3227 if (!anEvent) {
3228 KNotifyClient::beep(); 3228 KNotifyClient::beep();
3229 return; 3229 return;
3230 } 3230 }
3231 3231
3232 editEvent(anEvent); 3232 editEvent(anEvent);
3233} 3233}
3234 3234
3235void CalendarView::appointment_delete() 3235void CalendarView::appointment_delete()
3236{ 3236{
3237 Event *anEvent = 0; 3237 Event *anEvent = 0;
3238 3238
3239 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3239 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3240 3240
3241 if (mViewManager->currentView()->isEventView()) { 3241 if (mViewManager->currentView()->isEventView()) {
3242 if ( incidence && incidence->typeID() == eventID ) { 3242 if ( incidence && incidence->typeID() == eventID ) {
3243 anEvent = static_cast<Event *>(incidence); 3243 anEvent = static_cast<Event *>(incidence);
3244 } 3244 }
3245 } 3245 }
3246 3246
3247 if (!anEvent) { 3247 if (!anEvent) {
3248 KNotifyClient::beep(); 3248 KNotifyClient::beep();
3249 return; 3249 return;
3250 } 3250 }
3251 3251
3252 deleteEvent(anEvent); 3252 deleteEvent(anEvent);
3253} 3253}
3254 3254
3255void CalendarView::todo_resub( Todo * parent, Todo * sub ) 3255void CalendarView::todo_resub( Todo * parent, Todo * sub )
3256{ 3256{
3257 if (!sub) return; 3257 if (!sub) return;
3258 if ( sub->relatedTo() == parent ) 3258 if ( sub->relatedTo() == parent )
3259 return; 3259 return;
3260 sub->setRelatedTo(parent); 3260 sub->setRelatedTo(parent);
3261 sub->updated(); 3261 sub->updated();
3262 setModified(true); 3262 setModified(true);
3263 updateView(); 3263 updateView();
3264} 3264}
3265void CalendarView::todo_unsub(Todo *anTodo ) 3265void CalendarView::todo_unsub(Todo *anTodo )
3266{ 3266{
3267 todo_resub( 0, anTodo ); 3267 todo_resub( 0, anTodo );
3268} 3268}
3269 3269
3270void CalendarView::deleteTodo(Todo *todo) 3270void CalendarView::deleteTodo(Todo *todo)
3271{ 3271{
3272 if (!todo) { 3272 if (!todo) {
3273 KNotifyClient::beep(); 3273 KNotifyClient::beep();
3274 return; 3274 return;
3275 } 3275 }
3276 if (KOPrefs::instance()->mConfirm) { 3276 if (KOPrefs::instance()->mConfirm) {
3277 QString text = todo->summary().left(20); 3277 QString text = todo->summary().left(20);
3278 if (!todo->relations().isEmpty()) { 3278 if (!todo->relations().isEmpty()) {
3279 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); 3279 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!");
3280 3280
3281 } 3281 }
3282 switch (msgItemDelete(text)) { 3282 switch (msgItemDelete(text)) {
3283 case KMessageBox::Continue: // OK 3283 case KMessageBox::Continue: // OK
3284 bool deleteT = false; 3284 bool deleteT = false;
3285 if (!todo->relations().isEmpty()) { 3285 if (!todo->relations().isEmpty()) {
3286 deleteT = removeCompletedSubTodos( todo ); 3286 deleteT = removeCompletedSubTodos( todo );
3287 } 3287 }
3288 // deleteT == true: todo already deleted in removeCompletedSubTodos 3288 // deleteT == true: todo already deleted in removeCompletedSubTodos
3289 if ( !deleteT ) { 3289 if ( !deleteT ) {
3290 checkExternalId( todo ); 3290 checkExternalId( todo );
3291 calendar()->deleteTodo(todo); 3291 calendar()->deleteTodo(todo);
3292 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 3292 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
3293 updateView(); 3293 updateView();
3294 } 3294 }
3295 break; 3295 break;
3296 } // switch 3296 } // switch
3297 } else { 3297 } else {
3298 checkExternalId( todo ); 3298 checkExternalId( todo );
3299 mCalendar->deleteTodo(todo); 3299 mCalendar->deleteTodo(todo);
3300 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 3300 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
3301 updateView(); 3301 updateView();
3302 } 3302 }
3303 3303
3304 emit updateSearchDialog(); 3304 emit updateSearchDialog();
3305} 3305}
3306void CalendarView::deleteJournal(Journal *jour) 3306void CalendarView::deleteJournal(Journal *jour)
3307{ 3307{
3308 if (!jour) { 3308 if (!jour) {
3309 KNotifyClient::beep(); 3309 KNotifyClient::beep();
3310 return; 3310 return;
3311 } 3311 }
3312 if (KOPrefs::instance()->mConfirm) { 3312 if (KOPrefs::instance()->mConfirm) {
3313 switch (msgItemDelete( jour->description().left(20))) { 3313 switch (msgItemDelete( jour->description().left(20))) {
3314 case KMessageBox::Continue: // OK 3314 case KMessageBox::Continue: // OK
3315 calendar()->deleteJournal(jour); 3315 calendar()->deleteJournal(jour);
3316 updateView(); 3316 updateView();
3317 break; 3317 break;
3318 } // switch 3318 } // switch
3319 } else { 3319 } else {
3320 calendar()->deleteJournal(jour);; 3320 calendar()->deleteJournal(jour);;
3321 updateView(); 3321 updateView();
3322 } 3322 }
3323 emit updateSearchDialog(); 3323 emit updateSearchDialog();
3324} 3324}
3325 3325
3326void CalendarView::deleteEvent(Event *anEvent) 3326void CalendarView::deleteEvent(Event *anEvent)
3327{ 3327{
3328 if (!anEvent) { 3328 if (!anEvent) {
3329 KNotifyClient::beep(); 3329 KNotifyClient::beep();
3330 return; 3330 return;
3331 } 3331 }
3332 3332
3333 if (anEvent->recurrence()->doesRecur()) { 3333 if (anEvent->recurrence()->doesRecur()) {
3334 QDate itemDate = mViewManager->currentSelectionDate(); 3334 QDate itemDate = mViewManager->currentSelectionDate();
3335 int km; 3335 int km;
3336 if (!itemDate.isValid()) { 3336 if (!itemDate.isValid()) {
3337 //kdDebug() << "Date Not Valid" << endl; 3337 //kdDebug() << "Date Not Valid" << endl;
3338 if (KOPrefs::instance()->mConfirm) { 3338 if (KOPrefs::instance()->mConfirm) {
3339 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 3339 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3340 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 3340 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
3341 i18n("KO/Pi Confirmation"),i18n("Delete All")); 3341 i18n("KO/Pi Confirmation"),i18n("Delete All"));
3342 if ( km == KMessageBox::Continue ) 3342 if ( km == KMessageBox::Continue )
3343 km = KMessageBox::No; // No = all below 3343 km = KMessageBox::No; // No = all below
3344 } else 3344 } else
3345 km = KMessageBox::No; 3345 km = KMessageBox::No;
3346 } else { 3346 } else {
3347 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + 3347 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) +
3348 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 3348 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
3349 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 3349 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
3350 i18n("KO/Pi Confirmation"),i18n("Current"), 3350 i18n("KO/Pi Confirmation"),i18n("Current"),
3351 i18n("All")); 3351 i18n("All"));
3352 } 3352 }
3353 switch(km) { 3353 switch(km) {
3354 3354
3355 case KMessageBox::No: // Continue // all 3355 case KMessageBox::No: // Continue // all
3356 //qDebug("KMessageBox::No "); 3356 //qDebug("KMessageBox::No ");
3357 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3357 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3358 schedule(Scheduler::Cancel,anEvent); 3358 schedule(Scheduler::Cancel,anEvent);
3359 3359
3360 checkExternalId( anEvent); 3360 checkExternalId( anEvent);
3361 mCalendar->deleteEvent(anEvent); 3361 mCalendar->deleteEvent(anEvent);
3362 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 3362 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
3363 break; 3363 break;
3364 3364
3365 // Disabled because it does not work 3365 // Disabled because it does not work
3366 //#if 0 3366 //#if 0
3367 case KMessageBox::Yes: // just this one 3367 case KMessageBox::Yes: // just this one
3368 //QDate qd = mNavigator->selectedDates().first(); 3368 //QDate qd = mNavigator->selectedDates().first();
3369 //if (!qd.isValid()) { 3369 //if (!qd.isValid()) {
3370 // kdDebug() << "no date selected, or invalid date" << endl; 3370 // kdDebug() << "no date selected, or invalid date" << endl;
3371 // KNotifyClient::beep(); 3371 // KNotifyClient::beep();
3372 // return; 3372 // return;
3373 //} 3373 //}
3374 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 3374 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
3375 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 3375 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
3376 anEvent->addExDate(itemDate); 3376 anEvent->addExDate(itemDate);
3377 int duration = anEvent->recurrence()->duration(); 3377 int duration = anEvent->recurrence()->duration();
3378 if ( duration > 0 ) { 3378 if ( duration > 0 ) {
3379 anEvent->recurrence()->setDuration( duration - 1 ); 3379 anEvent->recurrence()->setDuration( duration - 1 );
3380 } 3380 }
3381 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 3381 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
3382 } 3382 }
3383 break; 3383 break;
3384 //#endif 3384 //#endif
3385 } // switch 3385 } // switch
3386 } else { 3386 } else {
3387 if (KOPrefs::instance()->mConfirm) { 3387 if (KOPrefs::instance()->mConfirm) {
3388 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 3388 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3389 i18n("\nAre you sure you want\nto delete this event?"), 3389 i18n("\nAre you sure you want\nto delete this event?"),
3390 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 3390 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
3391 case KMessageBox::Continue: // OK 3391 case KMessageBox::Continue: // OK
3392 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3392 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3393 schedule(Scheduler::Cancel,anEvent); 3393 schedule(Scheduler::Cancel,anEvent);
3394 checkExternalId( anEvent); 3394 checkExternalId( anEvent);
3395 mCalendar->deleteEvent(anEvent); 3395 mCalendar->deleteEvent(anEvent);
3396 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3396 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3397 break; 3397 break;
3398 } // switch 3398 } // switch
3399 } else { 3399 } else {
3400 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3400 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3401 schedule(Scheduler::Cancel,anEvent); 3401 schedule(Scheduler::Cancel,anEvent);
3402 checkExternalId( anEvent); 3402 checkExternalId( anEvent);
3403 mCalendar->deleteEvent(anEvent); 3403 mCalendar->deleteEvent(anEvent);
3404 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3404 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3405 } 3405 }
3406 } // if-else 3406 } // if-else
3407 emit updateSearchDialog(); 3407 emit updateSearchDialog();
3408} 3408}
3409 3409
3410bool CalendarView::deleteEvent(const QString &uid) 3410bool CalendarView::deleteEvent(const QString &uid)
3411{ 3411{
3412 Event *ev = mCalendar->event(uid); 3412 Event *ev = mCalendar->event(uid);
3413 if (ev) { 3413 if (ev) {
3414 deleteEvent(ev); 3414 deleteEvent(ev);
3415 return true; 3415 return true;
3416 } else { 3416 } else {
3417 return false; 3417 return false;
3418 } 3418 }
3419} 3419}
3420 3420
3421/*****************************************************************************/ 3421/*****************************************************************************/
3422 3422
3423void CalendarView::action_mail() 3423void CalendarView::action_mail()
3424{ 3424{
3425#ifndef KORG_NOMAIL 3425#ifndef KORG_NOMAIL
3426 KOMailClient mailClient; 3426 KOMailClient mailClient;
3427 3427
3428 Incidence *incidence = currentSelection(); 3428 Incidence *incidence = currentSelection();
3429 3429
3430 if (!incidence) { 3430 if (!incidence) {
3431 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3431 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3432 return; 3432 return;
3433 } 3433 }
3434 if(incidence->attendeeCount() == 0 ) { 3434 if(incidence->attendeeCount() == 0 ) {
3435 KMessageBox::sorry(this, 3435 KMessageBox::sorry(this,
3436 i18n("Can't generate mail:\nNo attendees defined.\n")); 3436 i18n("Can't generate mail:\nNo attendees defined.\n"));
3437 return; 3437 return;
3438 } 3438 }
3439 3439
3440 CalendarLocal cal_tmp; 3440 CalendarLocal cal_tmp;
3441 Event *event = 0; 3441 Event *event = 0;
3442 Event *ev = 0; 3442 Event *ev = 0;
3443 if ( incidence && incidence->typeID() == eventID ) { 3443 if ( incidence && incidence->typeID() == eventID ) {
3444 event = static_cast<Event *>(incidence); 3444 event = static_cast<Event *>(incidence);
3445 ev = new Event(*event); 3445 ev = new Event(*event);
3446 cal_tmp.addEvent(ev); 3446 cal_tmp.addEvent(ev);
3447 } 3447 }
3448 ICalFormat mForm(); 3448 ICalFormat mForm();
3449 QString attachment = mForm.toString( &cal_tmp ); 3449 QString attachment = mForm.toString( &cal_tmp );
3450 if (ev) delete(ev); 3450 if (ev) delete(ev);
3451 3451
3452 mailClient.mailAttendees(currentSelection(), attachment); 3452 mailClient.mailAttendees(currentSelection(), attachment);
3453 3453
3454#endif 3454#endif
3455 3455
3456#if 0 3456#if 0
3457 Event *anEvent = 0; 3457 Event *anEvent = 0;
3458 if (mViewManager->currentView()->isEventView()) { 3458 if (mViewManager->currentView()->isEventView()) {
3459 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 3459 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
3460 } 3460 }
3461 3461
3462 if (!anEvent) { 3462 if (!anEvent) {
3463 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3463 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3464 return; 3464 return;
3465 } 3465 }
3466 if(anEvent->attendeeCount() == 0 ) { 3466 if(anEvent->attendeeCount() == 0 ) {
3467 KMessageBox::sorry(this, 3467 KMessageBox::sorry(this,
3468 i18n("Can't generate mail:\nNo attendees defined.\n")); 3468 i18n("Can't generate mail:\nNo attendees defined.\n"));
3469 return; 3469 return;
3470 } 3470 }
3471 3471
3472 mailobject.emailEvent(anEvent); 3472 mailobject.emailEvent(anEvent);
3473#endif 3473#endif
3474} 3474}
3475 3475
3476 3476
3477void CalendarView::schedule_publish(Incidence *incidence) 3477void CalendarView::schedule_publish(Incidence *incidence)
3478{ 3478{
3479 Event *event = 0; 3479 Event *event = 0;
3480 Todo *todo = 0; 3480 Todo *todo = 0;
3481 3481
3482 if (incidence == 0) { 3482 if (incidence == 0) {
3483 incidence = mViewManager->currentView()->selectedIncidences().first(); 3483 incidence = mViewManager->currentView()->selectedIncidences().first();
3484 if (incidence == 0) { 3484 if (incidence == 0) {
3485 incidence = mTodoList->selectedIncidences().first(); 3485 incidence = mTodoList->selectedIncidences().first();
3486 } 3486 }
3487 } 3487 }
3488 if ( incidence && incidence->typeID() == eventID ) { 3488 if ( incidence && incidence->typeID() == eventID ) {
3489 event = static_cast<Event *>(incidence); 3489 event = static_cast<Event *>(incidence);
3490 } else { 3490 } else {
3491 if ( incidence && incidence->typeID() == todoID ) { 3491 if ( incidence && incidence->typeID() == todoID ) {
3492 todo = static_cast<Todo *>(incidence); 3492 todo = static_cast<Todo *>(incidence);
3493 } 3493 }
3494 } 3494 }
3495 3495
3496 if (!event && !todo) { 3496 if (!event && !todo) {
3497 KMessageBox::sorry(this,i18n("No event selected.")); 3497 KMessageBox::sorry(this,i18n("No event selected."));
3498 return; 3498 return;
3499 } 3499 }
3500 3500
3501 PublishDialog *publishdlg = new PublishDialog(); 3501 PublishDialog *publishdlg = new PublishDialog();
3502 if (incidence->attendeeCount()>0) { 3502 if (incidence->attendeeCount()>0) {
3503 QPtrList<Attendee> attendees = incidence->attendees(); 3503 QPtrList<Attendee> attendees = incidence->attendees();
3504 attendees.first(); 3504 attendees.first();
3505 while ( attendees.current()!=0 ) { 3505 while ( attendees.current()!=0 ) {
3506 publishdlg->addAttendee(attendees.current()); 3506 publishdlg->addAttendee(attendees.current());
3507 attendees.next(); 3507 attendees.next();
3508 } 3508 }
3509 } 3509 }
3510 bool send = true; 3510 bool send = true;
3511 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 3511 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
3512 if ( publishdlg->exec() != QDialog::Accepted ) 3512 if ( publishdlg->exec() != QDialog::Accepted )
3513 send = false; 3513 send = false;
3514 } 3514 }
3515 if ( send ) { 3515 if ( send ) {
3516 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3516 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3517 if ( event ) { 3517 if ( event ) {
3518 Event *ev = new Event(*event); 3518 Event *ev = new Event(*event);
3519 ev->registerObserver(0); 3519 ev->registerObserver(0);
3520 ev->clearAttendees(); 3520 ev->clearAttendees();
3521 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3521 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3522 delete(ev); 3522 delete(ev);
3523 } 3523 }
3524 } else { 3524 } else {
3525 if ( todo ) { 3525 if ( todo ) {
3526 Todo *ev = new Todo(*todo); 3526 Todo *ev = new Todo(*todo);
3527 ev->registerObserver(0); 3527 ev->registerObserver(0);
3528 ev->clearAttendees(); 3528 ev->clearAttendees();
3529 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3529 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3530 delete(ev); 3530 delete(ev);
3531 } 3531 }
3532 } 3532 }
3533 } 3533 }
3534 } 3534 }
3535 delete publishdlg; 3535 delete publishdlg;
3536} 3536}
3537 3537
3538void CalendarView::schedule_request(Incidence *incidence) 3538void CalendarView::schedule_request(Incidence *incidence)
3539{ 3539{
3540 schedule(Scheduler::Request,incidence); 3540 schedule(Scheduler::Request,incidence);
3541} 3541}
3542 3542
3543void CalendarView::schedule_refresh(Incidence *incidence) 3543void CalendarView::schedule_refresh(Incidence *incidence)
3544{ 3544{
3545 schedule(Scheduler::Refresh,incidence); 3545 schedule(Scheduler::Refresh,incidence);
3546} 3546}
3547 3547
3548void CalendarView::schedule_cancel(Incidence *incidence) 3548void CalendarView::schedule_cancel(Incidence *incidence)
3549{ 3549{
3550 schedule(Scheduler::Cancel,incidence); 3550 schedule(Scheduler::Cancel,incidence);
3551} 3551}
3552 3552
3553void CalendarView::schedule_add(Incidence *incidence) 3553void CalendarView::schedule_add(Incidence *incidence)
3554{ 3554{
3555 schedule(Scheduler::Add,incidence); 3555 schedule(Scheduler::Add,incidence);
3556} 3556}
3557 3557
3558void CalendarView::schedule_reply(Incidence *incidence) 3558void CalendarView::schedule_reply(Incidence *incidence)
3559{ 3559{
3560 schedule(Scheduler::Reply,incidence); 3560 schedule(Scheduler::Reply,incidence);
3561} 3561}
3562 3562
3563void CalendarView::schedule_counter(Incidence *incidence) 3563void CalendarView::schedule_counter(Incidence *incidence)
3564{ 3564{
3565 schedule(Scheduler::Counter,incidence); 3565 schedule(Scheduler::Counter,incidence);
3566} 3566}
3567 3567
3568void CalendarView::schedule_declinecounter(Incidence *incidence) 3568void CalendarView::schedule_declinecounter(Incidence *incidence)
3569{ 3569{
3570 schedule(Scheduler::Declinecounter,incidence); 3570 schedule(Scheduler::Declinecounter,incidence);
3571} 3571}
3572 3572
3573void CalendarView::schedule_publish_freebusy(int daysToPublish) 3573void CalendarView::schedule_publish_freebusy(int daysToPublish)
3574{ 3574{
3575 QDateTime start = QDateTime::currentDateTime(); 3575 QDateTime start = QDateTime::currentDateTime();
3576 QDateTime end = start.addDays(daysToPublish); 3576 QDateTime end = start.addDays(daysToPublish);
3577 3577
3578 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 3578 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
3579 freebusy->setOrganizer(KOPrefs::instance()->email()); 3579 freebusy->setOrganizer(KOPrefs::instance()->email());
3580 3580
3581 3581
3582 PublishDialog *publishdlg = new PublishDialog(); 3582 PublishDialog *publishdlg = new PublishDialog();
3583 if ( publishdlg->exec() == QDialog::Accepted ) { 3583 if ( publishdlg->exec() == QDialog::Accepted ) {
3584 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3584 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3585 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 3585 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
3586 delete(freebusy); 3586 delete(freebusy);
3587 } 3587 }
3588 } 3588 }
3589 delete publishdlg; 3589 delete publishdlg;
3590} 3590}
3591 3591
3592void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 3592void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
3593{ 3593{
3594 Event *event = 0; 3594 Event *event = 0;
3595 Todo *todo = 0; 3595 Todo *todo = 0;
3596 3596
3597 if (incidence == 0) { 3597 if (incidence == 0) {
3598 incidence = mViewManager->currentView()->selectedIncidences().first(); 3598 incidence = mViewManager->currentView()->selectedIncidences().first();
3599 if (incidence == 0) { 3599 if (incidence == 0) {
3600 incidence = mTodoList->selectedIncidences().first(); 3600 incidence = mTodoList->selectedIncidences().first();
3601 } 3601 }
3602 } 3602 }
3603 if ( incidence && incidence->typeID() == eventID ) { 3603 if ( incidence && incidence->typeID() == eventID ) {
3604 event = static_cast<Event *>(incidence); 3604 event = static_cast<Event *>(incidence);
3605 } 3605 }
3606 if ( incidence && incidence->typeID() == todoID ) { 3606 if ( incidence && incidence->typeID() == todoID ) {
3607 todo = static_cast<Todo *>(incidence); 3607 todo = static_cast<Todo *>(incidence);
3608 } 3608 }
3609 3609
3610 if (!event && !todo) { 3610 if (!event && !todo) {
3611 KMessageBox::sorry(this,i18n("No event selected.")); 3611 KMessageBox::sorry(this,i18n("No event selected."));
3612 return; 3612 return;
3613 } 3613 }
3614 3614
3615 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 3615 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
3616 KMessageBox::sorry(this,i18n("The event has no attendees.")); 3616 KMessageBox::sorry(this,i18n("The event has no attendees."));
3617 return; 3617 return;
3618 } 3618 }
3619 3619
3620 Event *ev = 0; 3620 Event *ev = 0;
3621 if (event) ev = new Event(*event); 3621 if (event) ev = new Event(*event);
3622 Todo *to = 0; 3622 Todo *to = 0;
3623 if (todo) to = new Todo(*todo); 3623 if (todo) to = new Todo(*todo);
3624 3624
3625 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 3625 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
3626 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 3626 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
3627 if (!me) { 3627 if (!me) {
3628 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 3628 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
3629 return; 3629 return;
3630 } 3630 }
3631 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 3631 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
3632 StatusDialog *statdlg = new StatusDialog(this); 3632 StatusDialog *statdlg = new StatusDialog(this);
3633 if (!statdlg->exec()==QDialog::Accepted) return; 3633 if (!statdlg->exec()==QDialog::Accepted) return;
3634 me->setStatus( statdlg->status() ); 3634 me->setStatus( statdlg->status() );
3635 delete(statdlg); 3635 delete(statdlg);
3636 } 3636 }
3637 Attendee *menew = new Attendee(*me); 3637 Attendee *menew = new Attendee(*me);
3638 if (ev) { 3638 if (ev) {
3639 ev->clearAttendees(); 3639 ev->clearAttendees();
3640 ev->addAttendee(menew,false); 3640 ev->addAttendee(menew,false);
3641 } else { 3641 } else {
3642 if (to) { 3642 if (to) {
3643 todo->clearAttendees(); 3643 todo->clearAttendees();
3644 todo->addAttendee(menew,false); 3644 todo->addAttendee(menew,false);
3645 } 3645 }
3646 } 3646 }
3647 } 3647 }
3648 3648
3649 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3649 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3650 if (ev) { 3650 if (ev) {
3651 if ( !dlg->addMessage(ev,method) ) delete(ev); 3651 if ( !dlg->addMessage(ev,method) ) delete(ev);
3652 } else { 3652 } else {
3653 if (to) { 3653 if (to) {
3654 if ( !dlg->addMessage(to,method) ) delete(to); 3654 if ( !dlg->addMessage(to,method) ) delete(to);
3655 } 3655 }
3656 } 3656 }
3657} 3657}
3658 3658
3659void CalendarView::openAddressbook() 3659void CalendarView::openAddressbook()
3660{ 3660{
3661 KRun::runCommand("kaddressbook"); 3661 KRun::runCommand("kaddressbook");
3662} 3662}
3663 3663
3664void CalendarView::setModified(bool modified) 3664void CalendarView::setModified(bool modified)
3665{ 3665{
3666 if ( modified ) 3666 if ( modified )
3667 emit signalmodified(); 3667 emit signalmodified();
3668 if (mModified != modified) { 3668 if (mModified != modified) {
3669 mModified = modified; 3669 mModified = modified;
3670 emit modifiedChanged(mModified); 3670 emit modifiedChanged(mModified);
3671 } 3671 }
3672} 3672}
3673 3673
3674bool CalendarView::isReadOnly() 3674bool CalendarView::isReadOnly()
3675{ 3675{
3676 return mReadOnly; 3676 return mReadOnly;
3677} 3677}
3678 3678
3679void CalendarView::setReadOnly(bool readOnly) 3679void CalendarView::setReadOnly(bool readOnly)
3680{ 3680{
3681 if (mReadOnly != readOnly) { 3681 if (mReadOnly != readOnly) {
3682 mReadOnly = readOnly; 3682 mReadOnly = readOnly;
3683 emit readOnlyChanged(mReadOnly); 3683 emit readOnlyChanged(mReadOnly);
3684 } 3684 }
3685} 3685}
3686 3686
3687bool CalendarView::isModified() 3687bool CalendarView::isModified()
3688{ 3688{
3689 return mModified; 3689 return mModified;
3690} 3690}
3691void CalendarView::slotprintSelInc() 3691void CalendarView::slotprintSelInc()
3692{ 3692{
3693 if ( currentSelection() == 0 ) { 3693 if ( currentSelection() == 0 ) {
3694 KMessageBox::sorry(this,i18n("There is nothing selected!")); 3694 KMessageBox::sorry(this,i18n("There is nothing selected!"));
3695 return; 3695 return;
3696 } 3696 }
3697 showIncidence(); 3697 showIncidence();
3698 getEventViewerDialog()->print(); 3698 getEventViewerDialog()->print();
3699 3699
3700} 3700}
3701void CalendarView::printSetup() 3701void CalendarView::printSetup()
3702{ 3702{
3703#ifndef KORG_NOPRINTER 3703#ifndef KORG_NOPRINTER
3704 createPrinter(); 3704 createPrinter();
3705 3705
3706 mCalPrinter->setupPrinter(); 3706 mCalPrinter->setupPrinter();
3707#endif 3707#endif
3708} 3708}
3709 3709
3710void CalendarView::print() 3710void CalendarView::print()
3711{ 3711{
3712#ifndef KORG_NOPRINTER 3712#ifndef KORG_NOPRINTER
3713 createPrinter(); 3713 createPrinter();
3714 3714
3715 DateList tmpDateList = mNavigator->selectedDates(); 3715 DateList tmpDateList = mNavigator->selectedDates();
3716 mCalPrinter->print(CalPrinter::Month, 3716 mCalPrinter->print(CalPrinter::Month,
3717 tmpDateList.first(), tmpDateList.last()); 3717 tmpDateList.first(), tmpDateList.last());
3718#endif 3718#endif
3719} 3719}
3720 3720
3721void CalendarView::printPreview() 3721void CalendarView::printPreview()
3722{ 3722{
3723#ifndef KORG_NOPRINTER 3723#ifndef KORG_NOPRINTER
3724 kdDebug() << "CalendarView::printPreview()" << endl; 3724 kdDebug() << "CalendarView::printPreview()" << endl;
3725 3725
3726 createPrinter(); 3726 createPrinter();
3727 3727
3728 DateList tmpDateList = mNavigator->selectedDates(); 3728 DateList tmpDateList = mNavigator->selectedDates();
3729 3729
3730 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 3730 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
3731 tmpDateList.last()); 3731 tmpDateList.last());
3732#endif 3732#endif
3733} 3733}
3734 3734
3735void CalendarView::exportICalendar() 3735void CalendarView::exportICalendar()
3736{ 3736{
3737 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 3737 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
3738 3738
3739 // Force correct extension 3739 // Force correct extension
3740 if (filename.right(4) != ".ics") filename += ".ics"; 3740 if (filename.right(4) != ".ics") filename += ".ics";
3741 3741
3742 FileStorage storage( mCalendar, filename, new ICalFormat() ); 3742 FileStorage storage( mCalendar, filename, new ICalFormat() );
3743 storage.save(); 3743 storage.save();
3744} 3744}
3745 3745
3746bool CalendarView::exportVCalendar( QString filename ) 3746bool CalendarView::exportVCalendar( QString filename )
3747{ 3747{
3748 if (mCalendar->journals().count() > 0) { 3748 if (mCalendar->journals().count() > 0) {
3749 int result = KMessageBox::warningContinueCancel(this, 3749 int result = KMessageBox::warningContinueCancel(this,
3750 i18n("The journal entries can not be\nexported to a vCalendar file."), 3750 i18n("The journal entries can not be\nexported to a vCalendar file."),
3751 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3751 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3752 true); 3752 true);
3753 if (result != KMessageBox::Continue) return false; 3753 if (result != KMessageBox::Continue) return false;
3754 } 3754 }
3755 3755
3756 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3756 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3757 3757
3758 // Force correct extension 3758 // Force correct extension
3759 if (filename.right(4) != ".vcs") filename += ".vcs"; 3759 if (filename.right(4) != ".vcs") filename += ".vcs";
3760 3760
3761 FileStorage storage( mCalendar, filename, new VCalFormat ); 3761 FileStorage storage( mCalendar, filename, new VCalFormat );
3762 return storage.save(); 3762 return storage.save();
3763 3763
3764} 3764}
3765 3765
3766void CalendarView::eventUpdated(Incidence *) 3766void CalendarView::eventUpdated(Incidence *)
3767{ 3767{
3768 setModified(); 3768 setModified();
3769 // Don't call updateView here. The code, which has caused the update of the 3769 // Don't call updateView here. The code, which has caused the update of the
3770 // event is responsible for updating the view. 3770 // event is responsible for updating the view.
3771 // updateView(); 3771 // updateView();
3772} 3772}
3773 3773
3774void CalendarView::adaptNavigationUnits() 3774void CalendarView::adaptNavigationUnits()
3775{ 3775{
3776 if (mViewManager->currentView()->isEventView()) { 3776 if (mViewManager->currentView()->isEventView()) {
3777 int days = mViewManager->currentView()->currentDateCount(); 3777 int days = mViewManager->currentView()->currentDateCount();
3778 if (days == 1) { 3778 if (days == 1) {
3779 emit changeNavStringPrev(i18n("&Previous Day")); 3779 emit changeNavStringPrev(i18n("&Previous Day"));
3780 emit changeNavStringNext(i18n("&Next Day")); 3780 emit changeNavStringNext(i18n("&Next Day"));
3781 } else { 3781 } else {
3782 emit changeNavStringPrev(i18n("&Previous Week")); 3782 emit changeNavStringPrev(i18n("&Previous Week"));
3783 emit changeNavStringNext(i18n("&Next Week")); 3783 emit changeNavStringNext(i18n("&Next Week"));
3784 } 3784 }
3785 } 3785 }
3786} 3786}
3787 3787
3788void CalendarView::processMainViewSelection( Incidence *incidence ) 3788void CalendarView::processMainViewSelection( Incidence *incidence )
3789{ 3789{
3790 if ( incidence ) mTodoList->clearSelection(); 3790 if ( incidence ) mTodoList->clearSelection();
3791 processIncidenceSelection( incidence ); 3791 processIncidenceSelection( incidence );
3792} 3792}
3793 3793
3794void CalendarView::processTodoListSelection( Incidence *incidence ) 3794void CalendarView::processTodoListSelection( Incidence *incidence )
3795{ 3795{
3796 if ( incidence && mViewManager->currentView() ) { 3796 if ( incidence && mViewManager->currentView() ) {
3797 mViewManager->currentView()->clearSelection(); 3797 mViewManager->currentView()->clearSelection();
3798 } 3798 }
3799 processIncidenceSelection( incidence ); 3799 processIncidenceSelection( incidence );
3800} 3800}
3801 3801
3802void CalendarView::processIncidenceSelection( Incidence *incidence ) 3802void CalendarView::processIncidenceSelection( Incidence *incidence )
3803{ 3803{
3804 if ( incidence == mSelectedIncidence ) return; 3804 if ( incidence == mSelectedIncidence ) return;
3805 3805
3806 mSelectedIncidence = incidence; 3806 mSelectedIncidence = incidence;
3807 3807
3808 emit incidenceSelected( mSelectedIncidence ); 3808 emit incidenceSelected( mSelectedIncidence );
3809 3809
3810 if ( incidence && incidence->typeID() == eventID ) { 3810 if ( incidence && incidence->typeID() == eventID ) {
3811 Event *event = static_cast<Event *>( incidence ); 3811 Event *event = static_cast<Event *>( incidence );
3812 if ( event->organizer() == KOPrefs::instance()->email() ) { 3812 if ( event->organizer() == KOPrefs::instance()->email() ) {
3813 emit organizerEventsSelected( true ); 3813 emit organizerEventsSelected( true );
3814 } else { 3814 } else {
3815 emit organizerEventsSelected(false); 3815 emit organizerEventsSelected(false);
3816 } 3816 }
3817 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3817 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3818 KOPrefs::instance()->email() ) ) { 3818 KOPrefs::instance()->email() ) ) {
3819 emit groupEventsSelected( true ); 3819 emit groupEventsSelected( true );
3820 } else { 3820 } else {
3821 emit groupEventsSelected(false); 3821 emit groupEventsSelected(false);
3822 } 3822 }
3823 return; 3823 return;
3824 } else { 3824 } else {
3825 if ( incidence && incidence->typeID() == todoID ) { 3825 if ( incidence && incidence->typeID() == todoID ) {
3826 emit todoSelected( true ); 3826 emit todoSelected( true );
3827 Todo *event = static_cast<Todo *>( incidence ); 3827 Todo *event = static_cast<Todo *>( incidence );
3828 if ( event->organizer() == KOPrefs::instance()->email() ) { 3828 if ( event->organizer() == KOPrefs::instance()->email() ) {
3829 emit organizerEventsSelected( true ); 3829 emit organizerEventsSelected( true );
3830 } else { 3830 } else {
3831 emit organizerEventsSelected(false); 3831 emit organizerEventsSelected(false);
3832 } 3832 }
3833 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3833 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3834 KOPrefs::instance()->email() ) ) { 3834 KOPrefs::instance()->email() ) ) {
3835 emit groupEventsSelected( true ); 3835 emit groupEventsSelected( true );
3836 } else { 3836 } else {
3837 emit groupEventsSelected(false); 3837 emit groupEventsSelected(false);
3838 } 3838 }
3839 return; 3839 return;
3840 } else { 3840 } else {
3841 emit todoSelected( false ); 3841 emit todoSelected( false );
3842 emit organizerEventsSelected(false); 3842 emit organizerEventsSelected(false);
3843 emit groupEventsSelected(false); 3843 emit groupEventsSelected(false);
3844 } 3844 }
3845 return; 3845 return;
3846 } 3846 }
3847 3847
3848 /* if ( incidence && incidence->typeID() == todoID ) { 3848 /* if ( incidence && incidence->typeID() == todoID ) {
3849 emit todoSelected( true ); 3849 emit todoSelected( true );
3850 } else { 3850 } else {
3851 emit todoSelected( false ); 3851 emit todoSelected( false );
3852 }*/ 3852 }*/
3853} 3853}
3854 3854
3855 3855
3856void CalendarView::checkClipboard() 3856void CalendarView::checkClipboard()
3857{ 3857{
3858#ifndef KORG_NODND 3858#ifndef KORG_NODND
3859 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3859 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3860 emit pasteEnabled(true); 3860 emit pasteEnabled(true);
3861 } else { 3861 } else {
3862 emit pasteEnabled(false); 3862 emit pasteEnabled(false);
3863 } 3863 }
3864#endif 3864#endif
3865} 3865}
3866 3866
3867void CalendarView::showDates(const DateList &selectedDates) 3867void CalendarView::showDates(const DateList &selectedDates)
3868{ 3868{
3869 // kdDebug() << "CalendarView::selectDates()" << endl; 3869 // kdDebug() << "CalendarView::selectDates()" << endl;
3870 3870
3871 3871
3872 if ( !mBlockShowDates ) { 3872 if ( !mBlockShowDates ) {
3873 if ( mViewManager->currentView() ) { 3873 if ( mViewManager->currentView() ) {
3874 updateView( selectedDates.first(), selectedDates.last() ); 3874 updateView( selectedDates.first(), selectedDates.last() );
3875 } else { 3875 } else {
3876 mViewManager->showAgendaView(); 3876 mViewManager->showAgendaView();
3877 } 3877 }
3878 } 3878 }
3879 3879
3880 QDate date = selectedDates.first(); 3880 QDate date = selectedDates.first();
3881 if ( ! date.isValid() ) { 3881 if ( ! date.isValid() ) {
3882 topLevelWidget()->setCaption(""); 3882 topLevelWidget()->setCaption("");
3883 return; 3883 return;
3884 } 3884 }
3885 3885
3886 QString selDates; 3886 QString selDates;
3887 selDates = KGlobal::locale()->formatDate( date, true); 3887 selDates = KGlobal::locale()->formatDate( date, true);
3888 if (selectedDates.first() < selectedDates.last() ) 3888 if (selectedDates.first() < selectedDates.last() )
3889 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3889 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3890 else { 3890 else {
3891 QString addString; 3891 QString addString;
3892 if ( date == QDateTime::currentDateTime().date() ) 3892 if ( date == QDateTime::currentDateTime().date() )
3893 addString = i18n("Today"); 3893 addString = i18n("Today");
3894 else if ( date == QDateTime::currentDateTime().date().addDays(1) ) 3894 else if ( date == QDateTime::currentDateTime().date().addDays(1) )
3895 addString = i18n("Tomorrow"); 3895 addString = i18n("Tomorrow");
3896 else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) 3896 else if ( date == QDateTime::currentDateTime().date().addDays(-1) )
3897 addString = i18n("Yesterday"); 3897 addString = i18n("Yesterday");
3898 else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) 3898 else if ( date == QDateTime::currentDateTime().date().addDays(-2) )
3899 addString = i18n("Day before yesterday"); 3899 addString = i18n("Day before yesterday");
3900 else if ( date == QDateTime::currentDateTime().date().addDays(2) ) 3900 else if ( date == QDateTime::currentDateTime().date().addDays(2) )
3901 addString = i18n("Day after tomorrow"); 3901 addString = i18n("Day after tomorrow");
3902 if ( !addString.isEmpty() ) { 3902 if ( !addString.isEmpty() ) {
3903 topLevelWidget()->setCaption( addString+", " + selDates ); 3903 topLevelWidget()->setCaption( addString+", " + selDates );
3904 return; 3904 return;
3905 } 3905 }
3906 } 3906 }
3907 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3907 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3908 3908
3909} 3909}
3910 3910
3911QPtrList<CalFilter> CalendarView::filters() 3911QPtrList<CalFilter> CalendarView::filters()
3912{ 3912{
3913 return mFilters; 3913 return mFilters;
3914 3914
3915} 3915}
3916void CalendarView::editFilters() 3916void CalendarView::editFilters()
3917{ 3917{
3918 // kdDebug() << "CalendarView::editFilters()" << endl; 3918 // kdDebug() << "CalendarView::editFilters()" << endl;
3919 3919
3920 CalFilter *filter = mFilters.first(); 3920 CalFilter *filter = mFilters.first();
3921 while(filter) { 3921 while(filter) {
3922 kdDebug() << " Filter: " << filter->name() << endl; 3922 kdDebug() << " Filter: " << filter->name() << endl;
3923 filter = mFilters.next(); 3923 filter = mFilters.next();
3924 } 3924 }
3925 3925
3926 mDialogManager->showFilterEditDialog(&mFilters); 3926 mDialogManager->showFilterEditDialog(&mFilters);
3927} 3927}
3928void CalendarView::toggleFilter() 3928void CalendarView::toggleFilter()
3929{ 3929{
3930 showFilter(! mFilterView->isVisible()); 3930 showFilter(! mFilterView->isVisible());
3931} 3931}
3932 3932
3933KOFilterView *CalendarView::filterView() 3933KOFilterView *CalendarView::filterView()
3934{ 3934{
3935 return mFilterView; 3935 return mFilterView;
3936} 3936}
3937void CalendarView::selectFilter( int fil ) 3937void CalendarView::selectFilter( int fil )
3938{ 3938{
3939 mFilterView->setSelectedFilter( fil ); 3939 mFilterView->setSelectedFilter( fil );
3940} 3940}
3941void CalendarView::showFilter(bool visible) 3941void CalendarView::showFilter(bool visible)
3942{ 3942{
3943#if 0 3943#if 1
3944 if (visible) mCalEditView->show(); 3944 if (visible) {
3945 mCalEditView->readConfig();
3946 mCalEditView->show();
3947 }
3945 else mCalEditView->hide(); 3948 else mCalEditView->hide();
3946#else 3949#else
3947 if (visible) mFilterView->show(); 3950 if (visible) mFilterView->show();
3948 else mFilterView->hide(); 3951 else mFilterView->hide();
3949#endif 3952#endif
3950} 3953}
3951void CalendarView::toggleFilerEnabled( ) 3954void CalendarView::toggleFilerEnabled( )
3952{ 3955{
3953 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3956 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3954 if ( !mFilterView->filtersEnabled() ) 3957 if ( !mFilterView->filtersEnabled() )
3955 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3958 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3956 3959
3957} 3960}
3958void CalendarView::updateFilter() 3961void CalendarView::updateFilter()
3959{ 3962{
3960 CalFilter *filter = mFilterView->selectedFilter(); 3963 CalFilter *filter = mFilterView->selectedFilter();
3961 if (filter) { 3964 if (filter) {
3962 QString mess; 3965 QString mess;
3963 if (mFilterView->filtersEnabled()) { 3966 if (mFilterView->filtersEnabled()) {
3964 mess = i18n("Filter selected: ")+filter->name(); 3967 mess = i18n("Filter selected: ")+filter->name();
3965 filter->setEnabled(true); 3968 filter->setEnabled(true);
3966 } 3969 }
3967 else filter->setEnabled(false); 3970 else filter->setEnabled(false);
3968 mCalendar->setFilter(filter); 3971 mCalendar->setFilter(filter);
3969 updateView(); 3972 updateView();
3970 if ( !mess.isEmpty() ) 3973 if ( !mess.isEmpty() )
3971 topLevelWidget()->setCaption( mess ); 3974 topLevelWidget()->setCaption( mess );
3972 3975
3973 } 3976 }
3974} 3977}
3975 3978
3976void CalendarView::filterEdited() 3979void CalendarView::filterEdited()
3977{ 3980{
3978 mFilterView->updateFilters(); 3981 mFilterView->updateFilters();
3979 updateFilter(); 3982 updateFilter();
3980 writeSettings(); 3983 writeSettings();
3981} 3984}
3982 3985
3983 3986
3984void CalendarView::takeOverEvent() 3987void CalendarView::takeOverEvent()
3985{ 3988{
3986 Incidence *incidence = currentSelection(); 3989 Incidence *incidence = currentSelection();
3987 3990
3988 if (!incidence) return; 3991 if (!incidence) return;
3989 3992
3990 incidence->setOrganizer(KOPrefs::instance()->email()); 3993 incidence->setOrganizer(KOPrefs::instance()->email());
3991 incidence->recreate(); 3994 incidence->recreate();
3992 incidence->setReadOnly(false); 3995 incidence->setReadOnly(false);
3993 3996
3994 updateView(); 3997 updateView();
3995} 3998}
3996 3999
3997void CalendarView::takeOverCalendar() 4000void CalendarView::takeOverCalendar()
3998{ 4001{
3999 // TODO: Create Calendar::allIncidences() function and use it here 4002 // TODO: Create Calendar::allIncidences() function and use it here
4000 4003
4001 clearAllViews(); 4004 clearAllViews();
4002 QPtrList<Event> events = mCalendar->events(); 4005 QPtrList<Event> events = mCalendar->events();
4003 for(uint i=0; i<events.count(); ++i) { 4006 for(uint i=0; i<events.count(); ++i) {
4004 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 4007 events.at(i)->setOrganizer(KOPrefs::instance()->email());
4005 events.at(i)->recreate(); 4008 events.at(i)->recreate();
4006 events.at(i)->setReadOnly(false); 4009 events.at(i)->setReadOnly(false);
4007 } 4010 }
4008 4011
4009 QPtrList<Todo> todos = mCalendar->todos(); 4012 QPtrList<Todo> todos = mCalendar->todos();
4010 for(uint i=0; i<todos.count(); ++i) { 4013 for(uint i=0; i<todos.count(); ++i) {
4011 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 4014 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
4012 todos.at(i)->recreate(); 4015 todos.at(i)->recreate();
4013 todos.at(i)->setReadOnly(false); 4016 todos.at(i)->setReadOnly(false);
4014 } 4017 }
4015 4018
4016 QPtrList<Journal> journals = mCalendar->journals(); 4019 QPtrList<Journal> journals = mCalendar->journals();
4017 for(uint i=0; i<journals.count(); ++i) { 4020 for(uint i=0; i<journals.count(); ++i) {
4018 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 4021 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
4019 journals.at(i)->recreate(); 4022 journals.at(i)->recreate();
4020 journals.at(i)->setReadOnly(false); 4023 journals.at(i)->setReadOnly(false);
4021 } 4024 }
4022 4025
4023 updateView(); 4026 updateView();
4024} 4027}
4025 4028
4026void CalendarView::showIntro() 4029void CalendarView::showIntro()
4027{ 4030{
4028 kdDebug() << "To be implemented." << endl; 4031 kdDebug() << "To be implemented." << endl;
4029} 4032}
4030 4033
4031QWidgetStack *CalendarView::viewStack() 4034QWidgetStack *CalendarView::viewStack()
4032{ 4035{
4033 return mRightFrame; 4036 return mRightFrame;
4034} 4037}
4035 4038
4036QWidget *CalendarView::leftFrame() 4039QWidget *CalendarView::leftFrame()
4037{ 4040{
4038 return ( QWidget *)mLeftFrame; 4041 return ( QWidget *)mLeftFrame;
4039} 4042}
4040 4043
4041DateNavigator *CalendarView::dateNavigator() 4044DateNavigator *CalendarView::dateNavigator()
4042{ 4045{
4043 return mNavigator; 4046 return mNavigator;
4044} 4047}
4045 4048
4046KDateNavigator* CalendarView::dateNavigatorWidget() 4049KDateNavigator* CalendarView::dateNavigatorWidget()
4047{ 4050{
4048 return mDateNavigator->navigatorView(); 4051 return mDateNavigator->navigatorView();
4049} 4052}
4050void CalendarView::toggleDateNavigatorWidget() 4053void CalendarView::toggleDateNavigatorWidget()
4051{ 4054{
4052 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; 4055 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ;
4053 4056
4054 if (!KOPrefs::instance()->mShowDateNavigator ) 4057 if (!KOPrefs::instance()->mShowDateNavigator )
4055 mDateNavigator->hide(); 4058 mDateNavigator->hide();
4056 else 4059 else
4057 mDateNavigator->show(); 4060 mDateNavigator->show();
4058} 4061}
4059void CalendarView::addView(KOrg::BaseView *view) 4062void CalendarView::addView(KOrg::BaseView *view)
4060{ 4063{
4061 mViewManager->addView(view); 4064 mViewManager->addView(view);
4062} 4065}
4063 4066
4064void CalendarView::showView(KOrg::BaseView *view) 4067void CalendarView::showView(KOrg::BaseView *view)
4065{ 4068{
4066 mViewManager->showView(view, mLeftFrame->isVisible()); 4069 mViewManager->showView(view, mLeftFrame->isVisible());
4067} 4070}
4068 4071
4069Incidence *CalendarView::currentSelection() 4072Incidence *CalendarView::currentSelection()
4070{ 4073{
4071 return mViewManager->currentSelection(); 4074 return mViewManager->currentSelection();
4072} 4075}
4073void CalendarView::toggleAllDaySize() 4076void CalendarView::toggleAllDaySize()
4074{ 4077{
4075 /* 4078 /*
4076 if ( KOPrefs::instance()->mAllDaySize > 47 ) 4079 if ( KOPrefs::instance()->mAllDaySize > 47 )
4077 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 4080 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
4078 else 4081 else
4079 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 4082 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
4080 */ 4083 */
4081 viewManager()->agendaView()->toggleAllDay(); 4084 viewManager()->agendaView()->toggleAllDay();
4082} 4085}
4083void CalendarView::toggleExpand() 4086void CalendarView::toggleExpand()
4084{ 4087{
4085 // if ( mLeftFrame->isHidden() ) { 4088 // if ( mLeftFrame->isHidden() ) {
4086 // mLeftFrame->show(); 4089 // mLeftFrame->show();
4087 // emit calendarViewExpanded( false ); 4090 // emit calendarViewExpanded( false );
4088 // } else { 4091 // } else {
4089 // mLeftFrame->hide(); 4092 // mLeftFrame->hide();
4090 // emit calendarViewExpanded( true ); 4093 // emit calendarViewExpanded( true );
4091 // } 4094 // }
4092 //qDebug(" CalendarView::toggleExpand()"); 4095 //qDebug(" CalendarView::toggleExpand()");
4093 globalFlagBlockAgenda = 1; 4096 globalFlagBlockAgenda = 1;
4094 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 4097 emit calendarViewExpanded( !mLeftFrame->isHidden() );
4095 globalFlagBlockAgenda = 5; 4098 globalFlagBlockAgenda = 5;
4096 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 4099 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
4097 //mViewManager->showView( 0, true ); 4100 //mViewManager->showView( 0, true );
4098} 4101}
4099 4102
4100void CalendarView::calendarModified( bool modified, Calendar * ) 4103void CalendarView::calendarModified( bool modified, Calendar * )
4101{ 4104{
4102 setModified( modified ); 4105 setModified( modified );
4103} 4106}
4104 4107
4105Todo *CalendarView::selectedTodo() 4108Todo *CalendarView::selectedTodo()
4106{ 4109{
4107 Incidence *incidence = currentSelection(); 4110 Incidence *incidence = currentSelection();
4108 if ( incidence && incidence->typeID() == todoID ) { 4111 if ( incidence && incidence->typeID() == todoID ) {
4109 return static_cast<Todo *>( incidence ); 4112 return static_cast<Todo *>( incidence );
4110 } 4113 }
4111 4114
4112 incidence = mTodoList->selectedIncidences().first(); 4115 incidence = mTodoList->selectedIncidences().first();
4113 if ( incidence && incidence->typeID() == todoID ) { 4116 if ( incidence && incidence->typeID() == todoID ) {
4114 return static_cast<Todo *>( incidence ); 4117 return static_cast<Todo *>( incidence );
4115 } 4118 }
4116 4119
4117 return 0; 4120 return 0;
4118} 4121}
4119 4122
4120void CalendarView::dialogClosing(Incidence *in) 4123void CalendarView::dialogClosing(Incidence *in)
4121{ 4124{
4122 // mDialogList.remove(in); 4125 // mDialogList.remove(in);
4123} 4126}
4124 4127
4125void CalendarView::showIncidence() 4128void CalendarView::showIncidence()
4126{ 4129{
4127 mViewerCallerIsSearchDialog = false; 4130 mViewerCallerIsSearchDialog = false;
4128 Incidence *incidence = currentSelection(); 4131 Incidence *incidence = currentSelection();
4129 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4132 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4130 if ( incidence ) { 4133 if ( incidence ) {
4131 ShowIncidenceVisitor v; 4134 ShowIncidenceVisitor v;
4132 v.act( incidence, this ); 4135 v.act( incidence, this );
4133 } 4136 }
4134} 4137}
4135void CalendarView::editIncidenceDescription() 4138void CalendarView::editIncidenceDescription()
4136{ 4139{
4137 mFlagEditDescription = true; 4140 mFlagEditDescription = true;
4138 editIncidence(); 4141 editIncidence();
4139 mFlagEditDescription = false; 4142 mFlagEditDescription = false;
4140} 4143}
4141void CalendarView::editIncidence() 4144void CalendarView::editIncidence()
4142{ 4145{
4143 // qDebug("editIncidence() "); 4146 // qDebug("editIncidence() ");
4144 Incidence *incidence = currentSelection(); 4147 Incidence *incidence = currentSelection();
4145 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4148 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4146 if ( incidence ) { 4149 if ( incidence ) {
4147 EditIncidenceVisitor v; 4150 EditIncidenceVisitor v;
4148 v.act( incidence, this ); 4151 v.act( incidence, this );
4149 } 4152 }
4150} 4153}
4151 4154
4152void CalendarView::deleteIncidence() 4155void CalendarView::deleteIncidence()
4153{ 4156{
4154 Incidence *incidence = currentSelection(); 4157 Incidence *incidence = currentSelection();
4155 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4158 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4156 if ( incidence ) { 4159 if ( incidence ) {
4157 deleteIncidence(incidence); 4160 deleteIncidence(incidence);
4158 } 4161 }
4159} 4162}
4160void CalendarView::showIncidence(QString uid) 4163void CalendarView::showIncidence(QString uid)
4161{ 4164{
4162 Incidence *inc = mCalendar->incidence( uid ); 4165 Incidence *inc = mCalendar->incidence( uid );
4163 if ( inc ) 4166 if ( inc )
4164 showIncidence( inc ); 4167 showIncidence( inc );
4165} 4168}
4166void CalendarView::showIncidence(Incidence *incidence) 4169void CalendarView::showIncidence(Incidence *incidence)
4167{ 4170{
4168 mViewerCallerIsSearchDialog = false; 4171 mViewerCallerIsSearchDialog = false;
4169 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); 4172 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() );
4170 if ( sender() && mDialogManager->getSearchDialog() ) { 4173 if ( sender() && mDialogManager->getSearchDialog() ) {
4171 if ( sender () == mDialogManager->getSearchDialog()->listview() ) { 4174 if ( sender () == mDialogManager->getSearchDialog()->listview() ) {
4172 mViewerCallerIsSearchDialog = true; 4175 mViewerCallerIsSearchDialog = true;
4173 } 4176 }
4174 } 4177 }
4175 if ( incidence ) { 4178 if ( incidence ) {
4176 ShowIncidenceVisitor v; 4179 ShowIncidenceVisitor v;
4177 v.act( incidence, this ); 4180 v.act( incidence, this );
4178 } 4181 }
4179} 4182}
4180 4183
4181void CalendarView::editIncidence(Incidence *incidence) 4184void CalendarView::editIncidence(Incidence *incidence)
4182{ 4185{
4183 if ( incidence ) { 4186 if ( incidence ) {
4184 4187
4185 EditIncidenceVisitor v; 4188 EditIncidenceVisitor v;
4186 v.act( incidence, this ); 4189 v.act( incidence, this );
4187 4190
4188 } 4191 }
4189} 4192}
4190 4193
4191void CalendarView::deleteIncidence(Incidence *incidence) 4194void CalendarView::deleteIncidence(Incidence *incidence)
4192{ 4195{
4193 //qDebug(" CalendarView::deleteIncidence "); 4196 //qDebug(" CalendarView::deleteIncidence ");
4194 if ( incidence ) { 4197 if ( incidence ) {
4195 DeleteIncidenceVisitor v; 4198 DeleteIncidenceVisitor v;
4196 v.act( incidence, this ); 4199 v.act( incidence, this );
4197 } 4200 }
4198} 4201}
4199 4202
4200 4203
4201void CalendarView::lookForOutgoingMessages() 4204void CalendarView::lookForOutgoingMessages()
4202{ 4205{
4203 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 4206 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
4204 ogd->loadMessages(); 4207 ogd->loadMessages();
4205} 4208}
4206 4209
4207void CalendarView::lookForIncomingMessages() 4210void CalendarView::lookForIncomingMessages()
4208{ 4211{
4209 IncomingDialog *icd = mDialogManager->incomingDialog(); 4212 IncomingDialog *icd = mDialogManager->incomingDialog();
4210 icd->retrieve(); 4213 icd->retrieve();
4211} 4214}
4212 4215
4213bool CalendarView::removeCompletedSubTodos( Todo* t ) 4216bool CalendarView::removeCompletedSubTodos( Todo* t )
4214{ 4217{
4215 bool deleteTodo = true; 4218 bool deleteTodo = true;
4216 QPtrList<Incidence> subTodos; 4219 QPtrList<Incidence> subTodos;
4217 Incidence *aTodo; 4220 Incidence *aTodo;
4218 subTodos = t->relations(); 4221 subTodos = t->relations();
4219 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 4222 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
4220 if (! removeCompletedSubTodos( (Todo*) aTodo )) 4223 if (! removeCompletedSubTodos( (Todo*) aTodo ))
4221 deleteTodo = false; 4224 deleteTodo = false;
4222 } 4225 }
4223 if ( deleteTodo ) { 4226 if ( deleteTodo ) {
4224 if ( t->isCompleted() && !t->doesRecur()) { 4227 if ( t->isCompleted() && !t->doesRecur()) {
4225 checkExternalId( t ); 4228 checkExternalId( t );
4226 mCalendar->deleteTodo( t ); 4229 mCalendar->deleteTodo( t );
4227 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 4230 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
4228 } 4231 }
4229 else 4232 else
4230 deleteTodo = false; 4233 deleteTodo = false;
4231 } 4234 }
4232 return deleteTodo; 4235 return deleteTodo;
4233 4236
4234} 4237}
4235void CalendarView::purgeCompleted() 4238void CalendarView::purgeCompleted()
4236{ 4239{
4237 int result = KMessageBox::warningContinueCancel(this, 4240 int result = KMessageBox::warningContinueCancel(this,
4238 i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); 4241 i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge"));
4239 4242
4240 if (result == KMessageBox::Continue) { 4243 if (result == KMessageBox::Continue) {
4241 4244
4242 QPtrList<Todo> todoCal; 4245 QPtrList<Todo> todoCal;
4243 QPtrList<Todo> rootTodos; 4246 QPtrList<Todo> rootTodos;
4244 //QPtrList<Incidence> rel; 4247 //QPtrList<Incidence> rel;
4245 Todo *aTodo;//, *rTodo; 4248 Todo *aTodo;//, *rTodo;
4246 Incidence *rIncidence; 4249 Incidence *rIncidence;
4247 bool childDelete = false; 4250 bool childDelete = false;
4248 bool deletedOne = true; 4251 bool deletedOne = true;
4249 todoCal = calendar()->todos(); 4252 todoCal = calendar()->todos();
4250 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 4253 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
4251 if ( !aTodo->relatedTo() ) 4254 if ( !aTodo->relatedTo() )
4252 rootTodos.append( aTodo ); 4255 rootTodos.append( aTodo );
4253 } 4256 }
4254 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 4257 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
4255 removeCompletedSubTodos( aTodo ); 4258 removeCompletedSubTodos( aTodo );
4256 } 4259 }
4257 4260
4258 updateView(); 4261 updateView();
4259 } 4262 }
4260} 4263}
4261 4264
4262void CalendarView::slotCalendarChanged() 4265void CalendarView::slotCalendarChanged()
4263{ 4266{
4264 ; 4267 ;
4265} 4268}
4266 4269
4267void CalendarView::keyPressEvent ( QKeyEvent *e) 4270void CalendarView::keyPressEvent ( QKeyEvent *e)
4268{ 4271{
4269 //qDebug(" alendarView::keyPressEvent "); 4272 //qDebug(" alendarView::keyPressEvent ");
4270 e->ignore(); 4273 e->ignore();
4271} 4274}
4272 4275
4273 4276
4274bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) 4277bool CalendarView::sync(KSyncManager* manager, QString filename, int mode)
4275{ 4278{
4276 // mSyncManager = manager; 4279 // mSyncManager = manager;
4277 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { 4280 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) {
4278 qDebug("KO: SyncKDE request detected!"); 4281 qDebug("KO: SyncKDE request detected!");
4279 } 4282 }
4280 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 4283 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
4281 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 4284 mCurrentSyncName = mSyncManager->getCurrentSyncName();
4282 return syncCalendar( filename, mode ); 4285 return syncCalendar( filename, mode );
4283} 4286}
4284bool CalendarView::syncExternal(KSyncManager* manager, QString resource) 4287bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
4285{ 4288{
4286 //mSyncManager = manager; 4289 //mSyncManager = manager;
4287 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 4290 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
4288 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 4291 mCurrentSyncName = mSyncManager->getCurrentSyncName();
4289 if ( resource == "sharp" ) 4292 if ( resource == "sharp" )
4290 syncExternal( 0 ); 4293 syncExternal( 0 );
4291 if ( resource == "phone" ) 4294 if ( resource == "phone" )
4292 syncExternal( 1 ); 4295 syncExternal( 1 );
4293 // pending setmodified 4296 // pending setmodified
4294 return true; 4297 return true;
4295} 4298}
4296void CalendarView::setSyncManager(KSyncManager* manager) 4299void CalendarView::setSyncManager(KSyncManager* manager)
4297{ 4300{
4298 mSyncManager = manager; 4301 mSyncManager = manager;
4299} 4302}
4300 4303
4301void CalendarView::removeSyncInfo( QString syncProfile) 4304void CalendarView::removeSyncInfo( QString syncProfile)
4302{ 4305{
4303 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); 4306 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1());
4304 mCalendar->removeSyncInfo( syncProfile ); 4307 mCalendar->removeSyncInfo( syncProfile );
4305 4308
4306} 4309}
4307 4310
4308void CalendarView::undo_delete() 4311void CalendarView::undo_delete()
4309{ 4312{
4310 //qDebug("undo_delete() "); 4313 //qDebug("undo_delete() ");
4311 Incidence* undo = mCalendar->undoIncidence(); 4314 Incidence* undo = mCalendar->undoIncidence();
4312 if ( !undo ) { 4315 if ( !undo ) {
4313 KMessageBox::sorry(this,i18n("There is nothing to undo!"), 4316 KMessageBox::sorry(this,i18n("There is nothing to undo!"),
4314 i18n("KO/Pi")); 4317 i18n("KO/Pi"));
4315 return; 4318 return;
4316 } 4319 }
4317 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + 4320 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) +
4318 i18n("\nAre you sure you want\nto restore this?"), 4321 i18n("\nAre you sure you want\nto restore this?"),
4319 i18n("KO/Pi Confirmation"),i18n("Restore"))) { 4322 i18n("KO/Pi Confirmation"),i18n("Restore"))) {
4320 mCalendar->undoDeleteIncidence(); 4323 mCalendar->undoDeleteIncidence();
4321 updateView(); 4324 updateView();
4322 } 4325 }
4323} 4326}
4324 4327
4325void CalendarView::slotViewerClosed() 4328void CalendarView::slotViewerClosed()
4326{ 4329{
4327 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); 4330 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) );
4328} 4331}
4329 4332
4330void CalendarView::resetFocus() 4333void CalendarView::resetFocus()
4331{ 4334{
4332 if ( mViewerCallerIsSearchDialog ) { 4335 if ( mViewerCallerIsSearchDialog ) {
4333 if ( mDialogManager->getSearchDialog()->isVisible() ){ 4336 if ( mDialogManager->getSearchDialog()->isVisible() ){
4334 mDialogManager->getSearchDialog()->raise(); 4337 mDialogManager->getSearchDialog()->raise();
4335 mDialogManager->getSearchDialog()->setActiveWindow(); 4338 mDialogManager->getSearchDialog()->setActiveWindow();
4336 mDialogManager->getSearchDialog()->listview()->resetFocus(); 4339 mDialogManager->getSearchDialog()->listview()->resetFocus();
4337 } else 4340 } else
4338 mViewerCallerIsSearchDialog = false; 4341 mViewerCallerIsSearchDialog = false;
4339 } 4342 }
4340 if ( !mViewerCallerIsSearchDialog ) { 4343 if ( !mViewerCallerIsSearchDialog ) {
4341 //mViewManager->currentView()->setFocus(); 4344 //mViewManager->currentView()->setFocus();
4342 //qDebug("sssssssssssssssset focus "); 4345 //qDebug("sssssssssssssssset focus ");
4343 topLevelWidget()->raise(); 4346 topLevelWidget()->raise();
4344 setActiveWindow(); 4347 setActiveWindow();
4345 //setFocus(); 4348 //setFocus();
4346 } 4349 }
4347 mViewerCallerIsSearchDialog = false; 4350 mViewerCallerIsSearchDialog = false;
4348} 4351}
4349 4352
4350void CalendarView::showNextAlarms() 4353void CalendarView::showNextAlarms()
4351{ 4354{
4352 QString message; 4355 QString message;
4353 QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); 4356 QDateTime nextAl = mCalendar->nextAlarmEventDateTime();
4354 if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { 4357 if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) {
4355 QString sum = mCalendar->nextSummary(); 4358 QString sum = mCalendar->nextSummary();
4356 QDateTime nextA = mNextAlarmDateTime; 4359 QDateTime nextA = mNextAlarmDateTime;
4357 QDateTime cur = QDateTime::currentDateTime(); 4360 QDateTime cur = QDateTime::currentDateTime();
4358 int secs = cur.secsTo( nextA ); 4361 int secs = cur.secsTo( nextA );
4359 int min = secs /60; 4362 int min = secs /60;
4360 int hours = min /60; 4363 int hours = min /60;
4361 min = min % 60; 4364 min = min % 60;
4362 int days = hours /24; 4365 int days = hours /24;
4363 hours = hours % 24; 4366 hours = hours % 24;
4364 4367
4365 //message = i18n("The next alarm is in:\n"); 4368 //message = i18n("The next alarm is in:\n");
4366 if ( days > 1 ) 4369 if ( days > 1 )
4367 message += i18n("%1 days\n").arg( days ); 4370 message += i18n("%1 days\n").arg( days );
4368 else if ( days == 1 ) 4371 else if ( days == 1 )
4369 message += i18n("1 day\n"); 4372 message += i18n("1 day\n");
4370 if ( hours > 1 ) 4373 if ( hours > 1 )
4371 message += i18n("%1 hours\n").arg( hours ); 4374 message += i18n("%1 hours\n").arg( hours );
4372 else if ( hours == 1 ) 4375 else if ( hours == 1 )
4373 message += i18n("1 hour\n"); 4376 message += i18n("1 hour\n");
4374 if ( min > 1 ) 4377 if ( min > 1 )
4375 message += i18n("%1 minutes\n").arg( min ); 4378 message += i18n("%1 minutes\n").arg( min );
4376 else if ( min == 1 ) 4379 else if ( min == 1 )
4377 message += i18n("1 minute\n"); 4380 message += i18n("1 minute\n");
4378 if ( message.isEmpty() ) 4381 if ( message.isEmpty() )
4379 message = i18n("The next alarm is in\nless than one minute!"); 4382 message = i18n("The next alarm is in\nless than one minute!");
4380 else 4383 else
4381 message = i18n("The next alarm is in:\n") + message; 4384 message = i18n("The next alarm is in:\n") + message;
4382 message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; 4385 message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ;
4383 } else { 4386 } else {
4384 message = i18n("There is no next alarm."); 4387 message = i18n("There is no next alarm.");
4385 4388
4386 } 4389 }
4387#ifdef DESKTOP_VERSION 4390#ifdef DESKTOP_VERSION
4388 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 4391 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
4389 message += i18n("\nThe internal alarm notification is disabled!\n"); 4392 message += i18n("\nThe internal alarm notification is disabled!\n");
4390 message += i18n("Enable it in the settings menu, TAB alarm."); 4393 message += i18n("Enable it in the settings menu, TAB alarm.");
4391 } 4394 }
4392 4395
4393#endif 4396#endif
4394 KMessageBox::information( this, message); 4397 KMessageBox::information( this, message);
4395} 4398}
diff --git a/korganizer/kofilterview.cpp b/korganizer/kofilterview.cpp
index dc6237b..d79b28e 100644
--- a/korganizer/kofilterview.cpp
+++ b/korganizer/kofilterview.cpp
@@ -1,176 +1,383 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qcheckbox.h> 24#include <qcheckbox.h>
25#include <qcombobox.h> 25#include <qcombobox.h>
26#include <qpushbutton.h> 26#include <qpushbutton.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qlabel.h> 28#include <qlabel.h>
29#include <qdialog.h>
29 30
30 31
31#include <libkcal/calfilter.h> 32#include <libkcal/calfilter.h>
32 33
33#include "kofilterview.h" 34#include "kofilterview.h"
35#include "koprefs.h"
34#include <kiconloader.h> 36#include <kiconloader.h>
35#include <kglobal.h> 37#include <kglobal.h>
38#include <kcolorbutton.h>
39#include <kmessagebox.h>
40
41
42#include <kurlrequester.h>
43#include <klineedit.h>
44
45class KONewCalPrefs : public QDialog
46{
47 public:
48 KONewCalPrefs( QWidget *parent=0, const char *name=0 ) :
49 QDialog( parent, name, true )
50 {
51 setCaption( i18n("Add new Calendar") );
52 QVBoxLayout* lay = new QVBoxLayout( this );
53 lay->setSpacing( 3 );
54 lay->setMargin( 3 );
55 QLabel * lab = new QLabel( i18n("<b>Name of new calendar:</b>"), this );
56 lay->addWidget( lab );
57 nameE = new KLineEdit( this );
58 lay->addWidget( nameE );
59 lab = new QLabel( i18n("Local ical (*.ics) file:"), this );
60 lay->addWidget( lab );
61 url = new KURLRequester ( this );
62 lay->addWidget( url );
63 QPushButton * ok = new QPushButton( i18n("OK"), this );
64 lay->addWidget( ok );
65 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
66 lay->addWidget( cancel );
67 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
68 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
69 resize( 200, 200 );
70 }
71
72 QString calName() { return nameE->text(); }
73 QString calFileName() { return url->url(); }
74private:
75 KLineEdit* nameE;
76 KURLRequester *url;
77};
78
36 79
37KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent, 80KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent,
38 const char* name,WFlags fl ) 81 const char* name,WFlags fl )
39 : KOFilterView_base(parent,name,fl) 82 : KOFilterView_base(parent,name,fl)
40{ 83{
41 mFilters = filterList; 84 mFilters = filterList;
42 85
43 connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged())); 86 connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged()));
44 connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged())); 87 connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged()));
45 connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters())); 88 connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters()));
46} 89}
47 90
48KOFilterView::~KOFilterView() 91KOFilterView::~KOFilterView()
49{ 92{
50 // no need to delete child widgets, Qt does it all for us 93 // no need to delete child widgets, Qt does it all for us
51} 94}
52 95
53bool KOFilterView::filtersEnabled() 96bool KOFilterView::filtersEnabled()
54{ 97{
55 return mEnabledCheck->isChecked(); 98 return mEnabledCheck->isChecked();
56} 99}
57 100
58void KOFilterView::setFiltersEnabled(bool set) 101void KOFilterView::setFiltersEnabled(bool set)
59{ 102{
60 mEnabledCheck->setChecked(set); 103 mEnabledCheck->setChecked(set);
61 emit filterChanged(); 104 emit filterChanged();
62} 105}
63 106
64 107
65void KOFilterView::updateFilters() 108void KOFilterView::updateFilters()
66{ 109{
67 mSelectionCombo->clear(); 110 mSelectionCombo->clear();
68 111
69 CalFilter *filter = mFilters->first(); 112 CalFilter *filter = mFilters->first();
70 while(filter) { 113 while(filter) {
71 mSelectionCombo->insertItem(filter->name()); 114 mSelectionCombo->insertItem(filter->name());
72 filter = mFilters->next(); 115 filter = mFilters->next();
73 } 116 }
74} 117}
75 118
76CalFilter *KOFilterView::selectedFilter() 119CalFilter *KOFilterView::selectedFilter()
77{ 120{
78 CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); 121 CalFilter *f = mFilters->at(mSelectionCombo->currentItem());
79 return f; 122 return f;
80} 123}
81 124
82void KOFilterView::setSelectedFilter(QString filterName) 125void KOFilterView::setSelectedFilter(QString filterName)
83{ 126{
84 int filter_num = mSelectionCombo->count(); 127 int filter_num = mSelectionCombo->count();
85 int i; 128 int i;
86 for (i=0;i<filter_num;i++) { 129 for (i=0;i<filter_num;i++) {
87 if (mSelectionCombo->text(i)==filterName) 130 if (mSelectionCombo->text(i)==filterName)
88 mSelectionCombo->setCurrentItem(i); 131 mSelectionCombo->setCurrentItem(i);
89 } 132 }
90 emit filterChanged(); 133 emit filterChanged();
91} 134}
92void KOFilterView::setSelectedFilter( int fil ) 135void KOFilterView::setSelectedFilter( int fil )
93{ 136{
94 if ( fil >= mSelectionCombo->count() ) 137 if ( fil >= mSelectionCombo->count() )
95 return; 138 return;
96 mSelectionCombo->setCurrentItem( fil ); 139 mSelectionCombo->setCurrentItem( fil );
97 emit filterChanged(); 140 emit filterChanged();
98} 141}
99 142
100 143
101 144
102KOCalEditView::KOCalEditView(QWidget* parent, 145KOCalEditView::KOCalEditView(QWidget* parent,
103 const char* name ) 146 const char* name )
104 : QWidget(parent,name) 147 : QWidget(parent,name)
105{ 148{
106 /* 149 mw = 0;
107 connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged())); 150 ml = new QVBoxLayout ( this );
108 connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged())); 151}
109 connect(mEditButton,SIGNAL(clicked()),SIGNAL(editCalEdits())); 152
110 */ 153KOCalEditView::~KOCalEditView()
111 QGridLayout* mainLayout = new QGridLayout ( this , 2, 6 ); 154{
112 QPushButton * addBut = new QPushButton ( this ); 155 // no need to delete child widgets, Qt does it all for us
156}
157void KOCalEditView::selectCal(int id ,bool b)
158{
159 KOPrefs::instance()->getCalendar( id )->isEnabled = b;
160 emit calendarEnabled ( id, b );
161
162}
163void KOCalEditView::selectStdCal( int id, bool b )
164{
165
166 if ( !b ) {
167 KOCalCheckButton* it = (KOCalCheckButton*) sender();
168 if ( it ) {
169 it->blockSignals( true );
170 it->setChecked( true );
171 it->blockSignals( false );
172 return;
173 }
174 return;
175 }
176 KOCalCheckButton* sen = (KOCalCheckButton*) sender();
177 KOCalCheckButton* it = mStdandardB.first();
178 while ( it ) {
179 if ( it->isChecked() ) {
180 if ( it != sen ) {
181 it->blockSignals( true );
182 it->setChecked( false );
183 it->blockSignals( false );
184 break;
185 }
186 }
187 it = mStdandardB.next();
188 }
189 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
190 while ( kkf ) {
191 kkf->isStandard = false;
192 kkf = KOPrefs::instance()->mCalendars.next();
193 }
194 KOPrefs::instance()->getCalendar( id )->isStandard = true;
195 emit setCalendarDefault ( id );
196}
197
198void KOCalEditView::selectCalAlarm(int id ,bool b )
199{
200 KOPrefs::instance()->getCalendar( id )->isAlarmEnabled = b;
201 emit alarmEnabled ( id , b );
202}
203void KOCalEditView::selectReadOnly(int id ,bool b )
204{
205 KOPrefs::instance()->getCalendar( id )->isReadOnly = b;
206 emit calendarReadonly ( id , b );
207
208}
209void KOCalEditView::setColor( const QColor& c, int id )
210{
211 KOPrefs::instance()->getCalendar( id )->mDefaultColor = c;
212}
213void KOCalEditView::deleteCal( int id )
214{
215 KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id );
216 QString name = kkf->mName;
217 QString file = kkf->mFileName;
218 if ( KMessageBox::warningContinueCancel( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b><tr> Do you want to remove this calendar from KO/Pi? (The file is not removed, of course!)").arg(name).arg(file) ) != KMessageBox::Continue ) return;
219 emit removeCalendar ( id );
220 KOPrefs::instance()->mCalendars.remove ( kkf );
221 readConfig();
222}
223void KOCalEditView::infoCal( int id )
224{
225 QString name = KOPrefs::instance()->getCalendar( id )->mName;
226 QString file = KOPrefs::instance()->getCalendar( id )->mFileName;
227 KMessageBox::information( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file) );
228}
229void KOCalEditView::readConfig()
230{
231
232 mStdandardB.clear();
233 mEnabledB.clear();
234 mAlarmB.clear();
235 mROB.clear();
236
237 if ( mw ) delete mw;
238 mw = new QWidget ( this );
239 ml->addWidget ( mw );
240
241 mainLayout = new QGridLayout ( mw , 2, 8 );
242 mainLayout->setSpacing( 3 );
243 QPushButton * addBut = new QPushButton ( mw );
113 mainLayout->addWidget( addBut,0,0 ); 244 mainLayout->addWidget( addBut,0,0 );
114 addBut->setPixmap ( SmallIcon("plus")); 245 addBut->setPixmap ( SmallIcon("plus"));
115 connect(addBut,SIGNAL(clicked()),SLOT(addCal())); 246 connect(addBut,SIGNAL(clicked()),SLOT(addCal()));
116 addBut->setMaximumWidth( addBut->sizeHint().height() ); 247 addBut->setMaximumWidth( addBut->sizeHint().height() );
117 248
118 addBut = new QPushButton ( this ); 249 addBut = new QPushButton ( mw );
119 mainLayout->addWidget( addBut,0,1 ); 250 mainLayout->addWidget( addBut,0,1 );
120 addBut->setPixmap ( SmallIcon("eye")); 251 addBut->setPixmap ( SmallIcon("eye"));
121 connect(addBut,SIGNAL(clicked()),SLOT(enableAll())); 252 connect(addBut,SIGNAL(clicked()),SLOT(enableAll()));
122 addBut->setMaximumWidth( addBut->sizeHint().height() ); 253 addBut->setMaximumWidth( addBut->sizeHint().height() );
123 254
124 QLabel* lab = new QLabel ( " "+i18n("Calendar")+" ", this ); 255 QLabel* lab = new QLabel ( " "+i18n("Calendar")+" ", mw );
125 mainLayout->addWidget( lab,0,2 ); 256 mainLayout->addWidget( lab,0,2 );
126 257
127 addBut = new QPushButton ( this ); 258 addBut = new QPushButton ( mw );
128 mainLayout->addWidget( addBut,0,3 ); 259 mainLayout->addWidget( addBut,0,3 );
129 addBut->setPixmap ( SmallIcon("bell")); 260 addBut->setPixmap ( SmallIcon("bell"));
130 connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm())); 261 connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm()));
131 addBut->setMaximumWidth( addBut->sizeHint().height() ); 262 addBut->setMaximumWidth( addBut->sizeHint().height() );
132 263
133 addBut = new QPushButton ( this ); 264 addBut = new QPushButton ( mw );
134 mainLayout->addWidget( addBut,0,4 ); 265 mainLayout->addWidget( addBut,0,4 );
135 addBut->setPixmap ( SmallIcon("pencil")); 266 addBut->setPixmap ( SmallIcon("pencil"));
136 connect(addBut,SIGNAL(clicked()),SLOT(disableRO())); 267 connect(addBut,SIGNAL(clicked()),SLOT(disableRO()));
137 addBut->setMaximumWidth( addBut->sizeHint().height() ); 268 addBut->setMaximumWidth( addBut->sizeHint().height() );
138 269
139 addBut = new QPushButton ( this ); 270 lab = new QLabel ( i18n(" Color "), mw );
140 mainLayout->addWidget( addBut,0,5 ); 271 mainLayout->addWidget( lab,0,5 );
272#if 0
273 addBut = new QPushButton ( mw );
274 mainLayout->addWidget( addBut,0,6 );
141 addBut->setPixmap ( SmallIcon("minus")); 275 addBut->setPixmap ( SmallIcon("minus"));
142 connect(addBut,SIGNAL(clicked()),SLOT(deleteAll())); 276 connect(addBut,SIGNAL(clicked()),SLOT(deleteAll()));
143 addBut->setMaximumWidth( addBut->sizeHint().height() ); 277 addBut->setMaximumWidth( addBut->sizeHint().height() );
278#endif
144 279
145 280
281 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
282 int row = 1;
283 while ( kkf ) {
146 284
147} 285 KOCalCheckButton* cb = new KOCalCheckButton( mw );
148 286 mainLayout->addWidget( cb,row,0 );mStdandardB.append( cb );
149KOCalEditView::~KOCalEditView() 287 cb->setChecked( kkf->isStandard );
150{ 288 cb->setNum( kkf->mCalNumber );
151 // no need to delete child widgets, Qt does it all for us 289 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectStdCal(int,bool) ) );
152} 290 cb = new KOCalCheckButton( mw );
153void KOCalEditView::readConfig( KConfig *) 291 mainLayout->addWidget( cb,row,1 );mEnabledB.append( cb );
154{ 292 cb->setChecked( kkf->isEnabled );
293 cb->setNum( kkf->mCalNumber );
294 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCal(int,bool) ) );
295 KOCalButton* name = new KOCalButton( mw );
296 name->setNum( kkf->mCalNumber );
297 name->setText( kkf->mName );
298 mainLayout->addWidget( name,row,2 );
299 connect (name, SIGNAL (selectNum(int)), SLOT ( infoCal(int) ) );
300 cb = new KOCalCheckButton( mw );
301 mainLayout->addWidget( cb,row,3 );mAlarmB.append( cb );
302 cb->setChecked( kkf->isAlarmEnabled );
303 cb->setNum( kkf->mCalNumber );
304 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) );
305 cb = new KOCalCheckButton( mw );
306 mainLayout->addWidget( cb,row,4 );mROB.append( cb );
307 cb->setChecked( kkf->isReadOnly );
308 cb->setNum( kkf->mCalNumber );
309 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) );
310 KColorButton *colb = new KColorButton( mw );
311 mainLayout->addWidget( colb,row,5 );
312 colb->setID( kkf->mCalNumber );
313 colb->setColor( kkf->mDefaultColor );
314 connect (colb, SIGNAL (changedID(const QColor&, int )), SLOT ( setColor(const QColor&,int) ) );
315 if ( row > 1) {
316 KOCalButton* calb = new KOCalButton( mw );
317 mainLayout->addWidget( calb,row,6 );
318 calb->setNum( kkf->mCalNumber );
319 calb->setPixmap ( SmallIcon("minus"));
320 connect (calb, SIGNAL (selectNum(int)), SLOT ( deleteCal(int) ) );
321 int hei = calb->sizeHint().height();
322 calb->setMaximumSize( hei*9/10, hei*9/10 );
323 }
324 ++row;
325 kkf = KOPrefs::instance()->mCalendars.next();
326 }
327 lab = new QLabel ( "", mw );
328 mainLayout->addWidget( lab,row,0 );
329 mw->show();
155 330
156} 331}
157void KOCalEditView::addCal() 332void KOCalEditView::addCal()
158{ 333{
159 qDebug("addcal "); 334 qDebug("addcal ");
335 KONewCalPrefs prefs ( this );
336 if ( ! prefs.exec() )
337 return;
338 QString name = prefs.calName();
339 QString file = prefs.calFileName();
340 QFileInfo fi ( file );
341 if (!fi.exists() ) {
342 KMessageBox::information( this, i18n("File does not exist!\nNo calendar added!"));
343 return;
344 }
345 KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar();
346 kkf->mName = name;
347 kkf->mFileName = file;
348 emit calendarAdded( kkf->mCalNumber );
349 readConfig();
160} 350}
161void KOCalEditView::enableAll() 351void KOCalEditView::enableAll()
162{ 352{
163 qDebug("enableAll"); 353 toggleList( mEnabledB );
164} 354}
165void KOCalEditView::enableAlarm() 355void KOCalEditView::enableAlarm()
166{ 356{
167 qDebug("enableAlarm"); 357 toggleList( mAlarmB );
168} 358}
169void KOCalEditView::disableRO() 359void KOCalEditView::disableRO()
170{ 360{
171 qDebug("OCalEditView::disableRO() "); 361 toggleList( mROB );
362}
363void KOCalEditView::toggleList ( QPtrList<KOCalCheckButton> list )
364{
365 bool dis = false;
366 KOCalCheckButton* it = list.first();
367 while ( it ) {
368 if ( !it->isChecked() ) {
369 dis = true;
370 break;
371 }
372 it = list.next();
373 }
374 it = list.first();
375 while ( it ) {
376 it->setChecked(dis);
377 it = list.next();
378 }
172} 379}
173void KOCalEditView::deleteAll() 380void KOCalEditView::deleteAll()
174{ 381{
175 qDebug("delteAll"); 382 qDebug("delteAll");
176} 383}
diff --git a/korganizer/kofilterview.h b/korganizer/kofilterview.h
index 060108f..aaf0eb6 100644
--- a/korganizer/kofilterview.h
+++ b/korganizer/kofilterview.h
@@ -1,133 +1,155 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KOFILTERVIEW_H 23#ifndef KOFILTERVIEW_H
24#define KOFILTERVIEW_H 24#define KOFILTERVIEW_H
25 25
26#include <qstring.h> 26#include <qstring.h>
27#include <qcheckbox.h> 27#include <qcheckbox.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <kconfig.h> 29#include <kconfig.h>
30#include "kofilterview_base.h" 30#include "kofilterview_base.h"
31 31
32#include <libkcal/calfilter.h> 32#include <libkcal/calfilter.h>
33 33
34using namespace KCal; 34class QGridLayout;
35
36class KOFilterView : public KOFilterView_base
37{
38 Q_OBJECT
39 public:
40 KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent=0,const char* name=0, WFlags fl=0);
41 ~KOFilterView();
42
43 void updateFilters();
44
45 bool filtersEnabled();
46 void setFiltersEnabled(bool);
47 CalFilter *selectedFilter();
48 void setSelectedFilter(QString);
49 void setSelectedFilter( int );
50
51 signals:
52 void filterChanged();
53 void editFilters();
54
55 private:
56 QPtrList<CalFilter> *mFilters;
57};
58
59class KOCalEditView : public QWidget
60{
61 Q_OBJECT
62 public:
63 KOCalEditView( QWidget* parent=0,const char* name=0);
64 ~KOCalEditView();
65
66 void readConfig( KConfig *);
67 public slots:
68 void addCal();
69 void enableAll();
70 void enableAlarm();
71 void disableRO();
72 void deleteAll();
73 signals:
74 void alarmEnabled ( int cal, bool enable );
75 void calendarEnabled ( int cal, bool enable );
76 void calendarReadonly ( int cal, bool readonly );
77 void setCalendarDefault ( int cal );
78 void removeCalendar ( int cal );
79
80 private:
81};
82 35
36using namespace KCal;
83class KOCalButton : public QPushButton 37class KOCalButton : public QPushButton
84{ 38{
85 Q_OBJECT 39 Q_OBJECT
86 public: 40 public:
87 KOCalButton( QWidget *parent=0, const char *name=0 ) : 41 KOCalButton( QWidget *parent=0, const char *name=0 ) :
88 QPushButton( parent, name) 42 QPushButton( parent, name)
89 { 43 {
90 connect( this, SIGNAL( clicked() ), 44 connect( this, SIGNAL( clicked() ),
91 SLOT( bottonClicked() )); 45 SLOT( bottonClicked() ));
92 mNumber = -1; 46 mNumber = -1;
93 } 47 }
94 void setNum ( int num ) {mNumber = num; } 48 void setNum ( int num ) {mNumber = num; }
95 signals: 49 signals:
96 void selectNum ( int ); 50 void selectNum ( int );
97private: 51private:
98 int mNumber; 52 int mNumber;
99 void keyPressEvent ( QKeyEvent * e ) 53 void keyPressEvent ( QKeyEvent * e )
100 { 54 {
101 e->ignore(); 55 e->ignore();
102 } 56 }
103 57
104private slots : 58private slots :
105 void bottonClicked() { if ( mNumber > 0 ) emit selectNum ( mNumber ); } 59 void bottonClicked() { if ( mNumber > 0 ) emit selectNum ( mNumber ); }
106}; 60};
107class KOCalCheckButton : public QCheckBox 61class KOCalCheckButton : public QCheckBox
108{ 62{
109 Q_OBJECT 63 Q_OBJECT
110 public: 64 public:
111 KOCalCheckButton( QWidget *parent=0, const char *name=0 ) : 65 KOCalCheckButton( QWidget *parent=0, const char *name=0 ) :
112 QCheckBox( parent, name) 66 QCheckBox( parent, name)
113 { 67 {
114 connect( this, SIGNAL( toggled ( bool ) ), 68 connect( this, SIGNAL( toggled ( bool ) ),
115 SLOT( bottonClicked( bool ) )); 69 SLOT( bottonClicked( bool ) ));
116 mNumber = -1; 70 mNumber = -1;
71 //setMaximumWidth( 10 );
72
117 } 73 }
118 void setNum ( int num ) {mNumber = num; } 74 void setNum ( int num ) {mNumber = num; }
119 signals: 75 signals:
120 void selectNum ( int, bool ); 76 void selectNum ( int, bool );
121private: 77private:
122 int mNumber; 78 int mNumber;
123 void keyPressEvent ( QKeyEvent * e ) 79 void keyPressEvent ( QKeyEvent * e )
124 { 80 {
125 e->ignore(); 81 e->ignore();
126 } 82 }
127 83
128private slots : 84private slots :
129 void bottonClicked( bool b) { if ( mNumber > 0 ) emit selectNum ( mNumber , b); } 85 void bottonClicked( bool b) { if ( mNumber > 0 ) emit selectNum ( mNumber , b); }
130}; 86};
131 87
132 88
89
90class KOFilterView : public KOFilterView_base
91{
92 Q_OBJECT
93 public:
94 KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent=0,const char* name=0, WFlags fl=0);
95 ~KOFilterView();
96
97 void updateFilters();
98
99 bool filtersEnabled();
100 void setFiltersEnabled(bool);
101 CalFilter *selectedFilter();
102 void setSelectedFilter(QString);
103 void setSelectedFilter( int );
104
105 signals:
106 void filterChanged();
107 void editFilters();
108
109 private:
110 QPtrList<CalFilter> *mFilters;
111};
112
113class KOCalEditView : public QWidget
114{
115 Q_OBJECT
116 public:
117 KOCalEditView( QWidget* parent=0,const char* name=0);
118 ~KOCalEditView();
119
120 void readConfig();
121 public slots:
122 void addCal();
123 void enableAll();
124 void enableAlarm();
125 void disableRO();
126 void deleteAll();
127 void selectStdCal(int,bool );
128 void selectCal(int,bool );
129 void selectCalAlarm(int,bool );
130 void selectReadOnly(int,bool );
131 void setColor(const QColor &,int) ;
132 void deleteCal(int) ;
133 void infoCal(int) ;
134 signals:
135 void alarmEnabled ( int cal, bool enable );
136 void calendarEnabled ( int cal, bool enable );
137 void calendarReadonly ( int cal, bool readonly );
138 void setCalendarDefault ( int cal );
139 void removeCalendar ( int cal );
140 void calendarAdded( int );
141
142 private:
143 QVBoxLayout* ml;
144 QWidget *mw;
145 void toggleList ( QPtrList<KOCalCheckButton> );
146 QPtrList<KOCalCheckButton> mStdandardB;
147 QPtrList<KOCalCheckButton> mEnabledB;
148 QPtrList<KOCalCheckButton> mAlarmB;
149 QPtrList<KOCalCheckButton> mROB;
150 QGridLayout* mainLayout;
151};
152
153
154
133#endif // KOFILTERVIEW_H 155#endif // KOFILTERVIEW_H
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp
index 179f586..bc6aae4 100644
--- a/korganizer/koprefs.cpp
+++ b/korganizer/koprefs.cpp
@@ -1,588 +1,591 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <time.h> 24#include <time.h>
25#ifndef _WIN32_ 25#ifndef _WIN32_
26#include <unistd.h> 26#include <unistd.h>
27#endif 27#endif
28#include <qdir.h> 28#include <qdir.h>
29#include <qtextstream.h> 29#include <qtextstream.h>
30#include <qtextcodec.h> 30#include <qtextcodec.h>
31#include <qstring.h> 31#include <qstring.h>
32#include <qregexp.h> 32#include <qregexp.h>
33#include <qfont.h> 33#include <qfont.h>
34#include <qcolor.h> 34#include <qcolor.h>
35#include <qstringlist.h> 35#include <qstringlist.h>
36#include <stdlib.h> 36#include <stdlib.h>
37 37
38#include <kglobal.h> 38#include <kglobal.h>
39#include <kglobalsettings.h> 39#include <kglobalsettings.h>
40#include <kconfig.h> 40#include <kconfig.h>
41#include <klocale.h> 41#include <klocale.h>
42#include <kdebug.h> 42#include <kdebug.h>
43#include <kemailsettings.h> 43#include <kemailsettings.h>
44#include <kstaticdeleter.h> 44#include <kstaticdeleter.h>
45#include <libkdepim/kpimglobalprefs.h> 45#include <libkdepim/kpimglobalprefs.h>
46 46
47#include "koprefs.h" 47#include "koprefs.h"
48#include "mainwindow.h" 48#include "mainwindow.h"
49 49
50KOPrefs *KOPrefs::mInstance = 0; 50KOPrefs *KOPrefs::mInstance = 0;
51static KStaticDeleter<KOPrefs> insd; 51static KStaticDeleter<KOPrefs> insd;
52 52
53KOPrefs::KOPrefs() : 53KOPrefs::KOPrefs() :
54 KPimPrefs("korganizerrc") 54 KPimPrefs("korganizerrc")
55{ 55{
56 mCategoryColors.setAutoDelete(true); 56 mCategoryColors.setAutoDelete(true);
57 fillMailDefaults(); 57 fillMailDefaults();
58 mDefaultCategoryColor = QColor(175,210,255);//196,196,196); 58 mDefaultCategoryColor = QColor(175,210,255);//196,196,196);
59 QColor defaultHolidayColor = QColor(255,0,0); 59 QColor defaultHolidayColor = QColor(255,0,0);
60 QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); 60 QColor defaultHighlightColor = QColor(129,112,255);//64,64,255);
61 QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); 61 QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128);
62 QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); 62 QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160);
63 QColor defaultTodoDueTodayColor = QColor(255,220,100); 63 QColor defaultTodoDueTodayColor = QColor(255,220,100);
64 QColor defaultTodoOverdueColor = QColor(255,153,125); 64 QColor defaultTodoOverdueColor = QColor(255,153,125);
65 QColor defaultTodoRunColor = QColor(99,194,30); 65 QColor defaultTodoRunColor = QColor(99,194,30);
66 KPrefs::setCurrentGroup("General"); 66 KPrefs::setCurrentGroup("General");
67 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); 67 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
68 addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); 68 addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true);
69 addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); 69 addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true);
70 addItemBool("ShowIconSearch",&mShowIconSearch,true); 70 addItemBool("ShowIconSearch",&mShowIconSearch,true);
71 addItemBool("ShowIconList",&mShowIconList,true); 71 addItemBool("ShowIconList",&mShowIconList,true);
72 addItemBool("ShowIconDay1",&mShowIconDay1,true); 72 addItemBool("ShowIconDay1",&mShowIconDay1,true);
73 addItemBool("ShowIconDay5",&mShowIconDay5,true); 73 addItemBool("ShowIconDay5",&mShowIconDay5,true);
74 addItemBool("ShowIconDay6",&mShowIconDay6,true); 74 addItemBool("ShowIconDay6",&mShowIconDay6,true);
75 addItemBool("ShowIconDay7",&mShowIconDay7,true); 75 addItemBool("ShowIconDay7",&mShowIconDay7,true);
76 addItemBool("ShowIconMonth",&mShowIconMonth,true); 76 addItemBool("ShowIconMonth",&mShowIconMonth,true);
77 addItemBool("ShowIconTodoview",&mShowIconTodoview,true); 77 addItemBool("ShowIconTodoview",&mShowIconTodoview,true);
78 addItemBool("ShowIconBackFast",&mShowIconBackFast,true); 78 addItemBool("ShowIconBackFast",&mShowIconBackFast,true);
79 addItemBool("ShowIconBack",&mShowIconBack,true); 79 addItemBool("ShowIconBack",&mShowIconBack,true);
80 addItemBool("ShowIconToday",&mShowIconToday,true); 80 addItemBool("ShowIconToday",&mShowIconToday,true);
81 addItemBool("ShowIconForward",&mShowIconForward,true); 81 addItemBool("ShowIconForward",&mShowIconForward,true);
82 addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); 82 addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true);
83 addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,true); 83 addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,true);
84 addItemBool("ShowIconWeekNum",&mShowIconWeekNum,true); 84 addItemBool("ShowIconWeekNum",&mShowIconWeekNum,true);
85 addItemBool("ShowIconNextDays",&mShowIconNextDays,true); 85 addItemBool("ShowIconNextDays",&mShowIconNextDays,true);
86 addItemBool("ShowIconNext",&mShowIconNext,true); 86 addItemBool("ShowIconNext",&mShowIconNext,true);
87 addItemBool("ShowIconJournal",&mShowIconJournal,true); 87 addItemBool("ShowIconJournal",&mShowIconJournal,true);
88 addItemBool("ShowIconStretch",&mShowIconStretch,true); 88 addItemBool("ShowIconStretch",&mShowIconStretch,true);
89 addItemBool("ShowIconFilter",&mShowIconFilter,false); 89 addItemBool("ShowIconFilter",&mShowIconFilter,false);
90 addItemBool("ShowIconOnetoolbar",&mShowIconOnetoolbar,true); 90 addItemBool("ShowIconOnetoolbar",&mShowIconOnetoolbar,true);
91 91
92 bool addIcons = false; 92 bool addIcons = false;
93#ifdef DESKTOP_VERSION 93#ifdef DESKTOP_VERSION
94 addIcons = true; 94 addIcons = true;
95#endif 95#endif
96 addItemBool("ShowIconNavigator",&mShowIconNavigator,addIcons); 96 addItemBool("ShowIconNavigator",&mShowIconNavigator,addIcons);
97 addItemBool("ShowIconAllday",&mShowIconAllday,addIcons); 97 addItemBool("ShowIconAllday",&mShowIconAllday,addIcons);
98 addItemBool("ShowIconFilterview",&mShowIconFilterview,addIcons); 98 addItemBool("ShowIconFilterview",&mShowIconFilterview,addIcons);
99 addItemBool("ShowIconToggleFull",&mShowIconToggleFull,addIcons); 99 addItemBool("ShowIconToggleFull",&mShowIconToggleFull,addIcons);
100 100
101 addItemInt("LastLoadedLanguage",&mOldLanguage,0); 101 addItemInt("LastLoadedLanguage",&mOldLanguage,0);
102 102
103 addItemBool("AskForQuit",&mAskForQuit,false); 103 addItemBool("AskForQuit",&mAskForQuit,false);
104 104
105#ifndef DESKTOP_VERSION 105#ifndef DESKTOP_VERSION
106 addItemBool("ShowFullMenu",&mShowFullMenu,false); 106 addItemBool("ShowFullMenu",&mShowFullMenu,false);
107#else 107#else
108 addItemBool("ShowFullMenu",&mShowFullMenu,true); 108 addItemBool("ShowFullMenu",&mShowFullMenu,true);
109#endif 109#endif
110 addItemBool("ToolBarHor",&mToolBarHor, true ); 110 addItemBool("ToolBarHor",&mToolBarHor, true );
111 addItemBool("ToolBarUp",&mToolBarUp, false ); 111 addItemBool("ToolBarUp",&mToolBarUp, false );
112 addItemBool("ToolBarHorV",&mToolBarHorV, true ); 112 addItemBool("ToolBarHorV",&mToolBarHorV, true );
113 addItemBool("ToolBarUpV",&mToolBarUpV, false ); 113 addItemBool("ToolBarUpV",&mToolBarUpV, false );
114 addItemBool("ToolBarHorN",&mToolBarHorN, true ); 114 addItemBool("ToolBarHorN",&mToolBarHorN, true );
115 addItemBool("ToolBarUpN",&mToolBarUpN, false ); 115 addItemBool("ToolBarUpN",&mToolBarUpN, false );
116 addItemBool("ToolBarHorF",&mToolBarHorF, true ); 116 addItemBool("ToolBarHorF",&mToolBarHorF, true );
117 addItemBool("ToolBarUpF",&mToolBarUpF, false ); 117 addItemBool("ToolBarUpF",&mToolBarUpF, false );
118 addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); 118 addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false );
119 addItemInt("Whats Next Days",&mWhatsNextDays,3); 119 addItemInt("Whats Next Days",&mWhatsNextDays,3);
120 addItemInt("Whats Next Prios",&mWhatsNextPrios,1); 120 addItemInt("Whats Next Prios",&mWhatsNextPrios,1);
121 121
122 addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); 122 addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true);
123 addItemBool("ShowCompletedTodoInAgenda",&mShowCompletedTodoInAgenda,true); 123 addItemBool("ShowCompletedTodoInAgenda",&mShowCompletedTodoInAgenda,true);
124 addItemBool("ShowTimeInAgenda",&mShowTimeInAgenda,true); 124 addItemBool("ShowTimeInAgenda",&mShowTimeInAgenda,true);
125 addItemBool("HideNonStartedTodos",&mHideNonStartedTodos,false); 125 addItemBool("HideNonStartedTodos",&mHideNonStartedTodos,false);
126 addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); 126 addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true);
127 addItemInt("AllDay Size",&mAllDaySize,28); 127 addItemInt("AllDay Size",&mAllDaySize,28);
128 QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; 128 QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav";
129 addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); 129 addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm );
130 130
131 addItemStringList("LocationDefaults",&mLocationDefaults ); 131 addItemStringList("LocationDefaults",&mLocationDefaults );
132 addItemStringList("EventSummary User",&mEventSummaryUser); 132 addItemStringList("EventSummary User",&mEventSummaryUser);
133 addItemStringList("TodoSummary User",&mTodoSummaryUser); 133 addItemStringList("TodoSummary User",&mTodoSummaryUser);
134 134
135 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); 135 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
136 addItemBool("Enable Project View",&mEnableProjectView,false); 136 addItemBool("Enable Project View",&mEnableProjectView,false);
137 addItemBool("Auto Save",&mAutoSave,false); 137 addItemBool("Auto Save",&mAutoSave,false);
138 addItemInt("Auto Save Interval",&mAutoSaveInterval,3); 138 addItemInt("Auto Save Interval",&mAutoSaveInterval,3);
139 addItemBool("Confirm Deletes",&mConfirm,true); 139 addItemBool("Confirm Deletes",&mConfirm,true);
140 addItemString("Archive File",&mArchiveFile); 140 addItemString("Archive File",&mArchiveFile);
141 addItemString("Html Export File",&mHtmlExportFile, 141 addItemString("Html Export File",&mHtmlExportFile,
142 QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); 142 QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html"));
143 addItemBool("Html With Save",&mHtmlWithSave,false); 143 addItemBool("Html With Save",&mHtmlWithSave,false);
144 144
145 KPrefs::setCurrentGroup("Personal Settings"); 145 KPrefs::setCurrentGroup("Personal Settings");
146 146
147 addItemInt("Mail Client",&mMailClient,MailClientKMail); 147 addItemInt("Mail Client",&mMailClient,MailClientKMail);
148 addItemBool("Use Control Center Email",&mEmailControlCenter,false); 148 addItemBool("Use Control Center Email",&mEmailControlCenter,false);
149 addItemBool("Bcc",&mBcc,false); 149 addItemBool("Bcc",&mBcc,false);
150 150
151 KPrefs::setCurrentGroup("Time & Date"); 151 KPrefs::setCurrentGroup("Time & Date");
152 152
153 153
154 addItemInt("Default Start Time",&mStartTime,10); 154 addItemInt("Default Start Time",&mStartTime,10);
155 addItemInt("Default Duration",&mDefaultDuration,2); 155 addItemInt("Default Duration",&mDefaultDuration,2);
156 addItemInt("Default Alarm Time",&mAlarmTime,3); 156 addItemInt("Default Alarm Time",&mAlarmTime,3);
157 KPrefs::setCurrentGroup("AlarmSettings"); 157 KPrefs::setCurrentGroup("AlarmSettings");
158 addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); 158 addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20);
159 addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); 159 addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7);
160 addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); 160 addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5);
161 addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); 161 addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3);
162 162
163 163
164 KPrefs::setCurrentGroup("Calendar"); 164 KPrefs::setCurrentGroup("Calendar");
165 165
166 addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); 166 addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar);
167 167
168 KPrefs::setCurrentGroup("Fonts"); 168 KPrefs::setCurrentGroup("Fonts");
169 // qDebug(" KPrefs::setCurrentGroup(Fonts); "); 169 // qDebug(" KPrefs::setCurrentGroup(Fonts); ");
170 QFont fon = KGlobalSettings::generalFont(); 170 QFont fon = KGlobalSettings::generalFont();
171 addItemFont("TimeBar Font",&mTimeBarFont,fon ); 171 addItemFont("TimeBar Font",&mTimeBarFont,fon );
172 addItemFont("MonthView Font",&mMonthViewFont,fon); 172 addItemFont("MonthView Font",&mMonthViewFont,fon);
173 addItemFont("AgendaView Font",&mAgendaViewFont,fon); 173 addItemFont("AgendaView Font",&mAgendaViewFont,fon);
174 addItemFont("MarcusBains Font",&mMarcusBainsFont,fon); 174 addItemFont("MarcusBains Font",&mMarcusBainsFont,fon);
175 addItemFont("TimeLabels Font",&mTimeLabelsFont,fon); 175 addItemFont("TimeLabels Font",&mTimeLabelsFont,fon);
176 addItemFont("TodoView Font",&mTodoViewFont,fon); 176 addItemFont("TodoView Font",&mTodoViewFont,fon);
177 addItemFont("ListView Font",&mListViewFont,fon); 177 addItemFont("ListView Font",&mListViewFont,fon);
178 addItemFont("DateNavigator Font",&mDateNavigatorFont,fon); 178 addItemFont("DateNavigator Font",&mDateNavigatorFont,fon);
179 addItemFont("EditBox Font",&mEditBoxFont,fon); 179 addItemFont("EditBox Font",&mEditBoxFont,fon);
180 addItemFont("JournalView Font",&mJornalViewFont,fon); 180 addItemFont("JournalView Font",&mJornalViewFont,fon);
181 addItemFont("WhatsNextView Font",&mWhatsNextFont,fon); 181 addItemFont("WhatsNextView Font",&mWhatsNextFont,fon);
182 addItemFont("EventView Font",&mEventViewFont,fon); 182 addItemFont("EventView Font",&mEventViewFont,fon);
183 183
184 KPrefs::setCurrentGroup("RemoteSyncing"); 184 KPrefs::setCurrentGroup("RemoteSyncing");
185 addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); 185 addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" );
186 addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); 186 addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" );
187 addItemBool("ShowSyncEvents",&mShowSyncEvents,false); 187 addItemBool("ShowSyncEvents",&mShowSyncEvents,false);
188 addItemInt("LastSyncTime",&mLastSyncTime,0); 188 addItemInt("LastSyncTime",&mLastSyncTime,0);
189 189
190#ifdef _WIN32_ 190#ifdef _WIN32_
191 QString hdp= locateLocal("data","korganizer")+"\\\\"; 191 QString hdp= locateLocal("data","korganizer")+"\\\\";
192#else 192#else
193 QString hdp= locateLocal("data","korganizer")+"/"; 193 QString hdp= locateLocal("data","korganizer")+"/";
194#endif 194#endif
195 195
196 KPrefs::setCurrentGroup("LoadSaveFileNames"); 196 KPrefs::setCurrentGroup("LoadSaveFileNames");
197 197
198 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); 198 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" );
199 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); 199 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" );
200 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); 200 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" );
201 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); 201 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" );
202 202
203 203
204 KPrefs::setCurrentGroup("Locale"); 204 KPrefs::setCurrentGroup("Locale");
205 addItemBool("ShortDateInViewer",&mShortDateInViewer,false); 205 addItemBool("ShortDateInViewer",&mShortDateInViewer,false);
206 206
207 207
208 KPrefs::setCurrentGroup("Colors"); 208 KPrefs::setCurrentGroup("Colors");
209 addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); 209 addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor);
210 addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); 210 addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor);
211 addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); 211 addItemColor("Event Color",&mEventColor,mDefaultCategoryColor);
212 addItemColor("Todo done Color",&mTodoDoneColor,QColor(111,255,115) ); 212 addItemColor("Todo done Color",&mTodoDoneColor,QColor(111,255,115) );
213 addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); 213 addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor);
214 addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); 214 addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor);
215 addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); 215 addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor);
216 addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); 216 addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor);
217 addItemColor("Todo running Color",&mTodoRunColor,defaultTodoRunColor); 217 addItemColor("Todo running Color",&mTodoRunColor,defaultTodoRunColor);
218 addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); 218 addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 ));
219 addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); 219 addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 ));
220 addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); 220 addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 ));
221 addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); 221 addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true);
222 addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); 222 addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true);
223 addItemBool("MonthViewWeek",&mMonthViewWeek,false); 223 addItemBool("MonthViewWeek",&mMonthViewWeek,false);
224 addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); 224 addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false);
225 addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); 225 addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 ));
226 addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); 226 addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 ));
227 addItemBool("UseAppColors",&mUseAppColors,false); 227 addItemBool("UseAppColors",&mUseAppColors,false);
228 228
229 229
230 230
231 KPrefs::setCurrentGroup("Views"); 231 KPrefs::setCurrentGroup("Views");
232 addItemBool("Block Popup Menu",&mBlockPopupMenu,true); 232 addItemBool("Block Popup Menu",&mBlockPopupMenu,true);
233 addItemBool("Show Date Navigator",&mShowDateNavigator,true); 233 addItemBool("Show Date Navigator",&mShowDateNavigator,true);
234 addItemInt("Hour Size",&mHourSize,8); 234 addItemInt("Hour Size",&mHourSize,8);
235 addItemBool("Show Daily Recurrences",&mDailyRecur,true); 235 addItemBool("Show Daily Recurrences",&mDailyRecur,true);
236 addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); 236 addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true);
237 addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); 237 addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true);
238 addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); 238 addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true);
239 addItemBool("ShowShortMonthName",&mMonthShowShort,false); 239 addItemBool("ShowShortMonthName",&mMonthShowShort,false);
240 addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); 240 addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true);
241 addItemBool("ShowTimesInMonthCell",&mMonthShowTimes,true); 241 addItemBool("ShowTimesInMonthCell",&mMonthShowTimes,true);
242#ifdef DESKTOP_VERION 242#ifdef DESKTOP_VERION
243 addItemBool("Enable ToolTips",&mEnableToolTips,true); 243 addItemBool("Enable ToolTips",&mEnableToolTips,true);
244#else 244#else
245 addItemBool("Enable ToolTips",&mEnableToolTips,false); 245 addItemBool("Enable ToolTips",&mEnableToolTips,false);
246#endif 246#endif
247 addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); 247 addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false);
248 addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); 248 addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false);
249 addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); 249 addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true);
250 addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); 250 addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true);
251 addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,true); 251 addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,true);
252 addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); 252 addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false);
253 addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); 253 addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false);
254 addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); 254 addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true);
255 addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); 255 addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true);
256 addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);; 256 addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);;
257 addItemBool("WNViewShowsPast",&mWNViewShowsPast,true); 257 addItemBool("WNViewShowsPast",&mWNViewShowsPast,true);
258 addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); 258 addItemBool("WNViewShowLocation",&mWNViewShowLocation,false);
259 addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); 259 addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false);
260 addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); 260 addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true);
261 addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); 261 addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false);
262 addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); 262 addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false);
263 addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,true); 263 addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,true);
264 addItemBool("MonthViewUsesBigFont",&mMonthViewUsesBigFont,true); 264 addItemBool("MonthViewUsesBigFont",&mMonthViewUsesBigFont,true);
265 addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); 265 addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false);
266 addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); 266 addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false);
267#ifdef DESKTOP_VERSION 267#ifdef DESKTOP_VERSION
268 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); 268 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true);
269#else 269#else
270 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); 270 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false);
271#endif 271#endif
272 addItemInt("Day Begins",&mDayBegins,7); 272 addItemInt("Day Begins",&mDayBegins,7);
273 addItemInt("Working Hours Start",&mWorkingHoursStart,8); 273 addItemInt("Working Hours Start",&mWorkingHoursStart,8);
274 addItemInt("Working Hours End",&mWorkingHoursEnd,17); 274 addItemInt("Working Hours End",&mWorkingHoursEnd,17);
275 addItemBool("Exclude Holidays",&mExcludeHolidays,true); 275 addItemBool("Exclude Holidays",&mExcludeHolidays,true);
276 addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); 276 addItemBool("Exclude Saturdays",&mExcludeSaturdays,true);
277 277
278 addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); 278 addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false);
279 addItemBool("Full View Month",&mFullViewMonth,true); 279 addItemBool("Full View Month",&mFullViewMonth,true);
280 addItemBool("Full View Todo",&mFullViewTodo,true); 280 addItemBool("Full View Todo",&mFullViewTodo,true);
281 addItemBool("Quick Todo",&mEnableQuickTodo,false); 281 addItemBool("Quick Todo",&mEnableQuickTodo,false);
282 282
283 addItemInt("Next X Days",&mNextXDays,3); 283 addItemInt("Next X Days",&mNextXDays,3);
284 284
285 KPrefs::setCurrentGroup("Printer"); 285 KPrefs::setCurrentGroup("Printer");
286 286
287 KPrefs::setCurrentGroup("Layout"); 287 KPrefs::setCurrentGroup("Layout");
288 288
289 addItemBool("CompactDialogs",&mCompactDialogs,false); 289 addItemBool("CompactDialogs",&mCompactDialogs,false);
290 addItemBool("VerticalScreen",&mVerticalScreen,true); 290 addItemBool("VerticalScreen",&mVerticalScreen,true);
291 291
292 KPrefs::setCurrentGroup("KOrganizer Plugins"); 292 KPrefs::setCurrentGroup("KOrganizer Plugins");
293 293
294 addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); 294 addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays");
295 295
296 KPrefs::setCurrentGroup("Group Scheduling"); 296 KPrefs::setCurrentGroup("Group Scheduling");
297 297
298 addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); 298 addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail);
299 addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); 299 addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend);
300 addItemStringList("AdditionalMails",&mAdditionalMails,""); 300 addItemStringList("AdditionalMails",&mAdditionalMails,"");
301 addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); 301 addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto);
302 addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); 302 addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto);
303 addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); 303 addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto);
304 addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); 304 addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto);
305 addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); 305 addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto);
306 306
307 KPrefs::setCurrentGroup( "Editors" ); 307 KPrefs::setCurrentGroup( "Editors" );
308 308
309 addItemStringList( "EventTemplates", &mEventTemplates ); 309 addItemStringList( "EventTemplates", &mEventTemplates );
310 addItemStringList( "TodoTemplates", &mTodoTemplates ); 310 addItemStringList( "TodoTemplates", &mTodoTemplates );
311 311
312 addItemInt("DestinationPolicy",&mDestination,standardDestination); 312 addItemInt("DestinationPolicy",&mDestination,standardDestination);
313 313
314 KPrefs::setCurrentGroup( "ViewOptions" ); 314 KPrefs::setCurrentGroup( "ViewOptions" );
315 addItemBool("EVshowDetails",&mEVshowDetails,true); 315 addItemBool("EVshowDetails",&mEVshowDetails,true);
316 addItemBool("EVshowCreated",&mEVshowCreated,true); 316 addItemBool("EVshowCreated",&mEVshowCreated,true);
317 addItemBool("EVshowChanged",&mEVshowChanged,true); 317 addItemBool("EVshowChanged",&mEVshowChanged,true);
318 addItemBool("WTshowDetails",&mWTshowDetails,false); 318 addItemBool("WTshowDetails",&mWTshowDetails,false);
319 addItemBool("WTshowCreated",&mWTshowCreated,false); 319 addItemBool("WTshowCreated",&mWTshowCreated,false);
320 addItemBool("WTshowChanged",&mWTshowChanged,false); 320 addItemBool("WTshowChanged",&mWTshowChanged,false);
321 mCalendars.setAutoDelete( true ); 321 mCalendars.setAutoDelete( true );
322} 322}
323 323
324 324
325KOPrefs::~KOPrefs() 325KOPrefs::~KOPrefs()
326{ 326{
327 if (mInstance == this) 327 if (mInstance == this)
328 mInstance = insd.setObject(0); 328 mInstance = insd.setObject(0);
329 mCalendars.setAutoDelete( true ); 329 mCalendars.setAutoDelete( true );
330 mCalendars.clear(); 330 mCalendars.clear();
331 //qDebug("KOPrefs::~KOPrefs() "); 331 //qDebug("KOPrefs::~KOPrefs() ");
332} 332}
333 333
334 334
335KOPrefs *KOPrefs::instance() 335KOPrefs *KOPrefs::instance()
336{ 336{
337 if (!mInstance) { 337 if (!mInstance) {
338 mInstance = insd.setObject(new KOPrefs()); 338 mInstance = insd.setObject(new KOPrefs());
339 mInstance->readConfig(); 339 mInstance->readConfig();
340 } 340 }
341 341
342 return mInstance; 342 return mInstance;
343} 343}
344 344
345void KOPrefs::usrSetDefaults() 345void KOPrefs::usrSetDefaults()
346{ 346{
347 347
348} 348}
349 349
350void KOPrefs::fillMailDefaults() 350void KOPrefs::fillMailDefaults()
351{ 351{
352 if (mName.isEmpty()) mName = i18n("Anonymous"); 352 if (mName.isEmpty()) mName = i18n("Anonymous");
353 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); 353 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere");
354} 354}
355 355
356void KOPrefs::setTimeZoneIdDefault() 356void KOPrefs::setTimeZoneIdDefault()
357{ 357{
358 ; 358 ;
359} 359}
360 360
361void KOPrefs::setAllDefaults() 361void KOPrefs::setAllDefaults()
362{ 362{
363 setCategoryDefaults(); 363 setCategoryDefaults();
364 mEventSummaryUser = getDefaultList() ; 364 mEventSummaryUser = getDefaultList() ;
365 mTodoSummaryUser = getDefaultList() ; 365 mTodoSummaryUser = getDefaultList() ;
366 mLocationDefaults = getLocationDefaultList(); 366 mLocationDefaults = getLocationDefaultList();
367} 367}
368 368
369void KOPrefs::setCategoryDefaults() 369void KOPrefs::setCategoryDefaults()
370{ 370{
371 mCustomCategories.clear(); 371 mCustomCategories.clear();
372 mCustomCategories = getDefaultList(); 372 mCustomCategories = getDefaultList();
373 373
374 QStringList::Iterator it; 374 QStringList::Iterator it;
375 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { 375 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) {
376 setCategoryColor(*it,mDefaultCategoryColor); 376 setCategoryColor(*it,mDefaultCategoryColor);
377 } 377 }
378} 378}
379QStringList KOPrefs::getLocationDefaultList() 379QStringList KOPrefs::getLocationDefaultList()
380{ 380{
381 QStringList retval ; 381 QStringList retval ;
382 retval << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") 382 retval << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach")
383 << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") 383 << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room")
384 << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") 384 << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten")
385 << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; 385 << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ;
386 // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") 386 // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("")
387 387
388 retval.sort(); 388 retval.sort();
389 return retval; 389 return retval;
390} 390}
391QStringList KOPrefs::getDefaultList() 391QStringList KOPrefs::getDefaultList()
392{ 392{
393 QStringList retval ; 393 QStringList retval ;
394 retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer") 394 retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer")
395 << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner") 395 << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner")
396 << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts") 396 << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts")
397 << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids") 397 << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids")
398 << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel") 398 << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel")
399 << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping") 399 << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping")
400 << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University") 400 << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University")
401 << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ; 401 << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ;
402 retval.sort(); 402 retval.sort();
403 //qDebug("cat %s ", retval.join("-").latin1()); 403 //qDebug("cat %s ", retval.join("-").latin1());
404 return retval; 404 return retval;
405} 405}
406 406
407void KOPrefs::usrReadConfig() 407void KOPrefs::usrReadConfig()
408{ 408{
409 config()->setGroup("General"); 409 config()->setGroup("General");
410 410
411 //qDebug("KOPrefs::usrReadConfig() "); 411 //qDebug("KOPrefs::usrReadConfig() ");
412 mCustomCategories = config()->readListEntry("Custom Categories"); 412 mCustomCategories = config()->readListEntry("Custom Categories");
413 mOldLoadedLanguage = mOldLanguage ; 413 mOldLoadedLanguage = mOldLanguage ;
414 mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; 414 mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage;
415 if (mLocationDefaults.isEmpty()) { 415 if (mLocationDefaults.isEmpty()) {
416 mLocationDefaults = getLocationDefaultList(); 416 mLocationDefaults = getLocationDefaultList();
417 } 417 }
418 418
419 if (mEventSummaryUser.isEmpty()) { 419 if (mEventSummaryUser.isEmpty()) {
420 mEventSummaryUser = getDefaultList() ; 420 mEventSummaryUser = getDefaultList() ;
421 } 421 }
422 if (mTodoSummaryUser.isEmpty()) { 422 if (mTodoSummaryUser.isEmpty()) {
423 mTodoSummaryUser = getDefaultList() ; 423 mTodoSummaryUser = getDefaultList() ;
424 } 424 }
425 425
426 if (mCustomCategories.isEmpty()) setCategoryDefaults(); 426 if (mCustomCategories.isEmpty()) setCategoryDefaults();
427 427
428 config()->setGroup("Personal Settings"); 428 config()->setGroup("Personal Settings");
429 mName = config()->readEntry("user_name",""); 429 mName = config()->readEntry("user_name","");
430 mEmail = config()->readEntry("user_email",""); 430 mEmail = config()->readEntry("user_email","");
431 fillMailDefaults(); 431 fillMailDefaults();
432 432
433 config()->setGroup("Category Colors"); 433 config()->setGroup("Category Colors");
434 QStringList::Iterator it; 434 QStringList::Iterator it;
435 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { 435 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) {
436 setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); 436 setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor));
437 437
438 } 438 }
439 config()->setGroup("CCal"); 439 config()->setGroup("CCal");
440 int numCals = config()->readNumEntry("NumberCalendars",0 ); 440 int numCals = config()->readNumEntry("NumberCalendars",0 );
441 mNextAvailableCalendar = 1; 441 mNextAvailableCalendar = 1;
442 if ( numCals == 0 ) { 442 if ( numCals == 0 ) {
443 KopiCalendarFile *kkf = getNewCalendar(); 443 KopiCalendarFile *kkf = getNewCalendar();
444 kkf->isStandard = true; 444 kkf->isStandard = true;
445 kkf->mName = i18n("Standard Calendar"); 445 kkf->mName = i18n("Standard");
446 kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); 446 kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" );
447 } 447 }
448 while ( mNextAvailableCalendar <= numCals ) { 448 while ( mNextAvailableCalendar <= numCals ) {
449 qDebug("Read cal #%d ", mNextAvailableCalendar ); 449 qDebug("Read cal #%d ", mNextAvailableCalendar );
450 QString prefix = "Cal_" +QString::number( mNextAvailableCalendar ); 450 QString prefix = "Cal_" +QString::number( mNextAvailableCalendar );
451 KopiCalendarFile *kkf = getNewCalendar(); 451 KopiCalendarFile *kkf = getNewCalendar();
452 kkf->isStandard = config()->readBoolEntry( prefix+"_isStandard", false ); 452 kkf->isStandard = config()->readBoolEntry( prefix+"_isStandard", false );
453 kkf->isEnabled = config()->readBoolEntry( prefix+"_isEnabled", true); 453 kkf->isEnabled = config()->readBoolEntry( prefix+"_isEnabled", true);
454 kkf->isAlarmEnabled = config()->readBoolEntry( prefix+"_isAlarmEnabled", true); 454 kkf->isAlarmEnabled = config()->readBoolEntry( prefix+"_isAlarmEnabled", true);
455 kkf->isReadOnly = config()->readBoolEntry( prefix+"_isReadOnly", false); 455 kkf->isReadOnly = config()->readBoolEntry( prefix+"_isReadOnly", false);
456 kkf->mName = config()->readEntry( prefix+"_Name", "Calendar"); 456 kkf->mName = config()->readEntry( prefix+"_Name", "Calendar");
457 kkf->mFileName = config()->readEntry( prefix+"_FileName", kkf->mFileName); 457 kkf->mFileName = config()->readEntry( prefix+"_FileName", kkf->mFileName);
458 kkf->mDefaultColor = config()->readColorEntry( prefix+"_Color",&mEventColor); 458 kkf->mDefaultColor = config()->readColorEntry( prefix+"_Color",&mEventColor);
459 if ( kkf->mCalNumber == 1 ) { 459 if ( kkf->mCalNumber == 1 ) {
460 kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); 460 kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" );
461 //kkf->mName = i18n("Standard Calendar");
462 } 461 }
463 } 462 }
464 463
465 KPimPrefs::usrReadConfig(); 464 KPimPrefs::usrReadConfig();
466} 465}
467 466
467KopiCalendarFile * KOPrefs::getCalendar( int num )
468{
469 return mDefCalColors[num-1];
470}
468 471
469KopiCalendarFile * KOPrefs::getNewCalendar() 472KopiCalendarFile * KOPrefs::getNewCalendar()
470{ 473{
471 KopiCalendarFile * kkf = new KopiCalendarFile(); 474 KopiCalendarFile * kkf = new KopiCalendarFile();
472 kkf->mCalNumber = mNextAvailableCalendar; 475 kkf->mCalNumber = mNextAvailableCalendar;
473 mDefCalColors.resize( mNextAvailableCalendar ); 476 mDefCalColors.resize( mNextAvailableCalendar );
474 mDefCalColors[mNextAvailableCalendar-1] = kkf; 477 mDefCalColors[mNextAvailableCalendar-1] = kkf;
475 ++mNextAvailableCalendar; 478 ++mNextAvailableCalendar;
476 kkf->mDefaultColor = mEventColor; 479 kkf->mDefaultColor = mEventColor;
477 kkf->mName = i18n("New Calendar"); 480 kkf->mName = i18n("New Calendar");
478 mCalendars.append( kkf ); 481 mCalendars.append( kkf );
479 return kkf; 482 return kkf;
480} 483}
481void KOPrefs::deleteCalendar( int num ) 484void KOPrefs::deleteCalendar( int num )
482{ 485{
483 KopiCalendarFile * kkf = mCalendars.first(); 486 KopiCalendarFile * kkf = mCalendars.first();
484 while ( kkf ) { 487 while ( kkf ) {
485 if ( kkf->mCalNumber == num ) { 488 if ( kkf->mCalNumber == num ) {
486 qDebug("KOPrefs::deleteCalendar %d ", num ); 489 qDebug("KOPrefs::deleteCalendar %d ", num );
487 mCalendars.remove( kkf ); 490 mCalendars.remove( kkf );
488 delete kkf; 491 delete kkf;
489 return; 492 return;
490 } 493 }
491 kkf = mCalendars.next(); 494 kkf = mCalendars.next();
492 } 495 }
493} 496}
494QColor KOPrefs::defaultColor( int calNum ) const 497QColor KOPrefs::defaultColor( int calNum ) const
495{ 498{
496 return (mDefCalColors[calNum-1])->mDefaultColor; 499 return (mDefCalColors[calNum-1])->mDefaultColor;
497} 500}
498void KOPrefs::usrWriteConfig() 501void KOPrefs::usrWriteConfig()
499{ 502{
500 config()->setGroup("General"); 503 config()->setGroup("General");
501 config()->writeEntry("Custom Categories",mCustomCategories); 504 config()->writeEntry("Custom Categories",mCustomCategories);
502 505
503 config()->setGroup("Personal Settings"); 506 config()->setGroup("Personal Settings");
504 config()->writeEntry("user_name",mName); 507 config()->writeEntry("user_name",mName);
505 config()->writeEntry("user_email",mEmail); 508 config()->writeEntry("user_email",mEmail);
506 509
507 config()->setGroup("Category Colors"); 510 config()->setGroup("Category Colors");
508 QDictIterator<QColor> it(mCategoryColors); 511 QDictIterator<QColor> it(mCategoryColors);
509 while (it.current()) { 512 while (it.current()) {
510 config()->writeEntry(it.currentKey(),*(it.current())); 513 config()->writeEntry(it.currentKey(),*(it.current()));
511 ++it; 514 ++it;
512 } 515 }
513 config()->setGroup("CCal"); 516 config()->setGroup("CCal");
514 config()->writeEntry("NumberCalendars",mCalendars.count()); 517 config()->writeEntry("NumberCalendars",mCalendars.count());
515 int numCal = 1; 518 int numCal = 1;
516 int writeCal = 0; 519 int writeCal = 0;
517 while ( numCal < mNextAvailableCalendar ) { 520 while ( numCal < mNextAvailableCalendar ) {
518 KopiCalendarFile * kkf = mCalendars.first(); 521 KopiCalendarFile * kkf = mCalendars.first();
519 while ( kkf ) { 522 while ( kkf ) {
520 qDebug("cal num %d %d ", kkf->mCalNumber, numCal); 523 qDebug("cal num %d %d ", kkf->mCalNumber, numCal);
521 if ( kkf->mCalNumber == numCal ) { 524 if ( kkf->mCalNumber == numCal ) {
522 ++writeCal; 525 ++writeCal;
523 qDebug("Write calendar %d %d ", numCal , writeCal); 526 qDebug("Write calendar %d %d ", numCal , writeCal);
524 QString prefix = "Cal_" + QString::number( writeCal ); 527 QString prefix = "Cal_" + QString::number( writeCal );
525 config()->writeEntry( prefix+"_isStandard", kkf->isStandard ); 528 config()->writeEntry( prefix+"_isStandard", kkf->isStandard );
526 config()->writeEntry( prefix+"_isEnabled", kkf->isEnabled ); 529 config()->writeEntry( prefix+"_isEnabled", kkf->isEnabled );
527 config()->writeEntry( prefix+"_isAlarmEnabled", kkf->isAlarmEnabled ); 530 config()->writeEntry( prefix+"_isAlarmEnabled", kkf->isAlarmEnabled );
528 config()->writeEntry( prefix+"_isReadOnly", kkf->isReadOnly ); 531 config()->writeEntry( prefix+"_isReadOnly", kkf->isReadOnly );
529 config()->writeEntry( prefix+"_Name", kkf->mName); 532 config()->writeEntry( prefix+"_Name", kkf->mName);
530 config()->writeEntry( prefix+"_FileName", kkf->mFileName); 533 config()->writeEntry( prefix+"_FileName", kkf->mFileName);
531 config()->writeEntry( prefix+"_Color",kkf->mDefaultColor); 534 config()->writeEntry( prefix+"_Color",kkf->mDefaultColor);
532 } 535 }
533 kkf = mCalendars.next(); 536 kkf = mCalendars.next();
534 } 537 }
535 ++numCal; 538 ++numCal;
536 } 539 }
537 KPimPrefs::usrWriteConfig(); 540 KPimPrefs::usrWriteConfig();
538} 541}
539 542
540void KOPrefs::setCategoryColor(QString cat,const QColor & color) 543void KOPrefs::setCategoryColor(QString cat,const QColor & color)
541{ 544{
542 mCategoryColors.replace(cat,new QColor(color)); 545 mCategoryColors.replace(cat,new QColor(color));
543} 546}
544 547
545QColor *KOPrefs::categoryColor(QString cat) 548QColor *KOPrefs::categoryColor(QString cat)
546{ 549{
547 QColor *color = 0; 550 QColor *color = 0;
548 551
549 if (!cat.isEmpty()) color = mCategoryColors[cat]; 552 if (!cat.isEmpty()) color = mCategoryColors[cat];
550 553
551 if (color) return color; 554 if (color) return color;
552 else return &mDefaultCategoryColor; 555 else return &mDefaultCategoryColor;
553} 556}
554 557
555void KOPrefs::setFullName(const QString &name) 558void KOPrefs::setFullName(const QString &name)
556{ 559{
557 mName = name; 560 mName = name;
558} 561}
559 562
560void KOPrefs::setEmail(const QString &email) 563void KOPrefs::setEmail(const QString &email)
561{ 564{
562 //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); 565 //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() );
563 mEmail = email; 566 mEmail = email;
564} 567}
565 568
566QString KOPrefs::fullName() 569QString KOPrefs::fullName()
567{ 570{
568 if (mEmailControlCenter) { 571 if (mEmailControlCenter) {
569 KEMailSettings settings; 572 KEMailSettings settings;
570 return settings.getSetting(KEMailSettings::RealName); 573 return settings.getSetting(KEMailSettings::RealName);
571 } else { 574 } else {
572 return mName; 575 return mName;
573 } 576 }
574} 577}
575 578
576QString KOPrefs::email() 579QString KOPrefs::email()
577{ 580{
578 if (mEmailControlCenter) { 581 if (mEmailControlCenter) {
579 KEMailSettings settings; 582 KEMailSettings settings;
580 return settings.getSetting(KEMailSettings::EmailAddress); 583 return settings.getSetting(KEMailSettings::EmailAddress);
581 } else { 584 } else {
582 return mEmail; 585 return mEmail;
583 } 586 }
584} 587}
585KConfig* KOPrefs::getConfig() 588KConfig* KOPrefs::getConfig()
586{ 589{
587 return config(); 590 return config();
588} 591}
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index 7d71cbd..f114d88 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -1,351 +1,352 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KOPREFS_H 23#ifndef KOPREFS_H
24#define KOPREFS_H 24#define KOPREFS_H
25 25
26 26
27#include <libkdepim/kpimprefs.h> 27#include <libkdepim/kpimprefs.h>
28#include <qdict.h> 28#include <qdict.h>
29#include <qdir.h> 29#include <qdir.h>
30#include <qobject.h> 30#include <qobject.h>
31 31
32class KConfig; 32class KConfig;
33class QFont; 33class QFont;
34class QColor; 34class QColor;
35class QStringList; 35class QStringList;
36 36
37#define VIEW_WN_VIEW 1 37#define VIEW_WN_VIEW 1
38#define VIEW_NX_VIEW 2 38#define VIEW_NX_VIEW 2
39#define VIEW_J_VIEW 3 39#define VIEW_J_VIEW 3
40#define VIEW_A_VIEW 4 40#define VIEW_A_VIEW 4
41#define VIEW_ML_VIEW 5 41#define VIEW_ML_VIEW 5
42#define VIEW_M_VIEW 6 42#define VIEW_M_VIEW 6
43#define VIEW_L_VIEW 7 43#define VIEW_L_VIEW 7
44#define VIEW_T_VIEW 8 44#define VIEW_T_VIEW 8
45 45
46class KopiCalendarFile : public QObject 46class KopiCalendarFile : public QObject
47{ 47{
48 public: 48 public:
49 KopiCalendarFile( ) : QObject( ) 49 KopiCalendarFile( ) : QObject( )
50 { 50 {
51 isStandard = false; 51 isStandard = false;
52 isEnabled = true; 52 isEnabled = true;
53 isAlarmEnabled = true; 53 isAlarmEnabled = true;
54 isReadOnly = false; 54 isReadOnly = false;
55 mName = "Calendar"; 55 mName = "Calendar";
56 mFileName = QDir::homeDirPath() + "/icalfile.ics"; 56 mFileName = QDir::homeDirPath() + "/icalfile.ics";
57 mCalNumber = 0; 57 mCalNumber = 0;
58 mDefaultColor = Qt::red; 58 mDefaultColor = Qt::red;
59 } 59 }
60 bool isStandard; 60 bool isStandard;
61 bool isEnabled; 61 bool isEnabled;
62 bool isAlarmEnabled; 62 bool isAlarmEnabled;
63 bool isReadOnly; 63 bool isReadOnly;
64 QString mName; 64 QString mName;
65 QString mFileName; 65 QString mFileName;
66 int mCalNumber; 66 int mCalNumber;
67 QColor mDefaultColor; 67 QColor mDefaultColor;
68}; 68};
69class KOPrefs : public KPimPrefs 69class KOPrefs : public KPimPrefs
70{ 70{
71 public: 71 public:
72 enum { FormatVCalendar, FormatICalendar }; 72 enum { FormatVCalendar, FormatICalendar };
73 enum { MailClientKMail, MailClientSendmail }; 73 enum { MailClientKMail, MailClientSendmail };
74 enum { IMIPDummy, IMIPKMail }; 74 enum { IMIPDummy, IMIPKMail };
75 enum { IMIPOutbox, IMIPdirectsend }; 75 enum { IMIPOutbox, IMIPdirectsend };
76 enum { neverAuto, addressbookAuto, selectedAuto }; 76 enum { neverAuto, addressbookAuto, selectedAuto };
77 enum { standardDestination, askDestination }; 77 enum { standardDestination, askDestination };
78 78
79 virtual ~KOPrefs(); 79 virtual ~KOPrefs();
80 80
81 /** Get instance of KOPrefs. It is made sure that there is only one 81 /** Get instance of KOPrefs. It is made sure that there is only one
82 instance. */ 82 instance. */
83 static KOPrefs *instance(); 83 static KOPrefs *instance();
84 84
85 /** Set preferences to default values */ 85 /** Set preferences to default values */
86 void usrSetDefaults(); 86 void usrSetDefaults();
87 87
88 /** Read preferences from config file */ 88 /** Read preferences from config file */
89 void usrReadConfig(); 89 void usrReadConfig();
90 90
91 /** Write preferences to config file */ 91 /** Write preferences to config file */
92 void usrWriteConfig(); 92 void usrWriteConfig();
93 void setCategoryDefaults(); 93 void setCategoryDefaults();
94 void setAllDefaults(); 94 void setAllDefaults();
95 KopiCalendarFile * getNewCalendar(); 95 KopiCalendarFile * getNewCalendar();
96 KopiCalendarFile * getCalendar( int );
96 void deleteCalendar( int ); 97 void deleteCalendar( int );
97 QColor defaultColor( int ) const; 98 QColor defaultColor( int ) const;
98 protected: 99 protected:
99 void setTimeZoneIdDefault(); 100 void setTimeZoneIdDefault();
100 101
101 /** Fill empty mail fields with default values. */ 102 /** Fill empty mail fields with default values. */
102 void fillMailDefaults(); 103 void fillMailDefaults();
103 104
104 private: 105 private:
105 /** Constructor disabled for public. Use instance() to create a KOPrefs 106 /** Constructor disabled for public. Use instance() to create a KOPrefs
106 object. */ 107 object. */
107 KOPrefs(); 108 KOPrefs();
108 109
109 static KOPrefs *mInstance; 110 static KOPrefs *mInstance;
110 QStringList getDefaultList(); 111 QStringList getDefaultList();
111 QStringList getLocationDefaultList(); 112 QStringList getLocationDefaultList();
112 public: 113 public:
113 // preferences data 114 // preferences data
114 KConfig* getConfig(); 115 KConfig* getConfig();
115 void setFullName(const QString &); 116 void setFullName(const QString &);
116 QString fullName(); 117 QString fullName();
117 void setEmail(const QString &); 118 void setEmail(const QString &);
118 QString email(); 119 QString email();
119 120
120 QString mAdditional; 121 QString mAdditional;
121 122
122 bool mEmailControlCenter; 123 bool mEmailControlCenter;
123 124
124 bool mBcc; 125 bool mBcc;
125 bool mAutoSave; 126 bool mAutoSave;
126 int mAutoSaveInterval; 127 int mAutoSaveInterval;
127 bool mConfirm; 128 bool mConfirm;
128 129
129 bool mEnableGroupScheduling; 130 bool mEnableGroupScheduling;
130 bool mEnableProjectView; 131 bool mEnableProjectView;
131 132
132 int mDefaultFormat; 133 int mDefaultFormat;
133 int mMailClient; 134 int mMailClient;
134 135
135 int mStartTime; 136 int mStartTime;
136 int mDefaultDuration; 137 int mDefaultDuration;
137 int mAlarmTime; 138 int mAlarmTime;
138 139
139 int mWorkingHoursStart; 140 int mWorkingHoursStart;
140 int mWorkingHoursEnd; 141 int mWorkingHoursEnd;
141 bool mExcludeHolidays; 142 bool mExcludeHolidays;
142 bool mExcludeSaturdays; 143 bool mExcludeSaturdays;
143 bool mMarcusBainsShowSeconds; 144 bool mMarcusBainsShowSeconds;
144 145
145 QFont mTimeBarFont; 146 QFont mTimeBarFont;
146 QFont mMonthViewFont; 147 QFont mMonthViewFont;
147 QFont mAgendaViewFont; 148 QFont mAgendaViewFont;
148 QFont mMarcusBainsFont; 149 QFont mMarcusBainsFont;
149 QFont mTimeLabelsFont; 150 QFont mTimeLabelsFont;
150 QFont mTodoViewFont; 151 QFont mTodoViewFont;
151 QFont mListViewFont; 152 QFont mListViewFont;
152 QFont mDateNavigatorFont; 153 QFont mDateNavigatorFont;
153 QFont mEditBoxFont; 154 QFont mEditBoxFont;
154 QFont mJornalViewFont; 155 QFont mJornalViewFont;
155 QFont mWhatsNextFont; 156 QFont mWhatsNextFont;
156 QFont mEventViewFont; 157 QFont mEventViewFont;
157 158
158 159
159 160
160 161
161 QColor mHolidayColor; 162 QColor mHolidayColor;
162 QColor mHighlightColor; 163 QColor mHighlightColor;
163 QColor mEventColor; 164 QColor mEventColor;
164 QColor mTodoDoneColor; 165 QColor mTodoDoneColor;
165 QColor mAgendaBgColor; 166 QColor mAgendaBgColor;
166 QColor mWorkingHoursColor; 167 QColor mWorkingHoursColor;
167 QColor mTodoDueTodayColor; 168 QColor mTodoDueTodayColor;
168 QColor mTodoOverdueColor; 169 QColor mTodoOverdueColor;
169 QColor mTodoRunColor; 170 QColor mTodoRunColor;
170 QColor mMonthViewEvenColor; 171 QColor mMonthViewEvenColor;
171 QColor mMonthViewOddColor; 172 QColor mMonthViewOddColor;
172 QColor mMonthViewHolidayColor; 173 QColor mMonthViewHolidayColor;
173 bool mMonthViewUsesDayColors; 174 bool mMonthViewUsesDayColors;
174 bool mMonthViewSatSunTog; 175 bool mMonthViewSatSunTog;
175 bool mMonthViewWeek; 176 bool mMonthViewWeek;
176 QColor mAppColor1; 177 QColor mAppColor1;
177 QColor mAppColor2; 178 QColor mAppColor2;
178 bool mUseAppColors; 179 bool mUseAppColors;
179 180
180 int mDayBegins; 181 int mDayBegins;
181 int mHourSize; 182 int mHourSize;
182 int mAllDaySize; 183 int mAllDaySize;
183 bool mShowFullMenu; 184 bool mShowFullMenu;
184 bool mDailyRecur; 185 bool mDailyRecur;
185 bool mWeeklyRecur; 186 bool mWeeklyRecur;
186 bool mMonthDailyRecur; 187 bool mMonthDailyRecur;
187 bool mMonthWeeklyRecur; 188 bool mMonthWeeklyRecur;
188 bool mMonthShowIcons; 189 bool mMonthShowIcons;
189 bool mMonthShowTimes; 190 bool mMonthShowTimes;
190 bool mMonthShowShort; 191 bool mMonthShowShort;
191 bool mEnableToolTips; 192 bool mEnableToolTips;
192 bool mEnableMonthScroll; 193 bool mEnableMonthScroll;
193 bool mFullViewMonth; 194 bool mFullViewMonth;
194 bool mMonthViewUsesCategoryColor; 195 bool mMonthViewUsesCategoryColor;
195 bool mFullViewTodo; 196 bool mFullViewTodo;
196 bool mShowCompletedTodo; 197 bool mShowCompletedTodo;
197 bool mMarcusBainsEnabled; 198 bool mMarcusBainsEnabled;
198 int mNextXDays; 199 int mNextXDays;
199 int mWhatsNextDays; 200 int mWhatsNextDays;
200 int mWhatsNextPrios; 201 int mWhatsNextPrios;
201 bool mEnableQuickTodo; 202 bool mEnableQuickTodo;
202 203
203 bool mCompactDialogs; 204 bool mCompactDialogs;
204 bool mVerticalScreen; 205 bool mVerticalScreen;
205 206
206 bool mShowIconNewTodo; 207 bool mShowIconNewTodo;
207 bool mShowIconNewEvent; 208 bool mShowIconNewEvent;
208 bool mShowIconSearch; 209 bool mShowIconSearch;
209 bool mShowIconList; 210 bool mShowIconList;
210 bool mShowIconDay1; 211 bool mShowIconDay1;
211 bool mShowIconDay5; 212 bool mShowIconDay5;
212 bool mShowIconDay6; 213 bool mShowIconDay6;
213 bool mShowIconDay7; 214 bool mShowIconDay7;
214 bool mShowIconMonth; 215 bool mShowIconMonth;
215 bool mShowIconTodoview; 216 bool mShowIconTodoview;
216 bool mShowIconBackFast; 217 bool mShowIconBackFast;
217 bool mShowIconBack; 218 bool mShowIconBack;
218 bool mShowIconToday; 219 bool mShowIconToday;
219 bool mShowIconForward; 220 bool mShowIconForward;
220 bool mShowIconForwardFast; 221 bool mShowIconForwardFast;
221 bool mShowIconWhatsThis; 222 bool mShowIconWhatsThis;
222 bool mShowIconWeekNum; 223 bool mShowIconWeekNum;
223 bool mShowIconNextDays; 224 bool mShowIconNextDays;
224 bool mShowIconNext; 225 bool mShowIconNext;
225 bool mShowIconJournal; 226 bool mShowIconJournal;
226 bool mShowIconFilter; 227 bool mShowIconFilter;
227 bool mShowIconOnetoolbar; 228 bool mShowIconOnetoolbar;
228 bool mShowIconNavigator; 229 bool mShowIconNavigator;
229 bool mShowIconAllday; 230 bool mShowIconAllday;
230 bool mShowIconFilterview; 231 bool mShowIconFilterview;
231 bool mShowIconToggleFull; 232 bool mShowIconToggleFull;
232 233
233 bool mShowIconStretch; 234 bool mShowIconStretch;
234 235
235 bool mToolBarHor; 236 bool mToolBarHor;
236 bool mToolBarUp; 237 bool mToolBarUp;
237 bool mToolBarHorV; 238 bool mToolBarHorV;
238 bool mToolBarUpV; 239 bool mToolBarUpV;
239 bool mToolBarHorN; 240 bool mToolBarHorN;
240 bool mToolBarUpN; 241 bool mToolBarUpN;
241 bool mToolBarHorF; 242 bool mToolBarHorF;
242 bool mToolBarUpF; 243 bool mToolBarUpF;
243 bool mToolBarMiniIcons; 244 bool mToolBarMiniIcons;
244 245
245 bool mAskForQuit; 246 bool mAskForQuit;
246 bool mUsePassWd; 247 bool mUsePassWd;
247 bool mShowSyncEvents; 248 bool mShowSyncEvents;
248 bool mShowTodoInAgenda; 249 bool mShowTodoInAgenda;
249 bool mShowCompletedTodoInAgenda; 250 bool mShowCompletedTodoInAgenda;
250 bool mShowTimeInAgenda; 251 bool mShowTimeInAgenda;
251 bool mHideNonStartedTodos; 252 bool mHideNonStartedTodos;
252 253
253 bool mBlockPopupMenu; 254 bool mBlockPopupMenu;
254 255
255 int mLastSyncTime; 256 int mLastSyncTime;
256 void setCategoryColor(QString cat,const QColor & color); 257 void setCategoryColor(QString cat,const QColor & color);
257 QColor *categoryColor(QString cat); 258 QColor *categoryColor(QString cat);
258 259
259 QString mArchiveFile; 260 QString mArchiveFile;
260 QString mHtmlExportFile; 261 QString mHtmlExportFile;
261 bool mHtmlWithSave; 262 bool mHtmlWithSave;
262 263
263 QStringList mSelectedPlugins; 264 QStringList mSelectedPlugins;
264 265
265 QString mLastImportFile; 266 QString mLastImportFile;
266 QString mLastVcalFile; 267 QString mLastVcalFile;
267 QString mLastSaveFile; 268 QString mLastSaveFile;
268 QString mLastLoadFile; 269 QString mLastLoadFile;
269 270
270 271
271 QString mDefaultAlarmFile; 272 QString mDefaultAlarmFile;
272 int mIMIPScheduler; 273 int mIMIPScheduler;
273 int mIMIPSend; 274 int mIMIPSend;
274 QStringList mAdditionalMails; 275 QStringList mAdditionalMails;
275 int mIMIPAutoRefresh; 276 int mIMIPAutoRefresh;
276 int mIMIPAutoInsertReply; 277 int mIMIPAutoInsertReply;
277 int mIMIPAutoInsertRequest; 278 int mIMIPAutoInsertRequest;
278 int mIMIPAutoFreeBusy; 279 int mIMIPAutoFreeBusy;
279 int mIMIPAutoFreeBusyReply; 280 int mIMIPAutoFreeBusyReply;
280 281
281 QStringList mTodoTemplates; 282 QStringList mTodoTemplates;
282 QStringList mEventTemplates; 283 QStringList mEventTemplates;
283 284
284 int mDestination; 285 int mDestination;
285 286
286 287
287 bool mEditOnDoubleClick; 288 bool mEditOnDoubleClick;
288 bool mViewChangeHoldFullscreen; 289 bool mViewChangeHoldFullscreen;
289 bool mViewChangeHoldNonFullscreen; 290 bool mViewChangeHoldNonFullscreen;
290 bool mCenterOnCurrentTime; 291 bool mCenterOnCurrentTime;
291 bool mSetTimeToDayStartAt; 292 bool mSetTimeToDayStartAt;
292 bool mHighlightCurrentDay; 293 bool mHighlightCurrentDay;
293 bool mUseHighlightLightColor; 294 bool mUseHighlightLightColor;
294 bool mListViewMonthTimespan; 295 bool mListViewMonthTimespan;
295 bool mWNViewShowsParents; 296 bool mWNViewShowsParents;
296 bool mWNViewShowsPast; 297 bool mWNViewShowsPast;
297 bool mWNViewShowLocation; 298 bool mWNViewShowLocation;
298 bool mTodoViewShowsPercentage; 299 bool mTodoViewShowsPercentage;
299 bool mTodoViewUsesCatColors; 300 bool mTodoViewUsesCatColors;
300 bool mMonthViewUsesBigFont; 301 bool mMonthViewUsesBigFont;
301 bool mTodoViewUsesSmallFont; 302 bool mTodoViewUsesSmallFont;
302 bool mTodoViewUsesForegroundColor; 303 bool mTodoViewUsesForegroundColor;
303 bool mMonthViewUsesForegroundColor; 304 bool mMonthViewUsesForegroundColor;
304 305
305 bool mHightlightDateTimeEdit; 306 bool mHightlightDateTimeEdit;
306 bool mShortDateInViewer; 307 bool mShortDateInViewer;
307 308
308 bool mShowDateNavigator; 309 bool mShowDateNavigator;
309 310
310 QStringList mLocationDefaults; 311 QStringList mLocationDefaults;
311 QStringList mEventSummaryUser; 312 QStringList mEventSummaryUser;
312 QStringList mTodoSummaryUser; 313 QStringList mTodoSummaryUser;
313 314
314 bool mUseInternalAlarmNotification; 315 bool mUseInternalAlarmNotification;
315 int mAlarmPlayBeeps; 316 int mAlarmPlayBeeps;
316 int mAlarmSuspendTime; 317 int mAlarmSuspendTime;
317 int mAlarmSuspendCount; 318 int mAlarmSuspendCount;
318 int mAlarmBeepInterval; 319 int mAlarmBeepInterval;
319 int mOldLanguage; 320 int mOldLanguage;
320 int mOldLoadedLanguage; 321 int mOldLoadedLanguage;
321 322
322 323
323 QString mActiveSyncPort; 324 QString mActiveSyncPort;
324 QString mActiveSyncIP; 325 QString mActiveSyncIP;
325 326
326 // settings for eventviewer 327 // settings for eventviewer
327 bool mEVshowDetails; 328 bool mEVshowDetails;
328 bool mEVshowCreated; 329 bool mEVshowCreated;
329 bool mEVshowChanged; 330 bool mEVshowChanged;
330 bool mWTshowDetails; 331 bool mWTshowDetails;
331 bool mWTshowCreated; 332 bool mWTshowCreated;
332 bool mWTshowChanged; 333 bool mWTshowChanged;
333 334
334 int mCurrentDisplayedView; 335 int mCurrentDisplayedView;
335 QPtrList<KopiCalendarFile> mCalendars; 336 QPtrList<KopiCalendarFile> mCalendars;
336 int mNextAvailableCalendar; 337 int mNextAvailableCalendar;
337 338
338 private: 339 private:
339 QDict<QColor> mCategoryColors; 340 QDict<QColor> mCategoryColors;
340 QArray<KopiCalendarFile*> mDefCalColors; 341 QArray<KopiCalendarFile*> mDefCalColors;
341 QColor mDefaultCategoryColor; 342 QColor mDefaultCategoryColor;
342 343
343 QFont mDefaultTimeBarFont; 344 QFont mDefaultTimeBarFont;
344 QFont mDefaultViewFont; 345 QFont mDefaultViewFont;
345 QFont mDefaultMonthViewFont; 346 QFont mDefaultMonthViewFont;
346 347
347 QString mName; 348 QString mName;
348 QString mEmail; 349 QString mEmail;
349}; 350};
350 351
351#endif 352#endif
diff --git a/libkdepim/kcmconfigs/kdepimconfigwidget.cpp b/libkdepim/kcmconfigs/kdepimconfigwidget.cpp
index a0f9d2e..ff1e240 100644
--- a/libkdepim/kcmconfigs/kdepimconfigwidget.cpp
+++ b/libkdepim/kcmconfigs/kdepimconfigwidget.cpp
@@ -1,986 +1,987 @@
1/* 1/*
2 This file is part of KdePim/Pi. 2 This file is part of KdePim/Pi.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include <qlayout.h> 31#include <qlayout.h>
32#include <qtabwidget.h> 32#include <qtabwidget.h>
33#include <qcombobox.h> 33#include <qcombobox.h>
34#include <qgroupbox.h> 34#include <qgroupbox.h>
35#include <qlabel.h> 35#include <qlabel.h>
36#include <qlineedit.h> 36#include <qlineedit.h>
37#include <qbuttongroup.h> 37#include <qbuttongroup.h>
38#include <qcheckbox.h> 38#include <qcheckbox.h>
39#include <qfile.h> 39#include <qfile.h>
40#include <qvbox.h> 40#include <qvbox.h>
41#include <qdir.h> 41#include <qdir.h>
42#include <qregexp.h> 42#include <qregexp.h>
43#include <qspinbox.h> 43#include <qspinbox.h>
44 44
45#include <kdialog.h> 45#include <kdialog.h>
46#include <kprefsdialog.h> 46#include <kprefsdialog.h>
47#include <klocale.h> 47#include <klocale.h>
48#include <kglobalsettings.h> 48#include <kglobalsettings.h>
49#include <kdateedit.h> 49#include <kdateedit.h>
50#include <kglobal.h> 50#include <kglobal.h>
51#include <stdlib.h> 51#include <stdlib.h>
52 52
53/*US 53/*US
54#include <qcheckbox.h> 54#include <qcheckbox.h>
55#include <qframe.h> 55#include <qframe.h>
56#include <qpushbutton.h> 56#include <qpushbutton.h>
57#include <qcombobox.h> 57#include <qcombobox.h>
58#include <qlineedit.h> 58#include <qlineedit.h>
59#include <qlabel.h> 59#include <qlabel.h>
60#include <qfile.h> 60#include <qfile.h>
61 61
62#include <kconfig.h> 62#include <kconfig.h>
63#include <kdebug.h> 63#include <kdebug.h>
64#include <kdialog.h> 64#include <kdialog.h>
65#include <klistview.h> 65#include <klistview.h>
66#include <klocale.h> 66#include <klocale.h>
67#include <kglobal.h> 67#include <kglobal.h>
68#include <kmessagebox.h> 68#include <kmessagebox.h>
69#include <kstandarddirs.h> 69#include <kstandarddirs.h>
70 70
71#ifndef KAB_EMBEDDED 71#ifndef KAB_EMBEDDED
72#include <ktrader.h> 72#include <ktrader.h>
73#else // KAB_EMBEDDED 73#else // KAB_EMBEDDED
74#include <mergewidget.h> 74#include <mergewidget.h>
75#include <distributionlistwidget.h> 75#include <distributionlistwidget.h>
76#endif // KAB_EMBEDDED 76#endif // KAB_EMBEDDED
77 77
78#include "addresseewidget.h" 78#include "addresseewidget.h"
79#include "extensionconfigdialog.h" 79#include "extensionconfigdialog.h"
80#include "extensionwidget.h" 80#include "extensionwidget.h"
81*/ 81*/
82 82
83#include "qapplication.h" 83#include "qapplication.h"
84 84
85#include "kpimglobalprefs.h" 85#include "kpimglobalprefs.h"
86 86
87#include "kdepimconfigwidget.h" 87#include "kdepimconfigwidget.h"
88#include <kprefs.h> 88#include <kprefs.h>
89#include <kmessagebox.h> 89#include <kmessagebox.h>
90 90
91 91
92
92KDEPIMConfigWidget::KDEPIMConfigWidget(KPimGlobalPrefs *prefs, QWidget *parent, const char *name ) 93KDEPIMConfigWidget::KDEPIMConfigWidget(KPimGlobalPrefs *prefs, QWidget *parent, const char *name )
93 : KPrefsWidget(prefs, parent, name ) 94 : KPrefsWidget(prefs, parent, name )
94{ 95{
95 mExternalAppsMap.insert(ExternalAppHandler::EMAIL, i18n("Email")); 96 mExternalAppsMap.insert(ExternalAppHandler::EMAIL, i18n("Email"));
96 mExternalAppsMap.insert(ExternalAppHandler::PHONE, i18n("Phone")); 97 mExternalAppsMap.insert(ExternalAppHandler::PHONE, i18n("Phone"));
97 mExternalAppsMap.insert(ExternalAppHandler::SMS, i18n("SMS")); 98 mExternalAppsMap.insert(ExternalAppHandler::SMS, i18n("SMS"));
98 mExternalAppsMap.insert(ExternalAppHandler::FAX, i18n("Fax")); 99 mExternalAppsMap.insert(ExternalAppHandler::FAX, i18n("Fax"));
99 mExternalAppsMap.insert(ExternalAppHandler::PAGER, i18n("Pager")); 100 mExternalAppsMap.insert(ExternalAppHandler::PAGER, i18n("Pager"));
100 mExternalAppsMap.insert(ExternalAppHandler::SIP, i18n("SIP")); 101 mExternalAppsMap.insert(ExternalAppHandler::SIP, i18n("SIP"));
101 102
102 103
103 QVBoxLayout *topLayout = new QVBoxLayout( this, 0, 104 QVBoxLayout *topLayout = new QVBoxLayout( this, 0,
104 KDialog::spacingHint() ); 105 KDialog::spacingHint() );
105 106
106 tabWidget = new QTabWidget( this ); 107 tabWidget = new QTabWidget( this );
107 topLayout->addWidget( tabWidget ); 108 topLayout->addWidget( tabWidget );
108 109
109 110
110 setupLocaleTab(); 111 setupLocaleTab();
111 setupLocaleDateTab(); 112 setupLocaleDateTab();
112 setupTimeZoneTab(); 113 setupTimeZoneTab();
113 setupExternalAppTab(); 114 setupExternalAppTab();
114 setupStoreTab(); 115 setupStoreTab();
115 setupBackupTab(); 116 setupBackupTab();
116} 117}
117void KDEPIMConfigWidget::showTimeZoneTab() 118void KDEPIMConfigWidget::showTimeZoneTab()
118{ 119{
119 tabWidget->setCurrentPage ( 3 ) ; 120 tabWidget->setCurrentPage ( 3 ) ;
120} 121}
121void KDEPIMConfigWidget::setupBackupTab() 122void KDEPIMConfigWidget::setupBackupTab()
122{ 123{
123 QVBox *colorPage = new QVBox( this ); 124 QVBox *colorPage = new QVBox( this );
124 tabWidget->addTab( colorPage, i18n( "Backup" ) ); 125 tabWidget->addTab( colorPage, i18n( "Backup" ) );
125 QWidget* topFrame = new QWidget( colorPage ); 126 QWidget* topFrame = new QWidget( colorPage );
126 QVBoxLayout *topLayout = new QVBoxLayout(topFrame); 127 QVBoxLayout *topLayout = new QVBoxLayout(topFrame);
127 KPrefsWidBool *sb = addWidBool(i18n("Backup enabled"), 128 KPrefsWidBool *sb = addWidBool(i18n("Backup enabled"),
128 &(KPimGlobalPrefs::instance()->mBackupEnabled),topFrame); 129 &(KPimGlobalPrefs::instance()->mBackupEnabled),topFrame);
129 topLayout->addWidget((QWidget*)sb->checkBox()); 130 topLayout->addWidget((QWidget*)sb->checkBox());
130 QWidget* bupFrame = new QWidget( topFrame ); 131 QWidget* bupFrame = new QWidget( topFrame );
131 topLayout->addWidget((bupFrame)); 132 topLayout->addWidget((bupFrame));
132 QObject::connect ( sb->checkBox(), SIGNAL (toggled ( bool ) ), bupFrame, SLOT ( setEnabled( bool ) ) ); 133 QObject::connect ( sb->checkBox(), SIGNAL (toggled ( bool ) ), bupFrame, SLOT ( setEnabled( bool ) ) );
133 QVBoxLayout *bupLayout = new QVBoxLayout(bupFrame); 134 QVBoxLayout *bupLayout = new QVBoxLayout(bupFrame);
134 sb = addWidBool(i18n("Use standard backup dir"), 135 sb = addWidBool(i18n("Use standard backup dir"),
135 &(KPimGlobalPrefs::instance()->mBackupUseDefaultDir),bupFrame); 136 &(KPimGlobalPrefs::instance()->mBackupUseDefaultDir),bupFrame);
136 bupLayout->addWidget((QWidget*)sb->checkBox()); 137 bupLayout->addWidget((QWidget*)sb->checkBox());
137 mBackupUrl = new KURLRequester( bupFrame ); 138 mBackupUrl = new KURLRequester( bupFrame );
138 mBackupUrl->setPathIsDir(); 139 mBackupUrl->setPathIsDir();
139 mBackupUrl->setURL( KGlobalSettings::backupDataDir() ); 140 mBackupUrl->setURL( KGlobalSettings::backupDataDir() );
140 QObject::connect ( sb->checkBox(), SIGNAL (toggled ( bool ) ), mBackupUrl ,SLOT ( setDisabled( bool ) ) ); 141 QObject::connect ( sb->checkBox(), SIGNAL (toggled ( bool ) ), mBackupUrl ,SLOT ( setDisabled( bool ) ) );
141 bupLayout->addWidget( mBackupUrl ); 142 bupLayout->addWidget( mBackupUrl );
142 143
143 mBackupUrl->setEnabled( !KPimGlobalPrefs::instance()->mBackupUseDefaultDir ); 144 mBackupUrl->setEnabled( !KPimGlobalPrefs::instance()->mBackupUseDefaultDir );
144 bupFrame->setEnabled( KPimGlobalPrefs::instance()->mBackupEnabled ); 145 bupFrame->setEnabled( KPimGlobalPrefs::instance()->mBackupEnabled );
145 QHBox *dummy = new QHBox(bupFrame); 146 QHBox *dummy = new QHBox(bupFrame);
146 new QLabel(i18n("Number of Backups:"),dummy); 147 new QLabel(i18n("Number of Backups:"),dummy);
147 mBackupNumbersSpin = new QSpinBox(1,21,1,dummy); 148 mBackupNumbersSpin = new QSpinBox(1,21,1,dummy);
148 new QLabel(i18n(" "),dummy); 149 new QLabel(i18n(" "),dummy);
149 bupLayout->addWidget( dummy ); 150 bupLayout->addWidget( dummy );
150 151
151 dummy = new QHBox(bupFrame); 152 dummy = new QHBox(bupFrame);
152 new QLabel(i18n("Make backup every "),dummy); 153 new QLabel(i18n("Make backup every "),dummy);
153 mBackupDayCountSpin = new QSpinBox(1,28,1,dummy); 154 mBackupDayCountSpin = new QSpinBox(1,28,1,dummy);
154 new QLabel(i18n(" days"),dummy); 155 new QLabel(i18n(" days"),dummy);
155 new QLabel(i18n(" "),dummy); 156 new QLabel(i18n(" "),dummy);
156 bupLayout->addWidget( dummy ); 157 bupLayout->addWidget( dummy );
157 QString localKdeDir; 158 QString localKdeDir;
158 localKdeDir = readEnvPath("LOCALMICROKDEHOME"); 159 localKdeDir = readEnvPath("LOCALMICROKDEHOME");
159 if ( ! localKdeDir.isEmpty() ) { 160 if ( ! localKdeDir.isEmpty() ) {
160 sb->checkBox()->setEnabled( false ); 161 sb->checkBox()->setEnabled( false );
161 sb->checkBox()->setChecked( true ); 162 sb->checkBox()->setChecked( true );
162 mBackupUrl->setEnabled( false ); 163 mBackupUrl->setEnabled( false );
163 KPimGlobalPrefs::instance()->mBackupUseDefaultDir = true; 164 KPimGlobalPrefs::instance()->mBackupUseDefaultDir = true;
164 } 165 }
165 166
166} 167}
167void KDEPIMConfigWidget::setupStoreTab() 168void KDEPIMConfigWidget::setupStoreTab()
168{ 169{
169 QVBox *colorPage = new QVBox( this ); 170 QVBox *colorPage = new QVBox( this );
170 tabWidget->addTab( colorPage, i18n( "Colors" ) ); 171 tabWidget->addTab( colorPage, i18n( "Colors" ) );
171 QWidget* cw = new QWidget( colorPage ); 172 QWidget* cw = new QWidget( colorPage );
172 KPrefsWidColor *holidayColor = 173 KPrefsWidColor *holidayColor =
173 addWidColor(i18n("Alternating background of list views"), 174 addWidColor(i18n("Alternating background of list views"),
174 &(KPimGlobalPrefs::instance()->mAlternateColor),cw); 175 &(KPimGlobalPrefs::instance()->mAlternateColor),cw);
175 QHBoxLayout *topLayout = new QHBoxLayout(cw); 176 QHBoxLayout *topLayout = new QHBoxLayout(cw);
176 topLayout->addWidget(holidayColor->label()); 177 topLayout->addWidget(holidayColor->label());
177 topLayout->addWidget( (QWidget* )holidayColor->button()); 178 topLayout->addWidget( (QWidget* )holidayColor->button());
178 179
179 180
180 QVBox *storePage = new QVBox( this ); 181 QVBox *storePage = new QVBox( this );
181 if ( QApplication::desktop()->height() > 240 ) 182 if ( QApplication::desktop()->height() > 240 )
182 new QLabel( i18n("Your current storage dir is:\n%1\nYour mail is stored in:\n(storagedir)/apps/kopiemail/localmail").arg(KGlobal::dirs()->localkdedir()), storePage ); 183 new QLabel( i18n("Your current storage dir is:\n%1\nYour mail is stored in:\n(storagedir)/apps/kopiemail/localmail").arg(KGlobal::dirs()->localkdedir()), storePage );
183 new QLabel( i18n("<b>New data storage dir:</b>"), storePage ); 184 new QLabel( i18n("<b>New data storage dir:</b>"), storePage );
184 mStoreUrl = new KURLRequester( storePage ); 185 mStoreUrl = new KURLRequester( storePage );
185 mStoreUrl->setPathIsDir(); 186 mStoreUrl->setPathIsDir();
186 mStoreUrl->setURL( KGlobal::dirs()->localkdedir() ); 187 mStoreUrl->setURL( KGlobal::dirs()->localkdedir() );
187#ifdef DESKTOP_VERSION 188#ifdef DESKTOP_VERSION
188 QString confFile = qApp->applicationDirPath ()+ "/.microkdehome" ; 189 QString confFile = qApp->applicationDirPath ()+ "/.microkdehome" ;
189 QFileInfo fi ( confFile ); 190 QFileInfo fi ( confFile );
190 if ( fi.exists() ) { 191 if ( fi.exists() ) {
191 KConfig cfg ( confFile ); 192 KConfig cfg ( confFile );
192 cfg.setGroup("Global"); 193 cfg.setGroup("Global");
193 QString localKdeDir = cfg.readEntry( "MICROKDEHOME", "x_x_x" ); 194 QString localKdeDir = cfg.readEntry( "MICROKDEHOME", "x_x_x" );
194 if ( localKdeDir != "x_x_x" ) { 195 if ( localKdeDir != "x_x_x" ) {
195 mStoreUrl->setURL( localKdeDir ); 196 mStoreUrl->setURL( localKdeDir );
196 qDebug("Reading config from %s ", confFile.latin1()); 197 qDebug("Reading config from %s ", confFile.latin1());
197 } 198 }
198 } 199 }
199 200
200#endif 201#endif
201 new QLabel( i18n("New dirs are created automatically"), storePage ); 202 new QLabel( i18n("New dirs are created automatically"), storePage );
202 QHBox *bb = new QHBox( storePage ); 203 QHBox *bb = new QHBox( storePage );
203 QPushButton * pb; 204 QPushButton * pb;
204 if ( QApplication::desktop()->width() < 640 ) 205 if ( QApplication::desktop()->width() < 640 )
205 pb = new QPushButton ( i18n("Save"), bb ); 206 pb = new QPushButton ( i18n("Save"), bb );
206 else 207 else
207 pb = new QPushButton ( i18n("Save settings"), bb ); 208 pb = new QPushButton ( i18n("Save settings"), bb );
208 connect(pb, SIGNAL( clicked() ), this, SLOT ( saveStoreSettings() ) ); 209 connect(pb, SIGNAL( clicked() ), this, SLOT ( saveStoreSettings() ) );
209 pb = new QPushButton ( i18n("Save standard"), bb ); 210 pb = new QPushButton ( i18n("Save standard"), bb );
210 connect(pb, SIGNAL( clicked() ), this, SLOT ( setStandardStore() ) ); 211 connect(pb, SIGNAL( clicked() ), this, SLOT ( setStandardStore() ) );
211#ifdef DESKTOP_VERSION 212#ifdef DESKTOP_VERSION
212 pb = new QPushButton ( i18n("Save using LOCAL storage"), bb ); 213 pb = new QPushButton ( i18n("Save using LOCAL storage"), bb );
213 connect(pb, SIGNAL( clicked() ), this, SLOT ( setLocalStore() ) ); 214 connect(pb, SIGNAL( clicked() ), this, SLOT ( setLocalStore() ) );
214#endif 215#endif
215 new QLabel( i18n("<b>New settings are used\nafter a restart</b>"), storePage ); 216 new QLabel( i18n("<b>New settings are used\nafter a restart</b>"), storePage );
216 new QLabel( i18n("Settings are stored in\n%1").arg(QDir::homeDirPath() + "/.microkdehome" ), storePage ); 217 new QLabel( i18n("Settings are stored in\n%1").arg(QDir::homeDirPath() + "/.microkdehome" ), storePage );
217 tabWidget->addTab( storePage, i18n( "Data storage path" ) ); 218 tabWidget->addTab( storePage, i18n( "Data storage path" ) );
218} 219}
219void KDEPIMConfigWidget::setLocalStore() 220void KDEPIMConfigWidget::setLocalStore()
220{ 221{
221 mStoreUrl->setURL( "LOCAL:kdepimpi" ); 222 mStoreUrl->setURL( "LOCAL:kdepimpi" );
222 saveStoreSettings(); 223 saveStoreSettings();
223 QString message = i18n("'LOCAL' mode makes is possible to run\nKA/Pi and KO/Pi from a USB memory stick.\nIn LOCAL mode the data is stored\nin a path relative to the executable.\nNote, that in LOCAL mode only addressbook\nresource files in\n <path of the executable>/<dirname after LOCAL:>/apps/kabc/*.vcf\n are supported.\nIf you use the standard addressbook settings\nyou do not have to reconfigure any path,\njust restart the application and import\nyour addressbook and calendar data."); 224 QString message = i18n("'LOCAL' mode makes is possible to run\nKA/Pi and KO/Pi from a USB memory stick.\nIn LOCAL mode the data is stored\nin a path relative to the executable.\nNote, that in LOCAL mode only addressbook\nresource files in\n <path of the executable>/<dirname after LOCAL:>/apps/kabc/*.vcf\n are supported.\nIf you use the standard addressbook settings\nyou do not have to reconfigure any path,\njust restart the application and import\nyour addressbook and calendar data.");
224 KMessageBox::information( this, message); 225 KMessageBox::information( this, message);
225} 226}
226void KDEPIMConfigWidget::setStandardStore() 227void KDEPIMConfigWidget::setStandardStore()
227{ 228{
228 mStoreUrl->setURL( QDir::homeDirPath() + "/kdepim" ); 229 mStoreUrl->setURL( QDir::homeDirPath() + "/kdepim" );
229 saveStoreSettings(); 230 saveStoreSettings();
230} 231}
231void KDEPIMConfigWidget::saveStoreSettings() 232void KDEPIMConfigWidget::saveStoreSettings()
232{ 233{
233 if ( !mStoreUrl->url().isEmpty() ) { 234 if ( !mStoreUrl->url().isEmpty() ) {
234 QString path = QDir::homeDirPath(); 235 QString path = QDir::homeDirPath();
235 QString url = mStoreUrl->url(); 236 QString url = mStoreUrl->url();
236#ifdef DESKTOP_VERSION 237#ifdef DESKTOP_VERSION
237 if ( url.startsWith( "LOCAL:" ) ) { 238 if ( url.startsWith( "LOCAL:" ) ) {
238 path = qApp->applicationDirPath () ; 239 path = qApp->applicationDirPath () ;
239 } 240 }
240#endif 241#endif
241 KConfig cfg ( path + "/.microkdehome" ); 242 KConfig cfg ( path + "/.microkdehome" );
242 cfg.setGroup("Global"); 243 cfg.setGroup("Global");
243 cfg.writeEntry( "MICROKDEHOME", url ); 244 cfg.writeEntry( "MICROKDEHOME", url );
244 qDebug("cfg.writeEntry( MICROKDEHOME, %s ", url.latin1()); 245 qDebug("cfg.writeEntry( MICROKDEHOME, %s ", url.latin1());
245 cfg.sync(); 246 cfg.sync();
246 } else { 247 } else {
247 mStoreUrl->setURL( QDir::homeDirPath() + "/kdepim" ); 248 mStoreUrl->setURL( QDir::homeDirPath() + "/kdepim" );
248 saveStoreSettings(); 249 saveStoreSettings();
249 } 250 }
250} 251}
251void KDEPIMConfigWidget::setupExternalAppTab() 252void KDEPIMConfigWidget::setupExternalAppTab()
252{ 253{
253 QWidget *externalAppsPage = new QWidget( this ); 254 QWidget *externalAppsPage = new QWidget( this );
254 QVBoxLayout* layout = new QVBoxLayout( externalAppsPage, KDialog::marginHintSmall(), 255 QVBoxLayout* layout = new QVBoxLayout( externalAppsPage, KDialog::marginHintSmall(),
255 KDialog::spacingHintSmall() ); 256 KDialog::spacingHintSmall() );
256 257
257 mExternalApps = new QComboBox( externalAppsPage ); 258 mExternalApps = new QComboBox( externalAppsPage );
258 259
259 QMap<ExternalAppHandler::Types, QString>::Iterator it; 260 QMap<ExternalAppHandler::Types, QString>::Iterator it;
260 for( it = mExternalAppsMap.begin(); it != mExternalAppsMap.end(); ++it ) 261 for( it = mExternalAppsMap.begin(); it != mExternalAppsMap.end(); ++it )
261 mExternalApps->insertItem( it.data(), it.key() ); 262 mExternalApps->insertItem( it.data(), it.key() );
262 263
263 layout->addWidget( mExternalApps ); 264 layout->addWidget( mExternalApps );
264 265
265 connect( mExternalApps, SIGNAL( activated( int ) ), 266 connect( mExternalApps, SIGNAL( activated( int ) ),
266 this, SLOT (externalapp_changed( int ) ) ); 267 this, SLOT (externalapp_changed( int ) ) );
267 268
268 269
269 mExternalAppGroupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Used Mail Client" ), externalAppsPage ); 270 mExternalAppGroupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Used Mail Client" ), externalAppsPage );
270 QGridLayout *boxLayout = new QGridLayout( mExternalAppGroupBox->layout(), 4, 2, -1, "gridlayout" ); 271 QGridLayout *boxLayout = new QGridLayout( mExternalAppGroupBox->layout(), 4, 2, -1, "gridlayout" );
271 mExternalAppGroupBox->layout()->setMargin(4); 272 mExternalAppGroupBox->layout()->setMargin(4);
272 273
273 mClient = new QComboBox( mExternalAppGroupBox ); 274 mClient = new QComboBox( mExternalAppGroupBox );
274 boxLayout->addMultiCellWidget( mClient, 0, 0, 0, 1 ); 275 boxLayout->addMultiCellWidget( mClient, 0, 0, 0, 1 );
275 276
276 connect( mClient, SIGNAL( activated( int ) ), 277 connect( mClient, SIGNAL( activated( int ) ),
277 this, SLOT (client_changed( int ) ) ); 278 this, SLOT (client_changed( int ) ) );
278 279
279 QLabel* lab = new QLabel( i18n("Channel:"), mExternalAppGroupBox); 280 QLabel* lab = new QLabel( i18n("Channel:"), mExternalAppGroupBox);
280 boxLayout->addWidget( lab, 1, 0 ); 281 boxLayout->addWidget( lab, 1, 0 );
281 mChannel = new QLineEdit(mExternalAppGroupBox); 282 mChannel = new QLineEdit(mExternalAppGroupBox);
282 mChannel->setReadOnly(true); 283 mChannel->setReadOnly(true);
283 boxLayout->addMultiCellWidget( mChannel, 2 , 2, 0, 1 ); 284 boxLayout->addMultiCellWidget( mChannel, 2 , 2, 0, 1 );
284 285
285 lab = new QLabel( i18n("Message:"), mExternalAppGroupBox); 286 lab = new QLabel( i18n("Message:"), mExternalAppGroupBox);
286 boxLayout->addWidget( lab, 3, 0 ); 287 boxLayout->addWidget( lab, 3, 0 );
287 mMessage = new QLineEdit(mExternalAppGroupBox); 288 mMessage = new QLineEdit(mExternalAppGroupBox);
288 mMessage->setReadOnly(true); 289 mMessage->setReadOnly(true);
289 boxLayout->addWidget( mMessage , 4, 0); 290 boxLayout->addWidget( mMessage , 4, 0);
290 291
291 lab = new QLabel( i18n("Parameters:"), mExternalAppGroupBox); 292 lab = new QLabel( i18n("Parameters:"), mExternalAppGroupBox);
292 boxLayout->addWidget( lab, 3, 1 ); 293 boxLayout->addWidget( lab, 3, 1 );
293 mParameters = new QLineEdit(mExternalAppGroupBox); 294 mParameters = new QLineEdit(mExternalAppGroupBox);
294 mParameters->setReadOnly(true); 295 mParameters->setReadOnly(true);
295 boxLayout->addWidget( mParameters, 4, 1 ); 296 boxLayout->addWidget( mParameters, 4, 1 );
296 lab = new QLabel( i18n("HINT: Delimiter=; Name=%1,Email=%2"), mExternalAppGroupBox); 297 lab = new QLabel( i18n("HINT: Delimiter=; Name=%1,Email=%2"), mExternalAppGroupBox);
297 boxLayout->addMultiCellWidget( lab, 5, 5, 0, 1 ); 298 boxLayout->addMultiCellWidget( lab, 5, 5, 0, 1 );
298 299
299 300
300 if ( QApplication::desktop()->height() > 240 ) { 301 if ( QApplication::desktop()->height() > 240 ) {
301 lab = new QLabel( i18n("extra Message:"), mExternalAppGroupBox); 302 lab = new QLabel( i18n("extra Message:"), mExternalAppGroupBox);
302 boxLayout->addWidget( lab, 6, 0 ); 303 boxLayout->addWidget( lab, 6, 0 );
303 mMessage2 = new QLineEdit(mExternalAppGroupBox); 304 mMessage2 = new QLineEdit(mExternalAppGroupBox);
304 mMessage2->setReadOnly(true); 305 mMessage2->setReadOnly(true);
305 boxLayout->addWidget( mMessage2 , 7, 0); 306 boxLayout->addWidget( mMessage2 , 7, 0);
306 307
307 lab = new QLabel( i18n("extra Parameters:"), mExternalAppGroupBox); 308 lab = new QLabel( i18n("extra Parameters:"), mExternalAppGroupBox);
308 boxLayout->addWidget( lab, 6, 1 ); 309 boxLayout->addWidget( lab, 6, 1 );
309 mParameters2 = new QLineEdit(mExternalAppGroupBox); 310 mParameters2 = new QLineEdit(mExternalAppGroupBox);
310 mParameters2->setReadOnly(true); 311 mParameters2->setReadOnly(true);
311 boxLayout->addWidget( mParameters2, 7, 1 ); 312 boxLayout->addWidget( mParameters2, 7, 1 );
312 313
313 lab = new QLabel( i18n("HINT: Emails=%1,Attachments=%2"), mExternalAppGroupBox); 314 lab = new QLabel( i18n("HINT: Emails=%1,Attachments=%2"), mExternalAppGroupBox);
314 boxLayout->addMultiCellWidget( lab, 8, 8, 0, 1 ); 315 boxLayout->addMultiCellWidget( lab, 8, 8, 0, 1 );
315 connect( mMessage2, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); 316 connect( mMessage2, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
316 connect( mParameters2, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); 317 connect( mParameters2, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
317 } else { 318 } else {
318 mMessage2 = 0; 319 mMessage2 = 0;
319 mParameters2 = 0; 320 mParameters2 = 0;
320 } 321 }
321 322
322 connect( mChannel, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); 323 connect( mChannel, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
323 connect( mMessage, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); 324 connect( mMessage, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
324 connect( mParameters, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); 325 connect( mParameters, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
325 326
326 327
327 layout->addWidget( mExternalAppGroupBox ); 328 layout->addWidget( mExternalAppGroupBox );
328 tabWidget->addTab( externalAppsPage, i18n( "External Apps." ) ); 329 tabWidget->addTab( externalAppsPage, i18n( "External Apps." ) );
329 330
330} 331}
331 332
332 333
333void KDEPIMConfigWidget::setupLocaleDateTab() 334void KDEPIMConfigWidget::setupLocaleDateTab()
334{ 335{
335 QWidget *topFrame = new QWidget( this ); 336 QWidget *topFrame = new QWidget( this );
336 QGridLayout *topLayout = new QGridLayout( topFrame, 3, 2); 337 QGridLayout *topLayout = new QGridLayout( topFrame, 3, 2);
337 338
338 topLayout->setSpacing(KDialog::spacingHintSmall()); 339 topLayout->setSpacing(KDialog::spacingHintSmall());
339 topLayout->setMargin(KDialog::marginHintSmall()); 340 topLayout->setMargin(KDialog::marginHintSmall());
340 int iii = 0; 341 int iii = 0;
341 342
342 343
343 KPrefsWidRadios *syncPrefsGroup = 344 KPrefsWidRadios *syncPrefsGroup =
344 addWidRadios(i18n("Date Format:"),&(KPimGlobalPrefs::instance()->mPreferredDate),topFrame); 345 addWidRadios(i18n("Date Format:"),&(KPimGlobalPrefs::instance()->mPreferredDate),topFrame);
345 QString format; 346 QString format;
346 if ( QApplication::desktop()->width() < 480 ) 347 if ( QApplication::desktop()->width() < 480 )
347 format = "(%d.%m.%Y)"; 348 format = "(%d.%m.%Y)";
348 else 349 else
349 format = "(%d.%m.%Y|%A %d %B %Y)"; 350 format = "(%d.%m.%Y|%A %d %B %Y)";
350 syncPrefsGroup->addRadio(i18n("24.03.2004 "+format)); 351 syncPrefsGroup->addRadio(i18n("24.03.2004 "+format));
351 if ( QApplication::desktop()->width() < 480 ) 352 if ( QApplication::desktop()->width() < 480 )
352 format = "(%m.%d.%Y)"; 353 format = "(%m.%d.%Y)";
353 else 354 else
354 format = "(%m.%d.%Y|%A %B %d %Y)"; 355 format = "(%m.%d.%Y|%A %B %d %Y)";
355 syncPrefsGroup->addRadio(i18n("03.24.2004 "+format)); 356 syncPrefsGroup->addRadio(i18n("03.24.2004 "+format));
356 if ( QApplication::desktop()->width() < 480 ) 357 if ( QApplication::desktop()->width() < 480 )
357 format = "(%Y-%m-%d)"; 358 format = "(%Y-%m-%d)";
358 else 359 else
359 format = "(%Y-%m-%d|%A %Y %B %d)"; 360 format = "(%Y-%m-%d|%A %Y %B %d)";
360 syncPrefsGroup->addRadio(i18n("2004-03-24 "+format)); 361 syncPrefsGroup->addRadio(i18n("2004-03-24 "+format));
361 syncPrefsGroup->addRadio(i18n("User defined")); 362 syncPrefsGroup->addRadio(i18n("User defined"));
362 if ( QApplication::desktop()->width() < 480 ) { 363 if ( QApplication::desktop()->width() < 480 ) {
363 syncPrefsGroup->groupBox()->layout()->setMargin( 5 ); 364 syncPrefsGroup->groupBox()->layout()->setMargin( 5 );
364 syncPrefsGroup->groupBox()->layout()->setSpacing( 0 ); 365 syncPrefsGroup->groupBox()->layout()->setSpacing( 0 );
365 } 366 }
366 topLayout->addMultiCellWidget( (QWidget*)syncPrefsGroup->groupBox(),iii,iii,0,1); 367 topLayout->addMultiCellWidget( (QWidget*)syncPrefsGroup->groupBox(),iii,iii,0,1);
367 ++iii; 368 ++iii;
368 ++iii; 369 ++iii;
369 QLabel * lab; 370 QLabel * lab;
370 mUserDateFormatLong = new QLineEdit(topFrame); 371 mUserDateFormatLong = new QLineEdit(topFrame);
371 lab = new QLabel(mUserDateFormatLong, i18n("User long date:"), topFrame); 372 lab = new QLabel(mUserDateFormatLong, i18n("User long date:"), topFrame);
372 topLayout->addWidget(lab ,iii,0); 373 topLayout->addWidget(lab ,iii,0);
373 topLayout->addWidget(mUserDateFormatLong,iii,1); 374 topLayout->addWidget(mUserDateFormatLong,iii,1);
374 ++iii; 375 ++iii;
375 mUserDateFormatShort = new QLineEdit(topFrame); 376 mUserDateFormatShort = new QLineEdit(topFrame);
376 lab = new QLabel(mUserDateFormatShort, i18n("User short date:"), topFrame); 377 lab = new QLabel(mUserDateFormatShort, i18n("User short date:"), topFrame);
377 topLayout->addWidget(lab ,iii,0); 378 topLayout->addWidget(lab ,iii,0);
378 topLayout->addWidget(mUserDateFormatShort,iii,1); 379 topLayout->addWidget(mUserDateFormatShort,iii,1);
379 ++iii; 380 ++iii;
380 lab = new QLabel( i18n("Monday 19 April 2004: %A %d %B %Y"), topFrame); 381 lab = new QLabel( i18n("Monday 19 April 2004: %A %d %B %Y"), topFrame);
381 topLayout->addMultiCellWidget(lab ,iii,iii,0,1); 382 topLayout->addMultiCellWidget(lab ,iii,iii,0,1);
382 ++iii; 383 ++iii;
383 //qDebug(" QApplication::desktop()->height()xx %d ", QApplication::desktop()->height() ); 384 //qDebug(" QApplication::desktop()->height()xx %d ", QApplication::desktop()->height() );
384 if ( QApplication::desktop()->height() > 240 ) { 385 if ( QApplication::desktop()->height() > 240 ) {
385 lab = new QLabel( i18n("Mon 19.04.04: %a %d.%m.%y"), topFrame); 386 lab = new QLabel( i18n("Mon 19.04.04: %a %d.%m.%y"), topFrame);
386 topLayout->addMultiCellWidget(lab ,iii,iii,0,1); 387 topLayout->addMultiCellWidget(lab ,iii,iii,0,1);
387 ++iii; 388 ++iii;
388 lab = new QLabel( i18n("Mon, 19.Apr.04: %a, %d.%b.%y"), topFrame); 389 lab = new QLabel( i18n("Mon, 19.Apr.04: %a, %d.%b.%y"), topFrame);
389 topLayout->addMultiCellWidget(lab ,iii,iii,0,1); 390 topLayout->addMultiCellWidget(lab ,iii,iii,0,1);
390 ++iii; 391 ++iii;
391 } 392 }
392 393
393 connect( mUserDateFormatLong, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); 394 connect( mUserDateFormatLong, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
394 connect( mUserDateFormatShort, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); 395 connect( mUserDateFormatShort, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
395 396
396 397
397 tabWidget->addTab( topFrame, i18n( "Date Format" ) ); 398 tabWidget->addTab( topFrame, i18n( "Date Format" ) );
398} 399}
399 400
400void KDEPIMConfigWidget::setupLocaleTab() 401void KDEPIMConfigWidget::setupLocaleTab()
401{ 402{
402 403
403 QWidget *topFrame = new QWidget( this ); 404 QWidget *topFrame = new QWidget( this );
404 QGridLayout *topLayout = new QGridLayout(topFrame,4,2); 405 QGridLayout *topLayout = new QGridLayout(topFrame,4,2);
405 406
406 topLayout->setSpacing(KDialog::spacingHint()); 407 topLayout->setSpacing(KDialog::spacingHint());
407 topLayout->setMargin(KDialog::marginHint()); 408 topLayout->setMargin(KDialog::marginHint());
408 int iii = 0; 409 int iii = 0;
409 KPrefsWidRadios *syncPrefsGroup = 410 KPrefsWidRadios *syncPrefsGroup =
410 addWidRadios(i18n("Language:(needs restart)"),&(KPimGlobalPrefs::instance()->mPreferredLanguage),topFrame); 411 addWidRadios(i18n("Language:(needs restart)"),&(KPimGlobalPrefs::instance()->mPreferredLanguage),topFrame);
411 syncPrefsGroup->addRadio(i18n("English")); 412 syncPrefsGroup->addRadio(i18n("English"));
412 syncPrefsGroup->addRadio(i18n("German")); 413 syncPrefsGroup->addRadio(i18n("German"));
413 syncPrefsGroup->addRadio(i18n("French")); 414 syncPrefsGroup->addRadio(i18n("French"));
414 syncPrefsGroup->addRadio(i18n("Italian")); 415 syncPrefsGroup->addRadio(i18n("Italian"));
415 syncPrefsGroup->addRadio(i18n("User defined (usertranslation.txt)")); 416 syncPrefsGroup->addRadio(i18n("User defined (usertranslation.txt)"));
416 if ( QApplication::desktop()->width() < 300 ) { 417 if ( QApplication::desktop()->width() < 300 ) {
417 syncPrefsGroup->groupBox()->layout()->setMargin( 5 ); 418 syncPrefsGroup->groupBox()->layout()->setMargin( 5 );
418 syncPrefsGroup->groupBox()->layout()->setSpacing( 0 ); 419 syncPrefsGroup->groupBox()->layout()->setSpacing( 0 );
419 } 420 }
420 topLayout->addMultiCellWidget( (QWidget*)syncPrefsGroup->groupBox(),iii,iii,0,1); 421 topLayout->addMultiCellWidget( (QWidget*)syncPrefsGroup->groupBox(),iii,iii,0,1);
421 ++iii; 422 ++iii;
422 423
423 424
424 tabWidget->addTab( topFrame, i18n( "Language" ) ); 425 tabWidget->addTab( topFrame, i18n( "Language" ) );
425 topFrame = new QWidget( this ); 426 topFrame = new QWidget( this );
426 topLayout = new QGridLayout(topFrame,4,2); 427 topLayout = new QGridLayout(topFrame,4,2);
427 428
428 topLayout->setSpacing(KDialog::spacingHint()); 429 topLayout->setSpacing(KDialog::spacingHint());
429 topLayout->setMargin(KDialog::marginHint()); 430 topLayout->setMargin(KDialog::marginHint());
430 iii = 0; 431 iii = 0;
431 syncPrefsGroup = 432 syncPrefsGroup =
432 addWidRadios(i18n("Time Format(nr):"),&(KPimGlobalPrefs::instance()->mPreferredTime),topFrame); 433 addWidRadios(i18n("Time Format(nr):"),&(KPimGlobalPrefs::instance()->mPreferredTime),topFrame);
433 if ( QApplication::desktop()->width() > 300 ) 434 if ( QApplication::desktop()->width() > 300 )
434 syncPrefsGroup->groupBox()->setOrientation (Qt::Vertical); 435 syncPrefsGroup->groupBox()->setOrientation (Qt::Vertical);
435 syncPrefsGroup->addRadio(i18n("24:00")); 436 syncPrefsGroup->addRadio(i18n("24:00"));
436 syncPrefsGroup->addRadio(i18n("12:00am")); 437 syncPrefsGroup->addRadio(i18n("12:00am"));
437 syncPrefsGroup->groupBox()->setOrientation (Qt::Vertical); 438 syncPrefsGroup->groupBox()->setOrientation (Qt::Vertical);
438 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); 439 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1);
439 ++iii; 440 ++iii;
440 441
441 KPrefsWidBool *sb = addWidBool(i18n("Week starts on Sunday"), 442 KPrefsWidBool *sb = addWidBool(i18n("Week starts on Sunday"),
442 &(KPimGlobalPrefs::instance()->mWeekStartsOnSunday),topFrame); 443 &(KPimGlobalPrefs::instance()->mWeekStartsOnSunday),topFrame);
443 topLayout->addMultiCellWidget((QWidget*)sb->checkBox(), iii,iii,0,1); 444 topLayout->addMultiCellWidget((QWidget*)sb->checkBox(), iii,iii,0,1);
444 ++iii; 445 ++iii;
445 446
446 447
447 tabWidget->addTab( topFrame, i18n( "Time Format" ) ); 448 tabWidget->addTab( topFrame, i18n( "Time Format" ) );
448 449
449} 450}
450 451
451 452
452void KDEPIMConfigWidget::setupTimeZoneTab() 453void KDEPIMConfigWidget::setupTimeZoneTab()
453{ 454{
454 QWidget *topFrame; 455 QWidget *topFrame;
455 QGridLayout *topLayout ; 456 QGridLayout *topLayout ;
456 457
457 458
458 459
459 460
460 461
461 462
462 topFrame = new QWidget( this ); 463 topFrame = new QWidget( this );
463 topLayout = new QGridLayout( topFrame, 5, 2); 464 topLayout = new QGridLayout( topFrame, 5, 2);
464 topLayout->setSpacing(KDialog::spacingHintSmall()); 465 topLayout->setSpacing(KDialog::spacingHintSmall());
465 topLayout->setMargin(KDialog::marginHintSmall()); 466 topLayout->setMargin(KDialog::marginHintSmall());
466 467
467 QHBox *timeZoneBox = new QHBox( topFrame ); 468 QHBox *timeZoneBox = new QHBox( topFrame );
468 topLayout->addMultiCellWidget( timeZoneBox, 0, 0, 0, 1 ); 469 topLayout->addMultiCellWidget( timeZoneBox, 0, 0, 0, 1 );
469 470
470 new QLabel( i18n("Timezone:"), timeZoneBox ); 471 new QLabel( i18n("Timezone:"), timeZoneBox );
471 mTimeZoneCombo = new QComboBox( timeZoneBox ); 472 mTimeZoneCombo = new QComboBox( timeZoneBox );
472 if ( QApplication::desktop()->width() < 300 ) { 473 if ( QApplication::desktop()->width() < 300 ) {
473 mTimeZoneCombo->setMaximumWidth(150); 474 mTimeZoneCombo->setMaximumWidth(150);
474 } 475 }
475 476
476 QStringList list; 477 QStringList list;
477 list = KGlobal::locale()->timeZoneList(); 478 list = KGlobal::locale()->timeZoneList();
478 mTimeZoneCombo->insertStringList(list); 479 mTimeZoneCombo->insertStringList(list);
479 480
480 // find the currently set time zone and select it 481 // find the currently set time zone and select it
481 QString sCurrentlySet = KPimGlobalPrefs::instance()->mTimeZoneId; 482 QString sCurrentlySet = KPimGlobalPrefs::instance()->mTimeZoneId;
482 int nCurrentlySet = 11; 483 int nCurrentlySet = 11;
483 for (int i = 0; i < mTimeZoneCombo->count(); i++) 484 for (int i = 0; i < mTimeZoneCombo->count(); i++)
484 { 485 {
485 if (mTimeZoneCombo->text(i) == sCurrentlySet) 486 if (mTimeZoneCombo->text(i) == sCurrentlySet)
486 { 487 {
487 nCurrentlySet = i; 488 nCurrentlySet = i;
488 break; 489 break;
489 } 490 }
490 } 491 }
491 mTimeZoneCombo->setCurrentItem(nCurrentlySet); 492 mTimeZoneCombo->setCurrentItem(nCurrentlySet);
492 int iii = 1; 493 int iii = 1;
493 KPrefsWidBool *sb = 494 KPrefsWidBool *sb =
494 addWidBool(i18n("Add 30 min to selected Timezone"), 495 addWidBool(i18n("Add 30 min to selected Timezone"),
495 &(KPimGlobalPrefs::instance()->mTimeZoneAdd30min),topFrame); 496 &(KPimGlobalPrefs::instance()->mTimeZoneAdd30min),topFrame);
496 topLayout->addMultiCellWidget((QWidget*)sb->checkBox(), iii,iii,0,1); 497 topLayout->addMultiCellWidget((QWidget*)sb->checkBox(), iii,iii,0,1);
497 ++iii; 498 ++iii;
498 sb = 499 sb =
499 addWidBool(i18n("Timezone has daylight saving"), 500 addWidBool(i18n("Timezone has daylight saving"),
500 &(KPimGlobalPrefs::instance()->mUseDaylightsaving),topFrame); 501 &(KPimGlobalPrefs::instance()->mUseDaylightsaving),topFrame);
501 topLayout->addMultiCellWidget((QWidget*)sb->checkBox(), iii,iii,0,1); 502 topLayout->addMultiCellWidget((QWidget*)sb->checkBox(), iii,iii,0,1);
502 ++iii; 503 ++iii;
503 QLabel* lab; 504 QLabel* lab;
504 505
505 lab = new QLabel( i18n("Actual start and end is the\nsunday before this date."), topFrame ); 506 lab = new QLabel( i18n("Actual start and end is the\nsunday before this date."), topFrame );
506 topLayout->addMultiCellWidget(lab, iii,iii,0,1); 507 topLayout->addMultiCellWidget(lab, iii,iii,0,1);
507 ++iii; 508 ++iii;
508 509
509 lab = new QLabel( i18n("The year in the date is ignored."), topFrame ); 510 lab = new QLabel( i18n("The year in the date is ignored."), topFrame );
510 topLayout->addMultiCellWidget(lab, iii,iii,0,1); 511 topLayout->addMultiCellWidget(lab, iii,iii,0,1);
511 ++iii; 512 ++iii;
512 lab = new QLabel( i18n("Daylight start:"), topFrame ); 513 lab = new QLabel( i18n("Daylight start:"), topFrame );
513 topLayout->addWidget(lab, iii,0); 514 topLayout->addWidget(lab, iii,0);
514 mStartDateSavingEdit = new KDateEdit(topFrame); 515 mStartDateSavingEdit = new KDateEdit(topFrame);
515 topLayout->addWidget(mStartDateSavingEdit, iii,1); 516 topLayout->addWidget(mStartDateSavingEdit, iii,1);
516 ++iii; 517 ++iii;
517 518
518 lab = new QLabel( i18n("Daylight end:"), topFrame ); 519 lab = new QLabel( i18n("Daylight end:"), topFrame );
519 topLayout->addWidget(lab, iii,0); 520 topLayout->addWidget(lab, iii,0);
520 mEndDateSavingEdit = new KDateEdit(topFrame); 521 mEndDateSavingEdit = new KDateEdit(topFrame);
521 topLayout->addWidget(mEndDateSavingEdit, iii,1); 522 topLayout->addWidget(mEndDateSavingEdit, iii,1);
522 ++iii; 523 ++iii;
523 QDate current ( 2001, 1,1); 524 QDate current ( 2001, 1,1);
524 mStartDateSavingEdit->setDate(current.addDays(KPimGlobalPrefs::instance()->mDaylightsavingStart-1)); 525 mStartDateSavingEdit->setDate(current.addDays(KPimGlobalPrefs::instance()->mDaylightsavingStart-1));
525 mEndDateSavingEdit->setDate(current.addDays(KPimGlobalPrefs::instance()->mDaylightsavingEnd-1)); 526 mEndDateSavingEdit->setDate(current.addDays(KPimGlobalPrefs::instance()->mDaylightsavingEnd-1));
526 527
527 connect( mStartDateSavingEdit, SIGNAL( dateChanged(QDate)), this, SLOT( modified()) ); 528 connect( mStartDateSavingEdit, SIGNAL( dateChanged(QDate)), this, SLOT( modified()) );
528 connect( mEndDateSavingEdit, SIGNAL( dateChanged(QDate)), this, SLOT( modified()) ); 529 connect( mEndDateSavingEdit, SIGNAL( dateChanged(QDate)), this, SLOT( modified()) );
529 connect( mTimeZoneCombo, SIGNAL( activated( int ) ), this, SLOT (modified() ) ); 530 connect( mTimeZoneCombo, SIGNAL( activated( int ) ), this, SLOT (modified() ) );
530 tabWidget->addTab( topFrame, i18n( "Time Zone" ) ); 531 tabWidget->addTab( topFrame, i18n( "Time Zone" ) );
531 532
532 533
533 topFrame = new QWidget( this ); 534 topFrame = new QWidget( this );
534 topLayout = new QGridLayout( topFrame, 3, 2); 535 topLayout = new QGridLayout( topFrame, 3, 2);
535 topLayout->setSpacing(KDialog::spacingHintSmall()); 536 topLayout->setSpacing(KDialog::spacingHintSmall());
536 topLayout->setMargin(KDialog::marginHintSmall()); 537 topLayout->setMargin(KDialog::marginHintSmall());
537 tabWidget->addTab( topFrame, i18n( "Fonts" ) ); 538 tabWidget->addTab( topFrame, i18n( "Fonts" ) );
538 539
539 QLabel* labb = new QLabel( i18n("Global application font for all apps:"), topFrame ); 540 QLabel* labb = new QLabel( i18n("Global application font for all apps:"), topFrame );
540 topLayout->addMultiCellWidget(labb,0,0,0,2); 541 topLayout->addMultiCellWidget(labb,0,0,0,2);
541 int i = 1; 542 int i = 1;
542 KPrefsWidFont *timeLabelsFont = 543 KPrefsWidFont *timeLabelsFont =
543 addWidFont(i18n("Kx/Pi"),i18n("Application Font"), 544 addWidFont(i18n("Kx/Pi"),i18n("Application Font"),
544 &(KPimGlobalPrefs::instance()->mApplicationFont),topFrame); 545 &(KPimGlobalPrefs::instance()->mApplicationFont),topFrame);
545 topLayout->addWidget(timeLabelsFont->label(),i,0); 546 topLayout->addWidget(timeLabelsFont->label(),i,0);
546 topLayout->addWidget(timeLabelsFont->preview(),i,1); 547 topLayout->addWidget(timeLabelsFont->preview(),i,1);
547 topLayout->addWidget(timeLabelsFont->button(),i,2); 548 topLayout->addWidget(timeLabelsFont->button(),i,2);
548} 549}
549 550
550void KDEPIMConfigWidget::externalapp_changed( int newApp ) 551void KDEPIMConfigWidget::externalapp_changed( int newApp )
551{ 552{
552 // first store the current data 553 // first store the current data
553 saveEditFieldSettings(); 554 saveEditFieldSettings();
554 555
555 // set mCurrentApp 556 // set mCurrentApp
556 mCurrentApp = (ExternalAppHandler::Types)newApp; 557 mCurrentApp = (ExternalAppHandler::Types)newApp;
557 558
558 // set mCurrentClient 559 // set mCurrentClient
559 switch(mCurrentApp) 560 switch(mCurrentApp)
560 { 561 {
561 case(ExternalAppHandler::EMAIL): 562 case(ExternalAppHandler::EMAIL):
562 mCurrentClient = mEmailClient; 563 mCurrentClient = mEmailClient;
563 break; 564 break;
564 case(ExternalAppHandler::PHONE): 565 case(ExternalAppHandler::PHONE):
565 mCurrentClient = mPhoneClient; 566 mCurrentClient = mPhoneClient;
566 break; 567 break;
567 case(ExternalAppHandler::SMS): 568 case(ExternalAppHandler::SMS):
568 mCurrentClient = mSMSClient; 569 mCurrentClient = mSMSClient;
569 break; 570 break;
570 case(ExternalAppHandler::FAX): 571 case(ExternalAppHandler::FAX):
571 mCurrentClient = mFaxClient; 572 mCurrentClient = mFaxClient;
572 break; 573 break;
573 case(ExternalAppHandler::PAGER): 574 case(ExternalAppHandler::PAGER):
574 mCurrentClient = mPagerClient; 575 mCurrentClient = mPagerClient;
575 break; 576 break;
576 case(ExternalAppHandler::SIP): 577 case(ExternalAppHandler::SIP):
577 mCurrentClient = mSipClient; 578 mCurrentClient = mSipClient;
578 break; 579 break;
579 default: 580 default:
580 return; 581 return;
581 } 582 }
582 583
583 // and at last update the widgets 584 // and at last update the widgets
584 updateClientWidgets(); 585 updateClientWidgets();
585} 586}
586 587
587 588
588 589
589void KDEPIMConfigWidget::client_changed( int newClient ) 590void KDEPIMConfigWidget::client_changed( int newClient )
590{ 591{
591 if (newClient == mCurrentClient) 592 if (newClient == mCurrentClient)
592 return; 593 return;
593 594
594 // first store the current data 595 // first store the current data
595 saveEditFieldSettings(); 596 saveEditFieldSettings();
596 597
597 598
598 //then reset the clientvariable 599 //then reset the clientvariable
599 mCurrentClient = newClient; 600 mCurrentClient = newClient;
600 601
601 // and at last update the widgets 602 // and at last update the widgets
602 updateClientWidgets(); 603 updateClientWidgets();
603 604
604 KPrefsWidget::modified(); 605 KPrefsWidget::modified();
605} 606}
606 607
607void KDEPIMConfigWidget::saveEditFieldSettings() 608void KDEPIMConfigWidget::saveEditFieldSettings()
608{ 609{
609 610
610 switch(mCurrentApp) 611 switch(mCurrentApp)
611 { 612 {
612 case(ExternalAppHandler::EMAIL): 613 case(ExternalAppHandler::EMAIL):
613 mEmailClient = mClient->currentItem(); 614 mEmailClient = mClient->currentItem();
614 break; 615 break;
615 case(ExternalAppHandler::PHONE): 616 case(ExternalAppHandler::PHONE):
616 mPhoneClient= mClient->currentItem(); 617 mPhoneClient= mClient->currentItem();
617 break; 618 break;
618 case(ExternalAppHandler::SMS): 619 case(ExternalAppHandler::SMS):
619 mSMSClient = mClient->currentItem(); 620 mSMSClient = mClient->currentItem();
620 break; 621 break;
621 case(ExternalAppHandler::FAX): 622 case(ExternalAppHandler::FAX):
622 mFaxClient = mClient->currentItem(); 623 mFaxClient = mClient->currentItem();
623 break; 624 break;
624 case(ExternalAppHandler::PAGER): 625 case(ExternalAppHandler::PAGER):
625 mPagerClient = mClient->currentItem(); 626 mPagerClient = mClient->currentItem();
626 break; 627 break;
627 case(ExternalAppHandler::SIP): 628 case(ExternalAppHandler::SIP):
628 mSipClient = mClient->currentItem(); 629 mSipClient = mClient->currentItem();
629 break; 630 break;
630 default: 631 default:
631 return; 632 return;
632 } 633 }
633 634
634 //store the current data back to the apropriate membervariables if we had set it to "other" 635 //store the current data back to the apropriate membervariables if we had set it to "other"
635 if ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::OTHER_EMC)) 636 if ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::OTHER_EMC))
636 { 637 {
637 mEmailOtherChannel = mChannel->text(); 638 mEmailOtherChannel = mChannel->text();
638 mEmailOtherMessage = mMessage->text(); 639 mEmailOtherMessage = mMessage->text();
639 mEmailOtherMessageParameters = mParameters->text(); 640 mEmailOtherMessageParameters = mParameters->text();
640 if ( mMessage2 ) 641 if ( mMessage2 )
641 mEmailOtherMessage2 = mMessage2->text(); 642 mEmailOtherMessage2 = mMessage2->text();
642 if ( mParameters2 ) 643 if ( mParameters2 )
643 mEmailOtherMessageParameters2 = mParameters2->text(); 644 mEmailOtherMessageParameters2 = mParameters2->text();
644 } 645 }
645 else if ((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::OTHER_PHC)) 646 else if ((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::OTHER_PHC))
646 { 647 {
647 mPhoneOtherChannel = mChannel->text(); 648 mPhoneOtherChannel = mChannel->text();
648 mPhoneOtherMessage = mMessage->text(); 649 mPhoneOtherMessage = mMessage->text();
649 mPhoneOtherMessageParameters = mParameters->text(); 650 mPhoneOtherMessageParameters = mParameters->text();
650 } 651 }
651 else if ((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::OTHER_SMC)) 652 else if ((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::OTHER_SMC))
652 { 653 {
653 mSMSOtherChannel = mChannel->text(); 654 mSMSOtherChannel = mChannel->text();
654 mSMSOtherMessage = mMessage->text(); 655 mSMSOtherMessage = mMessage->text();
655 mSMSOtherMessageParameters = mParameters->text(); 656 mSMSOtherMessageParameters = mParameters->text();
656 } 657 }
657 else if ((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::OTHER_FAC)) 658 else if ((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::OTHER_FAC))
658 { 659 {
659 mFaxOtherChannel = mChannel->text(); 660 mFaxOtherChannel = mChannel->text();
660 mFaxOtherMessage = mMessage->text(); 661 mFaxOtherMessage = mMessage->text();
661 mFaxOtherMessageParameters = mParameters->text(); 662 mFaxOtherMessageParameters = mParameters->text();
662 } 663 }
663 else if ((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::OTHER_PAC)) 664 else if ((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::OTHER_PAC))
664 { 665 {
665 mPagerOtherChannel = mChannel->text(); 666 mPagerOtherChannel = mChannel->text();
666 mPagerOtherMessage = mMessage->text(); 667 mPagerOtherMessage = mMessage->text();
667 mPagerOtherMessageParameters = mParameters->text(); 668 mPagerOtherMessageParameters = mParameters->text();
668 } 669 }
669 else if ((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::OTHER_SIC)) 670 else if ((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::OTHER_SIC))
670 { 671 {
671 mSipOtherChannel = mChannel->text(); 672 mSipOtherChannel = mChannel->text();
672 mSipOtherMessage = mMessage->text(); 673 mSipOtherMessage = mMessage->text();
673 mSipOtherMessageParameters = mParameters->text(); 674 mSipOtherMessageParameters = mParameters->text();
674 } 675 }
675 676
676 677
677} 678}
678 679
679void KDEPIMConfigWidget::updateClientWidgets() 680void KDEPIMConfigWidget::updateClientWidgets()
680{ 681{
681 bool blocked = signalsBlocked(); 682 bool blocked = signalsBlocked();
682 blockSignals( true ); 683 blockSignals( true );
683 684
684 // at this point we assume, that mCurrentApp and mCurrentClient are set to the values that we want to display 685 // at this point we assume, that mCurrentApp and mCurrentClient are set to the values that we want to display
685 QMap<ExternalAppHandler::Types, QString>::Iterator it = mExternalAppsMap.find ( mCurrentApp ); 686 QMap<ExternalAppHandler::Types, QString>::Iterator it = mExternalAppsMap.find ( mCurrentApp );
686 if (it == mExternalAppsMap.end()) 687 if (it == mExternalAppsMap.end())
687 return; 688 return;
688 689
689 // update group box 690 // update group box
690 mExternalAppGroupBox->setTitle(i18n( "Used %1 Client" ).arg(it.data())); 691 mExternalAppGroupBox->setTitle(i18n( "Used %1 Client" ).arg(it.data()));
691 692
692 //update the entries in the client combobox 693 //update the entries in the client combobox
693 mClient->clear(); 694 mClient->clear();
694 695
695 QList<DefaultAppItem> items = ExternalAppHandler::instance()->getAvailableDefaultItems(mCurrentApp); 696 QList<DefaultAppItem> items = ExternalAppHandler::instance()->getAvailableDefaultItems(mCurrentApp);
696 DefaultAppItem* dai; 697 DefaultAppItem* dai;
697 for ( dai=items.first(); dai != 0; dai=items.next() ) 698 for ( dai=items.first(); dai != 0; dai=items.next() )
698 { 699 {
699 mClient->insertItem( i18n(dai->_label), dai->_id ); 700 mClient->insertItem( i18n(dai->_label), dai->_id );
700 701
701 if (dai->_id == mCurrentClient) 702 if (dai->_id == mCurrentClient)
702 { 703 {
703 //restore the edit fields with the data of the local membervariables if we had set it to "other". 704 //restore the edit fields with the data of the local membervariables if we had set it to "other".
704 //Otherwise take the default data from externalapphandler. 705 //Otherwise take the default data from externalapphandler.
705 mChannel->setText(dai->_channel); 706 mChannel->setText(dai->_channel);
706 mMessage->setText(dai->_message); 707 mMessage->setText(dai->_message);
707 mParameters->setText(dai->_parameters); 708 mParameters->setText(dai->_parameters);
708 if ( mMessage2 ) 709 if ( mMessage2 )
709 mMessage2->setText(dai->_message2); 710 mMessage2->setText(dai->_message2);
710 if ( mParameters2 ) 711 if ( mParameters2 )
711 mParameters2->setText(dai->_parameters2); 712 mParameters2->setText(dai->_parameters2);
712 713
713 714
714 if ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::OTHER_EMC)) 715 if ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::OTHER_EMC))
715 { 716 {
716 mChannel->setText(mEmailOtherChannel); 717 mChannel->setText(mEmailOtherChannel);
717 mMessage->setText(mEmailOtherMessage); 718 mMessage->setText(mEmailOtherMessage);
718 mParameters->setText(mEmailOtherMessageParameters); 719 mParameters->setText(mEmailOtherMessageParameters);
719 if ( mMessage2 ) 720 if ( mMessage2 )
720 mMessage2->setText(mEmailOtherMessage2); 721 mMessage2->setText(mEmailOtherMessage2);
721 if ( mParameters2 ) 722 if ( mParameters2 )
722 mParameters2->setText(mEmailOtherMessageParameters2); 723 mParameters2->setText(mEmailOtherMessageParameters2);
723 } 724 }
724 else if ((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::OTHER_PHC)) 725 else if ((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::OTHER_PHC))
725 { 726 {
726 mChannel->setText(mPhoneOtherChannel); 727 mChannel->setText(mPhoneOtherChannel);
727 mMessage->setText(mPhoneOtherMessage); 728 mMessage->setText(mPhoneOtherMessage);
728 mParameters->setText(mPhoneOtherMessageParameters); 729 mParameters->setText(mPhoneOtherMessageParameters);
729 } 730 }
730 else if ((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::OTHER_SMC)) 731 else if ((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::OTHER_SMC))
731 { 732 {
732 mChannel->setText(mSMSOtherChannel); 733 mChannel->setText(mSMSOtherChannel);
733 mMessage->setText(mSMSOtherMessage); 734 mMessage->setText(mSMSOtherMessage);
734 mParameters->setText(mSMSOtherMessageParameters); 735 mParameters->setText(mSMSOtherMessageParameters);
735 } 736 }
736 else if ((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::OTHER_FAC)) 737 else if ((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::OTHER_FAC))
737 { 738 {
738 mChannel->setText(mFaxOtherChannel); 739 mChannel->setText(mFaxOtherChannel);
739 mMessage->setText(mFaxOtherMessage); 740 mMessage->setText(mFaxOtherMessage);
740 mParameters->setText(mFaxOtherMessageParameters); 741 mParameters->setText(mFaxOtherMessageParameters);
741 } 742 }
742 else if ((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::OTHER_PAC)) 743 else if ((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::OTHER_PAC))
743 { 744 {
744 mChannel->setText(mPagerOtherChannel); 745 mChannel->setText(mPagerOtherChannel);
745 mMessage->setText(mPagerOtherMessage); 746 mMessage->setText(mPagerOtherMessage);
746 mParameters->setText(mPagerOtherMessageParameters); 747 mParameters->setText(mPagerOtherMessageParameters);
747 } 748 }
748 else if ((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::OTHER_SIC)) 749 else if ((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::OTHER_SIC))
749 { 750 {
750 mChannel->setText(mSipOtherChannel); 751 mChannel->setText(mSipOtherChannel);
751 mMessage->setText(mSipOtherMessage); 752 mMessage->setText(mSipOtherMessage);
752 mParameters->setText(mSipOtherMessageParameters); 753 mParameters->setText(mSipOtherMessageParameters);
753 } 754 }
754 } 755 }
755 756
756 } 757 }
757 758
758 bool readonly; 759 bool readonly;
759 bool enabled; 760 bool enabled;
760 if ( ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::OTHER_EMC)) 761 if ( ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::OTHER_EMC))
761 ||((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::OTHER_PHC)) 762 ||((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::OTHER_PHC))
762 ||((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::OTHER_SMC)) 763 ||((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::OTHER_SMC))
763 ||((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::OTHER_FAC)) 764 ||((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::OTHER_FAC))
764 ||((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::OTHER_PAC)) 765 ||((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::OTHER_PAC))
765 ||((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::OTHER_SIC))) 766 ||((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::OTHER_SIC)))
766 { 767 {
767 readonly = false; 768 readonly = false;
768 } 769 }
769 else 770 else
770 { 771 {
771 readonly = true; 772 readonly = true;
772 } 773 }
773 774
774 if ( ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::NONE_EMC)) 775 if ( ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::NONE_EMC))
775 ||((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::NONE_PHC)) 776 ||((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::NONE_PHC))
776 ||((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::NONE_SMC)) 777 ||((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::NONE_SMC))
777 ||((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::NONE_FAC)) 778 ||((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::NONE_FAC))
778 ||((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::NONE_PAC)) 779 ||((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::NONE_PAC))
779 ||((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::NONE_SIC))) 780 ||((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::NONE_SIC)))
780 { 781 {
781 enabled = false; 782 enabled = false;
782 } 783 }
783 else 784 else
784 { 785 {
785 enabled = true; 786 enabled = true;
786 } 787 }
787 788
788 789
789 mChannel->setReadOnly(readonly); 790 mChannel->setReadOnly(readonly);
790 mMessage->setReadOnly(readonly); 791 mMessage->setReadOnly(readonly);
791 mParameters->setReadOnly(readonly); 792 mParameters->setReadOnly(readonly);
792 if ( mMessage2 ) 793 if ( mMessage2 )
793 mMessage2->setReadOnly(readonly); 794 mMessage2->setReadOnly(readonly);
794 if ( mParameters2 ) 795 if ( mParameters2 )
795 mParameters2->setReadOnly(readonly); 796 mParameters2->setReadOnly(readonly);
796 797
797 mChannel->setEnabled(enabled); 798 mChannel->setEnabled(enabled);
798 mMessage->setEnabled(enabled); 799 mMessage->setEnabled(enabled);
799 mParameters->setEnabled(enabled); 800 mParameters->setEnabled(enabled);
800 if ( mMessage2 ) 801 if ( mMessage2 )
801 mMessage2->setEnabled(enabled); 802 mMessage2->setEnabled(enabled);
802 if ( mParameters2 ) 803 if ( mParameters2 )
803 mParameters2->setEnabled(enabled); 804 mParameters2->setEnabled(enabled);
804 805
805 806
806 807
807 mClient->setCurrentItem(mCurrentClient); 808 mClient->setCurrentItem(mCurrentClient);
808 809
809 810
810 // enable/disable the extra message/parameter field 811 // enable/disable the extra message/parameter field
811 if (mCurrentApp == ExternalAppHandler::EMAIL) 812 if (mCurrentApp == ExternalAppHandler::EMAIL)
812 { 813 {
813 } 814 }
814 else 815 else
815 { 816 {
816 if ( mMessage2 ) 817 if ( mMessage2 )
817 mMessage2->setText( "" ); 818 mMessage2->setText( "" );
818 if ( mParameters2 ) 819 if ( mParameters2 )
819 mParameters2->setText( "" ); 820 mParameters2->setText( "" );
820 } 821 }
821 822
822 if (enabled == true) { 823 if (enabled == true) {
823 if ( mMessage2 ) 824 if ( mMessage2 )
824 mMessage2->setEnabled(mCurrentApp == ExternalAppHandler::EMAIL); 825 mMessage2->setEnabled(mCurrentApp == ExternalAppHandler::EMAIL);
825 if ( mParameters2 ) 826 if ( mParameters2 )
826 mParameters2->setEnabled(mCurrentApp == ExternalAppHandler::EMAIL); 827 mParameters2->setEnabled(mCurrentApp == ExternalAppHandler::EMAIL);
827 } 828 }
828 829
829 830
830 blockSignals( blocked ); 831 blockSignals( blocked );
831 832
832} 833}
833 834
834void KDEPIMConfigWidget::usrReadConfig() 835void KDEPIMConfigWidget::usrReadConfig()
835{ 836{
836 KPimGlobalPrefs* prefs = KPimGlobalPrefs::instance(); 837 KPimGlobalPrefs* prefs = KPimGlobalPrefs::instance();
837 838
838 bool blocked = signalsBlocked(); 839 bool blocked = signalsBlocked();
839 blockSignals( true ); 840 blockSignals( true );
840 841
841 if (KPimGlobalPrefs::instance()->mBackupUseDefaultDir ) 842 if (KPimGlobalPrefs::instance()->mBackupUseDefaultDir )
842 mBackupUrl->setURL( KGlobalSettings::backupDataDir() ); 843 mBackupUrl->setURL( KGlobalSettings::backupDataDir() );
843 else 844 else
844 mBackupUrl->setURL(prefs->mBackupDatadir); 845 mBackupUrl->setURL(prefs->mBackupDatadir);
845 mBackupNumbersSpin->setValue( prefs->mBackupNumbers ); 846 mBackupNumbersSpin->setValue( prefs->mBackupNumbers );
846 mBackupDayCountSpin->setValue( prefs->mBackupDayCount); 847 mBackupDayCountSpin->setValue( prefs->mBackupDayCount);
847 848
848 QString dummy = prefs->mUserDateFormatLong; 849 QString dummy = prefs->mUserDateFormatLong;
849 mUserDateFormatLong->setText(dummy.replace( QRegExp("K"), QString(",") )); 850 mUserDateFormatLong->setText(dummy.replace( QRegExp("K"), QString(",") ));
850 dummy = prefs->mUserDateFormatShort; 851 dummy = prefs->mUserDateFormatShort;
851 mUserDateFormatShort->setText(dummy.replace( QRegExp("K"), QString(",") )); 852 mUserDateFormatShort->setText(dummy.replace( QRegExp("K"), QString(",") ));
852 853
853 QDate current ( 2001, 1,1); 854 QDate current ( 2001, 1,1);
854 mStartDateSavingEdit->setDate(current.addDays(prefs->mDaylightsavingStart-1)); 855 mStartDateSavingEdit->setDate(current.addDays(prefs->mDaylightsavingStart-1));
855 mEndDateSavingEdit->setDate(current.addDays(prefs->mDaylightsavingEnd-1)); 856 mEndDateSavingEdit->setDate(current.addDays(prefs->mDaylightsavingEnd-1));
856 setCombo(mTimeZoneCombo,i18n(prefs->mTimeZoneId)); 857 setCombo(mTimeZoneCombo,i18n(prefs->mTimeZoneId));
857 858
858 mEmailClient = prefs->mEmailClient; 859 mEmailClient = prefs->mEmailClient;
859 mEmailOtherChannel = prefs->mEmailOtherChannel; 860 mEmailOtherChannel = prefs->mEmailOtherChannel;
860 mEmailOtherMessage = prefs->mEmailOtherMessage; 861 mEmailOtherMessage = prefs->mEmailOtherMessage;
861 mEmailOtherMessageParameters = prefs->mEmailOtherMessageParameters; 862 mEmailOtherMessageParameters = prefs->mEmailOtherMessageParameters;
862 mEmailOtherMessage2 = prefs->mEmailOtherMessage2; 863 mEmailOtherMessage2 = prefs->mEmailOtherMessage2;
863 mEmailOtherMessageParameters2 = prefs->mEmailOtherMessageParameters2; 864 mEmailOtherMessageParameters2 = prefs->mEmailOtherMessageParameters2;
864 865
865 mPhoneClient = prefs->mPhoneClient; 866 mPhoneClient = prefs->mPhoneClient;
866 mPhoneOtherChannel = prefs->mPhoneOtherChannel; 867 mPhoneOtherChannel = prefs->mPhoneOtherChannel;
867 mPhoneOtherMessage = prefs->mPhoneOtherMessage; 868 mPhoneOtherMessage = prefs->mPhoneOtherMessage;
868 mPhoneOtherMessageParameters = prefs->mPhoneOtherMessageParameters; 869 mPhoneOtherMessageParameters = prefs->mPhoneOtherMessageParameters;
869 870
870 mFaxClient = prefs->mFaxClient; 871 mFaxClient = prefs->mFaxClient;
871 mFaxOtherChannel = prefs->mFaxOtherChannel; 872 mFaxOtherChannel = prefs->mFaxOtherChannel;
872 mFaxOtherMessage = prefs->mFaxOtherMessage; 873 mFaxOtherMessage = prefs->mFaxOtherMessage;
873 mFaxOtherMessageParameters = prefs->mFaxOtherMessageParameters; 874 mFaxOtherMessageParameters = prefs->mFaxOtherMessageParameters;
874 875
875 mSMSClient = prefs->mSMSClient; 876 mSMSClient = prefs->mSMSClient;
876 mSMSOtherChannel = prefs->mSMSOtherChannel; 877 mSMSOtherChannel = prefs->mSMSOtherChannel;
877 mSMSOtherMessage = prefs->mSMSOtherMessage; 878 mSMSOtherMessage = prefs->mSMSOtherMessage;
878 mSMSOtherMessageParameters = prefs->mSMSOtherMessageParameters; 879 mSMSOtherMessageParameters = prefs->mSMSOtherMessageParameters;
879 880
880 mPagerClient = prefs->mPagerClient; 881 mPagerClient = prefs->mPagerClient;
881 mPagerOtherChannel = prefs->mPagerOtherChannel; 882 mPagerOtherChannel = prefs->mPagerOtherChannel;
882 mPagerOtherMessage = prefs->mPagerOtherMessage; 883 mPagerOtherMessage = prefs->mPagerOtherMessage;
883 mPagerOtherMessageParameters = prefs->mPagerOtherMessageParameters; 884 mPagerOtherMessageParameters = prefs->mPagerOtherMessageParameters;
884 885
885 mSipClient = prefs->mSipClient; 886 mSipClient = prefs->mSipClient;
886 mSipOtherChannel = prefs->mSipOtherChannel; 887 mSipOtherChannel = prefs->mSipOtherChannel;
887 mSipOtherMessage = prefs->mSipOtherMessage; 888 mSipOtherMessage = prefs->mSipOtherMessage;
888 mSipOtherMessageParameters = prefs->mSipOtherMessageParameters; 889 mSipOtherMessageParameters = prefs->mSipOtherMessageParameters;
889 890
890 mCurrentApp = ExternalAppHandler::EMAIL; 891 mCurrentApp = ExternalAppHandler::EMAIL;
891 mCurrentClient = mEmailClient; 892 mCurrentClient = mEmailClient;
892 893
893 updateClientWidgets(); 894 updateClientWidgets();
894 895
895 blockSignals( blocked ); 896 blockSignals( blocked );
896 897
897} 898}
898 899
899void KDEPIMConfigWidget::usrWriteConfig() 900void KDEPIMConfigWidget::usrWriteConfig()
900{ 901{
901 KPimGlobalPrefs* prefs = KPimGlobalPrefs::instance(); 902 KPimGlobalPrefs* prefs = KPimGlobalPrefs::instance();
902 903
903 saveEditFieldSettings(); 904 saveEditFieldSettings();
904 905
905 prefs->mBackupNumbers = mBackupNumbersSpin->value(); 906 prefs->mBackupNumbers = mBackupNumbersSpin->value();
906 prefs->mBackupDayCount = mBackupDayCountSpin->value(); 907 prefs->mBackupDayCount = mBackupDayCountSpin->value();
907 prefs->mBackupDatadir = mBackupUrl->url(); 908 prefs->mBackupDatadir = mBackupUrl->url();
908 909
909 prefs->mUserDateFormatShort = mUserDateFormatShort->text().replace( QRegExp(","), QString("K") ); 910 prefs->mUserDateFormatShort = mUserDateFormatShort->text().replace( QRegExp(","), QString("K") );
910 prefs->mUserDateFormatLong = mUserDateFormatLong->text().replace( QRegExp(","), QString("K") ); 911 prefs->mUserDateFormatLong = mUserDateFormatLong->text().replace( QRegExp(","), QString("K") );
911 912
912 prefs->mTimeZoneId = mTimeZoneCombo->currentText(); 913 prefs->mTimeZoneId = mTimeZoneCombo->currentText();
913 QDate date; 914 QDate date;
914 date = mStartDateSavingEdit->date(); 915 date = mStartDateSavingEdit->date();
915 int sub = 0; 916 int sub = 0;
916 if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 ) 917 if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 )
917 sub = 1; 918 sub = 1;
918 prefs->mDaylightsavingStart = date.dayOfYear()-sub; 919 prefs->mDaylightsavingStart = date.dayOfYear()-sub;
919 date = mEndDateSavingEdit->date(); 920 date = mEndDateSavingEdit->date();
920 if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 ) 921 if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 )
921 sub = 1; 922 sub = 1;
922 else 923 else
923 sub = 0; 924 sub = 0;
924 prefs->mDaylightsavingEnd = date.dayOfYear()-sub; 925 prefs->mDaylightsavingEnd = date.dayOfYear()-sub;
925 926
926 927
927 prefs->mEmailClient = mEmailClient; 928 prefs->mEmailClient = mEmailClient;
928 prefs->mEmailOtherChannel = mEmailOtherChannel; 929 prefs->mEmailOtherChannel = mEmailOtherChannel;
929 prefs->mEmailOtherMessage = mEmailOtherMessage; 930 prefs->mEmailOtherMessage = mEmailOtherMessage;
930 prefs->mEmailOtherMessageParameters = mEmailOtherMessageParameters; 931 prefs->mEmailOtherMessageParameters = mEmailOtherMessageParameters;
931 prefs->mEmailOtherMessage2 = mEmailOtherMessage2; 932 prefs->mEmailOtherMessage2 = mEmailOtherMessage2;
932 prefs->mEmailOtherMessageParameters2 = mEmailOtherMessageParameters2; 933 prefs->mEmailOtherMessageParameters2 = mEmailOtherMessageParameters2;
933 934
934 prefs->mPhoneClient = mPhoneClient; 935 prefs->mPhoneClient = mPhoneClient;
935 prefs->mPhoneOtherChannel = mPhoneOtherChannel; 936 prefs->mPhoneOtherChannel = mPhoneOtherChannel;
936 prefs->mPhoneOtherMessage = mPhoneOtherMessage; 937 prefs->mPhoneOtherMessage = mPhoneOtherMessage;
937 prefs->mPhoneOtherMessageParameters = mPhoneOtherMessageParameters; 938 prefs->mPhoneOtherMessageParameters = mPhoneOtherMessageParameters;
938 939
939 prefs->mFaxClient = mFaxClient; 940 prefs->mFaxClient = mFaxClient;
940 prefs->mFaxOtherChannel = mFaxOtherChannel; 941 prefs->mFaxOtherChannel = mFaxOtherChannel;
941 prefs->mFaxOtherMessage = mFaxOtherMessage; 942 prefs->mFaxOtherMessage = mFaxOtherMessage;
942 prefs->mFaxOtherMessageParameters = mFaxOtherMessageParameters; 943 prefs->mFaxOtherMessageParameters = mFaxOtherMessageParameters;
943 944
944 prefs->mSMSClient = mSMSClient; 945 prefs->mSMSClient = mSMSClient;
945 prefs->mSMSOtherChannel = mSMSOtherChannel; 946 prefs->mSMSOtherChannel = mSMSOtherChannel;
946 prefs->mSMSOtherMessage = mSMSOtherMessage; 947 prefs->mSMSOtherMessage = mSMSOtherMessage;
947 prefs->mSMSOtherMessageParameters = mSMSOtherMessageParameters; 948 prefs->mSMSOtherMessageParameters = mSMSOtherMessageParameters;
948 949
949 prefs->mPagerClient = mPagerClient; 950 prefs->mPagerClient = mPagerClient;
950 prefs->mPagerOtherChannel = mPagerOtherChannel; 951 prefs->mPagerOtherChannel = mPagerOtherChannel;
951 prefs->mPagerOtherMessage = mPagerOtherMessage; 952 prefs->mPagerOtherMessage = mPagerOtherMessage;
952 prefs->mPagerOtherMessageParameters = mPagerOtherMessageParameters; 953 prefs->mPagerOtherMessageParameters = mPagerOtherMessageParameters;
953 954
954 955
955 prefs->mSipClient = mSipClient; 956 prefs->mSipClient = mSipClient;
956 prefs->mSipOtherChannel = mSipOtherChannel; 957 prefs->mSipOtherChannel = mSipOtherChannel;
957 prefs->mSipOtherMessage = mSipOtherMessage; 958 prefs->mSipOtherMessage = mSipOtherMessage;
958 prefs->mSipOtherMessageParameters = mSipOtherMessageParameters; 959 prefs->mSipOtherMessageParameters = mSipOtherMessageParameters;
959 960
960 //release the cache that other views can access the changed values instantanious 961 //release the cache that other views can access the changed values instantanious
961 ExternalAppHandler::instance()->loadConfig(); 962 ExternalAppHandler::instance()->loadConfig();
962 KPimGlobalPrefs::instance()->setGlobalConfig(); 963 KPimGlobalPrefs::instance()->setGlobalConfig();
963} 964}
964 965
965 966
966void KDEPIMConfigWidget::setCombo(QComboBox *combo, const QString & text, 967void KDEPIMConfigWidget::setCombo(QComboBox *combo, const QString & text,
967 const QStringList *tags) 968 const QStringList *tags)
968{ 969{
969 if (tags) { 970 if (tags) {
970 int i = tags->findIndex(text); 971 int i = tags->findIndex(text);
971 if (i > 0) combo->setCurrentItem(i); 972 if (i > 0) combo->setCurrentItem(i);
972 } else { 973 } else {
973 for(int i=0;i<combo->count();++i) { 974 for(int i=0;i<combo->count();++i) {
974 if (combo->text(i) == text) { 975 if (combo->text(i) == text) {
975 combo->setCurrentItem(i); 976 combo->setCurrentItem(i);
976 break; 977 break;
977 } 978 }
978 } 979 }
979 } 980 }
980} 981}
981 982
982 983
983void KDEPIMConfigWidget::textChanged( const QString& text ) 984void KDEPIMConfigWidget::textChanged( const QString& text )
984{ 985{
985 emit changed( true ); 986 emit changed( true );
986} 987}
diff --git a/microkde/kcolorbutton.cpp b/microkde/kcolorbutton.cpp
index 96dc256..197bea2 100644
--- a/microkde/kcolorbutton.cpp
+++ b/microkde/kcolorbutton.cpp
@@ -1,47 +1,54 @@
1#include "kcolorbutton.h" 1#include "kcolorbutton.h"
2#include "kcolordialog.h" 2#include "kcolordialog.h"
3#include "qapplication.h" 3#include "qapplication.h"
4 4
5 5
6#include "qlayout.h" 6#include "qlayout.h"
7#ifdef DESKTOP_VERSION 7#ifdef DESKTOP_VERSION
8#include <qcolordialog.h> 8#include <qcolordialog.h>
9#endif 9#endif
10void KColorButton:: edit() 10void KColorButton:: edit()
11{ 11{
12 12
13#ifdef DESKTOP_VERSION 13#ifdef DESKTOP_VERSION
14 QColor col = QColorDialog::getColor ( mColor ); 14 QColor col = QColorDialog::getColor ( mColor );
15 if ( col.isValid () ) { 15 if ( col.isValid () ) {
16 mColor = col; 16 mColor = col;
17 setColor ( mColor ); 17 setColor ( mColor );
18 emit changed ( mColor ); 18 emit changed ( mColor );
19 emit changedID ( mColor, id );
19 } 20 }
20#else 21#else
21 KColorDialog* k = new KColorDialog( this ); 22 KColorDialog* k = new KColorDialog( this );
22 k->setColor( mColor ); 23 k->setColor( mColor );
23 int res = k->exec(); 24 int res = k->exec();
24 if ( res ) { 25 if ( res ) {
25 mColor = k->getColor(); 26 mColor = k->getColor();
26 setColor ( mColor ); 27 setColor ( mColor );
27 emit changed ( mColor ); 28 emit changed ( mColor );
29 emit changedID ( mColor, id );
28 } 30 }
29 delete k; 31 delete k;
30#endif 32#endif
31} 33}
32KColorButton::KColorButton( QWidget *p ):QPushButton( p ) 34KColorButton::KColorButton( QWidget *p ):QPushButton( p )
33{ 35{
34 int size = 24; 36 int size = 24;
35 if( QApplication::desktop()->width() < 480 || QApplication::desktop()->height() <= 320 ) 37 if( QApplication::desktop()->width() < 480 || QApplication::desktop()->height() <= 320 )
36 size = 18; 38 size = 18;
37 setFixedSize( size,size ); 39 setFixedSize( size,size );
40 int id = 0;
38 connect ( this, SIGNAL( clicked() ), this ,SLOT (edit() )); 41 connect ( this, SIGNAL( clicked() ), this ,SLOT (edit() ));
39 42
40} 43}
44void KColorButton::setID ( int i)
45{
46 id = i;
47}
41void KColorButton::setColor ( const QColor & c) 48void KColorButton::setColor ( const QColor & c)
42{ 49{
43 mColor = c; 50 mColor = c;
44 QPixmap pix ( height() - 4, width() - 4 ); 51 QPixmap pix ( height() - 4, width() - 4 );
45 pix.fill( c ); 52 pix.fill( c );
46 setPixmap ( pix ); 53 setPixmap ( pix );
47} 54}
diff --git a/microkde/kcolorbutton.h b/microkde/kcolorbutton.h
index 88b3774..983771b 100644
--- a/microkde/kcolorbutton.h
+++ b/microkde/kcolorbutton.h
@@ -1,26 +1,29 @@
1#ifndef MICROKDE_KCOLORBUTTON_H 1#ifndef MICROKDE_KCOLORBUTTON_H
2#define MICROKDE_KCOLORBUTTON_H 2#define MICROKDE_KCOLORBUTTON_H
3 3
4#include <qpushbutton.h> 4#include <qpushbutton.h>
5#include <qcolor.h> 5#include <qcolor.h>
6#include <kglobal.h> 6#include <kglobal.h>
7#include <qpixmap.h> 7#include <qpixmap.h>
8#include <qlabel.h> 8#include <qlabel.h>
9 9
10 10
11class KColorButton : public QPushButton 11class KColorButton : public QPushButton
12{ 12{
13Q_OBJECT 13Q_OBJECT
14public: 14public:
15 KColorButton( QWidget *p ); 15 KColorButton( QWidget *p );
16 void setColor ( const QColor &); 16 void setColor ( const QColor &);
17 void setID ( int i) ;
17 QColor color() const { return mColor ; } 18 QColor color() const { return mColor ; }
18 signals: 19 signals:
19 void changed(const QColor &); 20 void changed(const QColor &);
21 void changedID(const QColor &, int id);
20private slots: 22private slots:
21 void edit(); 23 void edit();
22 private: 24 private:
23 QColor mColor; 25 QColor mColor;
26 int id;
24}; 27};
25 28
26#endif 29#endif