summaryrefslogtreecommitdiff
path: root/noncore
Unidiff
Diffstat (limited to 'noncore') (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
@@ -10,2 +10,3 @@ HEADERS = global.h \
10 progressdlg.h \ 10 progressdlg.h \
11 progresswidget.h \
11 installdlgimpl.h \ 12 installdlgimpl.h \
@@ -28,2 +29,3 @@ SOURCES = mainwin.cpp \
28 progressdlg.cpp \ 29 progressdlg.cpp \
30 progresswidget.cpp \
29 installdlgimpl.cpp \ 31 installdlgimpl.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
@@ -22,2 +22,5 @@ using namespace std;
22#include <qpe/config.h> 22#include <qpe/config.h>
23#include <qpe/qpeapplication.h>
24#else
25#include <qapplication.h>
23#endif 26#endif
@@ -32,2 +35,3 @@ QString DataManager::availableCategories = "";
32DataManager::DataManager() 35DataManager::DataManager()
36 : QObject( 0x0, 0x0 )
33{ 37{
@@ -167,5 +171,15 @@ void DataManager :: reloadServerData( )
167{ 171{
172 emit progressSetSteps( serverList.size() );
173 emit progressSetMessage( tr( "Reading configuration..." ) );
174
168 vector<Server>::iterator it = serverList.begin(); 175 vector<Server>::iterator it = serverList.begin();
176 QString serverName;
177 int i = 0;
169 for ( it = serverList.begin() ; it != serverList.end() ; ++it ) 178 for ( it = serverList.begin() ; it != serverList.end() ; ++it )
170 { 179 {
180 serverName = it->getServerName();
181 i++;
182 emit progressUpdate( i );
183 qApp->processEvents();
184
171 // Now we've read the config file in we need to read the servers 185 // Now we've read the config file in we need to read the servers
@@ -175,5 +189,5 @@ void DataManager :: reloadServerData( )
175 // The other servers files hold the contents of the server package list 189 // The other servers files hold the contents of the server package list
176 if ( it->getServerName() == LOCAL_SERVER ) 190 if ( serverName == LOCAL_SERVER )
177 it->readStatusFile( destList ); 191 it->readStatusFile( destList );
178 else if ( it->getServerName() == LOCAL_IPKGS ) 192 else if ( serverName == LOCAL_IPKGS )
179 it->readLocalIpks( &( *getServer( LOCAL_SERVER ) ) ); 193 it->readLocalIpks( &( *getServer( LOCAL_SERVER ) ) );
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
@@ -23,2 +23,3 @@ using namespace std;
23 23
24#include <qobject.h>
24#include <qstring.h> 25#include <qstring.h>
@@ -36,4 +37,5 @@ using namespace std;
36 37
37class DataManager 38class DataManager : public QObject
38{ 39{
40 Q_OBJECT
39public: 41public:
@@ -88,2 +90,7 @@ private:
88 vector<Destination> destList; 90 vector<Destination> destList;
91
92signals:
93 void progressSetSteps( int );
94 void progressSetMessage( const QString & );
95 void progressUpdate( int );
89}; 96};
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
@@ -21,6 +21,8 @@ using namespace std;
21#include <qmenubar.h> 21#include <qmenubar.h>
22#include <qpopupmenu.h>
23#include <qmessagebox.h> 22#include <qmessagebox.h>
23#include <qpopupmenu.h>
24#include <qtimer.h>
24 25
25#include "mainwin.h" 26#include "mainwin.h"
27#include "progresswidget.h"
26#include "datamgr.h" 28#include "datamgr.h"
@@ -68,8 +70,15 @@ MainWindow :: MainWindow( QWidget *p, char *name )
68 70
69 mgr = new DataManager(); 71 // Create UI widgets
70 mgr->loadServers();
71
72 stack = new QWidgetStack( this ); 72 stack = new QWidgetStack( this );
73 73
74 networkPkgWindow = new NetworkPackageManager( mgr, stack ); 74 progressWindow = new ProgressWidget( stack );
75 stack->addWidget( progressWindow, 2 );
76
77 networkPkgWindow = new NetworkPackageManager( stack );
78 connect( networkPkgWindow, SIGNAL( appRaiseMainWidget() ), this, SLOT( raiseMainWidget() ) );
79 connect( networkPkgWindow, SIGNAL( appRaiseProgressWidget() ), this, SLOT( raiseProgressWidget() ) );
80 connect( networkPkgWindow, SIGNAL( progressSetSteps( int ) ), progressWindow, SLOT( setSteps( int ) ) );
81 connect( networkPkgWindow, SIGNAL( progressSetMessage( const QString & ) ),
82 progressWindow, SLOT( setMessage( const QString & ) ) );
83 connect( networkPkgWindow, SIGNAL( progressUpdate( int ) ), progressWindow, SLOT( update( int ) ) );
75 stack->addWidget( networkPkgWindow, 1 ); 84 stack->addWidget( networkPkgWindow, 1 );
@@ -77,3 +86,7 @@ MainWindow :: MainWindow( QWidget *p, char *name )
77 setCentralWidget( stack ); 86 setCentralWidget( stack );
78 stack->raiseWidget( networkPkgWindow ); 87 stack->raiseWidget( progressWindow );
88
89 // Delayed call to finish initialization
90 QTimer::singleShot( 100, this, SLOT( init() ) );
91
79} 92}
@@ -82,3 +95,17 @@ MainWindow :: ~MainWindow()
82{ 95{
83 delete networkPkgWindow; 96 delete mgr;
97}
98
99void MainWindow :: init()
100{
101 stack->raiseWidget( progressWindow );
102 mgr = new DataManager();
103 connect( mgr, SIGNAL( progressSetSteps( int ) ), progressWindow, SLOT( setSteps( int ) ) );
104 connect( mgr, SIGNAL( progressSetMessage( const QString & ) ),
105 progressWindow, SLOT( setMessage( const QString & ) ) );
106 connect( mgr, SIGNAL( progressUpdate( int ) ), progressWindow, SLOT( update( int ) ) );
107 mgr->loadServers();
108 networkPkgWindow->setDataManager( mgr );
109 networkPkgWindow->updateData();
110 stack->raiseWidget( networkPkgWindow );
84} 111}
@@ -210 +237,11 @@ void MainWindow :: filterCategory()
210} 237}
238
239void MainWindow :: raiseMainWidget()
240{
241 stack->raiseWidget( networkPkgWindow );
242}
243
244void MainWindow :: raiseProgressWidget()
245{
246 stack->raiseWidget( progressWindow );
247}
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
@@ -23,3 +23,3 @@
23 23
24 24class ProgressWidget;
25class NetworkPackageManager; 25class NetworkPackageManager;
@@ -46,2 +46,3 @@ private:
46 NetworkPackageManager *networkPkgWindow; 46 NetworkPackageManager *networkPkgWindow;
47 ProgressWidget *progressWindow;
47 48
@@ -65,3 +66,7 @@ public slots:
65 void setFilterCategory(); 66 void setFilterCategory();
67 void raiseMainWidget();
68 void raiseProgressWidget();
66 69
70private slots:
71 void init();
67}; 72};
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
@@ -48,6 +48,5 @@ extern int compareVersions( const char *v1, const char *v2 );
48 48
49NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name) 49NetworkPackageManager::NetworkPackageManager( QWidget *parent, const char *name )
50 : QWidget(parent, name) 50 : QWidget(parent, name)
51{ 51{
52 dataMgr = dataManager;
53 52
@@ -70,3 +69,3 @@ NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget
70 69
71 updateData(); 70 //updateData();
72} 71}
@@ -77,8 +76,5 @@ NetworkPackageManager::~NetworkPackageManager()
77 76
78void NetworkPackageManager :: timerEvent ( QTimerEvent * ) 77void NetworkPackageManager :: setDataManager( DataManager *dm )
79{ 78{
80 killTimer( timerId ); 79 dataMgr = dm;
81
82 // Add server names to listbox
83 updateData();
84} 80}
@@ -87,2 +83,4 @@ void NetworkPackageManager :: updateData()
87{ 83{
84 emit progressSetSteps( dataMgr->getServerList().size() );
85
88 serversList->clear(); 86 serversList->clear();
@@ -90,3 +88,2 @@ void NetworkPackageManager :: updateData()
90 88
91
92 vector<Server>::iterator it; 89 vector<Server>::iterator it;
@@ -94,4 +91,10 @@ void NetworkPackageManager :: updateData()
94 int i; 91 int i;
92 QString serverName;
95 for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i ) 93 for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i )
96 { 94 {
95 serverName = it->getServerName();
96 emit progressSetMessage( tr( "Building server list:\n\t%1" ).arg( serverName ) );
97 emit progressUpdate( i );
98 qApp->processEvents();
99
97// cout << "Adding " << it->getServerName() << " to combobox" << endl; 100// cout << "Adding " << it->getServerName() << " to combobox" << endl;
@@ -99,3 +102,3 @@ void NetworkPackageManager :: updateData()
99 { 102 {
100 cout << it->getServerName() << " is not active" << endl; 103 cout << serverName << " is not active" << endl;
101 i--; 104 i--;
@@ -103,4 +106,5 @@ void NetworkPackageManager :: updateData()
103 } 106 }
104 serversList->insertItem( it->getServerName() ); 107
105 if ( it->getServerName() == currentlySelectedServer ) 108 serversList->insertItem( serverName );
109 if ( serverName == currentlySelectedServer )
106 activeItem = i; 110 activeItem = i;
@@ -111,3 +115,3 @@ void NetworkPackageManager :: updateData()
111 serversList->setCurrentItem( activeItem ); 115 serversList->setCurrentItem( activeItem );
112 serverSelected( 0 ); 116 serverSelected( 0, FALSE );
113} 117}
@@ -195,15 +199,9 @@ void NetworkPackageManager :: setupConnections()
195 199
196void NetworkPackageManager :: showProgressDialog( char *initialText ) 200void NetworkPackageManager :: serverSelected( int index )
197{ 201{
198 if ( !progressDlg ) 202 serverSelected( index, TRUE );
199 progressDlg = new ProgressDlg( this, "Progress", false );
200 progressDlg->setText( initialText );
201 progressDlg->show();
202} 203}
203 204
204 205void NetworkPackageManager :: serverSelected( int, bool raiseProgress )
205void NetworkPackageManager :: serverSelected( int )
206{ 206{
207 packagesList->clear();
208
209 // display packages 207 // display packages
@@ -212,2 +210,21 @@ void NetworkPackageManager :: serverSelected( int )
212 210
211 vector<Server>::iterator s = dataMgr->getServer( serverName );
212
213 vector<Package> &list = s->getPackageList();
214 vector<Package>::iterator it;
215
216 // Display progress widget while loading list
217 bool doProgress = ( list.size() > 200 );
218 if ( doProgress )
219 {
220 if ( raiseProgress )
221 {
222 emit appRaiseProgressWidget();
223 }
224 emit progressSetSteps( list.size() );
225 emit progressSetMessage( tr( "Building package list for:\n\t%1" ).arg( serverName ) );
226 }
227
228 packagesList->clear();
229
213#ifdef QWS 230#ifdef QWS
@@ -219,8 +236,15 @@ void NetworkPackageManager :: serverSelected( int )
219 236
220 vector<Server>::iterator s = dataMgr->getServer( serverName ); 237 int i = 0;
221
222 vector<Package> &list = s->getPackageList();
223 vector<Package>::iterator it;
224 for ( it = list.begin() ; it != list.end() ; ++it ) 238 for ( it = list.begin() ; it != list.end() ; ++it )
225 { 239 {
240 // Update progress after every 100th package (arbitrary value, seems to give good balance)
241 i++;
242 if ( ( i % 100 ) == 0 )
243 {
244 if ( doProgress )
245 {
246 emit progressUpdate( i );
247 }
248 qApp->processEvents();
249 }
226 250
@@ -334,2 +358,8 @@ void NetworkPackageManager :: serverSelected( int )
334 } 358 }
359
360 // Display this widget once everything is done
361 if ( doProgress && raiseProgress )
362 {
363 emit appRaiseMainWidget();
364 }
335} 365}
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
@@ -28,2 +28,3 @@
28#include "progressdlg.h" 28#include "progressdlg.h"
29
29class InstallData; 30class InstallData;
@@ -36,3 +37,3 @@ public:
36 /** construtor */ 37 /** construtor */
37 NetworkPackageManager( DataManager *dataManager, QWidget* parent=0, const char *name=0); 38 NetworkPackageManager( QWidget* parent=0, const char *name=0 );
38 /** destructor */ 39 /** destructor */
@@ -40,2 +41,3 @@ public:
40 41
42 void setDataManager( DataManager *dm );
41 void selectLocalPackage( const QString &pkg ); 43 void selectLocalPackage( const QString &pkg );
@@ -69,5 +71,2 @@ private:
69 bool showUpgradedPkgs; 71 bool showUpgradedPkgs;
70 int timerId;
71
72 void timerEvent ( QTimerEvent * );
73 72
@@ -78,2 +77,4 @@ private:
78 void downloadRemotePackage(); 77 void downloadRemotePackage();
78 void serverSelected( int index, bool showProgress );
79
79 InstallData dealWithItem( QCheckListItem *item ); 80 InstallData dealWithItem( QCheckListItem *item );
@@ -81,4 +82,10 @@ private:
81 82
83signals:
84 void appRaiseMainWidget();
85 void appRaiseProgressWidget();
86 void progressSetSteps( int );
87 void progressSetMessage( const QString & );
88 void progressUpdate( int );
89
82public slots: 90public slots:
83 void serverSelected( int index );
84 void applyChanges(); 91 void applyChanges();
@@ -89,2 +96,3 @@ public slots:
89 void letterPushed( QString t ); 96 void letterPushed( QString t );
97 void serverSelected( int index );
90}; 98};
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 @@
1/*
2                This file is part of the OPIE Project
3 =.
4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org>
5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29#include "progresswidget.h"
30
31#include <qlabel.h>
32#include <qlayout.h>
33#include <qprogressbar.h>
34
35ProgressWidget::ProgressWidget( QWidget *parent, const char *name, WFlags f )
36 : QWidget( parent, name, f )
37{
38 QVBoxLayout *layout = new QVBoxLayout( this, 4, 4 );
39
40 m_status = new QLabel( this );
41 m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
42 layout->addWidget( m_status );
43
44 m_progress = new QProgressBar( this );
45 layout->addWidget( m_progress );
46}
47
48ProgressWidget::~ProgressWidget()
49{
50}
51
52void ProgressWidget::setSteps( int numsteps )
53{
54 m_progress->setTotalSteps( numsteps );
55}
56
57void ProgressWidget::setMessage( const QString &msg )
58{
59 m_status->setText( msg );
60}
61
62void ProgressWidget::update( int progress )
63{
64 m_progress->setProgress( progress );
65}
66
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 @@
1/*
2                This file is part of the OPIE Project
3 =.
4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org>
5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29#ifndef PROGRESSWIDGET_H
30#define PROGRESSWIDGET_H
31
32#include <qwidget.h>
33
34class QLabel;
35class QProgressBar;
36
37class ProgressWidget : public QWidget
38{
39 Q_OBJECT
40public:
41 ProgressWidget( QWidget * = 0, const char * = 0, WFlags = 0 );
42 ~ProgressWidget();
43
44private:
45 QLabel *m_status;
46 QProgressBar *m_progress;
47
48public slots:
49 void setSteps( int );
50 void setMessage( const QString & );
51 void update( int );
52};
53
54#endif