-rw-r--r-- | kaddressbook/kabcore.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 70ab6b7..7bf1a2f 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1,669 +1,675 @@ | |||
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 | #include "kabcore.h" | 24 | #include "kabcore.h" |
25 | 25 | ||
26 | #include <stdaddressbook.h> | 26 | #include <stdaddressbook.h> |
27 | #include <klocale.h> | 27 | #include <klocale.h> |
28 | 28 | ||
29 | #ifndef KAB_EMBEDDED | 29 | #ifndef KAB_EMBEDDED |
30 | #include <qclipboard.h> | 30 | #include <qclipboard.h> |
31 | #include <qdir.h> | 31 | #include <qdir.h> |
32 | #include <qfile.h> | 32 | #include <qfile.h> |
33 | #include <qapplicaton.h> | 33 | #include <qapplicaton.h> |
34 | #include <qlayout.h> | 34 | #include <qlayout.h> |
35 | #include <qregexp.h> | 35 | #include <qregexp.h> |
36 | #include <qvbox.h> | 36 | #include <qvbox.h> |
37 | #include <kabc/addresseelist.h> | 37 | #include <kabc/addresseelist.h> |
38 | #include <kabc/errorhandler.h> | 38 | #include <kabc/errorhandler.h> |
39 | #include <kabc/resource.h> | 39 | #include <kabc/resource.h> |
40 | #include <kabc/vcardconverter.h> | 40 | #include <kabc/vcardconverter.h> |
41 | #include <kapplication.h> | 41 | #include <kapplication.h> |
42 | #include <kactionclasses.h> | 42 | #include <kactionclasses.h> |
43 | #include <kcmultidialog.h> | 43 | #include <kcmultidialog.h> |
44 | #include <kdebug.h> | 44 | #include <kdebug.h> |
45 | #include <kdeversion.h> | 45 | #include <kdeversion.h> |
46 | #include <kkeydialog.h> | 46 | #include <kkeydialog.h> |
47 | #include <kmessagebox.h> | 47 | #include <kmessagebox.h> |
48 | #include <kprinter.h> | 48 | #include <kprinter.h> |
49 | #include <kprotocolinfo.h> | 49 | #include <kprotocolinfo.h> |
50 | #include <kresources/selectdialog.h> | 50 | #include <kresources/selectdialog.h> |
51 | #include <kstandarddirs.h> | 51 | #include <kstandarddirs.h> |
52 | #include <ktempfile.h> | 52 | #include <ktempfile.h> |
53 | #include <kxmlguiclient.h> | 53 | #include <kxmlguiclient.h> |
54 | #include <kaboutdata.h> | 54 | #include <kaboutdata.h> |
55 | #include <libkdepim/categoryselectdialog.h> | 55 | #include <libkdepim/categoryselectdialog.h> |
56 | 56 | ||
57 | #include "addresseeutil.h" | 57 | #include "addresseeutil.h" |
58 | #include "addresseeeditordialog.h" | 58 | #include "addresseeeditordialog.h" |
59 | #include "extensionmanager.h" | 59 | #include "extensionmanager.h" |
60 | #include "kstdaction.h" | 60 | #include "kstdaction.h" |
61 | #include "kaddressbookservice.h" | 61 | #include "kaddressbookservice.h" |
62 | #include "ldapsearchdialog.h" | 62 | #include "ldapsearchdialog.h" |
63 | #include "printing/printingwizard.h" | 63 | #include "printing/printingwizard.h" |
64 | #else // KAB_EMBEDDED | 64 | #else // KAB_EMBEDDED |
65 | 65 | ||
66 | #include "KDGanttMinimizeSplitter.h" | 66 | #include "KDGanttMinimizeSplitter.h" |
67 | #include "kaddressbookmain.h" | 67 | #include "kaddressbookmain.h" |
68 | #include "kactioncollection.h" | 68 | #include "kactioncollection.h" |
69 | #include <qapp.h> | 69 | #include <qapp.h> |
70 | #include <qmenubar.h> | 70 | #include <qmenubar.h> |
71 | //#include <qtoolbar.h> | 71 | //#include <qtoolbar.h> |
72 | #include <qmessagebox.h> | 72 | #include <qmessagebox.h> |
73 | #include <kdebug.h> | 73 | #include <kdebug.h> |
74 | #include <kiconloader.h> // needed for SmallIcon | 74 | #include <kiconloader.h> // needed for SmallIcon |
75 | #include <kresources/kcmkresources.h> | 75 | #include <kresources/kcmkresources.h> |
76 | #include <ktoolbar.h> | 76 | #include <ktoolbar.h> |
77 | 77 | ||
78 | #include <kcmkabconfig.h> | 78 | #include <kcmkabconfig.h> |
79 | 79 | ||
80 | //US#include <qpe/resource.h> // needed for Resource::loadPixmap | 80 | //US#include <qpe/resource.h> // needed for Resource::loadPixmap |
81 | //#include <qlabel.h> | 81 | //#include <qlabel.h> |
82 | #endif // KAB_EMBEDDED | 82 | #endif // KAB_EMBEDDED |
83 | #include <kcmkabconfig.h> | 83 | #include <kcmkabconfig.h> |
84 | 84 | ||
85 | 85 | ||
86 | #include <kresources/selectdialog.h> | 86 | #include <kresources/selectdialog.h> |
87 | #include <kmessagebox.h> | 87 | #include <kmessagebox.h> |
88 | 88 | ||
89 | #include <picture.h> | 89 | #include <picture.h> |
90 | #include <resource.h> | 90 | #include <resource.h> |
91 | 91 | ||
92 | //US#include <qsplitter.h> | 92 | //US#include <qsplitter.h> |
93 | #include <qvbox.h> | 93 | #include <qvbox.h> |
94 | #include <qlayout.h> | 94 | #include <qlayout.h> |
95 | #include <qclipboard.h> | 95 | #include <qclipboard.h> |
96 | 96 | ||
97 | #include <libkdepim/categoryselectdialog.h> | 97 | #include <libkdepim/categoryselectdialog.h> |
98 | 98 | ||
99 | #include "addresseeutil.h" | 99 | #include "addresseeutil.h" |
100 | #include "undocmds.h" | 100 | #include "undocmds.h" |
101 | #include "addresseeeditordialog.h" | 101 | #include "addresseeeditordialog.h" |
102 | #include "viewmanager.h" | 102 | #include "viewmanager.h" |
103 | #include "details/detailsviewcontainer.h" | 103 | #include "details/detailsviewcontainer.h" |
104 | #include "kabprefs.h" | 104 | #include "kabprefs.h" |
105 | #include "xxportmanager.h" | 105 | #include "xxportmanager.h" |
106 | #include "incsearchwidget.h" | 106 | #include "incsearchwidget.h" |
107 | #include "jumpbuttonbar.h" | 107 | #include "jumpbuttonbar.h" |
108 | #include "extensionmanager.h" | 108 | #include "extensionmanager.h" |
109 | #include "addresseeconfig.h" | 109 | #include "addresseeconfig.h" |
110 | #include <kcmultidialog.h> | 110 | #include <kcmultidialog.h> |
111 | 111 | ||
112 | 112 | ||
113 | #ifdef KAB_EMBEDDED | 113 | #ifdef KAB_EMBEDDED |
114 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 114 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) |
115 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), | 115 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), |
116 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ | 116 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ |
117 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) | 117 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) |
118 | #else //KAB_EMBEDDED | 118 | #else //KAB_EMBEDDED |
119 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 119 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) |
120 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), | 120 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), |
121 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), | 121 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), |
122 | mReadWrite( readWrite ), mModified( false ) | 122 | mReadWrite( readWrite ), mModified( false ) |
123 | #endif //KAB_EMBEDDED | 123 | #endif //KAB_EMBEDDED |
124 | { | 124 | { |
125 | #ifdef KAB_EMBEDDED | 125 | #ifdef KAB_EMBEDDED |
126 | //US we define here our own global actioncollection. | 126 | //US we define here our own global actioncollection. |
127 | //mActionCollection = new KActionCollection(this); | 127 | //mActionCollection = new KActionCollection(this); |
128 | #endif //KAB_EMBEDDED | 128 | #endif //KAB_EMBEDDED |
129 | mExtensionBarSplitter = 0; | 129 | mExtensionBarSplitter = 0; |
130 | mIsPart = !parent->inherits( "KAddressBookMain" ); | 130 | mIsPart = !parent->inherits( "KAddressBookMain" ); |
131 | 131 | ||
132 | mAddressBook = KABC::StdAddressBook::self(); | 132 | mAddressBook = KABC::StdAddressBook::self(); |
133 | KABC::StdAddressBook::setAutomaticSave( true ); | 133 | KABC::StdAddressBook::setAutomaticSave( true ); |
134 | 134 | ||
135 | #ifndef KAB_EMBEDDED | 135 | #ifndef KAB_EMBEDDED |
136 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); | 136 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); |
137 | #endif //KAB_EMBEDDED | 137 | #endif //KAB_EMBEDDED |
138 | 138 | ||
139 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), | 139 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), |
140 | SLOT( addressBookChanged() ) ); | 140 | SLOT( addressBookChanged() ) ); |
141 | 141 | ||
142 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, | 142 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, |
143 | "X-Department", "KADDRESSBOOK" ); | 143 | "X-Department", "KADDRESSBOOK" ); |
144 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 144 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
145 | "X-Profession", "KADDRESSBOOK" ); | 145 | "X-Profession", "KADDRESSBOOK" ); |
146 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 146 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
147 | "X-AssistantsName", "KADDRESSBOOK" ); | 147 | "X-AssistantsName", "KADDRESSBOOK" ); |
148 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 148 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
149 | "X-ManagersName", "KADDRESSBOOK" ); | 149 | "X-ManagersName", "KADDRESSBOOK" ); |
150 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 150 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
151 | "X-SpousesName", "KADDRESSBOOK" ); | 151 | "X-SpousesName", "KADDRESSBOOK" ); |
152 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, | 152 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, |
153 | "X-Office", "KADDRESSBOOK" ); | 153 | "X-Office", "KADDRESSBOOK" ); |
154 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 154 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
155 | "X-IMAddress", "KADDRESSBOOK" ); | 155 | "X-IMAddress", "KADDRESSBOOK" ); |
156 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 156 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
157 | "X-Anniversary", "KADDRESSBOOK" ); | 157 | "X-Anniversary", "KADDRESSBOOK" ); |
158 | |||
159 | //US added this field to become compatible with Opie addressbook | ||
160 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, | ||
161 | "X-Gender", "KADDRESSBOOK" ); | ||
162 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, | ||
163 | "X-Children", "KADDRESSBOOK" ); | ||
158 | 164 | ||
159 | initGUI(); | 165 | initGUI(); |
160 | 166 | ||
161 | mIncSearchWidget->setFocus(); | 167 | mIncSearchWidget->setFocus(); |
162 | 168 | ||
163 | 169 | ||
164 | connect( mViewManager, SIGNAL( selected( const QString& ) ), | 170 | connect( mViewManager, SIGNAL( selected( const QString& ) ), |
165 | SLOT( setContactSelected( const QString& ) ) ); | 171 | SLOT( setContactSelected( const QString& ) ) ); |
166 | connect( mViewManager, SIGNAL( executed( const QString& ) ), | 172 | connect( mViewManager, SIGNAL( executed( const QString& ) ), |
167 | SLOT( editContact( const QString& ) ) ); | 173 | SLOT( editContact( const QString& ) ) ); |
168 | connect( mViewManager, SIGNAL( deleteRequest( ) ), | 174 | connect( mViewManager, SIGNAL( deleteRequest( ) ), |
169 | SLOT( deleteContacts( ) ) ); | 175 | SLOT( deleteContacts( ) ) ); |
170 | connect( mViewManager, SIGNAL( modified() ), | 176 | connect( mViewManager, SIGNAL( modified() ), |
171 | SLOT( setModified() ) ); | 177 | SLOT( setModified() ) ); |
172 | 178 | ||
173 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); | 179 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); |
174 | 180 | ||
175 | connect( mXXPortManager, SIGNAL( modified() ), | 181 | connect( mXXPortManager, SIGNAL( modified() ), |
176 | SLOT( setModified() ) ); | 182 | SLOT( setModified() ) ); |
177 | 183 | ||
178 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), | 184 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), |
179 | SLOT( incrementalSearch( const QString& ) ) ); | 185 | SLOT( incrementalSearch( const QString& ) ) ); |
180 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), | 186 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), |
181 | mJumpButtonBar, SLOT( recreateButtons() ) ); | 187 | mJumpButtonBar, SLOT( recreateButtons() ) ); |
182 | 188 | ||
183 | #ifndef KAB_EMBEDDED | 189 | #ifndef KAB_EMBEDDED |
184 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), | 190 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), |
185 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); | 191 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); |
186 | 192 | ||
187 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), | 193 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), |
188 | SLOT( sendMail( const QString& ) ) ); | 194 | SLOT( sendMail( const QString& ) ) ); |
189 | connect( mDetails, SIGNAL( browse( const QString& ) ), | 195 | connect( mDetails, SIGNAL( browse( const QString& ) ), |
190 | SLOT( browse( const QString& ) ) ); | 196 | SLOT( browse( const QString& ) ) ); |
191 | 197 | ||
192 | mAddressBookService = new KAddressBookService( this ); | 198 | mAddressBookService = new KAddressBookService( this ); |
193 | 199 | ||
194 | #endif //KAB_EMBEDDED | 200 | #endif //KAB_EMBEDDED |
195 | 201 | ||
196 | setModified( false ); | 202 | setModified( false ); |
197 | } | 203 | } |
198 | 204 | ||
199 | KABCore::~KABCore() | 205 | KABCore::~KABCore() |
200 | { | 206 | { |
201 | // save(); | 207 | // save(); |
202 | //saveSettings(); | 208 | //saveSettings(); |
203 | //KABPrefs::instance()->writeConfig(); | 209 | //KABPrefs::instance()->writeConfig(); |
204 | delete AddresseeConfig::instance(); | 210 | delete AddresseeConfig::instance(); |
205 | mAddressBook = 0; | 211 | mAddressBook = 0; |
206 | KABC::StdAddressBook::close(); | 212 | KABC::StdAddressBook::close(); |
207 | 213 | ||
208 | #ifdef KAB_EMBEDDED | 214 | #ifdef KAB_EMBEDDED |
209 | //US we define here our own global actioncollection. | 215 | //US we define here our own global actioncollection. |
210 | // delete mActionCollection; | 216 | // delete mActionCollection; |
211 | #endif //KAB_EMBEDDED | 217 | #endif //KAB_EMBEDDED |
212 | 218 | ||
213 | } | 219 | } |
214 | 220 | ||
215 | void KABCore::restoreSettings() | 221 | void KABCore::restoreSettings() |
216 | { | 222 | { |
217 | bool state = KABPrefs::instance()->mJumpButtonBarVisible; | 223 | bool state = KABPrefs::instance()->mJumpButtonBarVisible; |
218 | 224 | ||
219 | mActionJumpBar->setChecked( state ); | 225 | mActionJumpBar->setChecked( state ); |
220 | setJumpButtonBarVisible( state ); | 226 | setJumpButtonBarVisible( state ); |
221 | 227 | ||
222 | state = KABPrefs::instance()->mDetailsPageVisible; | 228 | state = KABPrefs::instance()->mDetailsPageVisible; |
223 | 229 | ||
224 | mActionDetails->setChecked( state ); | 230 | mActionDetails->setChecked( state ); |
225 | setDetailsVisible( state ); | 231 | setDetailsVisible( state ); |
226 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 232 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
227 | if ( splitterSize.count() == 0 ) { | 233 | if ( splitterSize.count() == 0 ) { |
228 | splitterSize.append( width() / 2 ); | 234 | splitterSize.append( width() / 2 ); |
229 | splitterSize.append( width() / 2 ); | 235 | splitterSize.append( width() / 2 ); |
230 | } | 236 | } |
231 | mMiniSplitter->setSizes( splitterSize ); | 237 | mMiniSplitter->setSizes( splitterSize ); |
232 | if ( mExtensionBarSplitter ) { | 238 | if ( mExtensionBarSplitter ) { |
233 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 239 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
234 | if ( splitterSize.count() == 0 ) { | 240 | if ( splitterSize.count() == 0 ) { |
235 | splitterSize.append( width() / 2 ); | 241 | splitterSize.append( width() / 2 ); |
236 | splitterSize.append( width() / 2 ); | 242 | splitterSize.append( width() / 2 ); |
237 | } | 243 | } |
238 | mExtensionBarSplitter->setSizes( splitterSize ); | 244 | mExtensionBarSplitter->setSizes( splitterSize ); |
239 | 245 | ||
240 | } | 246 | } |
241 | #ifndef KAB_EMBEDDED | 247 | #ifndef KAB_EMBEDDED |
242 | QValueList<int> splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 248 | QValueList<int> splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
243 | if ( splitterSize.count() == 0 ) { | 249 | if ( splitterSize.count() == 0 ) { |
244 | splitterSize.append( width() / 2 ); | 250 | splitterSize.append( width() / 2 ); |
245 | splitterSize.append( width() / 2 ); | 251 | splitterSize.append( width() / 2 ); |
246 | } | 252 | } |
247 | mExtensionBarSplitter->setSizes( splitterSize ); | 253 | mExtensionBarSplitter->setSizes( splitterSize ); |
248 | 254 | ||
249 | splitterSize = KABPrefs::instance()->mDetailsSplitter; | 255 | splitterSize = KABPrefs::instance()->mDetailsSplitter; |
250 | if ( splitterSize.count() == 0 ) { | 256 | if ( splitterSize.count() == 0 ) { |
251 | splitterSize.append( height() / 2 ); | 257 | splitterSize.append( height() / 2 ); |
252 | splitterSize.append( height() / 2 ); | 258 | splitterSize.append( height() / 2 ); |
253 | } | 259 | } |
254 | mDetailsSplitter->setSizes( splitterSize ); | 260 | mDetailsSplitter->setSizes( splitterSize ); |
255 | 261 | ||
256 | mExtensionManager->restoreSettings(); | 262 | mExtensionManager->restoreSettings(); |
257 | 263 | ||
258 | #endif //KAB_EMBEDDED | 264 | #endif //KAB_EMBEDDED |
259 | 265 | ||
260 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 266 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
261 | 267 | ||
262 | mViewManager->restoreSettings(); | 268 | mViewManager->restoreSettings(); |
263 | mExtensionManager->restoreSettings(); | 269 | mExtensionManager->restoreSettings(); |
264 | } | 270 | } |
265 | 271 | ||
266 | void KABCore::saveSettings() | 272 | void KABCore::saveSettings() |
267 | { | 273 | { |
268 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | 274 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); |
269 | if ( mExtensionBarSplitter ) | 275 | if ( mExtensionBarSplitter ) |
270 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 276 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
271 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | 277 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); |
272 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); | 278 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); |
273 | #ifndef KAB_EMBEDDED | 279 | #ifndef KAB_EMBEDDED |
274 | 280 | ||
275 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 281 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
276 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | 282 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); |
277 | #endif //KAB_EMBEDDED | 283 | #endif //KAB_EMBEDDED |
278 | mExtensionManager->saveSettings(); | 284 | mExtensionManager->saveSettings(); |
279 | mViewManager->saveSettings(); | 285 | mViewManager->saveSettings(); |
280 | 286 | ||
281 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 287 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
282 | 288 | ||
283 | } | 289 | } |
284 | 290 | ||
285 | KABC::AddressBook *KABCore::addressBook() const | 291 | KABC::AddressBook *KABCore::addressBook() const |
286 | { | 292 | { |
287 | return mAddressBook; | 293 | return mAddressBook; |
288 | } | 294 | } |
289 | 295 | ||
290 | KConfig *KABCore::config() | 296 | KConfig *KABCore::config() |
291 | { | 297 | { |
292 | #ifndef KAB_EMBEDDED | 298 | #ifndef KAB_EMBEDDED |
293 | return KABPrefs::instance()->config(); | 299 | return KABPrefs::instance()->config(); |
294 | #else //KAB_EMBEDDED | 300 | #else //KAB_EMBEDDED |
295 | return KABPrefs::instance()->getConfig(); | 301 | return KABPrefs::instance()->getConfig(); |
296 | #endif //KAB_EMBEDDED | 302 | #endif //KAB_EMBEDDED |
297 | } | 303 | } |
298 | 304 | ||
299 | KActionCollection *KABCore::actionCollection() const | 305 | KActionCollection *KABCore::actionCollection() const |
300 | { | 306 | { |
301 | return mGUIClient->actionCollection(); | 307 | return mGUIClient->actionCollection(); |
302 | } | 308 | } |
303 | 309 | ||
304 | KABC::Field *KABCore::currentSearchField() const | 310 | KABC::Field *KABCore::currentSearchField() const |
305 | { | 311 | { |
306 | if (mIncSearchWidget) | 312 | if (mIncSearchWidget) |
307 | return mIncSearchWidget->currentField(); | 313 | return mIncSearchWidget->currentField(); |
308 | else | 314 | else |
309 | return 0; | 315 | return 0; |
310 | } | 316 | } |
311 | 317 | ||
312 | QStringList KABCore::selectedUIDs() const | 318 | QStringList KABCore::selectedUIDs() const |
313 | { | 319 | { |
314 | return mViewManager->selectedUids(); | 320 | return mViewManager->selectedUids(); |
315 | } | 321 | } |
316 | 322 | ||
317 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 323 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
318 | { | 324 | { |
319 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 325 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
320 | 326 | ||
321 | QPtrList<KRES::Resource> kresResources; | 327 | QPtrList<KRES::Resource> kresResources; |
322 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 328 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
323 | KABC::Resource *resource; | 329 | KABC::Resource *resource; |
324 | while ( ( resource = resIt.current() ) != 0 ) { | 330 | while ( ( resource = resIt.current() ) != 0 ) { |
325 | ++resIt; | 331 | ++resIt; |
326 | if ( !resource->readOnly() ) { | 332 | if ( !resource->readOnly() ) { |
327 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 333 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
328 | if ( res ) | 334 | if ( res ) |
329 | kresResources.append( res ); | 335 | kresResources.append( res ); |
330 | } | 336 | } |
331 | } | 337 | } |
332 | 338 | ||
333 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 339 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
334 | return static_cast<KABC::Resource*>( res ); | 340 | return static_cast<KABC::Resource*>( res ); |
335 | } | 341 | } |
336 | 342 | ||
337 | #ifndef KAB_EMBEDDED | 343 | #ifndef KAB_EMBEDDED |
338 | KAboutData *KABCore::createAboutData() | 344 | KAboutData *KABCore::createAboutData() |
339 | #else //KAB_EMBEDDED | 345 | #else //KAB_EMBEDDED |
340 | void KABCore::createAboutData() | 346 | void KABCore::createAboutData() |
341 | #endif //KAB_EMBEDDED | 347 | #endif //KAB_EMBEDDED |
342 | { | 348 | { |
343 | #ifndef KAB_EMBEDDED | 349 | #ifndef KAB_EMBEDDED |
344 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), | 350 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), |
345 | "3.1", I18N_NOOP( "The KDE Address Book" ), | 351 | "3.1", I18N_NOOP( "The KDE Address Book" ), |
346 | KAboutData::License_GPL_V2, | 352 | KAboutData::License_GPL_V2, |
347 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); | 353 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); |
348 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); | 354 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); |
349 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); | 355 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); |
350 | about->addAuthor( "Cornelius Schumacher", | 356 | about->addAuthor( "Cornelius Schumacher", |
351 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | 357 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), |
352 | "schumacher@kde.org" ); | 358 | "schumacher@kde.org" ); |
353 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | 359 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), |
354 | "mpilone@slac.com" ); | 360 | "mpilone@slac.com" ); |
355 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | 361 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); |
356 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | 362 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); |
357 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | 363 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), |
358 | "michel@klaralvdalens-datakonsult.se" ); | 364 | "michel@klaralvdalens-datakonsult.se" ); |
359 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | 365 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), |
360 | "hansen@kde.org" ); | 366 | "hansen@kde.org" ); |
361 | 367 | ||
362 | return about; | 368 | return about; |
363 | #endif //KAB_EMBEDDED | 369 | #endif //KAB_EMBEDDED |
364 | 370 | ||
365 | QString version; | 371 | QString version; |
366 | #include <../version> | 372 | #include <../version> |
367 | QMessageBox::about( this, "About KAddressbook/Pi", | 373 | QMessageBox::about( this, "About KAddressbook/Pi", |
368 | "KAddressbook/Platform-independent\n" | 374 | "KAddressbook/Platform-independent\n" |
369 | "(KA/Pi) " +version + " - " + | 375 | "(KA/Pi) " +version + " - " + |
370 | #ifdef DESKTOP_VERSION | 376 | #ifdef DESKTOP_VERSION |
371 | "Desktop Edition\n" | 377 | "Desktop Edition\n" |
372 | #else | 378 | #else |
373 | "PDA-Edition\n" | 379 | "PDA-Edition\n" |
374 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 380 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
375 | #endif | 381 | #endif |
376 | 382 | ||
377 | "(c) 2004 Ulf Schenk\n" | 383 | "(c) 2004 Ulf Schenk\n" |
378 | "(c) 1997-2003, The KDE PIM Team\n" | 384 | "(c) 1997-2003, The KDE PIM Team\n" |
379 | "Tobias Koenig Current maintainer tokoe@kde.org\n" | 385 | "Tobias Koenig Current maintainer tokoe@kde.org\n" |
380 | "Don Sanders Original author\n" | 386 | "Don Sanders Original author\n" |
381 | "Cornelius Schumacher Co-maintainer schumacher@kde.org\n" | 387 | "Cornelius Schumacher Co-maintainer schumacher@kde.org\n" |
382 | "Mike Pilone GUI and framework redesign mpilone@slac.com\n" | 388 | "Mike Pilone GUI and framework redesign mpilone@slac.com\n" |
383 | "Greg Stern DCOP interface\n" | 389 | "Greg Stern DCOP interface\n" |
384 | "Mark Westcot Contact pinning\n" | 390 | "Mark Westcot Contact pinning\n" |
385 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" | 391 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" |
386 | "Steffen Hansen LDAP Lookup hansen@kde.org\n" ); | 392 | "Steffen Hansen LDAP Lookup hansen@kde.org\n" ); |
387 | } | 393 | } |
388 | 394 | ||
389 | void KABCore::setContactSelected( const QString &uid ) | 395 | void KABCore::setContactSelected( const QString &uid ) |
390 | { | 396 | { |
391 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 397 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
392 | if ( !mDetails->isHidden() ) | 398 | if ( !mDetails->isHidden() ) |
393 | mDetails->setAddressee( addr ); | 399 | mDetails->setAddressee( addr ); |
394 | 400 | ||
395 | if ( !addr.isEmpty() ) { | 401 | if ( !addr.isEmpty() ) { |
396 | emit contactSelected( addr.formattedName() ); | 402 | emit contactSelected( addr.formattedName() ); |
397 | KABC::Picture pic = addr.photo(); | 403 | KABC::Picture pic = addr.photo(); |
398 | if ( pic.isIntern() ) { | 404 | if ( pic.isIntern() ) { |
399 | //US emit contactSelected( pic.data() ); | 405 | //US emit contactSelected( pic.data() ); |
400 | //US instead use: | 406 | //US instead use: |
401 | QPixmap px; | 407 | QPixmap px; |
402 | if (pic.data().isNull() != true) | 408 | if (pic.data().isNull() != true) |
403 | { | 409 | { |
404 | px.convertFromImage(pic.data()); | 410 | px.convertFromImage(pic.data()); |
405 | } | 411 | } |
406 | 412 | ||
407 | emit contactSelected( px ); | 413 | emit contactSelected( px ); |
408 | } | 414 | } |
409 | } | 415 | } |
410 | 416 | ||
411 | 417 | ||
412 | mExtensionManager->setSelectionChanged(); | 418 | mExtensionManager->setSelectionChanged(); |
413 | 419 | ||
414 | // update the actions | 420 | // update the actions |
415 | bool selected = !uid.isEmpty(); | 421 | bool selected = !uid.isEmpty(); |
416 | 422 | ||
417 | if ( mReadWrite ) { | 423 | if ( mReadWrite ) { |
418 | mActionCut->setEnabled( selected ); | 424 | mActionCut->setEnabled( selected ); |
419 | mActionPaste->setEnabled( selected ); | 425 | mActionPaste->setEnabled( selected ); |
420 | } | 426 | } |
421 | 427 | ||
422 | mActionCopy->setEnabled( selected ); | 428 | mActionCopy->setEnabled( selected ); |
423 | mActionDelete->setEnabled( selected ); | 429 | mActionDelete->setEnabled( selected ); |
424 | mActionEditAddressee->setEnabled( selected ); | 430 | mActionEditAddressee->setEnabled( selected ); |
425 | mActionMail->setEnabled( selected ); | 431 | mActionMail->setEnabled( selected ); |
426 | mActionMailVCard->setEnabled( selected ); | 432 | mActionMailVCard->setEnabled( selected ); |
427 | mActionWhoAmI->setEnabled( selected ); | 433 | mActionWhoAmI->setEnabled( selected ); |
428 | mActionCategories->setEnabled( selected ); | 434 | mActionCategories->setEnabled( selected ); |
429 | } | 435 | } |
430 | 436 | ||
431 | void KABCore::sendMail() | 437 | void KABCore::sendMail() |
432 | { | 438 | { |
433 | #ifndef KAB_EMBEDDED | 439 | #ifndef KAB_EMBEDDED |
434 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 440 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
435 | #else //KAB_EMBEDDED | 441 | #else //KAB_EMBEDDED |
436 | qDebug("KABCore::sendMail() ust be fixed"); | 442 | qDebug("KABCore::sendMail() ust be fixed"); |
437 | #endif //KAB_EMBEDDED | 443 | #endif //KAB_EMBEDDED |
438 | } | 444 | } |
439 | 445 | ||
440 | void KABCore::sendMail( const QString& email ) | 446 | void KABCore::sendMail( const QString& email ) |
441 | { | 447 | { |
442 | #ifndef KAB_EMBEDDED | 448 | #ifndef KAB_EMBEDDED |
443 | kapp->invokeMailer( email, "" ); | 449 | kapp->invokeMailer( email, "" ); |
444 | #else //KAB_EMBEDDED | 450 | #else //KAB_EMBEDDED |
445 | qDebug("KABCore::sendMail(const QString& email) ust be fixed"); | 451 | qDebug("KABCore::sendMail(const QString& email) ust be fixed"); |
446 | #endif //KAB_EMBEDDED | 452 | #endif //KAB_EMBEDDED |
447 | } | 453 | } |
448 | 454 | ||
449 | void KABCore::mailVCard() | 455 | void KABCore::mailVCard() |
450 | { | 456 | { |
451 | #ifndef KAB_EMBEDDED | 457 | #ifndef KAB_EMBEDDED |
452 | QStringList uids = mViewManager->selectedUids(); | 458 | QStringList uids = mViewManager->selectedUids(); |
453 | if ( !uids.isEmpty() ) | 459 | if ( !uids.isEmpty() ) |
454 | mailVCard( uids ); | 460 | mailVCard( uids ); |
455 | #else //KAB_EMBEDDED | 461 | #else //KAB_EMBEDDED |
456 | qDebug("KABCore::mailVCard() must be fixed"); | 462 | qDebug("KABCore::mailVCard() must be fixed"); |
457 | #endif //KAB_EMBEDDED | 463 | #endif //KAB_EMBEDDED |
458 | } | 464 | } |
459 | 465 | ||
460 | void KABCore::mailVCard( const QStringList& uids ) | 466 | void KABCore::mailVCard( const QStringList& uids ) |
461 | { | 467 | { |
462 | #ifndef KAB_EMBEDDED | 468 | #ifndef KAB_EMBEDDED |
463 | QStringList urls; | 469 | QStringList urls; |
464 | 470 | ||
465 | // Create a temp dir, so that we can put the files in it with proper names | 471 | // Create a temp dir, so that we can put the files in it with proper names |
466 | KTempFile tempDir; | 472 | KTempFile tempDir; |
467 | if ( tempDir.status() != 0 ) { | 473 | if ( tempDir.status() != 0 ) { |
468 | kdWarning() << strerror( tempDir.status() ) << endl; | 474 | kdWarning() << strerror( tempDir.status() ) << endl; |
469 | return; | 475 | return; |
470 | } | 476 | } |
471 | 477 | ||
472 | QString dirName = tempDir.name(); | 478 | QString dirName = tempDir.name(); |
473 | tempDir.unlink(); | 479 | tempDir.unlink(); |
474 | QDir().mkdir( dirName, true ); | 480 | QDir().mkdir( dirName, true ); |
475 | 481 | ||
476 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 482 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
477 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 483 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
478 | 484 | ||
479 | if ( a.isEmpty() ) | 485 | if ( a.isEmpty() ) |
480 | continue; | 486 | continue; |
481 | 487 | ||
482 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 488 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
483 | 489 | ||
484 | QString fileName = dirName + "/" + name; | 490 | QString fileName = dirName + "/" + name; |
485 | 491 | ||
486 | QFile outFile(fileName); | 492 | QFile outFile(fileName); |
487 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 493 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
488 | KABC::VCardConverter converter; | 494 | KABC::VCardConverter converter; |
489 | QString vcard; | 495 | QString vcard; |
490 | 496 | ||
491 | converter.addresseeToVCard( a, vcard ); | 497 | converter.addresseeToVCard( a, vcard ); |
492 | 498 | ||
493 | QTextStream t( &outFile ); // use a text stream | 499 | QTextStream t( &outFile ); // use a text stream |
494 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 500 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
495 | t << vcard; | 501 | t << vcard; |
496 | 502 | ||
497 | outFile.close(); | 503 | outFile.close(); |
498 | 504 | ||
499 | urls.append( fileName ); | 505 | urls.append( fileName ); |
500 | } | 506 | } |
501 | } | 507 | } |
502 | 508 | ||
503 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 509 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
504 | QString::null, // subject | 510 | QString::null, // subject |
505 | QString::null, // body | 511 | QString::null, // body |
506 | QString::null, | 512 | QString::null, |
507 | urls ); // attachments | 513 | urls ); // attachments |
508 | #else //KAB_EMBEDDED | 514 | #else //KAB_EMBEDDED |
509 | qDebug("KABCore::mailVCard( must be fixed"); | 515 | qDebug("KABCore::mailVCard( must be fixed"); |
510 | #endif //KAB_EMBEDDED | 516 | #endif //KAB_EMBEDDED |
511 | 517 | ||
512 | } | 518 | } |
513 | 519 | ||
514 | void KABCore::browse( const QString& url ) | 520 | void KABCore::browse( const QString& url ) |
515 | { | 521 | { |
516 | #ifndef KAB_EMBEDDED | 522 | #ifndef KAB_EMBEDDED |
517 | kapp->invokeBrowser( url ); | 523 | kapp->invokeBrowser( url ); |
518 | #else //KAB_EMBEDDED | 524 | #else //KAB_EMBEDDED |
519 | qDebug("KABCore::browse must be fixed"); | 525 | qDebug("KABCore::browse must be fixed"); |
520 | #endif //KAB_EMBEDDED | 526 | #endif //KAB_EMBEDDED |
521 | } | 527 | } |
522 | 528 | ||
523 | void KABCore::selectAllContacts() | 529 | void KABCore::selectAllContacts() |
524 | { | 530 | { |
525 | mViewManager->setSelected( QString::null, true ); | 531 | mViewManager->setSelected( QString::null, true ); |
526 | } | 532 | } |
527 | 533 | ||
528 | void KABCore::deleteContacts() | 534 | void KABCore::deleteContacts() |
529 | { | 535 | { |
530 | QStringList uidList = mViewManager->selectedUids(); | 536 | QStringList uidList = mViewManager->selectedUids(); |
531 | deleteContacts( uidList ); | 537 | deleteContacts( uidList ); |
532 | } | 538 | } |
533 | 539 | ||
534 | void KABCore::deleteContacts( const QStringList &uids ) | 540 | void KABCore::deleteContacts( const QStringList &uids ) |
535 | { | 541 | { |
536 | if ( uids.count() > 0 ) { | 542 | if ( uids.count() > 0 ) { |
537 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 543 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
538 | UndoStack::instance()->push( command ); | 544 | UndoStack::instance()->push( command ); |
539 | RedoStack::instance()->clear(); | 545 | RedoStack::instance()->clear(); |
540 | 546 | ||
541 | // now if we deleted anything, refresh | 547 | // now if we deleted anything, refresh |
542 | setContactSelected( QString::null ); | 548 | setContactSelected( QString::null ); |
543 | setModified( true ); | 549 | setModified( true ); |
544 | } | 550 | } |
545 | } | 551 | } |
546 | 552 | ||
547 | void KABCore::copyContacts() | 553 | void KABCore::copyContacts() |
548 | { | 554 | { |
549 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 555 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
550 | 556 | ||
551 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 557 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
552 | 558 | ||
553 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 559 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
554 | 560 | ||
555 | QClipboard *cb = QApplication::clipboard(); | 561 | QClipboard *cb = QApplication::clipboard(); |
556 | cb->setText( clipText ); | 562 | cb->setText( clipText ); |
557 | } | 563 | } |
558 | 564 | ||
559 | void KABCore::cutContacts() | 565 | void KABCore::cutContacts() |
560 | { | 566 | { |
561 | QStringList uidList = mViewManager->selectedUids(); | 567 | QStringList uidList = mViewManager->selectedUids(); |
562 | 568 | ||
563 | //US if ( uidList.size() > 0 ) { | 569 | //US if ( uidList.size() > 0 ) { |
564 | if ( uidList.count() > 0 ) { | 570 | if ( uidList.count() > 0 ) { |
565 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 571 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
566 | UndoStack::instance()->push( command ); | 572 | UndoStack::instance()->push( command ); |
567 | RedoStack::instance()->clear(); | 573 | RedoStack::instance()->clear(); |
568 | 574 | ||
569 | setModified( true ); | 575 | setModified( true ); |
570 | } | 576 | } |
571 | } | 577 | } |
572 | 578 | ||
573 | void KABCore::pasteContacts() | 579 | void KABCore::pasteContacts() |
574 | { | 580 | { |
575 | QClipboard *cb = QApplication::clipboard(); | 581 | QClipboard *cb = QApplication::clipboard(); |
576 | 582 | ||
577 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 583 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
578 | 584 | ||
579 | pasteContacts( list ); | 585 | pasteContacts( list ); |
580 | } | 586 | } |
581 | 587 | ||
582 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 588 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
583 | { | 589 | { |
584 | KABC::Resource *resource = requestResource( this ); | 590 | KABC::Resource *resource = requestResource( this ); |
585 | KABC::Addressee::List::Iterator it; | 591 | KABC::Addressee::List::Iterator it; |
586 | for ( it = list.begin(); it != list.end(); ++it ) | 592 | for ( it = list.begin(); it != list.end(); ++it ) |
587 | (*it).setResource( resource ); | 593 | (*it).setResource( resource ); |
588 | 594 | ||
589 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 595 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
590 | UndoStack::instance()->push( command ); | 596 | UndoStack::instance()->push( command ); |
591 | RedoStack::instance()->clear(); | 597 | RedoStack::instance()->clear(); |
592 | 598 | ||
593 | setModified( true ); | 599 | setModified( true ); |
594 | } | 600 | } |
595 | 601 | ||
596 | void KABCore::setWhoAmI() | 602 | void KABCore::setWhoAmI() |
597 | { | 603 | { |
598 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 604 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
599 | 605 | ||
600 | if ( addrList.count() > 1 ) { | 606 | if ( addrList.count() > 1 ) { |
601 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 607 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
602 | return; | 608 | return; |
603 | } | 609 | } |
604 | 610 | ||
605 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 611 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
606 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | 612 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) |
607 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 613 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
608 | } | 614 | } |
609 | 615 | ||
610 | void KABCore::setCategories() | 616 | void KABCore::setCategories() |
611 | { | 617 | { |
612 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 618 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
613 | if ( !dlg.exec() ) | 619 | if ( !dlg.exec() ) |
614 | return; | 620 | return; |
615 | 621 | ||
616 | bool merge = false; | 622 | bool merge = false; |
617 | QString msg = i18n( "Merge with existing categories?" ); | 623 | QString msg = i18n( "Merge with existing categories?" ); |
618 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 624 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
619 | merge = true; | 625 | merge = true; |
620 | 626 | ||
621 | QStringList categories = dlg.selectedCategories(); | 627 | QStringList categories = dlg.selectedCategories(); |
622 | 628 | ||
623 | QStringList uids = mViewManager->selectedUids(); | 629 | QStringList uids = mViewManager->selectedUids(); |
624 | QStringList::Iterator it; | 630 | QStringList::Iterator it; |
625 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 631 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
626 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 632 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
627 | if ( !addr.isEmpty() ) { | 633 | if ( !addr.isEmpty() ) { |
628 | if ( !merge ) | 634 | if ( !merge ) |
629 | addr.setCategories( categories ); | 635 | addr.setCategories( categories ); |
630 | else { | 636 | else { |
631 | QStringList addrCategories = addr.categories(); | 637 | QStringList addrCategories = addr.categories(); |
632 | QStringList::Iterator catIt; | 638 | QStringList::Iterator catIt; |
633 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 639 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
634 | if ( !addrCategories.contains( *catIt ) ) | 640 | if ( !addrCategories.contains( *catIt ) ) |
635 | addrCategories.append( *catIt ); | 641 | addrCategories.append( *catIt ); |
636 | } | 642 | } |
637 | addr.setCategories( addrCategories ); | 643 | addr.setCategories( addrCategories ); |
638 | } | 644 | } |
639 | 645 | ||
640 | mAddressBook->insertAddressee( addr ); | 646 | mAddressBook->insertAddressee( addr ); |
641 | } | 647 | } |
642 | } | 648 | } |
643 | 649 | ||
644 | if ( uids.count() > 0 ) | 650 | if ( uids.count() > 0 ) |
645 | setModified( true ); | 651 | setModified( true ); |
646 | } | 652 | } |
647 | 653 | ||
648 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 654 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
649 | { | 655 | { |
650 | mIncSearchWidget->setFields( fields ); | 656 | mIncSearchWidget->setFields( fields ); |
651 | } | 657 | } |
652 | 658 | ||
653 | void KABCore::incrementalSearch( const QString& text ) | 659 | void KABCore::incrementalSearch( const QString& text ) |
654 | { | 660 | { |
655 | mViewManager->setSelected( QString::null, false ); | 661 | mViewManager->setSelected( QString::null, false ); |
656 | 662 | ||
657 | if ( !text.isEmpty() ) { | 663 | if ( !text.isEmpty() ) { |
658 | KABC::Field *field = mIncSearchWidget->currentField(); | 664 | KABC::Field *field = mIncSearchWidget->currentField(); |
659 | 665 | ||
660 | QString pattern = text.lower(); | 666 | QString pattern = text.lower(); |
661 | 667 | ||
662 | #if KDE_VERSION >= 319 | 668 | #if KDE_VERSION >= 319 |
663 | KABC::AddresseeList list( mAddressBook->allAddressees() ); | 669 | KABC::AddresseeList list( mAddressBook->allAddressees() ); |
664 | if ( field ) { | 670 | if ( field ) { |
665 | list.sortByField( field ); | 671 | list.sortByField( field ); |
666 | KABC::AddresseeList::Iterator it; | 672 | KABC::AddresseeList::Iterator it; |
667 | for ( it = list.begin(); it != list.end(); ++it ) { | 673 | for ( it = list.begin(); it != list.end(); ++it ) { |
668 | if ( field->value( *it ).lower().startsWith( pattern ) ) { | 674 | if ( field->value( *it ).lower().startsWith( pattern ) ) { |
669 | mViewManager->setSelected( (*it).uid(), true ); | 675 | mViewManager->setSelected( (*it).uid(), true ); |