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