-rw-r--r-- | library/categoryselect.cpp | 185 |
1 files changed, 161 insertions, 24 deletions
diff --git a/library/categoryselect.cpp b/library/categoryselect.cpp index dc5d1fa..21b3f91 100644 --- a/library/categoryselect.cpp +++ b/library/categoryselect.cpp | |||
@@ -1,315 +1,452 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include <qpe/categories.h> | 21 | #include <qpe/categories.h> |
22 | #include <qpe/palmtoprecord.h> | ||
22 | 23 | ||
23 | #include <qdialog.h> | 24 | #include <qmessagebox.h> |
24 | #include <qlayout.h> | 25 | #include <qlayout.h> |
25 | #include <qtoolbutton.h> | 26 | #include <qtoolbutton.h> |
27 | #include <qfile.h> | ||
26 | 28 | ||
27 | #include "categorywidget.h" | 29 | #include "categorywidget.h" |
28 | #include "categoryselect.h" | 30 | #include "categoryselect.h" |
29 | 31 | ||
32 | #include <stdlib.h> | ||
33 | |||
34 | static QString categoryEdittingFileName() | ||
35 | { | ||
36 | QString str = getenv("HOME"); | ||
37 | str +="/.cateditting"; | ||
38 | return str; | ||
39 | } | ||
30 | 40 | ||
31 | class CategoryComboPrivate | 41 | class CategoryComboPrivate |
32 | { | 42 | { |
33 | public: | 43 | public: |
34 | CategoryComboPrivate(QObject *o) | 44 | CategoryComboPrivate(QObject *o) |
35 | : mCat( o ) | 45 | : mCat( o ) |
36 | { | 46 | { |
37 | } | 47 | } |
38 | QArray<int> mAppCats; | 48 | QArray<int> mAppCats; |
39 | QString mStrAppName; | 49 | QString mStrAppName; |
40 | QString mStrVisibleName; | 50 | QString mStrVisibleName; |
41 | Categories mCat; | 51 | Categories mCat; |
42 | }; | 52 | }; |
43 | 53 | ||
44 | class CategorySelectPrivate | 54 | class CategorySelectPrivate |
45 | { | 55 | { |
46 | public: | 56 | public: |
47 | CategorySelectPrivate( const QArray<int> &cats) | 57 | CategorySelectPrivate( const QArray<int> &cats) |
48 | : mRec( cats ), | 58 | : mRec( cats ), |
49 | usingAll( false ) | 59 | usingAll( false ) |
50 | { | 60 | { |
51 | } | 61 | } |
52 | CategorySelectPrivate() | 62 | CategorySelectPrivate() |
53 | { | 63 | { |
54 | } | 64 | } |
55 | QArray<int> mRec; | 65 | QArray<int> mRec; |
56 | bool usingAll; | 66 | bool usingAll; |
57 | QString mVisibleName; | 67 | QString mVisibleName; |
58 | }; | 68 | }; |
59 | 69 | ||
60 | CategoryCombo::CategoryCombo( QWidget *parent, const char *name ) | 70 | CategoryCombo::CategoryCombo( QWidget *parent, const char *name , int width) |
61 | : QComboBox( parent, name ) | 71 | : QComboBox( parent, name ) |
62 | { | 72 | { |
63 | d = new CategoryComboPrivate(this); | 73 | d = new CategoryComboPrivate(this); |
74 | if (width) | ||
75 | setFixedWidth(width); | ||
64 | } | 76 | } |
65 | 77 | ||
66 | void CategoryCombo::initCombo( const QArray<int> &recCats, | 78 | void CategoryCombo::initCombo( const QArray<int> &recCats, |
67 | const QString &appName ) | 79 | const QString &appName ) |
68 | { | 80 | { |
69 | initCombo( recCats, appName, appName ); | 81 | initCombo( recCats, appName, appName ); |
70 | } | 82 | } |
71 | 83 | ||
72 | void CategoryCombo::initCombo( const QArray<int> &recCats, | 84 | void CategoryCombo::initCombo( const QArray<int> &recCats, |
73 | const QString &appName, | 85 | const QString &appName, |
74 | const QString &visibleName ) | 86 | const QString &visibleName ) |
75 | { | 87 | { |
76 | d->mStrAppName = appName; | 88 | d->mStrAppName = appName; |
77 | d->mStrVisibleName = visibleName; | 89 | d->mStrVisibleName = visibleName; |
78 | clear(); | 90 | clear(); |
79 | QStringList slApp; | 91 | QStringList slApp; |
80 | 92 | ||
93 | QObject::disconnect( this, SIGNAL(activated(int)), | ||
94 | this, SLOT(slotValueChanged(int)) ); | ||
95 | |||
81 | QObject::connect( this, SIGNAL(activated(int)), | 96 | QObject::connect( this, SIGNAL(activated(int)), |
82 | this, SLOT(slotValueChanged(int)) ); | 97 | this, SLOT(slotValueChanged(int)) ); |
83 | bool loadOk = d->mCat.load( categoryFileName() ); | 98 | bool loadOk = d->mCat.load( categoryFileName() ); |
84 | slApp = d->mCat.labels( d->mStrAppName, TRUE, Categories::UnfiledLabel ); | 99 | slApp = d->mCat.labels( d->mStrAppName, TRUE, Categories::UnfiledLabel ); |
85 | d->mAppCats = d->mCat.ids( d->mStrAppName ); | 100 | |
101 | d->mAppCats = d->mCat.ids( d->mStrAppName, slApp); | ||
86 | 102 | ||
87 | int i, | 103 | int i, |
88 | j, | 104 | j, |
89 | saveMe, | 105 | saveMe, |
90 | recCount; | 106 | recCount; |
91 | QStringList::Iterator it; | 107 | QStringList::Iterator it; |
92 | // now add in all the items... | 108 | // now add in all the items... |
93 | recCount = recCats.count(); | 109 | recCount = recCats.count(); |
94 | saveMe = -1; | 110 | saveMe = -1; |
95 | if ( recCount > 1 && loadOk ) { | 111 | if ( recCount > 1 && loadOk ) { |
96 | it = slApp.begin(); | 112 | it = slApp.begin(); |
97 | insertItem( *it ); | 113 | for ( j = 0; j< (int)(slApp.count()-1); ++it, j++ ) { |
98 | ++it; | ||
99 | for ( j = 0; it != slApp.end(); ++it, j++ ) { | ||
100 | // grr... we have to go through and compare... | 114 | // grr... we have to go through and compare... |
101 | if ( j < int(d->mAppCats.size()) ) { | 115 | if ( j < int(d->mAppCats.size()) ) { |
102 | for ( i = 0; i < recCount; i++ ) { | 116 | for ( i = 0; i < recCount; i++ ) { |
103 | if ( recCats[i] == d->mAppCats[j] ) { | 117 | if ( recCats[i] == d->mAppCats[j] ) { |
104 | (*it).append( tr(" (Multi.)") ); | 118 | (*it).append( tr(" (Multi.)") ); |
105 | if ( saveMe < 0 ) | 119 | if ( saveMe < 0 ) |
106 | saveMe = j; | 120 | saveMe = j; |
107 | // no need to continue through the list. | 121 | // no need to continue through the list. |
108 | break; | 122 | break; |
109 | } | 123 | } |
110 | } | 124 | } |
111 | } | 125 | } |
112 | insertItem( *it ); | 126 | insertItem( *it ); |
113 | } | 127 | } |
128 | insertItem( *it ); | ||
114 | } else | 129 | } else |
115 | insertStringList( slApp ); | 130 | insertStringList( slApp ); |
116 | 131 | ||
117 | if ( recCount > 0 && loadOk ) { | 132 | if ( recCount > 0 && loadOk ) { |
118 | for ( i = 0; i < int(d->mAppCats.size()); i++ ) { | 133 | for ( i = 0; i < int(d->mAppCats.size()); i++ ) { |
119 | if ( d->mAppCats[i] == recCats[0] ) { | 134 | if ( d->mAppCats[i] == recCats[0] ) { |
120 | setCurrentItem( i + 1 ); | 135 | setCurrentItem( i ); |
136 | break; | ||
137 | } | ||
138 | } | ||
139 | } else | ||
140 | { | ||
141 | setCurrentItem( slApp.count()-1 ); // unfiled | ||
142 | } | ||
143 | } | ||
144 | |||
145 | // this is a new function by SHARP instead of initCombo() | ||
146 | QArray<int> CategoryCombo::initComboWithRefind( const QArray<int> &recCats, | ||
147 | const QString &appName) | ||
148 | { | ||
149 | QString visibleName = appName; | ||
150 | d->mStrAppName = appName; | ||
151 | d->mStrVisibleName = visibleName; | ||
152 | clear(); | ||
153 | QStringList slApp; | ||
154 | QArray<int> results; | ||
155 | |||
156 | QObject::disconnect( this, SIGNAL(activated(int)), | ||
157 | this, SLOT(slotValueChanged(int)) ); | ||
158 | |||
159 | QObject::connect( this, SIGNAL(activated(int)), | ||
160 | this, SLOT(slotValueChanged(int)) ); | ||
161 | bool loadOk = d->mCat.load( categoryFileName() ); | ||
162 | slApp = d->mCat.labels( d->mStrAppName, TRUE, Categories::UnfiledLabel ); | ||
163 | |||
164 | d->mAppCats = d->mCat.ids( d->mStrAppName, slApp); | ||
165 | |||
166 | // addition part | ||
167 | // make new recCats | ||
168 | if (loadOk){ | ||
169 | int i,j; | ||
170 | int value; | ||
171 | int rCount = recCats.count(); | ||
172 | int mCount = d->mAppCats.count(); | ||
173 | |||
174 | for (i=0; i<rCount; i++){ | ||
175 | value = 0; | ||
176 | for (j=0; j<mCount; j++){ | ||
177 | if (recCats[i] == d->mAppCats[j]){ | ||
178 | value = recCats[i]; | ||
179 | break; | ||
180 | } | ||
181 | } | ||
182 | if (value != 0){ | ||
183 | int tmp = results.size(); | ||
184 | results.resize( tmp + 1 ); | ||
185 | results[ tmp ] = value; | ||
186 | } | ||
187 | } | ||
188 | } | ||
189 | else{ | ||
190 | results = recCats; | ||
191 | } | ||
192 | // addition end | ||
193 | |||
194 | int i, | ||
195 | j, | ||
196 | saveMe, | ||
197 | recCount; | ||
198 | QStringList::Iterator it; | ||
199 | // now add in all the items... | ||
200 | recCount = results.count(); | ||
201 | saveMe = -1; | ||
202 | if ( recCount > 1 && loadOk ) { | ||
203 | it = slApp.begin(); | ||
204 | for ( j = 0; j< (int)(slApp.count()-1); ++it, j++ ) { | ||
205 | |||
206 | // grr... we have to go through and compare... | ||
207 | if ( j < int(d->mAppCats.size()) ) { | ||
208 | for ( i = 0; i < recCount; i++ ) { | ||
209 | if ( results[i] == d->mAppCats[j] ) { | ||
210 | (*it).append( tr(" (Multi.)") ); | ||
211 | if ( saveMe < 0 ) | ||
212 | saveMe = j; | ||
213 | // no need to continue through the list. | ||
214 | break; | ||
215 | } | ||
216 | } | ||
217 | } | ||
218 | insertItem( *it ); | ||
219 | } | ||
220 | insertItem( *it ); | ||
221 | } else | ||
222 | insertStringList( slApp ); | ||
223 | |||
224 | if ( recCount > 0 && loadOk ) { | ||
225 | for ( i = 0; i < int(d->mAppCats.size()); i++ ) { | ||
226 | if ( d->mAppCats[i] == results[0] ) { | ||
227 | setCurrentItem( i ); | ||
121 | break; | 228 | break; |
122 | } | 229 | } |
123 | } | 230 | } |
124 | } else | 231 | } else |
125 | setCurrentItem( 0 ); // unfiled | 232 | { |
233 | setCurrentItem( slApp.count()-1 ); // unfiled | ||
234 | } | ||
235 | /* | ||
126 | QObject::connect( this, SIGNAL(activated(int)), | 236 | QObject::connect( this, SIGNAL(activated(int)), |
127 | this, SLOT(slotValueChanged(int)) ); | 237 | this, SLOT(slotValueChanged(int)) ); |
238 | */ | ||
239 | return results; | ||
128 | } | 240 | } |
129 | 241 | ||
242 | |||
130 | CategoryCombo::~CategoryCombo() | 243 | CategoryCombo::~CategoryCombo() |
131 | { | 244 | { |
132 | delete d; | 245 | delete d; |
133 | } | 246 | } |
134 | 247 | ||
135 | int CategoryCombo::currentCategory() const | 248 | int CategoryCombo::currentCategory() const |
136 | { | 249 | { |
137 | int returnMe; | 250 | int returnMe; |
138 | returnMe = currentItem(); | 251 | returnMe = currentItem(); |
139 | // unfiled is now 0... | 252 | |
140 | if ( returnMe == 0 ) | 253 | if ( returnMe == (int)d->mAppCats.count() ) |
141 | returnMe = -1; | 254 | returnMe = -1; |
142 | else if ( returnMe > (int)d->mAppCats.count() ) // only happen on "All" | 255 | else if ( returnMe > (int)d->mAppCats.count() ) // only happen on "All" |
143 | returnMe = -2; | 256 | returnMe = -2; |
144 | else | 257 | else |
145 | returnMe = d->mAppCats[returnMe - 1]; | 258 | returnMe = d->mAppCats[returnMe]; |
146 | return returnMe; | 259 | return returnMe; |
147 | } | 260 | } |
148 | 261 | ||
149 | void CategoryCombo::setCurrentCategory( int newCatUid ) | 262 | void CategoryCombo::setCurrentCategory( int newCatUid ) |
150 | { | 263 | { |
151 | int i; | 264 | int i; |
152 | for ( i = 0; i < int(d->mAppCats.size()); i++ ) { | 265 | for ( i = 0; i < int(d->mAppCats.size()); i++ ) { |
153 | if ( d->mAppCats[i] == newCatUid ) | 266 | if ( d->mAppCats[i] == newCatUid ) |
154 | setCurrentItem( i ); | 267 | setCurrentItem( i ); |
155 | } | 268 | } |
156 | } | 269 | } |
157 | 270 | ||
158 | void CategoryCombo::setCurrentText( const QString &str ) | 271 | void CategoryCombo::setCurrentText( const QString &str ) |
159 | { | 272 | { |
160 | int i; | 273 | int i; |
161 | int stop; | 274 | int stop; |
162 | stop = count(); | 275 | stop = count(); |
163 | for ( i = 0; i < stop; i++ ) { | 276 | for ( i = 0; i < stop; i++ ) { |
164 | if ( text( i ) == str ) { | 277 | if ( text( i ) == str ) { |
165 | setCurrentItem( i ); | 278 | setCurrentItem( i ); |
166 | break; | 279 | break; |
167 | } | 280 | } |
168 | } | 281 | } |
169 | } | 282 | } |
170 | 283 | ||
171 | void CategoryCombo::slotValueChanged( int ) | 284 | void CategoryCombo::slotValueChanged( int ) |
172 | { | 285 | { |
173 | emit sigCatChanged( currentCategory() ); | 286 | emit sigCatChanged( currentCategory() ); |
174 | } | 287 | } |
175 | 288 | ||
176 | CategorySelect::CategorySelect( QWidget *parent, const char *name ) | 289 | CategorySelect::CategorySelect( QWidget *parent, const char *name,int width) |
177 | : QHBox( parent, name ), | 290 | : QHBox( parent, name ), |
178 | cmbCat( 0 ), | 291 | cmbCat( 0 ), |
179 | cmdCat( 0 ), | 292 | cmdCat( 0 ), |
180 | d( 0 ) | 293 | d( 0 ) |
181 | { | 294 | { |
182 | d = new CategorySelectPrivate(); | 295 | d = new CategorySelectPrivate(); |
183 | init(); | 296 | init(width); |
184 | } | 297 | } |
185 | 298 | ||
186 | CategorySelect::CategorySelect( const QArray<int> &vl, | 299 | CategorySelect::CategorySelect( const QArray<int> &vl, |
187 | const QString &appName, QWidget *parent, | 300 | const QString &appName, QWidget *parent, |
188 | const char *name ) | 301 | const char *name ,int width) |
189 | : QHBox( parent, name ) | 302 | : QHBox( parent, name ) |
190 | { | 303 | { |
191 | d = new CategorySelectPrivate( vl ); | 304 | d = new CategorySelectPrivate( vl ); |
192 | init(); | 305 | |
306 | init(width); | ||
307 | |||
193 | setCategories( vl, appName, appName ); | 308 | setCategories( vl, appName, appName ); |
194 | } | 309 | } |
195 | 310 | ||
196 | CategorySelect::CategorySelect( const QArray<int> &vl, | 311 | CategorySelect::CategorySelect( const QArray<int> &vl, |
197 | const QString &appName, | 312 | const QString &appName, |
198 | const QString &visibleName, | 313 | const QString &visibleName, |
199 | QWidget *parent, const char *name ) | 314 | QWidget *parent, const char *name , int width) |
200 | : QHBox( parent, name ) | 315 | : QHBox( parent, name ) |
201 | { | 316 | { |
202 | d = new CategorySelectPrivate( vl ); | 317 | d = new CategorySelectPrivate( vl ); |
203 | init(); | 318 | init(width); |
204 | setCategories( vl, appName, visibleName ); | 319 | setCategories( vl, appName, visibleName ); |
205 | } | 320 | } |
206 | 321 | ||
207 | CategorySelect::~CategorySelect() | 322 | CategorySelect::~CategorySelect() |
208 | { | 323 | { |
209 | delete d; | 324 | delete d; |
210 | } | 325 | } |
211 | 326 | ||
212 | void CategorySelect::slotDialog() | 327 | void CategorySelect::slotDialog() |
213 | { | 328 | { |
329 | if (QFile::exists( categoryEdittingFileName() )){ | ||
330 | QMessageBox::warning(this,tr("Error"), | ||
331 | tr("Sorry, another application is\nediting categories.") ); | ||
332 | return; | ||
333 | } | ||
334 | |||
335 | QFile f( categoryEdittingFileName() ); | ||
336 | if ( !f.open( IO_WriteOnly) ){ | ||
337 | return; | ||
338 | } | ||
339 | |||
214 | QDialog editDlg( this, 0, TRUE ); | 340 | QDialog editDlg( this, 0, TRUE ); |
215 | editDlg.setCaption( tr("Edit Categories") ); | 341 | editDlg.setCaption( tr("Edit Categories") ); |
216 | QVBoxLayout *vb = new QVBoxLayout( &editDlg ); | 342 | QVBoxLayout *vb = new QVBoxLayout( &editDlg ); |
217 | QScrollView *sv = new QScrollView( &editDlg ); | 343 | QScrollView *sv = new QScrollView( &editDlg ); |
218 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 344 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
219 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); | 345 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); |
220 | vb->addWidget( sv ); | 346 | vb->addWidget( sv ); |
221 | CategoryWidget ce( d->mRec, mStrAppName, d->mVisibleName, &editDlg ); | 347 | CategoryWidget ce( d->mRec, mStrAppName, d->mVisibleName, &editDlg ); |
222 | sv->addChild( &ce ); | 348 | sv->addChild( &ce ); |
223 | editDlg.showMaximized(); | 349 | editDlg.showMaximized(); |
224 | 350 | ||
225 | if ( editDlg.exec() ) { | 351 | if ( editDlg.exec() ) { |
226 | d->mRec = ce.newCategories(); | 352 | d->mRec = ce.newCategories(); |
227 | cmbCat->initCombo( d->mRec, mStrAppName ); | 353 | cmbCat->initCombo( d->mRec, mStrAppName ); |
228 | } | 354 | } |
355 | |||
356 | f.close(); | ||
357 | QFile::remove( categoryEdittingFileName() ); | ||
229 | } | 358 | } |
230 | 359 | ||
231 | void CategorySelect::slotNewCat( int newUid ) | 360 | void CategorySelect::slotNewCat( int newUid ) |
232 | { | 361 | { |
233 | if ( newUid != -1 ) { | 362 | if ( newUid != -1 ) { |
234 | bool alreadyIn = false; | 363 | bool alreadyIn = false; |
235 | for ( uint it = 0; it < d->mRec.count(); ++it ) { | 364 | for ( uint it = 0; it < d->mRec.count(); ++it ) { |
236 | if ( d->mRec[it] == newUid ) { | 365 | if ( d->mRec[it] == newUid ) { |
237 | alreadyIn = true; | 366 | alreadyIn = true; |
238 | break; | 367 | break; |
239 | } | 368 | } |
240 | } | 369 | } |
241 | if ( !alreadyIn ) { | 370 | if ( !alreadyIn ) { |
242 | d->mRec.resize( 1 ); | 371 | d->mRec.resize( 1 ); |
243 | d->mRec[ 0 ] = newUid; | 372 | d->mRec[ 0 ] = newUid; |
244 | } | 373 | } |
245 | } else | 374 | } else |
246 | d->mRec.resize(0); // now Unfiled. | 375 | d->mRec.resize(0); // now Unfiled. |
247 | emit signalSelected( currentCategory() ); | 376 | emit signalSelected( currentCategory() ); |
248 | } | 377 | } |
249 | 378 | ||
250 | void CategorySelect::setCategories( const QArray<int> &rec, | 379 | QString CategorySelect::setCategories( const QArray<int> &rec, |
251 | const QString &appName ) | 380 | const QString &appName ) |
252 | { | 381 | { |
253 | setCategories( rec, appName, appName ); | 382 | return setCategories( rec, appName, appName ); |
254 | } | 383 | } |
255 | 384 | ||
256 | void CategorySelect::setCategories( const QArray<int> &rec, | 385 | QString CategorySelect::setCategories( const QArray<int> &rec, |
257 | const QString &appName, | 386 | const QString &appName, |
258 | const QString &visibleName ) | 387 | const QString &visibleName ) |
259 | { | 388 | { |
260 | d->mRec = rec; | ||
261 | d->mVisibleName = visibleName; | 389 | d->mVisibleName = visibleName; |
262 | mStrAppName = appName; | 390 | mStrAppName = appName; |
263 | cmbCat->initCombo( rec, appName ); | 391 | d->mRec = cmbCat->initComboWithRefind( rec, appName ); |
392 | return Qtopia::Record::idsToString(d->mRec); | ||
264 | } | 393 | } |
265 | 394 | ||
266 | void CategorySelect::init() | 395 | void CategorySelect::init(int width) |
267 | { | 396 | { |
268 | cmbCat = new CategoryCombo( this ); | 397 | cmbCat = new CategoryCombo( this, 0, width); |
398 | |||
269 | QObject::connect( cmbCat, SIGNAL(sigCatChanged(int)), | 399 | QObject::connect( cmbCat, SIGNAL(sigCatChanged(int)), |
270 | this, SLOT(slotNewCat(int)) ); | 400 | this, SLOT(slotNewCat(int)) ); |
271 | cmdCat = new QToolButton( this ); | 401 | cmdCat = new QToolButton( this ); |
272 | QObject::connect( cmdCat, SIGNAL(clicked()), this, SLOT(slotDialog()) ); | 402 | QObject::connect( cmdCat, SIGNAL(clicked()), this, SLOT(slotDialog()) ); |
273 | cmdCat->setTextLabel( "...", FALSE ); | 403 | cmdCat->setTextLabel( "...", FALSE ); |
274 | cmdCat->setUsesTextLabel( true ); | 404 | cmdCat->setUsesTextLabel( true ); |
275 | cmdCat->setMaximumSize( cmdCat->sizeHint() ); | 405 | cmdCat->setMaximumSize( cmdCat->sizeHint() ); |
276 | cmdCat->setFocusPolicy( TabFocus ); | 406 | cmdCat->setFocusPolicy( TabFocus ); |
277 | } | 407 | } |
278 | 408 | ||
279 | 409 | ||
280 | int CategorySelect::currentCategory() const | 410 | int CategorySelect::currentCategory() const |
281 | { | 411 | { |
282 | return cmbCat->currentCategory(); | 412 | return cmbCat->currentCategory(); |
283 | } | 413 | } |
284 | 414 | ||
285 | void CategorySelect::setCurrentCategory( int newCatUid ) | 415 | void CategorySelect::setCurrentCategory( int newCatUid ) |
286 | { | 416 | { |
287 | cmbCat->setCurrentCategory( newCatUid ); | 417 | cmbCat->setCurrentCategory( newCatUid ); |
288 | } | 418 | } |
289 | 419 | ||
290 | 420 | ||
291 | const QArray<int> &CategorySelect::currentCategories() const | 421 | const QArray<int> &CategorySelect::currentCategories() const |
292 | { | 422 | { |
293 | return d->mRec; | 423 | return d->mRec; |
294 | } | 424 | } |
295 | 425 | ||
296 | void CategorySelect::setRemoveCategoryEdit( bool remove ) | 426 | void CategorySelect::setRemoveCategoryEdit( bool remove ) |
297 | { | 427 | { |
298 | if ( remove ) { | 428 | if ( remove ) { |
299 | cmdCat->setEnabled( FALSE ); | 429 | cmdCat->setEnabled( FALSE ); |
300 | cmdCat->hide(); | 430 | cmdCat->hide(); |
301 | } else { | 431 | } else { |
302 | cmdCat->setEnabled( TRUE ); | 432 | cmdCat->setEnabled( TRUE ); |
303 | cmdCat->show(); | 433 | cmdCat->show(); |
304 | } | 434 | } |
305 | } | 435 | } |
306 | 436 | ||
307 | void CategorySelect::setAllCategories( bool add ) | 437 | void CategorySelect::setAllCategories( bool add ) |
308 | { | 438 | { |
309 | d->usingAll = add; | 439 | d->usingAll = add; |
310 | if ( add ) { | 440 | if ( add ) { |
311 | cmbCat->insertItem( tr( "All" ), cmbCat->count() ); | 441 | cmbCat->insertItem( tr( "All" ), cmbCat->count() ); |
312 | cmbCat->setCurrentItem( cmbCat->count() - 1 ); | 442 | cmbCat->setCurrentItem( cmbCat->count() - 1 ); |
313 | } else | 443 | } else |
314 | cmbCat->removeItem( cmbCat->count() - 1 ); | 444 | cmbCat->removeItem( cmbCat->count() - 1 ); |
315 | } | 445 | } |
446 | |||
447 | // 01.12.21 added | ||
448 | void CategorySelect::setFixedWidth(int width) | ||
449 | { | ||
450 | width -= cmdCat->width(); | ||
451 | cmbCat->setFixedWidth(width); | ||
452 | } | ||