summaryrefslogtreecommitdiff
authortille <tille>2002-11-10 22:50:50 (UTC)
committer tille <tille>2002-11-10 22:50:50 (UTC)
commit9337c912158da3ad2fcda7ee1120c9357faddf8b (patch) (side-by-side diff)
treec5800efad3f90cfc9901db0337039eb883c0cf28
parentf6cabaaa364ee6d894462c0902734e434715fc58 (diff)
downloadopie-9337c912158da3ad2fcda7ee1120c9357faddf8b.zip
opie-9337c912158da3ad2fcda7ee1120c9357faddf8b.tar.gz
opie-9337c912158da3ad2fcda7ee1120c9357faddf8b.tar.bz2
here it's...
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/oipkg/listviewitemoipkg.cpp38
-rw-r--r--noncore/unsupported/oipkg/listviewitemoipkg.h33
-rw-r--r--noncore/unsupported/oipkg/mainwindow.h1
-rw-r--r--noncore/unsupported/oipkg/oipkg.pro4
-rw-r--r--noncore/unsupported/oipkg/package.cpp100
-rw-r--r--noncore/unsupported/oipkg/package.h22
-rw-r--r--noncore/unsupported/oipkg/packagelist.cpp34
-rw-r--r--noncore/unsupported/oipkg/packagelist.h20
-rw-r--r--noncore/unsupported/oipkg/packagelistdoclnk.cpp2
-rw-r--r--noncore/unsupported/oipkg/packagelistitem.cpp159
-rw-r--r--noncore/unsupported/oipkg/packagelistitem.h32
-rw-r--r--noncore/unsupported/oipkg/packagelistlocal.cpp2
-rw-r--r--noncore/unsupported/oipkg/packagelistview.cpp141
-rw-r--r--noncore/unsupported/oipkg/packagelistview.h17
-rw-r--r--noncore/unsupported/oipkg/pmipkg.cpp10
-rw-r--r--noncore/unsupported/oipkg/pmipkg.h8
16 files changed, 370 insertions, 253 deletions
diff --git a/noncore/unsupported/oipkg/listviewitemoipkg.cpp b/noncore/unsupported/oipkg/listviewitemoipkg.cpp
new file mode 100644
index 0000000..30b5a5e
--- a/dev/null
+++ b/noncore/unsupported/oipkg/listviewitemoipkg.cpp
@@ -0,0 +1,38 @@
+#include "listviewitemoipkg.h"
+#include "packagelistview.h"
+
+#include <qlistview.h>
+
+ListViewItemOipkg::ListViewItemOipkg(QListView *parent, QString name, QCheckListItem::Type qct, Type type)
+ : QCheckListItem(parent,name,qct)
+{
+ _type = type;
+}
+ListViewItemOipkg::ListViewItemOipkg(QListView *parent, QString name, Type type)
+ : QCheckListItem(parent,name,CheckBox)
+{
+ _type = type;
+}
+
+ListViewItemOipkg::ListViewItemOipkg(ListViewItemOipkg *parent, QString name, Type type)
+ : QCheckListItem(parent,name,CheckBox)
+{
+ _type = type;
+}
+
+ListViewItemOipkg::ListViewItemOipkg(PackageListView *parent, QString name, Type type)
+ : QCheckListItem(parent,name,Controller)
+{
+ _type = type;
+}
+
+ListViewItemOipkg::ListViewItemOipkg(ListViewItemOipkg *parent, Type type, QString name)
+ : QCheckListItem(parent,name,Controller)
+{
+ _type = type;
+}
+
+ListViewItemOipkg::~ListViewItemOipkg()
+{
+// delete _popupMenu;
+}
diff --git a/noncore/unsupported/oipkg/listviewitemoipkg.h b/noncore/unsupported/oipkg/listviewitemoipkg.h
new file mode 100644
index 0000000..4f7d2d7
--- a/dev/null
+++ b/noncore/unsupported/oipkg/listviewitemoipkg.h
@@ -0,0 +1,33 @@
+#ifndef LISTVIEWITEMOIPKG_H
+#define LISTVIEWITEMOIPKG_H
+
+#include <qpopupmenu.h>
+#include <qstring.h>
+#include <qlistview.h>
+#include <qcheckbox.h>
+
+class PackageListItem;
+class PackageListView;
+
+class ListViewItemOipkg : public QObject, public QCheckListItem
+{
+Q_OBJECT
+public:
+ enum Type {Package, Feed, Attribute};
+
+ ListViewItemOipkg(QListView *parent, QString name, QCheckListItem::Type qct, Type type); ListViewItemOipkg(QListView *parent, QString name, Type type);
+ ListViewItemOipkg(ListViewItemOipkg *parent, QString name, Type type);
+ ListViewItemOipkg(PackageListView *parent, QString name, Type type);
+ ListViewItemOipkg(ListViewItemOipkg *parent, Type type, QString name);
+ ~ListViewItemOipkg();
+
+ int getType() {return _type;};
+ virtual QPopupMenu* getPopupMenu() {return 0;};
+protected slots:
+ virtual void menuAction(int ) {};
+protected:
+ int _type;
+ static QPopupMenu* _popupMenu;
+};
+
+#endif
diff --git a/noncore/unsupported/oipkg/mainwindow.h b/noncore/unsupported/oipkg/mainwindow.h
index 354c585..f32352b 100644
--- a/noncore/unsupported/oipkg/mainwindow.h
+++ b/noncore/unsupported/oipkg/mainwindow.h
@@ -9,24 +9,25 @@
// Copyright (C) 2000 Trolltech AS.
// adadpted form qpe/qipkg
// (c) 2002 Patrick S. Vogt <tille@handhelds.org>
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <qmainwindow.h>
#include <qaction.h>
#include <qtimer.h>
#include <qpopupmenu.h>
+#include "package.h"
#include "packagelist.h"
#include "packagelistremote.h"
#include "packagelistlocal.h"
#include "packagelistdoclnk.h"
#include "pmipkg.h"
#include "pksettings.h"
#include "packagelistview.h"
class QComboBox;
class QPEToolBar;
class QLineEdit;
class PackageListItem;
diff --git a/noncore/unsupported/oipkg/oipkg.pro b/noncore/unsupported/oipkg/oipkg.pro
index 986cbcd..230df2c 100644
--- a/noncore/unsupported/oipkg/oipkg.pro
+++ b/noncore/unsupported/oipkg/oipkg.pro
@@ -1,47 +1,49 @@
DESTDIR = $(OPIEDIR)/bin
TEMPLATE = app
#CONFIG = qt warn_on release
CONFIG = qt warn_on debug
HEADERS = mainwindow.h \
pksettings.h \
pmipkg.h \
packagelistdoclnk.h \
installdialog.h \
utils.h \
+ listviewitemoipkg.h \
packagelistitem.h \
packagelistremote.h \
packagelist.h \
packagelistlocal.h \
packagelistview.h \
package.h
SOURCES = main.cpp \
mainwindow.cpp \
utils.cpp \
packagelistdoclnk.cpp \
packagelistview.cpp \
installdialog.cpp \
+ listviewitemoipkg.cpp \
packagelistremote.cpp \
packagelistlocal.cpp \
pksettings.cpp \
pmipkg.cpp \
packagelistitem.cpp \
packagelist.cpp \
package.cpp
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/ioclude
LIBS += -lqpe
LIBS += -lopie
INTERFACES = runwindow.ui \
- pksettingsbase.ui
+ pksettingsbase.ui
TARGET = oipkg
TRANSLATIONS = ../../../i18n/de/oipkg.ts \
../../../i18n/en/oipkg.ts \
../../../i18n/es/oipkg.ts \
../../../i18n/fr/oipkg.ts \
../../../i18n/hu/oipkg.ts \
../../../i18n/ja/oipkg.ts \
../../../i18n/ko/oipkg.ts \
../../../i18n/no/oipkg.ts \
../../../i18n/pl/oipkg.ts \
../../../i18n/pt/oipkg.ts \
diff --git a/noncore/unsupported/oipkg/package.cpp b/noncore/unsupported/oipkg/package.cpp
index 3effb73..e020601 100644
--- a/noncore/unsupported/oipkg/package.cpp
+++ b/noncore/unsupported/oipkg/package.cpp
@@ -9,91 +9,90 @@
// (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"
-Package::Package( QObject *parent, const char *name )
+OipkgPackage::OipkgPackage( QObject *parent, const char *name )
: QObject(parent,name)
{
}
-Package::~Package()
+OipkgPackage::~OipkgPackage()
{
}
-Package::Package( PackageManagerSettings *s, QObject *parent, const char *name )
+OipkgPackage::OipkgPackage( PackageManagerSettings *s, QObject *parent, const char *name )
: QObject(parent,name)
-{
- Package(parent,name);
+{
init(s);
}
-void Package::init( PackageManagerSettings *s )
+void OipkgPackage::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;
_version="";
}
-Package::Package( QStringList pack, PackageManagerSettings *s , QObject *parent, const char *name )
+OipkgPackage::OipkgPackage( QStringList pack, PackageManagerSettings *s , QObject *parent, const char *name )
: QObject(parent,name)
{
init(s);
parsePackage( pack );
}
-Package::Package( QString n, PackageManagerSettings *s, QObject *parent, const char *name )
+OipkgPackage::OipkgPackage( QString n, PackageManagerSettings *s, QObject *parent, const char *name )
: QObject(parent,name)
{
init(s);
if ( !QFile::exists( n ) )
{
_name = QString( n );
}else{
pvDebug(4,"remote file: "+n);
parseIpkgFile( n );
_useFileName = true;
_fileName = QString( n );
}
}
-Package::Package( Package *pi, QObject *parent, const char *name )
+OipkgPackage::OipkgPackage( OipkgPackage *pi, QObject *parent, const char *name )
: QObject(parent,name)
{
init(pi->settings);
copyValues( pi );
}
-void Package::setValue( QString n, QString t )
+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")
{
@@ -128,211 +127,210 @@ void Package::setValue( QString n, QString t )
}else if ( n == "Status")
{
if ( installed() ) return;
_status = t;
// }else if ( n == "Essential")
// {
}else{
_values.insert(n,new QString(t));
}
}
-QString Package::name()
+QString OipkgPackage::name()
{
if (_displayName.isEmpty() ) return _name;
else return _displayName;
}
-QString Package::installName()
+QString OipkgPackage::installName()
{
if (_useFileName) return _fileName;
else return _name;
}
-QString Package::packageName()
+QString OipkgPackage::packageName()
{
QString pn = installName();
pn = pn.right(pn.length()-pn.findRev("/"));
pn = pn.left(pn.find("_"));
return pn;
}
-bool Package::installed()
+bool OipkgPackage::installed()
{
if (_status.contains("installed"))
{
if (_status.contains("not-installed"))
{
_toProcess = true;
return false;
}
else return true;
}
else
if (_versions)
{
- QDictIterator<Package> other( *_versions );
+ QDictIterator<OipkgPackage> other( *_versions );
while ( other.current() )
{
if (other.current()->status().contains("installed")
&& other.current()->version() == version())
return true;
++other;
}
}
return false;
}
-bool Package::otherInstalled()
+bool OipkgPackage::otherInstalled()
{
if (_versions)
{
- QDictIterator<Package> other( *_versions );
+ QDictIterator<OipkgPackage> other( *_versions );
while ( other.current() )
{
if (other.current()->installed()) return true;
++other;
}
}
return false;
}
-void Package::setDesc( QString s )
+void OipkgPackage::setDesc( QString s )
{
_desc = s;
_shortDesc = s.left( s.find("\n") );
}
-QString Package::desc()
+QString OipkgPackage::desc()
{
return _desc;
}
-QString Package::shortDesc()
+QString OipkgPackage::shortDesc()
{
return _shortDesc;
}
-QString Package::size()
+QString OipkgPackage::size()
{
return _size;
}
-QString Package::version()
+QString OipkgPackage::version()
{
return _version;
}
-QString Package::sizeUnits()
+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 Package::toProcess()
+bool OipkgPackage::toProcess()
{
return _toProcess;
}
-bool Package::toRemove()
+bool OipkgPackage::toRemove()
{
if ( _toProcess && installed() ) return true;
else return false;
}
-bool Package::toInstall()
+bool OipkgPackage::toInstall()
{
if ( _toProcess && !installed() ) return true;
else return false;
}
-void Package::toggleProcess()
+void OipkgPackage::toggleProcess()
{
_toProcess = ! _toProcess;
}
-
-void Package::copyValues( Package* pack )
+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 Package::section()
+QString OipkgPackage::section()
{
return _section;
}
-void Package::setSection( QString s)
+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 Package::subSection()
+QString OipkgPackage::subSection()
{
return _subsection;
}
-void Package::parsePackage( QStringList pack )
+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 Package::details()
+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>");
@@ -353,62 +351,62 @@ QString Package::details()
description.append(":</b> ");
description.append(Qtopia::escapeString(line.mid(sep+2)));
} else {
description.append(" ");
description.append(Qtopia::escapeString(line));
}
}
}
}
return description;
}
-void Package::processed()
+void OipkgPackage::processed()
{
_toProcess = false;
//hack, but we're not writing status anyway...
if ( installed() ) _status = "install";
else _status = "installed";
}
-QString Package::dest()
+QString OipkgPackage::dest()
{
if ( installed()||(!installed() && _toProcess) )
return _dest!=""?_dest:settings->getDestinationName();
else return "";
}
-void Package::setDest( QString d )
+void OipkgPackage::setDest( QString d )
{
if ( d == "remote") _useFileName = true;
else _dest = d;
}
-void Package::setOn()
+void OipkgPackage::setOn()
{
_toProcess = true;
}
-bool Package::link()
+bool OipkgPackage::link()
{
if ( _dest == "root" || (!installed() && !_toProcess) ) return false;
return _link;
}
-void Package::setLink(bool b)
+void OipkgPackage::setLink(bool b)
{
_link = b;
}
-void Package::parseIpkgFile( QString file)
+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) )
@@ -416,64 +414,64 @@ void Package::parseIpkgFile( QString file)
QTextStream t( &f );
QStringList pack;
while ( !t.eof() )
{
pack << t.readLine();
}
f.close();
parsePackage( pack );
}
}
-//QString Package::getPackageName()
+//QString OipkgPackage::getPackageName()
//{
// if ( _packageName.isEmpty() ) return _name;
// else return _packageName;
//}
-void Package::instalFromFile(bool iff)
+void OipkgPackage::instalFromFile(bool iff)
{
_useFileName = iff;
}
-void Package::setName(QString n)
+void OipkgPackage::setName(QString n)
{
_displayName = n;
}
-QDict<QString>* Package::getFields()
+QDict<QString>* OipkgPackage::getFields()
{
return &_values;
}
-QString Package::status()
+QString OipkgPackage::status()
{
return _status;
}
-bool Package::isOld()
+bool OipkgPackage::isOld()
{
if (!_versions) return false;
- QDictIterator<Package> other( *_versions );
+ QDictIterator<OipkgPackage> other( *_versions );
while ( other.current() ) {
if (other.current()->version() > version() ) return true;
++other;
}
return false;
}
-bool Package::hasVersions()
+bool OipkgPackage::hasVersions()
{
if (!_versions) return false;
else return true;
}
-QDict<Package>* Package::getOtherVersions()
+QDict<OipkgPackage>* OipkgPackage::getOtherVersions()
{
return _versions;
}
-void Package::setOtherVersions(QDict<Package> *v)
+void OipkgPackage::setOtherVersions(QDict<OipkgPackage> *v)
{
_versions=v;
}
diff --git a/noncore/unsupported/oipkg/package.h b/noncore/unsupported/oipkg/package.h
index c147420..2334c31 100644
--- a/noncore/unsupported/oipkg/package.h
+++ b/noncore/unsupported/oipkg/package.h
@@ -10,37 +10,37 @@
#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
+class OipkgPackage : public QObject
{
Q_OBJECT
public:
- Package(QObject *parent=0, const char *name=0);
- Package(PackageManagerSettings *s, QObject *parent=0, const char *name=0);
- ~Package();
- Package( QStringList, PackageManagerSettings *s, QObject *parent=0, const char *name=0 );
- Package( QString, PackageManagerSettings *s, QObject *parent=0, const char *name=0 );
- Package( Package*s, QObject *parent=0, const char *name=0 );
+ 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( Package* );
+ void copyValues( OipkgPackage* );
QString name();
QString installName();
QString packageName();
bool installed();
bool otherInstalled();
void setDesc( QString );
QString shortDesc();
QString desc();
QString size();
QString sizeUnits();
@@ -57,44 +57,44 @@ class Package : public QObject
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>*);
+ 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<Package> *_versions;
+ QDict<OipkgPackage> *_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 edb9cc5..5f79ec1 100644
--- a/noncore/unsupported/oipkg/packagelist.cpp
+++ b/noncore/unsupported/oipkg/packagelist.cpp
@@ -7,125 +7,125 @@
* *
***************************************************************************/
// (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<Package> *packageListAll;
+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<Package>();
+ 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( Package* pack )
+void PackageList::insertPackage( OipkgPackage* pack )
{
if (!pack) return;
- Package* p = packageListAll->find( pack->name() );
+ 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<Package> *packver = p->getOtherVersions();
+ QDict<OipkgPackage> *packver = p->getOtherVersions();
// p->setName( pack->name()+"["+p->version()+"]" );
if (!packver)
{
- packver = new QDict<Package>();
+ 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<Package> filterIter( origPackageList );
+ QDictIterator<OipkgPackage> filterIter( origPackageList );
filterIter.toFirst();
- Package *pack= filterIter.current() ;
+ 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();
}
}
-Package* PackageList::find( QString n )
+OipkgPackage* PackageList::find( QString n )
{
return packageList.find( n );
}
-Package* PackageList::first()
+OipkgPackage* PackageList::first()
{
packageIter.toFirst();
return packageIter.current();
}
-Package* PackageList::next()
+OipkgPackage* PackageList::next()
{
++packageIter;
return packageIter.current();
}
QStringList PackageList::getSections()
{
sections.sort();
return sections;
}
QStringList PackageList::getSubSections()
@@ -138,25 +138,25 @@ QStringList PackageList::getSubSections()
}
void PackageList::setSection( QString sec )
{
aktSection = sec;
}
void PackageList::setSubSection( QString ssec )
{
aktSubSection = ssec;
}
-void PackageList::updateSections( Package* pack )
+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];
@@ -173,68 +173,68 @@ void PackageList::readFileEntries( QString filename, QString 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() )
{
- Package *p = new Package( packEntry, settings );
+ 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() )
{
- Package *p = new Package( packEntry, settings );
+ OipkgPackage *p = new OipkgPackage( packEntry, settings );
if ( p )
{
p->setDest( dest );
insertPackage( p );
packEntry.clear();
}
}
delete statusStream;
return;
}
void PackageList::setSettings( PackageManagerSettings *s )
{
settings = s;
}
-Package* PackageList::getByName( QString n )
+OipkgPackage* PackageList::getByName( QString n )
{
return origPackageList[n];
}
void PackageList::clear()
{
origPackageList.clear();
packageList.clear();
}
void PackageList::allPackages()
{
packageList.clear();
- QDictIterator<Package> filterIter( origPackageList );
+ QDictIterator<OipkgPackage> filterIter( origPackageList );
filterIter.toFirst();
- Package *pack= filterIter.current() ;
+ OipkgPackage *pack= filterIter.current() ;
while ( pack )
{
packageList.insert( pack->name(), pack );
++filterIter;
pack = filterIter.current();
}
}
diff --git a/noncore/unsupported/oipkg/packagelist.h b/noncore/unsupported/oipkg/packagelist.h
index 0c13688..88a8793 100644
--- a/noncore/unsupported/oipkg/packagelist.h
+++ b/noncore/unsupported/oipkg/packagelist.h
@@ -15,55 +15,55 @@
#include "pksettings.h"
#include "debug.h"
class PackageList : public QObject
{
Q_OBJECT
public:
// static QString all = QObject::tr("All");
PackageList (QObject *parent=0, const char *name=0);
PackageList( PackageManagerSettings *s, QObject *parent=0, const char *name=0);
virtual ~PackageList();
- void insertPackage( Package* );
- Package* find( QString );
- Package* next();
- Package* first();
+ void insertPackage( OipkgPackage* );
+ OipkgPackage* find( QString );
+ OipkgPackage* next();
+ OipkgPackage* first();
QStringList getSections();
QStringList getSubSections();
void setSettings( PackageManagerSettings* );
void filterPackages( QString );
- Package* getByName( QString );
+ OipkgPackage* getByName( QString );
void clear();
void allPackages();
- QDict<Package> *versions;
+ QDict<OipkgPackage> *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;
+ QDict<OipkgPackage> packageList;
+ QDict<OipkgPackage> origPackageList;
+ QDictIterator<OipkgPackage> packageIter;
bool empty;
QString aktSection;
QString aktSubSection;
QStringList sections;
QDict<QStringList> subSections;
QDict<bool> sectionsDict;
- void updateSections( Package* );
+ void updateSections( OipkgPackage* );
void readFileEntries( QString file, QString dest="" );
};
#endif
diff --git a/noncore/unsupported/oipkg/packagelistdoclnk.cpp b/noncore/unsupported/oipkg/packagelistdoclnk.cpp
index 76e91ff..a7a6f70 100644
--- a/noncore/unsupported/oipkg/packagelistdoclnk.cpp
+++ b/noncore/unsupported/oipkg/packagelistdoclnk.cpp
@@ -39,15 +39,15 @@ PackageListDocLnk::~PackageListDocLnk()
cfg.writeEntry( "docLnkDir", docLnkDir );
delete doclnkset;
}
void PackageListDocLnk::update()
{
pvDebug(2,"PackageListDocLnk::update ");
QList<DocLnk> packlist = doclnkset->children();
for (DocLnk *pack =packlist.first(); pack != 0; pack=packlist.next() )
{
- insertPackage( new Package(pack->file(), settings ) );
+ insertPackage( new OipkgPackage(pack->file(), settings ) );
}
}
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
@@ -2,81 +2,96 @@
* *
* 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(QListView* lv, Package *pi, PackageManagerSettings *s)
- : QCheckListItem(lv,pi->name(),CheckBox)
+PackageListItem::PackageListItem(ListViewItemOipkg *parent, QString name, Type ittype)
+ : ListViewItemOipkg(parent,name,ittype)
{
- init(pi,s);
+
}
-PackageListItem::PackageListItem(QListViewItem *lvi, Package *pi, PackageManagerSettings *s)
- : QCheckListItem(lvi,pi->name(),CheckBox)
+PackageListItem::PackageListItem(QListView* lv, OipkgPackage *pi, PackageManagerSettings *s)
+ : ListViewItemOipkg(lv,pi->name(),ListViewItemOipkg::Package)
{
- init(pi,s);
+ init(pi,s);
}
-void PackageListItem::init( Package *pi, PackageManagerSettings *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)
+{
+ popupMenu = new QPopupMenu( 0 );
+ destsMenu = new QPopupMenu( 0 );
package = pi;
settings = 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();
QDictIterator<QString> it( *fields );
- while ( it.current() ) {
- item = new QCheckListItem( otherItem, QString(it.currentKey()+": "+*it.current()) );
- ++it;
- }
+ 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"));
- }
+ {
+ 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 ) {
@@ -106,37 +121,37 @@ void PackageListItem::paintFocus( QPainter *p, const QColorGroup & cg,
// 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 (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;
- }
+ 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;
+ 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);
@@ -151,24 +166,74 @@ QString PackageListItem::key( int column, bool ascending ) const
}
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());
+ 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")));
+ 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();
+//} \ No newline at end of file
diff --git a/noncore/unsupported/oipkg/packagelistitem.h b/noncore/unsupported/oipkg/packagelistitem.h
index dba44f7..ca0cf17 100644
--- a/noncore/unsupported/oipkg/packagelistitem.h
+++ b/noncore/unsupported/oipkg/packagelistitem.h
@@ -1,50 +1,64 @@
/***************************************************************************
* *
* 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_LISTITEM_H
#define PK_LISTITEM_H
-#include "package.h"
#include <qstring.h>
-#include <qlistview.h>
+//#include <qlistview.h>
#include <qpainter.h>
#include <qpixmap.h>
#include <qdict.h>
+#include "listviewitemoipkg.h"
+#include "package.h"
#include "pksettings.h"
-class PackageListItem
-: public QCheckListItem
+class QPopupMenu;
+
+class PackageListItem : public ListViewItemOipkg
{
public:
- PackageListItem(QListViewItem*, Package*, PackageManagerSettings*);
- PackageListItem(QListView*, Package*, PackageManagerSettings*);
+ PackageListItem(ListViewItemOipkg *parent, QString name, Type ittype);
+ PackageListItem(
+ ListViewItemOipkg *parent,
+ OipkgPackage *pack,
+ PackageManagerSettings *s);
+ PackageListItem(QListView*, OipkgPackage*, PackageManagerSettings*);
+ ~PackageListItem();
void paintCell( QPainter*, const QColorGroup&, int, int, int );
void paintFocus( QPainter*, const QColorGroup&, const QRect& );
QPixmap statePixmap() const;
QString key( int, bool ) const;
- Package* getPackage() { return package; } ;
+ OipkgPackage* getPackage() { return package; } ;
QString getName() { return package->name(); } ;
bool isInstalled(){ return package->installed(); };
virtual void setOn ( bool );
void displayDetails();
private:
- void init(Package*, PackageManagerSettings*);
+ QPopupMenu *popupMenu;
+ QPopupMenu *destsMenu;
+ void init(OipkgPackage*, PackageManagerSettings*);
+ virtual QPopupMenu* getPopupMenu();
+ static QPopupMenu *_destsMenu;
QCheckListItem *nameItem;
QCheckListItem *destItem;
QCheckListItem *linkItem;
QCheckListItem *statusItem;
PackageManagerSettings *settings;
- Package *package;
+ OipkgPackage *package;
+protected slots:
+ // void toggleProcess();
+ virtual void menuAction( int );
};
#endif
diff --git a/noncore/unsupported/oipkg/packagelistlocal.cpp b/noncore/unsupported/oipkg/packagelistlocal.cpp
index b8a19253..2fe75bc 100644
--- a/noncore/unsupported/oipkg/packagelistlocal.cpp
+++ b/noncore/unsupported/oipkg/packagelistlocal.cpp
@@ -60,16 +60,16 @@ void PackageListLocal::parseList()
for ( QStringList::Iterator it = srvs.begin(); it != srvs.end(); ++it )
{
pvDebug( 2, "List: "+listsDir+"/"+*it);
readFileEntries( listsDir+"/"+*it );
}
}
void PackageListLocal::update()
{
pvDebug( 2, "parseStatus");
parseStatus();
- pvDebug( 2, "parseList");
+ pvDebug( 2, "parseList "+listsDir);
parseList();
pvDebug( 2, "finished parsing");
}
diff --git a/noncore/unsupported/oipkg/packagelistview.cpp b/noncore/unsupported/oipkg/packagelistview.cpp
index 0d6fa80..3c7435d 100644
--- a/noncore/unsupported/oipkg/packagelistview.cpp
+++ b/noncore/unsupported/oipkg/packagelistview.cpp
@@ -3,151 +3,116 @@
* 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 "packagelistview.h"
#include <qpopupmenu.h>
#include <qaction.h>
+#include "listviewitemoipkg.h"
#include "packagelistitem.h"
#include "pksettings.h"
PackageListView::PackageListView(QWidget *p, const char* n, PackageManagerSettings *s)
- : QListView(p,n)
+ : QListView(p,n)
{
- settings = s;
- popupMenu = new QPopupMenu( this );
- destsMenu = new QPopupMenu( popupMenu );
+ settings = s;
popupTimer = new QTimer( this );
setSelectionMode(QListView::NoSelection);
- addColumn( tr("Package") );
- setRootIsDecorated( true );
+ addColumn( tr("Package") );
+ setRootIsDecorated( true );
connect( popupTimer, SIGNAL(timeout()),
- this, SLOT(showPopup()) );
+ this, SLOT(showPopup()) );
connect( this, SIGNAL( pressed( QListViewItem* ) ),
- this, SLOT( setCurrent( QListViewItem* ) ) );
- connect( this, SIGNAL( clicked( QListViewItem* ) ),
+ this, SLOT( setCurrent( QListViewItem* ) ) );
+ connect( this, SIGNAL( clicked( QListViewItem* ) ),
this, SLOT( stopTimer( QListViewItem* ) ) );
}
//PackageListView::~PackageListView()
//{
//}
void PackageListView::setCurrent( QListViewItem* p )
{
- if ( !p ) return;
- activePackageListItem = (PackageListItem*)p;
- activePackage = activePackageListItem->getPackage();
- if (!activePackage)
- {
-// QDictIterator<QCheckListItem> it( rootItems );
-// while ( it.current() )
+ qDebug("PackageListView::setCurrent ");
+ activeItem = (ListViewItemOipkg*)p;
+
+ if ( activeItem != 0 ) popupTimer->start( 750, true );
+
+// if ( activeItem->getType() != ListViewItemOipkg::Package ){
+// qDebug("PackageListView::setCurrent !p ");
+// activePackage = 0;
+// activePackageListItem = 0;
+// qDebug("PackageListView::setCurrent returning ");
+// return;
+// };
+// activePackageListItem = (PackageListItem*)p;
+// activePackage = activePackageListItem->getPackage();
+// if (activePackage == 0 )
// {
-// if ( it.current()==p )
-// pvDebug(2,"current item");
-// ++it;
-// }
+// qDebug("PackageListView::setCurrent if (!activePackage)");
+// return;
+// }
+
- return;
- }
- popupTimer->start( 750, true );
+ qDebug("PackageListView::setCurrent popupTimer->start");
}
void PackageListView::showPopup()
{
- popupMenu->clear();
- destsMenu->clear();
-
- QAction *popupAction;
- if ( !activePackage->installed() )
- {
- popupMenu->insertItem( 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, this, 0 );
- popupAction->addTo( destsMenu );
- if ( dests[i] == ad && activePackage->toInstall() )
- {
- popupAction->setToggleAction( true );
- popupAction->setOn(true);
- };
- }
- connect( destsMenu, SIGNAL( activated( int ) ),
- this, SLOT( changePackageDest( int ) ) );
- }else{
- popupAction = new QAction( tr("Remove"),QString::null, 0, this, 0 );
- popupAction->addTo( popupMenu );
- connect( popupAction, SIGNAL( activated() ),
- this , SLOT( toggleProcess() ) );
- popupAction = new QAction( tr("Reinstall"),QString::null, 0, this, 0 );
- popupAction->addTo( popupMenu );
- popupAction->setEnabled( false );
- }
- popupMenu->popup( QCursor::pos() );
+ qDebug("PackageListView::showPopup");
+ QPopupMenu *popup = activeItem->getPopupMenu();
+ if (popup == 0) return;
+ popup->popup( QCursor::pos() );
+ qDebug("PackageListView::showPopup");
}
void PackageListView::stopTimer( QListViewItem* )
{
- popupTimer->stop();
+ popupTimer->stop();
}
-void PackageListView::changePackageDest( int i )
-{
- activePackage->setDest( destsMenu->text(i) );
- activePackage->setOn();
- activePackage->setLink( settings->createLinks() );
- activePackageListItem->displayDetails();
-}
-
-void PackageListView::toggleProcess()
-{
- activePackage->toggleProcess() ;
- activePackageListItem->displayDetails();
-}
-
void PackageListView::display()
{
- QDictIterator<PackageList> list( PackageLists );
- PackageList *packlist;
- Package *pack;
+ QDictIterator<PackageList> list( PackageLists );
+ PackageList *packlist;
+ OipkgPackage *pack;
PackageListItem *item;
- QCheckListItem *rootItem;
+ ListViewItemOipkg *rootItem;
QListViewItem* it;
QListViewItem* itdel;
- while ( list.current() ) {
- packlist = list.current();
+ while ( list.current() ) {
+ packlist = list.current();
rootItem = rootItems.find( list.currentKey() );
//rootItem->clear();
it=rootItem->firstChild();
while ( it )
- {
- itdel = it;
- it = it->nextSibling();
- delete itdel;
- }
+ {
+ itdel = it;
+ it = it->nextSibling();
+ delete itdel;
+ }
pack = packlist->first();
- while( pack )
- {
- item = new PackageListItem( rootItem, pack, settings );
+ while( pack )
+ {
+ item = new PackageListItem( rootItem, pack, settings );
pack = packlist->next();
- }
- ++list;
+ }
+ ++list;
}
}
void PackageListView::addList( QString n, PackageList* pl)
{
- PackageLists.insert(n, pl);
- QCheckListItem *item = new QCheckListItem(this,n);
- rootItems.insert(n, item);
+ PackageLists.insert(n, pl);
+ ListViewItemOipkg *item = new ListViewItemOipkg(this,n,ListViewItemOipkg::Feed);
+ rootItems.insert(n, item);
}
diff --git a/noncore/unsupported/oipkg/packagelistview.h b/noncore/unsupported/oipkg/packagelistview.h
index 3c09ba8..17dcb95 100644
--- a/noncore/unsupported/oipkg/packagelistview.h
+++ b/noncore/unsupported/oipkg/packagelistview.h
@@ -9,46 +9,47 @@
// (c) 2002 Patrick S. Vogt <tille@handhelds.org>
#ifndef PACKAGELISTVIEW_H
#define PACKAGELISTVIEW_H
#include <qlistview.h>
#include <qaction.h>
#include <qdict.h>
#include <qstring.h>
#include <qtimer.h>
#include <qwidget.h>
#include <qpopupmenu.h>
+#include "listviewitemoipkg.h"
#include "packagelist.h"
#include "debug.h"
class PackageListItem;
-class Package;
+class OipkgPackage;
class PackageManagerSettings;
+//class ListViewItemOipkg;
class PackageListView : public QListView
{
Q_OBJECT
public:
PackageListView(QWidget*, const char*, PackageManagerSettings*);
void addList( QString, PackageList* );
// ~PackageListView();
QTimer *popupTimer;
private:
- QDict<PackageList> PackageLists;
- QDict<QCheckListItem> rootItems;
- PackageManagerSettings *settings;
- Package *activePackage;
- PackageListItem *activePackageListItem;
+ QDict<PackageList> PackageLists;
+ QDict<ListViewItemOipkg> rootItems;
+ PackageManagerSettings *settings;
+// OipkgPackage *activePackage;
+// PackageListItem *activePackageListItem;
+ ListViewItemOipkg *activeItem;
QPopupMenu *popupMenu;
QPopupMenu *destsMenu;
public slots:
void showPopup();
- void changePackageDest( int );
void setCurrent( QListViewItem* );
void stopTimer( QListViewItem* );
- void toggleProcess();
void display();
};
#endif
diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp
index 2ed313c..cfaadbf 100644
--- a/noncore/unsupported/oipkg/pmipkg.cpp
+++ b/noncore/unsupported/oipkg/pmipkg.cpp
@@ -105,25 +105,25 @@ bool PmIpkg::runIpkg(const QString& args, const QString& dest )
if (lineStr.contains("Done")) ret = true;
if (lineStr!=lineStrOld)
out(lineStr);
lineStrOld = lineStr;
qApp->processEvents();
}
}
pclose(fp);
pvDebug(2,QString(ret?"success\n":"failure\n"));
return ret;
}
-void PmIpkg::makeLinks(Package *pack)
+void PmIpkg::makeLinks(OipkgPackage *pack)
{
pvDebug( 2, "PmIpkg::makeLinks "+ pack->name());
QString pn = pack->name();
linkPackage( pack->packageName(), pack->dest() );
}
QStringList* PmIpkg::getList( QString packFileName, QString d )
{
QString dest = settings->getDestinationUrlByName( d );
dest = dest==""?d:dest;
// if (dest == "/" ) return 0;
{
@@ -223,25 +223,25 @@ void PmIpkg::processLinkDir( QString file, QString dest )
QFileInfo toRemoveLink( destFile );
if ( !QFile::exists( file ) && toRemoveLink.isSymLink() )
{
pvDebug(4,"removing "+destFile+" no "+file);
unlink( linkFile );
}
}
}
}
void PmIpkg::loadList( PackageList *pl )
{
- for( Package *pack = pl->first();pack ; (pack = pl->next()) )
+ for( OipkgPackage *pack = pl->first();pack ; (pack = pl->next()) )
{
if ( pack && (pack->name() != "") && pack)
{
if ( pack->toInstall() )
to_install.append( pack );
if ( pack->toRemove() )
to_remove.append( pack );
}
}
}
void PmIpkg::commit()
@@ -282,25 +282,25 @@ void PmIpkg::doIt()
show();
remove();
install();
}
void PmIpkg::remove()
{
if ( to_remove.count() == 0 ) return;
out(tr("Removing")+"\n"+tr("please wait")+"\n\n");
- QStringList *fileList;
+ QStringList *fileList = new QStringList;
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)->installName(), to_remove.at(i)->dest() ))
{
runwindow->progress->setProgress( 1 );
linkOpp = removeLink;
to_remove.at(i)->processed();
pvDebug(3,"link "+QString::number(i));
if ( to_remove.at(i)->link() )
processFileList( fileList, to_remove.at(i)->dest() );
//pvDebug(3,"take "+QString::number(i)+" of "+QString::number(to_remove.count()));
@@ -405,38 +405,38 @@ void PmIpkg::show()
runwindow->showMaximized();
runwindow->show();
}
runwindow->outPut->setText("");
}
void PmIpkg::installFile(const QString &fileName, const QString &dest)
{
to_install.clear();
to_remove.clear();
pvDebug( 2,"PmIpkg::installFile "+ fileName);
- Package *p = new Package(fileName,settings);
+ OipkgPackage *p = new OipkgPackage(fileName,settings);
if ( dest!="") p->setDest( dest );
to_install.append( p );
commit();
delete p;
}
void PmIpkg::removeFile(const QString &fileName, const QString &dest)
{
to_install.clear();
to_remove.clear();
pvDebug( 2,"PmIpkg::removeFile "+ fileName);
- Package *p = new Package(fileName,settings);
+ OipkgPackage *p = new OipkgPackage(fileName,settings);
if ( dest!="") p->setDest( dest );
to_remove.append( p );
commit();
delete p;
}
void PmIpkg::clearLists()
{
to_remove.clear();
to_install.clear();
}
diff --git a/noncore/unsupported/oipkg/pmipkg.h b/noncore/unsupported/oipkg/pmipkg.h
index 2f4d6ae..cb0759a 100644
--- a/noncore/unsupported/oipkg/pmipkg.h
+++ b/noncore/unsupported/oipkg/pmipkg.h
@@ -14,25 +14,25 @@
#include <qlist.h>
#include <qstring.h>
#include <qwidget.h>
#include "pksettings.h"
#include "runwindow.h"
#include "packagelist.h"
#include "installdialog.h"
#include "debug.h"
#define createLink 0
#define removeLink 1
-class Package;
+class OipkgPackage;
class PmIpkg : public QObject
{
Q_OBJECT
public:
PmIpkg( PackageManagerSettings* , QWidget* p=0, const char * name=0, WFlags f=0 );
~PmIpkg();
int linkOpp;
void loadList( PackageList* );
void commit();
void update();
void show();
@@ -44,26 +44,26 @@ public slots:
void remove();
void installFile(const QString &fileName, const QString &dest="");
void removeFile(const QString &fileName, const QString &dest="");
void createLinks( const QString &dest );
void removeLinks( const QString &dest );
private:
QString ipkg_cmd;
PackageManagerSettings* settings;
RunWindow *runwindow;
InstallDialog *installDialog;
- QList<Package> to_remove;
- QList<Package> to_install;
- void makeLinks(Package*);
+ QList<OipkgPackage> to_remove;
+ QList<OipkgPackage> to_install;
+ void makeLinks(OipkgPackage*);
void linkPackage( QString, QString );
void processLinkDir( QString , QString );
bool runIpkg(const QString& args, const QString& dest="" );
void out( QString );
QStringList* getList( QString, QString );
void processFileList( QStringList*, QString );
};
#endif