summaryrefslogtreecommitdiffabout
path: root/libkdepim/categoryselectdialog.cpp
authorzautrix <zautrix>2005-02-06 18:00:15 (UTC)
committer zautrix <zautrix>2005-02-06 18:00:15 (UTC)
commit282c7fc5b72f8a6ff78a408e10a6018c290ed9f0 (patch) (side-by-side diff)
tree95291ead32969e45a6e4e405f15532c9f29543f7 /libkdepim/categoryselectdialog.cpp
parent002a447671cdec6a2ee7940bc183c630c61121fa (diff)
downloadkdepimpi-282c7fc5b72f8a6ff78a408e10a6018c290ed9f0.zip
kdepimpi-282c7fc5b72f8a6ff78a408e10a6018c290ed9f0.tar.gz
kdepimpi-282c7fc5b72f8a6ff78a408e10a6018c290ed9f0.tar.bz2
cat color better
Diffstat (limited to 'libkdepim/categoryselectdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/categoryselectdialog.cpp88
1 files changed, 77 insertions, 11 deletions
diff --git a/libkdepim/categoryselectdialog.cpp b/libkdepim/categoryselectdialog.cpp
index 7df9154..8b2bc4e 100644
--- a/libkdepim/categoryselectdialog.cpp
+++ b/libkdepim/categoryselectdialog.cpp
@@ -26,6 +26,7 @@
#include <qheader.h>
#include <qapp.h>
#include <qmessagebox.h>
+#include <kmessagebox.h>
#include "categoryeditdialog.h"
@@ -41,31 +42,35 @@ CategorySelectDialog::CategorySelectDialog( KPimPrefs *prefs, QWidget* parent,
: CategorySelectDialog_base( parent, name, true, fl ),
mPrefs( prefs )
{
- mCategories->header()->hide();
+ mColorItem = 0;
+ mColorEnabled = false;
+ mCategories->header()->hide();
- setCategories();
+ setCategories();
- connect(mButtonEdit,SIGNAL(clicked()),this, SLOT(editCategoriesDialog()));
- if ( QApplication::desktop()->width() > 460 )
- resize( 300, 360 );
- else
- showMaximized();
+ 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();
+ ced->exec();
delete ced;
setCategories();
}
void CategorySelectDialog::setCategories()
{
+ mColorItem = 0;
mCategories->clear();
mCategoryList.clear();
QStringList::Iterator it;
-
for (it = mPrefs->mCustomCategories.begin();
it != mPrefs->mCustomCategories.end(); ++it ) {
new QCheckListItem(mCategories,*it,QCheckListItem::CheckBox);
@@ -89,6 +94,8 @@ void CategorySelectDialog::setSelected(const QStringList &selList)
while (item) {
if (item->text() == *it) {
item->setOn(true);
+ if ( ! found )
+ setColorItem( item );
found = true;
break;
}
@@ -113,18 +120,77 @@ QStringList CategorySelectDialog::selectedCategories() const
{
return mCategoryList;
}
+void CategorySelectDialog::setColorEnabled()
+{
+ mColorEnabled = true;
+ mSetColorCat->show();
+}
+void CategorySelectDialog::setColorCat()
+{
+ QCheckListItem * newColorItem = (QCheckListItem * )mCategories->currentItem ();
+ if ( !newColorItem ) {
+ KMessageBox::error(this,i18n("There is no current item."));
+ return;
+ }
+ if ( !newColorItem->isOn() )
+ newColorItem->setOn( true );
+ setColorItem( newColorItem );
+}
+void CategorySelectDialog::clicked ( QListViewItem * it )
+{
+ if ( ! it )
+ return;
+ QCheckListItem *i = (QCheckListItem *) it;
+ qDebug("click %d ", i->isOn());
+ 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::blue );
+ newColorItem->setPixmap ( 0, pix );
+ mColorItem = newColorItem;
+ }
+}
void CategorySelectDialog::slotApply()
{
QStringList categories;
QCheckListItem *item = (QCheckListItem *)mCategories->firstChild();
+ QString colcat;
while (item) {
if (item->isOn()) {
- categories.append(item->text());
+ 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(",");
mCategoryList = categories;