summaryrefslogtreecommitdiff
authordrw <drw>2003-01-04 19:52:22 (UTC)
committer drw <drw>2003-01-04 19:52:22 (UTC)
commit8b0f280e69a6c5b4c1caf4070085feaf0951380d (patch) (unidiff)
treeee99aba03491199a28b862afd439a591d9a3de88
parentd7474edcc4efccbf5d5fd4b8926739a597463242 (diff)
downloadopie-8b0f280e69a6c5b4c1caf4070085feaf0951380d.zip
opie-8b0f280e69a6c5b4c1caf4070085feaf0951380d.tar.gz
opie-8b0f280e69a6c5b4c1caf4070085feaf0951380d.tar.bz2
Delay initial load of ipkg info so app displays quicker, and add progress display for longer operations (such as loading packages for large feeds).
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
@@ -1,40 +1,42 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG = qt warn_on debug 2 CONFIG = qt warn_on debug
3 HEADERS = global.h \ 3 HEADERS = global.h \
4 mainwin.h \ 4 mainwin.h \
5 datamgr.h \ 5 datamgr.h \
6 settingsimpl.h \ 6 settingsimpl.h \
7 ipkg.h \ 7 ipkg.h \
8 networkpkgmgr.h \ 8 networkpkgmgr.h \
9 package.h \ 9 package.h \
10 progressdlg.h \ 10 progressdlg.h \
11 progresswidget.h \
11 installdlgimpl.h \ 12 installdlgimpl.h \
12 instoptionsimpl.h \ 13 instoptionsimpl.h \
13 destination.h \ 14 destination.h \
14 utils.h \ 15 utils.h \
15 server.h \ 16 server.h \
16 helpwindow.h \ 17 helpwindow.h \
17 letterpushbutton.h \ 18 letterpushbutton.h \
18 inputdlg.h \ 19 inputdlg.h \
19 categoryfilterimpl.h 20 categoryfilterimpl.h
20 SOURCES = mainwin.cpp \ 21 SOURCES = mainwin.cpp \
21 datamgr.cpp \ 22 datamgr.cpp \
22 mem.cpp \ 23 mem.cpp \
23 settingsimpl.cpp \ 24 settingsimpl.cpp \
24 ipkg.cpp \ 25 ipkg.cpp \
25 networkpkgmgr.cpp \ 26 networkpkgmgr.cpp \
26 main.cpp \ 27 main.cpp \
27 package.cpp \ 28 package.cpp \
28 progressdlg.cpp \ 29 progressdlg.cpp \
30 progresswidget.cpp \
29 installdlgimpl.cpp \ 31 installdlgimpl.cpp \
30 instoptionsimpl.cpp \ 32 instoptionsimpl.cpp \
31 destination.cpp \ 33 destination.cpp \
32 utils.cpp \ 34 utils.cpp \
33 server.cpp \ 35 server.cpp \
34 helpwindow.cpp \ 36 helpwindow.cpp \
35 letterpushbutton.cpp \ 37 letterpushbutton.cpp \
36 inputdlg.cpp \ 38 inputdlg.cpp \
37 version.cpp \ 39 version.cpp \
38 categoryfilterimpl.cpp 40 categoryfilterimpl.cpp
39 INTERFACES= settings.ui \ 41 INTERFACES= settings.ui \
40 install.ui \ 42 install.ui \
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
@@ -11,34 +11,38 @@
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17#include <fstream> 17#include <fstream>
18#include <iostream> 18#include <iostream>
19using namespace std; 19using namespace std;
20 20
21#ifdef QWS 21#ifdef QWS
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
24 27
25#include <stdio.h> 28#include <stdio.h>
26 29
27#include "datamgr.h" 30#include "datamgr.h"
28#include "global.h" 31#include "global.h"
29 32
30 33
31QString DataManager::availableCategories = ""; 34QString DataManager::availableCategories = "";
32DataManager::DataManager() 35DataManager::DataManager()
36 : QObject( 0x0, 0x0 )
33{ 37{
34 activeServer = ""; 38 activeServer = "";
35 availableCategories = "#"; 39 availableCategories = "#";
36} 40}
37 41
38DataManager::~DataManager() 42DataManager::~DataManager()
39{ 43{
40} 44}
41 45
42vector<Server>::iterator DataManager :: getServer( const char *name ) 46vector<Server>::iterator DataManager :: getServer( const char *name )
43{ 47{
44 vector<Server>::iterator it = serverList.begin(); 48 vector<Server>::iterator it = serverList.begin();
@@ -156,35 +160,45 @@ void DataManager :: loadServers()
156 if ( stricmp( type, "proxy_password" ) == 0 ) 160 if ( stricmp( type, "proxy_password" ) == 0 )
157 proxyPassword = val; 161 proxyPassword = val;
158 } 162 }
159 } 163 }
160 } 164 }
161 fclose( fp ); 165 fclose( fp );
162 166
163 reloadServerData( ); 167 reloadServerData( );
164} 168}
165 169
166void DataManager :: reloadServerData( ) 170void 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
172 // The local server is a special case. This holds the contents of the 186 // The local server is a special case. This holds the contents of the
173 // status files the number of which depends on how many destinations 187 // status files the number of which depends on how many destinations
174 // we've set up 188 // we've set up
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 ) ) );
180 else 194 else
181 it->readPackageFile( &( *getServer( LOCAL_SERVER ) ) ); 195 it->readPackageFile( &( *getServer( LOCAL_SERVER ) ) );
182 } 196 }
183} 197}
184 198
185void DataManager :: writeOutIpkgConf() 199void DataManager :: writeOutIpkgConf()
186{ 200{
187 QString ipkg_conf = IPKG_CONF; 201 QString ipkg_conf = IPKG_CONF;
188 ofstream out( ipkg_conf ); 202 ofstream out( ipkg_conf );
189 203
190 out << "# Written by AQPkg" << endl; 204 out << "# Written by AQPkg" << endl;
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
@@ -12,39 +12,41 @@
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#ifndef DATAMGR_H 18#ifndef DATAMGR_H
19#define DATAMGR_H 19#define DATAMGR_H
20 20
21#include <map> 21#include <map>
22using namespace std; 22using namespace std;
23 23
24#include <qobject.h>
24#include <qstring.h> 25#include <qstring.h>
25 26
26#include "server.h" 27#include "server.h"
27#include "destination.h" 28#include "destination.h"
28 29
29 #define LOCAL_SERVER "Installed Pkgs" 30 #define LOCAL_SERVER "Installed Pkgs"
30 #define LOCAL_IPKGS "local IPKG" 31 #define LOCAL_IPKGS "local IPKG"
31 32
32/** 33/**
33 *@author Andy Qua 34 *@author Andy Qua
34 */ 35 */
35 36
36 37
37class DataManager 38class DataManager : public QObject
38{ 39{
40 Q_OBJECT
39public: 41public:
40 DataManager(); 42 DataManager();
41 ~DataManager(); 43 ~DataManager();
42 44
43 void setActiveServer( const QString &act ) { activeServer = act; } 45 void setActiveServer( const QString &act ) { activeServer = act; }
44 QString &getActiveServer( ) { return activeServer; } 46 QString &getActiveServer( ) { return activeServer; }
45 47
46 Server *getLocalServer() { return &( *getServer( LOCAL_SERVER ) ); } 48 Server *getLocalServer() { return &( *getServer( LOCAL_SERVER ) ); }
47 vector<Server> &getServerList() { return serverList; } 49 vector<Server> &getServerList() { return serverList; }
48 vector<Server>::iterator getServer( const char *name ); 50 vector<Server>::iterator getServer( const char *name );
49 51
50 vector<Destination> &getDestinationList() { return destList; } 52 vector<Destination> &getDestinationList() { return destList; }
@@ -77,15 +79,20 @@ private:
77 static QString availableCategories; 79 static QString availableCategories;
78 QString activeServer; 80 QString activeServer;
79 QString httpProxy; 81 QString httpProxy;
80 QString ftpProxy; 82 QString ftpProxy;
81 QString proxyUsername; 83 QString proxyUsername;
82 QString proxyPassword; 84 QString proxyPassword;
83 85
84 bool httpProxyEnabled; 86 bool httpProxyEnabled;
85 bool ftpProxyEnabled; 87 bool ftpProxyEnabled;
86 88
87 vector<Server> serverList; 89 vector<Server> serverList;
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};
90 97
91#endif 98#endif
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
@@ -10,28 +10,30 @@
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#include <iostream> 18#include <iostream>
19using namespace std; 19using namespace std;
20 20
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"
27#include "networkpkgmgr.h" 29#include "networkpkgmgr.h"
28#include "settingsimpl.h" 30#include "settingsimpl.h"
29#include "helpwindow.h" 31#include "helpwindow.h"
30#include "utils.h" 32#include "utils.h"
31#include "global.h" 33#include "global.h"
32 34
33MainWindow :: MainWindow( QWidget *p, char *name ) 35MainWindow :: MainWindow( QWidget *p, char *name )
34 :QMainWindow( p, name ) 36 :QMainWindow( p, name )
35{ 37{
36#ifdef QWS 38#ifdef QWS
37 showMaximized(); 39 showMaximized();
@@ -57,39 +59,64 @@ MainWindow :: MainWindow( QWidget *p, char *name )
57 mnuShowUpgradedPkgsId = filter->insertItem( "Show U&pdated Packages", this, SLOT(filterUpgradedPackages()), Qt::CTRL+Qt::Key_P ); 59 mnuShowUpgradedPkgsId = filter->insertItem( "Show U&pdated Packages", this, SLOT(filterUpgradedPackages()), Qt::CTRL+Qt::Key_P );
58 filter->insertSeparator(); 60 filter->insertSeparator();
59 mnuFilterByCategory = filter->insertItem( "Filter By &Category", this, SLOT(filterCategory()), Qt::CTRL+Qt::Key_C ); 61 mnuFilterByCategory = filter->insertItem( "Filter By &Category", this, SLOT(filterCategory()), Qt::CTRL+Qt::Key_C );
60 mnuSetFilterCategory = filter->insertItem( "Set Filter C&ategory", this, SLOT(setFilterCategory()), Qt::CTRL+Qt::Key_A ); 62 mnuSetFilterCategory = filter->insertItem( "Set Filter C&ategory", this, SLOT(setFilterCategory()), Qt::CTRL+Qt::Key_A );
61 63
62 // Create the main menu 64 // Create the main menu
63 menu = menuBar(); //new QMenuBar( this ); 65 menu = menuBar(); //new QMenuBar( this );
64 menu->insertItem( tr( "&Settings" ), settings ); 66 menu->insertItem( tr( "&Settings" ), settings );
65 menu->insertItem( tr( "&Edit" ), edit ); 67 menu->insertItem( tr( "&Edit" ), edit );
66 menu->insertItem( tr( "&Filter" ), filter ); 68 menu->insertItem( tr( "&Filter" ), filter );
67 menu->insertItem( tr( "&Help" ), help ); 69 menu->insertItem( tr( "&Help" ), help );
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 );
76 85
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}
80 93
81MainWindow :: ~MainWindow() 94MainWindow :: ~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}
85 112
86void MainWindow :: setDocument( const QString &doc ) 113void MainWindow :: setDocument( const QString &doc )
87{ 114{
88 // Remove path from package 115 // Remove path from package
89 QString package = Utils::getPackageNameFromIpkFilename( doc ); 116 QString package = Utils::getPackageNameFromIpkFilename( doc );
90 std::cout << "Selecting package " << package << std::endl; 117 std::cout << "Selecting package " << package << std::endl;
91 networkPkgWindow->selectLocalPackage( package ); 118 networkPkgWindow->selectLocalPackage( package );
92} 119}
93 120
94void MainWindow :: displaySettings() 121void MainWindow :: displaySettings()
95{ 122{
@@ -199,12 +226,22 @@ void MainWindow :: filterCategory()
199{ 226{
200 if ( filter->isItemChecked( mnuFilterByCategory ) ) 227 if ( filter->isItemChecked( mnuFilterByCategory ) )
201 { 228 {
202 networkPkgWindow->filterByCategory( false ); 229 networkPkgWindow->filterByCategory( false );
203 filter->setItemChecked( mnuFilterByCategory, false ); 230 filter->setItemChecked( mnuFilterByCategory, false );
204 } 231 }
205 else 232 else
206 { 233 {
207 if ( networkPkgWindow->filterByCategory( true ) ) 234 if ( networkPkgWindow->filterByCategory( true ) )
208 filter->setItemChecked( mnuFilterByCategory, true ); 235 filter->setItemChecked( mnuFilterByCategory, true );
209 } 236 }
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
@@ -12,57 +12,62 @@
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#ifndef MAINWIN_H 18#ifndef MAINWIN_H
19#define MAINWIN_H 19#define MAINWIN_H
20 20
21#include <qmainwindow.h> 21#include <qmainwindow.h>
22#include <qwidgetstack.h> 22#include <qwidgetstack.h>
23 23
24 24class ProgressWidget;
25class NetworkPackageManager; 25class NetworkPackageManager;
26class DataManager; 26class DataManager;
27 27
28class MainWindow :public QMainWindow 28class MainWindow :public QMainWindow
29{ 29{
30 Q_OBJECT 30 Q_OBJECT
31public: 31public:
32 32
33 MainWindow( QWidget *p = 0, char *name = 0 ); 33 MainWindow( QWidget *p = 0, char *name = 0 );
34 ~MainWindow(); 34 ~MainWindow();
35 35
36private: 36private:
37 DataManager *mgr; 37 DataManager *mgr;
38 38
39 QMenuBar *menu; 39 QMenuBar *menu;
40 QPopupMenu *help; 40 QPopupMenu *help;
41 QPopupMenu *settings; 41 QPopupMenu *settings;
42 QPopupMenu *edit; 42 QPopupMenu *edit;
43 QPopupMenu *filter; 43 QPopupMenu *filter;
44 QWidgetStack *stack; 44 QWidgetStack *stack;
45 45
46 NetworkPackageManager *networkPkgWindow; 46 NetworkPackageManager *networkPkgWindow;
47 ProgressWidget *progressWindow;
47 48
48 int mnuShowUninstalledPkgsId; 49 int mnuShowUninstalledPkgsId;
49 int mnuShowInstalledPkgsId; 50 int mnuShowInstalledPkgsId;
50 int mnuShowUpgradedPkgsId; 51 int mnuShowUpgradedPkgsId;
51 int mnuFilterByCategory; 52 int mnuFilterByCategory;
52 int mnuSetFilterCategory; 53 int mnuSetFilterCategory;
53 54
54public slots: 55public slots:
55 void setDocument( const QString &doc ); 56 void setDocument( const QString &doc );
56 void displayHelp(); 57 void displayHelp();
57 void searchForPackage(); 58 void searchForPackage();
58 void repeatSearchForPackage(); 59 void repeatSearchForPackage();
59 void displayAbout(); 60 void displayAbout();
60 void displaySettings(); 61 void displaySettings();
61 void filterUninstalledPackages(); 62 void filterUninstalledPackages();
62 void filterInstalledPackages(); 63 void filterInstalledPackages();
63 void filterUpgradedPackages(); 64 void filterUpgradedPackages();
64 void filterCategory(); 65 void filterCategory();
65 void setFilterCategory(); 66 void setFilterCategory();
67 void raiseMainWidget();
68 void raiseProgressWidget();
66 69
70private slots:
71 void init();
67}; 72};
68#endif 73#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
@@ -37,88 +37,92 @@ using namespace std;
37#include "datamgr.h" 37#include "datamgr.h"
38#include "networkpkgmgr.h" 38#include "networkpkgmgr.h"
39#include "installdlgimpl.h" 39#include "installdlgimpl.h"
40#include "ipkg.h" 40#include "ipkg.h"
41#include "inputdlg.h" 41#include "inputdlg.h"
42#include "letterpushbutton.h" 42#include "letterpushbutton.h"
43#include "categoryfilterimpl.h" 43#include "categoryfilterimpl.h"
44 44
45#include "global.h" 45#include "global.h"
46 46
47extern int compareVersions( const char *v1, const char *v2 ); 47extern 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
54#ifdef QWS 53#ifdef QWS
55 // read download directory from config file 54 // read download directory from config file
56 Config cfg( "aqpkg" ); 55 Config cfg( "aqpkg" );
57 cfg.setGroup( "settings" ); 56 cfg.setGroup( "settings" );
58 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); 57 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" );
59 showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); 58 showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" );
60 59
61#endif 60#endif
62 61
63 showUninstalledPkgs = false; 62 showUninstalledPkgs = false;
64 showInstalledPkgs = false; 63 showInstalledPkgs = false;
65 showUpgradedPkgs = false; 64 showUpgradedPkgs = false;
66 categoryFilterEnabled = false; 65 categoryFilterEnabled = false;
67 66
68 initGui(); 67 initGui();
69 setupConnections(); 68 setupConnections();
70 69
71 updateData(); 70 //updateData();
72} 71}
73 72
74NetworkPackageManager::~NetworkPackageManager() 73NetworkPackageManager::~NetworkPackageManager()
75{ 74{
76} 75}
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}
85 81
86void NetworkPackageManager :: updateData() 82void NetworkPackageManager :: updateData()
87{ 83{
84 emit progressSetSteps( dataMgr->getServerList().size() );
85
88 serversList->clear(); 86 serversList->clear();
89 packagesList->clear(); 87 packagesList->clear();
90 88
91
92 vector<Server>::iterator it; 89 vector<Server>::iterator it;
93 int activeItem = -1; 90 int activeItem = -1;
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;
98 if ( !it->isServerActive() ) 101 if ( !it->isServerActive() )
99 { 102 {
100 cout << it->getServerName() << " is not active" << endl; 103 cout << serverName << " is not active" << endl;
101 i--; 104 i--;
102 continue; 105 continue;
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;
107 } 111 }
108 112
109 // set selected server to be active server 113 // set selected server to be active server
110 if ( activeItem != -1 ) 114 if ( activeItem != -1 )
111 serversList->setCurrentItem( activeItem ); 115 serversList->setCurrentItem( activeItem );
112 serverSelected( 0 ); 116 serverSelected( 0, FALSE );
113} 117}
114 118
115void NetworkPackageManager :: selectLocalPackage( const QString &pkg ) 119void NetworkPackageManager :: selectLocalPackage( const QString &pkg )
116{ 120{
117 // First select local server 121 // First select local server
118 for ( int i = 0 ; i < serversList->count() ; ++i ) 122 for ( int i = 0 ; i < serversList->count() ; ++i )
119 { 123 {
120 if ( serversList->text( i ) == LOCAL_IPKGS ) 124 if ( serversList->text( i ) == LOCAL_IPKGS )
121 { 125 {
122 serversList->setCurrentItem( i ); 126 serversList->setCurrentItem( i );
123 break; 127 break;
124 } 128 }
@@ -184,54 +188,74 @@ void NetworkPackageManager :: initGui()
184 hbox2->addWidget( apply ); 188 hbox2->addWidget( apply );
185} 189}
186 190
187void NetworkPackageManager :: setupConnections() 191void NetworkPackageManager :: setupConnections()
188{ 192{
189 connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int ))); 193 connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int )));
190 connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) ); 194 connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) );
191 connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) ); 195 connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) );
192 connect( upgrade, SIGNAL( released()), this, SLOT(upgradePackages()) ); 196 connect( upgrade, SIGNAL( released()), this, SLOT(upgradePackages()) );
193 connect( update, SIGNAL(released()), this, SLOT(updateServer()) ); 197 connect( update, SIGNAL(released()), this, SLOT(updateServer()) );
194} 198}
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
210 QString serverName = serversList->currentText(); 208 QString serverName = serversList->currentText();
211 currentlySelectedServer = serverName; 209 currentlySelectedServer = serverName;
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
214 // read download directory from config file 231 // read download directory from config file
215 Config cfg( "aqpkg" ); 232 Config cfg( "aqpkg" );
216 cfg.setGroup( "settings" ); 233 cfg.setGroup( "settings" );
217 cfg.writeEntry( "selectedServer", currentlySelectedServer ); 234 cfg.writeEntry( "selectedServer", currentlySelectedServer );
218#endif 235#endif
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
227 QString text = ""; 251 QString text = "";
228 252
229 // Apply show only uninstalled packages filter 253 // Apply show only uninstalled packages filter
230 if ( showUninstalledPkgs && it->isInstalled() ) 254 if ( showUninstalledPkgs && it->isInstalled() )
231 continue; 255 continue;
232 256
233 // Apply show only installed packages filter 257 // Apply show only installed packages filter
234 if ( showInstalledPkgs && !it->isInstalled() ) 258 if ( showInstalledPkgs && !it->isInstalled() )
235 continue; 259 continue;
236 260
237 // Apply show only new installed packages filter 261 // Apply show only new installed packages filter
@@ -323,24 +347,30 @@ void NetworkPackageManager :: serverSelected( int )
323 else if ( serverName == LOCAL_IPKGS ) 347 else if ( serverName == LOCAL_IPKGS )
324 { 348 {
325 upgrade->setEnabled( false ); 349 upgrade->setEnabled( false );
326 download->setEnabled( true ); 350 download->setEnabled( true );
327 download->setText( "Remove" ); 351 download->setText( "Remove" );
328 } 352 }
329 else 353 else
330 { 354 {
331 upgrade->setEnabled( true ); 355 upgrade->setEnabled( true );
332 download->setEnabled( true ); 356 download->setEnabled( true );
333 download->setText( "Download" ); 357 download->setText( "Download" );
334 } 358 }
359
360 // Display this widget once everything is done
361 if ( doProgress && raiseProgress )
362 {
363 emit appRaiseMainWidget();
364 }
335} 365}
336 366
337void NetworkPackageManager :: updateServer() 367void NetworkPackageManager :: updateServer()
338{ 368{
339 QString serverName = serversList->currentText(); 369 QString serverName = serversList->currentText();
340 370
341 // Update the current server 371 // Update the current server
342 // Display dialog 372 // Display dialog
343 373
344 // Disable buttons to stop silly people clicking lots on them :) 374 // Disable buttons to stop silly people clicking lots on them :)
345 375
346 // First, write out ipkg_conf file so that ipkg can use it 376 // First, write out ipkg_conf file so that ipkg can use it
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
@@ -17,36 +17,38 @@
17 17
18#ifndef NETWORKPKGMGR_H 18#ifndef NETWORKPKGMGR_H
19#define NETWORKPKGMGR_H 19#define NETWORKPKGMGR_H
20 20
21#include <qlayout.h> 21#include <qlayout.h>
22#include <qpushbutton.h> 22#include <qpushbutton.h>
23#include <qwidget.h> 23#include <qwidget.h>
24#include <qcombobox.h> 24#include <qcombobox.h>
25#include <qlistview.h> 25#include <qlistview.h>
26 26
27#include "datamgr.h" 27#include "datamgr.h"
28#include "progressdlg.h" 28#include "progressdlg.h"
29
29class InstallData; 30class InstallData;
30 31
31/** NetworkPackageManager is the base class of the project */ 32/** NetworkPackageManager is the base class of the project */
32class NetworkPackageManager : public QWidget 33class NetworkPackageManager : public QWidget
33{ 34{
34 Q_OBJECT 35 Q_OBJECT
35public: 36public:
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 */
39 ~NetworkPackageManager(); 40 ~NetworkPackageManager();
40 41
42 void setDataManager( DataManager *dm );
41 void selectLocalPackage( const QString &pkg ); 43 void selectLocalPackage( const QString &pkg );
42 void updateData(); 44 void updateData();
43 void searchForPackage( bool findNext ); 45 void searchForPackage( bool findNext );
44 void showOnlyUninstalledPackages( bool val ); 46 void showOnlyUninstalledPackages( bool val );
45 void showOnlyInstalledPackages( bool val ); 47 void showOnlyInstalledPackages( bool val );
46 void showUpgradedPackages( bool val ); 48 void showUpgradedPackages( bool val );
47 bool filterByCategory( bool val ); 49 bool filterByCategory( bool val );
48 bool setFilterCategory(); 50 bool setFilterCategory();
49 51
50private: 52private:
51 DataManager *dataMgr; 53 DataManager *dataMgr;
52 54
@@ -58,35 +60,41 @@ private:
58 QPushButton *apply; 60 QPushButton *apply;
59 61
60 ProgressDlg *progressDlg; 62 ProgressDlg *progressDlg;
61 QString currentlySelectedServer; 63 QString currentlySelectedServer;
62 QString lastSearchText; 64 QString lastSearchText;
63 QString categoryFilter; 65 QString categoryFilter;
64 66
65 bool categoryFilterEnabled; 67 bool categoryFilterEnabled;
66 bool showJumpTo; 68 bool showJumpTo;
67 bool showUninstalledPkgs; 69 bool showUninstalledPkgs;
68 bool showInstalledPkgs; 70 bool showInstalledPkgs;
69 bool showUpgradedPkgs; 71 bool showUpgradedPkgs;
70 int timerId;
71
72 void timerEvent ( QTimerEvent * );
73 72
74 void initGui(); 73 void initGui();
75 void setupConnections(); 74 void setupConnections();
76 void showProgressDialog( char *initialText ); 75 void showProgressDialog( char *initialText );
77 void downloadSelectedPackages(); 76 void downloadSelectedPackages();
78 void downloadRemotePackage(); 77 void downloadRemotePackage();
78 void serverSelected( int index, bool showProgress );
79
79 InstallData dealWithItem( QCheckListItem *item ); 80 InstallData dealWithItem( QCheckListItem *item );
80 QString stickyOption; 81 QString stickyOption;
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();
85 void upgradePackages(); 92 void upgradePackages();
86 void downloadPackage(); 93 void downloadPackage();
87 void updateServer(); 94 void updateServer();
88 void displayText( const QString &t ); 95 void displayText( const QString &t );
89 void letterPushed( QString t ); 96 void letterPushed( QString t );
97 void serverSelected( int index );
90}; 98};
91 99
92#endif 100#endif
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