author | zautrix <zautrix> | 2005-06-07 06:37:42 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-07 06:37:42 (UTC) |
commit | ff8af7ccdd6346bba1cb871c33931352bbafe40e (patch) (unidiff) | |
tree | 8a905fe8237cd1be7276b3c5f10479a9efdb6ee5 | |
parent | 79f58240bc34d20601abe3325e1dc7e76e1ebe39 (diff) | |
download | kdepimpi-ff8af7ccdd6346bba1cb871c33931352bbafe40e.zip kdepimpi-ff8af7ccdd6346bba1cb871c33931352bbafe40e.tar.gz kdepimpi-ff8af7ccdd6346bba1cb871c33931352bbafe40e.tar.bz2 |
fixx
-rw-r--r-- | kaddressbook/mainembedded.cpp | 1 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 3 |
2 files changed, 3 insertions, 1 deletions
diff --git a/kaddressbook/mainembedded.cpp b/kaddressbook/mainembedded.cpp index 50db377..93ba53c 100644 --- a/kaddressbook/mainembedded.cpp +++ b/kaddressbook/mainembedded.cpp | |||
@@ -1,119 +1,120 @@ | |||
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 | #include <qmessagebox.h> | 10 | #include <qmessagebox.h> |
11 | #include <stdlib.h> | 11 | #include <stdlib.h> |
12 | #endif | 12 | #endif |
13 | 13 | ||
14 | #include <qtextcodec.h> | 14 | #include <qtextcodec.h> |
15 | #include <kstandarddirs.h> | 15 | #include <kstandarddirs.h> |
16 | #include <qregexp.h> | 16 | #include <qregexp.h> |
17 | #include <kglobal.h> | 17 | #include <kglobal.h> |
18 | #include <stdio.h> | 18 | #include <stdio.h> |
19 | #include <qdir.h> | 19 | #include <qdir.h> |
20 | #include "kabprefs.h" | 20 | #include "kabprefs.h" |
21 | #include "kaddressbookmain.h" | 21 | #include "kaddressbookmain.h" |
22 | #include "externalapphandler.h" | 22 | #include "externalapphandler.h" |
23 | #include <libkdepim/kpimglobalprefs.h> | 23 | #include <libkdepim/kpimglobalprefs.h> |
24 | void dumpMissing(); | 24 | void dumpMissing(); |
25 | int main( int argc, char **argv ) | 25 | int main( int argc, char **argv ) |
26 | { | 26 | { |
27 | #ifndef DESKTOP_VERSION | 27 | #ifndef DESKTOP_VERSION |
28 | QPEApplication a( argc, argv ); | 28 | QPEApplication a( argc, argv ); |
29 | a.setKeepRunning (); | 29 | a.setKeepRunning (); |
30 | #else | 30 | #else |
31 | QApplication a( argc, argv ); | 31 | QApplication a( argc, argv ); |
32 | QApplication::setStyle( new QPlatinumStyle ()); | 32 | QApplication::setStyle( new QPlatinumStyle ()); |
33 | #ifdef _WIN32_ | 33 | #ifdef _WIN32_ |
34 | QString hdir ( getenv( "HOME") ); | 34 | QString hdir ( getenv( "HOME") ); |
35 | if ( hdir.isEmpty() ) { | 35 | if ( hdir.isEmpty() ) { |
36 | QString hd ("C:/" ); | 36 | QString hd ("C:/" ); |
37 | //QMessageBox::information(0,"hh",QDir::homeDirPath()+" xx" +hd ); | 37 | //QMessageBox::information(0,"hh",QDir::homeDirPath()+" xx" +hd ); |
38 | if ( QDir::homeDirPath().lower() == hd.lower() ) { | 38 | if ( QDir::homeDirPath().lower() == hd.lower() ) { |
39 | _putenv( "HOME=C:"); | 39 | _putenv( "HOME=C:"); |
40 | //QMessageBox::information(0,"hh",QString ( getenv( "HOME") ) ); | 40 | //QMessageBox::information(0,"hh",QString ( getenv( "HOME") ) ); |
41 | } | 41 | } |
42 | } else { | 42 | } else { |
43 | QDir app_dir; | 43 | QDir app_dir; |
44 | if ( !app_dir.exists(hdir) ) | 44 | if ( !app_dir.exists(hdir) ) |
45 | app_dir.mkdir (hdir); | 45 | app_dir.mkdir (hdir); |
46 | } | 46 | } |
47 | #endif | 47 | #endif |
48 | #endif | 48 | #endif |
49 | 49 | ||
50 | bool exitHelp = false; | 50 | bool exitHelp = false; |
51 | if ( argc > 1 ) { | 51 | if ( argc > 1 ) { |
52 | QString command = argv[1]; | 52 | QString command = argv[1]; |
53 | if ( command == "-help" ){ | 53 | if ( command == "-help" ){ |
54 | printf("KA/E command line commands:\n"); | 54 | printf("KA/E command line commands:\n"); |
55 | printf(" no command: Start KA/E in usual way\n"); | 55 | printf(" no command: Start KA/E in usual way\n"); |
56 | printf(" -help: This output\n"); | 56 | printf(" -help: This output\n"); |
57 | printf(" KA/E is exiting now. Bye!\n"); | 57 | printf(" KA/E is exiting now. Bye!\n"); |
58 | exitHelp = true; | 58 | exitHelp = true; |
59 | } | 59 | } |
60 | } | 60 | } |
61 | if ( ! exitHelp ) { | 61 | if ( ! exitHelp ) { |
62 | 62 | ||
63 | KGlobal::setAppName( "kaddressbook" ); | 63 | KGlobal::setAppName( "kaddressbook" ); |
64 | #ifndef DESKTOP_VERSION | 64 | #ifndef DESKTOP_VERSION |
65 | if ( QApplication::desktop()->width() > 320 ) | 65 | if ( QApplication::desktop()->width() > 320 ) |
66 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/"); | 66 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/"); |
67 | else | 67 | else |
68 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/"); | 68 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/"); |
69 | #else | 69 | #else |
70 | QString fileName ; | 70 | QString fileName ; |
71 | fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/"; | 71 | fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/"; |
72 | KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); | 72 | KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); |
73 | QApplication::addLibraryPath ( qApp->applicationDirPath () ); | 73 | QApplication::addLibraryPath ( qApp->applicationDirPath () ); |
74 | 74 | ||
75 | #endif | 75 | #endif |
76 | KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook"))); | 76 | KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook"))); |
77 | // init language | 77 | // init language |
78 | KPimGlobalPrefs::instance()->setGlobalConfig(); | 78 | KPimGlobalPrefs::instance()->setGlobalConfig(); |
79 | QApplication::setFont( KPimGlobalPrefs::instance()->mApplicationFont ); | 79 | QApplication::setFont( KPimGlobalPrefs::instance()->mApplicationFont ); |
80 | KAddressBookMain m ; | 80 | KAddressBookMain m ; |
81 | //US MainWindow m; | 81 | //US MainWindow m; |
82 | #ifndef DESKTOP_VERSION | 82 | #ifndef DESKTOP_VERSION |
83 | QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); | 83 | QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); |
84 | #endif | 84 | #endif |
85 | 85 | ||
86 | 86 | ||
87 | #ifndef DESKTOP_VERSION | 87 | #ifndef DESKTOP_VERSION |
88 | a.showMainWidget( &m ); | 88 | a.showMainWidget( &m ); |
89 | 89 | ||
90 | #else | 90 | #else |
91 | a.setMainWidget( &m ); | 91 | a.setMainWidget( &m ); |
92 | m.show(); | 92 | m.show(); |
93 | #endif | 93 | #endif |
94 | a.exec(); | 94 | a.exec(); |
95 | #ifdef DESKTOP_VERSION | 95 | #ifdef DESKTOP_VERSION |
96 | KConfig *config = KABPrefs::instance()->getConfig(); | 96 | KConfig *config = KABPrefs::instance()->getConfig(); |
97 | config->setGroup("WidgetLayout"); | 97 | config->setGroup("WidgetLayout"); |
98 | QStringList list ;//= config->readListEntry("MainLayout"); | 98 | QStringList list ;//= config->readListEntry("MainLayout"); |
99 | int x,y,w,h; | 99 | int x,y,w,h; |
100 | QWidget* wid; | 100 | QWidget* wid; |
101 | wid = &m; | 101 | wid = &m; |
102 | x = wid->geometry().x(); | 102 | x = wid->geometry().x(); |
103 | y = wid->geometry().y(); | 103 | y = wid->geometry().y(); |
104 | w = wid->width(); | 104 | w = wid->width(); |
105 | h = wid->height(); | 105 | h = wid->height(); |
106 | list.clear(); | 106 | list.clear(); |
107 | list << QString::number( x ); | 107 | list << QString::number( x ); |
108 | list << QString::number( y ); | 108 | list << QString::number( y ); |
109 | list << QString::number( w ); | 109 | list << QString::number( w ); |
110 | list << QString::number( h ); | 110 | list << QString::number( h ); |
111 | config->writeEntry("MainLayout",list ); | 111 | config->writeEntry("MainLayout",list ); |
112 | config->sync(); | ||
112 | #endif | 113 | #endif |
113 | dumpMissing(); | 114 | dumpMissing(); |
114 | 115 | ||
115 | KPimGlobalPrefs::instance()->writeConfig(); | 116 | KPimGlobalPrefs::instance()->writeConfig(); |
116 | } | 117 | } |
117 | qDebug("KA: Bye! "); | 118 | qDebug("KA: Bye! "); |
118 | } | 119 | } |
119 | 120 | ||
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index e13d0be..720ad78 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,1667 +1,1668 @@ | |||
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 (preton.brown@yale.edu) | 8 | Preston Brown (preton.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 "datenavigatorcontainer.h" | 110 | #include "datenavigatorcontainer.h" |
111 | #include "statusdialog.h" | 111 | #include "statusdialog.h" |
112 | #include "kdatenavigator.h" | 112 | #include "kdatenavigator.h" |
113 | #include "kotodoview.h" | 113 | #include "kotodoview.h" |
114 | #include "datenavigator.h" | 114 | #include "datenavigator.h" |
115 | #include "resourceview.h" | 115 | #include "resourceview.h" |
116 | #include "navigatorbar.h" | 116 | #include "navigatorbar.h" |
117 | #include "searchdialog.h" | 117 | #include "searchdialog.h" |
118 | #include "mainwindow.h" | 118 | #include "mainwindow.h" |
119 | 119 | ||
120 | #include "calendarview.h" | 120 | #include "calendarview.h" |
121 | #ifndef DESKTOP_VERSION | 121 | #ifndef DESKTOP_VERSION |
122 | #include <qtopia/alarmserver.h> | 122 | #include <qtopia/alarmserver.h> |
123 | #endif | 123 | #endif |
124 | #ifndef _WIN32_ | 124 | #ifndef _WIN32_ |
125 | #include <stdlib.h> | 125 | #include <stdlib.h> |
126 | #include <stdio.h> | 126 | #include <stdio.h> |
127 | #include <unistd.h> | 127 | #include <unistd.h> |
128 | #else | 128 | #else |
129 | #include <qprocess.h> | 129 | #include <qprocess.h> |
130 | #endif | 130 | #endif |
131 | 131 | ||
132 | #ifdef DESKTOP_VERSION | 132 | #ifdef DESKTOP_VERSION |
133 | #include <kabc/stdaddressbook.h> | 133 | #include <kabc/stdaddressbook.h> |
134 | #endif | 134 | #endif |
135 | using namespace KOrg; | 135 | using namespace KOrg; |
136 | using namespace KCal; | 136 | using namespace KCal; |
137 | extern int globalFlagBlockAgenda; | 137 | extern int globalFlagBlockAgenda; |
138 | extern int globalFlagBlockStartup; | 138 | extern int globalFlagBlockStartup; |
139 | 139 | ||
140 | 140 | ||
141 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) | 141 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) |
142 | 142 | ||
143 | { | 143 | { |
144 | mAlarms = alarms; | 144 | mAlarms = alarms; |
145 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); | 145 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); |
146 | QString mText = "<table width=\"100%\">\n"; | 146 | QString mText = "<table width=\"100%\">\n"; |
147 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; | 147 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; |
148 | #ifdef DESKTOP_VERSION | 148 | #ifdef DESKTOP_VERSION |
149 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; | 149 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; |
150 | #else | 150 | #else |
151 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; | 151 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; |
152 | #endif | 152 | #endif |
153 | // mText += "<img src=\""; | 153 | // mText += "<img src=\""; |
154 | // mText += ipath; | 154 | // mText += ipath; |
155 | // mText += "\">"; | 155 | // mText += "\">"; |
156 | //mEventDate = QDate::currentDate(); | 156 | //mEventDate = QDate::currentDate(); |
157 | #ifdef DESKTOP_VERSION | 157 | #ifdef DESKTOP_VERSION |
158 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; | 158 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; |
159 | #else | 159 | #else |
160 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; | 160 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; |
161 | #endif | 161 | #endif |
162 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 162 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
163 | 163 | ||
164 | Incidence * inc = getNextInc( start ); | 164 | Incidence * inc = getNextInc( start ); |
165 | int time = 0; | 165 | int time = 0; |
166 | //mText += "<table>"; | 166 | //mText += "<table>"; |
167 | while ( inc ) { | 167 | while ( inc ) { |
168 | QDateTime dt ; | 168 | QDateTime dt ; |
169 | QString tempText = "<a "; | 169 | QString tempText = "<a "; |
170 | bool ok; | 170 | bool ok; |
171 | dt = inc->getNextOccurence( start, &ok ); | 171 | dt = inc->getNextOccurence( start, &ok ); |
172 | if ( !ok ) continue; | 172 | if ( !ok ) continue; |
173 | if ( inc->type() == "Event" ) { | 173 | if ( inc->type() == "Event" ) { |
174 | tempText += "href=\"event:"; | 174 | tempText += "href=\"event:"; |
175 | } else if ( inc->type() == "Todo" ) { | 175 | } else if ( inc->type() == "Todo" ) { |
176 | tempText += "href=\"todo:"; | 176 | tempText += "href=\"todo:"; |
177 | } | 177 | } |
178 | tempText += inc->uid() + "\">"; | 178 | tempText += inc->uid() + "\">"; |
179 | if ( inc->type() == "Todo" ) | 179 | if ( inc->type() == "Todo" ) |
180 | tempText += i18n("Todo: "); | 180 | tempText += i18n("Todo: "); |
181 | if ( inc->summary().length() > 0 ) | 181 | if ( inc->summary().length() > 0 ) |
182 | tempText += inc->summary(); | 182 | tempText += inc->summary(); |
183 | else | 183 | else |
184 | tempText += i18n("-no summary-"); | 184 | tempText += i18n("-no summary-"); |
185 | QString timestr; | 185 | QString timestr; |
186 | if (!inc->doesFloat()) | 186 | if (!inc->doesFloat()) |
187 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; | 187 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; |
188 | else | 188 | else |
189 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; | 189 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; |
190 | if ( dt.date() < QDate::currentDate() && time == 0 ) { | 190 | if ( dt.date() < QDate::currentDate() && time == 0 ) { |
191 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 191 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
192 | mText += "<table>"; | 192 | mText += "<table>"; |
193 | time = 1; | 193 | time = 1; |
194 | } | 194 | } |
195 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { | 195 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { |
196 | if ( time > 0 ) | 196 | if ( time > 0 ) |
197 | mText +="</table>"; | 197 | mText +="</table>"; |
198 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; | 198 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; |
199 | mText += "<table>"; | 199 | mText += "<table>"; |
200 | time = 2; | 200 | time = 2; |
201 | 201 | ||
202 | } | 202 | } |
203 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { | 203 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { |
204 | if ( time > 0 ) | 204 | if ( time > 0 ) |
205 | mText +="</table>"; | 205 | mText +="</table>"; |
206 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; | 206 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; |
207 | mText += "<table>"; | 207 | mText += "<table>"; |
208 | time = 3; | 208 | time = 3; |
209 | } | 209 | } |
210 | mText +="<tr><td><b>"; | 210 | mText +="<tr><td><b>"; |
211 | mText += timestr; | 211 | mText += timestr; |
212 | mText += "</b></td><td>"; | 212 | mText += "</b></td><td>"; |
213 | mText += tempText; | 213 | mText += tempText; |
214 | mText += "</td></tr>\n"; | 214 | mText += "</td></tr>\n"; |
215 | inc = getNextInc( start ); | 215 | inc = getNextInc( start ); |
216 | } | 216 | } |
217 | mText +="</table>"; | 217 | mText +="</table>"; |
218 | setText( mText ); | 218 | setText( mText ); |
219 | } | 219 | } |
220 | 220 | ||
221 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() | 221 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() |
222 | { | 222 | { |
223 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); | 223 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); |
224 | } | 224 | } |
225 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) | 225 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) |
226 | { | 226 | { |
227 | QDateTime dt ; | 227 | QDateTime dt ; |
228 | Incidence * retInc; | 228 | Incidence * retInc; |
229 | Incidence * inc = mAlarms.first(); | 229 | Incidence * inc = mAlarms.first(); |
230 | if ( inc == 0 ) | 230 | if ( inc == 0 ) |
231 | return 0; | 231 | return 0; |
232 | bool ok; | 232 | bool ok; |
233 | dt = inc->getNextOccurence( start, &ok ); | 233 | dt = inc->getNextOccurence( start, &ok ); |
234 | if ( ! ok ) return 0; | 234 | if ( ! ok ) return 0; |
235 | QDateTime dtn ; | 235 | QDateTime dtn ; |
236 | retInc = inc; | 236 | retInc = inc; |
237 | inc = mAlarms.next(); | 237 | inc = mAlarms.next(); |
238 | while ( inc ) { | 238 | while ( inc ) { |
239 | dtn = inc->getNextOccurence( start, &ok ); | 239 | dtn = inc->getNextOccurence( start, &ok ); |
240 | if ( ! ok ) return 0; | 240 | if ( ! ok ) return 0; |
241 | if ( dtn < dt ) { | 241 | if ( dtn < dt ) { |
242 | dt = dtn; | 242 | dt = dtn; |
243 | retInc = inc; | 243 | retInc = inc; |
244 | } | 244 | } |
245 | inc = mAlarms.next(); | 245 | inc = mAlarms.next(); |
246 | } | 246 | } |
247 | mAlarms.remove( retInc ); | 247 | mAlarms.remove( retInc ); |
248 | return retInc; | 248 | return retInc; |
249 | 249 | ||
250 | } | 250 | } |
251 | void MissedAlarmTextBrowser::setSource(const QString & n) | 251 | void MissedAlarmTextBrowser::setSource(const QString & n) |
252 | { | 252 | { |
253 | if (n.startsWith("event:")) { | 253 | if (n.startsWith("event:")) { |
254 | #ifdef DESKTOP_VERSION | 254 | #ifdef DESKTOP_VERSION |
255 | emit showIncidence(n.mid(8)); | 255 | emit showIncidence(n.mid(8)); |
256 | #else | 256 | #else |
257 | emit showIncidence(n.mid(6)); | 257 | emit showIncidence(n.mid(6)); |
258 | #endif | 258 | #endif |
259 | return; | 259 | return; |
260 | } else if (n.startsWith("todo:")) { | 260 | } else if (n.startsWith("todo:")) { |
261 | #ifdef DESKTOP_VERSION | 261 | #ifdef DESKTOP_VERSION |
262 | emit showIncidence(n.mid(7)); | 262 | emit showIncidence(n.mid(7)); |
263 | #else | 263 | #else |
264 | emit showIncidence(n.mid(5)); | 264 | emit showIncidence(n.mid(5)); |
265 | #endif | 265 | #endif |
266 | return; | 266 | return; |
267 | } | 267 | } |
268 | } | 268 | } |
269 | 269 | ||
270 | 270 | ||
271 | class KOBeamPrefs : public QDialog | 271 | class KOBeamPrefs : public QDialog |
272 | { | 272 | { |
273 | public: | 273 | public: |
274 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 274 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
275 | QDialog( parent, name, true ) | 275 | QDialog( parent, name, true ) |
276 | { | 276 | { |
277 | setCaption( i18n("Beam Options") ); | 277 | setCaption( i18n("Beam Options") ); |
278 | QVBoxLayout* lay = new QVBoxLayout( this ); | 278 | QVBoxLayout* lay = new QVBoxLayout( this ); |
279 | lay->setSpacing( 3 ); | 279 | lay->setSpacing( 3 ); |
280 | lay->setMargin( 3 ); | 280 | lay->setMargin( 3 ); |
281 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 281 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
282 | lay->addWidget( format ); | 282 | lay->addWidget( format ); |
283 | format->setExclusive ( true ) ; | 283 | format->setExclusive ( true ) ; |
284 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 284 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
285 | lay->addWidget( time ); time->setExclusive ( true ) ; | 285 | lay->addWidget( time ); time->setExclusive ( true ) ; |
286 | vcal = new QRadioButton(" vCalendar ", format ); | 286 | vcal = new QRadioButton(" vCalendar ", format ); |
287 | ical = new QRadioButton(" iCalendar ", format ); | 287 | ical = new QRadioButton(" iCalendar ", format ); |
288 | vcal->setChecked( true ); | 288 | vcal->setChecked( true ); |
289 | tz = new QRadioButton(i18n(" With timezone "), time ); | 289 | tz = new QRadioButton(i18n(" With timezone "), time ); |
290 | local = new QRadioButton(i18n(" Local time "), time ); | 290 | local = new QRadioButton(i18n(" Local time "), time ); |
291 | tz->setChecked( true ); | 291 | tz->setChecked( true ); |
292 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 292 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
293 | lay->addWidget( ok ); | 293 | lay->addWidget( ok ); |
294 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 294 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
295 | lay->addWidget( cancel ); | 295 | lay->addWidget( cancel ); |
296 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 296 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
297 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 297 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
298 | resize( 200, 200 ); | 298 | resize( 200, 200 ); |
299 | } | 299 | } |
300 | 300 | ||
301 | bool beamVcal() { return vcal->isChecked(); } | 301 | bool beamVcal() { return vcal->isChecked(); } |
302 | bool beamLocal() { return local->isChecked(); } | 302 | bool beamLocal() { return local->isChecked(); } |
303 | private: | 303 | private: |
304 | QRadioButton* vcal, *ical, *local, *tz; | 304 | QRadioButton* vcal, *ical, *local, *tz; |
305 | }; | 305 | }; |
306 | class KOCatPrefs : public QDialog | 306 | class KOCatPrefs : public QDialog |
307 | { | 307 | { |
308 | public: | 308 | public: |
309 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 309 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
310 | QDialog( parent, name, true ) | 310 | QDialog( parent, name, true ) |
311 | { | 311 | { |
312 | setCaption( i18n("Manage new Categories") ); | 312 | setCaption( i18n("Manage new Categories") ); |
313 | QVBoxLayout* lay = new QVBoxLayout( this ); | 313 | QVBoxLayout* lay = new QVBoxLayout( this ); |
314 | lay->setSpacing( 3 ); | 314 | lay->setSpacing( 3 ); |
315 | lay->setMargin( 3 ); | 315 | lay->setMargin( 3 ); |
316 | 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 ); | 316 | 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 ); |
317 | lay->addWidget( lab ); | 317 | lay->addWidget( lab ); |
318 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 318 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
319 | lay->addWidget( format ); | 319 | lay->addWidget( format ); |
320 | format->setExclusive ( true ) ; | 320 | format->setExclusive ( true ) ; |
321 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 321 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
322 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 322 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
323 | addCatBut->setChecked( true ); | 323 | addCatBut->setChecked( true ); |
324 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 324 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
325 | lay->addWidget( ok ); | 325 | lay->addWidget( ok ); |
326 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 326 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
327 | lay->addWidget( cancel ); | 327 | lay->addWidget( cancel ); |
328 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 328 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
329 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 329 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
330 | resize( 200, 200 ); | 330 | resize( 200, 200 ); |
331 | } | 331 | } |
332 | 332 | ||
333 | bool addCat() { return addCatBut->isChecked(); } | 333 | bool addCat() { return addCatBut->isChecked(); } |
334 | private: | 334 | private: |
335 | QRadioButton* addCatBut; | 335 | QRadioButton* addCatBut; |
336 | }; | 336 | }; |
337 | 337 | ||
338 | 338 | ||
339 | 339 | ||
340 | CalendarView::CalendarView( CalendarResources *calendar, | 340 | CalendarView::CalendarView( CalendarResources *calendar, |
341 | QWidget *parent, const char *name ) | 341 | QWidget *parent, const char *name ) |
342 | : CalendarViewBase( parent, name ), | 342 | : CalendarViewBase( parent, name ), |
343 | mCalendar( calendar ), | 343 | mCalendar( calendar ), |
344 | mResourceManager( calendar->resourceManager() ) | 344 | mResourceManager( calendar->resourceManager() ) |
345 | { | 345 | { |
346 | 346 | ||
347 | mEventEditor = 0; | 347 | mEventEditor = 0; |
348 | mTodoEditor = 0; | 348 | mTodoEditor = 0; |
349 | 349 | ||
350 | init(); | 350 | init(); |
351 | } | 351 | } |
352 | 352 | ||
353 | CalendarView::CalendarView( Calendar *calendar, | 353 | CalendarView::CalendarView( Calendar *calendar, |
354 | QWidget *parent, const char *name ) | 354 | QWidget *parent, const char *name ) |
355 | : CalendarViewBase( parent, name ), | 355 | : CalendarViewBase( parent, name ), |
356 | mCalendar( calendar ), | 356 | mCalendar( calendar ), |
357 | mResourceManager( 0 ) | 357 | mResourceManager( 0 ) |
358 | { | 358 | { |
359 | 359 | ||
360 | mEventEditor = 0; | 360 | mEventEditor = 0; |
361 | mTodoEditor = 0; | 361 | mTodoEditor = 0; |
362 | init(); | 362 | init(); |
363 | } | 363 | } |
364 | 364 | ||
365 | void CalendarView::init() | 365 | void CalendarView::init() |
366 | { | 366 | { |
367 | mNextAlarmDateTime = QDateTime::currentDateTime(); | 367 | mNextAlarmDateTime = QDateTime::currentDateTime(); |
368 | setFocusPolicy ( NoFocus ); | 368 | setFocusPolicy ( NoFocus ); |
369 | mViewerCallerIsSearchDialog = false; | 369 | mViewerCallerIsSearchDialog = false; |
370 | mBlockShowDates = false; | 370 | mBlockShowDates = false; |
371 | beamDialog = new KOBeamPrefs(); | 371 | beamDialog = new KOBeamPrefs(); |
372 | mDatePickerMode = 0; | 372 | mDatePickerMode = 0; |
373 | mCurrentSyncDevice = ""; | 373 | mCurrentSyncDevice = ""; |
374 | writeLocale(); | 374 | writeLocale(); |
375 | mViewManager = new KOViewManager( this ); | 375 | mViewManager = new KOViewManager( this ); |
376 | mDialogManager = new KODialogManager( this ); | 376 | mDialogManager = new KODialogManager( this ); |
377 | mEventViewerDialog = 0; | 377 | mEventViewerDialog = 0; |
378 | mModified = false; | 378 | mModified = false; |
379 | mReadOnly = false; | 379 | mReadOnly = false; |
380 | mSelectedIncidence = 0; | 380 | mSelectedIncidence = 0; |
381 | mCalPrinter = 0; | 381 | mCalPrinter = 0; |
382 | mFilters.setAutoDelete(true); | 382 | mFilters.setAutoDelete(true); |
383 | 383 | ||
384 | mCalendar->registerObserver( this ); | 384 | mCalendar->registerObserver( this ); |
385 | // TODO: Make sure that view is updated, when calendar is changed. | 385 | // TODO: Make sure that view is updated, when calendar is changed. |
386 | 386 | ||
387 | mStorage = new FileStorage( mCalendar ); | 387 | mStorage = new FileStorage( mCalendar ); |
388 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 388 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
389 | 389 | ||
390 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 390 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
391 | #ifndef KORG_NOSPLITTER | 391 | #ifndef KORG_NOSPLITTER |
392 | // create the main layout frames. | 392 | // create the main layout frames. |
393 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 393 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
394 | topLayout->addWidget(mPanner); | 394 | topLayout->addWidget(mPanner); |
395 | 395 | ||
396 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 396 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
397 | "CalendarView::LeftFrame"); | 397 | "CalendarView::LeftFrame"); |
398 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 398 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
399 | 399 | ||
400 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, | 400 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, |
401 | "CalendarView::DateNavigator" ); | 401 | "CalendarView::DateNavigator" ); |
402 | 402 | ||
403 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 403 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
404 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 404 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
405 | mTodoList->setNavigator( mNavigator ); | 405 | mTodoList->setNavigator( mNavigator ); |
406 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 406 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
407 | 407 | ||
408 | #ifdef KORG_NORESOURCEVIEW | 408 | #ifdef KORG_NORESOURCEVIEW |
409 | mResourceView = 0; | 409 | mResourceView = 0; |
410 | #else | 410 | #else |
411 | if ( mResourceManager ) { | 411 | if ( mResourceManager ) { |
412 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 412 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
413 | mResourceView->updateView(); | 413 | mResourceView->updateView(); |
414 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 414 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
415 | SLOT( updateView() ) ); | 415 | SLOT( updateView() ) ); |
416 | } else { | 416 | } else { |
417 | mResourceView = 0; | 417 | mResourceView = 0; |
418 | } | 418 | } |
419 | #endif | 419 | #endif |
420 | QWidget *rightBox = new QWidget( mPanner ); | 420 | QWidget *rightBox = new QWidget( mPanner ); |
421 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 421 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
422 | 422 | ||
423 | mRightFrame = new QWidgetStack( rightBox ); | 423 | mRightFrame = new QWidgetStack( rightBox ); |
424 | rightLayout->addWidget( mRightFrame, 1 ); | 424 | rightLayout->addWidget( mRightFrame, 1 ); |
425 | 425 | ||
426 | mLeftFrame = mLeftSplitter; | 426 | mLeftFrame = mLeftSplitter; |
427 | #else | 427 | #else |
428 | //QWidget *mainBox = new QWidget( this ); | 428 | //QWidget *mainBox = new QWidget( this ); |
429 | //QWidget *leftFrame = new QWidget( mainBox ); | 429 | //QWidget *leftFrame = new QWidget( mainBox ); |
430 | //QBoxLayout * mainBoxLayout; | 430 | //QBoxLayout * mainBoxLayout; |
431 | if ( KOPrefs::instance()->mVerticalScreen ) { | 431 | if ( KOPrefs::instance()->mVerticalScreen ) { |
432 | //mainBoxLayout = new QVBoxLayout(mainBox); | 432 | //mainBoxLayout = new QVBoxLayout(mainBox); |
433 | //leftFrameLayout = new QHBoxLayout(leftFrame ); | 433 | //leftFrameLayout = new QHBoxLayout(leftFrame ); |
434 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); | 434 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); |
435 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 435 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
436 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; | 436 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; |
437 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 437 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
438 | } else { | 438 | } else { |
439 | //mainBoxLayout = new QHBoxLayout(mainBox); | 439 | //mainBoxLayout = new QHBoxLayout(mainBox); |
440 | //leftFrameLayout = new QVBoxLayout(leftFrame ); | 440 | //leftFrameLayout = new QVBoxLayout(leftFrame ); |
441 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 441 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
442 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); | 442 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); |
443 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); | 443 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); |
444 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 444 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
445 | } | 445 | } |
446 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); | 446 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); |
447 | //QBoxLayout * leftFrameLayout; | 447 | //QBoxLayout * leftFrameLayout; |
448 | topLayout->addWidget( mMainFrame ); | 448 | topLayout->addWidget( mMainFrame ); |
449 | //mainBoxLayout->addWidget (mLeftFrame); | 449 | //mainBoxLayout->addWidget (mLeftFrame); |
450 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, | 450 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, |
451 | "CalendarView::DateNavigator" ); | 451 | "CalendarView::DateNavigator" ); |
452 | #if 0 | 452 | #if 0 |
453 | // FIXME | 453 | // FIXME |
454 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, | 454 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, |
455 | "CalendarView::DateNavigator", QDate::currentDate()); | 455 | "CalendarView::DateNavigator", QDate::currentDate()); |
456 | #endif | 456 | #endif |
457 | // mDateNavigator->blockSignals( true ); | 457 | // mDateNavigator->blockSignals( true ); |
458 | //leftFrameLayout->addWidget( mDateNavigator ); | 458 | //leftFrameLayout->addWidget( mDateNavigator ); |
459 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); | 459 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); |
460 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); | 460 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); |
461 | mTodoList->setNavigator( mNavigator ); | 461 | mTodoList->setNavigator( mNavigator ); |
462 | #if 0 | 462 | #if 0 |
463 | if ( QApplication::desktop()->width() < 480 ) { | 463 | if ( QApplication::desktop()->width() < 480 ) { |
464 | leftFrameLayout->addWidget(mFilterView); | 464 | leftFrameLayout->addWidget(mFilterView); |
465 | leftFrameLayout->addWidget(mTodoList, 2 ); | 465 | leftFrameLayout->addWidget(mTodoList, 2 ); |
466 | 466 | ||
467 | } else { | 467 | } else { |
468 | leftFrameLayout->addWidget(mTodoList,2 ); | 468 | leftFrameLayout->addWidget(mTodoList,2 ); |
469 | leftFrameLayout->addWidget(mFilterView ); | 469 | leftFrameLayout->addWidget(mFilterView ); |
470 | } | 470 | } |
471 | #endif | 471 | #endif |
472 | mFilterView->hide(); | 472 | mFilterView->hide(); |
473 | QWidget *rightBox = new QWidget( mMainFrame ); | 473 | QWidget *rightBox = new QWidget( mMainFrame ); |
474 | //mainBoxLayout->addWidget ( rightBox, 10 ); | 474 | //mainBoxLayout->addWidget ( rightBox, 10 ); |
475 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 475 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
476 | mRightFrame = new QWidgetStack( rightBox ); | 476 | mRightFrame = new QWidgetStack( rightBox ); |
477 | rightLayout->addWidget( mRightFrame, 10 ); | 477 | rightLayout->addWidget( mRightFrame, 10 ); |
478 | 478 | ||
479 | //mLeftFrame = (QWidget *)leftFrame; | 479 | //mLeftFrame = (QWidget *)leftFrame; |
480 | if ( KOPrefs::instance()->mVerticalScreen ) { | 480 | if ( KOPrefs::instance()->mVerticalScreen ) { |
481 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); | 481 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); |
482 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); | 482 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); |
483 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 483 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
484 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 484 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
485 | } else { | 485 | } else { |
486 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); | 486 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); |
487 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 487 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
488 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 488 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
489 | } | 489 | } |
490 | if ( !KOPrefs::instance()->mShowDateNavigator) | 490 | if ( !KOPrefs::instance()->mShowDateNavigator) |
491 | mDateNavigator->hide(); | 491 | mDateNavigator->hide(); |
492 | //qDebug("Calendarview Size %d %d ", width(), height()); | 492 | //qDebug("Calendarview Size %d %d ", width(), height()); |
493 | #endif | 493 | #endif |
494 | 494 | ||
495 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 495 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
496 | SLOT( showDates( const KCal::DateList & ) ) ); | 496 | SLOT( showDates( const KCal::DateList & ) ) ); |
497 | 497 | ||
498 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 498 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
499 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 499 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
500 | 500 | ||
501 | 501 | ||
502 | 502 | ||
503 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), | 503 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), |
504 | mViewManager, SLOT( showMonth( const QDate & ) ) ); | 504 | mViewManager, SLOT( showMonth( const QDate & ) ) ); |
505 | 505 | ||
506 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 506 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
507 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 507 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
508 | 508 | ||
509 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 509 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
510 | mNavigator, SLOT( selectPreviousYear() ) ); | 510 | mNavigator, SLOT( selectPreviousYear() ) ); |
511 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 511 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
512 | mNavigator, SLOT( selectNextYear() ) ); | 512 | mNavigator, SLOT( selectNextYear() ) ); |
513 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 513 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
514 | mNavigator, SLOT( selectPreviousMonth() ) ); | 514 | mNavigator, SLOT( selectPreviousMonth() ) ); |
515 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 515 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
516 | mNavigator, SLOT( selectNextMonth() ) ); | 516 | mNavigator, SLOT( selectNextMonth() ) ); |
517 | 517 | ||
518 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 518 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
519 | mNavigator, SLOT( selectPrevious() ) ); | 519 | mNavigator, SLOT( selectPrevious() ) ); |
520 | connect( mDateNavigator, SIGNAL( goNext() ), | 520 | connect( mDateNavigator, SIGNAL( goNext() ), |
521 | mNavigator, SLOT( selectNext() ) ); | 521 | mNavigator, SLOT( selectNext() ) ); |
522 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 522 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
523 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 523 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
524 | 524 | ||
525 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 525 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
526 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 526 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
527 | #if 0 | 527 | #if 0 |
528 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), | 528 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), |
529 | SLOT( incidenceAdded( Incidence *) ) ); | 529 | SLOT( incidenceAdded( Incidence *) ) ); |
530 | #endif | 530 | #endif |
531 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 531 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
532 | 532 | ||
533 | connect( this, SIGNAL( configChanged() ), | 533 | connect( this, SIGNAL( configChanged() ), |
534 | mDateNavigator, SLOT( updateConfig() ) ); | 534 | mDateNavigator, SLOT( updateConfig() ) ); |
535 | 535 | ||
536 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 536 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
537 | SLOT( newTodo() ) ); | 537 | SLOT( newTodo() ) ); |
538 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 538 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
539 | SLOT( newSubTodo( Todo * ) ) ); | 539 | SLOT( newSubTodo( Todo * ) ) ); |
540 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 540 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
541 | SLOT( editTodo( Todo * ) ) ); | 541 | SLOT( editTodo( Todo * ) ) ); |
542 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 542 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
543 | SLOT( showTodo( Todo *) ) ); | 543 | SLOT( showTodo( Todo *) ) ); |
544 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 544 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
545 | SLOT( deleteTodo( Todo *) ) ); | 545 | SLOT( deleteTodo( Todo *) ) ); |
546 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 546 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
547 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 547 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
548 | SLOT( purgeCompleted() ) ); | 548 | SLOT( purgeCompleted() ) ); |
549 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 549 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
550 | SIGNAL( todoModified( Todo *, int ) ) ); | 550 | SIGNAL( todoModified( Todo *, int ) ) ); |
551 | 551 | ||
552 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 552 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
553 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 553 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
554 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 554 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
555 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 555 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
556 | 556 | ||
557 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 557 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
558 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 558 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
559 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 559 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
560 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 560 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
561 | 561 | ||
562 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 562 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
563 | this, SLOT ( todo_unsub( Todo * ) ) ); | 563 | this, SLOT ( todo_unsub( Todo * ) ) ); |
564 | 564 | ||
565 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 565 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
566 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 566 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
567 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 567 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
568 | SLOT( updateTodo( Todo *, int ) ) ); | 568 | SLOT( updateTodo( Todo *, int ) ) ); |
569 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 569 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
570 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 570 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
571 | 571 | ||
572 | 572 | ||
573 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 573 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
574 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 574 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
575 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 575 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
576 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 576 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
577 | 577 | ||
578 | 578 | ||
579 | 579 | ||
580 | 580 | ||
581 | 581 | ||
582 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 582 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
583 | SLOT(checkClipboard())); | 583 | SLOT(checkClipboard())); |
584 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 584 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
585 | SLOT( processTodoListSelection( Incidence * ) ) ); | 585 | SLOT( processTodoListSelection( Incidence * ) ) ); |
586 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 586 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
587 | 587 | ||
588 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 588 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
589 | 589 | ||
590 | mDateFrame = new QVBox(0,0,WType_Popup); | 590 | mDateFrame = new QVBox(0,0,WType_Popup); |
591 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 591 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
592 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 592 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
593 | mDateFrame->setLineWidth(3); | 593 | mDateFrame->setLineWidth(3); |
594 | mDateFrame->hide(); | 594 | mDateFrame->hide(); |
595 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 595 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
596 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 596 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
597 | 597 | ||
598 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 598 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
599 | 599 | ||
600 | mEventEditor = mDialogManager->getEventEditor(); | 600 | mEventEditor = mDialogManager->getEventEditor(); |
601 | mTodoEditor = mDialogManager->getTodoEditor(); | 601 | mTodoEditor = mDialogManager->getTodoEditor(); |
602 | 602 | ||
603 | mFlagEditDescription = false; | 603 | mFlagEditDescription = false; |
604 | 604 | ||
605 | mSuspendTimer = new QTimer( this ); | 605 | mSuspendTimer = new QTimer( this ); |
606 | mAlarmTimer = new QTimer( this ); | 606 | mAlarmTimer = new QTimer( this ); |
607 | mRecheckAlarmTimer = new QTimer( this ); | 607 | mRecheckAlarmTimer = new QTimer( this ); |
608 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 608 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
609 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 609 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
610 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 610 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
611 | mAlarmDialog = new AlarmDialog( this ); | 611 | mAlarmDialog = new AlarmDialog( this ); |
612 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 612 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
613 | mAlarmDialog->setServerNotification( false ); | 613 | mAlarmDialog->setServerNotification( false ); |
614 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 614 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
615 | 615 | ||
616 | 616 | ||
617 | #ifndef DESKTOP_VERSION | 617 | #ifndef DESKTOP_VERSION |
618 | //US listen for arriving address resultsets | 618 | //US listen for arriving address resultsets |
619 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 619 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
620 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 620 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
621 | #endif | 621 | #endif |
622 | mDateNavigator->setCalendar( mCalendar ); | 622 | mDateNavigator->setCalendar( mCalendar ); |
623 | } | 623 | } |
624 | 624 | ||
625 | 625 | ||
626 | CalendarView::~CalendarView() | 626 | CalendarView::~CalendarView() |
627 | { | 627 | { |
628 | // kdDebug() << "~CalendarView()" << endl; | 628 | // kdDebug() << "~CalendarView()" << endl; |
629 | //qDebug("CalendarView::~CalendarView() "); | 629 | //qDebug("CalendarView::~CalendarView() "); |
630 | delete mDialogManager; | 630 | delete mDialogManager; |
631 | delete mViewManager; | 631 | delete mViewManager; |
632 | delete mStorage; | 632 | delete mStorage; |
633 | delete mDateFrame ; | 633 | delete mDateFrame ; |
634 | delete beamDialog; | 634 | delete beamDialog; |
635 | delete mEventViewerDialog; | 635 | delete mEventViewerDialog; |
636 | //kdDebug() << "~CalendarView() done" << endl; | 636 | //kdDebug() << "~CalendarView() done" << endl; |
637 | } | 637 | } |
638 | void CalendarView::checkAlarms() | 638 | void CalendarView::checkAlarms() |
639 | { | 639 | { |
640 | KConfig *config = KOGlobals::config(); | 640 | KConfig *config = KOGlobals::config(); |
641 | config->setGroup( "AppRun" ); | 641 | config->setGroup( "AppRun" ); |
642 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 642 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
643 | int secs = config->readNumEntry( "LatestProgramStop" ) - 30; | 643 | int secto = dt.secsTo( QDateTime::currentDateTime() ); |
644 | int secs = config->readNumEntry( "LatestProgramStop" , secto) - 30; | ||
644 | //secs -= ( 3600 * 24*3 ); // debug only | 645 | //secs -= ( 3600 * 24*3 ); // debug only |
645 | QDateTime latest = dt.addSecs ( secs ); | 646 | QDateTime latest = dt.addSecs ( secs ); |
646 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); | 647 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); |
647 | QPtrList<Incidence> el = mCalendar->rawIncidences(); | 648 | QPtrList<Incidence> el = mCalendar->rawIncidences(); |
648 | QPtrList<Incidence> al; | 649 | QPtrList<Incidence> al; |
649 | Incidence* inL = el.first(); | 650 | Incidence* inL = el.first(); |
650 | while ( inL ) { | 651 | while ( inL ) { |
651 | bool ok = false; | 652 | bool ok = false; |
652 | int offset = 0; | 653 | int offset = 0; |
653 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; | 654 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; |
654 | if ( ok ) { | 655 | if ( ok ) { |
655 | //qDebug("OK %s",next.toString().latin1()); | 656 | //qDebug("OK %s",next.toString().latin1()); |
656 | if ( next < QDateTime::currentDateTime() ) { | 657 | if ( next < QDateTime::currentDateTime() ) { |
657 | al.append( inL ); | 658 | al.append( inL ); |
658 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); | 659 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); |
659 | } | 660 | } |
660 | } | 661 | } |
661 | inL = el.next(); | 662 | inL = el.next(); |
662 | } | 663 | } |
663 | if ( al.count() ) { | 664 | if ( al.count() ) { |
664 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); | 665 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); |
665 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); | 666 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); |
666 | QVBoxLayout* lay = new QVBoxLayout( dia ); | 667 | QVBoxLayout* lay = new QVBoxLayout( dia ); |
667 | lay->setSpacing( 0 ); | 668 | lay->setSpacing( 0 ); |
668 | lay->setMargin( 0 ); | 669 | lay->setMargin( 0 ); |
669 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); | 670 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); |
670 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 671 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
671 | lay->addWidget( matb ); | 672 | lay->addWidget( matb ); |
672 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { | 673 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { |
673 | int wid = 210; | 674 | int wid = 210; |
674 | int x = QApplication::desktop()->width() - wid - 7; | 675 | int x = QApplication::desktop()->width() - wid - 7; |
675 | int y = QApplication::desktop()->height() - wid - 70; | 676 | int y = QApplication::desktop()->height() - wid - 70; |
676 | dia->setGeometry ( x,y,wid,wid); | 677 | dia->setGeometry ( x,y,wid,wid); |
677 | } else { | 678 | } else { |
678 | int si = 220; | 679 | int si = 220; |
679 | if ( QApplication::desktop()->width() > 470 ) | 680 | if ( QApplication::desktop()->width() > 470 ) |
680 | si = 400; | 681 | si = 400; |
681 | dia->resize(si,si/2); | 682 | dia->resize(si,si/2); |
682 | } | 683 | } |
683 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); | 684 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); |
684 | dia->show(); | 685 | dia->show(); |
685 | 686 | ||
686 | } | 687 | } |
687 | } | 688 | } |
688 | void CalendarView::showDay( QDate d ) | 689 | void CalendarView::showDay( QDate d ) |
689 | { | 690 | { |
690 | dateNavigator()->blockSignals( true ); | 691 | dateNavigator()->blockSignals( true ); |
691 | dateNavigator()->selectDate( d ); | 692 | dateNavigator()->selectDate( d ); |
692 | dateNavigator()->blockSignals( false ); | 693 | dateNavigator()->blockSignals( false ); |
693 | mViewManager->showDayView(); | 694 | mViewManager->showDayView(); |
694 | //dateNavigator()->selectDate( d ); | 695 | //dateNavigator()->selectDate( d ); |
695 | } | 696 | } |
696 | void CalendarView::timerAlarm() | 697 | void CalendarView::timerAlarm() |
697 | { | 698 | { |
698 | //qDebug("CalendarView::timerAlarm() "); | 699 | //qDebug("CalendarView::timerAlarm() "); |
699 | computeAlarm(mAlarmNotification ); | 700 | computeAlarm(mAlarmNotification ); |
700 | } | 701 | } |
701 | 702 | ||
702 | void CalendarView::suspendAlarm() | 703 | void CalendarView::suspendAlarm() |
703 | { | 704 | { |
704 | //qDebug(" CalendarView::suspendAlarm() "); | 705 | //qDebug(" CalendarView::suspendAlarm() "); |
705 | computeAlarm(mSuspendAlarmNotification ); | 706 | computeAlarm(mSuspendAlarmNotification ); |
706 | 707 | ||
707 | } | 708 | } |
708 | 709 | ||
709 | void CalendarView::startAlarm( QString mess , QString filename) | 710 | void CalendarView::startAlarm( QString mess , QString filename) |
710 | { | 711 | { |
711 | 712 | ||
712 | topLevelWidget()->showNormal(); | 713 | topLevelWidget()->showNormal(); |
713 | topLevelWidget()->setActiveWindow(); | 714 | topLevelWidget()->setActiveWindow(); |
714 | topLevelWidget()->raise(); | 715 | topLevelWidget()->raise(); |
715 | 716 | ||
716 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 717 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
717 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 718 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
718 | 719 | ||
719 | } | 720 | } |
720 | 721 | ||
721 | void CalendarView::checkNextTimerAlarm() | 722 | void CalendarView::checkNextTimerAlarm() |
722 | { | 723 | { |
723 | mCalendar->checkAlarmForIncidence( 0, true ); | 724 | mCalendar->checkAlarmForIncidence( 0, true ); |
724 | } | 725 | } |
725 | 726 | ||
726 | void CalendarView::computeAlarm( QString msg ) | 727 | void CalendarView::computeAlarm( QString msg ) |
727 | { | 728 | { |
728 | 729 | ||
729 | QString mess = msg; | 730 | QString mess = msg; |
730 | QString mAlarmMessage = mess.mid( 9 ); | 731 | QString mAlarmMessage = mess.mid( 9 ); |
731 | QString filename = MainWindow::resourcePath(); | 732 | QString filename = MainWindow::resourcePath(); |
732 | filename += "koalarm.wav"; | 733 | filename += "koalarm.wav"; |
733 | QString tempfilename; | 734 | QString tempfilename; |
734 | if ( mess.left( 13 ) == "suspend_alarm") { | 735 | if ( mess.left( 13 ) == "suspend_alarm") { |
735 | bool error = false; | 736 | bool error = false; |
736 | int len = mess.mid( 13 ).find("+++"); | 737 | int len = mess.mid( 13 ).find("+++"); |
737 | if ( len < 2 ) | 738 | if ( len < 2 ) |
738 | error = true; | 739 | error = true; |
739 | else { | 740 | else { |
740 | tempfilename = mess.mid( 13, len ); | 741 | tempfilename = mess.mid( 13, len ); |
741 | if ( !QFile::exists( tempfilename ) ) | 742 | if ( !QFile::exists( tempfilename ) ) |
742 | error = true; | 743 | error = true; |
743 | } | 744 | } |
744 | if ( ! error ) { | 745 | if ( ! error ) { |
745 | filename = tempfilename; | 746 | filename = tempfilename; |
746 | } | 747 | } |
747 | mAlarmMessage = mess.mid( 13+len+3 ); | 748 | mAlarmMessage = mess.mid( 13+len+3 ); |
748 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 749 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
749 | startAlarm( mAlarmMessage, filename); | 750 | startAlarm( mAlarmMessage, filename); |
750 | return; | 751 | return; |
751 | } | 752 | } |
752 | if ( mess.left( 11 ) == "timer_alarm") { | 753 | if ( mess.left( 11 ) == "timer_alarm") { |
753 | //mTimerTime = 0; | 754 | //mTimerTime = 0; |
754 | startAlarm( mess.mid( 11 ), filename ); | 755 | startAlarm( mess.mid( 11 ), filename ); |
755 | return; | 756 | return; |
756 | } | 757 | } |
757 | if ( mess.left( 10 ) == "proc_alarm") { | 758 | if ( mess.left( 10 ) == "proc_alarm") { |
758 | bool error = false; | 759 | bool error = false; |
759 | int len = mess.mid( 10 ).find("+++"); | 760 | int len = mess.mid( 10 ).find("+++"); |
760 | if ( len < 2 ) | 761 | if ( len < 2 ) |
761 | error = true; | 762 | error = true; |
762 | else { | 763 | else { |
763 | tempfilename = mess.mid( 10, len ); | 764 | tempfilename = mess.mid( 10, len ); |
764 | if ( !QFile::exists( tempfilename ) ) | 765 | if ( !QFile::exists( tempfilename ) ) |
765 | error = true; | 766 | error = true; |
766 | } | 767 | } |
767 | if ( error ) { | 768 | if ( error ) { |
768 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 769 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
769 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 770 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
770 | } else { | 771 | } else { |
771 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 772 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
772 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 773 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
773 | #ifndef _WIN32_ | 774 | #ifndef _WIN32_ |
774 | if ( vfork () == 0 ) { | 775 | if ( vfork () == 0 ) { |
775 | execl ( tempfilename.latin1(), 0 ); | 776 | execl ( tempfilename.latin1(), 0 ); |
776 | return; | 777 | return; |
777 | } | 778 | } |
778 | #else | 779 | #else |
779 | QProcess* p = new QProcess(); | 780 | QProcess* p = new QProcess(); |
780 | p->addArgument( tempfilename.latin1() ); | 781 | p->addArgument( tempfilename.latin1() ); |
781 | p->start(); | 782 | p->start(); |
782 | return; | 783 | return; |
783 | #endif | 784 | #endif |
784 | 785 | ||
785 | return; | 786 | return; |
786 | } | 787 | } |
787 | 788 | ||
788 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 789 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
789 | } | 790 | } |
790 | if ( mess.left( 11 ) == "audio_alarm") { | 791 | if ( mess.left( 11 ) == "audio_alarm") { |
791 | bool error = false; | 792 | bool error = false; |
792 | int len = mess.mid( 11 ).find("+++"); | 793 | int len = mess.mid( 11 ).find("+++"); |
793 | if ( len < 2 ) | 794 | if ( len < 2 ) |
794 | error = true; | 795 | error = true; |
795 | else { | 796 | else { |
796 | tempfilename = mess.mid( 11, len ); | 797 | tempfilename = mess.mid( 11, len ); |
797 | if ( !QFile::exists( tempfilename ) ) | 798 | if ( !QFile::exists( tempfilename ) ) |
798 | error = true; | 799 | error = true; |
799 | } | 800 | } |
800 | if ( ! error ) { | 801 | if ( ! error ) { |
801 | filename = tempfilename; | 802 | filename = tempfilename; |
802 | } | 803 | } |
803 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 804 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
804 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 805 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
805 | } | 806 | } |
806 | if ( mess.left( 9 ) == "cal_alarm") { | 807 | if ( mess.left( 9 ) == "cal_alarm") { |
807 | mAlarmMessage = mess.mid( 9 ) ; | 808 | mAlarmMessage = mess.mid( 9 ) ; |
808 | } | 809 | } |
809 | 810 | ||
810 | startAlarm( mAlarmMessage, filename ); | 811 | startAlarm( mAlarmMessage, filename ); |
811 | 812 | ||
812 | 813 | ||
813 | } | 814 | } |
814 | 815 | ||
815 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 816 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
816 | { | 817 | { |
817 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 818 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
818 | 819 | ||
819 | mSuspendAlarmNotification = noti; | 820 | mSuspendAlarmNotification = noti; |
820 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 821 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
821 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 822 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
822 | mSuspendTimer->start( ms , true ); | 823 | mSuspendTimer->start( ms , true ); |
823 | 824 | ||
824 | } | 825 | } |
825 | 826 | ||
826 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 827 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
827 | { | 828 | { |
828 | mNextAlarmDateTime = qdt; | 829 | mNextAlarmDateTime = qdt; |
829 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 830 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
830 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 831 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
831 | #ifndef DESKTOP_VERSION | 832 | #ifndef DESKTOP_VERSION |
832 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 833 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
833 | #endif | 834 | #endif |
834 | return; | 835 | return; |
835 | } | 836 | } |
836 | int maxSec; | 837 | int maxSec; |
837 | //maxSec = 5; //testing only | 838 | //maxSec = 5; //testing only |
838 | maxSec = 86400+3600; // one day+1hour | 839 | maxSec = 86400+3600; // one day+1hour |
839 | mAlarmNotification = noti; | 840 | mAlarmNotification = noti; |
840 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 841 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
841 | if ( sec > maxSec ) { | 842 | if ( sec > maxSec ) { |
842 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 843 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
843 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 844 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
844 | return; | 845 | return; |
845 | } else { | 846 | } else { |
846 | mRecheckAlarmTimer->stop(); | 847 | mRecheckAlarmTimer->stop(); |
847 | } | 848 | } |
848 | //qDebug("Alarm timer started with secs: %d ", sec); | 849 | //qDebug("Alarm timer started with secs: %d ", sec); |
849 | mAlarmTimer->start( sec *1000 , true ); | 850 | mAlarmTimer->start( sec *1000 , true ); |
850 | 851 | ||
851 | } | 852 | } |
852 | // called by mRecheckAlarmTimer to get next alarm | 853 | // called by mRecheckAlarmTimer to get next alarm |
853 | // we need this, because a QTimer has only a max range of 25 days | 854 | // we need this, because a QTimer has only a max range of 25 days |
854 | void CalendarView::recheckTimerAlarm() | 855 | void CalendarView::recheckTimerAlarm() |
855 | { | 856 | { |
856 | mAlarmTimer->stop(); | 857 | mAlarmTimer->stop(); |
857 | mRecheckAlarmTimer->stop(); | 858 | mRecheckAlarmTimer->stop(); |
858 | mCalendar->checkAlarmForIncidence( 0, true ); | 859 | mCalendar->checkAlarmForIncidence( 0, true ); |
859 | } | 860 | } |
860 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 861 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
861 | { | 862 | { |
862 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 863 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
863 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 864 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
864 | #ifndef DESKTOP_VERSION | 865 | #ifndef DESKTOP_VERSION |
865 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 866 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
866 | #endif | 867 | #endif |
867 | return; | 868 | return; |
868 | } | 869 | } |
869 | mAlarmTimer->stop(); | 870 | mAlarmTimer->stop(); |
870 | } | 871 | } |
871 | void CalendarView::selectWeekNum ( int num ) | 872 | void CalendarView::selectWeekNum ( int num ) |
872 | { | 873 | { |
873 | dateNavigator()->blockSignals( true ); | 874 | dateNavigator()->blockSignals( true ); |
874 | dateNavigator()->selectWeek( num ); | 875 | dateNavigator()->selectWeek( num ); |
875 | dateNavigator()->blockSignals( false ); | 876 | dateNavigator()->blockSignals( false ); |
876 | mViewManager->showWeekView(); | 877 | mViewManager->showWeekView(); |
877 | } | 878 | } |
878 | KOViewManager *CalendarView::viewManager() | 879 | KOViewManager *CalendarView::viewManager() |
879 | { | 880 | { |
880 | return mViewManager; | 881 | return mViewManager; |
881 | } | 882 | } |
882 | 883 | ||
883 | KODialogManager *CalendarView::dialogManager() | 884 | KODialogManager *CalendarView::dialogManager() |
884 | { | 885 | { |
885 | return mDialogManager; | 886 | return mDialogManager; |
886 | } | 887 | } |
887 | 888 | ||
888 | QDate CalendarView::startDate() | 889 | QDate CalendarView::startDate() |
889 | { | 890 | { |
890 | DateList dates = mNavigator->selectedDates(); | 891 | DateList dates = mNavigator->selectedDates(); |
891 | 892 | ||
892 | return dates.first(); | 893 | return dates.first(); |
893 | } | 894 | } |
894 | 895 | ||
895 | QDate CalendarView::endDate() | 896 | QDate CalendarView::endDate() |
896 | { | 897 | { |
897 | DateList dates = mNavigator->selectedDates(); | 898 | DateList dates = mNavigator->selectedDates(); |
898 | 899 | ||
899 | return dates.last(); | 900 | return dates.last(); |
900 | } | 901 | } |
901 | 902 | ||
902 | 903 | ||
903 | void CalendarView::createPrinter() | 904 | void CalendarView::createPrinter() |
904 | { | 905 | { |
905 | #ifndef KORG_NOPRINTER | 906 | #ifndef KORG_NOPRINTER |
906 | if (!mCalPrinter) { | 907 | if (!mCalPrinter) { |
907 | mCalPrinter = new CalPrinter(this, mCalendar); | 908 | mCalPrinter = new CalPrinter(this, mCalendar); |
908 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 909 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
909 | } | 910 | } |
910 | #endif | 911 | #endif |
911 | } | 912 | } |
912 | 913 | ||
913 | 914 | ||
914 | //KOPrefs::instance()->mWriteBackFile | 915 | //KOPrefs::instance()->mWriteBackFile |
915 | //KOPrefs::instance()->mWriteBackExistingOnly | 916 | //KOPrefs::instance()->mWriteBackExistingOnly |
916 | 917 | ||
917 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 918 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
918 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 919 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
919 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 920 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
920 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 921 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
921 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 922 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
922 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 923 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
923 | 924 | ||
924 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 925 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
925 | { | 926 | { |
926 | 927 | ||
927 | // 0 equal | 928 | // 0 equal |
928 | // 1 take local | 929 | // 1 take local |
929 | // 2 take remote | 930 | // 2 take remote |
930 | // 3 cancel | 931 | // 3 cancel |
931 | QDateTime lastSync = mLastCalendarSync; | 932 | QDateTime lastSync = mLastCalendarSync; |
932 | QDateTime localMod = local->lastModified(); | 933 | QDateTime localMod = local->lastModified(); |
933 | QDateTime remoteMod = remote->lastModified(); | 934 | QDateTime remoteMod = remote->lastModified(); |
934 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 935 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
935 | bool remCh, locCh; | 936 | bool remCh, locCh; |
936 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 937 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
937 | //if ( remCh ) | 938 | //if ( remCh ) |
938 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 939 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
939 | locCh = ( localMod > mLastCalendarSync ); | 940 | locCh = ( localMod > mLastCalendarSync ); |
940 | if ( !remCh && ! locCh ) { | 941 | if ( !remCh && ! locCh ) { |
941 | //qDebug("both not changed "); | 942 | //qDebug("both not changed "); |
942 | lastSync = localMod.addDays(1); | 943 | lastSync = localMod.addDays(1); |
943 | if ( mode <= SYNC_PREF_ASK ) | 944 | if ( mode <= SYNC_PREF_ASK ) |
944 | return 0; | 945 | return 0; |
945 | } else { | 946 | } else { |
946 | if ( locCh ) { | 947 | if ( locCh ) { |
947 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 948 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
948 | lastSync = localMod.addDays( -1 ); | 949 | lastSync = localMod.addDays( -1 ); |
949 | if ( !remCh ) | 950 | if ( !remCh ) |
950 | remoteMod = ( lastSync.addDays( -1 ) ); | 951 | remoteMod = ( lastSync.addDays( -1 ) ); |
951 | } else { | 952 | } else { |
952 | //qDebug(" not loc changed "); | 953 | //qDebug(" not loc changed "); |
953 | lastSync = localMod.addDays( 1 ); | 954 | lastSync = localMod.addDays( 1 ); |
954 | if ( remCh ) | 955 | if ( remCh ) |
955 | remoteMod =( lastSync.addDays( 1 ) ); | 956 | remoteMod =( lastSync.addDays( 1 ) ); |
956 | 957 | ||
957 | } | 958 | } |
958 | } | 959 | } |
959 | full = true; | 960 | full = true; |
960 | if ( mode < SYNC_PREF_ASK ) | 961 | if ( mode < SYNC_PREF_ASK ) |
961 | mode = SYNC_PREF_ASK; | 962 | mode = SYNC_PREF_ASK; |
962 | } else { | 963 | } else { |
963 | if ( localMod == remoteMod ) | 964 | if ( localMod == remoteMod ) |
964 | // if ( local->revision() == remote->revision() ) | 965 | // if ( local->revision() == remote->revision() ) |
965 | return 0; | 966 | return 0; |
966 | 967 | ||
967 | } | 968 | } |
968 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 969 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
969 | 970 | ||
970 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 971 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
971 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 972 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
972 | //full = true; //debug only | 973 | //full = true; //debug only |
973 | if ( full ) { | 974 | if ( full ) { |
974 | bool equ = false; | 975 | bool equ = false; |
975 | if ( local->type() == "Event" ) { | 976 | if ( local->type() == "Event" ) { |
976 | equ = (*((Event*) local) == *((Event*) remote)); | 977 | equ = (*((Event*) local) == *((Event*) remote)); |
977 | } | 978 | } |
978 | else if ( local->type() =="Todo" ) | 979 | else if ( local->type() =="Todo" ) |
979 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 980 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
980 | else if ( local->type() =="Journal" ) | 981 | else if ( local->type() =="Journal" ) |
981 | equ = (*((Journal*) local) == *((Journal*) remote)); | 982 | equ = (*((Journal*) local) == *((Journal*) remote)); |
982 | if ( equ ) { | 983 | if ( equ ) { |
983 | //qDebug("equal "); | 984 | //qDebug("equal "); |
984 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 985 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
985 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 986 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
986 | } | 987 | } |
987 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 988 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
988 | return 0; | 989 | return 0; |
989 | 990 | ||
990 | }//else //debug only | 991 | }//else //debug only |
991 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 992 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
992 | } | 993 | } |
993 | int result; | 994 | int result; |
994 | bool localIsNew; | 995 | bool localIsNew; |
995 | //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() ); | 996 | //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() ); |
996 | 997 | ||
997 | 998 | ||
998 | // ************************************************ | 999 | // ************************************************ |
999 | // ************************************************ | 1000 | // ************************************************ |
1000 | // ************************************************ | 1001 | // ************************************************ |
1001 | // We may have that lastSync > remoteMod AND lastSync > localMod | 1002 | // We may have that lastSync > remoteMod AND lastSync > localMod |
1002 | // BUT remoteMod != localMod | 1003 | // BUT remoteMod != localMod |
1003 | 1004 | ||
1004 | 1005 | ||
1005 | if ( full && mode < SYNC_PREF_NEWEST ) | 1006 | if ( full && mode < SYNC_PREF_NEWEST ) |
1006 | mode = SYNC_PREF_ASK; | 1007 | mode = SYNC_PREF_ASK; |
1007 | 1008 | ||
1008 | switch( mode ) { | 1009 | switch( mode ) { |
1009 | case SYNC_PREF_LOCAL: | 1010 | case SYNC_PREF_LOCAL: |
1010 | if ( lastSync > remoteMod ) | 1011 | if ( lastSync > remoteMod ) |
1011 | return 1; | 1012 | return 1; |
1012 | if ( lastSync > localMod ) | 1013 | if ( lastSync > localMod ) |
1013 | return 2; | 1014 | return 2; |
1014 | return 1; | 1015 | return 1; |
1015 | break; | 1016 | break; |
1016 | case SYNC_PREF_REMOTE: | 1017 | case SYNC_PREF_REMOTE: |
1017 | if ( lastSync > localMod ) | 1018 | if ( lastSync > localMod ) |
1018 | return 2; | 1019 | return 2; |
1019 | if ( lastSync > remoteMod ) | 1020 | if ( lastSync > remoteMod ) |
1020 | return 1; | 1021 | return 1; |
1021 | return 2; | 1022 | return 2; |
1022 | break; | 1023 | break; |
1023 | case SYNC_PREF_NEWEST: | 1024 | case SYNC_PREF_NEWEST: |
1024 | if ( localMod >= remoteMod ) | 1025 | if ( localMod >= remoteMod ) |
1025 | return 1; | 1026 | return 1; |
1026 | else | 1027 | else |
1027 | return 2; | 1028 | return 2; |
1028 | break; | 1029 | break; |
1029 | case SYNC_PREF_ASK: | 1030 | case SYNC_PREF_ASK: |
1030 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1031 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1031 | if ( lastSync > remoteMod && lastSync > localMod) | 1032 | if ( lastSync > remoteMod && lastSync > localMod) |
1032 | return 0; | 1033 | return 0; |
1033 | if ( lastSync > remoteMod ) | 1034 | if ( lastSync > remoteMod ) |
1034 | return 1; | 1035 | return 1; |
1035 | if ( lastSync > localMod ) | 1036 | if ( lastSync > localMod ) |
1036 | return 2; | 1037 | return 2; |
1037 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1038 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1038 | localIsNew = localMod >= remoteMod; | 1039 | localIsNew = localMod >= remoteMod; |
1039 | if ( localIsNew ) | 1040 | if ( localIsNew ) |
1040 | getEventViewerDialog()->setColorMode( 1 ); | 1041 | getEventViewerDialog()->setColorMode( 1 ); |
1041 | else | 1042 | else |
1042 | getEventViewerDialog()->setColorMode( 2 ); | 1043 | getEventViewerDialog()->setColorMode( 2 ); |
1043 | getEventViewerDialog()->setIncidence(local); | 1044 | getEventViewerDialog()->setIncidence(local); |
1044 | if ( localIsNew ) | 1045 | if ( localIsNew ) |
1045 | getEventViewerDialog()->setColorMode( 2 ); | 1046 | getEventViewerDialog()->setColorMode( 2 ); |
1046 | else | 1047 | else |
1047 | getEventViewerDialog()->setColorMode( 1 ); | 1048 | getEventViewerDialog()->setColorMode( 1 ); |
1048 | getEventViewerDialog()->addIncidence(remote); | 1049 | getEventViewerDialog()->addIncidence(remote); |
1049 | getEventViewerDialog()->setColorMode( 0 ); | 1050 | getEventViewerDialog()->setColorMode( 0 ); |
1050 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 1051 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
1051 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 1052 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
1052 | getEventViewerDialog()->showMe(); | 1053 | getEventViewerDialog()->showMe(); |
1053 | result = getEventViewerDialog()->executeS( localIsNew ); | 1054 | result = getEventViewerDialog()->executeS( localIsNew ); |
1054 | return result; | 1055 | return result; |
1055 | 1056 | ||
1056 | break; | 1057 | break; |
1057 | case SYNC_PREF_FORCE_LOCAL: | 1058 | case SYNC_PREF_FORCE_LOCAL: |
1058 | return 1; | 1059 | return 1; |
1059 | break; | 1060 | break; |
1060 | case SYNC_PREF_FORCE_REMOTE: | 1061 | case SYNC_PREF_FORCE_REMOTE: |
1061 | return 2; | 1062 | return 2; |
1062 | break; | 1063 | break; |
1063 | 1064 | ||
1064 | default: | 1065 | default: |
1065 | // SYNC_PREF_TAKE_BOTH not implemented | 1066 | // SYNC_PREF_TAKE_BOTH not implemented |
1066 | break; | 1067 | break; |
1067 | } | 1068 | } |
1068 | return 0; | 1069 | return 0; |
1069 | } | 1070 | } |
1070 | Event* CalendarView::getLastSyncEvent() | 1071 | Event* CalendarView::getLastSyncEvent() |
1071 | { | 1072 | { |
1072 | Event* lse; | 1073 | Event* lse; |
1073 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 1074 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
1074 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 1075 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
1075 | if (!lse) { | 1076 | if (!lse) { |
1076 | lse = new Event(); | 1077 | lse = new Event(); |
1077 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 1078 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
1078 | QString sum = ""; | 1079 | QString sum = ""; |
1079 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 1080 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
1080 | sum = "E: "; | 1081 | sum = "E: "; |
1081 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 1082 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
1082 | lse->setDtStart( mLastCalendarSync ); | 1083 | lse->setDtStart( mLastCalendarSync ); |
1083 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1084 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1084 | lse->setCategories( i18n("SyncEvent") ); | 1085 | lse->setCategories( i18n("SyncEvent") ); |
1085 | lse->setReadOnly( true ); | 1086 | lse->setReadOnly( true ); |
1086 | mCalendar->addEvent( lse ); | 1087 | mCalendar->addEvent( lse ); |
1087 | } | 1088 | } |
1088 | 1089 | ||
1089 | return lse; | 1090 | return lse; |
1090 | 1091 | ||
1091 | } | 1092 | } |
1092 | 1093 | ||
1093 | // we check, if the to delete event has a id for a profile | 1094 | // we check, if the to delete event has a id for a profile |
1094 | // if yes, we set this id in the profile to delete | 1095 | // if yes, we set this id in the profile to delete |
1095 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 1096 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
1096 | { | 1097 | { |
1097 | if ( lastSync.count() == 0 ) { | 1098 | if ( lastSync.count() == 0 ) { |
1098 | //qDebug(" lastSync.count() == 0"); | 1099 | //qDebug(" lastSync.count() == 0"); |
1099 | return; | 1100 | return; |
1100 | } | 1101 | } |
1101 | if ( toDelete->type() == "Journal" ) | 1102 | if ( toDelete->type() == "Journal" ) |
1102 | return; | 1103 | return; |
1103 | 1104 | ||
1104 | Event* eve = lastSync.first(); | 1105 | Event* eve = lastSync.first(); |
1105 | 1106 | ||
1106 | while ( eve ) { | 1107 | while ( eve ) { |
1107 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 1108 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
1108 | if ( !id.isEmpty() ) { | 1109 | if ( !id.isEmpty() ) { |
1109 | QString des = eve->description(); | 1110 | QString des = eve->description(); |
1110 | QString pref = "e"; | 1111 | QString pref = "e"; |
1111 | if ( toDelete->type() == "Todo" ) | 1112 | if ( toDelete->type() == "Todo" ) |
1112 | pref = "t"; | 1113 | pref = "t"; |
1113 | des += pref+ id + ","; | 1114 | des += pref+ id + ","; |
1114 | eve->setReadOnly( false ); | 1115 | eve->setReadOnly( false ); |
1115 | eve->setDescription( des ); | 1116 | eve->setDescription( des ); |
1116 | //qDebug("setdes %s ", des.latin1()); | 1117 | //qDebug("setdes %s ", des.latin1()); |
1117 | eve->setReadOnly( true ); | 1118 | eve->setReadOnly( true ); |
1118 | } | 1119 | } |
1119 | eve = lastSync.next(); | 1120 | eve = lastSync.next(); |
1120 | } | 1121 | } |
1121 | 1122 | ||
1122 | } | 1123 | } |
1123 | void CalendarView::checkExternalId( Incidence * inc ) | 1124 | void CalendarView::checkExternalId( Incidence * inc ) |
1124 | { | 1125 | { |
1125 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 1126 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
1126 | checkExternSyncEvent( lastSync, inc ); | 1127 | checkExternSyncEvent( lastSync, inc ); |
1127 | 1128 | ||
1128 | } | 1129 | } |
1129 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 1130 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
1130 | { | 1131 | { |
1131 | bool syncOK = true; | 1132 | bool syncOK = true; |
1132 | int addedEvent = 0; | 1133 | int addedEvent = 0; |
1133 | int addedEventR = 0; | 1134 | int addedEventR = 0; |
1134 | int deletedEventR = 0; | 1135 | int deletedEventR = 0; |
1135 | int deletedEventL = 0; | 1136 | int deletedEventL = 0; |
1136 | int changedLocal = 0; | 1137 | int changedLocal = 0; |
1137 | int changedRemote = 0; | 1138 | int changedRemote = 0; |
1138 | int filteredIN = 0; | 1139 | int filteredIN = 0; |
1139 | int filteredOUT = 0; | 1140 | int filteredOUT = 0; |
1140 | //QPtrList<Event> el = local->rawEvents(); | 1141 | //QPtrList<Event> el = local->rawEvents(); |
1141 | Event* eventR; | 1142 | Event* eventR; |
1142 | QString uid; | 1143 | QString uid; |
1143 | int take; | 1144 | int take; |
1144 | Event* eventL; | 1145 | Event* eventL; |
1145 | Event* eventRSync; | 1146 | Event* eventRSync; |
1146 | Event* eventLSync; | 1147 | Event* eventLSync; |
1147 | clearAllViews(); | 1148 | clearAllViews(); |
1148 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 1149 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
1149 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 1150 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
1150 | bool fullDateRange = false; | 1151 | bool fullDateRange = false; |
1151 | local->resetTempSyncStat(); | 1152 | local->resetTempSyncStat(); |
1152 | mLastCalendarSync = QDateTime::currentDateTime(); | 1153 | mLastCalendarSync = QDateTime::currentDateTime(); |
1153 | if ( mSyncManager->syncWithDesktop() ) { | 1154 | if ( mSyncManager->syncWithDesktop() ) { |
1154 | remote->resetPilotStat(1); | 1155 | remote->resetPilotStat(1); |
1155 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1156 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1156 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 1157 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
1157 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 1158 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
1158 | } else { | 1159 | } else { |
1159 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 1160 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
1160 | } | 1161 | } |
1161 | } | 1162 | } |
1162 | QDateTime modifiedCalendar = mLastCalendarSync; | 1163 | QDateTime modifiedCalendar = mLastCalendarSync; |
1163 | eventLSync = getLastSyncEvent(); | 1164 | eventLSync = getLastSyncEvent(); |
1164 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 1165 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
1165 | if ( eventR ) { | 1166 | if ( eventR ) { |
1166 | eventRSync = (Event*) eventR->clone(); | 1167 | eventRSync = (Event*) eventR->clone(); |
1167 | remote->deleteEvent(eventR ); | 1168 | remote->deleteEvent(eventR ); |
1168 | 1169 | ||
1169 | } else { | 1170 | } else { |
1170 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 1171 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
1171 | eventRSync = (Event*)eventLSync->clone(); | 1172 | eventRSync = (Event*)eventLSync->clone(); |
1172 | } else { | 1173 | } else { |
1173 | fullDateRange = true; | 1174 | fullDateRange = true; |
1174 | eventRSync = new Event(); | 1175 | eventRSync = new Event(); |
1175 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 1176 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
1176 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 1177 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
1177 | eventRSync->setDtStart( mLastCalendarSync ); | 1178 | eventRSync->setDtStart( mLastCalendarSync ); |
1178 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1179 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1179 | eventRSync->setCategories( i18n("SyncEvent") ); | 1180 | eventRSync->setCategories( i18n("SyncEvent") ); |
1180 | } | 1181 | } |
1181 | } | 1182 | } |
1182 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 1183 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
1183 | fullDateRange = true; | 1184 | fullDateRange = true; |
1184 | 1185 | ||
1185 | if ( ! fullDateRange ) { | 1186 | if ( ! fullDateRange ) { |
1186 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 1187 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
1187 | 1188 | ||
1188 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 1189 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
1189 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 1190 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
1190 | fullDateRange = true; | 1191 | fullDateRange = true; |
1191 | } | 1192 | } |
1192 | } | 1193 | } |
1193 | if ( mSyncManager->syncWithDesktop() ) { | 1194 | if ( mSyncManager->syncWithDesktop() ) { |
1194 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 1195 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
1195 | } | 1196 | } |
1196 | if ( fullDateRange ) | 1197 | if ( fullDateRange ) |
1197 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 1198 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
1198 | else | 1199 | else |
1199 | mLastCalendarSync = eventLSync->dtStart(); | 1200 | mLastCalendarSync = eventLSync->dtStart(); |
1200 | // for resyncing if own file has changed | 1201 | // for resyncing if own file has changed |
1201 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 1202 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
1202 | mLastCalendarSync = loadedFileVersion; | 1203 | mLastCalendarSync = loadedFileVersion; |
1203 | //qDebug("setting mLastCalendarSync "); | 1204 | //qDebug("setting mLastCalendarSync "); |
1204 | } | 1205 | } |
1205 | //qDebug("*************************** "); | 1206 | //qDebug("*************************** "); |
1206 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1207 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1207 | QPtrList<Incidence> er = remote->rawIncidences(); | 1208 | QPtrList<Incidence> er = remote->rawIncidences(); |
1208 | Incidence* inR = er.first(); | 1209 | Incidence* inR = er.first(); |
1209 | Incidence* inL; | 1210 | Incidence* inL; |
1210 | QProgressBar bar( er.count(),0 ); | 1211 | QProgressBar bar( er.count(),0 ); |
1211 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1212 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1212 | 1213 | ||
1213 | // ************** setting up filter ************* | 1214 | // ************** setting up filter ************* |
1214 | CalFilter *filterIN = 0; | 1215 | CalFilter *filterIN = 0; |
1215 | CalFilter *filterOUT = 0; | 1216 | CalFilter *filterOUT = 0; |
1216 | CalFilter *filter = mFilters.first(); | 1217 | CalFilter *filter = mFilters.first(); |
1217 | while(filter) { | 1218 | while(filter) { |
1218 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1219 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1219 | filterIN = filter; | 1220 | filterIN = filter; |
1220 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1221 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1221 | filterOUT = filter; | 1222 | filterOUT = filter; |
1222 | filter = mFilters.next(); | 1223 | filter = mFilters.next(); |
1223 | } | 1224 | } |
1224 | int w = 300; | 1225 | int w = 300; |
1225 | if ( QApplication::desktop()->width() < 320 ) | 1226 | if ( QApplication::desktop()->width() < 320 ) |
1226 | w = 220; | 1227 | w = 220; |
1227 | int h = bar.sizeHint().height() ; | 1228 | int h = bar.sizeHint().height() ; |
1228 | int dw = QApplication::desktop()->width(); | 1229 | int dw = QApplication::desktop()->width(); |
1229 | int dh = QApplication::desktop()->height(); | 1230 | int dh = QApplication::desktop()->height(); |
1230 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1231 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1231 | bar.show(); | 1232 | bar.show(); |
1232 | int modulo = (er.count()/10)+1; | 1233 | int modulo = (er.count()/10)+1; |
1233 | int incCounter = 0; | 1234 | int incCounter = 0; |
1234 | while ( inR ) { | 1235 | while ( inR ) { |
1235 | if ( ! bar.isVisible() ) | 1236 | if ( ! bar.isVisible() ) |
1236 | return false; | 1237 | return false; |
1237 | if ( incCounter % modulo == 0 ) | 1238 | if ( incCounter % modulo == 0 ) |
1238 | bar.setProgress( incCounter ); | 1239 | bar.setProgress( incCounter ); |
1239 | ++incCounter; | 1240 | ++incCounter; |
1240 | uid = inR->uid(); | 1241 | uid = inR->uid(); |
1241 | bool skipIncidence = false; | 1242 | bool skipIncidence = false; |
1242 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1243 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1243 | skipIncidence = true; | 1244 | skipIncidence = true; |
1244 | QString idS; | 1245 | QString idS; |
1245 | qApp->processEvents(); | 1246 | qApp->processEvents(); |
1246 | if ( !skipIncidence ) { | 1247 | if ( !skipIncidence ) { |
1247 | inL = local->incidence( uid ); | 1248 | inL = local->incidence( uid ); |
1248 | if ( inL ) { // maybe conflict - same uid in both calendars | 1249 | if ( inL ) { // maybe conflict - same uid in both calendars |
1249 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1250 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1250 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1251 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1251 | if ( take == 3 ) | 1252 | if ( take == 3 ) |
1252 | return false; | 1253 | return false; |
1253 | if ( take == 1 ) {// take local ********************** | 1254 | if ( take == 1 ) {// take local ********************** |
1254 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1255 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1255 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1256 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1256 | else | 1257 | else |
1257 | idS = inR->IDStr(); | 1258 | idS = inR->IDStr(); |
1258 | remote->deleteIncidence( inR ); | 1259 | remote->deleteIncidence( inR ); |
1259 | inR = inL->clone(); | 1260 | inR = inL->clone(); |
1260 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1261 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1261 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1262 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1262 | inR->setIDStr( idS ); | 1263 | inR->setIDStr( idS ); |
1263 | remote->addIncidence( inR ); | 1264 | remote->addIncidence( inR ); |
1264 | if ( mSyncManager->syncWithDesktop() ) | 1265 | if ( mSyncManager->syncWithDesktop() ) |
1265 | inR->setPilotId( 2 ); | 1266 | inR->setPilotId( 2 ); |
1266 | ++changedRemote; | 1267 | ++changedRemote; |
1267 | } else {// take remote ********************** | 1268 | } else {// take remote ********************** |
1268 | idS = inL->IDStr(); | 1269 | idS = inL->IDStr(); |
1269 | int pid = inL->pilotId(); | 1270 | int pid = inL->pilotId(); |
1270 | local->deleteIncidence( inL ); | 1271 | local->deleteIncidence( inL ); |
1271 | inL = inR->clone(); | 1272 | inL = inR->clone(); |
1272 | if ( mSyncManager->syncWithDesktop() ) | 1273 | if ( mSyncManager->syncWithDesktop() ) |
1273 | inL->setPilotId( pid ); | 1274 | inL->setPilotId( pid ); |
1274 | inL->setIDStr( idS ); | 1275 | inL->setIDStr( idS ); |
1275 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1276 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1276 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1277 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1277 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1278 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1278 | } | 1279 | } |
1279 | local->addIncidence( inL ); | 1280 | local->addIncidence( inL ); |
1280 | ++changedLocal; | 1281 | ++changedLocal; |
1281 | } | 1282 | } |
1282 | } | 1283 | } |
1283 | } else { // no conflict ********** add or delete remote | 1284 | } else { // no conflict ********** add or delete remote |
1284 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1285 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1285 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1286 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1286 | QString des = eventLSync->description(); | 1287 | QString des = eventLSync->description(); |
1287 | QString pref = "e"; | 1288 | QString pref = "e"; |
1288 | if ( inR->type() == "Todo" ) | 1289 | if ( inR->type() == "Todo" ) |
1289 | pref = "t"; | 1290 | pref = "t"; |
1290 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1291 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1291 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1292 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1292 | //remote->deleteIncidence( inR ); | 1293 | //remote->deleteIncidence( inR ); |
1293 | ++deletedEventR; | 1294 | ++deletedEventR; |
1294 | } else { | 1295 | } else { |
1295 | inR->setLastModified( modifiedCalendar ); | 1296 | inR->setLastModified( modifiedCalendar ); |
1296 | inL = inR->clone(); | 1297 | inL = inR->clone(); |
1297 | inL->setIDStr( ":" ); | 1298 | inL->setIDStr( ":" ); |
1298 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1299 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1299 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1300 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1300 | local->addIncidence( inL ); | 1301 | local->addIncidence( inL ); |
1301 | ++addedEvent; | 1302 | ++addedEvent; |
1302 | 1303 | ||
1303 | } | 1304 | } |
1304 | } else { | 1305 | } else { |
1305 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1306 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1306 | inR->setLastModified( modifiedCalendar ); | 1307 | inR->setLastModified( modifiedCalendar ); |
1307 | inL = inR->clone(); | 1308 | inL = inR->clone(); |
1308 | inL->setIDStr( ":" ); | 1309 | inL->setIDStr( ":" ); |
1309 | local->addIncidence( inL ); | 1310 | local->addIncidence( inL ); |
1310 | ++addedEvent; | 1311 | ++addedEvent; |
1311 | 1312 | ||
1312 | } else { | 1313 | } else { |
1313 | checkExternSyncEvent(eventRSyncSharp, inR); | 1314 | checkExternSyncEvent(eventRSyncSharp, inR); |
1314 | remote->deleteIncidence( inR ); | 1315 | remote->deleteIncidence( inR ); |
1315 | ++deletedEventR; | 1316 | ++deletedEventR; |
1316 | } | 1317 | } |
1317 | } | 1318 | } |
1318 | } else { | 1319 | } else { |
1319 | ++filteredIN; | 1320 | ++filteredIN; |
1320 | } | 1321 | } |
1321 | } | 1322 | } |
1322 | } | 1323 | } |
1323 | inR = er.next(); | 1324 | inR = er.next(); |
1324 | } | 1325 | } |
1325 | QPtrList<Incidence> el = local->rawIncidences(); | 1326 | QPtrList<Incidence> el = local->rawIncidences(); |
1326 | inL = el.first(); | 1327 | inL = el.first(); |
1327 | modulo = (el.count()/10)+1; | 1328 | modulo = (el.count()/10)+1; |
1328 | bar.setCaption (i18n("Add / remove events") ); | 1329 | bar.setCaption (i18n("Add / remove events") ); |
1329 | bar.setTotalSteps ( el.count() ) ; | 1330 | bar.setTotalSteps ( el.count() ) ; |
1330 | bar.show(); | 1331 | bar.show(); |
1331 | incCounter = 0; | 1332 | incCounter = 0; |
1332 | 1333 | ||
1333 | while ( inL ) { | 1334 | while ( inL ) { |
1334 | 1335 | ||
1335 | qApp->processEvents(); | 1336 | qApp->processEvents(); |
1336 | if ( ! bar.isVisible() ) | 1337 | if ( ! bar.isVisible() ) |
1337 | return false; | 1338 | return false; |
1338 | if ( incCounter % modulo == 0 ) | 1339 | if ( incCounter % modulo == 0 ) |
1339 | bar.setProgress( incCounter ); | 1340 | bar.setProgress( incCounter ); |
1340 | ++incCounter; | 1341 | ++incCounter; |
1341 | uid = inL->uid(); | 1342 | uid = inL->uid(); |
1342 | bool skipIncidence = false; | 1343 | bool skipIncidence = false; |
1343 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1344 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1344 | skipIncidence = true; | 1345 | skipIncidence = true; |
1345 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1346 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1346 | skipIncidence = true; | 1347 | skipIncidence = true; |
1347 | if ( !skipIncidence ) { | 1348 | if ( !skipIncidence ) { |
1348 | inR = remote->incidence( uid ); | 1349 | inR = remote->incidence( uid ); |
1349 | if ( ! inR ) { | 1350 | if ( ! inR ) { |
1350 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1351 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1351 | // no conflict ********** add or delete local | 1352 | // no conflict ********** add or delete local |
1352 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1353 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1353 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1354 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1354 | checkExternSyncEvent(eventLSyncSharp, inL); | 1355 | checkExternSyncEvent(eventLSyncSharp, inL); |
1355 | local->deleteIncidence( inL ); | 1356 | local->deleteIncidence( inL ); |
1356 | ++deletedEventL; | 1357 | ++deletedEventL; |
1357 | } else { | 1358 | } else { |
1358 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1359 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1359 | inL->removeID(mCurrentSyncDevice ); | 1360 | inL->removeID(mCurrentSyncDevice ); |
1360 | ++addedEventR; | 1361 | ++addedEventR; |
1361 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1362 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1362 | inL->setLastModified( modifiedCalendar ); | 1363 | inL->setLastModified( modifiedCalendar ); |
1363 | inR = inL->clone(); | 1364 | inR = inL->clone(); |
1364 | inR->setIDStr( ":" ); | 1365 | inR->setIDStr( ":" ); |
1365 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1366 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1366 | remote->addIncidence( inR ); | 1367 | remote->addIncidence( inR ); |
1367 | } | 1368 | } |
1368 | } | 1369 | } |
1369 | } else { | 1370 | } else { |
1370 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1371 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1371 | checkExternSyncEvent(eventLSyncSharp, inL); | 1372 | checkExternSyncEvent(eventLSyncSharp, inL); |
1372 | local->deleteIncidence( inL ); | 1373 | local->deleteIncidence( inL ); |
1373 | ++deletedEventL; | 1374 | ++deletedEventL; |
1374 | } else { | 1375 | } else { |
1375 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1376 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1376 | ++addedEventR; | 1377 | ++addedEventR; |
1377 | inL->setLastModified( modifiedCalendar ); | 1378 | inL->setLastModified( modifiedCalendar ); |
1378 | inR = inL->clone(); | 1379 | inR = inL->clone(); |
1379 | inR->setIDStr( ":" ); | 1380 | inR->setIDStr( ":" ); |
1380 | remote->addIncidence( inR ); | 1381 | remote->addIncidence( inR ); |
1381 | } | 1382 | } |
1382 | } | 1383 | } |
1383 | } | 1384 | } |
1384 | } else { | 1385 | } else { |
1385 | ++filteredOUT; | 1386 | ++filteredOUT; |
1386 | } | 1387 | } |
1387 | } | 1388 | } |
1388 | } | 1389 | } |
1389 | inL = el.next(); | 1390 | inL = el.next(); |
1390 | } | 1391 | } |
1391 | int delFut = 0; | 1392 | int delFut = 0; |
1392 | int remRem = 0; | 1393 | int remRem = 0; |
1393 | if ( mSyncManager->mWriteBackInFuture ) { | 1394 | if ( mSyncManager->mWriteBackInFuture ) { |
1394 | er = remote->rawIncidences(); | 1395 | er = remote->rawIncidences(); |
1395 | remRem = er.count(); | 1396 | remRem = er.count(); |
1396 | inR = er.first(); | 1397 | inR = er.first(); |
1397 | QDateTime dt; | 1398 | QDateTime dt; |
1398 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1399 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1399 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1400 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1400 | while ( inR ) { | 1401 | while ( inR ) { |
1401 | if ( inR->type() == "Todo" ) { | 1402 | if ( inR->type() == "Todo" ) { |
1402 | Todo * t = (Todo*)inR; | 1403 | Todo * t = (Todo*)inR; |
1403 | if ( t->hasDueDate() ) | 1404 | if ( t->hasDueDate() ) |
1404 | dt = t->dtDue(); | 1405 | dt = t->dtDue(); |
1405 | else | 1406 | else |
1406 | dt = cur.addSecs( 62 ); | 1407 | dt = cur.addSecs( 62 ); |
1407 | } | 1408 | } |
1408 | else if (inR->type() == "Event" ) { | 1409 | else if (inR->type() == "Event" ) { |
1409 | bool ok; | 1410 | bool ok; |
1410 | dt = inR->getNextOccurence( cur, &ok ); | 1411 | dt = inR->getNextOccurence( cur, &ok ); |
1411 | if ( !ok ) | 1412 | if ( !ok ) |
1412 | dt = cur.addSecs( -62 ); | 1413 | dt = cur.addSecs( -62 ); |
1413 | } | 1414 | } |
1414 | else | 1415 | else |
1415 | dt = inR->dtStart(); | 1416 | dt = inR->dtStart(); |
1416 | if ( dt < cur || dt > end ) { | 1417 | if ( dt < cur || dt > end ) { |
1417 | remote->deleteIncidence( inR ); | 1418 | remote->deleteIncidence( inR ); |
1418 | ++delFut; | 1419 | ++delFut; |
1419 | } | 1420 | } |
1420 | inR = er.next(); | 1421 | inR = er.next(); |
1421 | } | 1422 | } |
1422 | } | 1423 | } |
1423 | bar.hide(); | 1424 | bar.hide(); |
1424 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1425 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1425 | eventLSync->setReadOnly( false ); | 1426 | eventLSync->setReadOnly( false ); |
1426 | eventLSync->setDtStart( mLastCalendarSync ); | 1427 | eventLSync->setDtStart( mLastCalendarSync ); |
1427 | eventRSync->setDtStart( mLastCalendarSync ); | 1428 | eventRSync->setDtStart( mLastCalendarSync ); |
1428 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1429 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1429 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1430 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1430 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1431 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1431 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1432 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1432 | eventLSync->setReadOnly( true ); | 1433 | eventLSync->setReadOnly( true ); |
1433 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1434 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1434 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1435 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1435 | remote->addEvent( eventRSync ); | 1436 | remote->addEvent( eventRSync ); |
1436 | else | 1437 | else |
1437 | delete eventRSync; | 1438 | delete eventRSync; |
1438 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1439 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1439 | QString mes; | 1440 | QString mes; |
1440 | 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 %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); | 1441 | 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 %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); |
1441 | QString delmess; | 1442 | QString delmess; |
1442 | if ( delFut ) { | 1443 | if ( delFut ) { |
1443 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); | 1444 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1444 | mes += delmess; | 1445 | mes += delmess; |
1445 | } | 1446 | } |
1446 | mes = i18n("Local calendar changed!\n") +mes; | 1447 | mes = i18n("Local calendar changed!\n") +mes; |
1447 | mCalendar->checkAlarmForIncidence( 0, true ); | 1448 | mCalendar->checkAlarmForIncidence( 0, true ); |
1448 | qDebug( mes ); | 1449 | qDebug( mes ); |
1449 | if ( mSyncManager->mShowSyncSummary ) { | 1450 | if ( mSyncManager->mShowSyncSummary ) { |
1450 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1451 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1451 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1452 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1452 | qDebug("KO: WB cancelled "); | 1453 | qDebug("KO: WB cancelled "); |
1453 | mSyncManager->mWriteBackFile = false; | 1454 | mSyncManager->mWriteBackFile = false; |
1454 | return syncOK; | 1455 | return syncOK; |
1455 | } | 1456 | } |
1456 | } | 1457 | } |
1457 | return syncOK; | 1458 | return syncOK; |
1458 | } | 1459 | } |
1459 | 1460 | ||
1460 | void CalendarView::setSyncDevice( QString s ) | 1461 | void CalendarView::setSyncDevice( QString s ) |
1461 | { | 1462 | { |
1462 | mCurrentSyncDevice= s; | 1463 | mCurrentSyncDevice= s; |
1463 | } | 1464 | } |
1464 | void CalendarView::setSyncName( QString s ) | 1465 | void CalendarView::setSyncName( QString s ) |
1465 | { | 1466 | { |
1466 | mCurrentSyncName= s; | 1467 | mCurrentSyncName= s; |
1467 | } | 1468 | } |
1468 | bool CalendarView::syncCalendar(QString filename, int mode) | 1469 | bool CalendarView::syncCalendar(QString filename, int mode) |
1469 | { | 1470 | { |
1470 | //qDebug("syncCalendar %s ", filename.latin1()); | 1471 | //qDebug("syncCalendar %s ", filename.latin1()); |
1471 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1472 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1472 | CalendarLocal* calendar = new CalendarLocal(); | 1473 | CalendarLocal* calendar = new CalendarLocal(); |
1473 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1474 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1474 | FileStorage* storage = new FileStorage( calendar ); | 1475 | FileStorage* storage = new FileStorage( calendar ); |
1475 | bool syncOK = false; | 1476 | bool syncOK = false; |
1476 | storage->setFileName( filename ); | 1477 | storage->setFileName( filename ); |
1477 | // qDebug("loading ... "); | 1478 | // qDebug("loading ... "); |
1478 | if ( storage->load() ) { | 1479 | if ( storage->load() ) { |
1479 | getEventViewerDialog()->setSyncMode( true ); | 1480 | getEventViewerDialog()->setSyncMode( true ); |
1480 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1481 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1481 | getEventViewerDialog()->setSyncMode( false ); | 1482 | getEventViewerDialog()->setSyncMode( false ); |
1482 | if ( syncOK ) { | 1483 | if ( syncOK ) { |
1483 | if ( mSyncManager->mWriteBackFile ) | 1484 | if ( mSyncManager->mWriteBackFile ) |
1484 | { | 1485 | { |
1485 | storage->setSaveFormat( new ICalFormat() ); | 1486 | storage->setSaveFormat( new ICalFormat() ); |
1486 | storage->save(); | 1487 | storage->save(); |
1487 | } | 1488 | } |
1488 | } | 1489 | } |
1489 | setModified( true ); | 1490 | setModified( true ); |
1490 | } | 1491 | } |
1491 | delete storage; | 1492 | delete storage; |
1492 | delete calendar; | 1493 | delete calendar; |
1493 | if ( syncOK ) | 1494 | if ( syncOK ) |
1494 | updateView(); | 1495 | updateView(); |
1495 | return syncOK; | 1496 | return syncOK; |
1496 | } | 1497 | } |
1497 | 1498 | ||
1498 | void CalendarView::syncExternal( int mode ) | 1499 | void CalendarView::syncExternal( int mode ) |
1499 | { | 1500 | { |
1500 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1501 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1501 | 1502 | ||
1502 | qApp->processEvents(); | 1503 | qApp->processEvents(); |
1503 | CalendarLocal* calendar = new CalendarLocal(); | 1504 | CalendarLocal* calendar = new CalendarLocal(); |
1504 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1505 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1505 | bool syncOK = false; | 1506 | bool syncOK = false; |
1506 | bool loadSuccess = false; | 1507 | bool loadSuccess = false; |
1507 | PhoneFormat* phoneFormat = 0; | 1508 | PhoneFormat* phoneFormat = 0; |
1508 | emit tempDisableBR(true); | 1509 | emit tempDisableBR(true); |
1509 | #ifndef DESKTOP_VERSION | 1510 | #ifndef DESKTOP_VERSION |
1510 | SharpFormat* sharpFormat = 0; | 1511 | SharpFormat* sharpFormat = 0; |
1511 | if ( mode == 0 ) { // sharp | 1512 | if ( mode == 0 ) { // sharp |
1512 | sharpFormat = new SharpFormat () ; | 1513 | sharpFormat = new SharpFormat () ; |
1513 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1514 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1514 | 1515 | ||
1515 | } else | 1516 | } else |
1516 | #endif | 1517 | #endif |
1517 | if ( mode == 1 ) { // phone | 1518 | if ( mode == 1 ) { // phone |
1518 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1519 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1519 | mSyncManager->mPhoneDevice, | 1520 | mSyncManager->mPhoneDevice, |
1520 | mSyncManager->mPhoneConnection, | 1521 | mSyncManager->mPhoneConnection, |
1521 | mSyncManager->mPhoneModel); | 1522 | mSyncManager->mPhoneModel); |
1522 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1523 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1523 | 1524 | ||
1524 | } else { | 1525 | } else { |
1525 | emit tempDisableBR(false); | 1526 | emit tempDisableBR(false); |
1526 | return; | 1527 | return; |
1527 | } | 1528 | } |
1528 | if ( loadSuccess ) { | 1529 | if ( loadSuccess ) { |
1529 | getEventViewerDialog()->setSyncMode( true ); | 1530 | getEventViewerDialog()->setSyncMode( true ); |
1530 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1531 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1531 | getEventViewerDialog()->setSyncMode( false ); | 1532 | getEventViewerDialog()->setSyncMode( false ); |
1532 | qApp->processEvents(); | 1533 | qApp->processEvents(); |
1533 | if ( syncOK ) { | 1534 | if ( syncOK ) { |
1534 | if ( mSyncManager->mWriteBackFile ) | 1535 | if ( mSyncManager->mWriteBackFile ) |
1535 | { | 1536 | { |
1536 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1537 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1537 | Incidence* inc = iL.first(); | 1538 | Incidence* inc = iL.first(); |
1538 | if ( phoneFormat ) { | 1539 | if ( phoneFormat ) { |
1539 | while ( inc ) { | 1540 | while ( inc ) { |
1540 | inc->removeID(mCurrentSyncDevice); | 1541 | inc->removeID(mCurrentSyncDevice); |
1541 | inc = iL.next(); | 1542 | inc = iL.next(); |
1542 | } | 1543 | } |
1543 | } | 1544 | } |
1544 | #ifndef DESKTOP_VERSION | 1545 | #ifndef DESKTOP_VERSION |
1545 | if ( sharpFormat ) | 1546 | if ( sharpFormat ) |
1546 | sharpFormat->save(calendar); | 1547 | sharpFormat->save(calendar); |
1547 | #endif | 1548 | #endif |
1548 | if ( phoneFormat ) | 1549 | if ( phoneFormat ) |
1549 | phoneFormat->save(calendar); | 1550 | phoneFormat->save(calendar); |
1550 | iL = calendar->rawIncidences(); | 1551 | iL = calendar->rawIncidences(); |
1551 | inc = iL.first(); | 1552 | inc = iL.first(); |
1552 | Incidence* loc; | 1553 | Incidence* loc; |
1553 | while ( inc ) { | 1554 | while ( inc ) { |
1554 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1555 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1555 | loc = mCalendar->incidence(inc->uid() ); | 1556 | loc = mCalendar->incidence(inc->uid() ); |
1556 | if ( loc ) { | 1557 | if ( loc ) { |
1557 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1558 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1558 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1559 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1559 | } | 1560 | } |
1560 | } | 1561 | } |
1561 | inc = iL.next(); | 1562 | inc = iL.next(); |
1562 | } | 1563 | } |
1563 | Incidence* lse = getLastSyncEvent(); | 1564 | Incidence* lse = getLastSyncEvent(); |
1564 | if ( lse ) { | 1565 | if ( lse ) { |
1565 | lse->setReadOnly( false ); | 1566 | lse->setReadOnly( false ); |
1566 | lse->setDescription( "" ); | 1567 | lse->setDescription( "" ); |
1567 | lse->setReadOnly( true ); | 1568 | lse->setReadOnly( true ); |
1568 | } | 1569 | } |
1569 | } | 1570 | } |
1570 | } else { | 1571 | } else { |
1571 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1572 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1572 | } | 1573 | } |
1573 | setModified( true ); | 1574 | setModified( true ); |
1574 | } else { | 1575 | } else { |
1575 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1576 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1576 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1577 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1577 | question, i18n("Ok")) ; | 1578 | question, i18n("Ok")) ; |
1578 | 1579 | ||
1579 | } | 1580 | } |
1580 | delete calendar; | 1581 | delete calendar; |
1581 | updateView(); | 1582 | updateView(); |
1582 | emit tempDisableBR(false); | 1583 | emit tempDisableBR(false); |
1583 | return ;//syncOK; | 1584 | return ;//syncOK; |
1584 | 1585 | ||
1585 | } | 1586 | } |
1586 | 1587 | ||
1587 | bool CalendarView::importBday() | 1588 | bool CalendarView::importBday() |
1588 | { | 1589 | { |
1589 | #ifndef KORG_NOKABC | 1590 | #ifndef KORG_NOKABC |
1590 | 1591 | ||
1591 | #ifdef DESKTOP_VERSION | 1592 | #ifdef DESKTOP_VERSION |
1592 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1593 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1593 | KABC::AddressBook::Iterator it; | 1594 | KABC::AddressBook::Iterator it; |
1594 | int count = 0; | 1595 | int count = 0; |
1595 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1596 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1596 | ++count; | 1597 | ++count; |
1597 | } | 1598 | } |
1598 | QProgressBar bar(count,0 ); | 1599 | QProgressBar bar(count,0 ); |
1599 | int w = 300; | 1600 | int w = 300; |
1600 | if ( QApplication::desktop()->width() < 320 ) | 1601 | if ( QApplication::desktop()->width() < 320 ) |
1601 | w = 220; | 1602 | w = 220; |
1602 | int h = bar.sizeHint().height() ; | 1603 | int h = bar.sizeHint().height() ; |
1603 | int dw = QApplication::desktop()->width(); | 1604 | int dw = QApplication::desktop()->width(); |
1604 | int dh = QApplication::desktop()->height(); | 1605 | int dh = QApplication::desktop()->height(); |
1605 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1606 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1606 | bar.show(); | 1607 | bar.show(); |
1607 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1608 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1608 | qApp->processEvents(); | 1609 | qApp->processEvents(); |
1609 | count = 0; | 1610 | count = 0; |
1610 | int addCount = 0; | 1611 | int addCount = 0; |
1611 | KCal::Attendee* a = 0; | 1612 | KCal::Attendee* a = 0; |
1612 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1613 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1613 | if ( ! bar.isVisible() ) | 1614 | if ( ! bar.isVisible() ) |
1614 | return false; | 1615 | return false; |
1615 | bar.setProgress( count++ ); | 1616 | bar.setProgress( count++ ); |
1616 | qApp->processEvents(); | 1617 | qApp->processEvents(); |
1617 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1618 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1618 | if ( (*it).birthday().date().isValid() ){ | 1619 | if ( (*it).birthday().date().isValid() ){ |
1619 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1620 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1620 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1621 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1621 | ++addCount; | 1622 | ++addCount; |
1622 | } | 1623 | } |
1623 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1624 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1624 | if ( anni.isValid() ){ | 1625 | if ( anni.isValid() ){ |
1625 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1626 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1626 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1627 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1627 | ++addCount; | 1628 | ++addCount; |
1628 | } | 1629 | } |
1629 | } | 1630 | } |
1630 | updateView(); | 1631 | updateView(); |
1631 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1632 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1632 | #else //DESKTOP_VERSION | 1633 | #else //DESKTOP_VERSION |
1633 | 1634 | ||
1634 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1635 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1635 | // the result should now arrive through method insertBirthdays | 1636 | // the result should now arrive through method insertBirthdays |
1636 | 1637 | ||
1637 | #endif //DESKTOP_VERSION | 1638 | #endif //DESKTOP_VERSION |
1638 | 1639 | ||
1639 | #endif //KORG_NOKABC | 1640 | #endif //KORG_NOKABC |
1640 | 1641 | ||
1641 | 1642 | ||
1642 | return true; | 1643 | return true; |
1643 | } | 1644 | } |
1644 | 1645 | ||
1645 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1646 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1646 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1647 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1647 | const QStringList& anniversaryList, const QStringList& realNameList, | 1648 | const QStringList& anniversaryList, const QStringList& realNameList, |
1648 | const QStringList& emailList, const QStringList& assembledNameList, | 1649 | const QStringList& emailList, const QStringList& assembledNameList, |
1649 | const QStringList& uidList) | 1650 | const QStringList& uidList) |
1650 | { | 1651 | { |
1651 | //qDebug("KO::CalendarView::insertBirthdays"); | 1652 | //qDebug("KO::CalendarView::insertBirthdays"); |
1652 | if (uid == this->name()) | 1653 | if (uid == this->name()) |
1653 | { | 1654 | { |
1654 | int count = birthdayList.count(); | 1655 | int count = birthdayList.count(); |
1655 | int addCount = 0; | 1656 | int addCount = 0; |
1656 | KCal::Attendee* a = 0; | 1657 | KCal::Attendee* a = 0; |
1657 | 1658 | ||
1658 | //qDebug("CalView 1 %i", count); | 1659 | //qDebug("CalView 1 %i", count); |
1659 | 1660 | ||
1660 | QProgressBar bar(count,0 ); | 1661 | QProgressBar bar(count,0 ); |
1661 | int w = 300; | 1662 | int w = 300; |
1662 | if ( QApplication::desktop()->width() < 320 ) | 1663 | if ( QApplication::desktop()->width() < 320 ) |
1663 | w = 220; | 1664 | w = 220; |
1664 | int h = bar.sizeHint().height() ; | 1665 | int h = bar.sizeHint().height() ; |
1665 | int dw = QApplication::desktop()->width(); | 1666 | int dw = QApplication::desktop()->width(); |
1666 | int dh = QApplication::desktop()->height(); | 1667 | int dh = QApplication::desktop()->height(); |
1667 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1668 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |