-rw-r--r-- | noncore/unsupported/oipkg/package.cpp | 24 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/package.h | 3 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/packagelist.cpp | 1 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/packagelistitem.cpp | 1 |
4 files changed, 21 insertions, 8 deletions
diff --git a/noncore/unsupported/oipkg/package.cpp b/noncore/unsupported/oipkg/package.cpp index e020601..190b3fb 100644 --- a/noncore/unsupported/oipkg/package.cpp +++ b/noncore/unsupported/oipkg/package.cpp @@ -1,465 +1,475 @@ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ // (c) 2002 Patrick S. Vogt <tille@handhelds.org> #include "package.h" #include <qpe/process.h> #include <qpe/stringutil.h> #include <qfile.h> #include <qtextstream.h> #include <stdlib.h> #include <unistd.h> #include "debug.h" OipkgPackage::OipkgPackage( QObject *parent, const char *name ) : QObject(parent,name) { - + init(); } OipkgPackage::~OipkgPackage() { + } OipkgPackage::OipkgPackage( PackageManagerSettings *s, QObject *parent, const char *name ) : QObject(parent,name) { - init(s); + settings = s; + init(); } -void OipkgPackage::init( PackageManagerSettings *s ) +// void OipkgPackage::init( PackageManagerSettings *s ) +// { +// settings = s; +// init(); +// } + +void OipkgPackage::init( ) { - settings = s; _size = ""; _section = ""; _subsection = ""; _shortDesc = ""; _desc = ""; _name = ""; _toProcess = false; _useFileName = false; _old = false; _status = ""; _dest = settings->getDestinationName(); _link = settings->createLinks(); _versions=0; _version=""; } OipkgPackage::OipkgPackage( QStringList pack, PackageManagerSettings *s , QObject *parent, const char *name ) : QObject(parent,name) { - init(s); + settings = s; + init(); parsePackage( pack ); } OipkgPackage::OipkgPackage( QString n, PackageManagerSettings *s, QObject *parent, const char *name ) : QObject(parent,name) { - init(s); + settings = s; + init(); if ( !QFile::exists( n ) ) { _name = QString( n ); }else{ pvDebug(4,"remote file: "+n); parseIpkgFile( n ); _useFileName = true; _fileName = QString( n ); } } OipkgPackage::OipkgPackage( OipkgPackage *pi, QObject *parent, const char *name ) : QObject(parent,name) { - init(pi->settings); + settings = pi->settings; + init(); copyValues( pi ); } void OipkgPackage::setValue( QString n, QString t ) { if ( n == "Package" ) { _name = QString( t ); }else if ( n == "Installed-Size" ) { _size = t; // }else if ( n == "Priority") // { }else if ( n == "Section") { setSection( t ); // }else if ( n == "Maintainer") // { // // }else if ( n == "Architecture") // { }else if ( n == "Version") { _version = t; // }else if ( n == "Pre-Depends") // { // // }else if ( n == "Depends") // { }else if ( n == "Filename") { _fileName = t; // }else if ( n == "Size") // { // // }else if ( n == "MD5Sum") // { }else if ( n == "Description") { setDesc( t ); }else if ( n == "Status") { if ( installed() ) return; _status = t; // }else if ( n == "Essential") // { }else{ _values.insert(n,new QString(t)); } } QString OipkgPackage::name() { if (_displayName.isEmpty() ) return _name; else return _displayName; } QString OipkgPackage::installName() { if (_useFileName) return _fileName; else return _name; } QString OipkgPackage::packageName() { QString pn = installName(); pn = pn.right(pn.length()-pn.findRev("/")); pn = pn.left(pn.find("_")); return pn; } bool OipkgPackage::installed() { if (_status.contains("installed")) { if (_status.contains("not-installed")) { _toProcess = true; return false; } else return true; } else if (_versions) { QDictIterator<OipkgPackage> other( *_versions ); while ( other.current() ) { if (other.current()->status().contains("installed") && other.current()->version() == version()) return true; ++other; } } return false; } bool OipkgPackage::otherInstalled() { if (_versions) { QDictIterator<OipkgPackage> other( *_versions ); while ( other.current() ) { if (other.current()->installed()) return true; ++other; } } return false; } void OipkgPackage::setDesc( QString s ) { _desc = s; _shortDesc = s.left( s.find("\n") ); } QString OipkgPackage::desc() { return _desc; } QString OipkgPackage::shortDesc() { return _shortDesc; } QString OipkgPackage::size() { return _size; } QString OipkgPackage::version() { return _version; } QString OipkgPackage::sizeUnits() { int i = _size.toInt(); int c = 0; QString ret; QStringList unit; unit << "B" << "KB" << "MB" << "GB" << "TB"; //prepair for the future ;) while (i > 1) { ret=QString::number(i)+" "+unit[c]; c++; i /= 1024; } return ret; } bool OipkgPackage::toProcess() { return _toProcess; } bool OipkgPackage::toRemove() { if ( _toProcess && installed() ) return true; else return false; } bool OipkgPackage::toInstall() { if ( _toProcess && !installed() ) return true; else return false; } void OipkgPackage::toggleProcess() { _toProcess = ! _toProcess; } void OipkgPackage::copyValues( OipkgPackage* pack ) { if (_size.isEmpty() && !pack->_size.isEmpty()) _size = QString( pack->_size ); if (_section.isEmpty() && !pack->_section.isEmpty()) _section = QString( pack->_section ); if (_subsection.isEmpty()&& !pack->_subsection.isEmpty()) _subsection = QString( pack->_subsection ); if (_shortDesc.isEmpty() && !pack->_shortDesc.isEmpty()) _shortDesc = QString( pack->_shortDesc ); if (_desc.isEmpty() && !pack->_desc.isEmpty()) _desc = QString( pack->_desc ); if (_name.isEmpty() && !pack->_name.isEmpty()) _name = QString( pack->_name ); if (_dest.isEmpty() && !pack->_dest.isEmpty()) _dest= QString( pack->_dest ); if (_displayName.isEmpty()&& !pack->_displayName.isEmpty()) _displayName = QString( pack->_displayName ); if (_fileName.isEmpty() && !pack->_fileName.isEmpty()) _fileName = QString( pack->_fileName ); if (_version.isEmpty() && !pack->_version.isEmpty()) _version = QString( pack->_version ); if (_values.isEmpty() && !pack->_values.isEmpty())_values = QDict<QString>( pack->_values ); if (!installed() && _status.isEmpty() && !pack->_status.isEmpty()) _status = QString( pack->_status ); } QString OipkgPackage::section() { return _section; } void OipkgPackage::setSection( QString s) { int i = s.find("/"); if ( i > 0 ) { _section = s.left(i); _subsection = s.mid(i+1); }else{ _section = s; _subsection = ""; } } QString OipkgPackage::subSection() { return _subsection; } void OipkgPackage::parsePackage( QStringList pack ) { if ( pack.isEmpty() ) return; int count = pack.count(); for( int i = 0; i < count; i++ ) { QString line = pack[i]; int sep = line.find( QRegExp(":[\t ]+") ); if ( sep >= 0 ) { QString tag = line.left(sep); QString value = line.mid(sep+2).simplifyWhiteSpace(); setValue( tag, value ); }else{ } } return; } QString OipkgPackage::details() { QString status; Process ipkg_status(QStringList() << "ipkg" << "info" << name() ); QString description; if ( ipkg_status.exec("",status) ) { QStringList lines = QStringList::split('\n',status,TRUE); for (QStringList::Iterator it = lines.begin(); it!=lines.end(); ++it) { QString line = *it; if ( line == " ." ) { description.append("<p>"); } else if ( line[0] == ' ' || line[0] == '\t' ) { // continuation description.append(" "); description.append(Qtopia::escapeString(line)); } else { int sep = line.find(QRegExp(":[\t ]+")); if ( sep >= 0 ) { QString tag = line.left(sep); description.append("<br>"); description.append("<b>"); description.append(Qtopia::escapeString(tag)); description.append(":</b> "); description.append(Qtopia::escapeString(line.mid(sep+2))); } else { description.append(" "); description.append(Qtopia::escapeString(line)); } } } } return description; } void OipkgPackage::processed() { _toProcess = false; //hack, but we're not writing status anyway... if ( installed() ) _status = "install"; else _status = "installed"; } QString OipkgPackage::dest() { if ( installed()||(!installed() && _toProcess) ) return _dest!=""?_dest:settings->getDestinationName(); else return ""; } void OipkgPackage::setDest( QString d ) { if ( d == "remote") _useFileName = true; else _dest = d; } void OipkgPackage::setOn() { _toProcess = true; } bool OipkgPackage::link() { if ( _dest == "root" || (!installed() && !_toProcess) ) return false; return _link; } void OipkgPackage::setLink(bool b) { _link = b; } void OipkgPackage::parseIpkgFile( QString file) { // 20020830 // a quick hack to make oipkg understand the new ipk format // neu: ar pf PACKAGE control.tar.gz | tar xfOz - ./control > /tmp/control if (system("ar pf "+file+" control.tar.gz | tar xfOz - ./control > /tmp/control") != 0) { //#old tar ipk format system("tar xzf "+file+" -C /tmp"); system("tar xzf /tmp/control.tar.gz -C /tmp"); } QFile f("/tmp/control"); if ( f.open(IO_ReadOnly) ) { QTextStream t( &f ); QStringList pack; while ( !t.eof() ) { pack << t.readLine(); } f.close(); parsePackage( pack ); } } //QString OipkgPackage::getPackageName() //{ // if ( _packageName.isEmpty() ) return _name; // else return _packageName; //} void OipkgPackage::instalFromFile(bool iff) { _useFileName = iff; } void OipkgPackage::setName(QString n) { _displayName = n; } QDict<QString>* OipkgPackage::getFields() { return &_values; } QString OipkgPackage::status() { return _status; } bool OipkgPackage::isOld() { if (!_versions) return false; QDictIterator<OipkgPackage> other( *_versions ); while ( other.current() ) { if (other.current()->version() > version() ) return true; ++other; } return false; } bool OipkgPackage::hasVersions() { if (!_versions) return false; diff --git a/noncore/unsupported/oipkg/package.h b/noncore/unsupported/oipkg/package.h index 2334c31..02d8eff 100644 --- a/noncore/unsupported/oipkg/package.h +++ b/noncore/unsupported/oipkg/package.h @@ -1,100 +1,101 @@ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ // (c) 2002 Patrick S. Vogt <tille@handhelds.org> #ifndef PK_ITEM_H #define PK_ITEM_H #include <qstring.h> #include <qlistview.h> #include <qpainter.h> #include <qpixmap.h> #include <qdict.h> #include <qobject.h> #include "pksettings.h" class OipkgPackage : public QObject { Q_OBJECT public: OipkgPackage(QObject *parent=0, const char *name=0); OipkgPackage(PackageManagerSettings *s, QObject *parent=0, const char *name=0); ~OipkgPackage(); OipkgPackage( QStringList, PackageManagerSettings *s, QObject *parent=0, const char *name=0 ); OipkgPackage( QString, PackageManagerSettings *s, QObject *parent=0, const char *name=0 ); OipkgPackage( OipkgPackage*s, QObject *parent=0, const char *name=0 ); void setValue( QString, QString ); void copyValues( OipkgPackage* ); QString name(); QString installName(); QString packageName(); bool installed(); bool otherInstalled(); void setDesc( QString ); QString shortDesc(); QString desc(); QString size(); QString sizeUnits(); QString version(); void setSection( QString ); QString section(); QString subSection(); QString details(); bool toProcess(); bool toInstall(); bool toRemove(); void processed(); QString dest(); void setDest( QString d ); void setOn(); bool link(); void setLink(bool); bool isOld(); bool hasVersions(); void parseIpkgFile( QString ); void instalFromFile(bool iff=true); void setName(QString); QDict<QString>* getFields(); QString status(); QDict<OipkgPackage>* getOtherVersions(); void setOtherVersions(QDict<OipkgPackage>*); public slots: void toggleProcess(); private: PackageManagerSettings *settings; QString _displayName; QString _name; QString _fileName; bool _old; bool _hasVersions; bool _toProcess; bool _link; QString _status; QString _size; QString _section; QString _subsection; QString _shortDesc; QString _desc; QString _version; QString _dest; QDict<QString> _values; QDict<OipkgPackage> *_versions; bool _useFileName; void parsePackage( QStringList ); - void init(PackageManagerSettings *); + void init(); + // void init(PackageManagerSettings*); }; #endif diff --git a/noncore/unsupported/oipkg/packagelist.cpp b/noncore/unsupported/oipkg/packagelist.cpp index 5f79ec1..6f0b56f 100644 --- a/noncore/unsupported/oipkg/packagelist.cpp +++ b/noncore/unsupported/oipkg/packagelist.cpp @@ -1,240 +1,241 @@ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ // (c) 2002 Patrick S. Vogt <tille@handhelds.org> #include "packagelist.h" #include <assert.h> #include <qfile.h> #include <qfileinfo.h> #include <qtextstream.h> #include "debug.h" static QDict<OipkgPackage> *packageListAll; static int packageListAllRefCount = 0; PackageList::PackageList(QObject *parent, const char *name) : QObject(parent,name), packageIter( packageList ) { empty=true; if (!packageListAll) packageListAll = new QDict<OipkgPackage>(); packageListAllRefCount++; sections << "All"; subSections.insert("All", new QStringList() ); QStringList *ss = subSections["All"]; *ss << "All"; aktSection = "All"; aktSubSection = "All"; } PackageList::PackageList( PackageManagerSettings* s, QObject *parent, const char *name) : QObject(parent,name), packageIter( packageList ) { settings = s; PackageList(parent, name); } PackageList::~PackageList() { if (--packageListAllRefCount < 1 ) delete packageListAll; } /** Inserts a package into the list */ void PackageList::insertPackage( OipkgPackage* pack ) { if (!pack) return; OipkgPackage* p = packageListAll->find( pack->name() ); if ( p ) { if ( (p->version() == pack->version()) // && (p->dest() == pack->dest()) ) { p->copyValues( pack ); delete pack; pack = p; } else { QDict<OipkgPackage> *packver = p->getOtherVersions(); // p->setName( pack->name()+"["+p->version()+"]" ); if (!packver) { packver = new QDict<OipkgPackage>(); packver->insert( pack->name(), p ); p->setOtherVersions( packver ); } pack->setName( pack->name() );//+"["+pack->version()+"]" ); pack->setOtherVersions( packver ); packver->insert( pack->name(), pack ); packageListAll->insert( pack->name(), pack ); packageList.insert( pack->name(), pack ); origPackageList.insert( pack->name(), pack ); } }else{ packageListAll->insert( pack->name(), pack ); packageList.insert( pack->name(), pack ); origPackageList.insert( pack->name(), pack ); }; empty=false; updateSections( pack ); } void PackageList::filterPackages( QString f ) { packageList.clear(); QDictIterator<OipkgPackage> filterIter( origPackageList ); filterIter.toFirst(); OipkgPackage *pack= filterIter.current() ; while ( pack ) { if ( ((aktSection=="All")||(pack->section()==aktSection)) && ((aktSubSection=="All")||(pack->subSection()==aktSubSection)) && pack->name().contains( f ) ) { packageList.insert( pack->name(), pack ); } ++filterIter; pack = filterIter.current(); } } OipkgPackage* PackageList::find( QString n ) { return packageList.find( n ); } OipkgPackage* PackageList::first() { packageIter.toFirst(); return packageIter.current(); } OipkgPackage* PackageList::next() { ++packageIter; return packageIter.current(); } QStringList PackageList::getSections() { sections.sort(); return sections; } QStringList PackageList::getSubSections() { QStringList ss; if ( !subSections[aktSection] ) return ss; ss = *subSections[aktSection]; ss.sort(); return ss; } void PackageList::setSection( QString sec ) { aktSection = sec; } void PackageList::setSubSection( QString ssec ) { aktSubSection = ssec; } void PackageList::updateSections( OipkgPackage* pack ) { QString s = pack->section(); if ( s.isEmpty() || s == "") return; if ( !sections.contains(s) ) sections += s; QString ss = pack->subSection(); if ( ss.isEmpty() || ss == "" ) return; if ( !subSections[s] ) { subSections.insert( s, new QStringList() ); QStringList *subsecs = subSections[s]; *subsecs += "All"; } QStringList *subsecs = subSections[s]; if ( !subsecs->contains(ss) ) *subsecs += ss; // if ( !subSections["All"] ) subSections.insert( "All", new QStringList() ); // subsecs = subSections["All"]; // *subsecs += ss; } void PackageList::readFileEntries( QString filename, QString dest ) { pvDebug(5,"PackageList::readFileEntries "+filename+" dest "+dest); QStringList packEntry; QFile f( filename ); if ( !f.open(IO_ReadOnly) ) return; QTextStream *statusStream = new QTextStream( &f ); while ( !statusStream ->eof() ) { QString line = statusStream->readLine(); if ( line.find(QRegExp("[\n\t ]*")) || line == "" ) { //end of package if ( ! packEntry.isEmpty() ) { OipkgPackage *p = new OipkgPackage( packEntry, settings ); if ( p ) { p->setDest( dest ); insertPackage( p ); packEntry.clear(); } } }else{ packEntry << line; }; } //there might be no nl at the end of the package file if ( ! packEntry.isEmpty() ) { OipkgPackage *p = new OipkgPackage( packEntry, settings ); if ( p ) { p->setDest( dest ); insertPackage( p ); packEntry.clear(); } } delete statusStream; + f.close(); return; } void PackageList::setSettings( PackageManagerSettings *s ) { settings = s; } OipkgPackage* PackageList::getByName( QString n ) { return origPackageList[n]; } void PackageList::clear() { origPackageList.clear(); packageList.clear(); } void PackageList::allPackages() { packageList.clear(); QDictIterator<OipkgPackage> filterIter( origPackageList ); filterIter.toFirst(); OipkgPackage *pack= filterIter.current() ; while ( pack ) { packageList.insert( pack->name(), pack ); ++filterIter; pack = filterIter.current(); } } diff --git a/noncore/unsupported/oipkg/packagelistitem.cpp b/noncore/unsupported/oipkg/packagelistitem.cpp index 51d024b..1610a37 100644 --- a/noncore/unsupported/oipkg/packagelistitem.cpp +++ b/noncore/unsupported/oipkg/packagelistitem.cpp @@ -1,239 +1,240 @@ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ // (c) 2002 Patrick S. Vogt <tille@handhelds.org> #include "packagelistitem.h" #include <qpe/resource.h> #include <qobject.h> #include <qpopupmenu.h> #include <qaction.h> #include "debug.h" static QPixmap *pm_uninstalled=0; static QPixmap *pm_uninstalled_old=0; static QPixmap *pm_installed=0; static QPixmap *pm_installed_old=0; static QPixmap *pm_uninstall=0; static QPixmap *pm_install=0; static QPixmap *pm_uninstalled_old_installed_new=0; static QPixmap *pm_uninstalled_installed_old=0; 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) { init(pi,s); } PackageListItem::PackageListItem(ListViewItemOipkg *lvi, OipkgPackage *pi, PackageManagerSettings *s) : ListViewItemOipkg(lvi,pi->name(),ListViewItemOipkg::Package) { init(pi,s); } PackageListItem::~PackageListItem() { delete popupMenu; delete destsMenu; } void PackageListItem::init( OipkgPackage *pi, PackageManagerSettings *s) { + //waring pass something different than 0 popupMenu = new QPopupMenu( 0 ); destsMenu = new QPopupMenu( 0 ); package = pi; settings = s; setExpandable( true ); 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(); QDictIterator<QString> it( *fields ); while ( it.current() ) { item = new ListViewItemOipkg( otherItem, ListViewItemOipkg::Attribute, QString(it.currentKey()+": "+*it.current()) ); ++it; } displayDetails(); if (!pm_uninstalled) { pm_uninstalled = new QPixmap(Resource::loadPixmap("oipkg/uninstalled")); pm_uninstalled_old = new QPixmap(Resource::loadPixmap("oipkg/uninstalledOld")); pm_uninstalled_old_installed_new = new QPixmap(Resource::loadPixmap("oipkg/uninstalledOldinstalledNew")); pm_uninstalled_installed_old = new QPixmap(Resource::loadPixmap("oipkg/uninstalledInstalledOld")); pm_installed = new QPixmap(Resource::loadPixmap("oipkg/installed")); pm_installed_old = new QPixmap(Resource::loadPixmap("oipkg/installedOld")); pm_install = new QPixmap(Resource::loadPixmap("oipkg/install")); pm_uninstall = new QPixmap(Resource::loadPixmap("oipkg/uninstall")); } } void PackageListItem::paintCell( QPainter *p, const QColorGroup & cg, int column, int width, int alignment ) { if ( !p ) return; p->fillRect( 0, 0, width, height(), isSelected()? cg.highlight() : cg.base() ); if ( column != 0 ) { // The rest is text QListViewItem::paintCell( p, cg, column, width, alignment ); return; } QListView *lv = listView(); if ( !lv ) return; int marg = lv->itemMargin(); int r = marg; QPixmap pm = statePixmap(); p->drawPixmap(marg,(height()-pm.height())/2,pm); r += pm.width()+1; p->translate( r, 0 ); QListViewItem::paintCell( p, cg, column, width - r, alignment ); } void PackageListItem::paintFocus( QPainter *p, const QColorGroup & cg, const QRect & r ) { // Skip QCheckListItem // (makes you wonder what we're getting from QCheckListItem) QListViewItem::paintFocus(p,cg,r); } QPixmap PackageListItem::statePixmap() const { bool installed = package->installed(); bool old = package->isOld(); bool verinstalled = package->otherInstalled(); if ( !package->toProcess() ) { if ( !installed ) if (old) { if (verinstalled) return *pm_uninstalled_old_installed_new; else return *pm_uninstalled_old; } else { if (verinstalled) return *pm_uninstalled_installed_old; else return *pm_uninstalled; } else if (old) return *pm_installed_old; else return *pm_installed; } else { //toProcess() == true if ( !installed ) return *pm_install; else return *pm_uninstall; } } QString PackageListItem::key( int column, bool ascending ) const { if ( column == 2 ) { QString t = text(2); double bytes=t.toDouble(); if ( t.contains('M') ) bytes*=1024*1024; else if ( t.contains('K') || t.contains('k') ) bytes*=1024; if ( !ascending ) bytes=999999999-bytes; return QString().sprintf("%09d",(int)bytes); } else { return QListViewItem::key(column,ascending); } } void PackageListItem::setOn( bool b ) { QCheckListItem::setOn( b ); package->toggleProcess(); package->setLink( settings->createLinks() ); displayDetails(); } void PackageListItem::displayDetails() { QString sod; sod += package->sizeUnits().isEmpty()?QString(""):QString(package->sizeUnits()); //sod += QString(package->dest().isEmpty()?"":QObject::tr(" on ")+package->dest()); sod += package->dest().isEmpty()?QString(""):QString(QObject::tr(" on ")+package->dest()); sod = sod.isEmpty()?QString(""):QString(" ("+sod+")"); setText(0, package->name()+sod ); nameItem->setText( 0, QObject::tr("Name: ")+package->name()); linkItem->setText( 0, QObject::tr("Link: ")+(package->link()?QObject::tr("Yes"):QObject::tr("No"))); destItem->setText( 0, QObject::tr("Destination: ")+package->dest() ); statusItem->setText( 0, QObject::tr("Status: ")+package->status() ); repaint(); } 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(); //} |