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