author | mickeyl <mickeyl> | 2004-04-23 13:44:25 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-04-23 13:44:25 (UTC) |
commit | 8e32516bbda3fda10314f2afe4ee00eb9a49c013 (patch) (unidiff) | |
tree | 598226dff8f623159b7bec675ae95c463bb711a5 | |
parent | 25f3f2fe15578fd4deb04a951e3e23927977e032 (diff) | |
download | opie-8e32516bbda3fda10314f2afe4ee00eb9a49c013.zip opie-8e32516bbda3fda10314f2afe4ee00eb9a49c013.tar.gz opie-8e32516bbda3fda10314f2afe4ee00eb9a49c013.tar.bz2 |
gcc3.4 fixlet
-rw-r--r-- | noncore/apps/checkbook/listedit.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/apps/checkbook/listedit.cpp b/noncore/apps/checkbook/listedit.cpp index 5026c9d..2612488 100644 --- a/noncore/apps/checkbook/listedit.cpp +++ b/noncore/apps/checkbook/listedit.cpp | |||
@@ -1,349 +1,349 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | =. | 3 | =. |
4 | .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> | 4 | .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This file is free software; you can | 6 | _;:, .> :=|. This file is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This file is distributed in the hope that | 13 | .i_,=:_. -<s. This file is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
18 | ..}^=.= = ; Public License for more details. | 18 | ..}^=.= = ; Public License for more details. |
19 | ++= -. .` .: | 19 | ++= -. .` .: |
20 | : = ...= . :.=- You should have received a copy of the GNU | 20 | : = ...= . :.=- You should have received a copy of the GNU |
21 | -. .:....=;==+<; General Public License along with this file; | 21 | -. .:....=;==+<; General Public License along with this file; |
22 | -_. . . )=. = see the file COPYING. If not, write to the | 22 | -_. . . )=. = see the file COPYING. If not, write to the |
23 | -- :-=` Free Software Foundation, Inc., | 23 | -- :-=` Free Software Foundation, Inc., |
24 | 59 Temple Place - Suite 330, | 24 | 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "listedit.h" | 29 | #include "listedit.h" |
30 | 30 | ||
31 | /* OPIE */ | 31 | /* OPIE */ |
32 | #include <opie2/odebug.h> | 32 | #include <opie2/odebug.h> |
33 | #include <qpe/resource.h> | 33 | #include <qpe/resource.h> |
34 | using namespace Opie::Core; | 34 | using namespace Opie::Core; |
35 | 35 | ||
36 | /* QT */ | 36 | /* QT */ |
37 | #include <qlayout.h> | 37 | #include <qlayout.h> |
38 | #include <qlineedit.h> | 38 | #include <qlineedit.h> |
39 | #include <qlistview.h> | 39 | #include <qlistview.h> |
40 | #include <qwidgetstack.h> | 40 | #include <qwidgetstack.h> |
41 | #include <qcombobox.h> | 41 | #include <qcombobox.h> |
42 | #include <qpushbutton.h> | 42 | #include <qpushbutton.h> |
43 | 43 | ||
44 | // --- ListEdit --------------------------------------------------------------- | 44 | // --- ListEdit --------------------------------------------------------------- |
45 | ListEdit::ListEdit( QWidget *parent, const char *sName ) | 45 | ListEdit::ListEdit( QWidget *parent, const char *sName ) |
46 | : QWidget(parent, sName), TableDef(sName) | 46 | : QWidget(parent, sName), TableDef(sName) |
47 | { | 47 | { |
48 | // get font height | 48 | // get font height |
49 | int fh = fontMetrics().height(); | 49 | int fh = fontMetrics().height(); |
50 | 50 | ||
51 | // create layout | 51 | // create layout |
52 | QGridLayout *layout=new QGridLayout(this); | 52 | QGridLayout *layout=new QGridLayout(this); |
53 | layout->setSpacing( 2 ); | 53 | layout->setSpacing( 2 ); |
54 | layout->setMargin( 4 ); | 54 | layout->setMargin( 4 ); |
55 | 55 | ||
56 | // type table | 56 | // type table |
57 | _typeTable = new QListView( this ); | 57 | _typeTable = new QListView( this ); |
58 | ColumnDef *def=first(); | 58 | ColumnDef *def=first(); |
59 | while( def ) { | 59 | while( def ) { |
60 | _typeTable->addColumn( def->getName() ); | 60 | _typeTable->addColumn( def->getName() ); |
61 | def=next(); | 61 | def=next(); |
62 | } | 62 | } |
63 | connect( _typeTable, SIGNAL( clicked(QListViewItem*,const QPoint&,int) ), this, SLOT( slotClick(QListViewItem*,const QPoint&,int) ) ); | 63 | connect( _typeTable, SIGNAL( clicked(QListViewItem*,const QPoint&,int) ), this, SLOT( slotClick(QListViewItem*,const QPoint&,int) ) ); |
64 | layout->addMultiCellWidget(_typeTable, 0,4,0,4); | 64 | layout->addMultiCellWidget(_typeTable, 0,4,0,4); |
65 | _currentItem=NULL; | 65 | _currentItem=NULL; |
66 | 66 | ||
67 | // edit field | 67 | // edit field |
68 | _stack=new QWidgetStack( this ); | 68 | _stack=new QWidgetStack( this ); |
69 | _stack->setMaximumHeight(fh+5); | 69 | _stack->setMaximumHeight(fh+5); |
70 | layout->addMultiCellWidget(_stack, 5,5,0,2); | 70 | layout->addMultiCellWidget(_stack, 5,5,0,2); |
71 | _typeEdit = new QLineEdit( _stack ); | 71 | _typeEdit = new QLineEdit( _stack ); |
72 | _stack->raiseWidget(_typeEdit ); | 72 | _stack->raiseWidget(_typeEdit ); |
73 | connect( _typeEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( slotEditChanged(const QString&) ) ); | 73 | connect( _typeEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( slotEditChanged(const QString&) ) ); |
74 | 74 | ||
75 | // combo box | 75 | // combo box |
76 | _box=new QComboBox( _stack ); | 76 | _box=new QComboBox( _stack ); |
77 | connect( _box, SIGNAL( activated(const QString&) ), this, SLOT( slotActivated(const QString&) ) ); | 77 | connect( _box, SIGNAL( activated(const QString&) ), this, SLOT( slotActivated(const QString&) ) ); |
78 | 78 | ||
79 | 79 | ||
80 | // add button | 80 | // add button |
81 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/add" ), tr( "Add" ), this ); | 81 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/add" ), tr( "Add" ), this ); |
82 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotAdd() ) ); | 82 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotAdd() ) ); |
83 | layout->addWidget( btn, 5, 3 ); | 83 | layout->addWidget( btn, 5, 3 ); |
84 | 84 | ||
85 | // delete button | 85 | // delete button |
86 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), this ); | 86 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), this ); |
87 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDel() ) ); | 87 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDel() ) ); |
88 | layout->addWidget( btn, 5, 4 ); | 88 | layout->addWidget( btn, 5, 4 ); |
89 | } | 89 | } |
90 | 90 | ||
91 | // --- ~ListEdit -------------------------------------------------------------- | 91 | // --- ~ListEdit -------------------------------------------------------------- |
92 | ListEdit::~ListEdit() | 92 | ListEdit::~ListEdit() |
93 | { | 93 | { |
94 | } | 94 | } |
95 | 95 | ||
96 | 96 | ||
97 | // --- slotEditTypeChanged ---------------------------------------------------- | 97 | // --- slotEditTypeChanged ---------------------------------------------------- |
98 | void ListEdit::slotEditChanged(const QString &str) | 98 | void ListEdit::slotEditChanged(const QString &str) |
99 | { | 99 | { |
100 | if( !_currentItem || _currentColumn<0 ) return; | 100 | if( !_currentItem || _currentColumn<0 ) return; |
101 | _currentItem->setText(_currentColumn, str); | 101 | _currentItem->setText(_currentColumn, str); |
102 | } | 102 | } |
103 | 103 | ||
104 | // --- slotAddType ------------------------------------------------------------ | 104 | // --- slotAddType ------------------------------------------------------------ |
105 | void ListEdit::slotAdd() | 105 | void ListEdit::slotAdd() |
106 | { | 106 | { |
107 | // construct new row | 107 | // construct new row |
108 | QString args[8]; | 108 | QString args[8]; |
109 | ColumnDef *pCol=this->first(); | 109 | ColumnDef *pCol=this->first(); |
110 | int i=0; | 110 | int i=0; |
111 | while( pCol && i<8 ) { | 111 | while( pCol && i<8 ) { |
112 | args[i++]=pCol->getNewValue(); | 112 | args[i++]=pCol->getNewValue(); |
113 | pCol=this->next(); | 113 | pCol=this->next(); |
114 | } | 114 | } |
115 | _currentItem=new QListViewItem(_typeTable, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7] ); | 115 | _currentItem=new QListViewItem(_typeTable, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7] ); |
116 | 116 | ||
117 | // fix uniques | 117 | // fix uniques |
118 | fixTypes(); | 118 | fixTypes(); |
119 | 119 | ||
120 | // display col 0 of new value | 120 | // display col 0 of new value |
121 | QPoint pnt; | 121 | QPoint pnt; |
122 | slotClick(_currentItem, pnt, 0); | 122 | slotClick(_currentItem, pnt, 0); |
123 | _typeTable->setSelected( _currentItem, true ); | 123 | _typeTable->setSelected( _currentItem, true ); |
124 | 124 | ||
125 | // make it selected | 125 | // make it selected |
126 | _typeEdit->setCursorPosition(0); | 126 | _typeEdit->setCursorPosition(0); |
127 | _typeEdit->setSelection(0, _typeEdit->text().length() ); | 127 | _typeEdit->setSelection(0, _typeEdit->text().length() ); |
128 | } | 128 | } |
129 | 129 | ||
130 | // --- slotDel ------------------------------------------------------------- | 130 | // --- slotDel ------------------------------------------------------------- |
131 | void ListEdit::slotDel() | 131 | void ListEdit::slotDel() |
132 | { | 132 | { |
133 | if( !_currentItem ) return; | 133 | if( !_currentItem ) return; |
134 | delete _currentItem; | 134 | delete _currentItem; |
135 | _currentItem=NULL; | 135 | _currentItem=NULL; |
136 | _typeEdit->setText(""); | 136 | _typeEdit->setText(""); |
137 | _stack->raiseWidget(_typeEdit); | 137 | _stack->raiseWidget(_typeEdit); |
138 | } | 138 | } |
139 | 139 | ||
140 | 140 | ||
141 | // --- fixTypes ---------------------------------------------------------------- | 141 | // --- fixTypes ---------------------------------------------------------------- |
142 | // Makes sure all entries have a unique name and empty entries are replaced | 142 | // Makes sure all entries have a unique name and empty entries are replaced |
143 | // by a generic string. The first version performs the operation on a particular | 143 | // by a generic string. The first version performs the operation on a particular |
144 | // column, whereas the 2nd does it for all unique columns. | 144 | // column, whereas the 2nd does it for all unique columns. |
145 | class ColMap { | 145 | class ColMap { |
146 | public: | 146 | public: |
147 | ColMap(QString sValue, QListViewItem *pEntry) { | 147 | ColMap(QString sValue, QListViewItem *pEntry) { |
148 | _sValue=sValue; | 148 | _sValue=sValue; |
149 | _pEntry=pEntry; | 149 | _pEntry=pEntry; |
150 | } | 150 | } |
151 | QString &getValue() { return(_sValue); } | 151 | QString &getValue() { return(_sValue); } |
152 | QListViewItem *getItem() { return(_pEntry); } | 152 | QListViewItem *getItem() { return(_pEntry); } |
153 | 153 | ||
154 | protected: | 154 | protected: |
155 | QString _sValue; | 155 | QString _sValue; |
156 | QListViewItem *_pEntry; | 156 | QListViewItem *_pEntry; |
157 | }; | 157 | }; |
158 | 158 | ||
159 | class ColList : public QList<QString> | 159 | class ColList : public QList<QString> |
160 | { | 160 | { |
161 | public: | 161 | public: |
162 | ColList() : QList<QString>() { } | 162 | ColList() : QList<QString>() { } |
163 | 163 | ||
164 | protected: | 164 | protected: |
165 | int compareItems(QCollection::Item, QCollection::Item); | 165 | int compareItems(QCollection::Item, QCollection::Item); |
166 | }; | 166 | }; |
167 | 167 | ||
168 | int ColList::compareItems(QCollection::Item i1, QCollection::Item i2) { | 168 | int ColList::compareItems(QCollection::Item i1, QCollection::Item i2) { |
169 | return( ((QString *)i1)->compare(*(QString *)i2) ); | 169 | return( ((QString *)i1)->compare(*(QString *)i2) ); |
170 | } | 170 | } |
171 | 171 | ||
172 | void ListEdit::fixTypes(int iColumn) | 172 | void ListEdit::fixTypes(int iColumn) |
173 | { | 173 | { |
174 | // get column def | 174 | // get column def |
175 | ColumnDef *pDef=this->at(iColumn); | 175 | ColumnDef *pDef=this->at(iColumn); |
176 | 176 | ||
177 | // create map of entries | 177 | // create map of entries |
178 | if( !_typeTable->childCount() ) return; | 178 | if( !_typeTable->childCount() ) return; |
179 | ColMap **colMap=new (ColMap *)[_typeTable->childCount()]; | 179 | ColMap **colMap=new ColMap *[_typeTable->childCount()]; |
180 | QListViewItem *cur=_typeTable->firstChild(); | 180 | QListViewItem *cur=_typeTable->firstChild(); |
181 | ColList lst; | 181 | ColList lst; |
182 | for(int i=0; i<_typeTable->childCount(); i++) { | 182 | for(int i=0; i<_typeTable->childCount(); i++) { |
183 | colMap[i]=new ColMap(cur->text(iColumn), cur); | 183 | colMap[i]=new ColMap(cur->text(iColumn), cur); |
184 | lst.append( &(colMap[i]->getValue()) ); | 184 | lst.append( &(colMap[i]->getValue()) ); |
185 | cur=cur->nextSibling(); | 185 | cur=cur->nextSibling(); |
186 | } | 186 | } |
187 | 187 | ||
188 | // fix empty entries | 188 | // fix empty entries |
189 | int i=0; | 189 | int i=0; |
190 | for(QString *ptr=lst.first(); ptr; ptr=lst.next()) { | 190 | for(QString *ptr=lst.first(); ptr; ptr=lst.next()) { |
191 | *ptr=ptr->stripWhiteSpace(); | 191 | *ptr=ptr->stripWhiteSpace(); |
192 | if( ptr->isEmpty() ) { | 192 | if( ptr->isEmpty() ) { |
193 | i++; | 193 | i++; |
194 | if( i==1 ) *ptr=pDef->getNewValue(); | 194 | if( i==1 ) *ptr=pDef->getNewValue(); |
195 | else ptr->sprintf("%s %d", (const char *)pDef->getNewValue(), i); | 195 | else ptr->sprintf("%s %d", (const char *)pDef->getNewValue(), i); |
196 | } | 196 | } |
197 | } | 197 | } |
198 | 198 | ||
199 | // fix dups | 199 | // fix dups |
200 | lst.sort(); | 200 | lst.sort(); |
201 | QString repl; | 201 | QString repl; |
202 | for(uint iCur=0; iCur<lst.count()-1; iCur++) { | 202 | for(uint iCur=0; iCur<lst.count()-1; iCur++) { |
203 | QString *current=lst.at(iCur); | 203 | QString *current=lst.at(iCur); |
204 | for(uint iNext=iCur+1; iNext<lst.count(); iNext++ ) { | 204 | for(uint iNext=iCur+1; iNext<lst.count(); iNext++ ) { |
205 | if( *current!=*lst.at(iNext) ) continue; | 205 | if( *current!=*lst.at(iNext) ) continue; |
206 | for(int i=2; ; i++) { | 206 | for(int i=2; ; i++) { |
207 | repl.sprintf("%s %d", (const char *)*current, i); | 207 | repl.sprintf("%s %d", (const char *)*current, i); |
208 | bool bDup=false; | 208 | bool bDup=false; |
209 | uint iChk=iNext+1; | 209 | uint iChk=iNext+1; |
210 | while( iChk<lst.count() ) { | 210 | while( iChk<lst.count() ) { |
211 | QString *chk=lst.at(iChk); | 211 | QString *chk=lst.at(iChk); |
212 | if( !chk->startsWith(*current) ) break; | 212 | if( !chk->startsWith(*current) ) break; |
213 | if( *chk==repl ) { | 213 | if( *chk==repl ) { |
214 | bDup=true; | 214 | bDup=true; |
215 | break; | 215 | break; |
216 | } | 216 | } |
217 | iChk++; | 217 | iChk++; |
218 | } | 218 | } |
219 | if( !bDup ) { | 219 | if( !bDup ) { |
220 | *lst.at(iNext)=repl; | 220 | *lst.at(iNext)=repl; |
221 | break; | 221 | break; |
222 | } | 222 | } |
223 | } | 223 | } |
224 | } | 224 | } |
225 | } | 225 | } |
226 | lst.sort(); | 226 | lst.sort(); |
227 | 227 | ||
228 | // copy back clean up col map | 228 | // copy back clean up col map |
229 | for(int i=0; i<_typeTable->childCount(); i++) { | 229 | for(int i=0; i<_typeTable->childCount(); i++) { |
230 | colMap[i]->getItem()->setText(iColumn, colMap[i]->getValue()); | 230 | colMap[i]->getItem()->setText(iColumn, colMap[i]->getValue()); |
231 | delete colMap[i]; | 231 | delete colMap[i]; |
232 | } | 232 | } |
233 | delete colMap; | 233 | delete colMap; |
234 | } | 234 | } |
235 | 235 | ||
236 | void ListEdit::fixTypes() | 236 | void ListEdit::fixTypes() |
237 | { | 237 | { |
238 | int i; | 238 | int i; |
239 | ColumnDef *pDef; | 239 | ColumnDef *pDef; |
240 | for(pDef=this->first(), i=0; pDef; pDef=this->next(), i++) { | 240 | for(pDef=this->first(), i=0; pDef; pDef=this->next(), i++) { |
241 | if( pDef->hasFlag(ColumnDef::typeUnique) ) | 241 | if( pDef->hasFlag(ColumnDef::typeUnique) ) |
242 | fixTypes(i); | 242 | fixTypes(i); |
243 | } | 243 | } |
244 | _typeTable->sort(); | 244 | _typeTable->sort(); |
245 | } | 245 | } |
246 | 246 | ||
247 | 247 | ||
248 | // --- storeInList ------------------------------------------------------------ | 248 | // --- storeInList ------------------------------------------------------------ |
249 | void ListEdit::storeInList(QStringList &lst) | 249 | void ListEdit::storeInList(QStringList &lst) |
250 | { | 250 | { |
251 | // delete old content | 251 | // delete old content |
252 | lst.clear(); | 252 | lst.clear(); |
253 | 253 | ||
254 | // add new one | 254 | // add new one |
255 | fixTypes(); | 255 | fixTypes(); |
256 | QListViewItem *itm=_typeTable->firstChild(); | 256 | QListViewItem *itm=_typeTable->firstChild(); |
257 | while( itm ) { | 257 | while( itm ) { |
258 | int i=0; | 258 | int i=0; |
259 | QString sAdd; | 259 | QString sAdd; |
260 | ColumnDef *pDef; | 260 | ColumnDef *pDef; |
261 | for(pDef=this->first(), i=0; pDef; pDef=this->next(), i++) { | 261 | for(pDef=this->first(), i=0; pDef; pDef=this->next(), i++) { |
262 | if( i>=1 ) sAdd+=";"; | 262 | if( i>=1 ) sAdd+=";"; |
263 | sAdd += itm->text(i); | 263 | sAdd += itm->text(i); |
264 | } | 264 | } |
265 | lst.append( sAdd ); | 265 | lst.append( sAdd ); |
266 | itm=itm->nextSibling(); | 266 | itm=itm->nextSibling(); |
267 | } | 267 | } |
268 | } | 268 | } |
269 | 269 | ||
270 | 270 | ||
271 | // --- slotClicked ------------------------------------------------------------ | 271 | // --- slotClicked ------------------------------------------------------------ |
272 | void ListEdit::slotClick(QListViewItem *itm, const QPoint &pnt, int col) | 272 | void ListEdit::slotClick(QListViewItem *itm, const QPoint &pnt, int col) |
273 | { | 273 | { |
274 | (void)pnt; // get rid of unused warning; | 274 | (void)pnt; // get rid of unused warning; |
275 | 275 | ||
276 | // save values | 276 | // save values |
277 | _currentItem=itm; | 277 | _currentItem=itm; |
278 | _currentColumn=col; | 278 | _currentColumn=col; |
279 | if( itm==NULL ) { | 279 | if( itm==NULL ) { |
280 | _typeEdit->setText(""); | 280 | _typeEdit->setText(""); |
281 | _stack->raiseWidget(_typeEdit); | 281 | _stack->raiseWidget(_typeEdit); |
282 | return; | 282 | return; |
283 | } | 283 | } |
284 | 284 | ||
285 | // display value | 285 | // display value |
286 | if( _currentColumn<0 ) _currentColumn=0; | 286 | if( _currentColumn<0 ) _currentColumn=0; |
287 | ColumnDef *pDef=this->at(_currentColumn); | 287 | ColumnDef *pDef=this->at(_currentColumn); |
288 | if( pDef->isType(ColumnDef::typeString) ) { | 288 | if( pDef->isType(ColumnDef::typeString) ) { |
289 | _typeEdit->setText( _currentItem->text(_currentColumn) ); | 289 | _typeEdit->setText( _currentItem->text(_currentColumn) ); |
290 | _stack->raiseWidget(_typeEdit); | 290 | _stack->raiseWidget(_typeEdit); |
291 | } else if( pDef->isType(ColumnDef::typeList) ){ | 291 | } else if( pDef->isType(ColumnDef::typeList) ){ |
292 | _box->clear(); | 292 | _box->clear(); |
293 | _box->insertStringList( pDef->getValueList() ); | 293 | _box->insertStringList( pDef->getValueList() ); |
294 | QStringList::Iterator itr; | 294 | QStringList::Iterator itr; |
295 | int i=0; | 295 | int i=0; |
296 | for(itr=pDef->getValueList().begin(); itr!=pDef->getValueList().end(); itr++) { | 296 | for(itr=pDef->getValueList().begin(); itr!=pDef->getValueList().end(); itr++) { |
297 | if( (*itr)==_currentItem->text(_currentColumn) ) { | 297 | if( (*itr)==_currentItem->text(_currentColumn) ) { |
298 | _box->setCurrentItem(i); | 298 | _box->setCurrentItem(i); |
299 | i=-1; | 299 | i=-1; |
300 | break; | 300 | break; |
301 | } | 301 | } |
302 | i++; | 302 | i++; |
303 | } | 303 | } |
304 | if( i>=0 ) { | 304 | if( i>=0 ) { |
305 | _box->insertItem( _currentItem->text(_currentColumn) ); | 305 | _box->insertItem( _currentItem->text(_currentColumn) ); |
306 | _box->setCurrentItem(i); | 306 | _box->setCurrentItem(i); |
307 | } | 307 | } |
308 | _stack->raiseWidget(_box); | 308 | _stack->raiseWidget(_box); |
309 | } else { | 309 | } else { |
310 | odebug << "Unsupported column type for column " << (const char *)pDef->getName() << "" << oendl; | 310 | odebug << "Unsupported column type for column " << (const char *)pDef->getName() << "" << oendl; |
311 | _typeEdit->setText(""); | 311 | _typeEdit->setText(""); |
312 | _stack->raiseWidget(_typeEdit); | 312 | _stack->raiseWidget(_typeEdit); |
313 | } | 313 | } |
314 | } | 314 | } |
315 | 315 | ||
316 | 316 | ||
317 | // --- addColumnDef ----------------------------------------------------------- | 317 | // --- addColumnDef ----------------------------------------------------------- |
318 | void ListEdit::addColumnDef(ColumnDef *pDef) | 318 | void ListEdit::addColumnDef(ColumnDef *pDef) |
319 | { | 319 | { |
320 | _typeTable->addColumn( pDef->getName() ); | 320 | _typeTable->addColumn( pDef->getName() ); |
321 | _vColumns.append(pDef); | 321 | _vColumns.append(pDef); |
322 | } | 322 | } |
323 | 323 | ||
324 | // --- addData ---------------------------------------------------------------- | 324 | // --- addData ---------------------------------------------------------------- |
325 | void ListEdit::addData(QStringList &lst) | 325 | void ListEdit::addData(QStringList &lst) |
326 | { | 326 | { |
327 | // run through list | 327 | // run through list |
328 | QStringList::Iterator itr; | 328 | QStringList::Iterator itr; |
329 | for(itr=lst.begin(); itr!=lst.end(); itr++) { | 329 | for(itr=lst.begin(); itr!=lst.end(); itr++) { |
330 | QStringList split=QStringList::split(";", *itr, true); | 330 | QStringList split=QStringList::split(";", *itr, true); |
331 | QStringList::Iterator entry; | 331 | QStringList::Iterator entry; |
332 | QString args[8]; | 332 | QString args[8]; |
333 | int i=0; | 333 | int i=0; |
334 | for(entry=split.begin(); entry!=split.end() && i<8; entry++, i++) { | 334 | for(entry=split.begin(); entry!=split.end() && i<8; entry++, i++) { |
335 | args[i]= (*entry); | 335 | args[i]= (*entry); |
336 | } | 336 | } |
337 | while(i<8) { | 337 | while(i<8) { |
338 | args[i++]=""; | 338 | args[i++]=""; |
339 | } | 339 | } |
340 | new QListViewItem(_typeTable, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]); | 340 | new QListViewItem(_typeTable, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]); |
341 | } | 341 | } |
342 | } | 342 | } |
343 | 343 | ||
344 | // --- slotActivated ---------------------------------------------------------- | 344 | // --- slotActivated ---------------------------------------------------------- |
345 | void ListEdit::slotActivated(const QString &str) | 345 | void ListEdit::slotActivated(const QString &str) |
346 | { | 346 | { |
347 | if( _currentItem==NULL || _currentColumn<0 ) return; | 347 | if( _currentItem==NULL || _currentColumn<0 ) return; |
348 | _currentItem->setText(_currentColumn, str); | 348 | _currentItem->setText(_currentColumn, str); |
349 | } | 349 | } |