summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/aqpkg/aqpkg.pro2
-rw-r--r--noncore/settings/aqpkg/datamgr.cpp18
-rw-r--r--noncore/settings/aqpkg/datamgr.h9
-rw-r--r--noncore/settings/aqpkg/mainwin.cpp51
-rw-r--r--noncore/settings/aqpkg/mainwin.h7
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.cpp82
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.h18
-rw-r--r--noncore/settings/aqpkg/progresswidget.cpp66
-rw-r--r--noncore/settings/aqpkg/progresswidget.h54
9 files changed, 265 insertions, 42 deletions
diff --git a/noncore/settings/aqpkg/aqpkg.pro b/noncore/settings/aqpkg/aqpkg.pro
index 3b27ac3..ad0dfc5 100644
--- a/noncore/settings/aqpkg/aqpkg.pro
+++ b/noncore/settings/aqpkg/aqpkg.pro
@@ -9,4 +9,5 @@ HEADERS = global.h \
package.h \
progressdlg.h \
+ progresswidget.h \
installdlgimpl.h \
instoptionsimpl.h \
@@ -27,4 +28,5 @@ SOURCES = mainwin.cpp \
package.cpp \
progressdlg.cpp \
+ progresswidget.cpp \
installdlgimpl.cpp \
instoptionsimpl.cpp \
diff --git a/noncore/settings/aqpkg/datamgr.cpp b/noncore/settings/aqpkg/datamgr.cpp
index 0159a79..2c83e28 100644
--- a/noncore/settings/aqpkg/datamgr.cpp
+++ b/noncore/settings/aqpkg/datamgr.cpp
@@ -21,4 +21,7 @@ using namespace std;
#ifdef QWS
#include <qpe/config.h>
+#include <qpe/qpeapplication.h>
+#else
+#include <qapplication.h>
#endif
@@ -31,4 +34,5 @@ using namespace std;
QString DataManager::availableCategories = "";
DataManager::DataManager()
+ : QObject( 0x0, 0x0 )
{
activeServer = "";
@@ -166,7 +170,17 @@ void DataManager :: loadServers()
void DataManager :: reloadServerData( )
{
+ emit progressSetSteps( serverList.size() );
+ emit progressSetMessage( tr( "Reading configuration..." ) );
+
vector<Server>::iterator it = serverList.begin();
+ QString serverName;
+ int i = 0;
for ( it = serverList.begin() ; it != serverList.end() ; ++it )
{
+ serverName = it->getServerName();
+ i++;
+ emit progressUpdate( i );
+ qApp->processEvents();
+
// Now we've read the config file in we need to read the servers
// The local server is a special case. This holds the contents of the
@@ -174,7 +188,7 @@ void DataManager :: reloadServerData( )
// we've set up
// The other servers files hold the contents of the server package list
- if ( it->getServerName() == LOCAL_SERVER )
+ if ( serverName == LOCAL_SERVER )
it->readStatusFile( destList );
- else if ( it->getServerName() == LOCAL_IPKGS )
+ else if ( serverName == LOCAL_IPKGS )
it->readLocalIpks( &( *getServer( LOCAL_SERVER ) ) );
else
diff --git a/noncore/settings/aqpkg/datamgr.h b/noncore/settings/aqpkg/datamgr.h
index 0a7467f..90328ab 100644
--- a/noncore/settings/aqpkg/datamgr.h
+++ b/noncore/settings/aqpkg/datamgr.h
@@ -22,4 +22,5 @@
using namespace std;
+#include <qobject.h>
#include <qstring.h>
@@ -35,6 +36,7 @@ using namespace std;
-class DataManager
+class DataManager : public QObject
{
+ Q_OBJECT
public:
DataManager();
@@ -87,4 +89,9 @@ private:
vector<Server> serverList;
vector<Destination> destList;
+
+signals:
+ void progressSetSteps( int );
+ void progressSetMessage( const QString & );
+ void progressUpdate( int );
};
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp
index b00931e..5e03f11 100644
--- a/noncore/settings/aqpkg/mainwin.cpp
+++ b/noncore/settings/aqpkg/mainwin.cpp
@@ -20,8 +20,10 @@ using namespace std;
#include <qmenubar.h>
-#include <qpopupmenu.h>
#include <qmessagebox.h>
+#include <qpopupmenu.h>
+#include <qtimer.h>
#include "mainwin.h"
+#include "progresswidget.h"
#include "datamgr.h"
#include "networkpkgmgr.h"
@@ -67,19 +69,44 @@ MainWindow :: MainWindow( QWidget *p, char *name )
menu->insertItem( tr( "&Help" ), help );
- mgr = new DataManager();
- mgr->loadServers();
-
+ // Create UI widgets
stack = new QWidgetStack( this );
- networkPkgWindow = new NetworkPackageManager( mgr, stack );
+ progressWindow = new ProgressWidget( stack );
+ stack->addWidget( progressWindow, 2 );
+
+ networkPkgWindow = new NetworkPackageManager( stack );
+ connect( networkPkgWindow, SIGNAL( appRaiseMainWidget() ), this, SLOT( raiseMainWidget() ) );
+ connect( networkPkgWindow, SIGNAL( appRaiseProgressWidget() ), this, SLOT( raiseProgressWidget() ) );
+ connect( networkPkgWindow, SIGNAL( progressSetSteps( int ) ), progressWindow, SLOT( setSteps( int ) ) );
+ connect( networkPkgWindow, SIGNAL( progressSetMessage( const QString & ) ),
+ progressWindow, SLOT( setMessage( const QString & ) ) );
+ connect( networkPkgWindow, SIGNAL( progressUpdate( int ) ), progressWindow, SLOT( update( int ) ) );
stack->addWidget( networkPkgWindow, 1 );
setCentralWidget( stack );
- stack->raiseWidget( networkPkgWindow );
+ stack->raiseWidget( progressWindow );
+
+ // Delayed call to finish initialization
+ QTimer::singleShot( 100, this, SLOT( init() ) );
+
}
MainWindow :: ~MainWindow()
{
- delete networkPkgWindow;
+ delete mgr;
+}
+
+void MainWindow :: init()
+{
+ stack->raiseWidget( progressWindow );
+ mgr = new DataManager();
+ connect( mgr, SIGNAL( progressSetSteps( int ) ), progressWindow, SLOT( setSteps( int ) ) );
+ connect( mgr, SIGNAL( progressSetMessage( const QString & ) ),
+ progressWindow, SLOT( setMessage( const QString & ) ) );
+ connect( mgr, SIGNAL( progressUpdate( int ) ), progressWindow, SLOT( update( int ) ) );
+ mgr->loadServers();
+ networkPkgWindow->setDataManager( mgr );
+ networkPkgWindow->updateData();
+ stack->raiseWidget( networkPkgWindow );
}
@@ -209,2 +236,12 @@ void MainWindow :: filterCategory()
}
}
+
+void MainWindow :: raiseMainWidget()
+{
+ stack->raiseWidget( networkPkgWindow );
+}
+
+void MainWindow :: raiseProgressWidget()
+{
+ stack->raiseWidget( progressWindow );
+}
diff --git a/noncore/settings/aqpkg/mainwin.h b/noncore/settings/aqpkg/mainwin.h
index 92aba4d..39799f9 100644
--- a/noncore/settings/aqpkg/mainwin.h
+++ b/noncore/settings/aqpkg/mainwin.h
@@ -22,5 +22,5 @@
#include <qwidgetstack.h>
-
+class ProgressWidget;
class NetworkPackageManager;
class DataManager;
@@ -45,4 +45,5 @@ private:
NetworkPackageManager *networkPkgWindow;
+ ProgressWidget *progressWindow;
int mnuShowUninstalledPkgsId;
@@ -64,5 +65,9 @@ public slots:
void filterCategory();
void setFilterCategory();
+ void raiseMainWidget();
+ void raiseProgressWidget();
+private slots:
+ void init();
};
#endif
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp
index 79a380e..cae0d8f 100644
--- a/noncore/settings/aqpkg/networkpkgmgr.cpp
+++ b/noncore/settings/aqpkg/networkpkgmgr.cpp
@@ -47,8 +47,7 @@ using namespace std;
extern int compareVersions( const char *v1, const char *v2 );
-NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name)
+NetworkPackageManager::NetworkPackageManager( QWidget *parent, const char *name )
: QWidget(parent, name)
{
- dataMgr = dataManager;
#ifdef QWS
@@ -69,5 +68,5 @@ NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget
setupConnections();
- updateData();
+ //updateData();
}
@@ -76,32 +75,37 @@ NetworkPackageManager::~NetworkPackageManager()
}
-void NetworkPackageManager :: timerEvent ( QTimerEvent * )
+void NetworkPackageManager :: setDataManager( DataManager *dm )
{
- killTimer( timerId );
-
- // Add server names to listbox
- updateData();
+ dataMgr = dm;
}
void NetworkPackageManager :: updateData()
{
+ emit progressSetSteps( dataMgr->getServerList().size() );
+
serversList->clear();
packagesList->clear();
-
vector<Server>::iterator it;
int activeItem = -1;
int i;
+ QString serverName;
for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i )
{
+ serverName = it->getServerName();
+ emit progressSetMessage( tr( "Building server list:\n\t%1" ).arg( serverName ) );
+ emit progressUpdate( i );
+ qApp->processEvents();
+
// cout << "Adding " << it->getServerName() << " to combobox" << endl;
if ( !it->isServerActive() )
{
- cout << it->getServerName() << " is not active" << endl;
+ cout << serverName << " is not active" << endl;
i--;
continue;
}
- serversList->insertItem( it->getServerName() );
- if ( it->getServerName() == currentlySelectedServer )
+
+ serversList->insertItem( serverName );
+ if ( serverName == currentlySelectedServer )
activeItem = i;
}
@@ -110,5 +114,5 @@ void NetworkPackageManager :: updateData()
if ( activeItem != -1 )
serversList->setCurrentItem( activeItem );
- serverSelected( 0 );
+ serverSelected( 0, FALSE );
}
@@ -194,21 +198,34 @@ void NetworkPackageManager :: setupConnections()
}
-void NetworkPackageManager :: showProgressDialog( char *initialText )
+void NetworkPackageManager :: serverSelected( int index )
{
- if ( !progressDlg )
- progressDlg = new ProgressDlg( this, "Progress", false );
- progressDlg->setText( initialText );
- progressDlg->show();
+ serverSelected( index, TRUE );
}
-
-void NetworkPackageManager :: serverSelected( int )
+void NetworkPackageManager :: serverSelected( int, bool raiseProgress )
{
- packagesList->clear();
-
// display packages
QString serverName = serversList->currentText();
currentlySelectedServer = serverName;
+ vector<Server>::iterator s = dataMgr->getServer( serverName );
+
+ vector<Package> &list = s->getPackageList();
+ vector<Package>::iterator it;
+
+ // Display progress widget while loading list
+ bool doProgress = ( list.size() > 200 );
+ if ( doProgress )
+ {
+ if ( raiseProgress )
+ {
+ emit appRaiseProgressWidget();
+ }
+ emit progressSetSteps( list.size() );
+ emit progressSetMessage( tr( "Building package list for:\n\t%1" ).arg( serverName ) );
+ }
+
+ packagesList->clear();
+
#ifdef QWS
// read download directory from config file
@@ -218,10 +235,17 @@ void NetworkPackageManager :: serverSelected( int )
#endif
- vector<Server>::iterator s = dataMgr->getServer( serverName );
-
- vector<Package> &list = s->getPackageList();
- vector<Package>::iterator it;
+ int i = 0;
for ( it = list.begin() ; it != list.end() ; ++it )
{
+ // Update progress after every 100th package (arbitrary value, seems to give good balance)
+ i++;
+ if ( ( i % 100 ) == 0 )
+ {
+ if ( doProgress )
+ {
+ emit progressUpdate( i );
+ }
+ qApp->processEvents();
+ }
QString text = "";
@@ -333,4 +357,10 @@ void NetworkPackageManager :: serverSelected( int )
download->setText( "Download" );
}
+
+ // Display this widget once everything is done
+ if ( doProgress && raiseProgress )
+ {
+ emit appRaiseMainWidget();
+ }
}
diff --git a/noncore/settings/aqpkg/networkpkgmgr.h b/noncore/settings/aqpkg/networkpkgmgr.h
index 46919d7..2206c81 100644
--- a/noncore/settings/aqpkg/networkpkgmgr.h
+++ b/noncore/settings/aqpkg/networkpkgmgr.h
@@ -27,4 +27,5 @@
#include "datamgr.h"
#include "progressdlg.h"
+
class InstallData;
@@ -35,8 +36,9 @@ class NetworkPackageManager : public QWidget
public:
/** construtor */
- NetworkPackageManager( DataManager *dataManager, QWidget* parent=0, const char *name=0);
+ NetworkPackageManager( QWidget* parent=0, const char *name=0 );
/** destructor */
~NetworkPackageManager();
+ void setDataManager( DataManager *dm );
void selectLocalPackage( const QString &pkg );
void updateData();
@@ -68,7 +70,4 @@ private:
bool showInstalledPkgs;
bool showUpgradedPkgs;
- int timerId;
-
- void timerEvent ( QTimerEvent * );
void initGui();
@@ -77,9 +76,17 @@ private:
void downloadSelectedPackages();
void downloadRemotePackage();
+ void serverSelected( int index, bool showProgress );
+
InstallData dealWithItem( QCheckListItem *item );
QString stickyOption;
+signals:
+ void appRaiseMainWidget();
+ void appRaiseProgressWidget();
+ void progressSetSteps( int );
+ void progressSetMessage( const QString & );
+ void progressUpdate( int );
+
public slots:
- void serverSelected( int index );
void applyChanges();
void upgradePackages();
@@ -88,4 +95,5 @@ public slots:
void displayText( const QString &t );
void letterPushed( QString t );
+ void serverSelected( int index );
};
diff --git a/noncore/settings/aqpkg/progresswidget.cpp b/noncore/settings/aqpkg/progresswidget.cpp
new file mode 100644
index 0000000..bbafcac
--- a/dev/null
+++ b/noncore/settings/aqpkg/progresswidget.cpp
@@ -0,0 +1,66 @@
+/*
+                This file is part of the OPIE Project
+ =.
+             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org>
+           .>+-=
+ _;:,     .>    :=|. 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 "progresswidget.h"
+
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qprogressbar.h>
+
+ProgressWidget::ProgressWidget( QWidget *parent, const char *name, WFlags f )
+ : QWidget( parent, name, f )
+{
+ QVBoxLayout *layout = new QVBoxLayout( this, 4, 4 );
+
+ m_status = new QLabel( this );
+ m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ layout->addWidget( m_status );
+
+ m_progress = new QProgressBar( this );
+ layout->addWidget( m_progress );
+}
+
+ProgressWidget::~ProgressWidget()
+{
+}
+
+void ProgressWidget::setSteps( int numsteps )
+{
+ m_progress->setTotalSteps( numsteps );
+}
+
+void ProgressWidget::setMessage( const QString &msg )
+{
+ m_status->setText( msg );
+}
+
+void ProgressWidget::update( int progress )
+{
+ m_progress->setProgress( progress );
+}
+
diff --git a/noncore/settings/aqpkg/progresswidget.h b/noncore/settings/aqpkg/progresswidget.h
new file mode 100644
index 0000000..7d99978
--- a/dev/null
+++ b/noncore/settings/aqpkg/progresswidget.h
@@ -0,0 +1,54 @@
+/*
+                This file is part of the OPIE Project
+ =.
+             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org>
+           .>+-=
+ _;:,     .>    :=|. 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 PROGRESSWIDGET_H
+#define PROGRESSWIDGET_H
+
+#include <qwidget.h>
+
+class QLabel;
+class QProgressBar;
+
+class ProgressWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ ProgressWidget( QWidget * = 0, const char * = 0, WFlags = 0 );
+ ~ProgressWidget();
+
+private:
+ QLabel *m_status;
+ QProgressBar *m_progress;
+
+public slots:
+ void setSteps( int );
+ void setMessage( const QString & );
+ void update( int );
+};
+
+#endif