From 32479683283fc9f20d369ac9671ba0f8a33d3381 Mon Sep 17 00:00:00 2001 From: zautrix Date: Mon, 17 Jan 2005 18:22:47 +0000 Subject: fast set formatted name --- diff --git a/kaddressbook/imagewidget.cpp b/kaddressbook/imagewidget.cpp index 9ee4eac..1e9743c 100644 --- a/kaddressbook/imagewidget.cpp +++ b/kaddressbook/imagewidget.cpp @@ -53,7 +53,7 @@ ImageWidget::ImageWidget( QWidget *parent, const char *name ) KDialog::spacingHint() ); QGroupBox *photoBox = new QGroupBox( 0, Qt::Vertical, i18n( "Photo" ), this ); - QGridLayout *boxLayout = new QGridLayout( photoBox->layout(), 4, 2, + QGridLayout *boxLayout = new QGridLayout( photoBox->layout(), 3, 2, KDialog::spacingHint() ); boxLayout->setRowStretch( 2, 1 ); @@ -75,20 +75,19 @@ ImageWidget::ImageWidget( QWidget *parent, const char *name ) boxLayout->addWidget( mPhotoUrl, 0, 1 ); - - mUsePhotoUrl = new QCheckBox( i18n( "Store as URL" ), photoBox ); + QHBox *hb1 = new QHBox ( photoBox ); + mUsePhotoUrl = new QCheckBox( i18n( "Store as URL" ), hb1 ); mUsePhotoUrl->setEnabled( false ); - boxLayout->addWidget( mUsePhotoUrl, 1, 1 ); + boxLayout->addWidget( hb1, 1, 1 ); - QPushButton * pb = new QPushButton( i18n( "Remove" ), photoBox ); + QPushButton * pb = new QPushButton( i18n( "Remove" ), hb1 ); connect( pb, SIGNAL( clicked() ),this, SLOT( removePhoto() ) ); - boxLayout->addWidget( pb, 2, 1 ); - boxLayout->addWidget( new QLabel( photoBox ), 3, 1 ); + boxLayout->addWidget( new QLabel( photoBox ), 2, 1 ); topLayout->addWidget( photoBox, 0, 0 ); QGroupBox *logoBox = new QGroupBox( 0, Qt::Vertical, i18n( "Logo" ), this ); - boxLayout = new QGridLayout( logoBox->layout(), 4, 2, KDialog::spacingHint() ); + boxLayout = new QGridLayout( logoBox->layout(), 3, 2, KDialog::spacingHint() ); boxLayout->setRowStretch( 2, 1 ); mLogoLabel = new QLabel( logoBox ); @@ -105,14 +104,14 @@ ImageWidget::ImageWidget( QWidget *parent, const char *name ) #endif //KAB_EMBEDDED boxLayout->addWidget( mLogoUrl, 0, 1 ); - mUseLogoUrl = new QCheckBox( i18n( "Store as URL" ), logoBox ); + QHBox *hb2 = new QHBox ( logoBox ); + mUseLogoUrl = new QCheckBox( i18n( "Store as URL" ), hb2 ); mUseLogoUrl->setEnabled( false ); - boxLayout->addWidget( mUseLogoUrl, 1, 1 ); + boxLayout->addWidget( hb2, 1, 1 ); - pb = new QPushButton( i18n( "Remove" ), logoBox ); + pb = new QPushButton( i18n( "Remove" ), hb2 ); connect( pb, SIGNAL( clicked() ),this, SLOT( removeLogo() ) ); - boxLayout->addWidget( pb, 2, 1 ); - boxLayout->addWidget( new QLabel( logoBox ), 3, 1 ); + boxLayout->addWidget( new QLabel( logoBox ), 2, 1 ); topLayout->addWidget( logoBox, 1, 0 ); connect( mPhotoUrl, SIGNAL( textChanged( const QString& ) ), diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 9526f23..d393660 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -225,7 +225,8 @@ class KABFormatPrefs : public QDialog lay->addWidget( cancel ); connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); - resize( 200, 200 ); + //resize( 200, 200 ); + } public: QRadioButton* simple, *full, *reverse, *company; @@ -1373,7 +1374,8 @@ void KABCore::save() 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. " ); - message(i18n("Saving addressbook ... ")); + message(i18n("Saving ... please wait! ")); + qApp->processEvents(); #ifndef KAB_EMBEDDED KABC::StdAddressBook *b = dynamic_cast( mAddressBook ); if ( !b || !b->save() ) { @@ -2363,31 +2365,37 @@ void KABCore::setFormattedName() if ( !setpref.exec() ) { return; } - KABC::Addressee::List list; XXPortSelectDialog dlg( this, false, this ); - if ( dlg.exec() ) - list = dlg.contacts(); - else + if ( !dlg.exec() ) return; - KABC::Addressee::List::Iterator it; - for ( it = list.begin(); it != list.end(); ++it ) { - QString fName; - if ( setpref.simple->isChecked() ) - fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); - else if ( setpref.full->isChecked() ) - fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); - else if ( setpref.reverse->isChecked() ) - fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); - else - fName = (*it).organization(); - if ( setpref.setCompany->isChecked() ) - if ( fName.isEmpty() || fName =="," ) + mAddressBook->setUntagged(); + dlg.tagSelected(); + int count = 0; + KABC::AddressBook::Iterator it; + for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { + if ( (*it).tagged() ) { + message(i18n("Changing contact #%1").arg( ++count ) ); + qApp->processEvents(); + QString fName; + if ( setpref.simple->isChecked() ) + fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); + else if ( setpref.full->isChecked() ) + fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); + else if ( setpref.reverse->isChecked() ) + fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); + else fName = (*it).organization(); - (*it).setFormattedName( fName ); - addrModified((*it),false ); + if ( setpref.setCompany->isChecked() ) + if ( fName.isEmpty() || fName =="," ) + fName = (*it).organization(); + (*it).setFormattedName( fName ); + } } + message(i18n("Refreshing view...") ); + mViewManager->refreshView( "" ); Addressee add; mDetails->setAddressee( add ); + message(i18n("Setting formatted name completed!") ); } void KABCore::clipboardDataChanged() @@ -3206,7 +3214,7 @@ bool KABCore::syncExternal(KSyncManager* manager, QString resource) void KABCore::message( QString m ) { topLevelWidget()->setCaption( m ); - mMessageTimer->start( 15000, true ); + mMessageTimer->start( 20000, true ); } bool KABCore::syncPhone() { diff --git a/kaddressbook/xxportselectdialog.cpp b/kaddressbook/xxportselectdialog.cpp index 6282453..e7bc8c0 100644 --- a/kaddressbook/xxportselectdialog.cpp +++ b/kaddressbook/xxportselectdialog.cpp @@ -54,7 +54,7 @@ $Id$ XXPortSelectDialog::XXPortSelectDialog( KABCore *core, bool sort, QWidget* parent, const char* name ) - : KDialogBase( Plain, i18n( "Choose which contacts to select" ), Help | Ok | Cancel, + : KDialogBase( Plain, i18n( "Choose contact selection" ), Help | Ok | Cancel, Ok, parent, name, true, true ), mCore( core ), mUseSorting( sort ) { @@ -109,13 +109,53 @@ QStringList XXPortSelectDialog::uids() uidlist.append((*it).uid()); return uidlist; } +void XXPortSelectDialog::tagSelected() +{ + if ( mUseSelection->isChecked() ) { + + QStringList selection = mCore->selectedUIDs(); + KABC::AddressBook::Iterator it; + for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) { + if ( selection.findIndex((*it).uid()) >= 0 ) + (*it).setTagged( true ); + } + } else if ( mUseFilters->isChecked() ) { + // find contacts that can pass selected filter + Filter::List::Iterator filterIt; + for ( filterIt = mFilters.begin(); filterIt != mFilters.end(); ++filterIt ) + if ( (*filterIt).name() == mFiltersCombo->currentText() ) + break; + KABC::AddressBook::Iterator it; + for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) { + if ( (*filterIt).filterAddressee( *it ) ) + (*it).setTagged( true ); + } + } else if ( mUseCategories->isChecked() ) { + QStringList categorieList = categories(); + KABC::AddressBook::Iterator it; + for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) { + QStringList tmp( (*it).categories() ); + QStringList::Iterator tmpIt; + for ( tmpIt = tmp.begin(); tmpIt != tmp.end(); ++tmpIt ) + if ( categorieList.contains( *tmpIt ) ) { + (*it).setTagged( true ); + break; + } + } + } else { + // create a string list of all entries: + KABC::AddressBook::Iterator it; + for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) + (*it).setTagged( true ); + } +} KABC::AddresseeList XXPortSelectDialog::contacts() { - QStringList selection = mCore->selectedUIDs(); KABC::AddresseeList list; if ( mUseSelection->isChecked() ) { QStringList::Iterator it; + QStringList selection = mCore->selectedUIDs(); for ( it = selection.begin(); it != selection.end(); ++it ) { KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); if ( !addr.isEmpty() ) @@ -246,8 +286,8 @@ void XXPortSelectDialog::initGUI() QWhatsThis::add( mCategoriesView, i18n( "Check the categories whose members you want to select." ) ); groupLayout->addWidget( mCategoriesView, 3, 1 ); - // if (QApplication::desktop()->height() == 480 ) - // mCategoriesView->setMaximumHeight( 240 ); + if (QApplication::desktop()->height() == 480 ) + mCategoriesView->setMaximumHeight( 240 ); topLayout->addWidget( mButtonGroup ); QButtonGroup *sortingGroup = new QButtonGroup( i18n( "Sorting" ), page ); diff --git a/kaddressbook/xxportselectdialog.h b/kaddressbook/xxportselectdialog.h index 3bb696f..28b1fef 100644 --- a/kaddressbook/xxportselectdialog.h +++ b/kaddressbook/xxportselectdialog.h @@ -48,6 +48,7 @@ class XXPortSelectDialog : public KDialogBase const char* name = 0 ); KABC::AddresseeList contacts(); + void tagSelected(); QStringList uids(); private slots: -- cgit v0.9.0.2