-rw-r--r-- | kaddressbook/kabcore.cpp | 1571 |
1 files changed, 1571 insertions, 0 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp new file mode 100644 index 0000000..3e578bc --- a/dev/null +++ b/kaddressbook/kabcore.cpp | |||
@@ -0,0 +1,1571 @@ | |||
1 | /* | ||
2 | This file is part of KAddressbook. | ||
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | ||
4 | |||
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 | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
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 | ||
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | |||
19 | As a special exception, permission is given to link this program | ||
20 | with any edition of Qt, and distribute the resulting executable, | ||
21 | without including the source code for Qt in the source distribution. | ||
22 | */ | ||
23 | |||
24 | #include "kabcore.h" | ||
25 | |||
26 | #include <stdaddressbook.h> | ||
27 | #include <klocale.h> | ||
28 | |||
29 | #ifndef KAB_EMBEDDED | ||
30 | #include <qclipboard.h> | ||
31 | #include <qdir.h> | ||
32 | #include <qfile.h> | ||
33 | #include <qapplicaton.h> | ||
34 | #include <qlayout.h> | ||
35 | #include <qregexp.h> | ||
36 | #include <qvbox.h> | ||
37 | #include <kabc/addresseelist.h> | ||
38 | #include <kabc/errorhandler.h> | ||
39 | #include <kabc/resource.h> | ||
40 | #include <kabc/vcardconverter.h> | ||
41 | #include <kapplication.h> | ||
42 | #include <kactionclasses.h> | ||
43 | #include <kcmultidialog.h> | ||
44 | #include <kdebug.h> | ||
45 | #include <kdeversion.h> | ||
46 | #include <kkeydialog.h> | ||
47 | #include <kmessagebox.h> | ||
48 | #include <kprinter.h> | ||
49 | #include <kprotocolinfo.h> | ||
50 | #include <kresources/selectdialog.h> | ||
51 | #include <kstandarddirs.h> | ||
52 | #include <ktempfile.h> | ||
53 | #include <kxmlguiclient.h> | ||
54 | #include <kaboutdata.h> | ||
55 | #include <libkdepim/categoryselectdialog.h> | ||
56 | |||
57 | #include "addresseeutil.h" | ||
58 | #include "addresseeeditordialog.h" | ||
59 | #include "extensionmanager.h" | ||
60 | #include "kstdaction.h" | ||
61 | #include "kaddressbookservice.h" | ||
62 | #include "ldapsearchdialog.h" | ||
63 | #include "printing/printingwizard.h" | ||
64 | #else // KAB_EMBEDDED | ||
65 | |||
66 | #include "KDGanttMinimizeSplitter.h" | ||
67 | #include "kaddressbookmain.h" | ||
68 | #include "kactioncollection.h" | ||
69 | #include <qapp.h> | ||
70 | #include <qmenubar.h> | ||
71 | //#include <qtoolbar.h> | ||
72 | #include <qmessagebox.h> | ||
73 | #include <kdebug.h> | ||
74 | #include <kiconloader.h> // needed for SmallIcon | ||
75 | #include <kresources/kcmkresources.h> | ||
76 | #include <ktoolbar.h> | ||
77 | |||
78 | #include <kcmkabconfig.h> | ||
79 | |||
80 | //US#include <qpe/resource.h> // needed for Resource::loadPixmap | ||
81 | //#include <qlabel.h> | ||
82 | #endif // KAB_EMBEDDED | ||
83 | #include <kcmkabconfig.h> | ||
84 | |||
85 | |||
86 | #include <kresources/selectdialog.h> | ||
87 | #include <kmessagebox.h> | ||
88 | |||
89 | #include <picture.h> | ||
90 | #include <resource.h> | ||
91 | |||
92 | //US#include <qsplitter.h> | ||
93 | #include <qvbox.h> | ||
94 | #include <qlayout.h> | ||
95 | #include <qclipboard.h> | ||
96 | |||
97 | #include <libkdepim/categoryselectdialog.h> | ||
98 | |||
99 | #include "addresseeutil.h" | ||
100 | #include "undocmds.h" | ||
101 | #include "addresseeeditordialog.h" | ||
102 | #include "viewmanager.h" | ||
103 | #include "details/detailsviewcontainer.h" | ||
104 | #include "kabprefs.h" | ||
105 | #include "xxportmanager.h" | ||
106 | #include "incsearchwidget.h" | ||
107 | #include "jumpbuttonbar.h" | ||
108 | #include "extensionmanager.h" | ||
109 | #include "addresseeconfig.h" | ||
110 | #include <kcmultidialog.h> | ||
111 | |||
112 | |||
113 | #ifdef KAB_EMBEDDED | ||
114 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | ||
115 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), | ||
116 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ | ||
117 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) | ||
118 | #else //KAB_EMBEDDED | ||
119 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | ||
120 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), | ||
121 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), | ||
122 | mReadWrite( readWrite ), mModified( false ) | ||
123 | #endif //KAB_EMBEDDED | ||
124 | { | ||
125 | #ifdef KAB_EMBEDDED | ||
126 | //US we define here our own global actioncollection. | ||
127 | //mActionCollection = new KActionCollection(this); | ||
128 | #endif //KAB_EMBEDDED | ||
129 | |||
130 | mIsPart = !parent->inherits( "KAddressBookMain" ); | ||
131 | |||
132 | mAddressBook = KABC::StdAddressBook::self(); | ||
133 | KABC::StdAddressBook::setAutomaticSave( true ); | ||
134 | |||
135 | #ifndef KAB_EMBEDDED | ||
136 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); | ||
137 | #endif //KAB_EMBEDDED | ||
138 | |||
139 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), | ||
140 | SLOT( addressBookChanged() ) ); | ||
141 | |||
142 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, | ||
143 | "X-Department", "KADDRESSBOOK" ); | ||
144 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, | ||
145 | "X-Profession", "KADDRESSBOOK" ); | ||
146 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | ||
147 | "X-AssistantsName", "KADDRESSBOOK" ); | ||
148 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | ||
149 | "X-ManagersName", "KADDRESSBOOK" ); | ||
150 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | ||
151 | "X-SpousesName", "KADDRESSBOOK" ); | ||
152 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, | ||
153 | "X-Office", "KADDRESSBOOK" ); | ||
154 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | ||
155 | "X-IMAddress", "KADDRESSBOOK" ); | ||
156 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | ||
157 | "X-Anniversary", "KADDRESSBOOK" ); | ||
158 | |||
159 | initGUI(); | ||
160 | |||
161 | mIncSearchWidget->setFocus(); | ||
162 | |||
163 | |||
164 | connect( mViewManager, SIGNAL( selected( const QString& ) ), | ||
165 | SLOT( setContactSelected( const QString& ) ) ); | ||
166 | connect( mViewManager, SIGNAL( executed( const QString& ) ), | ||
167 | SLOT( editContact( const QString& ) ) ); | ||
168 | connect( mViewManager, SIGNAL( deleteRequest( ) ), | ||
169 | SLOT( deleteContacts( ) ) ); | ||
170 | connect( mViewManager, SIGNAL( modified() ), | ||
171 | SLOT( setModified() ) ); | ||
172 | |||
173 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); | ||
174 | |||
175 | connect( mXXPortManager, SIGNAL( modified() ), | ||
176 | SLOT( setModified() ) ); | ||
177 | |||
178 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), | ||
179 | SLOT( incrementalSearch( const QString& ) ) ); | ||
180 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), | ||
181 | mJumpButtonBar, SLOT( recreateButtons() ) ); | ||
182 | |||
183 | #ifndef KAB_EMBEDDED | ||
184 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), | ||
185 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); | ||
186 | |||
187 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), | ||
188 | SLOT( sendMail( const QString& ) ) ); | ||
189 | connect( mDetails, SIGNAL( browse( const QString& ) ), | ||
190 | SLOT( browse( const QString& ) ) ); | ||
191 | |||
192 | mAddressBookService = new KAddressBookService( this ); | ||
193 | |||
194 | #endif //KAB_EMBEDDED | ||
195 | |||
196 | setModified( false ); | ||
197 | } | ||
198 | |||
199 | KABCore::~KABCore() | ||
200 | { | ||
201 | // save(); | ||
202 | //saveSettings(); | ||
203 | //KABPrefs::instance()->writeConfig(); | ||
204 | delete AddresseeConfig::instance(); | ||
205 | mAddressBook = 0; | ||
206 | KABC::StdAddressBook::close(); | ||
207 | |||
208 | #ifdef KAB_EMBEDDED | ||
209 | //US we define here our own global actioncollection. | ||
210 | // delete mActionCollection; | ||
211 | #endif //KAB_EMBEDDED | ||
212 | |||
213 | } | ||
214 | |||
215 | void KABCore::restoreSettings() | ||
216 | { | ||
217 | bool state = KABPrefs::instance()->mJumpButtonBarVisible; | ||
218 | |||
219 | mActionJumpBar->setChecked( state ); | ||
220 | setJumpButtonBarVisible( state ); | ||
221 | |||
222 | state = KABPrefs::instance()->mDetailsPageVisible; | ||
223 | |||
224 | mActionDetails->setChecked( state ); | ||
225 | setDetailsVisible( state ); | ||
226 | QValueList<int> splitterSize = KABPrefs::instance()->mExtensionsSplitter; | ||
227 | if ( splitterSize.count() == 0 ) { | ||
228 | splitterSize.append( width() / 2 ); | ||
229 | splitterSize.append( width() / 2 ); | ||
230 | } | ||
231 | mMiniSplitter->setSizes( splitterSize ); | ||
232 | #ifndef KAB_EMBEDDED | ||
233 | QValueList<int> splitterSize = KABPrefs::instance()->mExtensionsSplitter; | ||
234 | if ( splitterSize.count() == 0 ) { | ||
235 | splitterSize.append( width() / 2 ); | ||
236 | splitterSize.append( width() / 2 ); | ||
237 | } | ||
238 | mExtensionBarSplitter->setSizes( splitterSize ); | ||
239 | |||
240 | splitterSize = KABPrefs::instance()->mDetailsSplitter; | ||
241 | if ( splitterSize.count() == 0 ) { | ||
242 | splitterSize.append( height() / 2 ); | ||
243 | splitterSize.append( height() / 2 ); | ||
244 | } | ||
245 | mDetailsSplitter->setSizes( splitterSize ); | ||
246 | |||
247 | mExtensionManager->restoreSettings(); | ||
248 | |||
249 | #endif //KAB_EMBEDDED | ||
250 | |||
251 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | ||
252 | |||
253 | mViewManager->restoreSettings(); | ||
254 | mExtensionManager->restoreSettings(); | ||
255 | } | ||
256 | |||
257 | void KABCore::saveSettings() | ||
258 | { | ||
259 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | ||
260 | KABPrefs::instance()->mExtensionsSplitter = mMiniSplitter->sizes(); | ||
261 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | ||
262 | |||
263 | #ifndef KAB_EMBEDDED | ||
264 | |||
265 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | ||
266 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | ||
267 | #endif //KAB_EMBEDDED | ||
268 | mExtensionManager->saveSettings(); | ||
269 | mViewManager->saveSettings(); | ||
270 | |||
271 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | ||
272 | |||
273 | } | ||
274 | |||
275 | KABC::AddressBook *KABCore::addressBook() const | ||
276 | { | ||
277 | return mAddressBook; | ||
278 | } | ||
279 | |||
280 | KConfig *KABCore::config() | ||
281 | { | ||
282 | #ifndef KAB_EMBEDDED | ||
283 | return KABPrefs::instance()->config(); | ||
284 | #else //KAB_EMBEDDED | ||
285 | return KABPrefs::instance()->getConfig(); | ||
286 | #endif //KAB_EMBEDDED | ||
287 | } | ||
288 | |||
289 | KActionCollection *KABCore::actionCollection() const | ||
290 | { | ||
291 | return mGUIClient->actionCollection(); | ||
292 | } | ||
293 | |||
294 | KABC::Field *KABCore::currentSearchField() const | ||
295 | { | ||
296 | if (mIncSearchWidget) | ||
297 | return mIncSearchWidget->currentField(); | ||
298 | else | ||
299 | return 0; | ||
300 | } | ||
301 | |||
302 | QStringList KABCore::selectedUIDs() const | ||
303 | { | ||
304 | return mViewManager->selectedUids(); | ||
305 | } | ||
306 | |||
307 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | ||
308 | { | ||
309 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | ||
310 | |||
311 | QPtrList<KRES::Resource> kresResources; | ||
312 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | ||
313 | KABC::Resource *resource; | ||
314 | while ( ( resource = resIt.current() ) != 0 ) { | ||
315 | ++resIt; | ||
316 | if ( !resource->readOnly() ) { | ||
317 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | ||
318 | if ( res ) | ||
319 | kresResources.append( res ); | ||
320 | } | ||
321 | } | ||
322 | |||
323 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | ||
324 | return static_cast<KABC::Resource*>( res ); | ||
325 | } | ||
326 | |||
327 | #ifndef KAB_EMBEDDED | ||
328 | KAboutData *KABCore::createAboutData() | ||
329 | #else //KAB_EMBEDDED | ||
330 | void KABCore::createAboutData() | ||
331 | #endif //KAB_EMBEDDED | ||
332 | { | ||
333 | #ifndef KAB_EMBEDDED | ||
334 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), | ||
335 | "3.1", I18N_NOOP( "The KDE Address Book" ), | ||
336 | KAboutData::License_GPL_V2, | ||
337 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); | ||
338 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); | ||
339 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); | ||
340 | about->addAuthor( "Cornelius Schumacher", | ||
341 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | ||
342 | "schumacher@kde.org" ); | ||
343 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | ||
344 | "mpilone@slac.com" ); | ||
345 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | ||
346 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | ||
347 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | ||
348 | "michel@klaralvdalens-datakonsult.se" ); | ||
349 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | ||
350 | "hansen@kde.org" ); | ||
351 | |||
352 | return about; | ||
353 | #endif //KAB_EMBEDDED | ||
354 | |||
355 | QString version; | ||
356 | #include <../version> | ||
357 | QMessageBox::about( this, "About KAddressbook/Pi", | ||
358 | "KAddressbook/Platform-independent\n" | ||
359 | "(KA/Pi) " +version + " - " + | ||
360 | #ifdef DESKTOP_VERSION | ||
361 | "Desktop Edition\n" | ||
362 | #else | ||
363 | "PDA-Edition\n" | ||
364 | "for: Zaurus 5500 / 7x0 / 8x0\n" | ||
365 | #endif | ||
366 | |||
367 | "(c) 2004 Ulf Schenk\n" | ||
368 | "(c) 1997-2003, The KDE PIM Team\n" | ||
369 | "Tobias Koenig Current maintainer tokoe@kde.org\n" | ||
370 | "Don Sanders Original author\n" | ||
371 | "Cornelius Schumacher Co-maintainer schumacher@kde.org\n" | ||
372 | "Mike Pilone GUI and framework redesign mpilone@slac.com\n" | ||
373 | "Greg Stern DCOP interface\n" | ||
374 | "Mark Westcot Contact pinning\n" | ||
375 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" | ||
376 | "Steffen Hansen LDAP Lookup hansen@kde.org\n" ); | ||
377 | } | ||
378 | |||
379 | void KABCore::setContactSelected( const QString &uid ) | ||
380 | { | ||
381 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | ||
382 | if ( !mDetails->isHidden() ) | ||
383 | mDetails->setAddressee( addr ); | ||
384 | |||
385 | if ( !addr.isEmpty() ) { | ||
386 | emit contactSelected( addr.formattedName() ); | ||
387 | KABC::Picture pic = addr.photo(); | ||
388 | if ( pic.isIntern() ) { | ||
389 | //US emit contactSelected( pic.data() ); | ||
390 | //US instead use: | ||
391 | QPixmap px; | ||
392 | if (pic.data().isNull() != true) | ||
393 | { | ||
394 | px.convertFromImage(pic.data()); | ||
395 | } | ||
396 | |||
397 | emit contactSelected( px ); | ||
398 | } | ||
399 | } | ||
400 | |||
401 | |||
402 | mExtensionManager->setSelectionChanged(); | ||
403 | |||
404 | // update the actions | ||
405 | bool selected = !uid.isEmpty(); | ||
406 | |||
407 | if ( mReadWrite ) { | ||
408 | mActionCut->setEnabled( selected ); | ||
409 | mActionPaste->setEnabled( selected ); | ||
410 | } | ||
411 | |||
412 | mActionCopy->setEnabled( selected ); | ||
413 | mActionDelete->setEnabled( selected ); | ||
414 | mActionEditAddressee->setEnabled( selected ); | ||
415 | mActionMail->setEnabled( selected ); | ||
416 | mActionMailVCard->setEnabled( selected ); | ||
417 | mActionWhoAmI->setEnabled( selected ); | ||
418 | mActionCategories->setEnabled( selected ); | ||
419 | } | ||
420 | |||
421 | void KABCore::sendMail() | ||
422 | { | ||
423 | #ifndef KAB_EMBEDDED | ||
424 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | ||
425 | #else //KAB_EMBEDDED | ||
426 | qDebug("KABCore::sendMail() ust be fixed"); | ||
427 | #endif //KAB_EMBEDDED | ||
428 | } | ||
429 | |||
430 | void KABCore::sendMail( const QString& email ) | ||
431 | { | ||
432 | #ifndef KAB_EMBEDDED | ||
433 | kapp->invokeMailer( email, "" ); | ||
434 | #else //KAB_EMBEDDED | ||
435 | qDebug("KABCore::sendMail(const QString& email) ust be fixed"); | ||
436 | #endif //KAB_EMBEDDED | ||
437 | } | ||
438 | |||
439 | void KABCore::mailVCard() | ||
440 | { | ||
441 | #ifndef KAB_EMBEDDED | ||
442 | QStringList uids = mViewManager->selectedUids(); | ||
443 | if ( !uids.isEmpty() ) | ||
444 | mailVCard( uids ); | ||
445 | #else //KAB_EMBEDDED | ||
446 | qDebug("KABCore::mailVCard() must be fixed"); | ||
447 | #endif //KAB_EMBEDDED | ||
448 | } | ||
449 | |||
450 | void KABCore::mailVCard( const QStringList& uids ) | ||
451 | { | ||
452 | #ifndef KAB_EMBEDDED | ||
453 | QStringList urls; | ||
454 | |||
455 | // Create a temp dir, so that we can put the files in it with proper names | ||
456 | KTempFile tempDir; | ||
457 | if ( tempDir.status() != 0 ) { | ||
458 | kdWarning() << strerror( tempDir.status() ) << endl; | ||
459 | return; | ||
460 | } | ||
461 | |||
462 | QString dirName = tempDir.name(); | ||
463 | tempDir.unlink(); | ||
464 | QDir().mkdir( dirName, true ); | ||
465 | |||
466 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | ||
467 | KABC::Addressee a = mAddressBook->findByUid( *it ); | ||
468 | |||
469 | if ( a.isEmpty() ) | ||
470 | continue; | ||
471 | |||
472 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | ||
473 | |||
474 | QString fileName = dirName + "/" + name; | ||
475 | |||
476 | QFile outFile(fileName); | ||
477 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | ||
478 | KABC::VCardConverter converter; | ||
479 | QString vcard; | ||
480 | |||
481 | converter.addresseeToVCard( a, vcard ); | ||
482 | |||
483 | QTextStream t( &outFile ); // use a text stream | ||
484 | t.setEncoding( QTextStream::UnicodeUTF8 ); | ||
485 | t << vcard; | ||
486 | |||
487 | outFile.close(); | ||
488 | |||
489 | urls.append( fileName ); | ||
490 | } | ||
491 | } | ||
492 | |||
493 | kapp->invokeMailer( QString::null, QString::null, QString::null, | ||
494 | QString::null, // subject | ||
495 | QString::null, // body | ||
496 | QString::null, | ||
497 | urls ); // attachments | ||
498 | #else //KAB_EMBEDDED | ||
499 | qDebug("KABCore::mailVCard( must be fixed"); | ||
500 | #endif //KAB_EMBEDDED | ||
501 | |||
502 | } | ||
503 | |||
504 | void KABCore::browse( const QString& url ) | ||
505 | { | ||
506 | #ifndef KAB_EMBEDDED | ||
507 | kapp->invokeBrowser( url ); | ||
508 | #else //KAB_EMBEDDED | ||
509 | qDebug("KABCore::browse must be fixed"); | ||
510 | #endif //KAB_EMBEDDED | ||
511 | } | ||
512 | |||
513 | void KABCore::selectAllContacts() | ||
514 | { | ||
515 | mViewManager->setSelected( QString::null, true ); | ||
516 | } | ||
517 | |||
518 | void KABCore::deleteContacts() | ||
519 | { | ||
520 | QStringList uidList = mViewManager->selectedUids(); | ||
521 | deleteContacts( uidList ); | ||
522 | } | ||
523 | |||
524 | void KABCore::deleteContacts( const QStringList &uids ) | ||
525 | { | ||
526 | if ( uids.count() > 0 ) { | ||
527 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | ||
528 | UndoStack::instance()->push( command ); | ||
529 | RedoStack::instance()->clear(); | ||
530 | |||
531 | // now if we deleted anything, refresh | ||
532 | setContactSelected( QString::null ); | ||
533 | setModified( true ); | ||
534 | } | ||
535 | } | ||
536 | |||
537 | void KABCore::copyContacts() | ||
538 | { | ||
539 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | ||
540 | |||
541 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | ||
542 | |||
543 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | ||
544 | |||
545 | QClipboard *cb = QApplication::clipboard(); | ||
546 | cb->setText( clipText ); | ||
547 | } | ||
548 | |||
549 | void KABCore::cutContacts() | ||
550 | { | ||
551 | QStringList uidList = mViewManager->selectedUids(); | ||
552 | |||
553 | //US if ( uidList.size() > 0 ) { | ||
554 | if ( uidList.count() > 0 ) { | ||
555 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | ||
556 | UndoStack::instance()->push( command ); | ||
557 | RedoStack::instance()->clear(); | ||
558 | |||
559 | setModified( true ); | ||
560 | } | ||
561 | } | ||
562 | |||
563 | void KABCore::pasteContacts() | ||
564 | { | ||
565 | QClipboard *cb = QApplication::clipboard(); | ||
566 | |||
567 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | ||
568 | |||
569 | pasteContacts( list ); | ||
570 | } | ||
571 | |||
572 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | ||
573 | { | ||
574 | KABC::Resource *resource = requestResource( this ); | ||
575 | KABC::Addressee::List::Iterator it; | ||
576 | for ( it = list.begin(); it != list.end(); ++it ) | ||
577 | (*it).setResource( resource ); | ||
578 | |||
579 | PwPasteCommand *command = new PwPasteCommand( this, list ); | ||
580 | UndoStack::instance()->push( command ); | ||
581 | RedoStack::instance()->clear(); | ||
582 | |||
583 | setModified( true ); | ||
584 | } | ||
585 | |||
586 | void KABCore::setWhoAmI() | ||
587 | { | ||
588 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | ||
589 | |||
590 | if ( addrList.count() > 1 ) { | ||
591 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | ||
592 | return; | ||
593 | } | ||
594 | |||
595 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | ||
596 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | ||
597 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | ||
598 | } | ||
599 | |||
600 | void KABCore::setCategories() | ||
601 | { | ||
602 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | ||
603 | if ( !dlg.exec() ) | ||
604 | return; | ||
605 | |||
606 | bool merge = false; | ||
607 | QString msg = i18n( "Merge with existing categories?" ); | ||
608 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | ||
609 | merge = true; | ||
610 | |||
611 | QStringList categories = dlg.selectedCategories(); | ||
612 | |||
613 | QStringList uids = mViewManager->selectedUids(); | ||
614 | QStringList::Iterator it; | ||
615 | for ( it = uids.begin(); it != uids.end(); ++it ) { | ||
616 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | ||
617 | if ( !addr.isEmpty() ) { | ||
618 | if ( !merge ) | ||
619 | addr.setCategories( categories ); | ||
620 | else { | ||
621 | QStringList addrCategories = addr.categories(); | ||
622 | QStringList::Iterator catIt; | ||
623 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | ||
624 | if ( !addrCategories.contains( *catIt ) ) | ||
625 | addrCategories.append( *catIt ); | ||
626 | } | ||
627 | addr.setCategories( addrCategories ); | ||
628 | } | ||
629 | |||
630 | mAddressBook->insertAddressee( addr ); | ||
631 | } | ||
632 | } | ||
633 | |||
634 | if ( uids.count() > 0 ) | ||
635 | setModified( true ); | ||
636 | } | ||
637 | |||
638 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | ||
639 | { | ||
640 | mIncSearchWidget->setFields( fields ); | ||
641 | } | ||
642 | |||
643 | void KABCore::incrementalSearch( const QString& text ) | ||
644 | { | ||
645 | mViewManager->setSelected( QString::null, false ); | ||
646 | |||
647 | if ( !text.isEmpty() ) { | ||
648 | KABC::Field *field = mIncSearchWidget->currentField(); | ||
649 | |||
650 | QString pattern = text.lower(); | ||
651 | |||
652 | #if KDE_VERSION >= 319 | ||
653 | KABC::AddresseeList list( mAddressBook->allAddressees() ); | ||
654 | if ( field ) { | ||
655 | list.sortByField( field ); | ||
656 | KABC::AddresseeList::Iterator it; | ||
657 | for ( it = list.begin(); it != list.end(); ++it ) { | ||
658 | if ( field->value( *it ).lower().startsWith( pattern ) ) { | ||
659 | mViewManager->setSelected( (*it).uid(), true ); | ||
660 | return; | ||
661 | } | ||
662 | } | ||
663 | } else { | ||
664 | KABC::AddresseeList::Iterator it; | ||
665 | for ( it = list.begin(); it != list.end(); ++it ) { | ||
666 | KABC::Field::List fieldList = mIncSearchWidget->fields(); | ||
667 | KABC::Field::List::ConstIterator fieldIt; | ||
668 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | ||
669 | if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { | ||
670 | mViewManager->setSelected( (*it).uid(), true ); | ||
671 | return; | ||
672 | } | ||
673 | } | ||
674 | } | ||
675 | } | ||
676 | #else | ||
677 | KABC::AddressBook::Iterator it; | ||
678 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | ||
679 | if ( field ) { | ||
680 | if ( field->value( *it ).lower().startsWith( pattern ) ) { | ||
681 | mViewManager->setSelected( (*it).uid(), true ); | ||
682 | return; | ||
683 | } | ||
684 | } else { | ||
685 | KABC::Field::List fieldList = mIncSearchWidget->fields(); | ||
686 | KABC::Field::List::ConstIterator fieldIt; | ||
687 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | ||
688 | if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { | ||
689 | mViewManager->setSelected( (*it).uid(), true ); | ||
690 | return; | ||
691 | } | ||
692 | } | ||
693 | } | ||
694 | } | ||
695 | #endif | ||
696 | } | ||
697 | } | ||
698 | |||
699 | void KABCore::setModified() | ||
700 | { | ||
701 | setModified( true ); | ||
702 | } | ||
703 | |||
704 | void KABCore::setModifiedWOrefresh() | ||
705 | { | ||
706 | // qDebug("KABCore::setModifiedWOrefresh() "); | ||
707 | mModified = true; | ||
708 | mActionSave->setEnabled( mModified ); | ||
709 | #ifdef DESKTOP_VERSION | ||
710 | mDetails->refreshView(); | ||
711 | #endif | ||
712 | |||
713 | } | ||
714 | void KABCore::setModified( bool modified ) | ||
715 | { | ||
716 | mModified = modified; | ||
717 | mActionSave->setEnabled( mModified ); | ||
718 | |||
719 | if ( modified ) | ||
720 | mJumpButtonBar->recreateButtons(); | ||
721 | |||
722 | mViewManager->refreshView(); | ||
723 | mDetails->refreshView(); | ||
724 | |||
725 | } | ||
726 | |||
727 | bool KABCore::modified() const | ||
728 | { | ||
729 | return mModified; | ||
730 | } | ||
731 | |||
732 | void KABCore::contactModified( const KABC::Addressee &addr ) | ||
733 | { | ||
734 | |||
735 | Command *command = 0; | ||
736 | QString uid; | ||
737 | |||
738 | // check if it exists already | ||
739 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | ||
740 | if ( origAddr.isEmpty() ) | ||
741 | command = new PwNewCommand( mAddressBook, addr ); | ||
742 | else { | ||
743 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | ||
744 | uid = addr.uid(); | ||
745 | } | ||
746 | |||
747 | UndoStack::instance()->push( command ); | ||
748 | RedoStack::instance()->clear(); | ||
749 | |||
750 | setModified( true ); | ||
751 | } | ||
752 | |||
753 | void KABCore::newContact() | ||
754 | { | ||
755 | AddresseeEditorDialog *dialog = 0; | ||
756 | |||
757 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | ||
758 | |||
759 | QPtrList<KRES::Resource> kresResources; | ||
760 | QPtrListIterator<KABC::Resource> it( kabcResources ); | ||
761 | KABC::Resource *resource; | ||
762 | while ( ( resource = it.current() ) != 0 ) { | ||
763 | ++it; | ||
764 | if ( !resource->readOnly() ) { | ||
765 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | ||
766 | if ( res ) | ||
767 | kresResources.append( res ); | ||
768 | } | ||
769 | } | ||
770 | |||
771 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | ||
772 | resource = static_cast<KABC::Resource*>( res ); | ||
773 | |||
774 | if ( resource ) { | ||
775 | KABC::Addressee addr; | ||
776 | addr.setResource( resource ); | ||
777 | dialog = createAddresseeEditorDialog( this ); | ||
778 | dialog->setAddressee( addr ); | ||
779 | |||
780 | } else | ||
781 | return; | ||
782 | |||
783 | mEditorDict.insert( dialog->addressee().uid(), dialog ); | ||
784 | |||
785 | dialog->show(); | ||
786 | |||
787 | } | ||
788 | |||
789 | void KABCore::addEmail( QString aStr ) | ||
790 | { | ||
791 | #ifndef KAB_EMBEDDED | ||
792 | QString fullName, email; | ||
793 | |||
794 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | ||
795 | |||
796 | // Try to lookup the addressee matching the email address | ||
797 | bool found = false; | ||
798 | QStringList emailList; | ||
799 | KABC::AddressBook::Iterator it; | ||
800 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | ||
801 | emailList = (*it).emails(); | ||
802 | if ( emailList.contains( email ) > 0 ) { | ||
803 | found = true; | ||
804 | (*it).setNameFromString( fullName ); | ||
805 | editContact( (*it).uid() ); | ||
806 | } | ||
807 | } | ||
808 | |||
809 | if ( !found ) { | ||
810 | KABC::Addressee addr; | ||
811 | addr.setNameFromString( fullName ); | ||
812 | addr.insertEmail( email, true ); | ||
813 | |||
814 | mAddressBook->insertAddressee( addr ); | ||
815 | mViewManager->refreshView( addr.uid() ); | ||
816 | editContact( addr.uid() ); | ||
817 | } | ||
818 | #else //KAB_EMBEDDED | ||
819 | qDebug("KABCore::addEmail finsih method"); | ||
820 | #endif //KAB_EMBEDDED | ||
821 | } | ||
822 | |||
823 | void KABCore::importVCard( const KURL &url, bool showPreview ) | ||
824 | { | ||
825 | mXXPortManager->importVCard( url, showPreview ); | ||
826 | } | ||
827 | |||
828 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | ||
829 | { | ||
830 | mXXPortManager->importVCard( vCard, showPreview ); | ||
831 | } | ||
832 | |||
833 | //US added a second method without defaultparameter | ||
834 | void KABCore::editContact2() { | ||
835 | editContact( QString::null ); | ||
836 | } | ||
837 | |||
838 | void KABCore::editContact( const QString &uid ) | ||
839 | { | ||
840 | |||
841 | if ( mExtensionManager->isQuickEditVisible() ) | ||
842 | return; | ||
843 | |||
844 | // First, locate the contact entry | ||
845 | QString localUID = uid; | ||
846 | if ( localUID.isNull() ) { | ||
847 | QStringList uidList = mViewManager->selectedUids(); | ||
848 | if ( uidList.count() > 0 ) | ||
849 | localUID = *( uidList.at( 0 ) ); | ||
850 | } | ||
851 | |||
852 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | ||
853 | if ( !addr.isEmpty() ) { | ||
854 | AddresseeEditorDialog *dialog = mEditorDict.find( addr.uid() ); | ||
855 | if ( !dialog ) { | ||
856 | dialog = createAddresseeEditorDialog( this ); | ||
857 | |||
858 | mEditorDict.insert( addr.uid(), dialog ); | ||
859 | |||
860 | dialog->setAddressee( addr ); | ||
861 | } | ||
862 | |||
863 | dialog->raise(); | ||
864 | dialog->show(); | ||
865 | } | ||
866 | } | ||
867 | |||
868 | void KABCore::save() | ||
869 | { | ||
870 | if ( !mModified ) | ||
871 | return; | ||
872 | QString text = i18n( "There was an error while attempting to save\n the " | ||
873 | "address book. Please check that some \nother application is " | ||
874 | "not using it. " ); | ||
875 | statusMessage(i18n("Saving addressbook ... ")); | ||
876 | #ifndef KAB_EMBEDDED | ||
877 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | ||
878 | if ( !b || !b->save() ) { | ||
879 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | ||
880 | } | ||
881 | #else //KAB_EMBEDDED | ||
882 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | ||
883 | if ( !b || !b->save() ) { | ||
884 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | ||
885 | } | ||
886 | #endif //KAB_EMBEDDED | ||
887 | |||
888 | statusMessage(i18n("Addressbook saved!")); | ||
889 | setModified( false ); | ||
890 | } | ||
891 | |||
892 | void KABCore::statusMessage(QString mess , int time ) | ||
893 | { | ||
894 | //topLevelWidget()->setCaption( mess ); | ||
895 | // pending setting timer to revome message | ||
896 | } | ||
897 | void KABCore::undo() | ||
898 | { | ||
899 | UndoStack::instance()->undo(); | ||
900 | |||
901 | // Refresh the view | ||
902 | mViewManager->refreshView(); | ||
903 | } | ||
904 | |||
905 | void KABCore::redo() | ||
906 | { | ||
907 | RedoStack::instance()->redo(); | ||
908 | |||
909 | // Refresh the view | ||
910 | mViewManager->refreshView(); | ||
911 | } | ||
912 | |||
913 | void KABCore::setJumpButtonBarVisible( bool visible ) | ||
914 | { | ||
915 | if ( visible ) | ||
916 | mJumpButtonBar->show(); | ||
917 | else | ||
918 | mJumpButtonBar->hide(); | ||
919 | } | ||
920 | void KABCore::setDetailsToState() | ||
921 | { | ||
922 | setDetailsVisible( mActionDetails->isChecked() ); | ||
923 | } | ||
924 | |||
925 | void KABCore::setDetailsVisible( bool visible ) | ||
926 | { | ||
927 | if ( visible ) | ||
928 | mDetails->show(); | ||
929 | else | ||
930 | mDetails->hide(); | ||
931 | } | ||
932 | |||
933 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | ||
934 | { | ||
935 | |||
936 | if ( list.count() != 0 ) { | ||
937 | KABC::Addressee::List::ConstIterator it; | ||
938 | for ( it = list.begin(); it != list.end(); ++it ) | ||
939 | mAddressBook->insertAddressee( *it ); | ||
940 | if ( list.count() > 1 ) | ||
941 | setModified(); | ||
942 | else | ||
943 | setModifiedWOrefresh(); | ||
944 | } | ||
945 | if ( list.count() == 0 ) | ||
946 | mViewManager->refreshView(); | ||
947 | else | ||
948 | mViewManager->refreshView( list[ 0 ].uid() ); | ||
949 | |||
950 | |||
951 | |||
952 | } | ||
953 | |||
954 | QString KABCore::getNameByPhone( const QString &phone ) | ||
955 | { | ||
956 | #ifndef KAB_EMBEDDED | ||
957 | QRegExp r( "[/*/-/ ]" ); | ||
958 | QString localPhone( phone ); | ||
959 | |||
960 | bool found = false; | ||
961 | QString ownerName = ""; | ||
962 | KABC::AddressBook::Iterator iter; | ||
963 | KABC::PhoneNumber::List::Iterator phoneIter; | ||
964 | KABC::PhoneNumber::List phoneList; | ||
965 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | ||
966 | phoneList = (*iter).phoneNumbers(); | ||
967 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | ||
968 | ++phoneIter) { | ||
969 | // Get rid of separator chars so just the numbers are compared. | ||
970 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | ||
971 | ownerName = (*iter).formattedName(); | ||
972 | found = true; | ||
973 | } | ||
974 | } | ||
975 | } | ||
976 | |||
977 | return ownerName; | ||
978 | #else //KAB_EMBEDDED | ||
979 | qDebug("KABCore::getNameByPhone finsih method"); | ||
980 | return ""; | ||
981 | #endif //KAB_EMBEDDED | ||
982 | |||
983 | } | ||
984 | |||
985 | void KABCore::openConfigDialog() | ||
986 | { | ||
987 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | ||
988 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | ||
989 | ConfigureDialog->addModule(kabcfg ); | ||
990 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | ||
991 | this, SLOT( configurationChanged() ) ); | ||
992 | connect( ConfigureDialog, SIGNAL( okClicked() ), | ||
993 | this, SLOT( configurationChanged() ) ); | ||
994 | saveSettings(); | ||
995 | ConfigureDialog->exec(); | ||
996 | delete ConfigureDialog; | ||
997 | } | ||
998 | |||
999 | void KABCore::openLDAPDialog() | ||
1000 | { | ||
1001 | #ifndef KAB_EMBEDDED | ||
1002 | if ( !mLdapSearchDialog ) { | ||
1003 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | ||
1004 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | ||
1005 | SLOT( refreshView() ) ); | ||
1006 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | ||
1007 | SLOT( setModified() ) ); | ||
1008 | } else | ||
1009 | mLdapSearchDialog->restoreSettings(); | ||
1010 | |||
1011 | if ( mLdapSearchDialog->isOK() ) | ||
1012 | mLdapSearchDialog->exec(); | ||
1013 | #else //KAB_EMBEDDED | ||
1014 | qDebug("KABCore::openLDAPDialog() finsih method"); | ||
1015 | #endif //KAB_EMBEDDED | ||
1016 | } | ||
1017 | |||
1018 | void KABCore::print() | ||
1019 | { | ||
1020 | #ifndef KAB_EMBEDDED | ||
1021 | KPrinter printer; | ||
1022 | if ( !printer.setup( this ) ) | ||
1023 | return; | ||
1024 | |||
1025 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | ||
1026 | mViewManager->selectedUids(), this ); | ||
1027 | |||
1028 | wizard.exec(); | ||
1029 | #else //KAB_EMBEDDED | ||
1030 | qDebug("KABCore::print() finsih method"); | ||
1031 | #endif //KAB_EMBEDDED | ||
1032 | |||
1033 | } | ||
1034 | |||
1035 | |||
1036 | void KABCore::addGUIClient( KXMLGUIClient *client ) | ||
1037 | { | ||
1038 | if ( mGUIClient ) | ||
1039 | mGUIClient->insertChildClient( client ); | ||
1040 | else | ||
1041 | KMessageBox::error( this, "no KXMLGUICLient"); | ||
1042 | } | ||
1043 | |||
1044 | |||
1045 | void KABCore::configurationChanged() | ||
1046 | { | ||
1047 | mExtensionManager->reconfigure(); | ||
1048 | } | ||
1049 | |||
1050 | void KABCore::addressBookChanged() | ||
1051 | { | ||
1052 | #ifndef KAB_EMBEDDED | ||
1053 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | ||
1054 | while ( it.current() ) { | ||
1055 | if ( it.current()->dirty() ) { | ||
1056 | QString text = i18n( "Data has been changed externally. Unsaved " | ||
1057 | "changes will be lost." ); | ||
1058 | KMessageBox::information( this, text ); | ||
1059 | } | ||
1060 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | ||
1061 | ++it; | ||
1062 | } | ||
1063 | |||
1064 | mViewManager->refreshView(); | ||
1065 | #else //KAB_EMBEDDED | ||
1066 | qDebug("KABCore::addressBookChanged() finsih method"); | ||
1067 | #endif //KAB_EMBEDDED | ||
1068 | } | ||
1069 | |||
1070 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | ||
1071 | const char *name ) | ||
1072 | { | ||
1073 | AddresseeEditorDialog *dialog = new AddresseeEditorDialog( this, parent, | ||
1074 | name ? name : "editorDialog" ); | ||
1075 | |||
1076 | //US | ||
1077 | dialog->setMaximumSize( 640, 480 ); | ||
1078 | dialog->showMaximized(); | ||
1079 | |||
1080 | connect( dialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | ||
1081 | SLOT( contactModified( const KABC::Addressee& ) ) ); | ||
1082 | connect( dialog, SIGNAL( editorDestroyed( const QString& ) ), | ||
1083 | SLOT( slotEditorDestroyed( const QString& ) ) ); | ||
1084 | |||
1085 | return dialog; | ||
1086 | } | ||
1087 | |||
1088 | void KABCore::slotEditorDestroyed( const QString &uid ) | ||
1089 | { | ||
1090 | mEditorDict.remove( uid ); | ||
1091 | } | ||
1092 | |||
1093 | void KABCore::initGUI() | ||
1094 | { | ||
1095 | #ifndef KAB_EMBEDDED | ||
1096 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | ||
1097 | topLayout->setSpacing( KDialogBase::spacingHint() ); | ||
1098 | |||
1099 | mExtensionBarSplitter = new QSplitter( this ); | ||
1100 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | ||
1101 | |||
1102 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | ||
1103 | |||
1104 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | ||
1105 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | ||
1106 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | ||
1107 | SLOT( incrementalSearch( const QString& ) ) ); | ||
1108 | |||
1109 | mViewManager = new ViewManager( this, viewSpace ); | ||
1110 | viewSpace->setStretchFactor( mViewManager, 1 ); | ||
1111 | |||
1112 | mDetails = new ViewContainer( mDetailsSplitter ); | ||
1113 | |||
1114 | mJumpButtonBar = new JumpButtonBar( this, this ); | ||
1115 | |||
1116 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | ||
1117 | |||
1118 | topLayout->addWidget( mExtensionBarSplitter ); | ||
1119 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | ||
1120 | topLayout->addWidget( mJumpButtonBar ); | ||
1121 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); | ||
1122 | |||
1123 | mXXPortManager = new XXPortManager( this, this ); | ||
1124 | |||
1125 | #else //KAB_EMBEDDED | ||
1126 | //US initialize viewMenu before settingup viewmanager. | ||
1127 | // Viewmanager needs this menu to plugin submenues. | ||
1128 | viewMenu = new QPopupMenu( this ); | ||
1129 | settingsMenu = new QPopupMenu( this ); | ||
1130 | //filterMenu = new QPopupMenu( this ); | ||
1131 | ImportMenu = new QPopupMenu( this ); | ||
1132 | ExportMenu = new QPopupMenu( this ); | ||
1133 | |||
1134 | |||
1135 | //US since we have no splitter for the embedded system, setup | ||
1136 | // a layout with two frames. One left and one right. | ||
1137 | |||
1138 | QBoxLayout *topLayout; | ||
1139 | |||
1140 | // = new QHBoxLayout( this ); | ||
1141 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | ||
1142 | |||
1143 | // QWidget *mainBox = new QWidget( this ); | ||
1144 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | ||
1145 | |||
1146 | |||
1147 | if ( QApplication::desktop()->width() > 480 ) { | ||
1148 | topLayout = new QHBoxLayout( this ); | ||
1149 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | ||
1150 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | ||
1151 | } else { | ||
1152 | |||
1153 | topLayout = new QVBoxLayout( this ); | ||
1154 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | ||
1155 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | ||
1156 | } | ||
1157 | |||
1158 | topLayout->addWidget(mMiniSplitter ); | ||
1159 | mViewManager = new ViewManager( this, mMiniSplitter ); | ||
1160 | mDetails = new ViewContainer( mMiniSplitter ); | ||
1161 | |||
1162 | |||
1163 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | ||
1164 | |||
1165 | //eh->hide(); | ||
1166 | // topLayout->addWidget(mExtensionManager ); | ||
1167 | |||
1168 | |||
1169 | /*US | ||
1170 | #ifndef KAB_NOSPLITTER | ||
1171 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | ||
1172 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | ||
1173 | topLayout->setSpacing( 10 ); | ||
1174 | |||
1175 | mDetailsSplitter = new QSplitter( this ); | ||
1176 | |||
1177 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | ||
1178 | |||
1179 | mViewManager = new ViewManager( this, viewSpace ); | ||
1180 | viewSpace->setStretchFactor( mViewManager, 1 ); | ||
1181 | |||
1182 | mDetails = new ViewContainer( mDetailsSplitter ); | ||
1183 | |||
1184 | topLayout->addWidget( mDetailsSplitter ); | ||
1185 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | ||
1186 | #else //KAB_NOSPLITTER | ||
1187 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | ||
1188 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | ||
1189 | topLayout->setSpacing( 10 ); | ||
1190 | |||
1191 | // mDetailsSplitter = new QSplitter( this ); | ||
1192 | |||
1193 | QVBox *viewSpace = new QVBox( this ); | ||
1194 | |||
1195 | mViewManager = new ViewManager( this, viewSpace ); | ||
1196 | viewSpace->setStretchFactor( mViewManager, 1 ); | ||
1197 | |||
1198 | mDetails = new ViewContainer( this ); | ||
1199 | |||
1200 | topLayout->addWidget( viewSpace ); | ||
1201 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | ||
1202 | topLayout->addWidget( mDetails ); | ||
1203 | #endif //KAB_NOSPLITTER | ||
1204 | */ | ||
1205 | |||
1206 | |||
1207 | #endif //KAB_EMBEDDED | ||
1208 | initActions(); | ||
1209 | |||
1210 | #ifdef KAB_EMBEDDED | ||
1211 | addActionsManually(); | ||
1212 | //US make sure the export and import menues are initialized before creating the xxPortManager. | ||
1213 | mXXPortManager = new XXPortManager( this, this ); | ||
1214 | |||
1215 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | ||
1216 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | ||
1217 | // mActionQuit->plug ( mMainWindow->toolBar()); | ||
1218 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | ||
1219 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | ||
1220 | // mIncSearchWidget->hide(); | ||
1221 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | ||
1222 | SLOT( incrementalSearch( const QString& ) ) ); | ||
1223 | |||
1224 | |||
1225 | mJumpButtonBar = new JumpButtonBar( this, this ); | ||
1226 | |||
1227 | topLayout->addWidget( mJumpButtonBar ); | ||
1228 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | ||
1229 | |||
1230 | // mMainWindow->getIconToolBar()->raise(); | ||
1231 | |||
1232 | #endif //KAB_EMBEDDED | ||
1233 | |||
1234 | } | ||
1235 | void KABCore::initActions() | ||
1236 | { | ||
1237 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | ||
1238 | |||
1239 | #ifndef KAB_EMBEDDED | ||
1240 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | ||
1241 | SLOT( clipboardDataChanged() ) ); | ||
1242 | #endif //KAB_EMBEDDED | ||
1243 | |||
1244 | // file menu | ||
1245 | if ( mIsPart ) { | ||
1246 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, | ||
1247 | SLOT( sendMail() ), actionCollection(), | ||
1248 | "kaddressbook_mail" ); | ||
1249 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, | ||
1250 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); | ||
1251 | |||
1252 | } else { | ||
1253 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | ||
1254 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | ||
1255 | } | ||
1256 | |||
1257 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | ||
1258 | SLOT( save() ), actionCollection(), "file_sync" ); | ||
1259 | |||
1260 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | ||
1261 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | ||
1262 | |||
1263 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | ||
1264 | this, SLOT( mailVCard() ), | ||
1265 | actionCollection(), "file_mail_vcard"); | ||
1266 | |||
1267 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | ||
1268 | this, SLOT( editContact2() ), | ||
1269 | actionCollection(), "file_properties" ); | ||
1270 | |||
1271 | #ifdef KAB_EMBEDDED | ||
1272 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | ||
1273 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | ||
1274 | mMainWindow, SLOT( exit() ), | ||
1275 | actionCollection(), "quit" ); | ||
1276 | #endif //KAB_EMBEDDED | ||
1277 | |||
1278 | // edit menu | ||
1279 | if ( mIsPart ) { | ||
1280 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | ||
1281 | SLOT( copyContacts() ), actionCollection(), | ||
1282 | "kaddressbook_copy" ); | ||
1283 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | ||
1284 | SLOT( cutContacts() ), actionCollection(), | ||
1285 | "kaddressbook_cut" ); | ||
1286 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | ||
1287 | SLOT( pasteContacts() ), actionCollection(), | ||
1288 | "kaddressbook_paste" ); | ||
1289 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | ||
1290 | SLOT( selectAllContacts() ), actionCollection(), | ||
1291 | "kaddressbook_select_all" ); | ||
1292 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | ||
1293 | SLOT( undo() ), actionCollection(), | ||
1294 | "kaddressbook_undo" ); | ||
1295 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | ||
1296 | this, SLOT( redo() ), actionCollection(), | ||
1297 | "kaddressbook_redo" ); | ||
1298 | } else { | ||
1299 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | ||
1300 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | ||
1301 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | ||
1302 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | ||
1303 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | ||
1304 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | ||
1305 | } | ||
1306 | |||
1307 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | ||
1308 | Key_Delete, this, SLOT( deleteContacts() ), | ||
1309 | actionCollection(), "edit_delete" ); | ||
1310 | |||
1311 | mActionUndo->setEnabled( false ); | ||
1312 | mActionRedo->setEnabled( false ); | ||
1313 | |||
1314 | // settings menu | ||
1315 | #ifdef KAB_EMBEDDED | ||
1316 | //US special menuentry to configure the addressbook resources. On KDE | ||
1317 | // you do that through the control center !!! | ||
1318 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | ||
1319 | SLOT( configureResources() ), actionCollection(), | ||
1320 | "kaddressbook_configure_resources" ); | ||
1321 | #endif //KAB_EMBEDDED | ||
1322 | |||
1323 | if ( mIsPart ) { | ||
1324 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | ||
1325 | SLOT( openConfigDialog() ), actionCollection(), | ||
1326 | "kaddressbook_configure" ); | ||
1327 | |||
1328 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | ||
1329 | this, SLOT( configureKeyBindings() ), actionCollection(), | ||
1330 | "kaddressbook_configure_shortcuts" ); | ||
1331 | #ifdef KAB_EMBEDDED | ||
1332 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | ||
1333 | #endif //KAB_EMBEDDED | ||
1334 | |||
1335 | } else { | ||
1336 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | ||
1337 | |||
1338 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | ||
1339 | } | ||
1340 | |||
1341 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | ||
1342 | actionCollection(), "options_show_jump_bar" ); | ||
1343 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); | ||
1344 | |||
1345 | mActionDetails = new KToggleAction( i18n( "Show Details" ), 0, 0, | ||
1346 | actionCollection(), "options_show_details" ); | ||
1347 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | ||
1348 | |||
1349 | // misc | ||
1350 | // only enable LDAP lookup if we can handle the protocol | ||
1351 | #ifndef KAB_EMBEDDED | ||
1352 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | ||
1353 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | ||
1354 | this, SLOT( openLDAPDialog() ), actionCollection(), | ||
1355 | "ldap_lookup" ); | ||
1356 | } | ||
1357 | #else //KAB_EMBEDDED | ||
1358 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | ||
1359 | #endif //KAB_EMBEDDED | ||
1360 | |||
1361 | |||
1362 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | ||
1363 | SLOT( setWhoAmI() ), actionCollection(), | ||
1364 | "set_personal" ); | ||
1365 | |||
1366 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | ||
1367 | SLOT( setCategories() ), actionCollection(), | ||
1368 | "edit_set_categories" ); | ||
1369 | |||
1370 | #ifdef KAB_EMBEDDED | ||
1371 | |||
1372 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | ||
1373 | this, SLOT( createAboutData() ), actionCollection(), | ||
1374 | "kaddressbook_about_data" ); | ||
1375 | #endif //KAB_EMBEDDED | ||
1376 | |||
1377 | clipboardDataChanged(); | ||
1378 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | ||
1379 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | ||
1380 | } | ||
1381 | |||
1382 | //US we need this function, to plug all actions into the correct menues. | ||
1383 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | ||
1384 | void KABCore::addActionsManually() | ||
1385 | { | ||
1386 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | ||
1387 | |||
1388 | #ifdef KAB_EMBEDDED | ||
1389 | QPopupMenu *fileMenu = new QPopupMenu( this ); | ||
1390 | QPopupMenu *editMenu = new QPopupMenu( this ); | ||
1391 | QPopupMenu *helpMenu = new QPopupMenu( this ); | ||
1392 | |||
1393 | KToolBar* tb = mMainWindow->toolBar(); | ||
1394 | |||
1395 | #ifdef DESKTOP_VERSION | ||
1396 | QMenuBar* mb = mMainWindow->menuBar(); | ||
1397 | |||
1398 | //US setup menubar. | ||
1399 | //Disable the following block if you do not want to have a menubar. | ||
1400 | mb->insertItem( "&File", fileMenu ); | ||
1401 | mb->insertItem( "&Edit", editMenu ); | ||
1402 | mb->insertItem( "&View", viewMenu ); | ||
1403 | mb->insertItem( "&Settings", settingsMenu ); | ||
1404 | mb->insertItem( "&Help", helpMenu ); | ||
1405 | mIncSearchWidget = new IncSearchWidget( tb ); | ||
1406 | // tb->insertWidget(-1, 0, mIncSearchWidget); | ||
1407 | |||
1408 | #else | ||
1409 | //US setup toolbar | ||
1410 | QMenuBar *menuBarTB = new QMenuBar( tb ); | ||
1411 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | ||
1412 | menuBarTB->insertItem( "ME", popupBarTB); | ||
1413 | tb->insertWidget(-1, 0, menuBarTB); | ||
1414 | mIncSearchWidget = new IncSearchWidget( tb ); | ||
1415 | |||
1416 | tb->enableMoving(false); | ||
1417 | popupBarTB->insertItem( "&File", fileMenu ); | ||
1418 | popupBarTB->insertItem( "&Edit", editMenu ); | ||
1419 | popupBarTB->insertItem( "&View", viewMenu ); | ||
1420 | popupBarTB->insertItem( "&Settings", settingsMenu ); | ||
1421 | mViewManager->getFilterAction()->plug ( popupBarTB); | ||
1422 | popupBarTB->insertItem( "&Help", helpMenu ); | ||
1423 | if (QApplication::desktop()->width() > 320 ) { | ||
1424 | // mViewManager->getFilterAction()->plug ( tb); | ||
1425 | } | ||
1426 | #endif | ||
1427 | // mActionQuit->plug ( mMainWindow->toolBar()); | ||
1428 | |||
1429 | |||
1430 | |||
1431 | //US Now connect the actions with the menue entries. | ||
1432 | mActionPrint->plug( fileMenu ); | ||
1433 | mActionMail->plug( fileMenu ); | ||
1434 | fileMenu->insertSeparator(); | ||
1435 | |||
1436 | mActionNewContact->plug( fileMenu ); | ||
1437 | mActionNewContact->plug( tb ); | ||
1438 | |||
1439 | mActionEditAddressee->plug( fileMenu ); | ||
1440 | fileMenu->insertSeparator(); | ||
1441 | mActionSave->plug( fileMenu ); | ||
1442 | fileMenu->insertItem( "&Import", ImportMenu ); | ||
1443 | fileMenu->insertItem( "&Emport", ExportMenu ); | ||
1444 | fileMenu->insertSeparator(); | ||
1445 | mActionMailVCard->plug( fileMenu ); | ||
1446 | fileMenu->insertSeparator(); | ||
1447 | mActionQuit->plug( fileMenu ); | ||
1448 | |||
1449 | |||
1450 | // edit menu | ||
1451 | mActionUndo->plug( editMenu ); | ||
1452 | mActionRedo->plug( editMenu ); | ||
1453 | editMenu->insertSeparator(); | ||
1454 | mActionCut->plug( editMenu ); | ||
1455 | mActionCopy->plug( editMenu ); | ||
1456 | mActionPaste->plug( editMenu ); | ||
1457 | mActionDelete->plug( editMenu ); | ||
1458 | editMenu->insertSeparator(); | ||
1459 | mActionSelectAll->plug( editMenu ); | ||
1460 | |||
1461 | |||
1462 | // settings menu | ||
1463 | //US special menuentry to configure the addressbook resources. On KDE | ||
1464 | // you do that through the control center !!! | ||
1465 | mActionConfigResources->plug( settingsMenu ); | ||
1466 | settingsMenu->insertSeparator(); | ||
1467 | |||
1468 | mActionConfigKAddressbook->plug( settingsMenu ); | ||
1469 | |||
1470 | if ( mIsPart ) { | ||
1471 | mActionConfigShortcuts->plug( settingsMenu ); | ||
1472 | mActionConfigureToolbars->plug( settingsMenu ); | ||
1473 | |||
1474 | } else { | ||
1475 | mActionKeyBindings->plug( settingsMenu ); | ||
1476 | } | ||
1477 | |||
1478 | settingsMenu->insertSeparator(); | ||
1479 | |||
1480 | mActionJumpBar->plug( settingsMenu ); | ||
1481 | mActionDetails->plug( settingsMenu ); | ||
1482 | settingsMenu->insertSeparator(); | ||
1483 | |||
1484 | mActionWhoAmI->plug( settingsMenu ); | ||
1485 | mActionCategories->plug( settingsMenu ); | ||
1486 | |||
1487 | mActionAboutKAddressbook->plug( helpMenu ); | ||
1488 | |||
1489 | if (QApplication::desktop()->width() > 320 ) { | ||
1490 | |||
1491 | mActionEditAddressee->plug( tb ); | ||
1492 | mActionSave->plug( tb ); | ||
1493 | mViewManager->getFilterAction()->plug ( tb); | ||
1494 | if (QApplication::desktop()->width() > 480 ) | ||
1495 | mActionDelete->plug( tb ); | ||
1496 | } | ||
1497 | mActionQuit->plug ( tb ); | ||
1498 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | ||
1499 | |||
1500 | //US link the searchwidget first to this. | ||
1501 | // The real linkage to the toolbar happens later. | ||
1502 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | ||
1503 | //US tb->insertItem( mIncSearchWidget ); | ||
1504 | /*US | ||
1505 | mIncSearchWidget = new IncSearchWidget( tb ); | ||
1506 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | ||
1507 | SLOT( incrementalSearch( const QString& ) ) ); | ||
1508 | |||
1509 | mJumpButtonBar = new JumpButtonBar( this, this ); | ||
1510 | |||
1511 | //US topLayout->addWidget( mJumpButtonBar ); | ||
1512 | this->layout()->add( mJumpButtonBar ); | ||
1513 | */ | ||
1514 | |||
1515 | #endif //KAB_EMBEDDED | ||
1516 | } | ||
1517 | |||
1518 | |||
1519 | |||
1520 | void KABCore::clipboardDataChanged() | ||
1521 | { | ||
1522 | |||
1523 | if ( mReadWrite ) | ||
1524 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | ||
1525 | |||
1526 | } | ||
1527 | |||
1528 | void KABCore::updateActionMenu() | ||
1529 | { | ||
1530 | UndoStack *undo = UndoStack::instance(); | ||
1531 | RedoStack *redo = RedoStack::instance(); | ||
1532 | |||
1533 | if ( undo->isEmpty() ) | ||
1534 | mActionUndo->setText( i18n( "Undo" ) ); | ||
1535 | else | ||
1536 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | ||
1537 | |||
1538 | mActionUndo->setEnabled( !undo->isEmpty() ); | ||
1539 | |||
1540 | if ( !redo->top() ) | ||
1541 | mActionRedo->setText( i18n( "Redo" ) ); | ||
1542 | else | ||
1543 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | ||
1544 | |||
1545 | mActionRedo->setEnabled( !redo->isEmpty() ); | ||
1546 | } | ||
1547 | |||
1548 | void KABCore::configureKeyBindings() | ||
1549 | { | ||
1550 | #ifndef KAB_EMBEDDED | ||
1551 | KKeyDialog::configure( actionCollection(), true ); | ||
1552 | #else //KAB_EMBEDDED | ||
1553 | qDebug("KABCore::configureKeyBindings() not implemented"); | ||
1554 | #endif //KAB_EMBEDDED | ||
1555 | } | ||
1556 | |||
1557 | #ifdef KAB_EMBEDDED | ||
1558 | void KABCore::configureResources() | ||
1559 | { | ||
1560 | KRES::KCMKResources dlg( this, "" , 0 ); | ||
1561 | |||
1562 | if ( !dlg.exec() ) | ||
1563 | return; | ||
1564 | } | ||
1565 | #endif //KAB_EMBEDDED | ||
1566 | |||
1567 | |||
1568 | |||
1569 | #ifndef KAB_EMBEDDED | ||
1570 | #include "kabcore.moc" | ||
1571 | #endif //KAB_EMBEDDED | ||