Diffstat (limited to 'noncore/unsupported/oipkg/packagelistitem.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/unsupported/oipkg/packagelistitem.cpp | 95 |
1 files changed, 80 insertions, 15 deletions
diff --git a/noncore/unsupported/oipkg/packagelistitem.cpp b/noncore/unsupported/oipkg/packagelistitem.cpp index 03bf477..4380393 100644 --- a/noncore/unsupported/oipkg/packagelistitem.cpp +++ b/noncore/unsupported/oipkg/packagelistitem.cpp | |||
@@ -8,54 +8,69 @@ | |||
8 | ***************************************************************************/ | 8 | ***************************************************************************/ |
9 | // (c) 2002 Patrick S. Vogt <tille@handhelds.org> | 9 | // (c) 2002 Patrick S. Vogt <tille@handhelds.org> |
10 | #include "packagelistitem.h" | 10 | #include "packagelistitem.h" |
11 | 11 | ||
12 | #include <qpe/resource.h> | 12 | #include <qpe/resource.h> |
13 | #include <qobject.h> | 13 | #include <qobject.h> |
14 | #include <qpopupmenu.h> | ||
15 | #include <qaction.h> | ||
14 | 16 | ||
15 | #include "debug.h" | 17 | #include "debug.h" |
16 | 18 | ||
17 | static QPixmap *pm_uninstalled=0; | 19 | static QPixmap *pm_uninstalled=0; |
18 | static QPixmap *pm_uninstalled_old=0; | 20 | static QPixmap *pm_uninstalled_old=0; |
19 | static QPixmap *pm_installed=0; | 21 | static QPixmap *pm_installed=0; |
20 | static QPixmap *pm_installed_old=0; | 22 | static QPixmap *pm_installed_old=0; |
21 | static QPixmap *pm_uninstall=0; | 23 | static QPixmap *pm_uninstall=0; |
22 | static QPixmap *pm_install=0; | 24 | static QPixmap *pm_install=0; |
23 | static QPixmap *pm_uninstalled_old_installed_new=0; | 25 | static QPixmap *pm_uninstalled_old_installed_new=0; |
24 | static QPixmap *pm_uninstalled_installed_old=0; | 26 | static QPixmap *pm_uninstalled_installed_old=0; |
25 | 27 | ||
26 | PackageListItem::PackageListItem(QListView* lv, Package *pi, PackageManagerSettings *s) | 28 | PackageListItem::PackageListItem(ListViewItemOipkg *parent, QString name, Type ittype) |
27 | :QCheckListItem(lv,pi->name(),CheckBox) | 29 | : ListViewItemOipkg(parent,name,ittype) |
30 | { | ||
31 | |||
32 | } | ||
33 | |||
34 | PackageListItem::PackageListItem(QListView* lv, OipkgPackage *pi, PackageManagerSettings *s) | ||
35 | :ListViewItemOipkg(lv,pi->name(),ListViewItemOipkg::Package) | ||
28 | { | 36 | { |
29 | init(pi,s); | 37 | init(pi,s); |
30 | } | 38 | } |
31 | 39 | ||
32 | PackageListItem::PackageListItem(QListViewItem *lvi, Package *pi, PackageManagerSettings *s) | 40 | PackageListItem::PackageListItem(ListViewItemOipkg *lvi, OipkgPackage *pi, PackageManagerSettings *s) |
33 | :QCheckListItem(lvi,pi->name(),CheckBox) | 41 | :ListViewItemOipkg(lvi,pi->name(),ListViewItemOipkg::Package) |
34 | { | 42 | { |
35 | init(pi,s); | 43 | init(pi,s); |
36 | } | 44 | } |
45 | PackageListItem::~PackageListItem() | ||
46 | { | ||
47 | delete popupMenu; | ||
48 | delete destsMenu; | ||
49 | } | ||
37 | 50 | ||
38 | void PackageListItem::init( Package *pi, PackageManagerSettings *s) | 51 | void PackageListItem::init( OipkgPackage *pi, PackageManagerSettings *s) |
39 | { | 52 | { |
53 | popupMenu = new QPopupMenu( 0 ); | ||
54 | destsMenu = new QPopupMenu( 0 ); | ||
40 | package = pi; | 55 | package = pi; |
41 | settings = s; | 56 | settings = s; |
42 | setExpandable( true ); | 57 | setExpandable( true ); |
43 | QCheckListItem *item; | 58 | ListViewItemOipkg *item; |
44 | nameItem = new QCheckListItem( this, "" ); | 59 | nameItem = new ListViewItemOipkg( this, ListViewItemOipkg::Attribute,"name" ); |
45 | item = new QCheckListItem( this, QObject::tr("Description: ")+pi->desc() ); | 60 | item = new ListViewItemOipkg( this, ListViewItemOipkg::Attribute, QObject::tr("Description: ")+pi->desc() ); |
46 | item = new QCheckListItem( this, QObject::tr("Size: ")+pi->size() ); | 61 | item = new ListViewItemOipkg( this, ListViewItemOipkg::Attribute, QObject::tr("Size: ")+pi->size() ); |
47 | destItem = new QCheckListItem( this, "" ); | 62 | destItem = new ListViewItemOipkg( this, ListViewItemOipkg::Attribute, "dest" ); |
48 | linkItem = new QCheckListItem( this, "" ); | 63 | linkItem = new ListViewItemOipkg( this, ListViewItemOipkg::Attribute, "link" ); |
49 | statusItem = new QCheckListItem( this, "" ); | 64 | statusItem = new ListViewItemOipkg( this, ListViewItemOipkg::Attribute, "status" ); |
50 | QCheckListItem *otherItem = new QCheckListItem( this, QObject::tr("other") ); | 65 | ListViewItemOipkg *otherItem = new ListViewItemOipkg( this, ListViewItemOipkg::Attribute, QObject::tr("other") ); |
51 | item = new QCheckListItem( otherItem, QObject::tr("Install Name: ")+pi->installName() ); | 66 | item = new ListViewItemOipkg( otherItem, ListViewItemOipkg::Attribute, QObject::tr("Install Name: ")+pi->installName() ); |
52 | QDict<QString> *fields = pi->getFields(); | 67 | QDict<QString> *fields = pi->getFields(); |
53 | QDictIterator<QString> it( *fields ); | 68 | QDictIterator<QString> it( *fields ); |
54 | while ( it.current() ) { | 69 | while ( it.current() ) { |
55 | item = new QCheckListItem( otherItem, QString(it.currentKey()+": "+*it.current()) ); | 70 | item = new ListViewItemOipkg( otherItem, ListViewItemOipkg::Attribute, QString(it.currentKey()+": "+*it.current()) ); |
56 | ++it; | 71 | ++it; |
57 | } | 72 | } |
58 | displayDetails(); | 73 | displayDetails(); |
59 | 74 | ||
60 | if (!pm_uninstalled) | 75 | if (!pm_uninstalled) |
61 | { | 76 | { |
@@ -169,6 +184,56 @@ void PackageListItem::displayDetails() | |||
169 | nameItem->setText( 0, QObject::tr("Name: ")+package->name()); | 184 | nameItem->setText( 0, QObject::tr("Name: ")+package->name()); |
170 | linkItem->setText( 0, QObject::tr("Link: ")+(package->link()?QObject::tr("Yes"):QObject::tr("No"))); | 185 | linkItem->setText( 0, QObject::tr("Link: ")+(package->link()?QObject::tr("Yes"):QObject::tr("No"))); |
171 | destItem->setText( 0, QObject::tr("Destination: ")+package->dest() ); | 186 | destItem->setText( 0, QObject::tr("Destination: ")+package->dest() ); |
172 | statusItem->setText( 0, QObject::tr("Status: ")+package->status() ); | 187 | statusItem->setText( 0, QObject::tr("Status: ")+package->status() ); |
173 | repaint(); | 188 | repaint(); |
174 | } | 189 | } |
190 | |||
191 | QPopupMenu* PackageListItem::getPopupMenu() | ||
192 | { | ||
193 | popupMenu->clear(); | ||
194 | destsMenu->clear(); | ||
195 | |||
196 | QAction *popupAction; | ||
197 | qDebug("PackageListItem::showPopup "); | ||
198 | |||
199 | if (!package->installed()){ | ||
200 | popupMenu->insertItem( QObject::tr("Install to"), destsMenu ); | ||
201 | QStringList dests = settings->getDestinationNames(); | ||
202 | QString ad = settings->getDestinationName(); | ||
203 | for (uint i = 0; i < dests.count(); i++ ) | ||
204 | { | ||
205 | popupAction = new QAction( dests[i], QString::null, 0, popupMenu, 0 ); | ||
206 | popupAction->addTo( destsMenu ); | ||
207 | if ( dests[i] == ad && getPackage()->toInstall() ) | ||
208 | { | ||
209 | popupAction->setToggleAction( true ); | ||
210 | popupAction->setOn(true); | ||
211 | } | ||
212 | } | ||
213 | connect( destsMenu, SIGNAL( activated( int ) ), | ||
214 | this, SLOT( menuAction( int ) ) ); | ||
215 | popupMenu->popup( QCursor::pos() ); | ||
216 | }else{ | ||
217 | popupMenu->insertItem( QObject::tr("Remove")); | ||
218 | connect( popupMenu, SIGNAL( activated( int ) ), | ||
219 | this, SLOT( menuAction( int ) ) ); | ||
220 | popupMenu->popup( QCursor::pos() ); | ||
221 | } | ||
222 | return popupMenu; | ||
223 | } | ||
224 | |||
225 | void PackageListItem::menuAction( int i ) | ||
226 | { | ||
227 | if (package->installed()){ | ||
228 | package->setDest( destsMenu->text(i) ); | ||
229 | package->setLink( settings->createLinks() ); | ||
230 | } | ||
231 | package->setOn(); | ||
232 | displayDetails(); | ||
233 | } | ||
234 | |||
235 | //void PackageListItem::toggleProcess() | ||
236 | //{ | ||
237 | // package->toggleProcess() ; | ||
238 | // displayDetails(); | ||
239 | //} \ No newline at end of file | ||