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