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