author | tille <tille> | 2002-05-01 16:14:36 (UTC) |
---|---|---|
committer | tille <tille> | 2002-05-01 16:14:36 (UTC) |
commit | da12e60078563ef6e10ddcc1edeb931f765b8b6d (patch) (unidiff) | |
tree | 0d6cfec0cf3de34568f02de41582bc84e962e12d | |
parent | da94bce203afca412336a7793ff8e58e18d59108 (diff) | |
download | opie-da12e60078563ef6e10ddcc1edeb931f765b8b6d.zip opie-da12e60078563ef6e10ddcc1edeb931f765b8b6d.tar.gz opie-da12e60078563ef6e10ddcc1edeb931f765b8b6d.tar.bz2 |
more fields in detailed view
-rw-r--r-- | noncore/unsupported/oipkg/TODO | 1 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/package.cpp | 5 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/package.h | 1 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/packagelistitem.cpp | 9 |
4 files changed, 14 insertions, 2 deletions
diff --git a/noncore/unsupported/oipkg/TODO b/noncore/unsupported/oipkg/TODO index fc2e8a4..9d9a650 100644 --- a/noncore/unsupported/oipkg/TODO +++ b/noncore/unsupported/oipkg/TODO | |||
@@ -1,14 +1,13 @@ | |||
1 | * Settings Class | 1 | * Settings Class |
2 | * tr() ;) | 2 | * tr() ;) |
3 | * Dialog to display ipkg output live | 3 | * Dialog to display ipkg output live |
4 | * parse "to install" and "to remove" from status | 4 | * parse "to install" and "to remove" from status |
5 | * install local file dialog | 5 | * install local file dialog |
6 | * qcop | 6 | * qcop |
7 | * error handling | 7 | * error handling |
8 | * manage links | 8 | * manage links |
9 | * dependency checking | 9 | * dependency checking |
10 | * create dest if it does not exist | 10 | * create dest if it does not exist |
11 | * allow reinstalling | 11 | * allow reinstalling |
12 | * handle different versions | ||
13 | * different types of filters and searches | 12 | * different types of filters and searches |
14 | i.e. name, desc, files etc \ No newline at end of file | 13 | i.e. name, desc, files etc \ No newline at end of file |
diff --git a/noncore/unsupported/oipkg/package.cpp b/noncore/unsupported/oipkg/package.cpp index 0787ece..f992641 100644 --- a/noncore/unsupported/oipkg/package.cpp +++ b/noncore/unsupported/oipkg/package.cpp | |||
@@ -172,192 +172,197 @@ QString Package::sizeUnits() | |||
172 | c++; | 172 | c++; |
173 | i /= 1024; | 173 | i /= 1024; |
174 | } | 174 | } |
175 | return ret; | 175 | return ret; |
176 | } | 176 | } |
177 | 177 | ||
178 | bool Package::toProcess() | 178 | bool Package::toProcess() |
179 | { | 179 | { |
180 | return _toProcess; | 180 | return _toProcess; |
181 | } | 181 | } |
182 | 182 | ||
183 | bool Package::toRemove() | 183 | bool Package::toRemove() |
184 | { | 184 | { |
185 | if ( _toProcess && installed() ) return true; | 185 | if ( _toProcess && installed() ) return true; |
186 | else return false; | 186 | else return false; |
187 | } | 187 | } |
188 | 188 | ||
189 | bool Package::toInstall() | 189 | bool Package::toInstall() |
190 | { | 190 | { |
191 | if ( _toProcess && !installed() ) return true; | 191 | if ( _toProcess && !installed() ) return true; |
192 | else return false; | 192 | else return false; |
193 | } | 193 | } |
194 | 194 | ||
195 | void Package::toggleProcess() | 195 | void Package::toggleProcess() |
196 | { | 196 | { |
197 | _toProcess = ! _toProcess; | 197 | _toProcess = ! _toProcess; |
198 | } | 198 | } |
199 | 199 | ||
200 | 200 | ||
201 | 201 | ||
202 | void Package::copyValues( Package* pack ) | 202 | void Package::copyValues( Package* pack ) |
203 | { | 203 | { |
204 | if (_size.isEmpty() && !pack->_size.isEmpty()) _size = QString( pack->_size ); | 204 | if (_size.isEmpty() && !pack->_size.isEmpty()) _size = QString( pack->_size ); |
205 | if (_section.isEmpty() && !pack->_section.isEmpty()) _section = QString( pack->_section ); | 205 | if (_section.isEmpty() && !pack->_section.isEmpty()) _section = QString( pack->_section ); |
206 | if (_subsection.isEmpty()&& !pack->_subsection.isEmpty()) _subsection = QString( pack->_subsection ); | 206 | if (_subsection.isEmpty()&& !pack->_subsection.isEmpty()) _subsection = QString( pack->_subsection ); |
207 | if (_shortDesc.isEmpty() && !pack->_shortDesc.isEmpty()) _shortDesc = QString( pack->_shortDesc ); | 207 | if (_shortDesc.isEmpty() && !pack->_shortDesc.isEmpty()) _shortDesc = QString( pack->_shortDesc ); |
208 | if (_desc.isEmpty() && !pack->_desc.isEmpty()) _desc = QString( pack->_desc ); | 208 | if (_desc.isEmpty() && !pack->_desc.isEmpty()) _desc = QString( pack->_desc ); |
209 | if (_name.isEmpty() && !pack->_name.isEmpty()) _name = QString( pack->_name ); | 209 | if (_name.isEmpty() && !pack->_name.isEmpty()) _name = QString( pack->_name ); |
210 | if (!installed() && _status.isEmpty() && !pack->_status.isEmpty()) _status = QString( pack->_status ); | 210 | if (!installed() && _status.isEmpty() && !pack->_status.isEmpty()) _status = QString( pack->_status ); |
211 | } | 211 | } |
212 | 212 | ||
213 | QString Package::section() | 213 | QString Package::section() |
214 | { | 214 | { |
215 | return _section; | 215 | return _section; |
216 | } | 216 | } |
217 | 217 | ||
218 | void Package::setSection( QString s) | 218 | void Package::setSection( QString s) |
219 | { | 219 | { |
220 | int i = s.find("/"); | 220 | int i = s.find("/"); |
221 | if ( i > 0 ) | 221 | if ( i > 0 ) |
222 | { | 222 | { |
223 | _section = s.left(i); | 223 | _section = s.left(i); |
224 | _subsection = s.mid(i+1); | 224 | _subsection = s.mid(i+1); |
225 | }else{ | 225 | }else{ |
226 | _section = s; | 226 | _section = s; |
227 | _subsection = ""; | 227 | _subsection = ""; |
228 | } | 228 | } |
229 | } | 229 | } |
230 | 230 | ||
231 | QString Package::subSection() | 231 | QString Package::subSection() |
232 | { | 232 | { |
233 | return _subsection; | 233 | return _subsection; |
234 | } | 234 | } |
235 | 235 | ||
236 | void Package::parsePackage( QStringList pack ) | 236 | void Package::parsePackage( QStringList pack ) |
237 | { | 237 | { |
238 | if ( pack.isEmpty() ) return; | 238 | if ( pack.isEmpty() ) return; |
239 | int count = pack.count(); | 239 | int count = pack.count(); |
240 | for( int i = 0; i < count; i++ ) | 240 | for( int i = 0; i < count; i++ ) |
241 | { | 241 | { |
242 | QString line = pack[i]; | 242 | QString line = pack[i]; |
243 | int sep = line.find( QRegExp(":[\t ]+") ); | 243 | int sep = line.find( QRegExp(":[\t ]+") ); |
244 | if ( sep >= 0 ) | 244 | if ( sep >= 0 ) |
245 | { | 245 | { |
246 | QString tag = line.left(sep); | 246 | QString tag = line.left(sep); |
247 | QString value = line.mid(sep+2).simplifyWhiteSpace(); | 247 | QString value = line.mid(sep+2).simplifyWhiteSpace(); |
248 | setValue( tag, value ); | 248 | setValue( tag, value ); |
249 | }else{ | 249 | }else{ |
250 | } | 250 | } |
251 | } | 251 | } |
252 | return; | 252 | return; |
253 | } | 253 | } |
254 | 254 | ||
255 | QString Package::details() | 255 | QString Package::details() |
256 | { | 256 | { |
257 | QString status; | 257 | QString status; |
258 | Process ipkg_status(QStringList() << "ipkg" << "info" << name() ); | 258 | Process ipkg_status(QStringList() << "ipkg" << "info" << name() ); |
259 | QString description; | 259 | QString description; |
260 | if ( ipkg_status.exec("",status) ) | 260 | if ( ipkg_status.exec("",status) ) |
261 | { | 261 | { |
262 | QStringList lines = QStringList::split('\n',status,TRUE); | 262 | QStringList lines = QStringList::split('\n',status,TRUE); |
263 | for (QStringList::Iterator it = lines.begin(); it!=lines.end(); ++it) { | 263 | for (QStringList::Iterator it = lines.begin(); it!=lines.end(); ++it) { |
264 | QString line = *it; | 264 | QString line = *it; |
265 | if ( line == " ." ) | 265 | if ( line == " ." ) |
266 | { | 266 | { |
267 | description.append("<p>"); | 267 | description.append("<p>"); |
268 | } else | 268 | } else |
269 | if ( line[0] == ' ' || line[0] == '\t' ) | 269 | if ( line[0] == ' ' || line[0] == '\t' ) |
270 | { | 270 | { |
271 | // continuation | 271 | // continuation |
272 | description.append(" "); | 272 | description.append(" "); |
273 | description.append(Qtopia::escapeString(line)); | 273 | description.append(Qtopia::escapeString(line)); |
274 | } else { | 274 | } else { |
275 | int sep = line.find(QRegExp(":[\t ]+")); | 275 | int sep = line.find(QRegExp(":[\t ]+")); |
276 | if ( sep >= 0 ) | 276 | if ( sep >= 0 ) |
277 | { | 277 | { |
278 | QString tag = line.left(sep); | 278 | QString tag = line.left(sep); |
279 | description.append("<br>"); | 279 | description.append("<br>"); |
280 | description.append("<b>"); | 280 | description.append("<b>"); |
281 | description.append(Qtopia::escapeString(tag)); | 281 | description.append(Qtopia::escapeString(tag)); |
282 | description.append(":</b> "); | 282 | description.append(":</b> "); |
283 | description.append(Qtopia::escapeString(line.mid(sep+2))); | 283 | description.append(Qtopia::escapeString(line.mid(sep+2))); |
284 | } else { | 284 | } else { |
285 | description.append(" "); | 285 | description.append(" "); |
286 | description.append(Qtopia::escapeString(line)); | 286 | description.append(Qtopia::escapeString(line)); |
287 | } | 287 | } |
288 | } | 288 | } |
289 | } | 289 | } |
290 | } | 290 | } |
291 | return description; | 291 | return description; |
292 | } | 292 | } |
293 | 293 | ||
294 | void Package::processed() | 294 | void Package::processed() |
295 | { | 295 | { |
296 | _toProcess = false; | 296 | _toProcess = false; |
297 | //hack, but we're not writing status anyway... | 297 | //hack, but we're not writing status anyway... |
298 | if ( installed() ) _status = "install"; | 298 | if ( installed() ) _status = "install"; |
299 | else _status = "installed"; | 299 | else _status = "installed"; |
300 | } | 300 | } |
301 | 301 | ||
302 | QString Package::dest() | 302 | QString Package::dest() |
303 | { | 303 | { |
304 | if ( installed()||(!installed() && _toProcess) ) | 304 | if ( installed()||(!installed() && _toProcess) ) |
305 | return _dest!=""?_dest:settings->getDestinationName(); | 305 | return _dest!=""?_dest:settings->getDestinationName(); |
306 | else return ""; | 306 | else return ""; |
307 | } | 307 | } |
308 | 308 | ||
309 | void Package::setDest( QString d ) | 309 | void Package::setDest( QString d ) |
310 | { | 310 | { |
311 | _dest = d; | 311 | _dest = d; |
312 | } | 312 | } |
313 | 313 | ||
314 | void Package::setOn() | 314 | void Package::setOn() |
315 | { | 315 | { |
316 | _toProcess = true; | 316 | _toProcess = true; |
317 | } | 317 | } |
318 | 318 | ||
319 | bool Package::link() | 319 | bool Package::link() |
320 | { | 320 | { |
321 | if ( _dest == "root" || (!installed() && !_toProcess) ) return false; | 321 | if ( _dest == "root" || (!installed() && !_toProcess) ) return false; |
322 | return _link; | 322 | return _link; |
323 | } | 323 | } |
324 | 324 | ||
325 | void Package::setLink(bool b) | 325 | void Package::setLink(bool b) |
326 | { | 326 | { |
327 | _link = b; | 327 | _link = b; |
328 | } | 328 | } |
329 | 329 | ||
330 | void Package::parseIpkgFile( QString file) | 330 | void Package::parseIpkgFile( QString file) |
331 | { | 331 | { |
332 | system("tar xzf "+file+" -C /tmp"); | 332 | system("tar xzf "+file+" -C /tmp"); |
333 | system("tar xzf /tmp/control.tar.gz -C /tmp"); | 333 | system("tar xzf /tmp/control.tar.gz -C /tmp"); |
334 | QFile f("/tmp/control"); | 334 | QFile f("/tmp/control"); |
335 | if ( f.open(IO_ReadOnly) ) | 335 | if ( f.open(IO_ReadOnly) ) |
336 | { | 336 | { |
337 | QTextStream t( &f ); | 337 | QTextStream t( &f ); |
338 | QStringList pack; | 338 | QStringList pack; |
339 | while ( !t.eof() ) | 339 | while ( !t.eof() ) |
340 | { | 340 | { |
341 | pack << t.readLine(); | 341 | pack << t.readLine(); |
342 | } | 342 | } |
343 | f.close(); | 343 | f.close(); |
344 | parsePackage( pack ); | 344 | parsePackage( pack ); |
345 | } | 345 | } |
346 | 346 | ||
347 | } | 347 | } |
348 | 348 | ||
349 | //QString Package::getPackageName() | 349 | //QString Package::getPackageName() |
350 | //{ | 350 | //{ |
351 | //if ( _packageName.isEmpty() ) return _name; | 351 | //if ( _packageName.isEmpty() ) return _name; |
352 | //else return _packageName; | 352 | //else return _packageName; |
353 | //} | 353 | //} |
354 | 354 | ||
355 | void Package::instalFromFile(bool iff) | 355 | void Package::instalFromFile(bool iff) |
356 | { | 356 | { |
357 | _useFileName = iff; | 357 | _useFileName = iff; |
358 | } | 358 | } |
359 | 359 | ||
360 | void Package::setName(QString n) | 360 | void Package::setName(QString n) |
361 | { | 361 | { |
362 | _displayName = n; | 362 | _displayName = n; |
363 | } | 363 | } |
364 | |||
365 | QDict<QString>* Package::getFields() | ||
366 | { | ||
367 | return &_values; | ||
368 | } | ||
diff --git a/noncore/unsupported/oipkg/package.h b/noncore/unsupported/oipkg/package.h index 2ca966d..fc725bc 100644 --- a/noncore/unsupported/oipkg/package.h +++ b/noncore/unsupported/oipkg/package.h | |||
@@ -1,77 +1,78 @@ | |||
1 | #ifndef PK_ITEM_H | 1 | #ifndef PK_ITEM_H |
2 | #define PK_ITEM_H | 2 | #define PK_ITEM_H |
3 | 3 | ||
4 | #include <qstring.h> | 4 | #include <qstring.h> |
5 | #include <qlistview.h> | 5 | #include <qlistview.h> |
6 | #include <qpainter.h> | 6 | #include <qpainter.h> |
7 | #include <qpixmap.h> | 7 | #include <qpixmap.h> |
8 | #include <qdict.h> | 8 | #include <qdict.h> |
9 | #include <qobject.h> | 9 | #include <qobject.h> |
10 | 10 | ||
11 | #include "pksettings.h" | 11 | #include "pksettings.h" |
12 | 12 | ||
13 | class Package //: public QObject | 13 | class Package //: public QObject |
14 | { | 14 | { |
15 | // Q_OBJECT | 15 | // Q_OBJECT |
16 | public: | 16 | public: |
17 | Package(PackageManagerSettings *); | 17 | Package(PackageManagerSettings *); |
18 | // ~Package(); | 18 | // ~Package(); |
19 | Package( QStringList, PackageManagerSettings * ); | 19 | Package( QStringList, PackageManagerSettings * ); |
20 | Package( QString, PackageManagerSettings * ); | 20 | Package( QString, PackageManagerSettings * ); |
21 | Package( Package* ); | 21 | Package( Package* ); |
22 | 22 | ||
23 | void setValue( QString, QString ); | 23 | void setValue( QString, QString ); |
24 | void copyValues( Package* ); | 24 | void copyValues( Package* ); |
25 | 25 | ||
26 | QString name() ; | 26 | QString name() ; |
27 | QString installName() ; | 27 | QString installName() ; |
28 | bool installed(); | 28 | bool installed(); |
29 | 29 | ||
30 | void setDesc( QString ); | 30 | void setDesc( QString ); |
31 | QString shortDesc(); | 31 | QString shortDesc(); |
32 | QString desc(); | 32 | QString desc(); |
33 | QString size(); | 33 | QString size(); |
34 | QString sizeUnits(); | 34 | QString sizeUnits(); |
35 | QString version(); | 35 | QString version(); |
36 | void setSection( QString ); | 36 | void setSection( QString ); |
37 | QString section(); | 37 | QString section(); |
38 | QString subSection(); | 38 | QString subSection(); |
39 | QString details(); | 39 | QString details(); |
40 | bool toProcess(); | 40 | bool toProcess(); |
41 | bool toInstall(); | 41 | bool toInstall(); |
42 | bool toRemove(); | 42 | bool toRemove(); |
43 | void processed(); | 43 | void processed(); |
44 | QString dest(); | 44 | QString dest(); |
45 | void setDest( QString d ); | 45 | void setDest( QString d ); |
46 | void setOn(); | 46 | void setOn(); |
47 | bool link(); | 47 | bool link(); |
48 | void setLink(bool); | 48 | void setLink(bool); |
49 | void parseIpkgFile( QString ); | 49 | void parseIpkgFile( QString ); |
50 | void instalFromFile(bool iff=true); | 50 | void instalFromFile(bool iff=true); |
51 | void setName(QString); | 51 | void setName(QString); |
52 | QDict<QString>* getFields(); | ||
52 | public slots: | 53 | public slots: |
53 | void toggleProcess(); | 54 | void toggleProcess(); |
54 | 55 | ||
55 | private: | 56 | private: |
56 | PackageManagerSettings *settings; | 57 | PackageManagerSettings *settings; |
57 | QString _displayName; | 58 | QString _displayName; |
58 | QString _name; | 59 | QString _name; |
59 | QString _fileName; | 60 | QString _fileName; |
60 | bool _toProcess; | 61 | bool _toProcess; |
61 | bool _link; | 62 | bool _link; |
62 | QString _status; | 63 | QString _status; |
63 | QString _size; | 64 | QString _size; |
64 | QString _section; | 65 | QString _section; |
65 | QString _subsection; | 66 | QString _subsection; |
66 | QString _shortDesc; | 67 | QString _shortDesc; |
67 | QString _desc; | 68 | QString _desc; |
68 | QString _version; | 69 | QString _version; |
69 | QString _dest; | 70 | QString _dest; |
70 | QDict<QString> _values; | 71 | QDict<QString> _values; |
71 | bool _useFileName; | 72 | bool _useFileName; |
72 | void parsePackage( QStringList ); | 73 | void parsePackage( QStringList ); |
73 | void init(PackageManagerSettings *); | 74 | void init(PackageManagerSettings *); |
74 | }; | 75 | }; |
75 | 76 | ||
76 | 77 | ||
77 | #endif | 78 | #endif |
diff --git a/noncore/unsupported/oipkg/packagelistitem.cpp b/noncore/unsupported/oipkg/packagelistitem.cpp index b7af9a6..2f81714 100644 --- a/noncore/unsupported/oipkg/packagelistitem.cpp +++ b/noncore/unsupported/oipkg/packagelistitem.cpp | |||
@@ -1,133 +1,140 @@ | |||
1 | #include "packagelistitem.h" | 1 | #include "packagelistitem.h" |
2 | 2 | ||
3 | #include <qpe/resource.h> | 3 | #include <qpe/resource.h> |
4 | #include <qobject.h> | 4 | #include <qobject.h> |
5 | 5 | ||
6 | #include "debug.h" | 6 | #include "debug.h" |
7 | 7 | ||
8 | static QPixmap *pm_uninstalled=0; | 8 | static QPixmap *pm_uninstalled=0; |
9 | static QPixmap *pm_installed=0; | 9 | static QPixmap *pm_installed=0; |
10 | static QPixmap *pm_uninstall=0; | 10 | static QPixmap *pm_uninstall=0; |
11 | static QPixmap *pm_install=0; | 11 | static QPixmap *pm_install=0; |
12 | 12 | ||
13 | PackageListItem::PackageListItem(QListView* lv, Package *pi, PackageManagerSettings *s) | 13 | PackageListItem::PackageListItem(QListView* lv, Package *pi, PackageManagerSettings *s) |
14 | :QCheckListItem(lv,pi->name(),CheckBox) | 14 | :QCheckListItem(lv,pi->name(),CheckBox) |
15 | { | 15 | { |
16 | init(pi,s); | 16 | init(pi,s); |
17 | } | 17 | } |
18 | 18 | ||
19 | PackageListItem::PackageListItem(QListViewItem *lvi, Package *pi, PackageManagerSettings *s) | 19 | PackageListItem::PackageListItem(QListViewItem *lvi, Package *pi, PackageManagerSettings *s) |
20 | :QCheckListItem(lvi,pi->name(),CheckBox) | 20 | :QCheckListItem(lvi,pi->name(),CheckBox) |
21 | { | 21 | { |
22 | init(pi,s); | 22 | init(pi,s); |
23 | } | 23 | } |
24 | 24 | ||
25 | void PackageListItem::init( Package *pi, PackageManagerSettings *s) | 25 | void PackageListItem::init( Package *pi, PackageManagerSettings *s) |
26 | { | 26 | { |
27 | package = pi; | 27 | package = pi; |
28 | settings = s; | 28 | settings = s; |
29 | setExpandable( true ); | 29 | setExpandable( true ); |
30 | QCheckListItem *item; | 30 | QCheckListItem *item; |
31 | nameItem = new QCheckListItem( this, "" ); | 31 | nameItem = new QCheckListItem( this, "" ); |
32 | item = new QCheckListItem( this, QObject::tr("Description: ")+pi->desc() ); | ||
33 | item = new QCheckListItem( this, QObject::tr("Size: ")+pi->size() ); | 32 | item = new QCheckListItem( this, QObject::tr("Size: ")+pi->size() ); |
34 | destItem = new QCheckListItem( this, "" ); | 33 | destItem = new QCheckListItem( this, "" ); |
35 | linkItem = new QCheckListItem( this, "" ); | 34 | linkItem = new QCheckListItem( this, "" ); |
35 | QCheckListItem *otherItem = new QCheckListItem( this, QObject::tr("other") ); | ||
36 | item = new QCheckListItem( otherItem, QObject::tr("Description: ")+pi->desc() ); | ||
37 | QDict<QString> *fields = pi->getFields(); | ||
38 | QDictIterator<QString> it( *fields ); | ||
39 | while ( it.current() ) { | ||
40 | item = new QCheckListItem( otherItem, QString(it.currentKey()+": "+*it.current()) ); | ||
41 | ++it; | ||
42 | } | ||
36 | displayDetails(); | 43 | displayDetails(); |
37 | 44 | ||
38 | if (!pm_uninstalled) | 45 | if (!pm_uninstalled) |
39 | { | 46 | { |
40 | pm_uninstalled = new QPixmap(Resource::loadPixmap("oipkg/uninstalled")); | 47 | pm_uninstalled = new QPixmap(Resource::loadPixmap("oipkg/uninstalled")); |
41 | pm_installed = new QPixmap(Resource::loadPixmap("oipkg/installed")); | 48 | pm_installed = new QPixmap(Resource::loadPixmap("oipkg/installed")); |
42 | pm_install = new QPixmap(Resource::loadPixmap("oipkg/install")); | 49 | pm_install = new QPixmap(Resource::loadPixmap("oipkg/install")); |
43 | pm_uninstall = new QPixmap(Resource::loadPixmap("oipkg/uninstall")); | 50 | pm_uninstall = new QPixmap(Resource::loadPixmap("oipkg/uninstall")); |
44 | } | 51 | } |
45 | } | 52 | } |
46 | 53 | ||
47 | void PackageListItem::paintCell( QPainter *p, const QColorGroup & cg, | 54 | void PackageListItem::paintCell( QPainter *p, const QColorGroup & cg, |
48 | int column, int width, int alignment ) | 55 | int column, int width, int alignment ) |
49 | { | 56 | { |
50 | if ( !p ) | 57 | if ( !p ) |
51 | return; | 58 | return; |
52 | 59 | ||
53 | p->fillRect( 0, 0, width, height(), | 60 | p->fillRect( 0, 0, width, height(), |
54 | isSelected()? cg.highlight() : cg.base() ); | 61 | isSelected()? cg.highlight() : cg.base() ); |
55 | 62 | ||
56 | if ( column != 0 ) { | 63 | if ( column != 0 ) { |
57 | // The rest is text | 64 | // The rest is text |
58 | QListViewItem::paintCell( p, cg, column, width, alignment ); | 65 | QListViewItem::paintCell( p, cg, column, width, alignment ); |
59 | return; | 66 | return; |
60 | } | 67 | } |
61 | 68 | ||
62 | QListView *lv = listView(); | 69 | QListView *lv = listView(); |
63 | if ( !lv ) | 70 | if ( !lv ) |
64 | return; | 71 | return; |
65 | int marg = lv->itemMargin(); | 72 | int marg = lv->itemMargin(); |
66 | int r = marg; | 73 | int r = marg; |
67 | 74 | ||
68 | QPixmap pm = statePixmap(); | 75 | QPixmap pm = statePixmap(); |
69 | p->drawPixmap(marg,(height()-pm.height())/2,pm); | 76 | p->drawPixmap(marg,(height()-pm.height())/2,pm); |
70 | r += pm.width()+1; | 77 | r += pm.width()+1; |
71 | 78 | ||
72 | p->translate( r, 0 ); | 79 | p->translate( r, 0 ); |
73 | QListViewItem::paintCell( p, cg, column, width - r, alignment ); | 80 | QListViewItem::paintCell( p, cg, column, width - r, alignment ); |
74 | } | 81 | } |
75 | 82 | ||
76 | 83 | ||
77 | void PackageListItem::paintFocus( QPainter *p, const QColorGroup & cg, | 84 | void PackageListItem::paintFocus( QPainter *p, const QColorGroup & cg, |
78 | const QRect & r ) | 85 | const QRect & r ) |
79 | { | 86 | { |
80 | // Skip QCheckListItem | 87 | // Skip QCheckListItem |
81 | // (makes you wonder what we're getting from QCheckListItem) | 88 | // (makes you wonder what we're getting from QCheckListItem) |
82 | QListViewItem::paintFocus(p,cg,r); | 89 | QListViewItem::paintFocus(p,cg,r); |
83 | } | 90 | } |
84 | 91 | ||
85 | QPixmap PackageListItem::statePixmap() const | 92 | QPixmap PackageListItem::statePixmap() const |
86 | { | 93 | { |
87 | bool installed = package->installed(); | 94 | bool installed = package->installed(); |
88 | if ( !package->toProcess() ) { | 95 | if ( !package->toProcess() ) { |
89 | if ( !installed ) | 96 | if ( !installed ) |
90 | return *pm_uninstalled; | 97 | return *pm_uninstalled; |
91 | else | 98 | else |
92 | return *pm_installed; | 99 | return *pm_installed; |
93 | } else { | 100 | } else { |
94 | if ( !installed ) | 101 | if ( !installed ) |
95 | return *pm_install; | 102 | return *pm_install; |
96 | else | 103 | else |
97 | return *pm_uninstall; | 104 | return *pm_uninstall; |
98 | } | 105 | } |
99 | } | 106 | } |
100 | 107 | ||
101 | QString PackageListItem::key( int column, bool ascending ) const | 108 | QString PackageListItem::key( int column, bool ascending ) const |
102 | { | 109 | { |
103 | if ( column == 2 ) { | 110 | if ( column == 2 ) { |
104 | QString t = text(2); | 111 | QString t = text(2); |
105 | double bytes=t.toDouble(); | 112 | double bytes=t.toDouble(); |
106 | if ( t.contains('M') ) bytes*=1024*1024; | 113 | if ( t.contains('M') ) bytes*=1024*1024; |
107 | else if ( t.contains('K') || t.contains('k') ) bytes*=1024; | 114 | else if ( t.contains('K') || t.contains('k') ) bytes*=1024; |
108 | if ( !ascending ) bytes=999999999-bytes; | 115 | if ( !ascending ) bytes=999999999-bytes; |
109 | return QString().sprintf("%09d",(int)bytes); | 116 | return QString().sprintf("%09d",(int)bytes); |
110 | } else { | 117 | } else { |
111 | return QListViewItem::key(column,ascending); | 118 | return QListViewItem::key(column,ascending); |
112 | } | 119 | } |
113 | } | 120 | } |
114 | 121 | ||
115 | void PackageListItem::setOn( bool b ) | 122 | void PackageListItem::setOn( bool b ) |
116 | { | 123 | { |
117 | QCheckListItem::setOn( b ); | 124 | QCheckListItem::setOn( b ); |
118 | package->toggleProcess(); | 125 | package->toggleProcess(); |
119 | package->setLink( settings->createLinks() ); | 126 | package->setLink( settings->createLinks() ); |
120 | displayDetails(); | 127 | displayDetails(); |
121 | } | 128 | } |
122 | 129 | ||
123 | void PackageListItem::displayDetails() | 130 | void PackageListItem::displayDetails() |
124 | { | 131 | { |
125 | QString sod = " ("+package->sizeUnits(); | 132 | QString sod = " ("+package->sizeUnits(); |
126 | sod += package->dest().isEmpty()?QString(""):QString(QObject::tr(" on ")+package->dest()); | 133 | sod += package->dest().isEmpty()?QString(""):QString(QObject::tr(" on ")+package->dest()); |
127 | sod += ")"; | 134 | sod += ")"; |
128 | setText(0, package->name()+sod ); | 135 | setText(0, package->name()+sod ); |
129 | nameItem->setText( 0, QObject::tr("Name: ")+package->name()); | 136 | nameItem->setText( 0, QObject::tr("Name: ")+package->name()); |
130 | linkItem->setText( 0, QObject::tr("Link: ")+QString(package->link()?QObject::tr("Yes"):QObject::tr("No")) ); | 137 | linkItem->setText( 0, QObject::tr("Link: ")+QString(package->link()?QObject::tr("Yes"):QObject::tr("No")) ); |
131 | destItem->setText( 0, QObject::tr("Destination: ")+package->dest() ); | 138 | destItem->setText( 0, QObject::tr("Destination: ")+package->dest() ); |
132 | repaint(); | 139 | repaint(); |
133 | } | 140 | } |