author | zautrix <zautrix> | 2005-09-25 02:09:22 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-09-25 02:09:22 (UTC) |
commit | 3bbc14431e854bc3d8870b5ba12d64f6e1af6eb6 (patch) (unidiff) | |
tree | 0d88d48dc1b9198c9c2deed6b55c70deffcfeadd | |
parent | 181bc87d92ecc48cb07c288cb2d135d8fde56716 (diff) | |
download | kdepimpi-3bbc14431e854bc3d8870b5ba12d64f6e1af6eb6.zip kdepimpi-3bbc14431e854bc3d8870b5ba12d64f6e1af6eb6.tar.gz kdepimpi-3bbc14431e854bc3d8870b5ba12d64f6e1af6eb6.tar.bz2 |
todo timer fix
-rw-r--r-- | korganizer/main.cpp | 3 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 15 | ||||
-rw-r--r-- | libkcal/todo.cpp | 12 |
3 files changed, 26 insertions, 4 deletions
diff --git a/korganizer/main.cpp b/korganizer/main.cpp index a96f7c2..9410c6a 100644 --- a/korganizer/main.cpp +++ b/korganizer/main.cpp | |||
@@ -12,103 +12,106 @@ | |||
12 | #include <qplatinumstyle.h> | 12 | #include <qplatinumstyle.h> |
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 | ||
109 | QPEApplication::setTempScreenSaverMode ( QPEApplication::Disable ); | ||
110 | #endif | ||
108 | a.exec(); | 111 | a.exec(); |
109 | dumpMissing(); | 112 | dumpMissing(); |
110 | 113 | ||
111 | KPimGlobalPrefs::instance()->writeConfig(); | 114 | KPimGlobalPrefs::instance()->writeConfig(); |
112 | } | 115 | } |
113 | qDebug("KO: Bye! "); | 116 | qDebug("KO: Bye! "); |
114 | } | 117 | } |
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index d1e369c..05e5087 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -1,125 +1,125 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | 2 | ||
3 | #include <qaction.h> | 3 | #include <qaction.h> |
4 | #include <qpopupmenu.h> | 4 | #include <qpopupmenu.h> |
5 | #include <qpainter.h> | 5 | #include <qpainter.h> |
6 | #include <qwhatsthis.h> | 6 | #include <qwhatsthis.h> |
7 | #include <qpushbutton.h> | 7 | #include <qpushbutton.h> |
8 | #include <qmessagebox.h> | 8 | #include <qmessagebox.h> |
9 | #include <qlineedit.h> | 9 | #include <qlineedit.h> |
10 | #include <qtextcodec.h> | 10 | #include <qtextcodec.h> |
11 | #include <qfile.h> | 11 | #include <qfile.h> |
12 | #include <qdir.h> | 12 | #include <qdir.h> |
13 | #include <qapp.h> | 13 | #include <qapp.h> |
14 | #include <qfileinfo.h> | 14 | #include <qfileinfo.h> |
15 | #include <qlabel.h> | 15 | #include <qlabel.h> |
16 | #include <qspinbox.h> | 16 | #include <qspinbox.h> |
17 | #include <qcheckbox.h> | 17 | #include <qcheckbox.h> |
18 | #include <qmap.h> | 18 | #include <qmap.h> |
19 | #include <qwmatrix.h> | 19 | #include <qwmatrix.h> |
20 | #include <qtextbrowser.h> | 20 | #include <qtextbrowser.h> |
21 | #include <qtextstream.h> | 21 | #include <qtextstream.h> |
22 | #ifndef DESKTOP_VERSION | 22 | #ifndef DESKTOP_VERSION |
23 | #include <qpe/global.h> | 23 | #include <qpe/global.h> |
24 | #include <qpe/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 | ||
65 | using namespace KCal; | 65 | using 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 | ||
76 | class KOex2phonePrefs : public QDialog | 76 | class 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 | ||
125 | public: | 125 | public: |
@@ -1952,235 +1952,240 @@ void MainWindow::saveOnClose() | |||
1952 | p->mToolBarUpV = viewToolBar->x() > width()/2 ; | 1952 | p->mToolBarUpV = viewToolBar->x() > width()/2 ; |
1953 | 1953 | ||
1954 | if ( p->mToolBarHorN ) | 1954 | if ( p->mToolBarHorN ) |
1955 | p->mToolBarUpN = navigatorToolBar->y() > height()/2; | 1955 | p->mToolBarUpN = navigatorToolBar->y() > height()/2; |
1956 | else | 1956 | else |
1957 | p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; | 1957 | p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; |
1958 | if ( filterToolBar ) { | 1958 | if ( filterToolBar ) { |
1959 | if ( p->mToolBarHorF ) | 1959 | if ( p->mToolBarHorF ) |
1960 | p->mToolBarUpF = filterToolBar->y() > height()/2; | 1960 | p->mToolBarUpF = filterToolBar->y() > height()/2; |
1961 | else | 1961 | else |
1962 | p->mToolBarUpF = filterToolBar->x() > width()/2 ; | 1962 | p->mToolBarUpF = filterToolBar->x() > width()/2 ; |
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 | |||
2049 | if ( mView->viewManager()->journalView() ) | 2048 | if ( mView->viewManager()->journalView() ) |
2050 | mView->viewManager()->journalView()->checkModified(); | 2049 | mView->viewManager()->journalView()->checkModified(); |
2051 | if ( !mCalendarModifiedFlag ) { | 2050 | if ( !mCalendarModifiedFlag ) { |
2052 | qDebug("KO: Calendar not modified. Nothing saved."); | 2051 | qDebug("KO: Calendar not modified. Nothing saved."); |
2053 | return; | 2052 | return; |
2054 | } | 2053 | } |
2055 | if ( mSyncManager->blockSave() ) { | 2054 | if ( mSyncManager->blockSave() ) { |
2056 | slotModifiedChanged( true ); | 2055 | slotModifiedChanged( true ); |
2057 | return; | 2056 | return; |
2058 | } | 2057 | } |
2058 | #ifndef DESKTOP_VERSION | ||
2059 | QPEApplication::setTempScreenSaverMode ( QPEApplication::Disable ); | ||
2060 | #endif | ||
2059 | mSaveDelay = 0; | 2061 | mSaveDelay = 0; |
2060 | mSyncManager->setBlockSave(true); | 2062 | mSyncManager->setBlockSave(true); |
2061 | if ( mView->checkAllFileVersions() ) { | 2063 | if ( mView->checkAllFileVersions() ) { |
2062 | if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ | 2064 | if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ |
2063 | QDate reference ( 2000,1,1); | 2065 | QDate reference ( 2000,1,1); |
2064 | int daysTo = reference.daysTo ( QDate::currentDate() ); | 2066 | int daysTo = reference.daysTo ( QDate::currentDate() ); |
2065 | if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { | 2067 | if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { |
2066 | backupAllFiles(); | 2068 | backupAllFiles(); |
2067 | } | 2069 | } |
2068 | ; // KPimGlobalPrefs::instance()->mLastBackupDate | 2070 | ; // KPimGlobalPrefs::instance()->mLastBackupDate |
2069 | } | 2071 | } |
2070 | QTime neededSaveTime; | 2072 | QTime neededSaveTime; |
2071 | neededSaveTime.start(); | 2073 | neededSaveTime.start(); |
2072 | if ( !isMinimized () ) | 2074 | if ( !isMinimized () ) |
2073 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); | 2075 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); |
2074 | qDebug("KO: Start saving data to file!"); | 2076 | qDebug("KO: Start saving data to file!"); |
2075 | if ( mView->saveCalendars() ) | 2077 | if ( mView->saveCalendars() ) |
2076 | mCalendarModifiedFlag = false; | 2078 | mCalendarModifiedFlag = false; |
2077 | int msNeeded = neededSaveTime.elapsed(); | 2079 | int msNeeded = neededSaveTime.elapsed(); |
2078 | qDebug("KO: Needed %d ms for saving.",msNeeded ); | 2080 | qDebug("KO: Needed %d ms for saving.",msNeeded ); |
2079 | QString savemes; | 2081 | QString savemes; |
2080 | 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 ); |
2081 | if ( !isMinimized () ) | 2083 | if ( !isMinimized () ) |
2082 | setCaption(savemes); | 2084 | setCaption(savemes); |
2083 | else | 2085 | else |
2084 | qDebug(savemes); | 2086 | qDebug(savemes); |
2085 | } else { | 2087 | } else { |
2086 | setCaption(i18n("Saving cancelled!")); | 2088 | setCaption(i18n("Saving cancelled!")); |
2087 | mCalendarModifiedFlag = false; | 2089 | mCalendarModifiedFlag = false; |
2088 | slotModifiedChanged( true ); | 2090 | slotModifiedChanged( true ); |
2089 | } | 2091 | } |
2090 | mSyncManager->setBlockSave( false ); | 2092 | mSyncManager->setBlockSave( false ); |
2093 | #ifndef DESKTOP_VERSION | ||
2094 | QPEApplication::setTempScreenSaverMode ( QPEApplication::Enable ); | ||
2095 | #endif | ||
2091 | } | 2096 | } |
2092 | 2097 | ||
2093 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) | 2098 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) |
2094 | { | 2099 | { |
2095 | if ( !e->isAutoRepeat() ) { | 2100 | if ( !e->isAutoRepeat() ) { |
2096 | mFlagKeyPressed = false; | 2101 | mFlagKeyPressed = false; |
2097 | } | 2102 | } |
2098 | } | 2103 | } |
2099 | void MainWindow::keyPressEvent ( QKeyEvent * e ) | 2104 | void MainWindow::keyPressEvent ( QKeyEvent * e ) |
2100 | { | 2105 | { |
2101 | qApp->processEvents(); | 2106 | qApp->processEvents(); |
2102 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 2107 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
2103 | e->ignore(); | 2108 | e->ignore(); |
2104 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 2109 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
2105 | return; | 2110 | return; |
2106 | } | 2111 | } |
2107 | if (! e->isAutoRepeat() ) | 2112 | if (! e->isAutoRepeat() ) |
2108 | mFlagKeyPressed = true; | 2113 | mFlagKeyPressed = true; |
2109 | KOPrefs *p = KOPrefs::instance(); | 2114 | KOPrefs *p = KOPrefs::instance(); |
2110 | bool showSelectedDates = false; | 2115 | bool showSelectedDates = false; |
2111 | int size; | 2116 | int size; |
2112 | int pro = 0; | 2117 | int pro = 0; |
2113 | //qDebug("MainWindow::keyPressEvent "); | 2118 | //qDebug("MainWindow::keyPressEvent "); |
2114 | switch ( e->key() ) { | 2119 | switch ( e->key() ) { |
2115 | case Qt::Key_Right: | 2120 | case Qt::Key_Right: |
2116 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 2121 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
2117 | mView->goNextMonth(); | 2122 | mView->goNextMonth(); |
2118 | else | 2123 | else |
2119 | mView->goNext(); | 2124 | mView->goNext(); |
2120 | showSelectedDates = true; | 2125 | showSelectedDates = true; |
2121 | break; | 2126 | break; |
2122 | case Qt::Key_Left: | 2127 | case Qt::Key_Left: |
2123 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 2128 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
2124 | mView->goPreviousMonth(); | 2129 | mView->goPreviousMonth(); |
2125 | else | 2130 | else |
2126 | mView->goPrevious(); | 2131 | mView->goPrevious(); |
2127 | showSelectedDates = true; | 2132 | showSelectedDates = true; |
2128 | break; | 2133 | break; |
2129 | case Qt::Key_Down: | 2134 | case Qt::Key_Down: |
2130 | mView->viewManager()->agendaView()->scrollOneHourDown(); | 2135 | mView->viewManager()->agendaView()->scrollOneHourDown(); |
2131 | break; | 2136 | break; |
2132 | case Qt::Key_Up: | 2137 | case Qt::Key_Up: |
2133 | mView->viewManager()->agendaView()->scrollOneHourUp(); | 2138 | mView->viewManager()->agendaView()->scrollOneHourUp(); |
2134 | break; | 2139 | break; |
2135 | case Qt::Key_K: | 2140 | case Qt::Key_K: |
2136 | mView->viewManager()->showMonthViewWeek(); | 2141 | mView->viewManager()->showMonthViewWeek(); |
2137 | break; | 2142 | break; |
2138 | case Qt::Key_I: | 2143 | case Qt::Key_I: |
2139 | mView->showIncidence(); | 2144 | mView->showIncidence(); |
2140 | break; | 2145 | break; |
2141 | case Qt::Key_Delete: | 2146 | case Qt::Key_Delete: |
2142 | case Qt::Key_Backspace: | 2147 | case Qt::Key_Backspace: |
2143 | mView->deleteIncidence(); | 2148 | mView->deleteIncidence(); |
2144 | break; | 2149 | break; |
2145 | case Qt::Key_D: | 2150 | case Qt::Key_D: |
2146 | mView->viewManager()->showDayView(); | 2151 | mView->viewManager()->showDayView(); |
2147 | showSelectedDates = true; | 2152 | showSelectedDates = true; |
2148 | break; | 2153 | break; |
2149 | case Qt::Key_O: | 2154 | case Qt::Key_O: |
2150 | mView->toggleFilerEnabled( ); | 2155 | mView->toggleFilerEnabled( ); |
2151 | break; | 2156 | break; |
2152 | case Qt::Key_0: | 2157 | case Qt::Key_0: |
2153 | case Qt::Key_1: | 2158 | case Qt::Key_1: |
2154 | case Qt::Key_2: | 2159 | case Qt::Key_2: |
2155 | case Qt::Key_3: | 2160 | case Qt::Key_3: |
2156 | case Qt::Key_4: | 2161 | case Qt::Key_4: |
2157 | case Qt::Key_5: | 2162 | case Qt::Key_5: |
2158 | case Qt::Key_6: | 2163 | case Qt::Key_6: |
2159 | case Qt::Key_7: | 2164 | case Qt::Key_7: |
2160 | case Qt::Key_8: | 2165 | case Qt::Key_8: |
2161 | case Qt::Key_9: | 2166 | case Qt::Key_9: |
2162 | pro = e->key()-48; | 2167 | pro = e->key()-48; |
2163 | if ( pro == 0 ) | 2168 | if ( pro == 0 ) |
2164 | pro = 10; | 2169 | pro = 10; |
2165 | if ( e->state() == Qt::ControlButton) | 2170 | if ( e->state() == Qt::ControlButton) |
2166 | pro += 10; | 2171 | pro += 10; |
2167 | break; | 2172 | break; |
2168 | case Qt::Key_M: | 2173 | case Qt::Key_M: |
2169 | mView->viewManager()->showMonthView(); | 2174 | mView->viewManager()->showMonthView(); |
2170 | showSelectedDates = true; | 2175 | showSelectedDates = true; |
2171 | break; | 2176 | break; |
2172 | case Qt::Key_Insert: | 2177 | case Qt::Key_Insert: |
2173 | mView->newEvent(); | 2178 | mView->newEvent(); |
2174 | break; | 2179 | break; |
2175 | case Qt::Key_S : | 2180 | case Qt::Key_S : |
2176 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 2181 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
2177 | mView->newSubTodo(); | 2182 | mView->newSubTodo(); |
2178 | else | 2183 | else |
2179 | mView->dialogManager()->showSearchDialog(); | 2184 | mView->dialogManager()->showSearchDialog(); |
2180 | break; | 2185 | break; |
2181 | case Qt::Key_Y : | 2186 | case Qt::Key_Y : |
2182 | case Qt::Key_Z : | 2187 | case Qt::Key_Z : |
2183 | mView->viewManager()->showWorkWeekView(); | 2188 | mView->viewManager()->showWorkWeekView(); |
2184 | showSelectedDates = true; | 2189 | showSelectedDates = true; |
2185 | break; | 2190 | break; |
2186 | case Qt::Key_U : | 2191 | case Qt::Key_U : |
@@ -2413,194 +2418,200 @@ void MainWindow::selectFilterPopup( int fil ) | |||
2413 | void MainWindow::configureToolBar( int item ) | 2418 | void MainWindow::configureToolBar( int item ) |
2414 | { | 2419 | { |
2415 | 2420 | ||
2416 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); | 2421 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); |
2417 | KOPrefs *p = KOPrefs::instance(); | 2422 | KOPrefs *p = KOPrefs::instance(); |
2418 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); | 2423 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); |
2419 | p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 ); | 2424 | p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 ); |
2420 | p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 ); | 2425 | p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 ); |
2421 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); | 2426 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); |
2422 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); | 2427 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); |
2423 | p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 ); | 2428 | p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 ); |
2424 | p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 ); | 2429 | p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 ); |
2425 | p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 ); | 2430 | p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 ); |
2426 | p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 ); | 2431 | p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 ); |
2427 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); | 2432 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); |
2428 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); | 2433 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); |
2429 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); | 2434 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); |
2430 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); | 2435 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); |
2431 | p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 ); | 2436 | p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 ); |
2432 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); | 2437 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); |
2433 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); | 2438 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); |
2434 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); | 2439 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); |
2435 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); | 2440 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); |
2436 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); | 2441 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); |
2437 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); | 2442 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); |
2438 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); | 2443 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); |
2439 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); | 2444 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); |
2440 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); | 2445 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); |
2441 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); | 2446 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); |
2442 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); | 2447 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); |
2443 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); | 2448 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); |
2444 | p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 ); | 2449 | p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 ); |
2445 | // initActions(); | 2450 | // initActions(); |
2446 | setCaption ( i18n("Toolbar changes needs a restart!") ); | 2451 | setCaption ( i18n("Toolbar changes needs a restart!") ); |
2447 | } | 2452 | } |
2448 | void MainWindow::setCaption ( const QString & c ) | 2453 | void MainWindow::setCaption ( const QString & c ) |
2449 | { | 2454 | { |
2450 | QString cap = c; | 2455 | QString cap = c; |
2451 | cap.replace( QRegExp("\n"), " " ); | 2456 | cap.replace( QRegExp("\n"), " " ); |
2452 | cap = cap.stripWhiteSpace(); | 2457 | cap = cap.stripWhiteSpace(); |
2453 | if ( cap.isEmpty() ) | 2458 | if ( cap.isEmpty() ) |
2454 | cap = "KO/Pi"; | 2459 | cap = "KO/Pi"; |
2455 | QWidget::setCaption( cap ); | 2460 | QWidget::setCaption( cap ); |
2456 | } | 2461 | } |
2457 | void MainWindow::setCaptionToDates() | 2462 | void MainWindow::setCaptionToDates() |
2458 | { | 2463 | { |
2459 | QString selDates; | 2464 | QString selDates; |
2460 | QDate date = mView->startDate(); | 2465 | QDate date = mView->startDate(); |
2461 | if ( ! date.isValid() ) { | 2466 | if ( ! date.isValid() ) { |
2462 | setCaption(""); | 2467 | setCaption(""); |
2463 | return; | 2468 | return; |
2464 | } | 2469 | } |
2465 | selDates = KGlobal::locale()->formatDate( date, true); | 2470 | selDates = KGlobal::locale()->formatDate( date, true); |
2466 | if (mView->startDate() < mView->endDate() ) | 2471 | if (mView->startDate() < mView->endDate() ) |
2467 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); | 2472 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); |
2468 | else { | 2473 | else { |
2469 | QString addString; | 2474 | QString addString; |
2470 | if ( date == QDateTime::currentDateTime().date() ) | 2475 | if ( date == QDateTime::currentDateTime().date() ) |
2471 | addString = i18n("Today"); | 2476 | addString = i18n("Today"); |
2472 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) | 2477 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) |
2473 | addString = i18n("Tomorrow"); | 2478 | addString = i18n("Tomorrow"); |
2474 | if ( !addString.isEmpty() ) | 2479 | if ( !addString.isEmpty() ) |
2475 | selDates = addString+", "+selDates ; | 2480 | selDates = addString+", "+selDates ; |
2476 | } | 2481 | } |
2477 | setCaption( i18n("Dates: ") + selDates ); | 2482 | setCaption( i18n("Dates: ") + selDates ); |
2478 | 2483 | ||
2479 | } | 2484 | } |
2480 | void MainWindow::showConfigureAgenda( ) | 2485 | void MainWindow::showConfigureAgenda( ) |
2481 | { | 2486 | { |
2482 | int iii; | 2487 | int iii; |
2483 | for ( iii = 1;iii<= 10 ;++iii ){ | 2488 | for ( iii = 1;iii<= 10 ;++iii ){ |
2484 | configureAgendaMenu->setItemChecked( (iii+1)*2, false ); | 2489 | configureAgendaMenu->setItemChecked( (iii+1)*2, false ); |
2485 | } | 2490 | } |
2486 | configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); | 2491 | configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); |
2487 | } | 2492 | } |
2488 | void MainWindow::configureAgenda( int item ) | 2493 | void MainWindow::configureAgenda( int item ) |
2489 | { | 2494 | { |
2490 | if ( KOPrefs::instance()->mHourSize == item ) | 2495 | if ( KOPrefs::instance()->mHourSize == item ) |
2491 | return; | 2496 | return; |
2492 | KOPrefs::instance()->mHourSize=item; | 2497 | KOPrefs::instance()->mHourSize=item; |
2493 | mView->viewManager()->agendaView()->updateConfig(); | 2498 | mView->viewManager()->agendaView()->updateConfig(); |
2494 | } | 2499 | } |
2495 | 2500 | ||
2496 | void MainWindow::saveCalendar() | 2501 | void MainWindow::saveCalendar() |
2497 | { | 2502 | { |
2498 | QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; | 2503 | QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; |
2499 | if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) | 2504 | if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) |
2500 | bupDir = KGlobalSettings::backupDataDir(); | 2505 | bupDir = KGlobalSettings::backupDataDir(); |
2501 | bupDir = KGlobal::formatMessage ( bupDir, 0 ); | 2506 | bupDir = KGlobal::formatMessage ( bupDir, 0 ); |
2502 | QString bupHint; | 2507 | QString bupHint; |
2503 | if ( !KPimGlobalPrefs::instance()->mBackupEnabled ) | 2508 | if ( !KPimGlobalPrefs::instance()->mBackupEnabled ) |
2504 | 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!)"); |
2505 | 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; |
2506 | bool enabled = KPimGlobalPrefs::instance()->mBackupEnabled; | 2511 | bool enabled = KPimGlobalPrefs::instance()->mBackupEnabled; |
2507 | KPimGlobalPrefs::instance()->mBackupEnabled = false; | 2512 | KPimGlobalPrefs::instance()->mBackupEnabled = false; |
2508 | save(); | 2513 | save(); |
2514 | #ifndef DESKTOP_VERSION | ||
2515 | QPEApplication::setTempScreenSaverMode ( QPEApplication::Disable ); | ||
2516 | #endif | ||
2509 | KPimGlobalPrefs::instance()->mBackupEnabled = enabled; | 2517 | KPimGlobalPrefs::instance()->mBackupEnabled = enabled; |
2510 | backupAllFiles(); | 2518 | backupAllFiles(); |
2519 | #ifndef DESKTOP_VERSION | ||
2520 | QPEApplication::setTempScreenSaverMode ( QPEApplication::Enable ); | ||
2521 | #endif | ||
2511 | } | 2522 | } |
2512 | void MainWindow::loadCalendar() | 2523 | void MainWindow::loadCalendar() |
2513 | { | 2524 | { |
2514 | 2525 | ||
2515 | 2526 | ||
2516 | #if 0 | 2527 | #if 0 |
2517 | QString fn = KOPrefs::instance()->mLastLoadFile; | 2528 | QString fn = KOPrefs::instance()->mLastLoadFile; |
2518 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); | 2529 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); |
2519 | 2530 | ||
2520 | if ( fn == "" ) | 2531 | if ( fn == "" ) |
2521 | return; | 2532 | return; |
2522 | QFileInfo info; | 2533 | QFileInfo info; |
2523 | info.setFile( fn ); | 2534 | info.setFile( fn ); |
2524 | QString mess; | 2535 | QString mess; |
2525 | bool loadbup = true; | 2536 | bool loadbup = true; |
2526 | if ( info. exists() ) { | 2537 | if ( info. exists() ) { |
2527 | 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 )); |
2528 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", | 2539 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", |
2529 | mess, | 2540 | mess, |
2530 | i18n("Load!"), i18n("Cancel"), 0, | 2541 | i18n("Load!"), i18n("Cancel"), 0, |
2531 | 0, 1 ); | 2542 | 0, 1 ); |
2532 | if ( result != 0 ) { | 2543 | if ( result != 0 ) { |
2533 | loadbup = false; | 2544 | loadbup = false; |
2534 | } | 2545 | } |
2535 | } else { | 2546 | } else { |
2536 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2547 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2537 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, | 2548 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, |
2538 | 0, 1 ); | 2549 | 0, 1 ); |
2539 | 2550 | ||
2540 | return; | 2551 | return; |
2541 | } | 2552 | } |
2542 | if ( loadbup ) { | 2553 | if ( loadbup ) { |
2543 | mView->openCalendar( fn ); | 2554 | mView->openCalendar( fn ); |
2544 | KOPrefs::instance()->mLastLoadFile = fn; | 2555 | KOPrefs::instance()->mLastLoadFile = fn; |
2545 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; | 2556 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; |
2546 | setCaption(mess); | 2557 | setCaption(mess); |
2547 | } | 2558 | } |
2548 | #endif | 2559 | #endif |
2549 | 2560 | ||
2550 | } | 2561 | } |
2551 | void MainWindow::quickImportIcal() | 2562 | void MainWindow::quickImportIcal() |
2552 | { | 2563 | { |
2553 | importFile( KOPrefs::instance()->mLastImportFile, false ); | 2564 | importFile( KOPrefs::instance()->mLastImportFile, false ); |
2554 | } | 2565 | } |
2555 | void MainWindow::importFile( QString fn, bool quick ) | 2566 | void MainWindow::importFile( QString fn, bool quick ) |
2556 | { | 2567 | { |
2557 | QFileInfo info; | 2568 | QFileInfo info; |
2558 | info.setFile( fn ); | 2569 | info.setFile( fn ); |
2559 | QString mess; | 2570 | QString mess; |
2560 | if ( !info. exists() ) { | 2571 | if ( !info. exists() ) { |
2561 | 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)); |
2562 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2573 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2563 | mess ); | 2574 | mess ); |
2564 | return; | 2575 | return; |
2565 | } | 2576 | } |
2566 | int result = 0; | 2577 | int result = 0; |
2567 | if ( !quick ) { | 2578 | if ( !quick ) { |
2568 | 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 )); |
2569 | result = QMessageBox::warning( this, "KO/Pi: Warning!", | 2580 | result = QMessageBox::warning( this, "KO/Pi: Warning!", |
2570 | mess, | 2581 | mess, |
2571 | "Import", "Cancel", 0, | 2582 | "Import", "Cancel", 0, |
2572 | 0, 1 ); | 2583 | 0, 1 ); |
2573 | } | 2584 | } |
2574 | if ( result == 0 ) { | 2585 | if ( result == 0 ) { |
2575 | if ( mView->openCalendar( fn, true )) { | 2586 | if ( mView->openCalendar( fn, true )) { |
2576 | KOPrefs::instance()->mLastImportFile = fn; | 2587 | KOPrefs::instance()->mLastImportFile = fn; |
2577 | setCaption(i18n("Imported file successfully")); | 2588 | setCaption(i18n("Imported file successfully")); |
2578 | } else { | 2589 | } else { |
2579 | setCaption(i18n("Error importing file")); | 2590 | setCaption(i18n("Error importing file")); |
2580 | } | 2591 | } |
2581 | mView->updateView(); | 2592 | mView->updateView(); |
2582 | } | 2593 | } |
2583 | } | 2594 | } |
2584 | 2595 | ||
2585 | void MainWindow::importIcal() | 2596 | void MainWindow::importIcal() |
2586 | { | 2597 | { |
2587 | 2598 | ||
2588 | QString fn =KOPrefs::instance()->mLastImportFile; | 2599 | QString fn =KOPrefs::instance()->mLastImportFile; |
2589 | 2600 | ||
2590 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); | 2601 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); |
2591 | if ( fn == "" ) | 2602 | if ( fn == "" ) |
2592 | return; | 2603 | return; |
2593 | importFile( fn, true ); | 2604 | importFile( fn, true ); |
2594 | 2605 | ||
2595 | } | 2606 | } |
2596 | void MainWindow::exportCalendar( bool iCalFormat ) | 2607 | void MainWindow::exportCalendar( bool iCalFormat ) |
2597 | { | 2608 | { |
2598 | QString fn = KOPrefs::instance()->mLastVcalFile; | 2609 | QString fn = KOPrefs::instance()->mLastVcalFile; |
2599 | if ( iCalFormat ) { | 2610 | if ( iCalFormat ) { |
2600 | fn = QDir::homeDirPath()+"/kopiexport.ics"; | 2611 | fn = QDir::homeDirPath()+"/kopiexport.ics"; |
2601 | fn = KFileDialog::getSaveFileName( fn, i18n("Export iCal filename(*.ics)"), this ); | 2612 | fn = KFileDialog::getSaveFileName( fn, i18n("Export iCal filename(*.ics)"), this ); |
2602 | } | 2613 | } |
2603 | else | 2614 | else |
2604 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); | 2615 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); |
2605 | if ( fn == "" ) | 2616 | if ( fn == "" ) |
2606 | return; | 2617 | return; |
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index f7d40ad..70a7711 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp | |||
@@ -1,283 +1,291 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <kglobal.h> | 21 | #include <kglobal.h> |
22 | #include <kglobalsettings.h> | 22 | #include <kglobalsettings.h> |
23 | #include <klocale.h> | 23 | #include <klocale.h> |
24 | #include <kdebug.h> | 24 | #include <kdebug.h> |
25 | #include <qregexp.h> | 25 | #include <qregexp.h> |
26 | #include <qfileinfo.h> | 26 | #include <qfileinfo.h> |
27 | 27 | ||
28 | #include "calendarlocal.h" | 28 | #include "calendarlocal.h" |
29 | #include "icalformat.h" | 29 | #include "icalformat.h" |
30 | #include "todo.h" | 30 | #include "todo.h" |
31 | 31 | ||
32 | #ifndef DESKTOP_VERSION | ||
33 | #include <qpe/qpeapplication.h> | ||
34 | #endif | ||
35 | |||
32 | #define SAVETIMER_TIMEOUT_SECONDS 300 | 36 | #define SAVETIMER_TIMEOUT_SECONDS 300 |
33 | //#define SAVETIMER_TIMEOUT_SECONDS 8 | 37 | //#define SAVETIMER_TIMEOUT_SECONDS 8 |
34 | #define SAVETIMER_TIMEOUT_RETRY_SECONDS 5 | 38 | #define SAVETIMER_TIMEOUT_RETRY_SECONDS 5 |
35 | 39 | ||
36 | using namespace KCal; | 40 | using namespace KCal; |
37 | 41 | ||
38 | Todo::Todo(): QObject(), Incidence() | 42 | Todo::Todo(): QObject(), Incidence() |
39 | { | 43 | { |
40 | // mStatus = TENTATIVE; | 44 | // mStatus = TENTATIVE; |
41 | 45 | ||
42 | mHasDueDate = false; | 46 | mHasDueDate = false; |
43 | setHasStartDate( false ); | 47 | setHasStartDate( false ); |
44 | mCompleted = getEvenTime(QDateTime::currentDateTime()); | 48 | mCompleted = getEvenTime(QDateTime::currentDateTime()); |
45 | mHasCompletedDate = false; | 49 | mHasCompletedDate = false; |
46 | mPercentComplete = 0; | 50 | mPercentComplete = 0; |
47 | mRunning = false; | 51 | mRunning = false; |
48 | mRunSaveTimer = 0; | 52 | mRunSaveTimer = 0; |
49 | setFloats( true ); | 53 | setFloats( true ); |
50 | mCurrentTimerDelay = 0; | 54 | mCurrentTimerDelay = 0; |
51 | } | 55 | } |
52 | 56 | ||
53 | Todo::Todo(const Todo &t) : QObject(),Incidence(t) | 57 | Todo::Todo(const Todo &t) : QObject(),Incidence(t) |
54 | { | 58 | { |
55 | mDtDue = t.mDtDue; | 59 | mDtDue = t.mDtDue; |
56 | mHasDueDate = t.mHasDueDate; | 60 | mHasDueDate = t.mHasDueDate; |
57 | mCompleted = t.mCompleted; | 61 | mCompleted = t.mCompleted; |
58 | mHasCompletedDate = t.mHasCompletedDate; | 62 | mHasCompletedDate = t.mHasCompletedDate; |
59 | mPercentComplete = t.mPercentComplete; | 63 | mPercentComplete = t.mPercentComplete; |
60 | mRunning = false; | 64 | mRunning = false; |
61 | mRunSaveTimer = 0; | 65 | mRunSaveTimer = 0; |
62 | mCurrentTimerDelay = 0; | 66 | mCurrentTimerDelay = 0; |
63 | } | 67 | } |
64 | 68 | ||
65 | Todo::~Todo() | 69 | Todo::~Todo() |
66 | { | 70 | { |
67 | setRunning( false ); | 71 | setRunning( false ); |
68 | //qDebug("Todo::~Todo() "); | 72 | //qDebug("Todo::~Todo() "); |
69 | } | 73 | } |
70 | 74 | ||
71 | void Todo::setRunningFalse( QString s ) | 75 | void Todo::setRunningFalse( QString s ) |
72 | { | 76 | { |
73 | if ( ! mRunning ) | 77 | if ( ! mRunning ) |
74 | return; | 78 | return; |
75 | mRunning = false; | 79 | mRunning = false; |
76 | if ( mRunSaveTimer ) | 80 | if ( mRunSaveTimer ) |
77 | mRunSaveTimer->stop(); | 81 | mRunSaveTimer->stop(); |
78 | saveRunningInfoToFile( s ); | 82 | saveRunningInfoToFile( s ); |
79 | } | 83 | } |
80 | void Todo::stopRunning() | 84 | void Todo::stopRunning() |
81 | { | 85 | { |
82 | if ( !mRunning ) | 86 | if ( !mRunning ) |
83 | return; | 87 | return; |
84 | if ( mRunSaveTimer ) | 88 | if ( mRunSaveTimer ) |
85 | mRunSaveTimer->stop(); | 89 | mRunSaveTimer->stop(); |
86 | mRunning = false; | 90 | mRunning = false; |
87 | } | 91 | } |
88 | void Todo::setRunning( bool run ) | 92 | void Todo::setRunning( bool run ) |
89 | { | 93 | { |
90 | if ( run == mRunning ) | 94 | if ( run == mRunning ) |
91 | return; | 95 | return; |
92 | //qDebug("Todo::setRunning %d ", run); | 96 | //qDebug("Todo::setRunning %d ", run); |
93 | if ( !mRunSaveTimer ) { | 97 | if ( !mRunSaveTimer ) { |
94 | mRunSaveTimer = new QTimer ( this ); | 98 | mRunSaveTimer = new QTimer ( this ); |
95 | connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( timerSlotSaveRunningInfoToFile() ) ); | 99 | connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( timerSlotSaveRunningInfoToFile() ) ); |
96 | } | 100 | } |
97 | mRunning = run; | 101 | mRunning = run; |
98 | mRunLastSave = QDateTime::currentDateTime(); | 102 | mRunLastSave = QDateTime::currentDateTime(); |
99 | if ( mRunning ) { | 103 | if ( mRunning ) { |
100 | restartSaveTimer( SAVETIMER_TIMEOUT_SECONDS ); | 104 | restartSaveTimer( SAVETIMER_TIMEOUT_SECONDS ); |
101 | mRunStart = QDateTime::currentDateTime(); | 105 | mRunStart = QDateTime::currentDateTime(); |
102 | } else { | 106 | } else { |
103 | mRunSaveTimer->stop(); | 107 | mRunSaveTimer->stop(); |
104 | saveRunningInfoToFile(); | 108 | saveRunningInfoToFile(); |
105 | } | 109 | } |
106 | } | 110 | } |
107 | void Todo::saveRunningInfo( QString comment, QDateTime start, QDateTime end ) | 111 | void Todo::saveRunningInfo( QString comment, QDateTime start, QDateTime end ) |
108 | { | 112 | { |
109 | if ( !mRunning) return; | 113 | if ( !mRunning) return; |
110 | mRunning = false; | 114 | mRunning = false; |
111 | mRunStart = start; | 115 | mRunStart = start; |
112 | mRunEnd = end; | 116 | mRunEnd = end; |
113 | saveRunningInfoToFile( comment ); | 117 | saveRunningInfoToFile( comment ); |
114 | } | 118 | } |
115 | void Todo::restartSaveTimer( int secs ) | 119 | void Todo::restartSaveTimer( int secs ) |
116 | { | 120 | { |
117 | mRunSaveTimer->start( secs * 1000 ); | 121 | mRunSaveTimer->start( secs * 1000 ); |
118 | mRunLastSave = QDateTime::currentDateTime(); | 122 | mRunLastSave = QDateTime::currentDateTime(); |
119 | mCurrentTimerDelay = secs; | 123 | mCurrentTimerDelay = secs; |
120 | } | 124 | } |
121 | void Todo::timerSlotSaveRunningInfoToFile() | 125 | void Todo::timerSlotSaveRunningInfoToFile() |
122 | { | 126 | { |
123 | mRunEnd = QDateTime::currentDateTime(); | 127 | mRunEnd = QDateTime::currentDateTime(); |
124 | int secsTo = mRunLastSave.secsTo( mRunEnd ); | 128 | int secsTo = mRunLastSave.secsTo( mRunEnd ); |
125 | //if( secsTo == 8 ) ++secsTo; | 129 | //if( secsTo == 8 ) ++secsTo; |
126 | qDebug("KO Todo::saveTimerTimeout %d %d", secsTo, mCurrentTimerDelay ); | 130 | qDebug("KO Todo::saveTimerTimeout %d %d", secsTo, mCurrentTimerDelay ); |
127 | if ( secsTo > mCurrentTimerDelay ) { | 131 | if ( secsTo > mCurrentTimerDelay ) { |
128 | qDebug("KO Todo::saveTimerTimeout restart %d ", SAVETIMER_TIMEOUT_RETRY_SECONDS ); | 132 | qDebug("KO Todo::saveTimerTimeout restart %d ", SAVETIMER_TIMEOUT_RETRY_SECONDS ); |
129 | restartSaveTimer( SAVETIMER_TIMEOUT_RETRY_SECONDS ); | 133 | restartSaveTimer( SAVETIMER_TIMEOUT_RETRY_SECONDS ); |
130 | return; | 134 | return; |
131 | } | 135 | } |
132 | int msecs = mRunLastSave.time().msecsTo( mRunEnd.time()); | 136 | int msecs = mRunLastSave.time().msecsTo( mRunEnd.time()); |
133 | if ( msecs < 0 ) { | 137 | if ( msecs < 0 ) { |
134 | restartSaveTimer( SAVETIMER_TIMEOUT_RETRY_SECONDS ); | 138 | restartSaveTimer( SAVETIMER_TIMEOUT_RETRY_SECONDS ); |
135 | return; | 139 | return; |
136 | } | 140 | } |
137 | // qDebug("KO Todo::saveTimerTimeout restarting! millisecs %d", msecs - ( ( mCurrentTimerDelay * 1000 ) + 50 ) ); | 141 | // qDebug("KO Todo::saveTimerTimeout restarting! millisecs %d", msecs - ( ( mCurrentTimerDelay * 1000 ) + 50 ) ); |
138 | if ( msecs > ( ( mCurrentTimerDelay * 1000 ) + 50 )) { | 142 | if ( msecs > ( ( mCurrentTimerDelay * 1000 ) + 50 )) { |
139 | qDebug("KO Todo::saveTimerTimeout restarting! millisecs %d", msecs - ( ( mCurrentTimerDelay * 1000 ) + 50 ) ); | 143 | qDebug("KO Todo::saveTimerTimeout restarting! millisecs %d", msecs - ( ( mCurrentTimerDelay * 1000 ) + 50 ) ); |
140 | restartSaveTimer( SAVETIMER_TIMEOUT_RETRY_SECONDS ); | 144 | restartSaveTimer( SAVETIMER_TIMEOUT_RETRY_SECONDS ); |
141 | return; | 145 | return; |
142 | |||
143 | } | 146 | } |
144 | restartSaveTimer( SAVETIMER_TIMEOUT_SECONDS ); | 147 | restartSaveTimer( SAVETIMER_TIMEOUT_SECONDS ); |
145 | saveRunningInfoToFile( QString::null ); | 148 | saveRunningInfoToFile( QString::null ); |
146 | } | 149 | } |
147 | void Todo::saveRunningInfoToFile() | 150 | void Todo::saveRunningInfoToFile() |
148 | { | 151 | { |
149 | mRunEnd = QDateTime::currentDateTime(); | 152 | mRunEnd = QDateTime::currentDateTime(); |
150 | saveRunningInfoToFile( QString::null ); | 153 | saveRunningInfoToFile( QString::null ); |
151 | } | 154 | } |
152 | void Todo::saveRunningInfoToFile( QString comment ) | 155 | void Todo::saveRunningInfoToFile( QString comment ) |
153 | { | 156 | { |
157 | #ifndef DESKTOP_VERSION | ||
158 | QPEApplication::setTempScreenSaverMode ( QPEApplication::Disable ); | ||
159 | #endif | ||
154 | //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1()); | 160 | //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1()); |
155 | if ( mRunStart.secsTo ( mRunEnd) < 15 ) { | 161 | if ( mRunStart.secsTo ( mRunEnd) < 15 ) { |
156 | qDebug("Running time < 15 seconds. Skipped. "); | 162 | qDebug("Running time < 15 seconds. Skipped. "); |
157 | return; | 163 | return; |
158 | } | 164 | } |
159 | QString dir = KGlobalSettings::timeTrackerDir(); | 165 | QString dir = KGlobalSettings::timeTrackerDir(); |
160 | //qDebug("%s ", dir.latin1()); | 166 | //qDebug("%s ", dir.latin1()); |
161 | QString file = "%1%2%3-%4%5%6-"; | 167 | QString file = "%1%2%3-%4%5%6-"; |
162 | file = file.arg( mRunStart.date().year(), 4).arg( mRunStart.date().month(),2 ).arg( mRunStart.date().day(), 2 ).arg( mRunStart.time().hour(),2 ).arg( mRunStart.time().minute(),2 ).arg( mRunStart.time().second(),2 ); | 168 | file = file.arg( mRunStart.date().year(), 4).arg( mRunStart.date().month(),2 ).arg( mRunStart.date().day(), 2 ).arg( mRunStart.time().hour(),2 ).arg( mRunStart.time().minute(),2 ).arg( mRunStart.time().second(),2 ); |
163 | file.replace ( QRegExp (" "), "0" ); | 169 | file.replace ( QRegExp (" "), "0" ); |
164 | file += uid(); | 170 | file += uid(); |
165 | //qDebug("File %s ",file.latin1() ); | 171 | //qDebug("File %s ",file.latin1() ); |
166 | CalendarLocal cal; | 172 | CalendarLocal cal; |
167 | cal.setLocalTime(); | 173 | cal.setLocalTime(); |
168 | Todo * to = (Todo*) clone(); | 174 | Todo * to = (Todo*) clone(); |
169 | to->setFloats( false ); | 175 | to->setFloats( false ); |
170 | to->setDtStart( mRunStart ); | 176 | to->setDtStart( mRunStart ); |
171 | to->setHasStartDate( true ); | 177 | to->setHasStartDate( true ); |
172 | to->setDtDue( mRunEnd ); | 178 | to->setDtDue( mRunEnd ); |
173 | to->setHasDueDate( true ); | 179 | to->setHasDueDate( true ); |
174 | to->setUid( file ); | 180 | to->setUid( file ); |
175 | if ( !comment.isEmpty() ) { | 181 | if ( !comment.isEmpty() ) { |
176 | QString des = to->description(); | 182 | QString des = to->description(); |
177 | if ( des.isEmpty () ) | 183 | if ( des.isEmpty () ) |
178 | to->setDescription( "TT-Note: " + comment ); | 184 | to->setDescription( "TT-Note: " + comment ); |
179 | else | 185 | else |
180 | to->setDescription( "TT-Note: " + comment +"\n" + des ); | 186 | to->setDescription( "TT-Note: " + comment +"\n" + des ); |
181 | } | 187 | } |
182 | cal.addIncidence( to ); | 188 | cal.addIncidence( to ); |
183 | ICalFormat format( false ); | 189 | ICalFormat format( false ); |
184 | file = dir +"/" +file +".ics"; | 190 | file = dir +"/" +file +".ics"; |
185 | format.save( &cal, file ); | 191 | format.save( &cal, file ); |
186 | saveParents(); | 192 | saveParents(); |
187 | 193 | #ifndef DESKTOP_VERSION | |
194 | QPEApplication::setTempScreenSaverMode ( QPEApplication::Enable ); | ||
195 | #endif | ||
188 | } | 196 | } |
189 | void Todo::saveParents() | 197 | void Todo::saveParents() |
190 | { | 198 | { |
191 | if (!relatedTo() ) | 199 | if (!relatedTo() ) |
192 | return; | 200 | return; |
193 | Incidence * inc = relatedTo(); | 201 | Incidence * inc = relatedTo(); |
194 | if ( inc->typeID() != todoID ) | 202 | if ( inc->typeID() != todoID ) |
195 | return; | 203 | return; |
196 | Todo* to = (Todo*)inc; | 204 | Todo* to = (Todo*)inc; |
197 | bool saveTodo = false; | 205 | bool saveTodo = false; |
198 | QString file = KGlobalSettings::timeTrackerDir() + "/"+ to->uid() + ".ics"; | 206 | QString file = KGlobalSettings::timeTrackerDir() + "/"+ to->uid() + ".ics"; |
199 | QFileInfo fi ( file ); | 207 | QFileInfo fi ( file ); |
200 | if ( fi.exists() ) { | 208 | if ( fi.exists() ) { |
201 | if ( fi.lastModified () < to->lastModified ()) | 209 | if ( fi.lastModified () < to->lastModified ()) |
202 | saveTodo = true; | 210 | saveTodo = true; |
203 | } else { | 211 | } else { |
204 | saveTodo = true; | 212 | saveTodo = true; |
205 | } | 213 | } |
206 | if ( saveTodo ) { | 214 | if ( saveTodo ) { |
207 | CalendarLocal cal; | 215 | CalendarLocal cal; |
208 | cal.setLocalTime(); | 216 | cal.setLocalTime(); |
209 | Todo * par = (Todo *) to->clone(); | 217 | Todo * par = (Todo *) to->clone(); |
210 | cal.addIncidence( par ); | 218 | cal.addIncidence( par ); |
211 | ICalFormat format( false ); | 219 | ICalFormat format( false ); |
212 | format.save( &cal, file ); | 220 | format.save( &cal, file ); |
213 | } | 221 | } |
214 | to->saveParents(); | 222 | to->saveParents(); |
215 | } | 223 | } |
216 | 224 | ||
217 | int Todo::runTime() | 225 | int Todo::runTime() |
218 | { | 226 | { |
219 | if ( !mRunning ) | 227 | if ( !mRunning ) |
220 | return 0; | 228 | return 0; |
221 | return mRunStart.secsTo( QDateTime::currentDateTime() ); | 229 | return mRunStart.secsTo( QDateTime::currentDateTime() ); |
222 | } | 230 | } |
223 | bool Todo::hasRunningSub() | 231 | bool Todo::hasRunningSub() |
224 | { | 232 | { |
225 | if ( mRunning ) | 233 | if ( mRunning ) |
226 | return true; | 234 | return true; |
227 | Incidence *aTodo; | 235 | Incidence *aTodo; |
228 | for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { | 236 | for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { |
229 | if ( ((Todo*)aTodo)->hasRunningSub() ) | 237 | if ( ((Todo*)aTodo)->hasRunningSub() ) |
230 | return true; | 238 | return true; |
231 | } | 239 | } |
232 | return false; | 240 | return false; |
233 | } | 241 | } |
234 | Incidence *Todo::clone() | 242 | Incidence *Todo::clone() |
235 | { | 243 | { |
236 | return new Todo(*this); | 244 | return new Todo(*this); |
237 | } | 245 | } |
238 | 246 | ||
239 | bool Todo::contains ( Todo* from ) | 247 | bool Todo::contains ( Todo* from ) |
240 | { | 248 | { |
241 | 249 | ||
242 | if ( !from->summary().isEmpty() ) | 250 | if ( !from->summary().isEmpty() ) |
243 | if ( !summary().startsWith( from->summary() )) | 251 | if ( !summary().startsWith( from->summary() )) |
244 | return false; | 252 | return false; |
245 | if ( from->hasStartDate() ) { | 253 | if ( from->hasStartDate() ) { |
246 | if ( !hasStartDate() ) | 254 | if ( !hasStartDate() ) |
247 | return false; | 255 | return false; |
248 | if ( from->dtStart() != dtStart()) | 256 | if ( from->dtStart() != dtStart()) |
249 | return false; | 257 | return false; |
250 | } | 258 | } |
251 | if ( from->hasDueDate() ){ | 259 | if ( from->hasDueDate() ){ |
252 | if ( !hasDueDate() ) | 260 | if ( !hasDueDate() ) |
253 | return false; | 261 | return false; |
254 | if ( from->dtDue() != dtDue()) | 262 | if ( from->dtDue() != dtDue()) |
255 | return false; | 263 | return false; |
256 | } | 264 | } |
257 | if ( !from->location().isEmpty() ) | 265 | if ( !from->location().isEmpty() ) |
258 | if ( !location().startsWith( from->location() ) ) | 266 | if ( !location().startsWith( from->location() ) ) |
259 | return false; | 267 | return false; |
260 | if ( !from->description().isEmpty() ) | 268 | if ( !from->description().isEmpty() ) |
261 | if ( !description().startsWith( from->description() )) | 269 | if ( !description().startsWith( from->description() )) |
262 | return false; | 270 | return false; |
263 | if ( from->alarms().count() ) { | 271 | if ( from->alarms().count() ) { |
264 | Alarm *a = from->alarms().first(); | 272 | Alarm *a = from->alarms().first(); |
265 | if ( a->enabled() ){ | 273 | if ( a->enabled() ){ |
266 | if ( !alarms().count() ) | 274 | if ( !alarms().count() ) |
267 | return false; | 275 | return false; |
268 | Alarm *b = alarms().first(); | 276 | Alarm *b = alarms().first(); |
269 | if( ! b->enabled() ) | 277 | if( ! b->enabled() ) |
270 | return false; | 278 | return false; |
271 | if ( ! (a->offset() == b->offset() )) | 279 | if ( ! (a->offset() == b->offset() )) |
272 | return false; | 280 | return false; |
273 | } | 281 | } |
274 | } | 282 | } |
275 | 283 | ||
276 | QStringList cat = categories(); | 284 | QStringList cat = categories(); |
277 | QStringList catFrom = from->categories(); | 285 | QStringList catFrom = from->categories(); |
278 | QString nCat; | 286 | QString nCat; |
279 | unsigned int iii; | 287 | unsigned int iii; |
280 | for ( iii = 0; iii < catFrom.count();++iii ) { | 288 | for ( iii = 0; iii < catFrom.count();++iii ) { |
281 | nCat = catFrom[iii]; | 289 | nCat = catFrom[iii]; |
282 | if ( !nCat.isEmpty() ) | 290 | if ( !nCat.isEmpty() ) |
283 | if ( !cat.contains( nCat )) { | 291 | if ( !cat.contains( nCat )) { |