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
@@ -133,35 +133,74 @@ void KOEditorGeneral::slotSetFocusOn()
133} 133}
134void KOEditorGeneral::editCategories() 134void KOEditorGeneral::editCategories()
135{ 135{
136 // qDebug("KOEditorGeneral::editCategories() "); 136 // qDebug("KOEditorGeneral::editCategories() ");
137 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); 137 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
138 connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &))); 138 connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &)));
139 //KOGlobals::fitDialogToScreen( csd ); 139 //KOGlobals::fitDialogToScreen( csd );
140 csd->setColorEnabled(); 140 csd->setColorEnabled();
141 csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) ); 141 csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) );
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
159void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout) 198void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout)
160{ 199{
161 QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout ); 200 QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout );
162 201
163 QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent); 202 QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent);
164 mCancelBox = new QCheckBox ( i18n("Cancelled"), parent); 203 mCancelBox = new QCheckBox ( i18n("Cancelled"), parent);
165 secrecyLayout->addWidget(mCancelBox); 204 secrecyLayout->addWidget(mCancelBox);
166 secrecyLayout->addWidget(secrecyLabel); 205 secrecyLayout->addWidget(secrecyLabel);
167 206