summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koprefs.cpp6
-rw-r--r--korganizer/koprefs.h3
-rw-r--r--korganizer/mainwindow.cpp134
-rw-r--r--korganizer/mainwindow.h1
-rw-r--r--libkcal/phoneformat.cpp68
-rw-r--r--libkcal/phoneformat.h2
6 files changed, 188 insertions, 26 deletions
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp
index c28da9a..716a125 100644
--- a/korganizer/koprefs.cpp
+++ b/korganizer/koprefs.cpp
@@ -1,463 +1,469 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <time.h> 24#include <time.h>
25#ifndef _WIN32_ 25#ifndef _WIN32_
26#include <unistd.h> 26#include <unistd.h>
27#endif 27#endif
28#include <qdir.h> 28#include <qdir.h>
29#include <qtextstream.h> 29#include <qtextstream.h>
30#include <qtextcodec.h> 30#include <qtextcodec.h>
31#include <qstring.h> 31#include <qstring.h>
32#include <qregexp.h> 32#include <qregexp.h>
33#include <qfont.h> 33#include <qfont.h>
34#include <qcolor.h> 34#include <qcolor.h>
35#include <qstringlist.h> 35#include <qstringlist.h>
36#include <stdlib.h> 36#include <stdlib.h>
37 37
38#include <kglobal.h> 38#include <kglobal.h>
39#include <kconfig.h> 39#include <kconfig.h>
40#include <klocale.h> 40#include <klocale.h>
41#include <kdebug.h> 41#include <kdebug.h>
42#include <kemailsettings.h> 42#include <kemailsettings.h>
43#include <kstaticdeleter.h> 43#include <kstaticdeleter.h>
44#include <libkdepim/kpimglobalprefs.h> 44#include <libkdepim/kpimglobalprefs.h>
45 45
46#include "koprefs.h" 46#include "koprefs.h"
47#include "mainwindow.h" 47#include "mainwindow.h"
48 48
49const char *germanwords[][2] = { 49const char *germanwords[][2] = {
50#include "wordsgerman.h" 50#include "wordsgerman.h"
51 "", "" 51 "", ""
52}; 52};
53 53
54KOPrefs *KOPrefs::mInstance = 0; 54KOPrefs *KOPrefs::mInstance = 0;
55static KStaticDeleter<KOPrefs> insd; 55static KStaticDeleter<KOPrefs> insd;
56 56
57KOPrefs::KOPrefs() : 57KOPrefs::KOPrefs() :
58 KPimPrefs("korganizerrc") 58 KPimPrefs("korganizerrc")
59{ 59{
60 mCategoryColors.setAutoDelete(true); 60 mCategoryColors.setAutoDelete(true);
61 mLocaleDict = 0; 61 mLocaleDict = 0;
62 fillMailDefaults(); 62 fillMailDefaults();
63 mDefaultCategoryColor = QColor(175,210,255);//196,196,196); 63 mDefaultCategoryColor = QColor(175,210,255);//196,196,196);
64 QColor defaultHolidayColor = QColor(255,0,0); 64 QColor defaultHolidayColor = QColor(255,0,0);
65 QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); 65 QColor defaultHighlightColor = QColor(129,112,255);//64,64,255);
66 QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); 66 QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128);
67 QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); 67 QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160);
68 QColor defaultTodoDueTodayColor = QColor(255,220,100); 68 QColor defaultTodoDueTodayColor = QColor(255,220,100);
69 QColor defaultTodoOverdueColor = QColor(255,153,125); 69 QColor defaultTodoOverdueColor = QColor(255,153,125);
70 70
71 mTimeBarFont = QFont("helvetica",10);//,QFont::Bold); 71 mTimeBarFont = QFont("helvetica",10);//,QFont::Bold);
72 mDefaultViewFont = QFont("helvetica",10); 72 mDefaultViewFont = QFont("helvetica",10);
73 mDefaultMonthViewFont = QFont("helvetica",8); 73 mDefaultMonthViewFont = QFont("helvetica",8);
74 mMarcusBainsFont= QFont("helvetica",10); 74 mMarcusBainsFont= QFont("helvetica",10);
75 mDateNavigatorFont= QFont("helvetica",10, QFont::Bold); 75 mDateNavigatorFont= QFont("helvetica",10, QFont::Bold);
76 mEditBoxFont = QFont("helvetica",12); 76 mEditBoxFont = QFont("helvetica",12);
77 mJornalViewFont = QFont("helvetica",12); 77 mJornalViewFont = QFont("helvetica",12);
78 78
79 KPrefs::setCurrentGroup("General"); 79 KPrefs::setCurrentGroup("General");
80
81
82 addItemString("Ex2PhoneDevice",&mEx2PhoneDevice,"/dev/ircomm");
83 addItemString("Ex2PhoneConnection",&mEx2PhoneConnection,"irda");
84 addItemString("Ex2PhoneModel",&mEx2PhoneModel,"6310i");
85
80 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); 86 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
81 87
82 addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); 88 addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true);
83 addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); 89 addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true);
84 addItemBool("ShowIconSearch",&mShowIconSearch,true); 90 addItemBool("ShowIconSearch",&mShowIconSearch,true);
85 addItemBool("ShowIconList",&mShowIconList,true); 91 addItemBool("ShowIconList",&mShowIconList,true);
86 addItemBool("ShowIconDay1",&mShowIconDay1,true); 92 addItemBool("ShowIconDay1",&mShowIconDay1,true);
87 addItemBool("ShowIconDay5",&mShowIconDay5,true); 93 addItemBool("ShowIconDay5",&mShowIconDay5,true);
88 addItemBool("ShowIconDay7",&mShowIconDay7,true); 94 addItemBool("ShowIconDay7",&mShowIconDay7,true);
89 addItemBool("ShowIconMonth",&mShowIconMonth,true); 95 addItemBool("ShowIconMonth",&mShowIconMonth,true);
90 addItemBool("ShowIconTodoview",&mShowIconTodoview,true); 96 addItemBool("ShowIconTodoview",&mShowIconTodoview,true);
91 addItemBool("ShowIconBackFast",&mShowIconBackFast,true); 97 addItemBool("ShowIconBackFast",&mShowIconBackFast,true);
92 addItemBool("ShowIconBack",&mShowIconBack,true); 98 addItemBool("ShowIconBack",&mShowIconBack,true);
93 addItemBool("ShowIconToday",&mShowIconToday,true); 99 addItemBool("ShowIconToday",&mShowIconToday,true);
94 addItemBool("ShowIconForward",&mShowIconForward,true); 100 addItemBool("ShowIconForward",&mShowIconForward,true);
95 addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); 101 addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true);
96 addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,false); 102 addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,false);
97 addItemBool("ShowIconNextDays",&mShowIconNextDays,true); 103 addItemBool("ShowIconNextDays",&mShowIconNextDays,true);
98 addItemBool("ShowIconNext",&mShowIconNext,true); 104 addItemBool("ShowIconNext",&mShowIconNext,true);
99 addItemBool("ShowIconJournal",&mShowIconJournal,true); 105 addItemBool("ShowIconJournal",&mShowIconJournal,true);
100 addItemBool("ShowIconStretch",&mShowIconStretch,true); 106 addItemBool("ShowIconStretch",&mShowIconStretch,true);
101 addItemBool("LanguageChanged",&mLanguageChanged,false); 107 addItemBool("LanguageChanged",&mLanguageChanged,false);
102 108
103 addItemBool("AskForQuit",&mAskForQuit,false); 109 addItemBool("AskForQuit",&mAskForQuit,false);
104 110
105#ifndef DESKTOP_VERSION 111#ifndef DESKTOP_VERSION
106 addItemBool("ShowFullMenu",&mShowFullMenu,false); 112 addItemBool("ShowFullMenu",&mShowFullMenu,false);
107#else 113#else
108 addItemBool("ShowFullMenu",&mShowFullMenu,true); 114 addItemBool("ShowFullMenu",&mShowFullMenu,true);
109#endif 115#endif
110 addItemBool("ToolBarHor",&mToolBarHor, true ); 116 addItemBool("ToolBarHor",&mToolBarHor, true );
111 addItemBool("ToolBarUp",&mToolBarUp, false ); 117 addItemBool("ToolBarUp",&mToolBarUp, false );
112 addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); 118 addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false );
113 addItemInt("Whats Next Days",&mWhatsNextDays,3); 119 addItemInt("Whats Next Days",&mWhatsNextDays,3);
114 addItemInt("Whats Next Prios",&mWhatsNextPrios,1); 120 addItemInt("Whats Next Prios",&mWhatsNextPrios,1);
115 121
116 addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); 122 addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true);
117 addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); 123 addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true);
118 addItemInt("AllDay Size",&mAllDaySize,28); 124 addItemInt("AllDay Size",&mAllDaySize,28);
119 QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; 125 QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav";
120 addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); 126 addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm );
121 127
122 addItemStringList("LocationDefaults",&mLocationDefaults ); 128 addItemStringList("LocationDefaults",&mLocationDefaults );
123 addItemStringList("EventSummary User",&mEventSummaryUser); 129 addItemStringList("EventSummary User",&mEventSummaryUser);
124 addItemStringList("TodoSummary User",&mTodoSummaryUser); 130 addItemStringList("TodoSummary User",&mTodoSummaryUser);
125 131
126 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); 132 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
127 addItemBool("Enable Project View",&mEnableProjectView,false); 133 addItemBool("Enable Project View",&mEnableProjectView,false);
128 addItemBool("Auto Save",&mAutoSave,false); 134 addItemBool("Auto Save",&mAutoSave,false);
129 addItemInt("Auto Save Interval",&mAutoSaveInterval,3); 135 addItemInt("Auto Save Interval",&mAutoSaveInterval,3);
130 addItemBool("Confirm Deletes",&mConfirm,true); 136 addItemBool("Confirm Deletes",&mConfirm,true);
131 addItemString("Archive File",&mArchiveFile); 137 addItemString("Archive File",&mArchiveFile);
132 addItemString("Html Export File",&mHtmlExportFile, 138 addItemString("Html Export File",&mHtmlExportFile,
133 QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); 139 QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html"));
134 addItemBool("Html With Save",&mHtmlWithSave,false); 140 addItemBool("Html With Save",&mHtmlWithSave,false);
135 141
136 KPrefs::setCurrentGroup("Personal Settings"); 142 KPrefs::setCurrentGroup("Personal Settings");
137 143
138 addItemInt("Mail Client",&mMailClient,MailClientKMail); 144 addItemInt("Mail Client",&mMailClient,MailClientKMail);
139 addItemBool("Use Control Center Email",&mEmailControlCenter,false); 145 addItemBool("Use Control Center Email",&mEmailControlCenter,false);
140 addItemBool("Bcc",&mBcc,false); 146 addItemBool("Bcc",&mBcc,false);
141 147
142 KPrefs::setCurrentGroup("Time & Date"); 148 KPrefs::setCurrentGroup("Time & Date");
143 149
144 // addItemString("Time Zone",&mTimeZone,"+0100"); 150 // addItemString("Time Zone",&mTimeZone,"+0100");
145 addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") ); 151 addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") );
146 // addItemInt("TimeZoneOffset",&mTimeZoneOffset,60); 152 // addItemInt("TimeZoneOffset",&mTimeZoneOffset,60);
147 addItemBool("UseDaylightsaving",&mUseDaylightsaving,true); 153 addItemBool("UseDaylightsaving",&mUseDaylightsaving,true);
148 addItemInt("DaylightsavingStart",&mDaylightsavingStart,90); 154 addItemInt("DaylightsavingStart",&mDaylightsavingStart,90);
149 addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304); 155 addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304);
150 156
151 157
152 addItemInt("Default Start Time",&mStartTime,10); 158 addItemInt("Default Start Time",&mStartTime,10);
153 addItemInt("Default Duration",&mDefaultDuration,2); 159 addItemInt("Default Duration",&mDefaultDuration,2);
154 addItemInt("Default Alarm Time",&mAlarmTime,3); 160 addItemInt("Default Alarm Time",&mAlarmTime,3);
155 addItemInt("Daylight Savings",&mDaylightSavings,0); 161 addItemInt("Daylight Savings",&mDaylightSavings,0);
156 KPrefs::setCurrentGroup("AlarmSettings"); 162 KPrefs::setCurrentGroup("AlarmSettings");
157 addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); 163 addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20);
158 addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); 164 addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7);
159 addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); 165 addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5);
160 addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); 166 addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3);
161 167
162 168
163 KPrefs::setCurrentGroup("Calendar"); 169 KPrefs::setCurrentGroup("Calendar");
164 170
165 addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); 171 addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar);
166 172
167 KPrefs::setCurrentGroup("Fonts"); 173 KPrefs::setCurrentGroup("Fonts");
168 // qDebug(" KPrefs::setCurrentGroup(Fonts); "); 174 // qDebug(" KPrefs::setCurrentGroup(Fonts); ");
169 addItemFont("TimeBar Font",&mTimeBarFont); 175 addItemFont("TimeBar Font",&mTimeBarFont);
170 addItemFont("MonthView Font",&mMonthViewFont); 176 addItemFont("MonthView Font",&mMonthViewFont);
171 addItemFont("AgendaView Font",&mAgendaViewFont); 177 addItemFont("AgendaView Font",&mAgendaViewFont);
172 addItemFont("MarcusBains Font",&mMarcusBainsFont); 178 addItemFont("MarcusBains Font",&mMarcusBainsFont);
173 addItemFont("TimeLabels Font",&mTimeLabelsFont); 179 addItemFont("TimeLabels Font",&mTimeLabelsFont);
174 addItemFont("TodoView Font",&mTodoViewFont); 180 addItemFont("TodoView Font",&mTodoViewFont);
175 addItemFont("ListView Font",&mListViewFont); 181 addItemFont("ListView Font",&mListViewFont);
176 addItemFont("DateNavigator Font",&mDateNavigatorFont); 182 addItemFont("DateNavigator Font",&mDateNavigatorFont);
177 addItemFont("EditBox Font",&mEditBoxFont); 183 addItemFont("EditBox Font",&mEditBoxFont);
178 addItemFont("JournalView Font",&mJornalViewFont); 184 addItemFont("JournalView Font",&mJornalViewFont);
179 addItemFont("WhatsNextView Font",&mWhatsNextFont); 185 addItemFont("WhatsNextView Font",&mWhatsNextFont);
180 addItemFont("EventView Font",&mEventViewFont); 186 addItemFont("EventView Font",&mEventViewFont);
181 187
182// KPrefs::setCurrentGroup("SyncProfiles"); 188// KPrefs::setCurrentGroup("SyncProfiles");
183// addItemString("LocalMachineName",&mLocalMachineName, "undefined"); 189// addItemString("LocalMachineName",&mLocalMachineName, "undefined");
184// addItemStringList("SyncProfileNames",&mSyncProfileNames); 190// addItemStringList("SyncProfileNames",&mSyncProfileNames);
185// addItemStringList("ExternSyncProfiles",&mExternSyncProfileNames); 191// addItemStringList("ExternSyncProfiles",&mExternSyncProfileNames);
186 192
187 KPrefs::setCurrentGroup("RemoteSyncing"); 193 KPrefs::setCurrentGroup("RemoteSyncing");
188// addItemBool("UsePasswd",&mUsePassWd,false); 194// addItemBool("UsePasswd",&mUsePassWd,false);
189// addItemBool("WriteBackFile",&mWriteBackFile,true); 195// addItemBool("WriteBackFile",&mWriteBackFile,true);
190// addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false); 196// addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false);
191// addItemBool("AskForPreferences",&mAskForPreferences,true); 197// addItemBool("AskForPreferences",&mAskForPreferences,true);
192// addItemBool("ShowSyncSummary",&mShowSyncSummary,true); 198// addItemBool("ShowSyncSummary",&mShowSyncSummary,true);
193 addItemString("PassiveSyncPort",&mPassiveSyncPort,"9197" ); 199 addItemString("PassiveSyncPort",&mPassiveSyncPort,"9197" );
194 addItemString("PassiveSyncPw",&mPassiveSyncPw,"abc" ); 200 addItemString("PassiveSyncPw",&mPassiveSyncPw,"abc" );
195 addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); 201 addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" );
196 addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); 202 addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" );
197 addItemBool("ShowSyncEvents",&mShowSyncEvents,false); 203 addItemBool("ShowSyncEvents",&mShowSyncEvents,false);
198 addItemInt("LastSyncTime",&mLastSyncTime,0); 204 addItemInt("LastSyncTime",&mLastSyncTime,0);
199 addItemInt("SyncAlgoPrefs",&mSyncAlgoPrefs,3); 205 addItemInt("SyncAlgoPrefs",&mSyncAlgoPrefs,3);
200 addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3); 206 addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3);
201 207
202#ifdef _WIN32_ 208#ifdef _WIN32_
203 QString hdp= locateLocal("data","korganizer")+"\\\\"; 209 QString hdp= locateLocal("data","korganizer")+"\\\\";
204#else 210#else
205 QString hdp= locateLocal("data","korganizer")+"/"; 211 QString hdp= locateLocal("data","korganizer")+"/";
206#endif 212#endif
207// addItemString("RemoteIP",&mRemoteIP, "192.168.0.65"); 213// addItemString("RemoteIP",&mRemoteIP, "192.168.0.65");
208// addItemString("RemoteUser",&mRemoteUser, "zaurus"); 214// addItemString("RemoteUser",&mRemoteUser, "zaurus");
209// addItemString("RemotePassWd",&mRemotePassWd, ""); 215// addItemString("RemotePassWd",&mRemotePassWd, "");
210// addItemString("RemoteFile", &mRemoteFile, hdp+"mycalendar.ics"); 216// addItemString("RemoteFile", &mRemoteFile, hdp+"mycalendar.ics");
211// addItemString("LocalTempFile",&mLocalTempFile, "/tmp/tempsyncfile.ics" ); 217// addItemString("LocalTempFile",&mLocalTempFile, "/tmp/tempsyncfile.ics" );
212 218
213 219
214 KPrefs::setCurrentGroup("LoadSaveFileNames"); 220 KPrefs::setCurrentGroup("LoadSaveFileNames");
215 221
216 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); 222 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" );
217 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); 223 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" );
218 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); 224 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" );
219 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); 225 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" );
220 addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" ); 226 addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" );
221 227
222 228
223 KPrefs::setCurrentGroup("Locale"); 229 KPrefs::setCurrentGroup("Locale");
224 addItemInt("PreferredLanguage",&mPreferredLanguage,0); 230 addItemInt("PreferredLanguage",&mPreferredLanguage,0);
225 addItemInt("PreferredTime",&mPreferredTime,0); 231 addItemInt("PreferredTime",&mPreferredTime,0);
226 addItemInt("PreferredDate",&mPreferredDate,0); 232 addItemInt("PreferredDate",&mPreferredDate,0);
227 addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false); 233 addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false);
228 addItemBool("ShortDateInViewer",&mShortDateInViewer,false); 234 addItemBool("ShortDateInViewer",&mShortDateInViewer,false);
229 addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y"); 235 addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y");
230 addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y"); 236 addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y");
231 237
232 238
233 KPrefs::setCurrentGroup("Colors"); 239 KPrefs::setCurrentGroup("Colors");
234 addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); 240 addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor);
235 addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); 241 addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor);
236 addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); 242 addItemColor("Event Color",&mEventColor,mDefaultCategoryColor);
237 addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); 243 addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor);
238 addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); 244 addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor);
239 addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); 245 addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor);
240 addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); 246 addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor);
241 addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); 247 addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 ));
242 addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); 248 addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 ));
243 addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); 249 addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 ));
244 addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); 250 addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true);
245 addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); 251 addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true);
246 addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); 252 addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false);
247 addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); 253 addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 ));
248 addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); 254 addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 ));
249 addItemBool("UseAppColors",&mUseAppColors,false); 255 addItemBool("UseAppColors",&mUseAppColors,false);
250 256
251 257
252 258
253 KPrefs::setCurrentGroup("Views"); 259 KPrefs::setCurrentGroup("Views");
254 addItemInt("Hour Size",&mHourSize,8); 260 addItemInt("Hour Size",&mHourSize,8);
255 addItemBool("Show Daily Recurrences",&mDailyRecur,true); 261 addItemBool("Show Daily Recurrences",&mDailyRecur,true);
256 addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); 262 addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true);
257 addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); 263 addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true);
258 addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); 264 addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true);
259 addItemBool("ShowShortMonthName",&mMonthShowShort,false); 265 addItemBool("ShowShortMonthName",&mMonthShowShort,false);
260 addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); 266 addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true);
261 addItemBool("Enable ToolTips",&mEnableToolTips,false); 267 addItemBool("Enable ToolTips",&mEnableToolTips,false);
262 addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); 268 addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false);
263 addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); 269 addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false);
264 addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); 270 addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true);
265 addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); 271 addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true);
266 addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,false); 272 addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,false);
267 addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); 273 addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false);
268 addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); 274 addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false);
269 addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); 275 addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true);
270 addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); 276 addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true);
271 addItemBool("WNViewShowsParents",&mWNViewShowsParents,true); 277 addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);
272 addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); 278 addItemBool("WNViewShowLocation",&mWNViewShowLocation,false);
273 addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); 279 addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false);
274 addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); 280 addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true);
275 addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); 281 addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false);
276 addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); 282 addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false);
277 addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,false); 283 addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,false);
278 addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); 284 addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false);
279 addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); 285 addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false);
280#ifdef DESKTOP_VERSION 286#ifdef DESKTOP_VERSION
281 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); 287 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true);
282#else 288#else
283 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); 289 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false);
284#endif 290#endif
285 addItemInt("Day Begins",&mDayBegins,7); 291 addItemInt("Day Begins",&mDayBegins,7);
286 addItemInt("Working Hours Start",&mWorkingHoursStart,8); 292 addItemInt("Working Hours Start",&mWorkingHoursStart,8);
287 addItemInt("Working Hours End",&mWorkingHoursEnd,17); 293 addItemInt("Working Hours End",&mWorkingHoursEnd,17);
288 addItemBool("Exclude Holidays",&mExcludeHolidays,true); 294 addItemBool("Exclude Holidays",&mExcludeHolidays,true);
289 addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); 295 addItemBool("Exclude Saturdays",&mExcludeSaturdays,true);
290 296
291 addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); 297 addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false);
292 addItemBool("Full View Month",&mFullViewMonth,true); 298 addItemBool("Full View Month",&mFullViewMonth,true);
293 addItemBool("Full View Todo",&mFullViewTodo,true); 299 addItemBool("Full View Todo",&mFullViewTodo,true);
294 addItemBool("Quick Todo",&mEnableQuickTodo,false); 300 addItemBool("Quick Todo",&mEnableQuickTodo,false);
295 301
296 addItemInt("Next X Days",&mNextXDays,3); 302 addItemInt("Next X Days",&mNextXDays,3);
297 303
298 KPrefs::setCurrentGroup("Printer"); 304 KPrefs::setCurrentGroup("Printer");
299 305
300 KPrefs::setCurrentGroup("Layout"); 306 KPrefs::setCurrentGroup("Layout");
301 307
302 addItemBool("CompactDialogs",&mCompactDialogs,false); 308 addItemBool("CompactDialogs",&mCompactDialogs,false);
303 addItemBool("VerticalScreen",&mVerticalScreen,true); 309 addItemBool("VerticalScreen",&mVerticalScreen,true);
304 310
305 KPrefs::setCurrentGroup("KOrganizer Plugins"); 311 KPrefs::setCurrentGroup("KOrganizer Plugins");
306 312
307 addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); 313 addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays");
308 314
309 KPrefs::setCurrentGroup("Group Scheduling"); 315 KPrefs::setCurrentGroup("Group Scheduling");
310 316
311 addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); 317 addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail);
312 addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); 318 addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend);
313 addItemStringList("AdditionalMails",&mAdditionalMails,""); 319 addItemStringList("AdditionalMails",&mAdditionalMails,"");
314 addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); 320 addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto);
315 addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); 321 addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto);
316 addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); 322 addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto);
317 addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); 323 addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto);
318 addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); 324 addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto);
319 325
320 KPrefs::setCurrentGroup( "Editors" ); 326 KPrefs::setCurrentGroup( "Editors" );
321 327
322 addItemStringList( "EventTemplates", &mEventTemplates ); 328 addItemStringList( "EventTemplates", &mEventTemplates );
323 addItemStringList( "TodoTemplates", &mTodoTemplates ); 329 addItemStringList( "TodoTemplates", &mTodoTemplates );
324 330
325 addItemInt("DestinationPolicy",&mDestination,standardDestination); 331 addItemInt("DestinationPolicy",&mDestination,standardDestination);
326 332
327 333
328 334
329} 335}
330 336
331 337
332KOPrefs::~KOPrefs() 338KOPrefs::~KOPrefs()
333{ 339{
334 if (mInstance == this) 340 if (mInstance == this)
335 mInstance = insd.setObject(0); 341 mInstance = insd.setObject(0);
336 setLocaleDict( 0 ); 342 setLocaleDict( 0 );
337 if ( mLocaleDict ) 343 if ( mLocaleDict )
338 delete mLocaleDict; 344 delete mLocaleDict;
339 //qDebug("KOPrefs::~KOPrefs() "); 345 //qDebug("KOPrefs::~KOPrefs() ");
340} 346}
341 347
342 348
343KOPrefs *KOPrefs::instance() 349KOPrefs *KOPrefs::instance()
344{ 350{
345 if (!mInstance) { 351 if (!mInstance) {
346 mInstance = insd.setObject(new KOPrefs()); 352 mInstance = insd.setObject(new KOPrefs());
347 mInstance->readConfig(); 353 mInstance->readConfig();
348 } 354 }
349 355
350 return mInstance; 356 return mInstance;
351} 357}
352 358
353void KOPrefs::usrSetDefaults() 359void KOPrefs::usrSetDefaults()
354{ 360{
355 361
356} 362}
357 363
358void KOPrefs::fillMailDefaults() 364void KOPrefs::fillMailDefaults()
359{ 365{
360 if (mName.isEmpty()) mName = i18n("Anonymous"); 366 if (mName.isEmpty()) mName = i18n("Anonymous");
361 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); 367 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere");
362} 368}
363 369
364void KOPrefs::setTimeZoneIdDefault() 370void KOPrefs::setTimeZoneIdDefault()
365{ 371{
366 mTimeZoneId = i18n("+01:00 Europe/Oslo(CET)"); 372 mTimeZoneId = i18n("+01:00 Europe/Oslo(CET)");
367} 373}
368 374
369void KOPrefs::setCategoryDefaults() 375void KOPrefs::setCategoryDefaults()
370{ 376{
371 mCustomCategories.clear(); 377 mCustomCategories.clear();
372 mCustomCategories = getDefaultList(); 378 mCustomCategories = getDefaultList();
373 379
374 QStringList::Iterator it; 380 QStringList::Iterator it;
375 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { 381 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) {
376 setCategoryColor(*it,mDefaultCategoryColor); 382 setCategoryColor(*it,mDefaultCategoryColor);
377 } 383 }
378} 384}
379 385
380QStringList KOPrefs::getDefaultList() 386QStringList KOPrefs::getDefaultList()
381{ 387{
382 QStringList retval ; 388 QStringList retval ;
383 retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer") 389 retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer")
384 << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner") 390 << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner")
385 << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts") 391 << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts")
386 << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids") 392 << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids")
387 << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel") 393 << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel")
388 << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping") 394 << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping")
389 << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University") 395 << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University")
390 << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ; 396 << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ;
391 retval.sort(); 397 retval.sort();
392 return retval; 398 return retval;
393} 399}
394 400
395void KOPrefs::usrReadConfig() 401void KOPrefs::usrReadConfig()
396{ 402{
397 mPreferredLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; 403 mPreferredLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage;
398 mLocaleDict = 0; 404 mLocaleDict = 0;
399 // pending LR fix translation 405 // pending LR fix translation
400 // qDebug("KOPrefs::usrReadConfig() fix translation "); 406 // qDebug("KOPrefs::usrReadConfig() fix translation ");
401 if ( mPreferredLanguage > 0 && mPreferredLanguage < 4 ) { 407 if ( mPreferredLanguage > 0 && mPreferredLanguage < 4 ) {
402 if ( mPreferredLanguage == 1 ) { 408 if ( mPreferredLanguage == 1 ) {
403 mLocaleDict = new QDict<QString>; 409 mLocaleDict = new QDict<QString>;
404 int i = 0; 410 int i = 0;
405 QString fw ( germanwords[i] [0]); 411 QString fw ( germanwords[i] [0]);
406 while ( !fw.isEmpty() ) { 412 while ( !fw.isEmpty() ) {
407 mLocaleDict->insert( fw, new QString (germanwords[i] [1] )); 413 mLocaleDict->insert( fw, new QString (germanwords[i] [1] ));
408 ++i; 414 ++i;
409 fw = germanwords[i] [0]; 415 fw = germanwords[i] [0];
410 } 416 }
411 417
412 setLocaleDict( mLocaleDict ); 418 setLocaleDict( mLocaleDict );
413 } else { 419 } else {
414 QString fileName ; 420 QString fileName ;
415 if ( mPreferredLanguage == 3 ) 421 if ( mPreferredLanguage == 3 )
416 fileName = MainWindow::resourcePath()+"usertranslation.txt"; 422 fileName = MainWindow::resourcePath()+"usertranslation.txt";
417 else if ( mPreferredLanguage == 2 ) 423 else if ( mPreferredLanguage == 2 )
418 fileName = MainWindow::resourcePath()+"frenchtranslation.txt"; 424 fileName = MainWindow::resourcePath()+"frenchtranslation.txt";
419 QFile file( fileName ); 425 QFile file( fileName );
420 if (file.open( IO_ReadOnly ) ) { 426 if (file.open( IO_ReadOnly ) ) {
421 QTextStream ts( &file ); 427 QTextStream ts( &file );
422 ts.setEncoding( QTextStream::Latin1 ); 428 ts.setEncoding( QTextStream::Latin1 );
423 //ts.setCodec( QTextCodec::latin1 ); 429 //ts.setCodec( QTextCodec::latin1 );
424 QString text = ts.read(); 430 QString text = ts.read();
425 file.close(); 431 file.close();
426 text.replace( QRegExp("\\\\n"), "\n" ); 432 text.replace( QRegExp("\\\\n"), "\n" );
427 QString line; 433 QString line;
428 QString we; 434 QString we;
429 QString wt; 435 QString wt;
430 int br = 0; 436 int br = 0;
431 int nbr; 437 int nbr;
432 nbr = text.find ( "},", br ); 438 nbr = text.find ( "},", br );
433 line = text.mid( br, nbr - br ); 439 line = text.mid( br, nbr - br );
434 br = nbr+1; 440 br = nbr+1;
435 int se, ee, st, et; 441 int se, ee, st, et;
436 mLocaleDict = new QDict<QString>; 442 mLocaleDict = new QDict<QString>;
437 QString end = "{ \"\",\"\" }"; 443 QString end = "{ \"\",\"\" }";
438 while ( (line != end) && (br > 1) ) { 444 while ( (line != end) && (br > 1) ) {
439 //qDebug("%d *%s* ", br, line.latin1()); 445 //qDebug("%d *%s* ", br, line.latin1());
440 se = line.find("\"")+1; 446 se = line.find("\"")+1;
441 et = line.findRev("\"",-1); 447 et = line.findRev("\"",-1);
442 ee = line.find("\",\""); 448 ee = line.find("\",\"");
443 st = ee+3; 449 st = ee+3;
444 we = line.mid( se, ee-se ); 450 we = line.mid( se, ee-se );
445 wt = line.mid( st, et-st ); 451 wt = line.mid( st, et-st );
446 //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); 452 //qDebug("*%s* *%s* ", we.latin1(), wt.latin1());
447 mLocaleDict->insert( we, new QString (wt) ); 453 mLocaleDict->insert( we, new QString (wt) );
448 nbr = text.find ( "}", br ); 454 nbr = text.find ( "}", br );
449 line = text.mid( br, nbr - br ); 455 line = text.mid( br, nbr - br );
450 br = nbr+1; 456 br = nbr+1;
451 } 457 }
452 //qDebug("end *%s* ", end.latin1()); 458 //qDebug("end *%s* ", end.latin1());
453 459
454 setLocaleDict( mLocaleDict ); 460 setLocaleDict( mLocaleDict );
455 } else { 461 } else {
456 qDebug("KO: Cannot find translation file %s",fileName.latin1() ); 462 qDebug("KO: Cannot find translation file %s",fileName.latin1() );
457 } 463 }
458 464
459 } 465 }
460 } 466 }
461 config()->setGroup("General"); 467 config()->setGroup("General");
462 468
463 mCustomCategories = config()->readListEntry("Custom Categories"); 469 mCustomCategories = config()->readListEntry("Custom Categories");
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index d9ac851..a1ba8b3 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -1,313 +1,316 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KOPREFS_H 23#ifndef KOPREFS_H
24#define KOPREFS_H 24#define KOPREFS_H
25 25
26#include <qdict.h> 26#include <qdict.h>
27 27
28#include <libkdepim/kpimprefs.h> 28#include <libkdepim/kpimprefs.h>
29 29
30class KConfig; 30class KConfig;
31class QFont; 31class QFont;
32class QColor; 32class QColor;
33class QStringList; 33class QStringList;
34 34
35class KOPrefs : public KPimPrefs 35class KOPrefs : public KPimPrefs
36{ 36{
37 public: 37 public:
38 enum { FormatVCalendar, FormatICalendar }; 38 enum { FormatVCalendar, FormatICalendar };
39 enum { MailClientKMail, MailClientSendmail }; 39 enum { MailClientKMail, MailClientSendmail };
40 enum { IMIPDummy, IMIPKMail }; 40 enum { IMIPDummy, IMIPKMail };
41 enum { IMIPOutbox, IMIPdirectsend }; 41 enum { IMIPOutbox, IMIPdirectsend };
42 enum { neverAuto, addressbookAuto, selectedAuto }; 42 enum { neverAuto, addressbookAuto, selectedAuto };
43 enum { standardDestination, askDestination }; 43 enum { standardDestination, askDestination };
44 44
45 virtual ~KOPrefs(); 45 virtual ~KOPrefs();
46 46
47 /** Get instance of KOPrefs. It is made sure that there is only one 47 /** Get instance of KOPrefs. It is made sure that there is only one
48 instance. */ 48 instance. */
49 static KOPrefs *instance(); 49 static KOPrefs *instance();
50 50
51 /** Set preferences to default values */ 51 /** Set preferences to default values */
52 void usrSetDefaults(); 52 void usrSetDefaults();
53 53
54 /** Read preferences from config file */ 54 /** Read preferences from config file */
55 void usrReadConfig(); 55 void usrReadConfig();
56 56
57 /** Write preferences to config file */ 57 /** Write preferences to config file */
58 void usrWriteConfig(); 58 void usrWriteConfig();
59 void setCategoryDefaults(); 59 void setCategoryDefaults();
60 60
61 protected: 61 protected:
62 void setTimeZoneIdDefault(); 62 void setTimeZoneIdDefault();
63 63
64 /** Fill empty mail fields with default values. */ 64 /** Fill empty mail fields with default values. */
65 void fillMailDefaults(); 65 void fillMailDefaults();
66 66
67 private: 67 private:
68 /** Constructor disabled for public. Use instance() to create a KOPrefs 68 /** Constructor disabled for public. Use instance() to create a KOPrefs
69 object. */ 69 object. */
70 KOPrefs(); 70 KOPrefs();
71 71
72 static KOPrefs *mInstance; 72 static KOPrefs *mInstance;
73 QDict<QString> *mLocaleDict; 73 QDict<QString> *mLocaleDict;
74 QStringList getDefaultList(); 74 QStringList getDefaultList();
75 public: 75 public:
76 // preferences data 76 // preferences data
77 KConfig* getConfig(); 77 KConfig* getConfig();
78 void setFullName(const QString &); 78 void setFullName(const QString &);
79 QString fullName(); 79 QString fullName();
80 void setEmail(const QString &); 80 void setEmail(const QString &);
81 QString email(); 81 QString email();
82 82
83 QString mAdditional; 83 QString mAdditional;
84 84
85 bool mEmailControlCenter; 85 bool mEmailControlCenter;
86 86
87 bool mBcc; 87 bool mBcc;
88 bool mAutoSave; 88 bool mAutoSave;
89 int mAutoSaveInterval; 89 int mAutoSaveInterval;
90 bool mConfirm; 90 bool mConfirm;
91 91
92 bool mEnableGroupScheduling; 92 bool mEnableGroupScheduling;
93 bool mEnableProjectView; 93 bool mEnableProjectView;
94 94
95 int mDefaultFormat; 95 int mDefaultFormat;
96 int mMailClient; 96 int mMailClient;
97 97
98 QString mTimeZone; 98 QString mTimeZone;
99 //QString mTimeZoneName; // e.g. +00:04:00 Indian/Mauritius 99 //QString mTimeZoneName; // e.g. +00:04:00 Indian/Mauritius
100 //int mTimeZoneOffset; // e.g. -240 min 100 //int mTimeZoneOffset; // e.g. -240 min
101 int mStartTime; 101 int mStartTime;
102 int mDefaultDuration; 102 int mDefaultDuration;
103 int mAlarmTime; 103 int mAlarmTime;
104 int mDaylightSavings; 104 int mDaylightSavings;
105 105
106 int mWorkingHoursStart; 106 int mWorkingHoursStart;
107 int mWorkingHoursEnd; 107 int mWorkingHoursEnd;
108 bool mExcludeHolidays; 108 bool mExcludeHolidays;
109 bool mExcludeSaturdays; 109 bool mExcludeSaturdays;
110 bool mMarcusBainsShowSeconds; 110 bool mMarcusBainsShowSeconds;
111 111
112 QFont mTimeBarFont; 112 QFont mTimeBarFont;
113 QFont mMonthViewFont; 113 QFont mMonthViewFont;
114 QFont mAgendaViewFont; 114 QFont mAgendaViewFont;
115 QFont mMarcusBainsFont; 115 QFont mMarcusBainsFont;
116 QFont mTimeLabelsFont; 116 QFont mTimeLabelsFont;
117 QFont mTodoViewFont; 117 QFont mTodoViewFont;
118 QFont mListViewFont; 118 QFont mListViewFont;
119 QFont mDateNavigatorFont; 119 QFont mDateNavigatorFont;
120 QFont mEditBoxFont; 120 QFont mEditBoxFont;
121 QFont mJornalViewFont; 121 QFont mJornalViewFont;
122 QFont mWhatsNextFont; 122 QFont mWhatsNextFont;
123 QFont mEventViewFont; 123 QFont mEventViewFont;
124 124
125 125
126 126
127 127
128 QColor mHolidayColor; 128 QColor mHolidayColor;
129 QColor mHighlightColor; 129 QColor mHighlightColor;
130 QColor mEventColor; 130 QColor mEventColor;
131 QColor mAgendaBgColor; 131 QColor mAgendaBgColor;
132 QColor mWorkingHoursColor; 132 QColor mWorkingHoursColor;
133 QColor mTodoDueTodayColor; 133 QColor mTodoDueTodayColor;
134 QColor mTodoOverdueColor; 134 QColor mTodoOverdueColor;
135 QColor mMonthViewEvenColor; 135 QColor mMonthViewEvenColor;
136 QColor mMonthViewOddColor; 136 QColor mMonthViewOddColor;
137 QColor mMonthViewHolidayColor; 137 QColor mMonthViewHolidayColor;
138 bool mMonthViewUsesDayColors; 138 bool mMonthViewUsesDayColors;
139 bool mMonthViewSatSunTog; 139 bool mMonthViewSatSunTog;
140 QColor mAppColor1; 140 QColor mAppColor1;
141 QColor mAppColor2; 141 QColor mAppColor2;
142 bool mUseAppColors; 142 bool mUseAppColors;
143 143
144 int mDayBegins; 144 int mDayBegins;
145 int mHourSize; 145 int mHourSize;
146 int mAllDaySize; 146 int mAllDaySize;
147 bool mShowFullMenu; 147 bool mShowFullMenu;
148 bool mDailyRecur; 148 bool mDailyRecur;
149 bool mWeeklyRecur; 149 bool mWeeklyRecur;
150 bool mMonthDailyRecur; 150 bool mMonthDailyRecur;
151 bool mMonthWeeklyRecur; 151 bool mMonthWeeklyRecur;
152 bool mMonthShowIcons; 152 bool mMonthShowIcons;
153 bool mMonthShowShort; 153 bool mMonthShowShort;
154 bool mEnableToolTips; 154 bool mEnableToolTips;
155 bool mEnableMonthScroll; 155 bool mEnableMonthScroll;
156 bool mFullViewMonth; 156 bool mFullViewMonth;
157 bool mMonthViewUsesCategoryColor; 157 bool mMonthViewUsesCategoryColor;
158 bool mFullViewTodo; 158 bool mFullViewTodo;
159 bool mShowCompletedTodo; 159 bool mShowCompletedTodo;
160 bool mMarcusBainsEnabled; 160 bool mMarcusBainsEnabled;
161 int mNextXDays; 161 int mNextXDays;
162 int mWhatsNextDays; 162 int mWhatsNextDays;
163 int mWhatsNextPrios; 163 int mWhatsNextPrios;
164 bool mEnableQuickTodo; 164 bool mEnableQuickTodo;
165 bool mLanguageChanged; 165 bool mLanguageChanged;
166 166
167 bool mCompactDialogs; 167 bool mCompactDialogs;
168 bool mVerticalScreen; 168 bool mVerticalScreen;
169 169
170 bool mShowIconNewTodo; 170 bool mShowIconNewTodo;
171 bool mShowIconNewEvent; 171 bool mShowIconNewEvent;
172 bool mShowIconSearch; 172 bool mShowIconSearch;
173 bool mShowIconList; 173 bool mShowIconList;
174 bool mShowIconDay1; 174 bool mShowIconDay1;
175 bool mShowIconDay5; 175 bool mShowIconDay5;
176 bool mShowIconDay7; 176 bool mShowIconDay7;
177 bool mShowIconMonth; 177 bool mShowIconMonth;
178 bool mShowIconTodoview; 178 bool mShowIconTodoview;
179 bool mShowIconBackFast; 179 bool mShowIconBackFast;
180 bool mShowIconBack; 180 bool mShowIconBack;
181 bool mShowIconToday; 181 bool mShowIconToday;
182 bool mShowIconForward; 182 bool mShowIconForward;
183 bool mShowIconForwardFast; 183 bool mShowIconForwardFast;
184 bool mShowIconWhatsThis; 184 bool mShowIconWhatsThis;
185 bool mShowIconNextDays; 185 bool mShowIconNextDays;
186 bool mShowIconNext; 186 bool mShowIconNext;
187 bool mShowIconJournal; 187 bool mShowIconJournal;
188 188
189 bool mShowIconStretch; 189 bool mShowIconStretch;
190 190
191 bool mToolBarHor; 191 bool mToolBarHor;
192 bool mToolBarUp; 192 bool mToolBarUp;
193 bool mToolBarMiniIcons; 193 bool mToolBarMiniIcons;
194 194
195 bool mAskForQuit; 195 bool mAskForQuit;
196 bool mUsePassWd; 196 bool mUsePassWd;
197 bool mWriteBackFile; 197 bool mWriteBackFile;
198 int mWriteBackInFuture; 198 int mWriteBackInFuture;
199 bool mAskForPreferences; 199 bool mAskForPreferences;
200 bool mShowSyncSummary; 200 bool mShowSyncSummary;
201 bool mShowSyncEvents; 201 bool mShowSyncEvents;
202 bool mShowTodoInAgenda; 202 bool mShowTodoInAgenda;
203 bool mWriteBackExistingOnly; 203 bool mWriteBackExistingOnly;
204 204
205 QString mRemoteIP; 205 QString mRemoteIP;
206 QString mRemoteUser; 206 QString mRemoteUser;
207 QString mRemotePassWd; 207 QString mRemotePassWd;
208 QString mRemoteFile; 208 QString mRemoteFile;
209 QString mLocalTempFile; 209 QString mLocalTempFile;
210 QString mPhoneDevice; 210 QString mPhoneDevice;
211 QString mPhoneConnection; 211 QString mPhoneConnection;
212 QString mPhoneModel; 212 QString mPhoneModel;
213 QString mEx2PhoneDevice;
214 QString mEx2PhoneConnection;
215 QString mEx2PhoneModel;
213 216
214 int mLastSyncTime; 217 int mLastSyncTime;
215 int mSyncAlgoPrefs; 218 int mSyncAlgoPrefs;
216 int mRingSyncAlgoPrefs; 219 int mRingSyncAlgoPrefs;
217 QStringList mSyncProfileNames; 220 QStringList mSyncProfileNames;
218 QStringList mExternSyncProfiles; 221 QStringList mExternSyncProfiles;
219 QString mLocalMachineName; 222 QString mLocalMachineName;
220 void setCategoryColor(QString cat,const QColor & color); 223 void setCategoryColor(QString cat,const QColor & color);
221 QColor *categoryColor(QString cat); 224 QColor *categoryColor(QString cat);
222 225
223 QString mArchiveFile; 226 QString mArchiveFile;
224 QString mHtmlExportFile; 227 QString mHtmlExportFile;
225 bool mHtmlWithSave; 228 bool mHtmlWithSave;
226 229
227 QStringList mSelectedPlugins; 230 QStringList mSelectedPlugins;
228 231
229 QString mLastImportFile; 232 QString mLastImportFile;
230 QString mLastVcalFile; 233 QString mLastVcalFile;
231 QString mLastSaveFile; 234 QString mLastSaveFile;
232 QString mLastLoadFile; 235 QString mLastLoadFile;
233 QString mLastSyncedLocalFile; 236 QString mLastSyncedLocalFile;
234 237
235 238
236 QString mDefaultAlarmFile; 239 QString mDefaultAlarmFile;
237 int mIMIPScheduler; 240 int mIMIPScheduler;
238 int mIMIPSend; 241 int mIMIPSend;
239 QStringList mAdditionalMails; 242 QStringList mAdditionalMails;
240 int mIMIPAutoRefresh; 243 int mIMIPAutoRefresh;
241 int mIMIPAutoInsertReply; 244 int mIMIPAutoInsertReply;
242 int mIMIPAutoInsertRequest; 245 int mIMIPAutoInsertRequest;
243 int mIMIPAutoFreeBusy; 246 int mIMIPAutoFreeBusy;
244 int mIMIPAutoFreeBusyReply; 247 int mIMIPAutoFreeBusyReply;
245 248
246 QStringList mTodoTemplates; 249 QStringList mTodoTemplates;
247 QStringList mEventTemplates; 250 QStringList mEventTemplates;
248 251
249 int mDestination; 252 int mDestination;
250 253
251 254
252 bool mEditOnDoubleClick; 255 bool mEditOnDoubleClick;
253 bool mViewChangeHoldFullscreen; 256 bool mViewChangeHoldFullscreen;
254 bool mViewChangeHoldNonFullscreen; 257 bool mViewChangeHoldNonFullscreen;
255 bool mCenterOnCurrentTime; 258 bool mCenterOnCurrentTime;
256 bool mSetTimeToDayStartAt; 259 bool mSetTimeToDayStartAt;
257 bool mHighlightCurrentDay; 260 bool mHighlightCurrentDay;
258 bool mUseHighlightLightColor; 261 bool mUseHighlightLightColor;
259 bool mListViewMonthTimespan; 262 bool mListViewMonthTimespan;
260 bool mWNViewShowsParents; 263 bool mWNViewShowsParents;
261 bool mWNViewShowLocation; 264 bool mWNViewShowLocation;
262 bool mTodoViewShowsPercentage; 265 bool mTodoViewShowsPercentage;
263 bool mTodoViewUsesCatColors; 266 bool mTodoViewUsesCatColors;
264 bool mTodoViewUsesSmallFont; 267 bool mTodoViewUsesSmallFont;
265 bool mTodoViewUsesForegroundColor; 268 bool mTodoViewUsesForegroundColor;
266 bool mMonthViewUsesForegroundColor; 269 bool mMonthViewUsesForegroundColor;
267 270
268 bool mHightlightDateTimeEdit; 271 bool mHightlightDateTimeEdit;
269 bool mShortDateInViewer; 272 bool mShortDateInViewer;
270 273
271 QStringList mLocationDefaults; 274 QStringList mLocationDefaults;
272 QStringList mEventSummaryUser; 275 QStringList mEventSummaryUser;
273 QStringList mTodoSummaryUser; 276 QStringList mTodoSummaryUser;
274 277
275 bool mUseInternalAlarmNotification; 278 bool mUseInternalAlarmNotification;
276 int mAlarmPlayBeeps; 279 int mAlarmPlayBeeps;
277 int mAlarmSuspendTime; 280 int mAlarmSuspendTime;
278 int mAlarmSuspendCount; 281 int mAlarmSuspendCount;
279 int mAlarmBeepInterval; 282 int mAlarmBeepInterval;
280 283
281 QString mPassiveSyncPort; 284 QString mPassiveSyncPort;
282 QString mPassiveSyncPw; 285 QString mPassiveSyncPw;
283 QString mActiveSyncPort; 286 QString mActiveSyncPort;
284 QString mActiveSyncIP; 287 QString mActiveSyncIP;
285 288
286 289
287 //US I copied the following settings into KPimGlobalPrefs 290 //US I copied the following settings into KPimGlobalPrefs
288 // that allows us later to easily remove the settings from here. 291 // that allows us later to easily remove the settings from here.
289 int mPreferredDate; 292 int mPreferredDate;
290 QString mUserDateFormatLong; 293 QString mUserDateFormatLong;
291 QString mUserDateFormatShort; 294 QString mUserDateFormatShort;
292 int mPreferredLanguage; 295 int mPreferredLanguage;
293 int mPreferredTime; 296 int mPreferredTime;
294 bool mWeekStartsOnSunday; 297 bool mWeekStartsOnSunday;
295 QString mTimeZoneId; 298 QString mTimeZoneId;
296 bool mUseDaylightsaving; 299 bool mUseDaylightsaving;
297 int mDaylightsavingStart; 300 int mDaylightsavingStart;
298 int mDaylightsavingEnd; 301 int mDaylightsavingEnd;
299 302
300 303
301 private: 304 private:
302 QDict<QColor> mCategoryColors; 305 QDict<QColor> mCategoryColors;
303 QColor mDefaultCategoryColor; 306 QColor mDefaultCategoryColor;
304 307
305 QFont mDefaultTimeBarFont; 308 QFont mDefaultTimeBarFont;
306 QFont mDefaultViewFont; 309 QFont mDefaultViewFont;
307 QFont mDefaultMonthViewFont; 310 QFont mDefaultMonthViewFont;
308 311
309 QString mName; 312 QString mName;
310 QString mEmail; 313 QString mEmail;
311}; 314};
312 315
313#endif 316#endif
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index de94b8c..ef73a78 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,1480 +1,1614 @@
1#include <stdlib.h> 1#include <stdlib.h>
2 2
3#include <qaction.h> 3#include <qaction.h>
4#include <qpopupmenu.h> 4#include <qpopupmenu.h>
5#include <qpainter.h> 5#include <qpainter.h>
6#include <qwhatsthis.h> 6#include <qwhatsthis.h>
7#include <qpushbutton.h> 7#include <qpushbutton.h>
8#include <qmessagebox.h> 8#include <qmessagebox.h>
9#include <qlineedit.h> 9#include <qlineedit.h>
10#include <qtextcodec.h> 10#include <qtextcodec.h>
11#include <qfile.h> 11#include <qfile.h>
12#include <qdir.h> 12#include <qdir.h>
13#include <qapp.h> 13#include <qapp.h>
14#include <qfileinfo.h> 14#include <qfileinfo.h>
15#include <qlabel.h> 15#include <qlabel.h>
16#include <qspinbox.h>
17#include <qcheckbox.h>
16#include <qmap.h> 18#include <qmap.h>
17#include <qwmatrix.h> 19#include <qwmatrix.h>
18#include <qtextbrowser.h> 20#include <qtextbrowser.h>
19#include <qtextstream.h> 21#include <qtextstream.h>
20#ifndef DESKTOP_VERSION 22#ifndef DESKTOP_VERSION
21#include <qpe/global.h> 23#include <qpe/global.h>
22#include <qpe/qpemenubar.h> 24#include <qpe/qpemenubar.h>
23#include <qpe/qpetoolbar.h> 25#include <qpe/qpetoolbar.h>
24#include <qpe/resource.h> 26#include <qpe/resource.h>
25#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
26#include <qtopia/alarmserver.h> 28#include <qtopia/alarmserver.h>
27#include <qtopia/qcopenvelope_qws.h> 29#include <qtopia/qcopenvelope_qws.h>
28#include <unistd.h> // for sleep 30#include <unistd.h> // for sleep
29#else 31#else
30#include <qmenubar.h> 32#include <qmenubar.h>
31#include <qtoolbar.h> 33#include <qtoolbar.h>
32#include <qapplication.h> 34#include <qapplication.h>
33//#include <resource.h> 35//#include <resource.h>
34 36
35#endif 37#endif
36#include <libkcal/calendarlocal.h> 38#include <libkcal/calendarlocal.h>
37#include <libkcal/todo.h> 39#include <libkcal/todo.h>
40#include <libkcal/phoneformat.h>
38#include <libkdepim/ksyncprofile.h> 41#include <libkdepim/ksyncprofile.h>
39#include <libkcal/kincidenceformatter.h> 42#include <libkcal/kincidenceformatter.h>
40#include <libkdepim/kpimglobalprefs.h> 43#include <libkdepim/kpimglobalprefs.h>
41 44
42#include "calendarview.h" 45#include "calendarview.h"
43#include "koviewmanager.h" 46#include "koviewmanager.h"
44#include "datenavigator.h" 47#include "datenavigator.h"
45#include "koagendaview.h" 48#include "koagendaview.h"
46#include "koagenda.h" 49#include "koagenda.h"
47#include "kodialogmanager.h" 50#include "kodialogmanager.h"
48#include "kdialogbase.h" 51#include "kdialogbase.h"
49#include "kapplication.h" 52#include "kapplication.h"
50#include "kofilterview.h" 53#include "kofilterview.h"
51#include "kstandarddirs.h" 54#include "kstandarddirs.h"
52#include "koprefs.h" 55#include "koprefs.h"
53#include "kfiledialog.h" 56#include "kfiledialog.h"
54#include "koglobals.h" 57#include "koglobals.h"
55#include "kglobal.h" 58#include "kglobal.h"
56#include "klocale.h" 59#include "klocale.h"
57#include "kconfig.h" 60#include "kconfig.h"
58#include "simplealarmclient.h" 61#include "simplealarmclient.h"
59#include "externalapphandler.h" 62#include "externalapphandler.h"
60 63
61using namespace KCal; 64using namespace KCal;
62#ifndef _WIN32_ 65#ifndef _WIN32_
63#include <unistd.h> 66#include <unistd.h>
64#else 67#else
65#include "koimportoldialog.h" 68#include "koimportoldialog.h"
66#endif 69#endif
67#include "mainwindow.h" 70#include "mainwindow.h"
68 71
72class KOex2phonePrefs : public QDialog
73{
74 public:
75 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
76 QDialog( parent, name, true )
77 {
78 setCaption( i18n("Export to phone options") );
79 QVBoxLayout* lay = new QVBoxLayout( this );
80 lay->setSpacing( 3 );
81 lay->setMargin( 3 );
82
83 lay->addWidget(new QLabel( i18n("Please read phone sync howto to\nknow more about the connection settings."), this ) );
84 QHBox* temphb;
85 temphb = new QHBox( this );
86 new QLabel( i18n("I/O device: "), temphb );
87 mPhoneDevice = new QLineEdit( temphb);
88 lay->addWidget( temphb );
89 temphb = new QHBox( this );
90 new QLabel( i18n("Connection: "), temphb );
91 mPhoneConnection = new QLineEdit( temphb);
92 lay->addWidget( temphb );
93 temphb = new QHBox( this );
94 new QLabel( i18n("Model(opt.): "), temphb );
95 mPhoneModel = new QLineEdit( temphb);
96 lay->addWidget( temphb );
97 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
98 mWriteBackFuture->setChecked( true );
99 lay->addWidget( mWriteBackFuture );
100 temphb = new QHBox( this );
101 new QLabel( i18n("Max. weeks in future: ") , temphb );
102 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
103 mWriteBackFutureWeeks->setValue( 8 );
104 lay->addWidget( temphb );
105 QPushButton * ok = new QPushButton( i18n("Export!"), this );
106 lay->addWidget( ok );
107 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
108 lay->addWidget( cancel );
109 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
110 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
111 resize( 220, 220 );
112
113 }
114
115public:
116 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
117 QCheckBox* mWriteBackFuture;
118 QSpinBox* mWriteBackFutureWeeks;
119};
120
69int globalFlagBlockStartup; 121int globalFlagBlockStartup;
70MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 122MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
71 QMainWindow( parent, name ) 123 QMainWindow( parent, name )
72{ 124{
73 mPassWordPiSync = "abc"; 125 mPassWordPiSync = "abc";
74#ifdef DESKTOP_VERSION 126#ifdef DESKTOP_VERSION
75 setFont( QFont("Arial"), 14 ); 127 setFont( QFont("Arial"), 14 );
76#endif 128#endif
77 mSyncActionDialog = 0; 129 mSyncActionDialog = 0;
78 mServerSocket = 0; 130 mServerSocket = 0;
79 mClosed = false; 131 mClosed = false;
80 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 132 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
81 QString confFile = locateLocal("config","korganizerrc"); 133 QString confFile = locateLocal("config","korganizerrc");
82 QFileInfo finf ( confFile ); 134 QFileInfo finf ( confFile );
83 bool showWarning = !finf.exists(); 135 bool showWarning = !finf.exists();
84 setIcon(SmallIcon( "ko24" ) ); 136 setIcon(SmallIcon( "ko24" ) );
85 mBlockAtStartup = true; 137 mBlockAtStartup = true;
86 mFlagKeyPressed = false; 138 mFlagKeyPressed = false;
87 setCaption("KOrganizer/Pi"); 139 setCaption("KOrganizer/Pi");
88 KOPrefs *p = KOPrefs::instance(); 140 KOPrefs *p = KOPrefs::instance();
89 KPimGlobalPrefs::instance()->setGlobalConfig(); 141 KPimGlobalPrefs::instance()->setGlobalConfig();
90 // if ( QApplication::desktop()->height() > 480 ) { 142 // if ( QApplication::desktop()->height() > 480 ) {
91// if ( p->mHourSize == 4 ) 143// if ( p->mHourSize == 4 )
92// p->mHourSize = 6; 144// p->mHourSize = 6;
93// } 145// }
94 if ( p->mHourSize > 18 ) 146 if ( p->mHourSize > 18 )
95 p->mHourSize = 18; 147 p->mHourSize = 18;
96 QMainWindow::ToolBarDock tbd; 148 QMainWindow::ToolBarDock tbd;
97 if ( p->mToolBarHor ) { 149 if ( p->mToolBarHor ) {
98 if ( p->mToolBarUp ) 150 if ( p->mToolBarUp )
99 tbd = Bottom; 151 tbd = Bottom;
100 else 152 else
101 tbd = Top; 153 tbd = Top;
102 } 154 }
103 else { 155 else {
104 if ( p->mToolBarUp ) 156 if ( p->mToolBarUp )
105 tbd = Right; 157 tbd = Right;
106 else 158 else
107 tbd = Left; 159 tbd = Left;
108 } 160 }
109 if ( KOPrefs::instance()->mUseAppColors ) 161 if ( KOPrefs::instance()->mUseAppColors )
110 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 162 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
111 globalFlagBlockStartup = 1; 163 globalFlagBlockStartup = 1;
112 iconToolBar = new QPEToolBar( this ); 164 iconToolBar = new QPEToolBar( this );
113 addToolBar (iconToolBar , tbd ); 165 addToolBar (iconToolBar , tbd );
114 mBlockSaveFlag = false; 166 mBlockSaveFlag = false;
115 mCalendarModifiedFlag = false; 167 mCalendarModifiedFlag = false;
116 168
117 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 169 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
118 splash->setAlignment ( AlignCenter ); 170 splash->setAlignment ( AlignCenter );
119 setCentralWidget( splash ); 171 setCentralWidget( splash );
120#ifndef DESKTOP_VERSION 172#ifndef DESKTOP_VERSION
121 showMaximized(); 173 showMaximized();
122#endif 174#endif
123 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 175 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
124 setDefaultPreferences(); 176 setDefaultPreferences();
125 mCalendar = new CalendarLocal(); 177 mCalendar = new CalendarLocal();
126 mView = new CalendarView( mCalendar, this,"mCalendar " ); 178 mView = new CalendarView( mCalendar, this,"mCalendar " );
127 mView->hide(); 179 mView->hide();
128 //mView->resize(splash->size() ); 180 //mView->resize(splash->size() );
129 initActions(); 181 initActions();
130#ifndef DESKTOP_VERSION 182#ifndef DESKTOP_VERSION
131 iconToolBar->show(); 183 iconToolBar->show();
132 qApp->processEvents(); 184 qApp->processEvents();
133#endif 185#endif
134 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 186 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
135 int vh = height() ; 187 int vh = height() ;
136 int vw = width(); 188 int vw = width();
137 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 189 //qDebug("Toolbar hei %d ",iconToolBar->height() );
138 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 190 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
139 vh -= iconToolBar->height(); 191 vh -= iconToolBar->height();
140 } else { 192 } else {
141 vw -= iconToolBar->height(); 193 vw -= iconToolBar->height();
142 } 194 }
143 //mView->setMaximumSize( splash->size() ); 195 //mView->setMaximumSize( splash->size() );
144 //mView->resize( splash->size() ); 196 //mView->resize( splash->size() );
145 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 197 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
146 mView->readSettings(); 198 mView->readSettings();
147 bool newFile = false; 199 bool newFile = false;
148 if( !QFile::exists( defaultFileName() ) ) { 200 if( !QFile::exists( defaultFileName() ) ) {
149 QFileInfo finfo ( defaultFileName() ); 201 QFileInfo finfo ( defaultFileName() );
150 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 202 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
151 qDebug("oldfile %s ", oldFile.latin1()); 203 qDebug("oldfile %s ", oldFile.latin1());
152 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; 204 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n";
153 finfo.setFile( oldFile ); 205 finfo.setFile( oldFile );
154 if (finfo.exists() ) { 206 if (finfo.exists() ) {
155 KMessageBox::information( this, message); 207 KMessageBox::information( this, message);
156 mView->openCalendar( oldFile ); 208 mView->openCalendar( oldFile );
157 qApp->processEvents(); 209 qApp->processEvents();
158 } else { 210 } else {
159 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 211 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
160 finfo.setFile( oldFile ); 212 finfo.setFile( oldFile );
161 if (finfo.exists() ) { 213 if (finfo.exists() ) {
162 KMessageBox::information( this, message); 214 KMessageBox::information( this, message);
163 mView->openCalendar( oldFile ); 215 mView->openCalendar( oldFile );
164 qApp->processEvents(); 216 qApp->processEvents();
165 } 217 }
166 } 218 }
167 mView->saveCalendar( defaultFileName() ); 219 mView->saveCalendar( defaultFileName() );
168 newFile = true; 220 newFile = true;
169 } 221 }
170 222
171 QTime neededSaveTime = QDateTime::currentDateTime().time(); 223 QTime neededSaveTime = QDateTime::currentDateTime().time();
172 mView->openCalendar( defaultFileName() ); 224 mView->openCalendar( defaultFileName() );
173 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 225 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
174 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 226 qDebug("KO: Calendar loading time: %d ms",msNeeded );
175 227
176 if ( KOPrefs::instance()->mLanguageChanged ) { 228 if ( KOPrefs::instance()->mLanguageChanged ) {
177 KOPrefs::instance()->setCategoryDefaults(); 229 KOPrefs::instance()->setCategoryDefaults();
178 int count = mView->addCategories(); 230 int count = mView->addCategories();
179 KOPrefs::instance()->mLanguageChanged = false; 231 KOPrefs::instance()->mLanguageChanged = false;
180 } 232 }
181 processIncidenceSelection( 0 ); 233 processIncidenceSelection( 0 );
182 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 234 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
183 SLOT( processIncidenceSelection( Incidence * ) ) ); 235 SLOT( processIncidenceSelection( Incidence * ) ) );
184 connect( mView, SIGNAL( modifiedChanged( bool ) ), 236 connect( mView, SIGNAL( modifiedChanged( bool ) ),
185 SLOT( slotModifiedChanged( bool ) ) ); 237 SLOT( slotModifiedChanged( bool ) ) );
186 238
187 239
188 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 240 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
189 mView->setModified( false ); 241 mView->setModified( false );
190 mBlockAtStartup = false; 242 mBlockAtStartup = false;
191 mView->setModified( false ); 243 mView->setModified( false );
192 setCentralWidget( mView ); 244 setCentralWidget( mView );
193 globalFlagBlockStartup = 0; 245 globalFlagBlockStartup = 0;
194 mView->show(); 246 mView->show();
195 delete splash; 247 delete splash;
196 if ( newFile ) 248 if ( newFile )
197 mView->updateConfig(); 249 mView->updateConfig();
198 // qApp->processEvents(); 250 // qApp->processEvents();
199 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 251 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
200 fillSyncMenu(); 252 fillSyncMenu();
201 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 253 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
202 if ( showWarning ) { 254 if ( showWarning ) {
203 KMessageBox::information( this, 255 KMessageBox::information( this,
204 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); 256 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information");
205 qApp->processEvents(); 257 qApp->processEvents();
206 mView->dialogManager()->showSyncOptions(); 258 mView->dialogManager()->showSyncOptions();
207 } 259 }
208 260
209 //US listen for result adressed from Ka/Pi 261 //US listen for result adressed from Ka/Pi
210#ifndef DESKTOP_VERSION 262#ifndef DESKTOP_VERSION
211 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 263 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
212#endif 264#endif
213} 265}
214MainWindow::~MainWindow() 266MainWindow::~MainWindow()
215{ 267{
216 //qDebug("MainWindow::~MainWindow() "); 268 //qDebug("MainWindow::~MainWindow() ");
217 //save toolbar location 269 //save toolbar location
218 delete mServerSocket; 270 delete mServerSocket;
219 delete mCalendar; 271 delete mCalendar;
220 delete KOPrefs::instance(); 272 delete KOPrefs::instance();
221 delete KIncidenceFormatter::instance(); 273 delete KIncidenceFormatter::instance();
222 274
223 275
224} 276}
225void MainWindow::showMaximized () 277void MainWindow::showMaximized ()
226{ 278{
227#ifndef DESKTOP_VERSION 279#ifndef DESKTOP_VERSION
228 if ( ! globalFlagBlockStartup ) 280 if ( ! globalFlagBlockStartup )
229 if ( mClosed ) 281 if ( mClosed )
230 mView->goToday(); 282 mView->goToday();
231#endif 283#endif
232 QWidget::showMaximized () ; 284 QWidget::showMaximized () ;
233 mClosed = false; 285 mClosed = false;
234} 286}
235void MainWindow::closeEvent( QCloseEvent* ce ) 287void MainWindow::closeEvent( QCloseEvent* ce )
236{ 288{
237 289
238 290
239 291
240 if ( ! KOPrefs::instance()->mAskForQuit ) { 292 if ( ! KOPrefs::instance()->mAskForQuit ) {
241 saveOnClose(); 293 saveOnClose();
242 mClosed = true; 294 mClosed = true;
243 ce->accept(); 295 ce->accept();
244 return; 296 return;
245 297
246 } 298 }
247 299
248 switch( QMessageBox::information( this, "KO/Pi", 300 switch( QMessageBox::information( this, "KO/Pi",
249 i18n("Do you really want\nto close KO/Pi?"), 301 i18n("Do you really want\nto close KO/Pi?"),
250 i18n("Close"), i18n("No"), 302 i18n("Close"), i18n("No"),
251 0, 0 ) ) { 303 0, 0 ) ) {
252 case 0: 304 case 0:
253 saveOnClose(); 305 saveOnClose();
254 mClosed = true; 306 mClosed = true;
255 ce->accept(); 307 ce->accept();
256 break; 308 break;
257 case 1: 309 case 1:
258 ce->ignore(); 310 ce->ignore();
259 break; 311 break;
260 case 2: 312 case 2:
261 313
262 default: 314 default:
263 break; 315 break;
264 } 316 }
265 317
266 318
267} 319}
268 320
269void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 321void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
270{ 322{
271 QDataStream stream( data, IO_ReadOnly ); 323 QDataStream stream( data, IO_ReadOnly );
272 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 324 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
273 //QString datamess; 325 //QString datamess;
274 //qDebug("message "); 326 //qDebug("message ");
275 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 327 qDebug("KO: QCOP message received: %s ", cmsg.data() );
276 328
277 if ( cmsg == "-writeFile" ) { 329 if ( cmsg == "-writeFile" ) {
278 // I made from the "-writeFile" an "-writeAlarm" 330 // I made from the "-writeFile" an "-writeAlarm"
279 mView->viewManager()->showWhatsNextView(); 331 mView->viewManager()->showWhatsNextView();
280 mCalendar->checkAlarmForIncidence( 0, true); 332 mCalendar->checkAlarmForIncidence( 0, true);
281 showMaximized(); 333 showMaximized();
282 raise(); 334 raise();
283 return; 335 return;
284 } 336 }
285 337
286 if ( cmsg == "-writeFile" ) { 338 if ( cmsg == "-writeFile" ) {
287 // I made from the "-writeFile" an "-writeAlarm" 339 // I made from the "-writeFile" an "-writeAlarm"
288 mView->viewManager()->showWhatsNextView(); 340 mView->viewManager()->showWhatsNextView();
289 mCalendar->checkAlarmForIncidence( 0, true); 341 mCalendar->checkAlarmForIncidence( 0, true);
290 showMaximized(); 342 showMaximized();
291 raise(); 343 raise();
292 return; 344 return;
293 345
294 } 346 }
295 if ( cmsg == "-writeFileSilent" ) { 347 if ( cmsg == "-writeFileSilent" ) {
296 // I made from the "-writeFile" an "-writeAlarm" 348 // I made from the "-writeFile" an "-writeAlarm"
297 // mView->viewManager()->showWhatsNextView(); 349 // mView->viewManager()->showWhatsNextView();
298 mCalendar->checkAlarmForIncidence( 0, true); 350 mCalendar->checkAlarmForIncidence( 0, true);
299 //showMaximized(); 351 //showMaximized();
300 //raise(); 352 //raise();
301 hide(); 353 hide();
302 return; 354 return;
303 } 355 }
304 if ( cmsg == "-newCountdown" ) { 356 if ( cmsg == "-newCountdown" ) {
305 qDebug("newCountdown "); 357 qDebug("newCountdown ");
306 358
307 } 359 }
308 QString msg ; 360 QString msg ;
309 QString allmsg = cmsg; 361 QString allmsg = cmsg;
310 while ( allmsg.length() > 0 ) { 362 while ( allmsg.length() > 0 ) {
311 int nextC = allmsg.find( "-", 1 ); 363 int nextC = allmsg.find( "-", 1 );
312 if ( nextC == -1 ) { 364 if ( nextC == -1 ) {
313 msg = allmsg; 365 msg = allmsg;
314 allmsg = ""; 366 allmsg = "";
315 } else{ 367 } else{
316 msg = allmsg.left( nextC ); 368 msg = allmsg.left( nextC );
317 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 369 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
318 } 370 }
319 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 371 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
320 if ( msg == "-newEvent" ) { 372 if ( msg == "-newEvent" ) {
321 mView->newEvent(); 373 mView->newEvent();
322 } 374 }
323 if ( msg == "-newTodo" ) { 375 if ( msg == "-newTodo" ) {
324 mView->newTodo(); 376 mView->newTodo();
325 377
326 } 378 }
327 if ( msg == "-showWN" ) { 379 if ( msg == "-showWN" ) {
328 mView->viewManager()->showWhatsNextView(); 380 mView->viewManager()->showWhatsNextView();
329 } 381 }
330 if ( msg == "-showTodo" ) { 382 if ( msg == "-showTodo" ) {
331 mView->viewManager()->showTodoView(); 383 mView->viewManager()->showTodoView();
332 } 384 }
333 if ( msg == "-showList" ) { 385 if ( msg == "-showList" ) {
334 mView->viewManager()->showListView(); 386 mView->viewManager()->showListView();
335 } 387 }
336 else if ( msg == "-showDay" ) { 388 else if ( msg == "-showDay" ) {
337 mView->viewManager()->showDayView(); 389 mView->viewManager()->showDayView();
338 } 390 }
339 else if ( msg == "-showWWeek" ) { 391 else if ( msg == "-showWWeek" ) {
340 mView->viewManager()->showWorkWeekView(); 392 mView->viewManager()->showWorkWeekView();
341 } 393 }
342 else if ( msg == "-ringSync" ) { 394 else if ( msg == "-ringSync" ) {
343 multiSync( false ); 395 multiSync( false );
344 } 396 }
345 else if ( msg == "-showWeek" ) { 397 else if ( msg == "-showWeek" ) {
346 mView->viewManager()->showWeekView(); 398 mView->viewManager()->showWeekView();
347 } 399 }
348 else if ( msg == "-showTodo" ) { 400 else if ( msg == "-showTodo" ) {
349 mView->viewManager()->showTodoView(); 401 mView->viewManager()->showTodoView();
350 } 402 }
351 else if ( msg == "-showJournal" ) { 403 else if ( msg == "-showJournal" ) {
352 mView->dateNavigator()->selectDates( 1 ); 404 mView->dateNavigator()->selectDates( 1 );
353 mView->dateNavigator()->selectToday(); 405 mView->dateNavigator()->selectToday();
354 mView->viewManager()->showJournalView(); 406 mView->viewManager()->showJournalView();
355 } 407 }
356 else if ( msg == "-showKO" ) { 408 else if ( msg == "-showKO" ) {
357 mView->viewManager()->showNextXView(); 409 mView->viewManager()->showNextXView();
358 } 410 }
359 else if ( msg == "-showWNext" || msg == "nextView()" ) { 411 else if ( msg == "-showWNext" || msg == "nextView()" ) {
360 mView->viewManager()->showWhatsNextView(); 412 mView->viewManager()->showWhatsNextView();
361 } 413 }
362 else if ( msg == "-showNextXView" ) { 414 else if ( msg == "-showNextXView" ) {
363 mView->viewManager()->showNextXView(); 415 mView->viewManager()->showNextXView();
364 } 416 }
365 417
366 418
367 } 419 }
368 420
369 showMaximized(); 421 showMaximized();
370 raise(); 422 raise();
371} 423}
372 424
373QPixmap MainWindow::loadPixmap( QString name ) 425QPixmap MainWindow::loadPixmap( QString name )
374{ 426{
375 return SmallIcon( name ); 427 return SmallIcon( name );
376 428
377} 429}
378void MainWindow::initActions() 430void MainWindow::initActions()
379{ 431{
380 //KOPrefs::instance()->mShowFullMenu 432 //KOPrefs::instance()->mShowFullMenu
381 iconToolBar->clear(); 433 iconToolBar->clear();
382 KOPrefs *p = KOPrefs::instance(); 434 KOPrefs *p = KOPrefs::instance();
383 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 435 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
384 436
385 QPopupMenu *viewMenu = new QPopupMenu( this ); 437 QPopupMenu *viewMenu = new QPopupMenu( this );
386 QPopupMenu *actionMenu = new QPopupMenu( this ); 438 QPopupMenu *actionMenu = new QPopupMenu( this );
387 QPopupMenu *importMenu = new QPopupMenu( this ); 439 QPopupMenu *importMenu = new QPopupMenu( this );
388 selectFilterMenu = new QPopupMenu( this ); 440 selectFilterMenu = new QPopupMenu( this );
389 selectFilterMenu->setCheckable( true ); 441 selectFilterMenu->setCheckable( true );
390 syncMenu = new QPopupMenu( this ); 442 syncMenu = new QPopupMenu( this );
391 configureAgendaMenu = new QPopupMenu( this ); 443 configureAgendaMenu = new QPopupMenu( this );
392 configureToolBarMenu = new QPopupMenu( this ); 444 configureToolBarMenu = new QPopupMenu( this );
393 QPopupMenu *helpMenu = new QPopupMenu( this ); 445 QPopupMenu *helpMenu = new QPopupMenu( this );
394 if ( KOPrefs::instance()->mShowFullMenu ) { 446 if ( KOPrefs::instance()->mShowFullMenu ) {
395 QMenuBar *menuBar1; 447 QMenuBar *menuBar1;
396 menuBar1 = menuBar(); 448 menuBar1 = menuBar();
397 menuBar1->insertItem( i18n("File"), importMenu ); 449 menuBar1->insertItem( i18n("File"), importMenu );
398 menuBar1->insertItem( i18n("View"), viewMenu ); 450 menuBar1->insertItem( i18n("View"), viewMenu );
399 menuBar1->insertItem( i18n("Actions"), actionMenu ); 451 menuBar1->insertItem( i18n("Actions"), actionMenu );
400 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 452 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
401 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 453 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
402 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 454 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
403 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 455 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
404 menuBar1->insertItem( i18n("Help"), helpMenu ); 456 menuBar1->insertItem( i18n("Help"), helpMenu );
405 } else { 457 } else {
406 QPEMenuBar *menuBar1; 458 QPEMenuBar *menuBar1;
407 menuBar1 = new QPEMenuBar( iconToolBar ); 459 menuBar1 = new QPEMenuBar( iconToolBar );
408 QPopupMenu *menuBar = new QPopupMenu( this ); 460 QPopupMenu *menuBar = new QPopupMenu( this );
409 menuBar1->insertItem( i18n("ME"), menuBar); 461 menuBar1->insertItem( i18n("ME"), menuBar);
410 menuBar->insertItem( i18n("File"), importMenu ); 462 menuBar->insertItem( i18n("File"), importMenu );
411 menuBar->insertItem( i18n("View"), viewMenu ); 463 menuBar->insertItem( i18n("View"), viewMenu );
412 menuBar->insertItem( i18n("Actions"), actionMenu ); 464 menuBar->insertItem( i18n("Actions"), actionMenu );
413 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 465 menuBar->insertItem( i18n("Synchronize"), syncMenu );
414 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 466 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
415 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 467 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
416 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 468 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
417 menuBar->insertItem( i18n("Help"), helpMenu ); 469 menuBar->insertItem( i18n("Help"), helpMenu );
418 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 470 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
419 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 471 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
420 } 472 }
421 connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); 473 connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) );
422 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 474 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
423 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); 475 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) );
424 476
425 // ****************** 477 // ******************
426 QAction *action; 478 QAction *action;
427 QIconSet icon; 479 QIconSet icon;
428 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 480 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
429 configureToolBarMenu->setCheckable( true ); 481 configureToolBarMenu->setCheckable( true );
430 482
431 QString pathString = ""; 483 QString pathString = "";
432 if ( !p->mToolBarMiniIcons ) { 484 if ( !p->mToolBarMiniIcons ) {
433 if ( QApplication::desktop()->width() < 480 ) 485 if ( QApplication::desktop()->width() < 480 )
434 pathString += "icons16/"; 486 pathString += "icons16/";
435 } else 487 } else
436 pathString += "iconsmini/"; 488 pathString += "iconsmini/";
437 configureAgendaMenu->setCheckable( true ); 489 configureAgendaMenu->setCheckable( true );
438 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); 490 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 );
439 configureAgendaMenu->insertSeparator(); 491 configureAgendaMenu->insertSeparator();
440 configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); 492 configureAgendaMenu->insertItem(i18n("Tiny"), 4 );
441 configureAgendaMenu->insertItem(i18n("Small"), 6 ); 493 configureAgendaMenu->insertItem(i18n("Small"), 6 );
442 configureAgendaMenu->insertItem(i18n("Medium"), 8 ); 494 configureAgendaMenu->insertItem(i18n("Medium"), 8 );
443 configureAgendaMenu->insertItem(i18n("Normal"), 10 ); 495 configureAgendaMenu->insertItem(i18n("Normal"), 10 );
444 configureAgendaMenu->insertItem(i18n("Large"), 12 ); 496 configureAgendaMenu->insertItem(i18n("Large"), 12 );
445 configureAgendaMenu->insertItem(i18n("Big"), 14 ); 497 configureAgendaMenu->insertItem(i18n("Big"), 14 );
446 configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); 498 configureAgendaMenu->insertItem(i18n("Bigger"), 16 );
447 configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); 499 configureAgendaMenu->insertItem(i18n("Biggest"), 18 );
448 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 500 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
449 501
450 icon = loadPixmap( pathString + "configure" ); 502 icon = loadPixmap( pathString + "configure" );
451 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); 503 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this );
452 action->addTo( actionMenu ); 504 action->addTo( actionMenu );
453 connect( action, SIGNAL( activated() ), 505 connect( action, SIGNAL( activated() ),
454 mView, SLOT( edit_options() ) ); 506 mView, SLOT( edit_options() ) );
455 actionMenu->insertSeparator(); 507 actionMenu->insertSeparator();
456 icon = loadPixmap( pathString + "newevent" ); 508 icon = loadPixmap( pathString + "newevent" );
457 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 509 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
458 configureToolBarMenu->insertSeparator(); 510 configureToolBarMenu->insertSeparator();
459 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 511 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
460 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 512 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
461 ne_action->addTo( actionMenu ); 513 ne_action->addTo( actionMenu );
462 connect( ne_action, SIGNAL( activated() ), 514 connect( ne_action, SIGNAL( activated() ),
463 mView, SLOT( newEvent() ) ); 515 mView, SLOT( newEvent() ) );
464 icon = loadPixmap( pathString + "newtodo" ); 516 icon = loadPixmap( pathString + "newtodo" );
465 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 517 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
466 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 518 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
467 nt_action->addTo( actionMenu ); 519 nt_action->addTo( actionMenu );
468 connect( nt_action, SIGNAL( activated() ), 520 connect( nt_action, SIGNAL( activated() ),
469 mView, SLOT( newTodo() ) ); 521 mView, SLOT( newTodo() ) );
470 icon = loadPixmap( pathString + "navi" ); 522 icon = loadPixmap( pathString + "navi" );
471 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 523 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
472 action->addTo( viewMenu ); 524 action->addTo( viewMenu );
473 connect( action, SIGNAL( activated() ), 525 connect( action, SIGNAL( activated() ),
474 mView, SLOT( toggleDateNavigatorWidget() ) ); 526 mView, SLOT( toggleDateNavigatorWidget() ) );
475 icon = loadPixmap( pathString + "filter" ); 527 icon = loadPixmap( pathString + "filter" );
476 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); 528 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this );
477 action->addTo( viewMenu ); 529 action->addTo( viewMenu );
478 connect( action, SIGNAL( activated() ), 530 connect( action, SIGNAL( activated() ),
479 mView, SLOT( toggleFilter() ) ); 531 mView, SLOT( toggleFilter() ) );
480 532
481 533
482 viewMenu->insertSeparator(); 534 viewMenu->insertSeparator();
483 icon = loadPixmap( pathString + "picker" ); 535 icon = loadPixmap( pathString + "picker" );
484 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); 536 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
485 action->addTo( viewMenu ); 537 action->addTo( viewMenu );
486 connect( action, SIGNAL( activated() ), 538 connect( action, SIGNAL( activated() ),
487 mView, SLOT( showDatePicker() ) ); 539 mView, SLOT( showDatePicker() ) );
488 action->addTo( iconToolBar ); 540 action->addTo( iconToolBar );
489 viewMenu->insertSeparator(); 541 viewMenu->insertSeparator();
490 icon = loadPixmap( pathString + "list" ); 542 icon = loadPixmap( pathString + "list" );
491 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 543 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
492 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 544 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
493 showlist_action->addTo( viewMenu ); 545 showlist_action->addTo( viewMenu );
494 connect( showlist_action, SIGNAL( activated() ), 546 connect( showlist_action, SIGNAL( activated() ),
495 mView->viewManager(), SLOT( showListView() ) ); 547 mView->viewManager(), SLOT( showListView() ) );
496 548
497 549
498 icon = loadPixmap( pathString + "day" ); 550 icon = loadPixmap( pathString + "day" );
499 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 551 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
500 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 552 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
501 day1_action->addTo( viewMenu ); 553 day1_action->addTo( viewMenu );
502 // action->addTo( toolBar ); 554 // action->addTo( toolBar );
503 connect( day1_action, SIGNAL( activated() ), 555 connect( day1_action, SIGNAL( activated() ),
504 mView->viewManager(), SLOT( showDayView() ) ); 556 mView->viewManager(), SLOT( showDayView() ) );
505 557
506 icon = loadPixmap( pathString + "workweek" ); 558 icon = loadPixmap( pathString + "workweek" );
507 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 559 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
508 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 560 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
509 day5_action->addTo( viewMenu ); 561 day5_action->addTo( viewMenu );
510 connect( day5_action, SIGNAL( activated() ), 562 connect( day5_action, SIGNAL( activated() ),
511 mView->viewManager(), SLOT( showWorkWeekView() ) ); 563 mView->viewManager(), SLOT( showWorkWeekView() ) );
512 564
513 icon = loadPixmap( pathString + "week" ); 565 icon = loadPixmap( pathString + "week" );
514 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 566 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
515 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 567 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
516 day7_action->addTo( viewMenu ); 568 day7_action->addTo( viewMenu );
517 connect( day7_action, SIGNAL( activated() ), 569 connect( day7_action, SIGNAL( activated() ),
518 mView->viewManager(), SLOT( showWeekView() ) ); 570 mView->viewManager(), SLOT( showWeekView() ) );
519 571
520 icon = loadPixmap( pathString + "month" ); 572 icon = loadPixmap( pathString + "month" );
521 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 573 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
522 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 574 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
523 month_action->addTo( viewMenu ); 575 month_action->addTo( viewMenu );
524 connect( month_action, SIGNAL( activated() ), 576 connect( month_action, SIGNAL( activated() ),
525 mView->viewManager(), SLOT( showMonthView() ) ); 577 mView->viewManager(), SLOT( showMonthView() ) );
526 578
527 icon = loadPixmap( pathString + "todo" ); 579 icon = loadPixmap( pathString + "todo" );
528 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 580 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
529 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 581 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
530 todoview_action->addTo( viewMenu ); 582 todoview_action->addTo( viewMenu );
531 connect( todoview_action, SIGNAL( activated() ), 583 connect( todoview_action, SIGNAL( activated() ),
532 mView->viewManager(), SLOT( showTodoView() ) ); 584 mView->viewManager(), SLOT( showTodoView() ) );
533 585
534 icon = loadPixmap( pathString + "journal" ); 586 icon = loadPixmap( pathString + "journal" );
535 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 587 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
536 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 588 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
537 viewjournal_action->addTo( viewMenu ); 589 viewjournal_action->addTo( viewMenu );
538 connect( viewjournal_action, SIGNAL( activated() ), 590 connect( viewjournal_action, SIGNAL( activated() ),
539 mView->viewManager(), SLOT( showJournalView() ) ); 591 mView->viewManager(), SLOT( showJournalView() ) );
540 592
541 icon = loadPixmap( pathString + "xdays" ); 593 icon = loadPixmap( pathString + "xdays" );
542 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); 594 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 );
543 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 595 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
544 xdays_action->addTo( viewMenu ); 596 xdays_action->addTo( viewMenu );
545 connect( xdays_action, SIGNAL( activated() ), 597 connect( xdays_action, SIGNAL( activated() ),
546 mView->viewManager(), SLOT( showNextXView() ) ); 598 mView->viewManager(), SLOT( showNextXView() ) );
547 599
548 icon = loadPixmap( pathString + "whatsnext" ); 600 icon = loadPixmap( pathString + "whatsnext" );
549 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); 601 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 );
550 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 602 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
551 whatsnext_action->addTo( viewMenu ); 603 whatsnext_action->addTo( viewMenu );
552 connect( whatsnext_action, SIGNAL( activated() ), 604 connect( whatsnext_action, SIGNAL( activated() ),
553 mView->viewManager(), SLOT( showWhatsNextView() ) ); 605 mView->viewManager(), SLOT( showWhatsNextView() ) );
554 606
555#if 0 607#if 0
556 action = new QAction( "view_timespan", "Time Span", 0, this ); 608 action = new QAction( "view_timespan", "Time Span", 0, this );
557 action->addTo( viewMenu ); 609 action->addTo( viewMenu );
558 connect( action, SIGNAL( activated() ), 610 connect( action, SIGNAL( activated() ),
559 mView->viewManager(), SLOT( showTimeSpanView() ) ); 611 mView->viewManager(), SLOT( showTimeSpanView() ) );
560#endif 612#endif
561 613
562 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 614 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
563 this ); 615 this );
564 mNewSubTodoAction->addTo( actionMenu ); 616 mNewSubTodoAction->addTo( actionMenu );
565 connect( mNewSubTodoAction, SIGNAL( activated() ), 617 connect( mNewSubTodoAction, SIGNAL( activated() ),
566 mView, SLOT( newSubTodo() ) ); 618 mView, SLOT( newSubTodo() ) );
567 619
568 actionMenu->insertSeparator(); 620 actionMenu->insertSeparator();
569 621
570 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); 622 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this );
571 mShowAction->addTo( actionMenu ); 623 mShowAction->addTo( actionMenu );
572 connect( mShowAction, SIGNAL( activated() ), 624 connect( mShowAction, SIGNAL( activated() ),
573 mView, SLOT( showIncidence() ) ); 625 mView, SLOT( showIncidence() ) );
574 626
575 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 627 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
576 mEditAction->addTo( actionMenu ); 628 mEditAction->addTo( actionMenu );
577 connect( mEditAction, SIGNAL( activated() ), 629 connect( mEditAction, SIGNAL( activated() ),
578 mView, SLOT( editIncidence() ) ); 630 mView, SLOT( editIncidence() ) );
579 631
580 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 632 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
581 mDeleteAction->addTo( actionMenu ); 633 mDeleteAction->addTo( actionMenu );
582 connect( mDeleteAction, SIGNAL( activated() ), 634 connect( mDeleteAction, SIGNAL( activated() ),
583 mView, SLOT( deleteIncidence() ) ); 635 mView, SLOT( deleteIncidence() ) );
584 636
585 actionMenu->insertSeparator(); 637 actionMenu->insertSeparator();
586 638
587 action = new QAction( "purge_completed", i18n("Purge Completed"), 0, 639 action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
588 this ); 640 this );
589 action->addTo( actionMenu ); 641 action->addTo( actionMenu );
590 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 642 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
591 643
592 icon = loadPixmap( pathString + "search" ); 644 icon = loadPixmap( pathString + "search" );
593 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 645 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
594 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); 646 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4);
595 search_action->addTo( actionMenu ); 647 search_action->addTo( actionMenu );
596 connect( search_action, SIGNAL( activated() ), 648 connect( search_action, SIGNAL( activated() ),
597 mView->dialogManager(), SLOT( showSearchDialog() ) ); 649 mView->dialogManager(), SLOT( showSearchDialog() ) );
598 650
599 icon = loadPixmap( pathString + "today" ); 651 icon = loadPixmap( pathString + "today" );
600 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 652 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
601 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 653 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
602 today_action->addTo( actionMenu ); 654 today_action->addTo( actionMenu );
603 connect( today_action, SIGNAL( activated() ), 655 connect( today_action, SIGNAL( activated() ),
604 mView, SLOT( goToday() ) ); 656 mView, SLOT( goToday() ) );
605 657
606 if ( KOPrefs::instance()->mShowFullMenu ) { 658 if ( KOPrefs::instance()->mShowFullMenu ) {
607 actionMenu->insertSeparator(); 659 actionMenu->insertSeparator();
608 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 660 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
609 661
610 } 662 }
611 // actionMenu->insertSeparator(); 663 // actionMenu->insertSeparator();
612 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 664 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
613 this ); 665 this );
614 action->addTo( importMenu ); 666 action->addTo( importMenu );
615 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 667 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
616 action = new QAction( "import_quick", i18n("Import last file"), 0, 668 action = new QAction( "import_quick", i18n("Import last file"), 0,
617 this ); 669 this );
618 action->addTo( importMenu ); 670 action->addTo( importMenu );
619 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 671 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
620 importMenu->insertSeparator(); 672 importMenu->insertSeparator();
621 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 673 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
622 this ); 674 this );
623 action->addTo( importMenu ); 675 action->addTo( importMenu );
624 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 676 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
625#ifndef DESKTOP_VERSION 677#ifndef DESKTOP_VERSION
626 importMenu->insertSeparator(); 678 importMenu->insertSeparator();
627 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 679 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
628 this ); 680 this );
629 action->addTo( importMenu ); 681 action->addTo( importMenu );
630 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 682 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
631#else 683#else
632#ifdef _WIN32_ 684#ifdef _WIN32_
633 importMenu->insertSeparator(); 685 importMenu->insertSeparator();
634 action = new QAction( "import_ol", i18n("Import from OL"), 0, 686 action = new QAction( "import_ol", i18n("Import from OL"), 0,
635 this ); 687 this );
636 action->addTo( importMenu ); 688 action->addTo( importMenu );
637 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 689 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
638#endif 690#endif
639#endif 691#endif
640 692
641 importMenu->insertSeparator(); 693 importMenu->insertSeparator();
642 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 694 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
643 this ); 695 this );
644 action->addTo( importMenu ); 696 action->addTo( importMenu );
645 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 697 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
646 698
647 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 699 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
648 this ); 700 this );
649 action->addTo( importMenu ); 701 action->addTo( importMenu );
650 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 702 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
651 703
652 importMenu->insertSeparator(); 704 importMenu->insertSeparator();
653 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 705 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
654 this ); 706 this );
655 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 707 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
708
709
710 //LR
711 QPopupMenu *ex2phone = new QPopupMenu( this );
712 ex2phone->insertItem(i18n("Complete calendar..."), 1 );
713 ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
714 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) );
715 importMenu->insertItem( i18n("Export to phone"), ex2phone );
716
656 importMenu->insertSeparator(); 717 importMenu->insertSeparator();
657 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 718 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
658 this ); 719 this );
659 action->addTo( importMenu ); 720 action->addTo( importMenu );
660 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 721 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
661#ifndef DESKTOP_VERSION 722#ifndef DESKTOP_VERSION
662 importMenu->insertSeparator(); 723 importMenu->insertSeparator();
663 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 724 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
664 this ); 725 this );
665 action->addTo( importMenu ); 726 action->addTo( importMenu );
666 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 727 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
667 728
668 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 729 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
669 this ); 730 this );
670 action->addTo( importMenu ); 731 action->addTo( importMenu );
671 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 732 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
672#else 733#else
673 importMenu->insertSeparator(); 734 importMenu->insertSeparator();
674 icon = loadPixmap( pathString + "print" ); 735 icon = loadPixmap( pathString + "print" );
675 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 736 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
676 action->addTo( importMenu ); 737 action->addTo( importMenu );
677 connect( action, SIGNAL( activated() ), 738 connect( action, SIGNAL( activated() ),
678 this, SLOT( printCal() ) ); 739 this, SLOT( printCal() ) );
679 740
680 icon = loadPixmap( pathString + "print" ); 741 icon = loadPixmap( pathString + "print" );
681 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 742 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
682 action->addTo( importMenu ); 743 action->addTo( importMenu );
683 connect( action, SIGNAL( activated() ), 744 connect( action, SIGNAL( activated() ),
684 this, SLOT( printSel() ) ); 745 this, SLOT( printSel() ) );
685#endif 746#endif
686 importMenu->insertSeparator(); 747 importMenu->insertSeparator();
687 action = new QAction( "beam all", i18n("Save"), 0, 748 action = new QAction( "beam all", i18n("Save"), 0,
688 this ); 749 this );
689 action->addTo( importMenu ); 750 action->addTo( importMenu );
690 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 751 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
691 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 752 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
692 this ); 753 this );
693 action->addTo( importMenu ); 754 action->addTo( importMenu );
694 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 755 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
695 756
696 //menuBar->insertItem( "Configure",configureMenu ); 757 //menuBar->insertItem( "Configure",configureMenu );
697 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 758 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
698 icon = loadPixmap( "korganizer/korganizer" ); 759 icon = loadPixmap( "korganizer/korganizer" );
699 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 760 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
700 action->addTo( helpMenu ); 761 action->addTo( helpMenu );
701 connect( action, SIGNAL( activated() ), 762 connect( action, SIGNAL( activated() ),
702 SLOT( keyBindings() ) ); 763 SLOT( keyBindings() ) );
703 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 764 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
704 action->addTo( helpMenu ); 765 action->addTo( helpMenu );
705 connect( action, SIGNAL( activated() ), 766 connect( action, SIGNAL( activated() ),
706 SLOT( features() ) ); 767 SLOT( features() ) );
707 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 768 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
708 action->addTo( helpMenu ); 769 action->addTo( helpMenu );
709 connect( action, SIGNAL( activated() ), 770 connect( action, SIGNAL( activated() ),
710 SLOT( aboutAutoSaving() ) ); 771 SLOT( aboutAutoSaving() ) );
711 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 772 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
712 action->addTo( helpMenu ); 773 action->addTo( helpMenu );
713 connect( action, SIGNAL( activated() ), 774 connect( action, SIGNAL( activated() ),
714 SLOT( aboutKnownBugs() ) ); 775 SLOT( aboutKnownBugs() ) );
715 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 776 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
716 action->addTo( helpMenu ); 777 action->addTo( helpMenu );
717 connect( action, SIGNAL( activated() ), 778 connect( action, SIGNAL( activated() ),
718 SLOT( usertrans() ) ); 779 SLOT( usertrans() ) );
719 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 780 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
720 action->addTo( helpMenu ); 781 action->addTo( helpMenu );
721 connect( action, SIGNAL( activated() ), 782 connect( action, SIGNAL( activated() ),
722 SLOT( synchowto() ) ); 783 SLOT( synchowto() ) );
723 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 784 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
724 action->addTo( helpMenu ); 785 action->addTo( helpMenu );
725 connect( action, SIGNAL( activated() ), 786 connect( action, SIGNAL( activated() ),
726 SLOT( whatsNew() ) ); 787 SLOT( whatsNew() ) );
727 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 788 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
728 action->addTo( helpMenu ); 789 action->addTo( helpMenu );
729 connect( action, SIGNAL( activated() ), 790 connect( action, SIGNAL( activated() ),
730 SLOT( faq() ) ); 791 SLOT( faq() ) );
731 792
732 793
733 action = new QAction( "about", i18n("About..."), 0, this ); 794 action = new QAction( "about", i18n("About..."), 0, this );
734 action->addTo( helpMenu ); 795 action->addTo( helpMenu );
735 connect( action, SIGNAL( activated() ), 796 connect( action, SIGNAL( activated() ),
736 SLOT( about() ) ); 797 SLOT( about() ) );
737 action = new QAction( "licence", i18n("Licence..."), 0, this ); 798 action = new QAction( "licence", i18n("Licence..."), 0, this );
738 action->addTo( helpMenu ); 799 action->addTo( helpMenu );
739 connect( action, SIGNAL( activated() ), 800 connect( action, SIGNAL( activated() ),
740 SLOT( licence() ) ); 801 SLOT( licence() ) );
741 //menuBar->insertSeparator(); 802 //menuBar->insertSeparator();
742 803
743 // ****************************************************** 804 // ******************************************************
744 // menubar icons 805 // menubar icons
745 806
746 807
747 iconToolBar->setHorizontalStretchable (true ); 808 iconToolBar->setHorizontalStretchable (true );
748 //menuBar->insertItem( iconToolBar ); 809 //menuBar->insertItem( iconToolBar );
749 //xdays_action 810 //xdays_action
750 if (p-> mShowIconNewEvent) 811 if (p-> mShowIconNewEvent)
751 ne_action->addTo( iconToolBar ); 812 ne_action->addTo( iconToolBar );
752 if (p->mShowIconNewTodo ) 813 if (p->mShowIconNewTodo )
753 nt_action->addTo( iconToolBar ); 814 nt_action->addTo( iconToolBar );
754 if (p-> mShowIconSearch) 815 if (p-> mShowIconSearch)
755 search_action->addTo( iconToolBar ); 816 search_action->addTo( iconToolBar );
756 if (p-> mShowIconNext) 817 if (p-> mShowIconNext)
757 whatsnext_action->addTo( iconToolBar ); 818 whatsnext_action->addTo( iconToolBar );
758 if (p-> mShowIconNextDays) 819 if (p-> mShowIconNextDays)
759 xdays_action->addTo( iconToolBar ); 820 xdays_action->addTo( iconToolBar );
760 if (p-> mShowIconList) 821 if (p-> mShowIconList)
761 showlist_action->addTo( iconToolBar ); 822 showlist_action->addTo( iconToolBar );
762 if (p-> mShowIconDay1) 823 if (p-> mShowIconDay1)
763 day1_action->addTo( iconToolBar ); 824 day1_action->addTo( iconToolBar );
764 if (p-> mShowIconDay5) 825 if (p-> mShowIconDay5)
765 day5_action->addTo( iconToolBar ); 826 day5_action->addTo( iconToolBar );
766 if (p-> mShowIconDay7) 827 if (p-> mShowIconDay7)
767 day7_action->addTo( iconToolBar ); 828 day7_action->addTo( iconToolBar );
768 if (p-> mShowIconMonth) 829 if (p-> mShowIconMonth)
769 month_action->addTo( iconToolBar ); 830 month_action->addTo( iconToolBar );
770 if (p-> mShowIconTodoview) 831 if (p-> mShowIconTodoview)
771 todoview_action->addTo( iconToolBar ); 832 todoview_action->addTo( iconToolBar );
772 if (p-> mShowIconJournal) 833 if (p-> mShowIconJournal)
773 viewjournal_action->addTo( iconToolBar ); 834 viewjournal_action->addTo( iconToolBar );
774 icon = loadPixmap( pathString + "2leftarrowB" ); 835 icon = loadPixmap( pathString + "2leftarrowB" );
775 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); 836 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14);
776 if (p-> mShowIconBackFast) { 837 if (p-> mShowIconBackFast) {
777 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 838 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
778 connect( action, SIGNAL( activated() ), 839 connect( action, SIGNAL( activated() ),
779 mView, SLOT( goPreviousMonth() ) ); 840 mView, SLOT( goPreviousMonth() ) );
780 action->addTo( iconToolBar ); 841 action->addTo( iconToolBar );
781 } 842 }
782 icon = loadPixmap( pathString + "1leftarrowB" ); 843 icon = loadPixmap( pathString + "1leftarrowB" );
783 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); 844 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15);
784 if (p-> mShowIconBack) { 845 if (p-> mShowIconBack) {
785 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 846 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
786 connect( action, SIGNAL( activated() ), 847 connect( action, SIGNAL( activated() ),
787 mView, SLOT( goPrevious() ) ); 848 mView, SLOT( goPrevious() ) );
788 action->addTo( iconToolBar ); 849 action->addTo( iconToolBar );
789 } 850 }
790 if (p-> mShowIconToday) 851 if (p-> mShowIconToday)
791 today_action->addTo( iconToolBar ); 852 today_action->addTo( iconToolBar );
792 icon = loadPixmap( pathString + "1rightarrowB" ); 853 icon = loadPixmap( pathString + "1rightarrowB" );
793 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 854 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
794 if (p-> mShowIconForward) { 855 if (p-> mShowIconForward) {
795 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 856 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
796 connect( action, SIGNAL( activated() ), 857 connect( action, SIGNAL( activated() ),
797 mView, SLOT( goNext() ) ); 858 mView, SLOT( goNext() ) );
798 action->addTo( iconToolBar ); 859 action->addTo( iconToolBar );
799 } 860 }
800 icon = loadPixmap( pathString + "2rightarrowB" ); 861 icon = loadPixmap( pathString + "2rightarrowB" );
801 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 862 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
802 if (p-> mShowIconForwardFast) { 863 if (p-> mShowIconForwardFast) {
803 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 864 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
804 connect( action, SIGNAL( activated() ), 865 connect( action, SIGNAL( activated() ),
805 mView, SLOT( goNextMonth() ) ); 866 mView, SLOT( goNextMonth() ) );
806 action->addTo( iconToolBar ); 867 action->addTo( iconToolBar );
807 } 868 }
808 869
809 870
810 configureToolBarMenu->insertItem(i18n("What's This?"), 300); 871 configureToolBarMenu->insertItem(i18n("What's This?"), 300);
811 872
812 if (p-> mShowIconNewEvent) 873 if (p-> mShowIconNewEvent)
813 configureToolBarMenu->setItemChecked( 10, true ); 874 configureToolBarMenu->setItemChecked( 10, true );
814 if (p->mShowIconNewTodo ) 875 if (p->mShowIconNewTodo )
815 configureToolBarMenu->setItemChecked( 20, true ); 876 configureToolBarMenu->setItemChecked( 20, true );
816 if (p-> mShowIconSearch) 877 if (p-> mShowIconSearch)
817 configureToolBarMenu->setItemChecked( 120, true ); 878 configureToolBarMenu->setItemChecked( 120, true );
818 if (p-> mShowIconList) 879 if (p-> mShowIconList)
819 configureToolBarMenu->setItemChecked( 30, true ); 880 configureToolBarMenu->setItemChecked( 30, true );
820 if (p-> mShowIconDay1) 881 if (p-> mShowIconDay1)
821 configureToolBarMenu->setItemChecked( 40, true ); 882 configureToolBarMenu->setItemChecked( 40, true );
822 if (p-> mShowIconDay5) 883 if (p-> mShowIconDay5)
823 configureToolBarMenu->setItemChecked( 50, true ); 884 configureToolBarMenu->setItemChecked( 50, true );
824 if (p-> mShowIconDay7) 885 if (p-> mShowIconDay7)
825 configureToolBarMenu->setItemChecked( 60, true ); 886 configureToolBarMenu->setItemChecked( 60, true );
826 if (p-> mShowIconMonth) 887 if (p-> mShowIconMonth)
827 configureToolBarMenu->setItemChecked( 70, true ); 888 configureToolBarMenu->setItemChecked( 70, true );
828 if (p-> mShowIconTodoview) 889 if (p-> mShowIconTodoview)
829 configureToolBarMenu->setItemChecked( 80, true ); 890 configureToolBarMenu->setItemChecked( 80, true );
830 if (p-> mShowIconBackFast) 891 if (p-> mShowIconBackFast)
831 configureToolBarMenu->setItemChecked( 200, true ); 892 configureToolBarMenu->setItemChecked( 200, true );
832 if (p-> mShowIconBack) 893 if (p-> mShowIconBack)
833 configureToolBarMenu->setItemChecked( 210, true ); 894 configureToolBarMenu->setItemChecked( 210, true );
834 if (p-> mShowIconToday) 895 if (p-> mShowIconToday)
835 configureToolBarMenu->setItemChecked( 130, true ); 896 configureToolBarMenu->setItemChecked( 130, true );
836 if (p-> mShowIconForward) 897 if (p-> mShowIconForward)
837 configureToolBarMenu->setItemChecked( 220, true ); 898 configureToolBarMenu->setItemChecked( 220, true );
838 if (p-> mShowIconForwardFast) 899 if (p-> mShowIconForwardFast)
839 configureToolBarMenu->setItemChecked( 230, true ); 900 configureToolBarMenu->setItemChecked( 230, true );
840 if (p-> mShowIconNextDays) 901 if (p-> mShowIconNextDays)
841 configureToolBarMenu->setItemChecked( 100, true ); 902 configureToolBarMenu->setItemChecked( 100, true );
842 if (p-> mShowIconNext) 903 if (p-> mShowIconNext)
843 configureToolBarMenu->setItemChecked( 110, true ); 904 configureToolBarMenu->setItemChecked( 110, true );
844 if (p-> mShowIconJournal) 905 if (p-> mShowIconJournal)
845 configureToolBarMenu->setItemChecked( 90, true ); 906 configureToolBarMenu->setItemChecked( 90, true );
846 if (p-> mShowIconWhatsThis) 907 if (p-> mShowIconWhatsThis)
847 configureToolBarMenu->setItemChecked( 300, true ); 908 configureToolBarMenu->setItemChecked( 300, true );
848 909
849 QLabel* dummy = new QLabel( iconToolBar ); 910 QLabel* dummy = new QLabel( iconToolBar );
850 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 911 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
851 if (!p-> mShowIconStretch) 912 if (!p-> mShowIconStretch)
852 iconToolBar->setStretchableWidget ( dummy ) ; 913 iconToolBar->setStretchableWidget ( dummy ) ;
853 else 914 else
854 configureToolBarMenu->setItemChecked( 5, true ); 915 configureToolBarMenu->setItemChecked( 5, true );
855 if (p-> mShowIconWhatsThis) 916 if (p-> mShowIconWhatsThis)
856 QWhatsThis::whatsThisButton ( iconToolBar ); 917 QWhatsThis::whatsThisButton ( iconToolBar );
857 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 918 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
858 configureAgenda( p->mHourSize ); 919 configureAgenda( p->mHourSize );
859 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 920 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
860} 921}
861void MainWindow::fillSyncMenu() 922void MainWindow::fillSyncMenu()
862{ 923{
863 if ( syncMenu->count() ) 924 if ( syncMenu->count() )
864 syncMenu->clear(); 925 syncMenu->clear();
865 syncMenu->insertItem( i18n("Configure..."), 0 ); 926 syncMenu->insertItem( i18n("Configure..."), 0 );
866 syncMenu->insertSeparator(); 927 syncMenu->insertSeparator();
867 if ( mServerSocket == 0 ) { 928 if ( mServerSocket == 0 ) {
868 syncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); 929 syncMenu->insertItem( i18n("Enable Pi-Sync"), 2 );
869 } else { 930 } else {
870 syncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); 931 syncMenu->insertItem( i18n("Disable Pi-Sync"), 3 );
871 } 932 }
872 syncMenu->insertSeparator(); 933 syncMenu->insertSeparator();
873 syncMenu->insertItem( i18n("Multiple sync"), 1 ); 934 syncMenu->insertItem( i18n("Multiple sync"), 1 );
874 syncMenu->insertSeparator(); 935 syncMenu->insertSeparator();
875 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 936 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
876 config.setGroup("General"); 937 config.setGroup("General");
877 QStringList prof = config.readListEntry("SyncProfileNames"); 938 QStringList prof = config.readListEntry("SyncProfileNames");
878 KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 939 KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined");
879 if ( prof.count() < 3 ) { 940 if ( prof.count() < 3 ) {
880 prof.clear(); 941 prof.clear();
881 prof << i18n("Sharp_DTM"); 942 prof << i18n("Sharp_DTM");
882 prof << i18n("Local_file"); 943 prof << i18n("Local_file");
883 prof << i18n("Last_file"); 944 prof << i18n("Last_file");
884 KSyncProfile* temp = new KSyncProfile (); 945 KSyncProfile* temp = new KSyncProfile ();
885 temp->setName( prof[0] ); 946 temp->setName( prof[0] );
886 temp->writeConfig(&config); 947 temp->writeConfig(&config);
887 temp->setName( prof[1] ); 948 temp->setName( prof[1] );
888 temp->writeConfig(&config); 949 temp->writeConfig(&config);
889 temp->setName( prof[2] ); 950 temp->setName( prof[2] );
890 temp->writeConfig(&config); 951 temp->writeConfig(&config);
891 config.setGroup("General"); 952 config.setGroup("General");
892 config.writeEntry("SyncProfileNames",prof); 953 config.writeEntry("SyncProfileNames",prof);
893 config.writeEntry("ExternSyncProfiles","Sharp_DTM"); 954 config.writeEntry("ExternSyncProfiles","Sharp_DTM");
894 config.sync(); 955 config.sync();
895 delete temp; 956 delete temp;
896 } 957 }
897 KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 958 KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
898 KOPrefs::instance()->mSyncProfileNames = prof; 959 KOPrefs::instance()->mSyncProfileNames = prof;
899 int i; 960 int i;
900 for ( i = 0; i < prof.count(); ++i ) { 961 for ( i = 0; i < prof.count(); ++i ) {
901 962
902 syncMenu->insertItem( prof[i], 1000+i ); 963 syncMenu->insertItem( prof[i], 1000+i );
903 if ( i == 2 ) 964 if ( i == 2 )
904 syncMenu->insertSeparator(); 965 syncMenu->insertSeparator();
905 } 966 }
906 QDir app_dir; 967 QDir app_dir;
907 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 968 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
908 syncMenu->setItemEnabled( false , 1000 ); 969 syncMenu->setItemEnabled( false , 1000 );
909 } 970 }
910 mView->setupExternSyncProfiles(); 971 mView->setupExternSyncProfiles();
911} 972}
912 973
913int MainWindow::ringSync() 974int MainWindow::ringSync()
914{ 975{
915 int syncedProfiles = 0; 976 int syncedProfiles = 0;
916 int i; 977 int i;
917 QTime timer; 978 QTime timer;
918 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 979 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
919 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; 980 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames;
920 KSyncProfile* temp = new KSyncProfile (); 981 KSyncProfile* temp = new KSyncProfile ();
921 KOPrefs::instance()->mAskForPreferences = false; 982 KOPrefs::instance()->mAskForPreferences = false;
922 for ( i = 0; i < syncProfileNames.count(); ++i ) { 983 for ( i = 0; i < syncProfileNames.count(); ++i ) {
923 mCurrentSyncProfile = i; 984 mCurrentSyncProfile = i;
924 temp->setName(syncProfileNames[mCurrentSyncProfile]); 985 temp->setName(syncProfileNames[mCurrentSyncProfile]);
925 temp->readConfig(&config); 986 temp->readConfig(&config);
926 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { 987 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) {
927 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 988 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
928 ++syncedProfiles; 989 ++syncedProfiles;
929 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 990 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
930 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 991 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
931 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 992 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
932 KOPrefs::instance()->mWriteBackInFuture = 0; 993 KOPrefs::instance()->mWriteBackInFuture = 0;
933 if ( temp->getWriteBackFuture() ) 994 if ( temp->getWriteBackFuture() )
934 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 995 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
935 KOPrefs::instance()->mShowSyncSummary = false; 996 KOPrefs::instance()->mShowSyncSummary = false;
936 mView->setSyncDevice(syncProfileNames[i] ); 997 mView->setSyncDevice(syncProfileNames[i] );
937 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 998 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
938 if ( i == 0 ) { 999 if ( i == 0 ) {
939 syncSharp(); 1000 syncSharp();
940 } else { 1001 } else {
941 if ( temp->getIsLocalFileSync() ) { 1002 if ( temp->getIsLocalFileSync() ) {
942 if ( syncWithFile( temp->getRemoteFileName( ), true ) ) 1003 if ( syncWithFile( temp->getRemoteFileName( ), true ) )
943 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 1004 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
944 } else { 1005 } else {
945 if ( temp->getIsPhoneSync() ) { 1006 if ( temp->getIsPhoneSync() ) {
946 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; 1007 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
947 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); 1008 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
948 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); 1009 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
949 syncPhone(); 1010 syncPhone();
950 } else if ( temp->getIsPiSync() ) { 1011 } else if ( temp->getIsPiSync() ) {
951 mPassWordPiSync = temp->getRemotePw(); 1012 mPassWordPiSync = temp->getRemotePw();
952 KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort(); 1013 KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort();
953 KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP(); 1014 KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP();
954 syncPi(); 1015 syncPi();
955 } else 1016 } else
956 syncRemote( temp, false ); 1017 syncRemote( temp, false );
957 1018
958 } 1019 }
959 } 1020 }
960 timer.start(); 1021 timer.start();
961 setCaption(i18n("Multiple sync in progress ... please wait!") ); 1022 setCaption(i18n("Multiple sync in progress ... please wait!") );
962 while ( timer.elapsed () < 2000 ) { 1023 while ( timer.elapsed () < 2000 ) {
963 qApp->processEvents(); 1024 qApp->processEvents();
964#ifndef _WIN32_ 1025#ifndef _WIN32_
965 sleep (1); 1026 sleep (1);
966#endif 1027#endif
967 } 1028 }
968 1029
969 } 1030 }
970 1031
971 } 1032 }
972 delete temp; 1033 delete temp;
973 return syncedProfiles; 1034 return syncedProfiles;
974} 1035}
975 1036
976void MainWindow::multiSync( bool askforPrefs ) 1037void MainWindow::multiSync( bool askforPrefs )
977{ 1038{
978 if (mBlockSaveFlag) 1039 if (mBlockSaveFlag)
979 return; 1040 return;
980 mBlockSaveFlag = true; 1041 mBlockSaveFlag = true;
981 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 1042 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
982 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 1043 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
983 question, 1044 question,
984 i18n("Yes"), i18n("No"), 1045 i18n("Yes"), i18n("No"),
985 0, 0 ) != 0 ) { 1046 0, 0 ) != 0 ) {
986 mBlockSaveFlag = false; 1047 mBlockSaveFlag = false;
987 setCaption(i18n("Aborted! Nothing synced!")); 1048 setCaption(i18n("Aborted! Nothing synced!"));
988 return; 1049 return;
989 } 1050 }
990 mView->setSyncDevice(i18n("Multiple profiles") ); 1051 mView->setSyncDevice(i18n("Multiple profiles") );
991 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; 1052 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs;
992 if ( askforPrefs ) { 1053 if ( askforPrefs ) {
993 mView->edit_sync_options(); 1054 mView->edit_sync_options();
994 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; 1055 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs;
995 } 1056 }
996 setCaption(i18n("Multiple sync started.") ); 1057 setCaption(i18n("Multiple sync started.") );
997 qApp->processEvents(); 1058 qApp->processEvents();
998 int num = ringSync() ; 1059 int num = ringSync() ;
999 if ( num > 1 ) 1060 if ( num > 1 )
1000 ringSync(); 1061 ringSync();
1001 mBlockSaveFlag = false; 1062 mBlockSaveFlag = false;
1002 if ( num ) 1063 if ( num )
1003 save(); 1064 save();
1004 if ( num ) 1065 if ( num )
1005 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); 1066 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
1006 else 1067 else
1007 setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 1068 setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
1008 return; 1069 return;
1009} 1070}
1010void MainWindow::slotSyncMenu( int action ) 1071void MainWindow::slotSyncMenu( int action )
1011{ 1072{
1012 qDebug("syncaction %d ", action); 1073 qDebug("syncaction %d ", action);
1013 if ( action == 0 ) { 1074 if ( action == 0 ) {
1014 1075
1015 // seems to be a Qt2 event handling bug 1076 // seems to be a Qt2 event handling bug
1016 // syncmenu.clear causes a segfault at first time 1077 // syncmenu.clear causes a segfault at first time
1017 // when we call it after the main event loop, it is ok 1078 // when we call it after the main event loop, it is ok
1018 // same behaviour when calling OM/Pi via QCOP for the first time 1079 // same behaviour when calling OM/Pi via QCOP for the first time
1019 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 1080 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
1020 //confSync(); 1081 //confSync();
1021 1082
1022 return; 1083 return;
1023 } 1084 }
1024 if ( action == 1 ) { 1085 if ( action == 1 ) {
1025 multiSync( true ); 1086 multiSync( true );
1026 return; 1087 return;
1027 } 1088 }
1028 if ( action == 2 ) { 1089 if ( action == 2 ) {
1029 enableQuick(); 1090 enableQuick();
1030 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 1091 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
1031 return; 1092 return;
1032 } 1093 }
1033 if ( action == 3 ) { 1094 if ( action == 3 ) {
1034 delete mServerSocket; 1095 delete mServerSocket;
1035 mServerSocket = 0; 1096 mServerSocket = 0;
1036 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 1097 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
1037 return; 1098 return;
1038 } 1099 }
1039 1100
1040 if (mBlockSaveFlag) 1101 if (mBlockSaveFlag)
1041 return; 1102 return;
1042 mBlockSaveFlag = true; 1103 mBlockSaveFlag = true;
1043 mCurrentSyncProfile = action - 1000 ; 1104 mCurrentSyncProfile = action - 1000 ;
1044 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); 1105 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] );
1045 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 1106 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
1046 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 1107 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
1047 KSyncProfile* temp = new KSyncProfile (); 1108 KSyncProfile* temp = new KSyncProfile ();
1048 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 1109 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
1049 temp->readConfig(&config); 1110 temp->readConfig(&config);
1050 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 1111 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
1051 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); 1112 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
1052 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 1113 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
1053 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 1114 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
1054 KOPrefs::instance()->mWriteBackInFuture = 0; 1115 KOPrefs::instance()->mWriteBackInFuture = 0;
1055 if ( temp->getWriteBackFuture() ) 1116 if ( temp->getWriteBackFuture() )
1056 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 1117 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
1057 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); 1118 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
1058 if ( action == 1000 ) { 1119 if ( action == 1000 ) {
1059 syncSharp(); 1120 syncSharp();
1060 1121
1061 } else if ( action == 1001 ) { 1122 } else if ( action == 1001 ) {
1062 syncLocalFile(); 1123 syncLocalFile();
1063 1124
1064 } else if ( action == 1002 ) { 1125 } else if ( action == 1002 ) {
1065 quickSyncLocalFile(); 1126 quickSyncLocalFile();
1066 1127
1067 } else if ( action >= 1003 ) { 1128 } else if ( action >= 1003 ) {
1068 if ( temp->getIsLocalFileSync() ) { 1129 if ( temp->getIsLocalFileSync() ) {
1069 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 1130 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
1070 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 1131 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
1071 } else { 1132 } else {
1072 if ( temp->getIsPhoneSync() ) { 1133 if ( temp->getIsPhoneSync() ) {
1073 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; 1134 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
1074 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); 1135 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
1075 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); 1136 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
1076 syncPhone(); 1137 syncPhone();
1077 } else if ( temp->getIsPiSync() ) { 1138 } else if ( temp->getIsPiSync() ) {
1078 mPassWordPiSync = temp->getRemotePw(); 1139 mPassWordPiSync = temp->getRemotePw();
1079 KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort(); 1140 KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort();
1080 KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP(); 1141 KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP();
1081 syncPi(); 1142 syncPi();
1082 } else 1143 } else
1083 syncRemote( temp ); 1144 syncRemote( temp );
1084 1145
1085 } 1146 }
1086 } 1147 }
1087 delete temp; 1148 delete temp;
1088 mBlockSaveFlag = false; 1149 mBlockSaveFlag = false;
1089} 1150}
1151void MainWindow::exportToPhone( int mode )
1152{
1153
1154 //ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1155 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1156 KOex2phonePrefs ex2phone;
1157 ex2phone.mPhoneConnection->setText( KOPrefs::instance()->mEx2PhoneConnection );
1158 ex2phone.mPhoneDevice->setText( KOPrefs::instance()->mEx2PhoneDevice );
1159 ex2phone.mPhoneModel->setText( KOPrefs::instance()->mEx2PhoneModel );
1160
1161 if ( !ex2phone.exec() ) {
1162 return;
1163 }
1164 KOPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
1165 KOPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
1166 KOPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
1167
1168 int inFuture = 0;
1169 if ( ex2phone.mWriteBackFuture->isChecked() )
1170 inFuture = ex2phone.mWriteBackFutureWeeks->value();
1171 QPtrList<Incidence> delSel;
1172 if ( mode == 1 )
1173 delSel = mCalendar->rawIncidences();
1174 if ( mode == 2 )
1175 delSel = mCalendar->incidences();
1176 CalendarLocal* cal = new CalendarLocal();
1177 cal->setLocalTime();
1178 Incidence *incidence = delSel.first();
1179 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1180 QDateTime end = cur.addDays( ( inFuture +1 ) *7 );
1181 while ( incidence ) {
1182 if ( incidence->type() != "journal" ) {
1183 bool add = true;
1184 if ( inFuture ) {
1185 QDateTime dt;
1186 if ( incidence->type() == "Todo" ) {
1187 Todo * t = (Todo*)incidence;
1188 if ( t->hasDueDate() )
1189 dt = t->dtDue();
1190 else
1191 dt = cur.addSecs( 62 );
1192 }
1193 else {
1194 bool ok;
1195 dt = incidence->getNextOccurence( cur, &ok );
1196 if ( !ok )
1197 dt = cur.addSecs( -62 );
1198 }
1199 if ( dt < cur || dt > end ) {
1200 add = false;
1201 }
1202 }
1203 if ( add ) {
1204 Incidence *in = incidence->clone();
1205 cal->addIncidence( in );
1206 }
1207 }
1208 incidence = delSel.next();
1209 }
1210 PhoneFormat::writeConfig( KOPrefs::instance()->mEx2PhoneDevice,
1211 KOPrefs::instance()->mEx2PhoneConnection,
1212 KOPrefs::instance()->mEx2PhoneModel );
1213
1214 setCaption( i18n("Writing to phone..."));
1215 if ( PhoneFormat::writeToPhone( cal ) )
1216 setCaption( i18n("Export to phone successful!"));
1217 else
1218 setCaption( i18n("Error exporting to phone!"));
1219 delete cal;
1220}
1221
1222
1090void MainWindow::setDefaultPreferences() 1223void MainWindow::setDefaultPreferences()
1091{ 1224{
1092 KOPrefs *p = KOPrefs::instance(); 1225 KOPrefs *p = KOPrefs::instance();
1093 1226
1094 p->mCompactDialogs = true; 1227 p->mCompactDialogs = true;
1095 p->mConfirm = true; 1228 p->mConfirm = true;
1096 // p->mEnableQuickTodo = false; 1229 // p->mEnableQuickTodo = false;
1230
1097} 1231}
1098 1232
1099QString MainWindow::resourcePath() 1233QString MainWindow::resourcePath()
1100{ 1234{
1101 return KGlobal::iconLoader()->iconPath(); 1235 return KGlobal::iconLoader()->iconPath();
1102} 1236}
1103 1237
1104void MainWindow::displayText( QString text ,QString cap ) 1238void MainWindow::displayText( QString text ,QString cap )
1105{ 1239{
1106 QDialog dia( this, "name", true ); ; 1240 QDialog dia( this, "name", true ); ;
1107 dia.setCaption( cap ); 1241 dia.setCaption( cap );
1108 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1242 QVBoxLayout* lay = new QVBoxLayout( &dia );
1109 lay->setSpacing( 3 ); 1243 lay->setSpacing( 3 );
1110 lay->setMargin( 3 ); 1244 lay->setMargin( 3 );
1111 QTextBrowser tb ( &dia ); 1245 QTextBrowser tb ( &dia );
1112 lay->addWidget( &tb ); 1246 lay->addWidget( &tb );
1113 tb.setText( text ); 1247 tb.setText( text );
1114#ifdef DESKTOP_VERSION 1248#ifdef DESKTOP_VERSION
1115 dia.resize( 640, 480); 1249 dia.resize( 640, 480);
1116#else 1250#else
1117 dia.showMaximized(); 1251 dia.showMaximized();
1118#endif 1252#endif
1119 dia.exec(); 1253 dia.exec();
1120} 1254}
1121void MainWindow::displayFile( QString fn, QString cap ) 1255void MainWindow::displayFile( QString fn, QString cap )
1122{ 1256{
1123 QString fileName = resourcePath() + fn; 1257 QString fileName = resourcePath() + fn;
1124 QString text; 1258 QString text;
1125 QFile file( fileName ); 1259 QFile file( fileName );
1126 if (!file.open( IO_ReadOnly ) ) { 1260 if (!file.open( IO_ReadOnly ) ) {
1127 return ; 1261 return ;
1128 1262
1129 } 1263 }
1130 QTextStream ts( &file ); 1264 QTextStream ts( &file );
1131 text = ts.read(); 1265 text = ts.read();
1132 file.close(); 1266 file.close();
1133 displayText( text, cap); 1267 displayText( text, cap);
1134} 1268}
1135void MainWindow::features() 1269void MainWindow::features()
1136{ 1270{
1137 1271
1138 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); 1272 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") );
1139} 1273}
1140 1274
1141void MainWindow::usertrans() 1275void MainWindow::usertrans()
1142{ 1276{
1143 1277
1144 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); 1278 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") );
1145} 1279}
1146 1280
1147void MainWindow::synchowto() 1281void MainWindow::synchowto()
1148{ 1282{
1149#if 0 1283#if 0
1150 QPtrList<Incidence> er = mCalendar->rawIncidences(); 1284 QPtrList<Incidence> er = mCalendar->rawIncidences();
1151 Incidence* inR = er.first(); 1285 Incidence* inR = er.first();
1152 VCalFormat vf; 1286 VCalFormat vf;
1153 QString strout; 1287 QString strout;
1154 while ( inR ) { 1288 while ( inR ) {
1155 if ( inR->type() == "Todo" ) 1289 if ( inR->type() == "Todo" )
1156 strout = vf.todoToString( (Todo *) inR ); 1290 strout = vf.todoToString( (Todo *) inR );
1157 if ( inR->type() == "Event" ) 1291 if ( inR->type() == "Event" )
1158 strout = vf.eventToString( (Event *) inR ); 1292 strout = vf.eventToString( (Event *) inR );
1159 qDebug("incidence: \n%s\n ente\n\n",strout.latin1() ); 1293 qDebug("incidence: \n%s\n ente\n\n",strout.latin1() );
1160 inR = er.next(); 1294 inR = er.next();
1161 } 1295 }
1162#endif 1296#endif
1163 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); 1297 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") );
1164} 1298}
1165void MainWindow::faq() 1299void MainWindow::faq()
1166{ 1300{
1167 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); 1301 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") );
1168 1302
1169} 1303}
1170void MainWindow::whatsNew() 1304void MainWindow::whatsNew()
1171{ 1305{
1172 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); 1306 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") );
1173 1307
1174} 1308}
1175void MainWindow::licence() 1309void MainWindow::licence()
1176{ 1310{
1177 KApplication::showLicence(); 1311 KApplication::showLicence();
1178 1312
1179} 1313}
1180void MainWindow::about() 1314void MainWindow::about()
1181{ 1315{
1182 QString version; 1316 QString version;
1183#include <../version> 1317#include <../version>
1184 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1318 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1185 i18n("KOrganizer/Platform-independent\n") + 1319 i18n("KOrganizer/Platform-independent\n") +
1186 "(KO/Pi) " + version + " - " + 1320 "(KO/Pi) " + version + " - " +
1187 1321
1188#ifdef DESKTOP_VERSION 1322#ifdef DESKTOP_VERSION
1189 i18n("Desktop Edition\n") + 1323 i18n("Desktop Edition\n") +
1190#else 1324#else
1191 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + 1325 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") +
1192#endif 1326#endif
1193 i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); 1327 i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") );
1194} 1328}
1195void MainWindow::keyBindings() 1329void MainWindow::keyBindings()
1196{ 1330{
1197 QString cap = i18n("Key bindings KOrganizer/Pi"); 1331 QString cap = i18n("Key bindings KOrganizer/Pi");
1198 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1332 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1199 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1333 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1200 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1334 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1201 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1335 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1202 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1336 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1203 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1337 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1204 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1338 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1205 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ 1339 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
1206 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1340 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1207 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1341 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1208 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1342 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1209 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1343 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1210 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1344 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1211 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ 1345 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
1212 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1346 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1213 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1347 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1214 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1348 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1215 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1349 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1216 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1350 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1217 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1351 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1218 i18n("<p><h3>In agenda view:</h3></p>\n") + 1352 i18n("<p><h3>In agenda view:</h3></p>\n") +
1219 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1353 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1220 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1354 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1221 i18n("<p><h3>In todo view:</h3></p>\n") + 1355 i18n("<p><h3>In todo view:</h3></p>\n") +
1222 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1356 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1223 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1357 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1224 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1358 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1225 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1359 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1226 i18n("<p><h3>In list view:</h3></p>\n") + 1360 i18n("<p><h3>In list view:</h3></p>\n") +
1227 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1361 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1228 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1362 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1229 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1363 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1230 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1364 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1231 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1365 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1232 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1366 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1233 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1367 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1234 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1368 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1235 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1369 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1236 i18n("<p><b>E</b>: Edit item</p>\n") + 1370 i18n("<p><b>E</b>: Edit item</p>\n") +
1237 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1371 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1238 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1372 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1239 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1373 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1240 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1374 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1241 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1375 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1242 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1376 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1243 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1377 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1244 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1378 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1245 i18n("<p><b>White</b>: Item readonly</p>\n"); 1379 i18n("<p><b>White</b>: Item readonly</p>\n");
1246 displayText( text, cap); 1380 displayText( text, cap);
1247 1381
1248} 1382}
1249void MainWindow::aboutAutoSaving() 1383void MainWindow::aboutAutoSaving()
1250{ 1384{
1251 QMessageBox* msg; 1385 QMessageBox* msg;
1252 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), 1386 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"),
1253 i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon, 1387 i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon,
1254 QMessageBox::Ok, 1388 QMessageBox::Ok,
1255 QMessageBox::NoButton, 1389 QMessageBox::NoButton,
1256 QMessageBox::NoButton); 1390 QMessageBox::NoButton);
1257 msg->exec(); 1391 msg->exec();
1258 delete msg; 1392 delete msg;
1259 1393
1260 1394
1261} 1395}
1262void MainWindow::aboutKnownBugs() 1396void MainWindow::aboutKnownBugs()
1263{ 1397{
1264 QMessageBox* msg; 1398 QMessageBox* msg;
1265 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1399 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1266 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ 1400 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+
1267 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1401 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1268 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + 1402 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") +
1269 i18n("\nor report them in the bugtracker on\n") + 1403 i18n("\nor report them in the bugtracker on\n") +
1270 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1404 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1271 QMessageBox::NoIcon, 1405 QMessageBox::NoIcon,
1272 QMessageBox::Ok, 1406 QMessageBox::Ok,
1273 QMessageBox::NoButton, 1407 QMessageBox::NoButton,
1274 QMessageBox::NoButton); 1408 QMessageBox::NoButton);
1275 msg->exec(); 1409 msg->exec();
1276 delete msg; 1410 delete msg;
1277 1411
1278} 1412}
1279 1413
1280QString MainWindow::defaultFileName() 1414QString MainWindow::defaultFileName()
1281{ 1415{
1282 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1416 return locateLocal( "data", "korganizer/mycalendar.ics" );
1283} 1417}
1284QString MainWindow::syncFileName() 1418QString MainWindow::syncFileName()
1285{ 1419{
1286#ifdef _WIN32_ 1420#ifdef _WIN32_
1287 return locateLocal( "tmp", "synccalendar.ics" ); 1421 return locateLocal( "tmp", "synccalendar.ics" );
1288#else 1422#else
1289 return QString( "/tmp/kopitempfile.ics" ); 1423 return QString( "/tmp/kopitempfile.ics" );
1290#endif 1424#endif
1291} 1425}
1292 1426
1293void MainWindow::processIncidenceSelection( Incidence *incidence ) 1427void MainWindow::processIncidenceSelection( Incidence *incidence )
1294{ 1428{
1295 if ( !incidence ) { 1429 if ( !incidence ) {
1296 enableIncidenceActions( false ); 1430 enableIncidenceActions( false );
1297 1431
1298 mNewSubTodoAction->setEnabled( false ); 1432 mNewSubTodoAction->setEnabled( false );
1299 setCaptionToDates(); 1433 setCaptionToDates();
1300 return; 1434 return;
1301 1435
1302 } 1436 }
1303 1437
1304 //KGlobal::locale()->formatDateTime(nextA, true); 1438 //KGlobal::locale()->formatDateTime(nextA, true);
1305 QString startString = ""; 1439 QString startString = "";
1306 if ( incidence->type() != "Todo" ) { 1440 if ( incidence->type() != "Todo" ) {
1307 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1441 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1308 if ( incidence->doesFloat() ) { 1442 if ( incidence->doesFloat() ) {
1309 startString += ": "+incidence->dtStartDateStr( true ); 1443 startString += ": "+incidence->dtStartDateStr( true );
1310 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1444 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1311 1445
1312 } else { 1446 } else {
1313 startString = ": "+incidence->dtStartStr(true); 1447 startString = ": "+incidence->dtStartStr(true);
1314 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1448 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1315 1449
1316 } 1450 }
1317 1451
1318 } else { 1452 } else {
1319 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1453 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1320 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1454 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1321 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1455 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1322 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1456 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1323 } 1457 }
1324 1458
1325 } 1459 }
1326 else 1460 else
1327 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1461 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1328 if ( !incidence->location().isEmpty() ) 1462 if ( !incidence->location().isEmpty() )
1329 startString += " (" +incidence->location()+")"; 1463 startString += " (" +incidence->location()+")";
1330 setCaption( incidence->summary()+startString); 1464 setCaption( incidence->summary()+startString);
1331 1465
1332 enableIncidenceActions( true ); 1466 enableIncidenceActions( true );
1333 1467
1334 if ( incidence->type() == "Event" ) { 1468 if ( incidence->type() == "Event" ) {
1335 mShowAction->setText( i18n("Show Event...") ); 1469 mShowAction->setText( i18n("Show Event...") );
1336 mEditAction->setText( i18n("Edit Event...") ); 1470 mEditAction->setText( i18n("Edit Event...") );
1337 mDeleteAction->setText( i18n("Delete Event...") ); 1471 mDeleteAction->setText( i18n("Delete Event...") );
1338 1472
1339 mNewSubTodoAction->setEnabled( false ); 1473 mNewSubTodoAction->setEnabled( false );
1340 } else if ( incidence->type() == "Todo" ) { 1474 } else if ( incidence->type() == "Todo" ) {
1341 mShowAction->setText( i18n("Show Todo...") ); 1475 mShowAction->setText( i18n("Show Todo...") );
1342 mEditAction->setText( i18n("Edit Todo...") ); 1476 mEditAction->setText( i18n("Edit Todo...") );
1343 mDeleteAction->setText( i18n("Delete Todo...") ); 1477 mDeleteAction->setText( i18n("Delete Todo...") );
1344 1478
1345 mNewSubTodoAction->setEnabled( true ); 1479 mNewSubTodoAction->setEnabled( true );
1346 } else { 1480 } else {
1347 mShowAction->setText( i18n("Show...") ); 1481 mShowAction->setText( i18n("Show...") );
1348 mShowAction->setText( i18n("Edit...") ); 1482 mShowAction->setText( i18n("Edit...") );
1349 mShowAction->setText( i18n("Delete...") ); 1483 mShowAction->setText( i18n("Delete...") );
1350 1484
1351 mNewSubTodoAction->setEnabled( false ); 1485 mNewSubTodoAction->setEnabled( false );
1352 } 1486 }
1353} 1487}
1354 1488
1355void MainWindow::enableIncidenceActions( bool enabled ) 1489void MainWindow::enableIncidenceActions( bool enabled )
1356{ 1490{
1357 mShowAction->setEnabled( enabled ); 1491 mShowAction->setEnabled( enabled );
1358 mEditAction->setEnabled( enabled ); 1492 mEditAction->setEnabled( enabled );
1359 mDeleteAction->setEnabled( enabled ); 1493 mDeleteAction->setEnabled( enabled );
1360} 1494}
1361 1495
1362void MainWindow::importOL() 1496void MainWindow::importOL()
1363{ 1497{
1364#ifdef _WIN32_ 1498#ifdef _WIN32_
1365 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1499 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1366 id->exec(); 1500 id->exec();
1367 delete id; 1501 delete id;
1368 mView->updateView(); 1502 mView->updateView();
1369#endif 1503#endif
1370} 1504}
1371void MainWindow::importBday() 1505void MainWindow::importBday()
1372{ 1506{
1373 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1507 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1374 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1508 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1375 i18n("Import!"), i18n("Cancel"), 0, 1509 i18n("Import!"), i18n("Cancel"), 0,
1376 0, 1 ); 1510 0, 1 );
1377 if ( result == 0 ) { 1511 if ( result == 0 ) {
1378 mView->importBday(); 1512 mView->importBday();
1379 1513
1380 } 1514 }
1381 1515
1382 1516
1383} 1517}
1384void MainWindow::importQtopia() 1518void MainWindow::importQtopia()
1385{ 1519{
1386#ifndef DESKTOP_VERSION 1520#ifndef DESKTOP_VERSION
1387 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1521 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1388 i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), 1522 i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"),
1389 i18n("Import!"), i18n("Cancel"), 0, 1523 i18n("Import!"), i18n("Cancel"), 0,
1390 0, 1 ); 1524 0, 1 );
1391 if ( result == 0 ) { 1525 if ( result == 0 ) {
1392 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1526 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1393 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1527 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1394 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1528 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1395 mView->importQtopia( categories, datebook, todolist ); 1529 mView->importQtopia( categories, datebook, todolist );
1396 } 1530 }
1397#else 1531#else
1398 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1532 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1399 i18n("Not supported \non desktop!\n"), 1533 i18n("Not supported \non desktop!\n"),
1400 i18n("Ok"), i18n("Cancel"), 0, 1534 i18n("Ok"), i18n("Cancel"), 0,
1401 0, 1 ); 1535 0, 1 );
1402 1536
1403#endif 1537#endif
1404} 1538}
1405 1539
1406void MainWindow::saveOnClose() 1540void MainWindow::saveOnClose()
1407{ 1541{
1408 KOPrefs *p = KOPrefs::instance(); 1542 KOPrefs *p = KOPrefs::instance();
1409 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1543 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1410 p->mToolBarUp = iconToolBar->x() > width()/2 || 1544 p->mToolBarUp = iconToolBar->x() > width()/2 ||
1411 iconToolBar->y() > height()/2; 1545 iconToolBar->y() > height()/2;
1412 mView->writeSettings(); 1546 mView->writeSettings();
1413 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1547 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1414 save(); 1548 save();
1415} 1549}
1416void MainWindow::slotModifiedChanged( bool changed ) 1550void MainWindow::slotModifiedChanged( bool changed )
1417{ 1551{
1418 if ( mBlockAtStartup ) 1552 if ( mBlockAtStartup )
1419 return; 1553 return;
1420 int msec; 1554 int msec;
1421 // we store the changes after 1 minute, 1555 // we store the changes after 1 minute,
1422 // and for safety reasons after 10 minutes again 1556 // and for safety reasons after 10 minutes again
1423 if ( !mBlockSaveFlag ) 1557 if ( !mBlockSaveFlag )
1424 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1558 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1425 else 1559 else
1426 msec = 1000 * 600; 1560 msec = 1000 * 600;
1427 mSaveTimer.start( msec, true ); // 1 minute 1561 mSaveTimer.start( msec, true ); // 1 minute
1428 qDebug("KO: Saving File in %d secs!", msec/1000); 1562 qDebug("KO: Saving File in %d secs!", msec/1000);
1429 mCalendarModifiedFlag = true; 1563 mCalendarModifiedFlag = true;
1430} 1564}
1431void MainWindow::save() 1565void MainWindow::save()
1432{ 1566{
1433 if ( mBlockSaveFlag ) 1567 if ( mBlockSaveFlag )
1434 return; 1568 return;
1435 bool store = mBlockSaveFlag; 1569 bool store = mBlockSaveFlag;
1436 mBlockSaveFlag = true; 1570 mBlockSaveFlag = true;
1437 if ( mView->checkFileVersion( defaultFileName()) ) { 1571 if ( mView->checkFileVersion( defaultFileName()) ) {
1438 1572
1439 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1573 QTime neededSaveTime = QDateTime::currentDateTime().time();
1440 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1574 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1441 qDebug("KO: Start saving data to file!"); 1575 qDebug("KO: Start saving data to file!");
1442 mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1576 mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1443 mView->saveCalendar( defaultFileName() ); 1577 mView->saveCalendar( defaultFileName() );
1444 1578
1445 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1579 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1446 mView->watchSavedFile(); 1580 mView->watchSavedFile();
1447 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1581 qDebug("KO: Needed %d ms for saving.",msNeeded );
1448 QString savemes; 1582 QString savemes;
1449 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1583 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1450 setCaption(savemes); 1584 setCaption(savemes);
1451 } else 1585 } else
1452 setCaption(i18n("Saving cancelled!")); 1586 setCaption(i18n("Saving cancelled!"));
1453 mCalendarModifiedFlag = false; 1587 mCalendarModifiedFlag = false;
1454 mBlockSaveFlag = store; 1588 mBlockSaveFlag = store;
1455} 1589}
1456 1590
1457void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1591void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1458{ 1592{
1459 if ( !e->isAutoRepeat() ) { 1593 if ( !e->isAutoRepeat() ) {
1460 mFlagKeyPressed = false; 1594 mFlagKeyPressed = false;
1461 } 1595 }
1462} 1596}
1463void MainWindow::keyPressEvent ( QKeyEvent * e ) 1597void MainWindow::keyPressEvent ( QKeyEvent * e )
1464{ 1598{
1465 qApp->processEvents(); 1599 qApp->processEvents();
1466 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1600 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1467 e->ignore(); 1601 e->ignore();
1468 // qDebug(" ignore %d",e->isAutoRepeat() ); 1602 // qDebug(" ignore %d",e->isAutoRepeat() );
1469 return; 1603 return;
1470 } 1604 }
1471 if (! e->isAutoRepeat() ) 1605 if (! e->isAutoRepeat() )
1472 mFlagKeyPressed = true; 1606 mFlagKeyPressed = true;
1473 KOPrefs *p = KOPrefs::instance(); 1607 KOPrefs *p = KOPrefs::instance();
1474 bool showSelectedDates = false; 1608 bool showSelectedDates = false;
1475 int size; 1609 int size;
1476 int pro = 0; 1610 int pro = 0;
1477 //qDebug("MainWindow::keyPressEvent "); 1611 //qDebug("MainWindow::keyPressEvent ");
1478 switch ( e->key() ) { 1612 switch ( e->key() ) {
1479 case Qt::Key_Right: 1613 case Qt::Key_Right:
1480 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1614 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index 7b24b88..74c7f45 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -1,209 +1,210 @@
1#ifndef KORGE_MAINWINDOW_H 1#ifndef KORGE_MAINWINDOW_H
2#define KORGE_MAINWINDOW_H 2#define KORGE_MAINWINDOW_H
3 3
4#include <qmainwindow.h> 4#include <qmainwindow.h>
5#include <qtimer.h> 5#include <qtimer.h>
6#include <qdict.h> 6#include <qdict.h>
7#include <qfile.h> 7#include <qfile.h>
8#include <qsocket.h> 8#include <qsocket.h>
9#include <qtextstream.h> 9#include <qtextstream.h>
10#include <qregexp.h> 10#include <qregexp.h>
11 11
12#include <libkcal/incidence.h> 12#include <libkcal/incidence.h>
13#include "simplealarmclient.h" 13#include "simplealarmclient.h"
14 14
15class QAction; 15class QAction;
16class CalendarView; 16class CalendarView;
17class KSyncProfile; 17class KSyncProfile;
18#ifdef DESKTOP_VERSION 18#ifdef DESKTOP_VERSION
19 19
20#define QPEToolBar QToolBar 20#define QPEToolBar QToolBar
21#define QPEMenuBar QMenuBar 21#define QPEMenuBar QMenuBar
22#endif 22#endif
23class QPEToolBar; 23class QPEToolBar;
24#include <qserversocket.h> 24#include <qserversocket.h>
25#include <qsocket.h> 25#include <qsocket.h>
26#include <qnetworkprotocol.h> 26#include <qnetworkprotocol.h>
27 27
28class KServerSocket : public QServerSocket 28class KServerSocket : public QServerSocket
29{ 29{
30 Q_OBJECT 30 Q_OBJECT
31 31
32public: 32public:
33 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); 33 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 );
34 34
35 void newConnection ( int socket ) ; 35 void newConnection ( int socket ) ;
36 void setFileName( QString fn ) {mFileName = fn;}; 36 void setFileName( QString fn ) {mFileName = fn;};
37 37
38signals: 38signals:
39 //void sendFile(QSocket*); 39 //void sendFile(QSocket*);
40 //void getFile(QSocket*); 40 //void getFile(QSocket*);
41 void file_received( bool ); 41 void file_received( bool );
42 //void file_sent(); 42 //void file_sent();
43 void saveFile(); 43 void saveFile();
44 void endConnect(); 44 void endConnect();
45private slots: 45private slots:
46 void discardClient(); 46 void discardClient();
47 void readClient(); 47 void readClient();
48 void readBackFileFromSocket(); 48 void readBackFileFromSocket();
49 private : 49 private :
50 bool blockRC; 50 bool blockRC;
51 void send_file(); 51 void send_file();
52 void get_file(); 52 void get_file();
53 void end_connect(); 53 void end_connect();
54 QDialog* mSyncActionDialog; 54 QDialog* mSyncActionDialog;
55 QSocket* mSocket; 55 QSocket* mSocket;
56 QString mPassWord; 56 QString mPassWord;
57 QString mFileName; 57 QString mFileName;
58 QTime piTime; 58 QTime piTime;
59 QString piFileString; 59 QString piFileString;
60}; 60};
61 61
62class KCommandSocket : public QObject 62class KCommandSocket : public QObject
63{ 63{
64 Q_OBJECT 64 Q_OBJECT
65public: 65public:
66 enum state { successR, errorR, successW, errorW, quiet }; 66 enum state { successR, errorR, successW, errorW, quiet };
67 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); 67 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 );
68 void readFile( QString ); 68 void readFile( QString );
69 void writeFile( QString ); 69 void writeFile( QString );
70 void sendStop(); 70 void sendStop();
71 71
72 72
73signals: 73signals:
74 void commandFinished( KCommandSocket*, int ); 74 void commandFinished( KCommandSocket*, int );
75private slots: 75private slots:
76 void startReadFileFromSocket(); 76 void startReadFileFromSocket();
77 void readFileFromSocket(); 77 void readFileFromSocket();
78 void deleteSocket(); 78 void deleteSocket();
79 void writeFileToSocket(); 79 void writeFileToSocket();
80 private : 80 private :
81 QSocket* mSocket; 81 QSocket* mSocket;
82 QString mPassWord; 82 QString mPassWord;
83 Q_UINT16 mPort; 83 Q_UINT16 mPort;
84 QString mHost; 84 QString mHost;
85 QString mFileName; 85 QString mFileName;
86 QTimer* mTimerSocket; 86 QTimer* mTimerSocket;
87 int mRetVal; 87 int mRetVal;
88 QTime mTime; 88 QTime mTime;
89 QString mFileString; 89 QString mFileString;
90 bool mFirst; 90 bool mFirst;
91}; 91};
92 92
93namespace KCal { 93namespace KCal {
94class CalendarLocal; 94class CalendarLocal;
95} 95}
96 96
97using namespace KCal; 97using namespace KCal;
98 98
99class MainWindow : public QMainWindow 99class MainWindow : public QMainWindow
100{ 100{
101 Q_OBJECT 101 Q_OBJECT
102 public: 102 public:
103 MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); 103 MainWindow( QWidget *parent = 0, const char *name = 0, QString command = "");
104 ~MainWindow(); 104 ~MainWindow();
105 public slots: 105 public slots:
106 virtual void showMaximized (); 106 virtual void showMaximized ();
107 void configureAgenda( int ); 107 void configureAgenda( int );
108 void recieve( const QCString& msg, const QByteArray& data ); 108 void recieve( const QCString& msg, const QByteArray& data );
109 static QString defaultFileName(); 109 static QString defaultFileName();
110 static QString syncFileName(); 110 static QString syncFileName();
111 static QString resourcePath(); 111 static QString resourcePath();
112 protected slots: 112 protected slots:
113 void setCaptionToDates(); 113 void setCaptionToDates();
114 int ringSync(); 114 int ringSync();
115 void multiSync( bool askforPrefs = false ); 115 void multiSync( bool askforPrefs = false );
116 void about(); 116 void about();
117 void licence(); 117 void licence();
118 void faq(); 118 void faq();
119 void usertrans(); 119 void usertrans();
120 void features(); 120 void features();
121 void synchowto(); 121 void synchowto();
122 void whatsNew(); 122 void whatsNew();
123 void keyBindings(); 123 void keyBindings();
124 void aboutAutoSaving();; 124 void aboutAutoSaving();;
125 void aboutKnownBugs(); 125 void aboutKnownBugs();
126 126
127 void processIncidenceSelection( Incidence * ); 127 void processIncidenceSelection( Incidence * );
128 128
129 void importQtopia(); 129 void importQtopia();
130 void importBday(); 130 void importBday();
131 void importOL(); 131 void importOL();
132 void importIcal(); 132 void importIcal();
133 void importFile( QString, bool ); 133 void importFile( QString, bool );
134 void quickImportIcal(); 134 void quickImportIcal();
135 135
136 void slotModifiedChanged( bool ); 136 void slotModifiedChanged( bool );
137 137
138 void save(); 138 void save();
139 void configureToolBar( int ); 139 void configureToolBar( int );
140 void printSel(); 140 void printSel();
141 void printCal(); 141 void printCal();
142 void saveCalendar(); 142 void saveCalendar();
143 void loadCalendar(); 143 void loadCalendar();
144 void exportVCalendar(); 144 void exportVCalendar();
145 void fillFilterMenu(); 145 void fillFilterMenu();
146 void selectFilter( int ); 146 void selectFilter( int );
147 void exportToPhone( int );
147 148
148 void slotSyncMenu( int ); 149 void slotSyncMenu( int );
149 void confSync(); 150 void confSync();
150 void syncSharp(); 151 void syncSharp();
151 void syncPhone(); 152 void syncPhone();
152 void syncPi(); 153 void syncPi();
153 void syncLocalFile(); 154 void syncLocalFile();
154 bool syncWithFile( QString, bool ); 155 bool syncWithFile( QString, bool );
155 void quickSyncLocalFile(); 156 void quickSyncLocalFile();
156 157
157 158
158 protected: 159 protected:
159 void displayText( QString, QString); 160 void displayText( QString, QString);
160 void displayFile( QString, QString); 161 void displayFile( QString, QString);
161 162
162 void enableIncidenceActions( bool ); 163 void enableIncidenceActions( bool );
163 164
164 private slots: 165 private slots:
165 QSocket* piSocket; 166 QSocket* piSocket;
166 QString piFileString; 167 QString piFileString;
167 QTime piTime; 168 QTime piTime;
168 void deleteCommandSocket(KCommandSocket* s, int state ); 169 void deleteCommandSocket(KCommandSocket* s, int state );
169 void fillSyncMenu(); 170 void fillSyncMenu();
170 void getFile( bool ); 171 void getFile( bool );
171 void readFileFromSocket(); 172 void readFileFromSocket();
172 private: 173 private:
173 //QTimer* mTimerCommandSocket; 174 //QTimer* mTimerCommandSocket;
174 QString mPassWordPiSync; 175 QString mPassWordPiSync;
175 KServerSocket * mServerSocket; 176 KServerSocket * mServerSocket;
176 bool mClosed; 177 bool mClosed;
177 void saveOnClose(); 178 void saveOnClose();
178 int mCurrentSyncProfile; 179 int mCurrentSyncProfile;
179 void enableQuick(); 180 void enableQuick();
180 void syncRemote( KSyncProfile* , bool ask = true); 181 void syncRemote( KSyncProfile* , bool ask = true);
181 bool mFlagKeyPressed; 182 bool mFlagKeyPressed;
182 bool mBlockAtStartup; 183 bool mBlockAtStartup;
183 QPEToolBar *iconToolBar; 184 QPEToolBar *iconToolBar;
184 void initActions(); 185 void initActions();
185 void setDefaultPreferences(); 186 void setDefaultPreferences();
186 void keyPressEvent ( QKeyEvent * ) ; 187 void keyPressEvent ( QKeyEvent * ) ;
187 void keyReleaseEvent ( QKeyEvent * ) ; 188 void keyReleaseEvent ( QKeyEvent * ) ;
188 QPopupMenu *configureToolBarMenu; 189 QPopupMenu *configureToolBarMenu;
189 QPopupMenu *selectFilterMenu; 190 QPopupMenu *selectFilterMenu;
190 QPopupMenu *configureAgendaMenu, *syncMenu; 191 QPopupMenu *configureAgendaMenu, *syncMenu;
191 CalendarLocal *mCalendar; 192 CalendarLocal *mCalendar;
192 CalendarView *mView; 193 CalendarView *mView;
193 QString getPassword(); 194 QString getPassword();
194 QAction *mNewSubTodoAction; 195 QAction *mNewSubTodoAction;
195 196
196 QAction *mShowAction; 197 QAction *mShowAction;
197 QAction *mEditAction; 198 QAction *mEditAction;
198 QAction *mDeleteAction; 199 QAction *mDeleteAction;
199 void closeEvent( QCloseEvent* ce ); 200 void closeEvent( QCloseEvent* ce );
200 SimpleAlarmClient mAlarmClient; 201 SimpleAlarmClient mAlarmClient;
201 QTimer mSaveTimer; 202 QTimer mSaveTimer;
202 bool mBlockSaveFlag; 203 bool mBlockSaveFlag;
203 bool mCalendarModifiedFlag; 204 bool mCalendarModifiedFlag;
204 QPixmap loadPixmap( QString ); 205 QPixmap loadPixmap( QString );
205 QDialog * mSyncActionDialog; 206 QDialog * mSyncActionDialog;
206}; 207};
207 208
208 209
209#endif 210#endif
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index 29c1ae6..b2a62b1 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -1,732 +1,748 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 3
4 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> 4 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#include <qdatetime.h> 22#include <qdatetime.h>
23#include <qstring.h> 23#include <qstring.h>
24#include <qapplication.h> 24#include <qapplication.h>
25#include <qptrlist.h> 25#include <qptrlist.h>
26#include <qregexp.h> 26#include <qregexp.h>
27#include <qmessagebox.h> 27#include <qmessagebox.h>
28#include <qclipboard.h> 28#include <qclipboard.h>
29#include <qfile.h> 29#include <qfile.h>
30#include <qtextstream.h> 30#include <qtextstream.h>
31#include <qtextcodec.h> 31#include <qtextcodec.h>
32#include <qdir.h> 32#include <qdir.h>
33#include <qlabel.h> 33#include <qlabel.h>
34 34
35#include <kdebug.h> 35#include <kdebug.h>
36#include <klocale.h> 36#include <klocale.h>
37#include <kglobal.h> 37#include <kglobal.h>
38#include <kmessagebox.h> 38#include <kmessagebox.h>
39 39
40#include "calendar.h" 40#include "calendar.h"
41#include "alarm.h" 41#include "alarm.h"
42#include "recurrence.h" 42#include "recurrence.h"
43#include "calendarlocal.h" 43#include "calendarlocal.h"
44 44
45#include "phoneformat.h" 45#include "phoneformat.h"
46#include "syncdefines.h" 46#include "syncdefines.h"
47 47
48using namespace KCal; 48using namespace KCal;
49class PhoneParser : public QObject 49class PhoneParser : public QObject
50{ 50{
51public: 51public:
52 PhoneParser( ) { 52 PhoneParser( ) {
53 ; 53 ;
54 } 54 }
55 55
56 static QString dtToString( const QDateTime& dti, bool useTZ = false ) 56 static QString dtToString( const QDateTime& dti, bool useTZ = false )
57 { 57 {
58 QString datestr; 58 QString datestr;
59 QString timestr; 59 QString timestr;
60 int offset = KGlobal::locale()->localTimeOffset( dti ); 60 int offset = KGlobal::locale()->localTimeOffset( dti );
61 QDateTime dt; 61 QDateTime dt;
62 if (useTZ) 62 if (useTZ)
63 dt = dti.addSecs ( -(offset*60)); 63 dt = dti.addSecs ( -(offset*60));
64 else 64 else
65 dt = dti; 65 dt = dti;
66 if(dt.date().isValid()){ 66 if(dt.date().isValid()){
67 const QDate& date = dt.date(); 67 const QDate& date = dt.date();
68 datestr.sprintf("%04d%02d%02d", 68 datestr.sprintf("%04d%02d%02d",
69 date.year(), date.month(), date.day()); 69 date.year(), date.month(), date.day());
70 } 70 }
71 if(dt.time().isValid()){ 71 if(dt.time().isValid()){
72 const QTime& time = dt.time(); 72 const QTime& time = dt.time();
73 timestr.sprintf("T%02d%02d%02d", 73 timestr.sprintf("T%02d%02d%02d",
74 time.hour(), time.minute(), time.second()); 74 time.hour(), time.minute(), time.second());
75 } 75 }
76 return datestr + timestr; 76 return datestr + timestr;
77 } 77 }
78 78
79 79
80}; 80};
81 81
82 82
83 83
84PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model ) 84PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model )
85{ 85{
86 mProfileName = profileName; 86 mProfileName = profileName;
87 87 writeConfig( device, connection, model );
88}
89
90PhoneFormat::~PhoneFormat()
91{
92}
93void PhoneFormat::writeConfig( QString device, QString connection, QString model )
94{
95#ifdef _WIN32_
96 QString fileName = qApp->applicationDirPath () +"\\gammurc";
97#else
88 QString fileName = QDir::homeDirPath() +"/.gammurc"; 98 QString fileName = QDir::homeDirPath() +"/.gammurc";
99#endif
89 //qDebug("save %d ", load ); 100 //qDebug("save %d ", load );
90 QString content; 101 QString content;
91 bool write = false; 102 bool write = false;
92 bool addPort = true, addConnection = true, addModel = true; 103 bool addPort = true, addConnection = true, addModel = true;
93 QFile file( fileName ); 104 QFile file( fileName );
94 if ( QFile::exists( fileName) ) { 105 if ( QFile::exists( fileName) ) {
95 if (!file.open( IO_ReadOnly ) ) { 106 if (!file.open( IO_ReadOnly ) ) {
96 qDebug("Error: cannot open %s ", fileName.latin1() ); 107 qDebug("Error: cannot open %s ", fileName.latin1() );
97 return; 108 return;
98 } 109 }
99 QString line; 110 QString line;
100 while ( file.readLine( line, 1024 ) > 0 ) { 111 while ( file.readLine( line, 1024 ) > 0 ) {
101 //qDebug("*%s* ", line.latin1() ); 112 //qDebug("*%s* ", line.latin1() );
102 if ( line.left(7 ) == "[gammu]" ) { 113 if ( line.left(7 ) == "[gammu]" ) {
103 ; 114 ;
104 } else 115 } else
105 if ( line.left(4 ) == "port" ) { 116 if ( line.left(4 ) == "port" ) {
106 if ( line == "port = " + device+"\n" ) { 117 if ( line == "port = " + device+"\n" ) {
107 content += line ; 118 content += line ;
108 addPort = false; 119 addPort = false;
109 //qDebug("port found" ); 120 //qDebug("port found" );
110 } 121 }
111 122
112 } else if ( line.left(5 ) == "model" ) { 123 } else if ( line.left(5 ) == "model" ) {
113 if ( line == "model = " + model +"\n") { 124 if ( line == "model = " + model +"\n") {
114 content += line ; 125 content += line ;
115 addModel = false; 126 addModel = false;
116 //qDebug("model found" ); 127 //qDebug("model found" );
117 } 128 }
118 129
119 } else if ( line.left( 10 ) == "connection" ) { 130 } else if ( line.left( 10 ) == "connection" ) {
120 if ( line == "connection = " + connection +"\n") { 131 if ( line == "connection = " + connection +"\n") {
121 addConnection = false; 132 addConnection = false;
122 content += line ; 133 content += line ;
123 //qDebug("con found" ); 134 //qDebug("con found" );
124 } 135 }
125 136
126 } else { 137 } else {
127 content += line ; 138 content += line ;
128 } 139 }
129 } 140 }
130 file.close(); 141 file.close();
131 } else { 142 } else {
132 if ( ! connection.isEmpty() ) { 143 if ( ! connection.isEmpty() ) {
133 addConnection = true; 144 addConnection = true;
134 } 145 }
135 if ( ! device.isEmpty() ) { 146 if ( ! device.isEmpty() ) {
136 addPort = true; 147 addPort = true;
137 148
138 } 149 }
139 if ( ! model.isEmpty() ) { 150 if ( ! model.isEmpty() ) {
140 addModel = true; 151 addModel = true;
141 } 152 }
142 } 153 }
143 154
144 if ( addConnection ) { 155 if ( addConnection ) {
145 if ( ! write ) 156 if ( ! write )
146 content += "[gammu]\n"; 157 content += "[gammu]\n";
147 write = true; 158 write = true;
148 content += "connection = "; 159 content += "connection = ";
149 content += connection; 160 content += connection;
150 content += "\n"; 161 content += "\n";
151 } 162 }
152 if ( addPort ) { 163 if ( addPort ) {
153 if ( ! write ) 164 if ( ! write )
154 content += "[gammu]\n"; 165 content += "[gammu]\n";
155 write = true; 166 write = true;
156 content += "port = "; 167 content += "port = ";
157 content += device; 168 content += device;
158 content += "\n"; 169 content += "\n";
159 170
160 } 171 }
161 if ( addModel ) { 172 if ( addModel ) {
162 if ( ! write ) 173 if ( ! write )
163 content += "[gammu]\n"; 174 content += "[gammu]\n";
164 write = true; 175 write = true;
165 content += "model = "; 176 content += "model = ";
166 content += model; 177 content += model;
167 content += "\n"; 178 content += "\n";
168 } 179 }
169 if ( write ) { 180 if ( write ) {
170 if (!file.open( IO_WriteOnly ) ) { 181 if (!file.open( IO_WriteOnly ) ) {
171 qDebug("Error: cannot write file %s ", fileName.latin1() ); 182 qDebug("Error: cannot write file %s ", fileName.latin1() );
172 return; 183 return;
173 } 184 }
174 qDebug("Writing file %s ", fileName.latin1() ); 185 qDebug("Writing file %s ", fileName.latin1() );
175 QTextStream ts( &file ); 186 QTextStream ts( &file );
176 ts << content ; 187 ts << content ;
177 file.close(); 188 file.close();
178 } 189 }
179}
180 190
181PhoneFormat::~PhoneFormat()
182{
183} 191}
184#if 0 192#if 0
185int PhoneFormat::initDevice(GSM_StateMachine *s) 193int PhoneFormat::initDevice(GSM_StateMachine *s)
186{ 194{
187 GSM_ReadConfig(NULL, &s->Config[0], 0); 195 GSM_ReadConfig(NULL, &s->Config[0], 0);
188 s->ConfigNum = 1; 196 s->ConfigNum = 1;
189 GSM_Config *cfg = &s->Config[0]; 197 GSM_Config *cfg = &s->Config[0];
190 if ( ! mConnection.isEmpty() ) { 198 if ( ! mConnection.isEmpty() ) {
191 cfg->Connection = strdup(mConnection.latin1()); 199 cfg->Connection = strdup(mConnection.latin1());
192 cfg->DefaultConnection = false; 200 cfg->DefaultConnection = false;
193 qDebug("Connection set %s ", cfg->Connection ); 201 qDebug("Connection set %s ", cfg->Connection );
194 202
195 } 203 }
196 if ( ! mDevice.isEmpty() ) { 204 if ( ! mDevice.isEmpty() ) {
197 cfg->Device = strdup(mDevice.latin1()); 205 cfg->Device = strdup(mDevice.latin1());
198 cfg->DefaultDevice = false; 206 cfg->DefaultDevice = false;
199 qDebug("Device set %s ", cfg->Device); 207 qDebug("Device set %s ", cfg->Device);
200 208
201 } 209 }
202 if ( ! mModel.isEmpty() ) { 210 if ( ! mModel.isEmpty() ) {
203 strcpy(cfg->Model,mModel.latin1() ); 211 strcpy(cfg->Model,mModel.latin1() );
204 cfg->DefaultModel = false; 212 cfg->DefaultModel = false;
205 qDebug("Model set %s ",cfg->Model ); 213 qDebug("Model set %s ",cfg->Model );
206 } 214 }
207 int error=GSM_InitConnection(s,3); 215 int error=GSM_InitConnection(s,3);
208 return error; 216 return error;
209} 217}
210#endif 218#endif
211ulong PhoneFormat::getCsumTodo( Todo* todo ) 219ulong PhoneFormat::getCsumTodo( Todo* todo )
212{ 220{
213 QStringList attList; 221 QStringList attList;
214 if ( todo->hasDueDate() ) 222 if ( todo->hasDueDate() )
215 attList << PhoneParser::dtToString ( todo->dtDue() ); 223 attList << PhoneParser::dtToString ( todo->dtDue() );
216 attList << todo->summary(); 224 attList << todo->summary();
217 QString completedString = "no"; 225 QString completedString = "no";
218 if ( todo->isCompleted() ) 226 if ( todo->isCompleted() )
219 completedString = "yes"; 227 completedString = "yes";
220 attList << completedString; 228 attList << completedString;
221 int prio = todo->priority(); 229 int prio = todo->priority();
222 if( prio == 2 ) prio = 1; 230 if( prio == 2 ) prio = 1;
223 if (prio == 4 ) prio = 5 ; 231 if (prio == 4 ) prio = 5 ;
224 attList << QString::number( prio ); 232 attList << QString::number( prio );
225 QString alarmString = "na"; 233 QString alarmString = "na";
226 Alarm *alarm; 234 Alarm *alarm;
227 if ( todo->alarms().count() > 0 ) { 235 if ( todo->alarms().count() > 0 ) {
228 alarm = todo->alarms().first(); 236 alarm = todo->alarms().first();
229 if ( alarm->enabled() ) { 237 if ( alarm->enabled() ) {
230 alarmString = QString::number(alarm->offset() ); 238 alarmString = QString::number(alarm->offset() );
231 } 239 }
232 } 240 }
233 attList << alarmString; 241 attList << alarmString;
234 attList << todo->categoriesStr(); 242 attList << todo->categoriesStr();
235 attList << todo->secrecyStr(); 243 attList << todo->secrecyStr();
236 return PhoneFormat::getCsum(attList ); 244 return PhoneFormat::getCsum(attList );
237 245
238} 246}
239ulong PhoneFormat::getCsumEvent( Event* event ) 247ulong PhoneFormat::getCsumEvent( Event* event )
240{ 248{
241 QStringList attList; 249 QStringList attList;
242 attList << PhoneParser::dtToString ( event->dtStart() ); 250 attList << PhoneParser::dtToString ( event->dtStart() );
243 attList << PhoneParser::dtToString ( event->dtEnd() ); 251 attList << PhoneParser::dtToString ( event->dtEnd() );
244 attList << event->summary(); 252 attList << event->summary();
245 attList << event->location(); 253 attList << event->location();
246 QString alarmString = "na"; 254 QString alarmString = "na";
247 Alarm *alarm; 255 Alarm *alarm;
248 if ( event->alarms().count() > 0 ) { 256 if ( event->alarms().count() > 0 ) {
249 alarm = event->alarms().first(); 257 alarm = event->alarms().first();
250 if ( alarm->enabled() ) { 258 if ( alarm->enabled() ) {
251 alarmString = QString::number( alarm->offset() ); 259 alarmString = QString::number( alarm->offset() );
252 } 260 }
253 } 261 }
254 attList << alarmString; 262 attList << alarmString;
255 Recurrence* rec = event->recurrence(); 263 Recurrence* rec = event->recurrence();
256 QStringList list; 264 QStringList list;
257 bool writeEndDate = false; 265 bool writeEndDate = false;
258 switch ( rec->doesRecur() ) 266 switch ( rec->doesRecur() )
259 { 267 {
260 case Recurrence::rDaily: // 0 268 case Recurrence::rDaily: // 0
261 list.append( "0" ); 269 list.append( "0" );
262 list.append( QString::number( rec->frequency() ));//12 270 list.append( QString::number( rec->frequency() ));//12
263 list.append( "0" ); 271 list.append( "0" );
264 list.append( "0" ); 272 list.append( "0" );
265 writeEndDate = true; 273 writeEndDate = true;
266 break; 274 break;
267 case Recurrence::rWeekly:// 1 275 case Recurrence::rWeekly:// 1
268 list.append( "1" ); 276 list.append( "1" );
269 list.append( QString::number( rec->frequency()) );//12 277 list.append( QString::number( rec->frequency()) );//12
270 list.append( "0" ); 278 list.append( "0" );
271 { 279 {
272 int days = 0; 280 int days = 0;
273 QBitArray weekDays = rec->days(); 281 QBitArray weekDays = rec->days();
274 int i; 282 int i;
275 for( i = 1; i <= 7; ++i ) { 283 for( i = 1; i <= 7; ++i ) {
276 if ( weekDays[i-1] ) { 284 if ( weekDays[i-1] ) {
277 days += 1 << (i-1); 285 days += 1 << (i-1);
278 } 286 }
279 } 287 }
280 list.append( QString::number( days ) ); 288 list.append( QString::number( days ) );
281 } 289 }
282 //pending weekdays 290 //pending weekdays
283 writeEndDate = true; 291 writeEndDate = true;
284 292
285 break; 293 break;
286 case Recurrence::rMonthlyPos:// 2 294 case Recurrence::rMonthlyPos:// 2
287 list.append( "2" ); 295 list.append( "2" );
288 list.append( QString::number( rec->frequency()) );//12 296 list.append( QString::number( rec->frequency()) );//12
289 297
290 writeEndDate = true; 298 writeEndDate = true;
291 { 299 {
292 int count = 1; 300 int count = 1;
293 QPtrList<Recurrence::rMonthPos> rmp; 301 QPtrList<Recurrence::rMonthPos> rmp;
294 rmp = rec->monthPositions(); 302 rmp = rec->monthPositions();
295 if ( rmp.first()->negative ) 303 if ( rmp.first()->negative )
296 count = 5 - rmp.first()->rPos - 1; 304 count = 5 - rmp.first()->rPos - 1;
297 else 305 else
298 count = rmp.first()->rPos - 1; 306 count = rmp.first()->rPos - 1;
299 list.append( QString::number( count ) ); 307 list.append( QString::number( count ) );
300 308
301 } 309 }
302 310
303 list.append( "0" ); 311 list.append( "0" );
304 break; 312 break;
305 case Recurrence::rMonthlyDay:// 3 313 case Recurrence::rMonthlyDay:// 3
306 list.append( "3" ); 314 list.append( "3" );
307 list.append( QString::number( rec->frequency()) );//12 315 list.append( QString::number( rec->frequency()) );//12
308 list.append( "0" ); 316 list.append( "0" );
309 list.append( "0" ); 317 list.append( "0" );
310 writeEndDate = true; 318 writeEndDate = true;
311 break; 319 break;
312 case Recurrence::rYearlyMonth://4 320 case Recurrence::rYearlyMonth://4
313 list.append( "4" ); 321 list.append( "4" );
314 list.append( QString::number( rec->frequency()) );//12 322 list.append( QString::number( rec->frequency()) );//12
315 list.append( "0" ); 323 list.append( "0" );
316 list.append( "0" ); 324 list.append( "0" );
317 writeEndDate = true; 325 writeEndDate = true;
318 break; 326 break;
319 327
320 default: 328 default:
321 list.append( "255" ); 329 list.append( "255" );
322 list.append( QString() ); 330 list.append( QString() );
323 list.append( "0" ); 331 list.append( "0" );
324 list.append( QString() ); 332 list.append( QString() );
325 list.append( "0" ); 333 list.append( "0" );
326 list.append( "20991231T000000" ); 334 list.append( "20991231T000000" );
327 break; 335 break;
328 } 336 }
329 if ( writeEndDate ) { 337 if ( writeEndDate ) {
330 338
331 if ( rec->endDate().isValid() ) { // 15 + 16 339 if ( rec->endDate().isValid() ) { // 15 + 16
332 list.append( "1" ); 340 list.append( "1" );
333 list.append( PhoneParser::dtToString( rec->endDate()) ); 341 list.append( PhoneParser::dtToString( rec->endDate()) );
334 } else { 342 } else {
335 list.append( "0" ); 343 list.append( "0" );
336 list.append( "20991231T000000" ); 344 list.append( "20991231T000000" );
337 } 345 }
338 346
339 } 347 }
340 attList << list.join(""); 348 attList << list.join("");
341 attList << event->categoriesStr(); 349 attList << event->categoriesStr();
342 //qDebug("csum cat %s", event->categoriesStr().latin1()); 350 //qDebug("csum cat %s", event->categoriesStr().latin1());
343 351
344 attList << event->secrecyStr(); 352 attList << event->secrecyStr();
345 return PhoneFormat::getCsum(attList ); 353 return PhoneFormat::getCsum(attList );
346} 354}
347ulong PhoneFormat::getCsum( const QStringList & attList) 355ulong PhoneFormat::getCsum( const QStringList & attList)
348{ 356{
349 int max = attList.count(); 357 int max = attList.count();
350 ulong cSum = 0; 358 ulong cSum = 0;
351 int j,k,i; 359 int j,k,i;
352 int add; 360 int add;
353 for ( i = 0; i < max ; ++i ) { 361 for ( i = 0; i < max ; ++i ) {
354 QString s = attList[i]; 362 QString s = attList[i];
355 if ( ! s.isEmpty() ){ 363 if ( ! s.isEmpty() ){
356 j = s.length(); 364 j = s.length();
357 for ( k = 0; k < j; ++k ) { 365 for ( k = 0; k < j; ++k ) {
358 int mul = k +1; 366 int mul = k +1;
359 add = s[k].unicode (); 367 add = s[k].unicode ();
360 if ( k < 16 ) 368 if ( k < 16 )
361 mul = mul * mul; 369 mul = mul * mul;
362 int ii = i+1; 370 int ii = i+1;
363 add = add * mul *ii*ii*ii; 371 add = add * mul *ii*ii*ii;
364 cSum += add; 372 cSum += add;
365 } 373 }
366 } 374 }
367 375
368 } 376 }
369 //QString dump = attList.join(","); 377 //QString dump = attList.join(",");
370 //qDebug("csum: %d %s", cSum,dump.latin1()); 378 //qDebug("csum: %d %s", cSum,dump.latin1());
371 379
372 return cSum; 380 return cSum;
373 381
374} 382}
375//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); 383//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum);
376#include <stdlib.h> 384#include <stdlib.h>
377#define DEBUGMODE false 385#define DEBUGMODE false
378bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) 386bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal)
379{ 387{
380 388
381 QString fileName; 389 QString fileName;
382#ifdef _WIN32_ 390#ifdef _WIN32_
383 fileName = locateLocal("tmp", "tempfile.vcs"); 391 fileName = locateLocal("tmp", "tempfile.vcs");
384#else 392#else
385 fileName = "/tmp/kdepimtemp.vcs"; 393 fileName = "/tmp/kdepimtemp.vcs";
386#endif 394#endif
387#ifdef DESKTOP_VERSION 395#ifdef DESKTOP_VERSION
388 QString command ="./kammu --backup " + fileName + " -yes" ; 396 QString command ="./kammu --backup " + fileName + " -yes" ;
389#else 397#else
390 QString command ="kammu --backup " + fileName + " -yes" ; 398 QString command ="kammu --backup " + fileName + " -yes" ;
391#endif 399#endif
392 int ret = system ( command.latin1() ); 400 int ret = system ( command.latin1() );
393 if ( ret != 0 ) { 401 if ( ret != 0 ) {
394 qDebug("Error::command returned %d", ret); 402 qDebug("Error::command returned %d", ret);
395 return false; 403 return false;
396 } 404 }
397 VCalFormat vfload; 405 VCalFormat vfload;
398 vfload.setLocalTime ( true ); 406 vfload.setLocalTime ( true );
399 qDebug("loading file ..."); 407 qDebug("loading file ...");
400 408
401 if ( ! vfload.load( calendar, fileName ) ) 409 if ( ! vfload.load( calendar, fileName ) )
402 return false; 410 return false;
403 QPtrList<Event> er = calendar->rawEvents(); 411 QPtrList<Event> er = calendar->rawEvents();
404 Event* ev = er.first(); 412 Event* ev = er.first();
405 qDebug("reading events... "); 413 qDebug("reading events... ");
406 while ( ev ) { 414 while ( ev ) {
407 QStringList cat = ev->categories(); 415 QStringList cat = ev->categories();
408 if ( cat.contains( "MeetingDEF" )) { 416 if ( cat.contains( "MeetingDEF" )) {
409 ev->setCategories( QStringList() ); 417 ev->setCategories( QStringList() );
410 } 418 }
411 int id = ev->pilotId(); 419 int id = ev->pilotId();
412 Event *event; 420 Event *event;
413 event = existingCal->event( mProfileName ,QString::number( id ) ); 421 event = existingCal->event( mProfileName ,QString::number( id ) );
414 if ( event ) { 422 if ( event ) {
415 event = (Event*)event->clone(); 423 event = (Event*)event->clone();
416 copyEvent( event, ev ); 424 copyEvent( event, ev );
417 calendar->deleteEvent( ev ); 425 calendar->deleteEvent( ev );
418 calendar->addEvent( event); 426 calendar->addEvent( event);
419 } 427 }
420 else 428 else
421 event = ev; 429 event = ev;
422 uint cSum; 430 uint cSum;
423 cSum = PhoneFormat::getCsumEvent( event ); 431 cSum = PhoneFormat::getCsumEvent( event );
424 event->setCsum( mProfileName, QString::number( cSum )); 432 event->setCsum( mProfileName, QString::number( cSum ));
425 event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); 433 event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
426 event->setID( mProfileName,QString::number( id ) ); 434 event->setID( mProfileName,QString::number( id ) );
427 ev = er.next(); 435 ev = er.next();
428 } 436 }
429 { 437 {
430 qDebug("reading todos... "); 438 qDebug("reading todos... ");
431 QPtrList<Todo> tr = calendar->rawTodos(); 439 QPtrList<Todo> tr = calendar->rawTodos();
432 Todo* ev = tr.first(); 440 Todo* ev = tr.first();
433 while ( ev ) { 441 while ( ev ) {
434 442
435 QStringList cat = ev->categories(); 443 QStringList cat = ev->categories();
436 if ( cat.contains( "MeetingDEF" )) { 444 if ( cat.contains( "MeetingDEF" )) {
437 ev->setCategories( QStringList() ); 445 ev->setCategories( QStringList() );
438 } 446 }
439 int id = ev->pilotId(); 447 int id = ev->pilotId();
440 Todo *event; 448 Todo *event;
441 event = existingCal->todo( mProfileName ,QString::number( id ) ); 449 event = existingCal->todo( mProfileName ,QString::number( id ) );
442 if ( event ) { 450 if ( event ) {
443 //qDebug("copy todo %s ", event->summary().latin1()); 451 //qDebug("copy todo %s ", event->summary().latin1());
444 452
445 event = (Todo*)event->clone(); 453 event = (Todo*)event->clone();
446 copyTodo( event, ev ); 454 copyTodo( event, ev );
447 calendar->deleteTodo( ev ); 455 calendar->deleteTodo( ev );
448 calendar->addTodo( event); 456 calendar->addTodo( event);
449 } 457 }
450 else 458 else
451 event = ev; 459 event = ev;
452 uint cSum; 460 uint cSum;
453 cSum = PhoneFormat::getCsumTodo( event ); 461 cSum = PhoneFormat::getCsumTodo( event );
454 event->setCsum( mProfileName, QString::number( cSum )); 462 event->setCsum( mProfileName, QString::number( cSum ));
455 event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); 463 event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
456 event->setID( mProfileName,QString::number( id ) ); 464 event->setID( mProfileName,QString::number( id ) );
457 ev = tr.next(); 465 ev = tr.next();
458 } 466 }
459 } 467 }
460 return true; 468 return true;
461} 469}
462void PhoneFormat::copyEvent( Event* to, Event* from ) 470void PhoneFormat::copyEvent( Event* to, Event* from )
463{ 471{
464 if ( from->dtStart().isValid() ) 472 if ( from->dtStart().isValid() )
465 to->setDtStart( from->dtStart() ); 473 to->setDtStart( from->dtStart() );
466 if ( from->dtEnd().isValid() ) 474 if ( from->dtEnd().isValid() )
467 to->setDtEnd( from->dtEnd() ); 475 to->setDtEnd( from->dtEnd() );
468 if ( !from->location().isEmpty() ) 476 if ( !from->location().isEmpty() )
469 to->setLocation( from->location() ); 477 to->setLocation( from->location() );
470 if ( !from->description().isEmpty() ) 478 if ( !from->description().isEmpty() )
471 to->setDescription( from->description() ); 479 to->setDescription( from->description() );
472 if ( !from->summary().isEmpty() ) 480 if ( !from->summary().isEmpty() )
473 to->setSummary( from->summary() ); 481 to->setSummary( from->summary() );
474 482
475 if ( from->alarms().count() ) { 483 if ( from->alarms().count() ) {
476 to->clearAlarms(); 484 to->clearAlarms();
477 Alarm *a = from->alarms().first(); 485 Alarm *a = from->alarms().first();
478 Alarm *b = to->newAlarm( ); 486 Alarm *b = to->newAlarm( );
479 b->setEnabled( a->enabled() ); 487 b->setEnabled( a->enabled() );
480 if ( a->hasStartOffset() ) { 488 if ( a->hasStartOffset() ) {
481 b->setStartOffset( a->startOffset() ); 489 b->setStartOffset( a->startOffset() );
482 } 490 }
483 if ( a->hasTime() ) 491 if ( a->hasTime() )
484 b->setTime( a->time() ); 492 b->setTime( a->time() );
485 493
486 } 494 }
487 QStringList cat = to->categories(); 495 QStringList cat = to->categories();
488 QStringList catFrom = from->categories(); 496 QStringList catFrom = from->categories();
489 QString nCat; 497 QString nCat;
490 int iii; 498 int iii;
491 for ( iii = 0; iii < catFrom.count();++iii ) { 499 for ( iii = 0; iii < catFrom.count();++iii ) {
492 nCat = catFrom[iii]; 500 nCat = catFrom[iii];
493 if ( !nCat.isEmpty() ) 501 if ( !nCat.isEmpty() )
494 if ( !cat.contains( nCat )) { 502 if ( !cat.contains( nCat )) {
495 cat << nCat; 503 cat << nCat;
496 } 504 }
497 } 505 }
498 to->setCategories( cat ); 506 to->setCategories( cat );
499 Recurrence * r = new Recurrence( *from->recurrence(),to); 507 Recurrence * r = new Recurrence( *from->recurrence(),to);
500 to->setRecurrence( r ) ; 508 to->setRecurrence( r ) ;
501 509
502 510
503} 511}
504void PhoneFormat::copyTodo( Todo* to, Todo* from ) 512void PhoneFormat::copyTodo( Todo* to, Todo* from )
505{ 513{
506 if ( from->dtStart().isValid() ) 514 if ( from->dtStart().isValid() )
507 to->setDtStart( from->dtStart() ); 515 to->setDtStart( from->dtStart() );
508 if ( from->dtDue().isValid() ) 516 if ( from->dtDue().isValid() )
509 to->setDtDue( from->dtDue() ); 517 to->setDtDue( from->dtDue() );
510 if ( !from->location().isEmpty() ) 518 if ( !from->location().isEmpty() )
511 to->setLocation( from->location() ); 519 to->setLocation( from->location() );
512 if ( !from->description().isEmpty() ) 520 if ( !from->description().isEmpty() )
513 to->setDescription( from->description() ); 521 to->setDescription( from->description() );
514 if ( !from->summary().isEmpty() ) 522 if ( !from->summary().isEmpty() )
515 to->setSummary( from->summary() ); 523 to->setSummary( from->summary() );
516 524
517 if ( from->alarms().count() ) { 525 if ( from->alarms().count() ) {
518 to->clearAlarms(); 526 to->clearAlarms();
519 Alarm *a = from->alarms().first(); 527 Alarm *a = from->alarms().first();
520 Alarm *b = to->newAlarm( ); 528 Alarm *b = to->newAlarm( );
521 b->setEnabled( a->enabled() ); 529 b->setEnabled( a->enabled() );
522 if ( a->hasStartOffset() ) 530 if ( a->hasStartOffset() )
523 b->setStartOffset( a->startOffset() ); 531 b->setStartOffset( a->startOffset() );
524 if ( a->hasTime() ) 532 if ( a->hasTime() )
525 b->setTime( a->time() ); 533 b->setTime( a->time() );
526 } 534 }
527 535
528 QStringList cat = to->categories(); 536 QStringList cat = to->categories();
529 QStringList catFrom = from->categories(); 537 QStringList catFrom = from->categories();
530 QString nCat; 538 QString nCat;
531 int iii; 539 int iii;
532 for ( iii = 0; iii < catFrom.count();++iii ) { 540 for ( iii = 0; iii < catFrom.count();++iii ) {
533 nCat = catFrom[iii]; 541 nCat = catFrom[iii];
534 if ( !nCat.isEmpty() ) 542 if ( !nCat.isEmpty() )
535 if ( !cat.contains( nCat )) { 543 if ( !cat.contains( nCat )) {
536 cat << nCat; 544 cat << nCat;
537 } 545 }
538 } 546 }
539 to->setCategories( cat ); 547 to->setCategories( cat );
540 if ( from->isCompleted() ) { 548 if ( from->isCompleted() ) {
541 to->setCompleted( true ); 549 to->setCompleted( true );
542 if( from->completed().isValid() ) 550 if( from->completed().isValid() )
543 to->setCompleted( from->completed() ); 551 to->setCompleted( from->completed() );
544 } else { 552 } else {
545 // set percentcomplete only, if to->isCompleted() 553 // set percentcomplete only, if to->isCompleted()
546 if ( to->isCompleted() ) 554 if ( to->isCompleted() )
547 to->setPercentComplete(from->percentComplete()); 555 to->setPercentComplete(from->percentComplete());
548 } 556 }
549 if( to->priority() == 2 && from->priority() == 1 ) 557 if( to->priority() == 2 && from->priority() == 1 )
550 ; //skip 558 ; //skip
551 else if (to->priority() == 4 && from->priority() == 5 ) 559 else if (to->priority() == 4 && from->priority() == 5 )
552 ; 560 ;
553 else 561 else
554 to->setPriority(from->priority()); 562 to->setPriority(from->priority());
555 563
556} 564}
557#include <qcstring.h> 565#include <qcstring.h>
558 566
559void PhoneFormat::afterSave( Incidence* inc) 567void PhoneFormat::afterSave( Incidence* inc)
560{ 568{
561 uint csum; 569 uint csum;
562 inc->removeID( mProfileName ); 570 inc->removeID( mProfileName );
563 if ( inc->type() == "Event") 571 if ( inc->type() == "Event")
564 csum = PhoneFormat::getCsumEvent( (Event*) inc ); 572 csum = PhoneFormat::getCsumEvent( (Event*) inc );
565 else 573 else
566 csum = PhoneFormat::getCsumTodo( (Todo*) inc ); 574 csum = PhoneFormat::getCsumTodo( (Todo*) inc );
567 inc->setCsum( mProfileName, QString::number( csum )); 575 inc->setCsum( mProfileName, QString::number( csum ));
568 576
569 inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 577 inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
570 578
571} 579}
580
581bool PhoneFormat::writeToPhone( Calendar * calendar)
582{
583#ifdef _WIN32_
584 QString fileName = locateLocal("tmp", "tempfile.vcs");
585#else
586 QString fileName = "/tmp/kdepimtemp.vcs";
587#endif
588
589 VCalFormat vfsave;
590 vfsave.setLocalTime ( true );
591 if ( ! vfsave.save( calendar, fileName ) )
592 return false;
593 // 4 call kammu
594#ifdef DESKTOP_VERSION
595 QString command ="./kammu --restore " + fileName ;
596#else
597 QString command ="kammu --restore " + fileName ;
598#endif
599 int ret;
600 while ( (ret = system ( command.latin1())) != 0 ) {
601 qDebug("Error S::command returned %d. asking users", ret);
602 int retval = KMessageBox::warningContinueCancel(0,
603 i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KO/Pi phone access"),i18n("Retry"),i18n("Cancel"));
604 if ( retval != KMessageBox::Continue )
605 return false;
606 }
607 return true;
608}
572bool PhoneFormat::save( Calendar *calendar) 609bool PhoneFormat::save( Calendar *calendar)
573{ 610{
574 QLabel status ( i18n(" Opening device ..."), 0 ); 611 QLabel status ( i18n(" Opening device ..."), 0 );
575 int w = status.sizeHint().width()+20 ; 612 int w = status.sizeHint().width()+20 ;
576 if ( w < 200 ) w = 230; 613 if ( w < 200 ) w = 230;
577 int h = status.sizeHint().height()+20 ; 614 int h = status.sizeHint().height()+20 ;
578 int dw = QApplication::desktop()->width(); 615 int dw = QApplication::desktop()->width();
579 int dh = QApplication::desktop()->height(); 616 int dh = QApplication::desktop()->height();
580 status.setCaption(i18n("Writing to phone...") ); 617 status.setCaption(i18n("Writing to phone...") );
581 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 618 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
582 status.show(); 619 status.show();
583 status.raise(); 620 status.raise();
584 qApp->processEvents(); 621 qApp->processEvents();
585 QString message; 622 QString message;
586#ifdef _WIN32_
587 QString fileName = locateLocal("tmp", "tempfile.vcs");
588#else
589 QString fileName = "/tmp/kdepimtemp.vcs";
590#endif
591 623
592 // 1 remove events which should be deleted 624 // 1 remove events which should be deleted
593 QPtrList<Event> er = calendar->rawEvents(); 625 QPtrList<Event> er = calendar->rawEvents();
594 Event* ev = er.first(); 626 Event* ev = er.first();
595 while ( ev ) { 627 while ( ev ) {
596 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { 628 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
597 calendar->deleteEvent( ev ); 629 calendar->deleteEvent( ev );
598 } else { 630 } else {
599 631
600 } 632 }
601 ev = er.next(); 633 ev = er.next();
602 } 634 }
603 // 2 remove todos which should be deleted 635 // 2 remove todos which should be deleted
604 QPtrList<Todo> tl = calendar->rawTodos(); 636 QPtrList<Todo> tl = calendar->rawTodos();
605 Todo* to = tl.first(); 637 Todo* to = tl.first();
606 while ( to ) { 638 while ( to ) {
607 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { 639 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
608 calendar->deleteTodo( to ); 640 calendar->deleteTodo( to );
609 } else { 641 } else {
610 if ( to->isCompleted()) { 642 if ( to->isCompleted()) {
611 calendar->deleteTodo( to ); 643 calendar->deleteTodo( to );
612 } 644 }
613 } 645 }
614 to = tl.next(); 646 to = tl.next();
615 } 647 }
616 // 3 save file 648 // 3 save file
617 VCalFormat vfsave; 649 if ( !writeToPhone( calendar ) )
618 vfsave.setLocalTime ( true );
619 if ( ! vfsave.save( calendar, fileName ) )
620 return false; 650 return false;
621 // 4 call kammu
622#ifdef DESKTOP_VERSION
623 QString command ="./kammu --restore " + fileName ;
624#else
625 QString command ="kammu --restore " + fileName ;
626#endif
627 int ret;
628 while ( (ret = system ( command.latin1())) != 0 ) {
629 qDebug("Error S::command returned %d. asking users", ret);
630 int retval = KMessageBox::warningContinueCancel(0,
631 i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KO/Pi phone sync"),i18n("Retry"),i18n("Cancel"));
632 if ( retval != KMessageBox::Continue )
633 return false;
634 }
635 651
636 // 5 reread data 652 // 5 reread data
637 message = i18n(" Rereading all data ... "); 653 message = i18n(" Rereading all data ... ");
638 status.setText ( message ); 654 status.setText ( message );
639 qApp->processEvents(); 655 qApp->processEvents();
640 CalendarLocal* calendarTemp = new CalendarLocal(); 656 CalendarLocal* calendarTemp = new CalendarLocal();
641 calendarTemp->setTimeZoneId( calendar->timeZoneId()); 657 calendarTemp->setTimeZoneId( calendar->timeZoneId());
642 if ( ! load( calendarTemp,calendar) ){ 658 if ( ! load( calendarTemp,calendar) ){
643 qDebug("error reloading calendar "); 659 qDebug("error reloading calendar ");
644 delete calendarTemp; 660 delete calendarTemp;
645 return false; 661 return false;
646 } 662 }
647 // 6 compare data 663 // 6 compare data
648 664
649//algo 6 compare event 665//algo 6 compare event
650 er = calendar->rawEvents(); 666 er = calendar->rawEvents();
651 ev = er.first(); 667 ev = er.first();
652 message = i18n(" Comparing event # "); 668 message = i18n(" Comparing event # ");
653 QPtrList<Event> er1 = calendarTemp->rawEvents(); 669 QPtrList<Event> er1 = calendarTemp->rawEvents();
654 Event* ev1; 670 Event* ev1;
655 int procCount = 0; 671 int procCount = 0;
656 while ( ev ) { 672 while ( ev ) {
657 //qDebug("event new ID %s",ev->summary().latin1()); 673 //qDebug("event new ID %s",ev->summary().latin1());
658 status.setText ( message + QString::number ( ++procCount ) ); 674 status.setText ( message + QString::number ( ++procCount ) );
659 qApp->processEvents(); 675 qApp->processEvents();
660 uint csum; 676 uint csum;
661 csum = PhoneFormat::getCsumEvent( ev ); 677 csum = PhoneFormat::getCsumEvent( ev );
662 QString cSum = QString::number( csum ); 678 QString cSum = QString::number( csum );
663 //ev->setCsum( mProfileName, cSum ); 679 //ev->setCsum( mProfileName, cSum );
664 //qDebug("Event cSum %s ", cSum.latin1()); 680 //qDebug("Event cSum %s ", cSum.latin1());
665 ev1 = er1.first(); 681 ev1 = er1.first();
666 while ( ev1 ) { 682 while ( ev1 ) {
667 if ( ev1->getCsum( mProfileName ) == cSum ) { 683 if ( ev1->getCsum( mProfileName ) == cSum ) {
668 er1.remove( ev1 ); 684 er1.remove( ev1 );
669 afterSave( ev ); 685 afterSave( ev );
670 ev->setID(mProfileName, ev1->getID(mProfileName) ); 686 ev->setID(mProfileName, ev1->getID(mProfileName) );
671 //qDebug("Event found on phone for %s ", ev->summary().latin1()); 687 //qDebug("Event found on phone for %s ", ev->summary().latin1());
672 688
673 break; 689 break;
674 } 690 }
675 ev1 = er1.next(); 691 ev1 = er1.next();
676 } 692 }
677 if ( ! ev1 ) { 693 if ( ! ev1 ) {
678 // ev->removeID(mProfileName); 694 // ev->removeID(mProfileName);
679 qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1()); 695 qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1());
680 } 696 }
681 697
682 698
683 ev = er.next(); 699 ev = er.next();
684 } 700 }
685 //algo 6 compare todo 701 //algo 6 compare todo
686 tl = calendar->rawTodos(); 702 tl = calendar->rawTodos();
687 to = tl.first(); 703 to = tl.first();
688 procCount = 0; 704 procCount = 0;
689 QPtrList<Todo> tl1 = calendarTemp->rawTodos(); 705 QPtrList<Todo> tl1 = calendarTemp->rawTodos();
690 Todo* to1 ; 706 Todo* to1 ;
691 message = i18n(" Comparing todo # "); 707 message = i18n(" Comparing todo # ");
692 while ( to ) { 708 while ( to ) {
693 status.setText ( message + QString::number ( ++procCount ) ); 709 status.setText ( message + QString::number ( ++procCount ) );
694 qApp->processEvents(); 710 qApp->processEvents();
695 uint csum; 711 uint csum;
696 csum = PhoneFormat::getCsumTodo( to ); 712 csum = PhoneFormat::getCsumTodo( to );
697 QString cSum = QString::number( csum ); 713 QString cSum = QString::number( csum );
698 //to->setCsum( mProfileName, cSum ); 714 //to->setCsum( mProfileName, cSum );
699 //qDebug("Todo cSum %s ", cSum.latin1()); 715 //qDebug("Todo cSum %s ", cSum.latin1());
700 Todo* to1 = tl1.first(); 716 Todo* to1 = tl1.first();
701 while ( to1 ) { 717 while ( to1 ) {
702 if ( to1->getCsum( mProfileName ) == cSum ) { 718 if ( to1->getCsum( mProfileName ) == cSum ) {
703 tl1.remove( to1 ); 719 tl1.remove( to1 );
704 afterSave( to ); 720 afterSave( to );
705 to->setID(mProfileName, to1->getID(mProfileName) ); 721 to->setID(mProfileName, to1->getID(mProfileName) );
706 break; 722 break;
707 } 723 }
708 to1 = tl1.next(); 724 to1 = tl1.next();
709 } 725 }
710 if ( ! to1 ) { 726 if ( ! to1 ) {
711 //to->removeID(mProfileName); 727 //to->removeID(mProfileName);
712 qDebug("ERROR: No todo found on phone for %s ", to->summary().latin1()); 728 qDebug("ERROR: No todo found on phone for %s ", to->summary().latin1());
713 } 729 }
714 730
715 to = tl.next(); 731 to = tl.next();
716 } 732 }
717 delete calendarTemp; 733 delete calendarTemp;
718 return true; 734 return true;
719 735
720 736
721 737
722} 738}
723 739
724 740
725QString PhoneFormat::toString( Calendar * ) 741QString PhoneFormat::toString( Calendar * )
726{ 742{
727 return QString::null; 743 return QString::null;
728} 744}
729bool PhoneFormat::fromString( Calendar *calendar, const QString & text) 745bool PhoneFormat::fromString( Calendar *calendar, const QString & text)
730{ 746{
731 return false; 747 return false;
732} 748}
diff --git a/libkcal/phoneformat.h b/libkcal/phoneformat.h
index 2d1ff79..61e8160 100644
--- a/libkcal/phoneformat.h
+++ b/libkcal/phoneformat.h
@@ -1,61 +1,63 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 3
4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21#ifndef PHONEFORMAT_H 21#ifndef PHONEFORMAT_H
22#define PHONEFORMAT_H 22#define PHONEFORMAT_H
23 23
24#include <qstring.h> 24#include <qstring.h>
25 25
26#include "scheduler.h" 26#include "scheduler.h"
27 27
28#include "vcalformat.h" 28#include "vcalformat.h"
29#include "calformat.h" 29#include "calformat.h"
30 30
31namespace KCal { 31namespace KCal {
32 32
33/** 33/**
34 This class implements the calendar format used by Phone. 34 This class implements the calendar format used by Phone.
35*/ 35*/
36 class Event; 36 class Event;
37 class Todo; 37 class Todo;
38class PhoneFormat : public QObject { 38class PhoneFormat : public QObject {
39 public: 39 public:
40 /** Create new iCalendar format. */ 40 /** Create new iCalendar format. */
41 PhoneFormat(QString profileName, QString device,QString connection, QString model); 41 PhoneFormat(QString profileName, QString device,QString connection, QString model);
42 virtual ~PhoneFormat(); 42 virtual ~PhoneFormat();
43 43
44 bool load( Calendar * ,Calendar * ); 44 bool load( Calendar * ,Calendar * );
45 bool save( Calendar * ); 45 bool save( Calendar * );
46 bool fromString( Calendar *, const QString & ); 46 bool fromString( Calendar *, const QString & );
47 QString toString( Calendar * ); 47 QString toString( Calendar * );
48 static ulong getCsum( const QStringList & ); 48 static ulong getCsum( const QStringList & );
49 static ulong getCsumTodo( Todo* to ); 49 static ulong getCsumTodo( Todo* to );
50 static ulong getCsumEvent( Event* ev ); 50 static ulong getCsumEvent( Event* ev );
51 static void writeConfig( QString device,QString connection, QString model );
52 static bool writeToPhone( Calendar * );
51 private: 53 private:
52 void copyEvent( Event* to, Event* from ); 54 void copyEvent( Event* to, Event* from );
53 void copyTodo( Todo* to, Todo* from ); 55 void copyTodo( Todo* to, Todo* from );
54 //int initDevice(GSM_StateMachine *s); 56 //int initDevice(GSM_StateMachine *s);
55 QString mProfileName; 57 QString mProfileName;
56 void afterSave( Incidence* ); 58 void afterSave( Incidence* );
57}; 59};
58 60
59} 61}
60 62
61#endif 63#endif