Diffstat (limited to 'libkdepim/categoryselectdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libkdepim/categoryselectdialog.cpp | 88 |
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 | |||
@@ -28,2 +28,3 @@ | |||
28 | #include <qmessagebox.h> | 28 | #include <qmessagebox.h> |
29 | #include <kmessagebox.h> | ||
29 | 30 | ||
@@ -43,11 +44,15 @@ CategorySelectDialog::CategorySelectDialog( KPimPrefs *prefs, QWidget* parent, | |||
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 | } |
@@ -57,3 +62,3 @@ void CategorySelectDialog::editCategoriesDialog() | |||
57 | 62 | ||
58 | ced->exec(); | 63 | ced->exec(); |
59 | delete ced; | 64 | delete ced; |
@@ -63,2 +68,3 @@ void CategorySelectDialog::setCategories() | |||
63 | { | 68 | { |
69 | mColorItem = 0; | ||
64 | mCategories->clear(); | 70 | mCategories->clear(); |
@@ -67,3 +73,2 @@ void CategorySelectDialog::setCategories() | |||
67 | QStringList::Iterator it; | 73 | QStringList::Iterator it; |
68 | |||
69 | for (it = mPrefs->mCustomCategories.begin(); | 74 | for (it = mPrefs->mCustomCategories.begin(); |
@@ -91,2 +96,4 @@ void CategorySelectDialog::setSelected(const QStringList &selList) | |||
91 | item->setOn(true); | 96 | item->setOn(true); |
97 | if ( ! found ) | ||
98 | setColorItem( item ); | ||
92 | found = true; | 99 | found = true; |
@@ -115,3 +122,56 @@ QStringList CategorySelectDialog::selectedCategories() const | |||
115 | } | 122 | } |
123 | void CategorySelectDialog::setColorEnabled() | ||
124 | { | ||
125 | mColorEnabled = true; | ||
126 | mSetColorCat->show(); | ||
127 | } | ||
128 | void 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 | } | ||
140 | void 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 | } | ||
160 | void 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 | } | ||
117 | void CategorySelectDialog::slotApply() | 177 | void CategorySelectDialog::slotApply() |
@@ -120,5 +180,9 @@ void CategorySelectDialog::slotApply() | |||
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 | } |
@@ -126,3 +190,5 @@ void CategorySelectDialog::slotApply() | |||
126 | } | 190 | } |
127 | 191 | categories.sort(); | |
192 | if ( ! colcat.isEmpty() ) | ||
193 | categories.prepend( colcat ); | ||
128 | QString categoriesStr = categories.join(","); | 194 | QString categoriesStr = categories.join(","); |