Diffstat (limited to 'noncore/unsupported/oipkg/packagelistitem.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/unsupported/oipkg/packagelistitem.cpp | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/noncore/unsupported/oipkg/packagelistitem.cpp b/noncore/unsupported/oipkg/packagelistitem.cpp index 5d08bb1..149ba35 100644 --- a/noncore/unsupported/oipkg/packagelistitem.cpp +++ b/noncore/unsupported/oipkg/packagelistitem.cpp | |||
@@ -1,45 +1,72 @@ | |||
1 | #include "packagelistitem.h" | 1 | #include "packagelistitem.h" |
2 | 2 | ||
3 | #include <qpe/resource.h> | 3 | #include <qpe/resource.h> |
4 | #include <qobject.h> | ||
5 | |||
6 | #include "debug.h" | ||
4 | 7 | ||
5 | static QPixmap *pm_uninstalled=0; | 8 | static QPixmap *pm_uninstalled=0; |
6 | static QPixmap *pm_installed=0; | 9 | static QPixmap *pm_installed=0; |
7 | static QPixmap *pm_uninstall=0; | 10 | static QPixmap *pm_uninstall=0; |
8 | static QPixmap *pm_install=0; | 11 | static QPixmap *pm_install=0; |
9 | 12 | ||
10 | PackageListItem::PackageListItem(QListView* lv, Package *pi) | 13 | PackageListItem::PackageListItem(QListView* lv, Package *pi, PackageManagerSettings *s) |
11 | :QCheckListItem(lv,pi->name(),CheckBox) | 14 | :QCheckListItem(lv,pi->name(),CheckBox) |
12 | { | 15 | { |
13 | package = pi; | 16 | package = pi; |
17 | settings = s; | ||
18 | setExpandable( true ); | ||
19 | QCheckListItem *item; | ||
20 | #ifndef NEWLAYOUT | ||
21 | item = new QCheckListItem( this, QObject::tr("Name") ); | ||
22 | item->setText(1,pi->name()); | ||
23 | item = new QCheckListItem( this, QObject::tr("Description") ); | ||
24 | item->setText(1,pi->desc()+"\ntest multi\nline"); | ||
25 | item = new QCheckListItem( this, QObject::tr("Size") ); | ||
26 | item->setText(1,pi->size()); | ||
27 | item = new QCheckListItem( this, QObject::tr("Destination") ); | ||
28 | item->setText(1,pi->getDest()); | ||
29 | #endif | ||
30 | #ifdef NEWLAYOUT | ||
31 | item = new QCheckListItem( this, QObject::tr("Name: ")+pi->name() ); | ||
32 | item = new QCheckListItem( this, QObject::tr("Description: ")+pi->desc() ); | ||
33 | item = new QCheckListItem( this, QObject::tr("Size: ")+pi->size() ); | ||
34 | destItem = new QCheckListItem( this, "" ); | ||
35 | linkItem = new QCheckListItem( this, "" ); | ||
36 | displayDetails(); | ||
37 | #endif | ||
38 | |||
14 | if (!pm_uninstalled) { | 39 | if (!pm_uninstalled) { |
15 | pm_uninstalled = new QPixmap(Resource::loadPixmap("oipkg/uninstalled")); | 40 | pm_uninstalled = new QPixmap(Resource::loadPixmap("oipkg/uninstalled")); |
16 | pm_installed = new QPixmap(Resource::loadPixmap("oipkg/installed")); | 41 | pm_installed = new QPixmap(Resource::loadPixmap("oipkg/installed")); |
17 | pm_install = new QPixmap(Resource::loadPixmap("oipkg/install")); | 42 | pm_install = new QPixmap(Resource::loadPixmap("oipkg/install")); |
18 | pm_uninstall = new QPixmap(Resource::loadPixmap("oipkg/uninstall")); | 43 | pm_uninstall = new QPixmap(Resource::loadPixmap("oipkg/uninstall")); |
19 | } | 44 | } |
45 | #ifndef NEWLAYOUT | ||
20 | setText(1, package->shortDesc() ); | 46 | setText(1, package->shortDesc() ); |
21 | setText(2, package->size() ); | 47 | setText(2, package->size() ); |
48 | #endif | ||
22 | } | 49 | } |
23 | 50 | ||
24 | void PackageListItem::paintCell( QPainter *p, const QColorGroup & cg, | 51 | void PackageListItem::paintCell( QPainter *p, const QColorGroup & cg, |
25 | int column, int width, int alignment ) | 52 | int column, int width, int alignment ) |
26 | { | 53 | { |
27 | if ( !p ) | 54 | if ( !p ) |
28 | return; | 55 | return; |
29 | 56 | ||
30 | p->fillRect( 0, 0, width, height(), | 57 | p->fillRect( 0, 0, width, height(), |
31 | isSelected()? cg.highlight() : cg.base() ); | 58 | isSelected()? cg.highlight() : cg.base() ); |
32 | 59 | ||
33 | if ( column != 0 ) { | 60 | if ( column != 0 ) { |
34 | // The rest is text | 61 | // The rest is text |
35 | QListViewItem::paintCell( p, cg, column, width, alignment ); | 62 | QListViewItem::paintCell( p, cg, column, width, alignment ); |
36 | return; | 63 | return; |
37 | } | 64 | } |
38 | 65 | ||
39 | QListView *lv = listView(); | 66 | QListView *lv = listView(); |
40 | if ( !lv ) | 67 | if ( !lv ) |
41 | return; | 68 | return; |
42 | int marg = lv->itemMargin(); | 69 | int marg = lv->itemMargin(); |
43 | int r = marg; | 70 | int r = marg; |
44 | 71 | ||
45 | QPixmap pm = statePixmap(); | 72 | QPixmap pm = statePixmap(); |
@@ -72,26 +99,41 @@ QPixmap PackageListItem::statePixmap() const | |||
72 | return *pm_install; | 99 | return *pm_install; |
73 | else | 100 | else |
74 | return *pm_uninstall; | 101 | return *pm_uninstall; |
75 | } | 102 | } |
76 | } | 103 | } |
77 | 104 | ||
78 | QString PackageListItem::key( int column, bool ascending ) const | 105 | QString PackageListItem::key( int column, bool ascending ) const |
79 | { | 106 | { |
80 | if ( column == 2 ) { | 107 | if ( column == 2 ) { |
81 | QString t = text(2); | 108 | QString t = text(2); |
82 | double bytes=t.toDouble(); | 109 | double bytes=t.toDouble(); |
83 | if ( t.contains('M') ) bytes*=1024*1024; | 110 | if ( t.contains('M') ) bytes*=1024*1024; |
84 | else if ( t.contains('K') || t.contains('k') ) bytes*=1024; | 111 | else if ( t.contains('K') || t.contains('k') ) bytes*=1024; |
85 | if ( !ascending ) bytes=999999999-bytes; | 112 | if ( !ascending ) bytes=999999999-bytes; |
86 | return QString().sprintf("%09d",(int)bytes); | 113 | return QString().sprintf("%09d",(int)bytes); |
87 | } else { | 114 | } else { |
88 | return QListViewItem::key(column,ascending); | 115 | return QListViewItem::key(column,ascending); |
89 | } | 116 | } |
90 | } | 117 | } |
91 | 118 | ||
92 | void PackageListItem::setOn( bool b ) | 119 | void PackageListItem::setOn( bool b ) |
93 | { | 120 | { |
94 | QCheckListItem::setOn( b ); | 121 | QCheckListItem::setOn( b ); |
95 | package->toggleProcess(); | 122 | package->toggleProcess(); |
123 | // if ( b ) | ||
124 | // { | ||
125 | // if ((package->dest()).isEmpty) | ||
126 | // package->setDest( settings->getDestinationName() ); | ||
127 | // }else{ | ||
128 | // package->setDest( QObject::tr("not installed")); | ||
129 | // } | ||
130 | package->setLink( settings->createLinks() ); | ||
131 | displayDetails(); | ||
132 | } | ||
133 | |||
134 | void PackageListItem::displayDetails() | ||
135 | { | ||
136 | linkItem->setText( 0, QObject::tr("Link: ")+QString(package->link()?QObject::tr("Yes"):QObject::tr("No")) ); | ||
137 | destItem->setText( 0, QObject::tr("Destination: ")+package->dest() ); | ||
96 | repaint(); | 138 | repaint(); |
97 | } | 139 | } |