summaryrefslogtreecommitdiffabout
path: root/korganizer/koeditorgeneral.cpp
Unidiff
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()
142 csd->exec(); 142 csd->exec();
143 delete csd; 143 delete csd;
144} 144}
145
146void KOEditorGeneral::showCatPopup()
147{
148 mCatPopup->clear();
149 QStringList checkedCategories = QStringList::split (",", mCategoriesLabel->text());
150 int index = 0;
151 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
152 it != KOPrefs::instance()->mCustomCategories.end ();
153 ++it) {
154 mCatPopup->insertItem (*it, index );
155 //mCategory[index] = *it;
156 if (checkedCategories.find (*it) != checkedCategories.end ()) mCatPopup->setItemChecked (index, true);
157 ++index;
158 }
159}
160void KOEditorGeneral::selectedCatPopup( int index )
161{
162 qDebug("i %d c %d ", index, KOPrefs::instance()->mCustomCategories.count());
163 QStringList categories = QStringList::split (",", mCategoriesLabel->text());
164 QString colcat = categories.first();
165 if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ())
166 categories.remove (KOPrefs::instance()->mCustomCategories[index]);
167 else
168 categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]);
169 categories.sort ();
170 if ( !colcat.isEmpty() ) {
171 if ( categories.find ( colcat ) != categories.end () ) {
172 categories.remove( colcat );
173 categories.prepend( colcat );
174 }
175 }
176 mCategoriesLabel->setText( categories.join(",") );
177}
178
145void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout) 179void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout)
146{ 180{
147 QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout ); 181 QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout );
148 182 mCatPopup = new QPopupMenu ( parent );
183 mCatPopup->setCheckable (true);
184 connect(mCatPopup,SIGNAL(aboutToShow () ), this ,SLOT(showCatPopup()));
185 connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT(selectedCatPopup( int )));
149 mCategoriesButton = new QPushButton(parent); 186 mCategoriesButton = new QPushButton(parent);
150 mCategoriesButton->setText(i18n("Categories...")); 187 mCategoriesButton->setText(i18n("Categories"));
151 connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); 188 //connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() ));
152 categoriesLayout->addWidget(mCategoriesButton); 189 categoriesLayout->addWidget(mCategoriesButton);
153 190 mCategoriesButton->setPopup( mCatPopup );
154 mCategoriesLabel = new QLabel(parent); 191 mCategoriesLabel = new QPushButton(parent);//new QLabel(parent);
155 mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken); 192 mCategoriesLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) );
193 connect(mCategoriesLabel,SIGNAL(clicked()),this, SLOT(editCategories() ));
194 //mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken);
156 categoriesLayout->addWidget(mCategoriesLabel,1); 195 categoriesLayout->addWidget(mCategoriesLabel,1);
157} 196}
158 197