summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koprefs.cpp5
-rw-r--r--korganizer/koprefs.h4
-rw-r--r--korganizer/mainwindow.cpp317
-rw-r--r--korganizer/mainwindow.h65
4 files changed, 386 insertions, 5 deletions
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp
index 5d7db4f..0034715 100644
--- a/korganizer/koprefs.cpp
+++ b/korganizer/koprefs.cpp
@@ -1,384 +1,387 @@
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 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); 80 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
81 81
82 addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); 82 addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true);
83 addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); 83 addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true);
84 addItemBool("ShowIconSearch",&mShowIconSearch,true); 84 addItemBool("ShowIconSearch",&mShowIconSearch,true);
85 addItemBool("ShowIconList",&mShowIconList,true); 85 addItemBool("ShowIconList",&mShowIconList,true);
86 addItemBool("ShowIconDay1",&mShowIconDay1,true); 86 addItemBool("ShowIconDay1",&mShowIconDay1,true);
87 addItemBool("ShowIconDay5",&mShowIconDay5,true); 87 addItemBool("ShowIconDay5",&mShowIconDay5,true);
88 addItemBool("ShowIconDay7",&mShowIconDay7,true); 88 addItemBool("ShowIconDay7",&mShowIconDay7,true);
89 addItemBool("ShowIconMonth",&mShowIconMonth,true); 89 addItemBool("ShowIconMonth",&mShowIconMonth,true);
90 addItemBool("ShowIconTodoview",&mShowIconTodoview,true); 90 addItemBool("ShowIconTodoview",&mShowIconTodoview,true);
91 addItemBool("ShowIconBackFast",&mShowIconBackFast,true); 91 addItemBool("ShowIconBackFast",&mShowIconBackFast,true);
92 addItemBool("ShowIconBack",&mShowIconBack,true); 92 addItemBool("ShowIconBack",&mShowIconBack,true);
93 addItemBool("ShowIconToday",&mShowIconToday,true); 93 addItemBool("ShowIconToday",&mShowIconToday,true);
94 addItemBool("ShowIconForward",&mShowIconForward,true); 94 addItemBool("ShowIconForward",&mShowIconForward,true);
95 addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); 95 addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true);
96 addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,false); 96 addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,false);
97 addItemBool("ShowIconNextDays",&mShowIconNextDays,true); 97 addItemBool("ShowIconNextDays",&mShowIconNextDays,true);
98 addItemBool("ShowIconNext",&mShowIconNext,true); 98 addItemBool("ShowIconNext",&mShowIconNext,true);
99 addItemBool("ShowIconJournal",&mShowIconJournal,true); 99 addItemBool("ShowIconJournal",&mShowIconJournal,true);
100 addItemBool("ShowIconStretch",&mShowIconStretch,true); 100 addItemBool("ShowIconStretch",&mShowIconStretch,true);
101 addItemBool("LanguageChanged",&mLanguageChanged,false); 101 addItemBool("LanguageChanged",&mLanguageChanged,false);
102 102
103 addItemBool("AskForQuit",&mAskForQuit,false); 103 addItemBool("AskForQuit",&mAskForQuit,false);
104 104
105#ifndef DESKTOP_VERSION 105#ifndef DESKTOP_VERSION
106 addItemBool("ShowFullMenu",&mShowFullMenu,false); 106 addItemBool("ShowFullMenu",&mShowFullMenu,false);
107#else 107#else
108 addItemBool("ShowFullMenu",&mShowFullMenu,true); 108 addItemBool("ShowFullMenu",&mShowFullMenu,true);
109#endif 109#endif
110 addItemBool("ToolBarHor",&mToolBarHor, true ); 110 addItemBool("ToolBarHor",&mToolBarHor, true );
111 addItemBool("ToolBarUp",&mToolBarUp, false ); 111 addItemBool("ToolBarUp",&mToolBarUp, false );
112 addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); 112 addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false );
113 addItemInt("Whats Next Days",&mWhatsNextDays,3); 113 addItemInt("Whats Next Days",&mWhatsNextDays,3);
114 addItemInt("Whats Next Prios",&mWhatsNextPrios,1); 114 addItemInt("Whats Next Prios",&mWhatsNextPrios,1);
115 115
116 addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); 116 addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true);
117 addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); 117 addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true);
118 addItemInt("AllDay Size",&mAllDaySize,28); 118 addItemInt("AllDay Size",&mAllDaySize,28);
119 QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; 119 QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav";
120 addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); 120 addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm );
121 121
122 addItemStringList("LocationDefaults",&mLocationDefaults ); 122 addItemStringList("LocationDefaults",&mLocationDefaults );
123 addItemStringList("EventSummary User",&mEventSummaryUser); 123 addItemStringList("EventSummary User",&mEventSummaryUser);
124 addItemStringList("TodoSummary User",&mTodoSummaryUser); 124 addItemStringList("TodoSummary User",&mTodoSummaryUser);
125 125
126 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); 126 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
127 addItemBool("Enable Project View",&mEnableProjectView,false); 127 addItemBool("Enable Project View",&mEnableProjectView,false);
128 addItemBool("Auto Save",&mAutoSave,false); 128 addItemBool("Auto Save",&mAutoSave,false);
129 addItemInt("Auto Save Interval",&mAutoSaveInterval,3); 129 addItemInt("Auto Save Interval",&mAutoSaveInterval,3);
130 addItemBool("Confirm Deletes",&mConfirm,true); 130 addItemBool("Confirm Deletes",&mConfirm,true);
131 addItemString("Archive File",&mArchiveFile); 131 addItemString("Archive File",&mArchiveFile);
132 addItemString("Html Export File",&mHtmlExportFile, 132 addItemString("Html Export File",&mHtmlExportFile,
133 QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); 133 QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html"));
134 addItemBool("Html With Save",&mHtmlWithSave,false); 134 addItemBool("Html With Save",&mHtmlWithSave,false);
135 135
136 KPrefs::setCurrentGroup("Personal Settings"); 136 KPrefs::setCurrentGroup("Personal Settings");
137 137
138 addItemInt("Mail Client",&mMailClient,MailClientKMail); 138 addItemInt("Mail Client",&mMailClient,MailClientKMail);
139 addItemBool("Use Control Center Email",&mEmailControlCenter,false); 139 addItemBool("Use Control Center Email",&mEmailControlCenter,false);
140 addItemBool("Bcc",&mBcc,false); 140 addItemBool("Bcc",&mBcc,false);
141 141
142 KPrefs::setCurrentGroup("Time & Date"); 142 KPrefs::setCurrentGroup("Time & Date");
143 143
144 // addItemString("Time Zone",&mTimeZone,"+0100"); 144 // addItemString("Time Zone",&mTimeZone,"+0100");
145 addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") ); 145 addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") );
146 // addItemInt("TimeZoneOffset",&mTimeZoneOffset,60); 146 // addItemInt("TimeZoneOffset",&mTimeZoneOffset,60);
147 addItemBool("UseDaylightsaving",&mUseDaylightsaving,true); 147 addItemBool("UseDaylightsaving",&mUseDaylightsaving,true);
148 addItemInt("DaylightsavingStart",&mDaylightsavingStart,90); 148 addItemInt("DaylightsavingStart",&mDaylightsavingStart,90);
149 addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304); 149 addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304);
150 150
151 151
152 addItemInt("Default Start Time",&mStartTime,10); 152 addItemInt("Default Start Time",&mStartTime,10);
153 addItemInt("Default Duration",&mDefaultDuration,2); 153 addItemInt("Default Duration",&mDefaultDuration,2);
154 addItemInt("Default Alarm Time",&mAlarmTime,3); 154 addItemInt("Default Alarm Time",&mAlarmTime,3);
155 addItemInt("Daylight Savings",&mDaylightSavings,0); 155 addItemInt("Daylight Savings",&mDaylightSavings,0);
156 KPrefs::setCurrentGroup("AlarmSettings"); 156 KPrefs::setCurrentGroup("AlarmSettings");
157 addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); 157 addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20);
158 addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); 158 addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7);
159 addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); 159 addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5);
160 addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); 160 addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3);
161 161
162 162
163 KPrefs::setCurrentGroup("Calendar"); 163 KPrefs::setCurrentGroup("Calendar");
164 164
165 addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); 165 addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar);
166 166
167 KPrefs::setCurrentGroup("Fonts"); 167 KPrefs::setCurrentGroup("Fonts");
168 // qDebug(" KPrefs::setCurrentGroup(Fonts); "); 168 // qDebug(" KPrefs::setCurrentGroup(Fonts); ");
169 addItemFont("TimeBar Font",&mTimeBarFont); 169 addItemFont("TimeBar Font",&mTimeBarFont);
170 addItemFont("MonthView Font",&mMonthViewFont); 170 addItemFont("MonthView Font",&mMonthViewFont);
171 addItemFont("AgendaView Font",&mAgendaViewFont); 171 addItemFont("AgendaView Font",&mAgendaViewFont);
172 addItemFont("MarcusBains Font",&mMarcusBainsFont); 172 addItemFont("MarcusBains Font",&mMarcusBainsFont);
173 addItemFont("TimeLabels Font",&mTimeLabelsFont); 173 addItemFont("TimeLabels Font",&mTimeLabelsFont);
174 addItemFont("TodoView Font",&mTodoViewFont); 174 addItemFont("TodoView Font",&mTodoViewFont);
175 addItemFont("ListView Font",&mListViewFont); 175 addItemFont("ListView Font",&mListViewFont);
176 addItemFont("DateNavigator Font",&mDateNavigatorFont); 176 addItemFont("DateNavigator Font",&mDateNavigatorFont);
177 addItemFont("EditBox Font",&mEditBoxFont); 177 addItemFont("EditBox Font",&mEditBoxFont);
178 addItemFont("JournalView Font",&mJornalViewFont); 178 addItemFont("JournalView Font",&mJornalViewFont);
179 addItemFont("WhatsNextView Font",&mWhatsNextFont); 179 addItemFont("WhatsNextView Font",&mWhatsNextFont);
180 addItemFont("EventView Font",&mEventViewFont); 180 addItemFont("EventView Font",&mEventViewFont);
181 181
182// KPrefs::setCurrentGroup("SyncProfiles"); 182// KPrefs::setCurrentGroup("SyncProfiles");
183// addItemString("LocalMachineName",&mLocalMachineName, "undefined"); 183// addItemString("LocalMachineName",&mLocalMachineName, "undefined");
184// addItemStringList("SyncProfileNames",&mSyncProfileNames); 184// addItemStringList("SyncProfileNames",&mSyncProfileNames);
185// addItemStringList("ExternSyncProfiles",&mExternSyncProfileNames); 185// addItemStringList("ExternSyncProfiles",&mExternSyncProfileNames);
186 186
187 KPrefs::setCurrentGroup("RemoteSyncing"); 187 KPrefs::setCurrentGroup("RemoteSyncing");
188// addItemBool("UsePasswd",&mUsePassWd,false); 188// addItemBool("UsePasswd",&mUsePassWd,false);
189// addItemBool("WriteBackFile",&mWriteBackFile,true); 189// addItemBool("WriteBackFile",&mWriteBackFile,true);
190// addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false); 190// addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false);
191// addItemBool("AskForPreferences",&mAskForPreferences,true); 191// addItemBool("AskForPreferences",&mAskForPreferences,true);
192// addItemBool("ShowSyncSummary",&mShowSyncSummary,true); 192// addItemBool("ShowSyncSummary",&mShowSyncSummary,true);
193 addItemString("PassiveSyncPort",&mPassiveSyncPort,"9197" );
194 addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" );
195 addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" );
193 addItemBool("ShowSyncEvents",&mShowSyncEvents,false); 196 addItemBool("ShowSyncEvents",&mShowSyncEvents,false);
194 addItemInt("LastSyncTime",&mLastSyncTime,0); 197 addItemInt("LastSyncTime",&mLastSyncTime,0);
195 addItemInt("SyncAlgoPrefs",&mSyncAlgoPrefs,3); 198 addItemInt("SyncAlgoPrefs",&mSyncAlgoPrefs,3);
196 addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3); 199 addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3);
197 200
198#ifdef _WIN32_ 201#ifdef _WIN32_
199 QString hdp= locateLocal("data","korganizer")+"\\\\"; 202 QString hdp= locateLocal("data","korganizer")+"\\\\";
200#else 203#else
201 QString hdp= locateLocal("data","korganizer")+"/"; 204 QString hdp= locateLocal("data","korganizer")+"/";
202#endif 205#endif
203// addItemString("RemoteIP",&mRemoteIP, "192.168.0.65"); 206// addItemString("RemoteIP",&mRemoteIP, "192.168.0.65");
204// addItemString("RemoteUser",&mRemoteUser, "zaurus"); 207// addItemString("RemoteUser",&mRemoteUser, "zaurus");
205// addItemString("RemotePassWd",&mRemotePassWd, ""); 208// addItemString("RemotePassWd",&mRemotePassWd, "");
206// addItemString("RemoteFile", &mRemoteFile, hdp+"mycalendar.ics"); 209// addItemString("RemoteFile", &mRemoteFile, hdp+"mycalendar.ics");
207// addItemString("LocalTempFile",&mLocalTempFile, "/tmp/tempsyncfile.ics" ); 210// addItemString("LocalTempFile",&mLocalTempFile, "/tmp/tempsyncfile.ics" );
208 211
209 212
210 KPrefs::setCurrentGroup("LoadSaveFileNames"); 213 KPrefs::setCurrentGroup("LoadSaveFileNames");
211 214
212 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); 215 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" );
213 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); 216 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" );
214 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); 217 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" );
215 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); 218 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" );
216 addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" ); 219 addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" );
217 220
218 221
219 KPrefs::setCurrentGroup("Locale"); 222 KPrefs::setCurrentGroup("Locale");
220 addItemInt("PreferredLanguage",&mPreferredLanguage,0); 223 addItemInt("PreferredLanguage",&mPreferredLanguage,0);
221 addItemInt("PreferredTime",&mPreferredTime,0); 224 addItemInt("PreferredTime",&mPreferredTime,0);
222 addItemInt("PreferredDate",&mPreferredDate,0); 225 addItemInt("PreferredDate",&mPreferredDate,0);
223 addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false); 226 addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false);
224 addItemBool("QuickSavingWOUnicode",&mUseQuicksave,false); 227 addItemBool("QuickSavingWOUnicode",&mUseQuicksave,false);
225 addItemBool("ShortDateInViewer",&mShortDateInViewer,false); 228 addItemBool("ShortDateInViewer",&mShortDateInViewer,false);
226 addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y"); 229 addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y");
227 addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y"); 230 addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y");
228 231
229 232
230 KPrefs::setCurrentGroup("Colors"); 233 KPrefs::setCurrentGroup("Colors");
231 addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); 234 addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor);
232 addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); 235 addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor);
233 addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); 236 addItemColor("Event Color",&mEventColor,mDefaultCategoryColor);
234 addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); 237 addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor);
235 addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); 238 addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor);
236 addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); 239 addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor);
237 addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); 240 addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor);
238 addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); 241 addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 ));
239 addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); 242 addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 ));
240 addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); 243 addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 ));
241 addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); 244 addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true);
242 addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); 245 addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true);
243 addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); 246 addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false);
244 addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); 247 addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 ));
245 addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); 248 addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 ));
246 addItemBool("UseAppColors",&mUseAppColors,false); 249 addItemBool("UseAppColors",&mUseAppColors,false);
247 250
248 251
249 252
250 KPrefs::setCurrentGroup("Views"); 253 KPrefs::setCurrentGroup("Views");
251 addItemInt("Hour Size",&mHourSize,8); 254 addItemInt("Hour Size",&mHourSize,8);
252 addItemBool("Show Daily Recurrences",&mDailyRecur,true); 255 addItemBool("Show Daily Recurrences",&mDailyRecur,true);
253 addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); 256 addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true);
254 addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); 257 addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true);
255 addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); 258 addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true);
256 addItemBool("ShowShortMonthName",&mMonthShowShort,false); 259 addItemBool("ShowShortMonthName",&mMonthShowShort,false);
257 addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); 260 addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true);
258 addItemBool("Enable ToolTips",&mEnableToolTips,false); 261 addItemBool("Enable ToolTips",&mEnableToolTips,false);
259 addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); 262 addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false);
260 addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); 263 addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false);
261 addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); 264 addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true);
262 addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); 265 addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true);
263 addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,false); 266 addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,false);
264 addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); 267 addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false);
265 addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); 268 addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false);
266 addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); 269 addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true);
267 addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); 270 addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true);
268 addItemBool("WNViewShowsParents",&mWNViewShowsParents,true); 271 addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);
269 addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); 272 addItemBool("WNViewShowLocation",&mWNViewShowLocation,false);
270 addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); 273 addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false);
271 addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); 274 addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true);
272 addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); 275 addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false);
273 addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); 276 addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false);
274 addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,false); 277 addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,false);
275 addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); 278 addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false);
276 addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); 279 addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false);
277#ifdef DESKTOP_VERSION 280#ifdef DESKTOP_VERSION
278 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); 281 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true);
279#else 282#else
280 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); 283 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false);
281#endif 284#endif
282 addItemInt("Day Begins",&mDayBegins,7); 285 addItemInt("Day Begins",&mDayBegins,7);
283 addItemInt("Working Hours Start",&mWorkingHoursStart,8); 286 addItemInt("Working Hours Start",&mWorkingHoursStart,8);
284 addItemInt("Working Hours End",&mWorkingHoursEnd,17); 287 addItemInt("Working Hours End",&mWorkingHoursEnd,17);
285 addItemBool("Exclude Holidays",&mExcludeHolidays,true); 288 addItemBool("Exclude Holidays",&mExcludeHolidays,true);
286 addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); 289 addItemBool("Exclude Saturdays",&mExcludeSaturdays,true);
287 290
288 addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); 291 addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false);
289 addItemBool("Full View Month",&mFullViewMonth,true); 292 addItemBool("Full View Month",&mFullViewMonth,true);
290 addItemBool("Full View Todo",&mFullViewTodo,true); 293 addItemBool("Full View Todo",&mFullViewTodo,true);
291 addItemBool("Quick Todo",&mEnableQuickTodo,false); 294 addItemBool("Quick Todo",&mEnableQuickTodo,false);
292 295
293 addItemInt("Next X Days",&mNextXDays,3); 296 addItemInt("Next X Days",&mNextXDays,3);
294 297
295 KPrefs::setCurrentGroup("Printer"); 298 KPrefs::setCurrentGroup("Printer");
296 299
297 KPrefs::setCurrentGroup("Layout"); 300 KPrefs::setCurrentGroup("Layout");
298 301
299 addItemBool("CompactDialogs",&mCompactDialogs,false); 302 addItemBool("CompactDialogs",&mCompactDialogs,false);
300 addItemBool("VerticalScreen",&mVerticalScreen,true); 303 addItemBool("VerticalScreen",&mVerticalScreen,true);
301 304
302 KPrefs::setCurrentGroup("KOrganizer Plugins"); 305 KPrefs::setCurrentGroup("KOrganizer Plugins");
303 306
304 addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); 307 addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays");
305 308
306 KPrefs::setCurrentGroup("Group Scheduling"); 309 KPrefs::setCurrentGroup("Group Scheduling");
307 310
308 addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); 311 addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail);
309 addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); 312 addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend);
310 addItemStringList("AdditionalMails",&mAdditionalMails,""); 313 addItemStringList("AdditionalMails",&mAdditionalMails,"");
311 addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); 314 addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto);
312 addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); 315 addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto);
313 addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); 316 addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto);
314 addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); 317 addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto);
315 addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); 318 addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto);
316 319
317 KPrefs::setCurrentGroup( "Editors" ); 320 KPrefs::setCurrentGroup( "Editors" );
318 321
319 addItemStringList( "EventTemplates", &mEventTemplates ); 322 addItemStringList( "EventTemplates", &mEventTemplates );
320 addItemStringList( "TodoTemplates", &mTodoTemplates ); 323 addItemStringList( "TodoTemplates", &mTodoTemplates );
321 324
322 addItemInt("DestinationPolicy",&mDestination,standardDestination); 325 addItemInt("DestinationPolicy",&mDestination,standardDestination);
323 326
324 327
325 328
326} 329}
327 330
328 331
329KOPrefs::~KOPrefs() 332KOPrefs::~KOPrefs()
330{ 333{
331 if (mInstance == this) 334 if (mInstance == this)
332 mInstance = insd.setObject(0); 335 mInstance = insd.setObject(0);
333 setLocaleDict( 0 ); 336 setLocaleDict( 0 );
334 if ( mLocaleDict ) 337 if ( mLocaleDict )
335 delete mLocaleDict; 338 delete mLocaleDict;
336 //qDebug("KOPrefs::~KOPrefs() "); 339 //qDebug("KOPrefs::~KOPrefs() ");
337} 340}
338 341
339 342
340KOPrefs *KOPrefs::instance() 343KOPrefs *KOPrefs::instance()
341{ 344{
342 if (!mInstance) { 345 if (!mInstance) {
343 mInstance = insd.setObject(new KOPrefs()); 346 mInstance = insd.setObject(new KOPrefs());
344 mInstance->readConfig(); 347 mInstance->readConfig();
345 } 348 }
346 349
347 return mInstance; 350 return mInstance;
348} 351}
349 352
350void KOPrefs::usrSetDefaults() 353void KOPrefs::usrSetDefaults()
351{ 354{
352 355
353} 356}
354 357
355void KOPrefs::fillMailDefaults() 358void KOPrefs::fillMailDefaults()
356{ 359{
357 if (mName.isEmpty()) mName = i18n("Anonymous"); 360 if (mName.isEmpty()) mName = i18n("Anonymous");
358 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); 361 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere");
359} 362}
360 363
361void KOPrefs::setTimeZoneIdDefault() 364void KOPrefs::setTimeZoneIdDefault()
362{ 365{
363 mTimeZoneId = i18n("+01:00 Europe/Oslo(CET)"); 366 mTimeZoneId = i18n("+01:00 Europe/Oslo(CET)");
364} 367}
365 368
366void KOPrefs::setCategoryDefaults() 369void KOPrefs::setCategoryDefaults()
367{ 370{
368 mCustomCategories.clear(); 371 mCustomCategories.clear();
369 mCustomCategories = getDefaultList(); 372 mCustomCategories = getDefaultList();
370 373
371 QStringList::Iterator it; 374 QStringList::Iterator it;
372 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { 375 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) {
373 setCategoryColor(*it,mDefaultCategoryColor); 376 setCategoryColor(*it,mDefaultCategoryColor);
374 } 377 }
375} 378}
376 379
377QStringList KOPrefs::getDefaultList() 380QStringList KOPrefs::getDefaultList()
378{ 381{
379 QStringList retval ; 382 QStringList retval ;
380 retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer") 383 retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer")
381 << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner") 384 << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner")
382 << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts") 385 << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts")
383 << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids") 386 << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids")
384 << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel") 387 << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel")
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index 33eda60..696433e 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -90,220 +90,224 @@ class KOPrefs : public KPimPrefs
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 213
214 int mLastSyncTime; 214 int mLastSyncTime;
215 int mSyncAlgoPrefs; 215 int mSyncAlgoPrefs;
216 int mRingSyncAlgoPrefs; 216 int mRingSyncAlgoPrefs;
217 QStringList mSyncProfileNames; 217 QStringList mSyncProfileNames;
218 QStringList mExternSyncProfiles; 218 QStringList mExternSyncProfiles;
219 QString mLocalMachineName; 219 QString mLocalMachineName;
220 void setCategoryColor(QString cat,const QColor & color); 220 void setCategoryColor(QString cat,const QColor & color);
221 QColor *categoryColor(QString cat); 221 QColor *categoryColor(QString cat);
222 222
223 QString mArchiveFile; 223 QString mArchiveFile;
224 QString mHtmlExportFile; 224 QString mHtmlExportFile;
225 bool mHtmlWithSave; 225 bool mHtmlWithSave;
226 226
227 QStringList mSelectedPlugins; 227 QStringList mSelectedPlugins;
228 228
229 QString mLastImportFile; 229 QString mLastImportFile;
230 QString mLastVcalFile; 230 QString mLastVcalFile;
231 QString mLastSaveFile; 231 QString mLastSaveFile;
232 QString mLastLoadFile; 232 QString mLastLoadFile;
233 QString mLastSyncedLocalFile; 233 QString mLastSyncedLocalFile;
234 234
235 235
236 QString mDefaultAlarmFile; 236 QString mDefaultAlarmFile;
237 int mIMIPScheduler; 237 int mIMIPScheduler;
238 int mIMIPSend; 238 int mIMIPSend;
239 QStringList mAdditionalMails; 239 QStringList mAdditionalMails;
240 int mIMIPAutoRefresh; 240 int mIMIPAutoRefresh;
241 int mIMIPAutoInsertReply; 241 int mIMIPAutoInsertReply;
242 int mIMIPAutoInsertRequest; 242 int mIMIPAutoInsertRequest;
243 int mIMIPAutoFreeBusy; 243 int mIMIPAutoFreeBusy;
244 int mIMIPAutoFreeBusyReply; 244 int mIMIPAutoFreeBusyReply;
245 245
246 QStringList mTodoTemplates; 246 QStringList mTodoTemplates;
247 QStringList mEventTemplates; 247 QStringList mEventTemplates;
248 248
249 int mDestination; 249 int mDestination;
250 250
251 251
252 bool mEditOnDoubleClick; 252 bool mEditOnDoubleClick;
253 bool mViewChangeHoldFullscreen; 253 bool mViewChangeHoldFullscreen;
254 bool mViewChangeHoldNonFullscreen; 254 bool mViewChangeHoldNonFullscreen;
255 bool mCenterOnCurrentTime; 255 bool mCenterOnCurrentTime;
256 bool mSetTimeToDayStartAt; 256 bool mSetTimeToDayStartAt;
257 bool mHighlightCurrentDay; 257 bool mHighlightCurrentDay;
258 bool mUseHighlightLightColor; 258 bool mUseHighlightLightColor;
259 bool mListViewMonthTimespan; 259 bool mListViewMonthTimespan;
260 bool mWNViewShowsParents; 260 bool mWNViewShowsParents;
261 bool mWNViewShowLocation; 261 bool mWNViewShowLocation;
262 bool mTodoViewShowsPercentage; 262 bool mTodoViewShowsPercentage;
263 bool mTodoViewUsesCatColors; 263 bool mTodoViewUsesCatColors;
264 bool mTodoViewUsesSmallFont; 264 bool mTodoViewUsesSmallFont;
265 bool mTodoViewUsesForegroundColor; 265 bool mTodoViewUsesForegroundColor;
266 bool mMonthViewUsesForegroundColor; 266 bool mMonthViewUsesForegroundColor;
267 267
268 bool mHightlightDateTimeEdit; 268 bool mHightlightDateTimeEdit;
269 bool mUseQuicksave; 269 bool mUseQuicksave;
270 bool mShortDateInViewer; 270 bool mShortDateInViewer;
271 271
272 QStringList mLocationDefaults; 272 QStringList mLocationDefaults;
273 QStringList mEventSummaryUser; 273 QStringList mEventSummaryUser;
274 QStringList mTodoSummaryUser; 274 QStringList mTodoSummaryUser;
275 275
276 bool mUseInternalAlarmNotification; 276 bool mUseInternalAlarmNotification;
277 int mAlarmPlayBeeps; 277 int mAlarmPlayBeeps;
278 int mAlarmSuspendTime; 278 int mAlarmSuspendTime;
279 int mAlarmSuspendCount; 279 int mAlarmSuspendCount;
280 int mAlarmBeepInterval; 280 int mAlarmBeepInterval;
281 281
282 QString mPassiveSyncPort;
283 QString mActiveSyncPort;
284 QString mActiveSyncIP;
285
282 286
283 //US I copied the following settings into KPimGlobalPrefs 287 //US I copied the following settings into KPimGlobalPrefs
284 // that allows us later to easily remove the settings from here. 288 // that allows us later to easily remove the settings from here.
285 int mPreferredDate; 289 int mPreferredDate;
286 QString mUserDateFormatLong; 290 QString mUserDateFormatLong;
287 QString mUserDateFormatShort; 291 QString mUserDateFormatShort;
288 int mPreferredLanguage; 292 int mPreferredLanguage;
289 int mPreferredTime; 293 int mPreferredTime;
290 bool mWeekStartsOnSunday; 294 bool mWeekStartsOnSunday;
291 QString mTimeZoneId; 295 QString mTimeZoneId;
292 bool mUseDaylightsaving; 296 bool mUseDaylightsaving;
293 int mDaylightsavingStart; 297 int mDaylightsavingStart;
294 int mDaylightsavingEnd; 298 int mDaylightsavingEnd;
295 299
296 300
297 private: 301 private:
298 QDict<QColor> mCategoryColors; 302 QDict<QColor> mCategoryColors;
299 QColor mDefaultCategoryColor; 303 QColor mDefaultCategoryColor;
300 304
301 QFont mDefaultTimeBarFont; 305 QFont mDefaultTimeBarFont;
302 QFont mDefaultViewFont; 306 QFont mDefaultViewFont;
303 QFont mDefaultMonthViewFont; 307 QFont mDefaultMonthViewFont;
304 308
305 QString mName; 309 QString mName;
306 QString mEmail; 310 QString mEmail;
307}; 311};
308 312
309#endif 313#endif
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 6315c64..f2e1bf8 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,408 +1,411 @@
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 <qmessagebox.h> 7#include <qmessagebox.h>
8#include <qlineedit.h> 8#include <qlineedit.h>
9#include <qtextcodec.h>
9#include <qfile.h> 10#include <qfile.h>
10#include <qdir.h> 11#include <qdir.h>
11#include <qapp.h> 12#include <qapp.h>
12#include <qfileinfo.h> 13#include <qfileinfo.h>
13#include <qlabel.h> 14#include <qlabel.h>
14#include <qmap.h> 15#include <qmap.h>
15#include <qwmatrix.h> 16#include <qwmatrix.h>
16#include <qtextbrowser.h> 17#include <qtextbrowser.h>
17#include <qtextstream.h> 18#include <qtextstream.h>
18#ifndef DESKTOP_VERSION 19#ifndef DESKTOP_VERSION
19#include <qpe/global.h> 20#include <qpe/global.h>
20#include <qpe/qpemenubar.h> 21#include <qpe/qpemenubar.h>
21#include <qpe/qpetoolbar.h> 22#include <qpe/qpetoolbar.h>
22#include <qpe/resource.h> 23#include <qpe/resource.h>
23#include <qpe/qpeapplication.h> 24#include <qpe/qpeapplication.h>
24#include <qtopia/alarmserver.h> 25#include <qtopia/alarmserver.h>
25#include <qtopia/qcopenvelope_qws.h> 26#include <qtopia/qcopenvelope_qws.h>
26#else 27#else
27#include <qmenubar.h> 28#include <qmenubar.h>
28#include <qtoolbar.h> 29#include <qtoolbar.h>
29#include <qapplication.h> 30#include <qapplication.h>
30//#include <resource.h> 31//#include <resource.h>
31 32
32#endif 33#endif
33#include <libkcal/calendarlocal.h> 34#include <libkcal/calendarlocal.h>
34#include <libkcal/todo.h> 35#include <libkcal/todo.h>
35#include <libkdepim/ksyncprofile.h> 36#include <libkdepim/ksyncprofile.h>
36#include <libkcal/kincidenceformatter.h> 37#include <libkcal/kincidenceformatter.h>
37#include <libkdepim/kpimglobalprefs.h> 38#include <libkdepim/kpimglobalprefs.h>
38 39
39#include "calendarview.h" 40#include "calendarview.h"
40#include "koviewmanager.h" 41#include "koviewmanager.h"
41#include "datenavigator.h" 42#include "datenavigator.h"
42#include "koagendaview.h" 43#include "koagendaview.h"
43#include "koagenda.h" 44#include "koagenda.h"
44#include "kodialogmanager.h" 45#include "kodialogmanager.h"
45#include "kdialogbase.h" 46#include "kdialogbase.h"
46#include "kapplication.h" 47#include "kapplication.h"
47#include "kofilterview.h" 48#include "kofilterview.h"
48#include "kstandarddirs.h" 49#include "kstandarddirs.h"
49#include "koprefs.h" 50#include "koprefs.h"
50#include "kfiledialog.h" 51#include "kfiledialog.h"
51#include "koglobals.h" 52#include "koglobals.h"
52#include "kglobal.h" 53#include "kglobal.h"
53#include "klocale.h" 54#include "klocale.h"
54#include "kconfig.h" 55#include "kconfig.h"
55#include "simplealarmclient.h" 56#include "simplealarmclient.h"
56#include "externalapphandler.h" 57#include "externalapphandler.h"
57 58
58using namespace KCal; 59using namespace KCal;
59#ifndef _WIN32_ 60#ifndef _WIN32_
60#include <unistd.h> 61#include <unistd.h>
61#else 62#else
62#include "koimportoldialog.h" 63#include "koimportoldialog.h"
63#endif 64#endif
64#include "mainwindow.h" 65#include "mainwindow.h"
65 66
66int globalFlagBlockStartup; 67int globalFlagBlockStartup;
67MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 68MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
68 QMainWindow( parent, name ) 69 QMainWindow( parent, name )
69{ 70{
70 71
71#ifdef DESKTOP_VERSION 72#ifdef DESKTOP_VERSION
72 setFont( QFont("Arial"), 14 ); 73 setFont( QFont("Arial"), 14 );
73#endif 74#endif
74 75 mCommandSocket = 0;
76 mSyncActionDialog = 0;
77 mServerSocket = 0;
75 mClosed = false; 78 mClosed = false;
76 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 79 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
77 QString confFile = locateLocal("config","korganizerrc"); 80 QString confFile = locateLocal("config","korganizerrc");
78 QFileInfo finf ( confFile ); 81 QFileInfo finf ( confFile );
79 bool showWarning = !finf.exists(); 82 bool showWarning = !finf.exists();
80 setIcon(SmallIcon( "ko24" ) ); 83 setIcon(SmallIcon( "ko24" ) );
81 mBlockAtStartup = true; 84 mBlockAtStartup = true;
82 mFlagKeyPressed = false; 85 mFlagKeyPressed = false;
83 setCaption("KOrganizer/Pi"); 86 setCaption("KOrganizer/Pi");
84 KOPrefs *p = KOPrefs::instance(); 87 KOPrefs *p = KOPrefs::instance();
85 KPimGlobalPrefs::instance()->setGlobalConfig(); 88 KPimGlobalPrefs::instance()->setGlobalConfig();
86 // if ( QApplication::desktop()->height() > 480 ) { 89 // if ( QApplication::desktop()->height() > 480 ) {
87// if ( p->mHourSize == 4 ) 90// if ( p->mHourSize == 4 )
88// p->mHourSize = 6; 91// p->mHourSize = 6;
89// } 92// }
90 if ( p->mHourSize > 18 ) 93 if ( p->mHourSize > 18 )
91 p->mHourSize = 18; 94 p->mHourSize = 18;
92 QMainWindow::ToolBarDock tbd; 95 QMainWindow::ToolBarDock tbd;
93 if ( p->mToolBarHor ) { 96 if ( p->mToolBarHor ) {
94 if ( p->mToolBarUp ) 97 if ( p->mToolBarUp )
95 tbd = Bottom; 98 tbd = Bottom;
96 else 99 else
97 tbd = Top; 100 tbd = Top;
98 } 101 }
99 else { 102 else {
100 if ( p->mToolBarUp ) 103 if ( p->mToolBarUp )
101 tbd = Right; 104 tbd = Right;
102 else 105 else
103 tbd = Left; 106 tbd = Left;
104 } 107 }
105 if ( KOPrefs::instance()->mUseAppColors ) 108 if ( KOPrefs::instance()->mUseAppColors )
106 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 109 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
107 globalFlagBlockStartup = 1; 110 globalFlagBlockStartup = 1;
108 iconToolBar = new QPEToolBar( this ); 111 iconToolBar = new QPEToolBar( this );
109 addToolBar (iconToolBar , tbd ); 112 addToolBar (iconToolBar , tbd );
110 mBlockSaveFlag = false; 113 mBlockSaveFlag = false;
111 mCalendarModifiedFlag = false; 114 mCalendarModifiedFlag = false;
112 115
113 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 116 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
114 splash->setAlignment ( AlignCenter ); 117 splash->setAlignment ( AlignCenter );
115 setCentralWidget( splash ); 118 setCentralWidget( splash );
116#ifndef DESKTOP_VERSION 119#ifndef DESKTOP_VERSION
117 showMaximized(); 120 showMaximized();
118#endif 121#endif
119 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 122 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
120 setDefaultPreferences(); 123 setDefaultPreferences();
121 mCalendar = new CalendarLocal(); 124 mCalendar = new CalendarLocal();
122 mView = new CalendarView( mCalendar, this,"mCalendar " ); 125 mView = new CalendarView( mCalendar, this,"mCalendar " );
123 mView->hide(); 126 mView->hide();
124 //mView->resize(splash->size() ); 127 //mView->resize(splash->size() );
125 initActions(); 128 initActions();
126#ifndef DESKTOP_VERSION 129#ifndef DESKTOP_VERSION
127 iconToolBar->show(); 130 iconToolBar->show();
128 qApp->processEvents(); 131 qApp->processEvents();
129#endif 132#endif
130 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 133 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
131 int vh = height() ; 134 int vh = height() ;
132 int vw = width(); 135 int vw = width();
133 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 136 //qDebug("Toolbar hei %d ",iconToolBar->height() );
134 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 137 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
135 vh -= iconToolBar->height(); 138 vh -= iconToolBar->height();
136 } else { 139 } else {
137 vw -= iconToolBar->height(); 140 vw -= iconToolBar->height();
138 } 141 }
139 //mView->setMaximumSize( splash->size() ); 142 //mView->setMaximumSize( splash->size() );
140 //mView->resize( splash->size() ); 143 //mView->resize( splash->size() );
141 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 144 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
142 mView->readSettings(); 145 mView->readSettings();
143 bool oldOpened = false; 146 bool oldOpened = false;
144 bool newFile = false; 147 bool newFile = false;
145 if( !QFile::exists( defaultFileName() ) ) { 148 if( !QFile::exists( defaultFileName() ) ) {
146 QFileInfo finfo ( defaultFileName() ); 149 QFileInfo finfo ( defaultFileName() );
147 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 150 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
148 qDebug("oldfile %s ", oldFile.latin1()); 151 qDebug("oldfile %s ", oldFile.latin1());
149 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"; 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";
150 finfo.setFile( oldFile ); 153 finfo.setFile( oldFile );
151 if (finfo.exists() ) { 154 if (finfo.exists() ) {
152 KMessageBox::information( this, message); 155 KMessageBox::information( this, message);
153 mView->openCalendar( oldFile ); 156 mView->openCalendar( oldFile );
154 qApp->processEvents(); 157 qApp->processEvents();
155 } else { 158 } else {
156 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 159 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
157 finfo.setFile( oldFile ); 160 finfo.setFile( oldFile );
158 if (finfo.exists() ) { 161 if (finfo.exists() ) {
159 KMessageBox::information( this, message); 162 KMessageBox::information( this, message);
160 mView->openCalendar( oldFile ); 163 mView->openCalendar( oldFile );
161 qApp->processEvents(); 164 qApp->processEvents();
162 } 165 }
163 } 166 }
164 mView->saveCalendar( defaultFileName() ); 167 mView->saveCalendar( defaultFileName() );
165 newFile = true; 168 newFile = true;
166 } 169 }
167 170
168 QTime neededSaveTime = QDateTime::currentDateTime().time(); 171 QTime neededSaveTime = QDateTime::currentDateTime().time();
169 if ( ! oldOpened ) 172 if ( ! oldOpened )
170 mView->openCalendar( defaultFileName() ); 173 mView->openCalendar( defaultFileName() );
171 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 174 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
172 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 175 qDebug("KO: Calendar loading time: %d ms",msNeeded );
173 176
174 if ( KOPrefs::instance()->mLanguageChanged ) { 177 if ( KOPrefs::instance()->mLanguageChanged ) {
175 KOPrefs::instance()->setCategoryDefaults(); 178 KOPrefs::instance()->setCategoryDefaults();
176 int count = mView->addCategories(); 179 int count = mView->addCategories();
177 KOPrefs::instance()->mLanguageChanged = false; 180 KOPrefs::instance()->mLanguageChanged = false;
178 } 181 }
179 processIncidenceSelection( 0 ); 182 processIncidenceSelection( 0 );
180 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 183 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
181 SLOT( processIncidenceSelection( Incidence * ) ) ); 184 SLOT( processIncidenceSelection( Incidence * ) ) );
182 connect( mView, SIGNAL( modifiedChanged( bool ) ), 185 connect( mView, SIGNAL( modifiedChanged( bool ) ),
183 SLOT( slotModifiedChanged( bool ) ) ); 186 SLOT( slotModifiedChanged( bool ) ) );
184 187
185 188
186 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 189 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
187 mView->setModified( false ); 190 mView->setModified( false );
188 mBlockAtStartup = false; 191 mBlockAtStartup = false;
189 mView->setModified( false ); 192 mView->setModified( false );
190 setCentralWidget( mView ); 193 setCentralWidget( mView );
191 globalFlagBlockStartup = 0; 194 globalFlagBlockStartup = 0;
192 mView->show(); 195 mView->show();
193 delete splash; 196 delete splash;
194 if ( newFile ) 197 if ( newFile )
195 mView->updateConfig(); 198 mView->updateConfig();
196 // qApp->processEvents(); 199 // qApp->processEvents();
197 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 200 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
198 fillSyncMenu(); 201 fillSyncMenu();
199 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 202 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
200 if ( showWarning ) { 203 if ( showWarning ) {
201 KMessageBox::information( this, 204 KMessageBox::information( this,
202 "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 "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");
203 qApp->processEvents(); 206 qApp->processEvents();
204 mView->dialogManager()->showSyncOptions(); 207 mView->dialogManager()->showSyncOptions();
205 } 208 }
206 209
207 //US listen for result adressed from Ka/Pi 210 //US listen for result adressed from Ka/Pi
208#ifndef DESKTOP_VERSION 211#ifndef DESKTOP_VERSION
209 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 212 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
210#endif 213#endif
211} 214}
212MainWindow::~MainWindow() 215MainWindow::~MainWindow()
213{ 216{
214 //qDebug("MainWindow::~MainWindow() "); 217 //qDebug("MainWindow::~MainWindow() ");
215 //save toolbar location 218 //save toolbar location
216 219 delete mServerSocket;
217 delete mCalendar; 220 delete mCalendar;
218 delete KOPrefs::instance(); 221 delete KOPrefs::instance();
219 delete KIncidenceFormatter::instance(); 222 delete KIncidenceFormatter::instance();
220 223
221 224
222} 225}
223void MainWindow::showMaximized () 226void MainWindow::showMaximized ()
224{ 227{
225#ifndef DESKTOP_VERSION 228#ifndef DESKTOP_VERSION
226 if ( ! globalFlagBlockStartup ) 229 if ( ! globalFlagBlockStartup )
227 if ( mClosed ) 230 if ( mClosed )
228 mView->goToday(); 231 mView->goToday();
229#endif 232#endif
230 QWidget::showMaximized () ; 233 QWidget::showMaximized () ;
231 mClosed = false; 234 mClosed = false;
232} 235}
233void MainWindow::closeEvent( QCloseEvent* ce ) 236void MainWindow::closeEvent( QCloseEvent* ce )
234{ 237{
235 238
236 239
237 240
238 if ( ! KOPrefs::instance()->mAskForQuit ) { 241 if ( ! KOPrefs::instance()->mAskForQuit ) {
239 saveOnClose(); 242 saveOnClose();
240 mClosed = true; 243 mClosed = true;
241 ce->accept(); 244 ce->accept();
242 return; 245 return;
243 246
244 } 247 }
245 248
246 switch( QMessageBox::information( this, "KO/Pi", 249 switch( QMessageBox::information( this, "KO/Pi",
247 i18n("Do you really want\nto close KO/Pi?"), 250 i18n("Do you really want\nto close KO/Pi?"),
248 i18n("Close"), i18n("No"), 251 i18n("Close"), i18n("No"),
249 0, 0 ) ) { 252 0, 0 ) ) {
250 case 0: 253 case 0:
251 saveOnClose(); 254 saveOnClose();
252 mClosed = true; 255 mClosed = true;
253 ce->accept(); 256 ce->accept();
254 break; 257 break;
255 case 1: 258 case 1:
256 ce->ignore(); 259 ce->ignore();
257 break; 260 break;
258 case 2: 261 case 2:
259 262
260 default: 263 default:
261 break; 264 break;
262 } 265 }
263 266
264 267
265} 268}
266 269
267void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 270void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
268{ 271{
269 QDataStream stream( data, IO_ReadOnly ); 272 QDataStream stream( data, IO_ReadOnly );
270 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 273 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
271 //QString datamess; 274 //QString datamess;
272 //qDebug("message "); 275 //qDebug("message ");
273 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 276 qDebug("KO: QCOP message received: %s ", cmsg.data() );
274 277
275 if ( cmsg == "-writeFile" ) { 278 if ( cmsg == "-writeFile" ) {
276 // I made from the "-writeFile" an "-writeAlarm" 279 // I made from the "-writeFile" an "-writeAlarm"
277 mView->viewManager()->showWhatsNextView(); 280 mView->viewManager()->showWhatsNextView();
278 mCalendar->checkAlarmForIncidence( 0, true); 281 mCalendar->checkAlarmForIncidence( 0, true);
279 showMaximized(); 282 showMaximized();
280 raise(); 283 raise();
281 return; 284 return;
282 } 285 }
283 286
284 if ( cmsg == "-writeFile" ) { 287 if ( cmsg == "-writeFile" ) {
285 // I made from the "-writeFile" an "-writeAlarm" 288 // I made from the "-writeFile" an "-writeAlarm"
286 mView->viewManager()->showWhatsNextView(); 289 mView->viewManager()->showWhatsNextView();
287 mCalendar->checkAlarmForIncidence( 0, true); 290 mCalendar->checkAlarmForIncidence( 0, true);
288 showMaximized(); 291 showMaximized();
289 raise(); 292 raise();
290 return; 293 return;
291 294
292 } 295 }
293 if ( cmsg == "-writeFileSilent" ) { 296 if ( cmsg == "-writeFileSilent" ) {
294 // I made from the "-writeFile" an "-writeAlarm" 297 // I made from the "-writeFile" an "-writeAlarm"
295 // mView->viewManager()->showWhatsNextView(); 298 // mView->viewManager()->showWhatsNextView();
296 mCalendar->checkAlarmForIncidence( 0, true); 299 mCalendar->checkAlarmForIncidence( 0, true);
297 //showMaximized(); 300 //showMaximized();
298 //raise(); 301 //raise();
299 hide(); 302 hide();
300 return; 303 return;
301 } 304 }
302 if ( cmsg == "-newCountdown" ) { 305 if ( cmsg == "-newCountdown" ) {
303 qDebug("newCountdown "); 306 qDebug("newCountdown ");
304 307
305 } 308 }
306 QString msg ; 309 QString msg ;
307 QString allmsg = cmsg; 310 QString allmsg = cmsg;
308 while ( allmsg.length() > 0 ) { 311 while ( allmsg.length() > 0 ) {
309 int nextC = allmsg.find( "-", 1 ); 312 int nextC = allmsg.find( "-", 1 );
310 if ( nextC == -1 ) { 313 if ( nextC == -1 ) {
311 msg = allmsg; 314 msg = allmsg;
312 allmsg = ""; 315 allmsg = "";
313 } else{ 316 } else{
314 msg = allmsg.left( nextC ); 317 msg = allmsg.left( nextC );
315 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 318 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
316 } 319 }
317 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 320 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
318 if ( msg == "-newEvent" ) { 321 if ( msg == "-newEvent" ) {
319 mView->newEvent(); 322 mView->newEvent();
320 } 323 }
321 if ( msg == "-newTodo" ) { 324 if ( msg == "-newTodo" ) {
322 mView->newTodo(); 325 mView->newTodo();
323 326
324 } 327 }
325 if ( msg == "-showWN" ) { 328 if ( msg == "-showWN" ) {
326 mView->viewManager()->showWhatsNextView(); 329 mView->viewManager()->showWhatsNextView();
327 } 330 }
328 if ( msg == "-showTodo" ) { 331 if ( msg == "-showTodo" ) {
329 mView->viewManager()->showTodoView(); 332 mView->viewManager()->showTodoView();
330 } 333 }
331 if ( msg == "-showList" ) { 334 if ( msg == "-showList" ) {
332 mView->viewManager()->showListView(); 335 mView->viewManager()->showListView();
333 } 336 }
334 else if ( msg == "-showDay" ) { 337 else if ( msg == "-showDay" ) {
335 mView->viewManager()->showDayView(); 338 mView->viewManager()->showDayView();
336 } 339 }
337 else if ( msg == "-showWWeek" ) { 340 else if ( msg == "-showWWeek" ) {
338 mView->viewManager()->showWorkWeekView(); 341 mView->viewManager()->showWorkWeekView();
339 } 342 }
340 else if ( msg == "-ringSync" ) { 343 else if ( msg == "-ringSync" ) {
341 multiSync( false ); 344 multiSync( false );
342 } 345 }
343 else if ( msg == "-showWeek" ) { 346 else if ( msg == "-showWeek" ) {
344 mView->viewManager()->showWeekView(); 347 mView->viewManager()->showWeekView();
345 } 348 }
346 else if ( msg == "-showTodo" ) { 349 else if ( msg == "-showTodo" ) {
347 mView->viewManager()->showTodoView(); 350 mView->viewManager()->showTodoView();
348 } 351 }
349 else if ( msg == "-showJournal" ) { 352 else if ( msg == "-showJournal" ) {
350 mView->dateNavigator()->selectDates( 1 ); 353 mView->dateNavigator()->selectDates( 1 );
351 mView->dateNavigator()->selectToday(); 354 mView->dateNavigator()->selectToday();
352 mView->viewManager()->showJournalView(); 355 mView->viewManager()->showJournalView();
353 } 356 }
354 else if ( msg == "-showKO" ) { 357 else if ( msg == "-showKO" ) {
355 mView->viewManager()->showNextXView(); 358 mView->viewManager()->showNextXView();
356 } 359 }
357 else if ( msg == "-showWNext" || msg == "nextView()" ) { 360 else if ( msg == "-showWNext" || msg == "nextView()" ) {
358 mView->viewManager()->showWhatsNextView(); 361 mView->viewManager()->showWhatsNextView();
359 } 362 }
360 else if ( msg == "-showNextXView" ) { 363 else if ( msg == "-showNextXView" ) {
361 mView->viewManager()->showNextXView(); 364 mView->viewManager()->showNextXView();
362 } 365 }
363 366
364 367
365 } 368 }
366 369
367 showMaximized(); 370 showMaximized();
368 raise(); 371 raise();
369} 372}
370 373
371QPixmap MainWindow::loadPixmap( QString name ) 374QPixmap MainWindow::loadPixmap( QString name )
372{ 375{
373 return SmallIcon( name ); 376 return SmallIcon( name );
374 377
375} 378}
376void MainWindow::initActions() 379void MainWindow::initActions()
377{ 380{
378 //KOPrefs::instance()->mShowFullMenu 381 //KOPrefs::instance()->mShowFullMenu
379 iconToolBar->clear(); 382 iconToolBar->clear();
380 KOPrefs *p = KOPrefs::instance(); 383 KOPrefs *p = KOPrefs::instance();
381 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 384 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
382 385
383 QPopupMenu *viewMenu = new QPopupMenu( this ); 386 QPopupMenu *viewMenu = new QPopupMenu( this );
384 QPopupMenu *actionMenu = new QPopupMenu( this ); 387 QPopupMenu *actionMenu = new QPopupMenu( this );
385 QPopupMenu *importMenu = new QPopupMenu( this ); 388 QPopupMenu *importMenu = new QPopupMenu( this );
386 selectFilterMenu = new QPopupMenu( this ); 389 selectFilterMenu = new QPopupMenu( this );
387 selectFilterMenu->setCheckable( true ); 390 selectFilterMenu->setCheckable( true );
388 syncMenu = new QPopupMenu( this ); 391 syncMenu = new QPopupMenu( this );
389 configureAgendaMenu = new QPopupMenu( this ); 392 configureAgendaMenu = new QPopupMenu( this );
390 configureToolBarMenu = new QPopupMenu( this ); 393 configureToolBarMenu = new QPopupMenu( this );
391 QPopupMenu *helpMenu = new QPopupMenu( this ); 394 QPopupMenu *helpMenu = new QPopupMenu( this );
392 if ( KOPrefs::instance()->mShowFullMenu ) { 395 if ( KOPrefs::instance()->mShowFullMenu ) {
393 QMenuBar *menuBar1; 396 QMenuBar *menuBar1;
394 menuBar1 = menuBar(); 397 menuBar1 = menuBar();
395 menuBar1->insertItem( i18n("File"), importMenu ); 398 menuBar1->insertItem( i18n("File"), importMenu );
396 menuBar1->insertItem( i18n("View"), viewMenu ); 399 menuBar1->insertItem( i18n("View"), viewMenu );
397 menuBar1->insertItem( i18n("Actions"), actionMenu ); 400 menuBar1->insertItem( i18n("Actions"), actionMenu );
398 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 401 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
399 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 402 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
400 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 403 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
401 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 404 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
402 menuBar1->insertItem( i18n("Help"), helpMenu ); 405 menuBar1->insertItem( i18n("Help"), helpMenu );
403 } else { 406 } else {
404 QPEMenuBar *menuBar1; 407 QPEMenuBar *menuBar1;
405 menuBar1 = new QPEMenuBar( iconToolBar ); 408 menuBar1 = new QPEMenuBar( iconToolBar );
406 QPopupMenu *menuBar = new QPopupMenu( this ); 409 QPopupMenu *menuBar = new QPopupMenu( this );
407 menuBar1->insertItem( i18n("ME"), menuBar); 410 menuBar1->insertItem( i18n("ME"), menuBar);
408 menuBar->insertItem( i18n("File"), importMenu ); 411 menuBar->insertItem( i18n("File"), importMenu );
@@ -673,534 +676,562 @@ void MainWindow::initActions()
673 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 676 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
674 action->addTo( importMenu ); 677 action->addTo( importMenu );
675 connect( action, SIGNAL( activated() ), 678 connect( action, SIGNAL( activated() ),
676 this, SLOT( printCal() ) ); 679 this, SLOT( printCal() ) );
677 680
678 icon = loadPixmap( pathString + "print" ); 681 icon = loadPixmap( pathString + "print" );
679 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 682 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
680 action->addTo( importMenu ); 683 action->addTo( importMenu );
681 connect( action, SIGNAL( activated() ), 684 connect( action, SIGNAL( activated() ),
682 this, SLOT( printSel() ) ); 685 this, SLOT( printSel() ) );
683#endif 686#endif
684 importMenu->insertSeparator(); 687 importMenu->insertSeparator();
685 action = new QAction( "beam all", i18n("Save"), 0, 688 action = new QAction( "beam all", i18n("Save"), 0,
686 this ); 689 this );
687 action->addTo( importMenu ); 690 action->addTo( importMenu );
688 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 691 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
689 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 692 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
690 this ); 693 this );
691 action->addTo( importMenu ); 694 action->addTo( importMenu );
692 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 695 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
693 696
694 //menuBar->insertItem( "Configure",configureMenu ); 697 //menuBar->insertItem( "Configure",configureMenu );
695 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 698 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
696 icon = loadPixmap( "korganizer/korganizer" ); 699 icon = loadPixmap( "korganizer/korganizer" );
697 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 700 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
698 action->addTo( helpMenu ); 701 action->addTo( helpMenu );
699 connect( action, SIGNAL( activated() ), 702 connect( action, SIGNAL( activated() ),
700 SLOT( keyBindings() ) ); 703 SLOT( keyBindings() ) );
701 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 704 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
702 action->addTo( helpMenu ); 705 action->addTo( helpMenu );
703 connect( action, SIGNAL( activated() ), 706 connect( action, SIGNAL( activated() ),
704 SLOT( features() ) ); 707 SLOT( features() ) );
705 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 708 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
706 action->addTo( helpMenu ); 709 action->addTo( helpMenu );
707 connect( action, SIGNAL( activated() ), 710 connect( action, SIGNAL( activated() ),
708 SLOT( aboutAutoSaving() ) ); 711 SLOT( aboutAutoSaving() ) );
709 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 712 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
710 action->addTo( helpMenu ); 713 action->addTo( helpMenu );
711 connect( action, SIGNAL( activated() ), 714 connect( action, SIGNAL( activated() ),
712 SLOT( aboutKnownBugs() ) ); 715 SLOT( aboutKnownBugs() ) );
713 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 716 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
714 action->addTo( helpMenu ); 717 action->addTo( helpMenu );
715 connect( action, SIGNAL( activated() ), 718 connect( action, SIGNAL( activated() ),
716 SLOT( usertrans() ) ); 719 SLOT( usertrans() ) );
717 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 720 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
718 action->addTo( helpMenu ); 721 action->addTo( helpMenu );
719 connect( action, SIGNAL( activated() ), 722 connect( action, SIGNAL( activated() ),
720 SLOT( synchowto() ) ); 723 SLOT( synchowto() ) );
721 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 724 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
722 action->addTo( helpMenu ); 725 action->addTo( helpMenu );
723 connect( action, SIGNAL( activated() ), 726 connect( action, SIGNAL( activated() ),
724 SLOT( whatsNew() ) ); 727 SLOT( whatsNew() ) );
725 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 728 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
726 action->addTo( helpMenu ); 729 action->addTo( helpMenu );
727 connect( action, SIGNAL( activated() ), 730 connect( action, SIGNAL( activated() ),
728 SLOT( faq() ) ); 731 SLOT( faq() ) );
729 732
730 733
731 action = new QAction( "about", i18n("About..."), 0, this ); 734 action = new QAction( "about", i18n("About..."), 0, this );
732 action->addTo( helpMenu ); 735 action->addTo( helpMenu );
733 connect( action, SIGNAL( activated() ), 736 connect( action, SIGNAL( activated() ),
734 SLOT( about() ) ); 737 SLOT( about() ) );
735 action = new QAction( "licence", i18n("Licence..."), 0, this ); 738 action = new QAction( "licence", i18n("Licence..."), 0, this );
736 action->addTo( helpMenu ); 739 action->addTo( helpMenu );
737 connect( action, SIGNAL( activated() ), 740 connect( action, SIGNAL( activated() ),
738 SLOT( licence() ) ); 741 SLOT( licence() ) );
739 //menuBar->insertSeparator(); 742 //menuBar->insertSeparator();
740 743
741 // ****************************************************** 744 // ******************************************************
742 // menubar icons 745 // menubar icons
743 746
744 747
745 iconToolBar->setHorizontalStretchable (true ); 748 iconToolBar->setHorizontalStretchable (true );
746 //menuBar->insertItem( iconToolBar ); 749 //menuBar->insertItem( iconToolBar );
747 //xdays_action 750 //xdays_action
748 if (p-> mShowIconNewEvent) 751 if (p-> mShowIconNewEvent)
749 ne_action->addTo( iconToolBar ); 752 ne_action->addTo( iconToolBar );
750 if (p->mShowIconNewTodo ) 753 if (p->mShowIconNewTodo )
751 nt_action->addTo( iconToolBar ); 754 nt_action->addTo( iconToolBar );
752 if (p-> mShowIconSearch) 755 if (p-> mShowIconSearch)
753 search_action->addTo( iconToolBar ); 756 search_action->addTo( iconToolBar );
754 if (p-> mShowIconNext) 757 if (p-> mShowIconNext)
755 whatsnext_action->addTo( iconToolBar ); 758 whatsnext_action->addTo( iconToolBar );
756 if (p-> mShowIconNextDays) 759 if (p-> mShowIconNextDays)
757 xdays_action->addTo( iconToolBar ); 760 xdays_action->addTo( iconToolBar );
758 if (p-> mShowIconList) 761 if (p-> mShowIconList)
759 showlist_action->addTo( iconToolBar ); 762 showlist_action->addTo( iconToolBar );
760 if (p-> mShowIconDay1) 763 if (p-> mShowIconDay1)
761 day1_action->addTo( iconToolBar ); 764 day1_action->addTo( iconToolBar );
762 if (p-> mShowIconDay5) 765 if (p-> mShowIconDay5)
763 day5_action->addTo( iconToolBar ); 766 day5_action->addTo( iconToolBar );
764 if (p-> mShowIconDay7) 767 if (p-> mShowIconDay7)
765 day7_action->addTo( iconToolBar ); 768 day7_action->addTo( iconToolBar );
766 if (p-> mShowIconMonth) 769 if (p-> mShowIconMonth)
767 month_action->addTo( iconToolBar ); 770 month_action->addTo( iconToolBar );
768 if (p-> mShowIconTodoview) 771 if (p-> mShowIconTodoview)
769 todoview_action->addTo( iconToolBar ); 772 todoview_action->addTo( iconToolBar );
770 if (p-> mShowIconJournal) 773 if (p-> mShowIconJournal)
771 viewjournal_action->addTo( iconToolBar ); 774 viewjournal_action->addTo( iconToolBar );
772 icon = loadPixmap( pathString + "2leftarrowB" ); 775 icon = loadPixmap( pathString + "2leftarrowB" );
773 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); 776 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14);
774 if (p-> mShowIconBackFast) { 777 if (p-> mShowIconBackFast) {
775 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 778 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
776 connect( action, SIGNAL( activated() ), 779 connect( action, SIGNAL( activated() ),
777 mView, SLOT( goPreviousMonth() ) ); 780 mView, SLOT( goPreviousMonth() ) );
778 action->addTo( iconToolBar ); 781 action->addTo( iconToolBar );
779 } 782 }
780 icon = loadPixmap( pathString + "1leftarrowB" ); 783 icon = loadPixmap( pathString + "1leftarrowB" );
781 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); 784 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15);
782 if (p-> mShowIconBack) { 785 if (p-> mShowIconBack) {
783 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 786 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
784 connect( action, SIGNAL( activated() ), 787 connect( action, SIGNAL( activated() ),
785 mView, SLOT( goPrevious() ) ); 788 mView, SLOT( goPrevious() ) );
786 action->addTo( iconToolBar ); 789 action->addTo( iconToolBar );
787 } 790 }
788 if (p-> mShowIconToday) 791 if (p-> mShowIconToday)
789 today_action->addTo( iconToolBar ); 792 today_action->addTo( iconToolBar );
790 icon = loadPixmap( pathString + "1rightarrowB" ); 793 icon = loadPixmap( pathString + "1rightarrowB" );
791 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 794 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
792 if (p-> mShowIconForward) { 795 if (p-> mShowIconForward) {
793 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 796 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
794 connect( action, SIGNAL( activated() ), 797 connect( action, SIGNAL( activated() ),
795 mView, SLOT( goNext() ) ); 798 mView, SLOT( goNext() ) );
796 action->addTo( iconToolBar ); 799 action->addTo( iconToolBar );
797 } 800 }
798 icon = loadPixmap( pathString + "2rightarrowB" ); 801 icon = loadPixmap( pathString + "2rightarrowB" );
799 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 802 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
800 if (p-> mShowIconForwardFast) { 803 if (p-> mShowIconForwardFast) {
801 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 804 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
802 connect( action, SIGNAL( activated() ), 805 connect( action, SIGNAL( activated() ),
803 mView, SLOT( goNextMonth() ) ); 806 mView, SLOT( goNextMonth() ) );
804 action->addTo( iconToolBar ); 807 action->addTo( iconToolBar );
805 } 808 }
806 809
807 810
808 configureToolBarMenu->insertItem(i18n("What's This?"), 300); 811 configureToolBarMenu->insertItem(i18n("What's This?"), 300);
809 812
810 if (p-> mShowIconNewEvent) 813 if (p-> mShowIconNewEvent)
811 configureToolBarMenu->setItemChecked( 10, true ); 814 configureToolBarMenu->setItemChecked( 10, true );
812 if (p->mShowIconNewTodo ) 815 if (p->mShowIconNewTodo )
813 configureToolBarMenu->setItemChecked( 20, true ); 816 configureToolBarMenu->setItemChecked( 20, true );
814 if (p-> mShowIconSearch) 817 if (p-> mShowIconSearch)
815 configureToolBarMenu->setItemChecked( 120, true ); 818 configureToolBarMenu->setItemChecked( 120, true );
816 if (p-> mShowIconList) 819 if (p-> mShowIconList)
817 configureToolBarMenu->setItemChecked( 30, true ); 820 configureToolBarMenu->setItemChecked( 30, true );
818 if (p-> mShowIconDay1) 821 if (p-> mShowIconDay1)
819 configureToolBarMenu->setItemChecked( 40, true ); 822 configureToolBarMenu->setItemChecked( 40, true );
820 if (p-> mShowIconDay5) 823 if (p-> mShowIconDay5)
821 configureToolBarMenu->setItemChecked( 50, true ); 824 configureToolBarMenu->setItemChecked( 50, true );
822 if (p-> mShowIconDay7) 825 if (p-> mShowIconDay7)
823 configureToolBarMenu->setItemChecked( 60, true ); 826 configureToolBarMenu->setItemChecked( 60, true );
824 if (p-> mShowIconMonth) 827 if (p-> mShowIconMonth)
825 configureToolBarMenu->setItemChecked( 70, true ); 828 configureToolBarMenu->setItemChecked( 70, true );
826 if (p-> mShowIconTodoview) 829 if (p-> mShowIconTodoview)
827 configureToolBarMenu->setItemChecked( 80, true ); 830 configureToolBarMenu->setItemChecked( 80, true );
828 if (p-> mShowIconBackFast) 831 if (p-> mShowIconBackFast)
829 configureToolBarMenu->setItemChecked( 200, true ); 832 configureToolBarMenu->setItemChecked( 200, true );
830 if (p-> mShowIconBack) 833 if (p-> mShowIconBack)
831 configureToolBarMenu->setItemChecked( 210, true ); 834 configureToolBarMenu->setItemChecked( 210, true );
832 if (p-> mShowIconToday) 835 if (p-> mShowIconToday)
833 configureToolBarMenu->setItemChecked( 130, true ); 836 configureToolBarMenu->setItemChecked( 130, true );
834 if (p-> mShowIconForward) 837 if (p-> mShowIconForward)
835 configureToolBarMenu->setItemChecked( 220, true ); 838 configureToolBarMenu->setItemChecked( 220, true );
836 if (p-> mShowIconForwardFast) 839 if (p-> mShowIconForwardFast)
837 configureToolBarMenu->setItemChecked( 230, true ); 840 configureToolBarMenu->setItemChecked( 230, true );
838 if (p-> mShowIconNextDays) 841 if (p-> mShowIconNextDays)
839 configureToolBarMenu->setItemChecked( 100, true ); 842 configureToolBarMenu->setItemChecked( 100, true );
840 if (p-> mShowIconNext) 843 if (p-> mShowIconNext)
841 configureToolBarMenu->setItemChecked( 110, true ); 844 configureToolBarMenu->setItemChecked( 110, true );
842 if (p-> mShowIconJournal) 845 if (p-> mShowIconJournal)
843 configureToolBarMenu->setItemChecked( 90, true ); 846 configureToolBarMenu->setItemChecked( 90, true );
844 if (p-> mShowIconWhatsThis) 847 if (p-> mShowIconWhatsThis)
845 configureToolBarMenu->setItemChecked( 300, true ); 848 configureToolBarMenu->setItemChecked( 300, true );
846 849
847 QLabel* dummy = new QLabel( iconToolBar ); 850 QLabel* dummy = new QLabel( iconToolBar );
848 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 851 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
849 if (!p-> mShowIconStretch) 852 if (!p-> mShowIconStretch)
850 iconToolBar->setStretchableWidget ( dummy ) ; 853 iconToolBar->setStretchableWidget ( dummy ) ;
851 else 854 else
852 configureToolBarMenu->setItemChecked( 5, true ); 855 configureToolBarMenu->setItemChecked( 5, true );
853 if (p-> mShowIconWhatsThis) 856 if (p-> mShowIconWhatsThis)
854 QWhatsThis::whatsThisButton ( iconToolBar ); 857 QWhatsThis::whatsThisButton ( iconToolBar );
855 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 858 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
856 configureAgenda( p->mHourSize ); 859 configureAgenda( p->mHourSize );
857 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 860 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
858} 861}
859void MainWindow::fillSyncMenu() 862void MainWindow::fillSyncMenu()
860{ 863{
861 if ( syncMenu->count() ) 864 if ( syncMenu->count() )
862 syncMenu->clear(); 865 syncMenu->clear();
863 syncMenu->insertItem( i18n("Configure..."), 0 ); 866 syncMenu->insertItem( i18n("Configure..."), 0 );
864 syncMenu->insertSeparator(); 867 syncMenu->insertSeparator();
868 if ( mServerSocket == 0 ) {
869 syncMenu->insertItem( i18n("Enable Easy-Pi-Sync"), 2 );
870 } else {
871 syncMenu->insertItem( i18n("Disable Easy-Pi-Sync"), 3 );
872 }
873 syncMenu->insertSeparator();
874 syncMenu->insertItem( i18n("New Easy-Pi-Sync!"), 4 );
875 syncMenu->insertItem( i18n("Quick Easy-Pi-Sync!"), 5 );
876 syncMenu->insertSeparator();
865 syncMenu->insertItem( i18n("Multiple sync"), 1 ); 877 syncMenu->insertItem( i18n("Multiple sync"), 1 );
866 syncMenu->insertSeparator(); 878 syncMenu->insertSeparator();
867 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 879 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
868 config.setGroup("General"); 880 config.setGroup("General");
869 QStringList prof = config.readListEntry("SyncProfileNames"); 881 QStringList prof = config.readListEntry("SyncProfileNames");
870 KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 882 KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined");
871 if ( prof.count() < 3 ) { 883 if ( prof.count() < 3 ) {
872 prof.clear(); 884 prof.clear();
873 prof << i18n("Sharp_DTM"); 885 prof << i18n("Sharp_DTM");
874 prof << i18n("Local_file"); 886 prof << i18n("Local_file");
875 prof << i18n("Last_file"); 887 prof << i18n("Last_file");
876 KSyncProfile* temp = new KSyncProfile (); 888 KSyncProfile* temp = new KSyncProfile ();
877 temp->setName( prof[0] ); 889 temp->setName( prof[0] );
878 temp->writeConfig(&config); 890 temp->writeConfig(&config);
879 temp->setName( prof[1] ); 891 temp->setName( prof[1] );
880 temp->writeConfig(&config); 892 temp->writeConfig(&config);
881 temp->setName( prof[2] ); 893 temp->setName( prof[2] );
882 temp->writeConfig(&config); 894 temp->writeConfig(&config);
883 config.setGroup("General"); 895 config.setGroup("General");
884 config.writeEntry("SyncProfileNames",prof); 896 config.writeEntry("SyncProfileNames",prof);
885 config.writeEntry("ExternSyncProfiles","Sharp_DTM"); 897 config.writeEntry("ExternSyncProfiles","Sharp_DTM");
886 config.sync(); 898 config.sync();
887 delete temp; 899 delete temp;
888 } 900 }
889 KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 901 KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
890 KOPrefs::instance()->mSyncProfileNames = prof; 902 KOPrefs::instance()->mSyncProfileNames = prof;
891 int i; 903 int i;
892 for ( i = 0; i < prof.count(); ++i ) { 904 for ( i = 0; i < prof.count(); ++i ) {
893 905
894 syncMenu->insertItem( prof[i], 1000+i ); 906 syncMenu->insertItem( prof[i], 1000+i );
895 if ( i == 2 ) 907 if ( i == 2 )
896 syncMenu->insertSeparator(); 908 syncMenu->insertSeparator();
897 } 909 }
898 QDir app_dir; 910 QDir app_dir;
899 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 911 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
900 syncMenu->setItemEnabled( false , 1000 ); 912 syncMenu->setItemEnabled( false , 1000 );
901 } 913 }
902 mView->setupExternSyncProfiles(); 914 mView->setupExternSyncProfiles();
903} 915}
904 916
905int MainWindow::ringSync() 917int MainWindow::ringSync()
906{ 918{
907 int syncedProfiles = 0; 919 int syncedProfiles = 0;
908 int i; 920 int i;
909 QTime timer; 921 QTime timer;
910 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 922 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
911 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; 923 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames;
912 KSyncProfile* temp = new KSyncProfile (); 924 KSyncProfile* temp = new KSyncProfile ();
913 KOPrefs::instance()->mAskForPreferences = false; 925 KOPrefs::instance()->mAskForPreferences = false;
914 for ( i = 0; i < syncProfileNames.count(); ++i ) { 926 for ( i = 0; i < syncProfileNames.count(); ++i ) {
915 mCurrentSyncProfile = i; 927 mCurrentSyncProfile = i;
916 temp->setName(syncProfileNames[mCurrentSyncProfile]); 928 temp->setName(syncProfileNames[mCurrentSyncProfile]);
917 temp->readConfig(&config); 929 temp->readConfig(&config);
918 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { 930 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) {
919 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 931 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
920 ++syncedProfiles; 932 ++syncedProfiles;
921 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 933 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
922 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 934 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
923 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 935 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
924 KOPrefs::instance()->mWriteBackInFuture = 0; 936 KOPrefs::instance()->mWriteBackInFuture = 0;
925 if ( temp->getWriteBackFuture() ) 937 if ( temp->getWriteBackFuture() )
926 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 938 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
927 KOPrefs::instance()->mShowSyncSummary = false; 939 KOPrefs::instance()->mShowSyncSummary = false;
928 mView->setSyncDevice(syncProfileNames[i] ); 940 mView->setSyncDevice(syncProfileNames[i] );
929 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 941 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
930 if ( i == 0 ) { 942 if ( i == 0 ) {
931 syncSharp(); 943 syncSharp();
932 } else { 944 } else {
933 if ( temp->getIsLocalFileSync() ) { 945 if ( temp->getIsLocalFileSync() ) {
934 if ( syncWithFile( temp->getRemoteFileName( ), true ) ) 946 if ( syncWithFile( temp->getRemoteFileName( ), true ) )
935 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 947 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
936 } else { 948 } else {
937 if ( temp->getIsPhoneSync() ) { 949 if ( temp->getIsPhoneSync() ) {
938 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; 950 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
939 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); 951 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
940 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); 952 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
941 syncPhone(); 953 syncPhone();
942 } else 954 } else
943 syncRemote( temp, false ); 955 syncRemote( temp, false );
944 956
945 } 957 }
946 } 958 }
947 timer.start(); 959 timer.start();
948 setCaption(i18n("Multiple sync in progress ... please wait!") ); 960 setCaption(i18n("Multiple sync in progress ... please wait!") );
949 while ( timer.elapsed () < 2000 ) { 961 while ( timer.elapsed () < 2000 ) {
950 qApp->processEvents(); 962 qApp->processEvents();
951#ifndef _WIN32_ 963#ifndef _WIN32_
952 sleep (1); 964 sleep (1);
953#endif 965#endif
954 } 966 }
955 967
956 } 968 }
957 969
958 } 970 }
959 delete temp; 971 delete temp;
960 return syncedProfiles; 972 return syncedProfiles;
961} 973}
962 974
963void MainWindow::multiSync( bool askforPrefs ) 975void MainWindow::multiSync( bool askforPrefs )
964{ 976{
965 if (mBlockSaveFlag) 977 if (mBlockSaveFlag)
966 return; 978 return;
967 mBlockSaveFlag = true; 979 mBlockSaveFlag = true;
968 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 980 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
969 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 981 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
970 question, 982 question,
971 i18n("Yes"), i18n("No"), 983 i18n("Yes"), i18n("No"),
972 0, 0 ) != 0 ) { 984 0, 0 ) != 0 ) {
973 mBlockSaveFlag = false; 985 mBlockSaveFlag = false;
974 setCaption(i18n("Aborted! Nothing synced!")); 986 setCaption(i18n("Aborted! Nothing synced!"));
975 return; 987 return;
976 } 988 }
977 mView->setSyncDevice(i18n("Multiple profiles") ); 989 mView->setSyncDevice(i18n("Multiple profiles") );
978 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; 990 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs;
979 if ( askforPrefs ) { 991 if ( askforPrefs ) {
980 mView->edit_sync_options(); 992 mView->edit_sync_options();
981 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; 993 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs;
982 } 994 }
983 setCaption(i18n("Multiple sync started.") ); 995 setCaption(i18n("Multiple sync started.") );
984 qApp->processEvents(); 996 qApp->processEvents();
985 int num = ringSync() ; 997 int num = ringSync() ;
986 if ( num > 1 ) 998 if ( num > 1 )
987 ringSync(); 999 ringSync();
988 mBlockSaveFlag = false; 1000 mBlockSaveFlag = false;
989 if ( num ) 1001 if ( num )
990 save(); 1002 save();
991 if ( num ) 1003 if ( num )
992 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); 1004 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
993 else 1005 else
994 setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 1006 setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
995 return; 1007 return;
996} 1008}
997void MainWindow::slotSyncMenu( int action ) 1009void MainWindow::slotSyncMenu( int action )
998{ 1010{
999 //qDebug("syncaction %d ", action); 1011 qDebug("syncaction %d ", action);
1000 if ( action == 0 ) { 1012 if ( action == 0 ) {
1001 1013
1002 // seems to be a Qt2 event handling bug 1014 // seems to be a Qt2 event handling bug
1003 // syncmenu.clear causes a segfault at first time 1015 // syncmenu.clear causes a segfault at first time
1004 // when we call it after the main event loop, it is ok 1016 // when we call it after the main event loop, it is ok
1005 // same behaviour when calling OM/Pi via QCOP for the first time 1017 // same behaviour when calling OM/Pi via QCOP for the first time
1006 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 1018 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
1007 //confSync(); 1019 //confSync();
1008 1020
1009 return; 1021 return;
1010 } 1022 }
1011 if ( action == 1 ) { 1023 if ( action == 1 ) {
1012 multiSync( true ); 1024 multiSync( true );
1013 return; 1025 return;
1014 } 1026 }
1027 if ( action == 2 ) {
1028 enableQuick();
1029 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
1030 return;
1031 }
1032 if ( action == 3 ) {
1033 delete mServerSocket;
1034 mServerSocket = 0;
1035 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
1036 return;
1037 }
1038 if ( action == 4 ) {
1039 performQuick();
1040 return;
1041 }
1042 if ( action == 5 ) {
1043 performQuickQuick();
1044 return;
1045 }
1015 1046
1016 if (mBlockSaveFlag) 1047 if (mBlockSaveFlag)
1017 return; 1048 return;
1018 mBlockSaveFlag = true; 1049 mBlockSaveFlag = true;
1019 mCurrentSyncProfile = action - 1000 ; 1050 mCurrentSyncProfile = action - 1000 ;
1020 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); 1051 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] );
1021 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 1052 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
1022 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 1053 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
1023 KSyncProfile* temp = new KSyncProfile (); 1054 KSyncProfile* temp = new KSyncProfile ();
1024 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 1055 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
1025 temp->readConfig(&config); 1056 temp->readConfig(&config);
1026 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 1057 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
1027 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); 1058 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
1028 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 1059 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
1029 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 1060 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
1030 KOPrefs::instance()->mWriteBackInFuture = 0; 1061 KOPrefs::instance()->mWriteBackInFuture = 0;
1031 if ( temp->getWriteBackFuture() ) 1062 if ( temp->getWriteBackFuture() )
1032 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 1063 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
1033 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); 1064 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
1034 if ( action == 1000 ) { 1065 if ( action == 1000 ) {
1035 syncSharp(); 1066 syncSharp();
1036 1067
1037 } else if ( action == 1001 ) { 1068 } else if ( action == 1001 ) {
1038 syncLocalFile(); 1069 syncLocalFile();
1039 1070
1040 } else if ( action == 1002 ) { 1071 } else if ( action == 1002 ) {
1041 quickSyncLocalFile(); 1072 quickSyncLocalFile();
1042 1073
1043 } else if ( action >= 1003 ) { 1074 } else if ( action >= 1003 ) {
1044 if ( temp->getIsLocalFileSync() ) { 1075 if ( temp->getIsLocalFileSync() ) {
1045 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 1076 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
1046 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 1077 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
1047 } else { 1078 } else {
1048 if ( temp->getIsPhoneSync() ) { 1079 if ( temp->getIsPhoneSync() ) {
1049 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; 1080 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
1050 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); 1081 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
1051 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); 1082 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
1052 syncPhone(); 1083 syncPhone();
1053 } else 1084 } else
1054 syncRemote( temp ); 1085 syncRemote( temp );
1055 1086
1056 } 1087 }
1057 } 1088 }
1058 delete temp; 1089 delete temp;
1059 mBlockSaveFlag = false; 1090 mBlockSaveFlag = false;
1060} 1091}
1061void MainWindow::setDefaultPreferences() 1092void MainWindow::setDefaultPreferences()
1062{ 1093{
1063 KOPrefs *p = KOPrefs::instance(); 1094 KOPrefs *p = KOPrefs::instance();
1064 1095
1065 p->mCompactDialogs = true; 1096 p->mCompactDialogs = true;
1066 p->mConfirm = true; 1097 p->mConfirm = true;
1067 // p->mEnableQuickTodo = false; 1098 // p->mEnableQuickTodo = false;
1068} 1099}
1069 1100
1070QString MainWindow::resourcePath() 1101QString MainWindow::resourcePath()
1071{ 1102{
1072 return KGlobal::iconLoader()->iconPath(); 1103 return KGlobal::iconLoader()->iconPath();
1073} 1104}
1074 1105
1075void MainWindow::displayText( QString text ,QString cap ) 1106void MainWindow::displayText( QString text ,QString cap )
1076{ 1107{
1077 QDialog dia( this, "name", true ); ; 1108 QDialog dia( this, "name", true ); ;
1078 dia.setCaption( cap ); 1109 dia.setCaption( cap );
1079 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1110 QVBoxLayout* lay = new QVBoxLayout( &dia );
1080 lay->setSpacing( 3 ); 1111 lay->setSpacing( 3 );
1081 lay->setMargin( 3 ); 1112 lay->setMargin( 3 );
1082 QTextBrowser tb ( &dia ); 1113 QTextBrowser tb ( &dia );
1083 lay->addWidget( &tb ); 1114 lay->addWidget( &tb );
1084 tb.setText( text ); 1115 tb.setText( text );
1085#ifdef DESKTOP_VERSION 1116#ifdef DESKTOP_VERSION
1086 dia.resize( 640, 480); 1117 dia.resize( 640, 480);
1087#else 1118#else
1088 dia.showMaximized(); 1119 dia.showMaximized();
1089#endif 1120#endif
1090 dia.exec(); 1121 dia.exec();
1091} 1122}
1092void MainWindow::displayFile( QString fn, QString cap ) 1123void MainWindow::displayFile( QString fn, QString cap )
1093{ 1124{
1094 QString fileName = resourcePath() + fn; 1125 QString fileName = resourcePath() + fn;
1095 QString text; 1126 QString text;
1096 QFile file( fileName ); 1127 QFile file( fileName );
1097 if (!file.open( IO_ReadOnly ) ) { 1128 if (!file.open( IO_ReadOnly ) ) {
1098 return ; 1129 return ;
1099 1130
1100 } 1131 }
1101 QTextStream ts( &file ); 1132 QTextStream ts( &file );
1102 text = ts.read(); 1133 text = ts.read();
1103 file.close(); 1134 file.close();
1104 displayText( text, cap); 1135 displayText( text, cap);
1105} 1136}
1106void MainWindow::features() 1137void MainWindow::features()
1107{ 1138{
1108 1139
1109 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); 1140 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") );
1110} 1141}
1111 1142
1112void MainWindow::usertrans() 1143void MainWindow::usertrans()
1113{ 1144{
1114 1145
1115 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); 1146 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") );
1116} 1147}
1117#if 0 1148#if 0
1118#include <libkcal/vcalformat.h> 1149#include <libkcal/vcalformat.h>
1119#include <libkcal/event.h> 1150#include <libkcal/event.h>
1120#include <libkcal/todo.h> 1151#include <libkcal/todo.h>
1121#include <libkcal/incidence.h> 1152#include <libkcal/incidence.h>
1122#endif 1153#endif
1123void MainWindow::synchowto() 1154void MainWindow::synchowto()
1124{ 1155{
1125#if 0 1156#if 0
1126 QPtrList<Incidence> er = mCalendar->rawIncidences(); 1157 QPtrList<Incidence> er = mCalendar->rawIncidences();
1127 Incidence* inR = er.first(); 1158 Incidence* inR = er.first();
1128 VCalFormat vf; 1159 VCalFormat vf;
1129 QString strout; 1160 QString strout;
1130 while ( inR ) { 1161 while ( inR ) {
1131 if ( inR->type() == "Todo" ) 1162 if ( inR->type() == "Todo" )
1132 strout = vf.todoToString( (Todo *) inR ); 1163 strout = vf.todoToString( (Todo *) inR );
1133 if ( inR->type() == "Event" ) 1164 if ( inR->type() == "Event" )
1134 strout = vf.eventToString( (Event *) inR ); 1165 strout = vf.eventToString( (Event *) inR );
1135 qDebug("incidence: \n%s\n ente\n\n",strout.latin1() ); 1166 qDebug("incidence: \n%s\n ente\n\n",strout.latin1() );
1136 inR = er.next(); 1167 inR = er.next();
1137 } 1168 }
1138#endif 1169#endif
1139 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); 1170 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") );
1140} 1171}
1141void MainWindow::faq() 1172void MainWindow::faq()
1142{ 1173{
1143 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); 1174 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") );
1144 1175
1145} 1176}
1146void MainWindow::whatsNew() 1177void MainWindow::whatsNew()
1147{ 1178{
1148 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); 1179 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") );
1149 1180
1150} 1181}
1151void MainWindow::licence() 1182void MainWindow::licence()
1152{ 1183{
1153 KApplication::showLicence(); 1184 KApplication::showLicence();
1154 1185
1155} 1186}
1156void MainWindow::about() 1187void MainWindow::about()
1157{ 1188{
1158 QString version; 1189 QString version;
1159#include <../version> 1190#include <../version>
1160 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1191 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1161 i18n("KOrganizer/Platform-independent\n") + 1192 i18n("KOrganizer/Platform-independent\n") +
1162 "(KO/Pi) " + version + " - " + 1193 "(KO/Pi) " + version + " - " +
1163 1194
1164#ifdef DESKTOP_VERSION 1195#ifdef DESKTOP_VERSION
1165 i18n("Desktop Edition\n") + 1196 i18n("Desktop Edition\n") +
1166#else 1197#else
1167 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + 1198 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") +
1168#endif 1199#endif
1169 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") ); 1200 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") );
1170} 1201}
1171void MainWindow::keyBindings() 1202void MainWindow::keyBindings()
1172{ 1203{
1173 QString cap = i18n("Key bindings KOrganizer/Pi"); 1204 QString cap = i18n("Key bindings KOrganizer/Pi");
1174 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1205 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1175 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1206 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1176 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1207 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1177 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1208 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1178 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1209 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1179 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1210 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1180 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1211 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1181 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ 1212 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
1182 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1213 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1183 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1214 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1184 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1215 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1185 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1216 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1186 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1217 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1187 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ 1218 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
1188 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1219 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1189 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1220 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1190 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1221 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1191 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1222 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1192 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1223 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1193 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1224 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1194 i18n("<p><h3>In agenda view:</h3></p>\n") + 1225 i18n("<p><h3>In agenda view:</h3></p>\n") +
1195 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1226 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1196 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1227 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1197 i18n("<p><h3>In todo view:</h3></p>\n") + 1228 i18n("<p><h3>In todo view:</h3></p>\n") +
1198 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1229 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1199 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1230 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1200 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1231 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1201 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1232 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1202 i18n("<p><h3>In list view:</h3></p>\n") + 1233 i18n("<p><h3>In list view:</h3></p>\n") +
1203 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1234 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1204 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1235 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1205 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1236 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1206 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1237 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
@@ -1671,384 +1702,664 @@ void MainWindow::setCaptionToDates()
1671} 1702}
1672// parameter item == 0: reinit 1703// parameter item == 0: reinit
1673void MainWindow::configureAgenda( int item ) 1704void MainWindow::configureAgenda( int item )
1674{ 1705{
1675 1706
1676 KOPrefs *p = KOPrefs::instance(); 1707 KOPrefs *p = KOPrefs::instance();
1677 1708
1678 int i; 1709 int i;
1679 if ( item == 1 ) { 1710 if ( item == 1 ) {
1680 mView->toggleAllDaySize(); 1711 mView->toggleAllDaySize();
1681 return; 1712 return;
1682 } 1713 }
1683 // do not allow 4 for widgets higher than 480 1714 // do not allow 4 for widgets higher than 480
1684 // if ( QApplication::desktop()->height() > 480 ) { 1715 // if ( QApplication::desktop()->height() > 480 ) {
1685// if ( item == 4 ) 1716// if ( item == 4 )
1686// item = 6; 1717// item = 6;
1687// } 1718// }
1688 for ( i = 4; i <= 18; i= i+2 ) 1719 for ( i = 4; i <= 18; i= i+2 )
1689 configureAgendaMenu->setItemChecked( i, false ); 1720 configureAgendaMenu->setItemChecked( i, false );
1690 configureAgendaMenu->setItemChecked( item, true ); 1721 configureAgendaMenu->setItemChecked( item, true );
1691 if ( p->mHourSize == item ) 1722 if ( p->mHourSize == item )
1692 return; 1723 return;
1693 p->mHourSize=item; 1724 p->mHourSize=item;
1694 mView->viewManager()->agendaView()->updateConfig(); 1725 mView->viewManager()->agendaView()->updateConfig();
1695} 1726}
1696 1727
1697void MainWindow::saveCalendar() 1728void MainWindow::saveCalendar()
1698{ 1729{
1699 QString fn = KOPrefs::instance()->mLastSaveFile; 1730 QString fn = KOPrefs::instance()->mLastSaveFile;
1700 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 1731 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
1701 1732
1702 if ( fn == "" ) 1733 if ( fn == "" )
1703 return; 1734 return;
1704 QFileInfo info; 1735 QFileInfo info;
1705 info.setFile( fn ); 1736 info.setFile( fn );
1706 QString mes; 1737 QString mes;
1707 bool createbup = true; 1738 bool createbup = true;
1708 if ( info. exists() ) { 1739 if ( info. exists() ) {
1709 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; 1740 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
1710 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1741 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1711 i18n("Overwrite!"), i18n("Cancel"), 0, 1742 i18n("Overwrite!"), i18n("Cancel"), 0,
1712 0, 1 ); 1743 0, 1 );
1713 if ( result != 0 ) { 1744 if ( result != 0 ) {
1714 createbup = false; 1745 createbup = false;
1715 } 1746 }
1716 } 1747 }
1717 if ( createbup ) { 1748 if ( createbup ) {
1718 mView->saveCalendar( fn ); 1749 mView->saveCalendar( fn );
1719 mes = i18n("KO/Pi:Saved %1").arg(fn); 1750 mes = i18n("KO/Pi:Saved %1").arg(fn);
1720 KOPrefs::instance()->mLastSaveFile = fn; 1751 KOPrefs::instance()->mLastSaveFile = fn;
1721 setCaption(mes); 1752 setCaption(mes);
1722 } 1753 }
1723} 1754}
1724void MainWindow::loadCalendar() 1755void MainWindow::loadCalendar()
1725{ 1756{
1726 1757
1727 QString fn = KOPrefs::instance()->mLastLoadFile; 1758 QString fn = KOPrefs::instance()->mLastLoadFile;
1728 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 1759 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
1729 1760
1730 if ( fn == "" ) 1761 if ( fn == "" )
1731 return; 1762 return;
1732 QFileInfo info; 1763 QFileInfo info;
1733 info.setFile( fn ); 1764 info.setFile( fn );
1734 QString mess; 1765 QString mess;
1735 bool loadbup = true; 1766 bool loadbup = true;
1736 if ( info. exists() ) { 1767 if ( info. exists() ) {
1737 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1768 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1738 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 1769 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
1739 mess, 1770 mess,
1740 i18n("Load!"), i18n("Cancel"), 0, 1771 i18n("Load!"), i18n("Cancel"), 0,
1741 0, 1 ); 1772 0, 1 );
1742 if ( result != 0 ) { 1773 if ( result != 0 ) {
1743 loadbup = false; 1774 loadbup = false;
1744 } 1775 }
1745 } else { 1776 } else {
1746 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1777 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1747 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 1778 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
1748 0, 1 ); 1779 0, 1 );
1749 1780
1750 return; 1781 return;
1751 } 1782 }
1752 if ( loadbup ) { 1783 if ( loadbup ) {
1753 mView->openCalendar( fn ); 1784 mView->openCalendar( fn );
1754 KOPrefs::instance()->mLastLoadFile = fn; 1785 KOPrefs::instance()->mLastLoadFile = fn;
1755 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 1786 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
1756 setCaption(mess); 1787 setCaption(mess);
1757 } 1788 }
1758 1789
1759} 1790}
1760void MainWindow::quickImportIcal() 1791void MainWindow::quickImportIcal()
1761{ 1792{
1762 importFile( KOPrefs::instance()->mLastImportFile, false ); 1793 importFile( KOPrefs::instance()->mLastImportFile, false );
1763} 1794}
1764void MainWindow::importFile( QString fn, bool quick ) 1795void MainWindow::importFile( QString fn, bool quick )
1765{ 1796{
1766 QFileInfo info; 1797 QFileInfo info;
1767 info.setFile( fn ); 1798 info.setFile( fn );
1768 QString mess; 1799 QString mess;
1769 bool loadbup = true; 1800 bool loadbup = true;
1770 if ( !info. exists() ) { 1801 if ( !info. exists() ) {
1771 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 1802 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
1772 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1803 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1773 mess ); 1804 mess );
1774 return; 1805 return;
1775 } 1806 }
1776 int result = 0; 1807 int result = 0;
1777 if ( !quick ) { 1808 if ( !quick ) {
1778 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1809 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1779 result = QMessageBox::warning( this, "KO/Pi: Warning!", 1810 result = QMessageBox::warning( this, "KO/Pi: Warning!",
1780 mess, 1811 mess,
1781 "Import", "Cancel", 0, 1812 "Import", "Cancel", 0,
1782 0, 1 ); 1813 0, 1 );
1783 } 1814 }
1784 if ( result == 0 ) { 1815 if ( result == 0 ) {
1785 if ( mView->openCalendar( fn, true )) { 1816 if ( mView->openCalendar( fn, true )) {
1786 KOPrefs::instance()->mLastImportFile = fn; 1817 KOPrefs::instance()->mLastImportFile = fn;
1787 setCaption(i18n("Imported file successfully")); 1818 setCaption(i18n("Imported file successfully"));
1788 } else { 1819 } else {
1789 setCaption(i18n("Error importing file")); 1820 setCaption(i18n("Error importing file"));
1790 } 1821 }
1791 } 1822 }
1792} 1823}
1793 1824
1794void MainWindow::importIcal() 1825void MainWindow::importIcal()
1795{ 1826{
1796 1827
1797 QString fn =KOPrefs::instance()->mLastImportFile; 1828 QString fn =KOPrefs::instance()->mLastImportFile;
1798 1829
1799 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 1830 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
1800 if ( fn == "" ) 1831 if ( fn == "" )
1801 return; 1832 return;
1802 importFile( fn, true ); 1833 importFile( fn, true );
1803 1834
1804} 1835}
1805 1836
1806void MainWindow::exportVCalendar() 1837void MainWindow::exportVCalendar()
1807{ 1838{
1808 QString fn = KOPrefs::instance()->mLastVcalFile; 1839 QString fn = KOPrefs::instance()->mLastVcalFile;
1809 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 1840 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
1810 if ( fn == "" ) 1841 if ( fn == "" )
1811 return; 1842 return;
1812 QFileInfo info; 1843 QFileInfo info;
1813 info.setFile( fn ); 1844 info.setFile( fn );
1814 QString mes; 1845 QString mes;
1815 bool createbup = true; 1846 bool createbup = true;
1816 if ( info. exists() ) { 1847 if ( info. exists() ) {
1817 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 1848 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
1818 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1849 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1819 i18n("Overwrite!"), i18n("Cancel"), 0, 1850 i18n("Overwrite!"), i18n("Cancel"), 0,
1820 0, 1 ); 1851 0, 1 );
1821 if ( result != 0 ) { 1852 if ( result != 0 ) {
1822 createbup = false; 1853 createbup = false;
1823 } 1854 }
1824 } 1855 }
1825 if ( createbup ) { 1856 if ( createbup ) {
1826 if ( mView->exportVCalendar( fn ) ) { 1857 if ( mView->exportVCalendar( fn ) ) {
1827 KOPrefs::instance()->mLastVcalFile = fn; 1858 KOPrefs::instance()->mLastVcalFile = fn;
1828 if ( fn.length() > 20 ) 1859 if ( fn.length() > 20 )
1829 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 1860 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
1830 else 1861 else
1831 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 1862 mes = i18n("KO/Pi:Exported to %1").arg(fn );
1832 setCaption(mes); 1863 setCaption(mes);
1833 } 1864 }
1834 } 1865 }
1835 1866
1836} 1867}
1837#include <qpushbutton.h> 1868#include <qpushbutton.h>
1838QString MainWindow::getPassword( ) 1869QString MainWindow::getPassword( )
1839{ 1870{
1840 QString retfile = ""; 1871 QString retfile = "";
1841 QDialog dia ( this, "input-dialog", true ); 1872 QDialog dia ( this, "input-dialog", true );
1842 QLineEdit lab ( &dia ); 1873 QLineEdit lab ( &dia );
1843 lab.setEchoMode( QLineEdit::Password ); 1874 lab.setEchoMode( QLineEdit::Password );
1844 QVBoxLayout lay( &dia ); 1875 QVBoxLayout lay( &dia );
1845 lay.setMargin(7); 1876 lay.setMargin(7);
1846 lay.setSpacing(7); 1877 lay.setSpacing(7);
1847 lay.addWidget( &lab); 1878 lay.addWidget( &lab);
1848 dia.setFixedSize( 230,50 ); 1879 dia.setFixedSize( 230,50 );
1849 dia.setCaption( i18n("Enter password") ); 1880 dia.setCaption( i18n("Enter password") );
1850 QPushButton pb ( "OK", &dia); 1881 QPushButton pb ( "OK", &dia);
1851 lay.addWidget( &pb ); 1882 lay.addWidget( &pb );
1852 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 1883 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
1853 dia.show(); 1884 dia.show();
1854 int res = dia.exec(); 1885 int res = dia.exec();
1855 if ( res ) 1886 if ( res )
1856 retfile = lab.text(); 1887 retfile = lab.text();
1857 dia.hide(); 1888 dia.hide();
1858 qApp->processEvents(); 1889 qApp->processEvents();
1859 return retfile; 1890 return retfile;
1860 1891
1861} 1892}
1862 1893
1894void MainWindow::enableQuick()
1895{
1896 QString retfile = "";
1897 QDialog dia ( this, "input-dialog", true );
1898 QLineEdit lab ( &dia );
1899 QVBoxLayout lay( &dia );
1900 lab.setText( KOPrefs::instance()->mPassiveSyncPort );
1901 lay.setMargin(7);
1902 lay.setSpacing(7);
1903 QLabel label ( i18n("Port number (Default: 9197)"), &dia );
1904 lay.addWidget( &label);
1905 lay.addWidget( &lab);
1906 dia.setFixedSize( 230,80 );
1907 dia.setCaption( i18n("Enter port for Easy-Pi-Sync") );
1908 QPushButton pb ( "OK", &dia);
1909 lay.addWidget( &pb );
1910 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
1911 dia.show();
1912 int res = dia.exec();
1913 if ( res )
1914 retfile = lab.text();
1915 else
1916 return;
1917 dia.hide();
1918 qApp->processEvents();
1919 KOPrefs::instance()->mPassiveSyncPort = retfile;
1920 bool ok;
1921 Q_UINT16 port = retfile.toUInt(&ok);
1922 if ( ! ok ) {
1923 qDebug("no valid port ");
1924 return;
1925 }
1926 qDebug("port %d ", port);
1927 mServerSocket = new KServerSocket ( port ,1 );
1928 qDebug("connected ");
1929 if ( !mServerSocket->ok() ) {
1930 qWarning("Failed to bind to port %d", port);
1931 delete mServerSocket;
1932 mServerSocket = 0;
1933 return;
1934 }
1935 connect( mServerSocket, SIGNAL ( sendFile(QSocket*) ), this, SLOT ( sendFile(QSocket*) ) );
1936 connect( mServerSocket, SIGNAL ( getFile(QSocket*) ), this, SLOT ( getFile(QSocket*) ) );
1937}
1938void MainWindow::sendFile(QSocket* socket)
1939{
1940 setCaption( i18n("Received request for file") );
1941 qDebug("MainWindow::sendFile(QSocket* s) ");
1942 mSyncActionDialog = new QDialog ( this, "input-dialog", true );
1943 mSyncActionDialog->setCaption(i18n("KO/Pi - WARNING"));
1944 QLabel* label = new QLabel( i18n("Synchronizing...\nDo not use\nthis application!\n"), mSyncActionDialog );
1945 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
1946 lay->addWidget( label);
1947 lay->setMargin(7);
1948 lay->setSpacing(7);
1949 mSyncActionDialog->setFixedSize( 200,100 );
1950 mSyncActionDialog->show();
1951 qApp->processEvents();
1952 qDebug("saving ... ");
1953 save();
1954 QString fileName = defaultFileName();
1955 QFile file( fileName );
1956 if (!file.open( IO_ReadOnly ) ) {
1957 setCaption( i18n("Error open file") );
1958 delete mSyncActionDialog;
1959 mSyncActionDialog = 0;
1960 qDebug("error open cal file ");
1961 return ;
1962
1963 }
1964 setCaption( i18n("Sending file...") );
1965 QTextStream ts( &file );
1966 ts.setCodec( QTextCodec::codecForName("utf8") );
1967 QTextStream os( socket );
1968 os.setCodec( QTextCodec::codecForName("utf8") );
1969 //os.setEncoding( QTextStream::UnicodeUTF8 );
1970 while ( ! ts.atEnd() ) {
1971 os << ts.readLine() << "\n";
1972 }
1973 //os << ts.read();
1974 socket->close();
1975 file.close();
1976 setCaption( i18n("File sent. Waiting to get back synced file") );
1977 qDebug("file sent ");
1978}
1979void MainWindow::getFile(QSocket* socket)
1980{
1981 setCaption( i18n("Receiving synced file...") );
1982 qDebug("MainWindow::sendFile(QSocket* s) ");
1983
1984 QString fileName = defaultFileName();
1985 QFile file( fileName );
1986 if (!file.open( IO_WriteOnly ) ) {
1987 setCaption( i18n("Error open file") );
1988 delete mSyncActionDialog;
1989 mSyncActionDialog = 0;
1990 qDebug("error open cal file ");
1991 return ;
1992
1993 }
1994
1995 mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1996 QTextStream ts( &file );
1997 ts.setCodec( QTextCodec::codecForName("utf8") );
1998 bool first = true;
1999 while ( socket->canReadLine () || first ) {
2000 first = false;
2001 while ( socket->canReadLine () ) {
2002 ts << socket->readLine ();
2003 }
2004 socket->waitForMore ( 5000 );
2005 }
2006 setCaption( i18n("File received - reloading calendar...") );
2007 file.close();
2008 socket->close();
2009 mView->watchSavedFile();
2010 mView->openCalendar( defaultFileName() );
2011 setCaption( i18n("Easy-Pi-Sync successful!") );
2012 delete mSyncActionDialog;
2013 mSyncActionDialog = 0;
2014
2015
2016}
2017void MainWindow::endConnect()
2018{
2019 setCaption( i18n("No file received - syncing successful") );
2020 delete mSyncActionDialog;
2021 mSyncActionDialog = 0;
2022}
2023void MainWindow::performQuick()
2024{
2025 setCaption( i18n("Please input connection settings") );
2026 QString retfile = "";
2027 QDialog dia ( this, "input-dialog", true );
2028 QLineEdit lab ( &dia );
2029 QVBoxLayout lay( &dia );
2030 QLabel label ( i18n("IP address\n(Example: 192.168.0.40)"), &dia );
2031 lay.addWidget( &label);
2032 lab.setText( KOPrefs::instance()->mActiveSyncIP );
2033 lay.setMargin(7);
2034 lay.setSpacing(7);
2035 lay.addWidget( &lab);
2036 QLabel label2 ( i18n("Port number (Default: 9197)"), &dia );
2037 lay.addWidget( &label2);
2038 QLineEdit lab2 ( &dia );
2039 lab2.setText( KOPrefs::instance()->mActiveSyncPort );
2040 lay.addWidget( &lab2);
2041 dia.setFixedSize( 230,200 );
2042 dia.setCaption( i18n("Enter port for Easy-Pi-Sync ") );
2043 QPushButton pb ( "OK", &dia);
2044 lay.addWidget( &pb );
2045 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
2046 dia.show();
2047 int res = dia.exec();
2048 if ( !res ) {
2049 setCaption( i18n("Syncing cancelled!") );
2050 return;
2051 }
2052 dia.hide();
2053 KOPrefs::instance()->mActiveSyncPort = lab2.text();
2054 KOPrefs::instance()->mActiveSyncIP = lab.text();
2055 qApp->processEvents();
2056 performQuickQuick();
2057}
2058
2059void MainWindow::performQuickQuick()
2060{
2061 // setCaption( i18n("") );
2062
2063 bool ok;
2064 Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok);
2065 if ( ! ok ) {
2066 setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
2067 return;
2068 }
2069 if ( mCommandSocket )
2070 delete mCommandSocket;
2071 mCommandSocket = new QSocket( this );
2072 connect( mCommandSocket, SIGNAL(readyRead()), this, SLOT(readFileFromSocket()) );
2073 QString host = KOPrefs::instance()->mActiveSyncIP;
2074 mCommandSocket->connectToHost( host, port );
2075 QTextStream os( mCommandSocket );
2076 os.setEncoding( QTextStream::UnicodeUTF8 );
2077 os << "GET\r\n";
2078 setCaption( i18n("Sending request for remote file ...") );
2079
2080}
2081void MainWindow::readFileFromSocket()
2082{
2083 setCaption( i18n("Receiving remote file ...") );
2084 qDebug("MainWindow::readFileFromSocket() ");
2085QString fileName;
2086#ifdef _WIN32_
2087 fileName = defaultFileName() +"sync";
2088#else
2089 fileName = "/tmp/kopitempfile.ics";
2090#endif
2091 QFile file( fileName );
2092 if (!file.open( IO_WriteOnly ) ) {
2093 setCaption( i18n("Error: Cannot open temp file for write.") );
2094 qDebug("Error open calender file for writing: %s",fileName.latin1() );
2095 return ;
2096 }
2097
2098 //QTextStream os2( mCommandSocket );
2099 //os2.setEncoding( QTextStream::UnicodeUTF8 );
2100
2101 QTextStream ts( &file );
2102 ts.setCodec( QTextCodec::codecForName("utf8") );
2103 bool first = true;
2104 while ( mCommandSocket->canReadLine () || first) {
2105 first = false;
2106 while ( mCommandSocket->canReadLine () ) {
2107 ts << mCommandSocket->readLine ();
2108 }
2109 mCommandSocket->waitForMore ( 5000 );
2110 }
2111 file.close();
2112 mCommandSocket->close();
2113 delete mCommandSocket;
2114 setCaption( i18n("Remote file saved to temp file.") );
2115 mCommandSocket = 0;
2116 mCurrentSyncProfile = 2 ; // last file
2117 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] );
2118 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
2119 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
2120 KSyncProfile* temp = new KSyncProfile ();
2121 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
2122 temp->readConfig(&config);
2123 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
2124 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
2125 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
2126 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
2127 KOPrefs::instance()->mWriteBackInFuture = 0;
2128 if ( temp->getWriteBackFuture() )
2129 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
2130 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
2131
2132 setCaption( i18n("Remote file saved to temp file.") );
2133 if ( ! syncWithFile( fileName , true ) ) {
2134 setCaption( i18n("Syncing failed.") );
2135 qDebug("Syncing failed ");
2136 return;
2137 }
2138
2139 mCommandSocket = new QSocket( this );
2140 QString host = KOPrefs::instance()->mActiveSyncIP;
2141 mCommandSocket->connectToHost( KOPrefs::instance()->mActiveSyncIP, KOPrefs::instance()->mActiveSyncPort.toUInt() );
2142
2143 QFile file2( fileName );
2144 if (!file2.open( IO_ReadOnly ) ) {
2145 setCaption( i18n("Error: Cannot open temp file for read.") );
2146 qDebug("error open cal file ");
2147 return ;
2148
2149 }
2150 setCaption( i18n("Sending back synced file...") );
2151 QTextStream ts2( &file2 );
2152 ts2.setCodec( QTextCodec::codecForName("utf8") );
2153 QTextStream os2( mCommandSocket );
2154 os2.setCodec( QTextCodec::codecForName("utf8") );
2155 //os.setEncoding( QTextStream::UnicodeUTF8 );
2156 if ( KOPrefs::instance()->mWriteBackFile ) {
2157 os2 << "PUT\r\n";
2158 while ( ! ts2.atEnd() ) {
2159 os2 << ts2.readLine() << "\n";
2160 }
2161 } else {
2162 os2 << "STOP\r\n";
2163 }
2164 mCommandSocket->close();
2165 file.close();
2166 delete mCommandSocket;
2167 mCommandSocket = 0;
2168 qDebug("Syncing succesful! ");
2169 setCaption( i18n("Easy-Pi-Sync succesful!") );
2170
2171
2172}
2173
1863void MainWindow::syncLocalFile() 2174void MainWindow::syncLocalFile()
1864{ 2175{
1865 2176
1866 QString fn =KOPrefs::instance()->mLastSyncedLocalFile; 2177 QString fn =KOPrefs::instance()->mLastSyncedLocalFile;
1867 2178
1868 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 2179 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
1869 if ( fn == "" ) 2180 if ( fn == "" )
1870 return; 2181 return;
1871 //mView->setSyncDevice("local-file" ); 2182 //mView->setSyncDevice("local-file" );
1872 if ( syncWithFile( fn, false ) ) { 2183 if ( syncWithFile( fn, false ) ) {
1873 // Event* e = mView->getLastSyncEvent(); 2184 // Event* e = mView->getLastSyncEvent();
1874// e->setReadOnly( false ); 2185// e->setReadOnly( false );
1875// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 2186// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
1876// e->setReadOnly( true ); 2187// e->setReadOnly( true );
1877 } 2188 }
1878 2189
1879} 2190}
1880 2191
1881bool MainWindow::syncWithFile( QString fn , bool quick ) 2192bool MainWindow::syncWithFile( QString fn , bool quick )
1882{ 2193{
1883 bool ret = false; 2194 bool ret = false;
1884 QFileInfo info; 2195 QFileInfo info;
1885 info.setFile( fn ); 2196 info.setFile( fn );
1886 QString mess; 2197 QString mess;
1887 bool loadbup = true; 2198 bool loadbup = true;
1888 if ( !info. exists() ) { 2199 if ( !info. exists() ) {
1889 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 2200 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
1890 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2201 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1891 mess ); 2202 mess );
1892 return ret; 2203 return ret;
1893 } 2204 }
1894 int result = 0; 2205 int result = 0;
1895 if ( !quick ) { 2206 if ( !quick ) {
1896 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 2207 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1897 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2208 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1898 mess, 2209 mess,
1899 i18n("Sync"), i18n("Cancel"), 0, 2210 i18n("Sync"), i18n("Cancel"), 0,
1900 0, 1 ); 2211 0, 1 );
1901 if ( result ) 2212 if ( result )
1902 return false; 2213 return false;
1903 } 2214 }
1904 if ( KOPrefs::instance()->mAskForPreferences ) 2215 if ( KOPrefs::instance()->mAskForPreferences )
1905 mView->edit_sync_options(); 2216 mView->edit_sync_options();
1906 if ( result == 0 ) { 2217 if ( result == 0 ) {
1907 //qDebug("Now sycing ... "); 2218 //qDebug("Now sycing ... ");
1908 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) 2219 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) )
1909 setCaption( i18n("Synchronization successful") ); 2220 setCaption( i18n("Synchronization successful") );
1910 else 2221 else
1911 setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); 2222 setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
1912 if ( ! quick ) 2223 if ( ! quick )
1913 KOPrefs::instance()->mLastSyncedLocalFile = fn; 2224 KOPrefs::instance()->mLastSyncedLocalFile = fn;
1914 slotModifiedChanged( true ); 2225 slotModifiedChanged( true );
1915 } 2226 }
1916 return ret; 2227 return ret;
1917} 2228}
1918void MainWindow::quickSyncLocalFile() 2229void MainWindow::quickSyncLocalFile()
1919{ 2230{
1920 //mView->setSyncDevice("local-file" ); 2231 //mView->setSyncDevice("local-file" );
1921 //qDebug("quickSyncLocalFile() "); 2232 //qDebug("quickSyncLocalFile() ");
1922 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) { 2233 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) {
1923 // Event* e = mView->getLastSyncEvent(); 2234 // Event* e = mView->getLastSyncEvent();
1924// e->setReadOnly( false ); 2235// e->setReadOnly( false );
1925// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 2236// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
1926// e->setReadOnly( true ); 2237// e->setReadOnly( true );
1927 2238
1928 } 2239 }
1929} 2240}
1930 2241
1931void MainWindow::confSync() 2242void MainWindow::confSync()
1932{ 2243{
1933 mView->confSync(); 2244 mView->confSync();
1934 fillSyncMenu(); 2245 fillSyncMenu();
1935} 2246}
1936void MainWindow::syncRemote( KSyncProfile* prof, bool ask) 2247void MainWindow::syncRemote( KSyncProfile* prof, bool ask)
1937{ 2248{
1938 QString question; 2249 QString question;
1939 if ( ask ) { 2250 if ( ask ) {
1940 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 2251 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
1941 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 2252 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
1942 question, 2253 question,
1943 i18n("Yes"), i18n("No"), 2254 i18n("Yes"), i18n("No"),
1944 0, 0 ) != 0 ) 2255 0, 0 ) != 0 )
1945 return; 2256 return;
1946 } 2257 }
1947 QString command = prof->getPreSyncCommand(); 2258 QString command = prof->getPreSyncCommand();
1948 int fi; 2259 int fi;
1949 if ( (fi = command.find("$PWD$")) > 0 ) { 2260 if ( (fi = command.find("$PWD$")) > 0 ) {
1950 QString pwd = getPassword(); 2261 QString pwd = getPassword();
1951 command = command.left( fi )+ pwd + command.mid( fi+5 ); 2262 command = command.left( fi )+ pwd + command.mid( fi+5 );
1952 2263
1953 } 2264 }
1954 int maxlen = 30; 2265 int maxlen = 30;
1955 if ( QApplication::desktop()->width() > 320 ) 2266 if ( QApplication::desktop()->width() > 320 )
1956 maxlen += 25; 2267 maxlen += 25;
1957 setCaption ( i18n( "Copy remote file to local machine..." ) ); 2268 setCaption ( i18n( "Copy remote file to local machine..." ) );
1958 int fileSize = 0; 2269 int fileSize = 0;
1959 int result = system ( command ); 2270 int result = system ( command );
1960 // 0 : okay 2271 // 0 : okay
1961 // 256: no such file or dir 2272 // 256: no such file or dir
1962 // 2273 //
1963 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 2274 qDebug("KO: Remote copy result(0 = okay): %d ",result );
1964 if ( result != 0 ) { 2275 if ( result != 0 ) {
1965 int len = maxlen; 2276 int len = maxlen;
1966 while ( len < command.length() ) { 2277 while ( len < command.length() ) {
1967 command.insert( len , "\n" ); 2278 command.insert( len , "\n" );
1968 len += maxlen +2; 2279 len += maxlen +2;
1969 } 2280 }
1970 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; 2281 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ;
1971 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 2282 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
1972 question, 2283 question,
1973 i18n("Okay!")) ; 2284 i18n("Okay!")) ;
1974 setCaption ("KO/Pi"); 2285 setCaption ("KO/Pi");
1975 return; 2286 return;
1976 } 2287 }
1977 setCaption ( i18n( "Copying succeed." ) ); 2288 setCaption ( i18n( "Copying succeed." ) );
1978 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 2289 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
1979 if ( syncWithFile( prof->getLocalTempFile(), true ) ) { 2290 if ( syncWithFile( prof->getLocalTempFile(), true ) ) {
1980// Event* e = mView->getLastSyncEvent(); 2291// Event* e = mView->getLastSyncEvent();
1981// e->setReadOnly( false ); 2292// e->setReadOnly( false );
1982// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 2293// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
1983// e->setReadOnly( true ); 2294// e->setReadOnly( true );
1984 if ( KOPrefs::instance()->mWriteBackFile ) { 2295 if ( KOPrefs::instance()->mWriteBackFile ) {
1985 command = prof->getPostSyncCommand(); 2296 command = prof->getPostSyncCommand();
1986 int fi; 2297 int fi;
1987 if ( (fi = command.find("$PWD$")) > 0 ) { 2298 if ( (fi = command.find("$PWD$")) > 0 ) {
1988 QString pwd = getPassword(); 2299 QString pwd = getPassword();
1989 command = command.left( fi )+ pwd + command.mid( fi+5 ); 2300 command = command.left( fi )+ pwd + command.mid( fi+5 );
1990 2301
1991 } 2302 }
1992 setCaption ( i18n( "Writing back file ..." ) ); 2303 setCaption ( i18n( "Writing back file ..." ) );
1993 result = system ( command ); 2304 result = system ( command );
1994 qDebug("KO: Writing back file result: %d ", result); 2305 qDebug("KO: Writing back file result: %d ", result);
1995 if ( result != 0 ) { 2306 if ( result != 0 ) {
1996 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 2307 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
1997 return; 2308 return;
1998 } else { 2309 } else {
1999 setCaption ( i18n( "Syncronization sucessfully completed" ) ); 2310 setCaption ( i18n( "Syncronization sucessfully completed" ) );
2000 } 2311 }
2001 } 2312 }
2002 } 2313 }
2003 return; 2314 return;
2004} 2315}
2005void MainWindow::syncSSH() 2316void MainWindow::syncSSH()
2006{ 2317{
2007 // not used anymore 2318 // not used anymore
2008 QTime timer; 2319 QTime timer;
2009 timer.start(); 2320 timer.start();
2010 //qDebug("MainWindow::syncssh() "); 2321 //qDebug("MainWindow::syncssh() ");
2011 KOPrefs *p = KOPrefs::instance(); 2322 KOPrefs *p = KOPrefs::instance();
2012 QString localFile = p->mLocalTempFile; 2323 QString localFile = p->mLocalTempFile;
2013 QString remoteIP = p->mRemoteIP; 2324 QString remoteIP = p->mRemoteIP;
2014 QString remoteUser = p->mRemoteUser; 2325 QString remoteUser = p->mRemoteUser;
2015 QString remoteFile = p->mRemoteFile; 2326 QString remoteFile = p->mRemoteFile;
2016 if ( p->mUsePassWd && p->mRemotePassWd.length() > 0 ) 2327 if ( p->mUsePassWd && p->mRemotePassWd.length() > 0 )
2017 remoteUser += ":" + p->mRemotePassWd; 2328 remoteUser += ":" + p->mRemotePassWd;
2018 2329
2019 QString question = i18n("Do you really want\nto remote sync?\n \n") + 2330 QString question = i18n("Do you really want\nto remote sync?\n \n") +
2020 i18n("IP: " ) +remoteIP +"\n" + 2331 i18n("IP: " ) +remoteIP +"\n" +
2021 i18n("User: " ) + remoteUser +"\n" ; 2332 i18n("User: " ) + remoteUser +"\n" ;
2022 int maxlen = 30; 2333 int maxlen = 30;
2023 if ( QApplication::desktop()->width() > 320 ) 2334 if ( QApplication::desktop()->width() > 320 )
2024 maxlen += 25; 2335 maxlen += 25;
2025 if ( remoteFile.length() > maxlen ) 2336 if ( remoteFile.length() > maxlen )
2026 question += i18n("Remote file:\n..." ) + remoteFile.right(maxlen) +"\n"; 2337 question += i18n("Remote file:\n..." ) + remoteFile.right(maxlen) +"\n";
2027 else 2338 else
2028 question += i18n("Remote file:\n " ) + remoteFile +"\n"; 2339 question += i18n("Remote file:\n " ) + remoteFile +"\n";
2029 if ( localFile.length() > maxlen ) 2340 if ( localFile.length() > maxlen )
2030 question += i18n("Local temp file:\n..." ) + localFile.right(maxlen) +"\n"; 2341 question += i18n("Local temp file:\n..." ) + localFile.right(maxlen) +"\n";
2031 else 2342 else
2032 question += i18n("Local temp file:\n " ) + localFile +"\n"; 2343 question += i18n("Local temp file:\n " ) + localFile +"\n";
2033 2344
2034 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 2345 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
2035 question, 2346 question,
2036 i18n("Yes"), i18n("No"), 2347 i18n("Yes"), i18n("No"),
2037 0, 0 ) != 0 ) 2348 0, 0 ) != 0 )
2038 return; 2349 return;
2039 // if ( !p->mUsePassWd ) { 2350 // if ( !p->mUsePassWd ) {
2040 // QString pass = getPassword(); 2351 // QString pass = getPassword();
2041 // if ( pass.length() > 0 ) 2352 // if ( pass.length() > 0 )
2042 // remoteUser += ":" + pass; 2353 // remoteUser += ":" + pass;
2043 // } 2354 // }
2044 QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile; 2355 QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile;
2045 setCaption ( i18n( "Copy remote file to local machine..." ) ); 2356 setCaption ( i18n( "Copy remote file to local machine..." ) );
2046 int fileSize = 0; 2357 int fileSize = 0;
2047 int result = system ( command ); 2358 int result = system ( command );
2048 // 0 : okay 2359 // 0 : okay
2049 // 256: no such file or dir 2360 // 256: no such file or dir
2050 // 2361 //
2051 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 2362 qDebug("KO: Remote copy result(0 = okay): %d ",result );
2052 if ( result != 0 ) { 2363 if ( result != 0 ) {
2053 int len = maxlen; 2364 int len = maxlen;
2054 while ( len < command.length() ) { 2365 while ( len < command.length() ) {
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index 47a7a90..58081f6 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -1,123 +1,186 @@
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 <qregexp.h>
7 8
8#include <libkcal/incidence.h> 9#include <libkcal/incidence.h>
9#include "simplealarmclient.h" 10#include "simplealarmclient.h"
10 11
11class QAction; 12class QAction;
12class CalendarView; 13class CalendarView;
13class KSyncProfile; 14class KSyncProfile;
14#ifdef DESKTOP_VERSION 15#ifdef DESKTOP_VERSION
15 16
16#define QPEToolBar QToolBar 17#define QPEToolBar QToolBar
17#define QPEMenuBar QMenuBar 18#define QPEMenuBar QMenuBar
18#endif 19#endif
19class QPEToolBar; 20class QPEToolBar;
21#include <qserversocket.h>
22#include <qsocket.h>
23#include <qnetworkprotocol.h>
24
25class KServerSocket : public QServerSocket
26{
27 Q_OBJECT
28
29public:
30 KServerSocket ( Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ) :
31 QServerSocket( port, backlog, parent, name ){;};
32 void newConnection ( int socket )
33 {
34 qDebug("KServerSocket:New connection %d ", socket);
35 QSocket* s = new QSocket( this );
36 connect( s, SIGNAL(readyRead()), this, SLOT(readClient()) );
37 connect( s, SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
38 s->setSocket( socket );
39 }
40
41signals:
42 void sendFile(QSocket*);
43 void getFile(QSocket*);
44 void endConnect();
45private slots:
46 void discardClient()
47 {
48 QSocket* socket = (QSocket*)sender();
49 delete socket;
50 emit endConnect();
51 }
52 void readClient()
53 {
54 qDebug("readClient() ");
55 QSocket* socket = (QSocket*)sender();
56 if ( socket->canReadLine() ) {
57 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), socket->readLine() );
58 if ( tokens[0] == "GET" ) {
59 emit sendFile( socket );
60 }
61 if ( tokens[0] == "PUT" ) {
62 emit getFile( socket );
63 }
64 if ( tokens[0] == "STOP" ) {
65 emit endConnect();
66 }
67 }
68 }
69};
70
20 71
21namespace KCal { 72namespace KCal {
22class CalendarLocal; 73class CalendarLocal;
23} 74}
24 75
25using namespace KCal; 76using namespace KCal;
26 77
27class MainWindow : public QMainWindow 78class MainWindow : public QMainWindow
28{ 79{
29 Q_OBJECT 80 Q_OBJECT
30 public: 81 public:
31 MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); 82 MainWindow( QWidget *parent = 0, const char *name = 0, QString command = "");
32 ~MainWindow(); 83 ~MainWindow();
33 public slots: 84 public slots:
34 virtual void showMaximized (); 85 virtual void showMaximized ();
35 void configureAgenda( int ); 86 void configureAgenda( int );
36 void recieve( const QCString& msg, const QByteArray& data ); 87 void recieve( const QCString& msg, const QByteArray& data );
37 static QString defaultFileName(); 88 static QString defaultFileName();
38 static QString resourcePath(); 89 static QString resourcePath();
39 protected slots: 90 protected slots:
40 void setCaptionToDates(); 91 void setCaptionToDates();
41 int ringSync(); 92 int ringSync();
42 void multiSync( bool askforPrefs = false ); 93 void multiSync( bool askforPrefs = false );
43 void about(); 94 void about();
44 void licence(); 95 void licence();
45 void faq(); 96 void faq();
46 void usertrans(); 97 void usertrans();
47 void features(); 98 void features();
48 void synchowto(); 99 void synchowto();
49 void whatsNew(); 100 void whatsNew();
50 void keyBindings(); 101 void keyBindings();
51 void aboutAutoSaving();; 102 void aboutAutoSaving();;
52 void aboutKnownBugs(); 103 void aboutKnownBugs();
53 104
54 void processIncidenceSelection( Incidence * ); 105 void processIncidenceSelection( Incidence * );
55 106
56 void importQtopia(); 107 void importQtopia();
57 void importBday(); 108 void importBday();
58 void importOL(); 109 void importOL();
59 void importIcal(); 110 void importIcal();
60 void importFile( QString, bool ); 111 void importFile( QString, bool );
61 void quickImportIcal(); 112 void quickImportIcal();
62 113
63 void slotModifiedChanged( bool ); 114 void slotModifiedChanged( bool );
64 115
65 void save(); 116 void save();
66 void configureToolBar( int ); 117 void configureToolBar( int );
67 void printSel(); 118 void printSel();
68 void printCal(); 119 void printCal();
69 void saveCalendar(); 120 void saveCalendar();
70 void loadCalendar(); 121 void loadCalendar();
71 void exportVCalendar(); 122 void exportVCalendar();
72 void fillFilterMenu(); 123 void fillFilterMenu();
73 void selectFilter( int ); 124 void selectFilter( int );
74 125
75 void slotSyncMenu( int ); 126 void slotSyncMenu( int );
76 void syncSSH(); 127 void syncSSH();
77 void confSync(); 128 void confSync();
78 void syncSharp(); 129 void syncSharp();
79 void syncPhone(); 130 void syncPhone();
80 void syncLocalFile(); 131 void syncLocalFile();
81 bool syncWithFile( QString, bool ); 132 bool syncWithFile( QString, bool );
82 void quickSyncLocalFile(); 133 void quickSyncLocalFile();
83 134
84 135
85 protected: 136 protected:
86 void displayText( QString, QString); 137 void displayText( QString, QString);
87 void displayFile( QString, QString); 138 void displayFile( QString, QString);
88 139
89 void enableIncidenceActions( bool ); 140 void enableIncidenceActions( bool );
90 141
142 private slots:
143 void fillSyncMenu();
144 void sendFile(QSocket* s);
145 void getFile(QSocket* socket);
146 void readFileFromSocket();
147 void endConnect();
91 private: 148 private:
149 QSocket* mCommandSocket;
150 KServerSocket * mServerSocket;
92 bool mClosed; 151 bool mClosed;
93 void saveOnClose(); 152 void saveOnClose();
94 int mCurrentSyncProfile; 153 int mCurrentSyncProfile;
154 void enableQuick();
155 void performQuick();
156 void performQuickQuick();
95 void syncRemote( KSyncProfile* , bool ask = true); 157 void syncRemote( KSyncProfile* , bool ask = true);
96 void fillSyncMenu();
97 bool mFlagKeyPressed; 158 bool mFlagKeyPressed;
98 bool mBlockAtStartup; 159 bool mBlockAtStartup;
99 QPEToolBar *iconToolBar; 160 QPEToolBar *iconToolBar;
100 void initActions(); 161 void initActions();
101 void setDefaultPreferences(); 162 void setDefaultPreferences();
102 void keyPressEvent ( QKeyEvent * ) ; 163 void keyPressEvent ( QKeyEvent * ) ;
103 void keyReleaseEvent ( QKeyEvent * ) ; 164 void keyReleaseEvent ( QKeyEvent * ) ;
104 QPopupMenu *configureToolBarMenu; 165 QPopupMenu *configureToolBarMenu;
105 QPopupMenu *selectFilterMenu; 166 QPopupMenu *selectFilterMenu;
106 QPopupMenu *configureAgendaMenu, *syncMenu; 167 QPopupMenu *configureAgendaMenu, *syncMenu;
107 CalendarLocal *mCalendar; 168 CalendarLocal *mCalendar;
108 CalendarView *mView; 169 CalendarView *mView;
109 QString getPassword(); 170 QString getPassword();
110 QAction *mNewSubTodoAction; 171 QAction *mNewSubTodoAction;
111 172
112 QAction *mShowAction; 173 QAction *mShowAction;
113 QAction *mEditAction; 174 QAction *mEditAction;
114 QAction *mDeleteAction; 175 QAction *mDeleteAction;
115 void closeEvent( QCloseEvent* ce ); 176 void closeEvent( QCloseEvent* ce );
116 SimpleAlarmClient mAlarmClient; 177 SimpleAlarmClient mAlarmClient;
117 QTimer mSaveTimer; 178 QTimer mSaveTimer;
118 bool mBlockSaveFlag; 179 bool mBlockSaveFlag;
119 bool mCalendarModifiedFlag; 180 bool mCalendarModifiedFlag;
120 QPixmap loadPixmap( QString ); 181 QPixmap loadPixmap( QString );
182 QDialog * mSyncActionDialog;
121}; 183};
122 184
185
123#endif 186#endif