summaryrefslogtreecommitdiff
path: root/noncore/unsupported/oipkg/packagelistitem.cpp
Unidiff
Diffstat (limited to 'noncore/unsupported/oipkg/packagelistitem.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/unsupported/oipkg/packagelistitem.cpp95
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
@@ -12,4 +12,6 @@
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"
@@ -24,34 +26,47 @@ static QPixmap *pm_uninstalled_old_installed_new=0;
24static QPixmap *pm_uninstalled_installed_old=0; 26static QPixmap *pm_uninstalled_installed_old=0;
25 27
26PackageListItem::PackageListItem(QListView* lv, Package *pi, PackageManagerSettings *s) 28PackageListItem::PackageListItem(ListViewItemOipkg *parent, QString name, Type ittype)
27 :QCheckListItem(lv,pi->name(),CheckBox) 29 : ListViewItemOipkg(parent,name,ittype)
30{
31
32}
33
34PackageListItem::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
32PackageListItem::PackageListItem(QListViewItem *lvi, Package *pi, PackageManagerSettings *s) 40PackageListItem::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}
45PackageListItem::~PackageListItem()
46{
47 delete popupMenu;
48 delete destsMenu;
49}
37 50
38void PackageListItem::init( Package *pi, PackageManagerSettings *s) 51void 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 }
@@ -173,2 +188,52 @@ void PackageListItem::displayDetails()
173 repaint(); 188 repaint();
174} 189}
190
191QPopupMenu* 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
225void 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