summaryrefslogtreecommitdiff
path: root/noncore/unsupported/oipkg/packagelist.cpp
Unidiff
Diffstat (limited to 'noncore/unsupported/oipkg/packagelist.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/oipkg/packagelist.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/noncore/unsupported/oipkg/packagelist.cpp b/noncore/unsupported/oipkg/packagelist.cpp
index 2fc4c41..fdd1163 100644
--- a/noncore/unsupported/oipkg/packagelist.cpp
+++ b/noncore/unsupported/oipkg/packagelist.cpp
@@ -1,66 +1,69 @@
1#include "packagelist.h" 1#include "packagelist.h"
2 2
3#include <assert.h> 3#include <assert.h>
4#include <qfile.h> 4#include <qfile.h>
5#include <qfileinfo.h> 5#include <qfileinfo.h>
6#include <qtextstream.h> 6#include <qtextstream.h>
7 7
8#include "debug.h" 8#include "debug.h"
9 9
10static QDict<Package> *packageListAll; 10static QDict<Package> *packageListAll;
11static int packageListAllRefCount = 0;
11 12
12PackageList::PackageList() 13PackageList::PackageList()
13 : packageIter( packageList ) 14 : packageIter( packageList )
14{ 15{
15 empty=true; 16 empty=true;
16 if (!packageListAll) packageListAll = new QDict<Package>(); 17 if (!packageListAll) packageListAll = new QDict<Package>();
18 packageListAllRefCount++;
17 sections << "All"; 19 sections << "All";
18 subSections.insert("All", new QStringList() ); 20 subSections.insert("All", new QStringList() );
19 QStringList *ss = subSections["All"]; 21 QStringList *ss = subSections["All"];
20 *ss << "All"; 22 *ss << "All";
21 aktSection = "All"; 23 aktSection = "All";
22 aktSubSection = "All"; 24 aktSubSection = "All";
23} 25}
24 26
25PackageList::PackageList( PackageManagerSettings* s) 27PackageList::PackageList( PackageManagerSettings* s)
26 : packageIter( packageList ) 28 : packageIter( packageList )
27{ 29{
28 settings = s; 30 settings = s;
29 PackageList(); 31 PackageList();
30} 32}
31 33
32PackageList::~PackageList() 34PackageList::~PackageList()
33{ 35{
36 if (--packageListAllRefCount < 1 ) delete packageListAll;
34} 37}
35 38
36/** Inserts a package into the list */ 39/** Inserts a package into the list */
37void PackageList::insertPackage( Package* pack ) 40void PackageList::insertPackage( Package* pack )
38{ 41{
39 if (!pack) return; 42 if (!pack) return;
40 Package* p = packageListAll->find( pack->name() ); 43 Package* p = packageListAll->find( pack->name() );
41 if ( p ) 44 if ( p )
42 { 45 {
43 if ( (p->version() == pack->version()) 46 if ( (p->version() == pack->version())
44 && (p->dest() == pack->dest()) ) 47 && (p->dest() == pack->dest()) )
45 { 48 {
46 p->copyValues( pack ); 49 p->copyValues( pack );
47 delete pack; 50 delete pack;
48 pack = p; 51 pack = p;
49 } else { 52 } else {
50 QDict<Package> *packver = p->getOtherVersions(); 53 QDict<Package> *packver = p->getOtherVersions();
51 // p->setName( pack->name()+"["+p->version()+"]" ); 54 // p->setName( pack->name()+"["+p->version()+"]" );
52 if (!packver) 55 if (!packver)
53 { 56 {
54 packver = new QDict<Package>; 57 packver = new QDict<Package>();
55 packver->insert( pack->name(), p ); 58 packver->insert( pack->name(), p );
56 p->setOtherVersions( packver ); 59 p->setOtherVersions( packver );
57 } 60 }
58 pack->setName( pack->name()+"["+pack->version()+"]" ); 61 pack->setName( pack->name()+"["+pack->version()+"]" );
59 pack->setOtherVersions( packver ); 62 pack->setOtherVersions( packver );
60 packver->insert( pack->name(), pack ); 63 packver->insert( pack->name(), pack );
61 packageListAll->insert( pack->name(), pack ); 64 packageListAll->insert( pack->name(), pack );
62 packageList.insert( pack->name(), pack ); 65 packageList.insert( pack->name(), pack );
63 origPackageList.insert( pack->name(), pack ); 66 origPackageList.insert( pack->name(), pack );
64 } 67 }
65 }else{ 68 }else{
66 packageListAll->insert( pack->name(), pack ); 69 packageListAll->insert( pack->name(), pack );
@@ -173,24 +176,25 @@ void PackageList::readFileEntries( QString filename, QString dest )
173 Package *p = new Package( packEntry, settings ); 176 Package *p = new Package( packEntry, settings );
174 p->setDest( dest ); 177 p->setDest( dest );
175 if ( p ) 178 if ( p )
176 { 179 {
177 insertPackage( p ); 180 insertPackage( p );
178 packEntry.clear(); 181 packEntry.clear();
179 } 182 }
180 } 183 }
181 }else{ 184 }else{
182 packEntry << line; 185 packEntry << line;
183 }; 186 };
184 } 187 }
188 delete statusStream;
185 return; 189 return;
186} 190}
187 191
188void PackageList::setSettings( PackageManagerSettings *s ) 192void PackageList::setSettings( PackageManagerSettings *s )
189{ 193{
190 settings = s; 194 settings = s;
191} 195}
192 196
193Package* PackageList::getByName( QString n ) 197Package* PackageList::getByName( QString n )
194{ 198{
195 origPackageList[n]; 199 origPackageList[n];
196} 200}