-rw-r--r-- | kaddressbook/kabcore.cpp | 108 | ||||
-rw-r--r-- | kaddressbook/kabcore.h | 6 |
2 files changed, 94 insertions, 20 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 6610288..96603e6 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -176,34 +176,44 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const //US added this field to become compatible with Opie/qtopia addressbook // values can be "female" or "male" or "". An empty field represents undefined. mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, "X-Gender", "KADDRESSBOOK" ); 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& ) ) ); - connect( mViewManager, SIGNAL( executed( 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& ) ) ); + } + 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( 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& ) ), @@ -223,41 +233,48 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const createAddresseeEditorDialog( this ); setModified( false ); } KABCore::~KABCore() { // save(); //saveSettings(); //KABPrefs::instance()->writeConfig(); delete AddresseeConfig::instance(); mAddressBook = 0; KABC::StdAddressBook::close(); } void KABCore::restoreSettings() { - bool state = KABPrefs::instance()->mJumpButtonBarVisible; + bool state; - mActionJumpBar->setChecked( state ); - setJumpButtonBarVisible( state ); - - state = KABPrefs::instance()->mDetailsPageVisible; + //small devices have at startup the details view disabled + if (KGlobal::getDesktopSize() > KGlobal::Small ) + state = KABPrefs::instance()->mDetailsPageVisible; + else + state = false; mActionDetails->setChecked( state ); setDetailsVisible( state ); + + state = KABPrefs::instance()->mJumpButtonBarVisible; + + mActionJumpBar->setChecked( state ); + setJumpButtonBarVisible( state ); + 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 @@ -266,55 +283,53 @@ void KABCore::restoreSettings() splitterSize.append( width() / 2 ); splitterSize.append( width() / 2 ); } mExtensionBarSplitter->setSizes( splitterSize ); splitterSize = KABPrefs::instance()->mDetailsSplitter; if ( splitterSize.count() == 0 ) { splitterSize.append( height() / 2 ); splitterSize.append( height() / 2 ); } mDetailsSplitter->setSizes( splitterSize ); mExtensionManager->restoreSettings(); #endif //KAB_EMBEDDED - mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); - 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(); KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); #endif //KAB_EMBEDDED mExtensionManager->saveSettings(); mViewManager->saveSettings(); KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); - } KABC::AddressBook *KABCore::addressBook() const { return mAddressBook; } KConfig *KABCore::config() { #ifndef KAB_EMBEDDED return KABPrefs::instance()->config(); #else //KAB_EMBEDDED return KABPrefs::instance()->getConfig(); #endif //KAB_EMBEDDED } @@ -402,33 +417,33 @@ void KABCore::createAboutData() "Don Sanders Original author\n" "Cornelius Schumacher Co-maintainer schumacher@kde.org\n" "Mike Pilone GUI and framework redesign mpilone@slac.com\n" "Greg Stern DCOP interface\n" "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 ); - if ( !mDetails->isHidden() ) +//US 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()); } emit contactSelected( px ); } @@ -1028,32 +1043,43 @@ void KABCore::editContact( const QString &uid ) // First, locate the contact entry QString localUID = uid; if ( localUID.isNull() ) { QStringList uidList = mViewManager->selectedUids(); 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, + 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*/ ) +{ + 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" ) ); } #else //KAB_EMBEDDED KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); if ( !b || !b->save() ) { @@ -1075,48 +1101,88 @@ void KABCore::undo() UndoStack::instance()->undo(); // Refresh the view mViewManager->refreshView(); } void KABCore::redo() { RedoStack::instance()->redo(); // Refresh the view mViewManager->refreshView(); } void KABCore::setJumpButtonBarVisible( bool visible ) { - if ( visible ) - mJumpButtonBar->show(); + if (KGlobal::getDesktopSize() > KGlobal::Small ) { + if ( visible ) + mJumpButtonBar->show(); + else + mJumpButtonBar->hide(); + } else - mJumpButtonBar->hide(); + { + // for the Z5500, 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 ) { - if ( visible ) - mDetails->show(); + //US "details visible" has two different meanings for small devices like the 5500 + // compared with large devices like the c series. + + // small devices: 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 ( visible ) + mDetails->show(); + else + mDetails->hide(); + } else - mDetails->hide(); + { + if ( visible ) { + mViewManager->hide(); + mDetails->show(); +// mDetails->show(); + } + else { + mViewManager->show(); + mDetails->hide(); + } + setJumpButtonBarVisible( !visible ); + + } } 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(); } if ( list.count() == 0 ) mViewManager->refreshView(); @@ -1558,33 +1624,33 @@ void KABCore::initActions() "kaddressbook_configure_shortcuts" ); #ifdef KAB_EMBEDDED mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); mActionConfigureToolbars->setEnabled( false ); #endif //KAB_EMBEDDED } else { mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); } mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, actionCollection(), "options_show_jump_bar" ); connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); - mActionDetails = new KToggleAction( i18n( "Show Details" ), 0, 0, + mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, actionCollection(), "options_show_details" ); connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); // misc // only enable LDAP lookup if we can handle the protocol #ifndef KAB_EMBEDDED if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, this, SLOT( openLDAPDialog() ), actionCollection(), "ldap_lookup" ); } #else //KAB_EMBEDDED //qDebug("KABCore::initActions() LDAP has to be implemented"); #endif //KAB_EMBEDDED @@ -1666,32 +1732,33 @@ void KABCore::addActionsManually() // mViewManager->getFilterAction()->plug ( tb); } #endif // mActionQuit->plug ( mMainWindow->toolBar()); //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 ); + 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 ); #ifdef _WIN32_ mActionImportOL->plug( ImportMenu ); #endif // edit menu @@ -1713,46 +1780,47 @@ void KABCore::addActionsManually() settingsMenu->insertSeparator(); mActionConfigKAddressbook->plug( settingsMenu ); 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 ) + mActionDetails->plug( tb ); settingsMenu->insertSeparator(); mActionWhoAmI->plug( settingsMenu ); mActionCategories->plug( settingsMenu ); mActionAboutKAddressbook->plug( helpMenu ); mActionLicence->plug( helpMenu ); - if (QApplication::desktop()->width() > 320 ) { + if (KGlobal::getDesktopSize() > KGlobal::Small ) { - mActionEditAddressee->plug( tb ); mActionSave->plug( tb ); mViewManager->getFilterAction()->plug ( tb); - if (QApplication::desktop()->width() > 480 ) { + if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { mActionUndo->plug( tb ); mActionDelete->plug( tb ); mActionRedo->plug( tb ); } } //mActionQuit->plug ( tb ); // tb->insertWidget(-1, 0, mIncSearchWidget, 6); //US link the searchwidget first to this. // The real linkage to the toolbar happens later. //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); //US tb->insertItem( mIncSearchWidget ); /*US mIncSearchWidget = new IncSearchWidget( tb ); connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), SLOT( incrementalSearch( const QString& ) ) ); diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index 6bbdfd4..a45c4c6 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h @@ -289,32 +289,38 @@ class KABCore : public QWidget void undo(); /** Redos the last command that was undone, using the redo stack. */ 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, + the method will try to find a selected addressee in the view. + */ + void showContact( const QString &uid /*US = QString::null*/ ); + + /** Launches the configuration dialog. */ void openConfigDialog(); /** Launches the ldap search dialog. */ void openLDAPDialog(); /** Creates a KAddressBookPrinter, which will display the print dialog and do the printing. */ void print(); /** |