summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-06-07 05:09:23 (UTC)
committer zautrix <zautrix>2005-06-07 05:09:23 (UTC)
commit0bbef196163a267722978e34db2ba3daaee76f88 (patch) (unidiff)
treefac0b701aea6348490c5e9585820070b32b35e29 /korganizer
parent790b8c38e1305b2f5ee4485e59a3ecd01e5b6f75 (diff)
downloadkdepimpi-0bbef196163a267722978e34db2ba3daaee76f88.zip
kdepimpi-0bbef196163a267722978e34db2ba3daaee76f88.tar.gz
kdepimpi-0bbef196163a267722978e34db2ba3daaee76f88.tar.bz2
clear view fixes
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp19
-rw-r--r--korganizer/calendarview.h1
-rw-r--r--korganizer/koagendaview.cpp7
-rw-r--r--korganizer/koagendaview.h1
-rw-r--r--korganizer/kojournalview.cpp4
-rw-r--r--korganizer/kojournalview.h1
-rw-r--r--korganizer/kolistview.cpp4
-rw-r--r--korganizer/kolistview.h1
-rw-r--r--korganizer/komonthview.cpp10
-rw-r--r--korganizer/komonthview.h1
-rw-r--r--korganizer/koviewmanager.cpp13
-rw-r--r--korganizer/koviewmanager.h1
-rw-r--r--korganizer/kowhatsnextview.cpp5
-rw-r--r--korganizer/kowhatsnextview.h1
-rw-r--r--korganizer/mainwindow.cpp1
15 files changed, 67 insertions, 3 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 608b73b..e13d0be 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1019,256 +1019,257 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b
1019 if ( lastSync > remoteMod ) 1019 if ( lastSync > remoteMod )
1020 return 1; 1020 return 1;
1021 return 2; 1021 return 2;
1022 break; 1022 break;
1023 case SYNC_PREF_NEWEST: 1023 case SYNC_PREF_NEWEST:
1024 if ( localMod >= remoteMod ) 1024 if ( localMod >= remoteMod )
1025 return 1; 1025 return 1;
1026 else 1026 else
1027 return 2; 1027 return 2;
1028 break; 1028 break;
1029 case SYNC_PREF_ASK: 1029 case SYNC_PREF_ASK:
1030 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1030 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1031 if ( lastSync > remoteMod && lastSync > localMod) 1031 if ( lastSync > remoteMod && lastSync > localMod)
1032 return 0; 1032 return 0;
1033 if ( lastSync > remoteMod ) 1033 if ( lastSync > remoteMod )
1034 return 1; 1034 return 1;
1035 if ( lastSync > localMod ) 1035 if ( lastSync > localMod )
1036 return 2; 1036 return 2;
1037 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1037 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1038 localIsNew = localMod >= remoteMod; 1038 localIsNew = localMod >= remoteMod;
1039 if ( localIsNew ) 1039 if ( localIsNew )
1040 getEventViewerDialog()->setColorMode( 1 ); 1040 getEventViewerDialog()->setColorMode( 1 );
1041 else 1041 else
1042 getEventViewerDialog()->setColorMode( 2 ); 1042 getEventViewerDialog()->setColorMode( 2 );
1043 getEventViewerDialog()->setIncidence(local); 1043 getEventViewerDialog()->setIncidence(local);
1044 if ( localIsNew ) 1044 if ( localIsNew )
1045 getEventViewerDialog()->setColorMode( 2 ); 1045 getEventViewerDialog()->setColorMode( 2 );
1046 else 1046 else
1047 getEventViewerDialog()->setColorMode( 1 ); 1047 getEventViewerDialog()->setColorMode( 1 );
1048 getEventViewerDialog()->addIncidence(remote); 1048 getEventViewerDialog()->addIncidence(remote);
1049 getEventViewerDialog()->setColorMode( 0 ); 1049 getEventViewerDialog()->setColorMode( 0 );
1050 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 1050 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
1051 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 1051 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
1052 getEventViewerDialog()->showMe(); 1052 getEventViewerDialog()->showMe();
1053 result = getEventViewerDialog()->executeS( localIsNew ); 1053 result = getEventViewerDialog()->executeS( localIsNew );
1054 return result; 1054 return result;
1055 1055
1056 break; 1056 break;
1057 case SYNC_PREF_FORCE_LOCAL: 1057 case SYNC_PREF_FORCE_LOCAL:
1058 return 1; 1058 return 1;
1059 break; 1059 break;
1060 case SYNC_PREF_FORCE_REMOTE: 1060 case SYNC_PREF_FORCE_REMOTE:
1061 return 2; 1061 return 2;
1062 break; 1062 break;
1063 1063
1064 default: 1064 default:
1065 // SYNC_PREF_TAKE_BOTH not implemented 1065 // SYNC_PREF_TAKE_BOTH not implemented
1066 break; 1066 break;
1067 } 1067 }
1068 return 0; 1068 return 0;
1069} 1069}
1070Event* CalendarView::getLastSyncEvent() 1070Event* CalendarView::getLastSyncEvent()
1071{ 1071{
1072 Event* lse; 1072 Event* lse;
1073 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 1073 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
1074 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 1074 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
1075 if (!lse) { 1075 if (!lse) {
1076 lse = new Event(); 1076 lse = new Event();
1077 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 1077 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
1078 QString sum = ""; 1078 QString sum = "";
1079 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 1079 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
1080 sum = "E: "; 1080 sum = "E: ";
1081 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 1081 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
1082 lse->setDtStart( mLastCalendarSync ); 1082 lse->setDtStart( mLastCalendarSync );
1083 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1083 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1084 lse->setCategories( i18n("SyncEvent") ); 1084 lse->setCategories( i18n("SyncEvent") );
1085 lse->setReadOnly( true ); 1085 lse->setReadOnly( true );
1086 mCalendar->addEvent( lse ); 1086 mCalendar->addEvent( lse );
1087 } 1087 }
1088 1088
1089 return lse; 1089 return lse;
1090 1090
1091} 1091}
1092 1092
1093// we check, if the to delete event has a id for a profile 1093// we check, if the to delete event has a id for a profile
1094// if yes, we set this id in the profile to delete 1094// if yes, we set this id in the profile to delete
1095void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 1095void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
1096{ 1096{
1097 if ( lastSync.count() == 0 ) { 1097 if ( lastSync.count() == 0 ) {
1098 //qDebug(" lastSync.count() == 0"); 1098 //qDebug(" lastSync.count() == 0");
1099 return; 1099 return;
1100 } 1100 }
1101 if ( toDelete->type() == "Journal" ) 1101 if ( toDelete->type() == "Journal" )
1102 return; 1102 return;
1103 1103
1104 Event* eve = lastSync.first(); 1104 Event* eve = lastSync.first();
1105 1105
1106 while ( eve ) { 1106 while ( eve ) {
1107 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 1107 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
1108 if ( !id.isEmpty() ) { 1108 if ( !id.isEmpty() ) {
1109 QString des = eve->description(); 1109 QString des = eve->description();
1110 QString pref = "e"; 1110 QString pref = "e";
1111 if ( toDelete->type() == "Todo" ) 1111 if ( toDelete->type() == "Todo" )
1112 pref = "t"; 1112 pref = "t";
1113 des += pref+ id + ","; 1113 des += pref+ id + ",";
1114 eve->setReadOnly( false ); 1114 eve->setReadOnly( false );
1115 eve->setDescription( des ); 1115 eve->setDescription( des );
1116 //qDebug("setdes %s ", des.latin1()); 1116 //qDebug("setdes %s ", des.latin1());
1117 eve->setReadOnly( true ); 1117 eve->setReadOnly( true );
1118 } 1118 }
1119 eve = lastSync.next(); 1119 eve = lastSync.next();
1120 } 1120 }
1121 1121
1122} 1122}
1123void CalendarView::checkExternalId( Incidence * inc ) 1123void CalendarView::checkExternalId( Incidence * inc )
1124{ 1124{
1125 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 1125 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
1126 checkExternSyncEvent( lastSync, inc ); 1126 checkExternSyncEvent( lastSync, inc );
1127 1127
1128} 1128}
1129bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 1129bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
1130{ 1130{
1131 bool syncOK = true; 1131 bool syncOK = true;
1132 int addedEvent = 0; 1132 int addedEvent = 0;
1133 int addedEventR = 0; 1133 int addedEventR = 0;
1134 int deletedEventR = 0; 1134 int deletedEventR = 0;
1135 int deletedEventL = 0; 1135 int deletedEventL = 0;
1136 int changedLocal = 0; 1136 int changedLocal = 0;
1137 int changedRemote = 0; 1137 int changedRemote = 0;
1138 int filteredIN = 0; 1138 int filteredIN = 0;
1139 int filteredOUT = 0; 1139 int filteredOUT = 0;
1140 //QPtrList<Event> el = local->rawEvents(); 1140 //QPtrList<Event> el = local->rawEvents();
1141 Event* eventR; 1141 Event* eventR;
1142 QString uid; 1142 QString uid;
1143 int take; 1143 int take;
1144 Event* eventL; 1144 Event* eventL;
1145 Event* eventRSync; 1145 Event* eventRSync;
1146 Event* eventLSync; 1146 Event* eventLSync;
1147 clearAllViews();
1147 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 1148 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
1148 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 1149 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
1149 bool fullDateRange = false; 1150 bool fullDateRange = false;
1150 local->resetTempSyncStat(); 1151 local->resetTempSyncStat();
1151 mLastCalendarSync = QDateTime::currentDateTime(); 1152 mLastCalendarSync = QDateTime::currentDateTime();
1152 if ( mSyncManager->syncWithDesktop() ) { 1153 if ( mSyncManager->syncWithDesktop() ) {
1153 remote->resetPilotStat(1); 1154 remote->resetPilotStat(1);
1154 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 1155 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1155 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 1156 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
1156 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 1157 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
1157 } else { 1158 } else {
1158 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 1159 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
1159 } 1160 }
1160 } 1161 }
1161 QDateTime modifiedCalendar = mLastCalendarSync; 1162 QDateTime modifiedCalendar = mLastCalendarSync;
1162 eventLSync = getLastSyncEvent(); 1163 eventLSync = getLastSyncEvent();
1163 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 1164 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
1164 if ( eventR ) { 1165 if ( eventR ) {
1165 eventRSync = (Event*) eventR->clone(); 1166 eventRSync = (Event*) eventR->clone();
1166 remote->deleteEvent(eventR ); 1167 remote->deleteEvent(eventR );
1167 1168
1168 } else { 1169 } else {
1169 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 1170 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
1170 eventRSync = (Event*)eventLSync->clone(); 1171 eventRSync = (Event*)eventLSync->clone();
1171 } else { 1172 } else {
1172 fullDateRange = true; 1173 fullDateRange = true;
1173 eventRSync = new Event(); 1174 eventRSync = new Event();
1174 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 1175 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
1175 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 1176 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
1176 eventRSync->setDtStart( mLastCalendarSync ); 1177 eventRSync->setDtStart( mLastCalendarSync );
1177 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1178 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1178 eventRSync->setCategories( i18n("SyncEvent") ); 1179 eventRSync->setCategories( i18n("SyncEvent") );
1179 } 1180 }
1180 } 1181 }
1181 if ( eventLSync->dtStart() == mLastCalendarSync ) 1182 if ( eventLSync->dtStart() == mLastCalendarSync )
1182 fullDateRange = true; 1183 fullDateRange = true;
1183 1184
1184 if ( ! fullDateRange ) { 1185 if ( ! fullDateRange ) {
1185 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 1186 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
1186 1187
1187 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 1188 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
1188 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 1189 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
1189 fullDateRange = true; 1190 fullDateRange = true;
1190 } 1191 }
1191 } 1192 }
1192 if ( mSyncManager->syncWithDesktop() ) { 1193 if ( mSyncManager->syncWithDesktop() ) {
1193 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 1194 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
1194 } 1195 }
1195 if ( fullDateRange ) 1196 if ( fullDateRange )
1196 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 1197 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
1197 else 1198 else
1198 mLastCalendarSync = eventLSync->dtStart(); 1199 mLastCalendarSync = eventLSync->dtStart();
1199 // for resyncing if own file has changed 1200 // for resyncing if own file has changed
1200 if ( mCurrentSyncDevice == "deleteaftersync" ) { 1201 if ( mCurrentSyncDevice == "deleteaftersync" ) {
1201 mLastCalendarSync = loadedFileVersion; 1202 mLastCalendarSync = loadedFileVersion;
1202 //qDebug("setting mLastCalendarSync "); 1203 //qDebug("setting mLastCalendarSync ");
1203 } 1204 }
1204 //qDebug("*************************** "); 1205 //qDebug("*************************** ");
1205 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 1206 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
1206 QPtrList<Incidence> er = remote->rawIncidences(); 1207 QPtrList<Incidence> er = remote->rawIncidences();
1207 Incidence* inR = er.first(); 1208 Incidence* inR = er.first();
1208 Incidence* inL; 1209 Incidence* inL;
1209 QProgressBar bar( er.count(),0 ); 1210 QProgressBar bar( er.count(),0 );
1210 bar.setCaption (i18n("Syncing - close to abort!") ); 1211 bar.setCaption (i18n("Syncing - close to abort!") );
1211 1212
1212 // ************** setting up filter ************* 1213 // ************** setting up filter *************
1213 CalFilter *filterIN = 0; 1214 CalFilter *filterIN = 0;
1214 CalFilter *filterOUT = 0; 1215 CalFilter *filterOUT = 0;
1215 CalFilter *filter = mFilters.first(); 1216 CalFilter *filter = mFilters.first();
1216 while(filter) { 1217 while(filter) {
1217 if ( filter->name() == mSyncManager->mFilterInCal ) 1218 if ( filter->name() == mSyncManager->mFilterInCal )
1218 filterIN = filter; 1219 filterIN = filter;
1219 if ( filter->name() == mSyncManager->mFilterOutCal ) 1220 if ( filter->name() == mSyncManager->mFilterOutCal )
1220 filterOUT = filter; 1221 filterOUT = filter;
1221 filter = mFilters.next(); 1222 filter = mFilters.next();
1222 } 1223 }
1223 int w = 300; 1224 int w = 300;
1224 if ( QApplication::desktop()->width() < 320 ) 1225 if ( QApplication::desktop()->width() < 320 )
1225 w = 220; 1226 w = 220;
1226 int h = bar.sizeHint().height() ; 1227 int h = bar.sizeHint().height() ;
1227 int dw = QApplication::desktop()->width(); 1228 int dw = QApplication::desktop()->width();
1228 int dh = QApplication::desktop()->height(); 1229 int dh = QApplication::desktop()->height();
1229 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1230 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1230 bar.show(); 1231 bar.show();
1231 int modulo = (er.count()/10)+1; 1232 int modulo = (er.count()/10)+1;
1232 int incCounter = 0; 1233 int incCounter = 0;
1233 while ( inR ) { 1234 while ( inR ) {
1234 if ( ! bar.isVisible() ) 1235 if ( ! bar.isVisible() )
1235 return false; 1236 return false;
1236 if ( incCounter % modulo == 0 ) 1237 if ( incCounter % modulo == 0 )
1237 bar.setProgress( incCounter ); 1238 bar.setProgress( incCounter );
1238 ++incCounter; 1239 ++incCounter;
1239 uid = inR->uid(); 1240 uid = inR->uid();
1240 bool skipIncidence = false; 1241 bool skipIncidence = false;
1241 if ( uid.left(15) == QString("last-syncEvent-") ) 1242 if ( uid.left(15) == QString("last-syncEvent-") )
1242 skipIncidence = true; 1243 skipIncidence = true;
1243 QString idS; 1244 QString idS;
1244 qApp->processEvents(); 1245 qApp->processEvents();
1245 if ( !skipIncidence ) { 1246 if ( !skipIncidence ) {
1246 inL = local->incidence( uid ); 1247 inL = local->incidence( uid );
1247 if ( inL ) { // maybe conflict - same uid in both calendars 1248 if ( inL ) { // maybe conflict - same uid in both calendars
1248 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1249 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1249 //qDebug("take %d %s ", take, inL->summary().latin1()); 1250 //qDebug("take %d %s ", take, inL->summary().latin1());
1250 if ( take == 3 ) 1251 if ( take == 3 )
1251 return false; 1252 return false;
1252 if ( take == 1 ) {// take local ********************** 1253 if ( take == 1 ) {// take local **********************
1253 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1254 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1254 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1255 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1255 else 1256 else
1256 idS = inR->IDStr(); 1257 idS = inR->IDStr();
1257 remote->deleteIncidence( inR ); 1258 remote->deleteIncidence( inR );
1258 inR = inL->clone(); 1259 inR = inL->clone();
1259 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1260 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1260 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1261 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1261 inR->setIDStr( idS ); 1262 inR->setIDStr( idS );
1262 remote->addIncidence( inR ); 1263 remote->addIncidence( inR );
1263 if ( mSyncManager->syncWithDesktop() ) 1264 if ( mSyncManager->syncWithDesktop() )
1264 inR->setPilotId( 2 ); 1265 inR->setPilotId( 2 );
1265 ++changedRemote; 1266 ++changedRemote;
1266 } else {// take remote ********************** 1267 } else {// take remote **********************
1267 idS = inL->IDStr(); 1268 idS = inL->IDStr();
1268 int pid = inL->pilotId(); 1269 int pid = inL->pilotId();
1269 local->deleteIncidence( inL ); 1270 local->deleteIncidence( inL );
1270 inL = inR->clone(); 1271 inL = inR->clone();
1271 if ( mSyncManager->syncWithDesktop() ) 1272 if ( mSyncManager->syncWithDesktop() )
1272 inL->setPilotId( pid ); 1273 inL->setPilotId( pid );
1273 inL->setIDStr( idS ); 1274 inL->setIDStr( idS );
1274 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1275 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
@@ -1711,401 +1712,403 @@ void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthd
1711 ++addCount; 1712 ++addCount;
1712 } 1713 }
1713 } 1714 }
1714 1715
1715 updateView(); 1716 updateView();
1716 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1717 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1717 1718
1718 } 1719 }
1719 1720
1720} 1721}
1721 1722
1722 1723
1723 1724
1724bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1725bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1725{ 1726{
1726 //qDebug("addAnni "); 1727 //qDebug("addAnni ");
1727 Event * ev = new Event(); 1728 Event * ev = new Event();
1728 ev->setOrganizer(KOPrefs::instance()->email()); 1729 ev->setOrganizer(KOPrefs::instance()->email());
1729 if ( a ) { 1730 if ( a ) {
1730 ev->addAttendee( a ); 1731 ev->addAttendee( a );
1731 } 1732 }
1732 QString kind; 1733 QString kind;
1733 if ( birthday ) { 1734 if ( birthday ) {
1734 kind = i18n( "Birthday" ); 1735 kind = i18n( "Birthday" );
1735 ev->setSummary( name + " (" + QString::number(date.year()) +")"); 1736 ev->setSummary( name + " (" + QString::number(date.year()) +")");
1736 } 1737 }
1737 else { 1738 else {
1738 kind = i18n( "Anniversary" ); 1739 kind = i18n( "Anniversary" );
1739 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); 1740 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
1740 } 1741 }
1741 ev->setCategories( kind ); 1742 ev->setCategories( kind );
1742 ev->setDtStart( QDateTime(date) ); 1743 ev->setDtStart( QDateTime(date) );
1743 ev->setDtEnd( QDateTime(date) ); 1744 ev->setDtEnd( QDateTime(date) );
1744 ev->setFloats( true ); 1745 ev->setFloats( true );
1745 Recurrence * rec = ev->recurrence(); 1746 Recurrence * rec = ev->recurrence();
1746 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1747 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1747 rec->addYearlyNum( date.month() ); 1748 rec->addYearlyNum( date.month() );
1748 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1749 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1749 delete ev; 1750 delete ev;
1750 return false; 1751 return false;
1751 } 1752 }
1752 return true; 1753 return true;
1753 1754
1754} 1755}
1755bool CalendarView::importQtopia( const QString &categories, 1756bool CalendarView::importQtopia( const QString &categories,
1756 const QString &datebook, 1757 const QString &datebook,
1757 const QString &todolist ) 1758 const QString &todolist )
1758{ 1759{
1759 1760
1760 QtopiaFormat qtopiaFormat; 1761 QtopiaFormat qtopiaFormat;
1761 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1762 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1762 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1763 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1763 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1764 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1764 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1765 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1765 1766
1766 updateView(); 1767 updateView();
1767 return true; 1768 return true;
1768 1769
1769#if 0 1770#if 0
1770 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1771 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1771 mCurrentSyncDevice = "qtopia-XML"; 1772 mCurrentSyncDevice = "qtopia-XML";
1772 if ( mSyncManager->mAskForPreferences ) 1773 if ( mSyncManager->mAskForPreferences )
1773 edit_sync_options(); 1774 edit_sync_options();
1774 qApp->processEvents(); 1775 qApp->processEvents();
1775 CalendarLocal* calendar = new CalendarLocal(); 1776 CalendarLocal* calendar = new CalendarLocal();
1776 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1777 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1777 bool syncOK = false; 1778 bool syncOK = false;
1778 QtopiaFormat qtopiaFormat; 1779 QtopiaFormat qtopiaFormat;
1779 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1780 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1780 bool loadOk = true; 1781 bool loadOk = true;
1781 if ( !categories.isEmpty() ) 1782 if ( !categories.isEmpty() )
1782 loadOk = qtopiaFormat.load( calendar, categories ); 1783 loadOk = qtopiaFormat.load( calendar, categories );
1783 if ( loadOk && !datebook.isEmpty() ) 1784 if ( loadOk && !datebook.isEmpty() )
1784 loadOk = qtopiaFormat.load( calendar, datebook ); 1785 loadOk = qtopiaFormat.load( calendar, datebook );
1785 if ( loadOk && !todolist.isEmpty() ) 1786 if ( loadOk && !todolist.isEmpty() )
1786 loadOk = qtopiaFormat.load( calendar, todolist ); 1787 loadOk = qtopiaFormat.load( calendar, todolist );
1787 1788
1788 if ( loadOk ) { 1789 if ( loadOk ) {
1789 getEventViewerDialog()->setSyncMode( true ); 1790 getEventViewerDialog()->setSyncMode( true );
1790 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1791 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1791 getEventViewerDialog()->setSyncMode( false ); 1792 getEventViewerDialog()->setSyncMode( false );
1792 qApp->processEvents(); 1793 qApp->processEvents();
1793 if ( syncOK ) { 1794 if ( syncOK ) {
1794 if ( mSyncManager->mWriteBackFile ) 1795 if ( mSyncManager->mWriteBackFile )
1795 { 1796 {
1796 // write back XML file 1797 // write back XML file
1797 1798
1798 } 1799 }
1799 setModified( true ); 1800 setModified( true );
1800 } 1801 }
1801 } else { 1802 } else {
1802 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1803 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1803 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1804 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1804 question, i18n("Ok")) ; 1805 question, i18n("Ok")) ;
1805 } 1806 }
1806 delete calendar; 1807 delete calendar;
1807 updateView(); 1808 updateView();
1808 return syncOK; 1809 return syncOK;
1809 1810
1810 1811
1811#endif 1812#endif
1812 1813
1813} 1814}
1814 1815
1815void CalendarView::setSyncEventsReadOnly() 1816void CalendarView::setSyncEventsReadOnly()
1816{ 1817{
1817 Event * ev; 1818 Event * ev;
1818 QPtrList<Event> eL = mCalendar->rawEvents(); 1819 QPtrList<Event> eL = mCalendar->rawEvents();
1819 ev = eL.first(); 1820 ev = eL.first();
1820 while ( ev ) { 1821 while ( ev ) {
1821 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1822 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1822 ev->setReadOnly( true ); 1823 ev->setReadOnly( true );
1823 ev = eL.next(); 1824 ev = eL.next();
1824 } 1825 }
1825} 1826}
1826bool CalendarView::openCalendar(QString filename, bool merge) 1827bool CalendarView::openCalendar(QString filename, bool merge)
1827{ 1828{
1828 1829
1829 if (filename.isEmpty()) { 1830 if (filename.isEmpty()) {
1830 return false; 1831 return false;
1831 } 1832 }
1832 1833
1833 if (!QFile::exists(filename)) { 1834 if (!QFile::exists(filename)) {
1834 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1835 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1835 return false; 1836 return false;
1836 } 1837 }
1837 1838
1838 globalFlagBlockAgenda = 1; 1839 globalFlagBlockAgenda = 1;
1840 clearAllViews();
1839 if (!merge) { 1841 if (!merge) {
1840 mTodoList->clearList();
1841 mViewManager->setDocumentId( filename ); 1842 mViewManager->setDocumentId( filename );
1842 mCalendar->close(); 1843 mCalendar->close();
1843 } 1844 }
1844 mStorage->setFileName( filename ); 1845 mStorage->setFileName( filename );
1845 1846
1846 if ( mStorage->load() ) { 1847 if ( mStorage->load() ) {
1847 if ( merge ) ;//setModified( true ); 1848 if ( merge ) ;//setModified( true );
1848 else { 1849 else {
1849 //setModified( true ); 1850 //setModified( true );
1850 mViewManager->setDocumentId( filename ); 1851 mViewManager->setDocumentId( filename );
1851 mDialogManager->setDocumentId( filename ); 1852 mDialogManager->setDocumentId( filename );
1852 mTodoList->setDocumentId( filename ); 1853 mTodoList->setDocumentId( filename );
1853 } 1854 }
1854 globalFlagBlockAgenda = 2; 1855 globalFlagBlockAgenda = 2;
1855 // if ( getLastSyncEvent() ) 1856 // if ( getLastSyncEvent() )
1856 // getLastSyncEvent()->setReadOnly( true ); 1857 // getLastSyncEvent()->setReadOnly( true );
1857 mCalendar->reInitAlarmSettings(); 1858 mCalendar->reInitAlarmSettings();
1858 setSyncEventsReadOnly(); 1859 setSyncEventsReadOnly();
1859 updateUnmanagedViews(); 1860 updateUnmanagedViews();
1860 updateView(); 1861 updateView();
1861 if ( filename != MainWindow::defaultFileName() ) { 1862 if ( filename != MainWindow::defaultFileName() ) {
1862 saveCalendar( MainWindow::defaultFileName() ); 1863 saveCalendar( MainWindow::defaultFileName() );
1863 } else { 1864 } else {
1864 QFileInfo finf ( MainWindow::defaultFileName()); 1865 QFileInfo finf ( MainWindow::defaultFileName());
1865 if ( finf.exists() ) { 1866 if ( finf.exists() ) {
1866 setLoadedFileVersion( finf.lastModified () ); 1867 setLoadedFileVersion( finf.lastModified () );
1867 } 1868 }
1868 } 1869 }
1869 return true; 1870 return true;
1870 } else { 1871 } else {
1871 // while failing to load, the calendar object could 1872 // while failing to load, the calendar object could
1872 // have become partially populated. Clear it out. 1873 // have become partially populated. Clear it out.
1873 if ( !merge ) { 1874 if ( !merge ) {
1874 mCalendar->close(); 1875 mCalendar->close();
1875 mViewManager->setDocumentId( filename ); 1876 mViewManager->setDocumentId( filename );
1876 mDialogManager->setDocumentId( filename ); 1877 mDialogManager->setDocumentId( filename );
1877 mTodoList->setDocumentId( filename ); 1878 mTodoList->setDocumentId( filename );
1878 } 1879 }
1879 1880
1880 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1881 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1881 1882
1882 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1883 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1883 globalFlagBlockAgenda = 2; 1884 globalFlagBlockAgenda = 2;
1884 mCalendar->reInitAlarmSettings(); 1885 mCalendar->reInitAlarmSettings();
1885 setSyncEventsReadOnly(); 1886 setSyncEventsReadOnly();
1886 updateUnmanagedViews(); 1887 updateUnmanagedViews();
1887 updateView(); 1888 updateView();
1888 } 1889 }
1889 return false; 1890 return false;
1890} 1891}
1891void CalendarView::showOpenError() 1892void CalendarView::showOpenError()
1892{ 1893{
1893 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1894 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1894} 1895}
1895void CalendarView::setLoadedFileVersion(QDateTime dt) 1896void CalendarView::setLoadedFileVersion(QDateTime dt)
1896{ 1897{
1897 loadedFileVersion = dt; 1898 loadedFileVersion = dt;
1898} 1899}
1899bool CalendarView::checkFileChanged(QString fn) 1900bool CalendarView::checkFileChanged(QString fn)
1900{ 1901{
1901 QFileInfo finf ( fn ); 1902 QFileInfo finf ( fn );
1902 if ( !finf.exists() ) 1903 if ( !finf.exists() )
1903 return true; 1904 return true;
1904 QDateTime dt = finf.lastModified (); 1905 QDateTime dt = finf.lastModified ();
1905 if ( dt <= loadedFileVersion ) 1906 if ( dt <= loadedFileVersion )
1906 return false; 1907 return false;
1907 return true; 1908 return true;
1908 1909
1909} 1910}
1910void CalendarView::watchSavedFile() 1911void CalendarView::watchSavedFile()
1911{ 1912{
1912 QFileInfo finf ( MainWindow::defaultFileName()); 1913 QFileInfo finf ( MainWindow::defaultFileName());
1913 if ( !finf.exists() ) 1914 if ( !finf.exists() )
1914 return; 1915 return;
1915 QDateTime dt = finf.lastModified (); 1916 QDateTime dt = finf.lastModified ();
1916 if ( dt < loadedFileVersion ) { 1917 if ( dt < loadedFileVersion ) {
1917 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1918 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1918 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1919 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1919 return; 1920 return;
1920 } 1921 }
1921 loadedFileVersion = dt; 1922 loadedFileVersion = dt;
1922} 1923}
1923 1924
1924bool CalendarView::checkFileVersion(QString fn) 1925bool CalendarView::checkFileVersion(QString fn)
1925{ 1926{
1926 QFileInfo finf ( fn ); 1927 QFileInfo finf ( fn );
1927 if ( !finf.exists() ) 1928 if ( !finf.exists() )
1928 return true; 1929 return true;
1929 QDateTime dt = finf.lastModified (); 1930 QDateTime dt = finf.lastModified ();
1930 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1931 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1931 //qDebug("file on disk version %s",dt.toString().latin1()); 1932 //qDebug("file on disk version %s",dt.toString().latin1());
1932 if ( dt <= loadedFileVersion ) 1933 if ( dt <= loadedFileVersion )
1933 return true; 1934 return true;
1934 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)) , 1935 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)) ,
1935 i18n("KO/Pi Warning"),i18n("Overwrite"), 1936 i18n("KO/Pi Warning"),i18n("Overwrite"),
1936 i18n("Sync+save")); 1937 i18n("Sync+save"));
1937 1938
1938 if ( km == KMessageBox::Cancel ) 1939 if ( km == KMessageBox::Cancel )
1939 return false; 1940 return false;
1940 if ( km == KMessageBox::Yes ) 1941 if ( km == KMessageBox::Yes )
1941 return true; 1942 return true;
1942 1943
1943 setSyncDevice("deleteaftersync" ); 1944 setSyncDevice("deleteaftersync" );
1944 mSyncManager->mAskForPreferences = true; 1945 mSyncManager->mAskForPreferences = true;
1945 mSyncManager->mSyncAlgoPrefs = 3; 1946 mSyncManager->mSyncAlgoPrefs = 3;
1946 mSyncManager->mWriteBackFile = false; 1947 mSyncManager->mWriteBackFile = false;
1947 mSyncManager->mWriteBackExistingOnly = false; 1948 mSyncManager->mWriteBackExistingOnly = false;
1948 mSyncManager->mShowSyncSummary = false; 1949 mSyncManager->mShowSyncSummary = false;
1949 syncCalendar( fn, 3 ); 1950 syncCalendar( fn, 3 );
1950 Event * e = getLastSyncEvent(); 1951 Event * e = getLastSyncEvent();
1951 mCalendar->deleteEvent ( e ); 1952 if ( e )
1953 deleteEvent ( e );
1952 updateView(); 1954 updateView();
1953 return true; 1955 return true;
1954} 1956}
1955 1957
1956bool CalendarView::saveCalendar( QString filename ) 1958bool CalendarView::saveCalendar( QString filename )
1957{ 1959{
1958 1960
1959 // Store back all unsaved data into calendar object 1961 // Store back all unsaved data into calendar object
1960 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1962 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1961 if ( mViewManager->currentView() ) 1963 if ( mViewManager->currentView() )
1962 mViewManager->currentView()->flushView(); 1964 mViewManager->currentView()->flushView();
1963 1965
1964 1966
1965 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 1967 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
1966 mStorage->setSaveFormat( new ICalFormat() ); 1968 mStorage->setSaveFormat( new ICalFormat() );
1967 mStorage->setFileName( filename ); 1969 mStorage->setFileName( filename );
1968 bool success; 1970 bool success;
1969 success = mStorage->save(); 1971 success = mStorage->save();
1970 if ( !success ) { 1972 if ( !success ) {
1971 return false; 1973 return false;
1972 } 1974 }
1973 if ( filename == MainWindow::defaultFileName() ) { 1975 if ( filename == MainWindow::defaultFileName() ) {
1974 setLoadedFileVersion( lfv ); 1976 setLoadedFileVersion( lfv );
1975 watchSavedFile(); 1977 watchSavedFile();
1976 } 1978 }
1977 return true; 1979 return true;
1978} 1980}
1979 1981
1980void CalendarView::closeCalendar() 1982void CalendarView::closeCalendar()
1981{ 1983{
1982 1984
1983 // child windows no longer valid 1985 // child windows no longer valid
1986 clearAllViews();
1984 emit closingDown(); 1987 emit closingDown();
1985 1988
1986 mCalendar->close(); 1989 mCalendar->close();
1987 setModified(false); 1990 setModified(false);
1988 updateView(); 1991 updateView();
1989} 1992}
1990 1993
1991void CalendarView::archiveCalendar() 1994void CalendarView::archiveCalendar()
1992{ 1995{
1993 mDialogManager->showArchiveDialog(); 1996 mDialogManager->showArchiveDialog();
1994} 1997}
1995 1998
1996 1999
1997void CalendarView::readSettings() 2000void CalendarView::readSettings()
1998{ 2001{
1999 2002
2000 2003
2001 // mViewManager->showAgendaView(); 2004 // mViewManager->showAgendaView();
2002 QString str; 2005 QString str;
2003 //qDebug("CalendarView::readSettings() "); 2006 //qDebug("CalendarView::readSettings() ");
2004 // read settings from the KConfig, supplying reasonable 2007 // read settings from the KConfig, supplying reasonable
2005 // defaults where none are to be found 2008 // defaults where none are to be found
2006 KConfig *config = KOGlobals::config(); 2009 KConfig *config = KOGlobals::config();
2007#ifndef KORG_NOSPLITTER 2010#ifndef KORG_NOSPLITTER
2008 config->setGroup("KOrganizer Geometry"); 2011 config->setGroup("KOrganizer Geometry");
2009 2012
2010 QValueList<int> sizes = config->readIntListEntry("Separator1"); 2013 QValueList<int> sizes = config->readIntListEntry("Separator1");
2011 if (sizes.count() != 2) { 2014 if (sizes.count() != 2) {
2012 sizes << mDateNavigator->minimumSizeHint().width(); 2015 sizes << mDateNavigator->minimumSizeHint().width();
2013 sizes << 300; 2016 sizes << 300;
2014 } 2017 }
2015 mPanner->setSizes(sizes); 2018 mPanner->setSizes(sizes);
2016 2019
2017 sizes = config->readIntListEntry("Separator2"); 2020 sizes = config->readIntListEntry("Separator2");
2018 if ( ( mResourceView && sizes.count() == 4 ) || 2021 if ( ( mResourceView && sizes.count() == 4 ) ||
2019 ( !mResourceView && sizes.count() == 3 ) ) { 2022 ( !mResourceView && sizes.count() == 3 ) ) {
2020 mLeftSplitter->setSizes(sizes); 2023 mLeftSplitter->setSizes(sizes);
2021 } 2024 }
2022#endif 2025#endif
2023 globalFlagBlockAgenda = 1; 2026 globalFlagBlockAgenda = 1;
2024 mViewManager->showAgendaView(); 2027 mViewManager->showAgendaView();
2025 //mViewManager->readSettings( config ); 2028 //mViewManager->readSettings( config );
2026 mTodoList->restoreLayout(config,QString("Todo Layout")); 2029 mTodoList->restoreLayout(config,QString("Todo Layout"));
2027 readFilterSettings(config); 2030 readFilterSettings(config);
2028 2031
2029#ifdef DESKTOP_VERSION 2032#ifdef DESKTOP_VERSION
2030 config->setGroup("WidgetLayout"); 2033 config->setGroup("WidgetLayout");
2031 QStringList list; 2034 QStringList list;
2032 list = config->readListEntry("MainLayout"); 2035 list = config->readListEntry("MainLayout");
2033 int x,y,w,h; 2036 int x,y,w,h;
2034 if ( ! list.isEmpty() ) { 2037 if ( ! list.isEmpty() ) {
2035 x = list[0].toInt(); 2038 x = list[0].toInt();
2036 y = list[1].toInt(); 2039 y = list[1].toInt();
2037 w = list[2].toInt(); 2040 w = list[2].toInt();
2038 h = list[3].toInt(); 2041 h = list[3].toInt();
2039 KApplication::testCoords( &x,&y,&w,&h ); 2042 KApplication::testCoords( &x,&y,&w,&h );
2040 topLevelWidget()->setGeometry(x,y,w,h); 2043 topLevelWidget()->setGeometry(x,y,w,h);
2041 2044
2042 } else { 2045 } else {
2043 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 2046 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
2044 } 2047 }
2045 list = config->readListEntry("EditEventLayout"); 2048 list = config->readListEntry("EditEventLayout");
2046 if ( ! list.isEmpty() ) { 2049 if ( ! list.isEmpty() ) {
2047 x = list[0].toInt(); 2050 x = list[0].toInt();
2048 y = list[1].toInt(); 2051 y = list[1].toInt();
2049 w = list[2].toInt(); 2052 w = list[2].toInt();
2050 h = list[3].toInt(); 2053 h = list[3].toInt();
2051 KApplication::testCoords( &x,&y,&w,&h ); 2054 KApplication::testCoords( &x,&y,&w,&h );
2052 mEventEditor->setGeometry(x,y,w,h); 2055 mEventEditor->setGeometry(x,y,w,h);
2053 2056
2054 } 2057 }
2055 list = config->readListEntry("EditTodoLayout"); 2058 list = config->readListEntry("EditTodoLayout");
2056 if ( ! list.isEmpty() ) { 2059 if ( ! list.isEmpty() ) {
2057 x = list[0].toInt(); 2060 x = list[0].toInt();
2058 y = list[1].toInt(); 2061 y = list[1].toInt();
2059 w = list[2].toInt(); 2062 w = list[2].toInt();
2060 h = list[3].toInt(); 2063 h = list[3].toInt();
2061 KApplication::testCoords( &x,&y,&w,&h ); 2064 KApplication::testCoords( &x,&y,&w,&h );
2062 mTodoEditor->setGeometry(x,y,w,h); 2065 mTodoEditor->setGeometry(x,y,w,h);
2063 2066
2064 } 2067 }
2065 list = config->readListEntry("ViewerLayout"); 2068 list = config->readListEntry("ViewerLayout");
2066 if ( ! list.isEmpty() ) { 2069 if ( ! list.isEmpty() ) {
2067 x = list[0].toInt(); 2070 x = list[0].toInt();
2068 y = list[1].toInt(); 2071 y = list[1].toInt();
2069 w = list[2].toInt(); 2072 w = list[2].toInt();
2070 h = list[3].toInt(); 2073 h = list[3].toInt();
2071 KApplication::testCoords( &x,&y,&w,&h ); 2074 KApplication::testCoords( &x,&y,&w,&h );
2072 getEventViewerDialog()->setGeometry(x,y,w,h); 2075 getEventViewerDialog()->setGeometry(x,y,w,h);
2073 } 2076 }
2074#endif 2077#endif
2075 config->setGroup( "Views" ); 2078 config->setGroup( "Views" );
2076 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 2079 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
2077 2080
2078 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); 2081 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame");
2079 2082
2080 int resetval = 0; 2083 int resetval = 0;
2081 int maxVal = 0; 2084 int maxVal = 0;
2082 if (sizes.count() != 3) { 2085 if (sizes.count() != 3) {
2083 if ( KOPrefs::instance()->mVerticalScreen ) { 2086 if ( KOPrefs::instance()->mVerticalScreen ) {
2084 resetval = mDateNavigator->sizeHint().width()+2; 2087 resetval = mDateNavigator->sizeHint().width()+2;
2085 } else { 2088 } else {
2086 resetval = mDateNavigator->sizeHint().height()+2; 2089 resetval = mDateNavigator->sizeHint().height()+2;
2087 } 2090 }
2088 } 2091 }
2089 if ( resetval ) { 2092 if ( resetval ) {
2090 sizes.clear(); 2093 sizes.clear();
2091 if ( KOPrefs::instance()->mVerticalScreen ) { 2094 if ( KOPrefs::instance()->mVerticalScreen ) {
2092 maxVal = QApplication::desktop()->width() -10; 2095 maxVal = QApplication::desktop()->width() -10;
2093 } else { 2096 } else {
2094 maxVal = QApplication::desktop()->height()-10; 2097 maxVal = QApplication::desktop()->height()-10;
2095 } 2098 }
2096 sizes << resetval; 2099 sizes << resetval;
2097 if ( maxVal < resetval + resetval) 2100 if ( maxVal < resetval + resetval)
2098 resetval = maxVal - resetval; 2101 resetval = maxVal - resetval;
2099 sizes << resetval; 2102 sizes << resetval;
2100 sizes << 100; 2103 sizes << 100;
2101 } 2104 }
2102 mLeftFrame->setSizes(sizes); 2105 mLeftFrame->setSizes(sizes);
2103 sizes = config->readIntListEntry("Main Splitter Frame"); 2106 sizes = config->readIntListEntry("Main Splitter Frame");
2104 resetval = 0; 2107 resetval = 0;
2105 maxVal = 0; 2108 maxVal = 0;
2106 if (sizes.count() != 2) { 2109 if (sizes.count() != 2) {
2107 if ( !KOPrefs::instance()->mVerticalScreen ) { 2110 if ( !KOPrefs::instance()->mVerticalScreen ) {
2108 resetval = mDateNavigator->sizeHint().width()+2; 2111 resetval = mDateNavigator->sizeHint().width()+2;
2109 } else { 2112 } else {
2110 resetval = mDateNavigator->sizeHint().height()+2; 2113 resetval = mDateNavigator->sizeHint().height()+2;
2111 } 2114 }
@@ -2307,256 +2310,267 @@ void CalendarView::goNext()
2307void CalendarView::goPrevious() 2310void CalendarView::goPrevious()
2308{ 2311{
2309 mNavigator->selectPrevious(); 2312 mNavigator->selectPrevious();
2310} 2313}
2311void CalendarView::goNextMonth() 2314void CalendarView::goNextMonth()
2312{ 2315{
2313 mNavigator->selectNextMonth(); 2316 mNavigator->selectNextMonth();
2314} 2317}
2315 2318
2316void CalendarView::goPreviousMonth() 2319void CalendarView::goPreviousMonth()
2317{ 2320{
2318 mNavigator->selectPreviousMonth(); 2321 mNavigator->selectPreviousMonth();
2319} 2322}
2320void CalendarView::writeLocale() 2323void CalendarView::writeLocale()
2321{ 2324{
2322 //KPimGlobalPrefs::instance()->setGlobalConfig(); 2325 //KPimGlobalPrefs::instance()->setGlobalConfig();
2323#if 0 2326#if 0
2324 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 2327 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
2325 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 2328 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
2326 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 2329 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
2327 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 2330 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
2328 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 2331 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
2329 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 2332 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
2330 dummy = KOPrefs::instance()->mUserDateFormatShort; 2333 dummy = KOPrefs::instance()->mUserDateFormatShort;
2331 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 2334 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
2332 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 2335 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
2333 KOPrefs::instance()->mDaylightsavingStart, 2336 KOPrefs::instance()->mDaylightsavingStart,
2334 KOPrefs::instance()->mDaylightsavingEnd ); 2337 KOPrefs::instance()->mDaylightsavingEnd );
2335 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); 2338 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId );
2336#endif 2339#endif
2337} 2340}
2338void CalendarView::updateConfig() 2341void CalendarView::updateConfig()
2339{ 2342{
2340 writeLocale(); 2343 writeLocale();
2341 if ( KOPrefs::instance()->mUseAppColors ) 2344 if ( KOPrefs::instance()->mUseAppColors )
2342 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2345 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2343 emit configChanged(); 2346 emit configChanged();
2344 mTodoList->updateConfig(); 2347 mTodoList->updateConfig();
2345 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2348 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2346 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2349 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2347 // To make the "fill window" configurations work 2350 // To make the "fill window" configurations work
2348 //mViewManager->raiseCurrentView(); 2351 //mViewManager->raiseCurrentView();
2349} 2352}
2350 2353
2351 2354
2352void CalendarView::eventChanged(Event *event) 2355void CalendarView::eventChanged(Event *event)
2353{ 2356{
2354 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2357 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2355 //updateUnmanagedViews(); 2358 //updateUnmanagedViews();
2356} 2359}
2357 2360
2358void CalendarView::eventAdded(Event *event) 2361void CalendarView::eventAdded(Event *event)
2359{ 2362{
2360 changeEventDisplay(event,KOGlobals::EVENTADDED); 2363 changeEventDisplay(event,KOGlobals::EVENTADDED);
2361} 2364}
2362 2365
2363void CalendarView::eventToBeDeleted(Event *) 2366void CalendarView::eventToBeDeleted(Event *)
2364{ 2367{
2365 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2368 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2366} 2369}
2367 2370
2368void CalendarView::eventDeleted() 2371void CalendarView::eventDeleted()
2369{ 2372{
2370 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2373 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2371} 2374}
2372void CalendarView::changeTodoDisplay(Todo *which, int action) 2375void CalendarView::changeTodoDisplay(Todo *which, int action)
2373{ 2376{
2374 changeIncidenceDisplay((Incidence *)which, action); 2377 changeIncidenceDisplay((Incidence *)which, action);
2375 mDateNavigator->updateView(); //LR 2378 mDateNavigator->updateView(); //LR
2376 //mDialogManager->updateSearchDialog(); 2379 //mDialogManager->updateSearchDialog();
2377 2380
2378 if (which) { 2381 if (which) {
2379 mViewManager->updateWNview(); 2382 mViewManager->updateWNview();
2380 //mTodoList->updateView(); 2383 //mTodoList->updateView();
2381 } 2384 }
2382 2385
2383} 2386}
2384 2387
2385void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2388void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2386{ 2389{
2387 updateUnmanagedViews(); 2390 updateUnmanagedViews();
2388 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2391 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2389 if ( action == KOGlobals::EVENTDELETED ) { //delete 2392 if ( action == KOGlobals::EVENTDELETED ) { //delete
2390 mCalendar->checkAlarmForIncidence( 0, true ); 2393 mCalendar->checkAlarmForIncidence( 0, true );
2391 if ( mEventViewerDialog ) 2394 if ( mEventViewerDialog )
2392 mEventViewerDialog->hide(); 2395 mEventViewerDialog->hide();
2393 } 2396 }
2394 else 2397 else
2395 mCalendar->checkAlarmForIncidence( which , false ); 2398 mCalendar->checkAlarmForIncidence( which , false );
2396} 2399}
2397 2400
2398// most of the changeEventDisplays() right now just call the view's 2401// most of the changeEventDisplays() right now just call the view's
2399// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2402// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2400void CalendarView::changeEventDisplay(Event *which, int action) 2403void CalendarView::changeEventDisplay(Event *which, int action)
2401{ 2404{
2402 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2405 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2403 changeIncidenceDisplay((Incidence *)which, action); 2406 changeIncidenceDisplay((Incidence *)which, action);
2404 mDateNavigator->updateView(); 2407 mDateNavigator->updateView();
2405 //mDialogManager->updateSearchDialog(); 2408 //mDialogManager->updateSearchDialog();
2406 2409
2407 if (which) { 2410 if (which) {
2408 // If there is an event view visible update the display 2411 // If there is an event view visible update the display
2409 mViewManager->currentView()->changeEventDisplay(which,action); 2412 mViewManager->currentView()->changeEventDisplay(which,action);
2410 // TODO: check, if update needed 2413 // TODO: check, if update needed
2411 // if (which->getTodoStatus()) { 2414 // if (which->getTodoStatus()) {
2412 mTodoList->updateView(); 2415 mTodoList->updateView();
2413 // } 2416 // }
2414 } else { 2417 } else {
2415 mViewManager->currentView()->updateView(); 2418 mViewManager->currentView()->updateView();
2416 } 2419 }
2417} 2420}
2418 2421
2419 2422
2420void CalendarView::updateTodoViews() 2423void CalendarView::updateTodoViews()
2421{ 2424{
2422 mTodoList->updateView(); 2425 mTodoList->updateView();
2423 mViewManager->currentView()->updateView(); 2426 mViewManager->currentView()->updateView();
2424 2427
2425} 2428}
2426 2429
2427 2430
2428void CalendarView::updateView(const QDate &start, const QDate &end) 2431void CalendarView::updateView(const QDate &start, const QDate &end)
2429{ 2432{
2430 mTodoList->updateView(); 2433 mTodoList->updateView();
2431 mViewManager->updateView(start, end); 2434 mViewManager->updateView(start, end);
2432 //mDateNavigator->updateView(); 2435 //mDateNavigator->updateView();
2433} 2436}
2434 2437
2438void CalendarView::clearAllViews()
2439{
2440 mTodoList->clearList();
2441 mViewManager->clearAllViews();
2442 SearchDialog * sd = mDialogManager->getSearchDialog();
2443 if ( sd ) {
2444 KOListView* kol = sd->listview();
2445 if ( kol )
2446 kol->clearList();
2447 }
2448}
2435void CalendarView::updateView() 2449void CalendarView::updateView()
2436{ 2450{
2437 DateList tmpList = mNavigator->selectedDates(); 2451 DateList tmpList = mNavigator->selectedDates();
2438 2452
2439 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2453 if ( KOPrefs::instance()->mHideNonStartedTodos )
2440 mTodoList->updateView(); 2454 mTodoList->updateView();
2441 // We assume that the navigator only selects consecutive days. 2455 // We assume that the navigator only selects consecutive days.
2442 updateView( tmpList.first(), tmpList.last() ); 2456 updateView( tmpList.first(), tmpList.last() );
2443} 2457}
2444 2458
2445void CalendarView::updateUnmanagedViews() 2459void CalendarView::updateUnmanagedViews()
2446{ 2460{
2447 mDateNavigator->updateDayMatrix(); 2461 mDateNavigator->updateDayMatrix();
2448} 2462}
2449 2463
2450int CalendarView::msgItemDelete(const QString name) 2464int CalendarView::msgItemDelete(const QString name)
2451{ 2465{
2452 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 2466 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
2453 i18n("This item will be\npermanently deleted."), 2467 i18n("This item will be\npermanently deleted."),
2454 i18n("KO/Pi Confirmation"),i18n("Delete")); 2468 i18n("KO/Pi Confirmation"),i18n("Delete"));
2455} 2469}
2456 2470
2457 2471
2458void CalendarView::edit_cut() 2472void CalendarView::edit_cut()
2459{ 2473{
2460 Event *anEvent=0; 2474 Event *anEvent=0;
2461 2475
2462 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2476 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2463 2477
2464 if (mViewManager->currentView()->isEventView()) { 2478 if (mViewManager->currentView()->isEventView()) {
2465 if ( incidence && incidence->type() == "Event" ) { 2479 if ( incidence && incidence->type() == "Event" ) {
2466 anEvent = static_cast<Event *>(incidence); 2480 anEvent = static_cast<Event *>(incidence);
2467 } 2481 }
2468 } 2482 }
2469 2483
2470 if (!anEvent) { 2484 if (!anEvent) {
2471 KNotifyClient::beep(); 2485 KNotifyClient::beep();
2472 return; 2486 return;
2473 } 2487 }
2474 DndFactory factory( mCalendar ); 2488 DndFactory factory( mCalendar );
2475 factory.cutIncidence(anEvent); 2489 factory.cutIncidence(anEvent);
2476 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2490 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2477} 2491}
2478 2492
2479void CalendarView::edit_copy() 2493void CalendarView::edit_copy()
2480{ 2494{
2481 Event *anEvent=0; 2495 Event *anEvent=0;
2482 2496
2483 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2497 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2484 2498
2485 if (mViewManager->currentView()->isEventView()) { 2499 if (mViewManager->currentView()->isEventView()) {
2486 if ( incidence && incidence->type() == "Event" ) { 2500 if ( incidence && incidence->type() == "Event" ) {
2487 anEvent = static_cast<Event *>(incidence); 2501 anEvent = static_cast<Event *>(incidence);
2488 } 2502 }
2489 } 2503 }
2490 2504
2491 if (!anEvent) { 2505 if (!anEvent) {
2492 KNotifyClient::beep(); 2506 KNotifyClient::beep();
2493 return; 2507 return;
2494 } 2508 }
2495 DndFactory factory( mCalendar ); 2509 DndFactory factory( mCalendar );
2496 factory.copyIncidence(anEvent); 2510 factory.copyIncidence(anEvent);
2497} 2511}
2498 2512
2499void CalendarView::edit_paste() 2513void CalendarView::edit_paste()
2500{ 2514{
2501 QDate date = mNavigator->selectedDates().first(); 2515 QDate date = mNavigator->selectedDates().first();
2502 2516
2503 DndFactory factory( mCalendar ); 2517 DndFactory factory( mCalendar );
2504 Event *pastedEvent = (Event *)factory.pasteIncidence( date ); 2518 Event *pastedEvent = (Event *)factory.pasteIncidence( date );
2505 2519
2506 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2520 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2507} 2521}
2508 2522
2509void CalendarView::edit_options() 2523void CalendarView::edit_options()
2510{ 2524{
2511 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; 2525 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId;
2512 emit save(); 2526 emit save();
2513 emit saveStopTimer(); 2527 emit saveStopTimer();
2514 mDialogManager->showOptionsDialog(); 2528 mDialogManager->showOptionsDialog();
2515 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { 2529 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
2516 emit saveStopTimer(); 2530 emit saveStopTimer();
2517 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!"), 2531 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!"),
2518 i18n("Timezone settings"),i18n("Reload"))) { 2532 i18n("Timezone settings"),i18n("Reload"))) {
2519 qDebug("KO: TZ reload cancelled "); 2533 qDebug("KO: TZ reload cancelled ");
2520 return; 2534 return;
2521 } 2535 }
2522 qDebug("KO: Timezone change "); 2536 qDebug("KO: Timezone change ");
2523 openCalendar( MainWindow::defaultFileName() ); 2537 openCalendar( MainWindow::defaultFileName() );
2524 setModified(true); 2538 setModified(true);
2525 } 2539 }
2526 else 2540 else
2527 qDebug("KO: No tz change "); 2541 qDebug("KO: No tz change ");
2528 2542
2529} 2543}
2530 2544
2531 2545
2532void CalendarView::slotSelectPickerDate( QDate d) 2546void CalendarView::slotSelectPickerDate( QDate d)
2533{ 2547{
2534 mDateFrame->hide(); 2548 mDateFrame->hide();
2535 if ( mDatePickerMode == 1 ) { 2549 if ( mDatePickerMode == 1 ) {
2536 mNavigator->slotDaySelect( d ); 2550 mNavigator->slotDaySelect( d );
2537 } else if ( mDatePickerMode == 2 ) { 2551 } else if ( mDatePickerMode == 2 ) {
2538 if ( mMoveIncidence->type() == "Todo" ) { 2552 if ( mMoveIncidence->type() == "Todo" ) {
2539 Todo * to = (Todo *) mMoveIncidence; 2553 Todo * to = (Todo *) mMoveIncidence;
2540 QTime tim; 2554 QTime tim;
2541 int len = 0; 2555 int len = 0;
2542 if ( to->hasStartDate() && to->hasDueDate() ) 2556 if ( to->hasStartDate() && to->hasDueDate() )
2543 len = to->dtStart().secsTo( to->dtDue()); 2557 len = to->dtStart().secsTo( to->dtDue());
2544 if ( to->hasDueDate() ) 2558 if ( to->hasDueDate() )
2545 tim = to->dtDue().time(); 2559 tim = to->dtDue().time();
2546 else { 2560 else {
2547 tim = QTime ( 0,0,0 ); 2561 tim = QTime ( 0,0,0 );
2548 to->setFloats( true ); 2562 to->setFloats( true );
2549 to->setHasDueDate( true ); 2563 to->setHasDueDate( true );
2550 } 2564 }
2551 QDateTime dt ( d,tim ); 2565 QDateTime dt ( d,tim );
2552 to->setDtDue( dt ); 2566 to->setDtDue( dt );
2553 2567
2554 if ( to->hasStartDate() ) { 2568 if ( to->hasStartDate() ) {
2555 if ( len>0 ) 2569 if ( len>0 )
2556 to->setDtStart(to->dtDue().addSecs( -len )); 2570 to->setDtStart(to->dtDue().addSecs( -len ));
2557 else 2571 else
2558 if (to->dtStart() > to->dtDue() ) 2572 if (to->dtStart() > to->dtDue() )
2559 to->setDtStart(to->dtDue().addDays( -3 )); 2573 to->setDtStart(to->dtDue().addDays( -3 ));
2560 } 2574 }
2561 2575
2562 todoChanged( to ); 2576 todoChanged( to );
@@ -3818,256 +3832,257 @@ void CalendarView::showDates(const DateList &selectedDates)
3818{ 3832{
3819 // kdDebug() << "CalendarView::selectDates()" << endl; 3833 // kdDebug() << "CalendarView::selectDates()" << endl;
3820 3834
3821 3835
3822 if ( !mBlockShowDates ) { 3836 if ( !mBlockShowDates ) {
3823 if ( mViewManager->currentView() ) { 3837 if ( mViewManager->currentView() ) {
3824 updateView( selectedDates.first(), selectedDates.last() ); 3838 updateView( selectedDates.first(), selectedDates.last() );
3825 } else { 3839 } else {
3826 mViewManager->showAgendaView(); 3840 mViewManager->showAgendaView();
3827 } 3841 }
3828 } 3842 }
3829 3843
3830 QDate date = selectedDates.first(); 3844 QDate date = selectedDates.first();
3831 if ( ! date.isValid() ) { 3845 if ( ! date.isValid() ) {
3832 topLevelWidget()->setCaption(""); 3846 topLevelWidget()->setCaption("");
3833 return; 3847 return;
3834 } 3848 }
3835 3849
3836 QString selDates; 3850 QString selDates;
3837 selDates = KGlobal::locale()->formatDate( date, true); 3851 selDates = KGlobal::locale()->formatDate( date, true);
3838 if (selectedDates.first() < selectedDates.last() ) 3852 if (selectedDates.first() < selectedDates.last() )
3839 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3853 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3840 else { 3854 else {
3841 QString addString; 3855 QString addString;
3842 if ( date == QDateTime::currentDateTime().date() ) 3856 if ( date == QDateTime::currentDateTime().date() )
3843 addString = i18n("Today"); 3857 addString = i18n("Today");
3844 else if ( date == QDateTime::currentDateTime().date().addDays(1) ) 3858 else if ( date == QDateTime::currentDateTime().date().addDays(1) )
3845 addString = i18n("Tomorrow"); 3859 addString = i18n("Tomorrow");
3846 else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) 3860 else if ( date == QDateTime::currentDateTime().date().addDays(-1) )
3847 addString = i18n("Yesterday"); 3861 addString = i18n("Yesterday");
3848 else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) 3862 else if ( date == QDateTime::currentDateTime().date().addDays(-2) )
3849 addString = i18n("Day before yesterday"); 3863 addString = i18n("Day before yesterday");
3850 else if ( date == QDateTime::currentDateTime().date().addDays(2) ) 3864 else if ( date == QDateTime::currentDateTime().date().addDays(2) )
3851 addString = i18n("Day after tomorrow"); 3865 addString = i18n("Day after tomorrow");
3852 if ( !addString.isEmpty() ) { 3866 if ( !addString.isEmpty() ) {
3853 topLevelWidget()->setCaption( addString+", " + selDates ); 3867 topLevelWidget()->setCaption( addString+", " + selDates );
3854 return; 3868 return;
3855 } 3869 }
3856 } 3870 }
3857 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3871 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3858 3872
3859} 3873}
3860 3874
3861QPtrList<CalFilter> CalendarView::filters() 3875QPtrList<CalFilter> CalendarView::filters()
3862{ 3876{
3863 return mFilters; 3877 return mFilters;
3864 3878
3865} 3879}
3866void CalendarView::editFilters() 3880void CalendarView::editFilters()
3867{ 3881{
3868 // kdDebug() << "CalendarView::editFilters()" << endl; 3882 // kdDebug() << "CalendarView::editFilters()" << endl;
3869 3883
3870 CalFilter *filter = mFilters.first(); 3884 CalFilter *filter = mFilters.first();
3871 while(filter) { 3885 while(filter) {
3872 kdDebug() << " Filter: " << filter->name() << endl; 3886 kdDebug() << " Filter: " << filter->name() << endl;
3873 filter = mFilters.next(); 3887 filter = mFilters.next();
3874 } 3888 }
3875 3889
3876 mDialogManager->showFilterEditDialog(&mFilters); 3890 mDialogManager->showFilterEditDialog(&mFilters);
3877} 3891}
3878void CalendarView::toggleFilter() 3892void CalendarView::toggleFilter()
3879{ 3893{
3880 showFilter(! mFilterView->isVisible()); 3894 showFilter(! mFilterView->isVisible());
3881} 3895}
3882 3896
3883KOFilterView *CalendarView::filterView() 3897KOFilterView *CalendarView::filterView()
3884{ 3898{
3885 return mFilterView; 3899 return mFilterView;
3886} 3900}
3887void CalendarView::selectFilter( int fil ) 3901void CalendarView::selectFilter( int fil )
3888{ 3902{
3889 mFilterView->setSelectedFilter( fil ); 3903 mFilterView->setSelectedFilter( fil );
3890} 3904}
3891void CalendarView::showFilter(bool visible) 3905void CalendarView::showFilter(bool visible)
3892{ 3906{
3893 if (visible) mFilterView->show(); 3907 if (visible) mFilterView->show();
3894 else mFilterView->hide(); 3908 else mFilterView->hide();
3895} 3909}
3896void CalendarView::toggleFilerEnabled( ) 3910void CalendarView::toggleFilerEnabled( )
3897{ 3911{
3898 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3912 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3899 if ( !mFilterView->filtersEnabled() ) 3913 if ( !mFilterView->filtersEnabled() )
3900 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3914 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3901 3915
3902} 3916}
3903void CalendarView::updateFilter() 3917void CalendarView::updateFilter()
3904{ 3918{
3905 CalFilter *filter = mFilterView->selectedFilter(); 3919 CalFilter *filter = mFilterView->selectedFilter();
3906 if (filter) { 3920 if (filter) {
3907 QString mess; 3921 QString mess;
3908 if (mFilterView->filtersEnabled()) { 3922 if (mFilterView->filtersEnabled()) {
3909 mess = i18n("Filter selected: ")+filter->name(); 3923 mess = i18n("Filter selected: ")+filter->name();
3910 filter->setEnabled(true); 3924 filter->setEnabled(true);
3911 } 3925 }
3912 else filter->setEnabled(false); 3926 else filter->setEnabled(false);
3913 mCalendar->setFilter(filter); 3927 mCalendar->setFilter(filter);
3914 updateView(); 3928 updateView();
3915 if ( !mess.isEmpty() ) 3929 if ( !mess.isEmpty() )
3916 topLevelWidget()->setCaption( mess ); 3930 topLevelWidget()->setCaption( mess );
3917 3931
3918 } 3932 }
3919} 3933}
3920 3934
3921void CalendarView::filterEdited() 3935void CalendarView::filterEdited()
3922{ 3936{
3923 mFilterView->updateFilters(); 3937 mFilterView->updateFilters();
3924 updateFilter(); 3938 updateFilter();
3925 writeSettings(); 3939 writeSettings();
3926} 3940}
3927 3941
3928 3942
3929void CalendarView::takeOverEvent() 3943void CalendarView::takeOverEvent()
3930{ 3944{
3931 Incidence *incidence = currentSelection(); 3945 Incidence *incidence = currentSelection();
3932 3946
3933 if (!incidence) return; 3947 if (!incidence) return;
3934 3948
3935 incidence->setOrganizer(KOPrefs::instance()->email()); 3949 incidence->setOrganizer(KOPrefs::instance()->email());
3936 incidence->recreate(); 3950 incidence->recreate();
3937 incidence->setReadOnly(false); 3951 incidence->setReadOnly(false);
3938 3952
3939 updateView(); 3953 updateView();
3940} 3954}
3941 3955
3942void CalendarView::takeOverCalendar() 3956void CalendarView::takeOverCalendar()
3943{ 3957{
3944 // TODO: Create Calendar::allIncidences() function and use it here 3958 // TODO: Create Calendar::allIncidences() function and use it here
3945 3959
3960 clearAllViews();
3946 QPtrList<Event> events = mCalendar->events(); 3961 QPtrList<Event> events = mCalendar->events();
3947 for(uint i=0; i<events.count(); ++i) { 3962 for(uint i=0; i<events.count(); ++i) {
3948 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 3963 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3949 events.at(i)->recreate(); 3964 events.at(i)->recreate();
3950 events.at(i)->setReadOnly(false); 3965 events.at(i)->setReadOnly(false);
3951 } 3966 }
3952 3967
3953 QPtrList<Todo> todos = mCalendar->todos(); 3968 QPtrList<Todo> todos = mCalendar->todos();
3954 for(uint i=0; i<todos.count(); ++i) { 3969 for(uint i=0; i<todos.count(); ++i) {
3955 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 3970 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
3956 todos.at(i)->recreate(); 3971 todos.at(i)->recreate();
3957 todos.at(i)->setReadOnly(false); 3972 todos.at(i)->setReadOnly(false);
3958 } 3973 }
3959 3974
3960 QPtrList<Journal> journals = mCalendar->journals(); 3975 QPtrList<Journal> journals = mCalendar->journals();
3961 for(uint i=0; i<journals.count(); ++i) { 3976 for(uint i=0; i<journals.count(); ++i) {
3962 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3977 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3963 journals.at(i)->recreate(); 3978 journals.at(i)->recreate();
3964 journals.at(i)->setReadOnly(false); 3979 journals.at(i)->setReadOnly(false);
3965 } 3980 }
3966 3981
3967 updateView(); 3982 updateView();
3968} 3983}
3969 3984
3970void CalendarView::showIntro() 3985void CalendarView::showIntro()
3971{ 3986{
3972 kdDebug() << "To be implemented." << endl; 3987 kdDebug() << "To be implemented." << endl;
3973} 3988}
3974 3989
3975QWidgetStack *CalendarView::viewStack() 3990QWidgetStack *CalendarView::viewStack()
3976{ 3991{
3977 return mRightFrame; 3992 return mRightFrame;
3978} 3993}
3979 3994
3980QWidget *CalendarView::leftFrame() 3995QWidget *CalendarView::leftFrame()
3981{ 3996{
3982 return ( QWidget *)mLeftFrame; 3997 return ( QWidget *)mLeftFrame;
3983} 3998}
3984 3999
3985DateNavigator *CalendarView::dateNavigator() 4000DateNavigator *CalendarView::dateNavigator()
3986{ 4001{
3987 return mNavigator; 4002 return mNavigator;
3988} 4003}
3989 4004
3990KDateNavigator* CalendarView::dateNavigatorWidget() 4005KDateNavigator* CalendarView::dateNavigatorWidget()
3991{ 4006{
3992 return mDateNavigator->navigatorView(); 4007 return mDateNavigator->navigatorView();
3993} 4008}
3994void CalendarView::toggleDateNavigatorWidget() 4009void CalendarView::toggleDateNavigatorWidget()
3995{ 4010{
3996 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; 4011 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ;
3997 4012
3998 if (!KOPrefs::instance()->mShowDateNavigator ) 4013 if (!KOPrefs::instance()->mShowDateNavigator )
3999 mDateNavigator->hide(); 4014 mDateNavigator->hide();
4000 else 4015 else
4001 mDateNavigator->show(); 4016 mDateNavigator->show();
4002} 4017}
4003void CalendarView::addView(KOrg::BaseView *view) 4018void CalendarView::addView(KOrg::BaseView *view)
4004{ 4019{
4005 mViewManager->addView(view); 4020 mViewManager->addView(view);
4006} 4021}
4007 4022
4008void CalendarView::showView(KOrg::BaseView *view) 4023void CalendarView::showView(KOrg::BaseView *view)
4009{ 4024{
4010 mViewManager->showView(view, mLeftFrame->isVisible()); 4025 mViewManager->showView(view, mLeftFrame->isVisible());
4011} 4026}
4012 4027
4013Incidence *CalendarView::currentSelection() 4028Incidence *CalendarView::currentSelection()
4014{ 4029{
4015 return mViewManager->currentSelection(); 4030 return mViewManager->currentSelection();
4016} 4031}
4017void CalendarView::toggleAllDaySize() 4032void CalendarView::toggleAllDaySize()
4018{ 4033{
4019 /* 4034 /*
4020 if ( KOPrefs::instance()->mAllDaySize > 47 ) 4035 if ( KOPrefs::instance()->mAllDaySize > 47 )
4021 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 4036 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
4022 else 4037 else
4023 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 4038 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
4024 */ 4039 */
4025 viewManager()->agendaView()->toggleAllDay(); 4040 viewManager()->agendaView()->toggleAllDay();
4026} 4041}
4027void CalendarView::toggleExpand() 4042void CalendarView::toggleExpand()
4028{ 4043{
4029 // if ( mLeftFrame->isHidden() ) { 4044 // if ( mLeftFrame->isHidden() ) {
4030 // mLeftFrame->show(); 4045 // mLeftFrame->show();
4031 // emit calendarViewExpanded( false ); 4046 // emit calendarViewExpanded( false );
4032 // } else { 4047 // } else {
4033 // mLeftFrame->hide(); 4048 // mLeftFrame->hide();
4034 // emit calendarViewExpanded( true ); 4049 // emit calendarViewExpanded( true );
4035 // } 4050 // }
4036 //qDebug(" CalendarView::toggleExpand()"); 4051 //qDebug(" CalendarView::toggleExpand()");
4037 globalFlagBlockAgenda = 1; 4052 globalFlagBlockAgenda = 1;
4038 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 4053 emit calendarViewExpanded( !mLeftFrame->isHidden() );
4039 globalFlagBlockAgenda = 5; 4054 globalFlagBlockAgenda = 5;
4040 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 4055 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
4041 //mViewManager->showView( 0, true ); 4056 //mViewManager->showView( 0, true );
4042} 4057}
4043 4058
4044void CalendarView::calendarModified( bool modified, Calendar * ) 4059void CalendarView::calendarModified( bool modified, Calendar * )
4045{ 4060{
4046 setModified( modified ); 4061 setModified( modified );
4047} 4062}
4048 4063
4049Todo *CalendarView::selectedTodo() 4064Todo *CalendarView::selectedTodo()
4050{ 4065{
4051 Incidence *incidence = currentSelection(); 4066 Incidence *incidence = currentSelection();
4052 if ( incidence && incidence->type() == "Todo" ) { 4067 if ( incidence && incidence->type() == "Todo" ) {
4053 return static_cast<Todo *>( incidence ); 4068 return static_cast<Todo *>( incidence );
4054 } 4069 }
4055 4070
4056 incidence = mTodoList->selectedIncidences().first(); 4071 incidence = mTodoList->selectedIncidences().first();
4057 if ( incidence && incidence->type() == "Todo" ) { 4072 if ( incidence && incidence->type() == "Todo" ) {
4058 return static_cast<Todo *>( incidence ); 4073 return static_cast<Todo *>( incidence );
4059 } 4074 }
4060 4075
4061 return 0; 4076 return 0;
4062} 4077}
4063 4078
4064void CalendarView::dialogClosing(Incidence *in) 4079void CalendarView::dialogClosing(Incidence *in)
4065{ 4080{
4066 // mDialogList.remove(in); 4081 // mDialogList.remove(in);
4067} 4082}
4068 4083
4069void CalendarView::showIncidence() 4084void CalendarView::showIncidence()
4070{ 4085{
4071 mViewerCallerIsSearchDialog = false; 4086 mViewerCallerIsSearchDialog = false;
4072 Incidence *incidence = currentSelection(); 4087 Incidence *incidence = currentSelection();
4073 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4088 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index 084b6db..4600090 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -206,256 +206,257 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
206 void addSuspendAlarm(const QDateTime &qdt, const QString &noti ); 206 void addSuspendAlarm(const QDateTime &qdt, const QString &noti );
207 void removeAlarm(const QDateTime &qdt, const QString &noti ); 207 void removeAlarm(const QDateTime &qdt, const QString &noti );
208 208
209 /** options dialog made a changed to the configuration. we catch this 209 /** options dialog made a changed to the configuration. we catch this
210 * and notify all widgets which need to update their configuration. */ 210 * and notify all widgets which need to update their configuration. */
211 void updateConfig(); 211 void updateConfig();
212 212
213 void insertBirthdays(const QString& uid, const QStringList& birthdayList, 213 void insertBirthdays(const QString& uid, const QStringList& birthdayList,
214 const QStringList& anniversaryList, const QStringList& realNameList, 214 const QStringList& anniversaryList, const QStringList& realNameList,
215 const QStringList& emailList, const QStringList& assembledNameList, 215 const QStringList& emailList, const QStringList& assembledNameList,
216 const QStringList& uidList); 216 const QStringList& uidList);
217 217
218 /** 218 /**
219 Load calendar from file \a filename. If \a merge is true, load 219 Load calendar from file \a filename. If \a merge is true, load
220 calendar into existing one, if it is false, clear calendar, before 220 calendar into existing one, if it is false, clear calendar, before
221 loading. Return true, if calendar could be successfully loaded. 221 loading. Return true, if calendar could be successfully loaded.
222 */ 222 */
223 bool openCalendar(QString filename, bool merge=false); 223 bool openCalendar(QString filename, bool merge=false);
224 bool syncCalendar(QString filename,int mode = 0 ); 224 bool syncCalendar(QString filename,int mode = 0 );
225 225
226 /** 226 /**
227 Save calendar data to file. Return true if calendar could be 227 Save calendar data to file. Return true if calendar could be
228 successfully saved. 228 successfully saved.
229 */ 229 */
230 bool saveCalendar(QString filename); 230 bool saveCalendar(QString filename);
231 231
232 /** 232 /**
233 Close calendar. Clear calendar data and reset views to display an empty 233 Close calendar. Clear calendar data and reset views to display an empty
234 calendar. 234 calendar.
235 */ 235 */
236 void closeCalendar(); 236 void closeCalendar();
237 237
238 /** Archive old events of calendar */ 238 /** Archive old events of calendar */
239 void archiveCalendar(); 239 void archiveCalendar();
240 240
241 void showIncidence(); 241 void showIncidence();
242 void editIncidence(); 242 void editIncidence();
243 void editIncidenceDescription(); 243 void editIncidenceDescription();
244 void deleteIncidence(); 244 void deleteIncidence();
245 void cloneIncidence(); 245 void cloneIncidence();
246 void moveIncidence(); 246 void moveIncidence();
247 void beamIncidence(); 247 void beamIncidence();
248 void toggleCancelIncidence(); 248 void toggleCancelIncidence();
249 249
250 /** create an editeventwin with supplied date/time, and if bool is true, 250 /** create an editeventwin with supplied date/time, and if bool is true,
251 * make the event take all day. */ 251 * make the event take all day. */
252 void newEvent(QDateTime, QDateTime, bool allDay ); 252 void newEvent(QDateTime, QDateTime, bool allDay );
253 void newEvent(QDateTime, QDateTime); 253 void newEvent(QDateTime, QDateTime);
254 void newEvent(QDateTime fh); 254 void newEvent(QDateTime fh);
255 void newEvent(QDate dt); 255 void newEvent(QDate dt);
256 /** create new event without having a date hint. Takes current date as 256 /** create new event without having a date hint. Takes current date as
257 default hint. */ 257 default hint. */
258 void newEvent(); 258 void newEvent();
259 void newFloatingEvent(); 259 void newFloatingEvent();
260 260
261 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ 261 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/
262 void showIncidence(Incidence *); 262 void showIncidence(Incidence *);
263 void showIncidence(QString uid); 263 void showIncidence(QString uid);
264 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ 264 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/
265 void editIncidence(Incidence *); 265 void editIncidence(Incidence *);
266 /** Delete the supplied incidence. It calls the correct deleteXXX method*/ 266 /** Delete the supplied incidence. It calls the correct deleteXXX method*/
267 void deleteIncidence(Incidence *); 267 void deleteIncidence(Incidence *);
268 void cloneIncidence(Incidence *); 268 void cloneIncidence(Incidence *);
269 void cancelIncidence(Incidence *); 269 void cancelIncidence(Incidence *);
270 /** Create an editor for the supplied event. */ 270 /** Create an editor for the supplied event. */
271 void editEvent(Event *); 271 void editEvent(Event *);
272 /** Delete the supplied event. */ 272 /** Delete the supplied event. */
273 void deleteEvent(Event *); 273 void deleteEvent(Event *);
274 /** Delete the event with the given unique ID. Returns false, if event wasn't 274 /** Delete the event with the given unique ID. Returns false, if event wasn't
275 found. */ 275 found. */
276 bool deleteEvent(const QString &uid); 276 bool deleteEvent(const QString &uid);
277 /** Create a read-only viewer dialog for the supplied event. */ 277 /** Create a read-only viewer dialog for the supplied event. */
278 void showEvent(Event *); 278 void showEvent(Event *);
279 279
280 void editJournal(Journal *); 280 void editJournal(Journal *);
281 void showJournal(Journal *); 281 void showJournal(Journal *);
282 void deleteJournal(Journal *); 282 void deleteJournal(Journal *);
283 /** Create an editor dialog for a todo */ 283 /** Create an editor dialog for a todo */
284 void editTodo(Todo *); 284 void editTodo(Todo *);
285 /** Create a read-only viewer dialog for the supplied todo */ 285 /** Create a read-only viewer dialog for the supplied todo */
286 void showTodo(Todo *); 286 void showTodo(Todo *);
287 /** create new todo */ 287 /** create new todo */
288 void newTodo(); 288 void newTodo();
289 void newTodoDateTime(QDateTime, bool allday); 289 void newTodoDateTime(QDateTime, bool allday);
290 /** create new todo with a parent todo */ 290 /** create new todo with a parent todo */
291 void newSubTodo(); 291 void newSubTodo();
292 /** create new todo with a parent todo */ 292 /** create new todo with a parent todo */
293 void newSubTodo(Todo *); 293 void newSubTodo(Todo *);
294 /** Delete todo */ 294 /** Delete todo */
295 void deleteTodo(Todo *); 295 void deleteTodo(Todo *);
296 296
297 297
298 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is 298 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is
299 * emitted as result. */ 299 * emitted as result. */
300 void checkClipboard(); 300 void checkClipboard();
301 301
302 /** using the KConfig associated with the kapp variable, read in the 302 /** using the KConfig associated with the kapp variable, read in the
303 * settings from the config file. 303 * settings from the config file.
304 */ 304 */
305 void readSettings(); 305 void readSettings();
306 306
307 /** write current state to config file. */ 307 /** write current state to config file. */
308 void writeSettings(); 308 void writeSettings();
309 309
310 /** read settings for calendar filters */ 310 /** read settings for calendar filters */
311 void readFilterSettings(KConfig *config); 311 void readFilterSettings(KConfig *config);
312 312
313 /** write settings for calendar filters */ 313 /** write settings for calendar filters */
314 void writeFilterSettings(KConfig *config); 314 void writeFilterSettings(KConfig *config);
315 315
316 /** passes on the message that an event has changed to the currently 316 /** passes on the message that an event has changed to the currently
317 * activated view so that it can make appropriate display changes. */ 317 * activated view so that it can make appropriate display changes. */
318 void changeEventDisplay(Event *, int); 318 void changeEventDisplay(Event *, int);
319 void changeIncidenceDisplay(Incidence *, int); 319 void changeIncidenceDisplay(Incidence *, int);
320 void changeTodoDisplay(Todo *, int); 320 void changeTodoDisplay(Todo *, int);
321 321
322 void eventAdded(Event *); 322 void eventAdded(Event *);
323 void eventChanged(Event *); 323 void eventChanged(Event *);
324 void eventToBeDeleted(Event *); 324 void eventToBeDeleted(Event *);
325 void eventDeleted(); 325 void eventDeleted();
326 326
327 void todoAdded(Todo *); 327 void todoAdded(Todo *);
328 void todoChanged(Todo *); 328 void todoChanged(Todo *);
329 void todoToBeDeleted(Todo *); 329 void todoToBeDeleted(Todo *);
330 void todoDeleted(); 330 void todoDeleted();
331 331
332 void updateView(const QDate &start, const QDate &end); 332 void updateView(const QDate &start, const QDate &end);
333 void updateView(); 333 void updateView();
334 void clearAllViews();
334 335
335 /** Full update of visible todo views */ 336 /** Full update of visible todo views */
336 void updateTodoViews(); 337 void updateTodoViews();
337 338
338 void updateUnmanagedViews(); 339 void updateUnmanagedViews();
339 340
340 /** cut the current appointment to the clipboard */ 341 /** cut the current appointment to the clipboard */
341 void edit_cut(); 342 void edit_cut();
342 343
343 /** copy the current appointment(s) to the clipboard */ 344 /** copy the current appointment(s) to the clipboard */
344 void edit_copy(); 345 void edit_copy();
345 346
346 /** paste the current vobject(s) in the clipboard buffer into calendar */ 347 /** paste the current vobject(s) in the clipboard buffer into calendar */
347 void edit_paste(); 348 void edit_paste();
348 349
349 /** edit viewing and configuration options. */ 350 /** edit viewing and configuration options. */
350 void edit_options(); 351 void edit_options();
351 /** 352 /**
352 Functions for printing, previewing a print, and setting up printing 353 Functions for printing, previewing a print, and setting up printing
353 parameters. 354 parameters.
354 */ 355 */
355 void print(); 356 void print();
356 void printSetup(); 357 void printSetup();
357 void printPreview(); 358 void printPreview();
358 359
359 /** Export as iCalendar file */ 360 /** Export as iCalendar file */
360 void exportICalendar(); 361 void exportICalendar();
361 362
362 /** Export as vCalendar file */ 363 /** Export as vCalendar file */
363 bool exportVCalendar( QString fn); 364 bool exportVCalendar( QString fn);
364 365
365 /** pop up a dialog to show an existing appointment. */ 366 /** pop up a dialog to show an existing appointment. */
366 void appointment_show(); 367 void appointment_show();
367 /** 368 /**
368 * pop up an Appointment Dialog to edit an existing appointment.Get 369 * pop up an Appointment Dialog to edit an existing appointment.Get
369 * information on the appointment from the list of unique IDs that is 370 * information on the appointment from the list of unique IDs that is
370 * currently in the View, called currIds. 371 * currently in the View, called currIds.
371 */ 372 */
372 void appointment_edit(); 373 void appointment_edit();
373 /** 374 /**
374 * pop up dialog confirming deletion of currently selected event in the 375 * pop up dialog confirming deletion of currently selected event in the
375 * View. 376 * View.
376 */ 377 */
377 void appointment_delete(); 378 void appointment_delete();
378 379
379 /** mails the currently selected event to a particular user as a vCalendar 380 /** mails the currently selected event to a particular user as a vCalendar
380 attachment. */ 381 attachment. */
381 void action_mail(); 382 void action_mail();
382 383
383 /* frees a subtodo from it's relation */ 384 /* frees a subtodo from it's relation */
384 void todo_unsub( Todo * ); 385 void todo_unsub( Todo * );
385 void todo_resub( Todo * parent, Todo * sub ); 386 void todo_resub( Todo * parent, Todo * sub );
386 387
387 /** Take ownership of selected event. */ 388 /** Take ownership of selected event. */
388 void takeOverEvent(); 389 void takeOverEvent();
389 390
390 /** Take ownership of all events in calendar. */ 391 /** Take ownership of all events in calendar. */
391 void takeOverCalendar(); 392 void takeOverCalendar();
392 393
393 /** query whether or not the calendar is "dirty". */ 394 /** query whether or not the calendar is "dirty". */
394 bool isModified(); 395 bool isModified();
395 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ 396 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */
396 void setModified(bool modified=true); 397 void setModified(bool modified=true);
397 398
398 /** query if the calendar is read-only. */ 399 /** query if the calendar is read-only. */
399 bool isReadOnly(); 400 bool isReadOnly();
400 /** set state of calendar to read-only */ 401 /** set state of calendar to read-only */
401 void setReadOnly(bool readOnly=true); 402 void setReadOnly(bool readOnly=true);
402 403
403 void eventUpdated(Incidence *); 404 void eventUpdated(Incidence *);
404 405
405 /* iTIP scheduling actions */ 406 /* iTIP scheduling actions */
406 void schedule_publish(Incidence *incidence = 0); 407 void schedule_publish(Incidence *incidence = 0);
407 void schedule_request(Incidence *incidence = 0); 408 void schedule_request(Incidence *incidence = 0);
408 void schedule_refresh(Incidence *incidence = 0); 409 void schedule_refresh(Incidence *incidence = 0);
409 void schedule_cancel(Incidence *incidence = 0); 410 void schedule_cancel(Incidence *incidence = 0);
410 void schedule_add(Incidence *incidence = 0); 411 void schedule_add(Incidence *incidence = 0);
411 void schedule_reply(Incidence *incidence = 0); 412 void schedule_reply(Incidence *incidence = 0);
412 void schedule_counter(Incidence *incidence = 0); 413 void schedule_counter(Incidence *incidence = 0);
413 void schedule_declinecounter(Incidence *incidence = 0); 414 void schedule_declinecounter(Incidence *incidence = 0);
414 void schedule_publish_freebusy(int daysToPublish = 30); 415 void schedule_publish_freebusy(int daysToPublish = 30);
415 416
416 void openAddressbook(); 417 void openAddressbook();
417 418
418 void editFilters(); 419 void editFilters();
419 void toggleFilerEnabled(); 420 void toggleFilerEnabled();
420 QPtrList<CalFilter> filters(); 421 QPtrList<CalFilter> filters();
421 void toggleFilter(); 422 void toggleFilter();
422 void showFilter(bool visible); 423 void showFilter(bool visible);
423 void updateFilter(); 424 void updateFilter();
424 void filterEdited(); 425 void filterEdited();
425 void selectFilter( int ); 426 void selectFilter( int );
426 KOFilterView *filterView(); 427 KOFilterView *filterView();
427 428
428 void showIntro(); 429 void showIntro();
429 430
430 /** Move the curdatepient view date to today */ 431 /** Move the curdatepient view date to today */
431 void goToday(); 432 void goToday();
432 433
433 /** Move to the next date(s) in the current view */ 434 /** Move to the next date(s) in the current view */
434 void goNext(); 435 void goNext();
435 436
436 /** Move to the previous date(s) in the current view */ 437 /** Move to the previous date(s) in the current view */
437 void goPrevious(); 438 void goPrevious();
438 /** Move to the next date(s) in the current view */ 439 /** Move to the next date(s) in the current view */
439 void goNextMonth(); 440 void goNextMonth();
440 441
441 /** Move to the previous date(s) in the current view */ 442 /** Move to the previous date(s) in the current view */
442 void goPreviousMonth(); 443 void goPreviousMonth();
443 444
444 void toggleExpand(); 445 void toggleExpand();
445 void toggleDateNavigatorWidget(); 446 void toggleDateNavigatorWidget();
446 void toggleAllDaySize(); 447 void toggleAllDaySize();
447 void dialogClosing(Incidence *); 448 void dialogClosing(Incidence *);
448 449
449 /** Look for new messages in the inbox */ 450 /** Look for new messages in the inbox */
450 void lookForIncomingMessages(); 451 void lookForIncomingMessages();
451 /** Look for new messages in the outbox */ 452 /** Look for new messages in the outbox */
452 void lookForOutgoingMessages(); 453 void lookForOutgoingMessages();
453 454
454 void processMainViewSelection( Incidence * ); 455 void processMainViewSelection( Incidence * );
455 void processTodoListSelection( Incidence * ); 456 void processTodoListSelection( Incidence * );
456 457
457 void processIncidenceSelection( Incidence * ); 458 void processIncidenceSelection( Incidence * );
458 459
459 void purgeCompleted(); 460 void purgeCompleted();
460 bool removeCompletedSubTodos( Todo* ); 461 bool removeCompletedSubTodos( Todo* );
461 void slotCalendarChanged(); 462 void slotCalendarChanged();
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index fd9bf29..1320a2e 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -1206,256 +1206,263 @@ void KOAgendaView::fillAgenda()
1206 } 1206 }
1207 int startY = mAgenda->timeToY(event->dtStart().time()); 1207 int startY = mAgenda->timeToY(event->dtStart().time());
1208 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1208 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1209 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); 1209 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol );
1210 if ((beginX <= 0 && curCol == 0) || beginX == curCol) { 1210 if ((beginX <= 0 && curCol == 0) || beginX == curCol) {
1211 //qDebug("insert!!! "); 1211 //qDebug("insert!!! ");
1212 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); 1212 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY);
1213 } 1213 }
1214 if (beginX == curCol) { 1214 if (beginX == curCol) {
1215 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1215 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1216 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1216 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1217 } else if (endX == curCol) { 1217 } else if (endX == curCol) {
1218 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1218 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1219 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1219 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1220 } else { 1220 } else {
1221 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1221 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1222 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1222 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1223 } 1223 }
1224 } else { 1224 } else {
1225 int startY = mAgenda->timeToY(event->dtStart().time()); 1225 int startY = mAgenda->timeToY(event->dtStart().time());
1226 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1226 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1227 if (endY < startY) endY = startY; 1227 if (endY < startY) endY = startY;
1228 mAgenda->insertItem(event,currentDate,curCol,startY,endY); 1228 mAgenda->insertItem(event,currentDate,curCol,startY,endY);
1229 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1229 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1230 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1230 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1231 } 1231 }
1232 } 1232 }
1233 // ---------- [display Todos -------------- 1233 // ---------- [display Todos --------------
1234 unsigned int numTodo; 1234 unsigned int numTodo;
1235 for (numTodo = 0; numTodo < todos.count(); ++numTodo) { 1235 for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
1236 Todo *todo = todos.at(numTodo); 1236 Todo *todo = todos.at(numTodo);
1237 1237
1238 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date 1238 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date
1239 if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) continue; 1239 if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) continue;
1240 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1240 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1241 // Already completed items can be displayed on their original due date 1241 // Already completed items can be displayed on their original due date
1242 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda 1242 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
1243 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; 1243 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda;
1244 bool fillIn = false; 1244 bool fillIn = false;
1245 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) 1245 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate )
1246 fillIn = true; 1246 fillIn = true;
1247 if ( ! fillIn && !todo->hasCompletedDate() ) 1247 if ( ! fillIn && !todo->hasCompletedDate() )
1248 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); 1248 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue);
1249 if ( fillIn ) { 1249 if ( fillIn ) {
1250 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue 1250 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue
1251 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1251 if ( KOPrefs::instance()->mShowTodoInAgenda )
1252 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); 1252 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol);
1253 } 1253 }
1254 else { 1254 else {
1255 QDateTime dt; 1255 QDateTime dt;
1256 if ( todo->hasCompletedDate() ) 1256 if ( todo->hasCompletedDate() )
1257 dt = todo->completed(); 1257 dt = todo->completed();
1258 else 1258 else
1259 dt = todo->dtDue();; 1259 dt = todo->dtDue();;
1260 1260
1261 1261
1262 int endY = mAgenda->timeToY(dt.time()) - 1; 1262 int endY = mAgenda->timeToY(dt.time()) - 1;
1263 int hi = (18/KOPrefs::instance()->mHourSize); 1263 int hi = (18/KOPrefs::instance()->mHourSize);
1264 //qDebug("hei %d ",KOPrefs::instance()->mHourSize); 1264 //qDebug("hei %d ",KOPrefs::instance()->mHourSize);
1265 int startY = endY -hi; 1265 int startY = endY -hi;
1266 1266
1267 mAgenda->insertItem(todo,currentDate,curCol,startY,endY); 1267 mAgenda->insertItem(todo,currentDate,curCol,startY,endY);
1268 1268
1269 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1269 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1270 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1270 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1271 } 1271 }
1272 } 1272 }
1273 } 1273 }
1274 // ---------- display Todos] -------------- 1274 // ---------- display Todos] --------------
1275 1275
1276 ++curCol; 1276 ++curCol;
1277 } 1277 }
1278 mAgenda->hideUnused(); 1278 mAgenda->hideUnused();
1279 mAllDayAgenda->hideUnused(); 1279 mAllDayAgenda->hideUnused();
1280 mAgenda->checkScrollBoundaries(); 1280 mAgenda->checkScrollBoundaries();
1281 1281
1282 deleteSelectedDateTime(); 1282 deleteSelectedDateTime();
1283 1283
1284 createDayLabels(); 1284 createDayLabels();
1285 emit incidenceSelected( 0 ); 1285 emit incidenceSelected( 0 );
1286 1286
1287 if ( globalFlagBlockAgenda == 2 ) { 1287 if ( globalFlagBlockAgenda == 2 ) {
1288 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 1288 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
1289 setStartHour( KOPrefs::instance()->mDayBegins ); 1289 setStartHour( KOPrefs::instance()->mDayBegins );
1290 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1290 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
1291 setStartHour( QTime::currentTime ().hour() ); 1291 setStartHour( QTime::currentTime ().hour() );
1292 // qApp->processEvents(); 1292 // qApp->processEvents();
1293 } 1293 }
1294 qApp->processEvents(); 1294 qApp->processEvents();
1295 //qDebug("qApp->processEvents(); END "); 1295 //qDebug("qApp->processEvents(); END ");
1296 globalFlagBlockAgenda = 0; 1296 globalFlagBlockAgenda = 0;
1297 1297
1298 // mAgenda->hideUnused(); 1298 // mAgenda->hideUnused();
1299 //mAllDayAgenda->hideUnused(); 1299 //mAllDayAgenda->hideUnused();
1300 mAllDayAgenda->drawContentsToPainter(); 1300 mAllDayAgenda->drawContentsToPainter();
1301 mAgenda->drawContentsToPainter(); 1301 mAgenda->drawContentsToPainter();
1302 repaintAgenda(); 1302 repaintAgenda();
1303 onlyOne = false; 1303 onlyOne = false;
1304 // mAgenda->finishUpdate(); 1304 // mAgenda->finishUpdate();
1305 //mAllDayAgenda->finishUpdate(); 1305 //mAllDayAgenda->finishUpdate();
1306 1306
1307 // repaintAgenda(); 1307 // repaintAgenda();
1308 //qApp->processEvents(); 1308 //qApp->processEvents();
1309 // globalFlagBlockAgenda = 0; 1309 // globalFlagBlockAgenda = 0;
1310} 1310}
1311void KOAgendaView::repaintAgenda() 1311void KOAgendaView::repaintAgenda()
1312{ 1312{
1313 // mAllDayAgenda->drawContentsToPainter(); 1313 // mAllDayAgenda->drawContentsToPainter();
1314// mAllDayAgenda->viewport()->repaint( false ); 1314// mAllDayAgenda->viewport()->repaint( false );
1315// mAgenda->drawContentsToPainter(); 1315// mAgenda->drawContentsToPainter();
1316// mAgenda->viewport()->repaint( false ); 1316// mAgenda->viewport()->repaint( false );
1317// qApp->processEvents(); 1317// qApp->processEvents();
1318 1318
1319 //qDebug("KOAgendaView::repaintAgenda() "); 1319 //qDebug("KOAgendaView::repaintAgenda() ");
1320 //qApp->processEvents(); 1320 //qApp->processEvents();
1321 mAgenda->viewport()->repaint( false ); 1321 mAgenda->viewport()->repaint( false );
1322 mAllDayAgenda->viewport()->repaint( false ); 1322 mAllDayAgenda->viewport()->repaint( false );
1323 mAgenda->finishUpdate(); 1323 mAgenda->finishUpdate();
1324 mAllDayAgenda->finishUpdate(); 1324 mAllDayAgenda->finishUpdate();
1325} 1325}
1326 1326
1327 1327
1328void KOAgendaView::clearView() 1328void KOAgendaView::clearView()
1329{ 1329{
1330 // kdDebug() << "ClearView" << endl; 1330 // kdDebug() << "ClearView" << endl;
1331 mAllDayAgenda->clear(); 1331 mAllDayAgenda->clear();
1332 mAgenda->clear(); 1332 mAgenda->clear();
1333} 1333}
1334void KOAgendaView::clearList()
1335{
1336 // kdDebug() << "ClearView" << endl;
1337 clearView();
1338 mAllDayAgenda->hideUnused();
1339 mAgenda->hideUnused();
1340}
1334 1341
1335void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1342void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1336 const QDate &td) 1343 const QDate &td)
1337{ 1344{
1338#ifndef KORG_NOPRINTER 1345#ifndef KORG_NOPRINTER
1339 if (fd == td) 1346 if (fd == td)
1340 calPrinter->preview(CalPrinter::Day, fd, td); 1347 calPrinter->preview(CalPrinter::Day, fd, td);
1341 else 1348 else
1342 calPrinter->preview(CalPrinter::Week, fd, td); 1349 calPrinter->preview(CalPrinter::Week, fd, td);
1343#endif 1350#endif
1344} 1351}
1345 1352
1346// void KOAgendaView::updateMovedTodo() 1353// void KOAgendaView::updateMovedTodo()
1347// { 1354// {
1348// // updateConfig(); 1355// // updateConfig();
1349// // emit updateTodoViews(); 1356// // emit updateTodoViews();
1350// } 1357// }
1351 1358
1352void KOAgendaView::slotShowDateView( int mode , int d ) 1359void KOAgendaView::slotShowDateView( int mode , int d )
1353{ 1360{
1354 if ( d >= mSelectedDates.count() ) { 1361 if ( d >= mSelectedDates.count() ) {
1355 qDebug("KOAgendaView::slotShowDateView datecounterror %d d ", d, mSelectedDates.count() ); 1362 qDebug("KOAgendaView::slotShowDateView datecounterror %d d ", d, mSelectedDates.count() );
1356 1363
1357 } else { 1364 } else {
1358 QDate day = mSelectedDates[d]; 1365 QDate day = mSelectedDates[d];
1359 emit showDateView(mode , day ); 1366 emit showDateView(mode , day );
1360 } 1367 }
1361 1368
1362} 1369}
1363void KOAgendaView::newEvent(int gx, int gy) 1370void KOAgendaView::newEvent(int gx, int gy)
1364{ 1371{
1365 if (!mSelectedDates.count()) return; 1372 if (!mSelectedDates.count()) return;
1366 1373
1367 QDate day = mSelectedDates[gx]; 1374 QDate day = mSelectedDates[gx];
1368 1375
1369 QTime time = mAgenda->gyToTime(gy); 1376 QTime time = mAgenda->gyToTime(gy);
1370 QDateTime dt(day,time); 1377 QDateTime dt(day,time);
1371 // if ( dt < QDateTime::currentDateTime () ) 1378 // if ( dt < QDateTime::currentDateTime () )
1372 // dt = QDateTime::currentDateTime ().addSecs( 3600 ); 1379 // dt = QDateTime::currentDateTime ().addSecs( 3600 );
1373 emit newEventSignal(dt); 1380 emit newEventSignal(dt);
1374} 1381}
1375 1382
1376void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) 1383void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd)
1377{ 1384{
1378 if (!mSelectedDates.count()) return; 1385 if (!mSelectedDates.count()) return;
1379 1386
1380 QDate dayStart = mSelectedDates[gxStart]; 1387 QDate dayStart = mSelectedDates[gxStart];
1381 QDate dayEnd = mSelectedDates[gxEnd]; 1388 QDate dayEnd = mSelectedDates[gxEnd];
1382 1389
1383 QTime timeStart = mAgenda->gyToTime(gyStart); 1390 QTime timeStart = mAgenda->gyToTime(gyStart);
1384 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1391 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1385 1392
1386 QDateTime dtStart(dayStart,timeStart); 1393 QDateTime dtStart(dayStart,timeStart);
1387 QDateTime dtEnd(dayEnd,timeEnd); 1394 QDateTime dtEnd(dayEnd,timeEnd);
1388 1395
1389 emit newEventSignal(dtStart,dtEnd); 1396 emit newEventSignal(dtStart,dtEnd);
1390} 1397}
1391 1398
1392void KOAgendaView::newEventAllDay(int gx, int ) 1399void KOAgendaView::newEventAllDay(int gx, int )
1393{ 1400{
1394 if (!mSelectedDates.count()) return; 1401 if (!mSelectedDates.count()) return;
1395 1402
1396 QDate day = mSelectedDates[gx]; 1403 QDate day = mSelectedDates[gx];
1397 1404
1398 emit newEventSignal(day); 1405 emit newEventSignal(day);
1399} 1406}
1400void KOAgendaView::newTodoAllDay(int gx, int ) 1407void KOAgendaView::newTodoAllDay(int gx, int )
1401{ 1408{
1402 if (!mSelectedDates.count()) return; 1409 if (!mSelectedDates.count()) return;
1403 1410
1404 QDateTime day (mSelectedDates[gx] ); 1411 QDateTime day (mSelectedDates[gx] );
1405 emit newTodoSignal(day, true); 1412 emit newTodoSignal(day, true);
1406} 1413}
1407void KOAgendaView::newTodo(int gx, int gy ) 1414void KOAgendaView::newTodo(int gx, int gy )
1408{ 1415{
1409 if (!mSelectedDates.count()) return; 1416 if (!mSelectedDates.count()) return;
1410 QDate dayStart = mSelectedDates[gx]; 1417 QDate dayStart = mSelectedDates[gx];
1411 QTime timeStart = mAgenda->gyToTime(gy); 1418 QTime timeStart = mAgenda->gyToTime(gy);
1412 QDateTime dt (dayStart,timeStart); 1419 QDateTime dt (dayStart,timeStart);
1413 emit newTodoSignal( dt, false ); 1420 emit newTodoSignal( dt, false );
1414} 1421}
1415 1422
1416void KOAgendaView::updateEventIndicatorTop(int newY) 1423void KOAgendaView::updateEventIndicatorTop(int newY)
1417{ 1424{
1418 uint i; 1425 uint i;
1419 for(i=0;i<mMinY.size();++i) { 1426 for(i=0;i<mMinY.size();++i) {
1420 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); 1427 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true);
1421 else mEventIndicatorTop->enableColumn(i,false); 1428 else mEventIndicatorTop->enableColumn(i,false);
1422 } 1429 }
1423 1430
1424 mEventIndicatorTop->update(); 1431 mEventIndicatorTop->update();
1425} 1432}
1426 1433
1427void KOAgendaView::updateEventIndicatorBottom(int newY) 1434void KOAgendaView::updateEventIndicatorBottom(int newY)
1428{ 1435{
1429 uint i; 1436 uint i;
1430 for(i=0;i<mMaxY.size();++i) { 1437 for(i=0;i<mMaxY.size();++i) {
1431 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); 1438 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true);
1432 else mEventIndicatorBottom->enableColumn(i,false); 1439 else mEventIndicatorBottom->enableColumn(i,false);
1433 } 1440 }
1434 1441
1435 mEventIndicatorBottom->update(); 1442 mEventIndicatorBottom->update();
1436} 1443}
1437 1444
1438void KOAgendaView::startDrag(Event *event) 1445void KOAgendaView::startDrag(Event *event)
1439{ 1446{
1440#ifndef KORG_NODND 1447#ifndef KORG_NODND
1441 DndFactory factory( calendar() ); 1448 DndFactory factory( calendar() );
1442 ICalDrag *vd = factory.createDrag(event,this); 1449 ICalDrag *vd = factory.createDrag(event,this);
1443 if (vd->drag()) { 1450 if (vd->drag()) {
1444 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; 1451 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl;
1445 } 1452 }
1446#endif 1453#endif
1447} 1454}
1448 1455
1449void KOAgendaView::readSettings() 1456void KOAgendaView::readSettings()
1450{ 1457{
1451 readSettings(KOGlobals::config()); 1458 readSettings(KOGlobals::config());
1452} 1459}
1453 1460
1454void KOAgendaView::readSettings(KConfig *config) 1461void KOAgendaView::readSettings(KConfig *config)
1455{ 1462{
1456 // kdDebug() << "KOAgendaView::readSettings()" << endl; 1463 // kdDebug() << "KOAgendaView::readSettings()" << endl;
1457 1464
1458 config->setGroup("Views"); 1465 config->setGroup("Views");
1459 1466
1460 //#ifndef KORG_NOSPLITTER 1467 //#ifndef KORG_NOSPLITTER
1461 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); 1468 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView");
diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h
index c6e6602..cc953fc 100644
--- a/korganizer/koagendaview.h
+++ b/korganizer/koagendaview.h
@@ -41,252 +41,253 @@ class QFrame;
41class QLabel; 41class QLabel;
42class QPushButton; 42class QPushButton;
43class CalendarView; 43class CalendarView;
44class KOAgenda; 44class KOAgenda;
45class KOAgendaItem; 45class KOAgendaItem;
46class KConfig; 46class KConfig;
47class KDGanttMinimizeSplitter; 47class KDGanttMinimizeSplitter;
48 48
49class KOAgendaButton : public QPushButton 49class KOAgendaButton : public QPushButton
50{ 50{
51 Q_OBJECT 51 Q_OBJECT
52 public: 52 public:
53 KOAgendaButton( QWidget *parent=0, const char *name=0 ) : 53 KOAgendaButton( QWidget *parent=0, const char *name=0 ) :
54 QPushButton( parent, name ) 54 QPushButton( parent, name )
55 { 55 {
56 mNum = -3; 56 mNum = -3;
57 setFlat( true ); 57 setFlat( true );
58 setFocusPolicy(NoFocus); 58 setFocusPolicy(NoFocus);
59 setSizePolicy(QSizePolicy( QSizePolicy::Expanding ,QSizePolicy::Expanding )); 59 setSizePolicy(QSizePolicy( QSizePolicy::Expanding ,QSizePolicy::Expanding ));
60 connect( this, SIGNAL( clicked() ), this, SLOT ( bClicked() ) ); 60 connect( this, SIGNAL( clicked() ), this, SLOT ( bClicked() ) );
61 }; 61 };
62 62
63 QSize sizeHint () const { return QSize( 5,5) ;} 63 QSize sizeHint () const { return QSize( 5,5) ;}
64 void setNum( int n) { mNum = n; } 64 void setNum( int n) { mNum = n; }
65private slots: 65private slots:
66 void bClicked() {emit numClicked( mNum);} 66 void bClicked() {emit numClicked( mNum);}
67signals: 67signals:
68 void numClicked( int ); 68 void numClicked( int );
69private: 69private:
70 int mNum; 70 int mNum;
71}; 71};
72 72
73class TimeLabels : public QScrollView { 73class TimeLabels : public QScrollView {
74 Q_OBJECT 74 Q_OBJECT
75 public: 75 public:
76 TimeLabels(int rows,QWidget *parent=0,const char *name=0,WFlags f=0); 76 TimeLabels(int rows,QWidget *parent=0,const char *name=0,WFlags f=0);
77 77
78 void setCellHeight(int height); 78 void setCellHeight(int height);
79 79
80 /** Calculates the minimum width */ 80 /** Calculates the minimum width */
81 virtual int minimumWidth() const; 81 virtual int minimumWidth() const;
82 82
83 /** updates widget's internal state */ 83 /** updates widget's internal state */
84 void updateConfig(); 84 void updateConfig();
85 85
86 /** */ 86 /** */
87 void setAgenda(KOAgenda* agenda); 87 void setAgenda(KOAgenda* agenda);
88 88
89 /** */ 89 /** */
90 virtual void paintEvent(QPaintEvent* e); 90 virtual void paintEvent(QPaintEvent* e);
91 void contentsMousePressEvent ( QMouseEvent * ) ; 91 void contentsMousePressEvent ( QMouseEvent * ) ;
92 void contentsMouseReleaseEvent ( QMouseEvent * ); 92 void contentsMouseReleaseEvent ( QMouseEvent * );
93 void contentsMouseMoveEvent ( QMouseEvent * ); 93 void contentsMouseMoveEvent ( QMouseEvent * );
94 94
95 public slots: 95 public slots:
96 /** update time label positions */ 96 /** update time label positions */
97 void positionChanged(); 97 void positionChanged();
98 signals: 98 signals:
99 void scaleChanged(); 99 void scaleChanged();
100 protected: 100 protected:
101 void drawContents(QPainter *p,int cx, int cy, int cw, int ch); 101 void drawContents(QPainter *p,int cx, int cy, int cw, int ch);
102 102
103 private: 103 private:
104 QPixmap myPix; 104 QPixmap myPix;
105 bool mRedrawNeeded; 105 bool mRedrawNeeded;
106 int mMiniWidth; 106 int mMiniWidth;
107 int mMouseDownY; 107 int mMouseDownY;
108 QString mOrgCap; 108 QString mOrgCap;
109 int mRows; 109 int mRows;
110 int mCellHeight; 110 int mCellHeight;
111 111
112 /** */ 112 /** */
113 KOAgenda* mAgenda; 113 KOAgenda* mAgenda;
114}; 114};
115 115
116class EventIndicator : public QFrame { 116class EventIndicator : public QFrame {
117 Q_OBJECT 117 Q_OBJECT
118 public: 118 public:
119 enum Location { Top, Bottom }; 119 enum Location { Top, Bottom };
120 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0); 120 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0);
121 virtual ~EventIndicator(); 121 virtual ~EventIndicator();
122 122
123 void changeColumns(int columns); 123 void changeColumns(int columns);
124 void setPaintWidget( KDGanttMinimizeSplitter* ); 124 void setPaintWidget( KDGanttMinimizeSplitter* );
125 void setXOffset( int ); 125 void setXOffset( int );
126 void enableColumn(int column, bool enable); 126 void enableColumn(int column, bool enable);
127 127
128 protected: 128 protected:
129 void drawContents(QPainter *); 129 void drawContents(QPainter *);
130 130
131 private: 131 private:
132 int mXOffset; 132 int mXOffset;
133 KDGanttMinimizeSplitter* mPaintWidget; 133 KDGanttMinimizeSplitter* mPaintWidget;
134 int mColumns; 134 int mColumns;
135 QHBox *mTopBox; 135 QHBox *mTopBox;
136 QBoxLayout *mTopLayout; 136 QBoxLayout *mTopLayout;
137 Location mLocation; 137 Location mLocation;
138 QPixmap mPixmap; 138 QPixmap mPixmap;
139 QMemArray<bool> mEnabled; 139 QMemArray<bool> mEnabled;
140}; 140};
141 141
142/** 142/**
143 KOAgendaView is the agenda-like view used to display events in an one or 143 KOAgendaView is the agenda-like view used to display events in an one or
144 multi-day view. 144 multi-day view.
145*/ 145*/
146class KOAgendaView : public KOEventView { 146class KOAgendaView : public KOEventView {
147 Q_OBJECT 147 Q_OBJECT
148 public: 148 public:
149 KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 ); 149 KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 );
150 virtual ~KOAgendaView(); 150 virtual ~KOAgendaView();
151 void setStartHour( int ); 151 void setStartHour( int );
152 void toggleAllDay(); 152 void toggleAllDay();
153 153
154 154
155 /** Returns maximum number of days supported by the koagendaview */ 155 /** Returns maximum number of days supported by the koagendaview */
156 virtual int maxDatesHint(); 156 virtual int maxDatesHint();
157 157
158 /** Returns number of currently shown dates. */ 158 /** Returns number of currently shown dates. */
159 virtual int currentDateCount(); 159 virtual int currentDateCount();
160 160
161 /** returns the currently selected events */ 161 /** returns the currently selected events */
162 virtual QPtrList<Incidence> selectedIncidences(); 162 virtual QPtrList<Incidence> selectedIncidences();
163 163
164 /** returns the currently selected events */ 164 /** returns the currently selected events */
165 virtual DateList selectedDates(); 165 virtual DateList selectedDates();
166 166
167 /** Remove all events from view */ 167 /** Remove all events from view */
168 void clearView(); 168 void clearView();
169 void clearList();
169 KOAgenda *agenda() { return mAgenda;} 170 KOAgenda *agenda() { return mAgenda;}
170 virtual void printPreview(CalPrinter *calPrinter, 171 virtual void printPreview(CalPrinter *calPrinter,
171 const QDate &, const QDate &); 172 const QDate &, const QDate &);
172 173
173 /** start-datetime of selection */ 174 /** start-datetime of selection */
174 QDateTime selectionStart() {return mTimeSpanBegin;} 175 QDateTime selectionStart() {return mTimeSpanBegin;}
175 /** end-datetime of selection */ 176 /** end-datetime of selection */
176 QDateTime selectionEnd() {return mTimeSpanEnd;} 177 QDateTime selectionEnd() {return mTimeSpanEnd;}
177 /** returns true if selection is for whole day */ 178 /** returns true if selection is for whole day */
178 bool selectedIsAllDay() {return mTimeSpanInAllDay;} 179 bool selectedIsAllDay() {return mTimeSpanInAllDay;}
179 /** make selected start/end invalid */ 180 /** make selected start/end invalid */
180 void deleteSelectedDateTime(); 181 void deleteSelectedDateTime();
181 void repaintAgenda(); 182 void repaintAgenda();
182 public slots: 183 public slots:
183 void setInitStartHour(); 184 void setInitStartHour();
184 virtual void updateView(); 185 virtual void updateView();
185 virtual void updateConfig(); 186 virtual void updateConfig();
186 virtual void showDates(const QDate &start, const QDate &end); 187 virtual void showDates(const QDate &start, const QDate &end);
187 virtual void showEvents(QPtrList<Event> eventList); 188 virtual void showEvents(QPtrList<Event> eventList);
188 189
189 void updateTodo( Todo *, int ); 190 void updateTodo( Todo *, int );
190 void changeEventDisplay(Event *, int); 191 void changeEventDisplay(Event *, int);
191 192
192 void clearSelection(); 193 void clearSelection();
193 194
194 void newTodo(int gx,int gy); 195 void newTodo(int gx,int gy);
195 void newEvent(int gx,int gy); 196 void newEvent(int gx,int gy);
196 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd); 197 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd);
197 void newEventAllDay(int gx, int gy); 198 void newEventAllDay(int gx, int gy);
198 void newTodoAllDay(int gx, int gy); 199 void newTodoAllDay(int gx, int gy);
199 200
200 void startDrag(Event *); 201 void startDrag(Event *);
201 202
202 void readSettings(); 203 void readSettings();
203 void readSettings(KConfig *); 204 void readSettings(KConfig *);
204 void writeSettings(KConfig *); 205 void writeSettings(KConfig *);
205 206
206 void setContentsPos(int y); 207 void setContentsPos(int y);
207 208
208 void scrollOneHourUp(); 209 void scrollOneHourUp();
209 void scrollOneHourDown(); 210 void scrollOneHourDown();
210 void addToCalSlot(Incidence *, Incidence *); 211 void addToCalSlot(Incidence *, Incidence *);
211 void slotShowDateView( int, int ); 212 void slotShowDateView( int, int );
212 213
213 signals: 214 signals:
214 void showDateView( int, QDate ); 215 void showDateView( int, QDate );
215 void newTodoSignal( QDateTime ,bool ); 216 void newTodoSignal( QDateTime ,bool );
216 void toggleExpand(); 217 void toggleExpand();
217 void selectWeekNum( int ); 218 void selectWeekNum( int );
218 void todoMoved( Todo *, int ); 219 void todoMoved( Todo *, int );
219 void incidenceChanged(Incidence * , int ); 220 void incidenceChanged(Incidence * , int );
220 // void cloneIncidenceSignal(Incidence *); 221 // void cloneIncidenceSignal(Incidence *);
221 222
222 protected: 223 protected:
223 KOAgendaButton* getNewDaylabel(); 224 KOAgendaButton* getNewDaylabel();
224 bool mBlockUpdating; 225 bool mBlockUpdating;
225 int mUpcomingWidth; 226 int mUpcomingWidth;
226 /** Fill agenda beginning with date startDate */ 227 /** Fill agenda beginning with date startDate */
227 void fillAgenda(const QDate &startDate); 228 void fillAgenda(const QDate &startDate);
228 void resizeEvent( QResizeEvent* e ); 229 void resizeEvent( QResizeEvent* e );
229 /** Fill agenda using the current set value for the start date */ 230 /** Fill agenda using the current set value for the start date */
230 void fillAgenda(); 231 void fillAgenda();
231 232
232 /** Create labels for the selected dates. */ 233 /** Create labels for the selected dates. */
233 void createDayLabels(); 234 void createDayLabels();
234 235
235 /** 236 /**
236 Set the masks on the agenda widgets indicating, which days are holidays. 237 Set the masks on the agenda widgets indicating, which days are holidays.
237 */ 238 */
238 void setHolidayMasks(); 239 void setHolidayMasks();
239 240
240 protected slots: 241 protected slots:
241 void slotDaylabelClicked( int ); 242 void slotDaylabelClicked( int );
242 /** Update event belonging to agenda item */ 243 /** Update event belonging to agenda item */
243 void updateEventDates(KOAgendaItem *item, int mode = -1); 244 void updateEventDates(KOAgendaItem *item, int mode = -1);
244 //void updateMovedTodo(); 245 //void updateMovedTodo();
245 246
246 void updateEventIndicatorTop(int newY); 247 void updateEventIndicatorTop(int newY);
247 void updateEventIndicatorBottom(int newY); 248 void updateEventIndicatorBottom(int newY);
248 249
249 /** Updates data for selected timespan */ 250 /** Updates data for selected timespan */
250 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd); 251 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd);
251 /** Updates data for selected timespan for all day event*/ 252 /** Updates data for selected timespan for all day event*/
252 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd); 253 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd);
253 254
254 private: 255 private:
255 // view widgets 256 // view widgets
256 QFrame *mDayLabels; 257 QFrame *mDayLabels;
257 QHBox *mDayLabelsFrame; 258 QHBox *mDayLabelsFrame;
258 QBoxLayout *mLayoutDayLabels; 259 QBoxLayout *mLayoutDayLabels;
259 QFrame *mAllDayFrame; 260 QFrame *mAllDayFrame;
260 KOAgenda *mAllDayAgenda; 261 KOAgenda *mAllDayAgenda;
261 KOAgenda *mAgenda; 262 KOAgenda *mAgenda;
262 TimeLabels *mTimeLabels; 263 TimeLabels *mTimeLabels;
263 QWidget *mDummyAllDayLeft; 264 QWidget *mDummyAllDayLeft;
264 265
265 KDGanttMinimizeSplitter* mSplitterAgenda; 266 KDGanttMinimizeSplitter* mSplitterAgenda;
266 QPushButton *mExpandButton; 267 QPushButton *mExpandButton;
267 268
268 DateList mSelectedDates; // List of dates to be displayed 269 DateList mSelectedDates; // List of dates to be displayed
269 int mViewType; 270 int mViewType;
270 271
271 bool mWeekStartsMonday; 272 bool mWeekStartsMonday;
272 int mStartHour; 273 int mStartHour;
273 274
274 KOEventPopupMenu *mAllAgendaPopup; 275 KOEventPopupMenu *mAllAgendaPopup;
275 //KOEventPopupMenu *mAllDayAgendaPopup; 276 //KOEventPopupMenu *mAllDayAgendaPopup;
276 277
277 EventIndicator *mEventIndicatorTop; 278 EventIndicator *mEventIndicatorTop;
278 EventIndicator *mEventIndicatorBottom; 279 EventIndicator *mEventIndicatorBottom;
279 280
280 QMemArray<int> mMinY; 281 QMemArray<int> mMinY;
281 QMemArray<int> mMaxY; 282 QMemArray<int> mMaxY;
282 283
283 QMemArray<bool> mHolidayMask; 284 QMemArray<bool> mHolidayMask;
284 285
285 QPtrList<KOAgendaButton> mDayLabelsList; 286 QPtrList<KOAgendaButton> mDayLabelsList;
286 QDateTime mTimeSpanBegin; 287 QDateTime mTimeSpanBegin;
287 QDateTime mTimeSpanEnd; 288 QDateTime mTimeSpanEnd;
288 bool mTimeSpanInAllDay; 289 bool mTimeSpanInAllDay;
289 void keyPressEvent ( QKeyEvent * e ); 290 void keyPressEvent ( QKeyEvent * e );
290}; 291};
291 292
292#endif // KOAGENDAVIEW_H 293#endif // KOAGENDAVIEW_H
diff --git a/korganizer/kojournalview.cpp b/korganizer/kojournalview.cpp
index 6e6a939..bc16037 100644
--- a/korganizer/kojournalview.cpp
+++ b/korganizer/kojournalview.cpp
@@ -1,112 +1,116 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24// 24//
25// View of Journal entries 25// View of Journal entries
26 26
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qpopupmenu.h> 28#include <qpopupmenu.h>
29 29
30#include <klocale.h> 30#include <klocale.h>
31#include <kdebug.h> 31#include <kdebug.h>
32#include "koprefs.h" 32#include "koprefs.h"
33 33
34#include <libkcal/calendar.h> 34#include <libkcal/calendar.h>
35 35
36#include "journalentry.h" 36#include "journalentry.h"
37 37
38#include "kojournalview.h" 38#include "kojournalview.h"
39using namespace KOrg; 39using namespace KOrg;
40 40
41KOJournalView::KOJournalView(Calendar *calendar, QWidget *parent, 41KOJournalView::KOJournalView(Calendar *calendar, QWidget *parent,
42 const char *name) 42 const char *name)
43 : KOrg::BaseView(calendar, parent, name) 43 : KOrg::BaseView(calendar, parent, name)
44{ 44{
45 mEntry = new JournalEntry(calendar,this); 45 mEntry = new JournalEntry(calendar,this);
46 mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); 46 mEntry->setFont ( KOPrefs::instance()->mJornalViewFont );
47 QBoxLayout *topLayout = new QVBoxLayout(this); 47 QBoxLayout *topLayout = new QVBoxLayout(this);
48 topLayout->addWidget(mEntry); 48 topLayout->addWidget(mEntry);
49 connect ( mEntry,SIGNAL(deleteJournal(Journal *) ),this ,SIGNAL(deleteJournal(Journal *) ) ) ; 49 connect ( mEntry,SIGNAL(deleteJournal(Journal *) ),this ,SIGNAL(deleteJournal(Journal *) ) ) ;
50} 50}
51 51
52KOJournalView::~KOJournalView() 52KOJournalView::~KOJournalView()
53{ 53{
54} 54}
55 55
56int KOJournalView::currentDateCount() 56int KOJournalView::currentDateCount()
57{ 57{
58 return 0; 58 return 0;
59} 59}
60 60
61QPtrList<Incidence> KOJournalView::selectedIncidences() 61QPtrList<Incidence> KOJournalView::selectedIncidences()
62{ 62{
63 QPtrList<Incidence> eventList; 63 QPtrList<Incidence> eventList;
64 64
65 return eventList; 65 return eventList;
66} 66}
67void KOJournalView::updateConfig() 67void KOJournalView::updateConfig()
68{ 68{
69 mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); 69 mEntry->setFont ( KOPrefs::instance()->mJornalViewFont );
70} 70}
71void KOJournalView::updateView() 71void KOJournalView::updateView()
72{ 72{
73 mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); 73 mEntry->setFont ( KOPrefs::instance()->mJornalViewFont );
74} 74}
75 75
76void KOJournalView::flushView() 76void KOJournalView::flushView()
77{ 77{
78 mEntry->flushEntry(); 78 mEntry->flushEntry();
79} 79}
80 80
81void KOJournalView::clearList()
82{
83 mEntry->clear();
84}
81void KOJournalView::showDates(const QDate &start, const QDate &) 85void KOJournalView::showDates(const QDate &start, const QDate &)
82{ 86{
83// kdDebug() << "KOJournalView::selectDates()" << endl; 87// kdDebug() << "KOJournalView::selectDates()" << endl;
84 88
85 mEntry->setDate(start); 89 mEntry->setDate(start);
86 90
87 Journal *j = calendar()->journal(start); 91 Journal *j = calendar()->journal(start);
88 if (j) mEntry->setJournal(j); 92 if (j) mEntry->setJournal(j);
89 else mEntry->clear(); 93 else mEntry->clear();
90 94
91// emit incidenceSelected( 0 ); 95// emit incidenceSelected( 0 );
92} 96}
93 97
94void KOJournalView::showEvents(QPtrList<Event>) 98void KOJournalView::showEvents(QPtrList<Event>)
95{ 99{
96 // After new creation of list view no events are selected. 100 // After new creation of list view no events are selected.
97// emit incidenceSelected( 0 ); 101// emit incidenceSelected( 0 );
98} 102}
99 103
100void KOJournalView::changeEventDisplay(Event *, int /*action*/) 104void KOJournalView::changeEventDisplay(Event *, int /*action*/)
101{ 105{
102 updateView(); 106 updateView();
103} 107}
104 108
105void KOJournalView::keyPressEvent ( QKeyEvent * e ) 109void KOJournalView::keyPressEvent ( QKeyEvent * e )
106{ 110{
107 //qDebug("keyPressEven "); 111 //qDebug("keyPressEven ");
108 if ( e->state() == Qt::ControlButton ) { 112 if ( e->state() == Qt::ControlButton ) {
109 if ( e->key () == Qt::Key_Right || e->key () == Qt::Key_Left ) 113 if ( e->key () == Qt::Key_Right || e->key () == Qt::Key_Left )
110 e->ignore(); 114 e->ignore();
111 } 115 }
112} 116}
diff --git a/korganizer/kojournalview.h b/korganizer/kojournalview.h
index 1c0be82..445f940 100644
--- a/korganizer/kojournalview.h
+++ b/korganizer/kojournalview.h
@@ -1,67 +1,68 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef _KOJOURNALVIEW_H 23#ifndef _KOJOURNALVIEW_H
24#define _KOJOURNALVIEW_H 24#define _KOJOURNALVIEW_H
25 25
26#include <korganizer/baseview.h> 26#include <korganizer/baseview.h>
27 27
28class JournalEntry; 28class JournalEntry;
29 29
30/** 30/**
31 * This class provides a journal view. 31 * This class provides a journal view.
32 32
33 * @short View for Journal components. 33 * @short View for Journal components.
34 * @author Cornelius Schumacher <schumacher@kde.org> 34 * @author Cornelius Schumacher <schumacher@kde.org>
35 * @see KOBaseView 35 * @see KOBaseView
36 */ 36 */
37class KOJournalView : public KOrg::BaseView 37class KOJournalView : public KOrg::BaseView
38{ 38{
39 Q_OBJECT 39 Q_OBJECT
40 public: 40 public:
41 KOJournalView(Calendar *calendar, QWidget *parent = 0, 41 KOJournalView(Calendar *calendar, QWidget *parent = 0,
42 const char *name = 0); 42 const char *name = 0);
43 ~KOJournalView(); 43 ~KOJournalView();
44 44
45 virtual int currentDateCount(); 45 virtual int currentDateCount();
46 void clearList();
46 virtual QPtrList<Incidence> selectedIncidences(); 47 virtual QPtrList<Incidence> selectedIncidences();
47 DateList selectedDates() 48 DateList selectedDates()
48 {DateList q; 49 {DateList q;
49 return q;}; 50 return q;};
50 signals: 51 signals:
51 void deleteJournal(Journal *); 52 void deleteJournal(Journal *);
52 public slots: 53 public slots:
53 void updateView(); 54 void updateView();
54 void flushView(); 55 void flushView();
55 void updateConfig(); 56 void updateConfig();
56 void showDates( const QDate &start, const QDate &end ); 57 void showDates( const QDate &start, const QDate &end );
57 void showEvents(QPtrList<Event> eventList); 58 void showEvents(QPtrList<Event> eventList);
58 59
59 void changeEventDisplay(Event *, int); 60 void changeEventDisplay(Event *, int);
60 61
61 private: 62 private:
62 JournalEntry *mEntry; 63 JournalEntry *mEntry;
63 void keyPressEvent ( QKeyEvent * ) ; 64 void keyPressEvent ( QKeyEvent * ) ;
64 65
65}; 66};
66 67
67#endif 68#endif
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index 5f32e79..bc52281 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -238,256 +238,260 @@ KOListView::KOListView(Calendar *calendar, QWidget *parent,
238 mActiveItem = 0; 238 mActiveItem = 0;
239 mListView = new KOListViewListView(this); 239 mListView = new KOListViewListView(this);
240 mListView->addColumn(i18n("Summary")); 240 mListView->addColumn(i18n("Summary"));
241 mListView->addColumn(i18n("Start Date")); 241 mListView->addColumn(i18n("Start Date"));
242 mListView->addColumn(i18n("Start Time")); 242 mListView->addColumn(i18n("Start Time"));
243 mListView->addColumn(i18n("End Date")); 243 mListView->addColumn(i18n("End Date"));
244 mListView->addColumn(i18n("End Time")); 244 mListView->addColumn(i18n("End Time"));
245 mListView->addColumn(i18n("Alarm")); // alarm set? 245 mListView->addColumn(i18n("Alarm")); // alarm set?
246 mListView->addColumn(i18n("Recurs")); // recurs? 246 mListView->addColumn(i18n("Recurs")); // recurs?
247 mListView->addColumn(i18n("Due Date")); 247 mListView->addColumn(i18n("Due Date"));
248 mListView->addColumn(i18n("Due Time")); 248 mListView->addColumn(i18n("Due Time"));
249 mListView->addColumn(i18n("Cancelled")); 249 mListView->addColumn(i18n("Cancelled"));
250 mListView->addColumn(i18n("Categories")); 250 mListView->addColumn(i18n("Categories"));
251 251
252 mListView->setColumnAlignment(0,AlignLeft); 252 mListView->setColumnAlignment(0,AlignLeft);
253 mListView->setColumnAlignment(1,AlignLeft); 253 mListView->setColumnAlignment(1,AlignLeft);
254 mListView->setColumnAlignment(2,AlignHCenter); 254 mListView->setColumnAlignment(2,AlignHCenter);
255 mListView->setColumnAlignment(3,AlignLeft); 255 mListView->setColumnAlignment(3,AlignLeft);
256 mListView->setColumnAlignment(4,AlignHCenter); 256 mListView->setColumnAlignment(4,AlignHCenter);
257 mListView->setColumnAlignment(5,AlignLeft); 257 mListView->setColumnAlignment(5,AlignLeft);
258 mListView->setColumnAlignment(6,AlignLeft); 258 mListView->setColumnAlignment(6,AlignLeft);
259 mListView->setColumnAlignment(7,AlignLeft); 259 mListView->setColumnAlignment(7,AlignLeft);
260 mListView->setColumnAlignment(8,AlignLeft); 260 mListView->setColumnAlignment(8,AlignLeft);
261 mListView->setColumnAlignment(9,AlignLeft); 261 mListView->setColumnAlignment(9,AlignLeft);
262 mListView->setColumnAlignment(10,AlignLeft); 262 mListView->setColumnAlignment(10,AlignLeft);
263 mListView->setColumnWidthMode(10, QListView::Manual); 263 mListView->setColumnWidthMode(10, QListView::Manual);
264 mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this); 264 mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this);
265 265
266 int iii = 0; 266 int iii = 0;
267 for ( iii = 0; iii< 10 ; ++iii ) 267 for ( iii = 0; iii< 10 ; ++iii )
268 mListView->setColumnWidthMode( iii, QListView::Manual ); 268 mListView->setColumnWidthMode( iii, QListView::Manual );
269 269
270 QBoxLayout *layoutTop = new QVBoxLayout(this); 270 QBoxLayout *layoutTop = new QVBoxLayout(this);
271 layoutTop->addWidget(mListView); 271 layoutTop->addWidget(mListView);
272 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 272 mListView->setFont ( KOPrefs::instance()->mListViewFont );
273 mPopupMenu = eventPopup(); 273 mPopupMenu = eventPopup();
274 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 274 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
275 i18n("Select all"),this, 275 i18n("Select all"),this,
276 SLOT(allSelection()),true); 276 SLOT(allSelection()),true);
277 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 277 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
278 i18n("Deselect all"),this, 278 i18n("Deselect all"),this,
279 SLOT(clearSelection()),true); 279 SLOT(clearSelection()),true);
280 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 280 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
281 i18n("Delete all selected"),this, 281 i18n("Delete all selected"),this,
282 SLOT(deleteAll()),true); 282 SLOT(deleteAll()),true);
283 mPopupMenu->insertSeparator(); 283 mPopupMenu->insertSeparator();
284 QPopupMenu * exportPO = new QPopupMenu ( this ); 284 QPopupMenu * exportPO = new QPopupMenu ( this );
285 mPopupMenu->insertItem( i18n("Export selected"), exportPO ); 285 mPopupMenu->insertItem( i18n("Export selected"), exportPO );
286 exportPO->insertItem( i18n("As iCal (ics) file..."),this, 286 exportPO->insertItem( i18n("As iCal (ics) file..."),this,
287 SLOT(saveToFile())); 287 SLOT(saveToFile()));
288 exportPO->insertItem( i18n("As vCal (vcs) file..."),this, 288 exportPO->insertItem( i18n("As vCal (vcs) file..."),this,
289 SLOT(saveToFileVCS())); 289 SLOT(saveToFileVCS()));
290 exportPO->insertItem( i18n("Journal/Details..."),this, 290 exportPO->insertItem( i18n("Journal/Details..."),this,
291 SLOT(saveDescriptionToFile())); 291 SLOT(saveDescriptionToFile()));
292 // mPopupMenu->insertSeparator(); 292 // mPopupMenu->insertSeparator();
293 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 293 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
294 i18n("Add Categ. to selected..."),this, 294 i18n("Add Categ. to selected..."),this,
295 SLOT(addCat()),true); 295 SLOT(addCat()),true);
296 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 296 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
297 i18n("Set Categ. for selected..."),this, 297 i18n("Set Categ. for selected..."),this,
298 SLOT(setCat()),true); 298 SLOT(setCat()),true);
299 //mPopupMenu->insertSeparator(); 299 //mPopupMenu->insertSeparator();
300 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 300 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
301 i18n("Set alarm for selected..."),this, 301 i18n("Set alarm for selected..."),this,
302 SLOT(setAlarm()),true); 302 SLOT(setAlarm()),true);
303 303
304 304
305#ifndef DESKTOP_VERSION 305#ifndef DESKTOP_VERSION
306 mPopupMenu->insertSeparator(); 306 mPopupMenu->insertSeparator();
307 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 307 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
308 i18n("Beam selected via IR"),this, 308 i18n("Beam selected via IR"),this,
309 SLOT(beamSelected()),true); 309 SLOT(beamSelected()),true);
310#endif 310#endif
311 /* 311 /*
312 mPopupMenu = new QPopupMenu; 312 mPopupMenu = new QPopupMenu;
313 mPopupMenu->insertItem(i18n("Edit Event"), this, 313 mPopupMenu->insertItem(i18n("Edit Event"), this,
314 SLOT (editEvent())); 314 SLOT (editEvent()));
315 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, 315 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this,
316 SLOT (deleteEvent())); 316 SLOT (deleteEvent()));
317 mPopupMenu->insertSeparator(); 317 mPopupMenu->insertSeparator();
318 mPopupMenu->insertItem(i18n("Show Dates"), this, 318 mPopupMenu->insertItem(i18n("Show Dates"), this,
319 SLOT(showDates())); 319 SLOT(showDates()));
320 mPopupMenu->insertItem(i18n("Hide Dates"), this, 320 mPopupMenu->insertItem(i18n("Hide Dates"), this,
321 SLOT(hideDates())); 321 SLOT(hideDates()));
322 */ 322 */
323 QObject::connect(mListView,SIGNAL( newEvent()), 323 QObject::connect(mListView,SIGNAL( newEvent()),
324 this,SIGNAL(signalNewEvent())); 324 this,SIGNAL(signalNewEvent()));
325 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), 325 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)),
326 this,SLOT(defaultItemAction(QListViewItem *))); 326 this,SLOT(defaultItemAction(QListViewItem *)));
327 QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *, 327 QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *,
328 const QPoint &, int )), 328 const QPoint &, int )),
329 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); 329 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int)));
330 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), 330 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)),
331 SLOT(processSelectionChange(QListViewItem *))); 331 SLOT(processSelectionChange(QListViewItem *)));
332 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), 332 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)),
333 SIGNAL(showIncidenceSignal(Incidence *)) ); 333 SIGNAL(showIncidenceSignal(Incidence *)) );
334 334
335 readSettings(KOGlobals::config(),"KOListView Layout"); 335 readSettings(KOGlobals::config(),"KOListView Layout");
336} 336}
337 337
338KOListView::~KOListView() 338KOListView::~KOListView()
339{ 339{
340 delete mPopupMenu; 340 delete mPopupMenu;
341#if QT_VERSION >= 0x030000 341#if QT_VERSION >= 0x030000
342 342
343#else 343#else
344 delete mKOListViewWhatsThis; 344 delete mKOListViewWhatsThis;
345#endif 345#endif
346} 346}
347 347
348QString KOListView::getWhatsThisText(QPoint p) 348QString KOListView::getWhatsThisText(QPoint p)
349{ 349{
350 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); 350 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p );
351 if ( item ) 351 if ( item )
352 return KIncidenceFormatter::instance()->getFormattedText( item->data(), 352 return KIncidenceFormatter::instance()->getFormattedText( item->data(),
353 KOPrefs::instance()->mWTshowDetails, 353 KOPrefs::instance()->mWTshowDetails,
354 KOPrefs::instance()->mWTshowCreated, 354 KOPrefs::instance()->mWTshowCreated,
355 KOPrefs::instance()->mWTshowChanged); 355 KOPrefs::instance()->mWTshowChanged);
356 return i18n("That is the list view" ); 356 return i18n("That is the list view" );
357 357
358} 358}
359 359
360void KOListView::updateList() 360void KOListView::updateList()
361{ 361{
362 // qDebug(" KOListView::updateList() "); 362 // qDebug(" KOListView::updateList() ");
363 363
364} 364}
365 365
366void KOListView::clearList()
367{
368 clear ();
369}
366void KOListView::addCat( ) 370void KOListView::addCat( )
367{ 371{
368 setCategories( false ); 372 setCategories( false );
369} 373}
370void KOListView::setCat() 374void KOListView::setCat()
371{ 375{
372 setCategories( true ); 376 setCategories( true );
373} 377}
374void KOListView::setAlarm() 378void KOListView::setAlarm()
375{ 379{
376 KOAlarmPrefs kap( this); 380 KOAlarmPrefs kap( this);
377 if ( !kap.exec() ) 381 if ( !kap.exec() )
378 return; 382 return;
379 QStringList itemList; 383 QStringList itemList;
380 QPtrList<KOListViewItem> sel ; 384 QPtrList<KOListViewItem> sel ;
381 QListViewItem *qitem = mListView->firstChild (); 385 QListViewItem *qitem = mListView->firstChild ();
382 while ( qitem ) { 386 while ( qitem ) {
383 if ( qitem->isSelected() ) { 387 if ( qitem->isSelected() ) {
384 Incidence* inc = ((KOListViewItem *) qitem)->data(); 388 Incidence* inc = ((KOListViewItem *) qitem)->data();
385 if ( inc->type() != "Journal" ) { 389 if ( inc->type() != "Journal" ) {
386 if ( inc->type() == "Todo" ) { 390 if ( inc->type() == "Todo" ) {
387 if ( ((Todo*)inc)->hasDueDate() ) 391 if ( ((Todo*)inc)->hasDueDate() )
388 sel.append(((KOListViewItem *)qitem)); 392 sel.append(((KOListViewItem *)qitem));
389 } else 393 } else
390 sel.append(((KOListViewItem *)qitem)); 394 sel.append(((KOListViewItem *)qitem));
391 } 395 }
392 } 396 }
393 qitem = qitem->nextSibling(); 397 qitem = qitem->nextSibling();
394 } 398 }
395 int count = 0; 399 int count = 0;
396 KOListViewItem * item, *temp; 400 KOListViewItem * item, *temp;
397 item = sel.first(); 401 item = sel.first();
398 Incidence* inc; 402 Incidence* inc;
399 while ( item ) { 403 while ( item ) {
400 inc = item->data(); 404 inc = item->data();
401 ++count; 405 ++count;
402 if (kap.mAlarmButton->isChecked()) { 406 if (kap.mAlarmButton->isChecked()) {
403 if (inc->alarms().count() == 0) 407 if (inc->alarms().count() == 0)
404 inc->newAlarm(); 408 inc->newAlarm();
405 QPtrList<Alarm> alarms = inc->alarms(); 409 QPtrList<Alarm> alarms = inc->alarms();
406 Alarm *alarm; 410 Alarm *alarm;
407 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { 411 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) {
408 alarm->setEnabled(true); 412 alarm->setEnabled(true);
409 int j = kap.mAlarmTimeEdit->value()* -60; 413 int j = kap.mAlarmTimeEdit->value()* -60;
410 if (kap.mAlarmIncrCombo->currentItem() == 1) 414 if (kap.mAlarmIncrCombo->currentItem() == 1)
411 j = j * 60; 415 j = j * 60;
412 else if (kap.mAlarmIncrCombo->currentItem() == 2) 416 else if (kap.mAlarmIncrCombo->currentItem() == 2)
413 j = j * (60 * 24); 417 j = j * (60 * 24);
414 alarm->setStartOffset( j ); 418 alarm->setStartOffset( j );
415 419
416 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { 420 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) {
417 alarm->setProcedureAlarm(kap.mAlarmProgram); 421 alarm->setProcedureAlarm(kap.mAlarmProgram);
418 } 422 }
419 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) 423 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn())
420 alarm->setAudioAlarm(kap.mAlarmSound); 424 alarm->setAudioAlarm(kap.mAlarmSound);
421 else 425 else
422 alarm->setType(Alarm::Invalid); 426 alarm->setType(Alarm::Invalid);
423 //alarm->setAudioAlarm("default"); 427 //alarm->setAudioAlarm("default");
424 // TODO: Deal with multiple alarms 428 // TODO: Deal with multiple alarms
425 break; // For now, stop after the first alarm 429 break; // For now, stop after the first alarm
426 } 430 }
427 } else { 431 } else {
428 Alarm* alarm = inc->alarms().first(); 432 Alarm* alarm = inc->alarms().first();
429 if ( alarm ) { 433 if ( alarm ) {
430 alarm->setEnabled(false); 434 alarm->setEnabled(false);
431 alarm->setType(Alarm::Invalid); 435 alarm->setType(Alarm::Invalid);
432 } 436 }
433 } 437 }
434 ListItemVisitor v(item, mStartDate ); 438 ListItemVisitor v(item, mStartDate );
435 inc->accept(v); 439 inc->accept(v);
436 item = sel.next(); 440 item = sel.next();
437 } 441 }
438 topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) ); 442 topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) );
439 qDebug("KO: Set alarm for %d items", count); 443 qDebug("KO: Set alarm for %d items", count);
440 calendar()->reInitAlarmSettings(); 444 calendar()->reInitAlarmSettings();
441 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 445 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
442} 446}
443void KOListView::setCategories( bool removeOld ) 447void KOListView::setCategories( bool removeOld )
444{ 448{
445 449
446 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); 450 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
447 csd->setColorEnabled(); 451 csd->setColorEnabled();
448 if (! csd->exec()) { 452 if (! csd->exec()) {
449 delete csd; 453 delete csd;
450 return; 454 return;
451 } 455 }
452 QStringList catList = csd->selectedCategories(); 456 QStringList catList = csd->selectedCategories();
453 delete csd; 457 delete csd;
454 // if ( catList.count() == 0 ) 458 // if ( catList.count() == 0 )
455 // return; 459 // return;
456 //catList.sort(); 460 //catList.sort();
457 QString categoriesStr = catList.join(","); 461 QString categoriesStr = catList.join(",");
458 int i; 462 int i;
459 QStringList itemList; 463 QStringList itemList;
460 QPtrList<KOListViewItem> sel ; 464 QPtrList<KOListViewItem> sel ;
461 QListViewItem *qitem = mListView->firstChild (); 465 QListViewItem *qitem = mListView->firstChild ();
462 while ( qitem ) { 466 while ( qitem ) {
463 if ( qitem->isSelected() ) { 467 if ( qitem->isSelected() ) {
464 sel.append(((KOListViewItem *)qitem)); 468 sel.append(((KOListViewItem *)qitem));
465 } 469 }
466 qitem = qitem->nextSibling(); 470 qitem = qitem->nextSibling();
467 } 471 }
468 KOListViewItem * item, *temp; 472 KOListViewItem * item, *temp;
469 item = sel.first(); 473 item = sel.first();
470 if( item ) { 474 if( item ) {
471 Incidence* inc = item->data() ; 475 Incidence* inc = item->data() ;
472 bool setSub = false; 476 bool setSub = false;
473 if( inc->type() == "Todo" && sel.count() == 1 && inc->relations().count() > 0 ) { 477 if( inc->type() == "Todo" && sel.count() == 1 && inc->relations().count() > 0 ) {
474 int result = KMessageBox::warningYesNoCancel(this, 478 int result = KMessageBox::warningYesNoCancel(this,
475 i18n("The todo\n%1\nhas subtodos!\nDo you want to set\nthe categories for\nall subtodos as well?").arg( inc->summary().left ( 25 ) ), 479 i18n("The todo\n%1\nhas subtodos!\nDo you want to set\nthe categories for\nall subtodos as well?").arg( inc->summary().left ( 25 ) ),
476 i18n("Todo has subtodos"), 480 i18n("Todo has subtodos"),
477 i18n("Yes"), 481 i18n("Yes"),
478 i18n("No")); 482 i18n("No"));
479 if (result == KMessageBox::Cancel) item = 0; 483 if (result == KMessageBox::Cancel) item = 0;
480 if (result == KMessageBox::Yes) setSub = true; 484 if (result == KMessageBox::Yes) setSub = true;
481 } 485 }
482 while ( item ) { 486 while ( item ) {
483 inc = item->data(); 487 inc = item->data();
484 if ( removeOld ) { 488 if ( removeOld ) {
485 inc->setCategories( catList, setSub ); 489 inc->setCategories( catList, setSub );
486 } else { 490 } else {
487 inc->addCategories( catList, setSub ); 491 inc->addCategories( catList, setSub );
488 } 492 }
489 ListItemVisitor v(item, mStartDate ); 493 ListItemVisitor v(item, mStartDate );
490 inc->accept(v); 494 inc->accept(v);
491 item = sel.next(); 495 item = sel.next();
492 } 496 }
493 } 497 }
diff --git a/korganizer/kolistview.h b/korganizer/kolistview.h
index dee69f6..f4d6879 100644
--- a/korganizer/kolistview.h
+++ b/korganizer/kolistview.h
@@ -132,182 +132,183 @@ void pickAlarmSound()
132 mAlarmSound = fileName; 132 mAlarmSound = fileName;
133 mAlarmLabel->setText( "..."+fileName.right( 30 ) ); 133 mAlarmLabel->setText( "..."+fileName.right( 30 ) );
134 QToolTip::remove(mAlarmSoundButton); 134 QToolTip::remove(mAlarmSoundButton);
135 QString dispStr = i18n("Playing '%1'").arg(fileName); 135 QString dispStr = i18n("Playing '%1'").arg(fileName);
136 QToolTip::add(mAlarmSoundButton, dispStr); 136 QToolTip::add(mAlarmSoundButton, dispStr);
137 mAlarmProgramButton->setOn(false); 137 mAlarmProgramButton->setOn(false);
138 mAlarmSoundButton->setOn(true); 138 mAlarmSoundButton->setOn(true);
139 } else { 139 } else {
140 mAlarmProgramButton->setOn(true); 140 mAlarmProgramButton->setOn(true);
141 mAlarmSoundButton->setOn(false); 141 mAlarmSoundButton->setOn(false);
142 142
143 } 143 }
144 } 144 }
145}; 145};
146 146
147void pickAlarmProgram() 147void pickAlarmProgram()
148{ 148{
149 if (!mAlarmProgramButton->isOn()) { 149 if (!mAlarmProgramButton->isOn()) {
150 //mAlarmProgram = ""; 150 //mAlarmProgram = "";
151 QToolTip::remove(mAlarmProgramButton); 151 QToolTip::remove(mAlarmProgramButton);
152 QToolTip::add(mAlarmProgramButton, i18n("No program set")); 152 QToolTip::add(mAlarmProgramButton, i18n("No program set"));
153 mAlarmProgramButton->setOn(false); 153 mAlarmProgramButton->setOn(false);
154 mAlarmSoundButton->setOn(true); 154 mAlarmSoundButton->setOn(true);
155 } else { 155 } else {
156 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm.: ") , 0)); 156 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm.: ") , 0));
157 if (!fileName.isEmpty()) { 157 if (!fileName.isEmpty()) {
158 mAlarmProgram = fileName; 158 mAlarmProgram = fileName;
159 mAlarmLabel->setText( "..."+fileName.right( 30 ) ); 159 mAlarmLabel->setText( "..."+fileName.right( 30 ) );
160 QToolTip::remove(mAlarmProgramButton); 160 QToolTip::remove(mAlarmProgramButton);
161 QString dispStr = i18n("Running '%1'").arg(fileName); 161 QString dispStr = i18n("Running '%1'").arg(fileName);
162 QToolTip::add(mAlarmProgramButton, dispStr); 162 QToolTip::add(mAlarmProgramButton, dispStr);
163 mAlarmSoundButton->setOn(false); 163 mAlarmSoundButton->setOn(false);
164 mAlarmProgramButton->setOn(true); 164 mAlarmProgramButton->setOn(true);
165 } else { 165 } else {
166 mAlarmProgramButton->setOn(false); 166 mAlarmProgramButton->setOn(false);
167 mAlarmSoundButton->setOn(true); 167 mAlarmSoundButton->setOn(true);
168 } 168 }
169 } 169 }
170}; 170};
171 171
172}; 172};
173 173
174 174
175 175
176 176
177 177
178 178
179 179
180typedef CustomListViewItem<Incidence *> KOListViewItem; 180typedef CustomListViewItem<Incidence *> KOListViewItem;
181 181
182/** 182/**
183 This class provides the initialisation of a KOListViewItem for calendar 183 This class provides the initialisation of a KOListViewItem for calendar
184 components using the Incidence::Visitor. 184 components using the Incidence::Visitor.
185*/ 185*/
186class ListItemVisitor : public Incidence::Visitor 186class ListItemVisitor : public Incidence::Visitor
187{ 187{
188 public: 188 public:
189 ListItemVisitor(KOListViewItem *, QDate d); 189 ListItemVisitor(KOListViewItem *, QDate d);
190 ~ListItemVisitor(); 190 ~ListItemVisitor();
191 191
192 bool visit(Event *); 192 bool visit(Event *);
193 bool visit(Todo *); 193 bool visit(Todo *);
194 bool visit(Journal *); 194 bool visit(Journal *);
195 195
196 private: 196 private:
197 KOListViewItem *mItem; 197 KOListViewItem *mItem;
198 QDate mDate; 198 QDate mDate;
199}; 199};
200 200
201/** 201/**
202 This class provides a multi-column list view of events. It can 202 This class provides a multi-column list view of events. It can
203 display events from one particular day or several days, it doesn't 203 display events from one particular day or several days, it doesn't
204 matter. To use a view that only handles one day at a time, use 204 matter. To use a view that only handles one day at a time, use
205 KODayListView. 205 KODayListView.
206 206
207 @short multi-column list view of various events. 207 @short multi-column list view of various events.
208 @author Preston Brown <pbrown@kde.org> 208 @author Preston Brown <pbrown@kde.org>
209 @see KOBaseView, KODayListView 209 @see KOBaseView, KODayListView
210*/ 210*/
211class KOListView; 211class KOListView;
212 212
213class KOListViewListView : public KListView 213class KOListViewListView : public KListView
214{ 214{
215 Q_OBJECT 215 Q_OBJECT
216 public: 216 public:
217 KOListViewListView(KOListView * lv ); 217 KOListViewListView(KOListView * lv );
218 bool hasMultiSelection(QListViewItem*); 218 bool hasMultiSelection(QListViewItem*);
219 signals: 219 signals:
220 void newEvent(); 220 void newEvent();
221 void showIncidence( Incidence* ); 221 void showIncidence( Incidence* );
222 public slots: 222 public slots:
223 void popupMenu(); 223 void popupMenu();
224 private: 224 private:
225 QPoint mEventPos; 225 QPoint mEventPos;
226 QPoint mEventGlobalPos; 226 QPoint mEventGlobalPos;
227 QTimer* mPopupTimer; 227 QTimer* mPopupTimer;
228 int mYMousePos; 228 int mYMousePos;
229 void keyPressEvent ( QKeyEvent * ) ; 229 void keyPressEvent ( QKeyEvent * ) ;
230 void contentsMouseDoubleClickEvent(QMouseEvent *e); 230 void contentsMouseDoubleClickEvent(QMouseEvent *e);
231 void contentsMousePressEvent(QMouseEvent *e); 231 void contentsMousePressEvent(QMouseEvent *e);
232 void contentsMouseReleaseEvent(QMouseEvent *e); 232 void contentsMouseReleaseEvent(QMouseEvent *e);
233 void contentsMouseMoveEvent(QMouseEvent *e); 233 void contentsMouseMoveEvent(QMouseEvent *e);
234 bool mMouseDown; 234 bool mMouseDown;
235}; 235};
236 236
237class KOListView : public KOEventView 237class KOListView : public KOEventView
238{ 238{
239 Q_OBJECT 239 Q_OBJECT
240 public: 240 public:
241 KOListView(Calendar *calendar, QWidget *parent = 0, 241 KOListView(Calendar *calendar, QWidget *parent = 0,
242 const char *name = 0); 242 const char *name = 0);
243 ~KOListView(); 243 ~KOListView();
244 244
245 virtual int maxDatesHint(); 245 virtual int maxDatesHint();
246 virtual int currentDateCount(); 246 virtual int currentDateCount();
247 virtual QPtrList<Incidence> selectedIncidences(); 247 virtual QPtrList<Incidence> selectedIncidences();
248 virtual DateList selectedDates(); 248 virtual DateList selectedDates();
249 249
250 void showDates(bool show); 250 void showDates(bool show);
251 Incidence* currentItem(); 251 Incidence* currentItem();
252 void addTodos(QPtrList<Todo> eventList); 252 void addTodos(QPtrList<Todo> eventList);
253 void addJournals(QPtrList<Journal> eventList); 253 void addJournals(QPtrList<Journal> eventList);
254 virtual void printPreview(CalPrinter *calPrinter, 254 virtual void printPreview(CalPrinter *calPrinter,
255 const QDate &, const QDate &); 255 const QDate &, const QDate &);
256 256
257 void readSettings(KConfig *config, QString setting = "KOListView Layout"); 257 void readSettings(KConfig *config, QString setting = "KOListView Layout");
258 void writeSettings(KConfig *config, QString setting = "KOListView Layout"); 258 void writeSettings(KConfig *config, QString setting = "KOListView Layout");
259 void updateList(); 259 void updateList();
260 void clearList();
260 void setStartDate(const QDate &start); 261 void setStartDate(const QDate &start);
261 int count(); 262 int count();
262 QString getWhatsThisText(QPoint p); 263 QString getWhatsThisText(QPoint p);
263 signals: 264 signals:
264 void signalNewEvent(); 265 void signalNewEvent();
265 void beamIncidenceList(QPtrList<Incidence>); 266 void beamIncidenceList(QPtrList<Incidence>);
266 267
267 public slots: 268 public slots:
268 void resetFocus(); 269 void resetFocus();
269 virtual void updateView(); 270 virtual void updateView();
270 virtual void showDates(const QDate &start, const QDate &end); 271 virtual void showDates(const QDate &start, const QDate &end);
271 virtual void showEvents(QPtrList<Event> eventList); 272 virtual void showEvents(QPtrList<Event> eventList);
272 void clearSelection(); 273 void clearSelection();
273 void allSelection(); 274 void allSelection();
274 275
275 void clear(); 276 void clear();
276 void beamDone( Ir *ir ); 277 void beamDone( Ir *ir );
277 void showDates(); 278 void showDates();
278 void hideDates(); 279 void hideDates();
279 void deleteAll(); 280 void deleteAll();
280 void saveToFile(); 281 void saveToFile();
281 void saveToFileVCS(); 282 void saveToFileVCS();
282 void saveDescriptionToFile(); 283 void saveDescriptionToFile();
283 void beamSelected(); 284 void beamSelected();
284 void updateConfig(); 285 void updateConfig();
285 void addCat(); 286 void addCat();
286 void setCat(); 287 void setCat();
287 void setAlarm(); 288 void setAlarm();
288 void setCategories( bool removeOld ); 289 void setCategories( bool removeOld );
289 void changeEventDisplay(Event *, int); 290 void changeEventDisplay(Event *, int);
290 291
291 void defaultItemAction(QListViewItem *item); 292 void defaultItemAction(QListViewItem *item);
292 void popupMenu(QListViewItem *item,const QPoint &,int); 293 void popupMenu(QListViewItem *item,const QPoint &,int);
293 294
294 protected slots: 295 protected slots:
295 void processSelectionChange(QListViewItem *); 296 void processSelectionChange(QListViewItem *);
296 297
297 protected: 298 protected:
298 void writeToFile( bool iCal ); 299 void writeToFile( bool iCal );
299 void addEvents(QPtrList<Event> eventList); 300 void addEvents(QPtrList<Event> eventList);
300 void addIncidence(Incidence *); 301 void addIncidence(Incidence *);
301 KOListViewItem *getItemForEvent(Event *event); 302 KOListViewItem *getItemForEvent(Event *event);
302 303
303 private: 304 private:
304 KOListViewWhatsThis *mKOListViewWhatsThis; 305 KOListViewWhatsThis *mKOListViewWhatsThis;
305 KOListViewListView *mListView; 306 KOListViewListView *mListView;
306 KOEventPopupMenu *mPopupMenu; 307 KOEventPopupMenu *mPopupMenu;
307 KOListViewItem *mActiveItem; 308 KOListViewItem *mActiveItem;
308 QDict<Incidence> mUidDict; 309 QDict<Incidence> mUidDict;
309 QDate mStartDate; 310 QDate mStartDate;
310 void keyPressEvent ( QKeyEvent * ) ; 311 void keyPressEvent ( QKeyEvent * ) ;
311}; 312};
312 313
313#endif 314#endif
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 8ee1363..678cab6 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -1290,256 +1290,266 @@ int KOMonthView::currentWeek()
1290} 1290}
1291void KOMonthView::switchView() 1291void KOMonthView::switchView()
1292{ 1292{
1293 if ( selectedCell( ) ) 1293 if ( selectedCell( ) )
1294 selectedCell()->deselect(); 1294 selectedCell()->deselect();
1295 mShowWeekView = !mShowWeekView; 1295 mShowWeekView = !mShowWeekView;
1296 KOPrefs::instance()->mMonthViewWeek = mShowWeekView; 1296 KOPrefs::instance()->mMonthViewWeek = mShowWeekView;
1297 if ( clPending ) { 1297 if ( clPending ) {
1298 computeLayout(); 1298 computeLayout();
1299 updateConfig(); 1299 updateConfig();
1300 } 1300 }
1301 if ( mShowWeekView ) 1301 if ( mShowWeekView )
1302 mWidStack->raiseWidget( mWeekView ); 1302 mWidStack->raiseWidget( mWeekView );
1303 else 1303 else
1304 mWidStack->raiseWidget( mMonthView ); 1304 mWidStack->raiseWidget( mMonthView );
1305 clPending = false; 1305 clPending = false;
1306} 1306}
1307 1307
1308int KOMonthView::maxDatesHint() 1308int KOMonthView::maxDatesHint()
1309{ 1309{
1310 return mNumCells; 1310 return mNumCells;
1311} 1311}
1312 1312
1313int KOMonthView::currentDateCount() 1313int KOMonthView::currentDateCount()
1314{ 1314{
1315 return mNumCells; 1315 return mNumCells;
1316} 1316}
1317 1317
1318QPtrList<Incidence> KOMonthView::selectedIncidences() 1318QPtrList<Incidence> KOMonthView::selectedIncidences()
1319{ 1319{
1320 QPtrList<Incidence> selected; 1320 QPtrList<Incidence> selected;
1321 1321
1322 if ( mSelectedCell ) { 1322 if ( mSelectedCell ) {
1323 Incidence *incidence = mSelectedCell->selectedIncidence(); 1323 Incidence *incidence = mSelectedCell->selectedIncidence();
1324 if ( incidence ) selected.append( incidence ); 1324 if ( incidence ) selected.append( incidence );
1325 } 1325 }
1326 1326
1327 return selected; 1327 return selected;
1328} 1328}
1329 1329
1330DateList KOMonthView::selectedDates() 1330DateList KOMonthView::selectedDates()
1331{ 1331{
1332 DateList selected; 1332 DateList selected;
1333 1333
1334 if ( mSelectedCell ) { 1334 if ( mSelectedCell ) {
1335 QDate qd = mSelectedCell->selectedIncidenceDate(); 1335 QDate qd = mSelectedCell->selectedIncidenceDate();
1336 if ( qd.isValid() ) selected.append( qd ); 1336 if ( qd.isValid() ) selected.append( qd );
1337 } 1337 }
1338 1338
1339 return selected; 1339 return selected;
1340} 1340}
1341 1341
1342void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1342void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1343 const QDate &td) 1343 const QDate &td)
1344{ 1344{
1345#ifndef KORG_NOPRINTER 1345#ifndef KORG_NOPRINTER
1346 calPrinter->preview(CalPrinter::Month, fd, td); 1346 calPrinter->preview(CalPrinter::Month, fd, td);
1347#endif 1347#endif
1348} 1348}
1349 1349
1350void KOMonthView::updateConfig() 1350void KOMonthView::updateConfig()
1351{ 1351{
1352 1352
1353 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 1353 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
1354 1354
1355 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { 1355 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) {
1356 mWeekStartsMonday = true; 1356 mWeekStartsMonday = true;
1357 } 1357 }
1358 QFontMetrics fontmetric(mDayLabels[0]->font()); 1358 QFontMetrics fontmetric(mDayLabels[0]->font());
1359 mWidthLongDayLabel = 0; 1359 mWidthLongDayLabel = 0;
1360 1360
1361 for (int i = 0; i < 7; i++) { 1361 for (int i = 0; i < 7; i++) {
1362 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 1362 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
1363 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 1363 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
1364 } 1364 }
1365 bool temp = mShowSatSunComp ; 1365 bool temp = mShowSatSunComp ;
1366 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 1366 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
1367 if ( ! mShowWeekView ) { 1367 if ( ! mShowWeekView ) {
1368 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) 1368 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog )
1369 computeLayout(); 1369 computeLayout();
1370 } 1370 }
1371 updateDayLabels(); 1371 updateDayLabels();
1372 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); 1372 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks);
1373 //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; 1373 //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks;
1374 //resizeEvent( 0 ); 1374 //resizeEvent( 0 );
1375 for (uint i = 0; i < mCells.count(); ++i) { 1375 for (uint i = 0; i < mCells.count(); ++i) {
1376 mCells[i]->updateConfig(); 1376 mCells[i]->updateConfig();
1377 } 1377 }
1378 1378
1379 for (uint i = 0; i < mCellsW.count(); ++i) { 1379 for (uint i = 0; i < mCellsW.count(); ++i) {
1380 mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); 1380 mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont);
1381 } 1381 }
1382#ifdef DESKTOP_VERSION 1382#ifdef DESKTOP_VERSION
1383 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); 1383 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips);
1384#endif 1384#endif
1385 updateView(); 1385 updateView();
1386} 1386}
1387 1387
1388void KOMonthView::updateDayLabels() 1388void KOMonthView::updateDayLabels()
1389{ 1389{
1390 1390
1391 QPtrVector<QLabel> *mDayLabelsT; 1391 QPtrVector<QLabel> *mDayLabelsT;
1392 1392
1393 mDayLabelsT = &mDayLabelsW; 1393 mDayLabelsT = &mDayLabelsW;
1394 for (int i = 0; i < 7; i++) { 1394 for (int i = 0; i < 7; i++) {
1395 { 1395 {
1396 bool show = mShortDayLabelsW; 1396 bool show = mShortDayLabelsW;
1397 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) 1397 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1398 show = true; 1398 show = true;
1399 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1399 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1400 } 1400 }
1401 } 1401 }
1402 mDayLabelsT = &mDayLabels; 1402 mDayLabelsT = &mDayLabels;
1403 for (int i = 0; i < 7; i++) { 1403 for (int i = 0; i < 7; i++) {
1404 if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) { 1404 if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) {
1405 bool show = mShortDayLabelsM; 1405 bool show = mShortDayLabelsM;
1406 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) 1406 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1407 show = true; 1407 show = true;
1408 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1408 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1409 } else { 1409 } else {
1410 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); 1410 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM));
1411 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); 1411 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM));
1412 1412
1413 } 1413 }
1414 } 1414 }
1415 1415
1416} 1416}
1417 1417
1418void KOMonthView::clearList()
1419{
1420 unsigned int i;
1421 for( i = 0; i < mCells.size(); ++i ) {
1422 mCells[i]->clear();
1423 }
1424 for( i = 0; i < mCellsW.size(); ++i ) {
1425 mCellsW[i]->clear();
1426 }
1427}
1418void KOMonthView::showDates(const QDate &start, const QDate &) 1428void KOMonthView::showDates(const QDate &start, const QDate &)
1419{ 1429{
1420 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; 1430 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl;
1421 1431
1422 QPtrVector<MonthViewCell> *cells; 1432 QPtrVector<MonthViewCell> *cells;
1423 QPtrVector<QLabel> *dayLabels; 1433 QPtrVector<QLabel> *dayLabels;
1424 QPtrVector<KOWeekButton> *weekLabels; 1434 QPtrVector<KOWeekButton> *weekLabels;
1425 int weekNum = 6; 1435 int weekNum = 6;
1426 mStartDate = start; 1436 mStartDate = start;
1427 if ( mShowWeekView ) { 1437 if ( mShowWeekView ) {
1428 weekNum = 1; 1438 weekNum = 1;
1429 cells = &mCellsW; 1439 cells = &mCellsW;
1430 dayLabels = &mDayLabelsW; 1440 dayLabels = &mDayLabelsW;
1431 weekLabels = &mWeekLabelsW; 1441 weekLabels = &mWeekLabelsW;
1432 if ( !KGlobal::locale()->weekStartsMonday() ) { 1442 if ( !KGlobal::locale()->weekStartsMonday() ) {
1433 mStartDate = mStartDate.addDays( 1 ); 1443 mStartDate = mStartDate.addDays( 1 );
1434 } 1444 }
1435 } else { 1445 } else {
1436 cells = &mCells; 1446 cells = &mCells;
1437 dayLabels = &mDayLabels; 1447 dayLabels = &mDayLabels;
1438 weekLabels = &mWeekLabels; 1448 weekLabels = &mWeekLabels;
1439 } 1449 }
1440 1450
1441 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 1451 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
1442 1452
1443 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { 1453 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) {
1444 mWeekStartsMonday = true; 1454 mWeekStartsMonday = true;
1445 } 1455 }
1446 int startWeekDay = mWeekStartsMonday ? 1 : 7; 1456 int startWeekDay = mWeekStartsMonday ? 1 : 7;
1447 1457
1448 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { 1458 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) {
1449 mStartDate = mStartDate.addDays( -1 ); 1459 mStartDate = mStartDate.addDays( -1 );
1450 } 1460 }
1451 bool primary = false; 1461 bool primary = false;
1452 uint i; 1462 uint i;
1453 for( i = 0; i < (*cells).size(); ++i ) { 1463 for( i = 0; i < (*cells).size(); ++i ) {
1454 QDate date = mStartDate.addDays( i ); 1464 QDate date = mStartDate.addDays( i );
1455 (*cells)[i]->setDate( date ); 1465 (*cells)[i]->setDate( date );
1456 1466
1457#ifndef KORG_NOPLUGINS 1467#ifndef KORG_NOPLUGINS
1458 // add holiday, if present 1468 // add holiday, if present
1459 QString hstring(KOCore::self()->holiday(date)); 1469 QString hstring(KOCore::self()->holiday(date));
1460 (*cells)[i]->setHoliday( hstring ); 1470 (*cells)[i]->setHoliday( hstring );
1461#endif 1471#endif
1462 1472
1463 } 1473 }
1464 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); 1474 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 );
1465 for( i = 0; i < weekNum; ++i ) { 1475 for( i = 0; i < weekNum; ++i ) {
1466 int wno; 1476 int wno;
1467 // remember, according to ISO 8601, the first week of the year is the 1477 // remember, according to ISO 8601, the first week of the year is the
1468 // first week that contains a thursday. Thus we must subtract off 4, 1478 // first week that contains a thursday. Thus we must subtract off 4,
1469 // not just 1. 1479 // not just 1.
1470 int dayOfYear = date.dayOfYear(); 1480 int dayOfYear = date.dayOfYear();
1471 if (dayOfYear % 7 != 0) 1481 if (dayOfYear % 7 != 0)
1472 wno = dayOfYear / 7 + 1; 1482 wno = dayOfYear / 7 + 1;
1473 else 1483 else
1474 wno =dayOfYear / 7; 1484 wno =dayOfYear / 7;
1475 (*weekLabels)[i]->setWeekNum( wno ); 1485 (*weekLabels)[i]->setWeekNum( wno );
1476 date = date.addDays( 7 ); 1486 date = date.addDays( 7 );
1477 } 1487 }
1478 updateView(); 1488 updateView();
1479} 1489}
1480 1490
1481void KOMonthView::showEvents(QPtrList<Event>) 1491void KOMonthView::showEvents(QPtrList<Event>)
1482{ 1492{
1483 qDebug("KOMonthView::selectEvents is not implemented yet. "); 1493 qDebug("KOMonthView::selectEvents is not implemented yet. ");
1484} 1494}
1485 1495
1486void KOMonthView::changeEventDisplay(Event *, int) 1496void KOMonthView::changeEventDisplay(Event *, int)
1487{ 1497{
1488 // this should be re-written to be much more efficient, but this 1498 // this should be re-written to be much more efficient, but this
1489 // quick-and-dirty-hack gets the job done for right now. 1499 // quick-and-dirty-hack gets the job done for right now.
1490 //qDebug("KOMonthView::changeEventDisplay "); 1500 //qDebug("KOMonthView::changeEventDisplay ");
1491 updateView(); 1501 updateView();
1492} 1502}
1493 1503
1494void KOMonthView::updateView() 1504void KOMonthView::updateView()
1495{ 1505{
1496 1506
1497 if ( !updatePossible ) 1507 if ( !updatePossible )
1498 return; 1508 return;
1499 //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); 1509 //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU ");
1500 //QTime ti; 1510 //QTime ti;
1501 //ti.start(); 1511 //ti.start();
1502 clearSelection(); 1512 clearSelection();
1503 QPtrVector<MonthViewCell> *cells; 1513 QPtrVector<MonthViewCell> *cells;
1504 if ( mShowWeekView ) { 1514 if ( mShowWeekView ) {
1505 cells = &mCellsW; 1515 cells = &mCellsW;
1506 } else { 1516 } else {
1507 cells = &mCells; 1517 cells = &mCells;
1508 } 1518 }
1509#if 1 1519#if 1
1510 int i; 1520 int i;
1511 int timeSpan = (*cells).size()-1; 1521 int timeSpan = (*cells).size()-1;
1512 if ( KOPrefs::instance()->mMonthViewWeek ) 1522 if ( KOPrefs::instance()->mMonthViewWeek )
1513 timeSpan = 6; 1523 timeSpan = 6;
1514 for( i = 0; i < timeSpan + 1; ++i ) { 1524 for( i = 0; i < timeSpan + 1; ++i ) {
1515 (*cells)[i]->startUpdateCell(); 1525 (*cells)[i]->startUpdateCell();
1516 } 1526 }
1517 1527
1518 QPtrList<Event> events = calendar()->events(); 1528 QPtrList<Event> events = calendar()->events();
1519 Event *event; 1529 Event *event;
1520 QDateTime dt; 1530 QDateTime dt;
1521 bool ok; 1531 bool ok;
1522 QDate endDate = mStartDate.addDays( timeSpan ); 1532 QDate endDate = mStartDate.addDays( timeSpan );
1523 for( event = events.first(); event; event = events.next() ) { // for event 1533 for( event = events.first(); event; event = events.next() ) { // for event
1524 if ( event->doesRecur() ) { 1534 if ( event->doesRecur() ) {
1525 bool last; 1535 bool last;
1526 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); 1536 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last );
1527 QDateTime incidenceEnd; 1537 QDateTime incidenceEnd;
1528 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); 1538 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() );
1529 bool invalid = false; 1539 bool invalid = false;
1530 while( true ) { 1540 while( true ) {
1531 if ( incidenceStart.isValid() ) { 1541 if ( incidenceStart.isValid() ) {
1532 incidenceEnd = incidenceStart.addDays( eventlen ); 1542 incidenceEnd = incidenceStart.addDays( eventlen );
1533 int st = incidenceStart.date().daysTo( endDate ); 1543 int st = incidenceStart.date().daysTo( endDate );
1534 if ( st >= 0 ) { // start before timeend 1544 if ( st >= 0 ) { // start before timeend
1535 int end = mStartDate.daysTo( incidenceEnd.date() ); 1545 int end = mStartDate.daysTo( incidenceEnd.date() );
1536 if ( end >= 0 ) { // end after timestart --- got one! 1546 if ( end >= 0 ) { // end after timestart --- got one!
1537 //normalize 1547 //normalize
1538 st = timeSpan - st; 1548 st = timeSpan - st;
1539 if ( st < 0 ) st = 0; 1549 if ( st < 0 ) st = 0;
1540 if ( end > timeSpan ) end = timeSpan; 1550 if ( end > timeSpan ) end = timeSpan;
1541 int iii; 1551 int iii;
1542 //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); 1552 //qDebug("found %s %d %d ",event->summary().latin1(), st, end );
1543 for ( iii = st;iii<= end;++iii) 1553 for ( iii = st;iii<= end;++iii)
1544 (*cells)[iii]->insertEvent( event ); 1554 (*cells)[iii]->insertEvent( event );
1545 } 1555 }
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index de5c014..65b5e77 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -131,210 +131,211 @@ class MonthViewItem: public QListBoxItem
131 bool isWeekItem; 131 bool isWeekItem;
132 bool mblockRepaint; 132 bool mblockRepaint;
133 int mMultiday; 133 int mMultiday;
134 bool mRecur; 134 bool mRecur;
135 bool mAlarm; 135 bool mAlarm;
136 bool mReply; 136 bool mReply;
137 bool mInfo; 137 bool mInfo;
138 138
139 QPalette mPalette; 139 QPalette mPalette;
140 QDate mDate; 140 QDate mDate;
141 141
142 Incidence *mIncidence; 142 Incidence *mIncidence;
143}; 143};
144 144
145 145
146class KOMonthView; 146class KOMonthView;
147 147
148class MonthViewCell : public KNoScrollListBox 148class MonthViewCell : public KNoScrollListBox
149{ 149{
150 Q_OBJECT 150 Q_OBJECT
151 public: 151 public:
152 MonthViewCell(KOMonthView *,QWidget* ); 152 MonthViewCell(KOMonthView *,QWidget* );
153 ~MonthViewCell() {mAvailItemList.setAutoDelete( true );} 153 ~MonthViewCell() {mAvailItemList.setAutoDelete( true );}
154 154
155 void setDate( const QDate & ); 155 void setDate( const QDate & );
156 QDate date() const; 156 QDate date() const;
157 157
158 void setPrimary( bool ); 158 void setPrimary( bool );
159 bool isPrimary() const; 159 bool isPrimary() const;
160 160
161 void setHoliday( bool ); 161 void setHoliday( bool );
162 void setHoliday( const QString & ); 162 void setHoliday( const QString & );
163 163
164 void updateCell(); 164 void updateCell();
165 void startUpdateCell(); 165 void startUpdateCell();
166 void finishUpdateCell(); 166 void finishUpdateCell();
167 void repaintfinishUpdateCell(); 167 void repaintfinishUpdateCell();
168 int insertEvent(Event *); 168 int insertEvent(Event *);
169 void insertTodo(Todo *); 169 void insertTodo(Todo *);
170 170
171 void updateConfig( bool bigFont = false ); 171 void updateConfig( bool bigFont = false );
172 172
173 void enableScrollBars( bool ); 173 void enableScrollBars( bool );
174 174
175 Incidence *selectedIncidence(); 175 Incidence *selectedIncidence();
176 QDate selectedIncidenceDate(); 176 QDate selectedIncidenceDate();
177 QPushButton * dateLabel() { return mLabel; } 177 QPushButton * dateLabel() { return mLabel; }
178 178
179 void deselect(); 179 void deselect();
180 void select(); 180 void select();
181#ifdef DESKTOP_VERSION 181#ifdef DESKTOP_VERSION
182 static QToolTipGroup *toolTipGroup(); 182 static QToolTipGroup *toolTipGroup();
183#endif 183#endif
184 signals: 184 signals:
185 void defaultAction( Incidence * ); 185 void defaultAction( Incidence * );
186 void newEventSignal( QDateTime ); 186 void newEventSignal( QDateTime );
187 void showDaySignal( QDate ); 187 void showDaySignal( QDate );
188 188
189 protected: 189 protected:
190 QStringList mToolTip; 190 QStringList mToolTip;
191 void resizeEvent( QResizeEvent * ); 191 void resizeEvent( QResizeEvent * );
192 192
193public slots: 193public slots:
194 void showDay(); 194 void showDay();
195 195
196 protected slots: 196 protected slots:
197 void defaultAction( QListBoxItem * ); 197 void defaultAction( QListBoxItem * );
198 void contextMenu( QListBoxItem * ); 198 void contextMenu( QListBoxItem * );
199 void selection( QListBoxItem * ); 199 void selection( QListBoxItem * );
200 void cellClicked( QListBoxItem * ); 200 void cellClicked( QListBoxItem * );
201 void newEvent(); 201 void newEvent();
202 202
203 private: 203 private:
204 int mdayCount; 204 int mdayCount;
205 QPtrList <MonthViewItem> mAvailItemList; 205 QPtrList <MonthViewItem> mAvailItemList;
206 KOMonthView *mMonthView; 206 KOMonthView *mMonthView;
207 int currentPalette; 207 int currentPalette;
208 208
209 QDate mDate; 209 QDate mDate;
210 bool mPrimary; 210 bool mPrimary;
211 bool mHoliday; 211 bool mHoliday;
212 QString mHolidayString; 212 QString mHolidayString;
213 213
214 //QLabel *mLabel; 214 //QLabel *mLabel;
215 QPushButton *mLabel; 215 QPushButton *mLabel;
216 //QListBox *mItemList; 216 //QListBox *mItemList;
217#ifdef DESKTOP_VERSION 217#ifdef DESKTOP_VERSION
218 static QToolTipGroup *mToolTipGroup; 218 static QToolTipGroup *mToolTipGroup;
219#endif 219#endif
220 QSize mLabelSize; 220 QSize mLabelSize;
221 QSize mLabelBigSize; 221 QSize mLabelBigSize;
222 QPalette mHolidayPalette; 222 QPalette mHolidayPalette;
223 QPalette mStandardPalette; 223 QPalette mStandardPalette;
224 QPalette mPrimaryPalette; 224 QPalette mPrimaryPalette;
225 QPalette mNonPrimaryPalette; 225 QPalette mNonPrimaryPalette;
226 void setMyPalette(); 226 void setMyPalette();
227 QPalette getPalette (); 227 QPalette getPalette ();
228 228
229}; 229};
230 230
231 231
232class KOMonthView: public KOEventView 232class KOMonthView: public KOEventView
233{ 233{
234 Q_OBJECT 234 Q_OBJECT
235 public: 235 public:
236 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); 236 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 );
237 ~KOMonthView(); 237 ~KOMonthView();
238 238
239 /** Returns maximum number of days supported by the komonthview */ 239 /** Returns maximum number of days supported by the komonthview */
240 virtual int maxDatesHint(); 240 virtual int maxDatesHint();
241 241
242 /** Returns number of currently shown dates. */ 242 /** Returns number of currently shown dates. */
243 virtual int currentDateCount(); 243 virtual int currentDateCount();
244 244
245 /** returns the currently selected events */ 245 /** returns the currently selected events */
246 virtual QPtrList<Incidence> selectedIncidences(); 246 virtual QPtrList<Incidence> selectedIncidences();
247 247
248 /** returns dates of the currently selected events */ 248 /** returns dates of the currently selected events */
249 virtual DateList selectedDates(); 249 virtual DateList selectedDates();
250 250
251 virtual void printPreview(CalPrinter *calPrinter, 251 virtual void printPreview(CalPrinter *calPrinter,
252 const QDate &, const QDate &); 252 const QDate &, const QDate &);
253 bool isMonthView() { return !mShowWeekView; } 253 bool isMonthView() { return !mShowWeekView; }
254 bool isUpdatePossible() { return updatePossible; } 254 bool isUpdatePossible() { return updatePossible; }
255 255
256 MonthViewCell * selectedCell(); 256 MonthViewCell * selectedCell();
257 bool skipResize; 257 bool skipResize;
258 NavigatorBar* navigatorBar() { return mNavigatorBar ;} 258 NavigatorBar* navigatorBar() { return mNavigatorBar ;}
259 void clearList();
259 public slots: 260 public slots:
260 void nextCell(); 261 void nextCell();
261 void prevCell(); 262 void prevCell();
262 virtual void updateView(); 263 virtual void updateView();
263 virtual void updateConfig(); 264 virtual void updateConfig();
264 virtual void showDates(const QDate &start, const QDate &end); 265 virtual void showDates(const QDate &start, const QDate &end);
265 virtual void showEvents(QPtrList<Event> eventList); 266 virtual void showEvents(QPtrList<Event> eventList);
266 267
267 void changeEventDisplay(Event *, int); 268 void changeEventDisplay(Event *, int);
268 269
269 void clearSelection(); 270 void clearSelection();
270 271
271 void showContextMenu( Incidence * ); 272 void showContextMenu( Incidence * );
272 273
273 void setSelectedCell( MonthViewCell * ); 274 void setSelectedCell( MonthViewCell * );
274 void setPopupCell( MonthViewCell * ); 275 void setPopupCell( MonthViewCell * );
275 void switchView(); 276 void switchView();
276 void setKeyBoardFocus(); 277 void setKeyBoardFocus();
277 void setKeyBFocus(); 278 void setKeyBFocus();
278 279
279 protected slots: 280 protected slots:
280 void slotNewTodo(); 281 void slotNewTodo();
281 void slotNewEvent(); 282 void slotNewEvent();
282 void slotEditJournal(); 283 void slotEditJournal();
283 void slotComputeLayout(); 284 void slotComputeLayout();
284 void selectInternalWeekNum ( int ); 285 void selectInternalWeekNum ( int );
285 void processSelectionChange(); 286 void processSelectionChange();
286 signals: 287 signals:
287 void nextMonth(); 288 void nextMonth();
288 void prevMonth(); 289 void prevMonth();
289 void selectWeekNum ( int ); 290 void selectWeekNum ( int );
290 void selectMonth (); 291 void selectMonth ();
291 void showDaySignal( QDate ); 292 void showDaySignal( QDate );
292 void newTodoSignal( QDateTime, bool ); 293 void newTodoSignal( QDateTime, bool );
293 void showJournalSignal( int,QDate ); 294 void showJournalSignal( int,QDate );
294 protected: 295 protected:
295 void resizeEvent(QResizeEvent *); 296 void resizeEvent(QResizeEvent *);
296 void viewChanged(); 297 void viewChanged();
297 void updateDayLabels(); 298 void updateDayLabels();
298 299
299 private: 300 private:
300 QTimer* mComputeLayoutTimer; 301 QTimer* mComputeLayoutTimer;
301 NavigatorBar* mNavigatorBar; 302 NavigatorBar* mNavigatorBar;
302 int currentWeek(); 303 int currentWeek();
303 bool clPending; 304 bool clPending;
304 QWidgetStack * mWidStack; 305 QWidgetStack * mWidStack;
305 QWidget* mMonthView; 306 QWidget* mMonthView;
306 QWidget* mWeekView; 307 QWidget* mWeekView;
307 bool mShowWeekView; 308 bool mShowWeekView;
308 bool updatePossible; 309 bool updatePossible;
309 int mDaysPerWeek; 310 int mDaysPerWeek;
310 int mNumWeeks; 311 int mNumWeeks;
311 int mNumCells; 312 int mNumCells;
312 //bool mWeekStartsMonday; 313 //bool mWeekStartsMonday;
313 bool mShowSatSunComp; 314 bool mShowSatSunComp;
314 void computeLayout(); 315 void computeLayout();
315 void computeLayoutWeek(); 316 void computeLayoutWeek();
316 317
317 QPtrVector<MonthViewCell> mCells; 318 QPtrVector<MonthViewCell> mCells;
318 QPtrVector<QLabel> mDayLabels; 319 QPtrVector<QLabel> mDayLabels;
319 QPtrVector<KOWeekButton> mWeekLabels; 320 QPtrVector<KOWeekButton> mWeekLabels;
320 QPtrVector<MonthViewCell> mCellsW; 321 QPtrVector<MonthViewCell> mCellsW;
321 QPtrVector<QLabel> mDayLabelsW; 322 QPtrVector<QLabel> mDayLabelsW;
322 QPtrVector<KOWeekButton> mWeekLabelsW; 323 QPtrVector<KOWeekButton> mWeekLabelsW;
323 324
324 bool mShortDayLabelsM; 325 bool mShortDayLabelsM;
325 bool mShortDayLabelsW; 326 bool mShortDayLabelsW;
326 int mWidthLongDayLabel; 327 int mWidthLongDayLabel;
327 328
328 QDate mStartDate; 329 QDate mStartDate;
329 330
330 MonthViewCell *mSelectedCell; 331 MonthViewCell *mSelectedCell;
331 MonthViewCell *mPopupCell; 332 MonthViewCell *mPopupCell;
332 bool mFlagKeyPressed; 333 bool mFlagKeyPressed;
333 KOEventPopupMenu *mContextMenu; 334 KOEventPopupMenu *mContextMenu;
334 QPopupMenu *mNewItemMenu; 335 QPopupMenu *mNewItemMenu;
335 void keyPressEvent ( QKeyEvent * ) ; 336 void keyPressEvent ( QKeyEvent * ) ;
336 void keyReleaseEvent ( QKeyEvent * ) ; 337 void keyReleaseEvent ( QKeyEvent * ) ;
337 338
338}; 339};
339 340
340#endif 341#endif
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index fb4de37..5d9af6d 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -233,256 +233,268 @@ void KOViewManager::showNextView()
233 JOURNAL: 233 JOURNAL:
234 if ( KOPrefs::instance()->mShowIconJournal ) { 234 if ( KOPrefs::instance()->mShowIconJournal ) {
235 resetDateSilent( baseCycleDate , 1 ); 235 resetDateSilent( baseCycleDate , 1 );
236 showJournalView() ;goto ENTE ;} 236 showJournalView() ;goto ENTE ;}
237 DAY_1: 237 DAY_1:
238 if ( KOPrefs::instance()->mShowIconDay1 ) { 238 if ( KOPrefs::instance()->mShowIconDay1 ) {
239 resetDateSilent( baseCycleDate , 2 ); 239 resetDateSilent( baseCycleDate , 2 );
240 showDayView() ;goto ENTE ;} 240 showDayView() ;goto ENTE ;}
241 DAY_5: 241 DAY_5:
242 if ( KOPrefs::instance()->mShowIconDay5 ) { 242 if ( KOPrefs::instance()->mShowIconDay5 ) {
243 resetDateSilent( baseCycleDate , 2 ); 243 resetDateSilent( baseCycleDate , 2 );
244 showWorkWeekView() ;goto ENTE ;} 244 showWorkWeekView() ;goto ENTE ;}
245 DAY_7: 245 DAY_7:
246 if ( KOPrefs::instance()->mShowIconDay7 ) { 246 if ( KOPrefs::instance()->mShowIconDay7 ) {
247 resetDateSilent( baseCycleDate , 2 ); 247 resetDateSilent( baseCycleDate , 2 );
248 showWeekView();goto ENTE ;} 248 showWeekView();goto ENTE ;}
249 DAY_6: 249 DAY_6:
250 if ( KOPrefs::instance()->mShowIconDay6 ) { 250 if ( KOPrefs::instance()->mShowIconDay6 ) {
251 resetDateSilent( baseCycleDate , 2 ); 251 resetDateSilent( baseCycleDate , 2 );
252 showMonthViewWeek();goto ENTE ;} 252 showMonthViewWeek();goto ENTE ;}
253 MONTH: 253 MONTH:
254 if ( KOPrefs::instance()->mShowIconMonth ) { 254 if ( KOPrefs::instance()->mShowIconMonth ) {
255 resetDateSilent( baseCycleDate , 2 ); 255 resetDateSilent( baseCycleDate , 2 );
256 showMonthView();goto ENTE ;} 256 showMonthView();goto ENTE ;}
257 LIST: 257 LIST:
258 if ( KOPrefs::instance()->mShowIconList ) { 258 if ( KOPrefs::instance()->mShowIconList ) {
259 resetDateSilent( baseCycleDate , 2 ); 259 resetDateSilent( baseCycleDate , 2 );
260 showListView() ;goto ENTE ;} 260 showListView() ;goto ENTE ;}
261 TODO: 261 TODO:
262 if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;goto ENTE ;} 262 if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;goto ENTE ;}
263 if ( KOPrefs::instance()->mShowIconNext ) { goto NEXT ;} 263 if ( KOPrefs::instance()->mShowIconNext ) { goto NEXT ;}
264 if ( KOPrefs::instance()->mShowIconNextDays ) { goto NEXT_X ;} 264 if ( KOPrefs::instance()->mShowIconNextDays ) { goto NEXT_X ;}
265 if ( KOPrefs::instance()->mShowIconJournal ) { goto JOURNAL;} 265 if ( KOPrefs::instance()->mShowIconJournal ) { goto JOURNAL;}
266 if ( KOPrefs::instance()->mShowIconDay1 ) { goto DAY_1 ;} 266 if ( KOPrefs::instance()->mShowIconDay1 ) { goto DAY_1 ;}
267 if ( KOPrefs::instance()->mShowIconDay5 ) { goto DAY_5 ;} 267 if ( KOPrefs::instance()->mShowIconDay5 ) { goto DAY_5 ;}
268 if ( KOPrefs::instance()->mShowIconDay7 ) { goto DAY_7 ;} 268 if ( KOPrefs::instance()->mShowIconDay7 ) { goto DAY_7 ;}
269 if ( KOPrefs::instance()->mShowIconDay6 ) { goto DAY_6 ;} 269 if ( KOPrefs::instance()->mShowIconDay6 ) { goto DAY_6 ;}
270 if ( KOPrefs::instance()->mShowIconMonth ) {goto MONTH ;} 270 if ( KOPrefs::instance()->mShowIconMonth ) {goto MONTH ;}
271 if ( KOPrefs::instance()->mShowIconList ) { goto LIST ;} 271 if ( KOPrefs::instance()->mShowIconList ) { goto LIST ;}
272 //if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;goto ENTE ;} 272 //if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;goto ENTE ;}
273 ENTE: 273 ENTE:
274 flagResetViewChangeDate = 0; 274 flagResetViewChangeDate = 0;
275 selecteddatescount = mMainView->dateNavigator()->selectedDates().count(); 275 selecteddatescount = mMainView->dateNavigator()->selectedDates().count();
276 selecteddate = mMainView->dateNavigator()->selectedDates().first(); 276 selecteddate = mMainView->dateNavigator()->selectedDates().first();
277 277
278} 278}
279void KOViewManager::resetDateSilent( QDate date , int days ) 279void KOViewManager::resetDateSilent( QDate date , int days )
280{ 280{
281 mMainView->dateNavigator()->blockSignals( true ); 281 mMainView->dateNavigator()->blockSignals( true );
282 mMainView->dateNavigator()->selectDates( date , days ); 282 mMainView->dateNavigator()->selectDates( date , days );
283 mMainView->dateNavigator()->blockSignals( false ); 283 mMainView->dateNavigator()->blockSignals( false );
284} 284}
285void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) 285void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen )
286{ 286{
287 if ( flagResetViewChangeDate < 10 ) 287 if ( flagResetViewChangeDate < 10 )
288 ++flagResetViewChangeDate; 288 ++flagResetViewChangeDate;
289 //mFlagShowNextxDays = false; 289 //mFlagShowNextxDays = false;
290 //if(view == mCurrentView) return; 290 //if(view == mCurrentView) return;
291 if ( view == 0 ) { 291 if ( view == 0 ) {
292 view = mCurrentView; 292 view = mCurrentView;
293 if ( view == 0 ) 293 if ( view == 0 )
294 return; 294 return;
295 } 295 }
296 bool callupdate = !(view == mCurrentView); 296 bool callupdate = !(view == mCurrentView);
297 bool full = fullScreen; 297 bool full = fullScreen;
298 if(view == mCurrentView && view != mWhatsNextView ) { 298 if(view == mCurrentView && view != mWhatsNextView ) {
299 if ( mCurrentAgendaView < 0 ) 299 if ( mCurrentAgendaView < 0 )
300 return; 300 return;
301 if ( view != mMonthView ) 301 if ( view != mMonthView )
302 full = mMainView->leftFrame()->isVisible(); 302 full = mMainView->leftFrame()->isVisible();
303 } else { 303 } else {
304 if ( view == mMonthView && mMonthView) 304 if ( view == mMonthView && mMonthView)
305 ;//mMonthView->skipResize = true ; 305 ;//mMonthView->skipResize = true ;
306 mCurrentView = view; 306 mCurrentView = view;
307 // bool full = fullScreen; 307 // bool full = fullScreen;
308 bool isFull = !mMainView->leftFrame()->isVisible(); 308 bool isFull = !mMainView->leftFrame()->isVisible();
309 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) 309 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen )
310 full = true; 310 full = true;
311 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) 311 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen )
312 full = false; 312 full = false;
313 } 313 }
314 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); 314 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime();
315 //raiseCurrentView( full ); 315 //raiseCurrentView( full );
316 mMainView->processIncidenceSelection( 0 ); 316 mMainView->processIncidenceSelection( 0 );
317 //mMainView->updateView(); 317 //mMainView->updateView();
318 raiseCurrentView( full, callupdate ); 318 raiseCurrentView( full, callupdate );
319 mMainView->adaptNavigationUnits(); 319 mMainView->adaptNavigationUnits();
320 mMainView->updateUnmanagedViews(); 320 mMainView->updateUnmanagedViews();
321} 321}
322 322
323void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView ) 323void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView )
324{ 324{
325 mCurrentAgendaView = 0; 325 mCurrentAgendaView = 0;
326 if ( fullScreen ) { 326 if ( fullScreen ) {
327 mMainView->leftFrame()->hide(); 327 mMainView->leftFrame()->hide();
328 } else { 328 } else {
329 mMainView->leftFrame()->show(); 329 mMainView->leftFrame()->show();
330 } 330 }
331 //if ( mCurrentView == mMonthView ) qApp->processEvents(); 331 //if ( mCurrentView == mMonthView ) qApp->processEvents();
332 emit signalFullScreen( !fullScreen ); 332 emit signalFullScreen( !fullScreen );
333 if ( callUpdateView ) 333 if ( callUpdateView )
334 mMainView->updateView(); 334 mMainView->updateView();
335 335
336 if ( globalFlagBlockAgenda == 5 ) { 336 if ( globalFlagBlockAgenda == 5 ) {
337 globalFlagBlockAgenda = 4; 337 globalFlagBlockAgenda = 4;
338 globalFlagBlockAgendaItemPaint = 1; 338 globalFlagBlockAgendaItemPaint = 1;
339 } 339 }
340 mMainView->viewStack()->raiseWidget(mCurrentView); 340 mMainView->viewStack()->raiseWidget(mCurrentView);
341 if ( globalFlagBlockAgenda == 4 ) { 341 if ( globalFlagBlockAgenda == 4 ) {
342 if ( mCurrentView == mAgendaView ) { 342 if ( mCurrentView == mAgendaView ) {
343 //globalFlagBlockAgenda =1 ; 343 //globalFlagBlockAgenda =1 ;
344 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 344 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
345 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); 345 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins );
346 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 346 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
347 mAgendaView->setStartHour( QTime::currentTime ().hour() ); 347 mAgendaView->setStartHour( QTime::currentTime ().hour() );
348 qApp->processEvents(); 348 qApp->processEvents();
349 //qDebug("qApp->processEvents() "); 349 //qDebug("qApp->processEvents() ");
350 globalFlagBlockAgenda = 0; 350 globalFlagBlockAgenda = 0;
351 mAgendaView->repaintAgenda(); 351 mAgendaView->repaintAgenda();
352 352
353 } 353 }
354 globalFlagBlockAgenda = 0; 354 globalFlagBlockAgenda = 0;
355 } 355 }
356 emit signalAgendaView( mCurrentView == mAgendaView ); 356 emit signalAgendaView( mCurrentView == mAgendaView );
357 //qDebug("raiseCurrentView ende "); 357 //qDebug("raiseCurrentView ende ");
358 358
359} 359}
360 360
361void KOViewManager::clearAllViews()
362{
363
364 if ( mTodoView ) mTodoView->clearList();
365 if ( mListView ) mListView->clearList();
366
367 if ( mAgendaView ) mAgendaView->clearList();
368 if ( mMonthView ) mMonthView->clearList();
369 if ( mWhatsNextView ) mWhatsNextView->clearList();
370 if ( mJournalView ) mJournalView->clearList();
371
372}
361void KOViewManager::updateView() 373void KOViewManager::updateView()
362{ 374{
363 // qDebug("KOViewManager::updateView() "); 375 // qDebug("KOViewManager::updateView() ");
364 // if we are updating mTodoView, we get endless recursion 376 // if we are updating mTodoView, we get endless recursion
365 if ( mTodoView == mCurrentView ) 377 if ( mTodoView == mCurrentView )
366 return; 378 return;
367 if ( mCurrentView ) mCurrentView->updateView(); 379 if ( mCurrentView ) mCurrentView->updateView();
368 380
369} 381}
370 382
371void KOViewManager::updateView(const QDate &start, const QDate &end) 383void KOViewManager::updateView(const QDate &start, const QDate &end)
372{ 384{
373 // kdDebug() << "KOViewManager::updateView()" << endl; 385 // kdDebug() << "KOViewManager::updateView()" << endl;
374 386
375 if (mCurrentView) mCurrentView->showDates(start, end); 387 if (mCurrentView) mCurrentView->showDates(start, end);
376 388
377 if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView(); 389 if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView();
378} 390}
379 391
380 392
381void KOViewManager::updateWNview() 393void KOViewManager::updateWNview()
382{ 394{
383 if ( mCurrentView == mWhatsNextView && mWhatsNextView ) 395 if ( mCurrentView == mWhatsNextView && mWhatsNextView )
384 mWhatsNextView->updateView(); 396 mWhatsNextView->updateView();
385 if ( mCurrentView == mMonthView && mMonthView ) 397 if ( mCurrentView == mMonthView && mMonthView )
386 mMonthView->updateView(); 398 mMonthView->updateView();
387 399
388} 400}
389void KOViewManager::showWhatsNextView() 401void KOViewManager::showWhatsNextView()
390{ 402{
391 if (!mWhatsNextView) { 403 if (!mWhatsNextView) {
392 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), 404 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(),
393 "KOViewManager::WhatsNextView"); 405 "KOViewManager::WhatsNextView");
394 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); 406 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog());
395 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); 407 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig()));
396 addView(mWhatsNextView); 408 addView(mWhatsNextView);
397 connect(this, SIGNAL( printWNV() ), 409 connect(this, SIGNAL( printWNV() ),
398 mWhatsNextView, SLOT( printMe() ) ); 410 mWhatsNextView, SLOT( printMe() ) );
399 } 411 }
400 globalFlagBlockAgenda = 1; 412 globalFlagBlockAgenda = 1;
401 KOPrefs::instance()->mCurrentDisplayedView = VIEW_WN_VIEW; 413 KOPrefs::instance()->mCurrentDisplayedView = VIEW_WN_VIEW;
402 showView(mWhatsNextView, true ); 414 showView(mWhatsNextView, true );
403 //mWhatsNextView->updateView(); 415 //mWhatsNextView->updateView();
404 KOPrefs::instance()->mCurrentDisplayedView = VIEW_WN_VIEW; 416 KOPrefs::instance()->mCurrentDisplayedView = VIEW_WN_VIEW;
405} 417}
406 418
407void KOViewManager::slotprintWNV() 419void KOViewManager::slotprintWNV()
408{ 420{
409 if (!mWhatsNextView) 421 if (!mWhatsNextView)
410 showWhatsNextView(); 422 showWhatsNextView();
411 emit printWNV(); 423 emit printWNV();
412 424
413} 425}
414void KOViewManager::showListView() 426void KOViewManager::showListView()
415{ 427{
416 if (!mListView) { 428 if (!mListView) {
417 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); 429 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView");
418 addView(mListView); 430 addView(mListView);
419 431
420 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), 432 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)),
421 mMainView, SLOT(showIncidence(Incidence *))); 433 mMainView, SLOT(showIncidence(Incidence *)));
422 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), 434 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)),
423 mMainView, SLOT(editIncidence(Incidence *))); 435 mMainView, SLOT(editIncidence(Incidence *)));
424 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), 436 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)),
425 mMainView, SLOT(deleteIncidence(Incidence *))); 437 mMainView, SLOT(deleteIncidence(Incidence *)));
426 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), 438 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ),
427 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 439 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
428 connect( mListView, SIGNAL( signalNewEvent() ), 440 connect( mListView, SIGNAL( signalNewEvent() ),
429 mMainView, SLOT( newEvent() ) ); 441 mMainView, SLOT( newEvent() ) );
430 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); 442 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig()));
431 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 443 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
432 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 444 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
433 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 445 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
434 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 446 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
435 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 447 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
436 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 448 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
437 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 449 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
438 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 450 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
439 } 451 }
440 // bool temp = mFlagShowNextxDays; 452 // bool temp = mFlagShowNextxDays;
441 //globalFlagBlockPainting = true; 453 //globalFlagBlockPainting = true;
442 globalFlagBlockAgenda = 1; 454 globalFlagBlockAgenda = 1;
443 if ( KOPrefs::instance()->mListViewMonthTimespan ) { 455 if ( KOPrefs::instance()->mListViewMonthTimespan ) {
444 mMainView->setBlockShowDates( true ); 456 mMainView->setBlockShowDates( true );
445 mMainView->dateNavigator()->selectMonth(); 457 mMainView->dateNavigator()->selectMonth();
446 mMainView->setBlockShowDates( false ); 458 mMainView->setBlockShowDates( false );
447 } 459 }
448 KOPrefs::instance()->mCurrentDisplayedView = VIEW_L_VIEW; 460 KOPrefs::instance()->mCurrentDisplayedView = VIEW_L_VIEW;
449 showView(mListView, KOPrefs::instance()->mFullViewTodo); 461 showView(mListView, KOPrefs::instance()->mFullViewTodo);
450 //mFlagShowNextxDays = temp; 462 //mFlagShowNextxDays = temp;
451 KOPrefs::instance()->mCurrentDisplayedView = VIEW_L_VIEW; 463 KOPrefs::instance()->mCurrentDisplayedView = VIEW_L_VIEW;
452} 464}
453 465
454void KOViewManager::showAgendaView( bool fullScreen ) 466void KOViewManager::showAgendaView( bool fullScreen )
455{ 467{
456 468
457 mMainView->dialogManager()->hideSearchDialog(); 469 mMainView->dialogManager()->hideSearchDialog();
458 // qDebug("KOViewManager::showAgendaView "); 470 // qDebug("KOViewManager::showAgendaView ");
459 bool full; 471 bool full;
460 full = fullScreen; 472 full = fullScreen;
461 if (!mAgendaView) { 473 if (!mAgendaView) {
462 full = false; 474 full = false;
463 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); 475 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView");
464 addView(mAgendaView); 476 addView(mAgendaView);
465#ifndef DESKTOP_VERSION 477#ifndef DESKTOP_VERSION
466 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); 478 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold );
467#endif 479#endif
468 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), 480 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )),
469 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); 481 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) ));
470 482
471 // SIGNALS/SLOTS FOR DAY/WEEK VIEW 483 // SIGNALS/SLOTS FOR DAY/WEEK VIEW
472 484
473 connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate ))); 485 connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate )));
474 486
475 connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)), 487 connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)),
476 mMainView, SLOT(newTodoDateTime(QDateTime,bool))); 488 mMainView, SLOT(newTodoDateTime(QDateTime,bool)));
477 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), 489 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)),
478 mMainView, SLOT(newEvent(QDateTime))); 490 mMainView, SLOT(newEvent(QDateTime)));
479 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), 491 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)),
480 mMainView, SLOT(newEvent(QDateTime,QDateTime))); 492 mMainView, SLOT(newEvent(QDateTime,QDateTime)));
481 connect(mAgendaView,SIGNAL(newEventSignal(QDate)), 493 connect(mAgendaView,SIGNAL(newEventSignal(QDate)),
482 mMainView, SLOT(newEvent(QDate))); 494 mMainView, SLOT(newEvent(QDate)));
483 495
484 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), 496 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)),
485 mMainView, SLOT(editIncidence(Incidence *))); 497 mMainView, SLOT(editIncidence(Incidence *)));
486 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), 498 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)),
487 mMainView, SLOT(showIncidence(Incidence *))); 499 mMainView, SLOT(showIncidence(Incidence *)));
488 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), 500 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)),
@@ -707,132 +719,131 @@ void KOViewManager::showMonthView()
707 719
708 showView(mMonthView, full ); 720 showView(mMonthView, full );
709 mMonthView->setKeyBFocus(); 721 mMonthView->setKeyBFocus();
710 KOPrefs::instance()->mCurrentDisplayedView = VIEW_M_VIEW ; 722 KOPrefs::instance()->mCurrentDisplayedView = VIEW_M_VIEW ;
711 723
712} 724}
713 725
714void KOViewManager::showTodoView() 726void KOViewManager::showTodoView()
715{ 727{
716 //mFlagShowNextxDays = false; 728 //mFlagShowNextxDays = false;
717 if ( !mTodoView ) { 729 if ( !mTodoView ) {
718 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), 730 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(),
719 "KOViewManager::TodoView" ); 731 "KOViewManager::TodoView" );
720 732
721 addView( mTodoView ); 733 addView( mTodoView );
722 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); 734 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold );
723 735
724 // SIGNALS/SLOTS FOR TODO VIEW 736 // SIGNALS/SLOTS FOR TODO VIEW
725 connect( mTodoView, SIGNAL( newTodoSignal() ), 737 connect( mTodoView, SIGNAL( newTodoSignal() ),
726 mMainView, SLOT( newTodo() ) ); 738 mMainView, SLOT( newTodo() ) );
727 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), 739 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ),
728 mMainView, SLOT( newSubTodo( Todo *) ) ); 740 mMainView, SLOT( newSubTodo( Todo *) ) );
729 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), 741 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ),
730 mMainView, SLOT( showTodo( Todo * ) ) ); 742 mMainView, SLOT( showTodo( Todo * ) ) );
731 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), 743 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ),
732 mMainView, SLOT( editTodo( Todo * ) ) ); 744 mMainView, SLOT( editTodo( Todo * ) ) );
733 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), 745 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ),
734 mMainView, SLOT( deleteTodo( Todo * ) ) ); 746 mMainView, SLOT( deleteTodo( Todo * ) ) );
735 connect( mTodoView, SIGNAL( purgeCompletedSignal() ), 747 connect( mTodoView, SIGNAL( purgeCompletedSignal() ),
736 mMainView, SLOT( purgeCompleted() ) ); 748 mMainView, SLOT( purgeCompleted() ) );
737 749
738 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), 750 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ),
739 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 751 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
740 752
741 connect( mMainView, SIGNAL( configChanged() ), mTodoView, 753 connect( mMainView, SIGNAL( configChanged() ), mTodoView,
742 SLOT( updateConfig() ) ); 754 SLOT( updateConfig() ) );
743 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, 755 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView,
744 SLOT( updateTodo( Todo *, int ) ) ); 756 SLOT( updateTodo( Todo *, int ) ) );
745 connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), 757 connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ),
746 mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); 758 mMainView, SIGNAL ( todoModified( Todo *, int ) ) );
747 connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), 759 connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ),
748 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 760 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
749 connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), 761 connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ),
750 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 762 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
751 connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), 763 connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ),
752 mMainView, SLOT ( todo_unsub( Todo * ) ) ); 764 mMainView, SLOT ( todo_unsub( Todo * ) ) );
753 connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 765 connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
754 mMainView, SLOT ( todo_resub( Todo *, Todo *) ) ); 766 mMainView, SLOT ( todo_resub( Todo *, Todo *) ) );
755 connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ), 767 connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ),
756 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 768 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
757 connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ), 769 connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ),
758 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 770 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
759 KConfig *config = KOGlobals::config(); 771 KConfig *config = KOGlobals::config();
760 mTodoView->restoreLayout(config,"Todo View"); 772 mTodoView->restoreLayout(config,"Todo View");
761 mTodoView->setNavigator( mMainView->dateNavigator() ); 773 mTodoView->setNavigator( mMainView->dateNavigator() );
762 } 774 }
763 775
764 KOPrefs::instance()->mCurrentDisplayedView = VIEW_T_VIEW ; 776 KOPrefs::instance()->mCurrentDisplayedView = VIEW_T_VIEW ;
765 globalFlagBlockAgenda = 1; 777 globalFlagBlockAgenda = 1;
766 showView( mTodoView, true ); 778 showView( mTodoView, true );
767 KOPrefs::instance()->mCurrentDisplayedView = VIEW_T_VIEW ; 779 KOPrefs::instance()->mCurrentDisplayedView = VIEW_T_VIEW ;
768 780
769} 781}
770 782
771void KOViewManager::showJournalView() 783void KOViewManager::showJournalView()
772{ 784{
773 //mFlagShowNextxDays = false; 785 //mFlagShowNextxDays = false;
774 if (!mJournalView) { 786 if (!mJournalView) {
775 mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), 787 mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(),
776 "KOViewManager::JournalView"); 788 "KOViewManager::JournalView");
777 connect( mMainView, SIGNAL( configChanged() ), mJournalView, 789 connect( mMainView, SIGNAL( configChanged() ), mJournalView,
778 SLOT( updateConfig() ) ); 790 SLOT( updateConfig() ) );
779 connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); 791 connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) );
780 addView(mJournalView); 792 addView(mJournalView);
781 } 793 }
782 794
783 KOPrefs::instance()->mCurrentDisplayedView = VIEW_J_VIEW ; 795 KOPrefs::instance()->mCurrentDisplayedView = VIEW_J_VIEW ;
784 showView(mJournalView); 796 showView(mJournalView);
785 mMainView->dateNavigator()->selectDates( 1 ); 797 mMainView->dateNavigator()->selectDates( 1 );
786 KOPrefs::instance()->mCurrentDisplayedView = VIEW_J_VIEW ; 798 KOPrefs::instance()->mCurrentDisplayedView = VIEW_J_VIEW ;
787} 799}
788 800
789void KOViewManager::showTimeSpanView() 801void KOViewManager::showTimeSpanView()
790{ 802{
791 //mFlagShowNextxDays = false; 803 //mFlagShowNextxDays = false;
792 if (!mTimeSpanView) { 804 if (!mTimeSpanView) {
793 mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(), 805 mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(),
794 "KOViewManager::TimeSpanView"); 806 "KOViewManager::TimeSpanView");
795 addView(mTimeSpanView); 807 addView(mTimeSpanView);
796 808
797 mTimeSpanView->readSettings(); 809 mTimeSpanView->readSettings();
798 } 810 }
799 811
800 showView(mTimeSpanView); 812 showView(mTimeSpanView);
801} 813}
802 814
803Incidence *KOViewManager::currentSelection() 815Incidence *KOViewManager::currentSelection()
804{ 816{
805 if (!mCurrentView) return 0; 817 if (!mCurrentView) return 0;
806 if ( mCurrentView == mListView ) { 818 if ( mCurrentView == mListView ) {
807 if ( mListView->currentItem() ) 819 if ( mListView->currentItem() )
808 return mListView->currentItem(); 820 return mListView->currentItem();
809 } 821 }
810 return mCurrentView->selectedIncidences().first(); 822 return mCurrentView->selectedIncidences().first();
811} 823}
812 824
813QDate KOViewManager::currentSelectionDate() 825QDate KOViewManager::currentSelectionDate()
814{ 826{
815 QDate qd; 827 QDate qd;
816 if (mCurrentView) { 828 if (mCurrentView) {
817 DateList qvl = mCurrentView->selectedDates(); 829 DateList qvl = mCurrentView->selectedDates();
818 if (!qvl.isEmpty()) qd = qvl.first(); 830 if (!qvl.isEmpty()) qd = qvl.first();
819 } 831 }
820 return qd; 832 return qd;
821} 833}
822 834
823void KOViewManager::addView(KOrg::BaseView *view) 835void KOViewManager::addView(KOrg::BaseView *view)
824{ 836{
825#if QT_VERSION >= 0x030000 837#if QT_VERSION >= 0x030000
826 mMainView->viewStack()->addWidget( view ); 838 mMainView->viewStack()->addWidget( view );
827#else 839#else
828 mMainView->viewStack()->addWidget( view, 1 ); 840 mMainView->viewStack()->addWidget( view, 1 );
829#endif 841#endif
830} 842}
831 843
832void KOViewManager::setDocumentId( const QString &id ) 844void KOViewManager::setDocumentId( const QString &id )
833{ 845{
834 if (mTodoView) { 846 if (mTodoView) {
835 mTodoView->clearList();
836 mTodoView->setDocumentId( id ); 847 mTodoView->setDocumentId( id );
837 } 848 }
838} 849}
diff --git a/korganizer/koviewmanager.h b/korganizer/koviewmanager.h
index 8dc03e0..838583b 100644
--- a/korganizer/koviewmanager.h
+++ b/korganizer/koviewmanager.h
@@ -1,126 +1,127 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 3 Copyright (c) 2001
4 Cornelius Schumacher <schumacher@kde.org> 4 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 KOVIEWMANAGER_H 24#ifndef KOVIEWMANAGER_H
25#define KOVIEWMANAGER_H 25#define KOVIEWMANAGER_H
26 26
27#include <qobject.h> 27#include <qobject.h>
28 28
29#include <korganizer/baseview.h> 29#include <korganizer/baseview.h>
30 30
31class CalendarView; 31class CalendarView;
32 32
33class KOListView; 33class KOListView;
34class KOAgendaView; 34class KOAgendaView;
35class KOMonthView; 35class KOMonthView;
36class KOTimeSpanView; 36class KOTimeSpanView;
37class KOTodoView; 37class KOTodoView;
38class KOWhatsNextView; 38class KOWhatsNextView;
39class KOJournalView; 39class KOJournalView;
40 40
41using namespace KCal; 41using namespace KCal;
42 42
43/** 43/**
44 This class manages the views of the calendar. It owns the objects and handles 44 This class manages the views of the calendar. It owns the objects and handles
45 creation and selection. 45 creation and selection.
46*/ 46*/
47class KOViewManager : public QObject 47class KOViewManager : public QObject
48{ 48{
49 Q_OBJECT 49 Q_OBJECT
50 public: 50 public:
51 KOViewManager( CalendarView * ); 51 KOViewManager( CalendarView * );
52 virtual ~KOViewManager(); 52 virtual ~KOViewManager();
53 53
54 /** changes the view to be the currently selected view */ 54 /** changes the view to be the currently selected view */
55 void showView(KOrg::BaseView *, bool fullScreen = false ); 55 void showView(KOrg::BaseView *, bool fullScreen = false );
56 void updateWNview(); 56 void updateWNview();
57 void readSettings(KConfig *config); 57 void readSettings(KConfig *config);
58 void writeSettings(KConfig *config); 58 void writeSettings(KConfig *config);
59 bool showsNextDays(); 59 bool showsNextDays();
60 /** Read which view was shown last from config file */ 60 /** Read which view was shown last from config file */
61 void readCurrentView(KConfig *); 61 void readCurrentView(KConfig *);
62 /** Write which view is currently shown to config file */ 62 /** Write which view is currently shown to config file */
63 void writeCurrentView(KConfig *); 63 void writeCurrentView(KConfig *);
64 64
65 KOrg::BaseView *currentView(); 65 KOrg::BaseView *currentView();
66 66
67 void setDocumentId( const QString & ); 67 void setDocumentId( const QString & );
68 68
69 void updateView( const QDate &start, const QDate &end ); 69 void updateView( const QDate &start, const QDate &end );
70 void clearAllViews();
70 71
71 void raiseCurrentView( bool fullScreen = false , bool updateView = false); 72 void raiseCurrentView( bool fullScreen = false , bool updateView = false);
72 73
73 void addView(KOrg::BaseView *); 74 void addView(KOrg::BaseView *);
74 75
75 Incidence *currentSelection(); 76 Incidence *currentSelection();
76 QDate currentSelectionDate(); 77 QDate currentSelectionDate();
77 78
78 KOAgendaView *agendaView() const { return mAgendaView; } 79 KOAgendaView *agendaView() const { return mAgendaView; }
79 80
80 signals: 81 signals:
81 void printWNV(); 82 void printWNV();
82 void signalFullScreen( bool ); 83 void signalFullScreen( bool );
83 void signalAgendaView( bool ); 84 void signalAgendaView( bool );
84 public slots: 85 public slots:
85 void slotprintWNV(); 86 void slotprintWNV();
86 void showNextView(); 87 void showNextView();
87 void showMonth( const QDate & ); 88 void showMonth( const QDate & );
88 void showDateView( int, QDate ); 89 void showDateView( int, QDate );
89 void updateView(); 90 void updateView();
90 void showWhatsNextView(); 91 void showWhatsNextView();
91 void showListView(); 92 void showListView();
92 void showAgendaView( bool fullScreen = false ); 93 void showAgendaView( bool fullScreen = false );
93 void showDayView(); 94 void showDayView();
94 void showWorkWeekView(); 95 void showWorkWeekView();
95 void showWeekView(); 96 void showWeekView();
96 void showNextXView(); 97 void showNextXView();
97 void showMonthView(); 98 void showMonthView();
98 void showMonthViewWeek(); 99 void showMonthViewWeek();
99 void showTodoView(); 100 void showTodoView();
100 void showJournalView(); 101 void showJournalView();
101 void showTimeSpanView(); 102 void showTimeSpanView();
102 103
103 private: 104 private:
104 void resetDateSilent( QDate date , int days ); 105 void resetDateSilent( QDate date , int days );
105 int flagResetViewChangeDate; 106 int flagResetViewChangeDate;
106 QDate currentViewChangeDate; 107 QDate currentViewChangeDate;
107 void createMonthView(); 108 void createMonthView();
108 CalendarView *mMainView; 109 CalendarView *mMainView;
109 110
110 int mCurrentAgendaView; 111 int mCurrentAgendaView;
111 KOAgendaView *mAgendaView; 112 KOAgendaView *mAgendaView;
112 KOListView *mListView; 113 KOListView *mListView;
113 KOMonthView *mMonthView; 114 KOMonthView *mMonthView;
114 KOTodoView *mTodoView; 115 KOTodoView *mTodoView;
115 KOWhatsNextView *mWhatsNextView; 116 KOWhatsNextView *mWhatsNextView;
116 KOJournalView *mJournalView; 117 KOJournalView *mJournalView;
117 KOTimeSpanView *mTimeSpanView; 118 KOTimeSpanView *mTimeSpanView;
118 119
119 KOrg::BaseView *mCurrentView; // currently active event view 120 KOrg::BaseView *mCurrentView; // currently active event view
120 121
121 int mAgendaViewMode; 122 int mAgendaViewMode;
122 bool mFlagShowNextxDays; 123 bool mFlagShowNextxDays;
123 124
124}; 125};
125 126
126#endif 127#endif
diff --git a/korganizer/kowhatsnextview.cpp b/korganizer/kowhatsnextview.cpp
index 65d8ac3..62d7ede 100644
--- a/korganizer/kowhatsnextview.cpp
+++ b/korganizer/kowhatsnextview.cpp
@@ -14,256 +14,261 @@
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 19
20#include <qlayout.h> 20#include <qlayout.h>
21#include <qtextbrowser.h> 21#include <qtextbrowser.h>
22#include <qtextcodec.h> 22#include <qtextcodec.h>
23#include <qfileinfo.h> 23#include <qfileinfo.h>
24#include <qlabel.h> 24#include <qlabel.h>
25 25
26#include <qapplication.h> 26#include <qapplication.h>
27#ifdef DESKTOP_VERSION 27#ifdef DESKTOP_VERSION
28#include <qpaintdevicemetrics.h> 28#include <qpaintdevicemetrics.h>
29#endif 29#endif
30#include <kglobal.h> 30#include <kglobal.h>
31#include <klocale.h> 31#include <klocale.h>
32#include <kdebug.h> 32#include <kdebug.h>
33#include <kiconloader.h> 33#include <kiconloader.h>
34#include <kmessagebox.h> 34#include <kmessagebox.h>
35 35
36#include <libkcal/calendar.h> 36#include <libkcal/calendar.h>
37 37
38#ifndef KORG_NOPRINTER 38#ifndef KORG_NOPRINTER
39#include "calprinter.h" 39#include "calprinter.h"
40#endif 40#endif
41#include "koglobals.h" 41#include "koglobals.h"
42#include "koprefs.h" 42#include "koprefs.h"
43#include "koeventviewerdialog.h" 43#include "koeventviewerdialog.h"
44#include "koeventviewer.h" 44#include "koeventviewer.h"
45#include <qstylesheet.h> 45#include <qstylesheet.h>
46#include "kowhatsnextview.h" 46#include "kowhatsnextview.h"
47using namespace KOrg; 47using namespace KOrg;
48 48
49void WhatsNextTextBrowser::setSource(const QString& n) 49void WhatsNextTextBrowser::setSource(const QString& n)
50{ 50{
51 51
52 if (n.startsWith("event:")) { 52 if (n.startsWith("event:")) {
53 emit showIncidence(n); 53 emit showIncidence(n);
54 return; 54 return;
55 } else if (n.startsWith("todo:")) { 55 } else if (n.startsWith("todo:")) {
56 emit showIncidence(n); 56 emit showIncidence(n);
57 return; 57 return;
58 } else { 58 } else {
59 QTextBrowser::setSource(n); 59 QTextBrowser::setSource(n);
60 } 60 }
61} 61}
62void WhatsNextTextBrowser::printMe() 62void WhatsNextTextBrowser::printMe()
63{ 63{
64#ifdef DESKTOP_VERSION 64#ifdef DESKTOP_VERSION
65 KOPrintPrefs pp ( this ); 65 KOPrintPrefs pp ( this );
66 if (!pp.exec() ) 66 if (!pp.exec() )
67 return; 67 return;
68 int scaleval = pp.printMode() ; 68 int scaleval = pp.printMode() ;
69 69
70 QPrinter printer; 70 QPrinter printer;
71 if (!printer.setup() ) 71 if (!printer.setup() )
72 return; 72 return;
73 QPainter p; 73 QPainter p;
74 p.begin ( &printer ); 74 p.begin ( &printer );
75 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); 75 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer );
76 float dx, dy; 76 float dx, dy;
77 int wid = (m.width() * 9)/10; 77 int wid = (m.width() * 9)/10;
78 dx = (float) wid/(float)contentsWidth (); 78 dx = (float) wid/(float)contentsWidth ();
79 dy = (float)(m.height()) / (float)contentsHeight (); 79 dy = (float)(m.height()) / (float)contentsHeight ();
80 float scale; 80 float scale;
81 // scale to fit the width or height of the paper 81 // scale to fit the width or height of the paper
82 if ( dx < dy ) 82 if ( dx < dy )
83 scale = dx; 83 scale = dx;
84 else 84 else
85 scale = dy; 85 scale = dy;
86 p.translate( m.width()/10,0 ); 86 p.translate( m.width()/10,0 );
87 if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { 87 if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) {
88 p.scale( scale, scale ); 88 p.scale( scale, scale );
89 } 89 }
90 drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); 90 drawContents ( &p, 0,0, contentsWidth (), contentsHeight () );
91 p.end(); 91 p.end();
92#endif 92#endif
93} 93}
94 94
95KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent, 95KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent,
96 const char *name) 96 const char *name)
97 : KOrg::BaseView(calendar, parent, name) 97 : KOrg::BaseView(calendar, parent, name)
98{ 98{
99 // mDateLabel = 99 // mDateLabel =
100 // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this); 100 // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this);
101 // mDateLabel->setMargin(2); 101 // mDateLabel->setMargin(2);
102 // mDateLabel->setAlignment(AlignCenter); 102 // mDateLabel->setAlignment(AlignCenter);
103 setFont( KOPrefs::instance()->mWhatsNextFont ); 103 setFont( KOPrefs::instance()->mWhatsNextFont );
104 mView = new WhatsNextTextBrowser(this); 104 mView = new WhatsNextTextBrowser(this);
105 connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &))); 105 connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &)));
106 QStyleSheet* stsh = mView->styleSheet(); 106 QStyleSheet* stsh = mView->styleSheet();
107 QStyleSheetItem * style ; 107 QStyleSheetItem * style ;
108 style = stsh->item ("h2" ); 108 style = stsh->item ("h2" );
109 if ( style ) { 109 if ( style ) {
110 style->setMargin(QStyleSheetItem::MarginAll,0); 110 style->setMargin(QStyleSheetItem::MarginAll,0);
111 } 111 }
112 style = stsh->item ("h3" ); 112 style = stsh->item ("h3" );
113 if ( style ) { 113 if ( style ) {
114 style->setMargin(QStyleSheetItem::MarginAll,0); 114 style->setMargin(QStyleSheetItem::MarginAll,0);
115 } 115 }
116 mEventViewer = 0; 116 mEventViewer = 0;
117 117
118 QBoxLayout *topLayout = new QVBoxLayout(this); 118 QBoxLayout *topLayout = new QVBoxLayout(this);
119 // topLayout->addWidget(mDateLabel); 119 // topLayout->addWidget(mDateLabel);
120 topLayout->addWidget(mView); 120 topLayout->addWidget(mView);
121 mTimer = new QTimer( this ); 121 mTimer = new QTimer( this );
122 connect(mTimer,SIGNAL( timeout() ),this, SLOT(updateView())); 122 connect(mTimer,SIGNAL( timeout() ),this, SLOT(updateView()));
123 123
124 connect(mView->horizontalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); 124 connect(mView->horizontalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer()));
125 connect(mView->verticalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); 125 connect(mView->verticalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer()));
126} 126}
127 127
128KOWhatsNextView::~KOWhatsNextView() 128KOWhatsNextView::~KOWhatsNextView()
129{ 129{
130} 130}
131 131
132int KOWhatsNextView::maxDatesHint() 132int KOWhatsNextView::maxDatesHint()
133{ 133{
134 return 0; 134 return 0;
135} 135}
136 136
137int KOWhatsNextView::currentDateCount() 137int KOWhatsNextView::currentDateCount()
138{ 138{
139 return 0; 139 return 0;
140} 140}
141 141
142void KOWhatsNextView::clearList()
143{
144 mTimer->stop();
145 mView->setText(" ");
146}
142QPtrList<Incidence> KOWhatsNextView::selectedIncidences() 147QPtrList<Incidence> KOWhatsNextView::selectedIncidences()
143{ 148{
144 QPtrList<Incidence> eventList; 149 QPtrList<Incidence> eventList;
145 150
146 return eventList; 151 return eventList;
147} 152}
148 153
149void KOWhatsNextView::printMe() 154void KOWhatsNextView::printMe()
150{ 155{
151#ifdef DESKTOP_VERSION 156#ifdef DESKTOP_VERSION
152 mView->printMe(); 157 mView->printMe();
153#endif 158#endif
154} 159}
155void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd, 160void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd,
156 const QDate &td) 161 const QDate &td)
157{ 162{
158#ifndef KORG_NOPRINTER 163#ifndef KORG_NOPRINTER
159 calPrinter->preview(CalPrinter::Day, fd, td); 164 calPrinter->preview(CalPrinter::Day, fd, td);
160#endif 165#endif
161} 166}
162void KOWhatsNextView::updateConfig() 167void KOWhatsNextView::updateConfig()
163{ 168{
164 setFont( KOPrefs::instance()->mWhatsNextFont ); 169 setFont( KOPrefs::instance()->mWhatsNextFont );
165 updateView(); 170 updateView();
166 171
167} 172}
168void KOWhatsNextView::showEvent ( QShowEvent * e ) 173void KOWhatsNextView::showEvent ( QShowEvent * e )
169{ 174{
170 //qDebug("KOWhatsNextView::showEvent "); 175 //qDebug("KOWhatsNextView::showEvent ");
171 restartTimer(); 176 restartTimer();
172 QWidget::showEvent ( e ); 177 QWidget::showEvent ( e );
173} 178}
174void KOWhatsNextView::hideEvent ( QHideEvent * e) 179void KOWhatsNextView::hideEvent ( QHideEvent * e)
175{ 180{
176 //qDebug(" KOWhatsNextView::hideEvent"); 181 //qDebug(" KOWhatsNextView::hideEvent");
177 mTimer->stop(); 182 mTimer->stop();
178 QWidget::hideEvent ( e ); 183 QWidget::hideEvent ( e );
179} 184}
180void KOWhatsNextView::restartTimer() 185void KOWhatsNextView::restartTimer()
181{ 186{
182 //qDebug("KOWhatsNextView::restartTimer() "); 187 //qDebug("KOWhatsNextView::restartTimer() ");
183 mTimer->start( 300000 ); 188 mTimer->start( 300000 );
184 //mTimer->start( 5000 ); 189 //mTimer->start( 5000 );
185} 190}
186void KOWhatsNextView::updateView() 191void KOWhatsNextView::updateView()
187{ 192{
188 //qDebug("KOWhatsNextView::updateView() "); 193 //qDebug("KOWhatsNextView::updateView() ");
189 if ( mTimer->isActive() ) 194 if ( mTimer->isActive() )
190 restartTimer(); 195 restartTimer();
191 mCurrentMaxPrio = 5; 196 mCurrentMaxPrio = 5;
192 //qDebug("KOWhatsNextView::updateView() "); 197 //qDebug("KOWhatsNextView::updateView() ");
193 // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate())); 198 // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate()));
194 KIconLoader kil("korganizer"); 199 KIconLoader kil("korganizer");
195 QString ipath;// = new QString(); 200 QString ipath;// = new QString();
196 // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath); 201 // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath);
197 //<big><big><strong>" + date + "</strong></big></big>\n"; 202 //<big><big><strong>" + date + "</strong></big></big>\n";
198 mText = "<table width=\"100%\">\n"; 203 mText = "<table width=\"100%\">\n";
199 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; 204 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
200#ifdef DESKTOP_VERSION 205#ifdef DESKTOP_VERSION
201 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>"; 206 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>";
202#else 207#else
203 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; 208 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>";
204#endif 209#endif
205 // mText += "<img src=\""; 210 // mText += "<img src=\"";
206 // mText += ipath; 211 // mText += ipath;
207 // mText += "\">"; 212 // mText += "\">";
208 mEventDate = QDate::currentDate(); 213 mEventDate = QDate::currentDate();
209#ifdef DESKTOP_VERSION 214#ifdef DESKTOP_VERSION
210 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>"; 215 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>";
211#else 216#else
212 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>"; 217 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>";
213#endif 218#endif
214 mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; 219 mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>";
215 int iii; 220 int iii;
216 mTodos.clear(); 221 mTodos.clear();
217 QPtrList<Event> events; 222 QPtrList<Event> events;
218 QPtrList<Todo> todos = calendar()->todos(); 223 QPtrList<Todo> todos = calendar()->todos();
219 Todo * todo; 224 Todo * todo;
220 //mText += "<h2>" + i18n("Events: ") + "</h2>\n"; 225 //mText += "<h2>" + i18n("Events: ") + "</h2>\n";
221 int daysToShow = KOPrefs::instance()->mWhatsNextDays ; 226 int daysToShow = KOPrefs::instance()->mWhatsNextDays ;
222 bool itemAdded = false; 227 bool itemAdded = false;
223 for ( iii = 0; iii < daysToShow; ++iii ) { 228 for ( iii = 0; iii < daysToShow; ++iii ) {
224 QString date; 229 QString date;
225 itemAdded = false; 230 itemAdded = false;
226 events = calendar()->events( mEventDate, true ); 231 events = calendar()->events( mEventDate, true );
227 232
228 if ( iii == 0 ) { // today !!! 233 if ( iii == 0 ) { // today !!!
229 todo = todos.first(); 234 todo = todos.first();
230 while(todo) { 235 while(todo) {
231 if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) { 236 if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) {
232 if ( ! itemAdded ) { 237 if ( ! itemAdded ) {
233 appendDay ( iii, mEventDate ); 238 appendDay ( iii, mEventDate );
234 //itemAdded = true; 239 //itemAdded = true;
235 240
236 } //bool reply=false, bool notRed = true, bool appendTable = false); 241 } //bool reply=false, bool notRed = true, bool appendTable = false);
237 appendEvent(todo, false, false, !itemAdded ); 242 appendEvent(todo, false, false, !itemAdded );
238 itemAdded = true; 243 itemAdded = true;
239 } 244 }
240 todo = todos.next(); 245 todo = todos.next();
241 } 246 }
242 } 247 }
243 248
244 249
245 if (events.count() > 0) { 250 if (events.count() > 0) {
246 // mText += "<p></p>"; 251 // mText += "<p></p>";
247 // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); 252 // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath);
248 // mText += "<h2>"; 253 // mText += "<h2>";
249 //mText += " <img src=\""; 254 //mText += " <img src=\"";
250 //mText += ipath; 255 //mText += ipath;
251 //mText += "\">"; 256 //mText += "\">";
252 if ( ! itemAdded ) { 257 if ( ! itemAdded ) {
253 appendDay ( iii, mEventDate ); 258 appendDay ( iii, mEventDate );
254 259
255 } 260 }
256 // for first day (iii == 0) 261 // for first day (iii == 0)
257 // we may have syncevents, or events in the past, which maybe should not be diaplayed 262 // we may have syncevents, or events in the past, which maybe should not be diaplayed
258 // for that reason we cannot append <table> in appendDay () for iii == 0 263 // for that reason we cannot append <table> in appendDay () for iii == 0
259 // we must append it in the first successful call of appendEvent() 264 // we must append it in the first successful call of appendEvent()
260 Event *ev = events.first(); 265 Event *ev = events.first();
261 while(ev) { 266 while(ev) {
262 //qDebug("+++++event append %s", ev->summary().latin1()); 267 //qDebug("+++++event append %s", ev->summary().latin1());
263 if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) { 268 if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) {
264 if ( appendEvent(ev, false , iii!= 0,!itemAdded ) ) 269 if ( appendEvent(ev, false , iii!= 0,!itemAdded ) )
265 itemAdded = true; 270 itemAdded = true;
266 } 271 }
267 ev = events.next(); 272 ev = events.next();
268 } 273 }
269 274
diff --git a/korganizer/kowhatsnextview.h b/korganizer/kowhatsnextview.h
index d6727ac..93574ef 100644
--- a/korganizer/kowhatsnextview.h
+++ b/korganizer/kowhatsnextview.h
@@ -1,101 +1,102 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19#ifndef KOWHATSNEXTVIEW_H 19#ifndef KOWHATSNEXTVIEW_H
20#define KOWHATSNEXTVIEW_H 20#define KOWHATSNEXTVIEW_H
21 21
22#include <qtextbrowser.h> 22#include <qtextbrowser.h>
23#include <qtimer.h> 23#include <qtimer.h>
24 24
25#include <korganizer/baseview.h> 25#include <korganizer/baseview.h>
26 26
27class QListView; 27class QListView;
28class QLabel; 28class QLabel;
29 29
30class KOEventViewerDialog; 30class KOEventViewerDialog;
31 31
32#include <qpainter.h> 32#include <qpainter.h>
33#include <qwidget.h> 33#include <qwidget.h>
34class WhatsNextTextBrowser : public QTextBrowser { 34class WhatsNextTextBrowser : public QTextBrowser {
35 Q_OBJECT 35 Q_OBJECT
36 public: 36 public:
37 WhatsNextTextBrowser(QWidget *parent) : QTextBrowser(parent) {}; 37 WhatsNextTextBrowser(QWidget *parent) : QTextBrowser(parent) {};
38 38
39 void setSource(const QString &); 39 void setSource(const QString &);
40 void printMe(); 40 void printMe();
41 41
42 signals: 42 signals:
43 void showIncidence(const QString &uid); 43 void showIncidence(const QString &uid);
44}; 44};
45 45
46 46
47/** 47/**
48 This class provides a view of the next events and todos 48 This class provides a view of the next events and todos
49*/ 49*/
50class KOWhatsNextView : public KOrg::BaseView 50class KOWhatsNextView : public KOrg::BaseView
51{ 51{
52 Q_OBJECT 52 Q_OBJECT
53 public: 53 public:
54 KOWhatsNextView(Calendar *calendar, QWidget *parent = 0, 54 KOWhatsNextView(Calendar *calendar, QWidget *parent = 0,
55 const char *name = 0); 55 const char *name = 0);
56 ~KOWhatsNextView(); 56 ~KOWhatsNextView();
57 57
58 virtual int maxDatesHint(); 58 virtual int maxDatesHint();
59 virtual int currentDateCount(); 59 virtual int currentDateCount();
60 void setEventViewer(KOEventViewerDialog* v ); 60 void setEventViewer(KOEventViewerDialog* v );
61 virtual QPtrList<Incidence> selectedIncidences(); 61 virtual QPtrList<Incidence> selectedIncidences();
62 void clearList();
62 DateList selectedDates() 63 DateList selectedDates()
63 {DateList q; 64 {DateList q;
64 return q;} 65 return q;}
65 virtual void printPreview(CalPrinter *calPrinter, 66 virtual void printPreview(CalPrinter *calPrinter,
66 const QDate &, const QDate &); 67 const QDate &, const QDate &);
67 68
68 public slots: 69 public slots:
69 virtual void updateView(); 70 virtual void updateView();
70 void printMe(); 71 void printMe();
71 virtual void showDates(const QDate &start, const QDate &end); 72 virtual void showDates(const QDate &start, const QDate &end);
72 virtual void showEvents(QPtrList<Event> eventList); 73 virtual void showEvents(QPtrList<Event> eventList);
73 void updateConfig(); 74 void updateConfig();
74 void changeEventDisplay(Event *, int); 75 void changeEventDisplay(Event *, int);
75 76
76 protected: 77 protected:
77 bool appendEvent(Incidence *, bool reply=false, bool notRed = true, bool appendTable = false); 78 bool appendEvent(Incidence *, bool reply=false, bool notRed = true, bool appendTable = false);
78 bool appendTodo(Incidence *, QString ind = "", bool isSub = false ); 79 bool appendTodo(Incidence *, QString ind = "", bool isSub = false );
79 void appendDay( int i, QDate date ); 80 void appendDay( int i, QDate date );
80 QDate mEventDate; 81 QDate mEventDate;
81 virtual void showEvent ( QShowEvent * ); 82 virtual void showEvent ( QShowEvent * );
82 virtual void hideEvent ( QHideEvent * ); 83 virtual void hideEvent ( QHideEvent * );
83 84
84 private slots: 85 private slots:
85 void showIncidence(const QString &); 86 void showIncidence(const QString &);
86 void restartTimer(); 87 void restartTimer();
87 88
88 89
89 private: 90 private:
90 int mCurrentMaxPrio; 91 int mCurrentMaxPrio;
91 //void createEventViewer(); 92 //void createEventViewer();
92 QTimer* mTimer; 93 QTimer* mTimer;
93 WhatsNextTextBrowser *mView; 94 WhatsNextTextBrowser *mView;
94 QString mText; 95 QString mText;
95 // QLabel *mDateLabel; 96 // QLabel *mDateLabel;
96 KOEventViewerDialog *mEventViewer; 97 KOEventViewerDialog *mEventViewer;
97 98
98 QValueList<Incidence *> mTodos; 99 QValueList<Incidence *> mTodos;
99}; 100};
100 101
101#endif 102#endif
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 63053a5..d959a7a 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1545,256 +1545,257 @@ void MainWindow::aboutKnownBugs()
1545 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1545 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1546 QMessageBox::NoIcon, 1546 QMessageBox::NoIcon,
1547 QMessageBox::Ok, 1547 QMessageBox::Ok,
1548 QMessageBox::NoButton, 1548 QMessageBox::NoButton,
1549 QMessageBox::NoButton); 1549 QMessageBox::NoButton);
1550 msg->exec(); 1550 msg->exec();
1551 delete msg; 1551 delete msg;
1552 1552
1553} 1553}
1554 1554
1555QString MainWindow::defaultFileName() 1555QString MainWindow::defaultFileName()
1556{ 1556{
1557 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1557 return locateLocal( "data", "korganizer/mycalendar.ics" );
1558} 1558}
1559QString MainWindow::syncFileName() 1559QString MainWindow::syncFileName()
1560{ 1560{
1561#ifdef DESKTOP_VERSION 1561#ifdef DESKTOP_VERSION
1562 return locateLocal( "tmp", "synccalendar.ics" ); 1562 return locateLocal( "tmp", "synccalendar.ics" );
1563#else 1563#else
1564 return QString( "/tmp/synccalendar.ics" ); 1564 return QString( "/tmp/synccalendar.ics" );
1565#endif 1565#endif
1566} 1566}
1567#include "koglobals.h" 1567#include "koglobals.h"
1568#include <kcalendarsystem.h> 1568#include <kcalendarsystem.h>
1569void MainWindow::updateWeek(QDate seda) 1569void MainWindow::updateWeek(QDate seda)
1570{ 1570{
1571 int weekNum = KGlobal::locale()->weekNum ( seda ); 1571 int weekNum = KGlobal::locale()->weekNum ( seda );
1572 mWeekPixmap.fill( mWeekBgColor ); 1572 mWeekPixmap.fill( mWeekBgColor );
1573 QPainter p ( &mWeekPixmap ); 1573 QPainter p ( &mWeekPixmap );
1574 p.setFont( mWeekFont ); 1574 p.setFont( mWeekFont );
1575 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); 1575 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) );
1576 p.end(); 1576 p.end();
1577 QIconSet icon3 ( mWeekPixmap ); 1577 QIconSet icon3 ( mWeekPixmap );
1578 mWeekAction->setIconSet ( icon3 ); 1578 mWeekAction->setIconSet ( icon3 );
1579 1579
1580} 1580}
1581void MainWindow::updateWeekNum(const DateList &selectedDates) 1581void MainWindow::updateWeekNum(const DateList &selectedDates)
1582{ 1582{
1583 updateWeek( selectedDates.first() ); 1583 updateWeek( selectedDates.first() );
1584} 1584}
1585void MainWindow::processIncidenceSelection( Incidence *incidence ) 1585void MainWindow::processIncidenceSelection( Incidence *incidence )
1586{ 1586{
1587 1587
1588 if ( !incidence ) { 1588 if ( !incidence ) {
1589 enableIncidenceActions( false ); 1589 enableIncidenceActions( false );
1590 1590
1591 mNewSubTodoAction->setEnabled( false ); 1591 mNewSubTodoAction->setEnabled( false );
1592 setCaptionToDates(); 1592 setCaptionToDates();
1593 return; 1593 return;
1594 1594
1595 } 1595 }
1596 1596
1597 //KGlobal::locale()->formatDateTime(nextA, true); 1597 //KGlobal::locale()->formatDateTime(nextA, true);
1598 QString startString = ""; 1598 QString startString = "";
1599 if ( incidence->type() != "Todo" ) { 1599 if ( incidence->type() != "Todo" ) {
1600 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1600 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1601 if ( incidence->doesFloat() ) { 1601 if ( incidence->doesFloat() ) {
1602 startString += ": "+incidence->dtStartDateStr( true ); 1602 startString += ": "+incidence->dtStartDateStr( true );
1603 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1603 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1604 1604
1605 } else { 1605 } else {
1606 startString = ": "+incidence->dtStartStr(true); 1606 startString = ": "+incidence->dtStartStr(true);
1607 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1607 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1608 1608
1609 } 1609 }
1610 1610
1611 } else { 1611 } else {
1612 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1612 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1613 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1613 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1614 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1614 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1615 1615
1616 if ( incidence->isBirthday() || incidence->isAnniversary() ) { 1616 if ( incidence->isBirthday() || incidence->isAnniversary() ) {
1617 bool ok; 1617 bool ok;
1618 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); 1618 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok );
1619 if ( ok ) { 1619 if ( ok ) {
1620 int years = noc.date().year() - incidence->dtStart().date().year(); 1620 int years = noc.date().year() - incidence->dtStart().date().year();
1621 startString += i18n(" (%1 y.)"). arg( years ); 1621 startString += i18n(" (%1 y.)"). arg( years );
1622 } 1622 }
1623 } 1623 }
1624 else 1624 else
1625 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1625 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1626 } 1626 }
1627 1627
1628 } 1628 }
1629 else 1629 else
1630 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1630 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1631 if ( !incidence->location().isEmpty() ) 1631 if ( !incidence->location().isEmpty() )
1632 startString += " (" +incidence->location()+")"; 1632 startString += " (" +incidence->location()+")";
1633 setCaption( incidence->summary()+startString); 1633 setCaption( incidence->summary()+startString);
1634 1634
1635 enableIncidenceActions( true ); 1635 enableIncidenceActions( true );
1636 1636
1637 if ( incidence->type() == "Event" ) { 1637 if ( incidence->type() == "Event" ) {
1638 mShowAction->setText( i18n("Show Event...") ); 1638 mShowAction->setText( i18n("Show Event...") );
1639 mEditAction->setText( i18n("Edit Event...") ); 1639 mEditAction->setText( i18n("Edit Event...") );
1640 mDeleteAction->setText( i18n("Delete Event...") ); 1640 mDeleteAction->setText( i18n("Delete Event...") );
1641 1641
1642 mNewSubTodoAction->setEnabled( false ); 1642 mNewSubTodoAction->setEnabled( false );
1643 } else if ( incidence->type() == "Todo" ) { 1643 } else if ( incidence->type() == "Todo" ) {
1644 mShowAction->setText( i18n("Show Todo...") ); 1644 mShowAction->setText( i18n("Show Todo...") );
1645 mEditAction->setText( i18n("Edit Todo...") ); 1645 mEditAction->setText( i18n("Edit Todo...") );
1646 mDeleteAction->setText( i18n("Delete Todo...") ); 1646 mDeleteAction->setText( i18n("Delete Todo...") );
1647 1647
1648 mNewSubTodoAction->setEnabled( true ); 1648 mNewSubTodoAction->setEnabled( true );
1649 } else { 1649 } else {
1650 mShowAction->setText( i18n("Show...") ); 1650 mShowAction->setText( i18n("Show...") );
1651 mShowAction->setText( i18n("Edit...") ); 1651 mShowAction->setText( i18n("Edit...") );
1652 mShowAction->setText( i18n("Delete...") ); 1652 mShowAction->setText( i18n("Delete...") );
1653 1653
1654 mNewSubTodoAction->setEnabled( false ); 1654 mNewSubTodoAction->setEnabled( false );
1655 } 1655 }
1656} 1656}
1657 1657
1658void MainWindow::enableIncidenceActions( bool enabled ) 1658void MainWindow::enableIncidenceActions( bool enabled )
1659{ 1659{
1660 mShowAction->setEnabled( enabled ); 1660 mShowAction->setEnabled( enabled );
1661 mEditAction->setEnabled( enabled ); 1661 mEditAction->setEnabled( enabled );
1662 mDeleteAction->setEnabled( enabled ); 1662 mDeleteAction->setEnabled( enabled );
1663 1663
1664 mCloneAction->setEnabled( enabled ); 1664 mCloneAction->setEnabled( enabled );
1665 mMoveAction->setEnabled( enabled ); 1665 mMoveAction->setEnabled( enabled );
1666 mBeamAction->setEnabled( enabled ); 1666 mBeamAction->setEnabled( enabled );
1667 mCancelAction->setEnabled( enabled ); 1667 mCancelAction->setEnabled( enabled );
1668} 1668}
1669 1669
1670void MainWindow::importOL() 1670void MainWindow::importOL()
1671{ 1671{
1672#ifdef _OL_IMPORT_ 1672#ifdef _OL_IMPORT_
1673 mView->clearAllViews();
1673 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1674 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1674 id->exec(); 1675 id->exec();
1675 delete id; 1676 delete id;
1676 mView->updateView(); 1677 mView->updateView();
1677#endif 1678#endif
1678} 1679}
1679void MainWindow::importBday() 1680void MainWindow::importBday()
1680{ 1681{
1681 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1682 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1682 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1683 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1683 i18n("Import!"), i18n("Cancel"), 0, 1684 i18n("Import!"), i18n("Cancel"), 0,
1684 0, 1 ); 1685 0, 1 );
1685 if ( result == 0 ) { 1686 if ( result == 0 ) {
1686 mView->importBday(); 1687 mView->importBday();
1687 1688
1688 } 1689 }
1689 1690
1690 1691
1691} 1692}
1692void MainWindow::importQtopia() 1693void MainWindow::importQtopia()
1693{ 1694{
1694 //#ifndef DESKTOP_VERSION 1695 //#ifndef DESKTOP_VERSION
1695 QString mess = i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"); 1696 QString mess = i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing");
1696#ifdef DESKTOP_VERSION 1697#ifdef DESKTOP_VERSION
1697 mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml"); 1698 mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml");
1698#endif 1699#endif
1699 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, 1700 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess,
1700 i18n("Import!"), i18n("Cancel"), 0, 1701 i18n("Import!"), i18n("Cancel"), 0,
1701 0, 1 ); 1702 0, 1 );
1702 if ( result == 0 ) { 1703 if ( result == 0 ) {
1703#ifndef DESKTOP_VERSION 1704#ifndef DESKTOP_VERSION
1704 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1705 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1705 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1706 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1706 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1707 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1707#else 1708#else
1708 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; 1709 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml";
1709 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; 1710 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml";
1710 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; 1711 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml";
1711#endif 1712#endif
1712 mView->importQtopia( categories, datebook, todolist ); 1713 mView->importQtopia( categories, datebook, todolist );
1713 } 1714 }
1714#if 0 1715#if 0
1715 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1716 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1716 i18n("Not supported \non desktop!\n"), 1717 i18n("Not supported \non desktop!\n"),
1717 i18n("Ok"), i18n("Cancel"), 0, 1718 i18n("Ok"), i18n("Cancel"), 0,
1718 0, 1 ); 1719 0, 1 );
1719 1720
1720#endif 1721#endif
1721} 1722}
1722 1723
1723void MainWindow::saveOnClose() 1724void MainWindow::saveOnClose()
1724{ 1725{
1725 KOPrefs *p = KOPrefs::instance(); 1726 KOPrefs *p = KOPrefs::instance();
1726 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1727 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1727 p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal ); 1728 p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal );
1728 p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal ); 1729 p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal );
1729 if ( filterToolBar ) { 1730 if ( filterToolBar ) {
1730 p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal ); 1731 p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal );
1731 } 1732 }
1732#ifdef DESKTOP_VERSION 1733#ifdef DESKTOP_VERSION
1733 1734
1734 QPoint myP; 1735 QPoint myP;
1735 myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) ); 1736 myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) );
1736 if ( p->mToolBarHor ) 1737 if ( p->mToolBarHor )
1737 p->mToolBarUp = myP.y() > height()/2; 1738 p->mToolBarUp = myP.y() > height()/2;
1738 else 1739 else
1739 p->mToolBarUp = myP.x() > width()/2; 1740 p->mToolBarUp = myP.x() > width()/2;
1740 myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) ); 1741 myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) );
1741 if ( p->mToolBarHorV ) 1742 if ( p->mToolBarHorV )
1742 p->mToolBarUpV = myP.y() > height()/2; 1743 p->mToolBarUpV = myP.y() > height()/2;
1743 else 1744 else
1744 p->mToolBarUpV = myP.x() > width()/2 ; 1745 p->mToolBarUpV = myP.x() > width()/2 ;
1745 myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) ); 1746 myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) );
1746 if ( p->mToolBarHorN ) 1747 if ( p->mToolBarHorN )
1747 p->mToolBarUpN = myP.y() > height()/2; 1748 p->mToolBarUpN = myP.y() > height()/2;
1748 else 1749 else
1749 p->mToolBarUpN = myP.x() > width()/2 ; 1750 p->mToolBarUpN = myP.x() > width()/2 ;
1750 if ( filterToolBar ) { 1751 if ( filterToolBar ) {
1751 myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) ); 1752 myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) );
1752 if ( p->mToolBarHorF ) 1753 if ( p->mToolBarHorF )
1753 p->mToolBarUpF = myP.y() > height()/2; 1754 p->mToolBarUpF = myP.y() > height()/2;
1754 else 1755 else
1755 p->mToolBarUpF = myP.x() > width()/2 ; 1756 p->mToolBarUpF = myP.x() > width()/2 ;
1756 } 1757 }
1757#else 1758#else
1758 if ( p->mToolBarHor ) 1759 if ( p->mToolBarHor )
1759 p->mToolBarUp = iconToolBar->y() > height()/2; 1760 p->mToolBarUp = iconToolBar->y() > height()/2;
1760 else 1761 else
1761 p->mToolBarUp = iconToolBar->x() > width()/2; 1762 p->mToolBarUp = iconToolBar->x() > width()/2;
1762 if ( p->mToolBarHorV ) 1763 if ( p->mToolBarHorV )
1763 p->mToolBarUpV = viewToolBar->y() > height()/2; 1764 p->mToolBarUpV = viewToolBar->y() > height()/2;
1764 else 1765 else
1765 p->mToolBarUpV = viewToolBar->x() > width()/2 ; 1766 p->mToolBarUpV = viewToolBar->x() > width()/2 ;
1766 1767
1767 if ( p->mToolBarHorN ) 1768 if ( p->mToolBarHorN )
1768 p->mToolBarUpN = navigatorToolBar->y() > height()/2; 1769 p->mToolBarUpN = navigatorToolBar->y() > height()/2;
1769 else 1770 else
1770 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; 1771 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ;
1771 if ( filterToolBar ) { 1772 if ( filterToolBar ) {
1772 if ( p->mToolBarHorF ) 1773 if ( p->mToolBarHorF )
1773 p->mToolBarUpF = filterToolBar->y() > height()/2; 1774 p->mToolBarUpF = filterToolBar->y() > height()/2;
1774 else 1775 else
1775 p->mToolBarUpF = filterToolBar->x() > width()/2 ; 1776 p->mToolBarUpF = filterToolBar->x() > width()/2 ;
1776 } 1777 }
1777#endif 1778#endif
1778 1779
1779 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1780 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1780 save(); 1781 save();
1781 mView->writeSettings(); 1782 mView->writeSettings();
1782} 1783}
1783void MainWindow::slotModifiedChanged( bool changed ) 1784void MainWindow::slotModifiedChanged( bool changed )
1784{ 1785{
1785 if ( mBlockAtStartup ) 1786 if ( mBlockAtStartup )
1786 return; 1787 return;
1787 1788
1788 int msec; 1789 int msec;
1789 // we store the changes after 1 minute, 1790 // we store the changes after 1 minute,
1790 // and for safety reasons after 10 minutes again 1791 // and for safety reasons after 10 minutes again
1791 if ( !mSyncManager->blockSave() ) 1792 if ( !mSyncManager->blockSave() )
1792 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1793 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1793 else 1794 else
1794 msec = 1000 * 600; 1795 msec = 1000 * 600;
1795 mSaveTimer.start( msec, true ); // 1 minute 1796 mSaveTimer.start( msec, true ); // 1 minute
1796 qDebug("KO: Saving File in %d secs!", msec/1000); 1797 qDebug("KO: Saving File in %d secs!", msec/1000);
1797 mCalendarModifiedFlag = true; 1798 mCalendarModifiedFlag = true;
1798} 1799}
1799void MainWindow::saveStopTimer() 1800void MainWindow::saveStopTimer()
1800{ 1801{