summaryrefslogtreecommitdiff
path: root/noncore/unsupported/oipkg/packagelistitem.cpp
Side-by-side diff
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
@@ -13,2 +13,4 @@
#include <qobject.h>
+#include <qpopupmenu.h>
+#include <qaction.h>
@@ -25,4 +27,10 @@ static QPixmap *pm_uninstalled_installed_old=0;
-PackageListItem::PackageListItem(QListView* lv, Package *pi, PackageManagerSettings *s)
- : QCheckListItem(lv,pi->name(),CheckBox)
+PackageListItem::PackageListItem(ListViewItemOipkg *parent, QString name, Type ittype)
+ : ListViewItemOipkg(parent,name,ittype)
+{
+
+}
+
+PackageListItem::PackageListItem(QListView* lv, OipkgPackage *pi, PackageManagerSettings *s)
+ : ListViewItemOipkg(lv,pi->name(),ListViewItemOipkg::Package)
{
@@ -31,4 +39,4 @@ PackageListItem::PackageListItem(QListView* lv, Package *pi, PackageManagerSetti
-PackageListItem::PackageListItem(QListViewItem *lvi, Package *pi, PackageManagerSettings *s)
- : QCheckListItem(lvi,pi->name(),CheckBox)
+PackageListItem::PackageListItem(ListViewItemOipkg *lvi, OipkgPackage *pi, PackageManagerSettings *s)
+ : ListViewItemOipkg(lvi,pi->name(),ListViewItemOipkg::Package)
{
@@ -36,5 +44,12 @@ PackageListItem::PackageListItem(QListViewItem *lvi, Package *pi, PackageManager
}
+PackageListItem::~PackageListItem()
+{
+ delete popupMenu;
+ delete destsMenu;
+}
-void PackageListItem::init( Package *pi, PackageManagerSettings *s)
+void PackageListItem::init( OipkgPackage *pi, PackageManagerSettings *s)
{
+ popupMenu = new QPopupMenu( 0 );
+ destsMenu = new QPopupMenu( 0 );
package = pi;
@@ -42,11 +57,11 @@ void PackageListItem::init( Package *pi, PackageManagerSettings *s)
setExpandable( true );
- QCheckListItem *item;
- nameItem = new QCheckListItem( this, "" );
- item = new QCheckListItem( this, QObject::tr("Description: ")+pi->desc() );
- item = new QCheckListItem( this, QObject::tr("Size: ")+pi->size() );
- destItem = new QCheckListItem( this, "" );
- linkItem = new QCheckListItem( this, "" );
- statusItem = new QCheckListItem( this, "" );
- QCheckListItem *otherItem = new QCheckListItem( this, QObject::tr("other") );
- item = new QCheckListItem( otherItem, QObject::tr("Install Name: ")+pi->installName() );
+ ListViewItemOipkg *item;
+ nameItem = new ListViewItemOipkg( this, ListViewItemOipkg::Attribute,"name" );
+ item = new ListViewItemOipkg( this, ListViewItemOipkg::Attribute, QObject::tr("Description: ")+pi->desc() );
+ item = new ListViewItemOipkg( this, ListViewItemOipkg::Attribute, QObject::tr("Size: ")+pi->size() );
+ destItem = new ListViewItemOipkg( this, ListViewItemOipkg::Attribute, "dest" );
+ linkItem = new ListViewItemOipkg( this, ListViewItemOipkg::Attribute, "link" );
+ statusItem = new ListViewItemOipkg( this, ListViewItemOipkg::Attribute, "status" );
+ ListViewItemOipkg *otherItem = new ListViewItemOipkg( this, ListViewItemOipkg::Attribute, QObject::tr("other") );
+ item = new ListViewItemOipkg( otherItem, ListViewItemOipkg::Attribute, QObject::tr("Install Name: ")+pi->installName() );
QDict<QString> *fields = pi->getFields();
@@ -54,3 +69,3 @@ void PackageListItem::init( Package *pi, PackageManagerSettings *s)
while ( it.current() ) {
- item = new QCheckListItem( otherItem, QString(it.currentKey()+": "+*it.current()) );
+ item = new ListViewItemOipkg( otherItem, ListViewItemOipkg::Attribute, QString(it.currentKey()+": "+*it.current()) );
++it;
@@ -174 +189,51 @@ void PackageListItem::displayDetails()
}
+
+QPopupMenu* PackageListItem::getPopupMenu()
+{
+ popupMenu->clear();
+ destsMenu->clear();
+
+ QAction *popupAction;
+ qDebug("PackageListItem::showPopup ");
+
+ if (!package->installed()){
+ popupMenu->insertItem( QObject::tr("Install to"), destsMenu );
+ QStringList dests = settings->getDestinationNames();
+ QString ad = settings->getDestinationName();
+ for (uint i = 0; i < dests.count(); i++ )
+ {
+ popupAction = new QAction( dests[i], QString::null, 0, popupMenu, 0 );
+ popupAction->addTo( destsMenu );
+ if ( dests[i] == ad && getPackage()->toInstall() )
+ {
+ popupAction->setToggleAction( true );
+ popupAction->setOn(true);
+ }
+ }
+ connect( destsMenu, SIGNAL( activated( int ) ),
+ this, SLOT( menuAction( int ) ) );
+ popupMenu->popup( QCursor::pos() );
+ }else{
+ popupMenu->insertItem( QObject::tr("Remove"));
+ connect( popupMenu, SIGNAL( activated( int ) ),
+ this, SLOT( menuAction( int ) ) );
+ popupMenu->popup( QCursor::pos() );
+ }
+ return popupMenu;
+}
+
+void PackageListItem::menuAction( int i )
+{
+ if (package->installed()){
+ package->setDest( destsMenu->text(i) );
+ package->setLink( settings->createLinks() );
+ }
+ package->setOn();
+ displayDetails();
+}
+
+//void PackageListItem::toggleProcess()
+//{
+// package->toggleProcess() ;
+// displayDetails();
+//} \ No newline at end of file