summaryrefslogtreecommitdiff
authordrw <drw>2003-02-01 02:07:22 (UTC)
committer drw <drw>2003-02-01 02:07:22 (UTC)
commit766f09a89eef17808e77836f76371aab8ebc4c1c (patch) (side-by-side diff)
tree3a298c40d5b688dc409a0e6d251a514d88eada48
parent266feac1ac442947651bf169dbf993c4d46d56ea (diff)
downloadopie-766f09a89eef17808e77836f76371aab8ebc4c1c.zip
opie-766f09a89eef17808e77836f76371aab8ebc4c1c.tar.gz
opie-766f09a89eef17808e77836f76371aab8ebc4c1c.tar.bz2
Many updates to install dialog
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/aqpkg/.cvsignore2
-rw-r--r--noncore/settings/aqpkg/aqpkg.pro1
-rw-r--r--noncore/settings/aqpkg/install.ui147
-rw-r--r--noncore/settings/aqpkg/installdlgimpl.cpp128
-rw-r--r--noncore/settings/aqpkg/installdlgimpl.h32
-rw-r--r--noncore/settings/aqpkg/mainwin.cpp84
-rw-r--r--noncore/settings/aqpkg/mainwin.h3
7 files changed, 157 insertions, 240 deletions
diff --git a/noncore/settings/aqpkg/.cvsignore b/noncore/settings/aqpkg/.cvsignore
index ef0e27f..751040e 100644
--- a/noncore/settings/aqpkg/.cvsignore
+++ b/noncore/settings/aqpkg/.cvsignore
@@ -1,10 +1,8 @@
Makefile*
-install.cpp
-install.h
instoptions.cpp
instoptions.h
moc*
settings.cpp
settings.h
categoryfilter.cpp
categoryfilter.h \ No newline at end of file
diff --git a/noncore/settings/aqpkg/aqpkg.pro b/noncore/settings/aqpkg/aqpkg.pro
index d8eee6a..d3f898b 100644
--- a/noncore/settings/aqpkg/aqpkg.pro
+++ b/noncore/settings/aqpkg/aqpkg.pro
@@ -12,49 +12,48 @@ HEADERS = global.h \
utils.h \
server.h \
helpwindow.h \
letterpushbutton.h \
inputdlg.h \
categoryfilterimpl.h
SOURCES = mainwin.cpp \
datamgr.cpp \
mem.cpp \
settingsimpl.cpp \
ipkg.cpp \
main.cpp \
package.cpp \
installdlgimpl.cpp \
instoptionsimpl.cpp \
destination.cpp \
utils.cpp \
server.cpp \
helpwindow.cpp \
letterpushbutton.cpp \
inputdlg.cpp \
version.cpp \
categoryfilterimpl.cpp
INTERFACES = settings.ui \
- install.ui \
instoptions.ui \
categoryfilter.ui
TARGET = aqpkg
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe -lopie -lstdc++
DESTDIR = $(OPIEDIR)/bin
TRANSLATIONS = ../../../i18n/de/aqpkg.ts \
../../../i18n/xx/aqpkg.ts \
../../../i18n/en/aqpkg.ts \
../../../i18n/es/aqpkg.ts \
../../../i18n/fr/aqpkg.ts \
../../../i18n/hu/aqpkg.ts \
../../../i18n/ja/aqpkg.ts \
../../../i18n/ko/aqpkg.ts \
../../../i18n/no/aqpkg.ts \
../../../i18n/pl/aqpkg.ts \
../../../i18n/pt/aqpkg.ts \
../../../i18n/pt_BR/aqpkg.ts \
../../../i18n/sl/aqpkg.ts \
../../../i18n/zh_CN/aqpkg.ts \
../../../i18n/zh_TW/aqpkg.ts \
../../../i18n/it/aqpkg.ts \
diff --git a/noncore/settings/aqpkg/install.ui b/noncore/settings/aqpkg/install.ui
deleted file mode 100644
index 53622dd..0000000
--- a/noncore/settings/aqpkg/install.ui
+++ b/dev/null
@@ -1,147 +0,0 @@
-<!DOCTYPE UI><UI>
-<class>InstallDlg</class>
-<widget>
- <class>QDialog</class>
- <property stdset="1">
- <name>name</name>
- <cstring>InstallDlg</cstring>
- </property>
- <property stdset="1">
- <name>geometry</name>
- <rect>
- <x>0</x>
- <y>0</y>
- <width>196</width>
- <height>278</height>
- </rect>
- </property>
- <property stdset="1">
- <name>caption</name>
- <string>Install</string>
- </property>
- <grid>
- <property stdset="1">
- <name>margin</name>
- <number>11</number>
- </property>
- <property stdset="1">
- <name>spacing</name>
- <number>6</number>
- </property>
- <widget row="0" column="1" >
- <class>QComboBox</class>
- <property stdset="1">
- <name>name</name>
- <cstring>destination</cstring>
- </property>
- </widget>
- <widget row="3" column="0" >
- <class>QPushButton</class>
- <property stdset="1">
- <name>name</name>
- <cstring>btnInstall</cstring>
- </property>
- <property stdset="1">
- <name>text</name>
- <string>Start</string>
- </property>
- </widget>
- <widget row="3" column="1" >
- <class>QPushButton</class>
- <property stdset="1">
- <name>name</name>
- <cstring>btnOptions</cstring>
- </property>
- <property stdset="1">
- <name>text</name>
- <string>Options</string>
- </property>
- </widget>
- <widget row="2" column="0" rowspan="1" colspan="2" >
- <class>QGroupBox</class>
- <property stdset="1">
- <name>name</name>
- <cstring>GroupBox2</cstring>
- </property>
- <property stdset="1">
- <name>title</name>
- <string>Output</string>
- </property>
- <grid>
- <property stdset="1">
- <name>margin</name>
- <number>11</number>
- </property>
- <property stdset="1">
- <name>spacing</name>
- <number>6</number>
- </property>
- <widget row="0" column="0" >
- <class>QMultiLineEdit</class>
- <property stdset="1">
- <name>name</name>
- <cstring>output</cstring>
- </property>
- </widget>
- </grid>
- </widget>
- <widget row="0" column="0" >
- <class>QLabel</class>
- <property stdset="1">
- <name>name</name>
- <cstring>TextLabel1</cstring>
- </property>
- <property stdset="1">
- <name>text</name>
- <string>Destination</string>
- </property>
- </widget>
- <widget row="1" column="0" >
- <class>QLabel</class>
- <property stdset="1">
- <name>name</name>
- <cstring>TextLabel3</cstring>
- </property>
- <property stdset="1">
- <name>text</name>
- <string>Space Avail</string>
- </property>
- </widget>
- <widget row="1" column="1" >
- <class>QLabel</class>
- <property stdset="1">
- <name>name</name>
- <cstring>txtAvailableSpace</cstring>
- </property>
- <property stdset="1">
- <name>text</name>
- <string></string>
- </property>
- </widget>
- </grid>
-</widget>
-<connections>
- <connection>
- <sender>btnOptions</sender>
- <signal>clicked()</signal>
- <receiver>InstallDlg</receiver>
- <slot>optionsSelected()</slot>
- </connection>
- <connection>
- <sender>btnInstall</sender>
- <signal>clicked()</signal>
- <receiver>InstallDlg</receiver>
- <slot>installSelected()</slot>
- </connection>
- <connection>
- <sender>destination</sender>
- <signal>highlighted(const QString&amp;)</signal>
- <receiver>InstallDlg</receiver>
- <slot>displayAvailableSpace( const QString&amp; )</slot>
- </connection>
- <slot access="public">displayAvailableSpace( const QString&amp; )</slot>
- <slot access="public">installSelected()</slot>
- <slot access="public">displayText( const QString &amp; )</slot>
- <slot access="public">optionsSelected()</slot>
-</connections>
-</UI>
diff --git a/noncore/settings/aqpkg/installdlgimpl.cpp b/noncore/settings/aqpkg/installdlgimpl.cpp
index 75ce1a1..65aaa32 100644
--- a/noncore/settings/aqpkg/installdlgimpl.cpp
+++ b/noncore/settings/aqpkg/installdlgimpl.cpp
@@ -1,199 +1,249 @@
/***************************************************************************
installdlgimpl.cpp - description
-------------------
begin : Mon Aug 26 2002
copyright : (C) 2002 by Andy Qua
email : andy.qua@blueyonder.co.uk
***************************************************************************/
/***************************************************************************
* *
* 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 <stdio.h>
+
#ifdef QWS
#include <qpe/config.h>
#include <qpe/qpeapplication.h>
+#include <qpe/resource.h>
#include <qpe/storage.h>
#endif
-#include <qmultilineedit.h>
-#include <qdialog.h>
-#include <qcombobox.h>
#include <qcheckbox.h>
-#include <qpushbutton.h>
+#include <qcombobox.h>
+#include <qdialog.h>
+#include <qgroupbox.h>
+#include <qmultilineedit.h>
#include <qlabel.h>
-
+#include <qlayout.h>
+#include <qpushbutton.h>
#include "datamgr.h"
-#include "instoptionsimpl.h"
#include "destination.h"
+#include "instoptionsimpl.h"
#include "installdlgimpl.h"
+#include "ipkg.h"
#include "utils.h"
#include "global.h"
-InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl )
- : InstallDlg( parent, name, modal, fl )
+InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *dataManager, const char *title = 0 )
+ : QWidget( 0, 0, 0 )
{
+ setCaption( title );
+ init( TRUE );
+
pIpkg = 0;
upgradePackages = false;
dataMgr = dataManager;
vector<Destination>::iterator dit;
QString defaultDest = "root";
#ifdef QWS
Config cfg( "aqpkg" );
cfg.setGroup( "settings" );
defaultDest = cfg.readEntry( "dest", "root" );
// Grab flags - Turn MAKE_LINKS on by default (if no flags found)
flags = cfg.readNumEntry( "installFlags", 0 );
#else
flags = 0;
#endif
// Output text is read only
output->setReadOnly( true );
- QFont f( "helvetica" );
- f.setPointSize( 10 );
- output->setFont( f );
+// QFont f( "helvetica" );
+// f.setPointSize( 10 );
+// output->setFont( f );
// setup destination data
int defIndex = 0;
int i;
for ( i = 0 , dit = dataMgr->getDestinationList().begin() ; dit != dataMgr->getDestinationList().end() ; ++dit, ++i )
{
destination->insertItem( dit->getDestinationName() );
if ( dit->getDestinationName() == defaultDest )
defIndex = i;
}
destination->setCurrentItem( defIndex );
vector<InstallData>::iterator it;
// setup package data
- QString remove = "Remove\n";
- QString install = "\nInstall\n";
- QString upgrade = "\nUpgrade\n";
+ QString remove = tr( "Remove\n" );
+ QString install = tr( "Install\n" );
+ QString upgrade = tr( "Upgrade\n" );
for ( it = packageList.begin() ; it != packageList.end() ; ++it )
{
InstallData item = *it;
if ( item.option == "I" )
{
installList.push_back( item );
- install += " " + item.packageName + "\n";
+ install.append( QString( " %1\n" ).arg( item.packageName ) );
}
else if ( item.option == "D" )
{
removeList.push_back( item );
- remove += " " + item.packageName + "\n";
+ remove.append( QString( " %1\n" ).arg( item.packageName ) );
}
else if ( item.option == "U" || item.option == "R" )
{
updateList.push_back( item );
- QString type = " (Upgrade)";
+ QString type;
if ( item.option == "R" )
- type = " (ReInstall)";
- upgrade += " " + item.packageName + type + "\n";
+ type = tr( "(ReInstall)" );
+ else
+ type = tr( "(Upgrade)" );
+ upgrade.append( QString( " %1 %2\n" ).arg( item.packageName ).arg( type ) );
}
}
- output->setText( remove + install + upgrade );
+ output->setText( QString( "%1\n%2\n%3\n" ).arg( remove ).arg( install ).arg( upgrade ) );
displayAvailableSpace( destination->currentText() );
}
-InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, QWidget *parent, const char *name, bool modal, WFlags fl )
- : InstallDlg( parent, name, modal, fl )
+InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title = 0 )
+ : QWidget( 0, 0, 0 )
{
+ setCaption( title );
+ init( FALSE );
pIpkg = ipkg;
output->setText( initialText );
}
InstallDlgImpl::~InstallDlgImpl()
{
+ if ( pIpkg )
+ delete pIpkg;
}
-bool InstallDlgImpl :: showDlg()
+void InstallDlgImpl :: init( bool displayextrainfo )
+{
+ QGridLayout *layout = new QGridLayout( this );
+ layout->setSpacing( 4 );
+ layout->setMargin( 4 );
+
+ if ( displayextrainfo )
+ {
+ QLabel *label = new QLabel( tr( "Destination" ), this );
+ layout->addWidget( label, 0, 0 );
+ destination = new QComboBox( FALSE, this );
+ layout->addWidget( destination, 0, 1 );
+ connect( destination, SIGNAL( highlighted( const QString & ) ),
+ this, SLOT( displayAvailableSpace( const QString & ) ) );
+
+ QLabel *label2 = new QLabel( tr( "Space Avail" ), this );
+ layout->addWidget( label2, 1, 0 );
+ txtAvailableSpace = new QLabel( "", this );
+ layout->addWidget( txtAvailableSpace, 1, 1 );
+ }
+ else
{
- showMaximized();
- bool ret = exec();
+ destination = 0x0;
+ txtAvailableSpace = 0x0;
+ }
+
+ QGroupBox *GroupBox2 = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this );
+ GroupBox2->layout()->setSpacing( 0 );
+ GroupBox2->layout()->setMargin( 4 );
+
+ QVBoxLayout *GroupBox2Layout = new QVBoxLayout( GroupBox2->layout() );
+ output = new QMultiLineEdit( GroupBox2 );
+ GroupBox2Layout->addWidget( output );
+ layout->addMultiCellWidget( GroupBox2, 2, 2, 0, 1 );
+
+ btnInstall = new QPushButton( Resource::loadPixmap( "aqpkg/apply" ), tr( "Start" ), this );
+ layout->addWidget( btnInstall, 3, 0 );
+ connect( btnInstall, SIGNAL( clicked() ), this, SLOT( installSelected() ) );
- return ret;
+ btnOptions = new QPushButton( Resource::loadPixmap( "aqpkg/config" ), tr( "Options" ), this );
+ layout->addWidget( btnOptions, 3, 1 );
+ connect( btnOptions, SIGNAL( clicked() ), this, SLOT( optionsSelected() ) );
}
void InstallDlgImpl :: optionsSelected()
{
InstallOptionsDlgImpl opt( flags, this, "Option", true );
opt.exec();
// set options selected from dialog
flags = opt.getFlags();
#ifdef QWS
Config cfg( "aqpkg" );
cfg.setGroup( "settings" );
cfg.writeEntry( "installFlags", flags );
#endif
}
void InstallDlgImpl :: installSelected()
{
- if ( btnInstall->text() == "Abort" )
+ if ( btnInstall->text() == tr( "Abort" ) )
{
if ( pIpkg )
{
- displayText( "\n**** User Clicked ABORT ***" );
+ displayText( tr( "\n**** User Clicked ABORT ***" ) );
pIpkg->abort();
- displayText( "**** Process Aborted ****" );
+ displayText( tr( "**** Process Aborted ****" ) );
}
btnInstall->setText( tr( "Close" ) );
+ btnInstall->setIconSet( Resource::loadPixmap( "enter" ) );
return;
}
else if ( btnInstall->text() == tr( "Close" ) )
{
- done( 1 );
+ emit reloadData( this );
return;
}
// Disable buttons
btnOptions->setEnabled( false );
// btnInstall->setEnabled( false );
- btnInstall->setText( "Abort" );
-
+ btnInstall->setText( tr( "Abort" ) );
+ btnInstall->setIconSet( Resource::loadPixmap( "close" ) );
if ( pIpkg )
{
output->setText( "" );
-
connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
pIpkg->runIpkg();
}
else
{
output->setText( "" );
vector<Destination>::iterator d = dataMgr->getDestination( destination->currentText() );
QString dest = d->getDestinationName();
QString destDir = d->getDestinationPath();
int instFlags = flags;
if ( d->linkToRoot() )
instFlags |= MAKE_LINKS;
#ifdef QWS
// Save settings
Config cfg( "aqpkg" );
cfg.setGroup( "settings" );
cfg.writeEntry( "dest", dest );
#endif
pIpkg = new Ipkg;
connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
// First run through the remove list, then the install list then the upgrade list
@@ -221,71 +271,75 @@ void InstallDlgImpl :: installSelected()
{
pIpkg->setPackage( it->packageName );
pIpkg->runIpkg();
}
flags |= FORCE_REINSTALL;
for ( it = updateList.begin() ; it != updateList.end() ; ++it )
{
if ( it->option == "R" )
pIpkg->setOption( "reinstall" );
else
pIpkg->setOption( "upgrade" );
pIpkg->setDestination( it->destination->getDestinationName() );
pIpkg->setDestinationDir( it->destination->getDestinationPath() );
pIpkg->setPackage( it->packageName );
int tmpFlags = flags;
if ( it->destination->linkToRoot() && it->recreateLinks )
tmpFlags |= MAKE_LINKS;
pIpkg->setFlags( tmpFlags );
pIpkg->runIpkg();
}
delete pIpkg;
+ pIpkg = 0;
}
btnOptions->setEnabled( true );
// btnInstall->setEnabled( true );
btnInstall->setText( tr( "Close" ) );
+ btnInstall->setIconSet( Resource::loadPixmap( "enter" ) );
- if ( destination->currentText() != 0 && destination->currentText() != "" )
+ if ( destination && destination->currentText() != 0 && destination->currentText() != "" )
displayAvailableSpace( destination->currentText() );
}
void InstallDlgImpl :: displayText(const QString &text )
{
- QString t = output->text() + "\n" + text;
- output->setText( t );
+ //output->setText( QString( "%1\n%2" ).arg( output->text() ).arg( text ) );
+ QString newtext = QString( "%1\n%2" ).arg( output->text() ).arg( text );
+ output->setText( newtext );
output->setCursorPosition( output->numLines(), 0 );
}
void InstallDlgImpl :: displayAvailableSpace( const QString &text )
{
vector<Destination>::iterator d = dataMgr->getDestination( text );
QString destDir = d->getDestinationPath();
long blockSize = 0;
long totalBlocks = 0;
long availBlocks = 0;
QString space;
if ( Utils::getStorageSpace( (const char *)destDir, &blockSize, &totalBlocks, &availBlocks ) )
{
long mult = blockSize / 1024;
long div = 1024 / blockSize;
if ( !mult ) mult = 1;
if ( !div ) div = 1;
// long total = totalBlocks * mult / div;
long avail = availBlocks * mult / div;
// long used = total - avail;
space.sprintf( "%ld Kb", avail );
}
else
- space = "Unknown";
+ space = tr( "Unknown" );
+ if ( txtAvailableSpace )
txtAvailableSpace->setText( space );
}
diff --git a/noncore/settings/aqpkg/installdlgimpl.h b/noncore/settings/aqpkg/installdlgimpl.h
index 2f80f08..4c9f087 100644
--- a/noncore/settings/aqpkg/installdlgimpl.h
+++ b/noncore/settings/aqpkg/installdlgimpl.h
@@ -1,67 +1,85 @@
/***************************************************************************
installdlgimpl.h - description
-------------------
begin : Mon Aug 26 2002
copyright : (C) 2002 by Andy Qua
email : andy.qua@blueyonder.co.uk
***************************************************************************/
/***************************************************************************
* *
* 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 INSTALLDLGIMPL_H
#define INSTALLDLGIMPL_H
#include <vector>
using namespace std;
+#include <qwidget.h>
#include <qstring.h>
-#include "ipkg.h"
-#include "install.h"
+class QComboBox;
+class QLabel;
+class QMultiLineEdit;
+class QPushButton;
+
+class DataManager;
+class Destination;
+class Ipkg;
class InstallData
{
public:
QString option; // I - install, D - delete, R- reinstall U - upgrade
QString packageName;
Destination *destination;
bool recreateLinks;
};
-class InstallDlgImpl : public InstallDlg
+class InstallDlgImpl : public QWidget
{
+ Q_OBJECT
public:
- InstallDlgImpl( vector<InstallData> &packageList, DataManager *dataManager, QWidget * parent = 0, const char* name = 0, bool modal = false, WFlags fl = 0 );
- InstallDlgImpl( Ipkg *ipkg, QString initialText, QWidget * parent = 0, const char* name = 0, bool modal = false, WFlags fl = 0 );
+ InstallDlgImpl( vector<InstallData> &packageList, DataManager *dataManager, const char *title = 0 );
+ InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title = 0 );
~InstallDlgImpl();
- bool showDlg();
bool upgradeServer( QString &server );
-
protected:
private:
DataManager *dataMgr;
vector<InstallData> installList;
vector<InstallData> removeList;
vector<InstallData> updateList;
int flags;
Ipkg *pIpkg;
bool upgradePackages;
+ QComboBox *destination;
+ QPushButton *btnInstall;
+ QPushButton *btnOptions;
+ QMultiLineEdit *output;
+ QLabel *txtAvailableSpace;
+
+ void init( bool );
+
bool runIpkg( QString &option, const QString& package, const QString& dest, int flags );
+signals:
+ void reloadData( InstallDlgImpl * );
+
+public slots:
void optionsSelected();
void installSelected();
void displayText(const QString &text );
void displayAvailableSpace( const QString &text);
};
#endif
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp
index a25f5a7..947aace 100644
--- a/noncore/settings/aqpkg/mainwin.cpp
+++ b/noncore/settings/aqpkg/mainwin.cpp
@@ -24,109 +24,101 @@
#include <qpe/qpetoolbar.h>
#include <qpe/config.h>
#include <qpe/resource.h>
#include <qaction.h>
#include <qcombobox.h>
#include <qfile.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qlineedit.h>
#include <qlistview.h>
#include <qmenubar.h>
#include <qmessagebox.h>
#include <qpopupmenu.h>
#include <qprogressbar.h>
#include <qtimer.h>
#include <qwhatsthis.h>
#include <qwidgetstack.h>
#include "categoryfilterimpl.h"
#include "datamgr.h"
#include "global.h"
#include "helpwindow.h"
#include "inputdlg.h"
+#include "ipkg.h"
#include "installdlgimpl.h"
#include "letterpushbutton.h"
#include "mainwin.h"
#include "settingsimpl.h"
#include "utils.h"
extern int compareVersions( const char *v1, const char *v2 );
MainWindow :: MainWindow()
: QMainWindow( 0x0, 0x0, WStyle_ContextHelp )
{
setCaption( tr( "AQPkg - Package Manager" ) );
// Create UI widgets
initMainWidget();
initProgressWidget();
// Build menu and tool bars
setToolBarsMovable( FALSE );
QPEToolBar *bar = new QPEToolBar( this );
bar->setHorizontalStretchable( TRUE );
QPEMenuBar *mb = new QPEMenuBar( bar );
mb->setMargin( 0 );
bar = new QPEToolBar( this );
// Find toolbar
findBar = new QPEToolBar( this );
addToolBar( findBar, QMainWindow::Top, true );
findBar->setHorizontalStretchable( true );
findEdit = new QLineEdit( findBar );
QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) );
findBar->setStretchableWidget( findEdit );
connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( findPackage( const QString & ) ) );
// Quick jump toolbar
jumpBar = new QPEToolBar( this );
addToolBar( jumpBar, QMainWindow::Top, true );
jumpBar->setHorizontalStretchable( true );
QWidget *w = new QWidget( jumpBar );
jumpBar->setStretchableWidget( w );
QGridLayout *layout = new QGridLayout( w );
- //QVBoxLayout *vbox = new QVBoxLayout( w, 0, -1 );
- //QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1 );
- //QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1 );
char text[2];
text[1] = '\0';
for ( int i = 0 ; i < 26 ; ++i )
{
text[0] = 'A' + i;
LetterPushButton *b = new LetterPushButton( text, w );
connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) );
layout->addWidget( b, i / 13, i % 13);
-/*
- if ( i < 13 )
- hbox3->addWidget( b );
- else
- hbox4->addWidget( b );
-*/
}
QAction *a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, w, 0 );
a->setWhatsThis( tr( "Click here to hide the Quick Jump toolbar." ) );
connect( a, SIGNAL( activated() ), this, SLOT( hideJumpBar() ) );
a->addTo( jumpBar );
jumpBar->hide();
// Packages menu
QPopupMenu *popup = new QPopupMenu( this );
a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here to update package lists from servers." ) );
connect( a, SIGNAL( activated() ), this, SLOT( updateServer() ) );
a->addTo( popup );
a->addTo( bar );
actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 );
actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) );
connect( actionUpgrade, SIGNAL( activated() ), this, SLOT( upgradePackages() ) );
actionUpgrade->addTo( popup );
actionUpgrade->addTo( bar );
iconDownload = Resource::loadPixmap( "aqpkg/download" );
@@ -777,86 +769,87 @@ void MainWindow :: searchForPackage( const QString &text )
// cout << "checking " << item->text().lower() << endl;
if ( item->text().lower().find( text ) != -1 )
{
// cout << "matched " << item->text() << endl;
packagesList->ensureItemVisible( item );
packagesList->setCurrentItem( item );
break;
}
}
}
}
void MainWindow :: updateServer()
{
QString serverName = serversList->currentText();
// Update the current server
// Display dialog
// Disable buttons to stop silly people clicking lots on them :)
// First, write out ipkg_conf file so that ipkg can use it
mgr->writeOutIpkgConf();
- Ipkg ipkg;
- ipkg.setOption( "update" );
-
- InstallDlgImpl dlg( &ipkg, tr( "Refreshing server package lists" ), this, tr( "Upgrade" ), true );
- dlg.showDlg();
+ Ipkg *ipkg = new Ipkg;
+ ipkg->setOption( "update" );
- reloadData();
+ InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ),
+ tr( "Update lists" ) );
+ connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
+ dlg->showMaximized();
// delete progDlg;
}
void MainWindow :: upgradePackages()
{
// We're gonna do an upgrade of all packages
// First warn user that this isn't recommended
// TODO - ODevice????
QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" );
QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning,
QMessageBox::Yes,
QMessageBox::No | QMessageBox::Escape | QMessageBox::Default ,
0, this );
warn.adjustSize();
if ( warn.exec() == QMessageBox::Yes )
{
// First, write out ipkg_conf file so that ipkg can use it
mgr->writeOutIpkgConf();
// Now run upgrade
- Ipkg ipkg;
- ipkg.setOption( "upgrade" );
-
- InstallDlgImpl dlg( &ipkg, tr( "Upgrading installed packages" ), this, tr( "Upgrade" ), true );
- dlg.showDlg();
+ Ipkg *ipkg = new Ipkg;
+ ipkg->setOption( "upgrade" );
- reloadData();
+ InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Upgrading installed packages" ),
+ tr ( "Upgrade" ) );
+ connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
+ dlg->showMaximized();
}
}
+
void MainWindow :: downloadPackage()
{
bool doUpdate = true;
if ( downloadEnabled )
{
// See if any packages are selected
bool found = false;
if ( serversList->currentText() != LOCAL_SERVER )
{
for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
item != 0 && !found;
item = (QCheckListItem *)item->nextSibling() )
{
if ( item->isOn() )
found = true;
}
}
// If user selected some packages then download the and store the locally
// otherwise, display dialog asking user what package to download from an http server
// and whether to install it
if ( found )
downloadSelectedPackages();
else
@@ -877,49 +870,49 @@ void MainWindow :: upgradePackages()
name.truncate( pos );
// if (there is a (installed), remove it
pos = name.find( "(installed)" );
if ( pos > 0 )
name.truncate( pos - 1 );
Package *p = mgr->getServer( serversList->currentText() )->getPackage( name );
QString msgtext;
msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() );
if ( QMessageBox::information( this, tr( "Are you sure?" ),
msgtext, tr( "No" ), tr( "Yes" ) ) == 1 )
{
doUpdate = true;
QFile f( p->getFilename() );
f.remove();
}
}
}
}
if ( doUpdate )
{
- reloadData();
+ reloadData( 0x0 );
}
}
void MainWindow :: downloadSelectedPackages()
{
// First, write out ipkg_conf file so that ipkg can use it
mgr->writeOutIpkgConf();
// Display dialog to user asking where to download the files to
bool ok = FALSE;
QString dir = "";
#ifdef QWS
// read download directory from config file
Config cfg( "aqpkg" );
cfg.setGroup( "settings" );
dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" );
#endif
QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this );
if ( ok && !text.isEmpty() )
dir = text; // user entered something and pressed ok
else
return; // user entered nothing or pressed cancel
@@ -949,105 +942,89 @@ void MainWindow :: downloadSelectedPackages()
}
}
}
void MainWindow :: downloadRemotePackage()
{
// Display dialog
bool ok;
QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this );
if ( !ok || package.isEmpty() )
return;
// DownloadRemoteDlgImpl dlg( this, "Install", true );
// if ( dlg.exec() == QDialog::Rejected )
// return;
// grab details from dialog
// QString package = dlg.getPackageLocation();
InstallData item;
item.option = "I";
item.packageName = package;
vector<InstallData> workingPackages;
workingPackages.push_back( item );
- InstallDlgImpl dlg2( workingPackages, mgr, this, "Install", true );
- dlg2.showDlg();
-
- reloadData();
-
-#ifdef QWS
- // Finally let the main system update itself
- QCopEnvelope e("QPE/System", "linkChanged(QString)");
- QString lf = QString::null;
- e << lf;
-#endif
+ InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) );
+ connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
+ dlg->showMaximized();
}
void MainWindow :: applyChanges()
{
stickyOption = "";
// First, write out ipkg_conf file so that ipkg can use it
mgr->writeOutIpkgConf();
// Now for each selected item
// deal with it
vector<InstallData> workingPackages;
for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
item != 0 ;
item = (QCheckListItem *)item->nextSibling() )
{
if ( item->isOn() )
{
InstallData data = dealWithItem( item );
workingPackages.push_back( data );
}
}
if ( workingPackages.size() == 0 )
{
// Nothing to do
QMessageBox::information( this, tr( "Nothing to do" ),
tr( "No packages selected" ), tr( "OK" ) );
return;
}
// do the stuff
- InstallDlgImpl dlg( workingPackages, mgr, this, "Install", true );
- dlg.showDlg();
-
- reloadData();
-
-#ifdef QWS
- // Finally let the main system update itself
- QCopEnvelope e("QPE/System", "linkChanged(QString)");
- QString lf = QString::null;
- e << lf;
-#endif
+ InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) );
+ connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
+ dlg->showMaximized();
}
// decide what to do - either remove, upgrade or install
// Current rules:
// If not installed - install
// If installed and different version available - upgrade
// If installed and version up to date - remove
InstallData MainWindow :: dealWithItem( QCheckListItem *item )
{
QString name = item->text();
// Get package
vector<Server>::iterator s = mgr->getServer( serversList->currentText() );
Package *p = s->getPackage( name );
// If the package has a filename then it is a local file
if ( p->isPackageStoredLocally() )
name = p->getFilename();
QString option;
QString dest = "root";
if ( !p->isInstalled() )
{
InstallData item;
@@ -1129,53 +1106,70 @@ InstallData MainWindow :: dealWithItem( QCheckListItem *item )
break;
case 1: // Quit or Escape
item.option = secondOption;
break;
}
}
else
{
// item.option = stickyOption;
}
}
// Check if we are reinstalling the same version
if ( item.option != "R" )
item.recreateLinks = true;
else
item.recreateLinks = false;
// User hit cancel (on dlg - assume remove)
return item;
}
}
-void MainWindow :: reloadData()
+void MainWindow :: reloadData( InstallDlgImpl *dlg )
{
stack->raiseWidget( progressWindow );
+
+ if ( dlg )
+ {
+ dlg->close();
+ delete dlg;
+ }
+
mgr->reloadServerData();
serverSelected( -1, FALSE );
+
+#ifdef QWS
+ m_status->setText( tr( "Updating Launcher..." ) );
+
+ // Finally let the main system update itself
+ QCopEnvelope e("QPE/System", "linkChanged(QString)");
+ QString lf = QString::null;
+ e << lf;
+#endif
+
stack->raiseWidget( networkPkgWindow );
}
void MainWindow :: letterPushed( QString t )
{
QCheckListItem *top = (QCheckListItem *)packagesList->firstChild();
QCheckListItem *start = (QCheckListItem *)packagesList->currentItem();
if ( packagesList->firstChild() == 0 )
return;
QCheckListItem *item;
if ( start == 0 )
{
item = (QCheckListItem *)packagesList->firstChild();
start = top;
}
else
item = (QCheckListItem *)start->nextSibling();
if ( item == 0 )
item = (QCheckListItem *)packagesList->firstChild();
do
{
if ( item->text().lower().startsWith( t.lower() ) )
diff --git a/noncore/settings/aqpkg/mainwin.h b/noncore/settings/aqpkg/mainwin.h
index b49c819..d0777fb 100644
--- a/noncore/settings/aqpkg/mainwin.h
+++ b/noncore/settings/aqpkg/mainwin.h
@@ -2,48 +2,49 @@
mainwin.h - description
-------------------
begin : Mon Aug 26 13:32:30 BST 2002
copyright : (C) 2002 by Andy Qua
email : andy.qua@blueyonder.co.uk
***************************************************************************/
/***************************************************************************
* *
* 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 MAINWIN_H
#define MAINWIN_H
#include <qmainwindow.h>
#include <qpixmap.h>
class DataManager;
class InstallData;
+class InstallDlgImpl;
class QAction;
class QCheckListItem;
class QComboBox;
class QLabel;
class QLineEdit;
class QListView;
class QPEToolBar;
class QProgressBar;
class QWidgetStack;
class MainWindow :public QMainWindow
{
Q_OBJECT
public:
MainWindow();
~MainWindow();
private:
DataManager *mgr;
QWidgetStack *stack;
@@ -71,67 +72,67 @@ private:
QWidget *networkPkgWindow;
QComboBox *serversList;
QListView *packagesList;
QPixmap installedIcon;
QPixmap updatedIcon;
QString currentlySelectedServer;
QString categoryFilter;
QString stickyOption;
bool categoryFilterEnabled;
bool showJumpTo;
bool showUninstalledPkgs;
bool showInstalledPkgs;
bool showUpgradedPkgs;
bool downloadEnabled;
void initMainWidget();
void updateData();
void serverSelected( int index, bool showProgress );
void searchForPackage( const QString & );
bool filterByCategory( bool val );
void downloadSelectedPackages();
void downloadRemotePackage();
InstallData dealWithItem( QCheckListItem *item );
- void reloadData();
// Progress widget
QWidget *progressWindow;
QLabel *m_status;
QProgressBar *m_progress;
void initProgressWidget();
public slots:
// void setDocument( const QString &doc );
void displayHelp();
void displayFindBar();
void displayJumpBar();
void repeatFind();
void findPackage( const QString & );
void hideFindBar();
void hideJumpBar();
void displayAbout();
void displaySettings();
void filterUninstalledPackages();
void filterInstalledPackages();
void filterUpgradedPackages();
void filterCategory();
bool setFilterCategory();
void raiseMainWidget();
void raiseProgressWidget();
void enableUpgrade( bool );
void enableDownload( bool );
+ void reloadData( InstallDlgImpl * );
private slots:
void init();
void setProgressSteps( int );
void setProgressMessage( const QString & );
void updateProgress( int );
void serverSelected( int index );
void updateServer();
void upgradePackages();
void downloadPackage();
void applyChanges();
void letterPushed( QString t );
};
#endif