-rw-r--r-- | kaddressbook/kabcore.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 3ab06c4..2e408b7 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1,1872 +1,1873 @@ | |||
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 | 207 | ||
208 | bool pasteWithNewUid = true; | 208 | bool pasteWithNewUid = true; |
209 | 209 | ||
210 | #ifdef KAB_EMBEDDED | 210 | #ifdef KAB_EMBEDDED |
211 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 211 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) |
212 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 212 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
213 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ | 213 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ |
214 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) | 214 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) |
215 | #else //KAB_EMBEDDED | 215 | #else //KAB_EMBEDDED |
216 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 216 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) |
217 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 217 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
218 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), | 218 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), |
219 | mReadWrite( readWrite ), mModified( false ) | 219 | mReadWrite( readWrite ), mModified( false ) |
220 | #endif //KAB_EMBEDDED | 220 | #endif //KAB_EMBEDDED |
221 | { | 221 | { |
222 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 222 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
223 | // syncManager->setBlockSave(false); | 223 | // syncManager->setBlockSave(false); |
224 | mExtensionBarSplitter = 0; | 224 | mExtensionBarSplitter = 0; |
225 | mIsPart = !parent->inherits( "KAddressBookMain" ); | 225 | mIsPart = !parent->inherits( "KAddressBookMain" ); |
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 | 310 | ||
311 | mMessageTimer = new QTimer( this ); | 311 | mMessageTimer = new QTimer( this ); |
312 | connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); | 312 | connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); |
313 | mEditorDialog = 0; | 313 | mEditorDialog = 0; |
314 | createAddresseeEditorDialog( this ); | 314 | createAddresseeEditorDialog( this ); |
315 | setModified( false ); | 315 | setModified( false ); |
316 | } | 316 | } |
317 | 317 | ||
318 | KABCore::~KABCore() | 318 | KABCore::~KABCore() |
319 | { | 319 | { |
320 | // save(); | 320 | // save(); |
321 | //saveSettings(); | 321 | //saveSettings(); |
322 | //KABPrefs::instance()->writeConfig(); | 322 | //KABPrefs::instance()->writeConfig(); |
323 | delete AddresseeConfig::instance(); | 323 | delete AddresseeConfig::instance(); |
324 | mAddressBook = 0; | 324 | mAddressBook = 0; |
325 | KABC::StdAddressBook::close(); | 325 | KABC::StdAddressBook::close(); |
326 | 326 | ||
327 | delete syncManager; | 327 | delete syncManager; |
328 | 328 | ||
329 | } | 329 | } |
330 | 330 | ||
331 | void KABCore::recieve( QString fn ) | 331 | void KABCore::recieve( QString fn ) |
332 | { | 332 | { |
333 | //qDebug("KABCore::recieve "); | 333 | //qDebug("KABCore::recieve "); |
334 | int count = mAddressBook->importFromFile( fn, true ); | 334 | int count = mAddressBook->importFromFile( fn, true ); |
335 | mViewManager->refreshView(); | 335 | mViewManager->refreshView(); |
336 | message(i18n("%1 contact(s) received!").arg( count )); | 336 | message(i18n("%1 contact(s) received!").arg( count )); |
337 | topLevelWidget()->showMaximized(); | ||
337 | topLevelWidget()->raise(); | 338 | topLevelWidget()->raise(); |
338 | } | 339 | } |
339 | void KABCore::restoreSettings() | 340 | void KABCore::restoreSettings() |
340 | { | 341 | { |
341 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; | 342 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; |
342 | 343 | ||
343 | bool state; | 344 | bool state; |
344 | 345 | ||
345 | if (mMultipleViewsAtOnce) | 346 | if (mMultipleViewsAtOnce) |
346 | state = KABPrefs::instance()->mDetailsPageVisible; | 347 | state = KABPrefs::instance()->mDetailsPageVisible; |
347 | else | 348 | else |
348 | state = false; | 349 | state = false; |
349 | 350 | ||
350 | mActionDetails->setChecked( state ); | 351 | mActionDetails->setChecked( state ); |
351 | setDetailsVisible( state ); | 352 | setDetailsVisible( state ); |
352 | 353 | ||
353 | state = KABPrefs::instance()->mJumpButtonBarVisible; | 354 | state = KABPrefs::instance()->mJumpButtonBarVisible; |
354 | 355 | ||
355 | mActionJumpBar->setChecked( state ); | 356 | mActionJumpBar->setChecked( state ); |
356 | setJumpButtonBarVisible( state ); | 357 | setJumpButtonBarVisible( state ); |
357 | /*US | 358 | /*US |
358 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 359 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
359 | if ( splitterSize.count() == 0 ) { | 360 | if ( splitterSize.count() == 0 ) { |
360 | splitterSize.append( width() / 2 ); | 361 | splitterSize.append( width() / 2 ); |
361 | splitterSize.append( width() / 2 ); | 362 | splitterSize.append( width() / 2 ); |
362 | } | 363 | } |
363 | mMiniSplitter->setSizes( splitterSize ); | 364 | mMiniSplitter->setSizes( splitterSize ); |
364 | if ( mExtensionBarSplitter ) { | 365 | if ( mExtensionBarSplitter ) { |
365 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 366 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
366 | if ( splitterSize.count() == 0 ) { | 367 | if ( splitterSize.count() == 0 ) { |
367 | splitterSize.append( width() / 2 ); | 368 | splitterSize.append( width() / 2 ); |
368 | splitterSize.append( width() / 2 ); | 369 | splitterSize.append( width() / 2 ); |
369 | } | 370 | } |
370 | mExtensionBarSplitter->setSizes( splitterSize ); | 371 | mExtensionBarSplitter->setSizes( splitterSize ); |
371 | 372 | ||
372 | } | 373 | } |
373 | */ | 374 | */ |
374 | mViewManager->restoreSettings(); | 375 | mViewManager->restoreSettings(); |
375 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 376 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
376 | mExtensionManager->restoreSettings(); | 377 | mExtensionManager->restoreSettings(); |
377 | #ifdef DESKTOP_VERSION | 378 | #ifdef DESKTOP_VERSION |
378 | int wid = width(); | 379 | int wid = width(); |
379 | if ( wid < 10 ) | 380 | if ( wid < 10 ) |
380 | wid = 400; | 381 | wid = 400; |
381 | #else | 382 | #else |
382 | int wid = QApplication::desktop()->width(); | 383 | int wid = QApplication::desktop()->width(); |
383 | if ( wid < 640 ) | 384 | if ( wid < 640 ) |
384 | wid = QApplication::desktop()->height(); | 385 | wid = QApplication::desktop()->height(); |
385 | #endif | 386 | #endif |
386 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; | 387 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; |
387 | if ( true /*splitterSize.count() == 0*/ ) { | 388 | if ( true /*splitterSize.count() == 0*/ ) { |
388 | splitterSize.append( wid / 2 ); | 389 | splitterSize.append( wid / 2 ); |
389 | splitterSize.append( wid / 2 ); | 390 | splitterSize.append( wid / 2 ); |
390 | } | 391 | } |
391 | mMiniSplitter->setSizes( splitterSize ); | 392 | mMiniSplitter->setSizes( splitterSize ); |
392 | if ( mExtensionBarSplitter ) { | 393 | if ( mExtensionBarSplitter ) { |
393 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 394 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
394 | if ( true /*splitterSize.count() == 0*/ ) { | 395 | if ( true /*splitterSize.count() == 0*/ ) { |
395 | splitterSize.append( wid / 2 ); | 396 | splitterSize.append( wid / 2 ); |
396 | splitterSize.append( wid / 2 ); | 397 | splitterSize.append( wid / 2 ); |
397 | } | 398 | } |
398 | mExtensionBarSplitter->setSizes( splitterSize ); | 399 | mExtensionBarSplitter->setSizes( splitterSize ); |
399 | 400 | ||
400 | } | 401 | } |
401 | 402 | ||
402 | 403 | ||
403 | } | 404 | } |
404 | 405 | ||
405 | void KABCore::saveSettings() | 406 | void KABCore::saveSettings() |
406 | { | 407 | { |
407 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | 408 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); |
408 | if ( mExtensionBarSplitter ) | 409 | if ( mExtensionBarSplitter ) |
409 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 410 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
410 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | 411 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); |
411 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); | 412 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); |
412 | #ifndef KAB_EMBEDDED | 413 | #ifndef KAB_EMBEDDED |
413 | 414 | ||
414 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 415 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
415 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | 416 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); |
416 | #endif //KAB_EMBEDDED | 417 | #endif //KAB_EMBEDDED |
417 | mExtensionManager->saveSettings(); | 418 | mExtensionManager->saveSettings(); |
418 | mViewManager->saveSettings(); | 419 | mViewManager->saveSettings(); |
419 | 420 | ||
420 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 421 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
421 | } | 422 | } |
422 | 423 | ||
423 | KABC::AddressBook *KABCore::addressBook() const | 424 | KABC::AddressBook *KABCore::addressBook() const |
424 | { | 425 | { |
425 | return mAddressBook; | 426 | return mAddressBook; |
426 | } | 427 | } |
427 | 428 | ||
428 | KConfig *KABCore::config() | 429 | KConfig *KABCore::config() |
429 | { | 430 | { |
430 | #ifndef KAB_EMBEDDED | 431 | #ifndef KAB_EMBEDDED |
431 | return KABPrefs::instance()->config(); | 432 | return KABPrefs::instance()->config(); |
432 | #else //KAB_EMBEDDED | 433 | #else //KAB_EMBEDDED |
433 | return KABPrefs::instance()->getConfig(); | 434 | return KABPrefs::instance()->getConfig(); |
434 | #endif //KAB_EMBEDDED | 435 | #endif //KAB_EMBEDDED |
435 | } | 436 | } |
436 | 437 | ||
437 | KActionCollection *KABCore::actionCollection() const | 438 | KActionCollection *KABCore::actionCollection() const |
438 | { | 439 | { |
439 | return mGUIClient->actionCollection(); | 440 | return mGUIClient->actionCollection(); |
440 | } | 441 | } |
441 | 442 | ||
442 | KABC::Field *KABCore::currentSearchField() const | 443 | KABC::Field *KABCore::currentSearchField() const |
443 | { | 444 | { |
444 | if (mIncSearchWidget) | 445 | if (mIncSearchWidget) |
445 | return mIncSearchWidget->currentField(); | 446 | return mIncSearchWidget->currentField(); |
446 | else | 447 | else |
447 | return 0; | 448 | return 0; |
448 | } | 449 | } |
449 | 450 | ||
450 | QStringList KABCore::selectedUIDs() const | 451 | QStringList KABCore::selectedUIDs() const |
451 | { | 452 | { |
452 | return mViewManager->selectedUids(); | 453 | return mViewManager->selectedUids(); |
453 | } | 454 | } |
454 | 455 | ||
455 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 456 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
456 | { | 457 | { |
457 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 458 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
458 | 459 | ||
459 | QPtrList<KRES::Resource> kresResources; | 460 | QPtrList<KRES::Resource> kresResources; |
460 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 461 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
461 | KABC::Resource *resource; | 462 | KABC::Resource *resource; |
462 | while ( ( resource = resIt.current() ) != 0 ) { | 463 | while ( ( resource = resIt.current() ) != 0 ) { |
463 | ++resIt; | 464 | ++resIt; |
464 | if ( !resource->readOnly() ) { | 465 | if ( !resource->readOnly() ) { |
465 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 466 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
466 | if ( res ) | 467 | if ( res ) |
467 | kresResources.append( res ); | 468 | kresResources.append( res ); |
468 | } | 469 | } |
469 | } | 470 | } |
470 | 471 | ||
471 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 472 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
472 | return static_cast<KABC::Resource*>( res ); | 473 | return static_cast<KABC::Resource*>( res ); |
473 | } | 474 | } |
474 | 475 | ||
475 | #ifndef KAB_EMBEDDED | 476 | #ifndef KAB_EMBEDDED |
476 | KAboutData *KABCore::createAboutData() | 477 | KAboutData *KABCore::createAboutData() |
477 | #else //KAB_EMBEDDED | 478 | #else //KAB_EMBEDDED |
478 | void KABCore::createAboutData() | 479 | void KABCore::createAboutData() |
479 | #endif //KAB_EMBEDDED | 480 | #endif //KAB_EMBEDDED |
480 | { | 481 | { |
481 | #ifndef KAB_EMBEDDED | 482 | #ifndef KAB_EMBEDDED |
482 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), | 483 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), |
483 | "3.1", I18N_NOOP( "The KDE Address Book" ), | 484 | "3.1", I18N_NOOP( "The KDE Address Book" ), |
484 | KAboutData::License_GPL_V2, | 485 | KAboutData::License_GPL_V2, |
485 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); | 486 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); |
486 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); | 487 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); |
487 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); | 488 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); |
488 | about->addAuthor( "Cornelius Schumacher", | 489 | about->addAuthor( "Cornelius Schumacher", |
489 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | 490 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), |
490 | "schumacher@kde.org" ); | 491 | "schumacher@kde.org" ); |
491 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | 492 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), |
492 | "mpilone@slac.com" ); | 493 | "mpilone@slac.com" ); |
493 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | 494 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); |
494 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | 495 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); |
495 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | 496 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), |
496 | "michel@klaralvdalens-datakonsult.se" ); | 497 | "michel@klaralvdalens-datakonsult.se" ); |
497 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | 498 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), |
498 | "hansen@kde.org" ); | 499 | "hansen@kde.org" ); |
499 | 500 | ||
500 | return about; | 501 | return about; |
501 | #endif //KAB_EMBEDDED | 502 | #endif //KAB_EMBEDDED |
502 | 503 | ||
503 | QString version; | 504 | QString version; |
504 | #include <../version> | 505 | #include <../version> |
505 | QMessageBox::about( this, "About KAddressbook/Pi", | 506 | QMessageBox::about( this, "About KAddressbook/Pi", |
506 | "KAddressbook/Platform-independent\n" | 507 | "KAddressbook/Platform-independent\n" |
507 | "(KA/Pi) " +version + " - " + | 508 | "(KA/Pi) " +version + " - " + |
508 | #ifdef DESKTOP_VERSION | 509 | #ifdef DESKTOP_VERSION |
509 | "Desktop Edition\n" | 510 | "Desktop Edition\n" |
510 | #else | 511 | #else |
511 | "PDA-Edition\n" | 512 | "PDA-Edition\n" |
512 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 513 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
513 | #endif | 514 | #endif |
514 | 515 | ||
515 | "(c) 2004 Ulf Schenk\n" | 516 | "(c) 2004 Ulf Schenk\n" |
516 | "(c) 2004 Lutz Rogowski\n" | 517 | "(c) 2004 Lutz Rogowski\n" |
517 | "(c) 1997-2003, The KDE PIM Team\n" | 518 | "(c) 1997-2003, The KDE PIM Team\n" |
518 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" | 519 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" |
519 | "Don Sanders Original author\n" | 520 | "Don Sanders Original author\n" |
520 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" | 521 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" |
521 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" | 522 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" |
522 | "Greg Stern DCOP interface\n" | 523 | "Greg Stern DCOP interface\n" |
523 | "Mark Westcot Contact pinning\n" | 524 | "Mark Westcot Contact pinning\n" |
524 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" | 525 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" |
525 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" | 526 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" |
526 | #ifdef _WIN32_ | 527 | #ifdef _WIN32_ |
527 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" | 528 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" |
528 | #endif | 529 | #endif |
529 | ); | 530 | ); |
530 | } | 531 | } |
531 | 532 | ||
532 | void KABCore::setContactSelected( const QString &uid ) | 533 | void KABCore::setContactSelected( const QString &uid ) |
533 | { | 534 | { |
534 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 535 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
535 | if ( !mDetails->isHidden() ) | 536 | if ( !mDetails->isHidden() ) |
536 | mDetails->setAddressee( addr ); | 537 | mDetails->setAddressee( addr ); |
537 | 538 | ||
538 | if ( !addr.isEmpty() ) { | 539 | if ( !addr.isEmpty() ) { |
539 | emit contactSelected( addr.formattedName() ); | 540 | emit contactSelected( addr.formattedName() ); |
540 | KABC::Picture pic = addr.photo(); | 541 | KABC::Picture pic = addr.photo(); |
541 | if ( pic.isIntern() ) { | 542 | if ( pic.isIntern() ) { |
542 | //US emit contactSelected( pic.data() ); | 543 | //US emit contactSelected( pic.data() ); |
543 | //US instead use: | 544 | //US instead use: |
544 | QPixmap px; | 545 | QPixmap px; |
545 | if (pic.data().isNull() != true) | 546 | if (pic.data().isNull() != true) |
546 | { | 547 | { |
547 | px.convertFromImage(pic.data()); | 548 | px.convertFromImage(pic.data()); |
548 | } | 549 | } |
549 | 550 | ||
550 | emit contactSelected( px ); | 551 | emit contactSelected( px ); |
551 | } | 552 | } |
552 | } | 553 | } |
553 | 554 | ||
554 | 555 | ||
555 | mExtensionManager->setSelectionChanged(); | 556 | mExtensionManager->setSelectionChanged(); |
556 | 557 | ||
557 | // update the actions | 558 | // update the actions |
558 | bool selected = !uid.isEmpty(); | 559 | bool selected = !uid.isEmpty(); |
559 | 560 | ||
560 | if ( mReadWrite ) { | 561 | if ( mReadWrite ) { |
561 | mActionCut->setEnabled( selected ); | 562 | mActionCut->setEnabled( selected ); |
562 | mActionPaste->setEnabled( selected ); | 563 | mActionPaste->setEnabled( selected ); |
563 | } | 564 | } |
564 | 565 | ||
565 | mActionCopy->setEnabled( selected ); | 566 | mActionCopy->setEnabled( selected ); |
566 | mActionDelete->setEnabled( selected ); | 567 | mActionDelete->setEnabled( selected ); |
567 | mActionEditAddressee->setEnabled( selected ); | 568 | mActionEditAddressee->setEnabled( selected ); |
568 | mActionMail->setEnabled( selected ); | 569 | mActionMail->setEnabled( selected ); |
569 | mActionMailVCard->setEnabled( selected ); | 570 | mActionMailVCard->setEnabled( selected ); |
570 | //if (mActionBeam) | 571 | //if (mActionBeam) |
571 | //mActionBeam->setEnabled( selected ); | 572 | //mActionBeam->setEnabled( selected ); |
572 | 573 | ||
573 | if (mActionBeamVCard) | 574 | if (mActionBeamVCard) |
574 | mActionBeamVCard->setEnabled( selected ); | 575 | mActionBeamVCard->setEnabled( selected ); |
575 | 576 | ||
576 | mActionExport2phone->setEnabled( selected ); | 577 | mActionExport2phone->setEnabled( selected ); |
577 | mActionWhoAmI->setEnabled( selected ); | 578 | mActionWhoAmI->setEnabled( selected ); |
578 | mActionCategories->setEnabled( selected ); | 579 | mActionCategories->setEnabled( selected ); |
579 | } | 580 | } |
580 | 581 | ||
581 | void KABCore::sendMail() | 582 | void KABCore::sendMail() |
582 | { | 583 | { |
583 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 584 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
584 | } | 585 | } |
585 | 586 | ||
586 | void KABCore::sendMail( const QString& emaillist ) | 587 | void KABCore::sendMail( const QString& emaillist ) |
587 | { | 588 | { |
588 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " | 589 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " |
589 | if (emaillist.contains(",") > 0) | 590 | if (emaillist.contains(",") > 0) |
590 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); | 591 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); |
591 | else | 592 | else |
592 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); | 593 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); |
593 | } | 594 | } |
594 | 595 | ||
595 | 596 | ||
596 | 597 | ||
597 | void KABCore::mailVCard() | 598 | void KABCore::mailVCard() |
598 | { | 599 | { |
599 | QStringList uids = mViewManager->selectedUids(); | 600 | QStringList uids = mViewManager->selectedUids(); |
600 | if ( !uids.isEmpty() ) | 601 | if ( !uids.isEmpty() ) |
601 | mailVCard( uids ); | 602 | mailVCard( uids ); |
602 | } | 603 | } |
603 | 604 | ||
604 | void KABCore::mailVCard( const QStringList& uids ) | 605 | void KABCore::mailVCard( const QStringList& uids ) |
605 | { | 606 | { |
606 | QStringList urls; | 607 | QStringList urls; |
607 | 608 | ||
608 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 609 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
609 | 610 | ||
610 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); | 611 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); |
611 | 612 | ||
612 | 613 | ||
613 | 614 | ||
614 | QDir().mkdir( dirName, true ); | 615 | QDir().mkdir( dirName, true ); |
615 | 616 | ||
616 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 617 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
617 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 618 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
618 | 619 | ||
619 | if ( a.isEmpty() ) | 620 | if ( a.isEmpty() ) |
620 | continue; | 621 | continue; |
621 | 622 | ||
622 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 623 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
623 | 624 | ||
624 | QString fileName = dirName + "/" + name; | 625 | QString fileName = dirName + "/" + name; |
625 | 626 | ||
626 | QFile outFile(fileName); | 627 | QFile outFile(fileName); |
627 | 628 | ||
628 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 629 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
629 | KABC::VCardConverter converter; | 630 | KABC::VCardConverter converter; |
630 | QString vcard; | 631 | QString vcard; |
631 | 632 | ||
632 | converter.addresseeToVCard( a, vcard ); | 633 | converter.addresseeToVCard( a, vcard ); |
633 | 634 | ||
634 | QTextStream t( &outFile ); // use a text stream | 635 | QTextStream t( &outFile ); // use a text stream |
635 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 636 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
636 | t << vcard; | 637 | t << vcard; |
637 | 638 | ||
638 | outFile.close(); | 639 | outFile.close(); |
639 | 640 | ||
640 | urls.append( fileName ); | 641 | urls.append( fileName ); |
641 | } | 642 | } |
642 | } | 643 | } |
643 | 644 | ||
644 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); | 645 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
645 | 646 | ||
646 | 647 | ||
647 | /*US | 648 | /*US |
648 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 649 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
649 | QString::null, // subject | 650 | QString::null, // subject |
650 | QString::null, // body | 651 | QString::null, // body |
651 | QString::null, | 652 | QString::null, |
652 | urls ); // attachments | 653 | urls ); // attachments |
653 | */ | 654 | */ |
654 | 655 | ||
655 | } | 656 | } |
656 | 657 | ||
657 | /** | 658 | /** |
658 | Beams the "WhoAmI contact. | 659 | Beams the "WhoAmI contact. |
659 | */ | 660 | */ |
660 | void KABCore::beamMySelf() | 661 | void KABCore::beamMySelf() |
661 | { | 662 | { |
662 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 663 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
663 | if (!a.isEmpty()) | 664 | if (!a.isEmpty()) |
664 | { | 665 | { |
665 | QStringList uids; | 666 | QStringList uids; |
666 | uids << a.uid(); | 667 | uids << a.uid(); |
667 | 668 | ||
668 | beamVCard(uids); | 669 | beamVCard(uids); |
669 | } else { | 670 | } else { |
670 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 671 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
671 | 672 | ||
672 | 673 | ||
673 | } | 674 | } |
674 | } | 675 | } |
675 | 676 | ||
676 | void KABCore::export2phone() | 677 | void KABCore::export2phone() |
677 | { | 678 | { |
678 | 679 | ||
679 | KAex2phonePrefs ex2phone; | 680 | KAex2phonePrefs ex2phone; |
680 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 681 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
681 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 682 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
682 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 683 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
683 | 684 | ||
684 | if ( !ex2phone.exec() ) { | 685 | if ( !ex2phone.exec() ) { |
685 | return; | 686 | return; |
686 | } | 687 | } |
687 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 688 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
688 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 689 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
689 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 690 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
690 | 691 | ||
691 | 692 | ||
692 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 693 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
693 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 694 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
694 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 695 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
695 | 696 | ||
696 | QStringList uids = mViewManager->selectedUids(); | 697 | QStringList uids = mViewManager->selectedUids(); |
697 | if ( uids.isEmpty() ) | 698 | if ( uids.isEmpty() ) |
698 | return; | 699 | return; |
699 | 700 | ||
700 | QString fileName = getPhoneFile(); | 701 | QString fileName = getPhoneFile(); |
701 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) | 702 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) |
702 | return; | 703 | return; |
703 | 704 | ||
704 | message(i18n("Exporting to phone...")); | 705 | message(i18n("Exporting to phone...")); |
705 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); | 706 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); |
706 | 707 | ||
707 | } | 708 | } |
708 | QString KABCore::getPhoneFile() | 709 | QString KABCore::getPhoneFile() |
709 | { | 710 | { |
710 | #ifdef _WIN32_ | 711 | #ifdef _WIN32_ |
711 | return locateLocal("tmp", "phonefile.vcf"); | 712 | return locateLocal("tmp", "phonefile.vcf"); |
712 | #else | 713 | #else |
713 | return "/tmp/phonefile.vcf"; | 714 | return "/tmp/phonefile.vcf"; |
714 | #endif | 715 | #endif |
715 | 716 | ||
716 | } | 717 | } |
717 | void KABCore::writeToPhone( ) | 718 | void KABCore::writeToPhone( ) |
718 | { | 719 | { |
719 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) | 720 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) |
720 | message(i18n("Export to phone finished!")); | 721 | message(i18n("Export to phone finished!")); |
721 | else | 722 | else |
722 | qDebug(i18n("Error exporting to phone")); | 723 | qDebug(i18n("Error exporting to phone")); |
723 | } | 724 | } |
724 | void KABCore::beamVCard() | 725 | void KABCore::beamVCard() |
725 | { | 726 | { |
726 | QStringList uids = mViewManager->selectedUids(); | 727 | QStringList uids = mViewManager->selectedUids(); |
727 | if ( !uids.isEmpty() ) | 728 | if ( !uids.isEmpty() ) |
728 | beamVCard( uids ); | 729 | beamVCard( uids ); |
729 | } | 730 | } |
730 | 731 | ||
731 | 732 | ||
732 | void KABCore::beamVCard(const QStringList& uids) | 733 | void KABCore::beamVCard(const QStringList& uids) |
733 | { | 734 | { |
734 | /*US | 735 | /*US |
735 | QString beamFilename; | 736 | QString beamFilename; |
736 | Opie::OPimContact c; | 737 | Opie::OPimContact c; |
737 | if ( actionPersonal->isOn() ) { | 738 | if ( actionPersonal->isOn() ) { |
738 | beamFilename = addressbookPersonalVCardName(); | 739 | beamFilename = addressbookPersonalVCardName(); |
739 | if ( !QFile::exists( beamFilename ) ) | 740 | if ( !QFile::exists( beamFilename ) ) |
740 | return; // can't beam a non-existent file | 741 | return; // can't beam a non-existent file |
741 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 742 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
742 | beamFilename ); | 743 | beamFilename ); |
743 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 744 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
744 | Opie::OPimContactAccess::List allList = access->allRecords(); | 745 | Opie::OPimContactAccess::List allList = access->allRecords(); |
745 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first | 746 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first |
746 | c = *it; | 747 | c = *it; |
747 | 748 | ||
748 | delete access; | 749 | delete access; |
749 | } else { | 750 | } else { |
750 | unlink( beamfile ); // delete if exists | 751 | unlink( beamfile ); // delete if exists |
751 | mkdir("/tmp/obex/", 0755); | 752 | mkdir("/tmp/obex/", 0755); |
752 | c = m_abView -> currentEntry(); | 753 | c = m_abView -> currentEntry(); |
753 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 754 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
754 | beamfile ); | 755 | beamfile ); |
755 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 756 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
756 | access->add( c ); | 757 | access->add( c ); |
757 | access->save(); | 758 | access->save(); |
758 | delete access; | 759 | delete access; |
759 | 760 | ||
760 | beamFilename = beamfile; | 761 | beamFilename = beamfile; |
761 | } | 762 | } |
762 | 763 | ||
763 | owarn << "Beaming: " << beamFilename << oendl; | 764 | owarn << "Beaming: " << beamFilename << oendl; |
764 | */ | 765 | */ |
765 | 766 | ||
766 | #if 0 | 767 | #if 0 |
767 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 768 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
768 | 769 | ||
769 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); | 770 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); |
770 | 771 | ||
771 | QString name = "contact.vcf"; | 772 | QString name = "contact.vcf"; |
772 | 773 | ||
773 | QString fileName = dirName + "/" + name; | 774 | QString fileName = dirName + "/" + name; |
774 | #endif | 775 | #endif |
775 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory | 776 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory |
776 | // | 777 | // |
777 | QString fileName = "/tmp/kapibeamfile.vcf"; | 778 | QString fileName = "/tmp/kapibeamfile.vcf"; |
778 | 779 | ||
779 | 780 | ||
780 | //QDir().mkdir( dirName, true ); | 781 | //QDir().mkdir( dirName, true ); |
781 | 782 | ||
782 | 783 | ||
783 | KABC::VCardConverter converter; | 784 | KABC::VCardConverter converter; |
784 | QString description; | 785 | QString description; |
785 | QString datastream; | 786 | QString datastream; |
786 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 787 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
787 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 788 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
788 | 789 | ||
789 | if ( a.isEmpty() ) | 790 | if ( a.isEmpty() ) |
790 | continue; | 791 | continue; |
791 | 792 | ||
792 | if (description.isEmpty()) | 793 | if (description.isEmpty()) |
793 | description = a.formattedName(); | 794 | description = a.formattedName(); |
794 | 795 | ||
795 | QString vcard; | 796 | QString vcard; |
796 | converter.addresseeToVCard( a, vcard ); | 797 | converter.addresseeToVCard( a, vcard ); |
797 | int start = 0; | 798 | int start = 0; |
798 | int next; | 799 | int next; |
799 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 800 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
800 | int semi = vcard.find(";", next); | 801 | int semi = vcard.find(";", next); |
801 | int dopp = vcard.find(":", next); | 802 | int dopp = vcard.find(":", next); |
802 | int sep; | 803 | int sep; |
803 | if ( semi < dopp && semi >= 0 ) | 804 | if ( semi < dopp && semi >= 0 ) |
804 | sep = semi ; | 805 | sep = semi ; |
805 | else | 806 | else |
806 | sep = dopp; | 807 | sep = dopp; |
807 | datastream +=vcard.mid( start, next - start); | 808 | datastream +=vcard.mid( start, next - start); |
808 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | 809 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); |
809 | start = sep; | 810 | start = sep; |
810 | } | 811 | } |
811 | datastream += vcard.mid( start,vcard.length() ); | 812 | datastream += vcard.mid( start,vcard.length() ); |
812 | } | 813 | } |
813 | #ifndef DESKTOP_VERSION | 814 | #ifndef DESKTOP_VERSION |
814 | QFile outFile(fileName); | 815 | QFile outFile(fileName); |
815 | if ( outFile.open(IO_WriteOnly) ) { | 816 | if ( outFile.open(IO_WriteOnly) ) { |
816 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 817 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
817 | QTextStream t( &outFile ); // use a text stream | 818 | QTextStream t( &outFile ); // use a text stream |
818 | //t.setEncoding( QTextStream::UnicodeUTF8 ); | 819 | //t.setEncoding( QTextStream::UnicodeUTF8 ); |
819 | t.setEncoding( QTextStream::Latin1 ); | 820 | t.setEncoding( QTextStream::Latin1 ); |
820 | t <<datastream.latin1(); | 821 | t <<datastream.latin1(); |
821 | outFile.close(); | 822 | outFile.close(); |
822 | Ir *ir = new Ir( this ); | 823 | Ir *ir = new Ir( this ); |
823 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 824 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
824 | ir->send( fileName, description, "text/x-vCard" ); | 825 | ir->send( fileName, description, "text/x-vCard" ); |
825 | } else { | 826 | } else { |
826 | qDebug("Error open temp beam file "); | 827 | qDebug("Error open temp beam file "); |
827 | return; | 828 | return; |
828 | } | 829 | } |
829 | #endif | 830 | #endif |
830 | 831 | ||
831 | } | 832 | } |
832 | 833 | ||
833 | void KABCore::beamDone( Ir *ir ) | 834 | void KABCore::beamDone( Ir *ir ) |
834 | { | 835 | { |
835 | #ifndef DESKTOP_VERSION | 836 | #ifndef DESKTOP_VERSION |
836 | delete ir; | 837 | delete ir; |
837 | #endif | 838 | #endif |
838 | topLevelWidget()->raise(); | 839 | topLevelWidget()->raise(); |
839 | message( i18n("Beaming finished!") ); | 840 | message( i18n("Beaming finished!") ); |
840 | } | 841 | } |
841 | 842 | ||
842 | 843 | ||
843 | void KABCore::browse( const QString& url ) | 844 | void KABCore::browse( const QString& url ) |
844 | { | 845 | { |
845 | #ifndef KAB_EMBEDDED | 846 | #ifndef KAB_EMBEDDED |
846 | kapp->invokeBrowser( url ); | 847 | kapp->invokeBrowser( url ); |
847 | #else //KAB_EMBEDDED | 848 | #else //KAB_EMBEDDED |
848 | qDebug("KABCore::browse must be fixed"); | 849 | qDebug("KABCore::browse must be fixed"); |
849 | #endif //KAB_EMBEDDED | 850 | #endif //KAB_EMBEDDED |
850 | } | 851 | } |
851 | 852 | ||
852 | void KABCore::selectAllContacts() | 853 | void KABCore::selectAllContacts() |
853 | { | 854 | { |
854 | mViewManager->setSelected( QString::null, true ); | 855 | mViewManager->setSelected( QString::null, true ); |
855 | } | 856 | } |
856 | 857 | ||
857 | void KABCore::deleteContacts() | 858 | void KABCore::deleteContacts() |
858 | { | 859 | { |
859 | QStringList uidList = mViewManager->selectedUids(); | 860 | QStringList uidList = mViewManager->selectedUids(); |
860 | deleteContacts( uidList ); | 861 | deleteContacts( uidList ); |
861 | } | 862 | } |
862 | 863 | ||
863 | void KABCore::deleteContacts( const QStringList &uids ) | 864 | void KABCore::deleteContacts( const QStringList &uids ) |
864 | { | 865 | { |
865 | if ( uids.count() > 0 ) { | 866 | if ( uids.count() > 0 ) { |
866 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 867 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
867 | UndoStack::instance()->push( command ); | 868 | UndoStack::instance()->push( command ); |
868 | RedoStack::instance()->clear(); | 869 | RedoStack::instance()->clear(); |
869 | 870 | ||
870 | // now if we deleted anything, refresh | 871 | // now if we deleted anything, refresh |
871 | setContactSelected( QString::null ); | 872 | setContactSelected( QString::null ); |
872 | setModified( true ); | 873 | setModified( true ); |
873 | } | 874 | } |
874 | } | 875 | } |
875 | 876 | ||
876 | void KABCore::copyContacts() | 877 | void KABCore::copyContacts() |
877 | { | 878 | { |
878 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 879 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
879 | 880 | ||
880 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 881 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
881 | 882 | ||
882 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 883 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
883 | 884 | ||
884 | QClipboard *cb = QApplication::clipboard(); | 885 | QClipboard *cb = QApplication::clipboard(); |
885 | cb->setText( clipText ); | 886 | cb->setText( clipText ); |
886 | } | 887 | } |
887 | 888 | ||
888 | void KABCore::cutContacts() | 889 | void KABCore::cutContacts() |
889 | { | 890 | { |
890 | QStringList uidList = mViewManager->selectedUids(); | 891 | QStringList uidList = mViewManager->selectedUids(); |
891 | 892 | ||
892 | //US if ( uidList.size() > 0 ) { | 893 | //US if ( uidList.size() > 0 ) { |
893 | if ( uidList.count() > 0 ) { | 894 | if ( uidList.count() > 0 ) { |
894 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 895 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
895 | UndoStack::instance()->push( command ); | 896 | UndoStack::instance()->push( command ); |
896 | RedoStack::instance()->clear(); | 897 | RedoStack::instance()->clear(); |
897 | 898 | ||
898 | setModified( true ); | 899 | setModified( true ); |
899 | } | 900 | } |
900 | } | 901 | } |
901 | 902 | ||
902 | void KABCore::pasteContacts() | 903 | void KABCore::pasteContacts() |
903 | { | 904 | { |
904 | QClipboard *cb = QApplication::clipboard(); | 905 | QClipboard *cb = QApplication::clipboard(); |
905 | 906 | ||
906 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 907 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
907 | 908 | ||
908 | pasteContacts( list ); | 909 | pasteContacts( list ); |
909 | } | 910 | } |
910 | 911 | ||
911 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 912 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
912 | { | 913 | { |
913 | KABC::Resource *resource = requestResource( this ); | 914 | KABC::Resource *resource = requestResource( this ); |
914 | KABC::Addressee::List::Iterator it; | 915 | KABC::Addressee::List::Iterator it; |
915 | for ( it = list.begin(); it != list.end(); ++it ) | 916 | for ( it = list.begin(); it != list.end(); ++it ) |
916 | (*it).setResource( resource ); | 917 | (*it).setResource( resource ); |
917 | 918 | ||
918 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 919 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
919 | UndoStack::instance()->push( command ); | 920 | UndoStack::instance()->push( command ); |
920 | RedoStack::instance()->clear(); | 921 | RedoStack::instance()->clear(); |
921 | 922 | ||
922 | setModified( true ); | 923 | setModified( true ); |
923 | } | 924 | } |
924 | 925 | ||
925 | void KABCore::setWhoAmI() | 926 | void KABCore::setWhoAmI() |
926 | { | 927 | { |
927 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 928 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
928 | 929 | ||
929 | if ( addrList.count() > 1 ) { | 930 | if ( addrList.count() > 1 ) { |
930 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 931 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
931 | return; | 932 | return; |
932 | } | 933 | } |
933 | 934 | ||
934 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 935 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
935 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | 936 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) |
936 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 937 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
937 | } | 938 | } |
938 | 939 | ||
939 | void KABCore::setCategories() | 940 | void KABCore::setCategories() |
940 | { | 941 | { |
941 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 942 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
942 | if ( !dlg.exec() ) | 943 | if ( !dlg.exec() ) |
943 | return; | 944 | return; |
944 | 945 | ||
945 | bool merge = false; | 946 | bool merge = false; |
946 | QString msg = i18n( "Merge with existing categories?" ); | 947 | QString msg = i18n( "Merge with existing categories?" ); |
947 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 948 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
948 | merge = true; | 949 | merge = true; |
949 | 950 | ||
950 | QStringList categories = dlg.selectedCategories(); | 951 | QStringList categories = dlg.selectedCategories(); |
951 | 952 | ||
952 | QStringList uids = mViewManager->selectedUids(); | 953 | QStringList uids = mViewManager->selectedUids(); |
953 | QStringList::Iterator it; | 954 | QStringList::Iterator it; |
954 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 955 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
955 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 956 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
956 | if ( !addr.isEmpty() ) { | 957 | if ( !addr.isEmpty() ) { |
957 | if ( !merge ) | 958 | if ( !merge ) |
958 | addr.setCategories( categories ); | 959 | addr.setCategories( categories ); |
959 | else { | 960 | else { |
960 | QStringList addrCategories = addr.categories(); | 961 | QStringList addrCategories = addr.categories(); |
961 | QStringList::Iterator catIt; | 962 | QStringList::Iterator catIt; |
962 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 963 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
963 | if ( !addrCategories.contains( *catIt ) ) | 964 | if ( !addrCategories.contains( *catIt ) ) |
964 | addrCategories.append( *catIt ); | 965 | addrCategories.append( *catIt ); |
965 | } | 966 | } |
966 | addr.setCategories( addrCategories ); | 967 | addr.setCategories( addrCategories ); |
967 | } | 968 | } |
968 | 969 | ||
969 | mAddressBook->insertAddressee( addr ); | 970 | mAddressBook->insertAddressee( addr ); |
970 | } | 971 | } |
971 | } | 972 | } |
972 | 973 | ||
973 | if ( uids.count() > 0 ) | 974 | if ( uids.count() > 0 ) |
974 | setModified( true ); | 975 | setModified( true ); |
975 | } | 976 | } |
976 | 977 | ||
977 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 978 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
978 | { | 979 | { |
979 | mIncSearchWidget->setFields( fields ); | 980 | mIncSearchWidget->setFields( fields ); |
980 | } | 981 | } |
981 | 982 | ||
982 | void KABCore::incrementalSearch( const QString& text ) | 983 | void KABCore::incrementalSearch( const QString& text ) |
983 | { | 984 | { |
984 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); | 985 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); |
985 | } | 986 | } |
986 | 987 | ||
987 | void KABCore::setModified() | 988 | void KABCore::setModified() |
988 | { | 989 | { |
989 | setModified( true ); | 990 | setModified( true ); |
990 | } | 991 | } |
991 | 992 | ||
992 | void KABCore::setModifiedWOrefresh() | 993 | void KABCore::setModifiedWOrefresh() |
993 | { | 994 | { |
994 | // qDebug("KABCore::setModifiedWOrefresh() "); | 995 | // qDebug("KABCore::setModifiedWOrefresh() "); |
995 | mModified = true; | 996 | mModified = true; |
996 | mActionSave->setEnabled( mModified ); | 997 | mActionSave->setEnabled( mModified ); |
997 | #ifdef DESKTOP_VERSION | 998 | #ifdef DESKTOP_VERSION |
998 | mDetails->refreshView(); | 999 | mDetails->refreshView(); |
999 | #endif | 1000 | #endif |
1000 | 1001 | ||
1001 | } | 1002 | } |
1002 | void KABCore::setModified( bool modified ) | 1003 | void KABCore::setModified( bool modified ) |
1003 | { | 1004 | { |
1004 | mModified = modified; | 1005 | mModified = modified; |
1005 | mActionSave->setEnabled( mModified ); | 1006 | mActionSave->setEnabled( mModified ); |
1006 | 1007 | ||
1007 | if ( modified ) | 1008 | if ( modified ) |
1008 | mJumpButtonBar->recreateButtons(); | 1009 | mJumpButtonBar->recreateButtons(); |
1009 | 1010 | ||
1010 | mViewManager->refreshView(); | 1011 | mViewManager->refreshView(); |
1011 | mDetails->refreshView(); | 1012 | mDetails->refreshView(); |
1012 | 1013 | ||
1013 | } | 1014 | } |
1014 | 1015 | ||
1015 | bool KABCore::modified() const | 1016 | bool KABCore::modified() const |
1016 | { | 1017 | { |
1017 | return mModified; | 1018 | return mModified; |
1018 | } | 1019 | } |
1019 | 1020 | ||
1020 | void KABCore::contactModified( const KABC::Addressee &addr ) | 1021 | void KABCore::contactModified( const KABC::Addressee &addr ) |
1021 | { | 1022 | { |
1022 | 1023 | ||
1023 | Command *command = 0; | 1024 | Command *command = 0; |
1024 | QString uid; | 1025 | QString uid; |
1025 | 1026 | ||
1026 | // check if it exists already | 1027 | // check if it exists already |
1027 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 1028 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
1028 | if ( origAddr.isEmpty() ) | 1029 | if ( origAddr.isEmpty() ) |
1029 | command = new PwNewCommand( mAddressBook, addr ); | 1030 | command = new PwNewCommand( mAddressBook, addr ); |
1030 | else { | 1031 | else { |
1031 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 1032 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
1032 | uid = addr.uid(); | 1033 | uid = addr.uid(); |
1033 | } | 1034 | } |
1034 | 1035 | ||
1035 | UndoStack::instance()->push( command ); | 1036 | UndoStack::instance()->push( command ); |
1036 | RedoStack::instance()->clear(); | 1037 | RedoStack::instance()->clear(); |
1037 | 1038 | ||
1038 | setModified( true ); | 1039 | setModified( true ); |
1039 | } | 1040 | } |
1040 | 1041 | ||
1041 | void KABCore::newContact() | 1042 | void KABCore::newContact() |
1042 | { | 1043 | { |
1043 | 1044 | ||
1044 | 1045 | ||
1045 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 1046 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
1046 | 1047 | ||
1047 | QPtrList<KRES::Resource> kresResources; | 1048 | QPtrList<KRES::Resource> kresResources; |
1048 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 1049 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
1049 | KABC::Resource *resource; | 1050 | KABC::Resource *resource; |
1050 | while ( ( resource = it.current() ) != 0 ) { | 1051 | while ( ( resource = it.current() ) != 0 ) { |
1051 | ++it; | 1052 | ++it; |
1052 | if ( !resource->readOnly() ) { | 1053 | if ( !resource->readOnly() ) { |
1053 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 1054 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
1054 | if ( res ) | 1055 | if ( res ) |
1055 | kresResources.append( res ); | 1056 | kresResources.append( res ); |
1056 | } | 1057 | } |
1057 | } | 1058 | } |
1058 | 1059 | ||
1059 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 1060 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
1060 | resource = static_cast<KABC::Resource*>( res ); | 1061 | resource = static_cast<KABC::Resource*>( res ); |
1061 | 1062 | ||
1062 | if ( resource ) { | 1063 | if ( resource ) { |
1063 | KABC::Addressee addr; | 1064 | KABC::Addressee addr; |
1064 | addr.setResource( resource ); | 1065 | addr.setResource( resource ); |
1065 | mEditorDialog->setAddressee( addr ); | 1066 | mEditorDialog->setAddressee( addr ); |
1066 | KApplication::execDialog ( mEditorDialog ); | 1067 | KApplication::execDialog ( mEditorDialog ); |
1067 | 1068 | ||
1068 | } else | 1069 | } else |
1069 | return; | 1070 | return; |
1070 | 1071 | ||
1071 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 1072 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
1072 | 1073 | ||
1073 | 1074 | ||
1074 | } | 1075 | } |
1075 | 1076 | ||
1076 | void KABCore::addEmail( QString aStr ) | 1077 | void KABCore::addEmail( QString aStr ) |
1077 | { | 1078 | { |
1078 | #ifndef KAB_EMBEDDED | 1079 | #ifndef KAB_EMBEDDED |
1079 | QString fullName, email; | 1080 | QString fullName, email; |
1080 | 1081 | ||
1081 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 1082 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
1082 | 1083 | ||
1083 | // Try to lookup the addressee matching the email address | 1084 | // Try to lookup the addressee matching the email address |
1084 | bool found = false; | 1085 | bool found = false; |
1085 | QStringList emailList; | 1086 | QStringList emailList; |
1086 | KABC::AddressBook::Iterator it; | 1087 | KABC::AddressBook::Iterator it; |
1087 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 1088 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
1088 | emailList = (*it).emails(); | 1089 | emailList = (*it).emails(); |
1089 | if ( emailList.contains( email ) > 0 ) { | 1090 | if ( emailList.contains( email ) > 0 ) { |
1090 | found = true; | 1091 | found = true; |
1091 | (*it).setNameFromString( fullName ); | 1092 | (*it).setNameFromString( fullName ); |
1092 | editContact( (*it).uid() ); | 1093 | editContact( (*it).uid() ); |
1093 | } | 1094 | } |
1094 | } | 1095 | } |
1095 | 1096 | ||
1096 | if ( !found ) { | 1097 | if ( !found ) { |
1097 | KABC::Addressee addr; | 1098 | KABC::Addressee addr; |
1098 | addr.setNameFromString( fullName ); | 1099 | addr.setNameFromString( fullName ); |
1099 | addr.insertEmail( email, true ); | 1100 | addr.insertEmail( email, true ); |
1100 | 1101 | ||
1101 | mAddressBook->insertAddressee( addr ); | 1102 | mAddressBook->insertAddressee( addr ); |
1102 | mViewManager->refreshView( addr.uid() ); | 1103 | mViewManager->refreshView( addr.uid() ); |
1103 | editContact( addr.uid() ); | 1104 | editContact( addr.uid() ); |
1104 | } | 1105 | } |
1105 | #else //KAB_EMBEDDED | 1106 | #else //KAB_EMBEDDED |
1106 | qDebug("KABCore::addEmail finsih method"); | 1107 | qDebug("KABCore::addEmail finsih method"); |
1107 | #endif //KAB_EMBEDDED | 1108 | #endif //KAB_EMBEDDED |
1108 | } | 1109 | } |
1109 | 1110 | ||
1110 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 1111 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
1111 | { | 1112 | { |
1112 | mXXPortManager->importVCard( url, showPreview ); | 1113 | mXXPortManager->importVCard( url, showPreview ); |
1113 | } | 1114 | } |
1114 | void KABCore::importFromOL() | 1115 | void KABCore::importFromOL() |
1115 | { | 1116 | { |
1116 | #ifdef _WIN32_ | 1117 | #ifdef _WIN32_ |
1117 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | 1118 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); |
1118 | idgl->exec(); | 1119 | idgl->exec(); |
1119 | KABC::Addressee::List list = idgl->getAddressList(); | 1120 | KABC::Addressee::List list = idgl->getAddressList(); |
1120 | if ( list.count() > 0 ) { | 1121 | if ( list.count() > 0 ) { |
1121 | KABC::Addressee::List listNew; | 1122 | KABC::Addressee::List listNew; |
1122 | KABC::Addressee::List listExisting; | 1123 | KABC::Addressee::List listExisting; |
1123 | KABC::Addressee::List::Iterator it; | 1124 | KABC::Addressee::List::Iterator it; |
1124 | KABC::AddressBook::Iterator iter; | 1125 | KABC::AddressBook::Iterator iter; |
1125 | for ( it = list.begin(); it != list.end(); ++it ) { | 1126 | for ( it = list.begin(); it != list.end(); ++it ) { |
1126 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) | 1127 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) |
1127 | listNew.append( (*it) ); | 1128 | listNew.append( (*it) ); |
1128 | else | 1129 | else |
1129 | listExisting.append( (*it) ); | 1130 | listExisting.append( (*it) ); |
1130 | } | 1131 | } |
1131 | if ( listExisting.count() > 0 ) | 1132 | if ( listExisting.count() > 0 ) |
1132 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); | 1133 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); |
1133 | if ( listNew.count() > 0 ) { | 1134 | if ( listNew.count() > 0 ) { |
1134 | pasteWithNewUid = false; | 1135 | pasteWithNewUid = false; |
1135 | pasteContacts( listNew ); | 1136 | pasteContacts( listNew ); |
1136 | pasteWithNewUid = true; | 1137 | pasteWithNewUid = true; |
1137 | } | 1138 | } |
1138 | } | 1139 | } |
1139 | delete idgl; | 1140 | delete idgl; |
1140 | #endif | 1141 | #endif |
1141 | } | 1142 | } |
1142 | 1143 | ||
1143 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1144 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
1144 | { | 1145 | { |
1145 | mXXPortManager->importVCard( vCard, showPreview ); | 1146 | mXXPortManager->importVCard( vCard, showPreview ); |
1146 | } | 1147 | } |
1147 | 1148 | ||
1148 | //US added a second method without defaultparameter | 1149 | //US added a second method without defaultparameter |
1149 | void KABCore::editContact2() { | 1150 | void KABCore::editContact2() { |
1150 | editContact( QString::null ); | 1151 | editContact( QString::null ); |
1151 | } | 1152 | } |
1152 | 1153 | ||
1153 | void KABCore::editContact( const QString &uid ) | 1154 | void KABCore::editContact( const QString &uid ) |
1154 | { | 1155 | { |
1155 | 1156 | ||
1156 | if ( mExtensionManager->isQuickEditVisible() ) | 1157 | if ( mExtensionManager->isQuickEditVisible() ) |
1157 | return; | 1158 | return; |
1158 | 1159 | ||
1159 | // First, locate the contact entry | 1160 | // First, locate the contact entry |
1160 | QString localUID = uid; | 1161 | QString localUID = uid; |
1161 | if ( localUID.isNull() ) { | 1162 | if ( localUID.isNull() ) { |
1162 | QStringList uidList = mViewManager->selectedUids(); | 1163 | QStringList uidList = mViewManager->selectedUids(); |
1163 | if ( uidList.count() > 0 ) | 1164 | if ( uidList.count() > 0 ) |
1164 | localUID = *( uidList.at( 0 ) ); | 1165 | localUID = *( uidList.at( 0 ) ); |
1165 | } | 1166 | } |
1166 | 1167 | ||
1167 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 1168 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
1168 | if ( !addr.isEmpty() ) { | 1169 | if ( !addr.isEmpty() ) { |
1169 | mEditorDialog->setAddressee( addr ); | 1170 | mEditorDialog->setAddressee( addr ); |
1170 | KApplication::execDialog ( mEditorDialog ); | 1171 | KApplication::execDialog ( mEditorDialog ); |
1171 | } | 1172 | } |
1172 | } | 1173 | } |
1173 | 1174 | ||
1174 | /** | 1175 | /** |
1175 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 1176 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
1176 | the method will try to find a selected addressee in the view. | 1177 | the method will try to find a selected addressee in the view. |
1177 | */ | 1178 | */ |
1178 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1179 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) |
1179 | { | 1180 | { |
1180 | if ( mMultipleViewsAtOnce ) | 1181 | if ( mMultipleViewsAtOnce ) |
1181 | { | 1182 | { |
1182 | editContact( uid ); | 1183 | editContact( uid ); |
1183 | } | 1184 | } |
1184 | else | 1185 | else |
1185 | { | 1186 | { |
1186 | setDetailsVisible( true ); | 1187 | setDetailsVisible( true ); |
1187 | mActionDetails->setChecked(true); | 1188 | mActionDetails->setChecked(true); |
1188 | } | 1189 | } |
1189 | 1190 | ||
1190 | } | 1191 | } |
1191 | 1192 | ||
1192 | void KABCore::save() | 1193 | void KABCore::save() |
1193 | { | 1194 | { |
1194 | if (syncManager->blockSave()) | 1195 | if (syncManager->blockSave()) |
1195 | return; | 1196 | return; |
1196 | if ( !mModified ) | 1197 | if ( !mModified ) |
1197 | return; | 1198 | return; |
1198 | 1199 | ||
1199 | syncManager->setBlockSave(true); | 1200 | syncManager->setBlockSave(true); |
1200 | QString text = i18n( "There was an error while attempting to save\n the " | 1201 | QString text = i18n( "There was an error while attempting to save\n the " |
1201 | "address book. Please check that some \nother application is " | 1202 | "address book. Please check that some \nother application is " |
1202 | "not using it. " ); | 1203 | "not using it. " ); |
1203 | message(i18n("Saving addressbook ... ")); | 1204 | message(i18n("Saving addressbook ... ")); |
1204 | #ifndef KAB_EMBEDDED | 1205 | #ifndef KAB_EMBEDDED |
1205 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1206 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
1206 | if ( !b || !b->save() ) { | 1207 | if ( !b || !b->save() ) { |
1207 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 1208 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
1208 | } | 1209 | } |
1209 | #else //KAB_EMBEDDED | 1210 | #else //KAB_EMBEDDED |
1210 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 1211 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
1211 | if ( !b || !b->save() ) { | 1212 | if ( !b || !b->save() ) { |
1212 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 1213 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
1213 | } | 1214 | } |
1214 | #endif //KAB_EMBEDDED | 1215 | #endif //KAB_EMBEDDED |
1215 | 1216 | ||
1216 | message(i18n("Addressbook saved!")); | 1217 | message(i18n("Addressbook saved!")); |
1217 | setModified( false ); | 1218 | setModified( false ); |
1218 | syncManager->setBlockSave(false); | 1219 | syncManager->setBlockSave(false); |
1219 | } | 1220 | } |
1220 | 1221 | ||
1221 | 1222 | ||
1222 | void KABCore::undo() | 1223 | void KABCore::undo() |
1223 | { | 1224 | { |
1224 | UndoStack::instance()->undo(); | 1225 | UndoStack::instance()->undo(); |
1225 | 1226 | ||
1226 | // Refresh the view | 1227 | // Refresh the view |
1227 | mViewManager->refreshView(); | 1228 | mViewManager->refreshView(); |
1228 | } | 1229 | } |
1229 | 1230 | ||
1230 | void KABCore::redo() | 1231 | void KABCore::redo() |
1231 | { | 1232 | { |
1232 | RedoStack::instance()->redo(); | 1233 | RedoStack::instance()->redo(); |
1233 | 1234 | ||
1234 | // Refresh the view | 1235 | // Refresh the view |
1235 | mViewManager->refreshView(); | 1236 | mViewManager->refreshView(); |
1236 | } | 1237 | } |
1237 | 1238 | ||
1238 | void KABCore::setJumpButtonBarVisible( bool visible ) | 1239 | void KABCore::setJumpButtonBarVisible( bool visible ) |
1239 | { | 1240 | { |
1240 | if (mMultipleViewsAtOnce) | 1241 | if (mMultipleViewsAtOnce) |
1241 | { | 1242 | { |
1242 | if ( visible ) | 1243 | if ( visible ) |
1243 | mJumpButtonBar->show(); | 1244 | mJumpButtonBar->show(); |
1244 | else | 1245 | else |
1245 | mJumpButtonBar->hide(); | 1246 | mJumpButtonBar->hide(); |
1246 | } | 1247 | } |
1247 | else | 1248 | else |
1248 | { | 1249 | { |
1249 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" | 1250 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" |
1250 | if (mViewManager->isVisible()) | 1251 | if (mViewManager->isVisible()) |
1251 | { | 1252 | { |
1252 | if ( visible ) | 1253 | if ( visible ) |
1253 | mJumpButtonBar->show(); | 1254 | mJumpButtonBar->show(); |
1254 | else | 1255 | else |
1255 | mJumpButtonBar->hide(); | 1256 | mJumpButtonBar->hide(); |
1256 | } | 1257 | } |
1257 | else | 1258 | else |
1258 | { | 1259 | { |
1259 | mJumpButtonBar->hide(); | 1260 | mJumpButtonBar->hide(); |
1260 | } | 1261 | } |
1261 | } | 1262 | } |
1262 | } | 1263 | } |
1263 | 1264 | ||
1264 | 1265 | ||
1265 | void KABCore::setDetailsToState() | 1266 | void KABCore::setDetailsToState() |
1266 | { | 1267 | { |
1267 | setDetailsVisible( mActionDetails->isChecked() ); | 1268 | setDetailsVisible( mActionDetails->isChecked() ); |
1268 | } | 1269 | } |
1269 | 1270 | ||
1270 | 1271 | ||
1271 | 1272 | ||
1272 | void KABCore::setDetailsVisible( bool visible ) | 1273 | void KABCore::setDetailsVisible( bool visible ) |
1273 | { | 1274 | { |
1274 | if (visible && mDetails->isHidden()) | 1275 | if (visible && mDetails->isHidden()) |
1275 | { | 1276 | { |
1276 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1277 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1277 | if ( addrList.count() > 0 ) | 1278 | if ( addrList.count() > 0 ) |
1278 | mDetails->setAddressee( addrList[ 0 ] ); | 1279 | mDetails->setAddressee( addrList[ 0 ] ); |
1279 | } | 1280 | } |
1280 | 1281 | ||
1281 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between | 1282 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between |
1282 | // the listview and the detailview. We do that by changing the splitbar size. | 1283 | // the listview and the detailview. We do that by changing the splitbar size. |
1283 | if (mMultipleViewsAtOnce) | 1284 | if (mMultipleViewsAtOnce) |
1284 | { | 1285 | { |
1285 | if ( visible ) | 1286 | if ( visible ) |
1286 | mDetails->show(); | 1287 | mDetails->show(); |
1287 | else | 1288 | else |
1288 | mDetails->hide(); | 1289 | mDetails->hide(); |
1289 | } | 1290 | } |
1290 | else | 1291 | else |
1291 | { | 1292 | { |
1292 | if ( visible ) { | 1293 | if ( visible ) { |
1293 | mViewManager->hide(); | 1294 | mViewManager->hide(); |
1294 | mDetails->show(); | 1295 | mDetails->show(); |
1295 | } | 1296 | } |
1296 | else { | 1297 | else { |
1297 | mViewManager->show(); | 1298 | mViewManager->show(); |
1298 | mDetails->hide(); | 1299 | mDetails->hide(); |
1299 | } | 1300 | } |
1300 | setJumpButtonBarVisible( !visible ); | 1301 | setJumpButtonBarVisible( !visible ); |
1301 | } | 1302 | } |
1302 | 1303 | ||
1303 | } | 1304 | } |
1304 | 1305 | ||
1305 | void KABCore::extensionChanged( int id ) | 1306 | void KABCore::extensionChanged( int id ) |
1306 | { | 1307 | { |
1307 | //change the details view only for non desktop systems | 1308 | //change the details view only for non desktop systems |
1308 | #ifndef DESKTOP_VERSION | 1309 | #ifndef DESKTOP_VERSION |
1309 | 1310 | ||
1310 | if (id == 0) | 1311 | if (id == 0) |
1311 | { | 1312 | { |
1312 | //the user disabled the extension. | 1313 | //the user disabled the extension. |
1313 | 1314 | ||
1314 | if (mMultipleViewsAtOnce) | 1315 | if (mMultipleViewsAtOnce) |
1315 | { // enable detailsview again | 1316 | { // enable detailsview again |
1316 | setDetailsVisible( true ); | 1317 | setDetailsVisible( true ); |
1317 | mActionDetails->setChecked( true ); | 1318 | mActionDetails->setChecked( true ); |
1318 | } | 1319 | } |
1319 | else | 1320 | else |
1320 | { //go back to the listview | 1321 | { //go back to the listview |
1321 | setDetailsVisible( false ); | 1322 | setDetailsVisible( false ); |
1322 | mActionDetails->setChecked( false ); | 1323 | mActionDetails->setChecked( false ); |
1323 | mActionDetails->setEnabled(true); | 1324 | mActionDetails->setEnabled(true); |
1324 | } | 1325 | } |
1325 | 1326 | ||
1326 | } | 1327 | } |
1327 | else | 1328 | else |
1328 | { | 1329 | { |
1329 | //the user enabled the extension. | 1330 | //the user enabled the extension. |
1330 | setDetailsVisible( false ); | 1331 | setDetailsVisible( false ); |
1331 | mActionDetails->setChecked( false ); | 1332 | mActionDetails->setChecked( false ); |
1332 | 1333 | ||
1333 | if (!mMultipleViewsAtOnce) | 1334 | if (!mMultipleViewsAtOnce) |
1334 | { | 1335 | { |
1335 | mActionDetails->setEnabled(false); | 1336 | mActionDetails->setEnabled(false); |
1336 | } | 1337 | } |
1337 | 1338 | ||
1338 | mExtensionManager->setSelectionChanged(); | 1339 | mExtensionManager->setSelectionChanged(); |
1339 | 1340 | ||
1340 | } | 1341 | } |
1341 | 1342 | ||
1342 | #endif// DESKTOP_VERSION | 1343 | #endif// DESKTOP_VERSION |
1343 | 1344 | ||
1344 | } | 1345 | } |
1345 | 1346 | ||
1346 | 1347 | ||
1347 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1348 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1348 | { | 1349 | { |
1349 | 1350 | ||
1350 | if ( list.count() != 0 ) { | 1351 | if ( list.count() != 0 ) { |
1351 | KABC::Addressee::List::ConstIterator it; | 1352 | KABC::Addressee::List::ConstIterator it; |
1352 | for ( it = list.begin(); it != list.end(); ++it ) | 1353 | for ( it = list.begin(); it != list.end(); ++it ) |
1353 | mAddressBook->insertAddressee( *it ); | 1354 | mAddressBook->insertAddressee( *it ); |
1354 | if ( list.count() > 1 ) | 1355 | if ( list.count() > 1 ) |
1355 | setModified(); | 1356 | setModified(); |
1356 | else | 1357 | else |
1357 | setModifiedWOrefresh(); | 1358 | setModifiedWOrefresh(); |
1358 | } | 1359 | } |
1359 | if ( list.count() == 0 ) | 1360 | if ( list.count() == 0 ) |
1360 | mViewManager->refreshView(); | 1361 | mViewManager->refreshView(); |
1361 | else | 1362 | else |
1362 | mViewManager->refreshView( list[ 0 ].uid() ); | 1363 | mViewManager->refreshView( list[ 0 ].uid() ); |
1363 | 1364 | ||
1364 | 1365 | ||
1365 | 1366 | ||
1366 | } | 1367 | } |
1367 | 1368 | ||
1368 | QString KABCore::getNameByPhone( const QString &phone ) | 1369 | QString KABCore::getNameByPhone( const QString &phone ) |
1369 | { | 1370 | { |
1370 | #ifndef KAB_EMBEDDED | 1371 | #ifndef KAB_EMBEDDED |
1371 | QRegExp r( "[/*/-/ ]" ); | 1372 | QRegExp r( "[/*/-/ ]" ); |
1372 | QString localPhone( phone ); | 1373 | QString localPhone( phone ); |
1373 | 1374 | ||
1374 | bool found = false; | 1375 | bool found = false; |
1375 | QString ownerName = ""; | 1376 | QString ownerName = ""; |
1376 | KABC::AddressBook::Iterator iter; | 1377 | KABC::AddressBook::Iterator iter; |
1377 | KABC::PhoneNumber::List::Iterator phoneIter; | 1378 | KABC::PhoneNumber::List::Iterator phoneIter; |
1378 | KABC::PhoneNumber::List phoneList; | 1379 | KABC::PhoneNumber::List phoneList; |
1379 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1380 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
1380 | phoneList = (*iter).phoneNumbers(); | 1381 | phoneList = (*iter).phoneNumbers(); |
1381 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1382 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
1382 | ++phoneIter) { | 1383 | ++phoneIter) { |
1383 | // Get rid of separator chars so just the numbers are compared. | 1384 | // Get rid of separator chars so just the numbers are compared. |
1384 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1385 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
1385 | ownerName = (*iter).formattedName(); | 1386 | ownerName = (*iter).formattedName(); |
1386 | found = true; | 1387 | found = true; |
1387 | } | 1388 | } |
1388 | } | 1389 | } |
1389 | } | 1390 | } |
1390 | 1391 | ||
1391 | return ownerName; | 1392 | return ownerName; |
1392 | #else //KAB_EMBEDDED | 1393 | #else //KAB_EMBEDDED |
1393 | qDebug("KABCore::getNameByPhone finsih method"); | 1394 | qDebug("KABCore::getNameByPhone finsih method"); |
1394 | return ""; | 1395 | return ""; |
1395 | #endif //KAB_EMBEDDED | 1396 | #endif //KAB_EMBEDDED |
1396 | 1397 | ||
1397 | } | 1398 | } |
1398 | 1399 | ||
1399 | void KABCore::openConfigDialog() | 1400 | void KABCore::openConfigDialog() |
1400 | { | 1401 | { |
1401 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 1402 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
1402 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 1403 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
1403 | ConfigureDialog->addModule(kabcfg ); | 1404 | ConfigureDialog->addModule(kabcfg ); |
1404 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 1405 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
1405 | ConfigureDialog->addModule(kdelibcfg ); | 1406 | ConfigureDialog->addModule(kdelibcfg ); |
1406 | 1407 | ||
1407 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1408 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1408 | this, SLOT( configurationChanged() ) ); | 1409 | this, SLOT( configurationChanged() ) ); |
1409 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1410 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
1410 | this, SLOT( configurationChanged() ) ); | 1411 | this, SLOT( configurationChanged() ) ); |
1411 | saveSettings(); | 1412 | saveSettings(); |
1412 | #ifndef DESKTOP_VERSION | 1413 | #ifndef DESKTOP_VERSION |
1413 | ConfigureDialog->showMaximized(); | 1414 | ConfigureDialog->showMaximized(); |
1414 | #endif | 1415 | #endif |
1415 | if ( ConfigureDialog->exec() ) | 1416 | if ( ConfigureDialog->exec() ) |
1416 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 1417 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
1417 | delete ConfigureDialog; | 1418 | delete ConfigureDialog; |
1418 | } | 1419 | } |
1419 | 1420 | ||
1420 | void KABCore::openLDAPDialog() | 1421 | void KABCore::openLDAPDialog() |
1421 | { | 1422 | { |
1422 | #ifndef KAB_EMBEDDED | 1423 | #ifndef KAB_EMBEDDED |
1423 | if ( !mLdapSearchDialog ) { | 1424 | if ( !mLdapSearchDialog ) { |
1424 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1425 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1425 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1426 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1426 | SLOT( refreshView() ) ); | 1427 | SLOT( refreshView() ) ); |
1427 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1428 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1428 | SLOT( setModified() ) ); | 1429 | SLOT( setModified() ) ); |
1429 | } else | 1430 | } else |
1430 | mLdapSearchDialog->restoreSettings(); | 1431 | mLdapSearchDialog->restoreSettings(); |
1431 | 1432 | ||
1432 | if ( mLdapSearchDialog->isOK() ) | 1433 | if ( mLdapSearchDialog->isOK() ) |
1433 | mLdapSearchDialog->exec(); | 1434 | mLdapSearchDialog->exec(); |
1434 | #else //KAB_EMBEDDED | 1435 | #else //KAB_EMBEDDED |
1435 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1436 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1436 | #endif //KAB_EMBEDDED | 1437 | #endif //KAB_EMBEDDED |
1437 | } | 1438 | } |
1438 | 1439 | ||
1439 | void KABCore::print() | 1440 | void KABCore::print() |
1440 | { | 1441 | { |
1441 | #ifndef KAB_EMBEDDED | 1442 | #ifndef KAB_EMBEDDED |
1442 | KPrinter printer; | 1443 | KPrinter printer; |
1443 | if ( !printer.setup( this ) ) | 1444 | if ( !printer.setup( this ) ) |
1444 | return; | 1445 | return; |
1445 | 1446 | ||
1446 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1447 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1447 | mViewManager->selectedUids(), this ); | 1448 | mViewManager->selectedUids(), this ); |
1448 | 1449 | ||
1449 | wizard.exec(); | 1450 | wizard.exec(); |
1450 | #else //KAB_EMBEDDED | 1451 | #else //KAB_EMBEDDED |
1451 | qDebug("KABCore::print() finsih method"); | 1452 | qDebug("KABCore::print() finsih method"); |
1452 | #endif //KAB_EMBEDDED | 1453 | #endif //KAB_EMBEDDED |
1453 | 1454 | ||
1454 | } | 1455 | } |
1455 | 1456 | ||
1456 | 1457 | ||
1457 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1458 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1458 | { | 1459 | { |
1459 | if ( mGUIClient ) | 1460 | if ( mGUIClient ) |
1460 | mGUIClient->insertChildClient( client ); | 1461 | mGUIClient->insertChildClient( client ); |
1461 | else | 1462 | else |
1462 | KMessageBox::error( this, "no KXMLGUICLient"); | 1463 | KMessageBox::error( this, "no KXMLGUICLient"); |
1463 | } | 1464 | } |
1464 | 1465 | ||
1465 | 1466 | ||
1466 | void KABCore::configurationChanged() | 1467 | void KABCore::configurationChanged() |
1467 | { | 1468 | { |
1468 | mExtensionManager->reconfigure(); | 1469 | mExtensionManager->reconfigure(); |
1469 | } | 1470 | } |
1470 | 1471 | ||
1471 | void KABCore::addressBookChanged() | 1472 | void KABCore::addressBookChanged() |
1472 | { | 1473 | { |
1473 | /*US | 1474 | /*US |
1474 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1475 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1475 | while ( it.current() ) { | 1476 | while ( it.current() ) { |
1476 | if ( it.current()->dirty() ) { | 1477 | if ( it.current()->dirty() ) { |
1477 | QString text = i18n( "Data has been changed externally. Unsaved " | 1478 | QString text = i18n( "Data has been changed externally. Unsaved " |
1478 | "changes will be lost." ); | 1479 | "changes will be lost." ); |
1479 | KMessageBox::information( this, text ); | 1480 | KMessageBox::information( this, text ); |
1480 | } | 1481 | } |
1481 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1482 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1482 | ++it; | 1483 | ++it; |
1483 | } | 1484 | } |
1484 | */ | 1485 | */ |
1485 | if (mEditorDialog) | 1486 | if (mEditorDialog) |
1486 | { | 1487 | { |
1487 | if (mEditorDialog->dirty()) | 1488 | if (mEditorDialog->dirty()) |
1488 | { | 1489 | { |
1489 | QString text = i18n( "Data has been changed externally. Unsaved " | 1490 | QString text = i18n( "Data has been changed externally. Unsaved " |
1490 | "changes will be lost." ); | 1491 | "changes will be lost." ); |
1491 | KMessageBox::information( this, text ); | 1492 | KMessageBox::information( this, text ); |
1492 | } | 1493 | } |
1493 | QString currentuid = mEditorDialog->addressee().uid(); | 1494 | QString currentuid = mEditorDialog->addressee().uid(); |
1494 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); | 1495 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); |
1495 | } | 1496 | } |
1496 | mViewManager->refreshView(); | 1497 | mViewManager->refreshView(); |
1497 | // mDetails->refreshView(); | 1498 | // mDetails->refreshView(); |
1498 | 1499 | ||
1499 | 1500 | ||
1500 | } | 1501 | } |
1501 | 1502 | ||
1502 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1503 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1503 | const char *name ) | 1504 | const char *name ) |
1504 | { | 1505 | { |
1505 | 1506 | ||
1506 | if ( mEditorDialog == 0 ) { | 1507 | if ( mEditorDialog == 0 ) { |
1507 | mEditorDialog = new AddresseeEditorDialog( this, parent, | 1508 | mEditorDialog = new AddresseeEditorDialog( this, parent, |
1508 | name ? name : "editorDialog" ); | 1509 | name ? name : "editorDialog" ); |
1509 | 1510 | ||
1510 | 1511 | ||
1511 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1512 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1512 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1513 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1513 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), | 1514 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), |
1514 | // SLOT( slotEditorDestroyed( const QString& ) ) ; | 1515 | // SLOT( slotEditorDestroyed( const QString& ) ) ; |
1515 | } | 1516 | } |
1516 | 1517 | ||
1517 | return mEditorDialog; | 1518 | return mEditorDialog; |
1518 | } | 1519 | } |
1519 | 1520 | ||
1520 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1521 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1521 | { | 1522 | { |
1522 | //mEditorDict.remove( uid ); | 1523 | //mEditorDict.remove( uid ); |
1523 | } | 1524 | } |
1524 | 1525 | ||
1525 | void KABCore::initGUI() | 1526 | void KABCore::initGUI() |
1526 | { | 1527 | { |
1527 | #ifndef KAB_EMBEDDED | 1528 | #ifndef KAB_EMBEDDED |
1528 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1529 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1529 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1530 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1530 | 1531 | ||
1531 | mExtensionBarSplitter = new QSplitter( this ); | 1532 | mExtensionBarSplitter = new QSplitter( this ); |
1532 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1533 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1533 | 1534 | ||
1534 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1535 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1535 | 1536 | ||
1536 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1537 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1537 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1538 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1538 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1539 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1539 | SLOT( incrementalSearch( const QString& ) ) ); | 1540 | SLOT( incrementalSearch( const QString& ) ) ); |
1540 | 1541 | ||
1541 | mViewManager = new ViewManager( this, viewSpace ); | 1542 | mViewManager = new ViewManager( this, viewSpace ); |
1542 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1543 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1543 | 1544 | ||
1544 | mDetails = new ViewContainer( mDetailsSplitter ); | 1545 | mDetails = new ViewContainer( mDetailsSplitter ); |
1545 | 1546 | ||
1546 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1547 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1547 | 1548 | ||
1548 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1549 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1549 | 1550 | ||
1550 | topLayout->addWidget( mExtensionBarSplitter ); | 1551 | topLayout->addWidget( mExtensionBarSplitter ); |
1551 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1552 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1552 | topLayout->addWidget( mJumpButtonBar ); | 1553 | topLayout->addWidget( mJumpButtonBar ); |
1553 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1554 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1554 | 1555 | ||
1555 | mXXPortManager = new XXPortManager( this, this ); | 1556 | mXXPortManager = new XXPortManager( this, this ); |
1556 | 1557 | ||
1557 | #else //KAB_EMBEDDED | 1558 | #else //KAB_EMBEDDED |
1558 | //US initialize viewMenu before settingup viewmanager. | 1559 | //US initialize viewMenu before settingup viewmanager. |
1559 | // Viewmanager needs this menu to plugin submenues. | 1560 | // Viewmanager needs this menu to plugin submenues. |
1560 | viewMenu = new QPopupMenu( this ); | 1561 | viewMenu = new QPopupMenu( this ); |
1561 | settingsMenu = new QPopupMenu( this ); | 1562 | settingsMenu = new QPopupMenu( this ); |
1562 | //filterMenu = new QPopupMenu( this ); | 1563 | //filterMenu = new QPopupMenu( this ); |
1563 | ImportMenu = new QPopupMenu( this ); | 1564 | ImportMenu = new QPopupMenu( this ); |
1564 | ExportMenu = new QPopupMenu( this ); | 1565 | ExportMenu = new QPopupMenu( this ); |
1565 | syncMenu = new QPopupMenu( this ); | 1566 | syncMenu = new QPopupMenu( this ); |
1566 | changeMenu= new QPopupMenu( this ); | 1567 | changeMenu= new QPopupMenu( this ); |
1567 | 1568 | ||
1568 | //US since we have no splitter for the embedded system, setup | 1569 | //US since we have no splitter for the embedded system, setup |
1569 | // a layout with two frames. One left and one right. | 1570 | // a layout with two frames. One left and one right. |
1570 | 1571 | ||
1571 | QBoxLayout *topLayout; | 1572 | QBoxLayout *topLayout; |
1572 | 1573 | ||
1573 | // = new QHBoxLayout( this ); | 1574 | // = new QHBoxLayout( this ); |
1574 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1575 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1575 | 1576 | ||
1576 | // QWidget *mainBox = new QWidget( this ); | 1577 | // QWidget *mainBox = new QWidget( this ); |
1577 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1578 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1578 | 1579 | ||
1579 | #ifdef DESKTOP_VERSION | 1580 | #ifdef DESKTOP_VERSION |
1580 | topLayout = new QHBoxLayout( this ); | 1581 | topLayout = new QHBoxLayout( this ); |
1581 | 1582 | ||
1582 | 1583 | ||
1583 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1584 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1584 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1585 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1585 | 1586 | ||
1586 | topLayout->addWidget(mMiniSplitter ); | 1587 | topLayout->addWidget(mMiniSplitter ); |
1587 | 1588 | ||
1588 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1589 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1589 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1590 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1590 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1591 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1591 | mDetails = new ViewContainer( mMiniSplitter ); | 1592 | mDetails = new ViewContainer( mMiniSplitter ); |
1592 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1593 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1593 | #else | 1594 | #else |
1594 | if ( QApplication::desktop()->width() > 480 ) { | 1595 | if ( QApplication::desktop()->width() > 480 ) { |
1595 | topLayout = new QHBoxLayout( this ); | 1596 | topLayout = new QHBoxLayout( this ); |
1596 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1597 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1597 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1598 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1598 | } else { | 1599 | } else { |
1599 | 1600 | ||
1600 | topLayout = new QHBoxLayout( this ); | 1601 | topLayout = new QHBoxLayout( this ); |
1601 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1602 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1602 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1603 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1603 | } | 1604 | } |
1604 | 1605 | ||
1605 | topLayout->addWidget(mMiniSplitter ); | 1606 | topLayout->addWidget(mMiniSplitter ); |
1606 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1607 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1607 | mDetails = new ViewContainer( mMiniSplitter ); | 1608 | mDetails = new ViewContainer( mMiniSplitter ); |
1608 | 1609 | ||
1609 | 1610 | ||
1610 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1611 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1611 | #endif | 1612 | #endif |
1612 | //eh->hide(); | 1613 | //eh->hide(); |
1613 | // topLayout->addWidget(mExtensionManager ); | 1614 | // topLayout->addWidget(mExtensionManager ); |
1614 | 1615 | ||
1615 | 1616 | ||
1616 | /*US | 1617 | /*US |
1617 | #ifndef KAB_NOSPLITTER | 1618 | #ifndef KAB_NOSPLITTER |
1618 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1619 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1619 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1620 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1620 | topLayout->setSpacing( 10 ); | 1621 | topLayout->setSpacing( 10 ); |
1621 | 1622 | ||
1622 | mDetailsSplitter = new QSplitter( this ); | 1623 | mDetailsSplitter = new QSplitter( this ); |
1623 | 1624 | ||
1624 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1625 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1625 | 1626 | ||
1626 | mViewManager = new ViewManager( this, viewSpace ); | 1627 | mViewManager = new ViewManager( this, viewSpace ); |
1627 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1628 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1628 | 1629 | ||
1629 | mDetails = new ViewContainer( mDetailsSplitter ); | 1630 | mDetails = new ViewContainer( mDetailsSplitter ); |
1630 | 1631 | ||
1631 | topLayout->addWidget( mDetailsSplitter ); | 1632 | topLayout->addWidget( mDetailsSplitter ); |
1632 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1633 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1633 | #else //KAB_NOSPLITTER | 1634 | #else //KAB_NOSPLITTER |
1634 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1635 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1635 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1636 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1636 | topLayout->setSpacing( 10 ); | 1637 | topLayout->setSpacing( 10 ); |
1637 | 1638 | ||
1638 | // mDetailsSplitter = new QSplitter( this ); | 1639 | // mDetailsSplitter = new QSplitter( this ); |
1639 | 1640 | ||
1640 | QVBox *viewSpace = new QVBox( this ); | 1641 | QVBox *viewSpace = new QVBox( this ); |
1641 | 1642 | ||
1642 | mViewManager = new ViewManager( this, viewSpace ); | 1643 | mViewManager = new ViewManager( this, viewSpace ); |
1643 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1644 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1644 | 1645 | ||
1645 | mDetails = new ViewContainer( this ); | 1646 | mDetails = new ViewContainer( this ); |
1646 | 1647 | ||
1647 | topLayout->addWidget( viewSpace ); | 1648 | topLayout->addWidget( viewSpace ); |
1648 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1649 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1649 | topLayout->addWidget( mDetails ); | 1650 | topLayout->addWidget( mDetails ); |
1650 | #endif //KAB_NOSPLITTER | 1651 | #endif //KAB_NOSPLITTER |
1651 | */ | 1652 | */ |
1652 | 1653 | ||
1653 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 1654 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
1654 | syncManager->setBlockSave(false); | 1655 | syncManager->setBlockSave(false); |
1655 | 1656 | ||
1656 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 1657 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
1657 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 1658 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
1658 | syncManager->setDefaultFileName( sentSyncFile()); | 1659 | syncManager->setDefaultFileName( sentSyncFile()); |
1659 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); | 1660 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); |
1660 | 1661 | ||
1661 | #endif //KAB_EMBEDDED | 1662 | #endif //KAB_EMBEDDED |
1662 | initActions(); | 1663 | initActions(); |
1663 | 1664 | ||
1664 | #ifdef KAB_EMBEDDED | 1665 | #ifdef KAB_EMBEDDED |
1665 | addActionsManually(); | 1666 | addActionsManually(); |
1666 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1667 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1667 | mXXPortManager = new XXPortManager( this, this ); | 1668 | mXXPortManager = new XXPortManager( this, this ); |
1668 | 1669 | ||
1669 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1670 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1670 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1671 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1671 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1672 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1672 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1673 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1673 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1674 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1674 | // mIncSearchWidget->hide(); | 1675 | // mIncSearchWidget->hide(); |
1675 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1676 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1676 | SLOT( incrementalSearch( const QString& ) ) ); | 1677 | SLOT( incrementalSearch( const QString& ) ) ); |
1677 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); | 1678 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); |
1678 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); | 1679 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); |
1679 | 1680 | ||
1680 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1681 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1681 | 1682 | ||
1682 | topLayout->addWidget( mJumpButtonBar ); | 1683 | topLayout->addWidget( mJumpButtonBar ); |
1683 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1684 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1684 | 1685 | ||
1685 | // mMainWindow->getIconToolBar()->raise(); | 1686 | // mMainWindow->getIconToolBar()->raise(); |
1686 | 1687 | ||
1687 | #endif //KAB_EMBEDDED | 1688 | #endif //KAB_EMBEDDED |
1688 | 1689 | ||
1689 | } | 1690 | } |
1690 | void KABCore::initActions() | 1691 | void KABCore::initActions() |
1691 | { | 1692 | { |
1692 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1693 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1693 | 1694 | ||
1694 | #ifndef KAB_EMBEDDED | 1695 | #ifndef KAB_EMBEDDED |
1695 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1696 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1696 | SLOT( clipboardDataChanged() ) ); | 1697 | SLOT( clipboardDataChanged() ) ); |
1697 | #endif //KAB_EMBEDDED | 1698 | #endif //KAB_EMBEDDED |
1698 | 1699 | ||
1699 | // file menu | 1700 | // file menu |
1700 | if ( mIsPart ) { | 1701 | if ( mIsPart ) { |
1701 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, | 1702 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, |
1702 | SLOT( sendMail() ), actionCollection(), | 1703 | SLOT( sendMail() ), actionCollection(), |
1703 | "kaddressbook_mail" ); | 1704 | "kaddressbook_mail" ); |
1704 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, | 1705 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, |
1705 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); | 1706 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); |
1706 | 1707 | ||
1707 | } else { | 1708 | } else { |
1708 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1709 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1709 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1710 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1710 | } | 1711 | } |
1711 | 1712 | ||
1712 | 1713 | ||
1713 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1714 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1714 | SLOT( save() ), actionCollection(), "file_sync" ); | 1715 | SLOT( save() ), actionCollection(), "file_sync" ); |
1715 | 1716 | ||
1716 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1717 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1717 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1718 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1718 | 1719 | ||
1719 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1720 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1720 | this, SLOT( mailVCard() ), | 1721 | this, SLOT( mailVCard() ), |
1721 | actionCollection(), "file_mail_vcard"); | 1722 | actionCollection(), "file_mail_vcard"); |
1722 | 1723 | ||
1723 | mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, | 1724 | mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, |
1724 | SLOT( export2phone() ), actionCollection(), | 1725 | SLOT( export2phone() ), actionCollection(), |
1725 | "kaddressbook_ex2phone" ); | 1726 | "kaddressbook_ex2phone" ); |
1726 | 1727 | ||
1727 | mActionBeamVCard = 0; | 1728 | mActionBeamVCard = 0; |
1728 | mActionBeam = 0; | 1729 | mActionBeam = 0; |
1729 | 1730 | ||
1730 | #ifndef DESKTOP_VERSION | 1731 | #ifndef DESKTOP_VERSION |
1731 | if ( Ir::supported() ) { | 1732 | if ( Ir::supported() ) { |
1732 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, | 1733 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, |
1733 | SLOT( beamVCard() ), actionCollection(), | 1734 | SLOT( beamVCard() ), actionCollection(), |
1734 | "kaddressbook_beam_vcard" ); | 1735 | "kaddressbook_beam_vcard" ); |
1735 | 1736 | ||
1736 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | 1737 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, |
1737 | SLOT( beamMySelf() ), actionCollection(), | 1738 | SLOT( beamMySelf() ), actionCollection(), |
1738 | "kaddressbook_beam_myself" ); | 1739 | "kaddressbook_beam_myself" ); |
1739 | } | 1740 | } |
1740 | #endif | 1741 | #endif |
1741 | 1742 | ||
1742 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1743 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1743 | this, SLOT( editContact2() ), | 1744 | this, SLOT( editContact2() ), |
1744 | actionCollection(), "file_properties" ); | 1745 | actionCollection(), "file_properties" ); |
1745 | 1746 | ||
1746 | #ifdef KAB_EMBEDDED | 1747 | #ifdef KAB_EMBEDDED |
1747 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1748 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1748 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1749 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1749 | mMainWindow, SLOT( exit() ), | 1750 | mMainWindow, SLOT( exit() ), |
1750 | actionCollection(), "quit" ); | 1751 | actionCollection(), "quit" ); |
1751 | #endif //KAB_EMBEDDED | 1752 | #endif //KAB_EMBEDDED |
1752 | 1753 | ||
1753 | // edit menu | 1754 | // edit menu |
1754 | if ( mIsPart ) { | 1755 | if ( mIsPart ) { |
1755 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1756 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
1756 | SLOT( copyContacts() ), actionCollection(), | 1757 | SLOT( copyContacts() ), actionCollection(), |
1757 | "kaddressbook_copy" ); | 1758 | "kaddressbook_copy" ); |
1758 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 1759 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
1759 | SLOT( cutContacts() ), actionCollection(), | 1760 | SLOT( cutContacts() ), actionCollection(), |
1760 | "kaddressbook_cut" ); | 1761 | "kaddressbook_cut" ); |
1761 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 1762 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
1762 | SLOT( pasteContacts() ), actionCollection(), | 1763 | SLOT( pasteContacts() ), actionCollection(), |
1763 | "kaddressbook_paste" ); | 1764 | "kaddressbook_paste" ); |
1764 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 1765 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
1765 | SLOT( selectAllContacts() ), actionCollection(), | 1766 | SLOT( selectAllContacts() ), actionCollection(), |
1766 | "kaddressbook_select_all" ); | 1767 | "kaddressbook_select_all" ); |
1767 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 1768 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
1768 | SLOT( undo() ), actionCollection(), | 1769 | SLOT( undo() ), actionCollection(), |
1769 | "kaddressbook_undo" ); | 1770 | "kaddressbook_undo" ); |
1770 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 1771 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
1771 | this, SLOT( redo() ), actionCollection(), | 1772 | this, SLOT( redo() ), actionCollection(), |
1772 | "kaddressbook_redo" ); | 1773 | "kaddressbook_redo" ); |
1773 | } else { | 1774 | } else { |
1774 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1775 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1775 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1776 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1776 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1777 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1777 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1778 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1778 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1779 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1779 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1780 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1780 | } | 1781 | } |
1781 | 1782 | ||
1782 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 1783 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
1783 | Key_Delete, this, SLOT( deleteContacts() ), | 1784 | Key_Delete, this, SLOT( deleteContacts() ), |
1784 | actionCollection(), "edit_delete" ); | 1785 | actionCollection(), "edit_delete" ); |
1785 | 1786 | ||
1786 | mActionUndo->setEnabled( false ); | 1787 | mActionUndo->setEnabled( false ); |
1787 | mActionRedo->setEnabled( false ); | 1788 | mActionRedo->setEnabled( false ); |
1788 | 1789 | ||
1789 | // settings menu | 1790 | // settings menu |
1790 | #ifdef KAB_EMBEDDED | 1791 | #ifdef KAB_EMBEDDED |
1791 | //US special menuentry to configure the addressbook resources. On KDE | 1792 | //US special menuentry to configure the addressbook resources. On KDE |
1792 | // you do that through the control center !!! | 1793 | // you do that through the control center !!! |
1793 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 1794 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
1794 | SLOT( configureResources() ), actionCollection(), | 1795 | SLOT( configureResources() ), actionCollection(), |
1795 | "kaddressbook_configure_resources" ); | 1796 | "kaddressbook_configure_resources" ); |
1796 | #endif //KAB_EMBEDDED | 1797 | #endif //KAB_EMBEDDED |
1797 | 1798 | ||
1798 | if ( mIsPart ) { | 1799 | if ( mIsPart ) { |
1799 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 1800 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
1800 | SLOT( openConfigDialog() ), actionCollection(), | 1801 | SLOT( openConfigDialog() ), actionCollection(), |
1801 | "kaddressbook_configure" ); | 1802 | "kaddressbook_configure" ); |
1802 | 1803 | ||
1803 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 1804 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
1804 | this, SLOT( configureKeyBindings() ), actionCollection(), | 1805 | this, SLOT( configureKeyBindings() ), actionCollection(), |
1805 | "kaddressbook_configure_shortcuts" ); | 1806 | "kaddressbook_configure_shortcuts" ); |
1806 | #ifdef KAB_EMBEDDED | 1807 | #ifdef KAB_EMBEDDED |
1807 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 1808 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
1808 | mActionConfigureToolbars->setEnabled( false ); | 1809 | mActionConfigureToolbars->setEnabled( false ); |
1809 | #endif //KAB_EMBEDDED | 1810 | #endif //KAB_EMBEDDED |
1810 | 1811 | ||
1811 | } else { | 1812 | } else { |
1812 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 1813 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
1813 | 1814 | ||
1814 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 1815 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
1815 | } | 1816 | } |
1816 | 1817 | ||
1817 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 1818 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
1818 | actionCollection(), "options_show_jump_bar" ); | 1819 | actionCollection(), "options_show_jump_bar" ); |
1819 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); | 1820 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); |
1820 | 1821 | ||
1821 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, | 1822 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
1822 | actionCollection(), "options_show_details" ); | 1823 | actionCollection(), "options_show_details" ); |
1823 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 1824 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
1824 | 1825 | ||
1825 | // misc | 1826 | // misc |
1826 | // only enable LDAP lookup if we can handle the protocol | 1827 | // only enable LDAP lookup if we can handle the protocol |
1827 | #ifndef KAB_EMBEDDED | 1828 | #ifndef KAB_EMBEDDED |
1828 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 1829 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
1829 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 1830 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
1830 | this, SLOT( openLDAPDialog() ), actionCollection(), | 1831 | this, SLOT( openLDAPDialog() ), actionCollection(), |
1831 | "ldap_lookup" ); | 1832 | "ldap_lookup" ); |
1832 | } | 1833 | } |
1833 | #else //KAB_EMBEDDED | 1834 | #else //KAB_EMBEDDED |
1834 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 1835 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
1835 | #endif //KAB_EMBEDDED | 1836 | #endif //KAB_EMBEDDED |
1836 | 1837 | ||
1837 | 1838 | ||
1838 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 1839 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
1839 | SLOT( setWhoAmI() ), actionCollection(), | 1840 | SLOT( setWhoAmI() ), actionCollection(), |
1840 | "set_personal" ); | 1841 | "set_personal" ); |
1841 | 1842 | ||
1842 | 1843 | ||
1843 | 1844 | ||
1844 | 1845 | ||
1845 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 1846 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
1846 | SLOT( setCategories() ), actionCollection(), | 1847 | SLOT( setCategories() ), actionCollection(), |
1847 | "edit_set_categories" ); | 1848 | "edit_set_categories" ); |
1848 | 1849 | ||
1849 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 1850 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
1850 | SLOT( removeVoice() ), actionCollection(), | 1851 | SLOT( removeVoice() ), actionCollection(), |
1851 | "remove_voice" ); | 1852 | "remove_voice" ); |
1852 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, | 1853 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, |
1853 | SLOT( importFromOL() ), actionCollection(), | 1854 | SLOT( importFromOL() ), actionCollection(), |
1854 | "import_OL" ); | 1855 | "import_OL" ); |
1855 | #ifdef KAB_EMBEDDED | 1856 | #ifdef KAB_EMBEDDED |
1856 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 1857 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
1857 | this, SLOT( showLicence() ), actionCollection(), | 1858 | this, SLOT( showLicence() ), actionCollection(), |
1858 | "licence_about_data" ); | 1859 | "licence_about_data" ); |
1859 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 1860 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
1860 | this, SLOT( faq() ), actionCollection(), | 1861 | this, SLOT( faq() ), actionCollection(), |
1861 | "faq_about_data" ); | 1862 | "faq_about_data" ); |
1862 | mActionWN = new KAction( i18n( "What's New?" ), 0, | 1863 | mActionWN = new KAction( i18n( "What's New?" ), 0, |
1863 | this, SLOT( whatsnew() ), actionCollection(), | 1864 | this, SLOT( whatsnew() ), actionCollection(), |
1864 | "wn" ); | 1865 | "wn" ); |
1865 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, | 1866 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, |
1866 | this, SLOT( synchowto() ), actionCollection(), | 1867 | this, SLOT( synchowto() ), actionCollection(), |
1867 | "sync" ); | 1868 | "sync" ); |
1868 | 1869 | ||
1869 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 1870 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
1870 | this, SLOT( createAboutData() ), actionCollection(), | 1871 | this, SLOT( createAboutData() ), actionCollection(), |
1871 | "kaddressbook_about_data" ); | 1872 | "kaddressbook_about_data" ); |
1872 | #endif //KAB_EMBEDDED | 1873 | #endif //KAB_EMBEDDED |