summaryrefslogtreecommitdiffabout
path: root/korganizer/koeditorgeneral.cpp
authorzautrix <zautrix>2005-06-30 11:05:14 (UTC)
committer zautrix <zautrix>2005-06-30 11:05:14 (UTC)
commitb03b54ce54c1391db8979db0df1369e1c68656fa (patch) (side-by-side diff)
treeadf1bb74f5f56cb54a18a2bbfa3bc327e2e32217 /korganizer/koeditorgeneral.cpp
parent00e631189f1dca0d596b6ce5816f2fcde9124bd7 (diff)
downloadkdepimpi-b03b54ce54c1391db8979db0df1369e1c68656fa.zip
kdepimpi-b03b54ce54c1391db8979db0df1369e1c68656fa.tar.gz
kdepimpi-b03b54ce54c1391db8979db0df1369e1c68656fa.tar.bz2
fixxx
Diffstat (limited to 'korganizer/koeditorgeneral.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koeditorgeneral.cpp51
1 files changed, 45 insertions, 6 deletions
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);
}