author | zautrix <zautrix> | 2005-09-25 02:28:24 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-09-25 02:28:24 (UTC) |
commit | fa126dfea03b4ebed9a4eed4f2104f93abb72e22 (patch) (unidiff) | |
tree | dab730835ae807e407b928623a85294558d756cb /korganizer | |
parent | 3bbc14431e854bc3d8870b5ba12d64f6e1af6eb6 (diff) | |
download | kdepimpi-fa126dfea03b4ebed9a4eed4f2104f93abb72e22.zip kdepimpi-fa126dfea03b4ebed9a4eed4f2104f93abb72e22.tar.gz kdepimpi-fa126dfea03b4ebed9a4eed4f2104f93abb72e22.tar.bz2 |
todo timer fix
-rw-r--r-- | korganizer/main.cpp | 2 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 8 |
2 files changed, 5 insertions, 5 deletions
diff --git a/korganizer/main.cpp b/korganizer/main.cpp index 9410c6a..4a0e24f 100644 --- a/korganizer/main.cpp +++ b/korganizer/main.cpp | |||
@@ -13,105 +13,105 @@ | |||
13 | #include <qsgistyle.h> | 13 | #include <qsgistyle.h> |
14 | #include <stdlib.h> | 14 | #include <stdlib.h> |
15 | #endif | 15 | #endif |
16 | #include <qtextcodec.h> | 16 | #include <qtextcodec.h> |
17 | 17 | ||
18 | #include <qdir.h> | 18 | #include <qdir.h> |
19 | #include <kstandarddirs.h> | 19 | #include <kstandarddirs.h> |
20 | #include <kglobal.h> | 20 | #include <kglobal.h> |
21 | #include <stdio.h> | 21 | #include <stdio.h> |
22 | #include "mainwindow.h" | 22 | #include "mainwindow.h" |
23 | #include <libkdepim/kpimglobalprefs.h> | 23 | #include <libkdepim/kpimglobalprefs.h> |
24 | void dumpMissing(); | 24 | void dumpMissing(); |
25 | 25 | ||
26 | 26 | ||
27 | int main( int argc, char **argv ) | 27 | int main( int argc, char **argv ) |
28 | { | 28 | { |
29 | #ifndef DESKTOP_VERSION | 29 | #ifndef DESKTOP_VERSION |
30 | QPEApplication a( argc, argv ); | 30 | QPEApplication a( argc, argv ); |
31 | a.setKeepRunning (); | 31 | a.setKeepRunning (); |
32 | #else | 32 | #else |
33 | QApplication a( argc, argv ); | 33 | QApplication a( argc, argv ); |
34 | QApplication::setStyle( new QPlatinumStyle ()); | 34 | QApplication::setStyle( new QPlatinumStyle ()); |
35 | #ifdef _WIN32_ | 35 | #ifdef _WIN32_ |
36 | QString hdir ( getenv( "HOME") ); | 36 | QString hdir ( getenv( "HOME") ); |
37 | if ( hdir.isEmpty() ) { | 37 | if ( hdir.isEmpty() ) { |
38 | QString hd ("C:/" ); | 38 | QString hd ("C:/" ); |
39 | //QMessageBox::information(0,"hh",QDir::homeDirPath()+" xx" +hd ); | 39 | //QMessageBox::information(0,"hh",QDir::homeDirPath()+" xx" +hd ); |
40 | if ( QDir::homeDirPath().lower() == hd.lower() ) { | 40 | if ( QDir::homeDirPath().lower() == hd.lower() ) { |
41 | _putenv( "HOME=C:"); | 41 | _putenv( "HOME=C:"); |
42 | //QMessageBox::information(0,"hh",QString ( getenv( "HOME") ) ); | 42 | //QMessageBox::information(0,"hh",QString ( getenv( "HOME") ) ); |
43 | } | 43 | } |
44 | } else { | 44 | } else { |
45 | QDir app_dir; | 45 | QDir app_dir; |
46 | if ( !app_dir.exists(hdir) ) | 46 | if ( !app_dir.exists(hdir) ) |
47 | app_dir.mkdir (hdir); | 47 | app_dir.mkdir (hdir); |
48 | } | 48 | } |
49 | #endif | 49 | #endif |
50 | #endif | 50 | #endif |
51 | bool exitHelp = false; | 51 | bool exitHelp = false; |
52 | if ( argc > 1 ) { | 52 | if ( argc > 1 ) { |
53 | QString command = argv[1]; | 53 | QString command = argv[1]; |
54 | if ( command == "-help" ){ | 54 | if ( command == "-help" ){ |
55 | printf("KO/Pi command line commands:\n"); | 55 | printf("KO/Pi command line commands:\n"); |
56 | printf(" no command: Start KO/Pi in usual way\n"); | 56 | printf(" no command: Start KO/Pi in usual way\n"); |
57 | printf(" -help: This output\n"); | 57 | printf(" -help: This output\n"); |
58 | printf("Next Option: Open or Show after start:\n"); | 58 | printf("Next Option: Open or Show after start:\n"); |
59 | printf(" -newTodo: New Todo dialog\n"); | 59 | printf(" -newTodo: New Todo dialog\n"); |
60 | printf(" -newEvent: New Event dialog\n"); | 60 | printf(" -newEvent: New Event dialog\n"); |
61 | printf(" -showList: List view\n"); | 61 | printf(" -showList: List view\n"); |
62 | printf(" -showDay: Day view\n"); | 62 | printf(" -showDay: Day view\n"); |
63 | printf(" -showWWeek: Work Week view\n"); | 63 | printf(" -showWWeek: Work Week view\n"); |
64 | printf(" -showWeek: Week view\n"); | 64 | printf(" -showWeek: Week view\n"); |
65 | printf(" -showTodo: Todo view\n"); | 65 | printf(" -showTodo: Todo view\n"); |
66 | printf(" -showJournal: Journal view\n"); | 66 | printf(" -showJournal: Journal view\n"); |
67 | printf(" -showKO: Next Days view\n"); | 67 | printf(" -showKO: Next Days view\n"); |
68 | printf(" -showWNext: What's Next view\n"); | 68 | printf(" -showWNext: What's Next view\n"); |
69 | printf(" -showNextXView: Next X View\n"); | 69 | printf(" -showNextXView: Next X View\n"); |
70 | printf(" -new[Y] and -show[X] may be used togehther\n"); | 70 | printf(" -new[Y] and -show[X] may be used togehther\n"); |
71 | printf(" KO/Pi is exiting now. Bye!\n"); | 71 | printf(" KO/Pi is exiting now. Bye!\n"); |
72 | exitHelp = true; | 72 | exitHelp = true; |
73 | } | 73 | } |
74 | } | 74 | } |
75 | if ( ! exitHelp ) { | 75 | if ( ! exitHelp ) { |
76 | KGlobal::setAppName( "korganizer" ); | 76 | KGlobal::setAppName( "korganizer" ); |
77 | QString fileName ; | 77 | QString fileName ; |
78 | #ifndef DESKTOP_VERSION | 78 | #ifndef DESKTOP_VERSION |
79 | fileName = getenv("QPEDIR"); | 79 | fileName = getenv("QPEDIR"); |
80 | KGlobal::iconLoader()->setIconPath( fileName +"/pics/kdepim/korganizer/"); | 80 | KGlobal::iconLoader()->setIconPath( fileName +"/pics/kdepim/korganizer/"); |
81 | #else | 81 | #else |
82 | fileName = qApp->applicationDirPath () + "/kdepim/korganizer/"; | 82 | fileName = qApp->applicationDirPath () + "/kdepim/korganizer/"; |
83 | KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); | 83 | KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); |
84 | #endif | 84 | #endif |
85 | KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "korganizer"))); | 85 | KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "korganizer"))); |
86 | 86 | ||
87 | QApplication::setFont( KPimGlobalPrefs::instance()->mApplicationFont ); | 87 | QApplication::setFont( KPimGlobalPrefs::instance()->mApplicationFont ); |
88 | KPimGlobalPrefs::instance()->setGlobalConfig(); | 88 | KPimGlobalPrefs::instance()->setGlobalConfig(); |
89 | MainWindow m; | 89 | MainWindow m; |
90 | #ifndef DESKTOP_VERSION | 90 | #ifndef DESKTOP_VERSION |
91 | 91 | ||
92 | QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&m, SLOT(receiveStart( const QCString&, const QByteArray& ))); | 92 | QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&m, SLOT(receiveStart( const QCString&, const QByteArray& ))); |
93 | a.showMainWidget(&m ); | 93 | a.showMainWidget(&m ); |
94 | #else | 94 | #else |
95 | a.setMainWidget(&m ); | 95 | a.setMainWidget(&m ); |
96 | m.show(); | 96 | m.show(); |
97 | //m.resize( 800, 600 ); | 97 | //m.resize( 800, 600 ); |
98 | //QObject::connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); | 98 | //QObject::connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); |
99 | #endif | 99 | #endif |
100 | if ( argc > 1 ) { | 100 | if ( argc > 1 ) { |
101 | QCString command = argv[1]; | 101 | QCString command = argv[1]; |
102 | if ( argc > 2 ) | 102 | if ( argc > 2 ) |
103 | command += argv[2]; | 103 | command += argv[2]; |
104 | m.recieve(command, QByteArray() ); | 104 | m.recieve(command, QByteArray() ); |
105 | 105 | ||
106 | } | 106 | } |
107 | 107 | ||
108 | #ifndef DESKTOP_VERSION | 108 | #ifndef DESKTOP_VERSION |
109 | QPEApplication::setTempScreenSaverMode ( QPEApplication::Disable ); | 109 | // QPEApplication::setTempScreenSaverMode ( QPEApplication::Disable ); |
110 | #endif | 110 | #endif |
111 | a.exec(); | 111 | a.exec(); |
112 | dumpMissing(); | 112 | dumpMissing(); |
113 | 113 | ||
114 | KPimGlobalPrefs::instance()->writeConfig(); | 114 | KPimGlobalPrefs::instance()->writeConfig(); |
115 | } | 115 | } |
116 | qDebug("KO: Bye! "); | 116 | qDebug("KO: Bye! "); |
117 | } | 117 | } |
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 05e5087..c597138 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -1963,228 +1963,228 @@ void MainWindow::saveOnClose() | |||
1963 | } | 1963 | } |
1964 | #endif | 1964 | #endif |
1965 | save(); | 1965 | save(); |
1966 | mView->writeSettings(); | 1966 | mView->writeSettings(); |
1967 | mView->checkSuspendAlarm(); | 1967 | mView->checkSuspendAlarm(); |
1968 | } | 1968 | } |
1969 | void MainWindow::slotModifiedChanged( bool ) | 1969 | void MainWindow::slotModifiedChanged( bool ) |
1970 | { | 1970 | { |
1971 | if ( mBlockAtStartup ) | 1971 | if ( mBlockAtStartup ) |
1972 | return; | 1972 | return; |
1973 | 1973 | ||
1974 | int msec; | 1974 | int msec; |
1975 | if ( mCalendarModifiedFlag ) { | 1975 | if ( mCalendarModifiedFlag ) { |
1976 | //qDebug(" MainWindow timer is running "); | 1976 | //qDebug(" MainWindow timer is running "); |
1977 | return; | 1977 | return; |
1978 | } | 1978 | } |
1979 | // we store the changes after 1 minute, | 1979 | // we store the changes after 1 minute, |
1980 | // and for safety reasons after 10 minutes again | 1980 | // and for safety reasons after 10 minutes again |
1981 | if ( !mSyncManager->blockSave() ) | 1981 | if ( !mSyncManager->blockSave() ) |
1982 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; | 1982 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; |
1983 | else | 1983 | else |
1984 | msec = 1000 * 600; | 1984 | msec = 1000 * 600; |
1985 | mSaveTimer.start( msec, true ); // 1 minute | 1985 | mSaveTimer.start( msec, true ); // 1 minute |
1986 | mSaveTimerStart = QDateTime::currentDateTime(); | 1986 | mSaveTimerStart = QDateTime::currentDateTime(); |
1987 | mSaveDelay = msec/1000; | 1987 | mSaveDelay = msec/1000; |
1988 | qDebug("KO: Saving File in %d secs!", msec/1000); | 1988 | qDebug("KO: Saving File in %d secs!", msec/1000); |
1989 | mCalendarModifiedFlag = true; | 1989 | mCalendarModifiedFlag = true; |
1990 | } | 1990 | } |
1991 | void MainWindow::saveStopTimer() | 1991 | void MainWindow::saveStopTimer() |
1992 | { | 1992 | { |
1993 | mSaveTimer.stop(); | 1993 | mSaveTimer.stop(); |
1994 | } | 1994 | } |
1995 | void MainWindow::backupAllFiles() | 1995 | void MainWindow::backupAllFiles() |
1996 | { | 1996 | { |
1997 | QDate reference ( 2000,1,1); | 1997 | QDate reference ( 2000,1,1); |
1998 | int daysTo = reference.daysTo ( QDate::currentDate() ); | 1998 | int daysTo = reference.daysTo ( QDate::currentDate() ); |
1999 | setCaption(i18n("Creating backup ... please wait ..." )); | 1999 | setCaption(i18n("Creating backup ... please wait ..." )); |
2000 | qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); | 2000 | qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); |
2001 | // we need the file path, the backup dir and the number of bups as param | 2001 | // we need the file path, the backup dir and the number of bups as param |
2002 | QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; | 2002 | QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; |
2003 | if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) | 2003 | if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) |
2004 | bupDir = KGlobalSettings::backupDataDir(); | 2004 | bupDir = KGlobalSettings::backupDataDir(); |
2005 | int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); | 2005 | int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); |
2006 | if ( retval == 0 ) { | 2006 | if ( retval == 0 ) { |
2007 | setCaption(i18n("Backup cancelled" )); | 2007 | setCaption(i18n("Backup cancelled" )); |
2008 | qDebug("KO: Backup cancelled. Will try again tomorrow "); | 2008 | qDebug("KO: Backup cancelled. Will try again tomorrow "); |
2009 | // retval == 0 : backup skipped for today, try again tomorrow | 2009 | // retval == 0 : backup skipped for today, try again tomorrow |
2010 | KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; | 2010 | KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; |
2011 | } else if ( retval == 1 ){ | 2011 | } else if ( retval == 1 ){ |
2012 | qDebug("KO: Backup created."); | 2012 | qDebug("KO: Backup created."); |
2013 | // backup ok | 2013 | // backup ok |
2014 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2014 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2015 | KopiCalendarFile * cal = calendars.first(); | 2015 | KopiCalendarFile * cal = calendars.first(); |
2016 | cal = calendars.next(); | 2016 | cal = calendars.next(); |
2017 | while ( cal ) { | 2017 | while ( cal ) { |
2018 | if ( !cal->mErrorOnLoad ) { | 2018 | if ( !cal->mErrorOnLoad ) { |
2019 | KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); | 2019 | KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); |
2020 | } | 2020 | } |
2021 | cal = calendars.next(); | 2021 | cal = calendars.next(); |
2022 | } | 2022 | } |
2023 | KOPrefs::instance()->mLastBackupDate = daysTo; | 2023 | KOPrefs::instance()->mLastBackupDate = daysTo; |
2024 | setCaption(i18n("Backup succesfully finished" )); | 2024 | setCaption(i18n("Backup succesfully finished" )); |
2025 | } else if ( retval == 2 ){ | 2025 | } else if ( retval == 2 ){ |
2026 | setCaption(i18n("Backup globally disabled" )); | 2026 | setCaption(i18n("Backup globally disabled" )); |
2027 | qDebug("KO: Backup globally cancelled."); | 2027 | qDebug("KO: Backup globally cancelled."); |
2028 | // backup globally cancelled | 2028 | // backup globally cancelled |
2029 | KPimGlobalPrefs::instance()->mBackupEnabled = false; | 2029 | KPimGlobalPrefs::instance()->mBackupEnabled = false; |
2030 | } | 2030 | } |
2031 | // retval == 3: do nothing, try again later | 2031 | // retval == 3: do nothing, try again later |
2032 | } | 2032 | } |
2033 | void MainWindow::save() | 2033 | void MainWindow::save() |
2034 | { | 2034 | { |
2035 | if ( mSaveDelay ) { | 2035 | if ( mSaveDelay ) { |
2036 | int elapsed = mSaveTimerStart.secsTo( QDateTime::currentDateTime() ); | 2036 | int elapsed = mSaveTimerStart.secsTo( QDateTime::currentDateTime() ); |
2037 | if ( mSaveDelay < elapsed ) { | 2037 | if ( mSaveDelay < elapsed ) { |
2038 | qDebug("KO: Pending save after wakeup from suspend detected."); | 2038 | qDebug("KO: Pending save after wakeup from suspend detected."); |
2039 | qDebug("KO: Save delay %d sec. Elapsed save time %d sec.", mSaveDelay, elapsed ); | 2039 | qDebug("KO: Save delay %d sec. Elapsed save time %d sec.", mSaveDelay, elapsed ); |
2040 | qDebug("KO: Restarting save timer to save in 10 sec."); | 2040 | qDebug("KO: Restarting save timer to save in 10 sec."); |
2041 | int msec = 10000; | 2041 | int msec = 10000; |
2042 | mSaveTimer.start( msec, true ); | 2042 | mSaveTimer.start( msec, true ); |
2043 | mSaveTimerStart = QDateTime::currentDateTime(); | 2043 | mSaveTimerStart = QDateTime::currentDateTime(); |
2044 | mSaveDelay = msec/1000; | 2044 | mSaveDelay = msec/1000; |
2045 | return; | 2045 | return; |
2046 | } | 2046 | } |
2047 | } | 2047 | } |
2048 | if ( mView->viewManager()->journalView() ) | 2048 | if ( mView->viewManager()->journalView() ) |
2049 | mView->viewManager()->journalView()->checkModified(); | 2049 | mView->viewManager()->journalView()->checkModified(); |
2050 | if ( !mCalendarModifiedFlag ) { | 2050 | if ( !mCalendarModifiedFlag ) { |
2051 | qDebug("KO: Calendar not modified. Nothing saved."); | 2051 | qDebug("KO: Calendar not modified. Nothing saved."); |
2052 | return; | 2052 | return; |
2053 | } | 2053 | } |
2054 | if ( mSyncManager->blockSave() ) { | 2054 | if ( mSyncManager->blockSave() ) { |
2055 | slotModifiedChanged( true ); | 2055 | slotModifiedChanged( true ); |
2056 | return; | 2056 | return; |
2057 | } | 2057 | } |
2058 | #ifndef DESKTOP_VERSION | 2058 | #ifndef DESKTOP_VERSION |
2059 | QPEApplication::setTempScreenSaverMode ( QPEApplication::Disable ); | 2059 | // QPEApplication::setTempScreenSaverMode ( QPEApplication::Disable ); |
2060 | #endif | 2060 | #endif |
2061 | mSaveDelay = 0; | 2061 | mSaveDelay = 0; |
2062 | mSyncManager->setBlockSave(true); | 2062 | mSyncManager->setBlockSave(true); |
2063 | if ( mView->checkAllFileVersions() ) { | 2063 | if ( mView->checkAllFileVersions() ) { |
2064 | if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ | 2064 | if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ |
2065 | QDate reference ( 2000,1,1); | 2065 | QDate reference ( 2000,1,1); |
2066 | int daysTo = reference.daysTo ( QDate::currentDate() ); | 2066 | int daysTo = reference.daysTo ( QDate::currentDate() ); |
2067 | if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { | 2067 | if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { |
2068 | backupAllFiles(); | 2068 | backupAllFiles(); |
2069 | } | 2069 | } |
2070 | ; // KPimGlobalPrefs::instance()->mLastBackupDate | 2070 | ; // KPimGlobalPrefs::instance()->mLastBackupDate |
2071 | } | 2071 | } |
2072 | QTime neededSaveTime; | 2072 | QTime neededSaveTime; |
2073 | neededSaveTime.start(); | 2073 | neededSaveTime.start(); |
2074 | if ( !isMinimized () ) | 2074 | if ( !isMinimized () ) |
2075 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); | 2075 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); |
2076 | qDebug("KO: Start saving data to file!"); | 2076 | qDebug("KO: Start saving data to file!"); |
2077 | if ( mView->saveCalendars() ) | 2077 | if ( mView->saveCalendars() ) |
2078 | mCalendarModifiedFlag = false; | 2078 | mCalendarModifiedFlag = false; |
2079 | int msNeeded = neededSaveTime.elapsed(); | 2079 | int msNeeded = neededSaveTime.elapsed(); |
2080 | qDebug("KO: Needed %d ms for saving.",msNeeded ); | 2080 | qDebug("KO: Needed %d ms for saving.",msNeeded ); |
2081 | QString savemes; | 2081 | QString savemes; |
2082 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); | 2082 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); |
2083 | if ( !isMinimized () ) | 2083 | if ( !isMinimized () ) |
2084 | setCaption(savemes); | 2084 | setCaption(savemes); |
2085 | else | 2085 | else |
2086 | qDebug(savemes); | 2086 | qDebug(savemes); |
2087 | } else { | 2087 | } else { |
2088 | setCaption(i18n("Saving cancelled!")); | 2088 | setCaption(i18n("Saving cancelled!")); |
2089 | mCalendarModifiedFlag = false; | 2089 | mCalendarModifiedFlag = false; |
2090 | slotModifiedChanged( true ); | 2090 | slotModifiedChanged( true ); |
2091 | } | 2091 | } |
2092 | mSyncManager->setBlockSave( false ); | 2092 | mSyncManager->setBlockSave( false ); |
2093 | #ifndef DESKTOP_VERSION | 2093 | #ifndef DESKTOP_VERSION |
2094 | QPEApplication::setTempScreenSaverMode ( QPEApplication::Enable ); | 2094 | //QPEApplication::setTempScreenSaverMode ( QPEApplication::Enable ); |
2095 | #endif | 2095 | #endif |
2096 | } | 2096 | } |
2097 | 2097 | ||
2098 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) | 2098 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) |
2099 | { | 2099 | { |
2100 | if ( !e->isAutoRepeat() ) { | 2100 | if ( !e->isAutoRepeat() ) { |
2101 | mFlagKeyPressed = false; | 2101 | mFlagKeyPressed = false; |
2102 | } | 2102 | } |
2103 | } | 2103 | } |
2104 | void MainWindow::keyPressEvent ( QKeyEvent * e ) | 2104 | void MainWindow::keyPressEvent ( QKeyEvent * e ) |
2105 | { | 2105 | { |
2106 | qApp->processEvents(); | 2106 | qApp->processEvents(); |
2107 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 2107 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
2108 | e->ignore(); | 2108 | e->ignore(); |
2109 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 2109 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
2110 | return; | 2110 | return; |
2111 | } | 2111 | } |
2112 | if (! e->isAutoRepeat() ) | 2112 | if (! e->isAutoRepeat() ) |
2113 | mFlagKeyPressed = true; | 2113 | mFlagKeyPressed = true; |
2114 | KOPrefs *p = KOPrefs::instance(); | 2114 | KOPrefs *p = KOPrefs::instance(); |
2115 | bool showSelectedDates = false; | 2115 | bool showSelectedDates = false; |
2116 | int size; | 2116 | int size; |
2117 | int pro = 0; | 2117 | int pro = 0; |
2118 | //qDebug("MainWindow::keyPressEvent "); | 2118 | //qDebug("MainWindow::keyPressEvent "); |
2119 | switch ( e->key() ) { | 2119 | switch ( e->key() ) { |
2120 | case Qt::Key_Right: | 2120 | case Qt::Key_Right: |
2121 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 2121 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
2122 | mView->goNextMonth(); | 2122 | mView->goNextMonth(); |
2123 | else | 2123 | else |
2124 | mView->goNext(); | 2124 | mView->goNext(); |
2125 | showSelectedDates = true; | 2125 | showSelectedDates = true; |
2126 | break; | 2126 | break; |
2127 | case Qt::Key_Left: | 2127 | case Qt::Key_Left: |
2128 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 2128 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
2129 | mView->goPreviousMonth(); | 2129 | mView->goPreviousMonth(); |
2130 | else | 2130 | else |
2131 | mView->goPrevious(); | 2131 | mView->goPrevious(); |
2132 | showSelectedDates = true; | 2132 | showSelectedDates = true; |
2133 | break; | 2133 | break; |
2134 | case Qt::Key_Down: | 2134 | case Qt::Key_Down: |
2135 | mView->viewManager()->agendaView()->scrollOneHourDown(); | 2135 | mView->viewManager()->agendaView()->scrollOneHourDown(); |
2136 | break; | 2136 | break; |
2137 | case Qt::Key_Up: | 2137 | case Qt::Key_Up: |
2138 | mView->viewManager()->agendaView()->scrollOneHourUp(); | 2138 | mView->viewManager()->agendaView()->scrollOneHourUp(); |
2139 | break; | 2139 | break; |
2140 | case Qt::Key_K: | 2140 | case Qt::Key_K: |
2141 | mView->viewManager()->showMonthViewWeek(); | 2141 | mView->viewManager()->showMonthViewWeek(); |
2142 | break; | 2142 | break; |
2143 | case Qt::Key_I: | 2143 | case Qt::Key_I: |
2144 | mView->showIncidence(); | 2144 | mView->showIncidence(); |
2145 | break; | 2145 | break; |
2146 | case Qt::Key_Delete: | 2146 | case Qt::Key_Delete: |
2147 | case Qt::Key_Backspace: | 2147 | case Qt::Key_Backspace: |
2148 | mView->deleteIncidence(); | 2148 | mView->deleteIncidence(); |
2149 | break; | 2149 | break; |
2150 | case Qt::Key_D: | 2150 | case Qt::Key_D: |
2151 | mView->viewManager()->showDayView(); | 2151 | mView->viewManager()->showDayView(); |
2152 | showSelectedDates = true; | 2152 | showSelectedDates = true; |
2153 | break; | 2153 | break; |
2154 | case Qt::Key_O: | 2154 | case Qt::Key_O: |
2155 | mView->toggleFilerEnabled( ); | 2155 | mView->toggleFilerEnabled( ); |
2156 | break; | 2156 | break; |
2157 | case Qt::Key_0: | 2157 | case Qt::Key_0: |
2158 | case Qt::Key_1: | 2158 | case Qt::Key_1: |
2159 | case Qt::Key_2: | 2159 | case Qt::Key_2: |
2160 | case Qt::Key_3: | 2160 | case Qt::Key_3: |
2161 | case Qt::Key_4: | 2161 | case Qt::Key_4: |
2162 | case Qt::Key_5: | 2162 | case Qt::Key_5: |
2163 | case Qt::Key_6: | 2163 | case Qt::Key_6: |
2164 | case Qt::Key_7: | 2164 | case Qt::Key_7: |
2165 | case Qt::Key_8: | 2165 | case Qt::Key_8: |
2166 | case Qt::Key_9: | 2166 | case Qt::Key_9: |
2167 | pro = e->key()-48; | 2167 | pro = e->key()-48; |
2168 | if ( pro == 0 ) | 2168 | if ( pro == 0 ) |
2169 | pro = 10; | 2169 | pro = 10; |
2170 | if ( e->state() == Qt::ControlButton) | 2170 | if ( e->state() == Qt::ControlButton) |
2171 | pro += 10; | 2171 | pro += 10; |
2172 | break; | 2172 | break; |
2173 | case Qt::Key_M: | 2173 | case Qt::Key_M: |
2174 | mView->viewManager()->showMonthView(); | 2174 | mView->viewManager()->showMonthView(); |
2175 | showSelectedDates = true; | 2175 | showSelectedDates = true; |
2176 | break; | 2176 | break; |
2177 | case Qt::Key_Insert: | 2177 | case Qt::Key_Insert: |
2178 | mView->newEvent(); | 2178 | mView->newEvent(); |
2179 | break; | 2179 | break; |
2180 | case Qt::Key_S : | 2180 | case Qt::Key_S : |
2181 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 2181 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
2182 | mView->newSubTodo(); | 2182 | mView->newSubTodo(); |
2183 | else | 2183 | else |
2184 | mView->dialogManager()->showSearchDialog(); | 2184 | mView->dialogManager()->showSearchDialog(); |
2185 | break; | 2185 | break; |
2186 | case Qt::Key_Y : | 2186 | case Qt::Key_Y : |
2187 | case Qt::Key_Z : | 2187 | case Qt::Key_Z : |
2188 | mView->viewManager()->showWorkWeekView(); | 2188 | mView->viewManager()->showWorkWeekView(); |
2189 | showSelectedDates = true; | 2189 | showSelectedDates = true; |
2190 | break; | 2190 | break; |
@@ -2419,198 +2419,198 @@ void MainWindow::configureToolBar( int item ) | |||
2419 | { | 2419 | { |
2420 | 2420 | ||
2421 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); | 2421 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); |
2422 | KOPrefs *p = KOPrefs::instance(); | 2422 | KOPrefs *p = KOPrefs::instance(); |
2423 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); | 2423 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); |
2424 | p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 ); | 2424 | p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 ); |
2425 | p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 ); | 2425 | p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 ); |
2426 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); | 2426 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); |
2427 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); | 2427 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); |
2428 | p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 ); | 2428 | p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 ); |
2429 | p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 ); | 2429 | p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 ); |
2430 | p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 ); | 2430 | p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 ); |
2431 | p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 ); | 2431 | p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 ); |
2432 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); | 2432 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); |
2433 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); | 2433 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); |
2434 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); | 2434 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); |
2435 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); | 2435 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); |
2436 | p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 ); | 2436 | p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 ); |
2437 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); | 2437 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); |
2438 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); | 2438 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); |
2439 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); | 2439 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); |
2440 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); | 2440 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); |
2441 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); | 2441 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); |
2442 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); | 2442 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); |
2443 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); | 2443 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); |
2444 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); | 2444 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); |
2445 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); | 2445 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); |
2446 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); | 2446 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); |
2447 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); | 2447 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); |
2448 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); | 2448 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); |
2449 | p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 ); | 2449 | p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 ); |
2450 | // initActions(); | 2450 | // initActions(); |
2451 | setCaption ( i18n("Toolbar changes needs a restart!") ); | 2451 | setCaption ( i18n("Toolbar changes needs a restart!") ); |
2452 | } | 2452 | } |
2453 | void MainWindow::setCaption ( const QString & c ) | 2453 | void MainWindow::setCaption ( const QString & c ) |
2454 | { | 2454 | { |
2455 | QString cap = c; | 2455 | QString cap = c; |
2456 | cap.replace( QRegExp("\n"), " " ); | 2456 | cap.replace( QRegExp("\n"), " " ); |
2457 | cap = cap.stripWhiteSpace(); | 2457 | cap = cap.stripWhiteSpace(); |
2458 | if ( cap.isEmpty() ) | 2458 | if ( cap.isEmpty() ) |
2459 | cap = "KO/Pi"; | 2459 | cap = "KO/Pi"; |
2460 | QWidget::setCaption( cap ); | 2460 | QWidget::setCaption( cap ); |
2461 | } | 2461 | } |
2462 | void MainWindow::setCaptionToDates() | 2462 | void MainWindow::setCaptionToDates() |
2463 | { | 2463 | { |
2464 | QString selDates; | 2464 | QString selDates; |
2465 | QDate date = mView->startDate(); | 2465 | QDate date = mView->startDate(); |
2466 | if ( ! date.isValid() ) { | 2466 | if ( ! date.isValid() ) { |
2467 | setCaption(""); | 2467 | setCaption(""); |
2468 | return; | 2468 | return; |
2469 | } | 2469 | } |
2470 | selDates = KGlobal::locale()->formatDate( date, true); | 2470 | selDates = KGlobal::locale()->formatDate( date, true); |
2471 | if (mView->startDate() < mView->endDate() ) | 2471 | if (mView->startDate() < mView->endDate() ) |
2472 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); | 2472 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); |
2473 | else { | 2473 | else { |
2474 | QString addString; | 2474 | QString addString; |
2475 | if ( date == QDateTime::currentDateTime().date() ) | 2475 | if ( date == QDateTime::currentDateTime().date() ) |
2476 | addString = i18n("Today"); | 2476 | addString = i18n("Today"); |
2477 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) | 2477 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) |
2478 | addString = i18n("Tomorrow"); | 2478 | addString = i18n("Tomorrow"); |
2479 | if ( !addString.isEmpty() ) | 2479 | if ( !addString.isEmpty() ) |
2480 | selDates = addString+", "+selDates ; | 2480 | selDates = addString+", "+selDates ; |
2481 | } | 2481 | } |
2482 | setCaption( i18n("Dates: ") + selDates ); | 2482 | setCaption( i18n("Dates: ") + selDates ); |
2483 | 2483 | ||
2484 | } | 2484 | } |
2485 | void MainWindow::showConfigureAgenda( ) | 2485 | void MainWindow::showConfigureAgenda( ) |
2486 | { | 2486 | { |
2487 | int iii; | 2487 | int iii; |
2488 | for ( iii = 1;iii<= 10 ;++iii ){ | 2488 | for ( iii = 1;iii<= 10 ;++iii ){ |
2489 | configureAgendaMenu->setItemChecked( (iii+1)*2, false ); | 2489 | configureAgendaMenu->setItemChecked( (iii+1)*2, false ); |
2490 | } | 2490 | } |
2491 | configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); | 2491 | configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); |
2492 | } | 2492 | } |
2493 | void MainWindow::configureAgenda( int item ) | 2493 | void MainWindow::configureAgenda( int item ) |
2494 | { | 2494 | { |
2495 | if ( KOPrefs::instance()->mHourSize == item ) | 2495 | if ( KOPrefs::instance()->mHourSize == item ) |
2496 | return; | 2496 | return; |
2497 | KOPrefs::instance()->mHourSize=item; | 2497 | KOPrefs::instance()->mHourSize=item; |
2498 | mView->viewManager()->agendaView()->updateConfig(); | 2498 | mView->viewManager()->agendaView()->updateConfig(); |
2499 | } | 2499 | } |
2500 | 2500 | ||
2501 | void MainWindow::saveCalendar() | 2501 | void MainWindow::saveCalendar() |
2502 | { | 2502 | { |
2503 | QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; | 2503 | QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; |
2504 | if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) | 2504 | if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) |
2505 | bupDir = KGlobalSettings::backupDataDir(); | 2505 | bupDir = KGlobalSettings::backupDataDir(); |
2506 | bupDir = KGlobal::formatMessage ( bupDir, 0 ); | 2506 | bupDir = KGlobal::formatMessage ( bupDir, 0 ); |
2507 | QString bupHint; | 2507 | QString bupHint; |
2508 | if ( !KPimGlobalPrefs::instance()->mBackupEnabled ) | 2508 | if ( !KPimGlobalPrefs::instance()->mBackupEnabled ) |
2509 | bupHint = i18n("(Hint: You can enable automatic backup in the global settings!)"); | 2509 | bupHint = i18n("(Hint: You can enable automatic backup in the global settings!)"); |
2510 | if ( KMessageBox::warningContinueCancel( this, i18n("This will <b>backup all calendar files</b> to the directory %1 %2").arg(bupDir).arg(bupHint),i18n("Information") ) != KMessageBox::Continue ) return; | 2510 | if ( KMessageBox::warningContinueCancel( this, i18n("This will <b>backup all calendar files</b> to the directory %1 %2").arg(bupDir).arg(bupHint),i18n("Information") ) != KMessageBox::Continue ) return; |
2511 | bool enabled = KPimGlobalPrefs::instance()->mBackupEnabled; | 2511 | bool enabled = KPimGlobalPrefs::instance()->mBackupEnabled; |
2512 | KPimGlobalPrefs::instance()->mBackupEnabled = false; | 2512 | KPimGlobalPrefs::instance()->mBackupEnabled = false; |
2513 | save(); | 2513 | save(); |
2514 | #ifndef DESKTOP_VERSION | 2514 | #ifndef DESKTOP_VERSION |
2515 | QPEApplication::setTempScreenSaverMode ( QPEApplication::Disable ); | 2515 | //QPEApplication::setTempScreenSaverMode ( QPEApplication::Disable ); |
2516 | #endif | 2516 | #endif |
2517 | KPimGlobalPrefs::instance()->mBackupEnabled = enabled; | 2517 | KPimGlobalPrefs::instance()->mBackupEnabled = enabled; |
2518 | backupAllFiles(); | 2518 | backupAllFiles(); |
2519 | #ifndef DESKTOP_VERSION | 2519 | #ifndef DESKTOP_VERSION |
2520 | QPEApplication::setTempScreenSaverMode ( QPEApplication::Enable ); | 2520 | //QPEApplication::setTempScreenSaverMode ( QPEApplication::Enable ); |
2521 | #endif | 2521 | #endif |
2522 | } | 2522 | } |
2523 | void MainWindow::loadCalendar() | 2523 | void MainWindow::loadCalendar() |
2524 | { | 2524 | { |
2525 | 2525 | ||
2526 | 2526 | ||
2527 | #if 0 | 2527 | #if 0 |
2528 | QString fn = KOPrefs::instance()->mLastLoadFile; | 2528 | QString fn = KOPrefs::instance()->mLastLoadFile; |
2529 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); | 2529 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); |
2530 | 2530 | ||
2531 | if ( fn == "" ) | 2531 | if ( fn == "" ) |
2532 | return; | 2532 | return; |
2533 | QFileInfo info; | 2533 | QFileInfo info; |
2534 | info.setFile( fn ); | 2534 | info.setFile( fn ); |
2535 | QString mess; | 2535 | QString mess; |
2536 | bool loadbup = true; | 2536 | bool loadbup = true; |
2537 | if ( info. exists() ) { | 2537 | if ( info. exists() ) { |
2538 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 2538 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
2539 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", | 2539 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", |
2540 | mess, | 2540 | mess, |
2541 | i18n("Load!"), i18n("Cancel"), 0, | 2541 | i18n("Load!"), i18n("Cancel"), 0, |
2542 | 0, 1 ); | 2542 | 0, 1 ); |
2543 | if ( result != 0 ) { | 2543 | if ( result != 0 ) { |
2544 | loadbup = false; | 2544 | loadbup = false; |
2545 | } | 2545 | } |
2546 | } else { | 2546 | } else { |
2547 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2547 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2548 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, | 2548 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, |
2549 | 0, 1 ); | 2549 | 0, 1 ); |
2550 | 2550 | ||
2551 | return; | 2551 | return; |
2552 | } | 2552 | } |
2553 | if ( loadbup ) { | 2553 | if ( loadbup ) { |
2554 | mView->openCalendar( fn ); | 2554 | mView->openCalendar( fn ); |
2555 | KOPrefs::instance()->mLastLoadFile = fn; | 2555 | KOPrefs::instance()->mLastLoadFile = fn; |
2556 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; | 2556 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; |
2557 | setCaption(mess); | 2557 | setCaption(mess); |
2558 | } | 2558 | } |
2559 | #endif | 2559 | #endif |
2560 | 2560 | ||
2561 | } | 2561 | } |
2562 | void MainWindow::quickImportIcal() | 2562 | void MainWindow::quickImportIcal() |
2563 | { | 2563 | { |
2564 | importFile( KOPrefs::instance()->mLastImportFile, false ); | 2564 | importFile( KOPrefs::instance()->mLastImportFile, false ); |
2565 | } | 2565 | } |
2566 | void MainWindow::importFile( QString fn, bool quick ) | 2566 | void MainWindow::importFile( QString fn, bool quick ) |
2567 | { | 2567 | { |
2568 | QFileInfo info; | 2568 | QFileInfo info; |
2569 | info.setFile( fn ); | 2569 | info.setFile( fn ); |
2570 | QString mess; | 2570 | QString mess; |
2571 | if ( !info. exists() ) { | 2571 | if ( !info. exists() ) { |
2572 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); | 2572 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); |
2573 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2573 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2574 | mess ); | 2574 | mess ); |
2575 | return; | 2575 | return; |
2576 | } | 2576 | } |
2577 | int result = 0; | 2577 | int result = 0; |
2578 | if ( !quick ) { | 2578 | if ( !quick ) { |
2579 | mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 2579 | mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
2580 | result = QMessageBox::warning( this, "KO/Pi: Warning!", | 2580 | result = QMessageBox::warning( this, "KO/Pi: Warning!", |
2581 | mess, | 2581 | mess, |
2582 | "Import", "Cancel", 0, | 2582 | "Import", "Cancel", 0, |
2583 | 0, 1 ); | 2583 | 0, 1 ); |
2584 | } | 2584 | } |
2585 | if ( result == 0 ) { | 2585 | if ( result == 0 ) { |
2586 | if ( mView->openCalendar( fn, true )) { | 2586 | if ( mView->openCalendar( fn, true )) { |
2587 | KOPrefs::instance()->mLastImportFile = fn; | 2587 | KOPrefs::instance()->mLastImportFile = fn; |
2588 | setCaption(i18n("Imported file successfully")); | 2588 | setCaption(i18n("Imported file successfully")); |
2589 | } else { | 2589 | } else { |
2590 | setCaption(i18n("Error importing file")); | 2590 | setCaption(i18n("Error importing file")); |
2591 | } | 2591 | } |
2592 | mView->updateView(); | 2592 | mView->updateView(); |
2593 | } | 2593 | } |
2594 | } | 2594 | } |
2595 | 2595 | ||
2596 | void MainWindow::importIcal() | 2596 | void MainWindow::importIcal() |
2597 | { | 2597 | { |
2598 | 2598 | ||
2599 | QString fn =KOPrefs::instance()->mLastImportFile; | 2599 | QString fn =KOPrefs::instance()->mLastImportFile; |
2600 | 2600 | ||
2601 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); | 2601 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); |
2602 | if ( fn == "" ) | 2602 | if ( fn == "" ) |
2603 | return; | 2603 | return; |
2604 | importFile( fn, true ); | 2604 | importFile( fn, true ); |
2605 | 2605 | ||
2606 | } | 2606 | } |
2607 | void MainWindow::exportCalendar( bool iCalFormat ) | 2607 | void MainWindow::exportCalendar( bool iCalFormat ) |
2608 | { | 2608 | { |
2609 | QString fn = KOPrefs::instance()->mLastVcalFile; | 2609 | QString fn = KOPrefs::instance()->mLastVcalFile; |
2610 | if ( iCalFormat ) { | 2610 | if ( iCalFormat ) { |
2611 | fn = QDir::homeDirPath()+"/kopiexport.ics"; | 2611 | fn = QDir::homeDirPath()+"/kopiexport.ics"; |
2612 | fn = KFileDialog::getSaveFileName( fn, i18n("Export iCal filename(*.ics)"), this ); | 2612 | fn = KFileDialog::getSaveFileName( fn, i18n("Export iCal filename(*.ics)"), this ); |
2613 | } | 2613 | } |
2614 | else | 2614 | else |
2615 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); | 2615 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); |
2616 | if ( fn == "" ) | 2616 | if ( fn == "" ) |