author | drw <drw> | 2003-01-04 19:52:22 (UTC) |
---|---|---|
committer | drw <drw> | 2003-01-04 19:52:22 (UTC) |
commit | 8b0f280e69a6c5b4c1caf4070085feaf0951380d (patch) (side-by-side diff) | |
tree | ee99aba03491199a28b862afd439a591d9a3de88 /noncore/settings/aqpkg/networkpkgmgr.cpp | |
parent | d7474edcc4efccbf5d5fd4b8926739a597463242 (diff) | |
download | opie-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 (limited to 'noncore/settings/aqpkg/networkpkgmgr.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.cpp | 82 |
1 files changed, 56 insertions, 26 deletions
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 ); -NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name) +NetworkPackageManager::NetworkPackageManager( QWidget *parent, const char *name ) : QWidget(parent, name) { - dataMgr = dataManager; @@ -70,3 +69,3 @@ NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget - updateData(); + //updateData(); } @@ -77,8 +76,5 @@ NetworkPackageManager::~NetworkPackageManager() -void NetworkPackageManager :: timerEvent ( QTimerEvent * ) +void NetworkPackageManager :: setDataManager( DataManager *dm ) { - killTimer( timerId ); - - // Add server names to listbox - updateData(); + dataMgr = dm; } @@ -87,2 +83,4 @@ void NetworkPackageManager :: updateData() { + emit progressSetSteps( dataMgr->getServerList().size() ); + serversList->clear(); @@ -90,3 +88,2 @@ void NetworkPackageManager :: updateData() - vector<Server>::iterator it; @@ -94,4 +91,10 @@ void NetworkPackageManager :: updateData() 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; @@ -99,3 +102,3 @@ void NetworkPackageManager :: updateData() { - cout << it->getServerName() << " is not active" << endl; + cout << serverName << " is not active" << endl; i--; @@ -103,4 +106,5 @@ void NetworkPackageManager :: updateData() } - serversList->insertItem( it->getServerName() ); - if ( it->getServerName() == currentlySelectedServer ) + + serversList->insertItem( serverName ); + if ( serverName == currentlySelectedServer ) activeItem = i; @@ -111,3 +115,3 @@ void NetworkPackageManager :: updateData() serversList->setCurrentItem( activeItem ); - serverSelected( 0 ); + serverSelected( 0, FALSE ); } @@ -195,15 +199,9 @@ 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 @@ -212,2 +210,21 @@ void NetworkPackageManager :: serverSelected( int ) + 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 @@ -219,8 +236,15 @@ void NetworkPackageManager :: serverSelected( int ) - 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(); + } @@ -334,2 +358,8 @@ void NetworkPackageManager :: serverSelected( int ) } + + // Display this widget once everything is done + if ( doProgress && raiseProgress ) + { + emit appRaiseMainWidget(); + } } |