author | ulf69 <ulf69> | 2004-08-11 01:57:44 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-08-11 01:57:44 (UTC) |
commit | 4e4e196bc4fbe4e078b4fbe6b372bd643bf372f1 (patch) (unidiff) | |
tree | c582e58964a01157962c2c9b605bc501ddbe2771 | |
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 | 92 | ||||
-rw-r--r-- | kaddressbook/kabcore.h | 6 |
2 files changed, 86 insertions, 12 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 6610288..96603e6 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -189,8 +189,18 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const | |||
189 | 189 | ||
190 | connect( mViewManager, SIGNAL( selected( const QString& ) ), | 190 | connect( mViewManager, SIGNAL( selected( const QString& ) ), |
191 | SLOT( setContactSelected( const QString& ) ) ); | 191 | SLOT( setContactSelected( const QString& ) ) ); |
192 | |||
193 | //small devices show only the details view. bigger devices can edit the entry | ||
194 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | ||
192 | connect( mViewManager, SIGNAL( executed( const QString& ) ), | 195 | connect( mViewManager, SIGNAL( executed( const QString& ) ), |
193 | SLOT( editContact( const QString& ) ) ); | 196 | SLOT( editContact( const QString& ) ) ); |
197 | } | ||
198 | else | ||
199 | { | ||
200 | connect( mViewManager, SIGNAL( executed( const QString& ) ), | ||
201 | SLOT( showContact( const QString& ) ) ); | ||
202 | } | ||
203 | |||
194 | connect( mViewManager, SIGNAL( deleteRequest( ) ), | 204 | connect( mViewManager, SIGNAL( deleteRequest( ) ), |
195 | SLOT( deleteContacts( ) ) ); | 205 | SLOT( deleteContacts( ) ) ); |
196 | connect( mViewManager, SIGNAL( modified() ), | 206 | connect( mViewManager, SIGNAL( modified() ), |
@@ -236,15 +246,22 @@ KABCore::~KABCore() | |||
236 | 246 | ||
237 | void KABCore::restoreSettings() | 247 | void KABCore::restoreSettings() |
238 | { | 248 | { |
239 | bool state = KABPrefs::instance()->mJumpButtonBarVisible; | 249 | bool state; |
240 | |||
241 | mActionJumpBar->setChecked( state ); | ||
242 | setJumpButtonBarVisible( state ); | ||
243 | 250 | ||
251 | //small devices have at startup the details view disabled | ||
252 | if (KGlobal::getDesktopSize() > KGlobal::Small ) | ||
244 | state = KABPrefs::instance()->mDetailsPageVisible; | 253 | state = KABPrefs::instance()->mDetailsPageVisible; |
254 | else | ||
255 | state = false; | ||
245 | 256 | ||
246 | mActionDetails->setChecked( state ); | 257 | mActionDetails->setChecked( state ); |
247 | setDetailsVisible( state ); | 258 | setDetailsVisible( state ); |
259 | |||
260 | state = KABPrefs::instance()->mJumpButtonBarVisible; | ||
261 | |||
262 | mActionJumpBar->setChecked( state ); | ||
263 | setJumpButtonBarVisible( state ); | ||
264 | |||
248 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 265 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
249 | if ( splitterSize.count() == 0 ) { | 266 | if ( splitterSize.count() == 0 ) { |
250 | splitterSize.append( width() / 2 ); | 267 | splitterSize.append( width() / 2 ); |
@@ -279,9 +296,8 @@ void KABCore::restoreSettings() | |||
279 | 296 | ||
280 | #endif //KAB_EMBEDDED | 297 | #endif //KAB_EMBEDDED |
281 | 298 | ||
282 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | ||
283 | |||
284 | mViewManager->restoreSettings(); | 299 | mViewManager->restoreSettings(); |
300 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | ||
285 | mExtensionManager->restoreSettings(); | 301 | mExtensionManager->restoreSettings(); |
286 | } | 302 | } |
287 | 303 | ||
@@ -301,7 +317,6 @@ void KABCore::saveSettings() | |||
301 | mViewManager->saveSettings(); | 317 | mViewManager->saveSettings(); |
302 | 318 | ||
303 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 319 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
304 | |||
305 | } | 320 | } |
306 | 321 | ||
307 | KABC::AddressBook *KABCore::addressBook() const | 322 | KABC::AddressBook *KABCore::addressBook() const |
@@ -415,7 +430,7 @@ void KABCore::createAboutData() | |||
415 | void KABCore::setContactSelected( const QString &uid ) | 430 | void KABCore::setContactSelected( const QString &uid ) |
416 | { | 431 | { |
417 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 432 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
418 | if ( !mDetails->isHidden() ) | 433 | //US if ( !mDetails->isHidden() ) |
419 | mDetails->setAddressee( addr ); | 434 | mDetails->setAddressee( addr ); |
420 | 435 | ||
421 | if ( !addr.isEmpty() ) { | 436 | if ( !addr.isEmpty() ) { |
@@ -1041,6 +1056,17 @@ void KABCore::editContact( const QString &uid ) | |||
1041 | } | 1056 | } |
1042 | } | 1057 | } |
1043 | 1058 | ||
1059 | /** | ||
1060 | Shows the detail view for the given uid. If the uid is QString::null, | ||
1061 | the method will try to find a selected addressee in the view. | ||
1062 | We call this method only if we use a small device. Bigger devices are calling editContact instead | ||
1063 | */ | ||
1064 | void KABCore::showContact( const QString &uid /*US = QString::null*/ ) | ||
1065 | { | ||
1066 | setDetailsVisible( true ); | ||
1067 | mActionDetails->setChecked(true); | ||
1068 | } | ||
1069 | |||
1044 | void KABCore::save() | 1070 | void KABCore::save() |
1045 | { | 1071 | { |
1046 | if ( !mModified ) | 1072 | if ( !mModified ) |
@@ -1088,23 +1114,63 @@ void KABCore::redo() | |||
1088 | 1114 | ||
1089 | void KABCore::setJumpButtonBarVisible( bool visible ) | 1115 | void KABCore::setJumpButtonBarVisible( bool visible ) |
1090 | { | 1116 | { |
1117 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | ||
1118 | if ( visible ) | ||
1119 | mJumpButtonBar->show(); | ||
1120 | else | ||
1121 | mJumpButtonBar->hide(); | ||
1122 | } | ||
1123 | else | ||
1124 | { | ||
1125 | // for the Z5500, show the jumpbar only if "the details are hidden" == "viewmanager are shown" | ||
1126 | if (mViewManager->isVisible()) | ||
1127 | { | ||
1091 | if ( visible ) | 1128 | if ( visible ) |
1092 | mJumpButtonBar->show(); | 1129 | mJumpButtonBar->show(); |
1093 | else | 1130 | else |
1094 | mJumpButtonBar->hide(); | 1131 | mJumpButtonBar->hide(); |
1095 | } | 1132 | } |
1133 | else | ||
1134 | { | ||
1135 | mJumpButtonBar->hide(); | ||
1136 | } | ||
1137 | } | ||
1138 | } | ||
1096 | void KABCore::setDetailsToState() | 1139 | void KABCore::setDetailsToState() |
1097 | { | 1140 | { |
1098 | setDetailsVisible( mActionDetails->isChecked() ); | 1141 | setDetailsVisible( mActionDetails->isChecked() ); |
1099 | } | 1142 | } |
1100 | 1143 | ||
1144 | |||
1145 | |||
1101 | void KABCore::setDetailsVisible( bool visible ) | 1146 | void KABCore::setDetailsVisible( bool visible ) |
1102 | { | 1147 | { |
1148 | //US "details visible" has two different meanings for small devices like the 5500 | ||
1149 | // compared with large devices like the c series. | ||
1150 | |||
1151 | // small devices: mDetails is always visible. But we switch between | ||
1152 | // the listview and the detailview. We do that by changing the splitbar size. | ||
1153 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | ||
1103 | if ( visible ) | 1154 | if ( visible ) |
1104 | mDetails->show(); | 1155 | mDetails->show(); |
1105 | else | 1156 | else |
1106 | mDetails->hide(); | 1157 | mDetails->hide(); |
1107 | } | 1158 | } |
1159 | else | ||
1160 | { | ||
1161 | if ( visible ) { | ||
1162 | mViewManager->hide(); | ||
1163 | mDetails->show(); | ||
1164 | // mDetails->show(); | ||
1165 | } | ||
1166 | else { | ||
1167 | mViewManager->show(); | ||
1168 | mDetails->hide(); | ||
1169 | } | ||
1170 | setJumpButtonBarVisible( !visible ); | ||
1171 | |||
1172 | } | ||
1173 | } | ||
1108 | 1174 | ||
1109 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1175 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1110 | { | 1176 | { |
@@ -1571,7 +1637,7 @@ void KABCore::initActions() | |||
1571 | actionCollection(), "options_show_jump_bar" ); | 1637 | actionCollection(), "options_show_jump_bar" ); |
1572 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); | 1638 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); |
1573 | 1639 | ||
1574 | mActionDetails = new KToggleAction( i18n( "Show Details" ), 0, 0, | 1640 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
1575 | actionCollection(), "options_show_details" ); | 1641 | actionCollection(), "options_show_details" ); |
1576 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 1642 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
1577 | 1643 | ||
@@ -1679,6 +1745,7 @@ void KABCore::addActionsManually() | |||
1679 | mActionNewContact->plug( tb ); | 1745 | mActionNewContact->plug( tb ); |
1680 | 1746 | ||
1681 | mActionEditAddressee->plug( fileMenu ); | 1747 | mActionEditAddressee->plug( fileMenu ); |
1748 | mActionEditAddressee->plug( tb ); | ||
1682 | fileMenu->insertSeparator(); | 1749 | fileMenu->insertSeparator(); |
1683 | mActionSave->plug( fileMenu ); | 1750 | mActionSave->plug( fileMenu ); |
1684 | fileMenu->insertItem( "&Import", ImportMenu ); | 1751 | fileMenu->insertItem( "&Import", ImportMenu ); |
@@ -1726,6 +1793,8 @@ void KABCore::addActionsManually() | |||
1726 | 1793 | ||
1727 | mActionJumpBar->plug( settingsMenu ); | 1794 | mActionJumpBar->plug( settingsMenu ); |
1728 | mActionDetails->plug( settingsMenu ); | 1795 | mActionDetails->plug( settingsMenu ); |
1796 | if (KGlobal::getDesktopSize() == KGlobal::Small ) | ||
1797 | mActionDetails->plug( tb ); | ||
1729 | settingsMenu->insertSeparator(); | 1798 | settingsMenu->insertSeparator(); |
1730 | 1799 | ||
1731 | mActionWhoAmI->plug( settingsMenu ); | 1800 | mActionWhoAmI->plug( settingsMenu ); |
@@ -1734,12 +1803,11 @@ void KABCore::addActionsManually() | |||
1734 | mActionAboutKAddressbook->plug( helpMenu ); | 1803 | mActionAboutKAddressbook->plug( helpMenu ); |
1735 | mActionLicence->plug( helpMenu ); | 1804 | mActionLicence->plug( helpMenu ); |
1736 | 1805 | ||
1737 | if (QApplication::desktop()->width() > 320 ) { | 1806 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
1738 | 1807 | ||
1739 | mActionEditAddressee->plug( tb ); | ||
1740 | mActionSave->plug( tb ); | 1808 | mActionSave->plug( tb ); |
1741 | mViewManager->getFilterAction()->plug ( tb); | 1809 | mViewManager->getFilterAction()->plug ( tb); |
1742 | if (QApplication::desktop()->width() > 480 ) { | 1810 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { |
1743 | mActionUndo->plug( tb ); | 1811 | mActionUndo->plug( tb ); |
1744 | mActionDelete->plug( tb ); | 1812 | mActionDelete->plug( tb ); |
1745 | mActionRedo->plug( tb ); | 1813 | mActionRedo->plug( tb ); |
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index 6bbdfd4..a45c4c6 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h | |||
@@ -302,6 +302,12 @@ class KABCore : public QWidget | |||
302 | void editContact2(); | 302 | void editContact2(); |
303 | 303 | ||
304 | /** | 304 | /** |
305 | Shows the detail view for the given uid. If the uid is QString::null, | ||
306 | the method will try to find a selected addressee in the view. | ||
307 | */ | ||
308 | void showContact( const QString &uid /*US = QString::null*/ ); | ||
309 | |||
310 | /** | ||
305 | Launches the configuration dialog. | 311 | Launches the configuration dialog. |
306 | */ | 312 | */ |
307 | void openConfigDialog(); | 313 | void openConfigDialog(); |