-rw-r--r-- | kaddressbook/kabcore.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index e56e46a..2f00a09 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1,2916 +1,2916 @@ | |||
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 | 207 | ||
208 | bool pasteWithNewUid = true; | 208 | bool pasteWithNewUid = true; |
209 | 209 | ||
210 | #ifdef KAB_EMBEDDED | 210 | #ifdef KAB_EMBEDDED |
211 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 211 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) |
212 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 212 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
213 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ | 213 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ |
214 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) | 214 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) |
215 | #else //KAB_EMBEDDED | 215 | #else //KAB_EMBEDDED |
216 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 216 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) |
217 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 217 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
218 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), | 218 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), |
219 | mReadWrite( readWrite ), mModified( false ) | 219 | mReadWrite( readWrite ), mModified( false ) |
220 | #endif //KAB_EMBEDDED | 220 | #endif //KAB_EMBEDDED |
221 | { | 221 | { |
222 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 222 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
223 | // syncManager->setBlockSave(false); | 223 | // syncManager->setBlockSave(false); |
224 | mExtensionBarSplitter = 0; | 224 | mExtensionBarSplitter = 0; |
225 | mIsPart = !parent->inherits( "KAddressBookMain" ); | 225 | mIsPart = !parent->inherits( "KAddressBookMain" ); |
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 | 310 | ||
311 | mMessageTimer = new QTimer( this ); | 311 | mMessageTimer = new QTimer( this ); |
312 | connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); | 312 | connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); |
313 | mEditorDialog = 0; | 313 | mEditorDialog = 0; |
314 | createAddresseeEditorDialog( this ); | 314 | createAddresseeEditorDialog( this ); |
315 | setModified( false ); | 315 | setModified( false ); |
316 | mBRdisabled = 0; | 316 | mBRdisabled = false; |
317 | #ifndef DESKTOP_VERSION | 317 | #ifndef DESKTOP_VERSION |
318 | infrared = 0; | 318 | infrared = 0; |
319 | #endif | 319 | #endif |
320 | toggleBeamReceive( ); | 320 | //toggleBeamReceive( ); |
321 | } | 321 | } |
322 | 322 | ||
323 | KABCore::~KABCore() | 323 | KABCore::~KABCore() |
324 | { | 324 | { |
325 | // save(); | 325 | // save(); |
326 | //saveSettings(); | 326 | //saveSettings(); |
327 | //KABPrefs::instance()->writeConfig(); | 327 | //KABPrefs::instance()->writeConfig(); |
328 | delete AddresseeConfig::instance(); | 328 | delete AddresseeConfig::instance(); |
329 | mAddressBook = 0; | 329 | mAddressBook = 0; |
330 | KABC::StdAddressBook::close(); | 330 | KABC::StdAddressBook::close(); |
331 | 331 | ||
332 | delete syncManager; | 332 | delete syncManager; |
333 | #ifndef DESKTOP_VERSION | 333 | #ifndef DESKTOP_VERSION |
334 | if ( infrared ) | 334 | if ( infrared ) |
335 | delete infrared; | 335 | delete infrared; |
336 | #endif | 336 | #endif |
337 | } | 337 | } |
338 | void KABCore::receive( const QCString& cmsg, const QByteArray& data ) | 338 | void KABCore::receive( const QCString& cmsg, const QByteArray& data ) |
339 | { | 339 | { |
340 | qDebug("KA: QCOP message received: %s ", cmsg.data() ); | 340 | qDebug("KA: QCOP message received: %s ", cmsg.data() ); |
341 | if ( cmsg == "setDocument(QString)" ) { | 341 | if ( cmsg == "setDocument(QString)" ) { |
342 | QDataStream stream( data, IO_ReadOnly ); | 342 | QDataStream stream( data, IO_ReadOnly ); |
343 | QString fileName; | 343 | QString fileName; |
344 | stream >> fileName; | 344 | stream >> fileName; |
345 | recieve( fileName ); | 345 | recieve( fileName ); |
346 | return; | 346 | return; |
347 | } | 347 | } |
348 | } | 348 | } |
349 | void KABCore::toggleBeamReceive( ) | 349 | void KABCore::toggleBeamReceive( ) |
350 | { | 350 | { |
351 | if ( mBRdisabled ) | 351 | if ( mBRdisabled ) |
352 | return; | 352 | return; |
353 | #ifndef DESKTOP_VERSION | 353 | #ifndef DESKTOP_VERSION |
354 | if ( infrared ) { | 354 | if ( infrared ) { |
355 | qDebug("AB disable BeamReceive "); | 355 | qDebug("AB disable BeamReceive "); |
356 | delete infrared; | 356 | delete infrared; |
357 | infrared = 0; | 357 | infrared = 0; |
358 | mActionBR->setChecked(false); | 358 | mActionBR->setChecked(false); |
359 | return; | 359 | return; |
360 | } | 360 | } |
361 | qDebug("AB enable BeamReceive "); | 361 | qDebug("AB enable BeamReceive "); |
362 | mActionBR->setChecked(true); | 362 | mActionBR->setChecked(true); |
363 | 363 | ||
364 | infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; | 364 | infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; |
365 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); | 365 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); |
366 | #endif | 366 | #endif |
367 | } | 367 | } |
368 | 368 | ||
369 | 369 | ||
370 | void KABCore::disableBR(bool b) | 370 | void KABCore::disableBR(bool b) |
371 | { | 371 | { |
372 | #ifndef DESKTOP_VERSION | 372 | #ifndef DESKTOP_VERSION |
373 | if ( b ) { | 373 | if ( b ) { |
374 | if ( infrared ) { | 374 | if ( infrared ) { |
375 | toggleBeamReceive( ); | 375 | toggleBeamReceive( ); |
376 | } | 376 | } |
377 | mBRdisabled = true; | 377 | mBRdisabled = true; |
378 | } else { | 378 | } else { |
379 | if ( mBRdisabled ) { | 379 | if ( mBRdisabled ) { |
380 | mBRdisabled = false; | 380 | mBRdisabled = false; |
381 | //toggleBeamReceive( ); | 381 | //toggleBeamReceive( ); |
382 | } | 382 | } |
383 | } | 383 | } |
384 | #endif | 384 | #endif |
385 | 385 | ||
386 | } | 386 | } |
387 | void KABCore::recieve( QString fn ) | 387 | void KABCore::recieve( QString fn ) |
388 | { | 388 | { |
389 | //qDebug("KABCore::recieve "); | 389 | //qDebug("KABCore::recieve "); |
390 | int count = mAddressBook->importFromFile( fn, true ); | 390 | int count = mAddressBook->importFromFile( fn, true ); |
391 | if ( count ) | 391 | if ( count ) |
392 | setModified( true ); | 392 | setModified( true ); |
393 | mViewManager->refreshView(); | 393 | mViewManager->refreshView(); |
394 | message(i18n("%1 contact(s) received!").arg( count )); | 394 | message(i18n("%1 contact(s) received!").arg( count )); |
395 | topLevelWidget()->showMaximized(); | 395 | topLevelWidget()->showMaximized(); |
396 | topLevelWidget()->raise(); | 396 | topLevelWidget()->raise(); |
397 | } | 397 | } |
398 | void KABCore::restoreSettings() | 398 | void KABCore::restoreSettings() |
399 | { | 399 | { |
400 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; | 400 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; |
401 | 401 | ||
402 | bool state; | 402 | bool state; |
403 | 403 | ||
404 | if (mMultipleViewsAtOnce) | 404 | if (mMultipleViewsAtOnce) |
405 | state = KABPrefs::instance()->mDetailsPageVisible; | 405 | state = KABPrefs::instance()->mDetailsPageVisible; |
406 | else | 406 | else |
407 | state = false; | 407 | state = false; |
408 | 408 | ||
409 | mActionDetails->setChecked( state ); | 409 | mActionDetails->setChecked( state ); |
410 | setDetailsVisible( state ); | 410 | setDetailsVisible( state ); |
411 | 411 | ||
412 | state = KABPrefs::instance()->mJumpButtonBarVisible; | 412 | state = KABPrefs::instance()->mJumpButtonBarVisible; |
413 | 413 | ||
414 | mActionJumpBar->setChecked( state ); | 414 | mActionJumpBar->setChecked( state ); |
415 | setJumpButtonBarVisible( state ); | 415 | setJumpButtonBarVisible( state ); |
416 | /*US | 416 | /*US |
417 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 417 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
418 | if ( splitterSize.count() == 0 ) { | 418 | if ( splitterSize.count() == 0 ) { |
419 | splitterSize.append( width() / 2 ); | 419 | splitterSize.append( width() / 2 ); |
420 | splitterSize.append( width() / 2 ); | 420 | splitterSize.append( width() / 2 ); |
421 | } | 421 | } |
422 | mMiniSplitter->setSizes( splitterSize ); | 422 | mMiniSplitter->setSizes( splitterSize ); |
423 | if ( mExtensionBarSplitter ) { | 423 | if ( mExtensionBarSplitter ) { |
424 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 424 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
425 | if ( splitterSize.count() == 0 ) { | 425 | if ( splitterSize.count() == 0 ) { |
426 | splitterSize.append( width() / 2 ); | 426 | splitterSize.append( width() / 2 ); |
427 | splitterSize.append( width() / 2 ); | 427 | splitterSize.append( width() / 2 ); |
428 | } | 428 | } |
429 | mExtensionBarSplitter->setSizes( splitterSize ); | 429 | mExtensionBarSplitter->setSizes( splitterSize ); |
430 | 430 | ||
431 | } | 431 | } |
432 | */ | 432 | */ |
433 | mViewManager->restoreSettings(); | 433 | mViewManager->restoreSettings(); |
434 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 434 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
435 | mExtensionManager->restoreSettings(); | 435 | mExtensionManager->restoreSettings(); |
436 | #ifdef DESKTOP_VERSION | 436 | #ifdef DESKTOP_VERSION |
437 | int wid = width(); | 437 | int wid = width(); |
438 | if ( wid < 10 ) | 438 | if ( wid < 10 ) |
439 | wid = 400; | 439 | wid = 400; |
440 | #else | 440 | #else |
441 | int wid = QApplication::desktop()->width(); | 441 | int wid = QApplication::desktop()->width(); |
442 | if ( wid < 640 ) | 442 | if ( wid < 640 ) |
443 | wid = QApplication::desktop()->height(); | 443 | wid = QApplication::desktop()->height(); |
444 | #endif | 444 | #endif |
445 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; | 445 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; |
446 | if ( true /*splitterSize.count() == 0*/ ) { | 446 | if ( true /*splitterSize.count() == 0*/ ) { |
447 | splitterSize.append( wid / 2 ); | 447 | splitterSize.append( wid / 2 ); |
448 | splitterSize.append( wid / 2 ); | 448 | splitterSize.append( wid / 2 ); |
449 | } | 449 | } |
450 | mMiniSplitter->setSizes( splitterSize ); | 450 | mMiniSplitter->setSizes( splitterSize ); |
451 | if ( mExtensionBarSplitter ) { | 451 | if ( mExtensionBarSplitter ) { |
452 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 452 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
453 | if ( true /*splitterSize.count() == 0*/ ) { | 453 | if ( true /*splitterSize.count() == 0*/ ) { |
454 | splitterSize.append( wid / 2 ); | 454 | splitterSize.append( wid / 2 ); |
455 | splitterSize.append( wid / 2 ); | 455 | splitterSize.append( wid / 2 ); |
456 | } | 456 | } |
457 | mExtensionBarSplitter->setSizes( splitterSize ); | 457 | mExtensionBarSplitter->setSizes( splitterSize ); |
458 | 458 | ||
459 | } | 459 | } |
460 | 460 | ||
461 | 461 | ||
462 | } | 462 | } |
463 | 463 | ||
464 | void KABCore::saveSettings() | 464 | void KABCore::saveSettings() |
465 | { | 465 | { |
466 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | 466 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); |
467 | if ( mExtensionBarSplitter ) | 467 | if ( mExtensionBarSplitter ) |
468 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 468 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
469 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | 469 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); |
470 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); | 470 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); |
471 | #ifndef KAB_EMBEDDED | 471 | #ifndef KAB_EMBEDDED |
472 | 472 | ||
473 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 473 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
474 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | 474 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); |
475 | #endif //KAB_EMBEDDED | 475 | #endif //KAB_EMBEDDED |
476 | mExtensionManager->saveSettings(); | 476 | mExtensionManager->saveSettings(); |
477 | mViewManager->saveSettings(); | 477 | mViewManager->saveSettings(); |
478 | 478 | ||
479 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 479 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
480 | } | 480 | } |
481 | 481 | ||
482 | KABC::AddressBook *KABCore::addressBook() const | 482 | KABC::AddressBook *KABCore::addressBook() const |
483 | { | 483 | { |
484 | return mAddressBook; | 484 | return mAddressBook; |
485 | } | 485 | } |
486 | 486 | ||
487 | KConfig *KABCore::config() | 487 | KConfig *KABCore::config() |
488 | { | 488 | { |
489 | #ifndef KAB_EMBEDDED | 489 | #ifndef KAB_EMBEDDED |
490 | return KABPrefs::instance()->config(); | 490 | return KABPrefs::instance()->config(); |
491 | #else //KAB_EMBEDDED | 491 | #else //KAB_EMBEDDED |
492 | return KABPrefs::instance()->getConfig(); | 492 | return KABPrefs::instance()->getConfig(); |
493 | #endif //KAB_EMBEDDED | 493 | #endif //KAB_EMBEDDED |
494 | } | 494 | } |
495 | 495 | ||
496 | KActionCollection *KABCore::actionCollection() const | 496 | KActionCollection *KABCore::actionCollection() const |
497 | { | 497 | { |
498 | return mGUIClient->actionCollection(); | 498 | return mGUIClient->actionCollection(); |
499 | } | 499 | } |
500 | 500 | ||
501 | KABC::Field *KABCore::currentSearchField() const | 501 | KABC::Field *KABCore::currentSearchField() const |
502 | { | 502 | { |
503 | if (mIncSearchWidget) | 503 | if (mIncSearchWidget) |
504 | return mIncSearchWidget->currentField(); | 504 | return mIncSearchWidget->currentField(); |
505 | else | 505 | else |
506 | return 0; | 506 | return 0; |
507 | } | 507 | } |
508 | 508 | ||
509 | QStringList KABCore::selectedUIDs() const | 509 | QStringList KABCore::selectedUIDs() const |
510 | { | 510 | { |
511 | return mViewManager->selectedUids(); | 511 | return mViewManager->selectedUids(); |
512 | } | 512 | } |
513 | 513 | ||
514 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 514 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
515 | { | 515 | { |
516 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 516 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
517 | 517 | ||
518 | QPtrList<KRES::Resource> kresResources; | 518 | QPtrList<KRES::Resource> kresResources; |
519 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 519 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
520 | KABC::Resource *resource; | 520 | KABC::Resource *resource; |
521 | while ( ( resource = resIt.current() ) != 0 ) { | 521 | while ( ( resource = resIt.current() ) != 0 ) { |
522 | ++resIt; | 522 | ++resIt; |
523 | if ( !resource->readOnly() ) { | 523 | if ( !resource->readOnly() ) { |
524 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 524 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
525 | if ( res ) | 525 | if ( res ) |
526 | kresResources.append( res ); | 526 | kresResources.append( res ); |
527 | } | 527 | } |
528 | } | 528 | } |
529 | 529 | ||
530 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 530 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
531 | return static_cast<KABC::Resource*>( res ); | 531 | return static_cast<KABC::Resource*>( res ); |
532 | } | 532 | } |
533 | 533 | ||
534 | #ifndef KAB_EMBEDDED | 534 | #ifndef KAB_EMBEDDED |
535 | KAboutData *KABCore::createAboutData() | 535 | KAboutData *KABCore::createAboutData() |
536 | #else //KAB_EMBEDDED | 536 | #else //KAB_EMBEDDED |
537 | void KABCore::createAboutData() | 537 | void KABCore::createAboutData() |
538 | #endif //KAB_EMBEDDED | 538 | #endif //KAB_EMBEDDED |
539 | { | 539 | { |
540 | #ifndef KAB_EMBEDDED | 540 | #ifndef KAB_EMBEDDED |
541 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), | 541 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), |
542 | "3.1", I18N_NOOP( "The KDE Address Book" ), | 542 | "3.1", I18N_NOOP( "The KDE Address Book" ), |
543 | KAboutData::License_GPL_V2, | 543 | KAboutData::License_GPL_V2, |
544 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); | 544 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); |
545 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); | 545 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); |
546 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); | 546 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); |
547 | about->addAuthor( "Cornelius Schumacher", | 547 | about->addAuthor( "Cornelius Schumacher", |
548 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | 548 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), |
549 | "schumacher@kde.org" ); | 549 | "schumacher@kde.org" ); |
550 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | 550 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), |
551 | "mpilone@slac.com" ); | 551 | "mpilone@slac.com" ); |
552 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | 552 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); |
553 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | 553 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); |
554 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | 554 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), |
555 | "michel@klaralvdalens-datakonsult.se" ); | 555 | "michel@klaralvdalens-datakonsult.se" ); |
556 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | 556 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), |
557 | "hansen@kde.org" ); | 557 | "hansen@kde.org" ); |
558 | 558 | ||
559 | return about; | 559 | return about; |
560 | #endif //KAB_EMBEDDED | 560 | #endif //KAB_EMBEDDED |
561 | 561 | ||
562 | QString version; | 562 | QString version; |
563 | #include <../version> | 563 | #include <../version> |
564 | QMessageBox::about( this, "About KAddressbook/Pi", | 564 | QMessageBox::about( this, "About KAddressbook/Pi", |
565 | "KAddressbook/Platform-independent\n" | 565 | "KAddressbook/Platform-independent\n" |
566 | "(KA/Pi) " +version + " - " + | 566 | "(KA/Pi) " +version + " - " + |
567 | #ifdef DESKTOP_VERSION | 567 | #ifdef DESKTOP_VERSION |
568 | "Desktop Edition\n" | 568 | "Desktop Edition\n" |
569 | #else | 569 | #else |
570 | "PDA-Edition\n" | 570 | "PDA-Edition\n" |
571 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 571 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
572 | #endif | 572 | #endif |
573 | 573 | ||
574 | "(c) 2004 Ulf Schenk\n" | 574 | "(c) 2004 Ulf Schenk\n" |
575 | "(c) 2004 Lutz Rogowski\n" | 575 | "(c) 2004 Lutz Rogowski\n" |
576 | "(c) 1997-2003, The KDE PIM Team\n" | 576 | "(c) 1997-2003, The KDE PIM Team\n" |
577 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" | 577 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" |
578 | "Don Sanders Original author\n" | 578 | "Don Sanders Original author\n" |
579 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" | 579 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" |
580 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" | 580 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" |
581 | "Greg Stern DCOP interface\n" | 581 | "Greg Stern DCOP interface\n" |
582 | "Mark Westcot Contact pinning\n" | 582 | "Mark Westcot Contact pinning\n" |
583 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" | 583 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" |
584 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" | 584 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" |
585 | #ifdef _WIN32_ | 585 | #ifdef _WIN32_ |
586 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" | 586 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" |
587 | #endif | 587 | #endif |
588 | ); | 588 | ); |
589 | } | 589 | } |
590 | 590 | ||
591 | void KABCore::setContactSelected( const QString &uid ) | 591 | void KABCore::setContactSelected( const QString &uid ) |
592 | { | 592 | { |
593 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 593 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
594 | if ( !mDetails->isHidden() ) | 594 | if ( !mDetails->isHidden() ) |
595 | mDetails->setAddressee( addr ); | 595 | mDetails->setAddressee( addr ); |
596 | 596 | ||
597 | if ( !addr.isEmpty() ) { | 597 | if ( !addr.isEmpty() ) { |
598 | emit contactSelected( addr.formattedName() ); | 598 | emit contactSelected( addr.formattedName() ); |
599 | KABC::Picture pic = addr.photo(); | 599 | KABC::Picture pic = addr.photo(); |
600 | if ( pic.isIntern() ) { | 600 | if ( pic.isIntern() ) { |
601 | //US emit contactSelected( pic.data() ); | 601 | //US emit contactSelected( pic.data() ); |
602 | //US instead use: | 602 | //US instead use: |
603 | QPixmap px; | 603 | QPixmap px; |
604 | if (pic.data().isNull() != true) | 604 | if (pic.data().isNull() != true) |
605 | { | 605 | { |
606 | px.convertFromImage(pic.data()); | 606 | px.convertFromImage(pic.data()); |
607 | } | 607 | } |
608 | 608 | ||
609 | emit contactSelected( px ); | 609 | emit contactSelected( px ); |
610 | } | 610 | } |
611 | } | 611 | } |
612 | 612 | ||
613 | 613 | ||
614 | mExtensionManager->setSelectionChanged(); | 614 | mExtensionManager->setSelectionChanged(); |
615 | 615 | ||
616 | // update the actions | 616 | // update the actions |
617 | bool selected = !uid.isEmpty(); | 617 | bool selected = !uid.isEmpty(); |
618 | 618 | ||
619 | if ( mReadWrite ) { | 619 | if ( mReadWrite ) { |
620 | mActionCut->setEnabled( selected ); | 620 | mActionCut->setEnabled( selected ); |
621 | mActionPaste->setEnabled( selected ); | 621 | mActionPaste->setEnabled( selected ); |
622 | } | 622 | } |
623 | 623 | ||
624 | mActionCopy->setEnabled( selected ); | 624 | mActionCopy->setEnabled( selected ); |
625 | mActionDelete->setEnabled( selected ); | 625 | mActionDelete->setEnabled( selected ); |
626 | mActionEditAddressee->setEnabled( selected ); | 626 | mActionEditAddressee->setEnabled( selected ); |
627 | mActionMail->setEnabled( selected ); | 627 | mActionMail->setEnabled( selected ); |
628 | mActionMailVCard->setEnabled( selected ); | 628 | mActionMailVCard->setEnabled( selected ); |
629 | //if (mActionBeam) | 629 | //if (mActionBeam) |
630 | //mActionBeam->setEnabled( selected ); | 630 | //mActionBeam->setEnabled( selected ); |
631 | 631 | ||
632 | if (mActionBeamVCard) | 632 | if (mActionBeamVCard) |
633 | mActionBeamVCard->setEnabled( selected ); | 633 | mActionBeamVCard->setEnabled( selected ); |
634 | 634 | ||
635 | mActionExport2phone->setEnabled( selected ); | 635 | mActionExport2phone->setEnabled( selected ); |
636 | mActionWhoAmI->setEnabled( selected ); | 636 | mActionWhoAmI->setEnabled( selected ); |
637 | mActionCategories->setEnabled( selected ); | 637 | mActionCategories->setEnabled( selected ); |
638 | } | 638 | } |
639 | 639 | ||
640 | void KABCore::sendMail() | 640 | void KABCore::sendMail() |
641 | { | 641 | { |
642 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 642 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
643 | } | 643 | } |
644 | 644 | ||
645 | void KABCore::sendMail( const QString& emaillist ) | 645 | void KABCore::sendMail( const QString& emaillist ) |
646 | { | 646 | { |
647 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " | 647 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " |
648 | if (emaillist.contains(",") > 0) | 648 | if (emaillist.contains(",") > 0) |
649 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); | 649 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); |
650 | else | 650 | else |
651 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); | 651 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); |
652 | } | 652 | } |
653 | 653 | ||
654 | 654 | ||
655 | 655 | ||
656 | void KABCore::mailVCard() | 656 | void KABCore::mailVCard() |
657 | { | 657 | { |
658 | QStringList uids = mViewManager->selectedUids(); | 658 | QStringList uids = mViewManager->selectedUids(); |
659 | if ( !uids.isEmpty() ) | 659 | if ( !uids.isEmpty() ) |
660 | mailVCard( uids ); | 660 | mailVCard( uids ); |
661 | } | 661 | } |
662 | 662 | ||
663 | void KABCore::mailVCard( const QStringList& uids ) | 663 | void KABCore::mailVCard( const QStringList& uids ) |
664 | { | 664 | { |
665 | QStringList urls; | 665 | QStringList urls; |
666 | 666 | ||
667 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 667 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
668 | 668 | ||
669 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); | 669 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); |
670 | 670 | ||
671 | 671 | ||
672 | 672 | ||
673 | QDir().mkdir( dirName, true ); | 673 | QDir().mkdir( dirName, true ); |
674 | 674 | ||
675 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 675 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
676 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 676 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
677 | 677 | ||
678 | if ( a.isEmpty() ) | 678 | if ( a.isEmpty() ) |
679 | continue; | 679 | continue; |
680 | 680 | ||
681 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 681 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
682 | 682 | ||
683 | QString fileName = dirName + "/" + name; | 683 | QString fileName = dirName + "/" + name; |
684 | 684 | ||
685 | QFile outFile(fileName); | 685 | QFile outFile(fileName); |
686 | 686 | ||
687 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 687 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
688 | KABC::VCardConverter converter; | 688 | KABC::VCardConverter converter; |
689 | QString vcard; | 689 | QString vcard; |
690 | 690 | ||
691 | converter.addresseeToVCard( a, vcard ); | 691 | converter.addresseeToVCard( a, vcard ); |
692 | 692 | ||
693 | QTextStream t( &outFile ); // use a text stream | 693 | QTextStream t( &outFile ); // use a text stream |
694 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 694 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
695 | t << vcard; | 695 | t << vcard; |
696 | 696 | ||
697 | outFile.close(); | 697 | outFile.close(); |
698 | 698 | ||
699 | urls.append( fileName ); | 699 | urls.append( fileName ); |
700 | } | 700 | } |
701 | } | 701 | } |
702 | 702 | ||
703 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); | 703 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
704 | 704 | ||
705 | 705 | ||
706 | /*US | 706 | /*US |
707 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 707 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
708 | QString::null, // subject | 708 | QString::null, // subject |
709 | QString::null, // body | 709 | QString::null, // body |
710 | QString::null, | 710 | QString::null, |
711 | urls ); // attachments | 711 | urls ); // attachments |
712 | */ | 712 | */ |
713 | 713 | ||
714 | } | 714 | } |
715 | 715 | ||
716 | /** | 716 | /** |
717 | Beams the "WhoAmI contact. | 717 | Beams the "WhoAmI contact. |
718 | */ | 718 | */ |
719 | void KABCore::beamMySelf() | 719 | void KABCore::beamMySelf() |
720 | { | 720 | { |
721 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 721 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
722 | if (!a.isEmpty()) | 722 | if (!a.isEmpty()) |
723 | { | 723 | { |
724 | QStringList uids; | 724 | QStringList uids; |
725 | uids << a.uid(); | 725 | uids << a.uid(); |
726 | 726 | ||
727 | beamVCard(uids); | 727 | beamVCard(uids); |
728 | } else { | 728 | } else { |
729 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 729 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
730 | 730 | ||
731 | 731 | ||
732 | } | 732 | } |
733 | } | 733 | } |
734 | 734 | ||
735 | void KABCore::export2phone() | 735 | void KABCore::export2phone() |
736 | { | 736 | { |
737 | 737 | ||
738 | KAex2phonePrefs ex2phone; | 738 | KAex2phonePrefs ex2phone; |
739 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 739 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
740 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 740 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
741 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 741 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
742 | 742 | ||
743 | if ( !ex2phone.exec() ) { | 743 | if ( !ex2phone.exec() ) { |
744 | return; | 744 | return; |
745 | } | 745 | } |
746 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 746 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
747 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 747 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
748 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 748 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
749 | 749 | ||
750 | 750 | ||
751 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 751 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
752 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 752 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
753 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 753 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
754 | 754 | ||
755 | QStringList uids = mViewManager->selectedUids(); | 755 | QStringList uids = mViewManager->selectedUids(); |
756 | if ( uids.isEmpty() ) | 756 | if ( uids.isEmpty() ) |
757 | return; | 757 | return; |
758 | 758 | ||
759 | QString fileName = getPhoneFile(); | 759 | QString fileName = getPhoneFile(); |
760 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) | 760 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) |
761 | return; | 761 | return; |
762 | 762 | ||
763 | message(i18n("Exporting to phone...")); | 763 | message(i18n("Exporting to phone...")); |
764 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); | 764 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); |
765 | 765 | ||
766 | } | 766 | } |
767 | QString KABCore::getPhoneFile() | 767 | QString KABCore::getPhoneFile() |
768 | { | 768 | { |
769 | #ifdef DESKTOP_VERSION | 769 | #ifdef DESKTOP_VERSION |
770 | return locateLocal("tmp", "phonefile.vcf"); | 770 | return locateLocal("tmp", "phonefile.vcf"); |
771 | #else | 771 | #else |
772 | return "/tmp/phonefile.vcf"; | 772 | return "/tmp/phonefile.vcf"; |
773 | #endif | 773 | #endif |
774 | 774 | ||
775 | } | 775 | } |
776 | void KABCore::writeToPhone( ) | 776 | void KABCore::writeToPhone( ) |
777 | { | 777 | { |
778 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) | 778 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) |
779 | message(i18n("Export to phone finished!")); | 779 | message(i18n("Export to phone finished!")); |
780 | else | 780 | else |
781 | qDebug(i18n("Error exporting to phone")); | 781 | qDebug(i18n("Error exporting to phone")); |
782 | } | 782 | } |
783 | void KABCore::beamVCard() | 783 | void KABCore::beamVCard() |
784 | { | 784 | { |
785 | QStringList uids = mViewManager->selectedUids(); | 785 | QStringList uids = mViewManager->selectedUids(); |
786 | if ( !uids.isEmpty() ) | 786 | if ( !uids.isEmpty() ) |
787 | beamVCard( uids ); | 787 | beamVCard( uids ); |
788 | } | 788 | } |
789 | 789 | ||
790 | 790 | ||
791 | void KABCore::beamVCard(const QStringList& uids) | 791 | void KABCore::beamVCard(const QStringList& uids) |
792 | { | 792 | { |
793 | 793 | ||
794 | // LR: we should use the /tmp dir on the Zaurus, | 794 | // LR: we should use the /tmp dir on the Zaurus, |
795 | // because: /tmp = RAM, (HOME)/kdepim = flash memory | 795 | // because: /tmp = RAM, (HOME)/kdepim = flash memory |
796 | 796 | ||
797 | #ifdef DESKTOP_VERSION | 797 | #ifdef DESKTOP_VERSION |
798 | QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); | 798 | QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); |
799 | #else | 799 | #else |
800 | QString fileName = "/tmp/kapibeamfile.vcf"; | 800 | QString fileName = "/tmp/kapibeamfile.vcf"; |
801 | #endif | 801 | #endif |
802 | 802 | ||
803 | KABC::VCardConverter converter; | 803 | KABC::VCardConverter converter; |
804 | QString description; | 804 | QString description; |
805 | QString datastream; | 805 | QString datastream; |
806 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 806 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
807 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 807 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
808 | 808 | ||
809 | if ( a.isEmpty() ) | 809 | if ( a.isEmpty() ) |
810 | continue; | 810 | continue; |
811 | 811 | ||
812 | if (description.isEmpty()) | 812 | if (description.isEmpty()) |
813 | description = a.formattedName(); | 813 | description = a.formattedName(); |
814 | 814 | ||
815 | QString vcard; | 815 | QString vcard; |
816 | converter.addresseeToVCard( a, vcard ); | 816 | converter.addresseeToVCard( a, vcard ); |
817 | int start = 0; | 817 | int start = 0; |
818 | int next; | 818 | int next; |
819 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 819 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
820 | int semi = vcard.find(";", next); | 820 | int semi = vcard.find(";", next); |
821 | int dopp = vcard.find(":", next); | 821 | int dopp = vcard.find(":", next); |
822 | int sep; | 822 | int sep; |
823 | if ( semi < dopp && semi >= 0 ) | 823 | if ( semi < dopp && semi >= 0 ) |
824 | sep = semi ; | 824 | sep = semi ; |
825 | else | 825 | else |
826 | sep = dopp; | 826 | sep = dopp; |
827 | datastream +=vcard.mid( start, next - start); | 827 | datastream +=vcard.mid( start, next - start); |
828 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | 828 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); |
829 | start = sep; | 829 | start = sep; |
830 | } | 830 | } |
831 | datastream += vcard.mid( start,vcard.length() ); | 831 | datastream += vcard.mid( start,vcard.length() ); |
832 | } | 832 | } |
833 | #ifndef DESKTOP_VERSION | 833 | #ifndef DESKTOP_VERSION |
834 | QFile outFile(fileName); | 834 | QFile outFile(fileName); |
835 | if ( outFile.open(IO_WriteOnly) ) { | 835 | if ( outFile.open(IO_WriteOnly) ) { |
836 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 836 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
837 | QTextStream t( &outFile ); // use a text stream | 837 | QTextStream t( &outFile ); // use a text stream |
838 | //t.setEncoding( QTextStream::UnicodeUTF8 ); | 838 | //t.setEncoding( QTextStream::UnicodeUTF8 ); |
839 | t.setEncoding( QTextStream::Latin1 ); | 839 | t.setEncoding( QTextStream::Latin1 ); |
840 | t <<datastream.latin1(); | 840 | t <<datastream.latin1(); |
841 | outFile.close(); | 841 | outFile.close(); |
842 | Ir *ir = new Ir( this ); | 842 | Ir *ir = new Ir( this ); |
843 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 843 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
844 | ir->send( fileName, description, "text/x-vCard" ); | 844 | ir->send( fileName, description, "text/x-vCard" ); |
845 | } else { | 845 | } else { |
846 | qDebug("Error open temp beam file "); | 846 | qDebug("Error open temp beam file "); |
847 | return; | 847 | return; |
848 | } | 848 | } |
849 | #endif | 849 | #endif |
850 | 850 | ||
851 | } | 851 | } |
852 | 852 | ||
853 | void KABCore::beamDone( Ir *ir ) | 853 | void KABCore::beamDone( Ir *ir ) |
854 | { | 854 | { |
855 | #ifndef DESKTOP_VERSION | 855 | #ifndef DESKTOP_VERSION |
856 | delete ir; | 856 | delete ir; |
857 | #endif | 857 | #endif |
858 | topLevelWidget()->raise(); | 858 | topLevelWidget()->raise(); |
859 | message( i18n("Beaming finished!") ); | 859 | message( i18n("Beaming finished!") ); |
860 | } | 860 | } |
861 | 861 | ||
862 | 862 | ||
863 | void KABCore::browse( const QString& url ) | 863 | void KABCore::browse( const QString& url ) |
864 | { | 864 | { |
865 | #ifndef KAB_EMBEDDED | 865 | #ifndef KAB_EMBEDDED |
866 | kapp->invokeBrowser( url ); | 866 | kapp->invokeBrowser( url ); |
867 | #else //KAB_EMBEDDED | 867 | #else //KAB_EMBEDDED |
868 | qDebug("KABCore::browse must be fixed"); | 868 | qDebug("KABCore::browse must be fixed"); |
869 | #endif //KAB_EMBEDDED | 869 | #endif //KAB_EMBEDDED |
870 | } | 870 | } |
871 | 871 | ||
872 | void KABCore::selectAllContacts() | 872 | void KABCore::selectAllContacts() |
873 | { | 873 | { |
874 | mViewManager->setSelected( QString::null, true ); | 874 | mViewManager->setSelected( QString::null, true ); |
875 | } | 875 | } |
876 | 876 | ||
877 | void KABCore::deleteContacts() | 877 | void KABCore::deleteContacts() |
878 | { | 878 | { |
879 | QStringList uidList = mViewManager->selectedUids(); | 879 | QStringList uidList = mViewManager->selectedUids(); |
880 | deleteContacts( uidList ); | 880 | deleteContacts( uidList ); |
881 | } | 881 | } |
882 | 882 | ||
883 | void KABCore::deleteContacts( const QStringList &uids ) | 883 | void KABCore::deleteContacts( const QStringList &uids ) |
884 | { | 884 | { |
885 | if ( uids.count() > 0 ) { | 885 | if ( uids.count() > 0 ) { |
886 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 886 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
887 | UndoStack::instance()->push( command ); | 887 | UndoStack::instance()->push( command ); |
888 | RedoStack::instance()->clear(); | 888 | RedoStack::instance()->clear(); |
889 | 889 | ||
890 | // now if we deleted anything, refresh | 890 | // now if we deleted anything, refresh |
891 | setContactSelected( QString::null ); | 891 | setContactSelected( QString::null ); |
892 | setModified( true ); | 892 | setModified( true ); |
893 | } | 893 | } |
894 | } | 894 | } |
895 | 895 | ||
896 | void KABCore::copyContacts() | 896 | void KABCore::copyContacts() |
897 | { | 897 | { |
898 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 898 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
899 | 899 | ||
900 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 900 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
901 | 901 | ||
902 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 902 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
903 | 903 | ||
904 | QClipboard *cb = QApplication::clipboard(); | 904 | QClipboard *cb = QApplication::clipboard(); |
905 | cb->setText( clipText ); | 905 | cb->setText( clipText ); |
906 | } | 906 | } |
907 | 907 | ||
908 | void KABCore::cutContacts() | 908 | void KABCore::cutContacts() |
909 | { | 909 | { |
910 | QStringList uidList = mViewManager->selectedUids(); | 910 | QStringList uidList = mViewManager->selectedUids(); |
911 | 911 | ||
912 | //US if ( uidList.size() > 0 ) { | 912 | //US if ( uidList.size() > 0 ) { |
913 | if ( uidList.count() > 0 ) { | 913 | if ( uidList.count() > 0 ) { |
914 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 914 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
915 | UndoStack::instance()->push( command ); | 915 | UndoStack::instance()->push( command ); |
916 | RedoStack::instance()->clear(); | 916 | RedoStack::instance()->clear(); |
917 | 917 | ||
918 | setModified( true ); | 918 | setModified( true ); |
919 | } | 919 | } |
920 | } | 920 | } |
921 | 921 | ||
922 | void KABCore::pasteContacts() | 922 | void KABCore::pasteContacts() |
923 | { | 923 | { |
924 | QClipboard *cb = QApplication::clipboard(); | 924 | QClipboard *cb = QApplication::clipboard(); |
925 | 925 | ||
926 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 926 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
927 | 927 | ||
928 | pasteContacts( list ); | 928 | pasteContacts( list ); |
929 | } | 929 | } |
930 | 930 | ||
931 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 931 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
932 | { | 932 | { |
933 | KABC::Resource *resource = requestResource( this ); | 933 | KABC::Resource *resource = requestResource( this ); |
934 | KABC::Addressee::List::Iterator it; | 934 | KABC::Addressee::List::Iterator it; |
935 | for ( it = list.begin(); it != list.end(); ++it ) | 935 | for ( it = list.begin(); it != list.end(); ++it ) |
936 | (*it).setResource( resource ); | 936 | (*it).setResource( resource ); |
937 | 937 | ||
938 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 938 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
939 | UndoStack::instance()->push( command ); | 939 | UndoStack::instance()->push( command ); |
940 | RedoStack::instance()->clear(); | 940 | RedoStack::instance()->clear(); |
941 | 941 | ||
942 | setModified( true ); | 942 | setModified( true ); |
943 | } | 943 | } |
944 | 944 | ||
945 | void KABCore::setWhoAmI() | 945 | void KABCore::setWhoAmI() |
946 | { | 946 | { |
947 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 947 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
948 | 948 | ||
949 | if ( addrList.count() > 1 ) { | 949 | if ( addrList.count() > 1 ) { |
950 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 950 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
951 | return; | 951 | return; |
952 | } | 952 | } |
953 | 953 | ||
954 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 954 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
955 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | 955 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) |
956 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 956 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
957 | } | 957 | } |
958 | 958 | ||
959 | void KABCore::setCategories() | 959 | void KABCore::setCategories() |
960 | { | 960 | { |
961 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 961 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
962 | if ( !dlg.exec() ) | 962 | if ( !dlg.exec() ) |
963 | return; | 963 | return; |
964 | 964 | ||
965 | bool merge = false; | 965 | bool merge = false; |
966 | QString msg = i18n( "Merge with existing categories?" ); | 966 | QString msg = i18n( "Merge with existing categories?" ); |
967 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 967 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
968 | merge = true; | 968 | merge = true; |
969 | 969 | ||
970 | QStringList categories = dlg.selectedCategories(); | 970 | QStringList categories = dlg.selectedCategories(); |
971 | 971 | ||
972 | QStringList uids = mViewManager->selectedUids(); | 972 | QStringList uids = mViewManager->selectedUids(); |
973 | QStringList::Iterator it; | 973 | QStringList::Iterator it; |
974 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 974 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
975 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 975 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
976 | if ( !addr.isEmpty() ) { | 976 | if ( !addr.isEmpty() ) { |
977 | if ( !merge ) | 977 | if ( !merge ) |
978 | addr.setCategories( categories ); | 978 | addr.setCategories( categories ); |
979 | else { | 979 | else { |
980 | QStringList addrCategories = addr.categories(); | 980 | QStringList addrCategories = addr.categories(); |
981 | QStringList::Iterator catIt; | 981 | QStringList::Iterator catIt; |
982 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 982 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
983 | if ( !addrCategories.contains( *catIt ) ) | 983 | if ( !addrCategories.contains( *catIt ) ) |
984 | addrCategories.append( *catIt ); | 984 | addrCategories.append( *catIt ); |
985 | } | 985 | } |
986 | addr.setCategories( addrCategories ); | 986 | addr.setCategories( addrCategories ); |
987 | } | 987 | } |
988 | 988 | ||
989 | mAddressBook->insertAddressee( addr ); | 989 | mAddressBook->insertAddressee( addr ); |
990 | } | 990 | } |
991 | } | 991 | } |
992 | 992 | ||
993 | if ( uids.count() > 0 ) | 993 | if ( uids.count() > 0 ) |
994 | setModified( true ); | 994 | setModified( true ); |
995 | } | 995 | } |
996 | 996 | ||
997 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 997 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
998 | { | 998 | { |
999 | mIncSearchWidget->setFields( fields ); | 999 | mIncSearchWidget->setFields( fields ); |
1000 | } | 1000 | } |
1001 | 1001 | ||
1002 | void KABCore::incrementalSearch( const QString& text ) | 1002 | void KABCore::incrementalSearch( const QString& text ) |
1003 | { | 1003 | { |
1004 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); | 1004 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); |
1005 | } | 1005 | } |
1006 | 1006 | ||
1007 | void KABCore::setModified() | 1007 | void KABCore::setModified() |
1008 | { | 1008 | { |
1009 | setModified( true ); | 1009 | setModified( true ); |
1010 | } | 1010 | } |
1011 | 1011 | ||
1012 | void KABCore::setModifiedWOrefresh() | 1012 | void KABCore::setModifiedWOrefresh() |
1013 | { | 1013 | { |
1014 | // qDebug("KABCore::setModifiedWOrefresh() "); | 1014 | // qDebug("KABCore::setModifiedWOrefresh() "); |
1015 | mModified = true; | 1015 | mModified = true; |
1016 | mActionSave->setEnabled( mModified ); | 1016 | mActionSave->setEnabled( mModified ); |
1017 | #ifdef DESKTOP_VERSION | 1017 | #ifdef DESKTOP_VERSION |
1018 | mDetails->refreshView(); | 1018 | mDetails->refreshView(); |
1019 | #endif | 1019 | #endif |
1020 | 1020 | ||
1021 | } | 1021 | } |
1022 | void KABCore::setModified( bool modified ) | 1022 | void KABCore::setModified( bool modified ) |
1023 | { | 1023 | { |
1024 | mModified = modified; | 1024 | mModified = modified; |
1025 | mActionSave->setEnabled( mModified ); | 1025 | mActionSave->setEnabled( mModified ); |
1026 | 1026 | ||
1027 | if ( modified ) | 1027 | if ( modified ) |
1028 | mJumpButtonBar->recreateButtons(); | 1028 | mJumpButtonBar->recreateButtons(); |
1029 | 1029 | ||
1030 | mViewManager->refreshView(); | 1030 | mViewManager->refreshView(); |
1031 | mDetails->refreshView(); | 1031 | mDetails->refreshView(); |
1032 | 1032 | ||
1033 | } | 1033 | } |
1034 | 1034 | ||
1035 | bool KABCore::modified() const | 1035 | bool KABCore::modified() const |
1036 | { | 1036 | { |
1037 | return mModified; | 1037 | return mModified; |
1038 | } | 1038 | } |
1039 | 1039 | ||
1040 | void KABCore::contactModified( const KABC::Addressee &addr ) | 1040 | void KABCore::contactModified( const KABC::Addressee &addr ) |
1041 | { | 1041 | { |
1042 | 1042 | ||
1043 | Command *command = 0; | 1043 | Command *command = 0; |
1044 | QString uid; | 1044 | QString uid; |
1045 | 1045 | ||
1046 | // check if it exists already | 1046 | // check if it exists already |
1047 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 1047 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
1048 | if ( origAddr.isEmpty() ) | 1048 | if ( origAddr.isEmpty() ) |
1049 | command = new PwNewCommand( mAddressBook, addr ); | 1049 | command = new PwNewCommand( mAddressBook, addr ); |
1050 | else { | 1050 | else { |
1051 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 1051 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
1052 | uid = addr.uid(); | 1052 | uid = addr.uid(); |
1053 | } | 1053 | } |
1054 | 1054 | ||
1055 | UndoStack::instance()->push( command ); | 1055 | UndoStack::instance()->push( command ); |
1056 | RedoStack::instance()->clear(); | 1056 | RedoStack::instance()->clear(); |
1057 | 1057 | ||
1058 | setModified( true ); | 1058 | setModified( true ); |
1059 | } | 1059 | } |
1060 | 1060 | ||
1061 | void KABCore::newContact() | 1061 | void KABCore::newContact() |
1062 | { | 1062 | { |
1063 | 1063 | ||
1064 | 1064 | ||
1065 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 1065 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
1066 | 1066 | ||
1067 | QPtrList<KRES::Resource> kresResources; | 1067 | QPtrList<KRES::Resource> kresResources; |
1068 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 1068 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
1069 | KABC::Resource *resource; | 1069 | KABC::Resource *resource; |
1070 | while ( ( resource = it.current() ) != 0 ) { | 1070 | while ( ( resource = it.current() ) != 0 ) { |
1071 | ++it; | 1071 | ++it; |
1072 | if ( !resource->readOnly() ) { | 1072 | if ( !resource->readOnly() ) { |
1073 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 1073 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
1074 | if ( res ) | 1074 | if ( res ) |
1075 | kresResources.append( res ); | 1075 | kresResources.append( res ); |
1076 | } | 1076 | } |
1077 | } | 1077 | } |
1078 | 1078 | ||
1079 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 1079 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
1080 | resource = static_cast<KABC::Resource*>( res ); | 1080 | resource = static_cast<KABC::Resource*>( res ); |
1081 | 1081 | ||
1082 | if ( resource ) { | 1082 | if ( resource ) { |
1083 | KABC::Addressee addr; | 1083 | KABC::Addressee addr; |
1084 | addr.setResource( resource ); | 1084 | addr.setResource( resource ); |
1085 | mEditorDialog->setAddressee( addr ); | 1085 | mEditorDialog->setAddressee( addr ); |
1086 | KApplication::execDialog ( mEditorDialog ); | 1086 | KApplication::execDialog ( mEditorDialog ); |
1087 | 1087 | ||
1088 | } else | 1088 | } else |
1089 | return; | 1089 | return; |
1090 | 1090 | ||
1091 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 1091 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
1092 | 1092 | ||
1093 | 1093 | ||
1094 | } | 1094 | } |
1095 | 1095 | ||
1096 | void KABCore::addEmail( QString aStr ) | 1096 | void KABCore::addEmail( QString aStr ) |
1097 | { | 1097 | { |
1098 | #ifndef KAB_EMBEDDED | 1098 | #ifndef KAB_EMBEDDED |
1099 | QString fullName, email; | 1099 | QString fullName, email; |
1100 | 1100 | ||
1101 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 1101 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
1102 | 1102 | ||
1103 | // Try to lookup the addressee matching the email address | 1103 | // Try to lookup the addressee matching the email address |
1104 | bool found = false; | 1104 | bool found = false; |
1105 | QStringList emailList; | 1105 | QStringList emailList; |
1106 | KABC::AddressBook::Iterator it; | 1106 | KABC::AddressBook::Iterator it; |
1107 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 1107 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
1108 | emailList = (*it).emails(); | 1108 | emailList = (*it).emails(); |
1109 | if ( emailList.contains( email ) > 0 ) { | 1109 | if ( emailList.contains( email ) > 0 ) { |
1110 | found = true; | 1110 | found = true; |
1111 | (*it).setNameFromString( fullName ); | 1111 | (*it).setNameFromString( fullName ); |
1112 | editContact( (*it).uid() ); | 1112 | editContact( (*it).uid() ); |
1113 | } | 1113 | } |
1114 | } | 1114 | } |
1115 | 1115 | ||
1116 | if ( !found ) { | 1116 | if ( !found ) { |
1117 | KABC::Addressee addr; | 1117 | KABC::Addressee addr; |
1118 | addr.setNameFromString( fullName ); | 1118 | addr.setNameFromString( fullName ); |
1119 | addr.insertEmail( email, true ); | 1119 | addr.insertEmail( email, true ); |
1120 | 1120 | ||
1121 | mAddressBook->insertAddressee( addr ); | 1121 | mAddressBook->insertAddressee( addr ); |
1122 | mViewManager->refreshView( addr.uid() ); | 1122 | mViewManager->refreshView( addr.uid() ); |
1123 | editContact( addr.uid() ); | 1123 | editContact( addr.uid() ); |
1124 | } | 1124 | } |
1125 | #else //KAB_EMBEDDED | 1125 | #else //KAB_EMBEDDED |
1126 | qDebug("KABCore::addEmail finsih method"); | 1126 | qDebug("KABCore::addEmail finsih method"); |
1127 | #endif //KAB_EMBEDDED | 1127 | #endif //KAB_EMBEDDED |
1128 | } | 1128 | } |
1129 | 1129 | ||
1130 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 1130 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
1131 | { | 1131 | { |
1132 | mXXPortManager->importVCard( url, showPreview ); | 1132 | mXXPortManager->importVCard( url, showPreview ); |
1133 | } | 1133 | } |
1134 | void KABCore::importFromOL() | 1134 | void KABCore::importFromOL() |
1135 | { | 1135 | { |
1136 | #ifdef _WIN32_ | 1136 | #ifdef _WIN32_ |
1137 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | 1137 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); |
1138 | idgl->exec(); | 1138 | idgl->exec(); |
1139 | KABC::Addressee::List list = idgl->getAddressList(); | 1139 | KABC::Addressee::List list = idgl->getAddressList(); |
1140 | if ( list.count() > 0 ) { | 1140 | if ( list.count() > 0 ) { |
1141 | KABC::Addressee::List listNew; | 1141 | KABC::Addressee::List listNew; |
1142 | KABC::Addressee::List listExisting; | 1142 | KABC::Addressee::List listExisting; |
1143 | KABC::Addressee::List::Iterator it; | 1143 | KABC::Addressee::List::Iterator it; |
1144 | KABC::AddressBook::Iterator iter; | 1144 | KABC::AddressBook::Iterator iter; |
1145 | for ( it = list.begin(); it != list.end(); ++it ) { | 1145 | for ( it = list.begin(); it != list.end(); ++it ) { |
1146 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) | 1146 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) |
1147 | listNew.append( (*it) ); | 1147 | listNew.append( (*it) ); |
1148 | else | 1148 | else |
1149 | listExisting.append( (*it) ); | 1149 | listExisting.append( (*it) ); |
1150 | } | 1150 | } |
1151 | if ( listExisting.count() > 0 ) | 1151 | if ( listExisting.count() > 0 ) |
1152 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); | 1152 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); |
1153 | if ( listNew.count() > 0 ) { | 1153 | if ( listNew.count() > 0 ) { |
1154 | pasteWithNewUid = false; | 1154 | pasteWithNewUid = false; |
1155 | pasteContacts( listNew ); | 1155 | pasteContacts( listNew ); |
1156 | pasteWithNewUid = true; | 1156 | pasteWithNewUid = true; |
1157 | } | 1157 | } |
1158 | } | 1158 | } |
1159 | delete idgl; | 1159 | delete idgl; |
1160 | #endif | 1160 | #endif |
1161 | } | 1161 | } |
1162 | 1162 | ||
1163 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1163 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
1164 | { | 1164 | { |
1165 | mXXPortManager->importVCard( vCard, showPreview ); | 1165 | mXXPortManager->importVCard( vCard, showPreview ); |
1166 | } | 1166 | } |
1167 | 1167 | ||
1168 | //US added a second method without defaultparameter | 1168 | //US added a second method without defaultparameter |
1169 | void KABCore::editContact2() { | 1169 | void KABCore::editContact2() { |
1170 | editContact( QString::null ); | 1170 | editContact( QString::null ); |
1171 | } | 1171 | } |
1172 | 1172 | ||
1173 | void KABCore::editContact( const QString &uid ) | 1173 | void KABCore::editContact( const QString &uid ) |
1174 | { | 1174 | { |
1175 | 1175 | ||
1176 | if ( mExtensionManager->isQuickEditVisible() ) | 1176 | if ( mExtensionManager->isQuickEditVisible() ) |
1177 | return; | 1177 | return; |
1178 | 1178 | ||
1179 | // First, locate the contact entry | 1179 | // First, locate the contact entry |
1180 | QString localUID = uid; | 1180 | QString localUID = uid; |
1181 | if ( localUID.isNull() ) { | 1181 | if ( localUID.isNull() ) { |
1182 | QStringList uidList = mViewManager->selectedUids(); | 1182 | QStringList uidList = mViewManager->selectedUids(); |
1183 | if ( uidList.count() > 0 ) | 1183 | if ( uidList.count() > 0 ) |
1184 | localUID = *( uidList.at( 0 ) ); | 1184 | localUID = *( uidList.at( 0 ) ); |
1185 | } | 1185 | } |
1186 | 1186 | ||
1187 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 1187 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
1188 | if ( !addr.isEmpty() ) { | 1188 | if ( !addr.isEmpty() ) { |
1189 | mEditorDialog->setAddressee( addr ); | 1189 | mEditorDialog->setAddressee( addr ); |
1190 | KApplication::execDialog ( mEditorDialog ); | 1190 | KApplication::execDialog ( mEditorDialog ); |
1191 | } | 1191 | } |
1192 | } | 1192 | } |
1193 | 1193 | ||
1194 | /** | 1194 | /** |
1195 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 1195 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
1196 | the method will try to find a selected addressee in the view. | 1196 | the method will try to find a selected addressee in the view. |
1197 | */ | 1197 | */ |
1198 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1198 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) |
1199 | { | 1199 | { |
1200 | if ( mMultipleViewsAtOnce ) | 1200 | if ( mMultipleViewsAtOnce ) |
1201 | { | 1201 | { |
1202 | editContact( uid ); | 1202 | editContact( uid ); |
1203 | } | 1203 | } |
1204 | else | 1204 | else |
1205 | { | 1205 | { |
1206 | setDetailsVisible( true ); | 1206 | setDetailsVisible( true ); |
1207 | mActionDetails->setChecked(true); | 1207 | mActionDetails->setChecked(true); |
1208 | } | 1208 | } |
1209 | 1209 | ||
1210 | } | 1210 | } |
1211 | 1211 | ||
1212 | void KABCore::save() | 1212 | void KABCore::save() |
1213 | { | 1213 | { |
1214 | if (syncManager->blockSave()) | 1214 | if (syncManager->blockSave()) |
1215 | return; | 1215 | return; |
1216 | if ( !mModified ) | 1216 | if ( !mModified ) |
1217 | return; | 1217 | return; |
1218 | 1218 | ||
1219 | syncManager->setBlockSave(true); | 1219 | syncManager->setBlockSave(true); |
1220 | QString text = i18n( "There was an error while attempting to save\n the " | 1220 | QString text = i18n( "There was an error while attempting to save\n the " |
1221 | "address book. Please check that some \nother application is " | 1221 | "address book. Please check that some \nother application is " |
1222 | "not using it. " ); | 1222 | "not using it. " ); |
1223 | message(i18n("Saving addressbook ... ")); | 1223 | message(i18n("Saving addressbook ... ")); |
1224 | #ifndef KAB_EMBEDDED | 1224 | #ifndef KAB_EMBEDDED |
1225 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1225 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
1226 | if ( !b || !b->save() ) { | 1226 | if ( !b || !b->save() ) { |
1227 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 1227 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
1228 | } | 1228 | } |
1229 | #else //KAB_EMBEDDED | 1229 | #else //KAB_EMBEDDED |
1230 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 1230 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
1231 | if ( !b || !b->save() ) { | 1231 | if ( !b || !b->save() ) { |
1232 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 1232 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
1233 | } | 1233 | } |
1234 | #endif //KAB_EMBEDDED | 1234 | #endif //KAB_EMBEDDED |
1235 | 1235 | ||
1236 | message(i18n("Addressbook saved!")); | 1236 | message(i18n("Addressbook saved!")); |
1237 | setModified( false ); | 1237 | setModified( false ); |
1238 | syncManager->setBlockSave(false); | 1238 | syncManager->setBlockSave(false); |
1239 | } | 1239 | } |
1240 | 1240 | ||
1241 | 1241 | ||
1242 | void KABCore::undo() | 1242 | void KABCore::undo() |
1243 | { | 1243 | { |
1244 | UndoStack::instance()->undo(); | 1244 | UndoStack::instance()->undo(); |
1245 | 1245 | ||
1246 | // Refresh the view | 1246 | // Refresh the view |
1247 | mViewManager->refreshView(); | 1247 | mViewManager->refreshView(); |
1248 | } | 1248 | } |
1249 | 1249 | ||
1250 | void KABCore::redo() | 1250 | void KABCore::redo() |
1251 | { | 1251 | { |
1252 | RedoStack::instance()->redo(); | 1252 | RedoStack::instance()->redo(); |
1253 | 1253 | ||
1254 | // Refresh the view | 1254 | // Refresh the view |
1255 | mViewManager->refreshView(); | 1255 | mViewManager->refreshView(); |
1256 | } | 1256 | } |
1257 | 1257 | ||
1258 | void KABCore::setJumpButtonBarVisible( bool visible ) | 1258 | void KABCore::setJumpButtonBarVisible( bool visible ) |
1259 | { | 1259 | { |
1260 | if (mMultipleViewsAtOnce) | 1260 | if (mMultipleViewsAtOnce) |
1261 | { | 1261 | { |
1262 | if ( visible ) | 1262 | if ( visible ) |
1263 | mJumpButtonBar->show(); | 1263 | mJumpButtonBar->show(); |
1264 | else | 1264 | else |
1265 | mJumpButtonBar->hide(); | 1265 | mJumpButtonBar->hide(); |
1266 | } | 1266 | } |
1267 | else | 1267 | else |
1268 | { | 1268 | { |
1269 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" | 1269 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" |
1270 | if (mViewManager->isVisible()) | 1270 | if (mViewManager->isVisible()) |
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 | mJumpButtonBar->hide(); | 1279 | mJumpButtonBar->hide(); |
1280 | } | 1280 | } |
1281 | } | 1281 | } |
1282 | } | 1282 | } |
1283 | 1283 | ||
1284 | 1284 | ||
1285 | void KABCore::setDetailsToState() | 1285 | void KABCore::setDetailsToState() |
1286 | { | 1286 | { |
1287 | setDetailsVisible( mActionDetails->isChecked() ); | 1287 | setDetailsVisible( mActionDetails->isChecked() ); |
1288 | } | 1288 | } |
1289 | 1289 | ||
1290 | 1290 | ||
1291 | 1291 | ||
1292 | void KABCore::setDetailsVisible( bool visible ) | 1292 | void KABCore::setDetailsVisible( bool visible ) |
1293 | { | 1293 | { |
1294 | if (visible && mDetails->isHidden()) | 1294 | if (visible && mDetails->isHidden()) |
1295 | { | 1295 | { |
1296 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1296 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1297 | if ( addrList.count() > 0 ) | 1297 | if ( addrList.count() > 0 ) |
1298 | mDetails->setAddressee( addrList[ 0 ] ); | 1298 | mDetails->setAddressee( addrList[ 0 ] ); |
1299 | } | 1299 | } |
1300 | 1300 | ||
1301 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between | 1301 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between |
1302 | // the listview and the detailview. We do that by changing the splitbar size. | 1302 | // the listview and the detailview. We do that by changing the splitbar size. |
1303 | if (mMultipleViewsAtOnce) | 1303 | if (mMultipleViewsAtOnce) |
1304 | { | 1304 | { |
1305 | if ( visible ) | 1305 | if ( visible ) |
1306 | mDetails->show(); | 1306 | mDetails->show(); |
1307 | else | 1307 | else |
1308 | mDetails->hide(); | 1308 | mDetails->hide(); |
1309 | } | 1309 | } |
1310 | else | 1310 | else |
1311 | { | 1311 | { |
1312 | if ( visible ) { | 1312 | if ( visible ) { |
1313 | mViewManager->hide(); | 1313 | mViewManager->hide(); |
1314 | mDetails->show(); | 1314 | mDetails->show(); |
1315 | } | 1315 | } |
1316 | else { | 1316 | else { |
1317 | mViewManager->show(); | 1317 | mViewManager->show(); |
1318 | mDetails->hide(); | 1318 | mDetails->hide(); |
1319 | } | 1319 | } |
1320 | setJumpButtonBarVisible( !visible ); | 1320 | setJumpButtonBarVisible( !visible ); |
1321 | } | 1321 | } |
1322 | 1322 | ||
1323 | } | 1323 | } |
1324 | 1324 | ||
1325 | void KABCore::extensionChanged( int id ) | 1325 | void KABCore::extensionChanged( int id ) |
1326 | { | 1326 | { |
1327 | //change the details view only for non desktop systems | 1327 | //change the details view only for non desktop systems |
1328 | #ifndef DESKTOP_VERSION | 1328 | #ifndef DESKTOP_VERSION |
1329 | 1329 | ||
1330 | if (id == 0) | 1330 | if (id == 0) |
1331 | { | 1331 | { |
1332 | //the user disabled the extension. | 1332 | //the user disabled the extension. |
1333 | 1333 | ||
1334 | if (mMultipleViewsAtOnce) | 1334 | if (mMultipleViewsAtOnce) |
1335 | { // enable detailsview again | 1335 | { // enable detailsview again |
1336 | setDetailsVisible( true ); | 1336 | setDetailsVisible( true ); |
1337 | mActionDetails->setChecked( true ); | 1337 | mActionDetails->setChecked( true ); |
1338 | } | 1338 | } |
1339 | else | 1339 | else |
1340 | { //go back to the listview | 1340 | { //go back to the listview |
1341 | setDetailsVisible( false ); | 1341 | setDetailsVisible( false ); |
1342 | mActionDetails->setChecked( false ); | 1342 | mActionDetails->setChecked( false ); |
1343 | mActionDetails->setEnabled(true); | 1343 | mActionDetails->setEnabled(true); |
1344 | } | 1344 | } |
1345 | 1345 | ||
1346 | } | 1346 | } |
1347 | else | 1347 | else |
1348 | { | 1348 | { |
1349 | //the user enabled the extension. | 1349 | //the user enabled the extension. |
1350 | setDetailsVisible( false ); | 1350 | setDetailsVisible( false ); |
1351 | mActionDetails->setChecked( false ); | 1351 | mActionDetails->setChecked( false ); |
1352 | 1352 | ||
1353 | if (!mMultipleViewsAtOnce) | 1353 | if (!mMultipleViewsAtOnce) |
1354 | { | 1354 | { |
1355 | mActionDetails->setEnabled(false); | 1355 | mActionDetails->setEnabled(false); |
1356 | } | 1356 | } |
1357 | 1357 | ||
1358 | mExtensionManager->setSelectionChanged(); | 1358 | mExtensionManager->setSelectionChanged(); |
1359 | 1359 | ||
1360 | } | 1360 | } |
1361 | 1361 | ||
1362 | #endif// DESKTOP_VERSION | 1362 | #endif// DESKTOP_VERSION |
1363 | 1363 | ||
1364 | } | 1364 | } |
1365 | 1365 | ||
1366 | 1366 | ||
1367 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1367 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1368 | { | 1368 | { |
1369 | 1369 | ||
1370 | if ( list.count() != 0 ) { | 1370 | if ( list.count() != 0 ) { |
1371 | KABC::Addressee::List::ConstIterator it; | 1371 | KABC::Addressee::List::ConstIterator it; |
1372 | for ( it = list.begin(); it != list.end(); ++it ) | 1372 | for ( it = list.begin(); it != list.end(); ++it ) |
1373 | mAddressBook->insertAddressee( *it ); | 1373 | mAddressBook->insertAddressee( *it ); |
1374 | if ( list.count() > 1 ) | 1374 | if ( list.count() > 1 ) |
1375 | setModified(); | 1375 | setModified(); |
1376 | else | 1376 | else |
1377 | setModifiedWOrefresh(); | 1377 | setModifiedWOrefresh(); |
1378 | } | 1378 | } |
1379 | if ( list.count() == 0 ) | 1379 | if ( list.count() == 0 ) |
1380 | mViewManager->refreshView(); | 1380 | mViewManager->refreshView(); |
1381 | else | 1381 | else |
1382 | mViewManager->refreshView( list[ 0 ].uid() ); | 1382 | mViewManager->refreshView( list[ 0 ].uid() ); |
1383 | 1383 | ||
1384 | 1384 | ||
1385 | 1385 | ||
1386 | } | 1386 | } |
1387 | 1387 | ||
1388 | QString KABCore::getNameByPhone( const QString &phone ) | 1388 | QString KABCore::getNameByPhone( const QString &phone ) |
1389 | { | 1389 | { |
1390 | #ifndef KAB_EMBEDDED | 1390 | #ifndef KAB_EMBEDDED |
1391 | QRegExp r( "[/*/-/ ]" ); | 1391 | QRegExp r( "[/*/-/ ]" ); |
1392 | QString localPhone( phone ); | 1392 | QString localPhone( phone ); |
1393 | 1393 | ||
1394 | bool found = false; | 1394 | bool found = false; |
1395 | QString ownerName = ""; | 1395 | QString ownerName = ""; |
1396 | KABC::AddressBook::Iterator iter; | 1396 | KABC::AddressBook::Iterator iter; |
1397 | KABC::PhoneNumber::List::Iterator phoneIter; | 1397 | KABC::PhoneNumber::List::Iterator phoneIter; |
1398 | KABC::PhoneNumber::List phoneList; | 1398 | KABC::PhoneNumber::List phoneList; |
1399 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1399 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
1400 | phoneList = (*iter).phoneNumbers(); | 1400 | phoneList = (*iter).phoneNumbers(); |
1401 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1401 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
1402 | ++phoneIter) { | 1402 | ++phoneIter) { |
1403 | // Get rid of separator chars so just the numbers are compared. | 1403 | // Get rid of separator chars so just the numbers are compared. |
1404 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1404 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
1405 | ownerName = (*iter).formattedName(); | 1405 | ownerName = (*iter).formattedName(); |
1406 | found = true; | 1406 | found = true; |
1407 | } | 1407 | } |
1408 | } | 1408 | } |
1409 | } | 1409 | } |
1410 | 1410 | ||
1411 | return ownerName; | 1411 | return ownerName; |
1412 | #else //KAB_EMBEDDED | 1412 | #else //KAB_EMBEDDED |
1413 | qDebug("KABCore::getNameByPhone finsih method"); | 1413 | qDebug("KABCore::getNameByPhone finsih method"); |
1414 | return ""; | 1414 | return ""; |
1415 | #endif //KAB_EMBEDDED | 1415 | #endif //KAB_EMBEDDED |
1416 | 1416 | ||
1417 | } | 1417 | } |
1418 | 1418 | ||
1419 | void KABCore::openConfigDialog() | 1419 | void KABCore::openConfigDialog() |
1420 | { | 1420 | { |
1421 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 1421 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
1422 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 1422 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
1423 | ConfigureDialog->addModule(kabcfg ); | 1423 | ConfigureDialog->addModule(kabcfg ); |
1424 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 1424 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
1425 | ConfigureDialog->addModule(kdelibcfg ); | 1425 | ConfigureDialog->addModule(kdelibcfg ); |
1426 | 1426 | ||
1427 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1427 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1428 | this, SLOT( configurationChanged() ) ); | 1428 | this, SLOT( configurationChanged() ) ); |
1429 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1429 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
1430 | this, SLOT( configurationChanged() ) ); | 1430 | this, SLOT( configurationChanged() ) ); |
1431 | saveSettings(); | 1431 | saveSettings(); |
1432 | #ifndef DESKTOP_VERSION | 1432 | #ifndef DESKTOP_VERSION |
1433 | ConfigureDialog->showMaximized(); | 1433 | ConfigureDialog->showMaximized(); |
1434 | #endif | 1434 | #endif |
1435 | if ( ConfigureDialog->exec() ) | 1435 | if ( ConfigureDialog->exec() ) |
1436 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 1436 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
1437 | delete ConfigureDialog; | 1437 | delete ConfigureDialog; |
1438 | } | 1438 | } |
1439 | 1439 | ||
1440 | void KABCore::openLDAPDialog() | 1440 | void KABCore::openLDAPDialog() |
1441 | { | 1441 | { |
1442 | #ifndef KAB_EMBEDDED | 1442 | #ifndef KAB_EMBEDDED |
1443 | if ( !mLdapSearchDialog ) { | 1443 | if ( !mLdapSearchDialog ) { |
1444 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1444 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1445 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1445 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1446 | SLOT( refreshView() ) ); | 1446 | SLOT( refreshView() ) ); |
1447 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1447 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1448 | SLOT( setModified() ) ); | 1448 | SLOT( setModified() ) ); |
1449 | } else | 1449 | } else |
1450 | mLdapSearchDialog->restoreSettings(); | 1450 | mLdapSearchDialog->restoreSettings(); |
1451 | 1451 | ||
1452 | if ( mLdapSearchDialog->isOK() ) | 1452 | if ( mLdapSearchDialog->isOK() ) |
1453 | mLdapSearchDialog->exec(); | 1453 | mLdapSearchDialog->exec(); |
1454 | #else //KAB_EMBEDDED | 1454 | #else //KAB_EMBEDDED |
1455 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1455 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1456 | #endif //KAB_EMBEDDED | 1456 | #endif //KAB_EMBEDDED |
1457 | } | 1457 | } |
1458 | 1458 | ||
1459 | void KABCore::print() | 1459 | void KABCore::print() |
1460 | { | 1460 | { |
1461 | #ifndef KAB_EMBEDDED | 1461 | #ifndef KAB_EMBEDDED |
1462 | KPrinter printer; | 1462 | KPrinter printer; |
1463 | if ( !printer.setup( this ) ) | 1463 | if ( !printer.setup( this ) ) |
1464 | return; | 1464 | return; |
1465 | 1465 | ||
1466 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1466 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1467 | mViewManager->selectedUids(), this ); | 1467 | mViewManager->selectedUids(), this ); |
1468 | 1468 | ||
1469 | wizard.exec(); | 1469 | wizard.exec(); |
1470 | #else //KAB_EMBEDDED | 1470 | #else //KAB_EMBEDDED |
1471 | qDebug("KABCore::print() finsih method"); | 1471 | qDebug("KABCore::print() finsih method"); |
1472 | #endif //KAB_EMBEDDED | 1472 | #endif //KAB_EMBEDDED |
1473 | 1473 | ||
1474 | } | 1474 | } |
1475 | 1475 | ||
1476 | 1476 | ||
1477 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1477 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1478 | { | 1478 | { |
1479 | if ( mGUIClient ) | 1479 | if ( mGUIClient ) |
1480 | mGUIClient->insertChildClient( client ); | 1480 | mGUIClient->insertChildClient( client ); |
1481 | else | 1481 | else |
1482 | KMessageBox::error( this, "no KXMLGUICLient"); | 1482 | KMessageBox::error( this, "no KXMLGUICLient"); |
1483 | } | 1483 | } |
1484 | 1484 | ||
1485 | 1485 | ||
1486 | void KABCore::configurationChanged() | 1486 | void KABCore::configurationChanged() |
1487 | { | 1487 | { |
1488 | mExtensionManager->reconfigure(); | 1488 | mExtensionManager->reconfigure(); |
1489 | } | 1489 | } |
1490 | 1490 | ||
1491 | void KABCore::addressBookChanged() | 1491 | void KABCore::addressBookChanged() |
1492 | { | 1492 | { |
1493 | /*US | 1493 | /*US |
1494 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1494 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1495 | while ( it.current() ) { | 1495 | while ( it.current() ) { |
1496 | if ( it.current()->dirty() ) { | 1496 | if ( it.current()->dirty() ) { |
1497 | QString text = i18n( "Data has been changed externally. Unsaved " | 1497 | QString text = i18n( "Data has been changed externally. Unsaved " |
1498 | "changes will be lost." ); | 1498 | "changes will be lost." ); |
1499 | KMessageBox::information( this, text ); | 1499 | KMessageBox::information( this, text ); |
1500 | } | 1500 | } |
1501 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1501 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1502 | ++it; | 1502 | ++it; |
1503 | } | 1503 | } |
1504 | */ | 1504 | */ |
1505 | if (mEditorDialog) | 1505 | if (mEditorDialog) |
1506 | { | 1506 | { |
1507 | if (mEditorDialog->dirty()) | 1507 | if (mEditorDialog->dirty()) |
1508 | { | 1508 | { |
1509 | QString text = i18n( "Data has been changed externally. Unsaved " | 1509 | QString text = i18n( "Data has been changed externally. Unsaved " |
1510 | "changes will be lost." ); | 1510 | "changes will be lost." ); |
1511 | KMessageBox::information( this, text ); | 1511 | KMessageBox::information( this, text ); |
1512 | } | 1512 | } |
1513 | QString currentuid = mEditorDialog->addressee().uid(); | 1513 | QString currentuid = mEditorDialog->addressee().uid(); |
1514 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); | 1514 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); |
1515 | } | 1515 | } |
1516 | mViewManager->refreshView(); | 1516 | mViewManager->refreshView(); |
1517 | // mDetails->refreshView(); | 1517 | // mDetails->refreshView(); |
1518 | 1518 | ||
1519 | 1519 | ||
1520 | } | 1520 | } |
1521 | 1521 | ||
1522 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1522 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1523 | const char *name ) | 1523 | const char *name ) |
1524 | { | 1524 | { |
1525 | 1525 | ||
1526 | if ( mEditorDialog == 0 ) { | 1526 | if ( mEditorDialog == 0 ) { |
1527 | mEditorDialog = new AddresseeEditorDialog( this, parent, | 1527 | mEditorDialog = new AddresseeEditorDialog( this, parent, |
1528 | name ? name : "editorDialog" ); | 1528 | name ? name : "editorDialog" ); |
1529 | 1529 | ||
1530 | 1530 | ||
1531 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1531 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1532 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1532 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1533 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), | 1533 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), |
1534 | // SLOT( slotEditorDestroyed( const QString& ) ) ; | 1534 | // SLOT( slotEditorDestroyed( const QString& ) ) ; |
1535 | } | 1535 | } |
1536 | 1536 | ||
1537 | return mEditorDialog; | 1537 | return mEditorDialog; |
1538 | } | 1538 | } |
1539 | 1539 | ||
1540 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1540 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1541 | { | 1541 | { |
1542 | //mEditorDict.remove( uid ); | 1542 | //mEditorDict.remove( uid ); |
1543 | } | 1543 | } |
1544 | 1544 | ||
1545 | void KABCore::initGUI() | 1545 | void KABCore::initGUI() |
1546 | { | 1546 | { |
1547 | #ifndef KAB_EMBEDDED | 1547 | #ifndef KAB_EMBEDDED |
1548 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1548 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1549 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1549 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1550 | 1550 | ||
1551 | mExtensionBarSplitter = new QSplitter( this ); | 1551 | mExtensionBarSplitter = new QSplitter( this ); |
1552 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1552 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1553 | 1553 | ||
1554 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1554 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1555 | 1555 | ||
1556 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1556 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1557 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1557 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1558 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1558 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1559 | SLOT( incrementalSearch( const QString& ) ) ); | 1559 | SLOT( incrementalSearch( const QString& ) ) ); |
1560 | 1560 | ||
1561 | mViewManager = new ViewManager( this, viewSpace ); | 1561 | mViewManager = new ViewManager( this, viewSpace ); |
1562 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1562 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1563 | 1563 | ||
1564 | mDetails = new ViewContainer( mDetailsSplitter ); | 1564 | mDetails = new ViewContainer( mDetailsSplitter ); |
1565 | 1565 | ||
1566 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1566 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1567 | 1567 | ||
1568 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1568 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1569 | 1569 | ||
1570 | topLayout->addWidget( mExtensionBarSplitter ); | 1570 | topLayout->addWidget( mExtensionBarSplitter ); |
1571 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1571 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1572 | topLayout->addWidget( mJumpButtonBar ); | 1572 | topLayout->addWidget( mJumpButtonBar ); |
1573 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1573 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1574 | 1574 | ||
1575 | mXXPortManager = new XXPortManager( this, this ); | 1575 | mXXPortManager = new XXPortManager( this, this ); |
1576 | 1576 | ||
1577 | #else //KAB_EMBEDDED | 1577 | #else //KAB_EMBEDDED |
1578 | //US initialize viewMenu before settingup viewmanager. | 1578 | //US initialize viewMenu before settingup viewmanager. |
1579 | // Viewmanager needs this menu to plugin submenues. | 1579 | // Viewmanager needs this menu to plugin submenues. |
1580 | viewMenu = new QPopupMenu( this ); | 1580 | viewMenu = new QPopupMenu( this ); |
1581 | settingsMenu = new QPopupMenu( this ); | 1581 | settingsMenu = new QPopupMenu( this ); |
1582 | //filterMenu = new QPopupMenu( this ); | 1582 | //filterMenu = new QPopupMenu( this ); |
1583 | ImportMenu = new QPopupMenu( this ); | 1583 | ImportMenu = new QPopupMenu( this ); |
1584 | ExportMenu = new QPopupMenu( this ); | 1584 | ExportMenu = new QPopupMenu( this ); |
1585 | syncMenu = new QPopupMenu( this ); | 1585 | syncMenu = new QPopupMenu( this ); |
1586 | changeMenu= new QPopupMenu( this ); | 1586 | changeMenu= new QPopupMenu( this ); |
1587 | 1587 | ||
1588 | //US since we have no splitter for the embedded system, setup | 1588 | //US since we have no splitter for the embedded system, setup |
1589 | // a layout with two frames. One left and one right. | 1589 | // a layout with two frames. One left and one right. |
1590 | 1590 | ||
1591 | QBoxLayout *topLayout; | 1591 | QBoxLayout *topLayout; |
1592 | 1592 | ||
1593 | // = new QHBoxLayout( this ); | 1593 | // = new QHBoxLayout( this ); |
1594 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1594 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1595 | 1595 | ||
1596 | // QWidget *mainBox = new QWidget( this ); | 1596 | // QWidget *mainBox = new QWidget( this ); |
1597 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1597 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1598 | 1598 | ||
1599 | #ifdef DESKTOP_VERSION | 1599 | #ifdef DESKTOP_VERSION |
1600 | topLayout = new QHBoxLayout( this ); | 1600 | topLayout = new QHBoxLayout( this ); |
1601 | 1601 | ||
1602 | 1602 | ||
1603 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1603 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1604 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1604 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1605 | 1605 | ||
1606 | topLayout->addWidget(mMiniSplitter ); | 1606 | topLayout->addWidget(mMiniSplitter ); |
1607 | 1607 | ||
1608 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1608 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1609 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1609 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1610 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1610 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1611 | mDetails = new ViewContainer( mMiniSplitter ); | 1611 | mDetails = new ViewContainer( mMiniSplitter ); |
1612 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1612 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1613 | #else | 1613 | #else |
1614 | if ( QApplication::desktop()->width() > 480 ) { | 1614 | if ( QApplication::desktop()->width() > 480 ) { |
1615 | topLayout = new QHBoxLayout( this ); | 1615 | topLayout = new QHBoxLayout( this ); |
1616 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1616 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1617 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1617 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1618 | } else { | 1618 | } else { |
1619 | 1619 | ||
1620 | topLayout = new QHBoxLayout( this ); | 1620 | topLayout = new QHBoxLayout( this ); |
1621 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1621 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1622 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1622 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1623 | } | 1623 | } |
1624 | 1624 | ||
1625 | topLayout->addWidget(mMiniSplitter ); | 1625 | topLayout->addWidget(mMiniSplitter ); |
1626 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1626 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1627 | mDetails = new ViewContainer( mMiniSplitter ); | 1627 | mDetails = new ViewContainer( mMiniSplitter ); |
1628 | 1628 | ||
1629 | 1629 | ||
1630 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1630 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1631 | #endif | 1631 | #endif |
1632 | //eh->hide(); | 1632 | //eh->hide(); |
1633 | // topLayout->addWidget(mExtensionManager ); | 1633 | // topLayout->addWidget(mExtensionManager ); |
1634 | 1634 | ||
1635 | 1635 | ||
1636 | /*US | 1636 | /*US |
1637 | #ifndef KAB_NOSPLITTER | 1637 | #ifndef KAB_NOSPLITTER |
1638 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1638 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1639 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1639 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1640 | topLayout->setSpacing( 10 ); | 1640 | topLayout->setSpacing( 10 ); |
1641 | 1641 | ||
1642 | mDetailsSplitter = new QSplitter( this ); | 1642 | mDetailsSplitter = new QSplitter( this ); |
1643 | 1643 | ||
1644 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1644 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1645 | 1645 | ||
1646 | mViewManager = new ViewManager( this, viewSpace ); | 1646 | mViewManager = new ViewManager( this, viewSpace ); |
1647 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1647 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1648 | 1648 | ||
1649 | mDetails = new ViewContainer( mDetailsSplitter ); | 1649 | mDetails = new ViewContainer( mDetailsSplitter ); |
1650 | 1650 | ||
1651 | topLayout->addWidget( mDetailsSplitter ); | 1651 | topLayout->addWidget( mDetailsSplitter ); |
1652 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1652 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1653 | #else //KAB_NOSPLITTER | 1653 | #else //KAB_NOSPLITTER |
1654 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1654 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1655 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1655 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1656 | topLayout->setSpacing( 10 ); | 1656 | topLayout->setSpacing( 10 ); |
1657 | 1657 | ||
1658 | // mDetailsSplitter = new QSplitter( this ); | 1658 | // mDetailsSplitter = new QSplitter( this ); |
1659 | 1659 | ||
1660 | QVBox *viewSpace = new QVBox( this ); | 1660 | QVBox *viewSpace = new QVBox( this ); |
1661 | 1661 | ||
1662 | mViewManager = new ViewManager( this, viewSpace ); | 1662 | mViewManager = new ViewManager( this, viewSpace ); |
1663 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1663 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1664 | 1664 | ||
1665 | mDetails = new ViewContainer( this ); | 1665 | mDetails = new ViewContainer( this ); |
1666 | 1666 | ||
1667 | topLayout->addWidget( viewSpace ); | 1667 | topLayout->addWidget( viewSpace ); |
1668 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1668 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1669 | topLayout->addWidget( mDetails ); | 1669 | topLayout->addWidget( mDetails ); |
1670 | #endif //KAB_NOSPLITTER | 1670 | #endif //KAB_NOSPLITTER |
1671 | */ | 1671 | */ |
1672 | 1672 | ||
1673 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 1673 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
1674 | syncManager->setBlockSave(false); | 1674 | syncManager->setBlockSave(false); |
1675 | 1675 | ||
1676 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 1676 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
1677 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 1677 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
1678 | syncManager->setDefaultFileName( sentSyncFile()); | 1678 | syncManager->setDefaultFileName( sentSyncFile()); |
1679 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); | 1679 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); |
1680 | 1680 | ||
1681 | #endif //KAB_EMBEDDED | 1681 | #endif //KAB_EMBEDDED |
1682 | initActions(); | 1682 | initActions(); |
1683 | 1683 | ||
1684 | #ifdef KAB_EMBEDDED | 1684 | #ifdef KAB_EMBEDDED |
1685 | addActionsManually(); | 1685 | addActionsManually(); |
1686 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1686 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1687 | mXXPortManager = new XXPortManager( this, this ); | 1687 | mXXPortManager = new XXPortManager( this, this ); |
1688 | 1688 | ||
1689 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1689 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1690 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1690 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1691 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1691 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1692 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1692 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1693 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1693 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1694 | // mIncSearchWidget->hide(); | 1694 | // mIncSearchWidget->hide(); |
1695 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1695 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1696 | SLOT( incrementalSearch( const QString& ) ) ); | 1696 | SLOT( incrementalSearch( const QString& ) ) ); |
1697 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); | 1697 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); |
1698 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); | 1698 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); |
1699 | 1699 | ||
1700 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1700 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1701 | 1701 | ||
1702 | topLayout->addWidget( mJumpButtonBar ); | 1702 | topLayout->addWidget( mJumpButtonBar ); |
1703 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1703 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1704 | 1704 | ||
1705 | // mMainWindow->getIconToolBar()->raise(); | 1705 | // mMainWindow->getIconToolBar()->raise(); |
1706 | 1706 | ||
1707 | #endif //KAB_EMBEDDED | 1707 | #endif //KAB_EMBEDDED |
1708 | 1708 | ||
1709 | } | 1709 | } |
1710 | void KABCore::initActions() | 1710 | void KABCore::initActions() |
1711 | { | 1711 | { |
1712 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1712 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1713 | 1713 | ||
1714 | #ifndef KAB_EMBEDDED | 1714 | #ifndef KAB_EMBEDDED |
1715 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1715 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1716 | SLOT( clipboardDataChanged() ) ); | 1716 | SLOT( clipboardDataChanged() ) ); |
1717 | #endif //KAB_EMBEDDED | 1717 | #endif //KAB_EMBEDDED |
1718 | 1718 | ||
1719 | // file menu | 1719 | // file menu |
1720 | if ( mIsPart ) { | 1720 | if ( mIsPart ) { |
1721 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, | 1721 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, |
1722 | SLOT( sendMail() ), actionCollection(), | 1722 | SLOT( sendMail() ), actionCollection(), |
1723 | "kaddressbook_mail" ); | 1723 | "kaddressbook_mail" ); |
1724 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, | 1724 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, |
1725 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); | 1725 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); |
1726 | 1726 | ||
1727 | } else { | 1727 | } else { |
1728 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1728 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1729 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1729 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1730 | } | 1730 | } |
1731 | 1731 | ||
1732 | 1732 | ||
1733 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1733 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1734 | SLOT( save() ), actionCollection(), "file_sync" ); | 1734 | SLOT( save() ), actionCollection(), "file_sync" ); |
1735 | 1735 | ||
1736 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1736 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1737 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1737 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1738 | 1738 | ||
1739 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1739 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1740 | this, SLOT( mailVCard() ), | 1740 | this, SLOT( mailVCard() ), |
1741 | actionCollection(), "file_mail_vcard"); | 1741 | actionCollection(), "file_mail_vcard"); |
1742 | 1742 | ||
1743 | mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, | 1743 | mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, |
1744 | SLOT( export2phone() ), actionCollection(), | 1744 | SLOT( export2phone() ), actionCollection(), |
1745 | "kaddressbook_ex2phone" ); | 1745 | "kaddressbook_ex2phone" ); |
1746 | 1746 | ||
1747 | mActionBeamVCard = 0; | 1747 | mActionBeamVCard = 0; |
1748 | mActionBeam = 0; | 1748 | mActionBeam = 0; |
1749 | 1749 | ||
1750 | #ifndef DESKTOP_VERSION | 1750 | #ifndef DESKTOP_VERSION |
1751 | if ( Ir::supported() ) { | 1751 | if ( Ir::supported() ) { |
1752 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, | 1752 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, |
1753 | SLOT( beamVCard() ), actionCollection(), | 1753 | SLOT( beamVCard() ), actionCollection(), |
1754 | "kaddressbook_beam_vcard" ); | 1754 | "kaddressbook_beam_vcard" ); |
1755 | 1755 | ||
1756 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | 1756 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, |
1757 | SLOT( beamMySelf() ), actionCollection(), | 1757 | SLOT( beamMySelf() ), actionCollection(), |
1758 | "kaddressbook_beam_myself" ); | 1758 | "kaddressbook_beam_myself" ); |
1759 | } | 1759 | } |
1760 | #endif | 1760 | #endif |
1761 | 1761 | ||
1762 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1762 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1763 | this, SLOT( editContact2() ), | 1763 | this, SLOT( editContact2() ), |
1764 | actionCollection(), "file_properties" ); | 1764 | actionCollection(), "file_properties" ); |
1765 | 1765 | ||
1766 | #ifdef KAB_EMBEDDED | 1766 | #ifdef KAB_EMBEDDED |
1767 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1767 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1768 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1768 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1769 | mMainWindow, SLOT( exit() ), | 1769 | mMainWindow, SLOT( exit() ), |
1770 | actionCollection(), "quit" ); | 1770 | actionCollection(), "quit" ); |
1771 | #endif //KAB_EMBEDDED | 1771 | #endif //KAB_EMBEDDED |
1772 | 1772 | ||
1773 | // edit menu | 1773 | // edit menu |
1774 | if ( mIsPart ) { | 1774 | if ( mIsPart ) { |
1775 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1775 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
1776 | SLOT( copyContacts() ), actionCollection(), | 1776 | SLOT( copyContacts() ), actionCollection(), |
1777 | "kaddressbook_copy" ); | 1777 | "kaddressbook_copy" ); |
1778 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 1778 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
1779 | SLOT( cutContacts() ), actionCollection(), | 1779 | SLOT( cutContacts() ), actionCollection(), |
1780 | "kaddressbook_cut" ); | 1780 | "kaddressbook_cut" ); |
1781 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 1781 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
1782 | SLOT( pasteContacts() ), actionCollection(), | 1782 | SLOT( pasteContacts() ), actionCollection(), |
1783 | "kaddressbook_paste" ); | 1783 | "kaddressbook_paste" ); |
1784 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 1784 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
1785 | SLOT( selectAllContacts() ), actionCollection(), | 1785 | SLOT( selectAllContacts() ), actionCollection(), |
1786 | "kaddressbook_select_all" ); | 1786 | "kaddressbook_select_all" ); |
1787 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 1787 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
1788 | SLOT( undo() ), actionCollection(), | 1788 | SLOT( undo() ), actionCollection(), |
1789 | "kaddressbook_undo" ); | 1789 | "kaddressbook_undo" ); |
1790 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 1790 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
1791 | this, SLOT( redo() ), actionCollection(), | 1791 | this, SLOT( redo() ), actionCollection(), |
1792 | "kaddressbook_redo" ); | 1792 | "kaddressbook_redo" ); |
1793 | } else { | 1793 | } else { |
1794 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1794 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1795 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1795 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1796 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1796 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1797 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1797 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1798 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1798 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1799 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1799 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1800 | } | 1800 | } |
1801 | 1801 | ||
1802 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 1802 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
1803 | Key_Delete, this, SLOT( deleteContacts() ), | 1803 | Key_Delete, this, SLOT( deleteContacts() ), |
1804 | actionCollection(), "edit_delete" ); | 1804 | actionCollection(), "edit_delete" ); |
1805 | 1805 | ||
1806 | mActionUndo->setEnabled( false ); | 1806 | mActionUndo->setEnabled( false ); |
1807 | mActionRedo->setEnabled( false ); | 1807 | mActionRedo->setEnabled( false ); |
1808 | 1808 | ||
1809 | // settings menu | 1809 | // settings menu |
1810 | #ifdef KAB_EMBEDDED | 1810 | #ifdef KAB_EMBEDDED |
1811 | //US special menuentry to configure the addressbook resources. On KDE | 1811 | //US special menuentry to configure the addressbook resources. On KDE |
1812 | // you do that through the control center !!! | 1812 | // you do that through the control center !!! |
1813 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 1813 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
1814 | SLOT( configureResources() ), actionCollection(), | 1814 | SLOT( configureResources() ), actionCollection(), |
1815 | "kaddressbook_configure_resources" ); | 1815 | "kaddressbook_configure_resources" ); |
1816 | #endif //KAB_EMBEDDED | 1816 | #endif //KAB_EMBEDDED |
1817 | 1817 | ||
1818 | if ( mIsPart ) { | 1818 | if ( mIsPart ) { |
1819 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 1819 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
1820 | SLOT( openConfigDialog() ), actionCollection(), | 1820 | SLOT( openConfigDialog() ), actionCollection(), |
1821 | "kaddressbook_configure" ); | 1821 | "kaddressbook_configure" ); |
1822 | 1822 | ||
1823 | //US not implemented yet | 1823 | //US not implemented yet |
1824 | //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 1824 | //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
1825 | // this, SLOT( configureKeyBindings() ), actionCollection(), | 1825 | // this, SLOT( configureKeyBindings() ), actionCollection(), |
1826 | // "kaddressbook_configure_shortcuts" ); | 1826 | // "kaddressbook_configure_shortcuts" ); |
1827 | #ifdef KAB_EMBEDDED | 1827 | #ifdef KAB_EMBEDDED |
1828 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 1828 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
1829 | mActionConfigureToolbars->setEnabled( false ); | 1829 | mActionConfigureToolbars->setEnabled( false ); |
1830 | #endif //KAB_EMBEDDED | 1830 | #endif //KAB_EMBEDDED |
1831 | 1831 | ||
1832 | } else { | 1832 | } else { |
1833 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 1833 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
1834 | 1834 | ||
1835 | //US not implemented yet | 1835 | //US not implemented yet |
1836 | //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 1836 | //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
1837 | } | 1837 | } |
1838 | 1838 | ||
1839 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 1839 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
1840 | actionCollection(), "options_show_jump_bar" ); | 1840 | actionCollection(), "options_show_jump_bar" ); |
1841 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); | 1841 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); |
1842 | 1842 | ||
1843 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, | 1843 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
1844 | actionCollection(), "options_show_details" ); | 1844 | actionCollection(), "options_show_details" ); |
1845 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 1845 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
1846 | 1846 | ||
1847 | 1847 | ||
1848 | mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, | 1848 | mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, |
1849 | SLOT( toggleBeamReceive() ), actionCollection(), | 1849 | SLOT( toggleBeamReceive() ), actionCollection(), |
1850 | "kaddressbook_beam_rec" ); | 1850 | "kaddressbook_beam_rec" ); |
1851 | 1851 | ||
1852 | 1852 | ||
1853 | // misc | 1853 | // misc |
1854 | // only enable LDAP lookup if we can handle the protocol | 1854 | // only enable LDAP lookup if we can handle the protocol |
1855 | #ifndef KAB_EMBEDDED | 1855 | #ifndef KAB_EMBEDDED |
1856 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 1856 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
1857 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 1857 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
1858 | this, SLOT( openLDAPDialog() ), actionCollection(), | 1858 | this, SLOT( openLDAPDialog() ), actionCollection(), |
1859 | "ldap_lookup" ); | 1859 | "ldap_lookup" ); |
1860 | } | 1860 | } |
1861 | #else //KAB_EMBEDDED | 1861 | #else //KAB_EMBEDDED |
1862 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 1862 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
1863 | #endif //KAB_EMBEDDED | 1863 | #endif //KAB_EMBEDDED |
1864 | 1864 | ||
1865 | 1865 | ||
1866 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 1866 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
1867 | SLOT( setWhoAmI() ), actionCollection(), | 1867 | SLOT( setWhoAmI() ), actionCollection(), |
1868 | "set_personal" ); | 1868 | "set_personal" ); |
1869 | 1869 | ||
1870 | 1870 | ||
1871 | 1871 | ||
1872 | 1872 | ||
1873 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 1873 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
1874 | SLOT( setCategories() ), actionCollection(), | 1874 | SLOT( setCategories() ), actionCollection(), |
1875 | "edit_set_categories" ); | 1875 | "edit_set_categories" ); |
1876 | 1876 | ||
1877 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 1877 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
1878 | SLOT( removeVoice() ), actionCollection(), | 1878 | SLOT( removeVoice() ), actionCollection(), |
1879 | "remove_voice" ); | 1879 | "remove_voice" ); |
1880 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, | 1880 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, |
1881 | SLOT( importFromOL() ), actionCollection(), | 1881 | SLOT( importFromOL() ), actionCollection(), |
1882 | "import_OL" ); | 1882 | "import_OL" ); |
1883 | #ifdef KAB_EMBEDDED | 1883 | #ifdef KAB_EMBEDDED |
1884 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 1884 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
1885 | this, SLOT( showLicence() ), actionCollection(), | 1885 | this, SLOT( showLicence() ), actionCollection(), |
1886 | "licence_about_data" ); | 1886 | "licence_about_data" ); |
1887 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 1887 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
1888 | this, SLOT( faq() ), actionCollection(), | 1888 | this, SLOT( faq() ), actionCollection(), |
1889 | "faq_about_data" ); | 1889 | "faq_about_data" ); |
1890 | mActionWN = new KAction( i18n( "What's New?" ), 0, | 1890 | mActionWN = new KAction( i18n( "What's New?" ), 0, |
1891 | this, SLOT( whatsnew() ), actionCollection(), | 1891 | this, SLOT( whatsnew() ), actionCollection(), |
1892 | "wn" ); | 1892 | "wn" ); |
1893 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, | 1893 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, |
1894 | this, SLOT( synchowto() ), actionCollection(), | 1894 | this, SLOT( synchowto() ), actionCollection(), |
1895 | "sync" ); | 1895 | "sync" ); |
1896 | 1896 | ||
1897 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 1897 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
1898 | this, SLOT( createAboutData() ), actionCollection(), | 1898 | this, SLOT( createAboutData() ), actionCollection(), |
1899 | "kaddressbook_about_data" ); | 1899 | "kaddressbook_about_data" ); |
1900 | #endif //KAB_EMBEDDED | 1900 | #endif //KAB_EMBEDDED |
1901 | 1901 | ||
1902 | clipboardDataChanged(); | 1902 | clipboardDataChanged(); |
1903 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1903 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1904 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1904 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1905 | } | 1905 | } |
1906 | 1906 | ||
1907 | //US we need this function, to plug all actions into the correct menues. | 1907 | //US we need this function, to plug all actions into the correct menues. |
1908 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 1908 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
1909 | void KABCore::addActionsManually() | 1909 | void KABCore::addActionsManually() |
1910 | { | 1910 | { |
1911 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1911 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1912 | 1912 | ||
1913 | #ifdef KAB_EMBEDDED | 1913 | #ifdef KAB_EMBEDDED |
1914 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 1914 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
1915 | QPopupMenu *editMenu = new QPopupMenu( this ); | 1915 | QPopupMenu *editMenu = new QPopupMenu( this ); |
1916 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 1916 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
1917 | 1917 | ||
1918 | KToolBar* tb = mMainWindow->toolBar(); | 1918 | KToolBar* tb = mMainWindow->toolBar(); |
1919 | 1919 | ||
1920 | #ifdef DESKTOP_VERSION | 1920 | #ifdef DESKTOP_VERSION |
1921 | QMenuBar* mb = mMainWindow->menuBar(); | 1921 | QMenuBar* mb = mMainWindow->menuBar(); |
1922 | 1922 | ||
1923 | //US setup menubar. | 1923 | //US setup menubar. |
1924 | //Disable the following block if you do not want to have a menubar. | 1924 | //Disable the following block if you do not want to have a menubar. |
1925 | mb->insertItem( "&File", fileMenu ); | 1925 | mb->insertItem( "&File", fileMenu ); |
1926 | mb->insertItem( "&Edit", editMenu ); | 1926 | mb->insertItem( "&Edit", editMenu ); |
1927 | mb->insertItem( "&View", viewMenu ); | 1927 | mb->insertItem( "&View", viewMenu ); |
1928 | mb->insertItem( "&Settings", settingsMenu ); | 1928 | mb->insertItem( "&Settings", settingsMenu ); |
1929 | mb->insertItem( i18n("Synchronize"), syncMenu ); | 1929 | mb->insertItem( i18n("Synchronize"), syncMenu ); |
1930 | mb->insertItem( "&Change selected", changeMenu ); | 1930 | mb->insertItem( "&Change selected", changeMenu ); |
1931 | mb->insertItem( "&Help", helpMenu ); | 1931 | mb->insertItem( "&Help", helpMenu ); |
1932 | mIncSearchWidget = new IncSearchWidget( tb ); | 1932 | mIncSearchWidget = new IncSearchWidget( tb ); |
1933 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 1933 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
1934 | 1934 | ||
1935 | #else | 1935 | #else |
1936 | //US setup toolbar | 1936 | //US setup toolbar |
1937 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 1937 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
1938 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 1938 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
1939 | menuBarTB->insertItem( "ME", popupBarTB); | 1939 | menuBarTB->insertItem( "ME", popupBarTB); |
1940 | tb->insertWidget(-1, 0, menuBarTB); | 1940 | tb->insertWidget(-1, 0, menuBarTB); |
1941 | mIncSearchWidget = new IncSearchWidget( tb ); | 1941 | mIncSearchWidget = new IncSearchWidget( tb ); |
1942 | 1942 | ||
1943 | tb->enableMoving(false); | 1943 | tb->enableMoving(false); |
1944 | popupBarTB->insertItem( "&File", fileMenu ); | 1944 | popupBarTB->insertItem( "&File", fileMenu ); |
1945 | popupBarTB->insertItem( "&Edit", editMenu ); | 1945 | popupBarTB->insertItem( "&Edit", editMenu ); |
1946 | popupBarTB->insertItem( "&View", viewMenu ); | 1946 | popupBarTB->insertItem( "&View", viewMenu ); |
1947 | popupBarTB->insertItem( "&Settings", settingsMenu ); | 1947 | popupBarTB->insertItem( "&Settings", settingsMenu ); |
1948 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); | 1948 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); |
1949 | mViewManager->getFilterAction()->plug ( popupBarTB); | 1949 | mViewManager->getFilterAction()->plug ( popupBarTB); |
1950 | popupBarTB->insertItem( "&Change selected", changeMenu ); | 1950 | popupBarTB->insertItem( "&Change selected", changeMenu ); |
1951 | popupBarTB->insertItem( "&Help", helpMenu ); | 1951 | popupBarTB->insertItem( "&Help", helpMenu ); |
1952 | if (QApplication::desktop()->width() > 320 ) { | 1952 | if (QApplication::desktop()->width() > 320 ) { |
1953 | // mViewManager->getFilterAction()->plug ( tb); | 1953 | // mViewManager->getFilterAction()->plug ( tb); |
1954 | } | 1954 | } |
1955 | #endif | 1955 | #endif |
1956 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1956 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1957 | 1957 | ||
1958 | 1958 | ||
1959 | 1959 | ||
1960 | //US Now connect the actions with the menue entries. | 1960 | //US Now connect the actions with the menue entries. |
1961 | mActionPrint->plug( fileMenu ); | 1961 | mActionPrint->plug( fileMenu ); |
1962 | mActionMail->plug( fileMenu ); | 1962 | mActionMail->plug( fileMenu ); |
1963 | fileMenu->insertSeparator(); | 1963 | fileMenu->insertSeparator(); |
1964 | 1964 | ||
1965 | mActionNewContact->plug( fileMenu ); | 1965 | mActionNewContact->plug( fileMenu ); |
1966 | mActionNewContact->plug( tb ); | 1966 | mActionNewContact->plug( tb ); |
1967 | 1967 | ||
1968 | mActionEditAddressee->plug( fileMenu ); | 1968 | mActionEditAddressee->plug( fileMenu ); |
1969 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 1969 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
1970 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 1970 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
1971 | mActionEditAddressee->plug( tb ); | 1971 | mActionEditAddressee->plug( tb ); |
1972 | 1972 | ||
1973 | fileMenu->insertSeparator(); | 1973 | fileMenu->insertSeparator(); |
1974 | mActionSave->plug( fileMenu ); | 1974 | mActionSave->plug( fileMenu ); |
1975 | fileMenu->insertItem( "&Import", ImportMenu ); | 1975 | fileMenu->insertItem( "&Import", ImportMenu ); |
1976 | fileMenu->insertItem( "&Export", ExportMenu ); | 1976 | fileMenu->insertItem( "&Export", ExportMenu ); |
1977 | fileMenu->insertSeparator(); | 1977 | fileMenu->insertSeparator(); |
1978 | mActionMailVCard->plug( fileMenu ); | 1978 | mActionMailVCard->plug( fileMenu ); |
1979 | #ifndef DESKTOP_VERSION | 1979 | #ifndef DESKTOP_VERSION |
1980 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); | 1980 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); |
1981 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); | 1981 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); |
1982 | #endif | 1982 | #endif |
1983 | fileMenu->insertSeparator(); | 1983 | fileMenu->insertSeparator(); |
1984 | mActionQuit->plug( fileMenu ); | 1984 | mActionQuit->plug( fileMenu ); |
1985 | #ifdef _WIN32_ | 1985 | #ifdef _WIN32_ |
1986 | mActionImportOL->plug( ImportMenu ); | 1986 | mActionImportOL->plug( ImportMenu ); |
1987 | #endif | 1987 | #endif |
1988 | // edit menu | 1988 | // edit menu |
1989 | mActionUndo->plug( editMenu ); | 1989 | mActionUndo->plug( editMenu ); |
1990 | mActionRedo->plug( editMenu ); | 1990 | mActionRedo->plug( editMenu ); |
1991 | editMenu->insertSeparator(); | 1991 | editMenu->insertSeparator(); |
1992 | mActionCut->plug( editMenu ); | 1992 | mActionCut->plug( editMenu ); |
1993 | mActionCopy->plug( editMenu ); | 1993 | mActionCopy->plug( editMenu ); |
1994 | mActionPaste->plug( editMenu ); | 1994 | mActionPaste->plug( editMenu ); |
1995 | mActionDelete->plug( editMenu ); | 1995 | mActionDelete->plug( editMenu ); |
1996 | editMenu->insertSeparator(); | 1996 | editMenu->insertSeparator(); |
1997 | mActionSelectAll->plug( editMenu ); | 1997 | mActionSelectAll->plug( editMenu ); |
1998 | 1998 | ||
1999 | mActionRemoveVoice->plug( changeMenu ); | 1999 | mActionRemoveVoice->plug( changeMenu ); |
2000 | // settings menu | 2000 | // settings menu |
2001 | //US special menuentry to configure the addressbook resources. On KDE | 2001 | //US special menuentry to configure the addressbook resources. On KDE |
2002 | // you do that through the control center !!! | 2002 | // you do that through the control center !!! |
2003 | mActionConfigResources->plug( settingsMenu ); | 2003 | mActionConfigResources->plug( settingsMenu ); |
2004 | settingsMenu->insertSeparator(); | 2004 | settingsMenu->insertSeparator(); |
2005 | 2005 | ||
2006 | mActionConfigKAddressbook->plug( settingsMenu ); | 2006 | mActionConfigKAddressbook->plug( settingsMenu ); |
2007 | 2007 | ||
2008 | if ( mIsPart ) { | 2008 | if ( mIsPart ) { |
2009 | //US not implemented yet | 2009 | //US not implemented yet |
2010 | //mActionConfigShortcuts->plug( settingsMenu ); | 2010 | //mActionConfigShortcuts->plug( settingsMenu ); |
2011 | //mActionConfigureToolbars->plug( settingsMenu ); | 2011 | //mActionConfigureToolbars->plug( settingsMenu ); |
2012 | 2012 | ||
2013 | } else { | 2013 | } else { |
2014 | //US not implemented yet | 2014 | //US not implemented yet |
2015 | //mActionKeyBindings->plug( settingsMenu ); | 2015 | //mActionKeyBindings->plug( settingsMenu ); |
2016 | } | 2016 | } |
2017 | 2017 | ||
2018 | settingsMenu->insertSeparator(); | 2018 | settingsMenu->insertSeparator(); |
2019 | 2019 | ||
2020 | mActionJumpBar->plug( settingsMenu ); | 2020 | mActionJumpBar->plug( settingsMenu ); |
2021 | mActionDetails->plug( settingsMenu ); | 2021 | mActionDetails->plug( settingsMenu ); |
2022 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 2022 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
2023 | mActionDetails->plug( tb ); | 2023 | mActionDetails->plug( tb ); |
2024 | settingsMenu->insertSeparator(); | 2024 | settingsMenu->insertSeparator(); |
2025 | mActionBR->plug(settingsMenu ); | 2025 | mActionBR->plug(settingsMenu ); |
2026 | settingsMenu->insertSeparator(); | 2026 | settingsMenu->insertSeparator(); |
2027 | 2027 | ||
2028 | mActionWhoAmI->plug( settingsMenu ); | 2028 | mActionWhoAmI->plug( settingsMenu ); |
2029 | mActionCategories->plug( settingsMenu ); | 2029 | mActionCategories->plug( settingsMenu ); |
2030 | 2030 | ||
2031 | 2031 | ||
2032 | mActionWN->plug( helpMenu ); | 2032 | mActionWN->plug( helpMenu ); |
2033 | mActionSyncHowto->plug( helpMenu ); | 2033 | mActionSyncHowto->plug( helpMenu ); |
2034 | mActionLicence->plug( helpMenu ); | 2034 | mActionLicence->plug( helpMenu ); |
2035 | mActionFaq->plug( helpMenu ); | 2035 | mActionFaq->plug( helpMenu ); |
2036 | mActionAboutKAddressbook->plug( helpMenu ); | 2036 | mActionAboutKAddressbook->plug( helpMenu ); |
2037 | 2037 | ||
2038 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 2038 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
2039 | 2039 | ||
2040 | mActionSave->plug( tb ); | 2040 | mActionSave->plug( tb ); |
2041 | mViewManager->getFilterAction()->plug ( tb); | 2041 | mViewManager->getFilterAction()->plug ( tb); |
2042 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { | 2042 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { |
2043 | mActionUndo->plug( tb ); | 2043 | mActionUndo->plug( tb ); |
2044 | mActionDelete->plug( tb ); | 2044 | mActionDelete->plug( tb ); |
2045 | mActionRedo->plug( tb ); | 2045 | mActionRedo->plug( tb ); |
2046 | } | 2046 | } |
2047 | } | 2047 | } |
2048 | //mActionQuit->plug ( tb ); | 2048 | //mActionQuit->plug ( tb ); |
2049 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 2049 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
2050 | 2050 | ||
2051 | //US link the searchwidget first to this. | 2051 | //US link the searchwidget first to this. |
2052 | // The real linkage to the toolbar happens later. | 2052 | // The real linkage to the toolbar happens later. |
2053 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 2053 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
2054 | //US tb->insertItem( mIncSearchWidget ); | 2054 | //US tb->insertItem( mIncSearchWidget ); |
2055 | /*US | 2055 | /*US |
2056 | mIncSearchWidget = new IncSearchWidget( tb ); | 2056 | mIncSearchWidget = new IncSearchWidget( tb ); |
2057 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 2057 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
2058 | SLOT( incrementalSearch( const QString& ) ) ); | 2058 | SLOT( incrementalSearch( const QString& ) ) ); |
2059 | 2059 | ||
2060 | mJumpButtonBar = new JumpButtonBar( this, this ); | 2060 | mJumpButtonBar = new JumpButtonBar( this, this ); |
2061 | 2061 | ||
2062 | //US topLayout->addWidget( mJumpButtonBar ); | 2062 | //US topLayout->addWidget( mJumpButtonBar ); |
2063 | this->layout()->add( mJumpButtonBar ); | 2063 | this->layout()->add( mJumpButtonBar ); |
2064 | */ | 2064 | */ |
2065 | 2065 | ||
2066 | #endif //KAB_EMBEDDED | 2066 | #endif //KAB_EMBEDDED |
2067 | 2067 | ||
2068 | mActionExport2phone->plug( ExportMenu ); | 2068 | mActionExport2phone->plug( ExportMenu ); |
2069 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 2069 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
2070 | syncManager->fillSyncMenu(); | 2070 | syncManager->fillSyncMenu(); |
2071 | 2071 | ||
2072 | } | 2072 | } |
2073 | void KABCore::showLicence() | 2073 | void KABCore::showLicence() |
2074 | { | 2074 | { |
2075 | KApplication::showLicence(); | 2075 | KApplication::showLicence(); |
2076 | } | 2076 | } |
2077 | void KABCore::removeVoice() | 2077 | void KABCore::removeVoice() |
2078 | { | 2078 | { |
2079 | 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 ) | 2079 | 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 ) |
2080 | return; | 2080 | return; |
2081 | KABC::Addressee::List list = mViewManager->selectedAddressees(); | 2081 | KABC::Addressee::List list = mViewManager->selectedAddressees(); |
2082 | KABC::Addressee::List::Iterator it; | 2082 | KABC::Addressee::List::Iterator it; |
2083 | for ( it = list.begin(); it != list.end(); ++it ) { | 2083 | for ( it = list.begin(); it != list.end(); ++it ) { |
2084 | 2084 | ||
2085 | if ( (*it).removeVoice() ) | 2085 | if ( (*it).removeVoice() ) |
2086 | contactModified((*it) ); | 2086 | contactModified((*it) ); |
2087 | } | 2087 | } |
2088 | } | 2088 | } |
2089 | 2089 | ||
2090 | 2090 | ||
2091 | 2091 | ||
2092 | void KABCore::clipboardDataChanged() | 2092 | void KABCore::clipboardDataChanged() |
2093 | { | 2093 | { |
2094 | 2094 | ||
2095 | if ( mReadWrite ) | 2095 | if ( mReadWrite ) |
2096 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 2096 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
2097 | 2097 | ||
2098 | } | 2098 | } |
2099 | 2099 | ||
2100 | void KABCore::updateActionMenu() | 2100 | void KABCore::updateActionMenu() |
2101 | { | 2101 | { |
2102 | UndoStack *undo = UndoStack::instance(); | 2102 | UndoStack *undo = UndoStack::instance(); |
2103 | RedoStack *redo = RedoStack::instance(); | 2103 | RedoStack *redo = RedoStack::instance(); |
2104 | 2104 | ||
2105 | if ( undo->isEmpty() ) | 2105 | if ( undo->isEmpty() ) |
2106 | mActionUndo->setText( i18n( "Undo" ) ); | 2106 | mActionUndo->setText( i18n( "Undo" ) ); |
2107 | else | 2107 | else |
2108 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 2108 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
2109 | 2109 | ||
2110 | mActionUndo->setEnabled( !undo->isEmpty() ); | 2110 | mActionUndo->setEnabled( !undo->isEmpty() ); |
2111 | 2111 | ||
2112 | if ( !redo->top() ) | 2112 | if ( !redo->top() ) |
2113 | mActionRedo->setText( i18n( "Redo" ) ); | 2113 | mActionRedo->setText( i18n( "Redo" ) ); |
2114 | else | 2114 | else |
2115 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 2115 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
2116 | 2116 | ||
2117 | mActionRedo->setEnabled( !redo->isEmpty() ); | 2117 | mActionRedo->setEnabled( !redo->isEmpty() ); |
2118 | } | 2118 | } |
2119 | 2119 | ||
2120 | void KABCore::configureKeyBindings() | 2120 | void KABCore::configureKeyBindings() |
2121 | { | 2121 | { |
2122 | #ifndef KAB_EMBEDDED | 2122 | #ifndef KAB_EMBEDDED |
2123 | KKeyDialog::configure( actionCollection(), true ); | 2123 | KKeyDialog::configure( actionCollection(), true ); |
2124 | #else //KAB_EMBEDDED | 2124 | #else //KAB_EMBEDDED |
2125 | qDebug("KABCore::configureKeyBindings() not implemented"); | 2125 | qDebug("KABCore::configureKeyBindings() not implemented"); |
2126 | #endif //KAB_EMBEDDED | 2126 | #endif //KAB_EMBEDDED |
2127 | } | 2127 | } |
2128 | 2128 | ||
2129 | #ifdef KAB_EMBEDDED | 2129 | #ifdef KAB_EMBEDDED |
2130 | void KABCore::configureResources() | 2130 | void KABCore::configureResources() |
2131 | { | 2131 | { |
2132 | KRES::KCMKResources dlg( this, "" , 0 ); | 2132 | KRES::KCMKResources dlg( this, "" , 0 ); |
2133 | 2133 | ||
2134 | if ( !dlg.exec() ) | 2134 | if ( !dlg.exec() ) |
2135 | return; | 2135 | return; |
2136 | 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") ); |
2137 | } | 2137 | } |
2138 | #endif //KAB_EMBEDDED | 2138 | #endif //KAB_EMBEDDED |
2139 | 2139 | ||
2140 | 2140 | ||
2141 | /* 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 |
2142 | * for the attendees list of an event. | 2142 | * for the attendees list of an event. |
2143 | */ | 2143 | */ |
2144 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 2144 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
2145 | { | 2145 | { |
2146 | QStringList nameList; | 2146 | QStringList nameList; |
2147 | QStringList emailList; | 2147 | QStringList emailList; |
2148 | QStringList uidList; | 2148 | QStringList uidList; |
2149 | 2149 | ||
2150 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 2150 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
2151 | uint i=0; | 2151 | uint i=0; |
2152 | for (i=0; i < list.count(); i++) | 2152 | for (i=0; i < list.count(); i++) |
2153 | { | 2153 | { |
2154 | nameList.append(list[i].realName()); | 2154 | nameList.append(list[i].realName()); |
2155 | emailList.append(list[i].preferredEmail()); | 2155 | emailList.append(list[i].preferredEmail()); |
2156 | uidList.append(list[i].uid()); | 2156 | uidList.append(list[i].uid()); |
2157 | } | 2157 | } |
2158 | 2158 | ||
2159 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); | 2159 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); |
2160 | 2160 | ||
2161 | } | 2161 | } |
2162 | 2162 | ||
2163 | /* 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 |
2164 | * to put them into the calendar. | 2164 | * to put them into the calendar. |
2165 | */ | 2165 | */ |
2166 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) | 2166 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) |
2167 | { | 2167 | { |
2168 | // qDebug("KABCore::requestForBirthdayList"); | 2168 | // qDebug("KABCore::requestForBirthdayList"); |
2169 | QStringList birthdayList; | 2169 | QStringList birthdayList; |
2170 | QStringList anniversaryList; | 2170 | QStringList anniversaryList; |
2171 | QStringList realNameList; | 2171 | QStringList realNameList; |
2172 | QStringList preferredEmailList; | 2172 | QStringList preferredEmailList; |
2173 | QStringList assembledNameList; | 2173 | QStringList assembledNameList; |
2174 | QStringList uidList; | 2174 | QStringList uidList; |
2175 | 2175 | ||
2176 | KABC::AddressBook::Iterator it; | 2176 | KABC::AddressBook::Iterator it; |
2177 | 2177 | ||
2178 | int count = 0; | 2178 | int count = 0; |
2179 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2179 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2180 | ++count; | 2180 | ++count; |
2181 | } | 2181 | } |
2182 | QProgressBar bar(count,0 ); | 2182 | QProgressBar bar(count,0 ); |
2183 | int w = 300; | 2183 | int w = 300; |
2184 | if ( QApplication::desktop()->width() < 320 ) | 2184 | if ( QApplication::desktop()->width() < 320 ) |
2185 | w = 220; | 2185 | w = 220; |
2186 | int h = bar.sizeHint().height() ; | 2186 | int h = bar.sizeHint().height() ; |
2187 | int dw = QApplication::desktop()->width(); | 2187 | int dw = QApplication::desktop()->width(); |
2188 | int dh = QApplication::desktop()->height(); | 2188 | int dh = QApplication::desktop()->height(); |
2189 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2189 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2190 | bar.show(); | 2190 | bar.show(); |
2191 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); | 2191 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); |
2192 | qApp->processEvents(); | 2192 | qApp->processEvents(); |
2193 | 2193 | ||
2194 | QDate bday; | 2194 | QDate bday; |
2195 | QString anni; | 2195 | QString anni; |
2196 | QString formattedbday; | 2196 | QString formattedbday; |
2197 | 2197 | ||
2198 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) | 2198 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) |
2199 | { | 2199 | { |
2200 | if ( ! bar.isVisible() ) | 2200 | if ( ! bar.isVisible() ) |
2201 | return; | 2201 | return; |
2202 | bar.setProgress( count++ ); | 2202 | bar.setProgress( count++ ); |
2203 | qApp->processEvents(); | 2203 | qApp->processEvents(); |
2204 | bday = (*it).birthday().date(); | 2204 | bday = (*it).birthday().date(); |
2205 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); | 2205 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); |
2206 | 2206 | ||
2207 | if ( bday.isValid() || !anni.isEmpty()) | 2207 | if ( bday.isValid() || !anni.isEmpty()) |
2208 | { | 2208 | { |
2209 | if (bday.isValid()) | 2209 | if (bday.isValid()) |
2210 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); | 2210 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); |
2211 | else | 2211 | else |
2212 | formattedbday = "NOTVALID"; | 2212 | formattedbday = "NOTVALID"; |
2213 | if (anni.isEmpty()) | 2213 | if (anni.isEmpty()) |
2214 | anni = "INVALID"; | 2214 | anni = "INVALID"; |
2215 | 2215 | ||
2216 | birthdayList.append(formattedbday); | 2216 | birthdayList.append(formattedbday); |
2217 | anniversaryList.append(anni); //should be ISODate | 2217 | anniversaryList.append(anni); //should be ISODate |
2218 | realNameList.append((*it).realName()); | 2218 | realNameList.append((*it).realName()); |
2219 | preferredEmailList.append((*it).preferredEmail()); | 2219 | preferredEmailList.append((*it).preferredEmail()); |
2220 | assembledNameList.append((*it).assembledName()); | 2220 | assembledNameList.append((*it).assembledName()); |
2221 | uidList.append((*it).uid()); | 2221 | uidList.append((*it).uid()); |
2222 | 2222 | ||
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() ); | 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() ); |
2224 | } | 2224 | } |
2225 | } | 2225 | } |
2226 | 2226 | ||
2227 | 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); |
2228 | 2228 | ||
2229 | } | 2229 | } |
2230 | 2230 | ||
2231 | /* 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. |
2232 | */ | 2232 | */ |
2233 | 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) |
2234 | { | 2234 | { |
2235 | 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()); |
2236 | 2236 | ||
2237 | QString foundUid = QString::null; | 2237 | QString foundUid = QString::null; |
2238 | if ( ! uid.isEmpty() ) { | 2238 | if ( ! uid.isEmpty() ) { |
2239 | Addressee adrr = mAddressBook->findByUid( uid ); | 2239 | Addressee adrr = mAddressBook->findByUid( uid ); |
2240 | if ( !adrr.isEmpty() ) { | 2240 | if ( !adrr.isEmpty() ) { |
2241 | foundUid = uid; | 2241 | foundUid = uid; |
2242 | } | 2242 | } |
2243 | if ( email == "sendbacklist" ) { | 2243 | if ( email == "sendbacklist" ) { |
2244 | //qDebug("ssssssssssssssssssssssend "); | 2244 | //qDebug("ssssssssssssssssssssssend "); |
2245 | QStringList nameList; | 2245 | QStringList nameList; |
2246 | QStringList emailList; | 2246 | QStringList emailList; |
2247 | QStringList uidList; | 2247 | QStringList uidList; |
2248 | nameList.append(adrr.realName()); | 2248 | nameList.append(adrr.realName()); |
2249 | emailList = adrr.emails(); | 2249 | emailList = adrr.emails(); |
2250 | uidList.append( adrr.preferredEmail()); | 2250 | uidList.append( adrr.preferredEmail()); |
2251 | 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); |
2252 | return; | 2252 | return; |
2253 | } | 2253 | } |
2254 | 2254 | ||
2255 | } | 2255 | } |
2256 | 2256 | ||
2257 | if ( email == "sendbacklist" ) | 2257 | if ( email == "sendbacklist" ) |
2258 | return; | 2258 | return; |
2259 | if (foundUid.isEmpty()) | 2259 | if (foundUid.isEmpty()) |
2260 | { | 2260 | { |
2261 | //find the uid of the person first | 2261 | //find the uid of the person first |
2262 | Addressee::List namelist; | 2262 | Addressee::List namelist; |
2263 | Addressee::List emaillist; | 2263 | Addressee::List emaillist; |
2264 | 2264 | ||
2265 | if (!name.isEmpty()) | 2265 | if (!name.isEmpty()) |
2266 | namelist = mAddressBook->findByName( name ); | 2266 | namelist = mAddressBook->findByName( name ); |
2267 | 2267 | ||
2268 | if (!email.isEmpty()) | 2268 | if (!email.isEmpty()) |
2269 | emaillist = mAddressBook->findByEmail( email ); | 2269 | emaillist = mAddressBook->findByEmail( email ); |
2270 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2270 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2271 | //check if we have a match in Namelist and Emaillist | 2271 | //check if we have a match in Namelist and Emaillist |
2272 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2272 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2273 | foundUid = emaillist[0].uid(); | 2273 | foundUid = emaillist[0].uid(); |
2274 | } | 2274 | } |
2275 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2275 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2276 | foundUid = namelist[0].uid(); | 2276 | foundUid = namelist[0].uid(); |
2277 | else | 2277 | else |
2278 | { | 2278 | { |
2279 | for (int i = 0; i < namelist.count(); i++) | 2279 | for (int i = 0; i < namelist.count(); i++) |
2280 | { | 2280 | { |
2281 | for (int j = 0; j < emaillist.count(); j++) | 2281 | for (int j = 0; j < emaillist.count(); j++) |
2282 | { | 2282 | { |
2283 | if (namelist[i] == emaillist[j]) | 2283 | if (namelist[i] == emaillist[j]) |
2284 | { | 2284 | { |
2285 | foundUid = namelist[i].uid(); | 2285 | foundUid = namelist[i].uid(); |
2286 | } | 2286 | } |
2287 | } | 2287 | } |
2288 | } | 2288 | } |
2289 | } | 2289 | } |
2290 | } | 2290 | } |
2291 | else | 2291 | else |
2292 | { | 2292 | { |
2293 | foundUid = uid; | 2293 | foundUid = uid; |
2294 | } | 2294 | } |
2295 | 2295 | ||
2296 | if (!foundUid.isEmpty()) | 2296 | if (!foundUid.isEmpty()) |
2297 | { | 2297 | { |
2298 | 2298 | ||
2299 | // raise Ka/Pi if it is in the background | 2299 | // raise Ka/Pi if it is in the background |
2300 | #ifndef DESKTOP_VERSION | 2300 | #ifndef DESKTOP_VERSION |
2301 | #ifndef KORG_NODCOP | 2301 | #ifndef KORG_NODCOP |
2302 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2302 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2303 | #endif | 2303 | #endif |
2304 | #endif | 2304 | #endif |
2305 | 2305 | ||
2306 | mMainWindow->showMaximized(); | 2306 | mMainWindow->showMaximized(); |
2307 | mMainWindow-> raise(); | 2307 | mMainWindow-> raise(); |
2308 | 2308 | ||
2309 | mViewManager->setSelected( "", false); | 2309 | mViewManager->setSelected( "", false); |
2310 | mViewManager->refreshView( "" ); | 2310 | mViewManager->refreshView( "" ); |
2311 | mViewManager->setSelected( foundUid, true ); | 2311 | mViewManager->setSelected( foundUid, true ); |
2312 | mViewManager->refreshView( foundUid ); | 2312 | mViewManager->refreshView( foundUid ); |
2313 | 2313 | ||
2314 | if ( !mMultipleViewsAtOnce ) | 2314 | if ( !mMultipleViewsAtOnce ) |
2315 | { | 2315 | { |
2316 | setDetailsVisible( true ); | 2316 | setDetailsVisible( true ); |
2317 | mActionDetails->setChecked(true); | 2317 | mActionDetails->setChecked(true); |
2318 | } | 2318 | } |
2319 | } | 2319 | } |
2320 | } | 2320 | } |
2321 | 2321 | ||
2322 | void KABCore::whatsnew() | 2322 | void KABCore::whatsnew() |
2323 | { | 2323 | { |
2324 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 2324 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
2325 | } | 2325 | } |
2326 | void KABCore::synchowto() | 2326 | void KABCore::synchowto() |
2327 | { | 2327 | { |
2328 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 2328 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
2329 | } | 2329 | } |
2330 | 2330 | ||
2331 | void KABCore::faq() | 2331 | void KABCore::faq() |
2332 | { | 2332 | { |
2333 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2333 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2334 | } | 2334 | } |
2335 | 2335 | ||
2336 | #include <libkcal/syncdefines.h> | 2336 | #include <libkcal/syncdefines.h> |
2337 | 2337 | ||
2338 | KABC::Addressee KABCore::getLastSyncAddressee() | 2338 | KABC::Addressee KABCore::getLastSyncAddressee() |
2339 | { | 2339 | { |
2340 | Addressee lse; | 2340 | Addressee lse; |
2341 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2341 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2342 | 2342 | ||
2343 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2343 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2344 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2344 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2345 | if (lse.isEmpty()) { | 2345 | if (lse.isEmpty()) { |
2346 | qDebug("Creating new last-syncAddressee "); | 2346 | qDebug("Creating new last-syncAddressee "); |
2347 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2347 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2348 | QString sum = ""; | 2348 | QString sum = ""; |
2349 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2349 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2350 | sum = "E: "; | 2350 | sum = "E: "; |
2351 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2351 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2352 | lse.setRevision( mLastAddressbookSync ); | 2352 | lse.setRevision( mLastAddressbookSync ); |
2353 | lse.setCategories( i18n("SyncEvent") ); | 2353 | lse.setCategories( i18n("SyncEvent") ); |
2354 | mAddressBook->insertAddressee( lse ); | 2354 | mAddressBook->insertAddressee( lse ); |
2355 | } | 2355 | } |
2356 | return lse; | 2356 | return lse; |
2357 | } | 2357 | } |
2358 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2358 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2359 | { | 2359 | { |
2360 | 2360 | ||
2361 | //void setZaurusId(int id); | 2361 | //void setZaurusId(int id); |
2362 | // int zaurusId() const; | 2362 | // int zaurusId() const; |
2363 | // void setZaurusUid(int id); | 2363 | // void setZaurusUid(int id); |
2364 | // int zaurusUid() const; | 2364 | // int zaurusUid() const; |
2365 | // void setZaurusStat(int id); | 2365 | // void setZaurusStat(int id); |
2366 | // int zaurusStat() const; | 2366 | // int zaurusStat() const; |
2367 | // 0 equal | 2367 | // 0 equal |
2368 | // 1 take local | 2368 | // 1 take local |
2369 | // 2 take remote | 2369 | // 2 take remote |
2370 | // 3 cancel | 2370 | // 3 cancel |
2371 | QDateTime lastSync = mLastAddressbookSync; | 2371 | QDateTime lastSync = mLastAddressbookSync; |
2372 | QDateTime localMod = local->revision(); | 2372 | QDateTime localMod = local->revision(); |
2373 | QDateTime remoteMod = remote->revision(); | 2373 | QDateTime remoteMod = remote->revision(); |
2374 | 2374 | ||
2375 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2375 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2376 | 2376 | ||
2377 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2377 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2378 | bool remCh, locCh; | 2378 | bool remCh, locCh; |
2379 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2379 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2380 | 2380 | ||
2381 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2381 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2382 | locCh = ( localMod > mLastAddressbookSync ); | 2382 | locCh = ( localMod > mLastAddressbookSync ); |
2383 | if ( !remCh && ! locCh ) { | 2383 | if ( !remCh && ! locCh ) { |
2384 | //qDebug("both not changed "); | 2384 | //qDebug("both not changed "); |
2385 | lastSync = localMod.addDays(1); | 2385 | lastSync = localMod.addDays(1); |
2386 | if ( mode <= SYNC_PREF_ASK ) | 2386 | if ( mode <= SYNC_PREF_ASK ) |
2387 | return 0; | 2387 | return 0; |
2388 | } else { | 2388 | } else { |
2389 | if ( locCh ) { | 2389 | if ( locCh ) { |
2390 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2390 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2391 | lastSync = localMod.addDays( -1 ); | 2391 | lastSync = localMod.addDays( -1 ); |
2392 | if ( !remCh ) | 2392 | if ( !remCh ) |
2393 | remoteMod =( lastSync.addDays( -1 ) ); | 2393 | remoteMod =( lastSync.addDays( -1 ) ); |
2394 | } else { | 2394 | } else { |
2395 | //qDebug(" not loc changed "); | 2395 | //qDebug(" not loc changed "); |
2396 | lastSync = localMod.addDays( 1 ); | 2396 | lastSync = localMod.addDays( 1 ); |
2397 | if ( remCh ) | 2397 | if ( remCh ) |
2398 | remoteMod =( lastSync.addDays( 1 ) ); | 2398 | remoteMod =( lastSync.addDays( 1 ) ); |
2399 | 2399 | ||
2400 | } | 2400 | } |
2401 | } | 2401 | } |
2402 | full = true; | 2402 | full = true; |
2403 | if ( mode < SYNC_PREF_ASK ) | 2403 | if ( mode < SYNC_PREF_ASK ) |
2404 | mode = SYNC_PREF_ASK; | 2404 | mode = SYNC_PREF_ASK; |
2405 | } else { | 2405 | } else { |
2406 | if ( localMod == remoteMod ) | 2406 | if ( localMod == remoteMod ) |
2407 | return 0; | 2407 | return 0; |
2408 | 2408 | ||
2409 | } | 2409 | } |
2410 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 2410 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
2411 | 2411 | ||
2412 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); | 2412 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); |
2413 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 2413 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); |
2414 | //full = true; //debug only | 2414 | //full = true; //debug only |
2415 | if ( full ) { | 2415 | if ( full ) { |
2416 | bool equ = ( (*local) == (*remote) ); | 2416 | bool equ = ( (*local) == (*remote) ); |
2417 | if ( equ ) { | 2417 | if ( equ ) { |
2418 | //qDebug("equal "); | 2418 | //qDebug("equal "); |
2419 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2419 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2420 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2420 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2421 | } | 2421 | } |
2422 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2422 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2423 | return 0; | 2423 | return 0; |
2424 | 2424 | ||
2425 | }//else //debug only | 2425 | }//else //debug only |
2426 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2426 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2427 | } | 2427 | } |
2428 | int result; | 2428 | int result; |
2429 | bool localIsNew; | 2429 | bool localIsNew; |
2430 | //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() ); | 2430 | //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() ); |
2431 | 2431 | ||
2432 | if ( full && mode < SYNC_PREF_NEWEST ) | 2432 | if ( full && mode < SYNC_PREF_NEWEST ) |
2433 | mode = SYNC_PREF_ASK; | 2433 | mode = SYNC_PREF_ASK; |
2434 | 2434 | ||
2435 | switch( mode ) { | 2435 | switch( mode ) { |
2436 | case SYNC_PREF_LOCAL: | 2436 | case SYNC_PREF_LOCAL: |
2437 | if ( lastSync > remoteMod ) | 2437 | if ( lastSync > remoteMod ) |
2438 | return 1; | 2438 | return 1; |
2439 | if ( lastSync > localMod ) | 2439 | if ( lastSync > localMod ) |
2440 | return 2; | 2440 | return 2; |
2441 | return 1; | 2441 | return 1; |
2442 | break; | 2442 | break; |
2443 | case SYNC_PREF_REMOTE: | 2443 | case SYNC_PREF_REMOTE: |
2444 | if ( lastSync > remoteMod ) | 2444 | if ( lastSync > remoteMod ) |
2445 | return 1; | 2445 | return 1; |
2446 | if ( lastSync > localMod ) | 2446 | if ( lastSync > localMod ) |
2447 | return 2; | 2447 | return 2; |
2448 | return 2; | 2448 | return 2; |
2449 | break; | 2449 | break; |
2450 | case SYNC_PREF_NEWEST: | 2450 | case SYNC_PREF_NEWEST: |
2451 | if ( localMod > remoteMod ) | 2451 | if ( localMod > remoteMod ) |
2452 | return 1; | 2452 | return 1; |
2453 | else | 2453 | else |
2454 | return 2; | 2454 | return 2; |
2455 | break; | 2455 | break; |
2456 | case SYNC_PREF_ASK: | 2456 | case SYNC_PREF_ASK: |
2457 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 2457 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
2458 | if ( lastSync > remoteMod ) | 2458 | if ( lastSync > remoteMod ) |
2459 | return 1; | 2459 | return 1; |
2460 | if ( lastSync > localMod ) | 2460 | if ( lastSync > localMod ) |
2461 | return 2; | 2461 | return 2; |
2462 | localIsNew = localMod >= remoteMod; | 2462 | localIsNew = localMod >= remoteMod; |
2463 | //qDebug("conflict! ************************************** "); | 2463 | //qDebug("conflict! ************************************** "); |
2464 | { | 2464 | { |
2465 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | 2465 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); |
2466 | result = acd.executeD(localIsNew); | 2466 | result = acd.executeD(localIsNew); |
2467 | return result; | 2467 | return result; |
2468 | } | 2468 | } |
2469 | break; | 2469 | break; |
2470 | case SYNC_PREF_FORCE_LOCAL: | 2470 | case SYNC_PREF_FORCE_LOCAL: |
2471 | return 1; | 2471 | return 1; |
2472 | break; | 2472 | break; |
2473 | case SYNC_PREF_FORCE_REMOTE: | 2473 | case SYNC_PREF_FORCE_REMOTE: |
2474 | return 2; | 2474 | return 2; |
2475 | break; | 2475 | break; |
2476 | 2476 | ||
2477 | default: | 2477 | default: |
2478 | // SYNC_PREF_TAKE_BOTH not implemented | 2478 | // SYNC_PREF_TAKE_BOTH not implemented |
2479 | break; | 2479 | break; |
2480 | } | 2480 | } |
2481 | return 0; | 2481 | return 0; |
2482 | } | 2482 | } |
2483 | 2483 | ||
2484 | 2484 | ||
2485 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2485 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2486 | { | 2486 | { |
2487 | bool syncOK = true; | 2487 | bool syncOK = true; |
2488 | int addedAddressee = 0; | 2488 | int addedAddressee = 0; |
2489 | int addedAddresseeR = 0; | 2489 | int addedAddresseeR = 0; |
2490 | int deletedAddresseeR = 0; | 2490 | int deletedAddresseeR = 0; |
2491 | int deletedAddresseeL = 0; | 2491 | int deletedAddresseeL = 0; |
2492 | int changedLocal = 0; | 2492 | int changedLocal = 0; |
2493 | int changedRemote = 0; | 2493 | int changedRemote = 0; |
2494 | 2494 | ||
2495 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); | 2495 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); |
2496 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2496 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2497 | 2497 | ||
2498 | //QPtrList<Addressee> el = local->rawAddressees(); | 2498 | //QPtrList<Addressee> el = local->rawAddressees(); |
2499 | Addressee addresseeR; | 2499 | Addressee addresseeR; |
2500 | QString uid; | 2500 | QString uid; |
2501 | int take; | 2501 | int take; |
2502 | Addressee addresseeL; | 2502 | Addressee addresseeL; |
2503 | Addressee addresseeRSync; | 2503 | Addressee addresseeRSync; |
2504 | Addressee addresseeLSync; | 2504 | Addressee addresseeLSync; |
2505 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2505 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2506 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2506 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2507 | bool fullDateRange = false; | 2507 | bool fullDateRange = false; |
2508 | local->resetTempSyncStat(); | 2508 | local->resetTempSyncStat(); |
2509 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2509 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2510 | QDateTime modifiedCalendar = mLastAddressbookSync;; | 2510 | QDateTime modifiedCalendar = mLastAddressbookSync;; |
2511 | addresseeLSync = getLastSyncAddressee(); | 2511 | addresseeLSync = getLastSyncAddressee(); |
2512 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2512 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2513 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2513 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2514 | if ( !addresseeR.isEmpty() ) { | 2514 | if ( !addresseeR.isEmpty() ) { |
2515 | addresseeRSync = addresseeR; | 2515 | addresseeRSync = addresseeR; |
2516 | remote->removeAddressee(addresseeR ); | 2516 | remote->removeAddressee(addresseeR ); |
2517 | 2517 | ||
2518 | } else { | 2518 | } else { |
2519 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2519 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2520 | addresseeRSync = addresseeLSync ; | 2520 | addresseeRSync = addresseeLSync ; |
2521 | } else { | 2521 | } else { |
2522 | qDebug("FULLDATE 1"); | 2522 | qDebug("FULLDATE 1"); |
2523 | fullDateRange = true; | 2523 | fullDateRange = true; |
2524 | Addressee newAdd; | 2524 | Addressee newAdd; |
2525 | addresseeRSync = newAdd; | 2525 | addresseeRSync = newAdd; |
2526 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2526 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2527 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2527 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2528 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2528 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2529 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2529 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2530 | } | 2530 | } |
2531 | } | 2531 | } |
2532 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2532 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2533 | qDebug("FULLDATE 2"); | 2533 | qDebug("FULLDATE 2"); |
2534 | fullDateRange = true; | 2534 | fullDateRange = true; |
2535 | } | 2535 | } |
2536 | if ( ! fullDateRange ) { | 2536 | if ( ! fullDateRange ) { |
2537 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2537 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2538 | 2538 | ||
2539 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2539 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2540 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2540 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2541 | fullDateRange = true; | 2541 | fullDateRange = true; |
2542 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2542 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2543 | } | 2543 | } |
2544 | } | 2544 | } |
2545 | // fullDateRange = true; // debug only! | 2545 | // fullDateRange = true; // debug only! |
2546 | if ( fullDateRange ) | 2546 | if ( fullDateRange ) |
2547 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2547 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2548 | else | 2548 | else |
2549 | mLastAddressbookSync = addresseeLSync.revision(); | 2549 | mLastAddressbookSync = addresseeLSync.revision(); |
2550 | // for resyncing if own file has changed | 2550 | // for resyncing if own file has changed |
2551 | // PENDING fixme later when implemented | 2551 | // PENDING fixme later when implemented |
2552 | #if 0 | 2552 | #if 0 |
2553 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2553 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2554 | mLastAddressbookSync = loadedFileVersion; | 2554 | mLastAddressbookSync = loadedFileVersion; |
2555 | qDebug("setting mLastAddressbookSync "); | 2555 | qDebug("setting mLastAddressbookSync "); |
2556 | } | 2556 | } |
2557 | #endif | 2557 | #endif |
2558 | 2558 | ||
2559 | //qDebug("*************************** "); | 2559 | //qDebug("*************************** "); |
2560 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2560 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2561 | QStringList er = remote->uidList(); | 2561 | QStringList er = remote->uidList(); |
2562 | Addressee inR ;//= er.first(); | 2562 | Addressee inR ;//= er.first(); |
2563 | Addressee inL; | 2563 | Addressee inL; |
2564 | 2564 | ||
2565 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 2565 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
2566 | 2566 | ||
2567 | int modulo = (er.count()/10)+1; | 2567 | int modulo = (er.count()/10)+1; |
2568 | int incCounter = 0; | 2568 | int incCounter = 0; |
2569 | while ( incCounter < er.count()) { | 2569 | while ( incCounter < er.count()) { |
2570 | if (syncManager->isProgressBarCanceled()) | 2570 | if (syncManager->isProgressBarCanceled()) |
2571 | return false; | 2571 | return false; |
2572 | if ( incCounter % modulo == 0 ) | 2572 | if ( incCounter % modulo == 0 ) |
2573 | syncManager->showProgressBar(incCounter); | 2573 | syncManager->showProgressBar(incCounter); |
2574 | 2574 | ||
2575 | uid = er[ incCounter ]; | 2575 | uid = er[ incCounter ]; |
2576 | bool skipIncidence = false; | 2576 | bool skipIncidence = false; |
2577 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2577 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2578 | skipIncidence = true; | 2578 | skipIncidence = true; |
2579 | QString idS,OidS; | 2579 | QString idS,OidS; |
2580 | qApp->processEvents(); | 2580 | qApp->processEvents(); |
2581 | if ( !skipIncidence ) { | 2581 | if ( !skipIncidence ) { |
2582 | inL = local->findByUid( uid ); | 2582 | inL = local->findByUid( uid ); |
2583 | inR = remote->findByUid( uid ); | 2583 | inR = remote->findByUid( uid ); |
2584 | //inL.setResource( 0 ); | 2584 | //inL.setResource( 0 ); |
2585 | //inR.setResource( 0 ); | 2585 | //inR.setResource( 0 ); |
2586 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2586 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2587 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 2587 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
2588 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { | 2588 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { |
2589 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2589 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2590 | if ( take == 3 ) | 2590 | if ( take == 3 ) |
2591 | return false; | 2591 | return false; |
2592 | if ( take == 1 ) {// take local | 2592 | if ( take == 1 ) {// take local |
2593 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2593 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2594 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2594 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2595 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2595 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2596 | local->insertAddressee( inL, false ); | 2596 | local->insertAddressee( inL, false ); |
2597 | idS = inR.externalUID(); | 2597 | idS = inR.externalUID(); |
2598 | OidS = inR.originalExternalUID(); | 2598 | OidS = inR.originalExternalUID(); |
2599 | } | 2599 | } |
2600 | else | 2600 | else |
2601 | idS = inR.IDStr(); | 2601 | idS = inR.IDStr(); |
2602 | remote->removeAddressee( inR ); | 2602 | remote->removeAddressee( inR ); |
2603 | inR = inL; | 2603 | inR = inL; |
2604 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2604 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2605 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2605 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2606 | inR.setOriginalExternalUID( OidS ); | 2606 | inR.setOriginalExternalUID( OidS ); |
2607 | inR.setExternalUID( idS ); | 2607 | inR.setExternalUID( idS ); |
2608 | } else { | 2608 | } else { |
2609 | inR.setIDStr( idS ); | 2609 | inR.setIDStr( idS ); |
2610 | } | 2610 | } |
2611 | inR.setResource( 0 ); | 2611 | inR.setResource( 0 ); |
2612 | remote->insertAddressee( inR , false); | 2612 | remote->insertAddressee( inR , false); |
2613 | ++changedRemote; | 2613 | ++changedRemote; |
2614 | } else { // take == 2 take remote | 2614 | } else { // take == 2 take remote |
2615 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2615 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2616 | if ( inR.revision().date().year() < 2004 ) | 2616 | if ( inR.revision().date().year() < 2004 ) |
2617 | inR.setRevision( modifiedCalendar ); | 2617 | inR.setRevision( modifiedCalendar ); |
2618 | } | 2618 | } |
2619 | idS = inL.IDStr(); | 2619 | idS = inL.IDStr(); |
2620 | local->removeAddressee( inL ); | 2620 | local->removeAddressee( inL ); |
2621 | inL = inR; | 2621 | inL = inR; |
2622 | inL.setIDStr( idS ); | 2622 | inL.setIDStr( idS ); |
2623 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2623 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2624 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2624 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2625 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2625 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2626 | } | 2626 | } |
2627 | inL.setResource( 0 ); | 2627 | inL.setResource( 0 ); |
2628 | local->insertAddressee( inL , false ); | 2628 | local->insertAddressee( inL , false ); |
2629 | ++changedLocal; | 2629 | ++changedLocal; |
2630 | } | 2630 | } |
2631 | } | 2631 | } |
2632 | } | 2632 | } |
2633 | } else { // no conflict | 2633 | } else { // no conflict |
2634 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2634 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2635 | QString des = addresseeLSync.note(); | 2635 | QString des = addresseeLSync.note(); |
2636 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 2636 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2637 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 2637 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2638 | remote->insertAddressee( inR, false ); | 2638 | remote->insertAddressee( inR, false ); |
2639 | ++deletedAddresseeR; | 2639 | ++deletedAddresseeR; |
2640 | } else { | 2640 | } else { |
2641 | inR.setRevision( modifiedCalendar ); | 2641 | inR.setRevision( modifiedCalendar ); |
2642 | remote->insertAddressee( inR, false ); | 2642 | remote->insertAddressee( inR, false ); |
2643 | inL = inR; | 2643 | inL = inR; |
2644 | inL.setResource( 0 ); | 2644 | inL.setResource( 0 ); |
2645 | local->insertAddressee( inL , false); | 2645 | local->insertAddressee( inL , false); |
2646 | ++addedAddressee; | 2646 | ++addedAddressee; |
2647 | } | 2647 | } |
2648 | } else { | 2648 | } else { |
2649 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { | 2649 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
2650 | inR.setRevision( modifiedCalendar ); | 2650 | inR.setRevision( modifiedCalendar ); |
2651 | remote->insertAddressee( inR, false ); | 2651 | remote->insertAddressee( inR, false ); |
2652 | inR.setResource( 0 ); | 2652 | inR.setResource( 0 ); |
2653 | local->insertAddressee( inR, false ); | 2653 | local->insertAddressee( inR, false ); |
2654 | ++addedAddressee; | 2654 | ++addedAddressee; |
2655 | } else { | 2655 | } else { |
2656 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 2656 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
2657 | remote->removeAddressee( inR ); | 2657 | remote->removeAddressee( inR ); |
2658 | ++deletedAddresseeR; | 2658 | ++deletedAddresseeR; |
2659 | } | 2659 | } |
2660 | } | 2660 | } |
2661 | } | 2661 | } |
2662 | } | 2662 | } |
2663 | ++incCounter; | 2663 | ++incCounter; |
2664 | } | 2664 | } |
2665 | er.clear(); | 2665 | er.clear(); |
2666 | QStringList el = local->uidList(); | 2666 | QStringList el = local->uidList(); |
2667 | modulo = (el.count()/10)+1; | 2667 | modulo = (el.count()/10)+1; |
2668 | 2668 | ||
2669 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 2669 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
2670 | incCounter = 0; | 2670 | incCounter = 0; |
2671 | while ( incCounter < el.count()) { | 2671 | while ( incCounter < el.count()) { |
2672 | qApp->processEvents(); | 2672 | qApp->processEvents(); |
2673 | if (syncManager->isProgressBarCanceled()) | 2673 | if (syncManager->isProgressBarCanceled()) |
2674 | return false; | 2674 | return false; |
2675 | if ( incCounter % modulo == 0 ) | 2675 | if ( incCounter % modulo == 0 ) |
2676 | syncManager->showProgressBar(incCounter); | 2676 | syncManager->showProgressBar(incCounter); |
2677 | uid = el[ incCounter ]; | 2677 | uid = el[ incCounter ]; |
2678 | bool skipIncidence = false; | 2678 | bool skipIncidence = false; |
2679 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2679 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2680 | skipIncidence = true; | 2680 | skipIncidence = true; |
2681 | if ( !skipIncidence ) { | 2681 | if ( !skipIncidence ) { |
2682 | inL = local->findByUid( uid ); | 2682 | inL = local->findByUid( uid ); |
2683 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 2683 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
2684 | inR = remote->findByUid( uid ); | 2684 | inR = remote->findByUid( uid ); |
2685 | if ( inR.isEmpty() ) { | 2685 | if ( inR.isEmpty() ) { |
2686 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2686 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2687 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 2687 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
2688 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2688 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2689 | local->removeAddressee( inL ); | 2689 | local->removeAddressee( inL ); |
2690 | ++deletedAddresseeL; | 2690 | ++deletedAddresseeL; |
2691 | } else { | 2691 | } else { |
2692 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2692 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2693 | inL.removeID(mCurrentSyncDevice ); | 2693 | inL.removeID(mCurrentSyncDevice ); |
2694 | ++addedAddresseeR; | 2694 | ++addedAddresseeR; |
2695 | inL.setRevision( modifiedCalendar ); | 2695 | inL.setRevision( modifiedCalendar ); |
2696 | local->insertAddressee( inL, false ); | 2696 | local->insertAddressee( inL, false ); |
2697 | inR = inL; | 2697 | inR = inL; |
2698 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); | 2698 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); |
2699 | inR.setResource( 0 ); | 2699 | inR.setResource( 0 ); |
2700 | remote->insertAddressee( inR, false ); | 2700 | remote->insertAddressee( inR, false ); |
2701 | } | 2701 | } |
2702 | } | 2702 | } |
2703 | } else { | 2703 | } else { |
2704 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 2704 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
2705 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2705 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2706 | local->removeAddressee( inL ); | 2706 | local->removeAddressee( inL ); |
2707 | ++deletedAddresseeL; | 2707 | ++deletedAddresseeL; |
2708 | } else { | 2708 | } else { |
2709 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2709 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2710 | ++addedAddresseeR; | 2710 | ++addedAddresseeR; |
2711 | inL.setRevision( modifiedCalendar ); | 2711 | inL.setRevision( modifiedCalendar ); |
2712 | local->insertAddressee( inL, false ); | 2712 | local->insertAddressee( inL, false ); |
2713 | inR = inL; | 2713 | inR = inL; |
2714 | inR.setResource( 0 ); | 2714 | inR.setResource( 0 ); |
2715 | remote->insertAddressee( inR, false ); | 2715 | remote->insertAddressee( inR, false ); |
2716 | } | 2716 | } |
2717 | } | 2717 | } |
2718 | } | 2718 | } |
2719 | } | 2719 | } |
2720 | } | 2720 | } |
2721 | } | 2721 | } |
2722 | ++incCounter; | 2722 | ++incCounter; |
2723 | } | 2723 | } |
2724 | el.clear(); | 2724 | el.clear(); |
2725 | syncManager->hideProgressBar(); | 2725 | syncManager->hideProgressBar(); |
2726 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 2726 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
2727 | // get rid of micro seconds | 2727 | // get rid of micro seconds |
2728 | QTime t = mLastAddressbookSync.time(); | 2728 | QTime t = mLastAddressbookSync.time(); |
2729 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 2729 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
2730 | addresseeLSync.setRevision( mLastAddressbookSync ); | 2730 | addresseeLSync.setRevision( mLastAddressbookSync ); |
2731 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2731 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2732 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 2732 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
2733 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 2733 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
2734 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 2734 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
2735 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 2735 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
2736 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 2736 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
2737 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 2737 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
2738 | addresseeRSync.setNote( "" ) ; | 2738 | addresseeRSync.setNote( "" ) ; |
2739 | addresseeLSync.setNote( "" ); | 2739 | addresseeLSync.setNote( "" ); |
2740 | 2740 | ||
2741 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 2741 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
2742 | remote->insertAddressee( addresseeRSync, false ); | 2742 | remote->insertAddressee( addresseeRSync, false ); |
2743 | local->insertAddressee( addresseeLSync, false ); | 2743 | local->insertAddressee( addresseeLSync, false ); |
2744 | QString mes; | 2744 | QString mes; |
2745 | 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 ); | 2745 | 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 ); |
2746 | if ( syncManager->mShowSyncSummary ) { | 2746 | if ( syncManager->mShowSyncSummary ) { |
2747 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); | 2747 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); |
2748 | } | 2748 | } |
2749 | qDebug( mes ); | 2749 | qDebug( mes ); |
2750 | return syncOK; | 2750 | return syncOK; |
2751 | } | 2751 | } |
2752 | 2752 | ||
2753 | 2753 | ||
2754 | //this is a overwritten callbackmethods from the syncinterface | 2754 | //this is a overwritten callbackmethods from the syncinterface |
2755 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | 2755 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) |
2756 | { | 2756 | { |
2757 | 2757 | ||
2758 | //pending prepare addresseeview for output | 2758 | //pending prepare addresseeview for output |
2759 | //pending detect, if remote file has REV field. if not switch to external sync | 2759 | //pending detect, if remote file has REV field. if not switch to external sync |
2760 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 2760 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
2761 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2761 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2762 | 2762 | ||
2763 | AddressBook abLocal(filename,"syncContact"); | 2763 | AddressBook abLocal(filename,"syncContact"); |
2764 | bool syncOK = false; | 2764 | bool syncOK = false; |
2765 | if ( abLocal.load() ) { | 2765 | if ( abLocal.load() ) { |
2766 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); | 2766 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); |
2767 | bool external = false; | 2767 | bool external = false; |
2768 | bool isXML = false; | 2768 | bool isXML = false; |
2769 | if ( filename.right(4) == ".xml") { | 2769 | if ( filename.right(4) == ".xml") { |
2770 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2770 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2771 | isXML = true; | 2771 | isXML = true; |
2772 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 2772 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
2773 | } else { | 2773 | } else { |
2774 | external = !manager->mIsKapiFile; | 2774 | external = !manager->mIsKapiFile; |
2775 | if ( external ) { | 2775 | if ( external ) { |
2776 | qDebug("Setting vcf mode to external "); | 2776 | qDebug("Setting vcf mode to external "); |
2777 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2777 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2778 | AddressBook::Iterator it; | 2778 | AddressBook::Iterator it; |
2779 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2779 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2780 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 2780 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
2781 | (*it).computeCsum( mCurrentSyncDevice ); | 2781 | (*it).computeCsum( mCurrentSyncDevice ); |
2782 | } | 2782 | } |
2783 | } | 2783 | } |
2784 | } | 2784 | } |
2785 | //AddressBook::Iterator it; | 2785 | //AddressBook::Iterator it; |
2786 | //QStringList vcards; | 2786 | //QStringList vcards; |
2787 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2787 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2788 | // qDebug("Name %s ", (*it).familyName().latin1()); | 2788 | // qDebug("Name %s ", (*it).familyName().latin1()); |
2789 | //} | 2789 | //} |
2790 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2790 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
2791 | if ( syncOK ) { | 2791 | if ( syncOK ) { |
2792 | if ( syncManager->mWriteBackFile ) | 2792 | if ( syncManager->mWriteBackFile ) |
2793 | { | 2793 | { |
2794 | if ( external ) | 2794 | if ( external ) |
2795 | abLocal.removeSyncAddressees( !isXML); | 2795 | abLocal.removeSyncAddressees( !isXML); |
2796 | qDebug("Saving remote AB "); | 2796 | qDebug("Saving remote AB "); |
2797 | if ( ! abLocal.saveAB()) | 2797 | if ( ! abLocal.saveAB()) |
2798 | qDebug("Error writing back AB to file "); | 2798 | qDebug("Error writing back AB to file "); |
2799 | if ( isXML ) { | 2799 | if ( isXML ) { |
2800 | // afterwrite processing | 2800 | // afterwrite processing |
2801 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2801 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2802 | } | 2802 | } |
2803 | } | 2803 | } |
2804 | } | 2804 | } |
2805 | setModified(); | 2805 | setModified(); |
2806 | 2806 | ||
2807 | } | 2807 | } |
2808 | if ( syncOK ) | 2808 | if ( syncOK ) |
2809 | mViewManager->refreshView(); | 2809 | mViewManager->refreshView(); |
2810 | return syncOK; | 2810 | return syncOK; |
2811 | 2811 | ||
2812 | } | 2812 | } |
2813 | void KABCore::removeSyncInfo( QString syncProfile) | 2813 | void KABCore::removeSyncInfo( QString syncProfile) |
2814 | { | 2814 | { |
2815 | qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); | 2815 | qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); |
2816 | mAddressBook->removeSyncInfo( syncProfile ); | 2816 | mAddressBook->removeSyncInfo( syncProfile ); |
2817 | } | 2817 | } |
2818 | 2818 | ||
2819 | 2819 | ||
2820 | //this is a overwritten callbackmethods from the syncinterface | 2820 | //this is a overwritten callbackmethods from the syncinterface |
2821 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 2821 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
2822 | { | 2822 | { |
2823 | if ( resource == "phone" ) | 2823 | if ( resource == "phone" ) |
2824 | return syncPhone(); | 2824 | return syncPhone(); |
2825 | disableBR( true ); | 2825 | disableBR( true ); |
2826 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2826 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2827 | 2827 | ||
2828 | AddressBook abLocal( resource,"syncContact"); | 2828 | AddressBook abLocal( resource,"syncContact"); |
2829 | bool syncOK = false; | 2829 | bool syncOK = false; |
2830 | if ( abLocal.load() ) { | 2830 | if ( abLocal.load() ) { |
2831 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2831 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2832 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2832 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2833 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); | 2833 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); |
2834 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2834 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2835 | if ( syncOK ) { | 2835 | if ( syncOK ) { |
2836 | if ( syncManager->mWriteBackFile ) { | 2836 | if ( syncManager->mWriteBackFile ) { |
2837 | abLocal.removeSyncAddressees( false ); | 2837 | abLocal.removeSyncAddressees( false ); |
2838 | abLocal.saveAB(); | 2838 | abLocal.saveAB(); |
2839 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2839 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2840 | } | 2840 | } |
2841 | } | 2841 | } |
2842 | setModified(); | 2842 | setModified(); |
2843 | } | 2843 | } |
2844 | if ( syncOK ) | 2844 | if ( syncOK ) |
2845 | mViewManager->refreshView(); | 2845 | mViewManager->refreshView(); |
2846 | disableBR( false ); | 2846 | disableBR( false ); |
2847 | return syncOK; | 2847 | return syncOK; |
2848 | 2848 | ||
2849 | } | 2849 | } |
2850 | void KABCore::message( QString m ) | 2850 | void KABCore::message( QString m ) |
2851 | { | 2851 | { |
2852 | topLevelWidget()->setCaption( m ); | 2852 | topLevelWidget()->setCaption( m ); |
2853 | mMessageTimer->start( 15000, true ); | 2853 | mMessageTimer->start( 15000, true ); |
2854 | } | 2854 | } |
2855 | bool KABCore::syncPhone() | 2855 | bool KABCore::syncPhone() |
2856 | { | 2856 | { |
2857 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2857 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2858 | QString fileName = getPhoneFile(); | 2858 | QString fileName = getPhoneFile(); |
2859 | if ( !PhoneAccess::readFromPhone( fileName) ) { | 2859 | if ( !PhoneAccess::readFromPhone( fileName) ) { |
2860 | message(i18n("Phone access failed!")); | 2860 | message(i18n("Phone access failed!")); |
2861 | return false; | 2861 | return false; |
2862 | } | 2862 | } |
2863 | AddressBook abLocal( fileName,"syncContact"); | 2863 | AddressBook abLocal( fileName,"syncContact"); |
2864 | bool syncOK = false; | 2864 | bool syncOK = false; |
2865 | { | 2865 | { |
2866 | abLocal.importFromFile( fileName ); | 2866 | abLocal.importFromFile( fileName ); |
2867 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2867 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2868 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2868 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2869 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); | 2869 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); |
2870 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 2870 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
2871 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2871 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2872 | if ( syncOK ) { | 2872 | if ( syncOK ) { |
2873 | if ( syncManager->mWriteBackFile ) { | 2873 | if ( syncManager->mWriteBackFile ) { |
2874 | abLocal.removeSyncAddressees( true ); | 2874 | abLocal.removeSyncAddressees( true ); |
2875 | abLocal.saveABphone( fileName ); | 2875 | abLocal.saveABphone( fileName ); |
2876 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); | 2876 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); |
2877 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); | 2877 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); |
2878 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2878 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2879 | } | 2879 | } |
2880 | } | 2880 | } |
2881 | setModified(); | 2881 | setModified(); |
2882 | } | 2882 | } |
2883 | if ( syncOK ) | 2883 | if ( syncOK ) |
2884 | mViewManager->refreshView(); | 2884 | mViewManager->refreshView(); |
2885 | return syncOK; | 2885 | return syncOK; |
2886 | } | 2886 | } |
2887 | void KABCore::getFile( bool success ) | 2887 | void KABCore::getFile( bool success ) |
2888 | { | 2888 | { |
2889 | if ( ! success ) { | 2889 | if ( ! success ) { |
2890 | message( i18n("Error receiving file. Nothing changed!") ); | 2890 | message( i18n("Error receiving file. Nothing changed!") ); |
2891 | return; | 2891 | return; |
2892 | } | 2892 | } |
2893 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); | 2893 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); |
2894 | if ( count ) | 2894 | if ( count ) |
2895 | setModified( true ); | 2895 | setModified( true ); |
2896 | message( i18n("Pi-Sync successful!") ); | 2896 | message( i18n("Pi-Sync successful!") ); |
2897 | mViewManager->refreshView(); | 2897 | mViewManager->refreshView(); |
2898 | } | 2898 | } |
2899 | void KABCore::syncFileRequest() | 2899 | void KABCore::syncFileRequest() |
2900 | { | 2900 | { |
2901 | mAddressBook->export2File( sentSyncFile() ); | 2901 | mAddressBook->export2File( sentSyncFile() ); |
2902 | } | 2902 | } |
2903 | QString KABCore::sentSyncFile() | 2903 | QString KABCore::sentSyncFile() |
2904 | { | 2904 | { |
2905 | #ifdef DESKTOP_VERSION | 2905 | #ifdef DESKTOP_VERSION |
2906 | return locateLocal( "tmp", "copysyncab.vcf" ); | 2906 | return locateLocal( "tmp", "copysyncab.vcf" ); |
2907 | #else | 2907 | #else |
2908 | return QString( "/tmp/copysyncab.vcf" ); | 2908 | return QString( "/tmp/copysyncab.vcf" ); |
2909 | #endif | 2909 | #endif |
2910 | } | 2910 | } |
2911 | 2911 | ||
2912 | void KABCore::setCaptionBack() | 2912 | void KABCore::setCaptionBack() |
2913 | { | 2913 | { |
2914 | mMessageTimer->stop(); | 2914 | mMessageTimer->stop(); |
2915 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); | 2915 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); |
2916 | } | 2916 | } |