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