author | zautrix <zautrix> | 2005-03-16 23:29:30 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-16 23:29:30 (UTC) |
commit | e0a510893ffcddb8d58f785832622d030900b2f9 (patch) (unidiff) | |
tree | aa9499e0a81c26a24f832b0dd58bc8943db13e3d | |
parent | d2be5ea1cd22f5222aecb0f70a2fe8657fae9698 (diff) | |
download | kdepimpi-e0a510893ffcddb8d58f785832622d030900b2f9.zip kdepimpi-e0a510893ffcddb8d58f785832622d030900b2f9.tar.gz kdepimpi-e0a510893ffcddb8d58f785832622d030900b2f9.tar.bz2 |
fixes
-rw-r--r-- | libkdepim/categoryselectdialog.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/libkdepim/categoryselectdialog.cpp b/libkdepim/categoryselectdialog.cpp index 4d80726..974752c 100644 --- a/libkdepim/categoryselectdialog.cpp +++ b/libkdepim/categoryselectdialog.cpp | |||
@@ -1,238 +1,241 @@ | |||
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 | slotApply(); | ||
66 | QStringList temp = mCategoryList; | ||
65 | setCategories(); | 67 | setCategories(); |
68 | setSelected( temp ); | ||
66 | } | 69 | } |
67 | void CategorySelectDialog::setCategories() | 70 | void CategorySelectDialog::setCategories() |
68 | { | 71 | { |
69 | mColorItem = 0; | 72 | mColorItem = 0; |
70 | mCategories->clear(); | 73 | mCategories->clear(); |
71 | mCategoryList.clear(); | 74 | mCategoryList.clear(); |
72 | 75 | ||
73 | QStringList::Iterator it; | 76 | QStringList::Iterator it; |
74 | for (it = mPrefs->mCustomCategories.begin(); | 77 | for (it = mPrefs->mCustomCategories.begin(); |
75 | it != mPrefs->mCustomCategories.end(); ++it ) { | 78 | it != mPrefs->mCustomCategories.end(); ++it ) { |
76 | CategorySelectItem * item = new CategorySelectItem(mCategories,*it,QCheckListItem::CheckBox); | 79 | CategorySelectItem * item = new CategorySelectItem(mCategories,*it,QCheckListItem::CheckBox); |
77 | QObject::connect( item, SIGNAL( stateChanged(QListViewItem *) ), this, SLOT( clicked(QListViewItem *) ) ); | 80 | QObject::connect( item, SIGNAL( stateChanged(QListViewItem *) ), this, SLOT( clicked(QListViewItem *) ) ); |
78 | 81 | ||
79 | } | 82 | } |
80 | } | 83 | } |
81 | 84 | ||
82 | CategorySelectDialog::~CategorySelectDialog() | 85 | CategorySelectDialog::~CategorySelectDialog() |
83 | { | 86 | { |
84 | } | 87 | } |
85 | 88 | ||
86 | void CategorySelectDialog::setSelected(const QStringList &selList) | 89 | void CategorySelectDialog::setSelected(const QStringList &selList) |
87 | { | 90 | { |
88 | clear(); | 91 | clear(); |
89 | 92 | ||
90 | QStringList::ConstIterator it; | 93 | QStringList::ConstIterator it; |
91 | QStringList notFound; | 94 | QStringList notFound; |
92 | bool found = false; | 95 | bool found = false; |
93 | for (it=selList.begin();it!=selList.end();++it) { | 96 | for (it=selList.begin();it!=selList.end();++it) { |
94 | //qDebug(" CategorySelectDialog::setSelected("); | 97 | //qDebug(" CategorySelectDialog::setSelected("); |
95 | QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); | 98 | QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); |
96 | while (item) { | 99 | while (item) { |
97 | if (item->text() == *it) { | 100 | if (item->text() == *it) { |
98 | item->setOn(true); | 101 | item->setOn(true); |
99 | if ( ! found ) | 102 | if ( ! found ) |
100 | setColorItem( item ); | 103 | setColorItem( item ); |
101 | found = true; | 104 | found = true; |
102 | break; | 105 | break; |
103 | } | 106 | } |
104 | item = (QCheckListItem *)item->nextSibling(); | 107 | item = (QCheckListItem *)item->nextSibling(); |
105 | } | 108 | } |
106 | // if ( ! found ) { | 109 | // if ( ! found ) { |
107 | 110 | ||
108 | //emit updateCategoriesGlobal(); | 111 | //emit updateCategoriesGlobal(); |
109 | // QMessageBox::information( this, "KO/E: Information!", | 112 | // QMessageBox::information( this, "KO/E: Information!", |
110 | // "Categories found, which were not\n" | 113 | // "Categories found, which were not\n" |
111 | // "in list of categories!\n" | 114 | // "in list of categories!\n" |
112 | // "message", | 115 | // "message", |
113 | // "OK", "", 0, | 116 | // "OK", "", 0, |
114 | // 0, 1 ); | 117 | // 0, 1 ); |
115 | // setSelected(selList); | 118 | // setSelected(selList); |
116 | // return; | 119 | // return; |
117 | // } | 120 | // } |
118 | } | 121 | } |
119 | } | 122 | } |
120 | 123 | ||
121 | QStringList CategorySelectDialog::selectedCategories() const | 124 | QStringList CategorySelectDialog::selectedCategories() const |
122 | { | 125 | { |
123 | return mCategoryList; | 126 | return mCategoryList; |
124 | } | 127 | } |
125 | void CategorySelectDialog::setColorEnabled() | 128 | void CategorySelectDialog::setColorEnabled() |
126 | { | 129 | { |
127 | mColorEnabled = true; | 130 | mColorEnabled = true; |
128 | mSetColorCat->show(); | 131 | mSetColorCat->show(); |
129 | } | 132 | } |
130 | void CategorySelectDialog::setColorCat() | 133 | void CategorySelectDialog::setColorCat() |
131 | { | 134 | { |
132 | QCheckListItem * newColorItem = (QCheckListItem * )mCategories->currentItem (); | 135 | QCheckListItem * newColorItem = (QCheckListItem * )mCategories->currentItem (); |
133 | if ( !newColorItem ) { | 136 | if ( !newColorItem ) { |
134 | KMessageBox::error(this,i18n("There is no current item.")); | 137 | KMessageBox::error(this,i18n("There is no current item.")); |
135 | return; | 138 | return; |
136 | } | 139 | } |
137 | if ( !newColorItem->isOn() ) | 140 | if ( !newColorItem->isOn() ) |
138 | newColorItem->setOn( true ); | 141 | newColorItem->setOn( true ); |
139 | setColorItem( newColorItem ); | 142 | setColorItem( newColorItem ); |
140 | 143 | ||
141 | } | 144 | } |
142 | void CategorySelectDialog::clicked ( QListViewItem * it ) | 145 | void CategorySelectDialog::clicked ( QListViewItem * it ) |
143 | { | 146 | { |
144 | if ( ! it ) | 147 | if ( ! it ) |
145 | return; | 148 | return; |
146 | QCheckListItem *i = (QCheckListItem *) it; | 149 | QCheckListItem *i = (QCheckListItem *) it; |
147 | if ( !i->isOn() && i==mColorItem) { | 150 | if ( !i->isOn() && i==mColorItem) { |
148 | setColorItem( 0); | 151 | setColorItem( 0); |
149 | QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); | 152 | QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); |
150 | while (item) { | 153 | while (item) { |
151 | if (item->isOn()) { | 154 | if (item->isOn()) { |
152 | setColorItem( item ); | 155 | setColorItem( item ); |
153 | break; | 156 | break; |
154 | } | 157 | } |
155 | item = (QCheckListItem *)item->nextSibling(); | 158 | item = (QCheckListItem *)item->nextSibling(); |
156 | } | 159 | } |
157 | } else if ( i->isOn() && !mColorItem) { | 160 | } else if ( i->isOn() && !mColorItem) { |
158 | setColorItem( i); | 161 | setColorItem( i); |
159 | } | 162 | } |
160 | } | 163 | } |
161 | void CategorySelectDialog::setColorItem( QCheckListItem * newColorItem ) | 164 | void CategorySelectDialog::setColorItem( QCheckListItem * newColorItem ) |
162 | { | 165 | { |
163 | if ( !mColorEnabled ) | 166 | if ( !mColorEnabled ) |
164 | return; | 167 | return; |
165 | if ( mColorItem == newColorItem) | 168 | if ( mColorItem == newColorItem) |
166 | return; | 169 | return; |
167 | if ( mColorItem ) { | 170 | if ( mColorItem ) { |
168 | mColorItem->setPixmap ( 0, QPixmap() ); | 171 | mColorItem->setPixmap ( 0, QPixmap() ); |
169 | mColorItem = 0; | 172 | mColorItem = 0; |
170 | } | 173 | } |
171 | if ( newColorItem ) { | 174 | if ( newColorItem ) { |
172 | QPixmap pix (newColorItem->height()/2, newColorItem->height()/2 ); | 175 | QPixmap pix (newColorItem->height()/2, newColorItem->height()/2 ); |
173 | pix.fill(Qt::red ); | 176 | pix.fill(Qt::red ); |
174 | newColorItem->setPixmap ( 0, pix ); | 177 | newColorItem->setPixmap ( 0, pix ); |
175 | mColorItem = newColorItem; | 178 | mColorItem = newColorItem; |
176 | } | 179 | } |
177 | } | 180 | } |
178 | void CategorySelectDialog::slotApply() | 181 | void CategorySelectDialog::slotApply() |
179 | { | 182 | { |
180 | QStringList categories; | 183 | QStringList categories; |
181 | QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); | 184 | QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); |
182 | QString colcat; | 185 | QString colcat; |
183 | while (item) { | 186 | while (item) { |
184 | if (item->isOn()) { | 187 | if (item->isOn()) { |
185 | if ( item == mColorItem) | 188 | if ( item == mColorItem) |
186 | colcat = item->text(); | 189 | colcat = item->text(); |
187 | else | 190 | else |
188 | categories.append(item->text()); | 191 | categories.append(item->text()); |
189 | } | 192 | } |
190 | item = (QCheckListItem *)item->nextSibling(); | 193 | item = (QCheckListItem *)item->nextSibling(); |
191 | } | 194 | } |
192 | categories.sort(); | 195 | categories.sort(); |
193 | if ( ! colcat.isEmpty() ) | 196 | if ( ! colcat.isEmpty() ) |
194 | categories.prepend( colcat ); | 197 | categories.prepend( colcat ); |
195 | QString categoriesStr = categories.join(","); | 198 | // QString categoriesStr = categories.join(","); |
196 | 199 | ||
197 | mCategoryList = categories; | 200 | mCategoryList = categories; |
198 | 201 | ||
199 | emit categoriesSelected(categories); | ||
200 | emit categoriesSelected(categoriesStr); | ||
201 | } | 202 | } |
202 | void CategorySelectDialog::accept() | 203 | void CategorySelectDialog::accept() |
203 | { | 204 | { |
204 | slotOk(); | 205 | slotOk(); |
205 | } | 206 | } |
206 | 207 | ||
207 | void CategorySelectDialog::slotOk() | 208 | void CategorySelectDialog::slotOk() |
208 | { | 209 | { |
209 | slotApply(); | 210 | slotApply(); |
211 | emit categoriesSelected(mCategoryList); | ||
212 | emit categoriesSelected(mCategoryList.join(",")); | ||
210 | QDialog::accept(); | 213 | QDialog::accept(); |
211 | } | 214 | } |
212 | 215 | ||
213 | void CategorySelectDialog::clear() | 216 | void CategorySelectDialog::clear() |
214 | { | 217 | { |
215 | QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); | 218 | QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); |
216 | while (item) { | 219 | while (item) { |
217 | item->setOn(false); | 220 | item->setOn(false); |
218 | item = (QCheckListItem *)item->nextSibling(); | 221 | item = (QCheckListItem *)item->nextSibling(); |
219 | } | 222 | } |
220 | } | 223 | } |
221 | 224 | ||
222 | void CategorySelectDialog::updateCategoryConfig() | 225 | void CategorySelectDialog::updateCategoryConfig() |
223 | { | 226 | { |
224 | QStringList selected; | 227 | QStringList selected; |
225 | QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); | 228 | QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); |
226 | while (item) { | 229 | while (item) { |
227 | if (item->isOn()) { | 230 | if (item->isOn()) { |
228 | selected.append(item->text()); | 231 | selected.append(item->text()); |
229 | } | 232 | } |
230 | item = (QCheckListItem *)item->nextSibling(); | 233 | item = (QCheckListItem *)item->nextSibling(); |
231 | } | 234 | } |
232 | 235 | ||
233 | setCategories(); | 236 | setCategories(); |
234 | 237 | ||
235 | setSelected(selected); | 238 | setSelected(selected); |
236 | } | 239 | } |
237 | 240 | ||
238 | //#include "categoryselectdialog.moc" | 241 | //#include "categoryselectdialog.moc" |