summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp6
-rw-r--r--korganizer/kodialogmanager.cpp4
-rw-r--r--korganizer/koprefs.h11
-rw-r--r--korganizer/koviewmanager.cpp20
-rw-r--r--korganizer/mainwindow.cpp1
-rw-r--r--korganizer/searchdialog.cpp47
-rw-r--r--korganizer/searchdialog.h1
-rw-r--r--microkde/KDGanttMinimizeSplitter.cpp7
-rw-r--r--microkde/kapplication.cpp15
-rw-r--r--microkde/kapplication.h1
-rw-r--r--microkde/kresources/factory.cpp6
11 files changed, 100 insertions, 19 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 1e83236..beb19d9 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -818,2078 +818,2082 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b
818 case SYNC_PREF_LOCAL: 818 case SYNC_PREF_LOCAL:
819 if ( lastSync > remoteMod ) 819 if ( lastSync > remoteMod )
820 return 1; 820 return 1;
821 if ( lastSync > localMod ) 821 if ( lastSync > localMod )
822 return 2; 822 return 2;
823 return 1; 823 return 1;
824 break; 824 break;
825 case SYNC_PREF_REMOTE: 825 case SYNC_PREF_REMOTE:
826 if ( lastSync > remoteMod ) 826 if ( lastSync > remoteMod )
827 return 1; 827 return 1;
828 if ( lastSync > localMod ) 828 if ( lastSync > localMod )
829 return 2; 829 return 2;
830 return 2; 830 return 2;
831 break; 831 break;
832 case SYNC_PREF_NEWEST: 832 case SYNC_PREF_NEWEST:
833 if ( localMod > remoteMod ) 833 if ( localMod > remoteMod )
834 return 1; 834 return 1;
835 else 835 else
836 return 2; 836 return 2;
837 break; 837 break;
838 case SYNC_PREF_ASK: 838 case SYNC_PREF_ASK:
839 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 839 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
840 if ( lastSync > remoteMod ) 840 if ( lastSync > remoteMod )
841 return 1; 841 return 1;
842 if ( lastSync > localMod ) 842 if ( lastSync > localMod )
843 return 2; 843 return 2;
844 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 844 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
845 localIsNew = localMod >= remoteMod; 845 localIsNew = localMod >= remoteMod;
846 if ( localIsNew ) 846 if ( localIsNew )
847 getEventViewerDialog()->setColorMode( 1 ); 847 getEventViewerDialog()->setColorMode( 1 );
848 else 848 else
849 getEventViewerDialog()->setColorMode( 2 ); 849 getEventViewerDialog()->setColorMode( 2 );
850 getEventViewerDialog()->setIncidence(local); 850 getEventViewerDialog()->setIncidence(local);
851 if ( localIsNew ) 851 if ( localIsNew )
852 getEventViewerDialog()->setColorMode( 2 ); 852 getEventViewerDialog()->setColorMode( 2 );
853 else 853 else
854 getEventViewerDialog()->setColorMode( 1 ); 854 getEventViewerDialog()->setColorMode( 1 );
855 getEventViewerDialog()->addIncidence(remote); 855 getEventViewerDialog()->addIncidence(remote);
856 getEventViewerDialog()->setColorMode( 0 ); 856 getEventViewerDialog()->setColorMode( 0 );
857 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 857 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
858 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 858 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
859 getEventViewerDialog()->showMe(); 859 getEventViewerDialog()->showMe();
860 result = getEventViewerDialog()->executeS( localIsNew ); 860 result = getEventViewerDialog()->executeS( localIsNew );
861 return result; 861 return result;
862 862
863 break; 863 break;
864 case SYNC_PREF_FORCE_LOCAL: 864 case SYNC_PREF_FORCE_LOCAL:
865 return 1; 865 return 1;
866 break; 866 break;
867 case SYNC_PREF_FORCE_REMOTE: 867 case SYNC_PREF_FORCE_REMOTE:
868 return 2; 868 return 2;
869 break; 869 break;
870 870
871 default: 871 default:
872 // SYNC_PREF_TAKE_BOTH not implemented 872 // SYNC_PREF_TAKE_BOTH not implemented
873 break; 873 break;
874 } 874 }
875 return 0; 875 return 0;
876} 876}
877Event* CalendarView::getLastSyncEvent() 877Event* CalendarView::getLastSyncEvent()
878{ 878{
879 Event* lse; 879 Event* lse;
880 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 880 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
881 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 881 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
882 if (!lse) { 882 if (!lse) {
883 lse = new Event(); 883 lse = new Event();
884 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 884 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
885 QString sum = ""; 885 QString sum = "";
886 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 886 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
887 sum = "E: "; 887 sum = "E: ";
888 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 888 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
889 lse->setDtStart( mLastCalendarSync ); 889 lse->setDtStart( mLastCalendarSync );
890 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 890 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
891 lse->setCategories( i18n("SyncEvent") ); 891 lse->setCategories( i18n("SyncEvent") );
892 lse->setReadOnly( true ); 892 lse->setReadOnly( true );
893 mCalendar->addEvent( lse ); 893 mCalendar->addEvent( lse );
894 } 894 }
895 895
896 return lse; 896 return lse;
897 897
898} 898}
899 899
900// we check, if the to delete event has a id for a profile 900// we check, if the to delete event has a id for a profile
901// if yes, we set this id in the profile to delete 901// if yes, we set this id in the profile to delete
902void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 902void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
903{ 903{
904 if ( lastSync.count() == 0 ) { 904 if ( lastSync.count() == 0 ) {
905 //qDebug(" lastSync.count() == 0"); 905 //qDebug(" lastSync.count() == 0");
906 return; 906 return;
907 } 907 }
908 if ( toDelete->type() == "Journal" ) 908 if ( toDelete->type() == "Journal" )
909 return; 909 return;
910 910
911 Event* eve = lastSync.first(); 911 Event* eve = lastSync.first();
912 912
913 while ( eve ) { 913 while ( eve ) {
914 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 914 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
915 if ( !id.isEmpty() ) { 915 if ( !id.isEmpty() ) {
916 QString des = eve->description(); 916 QString des = eve->description();
917 QString pref = "e"; 917 QString pref = "e";
918 if ( toDelete->type() == "Todo" ) 918 if ( toDelete->type() == "Todo" )
919 pref = "t"; 919 pref = "t";
920 des += pref+ id + ","; 920 des += pref+ id + ",";
921 eve->setReadOnly( false ); 921 eve->setReadOnly( false );
922 eve->setDescription( des ); 922 eve->setDescription( des );
923 //qDebug("setdes %s ", des.latin1()); 923 //qDebug("setdes %s ", des.latin1());
924 eve->setReadOnly( true ); 924 eve->setReadOnly( true );
925 } 925 }
926 eve = lastSync.next(); 926 eve = lastSync.next();
927 } 927 }
928 928
929} 929}
930void CalendarView::checkExternalId( Incidence * inc ) 930void CalendarView::checkExternalId( Incidence * inc )
931{ 931{
932 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 932 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
933 checkExternSyncEvent( lastSync, inc ); 933 checkExternSyncEvent( lastSync, inc );
934 934
935} 935}
936bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 936bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
937{ 937{
938 bool syncOK = true; 938 bool syncOK = true;
939 int addedEvent = 0; 939 int addedEvent = 0;
940 int addedEventR = 0; 940 int addedEventR = 0;
941 int deletedEventR = 0; 941 int deletedEventR = 0;
942 int deletedEventL = 0; 942 int deletedEventL = 0;
943 int changedLocal = 0; 943 int changedLocal = 0;
944 int changedRemote = 0; 944 int changedRemote = 0;
945 int filteredIN = 0; 945 int filteredIN = 0;
946 int filteredOUT = 0; 946 int filteredOUT = 0;
947 //QPtrList<Event> el = local->rawEvents(); 947 //QPtrList<Event> el = local->rawEvents();
948 Event* eventR; 948 Event* eventR;
949 QString uid; 949 QString uid;
950 int take; 950 int take;
951 Event* eventL; 951 Event* eventL;
952 Event* eventRSync; 952 Event* eventRSync;
953 Event* eventLSync; 953 Event* eventLSync;
954 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 954 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
955 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 955 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
956 bool fullDateRange = false; 956 bool fullDateRange = false;
957 local->resetTempSyncStat(); 957 local->resetTempSyncStat();
958 mLastCalendarSync = QDateTime::currentDateTime(); 958 mLastCalendarSync = QDateTime::currentDateTime();
959 if ( mSyncManager->syncWithDesktop() ) { 959 if ( mSyncManager->syncWithDesktop() ) {
960 remote->resetPilotStat(1); 960 remote->resetPilotStat(1);
961 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 961 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
962 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 962 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
963 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 963 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
964 } else { 964 } else {
965 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 965 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
966 } 966 }
967 } 967 }
968 QDateTime modifiedCalendar = mLastCalendarSync; 968 QDateTime modifiedCalendar = mLastCalendarSync;
969 eventLSync = getLastSyncEvent(); 969 eventLSync = getLastSyncEvent();
970 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 970 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
971 if ( eventR ) { 971 if ( eventR ) {
972 eventRSync = (Event*) eventR->clone(); 972 eventRSync = (Event*) eventR->clone();
973 remote->deleteEvent(eventR ); 973 remote->deleteEvent(eventR );
974 974
975 } else { 975 } else {
976 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 976 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
977 eventRSync = (Event*)eventLSync->clone(); 977 eventRSync = (Event*)eventLSync->clone();
978 } else { 978 } else {
979 fullDateRange = true; 979 fullDateRange = true;
980 eventRSync = new Event(); 980 eventRSync = new Event();
981 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 981 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
982 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 982 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
983 eventRSync->setDtStart( mLastCalendarSync ); 983 eventRSync->setDtStart( mLastCalendarSync );
984 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 984 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
985 eventRSync->setCategories( i18n("SyncEvent") ); 985 eventRSync->setCategories( i18n("SyncEvent") );
986 } 986 }
987 } 987 }
988 if ( eventLSync->dtStart() == mLastCalendarSync ) 988 if ( eventLSync->dtStart() == mLastCalendarSync )
989 fullDateRange = true; 989 fullDateRange = true;
990 990
991 if ( ! fullDateRange ) { 991 if ( ! fullDateRange ) {
992 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 992 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
993 993
994 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 994 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
995 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 995 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
996 fullDateRange = true; 996 fullDateRange = true;
997 } 997 }
998 } 998 }
999 if ( mSyncManager->syncWithDesktop() ) { 999 if ( mSyncManager->syncWithDesktop() ) {
1000 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 1000 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
1001 } 1001 }
1002 if ( fullDateRange ) 1002 if ( fullDateRange )
1003 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 1003 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
1004 else 1004 else
1005 mLastCalendarSync = eventLSync->dtStart(); 1005 mLastCalendarSync = eventLSync->dtStart();
1006 // for resyncing if own file has changed 1006 // for resyncing if own file has changed
1007 if ( mCurrentSyncDevice == "deleteaftersync" ) { 1007 if ( mCurrentSyncDevice == "deleteaftersync" ) {
1008 mLastCalendarSync = loadedFileVersion; 1008 mLastCalendarSync = loadedFileVersion;
1009 //qDebug("setting mLastCalendarSync "); 1009 //qDebug("setting mLastCalendarSync ");
1010 } 1010 }
1011 //qDebug("*************************** "); 1011 //qDebug("*************************** ");
1012 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 1012 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
1013 QPtrList<Incidence> er = remote->rawIncidences(); 1013 QPtrList<Incidence> er = remote->rawIncidences();
1014 Incidence* inR = er.first(); 1014 Incidence* inR = er.first();
1015 Incidence* inL; 1015 Incidence* inL;
1016 QProgressBar bar( er.count(),0 ); 1016 QProgressBar bar( er.count(),0 );
1017 bar.setCaption (i18n("Syncing - close to abort!") ); 1017 bar.setCaption (i18n("Syncing - close to abort!") );
1018 1018
1019 // ************** setting up filter ************* 1019 // ************** setting up filter *************
1020 CalFilter *filterIN = 0; 1020 CalFilter *filterIN = 0;
1021 CalFilter *filterOUT = 0; 1021 CalFilter *filterOUT = 0;
1022 CalFilter *filter = mFilters.first(); 1022 CalFilter *filter = mFilters.first();
1023 while(filter) { 1023 while(filter) {
1024 if ( filter->name() == mSyncManager->mFilterInCal ) 1024 if ( filter->name() == mSyncManager->mFilterInCal )
1025 filterIN = filter; 1025 filterIN = filter;
1026 if ( filter->name() == mSyncManager->mFilterOutCal ) 1026 if ( filter->name() == mSyncManager->mFilterOutCal )
1027 filterOUT = filter; 1027 filterOUT = filter;
1028 filter = mFilters.next(); 1028 filter = mFilters.next();
1029 } 1029 }
1030 int w = 300; 1030 int w = 300;
1031 if ( QApplication::desktop()->width() < 320 ) 1031 if ( QApplication::desktop()->width() < 320 )
1032 w = 220; 1032 w = 220;
1033 int h = bar.sizeHint().height() ; 1033 int h = bar.sizeHint().height() ;
1034 int dw = QApplication::desktop()->width(); 1034 int dw = QApplication::desktop()->width();
1035 int dh = QApplication::desktop()->height(); 1035 int dh = QApplication::desktop()->height();
1036 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1036 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1037 bar.show(); 1037 bar.show();
1038 int modulo = (er.count()/10)+1; 1038 int modulo = (er.count()/10)+1;
1039 int incCounter = 0; 1039 int incCounter = 0;
1040 while ( inR ) { 1040 while ( inR ) {
1041 if ( ! bar.isVisible() ) 1041 if ( ! bar.isVisible() )
1042 return false; 1042 return false;
1043 if ( incCounter % modulo == 0 ) 1043 if ( incCounter % modulo == 0 )
1044 bar.setProgress( incCounter ); 1044 bar.setProgress( incCounter );
1045 ++incCounter; 1045 ++incCounter;
1046 uid = inR->uid(); 1046 uid = inR->uid();
1047 bool skipIncidence = false; 1047 bool skipIncidence = false;
1048 if ( uid.left(15) == QString("last-syncEvent-") ) 1048 if ( uid.left(15) == QString("last-syncEvent-") )
1049 skipIncidence = true; 1049 skipIncidence = true;
1050 QString idS; 1050 QString idS;
1051 qApp->processEvents(); 1051 qApp->processEvents();
1052 if ( !skipIncidence ) { 1052 if ( !skipIncidence ) {
1053 inL = local->incidence( uid ); 1053 inL = local->incidence( uid );
1054 if ( inL ) { // maybe conflict - same uid in both calendars 1054 if ( inL ) { // maybe conflict - same uid in both calendars
1055 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1055 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1056 //qDebug("take %d %s ", take, inL->summary().latin1()); 1056 //qDebug("take %d %s ", take, inL->summary().latin1());
1057 if ( take == 3 ) 1057 if ( take == 3 )
1058 return false; 1058 return false;
1059 if ( take == 1 ) {// take local ********************** 1059 if ( take == 1 ) {// take local **********************
1060 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1060 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1061 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1061 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1062 else 1062 else
1063 idS = inR->IDStr(); 1063 idS = inR->IDStr();
1064 remote->deleteIncidence( inR ); 1064 remote->deleteIncidence( inR );
1065 inR = inL->clone(); 1065 inR = inL->clone();
1066 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1066 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1067 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1067 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1068 inR->setIDStr( idS ); 1068 inR->setIDStr( idS );
1069 remote->addIncidence( inR ); 1069 remote->addIncidence( inR );
1070 if ( mSyncManager->syncWithDesktop() ) 1070 if ( mSyncManager->syncWithDesktop() )
1071 inR->setPilotId( 2 ); 1071 inR->setPilotId( 2 );
1072 ++changedRemote; 1072 ++changedRemote;
1073 } else {// take remote ********************** 1073 } else {// take remote **********************
1074 idS = inL->IDStr(); 1074 idS = inL->IDStr();
1075 int pid = inL->pilotId(); 1075 int pid = inL->pilotId();
1076 local->deleteIncidence( inL ); 1076 local->deleteIncidence( inL );
1077 inL = inR->clone(); 1077 inL = inR->clone();
1078 if ( mSyncManager->syncWithDesktop() ) 1078 if ( mSyncManager->syncWithDesktop() )
1079 inL->setPilotId( pid ); 1079 inL->setPilotId( pid );
1080 inL->setIDStr( idS ); 1080 inL->setIDStr( idS );
1081 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1081 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1082 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1082 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1083 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1083 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1084 } 1084 }
1085 local->addIncidence( inL ); 1085 local->addIncidence( inL );
1086 ++changedLocal; 1086 ++changedLocal;
1087 } 1087 }
1088 } 1088 }
1089 } else { // no conflict ********** add or delete remote 1089 } else { // no conflict ********** add or delete remote
1090 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ 1090 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1091 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1091 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1092 QString des = eventLSync->description(); 1092 QString des = eventLSync->description();
1093 QString pref = "e"; 1093 QString pref = "e";
1094 if ( inR->type() == "Todo" ) 1094 if ( inR->type() == "Todo" )
1095 pref = "t"; 1095 pref = "t";
1096 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1096 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1097 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1097 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1098 //remote->deleteIncidence( inR ); 1098 //remote->deleteIncidence( inR );
1099 ++deletedEventR; 1099 ++deletedEventR;
1100 } else { 1100 } else {
1101 inR->setLastModified( modifiedCalendar ); 1101 inR->setLastModified( modifiedCalendar );
1102 inL = inR->clone(); 1102 inL = inR->clone();
1103 inL->setIDStr( ":" ); 1103 inL->setIDStr( ":" );
1104 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1104 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1105 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1105 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1106 local->addIncidence( inL ); 1106 local->addIncidence( inL );
1107 ++addedEvent; 1107 ++addedEvent;
1108 1108
1109 } 1109 }
1110 } else { 1110 } else {
1111 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1111 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1112 inR->setLastModified( modifiedCalendar ); 1112 inR->setLastModified( modifiedCalendar );
1113 inL = inR->clone(); 1113 inL = inR->clone();
1114 inL->setIDStr( ":" ); 1114 inL->setIDStr( ":" );
1115 local->addIncidence( inL ); 1115 local->addIncidence( inL );
1116 ++addedEvent; 1116 ++addedEvent;
1117 1117
1118 } else { 1118 } else {
1119 checkExternSyncEvent(eventRSyncSharp, inR); 1119 checkExternSyncEvent(eventRSyncSharp, inR);
1120 remote->deleteIncidence( inR ); 1120 remote->deleteIncidence( inR );
1121 ++deletedEventR; 1121 ++deletedEventR;
1122 } 1122 }
1123 } 1123 }
1124 } else { 1124 } else {
1125 ++filteredIN; 1125 ++filteredIN;
1126 } 1126 }
1127 } 1127 }
1128 } 1128 }
1129 inR = er.next(); 1129 inR = er.next();
1130 } 1130 }
1131 QPtrList<Incidence> el = local->rawIncidences(); 1131 QPtrList<Incidence> el = local->rawIncidences();
1132 inL = el.first(); 1132 inL = el.first();
1133 modulo = (el.count()/10)+1; 1133 modulo = (el.count()/10)+1;
1134 bar.setCaption (i18n("Add / remove events") ); 1134 bar.setCaption (i18n("Add / remove events") );
1135 bar.setTotalSteps ( el.count() ) ; 1135 bar.setTotalSteps ( el.count() ) ;
1136 bar.show(); 1136 bar.show();
1137 incCounter = 0; 1137 incCounter = 0;
1138 1138
1139 while ( inL ) { 1139 while ( inL ) {
1140 1140
1141 qApp->processEvents(); 1141 qApp->processEvents();
1142 if ( ! bar.isVisible() ) 1142 if ( ! bar.isVisible() )
1143 return false; 1143 return false;
1144 if ( incCounter % modulo == 0 ) 1144 if ( incCounter % modulo == 0 )
1145 bar.setProgress( incCounter ); 1145 bar.setProgress( incCounter );
1146 ++incCounter; 1146 ++incCounter;
1147 uid = inL->uid(); 1147 uid = inL->uid();
1148 bool skipIncidence = false; 1148 bool skipIncidence = false;
1149 if ( uid.left(15) == QString("last-syncEvent-") ) 1149 if ( uid.left(15) == QString("last-syncEvent-") )
1150 skipIncidence = true; 1150 skipIncidence = true;
1151 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1151 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1152 skipIncidence = true; 1152 skipIncidence = true;
1153 if ( !skipIncidence ) { 1153 if ( !skipIncidence ) {
1154 inR = remote->incidence( uid ); 1154 inR = remote->incidence( uid );
1155 if ( ! inR ) { 1155 if ( ! inR ) {
1156 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ 1156 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1157 // no conflict ********** add or delete local 1157 // no conflict ********** add or delete local
1158 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1158 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1159 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1159 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1160 checkExternSyncEvent(eventLSyncSharp, inL); 1160 checkExternSyncEvent(eventLSyncSharp, inL);
1161 local->deleteIncidence( inL ); 1161 local->deleteIncidence( inL );
1162 ++deletedEventL; 1162 ++deletedEventL;
1163 } else { 1163 } else {
1164 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1164 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1165 inL->removeID(mCurrentSyncDevice ); 1165 inL->removeID(mCurrentSyncDevice );
1166 ++addedEventR; 1166 ++addedEventR;
1167 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1167 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1168 inL->setLastModified( modifiedCalendar ); 1168 inL->setLastModified( modifiedCalendar );
1169 inR = inL->clone(); 1169 inR = inL->clone();
1170 inR->setIDStr( ":" ); 1170 inR->setIDStr( ":" );
1171 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1171 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1172 remote->addIncidence( inR ); 1172 remote->addIncidence( inR );
1173 } 1173 }
1174 } 1174 }
1175 } else { 1175 } else {
1176 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1176 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1177 checkExternSyncEvent(eventLSyncSharp, inL); 1177 checkExternSyncEvent(eventLSyncSharp, inL);
1178 local->deleteIncidence( inL ); 1178 local->deleteIncidence( inL );
1179 ++deletedEventL; 1179 ++deletedEventL;
1180 } else { 1180 } else {
1181 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1181 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1182 ++addedEventR; 1182 ++addedEventR;
1183 inL->setLastModified( modifiedCalendar ); 1183 inL->setLastModified( modifiedCalendar );
1184 inR = inL->clone(); 1184 inR = inL->clone();
1185 inR->setIDStr( ":" ); 1185 inR->setIDStr( ":" );
1186 remote->addIncidence( inR ); 1186 remote->addIncidence( inR );
1187 } 1187 }
1188 } 1188 }
1189 } 1189 }
1190 } else { 1190 } else {
1191 ++filteredOUT; 1191 ++filteredOUT;
1192 } 1192 }
1193 } 1193 }
1194 } 1194 }
1195 inL = el.next(); 1195 inL = el.next();
1196 } 1196 }
1197 int delFut = 0; 1197 int delFut = 0;
1198 int remRem = 0; 1198 int remRem = 0;
1199 if ( mSyncManager->mWriteBackInFuture ) { 1199 if ( mSyncManager->mWriteBackInFuture ) {
1200 er = remote->rawIncidences(); 1200 er = remote->rawIncidences();
1201 remRem = er.count(); 1201 remRem = er.count();
1202 inR = er.first(); 1202 inR = er.first();
1203 QDateTime dt; 1203 QDateTime dt;
1204 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1204 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1205 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1205 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1206 while ( inR ) { 1206 while ( inR ) {
1207 if ( inR->type() == "Todo" ) { 1207 if ( inR->type() == "Todo" ) {
1208 Todo * t = (Todo*)inR; 1208 Todo * t = (Todo*)inR;
1209 if ( t->hasDueDate() ) 1209 if ( t->hasDueDate() )
1210 dt = t->dtDue(); 1210 dt = t->dtDue();
1211 else 1211 else
1212 dt = cur.addSecs( 62 ); 1212 dt = cur.addSecs( 62 );
1213 } 1213 }
1214 else if (inR->type() == "Event" ) { 1214 else if (inR->type() == "Event" ) {
1215 bool ok; 1215 bool ok;
1216 dt = inR->getNextOccurence( cur, &ok ); 1216 dt = inR->getNextOccurence( cur, &ok );
1217 if ( !ok ) 1217 if ( !ok )
1218 dt = cur.addSecs( -62 ); 1218 dt = cur.addSecs( -62 );
1219 } 1219 }
1220 else 1220 else
1221 dt = inR->dtStart(); 1221 dt = inR->dtStart();
1222 if ( dt < cur || dt > end ) { 1222 if ( dt < cur || dt > end ) {
1223 remote->deleteIncidence( inR ); 1223 remote->deleteIncidence( inR );
1224 ++delFut; 1224 ++delFut;
1225 } 1225 }
1226 inR = er.next(); 1226 inR = er.next();
1227 } 1227 }
1228 } 1228 }
1229 bar.hide(); 1229 bar.hide();
1230 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1230 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1231 eventLSync->setReadOnly( false ); 1231 eventLSync->setReadOnly( false );
1232 eventLSync->setDtStart( mLastCalendarSync ); 1232 eventLSync->setDtStart( mLastCalendarSync );
1233 eventRSync->setDtStart( mLastCalendarSync ); 1233 eventRSync->setDtStart( mLastCalendarSync );
1234 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1234 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1235 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1235 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1236 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1236 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1237 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1237 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1238 eventLSync->setReadOnly( true ); 1238 eventLSync->setReadOnly( true );
1239 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); 1239 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL );
1240 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1240 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1241 remote->addEvent( eventRSync ); 1241 remote->addEvent( eventRSync );
1242 else 1242 else
1243 delete eventRSync; 1243 delete eventRSync;
1244 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); 1244 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() );
1245 QString mes; 1245 QString mes;
1246 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 ); 1246 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 );
1247 QString delmess; 1247 QString delmess;
1248 if ( delFut ) { 1248 if ( delFut ) {
1249 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); 1249 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);
1250 mes += delmess; 1250 mes += delmess;
1251 } 1251 }
1252 mes = i18n("Local calendar changed!\n") +mes; 1252 mes = i18n("Local calendar changed!\n") +mes;
1253 mCalendar->checkAlarmForIncidence( 0, true ); 1253 mCalendar->checkAlarmForIncidence( 0, true );
1254 qDebug( mes ); 1254 qDebug( mes );
1255 if ( mSyncManager->mShowSyncSummary ) { 1255 if ( mSyncManager->mShowSyncSummary ) {
1256 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1256 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1257 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1257 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1258 qDebug("KO: WB cancelled "); 1258 qDebug("KO: WB cancelled ");
1259 mSyncManager->mWriteBackFile = false; 1259 mSyncManager->mWriteBackFile = false;
1260 return syncOK; 1260 return syncOK;
1261 } 1261 }
1262 } 1262 }
1263 return syncOK; 1263 return syncOK;
1264} 1264}
1265 1265
1266void CalendarView::setSyncDevice( QString s ) 1266void CalendarView::setSyncDevice( QString s )
1267{ 1267{
1268 mCurrentSyncDevice= s; 1268 mCurrentSyncDevice= s;
1269} 1269}
1270void CalendarView::setSyncName( QString s ) 1270void CalendarView::setSyncName( QString s )
1271{ 1271{
1272 mCurrentSyncName= s; 1272 mCurrentSyncName= s;
1273} 1273}
1274bool CalendarView::syncCalendar(QString filename, int mode) 1274bool CalendarView::syncCalendar(QString filename, int mode)
1275{ 1275{
1276 //qDebug("syncCalendar %s ", filename.latin1()); 1276 //qDebug("syncCalendar %s ", filename.latin1());
1277 mGlobalSyncMode = SYNC_MODE_NORMAL; 1277 mGlobalSyncMode = SYNC_MODE_NORMAL;
1278 CalendarLocal* calendar = new CalendarLocal(); 1278 CalendarLocal* calendar = new CalendarLocal();
1279 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1279 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1280 FileStorage* storage = new FileStorage( calendar ); 1280 FileStorage* storage = new FileStorage( calendar );
1281 bool syncOK = false; 1281 bool syncOK = false;
1282 storage->setFileName( filename ); 1282 storage->setFileName( filename );
1283 // qDebug("loading ... "); 1283 // qDebug("loading ... ");
1284 if ( storage->load() ) { 1284 if ( storage->load() ) {
1285 getEventViewerDialog()->setSyncMode( true ); 1285 getEventViewerDialog()->setSyncMode( true );
1286 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1286 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1287 getEventViewerDialog()->setSyncMode( false ); 1287 getEventViewerDialog()->setSyncMode( false );
1288 if ( syncOK ) { 1288 if ( syncOK ) {
1289 if ( mSyncManager->mWriteBackFile ) 1289 if ( mSyncManager->mWriteBackFile )
1290 { 1290 {
1291 storage->setSaveFormat( new ICalFormat() ); 1291 storage->setSaveFormat( new ICalFormat() );
1292 storage->save(); 1292 storage->save();
1293 } 1293 }
1294 } 1294 }
1295 setModified( true ); 1295 setModified( true );
1296 } 1296 }
1297 delete storage; 1297 delete storage;
1298 delete calendar; 1298 delete calendar;
1299 if ( syncOK ) 1299 if ( syncOK )
1300 updateView(); 1300 updateView();
1301 return syncOK; 1301 return syncOK;
1302} 1302}
1303 1303
1304void CalendarView::syncExternal( int mode ) 1304void CalendarView::syncExternal( int mode )
1305{ 1305{
1306 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1306 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1307 1307
1308 qApp->processEvents(); 1308 qApp->processEvents();
1309 CalendarLocal* calendar = new CalendarLocal(); 1309 CalendarLocal* calendar = new CalendarLocal();
1310 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1310 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1311 bool syncOK = false; 1311 bool syncOK = false;
1312 bool loadSuccess = false; 1312 bool loadSuccess = false;
1313 PhoneFormat* phoneFormat = 0; 1313 PhoneFormat* phoneFormat = 0;
1314 emit tempDisableBR(true); 1314 emit tempDisableBR(true);
1315#ifndef DESKTOP_VERSION 1315#ifndef DESKTOP_VERSION
1316 SharpFormat* sharpFormat = 0; 1316 SharpFormat* sharpFormat = 0;
1317 if ( mode == 0 ) { // sharp 1317 if ( mode == 0 ) { // sharp
1318 sharpFormat = new SharpFormat () ; 1318 sharpFormat = new SharpFormat () ;
1319 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1319 loadSuccess = sharpFormat->load( calendar, mCalendar );
1320 1320
1321 } else 1321 } else
1322#endif 1322#endif
1323 if ( mode == 1 ) { // phone 1323 if ( mode == 1 ) { // phone
1324 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1324 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1325 mSyncManager->mPhoneDevice, 1325 mSyncManager->mPhoneDevice,
1326 mSyncManager->mPhoneConnection, 1326 mSyncManager->mPhoneConnection,
1327 mSyncManager->mPhoneModel); 1327 mSyncManager->mPhoneModel);
1328 loadSuccess = phoneFormat->load( calendar,mCalendar); 1328 loadSuccess = phoneFormat->load( calendar,mCalendar);
1329 1329
1330 } else { 1330 } else {
1331 emit tempDisableBR(false); 1331 emit tempDisableBR(false);
1332 return; 1332 return;
1333 } 1333 }
1334 if ( loadSuccess ) { 1334 if ( loadSuccess ) {
1335 getEventViewerDialog()->setSyncMode( true ); 1335 getEventViewerDialog()->setSyncMode( true );
1336 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1336 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1337 getEventViewerDialog()->setSyncMode( false ); 1337 getEventViewerDialog()->setSyncMode( false );
1338 qApp->processEvents(); 1338 qApp->processEvents();
1339 if ( syncOK ) { 1339 if ( syncOK ) {
1340 if ( mSyncManager->mWriteBackFile ) 1340 if ( mSyncManager->mWriteBackFile )
1341 { 1341 {
1342 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1342 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1343 Incidence* inc = iL.first(); 1343 Incidence* inc = iL.first();
1344 if ( phoneFormat ) { 1344 if ( phoneFormat ) {
1345 while ( inc ) { 1345 while ( inc ) {
1346 inc->removeID(mCurrentSyncDevice); 1346 inc->removeID(mCurrentSyncDevice);
1347 inc = iL.next(); 1347 inc = iL.next();
1348 } 1348 }
1349 } 1349 }
1350#ifndef DESKTOP_VERSION 1350#ifndef DESKTOP_VERSION
1351 if ( sharpFormat ) 1351 if ( sharpFormat )
1352 sharpFormat->save(calendar); 1352 sharpFormat->save(calendar);
1353#endif 1353#endif
1354 if ( phoneFormat ) 1354 if ( phoneFormat )
1355 phoneFormat->save(calendar); 1355 phoneFormat->save(calendar);
1356 iL = calendar->rawIncidences(); 1356 iL = calendar->rawIncidences();
1357 inc = iL.first(); 1357 inc = iL.first();
1358 Incidence* loc; 1358 Incidence* loc;
1359 while ( inc ) { 1359 while ( inc ) {
1360 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1360 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1361 loc = mCalendar->incidence(inc->uid() ); 1361 loc = mCalendar->incidence(inc->uid() );
1362 if ( loc ) { 1362 if ( loc ) {
1363 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1363 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1364 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1364 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1365 } 1365 }
1366 } 1366 }
1367 inc = iL.next(); 1367 inc = iL.next();
1368 } 1368 }
1369 Incidence* lse = getLastSyncEvent(); 1369 Incidence* lse = getLastSyncEvent();
1370 if ( lse ) { 1370 if ( lse ) {
1371 lse->setReadOnly( false ); 1371 lse->setReadOnly( false );
1372 lse->setDescription( "" ); 1372 lse->setDescription( "" );
1373 lse->setReadOnly( true ); 1373 lse->setReadOnly( true );
1374 } 1374 }
1375 } 1375 }
1376 } else { 1376 } else {
1377 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 1377 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
1378 } 1378 }
1379 setModified( true ); 1379 setModified( true );
1380 } else { 1380 } else {
1381 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1381 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1382 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1382 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1383 question, i18n("Ok")) ; 1383 question, i18n("Ok")) ;
1384 1384
1385 } 1385 }
1386 delete calendar; 1386 delete calendar;
1387 updateView(); 1387 updateView();
1388 emit tempDisableBR(false); 1388 emit tempDisableBR(false);
1389 return ;//syncOK; 1389 return ;//syncOK;
1390 1390
1391} 1391}
1392 1392
1393bool CalendarView::importBday() 1393bool CalendarView::importBday()
1394{ 1394{
1395#ifndef KORG_NOKABC 1395#ifndef KORG_NOKABC
1396 1396
1397#ifdef DESKTOP_VERSION 1397#ifdef DESKTOP_VERSION
1398 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1398 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1399 KABC::AddressBook::Iterator it; 1399 KABC::AddressBook::Iterator it;
1400 int count = 0; 1400 int count = 0;
1401 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1401 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1402 ++count; 1402 ++count;
1403 } 1403 }
1404 QProgressBar bar(count,0 ); 1404 QProgressBar bar(count,0 );
1405 int w = 300; 1405 int w = 300;
1406 if ( QApplication::desktop()->width() < 320 ) 1406 if ( QApplication::desktop()->width() < 320 )
1407 w = 220; 1407 w = 220;
1408 int h = bar.sizeHint().height() ; 1408 int h = bar.sizeHint().height() ;
1409 int dw = QApplication::desktop()->width(); 1409 int dw = QApplication::desktop()->width();
1410 int dh = QApplication::desktop()->height(); 1410 int dh = QApplication::desktop()->height();
1411 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1411 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1412 bar.show(); 1412 bar.show();
1413 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1413 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1414 qApp->processEvents(); 1414 qApp->processEvents();
1415 count = 0; 1415 count = 0;
1416 int addCount = 0; 1416 int addCount = 0;
1417 KCal::Attendee* a = 0; 1417 KCal::Attendee* a = 0;
1418 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1418 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1419 if ( ! bar.isVisible() ) 1419 if ( ! bar.isVisible() )
1420 return false; 1420 return false;
1421 bar.setProgress( count++ ); 1421 bar.setProgress( count++ );
1422 qApp->processEvents(); 1422 qApp->processEvents();
1423 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1423 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1424 if ( (*it).birthday().date().isValid() ){ 1424 if ( (*it).birthday().date().isValid() ){
1425 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1425 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1426 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1426 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1427 ++addCount; 1427 ++addCount;
1428 } 1428 }
1429 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1429 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1430 if ( anni.isValid() ){ 1430 if ( anni.isValid() ){
1431 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1431 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1432 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1432 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1433 ++addCount; 1433 ++addCount;
1434 } 1434 }
1435 } 1435 }
1436 updateView(); 1436 updateView();
1437 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1437 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1438#else //DESKTOP_VERSION 1438#else //DESKTOP_VERSION
1439 1439
1440 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1440 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1441 // the result should now arrive through method insertBirthdays 1441 // the result should now arrive through method insertBirthdays
1442 1442
1443#endif //DESKTOP_VERSION 1443#endif //DESKTOP_VERSION
1444 1444
1445#endif //KORG_NOKABC 1445#endif //KORG_NOKABC
1446 1446
1447 1447
1448 return true; 1448 return true;
1449} 1449}
1450 1450
1451// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1451// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1452void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1452void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1453 const QStringList& anniversaryList, const QStringList& realNameList, 1453 const QStringList& anniversaryList, const QStringList& realNameList,
1454 const QStringList& emailList, const QStringList& assembledNameList, 1454 const QStringList& emailList, const QStringList& assembledNameList,
1455 const QStringList& uidList) 1455 const QStringList& uidList)
1456{ 1456{
1457 //qDebug("KO::CalendarView::insertBirthdays"); 1457 //qDebug("KO::CalendarView::insertBirthdays");
1458 if (uid == this->name()) 1458 if (uid == this->name())
1459 { 1459 {
1460 int count = birthdayList.count(); 1460 int count = birthdayList.count();
1461 int addCount = 0; 1461 int addCount = 0;
1462 KCal::Attendee* a = 0; 1462 KCal::Attendee* a = 0;
1463 1463
1464 //qDebug("CalView 1 %i", count); 1464 //qDebug("CalView 1 %i", count);
1465 1465
1466 QProgressBar bar(count,0 ); 1466 QProgressBar bar(count,0 );
1467 int w = 300; 1467 int w = 300;
1468 if ( QApplication::desktop()->width() < 320 ) 1468 if ( QApplication::desktop()->width() < 320 )
1469 w = 220; 1469 w = 220;
1470 int h = bar.sizeHint().height() ; 1470 int h = bar.sizeHint().height() ;
1471 int dw = QApplication::desktop()->width(); 1471 int dw = QApplication::desktop()->width();
1472 int dh = QApplication::desktop()->height(); 1472 int dh = QApplication::desktop()->height();
1473 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1473 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1474 bar.show(); 1474 bar.show();
1475 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1475 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1476 qApp->processEvents(); 1476 qApp->processEvents();
1477 1477
1478 QDate birthday; 1478 QDate birthday;
1479 QDate anniversary; 1479 QDate anniversary;
1480 QString realName; 1480 QString realName;
1481 QString email; 1481 QString email;
1482 QString assembledName; 1482 QString assembledName;
1483 QString uid; 1483 QString uid;
1484 bool ok = true; 1484 bool ok = true;
1485 for ( int i = 0; i < count; i++) 1485 for ( int i = 0; i < count; i++)
1486 { 1486 {
1487 if ( ! bar.isVisible() ) 1487 if ( ! bar.isVisible() )
1488 return; 1488 return;
1489 bar.setProgress( i ); 1489 bar.setProgress( i );
1490 qApp->processEvents(); 1490 qApp->processEvents();
1491 1491
1492 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1492 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1493 if (!ok) { 1493 if (!ok) {
1494 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1494 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1495 } 1495 }
1496 1496
1497 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1497 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1498 if (!ok) { 1498 if (!ok) {
1499 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1499 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1500 } 1500 }
1501 realName = realNameList[i]; 1501 realName = realNameList[i];
1502 email = emailList[i]; 1502 email = emailList[i];
1503 assembledName = assembledNameList[i]; 1503 assembledName = assembledNameList[i];
1504 uid = uidList[i]; 1504 uid = uidList[i];
1505 //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() ); 1505 //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() );
1506 1506
1507 if ( birthday.isValid() ){ 1507 if ( birthday.isValid() ){
1508 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1508 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1509 KCal::Attendee::ReqParticipant,uid) ; 1509 KCal::Attendee::ReqParticipant,uid) ;
1510 if ( addAnniversary( birthday, assembledName, a, true ) ) 1510 if ( addAnniversary( birthday, assembledName, a, true ) )
1511 ++addCount; 1511 ++addCount;
1512 } 1512 }
1513 1513
1514 if ( anniversary.isValid() ){ 1514 if ( anniversary.isValid() ){
1515 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1515 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1516 KCal::Attendee::ReqParticipant,uid) ; 1516 KCal::Attendee::ReqParticipant,uid) ;
1517 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1517 if ( addAnniversary( anniversary, assembledName, a, false ) )
1518 ++addCount; 1518 ++addCount;
1519 } 1519 }
1520 } 1520 }
1521 1521
1522 updateView(); 1522 updateView();
1523 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1523 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1524 1524
1525 } 1525 }
1526 1526
1527} 1527}
1528 1528
1529 1529
1530 1530
1531bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1531bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1532{ 1532{
1533 //qDebug("addAnni "); 1533 //qDebug("addAnni ");
1534 Event * ev = new Event(); 1534 Event * ev = new Event();
1535 ev->setOrganizer(KOPrefs::instance()->email()); 1535 ev->setOrganizer(KOPrefs::instance()->email());
1536 if ( a ) { 1536 if ( a ) {
1537 ev->addAttendee( a ); 1537 ev->addAttendee( a );
1538 } 1538 }
1539 QString kind; 1539 QString kind;
1540 if ( birthday ) { 1540 if ( birthday ) {
1541 kind = i18n( "Birthday" ); 1541 kind = i18n( "Birthday" );
1542 ev->setSummary( name + " (" + QString::number(date.year()) +")"); 1542 ev->setSummary( name + " (" + QString::number(date.year()) +")");
1543 } 1543 }
1544 else { 1544 else {
1545 kind = i18n( "Anniversary" ); 1545 kind = i18n( "Anniversary" );
1546 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); 1546 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
1547 } 1547 }
1548 ev->setCategories( kind ); 1548 ev->setCategories( kind );
1549 ev->setDtStart( QDateTime(date) ); 1549 ev->setDtStart( QDateTime(date) );
1550 ev->setDtEnd( QDateTime(date) ); 1550 ev->setDtEnd( QDateTime(date) );
1551 ev->setFloats( true ); 1551 ev->setFloats( true );
1552 Recurrence * rec = ev->recurrence(); 1552 Recurrence * rec = ev->recurrence();
1553 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1553 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1554 rec->addYearlyNum( date.month() ); 1554 rec->addYearlyNum( date.month() );
1555 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1555 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1556 delete ev; 1556 delete ev;
1557 return false; 1557 return false;
1558 } 1558 }
1559 return true; 1559 return true;
1560 1560
1561} 1561}
1562bool CalendarView::importQtopia( const QString &categories, 1562bool CalendarView::importQtopia( const QString &categories,
1563 const QString &datebook, 1563 const QString &datebook,
1564 const QString &todolist ) 1564 const QString &todolist )
1565{ 1565{
1566 1566
1567 QtopiaFormat qtopiaFormat; 1567 QtopiaFormat qtopiaFormat;
1568 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1568 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1569 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1569 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1570 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1570 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1571 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1571 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1572 1572
1573 updateView(); 1573 updateView();
1574 return true; 1574 return true;
1575 1575
1576#if 0 1576#if 0
1577 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1577 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1578 mCurrentSyncDevice = "qtopia-XML"; 1578 mCurrentSyncDevice = "qtopia-XML";
1579 if ( mSyncManager->mAskForPreferences ) 1579 if ( mSyncManager->mAskForPreferences )
1580 edit_sync_options(); 1580 edit_sync_options();
1581 qApp->processEvents(); 1581 qApp->processEvents();
1582 CalendarLocal* calendar = new CalendarLocal(); 1582 CalendarLocal* calendar = new CalendarLocal();
1583 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1583 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1584 bool syncOK = false; 1584 bool syncOK = false;
1585 QtopiaFormat qtopiaFormat; 1585 QtopiaFormat qtopiaFormat;
1586 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1586 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1587 bool loadOk = true; 1587 bool loadOk = true;
1588 if ( !categories.isEmpty() ) 1588 if ( !categories.isEmpty() )
1589 loadOk = qtopiaFormat.load( calendar, categories ); 1589 loadOk = qtopiaFormat.load( calendar, categories );
1590 if ( loadOk && !datebook.isEmpty() ) 1590 if ( loadOk && !datebook.isEmpty() )
1591 loadOk = qtopiaFormat.load( calendar, datebook ); 1591 loadOk = qtopiaFormat.load( calendar, datebook );
1592 if ( loadOk && !todolist.isEmpty() ) 1592 if ( loadOk && !todolist.isEmpty() )
1593 loadOk = qtopiaFormat.load( calendar, todolist ); 1593 loadOk = qtopiaFormat.load( calendar, todolist );
1594 1594
1595 if ( loadOk ) { 1595 if ( loadOk ) {
1596 getEventViewerDialog()->setSyncMode( true ); 1596 getEventViewerDialog()->setSyncMode( true );
1597 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1597 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1598 getEventViewerDialog()->setSyncMode( false ); 1598 getEventViewerDialog()->setSyncMode( false );
1599 qApp->processEvents(); 1599 qApp->processEvents();
1600 if ( syncOK ) { 1600 if ( syncOK ) {
1601 if ( mSyncManager->mWriteBackFile ) 1601 if ( mSyncManager->mWriteBackFile )
1602 { 1602 {
1603 // write back XML file 1603 // write back XML file
1604 1604
1605 } 1605 }
1606 setModified( true ); 1606 setModified( true );
1607 } 1607 }
1608 } else { 1608 } else {
1609 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1609 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1610 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1610 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1611 question, i18n("Ok")) ; 1611 question, i18n("Ok")) ;
1612 } 1612 }
1613 delete calendar; 1613 delete calendar;
1614 updateView(); 1614 updateView();
1615 return syncOK; 1615 return syncOK;
1616 1616
1617 1617
1618#endif 1618#endif
1619 1619
1620} 1620}
1621 1621
1622void CalendarView::setSyncEventsReadOnly() 1622void CalendarView::setSyncEventsReadOnly()
1623{ 1623{
1624 Event * ev; 1624 Event * ev;
1625 QPtrList<Event> eL = mCalendar->rawEvents(); 1625 QPtrList<Event> eL = mCalendar->rawEvents();
1626 ev = eL.first(); 1626 ev = eL.first();
1627 while ( ev ) { 1627 while ( ev ) {
1628 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1628 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1629 ev->setReadOnly( true ); 1629 ev->setReadOnly( true );
1630 ev = eL.next(); 1630 ev = eL.next();
1631 } 1631 }
1632} 1632}
1633bool CalendarView::openCalendar(QString filename, bool merge) 1633bool CalendarView::openCalendar(QString filename, bool merge)
1634{ 1634{
1635 1635
1636 if (filename.isEmpty()) { 1636 if (filename.isEmpty()) {
1637 return false; 1637 return false;
1638 } 1638 }
1639 1639
1640 if (!QFile::exists(filename)) { 1640 if (!QFile::exists(filename)) {
1641 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1641 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1642 return false; 1642 return false;
1643 } 1643 }
1644 1644
1645 globalFlagBlockAgenda = 1; 1645 globalFlagBlockAgenda = 1;
1646 if (!merge) mCalendar->close(); 1646 if (!merge) mCalendar->close();
1647 1647
1648 mStorage->setFileName( filename ); 1648 mStorage->setFileName( filename );
1649 1649
1650 if ( mStorage->load() ) { 1650 if ( mStorage->load() ) {
1651 if ( merge ) ;//setModified( true ); 1651 if ( merge ) ;//setModified( true );
1652 else { 1652 else {
1653 //setModified( true ); 1653 //setModified( true );
1654 mViewManager->setDocumentId( filename ); 1654 mViewManager->setDocumentId( filename );
1655 mDialogManager->setDocumentId( filename ); 1655 mDialogManager->setDocumentId( filename );
1656 mTodoList->setDocumentId( filename ); 1656 mTodoList->setDocumentId( filename );
1657 } 1657 }
1658 globalFlagBlockAgenda = 2; 1658 globalFlagBlockAgenda = 2;
1659 // if ( getLastSyncEvent() ) 1659 // if ( getLastSyncEvent() )
1660 // getLastSyncEvent()->setReadOnly( true ); 1660 // getLastSyncEvent()->setReadOnly( true );
1661 mCalendar->reInitAlarmSettings(); 1661 mCalendar->reInitAlarmSettings();
1662 setSyncEventsReadOnly(); 1662 setSyncEventsReadOnly();
1663 updateUnmanagedViews(); 1663 updateUnmanagedViews();
1664 updateView(); 1664 updateView();
1665 if ( filename != MainWindow::defaultFileName() ) { 1665 if ( filename != MainWindow::defaultFileName() ) {
1666 saveCalendar( MainWindow::defaultFileName() ); 1666 saveCalendar( MainWindow::defaultFileName() );
1667 } else { 1667 } else {
1668 QFileInfo finf ( MainWindow::defaultFileName()); 1668 QFileInfo finf ( MainWindow::defaultFileName());
1669 if ( finf.exists() ) { 1669 if ( finf.exists() ) {
1670 setLoadedFileVersion( finf.lastModified () ); 1670 setLoadedFileVersion( finf.lastModified () );
1671 } 1671 }
1672 } 1672 }
1673 return true; 1673 return true;
1674 } else { 1674 } else {
1675 // while failing to load, the calendar object could 1675 // while failing to load, the calendar object could
1676 // have become partially populated. Clear it out. 1676 // have become partially populated. Clear it out.
1677 if ( !merge ) { 1677 if ( !merge ) {
1678 mCalendar->close(); 1678 mCalendar->close();
1679 mViewManager->setDocumentId( filename ); 1679 mViewManager->setDocumentId( filename );
1680 mDialogManager->setDocumentId( filename ); 1680 mDialogManager->setDocumentId( filename );
1681 mTodoList->setDocumentId( filename ); 1681 mTodoList->setDocumentId( filename );
1682 } 1682 }
1683 1683
1684 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1684 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1685 1685
1686 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1686 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1687 globalFlagBlockAgenda = 2; 1687 globalFlagBlockAgenda = 2;
1688 mCalendar->reInitAlarmSettings(); 1688 mCalendar->reInitAlarmSettings();
1689 setSyncEventsReadOnly(); 1689 setSyncEventsReadOnly();
1690 updateUnmanagedViews(); 1690 updateUnmanagedViews();
1691 updateView(); 1691 updateView();
1692 } 1692 }
1693 return false; 1693 return false;
1694} 1694}
1695void CalendarView::showOpenError() 1695void CalendarView::showOpenError()
1696{ 1696{
1697 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1697 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1698} 1698}
1699void CalendarView::setLoadedFileVersion(QDateTime dt) 1699void CalendarView::setLoadedFileVersion(QDateTime dt)
1700{ 1700{
1701 loadedFileVersion = dt; 1701 loadedFileVersion = dt;
1702} 1702}
1703bool CalendarView::checkFileChanged(QString fn) 1703bool CalendarView::checkFileChanged(QString fn)
1704{ 1704{
1705 QFileInfo finf ( fn ); 1705 QFileInfo finf ( fn );
1706 if ( !finf.exists() ) 1706 if ( !finf.exists() )
1707 return true; 1707 return true;
1708 QDateTime dt = finf.lastModified (); 1708 QDateTime dt = finf.lastModified ();
1709 if ( dt <= loadedFileVersion ) 1709 if ( dt <= loadedFileVersion )
1710 return false; 1710 return false;
1711 return true; 1711 return true;
1712 1712
1713} 1713}
1714void CalendarView::watchSavedFile() 1714void CalendarView::watchSavedFile()
1715{ 1715{
1716 QFileInfo finf ( MainWindow::defaultFileName()); 1716 QFileInfo finf ( MainWindow::defaultFileName());
1717 if ( !finf.exists() ) 1717 if ( !finf.exists() )
1718 return; 1718 return;
1719 QDateTime dt = finf.lastModified (); 1719 QDateTime dt = finf.lastModified ();
1720 if ( dt < loadedFileVersion ) { 1720 if ( dt < loadedFileVersion ) {
1721 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1721 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1722 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1722 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1723 return; 1723 return;
1724 } 1724 }
1725 loadedFileVersion = dt; 1725 loadedFileVersion = dt;
1726} 1726}
1727 1727
1728bool CalendarView::checkFileVersion(QString fn) 1728bool CalendarView::checkFileVersion(QString fn)
1729{ 1729{
1730 QFileInfo finf ( fn ); 1730 QFileInfo finf ( fn );
1731 if ( !finf.exists() ) 1731 if ( !finf.exists() )
1732 return true; 1732 return true;
1733 QDateTime dt = finf.lastModified (); 1733 QDateTime dt = finf.lastModified ();
1734 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1734 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1735 //qDebug("file on disk version %s",dt.toString().latin1()); 1735 //qDebug("file on disk version %s",dt.toString().latin1());
1736 if ( dt <= loadedFileVersion ) 1736 if ( dt <= loadedFileVersion )
1737 return true; 1737 return true;
1738 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)) , 1738 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)) ,
1739 i18n("KO/Pi Warning"),i18n("Overwrite"), 1739 i18n("KO/Pi Warning"),i18n("Overwrite"),
1740 i18n("Sync+save")); 1740 i18n("Sync+save"));
1741 1741
1742 if ( km == KMessageBox::Cancel ) 1742 if ( km == KMessageBox::Cancel )
1743 return false; 1743 return false;
1744 if ( km == KMessageBox::Yes ) 1744 if ( km == KMessageBox::Yes )
1745 return true; 1745 return true;
1746 1746
1747 setSyncDevice("deleteaftersync" ); 1747 setSyncDevice("deleteaftersync" );
1748 mSyncManager->mAskForPreferences = true; 1748 mSyncManager->mAskForPreferences = true;
1749 mSyncManager->mSyncAlgoPrefs = 3; 1749 mSyncManager->mSyncAlgoPrefs = 3;
1750 mSyncManager->mWriteBackFile = false; 1750 mSyncManager->mWriteBackFile = false;
1751 mSyncManager->mWriteBackExistingOnly = false; 1751 mSyncManager->mWriteBackExistingOnly = false;
1752 mSyncManager->mShowSyncSummary = false; 1752 mSyncManager->mShowSyncSummary = false;
1753 syncCalendar( fn, 3 ); 1753 syncCalendar( fn, 3 );
1754 Event * e = getLastSyncEvent(); 1754 Event * e = getLastSyncEvent();
1755 mCalendar->deleteEvent ( e ); 1755 mCalendar->deleteEvent ( e );
1756 updateView(); 1756 updateView();
1757 return true; 1757 return true;
1758} 1758}
1759 1759
1760bool CalendarView::saveCalendar( QString filename ) 1760bool CalendarView::saveCalendar( QString filename )
1761{ 1761{
1762 1762
1763 // Store back all unsaved data into calendar object 1763 // Store back all unsaved data into calendar object
1764 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1764 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1765 if ( mViewManager->currentView() ) 1765 if ( mViewManager->currentView() )
1766 mViewManager->currentView()->flushView(); 1766 mViewManager->currentView()->flushView();
1767 1767
1768 1768
1769 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 1769 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
1770 mStorage->setSaveFormat( new ICalFormat() ); 1770 mStorage->setSaveFormat( new ICalFormat() );
1771 mStorage->setFileName( filename ); 1771 mStorage->setFileName( filename );
1772 bool success; 1772 bool success;
1773 success = mStorage->save(); 1773 success = mStorage->save();
1774 if ( !success ) { 1774 if ( !success ) {
1775 return false; 1775 return false;
1776 } 1776 }
1777 if ( filename == MainWindow::defaultFileName() ) { 1777 if ( filename == MainWindow::defaultFileName() ) {
1778 setLoadedFileVersion( lfv ); 1778 setLoadedFileVersion( lfv );
1779 watchSavedFile(); 1779 watchSavedFile();
1780 } 1780 }
1781 return true; 1781 return true;
1782} 1782}
1783 1783
1784void CalendarView::closeCalendar() 1784void CalendarView::closeCalendar()
1785{ 1785{
1786 1786
1787 // child windows no longer valid 1787 // child windows no longer valid
1788 emit closingDown(); 1788 emit closingDown();
1789 1789
1790 mCalendar->close(); 1790 mCalendar->close();
1791 setModified(false); 1791 setModified(false);
1792 updateView(); 1792 updateView();
1793} 1793}
1794 1794
1795void CalendarView::archiveCalendar() 1795void CalendarView::archiveCalendar()
1796{ 1796{
1797 mDialogManager->showArchiveDialog(); 1797 mDialogManager->showArchiveDialog();
1798} 1798}
1799 1799
1800 1800
1801void CalendarView::readSettings() 1801void CalendarView::readSettings()
1802{ 1802{
1803 1803
1804 1804
1805 // mViewManager->showAgendaView(); 1805 // mViewManager->showAgendaView();
1806 QString str; 1806 QString str;
1807 //qDebug("CalendarView::readSettings() "); 1807 //qDebug("CalendarView::readSettings() ");
1808 // read settings from the KConfig, supplying reasonable 1808 // read settings from the KConfig, supplying reasonable
1809 // defaults where none are to be found 1809 // defaults where none are to be found
1810 KConfig *config = KOGlobals::config(); 1810 KConfig *config = KOGlobals::config();
1811#ifndef KORG_NOSPLITTER 1811#ifndef KORG_NOSPLITTER
1812 config->setGroup("KOrganizer Geometry"); 1812 config->setGroup("KOrganizer Geometry");
1813 1813
1814 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1814 QValueList<int> sizes = config->readIntListEntry("Separator1");
1815 if (sizes.count() != 2) { 1815 if (sizes.count() != 2) {
1816 sizes << mDateNavigator->minimumSizeHint().width(); 1816 sizes << mDateNavigator->minimumSizeHint().width();
1817 sizes << 300; 1817 sizes << 300;
1818 } 1818 }
1819 mPanner->setSizes(sizes); 1819 mPanner->setSizes(sizes);
1820 1820
1821 sizes = config->readIntListEntry("Separator2"); 1821 sizes = config->readIntListEntry("Separator2");
1822 if ( ( mResourceView && sizes.count() == 4 ) || 1822 if ( ( mResourceView && sizes.count() == 4 ) ||
1823 ( !mResourceView && sizes.count() == 3 ) ) { 1823 ( !mResourceView && sizes.count() == 3 ) ) {
1824 mLeftSplitter->setSizes(sizes); 1824 mLeftSplitter->setSizes(sizes);
1825 } 1825 }
1826#endif 1826#endif
1827 globalFlagBlockAgenda = 1; 1827 globalFlagBlockAgenda = 1;
1828 mViewManager->showAgendaView(); 1828 mViewManager->showAgendaView();
1829 //mViewManager->readSettings( config ); 1829 //mViewManager->readSettings( config );
1830 mTodoList->restoreLayout(config,QString("Todo Layout")); 1830 mTodoList->restoreLayout(config,QString("Todo Layout"));
1831 readFilterSettings(config); 1831 readFilterSettings(config);
1832 1832
1833#ifdef DESKTOP_VERSION 1833#ifdef DESKTOP_VERSION
1834 config->setGroup("WidgetLayout"); 1834 config->setGroup("WidgetLayout");
1835 QStringList list; 1835 QStringList list;
1836 list = config->readListEntry("MainLayout"); 1836 list = config->readListEntry("MainLayout");
1837 int x,y,w,h; 1837 int x,y,w,h;
1838 if ( ! list.isEmpty() ) { 1838 if ( ! list.isEmpty() ) {
1839 x = list[0].toInt(); 1839 x = list[0].toInt();
1840 y = list[1].toInt(); 1840 y = list[1].toInt();
1841 w = list[2].toInt(); 1841 w = list[2].toInt();
1842 h = list[3].toInt(); 1842 h = list[3].toInt();
1843 KApplication::testCoords( &x,&y,&w,&h );
1843 topLevelWidget()->setGeometry(x,y,w,h); 1844 topLevelWidget()->setGeometry(x,y,w,h);
1844 1845
1845 } else { 1846 } else {
1846 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1847 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1847 } 1848 }
1848 list = config->readListEntry("EditEventLayout"); 1849 list = config->readListEntry("EditEventLayout");
1849 if ( ! list.isEmpty() ) { 1850 if ( ! list.isEmpty() ) {
1850 x = list[0].toInt(); 1851 x = list[0].toInt();
1851 y = list[1].toInt(); 1852 y = list[1].toInt();
1852 w = list[2].toInt(); 1853 w = list[2].toInt();
1853 h = list[3].toInt(); 1854 h = list[3].toInt();
1855 KApplication::testCoords( &x,&y,&w,&h );
1854 mEventEditor->setGeometry(x,y,w,h); 1856 mEventEditor->setGeometry(x,y,w,h);
1855 1857
1856 } 1858 }
1857 list = config->readListEntry("EditTodoLayout"); 1859 list = config->readListEntry("EditTodoLayout");
1858 if ( ! list.isEmpty() ) { 1860 if ( ! list.isEmpty() ) {
1859 x = list[0].toInt(); 1861 x = list[0].toInt();
1860 y = list[1].toInt(); 1862 y = list[1].toInt();
1861 w = list[2].toInt(); 1863 w = list[2].toInt();
1862 h = list[3].toInt(); 1864 h = list[3].toInt();
1865 KApplication::testCoords( &x,&y,&w,&h );
1863 mTodoEditor->setGeometry(x,y,w,h); 1866 mTodoEditor->setGeometry(x,y,w,h);
1864 1867
1865 } 1868 }
1866 list = config->readListEntry("ViewerLayout"); 1869 list = config->readListEntry("ViewerLayout");
1867 if ( ! list.isEmpty() ) { 1870 if ( ! list.isEmpty() ) {
1868 x = list[0].toInt(); 1871 x = list[0].toInt();
1869 y = list[1].toInt(); 1872 y = list[1].toInt();
1870 w = list[2].toInt(); 1873 w = list[2].toInt();
1871 h = list[3].toInt(); 1874 h = list[3].toInt();
1875 KApplication::testCoords( &x,&y,&w,&h );
1872 getEventViewerDialog()->setGeometry(x,y,w,h); 1876 getEventViewerDialog()->setGeometry(x,y,w,h);
1873 } 1877 }
1874#endif 1878#endif
1875 config->setGroup( "Views" ); 1879 config->setGroup( "Views" );
1876 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1880 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1877 1881
1878 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); 1882 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame");
1879 1883
1880 int resetval = 0; 1884 int resetval = 0;
1881 int maxVal = 0; 1885 int maxVal = 0;
1882 if (sizes.count() != 3) { 1886 if (sizes.count() != 3) {
1883 if ( KOPrefs::instance()->mVerticalScreen ) { 1887 if ( KOPrefs::instance()->mVerticalScreen ) {
1884 resetval = mDateNavigator->sizeHint().width()+2; 1888 resetval = mDateNavigator->sizeHint().width()+2;
1885 } else { 1889 } else {
1886 resetval = mDateNavigator->sizeHint().height()+2; 1890 resetval = mDateNavigator->sizeHint().height()+2;
1887 } 1891 }
1888 } 1892 }
1889 if ( resetval ) { 1893 if ( resetval ) {
1890 sizes.clear(); 1894 sizes.clear();
1891 if ( KOPrefs::instance()->mVerticalScreen ) { 1895 if ( KOPrefs::instance()->mVerticalScreen ) {
1892 maxVal = QApplication::desktop()->width() -10; 1896 maxVal = QApplication::desktop()->width() -10;
1893 } else { 1897 } else {
1894 maxVal = QApplication::desktop()->height()-10; 1898 maxVal = QApplication::desktop()->height()-10;
1895 } 1899 }
1896 sizes << resetval; 1900 sizes << resetval;
1897 if ( maxVal < resetval + resetval) 1901 if ( maxVal < resetval + resetval)
1898 resetval = maxVal - resetval; 1902 resetval = maxVal - resetval;
1899 sizes << resetval; 1903 sizes << resetval;
1900 sizes << 100; 1904 sizes << 100;
1901 } 1905 }
1902 mLeftFrame->setSizes(sizes); 1906 mLeftFrame->setSizes(sizes);
1903 sizes = config->readIntListEntry("Main Splitter Frame"); 1907 sizes = config->readIntListEntry("Main Splitter Frame");
1904 resetval = 0; 1908 resetval = 0;
1905 maxVal = 0; 1909 maxVal = 0;
1906 if (sizes.count() != 2) { 1910 if (sizes.count() != 2) {
1907 if ( !KOPrefs::instance()->mVerticalScreen ) { 1911 if ( !KOPrefs::instance()->mVerticalScreen ) {
1908 resetval = mDateNavigator->sizeHint().width()+2; 1912 resetval = mDateNavigator->sizeHint().width()+2;
1909 } else { 1913 } else {
1910 resetval = mDateNavigator->sizeHint().height()+2; 1914 resetval = mDateNavigator->sizeHint().height()+2;
1911 } 1915 }
1912 } 1916 }
1913 if ( resetval ) { 1917 if ( resetval ) {
1914 sizes.clear(); 1918 sizes.clear();
1915 if ( !KOPrefs::instance()->mVerticalScreen ) { 1919 if ( !KOPrefs::instance()->mVerticalScreen ) {
1916 maxVal = QApplication::desktop()->width() -10; 1920 maxVal = QApplication::desktop()->width() -10;
1917 } else { 1921 } else {
1918 maxVal = QApplication::desktop()->height()-10; 1922 maxVal = QApplication::desktop()->height()-10;
1919 } 1923 }
1920 sizes << resetval; 1924 sizes << resetval;
1921 if ( maxVal < resetval + resetval) 1925 if ( maxVal < resetval + resetval)
1922 resetval = maxVal - resetval; 1926 resetval = maxVal - resetval;
1923 sizes << resetval; 1927 sizes << resetval;
1924 } 1928 }
1925 mMainFrame->setSizes(sizes); 1929 mMainFrame->setSizes(sizes);
1926 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1930 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1927 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1931 else if ( dateCount == 7 ) mNavigator->selectWeek();
1928 else mNavigator->selectDates( dateCount ); 1932 else mNavigator->selectDates( dateCount );
1929 // mViewManager->readSettings( config ); 1933 // mViewManager->readSettings( config );
1930 updateConfig(); 1934 updateConfig();
1931 globalFlagBlockAgenda = 2; 1935 globalFlagBlockAgenda = 2;
1932 mViewManager->readSettings( config ); 1936 mViewManager->readSettings( config );
1933 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); 1937 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) );
1934} 1938}
1935 1939
1936 1940
1937void CalendarView::writeSettings() 1941void CalendarView::writeSettings()
1938{ 1942{
1939 // kdDebug() << "CalendarView::writeSettings" << endl; 1943 // kdDebug() << "CalendarView::writeSettings" << endl;
1940 1944
1941 KConfig *config = KOGlobals::config(); 1945 KConfig *config = KOGlobals::config();
1942 1946
1943 mViewManager->writeSettings( config ); 1947 mViewManager->writeSettings( config );
1944 mTodoList->saveLayout(config,QString("Todo Layout")); 1948 mTodoList->saveLayout(config,QString("Todo Layout"));
1945 mDialogManager->writeSettings( config ); 1949 mDialogManager->writeSettings( config );
1946 //KOPrefs::instance()->usrWriteConfig(); 1950 //KOPrefs::instance()->usrWriteConfig();
1947 KOPrefs::instance()->writeConfig(); 1951 KOPrefs::instance()->writeConfig();
1948 1952
1949 writeFilterSettings(config); 1953 writeFilterSettings(config);
1950 1954
1951 config->setGroup( "Views" ); 1955 config->setGroup( "Views" );
1952 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1956 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1953 1957
1954 QValueList<int> listINT = mLeftFrame->sizes(); 1958 QValueList<int> listINT = mLeftFrame->sizes();
1955 config->writeEntry("Left Splitter Frame",listINT); 1959 config->writeEntry("Left Splitter Frame",listINT);
1956 QValueList<int> listINT2 = mMainFrame->sizes(); 1960 QValueList<int> listINT2 = mMainFrame->sizes();
1957 config->writeEntry("Main Splitter Frame",listINT2); 1961 config->writeEntry("Main Splitter Frame",listINT2);
1958#ifdef DESKTOP_VERSION 1962#ifdef DESKTOP_VERSION
1959 config->setGroup("WidgetLayout"); 1963 config->setGroup("WidgetLayout");
1960 QStringList list ;//= config->readListEntry("MainLayout"); 1964 QStringList list ;//= config->readListEntry("MainLayout");
1961 int x,y,w,h; 1965 int x,y,w,h;
1962 QWidget* wid; 1966 QWidget* wid;
1963 wid = topLevelWidget(); 1967 wid = topLevelWidget();
1964 x = wid->geometry().x(); 1968 x = wid->geometry().x();
1965 y = wid->geometry().y(); 1969 y = wid->geometry().y();
1966 w = wid->width(); 1970 w = wid->width();
1967 h = wid->height(); 1971 h = wid->height();
1968 list.clear(); 1972 list.clear();
1969 list << QString::number( x ); 1973 list << QString::number( x );
1970 list << QString::number( y ); 1974 list << QString::number( y );
1971 list << QString::number( w ); 1975 list << QString::number( w );
1972 list << QString::number( h ); 1976 list << QString::number( h );
1973 config->writeEntry("MainLayout",list ); 1977 config->writeEntry("MainLayout",list );
1974 1978
1975 wid = mEventEditor; 1979 wid = mEventEditor;
1976 x = wid->geometry().x(); 1980 x = wid->geometry().x();
1977 y = wid->geometry().y(); 1981 y = wid->geometry().y();
1978 w = wid->width(); 1982 w = wid->width();
1979 h = wid->height(); 1983 h = wid->height();
1980 list.clear(); 1984 list.clear();
1981 list << QString::number( x ); 1985 list << QString::number( x );
1982 list << QString::number( y ); 1986 list << QString::number( y );
1983 list << QString::number( w ); 1987 list << QString::number( w );
1984 list << QString::number( h ); 1988 list << QString::number( h );
1985 config->writeEntry("EditEventLayout",list ); 1989 config->writeEntry("EditEventLayout",list );
1986 1990
1987 wid = mTodoEditor; 1991 wid = mTodoEditor;
1988 x = wid->geometry().x(); 1992 x = wid->geometry().x();
1989 y = wid->geometry().y(); 1993 y = wid->geometry().y();
1990 w = wid->width(); 1994 w = wid->width();
1991 h = wid->height(); 1995 h = wid->height();
1992 list.clear(); 1996 list.clear();
1993 list << QString::number( x ); 1997 list << QString::number( x );
1994 list << QString::number( y ); 1998 list << QString::number( y );
1995 list << QString::number( w ); 1999 list << QString::number( w );
1996 list << QString::number( h ); 2000 list << QString::number( h );
1997 config->writeEntry("EditTodoLayout",list ); 2001 config->writeEntry("EditTodoLayout",list );
1998 wid = getEventViewerDialog(); 2002 wid = getEventViewerDialog();
1999 x = wid->geometry().x(); 2003 x = wid->geometry().x();
2000 y = wid->geometry().y(); 2004 y = wid->geometry().y();
2001 w = wid->width(); 2005 w = wid->width();
2002 h = wid->height(); 2006 h = wid->height();
2003 list.clear(); 2007 list.clear();
2004 list << QString::number( x ); 2008 list << QString::number( x );
2005 list << QString::number( y ); 2009 list << QString::number( y );
2006 list << QString::number( w ); 2010 list << QString::number( w );
2007 list << QString::number( h ); 2011 list << QString::number( h );
2008 config->writeEntry("ViewerLayout",list ); 2012 config->writeEntry("ViewerLayout",list );
2009 wid = mDialogManager->getSearchDialog(); 2013 wid = mDialogManager->getSearchDialog();
2010 if ( wid ) { 2014 if ( wid ) {
2011 x = wid->geometry().x(); 2015 x = wid->geometry().x();
2012 y = wid->geometry().y(); 2016 y = wid->geometry().y();
2013 w = wid->width(); 2017 w = wid->width();
2014 h = wid->height(); 2018 h = wid->height();
2015 list.clear(); 2019 list.clear();
2016 list << QString::number( x ); 2020 list << QString::number( x );
2017 list << QString::number( y ); 2021 list << QString::number( y );
2018 list << QString::number( w ); 2022 list << QString::number( w );
2019 list << QString::number( h ); 2023 list << QString::number( h );
2020 config->writeEntry("SearchLayout",list ); 2024 config->writeEntry("SearchLayout",list );
2021 } 2025 }
2022#endif 2026#endif
2023 2027
2024 2028
2025 config->sync(); 2029 config->sync();
2026} 2030}
2027 2031
2028void CalendarView::readFilterSettings(KConfig *config) 2032void CalendarView::readFilterSettings(KConfig *config)
2029{ 2033{
2030 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 2034 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
2031 2035
2032 mFilters.clear(); 2036 mFilters.clear();
2033 2037
2034 config->setGroup("General"); 2038 config->setGroup("General");
2035 QStringList filterList = config->readListEntry("CalendarFilters"); 2039 QStringList filterList = config->readListEntry("CalendarFilters");
2036 2040
2037 QStringList::ConstIterator it = filterList.begin(); 2041 QStringList::ConstIterator it = filterList.begin();
2038 QStringList::ConstIterator end = filterList.end(); 2042 QStringList::ConstIterator end = filterList.end();
2039 while(it != end) { 2043 while(it != end) {
2040 // kdDebug() << " filter: " << (*it) << endl; 2044 // kdDebug() << " filter: " << (*it) << endl;
2041 2045
2042 CalFilter *filter; 2046 CalFilter *filter;
2043 filter = new CalFilter(*it); 2047 filter = new CalFilter(*it);
2044 config->setGroup("Filter_" + (*it).utf8()); 2048 config->setGroup("Filter_" + (*it).utf8());
2045 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 2049 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
2046 filter->setCriteria(config->readNumEntry("Criteria",0)); 2050 filter->setCriteria(config->readNumEntry("Criteria",0));
2047 filter->setCategoryList(config->readListEntry("CategoryList")); 2051 filter->setCategoryList(config->readListEntry("CategoryList"));
2048 mFilters.append(filter); 2052 mFilters.append(filter);
2049 2053
2050 ++it; 2054 ++it;
2051 } 2055 }
2052 2056
2053 if (mFilters.count() == 0) { 2057 if (mFilters.count() == 0) {
2054 CalFilter *filter = new CalFilter(i18n("Default")); 2058 CalFilter *filter = new CalFilter(i18n("Default"));
2055 mFilters.append(filter); 2059 mFilters.append(filter);
2056 } 2060 }
2057 mFilterView->updateFilters(); 2061 mFilterView->updateFilters();
2058 config->setGroup("FilterView"); 2062 config->setGroup("FilterView");
2059 2063
2060 mFilterView->blockSignals(true); 2064 mFilterView->blockSignals(true);
2061 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 2065 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
2062 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 2066 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
2063 mFilterView->blockSignals(false); 2067 mFilterView->blockSignals(false);
2064 // We do it manually to avoid it being done twice by the above calls 2068 // We do it manually to avoid it being done twice by the above calls
2065 updateFilter(); 2069 updateFilter();
2066} 2070}
2067 2071
2068void CalendarView::writeFilterSettings(KConfig *config) 2072void CalendarView::writeFilterSettings(KConfig *config)
2069{ 2073{
2070 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 2074 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
2071 2075
2072 QStringList filterList; 2076 QStringList filterList;
2073 2077
2074 CalFilter *filter = mFilters.first(); 2078 CalFilter *filter = mFilters.first();
2075 while(filter) { 2079 while(filter) {
2076 // kdDebug() << " fn: " << filter->name() << endl; 2080 // kdDebug() << " fn: " << filter->name() << endl;
2077 filterList << filter->name(); 2081 filterList << filter->name();
2078 config->setGroup("Filter_" + filter->name().utf8()); 2082 config->setGroup("Filter_" + filter->name().utf8());
2079 config->writeEntry("Criteria",filter->criteria()); 2083 config->writeEntry("Criteria",filter->criteria());
2080 config->writeEntry("CategoryList",filter->categoryList()); 2084 config->writeEntry("CategoryList",filter->categoryList());
2081 filter = mFilters.next(); 2085 filter = mFilters.next();
2082 } 2086 }
2083 config->setGroup("General"); 2087 config->setGroup("General");
2084 config->writeEntry("CalendarFilters",filterList); 2088 config->writeEntry("CalendarFilters",filterList);
2085 2089
2086 config->setGroup("FilterView"); 2090 config->setGroup("FilterView");
2087 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2091 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
2088 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2092 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
2089} 2093}
2090 2094
2091 2095
2092void CalendarView::goToday() 2096void CalendarView::goToday()
2093{ 2097{
2094 if ( mViewManager->currentView()->isMonthView() ) 2098 if ( mViewManager->currentView()->isMonthView() )
2095 mNavigator->selectTodayMonth(); 2099 mNavigator->selectTodayMonth();
2096 else 2100 else
2097 mNavigator->selectToday(); 2101 mNavigator->selectToday();
2098} 2102}
2099 2103
2100void CalendarView::goNext() 2104void CalendarView::goNext()
2101{ 2105{
2102 mNavigator->selectNext(); 2106 mNavigator->selectNext();
2103} 2107}
2104 2108
2105void CalendarView::goPrevious() 2109void CalendarView::goPrevious()
2106{ 2110{
2107 mNavigator->selectPrevious(); 2111 mNavigator->selectPrevious();
2108} 2112}
2109void CalendarView::goNextMonth() 2113void CalendarView::goNextMonth()
2110{ 2114{
2111 mNavigator->selectNextMonth(); 2115 mNavigator->selectNextMonth();
2112} 2116}
2113 2117
2114void CalendarView::goPreviousMonth() 2118void CalendarView::goPreviousMonth()
2115{ 2119{
2116 mNavigator->selectPreviousMonth(); 2120 mNavigator->selectPreviousMonth();
2117} 2121}
2118void CalendarView::writeLocale() 2122void CalendarView::writeLocale()
2119{ 2123{
2120 //KPimGlobalPrefs::instance()->setGlobalConfig(); 2124 //KPimGlobalPrefs::instance()->setGlobalConfig();
2121#if 0 2125#if 0
2122 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 2126 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
2123 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 2127 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
2124 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 2128 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
2125 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 2129 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
2126 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 2130 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
2127 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 2131 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
2128 dummy = KOPrefs::instance()->mUserDateFormatShort; 2132 dummy = KOPrefs::instance()->mUserDateFormatShort;
2129 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 2133 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
2130 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 2134 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
2131 KOPrefs::instance()->mDaylightsavingStart, 2135 KOPrefs::instance()->mDaylightsavingStart,
2132 KOPrefs::instance()->mDaylightsavingEnd ); 2136 KOPrefs::instance()->mDaylightsavingEnd );
2133 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); 2137 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId );
2134#endif 2138#endif
2135} 2139}
2136void CalendarView::updateConfig() 2140void CalendarView::updateConfig()
2137{ 2141{
2138 writeLocale(); 2142 writeLocale();
2139 if ( KOPrefs::instance()->mUseAppColors ) 2143 if ( KOPrefs::instance()->mUseAppColors )
2140 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2144 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2141 emit configChanged(); 2145 emit configChanged();
2142 mTodoList->updateConfig(); 2146 mTodoList->updateConfig();
2143 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2147 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2144 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2148 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2145 // To make the "fill window" configurations work 2149 // To make the "fill window" configurations work
2146 //mViewManager->raiseCurrentView(); 2150 //mViewManager->raiseCurrentView();
2147} 2151}
2148 2152
2149 2153
2150void CalendarView::eventChanged(Event *event) 2154void CalendarView::eventChanged(Event *event)
2151{ 2155{
2152 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2156 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2153 //updateUnmanagedViews(); 2157 //updateUnmanagedViews();
2154} 2158}
2155 2159
2156void CalendarView::eventAdded(Event *event) 2160void CalendarView::eventAdded(Event *event)
2157{ 2161{
2158 changeEventDisplay(event,KOGlobals::EVENTADDED); 2162 changeEventDisplay(event,KOGlobals::EVENTADDED);
2159} 2163}
2160 2164
2161void CalendarView::eventToBeDeleted(Event *) 2165void CalendarView::eventToBeDeleted(Event *)
2162{ 2166{
2163 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2167 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2164} 2168}
2165 2169
2166void CalendarView::eventDeleted() 2170void CalendarView::eventDeleted()
2167{ 2171{
2168 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2172 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2169} 2173}
2170void CalendarView::changeTodoDisplay(Todo *which, int action) 2174void CalendarView::changeTodoDisplay(Todo *which, int action)
2171{ 2175{
2172 changeIncidenceDisplay((Incidence *)which, action); 2176 changeIncidenceDisplay((Incidence *)which, action);
2173 mDateNavigator->updateView(); //LR 2177 mDateNavigator->updateView(); //LR
2174 //mDialogManager->updateSearchDialog(); 2178 //mDialogManager->updateSearchDialog();
2175 2179
2176 if (which) { 2180 if (which) {
2177 mViewManager->updateWNview(); 2181 mViewManager->updateWNview();
2178 //mTodoList->updateView(); 2182 //mTodoList->updateView();
2179 } 2183 }
2180 2184
2181} 2185}
2182 2186
2183void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2187void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2184{ 2188{
2185 updateUnmanagedViews(); 2189 updateUnmanagedViews();
2186 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2190 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2187 if ( action == KOGlobals::EVENTDELETED ) { //delete 2191 if ( action == KOGlobals::EVENTDELETED ) { //delete
2188 mCalendar->checkAlarmForIncidence( 0, true ); 2192 mCalendar->checkAlarmForIncidence( 0, true );
2189 if ( mEventViewerDialog ) 2193 if ( mEventViewerDialog )
2190 mEventViewerDialog->hide(); 2194 mEventViewerDialog->hide();
2191 } 2195 }
2192 else 2196 else
2193 mCalendar->checkAlarmForIncidence( which , false ); 2197 mCalendar->checkAlarmForIncidence( which , false );
2194} 2198}
2195 2199
2196// most of the changeEventDisplays() right now just call the view's 2200// most of the changeEventDisplays() right now just call the view's
2197// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2201// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2198void CalendarView::changeEventDisplay(Event *which, int action) 2202void CalendarView::changeEventDisplay(Event *which, int action)
2199{ 2203{
2200 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2204 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2201 changeIncidenceDisplay((Incidence *)which, action); 2205 changeIncidenceDisplay((Incidence *)which, action);
2202 mDateNavigator->updateView(); 2206 mDateNavigator->updateView();
2203 //mDialogManager->updateSearchDialog(); 2207 //mDialogManager->updateSearchDialog();
2204 2208
2205 if (which) { 2209 if (which) {
2206 // If there is an event view visible update the display 2210 // If there is an event view visible update the display
2207 mViewManager->currentView()->changeEventDisplay(which,action); 2211 mViewManager->currentView()->changeEventDisplay(which,action);
2208 // TODO: check, if update needed 2212 // TODO: check, if update needed
2209 // if (which->getTodoStatus()) { 2213 // if (which->getTodoStatus()) {
2210 mTodoList->updateView(); 2214 mTodoList->updateView();
2211 // } 2215 // }
2212 } else { 2216 } else {
2213 mViewManager->currentView()->updateView(); 2217 mViewManager->currentView()->updateView();
2214 } 2218 }
2215} 2219}
2216 2220
2217 2221
2218void CalendarView::updateTodoViews() 2222void CalendarView::updateTodoViews()
2219{ 2223{
2220 mTodoList->updateView(); 2224 mTodoList->updateView();
2221 mViewManager->currentView()->updateView(); 2225 mViewManager->currentView()->updateView();
2222 2226
2223} 2227}
2224 2228
2225 2229
2226void CalendarView::updateView(const QDate &start, const QDate &end) 2230void CalendarView::updateView(const QDate &start, const QDate &end)
2227{ 2231{
2228 mTodoList->updateView(); 2232 mTodoList->updateView();
2229 mViewManager->updateView(start, end); 2233 mViewManager->updateView(start, end);
2230 //mDateNavigator->updateView(); 2234 //mDateNavigator->updateView();
2231} 2235}
2232 2236
2233void CalendarView::updateView() 2237void CalendarView::updateView()
2234{ 2238{
2235 DateList tmpList = mNavigator->selectedDates(); 2239 DateList tmpList = mNavigator->selectedDates();
2236 2240
2237 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2241 if ( KOPrefs::instance()->mHideNonStartedTodos )
2238 mTodoList->updateView(); 2242 mTodoList->updateView();
2239 // We assume that the navigator only selects consecutive days. 2243 // We assume that the navigator only selects consecutive days.
2240 updateView( tmpList.first(), tmpList.last() ); 2244 updateView( tmpList.first(), tmpList.last() );
2241} 2245}
2242 2246
2243void CalendarView::updateUnmanagedViews() 2247void CalendarView::updateUnmanagedViews()
2244{ 2248{
2245 mDateNavigator->updateDayMatrix(); 2249 mDateNavigator->updateDayMatrix();
2246} 2250}
2247 2251
2248int CalendarView::msgItemDelete(const QString name) 2252int CalendarView::msgItemDelete(const QString name)
2249{ 2253{
2250 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 2254 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
2251 i18n("This item will be\npermanently deleted."), 2255 i18n("This item will be\npermanently deleted."),
2252 i18n("KO/Pi Confirmation"),i18n("Delete")); 2256 i18n("KO/Pi Confirmation"),i18n("Delete"));
2253} 2257}
2254 2258
2255 2259
2256void CalendarView::edit_cut() 2260void CalendarView::edit_cut()
2257{ 2261{
2258 Event *anEvent=0; 2262 Event *anEvent=0;
2259 2263
2260 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2264 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2261 2265
2262 if (mViewManager->currentView()->isEventView()) { 2266 if (mViewManager->currentView()->isEventView()) {
2263 if ( incidence && incidence->type() == "Event" ) { 2267 if ( incidence && incidence->type() == "Event" ) {
2264 anEvent = static_cast<Event *>(incidence); 2268 anEvent = static_cast<Event *>(incidence);
2265 } 2269 }
2266 } 2270 }
2267 2271
2268 if (!anEvent) { 2272 if (!anEvent) {
2269 KNotifyClient::beep(); 2273 KNotifyClient::beep();
2270 return; 2274 return;
2271 } 2275 }
2272 DndFactory factory( mCalendar ); 2276 DndFactory factory( mCalendar );
2273 factory.cutIncidence(anEvent); 2277 factory.cutIncidence(anEvent);
2274 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2278 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2275} 2279}
2276 2280
2277void CalendarView::edit_copy() 2281void CalendarView::edit_copy()
2278{ 2282{
2279 Event *anEvent=0; 2283 Event *anEvent=0;
2280 2284
2281 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2285 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2282 2286
2283 if (mViewManager->currentView()->isEventView()) { 2287 if (mViewManager->currentView()->isEventView()) {
2284 if ( incidence && incidence->type() == "Event" ) { 2288 if ( incidence && incidence->type() == "Event" ) {
2285 anEvent = static_cast<Event *>(incidence); 2289 anEvent = static_cast<Event *>(incidence);
2286 } 2290 }
2287 } 2291 }
2288 2292
2289 if (!anEvent) { 2293 if (!anEvent) {
2290 KNotifyClient::beep(); 2294 KNotifyClient::beep();
2291 return; 2295 return;
2292 } 2296 }
2293 DndFactory factory( mCalendar ); 2297 DndFactory factory( mCalendar );
2294 factory.copyIncidence(anEvent); 2298 factory.copyIncidence(anEvent);
2295} 2299}
2296 2300
2297void CalendarView::edit_paste() 2301void CalendarView::edit_paste()
2298{ 2302{
2299 QDate date = mNavigator->selectedDates().first(); 2303 QDate date = mNavigator->selectedDates().first();
2300 2304
2301 DndFactory factory( mCalendar ); 2305 DndFactory factory( mCalendar );
2302 Event *pastedEvent = (Event *)factory.pasteIncidence( date ); 2306 Event *pastedEvent = (Event *)factory.pasteIncidence( date );
2303 2307
2304 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2308 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2305} 2309}
2306 2310
2307void CalendarView::edit_options() 2311void CalendarView::edit_options()
2308{ 2312{
2309 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; 2313 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId;
2310 emit save(); 2314 emit save();
2311 emit saveStopTimer(); 2315 emit saveStopTimer();
2312 mDialogManager->showOptionsDialog(); 2316 mDialogManager->showOptionsDialog();
2313 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { 2317 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
2314 emit saveStopTimer(); 2318 emit saveStopTimer();
2315 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!"), 2319 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!"),
2316 i18n("Timezone settings"),i18n("Reload"))) { 2320 i18n("Timezone settings"),i18n("Reload"))) {
2317 qDebug("KO: TZ reload cancelled "); 2321 qDebug("KO: TZ reload cancelled ");
2318 return; 2322 return;
2319 } 2323 }
2320 qDebug("KO: Timezone change "); 2324 qDebug("KO: Timezone change ");
2321 openCalendar( MainWindow::defaultFileName() ); 2325 openCalendar( MainWindow::defaultFileName() );
2322 setModified(true); 2326 setModified(true);
2323 } 2327 }
2324 else 2328 else
2325 qDebug("KO: No tz change "); 2329 qDebug("KO: No tz change ");
2326 2330
2327} 2331}
2328 2332
2329 2333
2330void CalendarView::slotSelectPickerDate( QDate d) 2334void CalendarView::slotSelectPickerDate( QDate d)
2331{ 2335{
2332 mDateFrame->hide(); 2336 mDateFrame->hide();
2333 if ( mDatePickerMode == 1 ) { 2337 if ( mDatePickerMode == 1 ) {
2334 mNavigator->slotDaySelect( d ); 2338 mNavigator->slotDaySelect( d );
2335 } else if ( mDatePickerMode == 2 ) { 2339 } else if ( mDatePickerMode == 2 ) {
2336 if ( mMoveIncidence->type() == "Todo" ) { 2340 if ( mMoveIncidence->type() == "Todo" ) {
2337 Todo * to = (Todo *) mMoveIncidence; 2341 Todo * to = (Todo *) mMoveIncidence;
2338 QTime tim; 2342 QTime tim;
2339 int len = 0; 2343 int len = 0;
2340 if ( to->hasStartDate() && to->hasDueDate() ) 2344 if ( to->hasStartDate() && to->hasDueDate() )
2341 len = to->dtStart().secsTo( to->dtDue()); 2345 len = to->dtStart().secsTo( to->dtDue());
2342 if ( to->hasDueDate() ) 2346 if ( to->hasDueDate() )
2343 tim = to->dtDue().time(); 2347 tim = to->dtDue().time();
2344 else { 2348 else {
2345 tim = QTime ( 0,0,0 ); 2349 tim = QTime ( 0,0,0 );
2346 to->setFloats( true ); 2350 to->setFloats( true );
2347 to->setHasDueDate( true ); 2351 to->setHasDueDate( true );
2348 } 2352 }
2349 QDateTime dt ( d,tim ); 2353 QDateTime dt ( d,tim );
2350 to->setDtDue( dt ); 2354 to->setDtDue( dt );
2351 2355
2352 if ( to->hasStartDate() ) { 2356 if ( to->hasStartDate() ) {
2353 if ( len>0 ) 2357 if ( len>0 )
2354 to->setDtStart(to->dtDue().addSecs( -len )); 2358 to->setDtStart(to->dtDue().addSecs( -len ));
2355 else 2359 else
2356 if (to->dtStart() > to->dtDue() ) 2360 if (to->dtStart() > to->dtDue() )
2357 to->setDtStart(to->dtDue().addDays( -3 )); 2361 to->setDtStart(to->dtDue().addDays( -3 ));
2358 } 2362 }
2359 2363
2360 todoChanged( to ); 2364 todoChanged( to );
2361 } else { 2365 } else {
2362 if ( mMoveIncidence->doesRecur() ) { 2366 if ( mMoveIncidence->doesRecur() ) {
2363#if 0 2367#if 0
2364 // PENDING implement this 2368 // PENDING implement this
2365 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 2369 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
2366 mCalendar()->addIncidence( newInc ); 2370 mCalendar()->addIncidence( newInc );
2367 if ( mMoveIncidence->type() == "Todo" ) 2371 if ( mMoveIncidence->type() == "Todo" )
2368 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 2372 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
2369 else 2373 else
2370 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 2374 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
2371 mMoveIncidence = newInc; 2375 mMoveIncidence = newInc;
2372 2376
2373#endif 2377#endif
2374 } 2378 }
2375 QTime tim = mMoveIncidence->dtStart().time(); 2379 QTime tim = mMoveIncidence->dtStart().time();
2376 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2380 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2377 QDateTime dt ( d,tim ); 2381 QDateTime dt ( d,tim );
2378 mMoveIncidence->setDtStart( dt ); 2382 mMoveIncidence->setDtStart( dt );
2379 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2383 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2380 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2384 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2381 } 2385 }
2382 2386
2383 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2387 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2384 } 2388 }
2385} 2389}
2386 2390
2387void CalendarView::removeCategories() 2391void CalendarView::removeCategories()
2388{ 2392{
2389 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2393 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2390 QStringList catList = KOPrefs::instance()->mCustomCategories; 2394 QStringList catList = KOPrefs::instance()->mCustomCategories;
2391 QStringList catIncList; 2395 QStringList catIncList;
2392 QStringList newCatList; 2396 QStringList newCatList;
2393 Incidence* inc = incList.first(); 2397 Incidence* inc = incList.first();
2394 int i; 2398 int i;
2395 int count = 0; 2399 int count = 0;
2396 while ( inc ) { 2400 while ( inc ) {
2397 newCatList.clear(); 2401 newCatList.clear();
2398 catIncList = inc->categories() ; 2402 catIncList = inc->categories() ;
2399 for( i = 0; i< catIncList.count(); ++i ) { 2403 for( i = 0; i< catIncList.count(); ++i ) {
2400 if ( catList.contains (catIncList[i])) 2404 if ( catList.contains (catIncList[i]))
2401 newCatList.append( catIncList[i] ); 2405 newCatList.append( catIncList[i] );
2402 } 2406 }
2403 newCatList.sort(); 2407 newCatList.sort();
2404 inc->setCategories( newCatList.join(",") ); 2408 inc->setCategories( newCatList.join(",") );
2405 inc = incList.next(); 2409 inc = incList.next();
2406 } 2410 }
2407} 2411}
2408 2412
2409int CalendarView::addCategories() 2413int CalendarView::addCategories()
2410{ 2414{
2411 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2415 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2412 QStringList catList = KOPrefs::instance()->mCustomCategories; 2416 QStringList catList = KOPrefs::instance()->mCustomCategories;
2413 QStringList catIncList; 2417 QStringList catIncList;
2414 Incidence* inc = incList.first(); 2418 Incidence* inc = incList.first();
2415 int i; 2419 int i;
2416 int count = 0; 2420 int count = 0;
2417 while ( inc ) { 2421 while ( inc ) {
2418 catIncList = inc->categories() ; 2422 catIncList = inc->categories() ;
2419 for( i = 0; i< catIncList.count(); ++i ) { 2423 for( i = 0; i< catIncList.count(); ++i ) {
2420 if ( !catList.contains (catIncList[i])) { 2424 if ( !catList.contains (catIncList[i])) {
2421 catList.append( catIncList[i] ); 2425 catList.append( catIncList[i] );
2422 //qDebug("add cat %s ", catIncList[i].latin1()); 2426 //qDebug("add cat %s ", catIncList[i].latin1());
2423 ++count; 2427 ++count;
2424 } 2428 }
2425 } 2429 }
2426 inc = incList.next(); 2430 inc = incList.next();
2427 } 2431 }
2428 catList.sort(); 2432 catList.sort();
2429 KOPrefs::instance()->mCustomCategories = catList; 2433 KOPrefs::instance()->mCustomCategories = catList;
2430 return count; 2434 return count;
2431} 2435}
2432 2436
2433void CalendarView::manageCategories() 2437void CalendarView::manageCategories()
2434{ 2438{
2435 KOCatPrefs* cp = new KOCatPrefs(); 2439 KOCatPrefs* cp = new KOCatPrefs();
2436 cp->show(); 2440 cp->show();
2437 int w =cp->sizeHint().width() ; 2441 int w =cp->sizeHint().width() ;
2438 int h = cp->sizeHint().height() ; 2442 int h = cp->sizeHint().height() ;
2439 int dw = QApplication::desktop()->width(); 2443 int dw = QApplication::desktop()->width();
2440 int dh = QApplication::desktop()->height(); 2444 int dh = QApplication::desktop()->height();
2441 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2445 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2442 if ( !cp->exec() ) { 2446 if ( !cp->exec() ) {
2443 delete cp; 2447 delete cp;
2444 return; 2448 return;
2445 } 2449 }
2446 int count = 0; 2450 int count = 0;
2447 if ( cp->addCat() ) { 2451 if ( cp->addCat() ) {
2448 count = addCategories(); 2452 count = addCategories();
2449 if ( count ) { 2453 if ( count ) {
2450 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2454 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2451 writeSettings(); 2455 writeSettings();
2452 } else 2456 } else
2453 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 2457 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
2454 } else { 2458 } else {
2455 removeCategories(); 2459 removeCategories();
2456 updateView(); 2460 updateView();
2457 } 2461 }
2458 delete cp; 2462 delete cp;
2459} 2463}
2460 2464
2461void CalendarView::beamIncidence(Incidence * Inc) 2465void CalendarView::beamIncidence(Incidence * Inc)
2462{ 2466{
2463 QPtrList<Incidence> delSel ; 2467 QPtrList<Incidence> delSel ;
2464 delSel.append(Inc); 2468 delSel.append(Inc);
2465 beamIncidenceList( delSel ); 2469 beamIncidenceList( delSel );
2466} 2470}
2467void CalendarView::beamCalendar() 2471void CalendarView::beamCalendar()
2468{ 2472{
2469 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2473 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2470 //qDebug("beamCalendar() "); 2474 //qDebug("beamCalendar() ");
2471 beamIncidenceList( delSel ); 2475 beamIncidenceList( delSel );
2472} 2476}
2473void CalendarView::beamFilteredCalendar() 2477void CalendarView::beamFilteredCalendar()
2474{ 2478{
2475 QPtrList<Incidence> delSel = mCalendar->incidences(); 2479 QPtrList<Incidence> delSel = mCalendar->incidences();
2476 //qDebug("beamFilteredCalendar() "); 2480 //qDebug("beamFilteredCalendar() ");
2477 beamIncidenceList( delSel ); 2481 beamIncidenceList( delSel );
2478} 2482}
2479void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2483void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2480{ 2484{
2481 if ( beamDialog->exec () == QDialog::Rejected ) 2485 if ( beamDialog->exec () == QDialog::Rejected )
2482 return; 2486 return;
2483#ifdef DESKTOP_VERSION 2487#ifdef DESKTOP_VERSION
2484 QString fn = locateLocal( "tmp", "kopibeamfile" ); 2488 QString fn = locateLocal( "tmp", "kopibeamfile" );
2485#else 2489#else
2486 QString fn = "/tmp/kopibeamfile"; 2490 QString fn = "/tmp/kopibeamfile";
2487#endif 2491#endif
2488 QString mes; 2492 QString mes;
2489 bool createbup = true; 2493 bool createbup = true;
2490 if ( createbup ) { 2494 if ( createbup ) {
2491 QString description = "\n"; 2495 QString description = "\n";
2492 CalendarLocal* cal = new CalendarLocal(); 2496 CalendarLocal* cal = new CalendarLocal();
2493 if ( beamDialog->beamLocal() ) 2497 if ( beamDialog->beamLocal() )
2494 cal->setLocalTime(); 2498 cal->setLocalTime();
2495 else 2499 else
2496 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2500 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2497 Incidence *incidence = delSel.first(); 2501 Incidence *incidence = delSel.first();
2498 bool addText = false; 2502 bool addText = false;
2499 if ( delSel.count() < 10 ) 2503 if ( delSel.count() < 10 )
2500 addText = true; 2504 addText = true;
2501 else { 2505 else {
2502 description.sprintf(i18n(" %d items?"),delSel.count() ); 2506 description.sprintf(i18n(" %d items?"),delSel.count() );
2503 } 2507 }
2504 while ( incidence ) { 2508 while ( incidence ) {
2505 Incidence *in = incidence->clone(); 2509 Incidence *in = incidence->clone();
2506 if ( ! in->summary().isEmpty() ) { 2510 if ( ! in->summary().isEmpty() ) {
2507 in->setDescription(""); 2511 in->setDescription("");
2508 } else { 2512 } else {
2509 in->setSummary( in->description().left(20)); 2513 in->setSummary( in->description().left(20));
2510 in->setDescription(""); 2514 in->setDescription("");
2511 } 2515 }
2512 if ( addText ) 2516 if ( addText )
2513 description += in->summary() + "\n"; 2517 description += in->summary() + "\n";
2514 cal->addIncidence( in ); 2518 cal->addIncidence( in );
2515 incidence = delSel.next(); 2519 incidence = delSel.next();
2516 } 2520 }
2517 if ( beamDialog->beamVcal() ) { 2521 if ( beamDialog->beamVcal() ) {
2518 fn += ".vcs"; 2522 fn += ".vcs";
2519 FileStorage storage( cal, fn, new VCalFormat ); 2523 FileStorage storage( cal, fn, new VCalFormat );
2520 storage.save(); 2524 storage.save();
2521 } else { 2525 } else {
2522 fn += ".ics"; 2526 fn += ".ics";
2523 FileStorage storage( cal, fn, new ICalFormat( ) ); 2527 FileStorage storage( cal, fn, new ICalFormat( ) );
2524 storage.save(); 2528 storage.save();
2525 } 2529 }
2526 delete cal; 2530 delete cal;
2527 mes = i18n("KO/Pi: Ready for beaming"); 2531 mes = i18n("KO/Pi: Ready for beaming");
2528 topLevelWidget()->setCaption(mes); 2532 topLevelWidget()->setCaption(mes);
2529 KApplication::convert2latin1( fn ); 2533 KApplication::convert2latin1( fn );
2530#ifndef DESKTOP_VERSION 2534#ifndef DESKTOP_VERSION
2531 Ir *ir = new Ir( this ); 2535 Ir *ir = new Ir( this );
2532 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2536 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2533 ir->send( fn, description, "text/x-vCalendar" ); 2537 ir->send( fn, description, "text/x-vCalendar" );
2534#endif 2538#endif
2535 } 2539 }
2536} 2540}
2537void CalendarView::beamDone( Ir *ir ) 2541void CalendarView::beamDone( Ir *ir )
2538{ 2542{
2539#ifndef DESKTOP_VERSION 2543#ifndef DESKTOP_VERSION
2540 delete ir; 2544 delete ir;
2541#endif 2545#endif
2542 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 2546 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2543 topLevelWidget()->raise(); 2547 topLevelWidget()->raise();
2544} 2548}
2545 2549
2546void CalendarView::moveIncidence(Incidence * inc ) 2550void CalendarView::moveIncidence(Incidence * inc )
2547{ 2551{
2548 if ( !inc ) return; 2552 if ( !inc ) return;
2549 showDatePickerPopup(); 2553 showDatePickerPopup();
2550 mDatePickerMode = 2; 2554 mDatePickerMode = 2;
2551 mMoveIncidence = inc ; 2555 mMoveIncidence = inc ;
2552 QDate da; 2556 QDate da;
2553 if ( mMoveIncidence->type() == "Todo" ) { 2557 if ( mMoveIncidence->type() == "Todo" ) {
2554 Todo * to = (Todo *) mMoveIncidence; 2558 Todo * to = (Todo *) mMoveIncidence;
2555 if ( to->hasDueDate() ) 2559 if ( to->hasDueDate() )
2556 da = to->dtDue().date(); 2560 da = to->dtDue().date();
2557 else 2561 else
2558 da = QDate::currentDate(); 2562 da = QDate::currentDate();
2559 } else { 2563 } else {
2560 da = mMoveIncidence->dtStart().date(); 2564 da = mMoveIncidence->dtStart().date();
2561 } 2565 }
2562 //PENDING set date for recurring incidence to date of recurrence 2566 //PENDING set date for recurring incidence to date of recurrence
2563 //mMoveIncidenceOldDate; 2567 //mMoveIncidenceOldDate;
2564 mDatePicker->setDate( da ); 2568 mDatePicker->setDate( da );
2565} 2569}
2566void CalendarView::showDatePickerPopup() 2570void CalendarView::showDatePickerPopup()
2567{ 2571{
2568 if ( mDateFrame->isVisible() ) 2572 if ( mDateFrame->isVisible() )
2569 mDateFrame->hide(); 2573 mDateFrame->hide();
2570 else { 2574 else {
2571 int offX = 0, offY = 0; 2575 int offX = 0, offY = 0;
2572#ifdef DESKTOP_VERSION 2576#ifdef DESKTOP_VERSION
2573 int w =mDatePicker->sizeHint().width() ; 2577 int w =mDatePicker->sizeHint().width() ;
2574 int h = mDatePicker->sizeHint().height() ; 2578 int h = mDatePicker->sizeHint().height() ;
2575 int dw = topLevelWidget()->width(); 2579 int dw = topLevelWidget()->width();
2576 int dh = topLevelWidget()->height(); 2580 int dh = topLevelWidget()->height();
2577 offX = topLevelWidget()->x(); 2581 offX = topLevelWidget()->x();
2578 offY = topLevelWidget()->y(); 2582 offY = topLevelWidget()->y();
2579#else 2583#else
2580 int w =mDatePicker->sizeHint().width() ; 2584 int w =mDatePicker->sizeHint().width() ;
2581 int h = mDatePicker->sizeHint().height() ; 2585 int h = mDatePicker->sizeHint().height() ;
2582 int dw = QApplication::desktop()->width(); 2586 int dw = QApplication::desktop()->width();
2583 int dh = QApplication::desktop()->height(); 2587 int dh = QApplication::desktop()->height();
2584#endif 2588#endif
2585 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); 2589 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h );
2586 mDateFrame->show(); 2590 mDateFrame->show();
2587 } 2591 }
2588} 2592}
2589void CalendarView::showDatePicker( ) 2593void CalendarView::showDatePicker( )
2590{ 2594{
2591 showDatePickerPopup(); 2595 showDatePickerPopup();
2592 mDatePickerMode = 1; 2596 mDatePickerMode = 1;
2593 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2597 mDatePicker->setDate( mNavigator->selectedDates().first() );
2594} 2598}
2595 2599
2596void CalendarView::showEventEditor() 2600void CalendarView::showEventEditor()
2597{ 2601{
2598#ifdef DESKTOP_VERSION 2602#ifdef DESKTOP_VERSION
2599 int x,y,w,h; 2603 int x,y,w,h;
2600 x = mEventEditor->geometry().x(); 2604 x = mEventEditor->geometry().x();
2601 y = mEventEditor->geometry().y(); 2605 y = mEventEditor->geometry().y();
2602 w = mEventEditor->width(); 2606 w = mEventEditor->width();
2603 h = mEventEditor->height(); 2607 h = mEventEditor->height();
2604 mEventEditor->show(); 2608 mEventEditor->show();
2605 mEventEditor->setGeometry(x,y,w,h); 2609 mEventEditor->setGeometry(x,y,w,h);
2606#else 2610#else
2607 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 2611 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
2608 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2612 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2609 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 2613 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
2610 qApp->processEvents(); 2614 qApp->processEvents();
2611 delete mEventEditor; 2615 delete mEventEditor;
2612 mEventEditor = mDialogManager->getEventEditor(); 2616 mEventEditor = mDialogManager->getEventEditor();
2613 topLevelWidget()->setCaption( i18n("") ); 2617 topLevelWidget()->setCaption( i18n("") );
2614 } 2618 }
2615 mEventEditor->showMaximized(); 2619 mEventEditor->showMaximized();
2616#endif 2620#endif
2617} 2621}
2618void CalendarView::showTodoEditor() 2622void CalendarView::showTodoEditor()
2619{ 2623{
2620#ifdef DESKTOP_VERSION 2624#ifdef DESKTOP_VERSION
2621 int x,y,w,h; 2625 int x,y,w,h;
2622 x = mTodoEditor->geometry().x(); 2626 x = mTodoEditor->geometry().x();
2623 y = mTodoEditor->geometry().y(); 2627 y = mTodoEditor->geometry().y();
2624 w = mTodoEditor->width(); 2628 w = mTodoEditor->width();
2625 h = mTodoEditor->height(); 2629 h = mTodoEditor->height();
2626 mTodoEditor->show(); 2630 mTodoEditor->show();
2627 mTodoEditor->setGeometry(x,y,w,h); 2631 mTodoEditor->setGeometry(x,y,w,h);
2628#else 2632#else
2629 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 2633 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
2630 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2634 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2631 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 2635 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
2632 qApp->processEvents(); 2636 qApp->processEvents();
2633 delete mTodoEditor; 2637 delete mTodoEditor;
2634 mTodoEditor = mDialogManager->getTodoEditor(); 2638 mTodoEditor = mDialogManager->getTodoEditor();
2635 topLevelWidget()->setCaption( i18n("") ); 2639 topLevelWidget()->setCaption( i18n("") );
2636 } 2640 }
2637 mTodoEditor->showMaximized(); 2641 mTodoEditor->showMaximized();
2638#endif 2642#endif
2639} 2643}
2640 2644
2641void CalendarView::cloneIncidence() 2645void CalendarView::cloneIncidence()
2642{ 2646{
2643 Incidence *incidence = currentSelection(); 2647 Incidence *incidence = currentSelection();
2644 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2648 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2645 if ( incidence ) { 2649 if ( incidence ) {
2646 cloneIncidence(incidence); 2650 cloneIncidence(incidence);
2647 } 2651 }
2648} 2652}
2649void CalendarView::moveIncidence() 2653void CalendarView::moveIncidence()
2650{ 2654{
2651 Incidence *incidence = currentSelection(); 2655 Incidence *incidence = currentSelection();
2652 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2656 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2653 if ( incidence ) { 2657 if ( incidence ) {
2654 moveIncidence(incidence); 2658 moveIncidence(incidence);
2655 } 2659 }
2656} 2660}
2657void CalendarView::beamIncidence() 2661void CalendarView::beamIncidence()
2658{ 2662{
2659 Incidence *incidence = currentSelection(); 2663 Incidence *incidence = currentSelection();
2660 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2664 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2661 if ( incidence ) { 2665 if ( incidence ) {
2662 beamIncidence(incidence); 2666 beamIncidence(incidence);
2663 } 2667 }
2664} 2668}
2665void CalendarView::toggleCancelIncidence() 2669void CalendarView::toggleCancelIncidence()
2666{ 2670{
2667 Incidence *incidence = currentSelection(); 2671 Incidence *incidence = currentSelection();
2668 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2672 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2669 if ( incidence ) { 2673 if ( incidence ) {
2670 cancelIncidence(incidence); 2674 cancelIncidence(incidence);
2671 } 2675 }
2672} 2676}
2673 2677
2674 2678
2675void CalendarView::cancelIncidence(Incidence * inc ) 2679void CalendarView::cancelIncidence(Incidence * inc )
2676{ 2680{
2677 inc->setCancelled( ! inc->cancelled() ); 2681 inc->setCancelled( ! inc->cancelled() );
2678 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2682 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2679 updateView(); 2683 updateView();
2680} 2684}
2681void CalendarView::cloneIncidence(Incidence * orgInc ) 2685void CalendarView::cloneIncidence(Incidence * orgInc )
2682{ 2686{
2683 Incidence * newInc = orgInc->clone(); 2687 Incidence * newInc = orgInc->clone();
2684 newInc->recreate(); 2688 newInc->recreate();
2685 2689
2686 if ( newInc->type() == "Todo" ) { 2690 if ( newInc->type() == "Todo" ) {
2687 Todo* t = (Todo*) newInc; 2691 Todo* t = (Todo*) newInc;
2688 showTodoEditor(); 2692 showTodoEditor();
2689 mTodoEditor->editTodo( t ); 2693 mTodoEditor->editTodo( t );
2690 if ( mTodoEditor->exec() ) { 2694 if ( mTodoEditor->exec() ) {
2691 mCalendar->addTodo( t ); 2695 mCalendar->addTodo( t );
2692 updateView(); 2696 updateView();
2693 } else { 2697 } else {
2694 delete t; 2698 delete t;
2695 } 2699 }
2696 } 2700 }
2697 else { 2701 else {
2698 Event* e = (Event*) newInc; 2702 Event* e = (Event*) newInc;
2699 showEventEditor(); 2703 showEventEditor();
2700 mEventEditor->editEvent( e ); 2704 mEventEditor->editEvent( e );
2701 if ( mEventEditor->exec() ) { 2705 if ( mEventEditor->exec() ) {
2702 mCalendar->addEvent( e ); 2706 mCalendar->addEvent( e );
2703 updateView(); 2707 updateView();
2704 } else { 2708 } else {
2705 delete e; 2709 delete e;
2706 } 2710 }
2707 } 2711 }
2708 setActiveWindow(); 2712 setActiveWindow();
2709} 2713}
2710 2714
2711void CalendarView::newEvent() 2715void CalendarView::newEvent()
2712{ 2716{
2713 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2717 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2714 KOAgendaView *aView = mViewManager->agendaView(); 2718 KOAgendaView *aView = mViewManager->agendaView();
2715 if (aView) { 2719 if (aView) {
2716 if (aView->selectionStart().isValid()) { 2720 if (aView->selectionStart().isValid()) {
2717 if (aView->selectedIsAllDay()) { 2721 if (aView->selectedIsAllDay()) {
2718 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2722 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2719 } else { 2723 } else {
2720 newEvent(aView->selectionStart(),aView->selectionEnd()); 2724 newEvent(aView->selectionStart(),aView->selectionEnd());
2721 } 2725 }
2722 return; 2726 return;
2723 } 2727 }
2724 } 2728 }
2725 2729
2726 QDate date = mNavigator->selectedDates().first(); 2730 QDate date = mNavigator->selectedDates().first();
2727 QDateTime current = QDateTime::currentDateTime(); 2731 QDateTime current = QDateTime::currentDateTime();
2728 if ( date <= current.date() ) { 2732 if ( date <= current.date() ) {
2729 int hour = current.time().hour() +1; 2733 int hour = current.time().hour() +1;
2730 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2734 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2731 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2735 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2732 } else 2736 } else
2733 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2737 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2734 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2738 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2735 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2739 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2736} 2740}
2737 2741
2738void CalendarView::newEvent(QDateTime fh) 2742void CalendarView::newEvent(QDateTime fh)
2739{ 2743{
2740 newEvent(fh, 2744 newEvent(fh,
2741 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2745 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2742} 2746}
2743 2747
2744void CalendarView::newEvent(QDate dt) 2748void CalendarView::newEvent(QDate dt)
2745{ 2749{
2746 newEvent(QDateTime(dt, QTime(0,0,0)), 2750 newEvent(QDateTime(dt, QTime(0,0,0)),
2747 QDateTime(dt, QTime(0,0,0)), true); 2751 QDateTime(dt, QTime(0,0,0)), true);
2748} 2752}
2749void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) 2753void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint)
2750{ 2754{
2751 newEvent(fromHint, toHint, false); 2755 newEvent(fromHint, toHint, false);
2752} 2756}
2753void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2757void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2754{ 2758{
2755 2759
2756 showEventEditor(); 2760 showEventEditor();
2757 mEventEditor->newEvent(fromHint,toHint,allDay); 2761 mEventEditor->newEvent(fromHint,toHint,allDay);
2758 if ( mFilterView->filtersEnabled() ) { 2762 if ( mFilterView->filtersEnabled() ) {
2759 CalFilter *filter = mFilterView->selectedFilter(); 2763 CalFilter *filter = mFilterView->selectedFilter();
2760 if (filter && filter->showCategories()) { 2764 if (filter && filter->showCategories()) {
2761 mEventEditor->setCategories(filter->categoryList().join(",") ); 2765 mEventEditor->setCategories(filter->categoryList().join(",") );
2762 } 2766 }
2763 if ( filter ) 2767 if ( filter )
2764 mEventEditor->setSecrecy( filter->getSecrecy() ); 2768 mEventEditor->setSecrecy( filter->getSecrecy() );
2765 } 2769 }
2766 mEventEditor->exec(); 2770 mEventEditor->exec();
2767 setActiveWindow(); 2771 setActiveWindow();
2768} 2772}
2769void CalendarView::todoAdded(Todo * t) 2773void CalendarView::todoAdded(Todo * t)
2770{ 2774{
2771 2775
2772 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2776 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2773 updateTodoViews(); 2777 updateTodoViews();
2774} 2778}
2775void CalendarView::todoChanged(Todo * t) 2779void CalendarView::todoChanged(Todo * t)
2776{ 2780{
2777 emit todoModified( t, 4 ); 2781 emit todoModified( t, 4 );
2778 // updateTodoViews(); 2782 // updateTodoViews();
2779} 2783}
2780void CalendarView::todoToBeDeleted(Todo *) 2784void CalendarView::todoToBeDeleted(Todo *)
2781{ 2785{
2782 //qDebug("todoToBeDeleted(Todo *) "); 2786 //qDebug("todoToBeDeleted(Todo *) ");
2783 updateTodoViews(); 2787 updateTodoViews();
2784} 2788}
2785void CalendarView::todoDeleted() 2789void CalendarView::todoDeleted()
2786{ 2790{
2787 //qDebug(" todoDeleted()"); 2791 //qDebug(" todoDeleted()");
2788 updateTodoViews(); 2792 updateTodoViews();
2789} 2793}
2790 2794
2791 2795
2792void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) 2796void CalendarView::newTodoDateTime( QDateTime dt, bool allday )
2793{ 2797{
2794 showTodoEditor(); 2798 showTodoEditor();
2795 mTodoEditor->newTodo(dt,0,allday); 2799 mTodoEditor->newTodo(dt,0,allday);
2796 if ( mFilterView->filtersEnabled() ) { 2800 if ( mFilterView->filtersEnabled() ) {
2797 CalFilter *filter = mFilterView->selectedFilter(); 2801 CalFilter *filter = mFilterView->selectedFilter();
2798 if (filter && filter->showCategories()) { 2802 if (filter && filter->showCategories()) {
2799 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2803 mTodoEditor->setCategories(filter->categoryList().join(",") );
2800 } 2804 }
2801 if ( filter ) 2805 if ( filter )
2802 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2806 mTodoEditor->setSecrecy( filter->getSecrecy() );
2803 } 2807 }
2804 mTodoEditor->exec(); 2808 mTodoEditor->exec();
2805 setActiveWindow(); 2809 setActiveWindow();
2806} 2810}
2807 2811
2808void CalendarView::newTodo() 2812void CalendarView::newTodo()
2809{ 2813{
2810 newTodoDateTime( QDateTime(),true ); 2814 newTodoDateTime( QDateTime(),true );
2811} 2815}
2812 2816
2813void CalendarView::newSubTodo() 2817void CalendarView::newSubTodo()
2814{ 2818{
2815 Todo *todo = selectedTodo(); 2819 Todo *todo = selectedTodo();
2816 if ( todo ) newSubTodo( todo ); 2820 if ( todo ) newSubTodo( todo );
2817} 2821}
2818 2822
2819void CalendarView::newSubTodo(Todo *parentEvent) 2823void CalendarView::newSubTodo(Todo *parentEvent)
2820{ 2824{
2821 2825
2822 showTodoEditor(); 2826 showTodoEditor();
2823 mTodoEditor->newTodo(QDateTime(),parentEvent,true); 2827 mTodoEditor->newTodo(QDateTime(),parentEvent,true);
2824 mTodoEditor->exec(); 2828 mTodoEditor->exec();
2825 setActiveWindow(); 2829 setActiveWindow();
2826} 2830}
2827 2831
2828void CalendarView::newFloatingEvent() 2832void CalendarView::newFloatingEvent()
2829{ 2833{
2830 DateList tmpList = mNavigator->selectedDates(); 2834 DateList tmpList = mNavigator->selectedDates();
2831 QDate date = tmpList.first(); 2835 QDate date = tmpList.first();
2832 2836
2833 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2837 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2834 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2838 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2835} 2839}
2836 2840
2837 2841
2838void CalendarView::editEvent( Event *event ) 2842void CalendarView::editEvent( Event *event )
2839{ 2843{
2840 2844
2841 if ( !event ) return; 2845 if ( !event ) return;
2842 if ( event->isReadOnly() ) { 2846 if ( event->isReadOnly() ) {
2843 showEvent( event ); 2847 showEvent( event );
2844 return; 2848 return;
2845 } 2849 }
2846 showEventEditor(); 2850 showEventEditor();
2847 mEventEditor->editEvent( event , mFlagEditDescription); 2851 mEventEditor->editEvent( event , mFlagEditDescription);
2848 mEventEditor->exec(); 2852 mEventEditor->exec();
2849 setActiveWindow(); 2853 setActiveWindow();
2850 2854
2851} 2855}
2852void CalendarView::editJournal( Journal *jour ) 2856void CalendarView::editJournal( Journal *jour )
2853{ 2857{
2854 if ( !jour ) return; 2858 if ( !jour ) return;
2855 mDialogManager->hideSearchDialog(); 2859 mDialogManager->hideSearchDialog();
2856 mViewManager->showJournalView(); 2860 mViewManager->showJournalView();
2857 mNavigator->slotDaySelect( jour->dtStart().date() ); 2861 mNavigator->slotDaySelect( jour->dtStart().date() );
2858} 2862}
2859void CalendarView::editTodo( Todo *todo ) 2863void CalendarView::editTodo( Todo *todo )
2860{ 2864{
2861 if ( !todo ) return; 2865 if ( !todo ) return;
2862 2866
2863 if ( todo->isReadOnly() ) { 2867 if ( todo->isReadOnly() ) {
2864 showTodo( todo ); 2868 showTodo( todo );
2865 return; 2869 return;
2866 } 2870 }
2867 showTodoEditor(); 2871 showTodoEditor();
2868 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2872 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2869 mTodoEditor->exec(); 2873 mTodoEditor->exec();
2870 setActiveWindow(); 2874 setActiveWindow();
2871 2875
2872} 2876}
2873 2877
2874KOEventViewerDialog* CalendarView::getEventViewerDialog() 2878KOEventViewerDialog* CalendarView::getEventViewerDialog()
2875{ 2879{
2876 if ( !mEventViewerDialog ) { 2880 if ( !mEventViewerDialog ) {
2877 mEventViewerDialog = new KOEventViewerDialog(0); 2881 mEventViewerDialog = new KOEventViewerDialog(0);
2878 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2882 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2879 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2883 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2880 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2884 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2881 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2885 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2882 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2886 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2883 viewManager(), SLOT( showAgendaView( bool ) ) ); 2887 viewManager(), SLOT( showAgendaView( bool ) ) );
2884 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), 2888 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()),
2885 this, SLOT( slotViewerClosed() ) ); 2889 this, SLOT( slotViewerClosed() ) );
2886 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), 2890 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ),
2887 this, SLOT( todoChanged(Todo *) ) ); 2891 this, SLOT( todoChanged(Todo *) ) );
2888 mEventViewerDialog->resize( 640, 480 ); 2892 mEventViewerDialog->resize( 640, 480 );
2889 2893
2890 } 2894 }
2891 return mEventViewerDialog; 2895 return mEventViewerDialog;
2892} 2896}
2893void CalendarView::showEvent(Event *event) 2897void CalendarView::showEvent(Event *event)
2894{ 2898{
2895 getEventViewerDialog()->setEvent(event); 2899 getEventViewerDialog()->setEvent(event);
diff --git a/korganizer/kodialogmanager.cpp b/korganizer/kodialogmanager.cpp
index a8652ea..c927b37 100644
--- a/korganizer/kodialogmanager.cpp
+++ b/korganizer/kodialogmanager.cpp
@@ -1,350 +1,352 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Copyright (c) 2001 4 Copyright (c) 2001
5 Cornelius Schumacher <schumacher@kde.org> 5 Cornelius Schumacher <schumacher@kde.org>
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 10 (at your option) any later version.
11 11
12 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#include <libkdepim/categoryeditdialog.h> 22#include <libkdepim/categoryeditdialog.h>
23 23
24#include "calendarview.h" 24#include "calendarview.h"
25#include "incomingdialog.h" 25#include "incomingdialog.h"
26#include "outgoingdialog.h" 26#include "outgoingdialog.h"
27#include "koprefsdialog.h" 27#include "koprefsdialog.h"
28#include "koeventeditor.h" 28#include "koeventeditor.h"
29#include "koprefs.h" 29#include "koprefs.h"
30#include "datenavigator.h" 30#include "datenavigator.h"
31#include "kotodoeditor.h" 31#include "kotodoeditor.h"
32#include "searchdialog.h" 32#include "searchdialog.h"
33#include "filtereditdialog.h" 33#include "filtereditdialog.h"
34#ifndef KORG_NOPLUGINS 34#ifndef KORG_NOPLUGINS
35#include "plugindialog.h" 35#include "plugindialog.h"
36#endif 36#endif
37#ifndef KORG_NOARCHIVE 37#ifndef KORG_NOARCHIVE
38#include "archivedialog.h" 38#include "archivedialog.h"
39#endif 39#endif
40 40
41#include "kconfig.h" 41#include "kconfig.h"
42#include "kodialogmanager.h" 42#include "kodialogmanager.h"
43#include <kapplication.h>
43 44
44KODialogManager::KODialogManager( CalendarView *mainView ) : 45KODialogManager::KODialogManager( CalendarView *mainView ) :
45 QObject(), mMainView( mainView ) 46 QObject(), mMainView( mainView )
46{ 47{
47 mOutgoingDialog = 0; 48 mOutgoingDialog = 0;
48 mIncomingDialog = 0; 49 mIncomingDialog = 0;
49 mOptionsDialog = 0; 50 mOptionsDialog = 0;
50 mSearchDialog = 0; 51 mSearchDialog = 0;
51 mArchiveDialog = 0; 52 mArchiveDialog = 0;
52 mFilterEditDialog = 0; 53 mFilterEditDialog = 0;
53 mPluginDialog = 0; 54 mPluginDialog = 0;
54 55
55 // mCategoryEditDialog = new KPIM::CategoryEditDialog(KOPrefs::instance(),mMainView); 56 // mCategoryEditDialog = new KPIM::CategoryEditDialog(KOPrefs::instance(),mMainView);
56 //KOGlobals::fitDialogToScreen( mCategoryEditDialog ); 57 //KOGlobals::fitDialogToScreen( mCategoryEditDialog );
57} 58}
58 59
59KODialogManager::~KODialogManager() 60KODialogManager::~KODialogManager()
60{ 61{
61 delete mOutgoingDialog; 62 delete mOutgoingDialog;
62 delete mIncomingDialog; 63 delete mIncomingDialog;
63 delete mOptionsDialog; 64 delete mOptionsDialog;
64 delete mSearchDialog; 65 delete mSearchDialog;
65#ifndef KORG_NOARCHIVE 66#ifndef KORG_NOARCHIVE
66 delete mArchiveDialog; 67 delete mArchiveDialog;
67#endif 68#endif
68 delete mFilterEditDialog; 69 delete mFilterEditDialog;
69#ifndef KORG_NOPLUGINS 70#ifndef KORG_NOPLUGINS
70 delete mPluginDialog; 71 delete mPluginDialog;
71#endif 72#endif
72} 73}
73 74
74OutgoingDialog *KODialogManager::outgoingDialog() 75OutgoingDialog *KODialogManager::outgoingDialog()
75{ 76{
76 createOutgoingDialog(); 77 createOutgoingDialog();
77 return mOutgoingDialog; 78 return mOutgoingDialog;
78} 79}
79 80
80void KODialogManager::createOutgoingDialog() 81void KODialogManager::createOutgoingDialog()
81{ 82{
82 if (!mOutgoingDialog) { 83 if (!mOutgoingDialog) {
83 mOutgoingDialog = new OutgoingDialog(mMainView->calendar(),mMainView); 84 mOutgoingDialog = new OutgoingDialog(mMainView->calendar(),mMainView);
84 if (mIncomingDialog) mIncomingDialog->setOutgoingDialog(mOutgoingDialog); 85 if (mIncomingDialog) mIncomingDialog->setOutgoingDialog(mOutgoingDialog);
85 connect(mOutgoingDialog,SIGNAL(numMessagesChanged(int)), 86 connect(mOutgoingDialog,SIGNAL(numMessagesChanged(int)),
86 mMainView,SIGNAL(numOutgoingChanged(int))); 87 mMainView,SIGNAL(numOutgoingChanged(int)));
87 } 88 }
88} 89}
89 90
90void KODialogManager::showOptionsDialog( bool showSync ) 91void KODialogManager::showOptionsDialog( bool showSync )
91{ 92{
92 93
93 if (!mOptionsDialog) { 94 if (!mOptionsDialog) {
94 mOptionsDialog = new KOPrefsDialog(mMainView); 95 mOptionsDialog = new KOPrefsDialog(mMainView);
95 //mOptionsDialog->readConfig(); 96 //mOptionsDialog->readConfig();
96 connect(mOptionsDialog,SIGNAL(configChanged()), 97 connect(mOptionsDialog,SIGNAL(configChanged()),
97 mMainView,SLOT(updateConfig())); 98 mMainView,SLOT(updateConfig()));
98 //connect(mCategoryEditDialog,SIGNAL(categoryConfigChanged()), 99 //connect(mCategoryEditDialog,SIGNAL(categoryConfigChanged()),
99 // mOptionsDialog,SLOT(updateCategories())); 100 // mOptionsDialog,SLOT(updateCategories()));
100 101
101 } 102 }
102 mOptionsDialog->readConfig(); 103 mOptionsDialog->readConfig();
103#ifndef DESKTOP_VERSION 104#ifndef DESKTOP_VERSION
104 mOptionsDialog->showMaximized(); 105 mOptionsDialog->showMaximized();
105#else 106#else
106 mOptionsDialog->show(); 107 mOptionsDialog->show();
107#endif 108#endif
108 if ( showSync ) 109 if ( showSync )
109 mOptionsDialog->showSyncPage(); 110 mOptionsDialog->showSyncPage();
110 mOptionsDialog->exec(); 111 mOptionsDialog->exec();
111 112
112} 113}
113void KODialogManager::showSyncOptions() 114void KODialogManager::showSyncOptions()
114{ 115{
115 showOptionsDialog( true ); 116 showOptionsDialog( true );
116 117
117} 118}
118void KODialogManager::showOutgoingDialog() 119void KODialogManager::showOutgoingDialog()
119{ 120{
120 createOutgoingDialog(); 121 createOutgoingDialog();
121 mOutgoingDialog->show(); 122 mOutgoingDialog->show();
122 mOutgoingDialog->raise(); 123 mOutgoingDialog->raise();
123} 124}
124 125
125IncomingDialog *KODialogManager::incomingDialog() 126IncomingDialog *KODialogManager::incomingDialog()
126{ 127{
127 createOutgoingDialog(); 128 createOutgoingDialog();
128 if (!mIncomingDialog) { 129 if (!mIncomingDialog) {
129 mIncomingDialog = new IncomingDialog(mMainView->calendar(),mOutgoingDialog,mMainView); 130 mIncomingDialog = new IncomingDialog(mMainView->calendar(),mOutgoingDialog,mMainView);
130 connect(mIncomingDialog,SIGNAL(numMessagesChanged(int)), 131 connect(mIncomingDialog,SIGNAL(numMessagesChanged(int)),
131 mMainView,SIGNAL(numIncomingChanged(int))); 132 mMainView,SIGNAL(numIncomingChanged(int)));
132 connect(mIncomingDialog,SIGNAL(calendarUpdated()), 133 connect(mIncomingDialog,SIGNAL(calendarUpdated()),
133 mMainView,SLOT(updateView())); 134 mMainView,SLOT(updateView()));
134 } 135 }
135 return mIncomingDialog; 136 return mIncomingDialog;
136} 137}
137 138
138void KODialogManager::createIncomingDialog() 139void KODialogManager::createIncomingDialog()
139{ 140{
140 createOutgoingDialog(); 141 createOutgoingDialog();
141 if (!mIncomingDialog) { 142 if (!mIncomingDialog) {
142 mIncomingDialog = new IncomingDialog(mMainView->calendar(),mOutgoingDialog,mMainView); 143 mIncomingDialog = new IncomingDialog(mMainView->calendar(),mOutgoingDialog,mMainView);
143 connect(mIncomingDialog,SIGNAL(numMessagesChanged(int)), 144 connect(mIncomingDialog,SIGNAL(numMessagesChanged(int)),
144 mMainView,SIGNAL(numIncomingChanged(int))); 145 mMainView,SIGNAL(numIncomingChanged(int)));
145 connect(mIncomingDialog,SIGNAL(calendarUpdated()), 146 connect(mIncomingDialog,SIGNAL(calendarUpdated()),
146 mMainView,SLOT(updateView())); 147 mMainView,SLOT(updateView()));
147 } 148 }
148} 149}
149 150
150void KODialogManager::showIncomingDialog() 151void KODialogManager::showIncomingDialog()
151{ 152{
152 createIncomingDialog(); 153 createIncomingDialog();
153 mIncomingDialog->show(); 154 mIncomingDialog->show();
154 mIncomingDialog->raise(); 155 mIncomingDialog->raise();
155} 156}
156/* 157/*
157void KODialogManager::showCategoryEditDialog() 158void KODialogManager::showCategoryEditDialog()
158{ 159{
159 mCategoryEditDialog->show(); 160 mCategoryEditDialog->show();
160} 161}
161*/ 162*/
162void KODialogManager::hideSearchDialog() 163void KODialogManager::hideSearchDialog()
163{ 164{
164 if (mSearchDialog) 165 if (mSearchDialog)
165 mSearchDialog->hide(); 166 mSearchDialog->hide();
166} 167}
167 168
168void KODialogManager::showSearchDialog() 169void KODialogManager::showSearchDialog()
169{ 170{
170 if (!mSearchDialog) { 171 if (!mSearchDialog) {
171 mSearchDialog = new SearchDialog(mMainView->calendar(),mMainView); 172 mSearchDialog = new SearchDialog(mMainView->calendar(),mMainView);
172 KOListView * lview = mSearchDialog->listview(); 173 KOListView * lview = mSearchDialog->listview();
173 174
174 connect(lview, SIGNAL(showIncidenceSignal(Incidence *)), 175 connect(lview, SIGNAL(showIncidenceSignal(Incidence *)),
175 mMainView, SLOT(showIncidence(Incidence *))); 176 mMainView, SLOT(showIncidence(Incidence *)));
176 connect(lview, SIGNAL(editIncidenceSignal(Incidence *)), 177 connect(lview, SIGNAL(editIncidenceSignal(Incidence *)),
177 mMainView, SLOT(editIncidence(Incidence *))); 178 mMainView, SLOT(editIncidence(Incidence *)));
178 connect(lview, SIGNAL(deleteIncidenceSignal(Incidence *)), 179 connect(lview, SIGNAL(deleteIncidenceSignal(Incidence *)),
179 mMainView, SLOT(deleteIncidence(Incidence *))); 180 mMainView, SLOT(deleteIncidence(Incidence *)));
180 connect(lview, SIGNAL(cloneIncidenceSignal(Incidence *)), 181 connect(lview, SIGNAL(cloneIncidenceSignal(Incidence *)),
181 mMainView, SLOT(cloneIncidence(Incidence *))); 182 mMainView, SLOT(cloneIncidence(Incidence *)));
182 connect(lview, SIGNAL(beamIncidenceSignal(Incidence *)), 183 connect(lview, SIGNAL(beamIncidenceSignal(Incidence *)),
183 mMainView, SLOT(beamIncidence(Incidence *))); 184 mMainView, SLOT(beamIncidence(Incidence *)));
184 connect(lview, SIGNAL(moveIncidenceSignal(Incidence *)), 185 connect(lview, SIGNAL(moveIncidenceSignal(Incidence *)),
185 mMainView, SLOT(moveIncidence(Incidence *))); 186 mMainView, SLOT(moveIncidence(Incidence *)));
186 connect(lview, SIGNAL(beamIncidenceList(QPtrList<Incidence> )), 187 connect(lview, SIGNAL(beamIncidenceList(QPtrList<Incidence> )),
187 mMainView, SLOT(beamIncidenceList(QPtrList<Incidence> ))); 188 mMainView, SLOT(beamIncidenceList(QPtrList<Incidence> )));
188 189
189 connect(mMainView, SIGNAL(configChanged()), mSearchDialog, SLOT(updateConfig())); 190 connect(mMainView, SIGNAL(configChanged()), mSearchDialog, SLOT(updateConfig()));
190 connect(mMainView, SIGNAL(updateSearchDialog()), mSearchDialog, SLOT(updateList())); 191 connect(mMainView, SIGNAL(updateSearchDialog()), mSearchDialog, SLOT(updateList()));
191 // connect( lview, SIGNAL( incidenceSelected( Incidence * ) ), 192 // connect( lview, SIGNAL( incidenceSelected( Incidence * ) ),
192 // mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 193 // mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
193#ifndef DESKTOP_VERSION 194#ifndef DESKTOP_VERSION
194 mSearchDialog->setMaximumSize( QApplication::desktop()->size()); 195 mSearchDialog->setMaximumSize( QApplication::desktop()->size());
195 mSearchDialog->showMaximized(); 196 mSearchDialog->showMaximized();
196#else 197#else
197 KConfig *config = KOGlobals::config(); 198 KConfig *config = KOGlobals::config();
198 config->setGroup("WidgetLayout"); 199 config->setGroup("WidgetLayout");
199 QStringList list; 200 QStringList list;
200 list = config->readListEntry("SearchLayout"); 201 list = config->readListEntry("SearchLayout");
201 int x,y,w,h; 202 int x,y,w,h;
202 if ( ! list.isEmpty() ) { 203 if ( ! list.isEmpty() ) {
203 x = list[0].toInt(); 204 x = list[0].toInt();
204 y = list[1].toInt(); 205 y = list[1].toInt();
205 w = list[2].toInt(); 206 w = list[2].toInt();
206 h = list[3].toInt(); 207 h = list[3].toInt();
208 KApplication::testCoords( &x,&y,&w,&h );
207 mSearchDialog->setGeometry(x,y,w,h); 209 mSearchDialog->setGeometry(x,y,w,h);
208 210
209 } 211 }
210 212
211#endif 213#endif
212 } 214 }
213 // make sure the widget is on top again 215 // make sure the widget is on top again
214#ifdef DESKTOP_VERSION 216#ifdef DESKTOP_VERSION
215 mSearchDialog->show(); 217 mSearchDialog->show();
216#else 218#else
217 mSearchDialog->setMaximumSize( QApplication::desktop()->size()); 219 mSearchDialog->setMaximumSize( QApplication::desktop()->size());
218 mSearchDialog->showMaximized(); 220 mSearchDialog->showMaximized();
219#endif 221#endif
220 mSearchDialog->raise(); 222 mSearchDialog->raiseAndSelect();
221} 223}
222 224
223SearchDialog * KODialogManager::getSearchDialog() 225SearchDialog * KODialogManager::getSearchDialog()
224{ 226{
225 return mSearchDialog; 227 return mSearchDialog;
226} 228}
227void KODialogManager::showArchiveDialog() 229void KODialogManager::showArchiveDialog()
228{ 230{
229#ifndef KORG_NOARCHIVE 231#ifndef KORG_NOARCHIVE
230 if (!mArchiveDialog) { 232 if (!mArchiveDialog) {
231 mArchiveDialog = new ArchiveDialog(mMainView->calendar(),mMainView); 233 mArchiveDialog = new ArchiveDialog(mMainView->calendar(),mMainView);
232 connect(mArchiveDialog,SIGNAL(eventsDeleted()), 234 connect(mArchiveDialog,SIGNAL(eventsDeleted()),
233 mMainView,SLOT(updateView())); 235 mMainView,SLOT(updateView()));
234 } 236 }
235 mArchiveDialog->show(); 237 mArchiveDialog->show();
236 mArchiveDialog->raise(); 238 mArchiveDialog->raise();
237 239
238 // Workaround. 240 // Workaround.
239 QApplication::restoreOverrideCursor(); 241 QApplication::restoreOverrideCursor();
240#endif 242#endif
241} 243}
242 244
243void KODialogManager::showFilterEditDialog(QPtrList<CalFilter> *filters) 245void KODialogManager::showFilterEditDialog(QPtrList<CalFilter> *filters)
244{ 246{
245 if (!mFilterEditDialog) { 247 if (!mFilterEditDialog) {
246 mFilterEditDialog = new FilterEditDialog(filters,mMainView); 248 mFilterEditDialog = new FilterEditDialog(filters,mMainView);
247 connect(mFilterEditDialog,SIGNAL(filterChanged()), 249 connect(mFilterEditDialog,SIGNAL(filterChanged()),
248 mMainView,SLOT(filterEdited())); 250 mMainView,SLOT(filterEdited()));
249 251
250 } 252 }
251 253
252#ifndef DESKTOP_VERSION 254#ifndef DESKTOP_VERSION
253 mFilterEditDialog->showMaximized(); 255 mFilterEditDialog->showMaximized();
254#else 256#else
255 mFilterEditDialog->show(); 257 mFilterEditDialog->show();
256#endif 258#endif
257 mFilterEditDialog->raise(); 259 mFilterEditDialog->raise();
258} 260}
259 261
260void KODialogManager::showPluginDialog() 262void KODialogManager::showPluginDialog()
261{ 263{
262#ifndef KORG_NOPLUGINS 264#ifndef KORG_NOPLUGINS
263 if (!mPluginDialog) { 265 if (!mPluginDialog) {
264 mPluginDialog = new PluginDialog(mMainView); 266 mPluginDialog = new PluginDialog(mMainView);
265 connect(mPluginDialog,SIGNAL(configChanged()), 267 connect(mPluginDialog,SIGNAL(configChanged()),
266 mMainView,SLOT(updateConfig())); 268 mMainView,SLOT(updateConfig()));
267 } 269 }
268 mPluginDialog->show(); 270 mPluginDialog->show();
269 mPluginDialog->raise(); 271 mPluginDialog->raise();
270#endif 272#endif
271} 273}
272 274
273KOEventEditor *KODialogManager::getEventEditor() 275KOEventEditor *KODialogManager::getEventEditor()
274{ 276{
275 KOEventEditor *eventEditor = new KOEventEditor( mMainView->calendar(), 277 KOEventEditor *eventEditor = new KOEventEditor( mMainView->calendar(),
276 mMainView ); 278 mMainView );
277 279
278 connect(eventEditor,SIGNAL(eventAdded(Event *)), 280 connect(eventEditor,SIGNAL(eventAdded(Event *)),
279 mMainView,SLOT(eventAdded(Event *))); 281 mMainView,SLOT(eventAdded(Event *)));
280 connect(eventEditor,SIGNAL(eventChanged(Event *)), 282 connect(eventEditor,SIGNAL(eventChanged(Event *)),
281 mMainView,SLOT(eventChanged(Event *))); 283 mMainView,SLOT(eventChanged(Event *)));
282 connect(eventEditor,SIGNAL(eventDeleted()), 284 connect(eventEditor,SIGNAL(eventDeleted()),
283 mMainView,SLOT(eventDeleted())); 285 mMainView,SLOT(eventDeleted()));
284 connect(eventEditor,SIGNAL(deleteAttendee(Incidence *)), 286 connect(eventEditor,SIGNAL(deleteAttendee(Incidence *)),
285 mMainView,SLOT(schedule_cancel(Incidence *))); 287 mMainView,SLOT(schedule_cancel(Incidence *)));
286 connect( eventEditor, SIGNAL(jumpToTime( const QDate &)), 288 connect( eventEditor, SIGNAL(jumpToTime( const QDate &)),
287 mMainView->dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 289 mMainView->dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
288 connect( eventEditor, SIGNAL( showAgendaView( bool)), 290 connect( eventEditor, SIGNAL( showAgendaView( bool)),
289 mMainView->viewManager(), SLOT( showAgendaView( bool) ) ); 291 mMainView->viewManager(), SLOT( showAgendaView( bool) ) );
290 292
291 // connect(mCategoryEditDialog,SIGNAL(categoryConfigChanged()), 293 // connect(mCategoryEditDialog,SIGNAL(categoryConfigChanged()),
292 // eventEditor,SLOT(updateCategoryConfig())); 294 // eventEditor,SLOT(updateCategoryConfig()));
293 // connect(eventEditor,SIGNAL(editCategories()), 295 // connect(eventEditor,SIGNAL(editCategories()),
294 // mCategoryEditDialog,SLOT(show())); 296 // mCategoryEditDialog,SLOT(show()));
295 connect(eventEditor,SIGNAL(dialogClose(Incidence*)), 297 connect(eventEditor,SIGNAL(dialogClose(Incidence*)),
296 mMainView,SLOT(dialogClosing(Incidence*))); 298 mMainView,SLOT(dialogClosing(Incidence*)));
297 299
298 //connect(mMainView,SIGNAL(closingDown()),eventEditor,SLOT(reject())); 300 //connect(mMainView,SIGNAL(closingDown()),eventEditor,SLOT(reject()));
299 301
300#ifndef DESKTOP_VERSION 302#ifndef DESKTOP_VERSION
301 eventEditor->resize( QApplication::desktop()->width() -20, 100 ); 303 eventEditor->resize( QApplication::desktop()->width() -20, 100 );
302#endif 304#endif
303 return eventEditor; 305 return eventEditor;
304} 306}
305 307
306KOTodoEditor *KODialogManager::getTodoEditor() 308KOTodoEditor *KODialogManager::getTodoEditor()
307{ 309{
308 KOTodoEditor *todoEditor = new KOTodoEditor( mMainView->calendar(), 310 KOTodoEditor *todoEditor = new KOTodoEditor( mMainView->calendar(),
309 mMainView ); 311 mMainView );
310 312
311 // connect(mCategoryEditDialog,SIGNAL(categoryConfigChanged()), 313 // connect(mCategoryEditDialog,SIGNAL(categoryConfigChanged()),
312 // todoEditor,SLOT(updateCategoryConfig())); 314 // todoEditor,SLOT(updateCategoryConfig()));
313 // connect(todoEditor,SIGNAL(editCategories()),mCategoryEditDialog,SLOT(show())); 315 // connect(todoEditor,SIGNAL(editCategories()),mCategoryEditDialog,SLOT(show()));
314 316
315 connect(todoEditor,SIGNAL(todoAdded(Todo *)), 317 connect(todoEditor,SIGNAL(todoAdded(Todo *)),
316 mMainView,SLOT(todoAdded(Todo *))); 318 mMainView,SLOT(todoAdded(Todo *)));
317 connect(todoEditor,SIGNAL(todoChanged(Todo *)), 319 connect(todoEditor,SIGNAL(todoChanged(Todo *)),
318 mMainView,SLOT(todoChanged(Todo *))); 320 mMainView,SLOT(todoChanged(Todo *)));
319 connect(todoEditor,SIGNAL(todoDeleted()), 321 connect(todoEditor,SIGNAL(todoDeleted()),
320 mMainView,SLOT(todoDeleted())); 322 mMainView,SLOT(todoDeleted()));
321 connect(todoEditor,SIGNAL(dialogClose(Incidence*)), 323 connect(todoEditor,SIGNAL(dialogClose(Incidence*)),
322 mMainView,SLOT(dialogClosing(Incidence*))); 324 mMainView,SLOT(dialogClosing(Incidence*)));
323 connect( todoEditor, SIGNAL(jumpToTime( const QDate &)), 325 connect( todoEditor, SIGNAL(jumpToTime( const QDate &)),
324 mMainView->dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 326 mMainView->dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
325 connect( todoEditor, SIGNAL( showAgendaView( bool)), 327 connect( todoEditor, SIGNAL( showAgendaView( bool)),
326 mMainView->viewManager(), SLOT( showAgendaView( bool) ) ); 328 mMainView->viewManager(), SLOT( showAgendaView( bool) ) );
327 // connect(todoEditor,SIGNAL(deleteAttendee(Incidence *)), 329 // connect(todoEditor,SIGNAL(deleteAttendee(Incidence *)),
328 // mMainView,SLOT(schedule_cancel(Incidence *))); 330 // mMainView,SLOT(schedule_cancel(Incidence *)));
329 //connect(mMainView,SIGNAL(closingDown()),todoEditor,SLOT(reject())); 331 //connect(mMainView,SIGNAL(closingDown()),todoEditor,SLOT(reject()));
330#ifndef DESKTOP_VERSION 332#ifndef DESKTOP_VERSION
331 todoEditor->resize( QApplication::desktop()->width() -20, 100 ); 333 todoEditor->resize( QApplication::desktop()->width() -20, 100 );
332#endif 334#endif
333 return todoEditor; 335 return todoEditor;
334} 336}
335 337
336void KODialogManager::updateSearchDialog() 338void KODialogManager::updateSearchDialog()
337{ 339{
338 if (mSearchDialog) mSearchDialog->updateView(); 340 if (mSearchDialog) mSearchDialog->updateView();
339} 341}
340 342
341void KODialogManager::setDocumentId( const QString &id ) 343void KODialogManager::setDocumentId( const QString &id )
342{ 344{
343 if (mOutgoingDialog) mOutgoingDialog->setDocumentId( id ); 345 if (mOutgoingDialog) mOutgoingDialog->setDocumentId( id );
344} 346}
345 347
346void KODialogManager::writeSettings( KConfig *config ) 348void KODialogManager::writeSettings( KConfig *config )
347{ 349{
348 if (mSearchDialog) 350 if (mSearchDialog)
349 mSearchDialog->listview()->writeSettings(config,"SearchListView Layout"); 351 mSearchDialog->listview()->writeSettings(config,"SearchListView Layout");
350} 352}
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index 3a07348..cf8dae6 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -1,305 +1,316 @@
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 29
30class KConfig; 30class KConfig;
31class QFont; 31class QFont;
32class QColor; 32class QColor;
33class QStringList; 33class QStringList;
34 34
35#define VIEW_WN_VIEW 1
36#define VIEW_NX_VIEW 2
37#define VIEW_J_VIEW 3
38#define VIEW_A_VIEW 4
39#define VIEW_ML_VIEW 5
40#define VIEW_M_VIEW 6
41#define VIEW_L_VIEW 7
42#define VIEW_T_VIEW 8
43
35class KOPrefs : public KPimPrefs 44class KOPrefs : public KPimPrefs
36{ 45{
37 public: 46 public:
38 enum { FormatVCalendar, FormatICalendar }; 47 enum { FormatVCalendar, FormatICalendar };
39 enum { MailClientKMail, MailClientSendmail }; 48 enum { MailClientKMail, MailClientSendmail };
40 enum { IMIPDummy, IMIPKMail }; 49 enum { IMIPDummy, IMIPKMail };
41 enum { IMIPOutbox, IMIPdirectsend }; 50 enum { IMIPOutbox, IMIPdirectsend };
42 enum { neverAuto, addressbookAuto, selectedAuto }; 51 enum { neverAuto, addressbookAuto, selectedAuto };
43 enum { standardDestination, askDestination }; 52 enum { standardDestination, askDestination };
44 53
45 virtual ~KOPrefs(); 54 virtual ~KOPrefs();
46 55
47 /** Get instance of KOPrefs. It is made sure that there is only one 56 /** Get instance of KOPrefs. It is made sure that there is only one
48 instance. */ 57 instance. */
49 static KOPrefs *instance(); 58 static KOPrefs *instance();
50 59
51 /** Set preferences to default values */ 60 /** Set preferences to default values */
52 void usrSetDefaults(); 61 void usrSetDefaults();
53 62
54 /** Read preferences from config file */ 63 /** Read preferences from config file */
55 void usrReadConfig(); 64 void usrReadConfig();
56 65
57 /** Write preferences to config file */ 66 /** Write preferences to config file */
58 void usrWriteConfig(); 67 void usrWriteConfig();
59 void setCategoryDefaults(); 68 void setCategoryDefaults();
60 void setAllDefaults(); 69 void setAllDefaults();
61 70
62 protected: 71 protected:
63 void setTimeZoneIdDefault(); 72 void setTimeZoneIdDefault();
64 73
65 /** Fill empty mail fields with default values. */ 74 /** Fill empty mail fields with default values. */
66 void fillMailDefaults(); 75 void fillMailDefaults();
67 76
68 private: 77 private:
69 /** Constructor disabled for public. Use instance() to create a KOPrefs 78 /** Constructor disabled for public. Use instance() to create a KOPrefs
70 object. */ 79 object. */
71 KOPrefs(); 80 KOPrefs();
72 81
73 static KOPrefs *mInstance; 82 static KOPrefs *mInstance;
74 QStringList getDefaultList(); 83 QStringList getDefaultList();
75 QStringList getLocationDefaultList(); 84 QStringList getLocationDefaultList();
76 public: 85 public:
77 // preferences data 86 // preferences data
78 KConfig* getConfig(); 87 KConfig* getConfig();
79 void setFullName(const QString &); 88 void setFullName(const QString &);
80 QString fullName(); 89 QString fullName();
81 void setEmail(const QString &); 90 void setEmail(const QString &);
82 QString email(); 91 QString email();
83 92
84 QString mAdditional; 93 QString mAdditional;
85 94
86 bool mEmailControlCenter; 95 bool mEmailControlCenter;
87 96
88 bool mBcc; 97 bool mBcc;
89 bool mAutoSave; 98 bool mAutoSave;
90 int mAutoSaveInterval; 99 int mAutoSaveInterval;
91 bool mConfirm; 100 bool mConfirm;
92 101
93 bool mEnableGroupScheduling; 102 bool mEnableGroupScheduling;
94 bool mEnableProjectView; 103 bool mEnableProjectView;
95 104
96 int mDefaultFormat; 105 int mDefaultFormat;
97 int mMailClient; 106 int mMailClient;
98 107
99 int mStartTime; 108 int mStartTime;
100 int mDefaultDuration; 109 int mDefaultDuration;
101 int mAlarmTime; 110 int mAlarmTime;
102 111
103 int mWorkingHoursStart; 112 int mWorkingHoursStart;
104 int mWorkingHoursEnd; 113 int mWorkingHoursEnd;
105 bool mExcludeHolidays; 114 bool mExcludeHolidays;
106 bool mExcludeSaturdays; 115 bool mExcludeSaturdays;
107 bool mMarcusBainsShowSeconds; 116 bool mMarcusBainsShowSeconds;
108 117
109 QFont mTimeBarFont; 118 QFont mTimeBarFont;
110 QFont mMonthViewFont; 119 QFont mMonthViewFont;
111 QFont mAgendaViewFont; 120 QFont mAgendaViewFont;
112 QFont mMarcusBainsFont; 121 QFont mMarcusBainsFont;
113 QFont mTimeLabelsFont; 122 QFont mTimeLabelsFont;
114 QFont mTodoViewFont; 123 QFont mTodoViewFont;
115 QFont mListViewFont; 124 QFont mListViewFont;
116 QFont mDateNavigatorFont; 125 QFont mDateNavigatorFont;
117 QFont mEditBoxFont; 126 QFont mEditBoxFont;
118 QFont mJornalViewFont; 127 QFont mJornalViewFont;
119 QFont mWhatsNextFont; 128 QFont mWhatsNextFont;
120 QFont mEventViewFont; 129 QFont mEventViewFont;
121 130
122 131
123 132
124 133
125 QColor mHolidayColor; 134 QColor mHolidayColor;
126 QColor mHighlightColor; 135 QColor mHighlightColor;
127 QColor mEventColor; 136 QColor mEventColor;
128 QColor mTodoDoneColor; 137 QColor mTodoDoneColor;
129 QColor mAgendaBgColor; 138 QColor mAgendaBgColor;
130 QColor mWorkingHoursColor; 139 QColor mWorkingHoursColor;
131 QColor mTodoDueTodayColor; 140 QColor mTodoDueTodayColor;
132 QColor mTodoOverdueColor; 141 QColor mTodoOverdueColor;
133 QColor mMonthViewEvenColor; 142 QColor mMonthViewEvenColor;
134 QColor mMonthViewOddColor; 143 QColor mMonthViewOddColor;
135 QColor mMonthViewHolidayColor; 144 QColor mMonthViewHolidayColor;
136 bool mMonthViewUsesDayColors; 145 bool mMonthViewUsesDayColors;
137 bool mMonthViewSatSunTog; 146 bool mMonthViewSatSunTog;
138 bool mMonthViewWeek; 147 bool mMonthViewWeek;
139 QColor mAppColor1; 148 QColor mAppColor1;
140 QColor mAppColor2; 149 QColor mAppColor2;
141 bool mUseAppColors; 150 bool mUseAppColors;
142 151
143 int mDayBegins; 152 int mDayBegins;
144 int mHourSize; 153 int mHourSize;
145 int mAllDaySize; 154 int mAllDaySize;
146 bool mShowFullMenu; 155 bool mShowFullMenu;
147 bool mDailyRecur; 156 bool mDailyRecur;
148 bool mWeeklyRecur; 157 bool mWeeklyRecur;
149 bool mMonthDailyRecur; 158 bool mMonthDailyRecur;
150 bool mMonthWeeklyRecur; 159 bool mMonthWeeklyRecur;
151 bool mMonthShowIcons; 160 bool mMonthShowIcons;
152 bool mMonthShowShort; 161 bool mMonthShowShort;
153 bool mEnableToolTips; 162 bool mEnableToolTips;
154 bool mEnableMonthScroll; 163 bool mEnableMonthScroll;
155 bool mFullViewMonth; 164 bool mFullViewMonth;
156 bool mMonthViewUsesCategoryColor; 165 bool mMonthViewUsesCategoryColor;
157 bool mFullViewTodo; 166 bool mFullViewTodo;
158 bool mShowCompletedTodo; 167 bool mShowCompletedTodo;
159 bool mMarcusBainsEnabled; 168 bool mMarcusBainsEnabled;
160 int mNextXDays; 169 int mNextXDays;
161 int mWhatsNextDays; 170 int mWhatsNextDays;
162 int mWhatsNextPrios; 171 int mWhatsNextPrios;
163 bool mEnableQuickTodo; 172 bool mEnableQuickTodo;
164 173
165 bool mCompactDialogs; 174 bool mCompactDialogs;
166 bool mVerticalScreen; 175 bool mVerticalScreen;
167 176
168 bool mShowIconNewTodo; 177 bool mShowIconNewTodo;
169 bool mShowIconNewEvent; 178 bool mShowIconNewEvent;
170 bool mShowIconSearch; 179 bool mShowIconSearch;
171 bool mShowIconList; 180 bool mShowIconList;
172 bool mShowIconDay1; 181 bool mShowIconDay1;
173 bool mShowIconDay5; 182 bool mShowIconDay5;
174 bool mShowIconDay6; 183 bool mShowIconDay6;
175 bool mShowIconDay7; 184 bool mShowIconDay7;
176 bool mShowIconMonth; 185 bool mShowIconMonth;
177 bool mShowIconTodoview; 186 bool mShowIconTodoview;
178 bool mShowIconBackFast; 187 bool mShowIconBackFast;
179 bool mShowIconBack; 188 bool mShowIconBack;
180 bool mShowIconToday; 189 bool mShowIconToday;
181 bool mShowIconForward; 190 bool mShowIconForward;
182 bool mShowIconForwardFast; 191 bool mShowIconForwardFast;
183 bool mShowIconWhatsThis; 192 bool mShowIconWhatsThis;
184 bool mShowIconWeekNum; 193 bool mShowIconWeekNum;
185 bool mShowIconNextDays; 194 bool mShowIconNextDays;
186 bool mShowIconNext; 195 bool mShowIconNext;
187 bool mShowIconJournal; 196 bool mShowIconJournal;
188 bool mShowIconFilter; 197 bool mShowIconFilter;
189 bool mShowIconOnetoolbar; 198 bool mShowIconOnetoolbar;
190 bool mShowIconNavigator; 199 bool mShowIconNavigator;
191 bool mShowIconAllday; 200 bool mShowIconAllday;
192 bool mShowIconFilterview; 201 bool mShowIconFilterview;
193 bool mShowIconToggleFull; 202 bool mShowIconToggleFull;
194 203
195 bool mShowIconStretch; 204 bool mShowIconStretch;
196 205
197 bool mToolBarHor; 206 bool mToolBarHor;
198 bool mToolBarUp; 207 bool mToolBarUp;
199 bool mToolBarHorV; 208 bool mToolBarHorV;
200 bool mToolBarUpV; 209 bool mToolBarUpV;
201 bool mToolBarHorN; 210 bool mToolBarHorN;
202 bool mToolBarUpN; 211 bool mToolBarUpN;
203 bool mToolBarHorF; 212 bool mToolBarHorF;
204 bool mToolBarUpF; 213 bool mToolBarUpF;
205 bool mToolBarMiniIcons; 214 bool mToolBarMiniIcons;
206 215
207 bool mAskForQuit; 216 bool mAskForQuit;
208 bool mUsePassWd; 217 bool mUsePassWd;
209 bool mShowSyncEvents; 218 bool mShowSyncEvents;
210 bool mShowTodoInAgenda; 219 bool mShowTodoInAgenda;
211 bool mShowTimeInAgenda; 220 bool mShowTimeInAgenda;
212 bool mHideNonStartedTodos; 221 bool mHideNonStartedTodos;
213 222
214 int mLastSyncTime; 223 int mLastSyncTime;
215 void setCategoryColor(QString cat,const QColor & color); 224 void setCategoryColor(QString cat,const QColor & color);
216 QColor *categoryColor(QString cat); 225 QColor *categoryColor(QString cat);
217 226
218 QString mArchiveFile; 227 QString mArchiveFile;
219 QString mHtmlExportFile; 228 QString mHtmlExportFile;
220 bool mHtmlWithSave; 229 bool mHtmlWithSave;
221 230
222 QStringList mSelectedPlugins; 231 QStringList mSelectedPlugins;
223 232
224 QString mLastImportFile; 233 QString mLastImportFile;
225 QString mLastVcalFile; 234 QString mLastVcalFile;
226 QString mLastSaveFile; 235 QString mLastSaveFile;
227 QString mLastLoadFile; 236 QString mLastLoadFile;
228 237
229 238
230 QString mDefaultAlarmFile; 239 QString mDefaultAlarmFile;
231 int mIMIPScheduler; 240 int mIMIPScheduler;
232 int mIMIPSend; 241 int mIMIPSend;
233 QStringList mAdditionalMails; 242 QStringList mAdditionalMails;
234 int mIMIPAutoRefresh; 243 int mIMIPAutoRefresh;
235 int mIMIPAutoInsertReply; 244 int mIMIPAutoInsertReply;
236 int mIMIPAutoInsertRequest; 245 int mIMIPAutoInsertRequest;
237 int mIMIPAutoFreeBusy; 246 int mIMIPAutoFreeBusy;
238 int mIMIPAutoFreeBusyReply; 247 int mIMIPAutoFreeBusyReply;
239 248
240 QStringList mTodoTemplates; 249 QStringList mTodoTemplates;
241 QStringList mEventTemplates; 250 QStringList mEventTemplates;
242 251
243 int mDestination; 252 int mDestination;
244 253
245 254
246 bool mEditOnDoubleClick; 255 bool mEditOnDoubleClick;
247 bool mViewChangeHoldFullscreen; 256 bool mViewChangeHoldFullscreen;
248 bool mViewChangeHoldNonFullscreen; 257 bool mViewChangeHoldNonFullscreen;
249 bool mCenterOnCurrentTime; 258 bool mCenterOnCurrentTime;
250 bool mSetTimeToDayStartAt; 259 bool mSetTimeToDayStartAt;
251 bool mHighlightCurrentDay; 260 bool mHighlightCurrentDay;
252 bool mUseHighlightLightColor; 261 bool mUseHighlightLightColor;
253 bool mListViewMonthTimespan; 262 bool mListViewMonthTimespan;
254 bool mWNViewShowsParents; 263 bool mWNViewShowsParents;
255 bool mWNViewShowsPast; 264 bool mWNViewShowsPast;
256 bool mWNViewShowLocation; 265 bool mWNViewShowLocation;
257 bool mTodoViewShowsPercentage; 266 bool mTodoViewShowsPercentage;
258 bool mTodoViewUsesCatColors; 267 bool mTodoViewUsesCatColors;
259 bool mMonthViewUsesBigFont; 268 bool mMonthViewUsesBigFont;
260 bool mTodoViewUsesSmallFont; 269 bool mTodoViewUsesSmallFont;
261 bool mTodoViewUsesForegroundColor; 270 bool mTodoViewUsesForegroundColor;
262 bool mMonthViewUsesForegroundColor; 271 bool mMonthViewUsesForegroundColor;
263 272
264 bool mHightlightDateTimeEdit; 273 bool mHightlightDateTimeEdit;
265 bool mShortDateInViewer; 274 bool mShortDateInViewer;
266 275
267 bool mShowDateNavigator; 276 bool mShowDateNavigator;
268 277
269 QStringList mLocationDefaults; 278 QStringList mLocationDefaults;
270 QStringList mEventSummaryUser; 279 QStringList mEventSummaryUser;
271 QStringList mTodoSummaryUser; 280 QStringList mTodoSummaryUser;
272 281
273 bool mUseInternalAlarmNotification; 282 bool mUseInternalAlarmNotification;
274 int mAlarmPlayBeeps; 283 int mAlarmPlayBeeps;
275 int mAlarmSuspendTime; 284 int mAlarmSuspendTime;
276 int mAlarmSuspendCount; 285 int mAlarmSuspendCount;
277 int mAlarmBeepInterval; 286 int mAlarmBeepInterval;
278 int mOldLanguage; 287 int mOldLanguage;
279 int mOldLoadedLanguage; 288 int mOldLoadedLanguage;
280 289
281 290
282 QString mActiveSyncPort; 291 QString mActiveSyncPort;
283 QString mActiveSyncIP; 292 QString mActiveSyncIP;
284 293
285 // settings for eventviewer 294 // settings for eventviewer
286 bool mEVshowDetails; 295 bool mEVshowDetails;
287 bool mEVshowCreated; 296 bool mEVshowCreated;
288 bool mEVshowChanged; 297 bool mEVshowChanged;
289 bool mWTshowDetails; 298 bool mWTshowDetails;
290 bool mWTshowCreated; 299 bool mWTshowCreated;
291 bool mWTshowChanged; 300 bool mWTshowChanged;
292 301
302 int mCurrentDisplayedView;
303
293 private: 304 private:
294 QDict<QColor> mCategoryColors; 305 QDict<QColor> mCategoryColors;
295 QColor mDefaultCategoryColor; 306 QColor mDefaultCategoryColor;
296 307
297 QFont mDefaultTimeBarFont; 308 QFont mDefaultTimeBarFont;
298 QFont mDefaultViewFont; 309 QFont mDefaultViewFont;
299 QFont mDefaultMonthViewFont; 310 QFont mDefaultMonthViewFont;
300 311
301 QString mName; 312 QString mName;
302 QString mEmail; 313 QString mEmail;
303}; 314};
304 315
305#endif 316#endif
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index c442d0b..406e741 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -1,829 +1,827 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Copyright (c) 2001 4 Copyright (c) 2001
5 Cornelius Schumacher <schumacher@kde.org> 5 Cornelius Schumacher <schumacher@kde.org>
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 10 (at your option) any later version.
11 11
12 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 20
21 As a special exception, permission is given to link this program 21 As a special exception, permission is given to link this program
22 with any edition of Qt, and distribute the resulting executable, 22 with any edition of Qt, and distribute the resulting executable,
23 without including the source code for Qt in the source distribution. 23 without including the source code for Qt in the source distribution.
24*/ 24*/
25 25
26#include <qwidgetstack.h> 26#include <qwidgetstack.h>
27 27
28#include <kconfig.h> 28#include <kconfig.h>
29#include <kglobal.h> 29#include <kglobal.h>
30#ifndef DESKTOP_VERSION 30#ifndef DESKTOP_VERSION
31#include <qpe/qpeapplication.h> 31#include <qpe/qpeapplication.h>
32#else 32#else
33#include <qapplication.h> 33#include <qapplication.h>
34#endif 34#endif
35#include <qdatetime.h> 35#include <qdatetime.h>
36#include "calendarview.h" 36#include "calendarview.h"
37#include "datenavigator.h" 37#include "datenavigator.h"
38#include "kotodoview.h" 38#include "kotodoview.h"
39#include "koagendaview.h" 39#include "koagendaview.h"
40#include "kodialogmanager.h" 40#include "kodialogmanager.h"
41#include "komonthview.h" 41#include "komonthview.h"
42#include "kolistview.h" 42#include "kolistview.h"
43#include "kowhatsnextview.h" 43#include "kowhatsnextview.h"
44#include "kojournalview.h" 44#include "kojournalview.h"
45#include "kotimespanview.h" 45#include "kotimespanview.h"
46#include "koprefs.h" 46#include "koprefs.h"
47#include "navigatorbar.h" 47#include "navigatorbar.h"
48#include "kdatenavigator.h" 48#include "kdatenavigator.h"
49 49
50#include "koviewmanager.h" 50#include "koviewmanager.h"
51//extern bool externFlagMonthviewBlockPainting; 51//extern bool externFlagMonthviewBlockPainting;
52 52
53//bool globalFlagBlockPainting = false; 53//bool globalFlagBlockPainting = false;
54int globalFlagBlockAgenda = 0; 54int globalFlagBlockAgenda = 0;
55int globalFlagBlockLabel = 0; 55int globalFlagBlockLabel = 0;
56int globalFlagBlockAgendaItemPaint = 1; 56int globalFlagBlockAgendaItemPaint = 1;
57int globalFlagBlockAgendaItemUpdate = 1; 57int globalFlagBlockAgendaItemUpdate = 1;
58 58
59 59
60KOViewManager::KOViewManager( CalendarView *mainView ) : 60KOViewManager::KOViewManager( CalendarView *mainView ) :
61 QObject(), mMainView( mainView ) 61 QObject(), mMainView( mainView )
62{ 62{
63 mCurrentView = 0; 63 mCurrentView = 0;
64 flagResetViewChangeDate = 0; 64 flagResetViewChangeDate = 0;
65 mWhatsNextView = 0; 65 mWhatsNextView = 0;
66 mTodoView = 0; 66 mTodoView = 0;
67 mAgendaView = 0; 67 mAgendaView = 0;
68 mMonthView = 0; 68 mMonthView = 0;
69 mListView = 0; 69 mListView = 0;
70 mJournalView = 0; 70 mJournalView = 0;
71 mTimeSpanView = 0; 71 mTimeSpanView = 0;
72 mCurrentAgendaView = 0 ; 72 mCurrentAgendaView = 0 ;
73 mFlagShowNextxDays = false; 73 mFlagShowNextxDays = false;
74} 74}
75 75
76KOViewManager::~KOViewManager() 76KOViewManager::~KOViewManager()
77{ 77{
78} 78}
79 79
80 80
81KOrg::BaseView *KOViewManager::currentView() 81KOrg::BaseView *KOViewManager::currentView()
82{ 82{
83 return mCurrentView; 83 return mCurrentView;
84} 84}
85 85
86void KOViewManager::readSettings(KConfig *config) 86void KOViewManager::readSettings(KConfig *config)
87{ 87{
88 config->setGroup("General"); 88 config->setGroup("General");
89 QString view = config->readEntry("Current View"); 89 QString view = config->readEntry("Current View");
90 if (view == "WhatsNext") showWhatsNextView(); 90 if (view == "WhatsNext") showWhatsNextView();
91 else if (view == "Month") { 91 else if (view == "Month") {
92 if ( !KOPrefs::instance()->mMonthViewWeek ) 92 if ( !KOPrefs::instance()->mMonthViewWeek )
93 showMonthView(); 93 showMonthView();
94 else 94 else
95 showMonthViewWeek(); 95 showMonthViewWeek();
96 } 96 }
97 else if (view == "List") showListView(); 97 else if (view == "List") showListView();
98 else if (view == "Journal") showJournalView(); 98 else if (view == "Journal") showJournalView();
99 else if (view == "TimeSpan") showTimeSpanView(); 99 else if (view == "TimeSpan") showTimeSpanView();
100 else if (view == "Todo") showTodoView(); 100 else if (view == "Todo") showTodoView();
101 else { 101 else {
102 config->setGroup( "Views" ); 102 config->setGroup( "Views" );
103 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 103 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
104 mCurrentAgendaView = dateCount; 104 mCurrentAgendaView = dateCount;
105 showAgendaView(); 105 showAgendaView();
106 mCurrentAgendaView = dateCount; 106 mCurrentAgendaView = dateCount;
107#ifdef DESKTOP_VERSION 107#ifdef DESKTOP_VERSION
108 QTimer::singleShot( 1000, mAgendaView, SLOT ( setInitStartHour() ) ); 108 QTimer::singleShot( 1000, mAgendaView, SLOT ( setInitStartHour() ) );
109#endif 109#endif
110 } 110 }
111} 111}
112 112
113void KOViewManager::showDateView( int view, QDate date) 113void KOViewManager::showDateView( int view, QDate date)
114{ 114{
115 static int lastMode = 0; 115 static int lastMode = 0;
116 static int lastCount = 0; 116 static int lastCount = 0;
117 static bool lastNDMode = false; 117 static bool lastNDMode = false;
118 static QDate lastDate; 118 static QDate lastDate;
119 //qDebug("date %d %s", view, date.toString().latin1()); 119 //qDebug("date %d %s", view, date.toString().latin1());
120 120
121 if (view != 9) 121 if (view != 9)
122 lastMode = 0; 122 lastMode = 0;
123 //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays ); 123 //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays );
124 bool savemFlagShowNextxDays = mFlagShowNextxDays; 124 bool savemFlagShowNextxDays = mFlagShowNextxDays;
125 mFlagShowNextxDays = false; 125 mFlagShowNextxDays = false;
126 if ( view == 3 ) { 126 if ( view == 3 ) {
127 //mCurrentAgendaView = 1 ; 127 //mCurrentAgendaView = 1 ;
128 lastDate = mMainView->dateNavigator()->selectedDates().first(); 128 lastDate = mMainView->dateNavigator()->selectedDates().first();
129 lastCount = mMainView->dateNavigator()->selectedDates().count(); 129 lastCount = mMainView->dateNavigator()->selectedDates().count();
130 lastNDMode = savemFlagShowNextxDays; 130 lastNDMode = savemFlagShowNextxDays;
131 mMainView->dateNavigator()->selectDate( date ); 131 mMainView->dateNavigator()->selectDate( date );
132 lastMode = 1; 132 lastMode = 1;
133 mCurrentAgendaView = 1 ; 133 mCurrentAgendaView = 1 ;
134 } else if (view == 4 ) { 134 } else if (view == 4 ) {
135 mCurrentAgendaView = 7 ; 135 mCurrentAgendaView = 7 ;
136 mMainView->dateNavigator()->selectDates( date, 7 ); 136 mMainView->dateNavigator()->selectDates( date, 7 );
137 } else if (view == 5 ) { 137 } else if (view == 5 ) {
138 mCurrentAgendaView = 14 ; 138 mCurrentAgendaView = 14 ;
139 mMainView->dateNavigator()->selectDates( date, 14); 139 mMainView->dateNavigator()->selectDates( date, 14);
140 } else if (view == 6 ) { 140 } else if (view == 6 ) {
141 resetDateSilent( date,1); 141 resetDateSilent( date,1);
142 showMonthView(); 142 showMonthView();
143 } else if (view == 7 ) { 143 } else if (view == 7 ) {
144 mMainView->dateNavigator()->selectDate( date ); 144 mMainView->dateNavigator()->selectDate( date );
145 showJournalView(); 145 showJournalView();
146 } else if (view == 8 ) { 146 } else if (view == 8 ) {
147 globalFlagBlockAgenda = 1; 147 globalFlagBlockAgenda = 1;
148 if ( mCurrentAgendaView != 3 ) 148 if ( mCurrentAgendaView != 3 )
149 mCurrentAgendaView = -1; 149 mCurrentAgendaView = -1;
150 showAgendaView(KOPrefs::instance()->mFullViewMonth); 150 showAgendaView(KOPrefs::instance()->mFullViewMonth);
151 globalFlagBlockAgenda = 2; 151 globalFlagBlockAgenda = 2;
152 mMainView->dateNavigator()->selectDates( date , 152 mMainView->dateNavigator()->selectDates( date ,
153 KOPrefs::instance()->mNextXDays ); 153 KOPrefs::instance()->mNextXDays );
154 mFlagShowNextxDays = true; 154 mFlagShowNextxDays = true;
155 mCurrentAgendaView = 3 ; 155 mCurrentAgendaView = 3 ;
156 } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode ) 156 } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode )
157 if ( lastMode ) { 157 if ( lastMode ) {
158 mCurrentAgendaView = lastCount ; 158 mCurrentAgendaView = lastCount ;
159 mMainView->dateNavigator()->selectDates( lastDate, lastCount); 159 mMainView->dateNavigator()->selectDates( lastDate, lastCount);
160 mFlagShowNextxDays = lastNDMode; 160 mFlagShowNextxDays = lastNDMode;
161 if ( mFlagShowNextxDays ) { 161 if ( mFlagShowNextxDays ) {
162 mCurrentAgendaView = 3 ; 162 mCurrentAgendaView = 3 ;
163 } 163 }
164 } else 164 } else
165 showWeekView(); 165 showWeekView();
166 } else if (view == 10) { 166 } else if (view == 10) {
167 mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() ); 167 mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() );
168 } 168 }
169} 169}
170 170
171 171
172 172
173void KOViewManager::writeSettings(KConfig *config) 173void KOViewManager::writeSettings(KConfig *config)
174{ 174{
175 config->setGroup("General"); 175 config->setGroup("General");
176 176
177 QString view; 177 QString view;
178 if (mCurrentView == mWhatsNextView) view = "WhatsNext"; 178 if (mCurrentView == mWhatsNextView) view = "WhatsNext";
179 else if (mCurrentView == mMonthView) view = "Month"; 179 else if (mCurrentView == mMonthView) view = "Month";
180 else if (mCurrentView == mListView) view = "List"; 180 else if (mCurrentView == mListView) view = "List";
181 else if (mCurrentView == mJournalView) view = "Journal"; 181 else if (mCurrentView == mJournalView) view = "Journal";
182 else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; 182 else if (mCurrentView == mTimeSpanView) view = "TimeSpan";
183 else if (mCurrentView == mTodoView) view = "Todo"; 183 else if (mCurrentView == mTodoView) view = "Todo";
184 else view = "Agenda"; 184 else view = "Agenda";
185 185
186 config->writeEntry("Current View",view); 186 config->writeEntry("Current View",view);
187 187
188 if (mAgendaView) { 188 if (mAgendaView) {
189 mAgendaView->writeSettings(config); 189 mAgendaView->writeSettings(config);
190 } 190 }
191 if (mTimeSpanView) { 191 if (mTimeSpanView) {
192 mTimeSpanView->writeSettings(config); 192 mTimeSpanView->writeSettings(config);
193 } 193 }
194 if (mListView) { 194 if (mListView) {
195 mListView->writeSettings(config); 195 mListView->writeSettings(config);
196 } 196 }
197 if (mTodoView) { 197 if (mTodoView) {
198 mTodoView->saveLayout(config,"Todo View"); 198 mTodoView->saveLayout(config,"Todo View");
199 } 199 }
200} 200}
201void KOViewManager::showNextView() 201void KOViewManager::showNextView()
202{ 202{
203 static int selecteddatescount = 0; 203 static int selecteddatescount = 0;
204 static QDate selecteddate = QDate ( 2000, 1, 1 ); 204 static QDate selecteddate = QDate ( 2000, 1, 1 );
205 static QDate baseCycleDate = QDate ( 2000, 1, 1 ); 205 static QDate baseCycleDate = QDate ( 2000, 1, 1 );
206 int newCount = mMainView->dateNavigator()->selectedDates().count(); 206 int newCount = mMainView->dateNavigator()->selectedDates().count();
207 if ( selecteddatescount != newCount && flagResetViewChangeDate == 0 ) { 207 if ( selecteddatescount != newCount && flagResetViewChangeDate == 0 ) {
208 flagResetViewChangeDate = 1; 208 flagResetViewChangeDate = 1;
209 } 209 }
210 if ( selecteddate != mMainView->dateNavigator()->selectedDates().first() ) 210 if ( selecteddate != mMainView->dateNavigator()->selectedDates().first() )
211 flagResetViewChangeDate = 1; 211 flagResetViewChangeDate = 1;
212 if ( flagResetViewChangeDate > 0 ) { 212 if ( flagResetViewChangeDate > 0 ) {
213 baseCycleDate = mMainView->dateNavigator()->selectedDates().first(); 213 baseCycleDate = mMainView->dateNavigator()->selectedDates().first();
214 //qDebug("newCycle "); 214 //qDebug("newCycle ");
215 } 215 }
216 if (mCurrentView == mWhatsNextView) goto NEXT_X; 216 if (mCurrentView == mWhatsNextView) goto NEXT_X;
217 if (mCurrentView == mAgendaView && mFlagShowNextxDays) goto JOURNAL; 217 if (mCurrentView == mAgendaView && mFlagShowNextxDays) goto JOURNAL;
218 if (mCurrentView == mJournalView ) goto DAY_1; 218 if (mCurrentView == mJournalView ) goto DAY_1;
219 if (mCurrentView == mAgendaView && mCurrentAgendaView == 1 ) goto DAY_5; 219 if (mCurrentView == mAgendaView && mCurrentAgendaView == 1 ) goto DAY_5;
220 if (mCurrentView == mAgendaView && mCurrentAgendaView == 5 ) goto DAY_7; 220 if (mCurrentView == mAgendaView && mCurrentAgendaView == 5 ) goto DAY_7;
221 if (mCurrentView == mAgendaView ) goto DAY_6; 221 if (mCurrentView == mAgendaView ) goto DAY_6;
222 if (mCurrentView == mMonthView && KOPrefs::instance()->mMonthViewWeek) goto MONTH; 222 if (mCurrentView == mMonthView && KOPrefs::instance()->mMonthViewWeek) goto MONTH;
223 if (mCurrentView == mMonthView ) goto LIST; 223 if (mCurrentView == mMonthView ) goto LIST;
224 if (mCurrentView == mListView ) goto TODO; 224 if (mCurrentView == mListView ) goto TODO;
225 // if (mCurrentView == mTodoView ) goto NEXT; 225 // if (mCurrentView == mTodoView ) goto NEXT;
226 NEXT: 226 NEXT:
227 if ( KOPrefs::instance()->mShowIconNext ) { showWhatsNextView();goto ENTE ;} 227 if ( KOPrefs::instance()->mShowIconNext ) { showWhatsNextView();goto ENTE ;}
228 NEXT_X: 228 NEXT_X:
229 if ( KOPrefs::instance()->mShowIconNextDays ) { 229 if ( KOPrefs::instance()->mShowIconNextDays ) {
230 globalFlagBlockAgenda = 1; 230 showNextXView();
231 if ( mCurrentAgendaView != 3 )
232 mCurrentAgendaView = -1;
233 showAgendaView(KOPrefs::instance()->mFullViewMonth);
234 globalFlagBlockAgenda = 2;
235 mMainView->dateNavigator()->selectDates( baseCycleDate ,
236 KOPrefs::instance()->mNextXDays );
237 mFlagShowNextxDays = true;
238 mCurrentAgendaView = 3 ;
239 goto ENTE ; 231 goto ENTE ;
240 } 232 }
241 JOURNAL: 233 JOURNAL:
242 if ( KOPrefs::instance()->mShowIconJournal ) { 234 if ( KOPrefs::instance()->mShowIconJournal ) {
243 resetDateSilent( baseCycleDate , 1 ); 235 resetDateSilent( baseCycleDate , 1 );
244 showJournalView() ;goto ENTE ;} 236 showJournalView() ;goto ENTE ;}
245 DAY_1: 237 DAY_1:
246 if ( KOPrefs::instance()->mShowIconDay1 ) { 238 if ( KOPrefs::instance()->mShowIconDay1 ) {
247 resetDateSilent( baseCycleDate , 2 ); 239 resetDateSilent( baseCycleDate , 2 );
248 showDayView() ;goto ENTE ;} 240 showDayView() ;goto ENTE ;}
249 DAY_5: 241 DAY_5:
250 if ( KOPrefs::instance()->mShowIconDay5 ) { 242 if ( KOPrefs::instance()->mShowIconDay5 ) {
251 resetDateSilent( baseCycleDate , 2 ); 243 resetDateSilent( baseCycleDate , 2 );
252 showWorkWeekView() ;goto ENTE ;} 244 showWorkWeekView() ;goto ENTE ;}
253 DAY_7: 245 DAY_7:
254 if ( KOPrefs::instance()->mShowIconDay7 ) { 246 if ( KOPrefs::instance()->mShowIconDay7 ) {
255 resetDateSilent( baseCycleDate , 2 ); 247 resetDateSilent( baseCycleDate , 2 );
256 showWeekView();goto ENTE ;} 248 showWeekView();goto ENTE ;}
257 DAY_6: 249 DAY_6:
258 if ( KOPrefs::instance()->mShowIconDay6 ) { 250 if ( KOPrefs::instance()->mShowIconDay6 ) {
259 resetDateSilent( baseCycleDate , 2 ); 251 resetDateSilent( baseCycleDate , 2 );
260 showMonthViewWeek();goto ENTE ;} 252 showMonthViewWeek();goto ENTE ;}
261 MONTH: 253 MONTH:
262 if ( KOPrefs::instance()->mShowIconMonth ) { 254 if ( KOPrefs::instance()->mShowIconMonth ) {
263 resetDateSilent( baseCycleDate , 2 ); 255 resetDateSilent( baseCycleDate , 2 );
264 showMonthView();goto ENTE ;} 256 showMonthView();goto ENTE ;}
265 LIST: 257 LIST:
266 if ( KOPrefs::instance()->mShowIconList ) { 258 if ( KOPrefs::instance()->mShowIconList ) {
267 resetDateSilent( baseCycleDate , 2 ); 259 resetDateSilent( baseCycleDate , 2 );
268 showListView() ;goto ENTE ;} 260 showListView() ;goto ENTE ;}
269 TODO: 261 TODO:
270 if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;goto ENTE ;} 262 if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;goto ENTE ;}
271 if ( KOPrefs::instance()->mShowIconNext ) { goto NEXT ;} 263 if ( KOPrefs::instance()->mShowIconNext ) { goto NEXT ;}
272 if ( KOPrefs::instance()->mShowIconNextDays ) { goto NEXT_X ;} 264 if ( KOPrefs::instance()->mShowIconNextDays ) { goto NEXT_X ;}
273 if ( KOPrefs::instance()->mShowIconJournal ) { goto JOURNAL;} 265 if ( KOPrefs::instance()->mShowIconJournal ) { goto JOURNAL;}
274 if ( KOPrefs::instance()->mShowIconDay1 ) { goto DAY_1 ;} 266 if ( KOPrefs::instance()->mShowIconDay1 ) { goto DAY_1 ;}
275 if ( KOPrefs::instance()->mShowIconDay5 ) { goto DAY_5 ;} 267 if ( KOPrefs::instance()->mShowIconDay5 ) { goto DAY_5 ;}
276 if ( KOPrefs::instance()->mShowIconDay7 ) { goto DAY_7 ;} 268 if ( KOPrefs::instance()->mShowIconDay7 ) { goto DAY_7 ;}
277 if ( KOPrefs::instance()->mShowIconDay6 ) { goto DAY_6 ;} 269 if ( KOPrefs::instance()->mShowIconDay6 ) { goto DAY_6 ;}
278 if ( KOPrefs::instance()->mShowIconMonth ) {goto MONTH ;} 270 if ( KOPrefs::instance()->mShowIconMonth ) {goto MONTH ;}
279 if ( KOPrefs::instance()->mShowIconList ) { goto LIST ;} 271 if ( KOPrefs::instance()->mShowIconList ) { goto LIST ;}
280 //if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;goto ENTE ;} 272 //if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;goto ENTE ;}
281 ENTE: 273 ENTE:
282 flagResetViewChangeDate = 0; 274 flagResetViewChangeDate = 0;
283 selecteddatescount = mMainView->dateNavigator()->selectedDates().count(); 275 selecteddatescount = mMainView->dateNavigator()->selectedDates().count();
284 selecteddate = mMainView->dateNavigator()->selectedDates().first(); 276 selecteddate = mMainView->dateNavigator()->selectedDates().first();
285 277
286} 278}
287void KOViewManager::resetDateSilent( QDate date , int days ) 279void KOViewManager::resetDateSilent( QDate date , int days )
288{ 280{
289 mMainView->dateNavigator()->blockSignals( true ); 281 mMainView->dateNavigator()->blockSignals( true );
290 mMainView->dateNavigator()->selectDates( date , days ); 282 mMainView->dateNavigator()->selectDates( date , days );
291 mMainView->dateNavigator()->blockSignals( false ); 283 mMainView->dateNavigator()->blockSignals( false );
292} 284}
293void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) 285void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen )
294{ 286{
295 if ( flagResetViewChangeDate < 10 ) 287 if ( flagResetViewChangeDate < 10 )
296 ++flagResetViewChangeDate; 288 ++flagResetViewChangeDate;
297 //mFlagShowNextxDays = false; 289 //mFlagShowNextxDays = false;
298 //if(view == mCurrentView) return; 290 //if(view == mCurrentView) return;
299 if ( view == 0 ) { 291 if ( view == 0 ) {
300 view = mCurrentView; 292 view = mCurrentView;
301 if ( view == 0 ) 293 if ( view == 0 )
302 return; 294 return;
303 } 295 }
304 bool callupdate = !(view == mCurrentView); 296 bool callupdate = !(view == mCurrentView);
305 bool full = fullScreen; 297 bool full = fullScreen;
306 if(view == mCurrentView && view != mWhatsNextView ) { 298 if(view == mCurrentView && view != mWhatsNextView ) {
307 if ( mCurrentAgendaView < 0 ) 299 if ( mCurrentAgendaView < 0 )
308 return; 300 return;
309 if ( view != mMonthView ) 301 if ( view != mMonthView )
310 full = mMainView->leftFrame()->isVisible(); 302 full = mMainView->leftFrame()->isVisible();
311 } else { 303 } else {
312 if ( view == mMonthView && mMonthView) 304 if ( view == mMonthView && mMonthView)
313 ;//mMonthView->skipResize = true ; 305 ;//mMonthView->skipResize = true ;
314 mCurrentView = view; 306 mCurrentView = view;
315 // bool full = fullScreen; 307 // bool full = fullScreen;
316 bool isFull = !mMainView->leftFrame()->isVisible(); 308 bool isFull = !mMainView->leftFrame()->isVisible();
317 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) 309 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen )
318 full = true; 310 full = true;
319 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) 311 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen )
320 full = false; 312 full = false;
321 } 313 }
322 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); 314 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime();
323 //raiseCurrentView( full ); 315 //raiseCurrentView( full );
324 mMainView->processIncidenceSelection( 0 ); 316 mMainView->processIncidenceSelection( 0 );
325 //mMainView->updateView(); 317 //mMainView->updateView();
326 raiseCurrentView( full, callupdate ); 318 raiseCurrentView( full, callupdate );
327 mMainView->adaptNavigationUnits(); 319 mMainView->adaptNavigationUnits();
328} 320}
329 321
330void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView ) 322void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView )
331{ 323{
332 mCurrentAgendaView = 0; 324 mCurrentAgendaView = 0;
333 if ( fullScreen ) { 325 if ( fullScreen ) {
334 mMainView->leftFrame()->hide(); 326 mMainView->leftFrame()->hide();
335 } else { 327 } else {
336 mMainView->leftFrame()->show(); 328 mMainView->leftFrame()->show();
337 } 329 }
338 //if ( mCurrentView == mMonthView ) qApp->processEvents(); 330 //if ( mCurrentView == mMonthView ) qApp->processEvents();
339 emit signalFullScreen( !fullScreen ); 331 emit signalFullScreen( !fullScreen );
340 if ( callUpdateView ) 332 if ( callUpdateView )
341 mMainView->updateView(); 333 mMainView->updateView();
342 334
343 if ( globalFlagBlockAgenda == 5 ) { 335 if ( globalFlagBlockAgenda == 5 ) {
344 globalFlagBlockAgenda = 4; 336 globalFlagBlockAgenda = 4;
345 globalFlagBlockAgendaItemPaint = 1; 337 globalFlagBlockAgendaItemPaint = 1;
346 } 338 }
347 mMainView->viewStack()->raiseWidget(mCurrentView); 339 mMainView->viewStack()->raiseWidget(mCurrentView);
348 if ( globalFlagBlockAgenda == 4 ) { 340 if ( globalFlagBlockAgenda == 4 ) {
349 if ( mCurrentView == mAgendaView ) { 341 if ( mCurrentView == mAgendaView ) {
350 //globalFlagBlockAgenda =1 ; 342 //globalFlagBlockAgenda =1 ;
351 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 343 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
352 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); 344 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins );
353 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 345 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
354 mAgendaView->setStartHour( QTime::currentTime ().hour() ); 346 mAgendaView->setStartHour( QTime::currentTime ().hour() );
355 qApp->processEvents(); 347 qApp->processEvents();
356 //qDebug("qApp->processEvents() "); 348 //qDebug("qApp->processEvents() ");
357 globalFlagBlockAgenda = 0; 349 globalFlagBlockAgenda = 0;
358 mAgendaView->repaintAgenda(); 350 mAgendaView->repaintAgenda();
359 351
360 } 352 }
361 globalFlagBlockAgenda = 0; 353 globalFlagBlockAgenda = 0;
362 } 354 }
363 emit signalAgendaView( mCurrentView == mAgendaView ); 355 emit signalAgendaView( mCurrentView == mAgendaView );
364 //qDebug("raiseCurrentView ende "); 356 //qDebug("raiseCurrentView ende ");
365 357
366} 358}
367 359
368void KOViewManager::updateView() 360void KOViewManager::updateView()
369{ 361{
370 // qDebug("KOViewManager::updateView() "); 362 // qDebug("KOViewManager::updateView() ");
371 // if we are updating mTodoView, we get endless recursion 363 // if we are updating mTodoView, we get endless recursion
372 if ( mTodoView == mCurrentView ) 364 if ( mTodoView == mCurrentView )
373 return; 365 return;
374 if ( mCurrentView ) mCurrentView->updateView(); 366 if ( mCurrentView ) mCurrentView->updateView();
375 367
376} 368}
377 369
378void KOViewManager::updateView(const QDate &start, const QDate &end) 370void KOViewManager::updateView(const QDate &start, const QDate &end)
379{ 371{
380 // kdDebug() << "KOViewManager::updateView()" << endl; 372 // kdDebug() << "KOViewManager::updateView()" << endl;
381 373
382 if (mCurrentView) mCurrentView->showDates(start, end); 374 if (mCurrentView) mCurrentView->showDates(start, end);
383 375
384 if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView(); 376 if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView();
385} 377}
386 378
387 379
388void KOViewManager::updateWNview() 380void KOViewManager::updateWNview()
389{ 381{
390 if ( mCurrentView == mWhatsNextView && mWhatsNextView ) 382 if ( mCurrentView == mWhatsNextView && mWhatsNextView )
391 mWhatsNextView->updateView(); 383 mWhatsNextView->updateView();
392 if ( mCurrentView == mMonthView && mMonthView ) 384 if ( mCurrentView == mMonthView && mMonthView )
393 mMonthView->updateView(); 385 mMonthView->updateView();
394 386
395} 387}
396void KOViewManager::showWhatsNextView() 388void KOViewManager::showWhatsNextView()
397{ 389{
398 if (!mWhatsNextView) { 390 if (!mWhatsNextView) {
399 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), 391 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(),
400 "KOViewManager::WhatsNextView"); 392 "KOViewManager::WhatsNextView");
401 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); 393 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog());
402 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); 394 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig()));
403 addView(mWhatsNextView); 395 addView(mWhatsNextView);
404 connect(this, SIGNAL( printWNV() ), 396 connect(this, SIGNAL( printWNV() ),
405 mWhatsNextView, SLOT( printMe() ) ); 397 mWhatsNextView, SLOT( printMe() ) );
406 } 398 }
407 globalFlagBlockAgenda = 1; 399 globalFlagBlockAgenda = 1;
408 showView(mWhatsNextView, true ); 400 showView(mWhatsNextView, true );
409 //mWhatsNextView->updateView(); 401 //mWhatsNextView->updateView();
410 402 KOPrefs::instance()->mCurrentDisplayedView = VIEW_WN_VIEW;
411} 403}
412 404
413void KOViewManager::slotprintWNV() 405void KOViewManager::slotprintWNV()
414{ 406{
415 if (!mWhatsNextView) 407 if (!mWhatsNextView)
416 showWhatsNextView(); 408 showWhatsNextView();
417 emit printWNV(); 409 emit printWNV();
418 410
419} 411}
420void KOViewManager::showListView() 412void KOViewManager::showListView()
421{ 413{
422 if (!mListView) { 414 if (!mListView) {
423 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); 415 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView");
424 addView(mListView); 416 addView(mListView);
425 417
426 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), 418 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)),
427 mMainView, SLOT(showIncidence(Incidence *))); 419 mMainView, SLOT(showIncidence(Incidence *)));
428 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), 420 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)),
429 mMainView, SLOT(editIncidence(Incidence *))); 421 mMainView, SLOT(editIncidence(Incidence *)));
430 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), 422 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)),
431 mMainView, SLOT(deleteIncidence(Incidence *))); 423 mMainView, SLOT(deleteIncidence(Incidence *)));
432 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), 424 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ),
433 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 425 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
434 connect( mListView, SIGNAL( signalNewEvent() ), 426 connect( mListView, SIGNAL( signalNewEvent() ),
435 mMainView, SLOT( newEvent() ) ); 427 mMainView, SLOT( newEvent() ) );
436 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); 428 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig()));
437 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 429 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
438 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 430 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
439 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 431 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
440 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 432 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
441 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 433 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
442 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 434 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
443 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 435 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
444 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 436 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
445 } 437 }
446 // bool temp = mFlagShowNextxDays; 438 // bool temp = mFlagShowNextxDays;
447 //globalFlagBlockPainting = true; 439 //globalFlagBlockPainting = true;
448 globalFlagBlockAgenda = 1; 440 globalFlagBlockAgenda = 1;
449 if ( KOPrefs::instance()->mListViewMonthTimespan ) { 441 if ( KOPrefs::instance()->mListViewMonthTimespan ) {
450 mMainView->setBlockShowDates( true ); 442 mMainView->setBlockShowDates( true );
451 mMainView->dateNavigator()->selectMonth(); 443 mMainView->dateNavigator()->selectMonth();
452 mMainView->setBlockShowDates( false ); 444 mMainView->setBlockShowDates( false );
453 } 445 }
454 showView(mListView, KOPrefs::instance()->mFullViewTodo); 446 showView(mListView, KOPrefs::instance()->mFullViewTodo);
455 //mFlagShowNextxDays = temp; 447 //mFlagShowNextxDays = temp;
448 KOPrefs::instance()->mCurrentDisplayedView = VIEW_L_VIEW;
456} 449}
457 450
458void KOViewManager::showAgendaView( bool fullScreen ) 451void KOViewManager::showAgendaView( bool fullScreen )
459{ 452{
460 453
461 mMainView->dialogManager()->hideSearchDialog(); 454 mMainView->dialogManager()->hideSearchDialog();
462 // qDebug("KOViewManager::showAgendaView "); 455 // qDebug("KOViewManager::showAgendaView ");
463 bool full; 456 bool full;
464 full = fullScreen; 457 full = fullScreen;
465 if (!mAgendaView) { 458 if (!mAgendaView) {
466 full = false; 459 full = false;
467 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); 460 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView");
468 addView(mAgendaView); 461 addView(mAgendaView);
469#ifndef DESKTOP_VERSION 462#ifndef DESKTOP_VERSION
470 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); 463 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold );
471#endif 464#endif
472 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), 465 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )),
473 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); 466 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) ));
474 467
475 // SIGNALS/SLOTS FOR DAY/WEEK VIEW 468 // SIGNALS/SLOTS FOR DAY/WEEK VIEW
476 469
477 connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate ))); 470 connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate )));
478 471
479 connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)), 472 connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)),
480 mMainView, SLOT(newTodoDateTime(QDateTime,bool))); 473 mMainView, SLOT(newTodoDateTime(QDateTime,bool)));
481 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), 474 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)),
482 mMainView, SLOT(newEvent(QDateTime))); 475 mMainView, SLOT(newEvent(QDateTime)));
483 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), 476 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)),
484 mMainView, SLOT(newEvent(QDateTime,QDateTime))); 477 mMainView, SLOT(newEvent(QDateTime,QDateTime)));
485 connect(mAgendaView,SIGNAL(newEventSignal(QDate)), 478 connect(mAgendaView,SIGNAL(newEventSignal(QDate)),
486 mMainView, SLOT(newEvent(QDate))); 479 mMainView, SLOT(newEvent(QDate)));
487 480
488 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), 481 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)),
489 mMainView, SLOT(editIncidence(Incidence *))); 482 mMainView, SLOT(editIncidence(Incidence *)));
490 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), 483 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)),
491 mMainView, SLOT(showIncidence(Incidence *))); 484 mMainView, SLOT(showIncidence(Incidence *)));
492 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), 485 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)),
493 mMainView, SLOT(deleteIncidence(Incidence *))); 486 mMainView, SLOT(deleteIncidence(Incidence *)));
494 487
495 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), 488 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ),
496 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 489 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
497 490
498 connect(mAgendaView, SIGNAL( toggleExpand() ), 491 connect(mAgendaView, SIGNAL( toggleExpand() ),
499 mMainView, SLOT( toggleExpand() ) ); 492 mMainView, SLOT( toggleExpand() ) );
500 493
501 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), 494 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ),
502 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; 495 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ;
503 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), 496 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ),
504 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; 497 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ;
505 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); 498 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig()));
506 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, 499 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView,
507 SLOT( updateTodo( Todo *, int ) ) ); 500 SLOT( updateTodo( Todo *, int ) ) );
508 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), 501 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )),
509 mMainView, SIGNAL( todoModified( Todo *, int ))); 502 mMainView, SIGNAL( todoModified( Todo *, int )));
510 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 503 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
511 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 504 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
512 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 505 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
513 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 506 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
514 connect( mAgendaView, SIGNAL( selectWeekNum( int ) ), 507 connect( mAgendaView, SIGNAL( selectWeekNum( int ) ),
515 mMainView->dateNavigator(), SLOT ( selectWeek( int ) ) ); 508 mMainView->dateNavigator(), SLOT ( selectWeek( int ) ) );
516 mAgendaView->readSettings(); 509 mAgendaView->readSettings();
517 mAgendaView->updateConfig(); 510 mAgendaView->updateConfig();
518 } 511 }
519 512
520 showView( mAgendaView, full); 513 showView( mAgendaView, full);
521 514 KOPrefs::instance()->mCurrentDisplayedView = VIEW_A_VIEW;
522} 515}
523 516
524void KOViewManager::showDayView() 517void KOViewManager::showDayView()
525{ 518{
526 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); 519 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count();
527 mFlagShowNextxDays = false; 520 mFlagShowNextxDays = false;
528 globalFlagBlockLabel = 1; 521 globalFlagBlockLabel = 1;
529 globalFlagBlockAgenda = 1; 522 globalFlagBlockAgenda = 1;
530 if ( mCurrentAgendaView != 1 ) 523 if ( mCurrentAgendaView != 1 )
531 mCurrentAgendaView = -1; 524 mCurrentAgendaView = -1;
532 showAgendaView(); 525 showAgendaView();
533 qApp->processEvents(); 526 qApp->processEvents();
534 globalFlagBlockAgenda = 2; 527 globalFlagBlockAgenda = 2;
535 globalFlagBlockLabel = 0; 528 globalFlagBlockLabel = 0;
536 mMainView->dateNavigator()->selectDates( 1 ); 529 mMainView->dateNavigator()->selectDates( 1 );
537 mCurrentAgendaView = 1 ; 530 mCurrentAgendaView = 1 ;
538 531
539} 532}
540 533
541void KOViewManager::showWorkWeekView() 534void KOViewManager::showWorkWeekView()
542{ 535{
543 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); 536 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count();
544 mFlagShowNextxDays = false; 537 mFlagShowNextxDays = false;
545 globalFlagBlockAgenda = 1; 538 globalFlagBlockAgenda = 1;
546 globalFlagBlockLabel = 1; 539 globalFlagBlockLabel = 1;
547 if ( mCurrentAgendaView != 5 ) 540 if ( mCurrentAgendaView != 5 )
548 mCurrentAgendaView = -1; 541 mCurrentAgendaView = -1;
549 showAgendaView(); 542 showAgendaView();
550 qApp->processEvents(); 543 qApp->processEvents();
551 globalFlagBlockAgenda = 2; 544 globalFlagBlockAgenda = 2;
552 globalFlagBlockLabel = 0; 545 globalFlagBlockLabel = 0;
553 mMainView->dateNavigator()->selectWorkWeek(); 546 mMainView->dateNavigator()->selectWorkWeek();
554 mCurrentAgendaView = 5 ; 547 mCurrentAgendaView = 5 ;
555 548
556} 549}
557 550
558void KOViewManager::showWeekView() 551void KOViewManager::showWeekView()
559{ 552{
560 /* 553 /*
561 globalFlagBlockAgenda = 2; 554 globalFlagBlockAgenda = 2;
562 qDebug("4globalFlagBlockAgenda = 2; "); 555 qDebug("4globalFlagBlockAgenda = 2; ");
563 //globalFlagBlockPainting = true; 556 //globalFlagBlockPainting = true;
564 mMainView->dateNavigator()->selectWeek(); 557 mMainView->dateNavigator()->selectWeek();
565 showAgendaView(); 558 showAgendaView();
566 */ 559 */
567 560
568 561
569 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); 562 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count();
570 mFlagShowNextxDays = false; 563 mFlagShowNextxDays = false;
571 globalFlagBlockAgenda = 1; 564 globalFlagBlockAgenda = 1;
572 globalFlagBlockLabel = 1; 565 globalFlagBlockLabel = 1;
573 if ( mCurrentAgendaView != 7 ) 566 if ( mCurrentAgendaView != 7 )
574 mCurrentAgendaView = -1; 567 mCurrentAgendaView = -1;
575 showAgendaView(); 568 showAgendaView();
576 qApp->processEvents(); 569 qApp->processEvents();
577 globalFlagBlockAgenda = 2; 570 globalFlagBlockAgenda = 2;
578 globalFlagBlockLabel = 0; 571 globalFlagBlockLabel = 0;
579 mMainView->dateNavigator()->selectWeek(); 572 mMainView->dateNavigator()->selectWeek();
580 mCurrentAgendaView = 7 ; 573 mCurrentAgendaView = 7 ;
581} 574}
582 575
583void KOViewManager::showNextXView() 576void KOViewManager::showNextXView()
584{ 577{
585 578
586 globalFlagBlockAgenda = 1; 579 globalFlagBlockAgenda = 1;
587 if ( mCurrentAgendaView != 3 ) 580 if ( mCurrentAgendaView != 3 )
588 mCurrentAgendaView = -1; 581 mCurrentAgendaView = -1;
589 showAgendaView(KOPrefs::instance()->mFullViewMonth); 582 showAgendaView(KOPrefs::instance()->mFullViewMonth);
590 globalFlagBlockAgenda = 2; 583 globalFlagBlockAgenda = 2;
591 mMainView->dateNavigator()->selectDates( QDate::currentDate(), 584 mMainView->dateNavigator()->selectDates( QDate::currentDate(),
592 KOPrefs::instance()->mNextXDays ); 585 KOPrefs::instance()->mNextXDays );
593 mFlagShowNextxDays = true; 586 mFlagShowNextxDays = true;
594 mCurrentAgendaView = 3 ; 587 mCurrentAgendaView = 3 ;
588 KOPrefs::instance()->mCurrentDisplayedView = VIEW_NX_VIEW;
595} 589}
596bool KOViewManager::showsNextDays() 590bool KOViewManager::showsNextDays()
597{ 591{
598 return mFlagShowNextxDays; 592 return mFlagShowNextxDays;
599} 593}
600void KOViewManager::createMonthView() 594void KOViewManager::createMonthView()
601{ 595{
602if (!mMonthView) { 596if (!mMonthView) {
603 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); 597 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView");
604 598
605 addView(mMonthView); 599 addView(mMonthView);
606 // mMonthView->show(); 600 // mMonthView->show();
607 // SIGNALS/SLOTS FOR MONTH VIEW 601 // SIGNALS/SLOTS FOR MONTH VIEW
608 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), 602 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)),
609 mMainView, SLOT(newEvent(QDateTime))); 603 mMainView, SLOT(newEvent(QDateTime)));
610 604
611 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), 605 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)),
612 mMainView, SLOT(showIncidence(Incidence *))); 606 mMainView, SLOT(showIncidence(Incidence *)));
613 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), 607 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)),
614 mMainView, SLOT(editIncidence(Incidence *))); 608 mMainView, SLOT(editIncidence(Incidence *)));
615 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), 609 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)),
616 mMainView, SLOT(deleteIncidence(Incidence *))); 610 mMainView, SLOT(deleteIncidence(Incidence *)));
617 611
618 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), 612 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ),
619 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 613 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
620 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 614 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
621 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 615 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
622 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 616 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
623 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 617 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
624 618
625 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 619 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
626 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 620 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
627 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 621 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
628 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 622 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
629 connect( mMonthView, SIGNAL( selectWeekNum( int ) ), 623 connect( mMonthView, SIGNAL( selectWeekNum( int ) ),
630 mMainView->dateNavigator(), SLOT ( selectWeekFromMonthView( int ) ) ); 624 mMainView->dateNavigator(), SLOT ( selectWeekFromMonthView( int ) ) );
631 connect( mMonthView, SIGNAL( selectMonth() ), 625 connect( mMonthView, SIGNAL( selectMonth() ),
632 mMainView->dateNavigator(), SLOT ( selectMonthFromMonthview() ) ); 626 mMainView->dateNavigator(), SLOT ( selectMonthFromMonthview() ) );
633 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), 627 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ),
634 mMainView, SLOT ( showDay( QDate ) ) ); 628 mMainView, SLOT ( showDay( QDate ) ) );
635 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); 629 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig()));
636 connect( mMonthView, SIGNAL(nextMonth() ), 630 connect( mMonthView, SIGNAL(nextMonth() ),
637 mMonthView->navigatorBar(), SIGNAL(goNextMonth() ) ); 631 mMonthView->navigatorBar(), SIGNAL(goNextMonth() ) );
638 connect( mMonthView, SIGNAL(prevMonth() ), 632 connect( mMonthView, SIGNAL(prevMonth() ),
639 mMonthView->navigatorBar(), SIGNAL(goPrevMonth() ) ); 633 mMonthView->navigatorBar(), SIGNAL(goPrevMonth() ) );
640 connect( mMonthView->navigatorBar(), SIGNAL( goPrevYear() ), 634 connect( mMonthView->navigatorBar(), SIGNAL( goPrevYear() ),
641 mMainView->dateNavigator(), SLOT( selectPreviousYear() ) ); 635 mMainView->dateNavigator(), SLOT( selectPreviousYear() ) );
642 connect( mMonthView->navigatorBar(), SIGNAL( goNextYear() ), 636 connect( mMonthView->navigatorBar(), SIGNAL( goNextYear() ),
643 mMainView->dateNavigator(), SLOT( selectNextYear() ) ); 637 mMainView->dateNavigator(), SLOT( selectNextYear() ) );
644 connect( mMonthView->navigatorBar(), SIGNAL( goPrevMonth() ), 638 connect( mMonthView->navigatorBar(), SIGNAL( goPrevMonth() ),
645 mMainView->dateNavigator(), SLOT( selectPreviousMonth() ) ); 639 mMainView->dateNavigator(), SLOT( selectPreviousMonth() ) );
646 connect( mMonthView->navigatorBar(), SIGNAL( goNextMonth() ), 640 connect( mMonthView->navigatorBar(), SIGNAL( goNextMonth() ),
647 mMainView->dateNavigator(), SLOT( selectNextMonth() ) ); 641 mMainView->dateNavigator(), SLOT( selectNextMonth() ) );
648 connect( mMonthView->navigatorBar(), SIGNAL( goPrevWeek() ), 642 connect( mMonthView->navigatorBar(), SIGNAL( goPrevWeek() ),
649 mMainView->dateNavigator(), SLOT( selectPreviousWeek() ) ); 643 mMainView->dateNavigator(), SLOT( selectPreviousWeek() ) );
650 connect( mMonthView->navigatorBar(), SIGNAL( goNextWeek() ), 644 connect( mMonthView->navigatorBar(), SIGNAL( goNextWeek() ),
651 mMainView->dateNavigator(), SLOT( selectNextWeek() ) ); 645 mMainView->dateNavigator(), SLOT( selectNextWeek() ) );
652 646
653 connect( mMainView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), 647 connect( mMainView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ),
654 mMonthView->navigatorBar(), SLOT( selectDates( const KCal::DateList & ) ) ); 648 mMonthView->navigatorBar(), SLOT( selectDates( const KCal::DateList & ) ) );
655 649
656 650
657 connect( mMonthView->navigatorBar(), SIGNAL( monthSelected ( int ) ), 651 connect( mMonthView->navigatorBar(), SIGNAL( monthSelected ( int ) ),
658 mMainView->dateNavigator(), SLOT( slotMonthSelect( int ) ) ); 652 mMainView->dateNavigator(), SLOT( slotMonthSelect( int ) ) );
659 653
660 } 654 }
661} 655}
662void KOViewManager::showMonthViewWeek() 656void KOViewManager::showMonthViewWeek()
663{ 657{
664 createMonthView(); 658 createMonthView();
665 globalFlagBlockAgenda = 1; 659 globalFlagBlockAgenda = 1;
666 bool full = true; 660 bool full = true;
667 if ( mCurrentView == mMonthView) 661 if ( mCurrentView == mMonthView)
668 full = mMainView->leftFrame()->isVisible(); 662 full = mMainView->leftFrame()->isVisible();
669 if ( !KOPrefs::instance()->mMonthViewWeek ) { 663 if ( !KOPrefs::instance()->mMonthViewWeek ) {
670 mMonthView->switchView(); 664 mMonthView->switchView();
671 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() ) 665 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() )
672 full = false; 666 full = false;
673 else 667 else
674 full = true; 668 full = true;
675 } 669 }
676 mMainView->dateNavigator()->selectWeek(); 670 mMainView->dateNavigator()->selectWeek();
677 showView(mMonthView, full ); 671 showView(mMonthView, full );
678 mMonthView->setKeyBFocus(); 672 mMonthView->setKeyBFocus();
673 KOPrefs::instance()->mCurrentDisplayedView = VIEW_ML_VIEW ;
679} 674}
680 675
681void KOViewManager::showMonth( const QDate & date ) 676void KOViewManager::showMonth( const QDate & date )
682{ 677{
683 mMainView->dateNavigator()->blockSignals( true ); 678 mMainView->dateNavigator()->blockSignals( true );
684 mMainView->dateNavigator()->selectDate( date ); 679 mMainView->dateNavigator()->selectDate( date );
685 mMainView->dateNavigator()->blockSignals( false ); 680 mMainView->dateNavigator()->blockSignals( false );
686 showMonthView(); 681 showMonthView();
687} 682}
688void KOViewManager::showMonthView() 683void KOViewManager::showMonthView()
689 { 684 {
690 685
691 createMonthView(); 686 createMonthView();
692 globalFlagBlockAgenda = 1; 687 globalFlagBlockAgenda = 1;
693 //mFlagShowNextxDays = false; 688 //mFlagShowNextxDays = false;
694 bool full = true; 689 bool full = true;
695 if ( mCurrentView == mMonthView) 690 if ( mCurrentView == mMonthView)
696 full = mMainView->leftFrame()->isVisible(); 691 full = mMainView->leftFrame()->isVisible();
697 // if(mMonthView == mCurrentView) return; 692 // if(mMonthView == mCurrentView) return;
698 if ( KOPrefs::instance()->mMonthViewWeek ) { 693 if ( KOPrefs::instance()->mMonthViewWeek ) {
699 mMonthView->switchView(); 694 mMonthView->switchView();
700 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() ) 695 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() )
701 full = false; 696 full = false;
702 else 697 else
703 full = true; 698 full = true;
704 } 699 }
705 mMainView->dateNavigator()->selectMonth(); 700 mMainView->dateNavigator()->selectMonth();
706 701
707 showView(mMonthView, full ); 702 showView(mMonthView, full );
708 mMonthView->setKeyBFocus(); 703 mMonthView->setKeyBFocus();
704 KOPrefs::instance()->mCurrentDisplayedView = VIEW_M_VIEW ;
709 705
710} 706}
711 707
712void KOViewManager::showTodoView() 708void KOViewManager::showTodoView()
713{ 709{
714 //mFlagShowNextxDays = false; 710 //mFlagShowNextxDays = false;
715 if ( !mTodoView ) { 711 if ( !mTodoView ) {
716 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), 712 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(),
717 "KOViewManager::TodoView" ); 713 "KOViewManager::TodoView" );
718 714
719 addView( mTodoView ); 715 addView( mTodoView );
720 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); 716 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold );
721 717
722 // SIGNALS/SLOTS FOR TODO VIEW 718 // SIGNALS/SLOTS FOR TODO VIEW
723 connect( mTodoView, SIGNAL( newTodoSignal() ), 719 connect( mTodoView, SIGNAL( newTodoSignal() ),
724 mMainView, SLOT( newTodo() ) ); 720 mMainView, SLOT( newTodo() ) );
725 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), 721 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ),
726 mMainView, SLOT( newSubTodo( Todo *) ) ); 722 mMainView, SLOT( newSubTodo( Todo *) ) );
727 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), 723 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ),
728 mMainView, SLOT( showTodo( Todo * ) ) ); 724 mMainView, SLOT( showTodo( Todo * ) ) );
729 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), 725 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ),
730 mMainView, SLOT( editTodo( Todo * ) ) ); 726 mMainView, SLOT( editTodo( Todo * ) ) );
731 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), 727 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ),
732 mMainView, SLOT( deleteTodo( Todo * ) ) ); 728 mMainView, SLOT( deleteTodo( Todo * ) ) );
733 connect( mTodoView, SIGNAL( purgeCompletedSignal() ), 729 connect( mTodoView, SIGNAL( purgeCompletedSignal() ),
734 mMainView, SLOT( purgeCompleted() ) ); 730 mMainView, SLOT( purgeCompleted() ) );
735 731
736 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), 732 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ),
737 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 733 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
738 734
739 connect( mMainView, SIGNAL( configChanged() ), mTodoView, 735 connect( mMainView, SIGNAL( configChanged() ), mTodoView,
740 SLOT( updateConfig() ) ); 736 SLOT( updateConfig() ) );
741 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, 737 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView,
742 SLOT( updateTodo( Todo *, int ) ) ); 738 SLOT( updateTodo( Todo *, int ) ) );
743 connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), 739 connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ),
744 mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); 740 mMainView, SIGNAL ( todoModified( Todo *, int ) ) );
745 connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), 741 connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ),
746 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 742 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
747 connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), 743 connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ),
748 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 744 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
749 connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), 745 connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ),
750 mMainView, SLOT ( todo_unsub( Todo * ) ) ); 746 mMainView, SLOT ( todo_unsub( Todo * ) ) );
751 connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 747 connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
752 mMainView, SLOT ( todo_resub( Todo *, Todo *) ) ); 748 mMainView, SLOT ( todo_resub( Todo *, Todo *) ) );
753 connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ), 749 connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ),
754 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 750 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
755 connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ), 751 connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ),
756 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 752 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
757 KConfig *config = KOGlobals::config(); 753 KConfig *config = KOGlobals::config();
758 mTodoView->restoreLayout(config,"Todo View"); 754 mTodoView->restoreLayout(config,"Todo View");
759 mTodoView->setNavigator( mMainView->dateNavigator() ); 755 mTodoView->setNavigator( mMainView->dateNavigator() );
760 } 756 }
761 757
762 globalFlagBlockAgenda = 1; 758 globalFlagBlockAgenda = 1;
763 showView( mTodoView, true ); 759 showView( mTodoView, true );
760 KOPrefs::instance()->mCurrentDisplayedView = VIEW_T_VIEW ;
764 761
765} 762}
766 763
767void KOViewManager::showJournalView() 764void KOViewManager::showJournalView()
768{ 765{
769 //mFlagShowNextxDays = false; 766 //mFlagShowNextxDays = false;
770 if (!mJournalView) { 767 if (!mJournalView) {
771 mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), 768 mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(),
772 "KOViewManager::JournalView"); 769 "KOViewManager::JournalView");
773 connect( mMainView, SIGNAL( configChanged() ), mJournalView, 770 connect( mMainView, SIGNAL( configChanged() ), mJournalView,
774 SLOT( updateConfig() ) ); 771 SLOT( updateConfig() ) );
775 connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); 772 connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) );
776 addView(mJournalView); 773 addView(mJournalView);
777 } 774 }
778 775
779 showView(mJournalView); 776 showView(mJournalView);
780 mMainView->dateNavigator()->selectDates( 1 ); 777 mMainView->dateNavigator()->selectDates( 1 );
778 KOPrefs::instance()->mCurrentDisplayedView = VIEW_J_VIEW ;
781} 779}
782 780
783void KOViewManager::showTimeSpanView() 781void KOViewManager::showTimeSpanView()
784{ 782{
785 //mFlagShowNextxDays = false; 783 //mFlagShowNextxDays = false;
786 if (!mTimeSpanView) { 784 if (!mTimeSpanView) {
787 mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(), 785 mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(),
788 "KOViewManager::TimeSpanView"); 786 "KOViewManager::TimeSpanView");
789 addView(mTimeSpanView); 787 addView(mTimeSpanView);
790 788
791 mTimeSpanView->readSettings(); 789 mTimeSpanView->readSettings();
792 } 790 }
793 791
794 showView(mTimeSpanView); 792 showView(mTimeSpanView);
795} 793}
796 794
797Incidence *KOViewManager::currentSelection() 795Incidence *KOViewManager::currentSelection()
798{ 796{
799 if (!mCurrentView) return 0; 797 if (!mCurrentView) return 0;
800 if ( mCurrentView == mListView ) { 798 if ( mCurrentView == mListView ) {
801 if ( mListView->currentItem() ) 799 if ( mListView->currentItem() )
802 return mListView->currentItem(); 800 return mListView->currentItem();
803 } 801 }
804 return mCurrentView->selectedIncidences().first(); 802 return mCurrentView->selectedIncidences().first();
805} 803}
806 804
807QDate KOViewManager::currentSelectionDate() 805QDate KOViewManager::currentSelectionDate()
808{ 806{
809 QDate qd; 807 QDate qd;
810 if (mCurrentView) { 808 if (mCurrentView) {
811 DateList qvl = mCurrentView->selectedDates(); 809 DateList qvl = mCurrentView->selectedDates();
812 if (!qvl.isEmpty()) qd = qvl.first(); 810 if (!qvl.isEmpty()) qd = qvl.first();
813 } 811 }
814 return qd; 812 return qd;
815} 813}
816 814
817void KOViewManager::addView(KOrg::BaseView *view) 815void KOViewManager::addView(KOrg::BaseView *view)
818{ 816{
819#if QT_VERSION >= 0x030000 817#if QT_VERSION >= 0x030000
820 mMainView->viewStack()->addWidget( view ); 818 mMainView->viewStack()->addWidget( view );
821#else 819#else
822 mMainView->viewStack()->addWidget( view, 1 ); 820 mMainView->viewStack()->addWidget( view, 1 );
823#endif 821#endif
824} 822}
825 823
826void KOViewManager::setDocumentId( const QString &id ) 824void KOViewManager::setDocumentId( const QString &id )
827{ 825{
828 if (mTodoView) mTodoView->setDocumentId( id ); 826 if (mTodoView) mTodoView->setDocumentId( id );
829} 827}
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index d98915b..357154e 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,1171 +1,1172 @@
1#include <stdlib.h> 1#include <stdlib.h>
2 2
3#include <qaction.h> 3#include <qaction.h>
4#include <qpopupmenu.h> 4#include <qpopupmenu.h>
5#include <qpainter.h> 5#include <qpainter.h>
6#include <qwhatsthis.h> 6#include <qwhatsthis.h>
7#include <qpushbutton.h> 7#include <qpushbutton.h>
8#include <qmessagebox.h> 8#include <qmessagebox.h>
9#include <qlineedit.h> 9#include <qlineedit.h>
10#include <qtextcodec.h> 10#include <qtextcodec.h>
11#include <qfile.h> 11#include <qfile.h>
12#include <qdir.h> 12#include <qdir.h>
13#include <qapp.h> 13#include <qapp.h>
14#include <qfileinfo.h> 14#include <qfileinfo.h>
15#include <qlabel.h> 15#include <qlabel.h>
16#include <qspinbox.h> 16#include <qspinbox.h>
17#include <qcheckbox.h> 17#include <qcheckbox.h>
18#include <qmap.h> 18#include <qmap.h>
19#include <qwmatrix.h> 19#include <qwmatrix.h>
20#include <qtextbrowser.h> 20#include <qtextbrowser.h>
21#include <qtextstream.h> 21#include <qtextstream.h>
22#ifndef DESKTOP_VERSION 22#ifndef DESKTOP_VERSION
23#include <qpe/global.h> 23#include <qpe/global.h>
24#include <qpe/qpemenubar.h> 24#include <qpe/qpemenubar.h>
25#include <qpe/qpetoolbar.h> 25#include <qpe/qpetoolbar.h>
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#include <qtopia/alarmserver.h> 28#include <qtopia/alarmserver.h>
29#include <qtopia/qcopenvelope_qws.h> 29#include <qtopia/qcopenvelope_qws.h>
30#include <unistd.h> // for sleep 30#include <unistd.h> // for sleep
31#else 31#else
32#include <qmenubar.h> 32#include <qmenubar.h>
33#include <qtoolbar.h> 33#include <qtoolbar.h>
34#include <qapplication.h> 34#include <qapplication.h>
35//#include <resource.h> 35//#include <resource.h>
36 36
37#endif 37#endif
38#include <libkcal/calendarlocal.h> 38#include <libkcal/calendarlocal.h>
39#include <libkcal/todo.h> 39#include <libkcal/todo.h>
40#include <libkcal/phoneformat.h> 40#include <libkcal/phoneformat.h>
41#include <libkdepim/ksyncprofile.h> 41#include <libkdepim/ksyncprofile.h>
42#include <libkdepim/phoneaccess.h> 42#include <libkdepim/phoneaccess.h>
43#include <libkcal/kincidenceformatter.h> 43#include <libkcal/kincidenceformatter.h>
44#include <libkdepim/kpimglobalprefs.h> 44#include <libkdepim/kpimglobalprefs.h>
45 45
46#include "calendarview.h" 46#include "calendarview.h"
47#include "koviewmanager.h" 47#include "koviewmanager.h"
48#include "datenavigator.h" 48#include "datenavigator.h"
49#include "koagendaview.h" 49#include "koagendaview.h"
50#include "koagenda.h" 50#include "koagenda.h"
51#include "kodialogmanager.h" 51#include "kodialogmanager.h"
52#include "kdialogbase.h" 52#include "kdialogbase.h"
53#include "kapplication.h" 53#include "kapplication.h"
54#include "kofilterview.h" 54#include "kofilterview.h"
55#include "kstandarddirs.h" 55#include "kstandarddirs.h"
56#include "koprefs.h" 56#include "koprefs.h"
57#include "kfiledialog.h" 57#include "kfiledialog.h"
58#include "koglobals.h" 58#include "koglobals.h"
59#include "kglobal.h" 59#include "kglobal.h"
60#include "ktoolbar.h" 60#include "ktoolbar.h"
61#include "klocale.h" 61#include "klocale.h"
62#include "kconfig.h" 62#include "kconfig.h"
63#include "simplealarmclient.h" 63#include "simplealarmclient.h"
64#include "externalapphandler.h" 64#include "externalapphandler.h"
65 65
66using namespace KCal; 66using namespace KCal;
67#ifndef _WIN32_ 67#ifndef _WIN32_
68#include <unistd.h> 68#include <unistd.h>
69#else 69#else
70#ifdef _OL_IMPORT_ 70#ifdef _OL_IMPORT_
71#include "koimportoldialog.h" 71#include "koimportoldialog.h"
72#endif 72#endif
73#endif 73#endif
74#include "mainwindow.h" 74#include "mainwindow.h"
75 75
76 76
77class KOex2phonePrefs : public QDialog 77class KOex2phonePrefs : public QDialog
78{ 78{
79 public: 79 public:
80 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 80 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
81 QDialog( parent, name, true ) 81 QDialog( parent, name, true )
82 { 82 {
83 setCaption( i18n("Export to phone options") ); 83 setCaption( i18n("Export to phone options") );
84 QVBoxLayout* lay = new QVBoxLayout( this ); 84 QVBoxLayout* lay = new QVBoxLayout( this );
85 lay->setSpacing( 3 ); 85 lay->setSpacing( 3 );
86 lay->setMargin( 3 ); 86 lay->setMargin( 3 );
87 QLabel *lab; 87 QLabel *lab;
88 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 88 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
89 lab->setAlignment (AlignHCenter ); 89 lab->setAlignment (AlignHCenter );
90 QHBox* temphb; 90 QHBox* temphb;
91 temphb = new QHBox( this ); 91 temphb = new QHBox( this );
92 new QLabel( i18n("I/O device: "), temphb ); 92 new QLabel( i18n("I/O device: "), temphb );
93 mPhoneDevice = new QLineEdit( temphb); 93 mPhoneDevice = new QLineEdit( temphb);
94 lay->addWidget( temphb ); 94 lay->addWidget( temphb );
95 temphb = new QHBox( this ); 95 temphb = new QHBox( this );
96 new QLabel( i18n("Connection: "), temphb ); 96 new QLabel( i18n("Connection: "), temphb );
97 mPhoneConnection = new QLineEdit( temphb); 97 mPhoneConnection = new QLineEdit( temphb);
98 lay->addWidget( temphb ); 98 lay->addWidget( temphb );
99 temphb = new QHBox( this ); 99 temphb = new QHBox( this );
100 new QLabel( i18n("Model(opt.): "), temphb ); 100 new QLabel( i18n("Model(opt.): "), temphb );
101 mPhoneModel = new QLineEdit( temphb); 101 mPhoneModel = new QLineEdit( temphb);
102 lay->addWidget( temphb ); 102 lay->addWidget( temphb );
103 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); 103 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
104 mWriteBackFuture->setChecked( true ); 104 mWriteBackFuture->setChecked( true );
105 lay->addWidget( mWriteBackFuture ); 105 lay->addWidget( mWriteBackFuture );
106 temphb = new QHBox( this ); 106 temphb = new QHBox( this );
107 new QLabel( i18n("Max. weeks in future: ") , temphb ); 107 new QLabel( i18n("Max. weeks in future: ") , temphb );
108 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); 108 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
109 mWriteBackFutureWeeks->setValue( 8 ); 109 mWriteBackFutureWeeks->setValue( 8 );
110 lay->addWidget( temphb ); 110 lay->addWidget( temphb );
111 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); 111 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) );
112 lab->setAlignment (AlignHCenter ); 112 lab->setAlignment (AlignHCenter );
113 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 113 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
114 lay->addWidget( ok ); 114 lay->addWidget( ok );
115 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 115 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
116 lay->addWidget( cancel ); 116 lay->addWidget( cancel );
117 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 117 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
118 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 118 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
119 resize( 220, 240 ); 119 resize( 220, 240 );
120 qApp->processEvents(); 120 qApp->processEvents();
121 int dw = QApplication::desktop()->width(); 121 int dw = QApplication::desktop()->width();
122 int dh = QApplication::desktop()->height(); 122 int dh = QApplication::desktop()->height();
123 move( (dw-width())/2, (dh - height() )/2 ); 123 move( (dw-width())/2, (dh - height() )/2 );
124 } 124 }
125 125
126public: 126public:
127 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 127 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
128 QCheckBox* mWriteBackFuture; 128 QCheckBox* mWriteBackFuture;
129 QSpinBox* mWriteBackFutureWeeks; 129 QSpinBox* mWriteBackFutureWeeks;
130}; 130};
131 131
132int globalFlagBlockStartup; 132int globalFlagBlockStartup;
133MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 133MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
134 QMainWindow( parent, name ) 134 QMainWindow( parent, name )
135{ 135{
136 136
137 mClosed = false; 137 mClosed = false;
138 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 138 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
139 QString confFile = locateLocal("config","korganizerrc"); 139 QString confFile = locateLocal("config","korganizerrc");
140 QFileInfo finf ( confFile ); 140 QFileInfo finf ( confFile );
141 bool showWarning = !finf.exists(); 141 bool showWarning = !finf.exists();
142 setIcon(SmallIcon( "ko24" ) ); 142 setIcon(SmallIcon( "ko24" ) );
143 mBlockAtStartup = true; 143 mBlockAtStartup = true;
144 mFlagKeyPressed = false; 144 mFlagKeyPressed = false;
145 setCaption("KO/Pi"); 145 setCaption("KO/Pi");
146 KOPrefs *p = KOPrefs::instance(); 146 KOPrefs *p = KOPrefs::instance();
147 KPimGlobalPrefs::instance()->setGlobalConfig(); 147 KPimGlobalPrefs::instance()->setGlobalConfig();
148 p->mCurrentDisplayedView = 0;
148 if ( p->mHourSize > 22 ) 149 if ( p->mHourSize > 22 )
149 p->mHourSize = 22; 150 p->mHourSize = 22;
150 QMainWindow::ToolBarDock tbd; 151 QMainWindow::ToolBarDock tbd;
151 if ( p->mToolBarHor ) { 152 if ( p->mToolBarHor ) {
152 if ( p->mToolBarUp ) 153 if ( p->mToolBarUp )
153 tbd = Bottom; 154 tbd = Bottom;
154 else 155 else
155 tbd = Top; 156 tbd = Top;
156 } 157 }
157 else { 158 else {
158 if ( p->mToolBarUp ) 159 if ( p->mToolBarUp )
159 tbd = Right; 160 tbd = Right;
160 else 161 else
161 tbd = Left; 162 tbd = Left;
162 } 163 }
163 if ( KOPrefs::instance()->mUseAppColors ) 164 if ( KOPrefs::instance()->mUseAppColors )
164 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 165 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
165 globalFlagBlockStartup = 1; 166 globalFlagBlockStartup = 1;
166 iconToolBar = new QPEToolBar( this ); 167 iconToolBar = new QPEToolBar( this );
167 addToolBar (iconToolBar , tbd ); 168 addToolBar (iconToolBar , tbd );
168 169
169#ifdef DESKTOP_VERSION 170#ifdef DESKTOP_VERSION
170 if ( KOPrefs::instance()->mShowIconFilter ) 171 if ( KOPrefs::instance()->mShowIconFilter )
171#else 172#else
172 if ( KOPrefs::instance()->mShowIconFilter || !p->mShowIconOnetoolbar ) 173 if ( KOPrefs::instance()->mShowIconFilter || !p->mShowIconOnetoolbar )
173#endif 174#endif
174 175
175{ 176{
176 if ( p->mToolBarHorF ) { 177 if ( p->mToolBarHorF ) {
177 if ( p->mToolBarUpF ) 178 if ( p->mToolBarUpF )
178 tbd = Bottom; 179 tbd = Bottom;
179 else 180 else
180 tbd = Top; 181 tbd = Top;
181 } 182 }
182 else { 183 else {
183 if ( p->mToolBarUpF ) 184 if ( p->mToolBarUpF )
184 tbd = Right; 185 tbd = Right;
185 else 186 else
186 tbd = Left; 187 tbd = Left;
187 } 188 }
188 filterToolBar = new QPEToolBar ( this ); 189 filterToolBar = new QPEToolBar ( this );
189 filterMenubar = new QPEMenuBar( filterToolBar ); 190 filterMenubar = new QPEMenuBar( filterToolBar );
190 QFontMetrics fm ( filterMenubar->font() ); 191 QFontMetrics fm ( filterMenubar->font() );
191 192
192 filterPopupMenu = new QPopupMenu( this ); 193 filterPopupMenu = new QPopupMenu( this );
193 filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 ); 194 filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 );
194 QString addTest = "Ax"; 195 QString addTest = "Ax";
195#ifdef DESKTOP_VERSION 196#ifdef DESKTOP_VERSION
196 addTest = "AAAx"; 197 addTest = "AAAx";
197#endif 198#endif
198 filterMenubar->setFixedWidth( fm.width( i18n("No Filter")+addTest ) ); 199 filterMenubar->setFixedWidth( fm.width( i18n("No Filter")+addTest ) );
199 addToolBar (filterToolBar , tbd ); 200 addToolBar (filterToolBar , tbd );
200 connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) ); 201 connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) );
201 connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) ); 202 connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) );
202 if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar ) 203 if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar )
203 filterToolBar->hide(); 204 filterToolBar->hide();
204 } else { 205 } else {
205 filterToolBar = 0; 206 filterToolBar = 0;
206 filterMenubar = 0; 207 filterMenubar = 0;
207 filterPopupMenu = 0; 208 filterPopupMenu = 0;
208 } 209 }
209 if ( p->mShowIconOnetoolbar ) { 210 if ( p->mShowIconOnetoolbar ) {
210 viewToolBar = iconToolBar ; 211 viewToolBar = iconToolBar ;
211 navigatorToolBar = iconToolBar ; 212 navigatorToolBar = iconToolBar ;
212 } else { 213 } else {
213#ifndef DESKTOP_VERSION 214#ifndef DESKTOP_VERSION
214 setToolBarsMovable( false ); 215 setToolBarsMovable( false );
215#endif 216#endif
216 if ( p->mToolBarHorV ) { 217 if ( p->mToolBarHorV ) {
217 if ( p->mToolBarUpV ) 218 if ( p->mToolBarUpV )
218 tbd = Bottom; 219 tbd = Bottom;
219 else 220 else
220 tbd = Top; 221 tbd = Top;
221 } 222 }
222 else { 223 else {
223 if ( p->mToolBarUpV ) 224 if ( p->mToolBarUpV )
224 tbd = Right; 225 tbd = Right;
225 else 226 else
226 tbd = Left; 227 tbd = Left;
227 } 228 }
228 viewToolBar = new QPEToolBar( this ); 229 viewToolBar = new QPEToolBar( this );
229 addToolBar (viewToolBar , tbd ); 230 addToolBar (viewToolBar , tbd );
230 if ( p->mToolBarHorN ) { 231 if ( p->mToolBarHorN ) {
231 if ( p->mToolBarUpN ) 232 if ( p->mToolBarUpN )
232 tbd = Bottom; 233 tbd = Bottom;
233 else 234 else
234 tbd = Top; 235 tbd = Top;
235 } 236 }
236 else { 237 else {
237 if ( p->mToolBarUpN ) 238 if ( p->mToolBarUpN )
238 tbd = Right; 239 tbd = Right;
239 else 240 else
240 tbd = Left; 241 tbd = Left;
241 } 242 }
242 navigatorToolBar = new QPEToolBar( this ); 243 navigatorToolBar = new QPEToolBar( this );
243 addToolBar (navigatorToolBar , tbd ); 244 addToolBar (navigatorToolBar , tbd );
244 } 245 }
245 246
246 247
247 248
248 mCalendarModifiedFlag = false; 249 mCalendarModifiedFlag = false;
249 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 250 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
250 splash->setAlignment ( AlignCenter ); 251 splash->setAlignment ( AlignCenter );
251 setCentralWidget( splash ); 252 setCentralWidget( splash );
252#ifndef DESKTOP_VERSION 253#ifndef DESKTOP_VERSION
253 showMaximized(); 254 showMaximized();
254#endif 255#endif
255 256
256 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 257 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
257 setDefaultPreferences(); 258 setDefaultPreferences();
258 mCalendar = new CalendarLocal(); 259 mCalendar = new CalendarLocal();
259 mView = new CalendarView( mCalendar, this,"mCalendar " ); 260 mView = new CalendarView( mCalendar, this,"mCalendar " );
260 mView->hide(); 261 mView->hide();
261 //mView->resize(splash->size() ); 262 //mView->resize(splash->size() );
262 initActions(); 263 initActions();
263 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); 264 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu);
264 mSyncManager->setBlockSave(false); 265 mSyncManager->setBlockSave(false);
265 mView->setSyncManager(mSyncManager); 266 mView->setSyncManager(mSyncManager);
266#ifndef DESKTOP_VERSION 267#ifndef DESKTOP_VERSION
267 iconToolBar->show(); 268 iconToolBar->show();
268 qApp->processEvents(); 269 qApp->processEvents();
269#endif 270#endif
270 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 271 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
271 int vh = height() ; 272 int vh = height() ;
272 int vw = width(); 273 int vw = width();
273 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 274 //qDebug("Toolbar hei %d ",iconToolBar->height() );
274 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 275 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
275 vh -= iconToolBar->height(); 276 vh -= iconToolBar->height();
276 } else { 277 } else {
277 vw -= iconToolBar->height(); 278 vw -= iconToolBar->height();
278 } 279 }
279 //mView->setMaximumSize( splash->size() ); 280 //mView->setMaximumSize( splash->size() );
280 //mView->resize( splash->size() ); 281 //mView->resize( splash->size() );
281 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 282 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
282 mView->readSettings(); 283 mView->readSettings();
283 bool newFile = false; 284 bool newFile = false;
284 if( !QFile::exists( defaultFileName() ) ) { 285 if( !QFile::exists( defaultFileName() ) ) {
285 QFileInfo finfo ( defaultFileName() ); 286 QFileInfo finfo ( defaultFileName() );
286 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 287 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
287 qDebug("oldfile %s ", oldFile.latin1()); 288 qDebug("oldfile %s ", oldFile.latin1());
288 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; 289 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n";
289 finfo.setFile( oldFile ); 290 finfo.setFile( oldFile );
290 if (finfo.exists() ) { 291 if (finfo.exists() ) {
291 KMessageBox::information( this, message); 292 KMessageBox::information( this, message);
292 mView->openCalendar( oldFile ); 293 mView->openCalendar( oldFile );
293 qApp->processEvents(); 294 qApp->processEvents();
294 } else { 295 } else {
295 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 296 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
296 finfo.setFile( oldFile ); 297 finfo.setFile( oldFile );
297 if (finfo.exists() ) { 298 if (finfo.exists() ) {
298 KMessageBox::information( this, message); 299 KMessageBox::information( this, message);
299 mView->openCalendar( oldFile ); 300 mView->openCalendar( oldFile );
300 qApp->processEvents(); 301 qApp->processEvents();
301 } 302 }
302 } 303 }
303 mView->saveCalendar( defaultFileName() ); 304 mView->saveCalendar( defaultFileName() );
304 newFile = true; 305 newFile = true;
305 } 306 }
306 307
307 QTime neededSaveTime = QDateTime::currentDateTime().time(); 308 QTime neededSaveTime = QDateTime::currentDateTime().time();
308 mView->openCalendar( defaultFileName() ); 309 mView->openCalendar( defaultFileName() );
309 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 310 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
310 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 311 qDebug("KO: Calendar loading time: %d ms",msNeeded );
311 312
312 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { 313 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) {
313 KOPrefs::instance()->setAllDefaults(); 314 KOPrefs::instance()->setAllDefaults();
314 int count = mView->addCategories(); 315 int count = mView->addCategories();
315 } 316 }
316 processIncidenceSelection( 0 ); 317 processIncidenceSelection( 0 );
317 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 318 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
318 SLOT( processIncidenceSelection( Incidence * ) ) ); 319 SLOT( processIncidenceSelection( Incidence * ) ) );
319 connect( mView, SIGNAL( modifiedChanged( bool ) ), 320 connect( mView, SIGNAL( modifiedChanged( bool ) ),
320 SLOT( slotModifiedChanged( bool ) ) ); 321 SLOT( slotModifiedChanged( bool ) ) );
321 322
322 323
323 connect( mView, SIGNAL( tempDisableBR(bool) ), 324 connect( mView, SIGNAL( tempDisableBR(bool) ),
324 SLOT( disableBR(bool) ) ); 325 SLOT( disableBR(bool) ) );
325 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 326 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
326 mView->setModified( false ); 327 mView->setModified( false );
327 mBlockAtStartup = false; 328 mBlockAtStartup = false;
328 mView->setModified( false ); 329 mView->setModified( false );
329 setCentralWidget( mView ); 330 setCentralWidget( mView );
330 globalFlagBlockStartup = 0; 331 globalFlagBlockStartup = 0;
331 mView->show(); 332 mView->show();
332 delete splash; 333 delete splash;
333 if ( newFile ) 334 if ( newFile )
334 mView->updateConfig(); 335 mView->updateConfig();
335 // qApp->processEvents(); 336 // qApp->processEvents();
336 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 337 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
337 //fillSyncMenu(); 338 //fillSyncMenu();
338 339
339 340
340 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); 341 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
341 connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); 342 connect(mView , SIGNAL( save() ), this, SLOT( save() ) );
342 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); 343 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) );
343 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 344 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
344 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 345 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
345 mSyncManager->setDefaultFileName( sentSyncFile()); 346 mSyncManager->setDefaultFileName( sentSyncFile());
346 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); 347 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
347 mSyncManager->fillSyncMenu(); 348 mSyncManager->fillSyncMenu();
348 349
349 350
350 351
351 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 352 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
352 if ( showWarning ) { 353 if ( showWarning ) {
353 KMessageBox::information( this, 354 KMessageBox::information( this,
354 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); 355 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information");
355 qApp->processEvents(); 356 qApp->processEvents();
356 mView->dialogManager()->showSyncOptions(); 357 mView->dialogManager()->showSyncOptions();
357 } 358 }
358 359
359 //US listen for result adressed from Ka/Pi 360 //US listen for result adressed from Ka/Pi
360#ifndef DESKTOP_VERSION 361#ifndef DESKTOP_VERSION
361 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 362 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
362#endif 363#endif
363#ifndef DESKTOP_VERSION 364#ifndef DESKTOP_VERSION
364 infrared = 0; 365 infrared = 0;
365#endif 366#endif
366 updateFilterToolbar(); 367 updateFilterToolbar();
367 updateWeek( mView->startDate() ); 368 updateWeek( mView->startDate() );
368 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), 369 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ),
369 SLOT( updateWeekNum( const KCal::DateList & ) ) ); 370 SLOT( updateWeekNum( const KCal::DateList & ) ) );
370 mBRdisabled = false; 371 mBRdisabled = false;
371 //toggleBeamReceive(); 372 //toggleBeamReceive();
372} 373}
373MainWindow::~MainWindow() 374MainWindow::~MainWindow()
374{ 375{
375 //qDebug("MainWindow::~MainWindow() "); 376 //qDebug("MainWindow::~MainWindow() ");
376 //save toolbar location 377 //save toolbar location
377 delete mCalendar; 378 delete mCalendar;
378 delete mSyncManager; 379 delete mSyncManager;
379#ifndef DESKTOP_VERSION 380#ifndef DESKTOP_VERSION
380 if ( infrared ) 381 if ( infrared )
381 delete infrared; 382 delete infrared;
382#endif 383#endif
383 384
384 385
385} 386}
386 387
387void MainWindow::disableBR(bool b) 388void MainWindow::disableBR(bool b)
388{ 389{
389#ifndef DESKTOP_VERSION 390#ifndef DESKTOP_VERSION
390 if ( b ) { 391 if ( b ) {
391 if ( infrared ) { 392 if ( infrared ) {
392 toggleBeamReceive(); 393 toggleBeamReceive();
393 mBRdisabled = true; 394 mBRdisabled = true;
394 } 395 }
395 mBRdisabled = true; 396 mBRdisabled = true;
396 } else { 397 } else {
397 if ( mBRdisabled ) { 398 if ( mBRdisabled ) {
398 mBRdisabled = false; 399 mBRdisabled = false;
399 //makes no sense,because other cal ap is probably running 400 //makes no sense,because other cal ap is probably running
400 // toggleBeamReceive(); 401 // toggleBeamReceive();
401 } 402 }
402 } 403 }
403#endif 404#endif
404 405
405} 406}
406bool MainWindow::beamReceiveEnabled() 407bool MainWindow::beamReceiveEnabled()
407{ 408{
408#ifndef DESKTOP_VERSION 409#ifndef DESKTOP_VERSION
409 return ( infrared != 0 ); 410 return ( infrared != 0 );
410#endif 411#endif
411 return false; 412 return false;
412} 413}
413 414
414void MainWindow::toggleBeamReceive() 415void MainWindow::toggleBeamReceive()
415{ 416{
416 if ( mBRdisabled ) 417 if ( mBRdisabled )
417 return; 418 return;
418#ifndef DESKTOP_VERSION 419#ifndef DESKTOP_VERSION
419 if ( infrared ) { 420 if ( infrared ) {
420 qDebug("disable BeamReceive "); 421 qDebug("disable BeamReceive ");
421 delete infrared; 422 delete infrared;
422 infrared = 0; 423 infrared = 0;
423 brAction->setOn(false); 424 brAction->setOn(false);
424 return; 425 return;
425 } 426 }
426 qDebug("enable BeamReceive "); 427 qDebug("enable BeamReceive ");
427 brAction->setOn(true); 428 brAction->setOn(true);
428 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; 429 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ;
429 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); 430 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& )));
430#endif 431#endif
431} 432}
432void MainWindow::showMaximized () 433void MainWindow::showMaximized ()
433{ 434{
434#ifndef DESKTOP_VERSION 435#ifndef DESKTOP_VERSION
435 if ( ! globalFlagBlockStartup ) 436 if ( ! globalFlagBlockStartup )
436 if ( mClosed ) 437 if ( mClosed )
437 mView->goToday(); 438 mView->goToday();
438#endif 439#endif
439 QWidget::showMaximized () ; 440 QWidget::showMaximized () ;
440 mClosed = false; 441 mClosed = false;
441} 442}
442void MainWindow::closeEvent( QCloseEvent* ce ) 443void MainWindow::closeEvent( QCloseEvent* ce )
443{ 444{
444 445
445 446
446 447
447 if ( ! KOPrefs::instance()->mAskForQuit ) { 448 if ( ! KOPrefs::instance()->mAskForQuit ) {
448 saveOnClose(); 449 saveOnClose();
449 mClosed = true; 450 mClosed = true;
450 ce->accept(); 451 ce->accept();
451 return; 452 return;
452 453
453 } 454 }
454 455
455 switch( QMessageBox::information( this, "KO/Pi", 456 switch( QMessageBox::information( this, "KO/Pi",
456 i18n("Do you really want\nto close KO/Pi?"), 457 i18n("Do you really want\nto close KO/Pi?"),
457 i18n("Close"), i18n("No"), 458 i18n("Close"), i18n("No"),
458 0, 0 ) ) { 459 0, 0 ) ) {
459 case 0: 460 case 0:
460 saveOnClose(); 461 saveOnClose();
461 mClosed = true; 462 mClosed = true;
462 ce->accept(); 463 ce->accept();
463 break; 464 break;
464 case 1: 465 case 1:
465 ce->ignore(); 466 ce->ignore();
466 break; 467 break;
467 case 2: 468 case 2:
468 469
469 default: 470 default:
470 break; 471 break;
471 } 472 }
472 473
473 474
474} 475}
475 476
476void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 477void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
477{ 478{
478 QDataStream stream( data, IO_ReadOnly ); 479 QDataStream stream( data, IO_ReadOnly );
479 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 480 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
480 //QString datamess; 481 //QString datamess;
481 //qDebug("message "); 482 //qDebug("message ");
482 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 483 qDebug("KO: QCOP message received: %s ", cmsg.data() );
483 484
484 if ( cmsg == "setDocument(QString)" ) { 485 if ( cmsg == "setDocument(QString)" ) {
485 QDataStream stream( data, IO_ReadOnly ); 486 QDataStream stream( data, IO_ReadOnly );
486 QString fileName; 487 QString fileName;
487 stream >> fileName; 488 stream >> fileName;
488 //qDebug("filename %s ", fileName.latin1()); 489 //qDebug("filename %s ", fileName.latin1());
489 showMaximized(); 490 showMaximized();
490 raise(); 491 raise();
491 KOPrefs::instance()->mLastSyncedLocalFile = fileName ; 492 KOPrefs::instance()->mLastSyncedLocalFile = fileName ;
492 mSyncManager->slotSyncMenu( 1002 ); 493 mSyncManager->slotSyncMenu( 1002 );
493 return; 494 return;
494 } 495 }
495 496
496 if ( cmsg == "-writeFile" ) { 497 if ( cmsg == "-writeFile" ) {
497 // I made from the "-writeFile" an "-writeAlarm" 498 // I made from the "-writeFile" an "-writeAlarm"
498 mView->viewManager()->showWhatsNextView(); 499 mView->viewManager()->showWhatsNextView();
499 mCalendar->checkAlarmForIncidence( 0, true); 500 mCalendar->checkAlarmForIncidence( 0, true);
500 showMaximized(); 501 showMaximized();
501 raise(); 502 raise();
502 return; 503 return;
503 504
504 } 505 }
505 if ( cmsg == "-writeFileSilent" ) { 506 if ( cmsg == "-writeFileSilent" ) {
506 // I made from the "-writeFile" an "-writeAlarm" 507 // I made from the "-writeFile" an "-writeAlarm"
507 // mView->viewManager()->showWhatsNextView(); 508 // mView->viewManager()->showWhatsNextView();
508 mCalendar->checkAlarmForIncidence( 0, true); 509 mCalendar->checkAlarmForIncidence( 0, true);
509 //showMaximized(); 510 //showMaximized();
510 //raise(); 511 //raise();
511 hide(); 512 hide();
512 return; 513 return;
513 } 514 }
514 if ( cmsg == "-newCountdown" ) { 515 if ( cmsg == "-newCountdown" ) {
515 qDebug("newCountdown "); 516 qDebug("newCountdown ");
516 517
517 } 518 }
518 QString msg ; 519 QString msg ;
519 QString allmsg = cmsg; 520 QString allmsg = cmsg;
520 while ( allmsg.length() > 0 ) { 521 while ( allmsg.length() > 0 ) {
521 int nextC = allmsg.find( "-", 1 ); 522 int nextC = allmsg.find( "-", 1 );
522 if ( nextC == -1 ) { 523 if ( nextC == -1 ) {
523 msg = allmsg; 524 msg = allmsg;
524 allmsg = ""; 525 allmsg = "";
525 } else{ 526 } else{
526 msg = allmsg.left( nextC ); 527 msg = allmsg.left( nextC );
527 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 528 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
528 } 529 }
529 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 530 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
530 if ( msg == "-newEvent" ) { 531 if ( msg == "-newEvent" ) {
531 mView->newEvent(); 532 mView->newEvent();
532 } 533 }
533 if ( msg == "-newTodo" ) { 534 if ( msg == "-newTodo" ) {
534 mView->newTodo(); 535 mView->newTodo();
535 536
536 } 537 }
537 if ( msg == "-showWN" ) { 538 if ( msg == "-showWN" ) {
538 mView->viewManager()->showWhatsNextView(); 539 mView->viewManager()->showWhatsNextView();
539 } 540 }
540 if ( msg == "-showTodo" ) { 541 if ( msg == "-showTodo" ) {
541 mView->viewManager()->showTodoView(); 542 mView->viewManager()->showTodoView();
542 } 543 }
543 if ( msg == "-showList" ) { 544 if ( msg == "-showList" ) {
544 mView->viewManager()->showListView(); 545 mView->viewManager()->showListView();
545 } 546 }
546 else if ( msg == "-showDay" ) { 547 else if ( msg == "-showDay" ) {
547 mView->viewManager()->showDayView(); 548 mView->viewManager()->showDayView();
548 } 549 }
549 else if ( msg == "-showWWeek" ) { 550 else if ( msg == "-showWWeek" ) {
550 mView->viewManager()->showWorkWeekView(); 551 mView->viewManager()->showWorkWeekView();
551 } 552 }
552 else if ( msg == "-ringSync" ) { 553 else if ( msg == "-ringSync" ) {
553 mSyncManager->multiSync( false ); 554 mSyncManager->multiSync( false );
554 } 555 }
555 else if ( msg == "-showWeek" ) { 556 else if ( msg == "-showWeek" ) {
556 mView->viewManager()->showWeekView(); 557 mView->viewManager()->showWeekView();
557 } 558 }
558 else if ( msg == "-showTodo" ) { 559 else if ( msg == "-showTodo" ) {
559 mView->viewManager()->showTodoView(); 560 mView->viewManager()->showTodoView();
560 } 561 }
561 else if ( msg == "-showJournal" ) { 562 else if ( msg == "-showJournal" ) {
562 mView->dateNavigator()->selectDates( 1 ); 563 mView->dateNavigator()->selectDates( 1 );
563 mView->dateNavigator()->selectToday(); 564 mView->dateNavigator()->selectToday();
564 mView->viewManager()->showJournalView(); 565 mView->viewManager()->showJournalView();
565 } 566 }
566 else if ( msg == "-showKO" ) { 567 else if ( msg == "-showKO" ) {
567 mView->viewManager()->showNextXView(); 568 mView->viewManager()->showNextXView();
568 } 569 }
569 else if ( msg == "-showWNext" ) { 570 else if ( msg == "-showWNext" ) {
570 mView->viewManager()->showWhatsNextView(); 571 mView->viewManager()->showWhatsNextView();
571 } 572 }
572 else if ( msg == "nextView()" ) { 573 else if ( msg == "nextView()" ) {
573 mView->viewManager()->showNextView(); 574 mView->viewManager()->showNextView();
574 } 575 }
575 else if ( msg == "-showNextXView" ) { 576 else if ( msg == "-showNextXView" ) {
576 mView->viewManager()->showNextXView(); 577 mView->viewManager()->showNextXView();
577 } 578 }
578 579
579 580
580 } 581 }
581 582
582 showMaximized(); 583 showMaximized();
583 raise(); 584 raise();
584} 585}
585 586
586QPixmap MainWindow::loadPixmap( QString name ) 587QPixmap MainWindow::loadPixmap( QString name )
587{ 588{
588 return SmallIcon( name ); 589 return SmallIcon( name );
589 590
590} 591}
591void MainWindow::initActions() 592void MainWindow::initActions()
592{ 593{
593 //KOPrefs::instance()->mShowFullMenu 594 //KOPrefs::instance()->mShowFullMenu
594 iconToolBar->clear(); 595 iconToolBar->clear();
595 KOPrefs *p = KOPrefs::instance(); 596 KOPrefs *p = KOPrefs::instance();
596 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 597 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
597 598
598 QPopupMenu *viewMenu = new QPopupMenu( this ); 599 QPopupMenu *viewMenu = new QPopupMenu( this );
599 QPopupMenu *actionMenu = new QPopupMenu( this ); 600 QPopupMenu *actionMenu = new QPopupMenu( this );
600 QPopupMenu *importMenu = new QPopupMenu( this ); 601 QPopupMenu *importMenu = new QPopupMenu( this );
601 QPopupMenu *importMenu_X = new QPopupMenu( this ); 602 QPopupMenu *importMenu_X = new QPopupMenu( this );
602 QPopupMenu *exportMenu_X = new QPopupMenu( this ); 603 QPopupMenu *exportMenu_X = new QPopupMenu( this );
603 QPopupMenu *beamMenu_X = new QPopupMenu( this ); 604 QPopupMenu *beamMenu_X = new QPopupMenu( this );
604 selectFilterMenu = new QPopupMenu( this ); 605 selectFilterMenu = new QPopupMenu( this );
605 selectFilterMenu->setCheckable( true ); 606 selectFilterMenu->setCheckable( true );
606 syncMenu = new QPopupMenu( this ); 607 syncMenu = new QPopupMenu( this );
607 configureAgendaMenu = new QPopupMenu( this ); 608 configureAgendaMenu = new QPopupMenu( this );
608 configureToolBarMenu = new QPopupMenu( this ); 609 configureToolBarMenu = new QPopupMenu( this );
609 QPopupMenu *helpMenu = new QPopupMenu( this ); 610 QPopupMenu *helpMenu = new QPopupMenu( this );
610 QIconSet icon; 611 QIconSet icon;
611 int pixWid = 22, pixHei = 22; 612 int pixWid = 22, pixHei = 22;
612 QString pathString = ""; 613 QString pathString = "";
613 if ( !p->mToolBarMiniIcons ) { 614 if ( !p->mToolBarMiniIcons ) {
614 if ( QApplication::desktop()->width() < 480 ) { 615 if ( QApplication::desktop()->width() < 480 ) {
615 pathString += "icons16/"; 616 pathString += "icons16/";
616 pixWid = 18; pixHei = 16; 617 pixWid = 18; pixHei = 16;
617 } 618 }
618 } else { 619 } else {
619 pathString += "iconsmini/"; 620 pathString += "iconsmini/";
620 pixWid = 18; pixHei = 16; 621 pixWid = 18; pixHei = 16;
621 } 622 }
622 if ( KOPrefs::instance()->mShowFullMenu ) { 623 if ( KOPrefs::instance()->mShowFullMenu ) {
623 QMenuBar *menuBar1; 624 QMenuBar *menuBar1;
624 menuBar1 = menuBar(); 625 menuBar1 = menuBar();
625 menuBar1->insertItem( i18n("File"), importMenu ); 626 menuBar1->insertItem( i18n("File"), importMenu );
626 menuBar1->insertItem( i18n("View"), viewMenu ); 627 menuBar1->insertItem( i18n("View"), viewMenu );
627 menuBar1->insertItem( i18n("Actions"), actionMenu ); 628 menuBar1->insertItem( i18n("Actions"), actionMenu );
628#ifdef DESKTOP_VERSION 629#ifdef DESKTOP_VERSION
629 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 630 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
630 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 631 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
631#else 632#else
632 menuBar1->insertItem( i18n("Sync"), syncMenu ); 633 menuBar1->insertItem( i18n("Sync"), syncMenu );
633 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu ); 634 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu );
634#endif 635#endif
635 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 636 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
636 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 637 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
637 menuBar1->insertItem( i18n("Help"), helpMenu ); 638 menuBar1->insertItem( i18n("Help"), helpMenu );
638 } else { 639 } else {
639 QPEMenuBar *menuBar1; 640 QPEMenuBar *menuBar1;
640 menuBar1 = new QPEMenuBar( iconToolBar ); 641 menuBar1 = new QPEMenuBar( iconToolBar );
641 QPopupMenu *menuBar = new QPopupMenu( this ); 642 QPopupMenu *menuBar = new QPopupMenu( this );
642 icon = loadPixmap( pathString + "z_menu" ); 643 icon = loadPixmap( pathString + "z_menu" );
643 menuBar1->insertItem( icon.pixmap(), menuBar); 644 menuBar1->insertItem( icon.pixmap(), menuBar);
644 //menuBar1->insertItem( i18n("ME"), menuBar); 645 //menuBar1->insertItem( i18n("ME"), menuBar);
645 menuBar->insertItem( i18n("File"), importMenu ); 646 menuBar->insertItem( i18n("File"), importMenu );
646 menuBar->insertItem( i18n("View"), viewMenu ); 647 menuBar->insertItem( i18n("View"), viewMenu );
647 menuBar->insertItem( i18n("Actions"), actionMenu ); 648 menuBar->insertItem( i18n("Actions"), actionMenu );
648 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 649 menuBar->insertItem( i18n("Synchronize"), syncMenu );
649 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 650 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
650 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 651 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
651 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 652 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
652 menuBar->insertItem( i18n("Help"), helpMenu ); 653 menuBar->insertItem( i18n("Help"), helpMenu );
653 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 654 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
654 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 655 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
655 } 656 }
656 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 657 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
657 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); 658 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) );
658 659
659 660
660 mWeekBgColor = iconToolBar->backgroundColor(); 661 mWeekBgColor = iconToolBar->backgroundColor();
661 mWeekPixmap.resize( pixWid , pixHei ); 662 mWeekPixmap.resize( pixWid , pixHei );
662 mWeekPixmap.fill( mWeekBgColor ); 663 mWeekPixmap.fill( mWeekBgColor );
663 icon = mWeekPixmap; 664 icon = mWeekPixmap;
664 mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this ); 665 mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this );
665 if ( p-> mShowIconWeekNum ) 666 if ( p-> mShowIconWeekNum )
666 mWeekAction->addTo( iconToolBar ); 667 mWeekAction->addTo( iconToolBar );
667 mWeekFont = font(); 668 mWeekFont = font();
668 669
669 int fontPoint = mWeekFont.pointSize(); 670 int fontPoint = mWeekFont.pointSize();
670 QFontMetrics f( mWeekFont ); 671 QFontMetrics f( mWeekFont );
671 int fontWid = f.width( "30" ); 672 int fontWid = f.width( "30" );
672 while ( fontWid > pixWid ) { 673 while ( fontWid > pixWid ) {
673 --fontPoint; 674 --fontPoint;
674 mWeekFont.setPointSize( fontPoint ); 675 mWeekFont.setPointSize( fontPoint );
675 QFontMetrics f( mWeekFont ); 676 QFontMetrics f( mWeekFont );
676 fontWid = f.width( "30" ); 677 fontWid = f.width( "30" );
677 //qDebug("dec-- "); 678 //qDebug("dec-- ");
678 } 679 }
679 680
680 connect( mWeekAction, SIGNAL( activated() ), 681 connect( mWeekAction, SIGNAL( activated() ),
681 this, SLOT( weekAction() ) ); 682 this, SLOT( weekAction() ) );
682 683
683 connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); 684 connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) );
684 if ( p->mShowIconFilterview ) { 685 if ( p->mShowIconFilterview ) {
685 icon = loadPixmap( pathString + "filter" ); 686 icon = loadPixmap( pathString + "filter" );
686 actionFilterMenuTB = new QAction( i18n("Filter selector"), icon, i18n("Filter selector"), 0, this ); 687 actionFilterMenuTB = new QAction( i18n("Filter selector"), icon, i18n("Filter selector"), 0, this );
687 connect( actionFilterMenuTB, SIGNAL( activated() ), 688 connect( actionFilterMenuTB, SIGNAL( activated() ),
688 this, SLOT( fillFilterMenuTB() ) ); 689 this, SLOT( fillFilterMenuTB() ) );
689 actionFilterMenuTB->addTo( iconToolBar ); 690 actionFilterMenuTB->addTo( iconToolBar );
690 selectFilterMenuTB = new QPopupMenu( this ); 691 selectFilterMenuTB = new QPopupMenu( this );
691 selectFilterMenuTB->setCheckable( true ); 692 selectFilterMenuTB->setCheckable( true );
692 connect ( selectFilterMenuTB, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 693 connect ( selectFilterMenuTB, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
693 } 694 }
694 695
695 //#endif 696 //#endif
696 // ****************** 697 // ******************
697 QAction *action; 698 QAction *action;
698 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 699 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
699 configureToolBarMenu->setCheckable( true ); 700 configureToolBarMenu->setCheckable( true );
700 701
701 702
702 configureAgendaMenu->setCheckable( true ); 703 configureAgendaMenu->setCheckable( true );
703 int iii ; 704 int iii ;
704 for ( iii = 1;iii<= 10 ;++iii ){ 705 for ( iii = 1;iii<= 10 ;++iii ){
705 configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); 706 configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 );
706 } 707 }
707 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 708 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
708 709
709 connect( configureAgendaMenu, SIGNAL( aboutToShow()), 710 connect( configureAgendaMenu, SIGNAL( aboutToShow()),
710 this, SLOT( showConfigureAgenda( ) ) ); 711 this, SLOT( showConfigureAgenda( ) ) );
711 712
712 icon = loadPixmap( pathString + "configure" ); 713 icon = loadPixmap( pathString + "configure" );
713 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); 714 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this );
714 action->addTo( actionMenu ); 715 action->addTo( actionMenu );
715 connect( action, SIGNAL( activated() ), 716 connect( action, SIGNAL( activated() ),
716 mView, SLOT( edit_options() ) ); 717 mView, SLOT( edit_options() ) );
717 actionMenu->insertSeparator(); 718 actionMenu->insertSeparator();
718 719
719 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); 720 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this );
720 action->addTo( actionMenu ); 721 action->addTo( actionMenu );
721 connect( action, SIGNAL( activated() ), 722 connect( action, SIGNAL( activated() ),
722 mView, SLOT( undo_delete() ) ); 723 mView, SLOT( undo_delete() ) );
723 actionMenu->insertSeparator(); 724 actionMenu->insertSeparator();
724 725
725 icon = loadPixmap( pathString + "newevent" ); 726 icon = loadPixmap( pathString + "newevent" );
726 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 727 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
727 configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 ); 728 configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 );
728 configureToolBarMenu->insertSeparator(); 729 configureToolBarMenu->insertSeparator();
729 configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 ); 730 configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 );
730 configureToolBarMenu->insertSeparator(); 731 configureToolBarMenu->insertSeparator();
731 configureToolBarMenu->insertItem(i18n("Week Number"), 400); 732 configureToolBarMenu->insertItem(i18n("Week Number"), 400);
732 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 733 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
733 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 734 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
734 ne_action->addTo( actionMenu ); 735 ne_action->addTo( actionMenu );
735 connect( ne_action, SIGNAL( activated() ), 736 connect( ne_action, SIGNAL( activated() ),
736 mView, SLOT( newEvent() ) ); 737 mView, SLOT( newEvent() ) );
737 icon = loadPixmap( pathString + "newtodo" ); 738 icon = loadPixmap( pathString + "newtodo" );
738 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 739 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
739 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 740 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
740 nt_action->addTo( actionMenu ); 741 nt_action->addTo( actionMenu );
741 connect( nt_action, SIGNAL( activated() ), 742 connect( nt_action, SIGNAL( activated() ),
742 mView, SLOT( newTodo() ) ); 743 mView, SLOT( newTodo() ) );
743 744
744 icon = loadPixmap( pathString + "today" ); 745 icon = loadPixmap( pathString + "today" );
745 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 746 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
746 today_action->addTo( viewMenu ); 747 today_action->addTo( viewMenu );
747 connect( today_action, SIGNAL( activated() ), 748 connect( today_action, SIGNAL( activated() ),
748 mView, SLOT( goToday() ) ); 749 mView, SLOT( goToday() ) );
749 viewMenu->insertSeparator(); 750 viewMenu->insertSeparator();
750 751
751 // *********************** 752 // ***********************
752 if ( KOPrefs::instance()->mVerticalScreen ) { 753 if ( KOPrefs::instance()->mVerticalScreen ) {
753 icon = SmallIcon( "1updownarrow" ); 754 icon = SmallIcon( "1updownarrow" );
754 } else { 755 } else {
755 icon = SmallIcon("1leftrightarrow" ); 756 icon = SmallIcon("1leftrightarrow" );
756 } 757 }
757 configureToolBarMenu->insertItem(icon, i18n("Toggle Fullscreen"), 28 ); 758 configureToolBarMenu->insertItem(icon, i18n("Toggle Fullscreen"), 28 );
758 QAction* FSaction = new QAction( i18n("Toggle Fullscreen"), icon, i18n("Toggle Fullscreen"), 0, this ); 759 QAction* FSaction = new QAction( i18n("Toggle Fullscreen"), icon, i18n("Toggle Fullscreen"), 0, this );
759 FSaction->addTo( viewMenu ); 760 FSaction->addTo( viewMenu );
760 connect( FSaction, SIGNAL( activated() ), mView, SLOT( toggleExpand() )); 761 connect( FSaction, SIGNAL( activated() ), mView, SLOT( toggleExpand() ));
761 762
762 icon = loadPixmap( pathString + "navi" ); 763 icon = loadPixmap( pathString + "navi" );
763 configureToolBarMenu->insertItem(icon, i18n("Toggle DateNavigator"), 22 ); 764 configureToolBarMenu->insertItem(icon, i18n("Toggle DateNavigator"), 22 );
764 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 765 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
765 action->addTo( viewMenu ); 766 action->addTo( viewMenu );
766 connect( action, SIGNAL( activated() ), 767 connect( action, SIGNAL( activated() ),
767 mView, SLOT( toggleDateNavigatorWidget() ) ); 768 mView, SLOT( toggleDateNavigatorWidget() ) );
768 mToggleNav = action ; 769 mToggleNav = action ;
769 icon = loadPixmap( pathString + "filter" ); 770 icon = loadPixmap( pathString + "filter" );
770 configureToolBarMenu->insertItem(icon, i18n("Filter menu icon"), 26 ); 771 configureToolBarMenu->insertItem(icon, i18n("Filter menu icon"), 26 );
771 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); 772 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this );
772 action->addTo( viewMenu ); 773 action->addTo( viewMenu );
773 connect( action, SIGNAL( activated() ), 774 connect( action, SIGNAL( activated() ),
774 mView, SLOT( toggleFilter() ) ); 775 mView, SLOT( toggleFilter() ) );
775 mToggleFilter = action; 776 mToggleFilter = action;
776 icon = loadPixmap( pathString + "allday" ); 777 icon = loadPixmap( pathString + "allday" );
777 configureToolBarMenu->insertItem(icon, i18n("Toggle Allday"), 24 ); 778 configureToolBarMenu->insertItem(icon, i18n("Toggle Allday"), 24 );
778 action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this ); 779 action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this );
779 action->addTo( viewMenu ); 780 action->addTo( viewMenu );
780 connect( action, SIGNAL( activated() ), 781 connect( action, SIGNAL( activated() ),
781 mView, SLOT( toggleAllDaySize() ) ); 782 mView, SLOT( toggleAllDaySize() ) );
782 mToggleAllday = action; 783 mToggleAllday = action;
783 784
784 785
785 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), 786 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
786 mToggleNav, SLOT( setEnabled ( bool ) ) ); 787 mToggleNav, SLOT( setEnabled ( bool ) ) );
787 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), 788 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
788 mToggleFilter, SLOT( setEnabled ( bool ) ) ); 789 mToggleFilter, SLOT( setEnabled ( bool ) ) );
789 connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), 790 connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ),
790 mToggleAllday, SLOT( setEnabled ( bool ) ) ); 791 mToggleAllday, SLOT( setEnabled ( bool ) ) );
791 792
792 viewMenu->insertSeparator(); 793 viewMenu->insertSeparator();
793 icon = loadPixmap( pathString + "picker" ); 794 icon = loadPixmap( pathString + "picker" );
794 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); 795 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
795 action->addTo( viewMenu ); 796 action->addTo( viewMenu );
796 connect( action, SIGNAL( activated() ), 797 connect( action, SIGNAL( activated() ),
797 mView, SLOT( showDatePicker() ) ); 798 mView, SLOT( showDatePicker() ) );
798 action->addTo( iconToolBar ); 799 action->addTo( iconToolBar );
799 viewMenu->insertSeparator(); 800 viewMenu->insertSeparator();
800 801
801 if ( p-> mShowIconToggleFull ) 802 if ( p-> mShowIconToggleFull )
802 FSaction->addTo( iconToolBar ); 803 FSaction->addTo( iconToolBar );
803 if ( p->mShowIconNavigator ) mToggleNav ->addTo( iconToolBar ); 804 if ( p->mShowIconNavigator ) mToggleNav ->addTo( iconToolBar );
804 805
805 //******************** 806 //********************
806 if ( p->mShowIconAllday ) mToggleAllday->addTo( iconToolBar ); 807 if ( p->mShowIconAllday ) mToggleAllday->addTo( iconToolBar );
807 808
808 809
809 icon = loadPixmap( pathString + "whatsnext" ); 810 icon = loadPixmap( pathString + "whatsnext" );
810 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 ); 811 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 );
811 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 812 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
812 whatsnext_action->addTo( viewMenu ); 813 whatsnext_action->addTo( viewMenu );
813 connect( whatsnext_action, SIGNAL( activated() ), 814 connect( whatsnext_action, SIGNAL( activated() ),
814 mView->viewManager(), SLOT( showWhatsNextView() ) ); 815 mView->viewManager(), SLOT( showWhatsNextView() ) );
815 816
816 icon = loadPixmap( pathString + "xdays" ); 817 icon = loadPixmap( pathString + "xdays" );
817 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 ); 818 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 );
818 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 819 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
819 xdays_action->addTo( viewMenu ); 820 xdays_action->addTo( viewMenu );
820 connect( xdays_action, SIGNAL( activated() ), 821 connect( xdays_action, SIGNAL( activated() ),
821 mView->viewManager(), SLOT( showNextXView() ) ); 822 mView->viewManager(), SLOT( showNextXView() ) );
822 823
823 824
824 icon = loadPixmap( pathString + "journal" ); 825 icon = loadPixmap( pathString + "journal" );
825 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 826 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
826 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 827 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
827 viewjournal_action->addTo( viewMenu ); 828 viewjournal_action->addTo( viewMenu );
828 connect( viewjournal_action, SIGNAL( activated() ), 829 connect( viewjournal_action, SIGNAL( activated() ),
829 mView->viewManager(), SLOT( showJournalView() ) ); 830 mView->viewManager(), SLOT( showJournalView() ) );
830 831
831 832
832 icon = loadPixmap( pathString + "day" ); 833 icon = loadPixmap( pathString + "day" );
833 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 834 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
834 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 835 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
835 day1_action->addTo( viewMenu ); 836 day1_action->addTo( viewMenu );
836 // action->addTo( toolBar ); 837 // action->addTo( toolBar );
837 connect( day1_action, SIGNAL( activated() ), 838 connect( day1_action, SIGNAL( activated() ),
838 mView->viewManager(), SLOT( showDayView() ) ); 839 mView->viewManager(), SLOT( showDayView() ) );
839 840
840 icon = loadPixmap( pathString + "workweek" ); 841 icon = loadPixmap( pathString + "workweek" );
841 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 842 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
842 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 843 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
843 day5_action->addTo( viewMenu ); 844 day5_action->addTo( viewMenu );
844 connect( day5_action, SIGNAL( activated() ), 845 connect( day5_action, SIGNAL( activated() ),
845 mView->viewManager(), SLOT( showWorkWeekView() ) ); 846 mView->viewManager(), SLOT( showWorkWeekView() ) );
846 847
847 icon = loadPixmap( pathString + "week" ); 848 icon = loadPixmap( pathString + "week" );
848 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 849 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
849 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 850 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
850 day7_action->addTo( viewMenu ); 851 day7_action->addTo( viewMenu );
851 connect( day7_action, SIGNAL( activated() ), 852 connect( day7_action, SIGNAL( activated() ),
852 mView->viewManager(), SLOT( showWeekView() ) ); 853 mView->viewManager(), SLOT( showWeekView() ) );
853 854
854 icon = loadPixmap( pathString + "workweek2" ); 855 icon = loadPixmap( pathString + "workweek2" );
855 configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 ); 856 configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 );
856 QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this ); 857 QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this );
857 day6_action->addTo( viewMenu ); 858 day6_action->addTo( viewMenu );
858 connect( day6_action, SIGNAL( activated() ), 859 connect( day6_action, SIGNAL( activated() ),
859 mView->viewManager(), SLOT( showMonthViewWeek() ) ); 860 mView->viewManager(), SLOT( showMonthViewWeek() ) );
860 861
861 icon = loadPixmap( pathString + "month" ); 862 icon = loadPixmap( pathString + "month" );
862 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 863 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
863 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 864 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
864 month_action->addTo( viewMenu ); 865 month_action->addTo( viewMenu );
865 connect( month_action, SIGNAL( activated() ), 866 connect( month_action, SIGNAL( activated() ),
866 mView->viewManager(), SLOT( showMonthView() ) ); 867 mView->viewManager(), SLOT( showMonthView() ) );
867 868
868 icon = loadPixmap( pathString + "list" ); 869 icon = loadPixmap( pathString + "list" );
869 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 870 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
870 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 871 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
871 showlist_action->addTo( viewMenu ); 872 showlist_action->addTo( viewMenu );
872 connect( showlist_action, SIGNAL( activated() ), 873 connect( showlist_action, SIGNAL( activated() ),
873 mView->viewManager(), SLOT( showListView() ) ); 874 mView->viewManager(), SLOT( showListView() ) );
874 875
875 icon = loadPixmap( pathString + "todo" ); 876 icon = loadPixmap( pathString + "todo" );
876 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 877 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
877 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 878 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
878 todoview_action->addTo( viewMenu ); 879 todoview_action->addTo( viewMenu );
879 connect( todoview_action, SIGNAL( activated() ), 880 connect( todoview_action, SIGNAL( activated() ),
880 mView->viewManager(), SLOT( showTodoView() ) ); 881 mView->viewManager(), SLOT( showTodoView() ) );
881 882
882 883
883 884
884#if 0 885#if 0
885 action = new QAction( "view_timespan", "Time Span", 0, this ); 886 action = new QAction( "view_timespan", "Time Span", 0, this );
886 action->addTo( viewMenu ); 887 action->addTo( viewMenu );
887 connect( action, SIGNAL( activated() ), 888 connect( action, SIGNAL( activated() ),
888 mView->viewManager(), SLOT( showTimeSpanView() ) ); 889 mView->viewManager(), SLOT( showTimeSpanView() ) );
889#endif 890#endif
890 891
891 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 892 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
892 this ); 893 this );
893 mNewSubTodoAction->addTo( actionMenu ); 894 mNewSubTodoAction->addTo( actionMenu );
894 connect( mNewSubTodoAction, SIGNAL( activated() ), 895 connect( mNewSubTodoAction, SIGNAL( activated() ),
895 mView, SLOT( newSubTodo() ) ); 896 mView, SLOT( newSubTodo() ) );
896 897
897 actionMenu->insertSeparator(); 898 actionMenu->insertSeparator();
898 899
899 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); 900 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this );
900 mShowAction->addTo( actionMenu ); 901 mShowAction->addTo( actionMenu );
901 connect( mShowAction, SIGNAL( activated() ), 902 connect( mShowAction, SIGNAL( activated() ),
902 mView, SLOT( showIncidence() ) ); 903 mView, SLOT( showIncidence() ) );
903 904
904 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 905 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
905 mEditAction->addTo( actionMenu ); 906 mEditAction->addTo( actionMenu );
906 connect( mEditAction, SIGNAL( activated() ), 907 connect( mEditAction, SIGNAL( activated() ),
907 mView, SLOT( editIncidence() ) ); 908 mView, SLOT( editIncidence() ) );
908 909
909 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 910 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
910 mDeleteAction->addTo( actionMenu ); 911 mDeleteAction->addTo( actionMenu );
911 connect( mDeleteAction, SIGNAL( activated() ), 912 connect( mDeleteAction, SIGNAL( activated() ),
912 mView, SLOT( deleteIncidence() ) ); 913 mView, SLOT( deleteIncidence() ) );
913 914
914 915
915 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); 916 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this );
916 mCloneAction->addTo( actionMenu ); 917 mCloneAction->addTo( actionMenu );
917 connect( mCloneAction, SIGNAL( activated() ), 918 connect( mCloneAction, SIGNAL( activated() ),
918 mView, SLOT( cloneIncidence() ) ); 919 mView, SLOT( cloneIncidence() ) );
919 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); 920 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this );
920 mMoveAction->addTo( actionMenu ); 921 mMoveAction->addTo( actionMenu );
921 connect( mMoveAction, SIGNAL( activated() ), 922 connect( mMoveAction, SIGNAL( activated() ),
922 mView, SLOT( moveIncidence() ) ); 923 mView, SLOT( moveIncidence() ) );
923 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); 924 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this );
924 mBeamAction->addTo( actionMenu ); 925 mBeamAction->addTo( actionMenu );
925 connect( mBeamAction, SIGNAL( activated() ), 926 connect( mBeamAction, SIGNAL( activated() ),
926 mView, SLOT( beamIncidence() ) ); 927 mView, SLOT( beamIncidence() ) );
927 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); 928 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this );
928 mCancelAction->addTo( actionMenu ); 929 mCancelAction->addTo( actionMenu );
929 connect( mCancelAction, SIGNAL( activated() ), 930 connect( mCancelAction, SIGNAL( activated() ),
930 mView, SLOT( toggleCancelIncidence() ) ); 931 mView, SLOT( toggleCancelIncidence() ) );
931 932
932 actionMenu->insertSeparator(); 933 actionMenu->insertSeparator();
933 934
934 action = new QAction( "purge_completed", i18n("Purge Completed"), 0, 935 action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
935 this ); 936 this );
936 action->addTo( actionMenu ); 937 action->addTo( actionMenu );
937 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 938 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
938 939
939 icon = loadPixmap( pathString + "search" ); 940 icon = loadPixmap( pathString + "search" );
940 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 941 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
941 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 5); 942 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 5);
942 search_action->addTo( actionMenu ); 943 search_action->addTo( actionMenu );
943 connect( search_action, SIGNAL( activated() ), 944 connect( search_action, SIGNAL( activated() ),
944 mView->dialogManager(), SLOT( showSearchDialog() ) ); 945 mView->dialogManager(), SLOT( showSearchDialog() ) );
945 946
946 947
947 948
948 if ( KOPrefs::instance()->mShowFullMenu ) { 949 if ( KOPrefs::instance()->mShowFullMenu ) {
949 actionMenu->insertSeparator(); 950 actionMenu->insertSeparator();
950 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 951 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
951 952
952 } 953 }
953 // actionMenu->insertSeparator(); 954 // actionMenu->insertSeparator();
954 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 955 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
955 this ); 956 this );
956 action->addTo( importMenu_X ); 957 action->addTo( importMenu_X );
957 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 958 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
958 action = new QAction( "import_quick", i18n("Import last file"), 0, 959 action = new QAction( "import_quick", i18n("Import last file"), 0,
959 this ); 960 this );
960 action->addTo( importMenu_X ); 961 action->addTo( importMenu_X );
961 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 962 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
962 importMenu_X->insertSeparator(); 963 importMenu_X->insertSeparator();
963 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 964 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
964 this ); 965 this );
965 action->addTo( importMenu_X ); 966 action->addTo( importMenu_X );
966 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 967 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
967 //#ifndef DESKTOP_VERSION 968 //#ifndef DESKTOP_VERSION
968 importMenu_X->insertSeparator(); 969 importMenu_X->insertSeparator();
969 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 970 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
970 this ); 971 this );
971 action->addTo( importMenu_X ); 972 action->addTo( importMenu_X );
972 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 973 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
973 //#else 974 //#else
974#ifdef _OL_IMPORT_ 975#ifdef _OL_IMPORT_
975 importMenu_X->insertSeparator(); 976 importMenu_X->insertSeparator();
976 action = new QAction( "import_ol", i18n("Import from OL"), 0, 977 action = new QAction( "import_ol", i18n("Import from OL"), 0,
977 this ); 978 this );
978 action->addTo( importMenu_X ); 979 action->addTo( importMenu_X );
979 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 980 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
980#endif 981#endif
981 //#endif 982 //#endif
982 983
983 //importMenu->insertSeparator(); 984 //importMenu->insertSeparator();
984 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 985 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
985 this ); 986 this );
986 action->addTo( importMenu ); 987 action->addTo( importMenu );
987 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 988 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
988 989
989 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 990 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
990 this ); 991 this );
991 action->addTo( importMenu ); 992 action->addTo( importMenu );
992 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 993 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
993 importMenu->insertSeparator(); 994 importMenu->insertSeparator();
994 importMenu->insertItem( i18n("Import"), importMenu_X ); 995 importMenu->insertItem( i18n("Import"), importMenu_X );
995 //importMenu->insertSeparator(); 996 //importMenu->insertSeparator();
996 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 997 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
997 this ); 998 this );
998 action->addTo( exportMenu_X ); 999 action->addTo( exportMenu_X );
999 connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 1000 connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
1000 1001
1001 1002
1002 //LR 1003 //LR
1003 QPopupMenu *ex2phone = new QPopupMenu( this ); 1004 QPopupMenu *ex2phone = new QPopupMenu( this );
1004 ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 1005 ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1005 ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 1006 ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1006 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); 1007 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) );
1007 exportMenu_X->insertItem( i18n("Export to phone"), ex2phone ); 1008 exportMenu_X->insertItem( i18n("Export to phone"), ex2phone );
1008 1009
1009 importMenu->insertItem( i18n("Export"), exportMenu_X ); 1010 importMenu->insertItem( i18n("Export"), exportMenu_X );
1010#ifndef DESKTOP_VERSION 1011#ifndef DESKTOP_VERSION
1011 //importMenu->insertSeparator(); 1012 //importMenu->insertSeparator();
1012 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, 1013 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0,
1013 this ); 1014 this );
1014 brAction->addTo( beamMenu_X ); 1015 brAction->addTo( beamMenu_X );
1015 brAction->setToggleAction (true ) ; 1016 brAction->setToggleAction (true ) ;
1016 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); 1017 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) );
1017 1018
1018 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 1019 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
1019 this ); 1020 this );
1020 action->addTo( beamMenu_X ); 1021 action->addTo( beamMenu_X );
1021 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 1022 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
1022 1023
1023 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 1024 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
1024 this ); 1025 this );
1025 action->addTo( beamMenu_X ); 1026 action->addTo( beamMenu_X );
1026 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 1027 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
1027 importMenu->insertItem( i18n("Beam"), beamMenu_X ); 1028 importMenu->insertItem( i18n("Beam"), beamMenu_X );
1028#else 1029#else
1029 //importMenu->insertSeparator(); 1030 //importMenu->insertSeparator();
1030 icon = loadPixmap( pathString + "print" ); 1031 icon = loadPixmap( pathString + "print" );
1031 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 1032 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
1032 action->addTo( beamMenu_X ); 1033 action->addTo( beamMenu_X );
1033 connect( action, SIGNAL( activated() ), 1034 connect( action, SIGNAL( activated() ),
1034 this, SLOT( printCal() ) ); 1035 this, SLOT( printCal() ) );
1035 1036
1036 icon = loadPixmap( pathString + "print" ); 1037 icon = loadPixmap( pathString + "print" );
1037 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 1038 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
1038 action->addTo( beamMenu_X ); 1039 action->addTo( beamMenu_X );
1039 connect( action, SIGNAL( activated() ), 1040 connect( action, SIGNAL( activated() ),
1040 this, SLOT( printSel() ) ); 1041 this, SLOT( printSel() ) );
1041 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this ); 1042 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this );
1042 action->addTo( beamMenu_X ); 1043 action->addTo( beamMenu_X );
1043 connect( action, SIGNAL( activated() ), 1044 connect( action, SIGNAL( activated() ),
1044 mView->viewManager(), SLOT( slotprintWNV() ) ); 1045 mView->viewManager(), SLOT( slotprintWNV() ) );
1045 1046
1046 action = new QAction( i18n("Print selected event / todo..."),icon,i18n("Print selected event / todo..."), 0, this ); 1047 action = new QAction( i18n("Print selected event / todo..."),icon,i18n("Print selected event / todo..."), 0, this );
1047 action->addTo( beamMenu_X ); 1048 action->addTo( beamMenu_X );
1048 connect( action, SIGNAL( activated() ), 1049 connect( action, SIGNAL( activated() ),
1049 mView, SLOT( slotprintSelInc() ) ); 1050 mView, SLOT( slotprintSelInc() ) );
1050 1051
1051 1052
1052 importMenu->insertItem( i18n("Print"), beamMenu_X ); 1053 importMenu->insertItem( i18n("Print"), beamMenu_X );
1053#endif 1054#endif
1054 importMenu->insertSeparator(); 1055 importMenu->insertSeparator();
1055 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 1056 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
1056 this ); 1057 this );
1057 action->addTo( importMenu ); 1058 action->addTo( importMenu );
1058 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 1059 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
1059 importMenu->insertSeparator(); 1060 importMenu->insertSeparator();
1060 action = new QAction( "beam all", i18n("Save"), 0, 1061 action = new QAction( "beam all", i18n("Save"), 0,
1061 this ); 1062 this );
1062 action->addTo( importMenu ); 1063 action->addTo( importMenu );
1063 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 1064 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
1064 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 1065 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
1065 this ); 1066 this );
1066 action->addTo( importMenu ); 1067 action->addTo( importMenu );
1067 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 1068 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
1068 1069
1069 //menuBar->insertItem( "Configure",configureMenu ); 1070 //menuBar->insertItem( "Configure",configureMenu );
1070 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 1071 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
1071 icon = loadPixmap( "korganizer/korganizer" ); 1072 icon = loadPixmap( "korganizer/korganizer" );
1072 1073
1073 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 1074 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
1074 action->addTo( helpMenu ); 1075 action->addTo( helpMenu );
1075 connect( action, SIGNAL( activated() ), 1076 connect( action, SIGNAL( activated() ),
1076 SLOT( whatsNew() ) ); 1077 SLOT( whatsNew() ) );
1077 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 1078 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
1078 action->addTo( helpMenu ); 1079 action->addTo( helpMenu );
1079 connect( action, SIGNAL( activated() ), 1080 connect( action, SIGNAL( activated() ),
1080 SLOT( features() ) ); 1081 SLOT( features() ) );
1081 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 1082 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
1082 action->addTo( helpMenu ); 1083 action->addTo( helpMenu );
1083 connect( action, SIGNAL( activated() ), 1084 connect( action, SIGNAL( activated() ),
1084 SLOT( keyBindings() ) ); 1085 SLOT( keyBindings() ) );
1085 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 1086 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
1086 action->addTo( helpMenu ); 1087 action->addTo( helpMenu );
1087 connect( action, SIGNAL( activated() ), 1088 connect( action, SIGNAL( activated() ),
1088 SLOT( synchowto() ) ); 1089 SLOT( synchowto() ) );
1089 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); 1090 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this );
1090 action->addTo( helpMenu ); 1091 action->addTo( helpMenu );
1091 connect( action, SIGNAL( activated() ), 1092 connect( action, SIGNAL( activated() ),
1092 SLOT( kdesynchowto() ) ); 1093 SLOT( kdesynchowto() ) );
1093 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); 1094 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this );
1094 action->addTo( helpMenu ); 1095 action->addTo( helpMenu );
1095 connect( action, SIGNAL( activated() ), 1096 connect( action, SIGNAL( activated() ),
1096 SLOT( multisynchowto() ) ); 1097 SLOT( multisynchowto() ) );
1097 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 1098 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
1098 action->addTo( helpMenu ); 1099 action->addTo( helpMenu );
1099 connect( action, SIGNAL( activated() ), 1100 connect( action, SIGNAL( activated() ),
1100 SLOT( aboutAutoSaving() ) ); 1101 SLOT( aboutAutoSaving() ) );
1101 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 1102 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
1102 action->addTo( helpMenu ); 1103 action->addTo( helpMenu );
1103 connect( action, SIGNAL( activated() ), 1104 connect( action, SIGNAL( activated() ),
1104 SLOT( aboutKnownBugs() ) ); 1105 SLOT( aboutKnownBugs() ) );
1105 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 1106 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
1106 action->addTo( helpMenu ); 1107 action->addTo( helpMenu );
1107 connect( action, SIGNAL( activated() ), 1108 connect( action, SIGNAL( activated() ),
1108 SLOT( usertrans() ) ); 1109 SLOT( usertrans() ) );
1109 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 1110 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
1110 action->addTo( helpMenu ); 1111 action->addTo( helpMenu );
1111 connect( action, SIGNAL( activated() ), 1112 connect( action, SIGNAL( activated() ),
1112 SLOT( faq() ) ); 1113 SLOT( faq() ) );
1113 action = new QAction( "licence", i18n("Licence..."), 0, this ); 1114 action = new QAction( "licence", i18n("Licence..."), 0, this );
1114 action->addTo( helpMenu ); 1115 action->addTo( helpMenu );
1115 connect( action, SIGNAL( activated() ), 1116 connect( action, SIGNAL( activated() ),
1116 SLOT( licence() ) ); 1117 SLOT( licence() ) );
1117 action = new QAction( "about", i18n("About..."), 0, this ); 1118 action = new QAction( "about", i18n("About..."), 0, this );
1118 action->addTo( helpMenu ); 1119 action->addTo( helpMenu );
1119 connect( action, SIGNAL( activated() ), 1120 connect( action, SIGNAL( activated() ),
1120 SLOT( about() ) ); 1121 SLOT( about() ) );
1121 //menuBar->insertSeparator(); 1122 //menuBar->insertSeparator();
1122 1123
1123 // ****************************************************** 1124 // ******************************************************
1124 // menubar icons 1125 // menubar icons
1125 1126
1126 1127
1127 1128
1128 //menuBar->insertItem( iconToolBar ); 1129 //menuBar->insertItem( iconToolBar );
1129 //xdays_action 1130 //xdays_action
1130 if (p-> mShowIconNewEvent) 1131 if (p-> mShowIconNewEvent)
1131 ne_action->addTo( iconToolBar ); 1132 ne_action->addTo( iconToolBar );
1132 if (p->mShowIconNewTodo ) 1133 if (p->mShowIconNewTodo )
1133 nt_action->addTo( iconToolBar ); 1134 nt_action->addTo( iconToolBar );
1134 if (p-> mShowIconSearch) 1135 if (p-> mShowIconSearch)
1135 search_action->addTo( iconToolBar ); 1136 search_action->addTo( iconToolBar );
1136 if (p-> mShowIconWhatsThis) 1137 if (p-> mShowIconWhatsThis)
1137 QWhatsThis::whatsThisButton ( iconToolBar ); 1138 QWhatsThis::whatsThisButton ( iconToolBar );
1138 if (p-> mShowIconNext) 1139 if (p-> mShowIconNext)
1139 whatsnext_action->addTo( viewToolBar ); 1140 whatsnext_action->addTo( viewToolBar );
1140 if (p-> mShowIconNextDays) 1141 if (p-> mShowIconNextDays)
1141 xdays_action->addTo( viewToolBar ); 1142 xdays_action->addTo( viewToolBar );
1142 if (p-> mShowIconJournal) 1143 if (p-> mShowIconJournal)
1143 viewjournal_action->addTo( viewToolBar ); 1144 viewjournal_action->addTo( viewToolBar );
1144 if (p-> mShowIconDay1) 1145 if (p-> mShowIconDay1)
1145 day1_action->addTo( viewToolBar ); 1146 day1_action->addTo( viewToolBar );
1146 if (p-> mShowIconDay5) 1147 if (p-> mShowIconDay5)
1147 day5_action->addTo( viewToolBar ); 1148 day5_action->addTo( viewToolBar );
1148 if (p-> mShowIconDay7) 1149 if (p-> mShowIconDay7)
1149 day7_action->addTo( viewToolBar ); 1150 day7_action->addTo( viewToolBar );
1150 if (p-> mShowIconDay6) 1151 if (p-> mShowIconDay6)
1151 day6_action->addTo( viewToolBar ); 1152 day6_action->addTo( viewToolBar );
1152 if (p-> mShowIconMonth) 1153 if (p-> mShowIconMonth)
1153 month_action->addTo( viewToolBar ); 1154 month_action->addTo( viewToolBar );
1154 if (p-> mShowIconList) 1155 if (p-> mShowIconList)
1155 showlist_action->addTo( viewToolBar ); 1156 showlist_action->addTo( viewToolBar );
1156 if (p-> mShowIconTodoview) 1157 if (p-> mShowIconTodoview)
1157 todoview_action->addTo( viewToolBar ); 1158 todoview_action->addTo( viewToolBar );
1158 1159
1159 icon = loadPixmap( pathString + "2leftarrowB" ); 1160 icon = loadPixmap( pathString + "2leftarrowB" );
1160 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200); 1161 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200);
1161 if (p-> mShowIconBackFast) { 1162 if (p-> mShowIconBackFast) {
1162 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 1163 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
1163 connect( action, SIGNAL( activated() ), 1164 connect( action, SIGNAL( activated() ),
1164 mView, SLOT( goPreviousMonth() ) ); 1165 mView, SLOT( goPreviousMonth() ) );
1165 action->addTo( navigatorToolBar ); 1166 action->addTo( navigatorToolBar );
1166 } 1167 }
1167 icon = loadPixmap( pathString + "1leftarrowB" ); 1168 icon = loadPixmap( pathString + "1leftarrowB" );
1168 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210); 1169 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210);
1169 if (p-> mShowIconBack) { 1170 if (p-> mShowIconBack) {
1170 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 1171 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
1171 connect( action, SIGNAL( activated() ), 1172 connect( action, SIGNAL( activated() ),
diff --git a/korganizer/searchdialog.cpp b/korganizer/searchdialog.cpp
index 341a839..db60383 100644
--- a/korganizer/searchdialog.cpp
+++ b/korganizer/searchdialog.cpp
@@ -1,417 +1,460 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 1998 Preston Brown 3 Copyright (c) 1998 Preston Brown
4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24 24
25#include <qlayout.h> 25#include <qlayout.h>
26#include <qcheckbox.h> 26#include <qcheckbox.h>
27#include <qgroupbox.h> 27#include <qgroupbox.h>
28#include <qlabel.h> 28#include <qlabel.h>
29#include <qlistview.h> 29#include <qlistview.h>
30#include <qwhatsthis.h> 30#include <qwhatsthis.h>
31#include <qlineedit.h> 31#include <qlineedit.h>
32#include <qpushbutton.h> 32#include <qpushbutton.h>
33 33
34#include <klocale.h> 34#include <klocale.h>
35#include <kmessagebox.h> 35#include <kmessagebox.h>
36 36
37#include <libkdepim/kdateedit.h> 37#include <libkdepim/kdateedit.h>
38 38
39#include "koglobals.h" 39#include "koglobals.h"
40#include "koprefs.h" 40#include "koprefs.h"
41#include "klineedit.h" 41#include "klineedit.h"
42 42
43#include "calendarview.h" 43#include "calendarview.h"
44#include "koviewmanager.h" 44#include "koviewmanager.h"
45#include "searchdialog.h" 45#include "searchdialog.h"
46 46
47SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent) 47SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent)
48 : QVBox( 0 ) 48 : QVBox( 0 )
49 49
50{ 50{
51 mCalendar = calendar; 51 mCalendar = calendar;
52 QFrame *topFrame = new QFrame( this ) ;//plainPage(); 52 QFrame *topFrame = new QFrame( this ) ;//plainPage();
53 QVBoxLayout *layout = new QVBoxLayout(topFrame,KDialog::marginHint(),KDialog::spacingHint()); 53 QVBoxLayout *layout = new QVBoxLayout(topFrame,KDialog::marginHint(),KDialog::spacingHint());
54 54
55 // Search expression 55 // Search expression
56 QHBoxLayout *subLayout = new QHBoxLayout(); 56 QHBoxLayout *subLayout = new QHBoxLayout();
57 layout->addLayout(subLayout); 57 layout->addLayout(subLayout);
58 searchLabel = new QLabel(topFrame); 58 searchLabel = new QLabel(topFrame);
59 searchLabel->setText(i18n("Search for:")); 59 searchLabel->setText(i18n("Search for:"));
60 subLayout->addWidget(searchLabel); 60 subLayout->addWidget(searchLabel);
61 61
62 searchEdit = new KLineEdit(topFrame); 62 searchEdit = new KLineEdit(topFrame);
63 subLayout->addWidget(searchEdit); 63 subLayout->addWidget(searchEdit);
64 QPushButton *OkButton = new QPushButton( i18n("&Find"), topFrame ); 64 QPushButton *OkButton = new QPushButton( i18n("&Find"), topFrame );
65 //OkButton->setDefault( true ); 65 //OkButton->setDefault( true );
66 connect(OkButton,SIGNAL(clicked()),SLOT(doSearch())); 66 connect(OkButton,SIGNAL(clicked()),SLOT(doSearch()));
67 subLayout->addWidget(OkButton); 67 subLayout->addWidget(OkButton);
68 searchEdit->setText("*"); // Find all events by default 68 searchEdit->setText("*"); // Find all events by default
69 searchEdit->setFocus(); 69 searchEdit->setFocus();
70 connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & ))); 70 connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & )));
71 connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch())); 71 connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch()));
72 // Subjects to search 72 // Subjects to search
73 // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"), 73 // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"),
74 // topFrame); 74 // topFrame);
75 75
76 QHBox *incidenceGroup = new QHBox( topFrame ); 76 QHBox *incidenceGroup = new QHBox( topFrame );
77 layout->addWidget(incidenceGroup); 77 layout->addWidget(incidenceGroup);
78 78
79 mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup); 79 mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup);
80 mSearchEvent->setChecked(true); 80 //mSearchEvent->setChecked(true);
81 mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup); 81 mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup);
82 mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup); 82 mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup);
83 83
84 QHBox *subjectGroup = new QHBox( topFrame ); 84 QHBox *subjectGroup = new QHBox( topFrame );
85 layout->addWidget(subjectGroup); 85 layout->addWidget(subjectGroup);
86 86
87 mSummaryCheck = new QCheckBox(i18n("Summary/Loc."),subjectGroup); 87 mSummaryCheck = new QCheckBox(i18n("Summary/Loc."),subjectGroup);
88 mSummaryCheck->setChecked(true); 88 mSummaryCheck->setChecked(true);
89 mDescriptionCheck = new QCheckBox(i18n("Details"),subjectGroup); 89 mDescriptionCheck = new QCheckBox(i18n("Details"),subjectGroup);
90 mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup); 90 mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup);
91 91
92 QHBox *attendeeGroup = new QHBox( topFrame ); 92 QHBox *attendeeGroup = new QHBox( topFrame );
93 layout->addWidget(attendeeGroup ); 93 layout->addWidget(attendeeGroup );
94 new QLabel( i18n("Attendee:"),attendeeGroup ); 94 new QLabel( i18n("Attendee:"),attendeeGroup );
95 mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup ); 95 mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup );
96 mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup ); 96 mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup );
97 // Date range 97 // Date range
98 // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"), 98 // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"),
99 // topFrame); 99 // topFrame);
100 // layout->addWidget(rangeGroup); 100 // layout->addWidget(rangeGroup);
101 101
102 QWidget *rangeWidget = new QWidget(topFrame); 102 QWidget *rangeWidget = new QWidget(topFrame);
103 QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,KDialog::spacingHint()); 103 QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,KDialog::spacingHint());
104 rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget)); 104 rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget));
105 mStartDate = new KDateEdit(rangeWidget); 105 mStartDate = new KDateEdit(rangeWidget);
106 rangeLayout->addWidget(mStartDate); 106 rangeLayout->addWidget(mStartDate);
107 rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget)); 107 rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget));
108 mEndDate = new KDateEdit(rangeWidget); 108 mEndDate = new KDateEdit(rangeWidget);
109 mEndDate->setDate(QDate::currentDate().addDays(365)); 109 mEndDate->setDate(QDate::currentDate().addDays(365));
110 rangeLayout->addWidget(mEndDate); 110 rangeLayout->addWidget(mEndDate);
111 QToolButton *wt = QWhatsThis::whatsThisButton ( rangeWidget ); 111 QToolButton *wt = QWhatsThis::whatsThisButton ( rangeWidget );
112 rangeLayout->addWidget( (QWidget*)wt ); 112 rangeLayout->addWidget( (QWidget*)wt );
113 layout->addWidget(rangeWidget); 113 layout->addWidget(rangeWidget);
114 // Results list view 114 // Results list view
115 listView = new KOListView(mCalendar,topFrame); 115 listView = new KOListView(mCalendar,topFrame);
116 layout->addWidget(listView); 116 layout->addWidget(listView);
117 117
118 listView->readSettings(KOGlobals::config(),"SearchListView Layout"); 118 listView->readSettings(KOGlobals::config(),"SearchListView Layout");
119 connect(searchEdit,SIGNAL(scrollDOWN()),SLOT(setFocusToList())); 119 connect(searchEdit,SIGNAL(scrollDOWN()),SLOT(setFocusToList()));
120 120
121 setCaption( i18n("KO/Pi Find: ")); 121 setCaption( i18n("KO/Pi Find: "));
122#ifdef DESKTOP_VERSION 122#ifdef DESKTOP_VERSION
123 OkButton = new QPushButton( i18n("Close"), this ); 123 OkButton = new QPushButton( i18n("Close"), this );
124 connect(OkButton,SIGNAL(clicked()),SLOT(hide())); 124 connect(OkButton,SIGNAL(clicked()),SLOT(hide()));
125#endif 125#endif
126} 126}
127 127
128SearchDialog::~SearchDialog() 128SearchDialog::~SearchDialog()
129{ 129{
130 130
131} 131}
132void SearchDialog::raiseAndSelect()
133{
134
135 static int currentState = 0;
136
137 if ( !mSearchJournal->isChecked() && !mSearchTodo->isChecked() && !mSearchEvent->isChecked() )
138 currentState = 0;
139 int newState = 0;
140 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) {
141 newState = VIEW_J_VIEW;
142 }
143 else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) {
144 newState = VIEW_T_VIEW;
145 }
146 else {
147 newState = VIEW_A_VIEW;
148 }
149 if ( newState != currentState ) {
150 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) {
151 if ( ! mSearchJournal->isChecked() ) {
152 mSearchJournal->setChecked( true );
153 mSearchTodo->setChecked( false );
154 mSearchEvent->setChecked( false );
155 }
156 }
157 else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) {
158 if ( ! mSearchTodo->isChecked() ) {
159 mSearchTodo->setChecked( true );
160 mSearchJournal->setChecked( false );
161 mSearchEvent->setChecked( false );
162 }
163 }
164 else {
165 if ( ! mSearchEvent->isChecked() ) {
166 mSearchEvent->setChecked( true );
167 mSearchJournal->setChecked( false );
168 mSearchTodo->setChecked( false );
169 }
170 }
171 }
172 currentState = newState;
173 raise();
174}
132void SearchDialog::setFocusToList() 175void SearchDialog::setFocusToList()
133{ 176{
134 listView->resetFocus(); 177 listView->resetFocus();
135} 178}
136void SearchDialog::accept() 179void SearchDialog::accept()
137{ 180{
138 doSearch(); 181 doSearch();
139} 182}
140void SearchDialog::updateList() 183void SearchDialog::updateList()
141{ 184{
142 //listView->updateList(); 185 //listView->updateList();
143 if ( isVisible() ) { 186 if ( isVisible() ) {
144 updateView(); 187 updateView();
145 //qDebug("SearchDialog::updated "); 188 //qDebug("SearchDialog::updated ");
146 } 189 }
147 else { 190 else {
148 listView->clear(); 191 listView->clear();
149 //qDebug("SearchDialog::cleared "); 192 //qDebug("SearchDialog::cleared ");
150 193
151 } 194 }
152} 195}
153void SearchDialog::searchTextChanged( const QString &_text ) 196void SearchDialog::searchTextChanged( const QString &_text )
154{ 197{
155#if 0 198#if 0
156 enableButton( KDialogBase::User1, !_text.isEmpty() ); 199 enableButton( KDialogBase::User1, !_text.isEmpty() );
157#endif 200#endif
158} 201}
159 202
160void SearchDialog::doSearch() 203void SearchDialog::doSearch()
161{ 204{
162 QRegExp re; 205 QRegExp re;
163 206
164 re.setWildcard(true); // most people understand these better. 207 re.setWildcard(true); // most people understand these better.
165 re.setCaseSensitive(false); 208 re.setCaseSensitive(false);
166 re.setPattern(searchEdit->text()); 209 re.setPattern(searchEdit->text());
167 if (!mSearchEvent->isChecked() && !mSearchTodo->isChecked() && !mSearchJournal->isChecked() ) { 210 if (!mSearchEvent->isChecked() && !mSearchTodo->isChecked() && !mSearchJournal->isChecked() ) {
168 KMessageBox::sorry(this, 211 KMessageBox::sorry(this,
169 i18n("Please select at least one\nof the types to search for:\n\nEvents\nTodos\nJournals")); 212 i18n("Please select at least one\nof the types to search for:\n\nEvents\nTodos\nJournals"));
170 return; 213 return;
171 } 214 }
172 if (!re.isValid() ) { 215 if (!re.isValid() ) {
173 KMessageBox::sorry(this, 216 KMessageBox::sorry(this,
174 i18n("Invalid search expression,\ncannot perform " 217 i18n("Invalid search expression,\ncannot perform "
175 "the search.\nPlease enter a search expression\n" 218 "the search.\nPlease enter a search expression\n"
176 "using the wildcard characters\n '*' and '?'" 219 "using the wildcard characters\n '*' and '?'"
177 "where needed.")); 220 "where needed."));
178 return; 221 return;
179 } 222 }
180 223
181 search(re); 224 search(re);
182 225
183 listView->setStartDate( mStartDate->date() ); 226 listView->setStartDate( mStartDate->date() );
184 listView->showEvents(mMatchedEvents); 227 listView->showEvents(mMatchedEvents);
185 listView->addTodos(mMatchedTodos); 228 listView->addTodos(mMatchedTodos);
186 listView->addJournals(mMatchedJournals); 229 listView->addJournals(mMatchedJournals);
187 230
188 if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) { 231 if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) {
189 setCaption(i18n("No items found. Use '*' and '?' where needed.")); 232 setCaption(i18n("No items found. Use '*' and '?' where needed."));
190 } else { 233 } else {
191 QString mess; 234 QString mess;
192 mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() ); 235 mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() );
193 setCaption( i18n("KO/Pi Find: ") + mess); 236 setCaption( i18n("KO/Pi Find: ") + mess);
194 237
195 } 238 }
196 searchEdit->setFocus(); 239 searchEdit->setFocus();
197} 240}
198void SearchDialog::updateConfig() 241void SearchDialog::updateConfig()
199{ 242{
200 listView->updateConfig(); 243 listView->updateConfig();
201} 244}
202void SearchDialog::updateView() 245void SearchDialog::updateView()
203{ 246{
204 247 //qDebug("SearchDialog::updateView() %d ", isVisible());
205 QRegExp re; 248 QRegExp re;
206 re.setWildcard(true); // most people understand these better. 249 re.setWildcard(true); // most people understand these better.
207 re.setCaseSensitive(false); 250 re.setCaseSensitive(false);
208 re.setPattern(searchEdit->text()); 251 re.setPattern(searchEdit->text());
209 if (re.isValid()) { 252 if (re.isValid()) {
210 search(re); 253 search(re);
211 } else { 254 } else {
212 mMatchedEvents.clear(); 255 mMatchedEvents.clear();
213 mMatchedTodos.clear(); 256 mMatchedTodos.clear();
214 mMatchedJournals.clear(); 257 mMatchedJournals.clear();
215 } 258 }
216 listView->setStartDate( mStartDate->date() ); 259 listView->setStartDate( mStartDate->date() );
217 listView->showEvents(mMatchedEvents); 260 listView->showEvents(mMatchedEvents);
218 listView->addTodos(mMatchedTodos); 261 listView->addTodos(mMatchedTodos);
219 listView->addJournals(mMatchedJournals); 262 listView->addJournals(mMatchedJournals);
220} 263}
221 264
222void SearchDialog::search(const QRegExp &re) 265void SearchDialog::search(const QRegExp &re)
223{ 266{
224 QPtrList<Event> events = mCalendar->events( mStartDate->date(), 267 QPtrList<Event> events = mCalendar->events( mStartDate->date(),
225 mEndDate->date(), 268 mEndDate->date(),
226 false /*mInclusiveCheck->isChecked()*/ ); 269 false /*mInclusiveCheck->isChecked()*/ );
227 270
228 mMatchedEvents.clear(); 271 mMatchedEvents.clear();
229 if ( mSearchEvent->isChecked() ) { 272 if ( mSearchEvent->isChecked() ) {
230 Event *ev; 273 Event *ev;
231 for(ev=events.first();ev;ev=events.next()) { 274 for(ev=events.first();ev;ev=events.next()) {
232 if (mSummaryCheck->isChecked()) { 275 if (mSummaryCheck->isChecked()) {
233#if QT_VERSION >= 0x030000 276#if QT_VERSION >= 0x030000
234 if (re.search(ev->summary()) != -1) 277 if (re.search(ev->summary()) != -1)
235#else 278#else
236 if (re.match(ev->summary()) != -1) 279 if (re.match(ev->summary()) != -1)
237#endif 280#endif
238 { 281 {
239 mMatchedEvents.append(ev); 282 mMatchedEvents.append(ev);
240 continue; 283 continue;
241 } 284 }
242#if QT_VERSION >= 0x030000 285#if QT_VERSION >= 0x030000
243 if (re.search(ev->location()) != -1) 286 if (re.search(ev->location()) != -1)
244#else 287#else
245 if (re.match(ev->location()) != -1) 288 if (re.match(ev->location()) != -1)
246#endif 289#endif
247 { 290 {
248 mMatchedEvents.append(ev); 291 mMatchedEvents.append(ev);
249 continue; 292 continue;
250 } 293 }
251 } 294 }
252 if (mDescriptionCheck->isChecked()) { 295 if (mDescriptionCheck->isChecked()) {
253#if QT_VERSION >= 0x030000 296#if QT_VERSION >= 0x030000
254 if (re.search(ev->description()) != -1) 297 if (re.search(ev->description()) != -1)
255#else 298#else
256 if (re.match(ev->description()) != -1) 299 if (re.match(ev->description()) != -1)
257#endif 300#endif
258 { 301 {
259 mMatchedEvents.append(ev); 302 mMatchedEvents.append(ev);
260 continue; 303 continue;
261 } 304 }
262 } 305 }
263 if (mCategoryCheck->isChecked()) { 306 if (mCategoryCheck->isChecked()) {
264#if QT_VERSION >= 0x030000 307#if QT_VERSION >= 0x030000
265 if (re.search(ev->categoriesStr()) != -1) 308 if (re.search(ev->categoriesStr()) != -1)
266#else 309#else
267 if (re.match(ev->categoriesStr()) != -1) 310 if (re.match(ev->categoriesStr()) != -1)
268#endif 311#endif
269 { 312 {
270 mMatchedEvents.append(ev); 313 mMatchedEvents.append(ev);
271 continue; 314 continue;
272 } 315 }
273 } 316 }
274 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { 317 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) {
275 QPtrList<Attendee> tmpAList = ev->attendees(); 318 QPtrList<Attendee> tmpAList = ev->attendees();
276 Attendee *a; 319 Attendee *a;
277 for (a = tmpAList.first(); a; a = tmpAList.next()) { 320 for (a = tmpAList.first(); a; a = tmpAList.next()) {
278 if (mSearchAName->isChecked()) { 321 if (mSearchAName->isChecked()) {
279#if QT_VERSION >= 0x030000 322#if QT_VERSION >= 0x030000
280 if (re.search(a->name()) != -1) 323 if (re.search(a->name()) != -1)
281#else 324#else
282 if (re.match(a->name()) != -1) 325 if (re.match(a->name()) != -1)
283#endif 326#endif
284 { 327 {
285 mMatchedEvents.append(ev); 328 mMatchedEvents.append(ev);
286 break; 329 break;
287 } 330 }
288 } 331 }
289 if (mSearchAEmail->isChecked()) { 332 if (mSearchAEmail->isChecked()) {
290#if QT_VERSION >= 0x030000 333#if QT_VERSION >= 0x030000
291 if (re.search(a->email()) != -1) 334 if (re.search(a->email()) != -1)
292#else 335#else
293 if (re.match(a->email()) != -1) 336 if (re.match(a->email()) != -1)
294#endif 337#endif
295 { 338 {
296 mMatchedEvents.append(ev); 339 mMatchedEvents.append(ev);
297 break; 340 break;
298 } 341 }
299 } 342 }
300 } 343 }
301 } 344 }
302 } 345 }
303 } 346 }
304 QPtrList<Todo> todos = mCalendar->todos( ); 347 QPtrList<Todo> todos = mCalendar->todos( );
305 mMatchedTodos.clear(); 348 mMatchedTodos.clear();
306 if ( mSearchTodo->isChecked() ) { 349 if ( mSearchTodo->isChecked() ) {
307 Todo *tod; 350 Todo *tod;
308 for(tod=todos.first();tod;tod=todos.next()) { 351 for(tod=todos.first();tod;tod=todos.next()) {
309 if (mSummaryCheck->isChecked()) { 352 if (mSummaryCheck->isChecked()) {
310#if QT_VERSION >= 0x030000 353#if QT_VERSION >= 0x030000
311 if (re.search(tod->summary()) != -1) 354 if (re.search(tod->summary()) != -1)
312#else 355#else
313 if (re.match(tod->summary()) != -1) 356 if (re.match(tod->summary()) != -1)
314#endif 357#endif
315 { 358 {
316 mMatchedTodos.append(tod); 359 mMatchedTodos.append(tod);
317 continue; 360 continue;
318 } 361 }
319 } 362 }
320 if (mDescriptionCheck->isChecked()) { 363 if (mDescriptionCheck->isChecked()) {
321#if QT_VERSION >= 0x030000 364#if QT_VERSION >= 0x030000
322 if (re.search(tod->description()) != -1) 365 if (re.search(tod->description()) != -1)
323#else 366#else
324 if (re.match(tod->description()) != -1) 367 if (re.match(tod->description()) != -1)
325#endif 368#endif
326 { 369 {
327 mMatchedTodos.append(tod); 370 mMatchedTodos.append(tod);
328 continue; 371 continue;
329 } 372 }
330 } 373 }
331 if (mCategoryCheck->isChecked()) { 374 if (mCategoryCheck->isChecked()) {
332#if QT_VERSION >= 0x030000 375#if QT_VERSION >= 0x030000
333 if (re.search(tod->categoriesStr()) != -1) 376 if (re.search(tod->categoriesStr()) != -1)
334#else 377#else
335 if (re.match(tod->categoriesStr()) != -1) 378 if (re.match(tod->categoriesStr()) != -1)
336#endif 379#endif
337 { 380 {
338 mMatchedTodos.append(tod); 381 mMatchedTodos.append(tod);
339 continue; 382 continue;
340 } 383 }
341 } 384 }
342 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { 385 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) {
343 QPtrList<Attendee> tmpAList = tod->attendees(); 386 QPtrList<Attendee> tmpAList = tod->attendees();
344 Attendee *a; 387 Attendee *a;
345 for (a = tmpAList.first(); a; a = tmpAList.next()) { 388 for (a = tmpAList.first(); a; a = tmpAList.next()) {
346 if (mSearchAName->isChecked()) { 389 if (mSearchAName->isChecked()) {
347#if QT_VERSION >= 0x030000 390#if QT_VERSION >= 0x030000
348 if (re.search(a->name()) != -1) 391 if (re.search(a->name()) != -1)
349#else 392#else
350 if (re.match(a->name()) != -1) 393 if (re.match(a->name()) != -1)
351#endif 394#endif
352 { 395 {
353 mMatchedTodos.append(tod); 396 mMatchedTodos.append(tod);
354 break; 397 break;
355 } 398 }
356 } 399 }
357 if (mSearchAEmail->isChecked()) { 400 if (mSearchAEmail->isChecked()) {
358#if QT_VERSION >= 0x030000 401#if QT_VERSION >= 0x030000
359 if (re.search(a->email()) != -1) 402 if (re.search(a->email()) != -1)
360#else 403#else
361 if (re.match(a->email()) != -1) 404 if (re.match(a->email()) != -1)
362#endif 405#endif
363 { 406 {
364 mMatchedTodos.append(tod); 407 mMatchedTodos.append(tod);
365 break; 408 break;
366 } 409 }
367 } 410 }
368 } 411 }
369 } 412 }
370 } 413 }
371 } 414 }
372 mMatchedJournals.clear(); 415 mMatchedJournals.clear();
373 if (mSearchJournal->isChecked() ) { 416 if (mSearchJournal->isChecked() ) {
374 QPtrList<Journal> journals = mCalendar->journals( ); 417 QPtrList<Journal> journals = mCalendar->journals( );
375 Journal* journ; 418 Journal* journ;
376 419
377 for(journ=journals.first();journ;journ=journals.next()) { 420 for(journ=journals.first();journ;journ=journals.next()) {
378 if ( journ->dtStart().date() <= mEndDate->date() 421 if ( journ->dtStart().date() <= mEndDate->date()
379 &&journ->dtStart().date() >= mStartDate->date()) { 422 &&journ->dtStart().date() >= mStartDate->date()) {
380#if QT_VERSION >= 0x030000 423#if QT_VERSION >= 0x030000
381 if (re.search(journ->description()) != -1) 424 if (re.search(journ->description()) != -1)
382#else 425#else
383 if (re.match(journ->description()) != -1) 426 if (re.match(journ->description()) != -1)
384#endif 427#endif
385 { 428 {
386 mMatchedJournals.append(journ); 429 mMatchedJournals.append(journ);
387 continue; 430 continue;
388 } 431 }
389 } 432 }
390 } 433 }
391 } 434 }
392 435
393} 436}
394 437
395void SearchDialog::keyPressEvent ( QKeyEvent *e) 438void SearchDialog::keyPressEvent ( QKeyEvent *e)
396{ 439{
397 switch ( e->key() ) { 440 switch ( e->key() ) {
398 case Qt::Key_Escape: 441 case Qt::Key_Escape:
399 hide(); 442 hide();
400 break; 443 break;
401 case Qt::Key_F: 444 case Qt::Key_F:
402 if ( e->state() == Qt::ControlButton ) { 445 if ( e->state() == Qt::ControlButton ) {
403 qDebug("full "); 446 qDebug("full ");
404 447
405 } 448 }
406 break; 449 break;
407 case Qt::Key_Return: 450 case Qt::Key_Return:
408 case Qt::Key_Enter: 451 case Qt::Key_Enter:
409 doSearch(); 452 doSearch();
410 break; 453 break;
411 454
412 default: 455 default:
413 e->ignore(); 456 e->ignore();
414 } 457 }
415} 458}
416 459
417//mMatchedJournals; 460//mMatchedJournals;
diff --git a/korganizer/searchdialog.h b/korganizer/searchdialog.h
index b730ed5..4559d20 100644
--- a/korganizer/searchdialog.h
+++ b/korganizer/searchdialog.h
@@ -1,94 +1,95 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 1998 Preston Brown 3 Copyright (c) 1998 Preston Brown
4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24#ifndef SEARCHDIALOG_H 24#ifndef SEARCHDIALOG_H
25#define SEARCHDIALOG_H 25#define SEARCHDIALOG_H
26 26
27#include <qregexp.h> 27#include <qregexp.h>
28 28
29#include <kdialogbase.h> 29#include <kdialogbase.h>
30#include <qvbox.h> 30#include <qvbox.h>
31 31
32#include <libkcal/calendar.h> 32#include <libkcal/calendar.h>
33 33
34#include "kolistview.h" 34#include "kolistview.h"
35 35
36class KDateEdit; 36class KDateEdit;
37class QCheckBox; 37class QCheckBox;
38class QLineEdit; 38class QLineEdit;
39class KLineEdit; 39class KLineEdit;
40class QLabel; 40class QLabel;
41class CalendarView; 41class CalendarView;
42 42
43using namespace KCal; 43using namespace KCal;
44class SearchDialog : public QVBox 44class SearchDialog : public QVBox
45{ 45{
46 Q_OBJECT 46 Q_OBJECT
47 public: 47 public:
48 SearchDialog(Calendar *calendar,CalendarView *parent=0); 48 SearchDialog(Calendar *calendar,CalendarView *parent=0);
49 virtual ~SearchDialog(); 49 virtual ~SearchDialog();
50 KOListView *listview(){ return listView;} 50 KOListView *listview(){ return listView;}
51 void updateView(); 51 void updateView();
52 void raiseAndSelect();
52 53
53 public slots: 54 public slots:
54 void changeEventDisplay(Event *, int) { updateView(); } 55 void changeEventDisplay(Event *, int) { updateView(); }
55 void updateConfig(); 56 void updateConfig();
56 void updateList(); 57 void updateList();
57 protected slots: 58 protected slots:
58 void setFocusToList(); 59 void setFocusToList();
59 void accept(); 60 void accept();
60 void doSearch(); 61 void doSearch();
61 void searchTextChanged( const QString &_text ); 62 void searchTextChanged( const QString &_text );
62 63
63 signals: 64 signals:
64 void showEventSignal(Event *); 65 void showEventSignal(Event *);
65 void editEventSignal(Event *); 66 void editEventSignal(Event *);
66 void deleteEventSignal(Event *); 67 void deleteEventSignal(Event *);
67 68
68 private: 69 private:
69 void search(const QRegExp &); 70 void search(const QRegExp &);
70 71
71 Calendar *mCalendar; 72 Calendar *mCalendar;
72 73
73 QPtrList<Event> mMatchedEvents; 74 QPtrList<Event> mMatchedEvents;
74 QPtrList<Todo> mMatchedTodos; 75 QPtrList<Todo> mMatchedTodos;
75 QPtrList<Journal> mMatchedJournals; 76 QPtrList<Journal> mMatchedJournals;
76 77
77 QLabel *searchLabel; 78 QLabel *searchLabel;
78 KLineEdit *searchEdit; 79 KLineEdit *searchEdit;
79 KOListView *listView; 80 KOListView *listView;
80 81
81 KDateEdit *mStartDate; 82 KDateEdit *mStartDate;
82 KDateEdit *mEndDate; 83 KDateEdit *mEndDate;
83 QCheckBox *mSummaryCheck; 84 QCheckBox *mSummaryCheck;
84 QCheckBox *mDescriptionCheck; 85 QCheckBox *mDescriptionCheck;
85 QCheckBox *mCategoryCheck; 86 QCheckBox *mCategoryCheck;
86 QCheckBox *mSearchEvent; 87 QCheckBox *mSearchEvent;
87 QCheckBox *mSearchTodo; 88 QCheckBox *mSearchTodo;
88 QCheckBox *mSearchJournal; 89 QCheckBox *mSearchJournal;
89 QCheckBox *mSearchAName; 90 QCheckBox *mSearchAName;
90 QCheckBox *mSearchAEmail; 91 QCheckBox *mSearchAEmail;
91 void keyPressEvent ( QKeyEvent *e) ; 92 void keyPressEvent ( QKeyEvent *e) ;
92}; 93};
93 94
94#endif 95#endif
diff --git a/microkde/KDGanttMinimizeSplitter.cpp b/microkde/KDGanttMinimizeSplitter.cpp
index c60b566..029f14b 100644
--- a/microkde/KDGanttMinimizeSplitter.cpp
+++ b/microkde/KDGanttMinimizeSplitter.cpp
@@ -1,1509 +1,1514 @@
1/* -*- Mode: C++ -*- 1/* -*- Mode: C++ -*-
2 $Id$ 2 $Id$
3*/ 3*/
4 4
5/**************************************************************************** 5/****************************************************************************
6 ** Copyright (C) 2002-2004 Klarälvdalens Datakonsult AB. All rights reserved. 6 ** Copyright (C) 2002-2004 Klarälvdalens Datakonsult AB. All rights reserved.
7 ** 7 **
8 ** This file is part of the KDGantt library. 8 ** This file is part of the KDGantt library.
9 ** 9 **
10 ** This file may be distributed and/or modified under the terms of the 10 ** This file may be distributed and/or modified under the terms of the
11 ** GNU General Public License version 2 as published by the Free Software 11 ** GNU General Public License version 2 as published by the Free Software
12 ** Foundation and appearing in the file LICENSE.GPL included in the 12 ** Foundation and appearing in the file LICENSE.GPL included in the
13 ** packaging of this file. 13 ** packaging of this file.
14 ** 14 **
15 ** Licensees holding valid commercial KDGantt licenses may use this file in 15 ** Licensees holding valid commercial KDGantt licenses may use this file in
16 ** accordance with the KDGantt Commercial License Agreement provided with 16 ** accordance with the KDGantt Commercial License Agreement provided with
17 ** the Software. 17 ** the Software.
18 ** 18 **
19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 ** 21 **
22 ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for 22 ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for
23 ** information about KDGantt Commercial License Agreements. 23 ** information about KDGantt Commercial License Agreements.
24 ** 24 **
25 ** Contact info@klaralvdalens-datakonsult.se if any conditions of this 25 ** Contact info@klaralvdalens-datakonsult.se if any conditions of this
26 ** licensing are not clear to you. 26 ** licensing are not clear to you.
27 ** 27 **
28 ** As a special exception, permission is given to link this program 28 ** As a special exception, permission is given to link this program
29 ** with any edition of Qt, and distribute the resulting executable, 29 ** with any edition of Qt, and distribute the resulting executable,
30 ** without including the source code for Qt in the source distribution. 30 ** without including the source code for Qt in the source distribution.
31 ** 31 **
32 **********************************************************************/ 32 **********************************************************************/
33 33
34#include "KDGanttMinimizeSplitter.h" 34#include "KDGanttMinimizeSplitter.h"
35#ifndef QT_NO_SPLITTER___ 35#ifndef QT_NO_SPLITTER___
36 36
37#include "qpainter.h" 37#include "qpainter.h"
38#include "qdrawutil.h" 38#include "qdrawutil.h"
39#include "qbitmap.h" 39#include "qbitmap.h"
40#if QT_VERSION >= 0x030000 40#if QT_VERSION >= 0x030000
41#include "qptrlist.h" 41#include "qptrlist.h"
42#include "qmemarray.h" 42#include "qmemarray.h"
43#else 43#else
44#include <qlist.h> 44#include <qlist.h>
45#include <qarray.h> 45#include <qarray.h>
46#define QPtrList QList 46#define QPtrList QList
47#define QMemArray QArray 47#define QMemArray QArray
48#endif 48#endif
49#include "qlayoutengine_p.h" 49#include "qlayoutengine_p.h"
50#include "qobjectlist.h" 50#include "qobjectlist.h"
51#include "qstyle.h" 51#include "qstyle.h"
52#include "qapplication.h" //sendPostedEvents 52#include "qapplication.h" //sendPostedEvents
53#include <qvaluelist.h> 53#include <qvaluelist.h>
54#include <qcursor.h> 54#include <qcursor.h>
55#ifndef KDGANTT_MASTER_CVS 55#ifndef KDGANTT_MASTER_CVS
56//#include "KDGanttMinimizeSplitter.moc" 56//#include "KDGanttMinimizeSplitter.moc"
57#endif 57#endif
58 58
59 59
60 60
61#ifndef DOXYGEN_SKIP_INTERNAL 61#ifndef DOXYGEN_SKIP_INTERNAL
62 62
63#if QT_VERSION >= 232 63#if QT_VERSION >= 232
64static int mouseOffset; 64static int mouseOffset;
65static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit risky 65static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit risky
66 66
67 67
68KDGanttSplitterHandle::KDGanttSplitterHandle( Qt::Orientation o, 68KDGanttSplitterHandle::KDGanttSplitterHandle( Qt::Orientation o,
69 KDGanttMinimizeSplitter *parent, const char * name ) 69 KDGanttMinimizeSplitter *parent, const char * name )
70 : QWidget( parent, name ), _activeButton( 0 ), _collapsed( false ) 70 : QWidget( parent, name ), _activeButton( 0 ), _collapsed( false )
71{ 71{
72 72
73 if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->width() < 650 ) { 73 if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->width() < 650 ) {
74 mSizeHint = QSize(7,7); 74 mSizeHint = QSize(7,7);
75 mUseOffset = true; 75 mUseOffset = true;
76 } else { 76 } else {
77 mSizeHint = QSize(6,6); 77 mSizeHint = QSize(6,6);
78 mUseOffset = false; 78 mUseOffset = false;
79 } 79 }
80 s = parent; 80 s = parent;
81 setOrientation(o); 81 setOrientation(o);
82 setMouseTracking( true ); 82 setMouseTracking( true );
83 mMouseDown = false; 83 mMouseDown = false;
84 //setMaximumHeight( 5 ); // test only 84 //setMaximumHeight( 5 ); // test only
85} 85}
86 86
87QSize KDGanttSplitterHandle::sizeHint() const 87QSize KDGanttSplitterHandle::sizeHint() const
88{ 88{
89 return mSizeHint; 89 return mSizeHint;
90} 90}
91 91
92void KDGanttSplitterHandle::setOrientation( Qt::Orientation o ) 92void KDGanttSplitterHandle::setOrientation( Qt::Orientation o )
93{ 93{
94 orient = o; 94 orient = o;
95#ifndef QT_NO_CURSOR 95#ifndef QT_NO_CURSOR
96 if ( o == KDGanttMinimizeSplitter::Horizontal ) 96 if ( o == KDGanttMinimizeSplitter::Horizontal )
97 setCursor( splitHCursor ); 97 setCursor( splitHCursor );
98 else 98 else
99 setCursor( splitVCursor ); 99 setCursor( splitVCursor );
100#endif 100#endif
101} 101}
102 102
103 103
104void KDGanttSplitterHandle::mouseMoveEvent( QMouseEvent *e ) 104void KDGanttSplitterHandle::mouseMoveEvent( QMouseEvent *e )
105{ 105{
106 updateCursor( e->pos() ); 106 updateCursor( e->pos() );
107 if ( !(e->state()&LeftButton) ) 107 if ( !(e->state()&LeftButton) )
108 return; 108 return;
109 109
110 if ( _activeButton != 0) 110 if ( _activeButton != 0)
111 return; 111 return;
112 112
113 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) 113 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos()))
114 - mouseOffset; 114 - mouseOffset;
115 if ( true /*opaque()*/ ) { 115 if ( opaque() ) {
116 s->moveSplitter( pos, id() ); 116 s->moveSplitter( pos, id() );
117 } else { 117 } else {
118 int min = pos; int max = pos; 118 int min = pos; int max = pos;
119 s->getRange( id(), &min, &max ); 119 s->getRange( id(), &min, &max );
120 s->setRubberband( QMAX( min, QMIN(max, pos ))); 120 s->setRubberband( QMAX( min, QMIN(max, pos )));
121 } 121 }
122 _collapsed = false; 122 _collapsed = false;
123} 123}
124 124
125void KDGanttSplitterHandle::mousePressEvent( QMouseEvent *e ) 125void KDGanttSplitterHandle::mousePressEvent( QMouseEvent *e )
126{ 126{
127 if ( e->button() == LeftButton ) { 127 if ( e->button() == LeftButton ) {
128 _activeButton = onButton( e->pos() ); 128 _activeButton = onButton( e->pos() );
129 mouseOffset = s->pick(e->pos()); 129 mouseOffset = s->pick(e->pos());
130 mMouseDown = true; 130 mMouseDown = true;
131 repaint(); 131 repaint();
132 updateCursor( e->pos() ); 132 updateCursor( e->pos() );
133 } 133 }
134} 134}
135 135
136void KDGanttSplitterHandle::updateCursor( const QPoint& p) 136void KDGanttSplitterHandle::updateCursor( const QPoint& p)
137{ 137{
138 if ( onButton( p ) != 0 ) { 138 if ( onButton( p ) != 0 ) {
139 setCursor( arrowCursor ); 139 setCursor( arrowCursor );
140 } 140 }
141 else { 141 else {
142 if ( orient == KDGanttMinimizeSplitter::Horizontal ) 142 if ( orient == KDGanttMinimizeSplitter::Horizontal )
143 setCursor( splitHCursor ); 143 setCursor( splitHCursor );
144 else 144 else
145 setCursor( splitVCursor ); 145 setCursor( splitVCursor );
146 } 146 }
147} 147}
148void KDGanttSplitterHandle::toggle() 148void KDGanttSplitterHandle::toggle()
149{ 149{
150 int pos; 150 int pos;
151 int min, max; 151 int min, max;
152 if ( !_collapsed ) { 152 if ( !_collapsed ) {
153 s->expandPos( id(), &min, &max ); 153 s->expandPos( id(), &min, &max );
154 if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left 154 if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left
155 || s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { 155 || s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) {
156 pos = min; 156 pos = min;
157 } 157 }
158 else { 158 else {
159 pos = max; 159 pos = max;
160 } 160 }
161 161
162 _origPos = s->pick(mapToParent( QPoint( 0,0 ) )); 162 _origPos = s->pick(mapToParent( QPoint( 0,0 ) ));
163 s->moveSplitter( pos, id() ); 163 s->moveSplitter( pos, id() );
164 _collapsed = true; 164 _collapsed = true;
165 } 165 }
166 else { 166 else {
167 s->moveSplitter( _origPos, id() ); 167 s->moveSplitter( _origPos, id() );
168 _collapsed = false; 168 _collapsed = false;
169 } 169 }
170 repaint(); 170 repaint();
171} 171}
172 172
173void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e ) 173void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e )
174{ 174{
175 mMouseDown = false; 175 mMouseDown = false;
176 if ( _activeButton != 0 ) { 176 if ( _activeButton != 0 ) {
177 if ( onButton( e->pos() ) == _activeButton ) 177 if ( onButton( e->pos() ) == _activeButton )
178 { 178 {
179 toggle(); 179 toggle();
180 } 180 }
181 _activeButton = 0; 181 _activeButton = 0;
182 updateCursor( e->pos() ); 182 updateCursor( e->pos() );
183 } 183 }
184 else { 184 else {
185 if ( !opaque() && e->button() == LeftButton ) { 185 if ( !opaque() && e->button() == LeftButton ) {
186 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) 186 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos()))
187 - mouseOffset; 187 - mouseOffset;
188 s->setRubberband( -1 ); 188 s->setRubberband( -1 );
189 s->moveSplitter( pos, id() ); 189 s->moveSplitter( pos, id() );
190 } 190 }
191 } 191 }
192 repaint(); 192 repaint();
193} 193}
194 194
195int KDGanttSplitterHandle::onButton( const QPoint& p ) 195int KDGanttSplitterHandle::onButton( const QPoint& p )
196{ 196{
197 QValueList<QPointArray> list = buttonRegions(); 197 QValueList<QPointArray> list = buttonRegions();
198 int index = 1; 198 int index = 1;
199 int add = 12; 199 int add = 12;
200 for( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { 200 for( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) {
201 QRect rect = (*it).boundingRect(); 201 QRect rect = (*it).boundingRect();
202 rect.setLeft( rect.left()- add ); 202 rect.setLeft( rect.left()- add );
203 rect.setRight( rect.right() + add); 203 rect.setRight( rect.right() + add);
204 rect.setTop( rect.top()- add ); 204 rect.setTop( rect.top()- add );
205 rect.setBottom( rect.bottom() + add); 205 rect.setBottom( rect.bottom() + add);
206 if ( rect.contains( p ) ) { 206 if ( rect.contains( p ) ) {
207 return index; 207 return index;
208 } 208 }
209 index++; 209 index++;
210 } 210 }
211 return 0; 211 return 0;
212} 212}
213 213
214 214
215QValueList<QPointArray> KDGanttSplitterHandle::buttonRegions() 215QValueList<QPointArray> KDGanttSplitterHandle::buttonRegions()
216{ 216{
217 QValueList<QPointArray> list; 217 QValueList<QPointArray> list;
218 218
219 int sw = 8; 219 int sw = 8;
220 int yyy = 1; 220 int yyy = 1;
221 int xxx = 1; 221 int xxx = 1;
222 int voffset[] = { (int) -sw*3, (int) sw*3 }; 222 int voffset[] = { (int) -sw*3, (int) sw*3 };
223 for ( int i = 0; i < 2; i++ ) { 223 for ( int i = 0; i < 2; i++ ) {
224 QPointArray arr; 224 QPointArray arr;
225 if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right || 225 if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ||
226 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left) { 226 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left) {
227 int mid = height()/2 + voffset[i]; 227 int mid = height()/2 + voffset[i];
228 arr.setPoints( 3, 228 arr.setPoints( 3,
229 1-xxx, mid - sw + 4, 229 1-xxx, mid - sw + 4,
230 sw-3-xxx, mid, 230 sw-3-xxx, mid,
231 1-xxx, mid + sw -4); 231 1-xxx, mid + sw -4);
232 } 232 }
233 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left || 233 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left ||
234 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { 234 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) {
235 int mid = height()/2 + voffset[i]; 235 int mid = height()/2 + voffset[i];
236 arr.setPoints( 3, 236 arr.setPoints( 3,
237 sw-4, mid - sw + 4, 237 sw-4, mid - sw + 4,
238 0, mid, 238 0, mid,
239 sw-4, mid + sw - 4); 239 sw-4, mid + sw - 4);
240 } 240 }
241 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up || 241 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up ||
242 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down) { 242 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down) {
243 int mid = width()/2 + voffset[i]; 243 int mid = width()/2 + voffset[i];
244 arr.setPoints( 3, 244 arr.setPoints( 3,
245 mid - sw + 4, sw-4, 245 mid - sw + 4, sw-4,
246 mid, 0, 246 mid, 0,
247 mid + sw - 4, sw-4 ); 247 mid + sw - 4, sw-4 );
248 } 248 }
249 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down || 249 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down ||
250 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { 250 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) {
251 int mid = width()/2 + voffset[i]; 251 int mid = width()/2 + voffset[i];
252 arr.setPoints( 3, 252 arr.setPoints( 3,
253 mid - sw + 4, 1-yyy, 253 mid - sw + 4, 1-yyy,
254 mid, sw-3-yyy, 254 mid, sw-3-yyy,
255 mid + sw -4, 1-yyy); 255 mid + sw -4, 1-yyy);
256 } 256 }
257 list.append( arr ); 257 list.append( arr );
258 } 258 }
259 return list; 259 return list;
260} 260}
261 261
262void KDGanttSplitterHandle::paintEvent( QPaintEvent * ) 262void KDGanttSplitterHandle::paintEvent( QPaintEvent * )
263{ 263{
264 QPixmap buffer( size() ); 264 QPixmap buffer( size() );
265 QPainter p( &buffer ); 265 QPainter p( &buffer );
266 266
267 //LR 267 //LR
268 // Draw the splitter rectangle 268 // Draw the splitter rectangle
269 p.setBrush( colorGroup().background() ); 269 p.setBrush( colorGroup().background() );
270 p.setPen( colorGroup().foreground() ); 270 p.setPen( colorGroup().foreground() );
271 //p.drawRect( rect() ); 271 //p.drawRect( rect() );
272 buffer.fill( colorGroup().background() ); 272 buffer.fill( colorGroup().background() );
273 //buffer.fill( backgroundColor() ); 273 //buffer.fill( backgroundColor() );
274 // parentWidget()->style().drawPrimitive( QStyle::PE_Panel, &p, rect(), parentWidget()->colorGroup()); 274 // parentWidget()->style().drawPrimitive( QStyle::PE_Panel, &p, rect(), parentWidget()->colorGroup());
275 275
276 int sw = 8; // Hardcoded, given I didn't use styles anymore, I didn't like to use their size 276 int sw = 8; // Hardcoded, given I didn't use styles anymore, I didn't like to use their size
277 277
278 // arrow color 278 // arrow color
279 QColor col; 279 QColor col;
280 if ( _activeButton ) 280 if ( _activeButton )
281 col = colorGroup().background().dark( 250 ); 281 col = colorGroup().background().dark( 250 );
282 else { 282 else {
283 if ( mMouseDown ) 283 if ( mMouseDown )
284 col = Qt::white; 284 col = Qt::white;
285 else 285 else
286 col = colorGroup().background().dark( 150 ); 286 col = colorGroup().background().dark( 150 );
287 } 287 }
288 //QColor col = backgroundColor().dark( 130 ); 288 //QColor col = backgroundColor().dark( 130 );
289 p.setBrush( col ); 289 p.setBrush( col );
290 p.setPen( col ); 290 p.setPen( col );
291 291
292 QValueList<QPointArray> list = buttonRegions(); 292 QValueList<QPointArray> list = buttonRegions();
293 int index = 1; 293 int index = 1;
294 if ( mUseOffset ) 294 if ( mUseOffset )
295 p.translate( 0, 1 ); 295 p.translate( 0, 1 );
296 for ( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { 296 for ( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) {
297 if ( index == _activeButton ) { 297 if ( index == _activeButton ) {
298 298
299 /* 299 /*
300 if ( ! _collapsed ) { 300 if ( ! _collapsed ) {
301 p.save(); 301 p.save();
302 // p.translate( parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftHorizontal ), 302 // p.translate( parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftHorizontal ),
303 // parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftVertical ) ); 303 // parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftVertical ) );
304 p.translate( -1, 0 ); 304 p.translate( -1, 0 );
305 p.drawPolygon( *it, true ); 305 p.drawPolygon( *it, true );
306 p.restore(); } else 306 p.restore(); } else
307 */ 307 */
308 p.drawPolygon( *it, true ); 308 p.drawPolygon( *it, true );
309 309
310 } 310 }
311 else { 311 else {
312 /* 312 /*
313 if ( ! _collapsed ) { 313 if ( ! _collapsed ) {
314 p.save(); 314 p.save();
315 p.translate( -1, 0 ); 315 p.translate( -1, 0 );
316 p.drawPolygon( *it, true ); 316 p.drawPolygon( *it, true );
317 p.restore(); 317 p.restore();
318 } else 318 } else
319 */ 319 */
320 p.drawPolygon( *it, true ); 320 p.drawPolygon( *it, true );
321 321
322 } 322 }
323 index++; 323 index++;
324 } 324 }
325 325
326 // Draw the lines between the arrows 326 // Draw the lines between the arrows
327 if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left || 327 if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left ||
328 s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { 328 s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) {
329 int mid = height()/2; 329 int mid = height()/2;
330 p.drawLine ( 1, mid - sw, 1, mid + sw ); 330 p.drawLine ( 1, mid - sw, 1, mid + sw );
331 p.drawLine ( 3, mid - sw, 3, mid + sw ); 331 p.drawLine ( 3, mid - sw, 3, mid + sw );
332 } 332 }
333 else if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Up || 333 else if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Up ||
334 s->minimizeDirection() == KDGanttMinimizeSplitter::Down ) { 334 s->minimizeDirection() == KDGanttMinimizeSplitter::Down ) {
335 int mid = width()/2; 335 int mid = width()/2;
336 p.drawLine( mid -sw, 1, mid +sw, 1 ); 336 p.drawLine( mid -sw, 1, mid +sw, 1 );
337 p.drawLine( mid -sw, 3, mid +sw, 3 ); 337 p.drawLine( mid -sw, 3, mid +sw, 3 );
338 } 338 }
339 bitBlt( this, 0, 0, &buffer ); 339 bitBlt( this, 0, 0, &buffer );
340 340
341} 341}
342#endif 342#endif
343 343
344class QSplitterLayoutStruct 344class QSplitterLayoutStruct
345{ 345{
346public: 346public:
347 KDGanttMinimizeSplitter::ResizeMode mode; 347 KDGanttMinimizeSplitter::ResizeMode mode;
348 QCOORD sizer; 348 QCOORD sizer;
349 bool isSplitter; 349 bool isSplitter;
350 QWidget *wid; 350 QWidget *wid;
351}; 351};
352 352
353class QSplitterData 353class QSplitterData
354{ 354{
355public: 355public:
356 QSplitterData() : opaque( FALSE ), firstShow( TRUE ) {} 356 QSplitterData() : opaque( FALSE ), firstShow( TRUE ) {}
357 357
358 QPtrList<QSplitterLayoutStruct> list; 358 QPtrList<QSplitterLayoutStruct> list;
359 bool opaque; 359 bool opaque;
360 bool firstShow; 360 bool firstShow;
361}; 361};
362 362
363void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos, 363void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos,
364 int space, int spacer ); 364 int space, int spacer );
365#endif // DOXYGEN_SKIP_INTERNAL 365#endif // DOXYGEN_SKIP_INTERNAL
366 366
367 367
368/*! 368/*!
369 \class KDGanttMinimizeSplitter KDGanttMinimizeSplitter.h 369 \class KDGanttMinimizeSplitter KDGanttMinimizeSplitter.h
370 \brief The KDGanttMinimizeSplitter class implements a splitter 370 \brief The KDGanttMinimizeSplitter class implements a splitter
371 widget with minimize buttons. 371 widget with minimize buttons.
372 372
373 This class (and its documentation) is largely a copy of Qt's 373 This class (and its documentation) is largely a copy of Qt's
374 QSplitter; the copying was necessary because QSplitter is not 374 QSplitter; the copying was necessary because QSplitter is not
375 extensible at all. QSplitter and its documentation are licensed 375 extensible at all. QSplitter and its documentation are licensed
376 according to the GPL and the Qt Professional License (if you hold 376 according to the GPL and the Qt Professional License (if you hold
377 such a license) and are (C) Trolltech AS. 377 such a license) and are (C) Trolltech AS.
378 378
379 A splitter lets the user control the size of child widgets by 379 A splitter lets the user control the size of child widgets by
380 dragging the boundary between the children. Any number of widgets 380 dragging the boundary between the children. Any number of widgets
381 may be controlled. 381 may be controlled.
382 382
383 To show a QListBox, a QListView and a QTextEdit side by side: 383 To show a QListBox, a QListView and a QTextEdit side by side:
384 384
385 \code 385 \code
386 KDGanttMinimizeSplitter *split = new KDGanttMinimizeSplitter( parent ); 386 KDGanttMinimizeSplitter *split = new KDGanttMinimizeSplitter( parent );
387 QListBox *lb = new QListBox( split ); 387 QListBox *lb = new QListBox( split );
388 QListView *lv = new QListView( split ); 388 QListView *lv = new QListView( split );
389 QTextEdit *ed = new QTextEdit( split ); 389 QTextEdit *ed = new QTextEdit( split );
390 \endcode 390 \endcode
391 391
392 In KDGanttMinimizeSplitter, the boundary can be either horizontal or 392 In KDGanttMinimizeSplitter, the boundary can be either horizontal or
393 vertical. The default is horizontal (the children are side by side) 393 vertical. The default is horizontal (the children are side by side)
394 but you can use setOrientation( QSplitter::Vertical ) to set it to 394 but you can use setOrientation( QSplitter::Vertical ) to set it to
395 vertical. 395 vertical.
396 396
397 Use setResizeMode() to specify 397 Use setResizeMode() to specify
398 that a widget should keep its size when the splitter is resized. 398 that a widget should keep its size when the splitter is resized.
399 399
400 Although KDGanttMinimizeSplitter normally resizes the children only 400 Although KDGanttMinimizeSplitter normally resizes the children only
401 at the end of a resize operation, if you call setOpaqueResize( TRUE 401 at the end of a resize operation, if you call setOpaqueResize( TRUE
402 ) the widgets are resized as often as possible. 402 ) the widgets are resized as often as possible.
403 403
404 The initial distribution of size between the widgets is determined 404 The initial distribution of size between the widgets is determined
405 by the initial size of each widget. You can also use setSizes() to 405 by the initial size of each widget. You can also use setSizes() to
406 set the sizes of all the widgets. The function sizes() returns the 406 set the sizes of all the widgets. The function sizes() returns the
407 sizes set by the user. 407 sizes set by the user.
408 408
409 If you hide() a child, its space will be distributed among the other 409 If you hide() a child, its space will be distributed among the other
410 children. It will be reinstated when you show() it again. It is also 410 children. It will be reinstated when you show() it again. It is also
411 possible to reorder the widgets within the splitter using 411 possible to reorder the widgets within the splitter using
412 moveToFirst() and moveToLast(). 412 moveToFirst() and moveToLast().
413*/ 413*/
414 414
415 415
416 416
417static QSize minSize( const QWidget* /*w*/ ) 417static QSize minSize( const QWidget* /*w*/ )
418{ 418{
419 return QSize(0,0); 419 return QSize(0,0);
420} 420}
421 421
422// This is the original version of minSize 422// This is the original version of minSize
423static QSize minSizeHint( const QWidget* w ) 423static QSize minSizeHint( const QWidget* w )
424{ 424{
425 QSize min = w->minimumSize(); 425 QSize min = w->minimumSize();
426 QSize s; 426 QSize s;
427 if ( min.height() <= 0 || min.width() <= 0 ) 427 if ( min.height() <= 0 || min.width() <= 0 )
428 s = w->minimumSizeHint(); 428 s = w->minimumSizeHint();
429 if ( min.height() > 0 ) 429 if ( min.height() > 0 )
430 s.setHeight( min.height() ); 430 s.setHeight( min.height() );
431 if ( min.width() > 0 ) 431 if ( min.width() > 0 )
432 s.setWidth( min.width() ); 432 s.setWidth( min.width() );
433 return s.expandedTo(QSize(0,0)); 433 return s.expandedTo(QSize(0,0));
434} 434}
435 435
436 436
437 437
438/*! 438/*!
439 Constructs a horizontal splitter with the \a parent and \a 439 Constructs a horizontal splitter with the \a parent and \a
440 name arguments being passed on to the QFrame constructor. 440 name arguments being passed on to the QFrame constructor.
441*/ 441*/
442KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( QWidget *parent, const char *name ) 442KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( QWidget *parent, const char *name )
443 :QFrame(parent,name,WPaintUnclipped) 443 :QFrame(parent,name,WPaintUnclipped)
444{ 444{
445 mFirstHandle = 0; 445 mFirstHandle = 0;
446#if QT_VERSION >= 232 446#if QT_VERSION >= 232
447 orient = Horizontal; 447 orient = Horizontal;
448 init(); 448 init();
449#endif 449#endif
450} 450}
451 451
452/*! 452/*!
453 Constructs a splitter with orientation \a o with the \a parent 453 Constructs a splitter with orientation \a o with the \a parent
454 and \a name arguments being passed on to the QFrame constructor. 454 and \a name arguments being passed on to the QFrame constructor.
455*/ 455*/
456KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( Orientation o, QWidget *parent, const char *name ) 456KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( Orientation o, QWidget *parent, const char *name )
457 :QFrame(parent,name,WPaintUnclipped) 457 :QFrame(parent,name,WPaintUnclipped)
458{ 458{
459 mFirstHandle = 0; 459 mFirstHandle = 0;
460#if QT_VERSION >= 232 460#if QT_VERSION >= 232
461 orient = o; 461 orient = o;
462 init(); 462 init();
463#endif 463#endif
464} 464}
465 465
466/*! 466/*!
467 Destroys the splitter and any children. 467 Destroys the splitter and any children.
468*/ 468*/
469KDGanttMinimizeSplitter::~KDGanttMinimizeSplitter() 469KDGanttMinimizeSplitter::~KDGanttMinimizeSplitter()
470{ 470{
471#if QT_VERSION >= 232 471#if QT_VERSION >= 232
472 data->list.setAutoDelete( TRUE ); 472 data->list.setAutoDelete( TRUE );
473 delete data; 473 delete data;
474#endif 474#endif
475} 475}
476 476
477 477
478#if QT_VERSION >= 232 478#if QT_VERSION >= 232
479void KDGanttMinimizeSplitter::init() 479void KDGanttMinimizeSplitter::init()
480{ 480{
481 data = new QSplitterData; 481 data = new QSplitterData;
482 if ( orient == Horizontal ) 482 if ( orient == Horizontal )
483 setSizePolicy( QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum) ); 483 setSizePolicy( QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum) );
484 else 484 else
485 setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding) ); 485 setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding) );
486#ifndef DESKTOP_VERSION
487 setOpaqueResize( false );
488#else
489 setOpaqueResize( true );
490#endif
486} 491}
487#endif 492#endif
488 493
489 494
490void KDGanttMinimizeSplitter::toggle() 495void KDGanttMinimizeSplitter::toggle()
491{ 496{
492 if ( mFirstHandle ) 497 if ( mFirstHandle )
493 mFirstHandle->toggle(); 498 mFirstHandle->toggle();
494 else 499 else
495 qDebug("KDGanttMinimizeSplitter::toggle::sorry, handle not available "); 500 qDebug("KDGanttMinimizeSplitter::toggle::sorry, handle not available ");
496 501
497} 502}
498 503
499 504
500/*! 505/*!
501 \brief the orientation of the splitter 506 \brief the orientation of the splitter
502 507
503 By default the orientation is horizontal (the widgets are side by side). 508 By default the orientation is horizontal (the widgets are side by side).
504 The possible orientations are Qt:Vertical and Qt::Horizontal (the default). 509 The possible orientations are Qt:Vertical and Qt::Horizontal (the default).
505*/ 510*/
506void KDGanttMinimizeSplitter::setOrientation( Orientation o ) 511void KDGanttMinimizeSplitter::setOrientation( Orientation o )
507{ 512{
508#if QT_VERSION >= 232 513#if QT_VERSION >= 232
509 if ( orient == o ) 514 if ( orient == o )
510 return; 515 return;
511 orient = o; 516 orient = o;
512 517
513 if ( orient == Horizontal ) 518 if ( orient == Horizontal )
514 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); 519 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) );
515 else 520 else
516 setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); 521 setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) );
517 522
518 QSplitterLayoutStruct *s = data->list.first(); 523 QSplitterLayoutStruct *s = data->list.first();
519 while ( s ) { 524 while ( s ) {
520 if ( s->isSplitter ) 525 if ( s->isSplitter )
521 ((KDGanttSplitterHandle*)s->wid)->setOrientation( o ); 526 ((KDGanttSplitterHandle*)s->wid)->setOrientation( o );
522 s = data->list.next(); // ### next at end of loop, no iterator 527 s = data->list.next(); // ### next at end of loop, no iterator
523 } 528 }
524 recalc( isVisible() ); 529 recalc( isVisible() );
525#endif 530#endif
526} 531}
527 532
528 533
529#if QT_VERSION >= 232 534#if QT_VERSION >= 232
530/*! 535/*!
531 \reimp 536 \reimp
532*/ 537*/
533void KDGanttMinimizeSplitter::resizeEvent( QResizeEvent * ) 538void KDGanttMinimizeSplitter::resizeEvent( QResizeEvent * )
534{ 539{
535 doResize(); 540 doResize();
536} 541}
537 542
538 543
539/* 544/*
540 Inserts the widget \a w at the end (or at the beginning if \a first 545 Inserts the widget \a w at the end (or at the beginning if \a first
541 is TRUE) of the splitter's list of widgets. 546 is TRUE) of the splitter's list of widgets.
542 547
543 It is the responsibility of the caller of this function to make sure 548 It is the responsibility of the caller of this function to make sure
544 that \a w is not already in the splitter and to call recalcId if 549 that \a w is not already in the splitter and to call recalcId if
545 needed. (If \a first is TRUE, then recalcId is very probably 550 needed. (If \a first is TRUE, then recalcId is very probably
546 needed.) 551 needed.)
547*/ 552*/
548QSplitterLayoutStruct *KDGanttMinimizeSplitter::addWidget( QWidget *w, bool first ) 553QSplitterLayoutStruct *KDGanttMinimizeSplitter::addWidget( QWidget *w, bool first )
549{ 554{
550 QSplitterLayoutStruct *s; 555 QSplitterLayoutStruct *s;
551 KDGanttSplitterHandle *newHandle = 0; 556 KDGanttSplitterHandle *newHandle = 0;
552 if ( data->list.count() > 0 ) { 557 if ( data->list.count() > 0 ) {
553 s = new QSplitterLayoutStruct; 558 s = new QSplitterLayoutStruct;
554 s->mode = KeepSize; 559 s->mode = KeepSize;
555 QString tmp = "qt_splithandle_"; 560 QString tmp = "qt_splithandle_";
556 tmp += w->name(); 561 tmp += w->name();
557 newHandle = new KDGanttSplitterHandle( orientation(), this, tmp.latin1() ); 562 newHandle = new KDGanttSplitterHandle( orientation(), this, tmp.latin1() );
558 if ( ! mFirstHandle ) 563 if ( ! mFirstHandle )
559 mFirstHandle = newHandle; 564 mFirstHandle = newHandle;
560 s->wid = newHandle; 565 s->wid = newHandle;
561 newHandle->setId(data->list.count()); 566 newHandle->setId(data->list.count());
562 s->isSplitter = TRUE; 567 s->isSplitter = TRUE;
563 s->sizer = pick( newHandle->sizeHint() ); 568 s->sizer = pick( newHandle->sizeHint() );
564 if ( first ) 569 if ( first )
565 data->list.insert( 0, s ); 570 data->list.insert( 0, s );
566 else 571 else
567 data->list.append( s ); 572 data->list.append( s );
568 } 573 }
569 s = new QSplitterLayoutStruct; 574 s = new QSplitterLayoutStruct;
570 s->mode = Stretch; 575 s->mode = Stretch;
571 s->wid = w; 576 s->wid = w;
572 if ( !testWState( WState_Resized ) && w->sizeHint().isValid() ) 577 if ( !testWState( WState_Resized ) && w->sizeHint().isValid() )
573 s->sizer = pick( w->sizeHint() ); 578 s->sizer = pick( w->sizeHint() );
574 else 579 else
575 s->sizer = pick( w->size() ); 580 s->sizer = pick( w->size() );
576 s->isSplitter = FALSE; 581 s->isSplitter = FALSE;
577 if ( first ) 582 if ( first )
578 data->list.insert( 0, s ); 583 data->list.insert( 0, s );
579 else 584 else
580 data->list.append( s ); 585 data->list.append( s );
581 if ( newHandle && isVisible() ) 586 if ( newHandle && isVisible() )
582 newHandle->show(); //will trigger sending of post events 587 newHandle->show(); //will trigger sending of post events
583 return s; 588 return s;
584} 589}
585 590
586 591
587/*! 592/*!
588 Tells the splitter that a child widget has been inserted or removed. 593 Tells the splitter that a child widget has been inserted or removed.
589 The event is passed in \a c. 594 The event is passed in \a c.
590*/ 595*/
591void KDGanttMinimizeSplitter::childEvent( QChildEvent *c ) 596void KDGanttMinimizeSplitter::childEvent( QChildEvent *c )
592{ 597{
593 if ( c->type() == QEvent::ChildInserted ) { 598 if ( c->type() == QEvent::ChildInserted ) {
594 if ( !c->child()->isWidgetType() ) 599 if ( !c->child()->isWidgetType() )
595 return; 600 return;
596 601
597 if ( ((QWidget*)c->child())->testWFlags( WType_TopLevel ) ) 602 if ( ((QWidget*)c->child())->testWFlags( WType_TopLevel ) )
598 return; 603 return;
599 604
600 QSplitterLayoutStruct *s = data->list.first(); 605 QSplitterLayoutStruct *s = data->list.first();
601 while ( s ) { 606 while ( s ) {
602 if ( s->wid == c->child() ) 607 if ( s->wid == c->child() )
603 return; 608 return;
604 s = data->list.next(); 609 s = data->list.next();
605 } 610 }
606 addWidget( (QWidget*)c->child() ); 611 addWidget( (QWidget*)c->child() );
607 recalc( isVisible() ); 612 recalc( isVisible() );
608 613
609 } else if ( c->type() == QEvent::ChildRemoved ) { 614 } else if ( c->type() == QEvent::ChildRemoved ) {
610 QSplitterLayoutStruct *p = 0; 615 QSplitterLayoutStruct *p = 0;
611 if ( data->list.count() > 1 ) 616 if ( data->list.count() > 1 )
612 p = data->list.at(1); //remove handle _after_ first widget. 617 p = data->list.at(1); //remove handle _after_ first widget.
613 QSplitterLayoutStruct *s = data->list.first(); 618 QSplitterLayoutStruct *s = data->list.first();
614 while ( s ) { 619 while ( s ) {
615 if ( s->wid == c->child() ) { 620 if ( s->wid == c->child() ) {
616 data->list.removeRef( s ); 621 data->list.removeRef( s );
617 delete s; 622 delete s;
618 if ( p && p->isSplitter ) { 623 if ( p && p->isSplitter ) {
619 data->list.removeRef( p ); 624 data->list.removeRef( p );
620 delete p->wid; //will call childEvent 625 delete p->wid; //will call childEvent
621 delete p; 626 delete p;
622 } 627 }
623 recalcId(); 628 recalcId();
624 doResize(); 629 doResize();
625 return; 630 return;
626 } 631 }
627 p = s; 632 p = s;
628 s = data->list.next(); 633 s = data->list.next();
629 } 634 }
630 } 635 }
631} 636}
632 637
633 638
634/*! 639/*!
635 Shows a rubber band at position \a p. If \a p is negative, the 640 Shows a rubber band at position \a p. If \a p is negative, the
636 rubber band is removed. 641 rubber band is removed.
637*/ 642*/
638void KDGanttMinimizeSplitter::setRubberband( int p ) 643void KDGanttMinimizeSplitter::setRubberband( int p )
639{ 644{
640 QPainter paint( this ); 645 QPainter paint( this );
641 paint.setPen( gray ); 646 paint.setPen( gray );
642 paint.setBrush( gray ); 647 paint.setBrush( gray );
643 paint.setRasterOp( XorROP ); 648 paint.setRasterOp( XorROP );
644 QRect r = contentsRect(); 649 QRect r = contentsRect();
645 const int rBord = 3; //Themable???? 650 const int rBord = 3; //Themable????
646#if QT_VERSION >= 0x030000 651#if QT_VERSION >= 0x030000
647 int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); 652 int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this);
648#else 653#else
649 int sw = style().splitterWidth(); 654 int sw = style().splitterWidth();
650#endif 655#endif
651 if ( orient == Horizontal ) { 656 if ( orient == Horizontal ) {
652 if ( opaqueOldPos >= 0 ) 657 if ( opaqueOldPos >= 0 )
653 paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(), 658 paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(),
654 2*rBord, r.height() ); 659 2*rBord, r.height() );
655 if ( p >= 0 ) 660 if ( p >= 0 )
656 paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() ); 661 paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() );
657 } else { 662 } else {
658 if ( opaqueOldPos >= 0 ) 663 if ( opaqueOldPos >= 0 )
659 paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord, 664 paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord,
660 r.width(), 2*rBord ); 665 r.width(), 2*rBord );
661 if ( p >= 0 ) 666 if ( p >= 0 )
662 paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord ); 667 paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord );
663 } 668 }
664 opaqueOldPos = p; 669 opaqueOldPos = p;
665} 670}
666 671
667 672
668/*! \reimp */ 673/*! \reimp */
669bool KDGanttMinimizeSplitter::event( QEvent *e ) 674bool KDGanttMinimizeSplitter::event( QEvent *e )
670{ 675{
671 if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) { 676 if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) {
672 recalc( isVisible() ); 677 recalc( isVisible() );
673 if ( e->type() == QEvent::Show ) 678 if ( e->type() == QEvent::Show )
674 data->firstShow = FALSE; 679 data->firstShow = FALSE;
675 } 680 }
676 return QWidget::event( e ); 681 return QWidget::event( e );
677} 682}
678 683
679 684
680/*! 685/*!
681 \obsolete 686 \obsolete
682 687
683 Draws the splitter handle in the rectangle described by \a x, \a y, 688 Draws the splitter handle in the rectangle described by \a x, \a y,
684 \a w, \a h using painter \a p. 689 \a w, \a h using painter \a p.
685 \sa QStyle::drawPrimitive() 690 \sa QStyle::drawPrimitive()
686*/ 691*/
687void KDGanttMinimizeSplitter::drawSplitter( QPainter *p, 692void KDGanttMinimizeSplitter::drawSplitter( QPainter *p,
688 QCOORD x, QCOORD y, QCOORD w, QCOORD h ) 693 QCOORD x, QCOORD y, QCOORD w, QCOORD h )
689{ 694{
690#if 0 695#if 0
691 // LR 696 // LR
692 style().drawPrimitive(QStyle::PE_Splitter, p, QRect(x, y, w, h), colorGroup(), 697 style().drawPrimitive(QStyle::PE_Splitter, p, QRect(x, y, w, h), colorGroup(),
693 (orientation() == Qt::Horizontal ? 698 (orientation() == Qt::Horizontal ?
694 QStyle::Style_Horizontal : 0)); 699 QStyle::Style_Horizontal : 0));
695#endif 700#endif
696} 701}
697 702
698 703
699/*! 704/*!
700 Returns the id of the splitter to the right of or below the widget \a w, 705 Returns the id of the splitter to the right of or below the widget \a w,
701 or 0 if there is no such splitter 706 or 0 if there is no such splitter
702 (i.e. it is either not in this KDGanttMinimizeSplitter or it is at the end). 707 (i.e. it is either not in this KDGanttMinimizeSplitter or it is at the end).
703*/ 708*/
704int KDGanttMinimizeSplitter::idAfter( QWidget* w ) const 709int KDGanttMinimizeSplitter::idAfter( QWidget* w ) const
705{ 710{
706 QSplitterLayoutStruct *s = data->list.first(); 711 QSplitterLayoutStruct *s = data->list.first();
707 bool seen_w = FALSE; 712 bool seen_w = FALSE;
708 while ( s ) { 713 while ( s ) {
709 if ( s->isSplitter && seen_w ) 714 if ( s->isSplitter && seen_w )
710 return data->list.at(); 715 return data->list.at();
711 if ( !s->isSplitter && s->wid == w ) 716 if ( !s->isSplitter && s->wid == w )
712 seen_w = TRUE; 717 seen_w = TRUE;
713 s = data->list.next(); 718 s = data->list.next();
714 } 719 }
715 return 0; 720 return 0;
716} 721}
717 722
718 723
719/*! 724/*!
720 Moves the left/top edge of the splitter handle with id \a id as 725 Moves the left/top edge of the splitter handle with id \a id as
721 close as possible to position \a p, which is the distance from the 726 close as possible to position \a p, which is the distance from the
722 left (or top) edge of the widget. 727 left (or top) edge of the widget.
723 728
724 For Arabic and Hebrew the layout is reversed, and using this 729 For Arabic and Hebrew the layout is reversed, and using this
725 function to set the position of the splitter might lead to 730 function to set the position of the splitter might lead to
726 unexpected results, since in Arabic and Hebrew the position of 731 unexpected results, since in Arabic and Hebrew the position of
727 splitter one is to the left of the position of splitter zero. 732 splitter one is to the left of the position of splitter zero.
728 733
729 \sa idAfter() 734 \sa idAfter()
730*/ 735*/
731void KDGanttMinimizeSplitter::moveSplitter( QCOORD p, int id ) 736void KDGanttMinimizeSplitter::moveSplitter( QCOORD p, int id )
732{ 737{
733 p = adjustPos( p, id ); 738 p = adjustPos( p, id );
734 QSplitterLayoutStruct *s = data->list.at(id); 739 QSplitterLayoutStruct *s = data->list.at(id);
735 int oldP = orient == Horizontal ? s->wid->x() : s->wid->y(); 740 int oldP = orient == Horizontal ? s->wid->x() : s->wid->y();
736 bool upLeft; 741 bool upLeft;
737 if ( false && orient == Horizontal ) { 742 if ( false && orient == Horizontal ) {
738 p += s->wid->width(); 743 p += s->wid->width();
739 upLeft = p > oldP; 744 upLeft = p > oldP;
740 } else 745 } else
741 upLeft = p < oldP; 746 upLeft = p < oldP;
742 747
743 moveAfter( p, id, upLeft ); 748 moveAfter( p, id, upLeft );
744 moveBefore( p-1, id-1, upLeft ); 749 moveBefore( p-1, id-1, upLeft );
745 750
746 storeSizes(); 751 storeSizes();
747} 752}
748 753
749 754
750void KDGanttMinimizeSplitter::setG( QWidget *w, int p, int s, bool isSplitter ) 755void KDGanttMinimizeSplitter::setG( QWidget *w, int p, int s, bool isSplitter )
751{ 756{
752 if ( orient == Horizontal ) { 757 if ( orient == Horizontal ) {
753 if ( false && orient == Horizontal && !isSplitter ) 758 if ( false && orient == Horizontal && !isSplitter )
754 p = contentsRect().width() - p - s; 759 p = contentsRect().width() - p - s;
755 w->setGeometry( p, contentsRect().y(), s, contentsRect().height() ); 760 w->setGeometry( p, contentsRect().y(), s, contentsRect().height() );
756 } else 761 } else
757 w->setGeometry( contentsRect().x(), p, contentsRect().width(), s ); 762 w->setGeometry( contentsRect().x(), p, contentsRect().width(), s );
758} 763}
759 764
760 765
761/* 766/*
762 Places the right/bottom edge of the widget at \a id at position \a pos. 767 Places the right/bottom edge of the widget at \a id at position \a pos.
763 768
764 \sa idAfter() 769 \sa idAfter()
765*/ 770*/
766void KDGanttMinimizeSplitter::moveBefore( int pos, int id, bool upLeft ) 771void KDGanttMinimizeSplitter::moveBefore( int pos, int id, bool upLeft )
767{ 772{
768 if( id < 0 ) 773 if( id < 0 )
769 return; 774 return;
770 QSplitterLayoutStruct *s = data->list.at(id); 775 QSplitterLayoutStruct *s = data->list.at(id);
771 if ( !s ) 776 if ( !s )
772 return; 777 return;
773 QWidget *w = s->wid; 778 QWidget *w = s->wid;
774 if ( w->isHidden() ) { 779 if ( w->isHidden() ) {
775 moveBefore( pos, id-1, upLeft ); 780 moveBefore( pos, id-1, upLeft );
776 } else if ( s->isSplitter ) { 781 } else if ( s->isSplitter ) {
777 int pos1, pos2; 782 int pos1, pos2;
778 int dd = s->sizer; 783 int dd = s->sizer;
779 if( false && orient == Horizontal ) { 784 if( false && orient == Horizontal ) {
780 pos1 = pos; 785 pos1 = pos;
781 pos2 = pos + dd; 786 pos2 = pos + dd;
782 } else { 787 } else {
783 pos2 = pos - dd; 788 pos2 = pos - dd;
784 pos1 = pos2 + 1; 789 pos1 = pos2 + 1;
785 } 790 }
786 if ( upLeft ) { 791 if ( upLeft ) {
787 setG( w, pos1, dd, TRUE ); 792 setG( w, pos1, dd, TRUE );
788 moveBefore( pos2, id-1, upLeft ); 793 moveBefore( pos2, id-1, upLeft );
789 } else { 794 } else {
790 moveBefore( pos2, id-1, upLeft ); 795 moveBefore( pos2, id-1, upLeft );
791 setG( w, pos1, dd, TRUE ); 796 setG( w, pos1, dd, TRUE );
792 } 797 }
793 } else { 798 } else {
794 int dd, newLeft, nextPos; 799 int dd, newLeft, nextPos;
795 if( false && orient == Horizontal ) { 800 if( false && orient == Horizontal ) {
796 dd = w->geometry().right() - pos; 801 dd = w->geometry().right() - pos;
797 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); 802 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize())));
798 newLeft = pos+1; 803 newLeft = pos+1;
799 nextPos = newLeft + dd; 804 nextPos = newLeft + dd;
800 } else { 805 } else {
801 dd = pos - pick( w->pos() ) + 1; 806 dd = pos - pick( w->pos() ) + 1;
802 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); 807 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize())));
803 newLeft = pos-dd+1; 808 newLeft = pos-dd+1;
804 nextPos = newLeft - 1; 809 nextPos = newLeft - 1;
805 } 810 }
806 setG( w, newLeft, dd, TRUE ); 811 setG( w, newLeft, dd, TRUE );
807 moveBefore( nextPos, id-1, upLeft ); 812 moveBefore( nextPos, id-1, upLeft );
808 } 813 }
809} 814}
810 815
811 816
812/* 817/*
813 Places the left/top edge of the widget at \a id at position \a pos. 818 Places the left/top edge of the widget at \a id at position \a pos.
814 819
815 \sa idAfter() 820 \sa idAfter()
816*/ 821*/
817void KDGanttMinimizeSplitter::moveAfter( int pos, int id, bool upLeft ) 822void KDGanttMinimizeSplitter::moveAfter( int pos, int id, bool upLeft )
818{ 823{
819 QSplitterLayoutStruct *s = id < int(data->list.count()) ? 824 QSplitterLayoutStruct *s = id < int(data->list.count()) ?
820 data->list.at(id) : 0; 825 data->list.at(id) : 0;
821 if ( !s ) 826 if ( !s )
822 return; 827 return;
823 QWidget *w = s->wid; 828 QWidget *w = s->wid;
824 if ( w->isHidden() ) { 829 if ( w->isHidden() ) {
825 moveAfter( pos, id+1, upLeft ); 830 moveAfter( pos, id+1, upLeft );
826 } else if ( pick( w->pos() ) == pos ) { 831 } else if ( pick( w->pos() ) == pos ) {
827 //No need to do anything if it's already there. 832 //No need to do anything if it's already there.
828 return; 833 return;
829 } else if ( s->isSplitter ) { 834 } else if ( s->isSplitter ) {
830 int dd = s->sizer; 835 int dd = s->sizer;
831 int pos1, pos2; 836 int pos1, pos2;
832 if( false && orient == Horizontal ) { 837 if( false && orient == Horizontal ) {
833 pos2 = pos - dd; 838 pos2 = pos - dd;
834 pos1 = pos2 + 1; 839 pos1 = pos2 + 1;
835 } else { 840 } else {
836 pos1 = pos; 841 pos1 = pos;
837 pos2 = pos + dd; 842 pos2 = pos + dd;
838 } 843 }
839 if ( upLeft ) { 844 if ( upLeft ) {
840 setG( w, pos1, dd, TRUE ); 845 setG( w, pos1, dd, TRUE );
841 moveAfter( pos2, id+1, upLeft ); 846 moveAfter( pos2, id+1, upLeft );
842 } else { 847 } else {
843 moveAfter( pos2, id+1, upLeft ); 848 moveAfter( pos2, id+1, upLeft );
844 setG( w, pos1, dd, TRUE ); 849 setG( w, pos1, dd, TRUE );
845 } 850 }
846 } else { 851 } else {
847 int left = pick( w->pos() ); 852 int left = pick( w->pos() );
848 int right, dd,/* newRight,*/ newLeft, nextPos; 853 int right, dd,/* newRight,*/ newLeft, nextPos;
849 if ( false && orient == Horizontal ) { 854 if ( false && orient == Horizontal ) {
850 dd = pos - left + 1; 855 dd = pos - left + 1;
851 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); 856 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize())));
852 newLeft = pos-dd+1; 857 newLeft = pos-dd+1;
853 nextPos = newLeft - 1; 858 nextPos = newLeft - 1;
854 } else { 859 } else {
855 right = pick( w->geometry().bottomRight() ); 860 right = pick( w->geometry().bottomRight() );
856 dd = right - pos + 1; 861 dd = right - pos + 1;
857 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); 862 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize())));
858 /*newRight = pos+dd-1;*/ 863 /*newRight = pos+dd-1;*/
859 newLeft = pos; 864 newLeft = pos;
860 nextPos = newLeft + dd; 865 nextPos = newLeft + dd;
861 } 866 }
862 setG( w, newLeft, dd, TRUE ); 867 setG( w, newLeft, dd, TRUE );
863 /*if( right != newRight )*/ 868 /*if( right != newRight )*/
864 moveAfter( nextPos, id+1, upLeft ); 869 moveAfter( nextPos, id+1, upLeft );
865 } 870 }
866} 871}
867 872
868 873
869void KDGanttMinimizeSplitter::expandPos( int id, int* min, int* max ) 874void KDGanttMinimizeSplitter::expandPos( int id, int* min, int* max )
870{ 875{
871 QSplitterLayoutStruct *s = data->list.at(id-1); 876 QSplitterLayoutStruct *s = data->list.at(id-1);
872 QWidget* w = s->wid; 877 QWidget* w = s->wid;
873 *min = pick( w->mapToParent( QPoint(0,0) ) ); 878 *min = pick( w->mapToParent( QPoint(0,0) ) );
874 879
875 if ( (uint) id == data->list.count() ) { 880 if ( (uint) id == data->list.count() ) {
876 pick( size() ); 881 pick( size() );
877 } 882 }
878 else { 883 else {
879 QSplitterLayoutStruct *s = data->list.at(id+1); 884 QSplitterLayoutStruct *s = data->list.at(id+1);
880 QWidget* w = s->wid; 885 QWidget* w = s->wid;
881 *max = pick( w->mapToParent( QPoint( w->width(), w->height() ) ) ) -8; 886 *max = pick( w->mapToParent( QPoint( w->width(), w->height() ) ) ) -8;
882 } 887 }
883} 888}
884 889
885 890
886/*! 891/*!
887 Returns the valid range of the splitter with id \a id in \a *min and \a *max. 892 Returns the valid range of the splitter with id \a id in \a *min and \a *max.
888 893
889 \sa idAfter() 894 \sa idAfter()
890*/ 895*/
891 896
892void KDGanttMinimizeSplitter::getRange( int id, int *min, int *max ) 897void KDGanttMinimizeSplitter::getRange( int id, int *min, int *max )
893{ 898{
894 int minB = 0;//before 899 int minB = 0;//before
895 int maxB = 0; 900 int maxB = 0;
896 int minA = 0; 901 int minA = 0;
897 int maxA = 0;//after 902 int maxA = 0;//after
898 int n = data->list.count(); 903 int n = data->list.count();
899 if ( id < 0 || id >= n ) 904 if ( id < 0 || id >= n )
900 return; 905 return;
901 int i; 906 int i;
902 for ( i = 0; i < id; i++ ) { 907 for ( i = 0; i < id; i++ ) {
903 QSplitterLayoutStruct *s = data->list.at(i); 908 QSplitterLayoutStruct *s = data->list.at(i);
904 if ( s->wid->isHidden() ) { 909 if ( s->wid->isHidden() ) {
905 //ignore 910 //ignore
906 } else if ( s->isSplitter ) { 911 } else if ( s->isSplitter ) {
907 minB += s->sizer; 912 minB += s->sizer;
908 maxB += s->sizer; 913 maxB += s->sizer;
909 } else { 914 } else {
910 minB += pick( minSize(s->wid) ); 915 minB += pick( minSize(s->wid) );
911 maxB += pick( s->wid->maximumSize() ); 916 maxB += pick( s->wid->maximumSize() );
912 } 917 }
913 } 918 }
914 for ( i = id; i < n; i++ ) { 919 for ( i = id; i < n; i++ ) {
915 QSplitterLayoutStruct *s = data->list.at(i); 920 QSplitterLayoutStruct *s = data->list.at(i);
916 if ( s->wid->isHidden() ) { 921 if ( s->wid->isHidden() ) {
917 //ignore 922 //ignore
918 } else if ( s->isSplitter ) { 923 } else if ( s->isSplitter ) {
919 minA += s->sizer; 924 minA += s->sizer;
920 maxA += s->sizer; 925 maxA += s->sizer;
921 } else { 926 } else {
922 minA += pick( minSize(s->wid) ); 927 minA += pick( minSize(s->wid) );
923 maxA += pick( s->wid->maximumSize() ); 928 maxA += pick( s->wid->maximumSize() );
924 } 929 }
925 } 930 }
926 QRect r = contentsRect(); 931 QRect r = contentsRect();
927 if ( orient == Horizontal && false ) { 932 if ( orient == Horizontal && false ) {
928#if QT_VERSION >= 0x030000 933#if QT_VERSION >= 0x030000
929 int splitterWidth = style().pixelMetric(QStyle::PM_SplitterWidth, this); 934 int splitterWidth = style().pixelMetric(QStyle::PM_SplitterWidth, this);
930#else 935#else
931 int splitterWidth = style().splitterWidth(); 936 int splitterWidth = style().splitterWidth();
932#endif 937#endif
933 938
934 if ( min ) 939 if ( min )
935 *min = pick(r.topRight()) - QMIN( maxB, pick(r.size())-minA ) - splitterWidth; 940 *min = pick(r.topRight()) - QMIN( maxB, pick(r.size())-minA ) - splitterWidth;
936 if ( max ) 941 if ( max )
937 *max = pick(r.topRight()) - QMAX( minB, pick(r.size())-maxA ) - splitterWidth; 942 *max = pick(r.topRight()) - QMAX( minB, pick(r.size())-maxA ) - splitterWidth;
938 } else { 943 } else {
939 if ( min ) 944 if ( min )
940 *min = pick(r.topLeft()) + QMAX( minB, pick(r.size())-maxA ); 945 *min = pick(r.topLeft()) + QMAX( minB, pick(r.size())-maxA );
941 if ( max ) 946 if ( max )
942 *max = pick(r.topLeft()) + QMIN( maxB, pick(r.size())-minA ); 947 *max = pick(r.topLeft()) + QMIN( maxB, pick(r.size())-minA );
943 } 948 }
944} 949}
945 950
946 951
947/*! 952/*!
948 Returns the closest legal position to \a p of the splitter with id \a id. 953 Returns the closest legal position to \a p of the splitter with id \a id.
949 954
950 \sa idAfter() 955 \sa idAfter()
951*/ 956*/
952 957
953int KDGanttMinimizeSplitter::adjustPos( int p, int id ) 958int KDGanttMinimizeSplitter::adjustPos( int p, int id )
954{ 959{
955 int min = 0; 960 int min = 0;
956 int max = 0; 961 int max = 0;
957 getRange( id, &min, &max ); 962 getRange( id, &min, &max );
958 p = QMAX( min, QMIN( p, max ) ); 963 p = QMAX( min, QMIN( p, max ) );
959 964
960 return p; 965 return p;
961} 966}
962 967
963 968
964void KDGanttMinimizeSplitter::doResize() 969void KDGanttMinimizeSplitter::doResize()
965{ 970{
966 QRect r = contentsRect(); 971 QRect r = contentsRect();
967 int i; 972 int i;
968 int n = data->list.count(); 973 int n = data->list.count();
969 QMemArray<QLayoutStruct> a( n ); 974 QMemArray<QLayoutStruct> a( n );
970 for ( i = 0; i< n; i++ ) { 975 for ( i = 0; i< n; i++ ) {
971 a[i].init(); 976 a[i].init();
972 QSplitterLayoutStruct *s = data->list.at(i); 977 QSplitterLayoutStruct *s = data->list.at(i);
973 if ( s->wid->isHidden() ) { 978 if ( s->wid->isHidden() ) {
974 a[i].stretch = 0; 979 a[i].stretch = 0;
975 a[i].sizeHint = a[i].minimumSize = 0; 980 a[i].sizeHint = a[i].minimumSize = 0;
976 a[i].maximumSize = 0; 981 a[i].maximumSize = 0;
977 } else if ( s->isSplitter ) { 982 } else if ( s->isSplitter ) {
978 a[i].stretch = 0; 983 a[i].stretch = 0;
979 a[i].sizeHint = a[i].minimumSize = a[i].maximumSize = s->sizer; 984 a[i].sizeHint = a[i].minimumSize = a[i].maximumSize = s->sizer;
980 a[i].empty = FALSE; 985 a[i].empty = FALSE;
981 } else if ( s->mode == KeepSize ) { 986 } else if ( s->mode == KeepSize ) {
982 a[i].stretch = 0; 987 a[i].stretch = 0;
983 a[i].minimumSize = pick( minSize(s->wid) ); 988 a[i].minimumSize = pick( minSize(s->wid) );
984 a[i].sizeHint = s->sizer; 989 a[i].sizeHint = s->sizer;
985 a[i].maximumSize = pick( s->wid->maximumSize() ); 990 a[i].maximumSize = pick( s->wid->maximumSize() );
986 a[i].empty = FALSE; 991 a[i].empty = FALSE;
987 } else if ( s->mode == FollowSizeHint ) { 992 } else if ( s->mode == FollowSizeHint ) {
988 a[i].stretch = 0; 993 a[i].stretch = 0;
989 a[i].minimumSize = a[i].sizeHint = pick( s->wid->sizeHint() ); 994 a[i].minimumSize = a[i].sizeHint = pick( s->wid->sizeHint() );
990 a[i].maximumSize = pick( s->wid->maximumSize() ); 995 a[i].maximumSize = pick( s->wid->maximumSize() );
991 a[i].empty = FALSE; 996 a[i].empty = FALSE;
992 } else { //proportional 997 } else { //proportional
993 a[i].stretch = s->sizer; 998 a[i].stretch = s->sizer;
994 a[i].maximumSize = pick( s->wid->maximumSize() ); 999 a[i].maximumSize = pick( s->wid->maximumSize() );
995 a[i].sizeHint = a[i].minimumSize = pick( minSize(s->wid) ); 1000 a[i].sizeHint = a[i].minimumSize = pick( minSize(s->wid) );
996 a[i].empty = FALSE; 1001 a[i].empty = FALSE;
997 } 1002 }
998 } 1003 }
999 1004
1000 kdganttGeomCalc( a, 0, n, pick( r.topLeft() ), pick( r.size() ), 0 ); 1005 kdganttGeomCalc( a, 0, n, pick( r.topLeft() ), pick( r.size() ), 0 );
1001 1006
1002 for ( i = 0; i< n; i++ ) { 1007 for ( i = 0; i< n; i++ ) {
1003 QSplitterLayoutStruct *s = data->list.at(i); 1008 QSplitterLayoutStruct *s = data->list.at(i);
1004 setG( s->wid, a[i].pos, a[i].size ); 1009 setG( s->wid, a[i].pos, a[i].size );
1005 } 1010 }
1006 1011
1007} 1012}
1008 1013
1009 1014
1010void KDGanttMinimizeSplitter::recalc( bool update ) 1015void KDGanttMinimizeSplitter::recalc( bool update )
1011{ 1016{
1012 int fi = 2*frameWidth(); 1017 int fi = 2*frameWidth();
1013 int maxl = fi; 1018 int maxl = fi;
1014 int minl = fi; 1019 int minl = fi;
1015 int maxt = QWIDGETSIZE_MAX; 1020 int maxt = QWIDGETSIZE_MAX;
1016 int mint = fi; 1021 int mint = fi;
1017 int n = data->list.count(); 1022 int n = data->list.count();
1018 bool first = TRUE; 1023 bool first = TRUE;
1019 /* 1024 /*
1020 The splitter before a hidden widget is always hidden. 1025 The splitter before a hidden widget is always hidden.
1021 The splitter before the first visible widget is hidden. 1026 The splitter before the first visible widget is hidden.
1022 The splitter before any other visible widget is visible. 1027 The splitter before any other visible widget is visible.
1023 */ 1028 */
1024 for ( int i = 0; i< n; i++ ) { 1029 for ( int i = 0; i< n; i++ ) {
1025 QSplitterLayoutStruct *s = data->list.at(i); 1030 QSplitterLayoutStruct *s = data->list.at(i);
1026 if ( !s->isSplitter ) { 1031 if ( !s->isSplitter ) {
1027 QSplitterLayoutStruct *p = (i > 0) ? p = data->list.at( i-1 ) : 0; 1032 QSplitterLayoutStruct *p = (i > 0) ? p = data->list.at( i-1 ) : 0;
1028 if ( p && p->isSplitter ) 1033 if ( p && p->isSplitter )
1029 if ( first || s->wid->isHidden() ) 1034 if ( first || s->wid->isHidden() )
1030 p->wid->hide(); //may trigger new recalc 1035 p->wid->hide(); //may trigger new recalc
1031 else 1036 else
1032 p->wid->show(); //may trigger new recalc 1037 p->wid->show(); //may trigger new recalc
1033 if ( !s->wid->isHidden() ) 1038 if ( !s->wid->isHidden() )
1034 first = FALSE; 1039 first = FALSE;
1035 } 1040 }
1036 } 1041 }
1037 1042
1038 bool empty=TRUE; 1043 bool empty=TRUE;
1039 for ( int j = 0; j< n; j++ ) { 1044 for ( int j = 0; j< n; j++ ) {
1040 QSplitterLayoutStruct *s = data->list.at(j); 1045 QSplitterLayoutStruct *s = data->list.at(j);
1041 if ( !s->wid->isHidden() ) { 1046 if ( !s->wid->isHidden() ) {
1042 empty = FALSE; 1047 empty = FALSE;
1043 if ( s->isSplitter ) { 1048 if ( s->isSplitter ) {
1044 minl += s->sizer; 1049 minl += s->sizer;
1045 maxl += s->sizer; 1050 maxl += s->sizer;
1046 } else { 1051 } else {
1047 QSize minS = minSize(s->wid); 1052 QSize minS = minSize(s->wid);
1048 minl += pick( minS ); 1053 minl += pick( minS );
1049 maxl += pick( s->wid->maximumSize() ); 1054 maxl += pick( s->wid->maximumSize() );
1050 mint = QMAX( mint, trans( minS )); 1055 mint = QMAX( mint, trans( minS ));
1051 int tm = trans( s->wid->maximumSize() ); 1056 int tm = trans( s->wid->maximumSize() );
1052 if ( tm > 0 ) 1057 if ( tm > 0 )
1053 maxt = QMIN( maxt, tm ); 1058 maxt = QMIN( maxt, tm );
1054 } 1059 }
1055 } 1060 }
1056 } 1061 }
1057 if ( empty ) { 1062 if ( empty ) {
1058 if ( parentWidget() != 0 && parentWidget()->inherits("KDGanttMinimizeSplitter") ) { 1063 if ( parentWidget() != 0 && parentWidget()->inherits("KDGanttMinimizeSplitter") ) {
1059 // nested splitters; be nice 1064 // nested splitters; be nice
1060 maxl = maxt = 0; 1065 maxl = maxt = 0;
1061 } else { 1066 } else {
1062 // KDGanttMinimizeSplitter with no children yet 1067 // KDGanttMinimizeSplitter with no children yet
1063 maxl = QWIDGETSIZE_MAX; 1068 maxl = QWIDGETSIZE_MAX;
1064 } 1069 }
1065 } else { 1070 } else {
1066 maxl = QMIN( maxl, QWIDGETSIZE_MAX ); 1071 maxl = QMIN( maxl, QWIDGETSIZE_MAX );
1067 } 1072 }
1068 if ( maxt < mint ) 1073 if ( maxt < mint )
1069 maxt = mint; 1074 maxt = mint;
1070 1075
1071 if ( orient == Horizontal ) { 1076 if ( orient == Horizontal ) {
1072 setMaximumSize( maxl, maxt ); 1077 setMaximumSize( maxl, maxt );
1073 setMinimumSize( minl, mint ); 1078 setMinimumSize( minl, mint );
1074 } else { 1079 } else {
1075 setMaximumSize( maxt, maxl ); 1080 setMaximumSize( maxt, maxl );
1076 setMinimumSize( mint, minl ); 1081 setMinimumSize( mint, minl );
1077 } 1082 }
1078 if ( update ) 1083 if ( update )
1079 doResize(); 1084 doResize();
1080} 1085}
1081 1086
1082/*! 1087/*!
1083 Sets resize mode of \a w to \a mode. 1088 Sets resize mode of \a w to \a mode.
1084 1089
1085 \sa ResizeMode 1090 \sa ResizeMode
1086*/ 1091*/
1087 1092
1088void KDGanttMinimizeSplitter::setResizeMode( QWidget *w, ResizeMode mode ) 1093void KDGanttMinimizeSplitter::setResizeMode( QWidget *w, ResizeMode mode )
1089{ 1094{
1090 processChildEvents(); 1095 processChildEvents();
1091 QSplitterLayoutStruct *s = data->list.first(); 1096 QSplitterLayoutStruct *s = data->list.first();
1092 while ( s ) { 1097 while ( s ) {
1093 if ( s->wid == w ) { 1098 if ( s->wid == w ) {
1094 s->mode = mode; 1099 s->mode = mode;
1095 return; 1100 return;
1096 } 1101 }
1097 s = data->list.next(); 1102 s = data->list.next();
1098 } 1103 }
1099 s = addWidget( w, TRUE ); 1104 s = addWidget( w, TRUE );
1100 s->mode = mode; 1105 s->mode = mode;
1101} 1106}
1102 1107
1103 1108
1104/*! 1109/*!
1105 Returns TRUE if opaque resize is on; otherwise returns FALSE. 1110 Returns TRUE if opaque resize is on; otherwise returns FALSE.
1106 1111
1107 \sa setOpaqueResize() 1112 \sa setOpaqueResize()
1108*/ 1113*/
1109 1114
1110bool KDGanttMinimizeSplitter::opaqueResize() const 1115bool KDGanttMinimizeSplitter::opaqueResize() const
1111{ 1116{
1112 return data->opaque; 1117 return data->opaque;
1113} 1118}
1114 1119
1115 1120
1116/*! 1121/*!
1117 If \a on is TRUE then opaque resizing is turned on; otherwise 1122 If \a on is TRUE then opaque resizing is turned on; otherwise
1118 opaque resizing is turned off. 1123 opaque resizing is turned off.
1119 Opaque resizing is initially turned off. 1124 Opaque resizing is initially turned off.
1120 1125
1121 \sa opaqueResize() 1126 \sa opaqueResize()
1122*/ 1127*/
1123 1128
1124void KDGanttMinimizeSplitter::setOpaqueResize( bool on ) 1129void KDGanttMinimizeSplitter::setOpaqueResize( bool on )
1125{ 1130{
1126 data->opaque = on; 1131 data->opaque = on;
1127} 1132}
1128 1133
1129 1134
1130/*! 1135/*!
1131 Moves widget \a w to the leftmost/top position. 1136 Moves widget \a w to the leftmost/top position.
1132*/ 1137*/
1133 1138
1134void KDGanttMinimizeSplitter::moveToFirst( QWidget *w ) 1139void KDGanttMinimizeSplitter::moveToFirst( QWidget *w )
1135{ 1140{
1136 processChildEvents(); 1141 processChildEvents();
1137 bool found = FALSE; 1142 bool found = FALSE;
1138 QSplitterLayoutStruct *s = data->list.first(); 1143 QSplitterLayoutStruct *s = data->list.first();
1139 while ( s ) { 1144 while ( s ) {
1140 if ( s->wid == w ) { 1145 if ( s->wid == w ) {
1141 found = TRUE; 1146 found = TRUE;
1142 QSplitterLayoutStruct *p = data->list.prev(); 1147 QSplitterLayoutStruct *p = data->list.prev();
1143 if ( p ) { // not already at first place 1148 if ( p ) { // not already at first place
1144 data->list.take(); //take p 1149 data->list.take(); //take p
1145 data->list.take(); // take s 1150 data->list.take(); // take s
1146 data->list.insert( 0, p ); 1151 data->list.insert( 0, p );
1147 data->list.insert( 0, s ); 1152 data->list.insert( 0, s );
1148 } 1153 }
1149 break; 1154 break;
1150 } 1155 }
1151 s = data->list.next(); 1156 s = data->list.next();
1152 } 1157 }
1153 if ( !found ) 1158 if ( !found )
1154 addWidget( w, TRUE ); 1159 addWidget( w, TRUE );
1155 recalcId(); 1160 recalcId();
1156} 1161}
1157 1162
1158 1163
1159/*! 1164/*!
1160 Moves widget \a w to the rightmost/bottom position. 1165 Moves widget \a w to the rightmost/bottom position.
1161*/ 1166*/
1162 1167
1163void KDGanttMinimizeSplitter::moveToLast( QWidget *w ) 1168void KDGanttMinimizeSplitter::moveToLast( QWidget *w )
1164{ 1169{
1165 processChildEvents(); 1170 processChildEvents();
1166 bool found = FALSE; 1171 bool found = FALSE;
1167 QSplitterLayoutStruct *s = data->list.first(); 1172 QSplitterLayoutStruct *s = data->list.first();
1168 while ( s ) { 1173 while ( s ) {
1169 if ( s->wid == w ) { 1174 if ( s->wid == w ) {
1170 found = TRUE; 1175 found = TRUE;
1171 data->list.take(); // take s 1176 data->list.take(); // take s
1172 QSplitterLayoutStruct *p = data->list.current(); 1177 QSplitterLayoutStruct *p = data->list.current();
1173 if ( p ) { // the splitter handle after s 1178 if ( p ) { // the splitter handle after s
1174 data->list.take(); //take p 1179 data->list.take(); //take p
1175 data->list.append( p ); 1180 data->list.append( p );
1176 } 1181 }
1177 data->list.append( s ); 1182 data->list.append( s );
1178 break; 1183 break;
1179 } 1184 }
1180 s = data->list.next(); 1185 s = data->list.next();
1181 } 1186 }
1182 if ( !found ) 1187 if ( !found )
1183 addWidget( w); 1188 addWidget( w);
1184 recalcId(); 1189 recalcId();
1185} 1190}
1186 1191
1187 1192
1188void KDGanttMinimizeSplitter::recalcId() 1193void KDGanttMinimizeSplitter::recalcId()
1189{ 1194{
1190 int n = data->list.count(); 1195 int n = data->list.count();
1191 for ( int i = 0; i < n; i++ ) { 1196 for ( int i = 0; i < n; i++ ) {
1192 QSplitterLayoutStruct *s = data->list.at(i); 1197 QSplitterLayoutStruct *s = data->list.at(i);
1193 if ( s->isSplitter ) 1198 if ( s->isSplitter )
1194 ((KDGanttSplitterHandle*)s->wid)->setId(i); 1199 ((KDGanttSplitterHandle*)s->wid)->setId(i);
1195 } 1200 }
1196} 1201}
1197 1202
1198 1203
1199/*!\reimp 1204/*!\reimp
1200*/ 1205*/
1201QSize KDGanttMinimizeSplitter::sizeHint() const 1206QSize KDGanttMinimizeSplitter::sizeHint() const
1202{ 1207{
1203 constPolish(); 1208 constPolish();
1204 int l = 0; 1209 int l = 0;
1205 int t = 0; 1210 int t = 0;
1206 if ( children() ) { 1211 if ( children() ) {
1207 const QObjectList * c = children(); 1212 const QObjectList * c = children();
1208 QObjectListIt it( *c ); 1213 QObjectListIt it( *c );
1209 QObject * o; 1214 QObject * o;
1210 1215
1211 while( (o=it.current()) != 0 ) { 1216 while( (o=it.current()) != 0 ) {
1212 ++it; 1217 ++it;
1213 if ( o->isWidgetType() && 1218 if ( o->isWidgetType() &&
1214 !((QWidget*)o)->isHidden() ) { 1219 !((QWidget*)o)->isHidden() ) {
1215 QSize s = ((QWidget*)o)->sizeHint(); 1220 QSize s = ((QWidget*)o)->sizeHint();
1216 if ( s.isValid() ) { 1221 if ( s.isValid() ) {
1217 l += pick( s ); 1222 l += pick( s );
1218 t = QMAX( t, trans( s ) ); 1223 t = QMAX( t, trans( s ) );
1219 } 1224 }
1220 } 1225 }
1221 } 1226 }
1222 } 1227 }
1223 return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l ); 1228 return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l );
1224} 1229}
1225 1230
1226 1231
1227/*! 1232/*!
1228\reimp 1233\reimp
1229*/ 1234*/
1230 1235
1231QSize KDGanttMinimizeSplitter::minimumSizeHint() const 1236QSize KDGanttMinimizeSplitter::minimumSizeHint() const
1232{ 1237{
1233 constPolish(); 1238 constPolish();
1234 int l = 0; 1239 int l = 0;
1235 int t = 0; 1240 int t = 0;
1236 if ( children() ) { 1241 if ( children() ) {
1237 const QObjectList * c = children(); 1242 const QObjectList * c = children();
1238 QObjectListIt it( *c ); 1243 QObjectListIt it( *c );
1239 QObject * o; 1244 QObject * o;
1240 1245
1241 while( (o=it.current()) != 0 ) { 1246 while( (o=it.current()) != 0 ) {
1242 ++it; 1247 ++it;
1243 if ( o->isWidgetType() && 1248 if ( o->isWidgetType() &&
1244 !((QWidget*)o)->isHidden() ) { 1249 !((QWidget*)o)->isHidden() ) {
1245 QSize s = minSizeHint((QWidget*)o); 1250 QSize s = minSizeHint((QWidget*)o);
1246 if ( s.isValid() ) { 1251 if ( s.isValid() ) {
1247 l += pick( s ); 1252 l += pick( s );
1248 t = QMAX( t, trans( s ) ); 1253 t = QMAX( t, trans( s ) );
1249 } 1254 }
1250 } 1255 }
1251 } 1256 }
1252 } 1257 }
1253 return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l ); 1258 return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l );
1254} 1259}
1255 1260
1256 1261
1257/* 1262/*
1258 Calculates stretch parameters from current sizes 1263 Calculates stretch parameters from current sizes
1259*/ 1264*/
1260 1265
1261void KDGanttMinimizeSplitter::storeSizes() 1266void KDGanttMinimizeSplitter::storeSizes()
1262{ 1267{
1263 QSplitterLayoutStruct *s = data->list.first(); 1268 QSplitterLayoutStruct *s = data->list.first();
1264 while ( s ) { 1269 while ( s ) {
1265 if ( !s->isSplitter ) 1270 if ( !s->isSplitter )
1266 s->sizer = pick( s->wid->size() ); 1271 s->sizer = pick( s->wid->size() );
1267 s = data->list.next(); 1272 s = data->list.next();
1268 } 1273 }
1269} 1274}
1270 1275
1271 1276
1272#if 0 // ### remove this code ASAP 1277#if 0 // ### remove this code ASAP
1273 1278
1274/*! 1279/*!
1275 Hides \a w if \a hide is TRUE and updates the splitter. 1280 Hides \a w if \a hide is TRUE and updates the splitter.
1276 1281
1277 \warning Due to a limitation in the current implementation, 1282 \warning Due to a limitation in the current implementation,
1278 calling QWidget::hide() will not work. 1283 calling QWidget::hide() will not work.
1279*/ 1284*/
1280 1285
1281void KDGanttMinimizeSplitter::setHidden( QWidget *w, bool hide ) 1286void KDGanttMinimizeSplitter::setHidden( QWidget *w, bool hide )
1282{ 1287{
1283 if ( w == w1 ) { 1288 if ( w == w1 ) {
1284 w1show = !hide; 1289 w1show = !hide;
1285 } else if ( w == w2 ) { 1290 } else if ( w == w2 ) {
1286 w2show = !hide; 1291 w2show = !hide;
1287 } else { 1292 } else {
1288#ifdef QT_CHECK_RANGE 1293#ifdef QT_CHECK_RANGE
1289 qWarning( "KDGanttMinimizeSplitter::setHidden(), unknown widget" ); 1294 qWarning( "KDGanttMinimizeSplitter::setHidden(), unknown widget" );
1290#endif 1295#endif
1291 return; 1296 return;
1292 } 1297 }
1293 if ( hide ) 1298 if ( hide )
1294 w->hide(); 1299 w->hide();
1295 else 1300 else
1296 w->show(); 1301 w->show();
1297 recalc( TRUE ); 1302 recalc( TRUE );
1298} 1303}
1299 1304
1300 1305
1301/*! 1306/*!
1302 Returns the hidden status of \a w 1307 Returns the hidden status of \a w
1303*/ 1308*/
1304 1309
1305bool KDGanttMinimizeSplitter::isHidden( QWidget *w ) const 1310bool KDGanttMinimizeSplitter::isHidden( QWidget *w ) const
1306{ 1311{
1307 if ( w == w1 ) 1312 if ( w == w1 )
1308 return !w1show; 1313 return !w1show;
1309 else if ( w == w2 ) 1314 else if ( w == w2 )
1310 return !w2show; 1315 return !w2show;
1311#ifdef QT_CHECK_RANGE 1316#ifdef QT_CHECK_RANGE
1312 else 1317 else
1313 qWarning( "KDGanttMinimizeSplitter::isHidden(), unknown widget" ); 1318 qWarning( "KDGanttMinimizeSplitter::isHidden(), unknown widget" );
1314#endif 1319#endif
1315 return FALSE; 1320 return FALSE;
1316} 1321}
1317#endif 1322#endif
1318 1323
1319 1324
1320/*! 1325/*!
1321 Returns a list of the size parameters of all the widgets in this 1326 Returns a list of the size parameters of all the widgets in this
1322 splitter. 1327 splitter.
1323 1328
1324 Giving the values to another splitter's setSizes() function will 1329 Giving the values to another splitter's setSizes() function will
1325 produce a splitter with the same layout as this one. 1330 produce a splitter with the same layout as this one.
1326 1331
1327 Note that if you want to iterate over the list, you should 1332 Note that if you want to iterate over the list, you should
1328 iterate over a copy, e.g. 1333 iterate over a copy, e.g.
1329 \code 1334 \code
1330 QValueList<int> list = mySplitter.sizes(); 1335 QValueList<int> list = mySplitter.sizes();
1331 QValueList<int>::Iterator it = list.begin(); 1336 QValueList<int>::Iterator it = list.begin();
1332 while( it != list.end() ) { 1337 while( it != list.end() ) {
1333 myProcessing( *it ); 1338 myProcessing( *it );
1334 ++it; 1339 ++it;
1335 } 1340 }
1336 \endcode 1341 \endcode
1337 1342
1338 \sa setSizes() 1343 \sa setSizes()
1339*/ 1344*/
1340 1345
1341QValueList<int> KDGanttMinimizeSplitter::sizes() const 1346QValueList<int> KDGanttMinimizeSplitter::sizes() const
1342{ 1347{
1343 if ( !testWState(WState_Polished) ) { 1348 if ( !testWState(WState_Polished) ) {
1344 QWidget* that = (QWidget*) this; 1349 QWidget* that = (QWidget*) this;
1345 that->polish(); 1350 that->polish();
1346 } 1351 }
1347 QValueList<int> list; 1352 QValueList<int> list;
1348 QSplitterLayoutStruct *s = data->list.first(); 1353 QSplitterLayoutStruct *s = data->list.first();
1349 while ( s ) { 1354 while ( s ) {
1350 if ( !s->isSplitter ) 1355 if ( !s->isSplitter )
1351 list.append( s->sizer ); 1356 list.append( s->sizer );
1352 s = data->list.next(); 1357 s = data->list.next();
1353 } 1358 }
1354 return list; 1359 return list;
1355} 1360}
1356 1361
1357 1362
1358 1363
1359/*! 1364/*!
1360 Sets the size parameters to the values given in \a list. 1365 Sets the size parameters to the values given in \a list.
1361 If the splitter is horizontal, the values set the sizes from 1366 If the splitter is horizontal, the values set the sizes from
1362 left to right. If it is vertical, the sizes are applied from 1367 left to right. If it is vertical, the sizes are applied from
1363 top to bottom. 1368 top to bottom.
1364 Extra values in \a list are ignored. 1369 Extra values in \a list are ignored.
1365 1370
1366 If \a list contains too few values, the result is undefined 1371 If \a list contains too few values, the result is undefined
1367 but the program will still be well-behaved. 1372 but the program will still be well-behaved.
1368 1373
1369 \sa sizes() 1374 \sa sizes()
1370*/ 1375*/
1371 1376
1372void KDGanttMinimizeSplitter::setSizes( QValueList<int> list ) 1377void KDGanttMinimizeSplitter::setSizes( QValueList<int> list )
1373{ 1378{
1374 processChildEvents(); 1379 processChildEvents();
1375 QValueList<int>::Iterator it = list.begin(); 1380 QValueList<int>::Iterator it = list.begin();
1376 QSplitterLayoutStruct *s = data->list.first(); 1381 QSplitterLayoutStruct *s = data->list.first();
1377 while ( s && it != list.end() ) { 1382 while ( s && it != list.end() ) {
1378 if ( !s->isSplitter ) { 1383 if ( !s->isSplitter ) {
1379 s->sizer = *it; 1384 s->sizer = *it;
1380 ++it; 1385 ++it;
1381 } 1386 }
1382 s = data->list.next(); 1387 s = data->list.next();
1383 } 1388 }
1384 doResize(); 1389 doResize();
1385} 1390}
1386 1391
1387 1392
1388/*! 1393/*!
1389 Gets all posted child events, ensuring that the internal state of 1394 Gets all posted child events, ensuring that the internal state of
1390 the splitter is consistent. 1395 the splitter is consistent.
1391*/ 1396*/
1392 1397
1393void KDGanttMinimizeSplitter::processChildEvents() 1398void KDGanttMinimizeSplitter::processChildEvents()
1394{ 1399{
1395 QApplication::sendPostedEvents( this, QEvent::ChildInserted ); 1400 QApplication::sendPostedEvents( this, QEvent::ChildInserted );
1396} 1401}
1397 1402
1398 1403
1399/*! 1404/*!
1400 \reimp 1405 \reimp
1401*/ 1406*/
1402 1407
1403void KDGanttMinimizeSplitter::styleChange( QStyle& old ) 1408void KDGanttMinimizeSplitter::styleChange( QStyle& old )
1404{ 1409{
1405 1410
1406#if QT_VERSION >= 0x030000 1411#if QT_VERSION >= 0x030000
1407 int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); 1412 int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this);
1408#else 1413#else
1409 int sw = style().splitterWidth(); 1414 int sw = style().splitterWidth();
1410#endif 1415#endif
1411 QSplitterLayoutStruct *s = data->list.first(); 1416 QSplitterLayoutStruct *s = data->list.first();
1412 while ( s ) { 1417 while ( s ) {
1413 if ( s->isSplitter ) 1418 if ( s->isSplitter )
1414 s->sizer = sw; 1419 s->sizer = sw;
1415 s = data->list.next(); 1420 s = data->list.next();
1416 } 1421 }
1417 doResize(); 1422 doResize();
1418 QFrame::styleChange( old ); 1423 QFrame::styleChange( old );
1419} 1424}
1420 1425
1421#endif 1426#endif
1422 1427
1423/*! 1428/*!
1424 Specifies the direction of the minimize buttons. 1429 Specifies the direction of the minimize buttons.
1425 If the orientation of the splitter is horizontal then with 1430 If the orientation of the splitter is horizontal then with
1426 KDGanttMinimizeSplitter::Left or KDGanttMinimizeSplitter::Right should be used, 1431 KDGanttMinimizeSplitter::Left or KDGanttMinimizeSplitter::Right should be used,
1427 otherwise either KDGanttMinimizeSplitter::Up or KDGanttMinimizeSplitter::Down 1432 otherwise either KDGanttMinimizeSplitter::Up or KDGanttMinimizeSplitter::Down
1428 should be used. 1433 should be used.
1429*/ 1434*/
1430void KDGanttMinimizeSplitter::setMinimizeDirection( Direction direction ) 1435void KDGanttMinimizeSplitter::setMinimizeDirection( Direction direction )
1431{ 1436{
1432 _direction = direction; 1437 _direction = direction;
1433} 1438}
1434 1439
1435/*! 1440/*!
1436 Returns the direction of the minimize buttons. 1441 Returns the direction of the minimize buttons.
1437*/ 1442*/
1438KDGanttMinimizeSplitter::Direction KDGanttMinimizeSplitter::minimizeDirection() const 1443KDGanttMinimizeSplitter::Direction KDGanttMinimizeSplitter::minimizeDirection() const
1439{ 1444{
1440 return _direction; 1445 return _direction;
1441} 1446}
1442 1447
1443/* 1448/*
1444 This is a copy of qGeomCalc() in qlayoutengine.cpp which 1449 This is a copy of qGeomCalc() in qlayoutengine.cpp which
1445 unfortunately isn't exported. 1450 unfortunately isn't exported.
1446*/ 1451*/
1447static inline int toFixed( int i ) { return i * 256; } 1452static inline int toFixed( int i ) { return i * 256; }
1448static inline int fRound( int i ) { 1453static inline int fRound( int i ) {
1449 return ( i % 256 < 128 ) ? i / 256 : 1 + i / 256; 1454 return ( i % 256 < 128 ) ? i / 256 : 1 + i / 256;
1450} 1455}
1451void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos, 1456void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos,
1452 int space, int spacer ) 1457 int space, int spacer )
1453{ 1458{
1454 typedef int fixed; 1459 typedef int fixed;
1455 int cHint = 0; 1460 int cHint = 0;
1456 int cMin = 0; 1461 int cMin = 0;
1457 int cMax = 0; 1462 int cMax = 0;
1458 int sumStretch = 0; 1463 int sumStretch = 0;
1459 int spacerCount = 0; 1464 int spacerCount = 0;
1460 1465
1461 bool wannaGrow = FALSE; // anyone who really wants to grow? 1466 bool wannaGrow = FALSE; // anyone who really wants to grow?
1462 // bool canShrink = FALSE; // anyone who could be persuaded to shrink? 1467 // bool canShrink = FALSE; // anyone who could be persuaded to shrink?
1463 1468
1464 int i; 1469 int i;
1465 for ( i = start; i < start + count; i++ ) { 1470 for ( i = start; i < start + count; i++ ) {
1466 chain[i].done = FALSE; 1471 chain[i].done = FALSE;
1467 cHint += chain[i].sizeHint; 1472 cHint += chain[i].sizeHint;
1468 cMin += chain[i].minimumSize; 1473 cMin += chain[i].minimumSize;
1469 cMax += chain[i].maximumSize; 1474 cMax += chain[i].maximumSize;
1470 sumStretch += chain[i].stretch; 1475 sumStretch += chain[i].stretch;
1471 if ( !chain[i].empty ) 1476 if ( !chain[i].empty )
1472 spacerCount++; 1477 spacerCount++;
1473 wannaGrow = wannaGrow || chain[i].expansive; 1478 wannaGrow = wannaGrow || chain[i].expansive;
1474 } 1479 }
1475 1480
1476 int extraspace = 0; 1481 int extraspace = 0;
1477 if ( spacerCount ) 1482 if ( spacerCount )
1478 spacerCount--; // only spacers between things 1483 spacerCount--; // only spacers between things
1479 if ( space < cMin + spacerCount * spacer ) { 1484 if ( space < cMin + spacerCount * spacer ) {
1480 //qDebug("not enough space"); 1485 //qDebug("not enough space");
1481 for ( i = start; i < start+count; i++ ) { 1486 for ( i = start; i < start+count; i++ ) {
1482 chain[i].size = chain[i].minimumSize; 1487 chain[i].size = chain[i].minimumSize;
1483 chain[i].done = TRUE; 1488 chain[i].done = TRUE;
1484 } 1489 }
1485 } else if ( space < cHint + spacerCount*spacer ) { 1490 } else if ( space < cHint + spacerCount*spacer ) {
1486 // Less space than sizeHint, but more than minimum. 1491 // Less space than sizeHint, but more than minimum.
1487 // Currently take space equally from each, like in Qt 2.x. 1492 // Currently take space equally from each, like in Qt 2.x.
1488 // Commented-out lines will give more space to stretchier items. 1493 // Commented-out lines will give more space to stretchier items.
1489 int n = count; 1494 int n = count;
1490 int space_left = space - spacerCount*spacer; 1495 int space_left = space - spacerCount*spacer;
1491 int overdraft = cHint - space_left; 1496 int overdraft = cHint - space_left;
1492 //first give to the fixed ones: 1497 //first give to the fixed ones:
1493 for ( i = start; i < start+count; i++ ) { 1498 for ( i = start; i < start+count; i++ ) {
1494 if ( !chain[i].done && chain[i].minimumSize >= chain[i].sizeHint) { 1499 if ( !chain[i].done && chain[i].minimumSize >= chain[i].sizeHint) {
1495 chain[i].size = chain[i].sizeHint; 1500 chain[i].size = chain[i].sizeHint;
1496 chain[i].done = TRUE; 1501 chain[i].done = TRUE;
1497 space_left -= chain[i].sizeHint; 1502 space_left -= chain[i].sizeHint;
1498 // sumStretch -= chain[i].stretch; 1503 // sumStretch -= chain[i].stretch;
1499 n--; 1504 n--;
1500 } 1505 }
1501 } 1506 }
1502 bool finished = n == 0; 1507 bool finished = n == 0;
1503 while ( !finished ) { 1508 while ( !finished ) {
1504 finished = TRUE; 1509 finished = TRUE;
1505 fixed fp_over = toFixed( overdraft ); 1510 fixed fp_over = toFixed( overdraft );
1506 fixed fp_w = 0; 1511 fixed fp_w = 0;
1507 1512
1508 for ( i = start; i < start+count; i++ ) { 1513 for ( i = start; i < start+count; i++ ) {
1509 if ( chain[i].done ) 1514 if ( chain[i].done )
diff --git a/microkde/kapplication.cpp b/microkde/kapplication.cpp
index f05b91b..80a83e0 100644
--- a/microkde/kapplication.cpp
+++ b/microkde/kapplication.cpp
@@ -1,111 +1,126 @@
1#include <stdlib.h> 1#include <stdlib.h>
2#include <stdio.h> 2#include <stdio.h>
3 3
4#include "kapplication.h" 4#include "kapplication.h"
5#include "ktextedit.h" 5#include "ktextedit.h"
6#include <qapplication.h> 6#include <qapplication.h>
7#include <qstring.h> 7#include <qstring.h>
8#include <qfile.h> 8#include <qfile.h>
9#include <qtextstream.h> 9#include <qtextstream.h>
10#include <qdialog.h> 10#include <qdialog.h>
11#include <qlayout.h> 11#include <qlayout.h>
12#include <qtextbrowser.h> 12#include <qtextbrowser.h>
13 13
14int KApplication::random() 14int KApplication::random()
15{ 15{
16 return rand(); 16 return rand();
17} 17}
18 18
19//US 19//US
20QString KApplication::randomString(int length) 20QString KApplication::randomString(int length)
21{ 21{
22 if (length <=0 ) return QString::null; 22 if (length <=0 ) return QString::null;
23 23
24 QString str; 24 QString str;
25 while (length--) 25 while (length--)
26 { 26 {
27 int r=random() % 62; 27 int r=random() % 62;
28 r+=48; 28 r+=48;
29 if (r>57) r+=7; 29 if (r>57) r+=7;
30 if (r>90) r+=6; 30 if (r>90) r+=6;
31 str += char(r); 31 str += char(r);
32 // so what if I work backwards? 32 // so what if I work backwards?
33 } 33 }
34 return str; 34 return str;
35} 35}
36int KApplication::execDialog( QDialog* d ) 36int KApplication::execDialog( QDialog* d )
37{ 37{
38 if (QApplication::desktop()->width() <= 640 ) 38 if (QApplication::desktop()->width() <= 640 )
39 d->showMaximized(); 39 d->showMaximized();
40 else 40 else
41 ;//d->resize( 800, 600 ); 41 ;//d->resize( 800, 600 );
42 return d->exec(); 42 return d->exec();
43} 43}
44void KApplication::showLicence() 44void KApplication::showLicence()
45{ 45{
46 KApplication::showFile( "KDE-Pim/Pi licence", "kdepim/licence.txt" ); 46 KApplication::showFile( "KDE-Pim/Pi licence", "kdepim/licence.txt" );
47} 47}
48 48
49void KApplication::testCoords( int* x, int* y, int* wid, int * hei )
50{
51 int dWid = QApplication::desktop()->width() ;
52 int dHei = QApplication::desktop()->height();
53 if ( *x + *wid > dWid ) {
54 *x = 0;
55 if ( *wid > dWid )
56 *wid = dWid;
57 }
58 if ( *y + *hei > dHei ) {
59 *y = 0;
60 if ( *hei > dHei )
61 *hei = dHei;
62 }
63}
49void KApplication::showFile(QString caption, QString fn) 64void KApplication::showFile(QString caption, QString fn)
50{ 65{
51 QString text; 66 QString text;
52 QString fileName; 67 QString fileName;
53#ifndef DESKTOP_VERSION 68#ifndef DESKTOP_VERSION
54 fileName = getenv("QPEDIR"); 69 fileName = getenv("QPEDIR");
55 fileName += "/pics/" + fn ; 70 fileName += "/pics/" + fn ;
56#else 71#else
57 fileName = qApp->applicationDirPath () + "/" + fn; 72 fileName = qApp->applicationDirPath () + "/" + fn;
58#endif 73#endif
59 QFile file( fileName ); 74 QFile file( fileName );
60 if (!file.open( IO_ReadOnly ) ) { 75 if (!file.open( IO_ReadOnly ) ) {
61 return ; 76 return ;
62 } 77 }
63 QTextStream ts( &file ); 78 QTextStream ts( &file );
64 text = ts.read(); 79 text = ts.read();
65 file.close(); 80 file.close();
66 KApplication::showText( caption, text ); 81 KApplication::showText( caption, text );
67 82
68} 83}
69 84
70bool KApplication::convert2latin1(QString fileName) 85bool KApplication::convert2latin1(QString fileName)
71{ 86{
72 QString text; 87 QString text;
73 QFile file( fileName ); 88 QFile file( fileName );
74 if (!file.open( IO_ReadOnly ) ) { 89 if (!file.open( IO_ReadOnly ) ) {
75 return false; 90 return false;
76 91
77 } 92 }
78 QTextStream ts( &file ); 93 QTextStream ts( &file );
79 ts.setEncoding( QTextStream::UnicodeUTF8 ); 94 ts.setEncoding( QTextStream::UnicodeUTF8 );
80 text = ts.read(); 95 text = ts.read();
81 file.close(); 96 file.close();
82 if (!file.open( IO_WriteOnly ) ) { 97 if (!file.open( IO_WriteOnly ) ) {
83 return false; 98 return false;
84 } 99 }
85 QTextStream tsIn( &file ); 100 QTextStream tsIn( &file );
86 tsIn.setEncoding( QTextStream::Latin1 ); 101 tsIn.setEncoding( QTextStream::Latin1 );
87 tsIn << text.latin1(); 102 tsIn << text.latin1();
88 file.close(); 103 file.close();
89 return true; 104 return true;
90 105
91 106
92} 107}
93void KApplication::showText(QString caption, QString text) 108void KApplication::showText(QString caption, QString text)
94{ 109{
95 QDialog dia( 0, "name", true ); ; 110 QDialog dia( 0, "name", true ); ;
96 dia.setCaption( caption ); 111 dia.setCaption( caption );
97 QVBoxLayout* lay = new QVBoxLayout( &dia ); 112 QVBoxLayout* lay = new QVBoxLayout( &dia );
98 lay->setSpacing( 3 ); 113 lay->setSpacing( 3 );
99 lay->setMargin( 3 ); 114 lay->setMargin( 3 );
100 KTextEdit tb ( &dia ); 115 KTextEdit tb ( &dia );
101 tb.setWordWrap( QMultiLineEdit::WidgetWidth ); 116 tb.setWordWrap( QMultiLineEdit::WidgetWidth );
102 lay->addWidget( &tb ); 117 lay->addWidget( &tb );
103 tb.setText( text ); 118 tb.setText( text );
104#ifdef DESKTOP_VERSION 119#ifdef DESKTOP_VERSION
105 dia.resize( 640, 480); 120 dia.resize( 640, 480);
106#else 121#else
107 dia.showMaximized(); 122 dia.showMaximized();
108#endif 123#endif
109 dia.exec(); 124 dia.exec();
110 125
111} 126}
diff --git a/microkde/kapplication.h b/microkde/kapplication.h
index 497ec2f..f7eb1ef 100644
--- a/microkde/kapplication.h
+++ b/microkde/kapplication.h
@@ -1,30 +1,31 @@
1#ifndef MINIKDE_KAPPLICATION_H 1#ifndef MINIKDE_KAPPLICATION_H
2#define MINIKDE_KAPPLICATION_H 2#define MINIKDE_KAPPLICATION_H
3 3
4#include "qstring.h" 4#include "qstring.h"
5#include <qdialog.h> 5#include <qdialog.h>
6#ifdef QDialog 6#ifdef QDialog
7#undef QDialog 7#undef QDialog
8#endif 8#endif
9 9
10class KApplication 10class KApplication
11{ 11{
12 public: 12 public:
13 static int random(); 13 static int random();
14 14
15//US 15//US
16 /** 16 /**
17 * Generates a random string. It operates in the range [A-Za-z0-9] 17 * Generates a random string. It operates in the range [A-Za-z0-9]
18 * @param length Generate a string of this length. 18 * @param length Generate a string of this length.
19 * @return the random string 19 * @return the random string
20 */ 20 */
21 static QString randomString(int length); 21 static QString randomString(int length);
22 static int execDialog( QDialog* ); 22 static int execDialog( QDialog* );
23 static void showLicence(); 23 static void showLicence();
24 static void testCoords( int* x, int* y, int* wid, int * hei );
24 static void showFile(QString caption, QString file); 25 static void showFile(QString caption, QString file);
25 static void showText(QString caption, QString text); 26 static void showText(QString caption, QString text);
26 static bool convert2latin1(QString file); 27 static bool convert2latin1(QString file);
27}; 28};
28 29
29 30
30#endif 31#endif
diff --git a/microkde/kresources/factory.cpp b/microkde/kresources/factory.cpp
index 3d1889f..a3b7fff 100644
--- a/microkde/kresources/factory.cpp
+++ b/microkde/kresources/factory.cpp
@@ -1,256 +1,256 @@
1/* 1/*
2 This file is part of libkresources. 2 This file is part of libkresources.
3 3
4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version. 11 version 2 of the License, or (at your option) any later version.
12 12
13 This library is distributed in the hope that it will be useful, 13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details. 16 Library General Public License for more details.
17 17
18 You should have received a copy of the GNU Library General Public License 18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to 19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. 21 Boston, MA 02111-1307, USA.
22*/ 22*/
23 23
24#include <kdebug.h> 24#include <kdebug.h>
25#include <klocale.h> 25#include <klocale.h>
26#include <ksimpleconfig.h> 26#include <ksimpleconfig.h>
27#include <kstandarddirs.h> 27#include <kstandarddirs.h>
28#include <kstaticdeleter.h> 28#include <kstaticdeleter.h>
29//#ifndef DESKTOP_VERSION 29//#ifndef DESKTOP_VERSION
30#include <klibloader.h> 30#include <klibloader.h>
31//#endif 31//#endif
32#include <qfile.h> 32#include <qfile.h>
33 33
34#include "resource.h" 34#include "resource.h"
35#include "factory.h" 35#include "factory.h"
36 36
37using namespace KRES; 37using namespace KRES;
38 38
39QDict<Factory> *Factory::mSelves = 0; 39QDict<Factory> *Factory::mSelves = 0;
40static KStaticDeleter< QDict<Factory> > staticDeleter; 40static KStaticDeleter< QDict<Factory> > staticDeleter;
41 41
42Factory *Factory::self( const QString& resourceFamily) 42Factory *Factory::self( const QString& resourceFamily)
43{ 43{
44 44
45 45
46 Factory *factory = 0; 46 Factory *factory = 0;
47 if ( !mSelves ) 47 if ( !mSelves )
48 { 48 {
49 mSelves = staticDeleter.setObject( new QDict<Factory> ); 49 mSelves = staticDeleter.setObject( new QDict<Factory> );
50 } 50 }
51 51
52 factory = mSelves->find( resourceFamily ); 52 factory = mSelves->find( resourceFamily );
53 53
54 if ( !factory ) { 54 if ( !factory ) {
55 factory = new Factory( resourceFamily); 55 factory = new Factory( resourceFamily);
56 mSelves->insert( resourceFamily, factory ); 56 mSelves->insert( resourceFamily, factory );
57 } 57 }
58 58
59 return factory; 59 return factory;
60} 60}
61 61
62Factory::Factory( const QString& resourceFamily) : 62Factory::Factory( const QString& resourceFamily) :
63 mResourceFamily( resourceFamily ) 63 mResourceFamily( resourceFamily )
64{ 64{
65//US so far we have three types available for resourceFamily "contact" 65//US so far we have three types available for resourceFamily "contact"
66// and that are "file", "dir", "ldap" 66// and that are "file", "dir", "ldap"
67/*US 67/*US
68 68
69 KTrader::OfferList plugins = KTrader::self()->query( "KResources/Plugin", QString( "[X-KDE-ResourceFamily] == '%1'" ) 69 KTrader::OfferList plugins = KTrader::self()->query( "KResources/Plugin", QString( "[X-KDE-ResourceFamily] == '%1'" )
70 .arg( resourceFamily ) ); 70 .arg( resourceFamily ) );
71 KTrader::OfferList::ConstIterator it; 71 KTrader::OfferList::ConstIterator it;
72 for ( it = plugins.begin(); it != plugins.end(); ++it ) { 72 for ( it = plugins.begin(); it != plugins.end(); ++it ) {
73 QVariant type = (*it)->property( "X-KDE-ResourceType" ); 73 QVariant type = (*it)->property( "X-KDE-ResourceType" );
74 if ( !type.toString().isEmpty() ) 74 if ( !type.toString().isEmpty() )
75 mTypeMap.insert( type.toString(), *it ); 75 mTypeMap.insert( type.toString(), *it );
76 } 76 }
77*/ 77*/
78 78
79//US new 79//US new
80 PluginInfo* info = new PluginInfo; 80 PluginInfo* info = new PluginInfo;
81 info->library = "microkabc_file"; 81 info->library = "microkabc_file";
82 info->nameLabel = i18n( "file" ); 82 info->nameLabel = i18n( "file" );
83 info->descriptionLabel = i18n( "Choose one file" ); 83 info->descriptionLabel = i18n( "One file" );
84 mTypeMap.insert( "file", info ); 84 mTypeMap.insert( "file", info );
85 85
86 info = new PluginInfo; 86 info = new PluginInfo;
87 info->library = "microkabc_dir"; 87 info->library = "microkabc_dir";
88 info->nameLabel = i18n( "dir" ); 88 info->nameLabel = i18n( "dir" );
89 info->descriptionLabel = i18n( "Choose a directory with may files" ); 89 info->descriptionLabel = i18n( "A directory with many files" );
90 mTypeMap.insert( "dir", info ); 90 mTypeMap.insert( "dir", info );
91 91
92 info = new PluginInfo; 92 info = new PluginInfo;
93 info->library = "microkabc_ldap"; 93 info->library = "microkabc_ldap";
94 info->nameLabel = i18n( "ldap" ); 94 info->nameLabel = i18n( "ldap" );
95 info->descriptionLabel = i18n( "No description available" ); 95 info->descriptionLabel = i18n( "Connect to a directory server" );
96 mTypeMap.insert( "ldap", info ); 96 mTypeMap.insert( "ldap", info );
97 97
98 //US add opie plugin only, if the library exists. 98 //US add opie plugin only, if the library exists.
99 /*US 99 /*US
100 QString libname = "microkabc_opie"; 100 QString libname = "microkabc_opie";
101 QString path = KLibLoader::findLibrary( QFile::encodeName( libname ) ); 101 QString path = KLibLoader::findLibrary( QFile::encodeName( libname ) );
102 if ( !path.isEmpty() ) 102 if ( !path.isEmpty() )
103 { 103 {
104 info = new PluginInfo; 104 info = new PluginInfo;
105 info->library = libname; 105 info->library = libname;
106 info->nameLabel = i18n( "opie" ); 106 info->nameLabel = i18n( "opie" );
107 info->descriptionLabel = i18n( "Opie PIM Addressbook." ); 107 info->descriptionLabel = i18n( "Opie PIM Addressbook." );
108 mTypeMap.insert( "opie", info ); 108 mTypeMap.insert( "opie", info );
109 } 109 }
110 */ 110 */
111 //US add qtopia plugin only, if the library exists. 111 //US add qtopia plugin only, if the library exists.
112 QString libname = "microkabc_qtopia"; 112 QString libname = "microkabc_qtopia";
113 QString path = KLibLoader::findLibrary( QFile::encodeName( libname ) ); 113 QString path = KLibLoader::findLibrary( QFile::encodeName( libname ) );
114 if ( !path.isEmpty() ) 114 if ( !path.isEmpty() )
115 { 115 {
116 info = new PluginInfo; 116 info = new PluginInfo;
117 info->library = libname; 117 info->library = libname;
118 info->nameLabel = i18n( "qtopia" ); 118 info->nameLabel = i18n( "qtopia" );
119 info->descriptionLabel = i18n( "Qtopia PIM Addressbook." ); 119 info->descriptionLabel = i18n( "Qtopia PIM Addressbook." );
120 mTypeMap.insert( "qtopia", info ); 120 mTypeMap.insert( "qtopia", info );
121 } 121 }
122 122
123 //US add sharp plugin only, if the library exists. 123 //US add sharp plugin only, if the library exists.
124 libname = "microkabc_sharpdtm"; 124 libname = "microkabc_sharpdtm";
125 path = KLibLoader::findLibrary( QFile::encodeName( libname ) ); 125 path = KLibLoader::findLibrary( QFile::encodeName( libname ) );
126 if ( !path.isEmpty() ) 126 if ( !path.isEmpty() )
127 { 127 {
128 info = new PluginInfo; 128 info = new PluginInfo;
129 info->library = libname; 129 info->library = libname;
130 info->nameLabel = i18n( "sharp" ); 130 info->nameLabel = i18n( "sharp" );
131 info->descriptionLabel = i18n( "Sharp DTM Addressbook." ); 131 info->descriptionLabel = i18n( "Sharp DTM Addressbook." );
132 mTypeMap.insert( "sharp", info ); 132 mTypeMap.insert( "sharp", info );
133 } 133 }
134 134
135 135
136} 136}
137 137
138Factory::~Factory() 138Factory::~Factory()
139{ 139{
140} 140}
141 141
142QStringList Factory::typeNames() const 142QStringList Factory::typeNames() const
143{ 143{
144//US method QMap::keys() not available yet. SO collect the data manually 144//US method QMap::keys() not available yet. SO collect the data manually
145//US return mTypeMap.keys(); 145//US return mTypeMap.keys();
146 146
147 QStringList result; 147 QStringList result;
148 148
149 QMap<QString, PluginInfo*>::ConstIterator it; 149 QMap<QString, PluginInfo*>::ConstIterator it;
150 for( it = mTypeMap.begin(); it != mTypeMap.end(); ++it ) { 150 for( it = mTypeMap.begin(); it != mTypeMap.end(); ++it ) {
151 result << it.key().latin1(); 151 result << it.key().latin1();
152// qDebug("Factory::typeNames() : %s ", it.key().latin1()); 152// qDebug("Factory::typeNames() : %s ", it.key().latin1());
153 153
154 } 154 }
155 return result; 155 return result;
156} 156}
157 157
158ConfigWidget *Factory::configWidget( const QString& type, QWidget *parent ) 158ConfigWidget *Factory::configWidget( const QString& type, QWidget *parent )
159{ 159{
160 if ( type.isEmpty() || !mTypeMap.contains( type ) ) 160 if ( type.isEmpty() || !mTypeMap.contains( type ) )
161 return 0; 161 return 0;
162 162
163//US KService::Ptr ptr = mTypeMap[ type ]; 163//US KService::Ptr ptr = mTypeMap[ type ];
164//US KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() ); 164//US KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() );
165 PluginInfo* pi = mTypeMap[ type ]; 165 PluginInfo* pi = mTypeMap[ type ];
166 KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() ); 166 KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() );
167 if ( !factory ) { 167 if ( !factory ) {
168 qDebug("KRES::Factory::configWidget(): Factory creation failed for library %s", pi->library.latin1()); 168 qDebug("KRES::Factory::configWidget(): Factory creation failed for library %s", pi->library.latin1());
169 kdDebug() << "KRES::Factory::configWidget(): Factory creation failed" << endl; 169 kdDebug() << "KRES::Factory::configWidget(): Factory creation failed" << endl;
170 return 0; 170 return 0;
171 } 171 }
172 172
173 PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory ); 173 PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory );
174 174
175 if ( !pluginFactory ) { 175 if ( !pluginFactory ) {
176 qDebug("KRES::Factory::configWidget(): no plugin factory for library %s", pi->library.latin1()); 176 qDebug("KRES::Factory::configWidget(): no plugin factory for library %s", pi->library.latin1());
177 kdDebug() << "KRES::Factory::configWidget(): no plugin factory." << endl; 177 kdDebug() << "KRES::Factory::configWidget(): no plugin factory." << endl;
178 return 0; 178 return 0;
179 } 179 }
180 180
181 ConfigWidget *wdg = pluginFactory->configWidget( parent ); 181 ConfigWidget *wdg = pluginFactory->configWidget( parent );
182 if ( !wdg ) { 182 if ( !wdg ) {
183//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl; 183//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl;
184 qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1()); 184 qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1());
185 return 0; 185 return 0;
186 } 186 }
187 return wdg; 187 return wdg;
188 188
189} 189}
190 190
191QString Factory::typeName( const QString &type ) const 191QString Factory::typeName( const QString &type ) const
192{ 192{
193 if ( type.isEmpty() || !mTypeMap.contains( type ) ) 193 if ( type.isEmpty() || !mTypeMap.contains( type ) )
194 return QString(); 194 return QString();
195 195
196 196
197//US KService::Ptr ptr = mTypeMap[ type ]; 197//US KService::Ptr ptr = mTypeMap[ type ];
198//US return ptr->name(); 198//US return ptr->name();
199 PluginInfo* pi = mTypeMap[ type ]; 199 PluginInfo* pi = mTypeMap[ type ];
200 return pi->nameLabel; 200 return pi->nameLabel;
201 201
202} 202}
203 203
204QString Factory::typeDescription( const QString &type ) const 204QString Factory::typeDescription( const QString &type ) const
205{ 205{
206 if ( type.isEmpty() || !mTypeMap.contains( type ) ) 206 if ( type.isEmpty() || !mTypeMap.contains( type ) )
207 return QString(); 207 return QString();
208 208
209//US KService::Ptr ptr = mTypeMap[ type ]; 209//US KService::Ptr ptr = mTypeMap[ type ];
210//US return ptr->comment(); 210//US return ptr->comment();
211 PluginInfo* pi = mTypeMap[ type ]; 211 PluginInfo* pi = mTypeMap[ type ];
212 return pi->descriptionLabel; 212 return pi->descriptionLabel;
213} 213}
214 214
215Resource *Factory::resource( const QString& type, const KConfig *config ) 215Resource *Factory::resource( const QString& type, const KConfig *config )
216{ 216{
217 217
218 218
219 if ( type.isEmpty() || !mTypeMap.contains( type ) ) 219 if ( type.isEmpty() || !mTypeMap.contains( type ) )
220 return 0; 220 return 0;
221 221
222/*US load the lib not dynamicly. !! 222/*US load the lib not dynamicly. !!
223 KService::Ptr ptr = mTypeMap[ type ]; 223 KService::Ptr ptr = mTypeMap[ type ];
224 KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() ); 224 KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() );
225 if ( !factory ) { 225 if ( !factory ) {
226 kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl; 226 kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl;
227 return 0; 227 return 0;
228 } 228 }
229*/ 229*/
230 PluginInfo* pi = mTypeMap[ type ]; 230 PluginInfo* pi = mTypeMap[ type ];
231 KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() ); 231 KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() );
232 if ( !factory ) { 232 if ( !factory ) {
233 qDebug("KRES::Factory::resource(): Factory creation failed for library %s", pi->library.latin1()); 233 qDebug("KRES::Factory::resource(): Factory creation failed for library %s", pi->library.latin1());
234 kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl; 234 kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl;
235 return 0; 235 return 0;
236 } 236 }
237 237
238 PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory ); 238 PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory );
239 239
240 if ( !pluginFactory ) { 240 if ( !pluginFactory ) {
241 qDebug("KRES::Factory::resource(): no plugin factory for library %s", pi->library.latin1()); 241 qDebug("KRES::Factory::resource(): no plugin factory for library %s", pi->library.latin1());
242 kdDebug() << "KRES::Factory::resource(): no plugin factory." << endl; 242 kdDebug() << "KRES::Factory::resource(): no plugin factory." << endl;
243 return 0; 243 return 0;
244 } 244 }
245 245
246 Resource *resource = pluginFactory->resource( config ); 246 Resource *resource = pluginFactory->resource( config );
247 if ( !resource ) { 247 if ( !resource ) {
248//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl; 248//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl;
249 qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1()); 249 qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1());
250 return 0; 250 return 0;
251 } 251 }
252 252
253 resource->setType( type ); 253 resource->setType( type );
254 254
255 return resource; 255 return resource;
256} 256}