-rw-r--r-- | libkdepim/categoryselectdialog.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/libkdepim/categoryselectdialog.cpp b/libkdepim/categoryselectdialog.cpp index 4d80726..974752c 100644 --- a/libkdepim/categoryselectdialog.cpp +++ b/libkdepim/categoryselectdialog.cpp @@ -17,97 +17,100 @@ 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. */ #include <qlistview.h> #include <qpushbutton.h> #include <qheader.h> #include <qapp.h> #include <qmessagebox.h> #include <kmessagebox.h> #include "categoryeditdialog.h" #include "categoryselectdialog.h" #include "kpimprefs.h" using namespace KPIM; CategorySelectDialog::CategorySelectDialog( KPimPrefs *prefs, QWidget* parent, const char* name, bool modal, WFlags fl ) : CategorySelectDialog_base( parent, name, true, fl ), mPrefs( prefs ) { mColorItem = 0; mColorEnabled = false; mCategories->header()->hide(); setCategories(); connect(mButtonEdit,SIGNAL(clicked()),this, SLOT(editCategoriesDialog())); if ( QApplication::desktop()->width() > 460 ) resize( 300, 360 ); else showMaximized(); connect( mSetColorCat, SIGNAL( clicked() ), this, SLOT( setColorCat() ) ); // connect( mCategories, SIGNAL( clicked(QListViewItem *) ), this, SLOT( clicked(QListViewItem *) ) ); } void CategorySelectDialog::editCategoriesDialog() { KPIM::CategoryEditDialog* ced = new KPIM::CategoryEditDialog(mPrefs,this ); ced->exec(); delete ced; + slotApply(); + QStringList temp = mCategoryList; setCategories(); + setSelected( temp ); } void CategorySelectDialog::setCategories() { mColorItem = 0; mCategories->clear(); mCategoryList.clear(); QStringList::Iterator it; for (it = mPrefs->mCustomCategories.begin(); it != mPrefs->mCustomCategories.end(); ++it ) { CategorySelectItem * item = new CategorySelectItem(mCategories,*it,QCheckListItem::CheckBox); QObject::connect( item, SIGNAL( stateChanged(QListViewItem *) ), this, SLOT( clicked(QListViewItem *) ) ); } } CategorySelectDialog::~CategorySelectDialog() { } void CategorySelectDialog::setSelected(const QStringList &selList) { clear(); QStringList::ConstIterator it; QStringList notFound; bool found = false; for (it=selList.begin();it!=selList.end();++it) { //qDebug(" CategorySelectDialog::setSelected("); QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); while (item) { if (item->text() == *it) { item->setOn(true); if ( ! found ) setColorItem( item ); found = true; break; } item = (QCheckListItem *)item->nextSibling(); } // if ( ! found ) { //emit updateCategoriesGlobal(); // QMessageBox::information( this, "KO/E: Information!", // "Categories found, which were not\n" // "in list of categories!\n" // "message", // "OK", "", 0, @@ -147,92 +150,92 @@ void CategorySelectDialog::clicked ( QListViewItem * it ) if ( !i->isOn() && i==mColorItem) { setColorItem( 0); QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); while (item) { if (item->isOn()) { setColorItem( item ); break; } item = (QCheckListItem *)item->nextSibling(); } } else if ( i->isOn() && !mColorItem) { setColorItem( i); } } void CategorySelectDialog::setColorItem( QCheckListItem * newColorItem ) { if ( !mColorEnabled ) return; if ( mColorItem == newColorItem) return; if ( mColorItem ) { mColorItem->setPixmap ( 0, QPixmap() ); mColorItem = 0; } if ( newColorItem ) { QPixmap pix (newColorItem->height()/2, newColorItem->height()/2 ); pix.fill(Qt::red ); newColorItem->setPixmap ( 0, pix ); mColorItem = newColorItem; } } void CategorySelectDialog::slotApply() { QStringList categories; QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); QString colcat; while (item) { if (item->isOn()) { if ( item == mColorItem) colcat = item->text(); else categories.append(item->text()); } item = (QCheckListItem *)item->nextSibling(); } categories.sort(); if ( ! colcat.isEmpty() ) categories.prepend( colcat ); - QString categoriesStr = categories.join(","); + // QString categoriesStr = categories.join(","); mCategoryList = categories; - emit categoriesSelected(categories); - emit categoriesSelected(categoriesStr); } void CategorySelectDialog::accept() { slotOk(); } void CategorySelectDialog::slotOk() { slotApply(); + emit categoriesSelected(mCategoryList); + emit categoriesSelected(mCategoryList.join(",")); QDialog::accept(); } void CategorySelectDialog::clear() { QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); while (item) { item->setOn(false); item = (QCheckListItem *)item->nextSibling(); } } void CategorySelectDialog::updateCategoryConfig() { QStringList selected; QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); while (item) { if (item->isOn()) { selected.append(item->text()); } item = (QCheckListItem *)item->nextSibling(); } setCategories(); setSelected(selected); } //#include "categoryselectdialog.moc" |