author | zautrix <zautrix> | 2006-02-24 18:49:56 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2006-02-24 18:49:56 (UTC) |
commit | d7738fdfc685192eb2f8317db6ffad3c246001c8 (patch) (unidiff) | |
tree | d9aae6ca97851fd1b53c4d9e74740a5ee2b69ea9 /kaddressbook | |
parent | 987757f168bbae56100f2aff763b865e81ceec18 (diff) | |
download | kdepimpi-d7738fdfc685192eb2f8317db6ffad3c246001c8.zip kdepimpi-d7738fdfc685192eb2f8317db6ffad3c246001c8.tar.gz kdepimpi-d7738fdfc685192eb2f8317db6ffad3c246001c8.tar.bz2 |
kapi sync
-rw-r--r-- | kaddressbook/kabcore.cpp | 130 | ||||
-rw-r--r-- | kaddressbook/kabcore.h | 5 | ||||
-rw-r--r-- | kaddressbook/kaimportoldialog.cpp | 712 | ||||
-rw-r--r-- | kaddressbook/kaimportoldialog.h | 63 | ||||
-rw-r--r-- | kaddressbook/phoneeditwidget.cpp | 11 |
5 files changed, 120 insertions, 801 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 7d8586a..ab2824c 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1,3500 +1,3586 @@ | |||
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 | Async a special exception, permission is given to link this program | 19 | Async 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 | #include <kprefsdialog.h> | 99 | #include <kprefsdialog.h> |
100 | 100 | ||
101 | 101 | ||
102 | //#include <qlabel.h> | 102 | //#include <qlabel.h> |
103 | 103 | ||
104 | 104 | ||
105 | #ifndef DESKTOP_VERSION | 105 | #ifndef DESKTOP_VERSION |
106 | #include <qpe/ir.h> | 106 | #include <qpe/ir.h> |
107 | #include <qpe/qpemenubar.h> | 107 | #include <qpe/qpemenubar.h> |
108 | #include <qtopia/qcopenvelope_qws.h> | 108 | #include <qtopia/qcopenvelope_qws.h> |
109 | #else | 109 | #else |
110 | 110 | ||
111 | #include <qmenubar.h> | 111 | #include <qmenubar.h> |
112 | #endif | 112 | #endif |
113 | 113 | ||
114 | #endif // KAB_EMBEDDED | 114 | #endif // KAB_EMBEDDED |
115 | #include "kcmconfigs/kcmkabconfig.h" | 115 | #include "kcmconfigs/kcmkabconfig.h" |
116 | #include "kcmconfigs/kcmkdepimconfig.h" | 116 | #include "kcmconfigs/kcmkdepimconfig.h" |
117 | #include "kpimglobalprefs.h" | 117 | #include "kpimglobalprefs.h" |
118 | #include "externalapphandler.h" | 118 | #include "externalapphandler.h" |
119 | #include "xxportselectdialog.h" | 119 | #include "xxportselectdialog.h" |
120 | 120 | ||
121 | 121 | ||
122 | #include <kresources/selectdialog.h> | 122 | #include <kresources/selectdialog.h> |
123 | #include <kmessagebox.h> | 123 | #include <kmessagebox.h> |
124 | 124 | ||
125 | #include <picture.h> | 125 | #include <picture.h> |
126 | #include <resource.h> | 126 | #include <resource.h> |
127 | 127 | ||
128 | //US#include <qsplitter.h> | 128 | //US#include <qsplitter.h> |
129 | #include <qmap.h> | 129 | #include <qmap.h> |
130 | #include <qdir.h> | 130 | #include <qdir.h> |
131 | #include <qfile.h> | 131 | #include <qfile.h> |
132 | #include <qvbox.h> | 132 | #include <qvbox.h> |
133 | #include <qlayout.h> | 133 | #include <qlayout.h> |
134 | #include <qclipboard.h> | 134 | #include <qclipboard.h> |
135 | #include <qtextstream.h> | 135 | #include <qtextstream.h> |
136 | #include <qradiobutton.h> | 136 | #include <qradiobutton.h> |
137 | #include <qbuttongroup.h> | 137 | #include <qbuttongroup.h> |
138 | 138 | ||
139 | #include <libkdepim/categoryselectdialog.h> | 139 | #include <libkdepim/categoryselectdialog.h> |
140 | #include <libkdepim/categoryeditdialog.h> | 140 | #include <libkdepim/categoryeditdialog.h> |
141 | #include <kabc/vcardconverter.h> | 141 | #include <kabc/vcardconverter.h> |
142 | 142 | ||
143 | 143 | ||
144 | #include "addresseeutil.h" | 144 | #include "addresseeutil.h" |
145 | #include "undocmds.h" | 145 | #include "undocmds.h" |
146 | #include "addresseeeditordialog.h" | 146 | #include "addresseeeditordialog.h" |
147 | #include "viewmanager.h" | 147 | #include "viewmanager.h" |
148 | #include "details/detailsviewcontainer.h" | 148 | #include "details/detailsviewcontainer.h" |
149 | #include "kabprefs.h" | 149 | #include "kabprefs.h" |
150 | #include "xxportmanager.h" | 150 | #include "xxportmanager.h" |
151 | #include "incsearchwidget.h" | 151 | #include "incsearchwidget.h" |
152 | #include "jumpbuttonbar.h" | 152 | #include "jumpbuttonbar.h" |
153 | #include "extensionmanager.h" | 153 | #include "extensionmanager.h" |
154 | #include "addresseeconfig.h" | 154 | #include "addresseeconfig.h" |
155 | #include "nameeditdialog.h" | 155 | #include "nameeditdialog.h" |
156 | #include <kcmultidialog.h> | 156 | #include <kcmultidialog.h> |
157 | 157 | ||
158 | #ifdef _WIN32_ | 158 | #ifdef _WIN32_ |
159 | #ifdef _OL_IMPORT_ | 159 | #ifdef _OL_IMPORT_ |
160 | #include "kaimportoldialog.h" | 160 | #include "kaimportoldialog.h" |
161 | #include <libkdepim/ol_access.h> | ||
161 | #endif | 162 | #endif |
162 | #else | 163 | #else |
163 | #include <unistd.h> | 164 | #include <unistd.h> |
164 | #endif | 165 | #endif |
165 | // sync includes | 166 | // sync includes |
166 | #include <libkdepim/ksyncprofile.h> | 167 | #include <libkdepim/ksyncprofile.h> |
167 | #include <libkdepim/ksyncprefsdialog.h> | 168 | #include <libkdepim/ksyncprefsdialog.h> |
168 | 169 | ||
169 | 170 | ||
170 | class KABCatPrefs : public QDialog | 171 | class KABCatPrefs : public QDialog |
171 | { | 172 | { |
172 | public: | 173 | public: |
173 | KABCatPrefs( QWidget *parent=0, const char *name=0 ) : | 174 | KABCatPrefs( QWidget *parent=0, const char *name=0 ) : |
174 | QDialog( parent, name, true ) | 175 | QDialog( parent, name, true ) |
175 | { | 176 | { |
176 | setCaption( i18n("Manage new Categories") ); | 177 | setCaption( i18n("Manage new Categories") ); |
177 | QVBoxLayout* lay = new QVBoxLayout( this ); | 178 | QVBoxLayout* lay = new QVBoxLayout( this ); |
178 | lay->setSpacing( 3 ); | 179 | lay->setSpacing( 3 ); |
179 | lay->setMargin( 3 ); | 180 | lay->setMargin( 3 ); |
180 | 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 ); | 181 | 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 ); |
181 | lay->addWidget( lab ); | 182 | lay->addWidget( lab ); |
182 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 183 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
183 | lay->addWidget( format ); | 184 | lay->addWidget( format ); |
184 | format->setExclusive ( true ) ; | 185 | format->setExclusive ( true ) ; |
185 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 186 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
186 | new QRadioButton(i18n("Remove from addressees"), format ); | 187 | new QRadioButton(i18n("Remove from addressees"), format ); |
187 | addCatBut->setChecked( true ); | 188 | addCatBut->setChecked( true ); |
188 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 189 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
189 | lay->addWidget( ok ); | 190 | lay->addWidget( ok ); |
190 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 191 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
191 | lay->addWidget( cancel ); | 192 | lay->addWidget( cancel ); |
192 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 193 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
193 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 194 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
194 | resize( 200, 200 ); | 195 | resize( 200, 200 ); |
195 | } | 196 | } |
196 | 197 | ||
197 | bool addCat() { return addCatBut->isChecked(); } | 198 | bool addCat() { return addCatBut->isChecked(); } |
198 | private: | 199 | private: |
199 | QRadioButton* addCatBut; | 200 | QRadioButton* addCatBut; |
200 | }; | 201 | }; |
201 | 202 | ||
202 | class KABFormatPrefs : public QDialog | 203 | class KABFormatPrefs : public QDialog |
203 | { | 204 | { |
204 | public: | 205 | public: |
205 | KABFormatPrefs( QWidget *parent=0, const char *name=0 ) : | 206 | KABFormatPrefs( QWidget *parent=0, const char *name=0 ) : |
206 | QDialog( parent, name, true ) | 207 | QDialog( parent, name, true ) |
207 | { | 208 | { |
208 | setCaption( i18n("Set formatted name") ); | 209 | setCaption( i18n("Set formatted name") ); |
209 | QVBoxLayout* lay = new QVBoxLayout( this ); | 210 | QVBoxLayout* lay = new QVBoxLayout( this ); |
210 | lay->setSpacing( 3 ); | 211 | lay->setSpacing( 3 ); |
211 | lay->setMargin( 3 ); | 212 | lay->setMargin( 3 ); |
212 | QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this ); | 213 | QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this ); |
213 | lay->addWidget( lab ); | 214 | lay->addWidget( lab ); |
214 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this ); | 215 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this ); |
215 | lay->addWidget( format ); | 216 | lay->addWidget( format ); |
216 | format->setExclusive ( true ) ; | 217 | format->setExclusive ( true ) ; |
217 | simple = new QRadioButton(i18n("Simple: James Bond"), format ); | 218 | simple = new QRadioButton(i18n("Simple: James Bond"), format ); |
218 | full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format ); | 219 | full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format ); |
219 | reverse = new QRadioButton(i18n("Reverse: Bond, James"), format ); | 220 | reverse = new QRadioButton(i18n("Reverse: Bond, James"), format ); |
220 | company = new QRadioButton(i18n("Organization: MI6"), format ); | 221 | company = new QRadioButton(i18n("Organization: MI6"), format ); |
221 | simple->setChecked( true ); | 222 | simple->setChecked( true ); |
222 | setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this); | 223 | setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this); |
223 | lay->addWidget( setCompany ); | 224 | lay->addWidget( setCompany ); |
224 | QPushButton * ok = new QPushButton( i18n("Select contact list"), this ); | 225 | QPushButton * ok = new QPushButton( i18n("Select contact list"), this ); |
225 | lay->addWidget( ok ); | 226 | lay->addWidget( ok ); |
226 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 227 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
227 | lay->addWidget( cancel ); | 228 | lay->addWidget( cancel ); |
228 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 229 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
229 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 230 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
230 | //resize( 200, 200 ); | 231 | //resize( 200, 200 ); |
231 | 232 | ||
232 | } | 233 | } |
233 | public: | 234 | public: |
234 | QRadioButton* simple, *full, *reverse, *company; | 235 | QRadioButton* simple, *full, *reverse, *company; |
235 | QCheckBox* setCompany; | 236 | QCheckBox* setCompany; |
236 | }; | 237 | }; |
237 | 238 | ||
238 | 239 | ||
239 | 240 | ||
240 | class KAex2phonePrefs : public QDialog | 241 | class KAex2phonePrefs : public QDialog |
241 | { | 242 | { |
242 | public: | 243 | public: |
243 | KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : | 244 | KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : |
244 | QDialog( parent, name, true ) | 245 | QDialog( parent, name, true ) |
245 | { | 246 | { |
246 | setCaption( i18n("Export to phone options") ); | 247 | setCaption( i18n("Export to phone options") ); |
247 | QVBoxLayout* lay = new QVBoxLayout( this ); | 248 | QVBoxLayout* lay = new QVBoxLayout( this ); |
248 | lay->setSpacing( 3 ); | 249 | lay->setSpacing( 3 ); |
249 | lay->setMargin( 3 ); | 250 | lay->setMargin( 3 ); |
250 | QLabel *lab; | 251 | QLabel *lab; |
251 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); | 252 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); |
252 | lab->setAlignment (AlignHCenter ); | 253 | lab->setAlignment (AlignHCenter ); |
253 | QHBox* temphb; | 254 | QHBox* temphb; |
254 | temphb = new QHBox( this ); | 255 | temphb = new QHBox( this ); |
255 | new QLabel( i18n("I/O device: "), temphb ); | 256 | new QLabel( i18n("I/O device: "), temphb ); |
256 | mPhoneDevice = new QLineEdit( temphb); | 257 | mPhoneDevice = new QLineEdit( temphb); |
257 | lay->addWidget( temphb ); | 258 | lay->addWidget( temphb ); |
258 | temphb = new QHBox( this ); | 259 | temphb = new QHBox( this ); |
259 | new QLabel( i18n("Connection: "), temphb ); | 260 | new QLabel( i18n("Connection: "), temphb ); |
260 | mPhoneConnection = new QLineEdit( temphb); | 261 | mPhoneConnection = new QLineEdit( temphb); |
261 | lay->addWidget( temphb ); | 262 | lay->addWidget( temphb ); |
262 | temphb = new QHBox( this ); | 263 | temphb = new QHBox( this ); |
263 | new QLabel( i18n("Model(opt.): "), temphb ); | 264 | new QLabel( i18n("Model(opt.): "), temphb ); |
264 | mPhoneModel = new QLineEdit( temphb); | 265 | mPhoneModel = new QLineEdit( temphb); |
265 | lay->addWidget( temphb ); | 266 | lay->addWidget( temphb ); |
266 | // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); | 267 | // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); |
267 | // lay->addWidget( mWriteToSim ); | 268 | // lay->addWidget( mWriteToSim ); |
268 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); | 269 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); |
269 | lab->setAlignment (AlignHCenter); | 270 | lab->setAlignment (AlignHCenter); |
270 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); | 271 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); |
271 | lay->addWidget( ok ); | 272 | lay->addWidget( ok ); |
272 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 273 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
273 | lay->addWidget( cancel ); | 274 | lay->addWidget( cancel ); |
274 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 275 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
275 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 276 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
276 | resize( 220, 240 ); | 277 | resize( 220, 240 ); |
277 | 278 | ||
278 | } | 279 | } |
279 | 280 | ||
280 | public: | 281 | public: |
281 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | 282 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; |
282 | QCheckBox* mWriteToSim; | 283 | QCheckBox* mWriteToSim; |
283 | }; | 284 | }; |
284 | 285 | ||
285 | 286 | ||
286 | bool pasteWithNewUid = true; | 287 | bool pasteWithNewUid = true; |
287 | 288 | ||
288 | #ifdef KAB_EMBEDDED | 289 | #ifdef KAB_EMBEDDED |
289 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 290 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) |
290 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 291 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
291 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ | 292 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ |
292 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) | 293 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) |
293 | #else //KAB_EMBEDDED | 294 | #else //KAB_EMBEDDED |
294 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 295 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) |
295 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 296 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
296 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), | 297 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), |
297 | mReadWrite( readWrite ), mModified( false ) | 298 | mReadWrite( readWrite ), mModified( false ) |
298 | #endif //KAB_EMBEDDED | 299 | #endif //KAB_EMBEDDED |
299 | { | 300 | { |
300 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 301 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
301 | // syncManager->setBlockSave(false); | 302 | // syncManager->setBlockSave(false); |
302 | mIncSearchWidget = 0; | 303 | mIncSearchWidget = 0; |
303 | mMiniSplitter = 0; | 304 | mMiniSplitter = 0; |
304 | mExtensionBarSplitter = 0; | 305 | mExtensionBarSplitter = 0; |
305 | mIsPart = !parent->inherits( "KAddressBookMain" ); | 306 | mIsPart = !parent->inherits( "KAddressBookMain" ); |
306 | mAddressBook = KABC::StdAddressBook::selfNoLoad(); | 307 | mAddressBook = KABC::StdAddressBook::selfNoLoad(); |
307 | KABC::StdAddressBook::setAutomaticSave( false ); | 308 | KABC::StdAddressBook::setAutomaticSave( false ); |
308 | 309 | ||
309 | #ifndef KAB_EMBEDDED | 310 | #ifndef KAB_EMBEDDED |
310 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); | 311 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); |
311 | #endif //KAB_EMBEDDED | 312 | #endif //KAB_EMBEDDED |
312 | 313 | ||
313 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), | 314 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), |
314 | SLOT( addressBookChanged() ) ); | 315 | SLOT( addressBookChanged() ) ); |
315 | 316 | ||
316 | #if 0 | 317 | #if 0 |
317 | // LR moved to addressbook init method | 318 | // LR moved to addressbook init method |
318 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, | 319 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, |
319 | "X-Department", "KADDRESSBOOK" ); | 320 | "X-Department", "KADDRESSBOOK" ); |
320 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 321 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
321 | "X-Profession", "KADDRESSBOOK" ); | 322 | "X-Profession", "KADDRESSBOOK" ); |
322 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 323 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
323 | "X-AssistantsName", "KADDRESSBOOK" ); | 324 | "X-AssistantsName", "KADDRESSBOOK" ); |
324 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 325 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
325 | "X-ManagersName", "KADDRESSBOOK" ); | 326 | "X-ManagersName", "KADDRESSBOOK" ); |
326 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 327 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
327 | "X-SpousesName", "KADDRESSBOOK" ); | 328 | "X-SpousesName", "KADDRESSBOOK" ); |
328 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, | 329 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, |
329 | "X-Office", "KADDRESSBOOK" ); | 330 | "X-Office", "KADDRESSBOOK" ); |
330 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 331 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
331 | "X-IMAddress", "KADDRESSBOOK" ); | 332 | "X-IMAddress", "KADDRESSBOOK" ); |
332 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 333 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
333 | "X-Anniversary", "KADDRESSBOOK" ); | 334 | "X-Anniversary", "KADDRESSBOOK" ); |
334 | 335 | ||
335 | //US added this field to become compatible with Opie/qtopia addressbook | 336 | //US added this field to become compatible with Opie/qtopia addressbook |
336 | // values can be "female" or "male" or "". An empty field represents undefined. | 337 | // values can be "female" or "male" or "". An empty field represents undefined. |
337 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 338 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
338 | "X-Gender", "KADDRESSBOOK" ); | 339 | "X-Gender", "KADDRESSBOOK" ); |
339 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, | 340 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, |
340 | "X-Children", "KADDRESSBOOK" ); | 341 | "X-Children", "KADDRESSBOOK" ); |
341 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 342 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
342 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 343 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
343 | #endif | 344 | #endif |
344 | initGUI(); | 345 | initGUI(); |
345 | 346 | ||
346 | mIncSearchWidget->setFocus(); | 347 | mIncSearchWidget->setFocus(); |
347 | 348 | ||
348 | 349 | ||
349 | connect( mViewManager, SIGNAL( selected( const QString& ) ), | 350 | connect( mViewManager, SIGNAL( selected( const QString& ) ), |
350 | SLOT( setContactSelected( const QString& ) ) ); | 351 | SLOT( setContactSelected( const QString& ) ) ); |
351 | connect( mViewManager, SIGNAL( executed( const QString& ) ), | 352 | connect( mViewManager, SIGNAL( executed( const QString& ) ), |
352 | SLOT( executeContact( const QString& ) ) ); | 353 | SLOT( executeContact( const QString& ) ) ); |
353 | 354 | ||
354 | connect( mViewManager, SIGNAL( deleteRequest( ) ), | 355 | connect( mViewManager, SIGNAL( deleteRequest( ) ), |
355 | SLOT( deleteContacts( ) ) ); | 356 | SLOT( deleteContacts( ) ) ); |
356 | connect( mViewManager, SIGNAL( modified() ), | 357 | connect( mViewManager, SIGNAL( modified() ), |
357 | SLOT( setModified() ) ); | 358 | SLOT( setModified() ) ); |
358 | 359 | ||
359 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); | 360 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); |
360 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); | 361 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); |
361 | 362 | ||
362 | connect( mXXPortManager, SIGNAL( modified() ), | 363 | connect( mXXPortManager, SIGNAL( modified() ), |
363 | SLOT( setModified() ) ); | 364 | SLOT( setModified() ) ); |
364 | 365 | ||
365 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), | 366 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), |
366 | SLOT( incrementalSearchJump( const QString& ) ) ); | 367 | SLOT( incrementalSearchJump( const QString& ) ) ); |
367 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), | 368 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), |
368 | mJumpButtonBar, SLOT( recreateButtons() ) ); | 369 | mJumpButtonBar, SLOT( recreateButtons() ) ); |
369 | 370 | ||
370 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), | 371 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), |
371 | SLOT( sendMail( const QString& ) ) ); | 372 | SLOT( sendMail( const QString& ) ) ); |
372 | 373 | ||
373 | 374 | ||
374 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); | 375 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); |
375 | 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&))); | 376 | 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&))); |
376 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); | 377 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); |
377 | connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); | 378 | connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); |
378 | connect( ExternalAppHandler::instance(), SIGNAL (doRingSync()),this, SLOT( doRingSync())); | 379 | connect( ExternalAppHandler::instance(), SIGNAL (doRingSync()),this, SLOT( doRingSync())); |
379 | connect( ExternalAppHandler::instance(), SIGNAL (callContactdialog()),this, SLOT(callContactdialog())); | 380 | connect( ExternalAppHandler::instance(), SIGNAL (callContactdialog()),this, SLOT(callContactdialog())); |
380 | 381 | ||
381 | 382 | ||
382 | #ifndef KAB_EMBEDDED | 383 | #ifndef KAB_EMBEDDED |
383 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), | 384 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), |
384 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); | 385 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); |
385 | 386 | ||
386 | connect( mDetails, SIGNAL( browse( const QString& ) ), | 387 | connect( mDetails, SIGNAL( browse( const QString& ) ), |
387 | SLOT( browse( const QString& ) ) ); | 388 | SLOT( browse( const QString& ) ) ); |
388 | 389 | ||
389 | 390 | ||
390 | mAddressBookService = new KAddressBookService( this ); | 391 | mAddressBookService = new KAddressBookService( this ); |
391 | 392 | ||
392 | #endif //KAB_EMBEDDED | 393 | #endif //KAB_EMBEDDED |
393 | 394 | ||
394 | mMessageTimer = new QTimer( this ); | 395 | mMessageTimer = new QTimer( this ); |
395 | connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); | 396 | connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); |
396 | mEditorDialog = 0; | 397 | mEditorDialog = 0; |
397 | createAddresseeEditorDialog( this ); | 398 | createAddresseeEditorDialog( this ); |
398 | setModified( false ); | 399 | setModified( false ); |
399 | mBRdisabled = false; | 400 | mBRdisabled = false; |
400 | #ifndef DESKTOP_VERSION | 401 | #ifndef DESKTOP_VERSION |
401 | infrared = 0; | 402 | infrared = 0; |
402 | #endif | 403 | #endif |
403 | //toggleBeamReceive( ); | 404 | //toggleBeamReceive( ); |
404 | mMainWindow->toolBar()->show(); | 405 | mMainWindow->toolBar()->show(); |
405 | // we have a toolbar repainting error on the Zaurus when starting KA/Pi | 406 | // we have a toolbar repainting error on the Zaurus when starting KA/Pi |
406 | //QTimer::singleShot( 10, this , SLOT ( updateToolBar())); | 407 | //QTimer::singleShot( 10, this , SLOT ( updateToolBar())); |
407 | QTimer::singleShot( 100, this, SLOT ( loadDataAfterStart() )); | 408 | QTimer::singleShot( 100, this, SLOT ( loadDataAfterStart() )); |
408 | } | 409 | } |
409 | void KABCore::receiveStart( const QCString& cmsg, const QByteArray& data ) | 410 | void KABCore::receiveStart( const QCString& cmsg, const QByteArray& data ) |
410 | { | 411 | { |
411 | //qDebug("KO: QCOP start message received: %s ", cmsg.data() ); | 412 | //qDebug("KO: QCOP start message received: %s ", cmsg.data() ); |
412 | mCStringMess = cmsg; | 413 | mCStringMess = cmsg; |
413 | mByteData = data; | 414 | mByteData = data; |
414 | } | 415 | } |
415 | 416 | ||
416 | void KABCore::loadDataAfterStart() | 417 | void KABCore::loadDataAfterStart() |
417 | { | 418 | { |
418 | //qDebug("KABCore::loadDataAfterStart() "); | 419 | //qDebug("KABCore::loadDataAfterStart() "); |
419 | ((StdAddressBook*)mAddressBook)->init( true ); | 420 | ((StdAddressBook*)mAddressBook)->init( true ); |
420 | mViewManager->refreshView(); | 421 | mViewManager->refreshView(); |
421 | 422 | ||
422 | #ifndef DESKTOP_VERSION | 423 | #ifndef DESKTOP_VERSION |
423 | disconnect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT (receiveStart ( const QCString &, const QByteArray & ))); | 424 | disconnect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT (receiveStart ( const QCString &, const QByteArray & ))); |
424 | 425 | ||
425 | QObject::connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); | 426 | QObject::connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); |
426 | if ( !mCStringMess.isEmpty() ) | 427 | if ( !mCStringMess.isEmpty() ) |
427 | ExternalAppHandler::instance()->appMessage( mCStringMess, mByteData ); | 428 | ExternalAppHandler::instance()->appMessage( mCStringMess, mByteData ); |
428 | #endif | 429 | #endif |
429 | // QTimer::singleShot( 10, this , SLOT ( updateToolBar())); | 430 | // QTimer::singleShot( 10, this , SLOT ( updateToolBar())); |
430 | setCaptionBack(); | 431 | setCaptionBack(); |
431 | } | 432 | } |
432 | void KABCore::updateToolBar() | 433 | void KABCore::updateToolBar() |
433 | { | 434 | { |
434 | static int iii = 0; | 435 | static int iii = 0; |
435 | ++iii; | 436 | ++iii; |
436 | mMainWindow->toolBar()->repaintMe(); | 437 | mMainWindow->toolBar()->repaintMe(); |
437 | if ( iii < 4 ) | 438 | if ( iii < 4 ) |
438 | QTimer::singleShot( 100*iii, this , SLOT ( updateToolBar())); | 439 | QTimer::singleShot( 100*iii, this , SLOT ( updateToolBar())); |
439 | } | 440 | } |
440 | KABCore::~KABCore() | 441 | KABCore::~KABCore() |
441 | { | 442 | { |
442 | // save(); | 443 | // save(); |
443 | //saveSettings(); | 444 | //saveSettings(); |
444 | //KABPrefs::instance()->writeConfig(); | 445 | //KABPrefs::instance()->writeConfig(); |
445 | delete AddresseeConfig::instance(); | 446 | delete AddresseeConfig::instance(); |
446 | mAddressBook = 0; | 447 | mAddressBook = 0; |
447 | KABC::StdAddressBook::close(); | 448 | KABC::StdAddressBook::close(); |
448 | 449 | ||
449 | delete syncManager; | 450 | delete syncManager; |
450 | #ifndef DESKTOP_VERSION | 451 | #ifndef DESKTOP_VERSION |
451 | if ( infrared ) | 452 | if ( infrared ) |
452 | delete infrared; | 453 | delete infrared; |
453 | #endif | 454 | #endif |
454 | } | 455 | } |
455 | void KABCore::receive( const QCString& cmsg, const QByteArray& data ) | 456 | void KABCore::receive( const QCString& cmsg, const QByteArray& data ) |
456 | { | 457 | { |
457 | //qDebug("KA: QCOP message received: %s ", cmsg.data() ); | 458 | //qDebug("KA: QCOP message received: %s ", cmsg.data() ); |
458 | if ( cmsg == "setDocument(QString)" ) { | 459 | if ( cmsg == "setDocument(QString)" ) { |
459 | QDataStream stream( data, IO_ReadOnly ); | 460 | QDataStream stream( data, IO_ReadOnly ); |
460 | QString fileName; | 461 | QString fileName; |
461 | stream >> fileName; | 462 | stream >> fileName; |
462 | recieve( fileName ); | 463 | recieve( fileName ); |
463 | return; | 464 | return; |
464 | } | 465 | } |
465 | } | 466 | } |
466 | void KABCore::toggleBeamReceive( ) | 467 | void KABCore::toggleBeamReceive( ) |
467 | { | 468 | { |
468 | if ( mBRdisabled ) | 469 | if ( mBRdisabled ) |
469 | return; | 470 | return; |
470 | #ifndef DESKTOP_VERSION | 471 | #ifndef DESKTOP_VERSION |
471 | if ( infrared ) { | 472 | if ( infrared ) { |
472 | qDebug("KA: AB disable BeamReceive "); | 473 | qDebug("KA: AB disable BeamReceive "); |
473 | delete infrared; | 474 | delete infrared; |
474 | infrared = 0; | 475 | infrared = 0; |
475 | mActionBR->setChecked(false); | 476 | mActionBR->setChecked(false); |
476 | return; | 477 | return; |
477 | } | 478 | } |
478 | qDebug("KA: AB enable BeamReceive "); | 479 | qDebug("KA: AB enable BeamReceive "); |
479 | mActionBR->setChecked(true); | 480 | mActionBR->setChecked(true); |
480 | 481 | ||
481 | infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; | 482 | infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; |
482 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); | 483 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); |
483 | #endif | 484 | #endif |
484 | } | 485 | } |
485 | 486 | ||
486 | 487 | ||
487 | void KABCore::disableBR(bool b) | 488 | void KABCore::disableBR(bool b) |
488 | { | 489 | { |
489 | #ifndef DESKTOP_VERSION | 490 | #ifndef DESKTOP_VERSION |
490 | if ( b ) { | 491 | if ( b ) { |
491 | if ( infrared ) { | 492 | if ( infrared ) { |
492 | toggleBeamReceive( ); | 493 | toggleBeamReceive( ); |
493 | } | 494 | } |
494 | mBRdisabled = true; | 495 | mBRdisabled = true; |
495 | } else { | 496 | } else { |
496 | if ( mBRdisabled ) { | 497 | if ( mBRdisabled ) { |
497 | mBRdisabled = false; | 498 | mBRdisabled = false; |
498 | //toggleBeamReceive( ); | 499 | //toggleBeamReceive( ); |
499 | } | 500 | } |
500 | } | 501 | } |
501 | #endif | 502 | #endif |
502 | 503 | ||
503 | } | 504 | } |
504 | void KABCore::recieve( QString fn ) | 505 | void KABCore::recieve( QString fn ) |
505 | { | 506 | { |
506 | //qDebug("KABCore::recieve "); | 507 | //qDebug("KABCore::recieve "); |
507 | int count = mAddressBook->importFromFile( fn, true ); | 508 | int count = mAddressBook->importFromFile( fn, true ); |
508 | if ( count ) | 509 | if ( count ) |
509 | setModified( true ); | 510 | setModified( true ); |
510 | mViewManager->refreshView(); | 511 | mViewManager->refreshView(); |
511 | message(i18n("%1 contact(s) received!").arg( count )); | 512 | message(i18n("%1 contact(s) received!").arg( count )); |
512 | topLevelWidget()->showMaximized(); | 513 | topLevelWidget()->showMaximized(); |
513 | topLevelWidget()->raise(); | 514 | topLevelWidget()->raise(); |
514 | } | 515 | } |
515 | void KABCore::restoreSettings() | 516 | void KABCore::restoreSettings() |
516 | { | 517 | { |
517 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; | 518 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; |
518 | 519 | ||
519 | bool state; | 520 | bool state; |
520 | 521 | ||
521 | if (mMultipleViewsAtOnce) | 522 | if (mMultipleViewsAtOnce) |
522 | state = KABPrefs::instance()->mDetailsPageVisible; | 523 | state = KABPrefs::instance()->mDetailsPageVisible; |
523 | else | 524 | else |
524 | state = false; | 525 | state = false; |
525 | 526 | ||
526 | mActionDetails->setChecked( state ); | 527 | mActionDetails->setChecked( state ); |
527 | setDetailsVisible( state ); | 528 | setDetailsVisible( state ); |
528 | 529 | ||
529 | state = KABPrefs::instance()->mJumpButtonBarVisible; | 530 | state = KABPrefs::instance()->mJumpButtonBarVisible; |
530 | 531 | ||
531 | mActionJumpBar->setChecked( state ); | 532 | mActionJumpBar->setChecked( state ); |
532 | setJumpButtonBarVisible( state ); | 533 | setJumpButtonBarVisible( state ); |
533 | /*US | 534 | /*US |
534 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 535 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
535 | if ( splitterSize.count() == 0 ) { | 536 | if ( splitterSize.count() == 0 ) { |
536 | splitterSize.append( width() / 2 ); | 537 | splitterSize.append( width() / 2 ); |
537 | splitterSize.append( width() / 2 ); | 538 | splitterSize.append( width() / 2 ); |
538 | } | 539 | } |
539 | mMiniSplitter->setSizes( splitterSize ); | 540 | mMiniSplitter->setSizes( splitterSize ); |
540 | if ( mExtensionBarSplitter ) { | 541 | if ( mExtensionBarSplitter ) { |
541 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 542 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
542 | if ( splitterSize.count() == 0 ) { | 543 | if ( splitterSize.count() == 0 ) { |
543 | splitterSize.append( width() / 2 ); | 544 | splitterSize.append( width() / 2 ); |
544 | splitterSize.append( width() / 2 ); | 545 | splitterSize.append( width() / 2 ); |
545 | } | 546 | } |
546 | mExtensionBarSplitter->setSizes( splitterSize ); | 547 | mExtensionBarSplitter->setSizes( splitterSize ); |
547 | 548 | ||
548 | } | 549 | } |
549 | */ | 550 | */ |
550 | mViewManager->restoreSettings(); | 551 | mViewManager->restoreSettings(); |
551 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 552 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
552 | mExtensionManager->restoreSettings(); | 553 | mExtensionManager->restoreSettings(); |
553 | #ifdef DESKTOP_VERSION | 554 | #ifdef DESKTOP_VERSION |
554 | int wid = width(); | 555 | int wid = width(); |
555 | if ( wid < 10 ) | 556 | if ( wid < 10 ) |
556 | wid = 400; | 557 | wid = 400; |
557 | #else | 558 | #else |
558 | int wid = QApplication::desktop()->width(); | 559 | int wid = QApplication::desktop()->width(); |
559 | if ( wid < 640 ) | 560 | if ( wid < 640 ) |
560 | wid = QApplication::desktop()->height(); | 561 | wid = QApplication::desktop()->height(); |
561 | #endif | 562 | #endif |
562 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; | 563 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; |
563 | if ( true /*splitterSize.count() == 0*/ ) { | 564 | if ( true /*splitterSize.count() == 0*/ ) { |
564 | splitterSize.append( wid / 2 ); | 565 | splitterSize.append( wid / 2 ); |
565 | splitterSize.append( wid / 2 ); | 566 | splitterSize.append( wid / 2 ); |
566 | } | 567 | } |
567 | mMiniSplitter->setSizes( splitterSize ); | 568 | mMiniSplitter->setSizes( splitterSize ); |
568 | if ( mExtensionBarSplitter ) { | 569 | if ( mExtensionBarSplitter ) { |
569 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 570 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
570 | if ( true /*splitterSize.count() == 0*/ ) { | 571 | if ( true /*splitterSize.count() == 0*/ ) { |
571 | splitterSize.append( wid / 2 ); | 572 | splitterSize.append( wid / 2 ); |
572 | splitterSize.append( wid / 2 ); | 573 | splitterSize.append( wid / 2 ); |
573 | } | 574 | } |
574 | mExtensionBarSplitter->setSizes( splitterSize ); | 575 | mExtensionBarSplitter->setSizes( splitterSize ); |
575 | 576 | ||
576 | } | 577 | } |
577 | #ifdef DESKTOP_VERSION | 578 | #ifdef DESKTOP_VERSION |
578 | KConfig *config = KABPrefs::instance()->getConfig(); | 579 | KConfig *config = KABPrefs::instance()->getConfig(); |
579 | config->setGroup("WidgetLayout"); | 580 | config->setGroup("WidgetLayout"); |
580 | QStringList list; | 581 | QStringList list; |
581 | list = config->readListEntry("MainLayout"); | 582 | list = config->readListEntry("MainLayout"); |
582 | int x,y,w,h; | 583 | int x,y,w,h; |
583 | if ( ! list.isEmpty() ) { | 584 | if ( ! list.isEmpty() ) { |
584 | x = list[0].toInt(); | 585 | x = list[0].toInt(); |
585 | y = list[1].toInt(); | 586 | y = list[1].toInt(); |
586 | w = list[2].toInt(); | 587 | w = list[2].toInt(); |
587 | h = list[3].toInt(); | 588 | h = list[3].toInt(); |
588 | KApplication::testCoords( &x,&y,&w,&h ); | 589 | KApplication::testCoords( &x,&y,&w,&h ); |
589 | topLevelWidget()->setGeometry(x,y,w,h); | 590 | topLevelWidget()->setGeometry(x,y,w,h); |
590 | 591 | ||
591 | } else { | 592 | } else { |
592 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 593 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
593 | } | 594 | } |
594 | #endif | 595 | #endif |
595 | } | 596 | } |
596 | 597 | ||
597 | void KABCore::saveSettings() | 598 | void KABCore::saveSettings() |
598 | { | 599 | { |
599 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | 600 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); |
600 | if ( mExtensionBarSplitter ) | 601 | if ( mExtensionBarSplitter ) |
601 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 602 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
602 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | 603 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); |
603 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); | 604 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); |
604 | #ifndef KAB_EMBEDDED | 605 | #ifndef KAB_EMBEDDED |
605 | 606 | ||
606 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 607 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
607 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | 608 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); |
608 | #endif //KAB_EMBEDDED | 609 | #endif //KAB_EMBEDDED |
609 | mExtensionManager->saveSettings(); | 610 | mExtensionManager->saveSettings(); |
610 | mViewManager->saveSettings(); | 611 | mViewManager->saveSettings(); |
611 | 612 | ||
612 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 613 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
613 | 614 | ||
614 | KABPrefs::instance()->writeConfig(); | 615 | KABPrefs::instance()->writeConfig(); |
615 | //qDebug("KA: KABCore::saveSettings() "); | 616 | //qDebug("KA: KABCore::saveSettings() "); |
616 | } | 617 | } |
617 | 618 | ||
618 | KABC::AddressBook *KABCore::addressBook() const | 619 | KABC::AddressBook *KABCore::addressBook() const |
619 | { | 620 | { |
620 | return mAddressBook; | 621 | return mAddressBook; |
621 | } | 622 | } |
622 | 623 | ||
623 | KConfig *KABCore::config() | 624 | KConfig *KABCore::config() |
624 | { | 625 | { |
625 | #ifndef KAB_EMBEDDED | 626 | #ifndef KAB_EMBEDDED |
626 | return KABPrefs::instance()->config(); | 627 | return KABPrefs::instance()->config(); |
627 | #else //KAB_EMBEDDED | 628 | #else //KAB_EMBEDDED |
628 | return KABPrefs::instance()->getConfig(); | 629 | return KABPrefs::instance()->getConfig(); |
629 | #endif //KAB_EMBEDDED | 630 | #endif //KAB_EMBEDDED |
630 | } | 631 | } |
631 | 632 | ||
632 | KActionCollection *KABCore::actionCollection() const | 633 | KActionCollection *KABCore::actionCollection() const |
633 | { | 634 | { |
634 | return mGUIClient->actionCollection(); | 635 | return mGUIClient->actionCollection(); |
635 | } | 636 | } |
636 | 637 | ||
637 | KABC::Field *KABCore::currentSearchField() const | 638 | KABC::Field *KABCore::currentSearchField() const |
638 | { | 639 | { |
639 | if (mIncSearchWidget) | 640 | if (mIncSearchWidget) |
640 | return mIncSearchWidget->currentField(); | 641 | return mIncSearchWidget->currentField(); |
641 | else | 642 | else |
642 | return 0; | 643 | return 0; |
643 | } | 644 | } |
644 | 645 | ||
645 | QStringList KABCore::selectedUIDs() const | 646 | QStringList KABCore::selectedUIDs() const |
646 | { | 647 | { |
647 | return mViewManager->selectedUids(); | 648 | return mViewManager->selectedUids(); |
648 | } | 649 | } |
649 | 650 | ||
650 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 651 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
651 | { | 652 | { |
652 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 653 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
653 | 654 | ||
654 | QPtrList<KRES::Resource> kresResources; | 655 | QPtrList<KRES::Resource> kresResources; |
655 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 656 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
656 | KABC::Resource *resource; | 657 | KABC::Resource *resource; |
657 | while ( ( resource = resIt.current() ) != 0 ) { | 658 | while ( ( resource = resIt.current() ) != 0 ) { |
658 | ++resIt; | 659 | ++resIt; |
659 | if ( !resource->readOnly() ) { | 660 | if ( !resource->readOnly() ) { |
660 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 661 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
661 | if ( res ) | 662 | if ( res ) |
662 | kresResources.append( res ); | 663 | kresResources.append( res ); |
663 | } | 664 | } |
664 | } | 665 | } |
665 | 666 | ||
666 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 667 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
667 | return static_cast<KABC::Resource*>( res ); | 668 | return static_cast<KABC::Resource*>( res ); |
668 | } | 669 | } |
669 | 670 | ||
670 | #ifndef KAB_EMBEDDED | 671 | #ifndef KAB_EMBEDDED |
671 | KAboutData *KABCore::createAboutData() | 672 | KAboutData *KABCore::createAboutData() |
672 | #else //KAB_EMBEDDED | 673 | #else //KAB_EMBEDDED |
673 | void KABCore::createAboutData() | 674 | void KABCore::createAboutData() |
674 | #endif //KAB_EMBEDDED | 675 | #endif //KAB_EMBEDDED |
675 | { | 676 | { |
676 | 677 | ||
677 | 678 | ||
678 | QString version; | 679 | QString version; |
679 | #include <../version> | 680 | #include <../version> |
680 | QMessageBox::about( this, "About KAddressbook/Pi", | 681 | QMessageBox::about( this, "About KAddressbook/Pi", |
681 | "KAddressbook/Platform-independent\n" | 682 | "KAddressbook/Platform-independent\n" |
682 | "(KA/Pi) " +version + " - " + | 683 | "(KA/Pi) " +version + " - " + |
683 | #ifdef DESKTOP_VERSION | 684 | #ifdef DESKTOP_VERSION |
684 | "Desktop Edition\n" | 685 | "Desktop Edition\n" |
685 | #else | 686 | #else |
686 | "PDA-Edition\n" | 687 | "PDA-Edition\n" |
687 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 688 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
688 | #endif | 689 | #endif |
689 | 690 | ||
690 | "(c) 2004 Ulf Schenk\n" | 691 | "(c) 2004 Ulf Schenk\n" |
691 | "(c) 2004-2005 Lutz Rogowski\nrogowski@kde.org\n" | 692 | "(c) 2004-2005 Lutz Rogowski\nrogowski@kde.org\n" |
692 | "(c) 1997-2003, The KDE PIM Team\n" | 693 | "(c) 1997-2003, The KDE PIM Team\n" |
693 | "Tobias Koenig Maintainer\n" | 694 | "Tobias Koenig Maintainer\n" |
694 | "Don Sanders Original author\n" | 695 | "Don Sanders Original author\n" |
695 | "Cornelius Schumacher Co-maintainer\n" | 696 | "Cornelius Schumacher Co-maintainer\n" |
696 | "Mike Pilone GUI and framework redesign\n" | 697 | "Mike Pilone GUI and framework redesign\n" |
697 | "Greg Stern DCOP interface\n" | 698 | "Greg Stern DCOP interface\n" |
698 | "Mark Westcot Contact pinning\n" | 699 | "Mark Westcot Contact pinning\n" |
699 | "Michel Boyer de la Giroday LDAP Lookup\n" | 700 | "Michel Boyer de la Giroday LDAP Lookup\n" |
700 | "Steffen Hansen LDAP Lookup" | 701 | "Steffen Hansen LDAP Lookup" |
701 | #ifdef _WIN32_ | 702 | #ifdef _WIN32_ |
702 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" | 703 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" |
703 | #endif | 704 | #endif |
704 | ); | 705 | ); |
705 | } | 706 | } |
706 | 707 | ||
707 | void KABCore::setContactSelected( const QString &uid ) | 708 | void KABCore::setContactSelected( const QString &uid ) |
708 | { | 709 | { |
709 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 710 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
710 | if ( !mDetails->isHidden() ) | 711 | if ( !mDetails->isHidden() ) |
711 | mDetails->setAddressee( addr ); | 712 | mDetails->setAddressee( addr ); |
712 | 713 | ||
713 | if ( !addr.isEmpty() ) { | 714 | if ( !addr.isEmpty() ) { |
714 | emit contactSelected( addr.formattedName() ); | 715 | emit contactSelected( addr.formattedName() ); |
715 | KABC::Picture pic = addr.photo(); | 716 | KABC::Picture pic = addr.photo(); |
716 | if ( pic.isIntern() ) { | 717 | if ( pic.isIntern() ) { |
717 | //US emit contactSelected( pic.data() ); | 718 | //US emit contactSelected( pic.data() ); |
718 | //US instead use: | 719 | //US instead use: |
719 | QPixmap px; | 720 | QPixmap px; |
720 | if (pic.data().isNull() != true) | 721 | if (pic.data().isNull() != true) |
721 | { | 722 | { |
722 | px.convertFromImage(pic.data()); | 723 | px.convertFromImage(pic.data()); |
723 | } | 724 | } |
724 | 725 | ||
725 | emit contactSelected( px ); | 726 | emit contactSelected( px ); |
726 | } | 727 | } |
727 | } | 728 | } |
728 | 729 | ||
729 | 730 | ||
730 | mExtensionManager->setSelectionChanged(); | 731 | mExtensionManager->setSelectionChanged(); |
731 | 732 | ||
732 | // update the actions | 733 | // update the actions |
733 | bool selected = !uid.isEmpty(); | 734 | bool selected = !uid.isEmpty(); |
734 | 735 | ||
735 | if ( mReadWrite ) { | 736 | if ( mReadWrite ) { |
736 | mActionCut->setEnabled( selected ); | 737 | mActionCut->setEnabled( selected ); |
737 | mActionPaste->setEnabled( selected ); | 738 | mActionPaste->setEnabled( selected ); |
738 | } | 739 | } |
739 | 740 | ||
740 | mActionCopy->setEnabled( selected ); | 741 | mActionCopy->setEnabled( selected ); |
741 | mActionDelete->setEnabled( selected ); | 742 | mActionDelete->setEnabled( selected ); |
742 | mActionEditAddressee->setEnabled( selected ); | 743 | mActionEditAddressee->setEnabled( selected ); |
743 | mActionMail->setEnabled( selected ); | 744 | mActionMail->setEnabled( selected ); |
744 | mActionMailVCard->setEnabled( selected ); | 745 | mActionMailVCard->setEnabled( selected ); |
745 | //if (mActionBeam) | 746 | //if (mActionBeam) |
746 | //mActionBeam->setEnabled( selected ); | 747 | //mActionBeam->setEnabled( selected ); |
747 | mActionWhoAmI->setEnabled( selected ); | 748 | mActionWhoAmI->setEnabled( selected ); |
748 | } | 749 | } |
749 | 750 | ||
750 | void KABCore::sendMail() | 751 | void KABCore::sendMail() |
751 | { | 752 | { |
752 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 753 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
753 | } | 754 | } |
754 | 755 | ||
755 | void KABCore::sendMail( const QString& emaillist ) | 756 | void KABCore::sendMail( const QString& emaillist ) |
756 | { | 757 | { |
757 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " | 758 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " |
758 | if (emaillist.contains(",") > 0) | 759 | if (emaillist.contains(",") > 0) |
759 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); | 760 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); |
760 | else | 761 | else |
761 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); | 762 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); |
762 | } | 763 | } |
763 | 764 | ||
764 | 765 | ||
765 | 766 | ||
766 | void KABCore::mailVCard() | 767 | void KABCore::mailVCard() |
767 | { | 768 | { |
768 | QStringList uids = mViewManager->selectedUids(); | 769 | QStringList uids = mViewManager->selectedUids(); |
769 | if ( !uids.isEmpty() ) | 770 | if ( !uids.isEmpty() ) |
770 | mailVCard( uids ); | 771 | mailVCard( uids ); |
771 | } | 772 | } |
772 | 773 | ||
773 | void KABCore::mailVCard( const QStringList& uids ) | 774 | void KABCore::mailVCard( const QStringList& uids ) |
774 | { | 775 | { |
775 | QStringList urls; | 776 | QStringList urls; |
776 | 777 | ||
777 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 778 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
778 | 779 | ||
779 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); | 780 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); |
780 | 781 | ||
781 | 782 | ||
782 | 783 | ||
783 | QDir().mkdir( dirName, true ); | 784 | QDir().mkdir( dirName, true ); |
784 | 785 | ||
785 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 786 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
786 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 787 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
787 | 788 | ||
788 | if ( a.isEmpty() ) | 789 | if ( a.isEmpty() ) |
789 | continue; | 790 | continue; |
790 | 791 | ||
791 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 792 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
792 | 793 | ||
793 | QString fileName = dirName + "/" + name; | 794 | QString fileName = dirName + "/" + name; |
794 | 795 | ||
795 | QFile outFile(fileName); | 796 | QFile outFile(fileName); |
796 | 797 | ||
797 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 798 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
798 | KABC::VCardConverter converter; | 799 | KABC::VCardConverter converter; |
799 | QString vcard; | 800 | QString vcard; |
800 | 801 | ||
801 | converter.addresseeToVCard( a, vcard ); | 802 | converter.addresseeToVCard( a, vcard ); |
802 | 803 | ||
803 | QTextStream t( &outFile ); // use a text stream | 804 | QTextStream t( &outFile ); // use a text stream |
804 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 805 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
805 | t << vcard; | 806 | t << vcard; |
806 | 807 | ||
807 | outFile.close(); | 808 | outFile.close(); |
808 | 809 | ||
809 | urls.append( fileName ); | 810 | urls.append( fileName ); |
810 | } | 811 | } |
811 | } | 812 | } |
812 | 813 | ||
813 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); | 814 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
814 | 815 | ||
815 | 816 | ||
816 | /*US | 817 | /*US |
817 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 818 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
818 | QString::null, // subject | 819 | QString::null, // subject |
819 | QString::null, // body | 820 | QString::null, // body |
820 | QString::null, | 821 | QString::null, |
821 | urls ); // attachments | 822 | urls ); // attachments |
822 | */ | 823 | */ |
823 | 824 | ||
824 | } | 825 | } |
825 | 826 | ||
826 | /** | 827 | /** |
827 | Beams the "WhoAmI contact. | 828 | Beams the "WhoAmI contact. |
828 | */ | 829 | */ |
829 | void KABCore::beamMySelf() | 830 | void KABCore::beamMySelf() |
830 | { | 831 | { |
831 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 832 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
832 | if (!a.isEmpty()) | 833 | if (!a.isEmpty()) |
833 | { | 834 | { |
834 | QStringList uids; | 835 | QStringList uids; |
835 | uids << a.uid(); | 836 | uids << a.uid(); |
836 | 837 | ||
837 | beamVCard(uids); | 838 | beamVCard(uids); |
838 | } else { | 839 | } else { |
839 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 840 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
840 | 841 | ||
841 | 842 | ||
842 | } | 843 | } |
843 | } | 844 | } |
844 | void KABCore::updateMainWindow() | 845 | void KABCore::updateMainWindow() |
845 | { | 846 | { |
846 | mMainWindow->showMaximized(); | 847 | mMainWindow->showMaximized(); |
847 | //mMainWindow->repaint(); | 848 | //mMainWindow->repaint(); |
848 | } | 849 | } |
849 | void KABCore::resizeEvent(QResizeEvent* e ) | 850 | void KABCore::resizeEvent(QResizeEvent* e ) |
850 | { | 851 | { |
851 | if ( !mMiniSplitter ) { | 852 | if ( !mMiniSplitter ) { |
852 | QWidget::resizeEvent( e ); | 853 | QWidget::resizeEvent( e ); |
853 | return; | 854 | return; |
854 | } | 855 | } |
855 | #ifndef DESKTOP_VERSION | 856 | #ifndef DESKTOP_VERSION |
856 | static int desktop_width = 0; | 857 | static int desktop_width = 0; |
857 | //qDebug("KABCore::resizeEvent %d %d ",desktop_width,QApplication::desktop()->width() ); | 858 | //qDebug("KABCore::resizeEvent %d %d ",desktop_width,QApplication::desktop()->width() ); |
858 | if ( desktop_width != QApplication::desktop()->width() ) | 859 | if ( desktop_width != QApplication::desktop()->width() ) |
859 | if ( QApplication::desktop()->width() >= 480 ) { | 860 | if ( QApplication::desktop()->width() >= 480 ) { |
860 | if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 | 861 | if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 |
861 | //qDebug("640 "); | 862 | //qDebug("640 "); |
862 | if ( mMiniSplitter->orientation() == Qt::Vertical ) { | 863 | if ( mMiniSplitter->orientation() == Qt::Vertical ) { |
863 | //qDebug("switch V->H "); | 864 | //qDebug("switch V->H "); |
864 | mMiniSplitter->setOrientation( Qt::Horizontal); | 865 | mMiniSplitter->setOrientation( Qt::Horizontal); |
865 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 866 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
866 | } | 867 | } |
867 | if ( QApplication::desktop()->width() <= 640 ) { | 868 | if ( QApplication::desktop()->width() <= 640 ) { |
868 | bool shot = mMainWindow->isVisible(); | 869 | bool shot = mMainWindow->isVisible(); |
869 | mMainWindow->showMinimized(); | 870 | mMainWindow->showMinimized(); |
870 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); | 871 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); |
871 | mViewManager->getFilterAction()->setComboWidth( 150 ); | 872 | mViewManager->getFilterAction()->setComboWidth( 150 ); |
872 | if ( mIncSearchWidget ) | 873 | if ( mIncSearchWidget ) |
873 | mIncSearchWidget->setSize(); | 874 | mIncSearchWidget->setSize(); |
874 | if ( shot ) | 875 | if ( shot ) |
875 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); | 876 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); |
876 | } | 877 | } |
877 | 878 | ||
878 | } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 | 879 | } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 |
879 | //qDebug("480 "); | 880 | //qDebug("480 "); |
880 | if ( mMiniSplitter->orientation() == Qt::Horizontal ) { | 881 | if ( mMiniSplitter->orientation() == Qt::Horizontal ) { |
881 | //qDebug("switch H->V "); | 882 | //qDebug("switch H->V "); |
882 | mMiniSplitter->setOrientation( Qt::Vertical ); | 883 | mMiniSplitter->setOrientation( Qt::Vertical ); |
883 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 884 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
884 | } | 885 | } |
885 | if ( QApplication::desktop()->width() <= 640 ) { | 886 | if ( QApplication::desktop()->width() <= 640 ) { |
886 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); | 887 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); |
887 | bool shot = mMainWindow->isVisible(); | 888 | bool shot = mMainWindow->isVisible(); |
888 | mMainWindow->showMinimized(); | 889 | mMainWindow->showMinimized(); |
889 | if ( KABPrefs::instance()->mHideSearchOnSwitch ) { | 890 | if ( KABPrefs::instance()->mHideSearchOnSwitch ) { |
890 | if ( mIncSearchWidget ) { | 891 | if ( mIncSearchWidget ) { |
891 | mIncSearchWidget->setSize(); | 892 | mIncSearchWidget->setSize(); |
892 | } | 893 | } |
893 | } else { | 894 | } else { |
894 | mViewManager->getFilterAction()->setComboWidth( 0 ); | 895 | mViewManager->getFilterAction()->setComboWidth( 0 ); |
895 | } | 896 | } |
896 | if ( shot ) | 897 | if ( shot ) |
897 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); | 898 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); |
898 | } | 899 | } |
899 | } | 900 | } |
900 | } | 901 | } |
901 | desktop_width = QApplication::desktop()->width(); | 902 | desktop_width = QApplication::desktop()->width(); |
902 | #endif | 903 | #endif |
903 | QWidget::resizeEvent( e ); | 904 | QWidget::resizeEvent( e ); |
904 | 905 | ||
905 | } | 906 | } |
906 | void KABCore::export2phone() | 907 | void KABCore::export2phone() |
907 | { | 908 | { |
908 | 909 | ||
909 | QStringList uids; | 910 | QStringList uids; |
910 | XXPortSelectDialog dlg( this, false, this ); | 911 | XXPortSelectDialog dlg( this, false, this ); |
911 | if ( dlg.exec() ) | 912 | if ( dlg.exec() ) |
912 | uids = dlg.uids(); | 913 | uids = dlg.uids(); |
913 | else | 914 | else |
914 | return; | 915 | return; |
915 | if ( uids.isEmpty() ) | 916 | if ( uids.isEmpty() ) |
916 | return; | 917 | return; |
917 | // qDebug("count %d ", uids.count()); | 918 | // qDebug("count %d ", uids.count()); |
918 | 919 | ||
919 | KAex2phonePrefs ex2phone; | 920 | KAex2phonePrefs ex2phone; |
920 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 921 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
921 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 922 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
922 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 923 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
923 | 924 | ||
924 | if ( !ex2phone.exec() ) { | 925 | if ( !ex2phone.exec() ) { |
925 | return; | 926 | return; |
926 | } | 927 | } |
927 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 928 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
928 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 929 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
929 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 930 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
930 | 931 | ||
931 | 932 | ||
932 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 933 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
933 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 934 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
934 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 935 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
935 | 936 | ||
936 | QString fileName = getPhoneFile(); | 937 | QString fileName = getPhoneFile(); |
937 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) | 938 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) |
938 | return; | 939 | return; |
939 | 940 | ||
940 | message(i18n("Exporting to phone...")); | 941 | message(i18n("Exporting to phone...")); |
941 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); | 942 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); |
942 | 943 | ||
943 | } | 944 | } |
944 | QString KABCore::getPhoneFile() | 945 | QString KABCore::getPhoneFile() |
945 | { | 946 | { |
946 | #ifdef DESKTOP_VERSION | 947 | #ifdef DESKTOP_VERSION |
947 | return locateLocal("tmp", "phonefile.vcf"); | 948 | return locateLocal("tmp", "phonefile.vcf"); |
948 | #else | 949 | #else |
949 | return "/tmp/phonefile.vcf"; | 950 | return "/tmp/phonefile.vcf"; |
950 | #endif | 951 | #endif |
951 | 952 | ||
952 | } | 953 | } |
953 | void KABCore::writeToPhone( ) | 954 | void KABCore::writeToPhone( ) |
954 | { | 955 | { |
955 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) | 956 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) |
956 | message(i18n("Export to phone finished!")); | 957 | message(i18n("Export to phone finished!")); |
957 | else | 958 | else |
958 | qDebug(i18n("KA: Error exporting to phone")); | 959 | qDebug(i18n("KA: Error exporting to phone")); |
959 | } | 960 | } |
960 | void KABCore::beamVCard() | 961 | void KABCore::beamVCard() |
961 | { | 962 | { |
962 | QStringList uids; | 963 | QStringList uids; |
963 | XXPortSelectDialog dlg( this, false, this ); | 964 | XXPortSelectDialog dlg( this, false, this ); |
964 | if ( dlg.exec() ) | 965 | if ( dlg.exec() ) |
965 | uids = dlg.uids(); | 966 | uids = dlg.uids(); |
966 | else | 967 | else |
967 | return; | 968 | return; |
968 | if ( uids.isEmpty() ) | 969 | if ( uids.isEmpty() ) |
969 | return; | 970 | return; |
970 | beamVCard( uids ); | 971 | beamVCard( uids ); |
971 | } | 972 | } |
972 | 973 | ||
973 | 974 | ||
974 | void KABCore::beamVCard(const QStringList& uids) | 975 | void KABCore::beamVCard(const QStringList& uids) |
975 | { | 976 | { |
976 | 977 | ||
977 | // LR: we should use the /tmp dir on the Zaurus, | 978 | // LR: we should use the /tmp dir on the Zaurus, |
978 | // because: /tmp = RAM, (HOME)/kdepim = flash memory | 979 | // because: /tmp = RAM, (HOME)/kdepim = flash memory |
979 | 980 | ||
980 | #ifdef DESKTOP_VERSION | 981 | #ifdef DESKTOP_VERSION |
981 | QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); | 982 | QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); |
982 | #else | 983 | #else |
983 | QString fileName = "/tmp/kapibeamfile.vcf"; | 984 | QString fileName = "/tmp/kapibeamfile.vcf"; |
984 | #endif | 985 | #endif |
985 | 986 | ||
986 | KABC::VCardConverter converter; | 987 | KABC::VCardConverter converter; |
987 | QString description; | 988 | QString description; |
988 | QString datastream; | 989 | QString datastream; |
989 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 990 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
990 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 991 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
991 | 992 | ||
992 | if ( a.isEmpty() ) | 993 | if ( a.isEmpty() ) |
993 | continue; | 994 | continue; |
994 | 995 | ||
995 | if (description.isEmpty()) | 996 | if (description.isEmpty()) |
996 | description = a.formattedName(); | 997 | description = a.formattedName(); |
997 | 998 | ||
998 | QString vcard; | 999 | QString vcard; |
999 | converter.addresseeToVCard( a, vcard ); | 1000 | converter.addresseeToVCard( a, vcard ); |
1000 | int start = 0; | 1001 | int start = 0; |
1001 | int next; | 1002 | int next; |
1002 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 1003 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
1003 | int semi = vcard.find(";", next); | 1004 | int semi = vcard.find(";", next); |
1004 | int dopp = vcard.find(":", next); | 1005 | int dopp = vcard.find(":", next); |
1005 | int sep; | 1006 | int sep; |
1006 | if ( semi < dopp && semi >= 0 ) | 1007 | if ( semi < dopp && semi >= 0 ) |
1007 | sep = semi ; | 1008 | sep = semi ; |
1008 | else | 1009 | else |
1009 | sep = dopp; | 1010 | sep = dopp; |
1010 | datastream +=vcard.mid( start, next - start); | 1011 | datastream +=vcard.mid( start, next - start); |
1011 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | 1012 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); |
1012 | start = sep; | 1013 | start = sep; |
1013 | } | 1014 | } |
1014 | datastream += vcard.mid( start,vcard.length() ); | 1015 | datastream += vcard.mid( start,vcard.length() ); |
1015 | } | 1016 | } |
1016 | #ifndef DESKTOP_VERSION | 1017 | #ifndef DESKTOP_VERSION |
1017 | QFile outFile(fileName); | 1018 | QFile outFile(fileName); |
1018 | if ( outFile.open(IO_WriteOnly) ) { | 1019 | if ( outFile.open(IO_WriteOnly) ) { |
1019 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 1020 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
1020 | QTextStream t( &outFile ); // use a text stream | 1021 | QTextStream t( &outFile ); // use a text stream |
1021 | //t.setEncoding( QTextStream::UnicodeUTF8 ); | 1022 | //t.setEncoding( QTextStream::UnicodeUTF8 ); |
1022 | t.setEncoding( QTextStream::Latin1 ); | 1023 | t.setEncoding( QTextStream::Latin1 ); |
1023 | t <<datastream.latin1(); | 1024 | t <<datastream.latin1(); |
1024 | outFile.close(); | 1025 | outFile.close(); |
1025 | Ir *ir = new Ir( this ); | 1026 | Ir *ir = new Ir( this ); |
1026 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 1027 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
1027 | ir->send( fileName, description, "text/x-vCard" ); | 1028 | ir->send( fileName, description, "text/x-vCard" ); |
1028 | } else { | 1029 | } else { |
1029 | qDebug("KA: Error open temp beam file "); | 1030 | qDebug("KA: Error open temp beam file "); |
1030 | return; | 1031 | return; |
1031 | } | 1032 | } |
1032 | #endif | 1033 | #endif |
1033 | 1034 | ||
1034 | } | 1035 | } |
1035 | 1036 | ||
1036 | void KABCore::beamDone( Ir *ir ) | 1037 | void KABCore::beamDone( Ir *ir ) |
1037 | { | 1038 | { |
1038 | #ifndef DESKTOP_VERSION | 1039 | #ifndef DESKTOP_VERSION |
1039 | delete ir; | 1040 | delete ir; |
1040 | #endif | 1041 | #endif |
1041 | topLevelWidget()->raise(); | 1042 | topLevelWidget()->raise(); |
1042 | message( i18n("Beaming finished!") ); | 1043 | message( i18n("Beaming finished!") ); |
1043 | } | 1044 | } |
1044 | 1045 | ||
1045 | 1046 | ||
1046 | void KABCore::browse( const QString& url ) | 1047 | void KABCore::browse( const QString& url ) |
1047 | { | 1048 | { |
1048 | #ifndef KAB_EMBEDDED | 1049 | #ifndef KAB_EMBEDDED |
1049 | kapp->invokeBrowser( url ); | 1050 | kapp->invokeBrowser( url ); |
1050 | #else //KAB_EMBEDDED | 1051 | #else //KAB_EMBEDDED |
1051 | qDebug("KABCore::browse must be fixed"); | 1052 | qDebug("KABCore::browse must be fixed"); |
1052 | #endif //KAB_EMBEDDED | 1053 | #endif //KAB_EMBEDDED |
1053 | } | 1054 | } |
1054 | 1055 | ||
1055 | void KABCore::selectAllContacts() | 1056 | void KABCore::selectAllContacts() |
1056 | { | 1057 | { |
1057 | mViewManager->setSelected( QString::null, true ); | 1058 | mViewManager->setSelected( QString::null, true ); |
1058 | } | 1059 | } |
1059 | 1060 | ||
1060 | void KABCore::deleteContacts() | 1061 | void KABCore::deleteContacts() |
1061 | { | 1062 | { |
1062 | QStringList uidList = mViewManager->selectedUids(); | 1063 | QStringList uidList = mViewManager->selectedUids(); |
1063 | deleteContacts( uidList ); | 1064 | deleteContacts( uidList ); |
1064 | } | 1065 | } |
1065 | 1066 | ||
1066 | void KABCore::deleteContacts( const QStringList &uids ) | 1067 | void KABCore::deleteContacts( const QStringList &uids ) |
1067 | { | 1068 | { |
1068 | 1069 | ||
1069 | if ( uids.count() > 0 ) { | 1070 | if ( uids.count() > 0 ) { |
1070 | 1071 | ||
1071 | if ( KABPrefs::instance()->mAskForDelete ) { | 1072 | if ( KABPrefs::instance()->mAskForDelete ) { |
1072 | int count = uids.count(); | 1073 | int count = uids.count(); |
1073 | if ( count > 5 ) count = 5; | 1074 | if ( count > 5 ) count = 5; |
1074 | QString cNames; | 1075 | QString cNames; |
1075 | int i; | 1076 | int i; |
1076 | for ( i = 0; i < count ; ++i ) { | 1077 | for ( i = 0; i < count ; ++i ) { |
1077 | cNames += KGlobal::formatMessage( mAddressBook->findByUid( uids[i] ).realName() ,0) + "\n"; | 1078 | cNames += KGlobal::formatMessage( mAddressBook->findByUid( uids[i] ).realName() ,0) + "\n"; |
1078 | } | 1079 | } |
1079 | if ( uids.count() > 5 ) | 1080 | if ( uids.count() > 5 ) |
1080 | cNames += i18n("...and %1 more\ncontact(s) selected").arg( uids.count() - 5 ); | 1081 | cNames += i18n("...and %1 more\ncontact(s) selected").arg( uids.count() - 5 ); |
1081 | QString text = i18n( "Do you really\nwant to delete the\nsetected contact(s)?\n\n" ) + cNames ; | 1082 | QString text = i18n( "Do you really\nwant to delete the\nsetected contact(s)?\n\n" ) + cNames ; |
1082 | if ( KMessageBox::questionYesNo( this, text ) != KMessageBox::Yes ) | 1083 | if ( KMessageBox::questionYesNo( this, text ) != KMessageBox::Yes ) |
1083 | return; | 1084 | return; |
1084 | } | 1085 | } |
1085 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 1086 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
1086 | UndoStack::instance()->push( command ); | 1087 | UndoStack::instance()->push( command ); |
1087 | RedoStack::instance()->clear(); | 1088 | RedoStack::instance()->clear(); |
1088 | 1089 | ||
1089 | // now if we deleted anything, refresh | 1090 | // now if we deleted anything, refresh |
1090 | setContactSelected( QString::null ); | 1091 | setContactSelected( QString::null ); |
1091 | setModified( true ); | 1092 | setModified( true ); |
1092 | } | 1093 | } |
1093 | } | 1094 | } |
1094 | 1095 | ||
1095 | void KABCore::copyContacts() | 1096 | void KABCore::copyContacts() |
1096 | { | 1097 | { |
1097 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1098 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1098 | 1099 | ||
1099 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 1100 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
1100 | 1101 | ||
1101 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 1102 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
1102 | 1103 | ||
1103 | QClipboard *cb = QApplication::clipboard(); | 1104 | QClipboard *cb = QApplication::clipboard(); |
1104 | cb->setText( clipText ); | 1105 | cb->setText( clipText ); |
1105 | } | 1106 | } |
1106 | 1107 | ||
1107 | void KABCore::cutContacts() | 1108 | void KABCore::cutContacts() |
1108 | { | 1109 | { |
1109 | QStringList uidList = mViewManager->selectedUids(); | 1110 | QStringList uidList = mViewManager->selectedUids(); |
1110 | 1111 | ||
1111 | //US if ( uidList.size() > 0 ) { | 1112 | //US if ( uidList.size() > 0 ) { |
1112 | if ( uidList.count() > 0 ) { | 1113 | if ( uidList.count() > 0 ) { |
1113 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 1114 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
1114 | UndoStack::instance()->push( command ); | 1115 | UndoStack::instance()->push( command ); |
1115 | RedoStack::instance()->clear(); | 1116 | RedoStack::instance()->clear(); |
1116 | 1117 | ||
1117 | setModified( true ); | 1118 | setModified( true ); |
1118 | } | 1119 | } |
1119 | } | 1120 | } |
1120 | 1121 | ||
1121 | void KABCore::pasteContacts() | 1122 | void KABCore::pasteContacts() |
1122 | { | 1123 | { |
1123 | QClipboard *cb = QApplication::clipboard(); | 1124 | QClipboard *cb = QApplication::clipboard(); |
1124 | 1125 | ||
1125 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 1126 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
1126 | 1127 | ||
1127 | pasteContacts( list ); | 1128 | pasteContacts( list ); |
1128 | } | 1129 | } |
1129 | 1130 | ||
1130 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 1131 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
1131 | { | 1132 | { |
1132 | KABC::Resource *resource = requestResource( this ); | 1133 | KABC::Resource *resource = requestResource( this ); |
1133 | KABC::Addressee::List::Iterator it; | 1134 | KABC::Addressee::List::Iterator it; |
1134 | for ( it = list.begin(); it != list.end(); ++it ) | 1135 | for ( it = list.begin(); it != list.end(); ++it ) |
1135 | (*it).setResource( resource ); | 1136 | (*it).setResource( resource ); |
1136 | 1137 | ||
1137 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 1138 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
1138 | UndoStack::instance()->push( command ); | 1139 | UndoStack::instance()->push( command ); |
1139 | RedoStack::instance()->clear(); | 1140 | RedoStack::instance()->clear(); |
1140 | 1141 | ||
1141 | setModified( true ); | 1142 | setModified( true ); |
1142 | } | 1143 | } |
1143 | 1144 | ||
1144 | void KABCore::setWhoAmI() | 1145 | void KABCore::setWhoAmI() |
1145 | { | 1146 | { |
1146 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1147 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1147 | 1148 | ||
1148 | if ( addrList.count() > 1 ) { | 1149 | if ( addrList.count() > 1 ) { |
1149 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 1150 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
1150 | return; | 1151 | return; |
1151 | } | 1152 | } |
1152 | 1153 | ||
1153 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 1154 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
1154 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].realName() ) ) == KMessageBox::Yes ) | 1155 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].realName() ) ) == KMessageBox::Yes ) |
1155 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 1156 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
1156 | } | 1157 | } |
1157 | void KABCore::editCategories() | 1158 | void KABCore::editCategories() |
1158 | { | 1159 | { |
1159 | KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); | 1160 | KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); |
1160 | dlg.exec(); | 1161 | dlg.exec(); |
1161 | } | 1162 | } |
1162 | void KABCore::setCategories() | 1163 | void KABCore::setCategories() |
1163 | { | 1164 | { |
1164 | 1165 | ||
1165 | QStringList uids; | 1166 | QStringList uids; |
1166 | XXPortSelectDialog dlgx( this, false, this ); | 1167 | XXPortSelectDialog dlgx( this, false, this ); |
1167 | if ( dlgx.exec() ) | 1168 | if ( dlgx.exec() ) |
1168 | uids = dlgx.uids(); | 1169 | uids = dlgx.uids(); |
1169 | else | 1170 | else |
1170 | return; | 1171 | return; |
1171 | if ( uids.isEmpty() ) | 1172 | if ( uids.isEmpty() ) |
1172 | return; | 1173 | return; |
1173 | // qDebug("count %d ", uids.count()); | 1174 | // qDebug("count %d ", uids.count()); |
1174 | 1175 | ||
1175 | 1176 | ||
1176 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 1177 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
1177 | if ( !dlg.exec() ) { | 1178 | if ( !dlg.exec() ) { |
1178 | message( i18n("Setting categories cancelled") ); | 1179 | message( i18n("Setting categories cancelled") ); |
1179 | return; | 1180 | return; |
1180 | } | 1181 | } |
1181 | bool merge = false; | 1182 | bool merge = false; |
1182 | QString msg = i18n( "Merge with existing categories?" ); | 1183 | QString msg = i18n( "Merge with existing categories?" ); |
1183 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 1184 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
1184 | merge = true; | 1185 | merge = true; |
1185 | 1186 | ||
1186 | message( i18n("Setting categories ... please wait!") ); | 1187 | message( i18n("Setting categories ... please wait!") ); |
1187 | QStringList categories = dlg.selectedCategories(); | 1188 | QStringList categories = dlg.selectedCategories(); |
1188 | 1189 | ||
1189 | //QStringList uids = mViewManager->selectedUids(); | 1190 | //QStringList uids = mViewManager->selectedUids(); |
1190 | QStringList::Iterator it; | 1191 | QStringList::Iterator it; |
1191 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 1192 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
1192 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 1193 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
1193 | if ( !addr.isEmpty() ) { | 1194 | if ( !addr.isEmpty() ) { |
1194 | if ( !merge ) | 1195 | if ( !merge ) |
1195 | addr.setCategories( categories ); | 1196 | addr.setCategories( categories ); |
1196 | else { | 1197 | else { |
1197 | QStringList addrCategories = addr.categories(); | 1198 | QStringList addrCategories = addr.categories(); |
1198 | QStringList::Iterator catIt; | 1199 | QStringList::Iterator catIt; |
1199 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 1200 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
1200 | if ( !addrCategories.contains( *catIt ) ) | 1201 | if ( !addrCategories.contains( *catIt ) ) |
1201 | addrCategories.append( *catIt ); | 1202 | addrCategories.append( *catIt ); |
1202 | } | 1203 | } |
1203 | addr.setCategories( addrCategories ); | 1204 | addr.setCategories( addrCategories ); |
1204 | } | 1205 | } |
1205 | mAddressBook->insertAddressee( addr ); | 1206 | mAddressBook->insertAddressee( addr ); |
1206 | } | 1207 | } |
1207 | } | 1208 | } |
1208 | 1209 | ||
1209 | if ( uids.count() > 0 ) | 1210 | if ( uids.count() > 0 ) |
1210 | setModified( true ); | 1211 | setModified( true ); |
1211 | message( i18n("Setting categories completed!") ); | 1212 | message( i18n("Setting categories completed!") ); |
1212 | } | 1213 | } |
1213 | 1214 | ||
1214 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 1215 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
1215 | { | 1216 | { |
1216 | mIncSearchWidget->setFields( fields ); | 1217 | mIncSearchWidget->setFields( fields ); |
1217 | } | 1218 | } |
1218 | 1219 | ||
1219 | void KABCore::incrementalSearch( const QString& text ) | 1220 | void KABCore::incrementalSearch( const QString& text ) |
1220 | { | 1221 | { |
1221 | QString stext; | 1222 | QString stext; |
1222 | if ( KABPrefs::instance()->mAutoSearchWithWildcard ) { | 1223 | if ( KABPrefs::instance()->mAutoSearchWithWildcard ) { |
1223 | stext = "*" + text; | 1224 | stext = "*" + text; |
1224 | } else { | 1225 | } else { |
1225 | stext = text; | 1226 | stext = text; |
1226 | } | 1227 | } |
1227 | mViewManager->doSearch( stext, mIncSearchWidget->currentField() ); | 1228 | mViewManager->doSearch( stext, mIncSearchWidget->currentField() ); |
1228 | } | 1229 | } |
1229 | void KABCore::incrementalSearchJump( const QString& text ) | 1230 | void KABCore::incrementalSearchJump( const QString& text ) |
1230 | { | 1231 | { |
1231 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); | 1232 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); |
1232 | } | 1233 | } |
1233 | 1234 | ||
1234 | void KABCore::setModified() | 1235 | void KABCore::setModified() |
1235 | { | 1236 | { |
1236 | setModified( true ); | 1237 | setModified( true ); |
1237 | } | 1238 | } |
1238 | 1239 | ||
1239 | void KABCore::setModifiedWOrefresh() | 1240 | void KABCore::setModifiedWOrefresh() |
1240 | { | 1241 | { |
1241 | // qDebug("KABCore::setModifiedWOrefresh() "); | 1242 | // qDebug("KABCore::setModifiedWOrefresh() "); |
1242 | mModified = true; | 1243 | mModified = true; |
1243 | mActionSave->setEnabled( mModified ); | 1244 | mActionSave->setEnabled( mModified ); |
1244 | 1245 | ||
1245 | 1246 | ||
1246 | } | 1247 | } |
1247 | void KABCore::setModified( bool modified ) | 1248 | void KABCore::setModified( bool modified ) |
1248 | { | 1249 | { |
1249 | mModified = modified; | 1250 | mModified = modified; |
1250 | mActionSave->setEnabled( mModified ); | 1251 | mActionSave->setEnabled( mModified ); |
1251 | 1252 | ||
1252 | if ( modified ) | 1253 | if ( modified ) |
1253 | mJumpButtonBar->recreateButtons(); | 1254 | mJumpButtonBar->recreateButtons(); |
1254 | 1255 | ||
1255 | mViewManager->refreshView(); | 1256 | mViewManager->refreshView(); |
1256 | 1257 | ||
1257 | } | 1258 | } |
1258 | 1259 | ||
1259 | bool KABCore::modified() const | 1260 | bool KABCore::modified() const |
1260 | { | 1261 | { |
1261 | return mModified; | 1262 | return mModified; |
1262 | } | 1263 | } |
1263 | 1264 | ||
1264 | void KABCore::contactModified( const KABC::Addressee &addr ) | 1265 | void KABCore::contactModified( const KABC::Addressee &addr ) |
1265 | { | 1266 | { |
1266 | addrModified( addr ); | 1267 | addrModified( addr ); |
1267 | #if 0 // debug only | 1268 | #if 0 // debug only |
1268 | KABC::Addressee ad = addr; | 1269 | KABC::Addressee ad = addr; |
1269 | ad.computeCsum( "123"); | 1270 | ad.computeCsum( "123"); |
1270 | #endif | 1271 | #endif |
1271 | } | 1272 | } |
1272 | 1273 | ||
1273 | void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) | 1274 | void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) |
1274 | { | 1275 | { |
1275 | 1276 | ||
1276 | Command *command = 0; | 1277 | Command *command = 0; |
1277 | QString uid; | 1278 | QString uid; |
1278 | 1279 | ||
1279 | // check if it exists already | 1280 | // check if it exists already |
1280 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 1281 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
1281 | if ( origAddr.isEmpty() ) | 1282 | if ( origAddr.isEmpty() ) |
1282 | command = new PwNewCommand( mAddressBook, addr ); | 1283 | command = new PwNewCommand( mAddressBook, addr ); |
1283 | else { | 1284 | else { |
1284 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 1285 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
1285 | uid = addr.uid(); | 1286 | uid = addr.uid(); |
1286 | } | 1287 | } |
1287 | 1288 | ||
1288 | UndoStack::instance()->push( command ); | 1289 | UndoStack::instance()->push( command ); |
1289 | RedoStack::instance()->clear(); | 1290 | RedoStack::instance()->clear(); |
1290 | if ( updateDetails ) | 1291 | if ( updateDetails ) |
1291 | mDetails->setAddressee( addr ); | 1292 | mDetails->setAddressee( addr ); |
1292 | setModified( true ); | 1293 | setModified( true ); |
1293 | } | 1294 | } |
1294 | 1295 | ||
1295 | void KABCore::newContact() | 1296 | void KABCore::newContact() |
1296 | { | 1297 | { |
1297 | 1298 | ||
1298 | 1299 | ||
1299 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 1300 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
1300 | 1301 | ||
1301 | QPtrList<KRES::Resource> kresResources; | 1302 | QPtrList<KRES::Resource> kresResources; |
1302 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 1303 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
1303 | KABC::Resource *resource; | 1304 | KABC::Resource *resource; |
1304 | while ( ( resource = it.current() ) != 0 ) { | 1305 | while ( ( resource = it.current() ) != 0 ) { |
1305 | ++it; | 1306 | ++it; |
1306 | if ( !resource->readOnly() ) { | 1307 | if ( !resource->readOnly() ) { |
1307 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 1308 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
1308 | if ( res ) | 1309 | if ( res ) |
1309 | kresResources.append( res ); | 1310 | kresResources.append( res ); |
1310 | } | 1311 | } |
1311 | } | 1312 | } |
1312 | 1313 | ||
1313 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 1314 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
1314 | resource = static_cast<KABC::Resource*>( res ); | 1315 | resource = static_cast<KABC::Resource*>( res ); |
1315 | 1316 | ||
1316 | if ( resource ) { | 1317 | if ( resource ) { |
1317 | KABC::Addressee addr; | 1318 | KABC::Addressee addr; |
1318 | addr.setResource( resource ); | 1319 | addr.setResource( resource ); |
1319 | mEditorDialog->setAddressee( addr ); | 1320 | mEditorDialog->setAddressee( addr ); |
1320 | mEditorDialog->setCaption( i18n("Edit new contact")); | 1321 | mEditorDialog->setCaption( i18n("Edit new contact")); |
1321 | KApplication::execDialog ( mEditorDialog ); | 1322 | KApplication::execDialog ( mEditorDialog ); |
1322 | 1323 | ||
1323 | } else | 1324 | } else |
1324 | return; | 1325 | return; |
1325 | 1326 | ||
1326 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 1327 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
1327 | 1328 | ||
1328 | 1329 | ||
1329 | } | 1330 | } |
1330 | 1331 | ||
1331 | void KABCore::addEmail( QString aStr ) | 1332 | void KABCore::addEmail( QString aStr ) |
1332 | { | 1333 | { |
1333 | #ifndef KAB_EMBEDDED | 1334 | #ifndef KAB_EMBEDDED |
1334 | QString fullName, email; | 1335 | QString fullName, email; |
1335 | 1336 | ||
1336 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 1337 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
1337 | 1338 | ||
1338 | // Try to lookup the addressee matching the email address | 1339 | // Try to lookup the addressee matching the email address |
1339 | bool found = false; | 1340 | bool found = false; |
1340 | QStringList emailList; | 1341 | QStringList emailList; |
1341 | KABC::AddressBook::Iterator it; | 1342 | KABC::AddressBook::Iterator it; |
1342 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 1343 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
1343 | emailList = (*it).emails(); | 1344 | emailList = (*it).emails(); |
1344 | if ( emailList.contains( email ) > 0 ) { | 1345 | if ( emailList.contains( email ) > 0 ) { |
1345 | found = true; | 1346 | found = true; |
1346 | (*it).setNameFromString( fullName ); | 1347 | (*it).setNameFromString( fullName ); |
1347 | editContact( (*it).uid() ); | 1348 | editContact( (*it).uid() ); |
1348 | } | 1349 | } |
1349 | } | 1350 | } |
1350 | 1351 | ||
1351 | if ( !found ) { | 1352 | if ( !found ) { |
1352 | KABC::Addressee addr; | 1353 | KABC::Addressee addr; |
1353 | addr.setNameFromString( fullName ); | 1354 | addr.setNameFromString( fullName ); |
1354 | addr.insertEmail( email, true ); | 1355 | addr.insertEmail( email, true ); |
1355 | 1356 | ||
1356 | mAddressBook->insertAddressee( addr ); | 1357 | mAddressBook->insertAddressee( addr ); |
1357 | mViewManager->refreshView( addr.uid() ); | 1358 | mViewManager->refreshView( addr.uid() ); |
1358 | editContact( addr.uid() ); | 1359 | editContact( addr.uid() ); |
1359 | } | 1360 | } |
1360 | #else //KAB_EMBEDDED | 1361 | #else //KAB_EMBEDDED |
1361 | qDebug("KABCore::addEmail finsih method"); | 1362 | qDebug("KABCore::addEmail finsih method"); |
1362 | #endif //KAB_EMBEDDED | 1363 | #endif //KAB_EMBEDDED |
1363 | } | 1364 | } |
1364 | 1365 | ||
1365 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 1366 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
1366 | { | 1367 | { |
1367 | mXXPortManager->importVCard( url, showPreview ); | 1368 | mXXPortManager->importVCard( url, showPreview ); |
1368 | } | 1369 | } |
1369 | void KABCore::importFromOL() | 1370 | void KABCore::importFromOL() |
1370 | { | 1371 | { |
1371 | #ifdef _OL_IMPORT_ | 1372 | #ifdef _OL_IMPORT_ |
1372 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | 1373 | KABC::Addressee::List list = OL_access::instance()->importOLcontacts(); |
1373 | idgl->exec(); | 1374 | if ( list.count() > 0 ) { |
1374 | KABC::Addressee::List list = idgl->getAddressList(); | 1375 | KABC::Addressee::List listNew; |
1375 | if ( list.count() > 0 ) { | 1376 | KABC::Addressee::List listExisting; |
1376 | KABC::Addressee::List listNew; | 1377 | KABC::Addressee::List::Iterator it; |
1377 | KABC::Addressee::List listExisting; | 1378 | KABC::AddressBook::Iterator iter; |
1378 | KABC::Addressee::List::Iterator it; | 1379 | for ( it = list.begin(); it != list.end(); ++it ) { |
1379 | KABC::AddressBook::Iterator iter; | 1380 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) |
1380 | for ( it = list.begin(); it != list.end(); ++it ) { | 1381 | listNew.append( (*it) ); |
1381 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) | 1382 | else |
1382 | listNew.append( (*it) ); | 1383 | listExisting.append( (*it) ); |
1383 | else | 1384 | } |
1384 | listExisting.append( (*it) ); | 1385 | QString mess = i18n("%1 contacts read from OL.\n\n%2 contacts added to addressbook!").arg( list.count()).arg( listNew.count() ); |
1385 | } | 1386 | if ( listExisting.count() > 0 ) |
1386 | if ( listExisting.count() > 0 ) | 1387 | mess += "\n\n"+ i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ); |
1387 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); | 1388 | |
1388 | if ( listNew.count() > 0 ) { | 1389 | KMessageBox::information( this, mess ); |
1389 | pasteWithNewUid = false; | 1390 | if ( listNew.count() > 0 ) { |
1390 | pasteContacts( listNew ); | 1391 | pasteWithNewUid = false; |
1391 | pasteWithNewUid = true; | 1392 | pasteContacts( listNew ); |
1393 | pasteWithNewUid = true; | ||
1394 | } | ||
1392 | } | 1395 | } |
1393 | } | ||
1394 | delete idgl; | ||
1395 | #endif | 1396 | #endif |
1396 | } | 1397 | } |
1397 | 1398 | ||
1399 | bool KABCore::readOLdata( KABC::AddressBook* local ) | ||
1400 | { | ||
1401 | #ifdef _OL_IMPORT_ | ||
1402 | QStringList folderList = OL_access::instance()->getFolderSelection( OL_CONTACT_DATA , i18n("Select Folder to sync")); | ||
1403 | KABC::Addressee::List list; | ||
1404 | if ( folderList.count() ) { | ||
1405 | OL_access::instance()->readContactData( OL_access::instance()->getFolderFromID( 0, folderList[1] ) , &list, true ); | ||
1406 | KABC::Addressee::List::Iterator it; | ||
1407 | for ( it = list.begin(); it != list.end(); ++it ) { | ||
1408 | (*it).setExternalUID( (*it).uid() ); | ||
1409 | (*it).setOriginalExternalUID( (*it).uid() ); | ||
1410 | (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | ||
1411 | local->insertAddressee( (*it) , false, false ); | ||
1412 | } | ||
1413 | mOLsyncFolderID = folderList[1]; | ||
1414 | //KMessageBox::information( this, i18n("OLsync folder ID ") + mOLsyncFolderID ); | ||
1415 | } | ||
1416 | return list.count() > 0; | ||
1417 | #else | ||
1418 | return false; | ||
1419 | #endif | ||
1420 | } | ||
1421 | bool KABCore::writeOLdata( KABC::AddressBook* aBook ) | ||
1422 | { | ||
1423 | #ifdef _OL_IMPORT_ | ||
1424 | if ( !OL_access::instance()->setSelectedFolder( mOLsyncFolderID ) ) | ||
1425 | return false; | ||
1426 | KABC::AddressBook::Iterator it; | ||
1427 | for ( it = aBook->begin(); it != aBook->end(); ++it ) { | ||
1428 | if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { | ||
1429 | KABC::Addressee addressee = (*it); | ||
1430 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) { | ||
1431 | (*it) = OL_access::instance()->addAddressee( (*it) ); | ||
1432 | (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | ||
1433 | } else if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { | ||
1434 | OL_access::instance()->deleteAddressee( (*it) ); | ||
1435 | } else if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { | ||
1436 | //changed | ||
1437 | (*it) = OL_access::instance()->changeAddressee( (*it) ); | ||
1438 | (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM ); | ||
1439 | } | ||
1440 | } | ||
1441 | } | ||
1442 | return true; | ||
1443 | #else | ||
1444 | return false; | ||
1445 | #endif | ||
1446 | } | ||
1398 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1447 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
1399 | { | 1448 | { |
1400 | mXXPortManager->importVCard( vCard, showPreview ); | 1449 | mXXPortManager->importVCard( vCard, showPreview ); |
1401 | } | 1450 | } |
1402 | 1451 | ||
1403 | //US added a second method without defaultparameter | 1452 | //US added a second method without defaultparameter |
1404 | void KABCore::editContact2() { | 1453 | void KABCore::editContact2() { |
1405 | editContact( QString::null ); | 1454 | editContact( QString::null ); |
1406 | } | 1455 | } |
1407 | 1456 | ||
1408 | void KABCore::editContact( const QString &uid ) | 1457 | void KABCore::editContact( const QString &uid ) |
1409 | { | 1458 | { |
1410 | 1459 | ||
1411 | if ( mExtensionManager->isQuickEditVisible() ) | 1460 | if ( mExtensionManager->isQuickEditVisible() ) |
1412 | return; | 1461 | return; |
1413 | 1462 | ||
1414 | // First, locate the contact entry | 1463 | // First, locate the contact entry |
1415 | QString localUID = uid; | 1464 | QString localUID = uid; |
1416 | if ( localUID.isNull() ) { | 1465 | if ( localUID.isNull() ) { |
1417 | QStringList uidList = mViewManager->selectedUids(); | 1466 | QStringList uidList = mViewManager->selectedUids(); |
1418 | if ( uidList.count() > 0 ) | 1467 | if ( uidList.count() > 0 ) |
1419 | localUID = *( uidList.at( 0 ) ); | 1468 | localUID = *( uidList.at( 0 ) ); |
1420 | } | 1469 | } |
1421 | 1470 | ||
1422 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 1471 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
1423 | if ( !addr.isEmpty() ) { | 1472 | if ( !addr.isEmpty() ) { |
1424 | mEditorDialog->setAddressee( addr ); | 1473 | mEditorDialog->setAddressee( addr ); |
1425 | KApplication::execDialog ( mEditorDialog ); | 1474 | KApplication::execDialog ( mEditorDialog ); |
1426 | } | 1475 | } |
1427 | } | 1476 | } |
1428 | 1477 | ||
1429 | /** | 1478 | /** |
1430 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 1479 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
1431 | the method will try to find a selected addressee in the view. | 1480 | the method will try to find a selected addressee in the view. |
1432 | */ | 1481 | */ |
1433 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1482 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) |
1434 | { | 1483 | { |
1435 | if ( mMultipleViewsAtOnce ) | 1484 | if ( mMultipleViewsAtOnce ) |
1436 | { | 1485 | { |
1437 | editContact( uid ); | 1486 | editContact( uid ); |
1438 | } | 1487 | } |
1439 | else | 1488 | else |
1440 | { | 1489 | { |
1441 | setDetailsVisible( true ); | 1490 | setDetailsVisible( true ); |
1442 | mActionDetails->setChecked(true); | 1491 | mActionDetails->setChecked(true); |
1443 | } | 1492 | } |
1444 | 1493 | ||
1445 | } | 1494 | } |
1446 | 1495 | ||
1447 | void KABCore::save() | 1496 | void KABCore::save() |
1448 | { | 1497 | { |
1449 | if (syncManager->blockSave()) | 1498 | if (syncManager->blockSave()) |
1450 | return; | 1499 | return; |
1451 | if ( !mModified ) | 1500 | if ( !mModified ) |
1452 | return; | 1501 | return; |
1453 | 1502 | ||
1454 | syncManager->setBlockSave(true); | 1503 | syncManager->setBlockSave(true); |
1455 | QString text = i18n( "There was an error while attempting to save\n the " | 1504 | QString text = i18n( "There was an error while attempting to save\n the " |
1456 | "address book. Please check that some \nother application is " | 1505 | "address book. Please check that some \nother application is " |
1457 | "not using it. " ); | 1506 | "not using it. " ); |
1458 | message(i18n("Saving ... please wait! "), false); | 1507 | message(i18n("Saving ... please wait! "), false); |
1459 | //qApp->processEvents(); | 1508 | //qApp->processEvents(); |
1460 | #ifndef KAB_EMBEDDED | 1509 | #ifndef KAB_EMBEDDED |
1461 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1510 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
1462 | if ( !b || !b->save() ) { | 1511 | if ( !b || !b->save() ) { |
1463 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 1512 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
1464 | } | 1513 | } |
1465 | #else //KAB_EMBEDDED | 1514 | #else //KAB_EMBEDDED |
1466 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 1515 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
1467 | if ( !b || !b->save() ) { | 1516 | if ( !b || !b->save() ) { |
1468 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 1517 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
1469 | } | 1518 | } |
1470 | #endif //KAB_EMBEDDED | 1519 | #endif //KAB_EMBEDDED |
1471 | 1520 | ||
1472 | message(i18n("Addressbook saved!")); | 1521 | message(i18n("Addressbook saved!")); |
1473 | setModified( false ); | 1522 | setModified( false ); |
1474 | syncManager->setBlockSave(false); | 1523 | syncManager->setBlockSave(false); |
1475 | } | 1524 | } |
1476 | 1525 | ||
1477 | 1526 | ||
1478 | void KABCore::undo() | 1527 | void KABCore::undo() |
1479 | { | 1528 | { |
1480 | UndoStack::instance()->undo(); | 1529 | UndoStack::instance()->undo(); |
1481 | 1530 | ||
1482 | // Refresh the view | 1531 | // Refresh the view |
1483 | mViewManager->refreshView(); | 1532 | mViewManager->refreshView(); |
1484 | } | 1533 | } |
1485 | 1534 | ||
1486 | void KABCore::redo() | 1535 | void KABCore::redo() |
1487 | { | 1536 | { |
1488 | RedoStack::instance()->redo(); | 1537 | RedoStack::instance()->redo(); |
1489 | 1538 | ||
1490 | // Refresh the view | 1539 | // Refresh the view |
1491 | mViewManager->refreshView(); | 1540 | mViewManager->refreshView(); |
1492 | } | 1541 | } |
1493 | void KABCore::setJumpButtonBar( bool visible ) | 1542 | void KABCore::setJumpButtonBar( bool visible ) |
1494 | { | 1543 | { |
1495 | setJumpButtonBarVisible(visible ); | 1544 | setJumpButtonBarVisible(visible ); |
1496 | saveSettings(); | 1545 | saveSettings(); |
1497 | } | 1546 | } |
1498 | void KABCore::setJumpButtonBarVisible( bool visible ) | 1547 | void KABCore::setJumpButtonBarVisible( bool visible ) |
1499 | { | 1548 | { |
1500 | if (mMultipleViewsAtOnce) | 1549 | if (mMultipleViewsAtOnce) |
1501 | { | 1550 | { |
1502 | if ( visible ) | 1551 | if ( visible ) |
1503 | mJumpButtonBar->show(); | 1552 | mJumpButtonBar->show(); |
1504 | else | 1553 | else |
1505 | mJumpButtonBar->hide(); | 1554 | mJumpButtonBar->hide(); |
1506 | } | 1555 | } |
1507 | else | 1556 | else |
1508 | { | 1557 | { |
1509 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" | 1558 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" |
1510 | if (mViewManager->isVisible()) | 1559 | if (mViewManager->isVisible()) |
1511 | { | 1560 | { |
1512 | if ( visible ) | 1561 | if ( visible ) |
1513 | mJumpButtonBar->show(); | 1562 | mJumpButtonBar->show(); |
1514 | else | 1563 | else |
1515 | mJumpButtonBar->hide(); | 1564 | mJumpButtonBar->hide(); |
1516 | } | 1565 | } |
1517 | else | 1566 | else |
1518 | { | 1567 | { |
1519 | mJumpButtonBar->hide(); | 1568 | mJumpButtonBar->hide(); |
1520 | } | 1569 | } |
1521 | } | 1570 | } |
1522 | if ( visible ) { | 1571 | if ( visible ) { |
1523 | if ( mIncSearchWidget->currentItem() == 0 ) { | 1572 | if ( mIncSearchWidget->currentItem() == 0 ) { |
1524 | message( i18n("Change search field enable jump bar") ); | 1573 | message( i18n("Change search field enable jump bar") ); |
1525 | } | 1574 | } |
1526 | } | 1575 | } |
1527 | } | 1576 | } |
1528 | 1577 | ||
1529 | 1578 | ||
1530 | void KABCore::setDetailsToState() | 1579 | void KABCore::setDetailsToState() |
1531 | { | 1580 | { |
1532 | setDetailsVisible( mActionDetails->isChecked() ); | 1581 | setDetailsVisible( mActionDetails->isChecked() ); |
1533 | } | 1582 | } |
1534 | void KABCore::setDetailsToggle() | 1583 | void KABCore::setDetailsToggle() |
1535 | { | 1584 | { |
1536 | mActionDetails->setChecked( !mActionDetails->isChecked() ); | 1585 | mActionDetails->setChecked( !mActionDetails->isChecked() ); |
1537 | setDetailsToState(); | 1586 | setDetailsToState(); |
1538 | } | 1587 | } |
1539 | 1588 | ||
1540 | 1589 | ||
1541 | 1590 | ||
1542 | void KABCore::setDetailsVisible( bool visible ) | 1591 | void KABCore::setDetailsVisible( bool visible ) |
1543 | { | 1592 | { |
1544 | if (visible && mDetails->isHidden()) | 1593 | if (visible && mDetails->isHidden()) |
1545 | { | 1594 | { |
1546 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1595 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1547 | if ( addrList.count() > 0 ) | 1596 | if ( addrList.count() > 0 ) |
1548 | mDetails->setAddressee( addrList[ 0 ] ); | 1597 | mDetails->setAddressee( addrList[ 0 ] ); |
1549 | } | 1598 | } |
1550 | 1599 | ||
1551 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between | 1600 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between |
1552 | // the listview and the detailview. We do that by changing the splitbar size. | 1601 | // the listview and the detailview. We do that by changing the splitbar size. |
1553 | if (mMultipleViewsAtOnce) | 1602 | if (mMultipleViewsAtOnce) |
1554 | { | 1603 | { |
1555 | if ( visible ) | 1604 | if ( visible ) |
1556 | mDetails->show(); | 1605 | mDetails->show(); |
1557 | else | 1606 | else |
1558 | mDetails->hide(); | 1607 | mDetails->hide(); |
1559 | } | 1608 | } |
1560 | else | 1609 | else |
1561 | { | 1610 | { |
1562 | if ( visible ) { | 1611 | if ( visible ) { |
1563 | mViewManager->hide(); | 1612 | mViewManager->hide(); |
1564 | mDetails->show(); | 1613 | mDetails->show(); |
1565 | mIncSearchWidget->setFocus(); | 1614 | mIncSearchWidget->setFocus(); |
1566 | } | 1615 | } |
1567 | else { | 1616 | else { |
1568 | mViewManager->show(); | 1617 | mViewManager->show(); |
1569 | mDetails->hide(); | 1618 | mDetails->hide(); |
1570 | mViewManager->setFocusAV(); | 1619 | mViewManager->setFocusAV(); |
1571 | } | 1620 | } |
1572 | setJumpButtonBarVisible( !visible ); | 1621 | setJumpButtonBarVisible( !visible ); |
1573 | } | 1622 | } |
1574 | 1623 | ||
1575 | } | 1624 | } |
1576 | 1625 | ||
1577 | void KABCore::extensionChanged( int id ) | 1626 | void KABCore::extensionChanged( int id ) |
1578 | { | 1627 | { |
1579 | //change the details view only for non desktop systems | 1628 | //change the details view only for non desktop systems |
1580 | #ifndef DESKTOP_VERSION | 1629 | #ifndef DESKTOP_VERSION |
1581 | 1630 | ||
1582 | if (id == 0) | 1631 | if (id == 0) |
1583 | { | 1632 | { |
1584 | //the user disabled the extension. | 1633 | //the user disabled the extension. |
1585 | 1634 | ||
1586 | if (mMultipleViewsAtOnce) | 1635 | if (mMultipleViewsAtOnce) |
1587 | { // enable detailsview again | 1636 | { // enable detailsview again |
1588 | setDetailsVisible( true ); | 1637 | setDetailsVisible( true ); |
1589 | mActionDetails->setChecked( true ); | 1638 | mActionDetails->setChecked( true ); |
1590 | } | 1639 | } |
1591 | else | 1640 | else |
1592 | { //go back to the listview | 1641 | { //go back to the listview |
1593 | setDetailsVisible( false ); | 1642 | setDetailsVisible( false ); |
1594 | mActionDetails->setChecked( false ); | 1643 | mActionDetails->setChecked( false ); |
1595 | mActionDetails->setEnabled(true); | 1644 | mActionDetails->setEnabled(true); |
1596 | } | 1645 | } |
1597 | 1646 | ||
1598 | } | 1647 | } |
1599 | else | 1648 | else |
1600 | { | 1649 | { |
1601 | //the user enabled the extension. | 1650 | //the user enabled the extension. |
1602 | setDetailsVisible( false ); | 1651 | setDetailsVisible( false ); |
1603 | mActionDetails->setChecked( false ); | 1652 | mActionDetails->setChecked( false ); |
1604 | 1653 | ||
1605 | if (!mMultipleViewsAtOnce) | 1654 | if (!mMultipleViewsAtOnce) |
1606 | { | 1655 | { |
1607 | mActionDetails->setEnabled(false); | 1656 | mActionDetails->setEnabled(false); |
1608 | } | 1657 | } |
1609 | 1658 | ||
1610 | mExtensionManager->setSelectionChanged(); | 1659 | mExtensionManager->setSelectionChanged(); |
1611 | 1660 | ||
1612 | } | 1661 | } |
1613 | 1662 | ||
1614 | #endif// DESKTOP_VERSION | 1663 | #endif// DESKTOP_VERSION |
1615 | 1664 | ||
1616 | } | 1665 | } |
1617 | 1666 | ||
1618 | 1667 | ||
1619 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1668 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1620 | { | 1669 | { |
1621 | 1670 | ||
1622 | if ( list.count() != 0 ) { | 1671 | if ( list.count() != 0 ) { |
1623 | KABC::Addressee::List::ConstIterator it; | 1672 | KABC::Addressee::List::ConstIterator it; |
1624 | for ( it = list.begin(); it != list.end(); ++it ) | 1673 | for ( it = list.begin(); it != list.end(); ++it ) |
1625 | mAddressBook->insertAddressee( *it ); | 1674 | mAddressBook->insertAddressee( *it ); |
1626 | if ( list.count() > 1 ) | 1675 | if ( list.count() > 1 ) |
1627 | setModified(); | 1676 | setModified(); |
1628 | else | 1677 | else |
1629 | setModifiedWOrefresh(); | 1678 | setModifiedWOrefresh(); |
1630 | } | 1679 | } |
1631 | if ( list.count() == 0 ) | 1680 | if ( list.count() == 0 ) |
1632 | mViewManager->refreshView(); | 1681 | mViewManager->refreshView(); |
1633 | else | 1682 | else |
1634 | mViewManager->refreshView( list[ 0 ].uid() ); | 1683 | mViewManager->refreshView( list[ 0 ].uid() ); |
1635 | 1684 | ||
1636 | 1685 | ||
1637 | 1686 | ||
1638 | } | 1687 | } |
1639 | 1688 | ||
1640 | QString KABCore::getNameByPhone( const QString &phone ) | 1689 | QString KABCore::getNameByPhone( const QString &phone ) |
1641 | { | 1690 | { |
1642 | #ifndef KAB_EMBEDDED | 1691 | #ifndef KAB_EMBEDDED |
1643 | QRegExp r( "[/*/-/ ]" ); | 1692 | QRegExp r( "[/*/-/ ]" ); |
1644 | QString localPhone( phone ); | 1693 | QString localPhone( phone ); |
1645 | 1694 | ||
1646 | bool found = false; | 1695 | bool found = false; |
1647 | QString ownerName = ""; | 1696 | QString ownerName = ""; |
1648 | KABC::AddressBook::Iterator iter; | 1697 | KABC::AddressBook::Iterator iter; |
1649 | KABC::PhoneNumber::List::Iterator phoneIter; | 1698 | KABC::PhoneNumber::List::Iterator phoneIter; |
1650 | KABC::PhoneNumber::List phoneList; | 1699 | KABC::PhoneNumber::List phoneList; |
1651 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1700 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
1652 | phoneList = (*iter).phoneNumbers(); | 1701 | phoneList = (*iter).phoneNumbers(); |
1653 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1702 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
1654 | ++phoneIter) { | 1703 | ++phoneIter) { |
1655 | // Get rid of separator chars so just the numbers are compared. | 1704 | // Get rid of separator chars so just the numbers are compared. |
1656 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1705 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
1657 | ownerName = (*iter).formattedName(); | 1706 | ownerName = (*iter).formattedName(); |
1658 | found = true; | 1707 | found = true; |
1659 | } | 1708 | } |
1660 | } | 1709 | } |
1661 | } | 1710 | } |
1662 | 1711 | ||
1663 | return ownerName; | 1712 | return ownerName; |
1664 | #else //KAB_EMBEDDED | 1713 | #else //KAB_EMBEDDED |
1665 | qDebug("KABCore::getNameByPhone finsih method"); | 1714 | qDebug("KABCore::getNameByPhone finsih method"); |
1666 | return ""; | 1715 | return ""; |
1667 | #endif //KAB_EMBEDDED | 1716 | #endif //KAB_EMBEDDED |
1668 | 1717 | ||
1669 | } | 1718 | } |
1670 | void KABCore::openConfigGlobalDialog() | 1719 | void KABCore::openConfigGlobalDialog() |
1671 | { | 1720 | { |
1672 | KPimPrefsGlobalDialog gc ( this ); | 1721 | KPimPrefsGlobalDialog gc ( this ); |
1673 | gc.exec(); | 1722 | gc.exec(); |
1674 | } | 1723 | } |
1675 | void KABCore::openConfigDialog() | 1724 | void KABCore::openConfigDialog() |
1676 | { | 1725 | { |
1677 | KDialogBase * ConfigureDialog = new KDialogBase ( KDialogBase::Plain , i18n("Configure KA/Pi"), KDialogBase::Default |KDialogBase::Cancel | KDialogBase::Apply | KDialogBase::Ok, KDialogBase::Ok,0, "name", true, true); | 1726 | KDialogBase * ConfigureDialog = new KDialogBase ( KDialogBase::Plain , i18n("Configure KA/Pi"), KDialogBase::Default |KDialogBase::Cancel | KDialogBase::Apply | KDialogBase::Ok, KDialogBase::Ok,0, "name", true, true); |
1678 | 1727 | ||
1679 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog , "KCMKabConfig" ); | 1728 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog , "KCMKabConfig" ); |
1680 | ConfigureDialog->setMainWidget( kabcfg ); | 1729 | ConfigureDialog->setMainWidget( kabcfg ); |
1681 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1730 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1682 | this, SLOT( configurationChanged() ) ); | 1731 | this, SLOT( configurationChanged() ) ); |
1683 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1732 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1684 | kabcfg, SLOT( save() ) ); | 1733 | kabcfg, SLOT( save() ) ); |
1685 | connect( ConfigureDialog, SIGNAL( acceptClicked() ), | 1734 | connect( ConfigureDialog, SIGNAL( acceptClicked() ), |
1686 | this, SLOT( configurationChanged() ) ); | 1735 | this, SLOT( configurationChanged() ) ); |
1687 | connect( ConfigureDialog, SIGNAL( acceptClicked() ), | 1736 | connect( ConfigureDialog, SIGNAL( acceptClicked() ), |
1688 | kabcfg, SLOT( save() ) ); | 1737 | kabcfg, SLOT( save() ) ); |
1689 | connect( ConfigureDialog, SIGNAL( defaultClicked() ), | 1738 | connect( ConfigureDialog, SIGNAL( defaultClicked() ), |
1690 | kabcfg, SLOT( defaults() ) ); | 1739 | kabcfg, SLOT( defaults() ) ); |
1691 | saveSettings(); | 1740 | saveSettings(); |
1692 | kabcfg->load(); | 1741 | kabcfg->load(); |
1693 | #ifndef DESKTOP_VERSION | 1742 | #ifndef DESKTOP_VERSION |
1694 | if ( QApplication::desktop()->height() <= 480 ) | 1743 | if ( QApplication::desktop()->height() <= 480 ) |
1695 | ConfigureDialog->hideButtons(); | 1744 | ConfigureDialog->hideButtons(); |
1696 | ConfigureDialog->showMaximized(); | 1745 | ConfigureDialog->showMaximized(); |
1697 | #endif | 1746 | #endif |
1698 | if ( ConfigureDialog->exec() ) | 1747 | if ( ConfigureDialog->exec() ) |
1699 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 1748 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
1700 | delete ConfigureDialog; | 1749 | delete ConfigureDialog; |
1701 | } | 1750 | } |
1702 | 1751 | ||
1703 | void KABCore::openLDAPDialog() | 1752 | void KABCore::openLDAPDialog() |
1704 | { | 1753 | { |
1705 | #ifndef KAB_EMBEDDED | 1754 | #ifndef KAB_EMBEDDED |
1706 | if ( !mLdapSearchDialog ) { | 1755 | if ( !mLdapSearchDialog ) { |
1707 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1756 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1708 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1757 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1709 | SLOT( refreshView() ) ); | 1758 | SLOT( refreshView() ) ); |
1710 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1759 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1711 | SLOT( setModified() ) ); | 1760 | SLOT( setModified() ) ); |
1712 | } else | 1761 | } else |
1713 | mLdapSearchDialog->restoreSettings(); | 1762 | mLdapSearchDialog->restoreSettings(); |
1714 | 1763 | ||
1715 | if ( mLdapSearchDialog->isOK() ) | 1764 | if ( mLdapSearchDialog->isOK() ) |
1716 | mLdapSearchDialog->exec(); | 1765 | mLdapSearchDialog->exec(); |
1717 | #else //KAB_EMBEDDED | 1766 | #else //KAB_EMBEDDED |
1718 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1767 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1719 | #endif //KAB_EMBEDDED | 1768 | #endif //KAB_EMBEDDED |
1720 | } | 1769 | } |
1721 | 1770 | ||
1722 | void KABCore::print() | 1771 | void KABCore::print() |
1723 | { | 1772 | { |
1724 | #ifndef KAB_EMBEDDED | 1773 | #ifndef KAB_EMBEDDED |
1725 | KPrinter printer; | 1774 | KPrinter printer; |
1726 | if ( !printer.setup( this ) ) | 1775 | if ( !printer.setup( this ) ) |
1727 | return; | 1776 | return; |
1728 | 1777 | ||
1729 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1778 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1730 | mViewManager->selectedUids(), this ); | 1779 | mViewManager->selectedUids(), this ); |
1731 | 1780 | ||
1732 | wizard.exec(); | 1781 | wizard.exec(); |
1733 | #else //KAB_EMBEDDED | 1782 | #else //KAB_EMBEDDED |
1734 | qDebug("KABCore::print() finsih method"); | 1783 | qDebug("KABCore::print() finsih method"); |
1735 | #endif //KAB_EMBEDDED | 1784 | #endif //KAB_EMBEDDED |
1736 | 1785 | ||
1737 | } | 1786 | } |
1738 | 1787 | ||
1739 | 1788 | ||
1740 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1789 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1741 | { | 1790 | { |
1742 | if ( mGUIClient ) | 1791 | if ( mGUIClient ) |
1743 | mGUIClient->insertChildClient( client ); | 1792 | mGUIClient->insertChildClient( client ); |
1744 | else | 1793 | else |
1745 | KMessageBox::error( this, "no KXMLGUICLient"); | 1794 | KMessageBox::error( this, "no KXMLGUICLient"); |
1746 | } | 1795 | } |
1747 | 1796 | ||
1748 | 1797 | ||
1749 | void KABCore::configurationChanged() | 1798 | void KABCore::configurationChanged() |
1750 | { | 1799 | { |
1751 | mExtensionManager->reconfigure(); | 1800 | mExtensionManager->reconfigure(); |
1752 | } | 1801 | } |
1753 | 1802 | ||
1754 | void KABCore::addressBookChanged() | 1803 | void KABCore::addressBookChanged() |
1755 | { | 1804 | { |
1756 | /*US | 1805 | /*US |
1757 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1806 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1758 | while ( it.current() ) { | 1807 | while ( it.current() ) { |
1759 | if ( it.current()->dirty() ) { | 1808 | if ( it.current()->dirty() ) { |
1760 | QString text = i18n( "Data has been changed externally. Unsaved " | 1809 | QString text = i18n( "Data has been changed externally. Unsaved " |
1761 | "changes will be lost." ); | 1810 | "changes will be lost." ); |
1762 | KMessageBox::information( this, text ); | 1811 | KMessageBox::information( this, text ); |
1763 | } | 1812 | } |
1764 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1813 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1765 | ++it; | 1814 | ++it; |
1766 | } | 1815 | } |
1767 | */ | 1816 | */ |
1768 | if (mEditorDialog) | 1817 | if (mEditorDialog) |
1769 | { | 1818 | { |
1770 | if (mEditorDialog->dirty()) | 1819 | if (mEditorDialog->dirty()) |
1771 | { | 1820 | { |
1772 | QString text = i18n( "Data has been changed externally. Unsaved " | 1821 | QString text = i18n( "Data has been changed externally. Unsaved " |
1773 | "changes will be lost." ); | 1822 | "changes will be lost." ); |
1774 | KMessageBox::information( this, text ); | 1823 | KMessageBox::information( this, text ); |
1775 | } | 1824 | } |
1776 | QString currentuid = mEditorDialog->addressee().uid(); | 1825 | QString currentuid = mEditorDialog->addressee().uid(); |
1777 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); | 1826 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); |
1778 | } | 1827 | } |
1779 | mViewManager->refreshView(); | 1828 | mViewManager->refreshView(); |
1780 | 1829 | ||
1781 | 1830 | ||
1782 | } | 1831 | } |
1783 | 1832 | ||
1784 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1833 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1785 | const char *name ) | 1834 | const char *name ) |
1786 | { | 1835 | { |
1787 | 1836 | ||
1788 | if ( mEditorDialog == 0 ) { | 1837 | if ( mEditorDialog == 0 ) { |
1789 | mEditorDialog = new AddresseeEditorDialog( this, parent, | 1838 | mEditorDialog = new AddresseeEditorDialog( this, parent, |
1790 | name ? name : "editorDialog" ); | 1839 | name ? name : "editorDialog" ); |
1791 | 1840 | ||
1792 | 1841 | ||
1793 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1842 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1794 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1843 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1795 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), | 1844 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), |
1796 | // SLOT( slotEditorDestroyed( const QString& ) ) ; | 1845 | // SLOT( slotEditorDestroyed( const QString& ) ) ; |
1797 | } | 1846 | } |
1798 | 1847 | ||
1799 | return mEditorDialog; | 1848 | return mEditorDialog; |
1800 | } | 1849 | } |
1801 | 1850 | ||
1802 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1851 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1803 | { | 1852 | { |
1804 | //mEditorDict.remove( uid ); | 1853 | //mEditorDict.remove( uid ); |
1805 | } | 1854 | } |
1806 | 1855 | ||
1807 | void KABCore::initGUI() | 1856 | void KABCore::initGUI() |
1808 | { | 1857 | { |
1809 | #ifndef KAB_EMBEDDED | 1858 | #ifndef KAB_EMBEDDED |
1810 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1859 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1811 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1860 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1812 | 1861 | ||
1813 | mExtensionBarSplitter = new QSplitter( this ); | 1862 | mExtensionBarSplitter = new QSplitter( this ); |
1814 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1863 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1815 | 1864 | ||
1816 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1865 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1817 | 1866 | ||
1818 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1867 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1819 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1868 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1820 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1869 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1821 | SLOT( incrementalSearch( const QString& ) ) ); | 1870 | SLOT( incrementalSearch( const QString& ) ) ); |
1822 | 1871 | ||
1823 | mViewManager = new ViewManager( this, viewSpace ); | 1872 | mViewManager = new ViewManager( this, viewSpace ); |
1824 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1873 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1825 | 1874 | ||
1826 | mDetails = new ViewContainer( mDetailsSplitter ); | 1875 | mDetails = new ViewContainer( mDetailsSplitter ); |
1827 | 1876 | ||
1828 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1877 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1829 | 1878 | ||
1830 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1879 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1831 | 1880 | ||
1832 | topLayout->addWidget( mExtensionBarSplitter ); | 1881 | topLayout->addWidget( mExtensionBarSplitter ); |
1833 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1882 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1834 | topLayout->addWidget( mJumpButtonBar ); | 1883 | topLayout->addWidget( mJumpButtonBar ); |
1835 | //topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1884 | //topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1836 | 1885 | ||
1837 | mXXPortManager = new XXPortManager( this, this ); | 1886 | mXXPortManager = new XXPortManager( this, this ); |
1838 | 1887 | ||
1839 | #else //KAB_EMBEDDED | 1888 | #else //KAB_EMBEDDED |
1840 | //US initialize viewMenu before settingup viewmanager. | 1889 | //US initialize viewMenu before settingup viewmanager. |
1841 | // Viewmanager needs this menu to plugin submenues. | 1890 | // Viewmanager needs this menu to plugin submenues. |
1842 | viewMenu = new QPopupMenu( this ); | 1891 | viewMenu = new QPopupMenu( this ); |
1843 | settingsMenu = new QPopupMenu( this ); | 1892 | settingsMenu = new QPopupMenu( this ); |
1844 | //filterMenu = new QPopupMenu( this ); | 1893 | //filterMenu = new QPopupMenu( this ); |
1845 | ImportMenu = new QPopupMenu( this ); | 1894 | ImportMenu = new QPopupMenu( this ); |
1846 | ExportMenu = new QPopupMenu( this ); | 1895 | ExportMenu = new QPopupMenu( this ); |
1847 | syncMenu = new QPopupMenu( this ); | 1896 | syncMenu = new QPopupMenu( this ); |
1848 | changeMenu= new QPopupMenu( this ); | 1897 | changeMenu= new QPopupMenu( this ); |
1849 | beamMenu= new QPopupMenu( this ); | 1898 | beamMenu= new QPopupMenu( this ); |
1850 | 1899 | ||
1851 | //US since we have no splitter for the embedded system, setup | 1900 | //US since we have no splitter for the embedded system, setup |
1852 | // a layout with two frames. One left and one right. | 1901 | // a layout with two frames. One left and one right. |
1853 | 1902 | ||
1854 | QBoxLayout *topLayout; | 1903 | QBoxLayout *topLayout; |
1855 | 1904 | ||
1856 | // = new QHBoxLayout( this ); | 1905 | // = new QHBoxLayout( this ); |
1857 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1906 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1858 | 1907 | ||
1859 | // QWidget *mainBox = new QWidget( this ); | 1908 | // QWidget *mainBox = new QWidget( this ); |
1860 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1909 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1861 | 1910 | ||
1862 | #ifdef DESKTOP_VERSION | 1911 | #ifdef DESKTOP_VERSION |
1863 | topLayout = new QHBoxLayout( this ); | 1912 | topLayout = new QHBoxLayout( this ); |
1864 | 1913 | ||
1865 | 1914 | ||
1866 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1915 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1867 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1916 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1868 | 1917 | ||
1869 | topLayout->addWidget(mMiniSplitter ); | 1918 | topLayout->addWidget(mMiniSplitter ); |
1870 | 1919 | ||
1871 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1920 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1872 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1921 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1873 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1922 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1874 | mDetails = new ViewContainer( mMiniSplitter ); | 1923 | mDetails = new ViewContainer( mMiniSplitter ); |
1875 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1924 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1876 | #else | 1925 | #else |
1877 | if ( QApplication::desktop()->width() > 480 ) { | 1926 | if ( QApplication::desktop()->width() > 480 ) { |
1878 | topLayout = new QHBoxLayout( this ); | 1927 | topLayout = new QHBoxLayout( this ); |
1879 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1928 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1880 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1929 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1881 | } else { | 1930 | } else { |
1882 | 1931 | ||
1883 | topLayout = new QHBoxLayout( this ); | 1932 | topLayout = new QHBoxLayout( this ); |
1884 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1933 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1885 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1934 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1886 | } | 1935 | } |
1887 | 1936 | ||
1888 | topLayout->addWidget(mMiniSplitter ); | 1937 | topLayout->addWidget(mMiniSplitter ); |
1889 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1938 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1890 | mDetails = new ViewContainer( mMiniSplitter ); | 1939 | mDetails = new ViewContainer( mMiniSplitter ); |
1891 | 1940 | ||
1892 | 1941 | ||
1893 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1942 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1894 | #endif | 1943 | #endif |
1895 | //eh->hide(); | 1944 | //eh->hide(); |
1896 | // topLayout->addWidget(mExtensionManager ); | 1945 | // topLayout->addWidget(mExtensionManager ); |
1897 | 1946 | ||
1898 | 1947 | ||
1899 | /*US | 1948 | /*US |
1900 | #ifndef KAB_NOSPLITTER | 1949 | #ifndef KAB_NOSPLITTER |
1901 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1950 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1902 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1951 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1903 | topLayout->setSpacing( 10 ); | 1952 | topLayout->setSpacing( 10 ); |
1904 | 1953 | ||
1905 | mDetailsSplitter = new QSplitter( this ); | 1954 | mDetailsSplitter = new QSplitter( this ); |
1906 | 1955 | ||
1907 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1956 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1908 | 1957 | ||
1909 | mViewManager = new ViewManager( this, viewSpace ); | 1958 | mViewManager = new ViewManager( this, viewSpace ); |
1910 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1959 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1911 | 1960 | ||
1912 | mDetails = new ViewContainer( mDetailsSplitter ); | 1961 | mDetails = new ViewContainer( mDetailsSplitter ); |
1913 | 1962 | ||
1914 | topLayout->addWidget( mDetailsSplitter ); | 1963 | topLayout->addWidget( mDetailsSplitter ); |
1915 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1964 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1916 | #else //KAB_NOSPLITTER | 1965 | #else //KAB_NOSPLITTER |
1917 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1966 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1918 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1967 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1919 | topLayout->setSpacing( 10 ); | 1968 | topLayout->setSpacing( 10 ); |
1920 | 1969 | ||
1921 | // mDetailsSplitter = new QSplitter( this ); | 1970 | // mDetailsSplitter = new QSplitter( this ); |
1922 | 1971 | ||
1923 | QVBox *viewSpace = new QVBox( this ); | 1972 | QVBox *viewSpace = new QVBox( this ); |
1924 | 1973 | ||
1925 | mViewManager = new ViewManager( this, viewSpace ); | 1974 | mViewManager = new ViewManager( this, viewSpace ); |
1926 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1975 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1927 | 1976 | ||
1928 | mDetails = new ViewContainer( this ); | 1977 | mDetails = new ViewContainer( this ); |
1929 | 1978 | ||
1930 | topLayout->addWidget( viewSpace ); | 1979 | topLayout->addWidget( viewSpace ); |
1931 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1980 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1932 | topLayout->addWidget( mDetails ); | 1981 | topLayout->addWidget( mDetails ); |
1933 | #endif //KAB_NOSPLITTER | 1982 | #endif //KAB_NOSPLITTER |
1934 | */ | 1983 | */ |
1935 | 1984 | ||
1936 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 1985 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
1937 | syncManager->setBlockSave(false); | 1986 | syncManager->setBlockSave(false); |
1938 | 1987 | ||
1939 | connect(syncManager , SIGNAL( request_file(const QString &) ), this, SLOT( syncFileRequest(const QString &) ) ); | 1988 | connect(syncManager , SIGNAL( request_file(const QString &) ), this, SLOT( syncFileRequest(const QString &) ) ); |
1940 | connect(syncManager , SIGNAL( getFile( bool ,const QString &)), this, SLOT(getFile( bool ,const QString &) ) ); | 1989 | connect(syncManager , SIGNAL( getFile( bool ,const QString &)), this, SLOT(getFile( bool ,const QString &) ) ); |
1941 | QString sync_file = sentSyncFile(); | 1990 | QString sync_file = sentSyncFile(); |
1942 | //qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); | 1991 | //qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); |
1943 | syncManager->setDefaultFileName( sync_file ); | 1992 | syncManager->setDefaultFileName( sync_file ); |
1944 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); | 1993 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); |
1945 | 1994 | ||
1946 | #endif //KAB_EMBEDDED | 1995 | #endif //KAB_EMBEDDED |
1947 | initActions(); | 1996 | initActions(); |
1948 | 1997 | ||
1949 | #ifdef KAB_EMBEDDED | 1998 | #ifdef KAB_EMBEDDED |
1950 | addActionsManually(); | 1999 | addActionsManually(); |
1951 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 2000 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1952 | mXXPortManager = new XXPortManager( this, this ); | 2001 | mXXPortManager = new XXPortManager( this, this ); |
1953 | 2002 | ||
1954 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 2003 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1955 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 2004 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1956 | // mActionQuit->plug ( mMainWindow->toolBar()); | 2005 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1957 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 2006 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1958 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 2007 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1959 | // mIncSearchWidget->hide(); | 2008 | // mIncSearchWidget->hide(); |
1960 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 2009 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1961 | SLOT( incrementalSearch( const QString& ) ) ); | 2010 | SLOT( incrementalSearch( const QString& ) ) ); |
1962 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); | 2011 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); |
1963 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); | 2012 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); |
1964 | 2013 | ||
1965 | mJumpButtonBar = new JumpButtonBar( this, this ); | 2014 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1966 | 2015 | ||
1967 | topLayout->addWidget( mJumpButtonBar ); | 2016 | topLayout->addWidget( mJumpButtonBar ); |
1968 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 2017 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1969 | 2018 | ||
1970 | // mMainWindow->getIconToolBar()->raise(); | 2019 | // mMainWindow->getIconToolBar()->raise(); |
1971 | 2020 | ||
1972 | #endif //KAB_EMBEDDED | 2021 | #endif //KAB_EMBEDDED |
1973 | 2022 | ||
1974 | } | 2023 | } |
1975 | void KABCore::initActions() | 2024 | void KABCore::initActions() |
1976 | { | 2025 | { |
1977 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 2026 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1978 | 2027 | ||
1979 | #ifndef KAB_EMBEDDED | 2028 | #ifndef KAB_EMBEDDED |
1980 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 2029 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1981 | SLOT( clipboardDataChanged() ) ); | 2030 | SLOT( clipboardDataChanged() ) ); |
1982 | #endif //KAB_EMBEDDED | 2031 | #endif //KAB_EMBEDDED |
1983 | 2032 | ||
1984 | // file menu | 2033 | // file menu |
1985 | 2034 | ||
1986 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 2035 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1987 | //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 2036 | //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1988 | mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager, | 2037 | mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager, |
1989 | SLOT( printView() ), actionCollection(), "kaddressbook_print" ); | 2038 | SLOT( printView() ), actionCollection(), "kaddressbook_print" ); |
1990 | 2039 | ||
1991 | 2040 | ||
1992 | mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails, | 2041 | mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails, |
1993 | SLOT( printView() ), actionCollection(), "kaddressbook_print2" ); | 2042 | SLOT( printView() ), actionCollection(), "kaddressbook_print2" ); |
1994 | 2043 | ||
1995 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 2044 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1996 | SLOT( save() ), actionCollection(), "file_sync" ); | 2045 | SLOT( save() ), actionCollection(), "file_sync" ); |
1997 | 2046 | ||
1998 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 2047 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1999 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 2048 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
2000 | 2049 | ||
2001 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 2050 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
2002 | this, SLOT( mailVCard() ), | 2051 | this, SLOT( mailVCard() ), |
2003 | actionCollection(), "file_mail_vcard"); | 2052 | actionCollection(), "file_mail_vcard"); |
2004 | 2053 | ||
2005 | mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, | 2054 | mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, |
2006 | SLOT( export2phone() ), actionCollection(), | 2055 | SLOT( export2phone() ), actionCollection(), |
2007 | "kaddressbook_ex2phone" ); | 2056 | "kaddressbook_ex2phone" ); |
2008 | 2057 | ||
2009 | mActionBeamVCard = 0; | 2058 | mActionBeamVCard = 0; |
2010 | mActionBeam = 0; | 2059 | mActionBeam = 0; |
2011 | 2060 | ||
2012 | #ifndef DESKTOP_VERSION | 2061 | #ifndef DESKTOP_VERSION |
2013 | if ( Ir::supported() ) { | 2062 | if ( Ir::supported() ) { |
2014 | mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, | 2063 | mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, |
2015 | SLOT( beamVCard() ), actionCollection(), | 2064 | SLOT( beamVCard() ), actionCollection(), |
2016 | "kaddressbook_beam_vcard" ); | 2065 | "kaddressbook_beam_vcard" ); |
2017 | 2066 | ||
2018 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | 2067 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, |
2019 | SLOT( beamMySelf() ), actionCollection(), | 2068 | SLOT( beamMySelf() ), actionCollection(), |
2020 | "kaddressbook_beam_myself" ); | 2069 | "kaddressbook_beam_myself" ); |
2021 | } | 2070 | } |
2022 | #endif | 2071 | #endif |
2023 | 2072 | ||
2024 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 2073 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
2025 | this, SLOT( editContact2() ), | 2074 | this, SLOT( editContact2() ), |
2026 | actionCollection(), "file_properties" ); | 2075 | actionCollection(), "file_properties" ); |
2027 | 2076 | ||
2028 | #ifdef KAB_EMBEDDED | 2077 | #ifdef KAB_EMBEDDED |
2029 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 2078 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
2030 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 2079 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
2031 | mMainWindow, SLOT( exit() ), | 2080 | mMainWindow, SLOT( exit() ), |
2032 | actionCollection(), "quit" ); | 2081 | actionCollection(), "quit" ); |
2033 | #endif //KAB_EMBEDDED | 2082 | #endif //KAB_EMBEDDED |
2034 | 2083 | ||
2035 | // edit menu | 2084 | // edit menu |
2036 | if ( mIsPart ) { | 2085 | if ( mIsPart ) { |
2037 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 2086 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
2038 | SLOT( copyContacts() ), actionCollection(), | 2087 | SLOT( copyContacts() ), actionCollection(), |
2039 | "kaddressbook_copy" ); | 2088 | "kaddressbook_copy" ); |
2040 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 2089 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
2041 | SLOT( cutContacts() ), actionCollection(), | 2090 | SLOT( cutContacts() ), actionCollection(), |
2042 | "kaddressbook_cut" ); | 2091 | "kaddressbook_cut" ); |
2043 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 2092 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
2044 | SLOT( pasteContacts() ), actionCollection(), | 2093 | SLOT( pasteContacts() ), actionCollection(), |
2045 | "kaddressbook_paste" ); | 2094 | "kaddressbook_paste" ); |
2046 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 2095 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
2047 | SLOT( selectAllContacts() ), actionCollection(), | 2096 | SLOT( selectAllContacts() ), actionCollection(), |
2048 | "kaddressbook_select_all" ); | 2097 | "kaddressbook_select_all" ); |
2049 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 2098 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
2050 | SLOT( undo() ), actionCollection(), | 2099 | SLOT( undo() ), actionCollection(), |
2051 | "kaddressbook_undo" ); | 2100 | "kaddressbook_undo" ); |
2052 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 2101 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
2053 | this, SLOT( redo() ), actionCollection(), | 2102 | this, SLOT( redo() ), actionCollection(), |
2054 | "kaddressbook_redo" ); | 2103 | "kaddressbook_redo" ); |
2055 | } else { | 2104 | } else { |
2056 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 2105 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
2057 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 2106 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
2058 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 2107 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
2059 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 2108 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
2060 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 2109 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
2061 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 2110 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
2062 | } | 2111 | } |
2063 | 2112 | ||
2064 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 2113 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
2065 | Key_Delete, this, SLOT( deleteContacts() ), | 2114 | Key_Delete, this, SLOT( deleteContacts() ), |
2066 | actionCollection(), "edit_delete" ); | 2115 | actionCollection(), "edit_delete" ); |
2067 | 2116 | ||
2068 | mActionUndo->setEnabled( false ); | 2117 | mActionUndo->setEnabled( false ); |
2069 | mActionRedo->setEnabled( false ); | 2118 | mActionRedo->setEnabled( false ); |
2070 | 2119 | ||
2071 | // settings menu | 2120 | // settings menu |
2072 | #ifdef KAB_EMBEDDED | 2121 | #ifdef KAB_EMBEDDED |
2073 | //US special menuentry to configure the addressbook resources. On KDE | 2122 | //US special menuentry to configure the addressbook resources. On KDE |
2074 | // you do that through the control center !!! | 2123 | // you do that through the control center !!! |
2075 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 2124 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
2076 | SLOT( configureResources() ), actionCollection(), | 2125 | SLOT( configureResources() ), actionCollection(), |
2077 | "kaddressbook_configure_resources" ); | 2126 | "kaddressbook_configure_resources" ); |
2078 | #endif //KAB_EMBEDDED | 2127 | #endif //KAB_EMBEDDED |
2079 | 2128 | ||
2080 | if ( mIsPart ) { | 2129 | if ( mIsPart ) { |
2081 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 2130 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
2082 | SLOT( openConfigDialog() ), actionCollection(), | 2131 | SLOT( openConfigDialog() ), actionCollection(), |
2083 | "kaddressbook_configure" ); | 2132 | "kaddressbook_configure" ); |
2084 | 2133 | ||
2085 | //US not implemented yet | 2134 | //US not implemented yet |
2086 | //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 2135 | //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
2087 | // this, SLOT( configureKeyBindings() ), actionCollection(), | 2136 | // this, SLOT( configureKeyBindings() ), actionCollection(), |
2088 | // "kaddressbook_configure_shortcuts" ); | 2137 | // "kaddressbook_configure_shortcuts" ); |
2089 | #ifdef KAB_EMBEDDED | 2138 | #ifdef KAB_EMBEDDED |
2090 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 2139 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
2091 | mActionConfigureToolbars->setEnabled( false ); | 2140 | mActionConfigureToolbars->setEnabled( false ); |
2092 | #endif //KAB_EMBEDDED | 2141 | #endif //KAB_EMBEDDED |
2093 | 2142 | ||
2094 | } else { | 2143 | } else { |
2095 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KA/Pi..." ), "configure", 0, this, | 2144 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KA/Pi..." ), "configure", 0, this, |
2096 | SLOT( openConfigDialog() ), actionCollection(), | 2145 | SLOT( openConfigDialog() ), actionCollection(), |
2097 | "kaddressbook_configure" ); | 2146 | "kaddressbook_configure" ); |
2098 | mActionConfigGlobal = new KAction( i18n( "Global Settings..." ), "configure", 0, this, | 2147 | mActionConfigGlobal = new KAction( i18n( "Global Settings..." ), "configure", 0, this, |
2099 | SLOT( openConfigGlobalDialog() ), actionCollection(), | 2148 | SLOT( openConfigGlobalDialog() ), actionCollection(), |
2100 | "kaddressbook_configure" ); | 2149 | "kaddressbook_configure" ); |
2101 | } | 2150 | } |
2102 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 2151 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
2103 | actionCollection(), "options_show_jump_bar" ); | 2152 | actionCollection(), "options_show_jump_bar" ); |
2104 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBar( bool ) ) ); | 2153 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBar( bool ) ) ); |
2105 | 2154 | ||
2106 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, | 2155 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
2107 | actionCollection(), "options_show_details" ); | 2156 | actionCollection(), "options_show_details" ); |
2108 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 2157 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
2109 | 2158 | ||
2110 | 2159 | ||
2111 | mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, | 2160 | mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, |
2112 | SLOT( toggleBeamReceive() ), actionCollection(), | 2161 | SLOT( toggleBeamReceive() ), actionCollection(), |
2113 | "kaddressbook_beam_rec" ); | 2162 | "kaddressbook_beam_rec" ); |
2114 | 2163 | ||
2115 | 2164 | ||
2116 | // misc | 2165 | // misc |
2117 | // only enable LDAP lookup if we can handle the protocol | 2166 | // only enable LDAP lookup if we can handle the protocol |
2118 | #ifndef KAB_EMBEDDED | 2167 | #ifndef KAB_EMBEDDED |
2119 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 2168 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
2120 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 2169 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
2121 | this, SLOT( openLDAPDialog() ), actionCollection(), | 2170 | this, SLOT( openLDAPDialog() ), actionCollection(), |
2122 | "ldap_lookup" ); | 2171 | "ldap_lookup" ); |
2123 | } | 2172 | } |
2124 | #else //KAB_EMBEDDED | 2173 | #else //KAB_EMBEDDED |
2125 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 2174 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
2126 | #endif //KAB_EMBEDDED | 2175 | #endif //KAB_EMBEDDED |
2127 | 2176 | ||
2128 | 2177 | ||
2129 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 2178 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
2130 | SLOT( setWhoAmI() ), actionCollection(), | 2179 | SLOT( setWhoAmI() ), actionCollection(), |
2131 | "set_personal" ); | 2180 | "set_personal" ); |
2132 | 2181 | ||
2133 | 2182 | ||
2134 | mActionCategories = new KAction( i18n( "Set Categories for Contacts..." ), 0, this, | 2183 | mActionCategories = new KAction( i18n( "Set Categories for Contacts..." ), 0, this, |
2135 | SLOT( setCategories() ), actionCollection(), | 2184 | SLOT( setCategories() ), actionCollection(), |
2136 | "edit_set_categories" ); | 2185 | "edit_set_categories" ); |
2137 | mActionEditCategories = new KAction( i18n( "Edit Category List..." ), 0, this, | 2186 | mActionEditCategories = new KAction( i18n( "Edit Category List..." ), 0, this, |
2138 | SLOT( editCategories() ), actionCollection(), | 2187 | SLOT( editCategories() ), actionCollection(), |
2139 | "edit__categories" ); | 2188 | "edit__categories" ); |
2140 | 2189 | ||
2141 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 2190 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
2142 | SLOT( removeVoice() ), actionCollection(), | 2191 | SLOT( removeVoice() ), actionCollection(), |
2143 | "remove_voice" ); | 2192 | "remove_voice" ); |
2144 | mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this, | 2193 | mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this, |
2145 | SLOT( setFormattedName() ), actionCollection(), | 2194 | SLOT( setFormattedName() ), actionCollection(), |
2146 | "set_formatted" ); | 2195 | "set_formatted" ); |
2147 | 2196 | ||
2148 | mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, | 2197 | mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, |
2149 | SLOT( manageCategories() ), actionCollection(), | 2198 | SLOT( manageCategories() ), actionCollection(), |
2150 | "remove_voice" ); | 2199 | "remove_voice" ); |
2151 | 2200 | ||
2152 | 2201 | ||
2153 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, | 2202 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, |
2154 | SLOT( importFromOL() ), actionCollection(), | 2203 | SLOT( importFromOL() ), actionCollection(), |
2155 | "import_OL" ); | 2204 | "import_OL" ); |
2156 | #ifdef KAB_EMBEDDED | 2205 | #ifdef KAB_EMBEDDED |
2157 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 2206 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
2158 | this, SLOT( showLicence() ), actionCollection(), | 2207 | this, SLOT( showLicence() ), actionCollection(), |
2159 | "licence_about_data" ); | 2208 | "licence_about_data" ); |
2160 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 2209 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
2161 | this, SLOT( faq() ), actionCollection(), | 2210 | this, SLOT( faq() ), actionCollection(), |
2162 | "faq_about_data" ); | 2211 | "faq_about_data" ); |
2163 | mActionWN = new KAction( i18n( "What's New?" ), 0, | 2212 | mActionWN = new KAction( i18n( "What's New?" ), 0, |
2164 | this, SLOT( whatsnew() ), actionCollection(), | 2213 | this, SLOT( whatsnew() ), actionCollection(), |
2165 | "wn" ); | 2214 | "wn" ); |
2166 | 2215 | ||
2167 | 2216 | ||
2168 | 2217 | ||
2169 | mActionStorageHowto = new KAction( i18n( "Storage HowTo" ), 0, | 2218 | mActionStorageHowto = new KAction( i18n( "Storage HowTo" ), 0, |
2170 | this, SLOT( storagehowto() ), actionCollection(), | 2219 | this, SLOT( storagehowto() ), actionCollection(), |
2171 | "storage" ); | 2220 | "storage" ); |
2172 | 2221 | ||
2173 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, | 2222 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, |
2174 | this, SLOT( synchowto() ), actionCollection(), | 2223 | this, SLOT( synchowto() ), actionCollection(), |
2175 | "sync" ); | 2224 | "sync" ); |
2176 | mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, | 2225 | mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, |
2177 | this, SLOT( kdesynchowto() ), actionCollection(), | 2226 | this, SLOT( kdesynchowto() ), actionCollection(), |
2178 | "kdesync" ); | 2227 | "kdesync" ); |
2179 | mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, | 2228 | mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, |
2180 | this, SLOT( multisynchowto() ), actionCollection(), | 2229 | this, SLOT( multisynchowto() ), actionCollection(), |
2181 | "multisync" ); | 2230 | "multisync" ); |
2182 | 2231 | ||
2183 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 2232 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
2184 | this, SLOT( createAboutData() ), actionCollection(), | 2233 | this, SLOT( createAboutData() ), actionCollection(), |
2185 | "kaddressbook_about_data" ); | 2234 | "kaddressbook_about_data" ); |
2186 | #endif //KAB_EMBEDDED | 2235 | #endif //KAB_EMBEDDED |
2187 | 2236 | ||
2188 | clipboardDataChanged(); | 2237 | clipboardDataChanged(); |
2189 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 2238 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
2190 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 2239 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
2191 | } | 2240 | } |
2192 | 2241 | ||
2193 | //US we need this function, to plug all actions into the correct menues. | 2242 | //US we need this function, to plug all actions into the correct menues. |
2194 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 2243 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
2195 | void KABCore::addActionsManually() | 2244 | void KABCore::addActionsManually() |
2196 | { | 2245 | { |
2197 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 2246 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
2198 | 2247 | ||
2199 | #ifdef KAB_EMBEDDED | 2248 | #ifdef KAB_EMBEDDED |
2200 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 2249 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
2201 | QPopupMenu *editMenu = new QPopupMenu( this ); | 2250 | QPopupMenu *editMenu = new QPopupMenu( this ); |
2202 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 2251 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
2203 | 2252 | ||
2204 | KToolBar* tb = mMainWindow->toolBar(); | 2253 | KToolBar* tb = mMainWindow->toolBar(); |
2205 | mMainWindow->setToolBarsMovable (false ); | 2254 | mMainWindow->setToolBarsMovable (false ); |
2206 | #ifndef DESKTOP_VERSION | 2255 | #ifndef DESKTOP_VERSION |
2207 | if ( KABPrefs::instance()->mFullMenuBarVisible ) { | 2256 | if ( KABPrefs::instance()->mFullMenuBarVisible ) { |
2208 | #endif | 2257 | #endif |
2209 | QMenuBar* mb = mMainWindow->menuBar(); | 2258 | QMenuBar* mb = mMainWindow->menuBar(); |
2210 | 2259 | ||
2211 | //US setup menubar. | 2260 | //US setup menubar. |
2212 | //Disable the following block if you do not want to have a menubar. | 2261 | //Disable the following block if you do not want to have a menubar. |
2213 | mb->insertItem( i18n("&File"), fileMenu ); | 2262 | mb->insertItem( i18n("&File"), fileMenu ); |
2214 | mb->insertItem( i18n("&Edit"), editMenu ); | 2263 | mb->insertItem( i18n("&Edit"), editMenu ); |
2215 | mb->insertItem( i18n("&View"), viewMenu ); | 2264 | mb->insertItem( i18n("&View"), viewMenu ); |
2216 | mb->insertItem( i18n("&Settings"), settingsMenu ); | 2265 | mb->insertItem( i18n("&Settings"), settingsMenu ); |
2217 | #ifdef DESKTOP_VERSION | 2266 | #ifdef DESKTOP_VERSION |
2218 | mb->insertItem( i18n("Synchronize"), syncMenu ); | 2267 | mb->insertItem( i18n("Synchronize"), syncMenu ); |
2219 | #else | 2268 | #else |
2220 | mb->insertItem( i18n("Sync"), syncMenu ); | 2269 | mb->insertItem( i18n("Sync"), syncMenu ); |
2221 | #endif | 2270 | #endif |
2222 | //mb->insertItem( i18n("&Change"), changeMenu ); | 2271 | //mb->insertItem( i18n("&Change"), changeMenu ); |
2223 | mb->insertItem( i18n("&Help"), helpMenu ); | 2272 | mb->insertItem( i18n("&Help"), helpMenu ); |
2224 | mIncSearchWidget = new IncSearchWidget( tb ); | 2273 | mIncSearchWidget = new IncSearchWidget( tb ); |
2225 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 2274 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
2226 | #ifndef DESKTOP_VERSION | 2275 | #ifndef DESKTOP_VERSION |
2227 | } else { | 2276 | } else { |
2228 | //US setup toolbar | 2277 | //US setup toolbar |
2229 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 2278 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
2230 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 2279 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
2231 | menuBarTB->insertItem( SmallIcon( "z_menu" ) , popupBarTB); | 2280 | menuBarTB->insertItem( SmallIcon( "z_menu" ) , popupBarTB); |
2232 | tb->insertWidget(-1, 0, menuBarTB); | 2281 | tb->insertWidget(-1, 0, menuBarTB); |
2233 | mIncSearchWidget = new IncSearchWidget( tb ); | 2282 | mIncSearchWidget = new IncSearchWidget( tb ); |
2234 | tb->enableMoving(false); | 2283 | tb->enableMoving(false); |
2235 | popupBarTB->insertItem( i18n("&File"), fileMenu ); | 2284 | popupBarTB->insertItem( i18n("&File"), fileMenu ); |
2236 | popupBarTB->insertItem( i18n("&Edit"), editMenu ); | 2285 | popupBarTB->insertItem( i18n("&Edit"), editMenu ); |
2237 | popupBarTB->insertItem( i18n("&View"), viewMenu ); | 2286 | popupBarTB->insertItem( i18n("&View"), viewMenu ); |
2238 | popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); | 2287 | popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); |
2239 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); | 2288 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); |
2240 | mViewManager->getFilterAction()->plug ( popupBarTB); | 2289 | mViewManager->getFilterAction()->plug ( popupBarTB); |
2241 | //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); | 2290 | //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); |
2242 | popupBarTB->insertItem( i18n("&Help"), helpMenu ); | 2291 | popupBarTB->insertItem( i18n("&Help"), helpMenu ); |
2243 | if (QApplication::desktop()->width() > 320 ) { | 2292 | if (QApplication::desktop()->width() > 320 ) { |
2244 | // mViewManager->getFilterAction()->plug ( tb); | 2293 | // mViewManager->getFilterAction()->plug ( tb); |
2245 | } | 2294 | } |
2246 | } | 2295 | } |
2247 | #endif | 2296 | #endif |
2248 | mIncSearchWidget->setSize(); | 2297 | mIncSearchWidget->setSize(); |
2249 | // mActionQuit->plug ( mMainWindow->toolBar()); | 2298 | // mActionQuit->plug ( mMainWindow->toolBar()); |
2250 | 2299 | ||
2251 | 2300 | ||
2252 | 2301 | ||
2253 | //US Now connect the actions with the menue entries. | 2302 | //US Now connect the actions with the menue entries. |
2254 | #ifdef DESKTOP_VERSION | 2303 | #ifdef DESKTOP_VERSION |
2255 | mActionPrint->plug( fileMenu ); | 2304 | mActionPrint->plug( fileMenu ); |
2256 | mActionPrintDetails->plug( fileMenu ); | 2305 | mActionPrintDetails->plug( fileMenu ); |
2257 | fileMenu->insertSeparator(); | 2306 | fileMenu->insertSeparator(); |
2258 | #endif | 2307 | #endif |
2259 | mActionMail->plug( fileMenu ); | 2308 | mActionMail->plug( fileMenu ); |
2260 | fileMenu->insertSeparator(); | 2309 | fileMenu->insertSeparator(); |
2261 | 2310 | ||
2262 | mActionNewContact->plug( editMenu ); | 2311 | mActionNewContact->plug( editMenu ); |
2263 | mActionNewContact->plug( tb ); | 2312 | mActionNewContact->plug( tb ); |
2264 | 2313 | ||
2265 | mActionEditAddressee->plug( editMenu ); | 2314 | mActionEditAddressee->plug( editMenu ); |
2266 | editMenu->insertSeparator(); | 2315 | editMenu->insertSeparator(); |
2267 | // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 2316 | // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
2268 | // (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 2317 | // (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
2269 | mActionEditAddressee->plug( tb ); | 2318 | mActionEditAddressee->plug( tb ); |
2270 | 2319 | ||
2271 | // fileMenu->insertSeparator(); | 2320 | // fileMenu->insertSeparator(); |
2272 | mActionSave->plug( fileMenu ); | 2321 | mActionSave->plug( fileMenu ); |
2273 | fileMenu->insertItem( "&Import", ImportMenu ); | 2322 | fileMenu->insertItem( "&Import", ImportMenu ); |
2274 | fileMenu->insertItem( "&Export", ExportMenu ); | 2323 | fileMenu->insertItem( "&Export", ExportMenu ); |
2275 | editMenu->insertItem( i18n("&Change"), changeMenu ); | 2324 | editMenu->insertItem( i18n("&Change"), changeMenu ); |
2276 | editMenu->insertSeparator(); | 2325 | editMenu->insertSeparator(); |
2277 | #ifndef DESKTOP_VERSION | 2326 | #ifndef DESKTOP_VERSION |
2278 | if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); | 2327 | if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); |
2279 | #endif | 2328 | #endif |
2280 | #if 0 | 2329 | #if 0 |
2281 | // PENDING fix MailVCard | 2330 | // PENDING fix MailVCard |
2282 | fileMenu->insertSeparator(); | 2331 | fileMenu->insertSeparator(); |
2283 | mActionMailVCard->plug( fileMenu ); | 2332 | mActionMailVCard->plug( fileMenu ); |
2284 | #endif | 2333 | #endif |
2285 | #ifndef DESKTOP_VERSION | 2334 | #ifndef DESKTOP_VERSION |
2286 | if ( Ir::supported() ) mActionBR->plug( beamMenu ); | 2335 | if ( Ir::supported() ) mActionBR->plug( beamMenu ); |
2287 | if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); | 2336 | if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); |
2288 | if ( Ir::supported() ) mActionBeam->plug( beamMenu ); | 2337 | if ( Ir::supported() ) mActionBeam->plug( beamMenu ); |
2289 | #endif | 2338 | #endif |
2290 | fileMenu->insertSeparator(); | 2339 | fileMenu->insertSeparator(); |
2291 | mActionQuit->plug( fileMenu ); | 2340 | mActionQuit->plug( fileMenu ); |
2292 | #ifdef _OL_IMPORT_ | 2341 | #ifdef _OL_IMPORT_ |
2293 | mActionImportOL->plug( ImportMenu ); | 2342 | mActionImportOL->plug( ImportMenu ); |
2294 | #endif | 2343 | #endif |
2295 | // edit menu | 2344 | // edit menu |
2296 | mActionUndo->plug( editMenu ); | 2345 | mActionUndo->plug( editMenu ); |
2297 | mActionRedo->plug( editMenu ); | 2346 | mActionRedo->plug( editMenu ); |
2298 | editMenu->insertSeparator(); | 2347 | editMenu->insertSeparator(); |
2299 | mActionCut->plug( editMenu ); | 2348 | mActionCut->plug( editMenu ); |
2300 | mActionCopy->plug( editMenu ); | 2349 | mActionCopy->plug( editMenu ); |
2301 | mActionPaste->plug( editMenu ); | 2350 | mActionPaste->plug( editMenu ); |
2302 | mActionDelete->plug( editMenu ); | 2351 | mActionDelete->plug( editMenu ); |
2303 | editMenu->insertSeparator(); | 2352 | editMenu->insertSeparator(); |
2304 | mActionSelectAll->plug( editMenu ); | 2353 | mActionSelectAll->plug( editMenu ); |
2305 | 2354 | ||
2306 | mActionSetFormattedName->plug( changeMenu ); | 2355 | mActionSetFormattedName->plug( changeMenu ); |
2307 | mActionRemoveVoice->plug( changeMenu ); | 2356 | mActionRemoveVoice->plug( changeMenu ); |
2308 | // settingsmings menu | 2357 | // settingsmings menu |
2309 | //US special menuentry to configure the addressbook resources. On KDE | 2358 | //US special menuentry to configure the addressbook resources. On KDE |
2310 | // you do that through the control center !!! | 2359 | // you do that through the control center !!! |
2311 | // settingsMenu->insertSeparator(); | 2360 | // settingsMenu->insertSeparator(); |
2312 | 2361 | ||
2313 | mActionConfigKAddressbook->plug( settingsMenu, 0 ); | 2362 | mActionConfigKAddressbook->plug( settingsMenu, 0 ); |
2314 | mActionConfigGlobal->plug( settingsMenu, 1 ); | 2363 | mActionConfigGlobal->plug( settingsMenu, 1 ); |
2315 | mActionConfigResources->plug( settingsMenu,2 ); | 2364 | mActionConfigResources->plug( settingsMenu,2 ); |
2316 | settingsMenu->insertSeparator(3); | 2365 | settingsMenu->insertSeparator(3); |
2317 | 2366 | ||
2318 | if ( mIsPart ) { | 2367 | if ( mIsPart ) { |
2319 | //US not implemented yet | 2368 | //US not implemented yet |
2320 | //mActionConfigShortcuts->plug( settingsMenu ); | 2369 | //mActionConfigShortcuts->plug( settingsMenu ); |
2321 | //mActionConfigureToolbars->plug( settingsMenu ); | 2370 | //mActionConfigureToolbars->plug( settingsMenu ); |
2322 | 2371 | ||
2323 | } else { | 2372 | } else { |
2324 | //US not implemented yet | 2373 | //US not implemented yet |
2325 | //mActionKeyBindings->plug( settingsMenu ); | 2374 | //mActionKeyBindings->plug( settingsMenu ); |
2326 | } | 2375 | } |
2327 | 2376 | ||
2328 | mActionEditCategories->plug( settingsMenu ); | 2377 | mActionEditCategories->plug( settingsMenu ); |
2329 | mActionManageCategories->plug( settingsMenu ); | 2378 | mActionManageCategories->plug( settingsMenu ); |
2330 | mActionJumpBar->plug( viewMenu,0 ); | 2379 | mActionJumpBar->plug( viewMenu,0 ); |
2331 | mActionDetails->plug( viewMenu,0 ); | 2380 | mActionDetails->plug( viewMenu,0 ); |
2332 | //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 2381 | //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
2333 | mActionDetails->plug( tb ); | 2382 | mActionDetails->plug( tb ); |
2334 | settingsMenu->insertSeparator(); | 2383 | settingsMenu->insertSeparator(); |
2335 | #ifndef DESKTOP_VERSION | 2384 | #ifndef DESKTOP_VERSION |
2336 | if ( Ir::supported() ) mActionBR->plug(settingsMenu ); | 2385 | if ( Ir::supported() ) mActionBR->plug(settingsMenu ); |
2337 | settingsMenu->insertSeparator(); | 2386 | settingsMenu->insertSeparator(); |
2338 | #endif | 2387 | #endif |
2339 | 2388 | ||
2340 | mActionWhoAmI->plug( settingsMenu ); | 2389 | mActionWhoAmI->plug( settingsMenu ); |
2341 | //mActionEditCategories->plug( changeMenu ); | 2390 | //mActionEditCategories->plug( changeMenu ); |
2342 | mActionCategories->plug( changeMenu ); | 2391 | mActionCategories->plug( changeMenu ); |
2343 | //mActionManageCategories->plug( changeMenu ); | 2392 | //mActionManageCategories->plug( changeMenu ); |
2344 | 2393 | ||
2345 | //mActionCategories->plug( settingsMenu ); | 2394 | //mActionCategories->plug( settingsMenu ); |
2346 | 2395 | ||
2347 | 2396 | ||
2348 | mActionWN->plug( helpMenu ); | 2397 | mActionWN->plug( helpMenu ); |
2349 | mActionStorageHowto->plug( helpMenu ); | 2398 | mActionStorageHowto->plug( helpMenu ); |
2350 | mActionSyncHowto->plug( helpMenu ); | 2399 | mActionSyncHowto->plug( helpMenu ); |
2351 | mActionKdeSyncHowto->plug( helpMenu ); | 2400 | mActionKdeSyncHowto->plug( helpMenu ); |
2352 | mActionMultiSyncHowto->plug( helpMenu ); | 2401 | mActionMultiSyncHowto->plug( helpMenu ); |
2353 | mActionFaq->plug( helpMenu ); | 2402 | mActionFaq->plug( helpMenu ); |
2354 | mActionLicence->plug( helpMenu ); | 2403 | mActionLicence->plug( helpMenu ); |
2355 | mActionAboutKAddressbook->plug( helpMenu ); | 2404 | mActionAboutKAddressbook->plug( helpMenu ); |
2356 | 2405 | ||
2357 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 2406 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
2358 | 2407 | ||
2359 | mActionSave->plug( tb ); | 2408 | mActionSave->plug( tb ); |
2360 | mViewManager->getFilterAction()->plug ( tb); | 2409 | mViewManager->getFilterAction()->plug ( tb); |
2361 | //LR hide filteraction on started in 480x640 | 2410 | //LR hide filteraction on started in 480x640 |
2362 | if (QApplication::desktop()->width() == 480 ) { | 2411 | if (QApplication::desktop()->width() == 480 ) { |
2363 | mViewManager->getFilterAction()->setComboWidth( 0 ); | 2412 | mViewManager->getFilterAction()->setComboWidth( 0 ); |
2364 | } | 2413 | } |
2365 | mActionUndo->plug( tb ); | 2414 | mActionUndo->plug( tb ); |
2366 | mActionDelete->plug( tb ); | 2415 | mActionDelete->plug( tb ); |
2367 | mActionRedo->plug( tb ); | 2416 | mActionRedo->plug( tb ); |
2368 | } else { | 2417 | } else { |
2369 | mActionSave->plug( tb ); | 2418 | mActionSave->plug( tb ); |
2370 | tb->enableMoving(false); | 2419 | tb->enableMoving(false); |
2371 | } | 2420 | } |
2372 | //mActionQuit->plug ( tb ); | 2421 | //mActionQuit->plug ( tb ); |
2373 | //tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 2422 | //tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
2374 | 2423 | ||
2375 | //US link the searchwidget first to this. | 2424 | //US link the searchwidget first to this. |
2376 | // The real linkage to the toolbar happens later. | 2425 | // The real linkage to the toolbar happens later. |
2377 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 2426 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
2378 | //US tb->insertItem( mIncSearchWidget ); | 2427 | //US tb->insertItem( mIncSearchWidget ); |
2379 | /*US | 2428 | /*US |
2380 | mIncSearchWidget = new IncSearchWidget( tb ); | 2429 | mIncSearchWidget = new IncSearchWidget( tb ); |
2381 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 2430 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
2382 | SLOT( incrementalSearch( const QString& ) ) ); | 2431 | SLOT( incrementalSearch( const QString& ) ) ); |
2383 | 2432 | ||
2384 | mJumpButtonBar = new JumpButtonBar( this, this ); | 2433 | mJumpButtonBar = new JumpButtonBar( this, this ); |
2385 | 2434 | ||
2386 | //US topLayout->addWidget( mJumpButtonBar ); | 2435 | //US topLayout->addWidget( mJumpButtonBar ); |
2387 | this->layout()->add( mJumpButtonBar ); | 2436 | this->layout()->add( mJumpButtonBar ); |
2388 | */ | 2437 | */ |
2389 | 2438 | ||
2390 | #endif //KAB_EMBEDDED | 2439 | #endif //KAB_EMBEDDED |
2391 | 2440 | ||
2392 | mActionExport2phone->plug( ExportMenu ); | 2441 | mActionExport2phone->plug( ExportMenu ); |
2393 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 2442 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
2394 | syncManager->fillSyncMenu(); | 2443 | syncManager->fillSyncMenu(); |
2395 | 2444 | ||
2396 | } | 2445 | } |
2397 | void KABCore::showLicence() | 2446 | void KABCore::showLicence() |
2398 | { | 2447 | { |
2399 | KApplication::showLicence(); | 2448 | KApplication::showLicence(); |
2400 | } | 2449 | } |
2401 | 2450 | ||
2402 | void KABCore::manageCategories( ) | 2451 | void KABCore::manageCategories( ) |
2403 | { | 2452 | { |
2404 | KABCatPrefs* cp = new KABCatPrefs(); | 2453 | KABCatPrefs* cp = new KABCatPrefs(); |
2405 | cp->show(); | 2454 | cp->show(); |
2406 | int w =cp->sizeHint().width() ; | 2455 | int w =cp->sizeHint().width() ; |
2407 | int h = cp->sizeHint().height() ; | 2456 | int h = cp->sizeHint().height() ; |
2408 | int dw = QApplication::desktop()->width(); | 2457 | int dw = QApplication::desktop()->width(); |
2409 | int dh = QApplication::desktop()->height(); | 2458 | int dh = QApplication::desktop()->height(); |
2410 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2459 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2411 | if ( !cp->exec() ) { | 2460 | if ( !cp->exec() ) { |
2412 | delete cp; | 2461 | delete cp; |
2413 | return; | 2462 | return; |
2414 | } | 2463 | } |
2415 | int count = 0; | 2464 | int count = 0; |
2416 | int cc = 0; | 2465 | int cc = 0; |
2417 | message( i18n("Please wait, processing categories...")); | 2466 | message( i18n("Please wait, processing categories...")); |
2418 | if ( cp->addCat() ) { | 2467 | if ( cp->addCat() ) { |
2419 | KABC::AddressBook::Iterator it; | 2468 | KABC::AddressBook::Iterator it; |
2420 | QStringList catList = KABPrefs::instance()->mCustomCategories; | 2469 | QStringList catList = KABPrefs::instance()->mCustomCategories; |
2421 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2470 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2422 | ++cc; | 2471 | ++cc; |
2423 | if ( cc %10 == 0) | 2472 | if ( cc %10 == 0) |
2424 | message(i18n("Processing contact #%1").arg(cc)); | 2473 | message(i18n("Processing contact #%1").arg(cc)); |
2425 | QStringList catIncList = (*it).categories(); | 2474 | QStringList catIncList = (*it).categories(); |
2426 | int i; | 2475 | int i; |
2427 | for( i = 0; i< catIncList.count(); ++i ) { | 2476 | for( i = 0; i< catIncList.count(); ++i ) { |
2428 | if ( !catList.contains (catIncList[i])) { | 2477 | if ( !catList.contains (catIncList[i])) { |
2429 | catList.append( catIncList[i] ); | 2478 | catList.append( catIncList[i] ); |
2430 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2479 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2431 | ++count; | 2480 | ++count; |
2432 | } | 2481 | } |
2433 | } | 2482 | } |
2434 | } | 2483 | } |
2435 | catList.sort(); | 2484 | catList.sort(); |
2436 | KABPrefs::instance()->mCustomCategories = catList; | 2485 | KABPrefs::instance()->mCustomCategories = catList; |
2437 | KABPrefs::instance()->writeConfig(); | 2486 | KABPrefs::instance()->writeConfig(); |
2438 | message(QString::number( count )+ i18n(" categories added to list! ")); | 2487 | message(QString::number( count )+ i18n(" categories added to list! ")); |
2439 | } else { | 2488 | } else { |
2440 | QStringList catList = KABPrefs::instance()->mCustomCategories; | 2489 | QStringList catList = KABPrefs::instance()->mCustomCategories; |
2441 | QStringList catIncList; | 2490 | QStringList catIncList; |
2442 | QStringList newCatList; | 2491 | QStringList newCatList; |
2443 | KABC::AddressBook::Iterator it; | 2492 | KABC::AddressBook::Iterator it; |
2444 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2493 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2445 | ++cc; | 2494 | ++cc; |
2446 | if ( cc %10 == 0) | 2495 | if ( cc %10 == 0) |
2447 | message(i18n("Processing contact #%1").arg(cc)); | 2496 | message(i18n("Processing contact #%1").arg(cc)); |
2448 | QStringList catIncList = (*it).categories(); | 2497 | QStringList catIncList = (*it).categories(); |
2449 | int i; | 2498 | int i; |
2450 | if ( catIncList.count() ) { | 2499 | if ( catIncList.count() ) { |
2451 | newCatList.clear(); | 2500 | newCatList.clear(); |
2452 | for( i = 0; i< catIncList.count(); ++i ) { | 2501 | for( i = 0; i< catIncList.count(); ++i ) { |
2453 | if ( catList.contains (catIncList[i])) { | 2502 | if ( catList.contains (catIncList[i])) { |
2454 | newCatList.append( catIncList[i] ); | 2503 | newCatList.append( catIncList[i] ); |
2455 | } | 2504 | } |
2456 | } | 2505 | } |
2457 | newCatList.sort(); | 2506 | newCatList.sort(); |
2458 | (*it).setCategories( newCatList ); | 2507 | (*it).setCategories( newCatList ); |
2459 | mAddressBook->insertAddressee( (*it) ); | 2508 | mAddressBook->insertAddressee( (*it) ); |
2460 | } | 2509 | } |
2461 | } | 2510 | } |
2462 | setModified( true ); | 2511 | setModified( true ); |
2463 | mViewManager->refreshView(); | 2512 | mViewManager->refreshView(); |
2464 | message( i18n("Removing categories done!")); | 2513 | message( i18n("Removing categories done!")); |
2465 | } | 2514 | } |
2466 | delete cp; | 2515 | delete cp; |
2467 | } | 2516 | } |
2468 | void KABCore::removeVoice() | 2517 | void KABCore::removeVoice() |
2469 | { | 2518 | { |
2470 | 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 ) | 2519 | 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 ) |
2471 | return; | 2520 | return; |
2472 | XXPortSelectDialog dlg( this, false, this ); | 2521 | XXPortSelectDialog dlg( this, false, this ); |
2473 | if ( !dlg.exec() ) | 2522 | if ( !dlg.exec() ) |
2474 | return; | 2523 | return; |
2475 | mAddressBook->setUntagged(); | 2524 | mAddressBook->setUntagged(); |
2476 | dlg.tagSelected(); | 2525 | dlg.tagSelected(); |
2477 | message(i18n("Removing voice..."), false ); | 2526 | message(i18n("Removing voice..."), false ); |
2478 | KABC::AddressBook::Iterator it; | 2527 | KABC::AddressBook::Iterator it; |
2479 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2528 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2480 | if ( (*it).tagged() ) { | 2529 | if ( (*it).tagged() ) { |
2481 | (*it).removeVoice(); | 2530 | (*it).removeVoice(); |
2482 | } | 2531 | } |
2483 | } | 2532 | } |
2484 | message(i18n("Refreshing view...") ); | 2533 | message(i18n("Refreshing view...") ); |
2485 | mViewManager->refreshView( "" ); | 2534 | mViewManager->refreshView( "" ); |
2486 | Addressee add; | 2535 | Addressee add; |
2487 | mDetails->setAddressee( add ); | 2536 | mDetails->setAddressee( add ); |
2488 | message(i18n("Remove voice completed!") ); | 2537 | message(i18n("Remove voice completed!") ); |
2489 | 2538 | ||
2490 | 2539 | ||
2491 | 2540 | ||
2492 | } | 2541 | } |
2493 | 2542 | ||
2494 | void KABCore::setFormattedName() | 2543 | void KABCore::setFormattedName() |
2495 | { | 2544 | { |
2496 | KABFormatPrefs setpref; | 2545 | KABFormatPrefs setpref; |
2497 | if ( !setpref.exec() ) { | 2546 | if ( !setpref.exec() ) { |
2498 | return; | 2547 | return; |
2499 | } | 2548 | } |
2500 | XXPortSelectDialog dlg( this, false, this ); | 2549 | XXPortSelectDialog dlg( this, false, this ); |
2501 | if ( !dlg.exec() ) | 2550 | if ( !dlg.exec() ) |
2502 | return; | 2551 | return; |
2503 | mAddressBook->setUntagged(); | 2552 | mAddressBook->setUntagged(); |
2504 | dlg.tagSelected(); | 2553 | dlg.tagSelected(); |
2505 | int count = 0; | 2554 | int count = 0; |
2506 | KABC::AddressBook::Iterator it; | 2555 | KABC::AddressBook::Iterator it; |
2507 | bool modified = false; | 2556 | bool modified = false; |
2508 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2557 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2509 | if ( (*it).tagged() ) { | 2558 | if ( (*it).tagged() ) { |
2510 | if ( (*it).uid().left( 2 ) == "la" ) | 2559 | if ( (*it).uid().left( 2 ) == "la" ) |
2511 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) | 2560 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) |
2512 | continue; | 2561 | continue; |
2513 | ++count; | 2562 | ++count; |
2514 | if ( count %10 == 0 ) | 2563 | if ( count %10 == 0 ) |
2515 | message(i18n("Changing contact #%1").arg( count ) ); | 2564 | message(i18n("Changing contact #%1").arg( count ) ); |
2516 | QString fName; | 2565 | QString fName; |
2517 | if ( setpref.simple->isChecked() ) | 2566 | if ( setpref.simple->isChecked() ) |
2518 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); | 2567 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); |
2519 | else if ( setpref.full->isChecked() ) | 2568 | else if ( setpref.full->isChecked() ) |
2520 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); | 2569 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); |
2521 | else if ( setpref.reverse->isChecked() ) | 2570 | else if ( setpref.reverse->isChecked() ) |
2522 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); | 2571 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); |
2523 | else | 2572 | else |
2524 | fName = (*it).organization(); | 2573 | fName = (*it).organization(); |
2525 | if ( setpref.setCompany->isChecked() ) | 2574 | if ( setpref.setCompany->isChecked() ) |
2526 | if ( fName.isEmpty() || fName =="," ) | 2575 | if ( fName.isEmpty() || fName =="," ) |
2527 | fName = (*it).organization(); | 2576 | fName = (*it).organization(); |
2528 | (*it).setFormattedName( fName ); | 2577 | (*it).setFormattedName( fName ); |
2529 | (*it).setChanged( true ); | 2578 | (*it).setChanged( true ); |
2530 | modified = true; | 2579 | modified = true; |
2531 | (*it).setRevision( QDateTime::currentDateTime() ); | 2580 | (*it).setRevision( QDateTime::currentDateTime() ); |
2532 | } | 2581 | } |
2533 | } | 2582 | } |
2534 | message(i18n("Refreshing view...") ); | 2583 | message(i18n("Refreshing view...") ); |
2535 | if ( modified ) | 2584 | if ( modified ) |
2536 | setModified( true ); | 2585 | setModified( true ); |
2537 | Addressee add; | 2586 | Addressee add; |
2538 | mDetails->setAddressee( add ); | 2587 | mDetails->setAddressee( add ); |
2539 | if ( count == 0 ) | 2588 | if ( count == 0 ) |
2540 | message(i18n("No contact changed!") ); | 2589 | message(i18n("No contact changed!") ); |
2541 | else | 2590 | else |
2542 | message(i18n("%1 contacts changed!").arg( count ) ); | 2591 | message(i18n("%1 contacts changed!").arg( count ) ); |
2543 | } | 2592 | } |
2544 | 2593 | ||
2545 | void KABCore::clipboardDataChanged() | 2594 | void KABCore::clipboardDataChanged() |
2546 | { | 2595 | { |
2547 | 2596 | ||
2548 | if ( mReadWrite ) | 2597 | if ( mReadWrite ) |
2549 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 2598 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
2550 | 2599 | ||
2551 | } | 2600 | } |
2552 | 2601 | ||
2553 | void KABCore::updateActionMenu() | 2602 | void KABCore::updateActionMenu() |
2554 | { | 2603 | { |
2555 | UndoStack *undo = UndoStack::instance(); | 2604 | UndoStack *undo = UndoStack::instance(); |
2556 | RedoStack *redo = RedoStack::instance(); | 2605 | RedoStack *redo = RedoStack::instance(); |
2557 | 2606 | ||
2558 | if ( undo->isEmpty() ) | 2607 | if ( undo->isEmpty() ) |
2559 | mActionUndo->setText( i18n( "Undo" ) ); | 2608 | mActionUndo->setText( i18n( "Undo" ) ); |
2560 | else | 2609 | else |
2561 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 2610 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
2562 | 2611 | ||
2563 | mActionUndo->setEnabled( !undo->isEmpty() ); | 2612 | mActionUndo->setEnabled( !undo->isEmpty() ); |
2564 | 2613 | ||
2565 | if ( !redo->top() ) | 2614 | if ( !redo->top() ) |
2566 | mActionRedo->setText( i18n( "Redo" ) ); | 2615 | mActionRedo->setText( i18n( "Redo" ) ); |
2567 | else | 2616 | else |
2568 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 2617 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
2569 | 2618 | ||
2570 | mActionRedo->setEnabled( !redo->isEmpty() ); | 2619 | mActionRedo->setEnabled( !redo->isEmpty() ); |
2571 | } | 2620 | } |
2572 | 2621 | ||
2573 | void KABCore::configureKeyBindings() | 2622 | void KABCore::configureKeyBindings() |
2574 | { | 2623 | { |
2575 | #ifndef KAB_EMBEDDED | 2624 | #ifndef KAB_EMBEDDED |
2576 | KKeyDialog::configure( actionCollection(), true ); | 2625 | KKeyDialog::configure( actionCollection(), true ); |
2577 | #else //KAB_EMBEDDED | 2626 | #else //KAB_EMBEDDED |
2578 | qDebug("KABCore::configureKeyBindings() not implemented"); | 2627 | qDebug("KABCore::configureKeyBindings() not implemented"); |
2579 | #endif //KAB_EMBEDDED | 2628 | #endif //KAB_EMBEDDED |
2580 | } | 2629 | } |
2581 | 2630 | ||
2582 | #ifdef KAB_EMBEDDED | 2631 | #ifdef KAB_EMBEDDED |
2583 | void KABCore::configureResources() | 2632 | void KABCore::configureResources() |
2584 | { | 2633 | { |
2585 | KRES::KCMKResources dlg( this, "" , 0 ); | 2634 | KRES::KCMKResources dlg( this, "" , 0 ); |
2586 | 2635 | ||
2587 | if ( !dlg.exec() ) | 2636 | if ( !dlg.exec() ) |
2588 | return; | 2637 | return; |
2589 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 2638 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
2590 | } | 2639 | } |
2591 | #endif //KAB_EMBEDDED | 2640 | #endif //KAB_EMBEDDED |
2592 | 2641 | ||
2593 | 2642 | ||
2594 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 2643 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
2595 | * for the attendees list of an event. | 2644 | * for the attendees list of an event. |
2596 | */ | 2645 | */ |
2597 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 2646 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
2598 | { | 2647 | { |
2599 | qDebug("KABCore::requestForNameEmailUidList "); | 2648 | qDebug("KABCore::requestForNameEmailUidList "); |
2600 | bool ok = false; | 2649 | bool ok = false; |
2601 | mEmailSourceChannel = sourceChannel; | 2650 | mEmailSourceChannel = sourceChannel; |
2602 | mEmailSourceUID = uid; | 2651 | mEmailSourceUID = uid; |
2603 | QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) ); | 2652 | QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) ); |
2604 | //callContactdialog(); | 2653 | //callContactdialog(); |
2605 | #if 0 | 2654 | #if 0 |
2606 | int wid = uid.toInt( &ok ); | 2655 | int wid = uid.toInt( &ok ); |
2607 | qDebug("UID %s ", uid.latin1()); | 2656 | qDebug("UID %s ", uid.latin1()); |
2608 | if ( ok ) { | 2657 | if ( ok ) { |
2609 | if ( wid != QApplication::desktop()->width() ) { | 2658 | if ( wid != QApplication::desktop()->width() ) { |
2610 | qDebug("KA/Pi: Request from different desktop geometry. Resizing ..."); | 2659 | qDebug("KA/Pi: Request from different desktop geometry. Resizing ..."); |
2611 | message( i18n("Resizing, please wait...") ); | 2660 | message( i18n("Resizing, please wait...") ); |
2612 | mMainWindow->showMinimized(); | 2661 | mMainWindow->showMinimized(); |
2613 | /* | 2662 | /* |
2614 | { | 2663 | { |
2615 | QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); | 2664 | QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); |
2616 | } | 2665 | } |
2617 | */ | 2666 | */ |
2618 | QTimer::singleShot( 1,this, SLOT ( resizeAndCallContactdialog() ) ); | 2667 | QTimer::singleShot( 1,this, SLOT ( resizeAndCallContactdialog() ) ); |
2619 | return; | 2668 | return; |
2620 | } | 2669 | } |
2621 | 2670 | ||
2622 | } else { | 2671 | } else { |
2623 | qDebug("KABCore::requestForNameEmailUidList:: Got invalid uid "); | 2672 | qDebug("KABCore::requestForNameEmailUidList:: Got invalid uid "); |
2624 | } | 2673 | } |
2625 | callContactdialog(); | 2674 | callContactdialog(); |
2626 | //QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); | 2675 | //QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); |
2627 | #endif | 2676 | #endif |
2628 | } | 2677 | } |
2629 | void KABCore::resizeAndCallContactdialog() | 2678 | void KABCore::resizeAndCallContactdialog() |
2630 | { | 2679 | { |
2631 | updateMainWindow(); | 2680 | updateMainWindow(); |
2632 | QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) ); | 2681 | QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) ); |
2633 | } | 2682 | } |
2634 | 2683 | ||
2635 | void KABCore::doRingSync() | 2684 | void KABCore::doRingSync() |
2636 | { | 2685 | { |
2637 | topLevelWidget()->raise(); | 2686 | topLevelWidget()->raise(); |
2638 | syncManager->multiSync( false ); | 2687 | syncManager->multiSync( false ); |
2639 | } | 2688 | } |
2640 | void KABCore::callContactdialog() | 2689 | void KABCore::callContactdialog() |
2641 | { | 2690 | { |
2642 | static bool running = false; | 2691 | static bool running = false; |
2643 | if (running) return; | 2692 | if (running) return; |
2644 | running = true; | 2693 | running = true; |
2645 | QStringList nameList; | 2694 | QStringList nameList; |
2646 | QStringList emailList; | 2695 | QStringList emailList; |
2647 | QStringList uidList; | 2696 | QStringList uidList; |
2648 | qDebug(" KABCore::callContactdialog:DESKTOP WIDTH %d ", QApplication::desktop()->width() ); | 2697 | qDebug(" KABCore::callContactdialog:DESKTOP WIDTH %d ", QApplication::desktop()->width() ); |
2649 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 2698 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
2650 | uint i=0; | 2699 | uint i=0; |
2651 | for (i=0; i < list.count(); i++) | 2700 | for (i=0; i < list.count(); i++) |
2652 | { | 2701 | { |
2653 | nameList.append(list[i].realName()); | 2702 | nameList.append(list[i].realName()); |
2654 | emailList.append(list[i].preferredEmail()); | 2703 | emailList.append(list[i].preferredEmail()); |
2655 | uidList.append(list[i].uid()); | 2704 | uidList.append(list[i].uid()); |
2656 | } | 2705 | } |
2657 | QString uid = mEmailSourceUID; | 2706 | QString uid = mEmailSourceUID; |
2658 | //qDebug("%s %s ", sourceChannel.latin1(), uid.latin1()); | 2707 | //qDebug("%s %s ", sourceChannel.latin1(), uid.latin1()); |
2659 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(mEmailSourceChannel, uid, nameList, emailList, uidList); | 2708 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(mEmailSourceChannel, uid, nameList, emailList, uidList); |
2660 | running = false; | 2709 | running = false; |
2661 | } | 2710 | } |
2662 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays | 2711 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays |
2663 | * to put them into the calendar. | 2712 | * to put them into the calendar. |
2664 | */ | 2713 | */ |
2665 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) | 2714 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) |
2666 | { | 2715 | { |
2667 | // qDebug("KABCore::requestForBirthdayList"); | 2716 | // qDebug("KABCore::requestForBirthdayList"); |
2668 | QStringList birthdayList; | 2717 | QStringList birthdayList; |
2669 | QStringList anniversaryList; | 2718 | QStringList anniversaryList; |
2670 | QStringList realNameList; | 2719 | QStringList realNameList; |
2671 | QStringList preferredEmailList; | 2720 | QStringList preferredEmailList; |
2672 | QStringList assembledNameList; | 2721 | QStringList assembledNameList; |
2673 | QStringList uidList; | 2722 | QStringList uidList; |
2674 | 2723 | ||
2675 | KABC::AddressBook::Iterator it; | 2724 | KABC::AddressBook::Iterator it; |
2676 | 2725 | ||
2677 | int count = 0; | 2726 | int count = 0; |
2678 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2727 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2679 | ++count; | 2728 | ++count; |
2680 | } | 2729 | } |
2681 | QProgressBar bar(count,0 ); | 2730 | QProgressBar bar(count,0 ); |
2682 | int w = 300; | 2731 | int w = 300; |
2683 | if ( QApplication::desktop()->width() < 320 ) | 2732 | if ( QApplication::desktop()->width() < 320 ) |
2684 | w = 220; | 2733 | w = 220; |
2685 | int h = bar.sizeHint().height() ; | 2734 | int h = bar.sizeHint().height() ; |
2686 | int dw = QApplication::desktop()->width(); | 2735 | int dw = QApplication::desktop()->width(); |
2687 | int dh = QApplication::desktop()->height(); | 2736 | int dh = QApplication::desktop()->height(); |
2688 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2737 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2689 | bar.show(); | 2738 | bar.show(); |
2690 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); | 2739 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); |
2691 | qApp->processEvents(); | 2740 | qApp->processEvents(); |
2692 | 2741 | ||
2693 | QDate bday; | 2742 | QDate bday; |
2694 | QString anni; | 2743 | QString anni; |
2695 | QString formattedbday; | 2744 | QString formattedbday; |
2696 | 2745 | ||
2697 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) | 2746 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) |
2698 | { | 2747 | { |
2699 | if ( ! bar.isVisible() ) | 2748 | if ( ! bar.isVisible() ) |
2700 | return; | 2749 | return; |
2701 | bar.setProgress( count++ ); | 2750 | bar.setProgress( count++ ); |
2702 | qApp->processEvents(); | 2751 | qApp->processEvents(); |
2703 | bday = (*it).birthday().date(); | 2752 | bday = (*it).birthday().date(); |
2704 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); | 2753 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); |
2705 | 2754 | ||
2706 | if ( bday.isValid() || !anni.isEmpty()) | 2755 | if ( bday.isValid() || !anni.isEmpty()) |
2707 | { | 2756 | { |
2708 | if (bday.isValid()) | 2757 | if (bday.isValid()) |
2709 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); | 2758 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); |
2710 | else | 2759 | else |
2711 | formattedbday = "NOTVALID"; | 2760 | formattedbday = "NOTVALID"; |
2712 | if (anni.isEmpty()) | 2761 | if (anni.isEmpty()) |
2713 | anni = "INVALID"; | 2762 | anni = "INVALID"; |
2714 | 2763 | ||
2715 | birthdayList.append(formattedbday); | 2764 | birthdayList.append(formattedbday); |
2716 | anniversaryList.append(anni); //should be ISODate | 2765 | anniversaryList.append(anni); //should be ISODate |
2717 | realNameList.append((*it).realName()); | 2766 | realNameList.append((*it).realName()); |
2718 | preferredEmailList.append((*it).preferredEmail()); | 2767 | preferredEmailList.append((*it).preferredEmail()); |
2719 | assembledNameList.append((*it).realName()); | 2768 | assembledNameList.append((*it).realName()); |
2720 | uidList.append((*it).uid()); | 2769 | uidList.append((*it).uid()); |
2721 | 2770 | ||
2722 | //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() ); | 2771 | //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() ); |
2723 | } | 2772 | } |
2724 | } | 2773 | } |
2725 | 2774 | ||
2726 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); | 2775 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); |
2727 | 2776 | ||
2728 | } | 2777 | } |
2729 | 2778 | ||
2730 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2779 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2731 | */ | 2780 | */ |
2732 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2781 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2733 | { | 2782 | { |
2734 | //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2783 | //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2735 | 2784 | ||
2736 | QString foundUid = QString::null; | 2785 | QString foundUid = QString::null; |
2737 | if ( ! uid.isEmpty() ) { | 2786 | if ( ! uid.isEmpty() ) { |
2738 | Addressee adrr = mAddressBook->findByUid( uid ); | 2787 | Addressee adrr = mAddressBook->findByUid( uid ); |
2739 | if ( !adrr.isEmpty() ) { | 2788 | if ( !adrr.isEmpty() ) { |
2740 | foundUid = uid; | 2789 | foundUid = uid; |
2741 | } | 2790 | } |
2742 | if ( email == "sendbacklist" ) { | 2791 | if ( email == "sendbacklist" ) { |
2743 | //qDebug("ssssssssssssssssssssssend "); | 2792 | //qDebug("ssssssssssssssssssssssend "); |
2744 | QStringList nameList; | 2793 | QStringList nameList; |
2745 | QStringList emailList; | 2794 | QStringList emailList; |
2746 | QStringList uidList; | 2795 | QStringList uidList; |
2747 | nameList.append(adrr.realName()); | 2796 | nameList.append(adrr.realName()); |
2748 | emailList = adrr.emails(); | 2797 | emailList = adrr.emails(); |
2749 | uidList.append( adrr.preferredEmail()); | 2798 | uidList.append( adrr.preferredEmail()); |
2750 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2799 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2751 | return; | 2800 | return; |
2752 | } | 2801 | } |
2753 | 2802 | ||
2754 | } | 2803 | } |
2755 | 2804 | ||
2756 | if ( email == "sendbacklist" ) | 2805 | if ( email == "sendbacklist" ) |
2757 | return; | 2806 | return; |
2758 | if (foundUid.isEmpty()) | 2807 | if (foundUid.isEmpty()) |
2759 | { | 2808 | { |
2760 | //find the uid of the person first | 2809 | //find the uid of the person first |
2761 | Addressee::List namelist; | 2810 | Addressee::List namelist; |
2762 | Addressee::List emaillist; | 2811 | Addressee::List emaillist; |
2763 | 2812 | ||
2764 | if (!name.isEmpty()) | 2813 | if (!name.isEmpty()) |
2765 | namelist = mAddressBook->findByName( name ); | 2814 | namelist = mAddressBook->findByName( name ); |
2766 | 2815 | ||
2767 | if (!email.isEmpty()) | 2816 | if (!email.isEmpty()) |
2768 | emaillist = mAddressBook->findByEmail( email ); | 2817 | emaillist = mAddressBook->findByEmail( email ); |
2769 | //qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2818 | //qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2770 | //check if we have a match in Namelist and Emaillist | 2819 | //check if we have a match in Namelist and Emaillist |
2771 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2820 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2772 | foundUid = emaillist[0].uid(); | 2821 | foundUid = emaillist[0].uid(); |
2773 | } | 2822 | } |
2774 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2823 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2775 | foundUid = namelist[0].uid(); | 2824 | foundUid = namelist[0].uid(); |
2776 | else | 2825 | else |
2777 | { | 2826 | { |
2778 | for (int i = 0; i < namelist.count(); i++) | 2827 | for (int i = 0; i < namelist.count(); i++) |
2779 | { | 2828 | { |
2780 | for (int j = 0; j < emaillist.count(); j++) | 2829 | for (int j = 0; j < emaillist.count(); j++) |
2781 | { | 2830 | { |
2782 | if (namelist[i] == emaillist[j]) | 2831 | if (namelist[i] == emaillist[j]) |
2783 | { | 2832 | { |
2784 | foundUid = namelist[i].uid(); | 2833 | foundUid = namelist[i].uid(); |
2785 | } | 2834 | } |
2786 | } | 2835 | } |
2787 | } | 2836 | } |
2788 | } | 2837 | } |
2789 | } | 2838 | } |
2790 | else | 2839 | else |
2791 | { | 2840 | { |
2792 | foundUid = uid; | 2841 | foundUid = uid; |
2793 | } | 2842 | } |
2794 | 2843 | ||
2795 | if (!foundUid.isEmpty()) | 2844 | if (!foundUid.isEmpty()) |
2796 | { | 2845 | { |
2797 | 2846 | ||
2798 | // raise Ka/Pi if it is in the background | 2847 | // raise Ka/Pi if it is in the background |
2799 | #ifndef DESKTOP_VERSION | 2848 | #ifndef DESKTOP_VERSION |
2800 | #ifndef KORG_NODCOP | 2849 | #ifndef KORG_NODCOP |
2801 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2850 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2802 | #endif | 2851 | #endif |
2803 | #endif | 2852 | #endif |
2804 | 2853 | ||
2805 | mMainWindow->showMaximized(); | 2854 | mMainWindow->showMaximized(); |
2806 | mMainWindow-> raise(); | 2855 | mMainWindow-> raise(); |
2807 | 2856 | ||
2808 | mViewManager->setSelected( "", false); | 2857 | mViewManager->setSelected( "", false); |
2809 | mViewManager->refreshView( "" ); | 2858 | mViewManager->refreshView( "" ); |
2810 | mViewManager->setSelected( foundUid, true ); | 2859 | mViewManager->setSelected( foundUid, true ); |
2811 | mViewManager->refreshView( foundUid ); | 2860 | mViewManager->refreshView( foundUid ); |
2812 | 2861 | ||
2813 | if ( !mMultipleViewsAtOnce ) | 2862 | if ( !mMultipleViewsAtOnce ) |
2814 | { | 2863 | { |
2815 | setDetailsVisible( true ); | 2864 | setDetailsVisible( true ); |
2816 | mActionDetails->setChecked(true); | 2865 | mActionDetails->setChecked(true); |
2817 | } | 2866 | } |
2818 | } | 2867 | } |
2819 | } | 2868 | } |
2820 | void KABCore::storagehowto() | 2869 | void KABCore::storagehowto() |
2821 | { | 2870 | { |
2822 | KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); | 2871 | KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); |
2823 | } | 2872 | } |
2824 | void KABCore::whatsnew() | 2873 | void KABCore::whatsnew() |
2825 | { | 2874 | { |
2826 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 2875 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
2827 | } | 2876 | } |
2828 | void KABCore::synchowto() | 2877 | void KABCore::synchowto() |
2829 | { | 2878 | { |
2830 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 2879 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
2831 | } | 2880 | } |
2832 | void KABCore::kdesynchowto() | 2881 | void KABCore::kdesynchowto() |
2833 | { | 2882 | { |
2834 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); | 2883 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); |
2835 | } | 2884 | } |
2836 | void KABCore::multisynchowto() | 2885 | void KABCore::multisynchowto() |
2837 | { | 2886 | { |
2838 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); | 2887 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); |
2839 | } | 2888 | } |
2840 | void KABCore::faq() | 2889 | void KABCore::faq() |
2841 | { | 2890 | { |
2842 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2891 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2843 | } | 2892 | } |
2844 | 2893 | ||
2845 | #include <libkcal/syncdefines.h> | 2894 | #include <libkcal/syncdefines.h> |
2846 | 2895 | ||
2847 | KABC::Addressee KABCore::getLastSyncAddressee() | 2896 | KABC::Addressee KABCore::getLastSyncAddressee() |
2848 | { | 2897 | { |
2849 | Addressee lse; | 2898 | Addressee lse; |
2850 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2899 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2851 | 2900 | ||
2852 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2901 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2853 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2902 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2854 | if (lse.isEmpty()) { | 2903 | if (lse.isEmpty()) { |
2855 | qDebug("KA: Creating new last-syncAddressee "); | 2904 | qDebug("KA: Creating new last-syncAddressee "); |
2856 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2905 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2857 | QString sum = ""; | 2906 | QString sum = ""; |
2858 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2907 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2859 | sum = "E: "; | 2908 | sum = "E: "; |
2860 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2909 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2861 | lse.setRevision( mLastAddressbookSync ); | 2910 | lse.setRevision( mLastAddressbookSync ); |
2862 | lse.setCategories( i18n("SyncEvent") ); | 2911 | lse.setCategories( i18n("SyncEvent") ); |
2863 | mAddressBook->insertAddressee( lse ); | 2912 | mAddressBook->insertAddressee( lse ); |
2864 | } | 2913 | } |
2865 | return lse; | 2914 | return lse; |
2866 | } | 2915 | } |
2867 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2916 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2868 | { | 2917 | { |
2869 | 2918 | ||
2870 | //void setZaurusId(int id); | 2919 | //void setZaurusId(int id); |
2871 | // int zaurusId() const; | 2920 | // int zaurusId() const; |
2872 | // void setZaurusUid(int id); | 2921 | // void setZaurusUid(int id); |
2873 | // int zaurusUid() const; | 2922 | // int zaurusUid() const; |
2874 | // void setZaurusStat(int id); | 2923 | // void setZaurusStat(int id); |
2875 | // int zaurusStat() const; | 2924 | // int zaurusStat() const; |
2876 | // 0 equal | 2925 | // 0 equal |
2877 | // 1 take local | 2926 | // 1 take local |
2878 | // 2 take remote | 2927 | // 2 take remote |
2879 | // 3 cancel | 2928 | // 3 cancel |
2880 | QDateTime lastSync = mLastAddressbookSync; | 2929 | QDateTime lastSync = mLastAddressbookSync; |
2881 | QDateTime localMod = local->revision(); | 2930 | QDateTime localMod = local->revision(); |
2882 | QDateTime remoteMod = remote->revision(); | 2931 | QDateTime remoteMod = remote->revision(); |
2883 | 2932 | ||
2884 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2933 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2885 | 2934 | ||
2886 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2935 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2887 | bool remCh, locCh; | 2936 | bool remCh, locCh; |
2888 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2937 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2889 | //if ( remCh ) | 2938 | //if ( remCh ) |
2890 | // qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2939 | // qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2891 | locCh = ( localMod > mLastAddressbookSync ); | 2940 | locCh = ( localMod > mLastAddressbookSync ); |
2892 | //qDebug("cahnged rem %d loc %d",remCh, locCh ); | 2941 | //qDebug("cahnged rem %d loc %d",remCh, locCh ); |
2893 | if ( !remCh && ! locCh ) { | 2942 | if ( !remCh && ! locCh ) { |
2894 | //qDebug("both not changed "); | 2943 | //qDebug("both not changed "); |
2895 | lastSync = localMod.addDays(1); | 2944 | lastSync = localMod.addDays(1); |
2896 | if ( mode <= SYNC_PREF_ASK ) | 2945 | if ( mode <= SYNC_PREF_ASK ) |
2897 | return 0; | 2946 | return 0; |
2898 | } else { | 2947 | } else { |
2899 | if ( locCh ) { | 2948 | if ( locCh ) { |
2900 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2949 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2901 | lastSync = localMod.addDays( -1 ); | 2950 | lastSync = localMod.addDays( -1 ); |
2902 | if ( !remCh ) | 2951 | if ( !remCh ) |
2903 | remoteMod =( lastSync.addDays( -1 ) ); | 2952 | remoteMod =( lastSync.addDays( -1 ) ); |
2904 | } else { | 2953 | } else { |
2905 | //qDebug(" not loc changed "); | 2954 | //qDebug(" not loc changed "); |
2906 | lastSync = localMod.addDays( 1 ); | 2955 | lastSync = localMod.addDays( 1 ); |
2907 | if ( remCh ) { | 2956 | if ( remCh ) { |
2908 | //qDebug("rem changed "); | 2957 | //qDebug("rem changed "); |
2909 | remoteMod =( lastSync.addDays( 1 ) ); | 2958 | remoteMod =( lastSync.addDays( 1 ) ); |
2910 | } | 2959 | } |
2911 | 2960 | ||
2912 | } | 2961 | } |
2913 | } | 2962 | } |
2914 | full = true; | 2963 | full = true; |
2915 | if ( mode < SYNC_PREF_ASK ) | 2964 | if ( mode < SYNC_PREF_ASK ) |
2916 | mode = SYNC_PREF_ASK; | 2965 | mode = SYNC_PREF_ASK; |
2917 | } else { | 2966 | } else { |
2918 | if ( localMod == remoteMod ) | 2967 | if ( localMod == remoteMod ) |
2919 | return 0; | 2968 | return 0; |
2920 | 2969 | ||
2921 | } | 2970 | } |
2922 | //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); | 2971 | //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); |
2923 | //qDebug("lastsync %s ", lastSync.toString().latin1() ); | 2972 | //qDebug("lastsync %s ", lastSync.toString().latin1() ); |
2924 | //full = true; //debug only | 2973 | //full = true; //debug only |
2925 | if ( full ) { | 2974 | if ( full ) { |
2926 | bool equ = ( (*local) == (*remote) ); | 2975 | bool equ = ( (*local) == (*remote) ); |
2927 | if ( equ ) { | 2976 | if ( equ ) { |
2928 | //qDebug("equal "); | 2977 | //qDebug("equal "); |
2929 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2978 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2930 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2979 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2931 | } | 2980 | } |
2932 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2981 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2933 | return 0; | 2982 | return 0; |
2934 | 2983 | ||
2935 | }//else //debug only | 2984 | }//else //debug only |
2936 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2985 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2937 | } | 2986 | } |
2938 | int result; | 2987 | int result; |
2939 | bool localIsNew; | 2988 | bool localIsNew; |
2940 | //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() ); | 2989 | //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() ); |
2941 | 2990 | ||
2942 | if ( full && mode < SYNC_PREF_NEWEST ) | 2991 | if ( full && mode < SYNC_PREF_NEWEST ) |
2943 | mode = SYNC_PREF_ASK; | 2992 | mode = SYNC_PREF_ASK; |
2944 | 2993 | ||
2945 | switch( mode ) { | 2994 | switch( mode ) { |
2946 | case SYNC_PREF_LOCAL: | 2995 | case SYNC_PREF_LOCAL: |
2947 | if ( lastSync > remoteMod ) | 2996 | if ( lastSync > remoteMod ) |
2948 | return 1; | 2997 | return 1; |
2949 | if ( lastSync > localMod ) | 2998 | if ( lastSync > localMod ) |
2950 | return 2; | 2999 | return 2; |
2951 | return 1; | 3000 | return 1; |
2952 | break; | 3001 | break; |
2953 | case SYNC_PREF_REMOTE: | 3002 | case SYNC_PREF_REMOTE: |
2954 | if ( lastSync > localMod ) | 3003 | if ( lastSync > localMod ) |
2955 | return 2; | 3004 | return 2; |
2956 | if ( lastSync > remoteMod ) | 3005 | if ( lastSync > remoteMod ) |
2957 | return 1; | 3006 | return 1; |
2958 | return 2; | 3007 | return 2; |
2959 | break; | 3008 | break; |
2960 | case SYNC_PREF_NEWEST: | 3009 | case SYNC_PREF_NEWEST: |
2961 | if ( localMod > remoteMod ) | 3010 | if ( localMod > remoteMod ) |
2962 | return 1; | 3011 | return 1; |
2963 | else | 3012 | else |
2964 | return 2; | 3013 | return 2; |
2965 | break; | 3014 | break; |
2966 | case SYNC_PREF_ASK: | 3015 | case SYNC_PREF_ASK: |
2967 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 3016 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
2968 | if ( lastSync > remoteMod && lastSync > localMod) | 3017 | if ( lastSync > remoteMod && lastSync > localMod) |
2969 | return 0; | 3018 | return 0; |
2970 | if ( lastSync > remoteMod ) | 3019 | if ( lastSync > remoteMod ) |
2971 | return 1; | 3020 | return 1; |
2972 | if ( lastSync > localMod ) { | 3021 | if ( lastSync > localMod ) { |
2973 | return 2; | 3022 | return 2; |
2974 | } | 3023 | } |
2975 | localIsNew = localMod >= remoteMod; | 3024 | localIsNew = localMod >= remoteMod; |
2976 | //qDebug("conflict! ************************************** "); | 3025 | //qDebug("conflict! ************************************** "); |
2977 | { | 3026 | { |
2978 | KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | 3027 | KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); |
2979 | result = acd.executeD(localIsNew); | 3028 | result = acd.executeD(localIsNew); |
2980 | return result; | 3029 | return result; |
2981 | } | 3030 | } |
2982 | break; | 3031 | break; |
2983 | case SYNC_PREF_FORCE_LOCAL: | 3032 | case SYNC_PREF_FORCE_LOCAL: |
2984 | return 1; | 3033 | return 1; |
2985 | break; | 3034 | break; |
2986 | case SYNC_PREF_FORCE_REMOTE: | 3035 | case SYNC_PREF_FORCE_REMOTE: |
2987 | return 2; | 3036 | return 2; |
2988 | break; | 3037 | break; |
2989 | 3038 | ||
2990 | default: | 3039 | default: |
2991 | // SYNC_PREF_TAKE_BOTH not implemented | 3040 | // SYNC_PREF_TAKE_BOTH not implemented |
2992 | break; | 3041 | break; |
2993 | } | 3042 | } |
2994 | return 0; | 3043 | return 0; |
2995 | } | 3044 | } |
2996 | 3045 | ||
2997 | 3046 | ||
2998 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 3047 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2999 | { | 3048 | { |
3000 | bool syncOK = true; | 3049 | bool syncOK = true; |
3001 | int addedAddressee = 0; | 3050 | int addedAddressee = 0; |
3002 | int addedAddresseeR = 0; | 3051 | int addedAddresseeR = 0; |
3003 | int deletedAddresseeR = 0; | 3052 | int deletedAddresseeR = 0; |
3004 | int deletedAddresseeL = 0; | 3053 | int deletedAddresseeL = 0; |
3005 | int changedLocal = 0; | 3054 | int changedLocal = 0; |
3006 | int changedRemote = 0; | 3055 | int changedRemote = 0; |
3007 | int filteredIN = 0; | 3056 | int filteredIN = 0; |
3008 | int filteredOUT = 0; | 3057 | int filteredOUT = 0; |
3009 | 3058 | ||
3010 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); | 3059 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); |
3011 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 3060 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
3012 | 3061 | ||
3013 | //QPtrList<Addressee> el = local->rawAddressees(); | 3062 | //QPtrList<Addressee> el = local->rawAddressees(); |
3014 | Addressee addresseeR; | 3063 | Addressee addresseeR; |
3015 | QString uid; | 3064 | QString uid; |
3016 | int take; | 3065 | int take; |
3017 | Addressee addresseeL; | 3066 | Addressee addresseeL; |
3018 | Addressee addresseeRSync; | 3067 | Addressee addresseeRSync; |
3019 | Addressee addresseeLSync; | 3068 | Addressee addresseeLSync; |
3020 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 3069 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
3021 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 3070 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
3022 | bool fullDateRange = false; | 3071 | bool fullDateRange = false; |
3023 | local->resetTempSyncStat(); | 3072 | local->resetTempSyncStat(); |
3024 | mLastAddressbookSync = QDateTime::currentDateTime(); | 3073 | mLastAddressbookSync = QDateTime::currentDateTime(); |
3025 | if ( syncManager->syncWithDesktop() ) { | 3074 | if ( syncManager->syncWithDesktop() ) { |
3026 | // remote->removeSyncInfo( QString());//remove all info | 3075 | // remote->removeSyncInfo( QString());//remove all info |
3027 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 3076 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
3028 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; | 3077 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; |
3029 | qDebug("KA: using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); | 3078 | qDebug("KA: using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); |
3030 | } else { | 3079 | } else { |
3031 | qDebug("KA: KSyncManager::mRequestedSyncEvent has invalid datatime "); | 3080 | qDebug("KA: KSyncManager::mRequestedSyncEvent has invalid datatime "); |
3032 | } | 3081 | } |
3033 | } | 3082 | } |
3034 | QDateTime modifiedCalendar = mLastAddressbookSync; | 3083 | QDateTime modifiedCalendar = mLastAddressbookSync; |
3035 | addresseeLSync = getLastSyncAddressee(); | 3084 | addresseeLSync = getLastSyncAddressee(); |
3036 | qDebug("KA: Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 3085 | qDebug("KA: Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
3037 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 3086 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
3038 | if ( !addresseeR.isEmpty() ) { | 3087 | if ( !addresseeR.isEmpty() ) { |
3039 | addresseeRSync = addresseeR; | 3088 | addresseeRSync = addresseeR; |
3040 | remote->removeAddressee(addresseeR ); | 3089 | remote->removeAddressee(addresseeR ); |
3041 | 3090 | ||
3042 | } else { | 3091 | } else { |
3043 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 3092 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
3044 | addresseeRSync = addresseeLSync ; | 3093 | addresseeRSync = addresseeLSync ; |
3045 | } else { | 3094 | } else { |
3046 | //qDebug("FULLDATE 1"); | 3095 | //qDebug("FULLDATE 1"); |
3047 | fullDateRange = true; | 3096 | fullDateRange = true; |
3048 | Addressee newAdd; | 3097 | Addressee newAdd; |
3049 | addresseeRSync = newAdd; | 3098 | addresseeRSync = newAdd; |
3050 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 3099 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
3051 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 3100 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
3052 | addresseeRSync.setRevision( mLastAddressbookSync ); | 3101 | addresseeRSync.setRevision( mLastAddressbookSync ); |
3053 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 3102 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
3054 | } | 3103 | } |
3055 | } | 3104 | } |
3056 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 3105 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
3057 | // qDebug("FULLDATE 2"); | 3106 | // qDebug("FULLDATE 2"); |
3058 | fullDateRange = true; | 3107 | fullDateRange = true; |
3059 | } | 3108 | } |
3060 | if ( ! fullDateRange ) { | 3109 | if ( ! fullDateRange ) { |
3061 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 3110 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
3062 | 3111 | ||
3063 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 3112 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
3064 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 3113 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
3065 | fullDateRange = true; | 3114 | fullDateRange = true; |
3066 | //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 3115 | //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
3067 | } | 3116 | } |
3068 | } | 3117 | } |
3069 | // fullDateRange = true; // debug only! | 3118 | // fullDateRange = true; // debug only! |
3070 | if ( fullDateRange ) | 3119 | if ( fullDateRange ) |
3071 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 3120 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
3072 | else | 3121 | else |
3073 | mLastAddressbookSync = addresseeLSync.revision(); | 3122 | mLastAddressbookSync = addresseeLSync.revision(); |
3074 | // for resyncing if own file has changed | 3123 | // for resyncing if own file has changed |
3075 | // PENDING fixme later when implemented | 3124 | // PENDING fixme later when implemented |
3076 | #if 0 | 3125 | #if 0 |
3077 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 3126 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
3078 | mLastAddressbookSync = loadedFileVersion; | 3127 | mLastAddressbookSync = loadedFileVersion; |
3079 | qDebug("setting mLastAddressbookSync "); | 3128 | qDebug("setting mLastAddressbookSync "); |
3080 | } | 3129 | } |
3081 | #endif | 3130 | #endif |
3082 | 3131 | ||
3083 | 3132 | ||
3084 | // ********** setting filters **************** | 3133 | // ********** setting filters **************** |
3085 | Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB ); | 3134 | Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB ); |
3086 | Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB ); | 3135 | Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB ); |
3087 | 3136 | ||
3088 | //qDebug("*************************** "); | 3137 | //qDebug("*************************** "); |
3089 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 3138 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
3090 | QStringList er = remote->uidList(); | 3139 | QStringList er = remote->uidList(); |
3091 | Addressee inR ;//= er.first(); | 3140 | Addressee inR ;//= er.first(); |
3092 | Addressee inL; | 3141 | Addressee inL; |
3093 | 3142 | ||
3094 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 3143 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
3095 | 3144 | ||
3096 | int modulo = (er.count()/10)+1; | 3145 | int modulo = (er.count()/10)+1; |
3097 | int incCounter = 0; | 3146 | int incCounter = 0; |
3098 | while ( incCounter < er.count()) { | 3147 | while ( incCounter < er.count()) { |
3099 | if (syncManager->isProgressBarCanceled()) | 3148 | if (syncManager->isProgressBarCanceled()) |
3100 | return false; | 3149 | return false; |
3101 | if ( incCounter % modulo == 0 ) | 3150 | if ( incCounter % modulo == 0 ) |
3102 | syncManager->showProgressBar(incCounter); | 3151 | syncManager->showProgressBar(incCounter); |
3103 | 3152 | ||
3104 | uid = er[ incCounter ]; | 3153 | uid = er[ incCounter ]; |
3105 | bool skipIncidence = false; | 3154 | bool skipIncidence = false; |
3106 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 3155 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
3107 | skipIncidence = true; | 3156 | skipIncidence = true; |
3108 | QString idS,OidS; | 3157 | QString idS,OidS; |
3109 | qApp->processEvents(); | 3158 | qApp->processEvents(); |
3110 | if ( !skipIncidence ) { | 3159 | if ( !skipIncidence ) { |
3111 | inL = local->findByUid( uid ); | 3160 | inL = local->findByUid( uid ); |
3112 | inR = remote->findByUid( uid ); | 3161 | inR = remote->findByUid( uid ); |
3113 | //inL.setResource( 0 ); | 3162 | //inL.setResource( 0 ); |
3114 | //inR.setResource( 0 ); | 3163 | //inR.setResource( 0 ); |
3115 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 3164 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
3116 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 3165 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
3117 | if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { | 3166 | if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { |
3118 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 3167 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
3119 | if ( take == 3 ) | 3168 | if ( take == 3 ) |
3120 | return false; | 3169 | return false; |
3121 | if ( take == 1 ) {// take local ********************** | 3170 | if ( take == 1 ) {// take local ********************** |
3122 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 3171 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
3123 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 3172 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
3124 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 3173 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
3125 | local->insertAddressee( inL, false ); | 3174 | local->insertAddressee( inL, false ); |
3126 | idS = inR.externalUID(); | 3175 | idS = inR.externalUID(); |
3127 | OidS = inR.originalExternalUID(); | 3176 | OidS = inR.originalExternalUID(); |
3128 | } | 3177 | } |
3129 | else | 3178 | else |
3130 | idS = inR.IDStr(); | 3179 | idS = inR.IDStr(); |
3131 | remote->removeAddressee( inR ); | 3180 | remote->removeAddressee( inR ); |
3132 | inR = inL; | 3181 | inR = inL; |
3133 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 3182 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
3134 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 3183 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
3135 | inR.setOriginalExternalUID( OidS ); | 3184 | inR.setOriginalExternalUID( OidS ); |
3136 | inR.setExternalUID( idS ); | 3185 | inR.setExternalUID( idS ); |
3137 | if ( syncManager->syncWithDesktop() ) { | 3186 | if ( syncManager->syncWithDesktop() ) { |
3138 | inR.setIDStr("changed" ); | 3187 | inR.setIDStr("changed" ); |
3139 | } | 3188 | } |
3140 | //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); | 3189 | //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); |
3141 | } else { | 3190 | } else { |
3142 | inR.setIDStr( idS ); | 3191 | inR.setIDStr( idS ); |
3143 | } | 3192 | } |
3144 | inR.setResource( 0 ); | 3193 | inR.setResource( 0 ); |
3145 | remote->insertAddressee( inR , false); | 3194 | remote->insertAddressee( inR , false); |
3146 | ++changedRemote; | 3195 | ++changedRemote; |
3147 | } else { // take == 2 take remote ********************** | 3196 | } else { // take == 2 take remote ********************** |
3148 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 3197 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
3149 | if ( inR.revision().date().year() < 2004 ) | 3198 | if ( inR.revision().date().year() < 2004 ) |
3150 | inR.setRevision( modifiedCalendar ); | 3199 | inR.setRevision( modifiedCalendar ); |
3151 | } | 3200 | } |
3152 | idS = inL.IDStr(); | 3201 | idS = inL.IDStr(); |
3153 | local->removeAddressee( inL ); | 3202 | local->removeAddressee( inL ); |
3154 | inL = inR; | 3203 | inL = inR; |
3155 | inL.setIDStr( idS ); | 3204 | inL.setIDStr( idS ); |
3156 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 3205 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
3157 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 3206 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
3158 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 3207 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
3159 | } | 3208 | } |
3160 | inL.setResource( 0 ); | 3209 | inL.setResource( 0 ); |
3161 | local->insertAddressee( inL , false ); | 3210 | local->insertAddressee( inL , false ); |
3162 | ++changedLocal; | 3211 | ++changedLocal; |
3163 | } | 3212 | } |
3164 | } | 3213 | } |
3165 | } | 3214 | } |
3166 | } else { // no conflict ********** add or delete remote | 3215 | } else { // no conflict ********** add or delete remote |
3167 | if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { | 3216 | if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { |
3168 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 3217 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
3169 | QString des = addresseeLSync.note(); | 3218 | QString des = addresseeLSync.note(); |
3170 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 3219 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
3171 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 3220 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
3172 | remote->insertAddressee( inR, false ); | 3221 | remote->insertAddressee( inR, false ); |
3173 | ++deletedAddresseeR; | 3222 | ++deletedAddresseeR; |
3174 | } else { | 3223 | } else { |
3175 | inR.setRevision( modifiedCalendar ); | 3224 | inR.setRevision( modifiedCalendar ); |
3176 | remote->insertAddressee( inR, false ); | 3225 | remote->insertAddressee( inR, false ); |
3177 | inL = inR; | 3226 | inL = inR; |
3178 | inL.setIDStr( ":" ); | 3227 | inL.setIDStr( ":" ); |
3179 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 3228 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
3180 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 3229 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
3181 | inL.setResource( 0 ); | 3230 | inL.setResource( 0 ); |
3182 | local->insertAddressee( inL , false); | 3231 | local->insertAddressee( inL , false); |
3183 | ++addedAddressee; | 3232 | ++addedAddressee; |
3184 | } | 3233 | } |
3185 | } else { | 3234 | } else { |
3186 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { | 3235 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
3187 | inR.setRevision( modifiedCalendar ); | 3236 | inR.setRevision( modifiedCalendar ); |
3188 | remote->insertAddressee( inR, false ); | 3237 | remote->insertAddressee( inR, false ); |
3189 | inR.setResource( 0 ); | 3238 | inR.setResource( 0 ); |
3190 | local->insertAddressee( inR, false ); | 3239 | local->insertAddressee( inR, false ); |
3191 | ++addedAddressee; | 3240 | ++addedAddressee; |
3192 | } else { | 3241 | } else { |
3193 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 3242 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
3194 | remote->removeAddressee( inR ); | 3243 | remote->removeAddressee( inR ); |
3195 | ++deletedAddresseeR; | 3244 | ++deletedAddresseeR; |
3196 | } | 3245 | } |
3197 | } | 3246 | } |
3198 | } else { | 3247 | } else { |
3199 | ++filteredIN; | 3248 | ++filteredIN; |
3200 | } | 3249 | } |
3201 | } | 3250 | } |
3202 | } | 3251 | } |
3203 | ++incCounter; | 3252 | ++incCounter; |
3204 | } | 3253 | } |
3205 | er.clear(); | 3254 | er.clear(); |
3206 | QStringList el = local->uidList(); | 3255 | QStringList el = local->uidList(); |
3207 | modulo = (el.count()/10)+1; | 3256 | modulo = (el.count()/10)+1; |
3208 | 3257 | ||
3209 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 3258 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
3210 | incCounter = 0; | 3259 | incCounter = 0; |
3211 | while ( incCounter < el.count()) { | 3260 | while ( incCounter < el.count()) { |
3212 | qApp->processEvents(); | 3261 | qApp->processEvents(); |
3213 | if (syncManager->isProgressBarCanceled()) | 3262 | if (syncManager->isProgressBarCanceled()) |
3214 | return false; | 3263 | return false; |
3215 | if ( incCounter % modulo == 0 ) | 3264 | if ( incCounter % modulo == 0 ) |
3216 | syncManager->showProgressBar(incCounter); | 3265 | syncManager->showProgressBar(incCounter); |
3217 | uid = el[ incCounter ]; | 3266 | uid = el[ incCounter ]; |
3218 | bool skipIncidence = false; | 3267 | bool skipIncidence = false; |
3219 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 3268 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
3220 | skipIncidence = true; | 3269 | skipIncidence = true; |
3221 | if ( !skipIncidence ) { | 3270 | if ( !skipIncidence ) { |
3222 | inL = local->findByUid( uid ); | 3271 | inL = local->findByUid( uid ); |
3223 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 3272 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
3224 | inR = remote->findByUid( uid ); | 3273 | inR = remote->findByUid( uid ); |
3225 | if ( inR.isEmpty() ){ | 3274 | if ( inR.isEmpty() ){ |
3226 | if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { | 3275 | if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { |
3227 | // no conflict ********** add or delete local | 3276 | // no conflict ********** add or delete local |
3228 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 3277 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
3229 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 3278 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
3230 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 3279 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
3231 | local->removeAddressee( inL ); | 3280 | local->removeAddressee( inL ); |
3232 | ++deletedAddresseeL; | 3281 | ++deletedAddresseeL; |
3233 | } else { | 3282 | } else { |
3234 | if ( ! syncManager->mWriteBackExistingOnly ) { | 3283 | if ( ! syncManager->mWriteBackExistingOnly ) { |
3235 | inL.removeID(mCurrentSyncDevice ); | 3284 | inL.removeID(mCurrentSyncDevice ); |
3236 | ++addedAddresseeR; | 3285 | ++addedAddresseeR; |
3237 | inL.setRevision( modifiedCalendar ); | 3286 | inL.setRevision( modifiedCalendar ); |
3238 | local->insertAddressee( inL, false ); | 3287 | local->insertAddressee( inL, false ); |
3239 | inR = inL; | 3288 | inR = inL; |
3240 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); | 3289 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); |
3241 | inR.setResource( 0 ); | 3290 | inR.setResource( 0 ); |
3242 | remote->insertAddressee( inR, false ); | 3291 | remote->insertAddressee( inR, false ); |
3243 | } | 3292 | } |
3244 | } | 3293 | } |
3245 | } else { | 3294 | } else { |
3246 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 3295 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
3247 | //qDebug("data %s ", inL.revision().toString().latin1()); | 3296 | //qDebug("data %s ", inL.revision().toString().latin1()); |
3248 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 3297 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
3249 | local->removeAddressee( inL ); | 3298 | local->removeAddressee( inL ); |
3250 | ++deletedAddresseeL; | 3299 | ++deletedAddresseeL; |
3251 | } else { | 3300 | } else { |
3252 | if ( ! syncManager->mWriteBackExistingOnly ) { | 3301 | if ( ! syncManager->mWriteBackExistingOnly ) { |
3253 | ++addedAddresseeR; | 3302 | ++addedAddresseeR; |
3254 | inL.setRevision( modifiedCalendar ); | 3303 | inL.setRevision( modifiedCalendar ); |
3255 | local->insertAddressee( inL, false ); | 3304 | local->insertAddressee( inL, false ); |
3256 | inR = inL; | 3305 | inR = inL; |
3257 | inR.setIDStr( ":" ); | 3306 | inR.setIDStr( ":" ); |
3258 | inR.setResource( 0 ); | 3307 | inR.setResource( 0 ); |
3259 | remote->insertAddressee( inR, false ); | 3308 | remote->insertAddressee( inR, false ); |
3260 | } | 3309 | } |
3261 | } | 3310 | } |
3262 | } | 3311 | } |
3263 | } else { | 3312 | } else { |
3264 | ++filteredOUT; | 3313 | ++filteredOUT; |
3265 | } | 3314 | } |
3266 | } | 3315 | } |
3267 | } | 3316 | } |
3268 | } | 3317 | } |
3269 | ++incCounter; | 3318 | ++incCounter; |
3270 | } | 3319 | } |
3271 | el.clear(); | 3320 | el.clear(); |
3272 | syncManager->hideProgressBar(); | 3321 | syncManager->hideProgressBar(); |
3273 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 3322 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
3274 | // get rid of micro seconds | 3323 | // get rid of micro seconds |
3275 | QTime t = mLastAddressbookSync.time(); | 3324 | QTime t = mLastAddressbookSync.time(); |
3276 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 3325 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
3277 | addresseeLSync.setRevision( mLastAddressbookSync ); | 3326 | addresseeLSync.setRevision( mLastAddressbookSync ); |
3278 | addresseeRSync.setRevision( mLastAddressbookSync ); | 3327 | addresseeRSync.setRevision( mLastAddressbookSync ); |
3279 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 3328 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
3280 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 3329 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
3281 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 3330 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
3282 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 3331 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
3283 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 3332 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
3284 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 3333 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
3285 | addresseeRSync.setNote( "" ) ; | 3334 | addresseeRSync.setNote( "" ) ; |
3286 | addresseeLSync.setNote( "" ); | 3335 | addresseeLSync.setNote( "" ); |
3287 | 3336 | ||
3288 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 3337 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
3289 | remote->insertAddressee( addresseeRSync, false ); | 3338 | remote->insertAddressee( addresseeRSync, false ); |
3290 | local->insertAddressee( addresseeLSync, false ); | 3339 | local->insertAddressee( addresseeLSync, false ); |
3291 | QString mes; | 3340 | QString mes; |
3292 | 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 %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); | 3341 | 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 %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); |
3293 | qDebug( mes ); | 3342 | qDebug( mes ); |
3294 | mes = i18n("Local addressbook changed!\n") +mes; | 3343 | mes = i18n("Local addressbook changed!\n") +mes; |
3295 | if ( syncManager->mShowSyncSummary ) { | 3344 | if ( syncManager->mShowSyncSummary ) { |
3296 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 3345 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
3297 | i18n("KA/Pi Synchronization"),i18n("Write back"))) { | 3346 | i18n("KA/Pi Synchronization"),i18n("Write back"))) { |
3298 | qDebug("KA: WB cancelled "); | 3347 | qDebug("KA: WB cancelled "); |
3299 | syncManager->mWriteBackFile = false; | 3348 | syncManager->mWriteBackFile = false; |
3300 | return syncOK; | 3349 | return syncOK; |
3301 | } | 3350 | } |
3302 | } | 3351 | } |
3303 | return syncOK; | 3352 | return syncOK; |
3304 | } | 3353 | } |
3305 | 3354 | ||
3306 | 3355 | ||
3307 | //this is a overwritten callbackmethods from the syncinterface | 3356 | //this is a overwritten callbackmethods from the syncinterface |
3308 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode,QString resource) | 3357 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode,QString resource) |
3309 | { | 3358 | { |
3310 | 3359 | ||
3311 | //pending prepare addresseeview for output | 3360 | //pending prepare addresseeview for output |
3312 | //pending detect, if remote file has REV field. if not switch to external sync | 3361 | //pending detect, if remote file has REV field. if not switch to external sync |
3313 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 3362 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
3314 | if ( manager != syncManager ) | 3363 | if ( manager != syncManager ) |
3315 | qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); | 3364 | qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); |
3316 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3365 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3317 | 3366 | ||
3318 | AddressBook abLocal(filename,"syncContact"); | 3367 | AddressBook abLocal(filename,"syncContact"); |
3319 | bool syncOK = false; | 3368 | bool syncOK = false; |
3320 | if ( abLocal.load() ) { | 3369 | if ( abLocal.load() ) { |
3321 | qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode ); | 3370 | qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode ); |
3322 | bool external = false; | 3371 | bool external = false; |
3323 | bool isXML = false; | 3372 | bool isXML = false; |
3324 | if ( filename.right(4) == ".xml") { | 3373 | if ( filename.right(4) == ".xml") { |
3325 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3374 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3326 | isXML = true; | 3375 | isXML = true; |
3327 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 3376 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
3328 | } else { | 3377 | } else { |
3329 | external = !manager->mIsKapiFile; | 3378 | external = !manager->mIsKapiFile; |
3330 | if ( external ) { | 3379 | if ( external ) { |
3331 | qDebug("KA: Sync::Setting vcf mode to external "); | 3380 | qDebug("KA: Sync::Setting vcf mode to external "); |
3332 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3381 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3333 | AddressBook::Iterator it; | 3382 | AddressBook::Iterator it; |
3334 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 3383 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
3335 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 3384 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
3336 | (*it).computeCsum( mCurrentSyncDevice ); | 3385 | (*it).computeCsum( mCurrentSyncDevice ); |
3337 | } | 3386 | } |
3338 | } | 3387 | } |
3339 | } | 3388 | } |
3340 | //AddressBook::Iterator it; | 3389 | //AddressBook::Iterator it; |
3341 | //QStringList vcards; | 3390 | //QStringList vcards; |
3342 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 3391 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
3343 | // qDebug("Name %s ", (*it).familyName().latin1()); | 3392 | // qDebug("Name %s ", (*it).familyName().latin1()); |
3344 | //} | 3393 | //} |
3345 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 3394 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
3346 | syncManager->hideProgressBar(); | 3395 | syncManager->hideProgressBar(); |
3347 | if ( syncOK ) { | 3396 | if ( syncOK ) { |
3348 | if ( syncManager->mWriteBackFile ) | 3397 | if ( syncManager->mWriteBackFile ) |
3349 | { | 3398 | { |
3350 | if ( external ) | 3399 | if ( external ) |
3351 | abLocal.removeSyncAddressees( !isXML); | 3400 | abLocal.removeSyncAddressees( !isXML); |
3352 | qDebug("KA: Sync::Saving remote AB "); | 3401 | qDebug("KA: Sync::Saving remote AB "); |
3353 | if ( ! abLocal.saveAB()) | 3402 | if ( ! abLocal.saveAB()) |
3354 | qDebug("KA: sync::Error writing back AB to file "); | 3403 | qDebug("KA: sync::Error writing back AB to file "); |
3355 | if ( external ) { | 3404 | if ( external ) { |
3356 | // afterwrite processing | 3405 | // afterwrite processing |
3357 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); | 3406 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); |
3358 | } | 3407 | } |
3359 | } | 3408 | } |
3360 | } | 3409 | } |
3361 | setModified(); | 3410 | setModified(); |
3362 | 3411 | ||
3363 | } | 3412 | } |
3364 | abLocal.removeResources(); | 3413 | abLocal.removeResources(); |
3365 | if ( syncOK ) | 3414 | if ( syncOK ) |
3366 | mViewManager->refreshView(); | 3415 | mViewManager->refreshView(); |
3367 | return syncOK; | 3416 | return syncOK; |
3368 | 3417 | ||
3369 | } | 3418 | } |
3370 | void KABCore::removeSyncInfo( QString syncProfile) | 3419 | void KABCore::removeSyncInfo( QString syncProfile) |
3371 | { | 3420 | { |
3372 | qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1()); | 3421 | qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1()); |
3373 | mAddressBook->removeSyncInfo( syncProfile ); | 3422 | mAddressBook->removeSyncInfo( syncProfile ); |
3374 | setModified(); | 3423 | setModified(); |
3375 | } | 3424 | } |
3376 | 3425 | ||
3426 | bool KABCore::syncOL() | ||
3427 | { | ||
3428 | disableBR( true ); | ||
3429 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | ||
3430 | AddressBook abLocal; | ||
3431 | if ( ! readOLdata( &abLocal ) ) | ||
3432 | return false; | ||
3433 | bool syncOK = false; | ||
3434 | message(i18n("Data from OL loaded..."), false); | ||
3435 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | ||
3436 | message(i18n("Sync preprocessing..."),false); | ||
3437 | abLocal.preOLSync( mAddressBook ,mCurrentSyncDevice ); | ||
3438 | message(i18n("Synchronizing..."),false); | ||
3439 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | ||
3440 | syncManager->hideProgressBar(); | ||
3441 | if ( syncOK ) { | ||
3442 | if ( syncManager->mWriteBackFile ) { | ||
3443 | abLocal.removeSyncAddressees( false ); | ||
3444 | message(i18n("Saving address data to OL..."),false); | ||
3445 | //abLocal.saveAB(); | ||
3446 | writeOLdata( &abLocal ); | ||
3447 | message(i18n("Sync postprocessing..."),false); | ||
3448 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | ||
3449 | } | ||
3450 | } else | ||
3451 | message( i18n("Sync cancelled or failed.") ); | ||
3452 | setModified(); | ||
3453 | abLocal.removeResources(); | ||
3454 | if ( syncOK ) { | ||
3455 | mViewManager->refreshView(); | ||
3456 | message(i18n("OL syncing finished.")); | ||
3457 | } | ||
3458 | disableBR( false ); | ||
3459 | return syncOK; | ||
3460 | } | ||
3377 | 3461 | ||
3378 | //this is a overwritten callbackmethods from the syncinterface | 3462 | //this is a overwritten callbackmethods from the syncinterface |
3379 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 3463 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
3380 | { | 3464 | { |
3381 | if ( resource == "phone" ) | 3465 | if ( resource == "phone" ) |
3382 | return syncPhone(); | 3466 | return syncPhone(); |
3467 | if ( resource == "ol" ) | ||
3468 | return syncOL(); | ||
3383 | disableBR( true ); | 3469 | disableBR( true ); |
3384 | if ( manager != syncManager ) | 3470 | if ( manager != syncManager ) |
3385 | qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); | 3471 | qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); |
3386 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3472 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3387 | 3473 | ||
3388 | AddressBook abLocal( resource,"syncContact"); | 3474 | AddressBook abLocal( resource,"syncContact"); |
3389 | bool syncOK = false; | 3475 | bool syncOK = false; |
3390 | message(i18n("Loading DTM address data..."), false); | 3476 | message(i18n("Loading DTM address data..."), false); |
3391 | if ( abLocal.load() ) { | 3477 | if ( abLocal.load() ) { |
3392 | qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 3478 | qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
3393 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3479 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3394 | message(i18n("Sync preprocessing..."),false); | 3480 | message(i18n("Sync preprocessing..."),false); |
3395 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); | 3481 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); |
3396 | message(i18n("Synchronizing..."),false); | 3482 | message(i18n("Synchronizing..."),false); |
3397 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 3483 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
3398 | syncManager->hideProgressBar(); | 3484 | syncManager->hideProgressBar(); |
3399 | if ( syncOK ) { | 3485 | if ( syncOK ) { |
3400 | if ( syncManager->mWriteBackFile ) { | 3486 | if ( syncManager->mWriteBackFile ) { |
3401 | abLocal.removeSyncAddressees( false ); | 3487 | abLocal.removeSyncAddressees( false ); |
3402 | message(i18n("Saving DTM address data..."),false); | 3488 | message(i18n("Saving DTM address data..."),false); |
3403 | abLocal.saveAB(); | 3489 | abLocal.saveAB(); |
3404 | message(i18n("Sync postprocessing..."),false); | 3490 | message(i18n("Sync postprocessing..."),false); |
3405 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 3491 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
3406 | } | 3492 | } |
3407 | } else | 3493 | } else |
3408 | message( i18n("Sync cancelled or failed.") ); | 3494 | message( i18n("Sync cancelled or failed.") ); |
3409 | setModified(); | 3495 | setModified(); |
3410 | } | 3496 | } |
3411 | abLocal.removeResources(); | 3497 | abLocal.removeResources(); |
3412 | if ( syncOK ) { | 3498 | if ( syncOK ) { |
3413 | mViewManager->refreshView(); | 3499 | mViewManager->refreshView(); |
3414 | message(i18n("DTM syncing finished.")); | 3500 | message(i18n("DTM syncing finished.")); |
3415 | } | 3501 | } |
3416 | disableBR( false ); | 3502 | disableBR( false ); |
3417 | return syncOK; | 3503 | return syncOK; |
3418 | 3504 | ||
3419 | } | 3505 | } |
3420 | void KABCore::message( QString m, bool startTimer) | 3506 | void KABCore::message( QString m, bool startTimer) |
3421 | { | 3507 | { |
3422 | topLevelWidget()->setCaption( m ); | 3508 | topLevelWidget()->setCaption( m ); |
3423 | qApp->processEvents(); | 3509 | qApp->processEvents(); |
3424 | if ( startTimer ) | 3510 | if ( startTimer ) |
3425 | mMessageTimer->start( 15000, true ); | 3511 | mMessageTimer->start( 15000, true ); |
3426 | else | 3512 | else |
3427 | mMessageTimer->stop(); | 3513 | mMessageTimer->stop(); |
3428 | } | 3514 | } |
3429 | bool KABCore::syncPhone() | 3515 | bool KABCore::syncPhone() |
3430 | { | 3516 | { |
3431 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 3517 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
3432 | QString fileName = getPhoneFile(); | 3518 | QString fileName = getPhoneFile(); |
3433 | if ( !PhoneAccess::readFromPhone( fileName) ) { | 3519 | if ( !PhoneAccess::readFromPhone( fileName) ) { |
3434 | message(i18n("Phone access failed!")); | 3520 | message(i18n("Phone access failed!")); |
3435 | return false; | 3521 | return false; |
3436 | } | 3522 | } |
3437 | AddressBook abLocal( fileName,"syncContact"); | 3523 | AddressBook abLocal( fileName,"syncContact"); |
3438 | bool syncOK = false; | 3524 | bool syncOK = false; |
3439 | { | 3525 | { |
3440 | abLocal.importFromFile( fileName ); | 3526 | abLocal.importFromFile( fileName ); |
3441 | qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 3527 | qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
3442 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3528 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3443 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); | 3529 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); |
3444 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 3530 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
3445 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 3531 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
3446 | syncManager->hideProgressBar(); | 3532 | syncManager->hideProgressBar(); |
3447 | if ( syncOK ) { | 3533 | if ( syncOK ) { |
3448 | if ( syncManager->mWriteBackFile ) { | 3534 | if ( syncManager->mWriteBackFile ) { |
3449 | abLocal.removeSyncAddressees( true ); | 3535 | abLocal.removeSyncAddressees( true ); |
3450 | abLocal.saveABphone( fileName ); | 3536 | abLocal.saveABphone( fileName ); |
3451 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); | 3537 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); |
3452 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); | 3538 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); |
3453 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 3539 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
3454 | } | 3540 | } |
3455 | } | 3541 | } |
3456 | setModified(); | 3542 | setModified(); |
3457 | } | 3543 | } |
3458 | abLocal.removeResources(); | 3544 | abLocal.removeResources(); |
3459 | if ( syncOK ) | 3545 | if ( syncOK ) |
3460 | mViewManager->refreshView(); | 3546 | mViewManager->refreshView(); |
3461 | return syncOK; | 3547 | return syncOK; |
3462 | } | 3548 | } |
3463 | void KABCore::getFile( bool success ,const QString & resource) | 3549 | void KABCore::getFile( bool success ,const QString & resource) |
3464 | { | 3550 | { |
3465 | if ( ! success ) { | 3551 | if ( ! success ) { |
3466 | message( i18n("Error receiving file. Nothing changed!") ); | 3552 | message( i18n("Error receiving file. Nothing changed!") ); |
3467 | return; | 3553 | return; |
3468 | } | 3554 | } |
3469 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ,resource); | 3555 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ,resource); |
3470 | if ( count ) | 3556 | if ( count ) |
3471 | setModified( true ); | 3557 | setModified( true ); |
3472 | message( i18n("Pi-Sync successful!") ); | 3558 | message( i18n("Pi-Sync successful!") ); |
3473 | mViewManager->refreshView(); | 3559 | mViewManager->refreshView(); |
3474 | } | 3560 | } |
3475 | void KABCore::syncFileRequest(const QString & resource) | 3561 | void KABCore::syncFileRequest(const QString & resource) |
3476 | { | 3562 | { |
3477 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { | 3563 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { |
3478 | syncManager->slotSyncMenu( 999 ); | 3564 | syncManager->slotSyncMenu( 999 ); |
3479 | } | 3565 | } |
3480 | 3566 | ||
3481 | if ( resource == "ALL" ) { | 3567 | if ( resource == "ALL" ) { |
3482 | mAddressBook->export2File( sentSyncFile() ); | 3568 | mAddressBook->export2File( sentSyncFile() ); |
3483 | } | 3569 | } |
3484 | else | 3570 | else |
3485 | mAddressBook->export2File( sentSyncFile(), resource); | 3571 | mAddressBook->export2File( sentSyncFile(), resource); |
3486 | } | 3572 | } |
3487 | QString KABCore::sentSyncFile() | 3573 | QString KABCore::sentSyncFile() |
3488 | { | 3574 | { |
3489 | #ifdef DESKTOP_VERSION | 3575 | #ifdef DESKTOP_VERSION |
3490 | return locateLocal( "tmp", "copysyncab.vcf" ); | 3576 | return locateLocal( "tmp", "copysyncab.vcf" ); |
3491 | #else | 3577 | #else |
3492 | return QString( "/tmp/copysyncab.vcf" ); | 3578 | return QString( "/tmp/copysyncab.vcf" ); |
3493 | #endif | 3579 | #endif |
3494 | } | 3580 | } |
3495 | 3581 | ||
3496 | void KABCore::setCaptionBack() | 3582 | void KABCore::setCaptionBack() |
3497 | { | 3583 | { |
3498 | mMessageTimer->stop(); | 3584 | mMessageTimer->stop(); |
3499 | topLevelWidget()->setCaption( i18n("KA/Pi") ); | 3585 | topLevelWidget()->setCaption( i18n("KA/Pi") ); |
3500 | } | 3586 | } |
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index e69cb60..ec6a9ec 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h | |||
@@ -1,535 +1,540 @@ | |||
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 | 99 | ||
100 | /** | 100 | /** |
101 | Returns a pointer to the StdAddressBook of the application. | 101 | Returns a pointer to the StdAddressBook of the application. |
102 | */ | 102 | */ |
103 | KABC::AddressBook *addressBook() const; | 103 | KABC::AddressBook *addressBook() const; |
104 | 104 | ||
105 | /** | 105 | /** |
106 | Returns a pointer to the KConfig object of the application. | 106 | Returns a pointer to the KConfig object of the application. |
107 | */ | 107 | */ |
108 | static KConfig *config(); | 108 | static KConfig *config(); |
109 | 109 | ||
110 | /** | 110 | /** |
111 | Returns a pointer to the global KActionCollection object. So | 111 | Returns a pointer to the global KActionCollection object. So |
112 | other classes can register their actions easily. | 112 | other classes can register their actions easily. |
113 | */ | 113 | */ |
114 | KActionCollection *actionCollection() const; | 114 | KActionCollection *actionCollection() const; |
115 | 115 | ||
116 | /** | 116 | /** |
117 | Returns the current search field of the Incremental Search Widget. | 117 | Returns the current search field of the Incremental Search Widget. |
118 | */ | 118 | */ |
119 | KABC::Field *currentSearchField() const; | 119 | KABC::Field *currentSearchField() const; |
120 | 120 | ||
121 | /** | 121 | /** |
122 | Returns the uid list of the currently selected contacts. | 122 | Returns the uid list of the currently selected contacts. |
123 | */ | 123 | */ |
124 | QStringList selectedUIDs() const; | 124 | QStringList selectedUIDs() const; |
125 | 125 | ||
126 | /** | 126 | /** |
127 | Displays the ResourceSelectDialog and returns the selected | 127 | Displays the ResourceSelectDialog and returns the selected |
128 | resource or a null pointer if no resource was selected by | 128 | resource or a null pointer if no resource was selected by |
129 | the user. | 129 | the user. |
130 | */ | 130 | */ |
131 | KABC::Resource *requestResource( QWidget *parent ); | 131 | KABC::Resource *requestResource( QWidget *parent ); |
132 | 132 | ||
133 | #ifndef KAB_EMBEDDED | 133 | #ifndef KAB_EMBEDDED |
134 | static KAboutData *createAboutData(); | 134 | static KAboutData *createAboutData(); |
135 | #endif //KAB_EMBEDDED | 135 | #endif //KAB_EMBEDDED |
136 | 136 | ||
137 | #ifdef KAB_EMBEDDED | 137 | #ifdef KAB_EMBEDDED |
138 | inline QPopupMenu* getImportMenu() { return ImportMenu;} | 138 | inline QPopupMenu* getImportMenu() { return ImportMenu;} |
139 | inline QPopupMenu* getExportMenu() { return ExportMenu;} | 139 | inline QPopupMenu* getExportMenu() { return ExportMenu;} |
140 | #endif //KAB_EMBEDDED | 140 | #endif //KAB_EMBEDDED |
141 | 141 | ||
142 | public slots: | 142 | public slots: |
143 | #ifdef KAB_EMBEDDED | 143 | #ifdef KAB_EMBEDDED |
144 | void createAboutData(); | 144 | void createAboutData(); |
145 | #endif //KAB_EMBEDDED | 145 | #endif //KAB_EMBEDDED |
146 | void setDetailsToggle(); | 146 | void setDetailsToggle(); |
147 | 147 | ||
148 | void showLicence(); | 148 | void showLicence(); |
149 | void faq(); | 149 | void faq(); |
150 | void whatsnew() ; | 150 | void whatsnew() ; |
151 | void synchowto() ; | 151 | void synchowto() ; |
152 | void storagehowto() ; | 152 | void storagehowto() ; |
153 | void multisynchowto() ; | 153 | void multisynchowto() ; |
154 | void kdesynchowto() ; | 154 | void kdesynchowto() ; |
155 | void writeToPhone(); | 155 | void writeToPhone(); |
156 | 156 | ||
157 | /** | 157 | /** |
158 | Is called whenever a contact is selected in the view. | 158 | Is called whenever a contact is selected in the view. |
159 | */ | 159 | */ |
160 | void setContactSelected( const QString &uid ); | 160 | void setContactSelected( const QString &uid ); |
161 | 161 | ||
162 | /** | 162 | /** |
163 | Opens the preferred mail composer with all selected contacts as | 163 | Opens the preferred mail composer with all selected contacts as |
164 | arguments. | 164 | arguments. |
165 | */ | 165 | */ |
166 | void sendMail(); | 166 | void sendMail(); |
167 | 167 | ||
168 | /** | 168 | /** |
169 | Opens the preferred mail composer with the given contacts as | 169 | Opens the preferred mail composer with the given contacts as |
170 | arguments. | 170 | arguments. |
171 | */ | 171 | */ |
172 | void sendMail( const QString& email ); | 172 | void sendMail( const QString& email ); |
173 | 173 | ||
174 | 174 | ||
175 | void mailVCard(); | 175 | void mailVCard(); |
176 | void mailVCard(const QStringList& uids); | 176 | void mailVCard(const QStringList& uids); |
177 | 177 | ||
178 | /** | 178 | /** |
179 | Beams the "WhoAmI contact. | 179 | Beams the "WhoAmI contact. |
180 | */ | 180 | */ |
181 | void beamMySelf(); | 181 | void beamMySelf(); |
182 | 182 | ||
183 | void beamVCard(); | 183 | void beamVCard(); |
184 | void export2phone(); | 184 | void export2phone(); |
185 | void beamVCard(const QStringList& uids); | 185 | void beamVCard(const QStringList& uids); |
186 | void beamDone( Ir *ir ); | 186 | void beamDone( Ir *ir ); |
187 | 187 | ||
188 | 188 | ||
189 | /** | 189 | /** |
190 | Starts the preferred web browser with the given URL as argument. | 190 | Starts the preferred web browser with the given URL as argument. |
191 | */ | 191 | */ |
192 | void browse( const QString& url ); | 192 | void browse( const QString& url ); |
193 | 193 | ||
194 | /** | 194 | /** |
195 | Select all contacts in the view. | 195 | Select all contacts in the view. |
196 | */ | 196 | */ |
197 | void selectAllContacts(); | 197 | void selectAllContacts(); |
198 | 198 | ||
199 | /** | 199 | /** |
200 | Deletes all selected contacts from the address book. | 200 | Deletes all selected contacts from the address book. |
201 | */ | 201 | */ |
202 | void deleteContacts(); | 202 | void deleteContacts(); |
203 | 203 | ||
204 | /** | 204 | /** |
205 | Deletes given contacts from the address book. | 205 | Deletes given contacts from the address book. |
206 | 206 | ||
207 | @param uids The uids of the contacts, which shall be deleted. | 207 | @param uids The uids of the contacts, which shall be deleted. |
208 | */ | 208 | */ |
209 | void deleteContacts( const QStringList &uids ); | 209 | void deleteContacts( const QStringList &uids ); |
210 | 210 | ||
211 | /** | 211 | /** |
212 | Copys the selected contacts into clipboard for later pasting. | 212 | Copys the selected contacts into clipboard for later pasting. |
213 | */ | 213 | */ |
214 | void copyContacts(); | 214 | void copyContacts(); |
215 | 215 | ||
216 | /** | 216 | /** |
217 | Cuts the selected contacts and stores them for later pasting. | 217 | Cuts the selected contacts and stores them for later pasting. |
218 | */ | 218 | */ |
219 | void cutContacts(); | 219 | void cutContacts(); |
220 | 220 | ||
221 | /** | 221 | /** |
222 | Paste contacts from clipboard into the address book. | 222 | Paste contacts from clipboard into the address book. |
223 | */ | 223 | */ |
224 | void pasteContacts(); | 224 | void pasteContacts(); |
225 | 225 | ||
226 | /** | 226 | /** |
227 | Paste given contacts into the address book. | 227 | Paste given contacts into the address book. |
228 | 228 | ||
229 | @param list The list of addressee, which shall be pasted. | 229 | @param list The list of addressee, which shall be pasted. |
230 | */ | 230 | */ |
231 | void pasteContacts( KABC::Addressee::List &list ); | 231 | void pasteContacts( KABC::Addressee::List &list ); |
232 | 232 | ||
233 | /** | 233 | /** |
234 | Sets the whoAmI contact, that is used by many other programs to | 234 | Sets the whoAmI contact, that is used by many other programs to |
235 | get personal information about the current user. | 235 | get personal information about the current user. |
236 | */ | 236 | */ |
237 | void setWhoAmI(); | 237 | void setWhoAmI(); |
238 | 238 | ||
239 | /** | 239 | /** |
240 | Displays the category dialog and applies the result to all | 240 | Displays the category dialog and applies the result to all |
241 | selected contacts. | 241 | selected contacts. |
242 | */ | 242 | */ |
243 | void setCategories(); | 243 | void setCategories(); |
244 | void manageCategories(); | 244 | void manageCategories(); |
245 | void editCategories(); | 245 | void editCategories(); |
246 | 246 | ||
247 | /** | 247 | /** |
248 | Sets the field list of the Incremental Search Widget. | 248 | Sets the field list of the Incremental Search Widget. |
249 | */ | 249 | */ |
250 | void setSearchFields( const KABC::Field::List &fields ); | 250 | void setSearchFields( const KABC::Field::List &fields ); |
251 | 251 | ||
252 | /** | 252 | /** |
253 | Search with the current search field for a contact, that matches | 253 | Search with the current search field for a contact, that matches |
254 | the given text, and selects it in the view. | 254 | the given text, and selects it in the view. |
255 | */ | 255 | */ |
256 | void incrementalSearch( const QString& text ); | 256 | void incrementalSearch( const QString& text ); |
257 | void incrementalSearchJump( const QString& text ); | 257 | void incrementalSearchJump( const QString& text ); |
258 | 258 | ||
259 | /** | 259 | /** |
260 | Marks the address book as modified. | 260 | Marks the address book as modified. |
261 | */ | 261 | */ |
262 | void setModified(); | 262 | void setModified(); |
263 | /** | 263 | /** |
264 | Marks the address book as modified without refreshing the view. | 264 | Marks the address book as modified without refreshing the view. |
265 | */ | 265 | */ |
266 | void setModifiedWOrefresh(); | 266 | void setModifiedWOrefresh(); |
267 | 267 | ||
268 | /** | 268 | /** |
269 | Marks the address book as modified concerning the argument. | 269 | Marks the address book as modified concerning the argument. |
270 | */ | 270 | */ |
271 | void setModified( bool modified ); | 271 | void setModified( bool modified ); |
272 | 272 | ||
273 | /** | 273 | /** |
274 | Returns whether the address book is modified. | 274 | Returns whether the address book is modified. |
275 | */ | 275 | */ |
276 | bool modified() const; | 276 | bool modified() const; |
277 | 277 | ||
278 | /** | 278 | /** |
279 | Called whenever an contact is modified in the contact editor | 279 | Called whenever an contact is modified in the contact editor |
280 | dialog or the quick edit. | 280 | dialog or the quick edit. |
281 | */ | 281 | */ |
282 | void contactModified( const KABC::Addressee &addr ); | 282 | void contactModified( const KABC::Addressee &addr ); |
283 | void addrModified( const KABC::Addressee &addr, bool updateDetails = true ); | 283 | void addrModified( const KABC::Addressee &addr, bool updateDetails = true ); |
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 | void openConfigGlobalDialog(); | 330 | void openConfigGlobalDialog(); |
331 | 331 | ||
332 | /** | 332 | /** |
333 | Launches the ldap search dialog. | 333 | Launches the ldap search dialog. |
334 | */ | 334 | */ |
335 | void openLDAPDialog(); | 335 | void openLDAPDialog(); |
336 | 336 | ||
337 | /** | 337 | /** |
338 | Creates a KAddressBookPrinter, which will display the print | 338 | Creates a KAddressBookPrinter, which will display the print |
339 | dialog and do the printing. | 339 | dialog and do the printing. |
340 | */ | 340 | */ |
341 | void print(); | 341 | void print(); |
342 | 342 | ||
343 | /** | 343 | /** |
344 | Registers a new GUI client, so plugins can register its actions. | 344 | Registers a new GUI client, so plugins can register its actions. |
345 | */ | 345 | */ |
346 | void addGUIClient( KXMLGUIClient *client ); | 346 | void addGUIClient( KXMLGUIClient *client ); |
347 | 347 | ||
348 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); | 348 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); |
349 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); | 349 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); |
350 | void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); | 350 | void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); |
351 | 351 | ||
352 | 352 | ||
353 | signals: | 353 | signals: |
354 | void contactSelected( const QString &name ); | 354 | void contactSelected( const QString &name ); |
355 | void contactSelected( const QPixmap &pixmap ); | 355 | void contactSelected( const QPixmap &pixmap ); |
356 | public slots: | 356 | public slots: |
357 | void loadDataAfterStart(); | 357 | void loadDataAfterStart(); |
358 | void recieve(QString cmsg ); | 358 | void recieve(QString cmsg ); |
359 | void getFile( bool success,const QString & ); | 359 | void getFile( bool success,const QString & ); |
360 | void syncFileRequest(const QString &); | 360 | void syncFileRequest(const QString &); |
361 | void setDetailsVisible( bool visible ); | 361 | void setDetailsVisible( bool visible ); |
362 | void setDetailsToState(); | 362 | void setDetailsToState(); |
363 | 363 | ||
364 | void saveSettings(); | 364 | void saveSettings(); |
365 | 365 | ||
366 | private slots: | 366 | private slots: |
367 | void updateToolBar(); | 367 | void updateToolBar(); |
368 | void updateMainWindow(); | 368 | void updateMainWindow(); |
369 | void receive( const QCString& cmsg, const QByteArray& data ); | 369 | void receive( const QCString& cmsg, const QByteArray& data ); |
370 | void receiveStart( const QCString& cmsg, const QByteArray& data ); | 370 | void receiveStart( const QCString& cmsg, const QByteArray& data ); |
371 | void toggleBeamReceive( ); | 371 | void toggleBeamReceive( ); |
372 | void disableBR(bool); | 372 | void disableBR(bool); |
373 | void setJumpButtonBarVisible( bool visible ); | 373 | void setJumpButtonBarVisible( bool visible ); |
374 | void setJumpButtonBar( bool visible ); | 374 | void setJumpButtonBar( bool visible ); |
375 | void setCaptionBack(); | 375 | void setCaptionBack(); |
376 | void resizeAndCallContactdialog(); | 376 | void resizeAndCallContactdialog(); |
377 | void callContactdialog(); | 377 | void callContactdialog(); |
378 | void doRingSync(); | 378 | void doRingSync(); |
379 | 379 | ||
380 | void importFromOL(); | 380 | void importFromOL(); |
381 | void extensionModified( const KABC::Addressee::List &list ); | 381 | void extensionModified( const KABC::Addressee::List &list ); |
382 | void extensionChanged( int id ); | 382 | void extensionChanged( int id ); |
383 | void clipboardDataChanged(); | 383 | void clipboardDataChanged(); |
384 | void updateActionMenu(); | 384 | void updateActionMenu(); |
385 | void configureKeyBindings(); | 385 | void configureKeyBindings(); |
386 | void removeVoice(); | 386 | void removeVoice(); |
387 | void setFormattedName(); | 387 | void setFormattedName(); |
388 | #ifdef KAB_EMBEDDED | 388 | #ifdef KAB_EMBEDDED |
389 | void configureResources(); | 389 | void configureResources(); |
390 | #endif //KAB_EMBEDDED | 390 | #endif //KAB_EMBEDDED |
391 | 391 | ||
392 | void slotEditorDestroyed( const QString &uid ); | 392 | void slotEditorDestroyed( const QString &uid ); |
393 | void configurationChanged(); | 393 | void configurationChanged(); |
394 | void addressBookChanged(); | 394 | void addressBookChanged(); |
395 | 395 | ||
396 | private: | 396 | private: |
397 | QCString mCStringMess; | 397 | QCString mCStringMess; |
398 | QByteArray mByteData; | 398 | QByteArray mByteData; |
399 | QString mEmailSourceChannel; | 399 | QString mEmailSourceChannel; |
400 | QString mEmailSourceUID; | 400 | QString mEmailSourceUID; |
401 | void resizeEvent(QResizeEvent* e ); | 401 | void resizeEvent(QResizeEvent* e ); |
402 | bool mBRdisabled; | 402 | bool mBRdisabled; |
403 | #ifndef DESKTOP_VERSION | 403 | #ifndef DESKTOP_VERSION |
404 | QCopChannel* infrared; | 404 | QCopChannel* infrared; |
405 | #endif | 405 | #endif |
406 | QTimer *mMessageTimer; | 406 | QTimer *mMessageTimer; |
407 | void initGUI(); | 407 | void initGUI(); |
408 | void initActions(); | 408 | void initActions(); |
409 | QString getPhoneFile(); | 409 | QString getPhoneFile(); |
410 | 410 | ||
411 | AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, | 411 | AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, |
412 | const char *name = 0 ); | 412 | const char *name = 0 ); |
413 | 413 | ||
414 | KXMLGUIClient *mGUIClient; | 414 | KXMLGUIClient *mGUIClient; |
415 | 415 | ||
416 | KABC::AddressBook *mAddressBook; | 416 | KABC::AddressBook *mAddressBook; |
417 | 417 | ||
418 | ViewManager *mViewManager; | 418 | ViewManager *mViewManager; |
419 | // QSplitter *mDetailsSplitter; | 419 | // QSplitter *mDetailsSplitter; |
420 | KDGanttMinimizeSplitter *mExtensionBarSplitter; | 420 | KDGanttMinimizeSplitter *mExtensionBarSplitter; |
421 | ViewContainer *mDetails; | 421 | ViewContainer *mDetails; |
422 | KDGanttMinimizeSplitter* mMiniSplitter; | 422 | KDGanttMinimizeSplitter* mMiniSplitter; |
423 | XXPortManager *mXXPortManager; | 423 | XXPortManager *mXXPortManager; |
424 | JumpButtonBar *mJumpButtonBar; | 424 | JumpButtonBar *mJumpButtonBar; |
425 | IncSearchWidget *mIncSearchWidget; | 425 | IncSearchWidget *mIncSearchWidget; |
426 | ExtensionManager *mExtensionManager; | 426 | ExtensionManager *mExtensionManager; |
427 | 427 | ||
428 | KCMultiDialog *mConfigureDialog; | 428 | KCMultiDialog *mConfigureDialog; |
429 | 429 | ||
430 | #ifndef KAB_EMBEDDED | 430 | #ifndef KAB_EMBEDDED |
431 | LDAPSearchDialog *mLdapSearchDialog; | 431 | LDAPSearchDialog *mLdapSearchDialog; |
432 | #endif //KAB_EMBEDDED | 432 | #endif //KAB_EMBEDDED |
433 | // QDict<AddresseeEditorDialog> mEditorDict; | 433 | // QDict<AddresseeEditorDialog> mEditorDict; |
434 | AddresseeEditorDialog *mEditorDialog; | 434 | AddresseeEditorDialog *mEditorDialog; |
435 | bool mReadWrite; | 435 | bool mReadWrite; |
436 | bool mModified; | 436 | bool mModified; |
437 | bool mIsPart; | 437 | bool mIsPart; |
438 | bool mMultipleViewsAtOnce; | 438 | bool mMultipleViewsAtOnce; |
439 | 439 | ||
440 | 440 | ||
441 | //US file menu | 441 | //US file menu |
442 | KAction *mActionMail; | 442 | KAction *mActionMail; |
443 | KAction *mActionBeam; | 443 | KAction *mActionBeam; |
444 | KToggleAction *mActionBR; | 444 | KToggleAction *mActionBR; |
445 | KAction *mActionExport2phone; | 445 | KAction *mActionExport2phone; |
446 | KAction* mActionPrint; | 446 | KAction* mActionPrint; |
447 | KAction* mActionPrintDetails; | 447 | KAction* mActionPrintDetails; |
448 | KAction* mActionNewContact; | 448 | KAction* mActionNewContact; |
449 | KAction *mActionSave; | 449 | KAction *mActionSave; |
450 | KAction *mActionEditAddressee; | 450 | KAction *mActionEditAddressee; |
451 | KAction *mActionMailVCard; | 451 | KAction *mActionMailVCard; |
452 | KAction *mActionBeamVCard; | 452 | KAction *mActionBeamVCard; |
453 | 453 | ||
454 | KAction *mActionQuit; | 454 | KAction *mActionQuit; |
455 | 455 | ||
456 | //US edit menu | 456 | //US edit menu |
457 | KAction *mActionCopy; | 457 | KAction *mActionCopy; |
458 | KAction *mActionCut; | 458 | KAction *mActionCut; |
459 | KAction *mActionPaste; | 459 | KAction *mActionPaste; |
460 | KAction *mActionSelectAll; | 460 | KAction *mActionSelectAll; |
461 | KAction *mActionUndo; | 461 | KAction *mActionUndo; |
462 | KAction *mActionRedo; | 462 | KAction *mActionRedo; |
463 | KAction *mActionDelete; | 463 | KAction *mActionDelete; |
464 | 464 | ||
465 | //US settings menu | 465 | //US settings menu |
466 | KAction *mActionConfigResources; | 466 | KAction *mActionConfigResources; |
467 | KAction *mActionConfigGlobal; | 467 | KAction *mActionConfigGlobal; |
468 | KAction *mActionConfigKAddressbook; | 468 | KAction *mActionConfigKAddressbook; |
469 | KAction *mActionConfigShortcuts; | 469 | KAction *mActionConfigShortcuts; |
470 | KAction *mActionConfigureToolbars; | 470 | KAction *mActionConfigureToolbars; |
471 | KAction *mActionKeyBindings; | 471 | KAction *mActionKeyBindings; |
472 | KToggleAction *mActionJumpBar; | 472 | KToggleAction *mActionJumpBar; |
473 | KToggleAction *mActionDetails; | 473 | KToggleAction *mActionDetails; |
474 | KAction *mActionWhoAmI; | 474 | KAction *mActionWhoAmI; |
475 | KAction *mActionCategories; | 475 | KAction *mActionCategories; |
476 | KAction *mActionEditCategories; | 476 | KAction *mActionEditCategories; |
477 | KAction *mActionManageCategories; | 477 | KAction *mActionManageCategories; |
478 | KAction *mActionAboutKAddressbook; | 478 | KAction *mActionAboutKAddressbook; |
479 | KAction *mActionLicence; | 479 | KAction *mActionLicence; |
480 | KAction *mActionFaq; | 480 | KAction *mActionFaq; |
481 | KAction *mActionWN; | 481 | KAction *mActionWN; |
482 | KAction *mActionSyncHowto; | 482 | KAction *mActionSyncHowto; |
483 | KAction *mActionStorageHowto; | 483 | KAction *mActionStorageHowto; |
484 | KAction *mActionKdeSyncHowto; | 484 | KAction *mActionKdeSyncHowto; |
485 | KAction *mActionMultiSyncHowto; | 485 | KAction *mActionMultiSyncHowto; |
486 | 486 | ||
487 | KAction *mActionDeleteView; | 487 | KAction *mActionDeleteView; |
488 | 488 | ||
489 | QPopupMenu *viewMenu; | 489 | QPopupMenu *viewMenu; |
490 | QPopupMenu *filterMenu; | 490 | QPopupMenu *filterMenu; |
491 | QPopupMenu *settingsMenu; | 491 | QPopupMenu *settingsMenu; |
492 | QPopupMenu *changeMenu; | 492 | QPopupMenu *changeMenu; |
493 | QPopupMenu *beamMenu; | 493 | QPopupMenu *beamMenu; |
494 | //US QAction *mActionSave; | 494 | //US QAction *mActionSave; |
495 | QPopupMenu *ImportMenu; | 495 | QPopupMenu *ImportMenu; |
496 | QPopupMenu *ExportMenu; | 496 | QPopupMenu *ExportMenu; |
497 | //LR additional methods | 497 | //LR additional methods |
498 | KAction *mActionRemoveVoice; | 498 | KAction *mActionRemoveVoice; |
499 | KAction *mActionSetFormattedName; | 499 | KAction *mActionSetFormattedName; |
500 | KAction * mActionImportOL; | 500 | KAction * mActionImportOL; |
501 | 501 | ||
502 | #ifndef KAB_EMBEDDED | 502 | #ifndef KAB_EMBEDDED |
503 | KAddressBookService *mAddressBookService; | 503 | KAddressBookService *mAddressBookService; |
504 | #endif //KAB_EMBEDDED | 504 | #endif //KAB_EMBEDDED |
505 | 505 | ||
506 | class KABCorePrivate; | 506 | class KABCorePrivate; |
507 | KABCorePrivate *d; | 507 | KABCorePrivate *d; |
508 | //US bool mBlockSaveFlag; | 508 | //US bool mBlockSaveFlag; |
509 | 509 | ||
510 | #ifdef KAB_EMBEDDED | 510 | #ifdef KAB_EMBEDDED |
511 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient | 511 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient |
512 | #endif //KAB_EMBEDDED | 512 | #endif //KAB_EMBEDDED |
513 | 513 | ||
514 | //this are the overwritten callbackmethods from the syncinterface | 514 | //this are the overwritten callbackmethods from the syncinterface |
515 | virtual bool sync(KSyncManager* manager, QString filename, int mode,QString resource); | 515 | virtual bool sync(KSyncManager* manager, QString filename, int mode,QString resource); |
516 | virtual bool syncExternal(KSyncManager* manager, QString resource); | 516 | virtual bool syncExternal(KSyncManager* manager, QString resource); |
517 | virtual void removeSyncInfo( QString syncProfile); | 517 | virtual void removeSyncInfo( QString syncProfile); |
518 | bool readOLdata( KABC::AddressBook* local ); | ||
519 | bool writeOLdata( KABC::AddressBook* local ); | ||
520 | bool syncOL(); | ||
518 | bool syncPhone(); | 521 | bool syncPhone(); |
519 | void message( QString m , bool startTimer = true); | 522 | void message( QString m , bool startTimer = true); |
520 | 523 | ||
521 | // LR ******************************* | 524 | // LR ******************************* |
522 | // sync stuff! | 525 | // sync stuff! |
523 | QString sentSyncFile(); | 526 | QString sentSyncFile(); |
524 | QPopupMenu *syncMenu; | 527 | QPopupMenu *syncMenu; |
525 | KSyncManager* syncManager; | 528 | KSyncManager* syncManager; |
526 | int mGlobalSyncMode; | 529 | int mGlobalSyncMode; |
527 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); | 530 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); |
528 | KABC::Addressee getLastSyncAddressee(); | 531 | KABC::Addressee getLastSyncAddressee(); |
529 | QDateTime mLastAddressbookSync; | 532 | QDateTime mLastAddressbookSync; |
530 | int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); | 533 | int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); |
531 | // ********************* | 534 | // ********************* |
535 | //OL sync stuff | ||
536 | QString mOLsyncFolderID; | ||
532 | 537 | ||
533 | }; | 538 | }; |
534 | 539 | ||
535 | #endif | 540 | #endif |
diff --git a/kaddressbook/kaimportoldialog.cpp b/kaddressbook/kaimportoldialog.cpp index 2f794d6..6afc288 100644 --- a/kaddressbook/kaimportoldialog.cpp +++ b/kaddressbook/kaimportoldialog.cpp | |||
@@ -1,735 +1,23 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressbook/Pi. | 2 | This file is part of KAddressbook/Pi. |
3 | Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> | 3 | Copyright (c) 2004 Lutz Rogowski <rogowski@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 | #include <qtooltip.h> | ||
25 | #include <qframe.h> | ||
26 | #include <qpixmap.h> | ||
27 | #include <qlayout.h> | ||
28 | #include <qprogressbar.h> | ||
29 | #include <qprogressdialog.h> | ||
30 | #include <qwidgetstack.h> | ||
31 | #include <qdatetime.h> | ||
32 | #include <qdir.h> | ||
33 | #include <qregexp.h> | ||
34 | #include <qapplication.h> | ||
35 | #include <qhbox.h> | ||
36 | #include <qheader.h> | ||
37 | #include <qdatetime.h> | ||
38 | #include <qlistview.h> | ||
39 | |||
40 | #include <kdebug.h> | ||
41 | #include <klocale.h> | ||
42 | #include <kstandarddirs.h> | ||
43 | #include <kmessagebox.h> | ||
44 | #include <kfiledialog.h> | ||
45 | |||
46 | #include <libkdepim/categoryselectdialog.h> | ||
47 | #include <libkdepim/kinputdialog.h> | ||
48 | |||
49 | #include <libkcal/calendarlocal.h> | ||
50 | #include <libkcal/icalformat.h> | ||
51 | |||
52 | #include <kabc/addresseelist.h> | ||
53 | #include <kabc/phonenumber.h> | ||
54 | |||
55 | #include "kaimportoldialog.h" | ||
56 | |||
57 | #include "../outport/msoutl9.h" | ||
58 | #include <ole2.h> | ||
59 | #include <comutil.h> | ||
60 | _Application gOlAppAB; | ||
61 | |||
62 | QDateTime mDdate2Qdtr( DATE dt) | ||
63 | { | ||
64 | COleDateTime odt; | ||
65 | SYSTEMTIME st; | ||
66 | odt = dt; | ||
67 | if ( odt.GetStatus() != 0 ) | ||
68 | return QDateTime(); | ||
69 | odt.GetAsSystemTime(st); | ||
70 | if ( st.wYear > 4000 ) // this program as a year 4000 bug! | ||
71 | return QDateTime(); | ||
72 | // it seems so, that 1.1.4501 indicates: DATE invalid | ||
73 | QDateTime qdt (QDate(st.wYear, st.wMonth,st.wDay ),QTime( st.wHour, st.wMinute,st.wSecond ) ); | ||
74 | return qdt; | ||
75 | } | ||
76 | |||
77 | class OLEListViewItem : public QCheckListItem | ||
78 | { | ||
79 | public: | ||
80 | OLEListViewItem( QListView *parent, QString text ) : | ||
81 | QCheckListItem( parent, text, QCheckListItem::CheckBox ) { ; }; | ||
82 | OLEListViewItem( QListViewItem *after, QString text ) : | ||
83 | QCheckListItem( after, text, QCheckListItem::CheckBox ) { ; }; | ||
84 | ~OLEListViewItem() {}; | ||
85 | void setData( DWORD data ) {mData= data; }; | ||
86 | DWORD data() { return mData ;}; | ||
87 | private: | ||
88 | DWORD mData; | ||
89 | }; | ||
90 | |||
91 | KAImportOLdialog::KAImportOLdialog( const QString &caption, | ||
92 | KABC::AddressBook * aBook, QWidget *parent ) : | ||
93 | KDialogBase( Plain, caption, User1 | Close, Ok, | ||
94 | parent, caption, true, false, i18n("Import!") ) | ||
95 | { | ||
96 | QHBox * mw = new QHBox( this ); | ||
97 | setMainWidget( mw ); | ||
98 | mListView = new QListView( mw ); | ||
99 | mListView->addColumn(i18n("Select Folder to import")); | ||
100 | mListView->addColumn(i18n("Content Type")); | ||
101 | mABook = aBook; | ||
102 | connect( this, SIGNAL( user1Clicked() ),SLOT ( slotApply())); | ||
103 | setupFolderView(); | ||
104 | resize( sizeHint().width()+50, sizeHint().height()+50 ); | ||
105 | } | ||
106 | |||
107 | KAImportOLdialog::~KAImportOLdialog() | ||
108 | { | ||
109 | |||
110 | } | ||
111 | |||
112 | KABC::Addressee::List KAImportOLdialog::getAddressList() | ||
113 | { | ||
114 | return mAList; | ||
115 | } | ||
116 | void KAImportOLdialog::setupFolderView() | ||
117 | { | ||
118 | SCODE sc = ::OleInitialize(NULL); | ||
119 | if ( FAILED ( sc ) ) { | ||
120 | KMessageBox::information(this,"OLE initialisation failed"); | ||
121 | return; | ||
122 | } | ||
123 | |||
124 | if(!gOlAppAB.CreateDispatch(_T("Outlook.Application"),NULL)){ | ||
125 | KMessageBox::information(this,"Sorry, cannot access Outlook"); | ||
126 | return ; | ||
127 | } | ||
128 | MAPIFolder mfInbox; | ||
129 | MAPIFolder mfRoot; | ||
130 | CString szName; | ||
131 | _NameSpace olNS; | ||
132 | olNS = gOlAppAB.GetNamespace(_T("MAPI")); | ||
133 | mfInbox = olNS.GetDefaultFolder(6); | ||
134 | mfRoot = mfInbox.GetParent(); | ||
135 | szName = mfRoot.GetName(); | ||
136 | long iType = mfRoot.GetDefaultItemType(); | ||
137 | QString mes; | ||
138 | mes = QString::fromUcs2( szName.GetBuffer() ); | ||
139 | OLEListViewItem * root = new OLEListViewItem( mListView, mes ); | ||
140 | mfRoot.m_lpDispatch->AddRef(); | ||
141 | addFolder( root, mfRoot.m_lpDispatch ); | ||
142 | root->setOpen( true ); | ||
143 | mListView->setSortColumn( 0 ); | ||
144 | mListView->sort( ); | ||
145 | } | ||
146 | |||
147 | |||
148 | void KAImportOLdialog::addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent) | ||
149 | { | ||
150 | MAPIFolder mfParent(dispParent), mfChild; | ||
151 | _Folders folders; | ||
152 | _variant_t fndx((long)0); | ||
153 | CString szName; | ||
154 | long iType; | ||
155 | OLEListViewItem* hChild; | ||
156 | |||
157 | folders = mfParent.GetFolders(); | ||
158 | for(int i=1; i <= folders.GetCount(); ++i) | ||
159 | { | ||
160 | fndx = (long)i; | ||
161 | mfChild = folders.Item(fndx.Detach()); | ||
162 | mfChild.m_lpDispatch->AddRef(); | ||
163 | szName = mfChild.GetName(); | ||
164 | iType = mfChild.GetDefaultItemType(); | ||
165 | hChild = new OLEListViewItem( iParent , QString::fromUcs2( szName.GetBuffer() ) ); | ||
166 | if ( iType != 2) | ||
167 | hChild->setEnabled( false ); | ||
168 | QString ts; | ||
169 | switch( iType ) { | ||
170 | case 0: | ||
171 | ts = i18n("Mail"); | ||
172 | break; | ||
173 | case 1: | ||
174 | ts = i18n("Calendar"); | ||
175 | break; | ||
176 | case 2: | ||
177 | ts = i18n("Contacts"); | ||
178 | break; | ||
179 | case 3: | ||
180 | ts = i18n("Todos"); | ||
181 | break; | ||
182 | case 4: | ||
183 | ts = i18n("Journals"); | ||
184 | break; | ||
185 | case 5: | ||
186 | ts = i18n("Notes"); | ||
187 | break; | ||
188 | default: | ||
189 | ts = i18n("Unknown"); | ||
190 | } | ||
191 | hChild->setText( 1,ts); | ||
192 | hChild->setData( (DWORD) mfChild.m_lpDispatch ); | ||
193 | mfChild.m_lpDispatch->AddRef(); | ||
194 | addFolder(hChild, mfChild.m_lpDispatch); | ||
195 | } | ||
196 | } | ||
197 | |||
198 | void KAImportOLdialog::slotApply() | ||
199 | { | ||
200 | importedItems = 0; | ||
201 | OLEListViewItem* child = (OLEListViewItem*) mListView->firstChild(); | ||
202 | while ( child ) { | ||
203 | if ( child->isOn() ) | ||
204 | readContactData( child->data() ); | ||
205 | child = (OLEListViewItem*) child->itemBelow(); | ||
206 | } | ||
207 | QString mes = i18n("Importing complete.\n\n%1 items imported.").arg( importedItems); | ||
208 | KMessageBox::information(this,mes); | ||
209 | } | ||
210 | void KAImportOLdialog::readContactData( DWORD folder ) | ||
211 | { | ||
212 | |||
213 | LPDISPATCH dispItem = (LPDISPATCH)folder; | ||
214 | dispItem->AddRef(); | ||
215 | MAPIFolder mf(dispItem); | ||
216 | mf.m_lpDispatch->AddRef(); | ||
217 | _Items folderItems; | ||
218 | _variant_t indx((long)0); | ||
219 | LPDISPATCH itm; | ||
220 | int i; | ||
221 | folderItems = mf.GetItems(); | ||
222 | QProgressDialog bar( i18n("Importing contact data"),i18n("Abort"), folderItems.GetCount(),this); | ||
223 | bar.setCaption (i18n("Importing!") ); | ||
224 | int h = bar.sizeHint().height() ; | ||
225 | int w = 300; | ||
226 | int dw = QApplication::desktop()->width(); | ||
227 | int dh = QApplication::desktop()->height(); | ||
228 | //bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | ||
229 | bar.show(); | ||
230 | for(i=1; i <= folderItems.GetCount(); ++i) | ||
231 | { | ||
232 | qApp->processEvents(); | ||
233 | if ( ! bar.isVisible() ) | ||
234 | return ; | ||
235 | bar.setProgress( i ); | ||
236 | indx = (long)i; | ||
237 | itm = folderItems.Item(indx.Detach()); | ||
238 | _ContactItem * pItem = (_ContactItem *)&itm; | ||
239 | ol2kapiContact( pItem ); | ||
240 | itm->Release(); | ||
241 | } | ||
242 | } | ||
243 | void KAImportOLdialog::slotOk() | ||
244 | { | ||
245 | QDialog::accept(); | ||
246 | } | ||
247 | |||
248 | void KAImportOLdialog::ol2kapiContact( _ContactItem * aItem ) | ||
249 | { | ||
250 | KABC::Addressee addressee; | ||
251 | |||
252 | addressee.setUid( QString::fromUcs2(aItem->GetEntryID().GetBuffer())); | ||
253 | //GetLastModificationTime() | ||
254 | //addressee.setName( const QString &name ); | ||
255 | //addressee.setFormattedName( const QString &formattedName ); | ||
256 | addressee.setFamilyName( QString::fromUcs2(aItem->GetLastName().GetBuffer()) ); | ||
257 | addressee.setGivenName( QString::fromUcs2(aItem->GetFirstName().GetBuffer()) ); | ||
258 | addressee.setAdditionalName( QString::fromUcs2(aItem->GetMiddleName().GetBuffer()) ); | ||
259 | addressee.setPrefix(QString::fromUcs2(aItem->GetTitle().GetBuffer()) ); | ||
260 | addressee.setSuffix( QString::fromUcs2(aItem->GetSuffix().GetBuffer()) ); | ||
261 | addressee.setNickName( QString::fromUcs2(aItem->GetNickName().GetBuffer()) ); | ||
262 | QDateTime dtb = mDdate2Qdtr(aItem->GetBirthday()); | ||
263 | if ( dtb.isValid() ) | ||
264 | addressee.setBirthday( mDdate2Qdtr(aItem->GetBirthday())); | ||
265 | |||
266 | //QString::fromUcs2(aItem->.GetBuffer()) | ||
267 | //addressee.setMailer( const QString &mailer ); | ||
268 | //addressee.setTimeZone( const TimeZone &timeZone ); | ||
269 | //addressee.setGeo( const Geo &geo ); | ||
270 | //addressee.setTitle( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) );// titel is the prefix | ||
271 | addressee.setRole( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) ); | ||
272 | addressee.setOrganization( QString::fromUcs2(aItem->GetCompanyName().GetBuffer()).replace( QRegExp("\\r"), "") ); | ||
273 | QString notesStr = QString::fromUcs2(aItem->GetBody().GetBuffer()); | ||
274 | notesStr.replace( QRegExp("\\r"), ""); | ||
275 | |||
276 | addressee.setProductId( QString::fromUcs2(aItem->GetCustomerID().GetBuffer()) ); | ||
277 | //addressee.setRevision( const QDateTime &revision ); | ||
278 | // addressee.setSortString( const QString &sortString ); | ||
279 | addressee.setUrl( QString::fromUcs2(aItem->GetWebPage().GetBuffer()) ); | ||
280 | |||
281 | QString tempS; | ||
282 | tempS = QString::fromUcs2(aItem->GetNetMeetingAlias().GetBuffer())+" AT SERVER: " +QString::fromUcs2(aItem->GetNetMeetingServer().GetBuffer()); | ||
283 | if ( tempS.length() > 12 ) | ||
284 | addressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", tempS ); | ||
285 | tempS = QString::fromUcs2(aItem->GetSpouse().GetBuffer()); | ||
286 | if ( !tempS.isEmpty() ) | ||
287 | addressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", tempS ); | ||
288 | tempS = QString::fromUcs2(aItem->GetManagerName().GetBuffer()); | ||
289 | if ( !tempS.isEmpty() ) | ||
290 | addressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", tempS ); | ||
291 | tempS = QString::fromUcs2(aItem->GetAssistantName().GetBuffer()); | ||
292 | if ( !tempS.isEmpty() ) | ||
293 | addressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", tempS ); | ||
294 | tempS = QString::fromUcs2(aItem->GetDepartment().GetBuffer()); | ||
295 | if ( !tempS.isEmpty() ) | ||
296 | addressee.insertCustom( "KADDRESSBOOK", "X-Department", tempS ); | ||
297 | tempS = QString::fromUcs2(aItem->GetOfficeLocation().GetBuffer()).replace( QRegExp("\\r"), ""); | ||
298 | if ( !tempS.isEmpty() ) | ||
299 | addressee.insertCustom( "KADDRESSBOOK", "X-Office",tempS ); | ||
300 | tempS = QString::fromUcs2(aItem->GetProfession().GetBuffer()); | ||
301 | if ( !tempS.isEmpty() ) | ||
302 | addressee.insertCustom( "KADDRESSBOOK", "X-Profession", tempS ); | ||
303 | dtb = mDdate2Qdtr(aItem->GetAnniversary()); | ||
304 | if (dtb.isValid() ) { | ||
305 | QString dt = KGlobal::locale()->formatDate( dtb.date() , true, KLocale::ISODate); | ||
306 | addressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); | ||
307 | } | ||
308 | int sec = aItem->GetSensitivity() ; | ||
309 | if ( sec > 1 )// mapping pers -> private | ||
310 | --sec; | ||
311 | addressee.setSecrecy( sec ); | ||
312 | //addressee.setLogo( const Picture &logo ); | ||
313 | //addressee.setPhoto( const Picture &photo ); | ||
314 | //addressee.setSound( const Sound &sound ); | ||
315 | //addressee.setAgent( const Agent &agent ); | ||
316 | QString cat = QString::fromUcs2( aItem->GetCategories().GetBuffer()).replace( QRegExp("\\r"), ""); | ||
317 | cat = cat.replace( QRegExp("; "), ";"); | ||
318 | addressee.setCategories( QStringList::split( ";", cat )); | ||
319 | |||
320 | QString phoneS; | ||
321 | |||
322 | phoneS = QString::fromUcs2( aItem->GetAssistantTelephoneNumber().GetBuffer()); | ||
323 | if ( ! phoneS.isEmpty()) | ||
324 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work + KABC::PhoneNumber::Voice ) ); | ||
325 | phoneS = QString::fromUcs2( aItem->GetBusinessTelephoneNumber().GetBuffer()); | ||
326 | if ( ! phoneS.isEmpty()) | ||
327 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work ) ); | ||
328 | phoneS = QString::fromUcs2( aItem->GetBusiness2TelephoneNumber().GetBuffer()); | ||
329 | if ( ! phoneS.isEmpty()) | ||
330 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work ) ); | ||
331 | phoneS = QString::fromUcs2( aItem->GetBusinessFaxNumber().GetBuffer()); | ||
332 | if ( ! phoneS.isEmpty()) | ||
333 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work + KABC::PhoneNumber::Fax ) ); | ||
334 | phoneS = QString::fromUcs2( aItem->GetCarTelephoneNumber().GetBuffer()); | ||
335 | if ( ! phoneS.isEmpty()) | ||
336 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Car ) ); | ||
337 | phoneS = QString::fromUcs2( aItem->GetHomeTelephoneNumber().GetBuffer()); | ||
338 | if ( ! phoneS.isEmpty()) | ||
339 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Home ) ); | ||
340 | phoneS = QString::fromUcs2( aItem->GetHome2TelephoneNumber().GetBuffer()); | ||
341 | if ( ! phoneS.isEmpty()) | ||
342 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Home ) ); | ||
343 | phoneS = QString::fromUcs2( aItem->GetHomeFaxNumber().GetBuffer()); | ||
344 | if ( ! phoneS.isEmpty()) | ||
345 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Home + KABC::PhoneNumber::Fax ) ); | ||
346 | phoneS = QString::fromUcs2( aItem->GetISDNNumber().GetBuffer()); | ||
347 | if ( ! phoneS.isEmpty()) | ||
348 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Isdn ) ); | ||
349 | phoneS = QString::fromUcs2( aItem->GetMobileTelephoneNumber().GetBuffer()); | ||
350 | if ( ! phoneS.isEmpty()) | ||
351 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Cell ) ); | ||
352 | phoneS = QString::fromUcs2( aItem->GetOtherFaxNumber().GetBuffer()); | ||
353 | if ( ! phoneS.isEmpty()) | ||
354 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Fax ) ); | ||
355 | phoneS = QString::fromUcs2( aItem->GetOtherTelephoneNumber().GetBuffer()); | ||
356 | if ( ! phoneS.isEmpty()) | ||
357 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Voice ) ); | ||
358 | phoneS = QString::fromUcs2( aItem->GetPagerNumber().GetBuffer()); | ||
359 | if ( ! phoneS.isEmpty()) | ||
360 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Pager ) ); | ||
361 | phoneS = QString::fromUcs2( aItem->GetPrimaryTelephoneNumber().GetBuffer()); | ||
362 | if ( ! phoneS.isEmpty()) | ||
363 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Pref ) ); | ||
364 | phoneS = QString::fromUcs2( aItem->GetTTYTDDTelephoneNumber().GetBuffer()); | ||
365 | if ( ! phoneS.isEmpty()) | ||
366 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Modem ) ); | ||
367 | phoneS = QString::fromUcs2( aItem->GetTelexNumber().GetBuffer()); | ||
368 | if ( ! phoneS.isEmpty()) | ||
369 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Fax + KABC::PhoneNumber::Bbs ) ); | ||
370 | phoneS = QString::fromUcs2( aItem->GetCompanyMainTelephoneNumber().GetBuffer()); | ||
371 | if ( ! phoneS.isEmpty()) | ||
372 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work + KABC::PhoneNumber::Pref ) ); | ||
373 | phoneS = QString::fromUcs2( aItem->GetRadioTelephoneNumber().GetBuffer()); | ||
374 | if ( ! phoneS.isEmpty()) | ||
375 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Video ) ); | ||
376 | phoneS = QString::fromUcs2( aItem->GetCallbackTelephoneNumber().GetBuffer()); | ||
377 | if ( ! phoneS.isEmpty()) | ||
378 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Voice + KABC::PhoneNumber::Pref ) ); | ||
379 | |||
380 | bool preferred = true; | ||
381 | phoneS = QString::fromUcs2( aItem->GetEmail1Address().GetBuffer()); | ||
382 | if ( ! phoneS.isEmpty()) { | ||
383 | addressee.insertEmail(phoneS , preferred ); | ||
384 | preferred = false; | ||
385 | } | ||
386 | phoneS = QString::fromUcs2( aItem->GetEmail2Address().GetBuffer()); | ||
387 | if ( ! phoneS.isEmpty()) { | ||
388 | addressee.insertEmail(phoneS , preferred ); | ||
389 | preferred = false; | ||
390 | } | ||
391 | phoneS = QString::fromUcs2( aItem->GetEmail3Address().GetBuffer()); | ||
392 | if ( ! phoneS.isEmpty()) { | ||
393 | addressee.insertEmail(phoneS , preferred ); | ||
394 | preferred = false; | ||
395 | } | ||
396 | // is this the number of the preferred email? | ||
397 | //long GetSelectedMailingAddress();??? | ||
398 | |||
399 | KABC::Address addressHome; | ||
400 | KABC::Address* addressAdd = &addressHome; | ||
401 | bool insert = false; | ||
402 | phoneS = QString::fromUcs2( aItem->GetHomeAddressCountry().GetBuffer()); | ||
403 | phoneS.replace( QRegExp("\\r"), ""); | ||
404 | if ( ! phoneS.isEmpty()) { | ||
405 | addressAdd->setCountry(phoneS ); | ||
406 | insert = true; | ||
407 | } | ||
408 | phoneS = QString::fromUcs2( aItem->GetHomeAddressState().GetBuffer()); | ||
409 | phoneS.replace( QRegExp("\\r"), ""); | ||
410 | if ( ! phoneS.isEmpty()) { | ||
411 | addressAdd->setRegion(phoneS ); | ||
412 | insert = true; | ||
413 | } | ||
414 | phoneS = QString::fromUcs2( aItem->GetHomeAddressCity().GetBuffer()); | ||
415 | phoneS.replace( QRegExp("\\r"), ""); | ||
416 | if ( ! phoneS.isEmpty()) { | ||
417 | addressAdd->setLocality(phoneS ); | ||
418 | insert = true; | ||
419 | } | ||
420 | phoneS = QString::fromUcs2( aItem->GetHomeAddressPostalCode().GetBuffer()); | ||
421 | phoneS.replace( QRegExp("\\r"), ""); | ||
422 | if ( ! phoneS.isEmpty()) { | ||
423 | addressAdd->setPostalCode(phoneS ); | ||
424 | insert = true; | ||
425 | } | ||
426 | phoneS = QString::fromUcs2( aItem->GetHomeAddressPostOfficeBox().GetBuffer()); | ||
427 | phoneS.replace( QRegExp("\\r"), ""); | ||
428 | if ( ! phoneS.isEmpty()) { | ||
429 | addressAdd->setPostOfficeBox(phoneS ); | ||
430 | insert = true; | ||
431 | } | ||
432 | phoneS = QString::fromUcs2( aItem->GetHomeAddressStreet().GetBuffer()); | ||
433 | phoneS.replace( QRegExp("\\r"), ""); | ||
434 | if ( ! phoneS.isEmpty()) { | ||
435 | addressAdd->setStreet(phoneS ); | ||
436 | insert = true; | ||
437 | } | ||
438 | phoneS = QString::fromUcs2( aItem->GetHomeAddress().GetBuffer()); | ||
439 | phoneS.replace( QRegExp("\\r"), ""); | ||
440 | if ( ! phoneS.isEmpty()) { | ||
441 | // redundant !addressAdd->setExtended(phoneS ); | ||
442 | // insert = true; | ||
443 | } | ||
444 | addressAdd->setType( KABC::Address::Home ); | ||
445 | if ( insert ) | ||
446 | addressee.insertAddress( *addressAdd ); | ||
447 | // ++++++++++++++++++++++ end of address | ||
448 | |||
449 | KABC::Address addressWork; | ||
450 | addressAdd = &addressWork; | ||
451 | insert = false; | ||
452 | phoneS = QString::fromUcs2( aItem->GetBusinessAddressCountry().GetBuffer()); | ||
453 | phoneS.replace( QRegExp("\\r"), ""); | ||
454 | if ( ! phoneS.isEmpty()) { | ||
455 | addressAdd->setCountry(phoneS ); | ||
456 | insert = true; | ||
457 | } | ||
458 | phoneS = QString::fromUcs2( aItem->GetBusinessAddressState().GetBuffer()); | ||
459 | phoneS.replace( QRegExp("\\r"), ""); | ||
460 | if ( ! phoneS.isEmpty()) { | ||
461 | addressAdd->setRegion(phoneS ); | ||
462 | insert = true; | ||
463 | } | ||
464 | phoneS = QString::fromUcs2( aItem->GetBusinessAddressCity().GetBuffer()); | ||
465 | phoneS.replace( QRegExp("\\r"), ""); | ||
466 | if ( ! phoneS.isEmpty()) { | ||
467 | addressAdd->setLocality(phoneS ); | ||
468 | insert = true; | ||
469 | } | ||
470 | phoneS = QString::fromUcs2( aItem->GetBusinessAddressPostalCode().GetBuffer()); | ||
471 | phoneS.replace( QRegExp("\\r"), ""); | ||
472 | if ( ! phoneS.isEmpty()) { | ||
473 | addressAdd->setPostalCode(phoneS ); | ||
474 | insert = true; | ||
475 | } | ||
476 | phoneS = QString::fromUcs2( aItem->GetBusinessAddressPostOfficeBox().GetBuffer()); | ||
477 | phoneS.replace( QRegExp("\\r"), ""); | ||
478 | if ( ! phoneS.isEmpty()) { | ||
479 | addressAdd->setPostOfficeBox(phoneS ); | ||
480 | insert = true; | ||
481 | } | ||
482 | phoneS = QString::fromUcs2( aItem->GetBusinessAddressStreet().GetBuffer()); | ||
483 | phoneS.replace( QRegExp("\\r"), ""); | ||
484 | if ( ! phoneS.isEmpty()) { | ||
485 | addressAdd->setStreet(phoneS ); | ||
486 | insert = true; | ||
487 | } | ||
488 | phoneS = QString::fromUcs2( aItem->GetBusinessAddress().GetBuffer()); | ||
489 | phoneS.replace( QRegExp("\\r"), ""); | ||
490 | if ( ! phoneS.isEmpty()) { | ||
491 | // redundant !addressAdd->setExtended(phoneS ); | ||
492 | // insert = true; | ||
493 | } | ||
494 | addressAdd->setType( KABC::Address::Work ); | ||
495 | if ( insert ) | ||
496 | addressee.insertAddress( *addressAdd ); | ||
497 | // ++++++++++++++++++++++ end of address | ||
498 | |||
499 | KABC::Address addressOther; | ||
500 | addressAdd = &addressOther; | ||
501 | insert = false; | ||
502 | phoneS = QString::fromUcs2( aItem->GetOtherAddressCountry().GetBuffer()); | ||
503 | phoneS.replace( QRegExp("\\r"), ""); | ||
504 | if ( ! phoneS.isEmpty()) { | ||
505 | addressAdd->setCountry(phoneS ); | ||
506 | insert = true; | ||
507 | } | ||
508 | phoneS = QString::fromUcs2( aItem->GetOtherAddressState().GetBuffer()); | ||
509 | phoneS.replace( QRegExp("\\r"), ""); | ||
510 | if ( ! phoneS.isEmpty()) { | ||
511 | addressAdd->setRegion(phoneS ); | ||
512 | insert = true; | ||
513 | } | ||
514 | phoneS = QString::fromUcs2( aItem->GetOtherAddressCity().GetBuffer()); | ||
515 | phoneS.replace( QRegExp("\\r"), ""); | ||
516 | if ( ! phoneS.isEmpty()) { | ||
517 | addressAdd->setLocality(phoneS ); | ||
518 | insert = true; | ||
519 | } | ||
520 | phoneS = QString::fromUcs2( aItem->GetOtherAddressPostalCode().GetBuffer()); | ||
521 | phoneS.replace( QRegExp("\\r"), ""); | ||
522 | if ( ! phoneS.isEmpty()) { | ||
523 | addressAdd->setPostalCode(phoneS ); | ||
524 | insert = true; | ||
525 | } | ||
526 | phoneS = QString::fromUcs2( aItem->GetOtherAddressPostOfficeBox().GetBuffer()); | ||
527 | phoneS.replace( QRegExp("\\r"), ""); | ||
528 | if ( ! phoneS.isEmpty()) { | ||
529 | addressAdd->setPostOfficeBox(phoneS ); | ||
530 | insert = true; | ||
531 | } | ||
532 | phoneS = QString::fromUcs2( aItem->GetOtherAddressStreet().GetBuffer()); | ||
533 | phoneS.replace( QRegExp("\\r"), ""); | ||
534 | if ( ! phoneS.isEmpty()) { | ||
535 | addressAdd->setStreet(phoneS ); | ||
536 | insert = true; | ||
537 | } | ||
538 | phoneS = QString::fromUcs2( aItem->GetOtherAddress().GetBuffer()); | ||
539 | if ( ! phoneS.isEmpty()) { | ||
540 | // redundant !addressAdd->setExtended(phoneS ); | ||
541 | //insert = true; | ||
542 | } | ||
543 | //addressAdd->setId( ); | ||
544 | if ( insert ) | ||
545 | addressee.insertAddress( *addressAdd ); | ||
546 | // ++++++++++++++++++++++ end of address | ||
547 | KABC::Address addressMail; | ||
548 | addressAdd = &addressMail; | ||
549 | insert = false; | ||
550 | phoneS = QString::fromUcs2( aItem->GetMailingAddressCountry().GetBuffer()); | ||
551 | phoneS.replace( QRegExp("\\r"), ""); | ||
552 | if ( ! phoneS.isEmpty()) { | ||
553 | addressAdd->setCountry(phoneS ); | ||
554 | insert = true; | ||
555 | } | ||
556 | phoneS = QString::fromUcs2( aItem->GetMailingAddressState().GetBuffer()); | ||
557 | phoneS.replace( QRegExp("\\r"), ""); | ||
558 | if ( ! phoneS.isEmpty()) { | ||
559 | addressAdd->setRegion(phoneS ); | ||
560 | insert = true; | ||
561 | } | ||
562 | phoneS = QString::fromUcs2( aItem->GetMailingAddressCity().GetBuffer()); | ||
563 | phoneS.replace( QRegExp("\\r"), ""); | ||
564 | if ( ! phoneS.isEmpty()) { | ||
565 | addressAdd->setLocality(phoneS ); | ||
566 | insert = true; | ||
567 | } | ||
568 | phoneS = QString::fromUcs2( aItem->GetMailingAddressPostalCode().GetBuffer()); | ||
569 | phoneS.replace( QRegExp("\\r"), ""); | ||
570 | if ( ! phoneS.isEmpty()) { | ||
571 | addressAdd->setPostalCode(phoneS ); | ||
572 | insert = true; | ||
573 | } | ||
574 | phoneS = QString::fromUcs2( aItem->GetMailingAddressPostOfficeBox().GetBuffer()); | ||
575 | phoneS.replace( QRegExp("\\r"), ""); | ||
576 | if ( ! phoneS.isEmpty()) { | ||
577 | addressAdd->setPostOfficeBox(phoneS ); | ||
578 | insert = true; | ||
579 | } | ||
580 | phoneS = QString::fromUcs2( aItem->GetMailingAddressStreet().GetBuffer()); | ||
581 | phoneS.replace( QRegExp("\\r"), ""); | ||
582 | if ( ! phoneS.isEmpty()) { | ||
583 | addressAdd->setStreet(phoneS ); | ||
584 | insert = true; | ||
585 | } | ||
586 | phoneS = QString::fromUcs2( aItem->GetMailingAddress().GetBuffer()); | ||
587 | phoneS.replace( QRegExp("\\r"), ""); | ||
588 | if ( ! phoneS.isEmpty()) { | ||
589 | // redundant ! addressAdd->setExtended(phoneS ); | ||
590 | // insert = true; | ||
591 | } | ||
592 | addressAdd->setType( KABC::Address::Postal ); | ||
593 | if ( insert ) { | ||
594 | addressee.insertAddress( *addressAdd ); | ||
595 | } | ||
596 | // the following code is disabled | ||
597 | // it does not seem to be useful | ||
598 | #if 0 | ||
599 | if ( insert ) { | ||
600 | addressAdd->setType( KABC::Address::Home ); | ||
601 | if ( addressMail == addressHome ) { | ||
602 | addressHome.setType( KABC::Address::Postal+ KABC::Address::Home ); | ||
603 | addressee.insertAddress( addressHome ); | ||
604 | } else { | ||
605 | addressAdd->setType( KABC::Address::Work ); | ||
606 | if ( addressMail == addressWork ){ | ||
607 | addressWork.setType( KABC::Address::Postal+ KABC::Address::Work ); | ||
608 | addressee.insertAddress( addressWork ); | ||
609 | |||
610 | } else { | ||
611 | addressAdd->setType( 0 ); | ||
612 | if ( addressOther == addressMail ){ | ||
613 | addressOther.setType( KABC::Address::Postal ); | ||
614 | addressee.insertAddress( addressOther ); | ||
615 | } else { | ||
616 | addressee.insertAddress( *addressAdd ); | ||
617 | } | ||
618 | } | ||
619 | } | ||
620 | } | ||
621 | #endif | ||
622 | // ++++++++++++++++++++++ end of ALL addresses | ||
623 | //GetUserProperties(); | ||
624 | tempS = QString::fromUcs2(aItem->GetInternetFreeBusyAddress().GetBuffer()); | ||
625 | phoneS.replace( QRegExp("\\r"), ""); | ||
626 | if ( !tempS.isEmpty() ) | ||
627 | addressee.insertCustom( "KADDRESSBOOK", "X-FreeBusyUrl", tempS ); | ||
628 | tempS = QString::fromUcs2(aItem->GetChildren().GetBuffer()); | ||
629 | if ( !tempS.isEmpty() ) | ||
630 | addressee.insertCustom( "KADDRESSBOOK", "X-Children", tempS ); | ||
631 | int gen = aItem->GetGender(); | ||
632 | if ( gen != 0 ) { // 0 undef - 1 female - 2 male | ||
633 | if ( gen == 1 ) | ||
634 | addressee.insertCustom( "KADDRESSBOOK", "X-Gender", "female" ); | ||
635 | else | ||
636 | addressee.insertCustom( "KADDRESSBOOK", "X-Gender", "male" ); | ||
637 | } | ||
638 | QString additionalInfo; | ||
639 | QString tempAdd; | ||
640 | tempAdd = QString::fromUcs2(aItem->GetLanguage().GetBuffer()); | ||
641 | if ( ! tempAdd.isEmpty() ) { | ||
642 | additionalInfo += i18n("\nLanguage: "); | ||
643 | additionalInfo += tempAdd; | ||
644 | } | ||
645 | tempAdd = QString::fromUcs2(aItem->GetHobby().GetBuffer()); | ||
646 | phoneS.replace( QRegExp("\\r"), ""); | ||
647 | if ( ! tempAdd.isEmpty() ) { | ||
648 | additionalInfo += i18n("\nHobby: "); | ||
649 | additionalInfo += tempAdd;; | ||
650 | } | ||
651 | tempAdd =QString::fromUcs2(aItem->GetPersonalHomePage().GetBuffer()); | ||
652 | phoneS.replace( QRegExp("\\r"), ""); | ||
653 | if ( ! tempAdd.isEmpty() ) { | ||
654 | additionalInfo += i18n("\nHomepage: "); | ||
655 | additionalInfo += tempAdd;; | ||
656 | } | ||
657 | tempAdd = QString::fromUcs2(aItem->GetBillingInformation().GetBuffer()); | ||
658 | phoneS.replace( QRegExp("\\r"), ""); | ||
659 | if ( ! tempAdd.isEmpty() ) { | ||
660 | additionalInfo += i18n("\nBilling information: "); | ||
661 | additionalInfo += tempAdd;; | ||
662 | } | ||
663 | tempAdd = QString::fromUcs2(aItem->GetCustomerID().GetBuffer()); | ||
664 | phoneS.replace( QRegExp("\\r"), ""); | ||
665 | if ( ! tempAdd.isEmpty() ) { | ||
666 | additionalInfo += i18n("\nCustomer ID: "); | ||
667 | additionalInfo += tempAdd;; | ||
668 | } | ||
669 | tempAdd = QString::fromUcs2(aItem->GetUser1().GetBuffer()); | ||
670 | phoneS.replace( QRegExp("\\r"), ""); | ||
671 | if ( ! tempAdd.isEmpty() ) { | ||
672 | additionalInfo += i18n("\nUser1: "); | ||
673 | additionalInfo += tempAdd;; | ||
674 | } | ||
675 | tempAdd = QString::fromUcs2(aItem->GetUser2().GetBuffer()); | ||
676 | phoneS.replace( QRegExp("\\r"), ""); | ||
677 | if ( ! tempAdd.isEmpty() ) { | ||
678 | additionalInfo += i18n("\nUser2: "); | ||
679 | additionalInfo += tempAdd;; | ||
680 | } | ||
681 | tempAdd = QString::fromUcs2(aItem->GetUser3().GetBuffer()); | ||
682 | phoneS.replace( QRegExp("\\r"), ""); | ||
683 | if ( ! tempAdd.isEmpty() ) { | ||
684 | additionalInfo += i18n("\nUser3: "); | ||
685 | additionalInfo += tempAdd;; | ||
686 | } | ||
687 | tempAdd = QString::fromUcs2(aItem->GetUser4().GetBuffer()); | ||
688 | phoneS.replace( QRegExp("\\r"), ""); | ||
689 | if ( ! tempAdd.isEmpty() ) { | ||
690 | additionalInfo += i18n("\nUser4: "); | ||
691 | additionalInfo += tempAdd;; | ||
692 | } | ||
693 | if (!additionalInfo.isEmpty() ) { | ||
694 | tempAdd = notesStr; | ||
695 | notesStr = "+++++++++++++++++++++++++++\n"; | ||
696 | notesStr += i18n("Additonal fields created\nby KA/Pi Outlook import:"); | ||
697 | notesStr += additionalInfo; | ||
698 | notesStr += i18n("\nEnd additonal fields created\nby KA/Pi Outlook import!\n"); | ||
699 | notesStr += "+++++++++++++++++++++++++++\n"; | ||
700 | notesStr += tempAdd; | ||
701 | } | ||
702 | addressee.setNote( notesStr ); | ||
703 | #if 0 | ||
704 | // pending | ||
705 | - IM address: no clue where to get info about the helper ID | ||
706 | -custom fields: difficult to implement - not implemented | ||
707 | -keys: makes no sense | ||
708 | #endif | ||
709 | |||
710 | if ( addAddressee( addressee )) | ||
711 | ++importedItems; | ||
712 | } | ||
713 | void KAImportOLdialog::slotCancel() | ||
714 | { | ||
715 | reject(); | ||
716 | } | ||
717 | |||
718 | bool KAImportOLdialog::addAddressee( KABC::Addressee a ) | ||
719 | { | ||
720 | bool add = true; | ||
721 | KABC::Addressee::List::Iterator it; | ||
722 | for ( it = mAList.begin(); it != mAList.end(); ++it ) { | ||
723 | if ( (*it).uid() == a.uid() ) { | ||
724 | add = false; | ||
725 | break; | ||
726 | } | ||
727 | } | ||
728 | if ( add ) { | ||
729 | if ( mABook->findByUid(a.uid() ).isEmpty()) | ||
730 | mAList.append ( a ); | ||
731 | else | ||
732 | add = false; | ||
733 | } | ||
734 | return add; | ||
735 | } | ||
diff --git a/kaddressbook/kaimportoldialog.h b/kaddressbook/kaimportoldialog.h index 41ea5f8..278935b 100644 --- a/kaddressbook/kaimportoldialog.h +++ b/kaddressbook/kaimportoldialog.h | |||
@@ -1,85 +1,22 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@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 | #ifndef KOINCIDENCEEDITOR_H | ||
24 | #define KOINCIDENCEEDITOR_H | ||
25 | |||
26 | #include <kdialogbase.h> | ||
27 | |||
28 | #include <afxdisp.h> | ||
29 | |||
30 | #include <kabc/addressee.h> | ||
31 | #include <kabc/addressbook.h> | ||
32 | |||
33 | class QDateTime; | ||
34 | class QListView; | ||
35 | class OLEListViewItem; | ||
36 | class _ContactItem; | ||
37 | |||
38 | |||
39 | //using namespace KABC; | ||
40 | //class KABC::AddressBook; | ||
41 | |||
42 | /** | ||
43 | This is the base class for the calendar component editors. | ||
44 | */ | ||
45 | class KAImportOLdialog : public KDialogBase | ||
46 | { | ||
47 | Q_OBJECT | ||
48 | public: | ||
49 | /** | ||
50 | Construct new IncidenceEditor. | ||
51 | */ | ||
52 | KAImportOLdialog( const QString &caption, KABC::AddressBook * aBook, | ||
53 | QWidget *parent ); | ||
54 | ~KAImportOLdialog(); | ||
55 | |||
56 | /** Initialize editor. This function creates the tab widgets. */ | ||
57 | void init(); | ||
58 | KABC::Addressee::List getAddressList(); | ||
59 | public slots: | ||
60 | |||
61 | |||
62 | signals: | ||
63 | |||
64 | protected slots: | ||
65 | void slotApply(); | ||
66 | void slotOk(); | ||
67 | void slotCancel(); | ||
68 | |||
69 | protected: | ||
70 | void setupFolderView(); | ||
71 | void addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent); | ||
72 | void readContactData( DWORD folder ); | ||
73 | void ol2kapiContact( _ContactItem * ); | ||
74 | |||
75 | KABC::AddressBook * mABook; | ||
76 | QListView * mListView; | ||
77 | KABC::Addressee::List mAList; | ||
78 | bool addAddressee( KABC::Addressee a ); | ||
79 | private: | ||
80 | int importedItems; | ||
81 | }; | ||
82 | |||
83 | #endif | ||
84 | |||
85 | |||
diff --git a/kaddressbook/phoneeditwidget.cpp b/kaddressbook/phoneeditwidget.cpp index 5639aa2..df3b551 100644 --- a/kaddressbook/phoneeditwidget.cpp +++ b/kaddressbook/phoneeditwidget.cpp | |||
@@ -1,728 +1,731 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
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 | #include <qlayout.h> | 24 | #include <qlayout.h> |
25 | #include <qlabel.h> | 25 | #include <qlabel.h> |
26 | #include <qtooltip.h> | 26 | #include <qtooltip.h> |
27 | #include <qpushbutton.h> | 27 | #include <qpushbutton.h> |
28 | #include <qcheckbox.h> | 28 | #include <qcheckbox.h> |
29 | #include <qstring.h> | 29 | #include <qstring.h> |
30 | #include <qlistbox.h> | 30 | #include <qlistbox.h> |
31 | #include <qlistview.h> | 31 | #include <qlistview.h> |
32 | #include <qbuttongroup.h> | 32 | #include <qbuttongroup.h> |
33 | #include <qhbox.h> | 33 | #include <qhbox.h> |
34 | #include <qcursor.h> | 34 | #include <qcursor.h> |
35 | #include <qtimer.h> | 35 | #include <qtimer.h> |
36 | #include <qapplication.h> | 36 | #include <qapplication.h> |
37 | 37 | ||
38 | #include <kbuttonbox.h> | 38 | #include <kbuttonbox.h> |
39 | #include <klistview.h> | 39 | #include <klistview.h> |
40 | #include <kapplication.h> | 40 | #include <kapplication.h> |
41 | #include <qapplication.h> | 41 | #include <qapplication.h> |
42 | #include <kconfig.h> | 42 | #include <kconfig.h> |
43 | #include <kmessagebox.h> | ||
43 | #include <klineedit.h> | 44 | #include <klineedit.h> |
44 | #include <kcombobox.h> | 45 | #include <kcombobox.h> |
45 | #include <klocale.h> | 46 | #include <klocale.h> |
46 | #include <kdebug.h> | 47 | #include <kdebug.h> |
47 | #include <kglobal.h> | 48 | #include <kglobal.h> |
48 | #include <kiconloader.h> | 49 | #include <kiconloader.h> |
49 | 50 | ||
50 | #include <kabc/phonenumber.h> | 51 | #include <kabc/phonenumber.h> |
51 | 52 | ||
52 | #include "typecombo.h" | 53 | #include "typecombo.h" |
53 | 54 | ||
54 | #include "phoneeditwidget.h" | 55 | #include "phoneeditwidget.h" |
55 | 56 | ||
56 | PhoneEditWidget::PhoneEditWidget( QWidget *parent, const char *name ) | 57 | PhoneEditWidget::PhoneEditWidget( QWidget *parent, const char *name ) |
57 | : QWidget(parent,name) | 58 | : QWidget(parent,name) |
58 | { | 59 | { |
59 | QGridLayout* gridLayout = new QGridLayout ( this, 2,2 ); | 60 | QGridLayout* gridLayout = new QGridLayout ( this, 2,2 ); |
60 | 61 | ||
61 | QLabel *temp = new QLabel( "", this ); | 62 | QLabel *temp = new QLabel( "", this ); |
62 | temp->setAlignment( Qt::AlignCenter ); | 63 | temp->setAlignment( Qt::AlignCenter ); |
63 | temp->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) ); | 64 | temp->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) ); |
64 | QPushButton *addBut = new QPushButton ( "add", this ); | 65 | QPushButton *addBut = new QPushButton ( "add", this ); |
65 | addBut->setPixmap ( SmallIcon("plus")); | 66 | addBut->setPixmap ( SmallIcon("plus")); |
66 | addBut->setMaximumSize( addBut->sizeHint().height(),addBut->sizeHint().height() ); | 67 | addBut->setMaximumSize( addBut->sizeHint().height(),addBut->sizeHint().height() ); |
67 | connect(addBut,SIGNAL(clicked ()),SLOT(addNumber())); | 68 | connect(addBut,SIGNAL(clicked ()),SLOT(addNumber())); |
68 | 69 | ||
69 | sv = new QScrollView( this ); | 70 | sv = new QScrollView( this ); |
70 | sv->setFrameStyle ( QFrame::Plain ); | 71 | sv->setFrameStyle ( QFrame::Plain ); |
71 | sv->setLineWidth ( 0 ); | 72 | sv->setLineWidth ( 0 ); |
72 | sv->setMidLineWidth ( 0 ); | 73 | sv->setMidLineWidth ( 0 ); |
73 | mw = new QWidget ( sv->viewport() ); | 74 | mw = new QWidget ( sv->viewport() ); |
74 | sv->addChild(mw); | 75 | sv->addChild(mw); |
75 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 76 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
76 | mainLayout = new QVBoxLayout ( mw ); | 77 | mainLayout = new QVBoxLayout ( mw ); |
77 | mainLayout->setMargin( 0 ); | 78 | mainLayout->setMargin( 0 ); |
78 | mainLayout->setSpacing( 0 ); | 79 | mainLayout->setSpacing( 0 ); |
79 | gridLayout->setMargin( 2 ); | 80 | gridLayout->setMargin( 2 ); |
80 | gridLayout->setSpacing( 4 ); | 81 | gridLayout->setSpacing( 4 ); |
81 | if ( QApplication::desktop()->width() == 240 || QApplication::desktop()->width() == 480 ) { | 82 | if ( QApplication::desktop()->width() == 240 || QApplication::desktop()->width() == 480 ) { |
82 | gridLayout->addWidget( addBut, 0, 0 ); | 83 | gridLayout->addWidget( addBut, 0, 0 ); |
83 | gridLayout->addWidget( temp, 0, 1 ); | 84 | gridLayout->addWidget( temp, 0, 1 ); |
84 | gridLayout->addMultiCellWidget( sv, 1,1 , 0,1 ); | 85 | gridLayout->addMultiCellWidget( sv, 1,1 , 0,1 ); |
85 | } else { | 86 | } else { |
86 | gridLayout->addWidget( temp, 1, 0 ); | 87 | gridLayout->addWidget( temp, 1, 0 ); |
87 | gridLayout->addWidget( addBut, 0, 0 ); | 88 | gridLayout->addWidget( addBut, 0, 0 ); |
88 | gridLayout->addMultiCellWidget( sv, 0, 1, 1,1 ); | 89 | gridLayout->addMultiCellWidget( sv, 0, 1, 1,1 ); |
89 | } | 90 | } |
90 | setDefaults(); | 91 | setDefaults(); |
91 | mTypeNumberEditList.setAutoDelete( true ); | 92 | mTypeNumberEditList.setAutoDelete( true ); |
92 | mPopup = new QPopupMenu( this ); | 93 | mPopup = new QPopupMenu( this ); |
93 | QStringList list = PhoneNumber::supportedTypeListNames(); | 94 | QStringList list = PhoneNumber::supportedTypeListNames(); |
94 | mPopupCount = list.count(); | 95 | mPopupCount = list.count(); |
95 | int i = 0; | 96 | int i = 0; |
96 | while ( i < mPopupCount ) { | 97 | while ( i < mPopupCount ) { |
97 | mPopup->insertItem( list[ i ], i ); | 98 | mPopup->insertItem( list[ i ], i ); |
98 | ++i; | 99 | ++i; |
99 | } | 100 | } |
100 | connect(mPopup,SIGNAL(activated(int)),this,SLOT(addNumberInt( int))); | 101 | connect(mPopup,SIGNAL(activated(int)),this,SLOT(addNumberInt( int))); |
101 | 102 | ||
102 | } | 103 | } |
103 | 104 | ||
104 | PhoneEditWidget::~PhoneEditWidget() | 105 | PhoneEditWidget::~PhoneEditWidget() |
105 | { | 106 | { |
106 | } | 107 | } |
107 | void PhoneEditWidget::setDefaults() | 108 | void PhoneEditWidget::setDefaults() |
108 | { | 109 | { |
109 | mTypeNumberEditList.clear(); | 110 | mTypeNumberEditList.clear(); |
110 | PhoneTypeNumberEdit* edit = appendEditCombo(); | 111 | PhoneTypeNumberEdit* edit = appendEditCombo(); |
111 | KABC::PhoneNumber phoneNumber; | 112 | KABC::PhoneNumber phoneNumber; |
112 | phoneNumber.setType( KABC::PhoneNumber::Home | KABC::PhoneNumber::Pref ); | 113 | phoneNumber.setType( KABC::PhoneNumber::Home | KABC::PhoneNumber::Pref ); |
113 | edit->setPhoneNumber( phoneNumber ); | 114 | edit->setPhoneNumber( phoneNumber ); |
114 | edit = appendEditCombo(); | 115 | edit = appendEditCombo(); |
115 | phoneNumber.setType( KABC::PhoneNumber::Work | KABC::PhoneNumber::Pref ); | 116 | KABC::PhoneNumber phoneNumber2; |
116 | edit->setPhoneNumber( phoneNumber ); | 117 | phoneNumber2.setType( KABC::PhoneNumber::Work | KABC::PhoneNumber::Pref ); |
118 | edit->setPhoneNumber( phoneNumber2 ); | ||
117 | edit = appendEditCombo(); | 119 | edit = appendEditCombo(); |
118 | phoneNumber.setType( KABC::PhoneNumber::Cell ); | 120 | KABC::PhoneNumber phoneNumber3; |
119 | edit->setPhoneNumber( phoneNumber ); | 121 | phoneNumber3.setType( KABC::PhoneNumber::Cell ); |
122 | edit->setPhoneNumber( phoneNumber3 ); | ||
120 | 123 | ||
121 | } | 124 | } |
122 | void PhoneEditWidget::addNumberInt( int index ) | 125 | void PhoneEditWidget::addNumberInt( int index ) |
123 | { | 126 | { |
124 | PhoneTypeNumberEdit* edit = appendEditCombo(); | 127 | PhoneTypeNumberEdit* edit = appendEditCombo(); |
125 | KABC::PhoneNumber phoneNumber; | 128 | KABC::PhoneNumber phoneNumber; |
126 | phoneNumber.setType( PhoneNumber::supportedTypeList()[index] ); | 129 | phoneNumber.setType( PhoneNumber::supportedTypeList()[index] ); |
127 | edit->setPhoneNumber( phoneNumber ); | 130 | edit->setPhoneNumber( phoneNumber ); |
128 | //verticalScrollBar()->setValue( 1024); | 131 | //verticalScrollBar()->setValue( 1024); |
129 | QTimer::singleShot( 0, this, SLOT ( bottomVisible() ) ); | 132 | QTimer::singleShot( 0, this, SLOT ( bottomVisible() ) ); |
130 | } | 133 | } |
131 | void PhoneEditWidget::bottomVisible() | 134 | void PhoneEditWidget::bottomVisible() |
132 | { | 135 | { |
133 | sv->setContentsPos ( 0, 1024 ); | 136 | sv->setContentsPos ( 0, 1024 ); |
134 | } | 137 | } |
135 | void PhoneEditWidget::addNumber() | 138 | void PhoneEditWidget::addNumber() |
136 | { | 139 | { |
137 | int i = 0; | 140 | int i = 0; |
138 | while ( i < mPopupCount ) { | 141 | while ( i < mPopupCount ) { |
139 | mPopup->setItemEnabled( i, true ); | 142 | mPopup->setItemEnabled( i, true ); |
140 | ++i; | 143 | ++i; |
141 | } | 144 | } |
142 | PhoneTypeNumberEdit* edit = mTypeNumberEditList.first(); | 145 | PhoneTypeNumberEdit* edit = mTypeNumberEditList.first(); |
143 | while ( edit ) { | 146 | while ( edit ) { |
144 | if ( edit->currentType() < mPopupCount -1 ) | 147 | if ( edit->currentType() < mPopupCount -1 ) |
145 | mPopup->setItemEnabled( edit->currentType(), false ); | 148 | mPopup->setItemEnabled( edit->currentType(), false ); |
146 | edit = mTypeNumberEditList.next(); | 149 | edit = mTypeNumberEditList.next(); |
147 | } | 150 | } |
148 | mPopup->popup( QCursor::pos() ); | 151 | mPopup->popup( QCursor::pos() ); |
149 | } | 152 | } |
150 | PhoneTypeNumberEdit* PhoneEditWidget::appendEditCombo() | 153 | PhoneTypeNumberEdit* PhoneEditWidget::appendEditCombo() |
151 | { | 154 | { |
152 | PhoneTypeNumberEdit* edit = new PhoneTypeNumberEdit( mw ); | 155 | PhoneTypeNumberEdit* edit = new PhoneTypeNumberEdit( mw ); |
153 | connect ( edit, SIGNAL ( typeChange( int , int) ), this, SIGNAL ( typeChange( int , int)) ); | 156 | connect ( edit, SIGNAL ( typeChange( int , int) ), this, SIGNAL ( typeChange( int , int)) ); |
154 | connect ( edit, SIGNAL ( modified() ), this, SIGNAL ( modified() ) ); | 157 | connect ( edit, SIGNAL ( modified() ), this, SIGNAL ( modified() ) ); |
155 | connect ( edit, SIGNAL ( deleteMe( PhoneTypeNumberEdit* ) ), this, SLOT ( deleteEdit( PhoneTypeNumberEdit*) ) ); | 158 | connect ( edit, SIGNAL ( deleteMe( PhoneTypeNumberEdit* ) ), this, SLOT ( deleteEdit( PhoneTypeNumberEdit*) ) ); |
156 | connect ( this, SIGNAL ( typeChange( int , int)), edit, SLOT ( typeExternalChanged( int, int)) ); | 159 | connect ( this, SIGNAL ( typeChange( int , int)), edit, SLOT ( typeExternalChanged( int, int)) ); |
157 | 160 | ||
158 | mainLayout->add( edit ); | 161 | mainLayout->add( edit ); |
159 | mTypeNumberEditList.append( edit ); | 162 | mTypeNumberEditList.append( edit ); |
160 | return edit; | 163 | return edit; |
161 | } | 164 | } |
162 | 165 | ||
163 | void PhoneEditWidget::deleteEdit( PhoneTypeNumberEdit* ew ) | 166 | void PhoneEditWidget::deleteEdit( PhoneTypeNumberEdit* ew ) |
164 | { | 167 | { |
165 | mPendingDelete = ew; | 168 | mPendingDelete = ew; |
166 | QTimer::singleShot( 0, this, SLOT ( pendingDelete() ) ); | 169 | QTimer::singleShot( 0, this, SLOT ( pendingDelete() ) ); |
167 | } | 170 | } |
168 | void PhoneEditWidget::pendingDelete() | 171 | void PhoneEditWidget::pendingDelete() |
169 | { | 172 | { |
170 | mTypeNumberEditList.removeRef( mPendingDelete ); | 173 | mTypeNumberEditList.removeRef( mPendingDelete ); |
171 | emit modified(); | 174 | emit modified(); |
172 | } | 175 | } |
173 | 176 | ||
174 | void PhoneEditWidget::setPhoneNumbers( const KABC::PhoneNumber::List &li ) | 177 | void PhoneEditWidget::setPhoneNumbers( const KABC::PhoneNumber::List &li ) |
175 | { | 178 | { |
176 | if ( li.isEmpty() ) { | 179 | if ( li.isEmpty() ) { |
177 | setDefaults(); | 180 | setDefaults(); |
178 | return; | 181 | return; |
179 | } | 182 | } |
180 | mTypeNumberEditList.clear(); | 183 | mTypeNumberEditList.clear(); |
181 | KABC::PhoneNumber::List::Iterator it; | 184 | KABC::PhoneNumber::List::Iterator it; |
182 | KABC::PhoneNumber::List list2 = li; | 185 | KABC::PhoneNumber::List list2 = li; |
183 | KABC::PhoneNumber::List list ; | 186 | KABC::PhoneNumber::List list ; |
184 | 187 | ||
185 | PhoneNumber::TypeList tList = PhoneNumber::supportedTypeList(); | 188 | PhoneNumber::TypeList tList = PhoneNumber::supportedTypeList(); |
186 | int i = 0; | 189 | int i = 0; |
187 | int max = tList.count(); | 190 | int max = tList.count(); |
188 | while ( i < max-1 ) { | 191 | while ( i < max-1 ) { |
189 | for ( it = list2.begin(); it != list2.end(); ++it ) { | 192 | for ( it = list2.begin(); it != list2.end(); ++it ) { |
190 | if ( (*it).type() == tList[i] ) { | 193 | if ( (*it).type() == tList[i] ) { |
191 | list.append( (*it ) ); | 194 | list.append( (*it ) ); |
192 | break; | 195 | break; |
193 | } | 196 | } |
194 | } | 197 | } |
195 | ++i; | 198 | ++i; |
196 | } | 199 | } |
197 | for ( it = list2.begin(); it != list2.end(); ++it ) { | 200 | for ( it = list2.begin(); it != list2.end(); ++it ) { |
198 | if ( (*it).type() == tList[ max-1 ] ) | 201 | if ( (*it).type() == tList[ max-1 ] ) |
199 | list.append( (*it ) ); | 202 | list.append( (*it ) ); |
200 | } | 203 | } |
201 | for ( it = list.begin(); it != list.end(); ++it ) { | 204 | for ( it = list.begin(); it != list.end(); ++it ) { |
202 | PhoneTypeNumberEdit* editNew = appendEditCombo(); | 205 | PhoneTypeNumberEdit* editNew = appendEditCombo(); |
203 | editNew->setPhoneNumber( (*it ) ); | 206 | editNew->setPhoneNumber( (*it ) ); |
204 | } | 207 | } |
205 | 208 | ||
206 | } | 209 | } |
207 | KABC::PhoneNumber::List PhoneEditWidget::phoneNumbers() | 210 | KABC::PhoneNumber::List PhoneEditWidget::phoneNumbers() |
208 | { | 211 | { |
209 | KABC::PhoneNumber::List retList; | 212 | KABC::PhoneNumber::List retList; |
210 | 213 | ||
211 | PhoneTypeNumberEdit* edit = mTypeNumberEditList.first(); | 214 | PhoneTypeNumberEdit* edit = mTypeNumberEditList.first(); |
212 | while ( edit ) { | 215 | while ( edit ) { |
213 | if ( edit->isValid() ) { | 216 | if ( edit->isValid() ) { |
214 | retList.append( edit->phoneNumber()); | 217 | retList.append( edit->phoneNumber()); |
215 | } | 218 | } |
216 | edit = mTypeNumberEditList.next(); | 219 | edit = mTypeNumberEditList.next(); |
217 | 220 | ||
218 | } | 221 | } |
219 | return retList; | 222 | return retList; |
220 | } | 223 | } |
221 | 224 | ||
222 | #if 0 | 225 | #if 0 |
223 | PhoneEditWidget::PhoneEditWidget( QWidget *parent, const char *name ) | 226 | PhoneEditWidget::PhoneEditWidget( QWidget *parent, const char *name ) |
224 | : QWidget( parent, name ) | 227 | : QWidget( parent, name ) |
225 | { | 228 | { |
226 | QGridLayout *layout = new QGridLayout( this, 4, 1 ); | 229 | QGridLayout *layout = new QGridLayout( this, 4, 1 ); |
227 | //US layout->setSpacing( KDialog::spacingHint() ); | 230 | //US layout->setSpacing( KDialog::spacingHint() ); |
228 | layout->setSpacing( KDialogBase::spacingHintSmall() ); | 231 | layout->setSpacing( KDialogBase::spacingHintSmall() ); |
229 | 232 | ||
230 | 233 | ||
231 | 234 | ||
232 | QLabel* label = new QLabel( this ); | 235 | QLabel* label = new QLabel( this ); |
233 | //US loadIcon call is ambiguous. Add one more parameter | 236 | //US loadIcon call is ambiguous. Add one more parameter |
234 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop ) ); | 237 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop ) ); |
235 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) ); | 238 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) ); |
236 | label->setAlignment( AlignCenter ); | 239 | label->setAlignment( AlignCenter ); |
237 | //US layout->addMultiCellWidget( label, 0, 1, 3, 3 ); | 240 | //US layout->addMultiCellWidget( label, 0, 1, 3, 3 ); |
238 | layout->addWidget( label, 0, 0 ); | 241 | layout->addWidget( label, 0, 0 ); |
239 | 242 | ||
240 | QPushButton *editButton = new QPushButton( i18n( "Edit Phone Numbers..." ), | 243 | QPushButton *editButton = new QPushButton( i18n( "Edit Phone Numbers..." ), |
241 | this ); | 244 | this ); |
242 | if ( QApplication::desktop()->width() < 640 ) | 245 | if ( QApplication::desktop()->width() < 640 ) |
243 | layout->addWidget( editButton, 0, 1 ); | 246 | layout->addWidget( editButton, 0, 1 ); |
244 | else | 247 | else |
245 | layout->addMultiCellWidget( editButton, 0, 0, 1, 3); | 248 | layout->addMultiCellWidget( editButton, 0, 0, 1, 3); |
246 | 249 | ||
247 | mPrefCombo = new PhoneTypeCombo( mPhoneList, this ); | 250 | mPrefCombo = new PhoneTypeCombo( mPhoneList, this ); |
248 | mPrefEdit = new KLineEdit( this ); | 251 | mPrefEdit = new KLineEdit( this ); |
249 | //mPrefEdit->setMinimumWidth( int(mPrefEdit->sizeHint().width() * 1.5) ); | 252 | //mPrefEdit->setMinimumWidth( int(mPrefEdit->sizeHint().width() * 1.5) ); |
250 | mPrefCombo->setLineEdit( mPrefEdit ); | 253 | mPrefCombo->setLineEdit( mPrefEdit ); |
251 | layout->addWidget( mPrefCombo, 1, 0 ); | 254 | layout->addWidget( mPrefCombo, 1, 0 ); |
252 | layout->addWidget( mPrefEdit, 1, 1 ); | 255 | layout->addWidget( mPrefEdit, 1, 1 ); |
253 | int x = 1, y = 2; | 256 | int x = 1, y = 2; |
254 | if ( QApplication::desktop()->width() < 640 ) { | 257 | if ( QApplication::desktop()->width() < 640 ) { |
255 | ++x; | 258 | ++x; |
256 | y = 0; | 259 | y = 0; |
257 | } | 260 | } |
258 | mSecondCombo = new PhoneTypeCombo( mPhoneList, this ); | 261 | mSecondCombo = new PhoneTypeCombo( mPhoneList, this ); |
259 | mSecondEdit = new KLineEdit( this ); | 262 | mSecondEdit = new KLineEdit( this ); |
260 | mSecondCombo->setLineEdit( mSecondEdit ); | 263 | mSecondCombo->setLineEdit( mSecondEdit ); |
261 | layout->addWidget( mSecondCombo, x, y++ ); | 264 | layout->addWidget( mSecondCombo, x, y++ ); |
262 | layout->addWidget( mSecondEdit, x, y++ ); | 265 | layout->addWidget( mSecondEdit, x, y++ ); |
263 | 266 | ||
264 | y = 0; | 267 | y = 0; |
265 | ++x; | 268 | ++x; |
266 | mThirdCombo = new PhoneTypeCombo( mPhoneList, this ); | 269 | mThirdCombo = new PhoneTypeCombo( mPhoneList, this ); |
267 | mThirdEdit = new KLineEdit( this ); | 270 | mThirdEdit = new KLineEdit( this ); |
268 | mThirdCombo->setLineEdit( mThirdEdit ); | 271 | mThirdCombo->setLineEdit( mThirdEdit ); |
269 | layout->addWidget( mThirdCombo, x, y++ ); | 272 | layout->addWidget( mThirdCombo, x, y++ ); |
270 | layout->addWidget( mThirdEdit, x, y++ ); | 273 | layout->addWidget( mThirdEdit, x, y++ ); |
271 | if ( QApplication::desktop()->width() < 640 ) { | 274 | if ( QApplication::desktop()->width() < 640 ) { |
272 | ++x; | 275 | ++x; |
273 | y = 0; | 276 | y = 0; |
274 | } | 277 | } |
275 | mFourthCombo = new PhoneTypeCombo( mPhoneList, this ); | 278 | mFourthCombo = new PhoneTypeCombo( mPhoneList, this ); |
276 | mFourthEdit = new KLineEdit( this ); | 279 | mFourthEdit = new KLineEdit( this ); |
277 | mFourthCombo->setLineEdit( mFourthEdit ); | 280 | mFourthCombo->setLineEdit( mFourthEdit ); |
278 | layout->addWidget( mFourthCombo, x, y++ ); | 281 | layout->addWidget( mFourthCombo, x, y++ ); |
279 | layout->addWidget( mFourthEdit, x, y++ ); | 282 | layout->addWidget( mFourthEdit, x, y++ ); |
280 | 283 | ||
281 | // Four numbers don't fit in the current dialog | 284 | // Four numbers don't fit in the current dialog |
282 | if ( QApplication::desktop()->width() < 640 ) { | 285 | if ( QApplication::desktop()->width() < 640 ) { |
283 | mFourthCombo->hide(); | 286 | mFourthCombo->hide(); |
284 | mFourthEdit->hide(); | 287 | mFourthEdit->hide(); |
285 | } else { | 288 | } else { |
286 | QFontMetrics fm ( font () ) ; | 289 | QFontMetrics fm ( font () ) ; |
287 | int wid = fm.width( "Messenger" ) +60; | 290 | int wid = fm.width( "Messenger" ) +60; |
288 | mPrefCombo->setMaximumWidth( wid ); | 291 | mPrefCombo->setMaximumWidth( wid ); |
289 | mSecondCombo->setMaximumWidth( wid ); | 292 | mSecondCombo->setMaximumWidth( wid ); |
290 | mThirdCombo->setMaximumWidth( wid ); | 293 | mThirdCombo->setMaximumWidth( wid ); |
291 | mFourthCombo->setMaximumWidth( wid ); | 294 | mFourthCombo->setMaximumWidth( wid ); |
292 | } | 295 | } |
293 | 296 | ||
294 | 297 | ||
295 | connect( mPrefEdit, SIGNAL( textChanged( const QString& ) ), | 298 | connect( mPrefEdit, SIGNAL( textChanged( const QString& ) ), |
296 | SLOT( slotPrefEditChanged() ) ); | 299 | SLOT( slotPrefEditChanged() ) ); |
297 | connect( mSecondEdit, SIGNAL( textChanged( const QString& ) ), | 300 | connect( mSecondEdit, SIGNAL( textChanged( const QString& ) ), |
298 | SLOT( slotSecondEditChanged() ) ); | 301 | SLOT( slotSecondEditChanged() ) ); |
299 | connect( mThirdEdit, SIGNAL( textChanged( const QString& ) ), | 302 | connect( mThirdEdit, SIGNAL( textChanged( const QString& ) ), |
300 | SLOT( slotThirdEditChanged() ) ); | 303 | SLOT( slotThirdEditChanged() ) ); |
301 | connect( mFourthEdit, SIGNAL( textChanged( const QString& ) ), | 304 | connect( mFourthEdit, SIGNAL( textChanged( const QString& ) ), |
302 | SLOT( slotFourthEditChanged() ) ); | 305 | SLOT( slotFourthEditChanged() ) ); |
303 | 306 | ||
304 | connect( editButton, SIGNAL( clicked() ), SLOT( edit() ) ); | 307 | connect( editButton, SIGNAL( clicked() ), SLOT( edit() ) ); |
305 | 308 | ||
306 | connect( mPrefCombo, SIGNAL( activated( int ) ), | 309 | connect( mPrefCombo, SIGNAL( activated( int ) ), |
307 | SLOT( updatePrefEdit() ) ); | 310 | SLOT( updatePrefEdit() ) ); |
308 | connect( mSecondCombo, SIGNAL( activated( int ) ), | 311 | connect( mSecondCombo, SIGNAL( activated( int ) ), |
309 | SLOT( updateSecondEdit() ) ); | 312 | SLOT( updateSecondEdit() ) ); |
310 | connect( mThirdCombo, SIGNAL( activated( int ) ), | 313 | connect( mThirdCombo, SIGNAL( activated( int ) ), |
311 | SLOT( updateThirdEdit() ) ); | 314 | SLOT( updateThirdEdit() ) ); |
312 | connect( mFourthCombo, SIGNAL( activated( int ) ), | 315 | connect( mFourthCombo, SIGNAL( activated( int ) ), |
313 | SLOT( updateFourthEdit() ) ); | 316 | SLOT( updateFourthEdit() ) ); |
314 | } | 317 | } |
315 | 318 | ||
316 | PhoneEditWidget::~PhoneEditWidget() | 319 | PhoneEditWidget::~PhoneEditWidget() |
317 | { | 320 | { |
318 | } | 321 | } |
319 | 322 | ||
320 | void PhoneEditWidget::setPhoneNumbers( const KABC::PhoneNumber::List &list ) | 323 | void PhoneEditWidget::setPhoneNumbers( const KABC::PhoneNumber::List &list ) |
321 | { | 324 | { |
322 | mPhoneList.clear(); | 325 | mPhoneList.clear(); |
323 | 326 | ||
324 | // Insert types for existing numbers. | 327 | // Insert types for existing numbers. |
325 | mPrefCombo->insertTypeList( list ); | 328 | mPrefCombo->insertTypeList( list ); |
326 | 329 | ||
327 | QValueList<int> defaultTypes; | 330 | QValueList<int> defaultTypes; |
328 | defaultTypes << KABC::PhoneNumber::Home; | 331 | defaultTypes << KABC::PhoneNumber::Home; |
329 | defaultTypes << KABC::PhoneNumber::Work; | 332 | defaultTypes << KABC::PhoneNumber::Work; |
330 | defaultTypes << KABC::PhoneNumber::Cell; | 333 | defaultTypes << KABC::PhoneNumber::Cell; |
331 | defaultTypes << ( KABC::PhoneNumber::Work | KABC::PhoneNumber::Fax ); | 334 | defaultTypes << ( KABC::PhoneNumber::Work | KABC::PhoneNumber::Fax ); |
332 | defaultTypes << ( KABC::PhoneNumber::Home | KABC::PhoneNumber::Fax ); | 335 | defaultTypes << ( KABC::PhoneNumber::Home | KABC::PhoneNumber::Fax ); |
333 | 336 | ||
334 | // Insert default types. | 337 | // Insert default types. |
335 | // Doing this for mPrefCombo is enough because the list is shared by all | 338 | // Doing this for mPrefCombo is enough because the list is shared by all |
336 | // combos. | 339 | // combos. |
337 | QValueList<int>::ConstIterator it; | 340 | QValueList<int>::ConstIterator it; |
338 | for( it = defaultTypes.begin(); it != defaultTypes.end(); ++it ) { | 341 | for( it = defaultTypes.begin(); it != defaultTypes.end(); ++it ) { |
339 | if ( !mPrefCombo->hasType( *it ) ) | 342 | if ( !mPrefCombo->hasType( *it ) ) |
340 | mPrefCombo->insertType( list, *it, PhoneNumber( "", *it ) ); | 343 | mPrefCombo->insertType( list, *it, PhoneNumber( "", *it ) ); |
341 | } | 344 | } |
342 | 345 | ||
343 | updateCombos(); | 346 | updateCombos(); |
344 | 347 | ||
345 | mPrefCombo->selectType( defaultTypes[ 0 ] ); | 348 | mPrefCombo->selectType( defaultTypes[ 0 ] ); |
346 | mSecondCombo->selectType( defaultTypes[ 1 ] ); | 349 | mSecondCombo->selectType( defaultTypes[ 1 ] ); |
347 | mThirdCombo->selectType( defaultTypes[ 2 ] ); | 350 | mThirdCombo->selectType( defaultTypes[ 2 ] ); |
348 | mFourthCombo->selectType( defaultTypes[ 3 ] ); | 351 | mFourthCombo->selectType( defaultTypes[ 3 ] ); |
349 | 352 | ||
350 | updateLineEdits(); | 353 | updateLineEdits(); |
351 | } | 354 | } |
352 | 355 | ||
353 | void PhoneEditWidget::updateLineEdits() | 356 | void PhoneEditWidget::updateLineEdits() |
354 | { | 357 | { |
355 | updatePrefEdit(); | 358 | updatePrefEdit(); |
356 | updateSecondEdit(); | 359 | updateSecondEdit(); |
357 | updateThirdEdit(); | 360 | updateThirdEdit(); |
358 | updateFourthEdit(); | 361 | updateFourthEdit(); |
359 | } | 362 | } |
360 | 363 | ||
361 | void PhoneEditWidget::updateCombos() | 364 | void PhoneEditWidget::updateCombos() |
362 | { | 365 | { |
363 | mPrefCombo->updateTypes(); | 366 | mPrefCombo->updateTypes(); |
364 | mSecondCombo->updateTypes(); | 367 | mSecondCombo->updateTypes(); |
365 | mThirdCombo->updateTypes(); | 368 | mThirdCombo->updateTypes(); |
366 | mFourthCombo->updateTypes(); | 369 | mFourthCombo->updateTypes(); |
367 | } | 370 | } |
368 | 371 | ||
369 | KABC::PhoneNumber::List PhoneEditWidget::phoneNumbers() | 372 | KABC::PhoneNumber::List PhoneEditWidget::phoneNumbers() |
370 | { | 373 | { |
371 | KABC::PhoneNumber::List retList; | 374 | KABC::PhoneNumber::List retList; |
372 | 375 | ||
373 | KABC::PhoneNumber::List::Iterator it; | 376 | KABC::PhoneNumber::List::Iterator it; |
374 | for ( it = mPhoneList.begin(); it != mPhoneList.end(); ++it ) | 377 | for ( it = mPhoneList.begin(); it != mPhoneList.end(); ++it ) |
375 | if ( !(*it).number().isEmpty() ) | 378 | if ( !(*it).number().isEmpty() ) |
376 | retList.append( *it ); | 379 | retList.append( *it ); |
377 | 380 | ||
378 | return retList; | 381 | return retList; |
379 | } | 382 | } |
380 | 383 | ||
381 | void PhoneEditWidget::edit() | 384 | void PhoneEditWidget::edit() |
382 | { | 385 | { |
383 | PhoneEditDialog dlg( mPhoneList, this ); | 386 | PhoneEditDialog dlg( mPhoneList, this ); |
384 | 387 | ||
385 | if ( dlg.exec() ) { | 388 | if ( dlg.exec() ) { |
386 | if ( dlg.changed() ) { | 389 | if ( dlg.changed() ) { |
387 | KABC::PhoneNumber::List list = dlg.phoneNumbers(); | 390 | KABC::PhoneNumber::List list = dlg.phoneNumbers(); |
388 | setPhoneNumbers( list ); | 391 | setPhoneNumbers( list ); |
389 | updateCombos(); | 392 | updateCombos(); |
390 | updateLineEdits(); | 393 | updateLineEdits(); |
391 | emit modified(); | 394 | emit modified(); |
392 | } | 395 | } |
393 | } | 396 | } |
394 | } | 397 | } |
395 | 398 | ||
396 | void PhoneEditWidget::updatePrefEdit() | 399 | void PhoneEditWidget::updatePrefEdit() |
397 | { | 400 | { |
398 | updateEdit( mPrefCombo ); | 401 | updateEdit( mPrefCombo ); |
399 | } | 402 | } |
400 | 403 | ||
401 | void PhoneEditWidget::updateSecondEdit() | 404 | void PhoneEditWidget::updateSecondEdit() |
402 | { | 405 | { |
403 | updateEdit( mSecondCombo ); | 406 | updateEdit( mSecondCombo ); |
404 | } | 407 | } |
405 | 408 | ||
406 | void PhoneEditWidget::updateThirdEdit() | 409 | void PhoneEditWidget::updateThirdEdit() |
407 | { | 410 | { |
408 | updateEdit( mThirdCombo ); | 411 | updateEdit( mThirdCombo ); |
409 | } | 412 | } |
410 | 413 | ||
411 | void PhoneEditWidget::updateFourthEdit() | 414 | void PhoneEditWidget::updateFourthEdit() |
412 | { | 415 | { |
413 | updateEdit( mFourthCombo ); | 416 | updateEdit( mFourthCombo ); |
414 | } | 417 | } |
415 | 418 | ||
416 | void PhoneEditWidget::updateEdit( PhoneTypeCombo *combo ) | 419 | void PhoneEditWidget::updateEdit( PhoneTypeCombo *combo ) |
417 | { | 420 | { |
418 | QLineEdit *edit = combo->lineEdit(); | 421 | QLineEdit *edit = combo->lineEdit(); |
419 | if ( !edit ) | 422 | if ( !edit ) |
420 | return; | 423 | return; |
421 | 424 | ||
422 | #if 0 | 425 | #if 0 |
423 | if ( edit == mPrefEdit ) kdDebug(5720) << " prefEdit" << endl; | 426 | if ( edit == mPrefEdit ) kdDebug(5720) << " prefEdit" << endl; |
424 | if ( edit == mSecondEdit ) kdDebug(5720) << " secondEdit" << endl; | 427 | if ( edit == mSecondEdit ) kdDebug(5720) << " secondEdit" << endl; |
425 | if ( edit == mThirdEdit ) kdDebug(5720) << " thirdEdit" << endl; | 428 | if ( edit == mThirdEdit ) kdDebug(5720) << " thirdEdit" << endl; |
426 | if ( edit == mFourthEdit ) kdDebug(5720) << " fourthEdit" << endl; | 429 | if ( edit == mFourthEdit ) kdDebug(5720) << " fourthEdit" << endl; |
427 | #endif | 430 | #endif |
428 | 431 | ||
429 | PhoneNumber::List::Iterator it = combo->selectedElement(); | 432 | PhoneNumber::List::Iterator it = combo->selectedElement(); |
430 | if ( it != mPhoneList.end() ) { | 433 | if ( it != mPhoneList.end() ) { |
431 | edit->setText( (*it).number() ); | 434 | edit->setText( (*it).number() ); |
432 | } else { | 435 | } else { |
433 | kdDebug(5720) << "PhoneEditWidget::updateEdit(): no selected element" << endl; | 436 | kdDebug(5720) << "PhoneEditWidget::updateEdit(): no selected element" << endl; |
434 | } | 437 | } |
435 | } | 438 | } |
436 | 439 | ||
437 | void PhoneEditWidget::slotPrefEditChanged() | 440 | void PhoneEditWidget::slotPrefEditChanged() |
438 | { | 441 | { |
439 | updatePhoneNumber( mPrefCombo ); | 442 | updatePhoneNumber( mPrefCombo ); |
440 | } | 443 | } |
441 | 444 | ||
442 | void PhoneEditWidget::slotSecondEditChanged() | 445 | void PhoneEditWidget::slotSecondEditChanged() |
443 | { | 446 | { |
444 | updatePhoneNumber( mSecondCombo ); | 447 | updatePhoneNumber( mSecondCombo ); |
445 | } | 448 | } |
446 | 449 | ||
447 | void PhoneEditWidget::slotThirdEditChanged() | 450 | void PhoneEditWidget::slotThirdEditChanged() |
448 | { | 451 | { |
449 | updatePhoneNumber( mThirdCombo ); | 452 | updatePhoneNumber( mThirdCombo ); |
450 | } | 453 | } |
451 | 454 | ||
452 | void PhoneEditWidget::slotFourthEditChanged() | 455 | void PhoneEditWidget::slotFourthEditChanged() |
453 | { | 456 | { |
454 | updatePhoneNumber( mFourthCombo ); | 457 | updatePhoneNumber( mFourthCombo ); |
455 | } | 458 | } |
456 | 459 | ||
457 | void PhoneEditWidget::updatePhoneNumber( PhoneTypeCombo *combo ) | 460 | void PhoneEditWidget::updatePhoneNumber( PhoneTypeCombo *combo ) |
458 | { | 461 | { |
459 | QLineEdit *edit = combo->lineEdit(); | 462 | QLineEdit *edit = combo->lineEdit(); |
460 | if ( !edit ) return; | 463 | if ( !edit ) return; |
461 | 464 | ||
462 | PhoneNumber::List::Iterator it = combo->selectedElement(); | 465 | PhoneNumber::List::Iterator it = combo->selectedElement(); |
463 | if ( it != mPhoneList.end() ) { | 466 | if ( it != mPhoneList.end() ) { |
464 | (*it).setNumber( edit->text() ); | 467 | (*it).setNumber( edit->text() ); |
465 | } | 468 | } |
466 | 469 | ||
467 | updateOtherEdit( combo, mPrefCombo ); | 470 | updateOtherEdit( combo, mPrefCombo ); |
468 | updateOtherEdit( combo, mSecondCombo ); | 471 | updateOtherEdit( combo, mSecondCombo ); |
469 | updateOtherEdit( combo, mThirdCombo ); | 472 | updateOtherEdit( combo, mThirdCombo ); |
470 | updateOtherEdit( combo, mFourthCombo ); | 473 | updateOtherEdit( combo, mFourthCombo ); |
471 | 474 | ||
472 | emit modified(); | 475 | emit modified(); |
473 | } | 476 | } |
474 | 477 | ||
475 | void PhoneEditWidget::updateOtherEdit( PhoneTypeCombo *combo, PhoneTypeCombo *otherCombo ) | 478 | void PhoneEditWidget::updateOtherEdit( PhoneTypeCombo *combo, PhoneTypeCombo *otherCombo ) |
476 | { | 479 | { |
477 | if ( combo == otherCombo ) return; | 480 | if ( combo == otherCombo ) return; |
478 | 481 | ||
479 | if ( combo->currentItem() == otherCombo->currentItem() ) { | 482 | if ( combo->currentItem() == otherCombo->currentItem() ) { |
480 | updateEdit( otherCombo ); | 483 | updateEdit( otherCombo ); |
481 | } | 484 | } |
482 | } | 485 | } |
483 | 486 | ||
484 | /////////////////////////////////////////// | 487 | /////////////////////////////////////////// |
485 | // PhoneEditDialog | 488 | // PhoneEditDialog |
486 | 489 | ||
487 | class PhoneViewItem : public QListViewItem | 490 | class PhoneViewItem : public QListViewItem |
488 | { | 491 | { |
489 | public: | 492 | public: |
490 | PhoneViewItem( QListView *parent, const KABC::PhoneNumber &number ); | 493 | PhoneViewItem( QListView *parent, const KABC::PhoneNumber &number ); |
491 | 494 | ||
492 | void setPhoneNumber( const KABC::PhoneNumber &number ) | 495 | void setPhoneNumber( const KABC::PhoneNumber &number ) |
493 | { | 496 | { |
494 | mPhoneNumber = number; | 497 | mPhoneNumber = number; |
495 | makeText(); | 498 | makeText(); |
496 | } | 499 | } |
497 | 500 | ||
498 | QString key() { return mPhoneNumber.id(); } | 501 | QString key() { return mPhoneNumber.id(); } |
499 | QString country() { return ""; } | 502 | QString country() { return ""; } |
500 | QString region() { return ""; } | 503 | QString region() { return ""; } |
501 | QString number() { return ""; } | 504 | QString number() { return ""; } |
502 | 505 | ||
503 | KABC::PhoneNumber phoneNumber() { return mPhoneNumber; } | 506 | KABC::PhoneNumber phoneNumber() { return mPhoneNumber; } |
504 | 507 | ||
505 | private: | 508 | private: |
506 | void makeText(); | 509 | void makeText(); |
507 | 510 | ||
508 | KABC::PhoneNumber mPhoneNumber; | 511 | KABC::PhoneNumber mPhoneNumber; |
509 | }; | 512 | }; |
510 | 513 | ||
511 | PhoneViewItem::PhoneViewItem( QListView *parent, const KABC::PhoneNumber &number ) | 514 | PhoneViewItem::PhoneViewItem( QListView *parent, const KABC::PhoneNumber &number ) |
512 | : QListViewItem( parent ), mPhoneNumber( number ) | 515 | : QListViewItem( parent ), mPhoneNumber( number ) |
513 | { | 516 | { |
514 | #ifdef DESKTOP_VERSION | 517 | #ifdef DESKTOP_VERSION |
515 | setRenameEnabled ( 0, true ); | 518 | setRenameEnabled ( 0, true ); |
516 | #endif | 519 | #endif |
517 | makeText(); | 520 | makeText(); |
518 | } | 521 | } |
519 | 522 | ||
520 | void PhoneViewItem::makeText() | 523 | void PhoneViewItem::makeText() |
521 | { | 524 | { |
522 | /** | 525 | /** |
523 | * Will be used in future versions of kaddressbook/libkabc | 526 | * Will be used in future versions of kaddressbook/libkabc |
524 | 527 | ||
525 | setText( 0, mPhoneNumber.country() ); | 528 | setText( 0, mPhoneNumber.country() ); |
526 | setText( 1, mPhoneNumber.region() ); | 529 | setText( 1, mPhoneNumber.region() ); |
527 | setText( 2, mPhoneNumber.number() ); | 530 | setText( 2, mPhoneNumber.number() ); |
528 | setText( 3, mPhoneNumber.typeLabel() ); | 531 | setText( 3, mPhoneNumber.typeLabel() ); |
529 | */ | 532 | */ |
530 | 533 | ||
531 | setText( 0, mPhoneNumber.number() ); | 534 | setText( 0, mPhoneNumber.number() ); |
532 | setText( 1, mPhoneNumber.typeLabel() ); | 535 | setText( 1, mPhoneNumber.typeLabel() ); |
533 | } | 536 | } |
534 | 537 | ||
535 | PhoneEditDialog::PhoneEditDialog( const KABC::PhoneNumber::List &list, QWidget *parent, const char *name ) | 538 | PhoneEditDialog::PhoneEditDialog( const KABC::PhoneNumber::List &list, QWidget *parent, const char *name ) |
536 | : KDialogBase( KDialogBase::Plain, i18n( "Edit Phone Numbers" ), | 539 | : KDialogBase( KDialogBase::Plain, i18n( "Edit Phone Numbers" ), |
537 | KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, | 540 | KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, |
538 | parent, name, true) | 541 | parent, name, true) |
539 | { | 542 | { |
540 | mPhoneNumberList = list; | 543 | mPhoneNumberList = list; |
541 | 544 | ||
542 | QWidget *page = plainPage(); | 545 | QWidget *page = plainPage(); |
543 | 546 | ||
544 | QGridLayout *layout = new QGridLayout( page, 1, 2 ); | 547 | QGridLayout *layout = new QGridLayout( page, 1, 2 ); |
545 | layout->setSpacing( spacingHint() ); | 548 | layout->setSpacing( spacingHint() ); |
546 | 549 | ||
547 | mListView = new KListView( page ); | 550 | mListView = new KListView( page ); |
548 | mListView->setAllColumnsShowFocus( true ); | 551 | mListView->setAllColumnsShowFocus( true ); |
549 | mListView->addColumn( i18n( "Number" ) ); | 552 | mListView->addColumn( i18n( "Number" ) ); |
550 | mListView->addColumn( i18n( "Type" ) ); | 553 | mListView->addColumn( i18n( "Type" ) ); |
551 | 554 | ||
552 | KButtonBox *buttonBox = new KButtonBox( page, Vertical ); | 555 | KButtonBox *buttonBox = new KButtonBox( page, Vertical ); |
553 | 556 | ||
554 | buttonBox->addButton( i18n( "&Add..." ), this, SLOT( slotAddPhoneNumber() ) ); | 557 | buttonBox->addButton( i18n( "&Add..." ), this, SLOT( slotAddPhoneNumber() ) ); |
555 | mEditButton = buttonBox->addButton( i18n( "&Edit..." ), this, SLOT( slotEditPhoneNumber() ) ); | 558 | mEditButton = buttonBox->addButton( i18n( "&Edit..." ), this, SLOT( slotEditPhoneNumber() ) ); |
556 | mEditButton->setEnabled( false ); | 559 | mEditButton->setEnabled( false ); |
557 | mRemoveButton = buttonBox->addButton( i18n( "&Remove" ), this, SLOT( slotRemovePhoneNumber() ) ); | 560 | mRemoveButton = buttonBox->addButton( i18n( "&Remove" ), this, SLOT( slotRemovePhoneNumber() ) ); |
558 | mRemoveButton->setEnabled( false ); | 561 | mRemoveButton->setEnabled( false ); |
559 | buttonBox->layout(); | 562 | buttonBox->layout(); |
560 | 563 | ||
561 | layout->addWidget( mListView, 0, 0 ); | 564 | layout->addWidget( mListView, 0, 0 ); |
562 | layout->addWidget( buttonBox, 0, 1 ); | 565 | layout->addWidget( buttonBox, 0, 1 ); |
563 | 566 | ||
564 | connect( mListView, SIGNAL(selectionChanged()), SLOT(slotSelectionChanged()) ); | 567 | connect( mListView, SIGNAL(selectionChanged()), SLOT(slotSelectionChanged()) ); |
565 | connect( mListView, SIGNAL(doubleClicked( QListViewItem *, const QPoint &, int )), this, SLOT( slotEditPhoneNumber())); | 568 | connect( mListView, SIGNAL(doubleClicked( QListViewItem *, const QPoint &, int )), this, SLOT( slotEditPhoneNumber())); |
566 | 569 | ||
567 | KABC::PhoneNumber::List::Iterator it; | 570 | KABC::PhoneNumber::List::Iterator it; |
568 | for ( it = mPhoneNumberList.begin(); it != mPhoneNumberList.end(); ++it ) | 571 | for ( it = mPhoneNumberList.begin(); it != mPhoneNumberList.end(); ++it ) |
569 | new PhoneViewItem( mListView, *it ); | 572 | new PhoneViewItem( mListView, *it ); |
570 | if (QApplication::desktop()->width() < 480 ) | 573 | if (QApplication::desktop()->width() < 480 ) |
571 | showMaximized(); | 574 | showMaximized(); |
572 | else | 575 | else |
573 | resize( 400, 400 ); | 576 | resize( 400, 400 ); |
574 | mChanged = false; | 577 | mChanged = false; |
575 | } | 578 | } |
576 | 579 | ||
577 | PhoneEditDialog::~PhoneEditDialog() | 580 | PhoneEditDialog::~PhoneEditDialog() |
578 | { | 581 | { |
579 | qDebug("PhoneEditDialog::~PhoneEditDialog() "); | 582 | qDebug("PhoneEditDialog::~PhoneEditDialog() "); |
580 | } | 583 | } |
581 | 584 | ||
582 | void PhoneEditDialog::slotAddPhoneNumber() | 585 | void PhoneEditDialog::slotAddPhoneNumber() |
583 | { | 586 | { |
584 | KABC::PhoneNumber tmp( "", 0 ); | 587 | KABC::PhoneNumber tmp( "", 0 ); |
585 | PhoneTypeDialog dlg( tmp, this ); | 588 | PhoneTypeDialog dlg( tmp, this ); |
586 | 589 | ||
587 | if ( dlg.exec() ) { | 590 | if ( dlg.exec() ) { |
588 | QListViewItem* i = mListView->firstChild(); | 591 | QListViewItem* i = mListView->firstChild(); |
589 | KABC::PhoneNumber phoneNumber = dlg.phoneNumber(); | 592 | KABC::PhoneNumber phoneNumber = dlg.phoneNumber(); |
590 | bool insert = true; | 593 | bool insert = true; |
591 | while ( i ) { | 594 | while ( i ) { |
592 | PhoneViewItem* p = ( PhoneViewItem* ) i; | 595 | PhoneViewItem* p = ( PhoneViewItem* ) i; |
593 | KABC::PhoneNumber pn = p->phoneNumber(); | 596 | KABC::PhoneNumber pn = p->phoneNumber(); |
594 | if ( (pn.type() | KABC::PhoneNumber::Pref) == (phoneNumber.type() | KABC::PhoneNumber::Pref) ) { | 597 | if ( (pn.type() | KABC::PhoneNumber::Pref) == (phoneNumber.type() | KABC::PhoneNumber::Pref) ) { |
595 | if ( p->text(0).isEmpty()) { | 598 | if ( p->text(0).isEmpty()) { |
596 | p->setPhoneNumber( phoneNumber ); | 599 | p->setPhoneNumber( phoneNumber ); |
597 | mPhoneNumberList.remove( pn ); | 600 | mPhoneNumberList.remove( pn ); |
598 | mPhoneNumberList.append( phoneNumber ); | 601 | mPhoneNumberList.append( phoneNumber ); |
599 | insert = false; | 602 | insert = false; |
600 | break; | 603 | break; |
601 | } | 604 | } |
602 | } | 605 | } |
603 | i = i->nextSibling(); | 606 | i = i->nextSibling(); |
604 | } | 607 | } |
605 | if ( insert ) { | 608 | if ( insert ) { |
606 | mPhoneNumberList.append( phoneNumber ); | 609 | mPhoneNumberList.append( phoneNumber ); |
607 | new PhoneViewItem( mListView, phoneNumber ); | 610 | new PhoneViewItem( mListView, phoneNumber ); |
608 | } | 611 | } |
609 | mChanged = true; | 612 | mChanged = true; |
610 | } | 613 | } |
611 | } | 614 | } |
612 | 615 | ||
613 | void PhoneEditDialog::slotRemovePhoneNumber() | 616 | void PhoneEditDialog::slotRemovePhoneNumber() |
614 | { | 617 | { |
615 | PhoneViewItem *item = static_cast<PhoneViewItem*>( mListView->currentItem() ); | 618 | PhoneViewItem *item = static_cast<PhoneViewItem*>( mListView->currentItem() ); |
616 | if ( !item ) | 619 | if ( !item ) |
617 | return; | 620 | return; |
618 | 621 | ||
619 | mPhoneNumberList.remove( item->phoneNumber() ); | 622 | mPhoneNumberList.remove( item->phoneNumber() ); |
620 | QListViewItem *currItem = mListView->currentItem(); | 623 | QListViewItem *currItem = mListView->currentItem(); |
621 | mListView->takeItem( currItem ); | 624 | mListView->takeItem( currItem ); |
622 | delete currItem; | 625 | delete currItem; |
623 | 626 | ||
624 | mChanged = true; | 627 | mChanged = true; |
625 | } | 628 | } |
626 | 629 | ||
627 | void PhoneEditDialog::slotEditPhoneNumber() | 630 | void PhoneEditDialog::slotEditPhoneNumber() |
628 | { | 631 | { |
629 | PhoneViewItem *item = static_cast<PhoneViewItem*>( mListView->currentItem() ); | 632 | PhoneViewItem *item = static_cast<PhoneViewItem*>( mListView->currentItem() ); |
630 | if ( !item ) | 633 | if ( !item ) |
631 | return; | 634 | return; |
632 | 635 | ||
633 | PhoneTypeDialog dlg( item->phoneNumber(), this ); | 636 | PhoneTypeDialog dlg( item->phoneNumber(), this ); |
634 | 637 | ||
635 | if ( dlg.exec() ) { | 638 | if ( dlg.exec() ) { |
636 | slotRemovePhoneNumber(); | 639 | slotRemovePhoneNumber(); |
637 | KABC::PhoneNumber phoneNumber = dlg.phoneNumber(); | 640 | KABC::PhoneNumber phoneNumber = dlg.phoneNumber(); |
638 | mPhoneNumberList.append( phoneNumber ); | 641 | mPhoneNumberList.append( phoneNumber ); |
639 | new PhoneViewItem( mListView, phoneNumber ); | 642 | new PhoneViewItem( mListView, phoneNumber ); |
640 | 643 | ||
641 | mChanged = true; | 644 | mChanged = true; |
642 | } | 645 | } |
643 | } | 646 | } |
644 | 647 | ||
645 | void PhoneEditDialog::slotSelectionChanged() | 648 | void PhoneEditDialog::slotSelectionChanged() |
646 | { | 649 | { |
647 | bool state = ( mListView->currentItem() != 0 ); | 650 | bool state = ( mListView->currentItem() != 0 ); |
648 | 651 | ||
649 | mRemoveButton->setEnabled( state ); | 652 | mRemoveButton->setEnabled( state ); |
650 | mEditButton->setEnabled( state ); | 653 | mEditButton->setEnabled( state ); |
651 | } | 654 | } |
652 | 655 | ||
653 | const KABC::PhoneNumber::List &PhoneEditDialog::phoneNumbers() | 656 | const KABC::PhoneNumber::List &PhoneEditDialog::phoneNumbers() |
654 | { | 657 | { |
655 | return mPhoneNumberList; | 658 | return mPhoneNumberList; |
656 | } | 659 | } |
657 | 660 | ||
658 | bool PhoneEditDialog::changed() const | 661 | bool PhoneEditDialog::changed() const |
659 | { | 662 | { |
660 | return mChanged; | 663 | return mChanged; |
661 | } | 664 | } |
662 | 665 | ||
663 | /////////////////////////////////////////// | 666 | /////////////////////////////////////////// |
664 | // PhoneTypeDialog | 667 | // PhoneTypeDialog |
665 | PhoneTypeDialog::PhoneTypeDialog( const KABC::PhoneNumber &phoneNumber, | 668 | PhoneTypeDialog::PhoneTypeDialog( const KABC::PhoneNumber &phoneNumber, |
666 | QWidget *parent, const char *name) | 669 | QWidget *parent, const char *name) |
667 | : KDialogBase( KDialogBase::Plain, i18n( "Edit Phone Number" ), | 670 | : KDialogBase( KDialogBase::Plain, i18n( "Edit Phone Number" ), |
668 | KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, | 671 | KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, |
669 | parent, name, true), mPhoneNumber( phoneNumber ) | 672 | parent, name, true), mPhoneNumber( phoneNumber ) |
670 | { | 673 | { |
671 | QWidget *page = plainPage(); | 674 | QWidget *page = plainPage(); |
672 | QLabel *label = 0; | 675 | QLabel *label = 0; |
673 | QGridLayout *layout = new QGridLayout( page, 3, 2, marginHint(), spacingHint() ); | 676 | QGridLayout *layout = new QGridLayout( page, 3, 2, marginHint(), spacingHint() ); |
674 | 677 | ||
675 | label = new QLabel( i18n( "Number:" ), page ); | 678 | label = new QLabel( i18n( "Number:" ), page ); |
676 | layout->addWidget( label, 0, 0 ); | 679 | layout->addWidget( label, 0, 0 ); |
677 | mNumber = new KLineEdit( page ); | 680 | mNumber = new KLineEdit( page ); |
678 | layout->addWidget( mNumber, 0, 1 ); | 681 | layout->addWidget( mNumber, 0, 1 ); |
679 | 682 | ||
680 | mPreferredBox = new QCheckBox( i18n( "This is the preferred phone number" ), page ); | 683 | mPreferredBox = new QCheckBox( i18n( "This is the preferred phone number" ), page ); |
681 | layout->addMultiCellWidget( mPreferredBox, 1, 1, 0, 1 ); | 684 | layout->addMultiCellWidget( mPreferredBox, 1, 1, 0, 1 ); |
682 | 685 | ||
683 | mGroup = new QButtonGroup( 2, Horizontal, i18n( "Types" ), page ); | 686 | mGroup = new QButtonGroup( 2, Horizontal, i18n( "Types" ), page ); |
684 | layout->addMultiCellWidget( mGroup, 2, 2, 0, 1 ); | 687 | layout->addMultiCellWidget( mGroup, 2, 2, 0, 1 ); |
685 | 688 | ||
686 | // fill widgets | 689 | // fill widgets |
687 | mNumber->setText( mPhoneNumber.number() ); | 690 | mNumber->setText( mPhoneNumber.number() ); |
688 | 691 | ||
689 | mTypeList = KABC::PhoneNumber::typeList(); | 692 | mTypeList = KABC::PhoneNumber::typeList(); |
690 | mTypeList.remove( KABC::PhoneNumber::Pref ); | 693 | mTypeList.remove( KABC::PhoneNumber::Pref ); |
691 | 694 | ||
692 | KABC::PhoneNumber::TypeList::Iterator it; | 695 | KABC::PhoneNumber::TypeList::Iterator it; |
693 | for ( it = mTypeList.begin(); it != mTypeList.end(); ++it ) | 696 | for ( it = mTypeList.begin(); it != mTypeList.end(); ++it ) |
694 | new QCheckBox( KABC::PhoneNumber::typeLabel( *it ), mGroup ); | 697 | new QCheckBox( KABC::PhoneNumber::typeLabel( *it ), mGroup ); |
695 | 698 | ||
696 | for ( int i = 0; i < mGroup->count(); ++i ) { | 699 | for ( int i = 0; i < mGroup->count(); ++i ) { |
697 | int type = mPhoneNumber.type(); | 700 | int type = mPhoneNumber.type(); |
698 | QCheckBox *box = (QCheckBox*)mGroup->find( i ); | 701 | QCheckBox *box = (QCheckBox*)mGroup->find( i ); |
699 | box->setChecked( type & mTypeList[ i ] ); | 702 | box->setChecked( type & mTypeList[ i ] ); |
700 | } | 703 | } |
701 | 704 | ||
702 | mPreferredBox->setChecked( mPhoneNumber.type() & KABC::PhoneNumber::Pref ); | 705 | mPreferredBox->setChecked( mPhoneNumber.type() & KABC::PhoneNumber::Pref ); |
703 | mNumber->setFocus(); | 706 | mNumber->setFocus(); |
704 | mNumber->setSelection( 0, 1024); | 707 | mNumber->setSelection( 0, 1024); |
705 | } | 708 | } |
706 | 709 | ||
707 | KABC::PhoneNumber PhoneTypeDialog::phoneNumber() | 710 | KABC::PhoneNumber PhoneTypeDialog::phoneNumber() |
708 | { | 711 | { |
709 | mPhoneNumber.setNumber( mNumber->text() ); | 712 | mPhoneNumber.setNumber( mNumber->text() ); |
710 | 713 | ||
711 | int type = 0; | 714 | int type = 0; |
712 | for ( int i = 0; i < mGroup->count(); ++i ) { | 715 | for ( int i = 0; i < mGroup->count(); ++i ) { |
713 | QCheckBox *box = (QCheckBox*)mGroup->find( i ); | 716 | QCheckBox *box = (QCheckBox*)mGroup->find( i ); |
714 | if ( box->isChecked() ) | 717 | if ( box->isChecked() ) |
715 | type += mTypeList[ i ]; | 718 | type += mTypeList[ i ]; |
716 | } | 719 | } |
717 | 720 | ||
718 | if ( mPreferredBox->isChecked() ) | 721 | if ( mPreferredBox->isChecked() ) |
719 | mPhoneNumber.setType( type | KABC::PhoneNumber::Pref ); | 722 | mPhoneNumber.setType( type | KABC::PhoneNumber::Pref ); |
720 | else | 723 | else |
721 | mPhoneNumber.setType( type & ~KABC::PhoneNumber::Pref ); | 724 | mPhoneNumber.setType( type & ~KABC::PhoneNumber::Pref ); |
722 | 725 | ||
723 | return mPhoneNumber; | 726 | return mPhoneNumber; |
724 | } | 727 | } |
725 | #endif | 728 | #endif |
726 | #ifndef KAB_EMBEDDED | 729 | #ifndef KAB_EMBEDDED |
727 | #include "phoneeditwidget.moc" | 730 | #include "phoneeditwidget.moc" |
728 | #endif //KAB_EMBEDDED | 731 | #endif //KAB_EMBEDDED |