From b03b54ce54c1391db8979db0df1369e1c68656fa Mon Sep 17 00:00:00 2001 From: zautrix Date: Thu, 30 Jun 2005 11:05:14 +0000 Subject: fixxx --- (limited to 'korganizer/koeditorgeneral.cpp') diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp index 915c7ec..50a04ea 100644 --- a/korganizer/koeditorgeneral.cpp +++ b/korganizer/koeditorgeneral.cpp @@ -142,17 +142,56 @@ void KOEditorGeneral::editCategories() csd->exec(); delete csd; } + +void KOEditorGeneral::showCatPopup() +{ + mCatPopup->clear(); + QStringList checkedCategories = QStringList::split (",", mCategoriesLabel->text()); + int index = 0; + for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); + it != KOPrefs::instance()->mCustomCategories.end (); + ++it) { + mCatPopup->insertItem (*it, index ); + //mCategory[index] = *it; + if (checkedCategories.find (*it) != checkedCategories.end ()) mCatPopup->setItemChecked (index, true); + ++index; + } +} +void KOEditorGeneral::selectedCatPopup( int index ) +{ + qDebug("i %d c %d ", index, KOPrefs::instance()->mCustomCategories.count()); + QStringList categories = QStringList::split (",", mCategoriesLabel->text()); + QString colcat = categories.first(); + if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ()) + categories.remove (KOPrefs::instance()->mCustomCategories[index]); + else + categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]); + categories.sort (); + if ( !colcat.isEmpty() ) { + if ( categories.find ( colcat ) != categories.end () ) { + categories.remove( colcat ); + categories.prepend( colcat ); + } + } + mCategoriesLabel->setText( categories.join(",") ); +} + void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout) { QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout ); - + mCatPopup = new QPopupMenu ( parent ); + mCatPopup->setCheckable (true); + connect(mCatPopup,SIGNAL(aboutToShow () ), this ,SLOT(showCatPopup())); + connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT(selectedCatPopup( int ))); mCategoriesButton = new QPushButton(parent); - mCategoriesButton->setText(i18n("Categories...")); - connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); + mCategoriesButton->setText(i18n("Categories")); + //connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); categoriesLayout->addWidget(mCategoriesButton); - - mCategoriesLabel = new QLabel(parent); - mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken); + mCategoriesButton->setPopup( mCatPopup ); + mCategoriesLabel = new QPushButton(parent);//new QLabel(parent); + mCategoriesLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); + connect(mCategoriesLabel,SIGNAL(clicked()),this, SLOT(editCategories() )); + //mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken); categoriesLayout->addWidget(mCategoriesLabel,1); } -- cgit v0.9.0.2