author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /libkdepim/categoryselectdialog.cpp | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2 |
initial public commit of qt4 portp1
Diffstat (limited to 'libkdepim/categoryselectdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libkdepim/categoryselectdialog.cpp | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/libkdepim/categoryselectdialog.cpp b/libkdepim/categoryselectdialog.cpp index 2a9b43e..4f72880 100644 --- a/libkdepim/categoryselectdialog.cpp +++ b/libkdepim/categoryselectdialog.cpp | |||
@@ -8,50 +8,53 @@ | |||
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 <q3listview.h> |
25 | #include <qpushbutton.h> | 25 | #include <qpushbutton.h> |
26 | #include <qheader.h> | 26 | #include <q3header.h> |
27 | #include <qapp.h> | 27 | #include <qapplication.h> |
28 | #include <qmessagebox.h> | 28 | #include <qmessagebox.h> |
29 | //Added by qt3to4: | ||
30 | #include <QPixmap> | ||
31 | #include <QDesktopWidget> | ||
29 | #include <kmessagebox.h> | 32 | #include <kmessagebox.h> |
30 | 33 | ||
31 | 34 | ||
32 | #include "categoryeditdialog.h" | 35 | #include "categoryeditdialog.h" |
33 | #include "categoryselectdialog.h" | 36 | #include "categoryselectdialog.h" |
34 | 37 | ||
35 | #include "kpimprefs.h" | 38 | #include "kpimprefs.h" |
36 | 39 | ||
37 | using namespace KPIM; | 40 | using namespace KPIM; |
38 | 41 | ||
39 | CategorySelectDialog::CategorySelectDialog( KPimPrefs *prefs, QWidget* parent, | 42 | CategorySelectDialog::CategorySelectDialog( KPimPrefs *prefs, QWidget* parent, |
40 | const char* name, | 43 | const char* name, |
41 | bool modal, WFlags fl ) | 44 | bool modal, Qt::WFlags fl ) |
42 | : CategorySelectDialog_base( parent, name, true, fl ), | 45 | : CategorySelectDialog_base( parent, name, true, fl ), |
43 | mPrefs( prefs ) | 46 | mPrefs( prefs ) |
44 | { | 47 | { |
45 | Q_UNUSED( modal ); | 48 | Q_UNUSED( modal ); |
46 | mColorItem = 0; | 49 | mColorItem = 0; |
47 | mColorEnabled = false; | 50 | mColorEnabled = false; |
48 | mCategories->header()->hide(); | 51 | mCategories->header()->hide(); |
49 | 52 | ||
50 | setCategories(); | 53 | setCategories(); |
51 | 54 | ||
52 | connect(mButtonEdit,SIGNAL(clicked()),this, SLOT(editCategoriesDialog())); | 55 | connect(mButtonEdit,SIGNAL(clicked()),this, SLOT(editCategoriesDialog())); |
53 | if ( QApplication::desktop()->width() > 460 ) | 56 | if ( QApplication::desktop()->width() > 460 ) |
54 | resize( 300, 360 ); | 57 | resize( 300, 360 ); |
55 | else | 58 | else |
56 | showMaximized(); | 59 | showMaximized(); |
57 | connect( mSetColorCat, SIGNAL( clicked() ), this, SLOT( setColorCat() ) ); | 60 | connect( mSetColorCat, SIGNAL( clicked() ), this, SLOT( setColorCat() ) ); |
@@ -68,179 +71,179 @@ void CategorySelectDialog::editCategoriesDialog() | |||
68 | ced->exec(); | 71 | ced->exec(); |
69 | delete ced; | 72 | delete ced; |
70 | slotApply(); | 73 | slotApply(); |
71 | QStringList temp = mCategoryList; | 74 | QStringList temp = mCategoryList; |
72 | setCategories(); | 75 | setCategories(); |
73 | setSelected( temp ); | 76 | setSelected( temp ); |
74 | } | 77 | } |
75 | void CategorySelectDialog::setCategories() | 78 | void CategorySelectDialog::setCategories() |
76 | { | 79 | { |
77 | mColorItem = 0; | 80 | mColorItem = 0; |
78 | mCategories->clear(); | 81 | mCategories->clear(); |
79 | mCategoryList.clear(); | 82 | mCategoryList.clear(); |
80 | 83 | ||
81 | QStringList::Iterator it; | 84 | QStringList::Iterator it; |
82 | for (it = mPrefs->mCustomCategories.begin(); | 85 | for (it = mPrefs->mCustomCategories.begin(); |
83 | it != mPrefs->mCustomCategories.end(); ++it ) { | 86 | it != mPrefs->mCustomCategories.end(); ++it ) { |
84 | CategorySelectItem * item = new CategorySelectItem(mCategories,*it,QCheckListItem::CheckBox); | 87 | CategorySelectItem * item = new CategorySelectItem(mCategories,*it,Q3CheckListItem::CheckBox); |
85 | QObject::connect( item, SIGNAL( stateChanged(QListViewItem *) ), this, SLOT( clicked(QListViewItem *) ) ); | 88 | QObject::connect( item, SIGNAL( stateChanged(Q3ListViewItem *) ), this, SLOT( clicked(Q3ListViewItem *) ) ); |
86 | 89 | ||
87 | } | 90 | } |
88 | } | 91 | } |
89 | 92 | ||
90 | CategorySelectDialog::~CategorySelectDialog() | 93 | CategorySelectDialog::~CategorySelectDialog() |
91 | { | 94 | { |
92 | } | 95 | } |
93 | 96 | ||
94 | void CategorySelectDialog::setSelected(const QStringList &selList) | 97 | void CategorySelectDialog::setSelected(const QStringList &selList) |
95 | { | 98 | { |
96 | clear(); | 99 | clear(); |
97 | 100 | ||
98 | QStringList::ConstIterator it; | 101 | QStringList::ConstIterator it; |
99 | QStringList notFound; | 102 | QStringList notFound; |
100 | bool found = false; | 103 | bool found = false; |
101 | for (it=selList.begin();it!=selList.end();++it) { | 104 | for (it=selList.begin();it!=selList.end();++it) { |
102 | //qDebug(" CategorySelectDialog::setSelected("); | 105 | //qDebug(" CategorySelectDialog::setSelected("); |
103 | QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); | 106 | Q3CheckListItem *item = (Q3CheckListItem *)mCategories->firstChild(); |
104 | while (item) { | 107 | while (item) { |
105 | if (item->text() == *it) { | 108 | if (item->text() == *it) { |
106 | item->setOn(true); | 109 | item->setOn(true); |
107 | if ( ! found ) | 110 | if ( ! found ) |
108 | setColorItem( item ); | 111 | setColorItem( item ); |
109 | found = true; | 112 | found = true; |
110 | break; | 113 | break; |
111 | } | 114 | } |
112 | item = (QCheckListItem *)item->nextSibling(); | 115 | item = (Q3CheckListItem *)item->nextSibling(); |
113 | } | 116 | } |
114 | // if ( ! found ) { | 117 | // if ( ! found ) { |
115 | 118 | ||
116 | //emit updateCategoriesGlobal(); | 119 | //emit updateCategoriesGlobal(); |
117 | // QMessageBox::information( this, "KO/E: Information!", | 120 | // QMessageBox::information( this, "KO/E: Information!", |
118 | // "Categories found, which were not\n" | 121 | // "Categories found, which were not\n" |
119 | // "in list of categories!\n" | 122 | // "in list of categories!\n" |
120 | // "message", | 123 | // "message", |
121 | // "OK", "", 0, | 124 | // "OK", "", 0, |
122 | // 0, 1 ); | 125 | // 0, 1 ); |
123 | // setSelected(selList); | 126 | // setSelected(selList); |
124 | // return; | 127 | // return; |
125 | // } | 128 | // } |
126 | } | 129 | } |
127 | } | 130 | } |
128 | 131 | ||
129 | QStringList CategorySelectDialog::selectedCategories() const | 132 | QStringList CategorySelectDialog::selectedCategories() const |
130 | { | 133 | { |
131 | return mCategoryList; | 134 | return mCategoryList; |
132 | } | 135 | } |
133 | void CategorySelectDialog::setColorEnabled() | 136 | void CategorySelectDialog::setColorEnabled() |
134 | { | 137 | { |
135 | mColorEnabled = true; | 138 | mColorEnabled = true; |
136 | mSetColorCat->show(); | 139 | mSetColorCat->show(); |
137 | } | 140 | } |
138 | void CategorySelectDialog::setColorCat() | 141 | void CategorySelectDialog::setColorCat() |
139 | { | 142 | { |
140 | QCheckListItem * newColorItem = (QCheckListItem * )mCategories->currentItem (); | 143 | Q3CheckListItem * newColorItem = (Q3CheckListItem * )mCategories->currentItem (); |
141 | if ( !newColorItem ) { | 144 | if ( !newColorItem ) { |
142 | KMessageBox::error(this,i18n("There is no current item.")); | 145 | KMessageBox::error(this,i18n("There is no current item.")); |
143 | return; | 146 | return; |
144 | } | 147 | } |
145 | if ( !newColorItem->isOn() ) | 148 | if ( !newColorItem->isOn() ) |
146 | newColorItem->setOn( true ); | 149 | newColorItem->setOn( true ); |
147 | setColorItem( newColorItem ); | 150 | setColorItem( newColorItem ); |
148 | 151 | ||
149 | } | 152 | } |
150 | void CategorySelectDialog::clicked ( QListViewItem * it ) | 153 | void CategorySelectDialog::clicked ( Q3ListViewItem * it ) |
151 | { | 154 | { |
152 | if ( ! it ) | 155 | if ( ! it ) |
153 | return; | 156 | return; |
154 | QCheckListItem *i = (QCheckListItem *) it; | 157 | Q3CheckListItem *i = (Q3CheckListItem *) it; |
155 | if ( !i->isOn() && i==mColorItem) { | 158 | if ( !i->isOn() && i==mColorItem) { |
156 | setColorItem( 0); | 159 | setColorItem( 0); |
157 | QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); | 160 | Q3CheckListItem *item = (Q3CheckListItem *)mCategories->firstChild(); |
158 | while (item) { | 161 | while (item) { |
159 | if (item->isOn()) { | 162 | if (item->isOn()) { |
160 | setColorItem( item ); | 163 | setColorItem( item ); |
161 | break; | 164 | break; |
162 | } | 165 | } |
163 | item = (QCheckListItem *)item->nextSibling(); | 166 | item = (Q3CheckListItem *)item->nextSibling(); |
164 | } | 167 | } |
165 | } else if ( i->isOn() && !mColorItem) { | 168 | } else if ( i->isOn() && !mColorItem) { |
166 | setColorItem( i); | 169 | setColorItem( i); |
167 | } | 170 | } |
168 | } | 171 | } |
169 | void CategorySelectDialog::setColorItem( QCheckListItem * newColorItem ) | 172 | void CategorySelectDialog::setColorItem( Q3CheckListItem * newColorItem ) |
170 | { | 173 | { |
171 | if ( !mColorEnabled ) | 174 | if ( !mColorEnabled ) |
172 | return; | 175 | return; |
173 | if ( mColorItem == newColorItem) | 176 | if ( mColorItem == newColorItem) |
174 | return; | 177 | return; |
175 | if ( mColorItem ) { | 178 | if ( mColorItem ) { |
176 | mColorItem->setPixmap ( 0, QPixmap() ); | 179 | mColorItem->setPixmap ( 0, QPixmap() ); |
177 | mColorItem = 0; | 180 | mColorItem = 0; |
178 | } | 181 | } |
179 | if ( newColorItem ) { | 182 | if ( newColorItem ) { |
180 | QPixmap pix (newColorItem->height()/2, newColorItem->height()/2 ); | 183 | QPixmap pix (newColorItem->height()/2, newColorItem->height()/2 ); |
181 | pix.fill(Qt::red ); | 184 | pix.fill(Qt::red ); |
182 | newColorItem->setPixmap ( 0, pix ); | 185 | newColorItem->setPixmap ( 0, pix ); |
183 | mColorItem = newColorItem; | 186 | mColorItem = newColorItem; |
184 | } | 187 | } |
185 | } | 188 | } |
186 | void CategorySelectDialog::slotApply() | 189 | void CategorySelectDialog::slotApply() |
187 | { | 190 | { |
188 | QStringList categories; | 191 | QStringList categories; |
189 | QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); | 192 | Q3CheckListItem *item = (Q3CheckListItem *)mCategories->firstChild(); |
190 | QString colcat; | 193 | QString colcat; |
191 | while (item) { | 194 | while (item) { |
192 | if (item->isOn()) { | 195 | if (item->isOn()) { |
193 | if ( item == mColorItem) | 196 | if ( item == mColorItem) |
194 | colcat = item->text(); | 197 | colcat = item->text(); |
195 | else | 198 | else |
196 | categories.append(item->text()); | 199 | categories.append(item->text()); |
197 | } | 200 | } |
198 | item = (QCheckListItem *)item->nextSibling(); | 201 | item = (Q3CheckListItem *)item->nextSibling(); |
199 | } | 202 | } |
200 | categories.sort(); | 203 | categories.sort(); |
201 | if ( ! colcat.isEmpty() ) | 204 | if ( ! colcat.isEmpty() ) |
202 | categories.prepend( colcat ); | 205 | categories.prepend( colcat ); |
203 | // QString categoriesStr = categories.join(","); | 206 | // QString categoriesStr = categories.join(","); |
204 | 207 | ||
205 | mCategoryList = categories; | 208 | mCategoryList = categories; |
206 | 209 | ||
207 | } | 210 | } |
208 | void CategorySelectDialog::accept() | 211 | void CategorySelectDialog::accept() |
209 | { | 212 | { |
210 | slotOk(); | 213 | slotOk(); |
211 | } | 214 | } |
212 | 215 | ||
213 | void CategorySelectDialog::slotOk() | 216 | void CategorySelectDialog::slotOk() |
214 | { | 217 | { |
215 | slotApply(); | 218 | slotApply(); |
216 | emit categoriesSelected(mCategoryList); | 219 | emit categoriesSelected(mCategoryList); |
217 | emit categoriesSelected(mCategoryList.join(",")); | 220 | emit categoriesSelected(mCategoryList.join(",")); |
218 | QDialog::accept(); | 221 | QDialog::accept(); |
219 | } | 222 | } |
220 | 223 | ||
221 | void CategorySelectDialog::clear() | 224 | void CategorySelectDialog::clear() |
222 | { | 225 | { |
223 | QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); | 226 | Q3CheckListItem *item = (Q3CheckListItem *)mCategories->firstChild(); |
224 | while (item) { | 227 | while (item) { |
225 | item->setOn(false); | 228 | item->setOn(false); |
226 | item = (QCheckListItem *)item->nextSibling(); | 229 | item = (Q3CheckListItem *)item->nextSibling(); |
227 | } | 230 | } |
228 | } | 231 | } |
229 | 232 | ||
230 | void CategorySelectDialog::updateCategoryConfig() | 233 | void CategorySelectDialog::updateCategoryConfig() |
231 | { | 234 | { |
232 | QStringList selected; | 235 | QStringList selected; |
233 | QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); | 236 | Q3CheckListItem *item = (Q3CheckListItem *)mCategories->firstChild(); |
234 | while (item) { | 237 | while (item) { |
235 | if (item->isOn()) { | 238 | if (item->isOn()) { |
236 | selected.append(item->text()); | 239 | selected.append(item->text()); |
237 | } | 240 | } |
238 | item = (QCheckListItem *)item->nextSibling(); | 241 | item = (Q3CheckListItem *)item->nextSibling(); |
239 | } | 242 | } |
240 | 243 | ||
241 | setCategories(); | 244 | setCategories(); |
242 | 245 | ||
243 | setSelected(selected); | 246 | setSelected(selected); |
244 | } | 247 | } |
245 | 248 | ||
246 | //#include "categoryselectdialog.moc" | 249 | //#include "categoryselectdialog.moc" |