-rw-r--r-- | kaddressbook/kabcore.cpp | 130 | ||||
-rw-r--r-- | kaddressbook/kabcore.h | 7 |
2 files changed, 96 insertions, 41 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 96603e6..6807bed 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -180,42 +180,34 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, "X-Children", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, "X-FreeBusyUrl", "KADDRESSBOOK" ); initGUI(); mIncSearchWidget->setFocus(); connect( mViewManager, SIGNAL( selected( const QString& ) ), SLOT( setContactSelected( const QString& ) ) ); - - //small devices show only the details view. bigger devices can edit the entry - if (KGlobal::getDesktopSize() > KGlobal::Small ) { - connect( mViewManager, SIGNAL( executed( const QString& ) ), - SLOT( editContact( const QString& ) ) ); - } - else - { connect( mViewManager, SIGNAL( executed( const QString& ) ), - SLOT( showContact( const QString& ) ) ); - } + SLOT( executeContact( const QString& ) ) ); connect( mViewManager, SIGNAL( deleteRequest( ) ), SLOT( deleteContacts( ) ) ); connect( mViewManager, SIGNAL( modified() ), SLOT( setModified() ) ); connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); + connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); connect( mXXPortManager, SIGNAL( modified() ), SLOT( setModified() ) ); connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), SLOT( incrementalSearch( const QString& ) ) ); connect( mIncSearchWidget, SIGNAL( fieldChanged() ), mJumpButtonBar, SLOT( recreateButtons() ) ); connect( mDetails, SIGNAL( sendEmail( const QString& ) ), SLOT( sendMail( const QString& ) ) ); @@ -237,77 +229,78 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const KABCore::~KABCore() { // save(); //saveSettings(); //KABPrefs::instance()->writeConfig(); delete AddresseeConfig::instance(); mAddressBook = 0; KABC::StdAddressBook::close(); } void KABCore::restoreSettings() { + mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; + bool state; - //small devices have at startup the details view disabled - if (KGlobal::getDesktopSize() > KGlobal::Small ) + if (mMultipleViewsAtOnce) state = KABPrefs::instance()->mDetailsPageVisible; else state = false; mActionDetails->setChecked( state ); setDetailsVisible( state ); state = KABPrefs::instance()->mJumpButtonBarVisible; mActionJumpBar->setChecked( state ); setJumpButtonBarVisible( state ); - +/*US QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; if ( splitterSize.count() == 0 ) { splitterSize.append( width() / 2 ); splitterSize.append( width() / 2 ); } mMiniSplitter->setSizes( splitterSize ); if ( mExtensionBarSplitter ) { splitterSize = KABPrefs::instance()->mExtensionsSplitter; if ( splitterSize.count() == 0 ) { splitterSize.append( width() / 2 ); splitterSize.append( width() / 2 ); } mExtensionBarSplitter->setSizes( splitterSize ); } -#ifndef KAB_EMBEDDED - QValueList<int> splitterSize = KABPrefs::instance()->mExtensionsSplitter; +*/ + mViewManager->restoreSettings(); + mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); + mExtensionManager->restoreSettings(); + + QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; if ( splitterSize.count() == 0 ) { splitterSize.append( width() / 2 ); splitterSize.append( width() / 2 ); } - mExtensionBarSplitter->setSizes( splitterSize ); - - splitterSize = KABPrefs::instance()->mDetailsSplitter; + mMiniSplitter->setSizes( splitterSize ); + if ( mExtensionBarSplitter ) { + splitterSize = KABPrefs::instance()->mExtensionsSplitter; if ( splitterSize.count() == 0 ) { - splitterSize.append( height() / 2 ); - splitterSize.append( height() / 2 ); + splitterSize.append( width() / 2 ); + splitterSize.append( width() / 2 ); } - mDetailsSplitter->setSizes( splitterSize ); + mExtensionBarSplitter->setSizes( splitterSize ); - mExtensionManager->restoreSettings(); + } -#endif //KAB_EMBEDDED - mViewManager->restoreSettings(); - mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); - mExtensionManager->restoreSettings(); } void KABCore::saveSettings() { KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); if ( mExtensionBarSplitter ) KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); #ifndef KAB_EMBEDDED KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); @@ -421,25 +414,25 @@ void KABCore::createAboutData() "Mark Westcot Contact pinning\n" "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" "Steffen Hansen LDAP Lookup hansen@kde.org\n" #ifdef _WIN32_ "(c) 2004 Lutz Rogowski Import from OL rogowski@kde.org\n" #endif ); } void KABCore::setContactSelected( const QString &uid ) { KABC::Addressee addr = mAddressBook->findByUid( uid ); -//US if ( !mDetails->isHidden() ) + if ( !mDetails->isHidden() ) mDetails->setAddressee( addr ); if ( !addr.isEmpty() ) { emit contactSelected( addr.formattedName() ); KABC::Picture pic = addr.photo(); if ( pic.isIntern() ) { //US emit contactSelected( pic.data() ); //US instead use: QPixmap px; if (pic.data().isNull() != true) { px.convertFromImage(pic.data()); @@ -1048,34 +1041,41 @@ void KABCore::editContact( const QString &uid ) if ( uidList.count() > 0 ) localUID = *( uidList.at( 0 ) ); } KABC::Addressee addr = mAddressBook->findByUid( localUID ); if ( !addr.isEmpty() ) { mEditorDialog->setAddressee( addr ); KApplication::execDialog ( mEditorDialog ); } } /** - Shows the detail view for the given uid. If the uid is QString::null, + Shows or edits the detail view for the given uid. If the uid is QString::null, the method will try to find a selected addressee in the view. - We call this method only if we use a small device. Bigger devices are calling editContact instead */ -void KABCore::showContact( const QString &uid /*US = QString::null*/ ) +void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) +{ + if ( mMultipleViewsAtOnce ) + { + editContact( uid ); + } + else { setDetailsVisible( true ); mActionDetails->setChecked(true); } +} + void KABCore::save() { if ( !mModified ) return; QString text = i18n( "There was an error while attempting to save\n the " "address book. Please check that some \nother application is " "not using it. " ); statusMessage(i18n("Saving addressbook ... ")); #ifndef KAB_EMBEDDED KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); if ( !b || !b->save() ) { KMessageBox::error( this, text, i18n( "Unable to Save" ) ); @@ -1105,82 +1105,131 @@ void KABCore::undo() } void KABCore::redo() { RedoStack::instance()->redo(); // Refresh the view mViewManager->refreshView(); } void KABCore::setJumpButtonBarVisible( bool visible ) { - if (KGlobal::getDesktopSize() > KGlobal::Small ) { + if (mMultipleViewsAtOnce) + { if ( visible ) mJumpButtonBar->show(); else mJumpButtonBar->hide(); } else { - // for the Z5500, show the jumpbar only if "the details are hidden" == "viewmanager are shown" + // show the jumpbar only if "the details are hidden" == "viewmanager are shown" if (mViewManager->isVisible()) { if ( visible ) mJumpButtonBar->show(); else mJumpButtonBar->hide(); } else { mJumpButtonBar->hide(); } } } + + void KABCore::setDetailsToState() { setDetailsVisible( mActionDetails->isChecked() ); } void KABCore::setDetailsVisible( bool visible ) { - //US "details visible" has two different meanings for small devices like the 5500 - // compared with large devices like the c series. + if (visible && mDetails->isHidden()) + { + KABC::Addressee::List addrList = mViewManager->selectedAddressees(); + if ( addrList.count() > 0 ) + mDetails->setAddressee( addrList[ 0 ] ); + } - // small devices: mDetails is always visible. But we switch between + // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between // the listview and the detailview. We do that by changing the splitbar size. - if (KGlobal::getDesktopSize() > KGlobal::Small ) { + if (mMultipleViewsAtOnce) + { if ( visible ) mDetails->show(); else mDetails->hide(); } else { if ( visible ) { mViewManager->hide(); mDetails->show(); -// mDetails->show(); } else { mViewManager->show(); mDetails->hide(); } setJumpButtonBarVisible( !visible ); + } + +} + +void KABCore::extensionChanged( int id ) +{ + //change the details view only for non desktop systems +#ifndef DESKTOP_VERSION + + if (id == 0) + { + //the user disabled the extension. + + if (mMultipleViewsAtOnce) + { // enable detailsview again + setDetailsVisible( true ); + mActionDetails->setChecked( true ); + } + else + { //go back to the listview + setDetailsVisible( false ); + mActionDetails->setChecked( false ); + mActionDetails->setEnabled(true); + } + + } + else + { + //the user enabled the extension. + setDetailsVisible( false ); + mActionDetails->setChecked( false ); + if (!mMultipleViewsAtOnce) + { + mActionDetails->setEnabled(false); } + + mExtensionManager->setSelectionChanged(); + } +#endif// DESKTOP_VERSION + +} + + void KABCore::extensionModified( const KABC::Addressee::List &list ) { if ( list.count() != 0 ) { KABC::Addressee::List::ConstIterator it; for ( it = list.begin(); it != list.end(); ++it ) mAddressBook->insertAddressee( *it ); if ( list.count() > 1 ) setModified(); else setModifiedWOrefresh(); } @@ -1235,25 +1284,25 @@ void KABCore::openConfigDialog() KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( kpim_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); ConfigureDialog->addModule(kdelibcfg ); connect( ConfigureDialog, SIGNAL( applyClicked() ), this, SLOT( configurationChanged() ) ); connect( ConfigureDialog, SIGNAL( okClicked() ), this, SLOT( configurationChanged() ) ); saveSettings(); ConfigureDialog->showMaximized(); if ( ConfigureDialog->exec() ) - KMessageBox::information( this, i18n("If you configured \nExtensions,\nplease restart!\n") ); + KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); delete ConfigureDialog; } void KABCore::openLDAPDialog() { #ifndef KAB_EMBEDDED if ( !mLdapSearchDialog ) { mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, SLOT( refreshView() ) ); connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, SLOT( setModified() ) ); @@ -1736,25 +1785,28 @@ void KABCore::addActionsManually() //US Now connect the actions with the menue entries. mActionPrint->plug( fileMenu ); mActionMail->plug( fileMenu ); fileMenu->insertSeparator(); mActionNewContact->plug( fileMenu ); mActionNewContact->plug( tb ); mActionEditAddressee->plug( fileMenu ); + if ((KGlobal::getDesktopSize() > KGlobal::Small ) || + (!KABPrefs::instance()->mMultipleViewsAtOnce )) mActionEditAddressee->plug( tb ); + fileMenu->insertSeparator(); mActionSave->plug( fileMenu ); fileMenu->insertItem( "&Import", ImportMenu ); fileMenu->insertItem( "&Emport", ExportMenu ); fileMenu->insertSeparator(); mActionMailVCard->plug( fileMenu ); #ifndef DESKTOP_VERSION if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); if ( Ir::supported() ) mActionBeam->plug(fileMenu ); #endif fileMenu->insertSeparator(); mActionQuit->plug( fileMenu ); @@ -1784,25 +1836,25 @@ void KABCore::addActionsManually() if ( mIsPart ) { mActionConfigShortcuts->plug( settingsMenu ); mActionConfigureToolbars->plug( settingsMenu ); } else { mActionKeyBindings->plug( settingsMenu ); } settingsMenu->insertSeparator(); mActionJumpBar->plug( settingsMenu ); mActionDetails->plug( settingsMenu ); - if (KGlobal::getDesktopSize() == KGlobal::Small ) + if (!KABPrefs::instance()->mMultipleViewsAtOnce ) mActionDetails->plug( tb ); settingsMenu->insertSeparator(); mActionWhoAmI->plug( settingsMenu ); mActionCategories->plug( settingsMenu ); mActionAboutKAddressbook->plug( helpMenu ); mActionLicence->plug( helpMenu ); if (KGlobal::getDesktopSize() > KGlobal::Small ) { mActionSave->plug( tb ); diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index a45c4c6..d4d28f1 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h @@ -293,28 +293,28 @@ class KABCore : public QWidget */ void redo(); /** Shows the edit dialog for the given uid. If the uid is QString::null, the method will try to find a selected addressee in the view. */ void editContact( const QString &uid /*US = QString::null*/ ); //US added a second method without defaultparameter void editContact2(); /** - Shows the detail view for the given uid. If the uid is QString::null, + Shows or edits the detail view for the given uid. If the uid is QString::null, the method will try to find a selected addressee in the view. */ - void showContact( const QString &uid /*US = QString::null*/ ); + void executeContact( const QString &uid /*US = QString::null*/ ); /** Launches the configuration dialog. */ void openConfigDialog(); /** Launches the ldap search dialog. */ void openLDAPDialog(); /** @@ -329,24 +329,25 @@ class KABCore : public QWidget void addGUIClient( KXMLGUIClient *client ); signals: void contactSelected( const QString &name ); void contactSelected( const QPixmap &pixmap ); public slots: void setDetailsVisible( bool visible ); void setDetailsToState(); private slots: void setJumpButtonBarVisible( bool visible ); void importFromOL(); void extensionModified( const KABC::Addressee::List &list ); + void extensionChanged( int id ); void clipboardDataChanged(); void updateActionMenu(); void configureKeyBindings(); void removeVoice(); #ifdef KAB_EMBEDDED void configureResources(); #endif //KAB_EMBEDDED void slotEditorDestroyed( const QString &uid ); void configurationChanged(); void addressBookChanged(); @@ -372,24 +373,26 @@ class KABCore : public QWidget ExtensionManager *mExtensionManager; KCMultiDialog *mConfigureDialog; #ifndef KAB_EMBEDDED LDAPSearchDialog *mLdapSearchDialog; #endif //KAB_EMBEDDED // QDict<AddresseeEditorDialog> mEditorDict; AddresseeEditorDialog *mEditorDialog; bool mReadWrite; bool mModified; bool mIsPart; + bool mMultipleViewsAtOnce; + //US file menu KAction *mActionMail; KAction *mActionBeam; KAction* mActionPrint; KAction* mActionNewContact; KAction *mActionSave; KAction *mActionEditAddressee; KAction *mActionMailVCard; KAction *mActionBeamVCard; KAction *mActionQuit; |