author | zautrix <zautrix> | 2005-02-06 18:00:15 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-06 18:00:15 (UTC) |
commit | 282c7fc5b72f8a6ff78a408e10a6018c290ed9f0 (patch) (side-by-side diff) | |
tree | 95291ead32969e45a6e4e405f15532c9f29543f7 | |
parent | 002a447671cdec6a2ee7940bc183c630c61121fa (diff) | |
download | kdepimpi-282c7fc5b72f8a6ff78a408e10a6018c290ed9f0.zip kdepimpi-282c7fc5b72f8a6ff78a408e10a6018c290ed9f0.tar.gz kdepimpi-282c7fc5b72f8a6ff78a408e10a6018c290ed9f0.tar.bz2 |
cat color better
-rw-r--r-- | bin/kdepim/korganizer/germantranslation.txt | 4 | ||||
-rw-r--r-- | korganizer/koeditorgeneral.cpp | 1 | ||||
-rw-r--r-- | korganizer/kotodoview.cpp | 7 | ||||
-rw-r--r-- | libkdepim/categoryselectdialog.cpp | 88 | ||||
-rw-r--r-- | libkdepim/categoryselectdialog.h | 8 | ||||
-rw-r--r-- | libkdepim/categoryselectdialog_base.cpp | 9 | ||||
-rw-r--r-- | libkdepim/categoryselectdialog_base.h | 1 |
7 files changed, 103 insertions, 15 deletions
diff --git a/bin/kdepim/korganizer/germantranslation.txt b/bin/kdepim/korganizer/germantranslation.txt index 523c054..ee37492 100644 --- a/bin/kdepim/korganizer/germantranslation.txt +++ b/bin/kdepim/korganizer/germantranslation.txt @@ -1223,8 +1223,12 @@ { "Save as Journal template","Speichere als Journal Vorlage" }, { "Insert Journal template","Füge Journal Vorlage ein" }, { "Sub todos:<br>","Unter Todos:<br>" }, { "Parent todo:<br>","Über Todo:<br>" }, +{ "Set current as color category","Setze Gewählte als Farbkategorie" }, +{ "","" }, +{ "","" }, +{ "","" }, { "","" }, { "","" }, { "","" }, { "","" }, diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp index f5eb52e..496f125 100644 --- a/korganizer/koeditorgeneral.cpp +++ b/korganizer/koeditorgeneral.cpp @@ -120,8 +120,9 @@ void KOEditorGeneral::editCategories() // qDebug("KOEditorGeneral::editCategories() "); KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &))); //KOGlobals::fitDialogToScreen( csd ); + csd->setColorEnabled(); csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) ); csd->exec(); delete csd; } diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 1a1bce5..3011458 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp @@ -960,13 +960,20 @@ QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) void KOTodoView::changedCategories(int index) { if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { QStringList categories = mActiveItem->todo()->categories (); + QString colcat = categories.first(); if (categories.find (mCategory[index]) != categories.end ()) categories.remove (mCategory[index]); else categories.insert (categories.end(), mCategory[index]); categories.sort (); + if ( !colcat.isEmpty() ) { + if ( categories.find ( colcat ) != categories.end () ) { + categories.remove( colcat ); + categories.prepend( colcat ); + } + } mActiveItem->todo()->setCategories (categories); mActiveItem->construct(); mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); diff --git a/libkdepim/categoryselectdialog.cpp b/libkdepim/categoryselectdialog.cpp index 7df9154..8b2bc4e 100644 --- a/libkdepim/categoryselectdialog.cpp +++ b/libkdepim/categoryselectdialog.cpp @@ -25,8 +25,9 @@ #include <qpushbutton.h> #include <qheader.h> #include <qapp.h> #include <qmessagebox.h> +#include <kmessagebox.h> #include "categoryeditdialog.h" #include "categoryselectdialog.h" @@ -40,33 +41,37 @@ CategorySelectDialog::CategorySelectDialog( KPimPrefs *prefs, QWidget* parent, bool modal, WFlags fl ) : 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); } @@ -88,8 +93,10 @@ void CategorySelectDialog::setSelected(const QStringList &selList) QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); while (item) { if (item->text() == *it) { item->setOn(true); + if ( ! found ) + setColorItem( item ); found = true; break; } item = (QCheckListItem *)item->nextSibling(); @@ -112,20 +119,79 @@ void CategorySelectDialog::setSelected(const QStringList &selList) 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; diff --git a/libkdepim/categoryselectdialog.h b/libkdepim/categoryselectdialog.h index 9b6261c..680a093 100644 --- a/libkdepim/categoryselectdialog.h +++ b/libkdepim/categoryselectdialog.h @@ -25,8 +25,9 @@ #include <categoryselectdialog_base.h> class KPimPrefs; +class QCheckListItem; namespace KPIM { class CategorySelectDialog : public CategorySelectDialog_base @@ -38,8 +39,9 @@ class CategorySelectDialog : public CategorySelectDialog_base bool modal = FALSE, WFlags fl = 0 ); ~CategorySelectDialog(); void setCategories(); + void setColorEnabled(); void setSelected(const QStringList &selList); QStringList selectedCategories() const; @@ -49,17 +51,21 @@ class CategorySelectDialog : public CategorySelectDialog_base void clear(); void accept(); void editCategoriesDialog(); void updateCategoryConfig(); - + void setColorCat(); + void clicked ( QListViewItem * ); signals: void categoriesSelected(const QString &); void categoriesSelected(const QStringList &); void editCategories(); private: + bool mColorEnabled; KPimPrefs *mPrefs; QStringList mCategoryList; + QCheckListItem *mColorItem; + void setColorItem( QCheckListItem * ); class CategorySelectDialogPrivate; CategorySelectDialogPrivate *d; }; diff --git a/libkdepim/categoryselectdialog_base.cpp b/libkdepim/categoryselectdialog_base.cpp index 3f050cf..4793fd7 100644 --- a/libkdepim/categoryselectdialog_base.cpp +++ b/libkdepim/categoryselectdialog_base.cpp @@ -35,10 +35,11 @@ CategorySelectDialog_base::CategorySelectDialog_base( QWidget* parent, const cha mCategories = new QListView( this, "mCategories" ); mCategories->addColumn( i18n( "Category" ) ); CategorySelectDialog_baseLayout->addWidget( mCategories ); - - Layout12 = new QHBoxLayout( 0, 0, 6, "Layout12"); + mSetColorCat = new QPushButton( this, "msetColor" ); + CategorySelectDialog_baseLayout->addWidget( mSetColorCat ); + Layout12 = new QHBoxLayout( 0, 0, 4, "Layout12"); mClear = new QPushButton( this, "mClear" ); Layout12->addWidget( mClear ); // QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); @@ -47,9 +48,9 @@ CategorySelectDialog_base::CategorySelectDialog_base( QWidget* parent, const cha mButtonEdit = new QPushButton( this, "mButtonEdit" ); Layout12->addWidget( mButtonEdit ); CategorySelectDialog_baseLayout->addLayout( Layout12 ); - Layout11 = new QHBoxLayout( 0, 0, 6, "Layout11"); + Layout11 = new QHBoxLayout( 0, 0, 4, "Layout11"); //mButtonHelp = new QPushButton( this, "mButtonHelp" ); //Layout11->addWidget( mButtonHelp ); //QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); @@ -83,8 +84,9 @@ CategorySelectDialog_base::CategorySelectDialog_base( QWidget* parent, const cha // setTabOrder( mApply, mButtonOk ); setTabOrder( mButtonOk, mButtonCancel ); // showMaximized(); //raise(); + mSetColorCat->hide(); } /* * Destroys the object and frees any allocated resources @@ -106,8 +108,9 @@ void CategorySelectDialog_base::languageChange() mButtonEdit->setText( i18n( " &Edit Categories " ) ); // mButtonHelp->setText( tr2i18n( "&Help" ) ); //mApply->setText( i18n( "&Apply" ) ); mButtonOk->setText( i18n( "&OK" ) ); + mSetColorCat->setText( i18n( "Set current as color category" ) ); mButtonCancel->setText( i18n( "&Cancel" ) ); } void CategorySelectDialog_base::clear() diff --git a/libkdepim/categoryselectdialog_base.h b/libkdepim/categoryselectdialog_base.h index af905ed..59ffa22 100644 --- a/libkdepim/categoryselectdialog_base.h +++ b/libkdepim/categoryselectdialog_base.h @@ -34,8 +34,9 @@ public: QPushButton* mButtonHelp; QPushButton* mApply; QPushButton* mButtonOk; QPushButton* mButtonCancel; + QPushButton* mSetColorCat; public slots: virtual void clear(); virtual void slotApply(); |