author | zautrix <zautrix> | 2004-10-08 23:38:07 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-08 23:38:07 (UTC) |
commit | 07fdef2c2ea1153d39d7114b3d5bd4abc4f4c861 (patch) (unidiff) | |
tree | 03d0e5d20e607e035e17fcdabd6bce789069f41e /kaddressbook | |
parent | 44169895703beb3e8b1551a313d2d341bf742905 (diff) | |
download | kdepimpi-07fdef2c2ea1153d39d7114b3d5bd4abc4f4c861.zip kdepimpi-07fdef2c2ea1153d39d7114b3d5bd4abc4f4c861.tar.gz kdepimpi-07fdef2c2ea1153d39d7114b3d5bd4abc4f4c861.tar.bz2 |
some bugfixes
-rw-r--r-- | kaddressbook/kabcore.cpp | 8 | ||||
-rw-r--r-- | kaddressbook/kabprefs.cpp | 3 |
2 files changed, 7 insertions, 4 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 939296f..9b059d3 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1,1472 +1,1474 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressbook. | 2 | This file is part of KAddressbook. |
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /*s | 24 | /*s |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include "kabcore.h" | 31 | #include "kabcore.h" |
32 | 32 | ||
33 | #include <stdaddressbook.h> | 33 | #include <stdaddressbook.h> |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | #include <kfiledialog.h> | 35 | #include <kfiledialog.h> |
36 | #include <qtimer.h> | 36 | #include <qtimer.h> |
37 | #include <qlabel.h> | 37 | #include <qlabel.h> |
38 | #include <qregexp.h> | 38 | #include <qregexp.h> |
39 | #include <qlineedit.h> | 39 | #include <qlineedit.h> |
40 | #include <qcheckbox.h> | 40 | #include <qcheckbox.h> |
41 | #include <qpushbutton.h> | 41 | #include <qpushbutton.h> |
42 | #include <qprogressbar.h> | 42 | #include <qprogressbar.h> |
43 | #include <libkdepim/phoneaccess.h> | 43 | #include <libkdepim/phoneaccess.h> |
44 | 44 | ||
45 | #ifndef KAB_EMBEDDED | 45 | #ifndef KAB_EMBEDDED |
46 | #include <qclipboard.h> | 46 | #include <qclipboard.h> |
47 | #include <qdir.h> | 47 | #include <qdir.h> |
48 | #include <qfile.h> | 48 | #include <qfile.h> |
49 | #include <qapplicaton.h> | 49 | #include <qapplicaton.h> |
50 | #include <qprogressbar.h> | 50 | #include <qprogressbar.h> |
51 | #include <qlayout.h> | 51 | #include <qlayout.h> |
52 | #include <qregexp.h> | 52 | #include <qregexp.h> |
53 | #include <qvbox.h> | 53 | #include <qvbox.h> |
54 | #include <kabc/addresseelist.h> | 54 | #include <kabc/addresseelist.h> |
55 | #include <kabc/errorhandler.h> | 55 | #include <kabc/errorhandler.h> |
56 | #include <kabc/resource.h> | 56 | #include <kabc/resource.h> |
57 | #include <kabc/vcardconverter.h> | 57 | #include <kabc/vcardconverter.h> |
58 | #include <kapplication.h> | 58 | #include <kapplication.h> |
59 | #include <kactionclasses.h> | 59 | #include <kactionclasses.h> |
60 | #include <kcmultidialog.h> | 60 | #include <kcmultidialog.h> |
61 | #include <kdebug.h> | 61 | #include <kdebug.h> |
62 | #include <kdeversion.h> | 62 | #include <kdeversion.h> |
63 | #include <kkeydialog.h> | 63 | #include <kkeydialog.h> |
64 | #include <kmessagebox.h> | 64 | #include <kmessagebox.h> |
65 | #include <kprinter.h> | 65 | #include <kprinter.h> |
66 | #include <kprotocolinfo.h> | 66 | #include <kprotocolinfo.h> |
67 | #include <kresources/selectdialog.h> | 67 | #include <kresources/selectdialog.h> |
68 | #include <kstandarddirs.h> | 68 | #include <kstandarddirs.h> |
69 | #include <ktempfile.h> | 69 | #include <ktempfile.h> |
70 | #include <kxmlguiclient.h> | 70 | #include <kxmlguiclient.h> |
71 | #include <kaboutdata.h> | 71 | #include <kaboutdata.h> |
72 | #include <libkdepim/categoryselectdialog.h> | 72 | #include <libkdepim/categoryselectdialog.h> |
73 | 73 | ||
74 | #include "addresseeutil.h" | 74 | #include "addresseeutil.h" |
75 | #include "addresseeeditordialog.h" | 75 | #include "addresseeeditordialog.h" |
76 | #include "extensionmanager.h" | 76 | #include "extensionmanager.h" |
77 | #include "kstdaction.h" | 77 | #include "kstdaction.h" |
78 | #include "kaddressbookservice.h" | 78 | #include "kaddressbookservice.h" |
79 | #include "ldapsearchdialog.h" | 79 | #include "ldapsearchdialog.h" |
80 | #include "printing/printingwizard.h" | 80 | #include "printing/printingwizard.h" |
81 | #else // KAB_EMBEDDED | 81 | #else // KAB_EMBEDDED |
82 | 82 | ||
83 | #include <kapplication.h> | 83 | #include <kapplication.h> |
84 | #include "KDGanttMinimizeSplitter.h" | 84 | #include "KDGanttMinimizeSplitter.h" |
85 | #include "kaddressbookmain.h" | 85 | #include "kaddressbookmain.h" |
86 | #include "kactioncollection.h" | 86 | #include "kactioncollection.h" |
87 | #include "addresseedialog.h" | 87 | #include "addresseedialog.h" |
88 | //US | 88 | //US |
89 | #include <addresseeview.h> | 89 | #include <addresseeview.h> |
90 | 90 | ||
91 | #include <qapp.h> | 91 | #include <qapp.h> |
92 | #include <qmenubar.h> | 92 | #include <qmenubar.h> |
93 | //#include <qtoolbar.h> | 93 | //#include <qtoolbar.h> |
94 | #include <qmessagebox.h> | 94 | #include <qmessagebox.h> |
95 | #include <kdebug.h> | 95 | #include <kdebug.h> |
96 | #include <kiconloader.h> // needed for SmallIcon | 96 | #include <kiconloader.h> // needed for SmallIcon |
97 | #include <kresources/kcmkresources.h> | 97 | #include <kresources/kcmkresources.h> |
98 | #include <ktoolbar.h> | 98 | #include <ktoolbar.h> |
99 | 99 | ||
100 | 100 | ||
101 | //#include <qlabel.h> | 101 | //#include <qlabel.h> |
102 | 102 | ||
103 | 103 | ||
104 | #ifndef DESKTOP_VERSION | 104 | #ifndef DESKTOP_VERSION |
105 | #include <qpe/ir.h> | 105 | #include <qpe/ir.h> |
106 | #include <qpe/qpemenubar.h> | 106 | #include <qpe/qpemenubar.h> |
107 | #include <qtopia/qcopenvelope_qws.h> | 107 | #include <qtopia/qcopenvelope_qws.h> |
108 | #else | 108 | #else |
109 | 109 | ||
110 | #include <qmenubar.h> | 110 | #include <qmenubar.h> |
111 | #endif | 111 | #endif |
112 | 112 | ||
113 | #endif // KAB_EMBEDDED | 113 | #endif // KAB_EMBEDDED |
114 | #include "kcmconfigs/kcmkabconfig.h" | 114 | #include "kcmconfigs/kcmkabconfig.h" |
115 | #include "kcmconfigs/kcmkdepimconfig.h" | 115 | #include "kcmconfigs/kcmkdepimconfig.h" |
116 | #include "kpimglobalprefs.h" | 116 | #include "kpimglobalprefs.h" |
117 | #include "externalapphandler.h" | 117 | #include "externalapphandler.h" |
118 | 118 | ||
119 | 119 | ||
120 | #include <kresources/selectdialog.h> | 120 | #include <kresources/selectdialog.h> |
121 | #include <kmessagebox.h> | 121 | #include <kmessagebox.h> |
122 | 122 | ||
123 | #include <picture.h> | 123 | #include <picture.h> |
124 | #include <resource.h> | 124 | #include <resource.h> |
125 | 125 | ||
126 | //US#include <qsplitter.h> | 126 | //US#include <qsplitter.h> |
127 | #include <qmap.h> | 127 | #include <qmap.h> |
128 | #include <qdir.h> | 128 | #include <qdir.h> |
129 | #include <qfile.h> | 129 | #include <qfile.h> |
130 | #include <qvbox.h> | 130 | #include <qvbox.h> |
131 | #include <qlayout.h> | 131 | #include <qlayout.h> |
132 | #include <qclipboard.h> | 132 | #include <qclipboard.h> |
133 | #include <qtextstream.h> | 133 | #include <qtextstream.h> |
134 | 134 | ||
135 | #include <libkdepim/categoryselectdialog.h> | 135 | #include <libkdepim/categoryselectdialog.h> |
136 | #include <kabc/vcardconverter.h> | 136 | #include <kabc/vcardconverter.h> |
137 | 137 | ||
138 | 138 | ||
139 | #include "addresseeutil.h" | 139 | #include "addresseeutil.h" |
140 | #include "undocmds.h" | 140 | #include "undocmds.h" |
141 | #include "addresseeeditordialog.h" | 141 | #include "addresseeeditordialog.h" |
142 | #include "viewmanager.h" | 142 | #include "viewmanager.h" |
143 | #include "details/detailsviewcontainer.h" | 143 | #include "details/detailsviewcontainer.h" |
144 | #include "kabprefs.h" | 144 | #include "kabprefs.h" |
145 | #include "xxportmanager.h" | 145 | #include "xxportmanager.h" |
146 | #include "incsearchwidget.h" | 146 | #include "incsearchwidget.h" |
147 | #include "jumpbuttonbar.h" | 147 | #include "jumpbuttonbar.h" |
148 | #include "extensionmanager.h" | 148 | #include "extensionmanager.h" |
149 | #include "addresseeconfig.h" | 149 | #include "addresseeconfig.h" |
150 | #include <kcmultidialog.h> | 150 | #include <kcmultidialog.h> |
151 | 151 | ||
152 | #ifdef _WIN32_ | 152 | #ifdef _WIN32_ |
153 | 153 | ||
154 | #include "kaimportoldialog.h" | 154 | #include "kaimportoldialog.h" |
155 | #else | 155 | #else |
156 | #include <unistd.h> | 156 | #include <unistd.h> |
157 | #endif | 157 | #endif |
158 | // sync includes | 158 | // sync includes |
159 | #include <libkdepim/ksyncprofile.h> | 159 | #include <libkdepim/ksyncprofile.h> |
160 | #include <libkdepim/ksyncprefsdialog.h> | 160 | #include <libkdepim/ksyncprefsdialog.h> |
161 | 161 | ||
162 | class KAex2phonePrefs : public QDialog | 162 | class KAex2phonePrefs : public QDialog |
163 | { | 163 | { |
164 | public: | 164 | public: |
165 | KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : | 165 | KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : |
166 | QDialog( parent, name, true ) | 166 | QDialog( parent, name, true ) |
167 | { | 167 | { |
168 | setCaption( i18n("Export to phone options") ); | 168 | setCaption( i18n("Export to phone options") ); |
169 | QVBoxLayout* lay = new QVBoxLayout( this ); | 169 | QVBoxLayout* lay = new QVBoxLayout( this ); |
170 | lay->setSpacing( 3 ); | 170 | lay->setSpacing( 3 ); |
171 | lay->setMargin( 3 ); | 171 | lay->setMargin( 3 ); |
172 | QLabel *lab; | 172 | QLabel *lab; |
173 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); | 173 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); |
174 | lab->setAlignment (AlignHCenter ); | 174 | lab->setAlignment (AlignHCenter ); |
175 | QHBox* temphb; | 175 | QHBox* temphb; |
176 | temphb = new QHBox( this ); | 176 | temphb = new QHBox( this ); |
177 | new QLabel( i18n("I/O device: "), temphb ); | 177 | new QLabel( i18n("I/O device: "), temphb ); |
178 | mPhoneDevice = new QLineEdit( temphb); | 178 | mPhoneDevice = new QLineEdit( temphb); |
179 | lay->addWidget( temphb ); | 179 | lay->addWidget( temphb ); |
180 | temphb = new QHBox( this ); | 180 | temphb = new QHBox( this ); |
181 | new QLabel( i18n("Connection: "), temphb ); | 181 | new QLabel( i18n("Connection: "), temphb ); |
182 | mPhoneConnection = new QLineEdit( temphb); | 182 | mPhoneConnection = new QLineEdit( temphb); |
183 | lay->addWidget( temphb ); | 183 | lay->addWidget( temphb ); |
184 | temphb = new QHBox( this ); | 184 | temphb = new QHBox( this ); |
185 | new QLabel( i18n("Model(opt.): "), temphb ); | 185 | new QLabel( i18n("Model(opt.): "), temphb ); |
186 | mPhoneModel = new QLineEdit( temphb); | 186 | mPhoneModel = new QLineEdit( temphb); |
187 | lay->addWidget( temphb ); | 187 | lay->addWidget( temphb ); |
188 | mWriteToSim= new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); | 188 | mWriteToSim= new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); |
189 | lay->addWidget( mWriteToSim ); | 189 | lay->addWidget( mWriteToSim ); |
190 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); | 190 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); |
191 | lab->setAlignment (AlignHCenter ); | 191 | lab->setAlignment (AlignHCenter ); |
192 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); | 192 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); |
193 | lay->addWidget( ok ); | 193 | lay->addWidget( ok ); |
194 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 194 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
195 | lay->addWidget( cancel ); | 195 | lay->addWidget( cancel ); |
196 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 196 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
197 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 197 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
198 | resize( 220, 240 ); | 198 | resize( 220, 240 ); |
199 | 199 | ||
200 | } | 200 | } |
201 | 201 | ||
202 | public: | 202 | public: |
203 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | 203 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; |
204 | QCheckBox* mWriteToSim; | 204 | QCheckBox* mWriteToSim; |
205 | }; | 205 | }; |
206 | 206 | ||
207 | bool pasteWithNewUid = true; | 207 | bool pasteWithNewUid = true; |
208 | 208 | ||
209 | #ifdef KAB_EMBEDDED | 209 | #ifdef KAB_EMBEDDED |
210 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 210 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) |
211 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 211 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
212 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ | 212 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ |
213 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) | 213 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) |
214 | #else //KAB_EMBEDDED | 214 | #else //KAB_EMBEDDED |
215 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 215 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) |
216 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 216 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
217 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), | 217 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), |
218 | mReadWrite( readWrite ), mModified( false ) | 218 | mReadWrite( readWrite ), mModified( false ) |
219 | #endif //KAB_EMBEDDED | 219 | #endif //KAB_EMBEDDED |
220 | { | 220 | { |
221 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 221 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
222 | // syncManager->setBlockSave(false); | 222 | // syncManager->setBlockSave(false); |
223 | mExtensionBarSplitter = 0; | 223 | mExtensionBarSplitter = 0; |
224 | mIsPart = !parent->inherits( "KAddressBookMain" ); | 224 | mIsPart = !parent->inherits( "KAddressBookMain" ); |
225 | 225 | ||
226 | mAddressBook = KABC::StdAddressBook::self(); | 226 | mAddressBook = KABC::StdAddressBook::self(); |
227 | KABC::StdAddressBook::setAutomaticSave( false ); | 227 | KABC::StdAddressBook::setAutomaticSave( false ); |
228 | 228 | ||
229 | #ifndef KAB_EMBEDDED | 229 | #ifndef KAB_EMBEDDED |
230 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); | 230 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); |
231 | #endif //KAB_EMBEDDED | 231 | #endif //KAB_EMBEDDED |
232 | 232 | ||
233 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), | 233 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), |
234 | SLOT( addressBookChanged() ) ); | 234 | SLOT( addressBookChanged() ) ); |
235 | 235 | ||
236 | #if 0 | 236 | #if 0 |
237 | // LP moved to addressbook init method | 237 | // LP moved to addressbook init method |
238 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, | 238 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, |
239 | "X-Department", "KADDRESSBOOK" ); | 239 | "X-Department", "KADDRESSBOOK" ); |
240 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 240 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
241 | "X-Profession", "KADDRESSBOOK" ); | 241 | "X-Profession", "KADDRESSBOOK" ); |
242 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 242 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
243 | "X-AssistantsName", "KADDRESSBOOK" ); | 243 | "X-AssistantsName", "KADDRESSBOOK" ); |
244 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 244 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
245 | "X-ManagersName", "KADDRESSBOOK" ); | 245 | "X-ManagersName", "KADDRESSBOOK" ); |
246 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 246 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
247 | "X-SpousesName", "KADDRESSBOOK" ); | 247 | "X-SpousesName", "KADDRESSBOOK" ); |
248 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, | 248 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, |
249 | "X-Office", "KADDRESSBOOK" ); | 249 | "X-Office", "KADDRESSBOOK" ); |
250 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 250 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
251 | "X-IMAddress", "KADDRESSBOOK" ); | 251 | "X-IMAddress", "KADDRESSBOOK" ); |
252 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 252 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
253 | "X-Anniversary", "KADDRESSBOOK" ); | 253 | "X-Anniversary", "KADDRESSBOOK" ); |
254 | 254 | ||
255 | //US added this field to become compatible with Opie/qtopia addressbook | 255 | //US added this field to become compatible with Opie/qtopia addressbook |
256 | // values can be "female" or "male" or "". An empty field represents undefined. | 256 | // values can be "female" or "male" or "". An empty field represents undefined. |
257 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 257 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
258 | "X-Gender", "KADDRESSBOOK" ); | 258 | "X-Gender", "KADDRESSBOOK" ); |
259 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, | 259 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, |
260 | "X-Children", "KADDRESSBOOK" ); | 260 | "X-Children", "KADDRESSBOOK" ); |
261 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 261 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
262 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 262 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
263 | #endif | 263 | #endif |
264 | initGUI(); | 264 | initGUI(); |
265 | 265 | ||
266 | mIncSearchWidget->setFocus(); | 266 | mIncSearchWidget->setFocus(); |
267 | 267 | ||
268 | 268 | ||
269 | connect( mViewManager, SIGNAL( selected( const QString& ) ), | 269 | connect( mViewManager, SIGNAL( selected( const QString& ) ), |
270 | SLOT( setContactSelected( const QString& ) ) ); | 270 | SLOT( setContactSelected( const QString& ) ) ); |
271 | connect( mViewManager, SIGNAL( executed( const QString& ) ), | 271 | connect( mViewManager, SIGNAL( executed( const QString& ) ), |
272 | SLOT( executeContact( const QString& ) ) ); | 272 | SLOT( executeContact( const QString& ) ) ); |
273 | 273 | ||
274 | connect( mViewManager, SIGNAL( deleteRequest( ) ), | 274 | connect( mViewManager, SIGNAL( deleteRequest( ) ), |
275 | SLOT( deleteContacts( ) ) ); | 275 | SLOT( deleteContacts( ) ) ); |
276 | connect( mViewManager, SIGNAL( modified() ), | 276 | connect( mViewManager, SIGNAL( modified() ), |
277 | SLOT( setModified() ) ); | 277 | SLOT( setModified() ) ); |
278 | 278 | ||
279 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); | 279 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); |
280 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); | 280 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); |
281 | 281 | ||
282 | connect( mXXPortManager, SIGNAL( modified() ), | 282 | connect( mXXPortManager, SIGNAL( modified() ), |
283 | SLOT( setModified() ) ); | 283 | SLOT( setModified() ) ); |
284 | 284 | ||
285 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), | 285 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), |
286 | SLOT( incrementalSearch( const QString& ) ) ); | 286 | SLOT( incrementalSearch( const QString& ) ) ); |
287 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), | 287 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), |
288 | mJumpButtonBar, SLOT( recreateButtons() ) ); | 288 | mJumpButtonBar, SLOT( recreateButtons() ) ); |
289 | 289 | ||
290 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), | 290 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), |
291 | SLOT( sendMail( const QString& ) ) ); | 291 | SLOT( sendMail( const QString& ) ) ); |
292 | 292 | ||
293 | 293 | ||
294 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); | 294 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); |
295 | connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); | 295 | connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); |
296 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); | 296 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); |
297 | 297 | ||
298 | 298 | ||
299 | #ifndef KAB_EMBEDDED | 299 | #ifndef KAB_EMBEDDED |
300 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), | 300 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), |
301 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); | 301 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); |
302 | 302 | ||
303 | connect( mDetails, SIGNAL( browse( const QString& ) ), | 303 | connect( mDetails, SIGNAL( browse( const QString& ) ), |
304 | SLOT( browse( const QString& ) ) ); | 304 | SLOT( browse( const QString& ) ) ); |
305 | 305 | ||
306 | 306 | ||
307 | mAddressBookService = new KAddressBookService( this ); | 307 | mAddressBookService = new KAddressBookService( this ); |
308 | 308 | ||
309 | #endif //KAB_EMBEDDED | 309 | #endif //KAB_EMBEDDED |
310 | mEditorDialog = 0; | 310 | mEditorDialog = 0; |
311 | createAddresseeEditorDialog( this ); | 311 | createAddresseeEditorDialog( this ); |
312 | setModified( false ); | 312 | setModified( false ); |
313 | } | 313 | } |
314 | 314 | ||
315 | KABCore::~KABCore() | 315 | KABCore::~KABCore() |
316 | { | 316 | { |
317 | // save(); | 317 | // save(); |
318 | //saveSettings(); | 318 | //saveSettings(); |
319 | //KABPrefs::instance()->writeConfig(); | 319 | //KABPrefs::instance()->writeConfig(); |
320 | delete AddresseeConfig::instance(); | 320 | delete AddresseeConfig::instance(); |
321 | mAddressBook = 0; | 321 | mAddressBook = 0; |
322 | KABC::StdAddressBook::close(); | 322 | KABC::StdAddressBook::close(); |
323 | |||
324 | delete syncManager; | ||
323 | 325 | ||
324 | delete syncManager; | ||
325 | } | 326 | } |
326 | 327 | ||
327 | void KABCore::restoreSettings() | 328 | void KABCore::restoreSettings() |
328 | { | 329 | { |
329 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; | 330 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; |
330 | 331 | ||
331 | bool state; | 332 | bool state; |
332 | 333 | ||
333 | if (mMultipleViewsAtOnce) | 334 | if (mMultipleViewsAtOnce) |
334 | state = KABPrefs::instance()->mDetailsPageVisible; | 335 | state = KABPrefs::instance()->mDetailsPageVisible; |
335 | else | 336 | else |
336 | state = false; | 337 | state = false; |
337 | 338 | ||
338 | mActionDetails->setChecked( state ); | 339 | mActionDetails->setChecked( state ); |
339 | setDetailsVisible( state ); | 340 | setDetailsVisible( state ); |
340 | 341 | ||
341 | state = KABPrefs::instance()->mJumpButtonBarVisible; | 342 | state = KABPrefs::instance()->mJumpButtonBarVisible; |
342 | 343 | ||
343 | mActionJumpBar->setChecked( state ); | 344 | mActionJumpBar->setChecked( state ); |
344 | setJumpButtonBarVisible( state ); | 345 | setJumpButtonBarVisible( state ); |
345 | /*US | 346 | /*US |
346 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 347 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
347 | if ( splitterSize.count() == 0 ) { | 348 | if ( splitterSize.count() == 0 ) { |
348 | splitterSize.append( width() / 2 ); | 349 | splitterSize.append( width() / 2 ); |
349 | splitterSize.append( width() / 2 ); | 350 | splitterSize.append( width() / 2 ); |
350 | } | 351 | } |
351 | mMiniSplitter->setSizes( splitterSize ); | 352 | mMiniSplitter->setSizes( splitterSize ); |
352 | if ( mExtensionBarSplitter ) { | 353 | if ( mExtensionBarSplitter ) { |
353 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 354 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
354 | if ( splitterSize.count() == 0 ) { | 355 | if ( splitterSize.count() == 0 ) { |
355 | splitterSize.append( width() / 2 ); | 356 | splitterSize.append( width() / 2 ); |
356 | splitterSize.append( width() / 2 ); | 357 | splitterSize.append( width() / 2 ); |
357 | } | 358 | } |
358 | mExtensionBarSplitter->setSizes( splitterSize ); | 359 | mExtensionBarSplitter->setSizes( splitterSize ); |
359 | 360 | ||
360 | } | 361 | } |
361 | */ | 362 | */ |
362 | mViewManager->restoreSettings(); | 363 | mViewManager->restoreSettings(); |
363 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 364 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
364 | mExtensionManager->restoreSettings(); | 365 | mExtensionManager->restoreSettings(); |
365 | #ifdef DESKTOP_VERSION | 366 | #ifdef DESKTOP_VERSION |
366 | int wid = width(); | 367 | int wid = width(); |
367 | if ( wid < 10 ) | 368 | if ( wid < 10 ) |
368 | wid = 400; | 369 | wid = 400; |
369 | #else | 370 | #else |
370 | int wid = QApplication::desktop()->width(); | 371 | int wid = QApplication::desktop()->width(); |
371 | if ( wid < 640 ) | 372 | if ( wid < 640 ) |
372 | wid = QApplication::desktop()->height(); | 373 | wid = QApplication::desktop()->height(); |
373 | #endif | 374 | #endif |
374 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; | 375 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; |
375 | if ( true /*splitterSize.count() == 0*/ ) { | 376 | if ( true /*splitterSize.count() == 0*/ ) { |
376 | splitterSize.append( wid / 2 ); | 377 | splitterSize.append( wid / 2 ); |
377 | splitterSize.append( wid / 2 ); | 378 | splitterSize.append( wid / 2 ); |
378 | } | 379 | } |
379 | mMiniSplitter->setSizes( splitterSize ); | 380 | mMiniSplitter->setSizes( splitterSize ); |
380 | if ( mExtensionBarSplitter ) { | 381 | if ( mExtensionBarSplitter ) { |
381 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 382 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
382 | if ( true /*splitterSize.count() == 0*/ ) { | 383 | if ( true /*splitterSize.count() == 0*/ ) { |
383 | splitterSize.append( wid / 2 ); | 384 | splitterSize.append( wid / 2 ); |
384 | splitterSize.append( wid / 2 ); | 385 | splitterSize.append( wid / 2 ); |
385 | } | 386 | } |
386 | mExtensionBarSplitter->setSizes( splitterSize ); | 387 | mExtensionBarSplitter->setSizes( splitterSize ); |
387 | 388 | ||
388 | } | 389 | } |
389 | 390 | ||
390 | 391 | ||
391 | } | 392 | } |
392 | 393 | ||
393 | void KABCore::saveSettings() | 394 | void KABCore::saveSettings() |
394 | { | 395 | { |
395 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | 396 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); |
396 | if ( mExtensionBarSplitter ) | 397 | if ( mExtensionBarSplitter ) |
397 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 398 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
398 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | 399 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); |
399 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); | 400 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); |
400 | #ifndef KAB_EMBEDDED | 401 | #ifndef KAB_EMBEDDED |
401 | 402 | ||
402 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 403 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
403 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | 404 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); |
404 | #endif //KAB_EMBEDDED | 405 | #endif //KAB_EMBEDDED |
405 | mExtensionManager->saveSettings(); | 406 | mExtensionManager->saveSettings(); |
406 | mViewManager->saveSettings(); | 407 | mViewManager->saveSettings(); |
407 | 408 | ||
408 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 409 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
409 | } | 410 | } |
410 | 411 | ||
411 | KABC::AddressBook *KABCore::addressBook() const | 412 | KABC::AddressBook *KABCore::addressBook() const |
412 | { | 413 | { |
413 | return mAddressBook; | 414 | return mAddressBook; |
414 | } | 415 | } |
415 | 416 | ||
416 | KConfig *KABCore::config() | 417 | KConfig *KABCore::config() |
417 | { | 418 | { |
418 | #ifndef KAB_EMBEDDED | 419 | #ifndef KAB_EMBEDDED |
419 | return KABPrefs::instance()->config(); | 420 | return KABPrefs::instance()->config(); |
420 | #else //KAB_EMBEDDED | 421 | #else //KAB_EMBEDDED |
421 | return KABPrefs::instance()->getConfig(); | 422 | return KABPrefs::instance()->getConfig(); |
422 | #endif //KAB_EMBEDDED | 423 | #endif //KAB_EMBEDDED |
423 | } | 424 | } |
424 | 425 | ||
425 | KActionCollection *KABCore::actionCollection() const | 426 | KActionCollection *KABCore::actionCollection() const |
426 | { | 427 | { |
427 | return mGUIClient->actionCollection(); | 428 | return mGUIClient->actionCollection(); |
428 | } | 429 | } |
429 | 430 | ||
430 | KABC::Field *KABCore::currentSearchField() const | 431 | KABC::Field *KABCore::currentSearchField() const |
431 | { | 432 | { |
432 | if (mIncSearchWidget) | 433 | if (mIncSearchWidget) |
433 | return mIncSearchWidget->currentField(); | 434 | return mIncSearchWidget->currentField(); |
434 | else | 435 | else |
435 | return 0; | 436 | return 0; |
436 | } | 437 | } |
437 | 438 | ||
438 | QStringList KABCore::selectedUIDs() const | 439 | QStringList KABCore::selectedUIDs() const |
439 | { | 440 | { |
440 | return mViewManager->selectedUids(); | 441 | return mViewManager->selectedUids(); |
441 | } | 442 | } |
442 | 443 | ||
443 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 444 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
444 | { | 445 | { |
445 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 446 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
446 | 447 | ||
447 | QPtrList<KRES::Resource> kresResources; | 448 | QPtrList<KRES::Resource> kresResources; |
448 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 449 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
449 | KABC::Resource *resource; | 450 | KABC::Resource *resource; |
450 | while ( ( resource = resIt.current() ) != 0 ) { | 451 | while ( ( resource = resIt.current() ) != 0 ) { |
451 | ++resIt; | 452 | ++resIt; |
452 | if ( !resource->readOnly() ) { | 453 | if ( !resource->readOnly() ) { |
453 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 454 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
454 | if ( res ) | 455 | if ( res ) |
455 | kresResources.append( res ); | 456 | kresResources.append( res ); |
456 | } | 457 | } |
457 | } | 458 | } |
458 | 459 | ||
459 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 460 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
460 | return static_cast<KABC::Resource*>( res ); | 461 | return static_cast<KABC::Resource*>( res ); |
461 | } | 462 | } |
462 | 463 | ||
463 | #ifndef KAB_EMBEDDED | 464 | #ifndef KAB_EMBEDDED |
464 | KAboutData *KABCore::createAboutData() | 465 | KAboutData *KABCore::createAboutData() |
465 | #else //KAB_EMBEDDED | 466 | #else //KAB_EMBEDDED |
466 | void KABCore::createAboutData() | 467 | void KABCore::createAboutData() |
467 | #endif //KAB_EMBEDDED | 468 | #endif //KAB_EMBEDDED |
468 | { | 469 | { |
469 | #ifndef KAB_EMBEDDED | 470 | #ifndef KAB_EMBEDDED |
470 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), | 471 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), |
471 | "3.1", I18N_NOOP( "The KDE Address Book" ), | 472 | "3.1", I18N_NOOP( "The KDE Address Book" ), |
472 | KAboutData::License_GPL_V2, | 473 | KAboutData::License_GPL_V2, |
473 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); | 474 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); |
474 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); | 475 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); |
475 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); | 476 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); |
476 | about->addAuthor( "Cornelius Schumacher", | 477 | about->addAuthor( "Cornelius Schumacher", |
477 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | 478 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), |
478 | "schumacher@kde.org" ); | 479 | "schumacher@kde.org" ); |
479 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | 480 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), |
480 | "mpilone@slac.com" ); | 481 | "mpilone@slac.com" ); |
481 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | 482 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); |
482 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | 483 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); |
483 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | 484 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), |
484 | "michel@klaralvdalens-datakonsult.se" ); | 485 | "michel@klaralvdalens-datakonsult.se" ); |
485 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | 486 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), |
486 | "hansen@kde.org" ); | 487 | "hansen@kde.org" ); |
487 | 488 | ||
488 | return about; | 489 | return about; |
489 | #endif //KAB_EMBEDDED | 490 | #endif //KAB_EMBEDDED |
490 | 491 | ||
491 | QString version; | 492 | QString version; |
492 | #include <../version> | 493 | #include <../version> |
493 | QMessageBox::about( this, "About KAddressbook/Pi", | 494 | QMessageBox::about( this, "About KAddressbook/Pi", |
494 | "KAddressbook/Platform-independent\n" | 495 | "KAddressbook/Platform-independent\n" |
495 | "(KA/Pi) " +version + " - " + | 496 | "(KA/Pi) " +version + " - " + |
496 | #ifdef DESKTOP_VERSION | 497 | #ifdef DESKTOP_VERSION |
497 | "Desktop Edition\n" | 498 | "Desktop Edition\n" |
498 | #else | 499 | #else |
499 | "PDA-Edition\n" | 500 | "PDA-Edition\n" |
500 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 501 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
501 | #endif | 502 | #endif |
502 | 503 | ||
503 | "(c) 2004 Ulf Schenk\n" | 504 | "(c) 2004 Ulf Schenk\n" |
504 | "(c) 2004 Lutz Rogowski\n" | 505 | "(c) 2004 Lutz Rogowski\n" |
505 | "(c) 1997-2003, The KDE PIM Team\n" | 506 | "(c) 1997-2003, The KDE PIM Team\n" |
506 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" | 507 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" |
507 | "Don Sanders Original author\n" | 508 | "Don Sanders Original author\n" |
508 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" | 509 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" |
509 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" | 510 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" |
510 | "Greg Stern DCOP interface\n" | 511 | "Greg Stern DCOP interface\n" |
511 | "Mark Westcot Contact pinning\n" | 512 | "Mark Westcot Contact pinning\n" |
512 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" | 513 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" |
513 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" | 514 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" |
514 | #ifdef _WIN32_ | 515 | #ifdef _WIN32_ |
515 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" | 516 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" |
516 | #endif | 517 | #endif |
517 | ); | 518 | ); |
518 | } | 519 | } |
519 | 520 | ||
520 | void KABCore::setContactSelected( const QString &uid ) | 521 | void KABCore::setContactSelected( const QString &uid ) |
521 | { | 522 | { |
522 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 523 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
523 | if ( !mDetails->isHidden() ) | 524 | if ( !mDetails->isHidden() ) |
524 | mDetails->setAddressee( addr ); | 525 | mDetails->setAddressee( addr ); |
525 | 526 | ||
526 | if ( !addr.isEmpty() ) { | 527 | if ( !addr.isEmpty() ) { |
527 | emit contactSelected( addr.formattedName() ); | 528 | emit contactSelected( addr.formattedName() ); |
528 | KABC::Picture pic = addr.photo(); | 529 | KABC::Picture pic = addr.photo(); |
529 | if ( pic.isIntern() ) { | 530 | if ( pic.isIntern() ) { |
530 | //US emit contactSelected( pic.data() ); | 531 | //US emit contactSelected( pic.data() ); |
531 | //US instead use: | 532 | //US instead use: |
532 | QPixmap px; | 533 | QPixmap px; |
533 | if (pic.data().isNull() != true) | 534 | if (pic.data().isNull() != true) |
534 | { | 535 | { |
535 | px.convertFromImage(pic.data()); | 536 | px.convertFromImage(pic.data()); |
536 | } | 537 | } |
537 | 538 | ||
538 | emit contactSelected( px ); | 539 | emit contactSelected( px ); |
539 | } | 540 | } |
540 | } | 541 | } |
541 | 542 | ||
542 | 543 | ||
543 | mExtensionManager->setSelectionChanged(); | 544 | mExtensionManager->setSelectionChanged(); |
544 | 545 | ||
545 | // update the actions | 546 | // update the actions |
546 | bool selected = !uid.isEmpty(); | 547 | bool selected = !uid.isEmpty(); |
547 | 548 | ||
548 | if ( mReadWrite ) { | 549 | if ( mReadWrite ) { |
549 | mActionCut->setEnabled( selected ); | 550 | mActionCut->setEnabled( selected ); |
550 | mActionPaste->setEnabled( selected ); | 551 | mActionPaste->setEnabled( selected ); |
551 | } | 552 | } |
552 | 553 | ||
553 | mActionCopy->setEnabled( selected ); | 554 | mActionCopy->setEnabled( selected ); |
554 | mActionDelete->setEnabled( selected ); | 555 | mActionDelete->setEnabled( selected ); |
555 | mActionEditAddressee->setEnabled( selected ); | 556 | mActionEditAddressee->setEnabled( selected ); |
556 | mActionMail->setEnabled( selected ); | 557 | mActionMail->setEnabled( selected ); |
557 | mActionMailVCard->setEnabled( selected ); | 558 | mActionMailVCard->setEnabled( selected ); |
558 | //if (mActionBeam) | 559 | //if (mActionBeam) |
559 | //mActionBeam->setEnabled( selected ); | 560 | //mActionBeam->setEnabled( selected ); |
560 | 561 | ||
561 | if (mActionBeamVCard) | 562 | if (mActionBeamVCard) |
562 | mActionBeamVCard->setEnabled( selected ); | 563 | mActionBeamVCard->setEnabled( selected ); |
563 | 564 | ||
564 | mActionExport2phone->setEnabled( selected ); | 565 | mActionExport2phone->setEnabled( selected ); |
565 | mActionWhoAmI->setEnabled( selected ); | 566 | mActionWhoAmI->setEnabled( selected ); |
566 | mActionCategories->setEnabled( selected ); | 567 | mActionCategories->setEnabled( selected ); |
567 | } | 568 | } |
568 | 569 | ||
569 | void KABCore::sendMail() | 570 | void KABCore::sendMail() |
570 | { | 571 | { |
571 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 572 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
572 | } | 573 | } |
573 | 574 | ||
574 | void KABCore::sendMail( const QString& emaillist ) | 575 | void KABCore::sendMail( const QString& emaillist ) |
575 | { | 576 | { |
576 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " | 577 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " |
577 | if (emaillist.contains(",") > 0) | 578 | if (emaillist.contains(",") > 0) |
578 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); | 579 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); |
579 | else | 580 | else |
580 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); | 581 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); |
581 | } | 582 | } |
582 | 583 | ||
583 | 584 | ||
584 | 585 | ||
585 | void KABCore::mailVCard() | 586 | void KABCore::mailVCard() |
586 | { | 587 | { |
587 | QStringList uids = mViewManager->selectedUids(); | 588 | QStringList uids = mViewManager->selectedUids(); |
588 | if ( !uids.isEmpty() ) | 589 | if ( !uids.isEmpty() ) |
589 | mailVCard( uids ); | 590 | mailVCard( uids ); |
590 | } | 591 | } |
591 | 592 | ||
592 | void KABCore::mailVCard( const QStringList& uids ) | 593 | void KABCore::mailVCard( const QStringList& uids ) |
593 | { | 594 | { |
594 | QStringList urls; | 595 | QStringList urls; |
595 | 596 | ||
596 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 597 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
597 | 598 | ||
598 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); | 599 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); |
599 | 600 | ||
600 | 601 | ||
601 | 602 | ||
602 | QDir().mkdir( dirName, true ); | 603 | QDir().mkdir( dirName, true ); |
603 | 604 | ||
604 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 605 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
605 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 606 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
606 | 607 | ||
607 | if ( a.isEmpty() ) | 608 | if ( a.isEmpty() ) |
608 | continue; | 609 | continue; |
609 | 610 | ||
610 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 611 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
611 | 612 | ||
612 | QString fileName = dirName + "/" + name; | 613 | QString fileName = dirName + "/" + name; |
613 | 614 | ||
614 | QFile outFile(fileName); | 615 | QFile outFile(fileName); |
615 | 616 | ||
616 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 617 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
617 | KABC::VCardConverter converter; | 618 | KABC::VCardConverter converter; |
618 | QString vcard; | 619 | QString vcard; |
619 | 620 | ||
620 | converter.addresseeToVCard( a, vcard ); | 621 | converter.addresseeToVCard( a, vcard ); |
621 | 622 | ||
622 | QTextStream t( &outFile ); // use a text stream | 623 | QTextStream t( &outFile ); // use a text stream |
623 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 624 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
624 | t << vcard; | 625 | t << vcard; |
625 | 626 | ||
626 | outFile.close(); | 627 | outFile.close(); |
627 | 628 | ||
628 | urls.append( fileName ); | 629 | urls.append( fileName ); |
629 | } | 630 | } |
630 | } | 631 | } |
631 | 632 | ||
632 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); | 633 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
633 | 634 | ||
634 | 635 | ||
635 | /*US | 636 | /*US |
636 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 637 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
637 | QString::null, // subject | 638 | QString::null, // subject |
638 | QString::null, // body | 639 | QString::null, // body |
639 | QString::null, | 640 | QString::null, |
640 | urls ); // attachments | 641 | urls ); // attachments |
641 | */ | 642 | */ |
642 | 643 | ||
643 | } | 644 | } |
644 | 645 | ||
645 | /** | 646 | /** |
646 | Beams the "WhoAmI contact. | 647 | Beams the "WhoAmI contact. |
647 | */ | 648 | */ |
648 | void KABCore::beamMySelf() | 649 | void KABCore::beamMySelf() |
649 | { | 650 | { |
650 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 651 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
651 | if (!a.isEmpty()) | 652 | if (!a.isEmpty()) |
652 | { | 653 | { |
653 | QStringList uids; | 654 | QStringList uids; |
654 | uids << a.uid(); | 655 | uids << a.uid(); |
655 | 656 | ||
656 | beamVCard(uids); | 657 | beamVCard(uids); |
657 | } else { | 658 | } else { |
658 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 659 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
659 | 660 | ||
660 | 661 | ||
661 | } | 662 | } |
662 | } | 663 | } |
663 | 664 | ||
664 | void KABCore::export2phone() | 665 | void KABCore::export2phone() |
665 | { | 666 | { |
666 | 667 | ||
667 | KAex2phonePrefs ex2phone; | 668 | KAex2phonePrefs ex2phone; |
668 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 669 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
669 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 670 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
670 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 671 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
671 | 672 | ||
672 | if ( !ex2phone.exec() ) { | 673 | if ( !ex2phone.exec() ) { |
673 | return; | 674 | return; |
674 | } | 675 | } |
675 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 676 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
676 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 677 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
677 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 678 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
678 | 679 | ||
679 | 680 | ||
680 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 681 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
681 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 682 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
682 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 683 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
683 | 684 | ||
684 | QStringList uids = mViewManager->selectedUids(); | 685 | QStringList uids = mViewManager->selectedUids(); |
685 | if ( uids.isEmpty() ) | 686 | if ( uids.isEmpty() ) |
686 | return; | 687 | return; |
687 | 688 | ||
688 | #ifdef _WIN32_ | 689 | #ifdef _WIN32_ |
689 | QString fileName = locateLocal("tmp", "tempfile.vcf"); | 690 | QString fileName = locateLocal("tmp", "tempfile.vcf"); |
690 | #else | 691 | #else |
691 | QString fileName = "/tmp/kdepimtemp.vcf"; | 692 | QString fileName = "/tmp/kdepimtemp.vcf"; |
692 | #endif | 693 | #endif |
693 | 694 | ||
694 | KABC::VCardConverter converter; | 695 | KABC::VCardConverter converter; |
695 | QString description; | 696 | QString description; |
696 | QString datastream; | 697 | QString datastream; |
697 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 698 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
698 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 699 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
699 | 700 | ||
700 | if ( a.isEmpty() ) | 701 | if ( a.isEmpty() ) |
701 | continue; | 702 | continue; |
702 | a.simplifyEmails(); | 703 | a.simplifyEmails(); |
703 | a.simplifyPhoneNumbers(); | 704 | a.simplifyPhoneNumbers(); |
704 | a.simplifyPhoneNumberTypes(); | 705 | a.simplifyPhoneNumberTypes(); |
706 | a.simplifyAddresses(); | ||
705 | 707 | ||
706 | if (description.isEmpty()) | 708 | if (description.isEmpty()) |
707 | description = a.formattedName(); | 709 | description = a.formattedName(); |
708 | QString vcard; | 710 | QString vcard; |
709 | QString vcardnew; | 711 | QString vcardnew; |
710 | converter.addresseeToVCard( a, vcard ); | 712 | converter.addresseeToVCard( a, vcard ); |
711 | int start = 0; | 713 | int start = 0; |
712 | int next; | 714 | int next; |
713 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 715 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
714 | int semi = vcard.find(";", next); | 716 | int semi = vcard.find(";", next); |
715 | int dopp = vcard.find(":", next); | 717 | int dopp = vcard.find(":", next); |
716 | int sep; | 718 | int sep; |
717 | if ( semi < dopp && semi >= 0 ) | 719 | if ( semi < dopp && semi >= 0 ) |
718 | sep = semi ; | 720 | sep = semi ; |
719 | else | 721 | else |
720 | sep = dopp; | 722 | sep = dopp; |
721 | vcardnew +=vcard.mid( start, next - start); | 723 | vcardnew +=vcard.mid( start, next - start); |
722 | vcardnew +=vcard.mid( next+5,sep -next -5 ).upper(); | 724 | vcardnew +=vcard.mid( next+5,sep -next -5 ).upper(); |
723 | start = sep; | 725 | start = sep; |
724 | } | 726 | } |
725 | vcardnew += vcard.mid( start,vcard.length() ); | 727 | vcardnew += vcard.mid( start,vcard.length() ); |
726 | vcard = ""; | 728 | vcard = ""; |
727 | start = 0; | 729 | start = 0; |
728 | while ( (next = vcardnew.find("ADR", start) )>= 0 ) { | 730 | while ( (next = vcardnew.find("ADR", start) )>= 0 ) { |
729 | int sep = vcardnew.find(":", next); | 731 | int sep = vcardnew.find(":", next); |
730 | vcard +=vcardnew.mid( start, next - start+3); | 732 | vcard +=vcardnew.mid( start, next - start+3); |
731 | start = sep; | 733 | start = sep; |
732 | } | 734 | } |
733 | vcard += vcardnew.mid( start,vcardnew.length() ); | 735 | vcard += vcardnew.mid( start,vcardnew.length() ); |
734 | vcard.replace ( QRegExp(";;;") , "" ); | 736 | vcard.replace ( QRegExp(";;;") , "" ); |
735 | vcard.replace ( QRegExp(";;") , "" ); | 737 | vcard.replace ( QRegExp(";;") , "" ); |
736 | datastream += vcard; | 738 | datastream += vcard; |
737 | 739 | ||
738 | } | 740 | } |
739 | QFile outFile(fileName); | 741 | QFile outFile(fileName); |
740 | if ( outFile.open(IO_WriteOnly) ) { | 742 | if ( outFile.open(IO_WriteOnly) ) { |
741 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 743 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
742 | QTextStream t( &outFile ); // use a text stream | 744 | QTextStream t( &outFile ); // use a text stream |
743 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 745 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
744 | t <<datastream; | 746 | t <<datastream; |
745 | outFile.close(); | 747 | outFile.close(); |
746 | if ( PhoneAccess::writeToPhone( fileName ) ) | 748 | if ( PhoneAccess::writeToPhone( fileName ) ) |
747 | qDebug("Export okay "); | 749 | qDebug("Export okay "); |
748 | else | 750 | else |
749 | qDebug("Error export contacts "); | 751 | qDebug("Error export contacts "); |
750 | 752 | ||
751 | } else { | 753 | } else { |
752 | qDebug("Error open temp file "); | 754 | qDebug("Error open temp file "); |
753 | return; | 755 | return; |
754 | } | 756 | } |
755 | 757 | ||
756 | 758 | ||
757 | #if 0 | 759 | #if 0 |
758 | 760 | ||
759 | setCaption( i18n("Writing to phone...")); | 761 | setCaption( i18n("Writing to phone...")); |
760 | if ( PhoneFormat::writeToPhone( cal ) ) | 762 | if ( PhoneFormat::writeToPhone( cal ) ) |
761 | setCaption( i18n("Export to phone successful!")); | 763 | setCaption( i18n("Export to phone successful!")); |
762 | else | 764 | else |
763 | setCaption( i18n("Error exporting to phone!")); | 765 | setCaption( i18n("Error exporting to phone!")); |
764 | #endif | 766 | #endif |
765 | 767 | ||
766 | 768 | ||
767 | } | 769 | } |
768 | void KABCore::beamVCard() | 770 | void KABCore::beamVCard() |
769 | { | 771 | { |
770 | QStringList uids = mViewManager->selectedUids(); | 772 | QStringList uids = mViewManager->selectedUids(); |
771 | if ( !uids.isEmpty() ) | 773 | if ( !uids.isEmpty() ) |
772 | beamVCard( uids ); | 774 | beamVCard( uids ); |
773 | } | 775 | } |
774 | 776 | ||
775 | 777 | ||
776 | void KABCore::beamVCard(const QStringList& uids) | 778 | void KABCore::beamVCard(const QStringList& uids) |
777 | { | 779 | { |
778 | /*US | 780 | /*US |
779 | QString beamFilename; | 781 | QString beamFilename; |
780 | Opie::OPimContact c; | 782 | Opie::OPimContact c; |
781 | if ( actionPersonal->isOn() ) { | 783 | if ( actionPersonal->isOn() ) { |
782 | beamFilename = addressbookPersonalVCardName(); | 784 | beamFilename = addressbookPersonalVCardName(); |
783 | if ( !QFile::exists( beamFilename ) ) | 785 | if ( !QFile::exists( beamFilename ) ) |
784 | return; // can't beam a non-existent file | 786 | return; // can't beam a non-existent file |
785 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 787 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
786 | beamFilename ); | 788 | beamFilename ); |
787 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 789 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
788 | Opie::OPimContactAccess::List allList = access->allRecords(); | 790 | Opie::OPimContactAccess::List allList = access->allRecords(); |
789 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first | 791 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first |
790 | c = *it; | 792 | c = *it; |
791 | 793 | ||
792 | delete access; | 794 | delete access; |
793 | } else { | 795 | } else { |
794 | unlink( beamfile ); // delete if exists | 796 | unlink( beamfile ); // delete if exists |
795 | mkdir("/tmp/obex/", 0755); | 797 | mkdir("/tmp/obex/", 0755); |
796 | c = m_abView -> currentEntry(); | 798 | c = m_abView -> currentEntry(); |
797 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 799 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
798 | beamfile ); | 800 | beamfile ); |
799 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 801 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
800 | access->add( c ); | 802 | access->add( c ); |
801 | access->save(); | 803 | access->save(); |
802 | delete access; | 804 | delete access; |
803 | 805 | ||
804 | beamFilename = beamfile; | 806 | beamFilename = beamfile; |
805 | } | 807 | } |
806 | 808 | ||
807 | owarn << "Beaming: " << beamFilename << oendl; | 809 | owarn << "Beaming: " << beamFilename << oendl; |
808 | */ | 810 | */ |
809 | 811 | ||
810 | #if 0 | 812 | #if 0 |
811 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 813 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
812 | 814 | ||
813 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); | 815 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); |
814 | 816 | ||
815 | QString name = "contact.vcf"; | 817 | QString name = "contact.vcf"; |
816 | 818 | ||
817 | QString fileName = dirName + "/" + name; | 819 | QString fileName = dirName + "/" + name; |
818 | #endif | 820 | #endif |
819 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory | 821 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory |
820 | // | 822 | // |
821 | QString fileName = "/tmp/kapibeamfile.vcf"; | 823 | QString fileName = "/tmp/kapibeamfile.vcf"; |
822 | 824 | ||
823 | 825 | ||
824 | //QDir().mkdir( dirName, true ); | 826 | //QDir().mkdir( dirName, true ); |
825 | 827 | ||
826 | 828 | ||
827 | KABC::VCardConverter converter; | 829 | KABC::VCardConverter converter; |
828 | QString description; | 830 | QString description; |
829 | QString datastream; | 831 | QString datastream; |
830 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 832 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
831 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 833 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
832 | 834 | ||
833 | if ( a.isEmpty() ) | 835 | if ( a.isEmpty() ) |
834 | continue; | 836 | continue; |
835 | 837 | ||
836 | if (description.isEmpty()) | 838 | if (description.isEmpty()) |
837 | description = a.formattedName(); | 839 | description = a.formattedName(); |
838 | 840 | ||
839 | QString vcard; | 841 | QString vcard; |
840 | converter.addresseeToVCard( a, vcard ); | 842 | converter.addresseeToVCard( a, vcard ); |
841 | int start = 0; | 843 | int start = 0; |
842 | int next; | 844 | int next; |
843 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 845 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
844 | int semi = vcard.find(";", next); | 846 | int semi = vcard.find(";", next); |
845 | int dopp = vcard.find(":", next); | 847 | int dopp = vcard.find(":", next); |
846 | int sep; | 848 | int sep; |
847 | if ( semi < dopp && semi >= 0 ) | 849 | if ( semi < dopp && semi >= 0 ) |
848 | sep = semi ; | 850 | sep = semi ; |
849 | else | 851 | else |
850 | sep = dopp; | 852 | sep = dopp; |
851 | datastream +=vcard.mid( start, next - start); | 853 | datastream +=vcard.mid( start, next - start); |
852 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | 854 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); |
853 | start = sep; | 855 | start = sep; |
854 | } | 856 | } |
855 | datastream += vcard.mid( start,vcard.length() ); | 857 | datastream += vcard.mid( start,vcard.length() ); |
856 | } | 858 | } |
857 | #ifndef DESKTOP_VERSION | 859 | #ifndef DESKTOP_VERSION |
858 | QFile outFile(fileName); | 860 | QFile outFile(fileName); |
859 | if ( outFile.open(IO_WriteOnly) ) { | 861 | if ( outFile.open(IO_WriteOnly) ) { |
860 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 862 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
861 | QTextStream t( &outFile ); // use a text stream | 863 | QTextStream t( &outFile ); // use a text stream |
862 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 864 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
863 | t <<datastream; | 865 | t <<datastream; |
864 | outFile.close(); | 866 | outFile.close(); |
865 | Ir *ir = new Ir( this ); | 867 | Ir *ir = new Ir( this ); |
866 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 868 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
867 | ir->send( fileName, description, "text/x-vCard" ); | 869 | ir->send( fileName, description, "text/x-vCard" ); |
868 | } else { | 870 | } else { |
869 | qDebug("Error open temp beam file "); | 871 | qDebug("Error open temp beam file "); |
870 | return; | 872 | return; |
871 | } | 873 | } |
872 | #endif | 874 | #endif |
873 | 875 | ||
874 | } | 876 | } |
875 | 877 | ||
876 | void KABCore::beamDone( Ir *ir ) | 878 | void KABCore::beamDone( Ir *ir ) |
877 | { | 879 | { |
878 | #ifndef DESKTOP_VERSION | 880 | #ifndef DESKTOP_VERSION |
879 | delete ir; | 881 | delete ir; |
880 | #endif | 882 | #endif |
881 | } | 883 | } |
882 | 884 | ||
883 | 885 | ||
884 | void KABCore::browse( const QString& url ) | 886 | void KABCore::browse( const QString& url ) |
885 | { | 887 | { |
886 | #ifndef KAB_EMBEDDED | 888 | #ifndef KAB_EMBEDDED |
887 | kapp->invokeBrowser( url ); | 889 | kapp->invokeBrowser( url ); |
888 | #else //KAB_EMBEDDED | 890 | #else //KAB_EMBEDDED |
889 | qDebug("KABCore::browse must be fixed"); | 891 | qDebug("KABCore::browse must be fixed"); |
890 | #endif //KAB_EMBEDDED | 892 | #endif //KAB_EMBEDDED |
891 | } | 893 | } |
892 | 894 | ||
893 | void KABCore::selectAllContacts() | 895 | void KABCore::selectAllContacts() |
894 | { | 896 | { |
895 | mViewManager->setSelected( QString::null, true ); | 897 | mViewManager->setSelected( QString::null, true ); |
896 | } | 898 | } |
897 | 899 | ||
898 | void KABCore::deleteContacts() | 900 | void KABCore::deleteContacts() |
899 | { | 901 | { |
900 | QStringList uidList = mViewManager->selectedUids(); | 902 | QStringList uidList = mViewManager->selectedUids(); |
901 | deleteContacts( uidList ); | 903 | deleteContacts( uidList ); |
902 | } | 904 | } |
903 | 905 | ||
904 | void KABCore::deleteContacts( const QStringList &uids ) | 906 | void KABCore::deleteContacts( const QStringList &uids ) |
905 | { | 907 | { |
906 | if ( uids.count() > 0 ) { | 908 | if ( uids.count() > 0 ) { |
907 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 909 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
908 | UndoStack::instance()->push( command ); | 910 | UndoStack::instance()->push( command ); |
909 | RedoStack::instance()->clear(); | 911 | RedoStack::instance()->clear(); |
910 | 912 | ||
911 | // now if we deleted anything, refresh | 913 | // now if we deleted anything, refresh |
912 | setContactSelected( QString::null ); | 914 | setContactSelected( QString::null ); |
913 | setModified( true ); | 915 | setModified( true ); |
914 | } | 916 | } |
915 | } | 917 | } |
916 | 918 | ||
917 | void KABCore::copyContacts() | 919 | void KABCore::copyContacts() |
918 | { | 920 | { |
919 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 921 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
920 | 922 | ||
921 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 923 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
922 | 924 | ||
923 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 925 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
924 | 926 | ||
925 | QClipboard *cb = QApplication::clipboard(); | 927 | QClipboard *cb = QApplication::clipboard(); |
926 | cb->setText( clipText ); | 928 | cb->setText( clipText ); |
927 | } | 929 | } |
928 | 930 | ||
929 | void KABCore::cutContacts() | 931 | void KABCore::cutContacts() |
930 | { | 932 | { |
931 | QStringList uidList = mViewManager->selectedUids(); | 933 | QStringList uidList = mViewManager->selectedUids(); |
932 | 934 | ||
933 | //US if ( uidList.size() > 0 ) { | 935 | //US if ( uidList.size() > 0 ) { |
934 | if ( uidList.count() > 0 ) { | 936 | if ( uidList.count() > 0 ) { |
935 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 937 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
936 | UndoStack::instance()->push( command ); | 938 | UndoStack::instance()->push( command ); |
937 | RedoStack::instance()->clear(); | 939 | RedoStack::instance()->clear(); |
938 | 940 | ||
939 | setModified( true ); | 941 | setModified( true ); |
940 | } | 942 | } |
941 | } | 943 | } |
942 | 944 | ||
943 | void KABCore::pasteContacts() | 945 | void KABCore::pasteContacts() |
944 | { | 946 | { |
945 | QClipboard *cb = QApplication::clipboard(); | 947 | QClipboard *cb = QApplication::clipboard(); |
946 | 948 | ||
947 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 949 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
948 | 950 | ||
949 | pasteContacts( list ); | 951 | pasteContacts( list ); |
950 | } | 952 | } |
951 | 953 | ||
952 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 954 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
953 | { | 955 | { |
954 | KABC::Resource *resource = requestResource( this ); | 956 | KABC::Resource *resource = requestResource( this ); |
955 | KABC::Addressee::List::Iterator it; | 957 | KABC::Addressee::List::Iterator it; |
956 | for ( it = list.begin(); it != list.end(); ++it ) | 958 | for ( it = list.begin(); it != list.end(); ++it ) |
957 | (*it).setResource( resource ); | 959 | (*it).setResource( resource ); |
958 | 960 | ||
959 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 961 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
960 | UndoStack::instance()->push( command ); | 962 | UndoStack::instance()->push( command ); |
961 | RedoStack::instance()->clear(); | 963 | RedoStack::instance()->clear(); |
962 | 964 | ||
963 | setModified( true ); | 965 | setModified( true ); |
964 | } | 966 | } |
965 | 967 | ||
966 | void KABCore::setWhoAmI() | 968 | void KABCore::setWhoAmI() |
967 | { | 969 | { |
968 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 970 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
969 | 971 | ||
970 | if ( addrList.count() > 1 ) { | 972 | if ( addrList.count() > 1 ) { |
971 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 973 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
972 | return; | 974 | return; |
973 | } | 975 | } |
974 | 976 | ||
975 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 977 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
976 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | 978 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) |
977 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 979 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
978 | } | 980 | } |
979 | 981 | ||
980 | void KABCore::setCategories() | 982 | void KABCore::setCategories() |
981 | { | 983 | { |
982 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 984 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
983 | if ( !dlg.exec() ) | 985 | if ( !dlg.exec() ) |
984 | return; | 986 | return; |
985 | 987 | ||
986 | bool merge = false; | 988 | bool merge = false; |
987 | QString msg = i18n( "Merge with existing categories?" ); | 989 | QString msg = i18n( "Merge with existing categories?" ); |
988 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 990 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
989 | merge = true; | 991 | merge = true; |
990 | 992 | ||
991 | QStringList categories = dlg.selectedCategories(); | 993 | QStringList categories = dlg.selectedCategories(); |
992 | 994 | ||
993 | QStringList uids = mViewManager->selectedUids(); | 995 | QStringList uids = mViewManager->selectedUids(); |
994 | QStringList::Iterator it; | 996 | QStringList::Iterator it; |
995 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 997 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
996 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 998 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
997 | if ( !addr.isEmpty() ) { | 999 | if ( !addr.isEmpty() ) { |
998 | if ( !merge ) | 1000 | if ( !merge ) |
999 | addr.setCategories( categories ); | 1001 | addr.setCategories( categories ); |
1000 | else { | 1002 | else { |
1001 | QStringList addrCategories = addr.categories(); | 1003 | QStringList addrCategories = addr.categories(); |
1002 | QStringList::Iterator catIt; | 1004 | QStringList::Iterator catIt; |
1003 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 1005 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
1004 | if ( !addrCategories.contains( *catIt ) ) | 1006 | if ( !addrCategories.contains( *catIt ) ) |
1005 | addrCategories.append( *catIt ); | 1007 | addrCategories.append( *catIt ); |
1006 | } | 1008 | } |
1007 | addr.setCategories( addrCategories ); | 1009 | addr.setCategories( addrCategories ); |
1008 | } | 1010 | } |
1009 | 1011 | ||
1010 | mAddressBook->insertAddressee( addr ); | 1012 | mAddressBook->insertAddressee( addr ); |
1011 | } | 1013 | } |
1012 | } | 1014 | } |
1013 | 1015 | ||
1014 | if ( uids.count() > 0 ) | 1016 | if ( uids.count() > 0 ) |
1015 | setModified( true ); | 1017 | setModified( true ); |
1016 | } | 1018 | } |
1017 | 1019 | ||
1018 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 1020 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
1019 | { | 1021 | { |
1020 | mIncSearchWidget->setFields( fields ); | 1022 | mIncSearchWidget->setFields( fields ); |
1021 | } | 1023 | } |
1022 | 1024 | ||
1023 | void KABCore::incrementalSearch( const QString& text ) | 1025 | void KABCore::incrementalSearch( const QString& text ) |
1024 | { | 1026 | { |
1025 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); | 1027 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); |
1026 | } | 1028 | } |
1027 | 1029 | ||
1028 | void KABCore::setModified() | 1030 | void KABCore::setModified() |
1029 | { | 1031 | { |
1030 | setModified( true ); | 1032 | setModified( true ); |
1031 | } | 1033 | } |
1032 | 1034 | ||
1033 | void KABCore::setModifiedWOrefresh() | 1035 | void KABCore::setModifiedWOrefresh() |
1034 | { | 1036 | { |
1035 | // qDebug("KABCore::setModifiedWOrefresh() "); | 1037 | // qDebug("KABCore::setModifiedWOrefresh() "); |
1036 | mModified = true; | 1038 | mModified = true; |
1037 | mActionSave->setEnabled( mModified ); | 1039 | mActionSave->setEnabled( mModified ); |
1038 | #ifdef DESKTOP_VERSION | 1040 | #ifdef DESKTOP_VERSION |
1039 | mDetails->refreshView(); | 1041 | mDetails->refreshView(); |
1040 | #endif | 1042 | #endif |
1041 | 1043 | ||
1042 | } | 1044 | } |
1043 | void KABCore::setModified( bool modified ) | 1045 | void KABCore::setModified( bool modified ) |
1044 | { | 1046 | { |
1045 | mModified = modified; | 1047 | mModified = modified; |
1046 | mActionSave->setEnabled( mModified ); | 1048 | mActionSave->setEnabled( mModified ); |
1047 | 1049 | ||
1048 | if ( modified ) | 1050 | if ( modified ) |
1049 | mJumpButtonBar->recreateButtons(); | 1051 | mJumpButtonBar->recreateButtons(); |
1050 | 1052 | ||
1051 | mViewManager->refreshView(); | 1053 | mViewManager->refreshView(); |
1052 | mDetails->refreshView(); | 1054 | mDetails->refreshView(); |
1053 | 1055 | ||
1054 | } | 1056 | } |
1055 | 1057 | ||
1056 | bool KABCore::modified() const | 1058 | bool KABCore::modified() const |
1057 | { | 1059 | { |
1058 | return mModified; | 1060 | return mModified; |
1059 | } | 1061 | } |
1060 | 1062 | ||
1061 | void KABCore::contactModified( const KABC::Addressee &addr ) | 1063 | void KABCore::contactModified( const KABC::Addressee &addr ) |
1062 | { | 1064 | { |
1063 | 1065 | ||
1064 | Command *command = 0; | 1066 | Command *command = 0; |
1065 | QString uid; | 1067 | QString uid; |
1066 | 1068 | ||
1067 | // check if it exists already | 1069 | // check if it exists already |
1068 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 1070 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
1069 | if ( origAddr.isEmpty() ) | 1071 | if ( origAddr.isEmpty() ) |
1070 | command = new PwNewCommand( mAddressBook, addr ); | 1072 | command = new PwNewCommand( mAddressBook, addr ); |
1071 | else { | 1073 | else { |
1072 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 1074 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
1073 | uid = addr.uid(); | 1075 | uid = addr.uid(); |
1074 | } | 1076 | } |
1075 | 1077 | ||
1076 | UndoStack::instance()->push( command ); | 1078 | UndoStack::instance()->push( command ); |
1077 | RedoStack::instance()->clear(); | 1079 | RedoStack::instance()->clear(); |
1078 | 1080 | ||
1079 | setModified( true ); | 1081 | setModified( true ); |
1080 | } | 1082 | } |
1081 | 1083 | ||
1082 | void KABCore::newContact() | 1084 | void KABCore::newContact() |
1083 | { | 1085 | { |
1084 | 1086 | ||
1085 | 1087 | ||
1086 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 1088 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
1087 | 1089 | ||
1088 | QPtrList<KRES::Resource> kresResources; | 1090 | QPtrList<KRES::Resource> kresResources; |
1089 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 1091 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
1090 | KABC::Resource *resource; | 1092 | KABC::Resource *resource; |
1091 | while ( ( resource = it.current() ) != 0 ) { | 1093 | while ( ( resource = it.current() ) != 0 ) { |
1092 | ++it; | 1094 | ++it; |
1093 | if ( !resource->readOnly() ) { | 1095 | if ( !resource->readOnly() ) { |
1094 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 1096 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
1095 | if ( res ) | 1097 | if ( res ) |
1096 | kresResources.append( res ); | 1098 | kresResources.append( res ); |
1097 | } | 1099 | } |
1098 | } | 1100 | } |
1099 | 1101 | ||
1100 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 1102 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
1101 | resource = static_cast<KABC::Resource*>( res ); | 1103 | resource = static_cast<KABC::Resource*>( res ); |
1102 | 1104 | ||
1103 | if ( resource ) { | 1105 | if ( resource ) { |
1104 | KABC::Addressee addr; | 1106 | KABC::Addressee addr; |
1105 | addr.setResource( resource ); | 1107 | addr.setResource( resource ); |
1106 | mEditorDialog->setAddressee( addr ); | 1108 | mEditorDialog->setAddressee( addr ); |
1107 | KApplication::execDialog ( mEditorDialog ); | 1109 | KApplication::execDialog ( mEditorDialog ); |
1108 | 1110 | ||
1109 | } else | 1111 | } else |
1110 | return; | 1112 | return; |
1111 | 1113 | ||
1112 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 1114 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
1113 | 1115 | ||
1114 | 1116 | ||
1115 | } | 1117 | } |
1116 | 1118 | ||
1117 | void KABCore::addEmail( QString aStr ) | 1119 | void KABCore::addEmail( QString aStr ) |
1118 | { | 1120 | { |
1119 | #ifndef KAB_EMBEDDED | 1121 | #ifndef KAB_EMBEDDED |
1120 | QString fullName, email; | 1122 | QString fullName, email; |
1121 | 1123 | ||
1122 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 1124 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
1123 | 1125 | ||
1124 | // Try to lookup the addressee matching the email address | 1126 | // Try to lookup the addressee matching the email address |
1125 | bool found = false; | 1127 | bool found = false; |
1126 | QStringList emailList; | 1128 | QStringList emailList; |
1127 | KABC::AddressBook::Iterator it; | 1129 | KABC::AddressBook::Iterator it; |
1128 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 1130 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
1129 | emailList = (*it).emails(); | 1131 | emailList = (*it).emails(); |
1130 | if ( emailList.contains( email ) > 0 ) { | 1132 | if ( emailList.contains( email ) > 0 ) { |
1131 | found = true; | 1133 | found = true; |
1132 | (*it).setNameFromString( fullName ); | 1134 | (*it).setNameFromString( fullName ); |
1133 | editContact( (*it).uid() ); | 1135 | editContact( (*it).uid() ); |
1134 | } | 1136 | } |
1135 | } | 1137 | } |
1136 | 1138 | ||
1137 | if ( !found ) { | 1139 | if ( !found ) { |
1138 | KABC::Addressee addr; | 1140 | KABC::Addressee addr; |
1139 | addr.setNameFromString( fullName ); | 1141 | addr.setNameFromString( fullName ); |
1140 | addr.insertEmail( email, true ); | 1142 | addr.insertEmail( email, true ); |
1141 | 1143 | ||
1142 | mAddressBook->insertAddressee( addr ); | 1144 | mAddressBook->insertAddressee( addr ); |
1143 | mViewManager->refreshView( addr.uid() ); | 1145 | mViewManager->refreshView( addr.uid() ); |
1144 | editContact( addr.uid() ); | 1146 | editContact( addr.uid() ); |
1145 | } | 1147 | } |
1146 | #else //KAB_EMBEDDED | 1148 | #else //KAB_EMBEDDED |
1147 | qDebug("KABCore::addEmail finsih method"); | 1149 | qDebug("KABCore::addEmail finsih method"); |
1148 | #endif //KAB_EMBEDDED | 1150 | #endif //KAB_EMBEDDED |
1149 | } | 1151 | } |
1150 | 1152 | ||
1151 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 1153 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
1152 | { | 1154 | { |
1153 | mXXPortManager->importVCard( url, showPreview ); | 1155 | mXXPortManager->importVCard( url, showPreview ); |
1154 | } | 1156 | } |
1155 | void KABCore::importFromOL() | 1157 | void KABCore::importFromOL() |
1156 | { | 1158 | { |
1157 | #ifdef _WIN32_ | 1159 | #ifdef _WIN32_ |
1158 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | 1160 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); |
1159 | idgl->exec(); | 1161 | idgl->exec(); |
1160 | KABC::Addressee::List list = idgl->getAddressList(); | 1162 | KABC::Addressee::List list = idgl->getAddressList(); |
1161 | if ( list.count() > 0 ) { | 1163 | if ( list.count() > 0 ) { |
1162 | KABC::Addressee::List listNew; | 1164 | KABC::Addressee::List listNew; |
1163 | KABC::Addressee::List listExisting; | 1165 | KABC::Addressee::List listExisting; |
1164 | KABC::Addressee::List::Iterator it; | 1166 | KABC::Addressee::List::Iterator it; |
1165 | KABC::AddressBook::Iterator iter; | 1167 | KABC::AddressBook::Iterator iter; |
1166 | for ( it = list.begin(); it != list.end(); ++it ) { | 1168 | for ( it = list.begin(); it != list.end(); ++it ) { |
1167 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) | 1169 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) |
1168 | listNew.append( (*it) ); | 1170 | listNew.append( (*it) ); |
1169 | else | 1171 | else |
1170 | listExisting.append( (*it) ); | 1172 | listExisting.append( (*it) ); |
1171 | } | 1173 | } |
1172 | if ( listExisting.count() > 0 ) | 1174 | if ( listExisting.count() > 0 ) |
1173 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); | 1175 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); |
1174 | if ( listNew.count() > 0 ) { | 1176 | if ( listNew.count() > 0 ) { |
1175 | pasteWithNewUid = false; | 1177 | pasteWithNewUid = false; |
1176 | pasteContacts( listNew ); | 1178 | pasteContacts( listNew ); |
1177 | pasteWithNewUid = true; | 1179 | pasteWithNewUid = true; |
1178 | } | 1180 | } |
1179 | } | 1181 | } |
1180 | delete idgl; | 1182 | delete idgl; |
1181 | #endif | 1183 | #endif |
1182 | } | 1184 | } |
1183 | 1185 | ||
1184 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1186 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
1185 | { | 1187 | { |
1186 | mXXPortManager->importVCard( vCard, showPreview ); | 1188 | mXXPortManager->importVCard( vCard, showPreview ); |
1187 | } | 1189 | } |
1188 | 1190 | ||
1189 | //US added a second method without defaultparameter | 1191 | //US added a second method without defaultparameter |
1190 | void KABCore::editContact2() { | 1192 | void KABCore::editContact2() { |
1191 | editContact( QString::null ); | 1193 | editContact( QString::null ); |
1192 | } | 1194 | } |
1193 | 1195 | ||
1194 | void KABCore::editContact( const QString &uid ) | 1196 | void KABCore::editContact( const QString &uid ) |
1195 | { | 1197 | { |
1196 | 1198 | ||
1197 | if ( mExtensionManager->isQuickEditVisible() ) | 1199 | if ( mExtensionManager->isQuickEditVisible() ) |
1198 | return; | 1200 | return; |
1199 | 1201 | ||
1200 | // First, locate the contact entry | 1202 | // First, locate the contact entry |
1201 | QString localUID = uid; | 1203 | QString localUID = uid; |
1202 | if ( localUID.isNull() ) { | 1204 | if ( localUID.isNull() ) { |
1203 | QStringList uidList = mViewManager->selectedUids(); | 1205 | QStringList uidList = mViewManager->selectedUids(); |
1204 | if ( uidList.count() > 0 ) | 1206 | if ( uidList.count() > 0 ) |
1205 | localUID = *( uidList.at( 0 ) ); | 1207 | localUID = *( uidList.at( 0 ) ); |
1206 | } | 1208 | } |
1207 | 1209 | ||
1208 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 1210 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
1209 | if ( !addr.isEmpty() ) { | 1211 | if ( !addr.isEmpty() ) { |
1210 | mEditorDialog->setAddressee( addr ); | 1212 | mEditorDialog->setAddressee( addr ); |
1211 | KApplication::execDialog ( mEditorDialog ); | 1213 | KApplication::execDialog ( mEditorDialog ); |
1212 | } | 1214 | } |
1213 | } | 1215 | } |
1214 | 1216 | ||
1215 | /** | 1217 | /** |
1216 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 1218 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
1217 | the method will try to find a selected addressee in the view. | 1219 | the method will try to find a selected addressee in the view. |
1218 | */ | 1220 | */ |
1219 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1221 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) |
1220 | { | 1222 | { |
1221 | if ( mMultipleViewsAtOnce ) | 1223 | if ( mMultipleViewsAtOnce ) |
1222 | { | 1224 | { |
1223 | editContact( uid ); | 1225 | editContact( uid ); |
1224 | } | 1226 | } |
1225 | else | 1227 | else |
1226 | { | 1228 | { |
1227 | setDetailsVisible( true ); | 1229 | setDetailsVisible( true ); |
1228 | mActionDetails->setChecked(true); | 1230 | mActionDetails->setChecked(true); |
1229 | } | 1231 | } |
1230 | 1232 | ||
1231 | } | 1233 | } |
1232 | 1234 | ||
1233 | void KABCore::save() | 1235 | void KABCore::save() |
1234 | { | 1236 | { |
1235 | if (syncManager->blockSave()) | 1237 | if (syncManager->blockSave()) |
1236 | return; | 1238 | return; |
1237 | if ( !mModified ) | 1239 | if ( !mModified ) |
1238 | return; | 1240 | return; |
1239 | 1241 | ||
1240 | syncManager->setBlockSave(true); | 1242 | syncManager->setBlockSave(true); |
1241 | QString text = i18n( "There was an error while attempting to save\n the " | 1243 | QString text = i18n( "There was an error while attempting to save\n the " |
1242 | "address book. Please check that some \nother application is " | 1244 | "address book. Please check that some \nother application is " |
1243 | "not using it. " ); | 1245 | "not using it. " ); |
1244 | statusMessage(i18n("Saving addressbook ... ")); | 1246 | statusMessage(i18n("Saving addressbook ... ")); |
1245 | #ifndef KAB_EMBEDDED | 1247 | #ifndef KAB_EMBEDDED |
1246 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1248 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
1247 | if ( !b || !b->save() ) { | 1249 | if ( !b || !b->save() ) { |
1248 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 1250 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
1249 | } | 1251 | } |
1250 | #else //KAB_EMBEDDED | 1252 | #else //KAB_EMBEDDED |
1251 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 1253 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
1252 | if ( !b || !b->save() ) { | 1254 | if ( !b || !b->save() ) { |
1253 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 1255 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
1254 | } | 1256 | } |
1255 | #endif //KAB_EMBEDDED | 1257 | #endif //KAB_EMBEDDED |
1256 | 1258 | ||
1257 | statusMessage(i18n("Addressbook saved!")); | 1259 | statusMessage(i18n("Addressbook saved!")); |
1258 | setModified( false ); | 1260 | setModified( false ); |
1259 | syncManager->setBlockSave(false); | 1261 | syncManager->setBlockSave(false); |
1260 | } | 1262 | } |
1261 | 1263 | ||
1262 | void KABCore::statusMessage(QString mess , int time ) | 1264 | void KABCore::statusMessage(QString mess , int time ) |
1263 | { | 1265 | { |
1264 | //topLevelWidget()->setCaption( mess ); | 1266 | //topLevelWidget()->setCaption( mess ); |
1265 | // pending setting timer to revome message | 1267 | // pending setting timer to revome message |
1266 | } | 1268 | } |
1267 | void KABCore::undo() | 1269 | void KABCore::undo() |
1268 | { | 1270 | { |
1269 | UndoStack::instance()->undo(); | 1271 | UndoStack::instance()->undo(); |
1270 | 1272 | ||
1271 | // Refresh the view | 1273 | // Refresh the view |
1272 | mViewManager->refreshView(); | 1274 | mViewManager->refreshView(); |
1273 | } | 1275 | } |
1274 | 1276 | ||
1275 | void KABCore::redo() | 1277 | void KABCore::redo() |
1276 | { | 1278 | { |
1277 | RedoStack::instance()->redo(); | 1279 | RedoStack::instance()->redo(); |
1278 | 1280 | ||
1279 | // Refresh the view | 1281 | // Refresh the view |
1280 | mViewManager->refreshView(); | 1282 | mViewManager->refreshView(); |
1281 | } | 1283 | } |
1282 | 1284 | ||
1283 | void KABCore::setJumpButtonBarVisible( bool visible ) | 1285 | void KABCore::setJumpButtonBarVisible( bool visible ) |
1284 | { | 1286 | { |
1285 | if (mMultipleViewsAtOnce) | 1287 | if (mMultipleViewsAtOnce) |
1286 | { | 1288 | { |
1287 | if ( visible ) | 1289 | if ( visible ) |
1288 | mJumpButtonBar->show(); | 1290 | mJumpButtonBar->show(); |
1289 | else | 1291 | else |
1290 | mJumpButtonBar->hide(); | 1292 | mJumpButtonBar->hide(); |
1291 | } | 1293 | } |
1292 | else | 1294 | else |
1293 | { | 1295 | { |
1294 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" | 1296 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" |
1295 | if (mViewManager->isVisible()) | 1297 | if (mViewManager->isVisible()) |
1296 | { | 1298 | { |
1297 | if ( visible ) | 1299 | if ( visible ) |
1298 | mJumpButtonBar->show(); | 1300 | mJumpButtonBar->show(); |
1299 | else | 1301 | else |
1300 | mJumpButtonBar->hide(); | 1302 | mJumpButtonBar->hide(); |
1301 | } | 1303 | } |
1302 | else | 1304 | else |
1303 | { | 1305 | { |
1304 | mJumpButtonBar->hide(); | 1306 | mJumpButtonBar->hide(); |
1305 | } | 1307 | } |
1306 | } | 1308 | } |
1307 | } | 1309 | } |
1308 | 1310 | ||
1309 | 1311 | ||
1310 | void KABCore::setDetailsToState() | 1312 | void KABCore::setDetailsToState() |
1311 | { | 1313 | { |
1312 | setDetailsVisible( mActionDetails->isChecked() ); | 1314 | setDetailsVisible( mActionDetails->isChecked() ); |
1313 | } | 1315 | } |
1314 | 1316 | ||
1315 | 1317 | ||
1316 | 1318 | ||
1317 | void KABCore::setDetailsVisible( bool visible ) | 1319 | void KABCore::setDetailsVisible( bool visible ) |
1318 | { | 1320 | { |
1319 | if (visible && mDetails->isHidden()) | 1321 | if (visible && mDetails->isHidden()) |
1320 | { | 1322 | { |
1321 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1323 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1322 | if ( addrList.count() > 0 ) | 1324 | if ( addrList.count() > 0 ) |
1323 | mDetails->setAddressee( addrList[ 0 ] ); | 1325 | mDetails->setAddressee( addrList[ 0 ] ); |
1324 | } | 1326 | } |
1325 | 1327 | ||
1326 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between | 1328 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between |
1327 | // the listview and the detailview. We do that by changing the splitbar size. | 1329 | // the listview and the detailview. We do that by changing the splitbar size. |
1328 | if (mMultipleViewsAtOnce) | 1330 | if (mMultipleViewsAtOnce) |
1329 | { | 1331 | { |
1330 | if ( visible ) | 1332 | if ( visible ) |
1331 | mDetails->show(); | 1333 | mDetails->show(); |
1332 | else | 1334 | else |
1333 | mDetails->hide(); | 1335 | mDetails->hide(); |
1334 | } | 1336 | } |
1335 | else | 1337 | else |
1336 | { | 1338 | { |
1337 | if ( visible ) { | 1339 | if ( visible ) { |
1338 | mViewManager->hide(); | 1340 | mViewManager->hide(); |
1339 | mDetails->show(); | 1341 | mDetails->show(); |
1340 | } | 1342 | } |
1341 | else { | 1343 | else { |
1342 | mViewManager->show(); | 1344 | mViewManager->show(); |
1343 | mDetails->hide(); | 1345 | mDetails->hide(); |
1344 | } | 1346 | } |
1345 | setJumpButtonBarVisible( !visible ); | 1347 | setJumpButtonBarVisible( !visible ); |
1346 | } | 1348 | } |
1347 | 1349 | ||
1348 | } | 1350 | } |
1349 | 1351 | ||
1350 | void KABCore::extensionChanged( int id ) | 1352 | void KABCore::extensionChanged( int id ) |
1351 | { | 1353 | { |
1352 | //change the details view only for non desktop systems | 1354 | //change the details view only for non desktop systems |
1353 | #ifndef DESKTOP_VERSION | 1355 | #ifndef DESKTOP_VERSION |
1354 | 1356 | ||
1355 | if (id == 0) | 1357 | if (id == 0) |
1356 | { | 1358 | { |
1357 | //the user disabled the extension. | 1359 | //the user disabled the extension. |
1358 | 1360 | ||
1359 | if (mMultipleViewsAtOnce) | 1361 | if (mMultipleViewsAtOnce) |
1360 | { // enable detailsview again | 1362 | { // enable detailsview again |
1361 | setDetailsVisible( true ); | 1363 | setDetailsVisible( true ); |
1362 | mActionDetails->setChecked( true ); | 1364 | mActionDetails->setChecked( true ); |
1363 | } | 1365 | } |
1364 | else | 1366 | else |
1365 | { //go back to the listview | 1367 | { //go back to the listview |
1366 | setDetailsVisible( false ); | 1368 | setDetailsVisible( false ); |
1367 | mActionDetails->setChecked( false ); | 1369 | mActionDetails->setChecked( false ); |
1368 | mActionDetails->setEnabled(true); | 1370 | mActionDetails->setEnabled(true); |
1369 | } | 1371 | } |
1370 | 1372 | ||
1371 | } | 1373 | } |
1372 | else | 1374 | else |
1373 | { | 1375 | { |
1374 | //the user enabled the extension. | 1376 | //the user enabled the extension. |
1375 | setDetailsVisible( false ); | 1377 | setDetailsVisible( false ); |
1376 | mActionDetails->setChecked( false ); | 1378 | mActionDetails->setChecked( false ); |
1377 | 1379 | ||
1378 | if (!mMultipleViewsAtOnce) | 1380 | if (!mMultipleViewsAtOnce) |
1379 | { | 1381 | { |
1380 | mActionDetails->setEnabled(false); | 1382 | mActionDetails->setEnabled(false); |
1381 | } | 1383 | } |
1382 | 1384 | ||
1383 | mExtensionManager->setSelectionChanged(); | 1385 | mExtensionManager->setSelectionChanged(); |
1384 | 1386 | ||
1385 | } | 1387 | } |
1386 | 1388 | ||
1387 | #endif// DESKTOP_VERSION | 1389 | #endif// DESKTOP_VERSION |
1388 | 1390 | ||
1389 | } | 1391 | } |
1390 | 1392 | ||
1391 | 1393 | ||
1392 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1394 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1393 | { | 1395 | { |
1394 | 1396 | ||
1395 | if ( list.count() != 0 ) { | 1397 | if ( list.count() != 0 ) { |
1396 | KABC::Addressee::List::ConstIterator it; | 1398 | KABC::Addressee::List::ConstIterator it; |
1397 | for ( it = list.begin(); it != list.end(); ++it ) | 1399 | for ( it = list.begin(); it != list.end(); ++it ) |
1398 | mAddressBook->insertAddressee( *it ); | 1400 | mAddressBook->insertAddressee( *it ); |
1399 | if ( list.count() > 1 ) | 1401 | if ( list.count() > 1 ) |
1400 | setModified(); | 1402 | setModified(); |
1401 | else | 1403 | else |
1402 | setModifiedWOrefresh(); | 1404 | setModifiedWOrefresh(); |
1403 | } | 1405 | } |
1404 | if ( list.count() == 0 ) | 1406 | if ( list.count() == 0 ) |
1405 | mViewManager->refreshView(); | 1407 | mViewManager->refreshView(); |
1406 | else | 1408 | else |
1407 | mViewManager->refreshView( list[ 0 ].uid() ); | 1409 | mViewManager->refreshView( list[ 0 ].uid() ); |
1408 | 1410 | ||
1409 | 1411 | ||
1410 | 1412 | ||
1411 | } | 1413 | } |
1412 | 1414 | ||
1413 | QString KABCore::getNameByPhone( const QString &phone ) | 1415 | QString KABCore::getNameByPhone( const QString &phone ) |
1414 | { | 1416 | { |
1415 | #ifndef KAB_EMBEDDED | 1417 | #ifndef KAB_EMBEDDED |
1416 | QRegExp r( "[/*/-/ ]" ); | 1418 | QRegExp r( "[/*/-/ ]" ); |
1417 | QString localPhone( phone ); | 1419 | QString localPhone( phone ); |
1418 | 1420 | ||
1419 | bool found = false; | 1421 | bool found = false; |
1420 | QString ownerName = ""; | 1422 | QString ownerName = ""; |
1421 | KABC::AddressBook::Iterator iter; | 1423 | KABC::AddressBook::Iterator iter; |
1422 | KABC::PhoneNumber::List::Iterator phoneIter; | 1424 | KABC::PhoneNumber::List::Iterator phoneIter; |
1423 | KABC::PhoneNumber::List phoneList; | 1425 | KABC::PhoneNumber::List phoneList; |
1424 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1426 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
1425 | phoneList = (*iter).phoneNumbers(); | 1427 | phoneList = (*iter).phoneNumbers(); |
1426 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1428 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
1427 | ++phoneIter) { | 1429 | ++phoneIter) { |
1428 | // Get rid of separator chars so just the numbers are compared. | 1430 | // Get rid of separator chars so just the numbers are compared. |
1429 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1431 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
1430 | ownerName = (*iter).formattedName(); | 1432 | ownerName = (*iter).formattedName(); |
1431 | found = true; | 1433 | found = true; |
1432 | } | 1434 | } |
1433 | } | 1435 | } |
1434 | } | 1436 | } |
1435 | 1437 | ||
1436 | return ownerName; | 1438 | return ownerName; |
1437 | #else //KAB_EMBEDDED | 1439 | #else //KAB_EMBEDDED |
1438 | qDebug("KABCore::getNameByPhone finsih method"); | 1440 | qDebug("KABCore::getNameByPhone finsih method"); |
1439 | return ""; | 1441 | return ""; |
1440 | #endif //KAB_EMBEDDED | 1442 | #endif //KAB_EMBEDDED |
1441 | 1443 | ||
1442 | } | 1444 | } |
1443 | 1445 | ||
1444 | void KABCore::openConfigDialog() | 1446 | void KABCore::openConfigDialog() |
1445 | { | 1447 | { |
1446 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 1448 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
1447 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 1449 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
1448 | ConfigureDialog->addModule(kabcfg ); | 1450 | ConfigureDialog->addModule(kabcfg ); |
1449 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 1451 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
1450 | ConfigureDialog->addModule(kdelibcfg ); | 1452 | ConfigureDialog->addModule(kdelibcfg ); |
1451 | 1453 | ||
1452 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1454 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1453 | this, SLOT( configurationChanged() ) ); | 1455 | this, SLOT( configurationChanged() ) ); |
1454 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1456 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
1455 | this, SLOT( configurationChanged() ) ); | 1457 | this, SLOT( configurationChanged() ) ); |
1456 | saveSettings(); | 1458 | saveSettings(); |
1457 | #ifndef DESKTOP_VERSION | 1459 | #ifndef DESKTOP_VERSION |
1458 | ConfigureDialog->showMaximized(); | 1460 | ConfigureDialog->showMaximized(); |
1459 | #endif | 1461 | #endif |
1460 | if ( ConfigureDialog->exec() ) | 1462 | if ( ConfigureDialog->exec() ) |
1461 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 1463 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
1462 | delete ConfigureDialog; | 1464 | delete ConfigureDialog; |
1463 | } | 1465 | } |
1464 | 1466 | ||
1465 | void KABCore::openLDAPDialog() | 1467 | void KABCore::openLDAPDialog() |
1466 | { | 1468 | { |
1467 | #ifndef KAB_EMBEDDED | 1469 | #ifndef KAB_EMBEDDED |
1468 | if ( !mLdapSearchDialog ) { | 1470 | if ( !mLdapSearchDialog ) { |
1469 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1471 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1470 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1472 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1471 | SLOT( refreshView() ) ); | 1473 | SLOT( refreshView() ) ); |
1472 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1474 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
diff --git a/kaddressbook/kabprefs.cpp b/kaddressbook/kabprefs.cpp index 552c933..dded2bf 100644 --- a/kaddressbook/kabprefs.cpp +++ b/kaddressbook/kabprefs.cpp | |||
@@ -1,132 +1,133 @@ | |||
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 | //US#ifdef KAB_EMBEDDED | 24 | //US#ifdef KAB_EMBEDDED |
25 | //#include <qstring.h> | 25 | //#include <qstring.h> |
26 | //#endif //KAB_EMBEDDED | 26 | //#endif //KAB_EMBEDDED |
27 | 27 | ||
28 | 28 | ||
29 | #include <kconfig.h> | 29 | #include <kconfig.h> |
30 | #include <klocale.h> | 30 | #include <klocale.h> |
31 | #include <kstaticdeleter.h> | 31 | #include <kstaticdeleter.h> |
32 | //US#include <kdebug.h> // defines kdDebug() | 32 | //US#include <kdebug.h> // defines kdDebug() |
33 | 33 | ||
34 | #include "kabprefs.h" | 34 | #include "kabprefs.h" |
35 | 35 | ||
36 | KABPrefs *KABPrefs::sInstance = 0; | 36 | KABPrefs *KABPrefs::sInstance = 0; |
37 | static KStaticDeleter<KABPrefs> staticDeleter; | 37 | static KStaticDeleter<KABPrefs> staticDeleter; |
38 | 38 | ||
39 | KABPrefs::KABPrefs() | 39 | KABPrefs::KABPrefs() |
40 | : KPimPrefs("kaddressbookrc") | 40 | : KPimPrefs("kaddressbookrc") |
41 | { | 41 | { |
42 | KPrefs::setCurrentGroup( "Views" ); | 42 | KPrefs::setCurrentGroup( "Views" ); |
43 | addItemBool( "HonorSingleClick", &mHonorSingleClick, false ); | 43 | addItemBool( "HonorSingleClick", &mHonorSingleClick, false ); |
44 | 44 | ||
45 | KPrefs::setCurrentGroup( "General" ); | 45 | KPrefs::setCurrentGroup( "General" ); |
46 | addItemBool( "AutomaticNameParsing", &mAutomaticNameParsing, true ); | 46 | addItemBool( "AutomaticNameParsing", &mAutomaticNameParsing, true ); |
47 | addItemInt( "CurrentIncSearchField", &mCurrentIncSearchField, 0 ); | 47 | addItemInt( "CurrentIncSearchField", &mCurrentIncSearchField, 0 ); |
48 | 48 | ||
49 | #ifdef KAB_EMBEDDED | 49 | #ifdef KAB_EMBEDDED |
50 | addItemBool("AskForQuit",&mAskForQuit,true); | 50 | addItemBool("AskForQuit",&mAskForQuit,true); |
51 | addItemBool("ToolBarHor",&mToolBarHor, true ); | 51 | addItemBool("ToolBarHor",&mToolBarHor, true ); |
52 | addItemBool("ToolBarUp",&mToolBarUp, false ); | 52 | addItemBool("ToolBarUp",&mToolBarUp, false ); |
53 | addItemBool("SearchWithReturn",&mSearchWithReturn, true ); | 53 | addItemBool("SearchWithReturn",&mSearchWithReturn, true ); |
54 | 54 | ||
55 | 55 | ||
56 | #endif //KAB_EMBEDDED | 56 | #endif //KAB_EMBEDDED |
57 | 57 | ||
58 | KPrefs::setCurrentGroup( "MainWindow" ); | 58 | KPrefs::setCurrentGroup( "MainWindow" ); |
59 | addItemBool( "JumpButtonBarVisible", &mJumpButtonBarVisible, false ); | 59 | addItemBool( "JumpButtonBarVisible", &mJumpButtonBarVisible, false ); |
60 | addItemBool( "DetailsPageVisible", &mDetailsPageVisible, true ); | 60 | addItemBool( "DetailsPageVisible", &mDetailsPageVisible, true ); |
61 | addItemIntList( "ExtensionsSplitter", &mExtensionsSplitter ); | 61 | addItemIntList( "ExtensionsSplitter", &mExtensionsSplitter ); |
62 | addItemIntList( "DetailsSplitter", &mDetailsSplitter ); | 62 | addItemIntList( "DetailsSplitter", &mDetailsSplitter ); |
63 | addItemBool( "MultipleViewsAtOnce", &mMultipleViewsAtOnce, true ); | 63 | addItemBool( "MultipleViewsAtOnce", &mMultipleViewsAtOnce, true ); |
64 | 64 | ||
65 | 65 | ||
66 | KPrefs::setCurrentGroup( "Extensions_General" ); | 66 | KPrefs::setCurrentGroup( "Extensions_General" ); |
67 | QStringList defaultExtensions; | 67 | QStringList defaultExtensions; |
68 | defaultExtensions << "merge"; | 68 | defaultExtensions << "merge"; |
69 | defaultExtensions << "distribution_list_editor"; | 69 | defaultExtensions << "distribution_list_editor"; |
70 | addItemInt( "CurrentExtension", &mCurrentExtension, 0 ); | 70 | addItemInt( "CurrentExtension", &mCurrentExtension, 0 ); |
71 | addItemStringList( "ActiveExtensions", &mActiveExtensions, defaultExtensions ); | 71 | addItemStringList( "ActiveExtensions", &mActiveExtensions, defaultExtensions ); |
72 | 72 | ||
73 | KPrefs::setCurrentGroup( "Views" ); | 73 | KPrefs::setCurrentGroup( "Views" ); |
74 | QString defaultView = i18n( "Default Table View" ); | 74 | QString defaultView = i18n( "Default Table View" ); |
75 | addItemString( "CurrentView", &mCurrentView, defaultView ); | 75 | addItemString( "CurrentView", &mCurrentView, defaultView ); |
76 | addItemStringList( "ViewNames", &mViewNames, defaultView ); | 76 | addItemStringList( "ViewNames", &mViewNames, defaultView ); |
77 | 77 | ||
78 | KPrefs::setCurrentGroup( "Filters" ); | 78 | KPrefs::setCurrentGroup( "Filters" ); |
79 | addItemInt( "CurrentFilter", &mCurrentFilter, 0 ); | 79 | addItemInt( "CurrentFilter", &mCurrentFilter, 0 ); |
80 | 80 | ||
81 | } | 81 | } |
82 | 82 | ||
83 | KABPrefs::~KABPrefs() | 83 | KABPrefs::~KABPrefs() |
84 | { | 84 | { |
85 | //qDebug("KABPrefs::~KABPrefs() "); | ||
85 | } | 86 | } |
86 | 87 | ||
87 | KABPrefs *KABPrefs::instance() | 88 | KABPrefs *KABPrefs::instance() |
88 | { | 89 | { |
89 | if ( !sInstance ) { | 90 | if ( !sInstance ) { |
90 | #ifdef KAB_EMBEDDED | 91 | #ifdef KAB_EMBEDDED |
91 | sInstance = staticDeleter.setObject( new KABPrefs() ); | 92 | sInstance = staticDeleter.setObject( new KABPrefs() ); |
92 | #else //KAB_EMBEDDED | 93 | #else //KAB_EMBEDDED |
93 | //US the following line has changed ???. Why | 94 | //US the following line has changed ???. Why |
94 | staticDeleter.setObject( sInstance, new KABPrefs() ); | 95 | staticDeleter.setObject( sInstance, new KABPrefs() ); |
95 | #endif //KAB_EMBEDDED | 96 | #endif //KAB_EMBEDDED |
96 | sInstance->readConfig(); | 97 | sInstance->readConfig(); |
97 | } | 98 | } |
98 | 99 | ||
99 | return sInstance; | 100 | return sInstance; |
100 | } | 101 | } |
101 | 102 | ||
102 | void KABPrefs::setCategoryDefaults() | 103 | void KABPrefs::setCategoryDefaults() |
103 | { | 104 | { |
104 | mCustomCategories.clear(); | 105 | mCustomCategories.clear(); |
105 | 106 | ||
106 | mCustomCategories << i18n( "Business" ) << i18n( "Family" ) << i18n( "School" ) | 107 | mCustomCategories << i18n( "Business" ) << i18n( "Family" ) << i18n( "School" ) |
107 | << i18n( "Customer" ) << i18n( "Friend" ); | 108 | << i18n( "Customer" ) << i18n( "Friend" ); |
108 | } | 109 | } |
109 | 110 | ||
110 | // US introduce a nonconst way to return the config object. | 111 | // US introduce a nonconst way to return the config object. |
111 | KConfig* KABPrefs::getConfig() | 112 | KConfig* KABPrefs::getConfig() |
112 | { | 113 | { |
113 | return config(); | 114 | return config(); |
114 | } | 115 | } |
115 | 116 | ||
116 | 117 | ||
117 | /*US | 118 | /*US |
118 | void KABPrefs::usrSetDefaults() | 119 | void KABPrefs::usrSetDefaults() |
119 | { | 120 | { |
120 | KPimPrefs::usrSetDefaults(); | 121 | KPimPrefs::usrSetDefaults(); |
121 | } | 122 | } |
122 | 123 | ||
123 | void KABPrefs::usrReadConfig() | 124 | void KABPrefs::usrReadConfig() |
124 | { | 125 | { |
125 | KPimPrefs::usrReadConfig(); | 126 | KPimPrefs::usrReadConfig(); |
126 | } | 127 | } |
127 | 128 | ||
128 | void KABPrefs::usrWriteConfig() | 129 | void KABPrefs::usrWriteConfig() |
129 | { | 130 | { |
130 | KPimPrefs::usrWriteConfig(); | 131 | KPimPrefs::usrWriteConfig(); |
131 | } | 132 | } |
132 | */ | 133 | */ |