summaryrefslogtreecommitdiff
authortille <tille>2002-04-27 14:35:48 (UTC)
committer tille <tille>2002-04-27 14:35:48 (UTC)
commit320532727fc7dfbe9760d0eea0e17b8e1230fc8e (patch) (side-by-side diff)
treed65575cdd4c89e6a531b178de04198f39d8276c0
parentdb90999f6298c1107888f062f2c25cb8817b528a (diff)
downloadopie-320532727fc7dfbe9760d0eea0e17b8e1230fc8e.zip
opie-320532727fc7dfbe9760d0eea0e17b8e1230fc8e.tar.gz
opie-320532727fc7dfbe9760d0eea0e17b8e1230fc8e.tar.bz2
added setDocument and a qcop call to install a file
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/unsupported/oipkg/TODO2
-rw-r--r--noncore/unsupported/oipkg/mainwindow.cpp18
-rw-r--r--noncore/unsupported/oipkg/mainwindow.h5
-rw-r--r--noncore/unsupported/oipkg/pmipkg.cpp38
-rw-r--r--noncore/unsupported/oipkg/pmipkg.h4
5 files changed, 64 insertions, 3 deletions
diff --git a/noncore/unsupported/oipkg/TODO b/noncore/unsupported/oipkg/TODO
index 744cba4..b07542a 100644
--- a/noncore/unsupported/oipkg/TODO
+++ b/noncore/unsupported/oipkg/TODO
@@ -1,8 +1,10 @@
+* 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
diff --git a/noncore/unsupported/oipkg/mainwindow.cpp b/noncore/unsupported/oipkg/mainwindow.cpp
index 25ca889..e3abf36 100644
--- a/noncore/unsupported/oipkg/mainwindow.cpp
+++ b/noncore/unsupported/oipkg/mainwindow.cpp
@@ -12,48 +12,52 @@
#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") );
listViewPackages = new QListView( this,0,0 );
listViewPackages->setSelectionMode(QListView::NoSelection);
setCentralWidget( listViewPackages );
+ 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() ) );
@@ -395,24 +399,38 @@ void MainWindow::showPopup()
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* )
{
pvDebug( 5, "stop timer" );
popupTimer->stop();
}
+
+void MainWindow::setDocument(const QString &fileName)
+{
+ ipkg->installFile( fileName );
+}
+
+void MainWindow::receive(const QCString &msg, const QByteArray &arg)
+{
+ pvDebug(3, "QCop "+msg);
+ if ( msg == "setDocument(QString)" )
+ {
+ setDocument( QString(arg) );
+ }
+} \ No newline at end of file
diff --git a/noncore/unsupported/oipkg/mainwindow.h b/noncore/unsupported/oipkg/mainwindow.h
index adc5e78..34943f2 100644
--- a/noncore/unsupported/oipkg/mainwindow.h
+++ b/noncore/unsupported/oipkg/mainwindow.h
@@ -1,75 +1,80 @@
#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"
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 &);
private:
void makeMenu();
void setSections();
void setSubSections();
PmIpkg* ipkg;
PackageManagerSettings *settings;
PackageDetails* details;
PackageList packageList;
Package *activePackage;
PackageListItem *activePackageListItem;
QAction *runAction;
QAction *detailsAction;
QAction *updateAction;
QAction *findAction;
QAction *sectionAction;
QListView *listViewPackages;
QPEToolBar *findBar;
QLineEdit *findEdit;
QPEToolBar *sectionBar;
QComboBox *section;
QComboBox *subsection;
QTimer *popupTimer;
diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp
index 3b31b4d..45c89c5 100644
--- a/noncore/unsupported/oipkg/pmipkg.cpp
+++ b/noncore/unsupported/oipkg/pmipkg.cpp
@@ -90,52 +90,57 @@ int PmIpkg::runIpkg(const QString& args, const QString& dest )
oldLine = line;
}
}
// }
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";
- QFile f( fn );
+ 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>"+fn );
+ out( "<b>Panik!</b> Could not open:<br>"+packFileName );
return;
};
QTextStream t( &f );
QString fp;
while ( !t.eof() )
{
fp = t.readLine();
processLinkDir( fp, dest );
}
f.close();
}
void PmIpkg::processLinkDir( QString file, QString 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 );
@@ -186,49 +191,49 @@ void PmIpkg::commit( PackageList pl )
{
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());
runwindow->progress->setTotalSteps( sizecount );
connect( runwindow->doItButton, SIGNAL( clicked() ),
SLOT( doIt() ) );
connect( runwindow->installButton, SIGNAL( clicked() ),
this, SLOT( install() ) );
connect( runwindow->removeButton, SIGNAL( clicked() ),
this, SLOT( remove() ) );
connect( runwindow->cancelButton, SIGNAL( clicked() ),
runwindow, SLOT( close() ) );
runwindow->exec();
- return;
+ out("<h1>"+tr("Its now save to close this window")+"<h1>");
}
void PmIpkg::doIt()
{
remove();
install();
}
void PmIpkg::remove()
{
if ( to_remove.count() == 0 ) return;
show( true );
out("<hr><hr><b>"+tr("Removing")+"<br>"+tr("please wait")+"</b><br>");
for (Package *it=to_remove.first(); it != 0; it=to_remove.next() )
{
if ( runIpkg("remove " + it->name()) == 0)
{
runwindow->progress->setProgress( it->size().toInt() + runwindow->progress->progress());
it->processed();
runwindow->progress->setProgress( 1 );
}else{
@@ -293,24 +298,51 @@ void PmIpkg::showButtons(bool b)
{
runwindow->cancelButton->hide();
runwindow->doItButton->hide();
runwindow->removeButton->hide();
runwindow->installButton->hide();
}else{
runwindow->cancelButton->show();
runwindow->doItButton->show();
runwindow->removeButton->show();
runwindow->installButton->show();
}
}
void PmIpkg::show(bool b)
{
if (!runwindow->isVisible())
runwindow->showMaximized();
showButtons(b);
if ( b )
runwindow->progress->hide();
else
runwindow->progress->show();
}
+
+void PmIpkg::installFile(const QString &fileName)
+{
+ 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();
+}
+
+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 c57adb7..8e06f4c 100644
--- a/noncore/unsupported/oipkg/pmipkg.h
+++ b/noncore/unsupported/oipkg/pmipkg.h
@@ -10,38 +10,42 @@
#include "runwindow.h"
#include "packagelist.h"
#include "debug.h"
class Package;
class PmIpkg : public QObject
{
Q_OBJECT
public:
PmIpkg( PackageManagerSettings* , QWidget* p=0, const char * name=0, WFlags f=0 );
~PmIpkg();
void commit( PackageList );
void update();
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 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