summaryrefslogtreecommitdiff
authordrw <drw>2003-02-06 01:19:25 (UTC)
committer drw <drw>2003-02-06 01:19:25 (UTC)
commit79588befde53765db0a92977c6890a4d226096e7 (patch) (side-by-side diff)
tree83b6dd14c49733b9759fad04147bf0bee50793fe
parentbbb3690f12191763a407e6a0edd521113b3c25ac (diff)
downloadopie-79588befde53765db0a92977c6890a4d226096e7.zip
opie-79588befde53765db0a92977c6890a4d226096e7.tar.gz
opie-79588befde53765db0a92977c6890a4d226096e7.tar.bz2
Change all vector<> to QList<>. First step in removing dependency on libstdc++.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/datamgr.cpp82
-rw-r--r--noncore/settings/aqpkg/datamgr.h15
-rw-r--r--noncore/settings/aqpkg/installdlgimpl.cpp84
-rw-r--r--noncore/settings/aqpkg/installdlgimpl.h12
-rw-r--r--noncore/settings/aqpkg/mainwin.cpp143
-rw-r--r--noncore/settings/aqpkg/mainwin.h2
-rw-r--r--noncore/settings/aqpkg/server.cpp75
-rw-r--r--noncore/settings/aqpkg/server.h8
-rw-r--r--noncore/settings/aqpkg/settingsimpl.cpp38
9 files changed, 245 insertions, 214 deletions
diff --git a/noncore/settings/aqpkg/datamgr.cpp b/noncore/settings/aqpkg/datamgr.cpp
index 2c83e28..79f36e1 100644
--- a/noncore/settings/aqpkg/datamgr.cpp
+++ b/noncore/settings/aqpkg/datamgr.cpp
@@ -38,4 +38,7 @@ DataManager::DataManager()
activeServer = "";
availableCategories = "#";
+
+ serverList.setAutoDelete( TRUE );
+ destList.setAutoDelete( TRUE );
}
@@ -44,30 +47,24 @@ DataManager::~DataManager()
}
-vector<Server>::iterator DataManager :: getServer( const char *name )
+Server *DataManager :: getServer( const char *name )
{
- vector<Server>::iterator it = serverList.begin();
- while ( it != serverList.end() )
+ QListIterator<Server> it( serverList );
+ while ( it.current() && it.current()->getServerName() != name )
{
- if ( it->getServerName() == name )
- return it;
-
++it;
}
- return serverList.end();
+ return it.current();
}
-vector<Destination>::iterator DataManager :: getDestination( const char *name )
+Destination *DataManager :: getDestination( const char *name )
{
- vector<Destination>::iterator it = destList.begin();
- while ( it != destList.end() )
+ QListIterator<Destination> it( destList );
+ while ( it.current() && it.current()->getDestinationName() != name )
{
- if ( it->getDestinationName() == name )
- return it;
-
++it;
}
- return destList.end();
+ return it.current();
}
@@ -76,6 +73,6 @@ void DataManager :: loadServers()
// First add our local server - not really a server but
// the local config (which packages are installed)
- serverList.push_back( Server( LOCAL_SERVER, "" ) );
- serverList.push_back( Server( LOCAL_IPKGS, "" ) );
+ serverList.append( new Server( LOCAL_SERVER, "" ) );
+ serverList.append( new Server( LOCAL_IPKGS, "" ) );
#ifdef QWS
@@ -110,11 +107,11 @@ void DataManager :: loadServers()
// Should Handle #src, # src, src, and combinations of
sscanf( lineStr, "%*[^r]%*[^ ] %s %s", alias, url );
- Server s( alias, url );
+ Server *s = new Server( alias, url );
if ( lineStr.startsWith( "src" ) )
- s.setActive( true );
+ s->setActive( true );
else
- s.setActive( false );
+ s->setActive( false );
- serverList.push_back( s );
+ serverList.append( s );
}
@@ -124,5 +121,5 @@ void DataManager :: loadServers()
char path[50];
sscanf( lineStr, "%*[^ ] %s %s", alias, path );
- Destination d( alias, path );
+ Destination *d = new Destination( alias, path );
bool linkToRoot = true;
#ifdef QWS
@@ -131,7 +128,7 @@ void DataManager :: loadServers()
linkToRoot = cfg.readBoolEntry( key, true );
#endif
- d.linkToRoot( linkToRoot );
+ d->linkToRoot( linkToRoot );
- destList.push_back( d );
+ destList.append( d );
}
else if ( lineStr.startsWith( "option" ) || lineStr.startsWith( "#option" ) )
@@ -170,13 +167,16 @@ void DataManager :: loadServers()
void DataManager :: reloadServerData( )
{
- emit progressSetSteps( serverList.size() );
+ emit progressSetSteps( serverList.count() );
emit progressSetMessage( tr( "Reading configuration..." ) );
- vector<Server>::iterator it = serverList.begin();
QString serverName;
int i = 0;
- for ( it = serverList.begin() ; it != serverList.end() ; ++it )
+
+ Server *server;
+ QListIterator<Server> it( serverList );
+ for ( ; it.current(); ++it )
{
- serverName = it->getServerName();
+ server = it.current();
+ serverName = server->getServerName();
i++;
emit progressUpdate( i );
@@ -189,9 +189,9 @@ void DataManager :: reloadServerData( )
// The other servers files hold the contents of the server package list
if ( serverName == LOCAL_SERVER )
- it->readStatusFile( destList );
+ server->readStatusFile( destList );
else if ( serverName == LOCAL_IPKGS )
- it->readLocalIpks( &( *getServer( LOCAL_SERVER ) ) );
+ server->readLocalIpks( getServer( LOCAL_SERVER ) );
else
- it->readPackageFile( &( *getServer( LOCAL_SERVER ) ) );
+ server->readPackageFile( getServer( LOCAL_SERVER ) );
}
}
@@ -218,19 +218,21 @@ void DataManager :: writeOutIpkgConf()
// Write out servers
- vector<Server>::iterator it = serverList.begin();
- while ( it != serverList.end() )
+ Server *server;
+ QListIterator<Server> it( serverList );
+ while ( it.current() )
{
- QString alias = it->getServerName();
+ server = it.current();
+ QString alias = server->getServerName();
// Don't write out local as its a dummy
if ( alias != LOCAL_SERVER && alias != LOCAL_IPKGS )
{
- QString url = it->getServerUrl();;
+ QString url = server->getServerUrl();;
- if ( !it->isServerActive() )
+ if ( !server->isServerActive() )
out << "#";
out << "src " << alias << " " << url << endl;
}
- it++;
+ ++it;
}
@@ -238,9 +240,9 @@ void DataManager :: writeOutIpkgConf()
// Write out destinations
- vector<Destination>::iterator it2 = destList.begin();
- while ( it2 != destList.end() )
+ QListIterator<Destination> it2( destList );
+ while ( it2.current() )
{
- out << "dest " << it2->getDestinationName() << " " << it2->getDestinationPath() << endl;
- it2++;
+ out << "dest " << it2.current()->getDestinationName() << " " << it2.current()->getDestinationPath() << endl;
+ ++it2;
}
diff --git a/noncore/settings/aqpkg/datamgr.h b/noncore/settings/aqpkg/datamgr.h
index 90328ab..7fa42c1 100644
--- a/noncore/settings/aqpkg/datamgr.h
+++ b/noncore/settings/aqpkg/datamgr.h
@@ -22,4 +22,5 @@
using namespace std;
+#include <qlist.h>
#include <qobject.h>
#include <qstring.h>
@@ -46,10 +47,10 @@ public:
QString &getActiveServer( ) { return activeServer; }
- Server *getLocalServer() { return &( *getServer( LOCAL_SERVER ) ); }
- vector<Server> &getServerList() { return serverList; }
- vector<Server>::iterator getServer( const char *name );
+ Server *getLocalServer() { return ( getServer( LOCAL_SERVER ) ); }
+ QList<Server> &getServerList() { return serverList; }
+ Server *getServer( const char *name );
- vector<Destination> &getDestinationList() { return destList; }
- vector<Destination>::iterator getDestination( const char *name );
+ QList<Destination> &getDestinationList() { return destList; }
+ Destination *getDestination( const char *name );
void loadServers();
@@ -87,6 +88,6 @@ private:
bool ftpProxyEnabled;
- vector<Server> serverList;
- vector<Destination> destList;
+ QList<Server> serverList;
+ QList<Destination> destList;
signals:
diff --git a/noncore/settings/aqpkg/installdlgimpl.cpp b/noncore/settings/aqpkg/installdlgimpl.cpp
index 19fe46a..9339086 100644
--- a/noncore/settings/aqpkg/installdlgimpl.cpp
+++ b/noncore/settings/aqpkg/installdlgimpl.cpp
@@ -42,5 +42,5 @@
#include "global.h"
-InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *dataManager, const char *title )
+InstallDlgImpl::InstallDlgImpl( QList<InstallData> &packageList, DataManager *dataManager, const char *title )
: QWidget( 0, 0, 0 )
{
@@ -51,5 +51,4 @@ InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *d
upgradePackages = false;
dataMgr = dataManager;
- vector<Destination>::iterator dit;
QString defaultDest = "root";
@@ -75,8 +74,9 @@ InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *d
int defIndex = 0;
int i;
- for ( i = 0 , dit = dataMgr->getDestinationList().begin() ; dit != dataMgr->getDestinationList().end() ; ++dit, ++i )
+ QListIterator<Destination> dit( dataMgr->getDestinationList() );
+ for ( i = 0; dit.current(); ++dit, ++i )
{
- destination->insertItem( dit->getDestinationName() );
- if ( dit->getDestinationName() == defaultDest )
+ destination->insertItem( dit.current()->getDestinationName() );
+ if ( dit.current()->getDestinationName() == defaultDest )
defIndex = i;
}
@@ -84,34 +84,40 @@ InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *d
destination->setCurrentItem( defIndex );
- vector<InstallData>::iterator it;
+ QListIterator<InstallData> it( packageList );
// setup package data
QString remove = tr( "Remove\n" );
QString install = tr( "Install\n" );
QString upgrade = tr( "Upgrade\n" );
- for ( it = packageList.begin() ; it != packageList.end() ; ++it )
+ for ( ; it.current(); ++it )
{
- InstallData item = *it;
- if ( item.option == "I" )
+ InstallData *item = it.current();
+ InstallData *newitem = new InstallData();
+
+ newitem->option = item->option;
+ newitem->packageName = item->packageName;
+ newitem->destination = item->destination;
+ newitem->recreateLinks = item->recreateLinks;
+
+ if ( item->option == "I" )
{
- installList.push_back( item );
- install.append( QString( " %1\n" ).arg( item.packageName ) );
+ installList.append( newitem );
+ install.append( QString( " %1\n" ).arg( item->packageName ) );
}
- else if ( item.option == "D" )
+ else if ( item->option == "D" )
{
- removeList.push_back( item );
- remove.append( QString( " %1\n" ).arg( item.packageName ) );
+ removeList.append( newitem );
+ remove.append( QString( " %1\n" ).arg( item->packageName ) );
}
- else if ( item.option == "U" || item.option == "R" )
+ else if ( item->option == "U" || item->option == "R" )
{
- updateList.push_back( item );
+ updateList.append( newitem );
QString type;
- if ( item.option == "R" )
+ if ( item->option == "R" )
type = tr( "(ReInstall)" );
else
type = tr( "(Upgrade)" );
- upgrade.append( QString( " %1 %2\n" ).arg( item.packageName ).arg( type ) );
+ upgrade.append( QString( " %1 %2\n" ).arg( item->packageName ).arg( type ) );
}
}
-
output->setText( QString( "%1\n%2\n%3\n" ).arg( remove ).arg( install ).arg( upgrade ) );
@@ -214,5 +220,5 @@ void InstallDlgImpl :: installSelected()
return;
}
-
+
// Disable buttons
btnOptions->setEnabled( false );
@@ -230,5 +236,5 @@ void InstallDlgImpl :: installSelected()
{
output->setText( "" );
- vector<Destination>::iterator d = dataMgr->getDestination( destination->currentText() );
+ Destination *d = dataMgr->getDestination( destination->currentText() );
QString dest = d->getDestinationName();
QString destDir = d->getDestinationPath();
@@ -248,14 +254,16 @@ void InstallDlgImpl :: installSelected()
// First run through the remove list, then the install list then the upgrade list
- vector<InstallData>::iterator it;
pIpkg->setOption( "remove" );
- for ( it = removeList.begin() ; it != removeList.end() ; ++it )
+ QListIterator<InstallData> it( removeList );
+ InstallData *idata;
+ for ( ; it.current(); ++it )
{
- pIpkg->setDestination( it->destination->getDestinationName() );
- pIpkg->setDestinationDir( it->destination->getDestinationPath() );
- pIpkg->setPackage( it->packageName );
+ idata = it.current();
+ pIpkg->setDestination( idata->destination->getDestinationName() );
+ pIpkg->setDestinationDir( idata->destination->getDestinationPath() );
+ pIpkg->setPackage( idata->packageName );
int tmpFlags = flags;
- if ( it->destination->linkToRoot() )
+ if ( idata->destination->linkToRoot() )
tmpFlags |= MAKE_LINKS;
@@ -268,23 +276,26 @@ void InstallDlgImpl :: installSelected()
pIpkg->setDestinationDir( destDir );
pIpkg->setFlags( instFlags );
- for ( it = installList.begin() ; it != installList.end() ; ++it )
+ QListIterator<InstallData> it2( installList );
+ for ( ; it2.current(); ++it2 )
{
- pIpkg->setPackage( it->packageName );
+ pIpkg->setPackage( it2.current()->packageName );
pIpkg->runIpkg();
}
flags |= FORCE_REINSTALL;
- for ( it = updateList.begin() ; it != updateList.end() ; ++it )
+ QListIterator<InstallData> it3( updateList );
+ for ( ; it3.current() ; ++it3 )
{
- if ( it->option == "R" )
+ idata = it3.current();
+ if ( idata->option == "R" )
pIpkg->setOption( "reinstall" );
else
pIpkg->setOption( "upgrade" );
- pIpkg->setDestination( it->destination->getDestinationName() );
- pIpkg->setDestinationDir( it->destination->getDestinationPath() );
- pIpkg->setPackage( it->packageName );
+ pIpkg->setDestination( idata->destination->getDestinationName() );
+ pIpkg->setDestinationDir( idata->destination->getDestinationPath() );
+ pIpkg->setPackage( idata->packageName );
int tmpFlags = flags;
- if ( it->destination->linkToRoot() && it->recreateLinks )
+ if ( idata->destination->linkToRoot() && idata->recreateLinks )
tmpFlags |= MAKE_LINKS;
pIpkg->setFlags( tmpFlags );
@@ -308,5 +319,4 @@ void InstallDlgImpl :: installSelected()
void InstallDlgImpl :: displayText(const QString &text )
{
- //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 );
@@ -317,5 +327,5 @@ void InstallDlgImpl :: displayText(const QString &text )
void InstallDlgImpl :: displayAvailableSpace( const QString &text )
{
- vector<Destination>::iterator d = dataMgr->getDestination( text );
+ Destination *d = dataMgr->getDestination( text );
QString destDir = d->getDestinationPath();
diff --git a/noncore/settings/aqpkg/installdlgimpl.h b/noncore/settings/aqpkg/installdlgimpl.h
index 4c9f087..d7509bb 100644
--- a/noncore/settings/aqpkg/installdlgimpl.h
+++ b/noncore/settings/aqpkg/installdlgimpl.h
@@ -18,9 +18,9 @@
#define INSTALLDLGIMPL_H
-#include <vector>
using namespace std;
-#include <qwidget.h>
+#include <qlist.h>
#include <qstring.h>
+#include <qwidget.h>
class QComboBox;
@@ -46,5 +46,5 @@ class InstallDlgImpl : public QWidget
Q_OBJECT
public:
- InstallDlgImpl( vector<InstallData> &packageList, DataManager *dataManager, const char *title = 0 );
+ InstallDlgImpl( QList<InstallData> &packageList, DataManager *dataManager, const char *title = 0 );
InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title = 0 );
~InstallDlgImpl();
@@ -56,7 +56,7 @@ protected:
private:
DataManager *dataMgr;
- vector<InstallData> installList;
- vector<InstallData> removeList;
- vector<InstallData> updateList;
+ QList<InstallData> installList;
+ QList<InstallData> removeList;
+ QList<InstallData> updateList;
int flags;
Ipkg *pIpkg;
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp
index 361946c..8ae5815 100644
--- a/noncore/settings/aqpkg/mainwin.cpp
+++ b/noncore/settings/aqpkg/mainwin.cpp
@@ -544,16 +544,20 @@ void MainWindow :: updateProgress( int progress )
void MainWindow :: updateData()
{
- m_progress->setTotalSteps( mgr->getServerList().size() );
+ m_progress->setTotalSteps( mgr->getServerList().count() );
serversList->clear();
packagesList->clear();
- vector<Server>::iterator it;
int activeItem = -1;
- int i;
+ int i = 0;
QString serverName;
- for ( i = 0, it = mgr->getServerList().begin() ; it != mgr->getServerList().end() ; ++it, ++i )
+
+ QListIterator<Server> it( mgr->getServerList() );
+ Server *server;
+
+ for ( ; it.current(); ++it, ++i )
{
- serverName = it->getServerName();
+ server = it.current();
+ serverName = server->getServerName();
m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) );
m_progress->setProgress( i );
@@ -561,5 +565,5 @@ void MainWindow :: updateData()
// cout << "Adding " << it->getServerName() << " to combobox" << endl;
- if ( !it->isServerActive() )
+ if ( !server->isServerActive() )
{
// cout << serverName << " is not active" << endl;
@@ -593,11 +597,11 @@ void MainWindow :: serverSelected( int, bool raiseProgress )
currentlySelectedServer = serverName;
- vector<Server>::iterator s = mgr->getServer( serverName );
+ Server *s = mgr->getServer( serverName );
- vector<Package> &list = s->getPackageList();
- vector<Package>::iterator it;
+ QList<Package> &list = s->getPackageList();
+ QListIterator<Package> it( list );
// Display progress widget while loading list
- bool doProgress = ( list.size() > 200 );
+ bool doProgress = ( list.count() > 200 );
if ( doProgress )
{
@@ -606,5 +610,5 @@ void MainWindow :: serverSelected( int, bool raiseProgress )
stack->raiseWidget( progressWindow );
}
- m_progress->setTotalSteps( list.size() );
+ m_progress->setTotalSteps( list.count() );
m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) );
}
@@ -620,5 +624,6 @@ void MainWindow :: serverSelected( int, bool raiseProgress )
int i = 0;
- for ( it = list.begin() ; it != list.end() ; ++it )
+ Package *package;
+ for ( ; it.current(); ++it )
{
// Update progress after every 100th package (arbitrary value, seems to give good balance)
@@ -634,11 +639,13 @@ void MainWindow :: serverSelected( int, bool raiseProgress )
QString text = "";
+
+ package = it.current();
// Apply show only uninstalled packages filter
- if ( showUninstalledPkgs && it->isInstalled() )
+ if ( showUninstalledPkgs && package->isInstalled() )
continue;
// Apply show only installed packages filter
- if ( showInstalledPkgs && !it->isInstalled() )
+ if ( showInstalledPkgs && !package->isInstalled() )
continue;
@@ -646,6 +653,6 @@ void MainWindow :: serverSelected( int, bool raiseProgress )
if ( showUpgradedPkgs )
{
- if ( !it->isInstalled() ||
- compareVersions( it->getInstalledVersion(), it->getVersion() ) != 1 )
+ if ( !package->isInstalled() ||
+ compareVersions( package->getInstalledVersion(), package->getVersion() ) != 1 )
continue;
}
@@ -654,21 +661,22 @@ void MainWindow :: serverSelected( int, bool raiseProgress )
if ( categoryFilterEnabled && categoryFilter != "" )
{
- if ( it->getSection() == "" || categoryFilter.find( it->getSection().lower() ) == -1 )
+ if ( package->getSection() == "" || categoryFilter.find( package->getSection().lower() ) == -1 )
continue;
}
// If the local server, only display installed packages
- if ( serverName == LOCAL_SERVER && !it->isInstalled() )
+ if ( serverName == LOCAL_SERVER && !package->isInstalled() )
continue;
- QCheckListItem *item = new QCheckListItem( packagesList, it->getPackageName(), QCheckListItem::CheckBox );
+ QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(),
+ QCheckListItem::CheckBox );
- if ( it->isInstalled() )
+ if ( package->isInstalled() )
{
// If a different version of package is available, show update available icon
// Otherwise, show installed icon
- if ( it->getVersion() != it->getInstalledVersion() &&
- compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1)
+ if ( package->getVersion() != package->getInstalledVersion() &&
+ compareVersions( package->getInstalledVersion(), package->getVersion() ) == 1)
{
@@ -681,13 +689,13 @@ void MainWindow :: serverSelected( int, bool raiseProgress )
QString destName = "";
- if ( it->getLocalPackage() )
+ if ( package->getLocalPackage() )
{
- if ( it->getLocalPackage()->getInstalledTo() )
- destName = it->getLocalPackage()->getInstalledTo()->getDestinationName();
+ if ( package->getLocalPackage()->getInstalledTo() )
+ destName = package->getLocalPackage()->getInstalledTo()->getDestinationName();
}
else
{
- if ( it->getInstalledTo() )
- destName = it->getInstalledTo()->getDestinationName();
+ if ( package->getInstalledTo() )
+ destName = package->getInstalledTo()->getDestinationName();
}
if ( destName != "" )
@@ -699,24 +707,24 @@ void MainWindow :: serverSelected( int, bool raiseProgress )
}
- if ( !it->isPackageStoredLocally() )
+ if ( !package->isPackageStoredLocally() )
{
- new QCheckListItem( item, QString( tr( "Description - %1" ).arg( it->getDescription() ) ) );
- new QCheckListItem( item, QString( tr( "Size - %1" ).arg( it->getPackageSize() ) ) );
- new QCheckListItem( item, QString( tr( "Section - %1" ).arg( it->getSection() ) ) );
+ new QCheckListItem( item, QString( tr( "Description - %1" ).arg( package->getDescription() ) ) );
+ new QCheckListItem( item, QString( tr( "Size - %1" ).arg( package->getPackageSize() ) ) );
+ new QCheckListItem( item, QString( tr( "Section - %1" ).arg( package->getSection() ) ) );
}
else
- new QCheckListItem( item, QString( tr( "Filename - %1" ).arg( it->getFilename() ) ) );
+ new QCheckListItem( item, QString( tr( "Filename - %1" ).arg( package->getFilename() ) ) );
if ( serverName == LOCAL_SERVER )
{
- new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( it->getVersion() ) ) );
+ new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( package->getVersion() ) ) );
}
else
{
- new QCheckListItem( item, QString( tr( "V. Available - %1" ).arg( it->getVersion() ) ) );
- if ( it->getLocalPackage() )
+ new QCheckListItem( item, QString( tr( "V. Available - %1" ).arg( package->getVersion() ) ) );
+ if ( package->getLocalPackage() )
{
- if ( it->isInstalled() )
- new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( it->getInstalledVersion() ) ) );
+ if ( package->isInstalled() )
+ new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( package->getInstalledVersion() ) ) );
}
}
@@ -756,5 +764,5 @@ void MainWindow :: searchForPackage( const QString &text )
// cout << "searching for " << text << endl;
// look through package list for text startng at current position
- vector<InstallData> workingPackages;
+// vector<InstallData> workingPackages;
QCheckListItem *start = (QCheckListItem *)packagesList->currentItem();
// if ( start != 0 )
@@ -958,9 +966,10 @@ void MainWindow :: downloadRemotePackage()
// QString package = dlg.getPackageLocation();
- InstallData item;
- item.option = "I";
- item.packageName = package;
- vector<InstallData> workingPackages;
- workingPackages.push_back( item );
+ InstallData *item = new InstallData();
+ item->option = "I";
+ item->packageName = package;
+ QList<InstallData> workingPackages;
+ workingPackages.setAutoDelete( TRUE );
+ workingPackages.append( item );
InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) );
@@ -980,5 +989,6 @@ void MainWindow :: applyChanges()
// deal with it
- vector<InstallData> workingPackages;
+ QList<InstallData> workingPackages;
+ workingPackages.setAutoDelete( TRUE );
for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
item != 0 ;
@@ -987,10 +997,9 @@ void MainWindow :: applyChanges()
if ( item->isOn() )
{
- InstallData data = dealWithItem( item );
- workingPackages.push_back( data );
+ workingPackages.append( dealWithItem( item ) );
}
}
- if ( workingPackages.size() == 0 )
+ if ( workingPackages.count() == 0 )
{
// Nothing to do
@@ -1012,10 +1021,10 @@ void MainWindow :: applyChanges()
// If installed and different version available - upgrade
// If installed and version up to date - remove
-InstallData MainWindow :: dealWithItem( QCheckListItem *item )
+InstallData *MainWindow :: dealWithItem( QCheckListItem *item )
{
QString name = item->text();
// Get package
- vector<Server>::iterator s = mgr->getServer( serversList->currentText() );
+ Server *s = mgr->getServer( serversList->currentText() );
Package *p = s->getPackage( name );
@@ -1028,21 +1037,21 @@ InstallData MainWindow :: dealWithItem( QCheckListItem *item )
if ( !p->isInstalled() )
{
- InstallData item;
- item.option = "I";
- item.packageName = name;
- return item;
+ InstallData *newitem = new InstallData();;
+ newitem->option = "I";
+ newitem->packageName = name;
+ return newitem;
}
else
{
- InstallData item;
- item.option = "D";
+ InstallData *newitem = new InstallData();;
+ newitem->option = "D";
if ( !p->isPackageStoredLocally() )
- item.packageName = p->getInstalledPackageName();
+ newitem->packageName = p->getInstalledPackageName();
else
- item.packageName = name;
+ newitem->packageName = name;
if ( p->getInstalledTo() )
{
- item.destination = p->getInstalledTo();
+ newitem->destination = p->getInstalledTo();
// cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl;
// cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl;
@@ -1050,5 +1059,5 @@ InstallData MainWindow :: dealWithItem( QCheckListItem *item )
else
{
- item.destination = p->getLocalPackage()->getInstalledTo();
+ newitem->destination = p->getLocalPackage()->getInstalledTo();
}
@@ -1067,5 +1076,5 @@ InstallData MainWindow :: dealWithItem( QCheckListItem *item )
{
// Version available is older - remove only
- item.option = "D";
+ newitem->option = "D";
}
else
@@ -1103,8 +1112,8 @@ InstallData MainWindow :: dealWithItem( QCheckListItem *item )
case 0: // Try again or Enter
// option 0 = Remove
- item.option = "D";
+ newitem->option = "D";
break;
case 1: // Quit or Escape
- item.option = secondOption;
+ newitem->option = secondOption;
break;
}
@@ -1112,5 +1121,5 @@ InstallData MainWindow :: dealWithItem( QCheckListItem *item )
else
{
-// item.option = stickyOption;
+// newitem->option = stickyOption;
}
}
@@ -1118,11 +1127,11 @@ InstallData MainWindow :: dealWithItem( QCheckListItem *item )
// Check if we are reinstalling the same version
- if ( item.option != "R" )
- item.recreateLinks = true;
+ if ( newitem->option != "R" )
+ newitem->recreateLinks = true;
else
- item.recreateLinks = false;
+ newitem->recreateLinks = false;
// User hit cancel (on dlg - assume remove)
- return item;
+ return newitem;
}
}
diff --git a/noncore/settings/aqpkg/mainwin.h b/noncore/settings/aqpkg/mainwin.h
index d0777fb..db06e16 100644
--- a/noncore/settings/aqpkg/mainwin.h
+++ b/noncore/settings/aqpkg/mainwin.h
@@ -93,5 +93,5 @@ private:
void downloadSelectedPackages();
void downloadRemotePackage();
- InstallData dealWithItem( QCheckListItem *item );
+ InstallData *dealWithItem( QCheckListItem *item );
// Progress widget
diff --git a/noncore/settings/aqpkg/server.cpp b/noncore/settings/aqpkg/server.cpp
index fc5ed12..04f5ab7 100644
--- a/noncore/settings/aqpkg/server.cpp
+++ b/noncore/settings/aqpkg/server.cpp
@@ -60,15 +60,17 @@ void Server :: cleanUp()
}
-void Server :: readStatusFile( vector<Destination> &destList )
+void Server :: readStatusFile( QList<Destination> &destList )
{
cleanUp();
- vector<Destination>::iterator dit;
+ Destination *dest;
+ QListIterator<Destination> dit( destList );
bool rootRead = false;
- for ( dit = destList.begin() ; dit != destList.end() ; ++dit )
+ for ( ; dit.current(); ++dit )
{
+ dest = dit.current();
bool installingToRoot = false;
- QString path = dit->getDestinationPath();
+ QString path = dest->getDestinationPath();
if ( path.right( 1 ) != "/" )
path += "/";
@@ -81,5 +83,5 @@ void Server :: readStatusFile( vector<Destination> &destList )
packageFile = path + "usr/lib/ipkg/status";
- readPackageFile( 0, false, installingToRoot, &( *dit ) );
+ readPackageFile( 0, false, installingToRoot, &( *dest ) );
}
@@ -116,10 +118,10 @@ void Server :: readLocalIpks( Server *local )
QString packageName = Utils::getFilenameFromIpkFilename( file );
QString ver = Utils::getPackageVersionFromIpkFilename( file );
- packageList.push_back( Package( packageName ) );
- packageList.back().setVersion( ver );
- packageList.back().setFilename( file );
- packageList.back().setPackageStoredLocally( true );
-
- }
+ Package *package = new Package( packageName );
+ package->setVersion( ver );
+ package->setFilename( file );
+ package->setPackageStoredLocally( true );
+ packageList.append( package );
+ }
#else
QString names[] = { "advancedfm_0.9.1-20020811_arm.ipk", "libopie_0.9.1-20020811_arm.ipk", "libopieobex_0.9.1-20020811.1_arm.ipk", "opie-addressbook_0.9.1-20020811_arm.ipk" };
@@ -181,8 +183,8 @@ void Server :: readPackageFile( Server *local, bool clearAll, bool installingToR
if ( !currPackage )
{
- packageList.push_back( Package( value ) );
- currPackage = &(packageList.back());
+ Package *package = new Package( value );
+ packageList.append( package );
+ currPackage = package;
currPackage->setInstalledTo( dest );
-
if ( installingToRoot )
currPackage->setInstalledToRoot( true );
@@ -240,24 +242,27 @@ void Server :: readPackageFile( Server *local, bool clearAll, bool installingToR
void Server :: buildLocalPackages( Server *local )
{
- for ( unsigned int i = 0 ; i < packageList.size() ; ++i )
+ Package *curr;
+ QListIterator<Package> it( packageList );
+ for ( ; it.current(); ++it )
{
- QString name = packageList[i].getPackageName();
+ curr = it.current();
+ QString name = curr->getPackageName();
// If the package name is an ipk name, then convert the filename to a package name
if ( name.find( ".ipk" ) != -1 )
- name = Utils::getPackageNameFromIpkFilename( packageList[i].getFilename() );
+ name = Utils::getPackageNameFromIpkFilename( curr->getFilename() );
if ( local )
{
Package *p = local->getPackage( name );
- packageList[i].setLocalPackage( p );
+ curr->setLocalPackage( p );
if ( p )
{
// Set some default stuff like size and things
- if ( p->getInstalledVersion() == packageList[i].getVersion() )
+ if ( p->getInstalledVersion() == curr->getVersion() )
{
- p->setPackageSize( packageList[i].getPackageSize() );
- p->setSection( packageList[i].getSection() );
- p->setDescription( packageList[i].getDescription() );
+ p->setPackageSize( curr->getPackageSize() );
+ p->setSection( curr->getSection() );
+ p->setDescription( curr->getDescription() );
}
}
@@ -265,5 +270,5 @@ void Server :: buildLocalPackages( Server *local )
}
else
- packageList[i].setLocalPackage( 0 );
+ curr->setLocalPackage( 0 );
}
@@ -279,9 +284,10 @@ Package *Server :: getPackage( const char *name )
Package *ret = 0;
- for ( unsigned int i = 0 ; i < packageList.size() && ret == 0; ++i )
+ QListIterator<Package> it( packageList );
+ for ( ; it.current(); ++it )
{
- if ( packageList[i].getPackageName() == name )
- ret = &packageList[i];
- }
+ if ( it.current()->getPackageName() == name )
+ ret = it.current();
+ }
return ret;
@@ -290,10 +296,11 @@ Package *Server :: getPackage( const char *name )
QString Server :: toString()
{
- QString ret = "Server\n name - " + serverName +
- "\n url - " + serverUrl +
- "\n";
-
- for ( unsigned int i = 0 ; i < packageList.size() ; ++i )
- ret += "\n " + packageList[i].toString();
+ QString ret = QString( "Server\n name - %1\n url - %2\n" ).arg( serverName ).arg( serverUrl );
+
+ QListIterator<Package> it( packageList );
+ for ( ; it.current(); ++it )
+ {
+ ret.append( QString( "\n %1" ).arg( it.current()->toString() ) );
+ }
@@ -301,5 +308,5 @@ QString Server :: toString()
}
-vector<Package> &Server::getPackageList()
+QList<Package> &Server::getPackageList()
{
return packageList;
diff --git a/noncore/settings/aqpkg/server.h b/noncore/settings/aqpkg/server.h
index f585b8f..02746e0 100644
--- a/noncore/settings/aqpkg/server.h
+++ b/noncore/settings/aqpkg/server.h
@@ -18,7 +18,7 @@
#define SERVER_H
+#include <qlist.h>
#include <qstring.h>
-#include <vector>
using namespace std;
@@ -36,5 +36,5 @@ public:
void cleanUp();
- void readStatusFile( vector<Destination> &v );
+ void readStatusFile( QList<Destination> &v );
void readLocalIpks( Server *local );
void readPackageFile( Server *local = 0, bool clearAll = true, bool installedToRoot= false, Destination *dest = 0 );
@@ -43,5 +43,5 @@ public:
Package *getPackage( QString &name );
QString toString();
- vector<Package> &getPackageList();
+ QList<Package> &getPackageList();
bool isServerActive() { return active; }
@@ -61,5 +61,5 @@ private:
- vector<Package> packageList;
+ QList<Package> packageList;
};
diff --git a/noncore/settings/aqpkg/settingsimpl.cpp b/noncore/settings/aqpkg/settingsimpl.cpp
index c5a55d2..7541f0b 100644
--- a/noncore/settings/aqpkg/settingsimpl.cpp
+++ b/noncore/settings/aqpkg/settingsimpl.cpp
@@ -255,18 +255,20 @@ void SettingsImpl :: setupData()
{
// add servers
- vector<Server>::iterator it;
- for ( it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it )
+ QString serverName;
+ QListIterator<Server> it( dataMgr->getServerList() );
+ for ( ; it.current(); ++it )
{
- if ( it->getServerName() == LOCAL_SERVER || it->getServerName() == LOCAL_IPKGS )
+ serverName = it.current()->getServerName();
+ if ( serverName == LOCAL_SERVER || serverName == LOCAL_IPKGS )
continue;
- servers->insertItem( it->getServerName() );
+ servers->insertItem( serverName );
}
// add destinations
- vector<Destination>::iterator it2;
- for ( it2 = dataMgr->getDestinationList().begin() ; it2 != dataMgr->getDestinationList().end() ; ++it2 )
- destinations->insertItem( it2->getDestinationName() );
+ QListIterator<Destination> it2( dataMgr->getDestinationList() );
+ for ( ; it2.current(); ++it2 )
+ destinations->insertItem( it2.current()->getDestinationName() );
// setup proxy tab
@@ -284,5 +286,5 @@ void SettingsImpl :: editServer( int sel )
{
currentSelectedServer = sel;
- vector<Server>::iterator s = dataMgr->getServer( servers->currentText() );
+ Server *s = dataMgr->getServer( servers->currentText() );
serverName = s->getServerName();
servername->setText( s->getServerName() );
@@ -303,6 +305,6 @@ void SettingsImpl :: removeServer()
{
changed = true;
- vector<Server>::iterator s = dataMgr->getServer( servers->currentText() );
- dataMgr->getServerList().erase( s );
+ Server *s = dataMgr->getServer( servers->currentText() );
+ dataMgr->getServerList().removeRef( s );
servers->removeItem( currentSelectedServer );
}
@@ -315,5 +317,5 @@ void SettingsImpl :: changeServerDetails()
if ( !newserver )
{
- vector<Server>::iterator s = dataMgr->getServer( servers->currentText() );
+ Server *s = dataMgr->getServer( servers->currentText() );
// Update url
@@ -339,6 +341,6 @@ void SettingsImpl :: changeServerDetails()
{
Server s( newName, serverurl->text() );
- dataMgr->getServerList().push_back( Server( newName, serverurl->text() ) );
- dataMgr->getServerList().end()->setActive( active->isChecked() );
+ dataMgr->getServerList().append( new Server( newName, serverurl->text() ) );
+ dataMgr->getServerList().last()->setActive( active->isChecked() );
servers->insertItem( newName );
servers->setCurrentItem( servers->count() );
@@ -352,5 +354,5 @@ void SettingsImpl :: editDestination( int sel )
{
currentSelectedDestination = sel;
- vector<Destination>::iterator d = dataMgr->getDestination( destinations->currentText() );
+ Destination *d = dataMgr->getDestination( destinations->currentText() );
destinationName = d->getDestinationName();
destinationname->setText( d->getDestinationName() );
@@ -371,6 +373,6 @@ void SettingsImpl :: removeDestination()
{
changed = true;
- vector<Destination>::iterator d = dataMgr->getDestination( destinations->currentText() );
- dataMgr->getDestinationList().erase( d );
+ Destination *d = dataMgr->getDestination( destinations->currentText() );
+ dataMgr->getDestinationList().removeRef( d );
destinations->removeItem( currentSelectedDestination );
}
@@ -388,5 +390,5 @@ void SettingsImpl :: changeDestinationDetails()
if ( !newdestination )
{
- vector<Destination>::iterator d = dataMgr->getDestination( destinations->currentText() );
+ Destination *d = dataMgr->getDestination( destinations->currentText() );
// Update url
@@ -412,5 +414,5 @@ void SettingsImpl :: changeDestinationDetails()
else
{
- dataMgr->getDestinationList().push_back( Destination( newName, destinationurl->text() ) );
+ dataMgr->getDestinationList().append( new Destination( newName, destinationurl->text() ) );
destinations->insertItem( newName );
destinations->setCurrentItem( destinations->count() );