-rw-r--r-- | kaddressbook/kabcore.cpp | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 59aa5a5..09d8523 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -277,48 +277,49 @@ class KAex2phonePrefs : public QDialog | |||
277 | } | 277 | } |
278 | 278 | ||
279 | public: | 279 | public: |
280 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | 280 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; |
281 | QCheckBox* mWriteToSim; | 281 | QCheckBox* mWriteToSim; |
282 | }; | 282 | }; |
283 | 283 | ||
284 | 284 | ||
285 | bool pasteWithNewUid = true; | 285 | bool pasteWithNewUid = true; |
286 | 286 | ||
287 | #ifdef KAB_EMBEDDED | 287 | #ifdef KAB_EMBEDDED |
288 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 288 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) |
289 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 289 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
290 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ | 290 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ |
291 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) | 291 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) |
292 | #else //KAB_EMBEDDED | 292 | #else //KAB_EMBEDDED |
293 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 293 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) |
294 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 294 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
295 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), | 295 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), |
296 | mReadWrite( readWrite ), mModified( false ) | 296 | mReadWrite( readWrite ), mModified( false ) |
297 | #endif //KAB_EMBEDDED | 297 | #endif //KAB_EMBEDDED |
298 | { | 298 | { |
299 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 299 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
300 | // syncManager->setBlockSave(false); | 300 | // syncManager->setBlockSave(false); |
301 | mIncSearchWidget = 0; | ||
301 | mMiniSplitter = 0; | 302 | mMiniSplitter = 0; |
302 | mExtensionBarSplitter = 0; | 303 | mExtensionBarSplitter = 0; |
303 | mIsPart = !parent->inherits( "KAddressBookMain" ); | 304 | mIsPart = !parent->inherits( "KAddressBookMain" ); |
304 | mAddressBook = KABC::StdAddressBook::self(); | 305 | mAddressBook = KABC::StdAddressBook::self(); |
305 | KABC::StdAddressBook::setAutomaticSave( false ); | 306 | KABC::StdAddressBook::setAutomaticSave( false ); |
306 | 307 | ||
307 | #ifndef KAB_EMBEDDED | 308 | #ifndef KAB_EMBEDDED |
308 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); | 309 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); |
309 | #endif //KAB_EMBEDDED | 310 | #endif //KAB_EMBEDDED |
310 | 311 | ||
311 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), | 312 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), |
312 | SLOT( addressBookChanged() ) ); | 313 | SLOT( addressBookChanged() ) ); |
313 | 314 | ||
314 | #if 0 | 315 | #if 0 |
315 | // LP moved to addressbook init method | 316 | // LP moved to addressbook init method |
316 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, | 317 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, |
317 | "X-Department", "KADDRESSBOOK" ); | 318 | "X-Department", "KADDRESSBOOK" ); |
318 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 319 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
319 | "X-Profession", "KADDRESSBOOK" ); | 320 | "X-Profession", "KADDRESSBOOK" ); |
320 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 321 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
321 | "X-AssistantsName", "KADDRESSBOOK" ); | 322 | "X-AssistantsName", "KADDRESSBOOK" ); |
322 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 323 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
323 | "X-ManagersName", "KADDRESSBOOK" ); | 324 | "X-ManagersName", "KADDRESSBOOK" ); |
324 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 325 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
@@ -798,78 +799,86 @@ void KABCore::mailVCard( const QStringList& uids ) | |||
798 | */ | 799 | */ |
799 | 800 | ||
800 | } | 801 | } |
801 | 802 | ||
802 | /** | 803 | /** |
803 | Beams the "WhoAmI contact. | 804 | Beams the "WhoAmI contact. |
804 | */ | 805 | */ |
805 | void KABCore::beamMySelf() | 806 | void KABCore::beamMySelf() |
806 | { | 807 | { |
807 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 808 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
808 | if (!a.isEmpty()) | 809 | if (!a.isEmpty()) |
809 | { | 810 | { |
810 | QStringList uids; | 811 | QStringList uids; |
811 | uids << a.uid(); | 812 | uids << a.uid(); |
812 | 813 | ||
813 | beamVCard(uids); | 814 | beamVCard(uids); |
814 | } else { | 815 | } else { |
815 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 816 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
816 | 817 | ||
817 | 818 | ||
818 | } | 819 | } |
819 | } | 820 | } |
820 | void KABCore::updateMainWindow() | 821 | void KABCore::updateMainWindow() |
821 | { | 822 | { |
822 | |||
823 | mMainWindow->showMaximized(); | 823 | mMainWindow->showMaximized(); |
824 | mMainWindow->update(); | 824 | mMainWindow->update(); |
825 | } | 825 | } |
826 | void KABCore::resizeEvent(QResizeEvent* e ) | 826 | void KABCore::resizeEvent(QResizeEvent* e ) |
827 | { | 827 | { |
828 | if ( !mMiniSplitter ) | 828 | if ( !mMiniSplitter ) |
829 | return; | 829 | return; |
830 | //qDebug("KABCore::resizeEvent(QResizeEvent* e ) "); | 830 | //qDebug("KABCore::resizeEvent(QResizeEvent* e ) "); |
831 | if ( QApplication::desktop()->width() >= 480 ) { | 831 | if ( QApplication::desktop()->width() >= 480 ) { |
832 | if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 | 832 | if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 |
833 | if ( mMiniSplitter->orientation() == Qt::Vertical ) { | 833 | if ( mMiniSplitter->orientation() == Qt::Vertical ) { |
834 | mMiniSplitter->setOrientation( Qt::Horizontal); | 834 | mMiniSplitter->setOrientation( Qt::Horizontal); |
835 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 835 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
836 | if ( QApplication::desktop()->width() <= 640 ) { | ||
837 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); | ||
838 | mViewManager->getFilterAction()->setComboWidth( 150 ); | ||
839 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); | ||
840 | } | ||
841 | } | 836 | } |
837 | if ( QApplication::desktop()->width() <= 640 ) { | ||
838 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); | ||
839 | mViewManager->getFilterAction()->setComboWidth( 150 ); | ||
840 | if ( mIncSearchWidget ) | ||
841 | mIncSearchWidget->setSize(); | ||
842 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); | ||
843 | } | ||
844 | |||
842 | } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 | 845 | } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 |
843 | if ( mMiniSplitter->orientation() == Qt::Horizontal ) { | 846 | if ( mMiniSplitter->orientation() == Qt::Horizontal ) { |
844 | mMiniSplitter->setOrientation( Qt::Vertical ); | 847 | mMiniSplitter->setOrientation( Qt::Vertical ); |
845 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 848 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
846 | if ( QApplication::desktop()->width() <= 640 ) { | 849 | } |
847 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); | 850 | if ( QApplication::desktop()->width() <= 640 ) { |
848 | mMainWindow->showMinimized(); | 851 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); |
852 | mMainWindow->showMinimized(); | ||
853 | if ( KABPrefs::instance()->mHideSearchOnSwitch ) { | ||
854 | if ( mIncSearchWidget ) { | ||
855 | mIncSearchWidget->setSize(); | ||
856 | } | ||
857 | } else { | ||
849 | mViewManager->getFilterAction()->setComboWidth( 0 ); | 858 | mViewManager->getFilterAction()->setComboWidth( 0 ); |
850 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); | ||
851 | } | 859 | } |
860 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); | ||
852 | } | 861 | } |
853 | } | 862 | } |
854 | } | 863 | } |
855 | 864 | ||
856 | } | 865 | } |
857 | void KABCore::export2phone() | 866 | void KABCore::export2phone() |
858 | { | 867 | { |
859 | 868 | ||
860 | QStringList uids; | 869 | QStringList uids; |
861 | XXPortSelectDialog dlg( this, false, this ); | 870 | XXPortSelectDialog dlg( this, false, this ); |
862 | if ( dlg.exec() ) | 871 | if ( dlg.exec() ) |
863 | uids = dlg.uids(); | 872 | uids = dlg.uids(); |
864 | else | 873 | else |
865 | return; | 874 | return; |
866 | if ( uids.isEmpty() ) | 875 | if ( uids.isEmpty() ) |
867 | return; | 876 | return; |
868 | // qDebug("count %d ", uids.count()); | 877 | // qDebug("count %d ", uids.count()); |
869 | 878 | ||
870 | KAex2phonePrefs ex2phone; | 879 | KAex2phonePrefs ex2phone; |
871 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 880 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
872 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 881 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
873 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 882 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
874 | 883 | ||
875 | if ( !ex2phone.exec() ) { | 884 | if ( !ex2phone.exec() ) { |
@@ -1132,49 +1141,55 @@ void KABCore::setCategories() | |||
1132 | QStringList addrCategories = addr.categories(); | 1141 | QStringList addrCategories = addr.categories(); |
1133 | QStringList::Iterator catIt; | 1142 | QStringList::Iterator catIt; |
1134 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 1143 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
1135 | if ( !addrCategories.contains( *catIt ) ) | 1144 | if ( !addrCategories.contains( *catIt ) ) |
1136 | addrCategories.append( *catIt ); | 1145 | addrCategories.append( *catIt ); |
1137 | } | 1146 | } |
1138 | addr.setCategories( addrCategories ); | 1147 | addr.setCategories( addrCategories ); |
1139 | } | 1148 | } |
1140 | mAddressBook->insertAddressee( addr ); | 1149 | mAddressBook->insertAddressee( addr ); |
1141 | } | 1150 | } |
1142 | } | 1151 | } |
1143 | 1152 | ||
1144 | if ( uids.count() > 0 ) | 1153 | if ( uids.count() > 0 ) |
1145 | setModified( true ); | 1154 | setModified( true ); |
1146 | message( i18n("Setting categories completed!") ); | 1155 | message( i18n("Setting categories completed!") ); |
1147 | } | 1156 | } |
1148 | 1157 | ||
1149 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 1158 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
1150 | { | 1159 | { |
1151 | mIncSearchWidget->setFields( fields ); | 1160 | mIncSearchWidget->setFields( fields ); |
1152 | } | 1161 | } |
1153 | 1162 | ||
1154 | void KABCore::incrementalSearch( const QString& text ) | 1163 | void KABCore::incrementalSearch( const QString& text ) |
1155 | { | 1164 | { |
1156 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); | 1165 | QString stext; |
1166 | if ( KABPrefs::instance()->mAutoSearchWithWildcard ) { | ||
1167 | stext = "*" + text; | ||
1168 | } else { | ||
1169 | stext = text; | ||
1170 | } | ||
1171 | mViewManager->doSearch( stext, mIncSearchWidget->currentField() ); | ||
1157 | } | 1172 | } |
1158 | 1173 | ||
1159 | void KABCore::setModified() | 1174 | void KABCore::setModified() |
1160 | { | 1175 | { |
1161 | setModified( true ); | 1176 | setModified( true ); |
1162 | } | 1177 | } |
1163 | 1178 | ||
1164 | void KABCore::setModifiedWOrefresh() | 1179 | void KABCore::setModifiedWOrefresh() |
1165 | { | 1180 | { |
1166 | // qDebug("KABCore::setModifiedWOrefresh() "); | 1181 | // qDebug("KABCore::setModifiedWOrefresh() "); |
1167 | mModified = true; | 1182 | mModified = true; |
1168 | mActionSave->setEnabled( mModified ); | 1183 | mActionSave->setEnabled( mModified ); |
1169 | 1184 | ||
1170 | 1185 | ||
1171 | } | 1186 | } |
1172 | void KABCore::setModified( bool modified ) | 1187 | void KABCore::setModified( bool modified ) |
1173 | { | 1188 | { |
1174 | mModified = modified; | 1189 | mModified = modified; |
1175 | mActionSave->setEnabled( mModified ); | 1190 | mActionSave->setEnabled( mModified ); |
1176 | 1191 | ||
1177 | if ( modified ) | 1192 | if ( modified ) |
1178 | mJumpButtonBar->recreateButtons(); | 1193 | mJumpButtonBar->recreateButtons(); |
1179 | 1194 | ||
1180 | mViewManager->refreshView(); | 1195 | mViewManager->refreshView(); |