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