author | zautrix <zautrix> | 2004-10-26 20:04:29 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-26 20:04:29 (UTC) |
commit | 8b111ae30fc51a4a580b8d485bef8ad28b0dde84 (patch) (unidiff) | |
tree | fb4cf20f5675e5ff2221ed6eea51785bdd65616c | |
parent | 62e91b888de607fa5a9f9c0fba807287e57d5d5c (diff) | |
download | kdepimpi-8b111ae30fc51a4a580b8d485bef8ad28b0dde84.zip kdepimpi-8b111ae30fc51a4a580b8d485bef8ad28b0dde84.tar.gz kdepimpi-8b111ae30fc51a4a580b8d485bef8ad28b0dde84.tar.bz2 |
fix in kapi translation call, clone fix and kde first sync fix
-rw-r--r-- | kaddressbook/mainembedded.cpp | 3 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 15 | ||||
-rw-r--r-- | libkcal/incidence.cpp | 2 |
3 files changed, 14 insertions, 6 deletions
diff --git a/kaddressbook/mainembedded.cpp b/kaddressbook/mainembedded.cpp index 547d208..771bec9 100644 --- a/kaddressbook/mainembedded.cpp +++ b/kaddressbook/mainembedded.cpp | |||
@@ -1,100 +1,99 @@ | |||
1 | #ifndef DESKTOP_VERSION | 1 | #ifndef DESKTOP_VERSION |
2 | #include <qpe/qpeapplication.h> | 2 | #include <qpe/qpeapplication.h> |
3 | #include <qcopchannel_qws.h> | 3 | #include <qcopchannel_qws.h> |
4 | #include <stdlib.h> | 4 | #include <stdlib.h> |
5 | #else | 5 | #else |
6 | #include <qapplication.h> | 6 | #include <qapplication.h> |
7 | #include <qwindowsstyle.h> | 7 | #include <qwindowsstyle.h> |
8 | #include <qplatinumstyle.h> | 8 | #include <qplatinumstyle.h> |
9 | #include <qmainwindow.h> | 9 | #include <qmainwindow.h> |
10 | #endif | 10 | #endif |
11 | 11 | ||
12 | #include <qtextcodec.h> | 12 | #include <qtextcodec.h> |
13 | #include <kstandarddirs.h> | 13 | #include <kstandarddirs.h> |
14 | #include <qregexp.h> | 14 | #include <qregexp.h> |
15 | #include <kglobal.h> | 15 | #include <kglobal.h> |
16 | #include <stdio.h> | 16 | #include <stdio.h> |
17 | #include <qdir.h> | 17 | #include <qdir.h> |
18 | #include "kabprefs.h" | 18 | #include "kabprefs.h" |
19 | #include "kaddressbookmain.h" | 19 | #include "kaddressbookmain.h" |
20 | #include "externalapphandler.h" | 20 | #include "externalapphandler.h" |
21 | #include <libkdepim/kpimglobalprefs.h> | 21 | #include <libkdepim/kpimglobalprefs.h> |
22 | void dumpMissing(); | 22 | void dumpMissing(); |
23 | int main( int argc, char **argv ) | 23 | int main( int argc, char **argv ) |
24 | { | 24 | { |
25 | #ifndef DESKTOP_VERSION | 25 | #ifndef DESKTOP_VERSION |
26 | QPEApplication a( argc, argv ); | 26 | QPEApplication a( argc, argv ); |
27 | a.setKeepRunning (); | 27 | a.setKeepRunning (); |
28 | #else | 28 | #else |
29 | QApplication a( argc, argv ); | 29 | QApplication a( argc, argv ); |
30 | QApplication::setStyle( new QPlatinumStyle ()); | 30 | QApplication::setStyle( new QPlatinumStyle ()); |
31 | QString hdir = QDir::homeDirPath(); | 31 | QString hdir = QDir::homeDirPath(); |
32 | // there is a bug when creating dirs for WIN 98 | 32 | // there is a bug when creating dirs for WIN 98 |
33 | // it is difficult to fix, because we have no WIN 98 runnung | 33 | // it is difficult to fix, because we have no WIN 98 runnung |
34 | // such that we try it to create the dirs at startup here | 34 | // such that we try it to create the dirs at startup here |
35 | if ( hdir == "C:\\" ) { // win 98 or ME | 35 | if ( hdir == "C:\\" ) { // win 98 or ME |
36 | QDir app_dir; | 36 | QDir app_dir; |
37 | if ( !app_dir.exists("C:\\kdepim") ) | 37 | if ( !app_dir.exists("C:\\kdepim") ) |
38 | app_dir.mkdir ("C:\\kdepim"); | 38 | app_dir.mkdir ("C:\\kdepim"); |
39 | if ( !app_dir.exists("C:\\kdepim\\apps") ) | 39 | if ( !app_dir.exists("C:\\kdepim\\apps") ) |
40 | app_dir.mkdir ("C:\\kdepim\\apps"); | 40 | app_dir.mkdir ("C:\\kdepim\\apps"); |
41 | if ( !app_dir.exists("C:\\kdepim\\config") ) | 41 | if ( !app_dir.exists("C:\\kdepim\\config") ) |
42 | app_dir.mkdir ("C:\\kdepim\\config"); | 42 | app_dir.mkdir ("C:\\kdepim\\config"); |
43 | if ( !app_dir.exists("C:\\kdepim\\apps\\kaddressbook") ) | 43 | if ( !app_dir.exists("C:\\kdepim\\apps\\kaddressbook") ) |
44 | app_dir.mkdir ("C:\\kdepim\\apps\\kaddressbook"); | 44 | app_dir.mkdir ("C:\\kdepim\\apps\\kaddressbook"); |
45 | } | 45 | } |
46 | #endif | 46 | #endif |
47 | 47 | ||
48 | bool exitHelp = false; | 48 | bool exitHelp = false; |
49 | if ( argc > 1 ) { | 49 | if ( argc > 1 ) { |
50 | QString command = argv[1]; | 50 | QString command = argv[1]; |
51 | if ( command == "-help" ){ | 51 | if ( command == "-help" ){ |
52 | printf("KA/E command line commands:\n"); | 52 | printf("KA/E command line commands:\n"); |
53 | printf(" no command: Start KA/E in usual way\n"); | 53 | printf(" no command: Start KA/E in usual way\n"); |
54 | printf(" -help: This output\n"); | 54 | printf(" -help: This output\n"); |
55 | printf(" KA/E is exiting now. Bye!\n"); | 55 | printf(" KA/E is exiting now. Bye!\n"); |
56 | exitHelp = true; | 56 | exitHelp = true; |
57 | } | 57 | } |
58 | } | 58 | } |
59 | if ( ! exitHelp ) { | 59 | if ( ! exitHelp ) { |
60 | 60 | ||
61 | KGlobal::setAppName( "kaddressbook" ); | 61 | KGlobal::setAppName( "kaddressbook" ); |
62 | #ifndef DESKTOP_VERSION | 62 | #ifndef DESKTOP_VERSION |
63 | if ( QApplication::desktop()->width() > 320 ) | 63 | if ( QApplication::desktop()->width() > 320 ) |
64 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/"); | 64 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/"); |
65 | else | 65 | else |
66 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/"); | 66 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/"); |
67 | #else | 67 | #else |
68 | QString fileName ; | 68 | QString fileName ; |
69 | fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/"; | 69 | fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/"; |
70 | KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); | 70 | KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); |
71 | QApplication::addLibraryPath ( qApp->applicationDirPath () ); | 71 | QApplication::addLibraryPath ( qApp->applicationDirPath () ); |
72 | 72 | ||
73 | #endif | 73 | #endif |
74 | KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook"))); | 74 | KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook"))); |
75 | // init language | 75 | // init language |
76 | KABPrefs::instance(); | 76 | KPimGlobalPrefs::instance()->setGlobalConfig(); |
77 | KAddressBookMain m ; | 77 | KAddressBookMain m ; |
78 | //US MainWindow m; | 78 | //US MainWindow m; |
79 | QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); | 79 | QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); |
80 | 80 | ||
81 | 81 | ||
82 | KPimGlobalPrefs::instance()->setGlobalConfig(); | ||
83 | 82 | ||
84 | #ifndef DESKTOP_VERSION | 83 | #ifndef DESKTOP_VERSION |
85 | a.showMainWidget( &m ); | 84 | a.showMainWidget( &m ); |
86 | 85 | ||
87 | #else | 86 | #else |
88 | a.setMainWidget( &m ); | 87 | a.setMainWidget( &m ); |
89 | m.resize (640, 480 ); | 88 | m.resize (640, 480 ); |
90 | m.show(); | 89 | m.show(); |
91 | #endif | 90 | #endif |
92 | a.exec(); | 91 | a.exec(); |
93 | 92 | ||
94 | dumpMissing(); | 93 | dumpMissing(); |
95 | 94 | ||
96 | KPimGlobalPrefs::instance()->writeConfig(); | 95 | KPimGlobalPrefs::instance()->writeConfig(); |
97 | } | 96 | } |
98 | qDebug("KA: Bye! "); | 97 | qDebug("KA: Bye! "); |
99 | } | 98 | } |
100 | 99 | ||
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 284ddbf..2ccccfa 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,3757 +1,3766 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Requires the Qt and KDE widget libraries, available at no cost at | 4 | Requires the Qt and KDE widget libraries, available at no cost at |
5 | http://www.troll.no and http://www.kde.org respectively | 5 | http://www.troll.no and http://www.kde.org respectively |
6 | 6 | ||
7 | Copyright (c) 1997, 1998, 1999 | 7 | Copyright (c) 1997, 1998, 1999 |
8 | Preston Brown (preston.brown@yale.edu) | 8 | Preston Brown (preston.brown@yale.edu) |
9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) | 9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) |
10 | Ian Dawes (iadawes@globalserve.net) | 10 | Ian Dawes (iadawes@globalserve.net) |
11 | Laszlo Boloni (boloni@cs.purdue.edu) | 11 | Laszlo Boloni (boloni@cs.purdue.edu) |
12 | 12 | ||
13 | Copyright (c) 2000, 2001, 2002 | 13 | Copyright (c) 2000, 2001, 2002 |
14 | Cornelius Schumacher <schumacher@kde.org> | 14 | Cornelius Schumacher <schumacher@kde.org> |
15 | 15 | ||
16 | This program is free software; you can redistribute it and/or modify | 16 | This program is free software; you can redistribute it and/or modify |
17 | it under the terms of the GNU General Public License as published by | 17 | it under the terms of the GNU General Public License as published by |
18 | the Free Software Foundation; either version 2 of the License, or | 18 | the Free Software Foundation; either version 2 of the License, or |
19 | (at your option) any later version. | 19 | (at your option) any later version. |
20 | 20 | ||
21 | This program is distributed in the hope that it will be useful, | 21 | This program is distributed in the hope that it will be useful, |
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
24 | GNU General Public License for more details. | 24 | GNU General Public License for more details. |
25 | 25 | ||
26 | You should have received a copy of the GNU General Public License | 26 | You should have received a copy of the GNU General Public License |
27 | along with this program; if not, write to the Free Software | 27 | along with this program; if not, write to the Free Software |
28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | 32 | ||
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qradiobutton.h> | 34 | #include <qradiobutton.h> |
35 | #include <qbuttongroup.h> | 35 | #include <qbuttongroup.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qclipboard.h> | 37 | #include <qclipboard.h> |
38 | #include <qcursor.h> | 38 | #include <qcursor.h> |
39 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
40 | #include <qprogressbar.h> | 40 | #include <qprogressbar.h> |
41 | #include <qmultilineedit.h> | 41 | #include <qmultilineedit.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qwidgetstack.h> | 43 | #include <qwidgetstack.h> |
44 | #include <qptrlist.h> | 44 | #include <qptrlist.h> |
45 | #include <qregexp.h> | 45 | #include <qregexp.h> |
46 | #include <qgroupbox.h> | 46 | #include <qgroupbox.h> |
47 | #include <qfile.h> | 47 | #include <qfile.h> |
48 | #include <qdir.h> | 48 | #include <qdir.h> |
49 | #ifndef KORG_NOSPLITTER | 49 | #ifndef KORG_NOSPLITTER |
50 | #include <qsplitter.h> | 50 | #include <qsplitter.h> |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #include <kglobal.h> | 53 | #include <kglobal.h> |
54 | #include <kdebug.h> | 54 | #include <kdebug.h> |
55 | #include <kstandarddirs.h> | 55 | #include <kstandarddirs.h> |
56 | #include <kfiledialog.h> | 56 | #include <kfiledialog.h> |
57 | #include <kmessagebox.h> | 57 | #include <kmessagebox.h> |
58 | #include <knotifyclient.h> | 58 | #include <knotifyclient.h> |
59 | #include <kconfig.h> | 59 | #include <kconfig.h> |
60 | 60 | ||
61 | #include <libkdepim/ksyncprefsdialog.h> | 61 | #include <libkdepim/ksyncprefsdialog.h> |
62 | #include <krun.h> | 62 | #include <krun.h> |
63 | #include <kdirwatch.h> | 63 | #include <kdirwatch.h> |
64 | #include <libkdepim/kdatepicker.h> | 64 | #include <libkdepim/kdatepicker.h> |
65 | #include <libkdepim/ksyncprofile.h> | 65 | #include <libkdepim/ksyncprofile.h> |
66 | #include <libkdepim/kpimglobalprefs.h> | 66 | #include <libkdepim/kpimglobalprefs.h> |
67 | 67 | ||
68 | #include <libkcal/vcaldrag.h> | 68 | #include <libkcal/vcaldrag.h> |
69 | #include <libkcal/icaldrag.h> | 69 | #include <libkcal/icaldrag.h> |
70 | #include <libkcal/icalformat.h> | 70 | #include <libkcal/icalformat.h> |
71 | #include <libkcal/vcalformat.h> | 71 | #include <libkcal/vcalformat.h> |
72 | #include <libkcal/scheduler.h> | 72 | #include <libkcal/scheduler.h> |
73 | #include <libkcal/calendarlocal.h> | 73 | #include <libkcal/calendarlocal.h> |
74 | #include <libkcal/journal.h> | 74 | #include <libkcal/journal.h> |
75 | #include <libkcal/calfilter.h> | 75 | #include <libkcal/calfilter.h> |
76 | #include <libkcal/attendee.h> | 76 | #include <libkcal/attendee.h> |
77 | #include <libkcal/dndfactory.h> | 77 | #include <libkcal/dndfactory.h> |
78 | #include <libkcal/freebusy.h> | 78 | #include <libkcal/freebusy.h> |
79 | #include <libkcal/filestorage.h> | 79 | #include <libkcal/filestorage.h> |
80 | #include <libkcal/calendarresources.h> | 80 | #include <libkcal/calendarresources.h> |
81 | #include <libkcal/qtopiaformat.h> | 81 | #include <libkcal/qtopiaformat.h> |
82 | #include "../kalarmd/alarmdialog.h" | 82 | #include "../kalarmd/alarmdialog.h" |
83 | 83 | ||
84 | #ifndef DESKTOP_VERSION | 84 | #ifndef DESKTOP_VERSION |
85 | #include <libkcal/sharpformat.h> | 85 | #include <libkcal/sharpformat.h> |
86 | #include <externalapphandler.h> | 86 | #include <externalapphandler.h> |
87 | #endif | 87 | #endif |
88 | #include <libkcal/phoneformat.h> | 88 | #include <libkcal/phoneformat.h> |
89 | #ifndef KORG_NOMAIL | 89 | #ifndef KORG_NOMAIL |
90 | #include "komailclient.h" | 90 | #include "komailclient.h" |
91 | #endif | 91 | #endif |
92 | #ifndef KORG_NOPRINTER | 92 | #ifndef KORG_NOPRINTER |
93 | #include "calprinter.h" | 93 | #include "calprinter.h" |
94 | #endif | 94 | #endif |
95 | #ifndef KORG_NOPLUGINS | 95 | #ifndef KORG_NOPLUGINS |
96 | #include "kocore.h" | 96 | #include "kocore.h" |
97 | #endif | 97 | #endif |
98 | #include "koeventeditor.h" | 98 | #include "koeventeditor.h" |
99 | #include "kotodoeditor.h" | 99 | #include "kotodoeditor.h" |
100 | #include "koprefs.h" | 100 | #include "koprefs.h" |
101 | #include "koeventviewerdialog.h" | 101 | #include "koeventviewerdialog.h" |
102 | #include "publishdialog.h" | 102 | #include "publishdialog.h" |
103 | #include "kofilterview.h" | 103 | #include "kofilterview.h" |
104 | #include "koglobals.h" | 104 | #include "koglobals.h" |
105 | #include "koviewmanager.h" | 105 | #include "koviewmanager.h" |
106 | #include "koagendaview.h" | 106 | #include "koagendaview.h" |
107 | #include "kodialogmanager.h" | 107 | #include "kodialogmanager.h" |
108 | #include "outgoingdialog.h" | 108 | #include "outgoingdialog.h" |
109 | #include "incomingdialog.h" | 109 | #include "incomingdialog.h" |
110 | #include "statusdialog.h" | 110 | #include "statusdialog.h" |
111 | #include "kdatenavigator.h" | 111 | #include "kdatenavigator.h" |
112 | #include "kotodoview.h" | 112 | #include "kotodoview.h" |
113 | #include "datenavigator.h" | 113 | #include "datenavigator.h" |
114 | #include "resourceview.h" | 114 | #include "resourceview.h" |
115 | #include "navigatorbar.h" | 115 | #include "navigatorbar.h" |
116 | #include "searchdialog.h" | 116 | #include "searchdialog.h" |
117 | #include "mainwindow.h" | 117 | #include "mainwindow.h" |
118 | 118 | ||
119 | #include "calendarview.h" | 119 | #include "calendarview.h" |
120 | #ifndef DESKTOP_VERSION | 120 | #ifndef DESKTOP_VERSION |
121 | #include <qtopia/alarmserver.h> | 121 | #include <qtopia/alarmserver.h> |
122 | #endif | 122 | #endif |
123 | #ifndef _WIN32_ | 123 | #ifndef _WIN32_ |
124 | #include <stdlib.h> | 124 | #include <stdlib.h> |
125 | #include <stdio.h> | 125 | #include <stdio.h> |
126 | #include <unistd.h> | 126 | #include <unistd.h> |
127 | #else | 127 | #else |
128 | #include <qprocess.h> | 128 | #include <qprocess.h> |
129 | #endif | 129 | #endif |
130 | 130 | ||
131 | #ifdef DESKTOP_VERSION | 131 | #ifdef DESKTOP_VERSION |
132 | #include <kabc/stdaddressbook.h> | 132 | #include <kabc/stdaddressbook.h> |
133 | #endif | 133 | #endif |
134 | using namespace KOrg; | 134 | using namespace KOrg; |
135 | using namespace KCal; | 135 | using namespace KCal; |
136 | extern int globalFlagBlockAgenda; | 136 | extern int globalFlagBlockAgenda; |
137 | extern int globalFlagBlockStartup; | 137 | extern int globalFlagBlockStartup; |
138 | 138 | ||
139 | 139 | ||
140 | 140 | ||
141 | class KOBeamPrefs : public QDialog | 141 | class KOBeamPrefs : public QDialog |
142 | { | 142 | { |
143 | public: | 143 | public: |
144 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 144 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
145 | QDialog( parent, name, true ) | 145 | QDialog( parent, name, true ) |
146 | { | 146 | { |
147 | setCaption( i18n("Beam Options") ); | 147 | setCaption( i18n("Beam Options") ); |
148 | QVBoxLayout* lay = new QVBoxLayout( this ); | 148 | QVBoxLayout* lay = new QVBoxLayout( this ); |
149 | lay->setSpacing( 3 ); | 149 | lay->setSpacing( 3 ); |
150 | lay->setMargin( 3 ); | 150 | lay->setMargin( 3 ); |
151 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 151 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
152 | lay->addWidget( format ); | 152 | lay->addWidget( format ); |
153 | format->setExclusive ( true ) ; | 153 | format->setExclusive ( true ) ; |
154 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 154 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
155 | lay->addWidget( time ); time->setExclusive ( true ) ; | 155 | lay->addWidget( time ); time->setExclusive ( true ) ; |
156 | vcal = new QRadioButton(" vCalendar ", format ); | 156 | vcal = new QRadioButton(" vCalendar ", format ); |
157 | ical = new QRadioButton(" iCalendar ", format ); | 157 | ical = new QRadioButton(" iCalendar ", format ); |
158 | vcal->setChecked( true ); | 158 | vcal->setChecked( true ); |
159 | tz = new QRadioButton(i18n(" With timezone "), time ); | 159 | tz = new QRadioButton(i18n(" With timezone "), time ); |
160 | local = new QRadioButton(i18n(" Local time "), time ); | 160 | local = new QRadioButton(i18n(" Local time "), time ); |
161 | tz->setChecked( true ); | 161 | tz->setChecked( true ); |
162 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 162 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
163 | lay->addWidget( ok ); | 163 | lay->addWidget( ok ); |
164 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 164 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
165 | lay->addWidget( cancel ); | 165 | lay->addWidget( cancel ); |
166 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 166 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
167 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 167 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
168 | resize( 200, 200 ); | 168 | resize( 200, 200 ); |
169 | } | 169 | } |
170 | 170 | ||
171 | bool beamVcal() { return vcal->isChecked(); } | 171 | bool beamVcal() { return vcal->isChecked(); } |
172 | bool beamLocal() { return local->isChecked(); } | 172 | bool beamLocal() { return local->isChecked(); } |
173 | private: | 173 | private: |
174 | QRadioButton* vcal, *ical, *local, *tz; | 174 | QRadioButton* vcal, *ical, *local, *tz; |
175 | }; | 175 | }; |
176 | class KOCatPrefs : public QDialog | 176 | class KOCatPrefs : public QDialog |
177 | { | 177 | { |
178 | public: | 178 | public: |
179 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 179 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
180 | QDialog( parent, name, true ) | 180 | QDialog( parent, name, true ) |
181 | { | 181 | { |
182 | setCaption( i18n("Manage new Categories") ); | 182 | setCaption( i18n("Manage new Categories") ); |
183 | QVBoxLayout* lay = new QVBoxLayout( this ); | 183 | QVBoxLayout* lay = new QVBoxLayout( this ); |
184 | lay->setSpacing( 3 ); | 184 | lay->setSpacing( 3 ); |
185 | lay->setMargin( 3 ); | 185 | lay->setMargin( 3 ); |
186 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); | 186 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); |
187 | lay->addWidget( lab ); | 187 | lay->addWidget( lab ); |
188 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 188 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
189 | lay->addWidget( format ); | 189 | lay->addWidget( format ); |
190 | format->setExclusive ( true ) ; | 190 | format->setExclusive ( true ) ; |
191 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 191 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
192 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 192 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
193 | addCatBut->setChecked( true ); | 193 | addCatBut->setChecked( true ); |
194 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 194 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
195 | lay->addWidget( ok ); | 195 | lay->addWidget( ok ); |
196 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 196 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
197 | lay->addWidget( cancel ); | 197 | lay->addWidget( cancel ); |
198 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 198 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
199 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 199 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
200 | resize( 200, 200 ); | 200 | resize( 200, 200 ); |
201 | } | 201 | } |
202 | 202 | ||
203 | bool addCat() { return addCatBut->isChecked(); } | 203 | bool addCat() { return addCatBut->isChecked(); } |
204 | private: | 204 | private: |
205 | QRadioButton* addCatBut; | 205 | QRadioButton* addCatBut; |
206 | }; | 206 | }; |
207 | 207 | ||
208 | 208 | ||
209 | 209 | ||
210 | CalendarView::CalendarView( CalendarResources *calendar, | 210 | CalendarView::CalendarView( CalendarResources *calendar, |
211 | QWidget *parent, const char *name ) | 211 | QWidget *parent, const char *name ) |
212 | : CalendarViewBase( parent, name ), | 212 | : CalendarViewBase( parent, name ), |
213 | mCalendar( calendar ), | 213 | mCalendar( calendar ), |
214 | mResourceManager( calendar->resourceManager() ) | 214 | mResourceManager( calendar->resourceManager() ) |
215 | { | 215 | { |
216 | 216 | ||
217 | mEventEditor = 0; | 217 | mEventEditor = 0; |
218 | mTodoEditor = 0; | 218 | mTodoEditor = 0; |
219 | 219 | ||
220 | init(); | 220 | init(); |
221 | } | 221 | } |
222 | 222 | ||
223 | CalendarView::CalendarView( Calendar *calendar, | 223 | CalendarView::CalendarView( Calendar *calendar, |
224 | QWidget *parent, const char *name ) | 224 | QWidget *parent, const char *name ) |
225 | : CalendarViewBase( parent, name ), | 225 | : CalendarViewBase( parent, name ), |
226 | mCalendar( calendar ), | 226 | mCalendar( calendar ), |
227 | mResourceManager( 0 ) | 227 | mResourceManager( 0 ) |
228 | { | 228 | { |
229 | 229 | ||
230 | mEventEditor = 0; | 230 | mEventEditor = 0; |
231 | mTodoEditor = 0; | 231 | mTodoEditor = 0; |
232 | init();} | 232 | init();} |
233 | 233 | ||
234 | void CalendarView::init() | 234 | void CalendarView::init() |
235 | { | 235 | { |
236 | beamDialog = new KOBeamPrefs(); | 236 | beamDialog = new KOBeamPrefs(); |
237 | mDatePickerMode = 0; | 237 | mDatePickerMode = 0; |
238 | mCurrentSyncDevice = ""; | 238 | mCurrentSyncDevice = ""; |
239 | writeLocale(); | 239 | writeLocale(); |
240 | mViewManager = new KOViewManager( this ); | 240 | mViewManager = new KOViewManager( this ); |
241 | mDialogManager = new KODialogManager( this ); | 241 | mDialogManager = new KODialogManager( this ); |
242 | mEventViewerDialog = 0; | 242 | mEventViewerDialog = 0; |
243 | mModified = false; | 243 | mModified = false; |
244 | mReadOnly = false; | 244 | mReadOnly = false; |
245 | mSelectedIncidence = 0; | 245 | mSelectedIncidence = 0; |
246 | mCalPrinter = 0; | 246 | mCalPrinter = 0; |
247 | mFilters.setAutoDelete(true); | 247 | mFilters.setAutoDelete(true); |
248 | 248 | ||
249 | mCalendar->registerObserver( this ); | 249 | mCalendar->registerObserver( this ); |
250 | // TODO: Make sure that view is updated, when calendar is changed. | 250 | // TODO: Make sure that view is updated, when calendar is changed. |
251 | 251 | ||
252 | mStorage = new FileStorage( mCalendar ); | 252 | mStorage = new FileStorage( mCalendar ); |
253 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 253 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
254 | 254 | ||
255 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 255 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
256 | #ifndef KORG_NOSPLITTER | 256 | #ifndef KORG_NOSPLITTER |
257 | // create the main layout frames. | 257 | // create the main layout frames. |
258 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 258 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
259 | topLayout->addWidget(mPanner); | 259 | topLayout->addWidget(mPanner); |
260 | 260 | ||
261 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 261 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
262 | "CalendarView::LeftFrame"); | 262 | "CalendarView::LeftFrame"); |
263 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 263 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
264 | 264 | ||
265 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, | 265 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, |
266 | "CalendarView::DateNavigator", QDate::currentDate() ); | 266 | "CalendarView::DateNavigator", QDate::currentDate() ); |
267 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 267 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
268 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 268 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
269 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 269 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
270 | 270 | ||
271 | #ifdef KORG_NORESOURCEVIEW | 271 | #ifdef KORG_NORESOURCEVIEW |
272 | mResourceView = 0; | 272 | mResourceView = 0; |
273 | #else | 273 | #else |
274 | if ( mResourceManager ) { | 274 | if ( mResourceManager ) { |
275 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 275 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
276 | mResourceView->updateView(); | 276 | mResourceView->updateView(); |
277 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 277 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
278 | SLOT( updateView() ) ); | 278 | SLOT( updateView() ) ); |
279 | } else { | 279 | } else { |
280 | mResourceView = 0; | 280 | mResourceView = 0; |
281 | } | 281 | } |
282 | #endif | 282 | #endif |
283 | QWidget *rightBox = new QWidget( mPanner ); | 283 | QWidget *rightBox = new QWidget( mPanner ); |
284 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 284 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
285 | 285 | ||
286 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); | 286 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); |
287 | rightLayout->addWidget( mNavigatorBar ); | 287 | rightLayout->addWidget( mNavigatorBar ); |
288 | 288 | ||
289 | mRightFrame = new QWidgetStack( rightBox ); | 289 | mRightFrame = new QWidgetStack( rightBox ); |
290 | rightLayout->addWidget( mRightFrame, 1 ); | 290 | rightLayout->addWidget( mRightFrame, 1 ); |
291 | 291 | ||
292 | mLeftFrame = mLeftSplitter; | 292 | mLeftFrame = mLeftSplitter; |
293 | #else | 293 | #else |
294 | QWidget *mainBox = new QWidget( this ); | 294 | QWidget *mainBox = new QWidget( this ); |
295 | QWidget *leftFrame = new QWidget( mainBox ); | 295 | QWidget *leftFrame = new QWidget( mainBox ); |
296 | 296 | ||
297 | QBoxLayout * mainBoxLayout; | 297 | QBoxLayout * mainBoxLayout; |
298 | QBoxLayout * leftFrameLayout; | 298 | QBoxLayout * leftFrameLayout; |
299 | if ( KOPrefs::instance()->mVerticalScreen ) { | 299 | if ( KOPrefs::instance()->mVerticalScreen ) { |
300 | mainBoxLayout = new QVBoxLayout(mainBox); | 300 | mainBoxLayout = new QVBoxLayout(mainBox); |
301 | leftFrameLayout = new QHBoxLayout(leftFrame ); | 301 | leftFrameLayout = new QHBoxLayout(leftFrame ); |
302 | } else { | 302 | } else { |
303 | mainBoxLayout = new QHBoxLayout(mainBox); | 303 | mainBoxLayout = new QHBoxLayout(mainBox); |
304 | leftFrameLayout = new QVBoxLayout(leftFrame ); | 304 | leftFrameLayout = new QVBoxLayout(leftFrame ); |
305 | } | 305 | } |
306 | topLayout->addWidget( mainBox ); | 306 | topLayout->addWidget( mainBox ); |
307 | mainBoxLayout->addWidget (leftFrame); | 307 | mainBoxLayout->addWidget (leftFrame); |
308 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, | 308 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, |
309 | "CalendarView::DateNavigator", QDate::currentDate()); | 309 | "CalendarView::DateNavigator", QDate::currentDate()); |
310 | // mDateNavigator->blockSignals( true ); | 310 | // mDateNavigator->blockSignals( true ); |
311 | leftFrameLayout->addWidget( mDateNavigator ); | 311 | leftFrameLayout->addWidget( mDateNavigator ); |
312 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); | 312 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); |
313 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); | 313 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); |
314 | 314 | ||
315 | if ( QApplication::desktop()->width() < 480 ) { | 315 | if ( QApplication::desktop()->width() < 480 ) { |
316 | leftFrameLayout->addWidget(mFilterView); | 316 | leftFrameLayout->addWidget(mFilterView); |
317 | leftFrameLayout->addWidget(mTodoList, 2 ); | 317 | leftFrameLayout->addWidget(mTodoList, 2 ); |
318 | 318 | ||
319 | } else { | 319 | } else { |
320 | leftFrameLayout->addWidget(mTodoList,2 ); | 320 | leftFrameLayout->addWidget(mTodoList,2 ); |
321 | leftFrameLayout->addWidget(mFilterView ); | 321 | leftFrameLayout->addWidget(mFilterView ); |
322 | } | 322 | } |
323 | mFilterView->hide(); | 323 | mFilterView->hide(); |
324 | QWidget *rightBox = new QWidget( mainBox ); | 324 | QWidget *rightBox = new QWidget( mainBox ); |
325 | mainBoxLayout->addWidget ( rightBox, 10 ); | 325 | mainBoxLayout->addWidget ( rightBox, 10 ); |
326 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 326 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
327 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); | 327 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); |
328 | mRightFrame = new QWidgetStack( rightBox ); | 328 | mRightFrame = new QWidgetStack( rightBox ); |
329 | rightLayout->addWidget( mNavigatorBar ); | 329 | rightLayout->addWidget( mNavigatorBar ); |
330 | rightLayout->addWidget( mRightFrame, 10 ); | 330 | rightLayout->addWidget( mRightFrame, 10 ); |
331 | 331 | ||
332 | mLeftFrame = leftFrame; | 332 | mLeftFrame = leftFrame; |
333 | if ( KOPrefs::instance()->mVerticalScreen ) { | 333 | if ( KOPrefs::instance()->mVerticalScreen ) { |
334 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 334 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
335 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 335 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
336 | } else { | 336 | } else { |
337 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 337 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
338 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 338 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
339 | } | 339 | } |
340 | 340 | ||
341 | //qDebug("Calendarview Size %d %d ", width(), height()); | 341 | //qDebug("Calendarview Size %d %d ", width(), height()); |
342 | #endif | 342 | #endif |
343 | 343 | ||
344 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 344 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
345 | SLOT( showDates( const KCal::DateList & ) ) ); | 345 | SLOT( showDates( const KCal::DateList & ) ) ); |
346 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 346 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
347 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 347 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
348 | 348 | ||
349 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), | 349 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), |
350 | mNavigator, SLOT( selectPreviousYear() ) ); | 350 | mNavigator, SLOT( selectPreviousYear() ) ); |
351 | connect( mNavigatorBar, SIGNAL( goNextYear() ), | 351 | connect( mNavigatorBar, SIGNAL( goNextYear() ), |
352 | mNavigator, SLOT( selectNextYear() ) ); | 352 | mNavigator, SLOT( selectNextYear() ) ); |
353 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), | 353 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), |
354 | mNavigator, SLOT( selectPreviousMonth() ) ); | 354 | mNavigator, SLOT( selectPreviousMonth() ) ); |
355 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), | 355 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), |
356 | mNavigator, SLOT( selectNextMonth() ) ); | 356 | mNavigator, SLOT( selectNextMonth() ) ); |
357 | 357 | ||
358 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 358 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
359 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); | 359 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); |
360 | 360 | ||
361 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 361 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
362 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 362 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
363 | 363 | ||
364 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 364 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
365 | mNavigator, SLOT( selectPreviousYear() ) ); | 365 | mNavigator, SLOT( selectPreviousYear() ) ); |
366 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 366 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
367 | mNavigator, SLOT( selectNextYear() ) ); | 367 | mNavigator, SLOT( selectNextYear() ) ); |
368 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 368 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
369 | mNavigator, SLOT( selectPreviousMonth() ) ); | 369 | mNavigator, SLOT( selectPreviousMonth() ) ); |
370 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 370 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
371 | mNavigator, SLOT( selectNextMonth() ) ); | 371 | mNavigator, SLOT( selectNextMonth() ) ); |
372 | 372 | ||
373 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 373 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
374 | mNavigator, SLOT( selectPrevious() ) ); | 374 | mNavigator, SLOT( selectPrevious() ) ); |
375 | connect( mDateNavigator, SIGNAL( goNext() ), | 375 | connect( mDateNavigator, SIGNAL( goNext() ), |
376 | mNavigator, SLOT( selectNext() ) ); | 376 | mNavigator, SLOT( selectNext() ) ); |
377 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 377 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
378 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 378 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
379 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), | 379 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), |
380 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 380 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
381 | 381 | ||
382 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 382 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
383 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 383 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
384 | 384 | ||
385 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), | 385 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), |
386 | SLOT( eventAdded( Event *) ) ); | 386 | SLOT( eventAdded( Event *) ) ); |
387 | 387 | ||
388 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 388 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
389 | 389 | ||
390 | connect( this, SIGNAL( configChanged() ), | 390 | connect( this, SIGNAL( configChanged() ), |
391 | mDateNavigator, SLOT( updateConfig() ) ); | 391 | mDateNavigator, SLOT( updateConfig() ) ); |
392 | 392 | ||
393 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 393 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
394 | SLOT( newTodo() ) ); | 394 | SLOT( newTodo() ) ); |
395 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 395 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
396 | SLOT( newSubTodo( Todo * ) ) ); | 396 | SLOT( newSubTodo( Todo * ) ) ); |
397 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 397 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
398 | SLOT( editTodo( Todo * ) ) ); | 398 | SLOT( editTodo( Todo * ) ) ); |
399 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 399 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
400 | SLOT( showTodo( Todo *) ) ); | 400 | SLOT( showTodo( Todo *) ) ); |
401 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 401 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
402 | SLOT( deleteTodo( Todo *) ) ); | 402 | SLOT( deleteTodo( Todo *) ) ); |
403 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 403 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
404 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 404 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
405 | SLOT( purgeCompleted() ) ); | 405 | SLOT( purgeCompleted() ) ); |
406 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 406 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
407 | SIGNAL( todoModified( Todo *, int ) ) ); | 407 | SIGNAL( todoModified( Todo *, int ) ) ); |
408 | 408 | ||
409 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 409 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
410 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 410 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
411 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 411 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
412 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 412 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
413 | 413 | ||
414 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 414 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
415 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 415 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
416 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 416 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
417 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 417 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
418 | 418 | ||
419 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 419 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
420 | this, SLOT ( todo_unsub( Todo * ) ) ); | 420 | this, SLOT ( todo_unsub( Todo * ) ) ); |
421 | 421 | ||
422 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 422 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
423 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 423 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
424 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 424 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
425 | SLOT( updateTodo( Todo *, int ) ) ); | 425 | SLOT( updateTodo( Todo *, int ) ) ); |
426 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 426 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
427 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 427 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
428 | 428 | ||
429 | 429 | ||
430 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 430 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
431 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 431 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
432 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 432 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
433 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 433 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
434 | 434 | ||
435 | 435 | ||
436 | 436 | ||
437 | 437 | ||
438 | 438 | ||
439 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 439 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
440 | SLOT(checkClipboard())); | 440 | SLOT(checkClipboard())); |
441 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 441 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
442 | SLOT( processTodoListSelection( Incidence * ) ) ); | 442 | SLOT( processTodoListSelection( Incidence * ) ) ); |
443 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 443 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
444 | 444 | ||
445 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 445 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
446 | 446 | ||
447 | mDateFrame = new QVBox(0,0,WType_Popup); | 447 | mDateFrame = new QVBox(0,0,WType_Popup); |
448 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 448 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
449 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 449 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
450 | mDateFrame->setLineWidth(3); | 450 | mDateFrame->setLineWidth(3); |
451 | mDateFrame->hide(); | 451 | mDateFrame->hide(); |
452 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 452 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
453 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 453 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
454 | 454 | ||
455 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 455 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
456 | 456 | ||
457 | mEventEditor = mDialogManager->getEventEditor(); | 457 | mEventEditor = mDialogManager->getEventEditor(); |
458 | mTodoEditor = mDialogManager->getTodoEditor(); | 458 | mTodoEditor = mDialogManager->getTodoEditor(); |
459 | 459 | ||
460 | mFlagEditDescription = false; | 460 | mFlagEditDescription = false; |
461 | 461 | ||
462 | mSuspendTimer = new QTimer( this ); | 462 | mSuspendTimer = new QTimer( this ); |
463 | mAlarmTimer = new QTimer( this ); | 463 | mAlarmTimer = new QTimer( this ); |
464 | mRecheckAlarmTimer = new QTimer( this ); | 464 | mRecheckAlarmTimer = new QTimer( this ); |
465 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 465 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
466 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 466 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
467 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 467 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
468 | mAlarmDialog = new AlarmDialog( this ); | 468 | mAlarmDialog = new AlarmDialog( this ); |
469 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 469 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
470 | mAlarmDialog->setServerNotification( false ); | 470 | mAlarmDialog->setServerNotification( false ); |
471 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 471 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
472 | 472 | ||
473 | 473 | ||
474 | #ifndef DESKTOP_VERSION | 474 | #ifndef DESKTOP_VERSION |
475 | //US listen for arriving address resultsets | 475 | //US listen for arriving address resultsets |
476 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 476 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
477 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 477 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
478 | #endif | 478 | #endif |
479 | 479 | ||
480 | } | 480 | } |
481 | 481 | ||
482 | 482 | ||
483 | CalendarView::~CalendarView() | 483 | CalendarView::~CalendarView() |
484 | { | 484 | { |
485 | // kdDebug() << "~CalendarView()" << endl; | 485 | // kdDebug() << "~CalendarView()" << endl; |
486 | //qDebug("CalendarView::~CalendarView() "); | 486 | //qDebug("CalendarView::~CalendarView() "); |
487 | delete mDialogManager; | 487 | delete mDialogManager; |
488 | delete mViewManager; | 488 | delete mViewManager; |
489 | delete mStorage; | 489 | delete mStorage; |
490 | delete mDateFrame ; | 490 | delete mDateFrame ; |
491 | delete beamDialog; | 491 | delete beamDialog; |
492 | //kdDebug() << "~CalendarView() done" << endl; | 492 | //kdDebug() << "~CalendarView() done" << endl; |
493 | } | 493 | } |
494 | void CalendarView::timerAlarm() | 494 | void CalendarView::timerAlarm() |
495 | { | 495 | { |
496 | //qDebug("CalendarView::timerAlarm() "); | 496 | //qDebug("CalendarView::timerAlarm() "); |
497 | computeAlarm(mAlarmNotification ); | 497 | computeAlarm(mAlarmNotification ); |
498 | } | 498 | } |
499 | 499 | ||
500 | void CalendarView::suspendAlarm() | 500 | void CalendarView::suspendAlarm() |
501 | { | 501 | { |
502 | //qDebug(" CalendarView::suspendAlarm() "); | 502 | //qDebug(" CalendarView::suspendAlarm() "); |
503 | computeAlarm(mSuspendAlarmNotification ); | 503 | computeAlarm(mSuspendAlarmNotification ); |
504 | 504 | ||
505 | } | 505 | } |
506 | 506 | ||
507 | void CalendarView::startAlarm( QString mess , QString filename) | 507 | void CalendarView::startAlarm( QString mess , QString filename) |
508 | { | 508 | { |
509 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 509 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
510 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 510 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
511 | 511 | ||
512 | } | 512 | } |
513 | 513 | ||
514 | void CalendarView::checkNextTimerAlarm() | 514 | void CalendarView::checkNextTimerAlarm() |
515 | { | 515 | { |
516 | mCalendar->checkAlarmForIncidence( 0, true ); | 516 | mCalendar->checkAlarmForIncidence( 0, true ); |
517 | } | 517 | } |
518 | 518 | ||
519 | void CalendarView::computeAlarm( QString msg ) | 519 | void CalendarView::computeAlarm( QString msg ) |
520 | { | 520 | { |
521 | 521 | ||
522 | QString mess = msg; | 522 | QString mess = msg; |
523 | QString mAlarmMessage = mess.mid( 9 ); | 523 | QString mAlarmMessage = mess.mid( 9 ); |
524 | QString filename = MainWindow::resourcePath(); | 524 | QString filename = MainWindow::resourcePath(); |
525 | filename += "koalarm.wav"; | 525 | filename += "koalarm.wav"; |
526 | QString tempfilename; | 526 | QString tempfilename; |
527 | if ( mess.left( 13 ) == "suspend_alarm") { | 527 | if ( mess.left( 13 ) == "suspend_alarm") { |
528 | bool error = false; | 528 | bool error = false; |
529 | int len = mess.mid( 13 ).find("+++"); | 529 | int len = mess.mid( 13 ).find("+++"); |
530 | if ( len < 2 ) | 530 | if ( len < 2 ) |
531 | error = true; | 531 | error = true; |
532 | else { | 532 | else { |
533 | tempfilename = mess.mid( 13, len ); | 533 | tempfilename = mess.mid( 13, len ); |
534 | if ( !QFile::exists( tempfilename ) ) | 534 | if ( !QFile::exists( tempfilename ) ) |
535 | error = true; | 535 | error = true; |
536 | } | 536 | } |
537 | if ( ! error ) { | 537 | if ( ! error ) { |
538 | filename = tempfilename; | 538 | filename = tempfilename; |
539 | } | 539 | } |
540 | mAlarmMessage = mess.mid( 13+len+3 ); | 540 | mAlarmMessage = mess.mid( 13+len+3 ); |
541 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 541 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
542 | startAlarm( mAlarmMessage, filename); | 542 | startAlarm( mAlarmMessage, filename); |
543 | return; | 543 | return; |
544 | } | 544 | } |
545 | if ( mess.left( 11 ) == "timer_alarm") { | 545 | if ( mess.left( 11 ) == "timer_alarm") { |
546 | //mTimerTime = 0; | 546 | //mTimerTime = 0; |
547 | startAlarm( mess.mid( 11 ), filename ); | 547 | startAlarm( mess.mid( 11 ), filename ); |
548 | return; | 548 | return; |
549 | } | 549 | } |
550 | if ( mess.left( 10 ) == "proc_alarm") { | 550 | if ( mess.left( 10 ) == "proc_alarm") { |
551 | bool error = false; | 551 | bool error = false; |
552 | int len = mess.mid( 10 ).find("+++"); | 552 | int len = mess.mid( 10 ).find("+++"); |
553 | if ( len < 2 ) | 553 | if ( len < 2 ) |
554 | error = true; | 554 | error = true; |
555 | else { | 555 | else { |
556 | tempfilename = mess.mid( 10, len ); | 556 | tempfilename = mess.mid( 10, len ); |
557 | if ( !QFile::exists( tempfilename ) ) | 557 | if ( !QFile::exists( tempfilename ) ) |
558 | error = true; | 558 | error = true; |
559 | } | 559 | } |
560 | if ( error ) { | 560 | if ( error ) { |
561 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 561 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
562 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 562 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
563 | } else { | 563 | } else { |
564 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 564 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
565 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 565 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
566 | #ifndef _WIN32_ | 566 | #ifndef _WIN32_ |
567 | if ( vfork () == 0 ) { | 567 | if ( vfork () == 0 ) { |
568 | execl ( tempfilename.latin1(), 0 ); | 568 | execl ( tempfilename.latin1(), 0 ); |
569 | return; | 569 | return; |
570 | } | 570 | } |
571 | #else | 571 | #else |
572 | QProcess* p = new QProcess(); | 572 | QProcess* p = new QProcess(); |
573 | p->addArgument( tempfilename.latin1() ); | 573 | p->addArgument( tempfilename.latin1() ); |
574 | p->start(); | 574 | p->start(); |
575 | return; | 575 | return; |
576 | #endif | 576 | #endif |
577 | 577 | ||
578 | return; | 578 | return; |
579 | } | 579 | } |
580 | 580 | ||
581 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 581 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
582 | } | 582 | } |
583 | if ( mess.left( 11 ) == "audio_alarm") { | 583 | if ( mess.left( 11 ) == "audio_alarm") { |
584 | bool error = false; | 584 | bool error = false; |
585 | int len = mess.mid( 11 ).find("+++"); | 585 | int len = mess.mid( 11 ).find("+++"); |
586 | if ( len < 2 ) | 586 | if ( len < 2 ) |
587 | error = true; | 587 | error = true; |
588 | else { | 588 | else { |
589 | tempfilename = mess.mid( 11, len ); | 589 | tempfilename = mess.mid( 11, len ); |
590 | if ( !QFile::exists( tempfilename ) ) | 590 | if ( !QFile::exists( tempfilename ) ) |
591 | error = true; | 591 | error = true; |
592 | } | 592 | } |
593 | if ( ! error ) { | 593 | if ( ! error ) { |
594 | filename = tempfilename; | 594 | filename = tempfilename; |
595 | } | 595 | } |
596 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 596 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
597 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 597 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
598 | } | 598 | } |
599 | if ( mess.left( 9 ) == "cal_alarm") { | 599 | if ( mess.left( 9 ) == "cal_alarm") { |
600 | mAlarmMessage = mess.mid( 9 ) ; | 600 | mAlarmMessage = mess.mid( 9 ) ; |
601 | } | 601 | } |
602 | 602 | ||
603 | startAlarm( mAlarmMessage, filename ); | 603 | startAlarm( mAlarmMessage, filename ); |
604 | 604 | ||
605 | 605 | ||
606 | } | 606 | } |
607 | 607 | ||
608 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 608 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
609 | { | 609 | { |
610 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 610 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
611 | 611 | ||
612 | mSuspendAlarmNotification = noti; | 612 | mSuspendAlarmNotification = noti; |
613 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 613 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
614 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 614 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
615 | mSuspendTimer->start( ms , true ); | 615 | mSuspendTimer->start( ms , true ); |
616 | 616 | ||
617 | } | 617 | } |
618 | 618 | ||
619 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 619 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
620 | { | 620 | { |
621 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 621 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
622 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 622 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
623 | #ifndef DESKTOP_VERSION | 623 | #ifndef DESKTOP_VERSION |
624 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 624 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
625 | #endif | 625 | #endif |
626 | return; | 626 | return; |
627 | } | 627 | } |
628 | int maxSec; | 628 | int maxSec; |
629 | //maxSec = 5; //testing only | 629 | //maxSec = 5; //testing only |
630 | maxSec = 86400+3600; // one day+1hour | 630 | maxSec = 86400+3600; // one day+1hour |
631 | mAlarmNotification = noti; | 631 | mAlarmNotification = noti; |
632 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 632 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
633 | if ( sec > maxSec ) { | 633 | if ( sec > maxSec ) { |
634 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 634 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
635 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 635 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
636 | return; | 636 | return; |
637 | } else { | 637 | } else { |
638 | mRecheckAlarmTimer->stop(); | 638 | mRecheckAlarmTimer->stop(); |
639 | } | 639 | } |
640 | //qDebug("Alarm timer started with secs: %d ", sec); | 640 | //qDebug("Alarm timer started with secs: %d ", sec); |
641 | mAlarmTimer->start( sec *1000 , true ); | 641 | mAlarmTimer->start( sec *1000 , true ); |
642 | 642 | ||
643 | } | 643 | } |
644 | // called by mRecheckAlarmTimer to get next alarm | 644 | // called by mRecheckAlarmTimer to get next alarm |
645 | // we need this, because a QTimer has only a max range of 25 days | 645 | // we need this, because a QTimer has only a max range of 25 days |
646 | void CalendarView::recheckTimerAlarm() | 646 | void CalendarView::recheckTimerAlarm() |
647 | { | 647 | { |
648 | mAlarmTimer->stop(); | 648 | mAlarmTimer->stop(); |
649 | mRecheckAlarmTimer->stop(); | 649 | mRecheckAlarmTimer->stop(); |
650 | mCalendar->checkAlarmForIncidence( 0, true ); | 650 | mCalendar->checkAlarmForIncidence( 0, true ); |
651 | } | 651 | } |
652 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 652 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
653 | { | 653 | { |
654 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 654 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
655 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 655 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
656 | #ifndef DESKTOP_VERSION | 656 | #ifndef DESKTOP_VERSION |
657 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 657 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
658 | #endif | 658 | #endif |
659 | return; | 659 | return; |
660 | } | 660 | } |
661 | mAlarmTimer->stop(); | 661 | mAlarmTimer->stop(); |
662 | } | 662 | } |
663 | void CalendarView::selectWeekNum ( int num ) | 663 | void CalendarView::selectWeekNum ( int num ) |
664 | { | 664 | { |
665 | dateNavigator()->selectWeek( num ); | 665 | dateNavigator()->selectWeek( num ); |
666 | mViewManager->showWeekView(); | 666 | mViewManager->showWeekView(); |
667 | } | 667 | } |
668 | KOViewManager *CalendarView::viewManager() | 668 | KOViewManager *CalendarView::viewManager() |
669 | { | 669 | { |
670 | return mViewManager; | 670 | return mViewManager; |
671 | } | 671 | } |
672 | 672 | ||
673 | KODialogManager *CalendarView::dialogManager() | 673 | KODialogManager *CalendarView::dialogManager() |
674 | { | 674 | { |
675 | return mDialogManager; | 675 | return mDialogManager; |
676 | } | 676 | } |
677 | 677 | ||
678 | QDate CalendarView::startDate() | 678 | QDate CalendarView::startDate() |
679 | { | 679 | { |
680 | DateList dates = mNavigator->selectedDates(); | 680 | DateList dates = mNavigator->selectedDates(); |
681 | 681 | ||
682 | return dates.first(); | 682 | return dates.first(); |
683 | } | 683 | } |
684 | 684 | ||
685 | QDate CalendarView::endDate() | 685 | QDate CalendarView::endDate() |
686 | { | 686 | { |
687 | DateList dates = mNavigator->selectedDates(); | 687 | DateList dates = mNavigator->selectedDates(); |
688 | 688 | ||
689 | return dates.last(); | 689 | return dates.last(); |
690 | } | 690 | } |
691 | 691 | ||
692 | 692 | ||
693 | void CalendarView::createPrinter() | 693 | void CalendarView::createPrinter() |
694 | { | 694 | { |
695 | #ifndef KORG_NOPRINTER | 695 | #ifndef KORG_NOPRINTER |
696 | if (!mCalPrinter) { | 696 | if (!mCalPrinter) { |
697 | mCalPrinter = new CalPrinter(this, mCalendar); | 697 | mCalPrinter = new CalPrinter(this, mCalendar); |
698 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 698 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
699 | } | 699 | } |
700 | #endif | 700 | #endif |
701 | } | 701 | } |
702 | 702 | ||
703 | 703 | ||
704 | //KOPrefs::instance()->mWriteBackFile | 704 | //KOPrefs::instance()->mWriteBackFile |
705 | //KOPrefs::instance()->mWriteBackExistingOnly | 705 | //KOPrefs::instance()->mWriteBackExistingOnly |
706 | 706 | ||
707 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 707 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
708 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 708 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
709 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 709 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
710 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 710 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
711 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 711 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
712 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 712 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
713 | 713 | ||
714 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 714 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
715 | { | 715 | { |
716 | 716 | ||
717 | // 0 equal | 717 | // 0 equal |
718 | // 1 take local | 718 | // 1 take local |
719 | // 2 take remote | 719 | // 2 take remote |
720 | // 3 cancel | 720 | // 3 cancel |
721 | QDateTime lastSync = mLastCalendarSync; | 721 | QDateTime lastSync = mLastCalendarSync; |
722 | QDateTime localMod = local->lastModified(); | 722 | QDateTime localMod = local->lastModified(); |
723 | QDateTime remoteMod = remote->lastModified(); | 723 | QDateTime remoteMod = remote->lastModified(); |
724 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 724 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
725 | bool remCh, locCh; | 725 | bool remCh, locCh; |
726 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 726 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
727 | //if ( remCh ) | 727 | //if ( remCh ) |
728 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 728 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
729 | locCh = ( localMod > mLastCalendarSync ); | 729 | locCh = ( localMod > mLastCalendarSync ); |
730 | if ( !remCh && ! locCh ) { | 730 | if ( !remCh && ! locCh ) { |
731 | //qDebug("both not changed "); | 731 | //qDebug("both not changed "); |
732 | lastSync = localMod.addDays(1); | 732 | lastSync = localMod.addDays(1); |
733 | if ( mode <= SYNC_PREF_ASK ) | 733 | if ( mode <= SYNC_PREF_ASK ) |
734 | return 0; | 734 | return 0; |
735 | } else { | 735 | } else { |
736 | if ( locCh ) { | 736 | if ( locCh ) { |
737 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 737 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
738 | lastSync = localMod.addDays( -1 ); | 738 | lastSync = localMod.addDays( -1 ); |
739 | if ( !remCh ) | 739 | if ( !remCh ) |
740 | remoteMod = ( lastSync.addDays( -1 ) ); | 740 | remoteMod = ( lastSync.addDays( -1 ) ); |
741 | } else { | 741 | } else { |
742 | //qDebug(" not loc changed "); | 742 | //qDebug(" not loc changed "); |
743 | lastSync = localMod.addDays( 1 ); | 743 | lastSync = localMod.addDays( 1 ); |
744 | if ( remCh ) | 744 | if ( remCh ) |
745 | remoteMod =( lastSync.addDays( 1 ) ); | 745 | remoteMod =( lastSync.addDays( 1 ) ); |
746 | 746 | ||
747 | } | 747 | } |
748 | } | 748 | } |
749 | full = true; | 749 | full = true; |
750 | if ( mode < SYNC_PREF_ASK ) | 750 | if ( mode < SYNC_PREF_ASK ) |
751 | mode = SYNC_PREF_ASK; | 751 | mode = SYNC_PREF_ASK; |
752 | } else { | 752 | } else { |
753 | if ( localMod == remoteMod ) | 753 | if ( localMod == remoteMod ) |
754 | // if ( local->revision() == remote->revision() ) | 754 | // if ( local->revision() == remote->revision() ) |
755 | return 0; | 755 | return 0; |
756 | 756 | ||
757 | } | 757 | } |
758 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 758 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
759 | 759 | ||
760 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 760 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
761 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 761 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
762 | //full = true; //debug only | 762 | //full = true; //debug only |
763 | if ( full ) { | 763 | if ( full ) { |
764 | bool equ = false; | 764 | bool equ = false; |
765 | if ( local->type() == "Event" ) { | 765 | if ( local->type() == "Event" ) { |
766 | equ = (*((Event*) local) == *((Event*) remote)); | 766 | equ = (*((Event*) local) == *((Event*) remote)); |
767 | } | 767 | } |
768 | else if ( local->type() =="Todo" ) | 768 | else if ( local->type() =="Todo" ) |
769 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 769 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
770 | else if ( local->type() =="Journal" ) | 770 | else if ( local->type() =="Journal" ) |
771 | equ = (*((Journal*) local) == *((Journal*) remote)); | 771 | equ = (*((Journal*) local) == *((Journal*) remote)); |
772 | if ( equ ) { | 772 | if ( equ ) { |
773 | //qDebug("equal "); | 773 | //qDebug("equal "); |
774 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 774 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
775 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 775 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
776 | } | 776 | } |
777 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 777 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
778 | return 0; | 778 | return 0; |
779 | 779 | ||
780 | }//else //debug only | 780 | }//else //debug only |
781 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 781 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
782 | } | 782 | } |
783 | int result; | 783 | int result; |
784 | bool localIsNew; | 784 | bool localIsNew; |
785 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); | 785 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); |
786 | 786 | ||
787 | if ( full && mode < SYNC_PREF_NEWEST ) | 787 | if ( full && mode < SYNC_PREF_NEWEST ) |
788 | mode = SYNC_PREF_ASK; | 788 | mode = SYNC_PREF_ASK; |
789 | 789 | ||
790 | switch( mode ) { | 790 | switch( mode ) { |
791 | case SYNC_PREF_LOCAL: | 791 | case SYNC_PREF_LOCAL: |
792 | if ( lastSync > remoteMod ) | 792 | if ( lastSync > remoteMod ) |
793 | return 1; | 793 | return 1; |
794 | if ( lastSync > localMod ) | 794 | if ( lastSync > localMod ) |
795 | return 2; | 795 | return 2; |
796 | return 1; | 796 | return 1; |
797 | break; | 797 | break; |
798 | case SYNC_PREF_REMOTE: | 798 | case SYNC_PREF_REMOTE: |
799 | if ( lastSync > remoteMod ) | 799 | if ( lastSync > remoteMod ) |
800 | return 1; | 800 | return 1; |
801 | if ( lastSync > localMod ) | 801 | if ( lastSync > localMod ) |
802 | return 2; | 802 | return 2; |
803 | return 2; | 803 | return 2; |
804 | break; | 804 | break; |
805 | case SYNC_PREF_NEWEST: | 805 | case SYNC_PREF_NEWEST: |
806 | if ( localMod > remoteMod ) | 806 | if ( localMod > remoteMod ) |
807 | return 1; | 807 | return 1; |
808 | else | 808 | else |
809 | return 2; | 809 | return 2; |
810 | break; | 810 | break; |
811 | case SYNC_PREF_ASK: | 811 | case SYNC_PREF_ASK: |
812 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 812 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
813 | if ( lastSync > remoteMod ) | 813 | if ( lastSync > remoteMod ) |
814 | return 1; | 814 | return 1; |
815 | if ( lastSync > localMod ) | 815 | if ( lastSync > localMod ) |
816 | return 2; | 816 | return 2; |
817 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 817 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
818 | localIsNew = localMod >= remoteMod; | 818 | localIsNew = localMod >= remoteMod; |
819 | if ( localIsNew ) | 819 | if ( localIsNew ) |
820 | getEventViewerDialog()->setColorMode( 1 ); | 820 | getEventViewerDialog()->setColorMode( 1 ); |
821 | else | 821 | else |
822 | getEventViewerDialog()->setColorMode( 2 ); | 822 | getEventViewerDialog()->setColorMode( 2 ); |
823 | getEventViewerDialog()->setIncidence(local); | 823 | getEventViewerDialog()->setIncidence(local); |
824 | if ( localIsNew ) | 824 | if ( localIsNew ) |
825 | getEventViewerDialog()->setColorMode( 2 ); | 825 | getEventViewerDialog()->setColorMode( 2 ); |
826 | else | 826 | else |
827 | getEventViewerDialog()->setColorMode( 1 ); | 827 | getEventViewerDialog()->setColorMode( 1 ); |
828 | getEventViewerDialog()->addIncidence(remote); | 828 | getEventViewerDialog()->addIncidence(remote); |
829 | getEventViewerDialog()->setColorMode( 0 ); | 829 | getEventViewerDialog()->setColorMode( 0 ); |
830 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 830 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
831 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 831 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
832 | getEventViewerDialog()->showMe(); | 832 | getEventViewerDialog()->showMe(); |
833 | result = getEventViewerDialog()->executeS( localIsNew ); | 833 | result = getEventViewerDialog()->executeS( localIsNew ); |
834 | return result; | 834 | return result; |
835 | 835 | ||
836 | break; | 836 | break; |
837 | case SYNC_PREF_FORCE_LOCAL: | 837 | case SYNC_PREF_FORCE_LOCAL: |
838 | return 1; | 838 | return 1; |
839 | break; | 839 | break; |
840 | case SYNC_PREF_FORCE_REMOTE: | 840 | case SYNC_PREF_FORCE_REMOTE: |
841 | return 2; | 841 | return 2; |
842 | break; | 842 | break; |
843 | 843 | ||
844 | default: | 844 | default: |
845 | // SYNC_PREF_TAKE_BOTH not implemented | 845 | // SYNC_PREF_TAKE_BOTH not implemented |
846 | break; | 846 | break; |
847 | } | 847 | } |
848 | return 0; | 848 | return 0; |
849 | } | 849 | } |
850 | Event* CalendarView::getLastSyncEvent() | 850 | Event* CalendarView::getLastSyncEvent() |
851 | { | 851 | { |
852 | Event* lse; | 852 | Event* lse; |
853 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 853 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
854 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 854 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
855 | if (!lse) { | 855 | if (!lse) { |
856 | lse = new Event(); | 856 | lse = new Event(); |
857 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 857 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
858 | QString sum = ""; | 858 | QString sum = ""; |
859 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 859 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
860 | sum = "E: "; | 860 | sum = "E: "; |
861 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 861 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
862 | lse->setDtStart( mLastCalendarSync ); | 862 | lse->setDtStart( mLastCalendarSync ); |
863 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 863 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
864 | lse->setCategories( i18n("SyncEvent") ); | 864 | lse->setCategories( i18n("SyncEvent") ); |
865 | lse->setReadOnly( true ); | 865 | lse->setReadOnly( true ); |
866 | mCalendar->addEvent( lse ); | 866 | mCalendar->addEvent( lse ); |
867 | } | 867 | } |
868 | 868 | ||
869 | return lse; | 869 | return lse; |
870 | 870 | ||
871 | } | 871 | } |
872 | 872 | ||
873 | // we check, if the to delete event has a id for a profile | 873 | // we check, if the to delete event has a id for a profile |
874 | // if yes, we set this id in the profile to delete | 874 | // if yes, we set this id in the profile to delete |
875 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 875 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
876 | { | 876 | { |
877 | if ( lastSync.count() == 0 ) { | 877 | if ( lastSync.count() == 0 ) { |
878 | //qDebug(" lastSync.count() == 0"); | 878 | //qDebug(" lastSync.count() == 0"); |
879 | return; | 879 | return; |
880 | } | 880 | } |
881 | if ( toDelete->type() == "Journal" ) | 881 | if ( toDelete->type() == "Journal" ) |
882 | return; | 882 | return; |
883 | 883 | ||
884 | Event* eve = lastSync.first(); | 884 | Event* eve = lastSync.first(); |
885 | 885 | ||
886 | while ( eve ) { | 886 | while ( eve ) { |
887 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 887 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
888 | if ( !id.isEmpty() ) { | 888 | if ( !id.isEmpty() ) { |
889 | QString des = eve->description(); | 889 | QString des = eve->description(); |
890 | QString pref = "e"; | 890 | QString pref = "e"; |
891 | if ( toDelete->type() == "Todo" ) | 891 | if ( toDelete->type() == "Todo" ) |
892 | pref = "t"; | 892 | pref = "t"; |
893 | des += pref+ id + ","; | 893 | des += pref+ id + ","; |
894 | eve->setReadOnly( false ); | 894 | eve->setReadOnly( false ); |
895 | eve->setDescription( des ); | 895 | eve->setDescription( des ); |
896 | //qDebug("setdes %s ", des.latin1()); | 896 | //qDebug("setdes %s ", des.latin1()); |
897 | eve->setReadOnly( true ); | 897 | eve->setReadOnly( true ); |
898 | } | 898 | } |
899 | eve = lastSync.next(); | 899 | eve = lastSync.next(); |
900 | } | 900 | } |
901 | 901 | ||
902 | } | 902 | } |
903 | void CalendarView::checkExternalId( Incidence * inc ) | 903 | void CalendarView::checkExternalId( Incidence * inc ) |
904 | { | 904 | { |
905 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 905 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
906 | checkExternSyncEvent( lastSync, inc ); | 906 | checkExternSyncEvent( lastSync, inc ); |
907 | 907 | ||
908 | } | 908 | } |
909 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 909 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
910 | { | 910 | { |
911 | bool syncOK = true; | 911 | bool syncOK = true; |
912 | int addedEvent = 0; | 912 | int addedEvent = 0; |
913 | int addedEventR = 0; | 913 | int addedEventR = 0; |
914 | int deletedEventR = 0; | 914 | int deletedEventR = 0; |
915 | int deletedEventL = 0; | 915 | int deletedEventL = 0; |
916 | int changedLocal = 0; | 916 | int changedLocal = 0; |
917 | int changedRemote = 0; | 917 | int changedRemote = 0; |
918 | //QPtrList<Event> el = local->rawEvents(); | 918 | //QPtrList<Event> el = local->rawEvents(); |
919 | Event* eventR; | 919 | Event* eventR; |
920 | QString uid; | 920 | QString uid; |
921 | int take; | 921 | int take; |
922 | Event* eventL; | 922 | Event* eventL; |
923 | Event* eventRSync; | 923 | Event* eventRSync; |
924 | Event* eventLSync; | 924 | Event* eventLSync; |
925 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 925 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
926 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 926 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
927 | bool fullDateRange = false; | 927 | bool fullDateRange = false; |
928 | local->resetTempSyncStat(); | 928 | local->resetTempSyncStat(); |
929 | if ( mSyncKDE ) | 929 | if ( mSyncKDE ) |
930 | remote->resetPilotStat(1); | 930 | remote->resetPilotStat(1); |
931 | mLastCalendarSync = QDateTime::currentDateTime(); | 931 | mLastCalendarSync = QDateTime::currentDateTime(); |
932 | QDateTime modifiedCalendar = mLastCalendarSync;; | 932 | QDateTime modifiedCalendar = mLastCalendarSync;; |
933 | eventLSync = getLastSyncEvent(); | 933 | eventLSync = getLastSyncEvent(); |
934 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 934 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
935 | if ( eventR ) { | 935 | if ( eventR ) { |
936 | eventRSync = (Event*) eventR->clone(); | 936 | eventRSync = (Event*) eventR->clone(); |
937 | remote->deleteEvent(eventR ); | 937 | remote->deleteEvent(eventR ); |
938 | 938 | ||
939 | } else { | 939 | } else { |
940 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncKDE) { | 940 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncKDE) { |
941 | eventRSync = (Event*)eventLSync->clone(); | 941 | eventRSync = (Event*)eventLSync->clone(); |
942 | } else { | 942 | } else { |
943 | fullDateRange = true; | 943 | fullDateRange = true; |
944 | eventRSync = new Event(); | 944 | eventRSync = new Event(); |
945 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 945 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
946 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 946 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
947 | eventRSync->setDtStart( mLastCalendarSync ); | 947 | eventRSync->setDtStart( mLastCalendarSync ); |
948 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 948 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
949 | eventRSync->setCategories( i18n("SyncEvent") ); | 949 | eventRSync->setCategories( i18n("SyncEvent") ); |
950 | } | 950 | } |
951 | } | 951 | } |
952 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 952 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
953 | fullDateRange = true; | 953 | fullDateRange = true; |
954 | 954 | ||
955 | if ( ! fullDateRange ) { | 955 | if ( ! fullDateRange ) { |
956 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 956 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
957 | 957 | ||
958 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 958 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
959 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 959 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
960 | fullDateRange = true; | 960 | fullDateRange = true; |
961 | } | 961 | } |
962 | } | 962 | } |
963 | if ( fullDateRange && !mSyncKDE ) | 963 | if ( mSyncKDE ) { |
964 | fullDateRange = ( eventLSync->dtStart() == mLastCalendarSync ); | ||
965 | } | ||
966 | if ( fullDateRange ) | ||
964 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 967 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
965 | else | 968 | else |
966 | mLastCalendarSync = eventLSync->dtStart(); | 969 | mLastCalendarSync = eventLSync->dtStart(); |
967 | // for resyncing if own file has changed | 970 | // for resyncing if own file has changed |
968 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 971 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
969 | mLastCalendarSync = loadedFileVersion; | 972 | mLastCalendarSync = loadedFileVersion; |
970 | //qDebug("setting mLastCalendarSync "); | 973 | //qDebug("setting mLastCalendarSync "); |
971 | } | 974 | } |
972 | //qDebug("*************************** "); | 975 | //qDebug("*************************** "); |
973 | qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 976 | qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
974 | QPtrList<Incidence> er = remote->rawIncidences(); | 977 | QPtrList<Incidence> er = remote->rawIncidences(); |
975 | Incidence* inR = er.first(); | 978 | Incidence* inR = er.first(); |
976 | Incidence* inL; | 979 | Incidence* inL; |
977 | QProgressBar bar( er.count(),0 ); | 980 | QProgressBar bar( er.count(),0 ); |
978 | bar.setCaption (i18n("Syncing - close to abort!") ); | 981 | bar.setCaption (i18n("Syncing - close to abort!") ); |
979 | 982 | ||
980 | int w = 300; | 983 | int w = 300; |
981 | if ( QApplication::desktop()->width() < 320 ) | 984 | if ( QApplication::desktop()->width() < 320 ) |
982 | w = 220; | 985 | w = 220; |
983 | int h = bar.sizeHint().height() ; | 986 | int h = bar.sizeHint().height() ; |
984 | int dw = QApplication::desktop()->width(); | 987 | int dw = QApplication::desktop()->width(); |
985 | int dh = QApplication::desktop()->height(); | 988 | int dh = QApplication::desktop()->height(); |
986 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 989 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
987 | bar.show(); | 990 | bar.show(); |
988 | int modulo = (er.count()/10)+1; | 991 | int modulo = (er.count()/10)+1; |
989 | int incCounter = 0; | 992 | int incCounter = 0; |
990 | while ( inR ) { | 993 | while ( inR ) { |
991 | if ( ! bar.isVisible() ) | 994 | if ( ! bar.isVisible() ) |
992 | return false; | 995 | return false; |
993 | if ( incCounter % modulo == 0 ) | 996 | if ( incCounter % modulo == 0 ) |
994 | bar.setProgress( incCounter ); | 997 | bar.setProgress( incCounter ); |
995 | ++incCounter; | 998 | ++incCounter; |
996 | uid = inR->uid(); | 999 | uid = inR->uid(); |
997 | bool skipIncidence = false; | 1000 | bool skipIncidence = false; |
998 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1001 | if ( uid.left(15) == QString("last-syncEvent-") ) |
999 | skipIncidence = true; | 1002 | skipIncidence = true; |
1000 | QString idS; | 1003 | QString idS; |
1001 | qApp->processEvents(); | 1004 | qApp->processEvents(); |
1002 | if ( !skipIncidence ) { | 1005 | if ( !skipIncidence ) { |
1003 | inL = local->incidence( uid ); | 1006 | inL = local->incidence( uid ); |
1004 | if ( inL ) { // maybe conflict - same uid in both calendars | 1007 | if ( inL ) { // maybe conflict - same uid in both calendars |
1005 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1008 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1006 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1009 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1007 | if ( take == 3 ) | 1010 | if ( take == 3 ) |
1008 | return false; | 1011 | return false; |
1009 | if ( take == 1 ) {// take local | 1012 | if ( take == 1 ) {// take local |
1010 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1013 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1011 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1014 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1012 | else | 1015 | else |
1013 | idS = inR->IDStr(); | 1016 | idS = inR->IDStr(); |
1014 | remote->deleteIncidence( inR ); | 1017 | remote->deleteIncidence( inR ); |
1015 | inR = inL->clone(); | 1018 | inR = inL->clone(); |
1016 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1019 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1017 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1020 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1018 | inR->setIDStr( idS ); | 1021 | inR->setIDStr( idS ); |
1019 | remote->addIncidence( inR ); | 1022 | remote->addIncidence( inR ); |
1020 | if ( mSyncKDE ) | 1023 | if ( mSyncKDE ) |
1021 | inR->setPilotId( 2 ); | 1024 | inR->setPilotId( 2 ); |
1022 | ++changedRemote; | 1025 | ++changedRemote; |
1023 | } else { | 1026 | } else { |
1024 | idS = inL->IDStr(); | 1027 | idS = inL->IDStr(); |
1025 | int pid = inL->pilotId(); | 1028 | int pid = inL->pilotId(); |
1026 | local->deleteIncidence( inL ); | 1029 | local->deleteIncidence( inL ); |
1027 | inL = inR->clone(); | 1030 | inL = inR->clone(); |
1028 | if ( mSyncKDE ) | 1031 | if ( mSyncKDE ) |
1029 | inL->setPilotId( pid ); | 1032 | inL->setPilotId( pid ); |
1030 | inL->setIDStr( idS ); | 1033 | inL->setIDStr( idS ); |
1031 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1034 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1032 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1035 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1033 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1036 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1034 | } | 1037 | } |
1035 | local->addIncidence( inL ); | 1038 | local->addIncidence( inL ); |
1036 | ++changedLocal; | 1039 | ++changedLocal; |
1037 | } | 1040 | } |
1038 | } | 1041 | } |
1039 | } else { // no conflict | 1042 | } else { // no conflict |
1040 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1043 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1041 | QString des = eventLSync->description(); | 1044 | QString des = eventLSync->description(); |
1042 | QString pref = "e"; | 1045 | QString pref = "e"; |
1043 | if ( inR->type() == "Todo" ) | 1046 | if ( inR->type() == "Todo" ) |
1044 | pref = "t"; | 1047 | pref = "t"; |
1045 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1048 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1046 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1049 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1047 | //remote->deleteIncidence( inR ); | 1050 | //remote->deleteIncidence( inR ); |
1048 | ++deletedEventR; | 1051 | ++deletedEventR; |
1049 | } else { | 1052 | } else { |
1050 | inR->setLastModified( modifiedCalendar ); | 1053 | inR->setLastModified( modifiedCalendar ); |
1051 | inL = inR->clone(); | 1054 | inL = inR->clone(); |
1055 | inL->setIDStr( ":" ); | ||
1052 | local->addIncidence( inL ); | 1056 | local->addIncidence( inL ); |
1053 | ++addedEvent; | 1057 | ++addedEvent; |
1054 | } | 1058 | } |
1055 | } else { | 1059 | } else { |
1056 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1060 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1057 | inR->setLastModified( modifiedCalendar ); | 1061 | inR->setLastModified( modifiedCalendar ); |
1058 | local->addIncidence( inR->clone() ); | 1062 | inL = inR->clone(); |
1063 | inL->setIDStr( ":" ); | ||
1064 | local->addIncidence( inL ); | ||
1059 | ++addedEvent; | 1065 | ++addedEvent; |
1060 | } else { | 1066 | } else { |
1061 | checkExternSyncEvent(eventRSyncSharp, inR); | 1067 | checkExternSyncEvent(eventRSyncSharp, inR); |
1062 | remote->deleteIncidence( inR ); | 1068 | remote->deleteIncidence( inR ); |
1063 | ++deletedEventR; | 1069 | ++deletedEventR; |
1064 | } | 1070 | } |
1065 | } | 1071 | } |
1066 | } | 1072 | } |
1067 | } | 1073 | } |
1068 | inR = er.next(); | 1074 | inR = er.next(); |
1069 | } | 1075 | } |
1070 | QPtrList<Incidence> el = local->rawIncidences(); | 1076 | QPtrList<Incidence> el = local->rawIncidences(); |
1071 | inL = el.first(); | 1077 | inL = el.first(); |
1072 | modulo = (el.count()/10)+1; | 1078 | modulo = (el.count()/10)+1; |
1073 | bar.setCaption (i18n("Add / remove events") ); | 1079 | bar.setCaption (i18n("Add / remove events") ); |
1074 | bar.setTotalSteps ( el.count() ) ; | 1080 | bar.setTotalSteps ( el.count() ) ; |
1075 | bar.show(); | 1081 | bar.show(); |
1076 | incCounter = 0; | 1082 | incCounter = 0; |
1077 | 1083 | ||
1078 | while ( inL ) { | 1084 | while ( inL ) { |
1079 | 1085 | ||
1080 | qApp->processEvents(); | 1086 | qApp->processEvents(); |
1081 | if ( ! bar.isVisible() ) | 1087 | if ( ! bar.isVisible() ) |
1082 | return false; | 1088 | return false; |
1083 | if ( incCounter % modulo == 0 ) | 1089 | if ( incCounter % modulo == 0 ) |
1084 | bar.setProgress( incCounter ); | 1090 | bar.setProgress( incCounter ); |
1085 | ++incCounter; | 1091 | ++incCounter; |
1086 | uid = inL->uid(); | 1092 | uid = inL->uid(); |
1087 | bool skipIncidence = false; | 1093 | bool skipIncidence = false; |
1088 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1094 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1089 | skipIncidence = true; | 1095 | skipIncidence = true; |
1090 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1096 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1091 | skipIncidence = true; | 1097 | skipIncidence = true; |
1092 | if ( !skipIncidence ) { | 1098 | if ( !skipIncidence ) { |
1093 | inR = remote->incidence( uid ); | 1099 | inR = remote->incidence( uid ); |
1094 | if ( ! inR ) { | 1100 | if ( ! inR ) { |
1095 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1101 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1096 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1102 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1097 | checkExternSyncEvent(eventLSyncSharp, inL); | 1103 | checkExternSyncEvent(eventLSyncSharp, inL); |
1098 | local->deleteIncidence( inL ); | 1104 | local->deleteIncidence( inL ); |
1099 | ++deletedEventL; | 1105 | ++deletedEventL; |
1100 | } else { | 1106 | } else { |
1101 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1107 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1102 | inL->removeID(mCurrentSyncDevice ); | 1108 | inL->removeID(mCurrentSyncDevice ); |
1103 | ++addedEventR; | 1109 | ++addedEventR; |
1104 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1110 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1105 | inL->setLastModified( modifiedCalendar ); | 1111 | inL->setLastModified( modifiedCalendar ); |
1106 | inR = inL->clone(); | 1112 | inR = inL->clone(); |
1113 | inR->setIDStr( ":" ); | ||
1107 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1114 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1108 | remote->addIncidence( inR ); | 1115 | remote->addIncidence( inR ); |
1109 | } | 1116 | } |
1110 | } | 1117 | } |
1111 | } else { | 1118 | } else { |
1112 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1119 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1113 | checkExternSyncEvent(eventLSyncSharp, inL); | 1120 | checkExternSyncEvent(eventLSyncSharp, inL); |
1114 | local->deleteIncidence( inL ); | 1121 | local->deleteIncidence( inL ); |
1115 | ++deletedEventL; | 1122 | ++deletedEventL; |
1116 | } else { | 1123 | } else { |
1117 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1124 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1118 | ++addedEventR; | 1125 | ++addedEventR; |
1119 | inL->setLastModified( modifiedCalendar ); | 1126 | inL->setLastModified( modifiedCalendar ); |
1120 | remote->addIncidence( inL->clone() ); | 1127 | inR = inL->clone(); |
1128 | inR->setIDStr( ":" ); | ||
1129 | remote->addIncidence( inR ); | ||
1121 | } | 1130 | } |
1122 | } | 1131 | } |
1123 | } | 1132 | } |
1124 | } | 1133 | } |
1125 | } | 1134 | } |
1126 | inL = el.next(); | 1135 | inL = el.next(); |
1127 | } | 1136 | } |
1128 | int delFut = 0; | 1137 | int delFut = 0; |
1129 | int remRem = 0; | 1138 | int remRem = 0; |
1130 | if ( mSyncManager->mWriteBackInFuture ) { | 1139 | if ( mSyncManager->mWriteBackInFuture ) { |
1131 | er = remote->rawIncidences(); | 1140 | er = remote->rawIncidences(); |
1132 | remRem = er.count(); | 1141 | remRem = er.count(); |
1133 | inR = er.first(); | 1142 | inR = er.first(); |
1134 | QDateTime dt; | 1143 | QDateTime dt; |
1135 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 1144 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1136 | QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); | 1145 | QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); |
1137 | while ( inR ) { | 1146 | while ( inR ) { |
1138 | if ( inR->type() == "Todo" ) { | 1147 | if ( inR->type() == "Todo" ) { |
1139 | Todo * t = (Todo*)inR; | 1148 | Todo * t = (Todo*)inR; |
1140 | if ( t->hasDueDate() ) | 1149 | if ( t->hasDueDate() ) |
1141 | dt = t->dtDue(); | 1150 | dt = t->dtDue(); |
1142 | else | 1151 | else |
1143 | dt = cur.addSecs( 62 ); | 1152 | dt = cur.addSecs( 62 ); |
1144 | } | 1153 | } |
1145 | else if (inR->type() == "Event" ) { | 1154 | else if (inR->type() == "Event" ) { |
1146 | bool ok; | 1155 | bool ok; |
1147 | dt = inR->getNextOccurence( cur, &ok ); | 1156 | dt = inR->getNextOccurence( cur, &ok ); |
1148 | if ( !ok ) | 1157 | if ( !ok ) |
1149 | dt = cur.addSecs( -62 ); | 1158 | dt = cur.addSecs( -62 ); |
1150 | } | 1159 | } |
1151 | else | 1160 | else |
1152 | dt = inR->dtStart(); | 1161 | dt = inR->dtStart(); |
1153 | if ( dt < cur || dt > end ) { | 1162 | if ( dt < cur || dt > end ) { |
1154 | remote->deleteIncidence( inR ); | 1163 | remote->deleteIncidence( inR ); |
1155 | ++delFut; | 1164 | ++delFut; |
1156 | } | 1165 | } |
1157 | inR = er.next(); | 1166 | inR = er.next(); |
1158 | } | 1167 | } |
1159 | } | 1168 | } |
1160 | bar.hide(); | 1169 | bar.hide(); |
1161 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1170 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1162 | eventLSync->setReadOnly( false ); | 1171 | eventLSync->setReadOnly( false ); |
1163 | eventLSync->setDtStart( mLastCalendarSync ); | 1172 | eventLSync->setDtStart( mLastCalendarSync ); |
1164 | eventRSync->setDtStart( mLastCalendarSync ); | 1173 | eventRSync->setDtStart( mLastCalendarSync ); |
1165 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1174 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1166 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1175 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1167 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1176 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1168 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1177 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1169 | eventLSync->setReadOnly( true ); | 1178 | eventLSync->setReadOnly( true ); |
1170 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncKDE) // kde is abnormal... | 1179 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncKDE) // kde is abnormal... |
1171 | remote->addEvent( eventRSync ); | 1180 | remote->addEvent( eventRSync ); |
1172 | else | 1181 | else |
1173 | delete eventRSync; | 1182 | delete eventRSync; |
1174 | QString mes; | 1183 | QString mes; |
1175 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); | 1184 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); |
1176 | QString delmess; | 1185 | QString delmess; |
1177 | if ( delFut ) { | 1186 | if ( delFut ) { |
1178 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut); | 1187 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1179 | mes += delmess; | 1188 | mes += delmess; |
1180 | } | 1189 | } |
1181 | if ( mSyncManager->mShowSyncSummary ) { | 1190 | if ( mSyncManager->mShowSyncSummary ) { |
1182 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); | 1191 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); |
1183 | } | 1192 | } |
1184 | qDebug( mes ); | 1193 | qDebug( mes ); |
1185 | mCalendar->checkAlarmForIncidence( 0, true ); | 1194 | mCalendar->checkAlarmForIncidence( 0, true ); |
1186 | return syncOK; | 1195 | return syncOK; |
1187 | } | 1196 | } |
1188 | 1197 | ||
1189 | void CalendarView::setSyncDevice( QString s ) | 1198 | void CalendarView::setSyncDevice( QString s ) |
1190 | { | 1199 | { |
1191 | mCurrentSyncDevice= s; | 1200 | mCurrentSyncDevice= s; |
1192 | } | 1201 | } |
1193 | void CalendarView::setSyncName( QString s ) | 1202 | void CalendarView::setSyncName( QString s ) |
1194 | { | 1203 | { |
1195 | mCurrentSyncName= s; | 1204 | mCurrentSyncName= s; |
1196 | } | 1205 | } |
1197 | bool CalendarView::syncCalendar(QString filename, int mode) | 1206 | bool CalendarView::syncCalendar(QString filename, int mode) |
1198 | { | 1207 | { |
1199 | //qDebug("syncCalendar %s ", filename.latin1()); | 1208 | //qDebug("syncCalendar %s ", filename.latin1()); |
1200 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1209 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1201 | CalendarLocal* calendar = new CalendarLocal(); | 1210 | CalendarLocal* calendar = new CalendarLocal(); |
1202 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1211 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1203 | FileStorage* storage = new FileStorage( calendar ); | 1212 | FileStorage* storage = new FileStorage( calendar ); |
1204 | bool syncOK = false; | 1213 | bool syncOK = false; |
1205 | storage->setFileName( filename ); | 1214 | storage->setFileName( filename ); |
1206 | // qDebug("loading ... "); | 1215 | // qDebug("loading ... "); |
1207 | if ( storage->load() ) { | 1216 | if ( storage->load() ) { |
1208 | getEventViewerDialog()->setSyncMode( true ); | 1217 | getEventViewerDialog()->setSyncMode( true ); |
1209 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1218 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1210 | getEventViewerDialog()->setSyncMode( false ); | 1219 | getEventViewerDialog()->setSyncMode( false ); |
1211 | if ( syncOK ) { | 1220 | if ( syncOK ) { |
1212 | if ( mSyncManager->mWriteBackFile ) | 1221 | if ( mSyncManager->mWriteBackFile ) |
1213 | { | 1222 | { |
1214 | storage->setSaveFormat( new ICalFormat() ); | 1223 | storage->setSaveFormat( new ICalFormat() ); |
1215 | storage->save(); | 1224 | storage->save(); |
1216 | } | 1225 | } |
1217 | } | 1226 | } |
1218 | setModified( true ); | 1227 | setModified( true ); |
1219 | } | 1228 | } |
1220 | delete storage; | 1229 | delete storage; |
1221 | delete calendar; | 1230 | delete calendar; |
1222 | if ( syncOK ) | 1231 | if ( syncOK ) |
1223 | updateView(); | 1232 | updateView(); |
1224 | return syncOK; | 1233 | return syncOK; |
1225 | } | 1234 | } |
1226 | 1235 | ||
1227 | void CalendarView::syncExternal( int mode ) | 1236 | void CalendarView::syncExternal( int mode ) |
1228 | { | 1237 | { |
1229 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1238 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1230 | 1239 | ||
1231 | qApp->processEvents(); | 1240 | qApp->processEvents(); |
1232 | CalendarLocal* calendar = new CalendarLocal(); | 1241 | CalendarLocal* calendar = new CalendarLocal(); |
1233 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1242 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1234 | bool syncOK = false; | 1243 | bool syncOK = false; |
1235 | bool loadSuccess = false; | 1244 | bool loadSuccess = false; |
1236 | PhoneFormat* phoneFormat = 0; | 1245 | PhoneFormat* phoneFormat = 0; |
1237 | emit tempDisableBR(true); | 1246 | emit tempDisableBR(true); |
1238 | #ifndef DESKTOP_VERSION | 1247 | #ifndef DESKTOP_VERSION |
1239 | SharpFormat* sharpFormat = 0; | 1248 | SharpFormat* sharpFormat = 0; |
1240 | if ( mode == 0 ) { // sharp | 1249 | if ( mode == 0 ) { // sharp |
1241 | sharpFormat = new SharpFormat () ; | 1250 | sharpFormat = new SharpFormat () ; |
1242 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1251 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1243 | 1252 | ||
1244 | } else | 1253 | } else |
1245 | #endif | 1254 | #endif |
1246 | if ( mode == 1 ) { // phone | 1255 | if ( mode == 1 ) { // phone |
1247 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1256 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1248 | mSyncManager->mPhoneDevice, | 1257 | mSyncManager->mPhoneDevice, |
1249 | mSyncManager->mPhoneConnection, | 1258 | mSyncManager->mPhoneConnection, |
1250 | mSyncManager->mPhoneModel); | 1259 | mSyncManager->mPhoneModel); |
1251 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1260 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1252 | 1261 | ||
1253 | } else { | 1262 | } else { |
1254 | emit tempDisableBR(false); | 1263 | emit tempDisableBR(false); |
1255 | return; | 1264 | return; |
1256 | } | 1265 | } |
1257 | if ( loadSuccess ) { | 1266 | if ( loadSuccess ) { |
1258 | getEventViewerDialog()->setSyncMode( true ); | 1267 | getEventViewerDialog()->setSyncMode( true ); |
1259 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1268 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1260 | getEventViewerDialog()->setSyncMode( false ); | 1269 | getEventViewerDialog()->setSyncMode( false ); |
1261 | qApp->processEvents(); | 1270 | qApp->processEvents(); |
1262 | if ( syncOK ) { | 1271 | if ( syncOK ) { |
1263 | if ( mSyncManager->mWriteBackFile ) | 1272 | if ( mSyncManager->mWriteBackFile ) |
1264 | { | 1273 | { |
1265 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1274 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1266 | Incidence* inc = iL.first(); | 1275 | Incidence* inc = iL.first(); |
1267 | if ( phoneFormat ) { | 1276 | if ( phoneFormat ) { |
1268 | while ( inc ) { | 1277 | while ( inc ) { |
1269 | inc->removeID(mCurrentSyncDevice); | 1278 | inc->removeID(mCurrentSyncDevice); |
1270 | inc = iL.next(); | 1279 | inc = iL.next(); |
1271 | } | 1280 | } |
1272 | } | 1281 | } |
1273 | #ifndef DESKTOP_VERSION | 1282 | #ifndef DESKTOP_VERSION |
1274 | if ( sharpFormat ) | 1283 | if ( sharpFormat ) |
1275 | sharpFormat->save(calendar); | 1284 | sharpFormat->save(calendar); |
1276 | #endif | 1285 | #endif |
1277 | if ( phoneFormat ) | 1286 | if ( phoneFormat ) |
1278 | phoneFormat->save(calendar); | 1287 | phoneFormat->save(calendar); |
1279 | iL = calendar->rawIncidences(); | 1288 | iL = calendar->rawIncidences(); |
1280 | inc = iL.first(); | 1289 | inc = iL.first(); |
1281 | Incidence* loc; | 1290 | Incidence* loc; |
1282 | while ( inc ) { | 1291 | while ( inc ) { |
1283 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1292 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1284 | loc = mCalendar->incidence(inc->uid() ); | 1293 | loc = mCalendar->incidence(inc->uid() ); |
1285 | if ( loc ) { | 1294 | if ( loc ) { |
1286 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1295 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1287 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1296 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1288 | } | 1297 | } |
1289 | } | 1298 | } |
1290 | inc = iL.next(); | 1299 | inc = iL.next(); |
1291 | } | 1300 | } |
1292 | Incidence* lse = getLastSyncEvent(); | 1301 | Incidence* lse = getLastSyncEvent(); |
1293 | if ( lse ) { | 1302 | if ( lse ) { |
1294 | lse->setReadOnly( false ); | 1303 | lse->setReadOnly( false ); |
1295 | lse->setDescription( "" ); | 1304 | lse->setDescription( "" ); |
1296 | lse->setReadOnly( true ); | 1305 | lse->setReadOnly( true ); |
1297 | } | 1306 | } |
1298 | } | 1307 | } |
1299 | } | 1308 | } |
1300 | setModified( true ); | 1309 | setModified( true ); |
1301 | } else { | 1310 | } else { |
1302 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1311 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1303 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1312 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1304 | question, i18n("Ok")) ; | 1313 | question, i18n("Ok")) ; |
1305 | 1314 | ||
1306 | } | 1315 | } |
1307 | delete calendar; | 1316 | delete calendar; |
1308 | updateView(); | 1317 | updateView(); |
1309 | emit tempDisableBR(false); | 1318 | emit tempDisableBR(false); |
1310 | return ;//syncOK; | 1319 | return ;//syncOK; |
1311 | 1320 | ||
1312 | } | 1321 | } |
1313 | 1322 | ||
1314 | bool CalendarView::importBday() | 1323 | bool CalendarView::importBday() |
1315 | { | 1324 | { |
1316 | #ifndef KORG_NOKABC | 1325 | #ifndef KORG_NOKABC |
1317 | 1326 | ||
1318 | #ifdef DESKTOP_VERSION | 1327 | #ifdef DESKTOP_VERSION |
1319 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1328 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1320 | KABC::AddressBook::Iterator it; | 1329 | KABC::AddressBook::Iterator it; |
1321 | int count = 0; | 1330 | int count = 0; |
1322 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1331 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1323 | ++count; | 1332 | ++count; |
1324 | } | 1333 | } |
1325 | QProgressBar bar(count,0 ); | 1334 | QProgressBar bar(count,0 ); |
1326 | int w = 300; | 1335 | int w = 300; |
1327 | if ( QApplication::desktop()->width() < 320 ) | 1336 | if ( QApplication::desktop()->width() < 320 ) |
1328 | w = 220; | 1337 | w = 220; |
1329 | int h = bar.sizeHint().height() ; | 1338 | int h = bar.sizeHint().height() ; |
1330 | int dw = QApplication::desktop()->width(); | 1339 | int dw = QApplication::desktop()->width(); |
1331 | int dh = QApplication::desktop()->height(); | 1340 | int dh = QApplication::desktop()->height(); |
1332 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1341 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1333 | bar.show(); | 1342 | bar.show(); |
1334 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1343 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1335 | qApp->processEvents(); | 1344 | qApp->processEvents(); |
1336 | count = 0; | 1345 | count = 0; |
1337 | int addCount = 0; | 1346 | int addCount = 0; |
1338 | KCal::Attendee* a = 0; | 1347 | KCal::Attendee* a = 0; |
1339 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1348 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1340 | if ( ! bar.isVisible() ) | 1349 | if ( ! bar.isVisible() ) |
1341 | return false; | 1350 | return false; |
1342 | bar.setProgress( count++ ); | 1351 | bar.setProgress( count++ ); |
1343 | qApp->processEvents(); | 1352 | qApp->processEvents(); |
1344 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1353 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1345 | if ( (*it).birthday().date().isValid() ){ | 1354 | if ( (*it).birthday().date().isValid() ){ |
1346 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1355 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1347 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1356 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1348 | ++addCount; | 1357 | ++addCount; |
1349 | } | 1358 | } |
1350 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1359 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1351 | if ( anni.isValid() ){ | 1360 | if ( anni.isValid() ){ |
1352 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1361 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1353 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1362 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1354 | ++addCount; | 1363 | ++addCount; |
1355 | } | 1364 | } |
1356 | } | 1365 | } |
1357 | updateView(); | 1366 | updateView(); |
1358 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1367 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1359 | #else //DESKTOP_VERSION | 1368 | #else //DESKTOP_VERSION |
1360 | 1369 | ||
1361 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1370 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1362 | // the result should now arrive through method insertBirthdays | 1371 | // the result should now arrive through method insertBirthdays |
1363 | 1372 | ||
1364 | #endif //DESKTOP_VERSION | 1373 | #endif //DESKTOP_VERSION |
1365 | 1374 | ||
1366 | #endif //KORG_NOKABC | 1375 | #endif //KORG_NOKABC |
1367 | 1376 | ||
1368 | 1377 | ||
1369 | return true; | 1378 | return true; |
1370 | } | 1379 | } |
1371 | 1380 | ||
1372 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1381 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1373 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1382 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1374 | const QStringList& anniversaryList, const QStringList& realNameList, | 1383 | const QStringList& anniversaryList, const QStringList& realNameList, |
1375 | const QStringList& emailList, const QStringList& assembledNameList, | 1384 | const QStringList& emailList, const QStringList& assembledNameList, |
1376 | const QStringList& uidList) | 1385 | const QStringList& uidList) |
1377 | { | 1386 | { |
1378 | qDebug("CalendarView::insertBirthdays"); | 1387 | qDebug("CalendarView::insertBirthdays"); |
1379 | if (uid == this->name()) | 1388 | if (uid == this->name()) |
1380 | { | 1389 | { |
1381 | int count = birthdayList.count(); | 1390 | int count = birthdayList.count(); |
1382 | int addCount = 0; | 1391 | int addCount = 0; |
1383 | KCal::Attendee* a = 0; | 1392 | KCal::Attendee* a = 0; |
1384 | 1393 | ||
1385 | qDebug("CalView 1 %i", count); | 1394 | qDebug("CalView 1 %i", count); |
1386 | 1395 | ||
1387 | QProgressBar bar(count,0 ); | 1396 | QProgressBar bar(count,0 ); |
1388 | int w = 300; | 1397 | int w = 300; |
1389 | if ( QApplication::desktop()->width() < 320 ) | 1398 | if ( QApplication::desktop()->width() < 320 ) |
1390 | w = 220; | 1399 | w = 220; |
1391 | int h = bar.sizeHint().height() ; | 1400 | int h = bar.sizeHint().height() ; |
1392 | int dw = QApplication::desktop()->width(); | 1401 | int dw = QApplication::desktop()->width(); |
1393 | int dh = QApplication::desktop()->height(); | 1402 | int dh = QApplication::desktop()->height(); |
1394 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1403 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1395 | bar.show(); | 1404 | bar.show(); |
1396 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1405 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1397 | qApp->processEvents(); | 1406 | qApp->processEvents(); |
1398 | 1407 | ||
1399 | QDate birthday; | 1408 | QDate birthday; |
1400 | QDate anniversary; | 1409 | QDate anniversary; |
1401 | QString realName; | 1410 | QString realName; |
1402 | QString email; | 1411 | QString email; |
1403 | QString assembledName; | 1412 | QString assembledName; |
1404 | QString uid; | 1413 | QString uid; |
1405 | bool ok = true; | 1414 | bool ok = true; |
1406 | for ( int i = 0; i < count; i++) | 1415 | for ( int i = 0; i < count; i++) |
1407 | { | 1416 | { |
1408 | if ( ! bar.isVisible() ) | 1417 | if ( ! bar.isVisible() ) |
1409 | return; | 1418 | return; |
1410 | bar.setProgress( i ); | 1419 | bar.setProgress( i ); |
1411 | qApp->processEvents(); | 1420 | qApp->processEvents(); |
1412 | 1421 | ||
1413 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1422 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1414 | if (!ok) { | 1423 | if (!ok) { |
1415 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1424 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1416 | } | 1425 | } |
1417 | 1426 | ||
1418 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1427 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1419 | if (!ok) { | 1428 | if (!ok) { |
1420 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1429 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1421 | } | 1430 | } |
1422 | realName = realNameList[i]; | 1431 | realName = realNameList[i]; |
1423 | email = emailList[i]; | 1432 | email = emailList[i]; |
1424 | assembledName = assembledNameList[i]; | 1433 | assembledName = assembledNameList[i]; |
1425 | uid = uidList[i]; | 1434 | uid = uidList[i]; |
1426 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); | 1435 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); |
1427 | 1436 | ||
1428 | if ( birthday.isValid() ){ | 1437 | if ( birthday.isValid() ){ |
1429 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1438 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1430 | KCal::Attendee::ReqParticipant,uid) ; | 1439 | KCal::Attendee::ReqParticipant,uid) ; |
1431 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1440 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1432 | ++addCount; | 1441 | ++addCount; |
1433 | } | 1442 | } |
1434 | 1443 | ||
1435 | if ( anniversary.isValid() ){ | 1444 | if ( anniversary.isValid() ){ |
1436 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1445 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1437 | KCal::Attendee::ReqParticipant,uid) ; | 1446 | KCal::Attendee::ReqParticipant,uid) ; |
1438 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1447 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1439 | ++addCount; | 1448 | ++addCount; |
1440 | } | 1449 | } |
1441 | } | 1450 | } |
1442 | 1451 | ||
1443 | updateView(); | 1452 | updateView(); |
1444 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1453 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1445 | 1454 | ||
1446 | } | 1455 | } |
1447 | 1456 | ||
1448 | } | 1457 | } |
1449 | 1458 | ||
1450 | 1459 | ||
1451 | 1460 | ||
1452 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1461 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1453 | { | 1462 | { |
1454 | //qDebug("addAnni "); | 1463 | //qDebug("addAnni "); |
1455 | Event * ev = new Event(); | 1464 | Event * ev = new Event(); |
1456 | if ( a ) { | 1465 | if ( a ) { |
1457 | ev->addAttendee( a ); | 1466 | ev->addAttendee( a ); |
1458 | } | 1467 | } |
1459 | QString kind; | 1468 | QString kind; |
1460 | if ( birthday ) | 1469 | if ( birthday ) |
1461 | kind = i18n( "Birthday" ); | 1470 | kind = i18n( "Birthday" ); |
1462 | else | 1471 | else |
1463 | kind = i18n( "Anniversary" ); | 1472 | kind = i18n( "Anniversary" ); |
1464 | ev->setSummary( name + " - " + kind ); | 1473 | ev->setSummary( name + " - " + kind ); |
1465 | ev->setOrganizer(a->email()); | 1474 | ev->setOrganizer(a->email()); |
1466 | ev->setCategories( kind ); | 1475 | ev->setCategories( kind ); |
1467 | ev->setDtStart( QDateTime(date) ); | 1476 | ev->setDtStart( QDateTime(date) ); |
1468 | ev->setDtEnd( QDateTime(date) ); | 1477 | ev->setDtEnd( QDateTime(date) ); |
1469 | ev->setFloats( true ); | 1478 | ev->setFloats( true ); |
1470 | Recurrence * rec = ev->recurrence(); | 1479 | Recurrence * rec = ev->recurrence(); |
1471 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1480 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1472 | rec->addYearlyNum( date.month() ); | 1481 | rec->addYearlyNum( date.month() ); |
1473 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1482 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1474 | delete ev; | 1483 | delete ev; |
1475 | return false; | 1484 | return false; |
1476 | } | 1485 | } |
1477 | return true; | 1486 | return true; |
1478 | 1487 | ||
1479 | } | 1488 | } |
1480 | bool CalendarView::importQtopia( const QString &categories, | 1489 | bool CalendarView::importQtopia( const QString &categories, |
1481 | const QString &datebook, | 1490 | const QString &datebook, |
1482 | const QString &todolist ) | 1491 | const QString &todolist ) |
1483 | { | 1492 | { |
1484 | 1493 | ||
1485 | QtopiaFormat qtopiaFormat; | 1494 | QtopiaFormat qtopiaFormat; |
1486 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1495 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1487 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1496 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1488 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1497 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1489 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1498 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1490 | 1499 | ||
1491 | updateView(); | 1500 | updateView(); |
1492 | return true; | 1501 | return true; |
1493 | 1502 | ||
1494 | #if 0 | 1503 | #if 0 |
1495 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1504 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1496 | mCurrentSyncDevice = "qtopia-XML"; | 1505 | mCurrentSyncDevice = "qtopia-XML"; |
1497 | if ( mSyncManager->mAskForPreferences ) | 1506 | if ( mSyncManager->mAskForPreferences ) |
1498 | edit_sync_options(); | 1507 | edit_sync_options(); |
1499 | qApp->processEvents(); | 1508 | qApp->processEvents(); |
1500 | CalendarLocal* calendar = new CalendarLocal(); | 1509 | CalendarLocal* calendar = new CalendarLocal(); |
1501 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1510 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1502 | bool syncOK = false; | 1511 | bool syncOK = false; |
1503 | QtopiaFormat qtopiaFormat; | 1512 | QtopiaFormat qtopiaFormat; |
1504 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1513 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1505 | bool loadOk = true; | 1514 | bool loadOk = true; |
1506 | if ( !categories.isEmpty() ) | 1515 | if ( !categories.isEmpty() ) |
1507 | loadOk = qtopiaFormat.load( calendar, categories ); | 1516 | loadOk = qtopiaFormat.load( calendar, categories ); |
1508 | if ( loadOk && !datebook.isEmpty() ) | 1517 | if ( loadOk && !datebook.isEmpty() ) |
1509 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1518 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1510 | if ( loadOk && !todolist.isEmpty() ) | 1519 | if ( loadOk && !todolist.isEmpty() ) |
1511 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1520 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1512 | 1521 | ||
1513 | if ( loadOk ) { | 1522 | if ( loadOk ) { |
1514 | getEventViewerDialog()->setSyncMode( true ); | 1523 | getEventViewerDialog()->setSyncMode( true ); |
1515 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1524 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1516 | getEventViewerDialog()->setSyncMode( false ); | 1525 | getEventViewerDialog()->setSyncMode( false ); |
1517 | qApp->processEvents(); | 1526 | qApp->processEvents(); |
1518 | if ( syncOK ) { | 1527 | if ( syncOK ) { |
1519 | if ( mSyncManager->mWriteBackFile ) | 1528 | if ( mSyncManager->mWriteBackFile ) |
1520 | { | 1529 | { |
1521 | // write back XML file | 1530 | // write back XML file |
1522 | 1531 | ||
1523 | } | 1532 | } |
1524 | setModified( true ); | 1533 | setModified( true ); |
1525 | } | 1534 | } |
1526 | } else { | 1535 | } else { |
1527 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1536 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1528 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1537 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1529 | question, i18n("Ok")) ; | 1538 | question, i18n("Ok")) ; |
1530 | } | 1539 | } |
1531 | delete calendar; | 1540 | delete calendar; |
1532 | updateView(); | 1541 | updateView(); |
1533 | return syncOK; | 1542 | return syncOK; |
1534 | 1543 | ||
1535 | 1544 | ||
1536 | #endif | 1545 | #endif |
1537 | 1546 | ||
1538 | } | 1547 | } |
1539 | 1548 | ||
1540 | void CalendarView::setSyncEventsReadOnly() | 1549 | void CalendarView::setSyncEventsReadOnly() |
1541 | { | 1550 | { |
1542 | Event * ev; | 1551 | Event * ev; |
1543 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1552 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1544 | ev = eL.first(); | 1553 | ev = eL.first(); |
1545 | while ( ev ) { | 1554 | while ( ev ) { |
1546 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1555 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1547 | ev->setReadOnly( true ); | 1556 | ev->setReadOnly( true ); |
1548 | ev = eL.next(); | 1557 | ev = eL.next(); |
1549 | } | 1558 | } |
1550 | } | 1559 | } |
1551 | bool CalendarView::openCalendar(QString filename, bool merge) | 1560 | bool CalendarView::openCalendar(QString filename, bool merge) |
1552 | { | 1561 | { |
1553 | 1562 | ||
1554 | if (filename.isEmpty()) { | 1563 | if (filename.isEmpty()) { |
1555 | return false; | 1564 | return false; |
1556 | } | 1565 | } |
1557 | 1566 | ||
1558 | if (!QFile::exists(filename)) { | 1567 | if (!QFile::exists(filename)) { |
1559 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1568 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1560 | return false; | 1569 | return false; |
1561 | } | 1570 | } |
1562 | 1571 | ||
1563 | globalFlagBlockAgenda = 1; | 1572 | globalFlagBlockAgenda = 1; |
1564 | if (!merge) mCalendar->close(); | 1573 | if (!merge) mCalendar->close(); |
1565 | 1574 | ||
1566 | mStorage->setFileName( filename ); | 1575 | mStorage->setFileName( filename ); |
1567 | 1576 | ||
1568 | if ( mStorage->load() ) { | 1577 | if ( mStorage->load() ) { |
1569 | if ( merge ) ;//setModified( true ); | 1578 | if ( merge ) ;//setModified( true ); |
1570 | else { | 1579 | else { |
1571 | //setModified( true ); | 1580 | //setModified( true ); |
1572 | mViewManager->setDocumentId( filename ); | 1581 | mViewManager->setDocumentId( filename ); |
1573 | mDialogManager->setDocumentId( filename ); | 1582 | mDialogManager->setDocumentId( filename ); |
1574 | mTodoList->setDocumentId( filename ); | 1583 | mTodoList->setDocumentId( filename ); |
1575 | } | 1584 | } |
1576 | globalFlagBlockAgenda = 2; | 1585 | globalFlagBlockAgenda = 2; |
1577 | // if ( getLastSyncEvent() ) | 1586 | // if ( getLastSyncEvent() ) |
1578 | // getLastSyncEvent()->setReadOnly( true ); | 1587 | // getLastSyncEvent()->setReadOnly( true ); |
1579 | mCalendar->reInitAlarmSettings(); | 1588 | mCalendar->reInitAlarmSettings(); |
1580 | setSyncEventsReadOnly(); | 1589 | setSyncEventsReadOnly(); |
1581 | updateUnmanagedViews(); | 1590 | updateUnmanagedViews(); |
1582 | updateView(); | 1591 | updateView(); |
1583 | if ( filename != MainWindow::defaultFileName() ) { | 1592 | if ( filename != MainWindow::defaultFileName() ) { |
1584 | saveCalendar( MainWindow::defaultFileName() ); | 1593 | saveCalendar( MainWindow::defaultFileName() ); |
1585 | } else { | 1594 | } else { |
1586 | QFileInfo finf ( MainWindow::defaultFileName()); | 1595 | QFileInfo finf ( MainWindow::defaultFileName()); |
1587 | if ( finf.exists() ) { | 1596 | if ( finf.exists() ) { |
1588 | setLoadedFileVersion( finf.lastModified () ); | 1597 | setLoadedFileVersion( finf.lastModified () ); |
1589 | } | 1598 | } |
1590 | } | 1599 | } |
1591 | return true; | 1600 | return true; |
1592 | } else { | 1601 | } else { |
1593 | // while failing to load, the calendar object could | 1602 | // while failing to load, the calendar object could |
1594 | // have become partially populated. Clear it out. | 1603 | // have become partially populated. Clear it out. |
1595 | if ( !merge ) { | 1604 | if ( !merge ) { |
1596 | mCalendar->close(); | 1605 | mCalendar->close(); |
1597 | mViewManager->setDocumentId( filename ); | 1606 | mViewManager->setDocumentId( filename ); |
1598 | mDialogManager->setDocumentId( filename ); | 1607 | mDialogManager->setDocumentId( filename ); |
1599 | mTodoList->setDocumentId( filename ); | 1608 | mTodoList->setDocumentId( filename ); |
1600 | } | 1609 | } |
1601 | 1610 | ||
1602 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1611 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1603 | 1612 | ||
1604 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1613 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1605 | globalFlagBlockAgenda = 2; | 1614 | globalFlagBlockAgenda = 2; |
1606 | mCalendar->reInitAlarmSettings(); | 1615 | mCalendar->reInitAlarmSettings(); |
1607 | setSyncEventsReadOnly(); | 1616 | setSyncEventsReadOnly(); |
1608 | updateUnmanagedViews(); | 1617 | updateUnmanagedViews(); |
1609 | updateView(); | 1618 | updateView(); |
1610 | } | 1619 | } |
1611 | return false; | 1620 | return false; |
1612 | } | 1621 | } |
1613 | void CalendarView::showOpenError() | 1622 | void CalendarView::showOpenError() |
1614 | { | 1623 | { |
1615 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1624 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1616 | } | 1625 | } |
1617 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1626 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1618 | { | 1627 | { |
1619 | loadedFileVersion = dt; | 1628 | loadedFileVersion = dt; |
1620 | } | 1629 | } |
1621 | bool CalendarView::checkFileChanged(QString fn) | 1630 | bool CalendarView::checkFileChanged(QString fn) |
1622 | { | 1631 | { |
1623 | QFileInfo finf ( fn ); | 1632 | QFileInfo finf ( fn ); |
1624 | if ( !finf.exists() ) | 1633 | if ( !finf.exists() ) |
1625 | return true; | 1634 | return true; |
1626 | QDateTime dt = finf.lastModified (); | 1635 | QDateTime dt = finf.lastModified (); |
1627 | if ( dt <= loadedFileVersion ) | 1636 | if ( dt <= loadedFileVersion ) |
1628 | return false; | 1637 | return false; |
1629 | return true; | 1638 | return true; |
1630 | 1639 | ||
1631 | } | 1640 | } |
1632 | void CalendarView::watchSavedFile() | 1641 | void CalendarView::watchSavedFile() |
1633 | { | 1642 | { |
1634 | QFileInfo finf ( MainWindow::defaultFileName()); | 1643 | QFileInfo finf ( MainWindow::defaultFileName()); |
1635 | if ( !finf.exists() ) | 1644 | if ( !finf.exists() ) |
1636 | return; | 1645 | return; |
1637 | QDateTime dt = finf.lastModified (); | 1646 | QDateTime dt = finf.lastModified (); |
1638 | if ( dt < loadedFileVersion ) { | 1647 | if ( dt < loadedFileVersion ) { |
1639 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1648 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1640 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1649 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1641 | return; | 1650 | return; |
1642 | } | 1651 | } |
1643 | loadedFileVersion = dt; | 1652 | loadedFileVersion = dt; |
1644 | } | 1653 | } |
1645 | 1654 | ||
1646 | bool CalendarView::checkFileVersion(QString fn) | 1655 | bool CalendarView::checkFileVersion(QString fn) |
1647 | { | 1656 | { |
1648 | QFileInfo finf ( fn ); | 1657 | QFileInfo finf ( fn ); |
1649 | if ( !finf.exists() ) | 1658 | if ( !finf.exists() ) |
1650 | return true; | 1659 | return true; |
1651 | QDateTime dt = finf.lastModified (); | 1660 | QDateTime dt = finf.lastModified (); |
1652 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1661 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1653 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1662 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1654 | if ( dt <= loadedFileVersion ) | 1663 | if ( dt <= loadedFileVersion ) |
1655 | return true; | 1664 | return true; |
1656 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 1665 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
1657 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1666 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1658 | i18n("Sync+save")); | 1667 | i18n("Sync+save")); |
1659 | 1668 | ||
1660 | if ( km == KMessageBox::Cancel ) | 1669 | if ( km == KMessageBox::Cancel ) |
1661 | return false; | 1670 | return false; |
1662 | if ( km == KMessageBox::Yes ) | 1671 | if ( km == KMessageBox::Yes ) |
1663 | return true; | 1672 | return true; |
1664 | 1673 | ||
1665 | setSyncDevice("deleteaftersync" ); | 1674 | setSyncDevice("deleteaftersync" ); |
1666 | mSyncManager->mAskForPreferences = true; | 1675 | mSyncManager->mAskForPreferences = true; |
1667 | mSyncManager->mSyncAlgoPrefs = 3; | 1676 | mSyncManager->mSyncAlgoPrefs = 3; |
1668 | mSyncManager->mWriteBackFile = false; | 1677 | mSyncManager->mWriteBackFile = false; |
1669 | mSyncManager->mWriteBackExistingOnly = false; | 1678 | mSyncManager->mWriteBackExistingOnly = false; |
1670 | mSyncManager->mShowSyncSummary = false; | 1679 | mSyncManager->mShowSyncSummary = false; |
1671 | syncCalendar( fn, 3 ); | 1680 | syncCalendar( fn, 3 ); |
1672 | Event * e = getLastSyncEvent(); | 1681 | Event * e = getLastSyncEvent(); |
1673 | mCalendar->deleteEvent ( e ); | 1682 | mCalendar->deleteEvent ( e ); |
1674 | updateView(); | 1683 | updateView(); |
1675 | return true; | 1684 | return true; |
1676 | } | 1685 | } |
1677 | 1686 | ||
1678 | bool CalendarView::saveCalendar( QString filename ) | 1687 | bool CalendarView::saveCalendar( QString filename ) |
1679 | { | 1688 | { |
1680 | 1689 | ||
1681 | // Store back all unsaved data into calendar object | 1690 | // Store back all unsaved data into calendar object |
1682 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1691 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1683 | if ( mViewManager->currentView() ) | 1692 | if ( mViewManager->currentView() ) |
1684 | mViewManager->currentView()->flushView(); | 1693 | mViewManager->currentView()->flushView(); |
1685 | 1694 | ||
1686 | 1695 | ||
1687 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1696 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1688 | mStorage->setSaveFormat( new ICalFormat() ); | 1697 | mStorage->setSaveFormat( new ICalFormat() ); |
1689 | mStorage->setFileName( filename ); | 1698 | mStorage->setFileName( filename ); |
1690 | bool success; | 1699 | bool success; |
1691 | success = mStorage->save(); | 1700 | success = mStorage->save(); |
1692 | if ( !success ) { | 1701 | if ( !success ) { |
1693 | return false; | 1702 | return false; |
1694 | } | 1703 | } |
1695 | if ( filename == MainWindow::defaultFileName() ) { | 1704 | if ( filename == MainWindow::defaultFileName() ) { |
1696 | setLoadedFileVersion( lfv ); | 1705 | setLoadedFileVersion( lfv ); |
1697 | watchSavedFile(); | 1706 | watchSavedFile(); |
1698 | } | 1707 | } |
1699 | return true; | 1708 | return true; |
1700 | } | 1709 | } |
1701 | 1710 | ||
1702 | void CalendarView::closeCalendar() | 1711 | void CalendarView::closeCalendar() |
1703 | { | 1712 | { |
1704 | 1713 | ||
1705 | // child windows no longer valid | 1714 | // child windows no longer valid |
1706 | emit closingDown(); | 1715 | emit closingDown(); |
1707 | 1716 | ||
1708 | mCalendar->close(); | 1717 | mCalendar->close(); |
1709 | setModified(false); | 1718 | setModified(false); |
1710 | updateView(); | 1719 | updateView(); |
1711 | } | 1720 | } |
1712 | 1721 | ||
1713 | void CalendarView::archiveCalendar() | 1722 | void CalendarView::archiveCalendar() |
1714 | { | 1723 | { |
1715 | mDialogManager->showArchiveDialog(); | 1724 | mDialogManager->showArchiveDialog(); |
1716 | } | 1725 | } |
1717 | 1726 | ||
1718 | 1727 | ||
1719 | void CalendarView::readSettings() | 1728 | void CalendarView::readSettings() |
1720 | { | 1729 | { |
1721 | 1730 | ||
1722 | 1731 | ||
1723 | // mViewManager->showAgendaView(); | 1732 | // mViewManager->showAgendaView(); |
1724 | QString str; | 1733 | QString str; |
1725 | //qDebug("CalendarView::readSettings() "); | 1734 | //qDebug("CalendarView::readSettings() "); |
1726 | // read settings from the KConfig, supplying reasonable | 1735 | // read settings from the KConfig, supplying reasonable |
1727 | // defaults where none are to be found | 1736 | // defaults where none are to be found |
1728 | KConfig *config = KOGlobals::config(); | 1737 | KConfig *config = KOGlobals::config(); |
1729 | #ifndef KORG_NOSPLITTER | 1738 | #ifndef KORG_NOSPLITTER |
1730 | config->setGroup("KOrganizer Geometry"); | 1739 | config->setGroup("KOrganizer Geometry"); |
1731 | 1740 | ||
1732 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1741 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1733 | if (sizes.count() != 2) { | 1742 | if (sizes.count() != 2) { |
1734 | sizes << mDateNavigator->minimumSizeHint().width(); | 1743 | sizes << mDateNavigator->minimumSizeHint().width(); |
1735 | sizes << 300; | 1744 | sizes << 300; |
1736 | } | 1745 | } |
1737 | mPanner->setSizes(sizes); | 1746 | mPanner->setSizes(sizes); |
1738 | 1747 | ||
1739 | sizes = config->readIntListEntry("Separator2"); | 1748 | sizes = config->readIntListEntry("Separator2"); |
1740 | if ( ( mResourceView && sizes.count() == 4 ) || | 1749 | if ( ( mResourceView && sizes.count() == 4 ) || |
1741 | ( !mResourceView && sizes.count() == 3 ) ) { | 1750 | ( !mResourceView && sizes.count() == 3 ) ) { |
1742 | mLeftSplitter->setSizes(sizes); | 1751 | mLeftSplitter->setSizes(sizes); |
1743 | } | 1752 | } |
1744 | #endif | 1753 | #endif |
1745 | globalFlagBlockAgenda = 1; | 1754 | globalFlagBlockAgenda = 1; |
1746 | mViewManager->showAgendaView(); | 1755 | mViewManager->showAgendaView(); |
1747 | //mViewManager->readSettings( config ); | 1756 | //mViewManager->readSettings( config ); |
1748 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1757 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1749 | readFilterSettings(config); | 1758 | readFilterSettings(config); |
1750 | config->setGroup( "Views" ); | 1759 | config->setGroup( "Views" ); |
1751 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1760 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1752 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1761 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1753 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1762 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1754 | else mNavigator->selectDates( dateCount ); | 1763 | else mNavigator->selectDates( dateCount ); |
1755 | // mViewManager->readSettings( config ); | 1764 | // mViewManager->readSettings( config ); |
1756 | updateConfig(); | 1765 | updateConfig(); |
1757 | globalFlagBlockAgenda = 2; | 1766 | globalFlagBlockAgenda = 2; |
1758 | mViewManager->readSettings( config ); | 1767 | mViewManager->readSettings( config ); |
1759 | #ifdef DESKTOP_VERSION | 1768 | #ifdef DESKTOP_VERSION |
1760 | config->setGroup("WidgetLayout"); | 1769 | config->setGroup("WidgetLayout"); |
1761 | QStringList list; | 1770 | QStringList list; |
1762 | list = config->readListEntry("MainLayout"); | 1771 | list = config->readListEntry("MainLayout"); |
1763 | int x,y,w,h; | 1772 | int x,y,w,h; |
1764 | if ( ! list.isEmpty() ) { | 1773 | if ( ! list.isEmpty() ) { |
1765 | x = list[0].toInt(); | 1774 | x = list[0].toInt(); |
1766 | y = list[1].toInt(); | 1775 | y = list[1].toInt(); |
1767 | w = list[2].toInt(); | 1776 | w = list[2].toInt(); |
1768 | h = list[3].toInt(); | 1777 | h = list[3].toInt(); |
1769 | topLevelWidget()->setGeometry(x,y,w,h); | 1778 | topLevelWidget()->setGeometry(x,y,w,h); |
1770 | 1779 | ||
1771 | } else { | 1780 | } else { |
1772 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1781 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1773 | } | 1782 | } |
1774 | list = config->readListEntry("EditEventLayout"); | 1783 | list = config->readListEntry("EditEventLayout"); |
1775 | if ( ! list.isEmpty() ) { | 1784 | if ( ! list.isEmpty() ) { |
1776 | x = list[0].toInt(); | 1785 | x = list[0].toInt(); |
1777 | y = list[1].toInt(); | 1786 | y = list[1].toInt(); |
1778 | w = list[2].toInt(); | 1787 | w = list[2].toInt(); |
1779 | h = list[3].toInt(); | 1788 | h = list[3].toInt(); |
1780 | mEventEditor->setGeometry(x,y,w,h); | 1789 | mEventEditor->setGeometry(x,y,w,h); |
1781 | 1790 | ||
1782 | } | 1791 | } |
1783 | list = config->readListEntry("EditTodoLayout"); | 1792 | list = config->readListEntry("EditTodoLayout"); |
1784 | if ( ! list.isEmpty() ) { | 1793 | if ( ! list.isEmpty() ) { |
1785 | x = list[0].toInt(); | 1794 | x = list[0].toInt(); |
1786 | y = list[1].toInt(); | 1795 | y = list[1].toInt(); |
1787 | w = list[2].toInt(); | 1796 | w = list[2].toInt(); |
1788 | h = list[3].toInt(); | 1797 | h = list[3].toInt(); |
1789 | mTodoEditor->setGeometry(x,y,w,h); | 1798 | mTodoEditor->setGeometry(x,y,w,h); |
1790 | 1799 | ||
1791 | } | 1800 | } |
1792 | list = config->readListEntry("ViewerLayout"); | 1801 | list = config->readListEntry("ViewerLayout"); |
1793 | if ( ! list.isEmpty() ) { | 1802 | if ( ! list.isEmpty() ) { |
1794 | x = list[0].toInt(); | 1803 | x = list[0].toInt(); |
1795 | y = list[1].toInt(); | 1804 | y = list[1].toInt(); |
1796 | w = list[2].toInt(); | 1805 | w = list[2].toInt(); |
1797 | h = list[3].toInt(); | 1806 | h = list[3].toInt(); |
1798 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1807 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1799 | } | 1808 | } |
1800 | #endif | 1809 | #endif |
1801 | 1810 | ||
1802 | } | 1811 | } |
1803 | 1812 | ||
1804 | 1813 | ||
1805 | void CalendarView::writeSettings() | 1814 | void CalendarView::writeSettings() |
1806 | { | 1815 | { |
1807 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1816 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1808 | 1817 | ||
1809 | KConfig *config = KOGlobals::config(); | 1818 | KConfig *config = KOGlobals::config(); |
1810 | 1819 | ||
1811 | #ifndef KORG_NOSPLITTER | 1820 | #ifndef KORG_NOSPLITTER |
1812 | config->setGroup("KOrganizer Geometry"); | 1821 | config->setGroup("KOrganizer Geometry"); |
1813 | 1822 | ||
1814 | QValueList<int> list = mPanner->sizes(); | 1823 | QValueList<int> list = mPanner->sizes(); |
1815 | config->writeEntry("Separator1",list); | 1824 | config->writeEntry("Separator1",list); |
1816 | 1825 | ||
1817 | list = mLeftSplitter->sizes(); | 1826 | list = mLeftSplitter->sizes(); |
1818 | config->writeEntry("Separator2",list); | 1827 | config->writeEntry("Separator2",list); |
1819 | #endif | 1828 | #endif |
1820 | 1829 | ||
1821 | mViewManager->writeSettings( config ); | 1830 | mViewManager->writeSettings( config ); |
1822 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1831 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1823 | mDialogManager->writeSettings( config ); | 1832 | mDialogManager->writeSettings( config ); |
1824 | //KOPrefs::instance()->usrWriteConfig(); | 1833 | //KOPrefs::instance()->usrWriteConfig(); |
1825 | KOPrefs::instance()->writeConfig(); | 1834 | KOPrefs::instance()->writeConfig(); |
1826 | 1835 | ||
1827 | writeFilterSettings(config); | 1836 | writeFilterSettings(config); |
1828 | 1837 | ||
1829 | config->setGroup( "Views" ); | 1838 | config->setGroup( "Views" ); |
1830 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1839 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1831 | 1840 | ||
1832 | #ifdef DESKTOP_VERSION | 1841 | #ifdef DESKTOP_VERSION |
1833 | config->setGroup("WidgetLayout"); | 1842 | config->setGroup("WidgetLayout"); |
1834 | QStringList list ;//= config->readListEntry("MainLayout"); | 1843 | QStringList list ;//= config->readListEntry("MainLayout"); |
1835 | int x,y,w,h; | 1844 | int x,y,w,h; |
1836 | QWidget* wid; | 1845 | QWidget* wid; |
1837 | wid = topLevelWidget(); | 1846 | wid = topLevelWidget(); |
1838 | x = wid->geometry().x(); | 1847 | x = wid->geometry().x(); |
1839 | y = wid->geometry().y(); | 1848 | y = wid->geometry().y(); |
1840 | w = wid->width(); | 1849 | w = wid->width(); |
1841 | h = wid->height(); | 1850 | h = wid->height(); |
1842 | list.clear(); | 1851 | list.clear(); |
1843 | list << QString::number( x ); | 1852 | list << QString::number( x ); |
1844 | list << QString::number( y ); | 1853 | list << QString::number( y ); |
1845 | list << QString::number( w ); | 1854 | list << QString::number( w ); |
1846 | list << QString::number( h ); | 1855 | list << QString::number( h ); |
1847 | config->writeEntry("MainLayout",list ); | 1856 | config->writeEntry("MainLayout",list ); |
1848 | 1857 | ||
1849 | wid = mEventEditor; | 1858 | wid = mEventEditor; |
1850 | x = wid->geometry().x(); | 1859 | x = wid->geometry().x(); |
1851 | y = wid->geometry().y(); | 1860 | y = wid->geometry().y(); |
1852 | w = wid->width(); | 1861 | w = wid->width(); |
1853 | h = wid->height(); | 1862 | h = wid->height(); |
1854 | list.clear(); | 1863 | list.clear(); |
1855 | list << QString::number( x ); | 1864 | list << QString::number( x ); |
1856 | list << QString::number( y ); | 1865 | list << QString::number( y ); |
1857 | list << QString::number( w ); | 1866 | list << QString::number( w ); |
1858 | list << QString::number( h ); | 1867 | list << QString::number( h ); |
1859 | config->writeEntry("EditEventLayout",list ); | 1868 | config->writeEntry("EditEventLayout",list ); |
1860 | 1869 | ||
1861 | wid = mTodoEditor; | 1870 | wid = mTodoEditor; |
1862 | x = wid->geometry().x(); | 1871 | x = wid->geometry().x(); |
1863 | y = wid->geometry().y(); | 1872 | y = wid->geometry().y(); |
1864 | w = wid->width(); | 1873 | w = wid->width(); |
1865 | h = wid->height(); | 1874 | h = wid->height(); |
1866 | list.clear(); | 1875 | list.clear(); |
1867 | list << QString::number( x ); | 1876 | list << QString::number( x ); |
1868 | list << QString::number( y ); | 1877 | list << QString::number( y ); |
1869 | list << QString::number( w ); | 1878 | list << QString::number( w ); |
1870 | list << QString::number( h ); | 1879 | list << QString::number( h ); |
1871 | config->writeEntry("EditTodoLayout",list ); | 1880 | config->writeEntry("EditTodoLayout",list ); |
1872 | wid = getEventViewerDialog(); | 1881 | wid = getEventViewerDialog(); |
1873 | x = wid->geometry().x(); | 1882 | x = wid->geometry().x(); |
1874 | y = wid->geometry().y(); | 1883 | y = wid->geometry().y(); |
1875 | w = wid->width(); | 1884 | w = wid->width(); |
1876 | h = wid->height(); | 1885 | h = wid->height(); |
1877 | list.clear(); | 1886 | list.clear(); |
1878 | list << QString::number( x ); | 1887 | list << QString::number( x ); |
1879 | list << QString::number( y ); | 1888 | list << QString::number( y ); |
1880 | list << QString::number( w ); | 1889 | list << QString::number( w ); |
1881 | list << QString::number( h ); | 1890 | list << QString::number( h ); |
1882 | config->writeEntry("ViewerLayout",list ); | 1891 | config->writeEntry("ViewerLayout",list ); |
1883 | wid = mDialogManager->getSearchDialog(); | 1892 | wid = mDialogManager->getSearchDialog(); |
1884 | if ( wid ) { | 1893 | if ( wid ) { |
1885 | x = wid->geometry().x(); | 1894 | x = wid->geometry().x(); |
1886 | y = wid->geometry().y(); | 1895 | y = wid->geometry().y(); |
1887 | w = wid->width(); | 1896 | w = wid->width(); |
1888 | h = wid->height(); | 1897 | h = wid->height(); |
1889 | list.clear(); | 1898 | list.clear(); |
1890 | list << QString::number( x ); | 1899 | list << QString::number( x ); |
1891 | list << QString::number( y ); | 1900 | list << QString::number( y ); |
1892 | list << QString::number( w ); | 1901 | list << QString::number( w ); |
1893 | list << QString::number( h ); | 1902 | list << QString::number( h ); |
1894 | config->writeEntry("SearchLayout",list ); | 1903 | config->writeEntry("SearchLayout",list ); |
1895 | } | 1904 | } |
1896 | #endif | 1905 | #endif |
1897 | 1906 | ||
1898 | 1907 | ||
1899 | config->sync(); | 1908 | config->sync(); |
1900 | } | 1909 | } |
1901 | 1910 | ||
1902 | void CalendarView::readFilterSettings(KConfig *config) | 1911 | void CalendarView::readFilterSettings(KConfig *config) |
1903 | { | 1912 | { |
1904 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 1913 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
1905 | 1914 | ||
1906 | mFilters.clear(); | 1915 | mFilters.clear(); |
1907 | 1916 | ||
1908 | config->setGroup("General"); | 1917 | config->setGroup("General"); |
1909 | QStringList filterList = config->readListEntry("CalendarFilters"); | 1918 | QStringList filterList = config->readListEntry("CalendarFilters"); |
1910 | 1919 | ||
1911 | QStringList::ConstIterator it = filterList.begin(); | 1920 | QStringList::ConstIterator it = filterList.begin(); |
1912 | QStringList::ConstIterator end = filterList.end(); | 1921 | QStringList::ConstIterator end = filterList.end(); |
1913 | while(it != end) { | 1922 | while(it != end) { |
1914 | // kdDebug() << " filter: " << (*it) << endl; | 1923 | // kdDebug() << " filter: " << (*it) << endl; |
1915 | 1924 | ||
1916 | CalFilter *filter; | 1925 | CalFilter *filter; |
1917 | filter = new CalFilter(*it); | 1926 | filter = new CalFilter(*it); |
1918 | config->setGroup("Filter_" + (*it)); | 1927 | config->setGroup("Filter_" + (*it)); |
1919 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 1928 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
1920 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 1929 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
1921 | filter->setCategoryList(config->readListEntry("CategoryList")); | 1930 | filter->setCategoryList(config->readListEntry("CategoryList")); |
1922 | mFilters.append(filter); | 1931 | mFilters.append(filter); |
1923 | 1932 | ||
1924 | ++it; | 1933 | ++it; |
1925 | } | 1934 | } |
1926 | 1935 | ||
1927 | if (mFilters.count() == 0) { | 1936 | if (mFilters.count() == 0) { |
1928 | CalFilter *filter = new CalFilter(i18n("Default")); | 1937 | CalFilter *filter = new CalFilter(i18n("Default")); |
1929 | mFilters.append(filter); | 1938 | mFilters.append(filter); |
1930 | } | 1939 | } |
1931 | mFilterView->updateFilters(); | 1940 | mFilterView->updateFilters(); |
1932 | config->setGroup("FilterView"); | 1941 | config->setGroup("FilterView"); |
1933 | 1942 | ||
1934 | mFilterView->blockSignals(true); | 1943 | mFilterView->blockSignals(true); |
1935 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 1944 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
1936 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 1945 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
1937 | mFilterView->blockSignals(false); | 1946 | mFilterView->blockSignals(false); |
1938 | // We do it manually to avoid it being done twice by the above calls | 1947 | // We do it manually to avoid it being done twice by the above calls |
1939 | updateFilter(); | 1948 | updateFilter(); |
1940 | } | 1949 | } |
1941 | 1950 | ||
1942 | void CalendarView::writeFilterSettings(KConfig *config) | 1951 | void CalendarView::writeFilterSettings(KConfig *config) |
1943 | { | 1952 | { |
1944 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 1953 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
1945 | 1954 | ||
1946 | QStringList filterList; | 1955 | QStringList filterList; |
1947 | 1956 | ||
1948 | CalFilter *filter = mFilters.first(); | 1957 | CalFilter *filter = mFilters.first(); |
1949 | while(filter) { | 1958 | while(filter) { |
1950 | // kdDebug() << " fn: " << filter->name() << endl; | 1959 | // kdDebug() << " fn: " << filter->name() << endl; |
1951 | filterList << filter->name(); | 1960 | filterList << filter->name(); |
1952 | config->setGroup("Filter_" + filter->name()); | 1961 | config->setGroup("Filter_" + filter->name()); |
1953 | config->writeEntry("Criteria",filter->criteria()); | 1962 | config->writeEntry("Criteria",filter->criteria()); |
1954 | config->writeEntry("CategoryList",filter->categoryList()); | 1963 | config->writeEntry("CategoryList",filter->categoryList()); |
1955 | filter = mFilters.next(); | 1964 | filter = mFilters.next(); |
1956 | } | 1965 | } |
1957 | config->setGroup("General"); | 1966 | config->setGroup("General"); |
1958 | config->writeEntry("CalendarFilters",filterList); | 1967 | config->writeEntry("CalendarFilters",filterList); |
1959 | 1968 | ||
1960 | config->setGroup("FilterView"); | 1969 | config->setGroup("FilterView"); |
1961 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 1970 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
1962 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 1971 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
1963 | } | 1972 | } |
1964 | 1973 | ||
1965 | 1974 | ||
1966 | void CalendarView::goToday() | 1975 | void CalendarView::goToday() |
1967 | { | 1976 | { |
1968 | mNavigator->selectToday(); | 1977 | mNavigator->selectToday(); |
1969 | } | 1978 | } |
1970 | 1979 | ||
1971 | void CalendarView::goNext() | 1980 | void CalendarView::goNext() |
1972 | { | 1981 | { |
1973 | mNavigator->selectNext(); | 1982 | mNavigator->selectNext(); |
1974 | } | 1983 | } |
1975 | 1984 | ||
1976 | void CalendarView::goPrevious() | 1985 | void CalendarView::goPrevious() |
1977 | { | 1986 | { |
1978 | mNavigator->selectPrevious(); | 1987 | mNavigator->selectPrevious(); |
1979 | } | 1988 | } |
1980 | void CalendarView::goNextMonth() | 1989 | void CalendarView::goNextMonth() |
1981 | { | 1990 | { |
1982 | mNavigator->selectNextMonth(); | 1991 | mNavigator->selectNextMonth(); |
1983 | } | 1992 | } |
1984 | 1993 | ||
1985 | void CalendarView::goPreviousMonth() | 1994 | void CalendarView::goPreviousMonth() |
1986 | { | 1995 | { |
1987 | mNavigator->selectPreviousMonth(); | 1996 | mNavigator->selectPreviousMonth(); |
1988 | } | 1997 | } |
1989 | void CalendarView::writeLocale() | 1998 | void CalendarView::writeLocale() |
1990 | { | 1999 | { |
1991 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 2000 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
1992 | #if 0 | 2001 | #if 0 |
1993 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 2002 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
1994 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 2003 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
1995 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 2004 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
1996 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 2005 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
1997 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 2006 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
1998 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 2007 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
1999 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 2008 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
2000 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 2009 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
2001 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 2010 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
2002 | KOPrefs::instance()->mDaylightsavingStart, | 2011 | KOPrefs::instance()->mDaylightsavingStart, |
2003 | KOPrefs::instance()->mDaylightsavingEnd ); | 2012 | KOPrefs::instance()->mDaylightsavingEnd ); |
2004 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); | 2013 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); |
2005 | #endif | 2014 | #endif |
2006 | } | 2015 | } |
2007 | void CalendarView::updateConfig() | 2016 | void CalendarView::updateConfig() |
2008 | { | 2017 | { |
2009 | writeLocale(); | 2018 | writeLocale(); |
2010 | if ( KOPrefs::instance()->mUseAppColors ) | 2019 | if ( KOPrefs::instance()->mUseAppColors ) |
2011 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2020 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2012 | emit configChanged(); | 2021 | emit configChanged(); |
2013 | mTodoList->updateConfig(); | 2022 | mTodoList->updateConfig(); |
2014 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2023 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2015 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2024 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2016 | // To make the "fill window" configurations work | 2025 | // To make the "fill window" configurations work |
2017 | //mViewManager->raiseCurrentView(); | 2026 | //mViewManager->raiseCurrentView(); |
2018 | } | 2027 | } |
2019 | 2028 | ||
2020 | 2029 | ||
2021 | void CalendarView::eventChanged(Event *event) | 2030 | void CalendarView::eventChanged(Event *event) |
2022 | { | 2031 | { |
2023 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2032 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2024 | //updateUnmanagedViews(); | 2033 | //updateUnmanagedViews(); |
2025 | } | 2034 | } |
2026 | 2035 | ||
2027 | void CalendarView::eventAdded(Event *event) | 2036 | void CalendarView::eventAdded(Event *event) |
2028 | { | 2037 | { |
2029 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2038 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2030 | } | 2039 | } |
2031 | 2040 | ||
2032 | void CalendarView::eventToBeDeleted(Event *) | 2041 | void CalendarView::eventToBeDeleted(Event *) |
2033 | { | 2042 | { |
2034 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2043 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2035 | } | 2044 | } |
2036 | 2045 | ||
2037 | void CalendarView::eventDeleted() | 2046 | void CalendarView::eventDeleted() |
2038 | { | 2047 | { |
2039 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2048 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2040 | } | 2049 | } |
2041 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2050 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2042 | { | 2051 | { |
2043 | changeIncidenceDisplay((Incidence *)which, action); | 2052 | changeIncidenceDisplay((Incidence *)which, action); |
2044 | mDateNavigator->updateView(); //LR | 2053 | mDateNavigator->updateView(); //LR |
2045 | //mDialogManager->updateSearchDialog(); | 2054 | //mDialogManager->updateSearchDialog(); |
2046 | 2055 | ||
2047 | if (which) { | 2056 | if (which) { |
2048 | mViewManager->updateWNview(); | 2057 | mViewManager->updateWNview(); |
2049 | //mTodoList->updateView(); | 2058 | //mTodoList->updateView(); |
2050 | } | 2059 | } |
2051 | 2060 | ||
2052 | } | 2061 | } |
2053 | 2062 | ||
2054 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2063 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2055 | { | 2064 | { |
2056 | updateUnmanagedViews(); | 2065 | updateUnmanagedViews(); |
2057 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2066 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2058 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2067 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2059 | mCalendar->checkAlarmForIncidence( 0, true ); | 2068 | mCalendar->checkAlarmForIncidence( 0, true ); |
2060 | if ( mEventViewerDialog ) | 2069 | if ( mEventViewerDialog ) |
2061 | mEventViewerDialog->hide(); | 2070 | mEventViewerDialog->hide(); |
2062 | } | 2071 | } |
2063 | else | 2072 | else |
2064 | mCalendar->checkAlarmForIncidence( which , false ); | 2073 | mCalendar->checkAlarmForIncidence( which , false ); |
2065 | } | 2074 | } |
2066 | 2075 | ||
2067 | // most of the changeEventDisplays() right now just call the view's | 2076 | // most of the changeEventDisplays() right now just call the view's |
2068 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2077 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2069 | void CalendarView::changeEventDisplay(Event *which, int action) | 2078 | void CalendarView::changeEventDisplay(Event *which, int action) |
2070 | { | 2079 | { |
2071 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2080 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2072 | changeIncidenceDisplay((Incidence *)which, action); | 2081 | changeIncidenceDisplay((Incidence *)which, action); |
2073 | mDateNavigator->updateView(); | 2082 | mDateNavigator->updateView(); |
2074 | //mDialogManager->updateSearchDialog(); | 2083 | //mDialogManager->updateSearchDialog(); |
2075 | 2084 | ||
2076 | if (which) { | 2085 | if (which) { |
2077 | // If there is an event view visible update the display | 2086 | // If there is an event view visible update the display |
2078 | mViewManager->currentView()->changeEventDisplay(which,action); | 2087 | mViewManager->currentView()->changeEventDisplay(which,action); |
2079 | // TODO: check, if update needed | 2088 | // TODO: check, if update needed |
2080 | // if (which->getTodoStatus()) { | 2089 | // if (which->getTodoStatus()) { |
2081 | mTodoList->updateView(); | 2090 | mTodoList->updateView(); |
2082 | // } | 2091 | // } |
2083 | } else { | 2092 | } else { |
2084 | mViewManager->currentView()->updateView(); | 2093 | mViewManager->currentView()->updateView(); |
2085 | } | 2094 | } |
2086 | } | 2095 | } |
2087 | 2096 | ||
2088 | 2097 | ||
2089 | void CalendarView::updateTodoViews() | 2098 | void CalendarView::updateTodoViews() |
2090 | { | 2099 | { |
2091 | 2100 | ||
2092 | mTodoList->updateView(); | 2101 | mTodoList->updateView(); |
2093 | mViewManager->currentView()->updateView(); | 2102 | mViewManager->currentView()->updateView(); |
2094 | 2103 | ||
2095 | } | 2104 | } |
2096 | 2105 | ||
2097 | 2106 | ||
2098 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2107 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2099 | { | 2108 | { |
2100 | mTodoList->updateView(); | 2109 | mTodoList->updateView(); |
2101 | mViewManager->updateView(start, end); | 2110 | mViewManager->updateView(start, end); |
2102 | //mDateNavigator->updateView(); | 2111 | //mDateNavigator->updateView(); |
2103 | } | 2112 | } |
2104 | 2113 | ||
2105 | void CalendarView::updateView() | 2114 | void CalendarView::updateView() |
2106 | { | 2115 | { |
2107 | DateList tmpList = mNavigator->selectedDates(); | 2116 | DateList tmpList = mNavigator->selectedDates(); |
2108 | 2117 | ||
2109 | // We assume that the navigator only selects consecutive days. | 2118 | // We assume that the navigator only selects consecutive days. |
2110 | updateView( tmpList.first(), tmpList.last() ); | 2119 | updateView( tmpList.first(), tmpList.last() ); |
2111 | } | 2120 | } |
2112 | 2121 | ||
2113 | void CalendarView::updateUnmanagedViews() | 2122 | void CalendarView::updateUnmanagedViews() |
2114 | { | 2123 | { |
2115 | mDateNavigator->updateDayMatrix(); | 2124 | mDateNavigator->updateDayMatrix(); |
2116 | } | 2125 | } |
2117 | 2126 | ||
2118 | int CalendarView::msgItemDelete() | 2127 | int CalendarView::msgItemDelete() |
2119 | { | 2128 | { |
2120 | return KMessageBox::warningContinueCancel(this, | 2129 | return KMessageBox::warningContinueCancel(this, |
2121 | i18n("This item will be\npermanently deleted."), | 2130 | i18n("This item will be\npermanently deleted."), |
2122 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2131 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2123 | } | 2132 | } |
2124 | 2133 | ||
2125 | 2134 | ||
2126 | void CalendarView::edit_cut() | 2135 | void CalendarView::edit_cut() |
2127 | { | 2136 | { |
2128 | Event *anEvent=0; | 2137 | Event *anEvent=0; |
2129 | 2138 | ||
2130 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2139 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2131 | 2140 | ||
2132 | if (mViewManager->currentView()->isEventView()) { | 2141 | if (mViewManager->currentView()->isEventView()) { |
2133 | if ( incidence && incidence->type() == "Event" ) { | 2142 | if ( incidence && incidence->type() == "Event" ) { |
2134 | anEvent = static_cast<Event *>(incidence); | 2143 | anEvent = static_cast<Event *>(incidence); |
2135 | } | 2144 | } |
2136 | } | 2145 | } |
2137 | 2146 | ||
2138 | if (!anEvent) { | 2147 | if (!anEvent) { |
2139 | KNotifyClient::beep(); | 2148 | KNotifyClient::beep(); |
2140 | return; | 2149 | return; |
2141 | } | 2150 | } |
2142 | DndFactory factory( mCalendar ); | 2151 | DndFactory factory( mCalendar ); |
2143 | factory.cutEvent(anEvent); | 2152 | factory.cutEvent(anEvent); |
2144 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2153 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2145 | } | 2154 | } |
2146 | 2155 | ||
2147 | void CalendarView::edit_copy() | 2156 | void CalendarView::edit_copy() |
2148 | { | 2157 | { |
2149 | Event *anEvent=0; | 2158 | Event *anEvent=0; |
2150 | 2159 | ||
2151 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2160 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2152 | 2161 | ||
2153 | if (mViewManager->currentView()->isEventView()) { | 2162 | if (mViewManager->currentView()->isEventView()) { |
2154 | if ( incidence && incidence->type() == "Event" ) { | 2163 | if ( incidence && incidence->type() == "Event" ) { |
2155 | anEvent = static_cast<Event *>(incidence); | 2164 | anEvent = static_cast<Event *>(incidence); |
2156 | } | 2165 | } |
2157 | } | 2166 | } |
2158 | 2167 | ||
2159 | if (!anEvent) { | 2168 | if (!anEvent) { |
2160 | KNotifyClient::beep(); | 2169 | KNotifyClient::beep(); |
2161 | return; | 2170 | return; |
2162 | } | 2171 | } |
2163 | DndFactory factory( mCalendar ); | 2172 | DndFactory factory( mCalendar ); |
2164 | factory.copyEvent(anEvent); | 2173 | factory.copyEvent(anEvent); |
2165 | } | 2174 | } |
2166 | 2175 | ||
2167 | void CalendarView::edit_paste() | 2176 | void CalendarView::edit_paste() |
2168 | { | 2177 | { |
2169 | QDate date = mNavigator->selectedDates().first(); | 2178 | QDate date = mNavigator->selectedDates().first(); |
2170 | 2179 | ||
2171 | DndFactory factory( mCalendar ); | 2180 | DndFactory factory( mCalendar ); |
2172 | Event *pastedEvent = factory.pasteEvent( date ); | 2181 | Event *pastedEvent = factory.pasteEvent( date ); |
2173 | 2182 | ||
2174 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2183 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2175 | } | 2184 | } |
2176 | 2185 | ||
2177 | void CalendarView::edit_options() | 2186 | void CalendarView::edit_options() |
2178 | { | 2187 | { |
2179 | mDialogManager->showOptionsDialog(); | 2188 | mDialogManager->showOptionsDialog(); |
2180 | //writeSettings(); | 2189 | //writeSettings(); |
2181 | } | 2190 | } |
2182 | 2191 | ||
2183 | void CalendarView::slotSelectPickerDate( QDate d) | 2192 | void CalendarView::slotSelectPickerDate( QDate d) |
2184 | { | 2193 | { |
2185 | mDateFrame->hide(); | 2194 | mDateFrame->hide(); |
2186 | if ( mDatePickerMode == 1 ) { | 2195 | if ( mDatePickerMode == 1 ) { |
2187 | mNavigator->slotDaySelect( d ); | 2196 | mNavigator->slotDaySelect( d ); |
2188 | } else if ( mDatePickerMode == 2 ) { | 2197 | } else if ( mDatePickerMode == 2 ) { |
2189 | if ( mMoveIncidence->type() == "Todo" ) { | 2198 | if ( mMoveIncidence->type() == "Todo" ) { |
2190 | Todo * to = (Todo *) mMoveIncidence; | 2199 | Todo * to = (Todo *) mMoveIncidence; |
2191 | QTime tim; | 2200 | QTime tim; |
2192 | if ( to->hasDueDate() ) | 2201 | if ( to->hasDueDate() ) |
2193 | tim = to->dtDue().time(); | 2202 | tim = to->dtDue().time(); |
2194 | else { | 2203 | else { |
2195 | tim = QTime ( 0,0,0 ); | 2204 | tim = QTime ( 0,0,0 ); |
2196 | to->setFloats( true ); | 2205 | to->setFloats( true ); |
2197 | to->setHasDueDate( true ); | 2206 | to->setHasDueDate( true ); |
2198 | } | 2207 | } |
2199 | QDateTime dt ( d,tim ); | 2208 | QDateTime dt ( d,tim ); |
2200 | to->setDtDue( dt ); | 2209 | to->setDtDue( dt ); |
2201 | todoChanged( to ); | 2210 | todoChanged( to ); |
2202 | } else { | 2211 | } else { |
2203 | QTime tim = mMoveIncidence->dtStart().time(); | 2212 | QTime tim = mMoveIncidence->dtStart().time(); |
2204 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2213 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2205 | QDateTime dt ( d,tim ); | 2214 | QDateTime dt ( d,tim ); |
2206 | mMoveIncidence->setDtStart( dt ); | 2215 | mMoveIncidence->setDtStart( dt ); |
2207 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2216 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2208 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2217 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2209 | } | 2218 | } |
2210 | 2219 | ||
2211 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2220 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2212 | } | 2221 | } |
2213 | } | 2222 | } |
2214 | 2223 | ||
2215 | void CalendarView::removeCategories() | 2224 | void CalendarView::removeCategories() |
2216 | { | 2225 | { |
2217 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2226 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2218 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2227 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2219 | QStringList catIncList; | 2228 | QStringList catIncList; |
2220 | QStringList newCatList; | 2229 | QStringList newCatList; |
2221 | Incidence* inc = incList.first(); | 2230 | Incidence* inc = incList.first(); |
2222 | int i; | 2231 | int i; |
2223 | int count = 0; | 2232 | int count = 0; |
2224 | while ( inc ) { | 2233 | while ( inc ) { |
2225 | newCatList.clear(); | 2234 | newCatList.clear(); |
2226 | catIncList = inc->categories() ; | 2235 | catIncList = inc->categories() ; |
2227 | for( i = 0; i< catIncList.count(); ++i ) { | 2236 | for( i = 0; i< catIncList.count(); ++i ) { |
2228 | if ( catList.contains (catIncList[i])) | 2237 | if ( catList.contains (catIncList[i])) |
2229 | newCatList.append( catIncList[i] ); | 2238 | newCatList.append( catIncList[i] ); |
2230 | } | 2239 | } |
2231 | newCatList.sort(); | 2240 | newCatList.sort(); |
2232 | inc->setCategories( newCatList.join(",") ); | 2241 | inc->setCategories( newCatList.join(",") ); |
2233 | inc = incList.next(); | 2242 | inc = incList.next(); |
2234 | } | 2243 | } |
2235 | } | 2244 | } |
2236 | 2245 | ||
2237 | int CalendarView::addCategories() | 2246 | int CalendarView::addCategories() |
2238 | { | 2247 | { |
2239 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2248 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2240 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2249 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2241 | QStringList catIncList; | 2250 | QStringList catIncList; |
2242 | Incidence* inc = incList.first(); | 2251 | Incidence* inc = incList.first(); |
2243 | int i; | 2252 | int i; |
2244 | int count = 0; | 2253 | int count = 0; |
2245 | while ( inc ) { | 2254 | while ( inc ) { |
2246 | catIncList = inc->categories() ; | 2255 | catIncList = inc->categories() ; |
2247 | for( i = 0; i< catIncList.count(); ++i ) { | 2256 | for( i = 0; i< catIncList.count(); ++i ) { |
2248 | if ( !catList.contains (catIncList[i])) { | 2257 | if ( !catList.contains (catIncList[i])) { |
2249 | catList.append( catIncList[i] ); | 2258 | catList.append( catIncList[i] ); |
2250 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2259 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2251 | ++count; | 2260 | ++count; |
2252 | } | 2261 | } |
2253 | } | 2262 | } |
2254 | inc = incList.next(); | 2263 | inc = incList.next(); |
2255 | } | 2264 | } |
2256 | catList.sort(); | 2265 | catList.sort(); |
2257 | KOPrefs::instance()->mCustomCategories = catList; | 2266 | KOPrefs::instance()->mCustomCategories = catList; |
2258 | return count; | 2267 | return count; |
2259 | } | 2268 | } |
2260 | 2269 | ||
2261 | void CalendarView::manageCategories() | 2270 | void CalendarView::manageCategories() |
2262 | { | 2271 | { |
2263 | KOCatPrefs* cp = new KOCatPrefs(); | 2272 | KOCatPrefs* cp = new KOCatPrefs(); |
2264 | cp->show(); | 2273 | cp->show(); |
2265 | int w =cp->sizeHint().width() ; | 2274 | int w =cp->sizeHint().width() ; |
2266 | int h = cp->sizeHint().height() ; | 2275 | int h = cp->sizeHint().height() ; |
2267 | int dw = QApplication::desktop()->width(); | 2276 | int dw = QApplication::desktop()->width(); |
2268 | int dh = QApplication::desktop()->height(); | 2277 | int dh = QApplication::desktop()->height(); |
2269 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2278 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2270 | if ( !cp->exec() ) { | 2279 | if ( !cp->exec() ) { |
2271 | delete cp; | 2280 | delete cp; |
2272 | return; | 2281 | return; |
2273 | } | 2282 | } |
2274 | int count = 0; | 2283 | int count = 0; |
2275 | if ( cp->addCat() ) { | 2284 | if ( cp->addCat() ) { |
2276 | count = addCategories(); | 2285 | count = addCategories(); |
2277 | if ( count ) { | 2286 | if ( count ) { |
2278 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2287 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2279 | writeSettings(); | 2288 | writeSettings(); |
2280 | } | 2289 | } |
2281 | } else { | 2290 | } else { |
2282 | removeCategories(); | 2291 | removeCategories(); |
2283 | updateView(); | 2292 | updateView(); |
2284 | } | 2293 | } |
2285 | delete cp; | 2294 | delete cp; |
2286 | } | 2295 | } |
2287 | 2296 | ||
2288 | void CalendarView::beamIncidence(Incidence * Inc) | 2297 | void CalendarView::beamIncidence(Incidence * Inc) |
2289 | { | 2298 | { |
2290 | QPtrList<Incidence> delSel ; | 2299 | QPtrList<Incidence> delSel ; |
2291 | delSel.append(Inc); | 2300 | delSel.append(Inc); |
2292 | beamIncidenceList( delSel ); | 2301 | beamIncidenceList( delSel ); |
2293 | } | 2302 | } |
2294 | void CalendarView::beamCalendar() | 2303 | void CalendarView::beamCalendar() |
2295 | { | 2304 | { |
2296 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2305 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2297 | //qDebug("beamCalendar() "); | 2306 | //qDebug("beamCalendar() "); |
2298 | beamIncidenceList( delSel ); | 2307 | beamIncidenceList( delSel ); |
2299 | } | 2308 | } |
2300 | void CalendarView::beamFilteredCalendar() | 2309 | void CalendarView::beamFilteredCalendar() |
2301 | { | 2310 | { |
2302 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2311 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2303 | //qDebug("beamFilteredCalendar() "); | 2312 | //qDebug("beamFilteredCalendar() "); |
2304 | beamIncidenceList( delSel ); | 2313 | beamIncidenceList( delSel ); |
2305 | } | 2314 | } |
2306 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2315 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2307 | { | 2316 | { |
2308 | if ( beamDialog->exec () == QDialog::Rejected ) | 2317 | if ( beamDialog->exec () == QDialog::Rejected ) |
2309 | return; | 2318 | return; |
2310 | #ifdef DESKTOP_VERSION | 2319 | #ifdef DESKTOP_VERSION |
2311 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2320 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2312 | #else | 2321 | #else |
2313 | QString fn = "/tmp/kopibeamfile"; | 2322 | QString fn = "/tmp/kopibeamfile"; |
2314 | #endif | 2323 | #endif |
2315 | QString mes; | 2324 | QString mes; |
2316 | bool createbup = true; | 2325 | bool createbup = true; |
2317 | if ( createbup ) { | 2326 | if ( createbup ) { |
2318 | QString description = "\n"; | 2327 | QString description = "\n"; |
2319 | CalendarLocal* cal = new CalendarLocal(); | 2328 | CalendarLocal* cal = new CalendarLocal(); |
2320 | if ( beamDialog->beamLocal() ) | 2329 | if ( beamDialog->beamLocal() ) |
2321 | cal->setLocalTime(); | 2330 | cal->setLocalTime(); |
2322 | else | 2331 | else |
2323 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2332 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2324 | Incidence *incidence = delSel.first(); | 2333 | Incidence *incidence = delSel.first(); |
2325 | bool addText = false; | 2334 | bool addText = false; |
2326 | if ( delSel.count() < 10 ) | 2335 | if ( delSel.count() < 10 ) |
2327 | addText = true; | 2336 | addText = true; |
2328 | else { | 2337 | else { |
2329 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2338 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2330 | } | 2339 | } |
2331 | while ( incidence ) { | 2340 | while ( incidence ) { |
2332 | Incidence *in = incidence->clone(); | 2341 | Incidence *in = incidence->clone(); |
2333 | if ( ! in->summary().isEmpty() ) { | 2342 | if ( ! in->summary().isEmpty() ) { |
2334 | in->setDescription(""); | 2343 | in->setDescription(""); |
2335 | } else { | 2344 | } else { |
2336 | in->setSummary( in->description().left(20)); | 2345 | in->setSummary( in->description().left(20)); |
2337 | in->setDescription(""); | 2346 | in->setDescription(""); |
2338 | } | 2347 | } |
2339 | if ( addText ) | 2348 | if ( addText ) |
2340 | description += in->summary() + "\n"; | 2349 | description += in->summary() + "\n"; |
2341 | cal->addIncidence( in ); | 2350 | cal->addIncidence( in ); |
2342 | incidence = delSel.next(); | 2351 | incidence = delSel.next(); |
2343 | } | 2352 | } |
2344 | if ( beamDialog->beamVcal() ) { | 2353 | if ( beamDialog->beamVcal() ) { |
2345 | fn += ".vcs"; | 2354 | fn += ".vcs"; |
2346 | FileStorage storage( cal, fn, new VCalFormat ); | 2355 | FileStorage storage( cal, fn, new VCalFormat ); |
2347 | storage.save(); | 2356 | storage.save(); |
2348 | } else { | 2357 | } else { |
2349 | fn += ".ics"; | 2358 | fn += ".ics"; |
2350 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2359 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2351 | storage.save(); | 2360 | storage.save(); |
2352 | } | 2361 | } |
2353 | delete cal; | 2362 | delete cal; |
2354 | mes = i18n("KO/Pi: Ready for beaming"); | 2363 | mes = i18n("KO/Pi: Ready for beaming"); |
2355 | topLevelWidget()->setCaption(mes); | 2364 | topLevelWidget()->setCaption(mes); |
2356 | KApplication::convert2latin1( fn ); | 2365 | KApplication::convert2latin1( fn ); |
2357 | #ifndef DESKTOP_VERSION | 2366 | #ifndef DESKTOP_VERSION |
2358 | Ir *ir = new Ir( this ); | 2367 | Ir *ir = new Ir( this ); |
2359 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2368 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2360 | ir->send( fn, description, "text/x-vCalendar" ); | 2369 | ir->send( fn, description, "text/x-vCalendar" ); |
2361 | #endif | 2370 | #endif |
2362 | } | 2371 | } |
2363 | } | 2372 | } |
2364 | void CalendarView::beamDone( Ir *ir ) | 2373 | void CalendarView::beamDone( Ir *ir ) |
2365 | { | 2374 | { |
2366 | #ifndef DESKTOP_VERSION | 2375 | #ifndef DESKTOP_VERSION |
2367 | delete ir; | 2376 | delete ir; |
2368 | #endif | 2377 | #endif |
2369 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2378 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2370 | topLevelWidget()->raise(); | 2379 | topLevelWidget()->raise(); |
2371 | } | 2380 | } |
2372 | 2381 | ||
2373 | void CalendarView::moveIncidence(Incidence * inc ) | 2382 | void CalendarView::moveIncidence(Incidence * inc ) |
2374 | { | 2383 | { |
2375 | if ( !inc ) return; | 2384 | if ( !inc ) return; |
2376 | // qDebug("showDatePickerForIncidence( ) "); | 2385 | // qDebug("showDatePickerForIncidence( ) "); |
2377 | if ( mDateFrame->isVisible() ) | 2386 | if ( mDateFrame->isVisible() ) |
2378 | mDateFrame->hide(); | 2387 | mDateFrame->hide(); |
2379 | else { | 2388 | else { |
2380 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; | 2389 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; |
2381 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; | 2390 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; |
2382 | int dw = QApplication::desktop()->width(); | 2391 | int dw = QApplication::desktop()->width(); |
2383 | int dh = QApplication::desktop()->height(); | 2392 | int dh = QApplication::desktop()->height(); |
2384 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2393 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2385 | mDateFrame->show(); | 2394 | mDateFrame->show(); |
2386 | } | 2395 | } |
2387 | mDatePickerMode = 2; | 2396 | mDatePickerMode = 2; |
2388 | mMoveIncidence = inc ; | 2397 | mMoveIncidence = inc ; |
2389 | QDate da; | 2398 | QDate da; |
2390 | if ( mMoveIncidence->type() == "Todo" ) { | 2399 | if ( mMoveIncidence->type() == "Todo" ) { |
2391 | Todo * to = (Todo *) mMoveIncidence; | 2400 | Todo * to = (Todo *) mMoveIncidence; |
2392 | if ( to->hasDueDate() ) | 2401 | if ( to->hasDueDate() ) |
2393 | da = to->dtDue().date(); | 2402 | da = to->dtDue().date(); |
2394 | else | 2403 | else |
2395 | da = QDate::currentDate(); | 2404 | da = QDate::currentDate(); |
2396 | } else { | 2405 | } else { |
2397 | da = mMoveIncidence->dtStart().date(); | 2406 | da = mMoveIncidence->dtStart().date(); |
2398 | } | 2407 | } |
2399 | mDatePicker->setDate( da ); | 2408 | mDatePicker->setDate( da ); |
2400 | } | 2409 | } |
2401 | void CalendarView::showDatePicker( ) | 2410 | void CalendarView::showDatePicker( ) |
2402 | { | 2411 | { |
2403 | //qDebug("CalendarView::showDatePicker( ) "); | 2412 | //qDebug("CalendarView::showDatePicker( ) "); |
2404 | if ( mDateFrame->isVisible() ) | 2413 | if ( mDateFrame->isVisible() ) |
2405 | mDateFrame->hide(); | 2414 | mDateFrame->hide(); |
2406 | else { | 2415 | else { |
2407 | int w =mDatePicker->sizeHint().width() ; | 2416 | int w =mDatePicker->sizeHint().width() ; |
2408 | int h = mDatePicker->sizeHint().height() ; | 2417 | int h = mDatePicker->sizeHint().height() ; |
2409 | int dw = QApplication::desktop()->width(); | 2418 | int dw = QApplication::desktop()->width(); |
2410 | int dh = QApplication::desktop()->height(); | 2419 | int dh = QApplication::desktop()->height(); |
2411 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2420 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2412 | mDateFrame->show(); | 2421 | mDateFrame->show(); |
2413 | } | 2422 | } |
2414 | mDatePickerMode = 1; | 2423 | mDatePickerMode = 1; |
2415 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2424 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2416 | } | 2425 | } |
2417 | 2426 | ||
2418 | void CalendarView::showEventEditor() | 2427 | void CalendarView::showEventEditor() |
2419 | { | 2428 | { |
2420 | #ifdef DESKTOP_VERSION | 2429 | #ifdef DESKTOP_VERSION |
2421 | mEventEditor->show(); | 2430 | mEventEditor->show(); |
2422 | #else | 2431 | #else |
2423 | mEventEditor->showMaximized(); | 2432 | mEventEditor->showMaximized(); |
2424 | #endif | 2433 | #endif |
2425 | } | 2434 | } |
2426 | void CalendarView::showTodoEditor() | 2435 | void CalendarView::showTodoEditor() |
2427 | { | 2436 | { |
2428 | #ifdef DESKTOP_VERSION | 2437 | #ifdef DESKTOP_VERSION |
2429 | mTodoEditor->show(); | 2438 | mTodoEditor->show(); |
2430 | #else | 2439 | #else |
2431 | mTodoEditor->showMaximized(); | 2440 | mTodoEditor->showMaximized(); |
2432 | #endif | 2441 | #endif |
2433 | } | 2442 | } |
2434 | 2443 | ||
2435 | void CalendarView::cloneIncidence() | 2444 | void CalendarView::cloneIncidence() |
2436 | { | 2445 | { |
2437 | Incidence *incidence = currentSelection(); | 2446 | Incidence *incidence = currentSelection(); |
2438 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2447 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2439 | if ( incidence ) { | 2448 | if ( incidence ) { |
2440 | cloneIncidence(incidence); | 2449 | cloneIncidence(incidence); |
2441 | } | 2450 | } |
2442 | } | 2451 | } |
2443 | void CalendarView::moveIncidence() | 2452 | void CalendarView::moveIncidence() |
2444 | { | 2453 | { |
2445 | Incidence *incidence = currentSelection(); | 2454 | Incidence *incidence = currentSelection(); |
2446 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2455 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2447 | if ( incidence ) { | 2456 | if ( incidence ) { |
2448 | moveIncidence(incidence); | 2457 | moveIncidence(incidence); |
2449 | } | 2458 | } |
2450 | } | 2459 | } |
2451 | void CalendarView::beamIncidence() | 2460 | void CalendarView::beamIncidence() |
2452 | { | 2461 | { |
2453 | Incidence *incidence = currentSelection(); | 2462 | Incidence *incidence = currentSelection(); |
2454 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2463 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2455 | if ( incidence ) { | 2464 | if ( incidence ) { |
2456 | beamIncidence(incidence); | 2465 | beamIncidence(incidence); |
2457 | } | 2466 | } |
2458 | } | 2467 | } |
2459 | void CalendarView::toggleCancelIncidence() | 2468 | void CalendarView::toggleCancelIncidence() |
2460 | { | 2469 | { |
2461 | Incidence *incidence = currentSelection(); | 2470 | Incidence *incidence = currentSelection(); |
2462 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2471 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2463 | if ( incidence ) { | 2472 | if ( incidence ) { |
2464 | cancelIncidence(incidence); | 2473 | cancelIncidence(incidence); |
2465 | } | 2474 | } |
2466 | } | 2475 | } |
2467 | 2476 | ||
2468 | 2477 | ||
2469 | void CalendarView::cancelIncidence(Incidence * inc ) | 2478 | void CalendarView::cancelIncidence(Incidence * inc ) |
2470 | { | 2479 | { |
2471 | inc->setCancelled( ! inc->cancelled() ); | 2480 | inc->setCancelled( ! inc->cancelled() ); |
2472 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2481 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2473 | updateView(); | 2482 | updateView(); |
2474 | } | 2483 | } |
2475 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2484 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2476 | { | 2485 | { |
2477 | Incidence * newInc = orgInc->clone(); | 2486 | Incidence * newInc = orgInc->clone(); |
2478 | newInc->recreate(); | 2487 | newInc->recreate(); |
2479 | 2488 | ||
2480 | if ( newInc->type() == "Todo" ) { | 2489 | if ( newInc->type() == "Todo" ) { |
2481 | Todo* t = (Todo*) newInc; | 2490 | Todo* t = (Todo*) newInc; |
2482 | mTodoEditor->editTodo( t ); | 2491 | mTodoEditor->editTodo( t ); |
2483 | showTodoEditor(); | 2492 | showTodoEditor(); |
2484 | if ( mTodoEditor->exec() ) { | 2493 | if ( mTodoEditor->exec() ) { |
2485 | mCalendar->addTodo( t ); | 2494 | mCalendar->addTodo( t ); |
2486 | updateView(); | 2495 | updateView(); |
2487 | } else { | 2496 | } else { |
2488 | delete t; | 2497 | delete t; |
2489 | } | 2498 | } |
2490 | } | 2499 | } |
2491 | else { | 2500 | else { |
2492 | Event* e = (Event*) newInc; | 2501 | Event* e = (Event*) newInc; |
2493 | mEventEditor->editEvent( e ); | 2502 | mEventEditor->editEvent( e ); |
2494 | showEventEditor(); | 2503 | showEventEditor(); |
2495 | if ( mEventEditor->exec() ) { | 2504 | if ( mEventEditor->exec() ) { |
2496 | mCalendar->addEvent( e ); | 2505 | mCalendar->addEvent( e ); |
2497 | updateView(); | 2506 | updateView(); |
2498 | } else { | 2507 | } else { |
2499 | delete e; | 2508 | delete e; |
2500 | } | 2509 | } |
2501 | } | 2510 | } |
2502 | } | 2511 | } |
2503 | 2512 | ||
2504 | void CalendarView::newEvent() | 2513 | void CalendarView::newEvent() |
2505 | { | 2514 | { |
2506 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2515 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2507 | KOAgendaView *aView = mViewManager->agendaView(); | 2516 | KOAgendaView *aView = mViewManager->agendaView(); |
2508 | if (aView) { | 2517 | if (aView) { |
2509 | if (aView->selectionStart().isValid()) { | 2518 | if (aView->selectionStart().isValid()) { |
2510 | if (aView->selectedIsAllDay()) { | 2519 | if (aView->selectedIsAllDay()) { |
2511 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2520 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2512 | } else { | 2521 | } else { |
2513 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2522 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2514 | } | 2523 | } |
2515 | return; | 2524 | return; |
2516 | } | 2525 | } |
2517 | } | 2526 | } |
2518 | 2527 | ||
2519 | QDate date = mNavigator->selectedDates().first(); | 2528 | QDate date = mNavigator->selectedDates().first(); |
2520 | QDateTime current = QDateTime::currentDateTime(); | 2529 | QDateTime current = QDateTime::currentDateTime(); |
2521 | if ( date <= current.date() ) { | 2530 | if ( date <= current.date() ) { |
2522 | int hour = current.time().hour() +1; | 2531 | int hour = current.time().hour() +1; |
2523 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2532 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2524 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2533 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2525 | } else | 2534 | } else |
2526 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2535 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2527 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2536 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2528 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2537 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2529 | } | 2538 | } |
2530 | 2539 | ||
2531 | void CalendarView::newEvent(QDateTime fh) | 2540 | void CalendarView::newEvent(QDateTime fh) |
2532 | { | 2541 | { |
2533 | newEvent(fh, | 2542 | newEvent(fh, |
2534 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2543 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2535 | } | 2544 | } |
2536 | 2545 | ||
2537 | void CalendarView::newEvent(QDate dt) | 2546 | void CalendarView::newEvent(QDate dt) |
2538 | { | 2547 | { |
2539 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2548 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2540 | QDateTime(dt, QTime(0,0,0)), true); | 2549 | QDateTime(dt, QTime(0,0,0)), true); |
2541 | } | 2550 | } |
2542 | 2551 | ||
2543 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2552 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2544 | { | 2553 | { |
2545 | 2554 | ||
2546 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2555 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2547 | if ( mFilterView->filtersEnabled() ) { | 2556 | if ( mFilterView->filtersEnabled() ) { |
2548 | CalFilter *filter = mFilterView->selectedFilter(); | 2557 | CalFilter *filter = mFilterView->selectedFilter(); |
2549 | if (filter && filter->showCategories()) { | 2558 | if (filter && filter->showCategories()) { |
2550 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2559 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2551 | } | 2560 | } |
2552 | if ( filter ) | 2561 | if ( filter ) |
2553 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2562 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2554 | } | 2563 | } |
2555 | showEventEditor(); | 2564 | showEventEditor(); |
2556 | } | 2565 | } |
2557 | void CalendarView::todoAdded(Todo * t) | 2566 | void CalendarView::todoAdded(Todo * t) |
2558 | { | 2567 | { |
2559 | 2568 | ||
2560 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2569 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2561 | updateTodoViews(); | 2570 | updateTodoViews(); |
2562 | } | 2571 | } |
2563 | void CalendarView::todoChanged(Todo * t) | 2572 | void CalendarView::todoChanged(Todo * t) |
2564 | { | 2573 | { |
2565 | emit todoModified( t, 4 ); | 2574 | emit todoModified( t, 4 ); |
2566 | // updateTodoViews(); | 2575 | // updateTodoViews(); |
2567 | } | 2576 | } |
2568 | void CalendarView::todoToBeDeleted(Todo *) | 2577 | void CalendarView::todoToBeDeleted(Todo *) |
2569 | { | 2578 | { |
2570 | //qDebug("todoToBeDeleted(Todo *) "); | 2579 | //qDebug("todoToBeDeleted(Todo *) "); |
2571 | updateTodoViews(); | 2580 | updateTodoViews(); |
2572 | } | 2581 | } |
2573 | void CalendarView::todoDeleted() | 2582 | void CalendarView::todoDeleted() |
2574 | { | 2583 | { |
2575 | //qDebug(" todoDeleted()"); | 2584 | //qDebug(" todoDeleted()"); |
2576 | updateTodoViews(); | 2585 | updateTodoViews(); |
2577 | } | 2586 | } |
2578 | 2587 | ||
2579 | 2588 | ||
2580 | 2589 | ||
2581 | void CalendarView::newTodo() | 2590 | void CalendarView::newTodo() |
2582 | { | 2591 | { |
2583 | 2592 | ||
2584 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); | 2593 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); |
2585 | if ( mFilterView->filtersEnabled() ) { | 2594 | if ( mFilterView->filtersEnabled() ) { |
2586 | CalFilter *filter = mFilterView->selectedFilter(); | 2595 | CalFilter *filter = mFilterView->selectedFilter(); |
2587 | if (filter && filter->showCategories()) { | 2596 | if (filter && filter->showCategories()) { |
2588 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 2597 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
2589 | } | 2598 | } |
2590 | if ( filter ) | 2599 | if ( filter ) |
2591 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 2600 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
2592 | } | 2601 | } |
2593 | showTodoEditor(); | 2602 | showTodoEditor(); |
2594 | } | 2603 | } |
2595 | 2604 | ||
2596 | void CalendarView::newSubTodo() | 2605 | void CalendarView::newSubTodo() |
2597 | { | 2606 | { |
2598 | Todo *todo = selectedTodo(); | 2607 | Todo *todo = selectedTodo(); |
2599 | if ( todo ) newSubTodo( todo ); | 2608 | if ( todo ) newSubTodo( todo ); |
2600 | } | 2609 | } |
2601 | 2610 | ||
2602 | void CalendarView::newSubTodo(Todo *parentEvent) | 2611 | void CalendarView::newSubTodo(Todo *parentEvent) |
2603 | { | 2612 | { |
2604 | 2613 | ||
2605 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); | 2614 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); |
2606 | showTodoEditor(); | 2615 | showTodoEditor(); |
2607 | } | 2616 | } |
2608 | 2617 | ||
2609 | void CalendarView::newFloatingEvent() | 2618 | void CalendarView::newFloatingEvent() |
2610 | { | 2619 | { |
2611 | DateList tmpList = mNavigator->selectedDates(); | 2620 | DateList tmpList = mNavigator->selectedDates(); |
2612 | QDate date = tmpList.first(); | 2621 | QDate date = tmpList.first(); |
2613 | 2622 | ||
2614 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 2623 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
2615 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 2624 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
2616 | } | 2625 | } |
2617 | 2626 | ||
2618 | 2627 | ||
2619 | void CalendarView::editEvent( Event *event ) | 2628 | void CalendarView::editEvent( Event *event ) |
2620 | { | 2629 | { |
2621 | 2630 | ||
2622 | if ( !event ) return; | 2631 | if ( !event ) return; |
2623 | if ( event->isReadOnly() ) { | 2632 | if ( event->isReadOnly() ) { |
2624 | showEvent( event ); | 2633 | showEvent( event ); |
2625 | return; | 2634 | return; |
2626 | } | 2635 | } |
2627 | mEventEditor->editEvent( event , mFlagEditDescription); | 2636 | mEventEditor->editEvent( event , mFlagEditDescription); |
2628 | showEventEditor(); | 2637 | showEventEditor(); |
2629 | } | 2638 | } |
2630 | void CalendarView::editJournal( Journal *jour ) | 2639 | void CalendarView::editJournal( Journal *jour ) |
2631 | { | 2640 | { |
2632 | if ( !jour ) return; | 2641 | if ( !jour ) return; |
2633 | mDialogManager->hideSearchDialog(); | 2642 | mDialogManager->hideSearchDialog(); |
2634 | mViewManager->showJournalView(); | 2643 | mViewManager->showJournalView(); |
2635 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 2644 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
2636 | } | 2645 | } |
2637 | void CalendarView::editTodo( Todo *todo ) | 2646 | void CalendarView::editTodo( Todo *todo ) |
2638 | { | 2647 | { |
2639 | if ( !todo ) return; | 2648 | if ( !todo ) return; |
2640 | 2649 | ||
2641 | if ( todo->isReadOnly() ) { | 2650 | if ( todo->isReadOnly() ) { |
2642 | showTodo( todo ); | 2651 | showTodo( todo ); |
2643 | return; | 2652 | return; |
2644 | } | 2653 | } |
2645 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 2654 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
2646 | showTodoEditor(); | 2655 | showTodoEditor(); |
2647 | 2656 | ||
2648 | } | 2657 | } |
2649 | 2658 | ||
2650 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 2659 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
2651 | { | 2660 | { |
2652 | if ( !mEventViewerDialog ) { | 2661 | if ( !mEventViewerDialog ) { |
2653 | mEventViewerDialog = new KOEventViewerDialog(this); | 2662 | mEventViewerDialog = new KOEventViewerDialog(this); |
2654 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 2663 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
2655 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 2664 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
2656 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 2665 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
2657 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 2666 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
2658 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 2667 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
2659 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 2668 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
2660 | mEventViewerDialog->resize( 640, 480 ); | 2669 | mEventViewerDialog->resize( 640, 480 ); |
2661 | 2670 | ||
2662 | } | 2671 | } |
2663 | return mEventViewerDialog; | 2672 | return mEventViewerDialog; |
2664 | } | 2673 | } |
2665 | void CalendarView::showEvent(Event *event) | 2674 | void CalendarView::showEvent(Event *event) |
2666 | { | 2675 | { |
2667 | getEventViewerDialog()->setEvent(event); | 2676 | getEventViewerDialog()->setEvent(event); |
2668 | getEventViewerDialog()->showMe(); | 2677 | getEventViewerDialog()->showMe(); |
2669 | } | 2678 | } |
2670 | 2679 | ||
2671 | void CalendarView::showTodo(Todo *event) | 2680 | void CalendarView::showTodo(Todo *event) |
2672 | { | 2681 | { |
2673 | getEventViewerDialog()->setTodo(event); | 2682 | getEventViewerDialog()->setTodo(event); |
2674 | getEventViewerDialog()->showMe(); | 2683 | getEventViewerDialog()->showMe(); |
2675 | } | 2684 | } |
2676 | void CalendarView::showJournal( Journal *jour ) | 2685 | void CalendarView::showJournal( Journal *jour ) |
2677 | { | 2686 | { |
2678 | getEventViewerDialog()->setJournal(jour); | 2687 | getEventViewerDialog()->setJournal(jour); |
2679 | getEventViewerDialog()->showMe(); | 2688 | getEventViewerDialog()->showMe(); |
2680 | 2689 | ||
2681 | } | 2690 | } |
2682 | // void CalendarView::todoModified (Todo *event, int changed) | 2691 | // void CalendarView::todoModified (Todo *event, int changed) |
2683 | // { | 2692 | // { |
2684 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 2693 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
2685 | // // kdDebug() << "Todo modified and open" << endl; | 2694 | // // kdDebug() << "Todo modified and open" << endl; |
2686 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 2695 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
2687 | // // temp->modified (changed); | 2696 | // // temp->modified (changed); |
2688 | 2697 | ||
2689 | // // } | 2698 | // // } |
2690 | 2699 | ||
2691 | // mViewManager->updateView(); | 2700 | // mViewManager->updateView(); |
2692 | // } | 2701 | // } |
2693 | 2702 | ||
2694 | void CalendarView::appointment_show() | 2703 | void CalendarView::appointment_show() |
2695 | { | 2704 | { |
2696 | Event *anEvent = 0; | 2705 | Event *anEvent = 0; |
2697 | 2706 | ||
2698 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2707 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2699 | 2708 | ||
2700 | if (mViewManager->currentView()->isEventView()) { | 2709 | if (mViewManager->currentView()->isEventView()) { |
2701 | if ( incidence && incidence->type() == "Event" ) { | 2710 | if ( incidence && incidence->type() == "Event" ) { |
2702 | anEvent = static_cast<Event *>(incidence); | 2711 | anEvent = static_cast<Event *>(incidence); |
2703 | } | 2712 | } |
2704 | } | 2713 | } |
2705 | 2714 | ||
2706 | if (!anEvent) { | 2715 | if (!anEvent) { |
2707 | KNotifyClient::beep(); | 2716 | KNotifyClient::beep(); |
2708 | return; | 2717 | return; |
2709 | } | 2718 | } |
2710 | 2719 | ||
2711 | showEvent(anEvent); | 2720 | showEvent(anEvent); |
2712 | } | 2721 | } |
2713 | 2722 | ||
2714 | void CalendarView::appointment_edit() | 2723 | void CalendarView::appointment_edit() |
2715 | { | 2724 | { |
2716 | Event *anEvent = 0; | 2725 | Event *anEvent = 0; |
2717 | 2726 | ||
2718 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2727 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2719 | 2728 | ||
2720 | if (mViewManager->currentView()->isEventView()) { | 2729 | if (mViewManager->currentView()->isEventView()) { |
2721 | if ( incidence && incidence->type() == "Event" ) { | 2730 | if ( incidence && incidence->type() == "Event" ) { |
2722 | anEvent = static_cast<Event *>(incidence); | 2731 | anEvent = static_cast<Event *>(incidence); |
2723 | } | 2732 | } |
2724 | } | 2733 | } |
2725 | 2734 | ||
2726 | if (!anEvent) { | 2735 | if (!anEvent) { |
2727 | KNotifyClient::beep(); | 2736 | KNotifyClient::beep(); |
2728 | return; | 2737 | return; |
2729 | } | 2738 | } |
2730 | 2739 | ||
2731 | editEvent(anEvent); | 2740 | editEvent(anEvent); |
2732 | } | 2741 | } |
2733 | 2742 | ||
2734 | void CalendarView::appointment_delete() | 2743 | void CalendarView::appointment_delete() |
2735 | { | 2744 | { |
2736 | Event *anEvent = 0; | 2745 | Event *anEvent = 0; |
2737 | 2746 | ||
2738 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2747 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2739 | 2748 | ||
2740 | if (mViewManager->currentView()->isEventView()) { | 2749 | if (mViewManager->currentView()->isEventView()) { |
2741 | if ( incidence && incidence->type() == "Event" ) { | 2750 | if ( incidence && incidence->type() == "Event" ) { |
2742 | anEvent = static_cast<Event *>(incidence); | 2751 | anEvent = static_cast<Event *>(incidence); |
2743 | } | 2752 | } |
2744 | } | 2753 | } |
2745 | 2754 | ||
2746 | if (!anEvent) { | 2755 | if (!anEvent) { |
2747 | KNotifyClient::beep(); | 2756 | KNotifyClient::beep(); |
2748 | return; | 2757 | return; |
2749 | } | 2758 | } |
2750 | 2759 | ||
2751 | deleteEvent(anEvent); | 2760 | deleteEvent(anEvent); |
2752 | } | 2761 | } |
2753 | 2762 | ||
2754 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 2763 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
2755 | { | 2764 | { |
2756 | if (!sub) return; | 2765 | if (!sub) return; |
2757 | if (!parent) return; | 2766 | if (!parent) return; |
2758 | if ( sub->relatedTo() ) | 2767 | if ( sub->relatedTo() ) |
2759 | sub->relatedTo()->removeRelation(sub); | 2768 | sub->relatedTo()->removeRelation(sub); |
2760 | sub->setRelatedTo(parent); | 2769 | sub->setRelatedTo(parent); |
2761 | sub->setRelatedToUid(parent->uid()); | 2770 | sub->setRelatedToUid(parent->uid()); |
2762 | parent->addRelation(sub); | 2771 | parent->addRelation(sub); |
2763 | sub->updated(); | 2772 | sub->updated(); |
2764 | parent->updated(); | 2773 | parent->updated(); |
2765 | setModified(true); | 2774 | setModified(true); |
2766 | updateView(); | 2775 | updateView(); |
2767 | } | 2776 | } |
2768 | void CalendarView::todo_unsub(Todo *anTodo ) | 2777 | void CalendarView::todo_unsub(Todo *anTodo ) |
2769 | { | 2778 | { |
2770 | // Todo *anTodo = selectedTodo(); | 2779 | // Todo *anTodo = selectedTodo(); |
2771 | if (!anTodo) return; | 2780 | if (!anTodo) return; |
2772 | if (!anTodo->relatedTo()) return; | 2781 | if (!anTodo->relatedTo()) return; |
2773 | anTodo->relatedTo()->removeRelation(anTodo); | 2782 | anTodo->relatedTo()->removeRelation(anTodo); |
2774 | anTodo->setRelatedTo(0); | 2783 | anTodo->setRelatedTo(0); |
2775 | anTodo->updated(); | 2784 | anTodo->updated(); |
2776 | anTodo->setRelatedToUid(""); | 2785 | anTodo->setRelatedToUid(""); |
2777 | setModified(true); | 2786 | setModified(true); |
2778 | updateView(); | 2787 | updateView(); |
2779 | } | 2788 | } |
2780 | 2789 | ||
2781 | void CalendarView::deleteTodo(Todo *todo) | 2790 | void CalendarView::deleteTodo(Todo *todo) |
2782 | { | 2791 | { |
2783 | if (!todo) { | 2792 | if (!todo) { |
2784 | KNotifyClient::beep(); | 2793 | KNotifyClient::beep(); |
2785 | return; | 2794 | return; |
2786 | } | 2795 | } |
2787 | if (KOPrefs::instance()->mConfirm) { | 2796 | if (KOPrefs::instance()->mConfirm) { |
2788 | switch (msgItemDelete()) { | 2797 | switch (msgItemDelete()) { |
2789 | case KMessageBox::Continue: // OK | 2798 | case KMessageBox::Continue: // OK |
2790 | if (!todo->relations().isEmpty()) { | 2799 | if (!todo->relations().isEmpty()) { |
2791 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), | 2800 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), |
2792 | i18n("Delete To-Do")); | 2801 | i18n("Delete To-Do")); |
2793 | } else { | 2802 | } else { |
2794 | checkExternalId( todo ); | 2803 | checkExternalId( todo ); |
2795 | calendar()->deleteTodo(todo); | 2804 | calendar()->deleteTodo(todo); |
2796 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2805 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2797 | updateView(); | 2806 | updateView(); |
2798 | } | 2807 | } |
2799 | break; | 2808 | break; |
2800 | } // switch | 2809 | } // switch |
2801 | } else { | 2810 | } else { |
2802 | if (!todo->relations().isEmpty()) { | 2811 | if (!todo->relations().isEmpty()) { |
2803 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), | 2812 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), |
2804 | i18n("Delete To-Do")); | 2813 | i18n("Delete To-Do")); |
2805 | } else { | 2814 | } else { |
2806 | checkExternalId( todo ); | 2815 | checkExternalId( todo ); |
2807 | mCalendar->deleteTodo(todo); | 2816 | mCalendar->deleteTodo(todo); |
2808 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2817 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2809 | updateView(); | 2818 | updateView(); |
2810 | } | 2819 | } |
2811 | } | 2820 | } |
2812 | emit updateSearchDialog(); | 2821 | emit updateSearchDialog(); |
2813 | } | 2822 | } |
2814 | void CalendarView::deleteJournal(Journal *jour) | 2823 | void CalendarView::deleteJournal(Journal *jour) |
2815 | { | 2824 | { |
2816 | if (!jour) { | 2825 | if (!jour) { |
2817 | KNotifyClient::beep(); | 2826 | KNotifyClient::beep(); |
2818 | return; | 2827 | return; |
2819 | } | 2828 | } |
2820 | if (KOPrefs::instance()->mConfirm) { | 2829 | if (KOPrefs::instance()->mConfirm) { |
2821 | switch (msgItemDelete()) { | 2830 | switch (msgItemDelete()) { |
2822 | case KMessageBox::Continue: // OK | 2831 | case KMessageBox::Continue: // OK |
2823 | calendar()->deleteJournal(jour); | 2832 | calendar()->deleteJournal(jour); |
2824 | updateView(); | 2833 | updateView(); |
2825 | break; | 2834 | break; |
2826 | } // switch | 2835 | } // switch |
2827 | } else { | 2836 | } else { |
2828 | calendar()->deleteJournal(jour);; | 2837 | calendar()->deleteJournal(jour);; |
2829 | updateView(); | 2838 | updateView(); |
2830 | } | 2839 | } |
2831 | emit updateSearchDialog(); | 2840 | emit updateSearchDialog(); |
2832 | } | 2841 | } |
2833 | 2842 | ||
2834 | void CalendarView::deleteEvent(Event *anEvent) | 2843 | void CalendarView::deleteEvent(Event *anEvent) |
2835 | { | 2844 | { |
2836 | if (!anEvent) { | 2845 | if (!anEvent) { |
2837 | KNotifyClient::beep(); | 2846 | KNotifyClient::beep(); |
2838 | return; | 2847 | return; |
2839 | } | 2848 | } |
2840 | 2849 | ||
2841 | if (anEvent->recurrence()->doesRecur()) { | 2850 | if (anEvent->recurrence()->doesRecur()) { |
2842 | QDate itemDate = mViewManager->currentSelectionDate(); | 2851 | QDate itemDate = mViewManager->currentSelectionDate(); |
2843 | int km; | 2852 | int km; |
2844 | if (!itemDate.isValid()) { | 2853 | if (!itemDate.isValid()) { |
2845 | //kdDebug() << "Date Not Valid" << endl; | 2854 | //kdDebug() << "Date Not Valid" << endl; |
2846 | if (KOPrefs::instance()->mConfirm) { | 2855 | if (KOPrefs::instance()->mConfirm) { |
2847 | km = KMessageBox::warningContinueCancel(this,anEvent->summary() + | 2856 | km = KMessageBox::warningContinueCancel(this,anEvent->summary() + |
2848 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 2857 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
2849 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 2858 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
2850 | if ( km == KMessageBox::Continue ) | 2859 | if ( km == KMessageBox::Continue ) |
2851 | km = KMessageBox::No; // No = all below | 2860 | km = KMessageBox::No; // No = all below |
2852 | } else | 2861 | } else |
2853 | km = KMessageBox::No; | 2862 | km = KMessageBox::No; |
2854 | } else { | 2863 | } else { |
2855 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + | 2864 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + |
2856 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 2865 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
2857 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 2866 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
2858 | i18n("KO/Pi Confirmation"),i18n("Current"), | 2867 | i18n("KO/Pi Confirmation"),i18n("Current"), |
2859 | i18n("All")); | 2868 | i18n("All")); |
2860 | } | 2869 | } |
2861 | switch(km) { | 2870 | switch(km) { |
2862 | 2871 | ||
2863 | case KMessageBox::No: // Continue // all | 2872 | case KMessageBox::No: // Continue // all |
2864 | //qDebug("KMessageBox::No "); | 2873 | //qDebug("KMessageBox::No "); |
2865 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2874 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2866 | schedule(Scheduler::Cancel,anEvent); | 2875 | schedule(Scheduler::Cancel,anEvent); |
2867 | 2876 | ||
2868 | checkExternalId( anEvent); | 2877 | checkExternalId( anEvent); |
2869 | mCalendar->deleteEvent(anEvent); | 2878 | mCalendar->deleteEvent(anEvent); |
2870 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 2879 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
2871 | break; | 2880 | break; |
2872 | 2881 | ||
2873 | // Disabled because it does not work | 2882 | // Disabled because it does not work |
2874 | //#if 0 | 2883 | //#if 0 |
2875 | case KMessageBox::Yes: // just this one | 2884 | case KMessageBox::Yes: // just this one |
2876 | //QDate qd = mNavigator->selectedDates().first(); | 2885 | //QDate qd = mNavigator->selectedDates().first(); |
2877 | //if (!qd.isValid()) { | 2886 | //if (!qd.isValid()) { |
2878 | // kdDebug() << "no date selected, or invalid date" << endl; | 2887 | // kdDebug() << "no date selected, or invalid date" << endl; |
2879 | // KNotifyClient::beep(); | 2888 | // KNotifyClient::beep(); |
2880 | // return; | 2889 | // return; |
2881 | //} | 2890 | //} |
2882 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 2891 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
2883 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 2892 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
2884 | anEvent->addExDate(itemDate); | 2893 | anEvent->addExDate(itemDate); |
2885 | int duration = anEvent->recurrence()->duration(); | 2894 | int duration = anEvent->recurrence()->duration(); |
2886 | if ( duration > 0 ) { | 2895 | if ( duration > 0 ) { |
2887 | anEvent->recurrence()->setDuration( duration - 1 ); | 2896 | anEvent->recurrence()->setDuration( duration - 1 ); |
2888 | } | 2897 | } |
2889 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 2898 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
2890 | } | 2899 | } |
2891 | break; | 2900 | break; |
2892 | //#endif | 2901 | //#endif |
2893 | } // switch | 2902 | } // switch |
2894 | } else { | 2903 | } else { |
2895 | if (KOPrefs::instance()->mConfirm) { | 2904 | if (KOPrefs::instance()->mConfirm) { |
2896 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + | 2905 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + |
2897 | i18n("\nAre you sure you want\nto delete this event?"), | 2906 | i18n("\nAre you sure you want\nto delete this event?"), |
2898 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 2907 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
2899 | case KMessageBox::Continue: // OK | 2908 | case KMessageBox::Continue: // OK |
2900 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2909 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2901 | schedule(Scheduler::Cancel,anEvent); | 2910 | schedule(Scheduler::Cancel,anEvent); |
2902 | checkExternalId( anEvent); | 2911 | checkExternalId( anEvent); |
2903 | mCalendar->deleteEvent(anEvent); | 2912 | mCalendar->deleteEvent(anEvent); |
2904 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2913 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2905 | break; | 2914 | break; |
2906 | } // switch | 2915 | } // switch |
2907 | } else { | 2916 | } else { |
2908 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2917 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2909 | schedule(Scheduler::Cancel,anEvent); | 2918 | schedule(Scheduler::Cancel,anEvent); |
2910 | checkExternalId( anEvent); | 2919 | checkExternalId( anEvent); |
2911 | mCalendar->deleteEvent(anEvent); | 2920 | mCalendar->deleteEvent(anEvent); |
2912 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2921 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2913 | } | 2922 | } |
2914 | } // if-else | 2923 | } // if-else |
2915 | emit updateSearchDialog(); | 2924 | emit updateSearchDialog(); |
2916 | } | 2925 | } |
2917 | 2926 | ||
2918 | bool CalendarView::deleteEvent(const QString &uid) | 2927 | bool CalendarView::deleteEvent(const QString &uid) |
2919 | { | 2928 | { |
2920 | Event *ev = mCalendar->event(uid); | 2929 | Event *ev = mCalendar->event(uid); |
2921 | if (ev) { | 2930 | if (ev) { |
2922 | deleteEvent(ev); | 2931 | deleteEvent(ev); |
2923 | return true; | 2932 | return true; |
2924 | } else { | 2933 | } else { |
2925 | return false; | 2934 | return false; |
2926 | } | 2935 | } |
2927 | } | 2936 | } |
2928 | 2937 | ||
2929 | /*****************************************************************************/ | 2938 | /*****************************************************************************/ |
2930 | 2939 | ||
2931 | void CalendarView::action_mail() | 2940 | void CalendarView::action_mail() |
2932 | { | 2941 | { |
2933 | #ifndef KORG_NOMAIL | 2942 | #ifndef KORG_NOMAIL |
2934 | KOMailClient mailClient; | 2943 | KOMailClient mailClient; |
2935 | 2944 | ||
2936 | Incidence *incidence = currentSelection(); | 2945 | Incidence *incidence = currentSelection(); |
2937 | 2946 | ||
2938 | if (!incidence) { | 2947 | if (!incidence) { |
2939 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 2948 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
2940 | return; | 2949 | return; |
2941 | } | 2950 | } |
2942 | if(incidence->attendeeCount() == 0 ) { | 2951 | if(incidence->attendeeCount() == 0 ) { |
2943 | KMessageBox::sorry(this, | 2952 | KMessageBox::sorry(this, |
2944 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 2953 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
2945 | return; | 2954 | return; |
2946 | } | 2955 | } |
2947 | 2956 | ||
2948 | CalendarLocal cal_tmp; | 2957 | CalendarLocal cal_tmp; |
2949 | Event *event = 0; | 2958 | Event *event = 0; |
2950 | Event *ev = 0; | 2959 | Event *ev = 0; |
2951 | if ( incidence && incidence->type() == "Event" ) { | 2960 | if ( incidence && incidence->type() == "Event" ) { |
2952 | event = static_cast<Event *>(incidence); | 2961 | event = static_cast<Event *>(incidence); |
2953 | ev = new Event(*event); | 2962 | ev = new Event(*event); |
2954 | cal_tmp.addEvent(ev); | 2963 | cal_tmp.addEvent(ev); |
2955 | } | 2964 | } |
2956 | ICalFormat mForm(); | 2965 | ICalFormat mForm(); |
2957 | QString attachment = mForm.toString( &cal_tmp ); | 2966 | QString attachment = mForm.toString( &cal_tmp ); |
2958 | if (ev) delete(ev); | 2967 | if (ev) delete(ev); |
2959 | 2968 | ||
2960 | mailClient.mailAttendees(currentSelection(), attachment); | 2969 | mailClient.mailAttendees(currentSelection(), attachment); |
2961 | 2970 | ||
2962 | #endif | 2971 | #endif |
2963 | 2972 | ||
2964 | #if 0 | 2973 | #if 0 |
2965 | Event *anEvent = 0; | 2974 | Event *anEvent = 0; |
2966 | if (mViewManager->currentView()->isEventView()) { | 2975 | if (mViewManager->currentView()->isEventView()) { |
2967 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 2976 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
2968 | } | 2977 | } |
2969 | 2978 | ||
2970 | if (!anEvent) { | 2979 | if (!anEvent) { |
2971 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 2980 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
2972 | return; | 2981 | return; |
2973 | } | 2982 | } |
2974 | if(anEvent->attendeeCount() == 0 ) { | 2983 | if(anEvent->attendeeCount() == 0 ) { |
2975 | KMessageBox::sorry(this, | 2984 | KMessageBox::sorry(this, |
2976 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 2985 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
2977 | return; | 2986 | return; |
2978 | } | 2987 | } |
2979 | 2988 | ||
2980 | mailobject.emailEvent(anEvent); | 2989 | mailobject.emailEvent(anEvent); |
2981 | #endif | 2990 | #endif |
2982 | } | 2991 | } |
2983 | 2992 | ||
2984 | 2993 | ||
2985 | void CalendarView::schedule_publish(Incidence *incidence) | 2994 | void CalendarView::schedule_publish(Incidence *incidence) |
2986 | { | 2995 | { |
2987 | Event *event = 0; | 2996 | Event *event = 0; |
2988 | Todo *todo = 0; | 2997 | Todo *todo = 0; |
2989 | 2998 | ||
2990 | if (incidence == 0) { | 2999 | if (incidence == 0) { |
2991 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3000 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
2992 | if (incidence == 0) { | 3001 | if (incidence == 0) { |
2993 | incidence = mTodoList->selectedIncidences().first(); | 3002 | incidence = mTodoList->selectedIncidences().first(); |
2994 | } | 3003 | } |
2995 | } | 3004 | } |
2996 | if ( incidence && incidence->type() == "Event" ) { | 3005 | if ( incidence && incidence->type() == "Event" ) { |
2997 | event = static_cast<Event *>(incidence); | 3006 | event = static_cast<Event *>(incidence); |
2998 | } else { | 3007 | } else { |
2999 | if ( incidence && incidence->type() == "Todo" ) { | 3008 | if ( incidence && incidence->type() == "Todo" ) { |
3000 | todo = static_cast<Todo *>(incidence); | 3009 | todo = static_cast<Todo *>(incidence); |
3001 | } | 3010 | } |
3002 | } | 3011 | } |
3003 | 3012 | ||
3004 | if (!event && !todo) { | 3013 | if (!event && !todo) { |
3005 | KMessageBox::sorry(this,i18n("No event selected.")); | 3014 | KMessageBox::sorry(this,i18n("No event selected.")); |
3006 | return; | 3015 | return; |
3007 | } | 3016 | } |
3008 | 3017 | ||
3009 | PublishDialog *publishdlg = new PublishDialog(); | 3018 | PublishDialog *publishdlg = new PublishDialog(); |
3010 | if (incidence->attendeeCount()>0) { | 3019 | if (incidence->attendeeCount()>0) { |
3011 | QPtrList<Attendee> attendees = incidence->attendees(); | 3020 | QPtrList<Attendee> attendees = incidence->attendees(); |
3012 | attendees.first(); | 3021 | attendees.first(); |
3013 | while ( attendees.current()!=0 ) { | 3022 | while ( attendees.current()!=0 ) { |
3014 | publishdlg->addAttendee(attendees.current()); | 3023 | publishdlg->addAttendee(attendees.current()); |
3015 | attendees.next(); | 3024 | attendees.next(); |
3016 | } | 3025 | } |
3017 | } | 3026 | } |
3018 | bool send = true; | 3027 | bool send = true; |
3019 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3028 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3020 | if ( publishdlg->exec() != QDialog::Accepted ) | 3029 | if ( publishdlg->exec() != QDialog::Accepted ) |
3021 | send = false; | 3030 | send = false; |
3022 | } | 3031 | } |
3023 | if ( send ) { | 3032 | if ( send ) { |
3024 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3033 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3025 | if ( event ) { | 3034 | if ( event ) { |
3026 | Event *ev = new Event(*event); | 3035 | Event *ev = new Event(*event); |
3027 | ev->registerObserver(0); | 3036 | ev->registerObserver(0); |
3028 | ev->clearAttendees(); | 3037 | ev->clearAttendees(); |
3029 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3038 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3030 | delete(ev); | 3039 | delete(ev); |
3031 | } | 3040 | } |
3032 | } else { | 3041 | } else { |
3033 | if ( todo ) { | 3042 | if ( todo ) { |
3034 | Todo *ev = new Todo(*todo); | 3043 | Todo *ev = new Todo(*todo); |
3035 | ev->registerObserver(0); | 3044 | ev->registerObserver(0); |
3036 | ev->clearAttendees(); | 3045 | ev->clearAttendees(); |
3037 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3046 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3038 | delete(ev); | 3047 | delete(ev); |
3039 | } | 3048 | } |
3040 | } | 3049 | } |
3041 | } | 3050 | } |
3042 | } | 3051 | } |
3043 | delete publishdlg; | 3052 | delete publishdlg; |
3044 | } | 3053 | } |
3045 | 3054 | ||
3046 | void CalendarView::schedule_request(Incidence *incidence) | 3055 | void CalendarView::schedule_request(Incidence *incidence) |
3047 | { | 3056 | { |
3048 | schedule(Scheduler::Request,incidence); | 3057 | schedule(Scheduler::Request,incidence); |
3049 | } | 3058 | } |
3050 | 3059 | ||
3051 | void CalendarView::schedule_refresh(Incidence *incidence) | 3060 | void CalendarView::schedule_refresh(Incidence *incidence) |
3052 | { | 3061 | { |
3053 | schedule(Scheduler::Refresh,incidence); | 3062 | schedule(Scheduler::Refresh,incidence); |
3054 | } | 3063 | } |
3055 | 3064 | ||
3056 | void CalendarView::schedule_cancel(Incidence *incidence) | 3065 | void CalendarView::schedule_cancel(Incidence *incidence) |
3057 | { | 3066 | { |
3058 | schedule(Scheduler::Cancel,incidence); | 3067 | schedule(Scheduler::Cancel,incidence); |
3059 | } | 3068 | } |
3060 | 3069 | ||
3061 | void CalendarView::schedule_add(Incidence *incidence) | 3070 | void CalendarView::schedule_add(Incidence *incidence) |
3062 | { | 3071 | { |
3063 | schedule(Scheduler::Add,incidence); | 3072 | schedule(Scheduler::Add,incidence); |
3064 | } | 3073 | } |
3065 | 3074 | ||
3066 | void CalendarView::schedule_reply(Incidence *incidence) | 3075 | void CalendarView::schedule_reply(Incidence *incidence) |
3067 | { | 3076 | { |
3068 | schedule(Scheduler::Reply,incidence); | 3077 | schedule(Scheduler::Reply,incidence); |
3069 | } | 3078 | } |
3070 | 3079 | ||
3071 | void CalendarView::schedule_counter(Incidence *incidence) | 3080 | void CalendarView::schedule_counter(Incidence *incidence) |
3072 | { | 3081 | { |
3073 | schedule(Scheduler::Counter,incidence); | 3082 | schedule(Scheduler::Counter,incidence); |
3074 | } | 3083 | } |
3075 | 3084 | ||
3076 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3085 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3077 | { | 3086 | { |
3078 | schedule(Scheduler::Declinecounter,incidence); | 3087 | schedule(Scheduler::Declinecounter,incidence); |
3079 | } | 3088 | } |
3080 | 3089 | ||
3081 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3090 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3082 | { | 3091 | { |
3083 | QDateTime start = QDateTime::currentDateTime(); | 3092 | QDateTime start = QDateTime::currentDateTime(); |
3084 | QDateTime end = start.addDays(daysToPublish); | 3093 | QDateTime end = start.addDays(daysToPublish); |
3085 | 3094 | ||
3086 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3095 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3087 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3096 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3088 | 3097 | ||
3089 | 3098 | ||
3090 | PublishDialog *publishdlg = new PublishDialog(); | 3099 | PublishDialog *publishdlg = new PublishDialog(); |
3091 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3100 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3092 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3101 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3093 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3102 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3094 | delete(freebusy); | 3103 | delete(freebusy); |
3095 | } | 3104 | } |
3096 | } | 3105 | } |
3097 | delete publishdlg; | 3106 | delete publishdlg; |
3098 | } | 3107 | } |
3099 | 3108 | ||
3100 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3109 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3101 | { | 3110 | { |
3102 | Event *event = 0; | 3111 | Event *event = 0; |
3103 | Todo *todo = 0; | 3112 | Todo *todo = 0; |
3104 | 3113 | ||
3105 | if (incidence == 0) { | 3114 | if (incidence == 0) { |
3106 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3115 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3107 | if (incidence == 0) { | 3116 | if (incidence == 0) { |
3108 | incidence = mTodoList->selectedIncidences().first(); | 3117 | incidence = mTodoList->selectedIncidences().first(); |
3109 | } | 3118 | } |
3110 | } | 3119 | } |
3111 | if ( incidence && incidence->type() == "Event" ) { | 3120 | if ( incidence && incidence->type() == "Event" ) { |
3112 | event = static_cast<Event *>(incidence); | 3121 | event = static_cast<Event *>(incidence); |
3113 | } | 3122 | } |
3114 | if ( incidence && incidence->type() == "Todo" ) { | 3123 | if ( incidence && incidence->type() == "Todo" ) { |
3115 | todo = static_cast<Todo *>(incidence); | 3124 | todo = static_cast<Todo *>(incidence); |
3116 | } | 3125 | } |
3117 | 3126 | ||
3118 | if (!event && !todo) { | 3127 | if (!event && !todo) { |
3119 | KMessageBox::sorry(this,i18n("No event selected.")); | 3128 | KMessageBox::sorry(this,i18n("No event selected.")); |
3120 | return; | 3129 | return; |
3121 | } | 3130 | } |
3122 | 3131 | ||
3123 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 3132 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
3124 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 3133 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
3125 | return; | 3134 | return; |
3126 | } | 3135 | } |
3127 | 3136 | ||
3128 | Event *ev = 0; | 3137 | Event *ev = 0; |
3129 | if (event) ev = new Event(*event); | 3138 | if (event) ev = new Event(*event); |
3130 | Todo *to = 0; | 3139 | Todo *to = 0; |
3131 | if (todo) to = new Todo(*todo); | 3140 | if (todo) to = new Todo(*todo); |
3132 | 3141 | ||
3133 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 3142 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
3134 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 3143 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
3135 | if (!me) { | 3144 | if (!me) { |
3136 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 3145 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
3137 | return; | 3146 | return; |
3138 | } | 3147 | } |
3139 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 3148 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
3140 | StatusDialog *statdlg = new StatusDialog(this); | 3149 | StatusDialog *statdlg = new StatusDialog(this); |
3141 | if (!statdlg->exec()==QDialog::Accepted) return; | 3150 | if (!statdlg->exec()==QDialog::Accepted) return; |
3142 | me->setStatus( statdlg->status() ); | 3151 | me->setStatus( statdlg->status() ); |
3143 | delete(statdlg); | 3152 | delete(statdlg); |
3144 | } | 3153 | } |
3145 | Attendee *menew = new Attendee(*me); | 3154 | Attendee *menew = new Attendee(*me); |
3146 | if (ev) { | 3155 | if (ev) { |
3147 | ev->clearAttendees(); | 3156 | ev->clearAttendees(); |
3148 | ev->addAttendee(menew,false); | 3157 | ev->addAttendee(menew,false); |
3149 | } else { | 3158 | } else { |
3150 | if (to) { | 3159 | if (to) { |
3151 | todo->clearAttendees(); | 3160 | todo->clearAttendees(); |
3152 | todo->addAttendee(menew,false); | 3161 | todo->addAttendee(menew,false); |
3153 | } | 3162 | } |
3154 | } | 3163 | } |
3155 | } | 3164 | } |
3156 | 3165 | ||
3157 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3166 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3158 | if (ev) { | 3167 | if (ev) { |
3159 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 3168 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
3160 | } else { | 3169 | } else { |
3161 | if (to) { | 3170 | if (to) { |
3162 | if ( !dlg->addMessage(to,method) ) delete(to); | 3171 | if ( !dlg->addMessage(to,method) ) delete(to); |
3163 | } | 3172 | } |
3164 | } | 3173 | } |
3165 | } | 3174 | } |
3166 | 3175 | ||
3167 | void CalendarView::openAddressbook() | 3176 | void CalendarView::openAddressbook() |
3168 | { | 3177 | { |
3169 | KRun::runCommand("kaddressbook"); | 3178 | KRun::runCommand("kaddressbook"); |
3170 | } | 3179 | } |
3171 | 3180 | ||
3172 | void CalendarView::setModified(bool modified) | 3181 | void CalendarView::setModified(bool modified) |
3173 | { | 3182 | { |
3174 | if ( modified ) | 3183 | if ( modified ) |
3175 | emit signalmodified(); | 3184 | emit signalmodified(); |
3176 | if (mModified != modified) { | 3185 | if (mModified != modified) { |
3177 | mModified = modified; | 3186 | mModified = modified; |
3178 | emit modifiedChanged(mModified); | 3187 | emit modifiedChanged(mModified); |
3179 | } | 3188 | } |
3180 | } | 3189 | } |
3181 | 3190 | ||
3182 | bool CalendarView::isReadOnly() | 3191 | bool CalendarView::isReadOnly() |
3183 | { | 3192 | { |
3184 | return mReadOnly; | 3193 | return mReadOnly; |
3185 | } | 3194 | } |
3186 | 3195 | ||
3187 | void CalendarView::setReadOnly(bool readOnly) | 3196 | void CalendarView::setReadOnly(bool readOnly) |
3188 | { | 3197 | { |
3189 | if (mReadOnly != readOnly) { | 3198 | if (mReadOnly != readOnly) { |
3190 | mReadOnly = readOnly; | 3199 | mReadOnly = readOnly; |
3191 | emit readOnlyChanged(mReadOnly); | 3200 | emit readOnlyChanged(mReadOnly); |
3192 | } | 3201 | } |
3193 | } | 3202 | } |
3194 | 3203 | ||
3195 | bool CalendarView::isModified() | 3204 | bool CalendarView::isModified() |
3196 | { | 3205 | { |
3197 | return mModified; | 3206 | return mModified; |
3198 | } | 3207 | } |
3199 | 3208 | ||
3200 | void CalendarView::printSetup() | 3209 | void CalendarView::printSetup() |
3201 | { | 3210 | { |
3202 | #ifndef KORG_NOPRINTER | 3211 | #ifndef KORG_NOPRINTER |
3203 | createPrinter(); | 3212 | createPrinter(); |
3204 | 3213 | ||
3205 | mCalPrinter->setupPrinter(); | 3214 | mCalPrinter->setupPrinter(); |
3206 | #endif | 3215 | #endif |
3207 | } | 3216 | } |
3208 | 3217 | ||
3209 | void CalendarView::print() | 3218 | void CalendarView::print() |
3210 | { | 3219 | { |
3211 | #ifndef KORG_NOPRINTER | 3220 | #ifndef KORG_NOPRINTER |
3212 | createPrinter(); | 3221 | createPrinter(); |
3213 | 3222 | ||
3214 | DateList tmpDateList = mNavigator->selectedDates(); | 3223 | DateList tmpDateList = mNavigator->selectedDates(); |
3215 | mCalPrinter->print(CalPrinter::Month, | 3224 | mCalPrinter->print(CalPrinter::Month, |
3216 | tmpDateList.first(), tmpDateList.last()); | 3225 | tmpDateList.first(), tmpDateList.last()); |
3217 | #endif | 3226 | #endif |
3218 | } | 3227 | } |
3219 | 3228 | ||
3220 | void CalendarView::printPreview() | 3229 | void CalendarView::printPreview() |
3221 | { | 3230 | { |
3222 | #ifndef KORG_NOPRINTER | 3231 | #ifndef KORG_NOPRINTER |
3223 | kdDebug() << "CalendarView::printPreview()" << endl; | 3232 | kdDebug() << "CalendarView::printPreview()" << endl; |
3224 | 3233 | ||
3225 | createPrinter(); | 3234 | createPrinter(); |
3226 | 3235 | ||
3227 | DateList tmpDateList = mNavigator->selectedDates(); | 3236 | DateList tmpDateList = mNavigator->selectedDates(); |
3228 | 3237 | ||
3229 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 3238 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
3230 | tmpDateList.last()); | 3239 | tmpDateList.last()); |
3231 | #endif | 3240 | #endif |
3232 | } | 3241 | } |
3233 | 3242 | ||
3234 | void CalendarView::exportICalendar() | 3243 | void CalendarView::exportICalendar() |
3235 | { | 3244 | { |
3236 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 3245 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
3237 | 3246 | ||
3238 | // Force correct extension | 3247 | // Force correct extension |
3239 | if (filename.right(4) != ".ics") filename += ".ics"; | 3248 | if (filename.right(4) != ".ics") filename += ".ics"; |
3240 | 3249 | ||
3241 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 3250 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
3242 | storage.save(); | 3251 | storage.save(); |
3243 | } | 3252 | } |
3244 | 3253 | ||
3245 | bool CalendarView::exportVCalendar( QString filename ) | 3254 | bool CalendarView::exportVCalendar( QString filename ) |
3246 | { | 3255 | { |
3247 | if (mCalendar->journals().count() > 0) { | 3256 | if (mCalendar->journals().count() > 0) { |
3248 | int result = KMessageBox::warningContinueCancel(this, | 3257 | int result = KMessageBox::warningContinueCancel(this, |
3249 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 3258 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
3250 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 3259 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
3251 | true); | 3260 | true); |
3252 | if (result != KMessageBox::Continue) return false; | 3261 | if (result != KMessageBox::Continue) return false; |
3253 | } | 3262 | } |
3254 | 3263 | ||
3255 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 3264 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
3256 | 3265 | ||
3257 | // Force correct extension | 3266 | // Force correct extension |
3258 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 3267 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
3259 | 3268 | ||
3260 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 3269 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
3261 | return storage.save(); | 3270 | return storage.save(); |
3262 | 3271 | ||
3263 | } | 3272 | } |
3264 | 3273 | ||
3265 | void CalendarView::eventUpdated(Incidence *) | 3274 | void CalendarView::eventUpdated(Incidence *) |
3266 | { | 3275 | { |
3267 | setModified(); | 3276 | setModified(); |
3268 | // Don't call updateView here. The code, which has caused the update of the | 3277 | // Don't call updateView here. The code, which has caused the update of the |
3269 | // event is responsible for updating the view. | 3278 | // event is responsible for updating the view. |
3270 | // updateView(); | 3279 | // updateView(); |
3271 | } | 3280 | } |
3272 | 3281 | ||
3273 | void CalendarView::adaptNavigationUnits() | 3282 | void CalendarView::adaptNavigationUnits() |
3274 | { | 3283 | { |
3275 | if (mViewManager->currentView()->isEventView()) { | 3284 | if (mViewManager->currentView()->isEventView()) { |
3276 | int days = mViewManager->currentView()->currentDateCount(); | 3285 | int days = mViewManager->currentView()->currentDateCount(); |
3277 | if (days == 1) { | 3286 | if (days == 1) { |
3278 | emit changeNavStringPrev(i18n("&Previous Day")); | 3287 | emit changeNavStringPrev(i18n("&Previous Day")); |
3279 | emit changeNavStringNext(i18n("&Next Day")); | 3288 | emit changeNavStringNext(i18n("&Next Day")); |
3280 | } else { | 3289 | } else { |
3281 | emit changeNavStringPrev(i18n("&Previous Week")); | 3290 | emit changeNavStringPrev(i18n("&Previous Week")); |
3282 | emit changeNavStringNext(i18n("&Next Week")); | 3291 | emit changeNavStringNext(i18n("&Next Week")); |
3283 | } | 3292 | } |
3284 | } | 3293 | } |
3285 | } | 3294 | } |
3286 | 3295 | ||
3287 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 3296 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
3288 | { | 3297 | { |
3289 | if ( incidence ) mTodoList->clearSelection(); | 3298 | if ( incidence ) mTodoList->clearSelection(); |
3290 | processIncidenceSelection( incidence ); | 3299 | processIncidenceSelection( incidence ); |
3291 | } | 3300 | } |
3292 | 3301 | ||
3293 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 3302 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
3294 | { | 3303 | { |
3295 | if ( incidence && mViewManager->currentView() ) { | 3304 | if ( incidence && mViewManager->currentView() ) { |
3296 | mViewManager->currentView()->clearSelection(); | 3305 | mViewManager->currentView()->clearSelection(); |
3297 | } | 3306 | } |
3298 | processIncidenceSelection( incidence ); | 3307 | processIncidenceSelection( incidence ); |
3299 | } | 3308 | } |
3300 | 3309 | ||
3301 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 3310 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
3302 | { | 3311 | { |
3303 | if ( incidence == mSelectedIncidence ) return; | 3312 | if ( incidence == mSelectedIncidence ) return; |
3304 | 3313 | ||
3305 | mSelectedIncidence = incidence; | 3314 | mSelectedIncidence = incidence; |
3306 | 3315 | ||
3307 | emit incidenceSelected( mSelectedIncidence ); | 3316 | emit incidenceSelected( mSelectedIncidence ); |
3308 | 3317 | ||
3309 | if ( incidence && incidence->type() == "Event" ) { | 3318 | if ( incidence && incidence->type() == "Event" ) { |
3310 | Event *event = static_cast<Event *>( incidence ); | 3319 | Event *event = static_cast<Event *>( incidence ); |
3311 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3320 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3312 | emit organizerEventsSelected( true ); | 3321 | emit organizerEventsSelected( true ); |
3313 | } else { | 3322 | } else { |
3314 | emit organizerEventsSelected(false); | 3323 | emit organizerEventsSelected(false); |
3315 | } | 3324 | } |
3316 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3325 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3317 | KOPrefs::instance()->email() ) ) { | 3326 | KOPrefs::instance()->email() ) ) { |
3318 | emit groupEventsSelected( true ); | 3327 | emit groupEventsSelected( true ); |
3319 | } else { | 3328 | } else { |
3320 | emit groupEventsSelected(false); | 3329 | emit groupEventsSelected(false); |
3321 | } | 3330 | } |
3322 | return; | 3331 | return; |
3323 | } else { | 3332 | } else { |
3324 | if ( incidence && incidence->type() == "Todo" ) { | 3333 | if ( incidence && incidence->type() == "Todo" ) { |
3325 | emit todoSelected( true ); | 3334 | emit todoSelected( true ); |
3326 | Todo *event = static_cast<Todo *>( incidence ); | 3335 | Todo *event = static_cast<Todo *>( incidence ); |
3327 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3336 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3328 | emit organizerEventsSelected( true ); | 3337 | emit organizerEventsSelected( true ); |
3329 | } else { | 3338 | } else { |
3330 | emit organizerEventsSelected(false); | 3339 | emit organizerEventsSelected(false); |
3331 | } | 3340 | } |
3332 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3341 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3333 | KOPrefs::instance()->email() ) ) { | 3342 | KOPrefs::instance()->email() ) ) { |
3334 | emit groupEventsSelected( true ); | 3343 | emit groupEventsSelected( true ); |
3335 | } else { | 3344 | } else { |
3336 | emit groupEventsSelected(false); | 3345 | emit groupEventsSelected(false); |
3337 | } | 3346 | } |
3338 | return; | 3347 | return; |
3339 | } else { | 3348 | } else { |
3340 | emit todoSelected( false ); | 3349 | emit todoSelected( false ); |
3341 | emit organizerEventsSelected(false); | 3350 | emit organizerEventsSelected(false); |
3342 | emit groupEventsSelected(false); | 3351 | emit groupEventsSelected(false); |
3343 | } | 3352 | } |
3344 | return; | 3353 | return; |
3345 | } | 3354 | } |
3346 | 3355 | ||
3347 | /* if ( incidence && incidence->type() == "Todo" ) { | 3356 | /* if ( incidence && incidence->type() == "Todo" ) { |
3348 | emit todoSelected( true ); | 3357 | emit todoSelected( true ); |
3349 | } else { | 3358 | } else { |
3350 | emit todoSelected( false ); | 3359 | emit todoSelected( false ); |
3351 | }*/ | 3360 | }*/ |
3352 | } | 3361 | } |
3353 | 3362 | ||
3354 | 3363 | ||
3355 | void CalendarView::checkClipboard() | 3364 | void CalendarView::checkClipboard() |
3356 | { | 3365 | { |
3357 | #ifndef KORG_NODND | 3366 | #ifndef KORG_NODND |
3358 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 3367 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
3359 | emit pasteEnabled(true); | 3368 | emit pasteEnabled(true); |
3360 | } else { | 3369 | } else { |
3361 | emit pasteEnabled(false); | 3370 | emit pasteEnabled(false); |
3362 | } | 3371 | } |
3363 | #endif | 3372 | #endif |
3364 | } | 3373 | } |
3365 | 3374 | ||
3366 | void CalendarView::showDates(const DateList &selectedDates) | 3375 | void CalendarView::showDates(const DateList &selectedDates) |
3367 | { | 3376 | { |
3368 | // kdDebug() << "CalendarView::selectDates()" << endl; | 3377 | // kdDebug() << "CalendarView::selectDates()" << endl; |
3369 | 3378 | ||
3370 | if ( mViewManager->currentView() ) { | 3379 | if ( mViewManager->currentView() ) { |
3371 | updateView( selectedDates.first(), selectedDates.last() ); | 3380 | updateView( selectedDates.first(), selectedDates.last() ); |
3372 | } else { | 3381 | } else { |
3373 | mViewManager->showAgendaView(); | 3382 | mViewManager->showAgendaView(); |
3374 | } | 3383 | } |
3375 | 3384 | ||
3376 | QString selDates; | 3385 | QString selDates; |
3377 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); | 3386 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); |
3378 | if (selectedDates.first() < selectedDates.last() ) | 3387 | if (selectedDates.first() < selectedDates.last() ) |
3379 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 3388 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
3380 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 3389 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
3381 | 3390 | ||
3382 | } | 3391 | } |
3383 | 3392 | ||
3384 | QPtrList<CalFilter> CalendarView::filters() | 3393 | QPtrList<CalFilter> CalendarView::filters() |
3385 | { | 3394 | { |
3386 | return mFilters; | 3395 | return mFilters; |
3387 | 3396 | ||
3388 | } | 3397 | } |
3389 | void CalendarView::editFilters() | 3398 | void CalendarView::editFilters() |
3390 | { | 3399 | { |
3391 | // kdDebug() << "CalendarView::editFilters()" << endl; | 3400 | // kdDebug() << "CalendarView::editFilters()" << endl; |
3392 | 3401 | ||
3393 | CalFilter *filter = mFilters.first(); | 3402 | CalFilter *filter = mFilters.first(); |
3394 | while(filter) { | 3403 | while(filter) { |
3395 | kdDebug() << " Filter: " << filter->name() << endl; | 3404 | kdDebug() << " Filter: " << filter->name() << endl; |
3396 | filter = mFilters.next(); | 3405 | filter = mFilters.next(); |
3397 | } | 3406 | } |
3398 | 3407 | ||
3399 | mDialogManager->showFilterEditDialog(&mFilters); | 3408 | mDialogManager->showFilterEditDialog(&mFilters); |
3400 | } | 3409 | } |
3401 | void CalendarView::toggleFilter() | 3410 | void CalendarView::toggleFilter() |
3402 | { | 3411 | { |
3403 | showFilter(! mFilterView->isVisible()); | 3412 | showFilter(! mFilterView->isVisible()); |
3404 | } | 3413 | } |
3405 | 3414 | ||
3406 | KOFilterView *CalendarView::filterView() | 3415 | KOFilterView *CalendarView::filterView() |
3407 | { | 3416 | { |
3408 | return mFilterView; | 3417 | return mFilterView; |
3409 | } | 3418 | } |
3410 | void CalendarView::selectFilter( int fil ) | 3419 | void CalendarView::selectFilter( int fil ) |
3411 | { | 3420 | { |
3412 | mFilterView->setSelectedFilter( fil ); | 3421 | mFilterView->setSelectedFilter( fil ); |
3413 | } | 3422 | } |
3414 | void CalendarView::showFilter(bool visible) | 3423 | void CalendarView::showFilter(bool visible) |
3415 | { | 3424 | { |
3416 | if (visible) mFilterView->show(); | 3425 | if (visible) mFilterView->show(); |
3417 | else mFilterView->hide(); | 3426 | else mFilterView->hide(); |
3418 | } | 3427 | } |
3419 | void CalendarView::toggleFilerEnabled( ) | 3428 | void CalendarView::toggleFilerEnabled( ) |
3420 | { | 3429 | { |
3421 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 3430 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
3422 | if ( !mFilterView->filtersEnabled() ) | 3431 | if ( !mFilterView->filtersEnabled() ) |
3423 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 3432 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
3424 | 3433 | ||
3425 | } | 3434 | } |
3426 | void CalendarView::updateFilter() | 3435 | void CalendarView::updateFilter() |
3427 | { | 3436 | { |
3428 | CalFilter *filter = mFilterView->selectedFilter(); | 3437 | CalFilter *filter = mFilterView->selectedFilter(); |
3429 | if (filter) { | 3438 | if (filter) { |
3430 | if (mFilterView->filtersEnabled()) { | 3439 | if (mFilterView->filtersEnabled()) { |
3431 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); | 3440 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); |
3432 | filter->setEnabled(true); | 3441 | filter->setEnabled(true); |
3433 | } | 3442 | } |
3434 | else filter->setEnabled(false); | 3443 | else filter->setEnabled(false); |
3435 | mCalendar->setFilter(filter); | 3444 | mCalendar->setFilter(filter); |
3436 | updateView(); | 3445 | updateView(); |
3437 | } | 3446 | } |
3438 | } | 3447 | } |
3439 | 3448 | ||
3440 | void CalendarView::filterEdited() | 3449 | void CalendarView::filterEdited() |
3441 | { | 3450 | { |
3442 | mFilterView->updateFilters(); | 3451 | mFilterView->updateFilters(); |
3443 | updateFilter(); | 3452 | updateFilter(); |
3444 | writeSettings(); | 3453 | writeSettings(); |
3445 | } | 3454 | } |
3446 | 3455 | ||
3447 | 3456 | ||
3448 | void CalendarView::takeOverEvent() | 3457 | void CalendarView::takeOverEvent() |
3449 | { | 3458 | { |
3450 | Incidence *incidence = currentSelection(); | 3459 | Incidence *incidence = currentSelection(); |
3451 | 3460 | ||
3452 | if (!incidence) return; | 3461 | if (!incidence) return; |
3453 | 3462 | ||
3454 | incidence->setOrganizer(KOPrefs::instance()->email()); | 3463 | incidence->setOrganizer(KOPrefs::instance()->email()); |
3455 | incidence->recreate(); | 3464 | incidence->recreate(); |
3456 | incidence->setReadOnly(false); | 3465 | incidence->setReadOnly(false); |
3457 | 3466 | ||
3458 | updateView(); | 3467 | updateView(); |
3459 | } | 3468 | } |
3460 | 3469 | ||
3461 | void CalendarView::takeOverCalendar() | 3470 | void CalendarView::takeOverCalendar() |
3462 | { | 3471 | { |
3463 | // TODO: Create Calendar::allIncidences() function and use it here | 3472 | // TODO: Create Calendar::allIncidences() function and use it here |
3464 | 3473 | ||
3465 | QPtrList<Event> events = mCalendar->events(); | 3474 | QPtrList<Event> events = mCalendar->events(); |
3466 | for(uint i=0; i<events.count(); ++i) { | 3475 | for(uint i=0; i<events.count(); ++i) { |
3467 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3476 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3468 | events.at(i)->recreate(); | 3477 | events.at(i)->recreate(); |
3469 | events.at(i)->setReadOnly(false); | 3478 | events.at(i)->setReadOnly(false); |
3470 | } | 3479 | } |
3471 | 3480 | ||
3472 | QPtrList<Todo> todos = mCalendar->todos(); | 3481 | QPtrList<Todo> todos = mCalendar->todos(); |
3473 | for(uint i=0; i<todos.count(); ++i) { | 3482 | for(uint i=0; i<todos.count(); ++i) { |
3474 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3483 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3475 | todos.at(i)->recreate(); | 3484 | todos.at(i)->recreate(); |
3476 | todos.at(i)->setReadOnly(false); | 3485 | todos.at(i)->setReadOnly(false); |
3477 | } | 3486 | } |
3478 | 3487 | ||
3479 | QPtrList<Journal> journals = mCalendar->journals(); | 3488 | QPtrList<Journal> journals = mCalendar->journals(); |
3480 | for(uint i=0; i<journals.count(); ++i) { | 3489 | for(uint i=0; i<journals.count(); ++i) { |
3481 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3490 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3482 | journals.at(i)->recreate(); | 3491 | journals.at(i)->recreate(); |
3483 | journals.at(i)->setReadOnly(false); | 3492 | journals.at(i)->setReadOnly(false); |
3484 | } | 3493 | } |
3485 | 3494 | ||
3486 | updateView(); | 3495 | updateView(); |
3487 | } | 3496 | } |
3488 | 3497 | ||
3489 | void CalendarView::showIntro() | 3498 | void CalendarView::showIntro() |
3490 | { | 3499 | { |
3491 | kdDebug() << "To be implemented." << endl; | 3500 | kdDebug() << "To be implemented." << endl; |
3492 | } | 3501 | } |
3493 | 3502 | ||
3494 | QWidgetStack *CalendarView::viewStack() | 3503 | QWidgetStack *CalendarView::viewStack() |
3495 | { | 3504 | { |
3496 | return mRightFrame; | 3505 | return mRightFrame; |
3497 | } | 3506 | } |
3498 | 3507 | ||
3499 | QWidget *CalendarView::leftFrame() | 3508 | QWidget *CalendarView::leftFrame() |
3500 | { | 3509 | { |
3501 | return mLeftFrame; | 3510 | return mLeftFrame; |
3502 | } | 3511 | } |
3503 | 3512 | ||
3504 | DateNavigator *CalendarView::dateNavigator() | 3513 | DateNavigator *CalendarView::dateNavigator() |
3505 | { | 3514 | { |
3506 | return mNavigator; | 3515 | return mNavigator; |
3507 | } | 3516 | } |
3508 | 3517 | ||
3509 | KDateNavigator* CalendarView::dateNavigatorWidget() | 3518 | KDateNavigator* CalendarView::dateNavigatorWidget() |
3510 | { | 3519 | { |
3511 | return mDateNavigator; | 3520 | return mDateNavigator; |
3512 | } | 3521 | } |
3513 | void CalendarView::toggleDateNavigatorWidget() | 3522 | void CalendarView::toggleDateNavigatorWidget() |
3514 | { | 3523 | { |
3515 | if (mDateNavigator->isVisible()) | 3524 | if (mDateNavigator->isVisible()) |
3516 | mDateNavigator->hide(); | 3525 | mDateNavigator->hide(); |
3517 | else | 3526 | else |
3518 | mDateNavigator->show(); | 3527 | mDateNavigator->show(); |
3519 | } | 3528 | } |
3520 | void CalendarView::addView(KOrg::BaseView *view) | 3529 | void CalendarView::addView(KOrg::BaseView *view) |
3521 | { | 3530 | { |
3522 | mViewManager->addView(view); | 3531 | mViewManager->addView(view); |
3523 | } | 3532 | } |
3524 | 3533 | ||
3525 | void CalendarView::showView(KOrg::BaseView *view) | 3534 | void CalendarView::showView(KOrg::BaseView *view) |
3526 | { | 3535 | { |
3527 | mViewManager->showView(view, mLeftFrame->isVisible()); | 3536 | mViewManager->showView(view, mLeftFrame->isVisible()); |
3528 | } | 3537 | } |
3529 | 3538 | ||
3530 | Incidence *CalendarView::currentSelection() | 3539 | Incidence *CalendarView::currentSelection() |
3531 | { | 3540 | { |
3532 | return mViewManager->currentSelection(); | 3541 | return mViewManager->currentSelection(); |
3533 | } | 3542 | } |
3534 | void CalendarView::toggleAllDaySize() | 3543 | void CalendarView::toggleAllDaySize() |
3535 | { | 3544 | { |
3536 | /* | 3545 | /* |
3537 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 3546 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
3538 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 3547 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
3539 | else | 3548 | else |
3540 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 3549 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
3541 | */ | 3550 | */ |
3542 | viewManager()->agendaView()->toggleAllDay(); | 3551 | viewManager()->agendaView()->toggleAllDay(); |
3543 | } | 3552 | } |
3544 | void CalendarView::toggleExpand() | 3553 | void CalendarView::toggleExpand() |
3545 | { | 3554 | { |
3546 | // if ( mLeftFrame->isHidden() ) { | 3555 | // if ( mLeftFrame->isHidden() ) { |
3547 | // mLeftFrame->show(); | 3556 | // mLeftFrame->show(); |
3548 | // emit calendarViewExpanded( false ); | 3557 | // emit calendarViewExpanded( false ); |
3549 | // } else { | 3558 | // } else { |
3550 | // mLeftFrame->hide(); | 3559 | // mLeftFrame->hide(); |
3551 | // emit calendarViewExpanded( true ); | 3560 | // emit calendarViewExpanded( true ); |
3552 | // } | 3561 | // } |
3553 | 3562 | ||
3554 | globalFlagBlockAgenda = 1; | 3563 | globalFlagBlockAgenda = 1; |
3555 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 3564 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
3556 | globalFlagBlockAgenda = 5; | 3565 | globalFlagBlockAgenda = 5; |
3557 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 3566 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
3558 | //mViewManager->showView( 0, true ); | 3567 | //mViewManager->showView( 0, true ); |
3559 | } | 3568 | } |
3560 | 3569 | ||
3561 | void CalendarView::calendarModified( bool modified, Calendar * ) | 3570 | void CalendarView::calendarModified( bool modified, Calendar * ) |
3562 | { | 3571 | { |
3563 | setModified( modified ); | 3572 | setModified( modified ); |
3564 | } | 3573 | } |
3565 | 3574 | ||
3566 | Todo *CalendarView::selectedTodo() | 3575 | Todo *CalendarView::selectedTodo() |
3567 | { | 3576 | { |
3568 | Incidence *incidence = currentSelection(); | 3577 | Incidence *incidence = currentSelection(); |
3569 | if ( incidence && incidence->type() == "Todo" ) { | 3578 | if ( incidence && incidence->type() == "Todo" ) { |
3570 | return static_cast<Todo *>( incidence ); | 3579 | return static_cast<Todo *>( incidence ); |
3571 | } | 3580 | } |
3572 | 3581 | ||
3573 | incidence = mTodoList->selectedIncidences().first(); | 3582 | incidence = mTodoList->selectedIncidences().first(); |
3574 | if ( incidence && incidence->type() == "Todo" ) { | 3583 | if ( incidence && incidence->type() == "Todo" ) { |
3575 | return static_cast<Todo *>( incidence ); | 3584 | return static_cast<Todo *>( incidence ); |
3576 | } | 3585 | } |
3577 | 3586 | ||
3578 | return 0; | 3587 | return 0; |
3579 | } | 3588 | } |
3580 | 3589 | ||
3581 | void CalendarView::dialogClosing(Incidence *in) | 3590 | void CalendarView::dialogClosing(Incidence *in) |
3582 | { | 3591 | { |
3583 | // mDialogList.remove(in); | 3592 | // mDialogList.remove(in); |
3584 | } | 3593 | } |
3585 | 3594 | ||
3586 | void CalendarView::showIncidence() | 3595 | void CalendarView::showIncidence() |
3587 | { | 3596 | { |
3588 | Incidence *incidence = currentSelection(); | 3597 | Incidence *incidence = currentSelection(); |
3589 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3598 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3590 | if ( incidence ) { | 3599 | if ( incidence ) { |
3591 | ShowIncidenceVisitor v; | 3600 | ShowIncidenceVisitor v; |
3592 | v.act( incidence, this ); | 3601 | v.act( incidence, this ); |
3593 | } | 3602 | } |
3594 | } | 3603 | } |
3595 | void CalendarView::editIncidenceDescription() | 3604 | void CalendarView::editIncidenceDescription() |
3596 | { | 3605 | { |
3597 | mFlagEditDescription = true; | 3606 | mFlagEditDescription = true; |
3598 | editIncidence(); | 3607 | editIncidence(); |
3599 | mFlagEditDescription = false; | 3608 | mFlagEditDescription = false; |
3600 | } | 3609 | } |
3601 | void CalendarView::editIncidence() | 3610 | void CalendarView::editIncidence() |
3602 | { | 3611 | { |
3603 | // qDebug("editIncidence() "); | 3612 | // qDebug("editIncidence() "); |
3604 | Incidence *incidence = currentSelection(); | 3613 | Incidence *incidence = currentSelection(); |
3605 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3614 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3606 | if ( incidence ) { | 3615 | if ( incidence ) { |
3607 | EditIncidenceVisitor v; | 3616 | EditIncidenceVisitor v; |
3608 | v.act( incidence, this ); | 3617 | v.act( incidence, this ); |
3609 | } | 3618 | } |
3610 | } | 3619 | } |
3611 | 3620 | ||
3612 | void CalendarView::deleteIncidence() | 3621 | void CalendarView::deleteIncidence() |
3613 | { | 3622 | { |
3614 | Incidence *incidence = currentSelection(); | 3623 | Incidence *incidence = currentSelection(); |
3615 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3624 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3616 | if ( incidence ) { | 3625 | if ( incidence ) { |
3617 | deleteIncidence(incidence); | 3626 | deleteIncidence(incidence); |
3618 | } | 3627 | } |
3619 | } | 3628 | } |
3620 | 3629 | ||
3621 | void CalendarView::showIncidence(Incidence *incidence) | 3630 | void CalendarView::showIncidence(Incidence *incidence) |
3622 | { | 3631 | { |
3623 | if ( incidence ) { | 3632 | if ( incidence ) { |
3624 | ShowIncidenceVisitor v; | 3633 | ShowIncidenceVisitor v; |
3625 | v.act( incidence, this ); | 3634 | v.act( incidence, this ); |
3626 | } | 3635 | } |
3627 | } | 3636 | } |
3628 | 3637 | ||
3629 | void CalendarView::editIncidence(Incidence *incidence) | 3638 | void CalendarView::editIncidence(Incidence *incidence) |
3630 | { | 3639 | { |
3631 | if ( incidence ) { | 3640 | if ( incidence ) { |
3632 | 3641 | ||
3633 | EditIncidenceVisitor v; | 3642 | EditIncidenceVisitor v; |
3634 | v.act( incidence, this ); | 3643 | v.act( incidence, this ); |
3635 | 3644 | ||
3636 | } | 3645 | } |
3637 | } | 3646 | } |
3638 | 3647 | ||
3639 | void CalendarView::deleteIncidence(Incidence *incidence) | 3648 | void CalendarView::deleteIncidence(Incidence *incidence) |
3640 | { | 3649 | { |
3641 | //qDebug(" CalendarView::deleteIncidence "); | 3650 | //qDebug(" CalendarView::deleteIncidence "); |
3642 | if ( incidence ) { | 3651 | if ( incidence ) { |
3643 | DeleteIncidenceVisitor v; | 3652 | DeleteIncidenceVisitor v; |
3644 | v.act( incidence, this ); | 3653 | v.act( incidence, this ); |
3645 | } | 3654 | } |
3646 | } | 3655 | } |
3647 | 3656 | ||
3648 | 3657 | ||
3649 | void CalendarView::lookForOutgoingMessages() | 3658 | void CalendarView::lookForOutgoingMessages() |
3650 | { | 3659 | { |
3651 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 3660 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
3652 | ogd->loadMessages(); | 3661 | ogd->loadMessages(); |
3653 | } | 3662 | } |
3654 | 3663 | ||
3655 | void CalendarView::lookForIncomingMessages() | 3664 | void CalendarView::lookForIncomingMessages() |
3656 | { | 3665 | { |
3657 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 3666 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
3658 | icd->retrieve(); | 3667 | icd->retrieve(); |
3659 | } | 3668 | } |
3660 | 3669 | ||
3661 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 3670 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
3662 | { | 3671 | { |
3663 | bool deleteTodo = true; | 3672 | bool deleteTodo = true; |
3664 | QPtrList<Incidence> subTodos; | 3673 | QPtrList<Incidence> subTodos; |
3665 | Incidence *aTodo; | 3674 | Incidence *aTodo; |
3666 | subTodos = t->relations(); | 3675 | subTodos = t->relations(); |
3667 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 3676 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
3668 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 3677 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
3669 | deleteTodo = false; | 3678 | deleteTodo = false; |
3670 | } | 3679 | } |
3671 | if ( deleteTodo ) { | 3680 | if ( deleteTodo ) { |
3672 | if ( t->isCompleted() ) { | 3681 | if ( t->isCompleted() ) { |
3673 | checkExternalId( t ); | 3682 | checkExternalId( t ); |
3674 | mCalendar->deleteTodo( t ); | 3683 | mCalendar->deleteTodo( t ); |
3675 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 3684 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
3676 | } | 3685 | } |
3677 | else | 3686 | else |
3678 | deleteTodo = false; | 3687 | deleteTodo = false; |
3679 | } | 3688 | } |
3680 | return deleteTodo; | 3689 | return deleteTodo; |
3681 | 3690 | ||
3682 | } | 3691 | } |
3683 | void CalendarView::purgeCompleted() | 3692 | void CalendarView::purgeCompleted() |
3684 | { | 3693 | { |
3685 | int result = KMessageBox::warningContinueCancel(this, | 3694 | int result = KMessageBox::warningContinueCancel(this, |
3686 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); | 3695 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); |
3687 | 3696 | ||
3688 | if (result == KMessageBox::Continue) { | 3697 | if (result == KMessageBox::Continue) { |
3689 | 3698 | ||
3690 | QPtrList<Todo> todoCal; | 3699 | QPtrList<Todo> todoCal; |
3691 | QPtrList<Todo> rootTodos; | 3700 | QPtrList<Todo> rootTodos; |
3692 | //QPtrList<Incidence> rel; | 3701 | //QPtrList<Incidence> rel; |
3693 | Todo *aTodo;//, *rTodo; | 3702 | Todo *aTodo;//, *rTodo; |
3694 | Incidence *rIncidence; | 3703 | Incidence *rIncidence; |
3695 | bool childDelete = false; | 3704 | bool childDelete = false; |
3696 | bool deletedOne = true; | 3705 | bool deletedOne = true; |
3697 | todoCal = calendar()->todos(); | 3706 | todoCal = calendar()->todos(); |
3698 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 3707 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
3699 | if ( !aTodo->relatedTo() ) | 3708 | if ( !aTodo->relatedTo() ) |
3700 | rootTodos.append( aTodo ); | 3709 | rootTodos.append( aTodo ); |
3701 | } | 3710 | } |
3702 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 3711 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
3703 | removeCompletedSubTodos( aTodo ); | 3712 | removeCompletedSubTodos( aTodo ); |
3704 | } | 3713 | } |
3705 | 3714 | ||
3706 | updateView(); | 3715 | updateView(); |
3707 | } | 3716 | } |
3708 | } | 3717 | } |
3709 | 3718 | ||
3710 | void CalendarView::slotCalendarChanged() | 3719 | void CalendarView::slotCalendarChanged() |
3711 | { | 3720 | { |
3712 | ; | 3721 | ; |
3713 | } | 3722 | } |
3714 | 3723 | ||
3715 | NavigatorBar *CalendarView::navigatorBar() | 3724 | NavigatorBar *CalendarView::navigatorBar() |
3716 | { | 3725 | { |
3717 | return mNavigatorBar; | 3726 | return mNavigatorBar; |
3718 | } | 3727 | } |
3719 | 3728 | ||
3720 | 3729 | ||
3721 | 3730 | ||
3722 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 3731 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
3723 | { | 3732 | { |
3724 | //qDebug(" alendarView::keyPressEvent "); | 3733 | //qDebug(" alendarView::keyPressEvent "); |
3725 | e->ignore(); | 3734 | e->ignore(); |
3726 | } | 3735 | } |
3727 | 3736 | ||
3728 | 3737 | ||
3729 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 3738 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
3730 | { | 3739 | { |
3731 | // mSyncManager = manager; | 3740 | // mSyncManager = manager; |
3732 | mSyncKDE = false; | 3741 | mSyncKDE = false; |
3733 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 3742 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
3734 | qDebug("SyncKDE request detected!"); | 3743 | qDebug("SyncKDE request detected!"); |
3735 | mSyncKDE = true; | 3744 | mSyncKDE = true; |
3736 | } | 3745 | } |
3737 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3746 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3738 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3747 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3739 | return syncCalendar( filename, mode ); | 3748 | return syncCalendar( filename, mode ); |
3740 | } | 3749 | } |
3741 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 3750 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
3742 | { | 3751 | { |
3743 | mSyncKDE = false; | 3752 | mSyncKDE = false; |
3744 | //mSyncManager = manager; | 3753 | //mSyncManager = manager; |
3745 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3754 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3746 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3755 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3747 | if ( resource == "sharp" ) | 3756 | if ( resource == "sharp" ) |
3748 | syncExternal( 0 ); | 3757 | syncExternal( 0 ); |
3749 | if ( resource == "phone" ) | 3758 | if ( resource == "phone" ) |
3750 | syncExternal( 1 ); | 3759 | syncExternal( 1 ); |
3751 | // pending setmodified | 3760 | // pending setmodified |
3752 | return true; | 3761 | return true; |
3753 | } | 3762 | } |
3754 | void CalendarView::setSyncManager(KSyncManager* manager) | 3763 | void CalendarView::setSyncManager(KSyncManager* manager) |
3755 | { | 3764 | { |
3756 | mSyncManager = manager; | 3765 | mSyncManager = manager; |
3757 | } | 3766 | } |
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index 55ac6d4..5a9ef0e 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp | |||
@@ -1,603 +1,603 @@ | |||
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 <klocale.h> | 22 | #include <klocale.h> |
23 | #include <kdebug.h> | 23 | #include <kdebug.h> |
24 | 24 | ||
25 | #include "calformat.h" | 25 | #include "calformat.h" |
26 | 26 | ||
27 | #include "incidence.h" | 27 | #include "incidence.h" |
28 | #include "todo.h" | 28 | #include "todo.h" |
29 | 29 | ||
30 | using namespace KCal; | 30 | using namespace KCal; |
31 | 31 | ||
32 | Incidence::Incidence() : | 32 | Incidence::Incidence() : |
33 | IncidenceBase(), | 33 | IncidenceBase(), |
34 | mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3) | 34 | mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3) |
35 | { | 35 | { |
36 | mRecurrence = new Recurrence(this); | 36 | mRecurrence = new Recurrence(this); |
37 | mCancelled = false; | 37 | mCancelled = false; |
38 | recreate(); | 38 | recreate(); |
39 | mHasStartDate = true; | 39 | mHasStartDate = true; |
40 | mAlarms.setAutoDelete(true); | 40 | mAlarms.setAutoDelete(true); |
41 | mAttachments.setAutoDelete(true); | 41 | mAttachments.setAutoDelete(true); |
42 | } | 42 | } |
43 | 43 | ||
44 | Incidence::Incidence( const Incidence &i ) : IncidenceBase( i ) | 44 | Incidence::Incidence( const Incidence &i ) : IncidenceBase( i ) |
45 | { | 45 | { |
46 | // TODO: reenable attributes currently commented out. | 46 | // TODO: reenable attributes currently commented out. |
47 | mRevision = i.mRevision; | 47 | mRevision = i.mRevision; |
48 | mCreated = i.mCreated; | 48 | mCreated = i.mCreated; |
49 | mDescription = i.mDescription; | 49 | mDescription = i.mDescription; |
50 | mSummary = i.mSummary; | 50 | mSummary = i.mSummary; |
51 | mCategories = i.mCategories; | 51 | mCategories = i.mCategories; |
52 | // Incidence *mRelatedTo; Incidence *mRelatedTo; | 52 | // Incidence *mRelatedTo; Incidence *mRelatedTo; |
53 | mRelatedTo = 0; | 53 | mRelatedTo = 0; |
54 | mRelatedToUid = i.mRelatedToUid; | 54 | mRelatedToUid = i.mRelatedToUid; |
55 | // QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations; | 55 | // QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations; |
56 | mExDates = i.mExDates; | 56 | mExDates = i.mExDates; |
57 | mAttachments = i.mAttachments; | 57 | mAttachments = i.mAttachments; |
58 | mResources = i.mResources; | 58 | mResources = i.mResources; |
59 | mSecrecy = i.mSecrecy; | 59 | mSecrecy = i.mSecrecy; |
60 | mPriority = i.mPriority; | 60 | mPriority = i.mPriority; |
61 | mLocation = i.mLocation; | 61 | mLocation = i.mLocation; |
62 | mCancelled = i.mCancelled; | 62 | mCancelled = i.mCancelled; |
63 | mHasStartDate = i.mHasStartDate; | 63 | mHasStartDate = i.mHasStartDate; |
64 | QPtrListIterator<Alarm> it( i.mAlarms ); | 64 | QPtrListIterator<Alarm> it( i.mAlarms ); |
65 | const Alarm *a; | 65 | const Alarm *a; |
66 | while( (a = it.current()) ) { | 66 | while( (a = it.current()) ) { |
67 | Alarm *b = new Alarm( *a ); | 67 | Alarm *b = new Alarm( *a ); |
68 | b->setParent( this ); | 68 | b->setParent( this ); |
69 | mAlarms.append( b ); | 69 | mAlarms.append( b ); |
70 | 70 | ||
71 | ++it; | 71 | ++it; |
72 | } | 72 | } |
73 | mAlarms.setAutoDelete(true); | 73 | mAlarms.setAutoDelete(true); |
74 | 74 | ||
75 | mRecurrence = new Recurrence( *(i.mRecurrence), this ); | 75 | mRecurrence = new Recurrence( *(i.mRecurrence), this ); |
76 | } | 76 | } |
77 | 77 | ||
78 | Incidence::~Incidence() | 78 | Incidence::~Incidence() |
79 | { | 79 | { |
80 | 80 | ||
81 | Incidence *ev; | 81 | Incidence *ev; |
82 | QPtrList<Incidence> Relations = relations(); | 82 | QPtrList<Incidence> Relations = relations(); |
83 | for (ev=Relations.first();ev;ev=Relations.next()) { | 83 | for (ev=Relations.first();ev;ev=Relations.next()) { |
84 | if (ev->relatedTo() == this) ev->setRelatedTo(0); | 84 | if (ev->relatedTo() == this) ev->setRelatedTo(0); |
85 | } | 85 | } |
86 | if (relatedTo()) relatedTo()->removeRelation(this); | 86 | if (relatedTo()) relatedTo()->removeRelation(this); |
87 | delete mRecurrence; | 87 | delete mRecurrence; |
88 | 88 | ||
89 | } | 89 | } |
90 | 90 | ||
91 | bool Incidence::cancelled() const | 91 | bool Incidence::cancelled() const |
92 | { | 92 | { |
93 | return mCancelled; | 93 | return mCancelled; |
94 | } | 94 | } |
95 | void Incidence::setCancelled( bool b ) | 95 | void Incidence::setCancelled( bool b ) |
96 | { | 96 | { |
97 | mCancelled = b; | 97 | mCancelled = b; |
98 | updated(); | 98 | updated(); |
99 | } | 99 | } |
100 | bool Incidence::hasStartDate() const | 100 | bool Incidence::hasStartDate() const |
101 | { | 101 | { |
102 | return mHasStartDate; | 102 | return mHasStartDate; |
103 | } | 103 | } |
104 | 104 | ||
105 | void Incidence::setHasStartDate(bool f) | 105 | void Incidence::setHasStartDate(bool f) |
106 | { | 106 | { |
107 | if (mReadOnly) return; | 107 | if (mReadOnly) return; |
108 | mHasStartDate = f; | 108 | mHasStartDate = f; |
109 | updated(); | 109 | updated(); |
110 | } | 110 | } |
111 | 111 | ||
112 | // A string comparison that considers that null and empty are the same | 112 | // A string comparison that considers that null and empty are the same |
113 | static bool stringCompare( const QString& s1, const QString& s2 ) | 113 | static bool stringCompare( const QString& s1, const QString& s2 ) |
114 | { | 114 | { |
115 | if ( s1.isEmpty() && s2.isEmpty() ) | 115 | if ( s1.isEmpty() && s2.isEmpty() ) |
116 | return true; | 116 | return true; |
117 | return s1 == s2; | 117 | return s1 == s2; |
118 | } | 118 | } |
119 | 119 | ||
120 | bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) | 120 | bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) |
121 | { | 121 | { |
122 | 122 | ||
123 | if( i1.alarms().count() != i2.alarms().count() ) { | 123 | if( i1.alarms().count() != i2.alarms().count() ) { |
124 | return false; // no need to check further | 124 | return false; // no need to check further |
125 | } | 125 | } |
126 | if ( i1.alarms().count() > 0 ) { | 126 | if ( i1.alarms().count() > 0 ) { |
127 | if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) | 127 | if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) |
128 | { | 128 | { |
129 | qDebug("alarm not equal "); | 129 | qDebug("alarm not equal "); |
130 | return false; | 130 | return false; |
131 | } | 131 | } |
132 | } | 132 | } |
133 | #if 0 | 133 | #if 0 |
134 | QPtrListIterator<Alarm> a1( i1.alarms() ); | 134 | QPtrListIterator<Alarm> a1( i1.alarms() ); |
135 | QPtrListIterator<Alarm> a2( i2.alarms() ); | 135 | QPtrListIterator<Alarm> a2( i2.alarms() ); |
136 | for( ; a1.current() && a2.current(); ++a1, ++a2 ) { | 136 | for( ; a1.current() && a2.current(); ++a1, ++a2 ) { |
137 | if( *a1.current() == *a2.current() ) { | 137 | if( *a1.current() == *a2.current() ) { |
138 | continue; | 138 | continue; |
139 | } | 139 | } |
140 | else { | 140 | else { |
141 | return false; | 141 | return false; |
142 | } | 142 | } |
143 | } | 143 | } |
144 | #endif | 144 | #endif |
145 | 145 | ||
146 | if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) ) | 146 | if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) ) |
147 | return false; | 147 | return false; |
148 | if ( i1.hasStartDate() == i2.hasStartDate() ) { | 148 | if ( i1.hasStartDate() == i2.hasStartDate() ) { |
149 | if ( i1.hasStartDate() ) { | 149 | if ( i1.hasStartDate() ) { |
150 | if ( i1.dtStart() != i2.dtStart() ) | 150 | if ( i1.dtStart() != i2.dtStart() ) |
151 | return false; | 151 | return false; |
152 | } | 152 | } |
153 | } else { | 153 | } else { |
154 | return false; | 154 | return false; |
155 | } | 155 | } |
156 | if (!( *i1.recurrence() == *i2.recurrence()) ) { | 156 | if (!( *i1.recurrence() == *i2.recurrence()) ) { |
157 | qDebug("recurrence is NOT equal "); | 157 | qDebug("recurrence is NOT equal "); |
158 | return false; | 158 | return false; |
159 | } | 159 | } |
160 | return | 160 | return |
161 | // i1.created() == i2.created() && | 161 | // i1.created() == i2.created() && |
162 | stringCompare( i1.description(), i2.description() ) && | 162 | stringCompare( i1.description(), i2.description() ) && |
163 | stringCompare( i1.summary(), i2.summary() ) && | 163 | stringCompare( i1.summary(), i2.summary() ) && |
164 | i1.categories() == i2.categories() && | 164 | i1.categories() == i2.categories() && |
165 | // no need to compare mRelatedTo | 165 | // no need to compare mRelatedTo |
166 | stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && | 166 | stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && |
167 | // i1.relations() == i2.relations() && | 167 | // i1.relations() == i2.relations() && |
168 | i1.exDates() == i2.exDates() && | 168 | i1.exDates() == i2.exDates() && |
169 | i1.attachments() == i2.attachments() && | 169 | i1.attachments() == i2.attachments() && |
170 | i1.resources() == i2.resources() && | 170 | i1.resources() == i2.resources() && |
171 | i1.secrecy() == i2.secrecy() && | 171 | i1.secrecy() == i2.secrecy() && |
172 | i1.priority() == i2.priority() && | 172 | i1.priority() == i2.priority() && |
173 | stringCompare( i1.location(), i2.location() ); | 173 | stringCompare( i1.location(), i2.location() ); |
174 | } | 174 | } |
175 | 175 | ||
176 | 176 | ||
177 | void Incidence::recreate() | 177 | void Incidence::recreate() |
178 | { | 178 | { |
179 | setCreated(QDateTime::currentDateTime()); | 179 | setCreated(QDateTime::currentDateTime()); |
180 | 180 | ||
181 | setUid(CalFormat::createUniqueId()); | 181 | setUid(CalFormat::createUniqueId()); |
182 | 182 | ||
183 | setRevision(0); | 183 | setRevision(0); |
184 | 184 | setIDStr( ":" ); | |
185 | setLastModified(QDateTime::currentDateTime()); | 185 | setLastModified(QDateTime::currentDateTime()); |
186 | } | 186 | } |
187 | 187 | ||
188 | void Incidence::setReadOnly( bool readOnly ) | 188 | void Incidence::setReadOnly( bool readOnly ) |
189 | { | 189 | { |
190 | IncidenceBase::setReadOnly( readOnly ); | 190 | IncidenceBase::setReadOnly( readOnly ); |
191 | recurrence()->setRecurReadOnly( readOnly); | 191 | recurrence()->setRecurReadOnly( readOnly); |
192 | } | 192 | } |
193 | 193 | ||
194 | void Incidence::setCreated(QDateTime created) | 194 | void Incidence::setCreated(QDateTime created) |
195 | { | 195 | { |
196 | if (mReadOnly) return; | 196 | if (mReadOnly) return; |
197 | mCreated = getEvenTime(created); | 197 | mCreated = getEvenTime(created); |
198 | } | 198 | } |
199 | 199 | ||
200 | QDateTime Incidence::created() const | 200 | QDateTime Incidence::created() const |
201 | { | 201 | { |
202 | return mCreated; | 202 | return mCreated; |
203 | } | 203 | } |
204 | 204 | ||
205 | void Incidence::setRevision(int rev) | 205 | void Incidence::setRevision(int rev) |
206 | { | 206 | { |
207 | if (mReadOnly) return; | 207 | if (mReadOnly) return; |
208 | mRevision = rev; | 208 | mRevision = rev; |
209 | 209 | ||
210 | updated(); | 210 | updated(); |
211 | } | 211 | } |
212 | 212 | ||
213 | int Incidence::revision() const | 213 | int Incidence::revision() const |
214 | { | 214 | { |
215 | return mRevision; | 215 | return mRevision; |
216 | } | 216 | } |
217 | 217 | ||
218 | void Incidence::setDtStart(const QDateTime &dtStart) | 218 | void Incidence::setDtStart(const QDateTime &dtStart) |
219 | { | 219 | { |
220 | 220 | ||
221 | QDateTime dt = getEvenTime(dtStart); | 221 | QDateTime dt = getEvenTime(dtStart); |
222 | recurrence()->setRecurStart( dt); | 222 | recurrence()->setRecurStart( dt); |
223 | IncidenceBase::setDtStart( dt ); | 223 | IncidenceBase::setDtStart( dt ); |
224 | } | 224 | } |
225 | 225 | ||
226 | void Incidence::setDescription(const QString &description) | 226 | void Incidence::setDescription(const QString &description) |
227 | { | 227 | { |
228 | if (mReadOnly) return; | 228 | if (mReadOnly) return; |
229 | mDescription = description; | 229 | mDescription = description; |
230 | updated(); | 230 | updated(); |
231 | } | 231 | } |
232 | 232 | ||
233 | QString Incidence::description() const | 233 | QString Incidence::description() const |
234 | { | 234 | { |
235 | return mDescription; | 235 | return mDescription; |
236 | } | 236 | } |
237 | 237 | ||
238 | 238 | ||
239 | void Incidence::setSummary(const QString &summary) | 239 | void Incidence::setSummary(const QString &summary) |
240 | { | 240 | { |
241 | if (mReadOnly) return; | 241 | if (mReadOnly) return; |
242 | mSummary = summary; | 242 | mSummary = summary; |
243 | updated(); | 243 | updated(); |
244 | } | 244 | } |
245 | 245 | ||
246 | QString Incidence::summary() const | 246 | QString Incidence::summary() const |
247 | { | 247 | { |
248 | return mSummary; | 248 | return mSummary; |
249 | } | 249 | } |
250 | 250 | ||
251 | void Incidence::setCategories(const QStringList &categories) | 251 | void Incidence::setCategories(const QStringList &categories) |
252 | { | 252 | { |
253 | if (mReadOnly) return; | 253 | if (mReadOnly) return; |
254 | mCategories = categories; | 254 | mCategories = categories; |
255 | updated(); | 255 | updated(); |
256 | } | 256 | } |
257 | 257 | ||
258 | // TODO: remove setCategories(QString) function | 258 | // TODO: remove setCategories(QString) function |
259 | void Incidence::setCategories(const QString &catStr) | 259 | void Incidence::setCategories(const QString &catStr) |
260 | { | 260 | { |
261 | if (mReadOnly) return; | 261 | if (mReadOnly) return; |
262 | mCategories.clear(); | 262 | mCategories.clear(); |
263 | 263 | ||
264 | if (catStr.isEmpty()) return; | 264 | if (catStr.isEmpty()) return; |
265 | 265 | ||
266 | mCategories = QStringList::split(",",catStr); | 266 | mCategories = QStringList::split(",",catStr); |
267 | 267 | ||
268 | QStringList::Iterator it; | 268 | QStringList::Iterator it; |
269 | for(it = mCategories.begin();it != mCategories.end(); ++it) { | 269 | for(it = mCategories.begin();it != mCategories.end(); ++it) { |
270 | *it = (*it).stripWhiteSpace(); | 270 | *it = (*it).stripWhiteSpace(); |
271 | } | 271 | } |
272 | 272 | ||
273 | updated(); | 273 | updated(); |
274 | } | 274 | } |
275 | 275 | ||
276 | QStringList Incidence::categories() const | 276 | QStringList Incidence::categories() const |
277 | { | 277 | { |
278 | return mCategories; | 278 | return mCategories; |
279 | } | 279 | } |
280 | 280 | ||
281 | QString Incidence::categoriesStr() | 281 | QString Incidence::categoriesStr() |
282 | { | 282 | { |
283 | return mCategories.join(","); | 283 | return mCategories.join(","); |
284 | } | 284 | } |
285 | 285 | ||
286 | void Incidence::setRelatedToUid(const QString &relatedToUid) | 286 | void Incidence::setRelatedToUid(const QString &relatedToUid) |
287 | { | 287 | { |
288 | if (mReadOnly) return; | 288 | if (mReadOnly) return; |
289 | mRelatedToUid = relatedToUid; | 289 | mRelatedToUid = relatedToUid; |
290 | } | 290 | } |
291 | 291 | ||
292 | QString Incidence::relatedToUid() const | 292 | QString Incidence::relatedToUid() const |
293 | { | 293 | { |
294 | return mRelatedToUid; | 294 | return mRelatedToUid; |
295 | } | 295 | } |
296 | 296 | ||
297 | void Incidence::setRelatedTo(Incidence *relatedTo) | 297 | void Incidence::setRelatedTo(Incidence *relatedTo) |
298 | { | 298 | { |
299 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); | 299 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); |
300 | //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); | 300 | //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); |
301 | if (mReadOnly || mRelatedTo == relatedTo) return; | 301 | if (mReadOnly || mRelatedTo == relatedTo) return; |
302 | if(mRelatedTo) { | 302 | if(mRelatedTo) { |
303 | // updated(); | 303 | // updated(); |
304 | mRelatedTo->removeRelation(this); | 304 | mRelatedTo->removeRelation(this); |
305 | } | 305 | } |
306 | mRelatedTo = relatedTo; | 306 | mRelatedTo = relatedTo; |
307 | if (mRelatedTo) mRelatedTo->addRelation(this); | 307 | if (mRelatedTo) mRelatedTo->addRelation(this); |
308 | } | 308 | } |
309 | 309 | ||
310 | Incidence *Incidence::relatedTo() const | 310 | Incidence *Incidence::relatedTo() const |
311 | { | 311 | { |
312 | return mRelatedTo; | 312 | return mRelatedTo; |
313 | } | 313 | } |
314 | 314 | ||
315 | QPtrList<Incidence> Incidence::relations() const | 315 | QPtrList<Incidence> Incidence::relations() const |
316 | { | 316 | { |
317 | return mRelations; | 317 | return mRelations; |
318 | } | 318 | } |
319 | 319 | ||
320 | void Incidence::addRelation(Incidence *event) | 320 | void Incidence::addRelation(Incidence *event) |
321 | { | 321 | { |
322 | if( mRelations.findRef( event ) == -1 ) { | 322 | if( mRelations.findRef( event ) == -1 ) { |
323 | mRelations.append(event); | 323 | mRelations.append(event); |
324 | //updated(); | 324 | //updated(); |
325 | } | 325 | } |
326 | } | 326 | } |
327 | 327 | ||
328 | void Incidence::removeRelation(Incidence *event) | 328 | void Incidence::removeRelation(Incidence *event) |
329 | { | 329 | { |
330 | 330 | ||
331 | mRelations.removeRef(event); | 331 | mRelations.removeRef(event); |
332 | 332 | ||
333 | // if (event->getRelatedTo() == this) event->setRelatedTo(0); | 333 | // if (event->getRelatedTo() == this) event->setRelatedTo(0); |
334 | } | 334 | } |
335 | 335 | ||
336 | bool Incidence::recursOn(const QDate &qd) const | 336 | bool Incidence::recursOn(const QDate &qd) const |
337 | { | 337 | { |
338 | if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; | 338 | if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; |
339 | else return false; | 339 | else return false; |
340 | } | 340 | } |
341 | 341 | ||
342 | void Incidence::setExDates(const DateList &exDates) | 342 | void Incidence::setExDates(const DateList &exDates) |
343 | { | 343 | { |
344 | if (mReadOnly) return; | 344 | if (mReadOnly) return; |
345 | mExDates = exDates; | 345 | mExDates = exDates; |
346 | 346 | ||
347 | recurrence()->setRecurExDatesCount(mExDates.count()); | 347 | recurrence()->setRecurExDatesCount(mExDates.count()); |
348 | 348 | ||
349 | updated(); | 349 | updated(); |
350 | } | 350 | } |
351 | 351 | ||
352 | void Incidence::addExDate(const QDate &date) | 352 | void Incidence::addExDate(const QDate &date) |
353 | { | 353 | { |
354 | if (mReadOnly) return; | 354 | if (mReadOnly) return; |
355 | mExDates.append(date); | 355 | mExDates.append(date); |
356 | 356 | ||
357 | recurrence()->setRecurExDatesCount(mExDates.count()); | 357 | recurrence()->setRecurExDatesCount(mExDates.count()); |
358 | 358 | ||
359 | updated(); | 359 | updated(); |
360 | } | 360 | } |
361 | 361 | ||
362 | DateList Incidence::exDates() const | 362 | DateList Incidence::exDates() const |
363 | { | 363 | { |
364 | return mExDates; | 364 | return mExDates; |
365 | } | 365 | } |
366 | 366 | ||
367 | bool Incidence::isException(const QDate &date) const | 367 | bool Incidence::isException(const QDate &date) const |
368 | { | 368 | { |
369 | DateList::ConstIterator it; | 369 | DateList::ConstIterator it; |
370 | for( it = mExDates.begin(); it != mExDates.end(); ++it ) { | 370 | for( it = mExDates.begin(); it != mExDates.end(); ++it ) { |
371 | if ( (*it) == date ) { | 371 | if ( (*it) == date ) { |
372 | return true; | 372 | return true; |
373 | } | 373 | } |
374 | } | 374 | } |
375 | 375 | ||
376 | return false; | 376 | return false; |
377 | } | 377 | } |
378 | 378 | ||
379 | void Incidence::addAttachment(Attachment *attachment) | 379 | void Incidence::addAttachment(Attachment *attachment) |
380 | { | 380 | { |
381 | if (mReadOnly || !attachment) return; | 381 | if (mReadOnly || !attachment) return; |
382 | mAttachments.append(attachment); | 382 | mAttachments.append(attachment); |
383 | updated(); | 383 | updated(); |
384 | } | 384 | } |
385 | 385 | ||
386 | void Incidence::deleteAttachment(Attachment *attachment) | 386 | void Incidence::deleteAttachment(Attachment *attachment) |
387 | { | 387 | { |
388 | mAttachments.removeRef(attachment); | 388 | mAttachments.removeRef(attachment); |
389 | } | 389 | } |
390 | 390 | ||
391 | void Incidence::deleteAttachments(const QString& mime) | 391 | void Incidence::deleteAttachments(const QString& mime) |
392 | { | 392 | { |
393 | Attachment *at = mAttachments.first(); | 393 | Attachment *at = mAttachments.first(); |
394 | while (at) { | 394 | while (at) { |
395 | if (at->mimeType() == mime) | 395 | if (at->mimeType() == mime) |
396 | mAttachments.remove(); | 396 | mAttachments.remove(); |
397 | else | 397 | else |
398 | at = mAttachments.next(); | 398 | at = mAttachments.next(); |
399 | } | 399 | } |
400 | } | 400 | } |
401 | 401 | ||
402 | QPtrList<Attachment> Incidence::attachments() const | 402 | QPtrList<Attachment> Incidence::attachments() const |
403 | { | 403 | { |
404 | return mAttachments; | 404 | return mAttachments; |
405 | } | 405 | } |
406 | 406 | ||
407 | QPtrList<Attachment> Incidence::attachments(const QString& mime) const | 407 | QPtrList<Attachment> Incidence::attachments(const QString& mime) const |
408 | { | 408 | { |
409 | QPtrList<Attachment> attachments; | 409 | QPtrList<Attachment> attachments; |
410 | QPtrListIterator<Attachment> it( mAttachments ); | 410 | QPtrListIterator<Attachment> it( mAttachments ); |
411 | Attachment *at; | 411 | Attachment *at; |
412 | while ( (at = it.current()) ) { | 412 | while ( (at = it.current()) ) { |
413 | if (at->mimeType() == mime) | 413 | if (at->mimeType() == mime) |
414 | attachments.append(at); | 414 | attachments.append(at); |
415 | ++it; | 415 | ++it; |
416 | } | 416 | } |
417 | 417 | ||
418 | return attachments; | 418 | return attachments; |
419 | } | 419 | } |
420 | 420 | ||
421 | void Incidence::setResources(const QStringList &resources) | 421 | void Incidence::setResources(const QStringList &resources) |
422 | { | 422 | { |
423 | if (mReadOnly) return; | 423 | if (mReadOnly) return; |
424 | mResources = resources; | 424 | mResources = resources; |
425 | updated(); | 425 | updated(); |
426 | } | 426 | } |
427 | 427 | ||
428 | QStringList Incidence::resources() const | 428 | QStringList Incidence::resources() const |
429 | { | 429 | { |
430 | return mResources; | 430 | return mResources; |
431 | } | 431 | } |
432 | 432 | ||
433 | 433 | ||
434 | void Incidence::setPriority(int priority) | 434 | void Incidence::setPriority(int priority) |
435 | { | 435 | { |
436 | if (mReadOnly) return; | 436 | if (mReadOnly) return; |
437 | mPriority = priority; | 437 | mPriority = priority; |
438 | updated(); | 438 | updated(); |
439 | } | 439 | } |
440 | 440 | ||
441 | int Incidence::priority() const | 441 | int Incidence::priority() const |
442 | { | 442 | { |
443 | return mPriority; | 443 | return mPriority; |
444 | } | 444 | } |
445 | 445 | ||
446 | void Incidence::setSecrecy(int sec) | 446 | void Incidence::setSecrecy(int sec) |
447 | { | 447 | { |
448 | if (mReadOnly) return; | 448 | if (mReadOnly) return; |
449 | mSecrecy = sec; | 449 | mSecrecy = sec; |
450 | updated(); | 450 | updated(); |
451 | } | 451 | } |
452 | 452 | ||
453 | int Incidence::secrecy() const | 453 | int Incidence::secrecy() const |
454 | { | 454 | { |
455 | return mSecrecy; | 455 | return mSecrecy; |
456 | } | 456 | } |
457 | 457 | ||
458 | QString Incidence::secrecyStr() const | 458 | QString Incidence::secrecyStr() const |
459 | { | 459 | { |
460 | return secrecyName(mSecrecy); | 460 | return secrecyName(mSecrecy); |
461 | } | 461 | } |
462 | 462 | ||
463 | QString Incidence::secrecyName(int secrecy) | 463 | QString Incidence::secrecyName(int secrecy) |
464 | { | 464 | { |
465 | switch (secrecy) { | 465 | switch (secrecy) { |
466 | case SecrecyPublic: | 466 | case SecrecyPublic: |
467 | return i18n("Public"); | 467 | return i18n("Public"); |
468 | break; | 468 | break; |
469 | case SecrecyPrivate: | 469 | case SecrecyPrivate: |
470 | return i18n("Private"); | 470 | return i18n("Private"); |
471 | break; | 471 | break; |
472 | case SecrecyConfidential: | 472 | case SecrecyConfidential: |
473 | return i18n("Confidential"); | 473 | return i18n("Confidential"); |
474 | break; | 474 | break; |
475 | default: | 475 | default: |
476 | return i18n("Undefined"); | 476 | return i18n("Undefined"); |
477 | break; | 477 | break; |
478 | } | 478 | } |
479 | } | 479 | } |
480 | 480 | ||
481 | QStringList Incidence::secrecyList() | 481 | QStringList Incidence::secrecyList() |
482 | { | 482 | { |
483 | QStringList list; | 483 | QStringList list; |
484 | list << secrecyName(SecrecyPublic); | 484 | list << secrecyName(SecrecyPublic); |
485 | list << secrecyName(SecrecyPrivate); | 485 | list << secrecyName(SecrecyPrivate); |
486 | list << secrecyName(SecrecyConfidential); | 486 | list << secrecyName(SecrecyConfidential); |
487 | 487 | ||
488 | return list; | 488 | return list; |
489 | } | 489 | } |
490 | 490 | ||
491 | 491 | ||
492 | QPtrList<Alarm> Incidence::alarms() const | 492 | QPtrList<Alarm> Incidence::alarms() const |
493 | { | 493 | { |
494 | return mAlarms; | 494 | return mAlarms; |
495 | } | 495 | } |
496 | 496 | ||
497 | Alarm* Incidence::newAlarm() | 497 | Alarm* Incidence::newAlarm() |
498 | { | 498 | { |
499 | Alarm* alarm = new Alarm(this); | 499 | Alarm* alarm = new Alarm(this); |
500 | mAlarms.append(alarm); | 500 | mAlarms.append(alarm); |
501 | // updated(); | 501 | // updated(); |
502 | return alarm; | 502 | return alarm; |
503 | } | 503 | } |
504 | 504 | ||
505 | void Incidence::addAlarm(Alarm *alarm) | 505 | void Incidence::addAlarm(Alarm *alarm) |
506 | { | 506 | { |
507 | mAlarms.append(alarm); | 507 | mAlarms.append(alarm); |
508 | updated(); | 508 | updated(); |
509 | } | 509 | } |
510 | 510 | ||
511 | void Incidence::removeAlarm(Alarm *alarm) | 511 | void Incidence::removeAlarm(Alarm *alarm) |
512 | { | 512 | { |
513 | mAlarms.removeRef(alarm); | 513 | mAlarms.removeRef(alarm); |
514 | updated(); | 514 | updated(); |
515 | } | 515 | } |
516 | 516 | ||
517 | void Incidence::clearAlarms() | 517 | void Incidence::clearAlarms() |
518 | { | 518 | { |
519 | mAlarms.clear(); | 519 | mAlarms.clear(); |
520 | updated(); | 520 | updated(); |
521 | } | 521 | } |
522 | 522 | ||
523 | bool Incidence::isAlarmEnabled() const | 523 | bool Incidence::isAlarmEnabled() const |
524 | { | 524 | { |
525 | Alarm* alarm; | 525 | Alarm* alarm; |
526 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { | 526 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { |
527 | if (alarm->enabled()) | 527 | if (alarm->enabled()) |
528 | return true; | 528 | return true; |
529 | } | 529 | } |
530 | return false; | 530 | return false; |
531 | } | 531 | } |
532 | 532 | ||
533 | Recurrence *Incidence::recurrence() const | 533 | Recurrence *Incidence::recurrence() const |
534 | { | 534 | { |
535 | return mRecurrence; | 535 | return mRecurrence; |
536 | } | 536 | } |
537 | void Incidence::setRecurrence( Recurrence * r) | 537 | void Incidence::setRecurrence( Recurrence * r) |
538 | { | 538 | { |
539 | delete mRecurrence; | 539 | delete mRecurrence; |
540 | mRecurrence = r; | 540 | mRecurrence = r; |
541 | } | 541 | } |
542 | 542 | ||
543 | void Incidence::setLocation(const QString &location) | 543 | void Incidence::setLocation(const QString &location) |
544 | { | 544 | { |
545 | if (mReadOnly) return; | 545 | if (mReadOnly) return; |
546 | mLocation = location; | 546 | mLocation = location; |
547 | updated(); | 547 | updated(); |
548 | } | 548 | } |
549 | 549 | ||
550 | QString Incidence::location() const | 550 | QString Incidence::location() const |
551 | { | 551 | { |
552 | return mLocation; | 552 | return mLocation; |
553 | } | 553 | } |
554 | 554 | ||
555 | ushort Incidence::doesRecur() const | 555 | ushort Incidence::doesRecur() const |
556 | { | 556 | { |
557 | if ( mRecurrence ) return mRecurrence->doesRecur(); | 557 | if ( mRecurrence ) return mRecurrence->doesRecur(); |
558 | else return Recurrence::rNone; | 558 | else return Recurrence::rNone; |
559 | } | 559 | } |
560 | 560 | ||
561 | QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const | 561 | QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const |
562 | { | 562 | { |
563 | QDateTime incidenceStart = dt; | 563 | QDateTime incidenceStart = dt; |
564 | *ok = false; | 564 | *ok = false; |
565 | if ( doesRecur() ) { | 565 | if ( doesRecur() ) { |
566 | bool last; | 566 | bool last; |
567 | recurrence()->getPreviousDateTime( incidenceStart , &last ); | 567 | recurrence()->getPreviousDateTime( incidenceStart , &last ); |
568 | int count = 0; | 568 | int count = 0; |
569 | if ( !last ) { | 569 | if ( !last ) { |
570 | while ( !last ) { | 570 | while ( !last ) { |
571 | ++count; | 571 | ++count; |
572 | incidenceStart = recurrence()->getNextDateTime( incidenceStart, &last ); | 572 | incidenceStart = recurrence()->getNextDateTime( incidenceStart, &last ); |
573 | if ( recursOn( incidenceStart.date() ) ) { | 573 | if ( recursOn( incidenceStart.date() ) ) { |
574 | last = true; // exit while llop | 574 | last = true; // exit while llop |
575 | } else { | 575 | } else { |
576 | if ( last ) { // no alarm on last recurrence | 576 | if ( last ) { // no alarm on last recurrence |
577 | return QDateTime (); | 577 | return QDateTime (); |
578 | } | 578 | } |
579 | int year = incidenceStart.date().year(); | 579 | int year = incidenceStart.date().year(); |
580 | // workaround for bug in recurrence | 580 | // workaround for bug in recurrence |
581 | if ( count == 100 || year < 1980 || year > 5000 ) { | 581 | if ( count == 100 || year < 1980 || year > 5000 ) { |
582 | return QDateTime (); | 582 | return QDateTime (); |
583 | } | 583 | } |
584 | incidenceStart = incidenceStart.addSecs( 1 ); | 584 | incidenceStart = incidenceStart.addSecs( 1 ); |
585 | } | 585 | } |
586 | } | 586 | } |
587 | } else { | 587 | } else { |
588 | return QDateTime (); | 588 | return QDateTime (); |
589 | } | 589 | } |
590 | } else { | 590 | } else { |
591 | if ( hasStartDate () ) { | 591 | if ( hasStartDate () ) { |
592 | incidenceStart = dtStart(); | 592 | incidenceStart = dtStart(); |
593 | } | 593 | } |
594 | if ( type() =="Todo" ) { | 594 | if ( type() =="Todo" ) { |
595 | if ( ((Todo*)this)->hasDueDate() ) | 595 | if ( ((Todo*)this)->hasDueDate() ) |
596 | incidenceStart = ((Todo*)this)->dtDue(); | 596 | incidenceStart = ((Todo*)this)->dtDue(); |
597 | 597 | ||
598 | } | 598 | } |
599 | } | 599 | } |
600 | if ( incidenceStart > dt ) | 600 | if ( incidenceStart > dt ) |
601 | *ok = true; | 601 | *ok = true; |
602 | return incidenceStart; | 602 | return incidenceStart; |
603 | } | 603 | } |