-rw-r--r-- | kaddressbook/addresseeeditorwidget.cpp | 50 | ||||
-rw-r--r-- | kaddressbook/addresseeeditorwidget.h | 5 |
2 files changed, 47 insertions, 8 deletions
diff --git a/kaddressbook/addresseeeditorwidget.cpp b/kaddressbook/addresseeeditorwidget.cpp index c4083a9..4313998 100644 --- a/kaddressbook/addresseeeditorwidget.cpp +++ b/kaddressbook/addresseeeditorwidget.cpp @@ -303,99 +303,135 @@ void AddresseeEditorWidget::setupTab1() //US loadIcon call is ambiguous. Add one more parameter //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop) ); label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop, 0) ); layout->addMultiCellWidget( label, 8, 9, 3, 3 ); label = new QLabel( i18n( "URL:" ), tab1 ); mURLEdit = new KLineEdit( tab1 ); connect( mURLEdit, SIGNAL( textChanged( const QString& ) ), SLOT( textChanged( const QString& ) ) ); label->setBuddy( mURLEdit ); layout->addWidget( label, 8, 4 ); layout->addMultiCellWidget( mURLEdit, 8, 8, 5, 6 ); label = new QLabel( i18n( "&IM address:" ), tab1 ); mIMAddressEdit = new KLineEdit( tab1 ); connect( mIMAddressEdit, SIGNAL( textChanged( const QString& ) ), SLOT( textChanged( const QString& ) ) ); label->setBuddy( mIMAddressEdit ); layout->addWidget( label, 9, 4 ); layout->addMultiCellWidget( mIMAddressEdit, 9, 9, 5, 6 ); layout->addColSpacing( 6, 50 ); bar = new KSeparator( KSeparator::HLine, tab1 ); layout->addMultiCellWidget( bar, 10, 10, 0, 6 ); */ /////////////////////////////////////// QHBox *categoryBox = new QHBox( tab1 ,"cato"); categoryBox->setSpacing( KDialogBase::spacingHint() ); 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() ) ); //US layout->addMultiCellWidget( categoryBox, 11, 11, 0, 6 ); layout->addMultiCellWidget( categoryBox, iii, iii, 0, maxCol ); // Build the layout and add to the tab widget layout->activate(); // required 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() { if ( mOrgEdit->text().isEmpty() ) return; mFormattedNameType = NameEditDialog::CustomName; mAddressee.setFormattedName( mOrgEdit->text() ); mFormattedNameLabel->setText( mOrgEdit->text() ); - mDirty = true; + emitModified(); } void AddresseeEditorWidget::setupTab1_1() { // This is the Address tab QWidget *tab1_1 = new QWidget( mTabWidget ); //US QGridLayout *layout = new QGridLayout( tab1_1, 11, 7 ); QGridLayout *layout = new QGridLayout( tab1_1, 7, 2 ); layout->setMargin( KDialogBase::marginHintSmall() ); layout->setSpacing( KDialogBase::spacingHintSmall() ); QLabel *label; KSeparator* bar; QPushButton *button; /*US ////////////////////////////////// // Upper left group (person info) // Person icon label = new QLabel( tab1 ); //US ambiguous call. Add one more parameter //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) ); label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) ); layout->addMultiCellWidget( label, 0, 1, 0, 0 ); // First name button = new QPushButton( i18n( "Name..." ), tab1 ); QToolTip::add( button, i18n( "Edit the contact's name" ) ); mNameEdit = new KLineEdit( tab1, "mNameEdit" ); connect( mNameEdit, SIGNAL( textChanged( const QString& ) ), diff --git a/kaddressbook/addresseeeditorwidget.h b/kaddressbook/addresseeeditorwidget.h index eaf5b16..1703e2f 100644 --- a/kaddressbook/addresseeeditorwidget.h +++ b/kaddressbook/addresseeeditorwidget.h @@ -60,126 +60,129 @@ class SoundWidget; namespace KPIM { class CategorySelectDialog; class CategoryEditDialog; } namespace KABC { class AddressBook; } class AddresseeEditorWidget : public ExtensionWidget { Q_OBJECT public: AddresseeEditorWidget( KABCore *core, bool isExtension, QWidget *parent, const char *name = 0 ); ~AddresseeEditorWidget(); void setAddressee( const KABC::Addressee& ); const KABC::Addressee &addressee(); void contactsSelectionChanged(); void load(); void save(); bool dirty(); QString title() const; QString identifier() const; protected slots: + void showCatPopup(); + void selectedCatPopup( int ); void setRole2FN(); void setCompany2FN(); void textChanged( const QString& ); void pageChanged( QWidget *wdg ); /** Emits the modified signal and sets the dirty flag. Any slot that modifies data should use this method instead of calling emit modified() directly. */ void emitModified(); void dateChanged( QDate ); void invalidDate(); void nameTextChanged( const QString& ); void nameBoxChanged(); void nameButtonClicked(); void categoryButtonClicked(); /** Called whenever the categories change in the categories dialog. */ void categoriesSelected( const QStringList& ); /** Edits which categories are available in the CategorySelectDialog. */ void editCategories(); private: AddresseeConfig * mAConfig; void initGUI(); void setupTab1(); void setupTab1_1(); void setupTab2(); void setupTab2_1(); void setupTab3(); void setupTab3_1(); KABC::Addressee mAddressee; int mFormattedNameType; bool mDirty; bool mIsExtension; bool mBlockSignals; // GUI KPIM::CategorySelectDialog *mCategoryDialog; KPIM::CategoryEditDialog *mCategoryEditDialog; QTabWidget *mTabWidget; // Tab1 and Tab1_1 KLineEdit *mNameEdit; KLineEdit *mRoleEdit; KLineEdit *mOrgEdit; KSqueezedTextLabel *mFormattedNameLabel; AddressEditWidget *mAddressEditWidget; EmailEditWidget *mEmailWidget; PhoneEditWidget *mPhoneEditWidget; KLineEdit *mURLEdit; KLineEdit *mIMAddressEdit; - KLineEdit *mCategoryEdit; + QPushButton *mCategoryEdit; + QPopupMenu *mCatPopup; SecrecyWidget *mSecrecyWidget; KSqueezedTextLabel *mNameLabel; // Tab2 and Tab2_2 KLineEdit *mDepartmentEdit; KLineEdit *mOfficeEdit; KLineEdit *mProfessionEdit; KLineEdit *mManagerEdit; KLineEdit *mAssistantEdit; KLineEdit *mNicknameEdit; KLineEdit *mSpouseEdit; KLineEdit *mChildEdit; QComboBox *mGenderBox; KDateEdit *mBirthdayPicker; KDateEdit *mAnniversaryPicker; #ifndef KAB_EMBEDDED QTextEdit *mNoteEdit; #else //KAB_EMBEDDED QMultiLineEdit *mNoteEdit; #endif //KAB_EMBEDDED QSpinBox *mTimeZoneSpin; QSpinBox *mGeoLat; QSpinBox *mGeoLon; // Tab3 GeoWidget *mGeoWidget; ImageWidget *mImageWidget; #ifndef KAB_EMBEDDED SoundWidget *mSoundWidget; #endif //KAB_EMBEDDED KeyWidget *mKeyWidget; |