summaryrefslogtreecommitdiff
authortille <tille>2002-05-12 13:29:15 (UTC)
committer tille <tille>2002-05-12 13:29:15 (UTC)
commit0ee7616dae861e140b0a68b9f04e39f3217b4711 (patch) (unidiff)
tree852465b35c894df05c00c5039886cf36696978b4
parent98229e01acc37562671b546a8aa955415a0f5843 (diff)
downloadopie-0ee7616dae861e140b0a68b9f04e39f3217b4711.zip
opie-0ee7616dae861e140b0a68b9f04e39f3217b4711.tar.gz
opie-0ee7616dae861e140b0a68b9f04e39f3217b4711.tar.bz2
removed dups
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/oipkg/packagelist.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/noncore/unsupported/oipkg/packagelist.cpp b/noncore/unsupported/oipkg/packagelist.cpp
index fdd1163..8f835b7 100644
--- a/noncore/unsupported/oipkg/packagelist.cpp
+++ b/noncore/unsupported/oipkg/packagelist.cpp
@@ -1,175 +1,176 @@
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; 11static int packageListAllRefCount = 0;
12 12
13PackageList::PackageList() 13PackageList::PackageList()
14 : packageIter( packageList ) 14 : packageIter( packageList )
15{ 15{
16 empty=true; 16 empty=true;
17 if (!packageListAll) packageListAll = new QDict<Package>(); 17 if (!packageListAll) packageListAll = new QDict<Package>();
18 packageListAllRefCount++; 18 packageListAllRefCount++;
19 sections << "All"; 19 sections << "All";
20 subSections.insert("All", new QStringList() ); 20 subSections.insert("All", new QStringList() );
21 QStringList *ss = subSections["All"]; 21 QStringList *ss = subSections["All"];
22 *ss << "All"; 22 *ss << "All";
23 aktSection = "All"; 23 aktSection = "All";
24 aktSubSection = "All"; 24 aktSubSection = "All";
25} 25}
26 26
27PackageList::PackageList( PackageManagerSettings* s) 27PackageList::PackageList( PackageManagerSettings* s)
28 : packageIter( packageList ) 28 : packageIter( packageList )
29{ 29{
30 settings = s; 30 settings = s;
31 PackageList(); 31 PackageList();
32} 32}
33 33
34PackageList::~PackageList() 34PackageList::~PackageList()
35{ 35{
36 if (--packageListAllRefCount < 1 ) delete packageListAll; 36 if (--packageListAllRefCount < 1 ) delete packageListAll;
37} 37}
38 38
39/** Inserts a package into the list */ 39/** Inserts a package into the list */
40void PackageList::insertPackage( Package* pack ) 40void PackageList::insertPackage( Package* pack )
41{ 41{
42 if (!pack) return; 42 if (!pack) return;
43 Package* p = packageListAll->find( pack->name() ); 43 Package* p = packageListAll->find( pack->name() );
44 if ( p ) 44 if ( p )
45 { 45 {
46 if ( (p->version() == pack->version()) 46 if ( (p->version() == pack->version())
47 && (p->dest() == pack->dest()) ) 47 // && (p->dest() == pack->dest())
48 )
48 { 49 {
49 p->copyValues( pack ); 50 p->copyValues( pack );
50 delete pack; 51 delete pack;
51 pack = p; 52 pack = p;
52 } else { 53 } else {
53 QDict<Package> *packver = p->getOtherVersions(); 54 QDict<Package> *packver = p->getOtherVersions();
54 // p->setName( pack->name()+"["+p->version()+"]" ); 55 // p->setName( pack->name()+"["+p->version()+"]" );
55 if (!packver) 56 if (!packver)
56 { 57 {
57 packver = new QDict<Package>(); 58 packver = new QDict<Package>();
58 packver->insert( pack->name(), p ); 59 packver->insert( pack->name(), p );
59 p->setOtherVersions( packver ); 60 p->setOtherVersions( packver );
60 } 61 }
61 pack->setName( pack->name()+"["+pack->version()+"]" ); 62 pack->setName( pack->name()+"["+pack->version()+"]" );
62 pack->setOtherVersions( packver ); 63 pack->setOtherVersions( packver );
63 packver->insert( pack->name(), pack ); 64 packver->insert( pack->name(), pack );
64 packageListAll->insert( pack->name(), pack ); 65 packageListAll->insert( pack->name(), pack );
65 packageList.insert( pack->name(), pack ); 66 packageList.insert( pack->name(), pack );
66 origPackageList.insert( pack->name(), pack ); 67 origPackageList.insert( pack->name(), pack );
67 } 68 }
68 }else{ 69 }else{
69 packageListAll->insert( pack->name(), pack ); 70 packageListAll->insert( pack->name(), pack );
70 packageList.insert( pack->name(), pack ); 71 packageList.insert( pack->name(), pack );
71 origPackageList.insert( pack->name(), pack ); 72 origPackageList.insert( pack->name(), pack );
72 }; 73 };
73 empty=false; 74 empty=false;
74 updateSections( pack ); 75 updateSections( pack );
75} 76}
76 77
77void PackageList::filterPackages( QString f ) 78void PackageList::filterPackages( QString f )
78 { 79 {
79 packageList.clear(); 80 packageList.clear();
80 QDictIterator<Package> filterIter( origPackageList ); 81 QDictIterator<Package> filterIter( origPackageList );
81 filterIter.toFirst(); 82 filterIter.toFirst();
82 Package *pack= filterIter.current() ; 83 Package *pack= filterIter.current() ;
83 while ( pack ) 84 while ( pack )
84 { 85 {
85 if ( 86 if (
86 ((aktSection=="All")||(pack->section()==aktSection)) && 87 ((aktSection=="All")||(pack->section()==aktSection)) &&
87 ((aktSubSection=="All")||(pack->subSection()==aktSubSection)) && 88 ((aktSubSection=="All")||(pack->subSection()==aktSubSection)) &&
88 pack->name().contains( f ) 89 pack->name().contains( f )
89 ) 90 )
90 { 91 {
91 packageList.insert( pack->name(), pack ); 92 packageList.insert( pack->name(), pack );
92 } 93 }
93 ++filterIter; 94 ++filterIter;
94 pack = filterIter.current(); 95 pack = filterIter.current();
95 } 96 }
96} 97}
97 98
98Package* PackageList::find( QString n ) 99Package* PackageList::find( QString n )
99{ 100{
100 return packageList.find( n ); 101 return packageList.find( n );
101} 102}
102 103
103Package* PackageList::first() 104Package* PackageList::first()
104 { 105 {
105 packageIter.toFirst(); 106 packageIter.toFirst();
106 return packageIter.current(); 107 return packageIter.current();
107} 108}
108 109
109Package* PackageList::next() 110Package* PackageList::next()
110{ 111{
111 ++packageIter; 112 ++packageIter;
112 return packageIter.current(); 113 return packageIter.current();
113} 114}
114 115
115QStringList PackageList::getSections() 116QStringList PackageList::getSections()
116{ 117{
117 sections.sort(); 118 sections.sort();
118 return sections; 119 return sections;
119} 120}
120 121
121QStringList PackageList::getSubSections() 122QStringList PackageList::getSubSections()
122{ 123{
123 QStringList ss; 124 QStringList ss;
124 if ( !subSections[aktSection] ) return ss; 125 if ( !subSections[aktSection] ) return ss;
125 ss = *subSections[aktSection]; 126 ss = *subSections[aktSection];
126 ss.sort(); 127 ss.sort();
127 return ss; 128 return ss;
128} 129}
129 130
130void PackageList::setSection( QString sec ) 131void PackageList::setSection( QString sec )
131{ 132{
132 aktSection = sec; 133 aktSection = sec;
133} 134}
134 135
135void PackageList::setSubSection( QString ssec ) 136void PackageList::setSubSection( QString ssec )
136{ 137{
137 aktSubSection = ssec; 138 aktSubSection = ssec;
138} 139}
139 140
140void PackageList::updateSections( Package* pack ) 141void PackageList::updateSections( Package* pack )
141{ 142{
142 QString s = pack->section(); 143 QString s = pack->section();
143 if ( s.isEmpty() || s == "") return; 144 if ( s.isEmpty() || s == "") return;
144 if ( sections.contains(s) ) return; 145 if ( sections.contains(s) ) return;
145 sections += s; 146 sections += s;
146 QString ss = pack->subSection(); 147 QString ss = pack->subSection();
147 if ( ss.isEmpty() || ss == "" ) return; 148 if ( ss.isEmpty() || ss == "" ) return;
148 if ( !subSections[s] ) { 149 if ( !subSections[s] ) {
149 subSections.insert( s, new QStringList() ); 150 subSections.insert( s, new QStringList() );
150 QStringList *subsecs = subSections[s]; 151 QStringList *subsecs = subSections[s];
151 *subsecs += "All"; 152 *subsecs += "All";
152 } 153 }
153 QStringList *subsecs = subSections[s]; 154 QStringList *subsecs = subSections[s];
154 *subsecs += ss; 155 *subsecs += ss;
155 if ( !subSections["All"] ) subSections.insert( "All", new QStringList() ); 156 if ( !subSections["All"] ) subSections.insert( "All", new QStringList() );
156 subsecs = subSections["All"]; 157 subsecs = subSections["All"];
157 *subsecs += ss; 158 *subsecs += ss;
158} 159}
159 160
160 161
161void PackageList::readFileEntries( QString filename, QString dest ) 162void PackageList::readFileEntries( QString filename, QString dest )
162 { 163 {
163 pvDebug(5,"PackageList::readFileEntries "+filename+" dest "+dest); 164 pvDebug(5,"PackageList::readFileEntries "+filename+" dest "+dest);
164 QStringList packEntry; 165 QStringList packEntry;
165 QFile f( filename ); 166 QFile f( filename );
166 if ( !f.open(IO_ReadOnly) ) return; 167 if ( !f.open(IO_ReadOnly) ) return;
167 QTextStream *statusStream = new QTextStream( &f ); 168 QTextStream *statusStream = new QTextStream( &f );
168 while ( !statusStream ->eof() ) 169 while ( !statusStream ->eof() )
169 { 170 {
170 QString line = statusStream->readLine(); 171 QString line = statusStream->readLine();
171 if ( line.find(QRegExp("[\n\t ]*")) || line == "" ) 172 if ( line.find(QRegExp("[\n\t ]*")) || line == "" )
172 { 173 {
173 //end of package 174 //end of package
174 if ( ! packEntry.isEmpty() ) 175 if ( ! packEntry.isEmpty() )
175 { 176 {