summaryrefslogtreecommitdiff
path: root/noncore/settings/packagemanager
authordrw <drw>2004-01-24 01:30:42 (UTC)
committer drw <drw>2004-01-24 01:30:42 (UTC)
commitd542ba6a426f9868d521dbd9eb502184086535fc (patch) (side-by-side diff)
tree6c975a8d20949d10dc48f2f372b836032988dcbd /noncore/settings/packagemanager
parent77ad4fd70864e36745dbee587ca959a2e56998a6 (diff)
downloadopie-d542ba6a426f9868d521dbd9eb502184086535fc.zip
opie-d542ba6a426f9868d521dbd9eb502184086535fc.tar.gz
opie-d542ba6a426f9868d521dbd9eb502184086535fc.tar.bz2
Added download packages (requires current version of libipkg) and code to have Opie update links so apps will display properly in Launcher after adding/removing
Diffstat (limited to 'noncore/settings/packagemanager') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/packagemanager/ChangeLog6
-rw-r--r--noncore/settings/packagemanager/entrydlg.cpp82
-rw-r--r--noncore/settings/packagemanager/entrydlg.h57
-rw-r--r--noncore/settings/packagemanager/installdlg.cpp2
-rw-r--r--noncore/settings/packagemanager/mainwindow.cpp50
-rw-r--r--noncore/settings/packagemanager/mainwindow.h2
-rw-r--r--noncore/settings/packagemanager/oipkg.cpp9
-rw-r--r--noncore/settings/packagemanager/packagemanager.pro4
-rw-r--r--noncore/settings/packagemanager/promptdlg.cpp2
9 files changed, 185 insertions, 29 deletions
diff --git a/noncore/settings/packagemanager/ChangeLog b/noncore/settings/packagemanager/ChangeLog
index 1ba12af..efa75b1 100644
--- a/noncore/settings/packagemanager/ChangeLog
+++ b/noncore/settings/packagemanager/ChangeLog
@@ -1,3 +1,9 @@
+2004-01-23 Dan Williams <drw@handhelds.org>
+
+ * Added package download functionality
+ * Have Opie update links after install/removal so that apps
+ will display properly in Launcher
+
2004-01-20 Dan Williams <drw@handhelds.org>
* Released version 0.2.0
diff --git a/noncore/settings/packagemanager/entrydlg.cpp b/noncore/settings/packagemanager/entrydlg.cpp
new file mode 100644
index 0000000..8deaa37
--- a/dev/null
+++ b/noncore/settings/packagemanager/entrydlg.cpp
@@ -0,0 +1,82 @@
+/*
+                This file is part of the OPIE Project
+
+ =. Copyright (c) 2004 Dan Williams <drw@handhelds.org>
+             .=l.
+           .>+-=
+ _;:,     .>    :=|. This file is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This file is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+    : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
+..}^=.=       =       ; Public License for more details.
+++=   -.     .`     .:
+ :     =  ...= . :.=- You should have received a copy of the GNU
+ -.   .:....=;==+<; General Public License along with this file;
+  -_. . .   )=.  = see the file COPYING. If not, write to the
+    --        :-=` Free Software Foundation, Inc.,
+ 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+*/
+
+#include "entrydlg.h"
+
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+
+EntryDlg::EntryDlg( const QString &label, QWidget* parent, const char* name, bool modal )
+ : QDialog( parent, name, modal )
+{
+ QVBoxLayout *vbox = new QVBoxLayout( this, 6, 6 );
+
+ QLabel *l = new QLabel( label, this );
+ l->setAlignment( AlignLeft | AlignTop | WordBreak );
+ vbox->addWidget( l );
+
+ m_entry = new QLineEdit( this );
+ vbox->addWidget( m_entry );
+
+ connect( m_entry, SIGNAL(returnPressed()), this, SLOT(tryAccept()) );
+}
+
+void EntryDlg::setText( const QString &text )
+{
+ m_entry->setText( text );
+ m_entry->selectAll();
+}
+
+QString EntryDlg::getText()
+{
+ return m_entry->text();
+}
+
+QString EntryDlg::getText( const QString &caption, const QString &label, const QString &text, bool *ok,
+ QWidget *parent, const char *name )
+{
+ EntryDlg *dlg = new EntryDlg( label, parent, name, true );
+ dlg->setCaption( caption );
+ dlg->setText( text );
+
+ QString result;
+ *ok = ( dlg->exec() == QDialog::Accepted );
+ if ( *ok )
+ result = dlg->getText();
+
+ delete dlg;
+ return result;
+}
+void EntryDlg::tryAccept()
+{
+ if ( !m_entry->text().isEmpty() )
+ accept();
+}
diff --git a/noncore/settings/packagemanager/entrydlg.h b/noncore/settings/packagemanager/entrydlg.h
new file mode 100644
index 0000000..33a7920
--- a/dev/null
+++ b/noncore/settings/packagemanager/entrydlg.h
@@ -0,0 +1,57 @@
+/*
+                This file is part of the OPIE Project
+
+ =. Copyright (c) 2004 Dan Williams <drw@handhelds.org>
+             .=l.
+           .>+-=
+ _;:,     .>    :=|. This file is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This file is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+    : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
+..}^=.=       =       ; Public License for more details.
+++=   -.     .`     .:
+ :     =  ...= . :.=- You should have received a copy of the GNU
+ -.   .:....=;==+<; General Public License along with this file;
+  -_. . .   )=.  = see the file COPYING. If not, write to the
+    --        :-=` Free Software Foundation, Inc.,
+ 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+*/
+
+#ifndef ENTRYDLG_H
+#define ENTRYDLG_H
+
+#include <qdialog.h>
+
+class QLineEdit;
+
+class EntryDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ static QString getText( const QString &caption, const QString &label, const QString &text = QString::null,
+ bool *ok = 0, QWidget *parent = 0, const char *name = 0 );
+
+ EntryDlg( const QString &label, QWidget* parent = 0, const char* name = 0, bool modal = true );
+
+ void setText( const QString &text );
+ QString getText();
+
+private slots:
+ void tryAccept();
+
+private:
+ QLineEdit *m_entry;
+};
+
+#endif // EntryDlg_H
diff --git a/noncore/settings/packagemanager/installdlg.cpp b/noncore/settings/packagemanager/installdlg.cpp
index 6a9ccbd..0c2ea78 100644
--- a/noncore/settings/packagemanager/installdlg.cpp
+++ b/noncore/settings/packagemanager/installdlg.cpp
@@ -141,6 +141,8 @@ InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &cap
break;
case OPackage::Upgrade : lineStr.append( tr( "upgrade" ) );
break;
+ case OPackage::Download : lineStr.append( tr( "download" ) );
+ break;
default :
break;
};
diff --git a/noncore/settings/packagemanager/mainwindow.cpp b/noncore/settings/packagemanager/mainwindow.cpp
index 4611404..486561d 100644
--- a/noncore/settings/packagemanager/mainwindow.cpp
+++ b/noncore/settings/packagemanager/mainwindow.cpp
@@ -28,6 +28,7 @@
*/
#include <qaction.h>
+#include <qdir.h>
#include <qlayout.h>
#include <qlineedit.h>
#include <qmenubar.h>
@@ -37,6 +38,7 @@
#include <qtoolbar.h>
#include <qwhatsthis.h>
+#include <qpe/qcopenvelope_qws.h>
#include <qpe/qpeapplication.h>
#include <qpe/resource.h>
@@ -44,6 +46,7 @@
#include "installdlg.h"
#include "filterdlg.h"
#include "promptdlg.h"
+#include "entrydlg.h"
MainWindow::MainWindow( QWidget *parent, const char *name, WFlags fl )
: QMainWindow( parent, name, fl || WStyle_ContextHelp )
@@ -162,7 +165,6 @@ void MainWindow::initUI()
actionUpgrade->addTo( popup );
actionUpgrade->addTo( &m_toolBar );
-/*
QPixmap iconDownload = Resource::loadPixmap( "packagemanager/download" );
QPixmap iconRemove = Resource::loadPixmap( "packagemanager/remove" );
QAction *actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 );
@@ -170,7 +172,6 @@ void MainWindow::initUI()
connect( actionDownload, SIGNAL(activated()), this, SLOT(slotDownload()) );
actionDownload->addTo( popup );
actionDownload->addTo( &m_toolBar );
-*/
a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "packagemanager/apply" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) );
@@ -370,7 +371,6 @@ void MainWindow::slotUpgrade()
m_widgetStack.raiseWidget( dlg );
}
-/*
void MainWindow::slotDownload()
{
// Retrieve list of packages selected for download (if any)
@@ -386,7 +386,8 @@ void MainWindow::slotDownload()
if ( workingPackages->isEmpty() )
{
- // No packages were selected, prompt for URL of package to download
+ QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) );
+ return;
}
else
{
@@ -394,33 +395,29 @@ void MainWindow::slotDownload()
m_config.setGroup( "settings" );
QString workingDir = m_config.readEntry( "DownloadDir", "/tmp" );
-// QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), workingDir, &ok, this );
-// if ( ok && !text.isEmpty() )
-// workingDir = text; // user entered something and pressed ok
-// else
-// return; // user entered nothing or pressed cancel
+ bool ok = false;
+ QString text = EntryDlg::getText( tr( "Download" ), tr( "Enter path to download package to:" ), workingDir, &ok, this );
+ if ( ok && !text.isEmpty() )
+ workingDir = text; // user entered something and pressed ok
+ else
+ return; // user entered nothing or pressed cancel
-// // Store download directory in config file
-// m_config.writeEntry( "DownloadDir", workingDir );
+ // Store download directory in config file
+ m_config.writeEntry( "DownloadDir", workingDir );
// Get starting directory
-// char initDir[PATH_MAX];
-// getcwd( initDir, PATH_MAX );
+ QDir::setCurrent( workingDir );
- // Download packages
+ // Create package manager output widget
+ InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Download packages" ), false,
+ OPackage::Download, workingPackages );
+ connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseInstallDlg()) );
+ // Display widget
+ m_widgetStack.addWidget( dlg, 3 );
+ m_widgetStack.raiseWidget( dlg );
}
-
- // Create package manager output widget
- InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Download packages" ), false,
- OPackage::Download, workingPackages );
- connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseInstallDlg()) );
-
- // Display widget
- m_widgetStack.addWidget( dlg, 3 );
- m_widgetStack.raiseWidget( dlg );
}
-*/
void MainWindow::slotApply()
{
@@ -526,6 +523,11 @@ void MainWindow::slotCloseInstallDlg()
// Reload package list
initPackageInfo();
+
+ // Update Opie launcher links
+ QCopEnvelope e("QPE/System", "linkChanged(QString)");
+ QString lf = QString::null;
+ e << lf;
}
void MainWindow::slotConfigure()
diff --git a/noncore/settings/packagemanager/mainwindow.h b/noncore/settings/packagemanager/mainwindow.h
index 49bb66c..285cddf 100644
--- a/noncore/settings/packagemanager/mainwindow.h
+++ b/noncore/settings/packagemanager/mainwindow.h
@@ -114,7 +114,7 @@ private slots:
// Actions menu action slots
void slotUpdate();
void slotUpgrade();
-// void slotDownload();
+ void slotDownload();
void slotApply();
void slotCloseInstallDlg();
void slotConfigure();
diff --git a/noncore/settings/packagemanager/oipkg.cpp b/noncore/settings/packagemanager/oipkg.cpp
index eeb0131..ed9ea10 100644
--- a/noncore/settings/packagemanager/oipkg.cpp
+++ b/noncore/settings/packagemanager/oipkg.cpp
@@ -327,8 +327,13 @@ bool OIpkg::executeCommand( OPackage::Command command, QStringList *parameters,
}
};
break;
- //case OPackage::Download : ;
- // break;
+ case OPackage::Download : {
+ for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it )
+ {
+ ipkg_packages_download( &m_ipkgArgs, (*it) );
+ }
+ };
+ break;
default : break;
};
diff --git a/noncore/settings/packagemanager/packagemanager.pro b/noncore/settings/packagemanager/packagemanager.pro
index 55af13e..9a64322 100644
--- a/noncore/settings/packagemanager/packagemanager.pro
+++ b/noncore/settings/packagemanager/packagemanager.pro
@@ -13,6 +13,7 @@ SOURCES = opackage.cpp \
packageinfodlg.cpp \
filterdlg.cpp \
promptdlg.cpp \
+ entrydlg.cpp \
main.cpp
HEADERS = opackage.h \
oconfitem.h \
@@ -23,7 +24,8 @@ HEADERS = opackage.h \
installdlg.h \
packageinfodlg.h \
filterdlg.h \
- promptdlg.h
+ promptdlg.h \
+ entrydlg.h
DEFINES += IPKG_LIB
DEFINES += HAVE_MKDTEMP
diff --git a/noncore/settings/packagemanager/promptdlg.cpp b/noncore/settings/packagemanager/promptdlg.cpp
index 3122699..bb27190 100644
--- a/noncore/settings/packagemanager/promptdlg.cpp
+++ b/noncore/settings/packagemanager/promptdlg.cpp
@@ -45,7 +45,7 @@ PromptDlg::PromptDlg( const QString &caption, const QString &text, const QString
QGridLayout *layout = new QGridLayout( this, 2, 2, 4, 2 );
QLabel *label = new QLabel( text, this );
- label->setAlignment( AlignCenter | WordBreak );
+ label->setAlignment( AlignCenter | AlignTop | WordBreak );
layout->addMultiCellWidget( label, 0, 0, 0, 1 );
QPushButton *btn = new QPushButton( btn1, this );