summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp4
-rw-r--r--korganizer/mainwindow.cpp22
-rw-r--r--korganizer/mainwindow.h2
3 files changed, 23 insertions, 5 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 14094bb..79fb727 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -2119,770 +2119,770 @@ bool CalendarView::importBday()
2119#endif //DESKTOP_VERSION 2119#endif //DESKTOP_VERSION
2120 2120
2121#endif //KORG_NOKABC 2121#endif //KORG_NOKABC
2122 2122
2123 2123
2124 return true; 2124 return true;
2125} 2125}
2126 2126
2127// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 2127// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
2128void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 2128void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
2129 const QStringList& anniversaryList, const QStringList& realNameList, 2129 const QStringList& anniversaryList, const QStringList& realNameList,
2130 const QStringList& emailList, const QStringList& assembledNameList, 2130 const QStringList& emailList, const QStringList& assembledNameList,
2131 const QStringList& uidList) 2131 const QStringList& uidList)
2132{ 2132{
2133 2133
2134 //qDebug("KO::CalendarView::insertBirthdays"); 2134 //qDebug("KO::CalendarView::insertBirthdays");
2135 if (uid == this->name()) 2135 if (uid == this->name())
2136 { 2136 {
2137 int curCal = mCalendar->defaultCalendar(); 2137 int curCal = mCalendar->defaultCalendar();
2138 int bd = mCalEditView->getBirtdayID(); 2138 int bd = mCalEditView->getBirtdayID();
2139 if ( bd == 0 ) 2139 if ( bd == 0 )
2140 return; 2140 return;
2141 mCalendar->setDefaultCalendar( bd ); 2141 mCalendar->setDefaultCalendar( bd );
2142 2142
2143 2143
2144 int count = birthdayList.count(); 2144 int count = birthdayList.count();
2145 int addCount = 0; 2145 int addCount = 0;
2146 KCal::Attendee* a = 0; 2146 KCal::Attendee* a = 0;
2147 2147
2148 //qDebug("CalView 1 %i", count); 2148 //qDebug("CalView 1 %i", count);
2149 2149
2150 QProgressBar bar(count,0 ); 2150 QProgressBar bar(count,0 );
2151 int w = 300; 2151 int w = 300;
2152 if ( QApplication::desktop()->width() < 320 ) 2152 if ( QApplication::desktop()->width() < 320 )
2153 w = 220; 2153 w = 220;
2154 int h = bar.sizeHint().height() ; 2154 int h = bar.sizeHint().height() ;
2155 int dw = QApplication::desktop()->width(); 2155 int dw = QApplication::desktop()->width();
2156 int dh = QApplication::desktop()->height(); 2156 int dh = QApplication::desktop()->height();
2157 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2157 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2158 bar.show(); 2158 bar.show();
2159 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 2159 bar.setCaption (i18n("inserting birthdays - close to abort!") );
2160 qApp->processEvents(); 2160 qApp->processEvents();
2161 2161
2162 QDate birthday; 2162 QDate birthday;
2163 QDate anniversary; 2163 QDate anniversary;
2164 QString realName; 2164 QString realName;
2165 QString email; 2165 QString email;
2166 QString assembledName; 2166 QString assembledName;
2167 QString uid; 2167 QString uid;
2168 bool ok = true; 2168 bool ok = true;
2169 for ( int i = 0; i < count; i++) 2169 for ( int i = 0; i < count; i++)
2170 { 2170 {
2171 if ( ! bar.isVisible() ) 2171 if ( ! bar.isVisible() )
2172 return; 2172 return;
2173 bar.setProgress( i ); 2173 bar.setProgress( i );
2174 qApp->processEvents(); 2174 qApp->processEvents();
2175 2175
2176 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 2176 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
2177 if (!ok) { 2177 if (!ok) {
2178 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 2178 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
2179 } 2179 }
2180 2180
2181 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 2181 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
2182 if (!ok) { 2182 if (!ok) {
2183 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 2183 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
2184 } 2184 }
2185 realName = realNameList[i]; 2185 realName = realNameList[i];
2186 email = emailList[i]; 2186 email = emailList[i];
2187 assembledName = assembledNameList[i]; 2187 assembledName = assembledNameList[i];
2188 uid = uidList[i]; 2188 uid = uidList[i];
2189 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); 2189 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() );
2190 2190
2191 if ( birthday.isValid() ){ 2191 if ( birthday.isValid() ){
2192 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 2192 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
2193 KCal::Attendee::ReqParticipant,uid) ; 2193 KCal::Attendee::ReqParticipant,uid) ;
2194 if ( addAnniversary( birthday, assembledName, a, true ) ) 2194 if ( addAnniversary( birthday, assembledName, a, true ) )
2195 ++addCount; 2195 ++addCount;
2196 } 2196 }
2197 2197
2198 if ( anniversary.isValid() ){ 2198 if ( anniversary.isValid() ){
2199 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 2199 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
2200 KCal::Attendee::ReqParticipant,uid) ; 2200 KCal::Attendee::ReqParticipant,uid) ;
2201 if ( addAnniversary( anniversary, assembledName, a, false ) ) 2201 if ( addAnniversary( anniversary, assembledName, a, false ) )
2202 ++addCount; 2202 ++addCount;
2203 } 2203 }
2204 } 2204 }
2205 2205
2206 mCalendar->setDefaultCalendar( curCal ); 2206 mCalendar->setDefaultCalendar( curCal );
2207 updateView(); 2207 updateView();
2208 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 2208 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
2209 2209
2210 } 2210 }
2211 2211
2212} 2212}
2213 2213
2214 2214
2215 2215
2216bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 2216bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
2217{ 2217{
2218 //qDebug("addAnni "); 2218 //qDebug("addAnni ");
2219 Event * ev = new Event(); 2219 Event * ev = new Event();
2220 ev->setOrganizer(KOPrefs::instance()->email()); 2220 ev->setOrganizer(KOPrefs::instance()->email());
2221 if ( a ) { 2221 if ( a ) {
2222 ev->addAttendee( a ); 2222 ev->addAttendee( a );
2223 } 2223 }
2224 QString kind; 2224 QString kind;
2225 if ( birthday ) { 2225 if ( birthday ) {
2226 kind = i18n( "Birthday" ); 2226 kind = i18n( "Birthday" );
2227 ev->setSummary( name + " (" + QString::number(date.year()) +")"); 2227 ev->setSummary( name + " (" + QString::number(date.year()) +")");
2228 } 2228 }
2229 else { 2229 else {
2230 kind = i18n( "Anniversary" ); 2230 kind = i18n( "Anniversary" );
2231 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); 2231 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
2232 } 2232 }
2233 ev->setCategories( kind ); 2233 ev->setCategories( kind );
2234 ev->setDtStart( QDateTime(date) ); 2234 ev->setDtStart( QDateTime(date) );
2235 ev->setDtEnd( QDateTime(date) ); 2235 ev->setDtEnd( QDateTime(date) );
2236 ev->setFloats( true ); 2236 ev->setFloats( true );
2237 Recurrence * rec = ev->recurrence(); 2237 Recurrence * rec = ev->recurrence();
2238 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 2238 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
2239 rec->addYearlyNum( date.month() ); 2239 rec->addYearlyNum( date.month() );
2240 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 2240 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
2241 delete ev; 2241 delete ev;
2242 return false; 2242 return false;
2243 } 2243 }
2244 return true; 2244 return true;
2245 2245
2246} 2246}
2247bool CalendarView::importQtopia( const QString &categories, 2247bool CalendarView::importQtopia( const QString &categories,
2248 const QString &datebook, 2248 const QString &datebook,
2249 const QString &todolist ) 2249 const QString &todolist )
2250{ 2250{
2251 2251
2252 QtopiaFormat qtopiaFormat; 2252 QtopiaFormat qtopiaFormat;
2253 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 2253 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
2254 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 2254 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
2255 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 2255 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
2256 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 2256 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
2257 2257
2258 updateView(); 2258 updateView();
2259 return true; 2259 return true;
2260 2260
2261#if 0 2261#if 0
2262 mGlobalSyncMode = SYNC_MODE_QTOPIA; 2262 mGlobalSyncMode = SYNC_MODE_QTOPIA;
2263 mCurrentSyncDevice = "qtopia-XML"; 2263 mCurrentSyncDevice = "qtopia-XML";
2264 if ( mSyncManager->mAskForPreferences ) 2264 if ( mSyncManager->mAskForPreferences )
2265 edit_sync_options(); 2265 edit_sync_options();
2266 qApp->processEvents(); 2266 qApp->processEvents();
2267 CalendarLocal* calendar = new CalendarLocal(); 2267 CalendarLocal* calendar = new CalendarLocal();
2268 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2268 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2269 bool syncOK = false; 2269 bool syncOK = false;
2270 QtopiaFormat qtopiaFormat; 2270 QtopiaFormat qtopiaFormat;
2271 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 2271 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
2272 bool loadOk = true; 2272 bool loadOk = true;
2273 if ( !categories.isEmpty() ) 2273 if ( !categories.isEmpty() )
2274 loadOk = qtopiaFormat.load( calendar, categories ); 2274 loadOk = qtopiaFormat.load( calendar, categories );
2275 if ( loadOk && !datebook.isEmpty() ) 2275 if ( loadOk && !datebook.isEmpty() )
2276 loadOk = qtopiaFormat.load( calendar, datebook ); 2276 loadOk = qtopiaFormat.load( calendar, datebook );
2277 if ( loadOk && !todolist.isEmpty() ) 2277 if ( loadOk && !todolist.isEmpty() )
2278 loadOk = qtopiaFormat.load( calendar, todolist ); 2278 loadOk = qtopiaFormat.load( calendar, todolist );
2279 2279
2280 if ( loadOk ) { 2280 if ( loadOk ) {
2281 getEventViewerDialog()->setSyncMode( true ); 2281 getEventViewerDialog()->setSyncMode( true );
2282 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 2282 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
2283 getEventViewerDialog()->setSyncMode( false ); 2283 getEventViewerDialog()->setSyncMode( false );
2284 qApp->processEvents(); 2284 qApp->processEvents();
2285 if ( syncOK ) { 2285 if ( syncOK ) {
2286 if ( mSyncManager->mWriteBackFile ) 2286 if ( mSyncManager->mWriteBackFile )
2287 { 2287 {
2288 // write back XML file 2288 // write back XML file
2289 2289
2290 } 2290 }
2291 setModified( true ); 2291 setModified( true );
2292 } 2292 }
2293 } else { 2293 } else {
2294 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 2294 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
2295 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 2295 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
2296 question, i18n("Ok")) ; 2296 question, i18n("Ok")) ;
2297 } 2297 }
2298 delete calendar; 2298 delete calendar;
2299 updateView(); 2299 updateView();
2300 return syncOK; 2300 return syncOK;
2301 2301
2302 2302
2303#endif 2303#endif
2304 2304
2305} 2305}
2306 2306
2307void CalendarView::setSyncEventsReadOnly() 2307void CalendarView::setSyncEventsReadOnly()
2308{ 2308{
2309 mCalendar->setSyncEventsReadOnly(); 2309 mCalendar->setSyncEventsReadOnly();
2310} 2310}
2311 2311
2312bool CalendarView::loadCalendars() 2312bool CalendarView::loadCalendars()
2313{ 2313{
2314 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2314 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2315 KopiCalendarFile * cal = calendars.first(); 2315 KopiCalendarFile * cal = calendars.first();
2316 mCalendar->setDefaultCalendar( 1 ); 2316 mCalendar->setDefaultCalendar( 1 );
2317 openCalendar( MainWindow::defaultFileName(), false ); 2317 openCalendar( MainWindow::defaultFileName(), false );
2318 cal = calendars.next(); 2318 cal = calendars.next();
2319 while ( cal ) { 2319 while ( cal ) {
2320 addCalendar( cal ); 2320 addCalendar( cal );
2321 cal = calendars.next(); 2321 cal = calendars.next();
2322 } 2322 }
2323 restoreCalendarSettings(); 2323 restoreCalendarSettings();
2324 return true; 2324 return true;
2325} 2325}
2326bool CalendarView::restoreCalendarSettings() 2326bool CalendarView::restoreCalendarSettings()
2327{ 2327{
2328 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2328 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2329 KopiCalendarFile * cal = calendars.first(); 2329 KopiCalendarFile * cal = calendars.first();
2330 while ( cal ) { 2330 while ( cal ) {
2331 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); 2331 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled );
2332 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); 2332 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled );
2333 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); 2333 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly );
2334 if ( cal->isStandard ) 2334 if ( cal->isStandard )
2335 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2335 mCalendar->setDefaultCalendar( cal->mCalNumber );
2336 cal = calendars.next(); 2336 cal = calendars.next();
2337 } 2337 }
2338 setSyncEventsReadOnly(); 2338 setSyncEventsReadOnly();
2339 mCalendar->reInitAlarmSettings(); 2339 mCalendar->reInitAlarmSettings();
2340 updateUnmanagedViews(); 2340 updateUnmanagedViews();
2341 updateView(); 2341 updateView();
2342 return true; 2342 return true;
2343} 2343}
2344void CalendarView::addCalendarId( int id ) 2344void CalendarView::addCalendarId( int id )
2345{ 2345{
2346 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); 2346 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id );
2347 if ( cal ) 2347 if ( cal )
2348 addCalendar( cal ); 2348 addCalendar( cal );
2349} 2349}
2350bool CalendarView::addCalendar( KopiCalendarFile * cal ) 2350bool CalendarView::addCalendar( KopiCalendarFile * cal )
2351{ 2351{
2352 cal->mErrorOnLoad = false; 2352 cal->mErrorOnLoad = false;
2353 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { 2353 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) {
2354 cal->mLoadDt = QDateTime::currentDateTime(); 2354 cal->mLoadDt = QDateTime::currentDateTime();
2355 return true; 2355 return true;
2356 } 2356 }
2357 qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); 2357 qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() );
2358 cal->mErrorOnLoad = true; 2358 cal->mErrorOnLoad = true;
2359 return false; 2359 return false;
2360} 2360}
2361bool CalendarView::openCalendar(QString filename, bool merge) 2361bool CalendarView::openCalendar(QString filename, bool merge)
2362{ 2362{
2363 2363
2364 if (filename.isEmpty()) { 2364 if (filename.isEmpty()) {
2365 return false; 2365 return false;
2366 } 2366 }
2367 2367
2368 if (!QFile::exists(filename)) { 2368 if (!QFile::exists(filename)) {
2369 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 2369 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
2370 return false; 2370 return false;
2371 } 2371 }
2372 2372
2373 globalFlagBlockAgenda = 1; 2373 globalFlagBlockAgenda = 1;
2374 clearAllViews(); 2374 clearAllViews();
2375 if (!merge) { 2375 if (!merge) {
2376 mViewManager->setDocumentId( filename ); 2376 mViewManager->setDocumentId( filename );
2377 mCalendar->close(); 2377 mCalendar->close();
2378 } 2378 }
2379 mStorage->setFileName( filename ); 2379 mStorage->setFileName( filename );
2380 2380
2381 if ( mStorage->load() ) { 2381 if ( mStorage->load() ) {
2382 if ( merge ) ;//setModified( true ); 2382 if ( merge ) ;//setModified( true );
2383 else { 2383 else {
2384 //setModified( true ); 2384 //setModified( true );
2385 mViewManager->setDocumentId( filename ); 2385 mViewManager->setDocumentId( filename );
2386 mDialogManager->setDocumentId( filename ); 2386 mDialogManager->setDocumentId( filename );
2387 mTodoList->setDocumentId( filename ); 2387 mTodoList->setDocumentId( filename );
2388 } 2388 }
2389 globalFlagBlockAgenda = 2; 2389 globalFlagBlockAgenda = 2;
2390 // if ( getLastSyncEvent() ) 2390 // if ( getLastSyncEvent() )
2391 // getLastSyncEvent()->setReadOnly( true ); 2391 // getLastSyncEvent()->setReadOnly( true );
2392 mCalendar->reInitAlarmSettings(); 2392 mCalendar->reInitAlarmSettings();
2393 setSyncEventsReadOnly(); 2393 setSyncEventsReadOnly();
2394 //updateUnmanagedViews(); 2394 //updateUnmanagedViews();
2395 //updateView(); 2395 //updateView();
2396 if ( filename != MainWindow::defaultFileName() ) { 2396 if ( filename != MainWindow::defaultFileName() ) {
2397 saveCalendar( MainWindow::defaultFileName() ); 2397 saveCalendar( MainWindow::defaultFileName() );
2398 } else { 2398 } else {
2399 QFileInfo finf ( MainWindow::defaultFileName()); 2399 QFileInfo finf ( MainWindow::defaultFileName());
2400 if ( finf.exists() ) { 2400 if ( finf.exists() ) {
2401 setLoadedFileVersion( finf.lastModified () ); 2401 setLoadedFileVersion( finf.lastModified () );
2402 } 2402 }
2403 } 2403 }
2404 return true; 2404 return true;
2405 } else { 2405 } else {
2406 // while failing to load, the calendar object could 2406 // while failing to load, the calendar object could
2407 // have become partially populated. Clear it out. 2407 // have become partially populated. Clear it out.
2408 if ( !merge ) { 2408 if ( !merge ) {
2409 mCalendar->close(); 2409 mCalendar->close();
2410 mViewManager->setDocumentId( filename ); 2410 mViewManager->setDocumentId( filename );
2411 mDialogManager->setDocumentId( filename ); 2411 mDialogManager->setDocumentId( filename );
2412 mTodoList->setDocumentId( filename ); 2412 mTodoList->setDocumentId( filename );
2413 } 2413 }
2414 2414
2415 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 2415 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
2416 2416
2417 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 2417 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
2418 globalFlagBlockAgenda = 2; 2418 globalFlagBlockAgenda = 2;
2419 mCalendar->reInitAlarmSettings(); 2419 mCalendar->reInitAlarmSettings();
2420 setSyncEventsReadOnly(); 2420 setSyncEventsReadOnly();
2421 updateUnmanagedViews(); 2421 updateUnmanagedViews();
2422 updateView(); 2422 updateView();
2423 } 2423 }
2424 return false; 2424 return false;
2425} 2425}
2426void CalendarView::mergeFile( QString fn ) 2426void CalendarView::mergeFile( QString fn )
2427{ 2427{
2428 clearAllViews(); 2428 clearAllViews();
2429 mCalendar->mergeCalendarFile( fn ); 2429 mCalendar->mergeCalendarFile( fn );
2430 mCalendar->reInitAlarmSettings(); 2430 mCalendar->reInitAlarmSettings();
2431 setSyncEventsReadOnly(); 2431 setSyncEventsReadOnly();
2432 updateUnmanagedViews(); 2432 updateUnmanagedViews();
2433 updateView(); 2433 updateView();
2434} 2434}
2435void CalendarView::showOpenError() 2435void CalendarView::showOpenError()
2436{ 2436{
2437 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 2437 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
2438} 2438}
2439void CalendarView::setLoadedFileVersion(QDateTime dt) 2439void CalendarView::setLoadedFileVersion(QDateTime dt)
2440{ 2440{
2441 loadedFileVersion = dt; 2441 loadedFileVersion = dt;
2442} 2442}
2443bool CalendarView::checkFileChanged(QString fn) 2443bool CalendarView::checkFileChanged(QString fn)
2444{ 2444{
2445 QFileInfo finf ( fn ); 2445 QFileInfo finf ( fn );
2446 if ( !finf.exists() ) 2446 if ( !finf.exists() )
2447 return true; 2447 return true;
2448 QDateTime dt = finf.lastModified (); 2448 QDateTime dt = finf.lastModified ();
2449 if ( dt <= loadedFileVersion ) 2449 if ( dt <= loadedFileVersion )
2450 return false; 2450 return false;
2451 return true; 2451 return true;
2452 2452
2453} 2453}
2454void CalendarView::watchSavedFile() 2454void CalendarView::watchSavedFile()
2455{ 2455{
2456 QFileInfo finf ( MainWindow::defaultFileName()); 2456 QFileInfo finf ( MainWindow::defaultFileName());
2457 if ( !finf.exists() ) 2457 if ( !finf.exists() )
2458 return; 2458 return;
2459 QDateTime dt = finf.lastModified (); 2459 QDateTime dt = finf.lastModified ();
2460 if ( dt < loadedFileVersion ) { 2460 if ( dt < loadedFileVersion ) {
2461 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 2461 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
2462 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 2462 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
2463 return; 2463 return;
2464 } 2464 }
2465 loadedFileVersion = dt; 2465 loadedFileVersion = dt;
2466} 2466}
2467bool CalendarView::checkAllFileVersions() 2467bool CalendarView::checkAllFileVersions()
2468{ 2468{
2469 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2469 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2470 KopiCalendarFile * cal = calendars.first(); 2470 KopiCalendarFile * cal = calendars.first();
2471 mCalendar->setDefaultCalendar( 1 ); 2471 mCalendar->setDefaultCalendar( 1 );
2472 mCalendar->setDefaultCalendarEnabledOnly(); 2472 mCalendar->setDefaultCalendarEnabledOnly();
2473 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2473 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2474 if ( !checkFileVersion(MainWindow::defaultFileName())) { 2474 if ( !checkFileVersion(MainWindow::defaultFileName())) {
2475 restoreCalendarSettings(); 2475 restoreCalendarSettings();
2476 return false; 2476 return false;
2477 } 2477 }
2478 } 2478 }
2479 cal = calendars.next(); 2479 cal = calendars.next();
2480 QDateTime storeTemp = loadedFileVersion; 2480 QDateTime storeTemp = loadedFileVersion;
2481 while ( cal ) { 2481 while ( cal ) {
2482 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2482 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2483 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2483 mCalendar->setDefaultCalendar( cal->mCalNumber );
2484 mCalendar->setDefaultCalendarEnabledOnly(); 2484 mCalendar->setDefaultCalendarEnabledOnly();
2485 loadedFileVersion = cal->mLoadDt.addSecs( 15 ); 2485 loadedFileVersion = cal->mLoadDt.addSecs( 15 );
2486 if ( !checkFileVersion(cal->mFileName )) { 2486 if ( !checkFileVersion(cal->mFileName )) {
2487 loadedFileVersion = storeTemp; 2487 loadedFileVersion = storeTemp;
2488 restoreCalendarSettings(); 2488 restoreCalendarSettings();
2489 return false; 2489 return false;
2490 } 2490 }
2491 } 2491 }
2492 cal = calendars.next(); 2492 cal = calendars.next();
2493 } 2493 }
2494 loadedFileVersion = storeTemp; 2494 loadedFileVersion = storeTemp;
2495 return true; 2495 return true;
2496} 2496}
2497bool CalendarView::checkFileVersion(QString fn) 2497bool CalendarView::checkFileVersion(QString fn)
2498{ 2498{
2499 QFileInfo finf ( fn ); 2499 QFileInfo finf ( fn );
2500 if ( !finf.exists() ) 2500 if ( !finf.exists() )
2501 return true; 2501 return true;
2502 QDateTime dt = finf.lastModified (); 2502 QDateTime dt = finf.lastModified ();
2503 qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); 2503 //qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1());
2504 qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); 2504 //qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1());
2505 if ( dt <= loadedFileVersion ) 2505 if ( dt <= loadedFileVersion )
2506 return true; 2506 return true;
2507 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 2507 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
2508 i18n("KO/Pi Warning"),i18n("Overwrite"), 2508 i18n("KO/Pi Warning"),i18n("Overwrite"),
2509 i18n("Sync+save")); 2509 i18n("Sync+save"));
2510 2510
2511 if ( km == KMessageBox::Cancel ) 2511 if ( km == KMessageBox::Cancel )
2512 return false; 2512 return false;
2513 if ( km == KMessageBox::Yes ) 2513 if ( km == KMessageBox::Yes )
2514 return true; 2514 return true;
2515 2515
2516 setSyncDevice("deleteaftersync" ); 2516 setSyncDevice("deleteaftersync" );
2517 mSyncManager->mAskForPreferences = true; 2517 mSyncManager->mAskForPreferences = true;
2518 mSyncManager->mSyncAlgoPrefs = 3; 2518 mSyncManager->mSyncAlgoPrefs = 3;
2519 mSyncManager->mWriteBackFile = false; 2519 mSyncManager->mWriteBackFile = false;
2520 mSyncManager->mWriteBackExistingOnly = false; 2520 mSyncManager->mWriteBackExistingOnly = false;
2521 mSyncManager->mShowSyncSummary = false; 2521 mSyncManager->mShowSyncSummary = false;
2522 syncCalendar( fn, 3 ); 2522 syncCalendar( fn, 3 );
2523 Event * e = getLastSyncEvent(); 2523 Event * e = getLastSyncEvent();
2524 if ( e ) 2524 if ( e )
2525 mCalendar->deleteEvent( e ); 2525 mCalendar->deleteEvent( e );
2526 return true; 2526 return true;
2527} 2527}
2528bool CalendarView::saveCalendars() 2528bool CalendarView::saveCalendars()
2529{ 2529{
2530 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2530 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2531 KopiCalendarFile * cal = calendars.first(); 2531 KopiCalendarFile * cal = calendars.first();
2532 mCalendar->setDefaultCalendar( 1 ); 2532 mCalendar->setDefaultCalendar( 1 );
2533 mCalendar->setDefaultCalendarEnabledOnly(); 2533 mCalendar->setDefaultCalendarEnabledOnly();
2534 QString saveError; 2534 QString saveError;
2535 if ( !saveCalendar( MainWindow::defaultFileName() ) ) 2535 if ( !saveCalendar( MainWindow::defaultFileName() ) )
2536 saveError = cal->mName +"\n"; 2536 saveError = cal->mName +"\n";
2537 cal = calendars.next(); 2537 cal = calendars.next();
2538 while ( cal ) { 2538 while ( cal ) {
2539 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2539 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2540 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2540 mCalendar->setDefaultCalendar( cal->mCalNumber );
2541 mCalendar->setDefaultCalendarEnabledOnly(); 2541 mCalendar->setDefaultCalendarEnabledOnly();
2542 if ( saveCalendar( cal->mFileName ) ) 2542 if ( saveCalendar( cal->mFileName ) )
2543 cal->mLoadDt = QDateTime::currentDateTime(); 2543 cal->mLoadDt = QDateTime::currentDateTime();
2544 else 2544 else
2545 saveError += cal->mName + "\n"; 2545 saveError += cal->mName + "\n";
2546 } 2546 }
2547 cal = calendars.next(); 2547 cal = calendars.next();
2548 } 2548 }
2549 restoreCalendarSettings(); 2549 restoreCalendarSettings();
2550 if ( !saveError.isEmpty() ) { 2550 if ( !saveError.isEmpty() ) {
2551 saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError; 2551 saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError;
2552 KMessageBox::error(this, saveError, i18n("Error saving data")); 2552 KMessageBox::error(this, saveError, i18n("Error saving data"));
2553 return false; 2553 return false;
2554 } 2554 }
2555 return true; 2555 return true;
2556} 2556}
2557bool CalendarView::saveCalendar( QString filename ) 2557bool CalendarView::saveCalendar( QString filename )
2558{ 2558{
2559 2559
2560 // Store back all unsaved data into calendar object 2560 // Store back all unsaved data into calendar object
2561 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 2561 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
2562 if ( mViewManager->currentView() ) 2562 if ( mViewManager->currentView() )
2563 mViewManager->currentView()->flushView(); 2563 mViewManager->currentView()->flushView();
2564 2564
2565 2565
2566 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 2566 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
2567 mStorage->setSaveFormat( new ICalFormat() ); 2567 mStorage->setSaveFormat( new ICalFormat() );
2568 mStorage->setFileName( filename ); 2568 mStorage->setFileName( filename );
2569 bool success; 2569 bool success;
2570 success = mStorage->save(); 2570 success = mStorage->save();
2571 if ( !success ) { 2571 if ( !success ) {
2572 return false; 2572 return false;
2573 } 2573 }
2574 if ( filename == MainWindow::defaultFileName() ) { 2574 if ( filename == MainWindow::defaultFileName() ) {
2575 setLoadedFileVersion( lfv ); 2575 setLoadedFileVersion( lfv );
2576 watchSavedFile(); 2576 watchSavedFile();
2577 } 2577 }
2578 return true; 2578 return true;
2579} 2579}
2580 2580
2581void CalendarView::closeCalendar() 2581void CalendarView::closeCalendar()
2582{ 2582{
2583 2583
2584 // child windows no longer valid 2584 // child windows no longer valid
2585 clearAllViews(); 2585 clearAllViews();
2586 emit closingDown(); 2586 emit closingDown();
2587 2587
2588 mCalendar->close(); 2588 mCalendar->close();
2589 setModified(false); 2589 setModified(false);
2590 updateView(); 2590 updateView();
2591} 2591}
2592 2592
2593void CalendarView::archiveCalendar() 2593void CalendarView::archiveCalendar()
2594{ 2594{
2595 mDialogManager->showArchiveDialog(); 2595 mDialogManager->showArchiveDialog();
2596} 2596}
2597 2597
2598 2598
2599void CalendarView::readSettings() 2599void CalendarView::readSettings()
2600{ 2600{
2601 2601
2602 2602
2603 // mViewManager->showAgendaView(); 2603 // mViewManager->showAgendaView();
2604 QString str; 2604 QString str;
2605 //qDebug("CalendarView::readSettings() "); 2605 //qDebug("CalendarView::readSettings() ");
2606 // read settings from the KConfig, supplying reasonable 2606 // read settings from the KConfig, supplying reasonable
2607 // defaults where none are to be found 2607 // defaults where none are to be found
2608 KConfig *config = KOGlobals::config(); 2608 KConfig *config = KOGlobals::config();
2609#ifndef KORG_NOSPLITTER 2609#ifndef KORG_NOSPLITTER
2610 config->setGroup("KOrganizer Geometry"); 2610 config->setGroup("KOrganizer Geometry");
2611 2611
2612 QValueList<int> sizes = config->readIntListEntry("Separator1"); 2612 QValueList<int> sizes = config->readIntListEntry("Separator1");
2613 if (sizes.count() != 2) { 2613 if (sizes.count() != 2) {
2614 sizes << mDateNavigator->minimumSizeHint().width(); 2614 sizes << mDateNavigator->minimumSizeHint().width();
2615 sizes << 300; 2615 sizes << 300;
2616 } 2616 }
2617 mPanner->setSizes(sizes); 2617 mPanner->setSizes(sizes);
2618 2618
2619 sizes = config->readIntListEntry("Separator2"); 2619 sizes = config->readIntListEntry("Separator2");
2620 if ( ( mResourceView && sizes.count() == 4 ) || 2620 if ( ( mResourceView && sizes.count() == 4 ) ||
2621 ( !mResourceView && sizes.count() == 3 ) ) { 2621 ( !mResourceView && sizes.count() == 3 ) ) {
2622 mLeftSplitter->setSizes(sizes); 2622 mLeftSplitter->setSizes(sizes);
2623 } 2623 }
2624#endif 2624#endif
2625 globalFlagBlockAgenda = 1; 2625 globalFlagBlockAgenda = 1;
2626 mViewManager->showAgendaView(); 2626 mViewManager->showAgendaView();
2627 //mViewManager->readSettings( config ); 2627 //mViewManager->readSettings( config );
2628 mTodoList->restoreLayout(config,QString("Todo Layout")); 2628 mTodoList->restoreLayout(config,QString("Todo Layout"));
2629 readFilterSettings(config); 2629 readFilterSettings(config);
2630 2630
2631#ifdef DESKTOP_VERSION 2631#ifdef DESKTOP_VERSION
2632 config->setGroup("WidgetLayout"); 2632 config->setGroup("WidgetLayout");
2633 QStringList list; 2633 QStringList list;
2634 list = config->readListEntry("MainLayout"); 2634 list = config->readListEntry("MainLayout");
2635 int x,y,w,h; 2635 int x,y,w,h;
2636 if ( ! list.isEmpty() ) { 2636 if ( ! list.isEmpty() ) {
2637 x = list[0].toInt(); 2637 x = list[0].toInt();
2638 y = list[1].toInt(); 2638 y = list[1].toInt();
2639 w = list[2].toInt(); 2639 w = list[2].toInt();
2640 h = list[3].toInt(); 2640 h = list[3].toInt();
2641 KApplication::testCoords( &x,&y,&w,&h ); 2641 KApplication::testCoords( &x,&y,&w,&h );
2642 topLevelWidget()->setGeometry(x,y,w,h); 2642 topLevelWidget()->setGeometry(x,y,w,h);
2643 2643
2644 } else { 2644 } else {
2645 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 2645 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
2646 } 2646 }
2647 list = config->readListEntry("EditEventLayout"); 2647 list = config->readListEntry("EditEventLayout");
2648 if ( ! list.isEmpty() ) { 2648 if ( ! list.isEmpty() ) {
2649 x = list[0].toInt(); 2649 x = list[0].toInt();
2650 y = list[1].toInt(); 2650 y = list[1].toInt();
2651 w = list[2].toInt(); 2651 w = list[2].toInt();
2652 h = list[3].toInt(); 2652 h = list[3].toInt();
2653 KApplication::testCoords( &x,&y,&w,&h ); 2653 KApplication::testCoords( &x,&y,&w,&h );
2654 mEventEditor->setGeometry(x,y,w,h); 2654 mEventEditor->setGeometry(x,y,w,h);
2655 2655
2656 } 2656 }
2657 list = config->readListEntry("EditTodoLayout"); 2657 list = config->readListEntry("EditTodoLayout");
2658 if ( ! list.isEmpty() ) { 2658 if ( ! list.isEmpty() ) {
2659 x = list[0].toInt(); 2659 x = list[0].toInt();
2660 y = list[1].toInt(); 2660 y = list[1].toInt();
2661 w = list[2].toInt(); 2661 w = list[2].toInt();
2662 h = list[3].toInt(); 2662 h = list[3].toInt();
2663 KApplication::testCoords( &x,&y,&w,&h ); 2663 KApplication::testCoords( &x,&y,&w,&h );
2664 mTodoEditor->setGeometry(x,y,w,h); 2664 mTodoEditor->setGeometry(x,y,w,h);
2665 2665
2666 } 2666 }
2667 list = config->readListEntry("ViewerLayout"); 2667 list = config->readListEntry("ViewerLayout");
2668 if ( ! list.isEmpty() ) { 2668 if ( ! list.isEmpty() ) {
2669 x = list[0].toInt(); 2669 x = list[0].toInt();
2670 y = list[1].toInt(); 2670 y = list[1].toInt();
2671 w = list[2].toInt(); 2671 w = list[2].toInt();
2672 h = list[3].toInt(); 2672 h = list[3].toInt();
2673 KApplication::testCoords( &x,&y,&w,&h ); 2673 KApplication::testCoords( &x,&y,&w,&h );
2674 getEventViewerDialog()->setGeometry(x,y,w,h); 2674 getEventViewerDialog()->setGeometry(x,y,w,h);
2675 } 2675 }
2676#endif 2676#endif
2677 config->setGroup( "Views" ); 2677 config->setGroup( "Views" );
2678 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 2678 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
2679 2679
2680 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); 2680 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame");
2681 2681
2682 int resetval = 0; 2682 int resetval = 0;
2683 int maxVal = 0; 2683 int maxVal = 0;
2684 if (sizes.count() != 3) { 2684 if (sizes.count() != 3) {
2685 if ( KOPrefs::instance()->mVerticalScreen ) { 2685 if ( KOPrefs::instance()->mVerticalScreen ) {
2686 resetval = mDateNavigator->sizeHint().width()+2; 2686 resetval = mDateNavigator->sizeHint().width()+2;
2687 } else { 2687 } else {
2688 resetval = mDateNavigator->sizeHint().height()+2; 2688 resetval = mDateNavigator->sizeHint().height()+2;
2689 } 2689 }
2690 } 2690 }
2691 if ( resetval ) { 2691 if ( resetval ) {
2692 sizes.clear(); 2692 sizes.clear();
2693 if ( KOPrefs::instance()->mVerticalScreen ) { 2693 if ( KOPrefs::instance()->mVerticalScreen ) {
2694 maxVal = QApplication::desktop()->width() -10; 2694 maxVal = QApplication::desktop()->width() -10;
2695 } else { 2695 } else {
2696 maxVal = QApplication::desktop()->height()-10; 2696 maxVal = QApplication::desktop()->height()-10;
2697 } 2697 }
2698 sizes << resetval; 2698 sizes << resetval;
2699 if ( maxVal < resetval + resetval) 2699 if ( maxVal < resetval + resetval)
2700 resetval = maxVal - resetval; 2700 resetval = maxVal - resetval;
2701 sizes << resetval; 2701 sizes << resetval;
2702 sizes << 100; 2702 sizes << 100;
2703 } 2703 }
2704 mLeftFrame->setSizes(sizes); 2704 mLeftFrame->setSizes(sizes);
2705 sizes = config->readIntListEntry("Main Splitter Frame"); 2705 sizes = config->readIntListEntry("Main Splitter Frame");
2706 resetval = 0; 2706 resetval = 0;
2707 maxVal = 0; 2707 maxVal = 0;
2708 if (sizes.count() != 2) { 2708 if (sizes.count() != 2) {
2709 if ( !KOPrefs::instance()->mVerticalScreen ) { 2709 if ( !KOPrefs::instance()->mVerticalScreen ) {
2710 resetval = mDateNavigator->sizeHint().width()+2; 2710 resetval = mDateNavigator->sizeHint().width()+2;
2711 } else { 2711 } else {
2712 resetval = mDateNavigator->sizeHint().height()+2; 2712 resetval = mDateNavigator->sizeHint().height()+2;
2713 } 2713 }
2714 } 2714 }
2715 if ( resetval ) { 2715 if ( resetval ) {
2716 sizes.clear(); 2716 sizes.clear();
2717 if ( !KOPrefs::instance()->mVerticalScreen ) { 2717 if ( !KOPrefs::instance()->mVerticalScreen ) {
2718 maxVal = QApplication::desktop()->width() -10; 2718 maxVal = QApplication::desktop()->width() -10;
2719 } else { 2719 } else {
2720 maxVal = QApplication::desktop()->height()-10; 2720 maxVal = QApplication::desktop()->height()-10;
2721 } 2721 }
2722 sizes << resetval; 2722 sizes << resetval;
2723 if ( maxVal < resetval + resetval) 2723 if ( maxVal < resetval + resetval)
2724 resetval = maxVal - resetval; 2724 resetval = maxVal - resetval;
2725 sizes << resetval; 2725 sizes << resetval;
2726 } 2726 }
2727 mMainFrame->setSizes(sizes); 2727 mMainFrame->setSizes(sizes);
2728 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 2728 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
2729 else if ( dateCount == 7 ) mNavigator->selectWeek(); 2729 else if ( dateCount == 7 ) mNavigator->selectWeek();
2730 else mNavigator->selectDates( dateCount ); 2730 else mNavigator->selectDates( dateCount );
2731 // mViewManager->readSettings( config ); 2731 // mViewManager->readSettings( config );
2732 updateConfig(); 2732 updateConfig();
2733 globalFlagBlockAgenda = 2; 2733 globalFlagBlockAgenda = 2;
2734 mViewManager->readSettings( config ); 2734 mViewManager->readSettings( config );
2735 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); 2735 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) );
2736} 2736}
2737 2737
2738void CalendarView::checkSuspendAlarm() 2738void CalendarView::checkSuspendAlarm()
2739{ 2739{
2740 if ( mSuspendTimer->isActive() ) { 2740 if ( mSuspendTimer->isActive() ) {
2741 KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); 2741 KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm"));
2742 } 2742 }
2743} 2743}
2744void CalendarView::writeSettings() 2744void CalendarView::writeSettings()
2745{ 2745{
2746 // kdDebug() << "CalendarView::writeSettings" << endl; 2746 // kdDebug() << "CalendarView::writeSettings" << endl;
2747 2747
2748 KConfig *config = KOGlobals::config(); 2748 KConfig *config = KOGlobals::config();
2749 2749
2750 mViewManager->writeSettings( config ); 2750 mViewManager->writeSettings( config );
2751 mTodoList->saveLayout(config,QString("Todo Layout")); 2751 mTodoList->saveLayout(config,QString("Todo Layout"));
2752 mDialogManager->writeSettings( config ); 2752 mDialogManager->writeSettings( config );
2753 //KOPrefs::instance()->usrWriteConfig(); 2753 //KOPrefs::instance()->usrWriteConfig();
2754 KOPrefs::instance()->writeConfig(); 2754 KOPrefs::instance()->writeConfig();
2755 2755
2756 writeFilterSettings(config); 2756 writeFilterSettings(config);
2757 config->setGroup( "AppRun" ); 2757 config->setGroup( "AppRun" );
2758 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 2758 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
2759 int days = dt.daysTo( QDate::currentDate() ); 2759 int days = dt.daysTo( QDate::currentDate() );
2760 dt = dt.addDays( days ); 2760 dt = dt.addDays( days );
2761 int secs = dt.secsTo( QDateTime::currentDateTime() ); 2761 int secs = dt.secsTo( QDateTime::currentDateTime() );
2762 config->writeEntry( "LatestProgramStopDays", days ); 2762 config->writeEntry( "LatestProgramStopDays", days );
2763 config->writeEntry( "LatestProgramStopSecs", secs ); 2763 config->writeEntry( "LatestProgramStopSecs", secs );
2764 //qDebug("KO: Writing stop time: %d ", secs); 2764 //qDebug("KO: Writing stop time: %d ", secs);
2765 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 2765 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
2766 //QDateTime latest = dt.addSecs ( secs ); 2766 //QDateTime latest = dt.addSecs ( secs );
2767 //qDebug("KO: Termination on %s ", latest.toString().latin1()); 2767 //qDebug("KO: Termination on %s ", latest.toString().latin1());
2768 config->setGroup( "Views" ); 2768 config->setGroup( "Views" );
2769 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 2769 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
2770 2770
2771#if 0 2771#if 0
2772 qDebug("********************* "); 2772 qDebug("********************* ");
2773 qDebug("Testcode secsto "); 2773 qDebug("Testcode secsto ");
2774 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); 2774 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) );
2775 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); 2775 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) );
2776 int secsto = dt_nodaylight.secsTo( dt_daylight ); 2776 int secsto = dt_nodaylight.secsTo( dt_daylight );
2777 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); 2777 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto );
2778 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); 2778 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() );
2779 qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); 2779 qDebug("dt daylight %s ",dt_daylight.toString().latin1() );
2780 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); 2780 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() );
2781 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); 2781 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600);
2782 qDebug("********************* testcode end"); 2782 qDebug("********************* testcode end");
2783 2783
2784#endif 2784#endif
2785 2785
2786 QValueList<int> listINT = mLeftFrame->sizes(); 2786 QValueList<int> listINT = mLeftFrame->sizes();
2787 config->writeEntry("Left Splitter Frame",listINT); 2787 config->writeEntry("Left Splitter Frame",listINT);
2788 QValueList<int> listINT2 = mMainFrame->sizes(); 2788 QValueList<int> listINT2 = mMainFrame->sizes();
2789 config->writeEntry("Main Splitter Frame",listINT2); 2789 config->writeEntry("Main Splitter Frame",listINT2);
2790#ifdef DESKTOP_VERSION 2790#ifdef DESKTOP_VERSION
2791 config->setGroup("WidgetLayout"); 2791 config->setGroup("WidgetLayout");
2792 QStringList list ;//= config->readListEntry("MainLayout"); 2792 QStringList list ;//= config->readListEntry("MainLayout");
2793 int x,y,w,h; 2793 int x,y,w,h;
2794 QWidget* wid; 2794 QWidget* wid;
2795 wid = topLevelWidget(); 2795 wid = topLevelWidget();
2796 x = wid->geometry().x(); 2796 x = wid->geometry().x();
2797 y = wid->geometry().y(); 2797 y = wid->geometry().y();
2798 w = wid->width(); 2798 w = wid->width();
2799 h = wid->height(); 2799 h = wid->height();
2800 list.clear(); 2800 list.clear();
2801 list << QString::number( x ); 2801 list << QString::number( x );
2802 list << QString::number( y ); 2802 list << QString::number( y );
2803 list << QString::number( w ); 2803 list << QString::number( w );
2804 list << QString::number( h ); 2804 list << QString::number( h );
2805 config->writeEntry("MainLayout",list ); 2805 config->writeEntry("MainLayout",list );
2806 2806
2807 wid = mEventEditor; 2807 wid = mEventEditor;
2808 x = wid->geometry().x(); 2808 x = wid->geometry().x();
2809 y = wid->geometry().y(); 2809 y = wid->geometry().y();
2810 w = wid->width(); 2810 w = wid->width();
2811 h = wid->height(); 2811 h = wid->height();
2812 list.clear(); 2812 list.clear();
2813 list << QString::number( x ); 2813 list << QString::number( x );
2814 list << QString::number( y ); 2814 list << QString::number( y );
2815 list << QString::number( w ); 2815 list << QString::number( w );
2816 list << QString::number( h ); 2816 list << QString::number( h );
2817 config->writeEntry("EditEventLayout",list ); 2817 config->writeEntry("EditEventLayout",list );
2818 2818
2819 wid = mTodoEditor; 2819 wid = mTodoEditor;
2820 x = wid->geometry().x(); 2820 x = wid->geometry().x();
2821 y = wid->geometry().y(); 2821 y = wid->geometry().y();
2822 w = wid->width(); 2822 w = wid->width();
2823 h = wid->height(); 2823 h = wid->height();
2824 list.clear(); 2824 list.clear();
2825 list << QString::number( x ); 2825 list << QString::number( x );
2826 list << QString::number( y ); 2826 list << QString::number( y );
2827 list << QString::number( w ); 2827 list << QString::number( w );
2828 list << QString::number( h ); 2828 list << QString::number( h );
2829 config->writeEntry("EditTodoLayout",list ); 2829 config->writeEntry("EditTodoLayout",list );
2830 wid = getEventViewerDialog(); 2830 wid = getEventViewerDialog();
2831 x = wid->geometry().x(); 2831 x = wid->geometry().x();
2832 y = wid->geometry().y(); 2832 y = wid->geometry().y();
2833 w = wid->width(); 2833 w = wid->width();
2834 h = wid->height(); 2834 h = wid->height();
2835 list.clear(); 2835 list.clear();
2836 list << QString::number( x ); 2836 list << QString::number( x );
2837 list << QString::number( y ); 2837 list << QString::number( y );
2838 list << QString::number( w ); 2838 list << QString::number( w );
2839 list << QString::number( h ); 2839 list << QString::number( h );
2840 config->writeEntry("ViewerLayout",list ); 2840 config->writeEntry("ViewerLayout",list );
2841 wid = mDialogManager->getSearchDialog(); 2841 wid = mDialogManager->getSearchDialog();
2842 if ( wid ) { 2842 if ( wid ) {
2843 x = wid->geometry().x(); 2843 x = wid->geometry().x();
2844 y = wid->geometry().y(); 2844 y = wid->geometry().y();
2845 w = wid->width(); 2845 w = wid->width();
2846 h = wid->height(); 2846 h = wid->height();
2847 list.clear(); 2847 list.clear();
2848 list << QString::number( x ); 2848 list << QString::number( x );
2849 list << QString::number( y ); 2849 list << QString::number( y );
2850 list << QString::number( w ); 2850 list << QString::number( w );
2851 list << QString::number( h ); 2851 list << QString::number( h );
2852 config->writeEntry("SearchLayout",list ); 2852 config->writeEntry("SearchLayout",list );
2853 } 2853 }
2854#endif 2854#endif
2855 2855
2856 2856
2857 config->sync(); 2857 config->sync();
2858} 2858}
2859 2859
2860void CalendarView::readFilterSettings(KConfig *config) 2860void CalendarView::readFilterSettings(KConfig *config)
2861{ 2861{
2862 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 2862 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
2863 2863
2864 mFilters.clear(); 2864 mFilters.clear();
2865 2865
2866 config->setGroup("General"); 2866 config->setGroup("General");
2867 QStringList filterList = config->readListEntry("CalendarFilters"); 2867 QStringList filterList = config->readListEntry("CalendarFilters");
2868 2868
2869 QStringList::ConstIterator it = filterList.begin(); 2869 QStringList::ConstIterator it = filterList.begin();
2870 QStringList::ConstIterator end = filterList.end(); 2870 QStringList::ConstIterator end = filterList.end();
2871 while(it != end) { 2871 while(it != end) {
2872 // kdDebug() << " filter: " << (*it) << endl; 2872 // kdDebug() << " filter: " << (*it) << endl;
2873 2873
2874 CalFilter *filter; 2874 CalFilter *filter;
2875 filter = new CalFilter(*it); 2875 filter = new CalFilter(*it);
2876 config->setGroup("Filter_" + (*it).utf8()); 2876 config->setGroup("Filter_" + (*it).utf8());
2877 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 2877 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
2878 filter->setCriteria(config->readNumEntry("Criteria",0)); 2878 filter->setCriteria(config->readNumEntry("Criteria",0));
2879 filter->setCategoryList(config->readListEntry("CategoryList")); 2879 filter->setCategoryList(config->readListEntry("CategoryList"));
2880 mFilters.append(filter); 2880 mFilters.append(filter);
2881 2881
2882 ++it; 2882 ++it;
2883 } 2883 }
2884 2884
2885 if (mFilters.count() == 0) { 2885 if (mFilters.count() == 0) {
2886 CalFilter *filter = new CalFilter(i18n("Default")); 2886 CalFilter *filter = new CalFilter(i18n("Default"));
2887 mFilters.append(filter); 2887 mFilters.append(filter);
2888 } 2888 }
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 70baf5c..2af605f 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -21,769 +21,770 @@
21#include <qtextstream.h> 21#include <qtextstream.h>
22#ifndef DESKTOP_VERSION 22#ifndef DESKTOP_VERSION
23#include <qpe/global.h> 23#include <qpe/global.h>
24#include <qpe/qpetoolbar.h> 24#include <qpe/qpetoolbar.h>
25#include <qpe/resource.h> 25#include <qpe/resource.h>
26#include <qpe/qpeapplication.h> 26#include <qpe/qpeapplication.h>
27#include <qtopia/alarmserver.h> 27#include <qtopia/alarmserver.h>
28#include <qtopia/qcopenvelope_qws.h> 28#include <qtopia/qcopenvelope_qws.h>
29#include <unistd.h> // for sleep 29#include <unistd.h> // for sleep
30#else 30#else
31#include <qtoolbar.h> 31#include <qtoolbar.h>
32#include <qapplication.h> 32#include <qapplication.h>
33//#include <resource.h> 33//#include <resource.h>
34 34
35#endif 35#endif
36#include <libkcal/calendarlocal.h> 36#include <libkcal/calendarlocal.h>
37#include <libkcal/todo.h> 37#include <libkcal/todo.h>
38#include <libkcal/phoneformat.h> 38#include <libkcal/phoneformat.h>
39#include <libkdepim/ksyncprofile.h> 39#include <libkdepim/ksyncprofile.h>
40#include <libkdepim/phoneaccess.h> 40#include <libkdepim/phoneaccess.h>
41#include <libkcal/kincidenceformatter.h> 41#include <libkcal/kincidenceformatter.h>
42#include <libkdepim/kpimglobalprefs.h> 42#include <libkdepim/kpimglobalprefs.h>
43 43
44#include "calendarview.h" 44#include "calendarview.h"
45#include "koviewmanager.h" 45#include "koviewmanager.h"
46#include "datenavigator.h" 46#include "datenavigator.h"
47#include "koagendaview.h" 47#include "koagendaview.h"
48#include "kojournalview.h" 48#include "kojournalview.h"
49#include "koagenda.h" 49#include "koagenda.h"
50#include "kodialogmanager.h" 50#include "kodialogmanager.h"
51#include "kdialogbase.h" 51#include "kdialogbase.h"
52#include "kapplication.h" 52#include "kapplication.h"
53#include "kofilterview.h" 53#include "kofilterview.h"
54#include "kstandarddirs.h" 54#include "kstandarddirs.h"
55#include "koprefs.h" 55#include "koprefs.h"
56#include "kfiledialog.h" 56#include "kfiledialog.h"
57#include "koglobals.h" 57#include "koglobals.h"
58#include "kglobal.h" 58#include "kglobal.h"
59#include "ktoolbar.h" 59#include "ktoolbar.h"
60#include "klocale.h" 60#include "klocale.h"
61#include "kconfig.h" 61#include "kconfig.h"
62#include "externalapphandler.h" 62#include "externalapphandler.h"
63#include <kglobalsettings.h> 63#include <kglobalsettings.h>
64 64
65using namespace KCal; 65using namespace KCal;
66#ifndef _WIN32_ 66#ifndef _WIN32_
67#include <unistd.h> 67#include <unistd.h>
68#else 68#else
69#ifdef _OL_IMPORT_ 69#ifdef _OL_IMPORT_
70#include "koimportoldialog.h" 70#include "koimportoldialog.h"
71#endif 71#endif
72#endif 72#endif
73#include "mainwindow.h" 73#include "mainwindow.h"
74 74
75 75
76class KOex2phonePrefs : public QDialog 76class KOex2phonePrefs : public QDialog
77{ 77{
78 public: 78 public:
79 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 79 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
80 QDialog( parent, name, true ) 80 QDialog( parent, name, true )
81 { 81 {
82 setCaption( i18n("Export to phone options") ); 82 setCaption( i18n("Export to phone options") );
83 QVBoxLayout* lay = new QVBoxLayout( this ); 83 QVBoxLayout* lay = new QVBoxLayout( this );
84 lay->setSpacing( 3 ); 84 lay->setSpacing( 3 );
85 lay->setMargin( 3 ); 85 lay->setMargin( 3 );
86 QLabel *lab; 86 QLabel *lab;
87 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 87 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
88 lab->setAlignment (AlignHCenter ); 88 lab->setAlignment (AlignHCenter );
89 QHBox* temphb; 89 QHBox* temphb;
90 temphb = new QHBox( this ); 90 temphb = new QHBox( this );
91 new QLabel( i18n("I/O device: "), temphb ); 91 new QLabel( i18n("I/O device: "), temphb );
92 mPhoneDevice = new QLineEdit( temphb); 92 mPhoneDevice = new QLineEdit( temphb);
93 lay->addWidget( temphb ); 93 lay->addWidget( temphb );
94 temphb = new QHBox( this ); 94 temphb = new QHBox( this );
95 new QLabel( i18n("Connection: "), temphb ); 95 new QLabel( i18n("Connection: "), temphb );
96 mPhoneConnection = new QLineEdit( temphb); 96 mPhoneConnection = new QLineEdit( temphb);
97 lay->addWidget( temphb ); 97 lay->addWidget( temphb );
98 temphb = new QHBox( this ); 98 temphb = new QHBox( this );
99 new QLabel( i18n("Model(opt.): "), temphb ); 99 new QLabel( i18n("Model(opt.): "), temphb );
100 mPhoneModel = new QLineEdit( temphb); 100 mPhoneModel = new QLineEdit( temphb);
101 lay->addWidget( temphb ); 101 lay->addWidget( temphb );
102 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); 102 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
103 mWriteBackFuture->setChecked( true ); 103 mWriteBackFuture->setChecked( true );
104 lay->addWidget( mWriteBackFuture ); 104 lay->addWidget( mWriteBackFuture );
105 temphb = new QHBox( this ); 105 temphb = new QHBox( this );
106 new QLabel( i18n("Max. weeks in future: ") , temphb ); 106 new QLabel( i18n("Max. weeks in future: ") , temphb );
107 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); 107 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
108 mWriteBackFutureWeeks->setValue( 8 ); 108 mWriteBackFutureWeeks->setValue( 8 );
109 lay->addWidget( temphb ); 109 lay->addWidget( temphb );
110 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); 110 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) );
111 lab->setAlignment (AlignHCenter ); 111 lab->setAlignment (AlignHCenter );
112 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 112 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
113 lay->addWidget( ok ); 113 lay->addWidget( ok );
114 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 114 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
115 lay->addWidget( cancel ); 115 lay->addWidget( cancel );
116 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 116 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
117 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 117 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
118 resize( 220, 240 ); 118 resize( 220, 240 );
119 qApp->processEvents(); 119 qApp->processEvents();
120 int dw = QApplication::desktop()->width(); 120 int dw = QApplication::desktop()->width();
121 int dh = QApplication::desktop()->height(); 121 int dh = QApplication::desktop()->height();
122 move( (dw-width())/2, (dh - height() )/2 ); 122 move( (dw-width())/2, (dh - height() )/2 );
123 } 123 }
124 124
125public: 125public:
126 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 126 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
127 QCheckBox* mWriteBackFuture; 127 QCheckBox* mWriteBackFuture;
128 QSpinBox* mWriteBackFutureWeeks; 128 QSpinBox* mWriteBackFutureWeeks;
129}; 129};
130 130
131QPixmap* sgListViewCompletedPix[6]; 131QPixmap* sgListViewCompletedPix[6];
132QPixmap* sgListViewJournalPix; 132QPixmap* sgListViewJournalPix;
133 133
134 134
135int globalFlagBlockStartup; 135int globalFlagBlockStartup;
136MainWindow::MainWindow( QWidget *parent, const char *name ) : 136MainWindow::MainWindow( QWidget *parent, const char *name ) :
137 QMainWindow( parent, name ) 137 QMainWindow( parent, name )
138{ 138{
139 sgListViewCompletedPix[5] = &listviewPix; 139 sgListViewCompletedPix[5] = &listviewPix;
140 sgListViewCompletedPix[0] = &listviewPix0; 140 sgListViewCompletedPix[0] = &listviewPix0;
141 sgListViewCompletedPix[1] = &listviewPix20; 141 sgListViewCompletedPix[1] = &listviewPix20;
142 sgListViewCompletedPix[2] = &listviewPix40; 142 sgListViewCompletedPix[2] = &listviewPix40;
143 sgListViewCompletedPix[3] = &listviewPix60; 143 sgListViewCompletedPix[3] = &listviewPix60;
144 sgListViewCompletedPix[4] = &listviewPix80; 144 sgListViewCompletedPix[4] = &listviewPix80;
145 //int size = 12; 145 //int size = 12;
146 { 146 {
147 sgListViewCompletedPix[5]->resize( 11, 11 ); 147 sgListViewCompletedPix[5]->resize( 11, 11 );
148 sgListViewCompletedPix[5]->fill( Qt::white ); 148 sgListViewCompletedPix[5]->fill( Qt::white );
149 QPainter p ( sgListViewCompletedPix[5] ); 149 QPainter p ( sgListViewCompletedPix[5] );
150 p.drawRect( 0,0,11,11); 150 p.drawRect( 0,0,11,11);
151 p.drawLine ( 2, 5, 4 , 7 ) ; 151 p.drawLine ( 2, 5, 4 , 7 ) ;
152 p.drawLine ( 4 , 7 , 8, 3) ; 152 p.drawLine ( 4 , 7 , 8, 3) ;
153 int iii = 0; 153 int iii = 0;
154 for ( iii = 0; iii < 5; ++iii ) { 154 for ( iii = 0; iii < 5; ++iii ) {
155 sgListViewCompletedPix[iii]->resize( 11, 11 ); 155 sgListViewCompletedPix[iii]->resize( 11, 11 );
156 sgListViewCompletedPix[iii]->fill( Qt::white ); 156 sgListViewCompletedPix[iii]->fill( Qt::white );
157 QPainter p ( sgListViewCompletedPix[iii] ); 157 QPainter p ( sgListViewCompletedPix[iii] );
158 p.drawRect( 0,0,11,11); 158 p.drawRect( 0,0,11,11);
159 if ( iii ) 159 if ( iii )
160 p.fillRect( 1,1,iii*2,9,Qt::gray ); 160 p.fillRect( 1,1,iii*2,9,Qt::gray );
161 } 161 }
162 sgListViewJournalPix = &journalPix; 162 sgListViewJournalPix = &journalPix;
163 sgListViewJournalPix->resize( 11, 11 ); 163 sgListViewJournalPix->resize( 11, 11 );
164 sgListViewJournalPix->fill( Qt::white ); 164 sgListViewJournalPix->fill( Qt::white );
165 { 165 {
166 QPainter p ( sgListViewJournalPix ); 166 QPainter p ( sgListViewJournalPix );
167 p.drawRect( 0,0,11,11); 167 p.drawRect( 0,0,11,11);
168 p.drawLine( 2,3,5,3); 168 p.drawLine( 2,3,5,3);
169 p.drawLine( 2,5,8,5); 169 p.drawLine( 2,5,8,5);
170 p.drawLine( 2,7,6,7); 170 p.drawLine( 2,7,6,7);
171 } 171 }
172 } 172 }
173 mClosed = false; 173 mClosed = false;
174 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 174 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
175 QString confFile = locateLocal("config","korganizerrc"); 175 QString confFile = locateLocal("config","korganizerrc");
176 QFileInfo finf ( confFile ); 176 QFileInfo finf ( confFile );
177 bool showWarning = !finf.exists(); 177 bool showWarning = !finf.exists();
178 setIcon(SmallIcon( "ko24" ) ); 178 setIcon(SmallIcon( "ko24" ) );
179 mBlockAtStartup = true; 179 mBlockAtStartup = true;
180 mFlagKeyPressed = false; 180 mFlagKeyPressed = false;
181 setCaption("KO/Pi"); 181 setCaption("KO/Pi");
182 KOPrefs *p = KOPrefs::instance(); 182 KOPrefs *p = KOPrefs::instance();
183 //KPimGlobalPrefs::instance()->setGlobalConfig(); 183 //KPimGlobalPrefs::instance()->setGlobalConfig();
184 p->mCurrentDisplayedView = 0; 184 p->mCurrentDisplayedView = 0;
185 if ( p->mHourSize > 22 ) 185 if ( p->mHourSize > 22 )
186 p->mHourSize = 22; 186 p->mHourSize = 22;
187 QMainWindow::ToolBarDock tbd; 187 QMainWindow::ToolBarDock tbd;
188 if ( p->mToolBarHor ) { 188 if ( p->mToolBarHor ) {
189 if ( p->mToolBarUp ) 189 if ( p->mToolBarUp )
190 tbd = Bottom; 190 tbd = Bottom;
191 else 191 else
192 tbd = Top; 192 tbd = Top;
193 } 193 }
194 else { 194 else {
195 if ( p->mToolBarUp ) 195 if ( p->mToolBarUp )
196 tbd = Right; 196 tbd = Right;
197 else 197 else
198 tbd = Left; 198 tbd = Left;
199 } 199 }
200 if ( KOPrefs::instance()->mUseAppColors ) 200 if ( KOPrefs::instance()->mUseAppColors )
201 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 201 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
202 globalFlagBlockStartup = 1; 202 globalFlagBlockStartup = 1;
203 iconToolBar = new QPEToolBar( this ); 203 iconToolBar = new QPEToolBar( this );
204 addToolBar (iconToolBar , tbd ); 204 addToolBar (iconToolBar , tbd );
205 205
206#ifdef DESKTOP_VERSION 206#ifdef DESKTOP_VERSION
207 if ( KOPrefs::instance()->mShowIconFilter ) 207 if ( KOPrefs::instance()->mShowIconFilter )
208#else 208#else
209 if ( KOPrefs::instance()->mShowIconFilter || ( !p->mShowIconOnetoolbar &&!p->mShowIconFilterview ) ) 209 if ( KOPrefs::instance()->mShowIconFilter || ( !p->mShowIconOnetoolbar &&!p->mShowIconFilterview ) )
210#endif 210#endif
211 211
212{ 212{
213 if ( p->mToolBarHorF ) { 213 if ( p->mToolBarHorF ) {
214 if ( p->mToolBarUpF ) 214 if ( p->mToolBarUpF )
215 tbd = Bottom; 215 tbd = Bottom;
216 else 216 else
217 tbd = Top; 217 tbd = Top;
218 } 218 }
219 else { 219 else {
220 if ( p->mToolBarUpF ) 220 if ( p->mToolBarUpF )
221 tbd = Right; 221 tbd = Right;
222 else 222 else
223 tbd = Left; 223 tbd = Left;
224 } 224 }
225 filterToolBar = new QPEToolBar ( this ); 225 filterToolBar = new QPEToolBar ( this );
226 filterMenubar = new KMenuBar( 0 ); 226 filterMenubar = new KMenuBar( 0 );
227 QFontMetrics fm ( filterMenubar->font() ); 227 QFontMetrics fm ( filterMenubar->font() );
228#ifndef DESKTOP_VERSION 228#ifndef DESKTOP_VERSION
229 filterToolBar->setFocusPolicy( NoFocus ); 229 filterToolBar->setFocusPolicy( NoFocus );
230 filterMenubar->setFocusPolicy( NoFocus ); 230 filterMenubar->setFocusPolicy( NoFocus );
231#endif 231#endif
232 filterPopupMenu = new QPopupMenu( this ); 232 filterPopupMenu = new QPopupMenu( this );
233 filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 ); 233 filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 );
234 QString addTest = "A"; 234 QString addTest = "A";
235 filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) ); 235 filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) );
236#ifdef DESKTOP_VERSION 236#ifdef DESKTOP_VERSION
237 addTest = "AAAAAABBBCCCx"; 237 addTest = "AAAAAABBBCCCx";
238#else 238#else
239 addTest = "AAAAAx"; 239 addTest = "AAAAAx";
240#endif 240#endif
241 filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) ); 241 filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) );
242 addToolBar (filterToolBar , tbd ); 242 addToolBar (filterToolBar , tbd );
243 connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) ); 243 connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) );
244 connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) ); 244 connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) );
245 if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar ) 245 if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar )
246 filterToolBar->hide(); 246 filterToolBar->hide();
247 } else { 247 } else {
248 filterToolBar = 0; 248 filterToolBar = 0;
249 filterMenubar = 0; 249 filterMenubar = 0;
250 filterPopupMenu = 0; 250 filterPopupMenu = 0;
251 } 251 }
252 if ( p->mShowIconOnetoolbar ) { 252 if ( p->mShowIconOnetoolbar ) {
253 viewToolBar = iconToolBar ; 253 viewToolBar = iconToolBar ;
254 navigatorToolBar = iconToolBar ; 254 navigatorToolBar = iconToolBar ;
255 } else { 255 } else {
256#ifndef DESKTOP_VERSION 256#ifndef DESKTOP_VERSION
257 setToolBarsMovable( false ); 257 setToolBarsMovable( false );
258#endif 258#endif
259 if ( p->mToolBarHorV ) { 259 if ( p->mToolBarHorV ) {
260 if ( p->mToolBarUpV ) 260 if ( p->mToolBarUpV )
261 tbd = Bottom; 261 tbd = Bottom;
262 else 262 else
263 tbd = Top; 263 tbd = Top;
264 } 264 }
265 else { 265 else {
266 if ( p->mToolBarUpV ) 266 if ( p->mToolBarUpV )
267 tbd = Right; 267 tbd = Right;
268 else 268 else
269 tbd = Left; 269 tbd = Left;
270 } 270 }
271 viewToolBar = new QPEToolBar( this ); 271 viewToolBar = new QPEToolBar( this );
272 addToolBar (viewToolBar , tbd ); 272 addToolBar (viewToolBar , tbd );
273 if ( p->mToolBarHorN ) { 273 if ( p->mToolBarHorN ) {
274 if ( p->mToolBarUpN ) 274 if ( p->mToolBarUpN )
275 tbd = Bottom; 275 tbd = Bottom;
276 else 276 else
277 tbd = Top; 277 tbd = Top;
278 } 278 }
279 else { 279 else {
280 if ( p->mToolBarUpN ) 280 if ( p->mToolBarUpN )
281 tbd = Right; 281 tbd = Right;
282 else 282 else
283 tbd = Left; 283 tbd = Left;
284 } 284 }
285 navigatorToolBar = new QPEToolBar( this ); 285 navigatorToolBar = new QPEToolBar( this );
286 addToolBar (navigatorToolBar , tbd ); 286 addToolBar (navigatorToolBar , tbd );
287 } 287 }
288 288
289 289
290 290
291 mCalendarModifiedFlag = false; 291 mCalendarModifiedFlag = false;
292 // QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 292 // QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
293 //splash->setAlignment ( AlignCenter ); 293 //splash->setAlignment ( AlignCenter );
294 //setCentralWidget( splash ); 294 //setCentralWidget( splash );
295#ifndef DESKTOP_VERSION 295#ifndef DESKTOP_VERSION
296 //showMaximized(); 296 //showMaximized();
297#endif 297#endif
298 298
299 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 299 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
300 setDefaultPreferences(); 300 setDefaultPreferences();
301 mCalendar = new CalendarLocal(); 301 mCalendar = new CalendarLocal();
302 mView = new CalendarView( mCalendar, this,"mCalendar " ); 302 mView = new CalendarView( mCalendar, this,"mCalendar " );
303 setCentralWidget( mView ); 303 setCentralWidget( mView );
304 //mView->hide(); 304 //mView->hide();
305 //mView->resize(splash->size() ); 305 //mView->resize(splash->size() );
306 initActions(); 306 initActions();
307 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); 307 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu);
308 mSyncManager->setBlockSave(false); 308 mSyncManager->setBlockSave(false);
309 mView->setSyncManager(mSyncManager); 309 mView->setSyncManager(mSyncManager);
310#ifndef DESKTOP_VERSION 310#ifndef DESKTOP_VERSION
311 iconToolBar->show(); 311 iconToolBar->show();
312 qApp->processEvents(); 312 qApp->processEvents();
313#endif 313#endif
314 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 314 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
315 int vh = height() ; 315 int vh = height() ;
316 int vw = width(); 316 int vw = width();
317 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 317 //qDebug("Toolbar hei %d ",iconToolBar->height() );
318 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 318 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
319 vh -= iconToolBar->height(); 319 vh -= iconToolBar->height();
320 } else { 320 } else {
321 vw -= iconToolBar->height(); 321 vw -= iconToolBar->height();
322 } 322 }
323 //mView->setMaximumSize( splash->size() ); 323 //mView->setMaximumSize( splash->size() );
324 //mView->resize( splash->size() ); 324 //mView->resize( splash->size() );
325 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 325 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
326 mView->readSettings(); 326 mView->readSettings();
327 bool newFile = false; 327 bool newFile = false;
328 if( !QFile::exists( defaultFileName() ) ) { 328 if( !QFile::exists( defaultFileName() ) ) {
329 QFileInfo finfo ( defaultFileName() ); 329 QFileInfo finfo ( defaultFileName() );
330 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 330 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
331 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; 331 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n";
332 finfo.setFile( oldFile ); 332 finfo.setFile( oldFile );
333 if (finfo.exists() ) { 333 if (finfo.exists() ) {
334 KMessageBox::information( this, message); 334 KMessageBox::information( this, message);
335 mView->openCalendar( oldFile ); 335 mView->openCalendar( oldFile );
336 qApp->processEvents(); 336 qApp->processEvents();
337 } else { 337 } else {
338 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 338 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
339 finfo.setFile( oldFile ); 339 finfo.setFile( oldFile );
340 if (finfo.exists() ) { 340 if (finfo.exists() ) {
341 KMessageBox::information( this, message); 341 KMessageBox::information( this, message);
342 mView->openCalendar( oldFile ); 342 mView->openCalendar( oldFile );
343 qApp->processEvents(); 343 qApp->processEvents();
344 } 344 }
345 } 345 }
346 mView->saveCalendar( defaultFileName() ); 346 mView->saveCalendar( defaultFileName() );
347 newFile = true; 347 newFile = true;
348 } 348 }
349 349
350 //QTime neededSaveTime = QDateTime::currentDateTime().time(); 350 //QTime neededSaveTime = QDateTime::currentDateTime().time();
351 //mView->loadCalendars(); 351 //mView->loadCalendars();
352 //int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 352 //int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
353 //qDebug("KO: Calendar loading time: %d ms",msNeeded ); 353 //qDebug("KO: Calendar loading time: %d ms",msNeeded );
354 354
355 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { 355 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) {
356 KOPrefs::instance()->setAllDefaults(); 356 KOPrefs::instance()->setAllDefaults();
357 } 357 }
358 358
359 359
360 connect( mView, SIGNAL( tempDisableBR(bool) ), 360 connect( mView, SIGNAL( tempDisableBR(bool) ),
361 SLOT( disableBR(bool) ) ); 361 SLOT( disableBR(bool) ) );
362 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 362 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
363 setCentralWidget( mView ); 363 setCentralWidget( mView );
364 globalFlagBlockStartup = 0; 364 globalFlagBlockStartup = 0;
365 //mView->show(); 365 //mView->show();
366 //delete splash; 366 //delete splash;
367 if ( newFile ) 367 if ( newFile )
368 mView->updateConfig(); 368 mView->updateConfig();
369 // qApp->processEvents(); 369 // qApp->processEvents();
370 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 370 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
371 //fillSyncMenu(); 371 //fillSyncMenu();
372 372
373 373
374 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); 374 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
375 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); 375 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) );
376 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 376 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
377 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 377 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
378 mSyncManager->setDefaultFileName( sentSyncFile()); 378 mSyncManager->setDefaultFileName( sentSyncFile());
379 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); 379 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
380 mSyncManager->fillSyncMenu(); 380 mSyncManager->fillSyncMenu();
381 381
382 382
383 383
384 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 384 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
385 if ( showWarning ) { 385 if ( showWarning ) {
386 KMessageBox::information( this, 386 KMessageBox::information( this,
387 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); 387 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information");
388 qApp->processEvents(); 388 qApp->processEvents();
389 mView->dialogManager()->showSyncOptions(); 389 mView->dialogManager()->showSyncOptions();
390 } 390 }
391 391
392 //US listen for result adressed from Ka/Pi 392 //US listen for result adressed from Ka/Pi
393 393
394#ifndef DESKTOP_VERSION 394#ifndef DESKTOP_VERSION
395 infrared = 0; 395 infrared = 0;
396#endif 396#endif
397 updateFilterToolbar(); 397 updateFilterToolbar();
398 updateWeek( mView->startDate() ); 398 updateWeek( mView->startDate() );
399 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), 399 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ),
400 SLOT( updateWeekNum( const KCal::DateList & ) ) ); 400 SLOT( updateWeekNum( const KCal::DateList & ) ) );
401 mBRdisabled = false; 401 mBRdisabled = false;
402 //toggleBeamReceive(); 402 //toggleBeamReceive();
403 403
404 setCaption(i18n("Loading calendar files ... please wait" )); 404 setCaption(i18n("Loading calendar files ... please wait" ));
405 QTimer::singleShot( 10, this, SLOT ( loadDataAfterStart() )); 405 mSaveDelay = 0;
406 QTimer::singleShot( 1, this, SLOT ( loadDataAfterStart() ));
406} 407}
407MainWindow::~MainWindow() 408MainWindow::~MainWindow()
408{ 409{
409 //qDebug("MainWindow::~MainWindow() "); 410 //qDebug("MainWindow::~MainWindow() ");
410 //save toolbar location 411 //save toolbar location
411 delete mCalendar; 412 delete mCalendar;
412 delete mSyncManager; 413 delete mSyncManager;
413#ifndef DESKTOP_VERSION 414#ifndef DESKTOP_VERSION
414 if ( infrared ) 415 if ( infrared )
415 delete infrared; 416 delete infrared;
416#endif 417#endif
417 418
418 419
419} 420}
420 421
421void MainWindow::loadDataAfterStart() 422void MainWindow::loadDataAfterStart()
422{ 423{
423 424
424 qDebug("KO: Start loading files..." ); 425 qDebug("KO: Start loading files..." );
425 QTime neededSaveTime = QDateTime::currentDateTime().time(); 426 QTime neededSaveTime = QDateTime::currentDateTime().time();
426 mView->loadCalendars(); 427 mView->loadCalendars();
427 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 428 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
428 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 429 qDebug("KO: Calendar loading time: %d ms",msNeeded );
429 //QTimer::singleShot( 1000, mView, SLOT ( checkFiles() )); 430 //QTimer::singleShot( 1000, mView, SLOT ( checkFiles() ));
430 mView->setModified( false ); 431 mView->setModified( false );
431 mBlockAtStartup = false; 432 mBlockAtStartup = false;
432 mView->setModified( false ); 433 mView->setModified( false );
433 connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); 434 connect(mView , SIGNAL( save() ), this, SLOT( save() ) );
434 processIncidenceSelection( 0 ); 435 processIncidenceSelection( 0 );
435 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 436 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
436 SLOT( processIncidenceSelection( Incidence * ) ) ); 437 SLOT( processIncidenceSelection( Incidence * ) ) );
437 connect( mView, SIGNAL( modifiedChanged( bool ) ), 438 connect( mView, SIGNAL( modifiedChanged( bool ) ),
438 SLOT( slotModifiedChanged( bool ) ) ); 439 SLOT( slotModifiedChanged( bool ) ) );
439 440
440#ifndef DESKTOP_VERSION 441#ifndef DESKTOP_VERSION
441 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 442 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
442 connect( qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT(recieve( const QCString&, const QByteArray& ))); 443 connect( qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT(recieve( const QCString&, const QByteArray& )));
443 disconnect( qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT(receiveStart( const QCString&, const QByteArray& ))); 444 disconnect( qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT(receiveStart( const QCString&, const QByteArray& )));
444 if ( !mCStringMess.isEmpty() ) 445 if ( !mCStringMess.isEmpty() )
445 recieve( mCStringMess, mByteData ); 446 recieve( mCStringMess, mByteData );
446#endif 447#endif
447 448
448 449
449 QTimer::singleShot( 1000, mView, SLOT ( checkFiles() )); 450 QTimer::singleShot( 1000, mView, SLOT ( checkFiles() ));
450} 451}
451 452
452void MainWindow::slotResetFocus() 453void MainWindow::slotResetFocus()
453{ 454{
454 //qDebug(" CalendarView::slotResetFocus() %x %x %x %x", qApp->focusWidget(), menuBar1, mView,iconToolBar); 455 //qDebug(" CalendarView::slotResetFocus() %x %x %x %x", qApp->focusWidget(), menuBar1, mView,iconToolBar);
455 mFocusLoop = 3; 456 mFocusLoop = 3;
456 QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() )); 457 QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() ));
457} 458}
458void MainWindow::slotResetFocusLoop() 459void MainWindow::slotResetFocusLoop()
459{ 460{
460 --mFocusLoop; 461 --mFocusLoop;
461 QWidget* fw = mView->viewManager()->currentView(); 462 QWidget* fw = mView->viewManager()->currentView();
462 if ( fw ) { 463 if ( fw ) {
463 //qDebug("loop "); 464 //qDebug("loop ");
464 fw->setFocus(); 465 fw->setFocus();
465 if ( qApp->focusWidget() != fw && mFocusLoop > 0 ) 466 if ( qApp->focusWidget() != fw && mFocusLoop > 0 )
466 QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() )); 467 QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() ));
467 } 468 }
468 469
469} 470}
470void MainWindow::disableBR(bool b) 471void MainWindow::disableBR(bool b)
471{ 472{
472#ifndef DESKTOP_VERSION 473#ifndef DESKTOP_VERSION
473 if ( b ) { 474 if ( b ) {
474 if ( infrared ) { 475 if ( infrared ) {
475 toggleBeamReceive(); 476 toggleBeamReceive();
476 mBRdisabled = true; 477 mBRdisabled = true;
477 } 478 }
478 mBRdisabled = true; 479 mBRdisabled = true;
479 } else { 480 } else {
480 if ( mBRdisabled ) { 481 if ( mBRdisabled ) {
481 mBRdisabled = false; 482 mBRdisabled = false;
482 //makes no sense,because other cal ap is probably running 483 //makes no sense,because other cal ap is probably running
483 // toggleBeamReceive(); 484 // toggleBeamReceive();
484 } 485 }
485 } 486 }
486#endif 487#endif
487 488
488} 489}
489bool MainWindow::beamReceiveEnabled() 490bool MainWindow::beamReceiveEnabled()
490{ 491{
491#ifndef DESKTOP_VERSION 492#ifndef DESKTOP_VERSION
492 return ( infrared != 0 ); 493 return ( infrared != 0 );
493#endif 494#endif
494 return false; 495 return false;
495} 496}
496 497
497void MainWindow::toggleBeamReceive() 498void MainWindow::toggleBeamReceive()
498{ 499{
499 if ( mBRdisabled ) 500 if ( mBRdisabled )
500 return; 501 return;
501#ifndef DESKTOP_VERSION 502#ifndef DESKTOP_VERSION
502 if ( infrared ) { 503 if ( infrared ) {
503 qDebug("KO: Disable BeamReceive "); 504 qDebug("KO: Disable BeamReceive ");
504 delete infrared; 505 delete infrared;
505 infrared = 0; 506 infrared = 0;
506 brAction->setOn(false); 507 brAction->setOn(false);
507 return; 508 return;
508 } 509 }
509 qDebug("KO: Enable BeamReceive "); 510 qDebug("KO: Enable BeamReceive ");
510 brAction->setOn(true); 511 brAction->setOn(true);
511 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; 512 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ;
512 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); 513 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& )));
513#endif 514#endif
514} 515}
515void MainWindow::showMaximized () 516void MainWindow::showMaximized ()
516{ 517{
517#ifndef DESKTOP_VERSION 518#ifndef DESKTOP_VERSION
518 if ( ! globalFlagBlockStartup ) 519 if ( ! globalFlagBlockStartup )
519 if ( mClosed ) 520 if ( mClosed )
520 mView->goToday(); 521 mView->goToday();
521#endif 522#endif
522 QWidget::showMaximized () ; 523 QWidget::showMaximized () ;
523 mClosed = false; 524 mClosed = false;
524} 525}
525void MainWindow::closeEvent( QCloseEvent* ce ) 526void MainWindow::closeEvent( QCloseEvent* ce )
526{ 527{
527 528
528 529
529 530
530 if ( ! KOPrefs::instance()->mAskForQuit ) { 531 if ( ! KOPrefs::instance()->mAskForQuit ) {
531 saveOnClose(); 532 saveOnClose();
532 if ( mCalendarModifiedFlag ) { 533 if ( mCalendarModifiedFlag ) {
533 ce->ignore(); 534 ce->ignore();
534 return; 535 return;
535 } 536 }
536 mClosed = true; 537 mClosed = true;
537 ce->accept(); 538 ce->accept();
538 return; 539 return;
539 540
540 } 541 }
541 542
542 switch( QMessageBox::information( this, "KO/Pi", 543 switch( QMessageBox::information( this, "KO/Pi",
543 i18n("Do you really want\nto close KO/Pi?"), 544 i18n("Do you really want\nto close KO/Pi?"),
544 i18n("Close"), i18n("No"), 545 i18n("Close"), i18n("No"),
545 0, 0 ) ) { 546 0, 0 ) ) {
546 case 0: 547 case 0:
547 saveOnClose(); 548 saveOnClose();
548 if ( mCalendarModifiedFlag ) { 549 if ( mCalendarModifiedFlag ) {
549 ce->ignore(); 550 ce->ignore();
550 return; 551 return;
551 } 552 }
552 mClosed = true; 553 mClosed = true;
553 ce->accept(); 554 ce->accept();
554 break; 555 break;
555 case 1: 556 case 1:
556 ce->ignore(); 557 ce->ignore();
557 break; 558 break;
558 case 2: 559 case 2:
559 560
560 default: 561 default:
561 break; 562 break;
562 } 563 }
563 564
564 565
565} 566}
566void MainWindow::receiveStart( const QCString& cmsg, const QByteArray& data ) 567void MainWindow::receiveStart( const QCString& cmsg, const QByteArray& data )
567{ 568{
568 qDebug("KO: QCOP start message received: %s ", cmsg.data() ); 569 qDebug("KO: QCOP start message received: %s ", cmsg.data() );
569 mCStringMess = cmsg; 570 mCStringMess = cmsg;
570 mByteData = data; 571 mByteData = data;
571} 572}
572void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 573void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
573{ 574{
574 QDataStream stream( data, IO_ReadOnly ); 575 QDataStream stream( data, IO_ReadOnly );
575 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 576 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
576 //QString datamess; 577 //QString datamess;
577 //qDebug("message "); 578 //qDebug("message ");
578 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 579 qDebug("KO: QCOP message received: %s ", cmsg.data() );
579 580
580 if ( cmsg == "setDocument(QString)" ) { 581 if ( cmsg == "setDocument(QString)" ) {
581 QDataStream stream( data, IO_ReadOnly ); 582 QDataStream stream( data, IO_ReadOnly );
582 QString fileName; 583 QString fileName;
583 stream >> fileName; 584 stream >> fileName;
584 //qDebug("filename %s ", fileName.latin1()); 585 //qDebug("filename %s ", fileName.latin1());
585 showMaximized(); 586 showMaximized();
586 raise(); 587 raise();
587 KOPrefs::instance()->mLastSyncedLocalFile = fileName ; 588 KOPrefs::instance()->mLastSyncedLocalFile = fileName ;
588 mSyncManager->slotSyncMenu( 1002 ); 589 mSyncManager->slotSyncMenu( 1002 );
589 return; 590 return;
590 } 591 }
591 592
592 if ( cmsg == "-writeFile" ) { 593 if ( cmsg == "-writeFile" ) {
593 // I made from the "-writeFile" an "-writeAlarm" 594 // I made from the "-writeFile" an "-writeAlarm"
594 mView->viewManager()->showWhatsNextView(); 595 mView->viewManager()->showWhatsNextView();
595 mCalendar->checkAlarmForIncidence( 0, true); 596 mCalendar->checkAlarmForIncidence( 0, true);
596 showMaximized(); 597 showMaximized();
597 raise(); 598 raise();
598 return; 599 return;
599 600
600 } 601 }
601 if ( cmsg == "-writeFileSilent" ) { 602 if ( cmsg == "-writeFileSilent" ) {
602 // I made from the "-writeFile" an "-writeAlarm" 603 // I made from the "-writeFile" an "-writeAlarm"
603 // mView->viewManager()->showWhatsNextView(); 604 // mView->viewManager()->showWhatsNextView();
604 mCalendar->checkAlarmForIncidence( 0, true); 605 mCalendar->checkAlarmForIncidence( 0, true);
605 //showMaximized(); 606 //showMaximized();
606 //raise(); 607 //raise();
607 hide(); 608 hide();
608 return; 609 return;
609 } 610 }
610 if ( cmsg == "-newCountdown" ) { 611 if ( cmsg == "-newCountdown" ) {
611 qDebug("newCountdown "); 612 qDebug("newCountdown ");
612 613
613 } 614 }
614 QString msg ; 615 QString msg ;
615 QString allmsg = cmsg; 616 QString allmsg = cmsg;
616 while ( allmsg.length() > 0 ) { 617 while ( allmsg.length() > 0 ) {
617 int nextC = allmsg.find( "-", 1 ); 618 int nextC = allmsg.find( "-", 1 );
618 if ( nextC == -1 ) { 619 if ( nextC == -1 ) {
619 msg = allmsg; 620 msg = allmsg;
620 allmsg = ""; 621 allmsg = "";
621 } else{ 622 } else{
622 msg = allmsg.left( nextC ); 623 msg = allmsg.left( nextC );
623 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 624 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
624 } 625 }
625 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 626 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
626 if ( msg == "-newEvent" ) { 627 if ( msg == "-newEvent" ) {
627 QTimer::singleShot( 0, mView, SLOT ( newEvent())); 628 QTimer::singleShot( 0, mView, SLOT ( newEvent()));
628 } 629 }
629 if ( msg == "-newTodo" ) { 630 if ( msg == "-newTodo" ) {
630 QTimer::singleShot( 0, mView, SLOT ( newTodo())); 631 QTimer::singleShot( 0, mView, SLOT ( newTodo()));
631 } 632 }
632 if ( msg == "-showWN" ) { 633 if ( msg == "-showWN" ) {
633 mView->viewManager()->showWhatsNextView(); 634 mView->viewManager()->showWhatsNextView();
634 } 635 }
635 if ( msg == "-showTodo" ) { 636 if ( msg == "-showTodo" ) {
636 mView->viewManager()->showTodoView(); 637 mView->viewManager()->showTodoView();
637 } 638 }
638 if ( msg == "-showList" ) { 639 if ( msg == "-showList" ) {
639 mView->viewManager()->showListView(); 640 mView->viewManager()->showListView();
640 } 641 }
641 else if ( msg == "-showDay" ) { 642 else if ( msg == "-showDay" ) {
642 mView->viewManager()->showDayView(); 643 mView->viewManager()->showDayView();
643 } 644 }
644 else if ( msg == "-showWWeek" ) { 645 else if ( msg == "-showWWeek" ) {
645 mView->viewManager()->showWorkWeekView(); 646 mView->viewManager()->showWorkWeekView();
646 } 647 }
647 else if ( msg == "-ringSync" ) { 648 else if ( msg == "-ringSync" ) {
648 QTimer::singleShot( 0, this, SLOT (startMultiSync())); 649 QTimer::singleShot( 0, this, SLOT (startMultiSync()));
649 } 650 }
650 else if ( msg == "-showWeek" ) { 651 else if ( msg == "-showWeek" ) {
651 mView->viewManager()->showWeekView(); 652 mView->viewManager()->showWeekView();
652 } 653 }
653 else if ( msg == "-showTodo" ) { 654 else if ( msg == "-showTodo" ) {
654 mView->viewManager()->showTodoView(); 655 mView->viewManager()->showTodoView();
655 } 656 }
656 else if ( msg == "-showJournal" ) { 657 else if ( msg == "-showJournal" ) {
657 mView->dateNavigator()->selectDates( 1 ); 658 mView->dateNavigator()->selectDates( 1 );
658 mView->dateNavigator()->selectToday(); 659 mView->dateNavigator()->selectToday();
659 mView->viewManager()->showJournalView(); 660 mView->viewManager()->showJournalView();
660 } 661 }
661 else if ( msg == "-showKO" ) { 662 else if ( msg == "-showKO" ) {
662 mView->viewManager()->showNextXView(); 663 mView->viewManager()->showNextXView();
663 } 664 }
664 else if ( msg == "-showWNext" ) { 665 else if ( msg == "-showWNext" ) {
665 mView->viewManager()->showWhatsNextView(); 666 mView->viewManager()->showWhatsNextView();
666 } 667 }
667 else if ( msg == "nextView()" ) { 668 else if ( msg == "nextView()" ) {
668 mView->viewManager()->showNextView(); 669 mView->viewManager()->showNextView();
669 } 670 }
670 else if ( msg == "-showNextXView" ) { 671 else if ( msg == "-showNextXView" ) {
671 mView->viewManager()->showNextXView(); 672 mView->viewManager()->showNextXView();
672 } 673 }
673 674
674 675
675 } 676 }
676 677
677 showMaximized(); 678 showMaximized();
678 raise(); 679 raise();
679} 680}
680void MainWindow::startMultiSync() 681void MainWindow::startMultiSync()
681{ 682{
682 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 683 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
683 if ( QMessageBox::information( this, i18n("KDE-Pim Sync"), 684 if ( QMessageBox::information( this, i18n("KDE-Pim Sync"),
684 question, 685 question,
685 i18n("Yes"), i18n("No"), 686 i18n("Yes"), i18n("No"),
686 0, 0 ) != 0 ) { 687 0, 0 ) != 0 ) {
687 setCaption(i18n("Aborted! Nothing synced!")); 688 setCaption(i18n("Aborted! Nothing synced!"));
688 return; 689 return;
689 } 690 }
690 mSyncManager->multiSync( false ); 691 mSyncManager->multiSync( false );
691#ifndef DESKTOP_VERSION 692#ifndef DESKTOP_VERSION
692 QCopEnvelope e("QPE/Application/kapi", "doRingSync"); 693 QCopEnvelope e("QPE/Application/kapi", "doRingSync");
693#endif 694#endif
694} 695}
695QPixmap MainWindow::loadPixmap( QString name ) 696QPixmap MainWindow::loadPixmap( QString name )
696{ 697{
697 return SmallIcon( name ); 698 return SmallIcon( name );
698 699
699} 700}
700void MainWindow::setUsesBigPixmaps ( bool b ) 701void MainWindow::setUsesBigPixmaps ( bool b )
701{ 702{
702 qDebug("KO: MainWindow::setUsesBigPixmaps %d called", b); 703 qDebug("KO: MainWindow::setUsesBigPixmaps %d called", b);
703 if ( b ) 704 if ( b )
704 qDebug("KO: BigPixmaps are not supported "); 705 qDebug("KO: BigPixmaps are not supported ");
705} 706}
706void MainWindow::initActions() 707void MainWindow::initActions()
707{ 708{
708 //KOPrefs::instance()->mShowFullMenu 709 //KOPrefs::instance()->mShowFullMenu
709 iconToolBar->clear(); 710 iconToolBar->clear();
710 KOPrefs *p = KOPrefs::instance(); 711 KOPrefs *p = KOPrefs::instance();
711 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 712 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
712 713
713 QPopupMenu *viewMenu = new QPopupMenu( this ); 714 QPopupMenu *viewMenu = new QPopupMenu( this );
714 QPopupMenu *actionMenu = new QPopupMenu( this ); 715 QPopupMenu *actionMenu = new QPopupMenu( this );
715 mCurrentItemMenu = new QPopupMenu ( this ); 716 mCurrentItemMenu = new QPopupMenu ( this );
716 QPopupMenu *nextConflictMenu = new QPopupMenu ( this ); 717 QPopupMenu *nextConflictMenu = new QPopupMenu ( this );
717 QPopupMenu *importMenu = new QPopupMenu( this ); 718 QPopupMenu *importMenu = new QPopupMenu( this );
718 QPopupMenu *importMenu_X = new QPopupMenu( this ); 719 QPopupMenu *importMenu_X = new QPopupMenu( this );
719 QPopupMenu *exportMenu_X = new QPopupMenu( this ); 720 QPopupMenu *exportMenu_X = new QPopupMenu( this );
720 QPopupMenu *beamMenu_X = new QPopupMenu( this ); 721 QPopupMenu *beamMenu_X = new QPopupMenu( this );
721 selectFilterMenu = new QPopupMenu( this ); 722 selectFilterMenu = new QPopupMenu( this );
722 selectFilterMenu->setCheckable( true ); 723 selectFilterMenu->setCheckable( true );
723 syncMenu = new QPopupMenu( this ); 724 syncMenu = new QPopupMenu( this );
724 configureAgendaMenu = new QPopupMenu( this ); 725 configureAgendaMenu = new QPopupMenu( this );
725 configureToolBarMenu = new QPopupMenu( this ); 726 configureToolBarMenu = new QPopupMenu( this );
726 QPopupMenu *helpMenu = new QPopupMenu( this ); 727 QPopupMenu *helpMenu = new QPopupMenu( this );
727 QIconSet icon; 728 QIconSet icon;
728 int pixWid = 22, pixHei = 22; 729 int pixWid = 22, pixHei = 22;
729 QString pathString = ""; 730 QString pathString = "";
730 if ( !p->mToolBarMiniIcons ) { 731 if ( !p->mToolBarMiniIcons ) {
731 if ( QApplication::desktop()->width() < 480 /*|| QApplication::desktop()->height() < 320*/) { 732 if ( QApplication::desktop()->width() < 480 /*|| QApplication::desktop()->height() < 320*/) {
732 pathString += "icons16/"; 733 pathString += "icons16/";
733 pixWid = 18; pixHei = 16; 734 pixWid = 18; pixHei = 16;
734 } 735 }
735 } else { 736 } else {
736 pathString += "iconsmini/"; 737 pathString += "iconsmini/";
737 pixWid = 18; pixHei = 16; 738 pixWid = 18; pixHei = 16;
738 } 739 }
739 740
740 if ( KOPrefs::instance()->mShowFullMenu ) { 741 if ( KOPrefs::instance()->mShowFullMenu ) {
741 menuBar1 = new KMenuBar( this );//menuBar(); 742 menuBar1 = new KMenuBar( this );//menuBar();
742 //setMenuBar( menuBar1 ); 743 //setMenuBar( menuBar1 );
743 menuBar1->show(); 744 menuBar1->show();
744 menuBar1->insertItem( i18n("File"), importMenu ); 745 menuBar1->insertItem( i18n("File"), importMenu );
745 menuBar1->insertItem( i18n("View"), viewMenu ); 746 menuBar1->insertItem( i18n("View"), viewMenu );
746 menuBar1->insertItem( i18n("Edit"), mCurrentItemMenu ); 747 menuBar1->insertItem( i18n("Edit"), mCurrentItemMenu );
747 menuBar1->insertItem( i18n("Action"), actionMenu ); 748 menuBar1->insertItem( i18n("Action"), actionMenu );
748#ifdef DESKTOP_VERSION 749#ifdef DESKTOP_VERSION
749 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 750 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
750 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 751 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
751#else 752#else
752 menuBar1->insertItem( i18n("Sync"), syncMenu ); 753 menuBar1->insertItem( i18n("Sync"), syncMenu );
753 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu ); 754 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu );
754#endif 755#endif
755 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 756 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
756 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 757 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
757 menuBar1->insertItem( i18n("Help"), helpMenu ); 758 menuBar1->insertItem( i18n("Help"), helpMenu );
758 } else { 759 } else {
759 menuBar1 = new KMenuBar( iconToolBar ); 760 menuBar1 = new KMenuBar( iconToolBar );
760 QPopupMenu *menuBar = new QPopupMenu( this ); 761 QPopupMenu *menuBar = new QPopupMenu( this );
761 icon = loadPixmap( pathString + "z_menu" ); 762 icon = loadPixmap( pathString + "z_menu" );
762 menuBar1->insertItem( icon.pixmap(), menuBar); 763 menuBar1->insertItem( icon.pixmap(), menuBar);
763 //menuBar1->insertItem( i18n("ME"), menuBar); 764 //menuBar1->insertItem( i18n("ME"), menuBar);
764 menuBar->insertItem( i18n("File"), importMenu ); 765 menuBar->insertItem( i18n("File"), importMenu );
765 menuBar->insertItem( i18n("View"), viewMenu ); 766 menuBar->insertItem( i18n("View"), viewMenu );
766 menuBar->insertItem( i18n("Edit"), mCurrentItemMenu ); 767 menuBar->insertItem( i18n("Edit"), mCurrentItemMenu );
767 menuBar->insertItem( i18n("Action"), actionMenu ); 768 menuBar->insertItem( i18n("Action"), actionMenu );
768 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 769 menuBar->insertItem( i18n("Synchronize"), syncMenu );
769 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 770 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
770 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 771 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
771 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 772 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
772 menuBar->insertItem( i18n("Help"), helpMenu ); 773 menuBar->insertItem( i18n("Help"), helpMenu );
773 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 774 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
774 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 775 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
775 connect ( menuBar, SIGNAL( aboutToHide () ), this, SLOT ( slotResetFocus() ) ); 776 connect ( menuBar, SIGNAL( aboutToHide () ), this, SLOT ( slotResetFocus() ) );
776 } 777 }
777 connect ( menuBar1, SIGNAL( lostFocus () ), this, SLOT ( slotResetFocus() ) ); 778 connect ( menuBar1, SIGNAL( lostFocus () ), this, SLOT ( slotResetFocus() ) );
778 //connect ( menuBar1, SIGNAL( lostFocus () ), this, SLOT ( slotResetFocus() ) ); 779 //connect ( menuBar1, SIGNAL( lostFocus () ), this, SLOT ( slotResetFocus() ) );
779 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 780 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
780 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); 781 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) );
781 782
782 783
783 mWeekBgColor = iconToolBar->backgroundColor(); 784 mWeekBgColor = iconToolBar->backgroundColor();
784 mWeekPixmap.resize( pixWid , pixHei ); 785 mWeekPixmap.resize( pixWid , pixHei );
785 mWeekPixmap.fill( mWeekBgColor ); 786 mWeekPixmap.fill( mWeekBgColor );
786 icon = mWeekPixmap; 787 icon = mWeekPixmap;
787 mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this ); 788 mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this );
788 if ( p-> mShowIconWeekNum ) 789 if ( p-> mShowIconWeekNum )
789 mWeekAction->addTo( iconToolBar ); 790 mWeekAction->addTo( iconToolBar );
@@ -1585,843 +1586,858 @@ void MainWindow::usertrans()
1585 1586
1586void MainWindow::storagehowto() 1587void MainWindow::storagehowto()
1587{ 1588{
1588 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); 1589 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" );
1589} 1590}
1590void MainWindow::timetrackinghowto() 1591void MainWindow::timetrackinghowto()
1591{ 1592{
1592 KApplication::showFile( "KO/Pi Timetracking HowTo", "kdepim/timetrackerhowto.txt" ); 1593 KApplication::showFile( "KO/Pi Timetracking HowTo", "kdepim/timetrackerhowto.txt" );
1593} 1594}
1594void MainWindow::kdesynchowto() 1595void MainWindow::kdesynchowto()
1595{ 1596{
1596 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 1597 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
1597} 1598}
1598void MainWindow::multisynchowto() 1599void MainWindow::multisynchowto()
1599{ 1600{
1600 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 1601 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
1601} 1602}
1602void MainWindow::synchowto() 1603void MainWindow::synchowto()
1603{ 1604{
1604 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 1605 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
1605} 1606}
1606void MainWindow::faq() 1607void MainWindow::faq()
1607{ 1608{
1608 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); 1609 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" );
1609 1610
1610} 1611}
1611void MainWindow::whatsNew() 1612void MainWindow::whatsNew()
1612{ 1613{
1613 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 1614 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
1614 1615
1615} 1616}
1616void MainWindow::licence() 1617void MainWindow::licence()
1617{ 1618{
1618 KApplication::showLicence(); 1619 KApplication::showLicence();
1619 1620
1620} 1621}
1621void MainWindow::about() 1622void MainWindow::about()
1622{ 1623{
1623 QString version; 1624 QString version;
1624#include <../version> 1625#include <../version>
1625 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1626 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1626 i18n("KOrganizer/Platform-independent\n") + 1627 i18n("KOrganizer/Platform-independent\n") +
1627 "(KO/Pi) " + version + " - " + 1628 "(KO/Pi) " + version + " - " +
1628 1629
1629#ifdef DESKTOP_VERSION 1630#ifdef DESKTOP_VERSION
1630 i18n("Desktop Edition\n") + 1631 i18n("Desktop Edition\n") +
1631#else 1632#else
1632 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") + 1633 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") +
1633#endif 1634#endif
1634 i18n("(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.info --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!") ); 1635 i18n("(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.info --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!") );
1635} 1636}
1636void MainWindow::keyBindings() 1637void MainWindow::keyBindings()
1637{ 1638{
1638 QString cap = i18n("KO/Pi Keys + Colors"); 1639 QString cap = i18n("KO/Pi Keys + Colors");
1639 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1640 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1640 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1641 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1641 i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") + 1642 i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") +
1642 i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") + 1643 i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") +
1643 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1644 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1644 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1645 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1645 i18n("<p><b>R</b>: Toggle Resource View |<b>F</b>: Edit filter </p>\n")+ 1646 i18n("<p><b>R</b>: Toggle Resource View |<b>F</b>: Edit filter </p>\n")+
1646 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1647 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1647 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1648 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1648 i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+ 1649 i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+
1649 i18n("<p><b>Q</b>: Show next date with conflicting events\n ")+ 1650 i18n("<p><b>Q</b>: Show next date with conflicting events\n ")+
1650 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1651 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1651 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1652 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1652 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1653 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1653 i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+ 1654 i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+
1654 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1655 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1655 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1656 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1656 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X+ctrl</b>: Toggle datenavigator</p>\n")+ 1657 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X+ctrl</b>: Toggle datenavigator</p>\n")+
1657 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1658 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1658 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1659 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1659 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1660 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1660 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1661 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1661 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1662 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1662 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1663 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1663 i18n("<p><h3>In agenda view:</h3></p>\n") + 1664 i18n("<p><h3>In agenda view:</h3></p>\n") +
1664 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1665 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1665 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1666 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1666 i18n("<p><h3>In todo view:</h3></p>\n") + 1667 i18n("<p><h3>In todo view:</h3></p>\n") +
1667 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ 1668 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+
1668 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ 1669 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+
1669 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ 1670 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+
1670 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1671 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1671 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1672 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1672 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1673 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1673 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1674 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1674 i18n("<p><h3>In list view:</h3></p>\n") + 1675 i18n("<p><h3>In list view:</h3></p>\n") +
1675 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1676 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1676 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1677 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1677 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1678 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1678 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1679 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1679 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1680 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1680 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1681 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1681 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1682 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1682 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1683 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1683 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1684 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1684 i18n("<p><b>E</b>: Edit item</p>\n") + 1685 i18n("<p><b>E</b>: Edit item</p>\n") +
1685 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1686 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1686 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1687 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1687 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1688 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1688 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1689 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1689 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1690 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1690 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1691 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1691 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1692 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1692 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1693 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1693 i18n("<p><b>White</b>: Item readonly</p>\n"); 1694 i18n("<p><b>White</b>: Item readonly</p>\n");
1694 displayText( text, cap); 1695 displayText( text, cap);
1695} 1696}
1696void MainWindow::aboutAutoSaving() 1697void MainWindow::aboutAutoSaving()
1697{ 1698{
1698 QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"); 1699 QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n");
1699 1700
1700 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); 1701 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text);
1701 1702
1702} 1703}
1703void MainWindow::aboutKnownBugs() 1704void MainWindow::aboutKnownBugs()
1704{ 1705{
1705 QMessageBox* msg; 1706 QMessageBox* msg;
1706 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1707 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1707 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ 1708 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+
1708 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1709 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1709 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") + 1710 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") +
1710 i18n("\nor report them in the bugtracker on\n") + 1711 i18n("\nor report them in the bugtracker on\n") +
1711 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1712 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1712 QMessageBox::NoIcon, 1713 QMessageBox::NoIcon,
1713 QMessageBox::Ok, 1714 QMessageBox::Ok,
1714 QMessageBox::NoButton, 1715 QMessageBox::NoButton,
1715 QMessageBox::NoButton); 1716 QMessageBox::NoButton);
1716 msg->exec(); 1717 msg->exec();
1717 delete msg; 1718 delete msg;
1718 1719
1719} 1720}
1720 1721
1721QString MainWindow::defaultFileName() 1722QString MainWindow::defaultFileName()
1722{ 1723{
1723 return QDir::convertSeparators( locateLocal( "data", "korganizer/mycalendar.ics" ) ); 1724 return QDir::convertSeparators( locateLocal( "data", "korganizer/mycalendar.ics" ) );
1724} 1725}
1725QString MainWindow::syncFileName() 1726QString MainWindow::syncFileName()
1726{ 1727{
1727#ifdef DESKTOP_VERSION 1728#ifdef DESKTOP_VERSION
1728 return QDir::convertSeparators( locateLocal( "tmp", "synccalendar.ics" ) ); 1729 return QDir::convertSeparators( locateLocal( "tmp", "synccalendar.ics" ) );
1729#else 1730#else
1730 return QString( "/tmp/synccalendar.ics" ); 1731 return QString( "/tmp/synccalendar.ics" );
1731#endif 1732#endif
1732} 1733}
1733#include "koglobals.h" 1734#include "koglobals.h"
1734#include <kcalendarsystem.h> 1735#include <kcalendarsystem.h>
1735void MainWindow::updateWeek(QDate seda) 1736void MainWindow::updateWeek(QDate seda)
1736{ 1737{
1737 int weekNum = KGlobal::locale()->weekNum ( seda ); 1738 int weekNum = KGlobal::locale()->weekNum ( seda );
1738 mWeekPixmap.fill( mWeekBgColor ); 1739 mWeekPixmap.fill( mWeekBgColor );
1739 QPainter p ( &mWeekPixmap ); 1740 QPainter p ( &mWeekPixmap );
1740 p.setFont( mWeekFont ); 1741 p.setFont( mWeekFont );
1741 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); 1742 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) );
1742 p.end(); 1743 p.end();
1743 QIconSet icon3 ( mWeekPixmap ); 1744 QIconSet icon3 ( mWeekPixmap );
1744 mWeekAction->setIconSet ( icon3 ); 1745 mWeekAction->setIconSet ( icon3 );
1745 1746
1746} 1747}
1747void MainWindow::updateWeekNum(const DateList &selectedDates) 1748void MainWindow::updateWeekNum(const DateList &selectedDates)
1748{ 1749{
1749 updateWeek( selectedDates.first() ); 1750 updateWeek( selectedDates.first() );
1750} 1751}
1751void MainWindow::processIncidenceSelection( Incidence *incidence ) 1752void MainWindow::processIncidenceSelection( Incidence *incidence )
1752{ 1753{
1753 if ( !incidence ) { 1754 if ( !incidence ) {
1754 mShowAction->setMenuText( i18n("Show") ); 1755 mShowAction->setMenuText( i18n("Show") );
1755 enableIncidenceActions( false ); 1756 enableIncidenceActions( false );
1756 mNewSubTodoAction->setEnabled( false ); 1757 mNewSubTodoAction->setEnabled( false );
1757 setCaptionToDates(); 1758 setCaptionToDates();
1758 return; 1759 return;
1759 } 1760 }
1760 QString startString = ""; 1761 QString startString = "";
1761 if ( incidence->typeID() != todoID ) { 1762 if ( incidence->typeID() != todoID ) {
1762 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1763 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1763 if ( incidence->doesFloat() ) { 1764 if ( incidence->doesFloat() ) {
1764 startString += ": "+incidence->dtStartDateStr( true ); 1765 startString += ": "+incidence->dtStartDateStr( true );
1765 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1766 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1766 } else { 1767 } else {
1767 startString = ": "+incidence->dtStartStr(true); 1768 startString = ": "+incidence->dtStartStr(true);
1768 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1769 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1769 } 1770 }
1770 } else { 1771 } else {
1771 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1772 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1772 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1773 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1773 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1774 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1774 if ( incidence->isBirthday() || incidence->isAnniversary() ) { 1775 if ( incidence->isBirthday() || incidence->isAnniversary() ) {
1775 bool ok; 1776 bool ok;
1776 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); 1777 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok );
1777 if ( ok ) { 1778 if ( ok ) {
1778 int years = noc.date().year() - incidence->dtStart().date().year(); 1779 int years = noc.date().year() - incidence->dtStart().date().year();
1779 startString += i18n(" (%1 y.)"). arg( years ); 1780 startString += i18n(" (%1 y.)"). arg( years );
1780 } 1781 }
1781 } 1782 }
1782 else 1783 else
1783 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1784 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1784 } 1785 }
1785 } 1786 }
1786 else { 1787 else {
1787 if ( (( KCal::Todo*)incidence)->percentComplete() == 100 ) 1788 if ( (( KCal::Todo*)incidence)->percentComplete() == 100 )
1788 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+i18n("completed on %1").arg( (( KCal::Todo*)incidence)->completedStr(true) ); 1789 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+i18n("completed on %1").arg( (( KCal::Todo*)incidence)->completedStr(true) );
1789 else 1790 else
1790 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1791 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1791 } 1792 }
1792 if ( !incidence->location().isEmpty() ) 1793 if ( !incidence->location().isEmpty() )
1793 startString += " (" +incidence->location()+")"; 1794 startString += " (" +incidence->location()+")";
1794 setCaption( incidence->summary()+startString); 1795 setCaption( incidence->summary()+startString);
1795 enableIncidenceActions( true ); 1796 enableIncidenceActions( true );
1796 if ( incidence->typeID() == eventID ) { 1797 if ( incidence->typeID() == eventID ) {
1797 mShowAction->setMenuText( i18n("Show Event") ); 1798 mShowAction->setMenuText( i18n("Show Event") );
1798 mNewSubTodoAction->setEnabled( false ); 1799 mNewSubTodoAction->setEnabled( false );
1799 } else if ( incidence->typeID() == todoID ) { 1800 } else if ( incidence->typeID() == todoID ) {
1800 mShowAction->setMenuText( i18n("Show Todo") ); 1801 mShowAction->setMenuText( i18n("Show Todo") );
1801 mNewSubTodoAction->setEnabled( true ); 1802 mNewSubTodoAction->setEnabled( true );
1802 } else { 1803 } else {
1803 mShowAction->setMenuText( i18n("Show") ); 1804 mShowAction->setMenuText( i18n("Show") );
1804 mNewSubTodoAction->setEnabled( false ); 1805 mNewSubTodoAction->setEnabled( false );
1805 } 1806 }
1806#ifdef DESKTOP_VERSION 1807#ifdef DESKTOP_VERSION
1807 static QPixmap jP = SmallIcon( "journal" ); 1808 static QPixmap jP = SmallIcon( "journal" );
1808 static QPixmap eP = SmallIcon( "newevent" ); 1809 static QPixmap eP = SmallIcon( "newevent" );
1809 static QPixmap tP = SmallIcon( "newtodo" ); 1810 static QPixmap tP = SmallIcon( "newtodo" );
1810 QIconSet icon; 1811 QIconSet icon;
1811 if ( incidence->typeID() == todoID ) 1812 if ( incidence->typeID() == todoID )
1812 icon = QIconSet ( tP ); 1813 icon = QIconSet ( tP );
1813 else if ( incidence->typeID() == eventID ) 1814 else if ( incidence->typeID() == eventID )
1814 icon = QIconSet ( eP ); 1815 icon = QIconSet ( eP );
1815 else if ( incidence->typeID() == journalID ) 1816 else if ( incidence->typeID() == journalID )
1816 icon = QIconSet ( jP ); 1817 icon = QIconSet ( jP );
1817 mPrintSelAction->setIconSet ( icon ); 1818 mPrintSelAction->setIconSet ( icon );
1818#endif 1819#endif
1819} 1820}
1820 1821
1821void MainWindow::enableIncidenceActions( bool enabled ) 1822void MainWindow::enableIncidenceActions( bool enabled )
1822{ 1823{
1823 mShowAction->setEnabled( enabled ); 1824 mShowAction->setEnabled( enabled );
1824 mEditAction->setEnabled( enabled ); 1825 mEditAction->setEnabled( enabled );
1825 mDeleteAction->setEnabled( enabled ); 1826 mDeleteAction->setEnabled( enabled );
1826 1827
1827 mCloneAction->setEnabled( enabled ); 1828 mCloneAction->setEnabled( enabled );
1828 mMoveAction->setEnabled( enabled ); 1829 mMoveAction->setEnabled( enabled );
1829#ifndef DESKTOP_VERSION 1830#ifndef DESKTOP_VERSION
1830 mBeamAction->setEnabled( enabled ); 1831 mBeamAction->setEnabled( enabled );
1831#else 1832#else
1832 mPrintSelAction->setEnabled( enabled ); 1833 mPrintSelAction->setEnabled( enabled );
1833#endif 1834#endif
1834 mCancelAction->setEnabled( enabled ); 1835 mCancelAction->setEnabled( enabled );
1835} 1836}
1836 1837
1837void MainWindow::importOL() 1838void MainWindow::importOL()
1838{ 1839{
1839#ifdef _OL_IMPORT_ 1840#ifdef _OL_IMPORT_
1840 mView->clearAllViews(); 1841 mView->clearAllViews();
1841 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1842 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1842 id->exec(); 1843 id->exec();
1843 delete id; 1844 delete id;
1844 mView->calendar()->checkAlarmForIncidence( 0, true ); 1845 mView->calendar()->checkAlarmForIncidence( 0, true );
1845 mView->updateView(); 1846 mView->updateView();
1846#endif 1847#endif
1847} 1848}
1848void MainWindow::importBday() 1849void MainWindow::importBday()
1849{ 1850{
1850 int result = QMessageBox::warning( this, i18n("KO/Pi import information!"), 1851 int result = QMessageBox::warning( this, i18n("KO/Pi import information!"),
1851 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1852 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1852 i18n("Import!"), i18n("Cancel"), 0, 1853 i18n("Import!"), i18n("Cancel"), 0,
1853 0, 1 ); 1854 0, 1 );
1854 if ( result == 0 ) { 1855 if ( result == 0 ) {
1855 mView->importBday(); 1856 mView->importBday();
1856 1857
1857 } 1858 }
1858 1859
1859 1860
1860} 1861}
1861void MainWindow::importQtopia() 1862void MainWindow::importQtopia()
1862{ 1863{
1863 //#ifndef DESKTOP_VERSION 1864 //#ifndef DESKTOP_VERSION
1864 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"); 1865 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");
1865#ifdef DESKTOP_VERSION 1866#ifdef DESKTOP_VERSION
1866 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"); 1867 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");
1867#endif 1868#endif
1868 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, 1869 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess,
1869 i18n("Import!"), i18n("Cancel"), 0, 1870 i18n("Import!"), i18n("Cancel"), 0,
1870 0, 1 ); 1871 0, 1 );
1871 if ( result == 0 ) { 1872 if ( result == 0 ) {
1872#ifndef DESKTOP_VERSION 1873#ifndef DESKTOP_VERSION
1873 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1874 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1874 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1875 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1875 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1876 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1876#else 1877#else
1877 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; 1878 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml";
1878 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; 1879 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml";
1879 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; 1880 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml";
1880#endif 1881#endif
1881 mView->importQtopia( categories, datebook, todolist ); 1882 mView->importQtopia( categories, datebook, todolist );
1882 } 1883 }
1883 mView->calendar()->reInitAlarmSettings(); 1884 mView->calendar()->reInitAlarmSettings();
1884#if 0 1885#if 0
1885 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1886 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1886 i18n("Not supported \non desktop!\n"), 1887 i18n("Not supported \non desktop!\n"),
1887 i18n("Ok"), i18n("Cancel"), 0, 1888 i18n("Ok"), i18n("Cancel"), 0,
1888 0, 1 ); 1889 0, 1 );
1889 1890
1890#endif 1891#endif
1891} 1892}
1892 1893
1893void MainWindow::saveOnClose() 1894void MainWindow::saveOnClose()
1894{ 1895{
1895 KOPrefs *p = KOPrefs::instance(); 1896 KOPrefs *p = KOPrefs::instance();
1896 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1897 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1897 p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal ); 1898 p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal );
1898 p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal ); 1899 p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal );
1899 if ( filterToolBar ) { 1900 if ( filterToolBar ) {
1900 p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal ); 1901 p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal );
1901 } 1902 }
1902#ifdef DESKTOP_VERSION 1903#ifdef DESKTOP_VERSION
1903 1904
1904 QPoint myP; 1905 QPoint myP;
1905 myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) ); 1906 myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) );
1906 if ( p->mToolBarHor ) 1907 if ( p->mToolBarHor )
1907 p->mToolBarUp = myP.y() > height()/2; 1908 p->mToolBarUp = myP.y() > height()/2;
1908 else 1909 else
1909 p->mToolBarUp = myP.x() > width()/2; 1910 p->mToolBarUp = myP.x() > width()/2;
1910 myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) ); 1911 myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) );
1911 if ( p->mToolBarHorV ) 1912 if ( p->mToolBarHorV )
1912 p->mToolBarUpV = myP.y() > height()/2; 1913 p->mToolBarUpV = myP.y() > height()/2;
1913 else 1914 else
1914 p->mToolBarUpV = myP.x() > width()/2 ; 1915 p->mToolBarUpV = myP.x() > width()/2 ;
1915 myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) ); 1916 myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) );
1916 if ( p->mToolBarHorN ) 1917 if ( p->mToolBarHorN )
1917 p->mToolBarUpN = myP.y() > height()/2; 1918 p->mToolBarUpN = myP.y() > height()/2;
1918 else 1919 else
1919 p->mToolBarUpN = myP.x() > width()/2 ; 1920 p->mToolBarUpN = myP.x() > width()/2 ;
1920 if ( filterToolBar ) { 1921 if ( filterToolBar ) {
1921 myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) ); 1922 myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) );
1922 if ( p->mToolBarHorF ) 1923 if ( p->mToolBarHorF )
1923 p->mToolBarUpF = myP.y() > height()/2; 1924 p->mToolBarUpF = myP.y() > height()/2;
1924 else 1925 else
1925 p->mToolBarUpF = myP.x() > width()/2 ; 1926 p->mToolBarUpF = myP.x() > width()/2 ;
1926 } 1927 }
1927#else 1928#else
1928 if ( p->mToolBarHor ) 1929 if ( p->mToolBarHor )
1929 p->mToolBarUp = iconToolBar->y() > height()/2; 1930 p->mToolBarUp = iconToolBar->y() > height()/2;
1930 else 1931 else
1931 p->mToolBarUp = iconToolBar->x() > width()/2; 1932 p->mToolBarUp = iconToolBar->x() > width()/2;
1932 if ( p->mToolBarHorV ) 1933 if ( p->mToolBarHorV )
1933 p->mToolBarUpV = viewToolBar->y() > height()/2; 1934 p->mToolBarUpV = viewToolBar->y() > height()/2;
1934 else 1935 else
1935 p->mToolBarUpV = viewToolBar->x() > width()/2 ; 1936 p->mToolBarUpV = viewToolBar->x() > width()/2 ;
1936 1937
1937 if ( p->mToolBarHorN ) 1938 if ( p->mToolBarHorN )
1938 p->mToolBarUpN = navigatorToolBar->y() > height()/2; 1939 p->mToolBarUpN = navigatorToolBar->y() > height()/2;
1939 else 1940 else
1940 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; 1941 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ;
1941 if ( filterToolBar ) { 1942 if ( filterToolBar ) {
1942 if ( p->mToolBarHorF ) 1943 if ( p->mToolBarHorF )
1943 p->mToolBarUpF = filterToolBar->y() > height()/2; 1944 p->mToolBarUpF = filterToolBar->y() > height()/2;
1944 else 1945 else
1945 p->mToolBarUpF = filterToolBar->x() > width()/2 ; 1946 p->mToolBarUpF = filterToolBar->x() > width()/2 ;
1946 } 1947 }
1947#endif 1948#endif
1948 save(); 1949 save();
1949 mView->writeSettings(); 1950 mView->writeSettings();
1950 mView->checkSuspendAlarm(); 1951 mView->checkSuspendAlarm();
1951} 1952}
1952void MainWindow::slotModifiedChanged( bool ) 1953void MainWindow::slotModifiedChanged( bool )
1953{ 1954{
1954 if ( mBlockAtStartup ) 1955 if ( mBlockAtStartup )
1955 return; 1956 return;
1956 1957
1957 int msec; 1958 int msec;
1958 if ( mCalendarModifiedFlag ) { 1959 if ( mCalendarModifiedFlag ) {
1959 //qDebug(" MainWindow timer is running "); 1960 //qDebug(" MainWindow timer is running ");
1960 return; 1961 return;
1961 } 1962 }
1962 // we store the changes after 1 minute, 1963 // we store the changes after 1 minute,
1963 // and for safety reasons after 10 minutes again 1964 // and for safety reasons after 10 minutes again
1964 if ( !mSyncManager->blockSave() ) 1965 if ( !mSyncManager->blockSave() )
1965 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1966 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1966 else 1967 else
1967 msec = 1000 * 600; 1968 msec = 1000 * 600;
1968 mSaveTimer.start( msec, true ); // 1 minute 1969 mSaveTimer.start( msec, true ); // 1 minute
1970 mSaveTime.restart();
1971 mSaveDelay = msec/1000;
1969 qDebug("KO: Saving File in %d secs!", msec/1000); 1972 qDebug("KO: Saving File in %d secs!", msec/1000);
1970 mCalendarModifiedFlag = true; 1973 mCalendarModifiedFlag = true;
1971} 1974}
1972void MainWindow::saveStopTimer() 1975void MainWindow::saveStopTimer()
1973{ 1976{
1974 mSaveTimer.stop(); 1977 mSaveTimer.stop();
1975} 1978}
1976void MainWindow::backupAllFiles() 1979void MainWindow::backupAllFiles()
1977{ 1980{
1978 QDate reference ( 2000,1,1); 1981 QDate reference ( 2000,1,1);
1979 int daysTo = reference.daysTo ( QDate::currentDate() ); 1982 int daysTo = reference.daysTo ( QDate::currentDate() );
1980 setCaption(i18n("Creating backup ... please wait ..." )); 1983 setCaption(i18n("Creating backup ... please wait ..." ));
1981 qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); 1984 qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate);
1982 // we need the file path, the backup dir and the number of bups as param 1985 // we need the file path, the backup dir and the number of bups as param
1983 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; 1986 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir;
1984 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) 1987 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir)
1985 bupDir = KGlobalSettings::backupDataDir(); 1988 bupDir = KGlobalSettings::backupDataDir();
1986 int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); 1989 int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );
1987 if ( retval == 0 ) { 1990 if ( retval == 0 ) {
1988 setCaption(i18n("Backup cancelled" )); 1991 setCaption(i18n("Backup cancelled" ));
1989 qDebug("KO: Backup cancelled. Will try again tomorrow "); 1992 qDebug("KO: Backup cancelled. Will try again tomorrow ");
1990 // retval == 0 : backup skipped for today, try again tomorrow 1993 // retval == 0 : backup skipped for today, try again tomorrow
1991 KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; 1994 KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1;
1992 } else if ( retval == 1 ){ 1995 } else if ( retval == 1 ){
1993 qDebug("KO: Backup created."); 1996 qDebug("KO: Backup created.");
1994 // backup ok 1997 // backup ok
1995 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 1998 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1996 KopiCalendarFile * cal = calendars.first(); 1999 KopiCalendarFile * cal = calendars.first();
1997 cal = calendars.next(); 2000 cal = calendars.next();
1998 while ( cal ) { 2001 while ( cal ) {
1999 if ( !cal->mErrorOnLoad ) { 2002 if ( !cal->mErrorOnLoad ) {
2000 KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); 2003 KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );
2001 } 2004 }
2002 cal = calendars.next(); 2005 cal = calendars.next();
2003 } 2006 }
2004 KOPrefs::instance()->mLastBackupDate = daysTo; 2007 KOPrefs::instance()->mLastBackupDate = daysTo;
2005 setCaption(i18n("Backup succesfully finished" )); 2008 setCaption(i18n("Backup succesfully finished" ));
2006 } else if ( retval == 2 ){ 2009 } else if ( retval == 2 ){
2007 setCaption(i18n("Backup globally disabled" )); 2010 setCaption(i18n("Backup globally disabled" ));
2008 qDebug("KO: Backup globally cancelled."); 2011 qDebug("KO: Backup globally cancelled.");
2009 // backup globally cancelled 2012 // backup globally cancelled
2010 KPimGlobalPrefs::instance()->mBackupEnabled = false; 2013 KPimGlobalPrefs::instance()->mBackupEnabled = false;
2011 } 2014 }
2012 // retval == 3: do nothing, try again later 2015 // retval == 3: do nothing, try again later
2013} 2016}
2014void MainWindow::save() 2017void MainWindow::save()
2015{ 2018{
2019 if ( mSaveDelay ) {
2020 if ( mSaveDelay + 60 < mSaveTime.elapsed()/1000 ) {
2021 qDebug("KO: Save delay %d. Elapsed save time %d ", mSaveDelay, mSaveTime.elapsed()/1000 );
2022 qDebug("KO: Restarting save timer");
2023 int msec = 10000;
2024 mSaveTimer.start( msec, true ); // 1 minute
2025 mSaveTime.restart();
2026 mSaveDelay = msec/1000;
2027 return;
2028 }
2029 }
2016 2030
2017 if ( mView->viewManager()->journalView() ) 2031 if ( mView->viewManager()->journalView() )
2018 mView->viewManager()->journalView()->checkModified(); 2032 mView->viewManager()->journalView()->checkModified();
2019 if ( !mCalendarModifiedFlag ) { 2033 if ( !mCalendarModifiedFlag ) {
2020 qDebug("KO: Calendar not modified. Nothing saved."); 2034 qDebug("KO: Calendar not modified. Nothing saved.");
2021 return; 2035 return;
2022 } 2036 }
2023 if ( mSyncManager->blockSave() ) { 2037 if ( mSyncManager->blockSave() ) {
2024 slotModifiedChanged( true ); 2038 slotModifiedChanged( true );
2025 return; 2039 return;
2026 } 2040 }
2041 mSaveDelay = 0;
2027 mSyncManager->setBlockSave(true); 2042 mSyncManager->setBlockSave(true);
2028 if ( mView->checkAllFileVersions() ) { 2043 if ( mView->checkAllFileVersions() ) {
2029 if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ 2044 if ( KPimGlobalPrefs::instance()->mBackupEnabled ){
2030 QDate reference ( 2000,1,1); 2045 QDate reference ( 2000,1,1);
2031 int daysTo = reference.daysTo ( QDate::currentDate() ); 2046 int daysTo = reference.daysTo ( QDate::currentDate() );
2032 if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { 2047 if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) {
2033 backupAllFiles(); 2048 backupAllFiles();
2034 } 2049 }
2035 ; // KPimGlobalPrefs::instance()->mLastBackupDate 2050 ; // KPimGlobalPrefs::instance()->mLastBackupDate
2036 } 2051 }
2037 QTime neededSaveTime = QDateTime::currentDateTime().time(); 2052 QTime neededSaveTime;
2053 neededSaveTime.start();
2038 if ( !isMinimized () ) 2054 if ( !isMinimized () )
2039 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 2055 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
2040 qDebug("KO: Start saving data to file!"); 2056 qDebug("KO: Start saving data to file!");
2041 if ( mView->saveCalendars() ) 2057 if ( mView->saveCalendars() )
2042 mCalendarModifiedFlag = false; 2058 mCalendarModifiedFlag = false;
2043 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 2059 int msNeeded = neededSaveTime.elapsed();
2044 qDebug("KO: Needed %d ms for saving.",msNeeded ); 2060 qDebug("KO: Needed %d ms for saving.",msNeeded );
2045 QString savemes; 2061 QString savemes;
2046 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 2062 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
2047 if ( !isMinimized () ) 2063 if ( !isMinimized () )
2048 setCaption(savemes); 2064 setCaption(savemes);
2049 else 2065 else
2050 qDebug(savemes); 2066 qDebug(savemes);
2051 } else { 2067 } else {
2052 setCaption(i18n("Saving cancelled!")); 2068 setCaption(i18n("Saving cancelled!"));
2053 mCalendarModifiedFlag = false; 2069 mCalendarModifiedFlag = false;
2054 slotModifiedChanged( true ); 2070 slotModifiedChanged( true );
2055 } 2071 }
2056 mSyncManager->setBlockSave( false ); 2072 mSyncManager->setBlockSave( false );
2057} 2073}
2058 2074
2059void MainWindow::keyReleaseEvent ( QKeyEvent * e) 2075void MainWindow::keyReleaseEvent ( QKeyEvent * e)
2060{ 2076{
2061 if ( !e->isAutoRepeat() ) { 2077 if ( !e->isAutoRepeat() ) {
2062 mFlagKeyPressed = false; 2078 mFlagKeyPressed = false;
2063 } 2079 }
2064} 2080}
2065void MainWindow::keyPressEvent ( QKeyEvent * e ) 2081void MainWindow::keyPressEvent ( QKeyEvent * e )
2066{ 2082{
2067 qApp->processEvents(); 2083 qApp->processEvents();
2068 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 2084 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
2069 e->ignore(); 2085 e->ignore();
2070 // qDebug(" ignore %d",e->isAutoRepeat() ); 2086 // qDebug(" ignore %d",e->isAutoRepeat() );
2071 return; 2087 return;
2072 } 2088 }
2073 if (! e->isAutoRepeat() ) 2089 if (! e->isAutoRepeat() )
2074 mFlagKeyPressed = true; 2090 mFlagKeyPressed = true;
2075 KOPrefs *p = KOPrefs::instance(); 2091 KOPrefs *p = KOPrefs::instance();
2076 bool showSelectedDates = false; 2092 bool showSelectedDates = false;
2077 int size; 2093 int size;
2078 int pro = 0; 2094 int pro = 0;
2079 //qDebug("MainWindow::keyPressEvent "); 2095 //qDebug("MainWindow::keyPressEvent ");
2080 switch ( e->key() ) { 2096 switch ( e->key() ) {
2081 case Qt::Key_Right: 2097 case Qt::Key_Right:
2082 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 2098 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
2083 mView->goNextMonth(); 2099 mView->goNextMonth();
2084 else 2100 else
2085 mView->goNext(); 2101 mView->goNext();
2086 showSelectedDates = true; 2102 showSelectedDates = true;
2087 break; 2103 break;
2088 case Qt::Key_Left: 2104 case Qt::Key_Left:
2089 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 2105 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
2090 mView->goPreviousMonth(); 2106 mView->goPreviousMonth();
2091 else 2107 else
2092 mView->goPrevious(); 2108 mView->goPrevious();
2093 showSelectedDates = true; 2109 showSelectedDates = true;
2094 break; 2110 break;
2095 case Qt::Key_Down: 2111 case Qt::Key_Down:
2096 mView->viewManager()->agendaView()->scrollOneHourDown(); 2112 mView->viewManager()->agendaView()->scrollOneHourDown();
2097 break; 2113 break;
2098 case Qt::Key_Up: 2114 case Qt::Key_Up:
2099 mView->viewManager()->agendaView()->scrollOneHourUp(); 2115 mView->viewManager()->agendaView()->scrollOneHourUp();
2100 break; 2116 break;
2101 case Qt::Key_K: 2117 case Qt::Key_K:
2102 mView->viewManager()->showMonthViewWeek(); 2118 mView->viewManager()->showMonthViewWeek();
2103 break; 2119 break;
2104 case Qt::Key_I: 2120 case Qt::Key_I:
2105 mView->showIncidence(); 2121 mView->showIncidence();
2106 break; 2122 break;
2107 case Qt::Key_Delete: 2123 case Qt::Key_Delete:
2108 case Qt::Key_Backspace: 2124 case Qt::Key_Backspace:
2109 mView->deleteIncidence(); 2125 mView->deleteIncidence();
2110 break; 2126 break;
2111 case Qt::Key_D: 2127 case Qt::Key_D:
2112 mView->viewManager()->showDayView(); 2128 mView->viewManager()->showDayView();
2113 showSelectedDates = true; 2129 showSelectedDates = true;
2114 break; 2130 break;
2115 case Qt::Key_O: 2131 case Qt::Key_O:
2116 mView->toggleFilerEnabled( ); 2132 mView->toggleFilerEnabled( );
2117 break; 2133 break;
2118 case Qt::Key_0: 2134 case Qt::Key_0:
2119 case Qt::Key_1: 2135 case Qt::Key_1:
2120 case Qt::Key_2: 2136 case Qt::Key_2:
2121 case Qt::Key_3: 2137 case Qt::Key_3:
2122 case Qt::Key_4: 2138 case Qt::Key_4:
2123 case Qt::Key_5: 2139 case Qt::Key_5:
2124 case Qt::Key_6: 2140 case Qt::Key_6:
2125 case Qt::Key_7: 2141 case Qt::Key_7:
2126 case Qt::Key_8: 2142 case Qt::Key_8:
2127 case Qt::Key_9: 2143 case Qt::Key_9:
2128 pro = e->key()-48; 2144 pro = e->key()-48;
2129 if ( pro == 0 ) 2145 if ( pro == 0 )
2130 pro = 10; 2146 pro = 10;
2131 if ( e->state() == Qt::ControlButton) 2147 if ( e->state() == Qt::ControlButton)
2132 pro += 10; 2148 pro += 10;
2133 break; 2149 break;
2134 case Qt::Key_M: 2150 case Qt::Key_M:
2135 mView->viewManager()->showMonthView(); 2151 mView->viewManager()->showMonthView();
2136 showSelectedDates = true; 2152 showSelectedDates = true;
2137 break; 2153 break;
2138 case Qt::Key_Insert: 2154 case Qt::Key_Insert:
2139 mView->newEvent(); 2155 mView->newEvent();
2140 break; 2156 break;
2141 case Qt::Key_S : 2157 case Qt::Key_S :
2142 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 2158 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
2143 mView->newSubTodo(); 2159 mView->newSubTodo();
2144 else 2160 else
2145 mView->dialogManager()->showSearchDialog(); 2161 mView->dialogManager()->showSearchDialog();
2146 break; 2162 break;
2147 case Qt::Key_Y : 2163 case Qt::Key_Y :
2148 case Qt::Key_Z : 2164 case Qt::Key_Z :
2149 mView->viewManager()->showWorkWeekView(); 2165 mView->viewManager()->showWorkWeekView();
2150 showSelectedDates = true; 2166 showSelectedDates = true;
2151 break; 2167 break;
2152 case Qt::Key_U : 2168 case Qt::Key_U :
2153 mView->viewManager()->showWeekView(); 2169 mView->viewManager()->showWeekView();
2154 showSelectedDates = true; 2170 showSelectedDates = true;
2155 break; 2171 break;
2156 case Qt::Key_H : 2172 case Qt::Key_H :
2157 keyBindings(); 2173 keyBindings();
2158 break; 2174 break;
2159 case Qt::Key_W: 2175 case Qt::Key_W:
2160 mView->viewManager()->showWhatsNextView(); 2176 mView->viewManager()->showWhatsNextView();
2161 break; 2177 break;
2162 case Qt::Key_L: 2178 case Qt::Key_L:
2163 mView->viewManager()->showListView(); 2179 mView->viewManager()->showListView();
2164 break; 2180 break;
2165 case Qt::Key_N: 2181 case Qt::Key_N:
2166 mView->viewManager()->showNextView(); 2182 mView->viewManager()->showNextView();
2167 break; 2183 break;
2168 case Qt::Key_V: 2184 case Qt::Key_V:
2169 mView->viewManager()->showTodoView(); 2185 mView->viewManager()->showTodoView();
2170 break; 2186 break;
2171 case Qt::Key_C: 2187 case Qt::Key_C:
2172 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 2188 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
2173 break; 2189 break;
2174 case Qt::Key_P: 2190 case Qt::Key_P:
2175 mView->showDatePicker( ); 2191 mView->showDatePicker( );
2176 break; 2192 break;
2177 case Qt::Key_F: 2193 case Qt::Key_F:
2178 mView->editFilters(); 2194 mView->editFilters();
2179 break; 2195 break;
2180 case Qt::Key_R: 2196 case Qt::Key_R:
2181 mView->toggleFilter(); 2197 mView->toggleFilter();
2182 break; 2198 break;
2183 case Qt::Key_X: 2199 case Qt::Key_X:
2184 if ( e->state() == Qt::ControlButton ) 2200 if ( e->state() == Qt::ControlButton )
2185 mView->toggleDateNavigatorWidget(); 2201 mView->toggleDateNavigatorWidget();
2186 else { 2202 else {
2187 mView->viewManager()->showNextXView(); 2203 mView->viewManager()->showNextXView();
2188 showSelectedDates = true; 2204 showSelectedDates = true;
2189 } 2205 }
2190 break; 2206 break;
2191 case Qt::Key_Space: 2207 case Qt::Key_Space:
2192 mView->toggleExpand(); 2208 mView->toggleExpand();
2193 break; 2209 break;
2194 case Qt::Key_A: 2210 case Qt::Key_A:
2195 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) 2211 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton )
2196 mView->showNextAlarms(); 2212 mView->showNextAlarms();
2197 else 2213 else
2198 mView->toggleAllDaySize(); 2214 mView->toggleAllDaySize();
2199 break; 2215 break;
2200 case Qt::Key_T: 2216 case Qt::Key_T:
2201 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 2217 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
2202 mView->newTodo(); 2218 mView->newTodo();
2203 else { 2219 else {
2204 mView->goToday(); 2220 mView->goToday();
2205 showSelectedDates = true; 2221 showSelectedDates = true;
2206 } 2222 }
2207 break; 2223 break;
2208 case Qt::Key_Q: 2224 case Qt::Key_Q:
2209 if ( e->state() == Qt::ControlButton ) 2225 if ( e->state() == Qt::ControlButton )
2210 mView->conflictNotAll(); 2226 mView->conflictNotAll();
2211 else if ( e->state() == Qt::ShiftButton ) 2227 else if ( e->state() == Qt::ShiftButton )
2212 mView->conflictAllday(); 2228 mView->conflictAllday();
2213 else 2229 else
2214 mView->conflictAll(); 2230 mView->conflictAll();
2215 break; 2231 break;
2216 case Qt::Key_J: 2232 case Qt::Key_J:
2217 mView->viewManager()->showJournalView(); 2233 mView->viewManager()->showJournalView();
2218 break; 2234 break;
2219 case Qt::Key_B: 2235 case Qt::Key_B:
2220 mView->editIncidenceDescription();; 2236 mView->editIncidenceDescription();;
2221 break; 2237 break;
2222 // case Qt::Key_Return: 2238 // case Qt::Key_Return:
2223 case Qt::Key_E: 2239 case Qt::Key_E:
2224 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 2240 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
2225 mView->newEvent(); 2241 mView->newEvent();
2226 else 2242 else
2227 mView->editIncidence(); 2243 mView->editIncidence();
2228 break; 2244 break;
2229 case Qt::Key_Plus: 2245 case Qt::Key_Plus:
2230 size = p->mHourSize +2; 2246 size = p->mHourSize +2;
2231 if ( size <= 22 ) 2247 if ( size <= 22 )
2232 configureAgenda( size ); 2248 configureAgenda( size );
2233 break; 2249 break;
2234 case Qt::Key_Minus: 2250 case Qt::Key_Minus:
2235 size = p->mHourSize - 2; 2251 size = p->mHourSize - 2;
2236 if ( size >= 4 ) 2252 if ( size >= 4 )
2237 configureAgenda( size ); 2253 configureAgenda( size );
2238 break; 2254 break;
2239 2255
2240 2256
2241 default: 2257 default:
2242 e->ignore(); 2258 e->ignore();
2243 } 2259 }
2244 if ( pro > 0 ) { 2260 if ( pro > 0 ) {
2245 selectFilter( pro+1 ); 2261 selectFilter( pro+1 );
2246 } 2262 }
2247 if ( showSelectedDates ) { 2263 if ( showSelectedDates ) {
2248 ;// setCaptionToDates(); 2264 ;// setCaptionToDates();
2249 } 2265 }
2250 2266
2251} 2267}
2252void MainWindow::fillFilterMenuTB() 2268void MainWindow::fillFilterMenuTB()
2253{ 2269{
2254 selectFilterMenuTB->clear(); 2270 selectFilterMenuTB->clear();
2255 selectFilterMenuTB->insertItem(i18n ( "Edit Filters" ), 0 ); 2271 selectFilterMenuTB->insertItem(i18n ( "Edit Filters" ), 0 );
2256 selectFilterMenuTB->insertSeparator(); 2272 selectFilterMenuTB->insertSeparator();
2257 selectFilterMenuTB->insertItem(i18n ( "No Filter" ), 1 ); 2273 selectFilterMenuTB->insertItem(i18n ( "No Filter" ), 1 );
2258 2274
2259 selectFilterMenuTB->insertSeparator(); 2275 selectFilterMenuTB->insertSeparator();
2260 QPtrList<CalFilter> fili = mView->filters(); 2276 QPtrList<CalFilter> fili = mView->filters();
2261 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2277 CalFilter *curfilter = mView->filterView()->selectedFilter();
2262 CalFilter *filter = fili.first(); 2278 CalFilter *filter = fili.first();
2263 int iii = 2; 2279 int iii = 2;
2264 bool checkitem = mView->filterView()->filtersEnabled(); 2280 bool checkitem = mView->filterView()->filtersEnabled();
2265 while(filter) { 2281 while(filter) {
2266 selectFilterMenuTB->insertItem( filter->name(), iii ); 2282 selectFilterMenuTB->insertItem( filter->name(), iii );
2267 if ( filter == curfilter) 2283 if ( filter == curfilter)
2268 selectFilterMenuTB->setItemChecked( iii, checkitem ); 2284 selectFilterMenuTB->setItemChecked( iii, checkitem );
2269 filter = fili.next(); 2285 filter = fili.next();
2270 ++iii; 2286 ++iii;
2271 } 2287 }
2272 if ( !checkitem ) 2288 if ( !checkitem )
2273 selectFilterMenuTB->setItemChecked( 1, true ); 2289 selectFilterMenuTB->setItemChecked( 1, true );
2274 2290
2275 int x = 0; 2291 int x = 0;
2276 int y = iconToolBar->height(); 2292 int y = iconToolBar->height();
2277 int dX = 0; 2293 int dX = 0;
2278 int dY = 0; 2294 int dY = 0;
2279 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 2295 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
2280 if ( iconToolBar->y() > height()/2 ) { 2296 if ( iconToolBar->y() > height()/2 ) {
2281 dY = selectFilterMenuTB->sizeHint().height()+8; 2297 dY = selectFilterMenuTB->sizeHint().height()+8;
2282 y = 0; 2298 y = 0;
2283 } 2299 }
2284 } else { 2300 } else {
2285 if ( iconToolBar->x() > width()/2 ) { // right side 2301 if ( iconToolBar->x() > width()/2 ) { // right side
2286 x=0; 2302 x=0;
2287 dX= selectFilterMenuTB->sizeHint().width()+8; 2303 dX= selectFilterMenuTB->sizeHint().width()+8;
2288 y = 0; 2304 y = 0;
2289 } else { 2305 } else {
2290 x= iconToolBar->width(); 2306 x= iconToolBar->width();
2291 y = 0; 2307 y = 0;
2292 } 2308 }
2293 } 2309 }
2294 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); 2310 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() );
2295 selectFilterMenuTB->popup(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))); 2311 selectFilterMenuTB->popup(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)));
2296} 2312}
2297void MainWindow::fillFilterMenu() 2313void MainWindow::fillFilterMenu()
2298{ 2314{
2299 selectFilterMenu->clear(); 2315 selectFilterMenu->clear();
2300 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); 2316 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 );
2301 selectFilterMenu->insertSeparator(); 2317 selectFilterMenu->insertSeparator();
2302 selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 ); 2318 selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 );
2303 2319
2304 selectFilterMenu->insertSeparator(); 2320 selectFilterMenu->insertSeparator();
2305 QPtrList<CalFilter> fili = mView->filters(); 2321 QPtrList<CalFilter> fili = mView->filters();
2306 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2322 CalFilter *curfilter = mView->filterView()->selectedFilter();
2307 CalFilter *filter = fili.first(); 2323 CalFilter *filter = fili.first();
2308 int iii = 2; 2324 int iii = 2;
2309 bool checkitem = mView->filterView()->filtersEnabled(); 2325 bool checkitem = mView->filterView()->filtersEnabled();
2310 while(filter) { 2326 while(filter) {
2311 selectFilterMenu->insertItem( filter->name(), iii ); 2327 selectFilterMenu->insertItem( filter->name(), iii );
2312 if ( filter == curfilter) 2328 if ( filter == curfilter)
2313 selectFilterMenu->setItemChecked( iii, checkitem ); 2329 selectFilterMenu->setItemChecked( iii, checkitem );
2314 filter = fili.next(); 2330 filter = fili.next();
2315 ++iii; 2331 ++iii;
2316 } 2332 }
2317 if ( !checkitem ) 2333 if ( !checkitem )
2318 selectFilterMenu->setItemChecked( 1, true ); 2334 selectFilterMenu->setItemChecked( 1, true );
2319} 2335}
2320void MainWindow::fillFilterMenuPopup() 2336void MainWindow::fillFilterMenuPopup()
2321{ 2337{
2322 filterPopupMenu->clear(); 2338 filterPopupMenu->clear();
2323 filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 ); 2339 filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 );
2324 2340
2325 filterPopupMenu->insertSeparator(); 2341 filterPopupMenu->insertSeparator();
2326 QPtrList<CalFilter> fili = mView->filters(); 2342 QPtrList<CalFilter> fili = mView->filters();
2327 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2343 CalFilter *curfilter = mView->filterView()->selectedFilter();
2328 CalFilter *filter = fili.first(); 2344 CalFilter *filter = fili.first();
2329 int iii = 1; 2345 int iii = 1;
2330 bool checkitem = mView->filterView()->filtersEnabled(); 2346 bool checkitem = mView->filterView()->filtersEnabled();
2331 while(filter) { 2347 while(filter) {
2332 filterPopupMenu->insertItem( filter->name(), iii ); 2348 filterPopupMenu->insertItem( filter->name(), iii );
2333 if ( filter == curfilter) 2349 if ( filter == curfilter)
2334 filterPopupMenu->setItemChecked( iii, checkitem ); 2350 filterPopupMenu->setItemChecked( iii, checkitem );
2335 filter = fili.next(); 2351 filter = fili.next();
2336 ++iii; 2352 ++iii;
2337 } 2353 }
2338 if ( !checkitem ) 2354 if ( !checkitem )
2339 filterPopupMenu->setItemChecked( 0, true ); 2355 filterPopupMenu->setItemChecked( 0, true );
2340} 2356}
2341void MainWindow::selectFilter( int fil ) 2357void MainWindow::selectFilter( int fil )
2342{ 2358{
2343 2359
2344 if ( fil == 0 ) { 2360 if ( fil == 0 ) {
2345 mView->editFilters( ); 2361 mView->editFilters( );
2346 } else if ( fil == 1 ){ 2362 } else if ( fil == 1 ){
2347 if ( mView->filterView()->filtersEnabled() ) 2363 if ( mView->filterView()->filtersEnabled() )
2348 mView->toggleFilerEnabled( ); 2364 mView->toggleFilerEnabled( );
2349 } else { 2365 } else {
2350 if ( !mView->filterView()->filtersEnabled() ) { 2366 if ( !mView->filterView()->filtersEnabled() ) {
2351 mView->filterView()->blockSignals( true ); 2367 mView->filterView()->blockSignals( true );
2352 mView->toggleFilerEnabled( ); 2368 mView->toggleFilerEnabled( );
2353 mView->filterView()->blockSignals( false ); 2369 mView->filterView()->blockSignals( false );
2354 } 2370 }
2355 mView->selectFilter( fil-2 ); 2371 mView->selectFilter( fil-2 );
2356 } 2372 }
2357} 2373}
2358void MainWindow::updateFilterToolbar() 2374void MainWindow::updateFilterToolbar()
2359{ 2375{
2360 if ( filterMenubar ) { 2376 if ( filterMenubar ) {
2361 if ( !mView->filterView()->filtersEnabled() ) { 2377 if ( !mView->filterView()->filtersEnabled() ) {
2362 filterMenubar->changeItem( 0, i18n("No Filter") ); 2378 filterMenubar->changeItem( 0, i18n("No Filter") );
2363 } else { 2379 } else {
2364 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2380 CalFilter *curfilter = mView->filterView()->selectedFilter();
2365 if ( curfilter ) { 2381 if ( curfilter ) {
2366 QString name = curfilter->name(); 2382 QString name = curfilter->name();
2367 if ( name.length() > 12 ) 2383 if ( name.length() > 12 )
2368 name = name.left(10)+"..."; 2384 name = name.left(10)+"...";
2369 filterMenubar->changeItem( 0, name ); 2385 filterMenubar->changeItem( 0, name );
2370 } 2386 }
2371 } 2387 }
2372 } 2388 }
2373} 2389}
2374void MainWindow::selectFilterPopup( int fil ) 2390void MainWindow::selectFilterPopup( int fil )
2375{ 2391{
2376 selectFilter( fil + 1 ); 2392 selectFilter( fil + 1 );
2377 2393
2378} 2394}
2379void MainWindow::configureToolBar( int item ) 2395void MainWindow::configureToolBar( int item )
2380{ 2396{
2381 2397
2382 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 2398 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
2383 KOPrefs *p = KOPrefs::instance(); 2399 KOPrefs *p = KOPrefs::instance();
2384 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 2400 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
2385 p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 ); 2401 p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 );
2386 p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 ); 2402 p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 );
2387 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 2403 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
2388 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 2404 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
2389 p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 ); 2405 p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 );
2390 p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 ); 2406 p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 );
2391 p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 ); 2407 p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 );
2392 p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 ); 2408 p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 );
2393 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 2409 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
2394 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 2410 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
2395 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 2411 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
2396 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 2412 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
2397 p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 ); 2413 p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 );
2398 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 2414 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
2399 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 2415 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
2400 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 2416 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
2401 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 2417 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
2402 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 2418 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
2403 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 2419 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
2404 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 2420 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
2405 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 2421 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
2406 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 2422 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
2407 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 2423 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
2408 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 2424 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
2409 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 2425 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
2410 p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 ); 2426 p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 );
2411 // initActions(); 2427 // initActions();
2412 setCaption ( i18n("Toolbar changes needs a restart!") ); 2428 setCaption ( i18n("Toolbar changes needs a restart!") );
2413} 2429}
2414void MainWindow::setCaption ( const QString & c ) 2430void MainWindow::setCaption ( const QString & c )
2415{ 2431{
2416 QString cap = c; 2432 QString cap = c;
2417 cap.replace( QRegExp("\n"), " " ); 2433 cap.replace( QRegExp("\n"), " " );
2418 cap = cap.stripWhiteSpace(); 2434 cap = cap.stripWhiteSpace();
2419 if ( cap.isEmpty() ) 2435 if ( cap.isEmpty() )
2420 cap = "KO/Pi"; 2436 cap = "KO/Pi";
2421 QWidget::setCaption( cap ); 2437 QWidget::setCaption( cap );
2422} 2438}
2423void MainWindow::setCaptionToDates() 2439void MainWindow::setCaptionToDates()
2424{ 2440{
2425 QString selDates; 2441 QString selDates;
2426 QDate date = mView->startDate(); 2442 QDate date = mView->startDate();
2427 if ( ! date.isValid() ) { 2443 if ( ! date.isValid() ) {
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index fdcf7c4..657c0a8 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -1,184 +1,186 @@
1#ifndef KORGE_MAINWINDOW_H 1#ifndef KORGE_MAINWINDOW_H
2#define KORGE_MAINWINDOW_H 2#define KORGE_MAINWINDOW_H
3 3
4#include <qmainwindow.h> 4#include <qmainwindow.h>
5#include <qtimer.h> 5#include <qtimer.h>
6#include <qdict.h> 6#include <qdict.h>
7#include <qfile.h> 7#include <qfile.h>
8#include <qmenubar.h> 8#include <qmenubar.h>
9#include <qtextstream.h> 9#include <qtextstream.h>
10#include <qregexp.h> 10#include <qregexp.h>
11 11
12#include <libkcal/incidence.h> 12#include <libkcal/incidence.h>
13#include <ksyncmanager.h> 13#include <ksyncmanager.h>
14#include <kpopupmenu.h> 14#include <kpopupmenu.h>
15#ifndef DESKTOP_VERSION 15#ifndef DESKTOP_VERSION
16#include <qcopchannel_qws.h> 16#include <qcopchannel_qws.h>
17#endif 17#endif
18class QAction; 18class QAction;
19class CalendarView; 19class CalendarView;
20class KSyncProfile; 20class KSyncProfile;
21#ifdef DESKTOP_VERSION 21#ifdef DESKTOP_VERSION
22 22
23#define QPEToolBar QToolBar 23#define QPEToolBar QToolBar
24#endif 24#endif
25class QPEToolBar; 25class QPEToolBar;
26 26
27 27
28namespace KCal { 28namespace KCal {
29class CalendarLocal; 29class CalendarLocal;
30} 30}
31 31
32using namespace KCal; 32using namespace KCal;
33 33
34class MainWindow : public QMainWindow 34class MainWindow : public QMainWindow
35{ 35{
36 Q_OBJECT 36 Q_OBJECT
37 public: 37 public:
38 MainWindow( QWidget *parent = 0, const char *name = 0 ); 38 MainWindow( QWidget *parent = 0, const char *name = 0 );
39 ~MainWindow(); 39 ~MainWindow();
40 bool beamReceiveEnabled(); 40 bool beamReceiveEnabled();
41 static QString defaultFileName(); 41 static QString defaultFileName();
42 static QString syncFileName(); 42 static QString syncFileName();
43 static QString resourcePath(); 43 static QString resourcePath();
44 public slots: 44 public slots:
45 void setUsesBigPixmaps ( bool ); 45 void setUsesBigPixmaps ( bool );
46 void setCaption ( const QString & ); 46 void setCaption ( const QString & );
47 void updateWeekNum(const KCal::DateList &); 47 void updateWeekNum(const KCal::DateList &);
48 void updateWeek(QDate); 48 void updateWeek(QDate);
49 void updateFilterToolbar(); 49 void updateFilterToolbar();
50 virtual void showMaximized (); 50 virtual void showMaximized ();
51 void configureAgenda( int ); 51 void configureAgenda( int );
52 void recieve( const QCString& msg, const QByteArray& data ); 52 void recieve( const QCString& msg, const QByteArray& data );
53 void receiveStart( const QCString& msg, const QByteArray& data ); 53 void receiveStart( const QCString& msg, const QByteArray& data );
54 protected slots: 54 protected slots:
55 void loadDataAfterStart(); 55 void loadDataAfterStart();
56 void calHint(); 56 void calHint();
57 void startMultiSync(); 57 void startMultiSync();
58 void setCaptionToDates(); 58 void setCaptionToDates();
59 void weekAction(); 59 void weekAction();
60 void about(); 60 void about();
61 void licence(); 61 void licence();
62 void faq(); 62 void faq();
63 void usertrans(); 63 void usertrans();
64 void features(); 64 void features();
65 void synchowto(); 65 void synchowto();
66 void storagehowto(); 66 void storagehowto();
67 void timetrackinghowto(); 67 void timetrackinghowto();
68 void kdesynchowto(); 68 void kdesynchowto();
69 void multisynchowto(); 69 void multisynchowto();
70 void whatsNew(); 70 void whatsNew();
71 void keyBindings(); 71 void keyBindings();
72 void aboutAutoSaving();; 72 void aboutAutoSaving();;
73 void aboutKnownBugs(); 73 void aboutKnownBugs();
74 74
75 void processIncidenceSelection( Incidence * ); 75 void processIncidenceSelection( Incidence * );
76 76
77 void importQtopia(); 77 void importQtopia();
78 void importBday(); 78 void importBday();
79 void importOL(); 79 void importOL();
80 void importIcal(); 80 void importIcal();
81 void importFile( QString, bool ); 81 void importFile( QString, bool );
82 void quickImportIcal(); 82 void quickImportIcal();
83 83
84 void slotModifiedChanged( bool ); 84 void slotModifiedChanged( bool );
85 85
86 void save(); 86 void save();
87 void backupAllFiles(); 87 void backupAllFiles();
88 void saveStopTimer(); 88 void saveStopTimer();
89 void configureToolBar( int ); 89 void configureToolBar( int );
90 void printSel(); 90 void printSel();
91 void printCal(); 91 void printCal();
92 void printListView(); 92 void printListView();
93 void saveCalendar(); 93 void saveCalendar();
94 void loadCalendar(); 94 void loadCalendar();
95 void exportVCalendar(); 95 void exportVCalendar();
96 void fillFilterMenu(); 96 void fillFilterMenu();
97 void fillFilterMenuTB(); 97 void fillFilterMenuTB();
98 void selectFilter( int ); 98 void selectFilter( int );
99 void fillFilterMenuPopup(); 99 void fillFilterMenuPopup();
100 void selectFilterPopup( int ); 100 void selectFilterPopup( int );
101 void exportToPhone( int ); 101 void exportToPhone( int );
102 void toggleBeamReceive(); 102 void toggleBeamReceive();
103 void disableBR(bool); 103 void disableBR(bool);
104 signals: 104 signals:
105 void selectWeek ( int ); 105 void selectWeek ( int );
106 private slots: 106 private slots:
107 void slotResetFocus(); 107 void slotResetFocus();
108 void slotResetFocusLoop(); 108 void slotResetFocusLoop();
109 void showConfigureAgenda(); 109 void showConfigureAgenda();
110 void getFile( bool ); 110 void getFile( bool );
111 void syncFileRequest(); 111 void syncFileRequest();
112 112
113 protected: 113 protected:
114 int mFocusLoop; 114 int mFocusLoop;
115 void hideEvent ( QHideEvent * ); 115 void hideEvent ( QHideEvent * );
116 QString sentSyncFile(); 116 QString sentSyncFile();
117 void displayText( QString, QString); 117 void displayText( QString, QString);
118 void enableIncidenceActions( bool ); 118 void enableIncidenceActions( bool );
119 119
120 private: 120 private:
121 121
122 QCString mCStringMess; 122 QCString mCStringMess;
123 QByteArray mByteData; 123 QByteArray mByteData;
124 124
125 //void setMenuBar( QMenuBar * ); 125 //void setMenuBar( QMenuBar * );
126 bool mBRdisabled; 126 bool mBRdisabled;
127#ifndef DESKTOP_VERSION 127#ifndef DESKTOP_VERSION
128 QCopChannel* infrared; 128 QCopChannel* infrared;
129#endif 129#endif
130 QAction* brAction; 130 QAction* brAction;
131 KSyncManager* mSyncManager; 131 KSyncManager* mSyncManager;
132 bool mClosed; 132 bool mClosed;
133 void saveOnClose(); 133 void saveOnClose();
134 bool mFlagKeyPressed; 134 bool mFlagKeyPressed;
135 bool mBlockAtStartup; 135 bool mBlockAtStartup;
136 KMenuBar *menuBar1; 136 KMenuBar *menuBar1;
137 QPEToolBar *iconToolBar; 137 QPEToolBar *iconToolBar;
138 QPEToolBar *viewToolBar; 138 QPEToolBar *viewToolBar;
139 QPEToolBar *navigatorToolBar; 139 QPEToolBar *navigatorToolBar;
140 QPEToolBar *filterToolBar; 140 QPEToolBar *filterToolBar;
141 KMenuBar *filterMenubar; 141 KMenuBar *filterMenubar;
142 QPopupMenu * filterPopupMenu; 142 QPopupMenu * filterPopupMenu;
143 QPopupMenu * mCurrentItemMenu; 143 QPopupMenu * mCurrentItemMenu;
144 void initActions(); 144 void initActions();
145 void setDefaultPreferences(); 145 void setDefaultPreferences();
146 void resizeEvent( QResizeEvent* e); 146 void resizeEvent( QResizeEvent* e);
147 void keyPressEvent ( QKeyEvent * ) ; 147 void keyPressEvent ( QKeyEvent * ) ;
148 void keyReleaseEvent ( QKeyEvent * ) ; 148 void keyReleaseEvent ( QKeyEvent * ) ;
149 QPopupMenu *configureToolBarMenu; 149 QPopupMenu *configureToolBarMenu;
150 QPopupMenu *selectFilterMenu; 150 QPopupMenu *selectFilterMenu;
151 QPopupMenu *selectFilterMenuTB; 151 QPopupMenu *selectFilterMenuTB;
152 QPopupMenu *configureAgendaMenu, *syncMenu; 152 QPopupMenu *configureAgendaMenu, *syncMenu;
153 CalendarLocal *mCalendar; 153 CalendarLocal *mCalendar;
154 CalendarView *mView; 154 CalendarView *mView;
155 QAction *mNewSubTodoAction; 155 QAction *mNewSubTodoAction;
156 QAction *mWeekAction; 156 QAction *mWeekAction;
157 QFont mWeekFont; 157 QFont mWeekFont;
158 QPixmap mWeekPixmap; 158 QPixmap mWeekPixmap;
159 QColor mWeekBgColor; 159 QColor mWeekBgColor;
160 160
161 QAction *mShowAction; 161 QAction *mShowAction;
162 QAction *mEditAction; 162 QAction *mEditAction;
163 QAction *mDeleteAction; 163 QAction *mDeleteAction;
164 QAction *mCloneAction; 164 QAction *mCloneAction;
165 QAction *mMoveAction; 165 QAction *mMoveAction;
166 QAction *mBeamAction; 166 QAction *mBeamAction;
167 QAction *mCancelAction; 167 QAction *mCancelAction;
168 QAction *mPrintSelAction; 168 QAction *mPrintSelAction;
169 169
170 QAction *mToggleNav; 170 QAction *mToggleNav;
171 QAction *mToggleFilter; 171 QAction *mToggleFilter;
172 QAction *mToggleAllday; 172 QAction *mToggleAllday;
173 QAction *actionFilterMenuTB; 173 QAction *actionFilterMenuTB;
174 174
175 void closeEvent( QCloseEvent* ce ); 175 void closeEvent( QCloseEvent* ce );
176 QTimer mSaveTimer; 176 QTimer mSaveTimer;
177 QTime mSaveTime;
178 int mSaveDelay;
177 //bool mBlockSaveFlag; 179 //bool mBlockSaveFlag;
178 bool mCalendarModifiedFlag; 180 bool mCalendarModifiedFlag;
179 QPixmap loadPixmap( QString ); 181 QPixmap loadPixmap( QString );
180 QPixmap listviewPix, listviewPix0, listviewPix20, listviewPix40, listviewPix60, listviewPix80, journalPix; 182 QPixmap listviewPix, listviewPix0, listviewPix20, listviewPix40, listviewPix60, listviewPix80, journalPix;
181}; 183};
182 184
183 185
184#endif 186#endif