summaryrefslogtreecommitdiff
authortille <tille>2002-04-24 19:15:02 (UTC)
committer tille <tille>2002-04-24 19:15:02 (UTC)
commit17eb865ad8248b1f47c565b074b9b6bbbd44935b (patch) (side-by-side diff)
treec494b5050ce910df3c74e2a21c5579571792d926
parent997b7685dcc48cc36737240ca53331f83b66dbeb (diff)
downloadopie-17eb865ad8248b1f47c565b074b9b6bbbd44935b.zip
opie-17eb865ad8248b1f47c565b074b9b6bbbd44935b.tar.gz
opie-17eb865ad8248b1f47c565b074b9b6bbbd44935b.tar.bz2
added find
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/oipkg/mainwindow.cpp204
-rw-r--r--noncore/unsupported/oipkg/mainwindow.h26
-rw-r--r--noncore/unsupported/oipkg/oipkg.pro1
-rw-r--r--noncore/unsupported/oipkg/packagelist.cpp23
-rw-r--r--noncore/unsupported/oipkg/packagelist.h7
-rw-r--r--noncore/unsupported/oipkg/pkwindow.ui147
-rw-r--r--noncore/unsupported/oipkg/pmipkg.cpp2
7 files changed, 180 insertions, 230 deletions
diff --git a/noncore/unsupported/oipkg/mainwindow.cpp b/noncore/unsupported/oipkg/mainwindow.cpp
index cb2b4cd..997f449 100644
--- a/noncore/unsupported/oipkg/mainwindow.cpp
+++ b/noncore/unsupported/oipkg/mainwindow.cpp
@@ -1,272 +1,348 @@
// adadpted form qpe/qipkg
#include "mainwindow.h"
#include <qpe/qpemenubar.h>
#include <qpe/qpemessagebox.h>
#include <qpe/resource.h>
#include <qpe/qpetoolbar.h>
#include <qaction.h>
#include <qmessagebox.h>
#include <qpopupmenu.h>
#include <qtoolbutton.h>
#include <qstring.h>
+#include <qlabel.h>
#include <qlistview.h>
#include <qtextview.h>
+#include <qlineedit.h>
#include <qtabwidget.h>
#include <qcombobox.h>
#include <qlayout.h>
#include "pksettingsbase.h"
#include "packagelistitem.h"
MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f = 0 ) :
QMainWindow( parent, name, f )
{
setCaption( tr("Package Manager") );
- table = new PackageWindow( this,0,0 );
- setCentralWidget( table );
+
+ listViewPackages = new QListView( this,0,0 );
+ setCentralWidget( listViewPackages );
+
makeMenu();
QFontMetrics fm = fontMetrics();
- int w0 = fm.width(tr("Package"))+30;
- int w2 = fm.width("00000")+4;
- table->ListViewPackages->setColumnWidth(0,w0);
- table->ListViewPackages->setColumnWidth(1,228-w2-w0); // ### screen-biased
- table->ListViewPackages->setColumnWidth(2,w2);
- table->ListViewPackages->setColumnWidthMode(0,QListView::Manual);
- table->ListViewPackages->setColumnWidthMode(1,QListView::Manual);
- table->ListViewPackages->setColumnWidthMode(2,QListView::Manual);
- table->ListViewPackages->setSelectionMode( QListView::Multi );
-
- connect( table->section, SIGNAL( activated(int) ),
+ int wlw = width()*2;
+ int w0 = fm.width(tr("Package"))+30;
+ // int w0 = fm.width(tr("Package"))+30;
+ int w2 = fm.width("00000")+4;
+ int w1 = wlw-w2-w0-20;
+ listViewPackages->addColumn( tr("Package"), w0 );
+ listViewPackages->addColumn( tr("Description"), w1 );
+ listViewPackages->addColumn( tr("Size"), w2 );
+ listViewPackages->setColumnWidthMode(0,QListView::Manual);
+ listViewPackages->setColumnWidthMode(1,QListView::Manual);
+ listViewPackages->setColumnWidthMode(2,QListView::Manual);
+ listViewPackages->setSelectionMode( QListView::Multi );
+
+ connect( section, SIGNAL( activated(int) ),
this, SLOT( sectionChanged() ) );
- connect( table->subsection, SIGNAL(activated(int) ),
+ connect( subsection, SIGNAL(activated(int) ),
this, SLOT( subSectionChanged() ) );
- connect( table->ListViewPackages, SIGNAL( clicked( QListViewItem* ) ),
+ connect( listViewPackages, SIGNAL( pressed( QListViewItem* ) ),
this, SLOT( setCurrent( QListViewItem* ) ) );
settings = new PackageManagerSettings(this,0,TRUE);
ipkg = new PmIpkg( settings, this );
packageList.setSettings( settings );
getList();
setSections();
setSubSections();
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 );
-//#define TOOLBAR
-#ifdef TOOLBAR
- QPEToolBar *secBar = new QPEToolBar( this );
- QComboBox *sections = new QComboBox( false, this );
- secBar->addTo( sections );
-#endif
+ popupMenu = new QPopupMenu( this );
contextMenu = new QPopupMenu( this );
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 );
- toolBar->setStretchableWidget (srvMenu);
+ QLabel *spacer = new QLabel( "", toolBar );
+ spacer->setBackgroundColor( toolBar->backgroundColor() );
+ toolBar->setStretchableWidget( spacer );
- runAction = new QAction( tr( "Run" ),
+ runAction = new QAction( tr( "Commit" ),
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/repeat" ),
QString::null, 0, this, 0 );
connect( updateAction, SIGNAL( activated() ),
this , SLOT( updateList() ) );
updateAction->addTo( toolBar );
updateAction->addTo( srvMenu );
- // detailsAction = new QAction( tr( "Details" ),
- // Resource::loadIconSet( "oipkg/details" ),
- // QString::null, 0, this, 0 );
- // connect( detailsAction, SIGNAL( activated() ),
- // this , SLOT( showDetails() ) );
- // detailsAction->addTo( toolBar );
- // detailsAction->addTo( srvMenu );
+ detailsAction = new QAction( tr( "Details" ),
+ Resource::loadIconSet( "find" ),
+ QString::null, 0, this, 0 );
+ connect( detailsAction, SIGNAL( activated() ),
+ this , SLOT( showDetails() ) );
+ detailsAction->addTo( toolBar );
+ detailsAction->addTo( srvMenu );
QAction *cfgact;
cfgact = new QAction( tr( "Setups" ),
- Resource::loadIconSet( "" ),
+ // Resource::loadIconSet( "" ),
QString::null, 0, this, 0 );
connect( cfgact, SIGNAL( activated() ),
SLOT( showSettings() ) );
cfgact->addTo( cfgMenu );
cfgact = new QAction( tr( "Servers" ),
- Resource::loadIconSet( "" ),
+ // Resource::loadIconSet( "" ),
QString::null, 0, this, 0 );
connect( cfgact, SIGNAL( activated() ),
SLOT( showSettingsSrv() ) );
cfgact->addTo( cfgMenu );
cfgact = new QAction( tr( "Destinations" ),
- Resource::loadIconSet( "" ),
+ // Resource::loadIconSet( "" ),
QString::null, 0, this, 0 );
connect( cfgact, SIGNAL( activated() ),
SLOT( showSettingsDst() ) );
cfgact->addTo( cfgMenu );
-
+
+ QAction *a;
+
+ sectionBar = new QPEToolBar( this );
+ addToolBar( sectionBar, "Section", QMainWindow::Top, TRUE );
+ sectionBar->setHorizontalStretchable( true );
+ QLabel *label = new QLabel( tr("Section: "), sectionBar );
+ label->setBackgroundColor( sectionBar->backgroundColor() );
+ section = new QComboBox( false, sectionBar );
+// section->setBackgroundMode( PaletteBackground );
+ label = new QLabel( " / ", sectionBar );
+ label->setBackgroundColor( sectionBar->backgroundColor() );
+ subsection = new QComboBox( false, sectionBar );
+ sectionBar->setStretchableWidget( label );
+
+ a = new QAction( tr( "Close Section" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
+ connect( a, SIGNAL( activated() ), this, SLOT( sectionClose() ) );
+ a->addTo( sectionBar );
+
+ sectionAction = new QAction( tr( "Sections" ), QString::null, 0, this, 0 );
+ connect( sectionAction, SIGNAL( toggled(bool) ), this, SLOT( sectionShow(bool) ) );
+ sectionAction->setToggleAction( true );
+ sectionAction->setOn( true );
+ sectionAction->addTo( viewMenu );
+
+ findBar = new QPEToolBar(this);
+ addToolBar( findBar, "Search", QMainWindow::Top, TRUE );
+ label = new QLabel( tr("Filter: "), findBar );
+ label->setBackgroundColor( findBar->backgroundColor() );
+ findBar->setHorizontalStretchable( TRUE );
+ findEdit = new QLineEdit( findBar, "findEdit" );
+ findBar->setStretchableWidget( findEdit );
+ connect( findEdit, SIGNAL( textChanged( const QString & ) ),
+ this, SLOT( displayList() ) );
+// a = new QAction( tr( "Filter" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 );
+// connect( a, SIGNAL( activated() ), this, SLOT( filterList() ) );
+// a->addTo( findBar );
+// a->addTo( edit );
+ a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
+ connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) );
+ a->addTo( findBar );
+ findAction = new QAction( tr( "Find" ), QString::null, 0, this, 0 );
+ connect( findAction, SIGNAL( toggled(bool) ), this, SLOT( findShow(bool) ) );
+ findAction->setToggleAction( true );
+ findAction->setOn( true );
+ findAction->addTo( viewMenu );
+
}
MainWindow::~MainWindow()
{
}
void MainWindow::runIpkg()
{
ipkg->commit( packageList );
- updateList();
+ updateList(); //to remove
}
void MainWindow::updateList()
{
- // todo: packageList.clear();
+ packageList.clear();
ipkg->update();
getList();
}
void MainWindow::getList()
{
packageList.update();
displayList();
}
void MainWindow::filterList()
{
- packageList.filterPackages();
+ QString f = "";
+ if ( findAction->isOn() ) f = findEdit->text();
+ packageList.filterPackages( f );
}
void MainWindow::displayList()
{
- table->ListViewPackages->clear();
+ filterList();
+ listViewPackages->clear();
Package *pack = packageList.first();
while( pack )
- {
- if ( pack && (pack->name() != "") )
- {
- table->ListViewPackages->insertItem(
- new PackageListItem( table->ListViewPackages, pack ) );
- }
- pack = packageList.next();
- }
+ {
+ if ( pack && (pack->name() != "") )
+ listViewPackages->insertItem( new PackageListItem( listViewPackages, pack ) );
+ pack = packageList.next();
+ }
}
void MainWindow::sectionChanged()
{
- disconnect( table->section, SIGNAL( activated(int) ),
+ disconnect( section, SIGNAL( activated(int) ),
this, SLOT( sectionChanged() ) );
- disconnect( table->subsection, SIGNAL(activated(int) ),
+ disconnect( subsection, SIGNAL(activated(int) ),
this, SLOT( subSectionChanged() ) );
- table->subsection->clear();
- packageList.setSection( table->section->currentText() );
+ subsection->clear();
+ packageList.setSection( section->currentText() );
setSubSections();
- filterList();
- connect( table->section, SIGNAL( activated(int) ),
+ connect( section, SIGNAL( activated(int) ),
this, SLOT( sectionChanged() ) );
- connect( table->subsection, SIGNAL(activated(int) ),
+ connect( subsection, SIGNAL(activated(int) ),
this, SLOT( subSectionChanged() ) );
displayList();
}
void MainWindow::subSectionChanged()
{
- disconnect( table->section, SIGNAL( activated(int) ),
+ disconnect( section, SIGNAL( activated(int) ),
this, SLOT( sectionChanged() ) );
- disconnect( table->subsection, SIGNAL(activated(int) ),
+ disconnect( subsection, SIGNAL(activated(int) ),
this, SLOT( subSectionChanged() ) );
- packageList.setSubSection( table->subsection->currentText() );
- filterList();
- connect( table->section, SIGNAL( activated(int) ),
+ packageList.setSubSection( subsection->currentText() );
+ connect( section, SIGNAL( activated(int) ),
this, SLOT( sectionChanged() ) );
- connect( table->subsection, SIGNAL(activated(int) ),
+ connect( subsection, SIGNAL(activated(int) ),
this, SLOT( subSectionChanged() ) );
displayList();
}
void MainWindow::setSections()
{
- table->section->clear();
- table->section->insertStringList( packageList.getSections() );
+ section->clear();
+ section->insertStringList( packageList.getSections() );
}
void MainWindow::setSubSections()
{
- table->subsection->clear();
- table->subsection->insertStringList( packageList.getSubSections() );
+ subsection->clear();
+ subsection->insertStringList( packageList.getSubSections() );
}
void MainWindow::showSettings()
{
if ( settings->showDialog( 0 ) )
getList();
}
void MainWindow::showSettingsSrv()
{
if ( settings->showDialog( 1 ) )
getList();
}
void MainWindow::showSettingsDst()
{
if ( settings->showDialog( 2 ) )
getList();
}
void MainWindow::showDetails()
{
if ( activePackage ) return;
if ( details )
{
details = new PackageDetails( this );
connect( details->install, SIGNAL(clicked()), SLOT( toggleActivePackage() ) );
connect( details->remove, SIGNAL(clicked()), SLOT( toggleActivePackage() ) );
connect( details->ignore, SIGNAL(clicked()), details, SLOT(close()));
details->description->setTextFormat(RichText);
}
details->setCaption("Package: " + activePackage->name());
details->description->setText(activePackage->details() );
details->install->setEnabled(!activePackage->installed());
details->remove->setEnabled(activePackage->installed());
details->showMaximized();
}
void MainWindow::toggleActivePackage()
{
activePackage->toggleProcess();
if ( details ) details->close();
}
void MainWindow::setCurrent( QListViewItem* p )
{
pvDebug(2, "MainWindow::setCurrent ");
- //+((Package*)p)->name());
+ return;
+ pvDebug(2, "name "+((Package*)p)->name());
activePackage = (Package*)p;
}
+
+void MainWindow::sectionShow(bool b)
+{
+ if (b) sectionBar->show();
+ else sectionBar->hide();
+ sectionAction->setOn( b );
+}
+
+void MainWindow::sectionClose()
+{
+ sectionAction->setOn( false );
+}
+
+void MainWindow::findShow(bool b)
+{
+ if (b) findBar->show();
+ else findBar->hide();
+ findAction->setOn( b );
+}
+
+void MainWindow::findClose()
+{
+ findAction->setOn( false );
+}
+
diff --git a/noncore/unsupported/oipkg/mainwindow.h b/noncore/unsupported/oipkg/mainwindow.h
index 95dcc90..0c1e474 100644
--- a/noncore/unsupported/oipkg/mainwindow.h
+++ b/noncore/unsupported/oipkg/mainwindow.h
@@ -1,62 +1,74 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <qmainwindow.h>
#include <qaction.h>
#include <qpopupmenu.h>
#include "packagelist.h"
#include "pmipkg.h"
#include "pksettings.h"
#include "pkdesc.h"
-#include "pkwindow.h"
+class QComboBox;
+class QPEToolBar;
+class QLineEdit;
+class QListView;
+
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
~MainWindow();
-
-protected:
- PackageWindow *table;
-
-
protected slots:
void runIpkg();
void getList();
void updateList();
- void filterList();
void displayList();
void subSectionChanged();
void sectionChanged();
void showSettings();
void showSettingsSrv();
void showSettingsDst();
public slots:
void showDetails();
void toggleActivePackage();
void setCurrent( QListViewItem* );
+ void sectionClose();
+ void sectionShow(bool);
+ void findClose();
+ void findShow(bool);
+ void filterList();
private:
void makeMenu();
void setSections();
void setSubSections();
PmIpkg* ipkg;
PackageManagerSettings *settings;
PackageDetails* details;
PackageList packageList;
Package *activePackage;
QAction *runAction;
QAction *detailsAction;
QAction *updateAction;
+ QAction *findAction;
+ QAction *sectionAction;
+ QListView *listViewPackages;
QPopupMenu *contextMenu;
+ QPEToolBar *findBar;
+ QLineEdit *findEdit;
+ QPEToolBar *sectionBar;
+ QComboBox *section;
+ QComboBox *subsection;
+ QPopupMenu *popupMenu;
};
#endif
diff --git a/noncore/unsupported/oipkg/oipkg.pro b/noncore/unsupported/oipkg/oipkg.pro
index c61af0f..c16cc73 100644
--- a/noncore/unsupported/oipkg/oipkg.pro
+++ b/noncore/unsupported/oipkg/oipkg.pro
@@ -1,27 +1,26 @@
DESTDIR = $(OPIEDIR)/bin
TEMPLATE = app
#CONFIG = qt warn_on release
CONFIG = qt warn_on debug
HEADERS = mainwindow.h \
pksettings.h \
pmipkg.h \
packagelistitem.h \
packagelist.h \
package.h
SOURCES = main.cpp \
mainwindow.cpp \
pksettings.cpp \
pmipkg.cpp \
packagelistitem.cpp \
packagelist.cpp \
package.cpp
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe
INTERFACES = pkdesc.ui \
pkfind.ui \
runwindow.ui \
- pkwindow.ui \
pksettingsbase.ui
TARGET = oipkg
diff --git a/noncore/unsupported/oipkg/packagelist.cpp b/noncore/unsupported/oipkg/packagelist.cpp
index 5f6934d..944bb83 100644
--- a/noncore/unsupported/oipkg/packagelist.cpp
+++ b/noncore/unsupported/oipkg/packagelist.cpp
@@ -1,216 +1,223 @@
#include "packagelist.h"
#include <assert.h>
#include <qfile.h>
#include <qfileinfo.h>
#include <qtextstream.h>
#include <qpe/config.h>
#include "debug.h"
PackageList::PackageList()
: packageIter( packageList )
{
empty=true;
{
Config cfg( "oipkg", Config::User );
cfg.setGroup( "Common" );
statusDir = cfg.readEntry( "statusDir", "" );
listsDir = cfg.readEntry( "listsDir", "" );
if ( statusDir=="" || ! QFileInfo(statusDir+"/status").isFile() )
{
statusDir="/usr/lib/ipkg/";
listsDir="/usr/lib/ipkg/lists/";
cfg.writeEntry( "statusDir", statusDir );
cfg.writeEntry( "listsDir", listsDir );
}
}
- pvDebug( 5, "PackageList::PackageList statusDir "+statusDir);
- pvDebug( 5, "PackageList::PackageList listsDir "+listsDir);
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 )
{
Package* p = packageList.find( pack->name() );
if ( p )
{
p->copyValues( pack );
delete pack;
pack = p;
}else{
packageList.insert( pack->name(), pack );
origPackageList.insert( pack->name(), pack );
empty=false;
};
updateSections( pack );
}
-void PackageList::filterPackages()
+void PackageList::filterPackages( QString f )
{
packageList.clear();
QDictIterator<Package> filterIter( origPackageList );
filterIter.toFirst();
Package *pack= filterIter.current() ;
while ( pack )
{
- if ( ((aktSection=="All")||(pack->getSection()==aktSection)) &&
- ((aktSubSection=="All")||(pack->getSubSection()==aktSubSection)) )
- {
- packageList.insert( pack->name(), pack );
- }
+ if (
+ ((aktSection=="All")||(pack->getSection()==aktSection)) &&
+ ((aktSubSection=="All")||(pack->getSubSection()==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();
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( Package* pack )
{
QString s = pack->getSection();
if ( s.isEmpty() || s == "") return;
if ( sections.contains(s) ) return;
sections += s;
QString ss = pack->getSubSection();
if ( ss.isEmpty() || ss == "" ) return;
if ( !subSections[s] ) {
subSections.insert( s, new QStringList() );
QStringList *subsecs = subSections[s];
*subsecs += "All";
}
QStringList *subsecs = subSections[s];
*subsecs += ss;
if ( !subSections["All"] ) subSections.insert( "All", new QStringList() );
subsecs = subSections["All"];
*subsecs += ss;
}
/** No descriptions */
void PackageList::parseStatus()
{
QStringList dests = settings->getDestinationUrls();
for ( QStringList::Iterator it = dests.begin(); it != dests.end(); ++it )
{
pvDebug( 2,"Status Dir: "+*it+statusDir+"/status");
readFileEntries( *it+statusDir+"/status" );
};
}
void PackageList::parseList()
{
QStringList srvs = settings->getActiveServers();
for ( QStringList::Iterator it = srvs.begin(); it != srvs.end(); ++it )
{
pvDebug( 2, "List Dir: "+listsDir+"/"+*it);
readFileEntries( listsDir+"/"+*it );
}
}
void PackageList::readFileEntries( QString filename )
{
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 );
if ( p )
{
insertPackage( p );
packEntry.clear();
}
}
}else{
packEntry << line;
};
}
return;
}
void PackageList::update()
{
pvDebug( 3, "parseStatus");
parseStatus();
pvDebug( 3, "parseList");
parseList();
pvDebug( 3, "finished parsing");
}
void PackageList::setSettings( PackageManagerSettings *s )
{
settings = s;
}
Package* PackageList::getByName( QString n )
{
origPackageList[n];
}
+
+void PackageList::clear()
+{
+ origPackageList.clear();
+ packageList.clear();
+}
diff --git a/noncore/unsupported/oipkg/packagelist.h b/noncore/unsupported/oipkg/packagelist.h
index 68b89f0..4ce97af 100644
--- a/noncore/unsupported/oipkg/packagelist.h
+++ b/noncore/unsupported/oipkg/packagelist.h
@@ -1,65 +1,68 @@
#ifndef PACKAGELIST_H
#define PACKAGELIST_H
#include <qdict.h>
#include "package.h"
#include "pksettings.h"
#include "debug.h"
#define HACK
#ifdef HACK
static QString listsDir="/usr/lib/ipkg/";
static QString statusDir="/usr/lib/ipkg/";
#endif
class PackageList {
public:
+// static QString all = QObject::tr("All");
+
PackageList();
PackageList( PackageManagerSettings* );
~PackageList();
void insertPackage( Package* );
Package* find( QString );
Package* next();
Package* first();
QStringList getSections();
QStringList getSubSections();
void setSettings( PackageManagerSettings* );
- void filterPackages();
- /** No descriptions */
+ void filterPackages( QString );
Package* getByName( QString );
+ /** No descriptions */
+ void clear();
public slots:
void setSection(QString);
void setSubSection(QString);
void update();
private:
int currentPackage;
int packageCount;
PackageManagerSettings *settings;
QDict<Package> packageList;
QDict<Package> origPackageList;
QDictIterator<Package> packageIter;
bool empty;
#ifndef HACK
QString listsDir;
QString statusDir;
#endif
QString aktSection;
QString aktSubSection;
QStringList sections;
QDict<QStringList> subSections;
QDict<bool> sectionsDict;
void updateSections( Package* );
void parseStatus();
void parseList();
void readFileEntries( QString );
};
#endif
diff --git a/noncore/unsupported/oipkg/pkwindow.ui b/noncore/unsupported/oipkg/pkwindow.ui
deleted file mode 100644
index 9e44338..0000000
--- a/noncore/unsupported/oipkg/pkwindow.ui
+++ b/dev/null
@@ -1,147 +0,0 @@
-<!DOCTYPE UI><UI>
-<class>PackageWindow</class>
-<widget>
- <class>QWidget</class>
- <property stdset="1">
- <name>name</name>
- <cstring>PackageWindow</cstring>
- </property>
- <property stdset="1">
- <name>geometry</name>
- <rect>
- <x>0</x>
- <y>0</y>
- <width>254</width>
- <height>298</height>
- </rect>
- </property>
- <property stdset="1">
- <name>caption</name>
- <string>PackageWindow</string>
- </property>
- <property>
- <name>layoutMargin</name>
- </property>
- <property>
- <name>layoutSpacing</name>
- </property>
- <vbox>
- <property stdset="1">
- <name>margin</name>
- <number>2</number>
- </property>
- <property stdset="1">
- <name>spacing</name>
- <number>2</number>
- </property>
- <widget>
- <class>QLayoutWidget</class>
- <property stdset="1">
- <name>name</name>
- <cstring>Layout5</cstring>
- </property>
- <property>
- <name>layoutSpacing</name>
- </property>
- <hbox>
- <property stdset="1">
- <name>margin</name>
- <number>0</number>
- </property>
- <property stdset="1">
- <name>spacing</name>
- <number>1</number>
- </property>
- <widget>
- <class>QLabel</class>
- <property stdset="1">
- <name>name</name>
- <cstring>LabelSection</cstring>
- </property>
- <property stdset="1">
- <name>text</name>
- <string>Section:</string>
- </property>
- </widget>
- <widget>
- <class>QComboBox</class>
- <property stdset="1">
- <name>name</name>
- <cstring>section</cstring>
- </property>
- <property stdset="1">
- <name>sizePolicy</name>
- <sizepolicy>
- <hsizetype>0</hsizetype>
- <vsizetype>0</vsizetype>
- </sizepolicy>
- </property>
- </widget>
- <widget>
- <class>QComboBox</class>
- <property stdset="1">
- <name>name</name>
- <cstring>subsection</cstring>
- </property>
- <property stdset="1">
- <name>sizePolicy</name>
- <sizepolicy>
- <hsizetype>0</hsizetype>
- <vsizetype>0</vsizetype>
- </sizepolicy>
- </property>
- </widget>
- </hbox>
- </widget>
- <widget>
- <class>QListView</class>
- <column>
- <property>
- <name>text</name>
- <string>Package</string>
- </property>
- <property>
- <name>clickable</name>
- <bool>true</bool>
- </property>
- <property>
- <name>resizeable</name>
- <bool>true</bool>
- </property>
- </column>
- <column>
- <property>
- <name>text</name>
- <string>Description</string>
- </property>
- <property>
- <name>clickable</name>
- <bool>true</bool>
- </property>
- <property>
- <name>resizeable</name>
- <bool>true</bool>
- </property>
- </column>
- <column>
- <property>
- <name>text</name>
- <string>Size</string>
- </property>
- <property>
- <name>clickable</name>
- <bool>true</bool>
- </property>
- <property>
- <name>resizeable</name>
- <bool>true</bool>
- </property>
- </column>
- <property stdset="1">
- <name>name</name>
- <cstring>ListViewPackages</cstring>
- </property>
- </widget>
- </vbox>
-</widget>
-</UI>
diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp
index 94ca824..b2ddf95 100644
--- a/noncore/unsupported/oipkg/pmipkg.cpp
+++ b/noncore/unsupported/oipkg/pmipkg.cpp
@@ -1,247 +1,247 @@
#include "pmipkg.h"
#include "pkdesc.h"
#include "pkfind.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 <qpe/qcopenvelope_qws.h>
#include <qdir.h>
#include <qfile.h>
#include <qmultilineedit.h>
#include <qstring.h>
#include <qtextstream.h>
#include <qtextview.h>
#include <stdlib.h>
#include <unistd.h>
#include "mainwindow.h"
#include "runwindow.h"
#define PARSE_FILELIST
// #define IPKG_FILELIST
PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f )
// : RunWindow ( p, name, f )
: QObject ( p )
{
settings = s;
runwindow = new RunWindow ( p, name, f );
- linkDest = new QCopChannel( "QPE/MakeLinks", this );
+ linkDest = new QCopChannel( "QPE/oipkg", this );
connect( linkDest, SIGNAL(received(const QCString &, const QByteArray &)),
this, SLOT(linkDestination( const QString &, const QByteArray&)) );
}
PmIpkg::~PmIpkg()
{
}
//#define PROC
#define SYSTEM
int PmIpkg::runIpkg(const QString& args)
{
pvDebug(2,"PmIpkg::runIpkg "+args);
#ifdef PROC
QStringList cmd = "/usr/bin/ipkg ";
#endif
#ifdef SYSTEM
QString cmd = "/usr/bin/ipkg ";
#endif
cmd += " -dest "+settings->getDestinationName();
cmd += " -force-defaults ";
out( "<hr><br>Starting to "+ args+"<br>\n");
cmd += args;
out( "running:<br>\n"+cmd+"<br>\n" );
int r = 0;
#ifdef PROC
QString o = "start";
Process ipkg( cmd );
QString description;
ipkg.exec("",o);
out( o );
#endif
#ifdef SYSTEM
QString redirect = "/tmp/oipkg.pipe";
cmd += " | tee "+redirect+" 2>&1";
pvDebug(2, "running >"+cmd+"<");
r = system(cmd.latin1());
QFile f( redirect );
while ( ! f.open(IO_ReadOnly) ) {};
// if ( f.open(IO_ReadOnly) ) {};
{
QTextStream t( &f );
QString fp;
while ( !t.eof() )
{
out( t.readLine() +"<br>" );
}
}
f.close();
out( "Finished!<br>");
#endif
return r;
}
void PmIpkg::makeLinks(QString pack)
{
pvDebug( 2, "PmIpkg::makeLinks "+ pack);
out( "<br>creating links<br>" );
QString dest = settings->getDestinationUrl();
out("for package "+pack+" in "+dest+"<br>");
#ifdef IPKG_FILELIST
system(("ipkg -d "+dest+" files "+pack+"> /tmp/oipkg.pipe 2>&1").latin1());
QFile f( "/tmp/oipkg.pipe" );
while ( ! f.open(IO_ReadOnly) ) {};
#endif
#ifdef PARSE_FILELIST
{
Config cfg( "oipkg", Config::User );
cfg.setGroup( "Common" );
QString statusDir = cfg.readEntry( "statusDir", "" );
}
QString fn = dest+"/"+statusDir+"/info/"+pack+".list";
QFile f( fn );
if ( ! f.open(IO_ReadOnly) )
{
out( "<b>Panik!</b> Could not open:<br>"+fn );
};
#endif
QTextStream t( &f );
QString fp;
while ( !t.eof() )
{
fp = t.readLine();
processLinkDir( fp, dest );
}
f.close();
}
void PmIpkg::processLinkDir( QString file, QString dest )
{
#ifdef PARSE_FILELIST
QString destFile = file;
file = dest+"/"+file;
#endif
#ifdef IPKG_FILELIST
QString destFile = file.right( file.length() - dest.length() );
#endif
QFileInfo fileInfo( file );
if ( fileInfo.isDir() )
{
QDir destDir( destFile );
destDir.mkdir( destFile, true );
QDir d( file );
d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks );
const QFileInfoList *list = d.entryInfoList();
QFileInfoListIterator it( *list );
QFileInfo *fi;
while ( (fi=it.current()) )
{
out( "<b>"+fi->absFilePath()+"</b>" );
processLinkDir( fi->absFilePath(), dest );
++it;
}
} else
if ( fileInfo.isFile() )
{
const char *instFile = strdup( (file).ascii() );
const char *linkFile = strdup( (destFile).ascii());
out( "linking: "+file+" -> "+destFile );
qDebug( "linking: %s -> %s", instFile, linkFile );
symlink( instFile, linkFile );
}
}
void PmIpkg::commit( PackageList pl )
{
runwindow->showMaximized();
// exec();
runwindow->outPut->setText("");
out( "<h1>Starting...</h1><br>\n");
QStringList to_remove, to_install;
QString rem="<b>To remove:</b><br>\n";
QString inst="<b>To install:</b><br>\n";;
for( Package *pack = pl.first();pack ; (pack = pl.next()) )
{
if ( pack && (pack->name() != "") && pack)
{
if ( pack->toInstall() )
{
to_install.append( pack->name() );
inst += pack->name()+"<br>";
}
if ( pack->toRemove() )
{
to_remove.append( pack->name() );
rem += pack->name()+"<br>";
}
}
}
out("<p>"+inst+"</p>"+"<p>"+rem+"</p>");
bool ok=TRUE;
qDebug("to remove=%i; to install=%i",to_remove.count(),to_install.count());
int jobs = to_remove.count()+to_install.count();
if ( jobs < 1 ) return;
if ( to_remove.count() )
for (QStringList::ConstIterator it=to_remove.begin(); it!=to_remove.end(); ++it)
if ( runIpkg("remove " + *it) != 0 ) ok = false;
if ( to_install.count() )
for (QStringList::ConstIterator it=to_install.begin(); it!=to_install.end(); ++it)
{
if ( runIpkg("install " + *it) == 0 )
{
if ( settings->createLinks() )
makeLinks( *it );
}else{
ok = false;
}
}
// ##### 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;
}
void PmIpkg::linkDestination( const QString msg, const QByteArray dest )
// add 3rd package parameter
{
qDebug("msg="+msg+" -- "+QString(dest) );
// QDir d( src );
// d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks );
//// if (! d.exists() ) return;
// const QFileInfoList *list = d.entryInfoList();
// QFileInfoListIterator it( *list );
// QFileInfo *fi;
// while ( (fi=it.current()) ) {
// processLinkDir( fi->absFilePath(), dest );
// ++it;
// }
}
void PmIpkg::update()
{
runwindow->showMaximized();
runIpkg( "update" );
}
void PmIpkg::out( QString o )
{
runwindow->outPut->setText( runwindow->outPut->text()+o );
runwindow->outPut->setContentsPos(0,runwindow->outPut->contentsHeight());
}