author | zautrix <zautrix> | 2005-02-19 20:30:34 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-19 20:30:34 (UTC) |
commit | 6f4d42c16c87668279db1e0a0d3e4f4aad5b84f6 (patch) (unidiff) | |
tree | 89fbb2b107a1681a1fbb19b35c3a9484652dc352 | |
parent | 11b5b0eb24cfb943df106f7ee97646955bec0fd3 (diff) | |
download | kdepimpi-6f4d42c16c87668279db1e0a0d3e4f4aad5b84f6.zip kdepimpi-6f4d42c16c87668279db1e0a0d3e4f4aad5b84f6.tar.gz kdepimpi-6f4d42c16c87668279db1e0a0d3e4f4aad5b84f6.tar.bz2 |
cat select fix
-rw-r--r-- | libkdepim/categoryeditdialog.h | 24 | ||||
-rw-r--r-- | libkdepim/categoryselectdialog.cpp | 6 |
2 files changed, 28 insertions, 2 deletions
diff --git a/libkdepim/categoryeditdialog.h b/libkdepim/categoryeditdialog.h index 4ebc802..3e8ab45 100644 --- a/libkdepim/categoryeditdialog.h +++ b/libkdepim/categoryeditdialog.h | |||
@@ -1,62 +1,86 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkdepim. | 2 | This file is part of libkdepim. |
3 | Copyright (c) 2000, 2001, 2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000, 2001, 2002 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef KPIM_CATEGORYEDITDIALOG_H | 23 | #ifndef KPIM_CATEGORYEDITDIALOG_H |
24 | #define KPIM_CATEGORYEDITDIALOG_H | 24 | #define KPIM_CATEGORYEDITDIALOG_H |
25 | 25 | ||
26 | #include <categoryeditdialog_base.h> | 26 | #include <categoryeditdialog_base.h> |
27 | #include <qlistview.h> | ||
27 | 28 | ||
28 | class KPimPrefs; | 29 | class KPimPrefs; |
29 | 30 | ||
30 | namespace KPIM { | 31 | namespace KPIM { |
31 | 32 | ||
33 | class CategorySelectItem :public QObject, public QCheckListItem | ||
34 | { | ||
35 | |||
36 | Q_OBJECT | ||
37 | public: | ||
38 | |||
39 | CategorySelectItem(QListView * parent, const QString & text, Type tt) : | ||
40 | QCheckListItem (parent, text, tt ) , QObject( parent ) | ||
41 | {;} | ||
42 | |||
43 | signals: | ||
44 | void stateChanged( QListViewItem*); | ||
45 | |||
46 | protected: | ||
47 | |||
48 | virtual void stateChange(bool b) | ||
49 | { | ||
50 | QCheckListItem::stateChange(b); | ||
51 | emit stateChanged( this ); | ||
52 | } | ||
53 | }; | ||
54 | |||
55 | |||
32 | class CategoryEditDialog : public CategoryEditDialog_base | 56 | class CategoryEditDialog : public CategoryEditDialog_base |
33 | { | 57 | { |
34 | Q_OBJECT | 58 | Q_OBJECT |
35 | public: | 59 | public: |
36 | CategoryEditDialog( KPimPrefs *prefs, QWidget* parent = 0, | 60 | CategoryEditDialog( KPimPrefs *prefs, QWidget* parent = 0, |
37 | const char* name = 0, | 61 | const char* name = 0, |
38 | bool modal = FALSE, WFlags fl = 0 ); | 62 | bool modal = FALSE, WFlags fl = 0 ); |
39 | ~CategoryEditDialog(); | 63 | ~CategoryEditDialog(); |
40 | 64 | ||
41 | public slots: | 65 | public slots: |
42 | void add(); | 66 | void add(); |
43 | void remove(); | 67 | void remove(); |
44 | void modify(); | 68 | void modify(); |
45 | void accept(); | 69 | void accept(); |
46 | 70 | ||
47 | void slotOk(); | 71 | void slotOk(); |
48 | void slotApply(); | 72 | void slotApply(); |
49 | 73 | ||
50 | signals: | 74 | signals: |
51 | void categoryConfigChanged(); | 75 | void categoryConfigChanged(); |
52 | 76 | ||
53 | private slots: | 77 | private slots: |
54 | void editItem(QListViewItem *item); | 78 | void editItem(QListViewItem *item); |
55 | void slotTextChanged(const QString &text); | 79 | void slotTextChanged(const QString &text); |
56 | 80 | ||
57 | KPimPrefs *mPrefs; | 81 | KPimPrefs *mPrefs; |
58 | }; | 82 | }; |
59 | 83 | ||
60 | } | 84 | } |
61 | 85 | ||
62 | #endif | 86 | #endif |
diff --git a/libkdepim/categoryselectdialog.cpp b/libkdepim/categoryselectdialog.cpp index 8038934..4d80726 100644 --- a/libkdepim/categoryselectdialog.cpp +++ b/libkdepim/categoryselectdialog.cpp | |||
@@ -1,236 +1,238 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkdepim. | 2 | This file is part of libkdepim. |
3 | Copyright (c) 2000, 2001, 2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000, 2001, 2002 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qlistview.h> | 24 | #include <qlistview.h> |
25 | #include <qpushbutton.h> | 25 | #include <qpushbutton.h> |
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 | #include <kmessagebox.h> |
30 | 30 | ||
31 | 31 | ||
32 | #include "categoryeditdialog.h" | 32 | #include "categoryeditdialog.h" |
33 | #include "categoryselectdialog.h" | 33 | #include "categoryselectdialog.h" |
34 | 34 | ||
35 | #include "kpimprefs.h" | 35 | #include "kpimprefs.h" |
36 | 36 | ||
37 | using namespace KPIM; | 37 | using namespace KPIM; |
38 | 38 | ||
39 | CategorySelectDialog::CategorySelectDialog( KPimPrefs *prefs, QWidget* parent, | 39 | CategorySelectDialog::CategorySelectDialog( KPimPrefs *prefs, QWidget* parent, |
40 | const char* name, | 40 | const char* name, |
41 | bool modal, WFlags fl ) | 41 | bool modal, WFlags fl ) |
42 | : CategorySelectDialog_base( parent, name, true, fl ), | 42 | : CategorySelectDialog_base( parent, name, true, fl ), |
43 | mPrefs( prefs ) | 43 | mPrefs( prefs ) |
44 | { | 44 | { |
45 | mColorItem = 0; | 45 | mColorItem = 0; |
46 | mColorEnabled = false; | 46 | mColorEnabled = false; |
47 | mCategories->header()->hide(); | 47 | mCategories->header()->hide(); |
48 | 48 | ||
49 | setCategories(); | 49 | setCategories(); |
50 | 50 | ||
51 | connect(mButtonEdit,SIGNAL(clicked()),this, SLOT(editCategoriesDialog())); | 51 | connect(mButtonEdit,SIGNAL(clicked()),this, SLOT(editCategoriesDialog())); |
52 | if ( QApplication::desktop()->width() > 460 ) | 52 | if ( QApplication::desktop()->width() > 460 ) |
53 | resize( 300, 360 ); | 53 | resize( 300, 360 ); |
54 | else | 54 | else |
55 | showMaximized(); | 55 | showMaximized(); |
56 | connect( mSetColorCat, SIGNAL( clicked() ), this, SLOT( setColorCat() ) ); | 56 | connect( mSetColorCat, SIGNAL( clicked() ), this, SLOT( setColorCat() ) ); |
57 | connect( mCategories, SIGNAL( clicked(QListViewItem *) ), this, SLOT( clicked(QListViewItem *) ) ); | 57 | // connect( mCategories, SIGNAL( clicked(QListViewItem *) ), this, SLOT( clicked(QListViewItem *) ) ); |
58 | } | 58 | } |
59 | void CategorySelectDialog::editCategoriesDialog() | 59 | void CategorySelectDialog::editCategoriesDialog() |
60 | { | 60 | { |
61 | KPIM::CategoryEditDialog* ced = new KPIM::CategoryEditDialog(mPrefs,this ); | 61 | KPIM::CategoryEditDialog* ced = new KPIM::CategoryEditDialog(mPrefs,this ); |
62 | 62 | ||
63 | ced->exec(); | 63 | ced->exec(); |
64 | delete ced; | 64 | delete ced; |
65 | setCategories(); | 65 | setCategories(); |
66 | } | 66 | } |
67 | void CategorySelectDialog::setCategories() | 67 | void CategorySelectDialog::setCategories() |
68 | { | 68 | { |
69 | mColorItem = 0; | 69 | mColorItem = 0; |
70 | mCategories->clear(); | 70 | mCategories->clear(); |
71 | mCategoryList.clear(); | 71 | mCategoryList.clear(); |
72 | 72 | ||
73 | QStringList::Iterator it; | 73 | QStringList::Iterator it; |
74 | for (it = mPrefs->mCustomCategories.begin(); | 74 | for (it = mPrefs->mCustomCategories.begin(); |
75 | it != mPrefs->mCustomCategories.end(); ++it ) { | 75 | it != mPrefs->mCustomCategories.end(); ++it ) { |
76 | new QCheckListItem(mCategories,*it,QCheckListItem::CheckBox); | 76 | CategorySelectItem * item = new CategorySelectItem(mCategories,*it,QCheckListItem::CheckBox); |
77 | QObject::connect( item, SIGNAL( stateChanged(QListViewItem *) ), this, SLOT( clicked(QListViewItem *) ) ); | ||
78 | |||
77 | } | 79 | } |
78 | } | 80 | } |
79 | 81 | ||
80 | CategorySelectDialog::~CategorySelectDialog() | 82 | CategorySelectDialog::~CategorySelectDialog() |
81 | { | 83 | { |
82 | } | 84 | } |
83 | 85 | ||
84 | void CategorySelectDialog::setSelected(const QStringList &selList) | 86 | void CategorySelectDialog::setSelected(const QStringList &selList) |
85 | { | 87 | { |
86 | clear(); | 88 | clear(); |
87 | 89 | ||
88 | QStringList::ConstIterator it; | 90 | QStringList::ConstIterator it; |
89 | QStringList notFound; | 91 | QStringList notFound; |
90 | bool found = false; | 92 | bool found = false; |
91 | for (it=selList.begin();it!=selList.end();++it) { | 93 | for (it=selList.begin();it!=selList.end();++it) { |
92 | //qDebug(" CategorySelectDialog::setSelected("); | 94 | //qDebug(" CategorySelectDialog::setSelected("); |
93 | QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); | 95 | QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); |
94 | while (item) { | 96 | while (item) { |
95 | if (item->text() == *it) { | 97 | if (item->text() == *it) { |
96 | item->setOn(true); | 98 | item->setOn(true); |
97 | if ( ! found ) | 99 | if ( ! found ) |
98 | setColorItem( item ); | 100 | setColorItem( item ); |
99 | found = true; | 101 | found = true; |
100 | break; | 102 | break; |
101 | } | 103 | } |
102 | item = (QCheckListItem *)item->nextSibling(); | 104 | item = (QCheckListItem *)item->nextSibling(); |
103 | } | 105 | } |
104 | // if ( ! found ) { | 106 | // if ( ! found ) { |
105 | 107 | ||
106 | //emit updateCategoriesGlobal(); | 108 | //emit updateCategoriesGlobal(); |
107 | // QMessageBox::information( this, "KO/E: Information!", | 109 | // QMessageBox::information( this, "KO/E: Information!", |
108 | // "Categories found, which were not\n" | 110 | // "Categories found, which were not\n" |
109 | // "in list of categories!\n" | 111 | // "in list of categories!\n" |
110 | // "message", | 112 | // "message", |
111 | // "OK", "", 0, | 113 | // "OK", "", 0, |
112 | // 0, 1 ); | 114 | // 0, 1 ); |
113 | // setSelected(selList); | 115 | // setSelected(selList); |
114 | // return; | 116 | // return; |
115 | // } | 117 | // } |
116 | } | 118 | } |
117 | } | 119 | } |
118 | 120 | ||
119 | QStringList CategorySelectDialog::selectedCategories() const | 121 | QStringList CategorySelectDialog::selectedCategories() const |
120 | { | 122 | { |
121 | return mCategoryList; | 123 | return mCategoryList; |
122 | } | 124 | } |
123 | void CategorySelectDialog::setColorEnabled() | 125 | void CategorySelectDialog::setColorEnabled() |
124 | { | 126 | { |
125 | mColorEnabled = true; | 127 | mColorEnabled = true; |
126 | mSetColorCat->show(); | 128 | mSetColorCat->show(); |
127 | } | 129 | } |
128 | void CategorySelectDialog::setColorCat() | 130 | void CategorySelectDialog::setColorCat() |
129 | { | 131 | { |
130 | QCheckListItem * newColorItem = (QCheckListItem * )mCategories->currentItem (); | 132 | QCheckListItem * newColorItem = (QCheckListItem * )mCategories->currentItem (); |
131 | if ( !newColorItem ) { | 133 | if ( !newColorItem ) { |
132 | KMessageBox::error(this,i18n("There is no current item.")); | 134 | KMessageBox::error(this,i18n("There is no current item.")); |
133 | return; | 135 | return; |
134 | } | 136 | } |
135 | if ( !newColorItem->isOn() ) | 137 | if ( !newColorItem->isOn() ) |
136 | newColorItem->setOn( true ); | 138 | newColorItem->setOn( true ); |
137 | setColorItem( newColorItem ); | 139 | setColorItem( newColorItem ); |
138 | 140 | ||
139 | } | 141 | } |
140 | void CategorySelectDialog::clicked ( QListViewItem * it ) | 142 | void CategorySelectDialog::clicked ( QListViewItem * it ) |
141 | { | 143 | { |
142 | if ( ! it ) | 144 | if ( ! it ) |
143 | return; | 145 | return; |
144 | QCheckListItem *i = (QCheckListItem *) it; | 146 | QCheckListItem *i = (QCheckListItem *) it; |
145 | if ( !i->isOn() && i==mColorItem) { | 147 | if ( !i->isOn() && i==mColorItem) { |
146 | setColorItem( 0); | 148 | setColorItem( 0); |
147 | QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); | 149 | QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); |
148 | while (item) { | 150 | while (item) { |
149 | if (item->isOn()) { | 151 | if (item->isOn()) { |
150 | setColorItem( item ); | 152 | setColorItem( item ); |
151 | break; | 153 | break; |
152 | } | 154 | } |
153 | item = (QCheckListItem *)item->nextSibling(); | 155 | item = (QCheckListItem *)item->nextSibling(); |
154 | } | 156 | } |
155 | } else if ( i->isOn() && !mColorItem) { | 157 | } else if ( i->isOn() && !mColorItem) { |
156 | setColorItem( i); | 158 | setColorItem( i); |
157 | } | 159 | } |
158 | } | 160 | } |
159 | void CategorySelectDialog::setColorItem( QCheckListItem * newColorItem ) | 161 | void CategorySelectDialog::setColorItem( QCheckListItem * newColorItem ) |
160 | { | 162 | { |
161 | if ( !mColorEnabled ) | 163 | if ( !mColorEnabled ) |
162 | return; | 164 | return; |
163 | if ( mColorItem == newColorItem) | 165 | if ( mColorItem == newColorItem) |
164 | return; | 166 | return; |
165 | if ( mColorItem ) { | 167 | if ( mColorItem ) { |
166 | mColorItem->setPixmap ( 0, QPixmap() ); | 168 | mColorItem->setPixmap ( 0, QPixmap() ); |
167 | mColorItem = 0; | 169 | mColorItem = 0; |
168 | } | 170 | } |
169 | if ( newColorItem ) { | 171 | if ( newColorItem ) { |
170 | QPixmap pix (newColorItem->height()/2, newColorItem->height()/2 ); | 172 | QPixmap pix (newColorItem->height()/2, newColorItem->height()/2 ); |
171 | pix.fill(Qt::red ); | 173 | pix.fill(Qt::red ); |
172 | newColorItem->setPixmap ( 0, pix ); | 174 | newColorItem->setPixmap ( 0, pix ); |
173 | mColorItem = newColorItem; | 175 | mColorItem = newColorItem; |
174 | } | 176 | } |
175 | } | 177 | } |
176 | void CategorySelectDialog::slotApply() | 178 | void CategorySelectDialog::slotApply() |
177 | { | 179 | { |
178 | QStringList categories; | 180 | QStringList categories; |
179 | QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); | 181 | QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); |
180 | QString colcat; | 182 | QString colcat; |
181 | while (item) { | 183 | while (item) { |
182 | if (item->isOn()) { | 184 | if (item->isOn()) { |
183 | if ( item == mColorItem) | 185 | if ( item == mColorItem) |
184 | colcat = item->text(); | 186 | colcat = item->text(); |
185 | else | 187 | else |
186 | categories.append(item->text()); | 188 | categories.append(item->text()); |
187 | } | 189 | } |
188 | item = (QCheckListItem *)item->nextSibling(); | 190 | item = (QCheckListItem *)item->nextSibling(); |
189 | } | 191 | } |
190 | categories.sort(); | 192 | categories.sort(); |
191 | if ( ! colcat.isEmpty() ) | 193 | if ( ! colcat.isEmpty() ) |
192 | categories.prepend( colcat ); | 194 | categories.prepend( colcat ); |
193 | QString categoriesStr = categories.join(","); | 195 | QString categoriesStr = categories.join(","); |
194 | 196 | ||
195 | mCategoryList = categories; | 197 | mCategoryList = categories; |
196 | 198 | ||
197 | emit categoriesSelected(categories); | 199 | emit categoriesSelected(categories); |
198 | emit categoriesSelected(categoriesStr); | 200 | emit categoriesSelected(categoriesStr); |
199 | } | 201 | } |
200 | void CategorySelectDialog::accept() | 202 | void CategorySelectDialog::accept() |
201 | { | 203 | { |
202 | slotOk(); | 204 | slotOk(); |
203 | } | 205 | } |
204 | 206 | ||
205 | void CategorySelectDialog::slotOk() | 207 | void CategorySelectDialog::slotOk() |
206 | { | 208 | { |
207 | slotApply(); | 209 | slotApply(); |
208 | QDialog::accept(); | 210 | QDialog::accept(); |
209 | } | 211 | } |
210 | 212 | ||
211 | void CategorySelectDialog::clear() | 213 | void CategorySelectDialog::clear() |
212 | { | 214 | { |
213 | QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); | 215 | QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); |
214 | while (item) { | 216 | while (item) { |
215 | item->setOn(false); | 217 | item->setOn(false); |
216 | item = (QCheckListItem *)item->nextSibling(); | 218 | item = (QCheckListItem *)item->nextSibling(); |
217 | } | 219 | } |
218 | } | 220 | } |
219 | 221 | ||
220 | void CategorySelectDialog::updateCategoryConfig() | 222 | void CategorySelectDialog::updateCategoryConfig() |
221 | { | 223 | { |
222 | QStringList selected; | 224 | QStringList selected; |
223 | QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); | 225 | QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); |
224 | while (item) { | 226 | while (item) { |
225 | if (item->isOn()) { | 227 | if (item->isOn()) { |
226 | selected.append(item->text()); | 228 | selected.append(item->text()); |
227 | } | 229 | } |
228 | item = (QCheckListItem *)item->nextSibling(); | 230 | item = (QCheckListItem *)item->nextSibling(); |
229 | } | 231 | } |
230 | 232 | ||
231 | setCategories(); | 233 | setCategories(); |
232 | 234 | ||
233 | setSelected(selected); | 235 | setSelected(selected); |
234 | } | 236 | } |
235 | 237 | ||
236 | //#include "categoryselectdialog.moc" | 238 | //#include "categoryselectdialog.moc" |