summaryrefslogtreecommitdiff
authortille <tille>2002-04-27 21:02:53 (UTC)
committer tille <tille>2002-04-27 21:02:53 (UTC)
commit69e271e44d23befc74a96a98708ddb6ec754a4b6 (patch) (side-by-side diff)
tree6f8300d8858d2c7659eb90066b58b302a2863e43
parentacdc33336307e48ac7089b146006fe7b36e321a5 (diff)
downloadopie-69e271e44d23befc74a96a98708ddb6ec754a4b6.zip
opie-69e271e44d23befc74a96a98708ddb6ec754a4b6.tar.gz
opie-69e271e44d23befc74a96a98708ddb6ec754a4b6.tar.bz2
setDocument working and some changes in install gui
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/oipkg/TODO3
-rw-r--r--noncore/unsupported/oipkg/debug.h2
-rw-r--r--noncore/unsupported/oipkg/mainwindow.cpp145
-rw-r--r--noncore/unsupported/oipkg/mainwindow.h22
-rw-r--r--noncore/unsupported/oipkg/oipkg.pro5
-rw-r--r--noncore/unsupported/oipkg/package.cpp56
-rw-r--r--noncore/unsupported/oipkg/package.h4
-rw-r--r--noncore/unsupported/oipkg/packagelistview.cpp91
-rw-r--r--noncore/unsupported/oipkg/packagelistview.h53
-rw-r--r--noncore/unsupported/oipkg/pmipkg.cpp134
-rw-r--r--noncore/unsupported/oipkg/pmipkg.h2
-rw-r--r--noncore/unsupported/oipkg/runwindow.ui32
12 files changed, 340 insertions, 209 deletions
diff --git a/noncore/unsupported/oipkg/TODO b/noncore/unsupported/oipkg/TODO
index b07542a..3fc84e5 100644
--- a/noncore/unsupported/oipkg/TODO
+++ b/noncore/unsupported/oipkg/TODO
@@ -1,10 +1,11 @@
* setDocument function
* Settings Class
* tr() ;)
* Dialog to display ipkg output live
* parse "to install" and "to remove" from status
* install local file
* qcop
* error handling
* manage links
-* dependency checking \ No newline at end of file
+* dependency checking
+* ipkg options in runwindow \ No newline at end of file
diff --git a/noncore/unsupported/oipkg/debug.h b/noncore/unsupported/oipkg/debug.h
index e73b9b2..973d96c 100644
--- a/noncore/unsupported/oipkg/debug.h
+++ b/noncore/unsupported/oipkg/debug.h
@@ -6,16 +6,16 @@
extern int debugLevel;
#define HACK
#define NEWLAYOUT
#define pvDebug(I, S) \
if ( debugLevel < 3 ) \
{ \
if ( I <= debugLevel ) qDebug(S);\
}else{\
if ( I <= debugLevel ) \
- printf("# %s \t\t(Level: %i)\n",QString(S).latin1(),I);\
+ qDebug("# %s \t\t(Level: %i)\n",QString(S).latin1(),I);\
}
#endif \ No newline at end of file
diff --git a/noncore/unsupported/oipkg/mainwindow.cpp b/noncore/unsupported/oipkg/mainwindow.cpp
index e3abf36..6bf9a7a 100644
--- a/noncore/unsupported/oipkg/mainwindow.cpp
+++ b/noncore/unsupported/oipkg/mainwindow.cpp
@@ -5,103 +5,74 @@
#include <qpe/qpemenubar.h>
#include <qpe/qpemessagebox.h>
#include <qpe/resource.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 <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") );
+ settings = new PackageManagerSettings(this,0,TRUE);
+ listViewPackages = new PackageListView( this,"listViewPackages",settings );
+ ipkg = new PmIpkg( settings, this );
- listViewPackages = new QListView( this,0,0 );
- listViewPackages->setSelectionMode(QListView::NoSelection);
setCentralWidget( listViewPackages );
+ setCaption( tr("Package Manager") );
channel = new QCopChannel( "QPE/Application/oipkg", this );
connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
this, SLOT(receive(const QCString&, const QByteArray&)) );
makeMenu();
-#ifdef NEWLAYOUT
- listViewPackages->addColumn( tr("Package") );
- listViewPackages->setRootIsDecorated( true );
-#endif
-#ifndef NEWLAYOUT
- QFontMetrics fm = fontMetrics();
- 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-24;
- 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 );
-#endif
+
connect( section, SIGNAL( activated(int) ),
this, SLOT( sectionChanged() ) );
connect( subsection, SIGNAL(activated(int) ),
this, SLOT( subSectionChanged() ) );
- connect( listViewPackages, SIGNAL( pressed( QListViewItem* ) ),
- this, SLOT( setCurrent( QListViewItem* ) ) );
- connect( listViewPackages, SIGNAL( clicked( QListViewItem* ) ),
- this, SLOT( stopTimer( QListViewItem* ) ) );
-
- popupMenu = new QPopupMenu( this );
-
- 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 );
- popupMenu = new QPopupMenu( this );
- destsMenu = new QPopupMenu( popupMenu );
- popupTimer = new QTimer( this );
- connect( popupTimer, SIGNAL(timeout()), this, SLOT(showPopup()) );
-
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 );
@@ -114,31 +85,32 @@ void MainWindow::makeMenu()
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 );
- 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 );
+// would we use for find
+// 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( "" ),
QString::null, 0, this, 0 );
connect( cfgact, SIGNAL( activated() ),
SLOT( showSettings() ) );
cfgact->addTo( cfgMenu );
cfgact = new QAction( tr( "Servers" ),
// Resource::loadIconSet( "" ),
@@ -307,63 +279,24 @@ void MainWindow::showSettings()
}
void MainWindow::showSettingsSrv()
{
if ( settings->showDialog( 1 ) )
updateList();
}
void MainWindow::showSettingsDst()
{
if ( settings->showDialog( 2 ) )
updateList();
}
-
-void MainWindow::showDetails()
-{
- 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);
- }
- if ( !activePackage )
- {
- details->description->setText(tr("no package selected"));
- details->description->setText(tr("errmm...<br>...not working?"));
- }else{
- 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 )
-{
- if ( !p ) return;
- activePackageListItem = (PackageListItem*)p;
- activePackage = activePackageListItem->getPackage();
- pvDebug(5, "start timer");
- popupTimer->start( 750, true );
-}
-
void MainWindow::sectionShow(bool b)
{
if (b) sectionBar->show();
else sectionBar->hide();
sectionAction->setOn( b );
}
void MainWindow::sectionClose()
{
sectionAction->setOn( false );
}
@@ -380,57 +313,45 @@ void MainWindow::findClose()
}
void MainWindow::rotateUpdateIcon()
{
pvDebug(2, "MainWindow::rotateUpdateIcon");
if ( updateIcon )
updateAction->setIconSet( Resource::loadIconSet( "oipkg/update" ) );
else
updateAction->setIconSet( Resource::loadIconSet( "oipkg/update2" ) );
updateIcon = !updateIcon;
}
-void MainWindow::showPopup()
-{
- popupMenu->clear();
- destsMenu->clear();
-
- QAction *popupAction;
- popupMenu->insertItem( tr("Install to"), destsMenu );
- QStringList dests = settings->getDestinationNames();
- for (uint i = 0; i < dests.count(); i++ )
- {
- popupAction = new QAction( dests[i], QString::null, 0, this, 0 );
- popupAction->addTo( destsMenu );
- }
- connect( destsMenu, SIGNAL( activated( int ) ),
- this, SLOT( changePackageDest( int ) ) );
- popupMenu->popup( QCursor::pos() );
-}
-
-void MainWindow::changePackageDest( int i )
-{
- activePackage->setDest( destsMenu->text(i) );
- activePackage->setOn();
- activePackage->setLink( settings->createLinks() );
- activePackageListItem->displayDetails();
-}
-void MainWindow::stopTimer( QListViewItem* )
+void MainWindow::setDocument(const QString &fileName)
{
- pvDebug( 5, "stop timer" );
- popupTimer->stop();
+ installFile(fileName);
+ // ##### 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::setDocument(const QString &fileName)
+void MainWindow::installFile(const QString &fileName)
{
+ pvDebug(3, "MainWindow::installFile "+fileName);
+ if ( !QFile::exists( fileName ) ) return;
ipkg->installFile( fileName );
+ // ##### 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::receive(const QCString &msg, const QByteArray &arg)
{
pvDebug(3, "QCop "+msg);
- if ( msg == "setDocument(QString)" )
+ if ( msg == "installFile(QString)" )
{
- setDocument( QString(arg) );
+ installFile( QString(arg) );
}
} \ No newline at end of file
diff --git a/noncore/unsupported/oipkg/mainwindow.h b/noncore/unsupported/oipkg/mainwindow.h
index 34943f2..bcb0cc9 100644
--- a/noncore/unsupported/oipkg/mainwindow.h
+++ b/noncore/unsupported/oipkg/mainwindow.h
@@ -1,88 +1,76 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <qmainwindow.h>
#include <qaction.h>
#include <qtimer.h>
#include <qpopupmenu.h>
#include "packagelist.h"
#include "pmipkg.h"
#include "pksettings.h"
-#include "pkdesc.h"
+#include "packagelistview.h"
class QComboBox;
class QPEToolBar;
class QLineEdit;
-class QListView;
class PackageListItem;
class QCopChannel;
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
~MainWindow();
QCopChannel *channel;
protected slots:
void runIpkg();
void getList();
void updateList();
void displayList();
void subSectionChanged();
void sectionChanged();
void showSettings();
void showSettingsSrv();
void showSettingsDst();
- void setDocument (const QString &);
public slots:
- void showDetails();
- void toggleActivePackage();
- void setCurrent( QListViewItem* );
void sectionClose();
void sectionShow(bool);
void findClose();
void findShow(bool);
void filterList();
- void showPopup();
- void changePackageDest( int );
- void stopTimer( QListViewItem* );
void receive (const QCString &, const QByteArray &);
+ void setDocument (const QString &);
private:
void makeMenu();
void setSections();
void setSubSections();
+ void installFile(const QString &);
+ bool updateIcon;
PmIpkg* ipkg;
PackageManagerSettings *settings;
- PackageDetails* details;
PackageList packageList;
- Package *activePackage;
- PackageListItem *activePackageListItem;
QAction *runAction;
QAction *detailsAction;
QAction *updateAction;
QAction *findAction;
QAction *sectionAction;
- QListView *listViewPackages;
+ PackageListView *listViewPackages;
QPEToolBar *findBar;
QLineEdit *findEdit;
QPEToolBar *sectionBar;
QComboBox *section;
QComboBox *subsection;
- QTimer *popupTimer;
- QPopupMenu *popupMenu;
- QPopupMenu *destsMenu;
- bool updateIcon;
private slots:
void rotateUpdateIcon();
};
#endif
diff --git a/noncore/unsupported/oipkg/oipkg.pro b/noncore/unsupported/oipkg/oipkg.pro
index 955c7f3..1f7a70d 100644
--- a/noncore/unsupported/oipkg/oipkg.pro
+++ b/noncore/unsupported/oipkg/oipkg.pro
@@ -1,25 +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 \
+ packagelistview.h \
package.h
SOURCES = main.cpp \
mainwindow.cpp \
+ packagelistview.cpp \
pksettings.cpp \
pmipkg.cpp \
packagelistitem.cpp \
packagelist.cpp \
package.cpp
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/ioclude
LIBS += -lqpe
-INTERFACES = pkdesc.ui \
- runwindow.ui \
+INTERFACES = runwindow.ui \
pksettingsbase.ui
TARGET = oipkg
diff --git a/noncore/unsupported/oipkg/package.cpp b/noncore/unsupported/oipkg/package.cpp
index 9f602b5..5f0e5fa 100644
--- a/noncore/unsupported/oipkg/package.cpp
+++ b/noncore/unsupported/oipkg/package.cpp
@@ -1,61 +1,70 @@
#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;
_status = "";
- _dest = "";
+ _dest = settings->getDestinationName();
+ _link = settings->createLinks();
}
Package::Package( QStringList pack, PackageManagerSettings *s )
{
init(s);
parsePackage( pack );
- _toProcess = false;
}
Package::Package( QString n, PackageManagerSettings *s )
{
init(s);
- _name = QString( n );
- _toProcess = false;
+ if ( !QFile::exists( n ) )
+ {
+ _name = QString( n );
+ }else{
+ parseIpkgFile( n );
+ _toProcess = true;
+ _packageName = QString( n );
+ }
}
Package::Package( Package *pi )
{
init(pi->settings);
copyValues( pi );
- _toProcess = false;
}
void Package::setValue( QString n, QString t )
{
if ( n == "Status" && installed() ) return;
if ( n == "Package" )
{
_name = QString( t );
}
if ( n == "Installed-Size" )
{
@@ -202,30 +211,30 @@ QString Package::subSection()
return _subsection;
}
void Package::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{
- }
+ {
+ QString tag = line.left(sep);
+ QString value = line.mid(sep+2).simplifyWhiteSpace();
+ setValue( tag, value );
+ }else{
+ }
}
return;
}
QString Package::details()
{
QString status;
Process ipkg_status(QStringList() << "ipkg" << "info" << name() );
QString description;
if ( ipkg_status.exec("",status) )
{
QStringList lines = QStringList::split('\n',status,TRUE);
@@ -286,12 +295,37 @@ void Package::setOn()
}
bool Package::link()
{
if ( _dest == "root" || (!installed() && !_toProcess) ) return false;
return _link;
}
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;
+}
diff --git a/noncore/unsupported/oipkg/package.h b/noncore/unsupported/oipkg/package.h
index 6c292ed..31b0010 100644
--- a/noncore/unsupported/oipkg/package.h
+++ b/noncore/unsupported/oipkg/package.h
@@ -34,29 +34,33 @@ class Package //: public QObject
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);
+ void parseIpkgFile( QString );;
public slots:
+ /** No descriptions */
+ QString getPackageName();
void toggleProcess();
private:
PackageManagerSettings *settings;
+ QString _packageName;
QString _name;
bool _toProcess;
bool _link;
QString _status;
QString _size;
QString _section;
QString _subsection;
QString _shortDesc;
QString _desc;
QString _dest;
void parsePackage( QStringList );
void init(PackageManagerSettings *);
diff --git a/noncore/unsupported/oipkg/packagelistview.cpp b/noncore/unsupported/oipkg/packagelistview.cpp
new file mode 100644
index 0000000..693ea6a
--- a/dev/null
+++ b/noncore/unsupported/oipkg/packagelistview.cpp
@@ -0,0 +1,91 @@
+/***************************************************************************
+ packagelistview.cpp - description
+ -------------------
+ begin : Sat Apr 27 2002
+ copyright : (C) 2002 by tille
+ email : tille@handhelds.org
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#include "packagelistview.h"
+
+#include <qpopupmenu.h>
+#include <qaction.h>
+
+#include "packagelistitem.h"
+#include "pksettings.h"
+
+PackageListView::PackageListView(QWidget *p, const char* n, PackageManagerSettings *s)
+ : QListView(p,n)
+{
+ settings = s;
+ popupMenu = new QPopupMenu( this );
+ destsMenu = new QPopupMenu( popupMenu );
+ popupTimer = new QTimer( this );
+ setSelectionMode(QListView::NoSelection);
+ addColumn( tr("Package") );
+ setRootIsDecorated( true );
+
+ connect( popupTimer, SIGNAL(timeout()),
+ this, SLOT(showPopup()) );
+ connect( this, SIGNAL( pressed( 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();
+ pvDebug(5, "start timer");
+ popupTimer->start( 750, true );
+}
+
+
+void PackageListView::showPopup()
+{
+ popupMenu->clear();
+ destsMenu->clear();
+
+ QAction *popupAction;
+ popupMenu->insertItem( QObject::tr("Install to"), destsMenu );
+ QStringList dests = settings->getDestinationNames();
+ for (uint i = 0; i < dests.count(); i++ )
+ {
+ popupAction = new QAction( dests[i], QString::null, 0, this, 0 );
+ popupAction->addTo( destsMenu );
+ }
+ connect( destsMenu, SIGNAL( activated( int ) ),
+ this, SLOT( changePackageDest( int ) ) );
+ popupMenu->popup( QCursor::pos() );
+}
+
+void PackageListView::stopTimer( QListViewItem* )
+{
+ pvDebug( 5, "stop timer" );
+ popupTimer->stop();
+}
+
+
+void PackageListView::changePackageDest( int i )
+{
+ activePackage->setDest( destsMenu->text(i) );
+ activePackage->setOn();
+ activePackage->setLink( settings->createLinks() );
+ activePackageListItem->displayDetails();
+}
diff --git a/noncore/unsupported/oipkg/packagelistview.h b/noncore/unsupported/oipkg/packagelistview.h
new file mode 100644
index 0000000..15e200b
--- a/dev/null
+++ b/noncore/unsupported/oipkg/packagelistview.h
@@ -0,0 +1,53 @@
+/***************************************************************************
+ packagelistview.h - description
+ -------------------
+ begin : Sat Apr 27 2002
+ copyright : (C) 2002 by tille
+ email : tille@handhelds.org
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#ifndef PACKAGELISTVIEW_H
+#define PACKAGELISTVIEW_H
+
+#include <qlistview.h>
+#include <qaction.h>
+#include <qtimer.h>
+#include <qwidget.h>
+#include <qpopupmenu.h>
+#include "debug.h"
+
+class PackageListItem;
+class Package;
+class PackageManagerSettings;
+
+class PackageListView : public QListView
+{
+ Q_OBJECT
+
+public:
+ PackageListView(QWidget*, const char*, PackageManagerSettings*);
+// ~PackageListView();
+ QTimer *popupTimer;
+private:
+ PackageManagerSettings *settings;
+ Package *activePackage;
+ PackageListItem *activePackageListItem;
+ QPopupMenu *popupMenu;
+ QPopupMenu *destsMenu;
+public slots:
+ void showPopup();
+ void changePackageDest( int );
+ void setCurrent( QListViewItem* );
+ void stopTimer( QListViewItem* );
+};
+
+#endif
diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp
index 45c89c5..f0992f5 100644
--- a/noncore/unsupported/oipkg/pmipkg.cpp
+++ b/noncore/unsupported/oipkg/pmipkg.cpp
@@ -1,26 +1,26 @@
#include "pmipkg.h"
-#include "pkdesc.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 <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"
@@ -48,39 +48,42 @@ int PmIpkg::runIpkg(const QString& args, const QString& dest )
#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 (runwindow->forcedepends->isChecked())
+// cmd += " -force-depends ";
+
out( "<hr><br>Starting to "+ args+"<br>\n");
cmd += args;
int r = 0;
#ifdef PROC
QString o = "start";
Process *ipkg = new Process( "ls");//cmd );
out( "running:<br>\n"+ipkg->arguments().join(" ")+"<br>\n" );
QString description;
ipkg->exec("",o);
// out( o );
#endif
#ifdef SYSTEM
out( "running:<br>\n"+cmd+"<br>\n" );
QString redirect = "/tmp/oipkg.pipe";
- cmd += " | tee "+redirect+" 2>&1";
+ 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 );
// QString fp;
while ( !t.eof() )
{
line = t.readLine();
@@ -94,55 +97,56 @@ int PmIpkg::runIpkg(const QString& args, const QString& dest )
f.close();
out( "Finished!<br>");
#endif
return r;
}
void PmIpkg::makeLinks(Package *pack)
{
pvDebug( 2, "PmIpkg::makeLinks "+ pack->name());
QString dest = settings->getDestinationUrlByName( pack->dest() );
if (dest == "/" ) return;
- out( "<br>creating links<br>" );
- out("for package "+pack->name()+" in "+dest+"<br>");
{
Config cfg( "oipkg", Config::User );
cfg.setGroup( "Common" );
QString statusDir = cfg.readEntry( "statusDir", "" );
}
QString fn = dest+"/"+statusDir+"/info/"+pack->name()+".list";
linkPackage( fn, dest );
}
void PmIpkg::linkPackage( QString packFileName, QString dest )
{
QFile f( packFileName );
if ( ! f.open(IO_ReadOnly) )
{
out( "<b>Panik!</b> Could not open:<br>"+packFileName );
return;
};
+ out( "<br>creating links<br>" );
+ out("for package "+packFileName+" in "+dest+"<br>");
QTextStream t( &f );
QString fp;
while ( !t.eof() )
{
fp = t.readLine();
processLinkDir( fp, dest );
}
f.close();
}
void PmIpkg::processLinkDir( QString file, QString dest )
{
+ pvDebug( 7,"PmIpkg::processLinkDir "+file+" to "+ dest);
if ( dest == "???" ) return;
QString destFile = file;
file = dest+"/"+file;
if (file == dest) return;
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();
@@ -158,70 +162,120 @@ void PmIpkg::processLinkDir( QString file, QString dest )
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 )
{
- show( false );
- runwindow->outPut->setText("");
- out( "<h1>"+tr("Todo")+"</h1>\n");
-
+ int sizecount = 0;
to_install.clear();
to_remove.clear();
- int sizecount = 0;
- QString rem="<b>To remove:</b><br>\n";
- QString inst="<b>To install:</b><br>\n";;
+ QString rem="<b>"+tr("To remove:")+"</b><br>\n";
+ QString inst="<b>"+tr("To install:")+"</b><br>\n";
pl.allPackages();
for( Package *pack = pl.first();pack ; (pack = pl.next()) )
{
if ( pack && (pack->name() != "") && pack)
{
if ( pack->toInstall() )
{
to_install.append( pack );
sizecount += pack->size().toInt();
- inst += pack->name()+"\t(on "+pack->dest()+")<br>";
+ inst += pack->name()+"\t("+tr("on ")+pack->dest()+")<br>";
}
if ( pack->toRemove() )
{
to_remove.append( pack );
sizecount += 1;
rem += pack->name()+"<br>";
}
}
}
- out("<p>"+inst+"</p>"+"<p>"+rem+"</p><hl>");
-
- qDebug("to remove=%i; to install=%i",to_remove.count(),to_install.count());
+ startDialog();
- runwindow->progress->setTotalSteps( sizecount );
+}
- connect( runwindow->doItButton, SIGNAL( clicked() ),
- SLOT( doIt() ) );
- connect( runwindow->installButton, SIGNAL( clicked() ),
+void PmIpkg::startDialog()
+{
+ QDialog *d = new QDialog();
+ QGridLayout *RunWindowLayout = new QGridLayout( d );
+ RunWindowLayout->setSpacing( 2 );
+ RunWindowLayout->setMargin( 2 );
+
+ QHBoxLayout *buttons = new QHBoxLayout;
+ buttons->setSpacing( 6 );
+ buttons->setMargin( 0 );
+
+ PackageListView *plv = new PackageListView(d, "install",settings);
+ RunWindowLayout->addWidget( plv, 1, 0 );
+ for (Package *it=to_remove.first(); it != 0; it=to_remove.next() )
+ {
+ plv->insertItem( new PackageListItem(plv, it,settings) );
+ }
+ for (Package *it=to_install.first(); it != 0; it=to_install.next() )
+ {
+ plv->insertItem( new PackageListItem(plv, it,settings) );
+ }
+ QPushButton *doItButton = new QPushButton( d, "doItButton" );
+ doItButton->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, doItButton->sizePolicy().hasHeightForWidth() ) );
+ QFont doItButton_font( doItButton->font() );
+ doItButton_font.setPointSize( 8 );
+ doItButton->setFont( doItButton_font );
+ doItButton->setText( tr( "Do all " ) );
+ doItButton->setAutoResize( FALSE );
+ buttons->addWidget( doItButton );
+
+ QPushButton *installButton = new QPushButton( d, "installButton" );
+ QFont installButton_font( installButton->font() );
+ installButton_font.setPointSize( 8 );
+ installButton->setFont( installButton_font );
+ installButton->setText( tr( "Install" ) );
+ installButton->setAutoResize( TRUE );
+ buttons->addWidget( installButton );
+
+ QPushButton *removeButton = new QPushButton( d, "removeButton" );
+ QFont removeButton_font( removeButton->font() );
+ removeButton_font.setPointSize( 7 );
+ removeButton->setFont( removeButton_font );
+ removeButton->setText( tr( "Remove" ) );
+ removeButton->setAutoResize( TRUE );
+ buttons->addWidget( removeButton );
+
+ QPushButton *cancelButton = new QPushButton( d, "cancelButton" );
+ QFont cancelButton_font( cancelButton->font() );
+ cancelButton_font.setPointSize( 8 );
+ cancelButton->setFont( cancelButton_font );
+ cancelButton->setText( tr( "Cancel" ) );
+ cancelButton->setAutoResize( TRUE );
+ buttons->addWidget( cancelButton );
+
+ RunWindowLayout->addLayout( buttons, 3, 0 );
+
+ connect( doItButton, SIGNAL( clicked() ),
+ this, SLOT( doIt() ) );
+ connect( installButton, SIGNAL( clicked() ),
this, SLOT( install() ) );
- connect( runwindow->removeButton, SIGNAL( clicked() ),
+ connect( removeButton, SIGNAL( clicked() ),
this, SLOT( remove() ) );
- connect( runwindow->cancelButton, SIGNAL( clicked() ),
- runwindow, SLOT( close() ) );
-
- runwindow->exec();
- out("<h1>"+tr("Its now save to close this window")+"<h1>");
+ connect( cancelButton, SIGNAL( clicked() ),
+ d, SLOT( close() ) );
+ d->showMaximized();
+ d->exec();
+ // d->close();
}
void PmIpkg::doIt()
{
remove();
install();
}
void PmIpkg::remove()
{
if ( to_remove.count() == 0 ) return;
@@ -242,25 +296,25 @@ void PmIpkg::remove()
}
}
void PmIpkg::install()
{
if ( to_install.count() == 0 ) return;
show( true );
out("<hr><hr><b>"+tr("Installing")+"<br>"+tr("please wait")+"</b><br>");
for (Package *it=to_install.first(); it != 0; it=to_install.next() )
{
- if ( runIpkg("install " + it->name(), it->dest() ) == 0 )
+ if ( runIpkg("install " + it->getPackageName(), it->dest() ) == 0 )
{
runwindow->progress->setProgress( it->size().toInt() + runwindow->progress->progress());
if ( it->link() )
makeLinks( it );
it->processed();
}else{
out("<b>"+tr("Error while installing")+"</b>"+it->name());
}
}
}
void PmIpkg::linkDestination( const QString msg, const QByteArray dest )
@@ -305,44 +359,28 @@ void PmIpkg::showButtons(bool b)
runwindow->doItButton->show();
runwindow->removeButton->show();
runwindow->installButton->show();
}
}
void PmIpkg::show(bool b)
{
if (!runwindow->isVisible())
runwindow->showMaximized();
showButtons(b);
- if ( b )
+ if ( !b )
runwindow->progress->hide();
else
runwindow->progress->show();
}
void PmIpkg::installFile(const QString &fileName)
{
+
+ to_install.clear();
+ to_remove.clear();
pvDebug( 2,"PmIpkg::installFile "+ fileName);
- show( false );
- runwindow->outPut->setText("");
- fileNameToInstall = fileName;
- runwindow->doItButton->hide();
- runwindow->removeButton->hide();
- out("<b>"+tr("Install: ")+fileName);
- connect( runwindow->installButton, SIGNAL( clicked() ),
- this, SLOT( installFileName() ) );
- connect( runwindow->cancelButton, SIGNAL( clicked() ),
- runwindow, SLOT( close() ) );
-
- runwindow->exec();
+ to_install.append( new Package(fileName,settings) );
+ startDialog();
}
-void PmIpkg::installFileName()
-{
- if ( !QFile::exists( fileNameToInstall ) ) return;
- out(tr("Installing pacakge ")+fileNameToInstall+"<br>"+tr("please wait")+"</b><br>");
- runIpkg("install " + fileNameToInstall );
- if ( settings->createLinks() )
- linkPackage( fileNameToInstall, settings->getDestinationUrl() );
- out("<h1>"+tr("Its now save to close this window")+"<h1>");
-} \ No newline at end of file
diff --git a/noncore/unsupported/oipkg/pmipkg.h b/noncore/unsupported/oipkg/pmipkg.h
index 8e06f4c..f70283e 100644
--- a/noncore/unsupported/oipkg/pmipkg.h
+++ b/noncore/unsupported/oipkg/pmipkg.h
@@ -24,28 +24,28 @@ public:
PackageList* getPackageList();
void showButtons(bool b=true);
void show( bool buttons=true );
private:
PackageManagerSettings* settings;
RunWindow *runwindow;
QList<Package> to_remove;
QList<Package> to_install;
bool runwindowopen;
QString fileNameToInstall;
+ void startDialog();
void makeLinks(Package*);
void linkPackage( QString, QString );
void processLinkDir( QString, QString );
int runIpkg(const QString& args, const QString& dest="" );
void out( QString );
public slots:
void doIt();
void install();
- void installFileName();
void remove();
void installFile(const QString &fileName);
void linkDestination( const QString, const QByteArray );
};
#endif
diff --git a/noncore/unsupported/oipkg/runwindow.ui b/noncore/unsupported/oipkg/runwindow.ui
index 52da408..8582ce8 100644
--- a/noncore/unsupported/oipkg/runwindow.ui
+++ b/noncore/unsupported/oipkg/runwindow.ui
@@ -3,25 +3,25 @@
<widget>
<class>QDialog</class>
<property stdset="1">
<name>name</name>
<cstring>RunWindow</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>0</x>
<y>0</y>
<width>344</width>
- <height>291</height>
+ <height>442</height>
</rect>
</property>
<property stdset="1">
<name>caption</name>
<string>running...</string>
</property>
<property>
<name>layoutMargin</name>
</property>
<property>
<name>layoutSpacing</name>
</property>
@@ -36,38 +36,25 @@
</property>
<widget row="0" column="0" >
<class>QProgressBar</class>
<property stdset="1">
<name>name</name>
<cstring>progress</cstring>
</property>
<property stdset="1">
<name>progress</name>
<number>0</number>
</property>
</widget>
- <widget row="1" column="0" >
- <class>QTextView</class>
- <property stdset="1">
- <name>name</name>
- <cstring>outPut</cstring>
- </property>
- <property stdset="1">
- <name>font</name>
- <font>
- <pointsize>6</pointsize>
- </font>
- </property>
- </widget>
- <widget row="2" column="0" >
+ <widget row="3" column="0" >
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>buttons</cstring>
</property>
<hbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
@@ -89,25 +76,25 @@
<property stdset="1">
<name>font</name>
<font>
<pointsize>8</pointsize>
</font>
</property>
<property stdset="1">
<name>text</name>
<string>Do all </string>
</property>
<property stdset="1">
<name>autoResize</name>
- <bool>true</bool>
+ <bool>false</bool>
</property>
</widget>
<widget>
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>installButton</cstring>
</property>
<property stdset="1">
<name>font</name>
<font>
<pointsize>8</pointsize>
@@ -157,15 +144,28 @@
</property>
<property stdset="1">
<name>text</name>
<string>Cancel</string>
</property>
<property stdset="1">
<name>autoResize</name>
<bool>true</bool>
</property>
</widget>
</hbox>
</widget>
+ <widget row="1" column="0" >
+ <class>QTextView</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>outPut</cstring>
+ </property>
+ <property stdset="1">
+ <name>font</name>
+ <font>
+ <pointsize>6</pointsize>
+ </font>
+ </property>
+ </widget>
</grid>
</widget>
</UI>