-rw-r--r-- | kaddressbook/filter.cpp | 2 | ||||
-rw-r--r-- | kaddressbook/filter.h | 2 | ||||
-rw-r--r-- | kaddressbook/filtereditdialog.cpp | 1 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 16 | ||||
-rw-r--r-- | kaddressbook/kaddressbookmain.cpp | 2 | ||||
-rw-r--r-- | kaddressbook/viewmanager.cpp | 3 |
6 files changed, 15 insertions, 11 deletions
diff --git a/kaddressbook/filter.cpp b/kaddressbook/filter.cpp index 9cb4c2d..7a869fa 100644 --- a/kaddressbook/filter.cpp +++ b/kaddressbook/filter.cpp @@ -56,173 +56,173 @@ void Filter::setName( const QString &name ) const QString &Filter::name() const { return mName; } bool Filter::isInternal() const { return mInternal; } void Filter::apply( KABC::Addressee::List &addresseeList ) { KABC::Addressee::List::Iterator iter; for ( iter = addresseeList.begin(); iter != addresseeList.end(); ) { if ( filterAddressee( *iter ) ) ++iter; else { #ifndef KAB_EMBEDDED iter = addresseeList.erase( iter ); #else //KAB_EMBEDDED iter = addresseeList.remove( iter ); #endif //KAB_EMBEDDED } } } bool Filter::filterAddressee( const KABC::Addressee &a ) { switch ( a.secrecy().type()) { case KABC::Secrecy::Public: if (! (mCriteria & ShowPublic )) return false; break; case KABC::Secrecy::Private: if (! (mCriteria & ShowPrivate )) return false; break; case KABC::Secrecy::Confidential: if (! (mCriteria & ShowConfidential )) return false; break; default: return false; break; } QStringList::Iterator iter; iter = mCategoryList.begin(); // empty filter always matches if ( iter == mCategoryList.end() ) return true; for ( ; iter != mCategoryList.end(); ++iter ) { if ( a.hasCategory( *iter ) ) return ( mMatchRule == Matching ); } return !( mMatchRule == Matching ); } void Filter::setEnabled( bool on ) { mEnabled = on; } bool Filter::isEnabled() const { return mEnabled; } void Filter::setCategories( const QStringList &list ) { mCategoryList = list; } const QStringList &Filter::categories() const { return mCategoryList; } void Filter::save( KConfig *config ) { config->writeEntry( "Name", mName ); config->writeEntry( "Enabled", mEnabled ); config->writeEntry( "Categories", mCategoryList ); config->writeEntry( "MatchRule", (int)mMatchRule ); config->writeEntry( "Criteria", (int)mCriteria ); } void Filter::restore( KConfig *config ) { mName = config->readEntry( "Name", "<internal error>" ); mEnabled = config->readBoolEntry( "Enabled", true ); mCategoryList = config->readListEntry( "Categories" ); mMatchRule = (MatchRule)config->readNumEntry( "MatchRule", Matching ); - mCriteria = config->readNumEntry( "Criteria", (ShowPublic | ShowPrivate| ShowConfidential) ); + mCriteria = config->readNumEntry( "Criteria", (ShowPublic | ShowPrivate| ShowConfidential ) ); } void Filter::save( KConfig *config, QString baseGroup, Filter::List &list ) { { KConfigGroupSaver s( config, baseGroup ); // remove the old filters uint count = config->readNumEntry( "Count" ); /* // memory access violation here for ( uint i = 0; i < count; ++i ) config->deleteGroup( QString( "%1_%2" ).arg( baseGroup ).arg( i ) ); */ } int index = 0; Filter::List::Iterator iter; for ( iter = list.begin(); iter != list.end(); ++iter ) { if ( !(*iter).mInternal ) { KConfigGroupSaver s( config, QString( "%1_%2" ).arg( baseGroup ).arg( index ) ); (*iter).save( config ); index++; } } KConfigGroupSaver s( config, baseGroup ); config->writeEntry( "Count", index ); } Filter::List Filter::restore( KConfig *config, QString baseGroup ) { Filter::List list; int count = 0; Filter f; { KConfigGroupSaver s( config, baseGroup ); count = config->readNumEntry( "Count", 0 ); } for ( int i = 0; i < count; i++ ) { { KConfigGroupSaver s( config, QString( "%1_%2" ).arg( baseGroup ).arg( i ) ); f.restore( config ); } list.append( f ); } if ( list.isEmpty()) { QStringList cats = KABPrefs::instance()->mCustomCategories; for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) { Filter filter; filter.mName = *it; filter.mEnabled = true; filter.mCategoryList = *it; filter.mMatchRule = Matching; filter.mInternal = true; list.append( filter ); } } return list; } void Filter::setMatchRule( MatchRule rule ) { mMatchRule = rule; } Filter::MatchRule Filter::matchRule() const { return mMatchRule; } diff --git a/kaddressbook/filter.h b/kaddressbook/filter.h index 26870d7..93f1352 100644 --- a/kaddressbook/filter.h +++ b/kaddressbook/filter.h @@ -1,138 +1,138 @@ /* This file is part of KAddressBook. Copyright (c) 2002 Mike Pilone <mpilone@slac.com> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #ifndef FILTER_H #define FILTER_H #include <qstring.h> #include <qstringlist.h> #include <qvaluelist.h> #include <kabc/addressee.h> #include <kconfig.h> /** Filter for AddressBook related objects (Addressees) @todo This class should be switched to use shared data. */ class Filter { public: - enum { ShowPublic = 1, ShowPrivate = 2, ShowConfidential = 4}; + enum { ShowPublic = 1, ShowPrivate = 2, ShowConfidential = 4 }; void setCriteria(int c) { mCriteria = c ;} int criteria() const { return mCriteria;} typedef QValueList<Filter> List; enum MatchRule { Matching = 0, NotMatching = 1 }; Filter(); Filter( const QString& name ); ~Filter(); /** Set the name of the filter. */ void setName( const QString &name ); /** @return The name of the filter. */ const QString &name() const; /** @return Whether the filter is an internal one. */ bool isInternal() const; /** Apply the filter to the addressee list. All addressees not passing the filter criterias will be removed from the list. If the MatchRule is NotMatch, then all the addressees matching the filter will be removed from the list. */ void apply( KABC::Addressee::List &addresseeList ); /** Apply the filter to the addressee. @return True if the addressee passes the criteria, false otherwise. The return values are opposite if the MatchRule is NotMatch. */ bool filterAddressee( const KABC::Addressee &a ); /** Enable or disable the filter */ void setEnabled( bool on ); /** @return True if this filter is enabled, false otherwise. */ bool isEnabled() const; /** Set the list of categories. This list is used to filter addressees. */ void setCategories( const QStringList &list ); /** @return The list of categories. */ const QStringList &categories() const; /** Saves the filter to the config file. The group should already be set. */ void save( KConfig *config ); /** Loads the filter from the config file. The group should already be set. */ void restore( KConfig *config ); /** Saves a list of filters to the config file. @param config The config file to use @param baseGroup The base groupname to use. The number of filters will be written to this group, then a _1, _2, etc will be append for each filter saved. @param list The list of filters to be saved. */ static void save( KConfig *config, QString baseGroup, Filter::List &list ); /** Restores a list of filters from a config file. @param config The config file to read from. @param baseGroup The base group name to be used to find the filters @return The list of filters. */ static Filter::List restore( KConfig *config, QString baseGroup ); /** Sets the filter rule. If the rule is Filter::Matching (default), then the filter will return true on items that match the filter. diff --git a/kaddressbook/filtereditdialog.cpp b/kaddressbook/filtereditdialog.cpp index 987f234..1194406 100644 --- a/kaddressbook/filtereditdialog.cpp +++ b/kaddressbook/filtereditdialog.cpp @@ -3,193 +3,192 @@ Copyright (c) 2002 Mike Pilone <mpilone@slac.com> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ /* Enhanced Version of the file for platform independent KDE tools. Copyright (c) 2004 Ulf Schenk $Id$ */ #include <qbuttongroup.h> #include <qhbox.h> #include <qlabel.h> #include <qlayout.h> #include <qpushbutton.h> #include <qradiobutton.h> #include <qcheckbox.h> #include <qregexp.h> #include <qstring.h> #include <qtoolbutton.h> #include <qtooltip.h> #include <qwidget.h> #include <kapplication.h> #include <kbuttonbox.h> #include <kdebug.h> #include <kiconloader.h> #include <klineedit.h> #include <klistbox.h> #include <klistview.h> #include <klocale.h> #include <kglobal.h> #include "kabprefs.h" #include "filtereditdialog.h" FilterEditDialog::FilterEditDialog( QWidget *parent, const char *name ) : KDialogBase( Plain, i18n( "Edit Address Book Filter" ), Help | Ok | Cancel, Ok, parent, name, /*US false*/ true, true ) { initGUI(); QStringList cats = KABPrefs::instance()->mCustomCategories; QStringList::Iterator iter; for ( iter = cats.begin(); iter != cats.end(); ++iter ) mCategoriesView->insertItem( new QCheckListItem( mCategoriesView, (*iter), QCheckListItem::CheckBox ) ); filterNameTextChanged( mNameEdit->text() ); } FilterEditDialog::~FilterEditDialog() { } void FilterEditDialog::setFilter( const Filter &filter ) { mNameEdit->setText( filter.name() ); QStringList categories = filter.categories(); QListViewItem *item = mCategoriesView->firstChild(); while ( item != 0 ) { if ( categories.contains( item->text( 0 ) ) ) { QCheckListItem *checkItem = static_cast<QCheckListItem*>( item ); checkItem->setOn( true ); } item = item->nextSibling(); } if ( filter.matchRule() == Filter::Matching ) mMatchRuleGroup->setButton( 0 ); else mMatchRuleGroup->setButton( 1 ); int c = filter.criteria() ; mPublic->setChecked(c &Filter::ShowPublic); mPrivate->setChecked(c & Filter::ShowPrivate); mConfidential->setChecked(c & Filter::ShowConfidential); - } Filter FilterEditDialog::filter() { Filter filter; filter.setName( mNameEdit->text() ); QStringList categories; QListViewItem *item = mCategoriesView->firstChild(); while ( item != 0 ) { QCheckListItem *checkItem = static_cast<QCheckListItem*>( item ); if ( checkItem->isOn() ) categories.append( item->text( 0 ) ); item = item->nextSibling(); } filter.setCategories( categories ); if ( mMatchRuleGroup->find( 0 )->isOn() ) filter.setMatchRule( Filter::Matching ); else filter.setMatchRule( Filter::NotMatching ); int c = 0; if (mPublic->isChecked()) c |= Filter::ShowPublic; if (mPrivate->isChecked()) c |= Filter::ShowPrivate; if (mConfidential->isChecked()) c |= Filter::ShowConfidential; filter.setCriteria( c ) ; return filter; } void FilterEditDialog::initGUI() { #ifndef KAB_EMBEDDED resize( 490, 300 ); #else //KAB_EMBEDDED resize( KMIN(KGlobal::getDesktopWidth()-10, 490), KMIN(KGlobal::getDesktopHeight()-50, 300)); #endif //KAB_EMBEDDED QWidget *page = plainPage(); QLabel *label; QGridLayout *topLayout = new QGridLayout( page, 3, 2, 0, spacingHint() ); label = new QLabel( i18n( "Name" ), page ); mNameEdit = new KLineEdit( page ); mNameEdit->setFocus(); topLayout->addWidget( label, 0, 0 ); topLayout->addWidget( mNameEdit, 0, 1 ); connect( mNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( filterNameTextChanged( const QString&) ) ); mCategoriesView = new KListView( page ); mCategoriesView->addColumn( i18n( "Categories" ) ); topLayout->addMultiCellWidget( mCategoriesView, 1, 1, 0, 1 ); mMatchRuleGroup = new QHButtonGroup( i18n( "Category rule" ), page ); mMatchRuleGroup->setExclusive( true ); QRadioButton *radio = new QRadioButton( i18n( "Include categories" ), mMatchRuleGroup ); radio->setChecked( true ); //mMatchRuleGroup->insert( radio ); radio = new QRadioButton( i18n( "Exclude categories" ), mMatchRuleGroup ); //mMatchRuleGroup->insert( radio ); topLayout->addMultiCellWidget( mMatchRuleGroup, 2, 2, 0, 1 ); QHButtonGroup * mMatchPPCGroup = new QHButtonGroup(i18n( "Include contacts, that are:" ), page ); mPublic = new QCheckBox( i18n( "public" ), mMatchPPCGroup ); mPrivate = new QCheckBox( i18n( "private" ), mMatchPPCGroup ); mConfidential = new QCheckBox( i18n( "confidential" ), mMatchPPCGroup ); mPublic->setChecked( true ); mPrivate->setChecked( true ); mConfidential->setChecked( true ); topLayout->addMultiCellWidget( mMatchPPCGroup, 3, 3, 0, 1 ); } void FilterEditDialog::filterNameTextChanged( const QString &text ) { enableButtonOK( !text.isEmpty() ); } void FilterEditDialog::slotHelp() { #ifndef KAB_EMBEDDED kapp->invokeHelp( "using-filters" ); #endif //KAB_EMBEDDED } FilterDialog::FilterDialog( QWidget *parent, const char *name ) : KDialogBase( Plain, i18n( "Edit Address Book Filters" ), Ok | Cancel, Ok, parent, name, /*US false*/true, true ) { initGUI(); diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index e61f65f..aa04631 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -170,193 +170,193 @@ class KABCatPrefs : public QDialog public: KABCatPrefs( QWidget *parent=0, const char *name=0 ) : QDialog( parent, name, true ) { setCaption( i18n("Manage new Categories") ); QVBoxLayout* lay = new QVBoxLayout( this ); lay->setSpacing( 3 ); lay->setMargin( 3 ); QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); lay->addWidget( lab ); QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); lay->addWidget( format ); format->setExclusive ( true ) ; addCatBut = new QRadioButton(i18n("Add to category list"), format ); new QRadioButton(i18n("Remove from addressees"), format ); addCatBut->setChecked( true ); QPushButton * ok = new QPushButton( i18n("OK"), this ); lay->addWidget( ok ); QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); lay->addWidget( cancel ); connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); resize( 200, 200 ); } bool addCat() { return addCatBut->isChecked(); } private: QRadioButton* addCatBut; }; class KABFormatPrefs : public QDialog { public: KABFormatPrefs( QWidget *parent=0, const char *name=0 ) : QDialog( parent, name, true ) { setCaption( i18n("Set formatted name") ); QVBoxLayout* lay = new QVBoxLayout( this ); lay->setSpacing( 3 ); lay->setMargin( 3 ); QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this ); lay->addWidget( lab ); QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this ); lay->addWidget( format ); format->setExclusive ( true ) ; simple = new QRadioButton(i18n("Simple: James Bond"), format ); full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format ); reverse = new QRadioButton(i18n("Reverse: Bond, James"), format ); company = new QRadioButton(i18n("Organization: MI6"), format ); simple->setChecked( true ); setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this); lay->addWidget( setCompany ); QPushButton * ok = new QPushButton( i18n("Select contact list"), this ); lay->addWidget( ok ); QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); lay->addWidget( cancel ); connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); resize( 200, 200 ); } public: QRadioButton* simple, *full, *reverse, *company; QCheckBox* setCompany; }; class KAex2phonePrefs : public QDialog { public: KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : QDialog( parent, name, true ) { setCaption( i18n("Export to phone options") ); QVBoxLayout* lay = new QVBoxLayout( this ); lay->setSpacing( 3 ); lay->setMargin( 3 ); QLabel *lab; lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); lab->setAlignment (AlignHCenter ); QHBox* temphb; temphb = new QHBox( this ); new QLabel( i18n("I/O device: "), temphb ); mPhoneDevice = new QLineEdit( temphb); lay->addWidget( temphb ); temphb = new QHBox( this ); new QLabel( i18n("Connection: "), temphb ); mPhoneConnection = new QLineEdit( temphb); lay->addWidget( temphb ); temphb = new QHBox( this ); new QLabel( i18n("Model(opt.): "), temphb ); mPhoneModel = new QLineEdit( temphb); lay->addWidget( temphb ); // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); // lay->addWidget( mWriteToSim ); lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); - lab->setAlignment (AlignHCenter ); + lab->setAlignment (AlignHCenter); QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); lay->addWidget( ok ); QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); lay->addWidget( cancel ); connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); resize( 220, 240 ); } public: QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; QCheckBox* mWriteToSim; }; bool pasteWithNewUid = true; #ifdef KAB_EMBEDDED KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ mReadWrite( readWrite ), mModified( false ), mMainWindow(client) #else //KAB_EMBEDDED KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), mReadWrite( readWrite ), mModified( false ) #endif //KAB_EMBEDDED { // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); // syncManager->setBlockSave(false); mMiniSplitter = 0; mExtensionBarSplitter = 0; mIsPart = !parent->inherits( "KAddressBookMain" ); mAddressBook = KABC::StdAddressBook::self(); KABC::StdAddressBook::setAutomaticSave( false ); #ifndef KAB_EMBEDDED mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); #endif //KAB_EMBEDDED connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), SLOT( addressBookChanged() ) ); #if 0 // LP moved to addressbook init method mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, "X-Department", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, "X-Profession", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, "X-AssistantsName", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, "X-ManagersName", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, "X-SpousesName", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, "X-Office", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, "X-IMAddress", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, "X-Anniversary", "KADDRESSBOOK" ); //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" ); #endif initGUI(); mIncSearchWidget->setFocus(); connect( mViewManager, SIGNAL( selected( const QString& ) ), SLOT( setContactSelected( const QString& ) ) ); connect( mViewManager, SIGNAL( executed( 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& ) ) ); @@ -472,192 +472,194 @@ void KABCore::disableBR(bool b) #endif } void KABCore::recieve( QString fn ) { //qDebug("KABCore::recieve "); int count = mAddressBook->importFromFile( fn, true ); if ( count ) setModified( true ); mViewManager->refreshView(); message(i18n("%1 contact(s) received!").arg( count )); topLevelWidget()->showMaximized(); topLevelWidget()->raise(); } void KABCore::restoreSettings() { mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; bool state; 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 ); } */ mViewManager->restoreSettings(); mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); mExtensionManager->restoreSettings(); #ifdef DESKTOP_VERSION int wid = width(); if ( wid < 10 ) wid = 400; #else int wid = QApplication::desktop()->width(); if ( wid < 640 ) wid = QApplication::desktop()->height(); #endif QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; if ( true /*splitterSize.count() == 0*/ ) { splitterSize.append( wid / 2 ); splitterSize.append( wid / 2 ); } mMiniSplitter->setSizes( splitterSize ); if ( mExtensionBarSplitter ) { //splitterSize = KABPrefs::instance()->mExtensionsSplitter; if ( true /*splitterSize.count() == 0*/ ) { splitterSize.append( wid / 2 ); splitterSize.append( wid / 2 ); } mExtensionBarSplitter->setSizes( splitterSize ); } } 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(); + KABPrefs::instance()->writeConfig(); + qDebug("KABPrefs::instance()->writeConfig() "); } 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 } KActionCollection *KABCore::actionCollection() const { return mGUIClient->actionCollection(); } KABC::Field *KABCore::currentSearchField() const { if (mIncSearchWidget) return mIncSearchWidget->currentField(); else return 0; } QStringList KABCore::selectedUIDs() const { return mViewManager->selectedUids(); } KABC::Resource *KABCore::requestResource( QWidget *parent ) { QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); QPtrList<KRES::Resource> kresResources; QPtrListIterator<KABC::Resource> resIt( kabcResources ); KABC::Resource *resource; while ( ( resource = resIt.current() ) != 0 ) { ++resIt; if ( !resource->readOnly() ) { KRES::Resource *res = static_cast<KRES::Resource*>( resource ); if ( res ) kresResources.append( res ); } } KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); return static_cast<KABC::Resource*>( res ); } #ifndef KAB_EMBEDDED KAboutData *KABCore::createAboutData() #else //KAB_EMBEDDED void KABCore::createAboutData() #endif //KAB_EMBEDDED { #ifndef KAB_EMBEDDED KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), "3.1", I18N_NOOP( "The KDE Address Book" ), KAboutData::License_GPL_V2, I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); about->addAuthor( "Cornelius Schumacher", I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), "schumacher@kde.org" ); about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), "mpilone@slac.com" ); about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), "michel@klaralvdalens-datakonsult.se" ); about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), "hansen@kde.org" ); return about; #endif //KAB_EMBEDDED QString version; #include <../version> QMessageBox::about( this, "About KAddressbook/Pi", "KAddressbook/Platform-independent\n" "(KA/Pi) " +version + " - " + #ifdef DESKTOP_VERSION "Desktop Edition\n" #else "PDA-Edition\n" "for: Zaurus 5500 / 7x0 / 8x0\n" #endif "(c) 2004 Ulf Schenk\n" "(c) 2004 Lutz Rogowski\n" @@ -2592,271 +2594,273 @@ void KABCore::requestForDetails(const QString& sourceChannel, const QString& ses foundUid = uid; } if (!foundUid.isEmpty()) { // raise Ka/Pi if it is in the background #ifndef DESKTOP_VERSION #ifndef KORG_NODCOP //QCopEnvelope e("QPE/Application/kapi", "raise()"); #endif #endif mMainWindow->showMaximized(); mMainWindow-> raise(); mViewManager->setSelected( "", false); mViewManager->refreshView( "" ); mViewManager->setSelected( foundUid, true ); mViewManager->refreshView( foundUid ); if ( !mMultipleViewsAtOnce ) { setDetailsVisible( true ); mActionDetails->setChecked(true); } } } void KABCore::whatsnew() { KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); } void KABCore::synchowto() { KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); } void KABCore::kdesynchowto() { KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); } void KABCore::multisynchowto() { KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); } void KABCore::faq() { KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); } #include <libkcal/syncdefines.h> KABC::Addressee KABCore::getLastSyncAddressee() { Addressee lse; QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); if (lse.isEmpty()) { qDebug("Creating new last-syncAddressee "); lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); QString sum = ""; if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) sum = "E: "; lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); lse.setRevision( mLastAddressbookSync ); lse.setCategories( i18n("SyncEvent") ); mAddressBook->insertAddressee( lse ); } return lse; } int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) { //void setZaurusId(int id); // int zaurusId() const; // void setZaurusUid(int id); // int zaurusUid() const; // void setZaurusStat(int id); // int zaurusStat() const; // 0 equal // 1 take local // 2 take remote // 3 cancel QDateTime lastSync = mLastAddressbookSync; QDateTime localMod = local->revision(); QDateTime remoteMod = remote->revision(); QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { bool remCh, locCh; remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); locCh = ( localMod > mLastAddressbookSync ); + //qDebug("cahnged rem %d loc %d",remCh, locCh ); if ( !remCh && ! locCh ) { //qDebug("both not changed "); lastSync = localMod.addDays(1); if ( mode <= SYNC_PREF_ASK ) return 0; } else { if ( locCh ) { //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); lastSync = localMod.addDays( -1 ); if ( !remCh ) remoteMod =( lastSync.addDays( -1 ) ); } else { //qDebug(" not loc changed "); lastSync = localMod.addDays( 1 ); if ( remCh ) { //qDebug("rem changed "); remoteMod =( lastSync.addDays( 1 ) ); } } } full = true; if ( mode < SYNC_PREF_ASK ) mode = SYNC_PREF_ASK; } else { if ( localMod == remoteMod ) return 0; } //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); //qDebug("lastsync %s ", lastSync.toString().latin1() ); //full = true; //debug only if ( full ) { bool equ = ( (*local) == (*remote) ); if ( equ ) { //qDebug("equal "); if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); } if ( mode < SYNC_PREF_FORCE_LOCAL ) return 0; }//else //debug only //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); } int result; bool localIsNew; //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); if ( full && mode < SYNC_PREF_NEWEST ) mode = SYNC_PREF_ASK; switch( mode ) { case SYNC_PREF_LOCAL: if ( lastSync > remoteMod ) return 1; if ( lastSync > localMod ) return 2; return 1; break; case SYNC_PREF_REMOTE: if ( lastSync > remoteMod ) return 1; if ( lastSync > localMod ) return 2; return 2; break; case SYNC_PREF_NEWEST: if ( localMod > remoteMod ) return 1; else return 2; break; case SYNC_PREF_ASK: //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); if ( lastSync > remoteMod ) return 1; - if ( lastSync > localMod ) + if ( lastSync > localMod ) { return 2; + } localIsNew = localMod >= remoteMod; //qDebug("conflict! ************************************** "); { KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); result = acd.executeD(localIsNew); return result; } break; case SYNC_PREF_FORCE_LOCAL: return 1; break; case SYNC_PREF_FORCE_REMOTE: return 2; break; default: // SYNC_PREF_TAKE_BOTH not implemented break; } return 0; } bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) { bool syncOK = true; int addedAddressee = 0; int addedAddresseeR = 0; int deletedAddresseeR = 0; int deletedAddresseeL = 0; int changedLocal = 0; int changedRemote = 0; QString mCurrentSyncName = syncManager->getCurrentSyncName(); QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); //QPtrList<Addressee> el = local->rawAddressees(); Addressee addresseeR; QString uid; int take; Addressee addresseeL; Addressee addresseeRSync; Addressee addresseeLSync; // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); bool fullDateRange = false; local->resetTempSyncStat(); mLastAddressbookSync = QDateTime::currentDateTime(); if ( syncManager->syncWithDesktop() ) { // remote->removeSyncInfo( QString());//remove all info if ( KSyncManager::mRequestedSyncEvent.isValid() ) { mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); } else { qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); } } QDateTime modifiedCalendar = mLastAddressbookSync; addresseeLSync = getLastSyncAddressee(); qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); if ( !addresseeR.isEmpty() ) { addresseeRSync = addresseeR; remote->removeAddressee(addresseeR ); } else { if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { addresseeRSync = addresseeLSync ; } else { //qDebug("FULLDATE 1"); fullDateRange = true; Addressee newAdd; addresseeRSync = newAdd; addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); addresseeRSync.setRevision( mLastAddressbookSync ); addresseeRSync.setCategories( i18n("SyncAddressee") ); } } if ( addresseeLSync.revision() == mLastAddressbookSync ) { // qDebug("FULLDATE 2"); fullDateRange = true; } if ( ! fullDateRange ) { if ( addresseeLSync.revision() != addresseeRSync.revision() ) { // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); fullDateRange = true; //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); } } // fullDateRange = true; // debug only! if ( fullDateRange ) mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); else @@ -2913,196 +2917,198 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); local->insertAddressee( inL, false ); idS = inR.externalUID(); OidS = inR.originalExternalUID(); } else idS = inR.IDStr(); remote->removeAddressee( inR ); inR = inL; inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { inR.setOriginalExternalUID( OidS ); inR.setExternalUID( idS ); if ( syncManager->syncWithDesktop() ) { inR.setIDStr("changed" ); } //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); } else { inR.setIDStr( idS ); } inR.setResource( 0 ); remote->insertAddressee( inR , false); ++changedRemote; } else { // take == 2 take remote ********************** if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { if ( inR.revision().date().year() < 2004 ) inR.setRevision( modifiedCalendar ); } idS = inL.IDStr(); local->removeAddressee( inL ); inL = inR; inL.setIDStr( idS ); if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); } inL.setResource( 0 ); local->insertAddressee( inL , false ); ++changedLocal; } } } } else { // no conflict ********** add or delete remote if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { QString des = addresseeLSync.note(); if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); remote->insertAddressee( inR, false ); ++deletedAddresseeR; } else { inR.setRevision( modifiedCalendar ); remote->insertAddressee( inR, false ); inL = inR; inL.setIDStr( ":" ); inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); inL.setResource( 0 ); local->insertAddressee( inL , false); ++addedAddressee; } } else { if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { inR.setRevision( modifiedCalendar ); remote->insertAddressee( inR, false ); inR.setResource( 0 ); local->insertAddressee( inR, false ); ++addedAddressee; } else { // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); remote->removeAddressee( inR ); ++deletedAddresseeR; } } } } } ++incCounter; } er.clear(); QStringList el = local->uidList(); modulo = (el.count()/10)+1; syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); incCounter = 0; while ( incCounter < el.count()) { qApp->processEvents(); if (syncManager->isProgressBarCanceled()) return false; if ( incCounter % modulo == 0 ) syncManager->showProgressBar(incCounter); uid = el[ incCounter ]; bool skipIncidence = false; if ( uid.left(19) == QString("last-syncAddressee-") ) skipIncidence = true; - if ( !filterOUT.name().isEmpty() && ! filterOUT.filterAddressee( inL ) ) - skipIncidence = true; - if ( !skipIncidence ) { + if ( ! skipIncidence ) { inL = local->findByUid( uid ); + if ( (!filterOUT.name().isEmpty()) && (! filterOUT.filterAddressee( inL ) ) ) + skipIncidence = true; + } + if ( !skipIncidence ) { if ( !inL.resource() || inL.resource()->includeInSync() ) { inR = remote->findByUid( uid ); if ( inR.isEmpty() ) { // no conflict ********** add or delete local if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); local->removeAddressee( inL ); ++deletedAddresseeL; } else { if ( ! syncManager->mWriteBackExistingOnly ) { inL.removeID(mCurrentSyncDevice ); ++addedAddresseeR; inL.setRevision( modifiedCalendar ); local->insertAddressee( inL, false ); inR = inL; inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); inR.setResource( 0 ); remote->insertAddressee( inR, false ); } } } else { if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { //qDebug("data %s ", inL.revision().toString().latin1()); // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); local->removeAddressee( inL ); ++deletedAddresseeL; } else { if ( ! syncManager->mWriteBackExistingOnly ) { ++addedAddresseeR; inL.setRevision( modifiedCalendar ); local->insertAddressee( inL, false ); inR = inL; inR.setIDStr( ":" ); inR.setResource( 0 ); remote->insertAddressee( inR, false ); } } } } } } ++incCounter; } el.clear(); syncManager->hideProgressBar(); mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); // get rid of micro seconds QTime t = mLastAddressbookSync.time(); mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); addresseeLSync.setRevision( mLastAddressbookSync ); addresseeRSync.setRevision( mLastAddressbookSync ); addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); addresseeRSync.setNote( "" ) ; addresseeLSync.setNote( "" ); if ( mGlobalSyncMode == SYNC_MODE_NORMAL) remote->insertAddressee( addresseeRSync, false ); local->insertAddressee( addresseeLSync, false ); QString mes; mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); qDebug( mes ); mes = i18n("Local addressbook changed!\n") +mes; if ( syncManager->mShowSyncSummary ) { if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, i18n("KA/Pi Synchronization"),i18n("Write back"))) { qDebug("cancelled "); return false; } } return syncOK; } //this is a overwritten callbackmethods from the syncinterface bool KABCore::sync(KSyncManager* manager, QString filename, int mode) { //pending prepare addresseeview for output //pending detect, if remote file has REV field. if not switch to external sync mGlobalSyncMode = SYNC_MODE_NORMAL; if ( manager != syncManager ) qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); AddressBook abLocal(filename,"syncContact"); bool syncOK = false; if ( abLocal.load() ) { qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); bool external = false; bool isXML = false; if ( filename.right(4) == ".xml") { diff --git a/kaddressbook/kaddressbookmain.cpp b/kaddressbook/kaddressbookmain.cpp index 2832257..519dc92 100644 --- a/kaddressbook/kaddressbookmain.cpp +++ b/kaddressbook/kaddressbookmain.cpp @@ -134,106 +134,106 @@ void KAddressBookMain::saveProperties( KConfig* ) void KAddressBookMain::readProperties( KConfig* ) { } void KAddressBookMain::initActions() { #ifndef KAB_EMBEDDED KStdAction::quit( this, SLOT( close() ), actionCollection() ); KStdAction::configureToolbars( this, SLOT( configureToolbars() ), actionCollection() ); #else //KAB_EMBEDDED //US: transfered the setup of the actions into KABCore #endif //KAB_EMBEDDED } //US new method to setup menues and toolbars on embedded systems #ifdef KAB_EMBEDDED /* QToolBar * KAddressBookMain::getIconToolBar() { return iconToolBar; } */ void KAddressBookMain::createGUI() { } #endif //KAB_EMBEDDED void KAddressBookMain::configureToolbars() { #ifndef KAB_EMBEDDED saveMainWindowSettings( KGlobal::config(), "MainWindow" ); KEditToolbar dlg( factory() ); connect( &dlg, SIGNAL( newToolbarConfig() ), SLOT( slotNewToolbarConfig() ) ); dlg.exec(); #else //KAB_EMBEDDED qDebug("KAddressBookMain::configureToolbars() not implemented by ulf" ); #endif //KAB_EMBEDDED } void KAddressBookMain::slotNewToolbarConfig() { #ifndef KAB_EMBEDDED applyMainWindowSettings( KGlobal::config(), "MainWindow" ); #else //KAB_EMBEDDED qDebug("KAddressBookMain::slotNewToolbarConfig() not implemented by ulf" ); #endif //KAB_EMBEDDED } void KAddressBookMain::configureKeys() { #ifndef KAB_EMBEDDED KKeyDialog::configureKeys( actionCollection(), xmlFile(), true, this ); #else //KAB_EMBEDDED qDebug("KAddressBookMain::configureKeys() not implemented by ulf" ); #endif //KAB_EMBEDDED } void KAddressBookMain::closeEvent( QCloseEvent* ce ) { bool mModified = mCore->modified(); bool mAskForQuit = KABPrefs::instance()->mAskForQuit; QString mess = i18n( "Close KA/Pi?"); if ( mModified == true ) mess += i18n( "\nChanges will be saved!"); else mess += i18n( "\nNo unsaved changes detected!\nNothing will be saved!"); bool mQuit = true; if (mAskForQuit) { int res = QMessageBox::information( this, "KA/Pi", mess , i18n("Yes!"), i18n("No"), 0, 0 ); if (res == 0) mQuit = true; else mQuit = false; } if (mQuit == false) return; if (mModified == true) { save(); mCore->saveSettings(); - KABPrefs::instance()->writeConfig(); + //KABPrefs::instance()->writeConfig(); } ce->accept(); } #ifndef KAB_EMBEDDED #include "kaddressbookmain.moc" #endif //KAB_EMBEDDED diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp index 9c3a641..4be860e 100644 --- a/kaddressbook/viewmanager.cpp +++ b/kaddressbook/viewmanager.cpp @@ -190,198 +190,197 @@ void ViewManager::setSelected( const QString &uid, bool selected ) if ( mActiveView ) mActiveView->setSelected( uid, selected ); } void ViewManager::setListSelected(QStringList list) { int i, count = list.count(); for ( i = 0; i < count;++i ) setSelected( list[i], true ); } void ViewManager::unloadViews() { mViewDict.clear(); mActiveView = 0; } void ViewManager::setActiveView( const QString &name ) { KAddressBookView *view = 0; // Check that this isn't the same as the current active view if ( mActiveView && ( mActiveView->caption() == name ) ) return; // At this point we know the view that should be active is not // currently active. We will try to find the new on in the list. If // we can't find it, it means it hasn't been instantiated, so we will // create it on demand. view = mViewDict.find( name ); // Check if we found the view. If we didn't, then we need to create it if ( view == 0 ) { KConfig *config = mCore->config(); KConfigGroupSaver saver( config, name ); QString type = config->readEntry( "Type", "Table" ); kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl; ViewFactory *factory = mViewFactoryDict.find( type ); if ( factory ) view = factory->view( mCore->addressBook(), mViewWidgetStack ); if ( view ) { view->setCaption( name ); mViewDict.insert( name, view ); //US my version needs an int as second parameter to addWidget mViewWidgetStack->addWidget( view, -1 ); view->readConfig( config ); // The manager just relays the signals connect( view, SIGNAL( selected( const QString& ) ), SIGNAL( selected( const QString & ) ) ); connect( view, SIGNAL( executed( const QString& ) ), SIGNAL( executed( const QString& ) ) ); connect( view, SIGNAL( deleteRequest( ) ), SIGNAL( deleteRequest( ) ) ); connect( view, SIGNAL( modified() ), SIGNAL( modified() ) ); connect( view, SIGNAL( dropped( QDropEvent* ) ), SLOT( dropped( QDropEvent* ) ) ); connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) ); } } // If we found or created the view, raise it and refresh it if ( view ) { mActiveView = view; mViewWidgetStack->raiseWidget( view ); // Set the proper filter in the view. By setting the combo // box, the activated slot will be called, which will push // the filter to the view and refresh it. if ( view->defaultFilterType() == KAddressBookView::None ) { mActionSelectFilter->setCurrentItem( 0 ); setActiveFilter( 0 ); } else if ( view->defaultFilterType() == KAddressBookView::Active ) { setActiveFilter( mActionSelectFilter->currentItem() ); } else { uint pos = filterPosition( view->defaultFilterName() ); mActionSelectFilter->setCurrentItem( pos ); setActiveFilter( pos ); } //US qDebug("ViewManager::setActiveView 6" ); // Update the inc search widget to show the fields in the new active // view. mCore->setSearchFields( mActiveView->fields() ); //US performance optimization. setActiveFilter calls also mActiveView->refresh() //US mActiveView->refresh(); - + mCore->saveSettings(); } else { qDebug("ViewManager::setActiveView: unable to find view" ); - kdDebug(5720) << "ViewManager::setActiveView: unable to find view\n"; } } //US added another method with no parameter, since my moc compiler does not support default parameters. void ViewManager::refreshView() { refreshView( QString::null ); } void ViewManager::refreshView( const QString &uid ) { if ( mActiveView ) mActiveView->refresh( uid ); } void ViewManager::setFocusAV() { if ( mActiveView ) mActiveView->setFocusAV(); } void ViewManager::editView() { if ( !mActiveView ) return; ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() ); ViewConfigureWidget *wdg = 0; ViewConfigureDialog* dlg = 0; if ( factory ) { // Save the filters so the dialog has the latest set Filter::save( mCore->config(), "Filter", mFilterList ); dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" ); wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" ); } else { qDebug("ViewManager::editView()::cannot find viewfactory "); return; } if ( wdg ) { dlg->setWidget( wdg ); #ifndef DESKTOP_VERSION //dlg.setMaximumSize( 640, 480 ); //dlg->setGeometry( 40,40, 400, 300); dlg->showMaximized(); #endif KConfigGroupSaver saver( mCore->config(), mActiveView->caption() ); dlg->restoreSettings( mCore->config() ); if ( dlg->exec() ) { dlg->saveSettings( mCore->config() ); mActiveView->readConfig( mCore->config() ); // Set the proper filter in the view. By setting the combo // box, the activated slot will be called, which will push // the filter to the view and refresh it. if ( mActiveView->defaultFilterType() == KAddressBookView::None ) { mActionSelectFilter->setCurrentItem( 0 ); setActiveFilter( 0 ); } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) { setActiveFilter( mActionSelectFilter->currentItem() ); } else { uint pos = filterPosition( mActiveView->defaultFilterName() ); mActionSelectFilter->setCurrentItem( pos ); setActiveFilter( pos ); } mCore->setSearchFields( mActiveView->fields() ); //US performance optimization. setActiveFilter calls also mActiveView->refresh() //US mActiveView->refresh(); //US this is a bugfix, that we get notified if we change a views configuration emit modified(); } } delete dlg; } void ViewManager::deleteView() { QString text = i18n( "<qt>Are you sure that you want to delete the view <b>%1</b>?</qt>" ) .arg( mActiveView->caption() ); QString caption = i18n( "Confirm Delete" ); if (QMessageBox::information( this, caption, text, i18n("Yes!"), i18n("No"), 0, 0 ) == 0) { mViewNameList.remove( mActiveView->caption() ); // remove the view from the config file KConfig *config = mCore->config(); |