summaryrefslogtreecommitdiffabout
path: root/kaddressbook/addresseeeditorwidget.cpp
Side-by-side diff
Diffstat (limited to 'kaddressbook/addresseeeditorwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/addresseeeditorwidget.cpp50
1 files changed, 43 insertions, 7 deletions
diff --git a/kaddressbook/addresseeeditorwidget.cpp b/kaddressbook/addresseeeditorwidget.cpp
index c4083a9..4313998 100644
--- a/kaddressbook/addresseeeditorwidget.cpp
+++ b/kaddressbook/addresseeeditorwidget.cpp
@@ -332,13 +332,17 @@ void AddresseeEditorWidget::setupTab1()
categoryBox->setMargin( KDialogBase::marginHintSmall() );
// Categories
- button = new QPushButton( i18n( "Categories" ), categoryBox );
+ button = new QPushButton( i18n( "Categories" )+":", categoryBox );
connect( button, SIGNAL( clicked() ), SLOT( categoryButtonClicked() ) );
- mCategoryEdit = new KLineEdit( categoryBox );
- mCategoryEdit->setReadOnly( true );
- connect( mCategoryEdit, SIGNAL( textChanged( const QString& ) ),
- SLOT( textChanged( const QString& ) ) );
+ mCategoryEdit = new QPushButton ( categoryBox );
+ mCategoryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Fixed ,FALSE) );
+ mCatPopup = new QPopupMenu ( categoryBox );
+ mCategoryEdit->setPopup( mCatPopup );
+ connect(mCatPopup,SIGNAL(aboutToShow () ), this ,SLOT(showCatPopup()));
+ connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT(selectedCatPopup( int )));
+ //connect( mCategoryEdit, SIGNAL( textChanged( const QString& ) ),
+ // SLOT( textChanged( const QString& ) ) );
mSecrecyWidget = new SecrecyWidget( categoryBox );
connect( mSecrecyWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
@@ -352,13 +356,45 @@ void AddresseeEditorWidget::setupTab1()
mTabWidget->addTab( tab1, i18n( "&General" ) );
}
+void AddresseeEditorWidget::showCatPopup()
+{
+ mCatPopup->clear();
+ QStringList checkedCategories = QStringList::split (",", mCategoryEdit->text());
+ int index = 0;
+ for (QStringList::Iterator it = KABPrefs::instance()->mCustomCategories.begin ();
+ it != KABPrefs::instance()->mCustomCategories.end ();
+ ++it) {
+ mCatPopup->insertItem (*it, index );
+ //mCategory[index] = *it;
+ if (checkedCategories.find (*it) != checkedCategories.end ()) mCatPopup->setItemChecked (index, true);
+ ++index;
+ }
+}
+void AddresseeEditorWidget::selectedCatPopup( int index )
+{
+ QStringList categories = QStringList::split (",", mCategoryEdit->text());
+ QString colcat = categories.first();
+ if (categories.find ( KABPrefs::instance()->mCustomCategories[index]) != categories.end ())
+ categories.remove (KABPrefs::instance()->mCustomCategories[index]);
+ else
+ categories.insert (categories.end(), KABPrefs::instance()->mCustomCategories[index]);
+ categories.sort ();
+ if ( !colcat.isEmpty() ) {
+ if ( categories.find ( colcat ) != categories.end () ) {
+ categories.remove( colcat );
+ categories.prepend( colcat );
+ }
+ }
+ mCategoryEdit->setText( categories.join(",") );
+ emitModified();
+}
void AddresseeEditorWidget::setRole2FN()
{
if ( mRoleEdit->text().isEmpty() ) return;
mFormattedNameType = NameEditDialog::CustomName;
mAddressee.setFormattedName( mRoleEdit->text() );
mFormattedNameLabel->setText( mRoleEdit->text() );
- mDirty = true;
+ emitModified();
}
void AddresseeEditorWidget::setCompany2FN()
{
@@ -366,7 +402,7 @@ void AddresseeEditorWidget::setCompany2FN()
mFormattedNameType = NameEditDialog::CustomName;
mAddressee.setFormattedName( mOrgEdit->text() );
mFormattedNameLabel->setText( mOrgEdit->text() );
- mDirty = true;
+ emitModified();
}
void AddresseeEditorWidget::setupTab1_1()