summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--bin/kdepim/korganizer/germantranslation.txt4
-rw-r--r--korganizer/koeditorgeneral.cpp1
-rw-r--r--korganizer/kotodoview.cpp7
-rw-r--r--libkdepim/categoryselectdialog.cpp88
-rw-r--r--libkdepim/categoryselectdialog.h8
-rw-r--r--libkdepim/categoryselectdialog_base.cpp9
-rw-r--r--libkdepim/categoryselectdialog_base.h1
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
@@ -1224,6 +1224,10 @@
1224{ "Insert Journal template","Füge Journal Vorlage ein" }, 1224{ "Insert Journal template","Füge Journal Vorlage ein" },
1225{ "Sub todos:<br>","Unter Todos:<br>" }, 1225{ "Sub todos:<br>","Unter Todos:<br>" },
1226{ "Parent todo:<br>","Über Todo:<br>" }, 1226{ "Parent todo:<br>","Über Todo:<br>" },
1227{ "Set current as color category","Setze Gewählte als Farbkategorie" },
1228{ "","" },
1229{ "","" },
1230{ "","" },
1227{ "","" }, 1231{ "","" },
1228{ "","" }, 1232{ "","" },
1229{ "","" }, 1233{ "","" },
diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp
index f5eb52e..496f125 100644
--- a/korganizer/koeditorgeneral.cpp
+++ b/korganizer/koeditorgeneral.cpp
@@ -121,6 +121,7 @@ void KOEditorGeneral::editCategories()
121 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); 121 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
122 connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &))); 122 connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &)));
123 //KOGlobals::fitDialogToScreen( csd ); 123 //KOGlobals::fitDialogToScreen( csd );
124 csd->setColorEnabled();
124 csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) ); 125 csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) );
125 csd->exec(); 126 csd->exec();
126 delete csd; 127 delete csd;
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index 1a1bce5..3011458 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -961,11 +961,18 @@ void KOTodoView::changedCategories(int index)
961{ 961{
962 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 962 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
963 QStringList categories = mActiveItem->todo()->categories (); 963 QStringList categories = mActiveItem->todo()->categories ();
964 QString colcat = categories.first();
964 if (categories.find (mCategory[index]) != categories.end ()) 965 if (categories.find (mCategory[index]) != categories.end ())
965 categories.remove (mCategory[index]); 966 categories.remove (mCategory[index]);
966 else 967 else
967 categories.insert (categories.end(), mCategory[index]); 968 categories.insert (categories.end(), mCategory[index]);
968 categories.sort (); 969 categories.sort ();
970 if ( !colcat.isEmpty() ) {
971 if ( categories.find ( colcat ) != categories.end () ) {
972 categories.remove( colcat );
973 categories.prepend( colcat );
974 }
975 }
969 mActiveItem->todo()->setCategories (categories); 976 mActiveItem->todo()->setCategories (categories);
970 mActiveItem->construct(); 977 mActiveItem->construct();
971 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 978 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
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 @@
26#include <qheader.h> 26#include <qheader.h>
27#include <qapp.h> 27#include <qapp.h>
28#include <qmessagebox.h> 28#include <qmessagebox.h>
29#include <kmessagebox.h>
29 30
30 31
31#include "categoryeditdialog.h" 32#include "categoryeditdialog.h"
@@ -41,31 +42,35 @@ CategorySelectDialog::CategorySelectDialog( KPimPrefs *prefs, QWidget* parent,
41 : CategorySelectDialog_base( parent, name, true, fl ), 42 : CategorySelectDialog_base( parent, name, true, fl ),
42 mPrefs( prefs ) 43 mPrefs( prefs )
43{ 44{
44 mCategories->header()->hide(); 45 mColorItem = 0;
46 mColorEnabled = false;
47 mCategories->header()->hide();
45 48
46 setCategories(); 49 setCategories();
47 50
48 connect(mButtonEdit,SIGNAL(clicked()),this, SLOT(editCategoriesDialog())); 51 connect(mButtonEdit,SIGNAL(clicked()),this, SLOT(editCategoriesDialog()));
49 if ( QApplication::desktop()->width() > 460 ) 52 if ( QApplication::desktop()->width() > 460 )
50 resize( 300, 360 ); 53 resize( 300, 360 );
51 else 54 else
52 showMaximized(); 55 showMaximized();
56 connect( mSetColorCat, SIGNAL( clicked() ), this, SLOT( setColorCat() ) );
57 connect( mCategories, SIGNAL( clicked(QListViewItem *) ), this, SLOT( clicked(QListViewItem *) ) );
53} 58}
54void CategorySelectDialog::editCategoriesDialog() 59void CategorySelectDialog::editCategoriesDialog()
55{ 60{
56 KPIM::CategoryEditDialog* ced = new KPIM::CategoryEditDialog(mPrefs,this ); 61 KPIM::CategoryEditDialog* ced = new KPIM::CategoryEditDialog(mPrefs,this );
57 62
58 ced->exec(); 63 ced->exec();
59 delete ced; 64 delete ced;
60 setCategories(); 65 setCategories();
61} 66}
62void CategorySelectDialog::setCategories() 67void CategorySelectDialog::setCategories()
63{ 68{
69 mColorItem = 0;
64 mCategories->clear(); 70 mCategories->clear();
65 mCategoryList.clear(); 71 mCategoryList.clear();
66 72
67 QStringList::Iterator it; 73 QStringList::Iterator it;
68
69 for (it = mPrefs->mCustomCategories.begin(); 74 for (it = mPrefs->mCustomCategories.begin();
70 it != mPrefs->mCustomCategories.end(); ++it ) { 75 it != mPrefs->mCustomCategories.end(); ++it ) {
71 new QCheckListItem(mCategories,*it,QCheckListItem::CheckBox); 76 new QCheckListItem(mCategories,*it,QCheckListItem::CheckBox);
@@ -89,6 +94,8 @@ void CategorySelectDialog::setSelected(const QStringList &selList)
89 while (item) { 94 while (item) {
90 if (item->text() == *it) { 95 if (item->text() == *it) {
91 item->setOn(true); 96 item->setOn(true);
97 if ( ! found )
98 setColorItem( item );
92 found = true; 99 found = true;
93 break; 100 break;
94 } 101 }
@@ -113,18 +120,77 @@ QStringList CategorySelectDialog::selectedCategories() const
113{ 120{
114 return mCategoryList; 121 return mCategoryList;
115} 122}
123void CategorySelectDialog::setColorEnabled()
124{
125 mColorEnabled = true;
126 mSetColorCat->show();
127}
128void CategorySelectDialog::setColorCat()
129{
130 QCheckListItem * newColorItem = (QCheckListItem * )mCategories->currentItem ();
131 if ( !newColorItem ) {
132 KMessageBox::error(this,i18n("There is no current item."));
133 return;
134 }
135 if ( !newColorItem->isOn() )
136 newColorItem->setOn( true );
137 setColorItem( newColorItem );
116 138
139}
140void CategorySelectDialog::clicked ( QListViewItem * it )
141{
142 if ( ! it )
143 return;
144 QCheckListItem *i = (QCheckListItem *) it;
145 qDebug("click %d ", i->isOn());
146 if ( !i->isOn() && i==mColorItem) {
147 setColorItem( 0);
148 QCheckListItem *item = (QCheckListItem *)mCategories->firstChild();
149 while (item) {
150 if (item->isOn()) {
151 setColorItem( item );
152 break;
153 }
154 item = (QCheckListItem *)item->nextSibling();
155 }
156 } else if ( i->isOn() && !mColorItem) {
157 setColorItem( i);
158 }
159}
160void CategorySelectDialog::setColorItem( QCheckListItem * newColorItem )
161{
162 if ( !mColorEnabled )
163 return;
164 if ( mColorItem == newColorItem)
165 return;
166 if ( mColorItem ) {
167 mColorItem->setPixmap ( 0, QPixmap() );
168 mColorItem = 0;
169 }
170 if ( newColorItem ) {
171 QPixmap pix (newColorItem->height()/2, newColorItem->height()/2 );
172 pix.fill(Qt::blue );
173 newColorItem->setPixmap ( 0, pix );
174 mColorItem = newColorItem;
175 }
176}
117void CategorySelectDialog::slotApply() 177void CategorySelectDialog::slotApply()
118{ 178{
119 QStringList categories; 179 QStringList categories;
120 QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); 180 QCheckListItem *item = (QCheckListItem *)mCategories->firstChild();
181 QString colcat;
121 while (item) { 182 while (item) {
122 if (item->isOn()) { 183 if (item->isOn()) {
123 categories.append(item->text()); 184 if ( item == mColorItem)
185 colcat = item->text();
186 else
187 categories.append(item->text());
124 } 188 }
125 item = (QCheckListItem *)item->nextSibling(); 189 item = (QCheckListItem *)item->nextSibling();
126 } 190 }
127 191 categories.sort();
192 if ( ! colcat.isEmpty() )
193 categories.prepend( colcat );
128 QString categoriesStr = categories.join(","); 194 QString categoriesStr = categories.join(",");
129 195
130 mCategoryList = categories; 196 mCategoryList = categories;
diff --git a/libkdepim/categoryselectdialog.h b/libkdepim/categoryselectdialog.h
index 9b6261c..680a093 100644
--- a/libkdepim/categoryselectdialog.h
+++ b/libkdepim/categoryselectdialog.h
@@ -26,6 +26,7 @@
26#include <categoryselectdialog_base.h> 26#include <categoryselectdialog_base.h>
27 27
28class KPimPrefs; 28class KPimPrefs;
29class QCheckListItem;
29 30
30namespace KPIM { 31namespace KPIM {
31 32
@@ -39,6 +40,7 @@ class CategorySelectDialog : public CategorySelectDialog_base
39 ~CategorySelectDialog(); 40 ~CategorySelectDialog();
40 41
41 void setCategories(); 42 void setCategories();
43 void setColorEnabled();
42 void setSelected(const QStringList &selList); 44 void setSelected(const QStringList &selList);
43 45
44 QStringList selectedCategories() const; 46 QStringList selectedCategories() const;
@@ -50,15 +52,19 @@ class CategorySelectDialog : public CategorySelectDialog_base
50 void accept(); 52 void accept();
51 void editCategoriesDialog(); 53 void editCategoriesDialog();
52 void updateCategoryConfig(); 54 void updateCategoryConfig();
53 55 void setColorCat();
56 void clicked ( QListViewItem * );
54 signals: 57 signals:
55 void categoriesSelected(const QString &); 58 void categoriesSelected(const QString &);
56 void categoriesSelected(const QStringList &); 59 void categoriesSelected(const QStringList &);
57 void editCategories(); 60 void editCategories();
58 61
59 private: 62 private:
63 bool mColorEnabled;
60 KPimPrefs *mPrefs; 64 KPimPrefs *mPrefs;
61 QStringList mCategoryList; 65 QStringList mCategoryList;
66 QCheckListItem *mColorItem;
67 void setColorItem( QCheckListItem * );
62 68
63 class CategorySelectDialogPrivate; 69 class CategorySelectDialogPrivate;
64 CategorySelectDialogPrivate *d; 70 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
@@ -36,8 +36,9 @@ CategorySelectDialog_base::CategorySelectDialog_base( QWidget* parent, const cha
36 mCategories = new QListView( this, "mCategories" ); 36 mCategories = new QListView( this, "mCategories" );
37 mCategories->addColumn( i18n( "Category" ) ); 37 mCategories->addColumn( i18n( "Category" ) );
38 CategorySelectDialog_baseLayout->addWidget( mCategories ); 38 CategorySelectDialog_baseLayout->addWidget( mCategories );
39 39 mSetColorCat = new QPushButton( this, "msetColor" );
40 Layout12 = new QHBoxLayout( 0, 0, 6, "Layout12"); 40 CategorySelectDialog_baseLayout->addWidget( mSetColorCat );
41 Layout12 = new QHBoxLayout( 0, 0, 4, "Layout12");
41 42
42 mClear = new QPushButton( this, "mClear" ); 43 mClear = new QPushButton( this, "mClear" );
43 Layout12->addWidget( mClear ); 44 Layout12->addWidget( mClear );
@@ -48,7 +49,7 @@ CategorySelectDialog_base::CategorySelectDialog_base( QWidget* parent, const cha
48 Layout12->addWidget( mButtonEdit ); 49 Layout12->addWidget( mButtonEdit );
49 CategorySelectDialog_baseLayout->addLayout( Layout12 ); 50 CategorySelectDialog_baseLayout->addLayout( Layout12 );
50 51
51 Layout11 = new QHBoxLayout( 0, 0, 6, "Layout11"); 52 Layout11 = new QHBoxLayout( 0, 0, 4, "Layout11");
52 53
53 //mButtonHelp = new QPushButton( this, "mButtonHelp" ); 54 //mButtonHelp = new QPushButton( this, "mButtonHelp" );
54 //Layout11->addWidget( mButtonHelp ); 55 //Layout11->addWidget( mButtonHelp );
@@ -84,6 +85,7 @@ CategorySelectDialog_base::CategorySelectDialog_base( QWidget* parent, const cha
84 setTabOrder( mButtonOk, mButtonCancel ); 85 setTabOrder( mButtonOk, mButtonCancel );
85 // showMaximized(); 86 // showMaximized();
86 //raise(); 87 //raise();
88 mSetColorCat->hide();
87} 89}
88 90
89/* 91/*
@@ -107,6 +109,7 @@ void CategorySelectDialog_base::languageChange()
107 // mButtonHelp->setText( tr2i18n( "&Help" ) ); 109 // mButtonHelp->setText( tr2i18n( "&Help" ) );
108 //mApply->setText( i18n( "&Apply" ) ); 110 //mApply->setText( i18n( "&Apply" ) );
109 mButtonOk->setText( i18n( "&OK" ) ); 111 mButtonOk->setText( i18n( "&OK" ) );
112 mSetColorCat->setText( i18n( "Set current as color category" ) );
110 mButtonCancel->setText( i18n( "&Cancel" ) ); 113 mButtonCancel->setText( i18n( "&Cancel" ) );
111} 114}
112 115
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
@@ -35,6 +35,7 @@ public:
35 QPushButton* mApply; 35 QPushButton* mApply;
36 QPushButton* mButtonOk; 36 QPushButton* mButtonOk;
37 QPushButton* mButtonCancel; 37 QPushButton* mButtonCancel;
38 QPushButton* mSetColorCat;
38 39
39public slots: 40public slots:
40 virtual void clear(); 41 virtual void clear();