author | ulf69 <ulf69> | 2004-08-11 01:57:44 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-08-11 01:57:44 (UTC) |
commit | 4e4e196bc4fbe4e078b4fbe6b372bd643bf372f1 (patch) (side-by-side diff) | |
tree | c582e58964a01157962c2c9b605bc501ddbe2771 /kaddressbook/kabcore.cpp | |
parent | 42860986468bb90c55783fcebc1b20bd3ee460ac (diff) | |
download | kdepimpi-4e4e196bc4fbe4e078b4fbe6b372bd643bf372f1.zip kdepimpi-4e4e196bc4fbe4e078b4fbe6b372bd643bf372f1.tar.gz kdepimpi-4e4e196bc4fbe4e078b4fbe6b372bd643bf372f1.tar.bz2 |
added special detailview handling for small devices. Now the behavior is
a little bit similar to qtopia and opie addressbook
-rw-r--r-- | kaddressbook/kabcore.cpp | 108 |
1 files changed, 88 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 @@ -188,10 +188,20 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const 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() ) ); @@ -235,17 +245,24 @@ KABCore::~KABCore() } 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 ); @@ -278,11 +295,10 @@ void KABCore::restoreSettings() mExtensionManager->restoreSettings(); #endif //KAB_EMBEDDED - mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); - mViewManager->restoreSettings(); + mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); mExtensionManager->restoreSettings(); } void KABCore::saveSettings() @@ -300,9 +316,8 @@ void KABCore::saveSettings() mExtensionManager->saveSettings(); mViewManager->saveSettings(); KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); - } KABC::AddressBook *KABCore::addressBook() const { @@ -414,9 +429,9 @@ void KABCore::createAboutData() 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() ); @@ -1040,8 +1055,19 @@ void KABCore::editContact( const QString &uid ) 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; @@ -1087,24 +1113,64 @@ void KABCore::redo() } 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 ) { @@ -1570,9 +1636,9 @@ void KABCore::initActions() 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 @@ -1678,8 +1744,9 @@ void KABCore::addActionsManually() 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 ); @@ -1725,22 +1792,23 @@ void KABCore::addActionsManually() 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 ); } |