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