-rw-r--r-- | kaddressbook/kabcore.cpp | 31 | ||||
-rw-r--r-- | kaddressbook/kabcore.h | 7 | ||||
-rw-r--r-- | korganizer/koprefs.cpp | 2 | ||||
-rw-r--r-- | korganizer/koprefs.h | 3 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 321 | ||||
-rw-r--r-- | korganizer/mainwindow.h | 70 | ||||
-rw-r--r-- | libkdepim/kpimprefs.cpp | 3 | ||||
-rw-r--r-- | libkdepim/kpimprefs.h | 3 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 567 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.h | 107 |
10 files changed, 646 insertions, 468 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index d9eb391..83fede4 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1,2876 +1,2871 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressbook. | 2 | This file is part of KAddressbook. |
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2003 Tobias Koenig <tokoe@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 | /*s | 24 | /*s |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include "kabcore.h" | 31 | #include "kabcore.h" |
32 | 32 | ||
33 | #include <stdaddressbook.h> | 33 | #include <stdaddressbook.h> |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | #include <kfiledialog.h> | 35 | #include <kfiledialog.h> |
36 | #include <qtimer.h> | 36 | #include <qtimer.h> |
37 | #include <qlabel.h> | 37 | #include <qlabel.h> |
38 | #include <qregexp.h> | 38 | #include <qregexp.h> |
39 | #include <qlineedit.h> | 39 | #include <qlineedit.h> |
40 | #include <qcheckbox.h> | 40 | #include <qcheckbox.h> |
41 | #include <qpushbutton.h> | 41 | #include <qpushbutton.h> |
42 | #include <qprogressbar.h> | 42 | #include <qprogressbar.h> |
43 | #include <libkdepim/phoneaccess.h> | 43 | #include <libkdepim/phoneaccess.h> |
44 | 44 | ||
45 | #ifndef KAB_EMBEDDED | 45 | #ifndef KAB_EMBEDDED |
46 | #include <qclipboard.h> | 46 | #include <qclipboard.h> |
47 | #include <qdir.h> | 47 | #include <qdir.h> |
48 | #include <qfile.h> | 48 | #include <qfile.h> |
49 | #include <qapplicaton.h> | 49 | #include <qapplicaton.h> |
50 | #include <qprogressbar.h> | 50 | #include <qprogressbar.h> |
51 | #include <qlayout.h> | 51 | #include <qlayout.h> |
52 | #include <qregexp.h> | 52 | #include <qregexp.h> |
53 | #include <qvbox.h> | 53 | #include <qvbox.h> |
54 | #include <kabc/addresseelist.h> | 54 | #include <kabc/addresseelist.h> |
55 | #include <kabc/errorhandler.h> | 55 | #include <kabc/errorhandler.h> |
56 | #include <kabc/resource.h> | 56 | #include <kabc/resource.h> |
57 | #include <kabc/vcardconverter.h> | 57 | #include <kabc/vcardconverter.h> |
58 | #include <kapplication.h> | 58 | #include <kapplication.h> |
59 | #include <kactionclasses.h> | 59 | #include <kactionclasses.h> |
60 | #include <kcmultidialog.h> | 60 | #include <kcmultidialog.h> |
61 | #include <kdebug.h> | 61 | #include <kdebug.h> |
62 | #include <kdeversion.h> | 62 | #include <kdeversion.h> |
63 | #include <kkeydialog.h> | 63 | #include <kkeydialog.h> |
64 | #include <kmessagebox.h> | 64 | #include <kmessagebox.h> |
65 | #include <kprinter.h> | 65 | #include <kprinter.h> |
66 | #include <kprotocolinfo.h> | 66 | #include <kprotocolinfo.h> |
67 | #include <kresources/selectdialog.h> | 67 | #include <kresources/selectdialog.h> |
68 | #include <kstandarddirs.h> | 68 | #include <kstandarddirs.h> |
69 | #include <ktempfile.h> | 69 | #include <ktempfile.h> |
70 | #include <kxmlguiclient.h> | 70 | #include <kxmlguiclient.h> |
71 | #include <kaboutdata.h> | 71 | #include <kaboutdata.h> |
72 | #include <libkdepim/categoryselectdialog.h> | 72 | #include <libkdepim/categoryselectdialog.h> |
73 | 73 | ||
74 | #include "addresseeutil.h" | 74 | #include "addresseeutil.h" |
75 | #include "addresseeeditordialog.h" | 75 | #include "addresseeeditordialog.h" |
76 | #include "extensionmanager.h" | 76 | #include "extensionmanager.h" |
77 | #include "kstdaction.h" | 77 | #include "kstdaction.h" |
78 | #include "kaddressbookservice.h" | 78 | #include "kaddressbookservice.h" |
79 | #include "ldapsearchdialog.h" | 79 | #include "ldapsearchdialog.h" |
80 | #include "printing/printingwizard.h" | 80 | #include "printing/printingwizard.h" |
81 | #else // KAB_EMBEDDED | 81 | #else // KAB_EMBEDDED |
82 | 82 | ||
83 | #include <kapplication.h> | 83 | #include <kapplication.h> |
84 | #include "KDGanttMinimizeSplitter.h" | 84 | #include "KDGanttMinimizeSplitter.h" |
85 | #include "kaddressbookmain.h" | 85 | #include "kaddressbookmain.h" |
86 | #include "kactioncollection.h" | 86 | #include "kactioncollection.h" |
87 | #include "addresseedialog.h" | 87 | #include "addresseedialog.h" |
88 | //US | 88 | //US |
89 | #include <addresseeview.h> | 89 | #include <addresseeview.h> |
90 | 90 | ||
91 | #include <qapp.h> | 91 | #include <qapp.h> |
92 | #include <qmenubar.h> | 92 | #include <qmenubar.h> |
93 | //#include <qtoolbar.h> | 93 | //#include <qtoolbar.h> |
94 | #include <qmessagebox.h> | 94 | #include <qmessagebox.h> |
95 | #include <kdebug.h> | 95 | #include <kdebug.h> |
96 | #include <kiconloader.h> // needed for SmallIcon | 96 | #include <kiconloader.h> // needed for SmallIcon |
97 | #include <kresources/kcmkresources.h> | 97 | #include <kresources/kcmkresources.h> |
98 | #include <ktoolbar.h> | 98 | #include <ktoolbar.h> |
99 | 99 | ||
100 | 100 | ||
101 | //#include <qlabel.h> | 101 | //#include <qlabel.h> |
102 | 102 | ||
103 | 103 | ||
104 | #ifndef DESKTOP_VERSION | 104 | #ifndef DESKTOP_VERSION |
105 | #include <qpe/ir.h> | 105 | #include <qpe/ir.h> |
106 | #include <qpe/qpemenubar.h> | 106 | #include <qpe/qpemenubar.h> |
107 | #include <qtopia/qcopenvelope_qws.h> | 107 | #include <qtopia/qcopenvelope_qws.h> |
108 | #else | 108 | #else |
109 | 109 | ||
110 | #include <qmenubar.h> | 110 | #include <qmenubar.h> |
111 | #endif | 111 | #endif |
112 | 112 | ||
113 | #endif // KAB_EMBEDDED | 113 | #endif // KAB_EMBEDDED |
114 | #include "kcmconfigs/kcmkabconfig.h" | 114 | #include "kcmconfigs/kcmkabconfig.h" |
115 | #include "kcmconfigs/kcmkdepimconfig.h" | 115 | #include "kcmconfigs/kcmkdepimconfig.h" |
116 | #include "kpimglobalprefs.h" | 116 | #include "kpimglobalprefs.h" |
117 | #include "externalapphandler.h" | 117 | #include "externalapphandler.h" |
118 | 118 | ||
119 | 119 | ||
120 | #include <kresources/selectdialog.h> | 120 | #include <kresources/selectdialog.h> |
121 | #include <kmessagebox.h> | 121 | #include <kmessagebox.h> |
122 | 122 | ||
123 | #include <picture.h> | 123 | #include <picture.h> |
124 | #include <resource.h> | 124 | #include <resource.h> |
125 | 125 | ||
126 | //US#include <qsplitter.h> | 126 | //US#include <qsplitter.h> |
127 | #include <qmap.h> | 127 | #include <qmap.h> |
128 | #include <qdir.h> | 128 | #include <qdir.h> |
129 | #include <qfile.h> | 129 | #include <qfile.h> |
130 | #include <qvbox.h> | 130 | #include <qvbox.h> |
131 | #include <qlayout.h> | 131 | #include <qlayout.h> |
132 | #include <qclipboard.h> | 132 | #include <qclipboard.h> |
133 | #include <qtextstream.h> | 133 | #include <qtextstream.h> |
134 | 134 | ||
135 | #include <libkdepim/categoryselectdialog.h> | 135 | #include <libkdepim/categoryselectdialog.h> |
136 | #include <kabc/vcardconverter.h> | 136 | #include <kabc/vcardconverter.h> |
137 | 137 | ||
138 | 138 | ||
139 | #include "addresseeutil.h" | 139 | #include "addresseeutil.h" |
140 | #include "undocmds.h" | 140 | #include "undocmds.h" |
141 | #include "addresseeeditordialog.h" | 141 | #include "addresseeeditordialog.h" |
142 | #include "viewmanager.h" | 142 | #include "viewmanager.h" |
143 | #include "details/detailsviewcontainer.h" | 143 | #include "details/detailsviewcontainer.h" |
144 | #include "kabprefs.h" | 144 | #include "kabprefs.h" |
145 | #include "xxportmanager.h" | 145 | #include "xxportmanager.h" |
146 | #include "incsearchwidget.h" | 146 | #include "incsearchwidget.h" |
147 | #include "jumpbuttonbar.h" | 147 | #include "jumpbuttonbar.h" |
148 | #include "extensionmanager.h" | 148 | #include "extensionmanager.h" |
149 | #include "addresseeconfig.h" | 149 | #include "addresseeconfig.h" |
150 | #include <kcmultidialog.h> | 150 | #include <kcmultidialog.h> |
151 | 151 | ||
152 | #ifdef _WIN32_ | 152 | #ifdef _WIN32_ |
153 | 153 | ||
154 | #include "kaimportoldialog.h" | 154 | #include "kaimportoldialog.h" |
155 | #else | 155 | #else |
156 | #include <unistd.h> | 156 | #include <unistd.h> |
157 | #endif | 157 | #endif |
158 | // sync includes | 158 | // sync includes |
159 | #include <libkdepim/ksyncprofile.h> | 159 | #include <libkdepim/ksyncprofile.h> |
160 | #include <libkdepim/ksyncprefsdialog.h> | 160 | #include <libkdepim/ksyncprefsdialog.h> |
161 | 161 | ||
162 | class KAex2phonePrefs : public QDialog | 162 | class KAex2phonePrefs : public QDialog |
163 | { | 163 | { |
164 | public: | 164 | public: |
165 | KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : | 165 | KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : |
166 | QDialog( parent, name, true ) | 166 | QDialog( parent, name, true ) |
167 | { | 167 | { |
168 | setCaption( i18n("Export to phone options") ); | 168 | setCaption( i18n("Export to phone options") ); |
169 | QVBoxLayout* lay = new QVBoxLayout( this ); | 169 | QVBoxLayout* lay = new QVBoxLayout( this ); |
170 | lay->setSpacing( 3 ); | 170 | lay->setSpacing( 3 ); |
171 | lay->setMargin( 3 ); | 171 | lay->setMargin( 3 ); |
172 | QLabel *lab; | 172 | QLabel *lab; |
173 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); | 173 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); |
174 | lab->setAlignment (AlignHCenter ); | 174 | lab->setAlignment (AlignHCenter ); |
175 | QHBox* temphb; | 175 | QHBox* temphb; |
176 | temphb = new QHBox( this ); | 176 | temphb = new QHBox( this ); |
177 | new QLabel( i18n("I/O device: "), temphb ); | 177 | new QLabel( i18n("I/O device: "), temphb ); |
178 | mPhoneDevice = new QLineEdit( temphb); | 178 | mPhoneDevice = new QLineEdit( temphb); |
179 | lay->addWidget( temphb ); | 179 | lay->addWidget( temphb ); |
180 | temphb = new QHBox( this ); | 180 | temphb = new QHBox( this ); |
181 | new QLabel( i18n("Connection: "), temphb ); | 181 | new QLabel( i18n("Connection: "), temphb ); |
182 | mPhoneConnection = new QLineEdit( temphb); | 182 | mPhoneConnection = new QLineEdit( temphb); |
183 | lay->addWidget( temphb ); | 183 | lay->addWidget( temphb ); |
184 | temphb = new QHBox( this ); | 184 | temphb = new QHBox( this ); |
185 | new QLabel( i18n("Model(opt.): "), temphb ); | 185 | new QLabel( i18n("Model(opt.): "), temphb ); |
186 | mPhoneModel = new QLineEdit( temphb); | 186 | mPhoneModel = new QLineEdit( temphb); |
187 | lay->addWidget( temphb ); | 187 | lay->addWidget( temphb ); |
188 | mWriteToSim= new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); | 188 | mWriteToSim= new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); |
189 | lay->addWidget( mWriteToSim ); | 189 | lay->addWidget( mWriteToSim ); |
190 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); | 190 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); |
191 | lab->setAlignment (AlignHCenter ); | 191 | lab->setAlignment (AlignHCenter ); |
192 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); | 192 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); |
193 | lay->addWidget( ok ); | 193 | lay->addWidget( ok ); |
194 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 194 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
195 | lay->addWidget( cancel ); | 195 | lay->addWidget( cancel ); |
196 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 196 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
197 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 197 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
198 | resize( 220, 240 ); | 198 | resize( 220, 240 ); |
199 | 199 | ||
200 | } | 200 | } |
201 | 201 | ||
202 | public: | 202 | public: |
203 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | 203 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; |
204 | QCheckBox* mWriteToSim; | 204 | QCheckBox* mWriteToSim; |
205 | }; | 205 | }; |
206 | 206 | ||
207 | bool pasteWithNewUid = true; | 207 | bool pasteWithNewUid = true; |
208 | 208 | ||
209 | #ifdef KAB_EMBEDDED | 209 | #ifdef KAB_EMBEDDED |
210 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 210 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) |
211 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 211 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
212 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ | 212 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ |
213 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) | 213 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) |
214 | #else //KAB_EMBEDDED | 214 | #else //KAB_EMBEDDED |
215 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 215 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) |
216 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 216 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
217 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), | 217 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), |
218 | mReadWrite( readWrite ), mModified( false ) | 218 | mReadWrite( readWrite ), mModified( false ) |
219 | #endif //KAB_EMBEDDED | 219 | #endif //KAB_EMBEDDED |
220 | { | 220 | { |
221 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 221 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
222 | // syncManager->setBlockSave(false); | 222 | // syncManager->setBlockSave(false); |
223 | mExtensionBarSplitter = 0; | 223 | mExtensionBarSplitter = 0; |
224 | mIsPart = !parent->inherits( "KAddressBookMain" ); | 224 | mIsPart = !parent->inherits( "KAddressBookMain" ); |
225 | 225 | ||
226 | mAddressBook = KABC::StdAddressBook::self(); | 226 | mAddressBook = KABC::StdAddressBook::self(); |
227 | KABC::StdAddressBook::setAutomaticSave( false ); | 227 | KABC::StdAddressBook::setAutomaticSave( false ); |
228 | 228 | ||
229 | #ifndef KAB_EMBEDDED | 229 | #ifndef KAB_EMBEDDED |
230 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); | 230 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); |
231 | #endif //KAB_EMBEDDED | 231 | #endif //KAB_EMBEDDED |
232 | 232 | ||
233 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), | 233 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), |
234 | SLOT( addressBookChanged() ) ); | 234 | SLOT( addressBookChanged() ) ); |
235 | 235 | ||
236 | #if 0 | 236 | #if 0 |
237 | // LP moved to addressbook init method | 237 | // LP moved to addressbook init method |
238 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, | 238 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, |
239 | "X-Department", "KADDRESSBOOK" ); | 239 | "X-Department", "KADDRESSBOOK" ); |
240 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 240 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
241 | "X-Profession", "KADDRESSBOOK" ); | 241 | "X-Profession", "KADDRESSBOOK" ); |
242 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 242 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
243 | "X-AssistantsName", "KADDRESSBOOK" ); | 243 | "X-AssistantsName", "KADDRESSBOOK" ); |
244 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 244 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
245 | "X-ManagersName", "KADDRESSBOOK" ); | 245 | "X-ManagersName", "KADDRESSBOOK" ); |
246 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 246 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
247 | "X-SpousesName", "KADDRESSBOOK" ); | 247 | "X-SpousesName", "KADDRESSBOOK" ); |
248 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, | 248 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, |
249 | "X-Office", "KADDRESSBOOK" ); | 249 | "X-Office", "KADDRESSBOOK" ); |
250 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 250 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
251 | "X-IMAddress", "KADDRESSBOOK" ); | 251 | "X-IMAddress", "KADDRESSBOOK" ); |
252 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 252 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
253 | "X-Anniversary", "KADDRESSBOOK" ); | 253 | "X-Anniversary", "KADDRESSBOOK" ); |
254 | 254 | ||
255 | //US added this field to become compatible with Opie/qtopia addressbook | 255 | //US added this field to become compatible with Opie/qtopia addressbook |
256 | // values can be "female" or "male" or "". An empty field represents undefined. | 256 | // values can be "female" or "male" or "". An empty field represents undefined. |
257 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 257 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
258 | "X-Gender", "KADDRESSBOOK" ); | 258 | "X-Gender", "KADDRESSBOOK" ); |
259 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, | 259 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, |
260 | "X-Children", "KADDRESSBOOK" ); | 260 | "X-Children", "KADDRESSBOOK" ); |
261 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 261 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
262 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 262 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
263 | #endif | 263 | #endif |
264 | initGUI(); | 264 | initGUI(); |
265 | 265 | ||
266 | mIncSearchWidget->setFocus(); | 266 | mIncSearchWidget->setFocus(); |
267 | 267 | ||
268 | 268 | ||
269 | connect( mViewManager, SIGNAL( selected( const QString& ) ), | 269 | connect( mViewManager, SIGNAL( selected( const QString& ) ), |
270 | SLOT( setContactSelected( const QString& ) ) ); | 270 | SLOT( setContactSelected( const QString& ) ) ); |
271 | connect( mViewManager, SIGNAL( executed( const QString& ) ), | 271 | connect( mViewManager, SIGNAL( executed( const QString& ) ), |
272 | SLOT( executeContact( const QString& ) ) ); | 272 | SLOT( executeContact( const QString& ) ) ); |
273 | 273 | ||
274 | connect( mViewManager, SIGNAL( deleteRequest( ) ), | 274 | connect( mViewManager, SIGNAL( deleteRequest( ) ), |
275 | SLOT( deleteContacts( ) ) ); | 275 | SLOT( deleteContacts( ) ) ); |
276 | connect( mViewManager, SIGNAL( modified() ), | 276 | connect( mViewManager, SIGNAL( modified() ), |
277 | SLOT( setModified() ) ); | 277 | SLOT( setModified() ) ); |
278 | 278 | ||
279 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); | 279 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); |
280 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); | 280 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); |
281 | 281 | ||
282 | connect( mXXPortManager, SIGNAL( modified() ), | 282 | connect( mXXPortManager, SIGNAL( modified() ), |
283 | SLOT( setModified() ) ); | 283 | SLOT( setModified() ) ); |
284 | 284 | ||
285 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), | 285 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), |
286 | SLOT( incrementalSearch( const QString& ) ) ); | 286 | SLOT( incrementalSearch( const QString& ) ) ); |
287 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), | 287 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), |
288 | mJumpButtonBar, SLOT( recreateButtons() ) ); | 288 | mJumpButtonBar, SLOT( recreateButtons() ) ); |
289 | 289 | ||
290 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), | 290 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), |
291 | SLOT( sendMail( const QString& ) ) ); | 291 | SLOT( sendMail( const QString& ) ) ); |
292 | 292 | ||
293 | 293 | ||
294 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); | 294 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); |
295 | connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); | 295 | connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); |
296 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); | 296 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); |
297 | 297 | ||
298 | 298 | ||
299 | #ifndef KAB_EMBEDDED | 299 | #ifndef KAB_EMBEDDED |
300 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), | 300 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), |
301 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); | 301 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); |
302 | 302 | ||
303 | connect( mDetails, SIGNAL( browse( const QString& ) ), | 303 | connect( mDetails, SIGNAL( browse( const QString& ) ), |
304 | SLOT( browse( const QString& ) ) ); | 304 | SLOT( browse( const QString& ) ) ); |
305 | 305 | ||
306 | 306 | ||
307 | mAddressBookService = new KAddressBookService( this ); | 307 | mAddressBookService = new KAddressBookService( this ); |
308 | 308 | ||
309 | #endif //KAB_EMBEDDED | 309 | #endif //KAB_EMBEDDED |
310 | mEditorDialog = 0; | 310 | mEditorDialog = 0; |
311 | createAddresseeEditorDialog( this ); | 311 | createAddresseeEditorDialog( this ); |
312 | setModified( false ); | 312 | setModified( false ); |
313 | } | 313 | } |
314 | 314 | ||
315 | KABCore::~KABCore() | 315 | KABCore::~KABCore() |
316 | { | 316 | { |
317 | // save(); | 317 | // save(); |
318 | //saveSettings(); | 318 | //saveSettings(); |
319 | //KABPrefs::instance()->writeConfig(); | 319 | //KABPrefs::instance()->writeConfig(); |
320 | delete AddresseeConfig::instance(); | 320 | delete AddresseeConfig::instance(); |
321 | mAddressBook = 0; | 321 | mAddressBook = 0; |
322 | KABC::StdAddressBook::close(); | 322 | KABC::StdAddressBook::close(); |
323 | 323 | ||
324 | delete syncManager; | 324 | delete syncManager; |
325 | } | 325 | } |
326 | 326 | ||
327 | void KABCore::restoreSettings() | 327 | void KABCore::restoreSettings() |
328 | { | 328 | { |
329 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; | 329 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; |
330 | 330 | ||
331 | bool state; | 331 | bool state; |
332 | 332 | ||
333 | if (mMultipleViewsAtOnce) | 333 | if (mMultipleViewsAtOnce) |
334 | state = KABPrefs::instance()->mDetailsPageVisible; | 334 | state = KABPrefs::instance()->mDetailsPageVisible; |
335 | else | 335 | else |
336 | state = false; | 336 | state = false; |
337 | 337 | ||
338 | mActionDetails->setChecked( state ); | 338 | mActionDetails->setChecked( state ); |
339 | setDetailsVisible( state ); | 339 | setDetailsVisible( state ); |
340 | 340 | ||
341 | state = KABPrefs::instance()->mJumpButtonBarVisible; | 341 | state = KABPrefs::instance()->mJumpButtonBarVisible; |
342 | 342 | ||
343 | mActionJumpBar->setChecked( state ); | 343 | mActionJumpBar->setChecked( state ); |
344 | setJumpButtonBarVisible( state ); | 344 | setJumpButtonBarVisible( state ); |
345 | /*US | 345 | /*US |
346 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 346 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
347 | if ( splitterSize.count() == 0 ) { | 347 | if ( splitterSize.count() == 0 ) { |
348 | splitterSize.append( width() / 2 ); | 348 | splitterSize.append( width() / 2 ); |
349 | splitterSize.append( width() / 2 ); | 349 | splitterSize.append( width() / 2 ); |
350 | } | 350 | } |
351 | mMiniSplitter->setSizes( splitterSize ); | 351 | mMiniSplitter->setSizes( splitterSize ); |
352 | if ( mExtensionBarSplitter ) { | 352 | if ( mExtensionBarSplitter ) { |
353 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 353 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
354 | if ( splitterSize.count() == 0 ) { | 354 | if ( splitterSize.count() == 0 ) { |
355 | splitterSize.append( width() / 2 ); | 355 | splitterSize.append( width() / 2 ); |
356 | splitterSize.append( width() / 2 ); | 356 | splitterSize.append( width() / 2 ); |
357 | } | 357 | } |
358 | mExtensionBarSplitter->setSizes( splitterSize ); | 358 | mExtensionBarSplitter->setSizes( splitterSize ); |
359 | 359 | ||
360 | } | 360 | } |
361 | */ | 361 | */ |
362 | mViewManager->restoreSettings(); | 362 | mViewManager->restoreSettings(); |
363 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 363 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
364 | mExtensionManager->restoreSettings(); | 364 | mExtensionManager->restoreSettings(); |
365 | #ifdef DESKTOP_VERSION | 365 | #ifdef DESKTOP_VERSION |
366 | int wid = width(); | 366 | int wid = width(); |
367 | if ( wid < 10 ) | 367 | if ( wid < 10 ) |
368 | wid = 400; | 368 | wid = 400; |
369 | #else | 369 | #else |
370 | int wid = QApplication::desktop()->width(); | 370 | int wid = QApplication::desktop()->width(); |
371 | if ( wid < 640 ) | 371 | if ( wid < 640 ) |
372 | wid = QApplication::desktop()->height(); | 372 | wid = QApplication::desktop()->height(); |
373 | #endif | 373 | #endif |
374 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; | 374 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; |
375 | if ( true /*splitterSize.count() == 0*/ ) { | 375 | if ( true /*splitterSize.count() == 0*/ ) { |
376 | splitterSize.append( wid / 2 ); | 376 | splitterSize.append( wid / 2 ); |
377 | splitterSize.append( wid / 2 ); | 377 | splitterSize.append( wid / 2 ); |
378 | } | 378 | } |
379 | mMiniSplitter->setSizes( splitterSize ); | 379 | mMiniSplitter->setSizes( splitterSize ); |
380 | if ( mExtensionBarSplitter ) { | 380 | if ( mExtensionBarSplitter ) { |
381 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 381 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
382 | if ( true /*splitterSize.count() == 0*/ ) { | 382 | if ( true /*splitterSize.count() == 0*/ ) { |
383 | splitterSize.append( wid / 2 ); | 383 | splitterSize.append( wid / 2 ); |
384 | splitterSize.append( wid / 2 ); | 384 | splitterSize.append( wid / 2 ); |
385 | } | 385 | } |
386 | mExtensionBarSplitter->setSizes( splitterSize ); | 386 | mExtensionBarSplitter->setSizes( splitterSize ); |
387 | 387 | ||
388 | } | 388 | } |
389 | 389 | ||
390 | 390 | ||
391 | } | 391 | } |
392 | 392 | ||
393 | void KABCore::saveSettings() | 393 | void KABCore::saveSettings() |
394 | { | 394 | { |
395 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | 395 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); |
396 | if ( mExtensionBarSplitter ) | 396 | if ( mExtensionBarSplitter ) |
397 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 397 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
398 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | 398 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); |
399 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); | 399 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); |
400 | #ifndef KAB_EMBEDDED | 400 | #ifndef KAB_EMBEDDED |
401 | 401 | ||
402 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 402 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
403 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | 403 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); |
404 | #endif //KAB_EMBEDDED | 404 | #endif //KAB_EMBEDDED |
405 | mExtensionManager->saveSettings(); | 405 | mExtensionManager->saveSettings(); |
406 | mViewManager->saveSettings(); | 406 | mViewManager->saveSettings(); |
407 | 407 | ||
408 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 408 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
409 | } | 409 | } |
410 | 410 | ||
411 | KABC::AddressBook *KABCore::addressBook() const | 411 | KABC::AddressBook *KABCore::addressBook() const |
412 | { | 412 | { |
413 | return mAddressBook; | 413 | return mAddressBook; |
414 | } | 414 | } |
415 | 415 | ||
416 | KConfig *KABCore::config() | 416 | KConfig *KABCore::config() |
417 | { | 417 | { |
418 | #ifndef KAB_EMBEDDED | 418 | #ifndef KAB_EMBEDDED |
419 | return KABPrefs::instance()->config(); | 419 | return KABPrefs::instance()->config(); |
420 | #else //KAB_EMBEDDED | 420 | #else //KAB_EMBEDDED |
421 | return KABPrefs::instance()->getConfig(); | 421 | return KABPrefs::instance()->getConfig(); |
422 | #endif //KAB_EMBEDDED | 422 | #endif //KAB_EMBEDDED |
423 | } | 423 | } |
424 | 424 | ||
425 | KActionCollection *KABCore::actionCollection() const | 425 | KActionCollection *KABCore::actionCollection() const |
426 | { | 426 | { |
427 | return mGUIClient->actionCollection(); | 427 | return mGUIClient->actionCollection(); |
428 | } | 428 | } |
429 | 429 | ||
430 | KABC::Field *KABCore::currentSearchField() const | 430 | KABC::Field *KABCore::currentSearchField() const |
431 | { | 431 | { |
432 | if (mIncSearchWidget) | 432 | if (mIncSearchWidget) |
433 | return mIncSearchWidget->currentField(); | 433 | return mIncSearchWidget->currentField(); |
434 | else | 434 | else |
435 | return 0; | 435 | return 0; |
436 | } | 436 | } |
437 | 437 | ||
438 | QStringList KABCore::selectedUIDs() const | 438 | QStringList KABCore::selectedUIDs() const |
439 | { | 439 | { |
440 | return mViewManager->selectedUids(); | 440 | return mViewManager->selectedUids(); |
441 | } | 441 | } |
442 | 442 | ||
443 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 443 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
444 | { | 444 | { |
445 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 445 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
446 | 446 | ||
447 | QPtrList<KRES::Resource> kresResources; | 447 | QPtrList<KRES::Resource> kresResources; |
448 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 448 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
449 | KABC::Resource *resource; | 449 | KABC::Resource *resource; |
450 | while ( ( resource = resIt.current() ) != 0 ) { | 450 | while ( ( resource = resIt.current() ) != 0 ) { |
451 | ++resIt; | 451 | ++resIt; |
452 | if ( !resource->readOnly() ) { | 452 | if ( !resource->readOnly() ) { |
453 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 453 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
454 | if ( res ) | 454 | if ( res ) |
455 | kresResources.append( res ); | 455 | kresResources.append( res ); |
456 | } | 456 | } |
457 | } | 457 | } |
458 | 458 | ||
459 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 459 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
460 | return static_cast<KABC::Resource*>( res ); | 460 | return static_cast<KABC::Resource*>( res ); |
461 | } | 461 | } |
462 | 462 | ||
463 | #ifndef KAB_EMBEDDED | 463 | #ifndef KAB_EMBEDDED |
464 | KAboutData *KABCore::createAboutData() | 464 | KAboutData *KABCore::createAboutData() |
465 | #else //KAB_EMBEDDED | 465 | #else //KAB_EMBEDDED |
466 | void KABCore::createAboutData() | 466 | void KABCore::createAboutData() |
467 | #endif //KAB_EMBEDDED | 467 | #endif //KAB_EMBEDDED |
468 | { | 468 | { |
469 | #ifndef KAB_EMBEDDED | 469 | #ifndef KAB_EMBEDDED |
470 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), | 470 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), |
471 | "3.1", I18N_NOOP( "The KDE Address Book" ), | 471 | "3.1", I18N_NOOP( "The KDE Address Book" ), |
472 | KAboutData::License_GPL_V2, | 472 | KAboutData::License_GPL_V2, |
473 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); | 473 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); |
474 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); | 474 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); |
475 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); | 475 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); |
476 | about->addAuthor( "Cornelius Schumacher", | 476 | about->addAuthor( "Cornelius Schumacher", |
477 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | 477 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), |
478 | "schumacher@kde.org" ); | 478 | "schumacher@kde.org" ); |
479 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | 479 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), |
480 | "mpilone@slac.com" ); | 480 | "mpilone@slac.com" ); |
481 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | 481 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); |
482 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | 482 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); |
483 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | 483 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), |
484 | "michel@klaralvdalens-datakonsult.se" ); | 484 | "michel@klaralvdalens-datakonsult.se" ); |
485 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | 485 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), |
486 | "hansen@kde.org" ); | 486 | "hansen@kde.org" ); |
487 | 487 | ||
488 | return about; | 488 | return about; |
489 | #endif //KAB_EMBEDDED | 489 | #endif //KAB_EMBEDDED |
490 | 490 | ||
491 | QString version; | 491 | QString version; |
492 | #include <../version> | 492 | #include <../version> |
493 | QMessageBox::about( this, "About KAddressbook/Pi", | 493 | QMessageBox::about( this, "About KAddressbook/Pi", |
494 | "KAddressbook/Platform-independent\n" | 494 | "KAddressbook/Platform-independent\n" |
495 | "(KA/Pi) " +version + " - " + | 495 | "(KA/Pi) " +version + " - " + |
496 | #ifdef DESKTOP_VERSION | 496 | #ifdef DESKTOP_VERSION |
497 | "Desktop Edition\n" | 497 | "Desktop Edition\n" |
498 | #else | 498 | #else |
499 | "PDA-Edition\n" | 499 | "PDA-Edition\n" |
500 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 500 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
501 | #endif | 501 | #endif |
502 | 502 | ||
503 | "(c) 2004 Ulf Schenk\n" | 503 | "(c) 2004 Ulf Schenk\n" |
504 | "(c) 2004 Lutz Rogowski\n" | 504 | "(c) 2004 Lutz Rogowski\n" |
505 | "(c) 1997-2003, The KDE PIM Team\n" | 505 | "(c) 1997-2003, The KDE PIM Team\n" |
506 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" | 506 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" |
507 | "Don Sanders Original author\n" | 507 | "Don Sanders Original author\n" |
508 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" | 508 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" |
509 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" | 509 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" |
510 | "Greg Stern DCOP interface\n" | 510 | "Greg Stern DCOP interface\n" |
511 | "Mark Westcot Contact pinning\n" | 511 | "Mark Westcot Contact pinning\n" |
512 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" | 512 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" |
513 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" | 513 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" |
514 | #ifdef _WIN32_ | 514 | #ifdef _WIN32_ |
515 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" | 515 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" |
516 | #endif | 516 | #endif |
517 | ); | 517 | ); |
518 | } | 518 | } |
519 | 519 | ||
520 | void KABCore::setContactSelected( const QString &uid ) | 520 | void KABCore::setContactSelected( const QString &uid ) |
521 | { | 521 | { |
522 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 522 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
523 | if ( !mDetails->isHidden() ) | 523 | if ( !mDetails->isHidden() ) |
524 | mDetails->setAddressee( addr ); | 524 | mDetails->setAddressee( addr ); |
525 | 525 | ||
526 | if ( !addr.isEmpty() ) { | 526 | if ( !addr.isEmpty() ) { |
527 | emit contactSelected( addr.formattedName() ); | 527 | emit contactSelected( addr.formattedName() ); |
528 | KABC::Picture pic = addr.photo(); | 528 | KABC::Picture pic = addr.photo(); |
529 | if ( pic.isIntern() ) { | 529 | if ( pic.isIntern() ) { |
530 | //US emit contactSelected( pic.data() ); | 530 | //US emit contactSelected( pic.data() ); |
531 | //US instead use: | 531 | //US instead use: |
532 | QPixmap px; | 532 | QPixmap px; |
533 | if (pic.data().isNull() != true) | 533 | if (pic.data().isNull() != true) |
534 | { | 534 | { |
535 | px.convertFromImage(pic.data()); | 535 | px.convertFromImage(pic.data()); |
536 | } | 536 | } |
537 | 537 | ||
538 | emit contactSelected( px ); | 538 | emit contactSelected( px ); |
539 | } | 539 | } |
540 | } | 540 | } |
541 | 541 | ||
542 | 542 | ||
543 | mExtensionManager->setSelectionChanged(); | 543 | mExtensionManager->setSelectionChanged(); |
544 | 544 | ||
545 | // update the actions | 545 | // update the actions |
546 | bool selected = !uid.isEmpty(); | 546 | bool selected = !uid.isEmpty(); |
547 | 547 | ||
548 | if ( mReadWrite ) { | 548 | if ( mReadWrite ) { |
549 | mActionCut->setEnabled( selected ); | 549 | mActionCut->setEnabled( selected ); |
550 | mActionPaste->setEnabled( selected ); | 550 | mActionPaste->setEnabled( selected ); |
551 | } | 551 | } |
552 | 552 | ||
553 | mActionCopy->setEnabled( selected ); | 553 | mActionCopy->setEnabled( selected ); |
554 | mActionDelete->setEnabled( selected ); | 554 | mActionDelete->setEnabled( selected ); |
555 | mActionEditAddressee->setEnabled( selected ); | 555 | mActionEditAddressee->setEnabled( selected ); |
556 | mActionMail->setEnabled( selected ); | 556 | mActionMail->setEnabled( selected ); |
557 | mActionMailVCard->setEnabled( selected ); | 557 | mActionMailVCard->setEnabled( selected ); |
558 | //if (mActionBeam) | 558 | //if (mActionBeam) |
559 | //mActionBeam->setEnabled( selected ); | 559 | //mActionBeam->setEnabled( selected ); |
560 | 560 | ||
561 | if (mActionBeamVCard) | 561 | if (mActionBeamVCard) |
562 | mActionBeamVCard->setEnabled( selected ); | 562 | mActionBeamVCard->setEnabled( selected ); |
563 | 563 | ||
564 | mActionExport2phone->setEnabled( selected ); | 564 | mActionExport2phone->setEnabled( selected ); |
565 | mActionWhoAmI->setEnabled( selected ); | 565 | mActionWhoAmI->setEnabled( selected ); |
566 | mActionCategories->setEnabled( selected ); | 566 | mActionCategories->setEnabled( selected ); |
567 | } | 567 | } |
568 | 568 | ||
569 | void KABCore::sendMail() | 569 | void KABCore::sendMail() |
570 | { | 570 | { |
571 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 571 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
572 | } | 572 | } |
573 | 573 | ||
574 | void KABCore::sendMail( const QString& emaillist ) | 574 | void KABCore::sendMail( const QString& emaillist ) |
575 | { | 575 | { |
576 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " | 576 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " |
577 | if (emaillist.contains(",") > 0) | 577 | if (emaillist.contains(",") > 0) |
578 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); | 578 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); |
579 | else | 579 | else |
580 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); | 580 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); |
581 | } | 581 | } |
582 | 582 | ||
583 | 583 | ||
584 | 584 | ||
585 | void KABCore::mailVCard() | 585 | void KABCore::mailVCard() |
586 | { | 586 | { |
587 | QStringList uids = mViewManager->selectedUids(); | 587 | QStringList uids = mViewManager->selectedUids(); |
588 | if ( !uids.isEmpty() ) | 588 | if ( !uids.isEmpty() ) |
589 | mailVCard( uids ); | 589 | mailVCard( uids ); |
590 | } | 590 | } |
591 | 591 | ||
592 | void KABCore::mailVCard( const QStringList& uids ) | 592 | void KABCore::mailVCard( const QStringList& uids ) |
593 | { | 593 | { |
594 | QStringList urls; | 594 | QStringList urls; |
595 | 595 | ||
596 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 596 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
597 | 597 | ||
598 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); | 598 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); |
599 | 599 | ||
600 | 600 | ||
601 | 601 | ||
602 | QDir().mkdir( dirName, true ); | 602 | QDir().mkdir( dirName, true ); |
603 | 603 | ||
604 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 604 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
605 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 605 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
606 | 606 | ||
607 | if ( a.isEmpty() ) | 607 | if ( a.isEmpty() ) |
608 | continue; | 608 | continue; |
609 | 609 | ||
610 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 610 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
611 | 611 | ||
612 | QString fileName = dirName + "/" + name; | 612 | QString fileName = dirName + "/" + name; |
613 | 613 | ||
614 | QFile outFile(fileName); | 614 | QFile outFile(fileName); |
615 | 615 | ||
616 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 616 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
617 | KABC::VCardConverter converter; | 617 | KABC::VCardConverter converter; |
618 | QString vcard; | 618 | QString vcard; |
619 | 619 | ||
620 | converter.addresseeToVCard( a, vcard ); | 620 | converter.addresseeToVCard( a, vcard ); |
621 | 621 | ||
622 | QTextStream t( &outFile ); // use a text stream | 622 | QTextStream t( &outFile ); // use a text stream |
623 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 623 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
624 | t << vcard; | 624 | t << vcard; |
625 | 625 | ||
626 | outFile.close(); | 626 | outFile.close(); |
627 | 627 | ||
628 | urls.append( fileName ); | 628 | urls.append( fileName ); |
629 | } | 629 | } |
630 | } | 630 | } |
631 | 631 | ||
632 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); | 632 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
633 | 633 | ||
634 | 634 | ||
635 | /*US | 635 | /*US |
636 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 636 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
637 | QString::null, // subject | 637 | QString::null, // subject |
638 | QString::null, // body | 638 | QString::null, // body |
639 | QString::null, | 639 | QString::null, |
640 | urls ); // attachments | 640 | urls ); // attachments |
641 | */ | 641 | */ |
642 | 642 | ||
643 | } | 643 | } |
644 | 644 | ||
645 | /** | 645 | /** |
646 | Beams the "WhoAmI contact. | 646 | Beams the "WhoAmI contact. |
647 | */ | 647 | */ |
648 | void KABCore::beamMySelf() | 648 | void KABCore::beamMySelf() |
649 | { | 649 | { |
650 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 650 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
651 | if (!a.isEmpty()) | 651 | if (!a.isEmpty()) |
652 | { | 652 | { |
653 | QStringList uids; | 653 | QStringList uids; |
654 | uids << a.uid(); | 654 | uids << a.uid(); |
655 | 655 | ||
656 | beamVCard(uids); | 656 | beamVCard(uids); |
657 | } else { | 657 | } else { |
658 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 658 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
659 | 659 | ||
660 | 660 | ||
661 | } | 661 | } |
662 | } | 662 | } |
663 | 663 | ||
664 | void KABCore::export2phone() | 664 | void KABCore::export2phone() |
665 | { | 665 | { |
666 | 666 | ||
667 | KAex2phonePrefs ex2phone; | 667 | KAex2phonePrefs ex2phone; |
668 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 668 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
669 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 669 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
670 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 670 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
671 | 671 | ||
672 | if ( !ex2phone.exec() ) { | 672 | if ( !ex2phone.exec() ) { |
673 | return; | 673 | return; |
674 | } | 674 | } |
675 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 675 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
676 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 676 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
677 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 677 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
678 | 678 | ||
679 | 679 | ||
680 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 680 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
681 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 681 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
682 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 682 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
683 | 683 | ||
684 | QStringList uids = mViewManager->selectedUids(); | 684 | QStringList uids = mViewManager->selectedUids(); |
685 | if ( uids.isEmpty() ) | 685 | if ( uids.isEmpty() ) |
686 | return; | 686 | return; |
687 | 687 | ||
688 | #ifdef _WIN32_ | 688 | #ifdef _WIN32_ |
689 | QString fileName = locateLocal("tmp", "tempfile.vcf"); | 689 | QString fileName = locateLocal("tmp", "tempfile.vcf"); |
690 | #else | 690 | #else |
691 | QString fileName = "/tmp/kdepimtemp.vcf"; | 691 | QString fileName = "/tmp/kdepimtemp.vcf"; |
692 | #endif | 692 | #endif |
693 | 693 | ||
694 | KABC::VCardConverter converter; | 694 | KABC::VCardConverter converter; |
695 | QString description; | 695 | QString description; |
696 | QString datastream; | 696 | QString datastream; |
697 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 697 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
698 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 698 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
699 | 699 | ||
700 | if ( a.isEmpty() ) | 700 | if ( a.isEmpty() ) |
701 | continue; | 701 | continue; |
702 | 702 | ||
703 | if (description.isEmpty()) | 703 | if (description.isEmpty()) |
704 | description = a.formattedName(); | 704 | description = a.formattedName(); |
705 | 705 | ||
706 | QString vcard; | 706 | QString vcard; |
707 | converter.addresseeToVCard( a, vcard ); | 707 | converter.addresseeToVCard( a, vcard ); |
708 | int start = 0; | 708 | int start = 0; |
709 | int next; | 709 | int next; |
710 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 710 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
711 | int semi = vcard.find(";", next); | 711 | int semi = vcard.find(";", next); |
712 | int dopp = vcard.find(":", next); | 712 | int dopp = vcard.find(":", next); |
713 | int sep; | 713 | int sep; |
714 | if ( semi < dopp && semi >= 0 ) | 714 | if ( semi < dopp && semi >= 0 ) |
715 | sep = semi ; | 715 | sep = semi ; |
716 | else | 716 | else |
717 | sep = dopp; | 717 | sep = dopp; |
718 | datastream +=vcard.mid( start, next - start); | 718 | datastream +=vcard.mid( start, next - start); |
719 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | 719 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); |
720 | start = sep; | 720 | start = sep; |
721 | } | 721 | } |
722 | datastream += vcard.mid( start,vcard.length() ); | 722 | datastream += vcard.mid( start,vcard.length() ); |
723 | } | 723 | } |
724 | QFile outFile(fileName); | 724 | QFile outFile(fileName); |
725 | if ( outFile.open(IO_WriteOnly) ) { | 725 | if ( outFile.open(IO_WriteOnly) ) { |
726 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 726 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
727 | QTextStream t( &outFile ); // use a text stream | 727 | QTextStream t( &outFile ); // use a text stream |
728 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 728 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
729 | t <<datastream; | 729 | t <<datastream; |
730 | outFile.close(); | 730 | outFile.close(); |
731 | if ( PhoneAccess::writeToPhone( fileName ) ) | 731 | if ( PhoneAccess::writeToPhone( fileName ) ) |
732 | qDebug("Export okay "); | 732 | qDebug("Export okay "); |
733 | else | 733 | else |
734 | qDebug("Error export contacts "); | 734 | qDebug("Error export contacts "); |
735 | 735 | ||
736 | } else { | 736 | } else { |
737 | qDebug("Error open temp file "); | 737 | qDebug("Error open temp file "); |
738 | return; | 738 | return; |
739 | } | 739 | } |
740 | 740 | ||
741 | 741 | ||
742 | #if 0 | 742 | #if 0 |
743 | 743 | ||
744 | setCaption( i18n("Writing to phone...")); | 744 | setCaption( i18n("Writing to phone...")); |
745 | if ( PhoneFormat::writeToPhone( cal ) ) | 745 | if ( PhoneFormat::writeToPhone( cal ) ) |
746 | setCaption( i18n("Export to phone successful!")); | 746 | setCaption( i18n("Export to phone successful!")); |
747 | else | 747 | else |
748 | setCaption( i18n("Error exporting to phone!")); | 748 | setCaption( i18n("Error exporting to phone!")); |
749 | #endif | 749 | #endif |
750 | 750 | ||
751 | 751 | ||
752 | } | 752 | } |
753 | void KABCore::beamVCard() | 753 | void KABCore::beamVCard() |
754 | { | 754 | { |
755 | QStringList uids = mViewManager->selectedUids(); | 755 | QStringList uids = mViewManager->selectedUids(); |
756 | if ( !uids.isEmpty() ) | 756 | if ( !uids.isEmpty() ) |
757 | beamVCard( uids ); | 757 | beamVCard( uids ); |
758 | } | 758 | } |
759 | 759 | ||
760 | 760 | ||
761 | void KABCore::beamVCard(const QStringList& uids) | 761 | void KABCore::beamVCard(const QStringList& uids) |
762 | { | 762 | { |
763 | /*US | 763 | /*US |
764 | QString beamFilename; | 764 | QString beamFilename; |
765 | Opie::OPimContact c; | 765 | Opie::OPimContact c; |
766 | if ( actionPersonal->isOn() ) { | 766 | if ( actionPersonal->isOn() ) { |
767 | beamFilename = addressbookPersonalVCardName(); | 767 | beamFilename = addressbookPersonalVCardName(); |
768 | if ( !QFile::exists( beamFilename ) ) | 768 | if ( !QFile::exists( beamFilename ) ) |
769 | return; // can't beam a non-existent file | 769 | return; // can't beam a non-existent file |
770 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 770 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
771 | beamFilename ); | 771 | beamFilename ); |
772 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 772 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
773 | Opie::OPimContactAccess::List allList = access->allRecords(); | 773 | Opie::OPimContactAccess::List allList = access->allRecords(); |
774 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first | 774 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first |
775 | c = *it; | 775 | c = *it; |
776 | 776 | ||
777 | delete access; | 777 | delete access; |
778 | } else { | 778 | } else { |
779 | unlink( beamfile ); // delete if exists | 779 | unlink( beamfile ); // delete if exists |
780 | mkdir("/tmp/obex/", 0755); | 780 | mkdir("/tmp/obex/", 0755); |
781 | c = m_abView -> currentEntry(); | 781 | c = m_abView -> currentEntry(); |
782 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 782 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
783 | beamfile ); | 783 | beamfile ); |
784 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 784 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
785 | access->add( c ); | 785 | access->add( c ); |
786 | access->save(); | 786 | access->save(); |
787 | delete access; | 787 | delete access; |
788 | 788 | ||
789 | beamFilename = beamfile; | 789 | beamFilename = beamfile; |
790 | } | 790 | } |
791 | 791 | ||
792 | owarn << "Beaming: " << beamFilename << oendl; | 792 | owarn << "Beaming: " << beamFilename << oendl; |
793 | */ | 793 | */ |
794 | 794 | ||
795 | #if 0 | 795 | #if 0 |
796 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 796 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
797 | 797 | ||
798 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); | 798 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); |
799 | 799 | ||
800 | QString name = "contact.vcf"; | 800 | QString name = "contact.vcf"; |
801 | 801 | ||
802 | QString fileName = dirName + "/" + name; | 802 | QString fileName = dirName + "/" + name; |
803 | #endif | 803 | #endif |
804 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory | 804 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory |
805 | // | 805 | // |
806 | QString fileName = "/tmp/kapibeamfile.vcf"; | 806 | QString fileName = "/tmp/kapibeamfile.vcf"; |
807 | 807 | ||
808 | 808 | ||
809 | //QDir().mkdir( dirName, true ); | 809 | //QDir().mkdir( dirName, true ); |
810 | 810 | ||
811 | 811 | ||
812 | KABC::VCardConverter converter; | 812 | KABC::VCardConverter converter; |
813 | QString description; | 813 | QString description; |
814 | QString datastream; | 814 | QString datastream; |
815 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 815 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
816 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 816 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
817 | 817 | ||
818 | if ( a.isEmpty() ) | 818 | if ( a.isEmpty() ) |
819 | continue; | 819 | continue; |
820 | 820 | ||
821 | if (description.isEmpty()) | 821 | if (description.isEmpty()) |
822 | description = a.formattedName(); | 822 | description = a.formattedName(); |
823 | 823 | ||
824 | QString vcard; | 824 | QString vcard; |
825 | converter.addresseeToVCard( a, vcard ); | 825 | converter.addresseeToVCard( a, vcard ); |
826 | int start = 0; | 826 | int start = 0; |
827 | int next; | 827 | int next; |
828 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 828 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
829 | int semi = vcard.find(";", next); | 829 | int semi = vcard.find(";", next); |
830 | int dopp = vcard.find(":", next); | 830 | int dopp = vcard.find(":", next); |
831 | int sep; | 831 | int sep; |
832 | if ( semi < dopp && semi >= 0 ) | 832 | if ( semi < dopp && semi >= 0 ) |
833 | sep = semi ; | 833 | sep = semi ; |
834 | else | 834 | else |
835 | sep = dopp; | 835 | sep = dopp; |
836 | datastream +=vcard.mid( start, next - start); | 836 | datastream +=vcard.mid( start, next - start); |
837 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | 837 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); |
838 | start = sep; | 838 | start = sep; |
839 | } | 839 | } |
840 | datastream += vcard.mid( start,vcard.length() ); | 840 | datastream += vcard.mid( start,vcard.length() ); |
841 | } | 841 | } |
842 | #ifndef DESKTOP_VERSION | 842 | #ifndef DESKTOP_VERSION |
843 | QFile outFile(fileName); | 843 | QFile outFile(fileName); |
844 | if ( outFile.open(IO_WriteOnly) ) { | 844 | if ( outFile.open(IO_WriteOnly) ) { |
845 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 845 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
846 | QTextStream t( &outFile ); // use a text stream | 846 | QTextStream t( &outFile ); // use a text stream |
847 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 847 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
848 | t <<datastream; | 848 | t <<datastream; |
849 | outFile.close(); | 849 | outFile.close(); |
850 | Ir *ir = new Ir( this ); | 850 | Ir *ir = new Ir( this ); |
851 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 851 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
852 | ir->send( fileName, description, "text/x-vCard" ); | 852 | ir->send( fileName, description, "text/x-vCard" ); |
853 | } else { | 853 | } else { |
854 | qDebug("Error open temp beam file "); | 854 | qDebug("Error open temp beam file "); |
855 | return; | 855 | return; |
856 | } | 856 | } |
857 | #endif | 857 | #endif |
858 | 858 | ||
859 | } | 859 | } |
860 | 860 | ||
861 | void KABCore::beamDone( Ir *ir ) | 861 | void KABCore::beamDone( Ir *ir ) |
862 | { | 862 | { |
863 | #ifndef DESKTOP_VERSION | 863 | #ifndef DESKTOP_VERSION |
864 | delete ir; | 864 | delete ir; |
865 | #endif | 865 | #endif |
866 | } | 866 | } |
867 | 867 | ||
868 | 868 | ||
869 | void KABCore::browse( const QString& url ) | 869 | void KABCore::browse( const QString& url ) |
870 | { | 870 | { |
871 | #ifndef KAB_EMBEDDED | 871 | #ifndef KAB_EMBEDDED |
872 | kapp->invokeBrowser( url ); | 872 | kapp->invokeBrowser( url ); |
873 | #else //KAB_EMBEDDED | 873 | #else //KAB_EMBEDDED |
874 | qDebug("KABCore::browse must be fixed"); | 874 | qDebug("KABCore::browse must be fixed"); |
875 | #endif //KAB_EMBEDDED | 875 | #endif //KAB_EMBEDDED |
876 | } | 876 | } |
877 | 877 | ||
878 | void KABCore::selectAllContacts() | 878 | void KABCore::selectAllContacts() |
879 | { | 879 | { |
880 | mViewManager->setSelected( QString::null, true ); | 880 | mViewManager->setSelected( QString::null, true ); |
881 | } | 881 | } |
882 | 882 | ||
883 | void KABCore::deleteContacts() | 883 | void KABCore::deleteContacts() |
884 | { | 884 | { |
885 | QStringList uidList = mViewManager->selectedUids(); | 885 | QStringList uidList = mViewManager->selectedUids(); |
886 | deleteContacts( uidList ); | 886 | deleteContacts( uidList ); |
887 | } | 887 | } |
888 | 888 | ||
889 | void KABCore::deleteContacts( const QStringList &uids ) | 889 | void KABCore::deleteContacts( const QStringList &uids ) |
890 | { | 890 | { |
891 | if ( uids.count() > 0 ) { | 891 | if ( uids.count() > 0 ) { |
892 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 892 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
893 | UndoStack::instance()->push( command ); | 893 | UndoStack::instance()->push( command ); |
894 | RedoStack::instance()->clear(); | 894 | RedoStack::instance()->clear(); |
895 | 895 | ||
896 | // now if we deleted anything, refresh | 896 | // now if we deleted anything, refresh |
897 | setContactSelected( QString::null ); | 897 | setContactSelected( QString::null ); |
898 | setModified( true ); | 898 | setModified( true ); |
899 | } | 899 | } |
900 | } | 900 | } |
901 | 901 | ||
902 | void KABCore::copyContacts() | 902 | void KABCore::copyContacts() |
903 | { | 903 | { |
904 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 904 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
905 | 905 | ||
906 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 906 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
907 | 907 | ||
908 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 908 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
909 | 909 | ||
910 | QClipboard *cb = QApplication::clipboard(); | 910 | QClipboard *cb = QApplication::clipboard(); |
911 | cb->setText( clipText ); | 911 | cb->setText( clipText ); |
912 | } | 912 | } |
913 | 913 | ||
914 | void KABCore::cutContacts() | 914 | void KABCore::cutContacts() |
915 | { | 915 | { |
916 | QStringList uidList = mViewManager->selectedUids(); | 916 | QStringList uidList = mViewManager->selectedUids(); |
917 | 917 | ||
918 | //US if ( uidList.size() > 0 ) { | 918 | //US if ( uidList.size() > 0 ) { |
919 | if ( uidList.count() > 0 ) { | 919 | if ( uidList.count() > 0 ) { |
920 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 920 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
921 | UndoStack::instance()->push( command ); | 921 | UndoStack::instance()->push( command ); |
922 | RedoStack::instance()->clear(); | 922 | RedoStack::instance()->clear(); |
923 | 923 | ||
924 | setModified( true ); | 924 | setModified( true ); |
925 | } | 925 | } |
926 | } | 926 | } |
927 | 927 | ||
928 | void KABCore::pasteContacts() | 928 | void KABCore::pasteContacts() |
929 | { | 929 | { |
930 | QClipboard *cb = QApplication::clipboard(); | 930 | QClipboard *cb = QApplication::clipboard(); |
931 | 931 | ||
932 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 932 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
933 | 933 | ||
934 | pasteContacts( list ); | 934 | pasteContacts( list ); |
935 | } | 935 | } |
936 | 936 | ||
937 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 937 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
938 | { | 938 | { |
939 | KABC::Resource *resource = requestResource( this ); | 939 | KABC::Resource *resource = requestResource( this ); |
940 | KABC::Addressee::List::Iterator it; | 940 | KABC::Addressee::List::Iterator it; |
941 | for ( it = list.begin(); it != list.end(); ++it ) | 941 | for ( it = list.begin(); it != list.end(); ++it ) |
942 | (*it).setResource( resource ); | 942 | (*it).setResource( resource ); |
943 | 943 | ||
944 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 944 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
945 | UndoStack::instance()->push( command ); | 945 | UndoStack::instance()->push( command ); |
946 | RedoStack::instance()->clear(); | 946 | RedoStack::instance()->clear(); |
947 | 947 | ||
948 | setModified( true ); | 948 | setModified( true ); |
949 | } | 949 | } |
950 | 950 | ||
951 | void KABCore::setWhoAmI() | 951 | void KABCore::setWhoAmI() |
952 | { | 952 | { |
953 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 953 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
954 | 954 | ||
955 | if ( addrList.count() > 1 ) { | 955 | if ( addrList.count() > 1 ) { |
956 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 956 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
957 | return; | 957 | return; |
958 | } | 958 | } |
959 | 959 | ||
960 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 960 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
961 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | 961 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) |
962 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 962 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
963 | } | 963 | } |
964 | 964 | ||
965 | void KABCore::setCategories() | 965 | void KABCore::setCategories() |
966 | { | 966 | { |
967 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 967 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
968 | if ( !dlg.exec() ) | 968 | if ( !dlg.exec() ) |
969 | return; | 969 | return; |
970 | 970 | ||
971 | bool merge = false; | 971 | bool merge = false; |
972 | QString msg = i18n( "Merge with existing categories?" ); | 972 | QString msg = i18n( "Merge with existing categories?" ); |
973 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 973 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
974 | merge = true; | 974 | merge = true; |
975 | 975 | ||
976 | QStringList categories = dlg.selectedCategories(); | 976 | QStringList categories = dlg.selectedCategories(); |
977 | 977 | ||
978 | QStringList uids = mViewManager->selectedUids(); | 978 | QStringList uids = mViewManager->selectedUids(); |
979 | QStringList::Iterator it; | 979 | QStringList::Iterator it; |
980 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 980 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
981 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 981 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
982 | if ( !addr.isEmpty() ) { | 982 | if ( !addr.isEmpty() ) { |
983 | if ( !merge ) | 983 | if ( !merge ) |
984 | addr.setCategories( categories ); | 984 | addr.setCategories( categories ); |
985 | else { | 985 | else { |
986 | QStringList addrCategories = addr.categories(); | 986 | QStringList addrCategories = addr.categories(); |
987 | QStringList::Iterator catIt; | 987 | QStringList::Iterator catIt; |
988 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 988 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
989 | if ( !addrCategories.contains( *catIt ) ) | 989 | if ( !addrCategories.contains( *catIt ) ) |
990 | addrCategories.append( *catIt ); | 990 | addrCategories.append( *catIt ); |
991 | } | 991 | } |
992 | addr.setCategories( addrCategories ); | 992 | addr.setCategories( addrCategories ); |
993 | } | 993 | } |
994 | 994 | ||
995 | mAddressBook->insertAddressee( addr ); | 995 | mAddressBook->insertAddressee( addr ); |
996 | } | 996 | } |
997 | } | 997 | } |
998 | 998 | ||
999 | if ( uids.count() > 0 ) | 999 | if ( uids.count() > 0 ) |
1000 | setModified( true ); | 1000 | setModified( true ); |
1001 | } | 1001 | } |
1002 | 1002 | ||
1003 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 1003 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
1004 | { | 1004 | { |
1005 | mIncSearchWidget->setFields( fields ); | 1005 | mIncSearchWidget->setFields( fields ); |
1006 | } | 1006 | } |
1007 | 1007 | ||
1008 | void KABCore::incrementalSearch( const QString& text ) | 1008 | void KABCore::incrementalSearch( const QString& text ) |
1009 | { | 1009 | { |
1010 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); | 1010 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); |
1011 | } | 1011 | } |
1012 | 1012 | ||
1013 | void KABCore::setModified() | 1013 | void KABCore::setModified() |
1014 | { | 1014 | { |
1015 | setModified( true ); | 1015 | setModified( true ); |
1016 | } | 1016 | } |
1017 | 1017 | ||
1018 | void KABCore::setModifiedWOrefresh() | 1018 | void KABCore::setModifiedWOrefresh() |
1019 | { | 1019 | { |
1020 | // qDebug("KABCore::setModifiedWOrefresh() "); | 1020 | // qDebug("KABCore::setModifiedWOrefresh() "); |
1021 | mModified = true; | 1021 | mModified = true; |
1022 | mActionSave->setEnabled( mModified ); | 1022 | mActionSave->setEnabled( mModified ); |
1023 | #ifdef DESKTOP_VERSION | 1023 | #ifdef DESKTOP_VERSION |
1024 | mDetails->refreshView(); | 1024 | mDetails->refreshView(); |
1025 | #endif | 1025 | #endif |
1026 | 1026 | ||
1027 | } | 1027 | } |
1028 | void KABCore::setModified( bool modified ) | 1028 | void KABCore::setModified( bool modified ) |
1029 | { | 1029 | { |
1030 | mModified = modified; | 1030 | mModified = modified; |
1031 | mActionSave->setEnabled( mModified ); | 1031 | mActionSave->setEnabled( mModified ); |
1032 | 1032 | ||
1033 | if ( modified ) | 1033 | if ( modified ) |
1034 | mJumpButtonBar->recreateButtons(); | 1034 | mJumpButtonBar->recreateButtons(); |
1035 | 1035 | ||
1036 | mViewManager->refreshView(); | 1036 | mViewManager->refreshView(); |
1037 | mDetails->refreshView(); | 1037 | mDetails->refreshView(); |
1038 | 1038 | ||
1039 | } | 1039 | } |
1040 | 1040 | ||
1041 | bool KABCore::modified() const | 1041 | bool KABCore::modified() const |
1042 | { | 1042 | { |
1043 | return mModified; | 1043 | return mModified; |
1044 | } | 1044 | } |
1045 | 1045 | ||
1046 | void KABCore::contactModified( const KABC::Addressee &addr ) | 1046 | void KABCore::contactModified( const KABC::Addressee &addr ) |
1047 | { | 1047 | { |
1048 | 1048 | ||
1049 | Command *command = 0; | 1049 | Command *command = 0; |
1050 | QString uid; | 1050 | QString uid; |
1051 | 1051 | ||
1052 | // check if it exists already | 1052 | // check if it exists already |
1053 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 1053 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
1054 | if ( origAddr.isEmpty() ) | 1054 | if ( origAddr.isEmpty() ) |
1055 | command = new PwNewCommand( mAddressBook, addr ); | 1055 | command = new PwNewCommand( mAddressBook, addr ); |
1056 | else { | 1056 | else { |
1057 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 1057 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
1058 | uid = addr.uid(); | 1058 | uid = addr.uid(); |
1059 | } | 1059 | } |
1060 | 1060 | ||
1061 | UndoStack::instance()->push( command ); | 1061 | UndoStack::instance()->push( command ); |
1062 | RedoStack::instance()->clear(); | 1062 | RedoStack::instance()->clear(); |
1063 | 1063 | ||
1064 | setModified( true ); | 1064 | setModified( true ); |
1065 | } | 1065 | } |
1066 | 1066 | ||
1067 | void KABCore::newContact() | 1067 | void KABCore::newContact() |
1068 | { | 1068 | { |
1069 | 1069 | ||
1070 | 1070 | ||
1071 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 1071 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
1072 | 1072 | ||
1073 | QPtrList<KRES::Resource> kresResources; | 1073 | QPtrList<KRES::Resource> kresResources; |
1074 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 1074 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
1075 | KABC::Resource *resource; | 1075 | KABC::Resource *resource; |
1076 | while ( ( resource = it.current() ) != 0 ) { | 1076 | while ( ( resource = it.current() ) != 0 ) { |
1077 | ++it; | 1077 | ++it; |
1078 | if ( !resource->readOnly() ) { | 1078 | if ( !resource->readOnly() ) { |
1079 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 1079 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
1080 | if ( res ) | 1080 | if ( res ) |
1081 | kresResources.append( res ); | 1081 | kresResources.append( res ); |
1082 | } | 1082 | } |
1083 | } | 1083 | } |
1084 | 1084 | ||
1085 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 1085 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
1086 | resource = static_cast<KABC::Resource*>( res ); | 1086 | resource = static_cast<KABC::Resource*>( res ); |
1087 | 1087 | ||
1088 | if ( resource ) { | 1088 | if ( resource ) { |
1089 | KABC::Addressee addr; | 1089 | KABC::Addressee addr; |
1090 | addr.setResource( resource ); | 1090 | addr.setResource( resource ); |
1091 | mEditorDialog->setAddressee( addr ); | 1091 | mEditorDialog->setAddressee( addr ); |
1092 | KApplication::execDialog ( mEditorDialog ); | 1092 | KApplication::execDialog ( mEditorDialog ); |
1093 | 1093 | ||
1094 | } else | 1094 | } else |
1095 | return; | 1095 | return; |
1096 | 1096 | ||
1097 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 1097 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
1098 | 1098 | ||
1099 | 1099 | ||
1100 | } | 1100 | } |
1101 | 1101 | ||
1102 | void KABCore::addEmail( QString aStr ) | 1102 | void KABCore::addEmail( QString aStr ) |
1103 | { | 1103 | { |
1104 | #ifndef KAB_EMBEDDED | 1104 | #ifndef KAB_EMBEDDED |
1105 | QString fullName, email; | 1105 | QString fullName, email; |
1106 | 1106 | ||
1107 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 1107 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
1108 | 1108 | ||
1109 | // Try to lookup the addressee matching the email address | 1109 | // Try to lookup the addressee matching the email address |
1110 | bool found = false; | 1110 | bool found = false; |
1111 | QStringList emailList; | 1111 | QStringList emailList; |
1112 | KABC::AddressBook::Iterator it; | 1112 | KABC::AddressBook::Iterator it; |
1113 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 1113 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
1114 | emailList = (*it).emails(); | 1114 | emailList = (*it).emails(); |
1115 | if ( emailList.contains( email ) > 0 ) { | 1115 | if ( emailList.contains( email ) > 0 ) { |
1116 | found = true; | 1116 | found = true; |
1117 | (*it).setNameFromString( fullName ); | 1117 | (*it).setNameFromString( fullName ); |
1118 | editContact( (*it).uid() ); | 1118 | editContact( (*it).uid() ); |
1119 | } | 1119 | } |
1120 | } | 1120 | } |
1121 | 1121 | ||
1122 | if ( !found ) { | 1122 | if ( !found ) { |
1123 | KABC::Addressee addr; | 1123 | KABC::Addressee addr; |
1124 | addr.setNameFromString( fullName ); | 1124 | addr.setNameFromString( fullName ); |
1125 | addr.insertEmail( email, true ); | 1125 | addr.insertEmail( email, true ); |
1126 | 1126 | ||
1127 | mAddressBook->insertAddressee( addr ); | 1127 | mAddressBook->insertAddressee( addr ); |
1128 | mViewManager->refreshView( addr.uid() ); | 1128 | mViewManager->refreshView( addr.uid() ); |
1129 | editContact( addr.uid() ); | 1129 | editContact( addr.uid() ); |
1130 | } | 1130 | } |
1131 | #else //KAB_EMBEDDED | 1131 | #else //KAB_EMBEDDED |
1132 | qDebug("KABCore::addEmail finsih method"); | 1132 | qDebug("KABCore::addEmail finsih method"); |
1133 | #endif //KAB_EMBEDDED | 1133 | #endif //KAB_EMBEDDED |
1134 | } | 1134 | } |
1135 | 1135 | ||
1136 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 1136 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
1137 | { | 1137 | { |
1138 | mXXPortManager->importVCard( url, showPreview ); | 1138 | mXXPortManager->importVCard( url, showPreview ); |
1139 | } | 1139 | } |
1140 | void KABCore::importFromOL() | 1140 | void KABCore::importFromOL() |
1141 | { | 1141 | { |
1142 | #ifdef _WIN32_ | 1142 | #ifdef _WIN32_ |
1143 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | 1143 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); |
1144 | idgl->exec(); | 1144 | idgl->exec(); |
1145 | KABC::Addressee::List list = idgl->getAddressList(); | 1145 | KABC::Addressee::List list = idgl->getAddressList(); |
1146 | if ( list.count() > 0 ) { | 1146 | if ( list.count() > 0 ) { |
1147 | KABC::Addressee::List listNew; | 1147 | KABC::Addressee::List listNew; |
1148 | KABC::Addressee::List listExisting; | 1148 | KABC::Addressee::List listExisting; |
1149 | KABC::Addressee::List::Iterator it; | 1149 | KABC::Addressee::List::Iterator it; |
1150 | KABC::AddressBook::Iterator iter; | 1150 | KABC::AddressBook::Iterator iter; |
1151 | for ( it = list.begin(); it != list.end(); ++it ) { | 1151 | for ( it = list.begin(); it != list.end(); ++it ) { |
1152 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) | 1152 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) |
1153 | listNew.append( (*it) ); | 1153 | listNew.append( (*it) ); |
1154 | else | 1154 | else |
1155 | listExisting.append( (*it) ); | 1155 | listExisting.append( (*it) ); |
1156 | } | 1156 | } |
1157 | if ( listExisting.count() > 0 ) | 1157 | if ( listExisting.count() > 0 ) |
1158 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); | 1158 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); |
1159 | if ( listNew.count() > 0 ) { | 1159 | if ( listNew.count() > 0 ) { |
1160 | pasteWithNewUid = false; | 1160 | pasteWithNewUid = false; |
1161 | pasteContacts( listNew ); | 1161 | pasteContacts( listNew ); |
1162 | pasteWithNewUid = true; | 1162 | pasteWithNewUid = true; |
1163 | } | 1163 | } |
1164 | } | 1164 | } |
1165 | delete idgl; | 1165 | delete idgl; |
1166 | #endif | 1166 | #endif |
1167 | } | 1167 | } |
1168 | 1168 | ||
1169 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1169 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
1170 | { | 1170 | { |
1171 | mXXPortManager->importVCard( vCard, showPreview ); | 1171 | mXXPortManager->importVCard( vCard, showPreview ); |
1172 | } | 1172 | } |
1173 | 1173 | ||
1174 | //US added a second method without defaultparameter | 1174 | //US added a second method without defaultparameter |
1175 | void KABCore::editContact2() { | 1175 | void KABCore::editContact2() { |
1176 | editContact( QString::null ); | 1176 | editContact( QString::null ); |
1177 | } | 1177 | } |
1178 | 1178 | ||
1179 | void KABCore::editContact( const QString &uid ) | 1179 | void KABCore::editContact( const QString &uid ) |
1180 | { | 1180 | { |
1181 | 1181 | ||
1182 | if ( mExtensionManager->isQuickEditVisible() ) | 1182 | if ( mExtensionManager->isQuickEditVisible() ) |
1183 | return; | 1183 | return; |
1184 | 1184 | ||
1185 | // First, locate the contact entry | 1185 | // First, locate the contact entry |
1186 | QString localUID = uid; | 1186 | QString localUID = uid; |
1187 | if ( localUID.isNull() ) { | 1187 | if ( localUID.isNull() ) { |
1188 | QStringList uidList = mViewManager->selectedUids(); | 1188 | QStringList uidList = mViewManager->selectedUids(); |
1189 | if ( uidList.count() > 0 ) | 1189 | if ( uidList.count() > 0 ) |
1190 | localUID = *( uidList.at( 0 ) ); | 1190 | localUID = *( uidList.at( 0 ) ); |
1191 | } | 1191 | } |
1192 | 1192 | ||
1193 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 1193 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
1194 | if ( !addr.isEmpty() ) { | 1194 | if ( !addr.isEmpty() ) { |
1195 | mEditorDialog->setAddressee( addr ); | 1195 | mEditorDialog->setAddressee( addr ); |
1196 | KApplication::execDialog ( mEditorDialog ); | 1196 | KApplication::execDialog ( mEditorDialog ); |
1197 | } | 1197 | } |
1198 | } | 1198 | } |
1199 | 1199 | ||
1200 | /** | 1200 | /** |
1201 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 1201 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
1202 | the method will try to find a selected addressee in the view. | 1202 | the method will try to find a selected addressee in the view. |
1203 | */ | 1203 | */ |
1204 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1204 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) |
1205 | { | 1205 | { |
1206 | if ( mMultipleViewsAtOnce ) | 1206 | if ( mMultipleViewsAtOnce ) |
1207 | { | 1207 | { |
1208 | editContact( uid ); | 1208 | editContact( uid ); |
1209 | } | 1209 | } |
1210 | else | 1210 | else |
1211 | { | 1211 | { |
1212 | setDetailsVisible( true ); | 1212 | setDetailsVisible( true ); |
1213 | mActionDetails->setChecked(true); | 1213 | mActionDetails->setChecked(true); |
1214 | } | 1214 | } |
1215 | 1215 | ||
1216 | } | 1216 | } |
1217 | 1217 | ||
1218 | void KABCore::save() | 1218 | void KABCore::save() |
1219 | { | 1219 | { |
1220 | if (syncManager->blockSave()) | 1220 | if (syncManager->blockSave()) |
1221 | return; | 1221 | return; |
1222 | if ( !mModified ) | 1222 | if ( !mModified ) |
1223 | return; | 1223 | return; |
1224 | 1224 | ||
1225 | syncManager->setBlockSave(true); | 1225 | syncManager->setBlockSave(true); |
1226 | QString text = i18n( "There was an error while attempting to save\n the " | 1226 | QString text = i18n( "There was an error while attempting to save\n the " |
1227 | "address book. Please check that some \nother application is " | 1227 | "address book. Please check that some \nother application is " |
1228 | "not using it. " ); | 1228 | "not using it. " ); |
1229 | statusMessage(i18n("Saving addressbook ... ")); | 1229 | statusMessage(i18n("Saving addressbook ... ")); |
1230 | #ifndef KAB_EMBEDDED | 1230 | #ifndef KAB_EMBEDDED |
1231 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1231 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
1232 | if ( !b || !b->save() ) { | 1232 | if ( !b || !b->save() ) { |
1233 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 1233 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
1234 | } | 1234 | } |
1235 | #else //KAB_EMBEDDED | 1235 | #else //KAB_EMBEDDED |
1236 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 1236 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
1237 | if ( !b || !b->save() ) { | 1237 | if ( !b || !b->save() ) { |
1238 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 1238 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
1239 | } | 1239 | } |
1240 | #endif //KAB_EMBEDDED | 1240 | #endif //KAB_EMBEDDED |
1241 | 1241 | ||
1242 | statusMessage(i18n("Addressbook saved!")); | 1242 | statusMessage(i18n("Addressbook saved!")); |
1243 | setModified( false ); | 1243 | setModified( false ); |
1244 | syncManager->setBlockSave(false); | 1244 | syncManager->setBlockSave(false); |
1245 | } | 1245 | } |
1246 | 1246 | ||
1247 | void KABCore::statusMessage(QString mess , int time ) | 1247 | void KABCore::statusMessage(QString mess , int time ) |
1248 | { | 1248 | { |
1249 | //topLevelWidget()->setCaption( mess ); | 1249 | //topLevelWidget()->setCaption( mess ); |
1250 | // pending setting timer to revome message | 1250 | // pending setting timer to revome message |
1251 | } | 1251 | } |
1252 | void KABCore::undo() | 1252 | void KABCore::undo() |
1253 | { | 1253 | { |
1254 | UndoStack::instance()->undo(); | 1254 | UndoStack::instance()->undo(); |
1255 | 1255 | ||
1256 | // Refresh the view | 1256 | // Refresh the view |
1257 | mViewManager->refreshView(); | 1257 | mViewManager->refreshView(); |
1258 | } | 1258 | } |
1259 | 1259 | ||
1260 | void KABCore::redo() | 1260 | void KABCore::redo() |
1261 | { | 1261 | { |
1262 | RedoStack::instance()->redo(); | 1262 | RedoStack::instance()->redo(); |
1263 | 1263 | ||
1264 | // Refresh the view | 1264 | // Refresh the view |
1265 | mViewManager->refreshView(); | 1265 | mViewManager->refreshView(); |
1266 | } | 1266 | } |
1267 | 1267 | ||
1268 | void KABCore::setJumpButtonBarVisible( bool visible ) | 1268 | void KABCore::setJumpButtonBarVisible( bool visible ) |
1269 | { | 1269 | { |
1270 | if (mMultipleViewsAtOnce) | 1270 | if (mMultipleViewsAtOnce) |
1271 | { | 1271 | { |
1272 | if ( visible ) | 1272 | if ( visible ) |
1273 | mJumpButtonBar->show(); | 1273 | mJumpButtonBar->show(); |
1274 | else | 1274 | else |
1275 | mJumpButtonBar->hide(); | 1275 | mJumpButtonBar->hide(); |
1276 | } | 1276 | } |
1277 | else | 1277 | else |
1278 | { | 1278 | { |
1279 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" | 1279 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" |
1280 | if (mViewManager->isVisible()) | 1280 | if (mViewManager->isVisible()) |
1281 | { | 1281 | { |
1282 | if ( visible ) | 1282 | if ( visible ) |
1283 | mJumpButtonBar->show(); | 1283 | mJumpButtonBar->show(); |
1284 | else | 1284 | else |
1285 | mJumpButtonBar->hide(); | 1285 | mJumpButtonBar->hide(); |
1286 | } | 1286 | } |
1287 | else | 1287 | else |
1288 | { | 1288 | { |
1289 | mJumpButtonBar->hide(); | 1289 | mJumpButtonBar->hide(); |
1290 | } | 1290 | } |
1291 | } | 1291 | } |
1292 | } | 1292 | } |
1293 | 1293 | ||
1294 | 1294 | ||
1295 | void KABCore::setDetailsToState() | 1295 | void KABCore::setDetailsToState() |
1296 | { | 1296 | { |
1297 | setDetailsVisible( mActionDetails->isChecked() ); | 1297 | setDetailsVisible( mActionDetails->isChecked() ); |
1298 | } | 1298 | } |
1299 | 1299 | ||
1300 | 1300 | ||
1301 | 1301 | ||
1302 | void KABCore::setDetailsVisible( bool visible ) | 1302 | void KABCore::setDetailsVisible( bool visible ) |
1303 | { | 1303 | { |
1304 | if (visible && mDetails->isHidden()) | 1304 | if (visible && mDetails->isHidden()) |
1305 | { | 1305 | { |
1306 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1306 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1307 | if ( addrList.count() > 0 ) | 1307 | if ( addrList.count() > 0 ) |
1308 | mDetails->setAddressee( addrList[ 0 ] ); | 1308 | mDetails->setAddressee( addrList[ 0 ] ); |
1309 | } | 1309 | } |
1310 | 1310 | ||
1311 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between | 1311 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between |
1312 | // the listview and the detailview. We do that by changing the splitbar size. | 1312 | // the listview and the detailview. We do that by changing the splitbar size. |
1313 | if (mMultipleViewsAtOnce) | 1313 | if (mMultipleViewsAtOnce) |
1314 | { | 1314 | { |
1315 | if ( visible ) | 1315 | if ( visible ) |
1316 | mDetails->show(); | 1316 | mDetails->show(); |
1317 | else | 1317 | else |
1318 | mDetails->hide(); | 1318 | mDetails->hide(); |
1319 | } | 1319 | } |
1320 | else | 1320 | else |
1321 | { | 1321 | { |
1322 | if ( visible ) { | 1322 | if ( visible ) { |
1323 | mViewManager->hide(); | 1323 | mViewManager->hide(); |
1324 | mDetails->show(); | 1324 | mDetails->show(); |
1325 | } | 1325 | } |
1326 | else { | 1326 | else { |
1327 | mViewManager->show(); | 1327 | mViewManager->show(); |
1328 | mDetails->hide(); | 1328 | mDetails->hide(); |
1329 | } | 1329 | } |
1330 | setJumpButtonBarVisible( !visible ); | 1330 | setJumpButtonBarVisible( !visible ); |
1331 | } | 1331 | } |
1332 | 1332 | ||
1333 | } | 1333 | } |
1334 | 1334 | ||
1335 | void KABCore::extensionChanged( int id ) | 1335 | void KABCore::extensionChanged( int id ) |
1336 | { | 1336 | { |
1337 | //change the details view only for non desktop systems | 1337 | //change the details view only for non desktop systems |
1338 | #ifndef DESKTOP_VERSION | 1338 | #ifndef DESKTOP_VERSION |
1339 | 1339 | ||
1340 | if (id == 0) | 1340 | if (id == 0) |
1341 | { | 1341 | { |
1342 | //the user disabled the extension. | 1342 | //the user disabled the extension. |
1343 | 1343 | ||
1344 | if (mMultipleViewsAtOnce) | 1344 | if (mMultipleViewsAtOnce) |
1345 | { // enable detailsview again | 1345 | { // enable detailsview again |
1346 | setDetailsVisible( true ); | 1346 | setDetailsVisible( true ); |
1347 | mActionDetails->setChecked( true ); | 1347 | mActionDetails->setChecked( true ); |
1348 | } | 1348 | } |
1349 | else | 1349 | else |
1350 | { //go back to the listview | 1350 | { //go back to the listview |
1351 | setDetailsVisible( false ); | 1351 | setDetailsVisible( false ); |
1352 | mActionDetails->setChecked( false ); | 1352 | mActionDetails->setChecked( false ); |
1353 | mActionDetails->setEnabled(true); | 1353 | mActionDetails->setEnabled(true); |
1354 | } | 1354 | } |
1355 | 1355 | ||
1356 | } | 1356 | } |
1357 | else | 1357 | else |
1358 | { | 1358 | { |
1359 | //the user enabled the extension. | 1359 | //the user enabled the extension. |
1360 | setDetailsVisible( false ); | 1360 | setDetailsVisible( false ); |
1361 | mActionDetails->setChecked( false ); | 1361 | mActionDetails->setChecked( false ); |
1362 | 1362 | ||
1363 | if (!mMultipleViewsAtOnce) | 1363 | if (!mMultipleViewsAtOnce) |
1364 | { | 1364 | { |
1365 | mActionDetails->setEnabled(false); | 1365 | mActionDetails->setEnabled(false); |
1366 | } | 1366 | } |
1367 | 1367 | ||
1368 | mExtensionManager->setSelectionChanged(); | 1368 | mExtensionManager->setSelectionChanged(); |
1369 | 1369 | ||
1370 | } | 1370 | } |
1371 | 1371 | ||
1372 | #endif// DESKTOP_VERSION | 1372 | #endif// DESKTOP_VERSION |
1373 | 1373 | ||
1374 | } | 1374 | } |
1375 | 1375 | ||
1376 | 1376 | ||
1377 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1377 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1378 | { | 1378 | { |
1379 | 1379 | ||
1380 | if ( list.count() != 0 ) { | 1380 | if ( list.count() != 0 ) { |
1381 | KABC::Addressee::List::ConstIterator it; | 1381 | KABC::Addressee::List::ConstIterator it; |
1382 | for ( it = list.begin(); it != list.end(); ++it ) | 1382 | for ( it = list.begin(); it != list.end(); ++it ) |
1383 | mAddressBook->insertAddressee( *it ); | 1383 | mAddressBook->insertAddressee( *it ); |
1384 | if ( list.count() > 1 ) | 1384 | if ( list.count() > 1 ) |
1385 | setModified(); | 1385 | setModified(); |
1386 | else | 1386 | else |
1387 | setModifiedWOrefresh(); | 1387 | setModifiedWOrefresh(); |
1388 | } | 1388 | } |
1389 | if ( list.count() == 0 ) | 1389 | if ( list.count() == 0 ) |
1390 | mViewManager->refreshView(); | 1390 | mViewManager->refreshView(); |
1391 | else | 1391 | else |
1392 | mViewManager->refreshView( list[ 0 ].uid() ); | 1392 | mViewManager->refreshView( list[ 0 ].uid() ); |
1393 | 1393 | ||
1394 | 1394 | ||
1395 | 1395 | ||
1396 | } | 1396 | } |
1397 | 1397 | ||
1398 | QString KABCore::getNameByPhone( const QString &phone ) | 1398 | QString KABCore::getNameByPhone( const QString &phone ) |
1399 | { | 1399 | { |
1400 | #ifndef KAB_EMBEDDED | 1400 | #ifndef KAB_EMBEDDED |
1401 | QRegExp r( "[/*/-/ ]" ); | 1401 | QRegExp r( "[/*/-/ ]" ); |
1402 | QString localPhone( phone ); | 1402 | QString localPhone( phone ); |
1403 | 1403 | ||
1404 | bool found = false; | 1404 | bool found = false; |
1405 | QString ownerName = ""; | 1405 | QString ownerName = ""; |
1406 | KABC::AddressBook::Iterator iter; | 1406 | KABC::AddressBook::Iterator iter; |
1407 | KABC::PhoneNumber::List::Iterator phoneIter; | 1407 | KABC::PhoneNumber::List::Iterator phoneIter; |
1408 | KABC::PhoneNumber::List phoneList; | 1408 | KABC::PhoneNumber::List phoneList; |
1409 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1409 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
1410 | phoneList = (*iter).phoneNumbers(); | 1410 | phoneList = (*iter).phoneNumbers(); |
1411 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1411 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
1412 | ++phoneIter) { | 1412 | ++phoneIter) { |
1413 | // Get rid of separator chars so just the numbers are compared. | 1413 | // Get rid of separator chars so just the numbers are compared. |
1414 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1414 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
1415 | ownerName = (*iter).formattedName(); | 1415 | ownerName = (*iter).formattedName(); |
1416 | found = true; | 1416 | found = true; |
1417 | } | 1417 | } |
1418 | } | 1418 | } |
1419 | } | 1419 | } |
1420 | 1420 | ||
1421 | return ownerName; | 1421 | return ownerName; |
1422 | #else //KAB_EMBEDDED | 1422 | #else //KAB_EMBEDDED |
1423 | qDebug("KABCore::getNameByPhone finsih method"); | 1423 | qDebug("KABCore::getNameByPhone finsih method"); |
1424 | return ""; | 1424 | return ""; |
1425 | #endif //KAB_EMBEDDED | 1425 | #endif //KAB_EMBEDDED |
1426 | 1426 | ||
1427 | } | 1427 | } |
1428 | 1428 | ||
1429 | void KABCore::openConfigDialog() | 1429 | void KABCore::openConfigDialog() |
1430 | { | 1430 | { |
1431 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 1431 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
1432 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 1432 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
1433 | ConfigureDialog->addModule(kabcfg ); | 1433 | ConfigureDialog->addModule(kabcfg ); |
1434 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 1434 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
1435 | ConfigureDialog->addModule(kdelibcfg ); | 1435 | ConfigureDialog->addModule(kdelibcfg ); |
1436 | 1436 | ||
1437 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1437 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1438 | this, SLOT( configurationChanged() ) ); | 1438 | this, SLOT( configurationChanged() ) ); |
1439 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1439 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
1440 | this, SLOT( configurationChanged() ) ); | 1440 | this, SLOT( configurationChanged() ) ); |
1441 | saveSettings(); | 1441 | saveSettings(); |
1442 | #ifndef DESKTOP_VERSION | 1442 | #ifndef DESKTOP_VERSION |
1443 | ConfigureDialog->showMaximized(); | 1443 | ConfigureDialog->showMaximized(); |
1444 | #endif | 1444 | #endif |
1445 | if ( ConfigureDialog->exec() ) | 1445 | if ( ConfigureDialog->exec() ) |
1446 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 1446 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
1447 | delete ConfigureDialog; | 1447 | delete ConfigureDialog; |
1448 | } | 1448 | } |
1449 | 1449 | ||
1450 | void KABCore::openLDAPDialog() | 1450 | void KABCore::openLDAPDialog() |
1451 | { | 1451 | { |
1452 | #ifndef KAB_EMBEDDED | 1452 | #ifndef KAB_EMBEDDED |
1453 | if ( !mLdapSearchDialog ) { | 1453 | if ( !mLdapSearchDialog ) { |
1454 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1454 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1455 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1455 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1456 | SLOT( refreshView() ) ); | 1456 | SLOT( refreshView() ) ); |
1457 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1457 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1458 | SLOT( setModified() ) ); | 1458 | SLOT( setModified() ) ); |
1459 | } else | 1459 | } else |
1460 | mLdapSearchDialog->restoreSettings(); | 1460 | mLdapSearchDialog->restoreSettings(); |
1461 | 1461 | ||
1462 | if ( mLdapSearchDialog->isOK() ) | 1462 | if ( mLdapSearchDialog->isOK() ) |
1463 | mLdapSearchDialog->exec(); | 1463 | mLdapSearchDialog->exec(); |
1464 | #else //KAB_EMBEDDED | 1464 | #else //KAB_EMBEDDED |
1465 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1465 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1466 | #endif //KAB_EMBEDDED | 1466 | #endif //KAB_EMBEDDED |
1467 | } | 1467 | } |
1468 | 1468 | ||
1469 | void KABCore::print() | 1469 | void KABCore::print() |
1470 | { | 1470 | { |
1471 | #ifndef KAB_EMBEDDED | 1471 | #ifndef KAB_EMBEDDED |
1472 | KPrinter printer; | 1472 | KPrinter printer; |
1473 | if ( !printer.setup( this ) ) | 1473 | if ( !printer.setup( this ) ) |
1474 | return; | 1474 | return; |
1475 | 1475 | ||
1476 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1476 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1477 | mViewManager->selectedUids(), this ); | 1477 | mViewManager->selectedUids(), this ); |
1478 | 1478 | ||
1479 | wizard.exec(); | 1479 | wizard.exec(); |
1480 | #else //KAB_EMBEDDED | 1480 | #else //KAB_EMBEDDED |
1481 | qDebug("KABCore::print() finsih method"); | 1481 | qDebug("KABCore::print() finsih method"); |
1482 | #endif //KAB_EMBEDDED | 1482 | #endif //KAB_EMBEDDED |
1483 | 1483 | ||
1484 | } | 1484 | } |
1485 | 1485 | ||
1486 | 1486 | ||
1487 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1487 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1488 | { | 1488 | { |
1489 | if ( mGUIClient ) | 1489 | if ( mGUIClient ) |
1490 | mGUIClient->insertChildClient( client ); | 1490 | mGUIClient->insertChildClient( client ); |
1491 | else | 1491 | else |
1492 | KMessageBox::error( this, "no KXMLGUICLient"); | 1492 | KMessageBox::error( this, "no KXMLGUICLient"); |
1493 | } | 1493 | } |
1494 | 1494 | ||
1495 | 1495 | ||
1496 | void KABCore::configurationChanged() | 1496 | void KABCore::configurationChanged() |
1497 | { | 1497 | { |
1498 | mExtensionManager->reconfigure(); | 1498 | mExtensionManager->reconfigure(); |
1499 | } | 1499 | } |
1500 | 1500 | ||
1501 | void KABCore::addressBookChanged() | 1501 | void KABCore::addressBookChanged() |
1502 | { | 1502 | { |
1503 | /*US | 1503 | /*US |
1504 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1504 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1505 | while ( it.current() ) { | 1505 | while ( it.current() ) { |
1506 | if ( it.current()->dirty() ) { | 1506 | if ( it.current()->dirty() ) { |
1507 | QString text = i18n( "Data has been changed externally. Unsaved " | 1507 | QString text = i18n( "Data has been changed externally. Unsaved " |
1508 | "changes will be lost." ); | 1508 | "changes will be lost." ); |
1509 | KMessageBox::information( this, text ); | 1509 | KMessageBox::information( this, text ); |
1510 | } | 1510 | } |
1511 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1511 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1512 | ++it; | 1512 | ++it; |
1513 | } | 1513 | } |
1514 | */ | 1514 | */ |
1515 | if (mEditorDialog) | 1515 | if (mEditorDialog) |
1516 | { | 1516 | { |
1517 | if (mEditorDialog->dirty()) | 1517 | if (mEditorDialog->dirty()) |
1518 | { | 1518 | { |
1519 | QString text = i18n( "Data has been changed externally. Unsaved " | 1519 | QString text = i18n( "Data has been changed externally. Unsaved " |
1520 | "changes will be lost." ); | 1520 | "changes will be lost." ); |
1521 | KMessageBox::information( this, text ); | 1521 | KMessageBox::information( this, text ); |
1522 | } | 1522 | } |
1523 | QString currentuid = mEditorDialog->addressee().uid(); | 1523 | QString currentuid = mEditorDialog->addressee().uid(); |
1524 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); | 1524 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); |
1525 | } | 1525 | } |
1526 | mViewManager->refreshView(); | 1526 | mViewManager->refreshView(); |
1527 | // mDetails->refreshView(); | 1527 | // mDetails->refreshView(); |
1528 | 1528 | ||
1529 | 1529 | ||
1530 | } | 1530 | } |
1531 | 1531 | ||
1532 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1532 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1533 | const char *name ) | 1533 | const char *name ) |
1534 | { | 1534 | { |
1535 | 1535 | ||
1536 | if ( mEditorDialog == 0 ) { | 1536 | if ( mEditorDialog == 0 ) { |
1537 | mEditorDialog = new AddresseeEditorDialog( this, parent, | 1537 | mEditorDialog = new AddresseeEditorDialog( this, parent, |
1538 | name ? name : "editorDialog" ); | 1538 | name ? name : "editorDialog" ); |
1539 | 1539 | ||
1540 | 1540 | ||
1541 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1541 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1542 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1542 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1543 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), | 1543 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), |
1544 | // SLOT( slotEditorDestroyed( const QString& ) ) ; | 1544 | // SLOT( slotEditorDestroyed( const QString& ) ) ; |
1545 | } | 1545 | } |
1546 | 1546 | ||
1547 | return mEditorDialog; | 1547 | return mEditorDialog; |
1548 | } | 1548 | } |
1549 | 1549 | ||
1550 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1550 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1551 | { | 1551 | { |
1552 | //mEditorDict.remove( uid ); | 1552 | //mEditorDict.remove( uid ); |
1553 | } | 1553 | } |
1554 | 1554 | ||
1555 | void KABCore::initGUI() | 1555 | void KABCore::initGUI() |
1556 | { | 1556 | { |
1557 | #ifndef KAB_EMBEDDED | 1557 | #ifndef KAB_EMBEDDED |
1558 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1558 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1559 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1559 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1560 | 1560 | ||
1561 | mExtensionBarSplitter = new QSplitter( this ); | 1561 | mExtensionBarSplitter = new QSplitter( this ); |
1562 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1562 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1563 | 1563 | ||
1564 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1564 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1565 | 1565 | ||
1566 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1566 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1567 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1567 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1568 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1568 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1569 | SLOT( incrementalSearch( const QString& ) ) ); | 1569 | SLOT( incrementalSearch( const QString& ) ) ); |
1570 | 1570 | ||
1571 | mViewManager = new ViewManager( this, viewSpace ); | 1571 | mViewManager = new ViewManager( this, viewSpace ); |
1572 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1572 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1573 | 1573 | ||
1574 | mDetails = new ViewContainer( mDetailsSplitter ); | 1574 | mDetails = new ViewContainer( mDetailsSplitter ); |
1575 | 1575 | ||
1576 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1576 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1577 | 1577 | ||
1578 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1578 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1579 | 1579 | ||
1580 | topLayout->addWidget( mExtensionBarSplitter ); | 1580 | topLayout->addWidget( mExtensionBarSplitter ); |
1581 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1581 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1582 | topLayout->addWidget( mJumpButtonBar ); | 1582 | topLayout->addWidget( mJumpButtonBar ); |
1583 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1583 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1584 | 1584 | ||
1585 | mXXPortManager = new XXPortManager( this, this ); | 1585 | mXXPortManager = new XXPortManager( this, this ); |
1586 | 1586 | ||
1587 | #else //KAB_EMBEDDED | 1587 | #else //KAB_EMBEDDED |
1588 | //US initialize viewMenu before settingup viewmanager. | 1588 | //US initialize viewMenu before settingup viewmanager. |
1589 | // Viewmanager needs this menu to plugin submenues. | 1589 | // Viewmanager needs this menu to plugin submenues. |
1590 | viewMenu = new QPopupMenu( this ); | 1590 | viewMenu = new QPopupMenu( this ); |
1591 | settingsMenu = new QPopupMenu( this ); | 1591 | settingsMenu = new QPopupMenu( this ); |
1592 | //filterMenu = new QPopupMenu( this ); | 1592 | //filterMenu = new QPopupMenu( this ); |
1593 | ImportMenu = new QPopupMenu( this ); | 1593 | ImportMenu = new QPopupMenu( this ); |
1594 | ExportMenu = new QPopupMenu( this ); | 1594 | ExportMenu = new QPopupMenu( this ); |
1595 | syncMenu = new QPopupMenu( this ); | 1595 | syncMenu = new QPopupMenu( this ); |
1596 | changeMenu= new QPopupMenu( this ); | 1596 | changeMenu= new QPopupMenu( this ); |
1597 | 1597 | ||
1598 | //US since we have no splitter for the embedded system, setup | 1598 | //US since we have no splitter for the embedded system, setup |
1599 | // a layout with two frames. One left and one right. | 1599 | // a layout with two frames. One left and one right. |
1600 | 1600 | ||
1601 | QBoxLayout *topLayout; | 1601 | QBoxLayout *topLayout; |
1602 | 1602 | ||
1603 | // = new QHBoxLayout( this ); | 1603 | // = new QHBoxLayout( this ); |
1604 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1604 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1605 | 1605 | ||
1606 | // QWidget *mainBox = new QWidget( this ); | 1606 | // QWidget *mainBox = new QWidget( this ); |
1607 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1607 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1608 | 1608 | ||
1609 | #ifdef DESKTOP_VERSION | 1609 | #ifdef DESKTOP_VERSION |
1610 | topLayout = new QHBoxLayout( this ); | 1610 | topLayout = new QHBoxLayout( this ); |
1611 | 1611 | ||
1612 | 1612 | ||
1613 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1613 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1614 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1614 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1615 | 1615 | ||
1616 | topLayout->addWidget(mMiniSplitter ); | 1616 | topLayout->addWidget(mMiniSplitter ); |
1617 | 1617 | ||
1618 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1618 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1619 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1619 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1620 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1620 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1621 | mDetails = new ViewContainer( mMiniSplitter ); | 1621 | mDetails = new ViewContainer( mMiniSplitter ); |
1622 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1622 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1623 | #else | 1623 | #else |
1624 | if ( QApplication::desktop()->width() > 480 ) { | 1624 | if ( QApplication::desktop()->width() > 480 ) { |
1625 | topLayout = new QHBoxLayout( this ); | 1625 | topLayout = new QHBoxLayout( this ); |
1626 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1626 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1627 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1627 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1628 | } else { | 1628 | } else { |
1629 | 1629 | ||
1630 | topLayout = new QHBoxLayout( this ); | 1630 | topLayout = new QHBoxLayout( this ); |
1631 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1631 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1632 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1632 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1633 | } | 1633 | } |
1634 | 1634 | ||
1635 | topLayout->addWidget(mMiniSplitter ); | 1635 | topLayout->addWidget(mMiniSplitter ); |
1636 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1636 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1637 | mDetails = new ViewContainer( mMiniSplitter ); | 1637 | mDetails = new ViewContainer( mMiniSplitter ); |
1638 | 1638 | ||
1639 | 1639 | ||
1640 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1640 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1641 | #endif | 1641 | #endif |
1642 | //eh->hide(); | 1642 | //eh->hide(); |
1643 | // topLayout->addWidget(mExtensionManager ); | 1643 | // topLayout->addWidget(mExtensionManager ); |
1644 | 1644 | ||
1645 | 1645 | ||
1646 | /*US | 1646 | /*US |
1647 | #ifndef KAB_NOSPLITTER | 1647 | #ifndef KAB_NOSPLITTER |
1648 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1648 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1649 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1649 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1650 | topLayout->setSpacing( 10 ); | 1650 | topLayout->setSpacing( 10 ); |
1651 | 1651 | ||
1652 | mDetailsSplitter = new QSplitter( this ); | 1652 | mDetailsSplitter = new QSplitter( this ); |
1653 | 1653 | ||
1654 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1654 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1655 | 1655 | ||
1656 | mViewManager = new ViewManager( this, viewSpace ); | 1656 | mViewManager = new ViewManager( this, viewSpace ); |
1657 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1657 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1658 | 1658 | ||
1659 | mDetails = new ViewContainer( mDetailsSplitter ); | 1659 | mDetails = new ViewContainer( mDetailsSplitter ); |
1660 | 1660 | ||
1661 | topLayout->addWidget( mDetailsSplitter ); | 1661 | topLayout->addWidget( mDetailsSplitter ); |
1662 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1662 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1663 | #else //KAB_NOSPLITTER | 1663 | #else //KAB_NOSPLITTER |
1664 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1664 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1665 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1665 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1666 | topLayout->setSpacing( 10 ); | 1666 | topLayout->setSpacing( 10 ); |
1667 | 1667 | ||
1668 | // mDetailsSplitter = new QSplitter( this ); | 1668 | // mDetailsSplitter = new QSplitter( this ); |
1669 | 1669 | ||
1670 | QVBox *viewSpace = new QVBox( this ); | 1670 | QVBox *viewSpace = new QVBox( this ); |
1671 | 1671 | ||
1672 | mViewManager = new ViewManager( this, viewSpace ); | 1672 | mViewManager = new ViewManager( this, viewSpace ); |
1673 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1673 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1674 | 1674 | ||
1675 | mDetails = new ViewContainer( this ); | 1675 | mDetails = new ViewContainer( this ); |
1676 | 1676 | ||
1677 | topLayout->addWidget( viewSpace ); | 1677 | topLayout->addWidget( viewSpace ); |
1678 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1678 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1679 | topLayout->addWidget( mDetails ); | 1679 | topLayout->addWidget( mDetails ); |
1680 | #endif //KAB_NOSPLITTER | 1680 | #endif //KAB_NOSPLITTER |
1681 | */ | 1681 | */ |
1682 | 1682 | ||
1683 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 1683 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
1684 | syncManager->setBlockSave(false); | 1684 | syncManager->setBlockSave(false); |
1685 | 1685 | ||
1686 | connect(syncManager , SIGNAL( save() ), this, SLOT( save() ) ); | ||
1687 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | ||
1688 | syncManager->setDefaultFileName(locateLocal( "apps","kabc/std.vcf") ); | ||
1689 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); | ||
1686 | 1690 | ||
1687 | #endif //KAB_EMBEDDED | 1691 | #endif //KAB_EMBEDDED |
1688 | initActions(); | 1692 | initActions(); |
1689 | 1693 | ||
1690 | #ifdef KAB_EMBEDDED | 1694 | #ifdef KAB_EMBEDDED |
1691 | addActionsManually(); | 1695 | addActionsManually(); |
1692 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1696 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1693 | mXXPortManager = new XXPortManager( this, this ); | 1697 | mXXPortManager = new XXPortManager( this, this ); |
1694 | 1698 | ||
1695 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1699 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1696 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1700 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1697 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1701 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1698 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1702 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1699 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1703 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1700 | // mIncSearchWidget->hide(); | 1704 | // mIncSearchWidget->hide(); |
1701 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1705 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1702 | SLOT( incrementalSearch( const QString& ) ) ); | 1706 | SLOT( incrementalSearch( const QString& ) ) ); |
1703 | 1707 | ||
1704 | 1708 | ||
1705 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1709 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1706 | 1710 | ||
1707 | topLayout->addWidget( mJumpButtonBar ); | 1711 | topLayout->addWidget( mJumpButtonBar ); |
1708 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1712 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1709 | 1713 | ||
1710 | // mMainWindow->getIconToolBar()->raise(); | 1714 | // mMainWindow->getIconToolBar()->raise(); |
1711 | 1715 | ||
1712 | #endif //KAB_EMBEDDED | 1716 | #endif //KAB_EMBEDDED |
1713 | 1717 | ||
1714 | } | 1718 | } |
1715 | void KABCore::initActions() | 1719 | void KABCore::initActions() |
1716 | { | 1720 | { |
1717 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1721 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1718 | 1722 | ||
1719 | #ifndef KAB_EMBEDDED | 1723 | #ifndef KAB_EMBEDDED |
1720 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1724 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1721 | SLOT( clipboardDataChanged() ) ); | 1725 | SLOT( clipboardDataChanged() ) ); |
1722 | #endif //KAB_EMBEDDED | 1726 | #endif //KAB_EMBEDDED |
1723 | 1727 | ||
1724 | // file menu | 1728 | // file menu |
1725 | if ( mIsPart ) { | 1729 | if ( mIsPart ) { |
1726 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, | 1730 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, |
1727 | SLOT( sendMail() ), actionCollection(), | 1731 | SLOT( sendMail() ), actionCollection(), |
1728 | "kaddressbook_mail" ); | 1732 | "kaddressbook_mail" ); |
1729 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, | 1733 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, |
1730 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); | 1734 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); |
1731 | 1735 | ||
1732 | } else { | 1736 | } else { |
1733 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1737 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1734 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1738 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1735 | } | 1739 | } |
1736 | 1740 | ||
1737 | 1741 | ||
1738 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1742 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1739 | SLOT( save() ), actionCollection(), "file_sync" ); | 1743 | SLOT( save() ), actionCollection(), "file_sync" ); |
1740 | 1744 | ||
1741 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1745 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1742 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1746 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1743 | 1747 | ||
1744 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1748 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1745 | this, SLOT( mailVCard() ), | 1749 | this, SLOT( mailVCard() ), |
1746 | actionCollection(), "file_mail_vcard"); | 1750 | actionCollection(), "file_mail_vcard"); |
1747 | 1751 | ||
1748 | mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, | 1752 | mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, |
1749 | SLOT( export2phone() ), actionCollection(), | 1753 | SLOT( export2phone() ), actionCollection(), |
1750 | "kaddressbook_ex2phone" ); | 1754 | "kaddressbook_ex2phone" ); |
1751 | 1755 | ||
1752 | mActionBeamVCard = 0; | 1756 | mActionBeamVCard = 0; |
1753 | mActionBeam = 0; | 1757 | mActionBeam = 0; |
1754 | 1758 | ||
1755 | #ifndef DESKTOP_VERSION | 1759 | #ifndef DESKTOP_VERSION |
1756 | if ( Ir::supported() ) { | 1760 | if ( Ir::supported() ) { |
1757 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, | 1761 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, |
1758 | SLOT( beamVCard() ), actionCollection(), | 1762 | SLOT( beamVCard() ), actionCollection(), |
1759 | "kaddressbook_beam_vcard" ); | 1763 | "kaddressbook_beam_vcard" ); |
1760 | 1764 | ||
1761 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | 1765 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, |
1762 | SLOT( beamMySelf() ), actionCollection(), | 1766 | SLOT( beamMySelf() ), actionCollection(), |
1763 | "kaddressbook_beam_myself" ); | 1767 | "kaddressbook_beam_myself" ); |
1764 | } | 1768 | } |
1765 | #endif | 1769 | #endif |
1766 | 1770 | ||
1767 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1771 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1768 | this, SLOT( editContact2() ), | 1772 | this, SLOT( editContact2() ), |
1769 | actionCollection(), "file_properties" ); | 1773 | actionCollection(), "file_properties" ); |
1770 | 1774 | ||
1771 | #ifdef KAB_EMBEDDED | 1775 | #ifdef KAB_EMBEDDED |
1772 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1776 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1773 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1777 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1774 | mMainWindow, SLOT( exit() ), | 1778 | mMainWindow, SLOT( exit() ), |
1775 | actionCollection(), "quit" ); | 1779 | actionCollection(), "quit" ); |
1776 | #endif //KAB_EMBEDDED | 1780 | #endif //KAB_EMBEDDED |
1777 | 1781 | ||
1778 | // edit menu | 1782 | // edit menu |
1779 | if ( mIsPart ) { | 1783 | if ( mIsPart ) { |
1780 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1784 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
1781 | SLOT( copyContacts() ), actionCollection(), | 1785 | SLOT( copyContacts() ), actionCollection(), |
1782 | "kaddressbook_copy" ); | 1786 | "kaddressbook_copy" ); |
1783 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 1787 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
1784 | SLOT( cutContacts() ), actionCollection(), | 1788 | SLOT( cutContacts() ), actionCollection(), |
1785 | "kaddressbook_cut" ); | 1789 | "kaddressbook_cut" ); |
1786 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 1790 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
1787 | SLOT( pasteContacts() ), actionCollection(), | 1791 | SLOT( pasteContacts() ), actionCollection(), |
1788 | "kaddressbook_paste" ); | 1792 | "kaddressbook_paste" ); |
1789 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 1793 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
1790 | SLOT( selectAllContacts() ), actionCollection(), | 1794 | SLOT( selectAllContacts() ), actionCollection(), |
1791 | "kaddressbook_select_all" ); | 1795 | "kaddressbook_select_all" ); |
1792 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 1796 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
1793 | SLOT( undo() ), actionCollection(), | 1797 | SLOT( undo() ), actionCollection(), |
1794 | "kaddressbook_undo" ); | 1798 | "kaddressbook_undo" ); |
1795 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 1799 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
1796 | this, SLOT( redo() ), actionCollection(), | 1800 | this, SLOT( redo() ), actionCollection(), |
1797 | "kaddressbook_redo" ); | 1801 | "kaddressbook_redo" ); |
1798 | } else { | 1802 | } else { |
1799 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1803 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1800 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1804 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1801 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1805 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1802 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1806 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1803 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1807 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1804 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1808 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1805 | } | 1809 | } |
1806 | 1810 | ||
1807 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 1811 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
1808 | Key_Delete, this, SLOT( deleteContacts() ), | 1812 | Key_Delete, this, SLOT( deleteContacts() ), |
1809 | actionCollection(), "edit_delete" ); | 1813 | actionCollection(), "edit_delete" ); |
1810 | 1814 | ||
1811 | mActionUndo->setEnabled( false ); | 1815 | mActionUndo->setEnabled( false ); |
1812 | mActionRedo->setEnabled( false ); | 1816 | mActionRedo->setEnabled( false ); |
1813 | 1817 | ||
1814 | // settings menu | 1818 | // settings menu |
1815 | #ifdef KAB_EMBEDDED | 1819 | #ifdef KAB_EMBEDDED |
1816 | //US special menuentry to configure the addressbook resources. On KDE | 1820 | //US special menuentry to configure the addressbook resources. On KDE |
1817 | // you do that through the control center !!! | 1821 | // you do that through the control center !!! |
1818 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 1822 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
1819 | SLOT( configureResources() ), actionCollection(), | 1823 | SLOT( configureResources() ), actionCollection(), |
1820 | "kaddressbook_configure_resources" ); | 1824 | "kaddressbook_configure_resources" ); |
1821 | #endif //KAB_EMBEDDED | 1825 | #endif //KAB_EMBEDDED |
1822 | 1826 | ||
1823 | if ( mIsPart ) { | 1827 | if ( mIsPart ) { |
1824 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 1828 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
1825 | SLOT( openConfigDialog() ), actionCollection(), | 1829 | SLOT( openConfigDialog() ), actionCollection(), |
1826 | "kaddressbook_configure" ); | 1830 | "kaddressbook_configure" ); |
1827 | 1831 | ||
1828 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 1832 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
1829 | this, SLOT( configureKeyBindings() ), actionCollection(), | 1833 | this, SLOT( configureKeyBindings() ), actionCollection(), |
1830 | "kaddressbook_configure_shortcuts" ); | 1834 | "kaddressbook_configure_shortcuts" ); |
1831 | #ifdef KAB_EMBEDDED | 1835 | #ifdef KAB_EMBEDDED |
1832 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 1836 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
1833 | mActionConfigureToolbars->setEnabled( false ); | 1837 | mActionConfigureToolbars->setEnabled( false ); |
1834 | #endif //KAB_EMBEDDED | 1838 | #endif //KAB_EMBEDDED |
1835 | 1839 | ||
1836 | } else { | 1840 | } else { |
1837 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 1841 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
1838 | 1842 | ||
1839 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 1843 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
1840 | } | 1844 | } |
1841 | 1845 | ||
1842 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 1846 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
1843 | actionCollection(), "options_show_jump_bar" ); | 1847 | actionCollection(), "options_show_jump_bar" ); |
1844 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); | 1848 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); |
1845 | 1849 | ||
1846 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, | 1850 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
1847 | actionCollection(), "options_show_details" ); | 1851 | actionCollection(), "options_show_details" ); |
1848 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 1852 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
1849 | 1853 | ||
1850 | // misc | 1854 | // misc |
1851 | // only enable LDAP lookup if we can handle the protocol | 1855 | // only enable LDAP lookup if we can handle the protocol |
1852 | #ifndef KAB_EMBEDDED | 1856 | #ifndef KAB_EMBEDDED |
1853 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 1857 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
1854 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 1858 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
1855 | this, SLOT( openLDAPDialog() ), actionCollection(), | 1859 | this, SLOT( openLDAPDialog() ), actionCollection(), |
1856 | "ldap_lookup" ); | 1860 | "ldap_lookup" ); |
1857 | } | 1861 | } |
1858 | #else //KAB_EMBEDDED | 1862 | #else //KAB_EMBEDDED |
1859 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 1863 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
1860 | #endif //KAB_EMBEDDED | 1864 | #endif //KAB_EMBEDDED |
1861 | 1865 | ||
1862 | 1866 | ||
1863 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 1867 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
1864 | SLOT( setWhoAmI() ), actionCollection(), | 1868 | SLOT( setWhoAmI() ), actionCollection(), |
1865 | "set_personal" ); | 1869 | "set_personal" ); |
1866 | 1870 | ||
1867 | 1871 | ||
1868 | 1872 | ||
1869 | 1873 | ||
1870 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 1874 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
1871 | SLOT( setCategories() ), actionCollection(), | 1875 | SLOT( setCategories() ), actionCollection(), |
1872 | "edit_set_categories" ); | 1876 | "edit_set_categories" ); |
1873 | 1877 | ||
1874 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 1878 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
1875 | SLOT( removeVoice() ), actionCollection(), | 1879 | SLOT( removeVoice() ), actionCollection(), |
1876 | "remove_voice" ); | 1880 | "remove_voice" ); |
1877 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, | 1881 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, |
1878 | SLOT( importFromOL() ), actionCollection(), | 1882 | SLOT( importFromOL() ), actionCollection(), |
1879 | "import_OL" ); | 1883 | "import_OL" ); |
1880 | #ifdef KAB_EMBEDDED | 1884 | #ifdef KAB_EMBEDDED |
1881 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 1885 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
1882 | this, SLOT( showLicence() ), actionCollection(), | 1886 | this, SLOT( showLicence() ), actionCollection(), |
1883 | "licence_about_data" ); | 1887 | "licence_about_data" ); |
1884 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 1888 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
1885 | this, SLOT( faq() ), actionCollection(), | 1889 | this, SLOT( faq() ), actionCollection(), |
1886 | "faq_about_data" ); | 1890 | "faq_about_data" ); |
1887 | 1891 | ||
1888 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 1892 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
1889 | this, SLOT( createAboutData() ), actionCollection(), | 1893 | this, SLOT( createAboutData() ), actionCollection(), |
1890 | "kaddressbook_about_data" ); | 1894 | "kaddressbook_about_data" ); |
1891 | #endif //KAB_EMBEDDED | 1895 | #endif //KAB_EMBEDDED |
1892 | 1896 | ||
1893 | clipboardDataChanged(); | 1897 | clipboardDataChanged(); |
1894 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1898 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1895 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1899 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1896 | } | 1900 | } |
1897 | 1901 | ||
1898 | //US we need this function, to plug all actions into the correct menues. | 1902 | //US we need this function, to plug all actions into the correct menues. |
1899 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 1903 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
1900 | void KABCore::addActionsManually() | 1904 | void KABCore::addActionsManually() |
1901 | { | 1905 | { |
1902 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1906 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1903 | 1907 | ||
1904 | #ifdef KAB_EMBEDDED | 1908 | #ifdef KAB_EMBEDDED |
1905 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 1909 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
1906 | QPopupMenu *editMenu = new QPopupMenu( this ); | 1910 | QPopupMenu *editMenu = new QPopupMenu( this ); |
1907 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 1911 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
1908 | 1912 | ||
1909 | KToolBar* tb = mMainWindow->toolBar(); | 1913 | KToolBar* tb = mMainWindow->toolBar(); |
1910 | 1914 | ||
1911 | #ifdef DESKTOP_VERSION | 1915 | #ifdef DESKTOP_VERSION |
1912 | QMenuBar* mb = mMainWindow->menuBar(); | 1916 | QMenuBar* mb = mMainWindow->menuBar(); |
1913 | 1917 | ||
1914 | //US setup menubar. | 1918 | //US setup menubar. |
1915 | //Disable the following block if you do not want to have a menubar. | 1919 | //Disable the following block if you do not want to have a menubar. |
1916 | mb->insertItem( "&File", fileMenu ); | 1920 | mb->insertItem( "&File", fileMenu ); |
1917 | mb->insertItem( "&Edit", editMenu ); | 1921 | mb->insertItem( "&Edit", editMenu ); |
1918 | mb->insertItem( "&View", viewMenu ); | 1922 | mb->insertItem( "&View", viewMenu ); |
1919 | mb->insertItem( "&Settings", settingsMenu ); | 1923 | mb->insertItem( "&Settings", settingsMenu ); |
1920 | mb->insertItem( i18n("Synchronize"), syncMenu ); | 1924 | mb->insertItem( i18n("Synchronize"), syncMenu ); |
1921 | mb->insertItem( "&Change selected", changeMenu ); | 1925 | mb->insertItem( "&Change selected", changeMenu ); |
1922 | mb->insertItem( "&Help", helpMenu ); | 1926 | mb->insertItem( "&Help", helpMenu ); |
1923 | mIncSearchWidget = new IncSearchWidget( tb ); | 1927 | mIncSearchWidget = new IncSearchWidget( tb ); |
1924 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 1928 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
1925 | 1929 | ||
1926 | #else | 1930 | #else |
1927 | //US setup toolbar | 1931 | //US setup toolbar |
1928 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 1932 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
1929 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 1933 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
1930 | menuBarTB->insertItem( "ME", popupBarTB); | 1934 | menuBarTB->insertItem( "ME", popupBarTB); |
1931 | tb->insertWidget(-1, 0, menuBarTB); | 1935 | tb->insertWidget(-1, 0, menuBarTB); |
1932 | mIncSearchWidget = new IncSearchWidget( tb ); | 1936 | mIncSearchWidget = new IncSearchWidget( tb ); |
1933 | 1937 | ||
1934 | tb->enableMoving(false); | 1938 | tb->enableMoving(false); |
1935 | popupBarTB->insertItem( "&File", fileMenu ); | 1939 | popupBarTB->insertItem( "&File", fileMenu ); |
1936 | popupBarTB->insertItem( "&Edit", editMenu ); | 1940 | popupBarTB->insertItem( "&Edit", editMenu ); |
1937 | popupBarTB->insertItem( "&View", viewMenu ); | 1941 | popupBarTB->insertItem( "&View", viewMenu ); |
1938 | popupBarTB->insertItem( "&Settings", settingsMenu ); | 1942 | popupBarTB->insertItem( "&Settings", settingsMenu ); |
1939 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); | 1943 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); |
1940 | mViewManager->getFilterAction()->plug ( popupBarTB); | 1944 | mViewManager->getFilterAction()->plug ( popupBarTB); |
1941 | popupBarTB->insertItem( "&Change selected", changeMenu ); | 1945 | popupBarTB->insertItem( "&Change selected", changeMenu ); |
1942 | popupBarTB->insertItem( "&Help", helpMenu ); | 1946 | popupBarTB->insertItem( "&Help", helpMenu ); |
1943 | if (QApplication::desktop()->width() > 320 ) { | 1947 | if (QApplication::desktop()->width() > 320 ) { |
1944 | // mViewManager->getFilterAction()->plug ( tb); | 1948 | // mViewManager->getFilterAction()->plug ( tb); |
1945 | } | 1949 | } |
1946 | #endif | 1950 | #endif |
1947 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1951 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1948 | 1952 | ||
1949 | 1953 | ||
1950 | 1954 | ||
1951 | //US Now connect the actions with the menue entries. | 1955 | //US Now connect the actions with the menue entries. |
1952 | mActionPrint->plug( fileMenu ); | 1956 | mActionPrint->plug( fileMenu ); |
1953 | mActionMail->plug( fileMenu ); | 1957 | mActionMail->plug( fileMenu ); |
1954 | fileMenu->insertSeparator(); | 1958 | fileMenu->insertSeparator(); |
1955 | 1959 | ||
1956 | mActionNewContact->plug( fileMenu ); | 1960 | mActionNewContact->plug( fileMenu ); |
1957 | mActionNewContact->plug( tb ); | 1961 | mActionNewContact->plug( tb ); |
1958 | 1962 | ||
1959 | mActionEditAddressee->plug( fileMenu ); | 1963 | mActionEditAddressee->plug( fileMenu ); |
1960 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 1964 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
1961 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 1965 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
1962 | mActionEditAddressee->plug( tb ); | 1966 | mActionEditAddressee->plug( tb ); |
1963 | 1967 | ||
1964 | fileMenu->insertSeparator(); | 1968 | fileMenu->insertSeparator(); |
1965 | mActionSave->plug( fileMenu ); | 1969 | mActionSave->plug( fileMenu ); |
1966 | fileMenu->insertItem( "&Import", ImportMenu ); | 1970 | fileMenu->insertItem( "&Import", ImportMenu ); |
1967 | fileMenu->insertItem( "&Export", ExportMenu ); | 1971 | fileMenu->insertItem( "&Export", ExportMenu ); |
1968 | fileMenu->insertSeparator(); | 1972 | fileMenu->insertSeparator(); |
1969 | mActionMailVCard->plug( fileMenu ); | 1973 | mActionMailVCard->plug( fileMenu ); |
1970 | #ifndef DESKTOP_VERSION | 1974 | #ifndef DESKTOP_VERSION |
1971 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); | 1975 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); |
1972 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); | 1976 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); |
1973 | #endif | 1977 | #endif |
1974 | fileMenu->insertSeparator(); | 1978 | fileMenu->insertSeparator(); |
1975 | mActionQuit->plug( fileMenu ); | 1979 | mActionQuit->plug( fileMenu ); |
1976 | #ifdef _WIN32_ | 1980 | #ifdef _WIN32_ |
1977 | mActionImportOL->plug( ImportMenu ); | 1981 | mActionImportOL->plug( ImportMenu ); |
1978 | #endif | 1982 | #endif |
1979 | // edit menu | 1983 | // edit menu |
1980 | mActionUndo->plug( editMenu ); | 1984 | mActionUndo->plug( editMenu ); |
1981 | mActionRedo->plug( editMenu ); | 1985 | mActionRedo->plug( editMenu ); |
1982 | editMenu->insertSeparator(); | 1986 | editMenu->insertSeparator(); |
1983 | mActionCut->plug( editMenu ); | 1987 | mActionCut->plug( editMenu ); |
1984 | mActionCopy->plug( editMenu ); | 1988 | mActionCopy->plug( editMenu ); |
1985 | mActionPaste->plug( editMenu ); | 1989 | mActionPaste->plug( editMenu ); |
1986 | mActionDelete->plug( editMenu ); | 1990 | mActionDelete->plug( editMenu ); |
1987 | editMenu->insertSeparator(); | 1991 | editMenu->insertSeparator(); |
1988 | mActionSelectAll->plug( editMenu ); | 1992 | mActionSelectAll->plug( editMenu ); |
1989 | 1993 | ||
1990 | mActionRemoveVoice->plug( changeMenu ); | 1994 | mActionRemoveVoice->plug( changeMenu ); |
1991 | // settings menu | 1995 | // settings menu |
1992 | //US special menuentry to configure the addressbook resources. On KDE | 1996 | //US special menuentry to configure the addressbook resources. On KDE |
1993 | // you do that through the control center !!! | 1997 | // you do that through the control center !!! |
1994 | mActionConfigResources->plug( settingsMenu ); | 1998 | mActionConfigResources->plug( settingsMenu ); |
1995 | settingsMenu->insertSeparator(); | 1999 | settingsMenu->insertSeparator(); |
1996 | 2000 | ||
1997 | mActionConfigKAddressbook->plug( settingsMenu ); | 2001 | mActionConfigKAddressbook->plug( settingsMenu ); |
1998 | 2002 | ||
1999 | if ( mIsPart ) { | 2003 | if ( mIsPart ) { |
2000 | mActionConfigShortcuts->plug( settingsMenu ); | 2004 | mActionConfigShortcuts->plug( settingsMenu ); |
2001 | mActionConfigureToolbars->plug( settingsMenu ); | 2005 | mActionConfigureToolbars->plug( settingsMenu ); |
2002 | 2006 | ||
2003 | } else { | 2007 | } else { |
2004 | mActionKeyBindings->plug( settingsMenu ); | 2008 | mActionKeyBindings->plug( settingsMenu ); |
2005 | } | 2009 | } |
2006 | 2010 | ||
2007 | settingsMenu->insertSeparator(); | 2011 | settingsMenu->insertSeparator(); |
2008 | 2012 | ||
2009 | mActionJumpBar->plug( settingsMenu ); | 2013 | mActionJumpBar->plug( settingsMenu ); |
2010 | mActionDetails->plug( settingsMenu ); | 2014 | mActionDetails->plug( settingsMenu ); |
2011 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 2015 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
2012 | mActionDetails->plug( tb ); | 2016 | mActionDetails->plug( tb ); |
2013 | settingsMenu->insertSeparator(); | 2017 | settingsMenu->insertSeparator(); |
2014 | 2018 | ||
2015 | mActionWhoAmI->plug( settingsMenu ); | 2019 | mActionWhoAmI->plug( settingsMenu ); |
2016 | mActionCategories->plug( settingsMenu ); | 2020 | mActionCategories->plug( settingsMenu ); |
2017 | 2021 | ||
2018 | mActionLicence->plug( helpMenu ); | 2022 | mActionLicence->plug( helpMenu ); |
2019 | mActionFaq->plug( helpMenu ); | 2023 | mActionFaq->plug( helpMenu ); |
2020 | mActionAboutKAddressbook->plug( helpMenu ); | 2024 | mActionAboutKAddressbook->plug( helpMenu ); |
2021 | 2025 | ||
2022 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 2026 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
2023 | 2027 | ||
2024 | mActionSave->plug( tb ); | 2028 | mActionSave->plug( tb ); |
2025 | mViewManager->getFilterAction()->plug ( tb); | 2029 | mViewManager->getFilterAction()->plug ( tb); |
2026 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { | 2030 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { |
2027 | mActionUndo->plug( tb ); | 2031 | mActionUndo->plug( tb ); |
2028 | mActionDelete->plug( tb ); | 2032 | mActionDelete->plug( tb ); |
2029 | mActionRedo->plug( tb ); | 2033 | mActionRedo->plug( tb ); |
2030 | } | 2034 | } |
2031 | } | 2035 | } |
2032 | //mActionQuit->plug ( tb ); | 2036 | //mActionQuit->plug ( tb ); |
2033 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 2037 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
2034 | 2038 | ||
2035 | //US link the searchwidget first to this. | 2039 | //US link the searchwidget first to this. |
2036 | // The real linkage to the toolbar happens later. | 2040 | // The real linkage to the toolbar happens later. |
2037 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 2041 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
2038 | //US tb->insertItem( mIncSearchWidget ); | 2042 | //US tb->insertItem( mIncSearchWidget ); |
2039 | /*US | 2043 | /*US |
2040 | mIncSearchWidget = new IncSearchWidget( tb ); | 2044 | mIncSearchWidget = new IncSearchWidget( tb ); |
2041 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 2045 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
2042 | SLOT( incrementalSearch( const QString& ) ) ); | 2046 | SLOT( incrementalSearch( const QString& ) ) ); |
2043 | 2047 | ||
2044 | mJumpButtonBar = new JumpButtonBar( this, this ); | 2048 | mJumpButtonBar = new JumpButtonBar( this, this ); |
2045 | 2049 | ||
2046 | //US topLayout->addWidget( mJumpButtonBar ); | 2050 | //US topLayout->addWidget( mJumpButtonBar ); |
2047 | this->layout()->add( mJumpButtonBar ); | 2051 | this->layout()->add( mJumpButtonBar ); |
2048 | */ | 2052 | */ |
2049 | 2053 | ||
2050 | #endif //KAB_EMBEDDED | 2054 | #endif //KAB_EMBEDDED |
2051 | 2055 | ||
2052 | mActionExport2phone->plug( ExportMenu ); | 2056 | mActionExport2phone->plug( ExportMenu ); |
2053 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 2057 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
2054 | syncManager->fillSyncMenu(); | 2058 | syncManager->fillSyncMenu(); |
2055 | 2059 | ||
2056 | } | 2060 | } |
2057 | void KABCore::showLicence() | 2061 | void KABCore::showLicence() |
2058 | { | 2062 | { |
2059 | KApplication::showLicence(); | 2063 | KApplication::showLicence(); |
2060 | } | 2064 | } |
2061 | void KABCore::removeVoice() | 2065 | void KABCore::removeVoice() |
2062 | { | 2066 | { |
2063 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) | 2067 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) |
2064 | return; | 2068 | return; |
2065 | KABC::Addressee::List list = mViewManager->selectedAddressees(); | 2069 | KABC::Addressee::List list = mViewManager->selectedAddressees(); |
2066 | KABC::Addressee::List::Iterator it; | 2070 | KABC::Addressee::List::Iterator it; |
2067 | for ( it = list.begin(); it != list.end(); ++it ) { | 2071 | for ( it = list.begin(); it != list.end(); ++it ) { |
2068 | PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); | 2072 | PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); |
2069 | PhoneNumber::List::Iterator phoneIt; | 2073 | PhoneNumber::List::Iterator phoneIt; |
2070 | bool found = false; | 2074 | bool found = false; |
2071 | for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { | 2075 | for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { |
2072 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found | 2076 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found |
2073 | if ((*phoneIt).type() - PhoneNumber::Voice ) { | 2077 | if ((*phoneIt).type() - PhoneNumber::Voice ) { |
2074 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); | 2078 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); |
2075 | (*it).insertPhoneNumber( (*phoneIt) ); | 2079 | (*it).insertPhoneNumber( (*phoneIt) ); |
2076 | found = true; | 2080 | found = true; |
2077 | } | 2081 | } |
2078 | } | 2082 | } |
2079 | 2083 | ||
2080 | } | 2084 | } |
2081 | if ( found ) | 2085 | if ( found ) |
2082 | contactModified((*it) ); | 2086 | contactModified((*it) ); |
2083 | } | 2087 | } |
2084 | } | 2088 | } |
2085 | 2089 | ||
2086 | 2090 | ||
2087 | 2091 | ||
2088 | void KABCore::clipboardDataChanged() | 2092 | void KABCore::clipboardDataChanged() |
2089 | { | 2093 | { |
2090 | 2094 | ||
2091 | if ( mReadWrite ) | 2095 | if ( mReadWrite ) |
2092 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 2096 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
2093 | 2097 | ||
2094 | } | 2098 | } |
2095 | 2099 | ||
2096 | void KABCore::updateActionMenu() | 2100 | void KABCore::updateActionMenu() |
2097 | { | 2101 | { |
2098 | UndoStack *undo = UndoStack::instance(); | 2102 | UndoStack *undo = UndoStack::instance(); |
2099 | RedoStack *redo = RedoStack::instance(); | 2103 | RedoStack *redo = RedoStack::instance(); |
2100 | 2104 | ||
2101 | if ( undo->isEmpty() ) | 2105 | if ( undo->isEmpty() ) |
2102 | mActionUndo->setText( i18n( "Undo" ) ); | 2106 | mActionUndo->setText( i18n( "Undo" ) ); |
2103 | else | 2107 | else |
2104 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 2108 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
2105 | 2109 | ||
2106 | mActionUndo->setEnabled( !undo->isEmpty() ); | 2110 | mActionUndo->setEnabled( !undo->isEmpty() ); |
2107 | 2111 | ||
2108 | if ( !redo->top() ) | 2112 | if ( !redo->top() ) |
2109 | mActionRedo->setText( i18n( "Redo" ) ); | 2113 | mActionRedo->setText( i18n( "Redo" ) ); |
2110 | else | 2114 | else |
2111 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 2115 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
2112 | 2116 | ||
2113 | mActionRedo->setEnabled( !redo->isEmpty() ); | 2117 | mActionRedo->setEnabled( !redo->isEmpty() ); |
2114 | } | 2118 | } |
2115 | 2119 | ||
2116 | void KABCore::configureKeyBindings() | 2120 | void KABCore::configureKeyBindings() |
2117 | { | 2121 | { |
2118 | #ifndef KAB_EMBEDDED | 2122 | #ifndef KAB_EMBEDDED |
2119 | KKeyDialog::configure( actionCollection(), true ); | 2123 | KKeyDialog::configure( actionCollection(), true ); |
2120 | #else //KAB_EMBEDDED | 2124 | #else //KAB_EMBEDDED |
2121 | qDebug("KABCore::configureKeyBindings() not implemented"); | 2125 | qDebug("KABCore::configureKeyBindings() not implemented"); |
2122 | #endif //KAB_EMBEDDED | 2126 | #endif //KAB_EMBEDDED |
2123 | } | 2127 | } |
2124 | 2128 | ||
2125 | #ifdef KAB_EMBEDDED | 2129 | #ifdef KAB_EMBEDDED |
2126 | void KABCore::configureResources() | 2130 | void KABCore::configureResources() |
2127 | { | 2131 | { |
2128 | KRES::KCMKResources dlg( this, "" , 0 ); | 2132 | KRES::KCMKResources dlg( this, "" , 0 ); |
2129 | 2133 | ||
2130 | if ( !dlg.exec() ) | 2134 | if ( !dlg.exec() ) |
2131 | return; | 2135 | return; |
2132 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 2136 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
2133 | } | 2137 | } |
2134 | #endif //KAB_EMBEDDED | 2138 | #endif //KAB_EMBEDDED |
2135 | 2139 | ||
2136 | 2140 | ||
2137 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 2141 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
2138 | * for the attendees list of an event. | 2142 | * for the attendees list of an event. |
2139 | */ | 2143 | */ |
2140 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 2144 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
2141 | { | 2145 | { |
2142 | QStringList nameList; | 2146 | QStringList nameList; |
2143 | QStringList emailList; | 2147 | QStringList emailList; |
2144 | QStringList uidList; | 2148 | QStringList uidList; |
2145 | 2149 | ||
2146 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 2150 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
2147 | uint i=0; | 2151 | uint i=0; |
2148 | for (i=0; i < list.count(); i++) | 2152 | for (i=0; i < list.count(); i++) |
2149 | { | 2153 | { |
2150 | nameList.append(list[i].realName()); | 2154 | nameList.append(list[i].realName()); |
2151 | emailList.append(list[i].preferredEmail()); | 2155 | emailList.append(list[i].preferredEmail()); |
2152 | uidList.append(list[i].uid()); | 2156 | uidList.append(list[i].uid()); |
2153 | } | 2157 | } |
2154 | 2158 | ||
2155 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); | 2159 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); |
2156 | 2160 | ||
2157 | } | 2161 | } |
2158 | 2162 | ||
2159 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays | 2163 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays |
2160 | * to put them into the calendar. | 2164 | * to put them into the calendar. |
2161 | */ | 2165 | */ |
2162 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) | 2166 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) |
2163 | { | 2167 | { |
2164 | // qDebug("KABCore::requestForBirthdayList"); | 2168 | // qDebug("KABCore::requestForBirthdayList"); |
2165 | QStringList birthdayList; | 2169 | QStringList birthdayList; |
2166 | QStringList anniversaryList; | 2170 | QStringList anniversaryList; |
2167 | QStringList realNameList; | 2171 | QStringList realNameList; |
2168 | QStringList preferredEmailList; | 2172 | QStringList preferredEmailList; |
2169 | QStringList assembledNameList; | 2173 | QStringList assembledNameList; |
2170 | QStringList uidList; | 2174 | QStringList uidList; |
2171 | 2175 | ||
2172 | KABC::AddressBook::Iterator it; | 2176 | KABC::AddressBook::Iterator it; |
2173 | 2177 | ||
2174 | int count = 0; | 2178 | int count = 0; |
2175 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2179 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2176 | ++count; | 2180 | ++count; |
2177 | } | 2181 | } |
2178 | QProgressBar bar(count,0 ); | 2182 | QProgressBar bar(count,0 ); |
2179 | int w = 300; | 2183 | int w = 300; |
2180 | if ( QApplication::desktop()->width() < 320 ) | 2184 | if ( QApplication::desktop()->width() < 320 ) |
2181 | w = 220; | 2185 | w = 220; |
2182 | int h = bar.sizeHint().height() ; | 2186 | int h = bar.sizeHint().height() ; |
2183 | int dw = QApplication::desktop()->width(); | 2187 | int dw = QApplication::desktop()->width(); |
2184 | int dh = QApplication::desktop()->height(); | 2188 | int dh = QApplication::desktop()->height(); |
2185 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2189 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2186 | bar.show(); | 2190 | bar.show(); |
2187 | bar.setCaption (i18n("collecting birthdays - close to abort!") ); | 2191 | bar.setCaption (i18n("collecting birthdays - close to abort!") ); |
2188 | qApp->processEvents(); | 2192 | qApp->processEvents(); |
2189 | 2193 | ||
2190 | QDate bday; | 2194 | QDate bday; |
2191 | QString anni; | 2195 | QString anni; |
2192 | QString formattedbday; | 2196 | QString formattedbday; |
2193 | 2197 | ||
2194 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) | 2198 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) |
2195 | { | 2199 | { |
2196 | if ( ! bar.isVisible() ) | 2200 | if ( ! bar.isVisible() ) |
2197 | return; | 2201 | return; |
2198 | bar.setProgress( count++ ); | 2202 | bar.setProgress( count++ ); |
2199 | qApp->processEvents(); | 2203 | qApp->processEvents(); |
2200 | bday = (*it).birthday().date(); | 2204 | bday = (*it).birthday().date(); |
2201 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); | 2205 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); |
2202 | 2206 | ||
2203 | if ( bday.isValid() || !anni.isEmpty()) | 2207 | if ( bday.isValid() || !anni.isEmpty()) |
2204 | { | 2208 | { |
2205 | if (bday.isValid()) | 2209 | if (bday.isValid()) |
2206 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); | 2210 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); |
2207 | else | 2211 | else |
2208 | formattedbday = "NOTVALID"; | 2212 | formattedbday = "NOTVALID"; |
2209 | if (anni.isEmpty()) | 2213 | if (anni.isEmpty()) |
2210 | anni = "INVALID"; | 2214 | anni = "INVALID"; |
2211 | 2215 | ||
2212 | birthdayList.append(formattedbday); | 2216 | birthdayList.append(formattedbday); |
2213 | anniversaryList.append(anni); //should be ISODate | 2217 | anniversaryList.append(anni); //should be ISODate |
2214 | realNameList.append((*it).realName()); | 2218 | realNameList.append((*it).realName()); |
2215 | preferredEmailList.append((*it).preferredEmail()); | 2219 | preferredEmailList.append((*it).preferredEmail()); |
2216 | assembledNameList.append((*it).assembledName()); | 2220 | assembledNameList.append((*it).assembledName()); |
2217 | uidList.append((*it).uid()); | 2221 | uidList.append((*it).uid()); |
2218 | 2222 | ||
2219 | qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); | 2223 | qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); |
2220 | } | 2224 | } |
2221 | } | 2225 | } |
2222 | 2226 | ||
2223 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); | 2227 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); |
2224 | 2228 | ||
2225 | } | 2229 | } |
2226 | 2230 | ||
2227 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2231 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2228 | */ | 2232 | */ |
2229 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2233 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2230 | { | 2234 | { |
2231 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2235 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2232 | 2236 | ||
2233 | QString foundUid = QString::null; | 2237 | QString foundUid = QString::null; |
2234 | if ( ! uid.isEmpty() ) { | 2238 | if ( ! uid.isEmpty() ) { |
2235 | Addressee adrr = mAddressBook->findByUid( uid ); | 2239 | Addressee adrr = mAddressBook->findByUid( uid ); |
2236 | if ( !adrr.isEmpty() ) { | 2240 | if ( !adrr.isEmpty() ) { |
2237 | foundUid = uid; | 2241 | foundUid = uid; |
2238 | } | 2242 | } |
2239 | if ( email == "sendbacklist" ) { | 2243 | if ( email == "sendbacklist" ) { |
2240 | //qDebug("ssssssssssssssssssssssend "); | 2244 | //qDebug("ssssssssssssssssssssssend "); |
2241 | QStringList nameList; | 2245 | QStringList nameList; |
2242 | QStringList emailList; | 2246 | QStringList emailList; |
2243 | QStringList uidList; | 2247 | QStringList uidList; |
2244 | nameList.append(adrr.realName()); | 2248 | nameList.append(adrr.realName()); |
2245 | emailList = adrr.emails(); | 2249 | emailList = adrr.emails(); |
2246 | uidList.append( adrr.preferredEmail()); | 2250 | uidList.append( adrr.preferredEmail()); |
2247 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2251 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2248 | return; | 2252 | return; |
2249 | } | 2253 | } |
2250 | 2254 | ||
2251 | } | 2255 | } |
2252 | 2256 | ||
2253 | if ( email == "sendbacklist" ) | 2257 | if ( email == "sendbacklist" ) |
2254 | return; | 2258 | return; |
2255 | if (foundUid.isEmpty()) | 2259 | if (foundUid.isEmpty()) |
2256 | { | 2260 | { |
2257 | //find the uid of the person first | 2261 | //find the uid of the person first |
2258 | Addressee::List namelist; | 2262 | Addressee::List namelist; |
2259 | Addressee::List emaillist; | 2263 | Addressee::List emaillist; |
2260 | 2264 | ||
2261 | if (!name.isEmpty()) | 2265 | if (!name.isEmpty()) |
2262 | namelist = mAddressBook->findByName( name ); | 2266 | namelist = mAddressBook->findByName( name ); |
2263 | 2267 | ||
2264 | if (!email.isEmpty()) | 2268 | if (!email.isEmpty()) |
2265 | emaillist = mAddressBook->findByEmail( email ); | 2269 | emaillist = mAddressBook->findByEmail( email ); |
2266 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2270 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2267 | //check if we have a match in Namelist and Emaillist | 2271 | //check if we have a match in Namelist and Emaillist |
2268 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2272 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2269 | foundUid = emaillist[0].uid(); | 2273 | foundUid = emaillist[0].uid(); |
2270 | } | 2274 | } |
2271 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2275 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2272 | foundUid = namelist[0].uid(); | 2276 | foundUid = namelist[0].uid(); |
2273 | else | 2277 | else |
2274 | { | 2278 | { |
2275 | for (int i = 0; i < namelist.count(); i++) | 2279 | for (int i = 0; i < namelist.count(); i++) |
2276 | { | 2280 | { |
2277 | for (int j = 0; j < emaillist.count(); j++) | 2281 | for (int j = 0; j < emaillist.count(); j++) |
2278 | { | 2282 | { |
2279 | if (namelist[i] == emaillist[j]) | 2283 | if (namelist[i] == emaillist[j]) |
2280 | { | 2284 | { |
2281 | foundUid = namelist[i].uid(); | 2285 | foundUid = namelist[i].uid(); |
2282 | } | 2286 | } |
2283 | } | 2287 | } |
2284 | } | 2288 | } |
2285 | } | 2289 | } |
2286 | } | 2290 | } |
2287 | else | 2291 | else |
2288 | { | 2292 | { |
2289 | foundUid = uid; | 2293 | foundUid = uid; |
2290 | } | 2294 | } |
2291 | 2295 | ||
2292 | if (!foundUid.isEmpty()) | 2296 | if (!foundUid.isEmpty()) |
2293 | { | 2297 | { |
2294 | 2298 | ||
2295 | // raise Ka/Pi if it is in the background | 2299 | // raise Ka/Pi if it is in the background |
2296 | #ifndef DESKTOP_VERSION | 2300 | #ifndef DESKTOP_VERSION |
2297 | #ifndef KORG_NODCOP | 2301 | #ifndef KORG_NODCOP |
2298 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2302 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2299 | #endif | 2303 | #endif |
2300 | #endif | 2304 | #endif |
2301 | 2305 | ||
2302 | mMainWindow->showMaximized(); | 2306 | mMainWindow->showMaximized(); |
2303 | mMainWindow-> raise(); | 2307 | mMainWindow-> raise(); |
2304 | 2308 | ||
2305 | mViewManager->setSelected( "", false); | 2309 | mViewManager->setSelected( "", false); |
2306 | mViewManager->refreshView( "" ); | 2310 | mViewManager->refreshView( "" ); |
2307 | mViewManager->setSelected( foundUid, true ); | 2311 | mViewManager->setSelected( foundUid, true ); |
2308 | mViewManager->refreshView( foundUid ); | 2312 | mViewManager->refreshView( foundUid ); |
2309 | 2313 | ||
2310 | if ( !mMultipleViewsAtOnce ) | 2314 | if ( !mMultipleViewsAtOnce ) |
2311 | { | 2315 | { |
2312 | setDetailsVisible( true ); | 2316 | setDetailsVisible( true ); |
2313 | mActionDetails->setChecked(true); | 2317 | mActionDetails->setChecked(true); |
2314 | } | 2318 | } |
2315 | } | 2319 | } |
2316 | } | 2320 | } |
2317 | 2321 | ||
2318 | 2322 | ||
2319 | void KABCore::faq() | 2323 | void KABCore::faq() |
2320 | { | 2324 | { |
2321 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2325 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2322 | } | 2326 | } |
2323 | 2327 | ||
2324 | #include <libkcal/syncdefines.h> | 2328 | #include <libkcal/syncdefines.h> |
2325 | 2329 | ||
2326 | KABC::Addressee KABCore::getLastSyncAddressee() | 2330 | KABC::Addressee KABCore::getLastSyncAddressee() |
2327 | { | 2331 | { |
2328 | Addressee lse; | 2332 | Addressee lse; |
2329 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2333 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2330 | 2334 | ||
2331 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2335 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2332 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2336 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2333 | if (lse.isEmpty()) { | 2337 | if (lse.isEmpty()) { |
2334 | qDebug("Creating new last-syncAddressee "); | 2338 | qDebug("Creating new last-syncAddressee "); |
2335 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2339 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2336 | QString sum = ""; | 2340 | QString sum = ""; |
2337 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2341 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2338 | sum = "E: "; | 2342 | sum = "E: "; |
2339 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2343 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2340 | lse.setRevision( mLastAddressbookSync ); | 2344 | lse.setRevision( mLastAddressbookSync ); |
2341 | lse.setCategories( i18n("SyncEvent") ); | 2345 | lse.setCategories( i18n("SyncEvent") ); |
2342 | mAddressBook->insertAddressee( lse ); | 2346 | mAddressBook->insertAddressee( lse ); |
2343 | } | 2347 | } |
2344 | return lse; | 2348 | return lse; |
2345 | } | 2349 | } |
2346 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2350 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2347 | { | 2351 | { |
2348 | 2352 | ||
2349 | //void setZaurusId(int id); | 2353 | //void setZaurusId(int id); |
2350 | // int zaurusId() const; | 2354 | // int zaurusId() const; |
2351 | // void setZaurusUid(int id); | 2355 | // void setZaurusUid(int id); |
2352 | // int zaurusUid() const; | 2356 | // int zaurusUid() const; |
2353 | // void setZaurusStat(int id); | 2357 | // void setZaurusStat(int id); |
2354 | // int zaurusStat() const; | 2358 | // int zaurusStat() const; |
2355 | // 0 equal | 2359 | // 0 equal |
2356 | // 1 take local | 2360 | // 1 take local |
2357 | // 2 take remote | 2361 | // 2 take remote |
2358 | // 3 cancel | 2362 | // 3 cancel |
2359 | QDateTime lastSync = mLastAddressbookSync; | 2363 | QDateTime lastSync = mLastAddressbookSync; |
2360 | QDateTime localMod = local->revision(); | 2364 | QDateTime localMod = local->revision(); |
2361 | QDateTime remoteMod = remote->revision(); | 2365 | QDateTime remoteMod = remote->revision(); |
2362 | 2366 | ||
2363 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2367 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2364 | 2368 | ||
2365 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2369 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2366 | bool remCh, locCh; | 2370 | bool remCh, locCh; |
2367 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2371 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2368 | 2372 | ||
2369 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2373 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2370 | locCh = ( localMod > mLastAddressbookSync ); | 2374 | locCh = ( localMod > mLastAddressbookSync ); |
2371 | if ( !remCh && ! locCh ) { | 2375 | if ( !remCh && ! locCh ) { |
2372 | //qDebug("both not changed "); | 2376 | //qDebug("both not changed "); |
2373 | lastSync = localMod.addDays(1); | 2377 | lastSync = localMod.addDays(1); |
2374 | if ( mode <= SYNC_PREF_ASK ) | 2378 | if ( mode <= SYNC_PREF_ASK ) |
2375 | return 0; | 2379 | return 0; |
2376 | } else { | 2380 | } else { |
2377 | if ( locCh ) { | 2381 | if ( locCh ) { |
2378 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2382 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2379 | lastSync = localMod.addDays( -1 ); | 2383 | lastSync = localMod.addDays( -1 ); |
2380 | if ( !remCh ) | 2384 | if ( !remCh ) |
2381 | remoteMod =( lastSync.addDays( -1 ) ); | 2385 | remoteMod =( lastSync.addDays( -1 ) ); |
2382 | } else { | 2386 | } else { |
2383 | //qDebug(" not loc changed "); | 2387 | //qDebug(" not loc changed "); |
2384 | lastSync = localMod.addDays( 1 ); | 2388 | lastSync = localMod.addDays( 1 ); |
2385 | if ( remCh ) | 2389 | if ( remCh ) |
2386 | remoteMod =( lastSync.addDays( 1 ) ); | 2390 | remoteMod =( lastSync.addDays( 1 ) ); |
2387 | 2391 | ||
2388 | } | 2392 | } |
2389 | } | 2393 | } |
2390 | full = true; | 2394 | full = true; |
2391 | if ( mode < SYNC_PREF_ASK ) | 2395 | if ( mode < SYNC_PREF_ASK ) |
2392 | mode = SYNC_PREF_ASK; | 2396 | mode = SYNC_PREF_ASK; |
2393 | } else { | 2397 | } else { |
2394 | if ( localMod == remoteMod ) | 2398 | if ( localMod == remoteMod ) |
2395 | return 0; | 2399 | return 0; |
2396 | 2400 | ||
2397 | } | 2401 | } |
2398 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 2402 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
2399 | 2403 | ||
2400 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); | 2404 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); |
2401 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 2405 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); |
2402 | //full = true; //debug only | 2406 | //full = true; //debug only |
2403 | if ( full ) { | 2407 | if ( full ) { |
2404 | bool equ = ( (*local) == (*remote) ); | 2408 | bool equ = ( (*local) == (*remote) ); |
2405 | if ( equ ) { | 2409 | if ( equ ) { |
2406 | //qDebug("equal "); | 2410 | //qDebug("equal "); |
2407 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2411 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2408 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2412 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2409 | } | 2413 | } |
2410 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2414 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2411 | return 0; | 2415 | return 0; |
2412 | 2416 | ||
2413 | }//else //debug only | 2417 | }//else //debug only |
2414 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2418 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2415 | } | 2419 | } |
2416 | int result; | 2420 | int result; |
2417 | bool localIsNew; | 2421 | bool localIsNew; |
2418 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); | 2422 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); |
2419 | 2423 | ||
2420 | if ( full && mode < SYNC_PREF_NEWEST ) | 2424 | if ( full && mode < SYNC_PREF_NEWEST ) |
2421 | mode = SYNC_PREF_ASK; | 2425 | mode = SYNC_PREF_ASK; |
2422 | 2426 | ||
2423 | switch( mode ) { | 2427 | switch( mode ) { |
2424 | case SYNC_PREF_LOCAL: | 2428 | case SYNC_PREF_LOCAL: |
2425 | if ( lastSync > remoteMod ) | 2429 | if ( lastSync > remoteMod ) |
2426 | return 1; | 2430 | return 1; |
2427 | if ( lastSync > localMod ) | 2431 | if ( lastSync > localMod ) |
2428 | return 2; | 2432 | return 2; |
2429 | return 1; | 2433 | return 1; |
2430 | break; | 2434 | break; |
2431 | case SYNC_PREF_REMOTE: | 2435 | case SYNC_PREF_REMOTE: |
2432 | if ( lastSync > remoteMod ) | 2436 | if ( lastSync > remoteMod ) |
2433 | return 1; | 2437 | return 1; |
2434 | if ( lastSync > localMod ) | 2438 | if ( lastSync > localMod ) |
2435 | return 2; | 2439 | return 2; |
2436 | return 2; | 2440 | return 2; |
2437 | break; | 2441 | break; |
2438 | case SYNC_PREF_NEWEST: | 2442 | case SYNC_PREF_NEWEST: |
2439 | if ( localMod > remoteMod ) | 2443 | if ( localMod > remoteMod ) |
2440 | return 1; | 2444 | return 1; |
2441 | else | 2445 | else |
2442 | return 2; | 2446 | return 2; |
2443 | break; | 2447 | break; |
2444 | case SYNC_PREF_ASK: | 2448 | case SYNC_PREF_ASK: |
2445 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 2449 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
2446 | if ( lastSync > remoteMod ) | 2450 | if ( lastSync > remoteMod ) |
2447 | return 1; | 2451 | return 1; |
2448 | if ( lastSync > localMod ) | 2452 | if ( lastSync > localMod ) |
2449 | return 2; | 2453 | return 2; |
2450 | localIsNew = localMod >= remoteMod; | 2454 | localIsNew = localMod >= remoteMod; |
2451 | //qDebug("conflict! ************************************** "); | 2455 | //qDebug("conflict! ************************************** "); |
2452 | { | 2456 | { |
2453 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | 2457 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); |
2454 | result = acd.executeD(localIsNew); | 2458 | result = acd.executeD(localIsNew); |
2455 | return result; | 2459 | return result; |
2456 | } | 2460 | } |
2457 | break; | 2461 | break; |
2458 | case SYNC_PREF_FORCE_LOCAL: | 2462 | case SYNC_PREF_FORCE_LOCAL: |
2459 | return 1; | 2463 | return 1; |
2460 | break; | 2464 | break; |
2461 | case SYNC_PREF_FORCE_REMOTE: | 2465 | case SYNC_PREF_FORCE_REMOTE: |
2462 | return 2; | 2466 | return 2; |
2463 | break; | 2467 | break; |
2464 | 2468 | ||
2465 | default: | 2469 | default: |
2466 | // SYNC_PREF_TAKE_BOTH not implemented | 2470 | // SYNC_PREF_TAKE_BOTH not implemented |
2467 | break; | 2471 | break; |
2468 | } | 2472 | } |
2469 | return 0; | 2473 | return 0; |
2470 | } | 2474 | } |
2471 | 2475 | ||
2472 | 2476 | ||
2473 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2477 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2474 | { | 2478 | { |
2475 | bool syncOK = true; | 2479 | bool syncOK = true; |
2476 | int addedAddressee = 0; | 2480 | int addedAddressee = 0; |
2477 | int addedAddresseeR = 0; | 2481 | int addedAddresseeR = 0; |
2478 | int deletedAddresseeR = 0; | 2482 | int deletedAddresseeR = 0; |
2479 | int deletedAddresseeL = 0; | 2483 | int deletedAddresseeL = 0; |
2480 | int changedLocal = 0; | 2484 | int changedLocal = 0; |
2481 | int changedRemote = 0; | 2485 | int changedRemote = 0; |
2482 | 2486 | ||
2483 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); | 2487 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); |
2484 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2488 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2485 | 2489 | ||
2486 | //QPtrList<Addressee> el = local->rawAddressees(); | 2490 | //QPtrList<Addressee> el = local->rawAddressees(); |
2487 | Addressee addresseeR; | 2491 | Addressee addresseeR; |
2488 | QString uid; | 2492 | QString uid; |
2489 | int take; | 2493 | int take; |
2490 | Addressee addresseeL; | 2494 | Addressee addresseeL; |
2491 | Addressee addresseeRSync; | 2495 | Addressee addresseeRSync; |
2492 | Addressee addresseeLSync; | 2496 | Addressee addresseeLSync; |
2493 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2497 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2494 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2498 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2495 | bool fullDateRange = false; | 2499 | bool fullDateRange = false; |
2496 | local->resetTempSyncStat(); | 2500 | local->resetTempSyncStat(); |
2497 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2501 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2498 | QDateTime modifiedCalendar = mLastAddressbookSync;; | 2502 | QDateTime modifiedCalendar = mLastAddressbookSync;; |
2499 | addresseeLSync = getLastSyncAddressee(); | 2503 | addresseeLSync = getLastSyncAddressee(); |
2500 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2504 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2501 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2505 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2502 | if ( !addresseeR.isEmpty() ) { | 2506 | if ( !addresseeR.isEmpty() ) { |
2503 | addresseeRSync = addresseeR; | 2507 | addresseeRSync = addresseeR; |
2504 | remote->removeAddressee(addresseeR ); | 2508 | remote->removeAddressee(addresseeR ); |
2505 | 2509 | ||
2506 | } else { | 2510 | } else { |
2507 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2511 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2508 | addresseeRSync = addresseeLSync ; | 2512 | addresseeRSync = addresseeLSync ; |
2509 | } else { | 2513 | } else { |
2510 | qDebug("FULLDATE 1"); | 2514 | qDebug("FULLDATE 1"); |
2511 | fullDateRange = true; | 2515 | fullDateRange = true; |
2512 | Addressee newAdd; | 2516 | Addressee newAdd; |
2513 | addresseeRSync = newAdd; | 2517 | addresseeRSync = newAdd; |
2514 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2518 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2515 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2519 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2516 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2520 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2517 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2521 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2518 | } | 2522 | } |
2519 | } | 2523 | } |
2520 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2524 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2521 | qDebug("FULLDATE 2"); | 2525 | qDebug("FULLDATE 2"); |
2522 | fullDateRange = true; | 2526 | fullDateRange = true; |
2523 | } | 2527 | } |
2524 | if ( ! fullDateRange ) { | 2528 | if ( ! fullDateRange ) { |
2525 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2529 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2526 | 2530 | ||
2527 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2531 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2528 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2532 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2529 | fullDateRange = true; | 2533 | fullDateRange = true; |
2530 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2534 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2531 | } | 2535 | } |
2532 | } | 2536 | } |
2533 | // fullDateRange = true; // debug only! | 2537 | // fullDateRange = true; // debug only! |
2534 | if ( fullDateRange ) | 2538 | if ( fullDateRange ) |
2535 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2539 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2536 | else | 2540 | else |
2537 | mLastAddressbookSync = addresseeLSync.revision(); | 2541 | mLastAddressbookSync = addresseeLSync.revision(); |
2538 | // for resyncing if own file has changed | 2542 | // for resyncing if own file has changed |
2539 | // PENDING fixme later when implemented | 2543 | // PENDING fixme later when implemented |
2540 | #if 0 | 2544 | #if 0 |
2541 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2545 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2542 | mLastAddressbookSync = loadedFileVersion; | 2546 | mLastAddressbookSync = loadedFileVersion; |
2543 | qDebug("setting mLastAddressbookSync "); | 2547 | qDebug("setting mLastAddressbookSync "); |
2544 | } | 2548 | } |
2545 | #endif | 2549 | #endif |
2546 | 2550 | ||
2547 | //qDebug("*************************** "); | 2551 | //qDebug("*************************** "); |
2548 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2552 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2549 | QStringList er = remote->uidList(); | 2553 | QStringList er = remote->uidList(); |
2550 | Addressee inR ;//= er.first(); | 2554 | Addressee inR ;//= er.first(); |
2551 | Addressee inL; | 2555 | Addressee inL; |
2552 | 2556 | ||
2553 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 2557 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
2554 | 2558 | ||
2555 | int modulo = (er.count()/10)+1; | 2559 | int modulo = (er.count()/10)+1; |
2556 | int incCounter = 0; | 2560 | int incCounter = 0; |
2557 | while ( incCounter < er.count()) { | 2561 | while ( incCounter < er.count()) { |
2558 | if (syncManager->isProgressBarCanceled()) | 2562 | if (syncManager->isProgressBarCanceled()) |
2559 | return false; | 2563 | return false; |
2560 | if ( incCounter % modulo == 0 ) | 2564 | if ( incCounter % modulo == 0 ) |
2561 | syncManager->showProgressBar(incCounter); | 2565 | syncManager->showProgressBar(incCounter); |
2562 | 2566 | ||
2563 | uid = er[ incCounter ]; | 2567 | uid = er[ incCounter ]; |
2564 | bool skipIncidence = false; | 2568 | bool skipIncidence = false; |
2565 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2569 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2566 | skipIncidence = true; | 2570 | skipIncidence = true; |
2567 | QString idS,OidS; | 2571 | QString idS,OidS; |
2568 | qApp->processEvents(); | 2572 | qApp->processEvents(); |
2569 | if ( !skipIncidence ) { | 2573 | if ( !skipIncidence ) { |
2570 | inL = local->findByUid( uid ); | 2574 | inL = local->findByUid( uid ); |
2571 | inR = remote->findByUid( uid ); | 2575 | inR = remote->findByUid( uid ); |
2572 | //inL.setResource( 0 ); | 2576 | //inL.setResource( 0 ); |
2573 | //inR.setResource( 0 ); | 2577 | //inR.setResource( 0 ); |
2574 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2578 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2575 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { | 2579 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { |
2576 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2580 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2577 | if ( take == 3 ) | 2581 | if ( take == 3 ) |
2578 | return false; | 2582 | return false; |
2579 | if ( take == 1 ) {// take local | 2583 | if ( take == 1 ) {// take local |
2580 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2584 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2581 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2585 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2582 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2586 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2583 | local->insertAddressee( inL, false ); | 2587 | local->insertAddressee( inL, false ); |
2584 | idS = inR.externalUID(); | 2588 | idS = inR.externalUID(); |
2585 | OidS = inR.originalExternalUID(); | 2589 | OidS = inR.originalExternalUID(); |
2586 | } | 2590 | } |
2587 | else | 2591 | else |
2588 | idS = inR.IDStr(); | 2592 | idS = inR.IDStr(); |
2589 | remote->removeAddressee( inR ); | 2593 | remote->removeAddressee( inR ); |
2590 | inR = inL; | 2594 | inR = inL; |
2591 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2595 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2592 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2596 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2593 | inR.setOriginalExternalUID( OidS ); | 2597 | inR.setOriginalExternalUID( OidS ); |
2594 | inR.setExternalUID( idS ); | 2598 | inR.setExternalUID( idS ); |
2595 | } else { | 2599 | } else { |
2596 | inR.setIDStr( idS ); | 2600 | inR.setIDStr( idS ); |
2597 | } | 2601 | } |
2598 | inR.setResource( 0 ); | 2602 | inR.setResource( 0 ); |
2599 | remote->insertAddressee( inR , false); | 2603 | remote->insertAddressee( inR , false); |
2600 | ++changedRemote; | 2604 | ++changedRemote; |
2601 | } else { // take == 2 take remote | 2605 | } else { // take == 2 take remote |
2602 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2606 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2603 | if ( inR.revision().date().year() < 2004 ) | 2607 | if ( inR.revision().date().year() < 2004 ) |
2604 | inR.setRevision( modifiedCalendar ); | 2608 | inR.setRevision( modifiedCalendar ); |
2605 | } | 2609 | } |
2606 | idS = inL.IDStr(); | 2610 | idS = inL.IDStr(); |
2607 | local->removeAddressee( inL ); | 2611 | local->removeAddressee( inL ); |
2608 | inL = inR; | 2612 | inL = inR; |
2609 | inL.setIDStr( idS ); | 2613 | inL.setIDStr( idS ); |
2610 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2614 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2611 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2615 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2612 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2616 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2613 | } | 2617 | } |
2614 | inL.setResource( 0 ); | 2618 | inL.setResource( 0 ); |
2615 | local->insertAddressee( inL , false ); | 2619 | local->insertAddressee( inL , false ); |
2616 | ++changedLocal; | 2620 | ++changedLocal; |
2617 | } | 2621 | } |
2618 | } | 2622 | } |
2619 | } else { // no conflict | 2623 | } else { // no conflict |
2620 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2624 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2621 | QString des = addresseeLSync.note(); | 2625 | QString des = addresseeLSync.note(); |
2622 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 2626 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2623 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 2627 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2624 | remote->insertAddressee( inR, false ); | 2628 | remote->insertAddressee( inR, false ); |
2625 | ++deletedAddresseeR; | 2629 | ++deletedAddresseeR; |
2626 | } else { | 2630 | } else { |
2627 | inR.setRevision( modifiedCalendar ); | 2631 | inR.setRevision( modifiedCalendar ); |
2628 | remote->insertAddressee( inR, false ); | 2632 | remote->insertAddressee( inR, false ); |
2629 | inL = inR; | 2633 | inL = inR; |
2630 | inL.setResource( 0 ); | 2634 | inL.setResource( 0 ); |
2631 | local->insertAddressee( inL , false); | 2635 | local->insertAddressee( inL , false); |
2632 | ++addedAddressee; | 2636 | ++addedAddressee; |
2633 | } | 2637 | } |
2634 | } else { | 2638 | } else { |
2635 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { | 2639 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
2636 | inR.setRevision( modifiedCalendar ); | 2640 | inR.setRevision( modifiedCalendar ); |
2637 | remote->insertAddressee( inR, false ); | 2641 | remote->insertAddressee( inR, false ); |
2638 | inR.setResource( 0 ); | 2642 | inR.setResource( 0 ); |
2639 | local->insertAddressee( inR, false ); | 2643 | local->insertAddressee( inR, false ); |
2640 | ++addedAddressee; | 2644 | ++addedAddressee; |
2641 | } else { | 2645 | } else { |
2642 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 2646 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
2643 | remote->removeAddressee( inR ); | 2647 | remote->removeAddressee( inR ); |
2644 | ++deletedAddresseeR; | 2648 | ++deletedAddresseeR; |
2645 | } | 2649 | } |
2646 | } | 2650 | } |
2647 | } | 2651 | } |
2648 | } | 2652 | } |
2649 | ++incCounter; | 2653 | ++incCounter; |
2650 | } | 2654 | } |
2651 | er.clear(); | 2655 | er.clear(); |
2652 | QStringList el = local->uidList(); | 2656 | QStringList el = local->uidList(); |
2653 | modulo = (el.count()/10)+1; | 2657 | modulo = (el.count()/10)+1; |
2654 | 2658 | ||
2655 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 2659 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
2656 | incCounter = 0; | 2660 | incCounter = 0; |
2657 | while ( incCounter < el.count()) { | 2661 | while ( incCounter < el.count()) { |
2658 | qApp->processEvents(); | 2662 | qApp->processEvents(); |
2659 | if (syncManager->isProgressBarCanceled()) | 2663 | if (syncManager->isProgressBarCanceled()) |
2660 | return false; | 2664 | return false; |
2661 | if ( incCounter % modulo == 0 ) | 2665 | if ( incCounter % modulo == 0 ) |
2662 | syncManager->showProgressBar(incCounter); | 2666 | syncManager->showProgressBar(incCounter); |
2663 | uid = el[ incCounter ]; | 2667 | uid = el[ incCounter ]; |
2664 | bool skipIncidence = false; | 2668 | bool skipIncidence = false; |
2665 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2669 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2666 | skipIncidence = true; | 2670 | skipIncidence = true; |
2667 | if ( !skipIncidence ) { | 2671 | if ( !skipIncidence ) { |
2668 | inL = local->findByUid( uid ); | 2672 | inL = local->findByUid( uid ); |
2669 | inR = remote->findByUid( uid ); | 2673 | inR = remote->findByUid( uid ); |
2670 | if ( inR.isEmpty() ) { | 2674 | if ( inR.isEmpty() ) { |
2671 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2675 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2672 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 2676 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
2673 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2677 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2674 | local->removeAddressee( inL ); | 2678 | local->removeAddressee( inL ); |
2675 | ++deletedAddresseeL; | 2679 | ++deletedAddresseeL; |
2676 | } else { | 2680 | } else { |
2677 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2681 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2678 | inL.removeID(mCurrentSyncDevice ); | 2682 | inL.removeID(mCurrentSyncDevice ); |
2679 | ++addedAddresseeR; | 2683 | ++addedAddresseeR; |
2680 | inL.setRevision( modifiedCalendar ); | 2684 | inL.setRevision( modifiedCalendar ); |
2681 | local->insertAddressee( inL, false ); | 2685 | local->insertAddressee( inL, false ); |
2682 | inR = inL; | 2686 | inR = inL; |
2683 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); | 2687 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); |
2684 | inR.setResource( 0 ); | 2688 | inR.setResource( 0 ); |
2685 | remote->insertAddressee( inR, false ); | 2689 | remote->insertAddressee( inR, false ); |
2686 | } | 2690 | } |
2687 | } | 2691 | } |
2688 | } else { | 2692 | } else { |
2689 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 2693 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
2690 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2694 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2691 | local->removeAddressee( inL ); | 2695 | local->removeAddressee( inL ); |
2692 | ++deletedAddresseeL; | 2696 | ++deletedAddresseeL; |
2693 | } else { | 2697 | } else { |
2694 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2698 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2695 | ++addedAddresseeR; | 2699 | ++addedAddresseeR; |
2696 | inL.setRevision( modifiedCalendar ); | 2700 | inL.setRevision( modifiedCalendar ); |
2697 | local->insertAddressee( inL, false ); | 2701 | local->insertAddressee( inL, false ); |
2698 | inR = inL; | 2702 | inR = inL; |
2699 | inR.setResource( 0 ); | 2703 | inR.setResource( 0 ); |
2700 | remote->insertAddressee( inR, false ); | 2704 | remote->insertAddressee( inR, false ); |
2701 | } | 2705 | } |
2702 | } | 2706 | } |
2703 | } | 2707 | } |
2704 | } | 2708 | } |
2705 | } | 2709 | } |
2706 | ++incCounter; | 2710 | ++incCounter; |
2707 | } | 2711 | } |
2708 | el.clear(); | 2712 | el.clear(); |
2709 | syncManager->hideProgressBar(); | 2713 | syncManager->hideProgressBar(); |
2710 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 2714 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
2711 | // get rid of micro seconds | 2715 | // get rid of micro seconds |
2712 | QTime t = mLastAddressbookSync.time(); | 2716 | QTime t = mLastAddressbookSync.time(); |
2713 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 2717 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
2714 | addresseeLSync.setRevision( mLastAddressbookSync ); | 2718 | addresseeLSync.setRevision( mLastAddressbookSync ); |
2715 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2719 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2716 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 2720 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
2717 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 2721 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
2718 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 2722 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
2719 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 2723 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
2720 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 2724 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
2721 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 2725 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
2722 | addresseeRSync.setNote( "" ) ; | 2726 | addresseeRSync.setNote( "" ) ; |
2723 | addresseeLSync.setNote( "" ); | 2727 | addresseeLSync.setNote( "" ); |
2724 | 2728 | ||
2725 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 2729 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
2726 | remote->insertAddressee( addresseeRSync, false ); | 2730 | remote->insertAddressee( addresseeRSync, false ); |
2727 | local->insertAddressee( addresseeLSync, false ); | 2731 | local->insertAddressee( addresseeLSync, false ); |
2728 | QString mes; | 2732 | QString mes; |
2729 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); | 2733 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); |
2730 | if ( syncManager->mShowSyncSummary ) { | 2734 | if ( syncManager->mShowSyncSummary ) { |
2731 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); | 2735 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); |
2732 | } | 2736 | } |
2733 | qDebug( mes ); | 2737 | qDebug( mes ); |
2734 | return syncOK; | 2738 | return syncOK; |
2735 | } | 2739 | } |
2736 | 2740 | ||
2737 | 2741 | ||
2738 | //this is a overwritten callbackmethods from the syncinterface | 2742 | //this is a overwritten callbackmethods from the syncinterface |
2739 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | 2743 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) |
2740 | { | 2744 | { |
2741 | 2745 | ||
2742 | //pending prepare addresseeview for output | 2746 | //pending prepare addresseeview for output |
2743 | //pending detect, if remote file has REV field. if not switch to external sync | 2747 | //pending detect, if remote file has REV field. if not switch to external sync |
2744 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 2748 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
2745 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2749 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2746 | 2750 | ||
2747 | AddressBook abLocal(filename,"syncContact"); | 2751 | AddressBook abLocal(filename,"syncContact"); |
2748 | bool syncOK = false; | 2752 | bool syncOK = false; |
2749 | if ( abLocal.load() ) { | 2753 | if ( abLocal.load() ) { |
2750 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); | 2754 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); |
2751 | bool external = false; | 2755 | bool external = false; |
2752 | bool isXML = false; | 2756 | bool isXML = false; |
2753 | if ( filename.right(4) == ".xml") { | 2757 | if ( filename.right(4) == ".xml") { |
2754 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2758 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2755 | isXML = true; | 2759 | isXML = true; |
2756 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); | 2760 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); |
2757 | } else { | 2761 | } else { |
2758 | Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2762 | Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2759 | if ( ! lse.isEmpty() ) { | 2763 | if ( ! lse.isEmpty() ) { |
2760 | if ( lse.familyName().left(4) == "!E: " ) | 2764 | if ( lse.familyName().left(4) == "!E: " ) |
2761 | external = true; | 2765 | external = true; |
2762 | } else { | 2766 | } else { |
2763 | bool found = false; | 2767 | bool found = false; |
2764 | AddressBook::Iterator it; | 2768 | AddressBook::Iterator it; |
2765 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2769 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2766 | if ( (*it).revision().date().year() > 2003 ) { | 2770 | if ( (*it).revision().date().year() > 2003 ) { |
2767 | found = true; | 2771 | found = true; |
2768 | break; | 2772 | break; |
2769 | } | 2773 | } |
2770 | } | 2774 | } |
2771 | external = ! found; | 2775 | external = ! found; |
2772 | } | 2776 | } |
2773 | 2777 | ||
2774 | if ( external ) { | 2778 | if ( external ) { |
2775 | qDebug("Setting vcf mode to external "); | 2779 | qDebug("Setting vcf mode to external "); |
2776 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2780 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2777 | AddressBook::Iterator it; | 2781 | AddressBook::Iterator it; |
2778 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2782 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2779 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 2783 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
2780 | (*it).computeCsum( mCurrentSyncDevice ); | 2784 | (*it).computeCsum( mCurrentSyncDevice ); |
2781 | } | 2785 | } |
2782 | } | 2786 | } |
2783 | } | 2787 | } |
2784 | //AddressBook::Iterator it; | 2788 | //AddressBook::Iterator it; |
2785 | //QStringList vcards; | 2789 | //QStringList vcards; |
2786 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2790 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2787 | // qDebug("Name %s ", (*it).familyName().latin1()); | 2791 | // qDebug("Name %s ", (*it).familyName().latin1()); |
2788 | //} | 2792 | //} |
2789 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2793 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
2790 | if ( syncOK ) { | 2794 | if ( syncOK ) { |
2791 | if ( syncManager->mWriteBackFile ) | 2795 | if ( syncManager->mWriteBackFile ) |
2792 | { | 2796 | { |
2793 | if ( external ) | 2797 | if ( external ) |
2794 | abLocal.removeSyncAddressees( !isXML); | 2798 | abLocal.removeSyncAddressees( !isXML); |
2795 | qDebug("Saving remote AB "); | 2799 | qDebug("Saving remote AB "); |
2796 | abLocal.saveAB(); | 2800 | abLocal.saveAB(); |
2797 | if ( isXML ) { | 2801 | if ( isXML ) { |
2798 | // afterwrite processing | 2802 | // afterwrite processing |
2799 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2803 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2800 | } | 2804 | } |
2801 | } | 2805 | } |
2802 | } | 2806 | } |
2803 | setModified(); | 2807 | setModified(); |
2804 | 2808 | ||
2805 | } | 2809 | } |
2806 | if ( syncOK ) | 2810 | if ( syncOK ) |
2807 | mViewManager->refreshView(); | 2811 | mViewManager->refreshView(); |
2808 | return syncOK; | 2812 | return syncOK; |
2809 | #if 0 | 2813 | #if 0 |
2810 | 2814 | ||
2811 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { | 2815 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { |
2812 | getEventViewerDialog()->setSyncMode( true ); | 2816 | getEventViewerDialog()->setSyncMode( true ); |
2813 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 2817 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
2814 | getEventViewerDialog()->setSyncMode( false ); | 2818 | getEventViewerDialog()->setSyncMode( false ); |
2815 | if ( syncOK ) { | 2819 | if ( syncOK ) { |
2816 | if ( KOPrefs::instance()->mWriteBackFile ) | 2820 | if ( KOPrefs::instance()->mWriteBackFile ) |
2817 | { | 2821 | { |
2818 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 2822 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
2819 | storage->save(); | 2823 | storage->save(); |
2820 | } | 2824 | } |
2821 | } | 2825 | } |
2822 | setModified(); | 2826 | setModified(); |
2823 | } | 2827 | } |
2824 | 2828 | ||
2825 | #endif | 2829 | #endif |
2826 | } | 2830 | } |
2827 | 2831 | ||
2828 | 2832 | ||
2829 | //this is a overwritten callbackmethods from the syncinterface | 2833 | //this is a overwritten callbackmethods from the syncinterface |
2830 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 2834 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
2831 | { | 2835 | { |
2832 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2836 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2833 | 2837 | ||
2834 | AddressBook abLocal( resource,"syncContact"); | 2838 | AddressBook abLocal( resource,"syncContact"); |
2835 | bool syncOK = false; | 2839 | bool syncOK = false; |
2836 | if ( abLocal.load() ) { | 2840 | if ( abLocal.load() ) { |
2837 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2841 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2838 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2842 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2839 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); | 2843 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); |
2840 | qDebug("KABCore::syncExternal: why do we acces here KABPrefs and not somehow KSyncProfile? "); | ||
2841 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2844 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2842 | if ( syncOK ) { | 2845 | if ( syncOK ) { |
2843 | if ( syncManager->mWriteBackFile ) { | 2846 | if ( syncManager->mWriteBackFile ) { |
2844 | abLocal.saveAB(); | 2847 | abLocal.saveAB(); |
2845 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2848 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2846 | } | 2849 | } |
2847 | } | 2850 | } |
2848 | setModified(); | 2851 | setModified(); |
2849 | } | 2852 | } |
2850 | if ( syncOK ) | 2853 | if ( syncOK ) |
2851 | mViewManager->refreshView(); | 2854 | mViewManager->refreshView(); |
2852 | return syncOK; | 2855 | return syncOK; |
2853 | 2856 | ||
2854 | } | 2857 | } |
2855 | 2858 | ||
2856 | //called by the syncmanager to indicate that the work has to marked as dirty. | 2859 | void KABCore::getFile( bool success ) |
2857 | void KABCore::sync_setModified() | ||
2858 | { | 2860 | { |
2859 | setModified(); | 2861 | if ( ! success ) { |
2860 | } | 2862 | setCaption( i18n("Error receiving file. Nothing changed!") ); |
2861 | 2863 | return; | |
2862 | //called by the syncmanager to ask if the dirty flag is set. | 2864 | } |
2863 | bool KABCore::sync_isModified() | 2865 | //mView->watchSavedFile(); |
2864 | { | 2866 | //mView->openCalendar( defaultFileName() ); |
2865 | return mModified; | 2867 | // pending: reload received file! |
2866 | } | 2868 | setCaption( i18n("Pi-Sync successful!") ); |
2867 | |||
2868 | |||
2869 | //called by the syncmanager to indicate that the work has to be saved. | ||
2870 | void KABCore::sync_save() | ||
2871 | { | ||
2872 | save(); | ||
2873 | } | 2869 | } |
2874 | 2870 | ||
2875 | 2871 | ||
2876 | |||
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index c9c0d38..355e828 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h | |||
@@ -1,484 +1,479 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressbook. | 2 | This file is part of KAddressbook. |
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2003 Tobias Koenig <tokoe@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 | #ifndef KABCORE_H | 24 | #ifndef KABCORE_H |
25 | #define KABCORE_H | 25 | #define KABCORE_H |
26 | 26 | ||
27 | #include <kabc/field.h> | 27 | #include <kabc/field.h> |
28 | 28 | ||
29 | #ifndef KAB_EMBEDDED | 29 | #ifndef KAB_EMBEDDED |
30 | #endif //KAB_EMBEDDED | 30 | #endif //KAB_EMBEDDED |
31 | #include <qdict.h> | 31 | #include <qdict.h> |
32 | 32 | ||
33 | #include <qwidget.h> | 33 | #include <qwidget.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <ksyncmanager.h> | 35 | #include <ksyncmanager.h> |
36 | 36 | ||
37 | namespace KABC { | 37 | namespace KABC { |
38 | class AddressBook; | 38 | class AddressBook; |
39 | } | 39 | } |
40 | 40 | ||
41 | #ifndef KAB_EMBEDDED | 41 | #ifndef KAB_EMBEDDED |
42 | class KAboutData; | 42 | class KAboutData; |
43 | class KConfig; | 43 | class KConfig; |
44 | 44 | ||
45 | class KAddressBookService; | 45 | class KAddressBookService; |
46 | class LDAPSearchDialog; | 46 | class LDAPSearchDialog; |
47 | #else //KAB_EMBEDDED | 47 | #else //KAB_EMBEDDED |
48 | class KAddressBookMain; | 48 | class KAddressBookMain; |
49 | //US class QAction; | 49 | //US class QAction; |
50 | #endif //KAB_EMBEDDED | 50 | #endif //KAB_EMBEDDED |
51 | class KCMultiDialog; | 51 | class KCMultiDialog; |
52 | class KXMLGUIClient; | 52 | class KXMLGUIClient; |
53 | class ExtensionManager; | 53 | class ExtensionManager; |
54 | class XXPortManager; | 54 | class XXPortManager; |
55 | class JumpButtonBar; | 55 | class JumpButtonBar; |
56 | class IncSearchWidget; | 56 | class IncSearchWidget; |
57 | class KDGanttMinimizeSplitter; | 57 | class KDGanttMinimizeSplitter; |
58 | class KAction; | 58 | class KAction; |
59 | class KActionCollection; | 59 | class KActionCollection; |
60 | class KToggleAction; | 60 | class KToggleAction; |
61 | class KSyncProfile; | 61 | class KSyncProfile; |
62 | 62 | ||
63 | class QAction; | 63 | class QAction; |
64 | class QMenuBar; | 64 | class QMenuBar; |
65 | class QSplitter; | 65 | class QSplitter; |
66 | class ViewContainer; | 66 | class ViewContainer; |
67 | class ViewManager; | 67 | class ViewManager; |
68 | class AddresseeEditorDialog; | 68 | class AddresseeEditorDialog; |
69 | class Ir; | 69 | class Ir; |
70 | 70 | ||
71 | class KABCore : public QWidget, public KSyncInterface | 71 | class KABCore : public QWidget, public KSyncInterface |
72 | { | 72 | { |
73 | Q_OBJECT | 73 | Q_OBJECT |
74 | 74 | ||
75 | public: | 75 | public: |
76 | KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); | 76 | KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); |
77 | 77 | ||
78 | 78 | ||
79 | ~KABCore(); | 79 | ~KABCore(); |
80 | 80 | ||
81 | 81 | ||
82 | #ifdef KAB_EMBEDDED | 82 | #ifdef KAB_EMBEDDED |
83 | //US added functionality | 83 | //US added functionality |
84 | QPopupMenu* getViewMenu() {return viewMenu;} | 84 | QPopupMenu* getViewMenu() {return viewMenu;} |
85 | QPopupMenu* getFilterMenu() {return filterMenu;} | 85 | QPopupMenu* getFilterMenu() {return filterMenu;} |
86 | QPopupMenu* getSettingsMenu() {return settingsMenu;} | 86 | QPopupMenu* getSettingsMenu() {return settingsMenu;} |
87 | void addActionsManually(); | 87 | void addActionsManually(); |
88 | #endif //KAB_EMBEDDED | 88 | #endif //KAB_EMBEDDED |
89 | /** | 89 | /** |
90 | Restores the global settings. | 90 | Restores the global settings. |
91 | */ | 91 | */ |
92 | void restoreSettings(); | 92 | void restoreSettings(); |
93 | 93 | ||
94 | /** | 94 | /** |
95 | Saves the global settings. | 95 | Saves the global settings. |
96 | */ | 96 | */ |
97 | void saveSettings(); | 97 | void saveSettings(); |
98 | 98 | ||
99 | /** | 99 | /** |
100 | Returns a pointer to the StdAddressBook of the application. | 100 | Returns a pointer to the StdAddressBook of the application. |
101 | */ | 101 | */ |
102 | KABC::AddressBook *addressBook() const; | 102 | KABC::AddressBook *addressBook() const; |
103 | 103 | ||
104 | /** | 104 | /** |
105 | Returns a pointer to the KConfig object of the application. | 105 | Returns a pointer to the KConfig object of the application. |
106 | */ | 106 | */ |
107 | static KConfig *config(); | 107 | static KConfig *config(); |
108 | 108 | ||
109 | /** | 109 | /** |
110 | Returns a pointer to the global KActionCollection object. So | 110 | Returns a pointer to the global KActionCollection object. So |
111 | other classes can register their actions easily. | 111 | other classes can register their actions easily. |
112 | */ | 112 | */ |
113 | KActionCollection *actionCollection() const; | 113 | KActionCollection *actionCollection() const; |
114 | 114 | ||
115 | /** | 115 | /** |
116 | Returns the current search field of the Incremental Search Widget. | 116 | Returns the current search field of the Incremental Search Widget. |
117 | */ | 117 | */ |
118 | KABC::Field *currentSearchField() const; | 118 | KABC::Field *currentSearchField() const; |
119 | 119 | ||
120 | /** | 120 | /** |
121 | Returns the uid list of the currently selected contacts. | 121 | Returns the uid list of the currently selected contacts. |
122 | */ | 122 | */ |
123 | QStringList selectedUIDs() const; | 123 | QStringList selectedUIDs() const; |
124 | 124 | ||
125 | /** | 125 | /** |
126 | Displays the ResourceSelectDialog and returns the selected | 126 | Displays the ResourceSelectDialog and returns the selected |
127 | resource or a null pointer if no resource was selected by | 127 | resource or a null pointer if no resource was selected by |
128 | the user. | 128 | the user. |
129 | */ | 129 | */ |
130 | KABC::Resource *requestResource( QWidget *parent ); | 130 | KABC::Resource *requestResource( QWidget *parent ); |
131 | 131 | ||
132 | #ifndef KAB_EMBEDDED | 132 | #ifndef KAB_EMBEDDED |
133 | static KAboutData *createAboutData(); | 133 | static KAboutData *createAboutData(); |
134 | #endif //KAB_EMBEDDED | 134 | #endif //KAB_EMBEDDED |
135 | 135 | ||
136 | #ifdef KAB_EMBEDDED | 136 | #ifdef KAB_EMBEDDED |
137 | inline QPopupMenu* getImportMenu() { return ImportMenu;} | 137 | inline QPopupMenu* getImportMenu() { return ImportMenu;} |
138 | inline QPopupMenu* getExportMenu() { return ExportMenu;} | 138 | inline QPopupMenu* getExportMenu() { return ExportMenu;} |
139 | #endif //KAB_EMBEDDED | 139 | #endif //KAB_EMBEDDED |
140 | 140 | ||
141 | public slots: | 141 | public slots: |
142 | #ifdef KAB_EMBEDDED | 142 | #ifdef KAB_EMBEDDED |
143 | void createAboutData(); | 143 | void createAboutData(); |
144 | #endif //KAB_EMBEDDED | 144 | #endif //KAB_EMBEDDED |
145 | 145 | ||
146 | void statusMessage(QString, int time = 0 ); | 146 | void statusMessage(QString, int time = 0 ); |
147 | void showLicence(); | 147 | void showLicence(); |
148 | void faq(); | 148 | void faq(); |
149 | 149 | ||
150 | /** | 150 | /** |
151 | Is called whenever a contact is selected in the view. | 151 | Is called whenever a contact is selected in the view. |
152 | */ | 152 | */ |
153 | void setContactSelected( const QString &uid ); | 153 | void setContactSelected( const QString &uid ); |
154 | 154 | ||
155 | /** | 155 | /** |
156 | Opens the preferred mail composer with all selected contacts as | 156 | Opens the preferred mail composer with all selected contacts as |
157 | arguments. | 157 | arguments. |
158 | */ | 158 | */ |
159 | void sendMail(); | 159 | void sendMail(); |
160 | 160 | ||
161 | /** | 161 | /** |
162 | Opens the preferred mail composer with the given contacts as | 162 | Opens the preferred mail composer with the given contacts as |
163 | arguments. | 163 | arguments. |
164 | */ | 164 | */ |
165 | void sendMail( const QString& email ); | 165 | void sendMail( const QString& email ); |
166 | 166 | ||
167 | 167 | ||
168 | void mailVCard(); | 168 | void mailVCard(); |
169 | void mailVCard(const QStringList& uids); | 169 | void mailVCard(const QStringList& uids); |
170 | 170 | ||
171 | /** | 171 | /** |
172 | Beams the "WhoAmI contact. | 172 | Beams the "WhoAmI contact. |
173 | */ | 173 | */ |
174 | void beamMySelf(); | 174 | void beamMySelf(); |
175 | 175 | ||
176 | void beamVCard(); | 176 | void beamVCard(); |
177 | void export2phone(); | 177 | void export2phone(); |
178 | void beamVCard(const QStringList& uids); | 178 | void beamVCard(const QStringList& uids); |
179 | void beamDone( Ir *ir ); | 179 | void beamDone( Ir *ir ); |
180 | 180 | ||
181 | 181 | ||
182 | /** | 182 | /** |
183 | Starts the preferred web browser with the given URL as argument. | 183 | Starts the preferred web browser with the given URL as argument. |
184 | */ | 184 | */ |
185 | void browse( const QString& url ); | 185 | void browse( const QString& url ); |
186 | 186 | ||
187 | /** | 187 | /** |
188 | Select all contacts in the view. | 188 | Select all contacts in the view. |
189 | */ | 189 | */ |
190 | void selectAllContacts(); | 190 | void selectAllContacts(); |
191 | 191 | ||
192 | /** | 192 | /** |
193 | Deletes all selected contacts from the address book. | 193 | Deletes all selected contacts from the address book. |
194 | */ | 194 | */ |
195 | void deleteContacts(); | 195 | void deleteContacts(); |
196 | 196 | ||
197 | /** | 197 | /** |
198 | Deletes given contacts from the address book. | 198 | Deletes given contacts from the address book. |
199 | 199 | ||
200 | @param uids The uids of the contacts, which shall be deleted. | 200 | @param uids The uids of the contacts, which shall be deleted. |
201 | */ | 201 | */ |
202 | void deleteContacts( const QStringList &uids ); | 202 | void deleteContacts( const QStringList &uids ); |
203 | 203 | ||
204 | /** | 204 | /** |
205 | Copys the selected contacts into clipboard for later pasting. | 205 | Copys the selected contacts into clipboard for later pasting. |
206 | */ | 206 | */ |
207 | void copyContacts(); | 207 | void copyContacts(); |
208 | 208 | ||
209 | /** | 209 | /** |
210 | Cuts the selected contacts and stores them for later pasting. | 210 | Cuts the selected contacts and stores them for later pasting. |
211 | */ | 211 | */ |
212 | void cutContacts(); | 212 | void cutContacts(); |
213 | 213 | ||
214 | /** | 214 | /** |
215 | Paste contacts from clipboard into the address book. | 215 | Paste contacts from clipboard into the address book. |
216 | */ | 216 | */ |
217 | void pasteContacts(); | 217 | void pasteContacts(); |
218 | 218 | ||
219 | /** | 219 | /** |
220 | Paste given contacts into the address book. | 220 | Paste given contacts into the address book. |
221 | 221 | ||
222 | @param list The list of addressee, which shall be pasted. | 222 | @param list The list of addressee, which shall be pasted. |
223 | */ | 223 | */ |
224 | void pasteContacts( KABC::Addressee::List &list ); | 224 | void pasteContacts( KABC::Addressee::List &list ); |
225 | 225 | ||
226 | /** | 226 | /** |
227 | Sets the whoAmI contact, that is used by many other programs to | 227 | Sets the whoAmI contact, that is used by many other programs to |
228 | get personal information about the current user. | 228 | get personal information about the current user. |
229 | */ | 229 | */ |
230 | void setWhoAmI(); | 230 | void setWhoAmI(); |
231 | 231 | ||
232 | /** | 232 | /** |
233 | Displays the category dialog and applies the result to all | 233 | Displays the category dialog and applies the result to all |
234 | selected contacts. | 234 | selected contacts. |
235 | */ | 235 | */ |
236 | void setCategories(); | 236 | void setCategories(); |
237 | 237 | ||
238 | /** | 238 | /** |
239 | Sets the field list of the Incremental Search Widget. | 239 | Sets the field list of the Incremental Search Widget. |
240 | */ | 240 | */ |
241 | void setSearchFields( const KABC::Field::List &fields ); | 241 | void setSearchFields( const KABC::Field::List &fields ); |
242 | 242 | ||
243 | /** | 243 | /** |
244 | Search with the current search field for a contact, that matches | 244 | Search with the current search field for a contact, that matches |
245 | the given text, and selects it in the view. | 245 | the given text, and selects it in the view. |
246 | */ | 246 | */ |
247 | void incrementalSearch( const QString& text ); | 247 | void incrementalSearch( const QString& text ); |
248 | 248 | ||
249 | /** | 249 | /** |
250 | Marks the address book as modified. | 250 | Marks the address book as modified. |
251 | */ | 251 | */ |
252 | void setModified(); | 252 | void setModified(); |
253 | /** | 253 | /** |
254 | Marks the address book as modified without refreshing the view. | 254 | Marks the address book as modified without refreshing the view. |
255 | */ | 255 | */ |
256 | void setModifiedWOrefresh(); | 256 | void setModifiedWOrefresh(); |
257 | 257 | ||
258 | /** | 258 | /** |
259 | Marks the address book as modified concerning the argument. | 259 | Marks the address book as modified concerning the argument. |
260 | */ | 260 | */ |
261 | void setModified( bool modified ); | 261 | void setModified( bool modified ); |
262 | 262 | ||
263 | /** | 263 | /** |
264 | Returns whether the address book is modified. | 264 | Returns whether the address book is modified. |
265 | */ | 265 | */ |
266 | bool modified() const; | 266 | bool modified() const; |
267 | 267 | ||
268 | /** | 268 | /** |
269 | Called whenever an contact is modified in the contact editor | 269 | Called whenever an contact is modified in the contact editor |
270 | dialog or the quick edit. | 270 | dialog or the quick edit. |
271 | */ | 271 | */ |
272 | void contactModified( const KABC::Addressee &addr ); | 272 | void contactModified( const KABC::Addressee &addr ); |
273 | 273 | ||
274 | /** | 274 | /** |
275 | DCOP METHODS. | 275 | DCOP METHODS. |
276 | */ | 276 | */ |
277 | void addEmail( QString addr ); | 277 | void addEmail( QString addr ); |
278 | void importVCard( const KURL& url, bool showPreview ); | 278 | void importVCard( const KURL& url, bool showPreview ); |
279 | void importVCard( const QString& vCard, bool showPreview ); | 279 | void importVCard( const QString& vCard, bool showPreview ); |
280 | void newContact(); | 280 | void newContact(); |
281 | QString getNameByPhone( const QString& phone ); | 281 | QString getNameByPhone( const QString& phone ); |
282 | /** | 282 | /** |
283 | END DCOP METHODS | 283 | END DCOP METHODS |
284 | */ | 284 | */ |
285 | 285 | ||
286 | /** | 286 | /** |
287 | Saves the contents of the AddressBook back to disk. | 287 | Saves the contents of the AddressBook back to disk. |
288 | */ | 288 | */ |
289 | void save(); | 289 | void save(); |
290 | 290 | ||
291 | /** | 291 | /** |
292 | Undos the last command using the undo stack. | 292 | Undos the last command using the undo stack. |
293 | */ | 293 | */ |
294 | void undo(); | 294 | void undo(); |
295 | 295 | ||
296 | /** | 296 | /** |
297 | Redos the last command that was undone, using the redo stack. | 297 | Redos the last command that was undone, using the redo stack. |
298 | */ | 298 | */ |
299 | void redo(); | 299 | void redo(); |
300 | 300 | ||
301 | /** | 301 | /** |
302 | Shows the edit dialog for the given uid. If the uid is QString::null, | 302 | Shows the edit dialog for the given uid. If the uid is QString::null, |
303 | the method will try to find a selected addressee in the view. | 303 | the method will try to find a selected addressee in the view. |
304 | */ | 304 | */ |
305 | void editContact( const QString &uid /*US = QString::null*/ ); | 305 | void editContact( const QString &uid /*US = QString::null*/ ); |
306 | //US added a second method without defaultparameter | 306 | //US added a second method without defaultparameter |
307 | void editContact2(); | 307 | void editContact2(); |
308 | 308 | ||
309 | /** | 309 | /** |
310 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 310 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
311 | the method will try to find a selected addressee in the view. | 311 | the method will try to find a selected addressee in the view. |
312 | */ | 312 | */ |
313 | void executeContact( const QString &uid /*US = QString::null*/ ); | 313 | void executeContact( const QString &uid /*US = QString::null*/ ); |
314 | 314 | ||
315 | /** | 315 | /** |
316 | Launches the configuration dialog. | 316 | Launches the configuration dialog. |
317 | */ | 317 | */ |
318 | void openConfigDialog(); | 318 | void openConfigDialog(); |
319 | 319 | ||
320 | /** | 320 | /** |
321 | Launches the ldap search dialog. | 321 | Launches the ldap search dialog. |
322 | */ | 322 | */ |
323 | void openLDAPDialog(); | 323 | void openLDAPDialog(); |
324 | 324 | ||
325 | /** | 325 | /** |
326 | Creates a KAddressBookPrinter, which will display the print | 326 | Creates a KAddressBookPrinter, which will display the print |
327 | dialog and do the printing. | 327 | dialog and do the printing. |
328 | */ | 328 | */ |
329 | void print(); | 329 | void print(); |
330 | 330 | ||
331 | /** | 331 | /** |
332 | Registers a new GUI client, so plugins can register its actions. | 332 | Registers a new GUI client, so plugins can register its actions. |
333 | */ | 333 | */ |
334 | void addGUIClient( KXMLGUIClient *client ); | 334 | void addGUIClient( KXMLGUIClient *client ); |
335 | 335 | ||
336 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); | 336 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); |
337 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); | 337 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); |
338 | void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); | 338 | void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); |
339 | 339 | ||
340 | 340 | ||
341 | signals: | 341 | signals: |
342 | void contactSelected( const QString &name ); | 342 | void contactSelected( const QString &name ); |
343 | void contactSelected( const QPixmap &pixmap ); | 343 | void contactSelected( const QPixmap &pixmap ); |
344 | public slots: | 344 | public slots: |
345 | void getFile( bool success ); | ||
345 | void setDetailsVisible( bool visible ); | 346 | void setDetailsVisible( bool visible ); |
346 | void setDetailsToState(); | 347 | void setDetailsToState(); |
347 | // void slotSyncMenu( int ); | 348 | // void slotSyncMenu( int ); |
348 | private slots: | 349 | private slots: |
349 | void setJumpButtonBarVisible( bool visible ); | 350 | void setJumpButtonBarVisible( bool visible ); |
350 | void importFromOL(); | 351 | void importFromOL(); |
351 | void extensionModified( const KABC::Addressee::List &list ); | 352 | void extensionModified( const KABC::Addressee::List &list ); |
352 | void extensionChanged( int id ); | 353 | void extensionChanged( int id ); |
353 | void clipboardDataChanged(); | 354 | void clipboardDataChanged(); |
354 | void updateActionMenu(); | 355 | void updateActionMenu(); |
355 | void configureKeyBindings(); | 356 | void configureKeyBindings(); |
356 | void removeVoice(); | 357 | void removeVoice(); |
357 | #ifdef KAB_EMBEDDED | 358 | #ifdef KAB_EMBEDDED |
358 | void configureResources(); | 359 | void configureResources(); |
359 | #endif //KAB_EMBEDDED | 360 | #endif //KAB_EMBEDDED |
360 | 361 | ||
361 | void slotEditorDestroyed( const QString &uid ); | 362 | void slotEditorDestroyed( const QString &uid ); |
362 | void configurationChanged(); | 363 | void configurationChanged(); |
363 | void addressBookChanged(); | 364 | void addressBookChanged(); |
364 | 365 | ||
365 | private: | 366 | private: |
366 | void initGUI(); | 367 | void initGUI(); |
367 | void initActions(); | 368 | void initActions(); |
368 | 369 | ||
369 | AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, | 370 | AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, |
370 | const char *name = 0 ); | 371 | const char *name = 0 ); |
371 | 372 | ||
372 | KXMLGUIClient *mGUIClient; | 373 | KXMLGUIClient *mGUIClient; |
373 | 374 | ||
374 | KABC::AddressBook *mAddressBook; | 375 | KABC::AddressBook *mAddressBook; |
375 | 376 | ||
376 | ViewManager *mViewManager; | 377 | ViewManager *mViewManager; |
377 | // QSplitter *mDetailsSplitter; | 378 | // QSplitter *mDetailsSplitter; |
378 | KDGanttMinimizeSplitter *mExtensionBarSplitter; | 379 | KDGanttMinimizeSplitter *mExtensionBarSplitter; |
379 | ViewContainer *mDetails; | 380 | ViewContainer *mDetails; |
380 | KDGanttMinimizeSplitter* mMiniSplitter; | 381 | KDGanttMinimizeSplitter* mMiniSplitter; |
381 | XXPortManager *mXXPortManager; | 382 | XXPortManager *mXXPortManager; |
382 | JumpButtonBar *mJumpButtonBar; | 383 | JumpButtonBar *mJumpButtonBar; |
383 | IncSearchWidget *mIncSearchWidget; | 384 | IncSearchWidget *mIncSearchWidget; |
384 | ExtensionManager *mExtensionManager; | 385 | ExtensionManager *mExtensionManager; |
385 | 386 | ||
386 | KCMultiDialog *mConfigureDialog; | 387 | KCMultiDialog *mConfigureDialog; |
387 | 388 | ||
388 | #ifndef KAB_EMBEDDED | 389 | #ifndef KAB_EMBEDDED |
389 | LDAPSearchDialog *mLdapSearchDialog; | 390 | LDAPSearchDialog *mLdapSearchDialog; |
390 | #endif //KAB_EMBEDDED | 391 | #endif //KAB_EMBEDDED |
391 | // QDict<AddresseeEditorDialog> mEditorDict; | 392 | // QDict<AddresseeEditorDialog> mEditorDict; |
392 | AddresseeEditorDialog *mEditorDialog; | 393 | AddresseeEditorDialog *mEditorDialog; |
393 | bool mReadWrite; | 394 | bool mReadWrite; |
394 | bool mModified; | 395 | bool mModified; |
395 | bool mIsPart; | 396 | bool mIsPart; |
396 | bool mMultipleViewsAtOnce; | 397 | bool mMultipleViewsAtOnce; |
397 | 398 | ||
398 | 399 | ||
399 | //US file menu | 400 | //US file menu |
400 | KAction *mActionMail; | 401 | KAction *mActionMail; |
401 | KAction *mActionBeam; | 402 | KAction *mActionBeam; |
402 | KAction *mActionExport2phone; | 403 | KAction *mActionExport2phone; |
403 | KAction* mActionPrint; | 404 | KAction* mActionPrint; |
404 | KAction* mActionNewContact; | 405 | KAction* mActionNewContact; |
405 | KAction *mActionSave; | 406 | KAction *mActionSave; |
406 | KAction *mActionEditAddressee; | 407 | KAction *mActionEditAddressee; |
407 | KAction *mActionMailVCard; | 408 | KAction *mActionMailVCard; |
408 | KAction *mActionBeamVCard; | 409 | KAction *mActionBeamVCard; |
409 | 410 | ||
410 | KAction *mActionQuit; | 411 | KAction *mActionQuit; |
411 | 412 | ||
412 | //US edit menu | 413 | //US edit menu |
413 | KAction *mActionCopy; | 414 | KAction *mActionCopy; |
414 | KAction *mActionCut; | 415 | KAction *mActionCut; |
415 | KAction *mActionPaste; | 416 | KAction *mActionPaste; |
416 | KAction *mActionSelectAll; | 417 | KAction *mActionSelectAll; |
417 | KAction *mActionUndo; | 418 | KAction *mActionUndo; |
418 | KAction *mActionRedo; | 419 | KAction *mActionRedo; |
419 | KAction *mActionDelete; | 420 | KAction *mActionDelete; |
420 | 421 | ||
421 | //US settings menu | 422 | //US settings menu |
422 | KAction *mActionConfigResources; | 423 | KAction *mActionConfigResources; |
423 | KAction *mActionConfigKAddressbook; | 424 | KAction *mActionConfigKAddressbook; |
424 | KAction *mActionConfigShortcuts; | 425 | KAction *mActionConfigShortcuts; |
425 | KAction *mActionConfigureToolbars; | 426 | KAction *mActionConfigureToolbars; |
426 | KAction *mActionKeyBindings; | 427 | KAction *mActionKeyBindings; |
427 | KToggleAction *mActionJumpBar; | 428 | KToggleAction *mActionJumpBar; |
428 | KToggleAction *mActionDetails; | 429 | KToggleAction *mActionDetails; |
429 | KAction *mActionWhoAmI; | 430 | KAction *mActionWhoAmI; |
430 | KAction *mActionCategories; | 431 | KAction *mActionCategories; |
431 | KAction *mActionAboutKAddressbook; | 432 | KAction *mActionAboutKAddressbook; |
432 | KAction *mActionLicence; | 433 | KAction *mActionLicence; |
433 | KAction *mActionFaq; | 434 | KAction *mActionFaq; |
434 | 435 | ||
435 | KAction *mActionDeleteView; | 436 | KAction *mActionDeleteView; |
436 | 437 | ||
437 | QPopupMenu *viewMenu; | 438 | QPopupMenu *viewMenu; |
438 | QPopupMenu *filterMenu; | 439 | QPopupMenu *filterMenu; |
439 | QPopupMenu *settingsMenu; | 440 | QPopupMenu *settingsMenu; |
440 | QPopupMenu *changeMenu; | 441 | QPopupMenu *changeMenu; |
441 | //US QAction *mActionSave; | 442 | //US QAction *mActionSave; |
442 | QPopupMenu *ImportMenu; | 443 | QPopupMenu *ImportMenu; |
443 | QPopupMenu *ExportMenu; | 444 | QPopupMenu *ExportMenu; |
444 | //LR additional methods | 445 | //LR additional methods |
445 | KAction *mActionRemoveVoice; | 446 | KAction *mActionRemoveVoice; |
446 | KAction * mActionImportOL; | 447 | KAction * mActionImportOL; |
447 | 448 | ||
448 | #ifndef KAB_EMBEDDED | 449 | #ifndef KAB_EMBEDDED |
449 | KAddressBookService *mAddressBookService; | 450 | KAddressBookService *mAddressBookService; |
450 | #endif //KAB_EMBEDDED | 451 | #endif //KAB_EMBEDDED |
451 | 452 | ||
452 | class KABCorePrivate; | 453 | class KABCorePrivate; |
453 | KABCorePrivate *d; | 454 | KABCorePrivate *d; |
454 | //US bool mBlockSaveFlag; | 455 | //US bool mBlockSaveFlag; |
455 | 456 | ||
456 | #ifdef KAB_EMBEDDED | 457 | #ifdef KAB_EMBEDDED |
457 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient | 458 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient |
458 | #endif //KAB_EMBEDDED | 459 | #endif //KAB_EMBEDDED |
459 | 460 | ||
460 | //this are the overwritten callbackmethods from the syncinterface | 461 | //this are the overwritten callbackmethods from the syncinterface |
461 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 462 | virtual bool sync(KSyncManager* manager, QString filename, int mode); |
462 | virtual bool syncExternal(KSyncManager* manager, QString resource); | 463 | virtual bool syncExternal(KSyncManager* manager, QString resource); |
463 | 464 | ||
464 | //called by the syncmanager to indicate that the work has to marked as dirty. | ||
465 | virtual void sync_setModified(); | ||
466 | //called by the syncmanager to ask if the dirty flag is set. | ||
467 | virtual bool sync_isModified(); | ||
468 | //called by the syncmanager to indicate that the work has to be saved. | ||
469 | virtual void sync_save(); | ||
470 | 465 | ||
471 | // LR ******************************* | 466 | // LR ******************************* |
472 | // sync stuff! | 467 | // sync stuff! |
473 | QPopupMenu *syncMenu; | 468 | QPopupMenu *syncMenu; |
474 | KSyncManager* syncManager; | 469 | KSyncManager* syncManager; |
475 | int mGlobalSyncMode; | 470 | int mGlobalSyncMode; |
476 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); | 471 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); |
477 | KABC::Addressee getLastSyncAddressee(); | 472 | KABC::Addressee getLastSyncAddressee(); |
478 | QDateTime mLastAddressbookSync; | 473 | QDateTime mLastAddressbookSync; |
479 | int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); | 474 | int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); |
480 | // ********************* | 475 | // ********************* |
481 | 476 | ||
482 | }; | 477 | }; |
483 | 478 | ||
484 | #endif | 479 | #endif |
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp index 84e3d00..1210094 100644 --- a/korganizer/koprefs.cpp +++ b/korganizer/koprefs.cpp | |||
@@ -1,575 +1,573 @@ | |||
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 | ||
49 | const char *germanwords[][2] = { | 49 | const char *germanwords[][2] = { |
50 | #include "wordsgerman.h" | 50 | #include "wordsgerman.h" |
51 | "", "" | 51 | "", "" |
52 | }; | 52 | }; |
53 | 53 | ||
54 | KOPrefs *KOPrefs::mInstance = 0; | 54 | KOPrefs *KOPrefs::mInstance = 0; |
55 | static KStaticDeleter<KOPrefs> insd; | 55 | static KStaticDeleter<KOPrefs> insd; |
56 | 56 | ||
57 | KOPrefs::KOPrefs() : | 57 | KOPrefs::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 | 80 | ||
81 | 81 | ||
82 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); | 82 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); |
83 | 83 | ||
84 | addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); | 84 | addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); |
85 | addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); | 85 | addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); |
86 | addItemBool("ShowIconSearch",&mShowIconSearch,true); | 86 | addItemBool("ShowIconSearch",&mShowIconSearch,true); |
87 | addItemBool("ShowIconList",&mShowIconList,true); | 87 | addItemBool("ShowIconList",&mShowIconList,true); |
88 | addItemBool("ShowIconDay1",&mShowIconDay1,true); | 88 | addItemBool("ShowIconDay1",&mShowIconDay1,true); |
89 | addItemBool("ShowIconDay5",&mShowIconDay5,true); | 89 | addItemBool("ShowIconDay5",&mShowIconDay5,true); |
90 | addItemBool("ShowIconDay7",&mShowIconDay7,true); | 90 | addItemBool("ShowIconDay7",&mShowIconDay7,true); |
91 | addItemBool("ShowIconMonth",&mShowIconMonth,true); | 91 | addItemBool("ShowIconMonth",&mShowIconMonth,true); |
92 | addItemBool("ShowIconTodoview",&mShowIconTodoview,true); | 92 | addItemBool("ShowIconTodoview",&mShowIconTodoview,true); |
93 | addItemBool("ShowIconBackFast",&mShowIconBackFast,true); | 93 | addItemBool("ShowIconBackFast",&mShowIconBackFast,true); |
94 | addItemBool("ShowIconBack",&mShowIconBack,true); | 94 | addItemBool("ShowIconBack",&mShowIconBack,true); |
95 | addItemBool("ShowIconToday",&mShowIconToday,true); | 95 | addItemBool("ShowIconToday",&mShowIconToday,true); |
96 | addItemBool("ShowIconForward",&mShowIconForward,true); | 96 | addItemBool("ShowIconForward",&mShowIconForward,true); |
97 | addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); | 97 | addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); |
98 | addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,false); | 98 | addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,false); |
99 | addItemBool("ShowIconNextDays",&mShowIconNextDays,true); | 99 | addItemBool("ShowIconNextDays",&mShowIconNextDays,true); |
100 | addItemBool("ShowIconNext",&mShowIconNext,true); | 100 | addItemBool("ShowIconNext",&mShowIconNext,true); |
101 | addItemBool("ShowIconJournal",&mShowIconJournal,true); | 101 | addItemBool("ShowIconJournal",&mShowIconJournal,true); |
102 | addItemBool("ShowIconStretch",&mShowIconStretch,true); | 102 | addItemBool("ShowIconStretch",&mShowIconStretch,true); |
103 | addItemBool("LanguageChanged",&mLanguageChanged,false); | 103 | addItemBool("LanguageChanged",&mLanguageChanged,false); |
104 | 104 | ||
105 | addItemBool("AskForQuit",&mAskForQuit,false); | 105 | addItemBool("AskForQuit",&mAskForQuit,false); |
106 | 106 | ||
107 | #ifndef DESKTOP_VERSION | 107 | #ifndef DESKTOP_VERSION |
108 | addItemBool("ShowFullMenu",&mShowFullMenu,false); | 108 | addItemBool("ShowFullMenu",&mShowFullMenu,false); |
109 | #else | 109 | #else |
110 | addItemBool("ShowFullMenu",&mShowFullMenu,true); | 110 | addItemBool("ShowFullMenu",&mShowFullMenu,true); |
111 | #endif | 111 | #endif |
112 | addItemBool("ToolBarHor",&mToolBarHor, true ); | 112 | addItemBool("ToolBarHor",&mToolBarHor, true ); |
113 | addItemBool("ToolBarUp",&mToolBarUp, false ); | 113 | addItemBool("ToolBarUp",&mToolBarUp, false ); |
114 | addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); | 114 | addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); |
115 | addItemInt("Whats Next Days",&mWhatsNextDays,3); | 115 | addItemInt("Whats Next Days",&mWhatsNextDays,3); |
116 | addItemInt("Whats Next Prios",&mWhatsNextPrios,1); | 116 | addItemInt("Whats Next Prios",&mWhatsNextPrios,1); |
117 | 117 | ||
118 | addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); | 118 | addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); |
119 | addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); | 119 | addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); |
120 | addItemInt("AllDay Size",&mAllDaySize,28); | 120 | addItemInt("AllDay Size",&mAllDaySize,28); |
121 | QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; | 121 | QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; |
122 | addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); | 122 | addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); |
123 | 123 | ||
124 | addItemStringList("LocationDefaults",&mLocationDefaults ); | 124 | addItemStringList("LocationDefaults",&mLocationDefaults ); |
125 | addItemStringList("EventSummary User",&mEventSummaryUser); | 125 | addItemStringList("EventSummary User",&mEventSummaryUser); |
126 | addItemStringList("TodoSummary User",&mTodoSummaryUser); | 126 | addItemStringList("TodoSummary User",&mTodoSummaryUser); |
127 | 127 | ||
128 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); | 128 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); |
129 | addItemBool("Enable Project View",&mEnableProjectView,false); | 129 | addItemBool("Enable Project View",&mEnableProjectView,false); |
130 | addItemBool("Auto Save",&mAutoSave,false); | 130 | addItemBool("Auto Save",&mAutoSave,false); |
131 | addItemInt("Auto Save Interval",&mAutoSaveInterval,3); | 131 | addItemInt("Auto Save Interval",&mAutoSaveInterval,3); |
132 | addItemBool("Confirm Deletes",&mConfirm,true); | 132 | addItemBool("Confirm Deletes",&mConfirm,true); |
133 | addItemString("Archive File",&mArchiveFile); | 133 | addItemString("Archive File",&mArchiveFile); |
134 | addItemString("Html Export File",&mHtmlExportFile, | 134 | addItemString("Html Export File",&mHtmlExportFile, |
135 | QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); | 135 | QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); |
136 | addItemBool("Html With Save",&mHtmlWithSave,false); | 136 | addItemBool("Html With Save",&mHtmlWithSave,false); |
137 | 137 | ||
138 | KPrefs::setCurrentGroup("Personal Settings"); | 138 | KPrefs::setCurrentGroup("Personal Settings"); |
139 | 139 | ||
140 | addItemInt("Mail Client",&mMailClient,MailClientKMail); | 140 | addItemInt("Mail Client",&mMailClient,MailClientKMail); |
141 | addItemBool("Use Control Center Email",&mEmailControlCenter,false); | 141 | addItemBool("Use Control Center Email",&mEmailControlCenter,false); |
142 | addItemBool("Bcc",&mBcc,false); | 142 | addItemBool("Bcc",&mBcc,false); |
143 | 143 | ||
144 | KPrefs::setCurrentGroup("Time & Date"); | 144 | KPrefs::setCurrentGroup("Time & Date"); |
145 | 145 | ||
146 | // addItemString("Time Zone",&mTimeZone,"+0100"); | 146 | // addItemString("Time Zone",&mTimeZone,"+0100"); |
147 | addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") ); | 147 | addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") ); |
148 | // addItemInt("TimeZoneOffset",&mTimeZoneOffset,60); | 148 | // addItemInt("TimeZoneOffset",&mTimeZoneOffset,60); |
149 | addItemBool("UseDaylightsaving",&mUseDaylightsaving,true); | 149 | addItemBool("UseDaylightsaving",&mUseDaylightsaving,true); |
150 | addItemInt("DaylightsavingStart",&mDaylightsavingStart,90); | 150 | addItemInt("DaylightsavingStart",&mDaylightsavingStart,90); |
151 | addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304); | 151 | addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304); |
152 | 152 | ||
153 | 153 | ||
154 | addItemInt("Default Start Time",&mStartTime,10); | 154 | addItemInt("Default Start Time",&mStartTime,10); |
155 | addItemInt("Default Duration",&mDefaultDuration,2); | 155 | addItemInt("Default Duration",&mDefaultDuration,2); |
156 | addItemInt("Default Alarm Time",&mAlarmTime,3); | 156 | addItemInt("Default Alarm Time",&mAlarmTime,3); |
157 | addItemInt("Daylight Savings",&mDaylightSavings,0); | 157 | addItemInt("Daylight Savings",&mDaylightSavings,0); |
158 | KPrefs::setCurrentGroup("AlarmSettings"); | 158 | KPrefs::setCurrentGroup("AlarmSettings"); |
159 | addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); | 159 | addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); |
160 | addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); | 160 | addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); |
161 | addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); | 161 | addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); |
162 | addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); | 162 | addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); |
163 | 163 | ||
164 | 164 | ||
165 | KPrefs::setCurrentGroup("Calendar"); | 165 | KPrefs::setCurrentGroup("Calendar"); |
166 | 166 | ||
167 | addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); | 167 | addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); |
168 | 168 | ||
169 | KPrefs::setCurrentGroup("Fonts"); | 169 | KPrefs::setCurrentGroup("Fonts"); |
170 | // qDebug(" KPrefs::setCurrentGroup(Fonts); "); | 170 | // qDebug(" KPrefs::setCurrentGroup(Fonts); "); |
171 | addItemFont("TimeBar Font",&mTimeBarFont); | 171 | addItemFont("TimeBar Font",&mTimeBarFont); |
172 | addItemFont("MonthView Font",&mMonthViewFont); | 172 | addItemFont("MonthView Font",&mMonthViewFont); |
173 | addItemFont("AgendaView Font",&mAgendaViewFont); | 173 | addItemFont("AgendaView Font",&mAgendaViewFont); |
174 | addItemFont("MarcusBains Font",&mMarcusBainsFont); | 174 | addItemFont("MarcusBains Font",&mMarcusBainsFont); |
175 | addItemFont("TimeLabels Font",&mTimeLabelsFont); | 175 | addItemFont("TimeLabels Font",&mTimeLabelsFont); |
176 | addItemFont("TodoView Font",&mTodoViewFont); | 176 | addItemFont("TodoView Font",&mTodoViewFont); |
177 | addItemFont("ListView Font",&mListViewFont); | 177 | addItemFont("ListView Font",&mListViewFont); |
178 | addItemFont("DateNavigator Font",&mDateNavigatorFont); | 178 | addItemFont("DateNavigator Font",&mDateNavigatorFont); |
179 | addItemFont("EditBox Font",&mEditBoxFont); | 179 | addItemFont("EditBox Font",&mEditBoxFont); |
180 | addItemFont("JournalView Font",&mJornalViewFont); | 180 | addItemFont("JournalView Font",&mJornalViewFont); |
181 | addItemFont("WhatsNextView Font",&mWhatsNextFont); | 181 | addItemFont("WhatsNextView Font",&mWhatsNextFont); |
182 | addItemFont("EventView Font",&mEventViewFont); | 182 | addItemFont("EventView Font",&mEventViewFont); |
183 | 183 | ||
184 | // KPrefs::setCurrentGroup("SyncProfiles"); | 184 | // KPrefs::setCurrentGroup("SyncProfiles"); |
185 | // addItemString("LocalMachineName",&mLocalMachineName, "undefined"); | 185 | // addItemString("LocalMachineName",&mLocalMachineName, "undefined"); |
186 | // addItemStringList("SyncProfileNames",&mSyncProfileNames); | 186 | // addItemStringList("SyncProfileNames",&mSyncProfileNames); |
187 | // addItemStringList("ExternSyncProfiles",&mExternSyncProfileNames); | 187 | // addItemStringList("ExternSyncProfiles",&mExternSyncProfileNames); |
188 | 188 | ||
189 | KPrefs::setCurrentGroup("RemoteSyncing"); | 189 | KPrefs::setCurrentGroup("RemoteSyncing"); |
190 | // addItemBool("UsePasswd",&mUsePassWd,false); | 190 | // addItemBool("UsePasswd",&mUsePassWd,false); |
191 | // addItemBool("WriteBackFile",&mWriteBackFile,true); | 191 | // addItemBool("WriteBackFile",&mWriteBackFile,true); |
192 | // addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false); | 192 | // addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false); |
193 | // addItemBool("AskForPreferences",&mAskForPreferences,true); | 193 | // addItemBool("AskForPreferences",&mAskForPreferences,true); |
194 | // addItemBool("ShowSyncSummary",&mShowSyncSummary,true); | 194 | // addItemBool("ShowSyncSummary",&mShowSyncSummary,true); |
195 | addItemString("PassiveSyncPort",&mPassiveSyncPort,"9197" ); | ||
196 | addItemString("PassiveSyncPw",&mPassiveSyncPw,"abc" ); | ||
197 | addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); | 195 | addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); |
198 | addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); | 196 | addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); |
199 | addItemBool("ShowSyncEvents",&mShowSyncEvents,false); | 197 | addItemBool("ShowSyncEvents",&mShowSyncEvents,false); |
200 | addItemInt("LastSyncTime",&mLastSyncTime,0); | 198 | addItemInt("LastSyncTime",&mLastSyncTime,0); |
201 | addItemInt("SyncAlgoPrefs",&mSyncAlgoPrefs,3); | 199 | addItemInt("SyncAlgoPrefs",&mSyncAlgoPrefs,3); |
202 | addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3); | 200 | addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3); |
203 | 201 | ||
204 | #ifdef _WIN32_ | 202 | #ifdef _WIN32_ |
205 | QString hdp= locateLocal("data","korganizer")+"\\\\"; | 203 | QString hdp= locateLocal("data","korganizer")+"\\\\"; |
206 | #else | 204 | #else |
207 | QString hdp= locateLocal("data","korganizer")+"/"; | 205 | QString hdp= locateLocal("data","korganizer")+"/"; |
208 | #endif | 206 | #endif |
209 | // addItemString("RemoteIP",&mRemoteIP, "192.168.0.65"); | 207 | // addItemString("RemoteIP",&mRemoteIP, "192.168.0.65"); |
210 | // addItemString("RemoteUser",&mRemoteUser, "zaurus"); | 208 | // addItemString("RemoteUser",&mRemoteUser, "zaurus"); |
211 | // addItemString("RemotePassWd",&mRemotePassWd, ""); | 209 | // addItemString("RemotePassWd",&mRemotePassWd, ""); |
212 | // addItemString("RemoteFile", &mRemoteFile, hdp+"mycalendar.ics"); | 210 | // addItemString("RemoteFile", &mRemoteFile, hdp+"mycalendar.ics"); |
213 | // addItemString("LocalTempFile",&mLocalTempFile, "/tmp/tempsyncfile.ics" ); | 211 | // addItemString("LocalTempFile",&mLocalTempFile, "/tmp/tempsyncfile.ics" ); |
214 | 212 | ||
215 | 213 | ||
216 | KPrefs::setCurrentGroup("LoadSaveFileNames"); | 214 | KPrefs::setCurrentGroup("LoadSaveFileNames"); |
217 | 215 | ||
218 | addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); | 216 | addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); |
219 | addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); | 217 | addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); |
220 | addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); | 218 | addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); |
221 | addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); | 219 | addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); |
222 | addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" ); | 220 | addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" ); |
223 | 221 | ||
224 | 222 | ||
225 | KPrefs::setCurrentGroup("Locale"); | 223 | KPrefs::setCurrentGroup("Locale"); |
226 | addItemInt("PreferredLanguage",&mPreferredLanguage,0); | 224 | addItemInt("PreferredLanguage",&mPreferredLanguage,0); |
227 | addItemInt("PreferredTime",&mPreferredTime,0); | 225 | addItemInt("PreferredTime",&mPreferredTime,0); |
228 | addItemInt("PreferredDate",&mPreferredDate,0); | 226 | addItemInt("PreferredDate",&mPreferredDate,0); |
229 | addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false); | 227 | addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false); |
230 | addItemBool("ShortDateInViewer",&mShortDateInViewer,false); | 228 | addItemBool("ShortDateInViewer",&mShortDateInViewer,false); |
231 | addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y"); | 229 | addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y"); |
232 | addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y"); | 230 | addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y"); |
233 | 231 | ||
234 | 232 | ||
235 | KPrefs::setCurrentGroup("Colors"); | 233 | KPrefs::setCurrentGroup("Colors"); |
236 | addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); | 234 | addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); |
237 | addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); | 235 | addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); |
238 | addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); | 236 | addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); |
239 | addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); | 237 | addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); |
240 | addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); | 238 | addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); |
241 | addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); | 239 | addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); |
242 | addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); | 240 | addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); |
243 | addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); | 241 | addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); |
244 | addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); | 242 | addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); |
245 | addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); | 243 | addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); |
246 | addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); | 244 | addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); |
247 | addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); | 245 | addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); |
248 | addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); | 246 | addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); |
249 | addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); | 247 | addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); |
250 | addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); | 248 | addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); |
251 | addItemBool("UseAppColors",&mUseAppColors,false); | 249 | addItemBool("UseAppColors",&mUseAppColors,false); |
252 | 250 | ||
253 | 251 | ||
254 | 252 | ||
255 | KPrefs::setCurrentGroup("Views"); | 253 | KPrefs::setCurrentGroup("Views"); |
256 | addItemInt("Hour Size",&mHourSize,8); | 254 | addItemInt("Hour Size",&mHourSize,8); |
257 | addItemBool("Show Daily Recurrences",&mDailyRecur,true); | 255 | addItemBool("Show Daily Recurrences",&mDailyRecur,true); |
258 | addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); | 256 | addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); |
259 | addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); | 257 | addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); |
260 | addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); | 258 | addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); |
261 | addItemBool("ShowShortMonthName",&mMonthShowShort,false); | 259 | addItemBool("ShowShortMonthName",&mMonthShowShort,false); |
262 | addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); | 260 | addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); |
263 | addItemBool("Enable ToolTips",&mEnableToolTips,false); | 261 | addItemBool("Enable ToolTips",&mEnableToolTips,false); |
264 | addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); | 262 | addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); |
265 | addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); | 263 | addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); |
266 | addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); | 264 | addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); |
267 | addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); | 265 | addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); |
268 | addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,false); | 266 | addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,false); |
269 | addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); | 267 | addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); |
270 | addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); | 268 | addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); |
271 | addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); | 269 | addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); |
272 | addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); | 270 | addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); |
273 | addItemBool("WNViewShowsParents",&mWNViewShowsParents,true); | 271 | addItemBool("WNViewShowsParents",&mWNViewShowsParents,true); |
274 | addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); | 272 | addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); |
275 | addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); | 273 | addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); |
276 | addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); | 274 | addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); |
277 | addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); | 275 | addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); |
278 | addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); | 276 | addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); |
279 | addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,false); | 277 | addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,false); |
280 | addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); | 278 | addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); |
281 | addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); | 279 | addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); |
282 | #ifdef DESKTOP_VERSION | 280 | #ifdef DESKTOP_VERSION |
283 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); | 281 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); |
284 | #else | 282 | #else |
285 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); | 283 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); |
286 | #endif | 284 | #endif |
287 | addItemInt("Day Begins",&mDayBegins,7); | 285 | addItemInt("Day Begins",&mDayBegins,7); |
288 | addItemInt("Working Hours Start",&mWorkingHoursStart,8); | 286 | addItemInt("Working Hours Start",&mWorkingHoursStart,8); |
289 | addItemInt("Working Hours End",&mWorkingHoursEnd,17); | 287 | addItemInt("Working Hours End",&mWorkingHoursEnd,17); |
290 | addItemBool("Exclude Holidays",&mExcludeHolidays,true); | 288 | addItemBool("Exclude Holidays",&mExcludeHolidays,true); |
291 | addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); | 289 | addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); |
292 | 290 | ||
293 | addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); | 291 | addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); |
294 | addItemBool("Full View Month",&mFullViewMonth,true); | 292 | addItemBool("Full View Month",&mFullViewMonth,true); |
295 | addItemBool("Full View Todo",&mFullViewTodo,true); | 293 | addItemBool("Full View Todo",&mFullViewTodo,true); |
296 | addItemBool("Quick Todo",&mEnableQuickTodo,false); | 294 | addItemBool("Quick Todo",&mEnableQuickTodo,false); |
297 | 295 | ||
298 | addItemInt("Next X Days",&mNextXDays,3); | 296 | addItemInt("Next X Days",&mNextXDays,3); |
299 | 297 | ||
300 | KPrefs::setCurrentGroup("Printer"); | 298 | KPrefs::setCurrentGroup("Printer"); |
301 | 299 | ||
302 | KPrefs::setCurrentGroup("Layout"); | 300 | KPrefs::setCurrentGroup("Layout"); |
303 | 301 | ||
304 | addItemBool("CompactDialogs",&mCompactDialogs,false); | 302 | addItemBool("CompactDialogs",&mCompactDialogs,false); |
305 | addItemBool("VerticalScreen",&mVerticalScreen,true); | 303 | addItemBool("VerticalScreen",&mVerticalScreen,true); |
306 | 304 | ||
307 | KPrefs::setCurrentGroup("KOrganizer Plugins"); | 305 | KPrefs::setCurrentGroup("KOrganizer Plugins"); |
308 | 306 | ||
309 | addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); | 307 | addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); |
310 | 308 | ||
311 | KPrefs::setCurrentGroup("Group Scheduling"); | 309 | KPrefs::setCurrentGroup("Group Scheduling"); |
312 | 310 | ||
313 | addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); | 311 | addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); |
314 | addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); | 312 | addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); |
315 | addItemStringList("AdditionalMails",&mAdditionalMails,""); | 313 | addItemStringList("AdditionalMails",&mAdditionalMails,""); |
316 | addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); | 314 | addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); |
317 | addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); | 315 | addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); |
318 | addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); | 316 | addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); |
319 | addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); | 317 | addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); |
320 | addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); | 318 | addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); |
321 | 319 | ||
322 | KPrefs::setCurrentGroup( "Editors" ); | 320 | KPrefs::setCurrentGroup( "Editors" ); |
323 | 321 | ||
324 | addItemStringList( "EventTemplates", &mEventTemplates ); | 322 | addItemStringList( "EventTemplates", &mEventTemplates ); |
325 | addItemStringList( "TodoTemplates", &mTodoTemplates ); | 323 | addItemStringList( "TodoTemplates", &mTodoTemplates ); |
326 | 324 | ||
327 | addItemInt("DestinationPolicy",&mDestination,standardDestination); | 325 | addItemInt("DestinationPolicy",&mDestination,standardDestination); |
328 | 326 | ||
329 | 327 | ||
330 | 328 | ||
331 | } | 329 | } |
332 | 330 | ||
333 | 331 | ||
334 | KOPrefs::~KOPrefs() | 332 | KOPrefs::~KOPrefs() |
335 | { | 333 | { |
336 | if (mInstance == this) | 334 | if (mInstance == this) |
337 | mInstance = insd.setObject(0); | 335 | mInstance = insd.setObject(0); |
338 | setLocaleDict( 0 ); | 336 | setLocaleDict( 0 ); |
339 | if ( mLocaleDict ) | 337 | if ( mLocaleDict ) |
340 | delete mLocaleDict; | 338 | delete mLocaleDict; |
341 | //qDebug("KOPrefs::~KOPrefs() "); | 339 | //qDebug("KOPrefs::~KOPrefs() "); |
342 | } | 340 | } |
343 | 341 | ||
344 | 342 | ||
345 | KOPrefs *KOPrefs::instance() | 343 | KOPrefs *KOPrefs::instance() |
346 | { | 344 | { |
347 | if (!mInstance) { | 345 | if (!mInstance) { |
348 | mInstance = insd.setObject(new KOPrefs()); | 346 | mInstance = insd.setObject(new KOPrefs()); |
349 | mInstance->readConfig(); | 347 | mInstance->readConfig(); |
350 | } | 348 | } |
351 | 349 | ||
352 | return mInstance; | 350 | return mInstance; |
353 | } | 351 | } |
354 | 352 | ||
355 | void KOPrefs::usrSetDefaults() | 353 | void KOPrefs::usrSetDefaults() |
356 | { | 354 | { |
357 | 355 | ||
358 | } | 356 | } |
359 | 357 | ||
360 | void KOPrefs::fillMailDefaults() | 358 | void KOPrefs::fillMailDefaults() |
361 | { | 359 | { |
362 | if (mName.isEmpty()) mName = i18n("Anonymous"); | 360 | if (mName.isEmpty()) mName = i18n("Anonymous"); |
363 | if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); | 361 | if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); |
364 | } | 362 | } |
365 | 363 | ||
366 | void KOPrefs::setTimeZoneIdDefault() | 364 | void KOPrefs::setTimeZoneIdDefault() |
367 | { | 365 | { |
368 | mTimeZoneId = i18n("+01:00 Europe/Oslo(CET)"); | 366 | mTimeZoneId = i18n("+01:00 Europe/Oslo(CET)"); |
369 | } | 367 | } |
370 | 368 | ||
371 | void KOPrefs::setCategoryDefaults() | 369 | void KOPrefs::setCategoryDefaults() |
372 | { | 370 | { |
373 | mCustomCategories.clear(); | 371 | mCustomCategories.clear(); |
374 | mCustomCategories = getDefaultList(); | 372 | mCustomCategories = getDefaultList(); |
375 | 373 | ||
376 | QStringList::Iterator it; | 374 | QStringList::Iterator it; |
377 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { | 375 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { |
378 | setCategoryColor(*it,mDefaultCategoryColor); | 376 | setCategoryColor(*it,mDefaultCategoryColor); |
379 | } | 377 | } |
380 | } | 378 | } |
381 | 379 | ||
382 | QStringList KOPrefs::getDefaultList() | 380 | QStringList KOPrefs::getDefaultList() |
383 | { | 381 | { |
384 | QStringList retval ; | 382 | QStringList retval ; |
385 | 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") |
386 | << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner") | 384 | << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner") |
387 | << 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") |
388 | << 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") |
389 | << 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") |
390 | << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping") | 388 | << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping") |
391 | << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University") | 389 | << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University") |
392 | << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ; | 390 | << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ; |
393 | retval.sort(); | 391 | retval.sort(); |
394 | return retval; | 392 | return retval; |
395 | } | 393 | } |
396 | 394 | ||
397 | void KOPrefs::usrReadConfig() | 395 | void KOPrefs::usrReadConfig() |
398 | { | 396 | { |
399 | mPreferredLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; | 397 | mPreferredLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; |
400 | mLocaleDict = 0; | 398 | mLocaleDict = 0; |
401 | // pending LR fix translation | 399 | // pending LR fix translation |
402 | // qDebug("KOPrefs::usrReadConfig() fix translation "); | 400 | // qDebug("KOPrefs::usrReadConfig() fix translation "); |
403 | if ( mPreferredLanguage > 0 && mPreferredLanguage < 4 ) { | 401 | if ( mPreferredLanguage > 0 && mPreferredLanguage < 4 ) { |
404 | if ( mPreferredLanguage == 1 ) { | 402 | if ( mPreferredLanguage == 1 ) { |
405 | mLocaleDict = new QDict<QString>; | 403 | mLocaleDict = new QDict<QString>; |
406 | int i = 0; | 404 | int i = 0; |
407 | QString fw ( germanwords[i] [0]); | 405 | QString fw ( germanwords[i] [0]); |
408 | while ( !fw.isEmpty() ) { | 406 | while ( !fw.isEmpty() ) { |
409 | mLocaleDict->insert( fw, new QString (germanwords[i] [1] )); | 407 | mLocaleDict->insert( fw, new QString (germanwords[i] [1] )); |
410 | ++i; | 408 | ++i; |
411 | fw = germanwords[i] [0]; | 409 | fw = germanwords[i] [0]; |
412 | } | 410 | } |
413 | 411 | ||
414 | setLocaleDict( mLocaleDict ); | 412 | setLocaleDict( mLocaleDict ); |
415 | } else { | 413 | } else { |
416 | QString fileName ; | 414 | QString fileName ; |
417 | if ( mPreferredLanguage == 3 ) | 415 | if ( mPreferredLanguage == 3 ) |
418 | fileName = MainWindow::resourcePath()+"usertranslation.txt"; | 416 | fileName = MainWindow::resourcePath()+"usertranslation.txt"; |
419 | else if ( mPreferredLanguage == 2 ) | 417 | else if ( mPreferredLanguage == 2 ) |
420 | fileName = MainWindow::resourcePath()+"frenchtranslation.txt"; | 418 | fileName = MainWindow::resourcePath()+"frenchtranslation.txt"; |
421 | QFile file( fileName ); | 419 | QFile file( fileName ); |
422 | if (file.open( IO_ReadOnly ) ) { | 420 | if (file.open( IO_ReadOnly ) ) { |
423 | QTextStream ts( &file ); | 421 | QTextStream ts( &file ); |
424 | ts.setEncoding( QTextStream::Latin1 ); | 422 | ts.setEncoding( QTextStream::Latin1 ); |
425 | //ts.setCodec( QTextCodec::latin1 ); | 423 | //ts.setCodec( QTextCodec::latin1 ); |
426 | QString text = ts.read(); | 424 | QString text = ts.read(); |
427 | file.close(); | 425 | file.close(); |
428 | text.replace( QRegExp("\\\\n"), "\n" ); | 426 | text.replace( QRegExp("\\\\n"), "\n" ); |
429 | QString line; | 427 | QString line; |
430 | QString we; | 428 | QString we; |
431 | QString wt; | 429 | QString wt; |
432 | int br = 0; | 430 | int br = 0; |
433 | int nbr; | 431 | int nbr; |
434 | nbr = text.find ( "},", br ); | 432 | nbr = text.find ( "},", br ); |
435 | line = text.mid( br, nbr - br ); | 433 | line = text.mid( br, nbr - br ); |
436 | br = nbr+1; | 434 | br = nbr+1; |
437 | int se, ee, st, et; | 435 | int se, ee, st, et; |
438 | mLocaleDict = new QDict<QString>; | 436 | mLocaleDict = new QDict<QString>; |
439 | QString end = "{ \"\",\"\" }"; | 437 | QString end = "{ \"\",\"\" }"; |
440 | while ( (line != end) && (br > 1) ) { | 438 | while ( (line != end) && (br > 1) ) { |
441 | //qDebug("%d *%s* ", br, line.latin1()); | 439 | //qDebug("%d *%s* ", br, line.latin1()); |
442 | se = line.find("\"")+1; | 440 | se = line.find("\"")+1; |
443 | et = line.findRev("\"",-1); | 441 | et = line.findRev("\"",-1); |
444 | ee = line.find("\",\""); | 442 | ee = line.find("\",\""); |
445 | st = ee+3; | 443 | st = ee+3; |
446 | we = line.mid( se, ee-se ); | 444 | we = line.mid( se, ee-se ); |
447 | wt = line.mid( st, et-st ); | 445 | wt = line.mid( st, et-st ); |
448 | //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); | 446 | //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); |
449 | mLocaleDict->insert( we, new QString (wt) ); | 447 | mLocaleDict->insert( we, new QString (wt) ); |
450 | nbr = text.find ( "}", br ); | 448 | nbr = text.find ( "}", br ); |
451 | line = text.mid( br, nbr - br ); | 449 | line = text.mid( br, nbr - br ); |
452 | br = nbr+1; | 450 | br = nbr+1; |
453 | } | 451 | } |
454 | //qDebug("end *%s* ", end.latin1()); | 452 | //qDebug("end *%s* ", end.latin1()); |
455 | 453 | ||
456 | setLocaleDict( mLocaleDict ); | 454 | setLocaleDict( mLocaleDict ); |
457 | } else { | 455 | } else { |
458 | qDebug("KO: Cannot find translation file %s",fileName.latin1() ); | 456 | qDebug("KO: Cannot find translation file %s",fileName.latin1() ); |
459 | } | 457 | } |
460 | 458 | ||
461 | } | 459 | } |
462 | } | 460 | } |
463 | config()->setGroup("General"); | 461 | config()->setGroup("General"); |
464 | 462 | ||
465 | mCustomCategories = config()->readListEntry("Custom Categories"); | 463 | mCustomCategories = config()->readListEntry("Custom Categories"); |
466 | if ( KOPrefs::instance()->mLanguageChanged ) { | 464 | if ( KOPrefs::instance()->mLanguageChanged ) { |
467 | mLocationDefaults.clear(); | 465 | mLocationDefaults.clear(); |
468 | mEventSummaryUser.clear(); | 466 | mEventSummaryUser.clear(); |
469 | mTodoSummaryUser.clear(); | 467 | mTodoSummaryUser.clear(); |
470 | } | 468 | } |
471 | if (mLocationDefaults.isEmpty()) { | 469 | if (mLocationDefaults.isEmpty()) { |
472 | mLocationDefaults << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") | 470 | mLocationDefaults << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") |
473 | << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") | 471 | << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") |
474 | << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; | 472 | << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; |
475 | // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") | 473 | // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") |
476 | mLocationDefaults.sort(); | 474 | mLocationDefaults.sort(); |
477 | } | 475 | } |
478 | 476 | ||
479 | if (mEventSummaryUser.isEmpty()) { | 477 | if (mEventSummaryUser.isEmpty()) { |
480 | mEventSummaryUser = getDefaultList() ; | 478 | mEventSummaryUser = getDefaultList() ; |
481 | } | 479 | } |
482 | if (mTodoSummaryUser.isEmpty()) { | 480 | if (mTodoSummaryUser.isEmpty()) { |
483 | mTodoSummaryUser = getDefaultList() ; | 481 | mTodoSummaryUser = getDefaultList() ; |
484 | } | 482 | } |
485 | 483 | ||
486 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); | 484 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); |
487 | 485 | ||
488 | config()->setGroup("Personal Settings"); | 486 | config()->setGroup("Personal Settings"); |
489 | mName = config()->readEntry("user_name",""); | 487 | mName = config()->readEntry("user_name",""); |
490 | mEmail = config()->readEntry("user_email",""); | 488 | mEmail = config()->readEntry("user_email",""); |
491 | fillMailDefaults(); | 489 | fillMailDefaults(); |
492 | 490 | ||
493 | config()->setGroup("Category Colors"); | 491 | config()->setGroup("Category Colors"); |
494 | QStringList::Iterator it; | 492 | QStringList::Iterator it; |
495 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { | 493 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { |
496 | setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); | 494 | setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); |
497 | 495 | ||
498 | } | 496 | } |
499 | 497 | ||
500 | if (mTimeZoneId.isEmpty()) { | 498 | if (mTimeZoneId.isEmpty()) { |
501 | setTimeZoneIdDefault(); | 499 | setTimeZoneIdDefault(); |
502 | } | 500 | } |
503 | KPimPrefs::usrReadConfig(); | 501 | KPimPrefs::usrReadConfig(); |
504 | } | 502 | } |
505 | 503 | ||
506 | 504 | ||
507 | void KOPrefs::usrWriteConfig() | 505 | void KOPrefs::usrWriteConfig() |
508 | { | 506 | { |
509 | config()->setGroup("General"); | 507 | config()->setGroup("General"); |
510 | config()->writeEntry("Custom Categories",mCustomCategories); | 508 | config()->writeEntry("Custom Categories",mCustomCategories); |
511 | 509 | ||
512 | config()->setGroup("Personal Settings"); | 510 | config()->setGroup("Personal Settings"); |
513 | config()->writeEntry("user_name",mName); | 511 | config()->writeEntry("user_name",mName); |
514 | config()->writeEntry("user_email",mEmail); | 512 | config()->writeEntry("user_email",mEmail); |
515 | 513 | ||
516 | config()->setGroup("Category Colors"); | 514 | config()->setGroup("Category Colors"); |
517 | QDictIterator<QColor> it(mCategoryColors); | 515 | QDictIterator<QColor> it(mCategoryColors); |
518 | while (it.current()) { | 516 | while (it.current()) { |
519 | config()->writeEntry(it.currentKey(),*(it.current())); | 517 | config()->writeEntry(it.currentKey(),*(it.current())); |
520 | ++it; | 518 | ++it; |
521 | } | 519 | } |
522 | 520 | ||
523 | 521 | ||
524 | KPimPrefs::usrWriteConfig(); | 522 | KPimPrefs::usrWriteConfig(); |
525 | } | 523 | } |
526 | 524 | ||
527 | void KOPrefs::setCategoryColor(QString cat,const QColor & color) | 525 | void KOPrefs::setCategoryColor(QString cat,const QColor & color) |
528 | { | 526 | { |
529 | mCategoryColors.replace(cat,new QColor(color)); | 527 | mCategoryColors.replace(cat,new QColor(color)); |
530 | } | 528 | } |
531 | 529 | ||
532 | QColor *KOPrefs::categoryColor(QString cat) | 530 | QColor *KOPrefs::categoryColor(QString cat) |
533 | { | 531 | { |
534 | QColor *color = 0; | 532 | QColor *color = 0; |
535 | 533 | ||
536 | if (!cat.isEmpty()) color = mCategoryColors[cat]; | 534 | if (!cat.isEmpty()) color = mCategoryColors[cat]; |
537 | 535 | ||
538 | if (color) return color; | 536 | if (color) return color; |
539 | else return &mDefaultCategoryColor; | 537 | else return &mDefaultCategoryColor; |
540 | } | 538 | } |
541 | 539 | ||
542 | void KOPrefs::setFullName(const QString &name) | 540 | void KOPrefs::setFullName(const QString &name) |
543 | { | 541 | { |
544 | mName = name; | 542 | mName = name; |
545 | } | 543 | } |
546 | 544 | ||
547 | void KOPrefs::setEmail(const QString &email) | 545 | void KOPrefs::setEmail(const QString &email) |
548 | { | 546 | { |
549 | //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); | 547 | //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); |
550 | mEmail = email; | 548 | mEmail = email; |
551 | } | 549 | } |
552 | 550 | ||
553 | QString KOPrefs::fullName() | 551 | QString KOPrefs::fullName() |
554 | { | 552 | { |
555 | if (mEmailControlCenter) { | 553 | if (mEmailControlCenter) { |
556 | KEMailSettings settings; | 554 | KEMailSettings settings; |
557 | return settings.getSetting(KEMailSettings::RealName); | 555 | return settings.getSetting(KEMailSettings::RealName); |
558 | } else { | 556 | } else { |
559 | return mName; | 557 | return mName; |
560 | } | 558 | } |
561 | } | 559 | } |
562 | 560 | ||
563 | QString KOPrefs::email() | 561 | QString KOPrefs::email() |
564 | { | 562 | { |
565 | if (mEmailControlCenter) { | 563 | if (mEmailControlCenter) { |
566 | KEMailSettings settings; | 564 | KEMailSettings settings; |
567 | return settings.getSetting(KEMailSettings::EmailAddress); | 565 | return settings.getSetting(KEMailSettings::EmailAddress); |
568 | } else { | 566 | } else { |
569 | return mEmail; | 567 | return mEmail; |
570 | } | 568 | } |
571 | } | 569 | } |
572 | KConfig* KOPrefs::getConfig() | 570 | KConfig* KOPrefs::getConfig() |
573 | { | 571 | { |
574 | return config(); | 572 | return config(); |
575 | } | 573 | } |
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h index d9ac851..ff09e19 100644 --- a/korganizer/koprefs.h +++ b/korganizer/koprefs.h | |||
@@ -1,313 +1,312 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef KOPREFS_H | 23 | #ifndef KOPREFS_H |
24 | #define KOPREFS_H | 24 | #define KOPREFS_H |
25 | 25 | ||
26 | #include <qdict.h> | 26 | #include <qdict.h> |
27 | 27 | ||
28 | #include <libkdepim/kpimprefs.h> | 28 | #include <libkdepim/kpimprefs.h> |
29 | 29 | ||
30 | class KConfig; | 30 | class KConfig; |
31 | class QFont; | 31 | class QFont; |
32 | class QColor; | 32 | class QColor; |
33 | class QStringList; | 33 | class QStringList; |
34 | 34 | ||
35 | class KOPrefs : public KPimPrefs | 35 | class KOPrefs : public KPimPrefs |
36 | { | 36 | { |
37 | public: | 37 | public: |
38 | enum { FormatVCalendar, FormatICalendar }; | 38 | enum { FormatVCalendar, FormatICalendar }; |
39 | enum { MailClientKMail, MailClientSendmail }; | 39 | enum { MailClientKMail, MailClientSendmail }; |
40 | enum { IMIPDummy, IMIPKMail }; | 40 | enum { IMIPDummy, IMIPKMail }; |
41 | enum { IMIPOutbox, IMIPdirectsend }; | 41 | enum { IMIPOutbox, IMIPdirectsend }; |
42 | enum { neverAuto, addressbookAuto, selectedAuto }; | 42 | enum { neverAuto, addressbookAuto, selectedAuto }; |
43 | enum { standardDestination, askDestination }; | 43 | enum { standardDestination, askDestination }; |
44 | 44 | ||
45 | virtual ~KOPrefs(); | 45 | virtual ~KOPrefs(); |
46 | 46 | ||
47 | /** Get instance of KOPrefs. It is made sure that there is only one | 47 | /** Get instance of KOPrefs. It is made sure that there is only one |
48 | instance. */ | 48 | instance. */ |
49 | static KOPrefs *instance(); | 49 | static KOPrefs *instance(); |
50 | 50 | ||
51 | /** Set preferences to default values */ | 51 | /** Set preferences to default values */ |
52 | void usrSetDefaults(); | 52 | void usrSetDefaults(); |
53 | 53 | ||
54 | /** Read preferences from config file */ | 54 | /** Read preferences from config file */ |
55 | void usrReadConfig(); | 55 | void usrReadConfig(); |
56 | 56 | ||
57 | /** Write preferences to config file */ | 57 | /** Write preferences to config file */ |
58 | void usrWriteConfig(); | 58 | void usrWriteConfig(); |
59 | void setCategoryDefaults(); | 59 | void setCategoryDefaults(); |
60 | 60 | ||
61 | protected: | 61 | protected: |
62 | void setTimeZoneIdDefault(); | 62 | void setTimeZoneIdDefault(); |
63 | 63 | ||
64 | /** Fill empty mail fields with default values. */ | 64 | /** Fill empty mail fields with default values. */ |
65 | void fillMailDefaults(); | 65 | void fillMailDefaults(); |
66 | 66 | ||
67 | private: | 67 | private: |
68 | /** Constructor disabled for public. Use instance() to create a KOPrefs | 68 | /** Constructor disabled for public. Use instance() to create a KOPrefs |
69 | object. */ | 69 | object. */ |
70 | KOPrefs(); | 70 | KOPrefs(); |
71 | 71 | ||
72 | static KOPrefs *mInstance; | 72 | static KOPrefs *mInstance; |
73 | QDict<QString> *mLocaleDict; | 73 | QDict<QString> *mLocaleDict; |
74 | QStringList getDefaultList(); | 74 | QStringList getDefaultList(); |
75 | public: | 75 | public: |
76 | // preferences data | 76 | // preferences data |
77 | KConfig* getConfig(); | 77 | KConfig* getConfig(); |
78 | void setFullName(const QString &); | 78 | void setFullName(const QString &); |
79 | QString fullName(); | 79 | QString fullName(); |
80 | void setEmail(const QString &); | 80 | void setEmail(const QString &); |
81 | QString email(); | 81 | QString email(); |
82 | 82 | ||
83 | QString mAdditional; | 83 | QString mAdditional; |
84 | 84 | ||
85 | bool mEmailControlCenter; | 85 | bool mEmailControlCenter; |
86 | 86 | ||
87 | bool mBcc; | 87 | bool mBcc; |
88 | bool mAutoSave; | 88 | bool mAutoSave; |
89 | int mAutoSaveInterval; | 89 | int mAutoSaveInterval; |
90 | bool mConfirm; | 90 | bool mConfirm; |
91 | 91 | ||
92 | bool mEnableGroupScheduling; | 92 | bool mEnableGroupScheduling; |
93 | bool mEnableProjectView; | 93 | bool mEnableProjectView; |
94 | 94 | ||
95 | int mDefaultFormat; | 95 | int mDefaultFormat; |
96 | int mMailClient; | 96 | int mMailClient; |
97 | 97 | ||
98 | QString mTimeZone; | 98 | QString mTimeZone; |
99 | //QString mTimeZoneName; // e.g. +00:04:00 Indian/Mauritius | 99 | //QString mTimeZoneName; // e.g. +00:04:00 Indian/Mauritius |
100 | //int mTimeZoneOffset; // e.g. -240 min | 100 | //int mTimeZoneOffset; // e.g. -240 min |
101 | int mStartTime; | 101 | int mStartTime; |
102 | int mDefaultDuration; | 102 | int mDefaultDuration; |
103 | int mAlarmTime; | 103 | int mAlarmTime; |
104 | int mDaylightSavings; | 104 | int mDaylightSavings; |
105 | 105 | ||
106 | int mWorkingHoursStart; | 106 | int mWorkingHoursStart; |
107 | int mWorkingHoursEnd; | 107 | int mWorkingHoursEnd; |
108 | bool mExcludeHolidays; | 108 | bool mExcludeHolidays; |
109 | bool mExcludeSaturdays; | 109 | bool mExcludeSaturdays; |
110 | bool mMarcusBainsShowSeconds; | 110 | bool mMarcusBainsShowSeconds; |
111 | 111 | ||
112 | QFont mTimeBarFont; | 112 | QFont mTimeBarFont; |
113 | QFont mMonthViewFont; | 113 | QFont mMonthViewFont; |
114 | QFont mAgendaViewFont; | 114 | QFont mAgendaViewFont; |
115 | QFont mMarcusBainsFont; | 115 | QFont mMarcusBainsFont; |
116 | QFont mTimeLabelsFont; | 116 | QFont mTimeLabelsFont; |
117 | QFont mTodoViewFont; | 117 | QFont mTodoViewFont; |
118 | QFont mListViewFont; | 118 | QFont mListViewFont; |
119 | QFont mDateNavigatorFont; | 119 | QFont mDateNavigatorFont; |
120 | QFont mEditBoxFont; | 120 | QFont mEditBoxFont; |
121 | QFont mJornalViewFont; | 121 | QFont mJornalViewFont; |
122 | QFont mWhatsNextFont; | 122 | QFont mWhatsNextFont; |
123 | QFont mEventViewFont; | 123 | QFont mEventViewFont; |
124 | 124 | ||
125 | 125 | ||
126 | 126 | ||
127 | 127 | ||
128 | QColor mHolidayColor; | 128 | QColor mHolidayColor; |
129 | QColor mHighlightColor; | 129 | QColor mHighlightColor; |
130 | QColor mEventColor; | 130 | QColor mEventColor; |
131 | QColor mAgendaBgColor; | 131 | QColor mAgendaBgColor; |
132 | QColor mWorkingHoursColor; | 132 | QColor mWorkingHoursColor; |
133 | QColor mTodoDueTodayColor; | 133 | QColor mTodoDueTodayColor; |
134 | QColor mTodoOverdueColor; | 134 | QColor mTodoOverdueColor; |
135 | QColor mMonthViewEvenColor; | 135 | QColor mMonthViewEvenColor; |
136 | QColor mMonthViewOddColor; | 136 | QColor mMonthViewOddColor; |
137 | QColor mMonthViewHolidayColor; | 137 | QColor mMonthViewHolidayColor; |
138 | bool mMonthViewUsesDayColors; | 138 | bool mMonthViewUsesDayColors; |
139 | bool mMonthViewSatSunTog; | 139 | bool mMonthViewSatSunTog; |
140 | QColor mAppColor1; | 140 | QColor mAppColor1; |
141 | QColor mAppColor2; | 141 | QColor mAppColor2; |
142 | bool mUseAppColors; | 142 | bool mUseAppColors; |
143 | 143 | ||
144 | int mDayBegins; | 144 | int mDayBegins; |
145 | int mHourSize; | 145 | int mHourSize; |
146 | int mAllDaySize; | 146 | int mAllDaySize; |
147 | bool mShowFullMenu; | 147 | bool mShowFullMenu; |
148 | bool mDailyRecur; | 148 | bool mDailyRecur; |
149 | bool mWeeklyRecur; | 149 | bool mWeeklyRecur; |
150 | bool mMonthDailyRecur; | 150 | bool mMonthDailyRecur; |
151 | bool mMonthWeeklyRecur; | 151 | bool mMonthWeeklyRecur; |
152 | bool mMonthShowIcons; | 152 | bool mMonthShowIcons; |
153 | bool mMonthShowShort; | 153 | bool mMonthShowShort; |
154 | bool mEnableToolTips; | 154 | bool mEnableToolTips; |
155 | bool mEnableMonthScroll; | 155 | bool mEnableMonthScroll; |
156 | bool mFullViewMonth; | 156 | bool mFullViewMonth; |
157 | bool mMonthViewUsesCategoryColor; | 157 | bool mMonthViewUsesCategoryColor; |
158 | bool mFullViewTodo; | 158 | bool mFullViewTodo; |
159 | bool mShowCompletedTodo; | 159 | bool mShowCompletedTodo; |
160 | bool mMarcusBainsEnabled; | 160 | bool mMarcusBainsEnabled; |
161 | int mNextXDays; | 161 | int mNextXDays; |
162 | int mWhatsNextDays; | 162 | int mWhatsNextDays; |
163 | int mWhatsNextPrios; | 163 | int mWhatsNextPrios; |
164 | bool mEnableQuickTodo; | 164 | bool mEnableQuickTodo; |
165 | bool mLanguageChanged; | 165 | bool mLanguageChanged; |
166 | 166 | ||
167 | bool mCompactDialogs; | 167 | bool mCompactDialogs; |
168 | bool mVerticalScreen; | 168 | bool mVerticalScreen; |
169 | 169 | ||
170 | bool mShowIconNewTodo; | 170 | bool mShowIconNewTodo; |
171 | bool mShowIconNewEvent; | 171 | bool mShowIconNewEvent; |
172 | bool mShowIconSearch; | 172 | bool mShowIconSearch; |
173 | bool mShowIconList; | 173 | bool mShowIconList; |
174 | bool mShowIconDay1; | 174 | bool mShowIconDay1; |
175 | bool mShowIconDay5; | 175 | bool mShowIconDay5; |
176 | bool mShowIconDay7; | 176 | bool mShowIconDay7; |
177 | bool mShowIconMonth; | 177 | bool mShowIconMonth; |
178 | bool mShowIconTodoview; | 178 | bool mShowIconTodoview; |
179 | bool mShowIconBackFast; | 179 | bool mShowIconBackFast; |
180 | bool mShowIconBack; | 180 | bool mShowIconBack; |
181 | bool mShowIconToday; | 181 | bool mShowIconToday; |
182 | bool mShowIconForward; | 182 | bool mShowIconForward; |
183 | bool mShowIconForwardFast; | 183 | bool mShowIconForwardFast; |
184 | bool mShowIconWhatsThis; | 184 | bool mShowIconWhatsThis; |
185 | bool mShowIconNextDays; | 185 | bool mShowIconNextDays; |
186 | bool mShowIconNext; | 186 | bool mShowIconNext; |
187 | bool mShowIconJournal; | 187 | bool mShowIconJournal; |
188 | 188 | ||
189 | bool mShowIconStretch; | 189 | bool mShowIconStretch; |
190 | 190 | ||
191 | bool mToolBarHor; | 191 | bool mToolBarHor; |
192 | bool mToolBarUp; | 192 | bool mToolBarUp; |
193 | bool mToolBarMiniIcons; | 193 | bool mToolBarMiniIcons; |
194 | 194 | ||
195 | bool mAskForQuit; | 195 | bool mAskForQuit; |
196 | bool mUsePassWd; | 196 | bool mUsePassWd; |
197 | bool mWriteBackFile; | 197 | bool mWriteBackFile; |
198 | int mWriteBackInFuture; | 198 | int mWriteBackInFuture; |
199 | bool mAskForPreferences; | 199 | bool mAskForPreferences; |
200 | bool mShowSyncSummary; | 200 | bool mShowSyncSummary; |
201 | bool mShowSyncEvents; | 201 | bool mShowSyncEvents; |
202 | bool mShowTodoInAgenda; | 202 | bool mShowTodoInAgenda; |
203 | bool mWriteBackExistingOnly; | 203 | bool mWriteBackExistingOnly; |
204 | 204 | ||
205 | QString mRemoteIP; | 205 | QString mRemoteIP; |
206 | QString mRemoteUser; | 206 | QString mRemoteUser; |
207 | QString mRemotePassWd; | 207 | QString mRemotePassWd; |
208 | QString mRemoteFile; | 208 | QString mRemoteFile; |
209 | QString mLocalTempFile; | 209 | QString mLocalTempFile; |
210 | QString mPhoneDevice; | 210 | QString mPhoneDevice; |
211 | QString mPhoneConnection; | 211 | QString mPhoneConnection; |
212 | QString mPhoneModel; | 212 | QString mPhoneModel; |
213 | 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 mShortDateInViewer; | 269 | bool mShortDateInViewer; |
270 | 270 | ||
271 | QStringList mLocationDefaults; | 271 | QStringList mLocationDefaults; |
272 | QStringList mEventSummaryUser; | 272 | QStringList mEventSummaryUser; |
273 | QStringList mTodoSummaryUser; | 273 | QStringList mTodoSummaryUser; |
274 | 274 | ||
275 | bool mUseInternalAlarmNotification; | 275 | bool mUseInternalAlarmNotification; |
276 | int mAlarmPlayBeeps; | 276 | int mAlarmPlayBeeps; |
277 | int mAlarmSuspendTime; | 277 | int mAlarmSuspendTime; |
278 | int mAlarmSuspendCount; | 278 | int mAlarmSuspendCount; |
279 | int mAlarmBeepInterval; | 279 | int mAlarmBeepInterval; |
280 | 280 | ||
281 | QString mPassiveSyncPort; | 281 | |
282 | QString mPassiveSyncPw; | ||
283 | QString mActiveSyncPort; | 282 | QString mActiveSyncPort; |
284 | QString mActiveSyncIP; | 283 | QString mActiveSyncIP; |
285 | 284 | ||
286 | 285 | ||
287 | //US I copied the following settings into KPimGlobalPrefs | 286 | //US I copied the following settings into KPimGlobalPrefs |
288 | // that allows us later to easily remove the settings from here. | 287 | // that allows us later to easily remove the settings from here. |
289 | int mPreferredDate; | 288 | int mPreferredDate; |
290 | QString mUserDateFormatLong; | 289 | QString mUserDateFormatLong; |
291 | QString mUserDateFormatShort; | 290 | QString mUserDateFormatShort; |
292 | int mPreferredLanguage; | 291 | int mPreferredLanguage; |
293 | int mPreferredTime; | 292 | int mPreferredTime; |
294 | bool mWeekStartsOnSunday; | 293 | bool mWeekStartsOnSunday; |
295 | QString mTimeZoneId; | 294 | QString mTimeZoneId; |
296 | bool mUseDaylightsaving; | 295 | bool mUseDaylightsaving; |
297 | int mDaylightsavingStart; | 296 | int mDaylightsavingStart; |
298 | int mDaylightsavingEnd; | 297 | int mDaylightsavingEnd; |
299 | 298 | ||
300 | 299 | ||
301 | private: | 300 | private: |
302 | QDict<QColor> mCategoryColors; | 301 | QDict<QColor> mCategoryColors; |
303 | QColor mDefaultCategoryColor; | 302 | QColor mDefaultCategoryColor; |
304 | 303 | ||
305 | QFont mDefaultTimeBarFont; | 304 | QFont mDefaultTimeBarFont; |
306 | QFont mDefaultViewFont; | 305 | QFont mDefaultViewFont; |
307 | QFont mDefaultMonthViewFont; | 306 | QFont mDefaultMonthViewFont; |
308 | 307 | ||
309 | QString mName; | 308 | QString mName; |
310 | QString mEmail; | 309 | QString mEmail; |
311 | }; | 310 | }; |
312 | 311 | ||
313 | #endif | 312 | #endif |
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 9104347..e3324ee 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -1,2669 +1,2348 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | 2 | ||
3 | #include <qaction.h> | 3 | #include <qaction.h> |
4 | #include <qpopupmenu.h> | 4 | #include <qpopupmenu.h> |
5 | #include <qpainter.h> | 5 | #include <qpainter.h> |
6 | #include <qwhatsthis.h> | 6 | #include <qwhatsthis.h> |
7 | #include <qpushbutton.h> | 7 | #include <qpushbutton.h> |
8 | #include <qmessagebox.h> | 8 | #include <qmessagebox.h> |
9 | #include <qlineedit.h> | 9 | #include <qlineedit.h> |
10 | #include <qtextcodec.h> | 10 | #include <qtextcodec.h> |
11 | #include <qfile.h> | 11 | #include <qfile.h> |
12 | #include <qdir.h> | 12 | #include <qdir.h> |
13 | #include <qapp.h> | 13 | #include <qapp.h> |
14 | #include <qfileinfo.h> | 14 | #include <qfileinfo.h> |
15 | #include <qlabel.h> | 15 | #include <qlabel.h> |
16 | #include <qspinbox.h> | 16 | #include <qspinbox.h> |
17 | #include <qcheckbox.h> | 17 | #include <qcheckbox.h> |
18 | #include <qmap.h> | 18 | #include <qmap.h> |
19 | #include <qwmatrix.h> | 19 | #include <qwmatrix.h> |
20 | #include <qtextbrowser.h> | 20 | #include <qtextbrowser.h> |
21 | #include <qtextstream.h> | 21 | #include <qtextstream.h> |
22 | #ifndef DESKTOP_VERSION | 22 | #ifndef DESKTOP_VERSION |
23 | #include <qpe/global.h> | 23 | #include <qpe/global.h> |
24 | #include <qpe/qpemenubar.h> | 24 | #include <qpe/qpemenubar.h> |
25 | #include <qpe/qpetoolbar.h> | 25 | #include <qpe/qpetoolbar.h> |
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
28 | #include <qtopia/alarmserver.h> | 28 | #include <qtopia/alarmserver.h> |
29 | #include <qtopia/qcopenvelope_qws.h> | 29 | #include <qtopia/qcopenvelope_qws.h> |
30 | #include <unistd.h> // for sleep | 30 | #include <unistd.h> // for sleep |
31 | #else | 31 | #else |
32 | #include <qmenubar.h> | 32 | #include <qmenubar.h> |
33 | #include <qtoolbar.h> | 33 | #include <qtoolbar.h> |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | //#include <resource.h> | 35 | //#include <resource.h> |
36 | 36 | ||
37 | #endif | 37 | #endif |
38 | #include <libkcal/calendarlocal.h> | 38 | #include <libkcal/calendarlocal.h> |
39 | #include <libkcal/todo.h> | 39 | #include <libkcal/todo.h> |
40 | #include <libkcal/phoneformat.h> | 40 | #include <libkcal/phoneformat.h> |
41 | #include <libkdepim/ksyncprofile.h> | 41 | #include <libkdepim/ksyncprofile.h> |
42 | #include <libkdepim/phoneaccess.h> | 42 | #include <libkdepim/phoneaccess.h> |
43 | #include <libkcal/kincidenceformatter.h> | 43 | #include <libkcal/kincidenceformatter.h> |
44 | #include <libkdepim/kpimglobalprefs.h> | 44 | #include <libkdepim/kpimglobalprefs.h> |
45 | 45 | ||
46 | #include "calendarview.h" | 46 | #include "calendarview.h" |
47 | #include "koviewmanager.h" | 47 | #include "koviewmanager.h" |
48 | #include "datenavigator.h" | 48 | #include "datenavigator.h" |
49 | #include "koagendaview.h" | 49 | #include "koagendaview.h" |
50 | #include "koagenda.h" | 50 | #include "koagenda.h" |
51 | #include "kodialogmanager.h" | 51 | #include "kodialogmanager.h" |
52 | #include "kdialogbase.h" | 52 | #include "kdialogbase.h" |
53 | #include "kapplication.h" | 53 | #include "kapplication.h" |
54 | #include "kofilterview.h" | 54 | #include "kofilterview.h" |
55 | #include "kstandarddirs.h" | 55 | #include "kstandarddirs.h" |
56 | #include "koprefs.h" | 56 | #include "koprefs.h" |
57 | #include "kfiledialog.h" | 57 | #include "kfiledialog.h" |
58 | #include "koglobals.h" | 58 | #include "koglobals.h" |
59 | #include "kglobal.h" | 59 | #include "kglobal.h" |
60 | #include "klocale.h" | 60 | #include "klocale.h" |
61 | #include "kconfig.h" | 61 | #include "kconfig.h" |
62 | #include "simplealarmclient.h" | 62 | #include "simplealarmclient.h" |
63 | #include "externalapphandler.h" | 63 | #include "externalapphandler.h" |
64 | 64 | ||
65 | using namespace KCal; | 65 | using namespace KCal; |
66 | #ifndef _WIN32_ | 66 | #ifndef _WIN32_ |
67 | #include <unistd.h> | 67 | #include <unistd.h> |
68 | #else | 68 | #else |
69 | #include "koimportoldialog.h" | 69 | #include "koimportoldialog.h" |
70 | #endif | 70 | #endif |
71 | #include "mainwindow.h" | 71 | #include "mainwindow.h" |
72 | 72 | ||
73 | class KOex2phonePrefs : public QDialog | 73 | class KOex2phonePrefs : public QDialog |
74 | { | 74 | { |
75 | public: | 75 | public: |
76 | KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : | 76 | KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : |
77 | QDialog( parent, name, true ) | 77 | QDialog( parent, name, true ) |
78 | { | 78 | { |
79 | setCaption( i18n("Export to phone options") ); | 79 | setCaption( i18n("Export to phone options") ); |
80 | QVBoxLayout* lay = new QVBoxLayout( this ); | 80 | QVBoxLayout* lay = new QVBoxLayout( this ); |
81 | lay->setSpacing( 3 ); | 81 | lay->setSpacing( 3 ); |
82 | lay->setMargin( 3 ); | 82 | lay->setMargin( 3 ); |
83 | QLabel *lab; | 83 | QLabel *lab; |
84 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); | 84 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); |
85 | lab->setAlignment (AlignHCenter ); | 85 | lab->setAlignment (AlignHCenter ); |
86 | QHBox* temphb; | 86 | QHBox* temphb; |
87 | temphb = new QHBox( this ); | 87 | temphb = new QHBox( this ); |
88 | new QLabel( i18n("I/O device: "), temphb ); | 88 | new QLabel( i18n("I/O device: "), temphb ); |
89 | mPhoneDevice = new QLineEdit( temphb); | 89 | mPhoneDevice = new QLineEdit( temphb); |
90 | lay->addWidget( temphb ); | 90 | lay->addWidget( temphb ); |
91 | temphb = new QHBox( this ); | 91 | temphb = new QHBox( this ); |
92 | new QLabel( i18n("Connection: "), temphb ); | 92 | new QLabel( i18n("Connection: "), temphb ); |
93 | mPhoneConnection = new QLineEdit( temphb); | 93 | mPhoneConnection = new QLineEdit( temphb); |
94 | lay->addWidget( temphb ); | 94 | lay->addWidget( temphb ); |
95 | temphb = new QHBox( this ); | 95 | temphb = new QHBox( this ); |
96 | new QLabel( i18n("Model(opt.): "), temphb ); | 96 | new QLabel( i18n("Model(opt.): "), temphb ); |
97 | mPhoneModel = new QLineEdit( temphb); | 97 | mPhoneModel = new QLineEdit( temphb); |
98 | lay->addWidget( temphb ); | 98 | lay->addWidget( temphb ); |
99 | mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); | 99 | mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); |
100 | mWriteBackFuture->setChecked( true ); | 100 | mWriteBackFuture->setChecked( true ); |
101 | lay->addWidget( mWriteBackFuture ); | 101 | lay->addWidget( mWriteBackFuture ); |
102 | temphb = new QHBox( this ); | 102 | temphb = new QHBox( this ); |
103 | new QLabel( i18n("Max. weeks in future: ") , temphb ); | 103 | new QLabel( i18n("Max. weeks in future: ") , temphb ); |
104 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); | 104 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); |
105 | mWriteBackFutureWeeks->setValue( 8 ); | 105 | mWriteBackFutureWeeks->setValue( 8 ); |
106 | lay->addWidget( temphb ); | 106 | lay->addWidget( temphb ); |
107 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); | 107 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); |
108 | lab->setAlignment (AlignHCenter ); | 108 | lab->setAlignment (AlignHCenter ); |
109 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); | 109 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); |
110 | lay->addWidget( ok ); | 110 | lay->addWidget( ok ); |
111 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 111 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
112 | lay->addWidget( cancel ); | 112 | lay->addWidget( cancel ); |
113 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 113 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
114 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 114 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
115 | resize( 220, 240 ); | 115 | resize( 220, 240 ); |
116 | 116 | ||
117 | } | 117 | } |
118 | 118 | ||
119 | public: | 119 | public: |
120 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | 120 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; |
121 | QCheckBox* mWriteBackFuture; | 121 | QCheckBox* mWriteBackFuture; |
122 | QSpinBox* mWriteBackFutureWeeks; | 122 | QSpinBox* mWriteBackFutureWeeks; |
123 | }; | 123 | }; |
124 | 124 | ||
125 | int globalFlagBlockStartup; | 125 | int globalFlagBlockStartup; |
126 | MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : | 126 | MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : |
127 | QMainWindow( parent, name ) | 127 | QMainWindow( parent, name ) |
128 | { | 128 | { |
129 | mPassWordPiSync = "abc"; | 129 | mPassWordPiSync = "abc"; |
130 | #ifdef DESKTOP_VERSION | 130 | #ifdef DESKTOP_VERSION |
131 | setFont( QFont("Arial"), 14 ); | 131 | setFont( QFont("Arial"), 14 ); |
132 | #endif | 132 | #endif |
133 | mSyncActionDialog = 0; | ||
134 | mServerSocket = 0; | 133 | mServerSocket = 0; |
135 | mClosed = false; | 134 | mClosed = false; |
136 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; | 135 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; |
137 | QString confFile = locateLocal("config","korganizerrc"); | 136 | QString confFile = locateLocal("config","korganizerrc"); |
138 | QFileInfo finf ( confFile ); | 137 | QFileInfo finf ( confFile ); |
139 | bool showWarning = !finf.exists(); | 138 | bool showWarning = !finf.exists(); |
140 | setIcon(SmallIcon( "ko24" ) ); | 139 | setIcon(SmallIcon( "ko24" ) ); |
141 | mBlockAtStartup = true; | 140 | mBlockAtStartup = true; |
142 | mFlagKeyPressed = false; | 141 | mFlagKeyPressed = false; |
143 | setCaption("KOrganizer/Pi"); | 142 | setCaption("KOrganizer/Pi"); |
144 | KOPrefs *p = KOPrefs::instance(); | 143 | KOPrefs *p = KOPrefs::instance(); |
145 | KPimGlobalPrefs::instance()->setGlobalConfig(); | 144 | KPimGlobalPrefs::instance()->setGlobalConfig(); |
146 | // if ( QApplication::desktop()->height() > 480 ) { | 145 | // if ( QApplication::desktop()->height() > 480 ) { |
147 | // if ( p->mHourSize == 4 ) | 146 | // if ( p->mHourSize == 4 ) |
148 | // p->mHourSize = 6; | 147 | // p->mHourSize = 6; |
149 | // } | 148 | // } |
150 | if ( p->mHourSize > 18 ) | 149 | if ( p->mHourSize > 18 ) |
151 | p->mHourSize = 18; | 150 | p->mHourSize = 18; |
152 | QMainWindow::ToolBarDock tbd; | 151 | QMainWindow::ToolBarDock tbd; |
153 | if ( p->mToolBarHor ) { | 152 | if ( p->mToolBarHor ) { |
154 | if ( p->mToolBarUp ) | 153 | if ( p->mToolBarUp ) |
155 | tbd = Bottom; | 154 | tbd = Bottom; |
156 | else | 155 | else |
157 | tbd = Top; | 156 | tbd = Top; |
158 | } | 157 | } |
159 | else { | 158 | else { |
160 | if ( p->mToolBarUp ) | 159 | if ( p->mToolBarUp ) |
161 | tbd = Right; | 160 | tbd = Right; |
162 | else | 161 | else |
163 | tbd = Left; | 162 | tbd = Left; |
164 | } | 163 | } |
165 | if ( KOPrefs::instance()->mUseAppColors ) | 164 | if ( KOPrefs::instance()->mUseAppColors ) |
166 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 165 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
167 | globalFlagBlockStartup = 1; | 166 | globalFlagBlockStartup = 1; |
168 | iconToolBar = new QPEToolBar( this ); | 167 | iconToolBar = new QPEToolBar( this ); |
169 | addToolBar (iconToolBar , tbd ); | 168 | addToolBar (iconToolBar , tbd ); |
170 | mBlockSaveFlag = false; | 169 | mBlockSaveFlag = false; |
171 | mCalendarModifiedFlag = false; | 170 | mCalendarModifiedFlag = false; |
172 | 171 | ||
173 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); | 172 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); |
174 | splash->setAlignment ( AlignCenter ); | 173 | splash->setAlignment ( AlignCenter ); |
175 | setCentralWidget( splash ); | 174 | setCentralWidget( splash ); |
176 | #ifndef DESKTOP_VERSION | 175 | #ifndef DESKTOP_VERSION |
177 | showMaximized(); | 176 | showMaximized(); |
178 | #endif | 177 | #endif |
179 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); | 178 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); |
180 | setDefaultPreferences(); | 179 | setDefaultPreferences(); |
181 | mCalendar = new CalendarLocal(); | 180 | mCalendar = new CalendarLocal(); |
182 | mView = new CalendarView( mCalendar, this,"mCalendar " ); | 181 | mView = new CalendarView( mCalendar, this,"mCalendar " ); |
183 | mView->hide(); | 182 | mView->hide(); |
184 | //mView->resize(splash->size() ); | 183 | //mView->resize(splash->size() ); |
185 | initActions(); | 184 | initActions(); |
186 | #ifndef DESKTOP_VERSION | 185 | #ifndef DESKTOP_VERSION |
187 | iconToolBar->show(); | 186 | iconToolBar->show(); |
188 | qApp->processEvents(); | 187 | qApp->processEvents(); |
189 | #endif | 188 | #endif |
190 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); | 189 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); |
191 | int vh = height() ; | 190 | int vh = height() ; |
192 | int vw = width(); | 191 | int vw = width(); |
193 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); | 192 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); |
194 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { | 193 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { |
195 | vh -= iconToolBar->height(); | 194 | vh -= iconToolBar->height(); |
196 | } else { | 195 | } else { |
197 | vw -= iconToolBar->height(); | 196 | vw -= iconToolBar->height(); |
198 | } | 197 | } |
199 | //mView->setMaximumSize( splash->size() ); | 198 | //mView->setMaximumSize( splash->size() ); |
200 | //mView->resize( splash->size() ); | 199 | //mView->resize( splash->size() ); |
201 | //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 ()); |
202 | mView->readSettings(); | 201 | mView->readSettings(); |
203 | bool newFile = false; | 202 | bool newFile = false; |
204 | if( !QFile::exists( defaultFileName() ) ) { | 203 | if( !QFile::exists( defaultFileName() ) ) { |
205 | QFileInfo finfo ( defaultFileName() ); | 204 | QFileInfo finfo ( defaultFileName() ); |
206 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); | 205 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); |
207 | qDebug("oldfile %s ", oldFile.latin1()); | 206 | qDebug("oldfile %s ", oldFile.latin1()); |
208 | 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"; | 207 | 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"; |
209 | finfo.setFile( oldFile ); | 208 | finfo.setFile( oldFile ); |
210 | if (finfo.exists() ) { | 209 | if (finfo.exists() ) { |
211 | KMessageBox::information( this, message); | 210 | KMessageBox::information( this, message); |
212 | mView->openCalendar( oldFile ); | 211 | mView->openCalendar( oldFile ); |
213 | qApp->processEvents(); | 212 | qApp->processEvents(); |
214 | } else { | 213 | } else { |
215 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); | 214 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); |
216 | finfo.setFile( oldFile ); | 215 | finfo.setFile( oldFile ); |
217 | if (finfo.exists() ) { | 216 | if (finfo.exists() ) { |
218 | KMessageBox::information( this, message); | 217 | KMessageBox::information( this, message); |
219 | mView->openCalendar( oldFile ); | 218 | mView->openCalendar( oldFile ); |
220 | qApp->processEvents(); | 219 | qApp->processEvents(); |
221 | } | 220 | } |
222 | } | 221 | } |
223 | mView->saveCalendar( defaultFileName() ); | 222 | mView->saveCalendar( defaultFileName() ); |
224 | newFile = true; | 223 | newFile = true; |
225 | } | 224 | } |
226 | 225 | ||
227 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 226 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
228 | mView->openCalendar( defaultFileName() ); | 227 | mView->openCalendar( defaultFileName() ); |
229 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 228 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
230 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); | 229 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); |
231 | 230 | ||
232 | if ( KOPrefs::instance()->mLanguageChanged ) { | 231 | if ( KOPrefs::instance()->mLanguageChanged ) { |
233 | KOPrefs::instance()->setCategoryDefaults(); | 232 | KOPrefs::instance()->setCategoryDefaults(); |
234 | int count = mView->addCategories(); | 233 | int count = mView->addCategories(); |
235 | KOPrefs::instance()->mLanguageChanged = false; | 234 | KOPrefs::instance()->mLanguageChanged = false; |
236 | } | 235 | } |
237 | processIncidenceSelection( 0 ); | 236 | processIncidenceSelection( 0 ); |
238 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), | 237 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), |
239 | SLOT( processIncidenceSelection( Incidence * ) ) ); | 238 | SLOT( processIncidenceSelection( Incidence * ) ) ); |
240 | connect( mView, SIGNAL( modifiedChanged( bool ) ), | 239 | connect( mView, SIGNAL( modifiedChanged( bool ) ), |
241 | SLOT( slotModifiedChanged( bool ) ) ); | 240 | SLOT( slotModifiedChanged( bool ) ) ); |
242 | 241 | ||
243 | 242 | ||
244 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); | 243 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); |
245 | mView->setModified( false ); | 244 | mView->setModified( false ); |
246 | mBlockAtStartup = false; | 245 | mBlockAtStartup = false; |
247 | mView->setModified( false ); | 246 | mView->setModified( false ); |
248 | setCentralWidget( mView ); | 247 | setCentralWidget( mView ); |
249 | globalFlagBlockStartup = 0; | 248 | globalFlagBlockStartup = 0; |
250 | mView->show(); | 249 | mView->show(); |
251 | delete splash; | 250 | delete splash; |
252 | if ( newFile ) | 251 | if ( newFile ) |
253 | mView->updateConfig(); | 252 | mView->updateConfig(); |
254 | // qApp->processEvents(); | 253 | // qApp->processEvents(); |
255 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 254 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
256 | fillSyncMenu(); | 255 | fillSyncMenu(); |
257 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); | 256 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); |
258 | if ( showWarning ) { | 257 | if ( showWarning ) { |
259 | KMessageBox::information( this, | 258 | KMessageBox::information( this, |
260 | "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"); | 259 | "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"); |
261 | qApp->processEvents(); | 260 | qApp->processEvents(); |
262 | mView->dialogManager()->showSyncOptions(); | 261 | mView->dialogManager()->showSyncOptions(); |
263 | } | 262 | } |
264 | 263 | ||
265 | //US listen for result adressed from Ka/Pi | 264 | //US listen for result adressed from Ka/Pi |
266 | #ifndef DESKTOP_VERSION | 265 | #ifndef DESKTOP_VERSION |
267 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); | 266 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); |
268 | #endif | 267 | #endif |
269 | } | 268 | } |
270 | MainWindow::~MainWindow() | 269 | MainWindow::~MainWindow() |
271 | { | 270 | { |
272 | //qDebug("MainWindow::~MainWindow() "); | 271 | //qDebug("MainWindow::~MainWindow() "); |
273 | //save toolbar location | 272 | //save toolbar location |
274 | delete mServerSocket; | 273 | delete mServerSocket; |
275 | delete mCalendar; | 274 | delete mCalendar; |
276 | delete KOPrefs::instance(); | 275 | delete KOPrefs::instance(); |
277 | delete KIncidenceFormatter::instance(); | 276 | delete KIncidenceFormatter::instance(); |
278 | 277 | ||
279 | 278 | ||
280 | } | 279 | } |
281 | void MainWindow::showMaximized () | 280 | void MainWindow::showMaximized () |
282 | { | 281 | { |
283 | #ifndef DESKTOP_VERSION | 282 | #ifndef DESKTOP_VERSION |
284 | if ( ! globalFlagBlockStartup ) | 283 | if ( ! globalFlagBlockStartup ) |
285 | if ( mClosed ) | 284 | if ( mClosed ) |
286 | mView->goToday(); | 285 | mView->goToday(); |
287 | #endif | 286 | #endif |
288 | QWidget::showMaximized () ; | 287 | QWidget::showMaximized () ; |
289 | mClosed = false; | 288 | mClosed = false; |
290 | } | 289 | } |
291 | void MainWindow::closeEvent( QCloseEvent* ce ) | 290 | void MainWindow::closeEvent( QCloseEvent* ce ) |
292 | { | 291 | { |
293 | 292 | ||
294 | 293 | ||
295 | 294 | ||
296 | if ( ! KOPrefs::instance()->mAskForQuit ) { | 295 | if ( ! KOPrefs::instance()->mAskForQuit ) { |
297 | saveOnClose(); | 296 | saveOnClose(); |
298 | mClosed = true; | 297 | mClosed = true; |
299 | ce->accept(); | 298 | ce->accept(); |
300 | return; | 299 | return; |
301 | 300 | ||
302 | } | 301 | } |
303 | 302 | ||
304 | switch( QMessageBox::information( this, "KO/Pi", | 303 | switch( QMessageBox::information( this, "KO/Pi", |
305 | i18n("Do you really want\nto close KO/Pi?"), | 304 | i18n("Do you really want\nto close KO/Pi?"), |
306 | i18n("Close"), i18n("No"), | 305 | i18n("Close"), i18n("No"), |
307 | 0, 0 ) ) { | 306 | 0, 0 ) ) { |
308 | case 0: | 307 | case 0: |
309 | saveOnClose(); | 308 | saveOnClose(); |
310 | mClosed = true; | 309 | mClosed = true; |
311 | ce->accept(); | 310 | ce->accept(); |
312 | break; | 311 | break; |
313 | case 1: | 312 | case 1: |
314 | ce->ignore(); | 313 | ce->ignore(); |
315 | break; | 314 | break; |
316 | case 2: | 315 | case 2: |
317 | 316 | ||
318 | default: | 317 | default: |
319 | break; | 318 | break; |
320 | } | 319 | } |
321 | 320 | ||
322 | 321 | ||
323 | } | 322 | } |
324 | 323 | ||
325 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) | 324 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) |
326 | { | 325 | { |
327 | QDataStream stream( data, IO_ReadOnly ); | 326 | QDataStream stream( data, IO_ReadOnly ); |
328 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); | 327 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); |
329 | //QString datamess; | 328 | //QString datamess; |
330 | //qDebug("message "); | 329 | //qDebug("message "); |
331 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); | 330 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); |
332 | 331 | ||
333 | if ( cmsg == "-writeFile" ) { | 332 | if ( cmsg == "-writeFile" ) { |
334 | // I made from the "-writeFile" an "-writeAlarm" | 333 | // I made from the "-writeFile" an "-writeAlarm" |
335 | mView->viewManager()->showWhatsNextView(); | 334 | mView->viewManager()->showWhatsNextView(); |
336 | mCalendar->checkAlarmForIncidence( 0, true); | 335 | mCalendar->checkAlarmForIncidence( 0, true); |
337 | showMaximized(); | 336 | showMaximized(); |
338 | raise(); | 337 | raise(); |
339 | return; | 338 | return; |
340 | } | 339 | } |
341 | 340 | ||
342 | if ( cmsg == "-writeFile" ) { | 341 | if ( cmsg == "-writeFile" ) { |
343 | // I made from the "-writeFile" an "-writeAlarm" | 342 | // I made from the "-writeFile" an "-writeAlarm" |
344 | mView->viewManager()->showWhatsNextView(); | 343 | mView->viewManager()->showWhatsNextView(); |
345 | mCalendar->checkAlarmForIncidence( 0, true); | 344 | mCalendar->checkAlarmForIncidence( 0, true); |
346 | showMaximized(); | 345 | showMaximized(); |
347 | raise(); | 346 | raise(); |
348 | return; | 347 | return; |
349 | 348 | ||
350 | } | 349 | } |
351 | if ( cmsg == "-writeFileSilent" ) { | 350 | if ( cmsg == "-writeFileSilent" ) { |
352 | // I made from the "-writeFile" an "-writeAlarm" | 351 | // I made from the "-writeFile" an "-writeAlarm" |
353 | // mView->viewManager()->showWhatsNextView(); | 352 | // mView->viewManager()->showWhatsNextView(); |
354 | mCalendar->checkAlarmForIncidence( 0, true); | 353 | mCalendar->checkAlarmForIncidence( 0, true); |
355 | //showMaximized(); | 354 | //showMaximized(); |
356 | //raise(); | 355 | //raise(); |
357 | hide(); | 356 | hide(); |
358 | return; | 357 | return; |
359 | } | 358 | } |
360 | if ( cmsg == "-newCountdown" ) { | 359 | if ( cmsg == "-newCountdown" ) { |
361 | qDebug("newCountdown "); | 360 | qDebug("newCountdown "); |
362 | 361 | ||
363 | } | 362 | } |
364 | QString msg ; | 363 | QString msg ; |
365 | QString allmsg = cmsg; | 364 | QString allmsg = cmsg; |
366 | while ( allmsg.length() > 0 ) { | 365 | while ( allmsg.length() > 0 ) { |
367 | int nextC = allmsg.find( "-", 1 ); | 366 | int nextC = allmsg.find( "-", 1 ); |
368 | if ( nextC == -1 ) { | 367 | if ( nextC == -1 ) { |
369 | msg = allmsg; | 368 | msg = allmsg; |
370 | allmsg = ""; | 369 | allmsg = ""; |
371 | } else{ | 370 | } else{ |
372 | msg = allmsg.left( nextC ); | 371 | msg = allmsg.left( nextC ); |
373 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); | 372 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); |
374 | } | 373 | } |
375 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); | 374 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); |
376 | if ( msg == "-newEvent" ) { | 375 | if ( msg == "-newEvent" ) { |
377 | mView->newEvent(); | 376 | mView->newEvent(); |
378 | } | 377 | } |
379 | if ( msg == "-newTodo" ) { | 378 | if ( msg == "-newTodo" ) { |
380 | mView->newTodo(); | 379 | mView->newTodo(); |
381 | 380 | ||
382 | } | 381 | } |
383 | if ( msg == "-showWN" ) { | 382 | if ( msg == "-showWN" ) { |
384 | mView->viewManager()->showWhatsNextView(); | 383 | mView->viewManager()->showWhatsNextView(); |
385 | } | 384 | } |
386 | if ( msg == "-showTodo" ) { | 385 | if ( msg == "-showTodo" ) { |
387 | mView->viewManager()->showTodoView(); | 386 | mView->viewManager()->showTodoView(); |
388 | } | 387 | } |
389 | if ( msg == "-showList" ) { | 388 | if ( msg == "-showList" ) { |
390 | mView->viewManager()->showListView(); | 389 | mView->viewManager()->showListView(); |
391 | } | 390 | } |
392 | else if ( msg == "-showDay" ) { | 391 | else if ( msg == "-showDay" ) { |
393 | mView->viewManager()->showDayView(); | 392 | mView->viewManager()->showDayView(); |
394 | } | 393 | } |
395 | else if ( msg == "-showWWeek" ) { | 394 | else if ( msg == "-showWWeek" ) { |
396 | mView->viewManager()->showWorkWeekView(); | 395 | mView->viewManager()->showWorkWeekView(); |
397 | } | 396 | } |
398 | else if ( msg == "-ringSync" ) { | 397 | else if ( msg == "-ringSync" ) { |
399 | multiSync( false ); | 398 | multiSync( false ); |
400 | } | 399 | } |
401 | else if ( msg == "-showWeek" ) { | 400 | else if ( msg == "-showWeek" ) { |
402 | mView->viewManager()->showWeekView(); | 401 | mView->viewManager()->showWeekView(); |
403 | } | 402 | } |
404 | else if ( msg == "-showTodo" ) { | 403 | else if ( msg == "-showTodo" ) { |
405 | mView->viewManager()->showTodoView(); | 404 | mView->viewManager()->showTodoView(); |
406 | } | 405 | } |
407 | else if ( msg == "-showJournal" ) { | 406 | else if ( msg == "-showJournal" ) { |
408 | mView->dateNavigator()->selectDates( 1 ); | 407 | mView->dateNavigator()->selectDates( 1 ); |
409 | mView->dateNavigator()->selectToday(); | 408 | mView->dateNavigator()->selectToday(); |
410 | mView->viewManager()->showJournalView(); | 409 | mView->viewManager()->showJournalView(); |
411 | } | 410 | } |
412 | else if ( msg == "-showKO" ) { | 411 | else if ( msg == "-showKO" ) { |
413 | mView->viewManager()->showNextXView(); | 412 | mView->viewManager()->showNextXView(); |
414 | } | 413 | } |
415 | else if ( msg == "-showWNext" || msg == "nextView()" ) { | 414 | else if ( msg == "-showWNext" || msg == "nextView()" ) { |
416 | mView->viewManager()->showWhatsNextView(); | 415 | mView->viewManager()->showWhatsNextView(); |
417 | } | 416 | } |
418 | else if ( msg == "-showNextXView" ) { | 417 | else if ( msg == "-showNextXView" ) { |
419 | mView->viewManager()->showNextXView(); | 418 | mView->viewManager()->showNextXView(); |
420 | } | 419 | } |
421 | 420 | ||
422 | 421 | ||
423 | } | 422 | } |
424 | 423 | ||
425 | showMaximized(); | 424 | showMaximized(); |
426 | raise(); | 425 | raise(); |
427 | } | 426 | } |
428 | 427 | ||
429 | QPixmap MainWindow::loadPixmap( QString name ) | 428 | QPixmap MainWindow::loadPixmap( QString name ) |
430 | { | 429 | { |
431 | return SmallIcon( name ); | 430 | return SmallIcon( name ); |
432 | 431 | ||
433 | } | 432 | } |
434 | void MainWindow::initActions() | 433 | void MainWindow::initActions() |
435 | { | 434 | { |
436 | //KOPrefs::instance()->mShowFullMenu | 435 | //KOPrefs::instance()->mShowFullMenu |
437 | iconToolBar->clear(); | 436 | iconToolBar->clear(); |
438 | KOPrefs *p = KOPrefs::instance(); | 437 | KOPrefs *p = KOPrefs::instance(); |
439 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); | 438 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); |
440 | 439 | ||
441 | QPopupMenu *viewMenu = new QPopupMenu( this ); | 440 | QPopupMenu *viewMenu = new QPopupMenu( this ); |
442 | QPopupMenu *actionMenu = new QPopupMenu( this ); | 441 | QPopupMenu *actionMenu = new QPopupMenu( this ); |
443 | QPopupMenu *importMenu = new QPopupMenu( this ); | 442 | QPopupMenu *importMenu = new QPopupMenu( this ); |
444 | selectFilterMenu = new QPopupMenu( this ); | 443 | selectFilterMenu = new QPopupMenu( this ); |
445 | selectFilterMenu->setCheckable( true ); | 444 | selectFilterMenu->setCheckable( true ); |
446 | syncMenu = new QPopupMenu( this ); | 445 | syncMenu = new QPopupMenu( this ); |
447 | configureAgendaMenu = new QPopupMenu( this ); | 446 | configureAgendaMenu = new QPopupMenu( this ); |
448 | configureToolBarMenu = new QPopupMenu( this ); | 447 | configureToolBarMenu = new QPopupMenu( this ); |
449 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 448 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
450 | if ( KOPrefs::instance()->mShowFullMenu ) { | 449 | if ( KOPrefs::instance()->mShowFullMenu ) { |
451 | QMenuBar *menuBar1; | 450 | QMenuBar *menuBar1; |
452 | menuBar1 = menuBar(); | 451 | menuBar1 = menuBar(); |
453 | menuBar1->insertItem( i18n("File"), importMenu ); | 452 | menuBar1->insertItem( i18n("File"), importMenu ); |
454 | menuBar1->insertItem( i18n("View"), viewMenu ); | 453 | menuBar1->insertItem( i18n("View"), viewMenu ); |
455 | menuBar1->insertItem( i18n("Actions"), actionMenu ); | 454 | menuBar1->insertItem( i18n("Actions"), actionMenu ); |
456 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); | 455 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); |
457 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 456 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
458 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 457 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
459 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); | 458 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); |
460 | menuBar1->insertItem( i18n("Help"), helpMenu ); | 459 | menuBar1->insertItem( i18n("Help"), helpMenu ); |
461 | } else { | 460 | } else { |
462 | QPEMenuBar *menuBar1; | 461 | QPEMenuBar *menuBar1; |
463 | menuBar1 = new QPEMenuBar( iconToolBar ); | 462 | menuBar1 = new QPEMenuBar( iconToolBar ); |
464 | QPopupMenu *menuBar = new QPopupMenu( this ); | 463 | QPopupMenu *menuBar = new QPopupMenu( this ); |
465 | menuBar1->insertItem( i18n("ME"), menuBar); | 464 | menuBar1->insertItem( i18n("ME"), menuBar); |
466 | menuBar->insertItem( i18n("File"), importMenu ); | 465 | menuBar->insertItem( i18n("File"), importMenu ); |
467 | menuBar->insertItem( i18n("View"), viewMenu ); | 466 | menuBar->insertItem( i18n("View"), viewMenu ); |
468 | menuBar->insertItem( i18n("Actions"), actionMenu ); | 467 | menuBar->insertItem( i18n("Actions"), actionMenu ); |
469 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); | 468 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); |
470 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 469 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
471 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 470 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
472 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); | 471 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); |
473 | menuBar->insertItem( i18n("Help"), helpMenu ); | 472 | menuBar->insertItem( i18n("Help"), helpMenu ); |
474 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); | 473 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); |
475 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); | 474 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); |
476 | } | 475 | } |
477 | connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); | 476 | connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); |
478 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); | 477 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); |
479 | connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); | 478 | connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); |
480 | 479 | ||
481 | // ****************** | 480 | // ****************** |
482 | QAction *action; | 481 | QAction *action; |
483 | QIconSet icon; | 482 | QIconSet icon; |
484 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); | 483 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); |
485 | configureToolBarMenu->setCheckable( true ); | 484 | configureToolBarMenu->setCheckable( true ); |
486 | 485 | ||
487 | QString pathString = ""; | 486 | QString pathString = ""; |
488 | if ( !p->mToolBarMiniIcons ) { | 487 | if ( !p->mToolBarMiniIcons ) { |
489 | if ( QApplication::desktop()->width() < 480 ) | 488 | if ( QApplication::desktop()->width() < 480 ) |
490 | pathString += "icons16/"; | 489 | pathString += "icons16/"; |
491 | } else | 490 | } else |
492 | pathString += "iconsmini/"; | 491 | pathString += "iconsmini/"; |
493 | configureAgendaMenu->setCheckable( true ); | 492 | configureAgendaMenu->setCheckable( true ); |
494 | configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); | 493 | configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); |
495 | configureAgendaMenu->insertSeparator(); | 494 | configureAgendaMenu->insertSeparator(); |
496 | configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); | 495 | configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); |
497 | configureAgendaMenu->insertItem(i18n("Small"), 6 ); | 496 | configureAgendaMenu->insertItem(i18n("Small"), 6 ); |
498 | configureAgendaMenu->insertItem(i18n("Medium"), 8 ); | 497 | configureAgendaMenu->insertItem(i18n("Medium"), 8 ); |
499 | configureAgendaMenu->insertItem(i18n("Normal"), 10 ); | 498 | configureAgendaMenu->insertItem(i18n("Normal"), 10 ); |
500 | configureAgendaMenu->insertItem(i18n("Large"), 12 ); | 499 | configureAgendaMenu->insertItem(i18n("Large"), 12 ); |
501 | configureAgendaMenu->insertItem(i18n("Big"), 14 ); | 500 | configureAgendaMenu->insertItem(i18n("Big"), 14 ); |
502 | configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); | 501 | configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); |
503 | configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); | 502 | configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); |
504 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); | 503 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); |
505 | 504 | ||
506 | icon = loadPixmap( pathString + "configure" ); | 505 | icon = loadPixmap( pathString + "configure" ); |
507 | action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); | 506 | action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); |
508 | action->addTo( actionMenu ); | 507 | action->addTo( actionMenu ); |
509 | connect( action, SIGNAL( activated() ), | 508 | connect( action, SIGNAL( activated() ), |
510 | mView, SLOT( edit_options() ) ); | 509 | mView, SLOT( edit_options() ) ); |
511 | actionMenu->insertSeparator(); | 510 | actionMenu->insertSeparator(); |
512 | icon = loadPixmap( pathString + "newevent" ); | 511 | icon = loadPixmap( pathString + "newevent" ); |
513 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); | 512 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); |
514 | configureToolBarMenu->insertSeparator(); | 513 | configureToolBarMenu->insertSeparator(); |
515 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); | 514 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); |
516 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); | 515 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); |
517 | ne_action->addTo( actionMenu ); | 516 | ne_action->addTo( actionMenu ); |
518 | connect( ne_action, SIGNAL( activated() ), | 517 | connect( ne_action, SIGNAL( activated() ), |
519 | mView, SLOT( newEvent() ) ); | 518 | mView, SLOT( newEvent() ) ); |
520 | icon = loadPixmap( pathString + "newtodo" ); | 519 | icon = loadPixmap( pathString + "newtodo" ); |
521 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); | 520 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); |
522 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); | 521 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); |
523 | nt_action->addTo( actionMenu ); | 522 | nt_action->addTo( actionMenu ); |
524 | connect( nt_action, SIGNAL( activated() ), | 523 | connect( nt_action, SIGNAL( activated() ), |
525 | mView, SLOT( newTodo() ) ); | 524 | mView, SLOT( newTodo() ) ); |
526 | icon = loadPixmap( pathString + "navi" ); | 525 | icon = loadPixmap( pathString + "navi" ); |
527 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); | 526 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); |
528 | action->addTo( viewMenu ); | 527 | action->addTo( viewMenu ); |
529 | connect( action, SIGNAL( activated() ), | 528 | connect( action, SIGNAL( activated() ), |
530 | mView, SLOT( toggleDateNavigatorWidget() ) ); | 529 | mView, SLOT( toggleDateNavigatorWidget() ) ); |
531 | icon = loadPixmap( pathString + "filter" ); | 530 | icon = loadPixmap( pathString + "filter" ); |
532 | action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); | 531 | action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); |
533 | action->addTo( viewMenu ); | 532 | action->addTo( viewMenu ); |
534 | connect( action, SIGNAL( activated() ), | 533 | connect( action, SIGNAL( activated() ), |
535 | mView, SLOT( toggleFilter() ) ); | 534 | mView, SLOT( toggleFilter() ) ); |
536 | 535 | ||
537 | 536 | ||
538 | viewMenu->insertSeparator(); | 537 | viewMenu->insertSeparator(); |
539 | icon = loadPixmap( pathString + "picker" ); | 538 | icon = loadPixmap( pathString + "picker" ); |
540 | action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); | 539 | action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); |
541 | action->addTo( viewMenu ); | 540 | action->addTo( viewMenu ); |
542 | connect( action, SIGNAL( activated() ), | 541 | connect( action, SIGNAL( activated() ), |
543 | mView, SLOT( showDatePicker() ) ); | 542 | mView, SLOT( showDatePicker() ) ); |
544 | action->addTo( iconToolBar ); | 543 | action->addTo( iconToolBar ); |
545 | viewMenu->insertSeparator(); | 544 | viewMenu->insertSeparator(); |
546 | icon = loadPixmap( pathString + "list" ); | 545 | icon = loadPixmap( pathString + "list" ); |
547 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); | 546 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); |
548 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); | 547 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); |
549 | showlist_action->addTo( viewMenu ); | 548 | showlist_action->addTo( viewMenu ); |
550 | connect( showlist_action, SIGNAL( activated() ), | 549 | connect( showlist_action, SIGNAL( activated() ), |
551 | mView->viewManager(), SLOT( showListView() ) ); | 550 | mView->viewManager(), SLOT( showListView() ) ); |
552 | 551 | ||
553 | 552 | ||
554 | icon = loadPixmap( pathString + "day" ); | 553 | icon = loadPixmap( pathString + "day" ); |
555 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); | 554 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); |
556 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); | 555 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); |
557 | day1_action->addTo( viewMenu ); | 556 | day1_action->addTo( viewMenu ); |
558 | // action->addTo( toolBar ); | 557 | // action->addTo( toolBar ); |
559 | connect( day1_action, SIGNAL( activated() ), | 558 | connect( day1_action, SIGNAL( activated() ), |
560 | mView->viewManager(), SLOT( showDayView() ) ); | 559 | mView->viewManager(), SLOT( showDayView() ) ); |
561 | 560 | ||
562 | icon = loadPixmap( pathString + "workweek" ); | 561 | icon = loadPixmap( pathString + "workweek" ); |
563 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); | 562 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); |
564 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); | 563 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); |
565 | day5_action->addTo( viewMenu ); | 564 | day5_action->addTo( viewMenu ); |
566 | connect( day5_action, SIGNAL( activated() ), | 565 | connect( day5_action, SIGNAL( activated() ), |
567 | mView->viewManager(), SLOT( showWorkWeekView() ) ); | 566 | mView->viewManager(), SLOT( showWorkWeekView() ) ); |
568 | 567 | ||
569 | icon = loadPixmap( pathString + "week" ); | 568 | icon = loadPixmap( pathString + "week" ); |
570 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); | 569 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); |
571 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); | 570 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); |
572 | day7_action->addTo( viewMenu ); | 571 | day7_action->addTo( viewMenu ); |
573 | connect( day7_action, SIGNAL( activated() ), | 572 | connect( day7_action, SIGNAL( activated() ), |
574 | mView->viewManager(), SLOT( showWeekView() ) ); | 573 | mView->viewManager(), SLOT( showWeekView() ) ); |
575 | 574 | ||
576 | icon = loadPixmap( pathString + "month" ); | 575 | icon = loadPixmap( pathString + "month" ); |
577 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); | 576 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); |
578 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); | 577 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); |
579 | month_action->addTo( viewMenu ); | 578 | month_action->addTo( viewMenu ); |
580 | connect( month_action, SIGNAL( activated() ), | 579 | connect( month_action, SIGNAL( activated() ), |
581 | mView->viewManager(), SLOT( showMonthView() ) ); | 580 | mView->viewManager(), SLOT( showMonthView() ) ); |
582 | 581 | ||
583 | icon = loadPixmap( pathString + "todo" ); | 582 | icon = loadPixmap( pathString + "todo" ); |
584 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); | 583 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); |
585 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); | 584 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); |
586 | todoview_action->addTo( viewMenu ); | 585 | todoview_action->addTo( viewMenu ); |
587 | connect( todoview_action, SIGNAL( activated() ), | 586 | connect( todoview_action, SIGNAL( activated() ), |
588 | mView->viewManager(), SLOT( showTodoView() ) ); | 587 | mView->viewManager(), SLOT( showTodoView() ) ); |
589 | 588 | ||
590 | icon = loadPixmap( pathString + "journal" ); | 589 | icon = loadPixmap( pathString + "journal" ); |
591 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); | 590 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); |
592 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); | 591 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); |
593 | viewjournal_action->addTo( viewMenu ); | 592 | viewjournal_action->addTo( viewMenu ); |
594 | connect( viewjournal_action, SIGNAL( activated() ), | 593 | connect( viewjournal_action, SIGNAL( activated() ), |
595 | mView->viewManager(), SLOT( showJournalView() ) ); | 594 | mView->viewManager(), SLOT( showJournalView() ) ); |
596 | 595 | ||
597 | icon = loadPixmap( pathString + "xdays" ); | 596 | icon = loadPixmap( pathString + "xdays" ); |
598 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); | 597 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); |
599 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); | 598 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); |
600 | xdays_action->addTo( viewMenu ); | 599 | xdays_action->addTo( viewMenu ); |
601 | connect( xdays_action, SIGNAL( activated() ), | 600 | connect( xdays_action, SIGNAL( activated() ), |
602 | mView->viewManager(), SLOT( showNextXView() ) ); | 601 | mView->viewManager(), SLOT( showNextXView() ) ); |
603 | 602 | ||
604 | icon = loadPixmap( pathString + "whatsnext" ); | 603 | icon = loadPixmap( pathString + "whatsnext" ); |
605 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); | 604 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); |
606 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); | 605 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); |
607 | whatsnext_action->addTo( viewMenu ); | 606 | whatsnext_action->addTo( viewMenu ); |
608 | connect( whatsnext_action, SIGNAL( activated() ), | 607 | connect( whatsnext_action, SIGNAL( activated() ), |
609 | mView->viewManager(), SLOT( showWhatsNextView() ) ); | 608 | mView->viewManager(), SLOT( showWhatsNextView() ) ); |
610 | 609 | ||
611 | #if 0 | 610 | #if 0 |
612 | action = new QAction( "view_timespan", "Time Span", 0, this ); | 611 | action = new QAction( "view_timespan", "Time Span", 0, this ); |
613 | action->addTo( viewMenu ); | 612 | action->addTo( viewMenu ); |
614 | connect( action, SIGNAL( activated() ), | 613 | connect( action, SIGNAL( activated() ), |
615 | mView->viewManager(), SLOT( showTimeSpanView() ) ); | 614 | mView->viewManager(), SLOT( showTimeSpanView() ) ); |
616 | #endif | 615 | #endif |
617 | 616 | ||
618 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, | 617 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, |
619 | this ); | 618 | this ); |
620 | mNewSubTodoAction->addTo( actionMenu ); | 619 | mNewSubTodoAction->addTo( actionMenu ); |
621 | connect( mNewSubTodoAction, SIGNAL( activated() ), | 620 | connect( mNewSubTodoAction, SIGNAL( activated() ), |
622 | mView, SLOT( newSubTodo() ) ); | 621 | mView, SLOT( newSubTodo() ) ); |
623 | 622 | ||
624 | actionMenu->insertSeparator(); | 623 | actionMenu->insertSeparator(); |
625 | 624 | ||
626 | mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); | 625 | mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); |
627 | mShowAction->addTo( actionMenu ); | 626 | mShowAction->addTo( actionMenu ); |
628 | connect( mShowAction, SIGNAL( activated() ), | 627 | connect( mShowAction, SIGNAL( activated() ), |
629 | mView, SLOT( showIncidence() ) ); | 628 | mView, SLOT( showIncidence() ) ); |
630 | 629 | ||
631 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); | 630 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); |
632 | mEditAction->addTo( actionMenu ); | 631 | mEditAction->addTo( actionMenu ); |
633 | connect( mEditAction, SIGNAL( activated() ), | 632 | connect( mEditAction, SIGNAL( activated() ), |
634 | mView, SLOT( editIncidence() ) ); | 633 | mView, SLOT( editIncidence() ) ); |
635 | 634 | ||
636 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); | 635 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); |
637 | mDeleteAction->addTo( actionMenu ); | 636 | mDeleteAction->addTo( actionMenu ); |
638 | connect( mDeleteAction, SIGNAL( activated() ), | 637 | connect( mDeleteAction, SIGNAL( activated() ), |
639 | mView, SLOT( deleteIncidence() ) ); | 638 | mView, SLOT( deleteIncidence() ) ); |
640 | 639 | ||
641 | 640 | ||
642 | mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); | 641 | mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); |
643 | mCloneAction->addTo( actionMenu ); | 642 | mCloneAction->addTo( actionMenu ); |
644 | connect( mCloneAction, SIGNAL( activated() ), | 643 | connect( mCloneAction, SIGNAL( activated() ), |
645 | mView, SLOT( cloneIncidence() ) ); | 644 | mView, SLOT( cloneIncidence() ) ); |
646 | mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); | 645 | mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); |
647 | mMoveAction->addTo( actionMenu ); | 646 | mMoveAction->addTo( actionMenu ); |
648 | connect( mMoveAction, SIGNAL( activated() ), | 647 | connect( mMoveAction, SIGNAL( activated() ), |
649 | mView, SLOT( moveIncidence() ) ); | 648 | mView, SLOT( moveIncidence() ) ); |
650 | mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); | 649 | mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); |
651 | mBeamAction->addTo( actionMenu ); | 650 | mBeamAction->addTo( actionMenu ); |
652 | connect( mBeamAction, SIGNAL( activated() ), | 651 | connect( mBeamAction, SIGNAL( activated() ), |
653 | mView, SLOT( beamIncidence() ) ); | 652 | mView, SLOT( beamIncidence() ) ); |
654 | mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); | 653 | mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); |
655 | mCancelAction->addTo( actionMenu ); | 654 | mCancelAction->addTo( actionMenu ); |
656 | connect( mCancelAction, SIGNAL( activated() ), | 655 | connect( mCancelAction, SIGNAL( activated() ), |
657 | mView, SLOT( toggleCancelIncidence() ) ); | 656 | mView, SLOT( toggleCancelIncidence() ) ); |
658 | 657 | ||
659 | actionMenu->insertSeparator(); | 658 | actionMenu->insertSeparator(); |
660 | 659 | ||
661 | action = new QAction( "purge_completed", i18n("Purge Completed"), 0, | 660 | action = new QAction( "purge_completed", i18n("Purge Completed"), 0, |
662 | this ); | 661 | this ); |
663 | action->addTo( actionMenu ); | 662 | action->addTo( actionMenu ); |
664 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); | 663 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); |
665 | 664 | ||
666 | icon = loadPixmap( pathString + "search" ); | 665 | icon = loadPixmap( pathString + "search" ); |
667 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); | 666 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); |
668 | configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); | 667 | configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); |
669 | search_action->addTo( actionMenu ); | 668 | search_action->addTo( actionMenu ); |
670 | connect( search_action, SIGNAL( activated() ), | 669 | connect( search_action, SIGNAL( activated() ), |
671 | mView->dialogManager(), SLOT( showSearchDialog() ) ); | 670 | mView->dialogManager(), SLOT( showSearchDialog() ) ); |
672 | 671 | ||
673 | icon = loadPixmap( pathString + "today" ); | 672 | icon = loadPixmap( pathString + "today" ); |
674 | configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); | 673 | configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); |
675 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); | 674 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); |
676 | today_action->addTo( actionMenu ); | 675 | today_action->addTo( actionMenu ); |
677 | connect( today_action, SIGNAL( activated() ), | 676 | connect( today_action, SIGNAL( activated() ), |
678 | mView, SLOT( goToday() ) ); | 677 | mView, SLOT( goToday() ) ); |
679 | 678 | ||
680 | if ( KOPrefs::instance()->mShowFullMenu ) { | 679 | if ( KOPrefs::instance()->mShowFullMenu ) { |
681 | actionMenu->insertSeparator(); | 680 | actionMenu->insertSeparator(); |
682 | actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); | 681 | actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); |
683 | 682 | ||
684 | } | 683 | } |
685 | // actionMenu->insertSeparator(); | 684 | // actionMenu->insertSeparator(); |
686 | action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, | 685 | action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, |
687 | this ); | 686 | this ); |
688 | action->addTo( importMenu ); | 687 | action->addTo( importMenu ); |
689 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); | 688 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); |
690 | action = new QAction( "import_quick", i18n("Import last file"), 0, | 689 | action = new QAction( "import_quick", i18n("Import last file"), 0, |
691 | this ); | 690 | this ); |
692 | action->addTo( importMenu ); | 691 | action->addTo( importMenu ); |
693 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); | 692 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); |
694 | importMenu->insertSeparator(); | 693 | importMenu->insertSeparator(); |
695 | action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, | 694 | action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, |
696 | this ); | 695 | this ); |
697 | action->addTo( importMenu ); | 696 | action->addTo( importMenu ); |
698 | connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); | 697 | connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); |
699 | #ifndef DESKTOP_VERSION | 698 | #ifndef DESKTOP_VERSION |
700 | importMenu->insertSeparator(); | 699 | importMenu->insertSeparator(); |
701 | action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, | 700 | action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, |
702 | this ); | 701 | this ); |
703 | action->addTo( importMenu ); | 702 | action->addTo( importMenu ); |
704 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); | 703 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); |
705 | #else | 704 | #else |
706 | #ifdef _WIN32_ | 705 | #ifdef _WIN32_ |
707 | importMenu->insertSeparator(); | 706 | importMenu->insertSeparator(); |
708 | action = new QAction( "import_ol", i18n("Import from OL"), 0, | 707 | action = new QAction( "import_ol", i18n("Import from OL"), 0, |
709 | this ); | 708 | this ); |
710 | action->addTo( importMenu ); | 709 | action->addTo( importMenu ); |
711 | connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); | 710 | connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); |
712 | #endif | 711 | #endif |
713 | #endif | 712 | #endif |
714 | 713 | ||
715 | importMenu->insertSeparator(); | 714 | importMenu->insertSeparator(); |
716 | action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, | 715 | action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, |
717 | this ); | 716 | this ); |
718 | action->addTo( importMenu ); | 717 | action->addTo( importMenu ); |
719 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); | 718 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); |
720 | 719 | ||
721 | action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, | 720 | action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, |
722 | this ); | 721 | this ); |
723 | action->addTo( importMenu ); | 722 | action->addTo( importMenu ); |
724 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); | 723 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); |
725 | 724 | ||
726 | importMenu->insertSeparator(); | 725 | importMenu->insertSeparator(); |
727 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, | 726 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, |
728 | this ); | 727 | this ); |
729 | action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); | 728 | action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); |
730 | 729 | ||
731 | 730 | ||
732 | //LR | 731 | //LR |
733 | QPopupMenu *ex2phone = new QPopupMenu( this ); | 732 | QPopupMenu *ex2phone = new QPopupMenu( this ); |
734 | ex2phone->insertItem(i18n("Complete calendar..."), 1 ); | 733 | ex2phone->insertItem(i18n("Complete calendar..."), 1 ); |
735 | ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); | 734 | ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); |
736 | connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); | 735 | connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); |
737 | importMenu->insertItem( i18n("Export to phone"), ex2phone ); | 736 | importMenu->insertItem( i18n("Export to phone"), ex2phone ); |
738 | 737 | ||
739 | importMenu->insertSeparator(); | 738 | importMenu->insertSeparator(); |
740 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, | 739 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, |
741 | this ); | 740 | this ); |
742 | action->addTo( importMenu ); | 741 | action->addTo( importMenu ); |
743 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); | 742 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); |
744 | #ifndef DESKTOP_VERSION | 743 | #ifndef DESKTOP_VERSION |
745 | importMenu->insertSeparator(); | 744 | importMenu->insertSeparator(); |
746 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, | 745 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, |
747 | this ); | 746 | this ); |
748 | action->addTo( importMenu ); | 747 | action->addTo( importMenu ); |
749 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); | 748 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); |
750 | 749 | ||
751 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, | 750 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, |
752 | this ); | 751 | this ); |
753 | action->addTo( importMenu ); | 752 | action->addTo( importMenu ); |
754 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); | 753 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); |
755 | #else | 754 | #else |
756 | importMenu->insertSeparator(); | 755 | importMenu->insertSeparator(); |
757 | icon = loadPixmap( pathString + "print" ); | 756 | icon = loadPixmap( pathString + "print" ); |
758 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); | 757 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); |
759 | action->addTo( importMenu ); | 758 | action->addTo( importMenu ); |
760 | connect( action, SIGNAL( activated() ), | 759 | connect( action, SIGNAL( activated() ), |
761 | this, SLOT( printCal() ) ); | 760 | this, SLOT( printCal() ) ); |
762 | 761 | ||
763 | icon = loadPixmap( pathString + "print" ); | 762 | icon = loadPixmap( pathString + "print" ); |
764 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); | 763 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); |
765 | action->addTo( importMenu ); | 764 | action->addTo( importMenu ); |
766 | connect( action, SIGNAL( activated() ), | 765 | connect( action, SIGNAL( activated() ), |
767 | this, SLOT( printSel() ) ); | 766 | this, SLOT( printSel() ) ); |
768 | #endif | 767 | #endif |
769 | importMenu->insertSeparator(); | 768 | importMenu->insertSeparator(); |
770 | action = new QAction( "beam all", i18n("Save"), 0, | 769 | action = new QAction( "beam all", i18n("Save"), 0, |
771 | this ); | 770 | this ); |
772 | action->addTo( importMenu ); | 771 | action->addTo( importMenu ); |
773 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); | 772 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); |
774 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, | 773 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, |
775 | this ); | 774 | this ); |
776 | action->addTo( importMenu ); | 775 | action->addTo( importMenu ); |
777 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); | 776 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); |
778 | 777 | ||
779 | //menuBar->insertItem( "Configure",configureMenu ); | 778 | //menuBar->insertItem( "Configure",configureMenu ); |
780 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); | 779 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); |
781 | icon = loadPixmap( "korganizer/korganizer" ); | 780 | icon = loadPixmap( "korganizer/korganizer" ); |
782 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); | 781 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); |
783 | action->addTo( helpMenu ); | 782 | action->addTo( helpMenu ); |
784 | connect( action, SIGNAL( activated() ), | 783 | connect( action, SIGNAL( activated() ), |
785 | SLOT( keyBindings() ) ); | 784 | SLOT( keyBindings() ) ); |
786 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); | 785 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); |
787 | action->addTo( helpMenu ); | 786 | action->addTo( helpMenu ); |
788 | connect( action, SIGNAL( activated() ), | 787 | connect( action, SIGNAL( activated() ), |
789 | SLOT( features() ) ); | 788 | SLOT( features() ) ); |
790 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); | 789 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); |
791 | action->addTo( helpMenu ); | 790 | action->addTo( helpMenu ); |
792 | connect( action, SIGNAL( activated() ), | 791 | connect( action, SIGNAL( activated() ), |
793 | SLOT( aboutAutoSaving() ) ); | 792 | SLOT( aboutAutoSaving() ) ); |
794 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); | 793 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); |
795 | action->addTo( helpMenu ); | 794 | action->addTo( helpMenu ); |
796 | connect( action, SIGNAL( activated() ), | 795 | connect( action, SIGNAL( activated() ), |
797 | SLOT( aboutKnownBugs() ) ); | 796 | SLOT( aboutKnownBugs() ) ); |
798 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); | 797 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); |
799 | action->addTo( helpMenu ); | 798 | action->addTo( helpMenu ); |
800 | connect( action, SIGNAL( activated() ), | 799 | connect( action, SIGNAL( activated() ), |
801 | SLOT( usertrans() ) ); | 800 | SLOT( usertrans() ) ); |
802 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); | 801 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); |
803 | action->addTo( helpMenu ); | 802 | action->addTo( helpMenu ); |
804 | connect( action, SIGNAL( activated() ), | 803 | connect( action, SIGNAL( activated() ), |
805 | SLOT( synchowto() ) ); | 804 | SLOT( synchowto() ) ); |
806 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); | 805 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); |
807 | action->addTo( helpMenu ); | 806 | action->addTo( helpMenu ); |
808 | connect( action, SIGNAL( activated() ), | 807 | connect( action, SIGNAL( activated() ), |
809 | SLOT( whatsNew() ) ); | 808 | SLOT( whatsNew() ) ); |
810 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); | 809 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); |
811 | action->addTo( helpMenu ); | 810 | action->addTo( helpMenu ); |
812 | connect( action, SIGNAL( activated() ), | 811 | connect( action, SIGNAL( activated() ), |
813 | SLOT( faq() ) ); | 812 | SLOT( faq() ) ); |
814 | 813 | ||
815 | 814 | ||
816 | action = new QAction( "about", i18n("About..."), 0, this ); | 815 | action = new QAction( "about", i18n("About..."), 0, this ); |
817 | action->addTo( helpMenu ); | 816 | action->addTo( helpMenu ); |
818 | connect( action, SIGNAL( activated() ), | 817 | connect( action, SIGNAL( activated() ), |
819 | SLOT( about() ) ); | 818 | SLOT( about() ) ); |
820 | action = new QAction( "licence", i18n("Licence..."), 0, this ); | 819 | action = new QAction( "licence", i18n("Licence..."), 0, this ); |
821 | action->addTo( helpMenu ); | 820 | action->addTo( helpMenu ); |
822 | connect( action, SIGNAL( activated() ), | 821 | connect( action, SIGNAL( activated() ), |
823 | SLOT( licence() ) ); | 822 | SLOT( licence() ) ); |
824 | //menuBar->insertSeparator(); | 823 | //menuBar->insertSeparator(); |
825 | 824 | ||
826 | // ****************************************************** | 825 | // ****************************************************** |
827 | // menubar icons | 826 | // menubar icons |
828 | 827 | ||
829 | 828 | ||
830 | iconToolBar->setHorizontalStretchable (true ); | 829 | iconToolBar->setHorizontalStretchable (true ); |
831 | //menuBar->insertItem( iconToolBar ); | 830 | //menuBar->insertItem( iconToolBar ); |
832 | //xdays_action | 831 | //xdays_action |
833 | if (p-> mShowIconNewEvent) | 832 | if (p-> mShowIconNewEvent) |
834 | ne_action->addTo( iconToolBar ); | 833 | ne_action->addTo( iconToolBar ); |
835 | if (p->mShowIconNewTodo ) | 834 | if (p->mShowIconNewTodo ) |
836 | nt_action->addTo( iconToolBar ); | 835 | nt_action->addTo( iconToolBar ); |
837 | if (p-> mShowIconSearch) | 836 | if (p-> mShowIconSearch) |
838 | search_action->addTo( iconToolBar ); | 837 | search_action->addTo( iconToolBar ); |
839 | if (p-> mShowIconNext) | 838 | if (p-> mShowIconNext) |
840 | whatsnext_action->addTo( iconToolBar ); | 839 | whatsnext_action->addTo( iconToolBar ); |
841 | if (p-> mShowIconNextDays) | 840 | if (p-> mShowIconNextDays) |
842 | xdays_action->addTo( iconToolBar ); | 841 | xdays_action->addTo( iconToolBar ); |
843 | if (p-> mShowIconList) | 842 | if (p-> mShowIconList) |
844 | showlist_action->addTo( iconToolBar ); | 843 | showlist_action->addTo( iconToolBar ); |
845 | if (p-> mShowIconDay1) | 844 | if (p-> mShowIconDay1) |
846 | day1_action->addTo( iconToolBar ); | 845 | day1_action->addTo( iconToolBar ); |
847 | if (p-> mShowIconDay5) | 846 | if (p-> mShowIconDay5) |
848 | day5_action->addTo( iconToolBar ); | 847 | day5_action->addTo( iconToolBar ); |
849 | if (p-> mShowIconDay7) | 848 | if (p-> mShowIconDay7) |
850 | day7_action->addTo( iconToolBar ); | 849 | day7_action->addTo( iconToolBar ); |
851 | if (p-> mShowIconMonth) | 850 | if (p-> mShowIconMonth) |
852 | month_action->addTo( iconToolBar ); | 851 | month_action->addTo( iconToolBar ); |
853 | if (p-> mShowIconTodoview) | 852 | if (p-> mShowIconTodoview) |
854 | todoview_action->addTo( iconToolBar ); | 853 | todoview_action->addTo( iconToolBar ); |
855 | if (p-> mShowIconJournal) | 854 | if (p-> mShowIconJournal) |
856 | viewjournal_action->addTo( iconToolBar ); | 855 | viewjournal_action->addTo( iconToolBar ); |
857 | icon = loadPixmap( pathString + "2leftarrowB" ); | 856 | icon = loadPixmap( pathString + "2leftarrowB" ); |
858 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); | 857 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); |
859 | if (p-> mShowIconBackFast) { | 858 | if (p-> mShowIconBackFast) { |
860 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); | 859 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); |
861 | connect( action, SIGNAL( activated() ), | 860 | connect( action, SIGNAL( activated() ), |
862 | mView, SLOT( goPreviousMonth() ) ); | 861 | mView, SLOT( goPreviousMonth() ) ); |
863 | action->addTo( iconToolBar ); | 862 | action->addTo( iconToolBar ); |
864 | } | 863 | } |
865 | icon = loadPixmap( pathString + "1leftarrowB" ); | 864 | icon = loadPixmap( pathString + "1leftarrowB" ); |
866 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); | 865 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); |
867 | if (p-> mShowIconBack) { | 866 | if (p-> mShowIconBack) { |
868 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); | 867 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); |
869 | connect( action, SIGNAL( activated() ), | 868 | connect( action, SIGNAL( activated() ), |
870 | mView, SLOT( goPrevious() ) ); | 869 | mView, SLOT( goPrevious() ) ); |
871 | action->addTo( iconToolBar ); | 870 | action->addTo( iconToolBar ); |
872 | } | 871 | } |
873 | if (p-> mShowIconToday) | 872 | if (p-> mShowIconToday) |
874 | today_action->addTo( iconToolBar ); | 873 | today_action->addTo( iconToolBar ); |
875 | icon = loadPixmap( pathString + "1rightarrowB" ); | 874 | icon = loadPixmap( pathString + "1rightarrowB" ); |
876 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); | 875 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); |
877 | if (p-> mShowIconForward) { | 876 | if (p-> mShowIconForward) { |
878 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); | 877 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); |
879 | connect( action, SIGNAL( activated() ), | 878 | connect( action, SIGNAL( activated() ), |
880 | mView, SLOT( goNext() ) ); | 879 | mView, SLOT( goNext() ) ); |
881 | action->addTo( iconToolBar ); | 880 | action->addTo( iconToolBar ); |
882 | } | 881 | } |
883 | icon = loadPixmap( pathString + "2rightarrowB" ); | 882 | icon = loadPixmap( pathString + "2rightarrowB" ); |
884 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); | 883 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); |
885 | if (p-> mShowIconForwardFast) { | 884 | if (p-> mShowIconForwardFast) { |
886 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); | 885 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); |
887 | connect( action, SIGNAL( activated() ), | 886 | connect( action, SIGNAL( activated() ), |
888 | mView, SLOT( goNextMonth() ) ); | 887 | mView, SLOT( goNextMonth() ) ); |
889 | action->addTo( iconToolBar ); | 888 | action->addTo( iconToolBar ); |
890 | } | 889 | } |
891 | 890 | ||
892 | 891 | ||
893 | configureToolBarMenu->insertItem(i18n("What's This?"), 300); | 892 | configureToolBarMenu->insertItem(i18n("What's This?"), 300); |
894 | 893 | ||
895 | if (p-> mShowIconNewEvent) | 894 | if (p-> mShowIconNewEvent) |
896 | configureToolBarMenu->setItemChecked( 10, true ); | 895 | configureToolBarMenu->setItemChecked( 10, true ); |
897 | if (p->mShowIconNewTodo ) | 896 | if (p->mShowIconNewTodo ) |
898 | configureToolBarMenu->setItemChecked( 20, true ); | 897 | configureToolBarMenu->setItemChecked( 20, true ); |
899 | if (p-> mShowIconSearch) | 898 | if (p-> mShowIconSearch) |
900 | configureToolBarMenu->setItemChecked( 120, true ); | 899 | configureToolBarMenu->setItemChecked( 120, true ); |
901 | if (p-> mShowIconList) | 900 | if (p-> mShowIconList) |
902 | configureToolBarMenu->setItemChecked( 30, true ); | 901 | configureToolBarMenu->setItemChecked( 30, true ); |
903 | if (p-> mShowIconDay1) | 902 | if (p-> mShowIconDay1) |
904 | configureToolBarMenu->setItemChecked( 40, true ); | 903 | configureToolBarMenu->setItemChecked( 40, true ); |
905 | if (p-> mShowIconDay5) | 904 | if (p-> mShowIconDay5) |
906 | configureToolBarMenu->setItemChecked( 50, true ); | 905 | configureToolBarMenu->setItemChecked( 50, true ); |
907 | if (p-> mShowIconDay7) | 906 | if (p-> mShowIconDay7) |
908 | configureToolBarMenu->setItemChecked( 60, true ); | 907 | configureToolBarMenu->setItemChecked( 60, true ); |
909 | if (p-> mShowIconMonth) | 908 | if (p-> mShowIconMonth) |
910 | configureToolBarMenu->setItemChecked( 70, true ); | 909 | configureToolBarMenu->setItemChecked( 70, true ); |
911 | if (p-> mShowIconTodoview) | 910 | if (p-> mShowIconTodoview) |
912 | configureToolBarMenu->setItemChecked( 80, true ); | 911 | configureToolBarMenu->setItemChecked( 80, true ); |
913 | if (p-> mShowIconBackFast) | 912 | if (p-> mShowIconBackFast) |
914 | configureToolBarMenu->setItemChecked( 200, true ); | 913 | configureToolBarMenu->setItemChecked( 200, true ); |
915 | if (p-> mShowIconBack) | 914 | if (p-> mShowIconBack) |
916 | configureToolBarMenu->setItemChecked( 210, true ); | 915 | configureToolBarMenu->setItemChecked( 210, true ); |
917 | if (p-> mShowIconToday) | 916 | if (p-> mShowIconToday) |
918 | configureToolBarMenu->setItemChecked( 130, true ); | 917 | configureToolBarMenu->setItemChecked( 130, true ); |
919 | if (p-> mShowIconForward) | 918 | if (p-> mShowIconForward) |
920 | configureToolBarMenu->setItemChecked( 220, true ); | 919 | configureToolBarMenu->setItemChecked( 220, true ); |
921 | if (p-> mShowIconForwardFast) | 920 | if (p-> mShowIconForwardFast) |
922 | configureToolBarMenu->setItemChecked( 230, true ); | 921 | configureToolBarMenu->setItemChecked( 230, true ); |
923 | if (p-> mShowIconNextDays) | 922 | if (p-> mShowIconNextDays) |
924 | configureToolBarMenu->setItemChecked( 100, true ); | 923 | configureToolBarMenu->setItemChecked( 100, true ); |
925 | if (p-> mShowIconNext) | 924 | if (p-> mShowIconNext) |
926 | configureToolBarMenu->setItemChecked( 110, true ); | 925 | configureToolBarMenu->setItemChecked( 110, true ); |
927 | if (p-> mShowIconJournal) | 926 | if (p-> mShowIconJournal) |
928 | configureToolBarMenu->setItemChecked( 90, true ); | 927 | configureToolBarMenu->setItemChecked( 90, true ); |
929 | if (p-> mShowIconWhatsThis) | 928 | if (p-> mShowIconWhatsThis) |
930 | configureToolBarMenu->setItemChecked( 300, true ); | 929 | configureToolBarMenu->setItemChecked( 300, true ); |
931 | 930 | ||
932 | QLabel* dummy = new QLabel( iconToolBar ); | 931 | QLabel* dummy = new QLabel( iconToolBar ); |
933 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); | 932 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); |
934 | if (!p-> mShowIconStretch) | 933 | if (!p-> mShowIconStretch) |
935 | iconToolBar->setStretchableWidget ( dummy ) ; | 934 | iconToolBar->setStretchableWidget ( dummy ) ; |
936 | else | 935 | else |
937 | configureToolBarMenu->setItemChecked( 5, true ); | 936 | configureToolBarMenu->setItemChecked( 5, true ); |
938 | if (p-> mShowIconWhatsThis) | 937 | if (p-> mShowIconWhatsThis) |
939 | QWhatsThis::whatsThisButton ( iconToolBar ); | 938 | QWhatsThis::whatsThisButton ( iconToolBar ); |
940 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); | 939 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); |
941 | configureAgenda( p->mHourSize ); | 940 | configureAgenda( p->mHourSize ); |
942 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); | 941 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); |
943 | } | 942 | } |
944 | void MainWindow::fillSyncMenu() | 943 | void MainWindow::fillSyncMenu() |
945 | { | 944 | { |
946 | if ( syncMenu->count() ) | 945 | if ( syncMenu->count() ) |
947 | syncMenu->clear(); | 946 | syncMenu->clear(); |
948 | syncMenu->insertItem( i18n("Configure..."), 0 ); | 947 | syncMenu->insertItem( i18n("Configure..."), 0 ); |
949 | syncMenu->insertSeparator(); | 948 | syncMenu->insertSeparator(); |
950 | if ( mServerSocket == 0 ) { | 949 | if ( mServerSocket == 0 ) { |
951 | syncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); | 950 | syncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); |
952 | } else { | 951 | } else { |
953 | syncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); | 952 | syncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); |
954 | } | 953 | } |
955 | syncMenu->insertSeparator(); | 954 | syncMenu->insertSeparator(); |
956 | syncMenu->insertItem( i18n("Multiple sync"), 1 ); | 955 | syncMenu->insertItem( i18n("Multiple sync"), 1 ); |
957 | syncMenu->insertSeparator(); | 956 | syncMenu->insertSeparator(); |
958 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 957 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
959 | config.setGroup("General"); | 958 | config.setGroup("General"); |
960 | QStringList prof = config.readListEntry("SyncProfileNames"); | 959 | QStringList prof = config.readListEntry("SyncProfileNames"); |
961 | KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); | 960 | KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); |
962 | if ( prof.count() < 3 ) { | 961 | if ( prof.count() < 3 ) { |
963 | prof.clear(); | 962 | prof.clear(); |
964 | prof << i18n("Sharp_DTM"); | 963 | prof << i18n("Sharp_DTM"); |
965 | prof << i18n("Local_file"); | 964 | prof << i18n("Local_file"); |
966 | prof << i18n("Last_file"); | 965 | prof << i18n("Last_file"); |
967 | KSyncProfile* temp = new KSyncProfile (); | 966 | KSyncProfile* temp = new KSyncProfile (); |
968 | temp->setName( prof[0] ); | 967 | temp->setName( prof[0] ); |
969 | temp->writeConfig(&config); | 968 | temp->writeConfig(&config); |
970 | temp->setName( prof[1] ); | 969 | temp->setName( prof[1] ); |
971 | temp->writeConfig(&config); | 970 | temp->writeConfig(&config); |
972 | temp->setName( prof[2] ); | 971 | temp->setName( prof[2] ); |
973 | temp->writeConfig(&config); | 972 | temp->writeConfig(&config); |
974 | config.setGroup("General"); | 973 | config.setGroup("General"); |
975 | config.writeEntry("SyncProfileNames",prof); | 974 | config.writeEntry("SyncProfileNames",prof); |
976 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); | 975 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); |
977 | config.sync(); | 976 | config.sync(); |
978 | delete temp; | 977 | delete temp; |
979 | } | 978 | } |
980 | KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | 979 | KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); |
981 | KOPrefs::instance()->mSyncProfileNames = prof; | 980 | KOPrefs::instance()->mSyncProfileNames = prof; |
982 | int i; | 981 | int i; |
983 | for ( i = 0; i < prof.count(); ++i ) { | 982 | for ( i = 0; i < prof.count(); ++i ) { |
984 | 983 | ||
985 | syncMenu->insertItem( prof[i], 1000+i ); | 984 | syncMenu->insertItem( prof[i], 1000+i ); |
986 | if ( i == 2 ) | 985 | if ( i == 2 ) |
987 | syncMenu->insertSeparator(); | 986 | syncMenu->insertSeparator(); |
988 | } | 987 | } |
989 | QDir app_dir; | 988 | QDir app_dir; |
990 | if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | 989 | if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { |
991 | syncMenu->setItemEnabled( false , 1000 ); | 990 | syncMenu->setItemEnabled( false , 1000 ); |
992 | } | 991 | } |
993 | } | 992 | } |
994 | 993 | ||
995 | int MainWindow::ringSync() | 994 | int MainWindow::ringSync() |
996 | { | 995 | { |
997 | int syncedProfiles = 0; | 996 | int syncedProfiles = 0; |
998 | int i; | 997 | int i; |
999 | QTime timer; | 998 | QTime timer; |
1000 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 999 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
1001 | QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; | 1000 | QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; |
1002 | KSyncProfile* temp = new KSyncProfile (); | 1001 | KSyncProfile* temp = new KSyncProfile (); |
1003 | KOPrefs::instance()->mAskForPreferences = false; | 1002 | KOPrefs::instance()->mAskForPreferences = false; |
1004 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 1003 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
1005 | mCurrentSyncProfile = i; | 1004 | mCurrentSyncProfile = i; |
1006 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 1005 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
1007 | temp->readConfig(&config); | 1006 | temp->readConfig(&config); |
1008 | if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { | 1007 | if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { |
1009 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 1008 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
1010 | ++syncedProfiles; | 1009 | ++syncedProfiles; |
1011 | // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 1010 | // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
1012 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 1011 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
1013 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 1012 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
1014 | KOPrefs::instance()->mWriteBackInFuture = 0; | 1013 | KOPrefs::instance()->mWriteBackInFuture = 0; |
1015 | if ( temp->getWriteBackFuture() ) | 1014 | if ( temp->getWriteBackFuture() ) |
1016 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 1015 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
1017 | KOPrefs::instance()->mShowSyncSummary = false; | 1016 | KOPrefs::instance()->mShowSyncSummary = false; |
1018 | mView->setSyncDevice(syncProfileNames[i] ); | 1017 | mView->setSyncDevice(syncProfileNames[i] ); |
1019 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); | 1018 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); |
1020 | if ( i == 0 ) { | 1019 | if ( i == 0 ) { |
1021 | syncSharp(); | 1020 | syncSharp(); |
1022 | } else { | 1021 | } else { |
1023 | if ( temp->getIsLocalFileSync() ) { | 1022 | if ( temp->getIsLocalFileSync() ) { |
1024 | if ( syncWithFile( temp->getRemoteFileName( ), true ) ) | 1023 | if ( syncWithFile( temp->getRemoteFileName( ), true ) ) |
1025 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); | 1024 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); |
1026 | } else { | 1025 | } else { |
1027 | if ( temp->getIsPhoneSync() ) { | 1026 | if ( temp->getIsPhoneSync() ) { |
1028 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | 1027 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; |
1029 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | 1028 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); |
1030 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | 1029 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); |
1031 | syncPhone(); | 1030 | syncPhone(); |
1032 | } else if ( temp->getIsPiSync() ) { | 1031 | } else if ( temp->getIsPiSync() ) { |
1033 | mPassWordPiSync = temp->getRemotePw(); | 1032 | mPassWordPiSync = temp->getRemotePw(); |
1034 | KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort(); | 1033 | KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort(); |
1035 | KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP(); | 1034 | KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP(); |
1036 | syncPi(); | 1035 | syncPi(); |
1037 | } else | 1036 | } else |
1038 | syncRemote( temp, false ); | 1037 | syncRemote( temp, false ); |
1039 | 1038 | ||
1040 | } | 1039 | } |
1041 | } | 1040 | } |
1042 | timer.start(); | 1041 | timer.start(); |
1043 | setCaption(i18n("Multiple sync in progress ... please wait!") ); | 1042 | setCaption(i18n("Multiple sync in progress ... please wait!") ); |
1044 | while ( timer.elapsed () < 2000 ) { | 1043 | while ( timer.elapsed () < 2000 ) { |
1045 | qApp->processEvents(); | 1044 | qApp->processEvents(); |
1046 | #ifndef _WIN32_ | 1045 | #ifndef _WIN32_ |
1047 | sleep (1); | 1046 | sleep (1); |
1048 | #endif | 1047 | #endif |
1049 | } | 1048 | } |
1050 | 1049 | ||
1051 | } | 1050 | } |
1052 | 1051 | ||
1053 | } | 1052 | } |
1054 | delete temp; | 1053 | delete temp; |
1055 | return syncedProfiles; | 1054 | return syncedProfiles; |
1056 | } | 1055 | } |
1057 | 1056 | ||
1058 | void MainWindow::multiSync( bool askforPrefs ) | 1057 | void MainWindow::multiSync( bool askforPrefs ) |
1059 | { | 1058 | { |
1060 | if (mBlockSaveFlag) | 1059 | if (mBlockSaveFlag) |
1061 | return; | 1060 | return; |
1062 | mBlockSaveFlag = true; | 1061 | mBlockSaveFlag = true; |
1063 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 1062 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
1064 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | 1063 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), |
1065 | question, | 1064 | question, |
1066 | i18n("Yes"), i18n("No"), | 1065 | i18n("Yes"), i18n("No"), |
1067 | 0, 0 ) != 0 ) { | 1066 | 0, 0 ) != 0 ) { |
1068 | mBlockSaveFlag = false; | 1067 | mBlockSaveFlag = false; |
1069 | setCaption(i18n("Aborted! Nothing synced!")); | 1068 | setCaption(i18n("Aborted! Nothing synced!")); |
1070 | return; | 1069 | return; |
1071 | } | 1070 | } |
1072 | mView->setSyncDevice(i18n("Multiple profiles") ); | 1071 | mView->setSyncDevice(i18n("Multiple profiles") ); |
1073 | KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; | 1072 | KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; |
1074 | if ( askforPrefs ) { | 1073 | if ( askforPrefs ) { |
1075 | mView->edit_sync_options(); | 1074 | mView->edit_sync_options(); |
1076 | KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; | 1075 | KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; |
1077 | } | 1076 | } |
1078 | setCaption(i18n("Multiple sync started.") ); | 1077 | setCaption(i18n("Multiple sync started.") ); |
1079 | qApp->processEvents(); | 1078 | qApp->processEvents(); |
1080 | int num = ringSync() ; | 1079 | int num = ringSync() ; |
1081 | if ( num > 1 ) | 1080 | if ( num > 1 ) |
1082 | ringSync(); | 1081 | ringSync(); |
1083 | mBlockSaveFlag = false; | 1082 | mBlockSaveFlag = false; |
1084 | if ( num ) | 1083 | if ( num ) |
1085 | save(); | 1084 | save(); |
1086 | if ( num ) | 1085 | if ( num ) |
1087 | setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); | 1086 | setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); |
1088 | else | 1087 | else |
1089 | setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 1088 | setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
1090 | return; | 1089 | return; |
1091 | } | 1090 | } |
1092 | void MainWindow::slotSyncMenu( int action ) | 1091 | void MainWindow::slotSyncMenu( int action ) |
1093 | { | 1092 | { |
1094 | qDebug("syncaction %d ", action); | 1093 | qDebug("syncaction %d ", action); |
1095 | if ( action == 0 ) { | 1094 | if ( action == 0 ) { |
1096 | 1095 | ||
1097 | // seems to be a Qt2 event handling bug | 1096 | // seems to be a Qt2 event handling bug |
1098 | // syncmenu.clear causes a segfault at first time | 1097 | // syncmenu.clear causes a segfault at first time |
1099 | // when we call it after the main event loop, it is ok | 1098 | // when we call it after the main event loop, it is ok |
1100 | // same behaviour when calling OM/Pi via QCOP for the first time | 1099 | // same behaviour when calling OM/Pi via QCOP for the first time |
1101 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | 1100 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); |
1102 | //confSync(); | 1101 | //confSync(); |
1103 | 1102 | ||
1104 | return; | 1103 | return; |
1105 | } | 1104 | } |
1106 | if ( action == 1 ) { | 1105 | if ( action == 1 ) { |
1107 | multiSync( true ); | 1106 | multiSync( true ); |
1108 | return; | 1107 | return; |
1109 | } | 1108 | } |
1110 | if ( action == 2 ) { | 1109 | if ( action == 2 ) { |
1111 | enableQuick(); | 1110 | enableQuick(); |
1112 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 1111 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
1113 | return; | 1112 | return; |
1114 | } | 1113 | } |
1115 | if ( action == 3 ) { | 1114 | if ( action == 3 ) { |
1116 | delete mServerSocket; | 1115 | delete mServerSocket; |
1117 | mServerSocket = 0; | 1116 | mServerSocket = 0; |
1118 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 1117 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
1119 | return; | 1118 | return; |
1120 | } | 1119 | } |
1121 | 1120 | ||
1122 | if (mBlockSaveFlag) | 1121 | if (mBlockSaveFlag) |
1123 | return; | 1122 | return; |
1124 | mBlockSaveFlag = true; | 1123 | mBlockSaveFlag = true; |
1125 | mCurrentSyncProfile = action - 1000 ; | 1124 | mCurrentSyncProfile = action - 1000 ; |
1126 | mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); | 1125 | mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); |
1127 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); | 1126 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); |
1128 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 1127 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
1129 | KSyncProfile* temp = new KSyncProfile (); | 1128 | KSyncProfile* temp = new KSyncProfile (); |
1130 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 1129 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
1131 | temp->readConfig(&config); | 1130 | temp->readConfig(&config); |
1132 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 1131 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
1133 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); | 1132 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); |
1134 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 1133 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
1135 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 1134 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
1136 | KOPrefs::instance()->mWriteBackInFuture = 0; | 1135 | KOPrefs::instance()->mWriteBackInFuture = 0; |
1137 | if ( temp->getWriteBackFuture() ) | 1136 | if ( temp->getWriteBackFuture() ) |
1138 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 1137 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
1139 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); | 1138 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); |
1140 | if ( action == 1000 ) { | 1139 | if ( action == 1000 ) { |
1141 | syncSharp(); | 1140 | syncSharp(); |
1142 | 1141 | ||
1143 | } else if ( action == 1001 ) { | 1142 | } else if ( action == 1001 ) { |
1144 | syncLocalFile(); | 1143 | syncLocalFile(); |
1145 | 1144 | ||
1146 | } else if ( action == 1002 ) { | 1145 | } else if ( action == 1002 ) { |
1147 | quickSyncLocalFile(); | 1146 | quickSyncLocalFile(); |
1148 | 1147 | ||
1149 | } else if ( action >= 1003 ) { | 1148 | } else if ( action >= 1003 ) { |
1150 | if ( temp->getIsLocalFileSync() ) { | 1149 | if ( temp->getIsLocalFileSync() ) { |
1151 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 1150 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
1152 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); | 1151 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); |
1153 | } else { | 1152 | } else { |
1154 | if ( temp->getIsPhoneSync() ) { | 1153 | if ( temp->getIsPhoneSync() ) { |
1155 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | 1154 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; |
1156 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | 1155 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); |
1157 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | 1156 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); |
1158 | syncPhone(); | 1157 | syncPhone(); |
1159 | } else if ( temp->getIsPiSync() ) { | 1158 | } else if ( temp->getIsPiSync() ) { |
1160 | mPassWordPiSync = temp->getRemotePw(); | 1159 | mPassWordPiSync = temp->getRemotePw(); |
1161 | KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort(); | 1160 | KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort(); |
1162 | KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP(); | 1161 | KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP(); |
1163 | syncPi(); | 1162 | syncPi(); |
1164 | } else | 1163 | } else |
1165 | syncRemote( temp ); | 1164 | syncRemote( temp ); |
1166 | 1165 | ||
1167 | } | 1166 | } |
1168 | } | 1167 | } |
1169 | delete temp; | 1168 | delete temp; |
1170 | mBlockSaveFlag = false; | 1169 | mBlockSaveFlag = false; |
1171 | } | 1170 | } |
1172 | void MainWindow::exportToPhone( int mode ) | 1171 | void MainWindow::exportToPhone( int mode ) |
1173 | { | 1172 | { |
1174 | 1173 | ||
1175 | //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); | 1174 | //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); |
1176 | //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); | 1175 | //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); |
1177 | KOex2phonePrefs ex2phone; | 1176 | KOex2phonePrefs ex2phone; |
1178 | 1177 | ||
1179 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 1178 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
1180 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 1179 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
1181 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 1180 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
1182 | if ( mode == 1 ) | 1181 | if ( mode == 1 ) |
1183 | ex2phone.setCaption(i18n("Export complete calendar")); | 1182 | ex2phone.setCaption(i18n("Export complete calendar")); |
1184 | if ( mode == 2 ) | 1183 | if ( mode == 2 ) |
1185 | ex2phone.setCaption(i18n("Export filtered calendar")); | 1184 | ex2phone.setCaption(i18n("Export filtered calendar")); |
1186 | 1185 | ||
1187 | if ( !ex2phone.exec() ) { | 1186 | if ( !ex2phone.exec() ) { |
1188 | return; | 1187 | return; |
1189 | } | 1188 | } |
1190 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 1189 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
1191 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 1190 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
1192 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 1191 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
1193 | 1192 | ||
1194 | int inFuture = 0; | 1193 | int inFuture = 0; |
1195 | if ( ex2phone.mWriteBackFuture->isChecked() ) | 1194 | if ( ex2phone.mWriteBackFuture->isChecked() ) |
1196 | inFuture = ex2phone.mWriteBackFutureWeeks->value(); | 1195 | inFuture = ex2phone.mWriteBackFutureWeeks->value(); |
1197 | QPtrList<Incidence> delSel; | 1196 | QPtrList<Incidence> delSel; |
1198 | if ( mode == 1 ) | 1197 | if ( mode == 1 ) |
1199 | delSel = mCalendar->rawIncidences(); | 1198 | delSel = mCalendar->rawIncidences(); |
1200 | if ( mode == 2 ) | 1199 | if ( mode == 2 ) |
1201 | delSel = mCalendar->incidences(); | 1200 | delSel = mCalendar->incidences(); |
1202 | CalendarLocal* cal = new CalendarLocal(); | 1201 | CalendarLocal* cal = new CalendarLocal(); |
1203 | cal->setLocalTime(); | 1202 | cal->setLocalTime(); |
1204 | Incidence *incidence = delSel.first(); | 1203 | Incidence *incidence = delSel.first(); |
1205 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 1204 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1206 | QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); | 1205 | QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); |
1207 | while ( incidence ) { | 1206 | while ( incidence ) { |
1208 | if ( incidence->type() != "Journal" ) { | 1207 | if ( incidence->type() != "Journal" ) { |
1209 | bool add = true; | 1208 | bool add = true; |
1210 | if ( inFuture ) { | 1209 | if ( inFuture ) { |
1211 | QDateTime dt; | 1210 | QDateTime dt; |
1212 | if ( incidence->type() == "Todo" ) { | 1211 | if ( incidence->type() == "Todo" ) { |
1213 | Todo * t = (Todo*)incidence; | 1212 | Todo * t = (Todo*)incidence; |
1214 | if ( t->hasDueDate() ) | 1213 | if ( t->hasDueDate() ) |
1215 | dt = t->dtDue(); | 1214 | dt = t->dtDue(); |
1216 | else | 1215 | else |
1217 | dt = cur.addSecs( 62 ); | 1216 | dt = cur.addSecs( 62 ); |
1218 | } | 1217 | } |
1219 | else { | 1218 | else { |
1220 | bool ok; | 1219 | bool ok; |
1221 | dt = incidence->getNextOccurence( cur, &ok ); | 1220 | dt = incidence->getNextOccurence( cur, &ok ); |
1222 | if ( !ok ) | 1221 | if ( !ok ) |
1223 | dt = cur.addSecs( -62 ); | 1222 | dt = cur.addSecs( -62 ); |
1224 | } | 1223 | } |
1225 | if ( dt < cur || dt > end ) { | 1224 | if ( dt < cur || dt > end ) { |
1226 | add = false; | 1225 | add = false; |
1227 | } | 1226 | } |
1228 | } | 1227 | } |
1229 | if ( add ) { | 1228 | if ( add ) { |
1230 | Incidence *in = incidence->clone(); | 1229 | Incidence *in = incidence->clone(); |
1231 | cal->addIncidence( in ); | 1230 | cal->addIncidence( in ); |
1232 | } | 1231 | } |
1233 | } | 1232 | } |
1234 | incidence = delSel.next(); | 1233 | incidence = delSel.next(); |
1235 | } | 1234 | } |
1236 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 1235 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
1237 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 1236 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
1238 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 1237 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
1239 | 1238 | ||
1240 | setCaption( i18n("Writing to phone...")); | 1239 | setCaption( i18n("Writing to phone...")); |
1241 | if ( PhoneFormat::writeToPhone( cal ) ) | 1240 | if ( PhoneFormat::writeToPhone( cal ) ) |
1242 | setCaption( i18n("Export to phone successful!")); | 1241 | setCaption( i18n("Export to phone successful!")); |
1243 | else | 1242 | else |
1244 | setCaption( i18n("Error exporting to phone!")); | 1243 | setCaption( i18n("Error exporting to phone!")); |
1245 | delete cal; | 1244 | delete cal; |
1246 | } | 1245 | } |
1247 | 1246 | ||
1248 | 1247 | ||
1249 | void MainWindow::setDefaultPreferences() | 1248 | void MainWindow::setDefaultPreferences() |
1250 | { | 1249 | { |
1251 | KOPrefs *p = KOPrefs::instance(); | 1250 | KOPrefs *p = KOPrefs::instance(); |
1252 | 1251 | ||
1253 | p->mCompactDialogs = true; | 1252 | p->mCompactDialogs = true; |
1254 | p->mConfirm = true; | 1253 | p->mConfirm = true; |
1255 | // p->mEnableQuickTodo = false; | 1254 | // p->mEnableQuickTodo = false; |
1256 | 1255 | ||
1257 | } | 1256 | } |
1258 | 1257 | ||
1259 | QString MainWindow::resourcePath() | 1258 | QString MainWindow::resourcePath() |
1260 | { | 1259 | { |
1261 | return KGlobal::iconLoader()->iconPath(); | 1260 | return KGlobal::iconLoader()->iconPath(); |
1262 | } | 1261 | } |
1263 | 1262 | ||
1264 | void MainWindow::displayText( QString text ,QString cap ) | 1263 | void MainWindow::displayText( QString text ,QString cap ) |
1265 | { | 1264 | { |
1266 | QDialog dia( this, "name", true ); ; | 1265 | QDialog dia( this, "name", true ); ; |
1267 | dia.setCaption( cap ); | 1266 | dia.setCaption( cap ); |
1268 | QVBoxLayout* lay = new QVBoxLayout( &dia ); | 1267 | QVBoxLayout* lay = new QVBoxLayout( &dia ); |
1269 | lay->setSpacing( 3 ); | 1268 | lay->setSpacing( 3 ); |
1270 | lay->setMargin( 3 ); | 1269 | lay->setMargin( 3 ); |
1271 | QTextBrowser tb ( &dia ); | 1270 | QTextBrowser tb ( &dia ); |
1272 | lay->addWidget( &tb ); | 1271 | lay->addWidget( &tb ); |
1273 | tb.setText( text ); | 1272 | tb.setText( text ); |
1274 | #ifdef DESKTOP_VERSION | 1273 | #ifdef DESKTOP_VERSION |
1275 | dia.resize( 640, 480); | 1274 | dia.resize( 640, 480); |
1276 | #else | 1275 | #else |
1277 | dia.showMaximized(); | 1276 | dia.showMaximized(); |
1278 | #endif | 1277 | #endif |
1279 | dia.exec(); | 1278 | dia.exec(); |
1280 | } | 1279 | } |
1281 | void MainWindow::displayFile( QString fn, QString cap ) | 1280 | void MainWindow::displayFile( QString fn, QString cap ) |
1282 | { | 1281 | { |
1283 | QString fileName = resourcePath() + fn; | 1282 | QString fileName = resourcePath() + fn; |
1284 | QString text; | 1283 | QString text; |
1285 | QFile file( fileName ); | 1284 | QFile file( fileName ); |
1286 | if (!file.open( IO_ReadOnly ) ) { | 1285 | if (!file.open( IO_ReadOnly ) ) { |
1287 | return ; | 1286 | return ; |
1288 | 1287 | ||
1289 | } | 1288 | } |
1290 | QTextStream ts( &file ); | 1289 | QTextStream ts( &file ); |
1291 | text = ts.read(); | 1290 | text = ts.read(); |
1292 | file.close(); | 1291 | file.close(); |
1293 | displayText( text, cap); | 1292 | displayText( text, cap); |
1294 | } | 1293 | } |
1295 | void MainWindow::features() | 1294 | void MainWindow::features() |
1296 | { | 1295 | { |
1297 | 1296 | ||
1298 | displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); | 1297 | displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); |
1299 | } | 1298 | } |
1300 | 1299 | ||
1301 | void MainWindow::usertrans() | 1300 | void MainWindow::usertrans() |
1302 | { | 1301 | { |
1303 | 1302 | ||
1304 | displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); | 1303 | displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); |
1305 | } | 1304 | } |
1306 | 1305 | ||
1307 | void MainWindow::synchowto() | 1306 | void MainWindow::synchowto() |
1308 | { | 1307 | { |
1309 | #if 0 | 1308 | #if 0 |
1310 | QPtrList<Incidence> er = mCalendar->rawIncidences(); | 1309 | QPtrList<Incidence> er = mCalendar->rawIncidences(); |
1311 | Incidence* inR = er.first(); | 1310 | Incidence* inR = er.first(); |
1312 | VCalFormat vf; | 1311 | VCalFormat vf; |
1313 | QString strout; | 1312 | QString strout; |
1314 | while ( inR ) { | 1313 | while ( inR ) { |
1315 | if ( inR->type() == "Todo" ) | 1314 | if ( inR->type() == "Todo" ) |
1316 | strout = vf.todoToString( (Todo *) inR ); | 1315 | strout = vf.todoToString( (Todo *) inR ); |
1317 | if ( inR->type() == "Event" ) | 1316 | if ( inR->type() == "Event" ) |
1318 | strout = vf.eventToString( (Event *) inR ); | 1317 | strout = vf.eventToString( (Event *) inR ); |
1319 | qDebug("incidence: \n%s\n ente\n\n",strout.latin1() ); | 1318 | qDebug("incidence: \n%s\n ente\n\n",strout.latin1() ); |
1320 | inR = er.next(); | 1319 | inR = er.next(); |
1321 | } | 1320 | } |
1322 | #endif | 1321 | #endif |
1323 | displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); | 1322 | displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); |
1324 | } | 1323 | } |
1325 | void MainWindow::faq() | 1324 | void MainWindow::faq() |
1326 | { | 1325 | { |
1327 | displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); | 1326 | displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); |
1328 | 1327 | ||
1329 | } | 1328 | } |
1330 | void MainWindow::whatsNew() | 1329 | void MainWindow::whatsNew() |
1331 | { | 1330 | { |
1332 | displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); | 1331 | displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); |
1333 | 1332 | ||
1334 | } | 1333 | } |
1335 | void MainWindow::licence() | 1334 | void MainWindow::licence() |
1336 | { | 1335 | { |
1337 | KApplication::showLicence(); | 1336 | KApplication::showLicence(); |
1338 | 1337 | ||
1339 | } | 1338 | } |
1340 | void MainWindow::about() | 1339 | void MainWindow::about() |
1341 | { | 1340 | { |
1342 | QString version; | 1341 | QString version; |
1343 | #include <../version> | 1342 | #include <../version> |
1344 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), | 1343 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), |
1345 | i18n("KOrganizer/Platform-independent\n") + | 1344 | i18n("KOrganizer/Platform-independent\n") + |
1346 | "(KO/Pi) " + version + " - " + | 1345 | "(KO/Pi) " + version + " - " + |
1347 | 1346 | ||
1348 | #ifdef DESKTOP_VERSION | 1347 | #ifdef DESKTOP_VERSION |
1349 | i18n("Desktop Edition\n") + | 1348 | i18n("Desktop Edition\n") + |
1350 | #else | 1349 | #else |
1351 | i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + | 1350 | i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + |
1352 | #endif | 1351 | #endif |
1353 | 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") ); | 1352 | 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") ); |
1354 | } | 1353 | } |
1355 | void MainWindow::keyBindings() | 1354 | void MainWindow::keyBindings() |
1356 | { | 1355 | { |
1357 | QString cap = i18n("Key bindings KOrganizer/Pi"); | 1356 | QString cap = i18n("Key bindings KOrganizer/Pi"); |
1358 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + | 1357 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + |
1359 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ | 1358 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ |
1360 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + | 1359 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + |
1361 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ | 1360 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ |
1362 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ | 1361 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ |
1363 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ | 1362 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ |
1364 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ | 1363 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ |
1365 | i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ | 1364 | i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ |
1366 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ | 1365 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ |
1367 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ | 1366 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ |
1368 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ | 1367 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ |
1369 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ | 1368 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ |
1370 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ | 1369 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ |
1371 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ | 1370 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ |
1372 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ | 1371 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ |
1373 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ | 1372 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ |
1374 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ | 1373 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ |
1375 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ | 1374 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ |
1376 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ | 1375 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ |
1377 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ | 1376 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ |
1378 | i18n("<p><h3>In agenda view:</h3></p>\n") + | 1377 | i18n("<p><h3>In agenda view:</h3></p>\n") + |
1379 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ | 1378 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ |
1380 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ | 1379 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ |
1381 | i18n("<p><h3>In todo view:</h3></p>\n") + | 1380 | i18n("<p><h3>In todo view:</h3></p>\n") + |
1382 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ | 1381 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ |
1383 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1382 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1384 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ | 1383 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ |
1385 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ | 1384 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ |
1386 | i18n("<p><h3>In list view:</h3></p>\n") + | 1385 | i18n("<p><h3>In list view:</h3></p>\n") + |
1387 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1386 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1388 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ | 1387 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ |
1389 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ | 1388 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ |
1390 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ | 1389 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ |
1391 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ | 1390 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ |
1392 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ | 1391 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ |
1393 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + | 1392 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + |
1394 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ | 1393 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ |
1395 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ | 1394 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ |
1396 | i18n("<p><b>E</b>: Edit item</p>\n") + | 1395 | i18n("<p><b>E</b>: Edit item</p>\n") + |
1397 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + | 1396 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + |
1398 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + | 1397 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + |
1399 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ | 1398 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ |
1400 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ | 1399 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ |
1401 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ | 1400 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ |
1402 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ | 1401 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ |
1403 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ | 1402 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ |
1404 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + | 1403 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + |
1405 | i18n("<p><b>White</b>: Item readonly</p>\n"); | 1404 | i18n("<p><b>White</b>: Item readonly</p>\n"); |
1406 | displayText( text, cap); | 1405 | displayText( text, cap); |
1407 | 1406 | ||
1408 | } | 1407 | } |
1409 | void MainWindow::aboutAutoSaving() | 1408 | void MainWindow::aboutAutoSaving() |
1410 | { | 1409 | { |
1411 | QMessageBox* msg; | 1410 | QMessageBox* msg; |
1412 | msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), | 1411 | msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), |
1413 | i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon, | 1412 | i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon, |
1414 | QMessageBox::Ok, | 1413 | QMessageBox::Ok, |
1415 | QMessageBox::NoButton, | 1414 | QMessageBox::NoButton, |
1416 | QMessageBox::NoButton); | 1415 | QMessageBox::NoButton); |
1417 | msg->exec(); | 1416 | msg->exec(); |
1418 | delete msg; | 1417 | delete msg; |
1419 | 1418 | ||
1420 | 1419 | ||
1421 | } | 1420 | } |
1422 | void MainWindow::aboutKnownBugs() | 1421 | void MainWindow::aboutKnownBugs() |
1423 | { | 1422 | { |
1424 | QMessageBox* msg; | 1423 | QMessageBox* msg; |
1425 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), | 1424 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), |
1426 | i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ | 1425 | i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ |
1427 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ | 1426 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ |
1428 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + | 1427 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + |
1429 | i18n("\nor report them in the bugtracker on\n") + | 1428 | i18n("\nor report them in the bugtracker on\n") + |
1430 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), | 1429 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), |
1431 | QMessageBox::NoIcon, | 1430 | QMessageBox::NoIcon, |
1432 | QMessageBox::Ok, | 1431 | QMessageBox::Ok, |
1433 | QMessageBox::NoButton, | 1432 | QMessageBox::NoButton, |
1434 | QMessageBox::NoButton); | 1433 | QMessageBox::NoButton); |
1435 | msg->exec(); | 1434 | msg->exec(); |
1436 | delete msg; | 1435 | delete msg; |
1437 | 1436 | ||
1438 | } | 1437 | } |
1439 | 1438 | ||
1440 | QString MainWindow::defaultFileName() | 1439 | QString MainWindow::defaultFileName() |
1441 | { | 1440 | { |
1442 | return locateLocal( "data", "korganizer/mycalendar.ics" ); | 1441 | return locateLocal( "data", "korganizer/mycalendar.ics" ); |
1443 | } | 1442 | } |
1444 | QString MainWindow::syncFileName() | 1443 | QString MainWindow::syncFileName() |
1445 | { | 1444 | { |
1446 | #ifdef _WIN32_ | 1445 | #ifdef _WIN32_ |
1447 | return locateLocal( "tmp", "synccalendar.ics" ); | 1446 | return locateLocal( "tmp", "synccalendar.ics" ); |
1448 | #else | 1447 | #else |
1449 | return QString( "/tmp/kopitempfile.ics" ); | 1448 | return QString( "/tmp/kopitempfile.ics" ); |
1450 | #endif | 1449 | #endif |
1451 | } | 1450 | } |
1452 | 1451 | ||
1453 | void MainWindow::processIncidenceSelection( Incidence *incidence ) | 1452 | void MainWindow::processIncidenceSelection( Incidence *incidence ) |
1454 | { | 1453 | { |
1455 | if ( !incidence ) { | 1454 | if ( !incidence ) { |
1456 | enableIncidenceActions( false ); | 1455 | enableIncidenceActions( false ); |
1457 | 1456 | ||
1458 | mNewSubTodoAction->setEnabled( false ); | 1457 | mNewSubTodoAction->setEnabled( false ); |
1459 | setCaptionToDates(); | 1458 | setCaptionToDates(); |
1460 | return; | 1459 | return; |
1461 | 1460 | ||
1462 | } | 1461 | } |
1463 | 1462 | ||
1464 | //KGlobal::locale()->formatDateTime(nextA, true); | 1463 | //KGlobal::locale()->formatDateTime(nextA, true); |
1465 | QString startString = ""; | 1464 | QString startString = ""; |
1466 | if ( incidence->type() != "Todo" ) { | 1465 | if ( incidence->type() != "Todo" ) { |
1467 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { | 1466 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { |
1468 | if ( incidence->doesFloat() ) { | 1467 | if ( incidence->doesFloat() ) { |
1469 | startString += ": "+incidence->dtStartDateStr( true ); | 1468 | startString += ": "+incidence->dtStartDateStr( true ); |
1470 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); | 1469 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); |
1471 | 1470 | ||
1472 | } else { | 1471 | } else { |
1473 | startString = ": "+incidence->dtStartStr(true); | 1472 | startString = ": "+incidence->dtStartStr(true); |
1474 | startString += " --- "+((Event*)incidence)->dtEndStr(true); | 1473 | startString += " --- "+((Event*)incidence)->dtEndStr(true); |
1475 | 1474 | ||
1476 | } | 1475 | } |
1477 | 1476 | ||
1478 | } else { | 1477 | } else { |
1479 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) | 1478 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) |
1480 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ | 1479 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ |
1481 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); | 1480 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); |
1482 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); | 1481 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); |
1483 | } | 1482 | } |
1484 | 1483 | ||
1485 | } | 1484 | } |
1486 | else | 1485 | else |
1487 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); | 1486 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); |
1488 | if ( !incidence->location().isEmpty() ) | 1487 | if ( !incidence->location().isEmpty() ) |
1489 | startString += " (" +incidence->location()+")"; | 1488 | startString += " (" +incidence->location()+")"; |
1490 | setCaption( incidence->summary()+startString); | 1489 | setCaption( incidence->summary()+startString); |
1491 | 1490 | ||
1492 | enableIncidenceActions( true ); | 1491 | enableIncidenceActions( true ); |
1493 | 1492 | ||
1494 | if ( incidence->type() == "Event" ) { | 1493 | if ( incidence->type() == "Event" ) { |
1495 | mShowAction->setText( i18n("Show Event...") ); | 1494 | mShowAction->setText( i18n("Show Event...") ); |
1496 | mEditAction->setText( i18n("Edit Event...") ); | 1495 | mEditAction->setText( i18n("Edit Event...") ); |
1497 | mDeleteAction->setText( i18n("Delete Event...") ); | 1496 | mDeleteAction->setText( i18n("Delete Event...") ); |
1498 | 1497 | ||
1499 | mNewSubTodoAction->setEnabled( false ); | 1498 | mNewSubTodoAction->setEnabled( false ); |
1500 | } else if ( incidence->type() == "Todo" ) { | 1499 | } else if ( incidence->type() == "Todo" ) { |
1501 | mShowAction->setText( i18n("Show Todo...") ); | 1500 | mShowAction->setText( i18n("Show Todo...") ); |
1502 | mEditAction->setText( i18n("Edit Todo...") ); | 1501 | mEditAction->setText( i18n("Edit Todo...") ); |
1503 | mDeleteAction->setText( i18n("Delete Todo...") ); | 1502 | mDeleteAction->setText( i18n("Delete Todo...") ); |
1504 | 1503 | ||
1505 | mNewSubTodoAction->setEnabled( true ); | 1504 | mNewSubTodoAction->setEnabled( true ); |
1506 | } else { | 1505 | } else { |
1507 | mShowAction->setText( i18n("Show...") ); | 1506 | mShowAction->setText( i18n("Show...") ); |
1508 | mShowAction->setText( i18n("Edit...") ); | 1507 | mShowAction->setText( i18n("Edit...") ); |
1509 | mShowAction->setText( i18n("Delete...") ); | 1508 | mShowAction->setText( i18n("Delete...") ); |
1510 | 1509 | ||
1511 | mNewSubTodoAction->setEnabled( false ); | 1510 | mNewSubTodoAction->setEnabled( false ); |
1512 | } | 1511 | } |
1513 | } | 1512 | } |
1514 | 1513 | ||
1515 | void MainWindow::enableIncidenceActions( bool enabled ) | 1514 | void MainWindow::enableIncidenceActions( bool enabled ) |
1516 | { | 1515 | { |
1517 | mShowAction->setEnabled( enabled ); | 1516 | mShowAction->setEnabled( enabled ); |
1518 | mEditAction->setEnabled( enabled ); | 1517 | mEditAction->setEnabled( enabled ); |
1519 | mDeleteAction->setEnabled( enabled ); | 1518 | mDeleteAction->setEnabled( enabled ); |
1520 | 1519 | ||
1521 | mCloneAction->setEnabled( enabled ); | 1520 | mCloneAction->setEnabled( enabled ); |
1522 | mMoveAction->setEnabled( enabled ); | 1521 | mMoveAction->setEnabled( enabled ); |
1523 | mBeamAction->setEnabled( enabled ); | 1522 | mBeamAction->setEnabled( enabled ); |
1524 | mCancelAction->setEnabled( enabled ); | 1523 | mCancelAction->setEnabled( enabled ); |
1525 | } | 1524 | } |
1526 | 1525 | ||
1527 | void MainWindow::importOL() | 1526 | void MainWindow::importOL() |
1528 | { | 1527 | { |
1529 | #ifdef _WIN32_ | 1528 | #ifdef _WIN32_ |
1530 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); | 1529 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); |
1531 | id->exec(); | 1530 | id->exec(); |
1532 | delete id; | 1531 | delete id; |
1533 | mView->updateView(); | 1532 | mView->updateView(); |
1534 | #endif | 1533 | #endif |
1535 | } | 1534 | } |
1536 | void MainWindow::importBday() | 1535 | void MainWindow::importBday() |
1537 | { | 1536 | { |
1538 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1537 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1539 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), | 1538 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), |
1540 | i18n("Import!"), i18n("Cancel"), 0, | 1539 | i18n("Import!"), i18n("Cancel"), 0, |
1541 | 0, 1 ); | 1540 | 0, 1 ); |
1542 | if ( result == 0 ) { | 1541 | if ( result == 0 ) { |
1543 | mView->importBday(); | 1542 | mView->importBday(); |
1544 | 1543 | ||
1545 | } | 1544 | } |
1546 | 1545 | ||
1547 | 1546 | ||
1548 | } | 1547 | } |
1549 | void MainWindow::importQtopia() | 1548 | void MainWindow::importQtopia() |
1550 | { | 1549 | { |
1551 | #ifndef DESKTOP_VERSION | 1550 | #ifndef DESKTOP_VERSION |
1552 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1551 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1553 | i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), | 1552 | i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), |
1554 | i18n("Import!"), i18n("Cancel"), 0, | 1553 | i18n("Import!"), i18n("Cancel"), 0, |
1555 | 0, 1 ); | 1554 | 0, 1 ); |
1556 | if ( result == 0 ) { | 1555 | if ( result == 0 ) { |
1557 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); | 1556 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); |
1558 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); | 1557 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); |
1559 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; | 1558 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; |
1560 | mView->importQtopia( categories, datebook, todolist ); | 1559 | mView->importQtopia( categories, datebook, todolist ); |
1561 | } | 1560 | } |
1562 | #else | 1561 | #else |
1563 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1562 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1564 | i18n("Not supported \non desktop!\n"), | 1563 | i18n("Not supported \non desktop!\n"), |
1565 | i18n("Ok"), i18n("Cancel"), 0, | 1564 | i18n("Ok"), i18n("Cancel"), 0, |
1566 | 0, 1 ); | 1565 | 0, 1 ); |
1567 | 1566 | ||
1568 | #endif | 1567 | #endif |
1569 | } | 1568 | } |
1570 | 1569 | ||
1571 | void MainWindow::saveOnClose() | 1570 | void MainWindow::saveOnClose() |
1572 | { | 1571 | { |
1573 | KOPrefs *p = KOPrefs::instance(); | 1572 | KOPrefs *p = KOPrefs::instance(); |
1574 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); | 1573 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); |
1575 | p->mToolBarUp = iconToolBar->x() > width()/2 || | 1574 | p->mToolBarUp = iconToolBar->x() > width()/2 || |
1576 | iconToolBar->y() > height()/2; | 1575 | iconToolBar->y() > height()/2; |
1577 | mView->writeSettings(); | 1576 | mView->writeSettings(); |
1578 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) | 1577 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) |
1579 | save(); | 1578 | save(); |
1580 | } | 1579 | } |
1581 | void MainWindow::slotModifiedChanged( bool changed ) | 1580 | void MainWindow::slotModifiedChanged( bool changed ) |
1582 | { | 1581 | { |
1583 | if ( mBlockAtStartup ) | 1582 | if ( mBlockAtStartup ) |
1584 | return; | 1583 | return; |
1585 | int msec; | 1584 | int msec; |
1586 | // we store the changes after 1 minute, | 1585 | // we store the changes after 1 minute, |
1587 | // and for safety reasons after 10 minutes again | 1586 | // and for safety reasons after 10 minutes again |
1588 | if ( !mBlockSaveFlag ) | 1587 | if ( !mBlockSaveFlag ) |
1589 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; | 1588 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; |
1590 | else | 1589 | else |
1591 | msec = 1000 * 600; | 1590 | msec = 1000 * 600; |
1592 | mSaveTimer.start( msec, true ); // 1 minute | 1591 | mSaveTimer.start( msec, true ); // 1 minute |
1593 | qDebug("KO: Saving File in %d secs!", msec/1000); | 1592 | qDebug("KO: Saving File in %d secs!", msec/1000); |
1594 | mCalendarModifiedFlag = true; | 1593 | mCalendarModifiedFlag = true; |
1595 | } | 1594 | } |
1596 | void MainWindow::save() | 1595 | void MainWindow::save() |
1597 | { | 1596 | { |
1598 | if ( mBlockSaveFlag ) | 1597 | if ( mBlockSaveFlag ) |
1599 | return; | 1598 | return; |
1600 | bool store = mBlockSaveFlag; | 1599 | bool store = mBlockSaveFlag; |
1601 | mBlockSaveFlag = true; | 1600 | mBlockSaveFlag = true; |
1602 | if ( mView->checkFileVersion( defaultFileName()) ) { | 1601 | if ( mView->checkFileVersion( defaultFileName()) ) { |
1603 | 1602 | ||
1604 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 1603 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
1605 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); | 1604 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); |
1606 | qDebug("KO: Start saving data to file!"); | 1605 | qDebug("KO: Start saving data to file!"); |
1607 | mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1606 | mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1608 | mView->saveCalendar( defaultFileName() ); | 1607 | mView->saveCalendar( defaultFileName() ); |
1609 | 1608 | ||
1610 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 1609 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
1611 | mView->watchSavedFile(); | 1610 | mView->watchSavedFile(); |
1612 | qDebug("KO: Needed %d ms for saving.",msNeeded ); | 1611 | qDebug("KO: Needed %d ms for saving.",msNeeded ); |
1613 | QString savemes; | 1612 | QString savemes; |
1614 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); | 1613 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); |
1615 | setCaption(savemes); | 1614 | setCaption(savemes); |
1616 | } else | 1615 | } else |
1617 | setCaption(i18n("Saving cancelled!")); | 1616 | setCaption(i18n("Saving cancelled!")); |
1618 | mCalendarModifiedFlag = false; | 1617 | mCalendarModifiedFlag = false; |
1619 | mBlockSaveFlag = store; | 1618 | mBlockSaveFlag = store; |
1620 | } | 1619 | } |
1621 | 1620 | ||
1622 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) | 1621 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) |
1623 | { | 1622 | { |
1624 | if ( !e->isAutoRepeat() ) { | 1623 | if ( !e->isAutoRepeat() ) { |
1625 | mFlagKeyPressed = false; | 1624 | mFlagKeyPressed = false; |
1626 | } | 1625 | } |
1627 | } | 1626 | } |
1628 | void MainWindow::keyPressEvent ( QKeyEvent * e ) | 1627 | void MainWindow::keyPressEvent ( QKeyEvent * e ) |
1629 | { | 1628 | { |
1630 | qApp->processEvents(); | 1629 | qApp->processEvents(); |
1631 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 1630 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
1632 | e->ignore(); | 1631 | e->ignore(); |
1633 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 1632 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
1634 | return; | 1633 | return; |
1635 | } | 1634 | } |
1636 | if (! e->isAutoRepeat() ) | 1635 | if (! e->isAutoRepeat() ) |
1637 | mFlagKeyPressed = true; | 1636 | mFlagKeyPressed = true; |
1638 | KOPrefs *p = KOPrefs::instance(); | 1637 | KOPrefs *p = KOPrefs::instance(); |
1639 | bool showSelectedDates = false; | 1638 | bool showSelectedDates = false; |
1640 | int size; | 1639 | int size; |
1641 | int pro = 0; | 1640 | int pro = 0; |
1642 | //qDebug("MainWindow::keyPressEvent "); | 1641 | //qDebug("MainWindow::keyPressEvent "); |
1643 | switch ( e->key() ) { | 1642 | switch ( e->key() ) { |
1644 | case Qt::Key_Right: | 1643 | case Qt::Key_Right: |
1645 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1644 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1646 | mView->goNextMonth(); | 1645 | mView->goNextMonth(); |
1647 | else | 1646 | else |
1648 | mView->goNext(); | 1647 | mView->goNext(); |
1649 | showSelectedDates = true; | 1648 | showSelectedDates = true; |
1650 | break; | 1649 | break; |
1651 | case Qt::Key_Left: | 1650 | case Qt::Key_Left: |
1652 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1651 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1653 | mView->goPreviousMonth(); | 1652 | mView->goPreviousMonth(); |
1654 | else | 1653 | else |
1655 | mView->goPrevious(); | 1654 | mView->goPrevious(); |
1656 | showSelectedDates = true; | 1655 | showSelectedDates = true; |
1657 | break; | 1656 | break; |
1658 | case Qt::Key_Down: | 1657 | case Qt::Key_Down: |
1659 | mView->viewManager()->agendaView()->scrollOneHourDown(); | 1658 | mView->viewManager()->agendaView()->scrollOneHourDown(); |
1660 | break; | 1659 | break; |
1661 | case Qt::Key_Up: | 1660 | case Qt::Key_Up: |
1662 | mView->viewManager()->agendaView()->scrollOneHourUp(); | 1661 | mView->viewManager()->agendaView()->scrollOneHourUp(); |
1663 | break; | 1662 | break; |
1664 | case Qt::Key_I: | 1663 | case Qt::Key_I: |
1665 | mView->showIncidence(); | 1664 | mView->showIncidence(); |
1666 | break; | 1665 | break; |
1667 | case Qt::Key_Delete: | 1666 | case Qt::Key_Delete: |
1668 | case Qt::Key_Backspace: | 1667 | case Qt::Key_Backspace: |
1669 | mView->deleteIncidence(); | 1668 | mView->deleteIncidence(); |
1670 | break; | 1669 | break; |
1671 | case Qt::Key_D: | 1670 | case Qt::Key_D: |
1672 | mView->viewManager()->showDayView(); | 1671 | mView->viewManager()->showDayView(); |
1673 | showSelectedDates = true; | 1672 | showSelectedDates = true; |
1674 | break; | 1673 | break; |
1675 | case Qt::Key_O: | 1674 | case Qt::Key_O: |
1676 | mView->toggleFilerEnabled( ); | 1675 | mView->toggleFilerEnabled( ); |
1677 | break; | 1676 | break; |
1678 | case Qt::Key_0: | 1677 | case Qt::Key_0: |
1679 | case Qt::Key_1: | 1678 | case Qt::Key_1: |
1680 | case Qt::Key_2: | 1679 | case Qt::Key_2: |
1681 | case Qt::Key_3: | 1680 | case Qt::Key_3: |
1682 | case Qt::Key_4: | 1681 | case Qt::Key_4: |
1683 | case Qt::Key_5: | 1682 | case Qt::Key_5: |
1684 | case Qt::Key_6: | 1683 | case Qt::Key_6: |
1685 | case Qt::Key_7: | 1684 | case Qt::Key_7: |
1686 | case Qt::Key_8: | 1685 | case Qt::Key_8: |
1687 | case Qt::Key_9: | 1686 | case Qt::Key_9: |
1688 | pro = e->key()-48; | 1687 | pro = e->key()-48; |
1689 | if ( pro == 0 ) | 1688 | if ( pro == 0 ) |
1690 | pro = 10; | 1689 | pro = 10; |
1691 | if ( e->state() == Qt::ControlButton) | 1690 | if ( e->state() == Qt::ControlButton) |
1692 | pro += 10; | 1691 | pro += 10; |
1693 | break; | 1692 | break; |
1694 | case Qt::Key_M: | 1693 | case Qt::Key_M: |
1695 | mView->viewManager()->showMonthView(); | 1694 | mView->viewManager()->showMonthView(); |
1696 | showSelectedDates = true; | 1695 | showSelectedDates = true; |
1697 | break; | 1696 | break; |
1698 | case Qt::Key_Insert: | 1697 | case Qt::Key_Insert: |
1699 | mView->newEvent(); | 1698 | mView->newEvent(); |
1700 | break; | 1699 | break; |
1701 | case Qt::Key_S : | 1700 | case Qt::Key_S : |
1702 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1701 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1703 | mView->newSubTodo(); | 1702 | mView->newSubTodo(); |
1704 | else | 1703 | else |
1705 | mView->dialogManager()->showSearchDialog(); | 1704 | mView->dialogManager()->showSearchDialog(); |
1706 | break; | 1705 | break; |
1707 | case Qt::Key_Y : | 1706 | case Qt::Key_Y : |
1708 | case Qt::Key_Z : | 1707 | case Qt::Key_Z : |
1709 | mView->viewManager()->showWorkWeekView(); | 1708 | mView->viewManager()->showWorkWeekView(); |
1710 | showSelectedDates = true; | 1709 | showSelectedDates = true; |
1711 | break; | 1710 | break; |
1712 | case Qt::Key_U : | 1711 | case Qt::Key_U : |
1713 | mView->viewManager()->showWeekView(); | 1712 | mView->viewManager()->showWeekView(); |
1714 | showSelectedDates = true; | 1713 | showSelectedDates = true; |
1715 | break; | 1714 | break; |
1716 | case Qt::Key_H : | 1715 | case Qt::Key_H : |
1717 | keyBindings(); | 1716 | keyBindings(); |
1718 | break; | 1717 | break; |
1719 | case Qt::Key_W: | 1718 | case Qt::Key_W: |
1720 | mView->viewManager()->showWhatsNextView(); | 1719 | mView->viewManager()->showWhatsNextView(); |
1721 | break; | 1720 | break; |
1722 | case Qt::Key_L: | 1721 | case Qt::Key_L: |
1723 | mView->viewManager()->showListView(); | 1722 | mView->viewManager()->showListView(); |
1724 | break; | 1723 | break; |
1725 | case Qt::Key_N: | 1724 | case Qt::Key_N: |
1726 | mView->viewManager()->showNextXView(); | 1725 | mView->viewManager()->showNextXView(); |
1727 | showSelectedDates = true; | 1726 | showSelectedDates = true; |
1728 | break; | 1727 | break; |
1729 | case Qt::Key_V: | 1728 | case Qt::Key_V: |
1730 | mView->viewManager()->showTodoView(); | 1729 | mView->viewManager()->showTodoView(); |
1731 | break; | 1730 | break; |
1732 | case Qt::Key_C: | 1731 | case Qt::Key_C: |
1733 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); | 1732 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); |
1734 | break; | 1733 | break; |
1735 | case Qt::Key_P: | 1734 | case Qt::Key_P: |
1736 | mView->showDatePicker( ); | 1735 | mView->showDatePicker( ); |
1737 | break; | 1736 | break; |
1738 | case Qt::Key_F: | 1737 | case Qt::Key_F: |
1739 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1738 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1740 | mView->editFilters(); | 1739 | mView->editFilters(); |
1741 | else | 1740 | else |
1742 | mView->toggleFilter(); | 1741 | mView->toggleFilter(); |
1743 | break; | 1742 | break; |
1744 | case Qt::Key_X: | 1743 | case Qt::Key_X: |
1745 | mView->toggleDateNavigatorWidget(); | 1744 | mView->toggleDateNavigatorWidget(); |
1746 | break; | 1745 | break; |
1747 | case Qt::Key_Space: | 1746 | case Qt::Key_Space: |
1748 | mView->toggleExpand(); | 1747 | mView->toggleExpand(); |
1749 | break; | 1748 | break; |
1750 | case Qt::Key_A: | 1749 | case Qt::Key_A: |
1751 | mView->toggleAllDaySize(); | 1750 | mView->toggleAllDaySize(); |
1752 | break; | 1751 | break; |
1753 | case Qt::Key_T: | 1752 | case Qt::Key_T: |
1754 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1753 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1755 | mView->newTodo(); | 1754 | mView->newTodo(); |
1756 | else { | 1755 | else { |
1757 | mView->goToday(); | 1756 | mView->goToday(); |
1758 | showSelectedDates = true; | 1757 | showSelectedDates = true; |
1759 | } | 1758 | } |
1760 | break; | 1759 | break; |
1761 | case Qt::Key_J: | 1760 | case Qt::Key_J: |
1762 | mView->viewManager()->showJournalView(); | 1761 | mView->viewManager()->showJournalView(); |
1763 | break; | 1762 | break; |
1764 | case Qt::Key_B: | 1763 | case Qt::Key_B: |
1765 | mView->editIncidenceDescription();; | 1764 | mView->editIncidenceDescription();; |
1766 | break; | 1765 | break; |
1767 | // case Qt::Key_Return: | 1766 | // case Qt::Key_Return: |
1768 | case Qt::Key_E: | 1767 | case Qt::Key_E: |
1769 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1768 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1770 | mView->newEvent(); | 1769 | mView->newEvent(); |
1771 | else | 1770 | else |
1772 | mView->editIncidence(); | 1771 | mView->editIncidence(); |
1773 | break; | 1772 | break; |
1774 | case Qt::Key_Plus: | 1773 | case Qt::Key_Plus: |
1775 | size = p->mHourSize +2; | 1774 | size = p->mHourSize +2; |
1776 | if ( size <= 18 ) | 1775 | if ( size <= 18 ) |
1777 | configureAgenda( size ); | 1776 | configureAgenda( size ); |
1778 | break; | 1777 | break; |
1779 | case Qt::Key_Minus: | 1778 | case Qt::Key_Minus: |
1780 | size = p->mHourSize - 2; | 1779 | size = p->mHourSize - 2; |
1781 | if ( size >= 4 ) | 1780 | if ( size >= 4 ) |
1782 | configureAgenda( size ); | 1781 | configureAgenda( size ); |
1783 | break; | 1782 | break; |
1784 | 1783 | ||
1785 | 1784 | ||
1786 | default: | 1785 | default: |
1787 | e->ignore(); | 1786 | e->ignore(); |
1788 | } | 1787 | } |
1789 | if ( pro > 0 ) { | 1788 | if ( pro > 0 ) { |
1790 | mView->selectFilter( pro-1 ); | 1789 | mView->selectFilter( pro-1 ); |
1791 | } | 1790 | } |
1792 | if ( showSelectedDates ) { | 1791 | if ( showSelectedDates ) { |
1793 | ;// setCaptionToDates(); | 1792 | ;// setCaptionToDates(); |
1794 | } | 1793 | } |
1795 | 1794 | ||
1796 | } | 1795 | } |
1797 | 1796 | ||
1798 | void MainWindow::fillFilterMenu() | 1797 | void MainWindow::fillFilterMenu() |
1799 | { | 1798 | { |
1800 | selectFilterMenu->clear(); | 1799 | selectFilterMenu->clear(); |
1801 | bool disable = false; | 1800 | bool disable = false; |
1802 | if ( mView->filterView()->filtersEnabled() ) { | 1801 | if ( mView->filterView()->filtersEnabled() ) { |
1803 | selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); | 1802 | selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); |
1804 | } | 1803 | } |
1805 | else { | 1804 | else { |
1806 | selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); | 1805 | selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); |
1807 | disable = true; | 1806 | disable = true; |
1808 | } | 1807 | } |
1809 | selectFilterMenu->insertSeparator(); | 1808 | selectFilterMenu->insertSeparator(); |
1810 | QPtrList<CalFilter> fili = mView->filters(); | 1809 | QPtrList<CalFilter> fili = mView->filters(); |
1811 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 1810 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
1812 | CalFilter *filter = fili.first(); | 1811 | CalFilter *filter = fili.first(); |
1813 | int iii = 1; | 1812 | int iii = 1; |
1814 | while(filter) { | 1813 | while(filter) { |
1815 | selectFilterMenu->insertItem( filter->name(), iii ); | 1814 | selectFilterMenu->insertItem( filter->name(), iii ); |
1816 | if ( filter == curfilter) | 1815 | if ( filter == curfilter) |
1817 | selectFilterMenu->setItemChecked( iii, true ); | 1816 | selectFilterMenu->setItemChecked( iii, true ); |
1818 | if ( disable ) | 1817 | if ( disable ) |
1819 | selectFilterMenu->setItemEnabled( iii, false ); | 1818 | selectFilterMenu->setItemEnabled( iii, false ); |
1820 | filter = fili.next(); | 1819 | filter = fili.next(); |
1821 | ++iii; | 1820 | ++iii; |
1822 | } | 1821 | } |
1823 | } | 1822 | } |
1824 | void MainWindow::selectFilter( int fil ) | 1823 | void MainWindow::selectFilter( int fil ) |
1825 | { | 1824 | { |
1826 | if ( fil == 0 ) { | 1825 | if ( fil == 0 ) { |
1827 | mView->toggleFilerEnabled( ); | 1826 | mView->toggleFilerEnabled( ); |
1828 | } else { | 1827 | } else { |
1829 | mView->selectFilter( fil-1 ); | 1828 | mView->selectFilter( fil-1 ); |
1830 | } | 1829 | } |
1831 | } | 1830 | } |
1832 | void MainWindow::configureToolBar( int item ) | 1831 | void MainWindow::configureToolBar( int item ) |
1833 | { | 1832 | { |
1834 | 1833 | ||
1835 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); | 1834 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); |
1836 | KOPrefs *p = KOPrefs::instance(); | 1835 | KOPrefs *p = KOPrefs::instance(); |
1837 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); | 1836 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); |
1838 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); | 1837 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); |
1839 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); | 1838 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); |
1840 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); | 1839 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); |
1841 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); | 1840 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); |
1842 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); | 1841 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); |
1843 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); | 1842 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); |
1844 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); | 1843 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); |
1845 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); | 1844 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); |
1846 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); | 1845 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); |
1847 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); | 1846 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); |
1848 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); | 1847 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); |
1849 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); | 1848 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); |
1850 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); | 1849 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); |
1851 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); | 1850 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); |
1852 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); | 1851 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); |
1853 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); | 1852 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); |
1854 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); | 1853 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); |
1855 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); | 1854 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); |
1856 | // initActions(); | 1855 | // initActions(); |
1857 | } | 1856 | } |
1858 | 1857 | ||
1859 | void MainWindow::setCaptionToDates() | 1858 | void MainWindow::setCaptionToDates() |
1860 | { | 1859 | { |
1861 | QString selDates; | 1860 | QString selDates; |
1862 | selDates = KGlobal::locale()->formatDate(mView->startDate(), true); | 1861 | selDates = KGlobal::locale()->formatDate(mView->startDate(), true); |
1863 | if (mView->startDate() < mView->endDate() ) | 1862 | if (mView->startDate() < mView->endDate() ) |
1864 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); | 1863 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); |
1865 | setCaption( i18n("Dates: ") + selDates ); | 1864 | setCaption( i18n("Dates: ") + selDates ); |
1866 | 1865 | ||
1867 | } | 1866 | } |
1868 | // parameter item == 0: reinit | 1867 | // parameter item == 0: reinit |
1869 | void MainWindow::configureAgenda( int item ) | 1868 | void MainWindow::configureAgenda( int item ) |
1870 | { | 1869 | { |
1871 | 1870 | ||
1872 | KOPrefs *p = KOPrefs::instance(); | 1871 | KOPrefs *p = KOPrefs::instance(); |
1873 | 1872 | ||
1874 | int i; | 1873 | int i; |
1875 | if ( item == 1 ) { | 1874 | if ( item == 1 ) { |
1876 | mView->toggleAllDaySize(); | 1875 | mView->toggleAllDaySize(); |
1877 | return; | 1876 | return; |
1878 | } | 1877 | } |
1879 | // do not allow 4 for widgets higher than 480 | 1878 | // do not allow 4 for widgets higher than 480 |
1880 | // if ( QApplication::desktop()->height() > 480 ) { | 1879 | // if ( QApplication::desktop()->height() > 480 ) { |
1881 | // if ( item == 4 ) | 1880 | // if ( item == 4 ) |
1882 | // item = 6; | 1881 | // item = 6; |
1883 | // } | 1882 | // } |
1884 | for ( i = 4; i <= 18; i= i+2 ) | 1883 | for ( i = 4; i <= 18; i= i+2 ) |
1885 | configureAgendaMenu->setItemChecked( i, false ); | 1884 | configureAgendaMenu->setItemChecked( i, false ); |
1886 | configureAgendaMenu->setItemChecked( item, true ); | 1885 | configureAgendaMenu->setItemChecked( item, true ); |
1887 | if ( p->mHourSize == item ) | 1886 | if ( p->mHourSize == item ) |
1888 | return; | 1887 | return; |
1889 | p->mHourSize=item; | 1888 | p->mHourSize=item; |
1890 | mView->viewManager()->agendaView()->updateConfig(); | 1889 | mView->viewManager()->agendaView()->updateConfig(); |
1891 | } | 1890 | } |
1892 | 1891 | ||
1893 | void MainWindow::saveCalendar() | 1892 | void MainWindow::saveCalendar() |
1894 | { | 1893 | { |
1895 | QString fn = KOPrefs::instance()->mLastSaveFile; | 1894 | QString fn = KOPrefs::instance()->mLastSaveFile; |
1896 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); | 1895 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); |
1897 | 1896 | ||
1898 | if ( fn == "" ) | 1897 | if ( fn == "" ) |
1899 | return; | 1898 | return; |
1900 | QFileInfo info; | 1899 | QFileInfo info; |
1901 | info.setFile( fn ); | 1900 | info.setFile( fn ); |
1902 | QString mes; | 1901 | QString mes; |
1903 | bool createbup = true; | 1902 | bool createbup = true; |
1904 | if ( info. exists() ) { | 1903 | if ( info. exists() ) { |
1905 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; | 1904 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; |
1906 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 1905 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
1907 | i18n("Overwrite!"), i18n("Cancel"), 0, | 1906 | i18n("Overwrite!"), i18n("Cancel"), 0, |
1908 | 0, 1 ); | 1907 | 0, 1 ); |
1909 | if ( result != 0 ) { | 1908 | if ( result != 0 ) { |
1910 | createbup = false; | 1909 | createbup = false; |
1911 | } | 1910 | } |
1912 | } | 1911 | } |
1913 | if ( createbup ) { | 1912 | if ( createbup ) { |
1914 | mView->saveCalendar( fn ); | 1913 | mView->saveCalendar( fn ); |
1915 | mes = i18n("KO/Pi:Saved %1").arg(fn); | 1914 | mes = i18n("KO/Pi:Saved %1").arg(fn); |
1916 | KOPrefs::instance()->mLastSaveFile = fn; | 1915 | KOPrefs::instance()->mLastSaveFile = fn; |
1917 | setCaption(mes); | 1916 | setCaption(mes); |
1918 | } | 1917 | } |
1919 | } | 1918 | } |
1920 | void MainWindow::loadCalendar() | 1919 | void MainWindow::loadCalendar() |
1921 | { | 1920 | { |
1922 | 1921 | ||
1923 | QString fn = KOPrefs::instance()->mLastLoadFile; | 1922 | QString fn = KOPrefs::instance()->mLastLoadFile; |
1924 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); | 1923 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); |
1925 | 1924 | ||
1926 | if ( fn == "" ) | 1925 | if ( fn == "" ) |
1927 | return; | 1926 | return; |
1928 | QFileInfo info; | 1927 | QFileInfo info; |
1929 | info.setFile( fn ); | 1928 | info.setFile( fn ); |
1930 | QString mess; | 1929 | QString mess; |
1931 | bool loadbup = true; | 1930 | bool loadbup = true; |
1932 | if ( info. exists() ) { | 1931 | if ( info. exists() ) { |
1933 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 1932 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
1934 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", | 1933 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", |
1935 | mess, | 1934 | mess, |
1936 | i18n("Load!"), i18n("Cancel"), 0, | 1935 | i18n("Load!"), i18n("Cancel"), 0, |
1937 | 0, 1 ); | 1936 | 0, 1 ); |
1938 | if ( result != 0 ) { | 1937 | if ( result != 0 ) { |
1939 | loadbup = false; | 1938 | loadbup = false; |
1940 | } | 1939 | } |
1941 | } else { | 1940 | } else { |
1942 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1941 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1943 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, | 1942 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, |
1944 | 0, 1 ); | 1943 | 0, 1 ); |
1945 | 1944 | ||
1946 | return; | 1945 | return; |
1947 | } | 1946 | } |
1948 | if ( loadbup ) { | 1947 | if ( loadbup ) { |
1949 | mView->openCalendar( fn ); | 1948 | mView->openCalendar( fn ); |
1950 | KOPrefs::instance()->mLastLoadFile = fn; | 1949 | KOPrefs::instance()->mLastLoadFile = fn; |
1951 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; | 1950 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; |
1952 | setCaption(mess); | 1951 | setCaption(mess); |
1953 | } | 1952 | } |
1954 | 1953 | ||
1955 | } | 1954 | } |
1956 | void MainWindow::quickImportIcal() | 1955 | void MainWindow::quickImportIcal() |
1957 | { | 1956 | { |
1958 | importFile( KOPrefs::instance()->mLastImportFile, false ); | 1957 | importFile( KOPrefs::instance()->mLastImportFile, false ); |
1959 | } | 1958 | } |
1960 | void MainWindow::importFile( QString fn, bool quick ) | 1959 | void MainWindow::importFile( QString fn, bool quick ) |
1961 | { | 1960 | { |
1962 | QFileInfo info; | 1961 | QFileInfo info; |
1963 | info.setFile( fn ); | 1962 | info.setFile( fn ); |
1964 | QString mess; | 1963 | QString mess; |
1965 | bool loadbup = true; | 1964 | bool loadbup = true; |
1966 | if ( !info. exists() ) { | 1965 | if ( !info. exists() ) { |
1967 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); | 1966 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); |
1968 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1967 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1969 | mess ); | 1968 | mess ); |
1970 | return; | 1969 | return; |
1971 | } | 1970 | } |
1972 | int result = 0; | 1971 | int result = 0; |
1973 | if ( !quick ) { | 1972 | if ( !quick ) { |
1974 | 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 )); | 1973 | 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 )); |
1975 | result = QMessageBox::warning( this, "KO/Pi: Warning!", | 1974 | result = QMessageBox::warning( this, "KO/Pi: Warning!", |
1976 | mess, | 1975 | mess, |
1977 | "Import", "Cancel", 0, | 1976 | "Import", "Cancel", 0, |
1978 | 0, 1 ); | 1977 | 0, 1 ); |
1979 | } | 1978 | } |
1980 | if ( result == 0 ) { | 1979 | if ( result == 0 ) { |
1981 | if ( mView->openCalendar( fn, true )) { | 1980 | if ( mView->openCalendar( fn, true )) { |
1982 | KOPrefs::instance()->mLastImportFile = fn; | 1981 | KOPrefs::instance()->mLastImportFile = fn; |
1983 | setCaption(i18n("Imported file successfully")); | 1982 | setCaption(i18n("Imported file successfully")); |
1984 | } else { | 1983 | } else { |
1985 | setCaption(i18n("Error importing file")); | 1984 | setCaption(i18n("Error importing file")); |
1986 | } | 1985 | } |
1987 | } | 1986 | } |
1988 | } | 1987 | } |
1989 | 1988 | ||
1990 | void MainWindow::importIcal() | 1989 | void MainWindow::importIcal() |
1991 | { | 1990 | { |
1992 | 1991 | ||
1993 | QString fn =KOPrefs::instance()->mLastImportFile; | 1992 | QString fn =KOPrefs::instance()->mLastImportFile; |
1994 | 1993 | ||
1995 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); | 1994 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); |
1996 | if ( fn == "" ) | 1995 | if ( fn == "" ) |
1997 | return; | 1996 | return; |
1998 | importFile( fn, true ); | 1997 | importFile( fn, true ); |
1999 | 1998 | ||
2000 | } | 1999 | } |
2001 | 2000 | ||
2002 | void MainWindow::exportVCalendar() | 2001 | void MainWindow::exportVCalendar() |
2003 | { | 2002 | { |
2004 | QString fn = KOPrefs::instance()->mLastVcalFile; | 2003 | QString fn = KOPrefs::instance()->mLastVcalFile; |
2005 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); | 2004 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); |
2006 | if ( fn == "" ) | 2005 | if ( fn == "" ) |
2007 | return; | 2006 | return; |
2008 | QFileInfo info; | 2007 | QFileInfo info; |
2009 | info.setFile( fn ); | 2008 | info.setFile( fn ); |
2010 | QString mes; | 2009 | QString mes; |
2011 | bool createbup = true; | 2010 | bool createbup = true; |
2012 | if ( info. exists() ) { | 2011 | if ( info. exists() ) { |
2013 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 2012 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
2014 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 2013 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
2015 | i18n("Overwrite!"), i18n("Cancel"), 0, | 2014 | i18n("Overwrite!"), i18n("Cancel"), 0, |
2016 | 0, 1 ); | 2015 | 0, 1 ); |
2017 | if ( result != 0 ) { | 2016 | if ( result != 0 ) { |
2018 | createbup = false; | 2017 | createbup = false; |
2019 | } | 2018 | } |
2020 | } | 2019 | } |
2021 | if ( createbup ) { | 2020 | if ( createbup ) { |
2022 | if ( mView->exportVCalendar( fn ) ) { | 2021 | if ( mView->exportVCalendar( fn ) ) { |
2023 | KOPrefs::instance()->mLastVcalFile = fn; | 2022 | KOPrefs::instance()->mLastVcalFile = fn; |
2024 | if ( fn.length() > 20 ) | 2023 | if ( fn.length() > 20 ) |
2025 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; | 2024 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; |
2026 | else | 2025 | else |
2027 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); | 2026 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); |
2028 | setCaption(mes); | 2027 | setCaption(mes); |
2029 | } | 2028 | } |
2030 | } | 2029 | } |
2031 | 2030 | ||
2032 | } | 2031 | } |
2033 | QString MainWindow::getPassword( ) | 2032 | QString MainWindow::getPassword( ) |
2034 | { | 2033 | { |
2035 | QString retfile = ""; | 2034 | QString retfile = ""; |
2036 | QDialog dia ( this, "input-dialog", true ); | 2035 | QDialog dia ( this, "input-dialog", true ); |
2037 | QLineEdit lab ( &dia ); | 2036 | QLineEdit lab ( &dia ); |
2038 | lab.setEchoMode( QLineEdit::Password ); | 2037 | lab.setEchoMode( QLineEdit::Password ); |
2039 | QVBoxLayout lay( &dia ); | 2038 | QVBoxLayout lay( &dia ); |
2040 | lay.setMargin(7); | 2039 | lay.setMargin(7); |
2041 | lay.setSpacing(7); | 2040 | lay.setSpacing(7); |
2042 | lay.addWidget( &lab); | 2041 | lay.addWidget( &lab); |
2043 | dia.setFixedSize( 230,50 ); | 2042 | dia.setFixedSize( 230,50 ); |
2044 | dia.setCaption( i18n("Enter password") ); | 2043 | dia.setCaption( i18n("Enter password") ); |
2045 | QPushButton pb ( "OK", &dia); | 2044 | QPushButton pb ( "OK", &dia); |
2046 | lay.addWidget( &pb ); | 2045 | lay.addWidget( &pb ); |
2047 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 2046 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
2048 | dia.show(); | 2047 | dia.show(); |
2049 | int res = dia.exec(); | 2048 | int res = dia.exec(); |
2050 | if ( res ) | 2049 | if ( res ) |
2051 | retfile = lab.text(); | 2050 | retfile = lab.text(); |
2052 | dia.hide(); | 2051 | dia.hide(); |
2053 | qApp->processEvents(); | 2052 | qApp->processEvents(); |
2054 | return retfile; | 2053 | return retfile; |
2055 | 2054 | ||
2056 | } | 2055 | } |
2057 | 2056 | ||
2058 | void MainWindow::enableQuick() | 2057 | void MainWindow::enableQuick() |
2059 | { | 2058 | { |
2060 | QDialog dia ( this, "input-dialog", true ); | 2059 | QDialog dia ( this, "input-dialog", true ); |
2061 | QLineEdit lab ( &dia ); | 2060 | QLineEdit lab ( &dia ); |
2062 | QVBoxLayout lay( &dia ); | 2061 | QVBoxLayout lay( &dia ); |
2063 | lab.setText( KOPrefs::instance()->mPassiveSyncPort ); | 2062 | lab.setText( KOPrefs::instance()->mPassiveSyncPort ); |
2064 | lay.setMargin(7); | 2063 | lay.setMargin(7); |
2065 | lay.setSpacing(7); | 2064 | lay.setSpacing(7); |
2066 | QLabel label ( i18n("Port number (Default: 9197)"), &dia ); | 2065 | QLabel label ( i18n("Port number (Default: 9197)"), &dia ); |
2067 | lay.addWidget( &label); | 2066 | lay.addWidget( &label); |
2068 | lay.addWidget( &lab); | 2067 | lay.addWidget( &lab); |
2069 | 2068 | ||
2070 | QLineEdit lepw ( &dia ); | 2069 | QLineEdit lepw ( &dia ); |
2071 | lepw.setText( KOPrefs::instance()->mPassiveSyncPw ); | 2070 | lepw.setText( KOPrefs::instance()->mPassiveSyncPw ); |
2072 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); | 2071 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); |
2073 | lay.addWidget( &label2); | 2072 | lay.addWidget( &label2); |
2074 | lay.addWidget( &lepw); | 2073 | lay.addWidget( &lepw); |
2075 | dia.setFixedSize( 230,80 ); | 2074 | dia.setFixedSize( 230,80 ); |
2076 | dia.setCaption( i18n("Enter port for Pi-Sync") ); | 2075 | dia.setCaption( i18n("Enter port for Pi-Sync") ); |
2077 | QPushButton pb ( "OK", &dia); | 2076 | QPushButton pb ( "OK", &dia); |
2078 | lay.addWidget( &pb ); | 2077 | lay.addWidget( &pb ); |
2079 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 2078 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
2080 | dia.show(); | 2079 | dia.show(); |
2081 | if ( ! dia.exec() ) | 2080 | if ( ! dia.exec() ) |
2082 | return; | 2081 | return; |
2083 | dia.hide(); | 2082 | dia.hide(); |
2084 | qApp->processEvents(); | 2083 | qApp->processEvents(); |
2085 | KOPrefs::instance()->mPassiveSyncPw = lepw.text(); | 2084 | KOPrefs::instance()->mPassiveSyncPw = lepw.text(); |
2086 | KOPrefs::instance()->mPassiveSyncPort = lab.text(); | 2085 | KOPrefs::instance()->mPassiveSyncPort = lab.text(); |
2087 | bool ok; | 2086 | bool ok; |
2088 | Q_UINT16 port = KOPrefs::instance()->mPassiveSyncPort.toUInt(&ok); | 2087 | Q_UINT16 port = KOPrefs::instance()->mPassiveSyncPort.toUInt(&ok); |
2089 | if ( ! ok ) { | 2088 | if ( ! ok ) { |
2090 | KMessageBox::information( this, i18n("No valid port")); | 2089 | KMessageBox::information( this, i18n("No valid port")); |
2091 | return; | 2090 | return; |
2092 | } | 2091 | } |
2093 | //qDebug("port %d ", port); | 2092 | //qDebug("port %d ", port); |
2094 | mServerSocket = new KServerSocket ( KOPrefs::instance()->mPassiveSyncPw, port ,1 ); | 2093 | mServerSocket = new KServerSocket ( KOPrefs::instance()->mPassiveSyncPw, port ,1 ); |
2095 | mServerSocket->setFileName( defaultFileName() ); | 2094 | mServerSocket->setFileName( defaultFileName() ); |
2096 | //qDebug("connected "); | 2095 | //qDebug("connected "); |
2097 | if ( !mServerSocket->ok() ) { | 2096 | if ( !mServerSocket->ok() ) { |
2098 | KMessageBox::information( this, i18n("Failed to bind or\nlisten to the port!")); | 2097 | KMessageBox::information( this, i18n("Failed to bind or\nlisten to the port!")); |
2099 | delete mServerSocket; | 2098 | delete mServerSocket; |
2100 | mServerSocket = 0; | 2099 | mServerSocket = 0; |
2101 | return; | 2100 | return; |
2102 | } | 2101 | } |
2103 | connect( mServerSocket, SIGNAL ( saveFile() ), this, SLOT ( save() ) ); | 2102 | connect( mServerSocket, SIGNAL ( saveFile() ), this, SLOT ( save() ) ); |
2104 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SLOT ( getFile( bool ) ) ); | 2103 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SLOT ( getFile( bool ) ) ); |
2105 | } | 2104 | } |
2106 | 2105 | ||
2107 | void MainWindow::getFile( bool success ) | 2106 | void MainWindow::getFile( bool success ) |
2108 | { | 2107 | { |
2109 | if ( ! success ) { | 2108 | if ( ! success ) { |
2110 | setCaption( i18n("Error receiving file. Nothing changed!") ); | 2109 | setCaption( i18n("Error receiving file. Nothing changed!") ); |
2111 | return; | 2110 | return; |
2112 | } | 2111 | } |
2113 | mView->watchSavedFile(); | 2112 | mView->watchSavedFile(); |
2114 | mView->openCalendar( defaultFileName() ); | 2113 | mView->openCalendar( defaultFileName() ); |
2115 | setCaption( i18n("Pi-Sync successful!") ); | 2114 | setCaption( i18n("Pi-Sync successful!") ); |
2116 | 2115 | ||
2117 | } | 2116 | } |
2118 | 2117 | ||
2119 | 2118 | ||
2120 | void MainWindow::syncPi() | 2119 | void MainWindow::syncPi() |
2121 | { | 2120 | { |
2122 | qApp->processEvents(); | 2121 | qApp->processEvents(); |
2123 | bool ok; | 2122 | bool ok; |
2124 | Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok); | 2123 | Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok); |
2125 | if ( ! ok ) { | 2124 | if ( ! ok ) { |
2126 | setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); | 2125 | setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); |
2127 | return; | 2126 | return; |
2128 | } | 2127 | } |
2129 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, KOPrefs::instance()->mActiveSyncIP, this ); | 2128 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, KOPrefs::instance()->mActiveSyncIP, this ); |
2130 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); | 2129 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); |
2131 | setCaption( i18n("Sending request for remote file ...") ); | 2130 | setCaption( i18n("Sending request for remote file ...") ); |
2132 | commandSocket->readFile( syncFileName() ); | 2131 | commandSocket->readFile( syncFileName() ); |
2133 | } | 2132 | } |
2134 | 2133 | ||
2135 | void MainWindow::deleteCommandSocket(KCommandSocket*s, int state) | 2134 | void MainWindow::deleteCommandSocket(KCommandSocket*s, int state) |
2136 | { | 2135 | { |
2137 | qDebug("MainWindow::deleteCommandSocket %d", state); | 2136 | qDebug("MainWindow::deleteCommandSocket %d", state); |
2138 | 2137 | ||
2139 | //enum { success, errorW, errorR, quiet }; | 2138 | //enum { success, errorW, errorR, quiet }; |
2140 | if ( state == KCommandSocket::errorR ) { | 2139 | if ( state == KCommandSocket::errorR ) { |
2141 | setCaption( i18n("ERROR: Receiving remote file failed.") ); | 2140 | setCaption( i18n("ERROR: Receiving remote file failed.") ); |
2142 | delete s; | 2141 | delete s; |
2143 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this ); | 2142 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this ); |
2144 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 2143 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
2145 | commandSocket->sendStop(); | 2144 | commandSocket->sendStop(); |
2146 | return; | 2145 | return; |
2147 | 2146 | ||
2148 | } else if ( state == KCommandSocket::errorW ) { | 2147 | } else if ( state == KCommandSocket::errorW ) { |
2149 | setCaption( i18n("ERROR:Writing back file failed.") ); | 2148 | setCaption( i18n("ERROR:Writing back file failed.") ); |
2150 | 2149 | ||
2151 | } else if ( state == KCommandSocket::successR ) { | 2150 | } else if ( state == KCommandSocket::successR ) { |
2152 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); | 2151 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); |
2153 | 2152 | ||
2154 | } else if ( state == KCommandSocket::successW ) { | 2153 | } else if ( state == KCommandSocket::successW ) { |
2155 | setCaption( i18n("Pi-Sync succesful!") ); | 2154 | setCaption( i18n("Pi-Sync succesful!") ); |
2156 | } | 2155 | } |
2157 | 2156 | ||
2158 | delete s; | 2157 | delete s; |
2159 | } | 2158 | } |
2160 | 2159 | ||
2161 | void MainWindow::readFileFromSocket() | 2160 | void MainWindow::readFileFromSocket() |
2162 | { | 2161 | { |
2163 | QString fileName = syncFileName(); | 2162 | QString fileName = syncFileName(); |
2164 | setCaption( i18n("Remote file saved to temp file.") ); | 2163 | setCaption( i18n("Remote file saved to temp file.") ); |
2165 | if ( ! syncWithFile( fileName , true ) ) { | 2164 | if ( ! syncWithFile( fileName , true ) ) { |
2166 | setCaption( i18n("Syncing failed.") ); | 2165 | setCaption( i18n("Syncing failed.") ); |
2167 | qDebug("Syncing failed "); | 2166 | qDebug("Syncing failed "); |
2168 | return; | 2167 | return; |
2169 | } | 2168 | } |
2170 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this ); | 2169 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this ); |
2171 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 2170 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
2172 | if ( KOPrefs::instance()->mWriteBackFile ) | 2171 | if ( KOPrefs::instance()->mWriteBackFile ) |
2173 | commandSocket->writeFile( fileName ); | 2172 | commandSocket->writeFile( fileName ); |
2174 | else { | 2173 | else { |
2175 | commandSocket->sendStop(); | 2174 | commandSocket->sendStop(); |
2176 | setCaption( i18n("Pi-Sync succesful!") ); | 2175 | setCaption( i18n("Pi-Sync succesful!") ); |
2177 | } | 2176 | } |
2178 | } | 2177 | } |
2179 | 2178 | ||
2180 | void MainWindow::syncLocalFile() | 2179 | void MainWindow::syncLocalFile() |
2181 | { | 2180 | { |
2182 | 2181 | ||
2183 | QString fn =KOPrefs::instance()->mLastSyncedLocalFile; | 2182 | QString fn =KOPrefs::instance()->mLastSyncedLocalFile; |
2184 | 2183 | ||
2185 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); | 2184 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); |
2186 | if ( fn == "" ) | 2185 | if ( fn == "" ) |
2187 | return; | 2186 | return; |
2188 | //mView->setSyncDevice("local-file" ); | 2187 | //mView->setSyncDevice("local-file" ); |
2189 | if ( syncWithFile( fn, false ) ) { | 2188 | if ( syncWithFile( fn, false ) ) { |
2190 | // Event* e = mView->getLastSyncEvent(); | 2189 | // Event* e = mView->getLastSyncEvent(); |
2191 | // e->setReadOnly( false ); | 2190 | // e->setReadOnly( false ); |
2192 | // e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); | 2191 | // e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); |
2193 | // e->setReadOnly( true ); | 2192 | // e->setReadOnly( true ); |
2194 | } | 2193 | } |
2195 | 2194 | ||
2196 | } | 2195 | } |
2197 | 2196 | ||
2198 | bool MainWindow::syncWithFile( QString fn , bool quick ) | 2197 | bool MainWindow::syncWithFile( QString fn , bool quick ) |
2199 | { | 2198 | { |
2200 | bool ret = false; | 2199 | bool ret = false; |
2201 | QFileInfo info; | 2200 | QFileInfo info; |
2202 | info.setFile( fn ); | 2201 | info.setFile( fn ); |
2203 | QString mess; | 2202 | QString mess; |
2204 | bool loadbup = true; | 2203 | bool loadbup = true; |
2205 | if ( !info. exists() ) { | 2204 | if ( !info. exists() ) { |
2206 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 2205 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
2207 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2206 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2208 | mess ); | 2207 | mess ); |
2209 | return ret; | 2208 | return ret; |
2210 | } | 2209 | } |
2211 | int result = 0; | 2210 | int result = 0; |
2212 | if ( !quick ) { | 2211 | if ( !quick ) { |
2213 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 2212 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
2214 | result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2213 | result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2215 | mess, | 2214 | mess, |
2216 | i18n("Sync"), i18n("Cancel"), 0, | 2215 | i18n("Sync"), i18n("Cancel"), 0, |
2217 | 0, 1 ); | 2216 | 0, 1 ); |
2218 | if ( result ) | 2217 | if ( result ) |
2219 | return false; | 2218 | return false; |
2220 | } | 2219 | } |
2221 | if ( KOPrefs::instance()->mAskForPreferences ) | 2220 | if ( KOPrefs::instance()->mAskForPreferences ) |
2222 | mView->edit_sync_options(); | 2221 | mView->edit_sync_options(); |
2223 | if ( result == 0 ) { | 2222 | if ( result == 0 ) { |
2224 | //qDebug("Now sycing ... "); | 2223 | //qDebug("Now sycing ... "); |
2225 | if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) | 2224 | if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) |
2226 | setCaption( i18n("Synchronization successful") ); | 2225 | setCaption( i18n("Synchronization successful") ); |
2227 | else | 2226 | else |
2228 | setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); | 2227 | setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); |
2229 | if ( ! quick ) | 2228 | if ( ! quick ) |
2230 | KOPrefs::instance()->mLastSyncedLocalFile = fn; | 2229 | KOPrefs::instance()->mLastSyncedLocalFile = fn; |
2231 | slotModifiedChanged( true ); | 2230 | slotModifiedChanged( true ); |
2232 | } | 2231 | } |
2233 | return ret; | 2232 | return ret; |
2234 | } | 2233 | } |
2235 | void MainWindow::quickSyncLocalFile() | 2234 | void MainWindow::quickSyncLocalFile() |
2236 | { | 2235 | { |
2237 | //mView->setSyncDevice("local-file" ); | 2236 | //mView->setSyncDevice("local-file" ); |
2238 | //qDebug("quickSyncLocalFile() "); | 2237 | //qDebug("quickSyncLocalFile() "); |
2239 | if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) { | 2238 | if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) { |
2240 | // Event* e = mView->getLastSyncEvent(); | 2239 | // Event* e = mView->getLastSyncEvent(); |
2241 | // e->setReadOnly( false ); | 2240 | // e->setReadOnly( false ); |
2242 | // e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); | 2241 | // e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); |
2243 | // e->setReadOnly( true ); | 2242 | // e->setReadOnly( true ); |
2244 | 2243 | ||
2245 | } | 2244 | } |
2246 | } | 2245 | } |
2247 | 2246 | ||
2248 | void MainWindow::confSync() | 2247 | void MainWindow::confSync() |
2249 | { | 2248 | { |
2250 | mView->confSync(); | 2249 | mView->confSync(); |
2251 | fillSyncMenu(); | 2250 | fillSyncMenu(); |
2252 | } | 2251 | } |
2253 | void MainWindow::syncRemote( KSyncProfile* prof, bool ask) | 2252 | void MainWindow::syncRemote( KSyncProfile* prof, bool ask) |
2254 | { | 2253 | { |
2255 | QString question; | 2254 | QString question; |
2256 | if ( ask ) { | 2255 | if ( ask ) { |
2257 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; | 2256 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; |
2258 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | 2257 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), |
2259 | question, | 2258 | question, |
2260 | i18n("Yes"), i18n("No"), | 2259 | i18n("Yes"), i18n("No"), |
2261 | 0, 0 ) != 0 ) | 2260 | 0, 0 ) != 0 ) |
2262 | return; | 2261 | return; |
2263 | } | 2262 | } |
2264 | QString command = prof->getPreSyncCommand(); | 2263 | QString command = prof->getPreSyncCommand(); |
2265 | int fi; | 2264 | int fi; |
2266 | if ( (fi = command.find("$PWD$")) > 0 ) { | 2265 | if ( (fi = command.find("$PWD$")) > 0 ) { |
2267 | QString pwd = getPassword(); | 2266 | QString pwd = getPassword(); |
2268 | command = command.left( fi )+ pwd + command.mid( fi+5 ); | 2267 | command = command.left( fi )+ pwd + command.mid( fi+5 ); |
2269 | 2268 | ||
2270 | } | 2269 | } |
2271 | int maxlen = 30; | 2270 | int maxlen = 30; |
2272 | if ( QApplication::desktop()->width() > 320 ) | 2271 | if ( QApplication::desktop()->width() > 320 ) |
2273 | maxlen += 25; | 2272 | maxlen += 25; |
2274 | setCaption ( i18n( "Copy remote file to local machine..." ) ); | 2273 | setCaption ( i18n( "Copy remote file to local machine..." ) ); |
2275 | int fileSize = 0; | 2274 | int fileSize = 0; |
2276 | int result = system ( command ); | 2275 | int result = system ( command ); |
2277 | // 0 : okay | 2276 | // 0 : okay |
2278 | // 256: no such file or dir | 2277 | // 256: no such file or dir |
2279 | // | 2278 | // |
2280 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); | 2279 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); |
2281 | if ( result != 0 ) { | 2280 | if ( result != 0 ) { |
2282 | int len = maxlen; | 2281 | int len = maxlen; |
2283 | while ( len < command.length() ) { | 2282 | while ( len < command.length() ) { |
2284 | command.insert( len , "\n" ); | 2283 | command.insert( len , "\n" ); |
2285 | len += maxlen +2; | 2284 | len += maxlen +2; |
2286 | } | 2285 | } |
2287 | 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) ; | 2286 | 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) ; |
2288 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), | 2287 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), |
2289 | question, | 2288 | question, |
2290 | i18n("Okay!")) ; | 2289 | i18n("Okay!")) ; |
2291 | setCaption ("KO/Pi"); | 2290 | setCaption ("KO/Pi"); |
2292 | return; | 2291 | return; |
2293 | } | 2292 | } |
2294 | setCaption ( i18n( "Copying succeed." ) ); | 2293 | setCaption ( i18n( "Copying succeed." ) ); |
2295 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); | 2294 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); |
2296 | if ( syncWithFile( prof->getLocalTempFile(), true ) ) { | 2295 | if ( syncWithFile( prof->getLocalTempFile(), true ) ) { |
2297 | // Event* e = mView->getLastSyncEvent(); | 2296 | // Event* e = mView->getLastSyncEvent(); |
2298 | // e->setReadOnly( false ); | 2297 | // e->setReadOnly( false ); |
2299 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 2298 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
2300 | // e->setReadOnly( true ); | 2299 | // e->setReadOnly( true ); |
2301 | if ( KOPrefs::instance()->mWriteBackFile ) { | 2300 | if ( KOPrefs::instance()->mWriteBackFile ) { |
2302 | command = prof->getPostSyncCommand(); | 2301 | command = prof->getPostSyncCommand(); |
2303 | int fi; | 2302 | int fi; |
2304 | if ( (fi = command.find("$PWD$")) > 0 ) { | 2303 | if ( (fi = command.find("$PWD$")) > 0 ) { |
2305 | QString pwd = getPassword(); | 2304 | QString pwd = getPassword(); |
2306 | command = command.left( fi )+ pwd + command.mid( fi+5 ); | 2305 | command = command.left( fi )+ pwd + command.mid( fi+5 ); |
2307 | 2306 | ||
2308 | } | 2307 | } |
2309 | setCaption ( i18n( "Writing back file ..." ) ); | 2308 | setCaption ( i18n( "Writing back file ..." ) ); |
2310 | result = system ( command ); | 2309 | result = system ( command ); |
2311 | qDebug("KO: Writing back file result: %d ", result); | 2310 | qDebug("KO: Writing back file result: %d ", result); |
2312 | if ( result != 0 ) { | 2311 | if ( result != 0 ) { |
2313 | setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); | 2312 | setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); |
2314 | return; | 2313 | return; |
2315 | } else { | 2314 | } else { |
2316 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); | 2315 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); |
2317 | } | 2316 | } |
2318 | } | 2317 | } |
2319 | } | 2318 | } |
2320 | return; | 2319 | return; |
2321 | } | 2320 | } |
2322 | 2321 | ||
2323 | void MainWindow::syncSharp() | 2322 | void MainWindow::syncSharp() |
2324 | { | 2323 | { |
2325 | if ( mCalendarModifiedFlag ) | 2324 | if ( mCalendarModifiedFlag ) |
2326 | save(); | 2325 | save(); |
2327 | mView->syncSharp(); | 2326 | mView->syncSharp(); |
2328 | slotModifiedChanged( true ); | 2327 | slotModifiedChanged( true ); |
2329 | 2328 | ||
2330 | } | 2329 | } |
2331 | void MainWindow::syncPhone() | 2330 | void MainWindow::syncPhone() |
2332 | { | 2331 | { |
2333 | if ( mCalendarModifiedFlag ) | 2332 | if ( mCalendarModifiedFlag ) |
2334 | save(); | 2333 | save(); |
2335 | mView->syncPhone(); | 2334 | mView->syncPhone(); |
2336 | slotModifiedChanged( true ); | 2335 | slotModifiedChanged( true ); |
2337 | 2336 | ||
2338 | } | 2337 | } |
2339 | 2338 | ||
2340 | void MainWindow::printSel( ) | 2339 | void MainWindow::printSel( ) |
2341 | { | 2340 | { |
2342 | mView->viewManager()->agendaView()->agenda()->printSelection(); | 2341 | mView->viewManager()->agendaView()->agenda()->printSelection(); |
2343 | } | 2342 | } |
2344 | 2343 | ||
2345 | void MainWindow::printCal() | 2344 | void MainWindow::printCal() |
2346 | { | 2345 | { |
2347 | mView->print();//mCp->showDialog(); | 2346 | mView->print();//mCp->showDialog(); |
2348 | } | 2347 | } |
2349 | 2348 | ||
2350 | |||
2351 | |||
2352 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) | ||
2353 | { | ||
2354 | mPassWord = pw; | ||
2355 | mSocket = 0; | ||
2356 | mSyncActionDialog = 0; | ||
2357 | blockRC = false; | ||
2358 | }; | ||
2359 | |||
2360 | void KServerSocket::newConnection ( int socket ) | ||
2361 | { | ||
2362 | // qDebug("KServerSocket:New connection %d ", socket); | ||
2363 | if ( mSocket ) { | ||
2364 | qDebug("KServerSocket::newConnection Socket deleted! "); | ||
2365 | delete mSocket; | ||
2366 | mSocket = 0; | ||
2367 | } | ||
2368 | mSocket = new QSocket( this ); | ||
2369 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); | ||
2370 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); | ||
2371 | mSocket->setSocket( socket ); | ||
2372 | } | ||
2373 | |||
2374 | void KServerSocket::discardClient() | ||
2375 | { | ||
2376 | //qDebug(" KServerSocket::discardClient()"); | ||
2377 | if ( mSocket ) { | ||
2378 | delete mSocket; | ||
2379 | mSocket = 0; | ||
2380 | } | ||
2381 | //emit endConnect(); | ||
2382 | } | ||
2383 | void KServerSocket::readClient() | ||
2384 | { | ||
2385 | if ( blockRC ) | ||
2386 | return; | ||
2387 | if ( mSocket == 0 ) { | ||
2388 | qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); | ||
2389 | return; | ||
2390 | } | ||
2391 | qDebug("KServerSocket readClient()"); | ||
2392 | if ( mSocket->canReadLine() ) { | ||
2393 | QString line = mSocket->readLine(); | ||
2394 | qDebug("KServerSocket readline: %s ", line.latin1()); | ||
2395 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); | ||
2396 | if ( tokens[0] == "GET" ) { | ||
2397 | if ( tokens[1] == mPassWord ) | ||
2398 | //emit sendFile( mSocket ); | ||
2399 | send_file(); | ||
2400 | else { | ||
2401 | KMessageBox::information( 0, i18n("ERROR:\nGot send file request\nwith invalid password")); | ||
2402 | qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); | ||
2403 | } | ||
2404 | } | ||
2405 | if ( tokens[0] == "PUT" ) { | ||
2406 | if ( tokens[1] == mPassWord ) { | ||
2407 | //emit getFile( mSocket ); | ||
2408 | blockRC = true; | ||
2409 | get_file(); | ||
2410 | } | ||
2411 | else { | ||
2412 | KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password")); | ||
2413 | qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); | ||
2414 | } | ||
2415 | } | ||
2416 | if ( tokens[0] == "STOP" ) { | ||
2417 | //emit endConnect(); | ||
2418 | end_connect(); | ||
2419 | } | ||
2420 | } | ||
2421 | } | ||
2422 | void KServerSocket::end_connect() | ||
2423 | { | ||
2424 | delete mSyncActionDialog; | ||
2425 | mSyncActionDialog = 0; | ||
2426 | } | ||
2427 | void KServerSocket::send_file() | ||
2428 | { | ||
2429 | //qDebug("MainWindow::sendFile(QSocket* s) "); | ||
2430 | if ( mSyncActionDialog ) | ||
2431 | delete mSyncActionDialog; | ||
2432 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); | ||
2433 | mSyncActionDialog->setCaption(i18n("Received sync request")); | ||
2434 | QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); | ||
2435 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); | ||
2436 | lay->addWidget( label); | ||
2437 | lay->setMargin(7); | ||
2438 | lay->setSpacing(7); | ||
2439 | mSyncActionDialog->setFixedSize( 230, 120); | ||
2440 | mSyncActionDialog->show(); | ||
2441 | qDebug("KSS::saving ... "); | ||
2442 | emit saveFile(); | ||
2443 | qApp->processEvents(); | ||
2444 | QString fileName = mFileName; | ||
2445 | QFile file( fileName ); | ||
2446 | if (!file.open( IO_ReadOnly ) ) { | ||
2447 | delete mSyncActionDialog; | ||
2448 | mSyncActionDialog = 0; | ||
2449 | qDebug("KSS::error open file "); | ||
2450 | mSocket->close(); | ||
2451 | if ( mSocket->state() == QSocket::Idle ) | ||
2452 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | ||
2453 | return ; | ||
2454 | |||
2455 | } | ||
2456 | mSyncActionDialog->setCaption( i18n("Sending file...") ); | ||
2457 | QTextStream ts( &file ); | ||
2458 | ts.setCodec( QTextCodec::codecForName("utf8") ); | ||
2459 | QTextStream os( mSocket ); | ||
2460 | os.setCodec( QTextCodec::codecForName("utf8") ); | ||
2461 | //os.setEncoding( QTextStream::UnicodeUTF8 ); | ||
2462 | while ( ! ts.atEnd() ) { | ||
2463 | os << ts.readLine() << "\n"; | ||
2464 | } | ||
2465 | //os << ts.read(); | ||
2466 | file.close(); | ||
2467 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); | ||
2468 | mSocket->close(); | ||
2469 | if ( mSocket->state() == QSocket::Idle ) | ||
2470 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | ||
2471 | } | ||
2472 | void KServerSocket::get_file() | ||
2473 | { | ||
2474 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); | ||
2475 | |||
2476 | piTime.start(); | ||
2477 | piFileString = ""; | ||
2478 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); | ||
2479 | } | ||
2480 | |||
2481 | |||
2482 | void KServerSocket::readBackFileFromSocket() | ||
2483 | { | ||
2484 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); | ||
2485 | while ( mSocket->canReadLine () ) { | ||
2486 | piTime.restart(); | ||
2487 | QString line = mSocket->readLine (); | ||
2488 | piFileString += line; | ||
2489 | //qDebug("readline: %s ", line.latin1()); | ||
2490 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); | ||
2491 | |||
2492 | } | ||
2493 | if ( piTime.elapsed () < 3000 ) { | ||
2494 | // wait for more | ||
2495 | //qDebug("waitformore "); | ||
2496 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); | ||
2497 | return; | ||
2498 | } | ||
2499 | QString fileName = mFileName; | ||
2500 | QFile file ( fileName ); | ||
2501 | if (!file.open( IO_WriteOnly ) ) { | ||
2502 | delete mSyncActionDialog; | ||
2503 | mSyncActionDialog = 0; | ||
2504 | qDebug("error open cal file "); | ||
2505 | piFileString = ""; | ||
2506 | emit file_received( false ); | ||
2507 | blockRC = false; | ||
2508 | return ; | ||
2509 | |||
2510 | } | ||
2511 | |||
2512 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | ||
2513 | QTextStream ts ( &file ); | ||
2514 | ts.setCodec( QTextCodec::codecForName("utf8") ); | ||
2515 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); | ||
2516 | ts << piFileString; | ||
2517 | mSocket->close(); | ||
2518 | if ( mSocket->state() == QSocket::Idle ) | ||
2519 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | ||
2520 | file.close(); | ||
2521 | delete mSyncActionDialog; | ||
2522 | mSyncActionDialog = 0; | ||
2523 | piFileString = ""; | ||
2524 | blockRC = false; | ||
2525 | emit file_received( true ); | ||
2526 | |||
2527 | } | ||
2528 | |||
2529 | KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) | ||
2530 | { | ||
2531 | mPassWord = password; | ||
2532 | mSocket = 0; | ||
2533 | mPort = port; | ||
2534 | mHost = host; | ||
2535 | |||
2536 | mRetVal = quiet; | ||
2537 | mTimerSocket = new QTimer ( this ); | ||
2538 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); | ||
2539 | } | ||
2540 | void KCommandSocket::readFile( QString fn ) | ||
2541 | { | ||
2542 | if ( !mSocket ) { | ||
2543 | mSocket = new QSocket( this ); | ||
2544 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); | ||
2545 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | ||
2546 | } | ||
2547 | mFileString = ""; | ||
2548 | mFileName = fn; | ||
2549 | mFirst = true; | ||
2550 | mSocket->connectToHost( mHost, mPort ); | ||
2551 | QTextStream os( mSocket ); | ||
2552 | os.setEncoding( QTextStream::UnicodeUTF8 ); | ||
2553 | os << "GET " << mPassWord << "\r\n"; | ||
2554 | mTimerSocket->start( 10000 ); | ||
2555 | } | ||
2556 | |||
2557 | void KCommandSocket::writeFile( QString fileName ) | ||
2558 | { | ||
2559 | if ( !mSocket ) { | ||
2560 | mSocket = new QSocket( this ); | ||
2561 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | ||
2562 | connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); | ||
2563 | } | ||
2564 | mFileName = fileName ; | ||
2565 | mSocket->connectToHost( mHost, mPort ); | ||
2566 | } | ||
2567 | void KCommandSocket::writeFileToSocket() | ||
2568 | { | ||
2569 | QFile file2( mFileName ); | ||
2570 | if (!file2.open( IO_ReadOnly ) ) { | ||
2571 | mRetVal= errorW; | ||
2572 | mSocket->close(); | ||
2573 | if ( mSocket->state() == QSocket::Idle ) | ||
2574 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | ||
2575 | return ; | ||
2576 | } | ||
2577 | QTextStream ts2( &file2 ); | ||
2578 | ts2.setCodec( QTextCodec::codecForName("utf8") ); | ||
2579 | QTextStream os2( mSocket ); | ||
2580 | os2.setCodec( QTextCodec::codecForName("utf8") ); | ||
2581 | os2 << "PUT " << mPassWord << "\r\n";; | ||
2582 | while ( ! ts2.atEnd() ) { | ||
2583 | os2 << ts2.readLine() << "\n"; | ||
2584 | } | ||
2585 | mRetVal= successW; | ||
2586 | file2.close(); | ||
2587 | mSocket->close(); | ||
2588 | if ( mSocket->state() == QSocket::Idle ) | ||
2589 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | ||
2590 | } | ||
2591 | void KCommandSocket::sendStop() | ||
2592 | { | ||
2593 | if ( !mSocket ) { | ||
2594 | mSocket = new QSocket( this ); | ||
2595 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | ||
2596 | } | ||
2597 | mSocket->connectToHost( mHost, mPort ); | ||
2598 | QTextStream os2( mSocket ); | ||
2599 | os2.setCodec( QTextCodec::codecForName("utf8") ); | ||
2600 | os2 << "STOP\r\n"; | ||
2601 | mSocket->close(); | ||
2602 | if ( mSocket->state() == QSocket::Idle ) | ||
2603 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | ||
2604 | } | ||
2605 | |||
2606 | void KCommandSocket::startReadFileFromSocket() | ||
2607 | { | ||
2608 | if ( ! mFirst ) | ||
2609 | return; | ||
2610 | mFirst = false; | ||
2611 | mTimerSocket->stop(); | ||
2612 | mFileString = ""; | ||
2613 | mTime.start(); | ||
2614 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); | ||
2615 | |||
2616 | } | ||
2617 | void KCommandSocket::readFileFromSocket() | ||
2618 | { | ||
2619 | //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); | ||
2620 | while ( mSocket->canReadLine () ) { | ||
2621 | mTime.restart(); | ||
2622 | QString line = mSocket->readLine (); | ||
2623 | mFileString += line; | ||
2624 | //qDebug("readline: %s ", line.latin1()); | ||
2625 | } | ||
2626 | if ( mTime.elapsed () < 3000 ) { | ||
2627 | // wait for more | ||
2628 | //qDebug("waitformore "); | ||
2629 | QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); | ||
2630 | return; | ||
2631 | } | ||
2632 | QString fileName = mFileName; | ||
2633 | QFile file ( fileName ); | ||
2634 | if (!file.open( IO_WriteOnly ) ) { | ||
2635 | mFileString = ""; | ||
2636 | mRetVal = errorR; | ||
2637 | qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); | ||
2638 | deleteSocket(); | ||
2639 | return ; | ||
2640 | |||
2641 | } | ||
2642 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | ||
2643 | QTextStream ts ( &file ); | ||
2644 | ts.setCodec( QTextCodec::codecForName("utf8") ); | ||
2645 | ts << mFileString; | ||
2646 | file.close(); | ||
2647 | mFileString = ""; | ||
2648 | mRetVal = successR; | ||
2649 | mSocket->close(); | ||
2650 | // if state is not idle, deleteSocket(); is called via | ||
2651 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | ||
2652 | if ( mSocket->state() == QSocket::Idle ) | ||
2653 | deleteSocket(); | ||
2654 | } | ||
2655 | |||
2656 | void KCommandSocket::deleteSocket() | ||
2657 | { | ||
2658 | if ( mTimerSocket->isActive () ) { | ||
2659 | mTimerSocket->stop(); | ||
2660 | KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? ")); | ||
2661 | mRetVal = errorR; | ||
2662 | } | ||
2663 | //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); | ||
2664 | if ( mSocket) | ||
2665 | delete mSocket; | ||
2666 | mSocket = 0; | ||
2667 | emit commandFinished( this, mRetVal ); | ||
2668 | } | ||
2669 | |||
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index 4f89e03..0da0be0 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h | |||
@@ -1,216 +1,148 @@ | |||
1 | #ifndef KORGE_MAINWINDOW_H | 1 | #ifndef KORGE_MAINWINDOW_H |
2 | #define KORGE_MAINWINDOW_H | 2 | #define KORGE_MAINWINDOW_H |
3 | 3 | ||
4 | #include <qmainwindow.h> | 4 | #include <qmainwindow.h> |
5 | #include <qtimer.h> | 5 | #include <qtimer.h> |
6 | #include <qdict.h> | 6 | #include <qdict.h> |
7 | #include <qfile.h> | 7 | #include <qfile.h> |
8 | #include <qsocket.h> | ||
9 | #include <qtextstream.h> | 8 | #include <qtextstream.h> |
10 | #include <qregexp.h> | 9 | #include <qregexp.h> |
11 | 10 | ||
12 | #include <libkcal/incidence.h> | 11 | #include <libkcal/incidence.h> |
13 | #include "simplealarmclient.h" | 12 | #include "simplealarmclient.h" |
13 | #include <ksyncmanager.h> | ||
14 | 14 | ||
15 | class QAction; | 15 | class QAction; |
16 | class CalendarView; | 16 | class CalendarView; |
17 | class KSyncProfile; | 17 | class KSyncProfile; |
18 | #ifdef DESKTOP_VERSION | 18 | #ifdef DESKTOP_VERSION |
19 | 19 | ||
20 | #define QPEToolBar QToolBar | 20 | #define QPEToolBar QToolBar |
21 | #define QPEMenuBar QMenuBar | 21 | #define QPEMenuBar QMenuBar |
22 | #endif | 22 | #endif |
23 | class QPEToolBar; | 23 | class QPEToolBar; |
24 | #include <qserversocket.h> | ||
25 | #include <qsocket.h> | ||
26 | #include <qnetworkprotocol.h> | ||
27 | 24 | ||
28 | class KServerSocket : public QServerSocket | ||
29 | { | ||
30 | Q_OBJECT | ||
31 | |||
32 | public: | ||
33 | KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); | ||
34 | |||
35 | void newConnection ( int socket ) ; | ||
36 | void setFileName( QString fn ) {mFileName = fn;}; | ||
37 | |||
38 | signals: | ||
39 | //void sendFile(QSocket*); | ||
40 | //void getFile(QSocket*); | ||
41 | void file_received( bool ); | ||
42 | //void file_sent(); | ||
43 | void saveFile(); | ||
44 | void endConnect(); | ||
45 | private slots: | ||
46 | void discardClient(); | ||
47 | void readClient(); | ||
48 | void readBackFileFromSocket(); | ||
49 | private : | ||
50 | bool blockRC; | ||
51 | void send_file(); | ||
52 | void get_file(); | ||
53 | void end_connect(); | ||
54 | QDialog* mSyncActionDialog; | ||
55 | QSocket* mSocket; | ||
56 | QString mPassWord; | ||
57 | QString mFileName; | ||
58 | QTime piTime; | ||
59 | QString piFileString; | ||
60 | }; | ||
61 | |||
62 | class KCommandSocket : public QObject | ||
63 | { | ||
64 | Q_OBJECT | ||
65 | public: | ||
66 | enum state { successR, errorR, successW, errorW, quiet }; | ||
67 | KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); | ||
68 | void readFile( QString ); | ||
69 | void writeFile( QString ); | ||
70 | void sendStop(); | ||
71 | |||
72 | |||
73 | signals: | ||
74 | void commandFinished( KCommandSocket*, int ); | ||
75 | private slots: | ||
76 | void startReadFileFromSocket(); | ||
77 | void readFileFromSocket(); | ||
78 | void deleteSocket(); | ||
79 | void writeFileToSocket(); | ||
80 | private : | ||
81 | QSocket* mSocket; | ||
82 | QString mPassWord; | ||
83 | Q_UINT16 mPort; | ||
84 | QString mHost; | ||
85 | QString mFileName; | ||
86 | QTimer* mTimerSocket; | ||
87 | int mRetVal; | ||
88 | QTime mTime; | ||
89 | QString mFileString; | ||
90 | bool mFirst; | ||
91 | }; | ||
92 | 25 | ||
93 | namespace KCal { | 26 | namespace KCal { |
94 | class CalendarLocal; | 27 | class CalendarLocal; |
95 | } | 28 | } |
96 | 29 | ||
97 | using namespace KCal; | 30 | using namespace KCal; |
98 | 31 | ||
99 | class MainWindow : public QMainWindow | 32 | class MainWindow : public QMainWindow |
100 | { | 33 | { |
101 | Q_OBJECT | 34 | Q_OBJECT |
102 | public: | 35 | public: |
103 | MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); | 36 | MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); |
104 | ~MainWindow(); | 37 | ~MainWindow(); |
105 | public slots: | 38 | public slots: |
106 | virtual void showMaximized (); | 39 | virtual void showMaximized (); |
107 | void configureAgenda( int ); | 40 | void configureAgenda( int ); |
108 | void recieve( const QCString& msg, const QByteArray& data ); | 41 | void recieve( const QCString& msg, const QByteArray& data ); |
109 | static QString defaultFileName(); | 42 | static QString defaultFileName(); |
110 | static QString syncFileName(); | 43 | static QString syncFileName(); |
111 | static QString resourcePath(); | 44 | static QString resourcePath(); |
112 | protected slots: | 45 | protected slots: |
113 | void setCaptionToDates(); | 46 | void setCaptionToDates(); |
114 | int ringSync(); | 47 | int ringSync(); |
115 | void multiSync( bool askforPrefs = false ); | 48 | void multiSync( bool askforPrefs = false ); |
116 | void about(); | 49 | void about(); |
117 | void licence(); | 50 | void licence(); |
118 | void faq(); | 51 | void faq(); |
119 | void usertrans(); | 52 | void usertrans(); |
120 | void features(); | 53 | void features(); |
121 | void synchowto(); | 54 | void synchowto(); |
122 | void whatsNew(); | 55 | void whatsNew(); |
123 | void keyBindings(); | 56 | void keyBindings(); |
124 | void aboutAutoSaving();; | 57 | void aboutAutoSaving();; |
125 | void aboutKnownBugs(); | 58 | void aboutKnownBugs(); |
126 | 59 | ||
127 | void processIncidenceSelection( Incidence * ); | 60 | void processIncidenceSelection( Incidence * ); |
128 | 61 | ||
129 | void importQtopia(); | 62 | void importQtopia(); |
130 | void importBday(); | 63 | void importBday(); |
131 | void importOL(); | 64 | void importOL(); |
132 | void importIcal(); | 65 | void importIcal(); |
133 | void importFile( QString, bool ); | 66 | void importFile( QString, bool ); |
134 | void quickImportIcal(); | 67 | void quickImportIcal(); |
135 | 68 | ||
136 | void slotModifiedChanged( bool ); | 69 | void slotModifiedChanged( bool ); |
137 | 70 | ||
138 | void save(); | 71 | void save(); |
139 | void configureToolBar( int ); | 72 | void configureToolBar( int ); |
140 | void printSel(); | 73 | void printSel(); |
141 | void printCal(); | 74 | void printCal(); |
142 | void saveCalendar(); | 75 | void saveCalendar(); |
143 | void loadCalendar(); | 76 | void loadCalendar(); |
144 | void exportVCalendar(); | 77 | void exportVCalendar(); |
145 | void fillFilterMenu(); | 78 | void fillFilterMenu(); |
146 | void selectFilter( int ); | 79 | void selectFilter( int ); |
147 | void exportToPhone( int ); | 80 | void exportToPhone( int ); |
148 | 81 | ||
149 | void slotSyncMenu( int ); | 82 | void slotSyncMenu( int ); |
150 | void confSync(); | 83 | void confSync(); |
151 | void syncSharp(); | 84 | void syncSharp(); |
152 | void syncPhone(); | 85 | void syncPhone(); |
153 | void syncPi(); | 86 | void syncPi(); |
154 | void syncLocalFile(); | 87 | void syncLocalFile(); |
155 | bool syncWithFile( QString, bool ); | 88 | bool syncWithFile( QString, bool ); |
156 | void quickSyncLocalFile(); | 89 | void quickSyncLocalFile(); |
157 | 90 | ||
158 | 91 | ||
159 | protected: | 92 | protected: |
160 | void displayText( QString, QString); | 93 | void displayText( QString, QString); |
161 | void displayFile( QString, QString); | 94 | void displayFile( QString, QString); |
162 | 95 | ||
163 | void enableIncidenceActions( bool ); | 96 | void enableIncidenceActions( bool ); |
164 | 97 | ||
165 | private slots: | 98 | private slots: |
166 | QSocket* piSocket; | 99 | QSocket* piSocket; |
167 | QString piFileString; | 100 | QString piFileString; |
168 | QTime piTime; | 101 | QTime piTime; |
169 | void deleteCommandSocket(KCommandSocket* s, int state ); | 102 | void deleteCommandSocket(KCommandSocket* s, int state ); |
170 | void fillSyncMenu(); | 103 | void fillSyncMenu(); |
171 | void getFile( bool ); | 104 | void getFile( bool ); |
172 | void readFileFromSocket(); | 105 | void readFileFromSocket(); |
173 | private: | 106 | private: |
174 | //QTimer* mTimerCommandSocket; | 107 | //QTimer* mTimerCommandSocket; |
175 | QString mPassWordPiSync; | 108 | QString mPassWordPiSync; |
176 | KServerSocket * mServerSocket; | 109 | KServerSocket * mServerSocket; |
177 | bool mClosed; | 110 | bool mClosed; |
178 | void saveOnClose(); | 111 | void saveOnClose(); |
179 | int mCurrentSyncProfile; | 112 | int mCurrentSyncProfile; |
180 | void enableQuick(); | 113 | void enableQuick(); |
181 | void syncRemote( KSyncProfile* , bool ask = true); | 114 | void syncRemote( KSyncProfile* , bool ask = true); |
182 | bool mFlagKeyPressed; | 115 | bool mFlagKeyPressed; |
183 | bool mBlockAtStartup; | 116 | bool mBlockAtStartup; |
184 | QPEToolBar *iconToolBar; | 117 | QPEToolBar *iconToolBar; |
185 | void initActions(); | 118 | void initActions(); |
186 | void setDefaultPreferences(); | 119 | void setDefaultPreferences(); |
187 | void keyPressEvent ( QKeyEvent * ) ; | 120 | void keyPressEvent ( QKeyEvent * ) ; |
188 | void keyReleaseEvent ( QKeyEvent * ) ; | 121 | void keyReleaseEvent ( QKeyEvent * ) ; |
189 | QPopupMenu *configureToolBarMenu; | 122 | QPopupMenu *configureToolBarMenu; |
190 | QPopupMenu *selectFilterMenu; | 123 | QPopupMenu *selectFilterMenu; |
191 | QPopupMenu *configureAgendaMenu, *syncMenu; | 124 | QPopupMenu *configureAgendaMenu, *syncMenu; |
192 | CalendarLocal *mCalendar; | 125 | CalendarLocal *mCalendar; |
193 | CalendarView *mView; | 126 | CalendarView *mView; |
194 | QString getPassword(); | 127 | QString getPassword(); |
195 | QAction *mNewSubTodoAction; | 128 | QAction *mNewSubTodoAction; |
196 | 129 | ||
197 | QAction *mShowAction; | 130 | QAction *mShowAction; |
198 | QAction *mEditAction; | 131 | QAction *mEditAction; |
199 | QAction *mDeleteAction; | 132 | QAction *mDeleteAction; |
200 | QAction *mCloneAction; | 133 | QAction *mCloneAction; |
201 | QAction *mMoveAction; | 134 | QAction *mMoveAction; |
202 | QAction *mBeamAction; | 135 | QAction *mBeamAction; |
203 | QAction *mCancelAction; | 136 | QAction *mCancelAction; |
204 | 137 | ||
205 | 138 | ||
206 | void closeEvent( QCloseEvent* ce ); | 139 | void closeEvent( QCloseEvent* ce ); |
207 | SimpleAlarmClient mAlarmClient; | 140 | SimpleAlarmClient mAlarmClient; |
208 | QTimer mSaveTimer; | 141 | QTimer mSaveTimer; |
209 | bool mBlockSaveFlag; | 142 | bool mBlockSaveFlag; |
210 | bool mCalendarModifiedFlag; | 143 | bool mCalendarModifiedFlag; |
211 | QPixmap loadPixmap( QString ); | 144 | QPixmap loadPixmap( QString ); |
212 | QDialog * mSyncActionDialog; | ||
213 | }; | 145 | }; |
214 | 146 | ||
215 | 147 | ||
216 | #endif | 148 | #endif |
diff --git a/libkdepim/kpimprefs.cpp b/libkdepim/kpimprefs.cpp index a9ea330..0a2f5f1 100644 --- a/libkdepim/kpimprefs.cpp +++ b/libkdepim/kpimprefs.cpp | |||
@@ -1,72 +1,75 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkdepim. | 2 | This file is part of libkdepim. |
3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2002 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 | /* | 24 | /* |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <kglobal.h> | 31 | #include <kglobal.h> |
32 | #include <kconfig.h> | 32 | #include <kconfig.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | #include <kdebug.h> | 34 | #include <kdebug.h> |
35 | 35 | ||
36 | #include "kpimprefs.h" | 36 | #include "kpimprefs.h" |
37 | 37 | ||
38 | KPimPrefs::KPimPrefs( const QString &name ) : | 38 | KPimPrefs::KPimPrefs( const QString &name ) : |
39 | KPrefs( name ) | 39 | KPrefs( name ) |
40 | { | 40 | { |
41 | config()->setGroup("General"); | ||
42 | addItemString("PassiveSyncPort",&mPassiveSyncPort,"9197" ); | ||
43 | addItemString("PassiveSyncPw",&mPassiveSyncPw,"abc" ); | ||
41 | } | 44 | } |
42 | 45 | ||
43 | KPimPrefs::~KPimPrefs() | 46 | KPimPrefs::~KPimPrefs() |
44 | { | 47 | { |
45 | } | 48 | } |
46 | 49 | ||
47 | void KPimPrefs::usrSetDefaults() | 50 | void KPimPrefs::usrSetDefaults() |
48 | { | 51 | { |
49 | setCategoryDefaults(); | 52 | setCategoryDefaults(); |
50 | } | 53 | } |
51 | 54 | ||
52 | void KPimPrefs::usrReadConfig() | 55 | void KPimPrefs::usrReadConfig() |
53 | { | 56 | { |
54 | kdDebug(5300) << "KPimPrefs::usrReadConfig()" << endl; | 57 | kdDebug(5300) << "KPimPrefs::usrReadConfig()" << endl; |
55 | 58 | ||
56 | config()->setGroup("General"); | 59 | config()->setGroup("General"); |
57 | mCustomCategories = config()->readListEntry("Custom Categories"); | 60 | mCustomCategories = config()->readListEntry("Custom Categories"); |
58 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); | 61 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); |
59 | } | 62 | } |
60 | 63 | ||
61 | 64 | ||
62 | void KPimPrefs::usrWriteConfig() | 65 | void KPimPrefs::usrWriteConfig() |
63 | { | 66 | { |
64 | config()->setGroup("General"); | 67 | config()->setGroup("General"); |
65 | config()->writeEntry("Custom Categories",mCustomCategories); | 68 | config()->writeEntry("Custom Categories",mCustomCategories); |
66 | } | 69 | } |
67 | 70 | ||
68 | void KPimPrefs::setCategoryDefaults() | 71 | void KPimPrefs::setCategoryDefaults() |
69 | { | 72 | { |
70 | // empty implementation | 73 | // empty implementation |
71 | } | 74 | } |
72 | 75 | ||
diff --git a/libkdepim/kpimprefs.h b/libkdepim/kpimprefs.h index 6f92919..fde8093 100644 --- a/libkdepim/kpimprefs.h +++ b/libkdepim/kpimprefs.h | |||
@@ -1,69 +1,70 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkdepim. | 2 | This file is part of libkdepim. |
3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2002 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 | /* | 24 | /* |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #ifndef KPIMPREFS_H | 31 | #ifndef KPIMPREFS_H |
32 | #define KPIMPREFS_H | 32 | #define KPIMPREFS_H |
33 | 33 | ||
34 | #include <qstringlist.h> | 34 | #include <qstringlist.h> |
35 | 35 | ||
36 | #include "kprefs.h" | 36 | #include "kprefs.h" |
37 | 37 | ||
38 | class KPimPrefs : public KPrefs | 38 | class KPimPrefs : public KPrefs |
39 | { | 39 | { |
40 | public: | 40 | public: |
41 | 41 | ||
42 | KPimPrefs( const QString &name = QString::null ); | 42 | KPimPrefs( const QString &name = QString::null ); |
43 | 43 | ||
44 | virtual ~KPimPrefs(); | 44 | virtual ~KPimPrefs(); |
45 | 45 | ||
46 | /** Set preferences to default values */ | 46 | /** Set preferences to default values */ |
47 | void usrSetDefaults(); | 47 | void usrSetDefaults(); |
48 | 48 | ||
49 | /** Read preferences from config file */ | 49 | /** Read preferences from config file */ |
50 | void usrReadConfig(); | 50 | void usrReadConfig(); |
51 | 51 | ||
52 | /** Write preferences to config file */ | 52 | /** Write preferences to config file */ |
53 | void usrWriteConfig(); | 53 | void usrWriteConfig(); |
54 | 54 | ||
55 | 55 | ||
56 | public: | 56 | public: |
57 | QStringList mCustomCategories; | 57 | QStringList mCustomCategories; |
58 | 58 | QString mPassiveSyncPort; | |
59 | QString mPassiveSyncPw; | ||
59 | 60 | ||
60 | 61 | ||
61 | 62 | ||
62 | protected: | 63 | protected: |
63 | virtual void setCategoryDefaults(); | 64 | virtual void setCategoryDefaults(); |
64 | 65 | ||
65 | 66 | ||
66 | 67 | ||
67 | }; | 68 | }; |
68 | 69 | ||
69 | #endif | 70 | #endif |
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index c0cc840..5d48884 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -1,663 +1,1158 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KDE-Pim/Pi. | 2 | This file is part of KDE-Pim/Pi. |
3 | Copyright (c) 2004 Ulf Schenk | 3 | Copyright (c) 2004 Ulf Schenk |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | // $Id$ | 21 | // $Id$ |
22 | 22 | ||
23 | #include "ksyncmanager.h" | 23 | #include "ksyncmanager.h" |
24 | 24 | ||
25 | #include <stdlib.h> | 25 | #include <stdlib.h> |
26 | 26 | ||
27 | #ifndef _WIN32_ | 27 | #ifndef _WIN32_ |
28 | #include <unistd.h> | 28 | #include <unistd.h> |
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | 31 | ||
32 | #include "ksyncprofile.h" | 32 | #include "ksyncprofile.h" |
33 | #include "ksyncprefsdialog.h" | 33 | #include "ksyncprefsdialog.h" |
34 | #include "kpimprefs.h" | 34 | #include "kpimprefs.h" |
35 | #include <kmessagebox.h> | ||
35 | 36 | ||
36 | #include <qdir.h> | 37 | #include <qdir.h> |
37 | #include <qprogressbar.h> | 38 | #include <qprogressbar.h> |
38 | #include <qpopupmenu.h> | 39 | #include <qpopupmenu.h> |
39 | #include <qpushbutton.h> | 40 | #include <qpushbutton.h> |
40 | #include <qradiobutton.h> | 41 | #include <qradiobutton.h> |
41 | #include <qbuttongroup.h> | 42 | #include <qbuttongroup.h> |
42 | #include <qtimer.h> | 43 | #include <qtimer.h> |
43 | #include <qmessagebox.h> | 44 | #include <qmessagebox.h> |
44 | #include <qapplication.h> | 45 | #include <qapplication.h> |
45 | #include <qlineedit.h> | 46 | #include <qlineedit.h> |
46 | #include <qdialog.h> | 47 | #include <qdialog.h> |
47 | #include <qlayout.h> | 48 | #include <qlayout.h> |
49 | #include <qtextcodec.h> | ||
50 | #include <qlabel.h> | ||
48 | 51 | ||
49 | #include <klocale.h> | 52 | #include <klocale.h> |
50 | #include <kglobal.h> | 53 | #include <kglobal.h> |
51 | #include <kconfig.h> | 54 | #include <kconfig.h> |
52 | #include <kfiledialog.h> | 55 | #include <kfiledialog.h> |
53 | 56 | ||
54 | KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) | 57 | KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) |
55 | : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu) | 58 | : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu) |
56 | { | 59 | { |
60 | mServerSocket = 0; | ||
57 | bar = new QProgressBar ( 1, 0 ); | 61 | bar = new QProgressBar ( 1, 0 ); |
58 | bar->setCaption (""); | 62 | bar->setCaption (""); |
59 | 63 | ||
60 | int w = 300; | 64 | int w = 300; |
61 | if ( QApplication::desktop()->width() < 320 ) | 65 | if ( QApplication::desktop()->width() < 320 ) |
62 | w = 220; | 66 | w = 220; |
63 | int h = bar->sizeHint().height() ; | 67 | int h = bar->sizeHint().height() ; |
64 | int dw = QApplication::desktop()->width(); | 68 | int dw = QApplication::desktop()->width(); |
65 | int dh = QApplication::desktop()->height(); | 69 | int dh = QApplication::desktop()->height(); |
66 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 70 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
67 | 71 | ||
68 | } | 72 | } |
69 | 73 | ||
70 | KSyncManager::~KSyncManager() | 74 | KSyncManager::~KSyncManager() |
71 | { | 75 | { |
72 | delete bar; | 76 | delete bar; |
73 | } | 77 | } |
74 | 78 | ||
75 | 79 | //LR ok | |
76 | void KSyncManager::fillSyncMenu() | 80 | void KSyncManager::fillSyncMenu() |
77 | { | 81 | { |
78 | if ( mSyncMenu->count() ) | 82 | if ( mSyncMenu->count() ) |
79 | mSyncMenu->clear(); | 83 | mSyncMenu->clear(); |
80 | 84 | ||
81 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); | 85 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); |
82 | mSyncMenu->insertSeparator(); | 86 | mSyncMenu->insertSeparator(); |
87 | if ( mServerSocket == 0 ) { | ||
88 | mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); | ||
89 | } else { | ||
90 | mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); | ||
91 | } | ||
92 | mSyncMenu->insertSeparator(); | ||
83 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); | 93 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); |
84 | mSyncMenu->insertSeparator(); | 94 | mSyncMenu->insertSeparator(); |
85 | 95 | ||
86 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 96 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
87 | config.setGroup("General"); | 97 | config.setGroup("General"); |
88 | QStringList prof = config.readListEntry("SyncProfileNames"); | 98 | QStringList prof = config.readListEntry("SyncProfileNames"); |
89 | mLocalMachineName = config.readEntry("LocalMachineName","undefined"); | 99 | mLocalMachineName = config.readEntry("LocalMachineName","undefined"); |
90 | if ( prof.count() < 3 ) { | 100 | if ( prof.count() < 2 ) { |
91 | prof.clear(); | 101 | prof.clear(); |
92 | prof << i18n("Sharp_DTM"); | 102 | prof << i18n("Sharp_DTM"); |
93 | prof << i18n("Local_file"); | 103 | prof << i18n("Local_file"); |
94 | prof << i18n("Last_file"); | ||
95 | KSyncProfile* temp = new KSyncProfile (); | 104 | KSyncProfile* temp = new KSyncProfile (); |
96 | temp->setName( prof[0] ); | 105 | temp->setName( prof[0] ); |
97 | temp->writeConfig(&config); | 106 | temp->writeConfig(&config); |
98 | temp->setName( prof[1] ); | 107 | temp->setName( prof[1] ); |
99 | temp->writeConfig(&config); | 108 | temp->writeConfig(&config); |
100 | temp->setName( prof[2] ); | ||
101 | temp->writeConfig(&config); | ||
102 | config.setGroup("General"); | 109 | config.setGroup("General"); |
103 | config.writeEntry("SyncProfileNames",prof); | 110 | config.writeEntry("SyncProfileNames",prof); |
104 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); | 111 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); |
105 | config.sync(); | 112 | config.sync(); |
106 | delete temp; | 113 | delete temp; |
107 | } | 114 | } |
108 | mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | 115 | mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); |
109 | mSyncProfileNames = prof; | 116 | mSyncProfileNames = prof; |
110 | unsigned int i; | 117 | unsigned int i; |
111 | for ( i = 0; i < prof.count(); ++i ) { | 118 | for ( i = 0; i < prof.count(); ++i ) { |
112 | mSyncMenu->insertItem( prof[i], 1000+i ); | 119 | mSyncMenu->insertItem( prof[i], 1000+i ); |
113 | if ( i == 2 ) | 120 | if ( i == 2 ) |
114 | mSyncMenu->insertSeparator(); | 121 | mSyncMenu->insertSeparator(); |
115 | } | 122 | } |
116 | QDir app_dir; | 123 | QDir app_dir; |
117 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available | 124 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available |
118 | if ( mTargetApp == PWMPI) { | 125 | if ( mTargetApp == PWMPI) { |
119 | mSyncMenu->removeItem( 1000 ); | 126 | mSyncMenu->removeItem( 1000 ); |
120 | } | 127 | } |
121 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | 128 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { |
122 | mSyncMenu->setItemEnabled( 1000, false ); | 129 | mSyncMenu->setItemEnabled( 1000, false ); |
123 | } | 130 | } |
124 | } | 131 | } |
125 | 132 | ||
126 | void KSyncManager::slotSyncMenu( int action ) | 133 | void KSyncManager::slotSyncMenu( int action ) |
127 | { | 134 | { |
128 | //qDebug("syncaction %d ", action); | 135 | //qDebug("syncaction %d ", action); |
129 | if ( action == 0 ) { | 136 | if ( action == 0 ) { |
130 | 137 | ||
131 | // seems to be a Qt2 event handling bug | 138 | // seems to be a Qt2 event handling bug |
132 | // syncmenu.clear causes a segfault at first time | 139 | // syncmenu.clear causes a segfault at first time |
133 | // when we call it after the main event loop, it is ok | 140 | // when we call it after the main event loop, it is ok |
134 | // same behaviour when calling OM/Pi via QCOP for the first time | 141 | // same behaviour when calling OM/Pi via QCOP for the first time |
135 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | 142 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); |
136 | //confSync(); | 143 | //confSync(); |
137 | 144 | ||
138 | return; | 145 | return; |
139 | } | 146 | } |
140 | if ( action == 1 ) { | 147 | if ( action == 1 ) { |
141 | multiSync( true ); | 148 | multiSync( true ); |
142 | return; | 149 | return; |
143 | } | 150 | } |
151 | if ( action == 2 ) { | ||
152 | enableQuick(); | ||
153 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | ||
154 | return; | ||
155 | } | ||
156 | if ( action == 3 ) { | ||
157 | delete mServerSocket; | ||
158 | mServerSocket = 0; | ||
159 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | ||
160 | return; | ||
161 | } | ||
144 | 162 | ||
145 | if (blockSave()) | 163 | if (blockSave()) |
146 | return; | 164 | return; |
147 | 165 | ||
148 | setBlockSave(true); | 166 | setBlockSave(true); |
149 | 167 | ||
150 | mCurrentSyncProfile = action - 1000 ; | 168 | mCurrentSyncProfile = action - 1000 ; |
151 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; | 169 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; |
152 | mCurrentSyncName = mLocalMachineName ; | 170 | mCurrentSyncName = mLocalMachineName ; |
153 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 171 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
154 | KSyncProfile* temp = new KSyncProfile (); | 172 | KSyncProfile* temp = new KSyncProfile (); |
155 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); | 173 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); |
156 | temp->readConfig(&config); | 174 | temp->readConfig(&config); |
157 | mAskForPreferences = temp->getAskForPreferences(); | 175 | mAskForPreferences = temp->getAskForPreferences(); |
158 | mSyncAlgoPrefs = temp->getSyncPrefs(); | 176 | mSyncAlgoPrefs = temp->getSyncPrefs(); |
159 | mWriteBackFile = temp->getWriteBackFile(); | 177 | mWriteBackFile = temp->getWriteBackFile(); |
160 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 178 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
161 | mWriteBackInFuture = 0; | 179 | mWriteBackInFuture = 0; |
162 | if ( temp->getWriteBackFuture() ) | 180 | if ( temp->getWriteBackFuture() ) |
163 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 181 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
164 | mShowSyncSummary = temp->getShowSummaryAfterSync(); | 182 | mShowSyncSummary = temp->getShowSummaryAfterSync(); |
165 | if ( action == 1000 ) { | 183 | if ( action == 1000 ) { |
166 | syncSharp(); | 184 | syncSharp(); |
167 | 185 | ||
168 | } else if ( action == 1001 ) { | 186 | } else if ( action == 1001 ) { |
169 | syncLocalFile(); | 187 | syncLocalFile(); |
170 | 188 | ||
171 | } else if ( action == 1002 ) { | 189 | } else if ( action == 1002 ) { |
172 | quickSyncLocalFile(); | 190 | quickSyncLocalFile(); |
173 | 191 | ||
174 | } else if ( action >= 1003 ) { | 192 | } else if ( action >= 1003 ) { |
175 | if ( temp->getIsLocalFileSync() ) { | 193 | if ( temp->getIsLocalFileSync() ) { |
176 | switch(mTargetApp) | 194 | switch(mTargetApp) |
177 | { | 195 | { |
178 | case (KAPI): | 196 | case (KAPI): |
179 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 197 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
180 | mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 198 | mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
181 | break; | 199 | break; |
182 | case (KOPI): | 200 | case (KOPI): |
183 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 201 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
184 | mLastSyncedLocalFile = temp->getRemoteFileName(); | 202 | mLastSyncedLocalFile = temp->getRemoteFileName(); |
185 | break; | 203 | break; |
186 | case (PWMPI): | 204 | case (PWMPI): |
187 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 205 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
188 | mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 206 | mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
189 | break; | 207 | break; |
190 | default: | 208 | default: |
191 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 209 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); |
192 | break; | 210 | break; |
193 | 211 | ||
194 | } | 212 | } |
195 | } else { | 213 | } else { |
196 | if ( temp->getIsPhoneSync() ) { | 214 | if ( temp->getIsPhoneSync() ) { |
197 | mPhoneDevice = temp->getPhoneDevice( ) ; | 215 | mPhoneDevice = temp->getPhoneDevice( ) ; |
198 | mPhoneConnection = temp->getPhoneConnection( ); | 216 | mPhoneConnection = temp->getPhoneConnection( ); |
199 | mPhoneModel = temp->getPhoneModel( ); | 217 | mPhoneModel = temp->getPhoneModel( ); |
200 | syncPhone(); | 218 | syncPhone(); |
201 | } else | 219 | } else if ( temp->getIsPiSync() ) { |
220 | mPassWordPiSync = temp->getRemotePw(); | ||
221 | mActiveSyncPort = temp->getRemotePort(); | ||
222 | mActiveSyncIP = temp->getRemoteIP(); | ||
223 | syncPi(); | ||
224 | } | ||
202 | syncRemote( temp ); | 225 | syncRemote( temp ); |
203 | 226 | ||
204 | } | 227 | } |
205 | } | 228 | } |
206 | delete temp; | 229 | delete temp; |
207 | setBlockSave(false); | 230 | setBlockSave(false); |
208 | } | 231 | } |
232 | void KSyncManager::enableQuick() | ||
233 | { | ||
234 | QDialog dia ( 0, "input-dialog", true ); | ||
235 | QLineEdit lab ( &dia ); | ||
236 | QVBoxLayout lay( &dia ); | ||
237 | lab.setText( mPrefs->mPassiveSyncPort ); | ||
238 | lay.setMargin(7); | ||
239 | lay.setSpacing(7); | ||
240 | int po = 9197+mTargetApp; | ||
241 | QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); | ||
242 | lay.addWidget( &label); | ||
243 | lay.addWidget( &lab); | ||
244 | |||
245 | QLineEdit lepw ( &dia ); | ||
246 | lepw.setText( mPrefs->mPassiveSyncPw ); | ||
247 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); | ||
248 | lay.addWidget( &label2); | ||
249 | lay.addWidget( &lepw); | ||
250 | dia.setFixedSize( 230,80 ); | ||
251 | dia.setCaption( i18n("Enter port for Pi-Sync") ); | ||
252 | QPushButton pb ( "OK", &dia); | ||
253 | lay.addWidget( &pb ); | ||
254 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | ||
255 | dia.show(); | ||
256 | if ( ! dia.exec() ) | ||
257 | return; | ||
258 | dia.hide(); | ||
259 | qApp->processEvents(); | ||
260 | mPrefs->mPassiveSyncPw = lepw.text(); | ||
261 | mPrefs->mPassiveSyncPort = lab.text(); | ||
262 | bool ok; | ||
263 | Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); | ||
264 | if ( ! ok ) { | ||
265 | KMessageBox::information( 0, i18n("No valid port")); | ||
266 | return; | ||
267 | } | ||
268 | //qDebug("port %d ", port); | ||
269 | mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); | ||
270 | mServerSocket->setFileName( defaultFileName() ); | ||
271 | //qDebug("connected "); | ||
272 | if ( !mServerSocket->ok() ) { | ||
273 | KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); | ||
274 | delete mServerSocket; | ||
275 | mServerSocket = 0; | ||
276 | return; | ||
277 | } | ||
278 | connect( mServerSocket, SIGNAL ( saveFile() ),this, SIGNAL ( save() ) ); | ||
279 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); | ||
280 | } | ||
209 | 281 | ||
210 | void KSyncManager::syncLocalFile() | 282 | void KSyncManager::syncLocalFile() |
211 | { | 283 | { |
212 | 284 | ||
213 | QString fn =mLastSyncedLocalFile; | 285 | QString fn =mLastSyncedLocalFile; |
214 | QString ext; | 286 | QString ext; |
215 | 287 | ||
216 | switch(mTargetApp) | 288 | switch(mTargetApp) |
217 | { | 289 | { |
218 | case (KAPI): | 290 | case (KAPI): |
219 | ext = "(*.vcf)"; | 291 | ext = "(*.vcf)"; |
220 | break; | 292 | break; |
221 | case (KOPI): | 293 | case (KOPI): |
222 | ext = "(*.ics/*.vcs)"; | 294 | ext = "(*.ics/*.vcs)"; |
223 | break; | 295 | break; |
224 | case (PWMPI): | 296 | case (PWMPI): |
225 | ext = "(*.pwm)"; | 297 | ext = "(*.pwm)"; |
226 | break; | 298 | break; |
227 | default: | 299 | default: |
228 | qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); | 300 | qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); |
229 | break; | 301 | break; |
230 | 302 | ||
231 | } | 303 | } |
232 | 304 | ||
233 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); | 305 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); |
234 | if ( fn == "" ) | 306 | if ( fn == "" ) |
235 | return; | 307 | return; |
236 | if ( syncWithFile( fn, false ) ) { | 308 | if ( syncWithFile( fn, false ) ) { |
237 | qDebug("syncLocalFile() successful "); | 309 | qDebug("syncLocalFile() successful "); |
238 | } | 310 | } |
239 | 311 | ||
240 | } | 312 | } |
241 | bool KSyncManager::syncWithFile( QString fn , bool quick ) | 313 | bool KSyncManager::syncWithFile( QString fn , bool quick ) |
242 | { | 314 | { |
243 | bool ret = false; | 315 | bool ret = false; |
244 | QFileInfo info; | 316 | QFileInfo info; |
245 | info.setFile( fn ); | 317 | info.setFile( fn ); |
246 | QString mess; | 318 | QString mess; |
247 | bool loadbup = true; | 319 | bool loadbup = true; |
248 | if ( !info. exists() ) { | 320 | if ( !info. exists() ) { |
249 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 321 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
250 | int result = QMessageBox::warning( mParent, i18n("Warning!"), | 322 | int result = QMessageBox::warning( mParent, i18n("Warning!"), |
251 | mess ); | 323 | mess ); |
252 | return ret; | 324 | return ret; |
253 | } | 325 | } |
254 | int result = 0; | 326 | int result = 0; |
255 | if ( !quick ) { | 327 | if ( !quick ) { |
256 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 328 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
257 | result = QMessageBox::warning( mParent, i18n("Warning!"), | 329 | result = QMessageBox::warning( mParent, i18n("Warning!"), |
258 | mess, | 330 | mess, |
259 | i18n("Sync"), i18n("Cancel"), 0, | 331 | i18n("Sync"), i18n("Cancel"), 0, |
260 | 0, 1 ); | 332 | 0, 1 ); |
261 | if ( result ) | 333 | if ( result ) |
262 | return false; | 334 | return false; |
263 | } | 335 | } |
264 | if ( mAskForPreferences ) | 336 | if ( mAskForPreferences ) |
265 | edit_sync_options(); | 337 | edit_sync_options(); |
266 | if ( result == 0 ) { | 338 | if ( result == 0 ) { |
267 | //qDebug("Now sycing ... "); | 339 | //qDebug("Now sycing ... "); |
268 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) | 340 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) |
269 | mParent->setCaption( i18n("Synchronization successful") ); | 341 | mParent->setCaption( i18n("Synchronization successful") ); |
270 | else | 342 | else |
271 | mParent->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); | 343 | mParent->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); |
272 | if ( ! quick ) | 344 | if ( ! quick ) |
273 | mLastSyncedLocalFile = fn; | 345 | mLastSyncedLocalFile = fn; |
274 | mImplementation->sync_setModified(); | ||
275 | } | 346 | } |
276 | return ret; | 347 | return ret; |
277 | } | 348 | } |
278 | void KSyncManager::quickSyncLocalFile() | 349 | void KSyncManager::quickSyncLocalFile() |
279 | { | 350 | { |
280 | 351 | ||
281 | if ( syncWithFile( mLastSyncedLocalFile, false ) ) { | 352 | if ( syncWithFile( mLastSyncedLocalFile, false ) ) { |
282 | qDebug("quick syncLocalFile() successful "); | 353 | qDebug("quick syncLocalFile() successful "); |
283 | 354 | ||
284 | } | 355 | } |
285 | } | 356 | } |
286 | void KSyncManager::multiSync( bool askforPrefs ) | 357 | void KSyncManager::multiSync( bool askforPrefs ) |
287 | { | 358 | { |
288 | if (blockSave()) | 359 | if (blockSave()) |
289 | return; | 360 | return; |
290 | setBlockSave(true); | 361 | setBlockSave(true); |
291 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 362 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
292 | if ( QMessageBox::information( mParent, i18n("Sync"), | 363 | if ( QMessageBox::information( mParent, i18n("Sync"), |
293 | question, | 364 | question, |
294 | i18n("Yes"), i18n("No"), | 365 | i18n("Yes"), i18n("No"), |
295 | 0, 0 ) != 0 ) { | 366 | 0, 0 ) != 0 ) { |
296 | setBlockSave(false); | 367 | setBlockSave(false); |
297 | mParent->setCaption(i18n("Aborted! Nothing synced!")); | 368 | mParent->setCaption(i18n("Aborted! Nothing synced!")); |
298 | return; | 369 | return; |
299 | } | 370 | } |
300 | mCurrentSyncDevice = i18n("Multiple profiles") ; | 371 | mCurrentSyncDevice = i18n("Multiple profiles") ; |
301 | mSyncAlgoPrefs = mRingSyncAlgoPrefs; | 372 | mSyncAlgoPrefs = mRingSyncAlgoPrefs; |
302 | if ( askforPrefs ) { | 373 | if ( askforPrefs ) { |
303 | edit_sync_options(); | 374 | edit_sync_options(); |
304 | mRingSyncAlgoPrefs = mSyncAlgoPrefs; | 375 | mRingSyncAlgoPrefs = mSyncAlgoPrefs; |
305 | } | 376 | } |
306 | mParent->setCaption(i18n("Multiple sync started.") ); | 377 | mParent->setCaption(i18n("Multiple sync started.") ); |
307 | qApp->processEvents(); | 378 | qApp->processEvents(); |
308 | int num = ringSync() ; | 379 | int num = ringSync() ; |
309 | if ( num > 1 ) | 380 | if ( num > 1 ) |
310 | ringSync(); | 381 | ringSync(); |
311 | setBlockSave(false); | 382 | setBlockSave(false); |
312 | if ( num ) | 383 | if ( num ) |
313 | mImplementation->sync_save(); | 384 | emit save(); |
314 | if ( num ) | 385 | if ( num ) |
315 | mParent->setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); | 386 | mParent->setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); |
316 | else | 387 | else |
317 | mParent->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 388 | mParent->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
318 | return; | 389 | return; |
319 | } | 390 | } |
320 | int KSyncManager::ringSync() | 391 | int KSyncManager::ringSync() |
321 | { | 392 | { |
322 | int syncedProfiles = 0; | 393 | int syncedProfiles = 0; |
323 | unsigned int i; | 394 | unsigned int i; |
324 | QTime timer; | 395 | QTime timer; |
325 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 396 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
326 | QStringList syncProfileNames = mSyncProfileNames; | 397 | QStringList syncProfileNames = mSyncProfileNames; |
327 | KSyncProfile* temp = new KSyncProfile (); | 398 | KSyncProfile* temp = new KSyncProfile (); |
328 | mAskForPreferences = false; | 399 | mAskForPreferences = false; |
329 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 400 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
330 | mCurrentSyncProfile = i; | 401 | mCurrentSyncProfile = i; |
331 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 402 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
332 | temp->readConfig(&config); | 403 | temp->readConfig(&config); |
333 | 404 | ||
334 | QString includeInRingSync; | 405 | QString includeInRingSync; |
335 | switch(mTargetApp) | 406 | switch(mTargetApp) |
336 | { | 407 | { |
337 | case (KAPI): | 408 | case (KAPI): |
338 | includeInRingSync = temp->getIncludeInRingSyncAB(); | 409 | includeInRingSync = temp->getIncludeInRingSyncAB(); |
339 | break; | 410 | break; |
340 | case (KOPI): | 411 | case (KOPI): |
341 | includeInRingSync = temp->getIncludeInRingSync(); | 412 | includeInRingSync = temp->getIncludeInRingSync(); |
342 | break; | 413 | break; |
343 | case (PWMPI): | 414 | case (PWMPI): |
344 | includeInRingSync = temp->getIncludeInRingSyncPWM(); | 415 | includeInRingSync = temp->getIncludeInRingSyncPWM(); |
345 | break; | 416 | break; |
346 | default: | 417 | default: |
347 | qDebug("KSyncManager::ringSync: invalid apptype selected"); | 418 | qDebug("KSyncManager::ringSync: invalid apptype selected"); |
348 | break; | 419 | break; |
349 | 420 | ||
350 | } | 421 | } |
351 | 422 | ||
352 | 423 | ||
353 | if ( includeInRingSync && ( i < 1 || i > 2 )) { | 424 | if ( includeInRingSync && ( i < 1 || i > 2 )) { |
354 | mParent->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 425 | mParent->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
355 | ++syncedProfiles; | 426 | ++syncedProfiles; |
356 | // mAskForPreferences = temp->getAskForPreferences(); | 427 | // mAskForPreferences = temp->getAskForPreferences(); |
357 | mWriteBackFile = temp->getWriteBackFile(); | 428 | mWriteBackFile = temp->getWriteBackFile(); |
358 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 429 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
359 | mWriteBackInFuture = 0; | 430 | mWriteBackInFuture = 0; |
360 | if ( temp->getWriteBackFuture() ) | 431 | if ( temp->getWriteBackFuture() ) |
361 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 432 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
362 | mShowSyncSummary = false; | 433 | mShowSyncSummary = false; |
363 | mCurrentSyncDevice = syncProfileNames[i] ; | 434 | mCurrentSyncDevice = syncProfileNames[i] ; |
364 | mCurrentSyncName = mLocalMachineName; | 435 | mCurrentSyncName = mLocalMachineName; |
365 | if ( i == 0 ) { | 436 | if ( i == 0 ) { |
366 | syncSharp(); | 437 | syncSharp(); |
367 | } else { | 438 | } else { |
368 | if ( temp->getIsLocalFileSync() ) { | 439 | if ( temp->getIsLocalFileSync() ) { |
369 | switch(mTargetApp) | 440 | switch(mTargetApp) |
370 | { | 441 | { |
371 | case (KAPI): | 442 | case (KAPI): |
372 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 443 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
373 | mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 444 | mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
374 | break; | 445 | break; |
375 | case (KOPI): | 446 | case (KOPI): |
376 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 447 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
377 | mLastSyncedLocalFile = temp->getRemoteFileName(); | 448 | mLastSyncedLocalFile = temp->getRemoteFileName(); |
378 | break; | 449 | break; |
379 | case (PWMPI): | 450 | case (PWMPI): |
380 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 451 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
381 | mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 452 | mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
382 | break; | 453 | break; |
383 | default: | 454 | default: |
384 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 455 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); |
385 | break; | 456 | break; |
386 | } | 457 | } |
387 | } else { | 458 | } else { |
388 | if ( temp->getIsPhoneSync() ) { | 459 | if ( temp->getIsPhoneSync() ) { |
389 | mPhoneDevice = temp->getPhoneDevice( ) ; | 460 | mPhoneDevice = temp->getPhoneDevice( ) ; |
390 | mPhoneConnection = temp->getPhoneConnection( ); | 461 | mPhoneConnection = temp->getPhoneConnection( ); |
391 | mPhoneModel = temp->getPhoneModel( ); | 462 | mPhoneModel = temp->getPhoneModel( ); |
392 | syncPhone(); | 463 | syncPhone(); |
393 | } else | 464 | } else |
394 | syncRemote( temp, false ); | 465 | syncRemote( temp, false ); |
395 | 466 | ||
396 | } | 467 | } |
397 | } | 468 | } |
398 | timer.start(); | 469 | timer.start(); |
399 | mParent->setCaption(i18n("Multiple sync in progress ... please wait!") ); | 470 | mParent->setCaption(i18n("Multiple sync in progress ... please wait!") ); |
400 | while ( timer.elapsed () < 2000 ) { | 471 | while ( timer.elapsed () < 2000 ) { |
401 | qApp->processEvents(); | 472 | qApp->processEvents(); |
402 | #ifndef _WIN32_ | 473 | #ifndef _WIN32_ |
403 | sleep (1); | 474 | sleep (1); |
404 | #endif | 475 | #endif |
405 | } | 476 | } |
406 | 477 | ||
407 | } | 478 | } |
408 | 479 | ||
409 | } | 480 | } |
410 | delete temp; | 481 | delete temp; |
411 | return syncedProfiles; | 482 | return syncedProfiles; |
412 | } | 483 | } |
413 | 484 | ||
414 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) | 485 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) |
415 | { | 486 | { |
416 | QString question; | 487 | QString question; |
417 | if ( ask ) { | 488 | if ( ask ) { |
418 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; | 489 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; |
419 | if ( QMessageBox::information( mParent, i18n("Sync"), | 490 | if ( QMessageBox::information( mParent, i18n("Sync"), |
420 | question, | 491 | question, |
421 | i18n("Yes"), i18n("No"), | 492 | i18n("Yes"), i18n("No"), |
422 | 0, 0 ) != 0 ) | 493 | 0, 0 ) != 0 ) |
423 | return; | 494 | return; |
424 | } | 495 | } |
425 | 496 | ||
426 | QString preCommand; | 497 | QString preCommand; |
427 | QString localTempFile; | 498 | QString localTempFile; |
428 | QString postCommand; | 499 | QString postCommand; |
429 | 500 | ||
430 | switch(mTargetApp) | 501 | switch(mTargetApp) |
431 | { | 502 | { |
432 | case (KAPI): | 503 | case (KAPI): |
433 | preCommand = prof->getPreSyncCommandAB(); | 504 | preCommand = prof->getPreSyncCommandAB(); |
434 | postCommand = prof->getPostSyncCommandAB(); | 505 | postCommand = prof->getPostSyncCommandAB(); |
435 | localTempFile = prof->getLocalTempFileAB(); | 506 | localTempFile = prof->getLocalTempFileAB(); |
436 | break; | 507 | break; |
437 | case (KOPI): | 508 | case (KOPI): |
438 | preCommand = prof->getPreSyncCommand(); | 509 | preCommand = prof->getPreSyncCommand(); |
439 | postCommand = prof->getPostSyncCommand(); | 510 | postCommand = prof->getPostSyncCommand(); |
440 | localTempFile = prof->getLocalTempFile(); | 511 | localTempFile = prof->getLocalTempFile(); |
441 | break; | 512 | break; |
442 | case (PWMPI): | 513 | case (PWMPI): |
443 | preCommand = prof->getPreSyncCommandPWM(); | 514 | preCommand = prof->getPreSyncCommandPWM(); |
444 | postCommand = prof->getPostSyncCommandPWM(); | 515 | postCommand = prof->getPostSyncCommandPWM(); |
445 | localTempFile = prof->getLocalTempFilePWM(); | 516 | localTempFile = prof->getLocalTempFilePWM(); |
446 | break; | 517 | break; |
447 | default: | 518 | default: |
448 | qDebug("KSyncManager::syncRemote: invalid apptype selected"); | 519 | qDebug("KSyncManager::syncRemote: invalid apptype selected"); |
449 | break; | 520 | break; |
450 | } | 521 | } |
451 | 522 | ||
452 | 523 | ||
453 | int fi; | 524 | int fi; |
454 | if ( (fi = preCommand.find("$PWD$")) > 0 ) { | 525 | if ( (fi = preCommand.find("$PWD$")) > 0 ) { |
455 | QString pwd = getPassword(); | 526 | QString pwd = getPassword(); |
456 | preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); | 527 | preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); |
457 | 528 | ||
458 | } | 529 | } |
459 | int maxlen = 30; | 530 | int maxlen = 30; |
460 | if ( QApplication::desktop()->width() > 320 ) | 531 | if ( QApplication::desktop()->width() > 320 ) |
461 | maxlen += 25; | 532 | maxlen += 25; |
462 | mParent->setCaption ( i18n( "Copy remote file to local machine..." ) ); | 533 | mParent->setCaption ( i18n( "Copy remote file to local machine..." ) ); |
463 | int fileSize = 0; | 534 | int fileSize = 0; |
464 | int result = system ( preCommand ); | 535 | int result = system ( preCommand ); |
465 | // 0 : okay | 536 | // 0 : okay |
466 | // 256: no such file or dir | 537 | // 256: no such file or dir |
467 | // | 538 | // |
468 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); | 539 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); |
469 | if ( result != 0 ) { | 540 | if ( result != 0 ) { |
470 | unsigned int len = maxlen; | 541 | unsigned int len = maxlen; |
471 | while ( len < preCommand.length() ) { | 542 | while ( len < preCommand.length() ) { |
472 | preCommand.insert( len , "\n" ); | 543 | preCommand.insert( len , "\n" ); |
473 | len += maxlen +2; | 544 | len += maxlen +2; |
474 | } | 545 | } |
475 | 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 (preCommand) ; | 546 | 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 (preCommand) ; |
476 | QMessageBox::information( mParent, i18n("Sync - ERROR"), | 547 | QMessageBox::information( mParent, i18n("Sync - ERROR"), |
477 | question, | 548 | question, |
478 | i18n("Okay!")) ; | 549 | i18n("Okay!")) ; |
479 | mParent->setCaption (""); | 550 | mParent->setCaption (""); |
480 | return; | 551 | return; |
481 | } | 552 | } |
482 | mParent->setCaption ( i18n( "Copying succeed." ) ); | 553 | mParent->setCaption ( i18n( "Copying succeed." ) ); |
483 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); | 554 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); |
484 | 555 | ||
485 | 556 | ||
486 | 557 | ||
487 | if ( syncWithFile( localTempFile, true ) ) { | 558 | if ( syncWithFile( localTempFile, true ) ) { |
488 | // Event* e = mView->getLastSyncEvent(); | 559 | // Event* e = mView->getLastSyncEvent(); |
489 | // e->setReadOnly( false ); | 560 | // e->setReadOnly( false ); |
490 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 561 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
491 | // e->setReadOnly( true ); | 562 | // e->setReadOnly( true ); |
492 | if ( mWriteBackFile ) { | 563 | if ( mWriteBackFile ) { |
493 | int fi; | 564 | int fi; |
494 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { | 565 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { |
495 | QString pwd = getPassword(); | 566 | QString pwd = getPassword(); |
496 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); | 567 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); |
497 | 568 | ||
498 | } | 569 | } |
499 | mParent->setCaption ( i18n( "Writing back file ..." ) ); | 570 | mParent->setCaption ( i18n( "Writing back file ..." ) ); |
500 | result = system ( postCommand ); | 571 | result = system ( postCommand ); |
501 | qDebug("Writing back file result: %d ", result); | 572 | qDebug("Writing back file result: %d ", result); |
502 | if ( result != 0 ) { | 573 | if ( result != 0 ) { |
503 | mParent->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); | 574 | mParent->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); |
504 | return; | 575 | return; |
505 | } else { | 576 | } else { |
506 | mParent->setCaption ( i18n( "Syncronization sucessfully completed" ) ); | 577 | mParent->setCaption ( i18n( "Syncronization sucessfully completed" ) ); |
507 | } | 578 | } |
508 | } | 579 | } |
509 | } | 580 | } |
510 | return; | 581 | return; |
511 | } | 582 | } |
512 | 583 | ||
513 | void KSyncManager::edit_sync_options() | 584 | void KSyncManager::edit_sync_options() |
514 | { | 585 | { |
515 | //mDialogManager->showSyncOptions(); | 586 | //mDialogManager->showSyncOptions(); |
516 | //mSyncAlgoPrefs | 587 | //mSyncAlgoPrefs |
517 | QDialog dia( mParent, "dia", true ); | 588 | QDialog dia( mParent, "dia", true ); |
518 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 589 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
519 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 590 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
520 | QVBoxLayout lay ( &dia ); | 591 | QVBoxLayout lay ( &dia ); |
521 | lay.setSpacing( 2 ); | 592 | lay.setSpacing( 2 ); |
522 | lay.setMargin( 3 ); | 593 | lay.setMargin( 3 ); |
523 | lay.addWidget(&gr); | 594 | lay.addWidget(&gr); |
524 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 595 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
525 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 596 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
526 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 597 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
527 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 598 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
528 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 599 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
529 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 600 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
530 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 601 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
531 | QPushButton pb ( "OK", &dia); | 602 | QPushButton pb ( "OK", &dia); |
532 | lay.addWidget( &pb ); | 603 | lay.addWidget( &pb ); |
533 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 604 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
534 | switch ( mSyncAlgoPrefs ) { | 605 | switch ( mSyncAlgoPrefs ) { |
535 | case 0: | 606 | case 0: |
536 | loc.setChecked( true); | 607 | loc.setChecked( true); |
537 | break; | 608 | break; |
538 | case 1: | 609 | case 1: |
539 | rem.setChecked( true ); | 610 | rem.setChecked( true ); |
540 | break; | 611 | break; |
541 | case 2: | 612 | case 2: |
542 | newest.setChecked( true); | 613 | newest.setChecked( true); |
543 | break; | 614 | break; |
544 | case 3: | 615 | case 3: |
545 | ask.setChecked( true); | 616 | ask.setChecked( true); |
546 | break; | 617 | break; |
547 | case 4: | 618 | case 4: |
548 | f_loc.setChecked( true); | 619 | f_loc.setChecked( true); |
549 | break; | 620 | break; |
550 | case 5: | 621 | case 5: |
551 | f_rem.setChecked( true); | 622 | f_rem.setChecked( true); |
552 | break; | 623 | break; |
553 | case 6: | 624 | case 6: |
554 | // both.setChecked( true); | 625 | // both.setChecked( true); |
555 | break; | 626 | break; |
556 | default: | 627 | default: |
557 | break; | 628 | break; |
558 | } | 629 | } |
559 | if ( dia.exec() ) { | 630 | if ( dia.exec() ) { |
560 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | 631 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; |
561 | } | 632 | } |
562 | 633 | ||
563 | 634 | ||
564 | } | 635 | } |
565 | QString KSyncManager::getPassword( ) | 636 | QString KSyncManager::getPassword( ) |
566 | { | 637 | { |
567 | QString retfile = ""; | 638 | QString retfile = ""; |
568 | QDialog dia ( mParent, "input-dialog", true ); | 639 | QDialog dia ( mParent, "input-dialog", true ); |
569 | QLineEdit lab ( &dia ); | 640 | QLineEdit lab ( &dia ); |
570 | lab.setEchoMode( QLineEdit::Password ); | 641 | lab.setEchoMode( QLineEdit::Password ); |
571 | QVBoxLayout lay( &dia ); | 642 | QVBoxLayout lay( &dia ); |
572 | lay.setMargin(7); | 643 | lay.setMargin(7); |
573 | lay.setSpacing(7); | 644 | lay.setSpacing(7); |
574 | lay.addWidget( &lab); | 645 | lay.addWidget( &lab); |
575 | dia.setFixedSize( 230,50 ); | 646 | dia.setFixedSize( 230,50 ); |
576 | dia.setCaption( i18n("Enter password") ); | 647 | dia.setCaption( i18n("Enter password") ); |
577 | QPushButton pb ( "OK", &dia); | 648 | QPushButton pb ( "OK", &dia); |
578 | lay.addWidget( &pb ); | 649 | lay.addWidget( &pb ); |
579 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 650 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
580 | dia.show(); | 651 | dia.show(); |
581 | int res = dia.exec(); | 652 | int res = dia.exec(); |
582 | if ( res ) | 653 | if ( res ) |
583 | retfile = lab.text(); | 654 | retfile = lab.text(); |
584 | dia.hide(); | 655 | dia.hide(); |
585 | qApp->processEvents(); | 656 | qApp->processEvents(); |
586 | return retfile; | 657 | return retfile; |
587 | 658 | ||
588 | } | 659 | } |
589 | 660 | ||
590 | 661 | ||
591 | void KSyncManager::confSync() | 662 | void KSyncManager::confSync() |
592 | { | 663 | { |
593 | static KSyncPrefsDialog* sp = 0; | 664 | static KSyncPrefsDialog* sp = 0; |
594 | if ( ! sp ) { | 665 | if ( ! sp ) { |
595 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); | 666 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); |
596 | } | 667 | } |
597 | sp->usrReadConfig(); | 668 | sp->usrReadConfig(); |
598 | #ifndef DESKTOP_VERSION | 669 | #ifndef DESKTOP_VERSION |
599 | sp->showMaximized(); | 670 | sp->showMaximized(); |
600 | #else | 671 | #else |
601 | sp->show(); | 672 | sp->show(); |
602 | #endif | 673 | #endif |
603 | sp->exec(); | 674 | sp->exec(); |
604 | mSyncProfileNames = sp->getSyncProfileNames(); | 675 | mSyncProfileNames = sp->getSyncProfileNames(); |
605 | mLocalMachineName = sp->getLocalMachineName (); | 676 | mLocalMachineName = sp->getLocalMachineName (); |
606 | fillSyncMenu(); | 677 | fillSyncMenu(); |
607 | } | 678 | } |
608 | 679 | ||
609 | void KSyncManager::syncSharp() | 680 | void KSyncManager::syncSharp() |
610 | { | 681 | { |
611 | if ( ! syncExternalApplication("sharp") ) | 682 | if ( ! syncExternalApplication("sharp") ) |
612 | qDebug("ERROR sync sharp ");; | 683 | qDebug("ERROR sync sharp ");; |
613 | } | 684 | } |
614 | 685 | ||
615 | bool KSyncManager::syncExternalApplication(QString resource) | 686 | bool KSyncManager::syncExternalApplication(QString resource) |
616 | { | 687 | { |
617 | if ( mImplementation->sync_isModified() ) | 688 | |
618 | mImplementation->sync_save(); | 689 | emit save(); |
619 | 690 | ||
620 | if ( mAskForPreferences ) | 691 | if ( mAskForPreferences ) |
621 | edit_sync_options(); | 692 | edit_sync_options(); |
622 | 693 | ||
623 | qDebug("sync %s", resource.latin1()); | 694 | qDebug("sync %s", resource.latin1()); |
624 | 695 | ||
625 | bool syncOK = mImplementation->syncExternal(this, resource); | 696 | bool syncOK = mImplementation->syncExternal(this, resource); |
626 | 697 | ||
627 | return syncOK; | 698 | return syncOK; |
628 | 699 | ||
629 | } | 700 | } |
630 | 701 | ||
631 | void KSyncManager::syncPhone() | 702 | void KSyncManager::syncPhone() |
632 | { | 703 | { |
633 | if ( mImplementation->sync_isModified() ) | 704 | emit save(); |
634 | mImplementation->sync_save(); | ||
635 | 705 | ||
636 | qDebug("pending syncPhone(); "); | 706 | qDebug("pending syncPhone(); "); |
637 | //mView->syncPhone(); | 707 | //mView->syncPhone(); |
638 | mImplementation->sync_setModified(); | ||
639 | 708 | ||
640 | } | 709 | } |
641 | 710 | ||
642 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) | 711 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) |
643 | { | 712 | { |
644 | if (!bar->isVisible()) | 713 | if (!bar->isVisible()) |
645 | { | 714 | { |
646 | bar->setCaption (caption); | 715 | bar->setCaption (caption); |
647 | bar->setTotalSteps ( total ) ; | 716 | bar->setTotalSteps ( total ) ; |
648 | 717 | ||
649 | bar->show(); | 718 | bar->show(); |
650 | } | 719 | } |
651 | 720 | ||
652 | bar->setProgress( percentage ); | 721 | bar->setProgress( percentage ); |
653 | } | 722 | } |
654 | 723 | ||
655 | void KSyncManager::hideProgressBar() | 724 | void KSyncManager::hideProgressBar() |
656 | { | 725 | { |
657 | bar->hide(); | 726 | bar->hide(); |
658 | } | 727 | } |
659 | 728 | ||
660 | bool KSyncManager::isProgressBarCanceled() | 729 | bool KSyncManager::isProgressBarCanceled() |
661 | { | 730 | { |
662 | return !bar->isVisible(); | 731 | return !bar->isVisible(); |
663 | } | 732 | } |
733 | |||
734 | QString KSyncManager::syncFileName() | ||
735 | { | ||
736 | |||
737 | QString fn = "tempfile"; | ||
738 | switch(mTargetApp) | ||
739 | { | ||
740 | case (KAPI): | ||
741 | fn = "addressbook.vcf"; | ||
742 | break; | ||
743 | case (KOPI): | ||
744 | fn = "synccalendar.ics"; | ||
745 | break; | ||
746 | case (PWMPI): | ||
747 | fn = "manager.pwm"; | ||
748 | break; | ||
749 | default: | ||
750 | break; | ||
751 | } | ||
752 | #ifdef _WIN32_ | ||
753 | return locateLocal( "tmp", fn ); | ||
754 | #else | ||
755 | return (QString( "/tmp/" )+ fn ); | ||
756 | #endif | ||
757 | } | ||
758 | |||
759 | void KSyncManager::syncPi() | ||
760 | { | ||
761 | qApp->processEvents(); | ||
762 | bool ok; | ||
763 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); | ||
764 | if ( ! ok ) { | ||
765 | mParent->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); | ||
766 | return; | ||
767 | } | ||
768 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); | ||
769 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); | ||
770 | mParent->setCaption( i18n("Sending request for remote file ...") ); | ||
771 | commandSocket->readFile( syncFileName() ); | ||
772 | } | ||
773 | |||
774 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) | ||
775 | { | ||
776 | qDebug("MainWindow::deleteCommandSocket %d", state); | ||
777 | |||
778 | //enum { success, errorW, errorR, quiet }; | ||
779 | if ( state == KCommandSocket::errorR ) { | ||
780 | mParent->setCaption( i18n("ERROR: Receiving remote file failed.") ); | ||
781 | delete s; | ||
782 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); | ||
783 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | ||
784 | commandSocket->sendStop(); | ||
785 | return; | ||
786 | |||
787 | } else if ( state == KCommandSocket::errorW ) { | ||
788 | mParent->setCaption( i18n("ERROR:Writing back file failed.") ); | ||
789 | |||
790 | } else if ( state == KCommandSocket::successR ) { | ||
791 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); | ||
792 | |||
793 | } else if ( state == KCommandSocket::successW ) { | ||
794 | mParent->setCaption( i18n("Pi-Sync succesful!") ); | ||
795 | } | ||
796 | |||
797 | delete s; | ||
798 | } | ||
799 | |||
800 | void KSyncManager::readFileFromSocket() | ||
801 | { | ||
802 | QString fileName = syncFileName(); | ||
803 | mParent->setCaption( i18n("Remote file saved to temp file.") ); | ||
804 | if ( ! syncWithFile( fileName , true ) ) { | ||
805 | mParent->setCaption( i18n("Syncing failed.") ); | ||
806 | qDebug("Syncing failed "); | ||
807 | return; | ||
808 | } | ||
809 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); | ||
810 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | ||
811 | if ( mWriteBackFile ) | ||
812 | commandSocket->writeFile( fileName ); | ||
813 | else { | ||
814 | commandSocket->sendStop(); | ||
815 | mParent->setCaption( i18n("Pi-Sync succesful!") ); | ||
816 | } | ||
817 | } | ||
818 | |||
819 | |||
820 | |||
821 | |||
822 | |||
823 | |||
824 | |||
825 | |||
826 | |||
827 | |||
828 | |||
829 | |||
830 | |||
831 | |||
832 | |||
833 | |||
834 | |||
835 | |||
836 | |||
837 | |||
838 | |||
839 | |||
840 | |||
841 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) | ||
842 | { | ||
843 | mPassWord = pw; | ||
844 | mSocket = 0; | ||
845 | mSyncActionDialog = 0; | ||
846 | blockRC = false; | ||
847 | }; | ||
848 | |||
849 | void KServerSocket::newConnection ( int socket ) | ||
850 | { | ||
851 | // qDebug("KServerSocket:New connection %d ", socket); | ||
852 | if ( mSocket ) { | ||
853 | qDebug("KServerSocket::newConnection Socket deleted! "); | ||
854 | delete mSocket; | ||
855 | mSocket = 0; | ||
856 | } | ||
857 | mSocket = new QSocket( this ); | ||
858 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); | ||
859 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); | ||
860 | mSocket->setSocket( socket ); | ||
861 | } | ||
862 | |||
863 | void KServerSocket::discardClient() | ||
864 | { | ||
865 | //qDebug(" KServerSocket::discardClient()"); | ||
866 | if ( mSocket ) { | ||
867 | delete mSocket; | ||
868 | mSocket = 0; | ||
869 | } | ||
870 | //emit endConnect(); | ||
871 | } | ||
872 | void KServerSocket::readClient() | ||
873 | { | ||
874 | if ( blockRC ) | ||
875 | return; | ||
876 | if ( mSocket == 0 ) { | ||
877 | qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); | ||
878 | return; | ||
879 | } | ||
880 | qDebug("KServerSocket readClient()"); | ||
881 | if ( mSocket->canReadLine() ) { | ||
882 | QString line = mSocket->readLine(); | ||
883 | qDebug("KServerSocket readline: %s ", line.latin1()); | ||
884 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); | ||
885 | if ( tokens[0] == "GET" ) { | ||
886 | if ( tokens[1] == mPassWord ) | ||
887 | //emit sendFile( mSocket ); | ||
888 | send_file(); | ||
889 | else { | ||
890 | KMessageBox::information( 0, i18n("ERROR:\nGot send file request\nwith invalid password")); | ||
891 | qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); | ||
892 | } | ||
893 | } | ||
894 | if ( tokens[0] == "PUT" ) { | ||
895 | if ( tokens[1] == mPassWord ) { | ||
896 | //emit getFile( mSocket ); | ||
897 | blockRC = true; | ||
898 | get_file(); | ||
899 | } | ||
900 | else { | ||
901 | KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password")); | ||
902 | qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); | ||
903 | } | ||
904 | } | ||
905 | if ( tokens[0] == "STOP" ) { | ||
906 | //emit endConnect(); | ||
907 | end_connect(); | ||
908 | } | ||
909 | } | ||
910 | } | ||
911 | void KServerSocket::end_connect() | ||
912 | { | ||
913 | delete mSyncActionDialog; | ||
914 | mSyncActionDialog = 0; | ||
915 | } | ||
916 | void KServerSocket::send_file() | ||
917 | { | ||
918 | //qDebug("MainWindow::sendFile(QSocket* s) "); | ||
919 | if ( mSyncActionDialog ) | ||
920 | delete mSyncActionDialog; | ||
921 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); | ||
922 | mSyncActionDialog->setCaption(i18n("Received sync request")); | ||
923 | QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); | ||
924 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); | ||
925 | lay->addWidget( label); | ||
926 | lay->setMargin(7); | ||
927 | lay->setSpacing(7); | ||
928 | mSyncActionDialog->setFixedSize( 230, 120); | ||
929 | mSyncActionDialog->show(); | ||
930 | qDebug("KSS::saving ... "); | ||
931 | emit saveFile(); | ||
932 | qApp->processEvents(); | ||
933 | QString fileName = mFileName; | ||
934 | QFile file( fileName ); | ||
935 | if (!file.open( IO_ReadOnly ) ) { | ||
936 | delete mSyncActionDialog; | ||
937 | mSyncActionDialog = 0; | ||
938 | qDebug("KSS::error open file "); | ||
939 | mSocket->close(); | ||
940 | if ( mSocket->state() == QSocket::Idle ) | ||
941 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | ||
942 | return ; | ||
943 | |||
944 | } | ||
945 | mSyncActionDialog->setCaption( i18n("Sending file...") ); | ||
946 | QTextStream ts( &file ); | ||
947 | ts.setCodec( QTextCodec::codecForName("utf8") ); | ||
948 | QTextStream os( mSocket ); | ||
949 | os.setCodec( QTextCodec::codecForName("utf8") ); | ||
950 | //os.setEncoding( QTextStream::UnicodeUTF8 ); | ||
951 | while ( ! ts.atEnd() ) { | ||
952 | os << ts.readLine() << "\n"; | ||
953 | } | ||
954 | //os << ts.read(); | ||
955 | file.close(); | ||
956 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); | ||
957 | mSocket->close(); | ||
958 | if ( mSocket->state() == QSocket::Idle ) | ||
959 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | ||
960 | } | ||
961 | void KServerSocket::get_file() | ||
962 | { | ||
963 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); | ||
964 | |||
965 | piTime.start(); | ||
966 | piFileString = ""; | ||
967 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); | ||
968 | } | ||
969 | |||
970 | |||
971 | void KServerSocket::readBackFileFromSocket() | ||
972 | { | ||
973 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); | ||
974 | while ( mSocket->canReadLine () ) { | ||
975 | piTime.restart(); | ||
976 | QString line = mSocket->readLine (); | ||
977 | piFileString += line; | ||
978 | //qDebug("readline: %s ", line.latin1()); | ||
979 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); | ||
980 | |||
981 | } | ||
982 | if ( piTime.elapsed () < 3000 ) { | ||
983 | // wait for more | ||
984 | //qDebug("waitformore "); | ||
985 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); | ||
986 | return; | ||
987 | } | ||
988 | QString fileName = mFileName; | ||
989 | QFile file ( fileName ); | ||
990 | if (!file.open( IO_WriteOnly ) ) { | ||
991 | delete mSyncActionDialog; | ||
992 | mSyncActionDialog = 0; | ||
993 | qDebug("error open cal file "); | ||
994 | piFileString = ""; | ||
995 | emit file_received( false ); | ||
996 | blockRC = false; | ||
997 | return ; | ||
998 | |||
999 | } | ||
1000 | |||
1001 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | ||
1002 | QTextStream ts ( &file ); | ||
1003 | ts.setCodec( QTextCodec::codecForName("utf8") ); | ||
1004 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); | ||
1005 | ts << piFileString; | ||
1006 | mSocket->close(); | ||
1007 | if ( mSocket->state() == QSocket::Idle ) | ||
1008 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | ||
1009 | file.close(); | ||
1010 | delete mSyncActionDialog; | ||
1011 | mSyncActionDialog = 0; | ||
1012 | piFileString = ""; | ||
1013 | blockRC = false; | ||
1014 | emit file_received( true ); | ||
1015 | |||
1016 | } | ||
1017 | |||
1018 | KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) | ||
1019 | { | ||
1020 | mPassWord = password; | ||
1021 | mSocket = 0; | ||
1022 | mPort = port; | ||
1023 | mHost = host; | ||
1024 | |||
1025 | mRetVal = quiet; | ||
1026 | mTimerSocket = new QTimer ( this ); | ||
1027 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); | ||
1028 | } | ||
1029 | void KCommandSocket::readFile( QString fn ) | ||
1030 | { | ||
1031 | if ( !mSocket ) { | ||
1032 | mSocket = new QSocket( this ); | ||
1033 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); | ||
1034 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | ||
1035 | } | ||
1036 | mFileString = ""; | ||
1037 | mFileName = fn; | ||
1038 | mFirst = true; | ||
1039 | mSocket->connectToHost( mHost, mPort ); | ||
1040 | QTextStream os( mSocket ); | ||
1041 | os.setEncoding( QTextStream::UnicodeUTF8 ); | ||
1042 | os << "GET " << mPassWord << "\r\n"; | ||
1043 | mTimerSocket->start( 10000 ); | ||
1044 | } | ||
1045 | |||
1046 | void KCommandSocket::writeFile( QString fileName ) | ||
1047 | { | ||
1048 | if ( !mSocket ) { | ||
1049 | mSocket = new QSocket( this ); | ||
1050 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | ||
1051 | connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); | ||
1052 | } | ||
1053 | mFileName = fileName ; | ||
1054 | mSocket->connectToHost( mHost, mPort ); | ||
1055 | } | ||
1056 | void KCommandSocket::writeFileToSocket() | ||
1057 | { | ||
1058 | QFile file2( mFileName ); | ||
1059 | if (!file2.open( IO_ReadOnly ) ) { | ||
1060 | mRetVal= errorW; | ||
1061 | mSocket->close(); | ||
1062 | if ( mSocket->state() == QSocket::Idle ) | ||
1063 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | ||
1064 | return ; | ||
1065 | } | ||
1066 | QTextStream ts2( &file2 ); | ||
1067 | ts2.setCodec( QTextCodec::codecForName("utf8") ); | ||
1068 | QTextStream os2( mSocket ); | ||
1069 | os2.setCodec( QTextCodec::codecForName("utf8") ); | ||
1070 | os2 << "PUT " << mPassWord << "\r\n";; | ||
1071 | while ( ! ts2.atEnd() ) { | ||
1072 | os2 << ts2.readLine() << "\n"; | ||
1073 | } | ||
1074 | mRetVal= successW; | ||
1075 | file2.close(); | ||
1076 | mSocket->close(); | ||
1077 | if ( mSocket->state() == QSocket::Idle ) | ||
1078 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | ||
1079 | } | ||
1080 | void KCommandSocket::sendStop() | ||
1081 | { | ||
1082 | if ( !mSocket ) { | ||
1083 | mSocket = new QSocket( this ); | ||
1084 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | ||
1085 | } | ||
1086 | mSocket->connectToHost( mHost, mPort ); | ||
1087 | QTextStream os2( mSocket ); | ||
1088 | os2.setCodec( QTextCodec::codecForName("utf8") ); | ||
1089 | os2 << "STOP\r\n"; | ||
1090 | mSocket->close(); | ||
1091 | if ( mSocket->state() == QSocket::Idle ) | ||
1092 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | ||
1093 | } | ||
1094 | |||
1095 | void KCommandSocket::startReadFileFromSocket() | ||
1096 | { | ||
1097 | if ( ! mFirst ) | ||
1098 | return; | ||
1099 | mFirst = false; | ||
1100 | mTimerSocket->stop(); | ||
1101 | mFileString = ""; | ||
1102 | mTime.start(); | ||
1103 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); | ||
1104 | |||
1105 | } | ||
1106 | void KCommandSocket::readFileFromSocket() | ||
1107 | { | ||
1108 | //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); | ||
1109 | while ( mSocket->canReadLine () ) { | ||
1110 | mTime.restart(); | ||
1111 | QString line = mSocket->readLine (); | ||
1112 | mFileString += line; | ||
1113 | //qDebug("readline: %s ", line.latin1()); | ||
1114 | } | ||
1115 | if ( mTime.elapsed () < 3000 ) { | ||
1116 | // wait for more | ||
1117 | //qDebug("waitformore "); | ||
1118 | QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); | ||
1119 | return; | ||
1120 | } | ||
1121 | QString fileName = mFileName; | ||
1122 | QFile file ( fileName ); | ||
1123 | if (!file.open( IO_WriteOnly ) ) { | ||
1124 | mFileString = ""; | ||
1125 | mRetVal = errorR; | ||
1126 | qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); | ||
1127 | deleteSocket(); | ||
1128 | return ; | ||
1129 | |||
1130 | } | ||
1131 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | ||
1132 | QTextStream ts ( &file ); | ||
1133 | ts.setCodec( QTextCodec::codecForName("utf8") ); | ||
1134 | ts << mFileString; | ||
1135 | file.close(); | ||
1136 | mFileString = ""; | ||
1137 | mRetVal = successR; | ||
1138 | mSocket->close(); | ||
1139 | // if state is not idle, deleteSocket(); is called via | ||
1140 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | ||
1141 | if ( mSocket->state() == QSocket::Idle ) | ||
1142 | deleteSocket(); | ||
1143 | } | ||
1144 | |||
1145 | void KCommandSocket::deleteSocket() | ||
1146 | { | ||
1147 | if ( mTimerSocket->isActive () ) { | ||
1148 | mTimerSocket->stop(); | ||
1149 | KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? ")); | ||
1150 | mRetVal = errorR; | ||
1151 | } | ||
1152 | //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); | ||
1153 | if ( mSocket) | ||
1154 | delete mSocket; | ||
1155 | mSocket = 0; | ||
1156 | emit commandFinished( this, mRetVal ); | ||
1157 | } | ||
1158 | |||
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h index 6b10016..52e2772 100644 --- a/libkdepim/ksyncmanager.h +++ b/libkdepim/ksyncmanager.h | |||
@@ -1,147 +1,228 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KDE-Pim/Pi. | 2 | This file is part of KDE-Pim/Pi. |
3 | Copyright (c) 2004 Ulf Schenk | 3 | Copyright (c) 2004 Ulf Schenk |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | $Id$ | 20 | $Id$ |
21 | */ | 21 | */ |
22 | #ifndef _KSYNCMANAGER_H | 22 | #ifndef _KSYNCMANAGER_H |
23 | #define _KSYNCMANAGER_H | 23 | #define _KSYNCMANAGER_H |
24 | 24 | ||
25 | #include <qobject.h> | 25 | #include <qobject.h> |
26 | #include <qstring.h> | 26 | #include <qstring.h> |
27 | #include <qsocket.h> | ||
28 | #include <qdatetime.h> | ||
29 | #include <qserversocket.h> | ||
30 | #include <qtextstream.h> | ||
31 | #include <qregexp.h> | ||
27 | 32 | ||
28 | class QPopupMenu; | 33 | class QPopupMenu; |
29 | class KSyncProfile; | 34 | class KSyncProfile; |
30 | class KPimPrefs; | 35 | class KPimPrefs; |
31 | class QWidget; | 36 | class QWidget; |
32 | class KSyncManager; | 37 | class KSyncManager; |
33 | class KSyncInterface; | 38 | class KSyncInterface; |
34 | class QProgressBar; | 39 | class QProgressBar; |
35 | 40 | ||
41 | |||
42 | class KServerSocket : public QServerSocket | ||
43 | { | ||
44 | Q_OBJECT | ||
45 | |||
46 | public: | ||
47 | KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); | ||
48 | |||
49 | void newConnection ( int socket ) ; | ||
50 | void setFileName( QString fn ) {mFileName = fn;}; | ||
51 | |||
52 | signals: | ||
53 | //void sendFile(QSocket*); | ||
54 | //void getFile(QSocket*); | ||
55 | void file_received( bool ); | ||
56 | //void file_sent(); | ||
57 | void saveFile(); | ||
58 | void endConnect(); | ||
59 | private slots: | ||
60 | void discardClient(); | ||
61 | void readClient(); | ||
62 | void readBackFileFromSocket(); | ||
63 | private : | ||
64 | bool blockRC; | ||
65 | void send_file(); | ||
66 | void get_file(); | ||
67 | void end_connect(); | ||
68 | QDialog* mSyncActionDialog; | ||
69 | QSocket* mSocket; | ||
70 | QString mPassWord; | ||
71 | QString mFileName; | ||
72 | QTime piTime; | ||
73 | QString piFileString; | ||
74 | }; | ||
75 | |||
76 | class KCommandSocket : public QObject | ||
77 | { | ||
78 | Q_OBJECT | ||
79 | public: | ||
80 | enum state { successR, errorR, successW, errorW, quiet }; | ||
81 | KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); | ||
82 | void readFile( QString ); | ||
83 | void writeFile( QString ); | ||
84 | void sendStop(); | ||
85 | |||
86 | |||
87 | signals: | ||
88 | void commandFinished( KCommandSocket*, int ); | ||
89 | private slots: | ||
90 | void startReadFileFromSocket(); | ||
91 | void readFileFromSocket(); | ||
92 | void deleteSocket(); | ||
93 | void writeFileToSocket(); | ||
94 | private : | ||
95 | QSocket* mSocket; | ||
96 | QString mPassWord; | ||
97 | Q_UINT16 mPort; | ||
98 | QString mHost; | ||
99 | QString mFileName; | ||
100 | QTimer* mTimerSocket; | ||
101 | int mRetVal; | ||
102 | QTime mTime; | ||
103 | QString mFileString; | ||
104 | bool mFirst; | ||
105 | }; | ||
106 | |||
107 | |||
36 | class KSyncManager : public QObject | 108 | class KSyncManager : public QObject |
37 | { | 109 | { |
38 | Q_OBJECT | 110 | Q_OBJECT |
39 | 111 | ||
40 | public: | 112 | public: |
41 | enum TargetApp { | 113 | enum TargetApp { |
42 | KOPI = 0, | 114 | KOPI = 0, |
43 | KAPI = 1, | 115 | KAPI = 1, |
44 | PWMPI = 2 }; | 116 | PWMPI = 2 }; |
45 | 117 | ||
46 | 118 | ||
47 | KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); | 119 | KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); |
48 | ~KSyncManager() ; | 120 | ~KSyncManager() ; |
49 | 121 | ||
50 | bool blockSave() { return mBlockSaveFlag; } | 122 | bool blockSave() { return mBlockSaveFlag; } |
51 | void setBlockSave(bool sa) { mBlockSaveFlag = sa; } | 123 | void setBlockSave(bool sa) { mBlockSaveFlag = sa; } |
52 | 124 | void setDefaultFileName( QString s) { mDefFileName = s ;} | |
125 | QString defaultFileName() { return mDefFileName ;} | ||
126 | QString syncFileName(); | ||
53 | void fillSyncMenu(); | 127 | void fillSyncMenu(); |
54 | 128 | ||
55 | QString getCurrentSyncDevice() { return mCurrentSyncDevice; } | 129 | QString getCurrentSyncDevice() { return mCurrentSyncDevice; } |
56 | QString getCurrentSyncName() { return mCurrentSyncName; } | 130 | QString getCurrentSyncName() { return mCurrentSyncName; } |
57 | 131 | ||
58 | void showProgressBar(int percentage, QString caption = QString::null, int total=100); | 132 | void showProgressBar(int percentage, QString caption = QString::null, int total=100); |
59 | void hideProgressBar(); | 133 | void hideProgressBar(); |
60 | bool isProgressBarCanceled(); | 134 | bool isProgressBarCanceled(); |
61 | 135 | ||
62 | // sync stuff | 136 | // sync stuff |
63 | QString mLocalMachineName; | 137 | QString mLocalMachineName; |
64 | QStringList mExternSyncProfiles; | 138 | QStringList mExternSyncProfiles; |
65 | QStringList mSyncProfileNames; | 139 | QStringList mSyncProfileNames; |
66 | bool mAskForPreferences; | 140 | bool mAskForPreferences; |
67 | bool mShowSyncSummary; | 141 | bool mShowSyncSummary; |
68 | bool mShowSyncEvents; | 142 | bool mShowSyncEvents; |
69 | bool mShowTodoInAgenda; | 143 | bool mShowTodoInAgenda; |
70 | bool mWriteBackExistingOnly; | 144 | bool mWriteBackExistingOnly; |
71 | int mSyncAlgoPrefs; | 145 | int mSyncAlgoPrefs; |
72 | int mRingSyncAlgoPrefs; | 146 | int mRingSyncAlgoPrefs; |
73 | bool mWriteBackFile; | 147 | bool mWriteBackFile; |
74 | int mWriteBackInFuture; | 148 | int mWriteBackInFuture; |
75 | QString mPhoneDevice; | 149 | QString mPhoneDevice; |
76 | QString mPhoneConnection; | 150 | QString mPhoneConnection; |
77 | QString mPhoneModel; | 151 | QString mPhoneModel; |
78 | QString mLastSyncedLocalFile; // save! | 152 | QString mLastSyncedLocalFile; // save! |
153 | QString mPassWordPiSync; | ||
154 | QString mActiveSyncPort; | ||
155 | QString mActiveSyncIP ; | ||
79 | 156 | ||
80 | 157 | signals: | |
158 | void save(); | ||
159 | void getFile( bool ); | ||
81 | 160 | ||
82 | public slots: | 161 | public slots: |
83 | void slotSyncMenu( int ); | 162 | void slotSyncMenu( int ); |
84 | 163 | ||
85 | private: | 164 | private: |
86 | // LR ******************************* | 165 | // LR ******************************* |
87 | // sync stuff! | 166 | // sync stuff! |
167 | void syncPi(); | ||
168 | void deleteCommandSocket(KCommandSocket*s, int state); | ||
169 | void readFileFromSocket(); | ||
170 | KServerSocket * mServerSocket; | ||
171 | void enableQuick(); | ||
172 | KPimPrefs* mPrefs; | ||
173 | QString mDefFileName; | ||
88 | QString mCurrentSyncDevice; | 174 | QString mCurrentSyncDevice; |
89 | QString mCurrentSyncName; | 175 | QString mCurrentSyncName; |
90 | void quickSyncLocalFile(); | 176 | void quickSyncLocalFile(); |
91 | bool syncWithFile( QString fn , bool quick ); | 177 | bool syncWithFile( QString fn , bool quick ); |
92 | void syncLocalFile(); | 178 | void syncLocalFile(); |
93 | void syncPhone(); | 179 | void syncPhone(); |
94 | void syncSharp(); | 180 | void syncSharp(); |
95 | bool syncExternalApplication(QString); | 181 | bool syncExternalApplication(QString); |
96 | void multiSync( bool askforPrefs ); | 182 | void multiSync( bool askforPrefs ); |
97 | int mCurrentSyncProfile ; | 183 | int mCurrentSyncProfile ; |
98 | void syncRemote( KSyncProfile* prof, bool ask = true); | 184 | void syncRemote( KSyncProfile* prof, bool ask = true); |
99 | void edit_sync_options(); | 185 | void edit_sync_options(); |
100 | int ringSync(); | 186 | int ringSync(); |
101 | QString getPassword( ); | 187 | QString getPassword( ); |
102 | 188 | ||
103 | private slots: | 189 | private slots: |
104 | void confSync(); | 190 | void confSync(); |
105 | // ********************* | 191 | // ********************* |
106 | 192 | ||
107 | private: | 193 | private: |
108 | bool mBlockSaveFlag; | 194 | bool mBlockSaveFlag; |
109 | 195 | ||
110 | 196 | ||
111 | QWidget* mParent; | 197 | QWidget* mParent; |
112 | KSyncInterface* mImplementation; | 198 | KSyncInterface* mImplementation; |
113 | TargetApp mTargetApp; | 199 | TargetApp mTargetApp; |
114 | QPopupMenu* mSyncMenu; | 200 | QPopupMenu* mSyncMenu; |
115 | 201 | ||
116 | QProgressBar* bar; | 202 | QProgressBar* bar; |
117 | 203 | ||
118 | 204 | ||
119 | 205 | ||
120 | 206 | ||
121 | 207 | ||
122 | }; | 208 | }; |
123 | 209 | ||
124 | 210 | ||
125 | class KSyncInterface | 211 | class KSyncInterface |
126 | { | 212 | { |
127 | public: | 213 | |
214 | |||
215 | public : | ||
128 | virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; | 216 | virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; |
129 | 217 | ||
130 | virtual bool syncExternal(KSyncManager* manager, QString resource) | 218 | virtual bool syncExternal(KSyncManager* manager, QString resource) |
131 | { | 219 | { |
132 | // empty implementation, because some syncable applications do not have an external(sharpdtm) syncmode, like pwmanager. | 220 | // empty implementation, because some syncable applications do not have an external(sharpdtm) syncmode, like pwmanager. |
133 | return false; | 221 | return false; |
134 | } | 222 | } |
135 | 223 | ||
136 | //called by the syncmanager to indicate that the work has to be marked as dirty. | 224 | |
137 | virtual void sync_setModified() = 0; | ||
138 | |||
139 | //called by the syncmanager to ask if the dirty flag is set. | ||
140 | virtual bool sync_isModified() = 0; | ||
141 | |||
142 | //called by the syncmanager to indicate that the work has to be saved. | ||
143 | virtual void sync_save() = 0; | ||
144 | }; | 225 | }; |
145 | 226 | ||
146 | 227 | ||
147 | #endif | 228 | #endif |