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 | |||
@@ -131,1025 +131,1026 @@ | |||
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() ) { |