author | tille <tille> | 2002-05-04 14:09:41 (UTC) |
---|---|---|
committer | tille <tille> | 2002-05-04 14:09:41 (UTC) |
commit | 27f8629d4e6e16e9a33410ffe650f4a6d0bb17be (patch) (side-by-side diff) | |
tree | 924a9449cff5d062d421f580644ea98ab8f42429 | |
parent | 4eddfebd1b4f70bbfe9106a16e9a3eeb6601f653 (diff) | |
download | opie-27f8629d4e6e16e9a33410ffe650f4a6d0bb17be.zip opie-27f8629d4e6e16e9a33410ffe650f4a6d0bb17be.tar.gz opie-27f8629d4e6e16e9a33410ffe650f4a6d0bb17be.tar.bz2 |
version handling
-rw-r--r-- | noncore/unsupported/oipkg/main.cpp | 2 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/mainwindow.cpp | 7 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/package.cpp | 58 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/package.h | 14 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/packagelist.cpp | 21 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/packagelist.h | 2 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/packagelistitem.cpp | 27 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/pmipkg.cpp | 9 | ||||
-rw-r--r-- | pics/oipkg/installedOld.png | bin | 0 -> 197 bytes | |||
-rw-r--r-- | pics/oipkg/uninstalledInstalledOld.png | bin | 0 -> 257 bytes | |||
-rw-r--r-- | pics/oipkg/uninstalledOld.png | bin | 0 -> 225 bytes | |||
-rw-r--r-- | pics/oipkg/uninstalledOldinstalledNew.png | bin | 0 -> 261 bytes |
12 files changed, 124 insertions, 16 deletions
diff --git a/noncore/unsupported/oipkg/main.cpp b/noncore/unsupported/oipkg/main.cpp index 4af11df..d98bcaa 100644 --- a/noncore/unsupported/oipkg/main.cpp +++ b/noncore/unsupported/oipkg/main.cpp @@ -1,24 +1,24 @@ #include "mainwindow.h" #include <qpe/qpeapplication.h> #include <qstring.h> #include <qmessagebox.h> int debugLevel; int main( int argc, char ** argv ) { debugLevel = 2; - if (argc > 0) + if (argc > 1) { debugLevel = QString ( argv[1] ).toInt(); qDebug("setting debug level to %i",debugLevel); } QPEApplication a( argc, argv ); MainWindow mw; if (argc > 2) QMessageBox::information( &mw, "oipkg","While ipkg is working\noipkg is hanging.\nPlease be patient!"); a.showMainDocumentWidget( &mw ); return a.exec(); } diff --git a/noncore/unsupported/oipkg/mainwindow.cpp b/noncore/unsupported/oipkg/mainwindow.cpp index 4f6e4cc..55f915d 100644 --- a/noncore/unsupported/oipkg/mainwindow.cpp +++ b/noncore/unsupported/oipkg/mainwindow.cpp @@ -4,114 +4,119 @@ #include "mainwindow.h" #include <qpe/qpemenubar.h> #include <qpe/qpemessagebox.h> #include <qpe/resource.h> #include <qpe/config.h> #include <qpe/qpetoolbar.h> #include <qpe/qcopenvelope_qws.h> #include <qaction.h> #include <qmessagebox.h> #include <qpopupmenu.h> #include <qtoolbutton.h> #include <qstring.h> #include <qlabel.h> #include <qfile.h> #include <qlistview.h> #include <qtextview.h> #include <qcheckbox.h> #include <qlineedit.h> #include <qtabwidget.h> #include <qcombobox.h> #include <qmessagebox.h> #include <qpushbutton.h> #include <qlayout.h> #include "pksettingsbase.h" #include "utils.h" #include "packagelistitem.h" MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f = 0 ) : QMainWindow( parent, name, f ) { setCaption( tr("Package Manager") ); settings = new PackageManagerSettings(this,0,TRUE); listViewPackages = new PackageListView( this,"listViewPackages",settings ); setCentralWidget( listViewPackages ); listViewPackages->addList( tr("feeds"), &packageListServers ); listViewPackages->addList( tr("ipkgfind"), &packageListSearch ); listViewPackages->addList( tr("documents"), &packageListDocLnk ); // wait = new QMessageBox(tr("oipkg"),tr("Please wait")//,QMessageBox::Information,QMessageBox::NoButton,QMessageBox::NoButton,QMessageBox::NoButton); // wait = new QMessageBox(this); // wait->setText(tr("Please wait")); ipkg = new PmIpkg( settings, this ); // settings->setIpkg( ipkg ); packageListServers.setSettings( settings ); packageListSearch.setSettings( settings ); packageListDocLnk.setSettings( settings ); + pvDebug(9,"packageListServers.update"); packageListServers.update(); + pvDebug(9,"packageListDocLnk.update"); packageListDocLnk.update(); + pvDebug(9,"makeMenu"); makeMenu(); makeChannel(); //opie is hardcoded default ;) + pvDebug(9,"section->setCurrentItem"); for (int i=0;i<section->count();i++) if (section->text(i)=="opie") section->setCurrentItem(i); sectionChanged(); connect( section, SIGNAL(activated(int)), SLOT(sectionChanged()) ); connect( subsection, SIGNAL(activated(int)), SLOT(subSectionChanged()) ); connect( settings->removeLinksButton, SIGNAL( clicked()), SLOT(removeLinks()) ); connect( settings->createLinksButton, SIGNAL( clicked()), SLOT(createLinks()) ); + pvDebug(9,"displayList"); displayList(); } void MainWindow::makeMenu() { QPEToolBar *toolBar = new QPEToolBar( this ); QPEMenuBar *menuBar = new QPEMenuBar( toolBar ); QPopupMenu *srvMenu = new QPopupMenu( menuBar ); QPopupMenu *viewMenu = new QPopupMenu( menuBar ); QPopupMenu *cfgMenu = new QPopupMenu( menuBar ); // QPopupMenu *sectMenu = new QPopupMenu( menuBar ); setToolBarsMovable( false ); toolBar->setHorizontalStretchable( true ); menuBar->insertItem( tr( "Package" ), srvMenu ); menuBar->insertItem( tr( "View" ), viewMenu ); menuBar->insertItem( tr( "Settings" ), cfgMenu ); // menuBar->insertItem( tr( "Sections" ), sectMenu ); QLabel *spacer = new QLabel( "", toolBar ); spacer->setBackgroundColor( toolBar->backgroundColor() ); toolBar->setStretchableWidget( spacer ); runAction = new QAction( tr( "Apply" ), Resource::loadPixmap( "oipkg/install" ), QString::null, 0, this, 0 ); connect( runAction, SIGNAL( activated() ), this, SLOT( runIpkg() ) ); runAction->addTo( toolBar ); runAction->addTo( srvMenu ); srvMenu->insertSeparator (); updateAction = new QAction( tr( "Update" ), Resource::loadIconSet( "oipkg/update" ), QString::null, 0, this, 0 ); connect( updateAction, SIGNAL( activated() ), this , SLOT( updateList() ) ); updateAction->addTo( toolBar ); updateAction->addTo( srvMenu ); QAction *cfgact; cfgact = new QAction( tr( "Setups" ), QString::null, 0, this, 0 ); connect( cfgact, SIGNAL( activated() ), @@ -191,104 +196,102 @@ void MainWindow::makeMenu() searchCommit->addTo( searchBar ); a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( searchClose() ) ); a->addTo( searchBar ); searchAction = new QAction( tr( "Search" ), QString::null, 0, this, 0 ); connect( searchAction, SIGNAL( toggled(bool) ), this, SLOT( searchShow(bool) ) ); searchAction->setToggleAction( true ); searchAction->addTo( viewMenu ); //DEST destBar = new QPEToolBar(this); addToolBar( destBar, "Destination", QMainWindow::Top, TRUE ); label = new QLabel( tr("Destination: "), destBar ); label->setBackgroundColor( destBar->backgroundColor() ); destBar->setHorizontalStretchable( TRUE ); destination = new QComboBox( false, destBar ); destination->insertStringList( settings->getDestinationNames() ); setComboName(destination,settings->getDestinationName()); connect( destination, SIGNAL(activated(int)), settings, SLOT(activeDestinationChange(int)) ); spacer = new QLabel( " ", destBar ); spacer->setBackgroundColor( destBar->backgroundColor() ); CheckBoxLink = new QCheckBox( tr("Link"), destBar); CheckBoxLink->setBackgroundColor( destBar->backgroundColor() ); CheckBoxLink->setChecked( settings->createLinks() ); connect( CheckBoxLink, SIGNAL(toggled(bool)), settings, SLOT(linkEnabled(bool)) ); destAction = new QAction( tr( "Destinations" ), QString::null, 0, this, 0 ); connect( destAction, SIGNAL( toggled(bool) ), SLOT( destShow(bool) ) ); a = new QAction( tr( "Close Destinations" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), SLOT( destClose() ) ); a->addTo( destBar ); destBar->setStretchableWidget( CheckBoxLink ); destAction->setToggleAction( true ); // destAction->addTo( viewMenu ); // configure the menus Config cfg( "oipkg", Config::User ); cfg.setGroup( "gui" ); findShow( cfg.readBoolEntry( "findBar", true ) ); searchShow( cfg.readBoolEntry( "searchBar", true ) ); sectionShow( cfg.readBoolEntry( "sectionBar", true ) ); destShow( cfg.readBoolEntry( "destBar", false ) ); } MainWindow::~MainWindow() { - pvDebug(7,"MainWindow::~MainWindow "); Config cfg( "oipkg", Config::User ); cfg.setGroup( "gui" ); cfg.writeEntry( "findBar", !findBar->isHidden() ); cfg.writeEntry( "searchBar", !searchBar->isHidden() ); cfg.writeEntry( "sectionBar", !sectionBar->isHidden() ); cfg.writeEntry( "destBar", !destBar->isHidden() ); - pvDebug(7,"MainWindow::~MainWindow "); } void MainWindow::runIpkg() { packageListServers.allPackages(); ipkg->loadList( &packageListSearch ); ipkg->loadList( &packageListDocLnk ); ipkg->loadList( &packageListServers ); ipkg->commit(); // ##### If we looked in the list of files, we could send out accurate // ##### messages. But we don't bother yet, and just do an "all". QCopEnvelope e("QPE/System", "linkChanged(QString)"); QString lf = QString::null; e << lf; displayList(); } void MainWindow::updateList() { // wait->show(); QTimer *t = new QTimer( this ); connect( t, SIGNAL(timeout()), SLOT( rotateUpdateIcon() ) ); t->start( 0, false ); packageListServers.clear(); packageListSearch.clear(); packageListDocLnk.clear(); ipkg->update(); packageListServers.update(); packageListSearch.update(); packageListDocLnk.update(); t->stop(); // wait->hide(); } void MainWindow::filterList() { // wait->show(); QString f = ""; if ( findAction->isOn() ) f = findEdit->text(); packageListServers.filterPackages( f ); // wait->hide(); } void MainWindow::displayList() { // wait->hide(); filterList(); diff --git a/noncore/unsupported/oipkg/package.cpp b/noncore/unsupported/oipkg/package.cpp index 9280d89..c947c64 100644 --- a/noncore/unsupported/oipkg/package.cpp +++ b/noncore/unsupported/oipkg/package.cpp @@ -1,179 +1,208 @@ #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" //Package::~Package() //{ //} Package::Package( PackageManagerSettings *s ) { init(s); } void Package::init( PackageManagerSettings *s ) { settings = s; _size = ""; _section = ""; _subsection = ""; _shortDesc = ""; _desc = ""; _name = ""; _toProcess = false; _useFileName = false; + _old = false; _status = ""; _dest = settings->getDestinationName(); _link = settings->createLinks(); + _versions=0; } Package::Package( QStringList pack, PackageManagerSettings *s ) { init(s); parsePackage( pack ); } Package::Package( QString n, PackageManagerSettings *s ) { init(s); if ( !QFile::exists( n ) ) { _name = QString( n ); }else{ parseIpkgFile( n ); _useFileName = true; _fileName = QString( n ); } } Package::Package( Package *pi ) { init(pi->settings); copyValues( pi ); } void Package::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 Package::name() { if (_displayName.isEmpty() ) return _name; else return _displayName; } QString Package::installName() { if (_useFileName) return _fileName; else return _name; } bool Package::installed() { - return _status.contains("installed"); + if (_status.contains("installed")) return true; + else + if (_versions) + { + QDictIterator<Package> other( *_versions ); + while ( other.current() ) + { + if (other.current()->status().contains("installed") + && other.current()->version() == version()) + return true; + ++other; + } + } + return false; +} + +bool Package::otherInstalled() +{ + if (_versions) + { + QDictIterator<Package> other( *_versions ); + while ( other.current() ) + { + if (other.current()->installed()) return true; + ++other; + } + } + return false; } void Package::setDesc( QString s ) { _desc = s; _shortDesc = s.left( s.find("\n") ); } QString Package::desc() { return _desc; } QString Package::shortDesc() { return _shortDesc; } QString Package::size() { return _size; } QString Package::version() { return _version; } QString Package::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 Package::toProcess() { return _toProcess; @@ -325,48 +354,75 @@ void Package::setLink(bool b) { _link = b; } void Package::parseIpkgFile( QString file) { 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 Package::getPackageName() //{ // if ( _packageName.isEmpty() ) return _name; // else return _packageName; //} void Package::instalFromFile(bool iff) { _useFileName = iff; } void Package::setName(QString n) { _displayName = n; } QDict<QString>* Package::getFields() { return &_values; } QString Package::status() { return _status; } + +bool Package::isOld() +{ + if (!_versions) return false; + QDictIterator<Package> other( *_versions ); + while ( other.current() ) { + if (other.current()->version() > version() ) return true; + ++other; + } + return false; +} + +bool Package::hasVersions() +{ + if (!_versions) return false; + else return true; +} + +QDict<Package>* Package::getOtherVersions() +{ + return _versions; +} + +void Package::setOtherVersions(QDict<Package> *v) +{ + _versions=v; +} diff --git a/noncore/unsupported/oipkg/package.h b/noncore/unsupported/oipkg/package.h index 257d9c7..68090dc 100644 --- a/noncore/unsupported/oipkg/package.h +++ b/noncore/unsupported/oipkg/package.h @@ -1,79 +1,89 @@ #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 Package //: public QObject { // Q_OBJECT public: Package(PackageManagerSettings *); // ~Package(); Package( QStringList, PackageManagerSettings * ); Package( QString, PackageManagerSettings * ); Package( Package* ); void setValue( QString, QString ); void copyValues( Package* ); - QString name() ; - QString installName() ; + QString name(); + QString installName(); 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<Package>* getOtherVersions(); + void setOtherVersions(QDict<Package>*); + 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<Package> *_versions; bool _useFileName; void parsePackage( QStringList ); void init(PackageManagerSettings *); }; #endif diff --git a/noncore/unsupported/oipkg/packagelist.cpp b/noncore/unsupported/oipkg/packagelist.cpp index be20c71..2fc4c41 100644 --- a/noncore/unsupported/oipkg/packagelist.cpp +++ b/noncore/unsupported/oipkg/packagelist.cpp @@ -1,99 +1,114 @@ #include "packagelist.h" #include <assert.h> #include <qfile.h> #include <qfileinfo.h> #include <qtextstream.h> #include "debug.h" +static QDict<Package> *packageListAll; + PackageList::PackageList() : packageIter( packageList ) { empty=true; + if (!packageListAll) packageListAll = new QDict<Package>(); sections << "All"; subSections.insert("All", new QStringList() ); QStringList *ss = subSections["All"]; *ss << "All"; aktSection = "All"; aktSubSection = "All"; } PackageList::PackageList( PackageManagerSettings* s) : packageIter( packageList ) { settings = s; PackageList(); } PackageList::~PackageList() { } /** Inserts a package into the list */ void PackageList::insertPackage( Package* pack ) { if (!pack) return; - Package* p = packageList.find( pack->name() ); + Package* p = packageListAll->find( pack->name() ); if ( p ) { - if ( p->version() == pack->version() ) + if ( (p->version() == pack->version()) + && (p->dest() == pack->dest()) ) { p->copyValues( pack ); delete pack; pack = p; } else { - p->setName( pack->name()+"["+p->version()+"]" ); + QDict<Package> *packver = p->getOtherVersions(); +// p->setName( pack->name()+"["+p->version()+"]" ); + if (!packver) + { + packver = new QDict<Package>; + 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<Package> filterIter( origPackageList ); filterIter.toFirst(); Package *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(); } } Package* PackageList::find( QString n ) { return packageList.find( n ); } Package* PackageList::first() { packageIter.toFirst(); return packageIter.current(); } Package* PackageList::next() { ++packageIter; return packageIter.current(); } QStringList PackageList::getSections() { sections.sort(); diff --git a/noncore/unsupported/oipkg/packagelist.h b/noncore/unsupported/oipkg/packagelist.h index acea3b9..d0f8897 100644 --- a/noncore/unsupported/oipkg/packagelist.h +++ b/noncore/unsupported/oipkg/packagelist.h @@ -1,58 +1,60 @@ #ifndef PACKAGELIST_H #define PACKAGELIST_H #include <qdict.h> #include "package.h" #include "pksettings.h" #include "debug.h" class PackageList //:QObject { // Q_OBJECT public: // static QString all = QObject::tr("All"); PackageList(); PackageList( PackageManagerSettings* ); virtual ~PackageList(); void insertPackage( Package* ); Package* find( QString ); Package* next(); Package* first(); QStringList getSections(); QStringList getSubSections(); void setSettings( PackageManagerSettings* ); void filterPackages( QString ); Package* getByName( QString ); void clear(); void allPackages(); + QDict<Package> *versions; + public slots: void setSection(QString); void setSubSection(QString); // virtual void update(); protected: int currentPackage; int packageCount; PackageManagerSettings *settings; QDict<Package> packageList; QDict<Package> origPackageList; QDictIterator<Package> packageIter; bool empty; QString aktSection; QString aktSubSection; QStringList sections; QDict<QStringList> subSections; QDict<bool> sectionsDict; void updateSections( Package* ); void readFileEntries( QString file, QString dest="" ); }; #endif diff --git a/noncore/unsupported/oipkg/packagelistitem.cpp b/noncore/unsupported/oipkg/packagelistitem.cpp index 45aaf1d..c743a49 100644 --- a/noncore/unsupported/oipkg/packagelistitem.cpp +++ b/noncore/unsupported/oipkg/packagelistitem.cpp @@ -1,144 +1,165 @@ #include "packagelistitem.h" #include <qpe/resource.h> #include <qobject.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(QListView* lv, Package *pi, PackageManagerSettings *s) : QCheckListItem(lv,pi->name(),CheckBox) { init(pi,s); } PackageListItem::PackageListItem(QListViewItem *lvi, Package *pi, PackageManagerSettings *s) : QCheckListItem(lvi,pi->name(),CheckBox) { init(pi,s); } void PackageListItem::init( Package *pi, PackageManagerSettings *s) { package = pi; settings = s; setExpandable( true ); QCheckListItem *item; nameItem = new QCheckListItem( this, "" ); 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("Description: ")+pi->desc() ); QDict<QString> *fields = pi->getFields(); QDictIterator<QString> it( *fields ); while ( it.current() ) { item = new QCheckListItem( otherItem, 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 versions = package->hasVersions(); + bool verinstalled = package->otherInstalled(); if ( !package->toProcess() ) { if ( !installed ) - return *pm_uninstalled; + 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 - return *pm_installed; - } 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: ")+QString(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(); } diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp index 0ae74da..5996e63 100644 --- a/noncore/unsupported/oipkg/pmipkg.cpp +++ b/noncore/unsupported/oipkg/pmipkg.cpp @@ -1,123 +1,124 @@ #include "pmipkg.h" #include "pksettings.h" #include "package.h" #include "packagelistitem.h" #include <qpe/process.h> #include <qpe/resource.h> #include <qpe/config.h> #include <qpe/stringutil.h> #include <qdir.h> #include <qfile.h> #include <qgroupbox.h> #include <qmultilineedit.h> #include <qstring.h> #include <qcheckbox.h> #include <qtextstream.h> #include <qtextview.h> #include <qprogressbar.h> #include <qpushbutton.h> #include <qlayout.h> #include <stdlib.h> #include <unistd.h> #include "mainwindow.h" PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f ) : QObject ( p ) { settings = s; runwindow = new RunWindow( p, name, true, f ); } PmIpkg::~PmIpkg() { } //#define PROC #define SYSTEM +#define QT_QPROCESS_DEBUG int PmIpkg::runIpkg(const QString& args, const QString& dest ) { pvDebug(2,"PmIpkg::runIpkg "+args); - + QDir::setCurrent("/tmp"); #ifdef PROC - QStringList cmd = "ipkg "; + QString cmd; #endif #ifdef SYSTEM QString cmd = "/usr/bin/ipkg "; #endif pvDebug( 3,"PmIpkg::runIpkg got dest="+dest); if ( dest == "" ) cmd += " -dest "+settings->getDestinationName(); else cmd += " -dest "+ dest; cmd += " -force-defaults "; if (installDialog->_force_depends) { if (installDialog->_force_depends->isChecked()) cmd += " -force-depends "; if (installDialog->_force_reinstall->isChecked()) cmd += " -force-reinstall "; if (installDialog->_force_remove->isChecked()) cmd += " -force-removal-of-essential-packages "; } out( "<hr><br>Starting to "+ args+"<br>\n"); cmd += args; int r = 0; #ifdef PROC QString o = "start"; - Process *ipkg = new Process( cmd ); + Process *ipkg = new Process(QStringList() << "ipkg" << cmd ); out( "running:<br>\n"+ipkg->arguments().join(" ")+"<br>\n" ); QString description; r = ipkg->exec("",o); out( o ); #endif #ifdef SYSTEM out( "running:<br>\n"+cmd+"<br>\n" ); QString redirect = "/tmp/oipkg.pipe"; cmd += " 2>&1 | tee "+redirect+" 2>&1"; pvDebug(2, "running >"+cmd+"<"); r = system(cmd.latin1()); QFile f( redirect ); QString line; QString oldLine; while ( ! f.open(IO_ReadOnly) ) {}; QTextStream t( &f ); while ( !t.eof() ) { line = t.readLine(); if ( line != oldLine ) { out( line +"<br>" ); oldLine = line; } } f.close(); out( "Finished!<br>"); #endif return r; } void PmIpkg::makeLinks(Package *pack) { pvDebug( 2, "PmIpkg::makeLinks "+ pack->name()); linkPackage( pack->name(), pack->dest() ); } QStringList* PmIpkg::getList( QString packFileName, QString d ) { QString dest = settings->getDestinationUrlByName( d ); dest = dest==""?d:dest; if (dest == "/" ) return 0; { Config cfg( "oipkg", Config::User ); cfg.setGroup( "Common" ); QString statusDir = cfg.readEntry( "statusDir", "" ); } @@ -252,97 +253,97 @@ void PmIpkg::doIt() { show( true ); remove(); install(); } void PmIpkg::remove() { if ( to_remove.count() == 0 ) return; out("<b>"+tr("Removing")+"<br>"+tr("please wait")+"</b><br><hr>"); QStringList *fileList; for (uint i=0; i < to_remove.count(); i++) { if ( to_remove.at(i)->link() )fileList = getList( to_remove.at(i)->name(), to_remove.at(i)->dest() ); if ( runIpkg("remove " + to_remove.at(i)->name(), to_remove.at(i)->dest() ) == 0) { runwindow->progress->setProgress( 1 ); linkOpp = removeLink; if ( to_remove.at(i)->link() ) { out( "<br>removing links<br>" ); out( "for package "+to_remove.at(i)->name()+" in "+to_remove.at(i)->dest()+"<br>" ); processFileList( fileList, to_remove.at(i)->dest() ); } to_remove.at(i)->processed(); to_remove.take( i ); out("<br><hr>"); }else{ out("<b>"+tr("Error while removing")+"</b><hr>"+to_remove.at(i)->name()); } if ( to_remove.at(i)->link() )delete fileList; } to_remove.clear(); out("<br>"); } void PmIpkg::install() { if ( to_install.count() == 0 ) return; out("<b>"+tr("Installing")+"<br>"+tr("please wait")+"</b><br>"); for (uint i=0; i < to_install.count(); i++) { if ( runIpkg("install " + to_install.at(i)->installName(), to_install.at(i)->dest() ) == 0 ) { - runwindow->progress->setProgress( to_install.at(i)->size().toInt() ); + runwindow->progress->setProgress( to_install.at(i)->size().toInt() + runwindow->progress->progress()); linkOpp = createLink; if ( to_install.at(i)->link() ) { out( "<br>creating links<br>" ); out( "for package "+to_install.at(i)->name()+" in "+to_install.at(i)->dest()+"<br>" ); makeLinks( to_install.at(i) ); } to_install.at(i)->processed(); to_install.take( i ); out("<br><hr>"); }else{ out("<b>"+tr("Error while installing")+"</b><hr>"+to_install.at(i)->name()); } } out("<br>"); to_install.clear(); } void PmIpkg::createLinks( const QString &dest ) { pvDebug(2,"PmIpkg::createLinks "+dest); linkOpp=createLink; QString url = settings->getDestinationUrlByName( dest ); url = url==""?dest:url; processLinkDir( "/opt", url ); processLinkDir( "/usr", url ); } void PmIpkg::removeLinks( const QString &dest ) { pvDebug(2,"PmIpkg::removeLinks "+dest); linkOpp=removeLink; QString url = settings->getDestinationUrlByName( dest ); url = url==""?dest:url; processLinkDir( "/opt", url ); processLinkDir( "/usr", url ); } void PmIpkg::update() { show( false ); runIpkg( "update" ); runwindow->close(); } void PmIpkg::out( QString o ) { runwindow->outPut->append(o); diff --git a/pics/oipkg/installedOld.png b/pics/oipkg/installedOld.png Binary files differnew file mode 100644 index 0000000..8a042fc --- a/dev/null +++ b/pics/oipkg/installedOld.png diff --git a/pics/oipkg/uninstalledInstalledOld.png b/pics/oipkg/uninstalledInstalledOld.png Binary files differnew file mode 100644 index 0000000..f369c63 --- a/dev/null +++ b/pics/oipkg/uninstalledInstalledOld.png diff --git a/pics/oipkg/uninstalledOld.png b/pics/oipkg/uninstalledOld.png Binary files differnew file mode 100644 index 0000000..5dce3ea --- a/dev/null +++ b/pics/oipkg/uninstalledOld.png diff --git a/pics/oipkg/uninstalledOldinstalledNew.png b/pics/oipkg/uninstalledOldinstalledNew.png Binary files differnew file mode 100644 index 0000000..3bfe126 --- a/dev/null +++ b/pics/oipkg/uninstalledOldinstalledNew.png |