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.cpp34
1 files changed, 17 insertions, 17 deletions
diff --git a/noncore/unsupported/oipkg/packagelist.cpp b/noncore/unsupported/oipkg/packagelist.cpp
index edb9cc5..5f79ec1 100644
--- a/noncore/unsupported/oipkg/packagelist.cpp
+++ b/noncore/unsupported/oipkg/packagelist.cpp
@@ -7,125 +7,125 @@
7 * * 7 * *
8 ***************************************************************************/ 8 ***************************************************************************/
9// (c) 2002 Patrick S. Vogt <tille@handhelds.org> 9// (c) 2002 Patrick S. Vogt <tille@handhelds.org>
10#include "packagelist.h" 10#include "packagelist.h"
11 11
12#include <assert.h> 12#include <assert.h>
13#include <qfile.h> 13#include <qfile.h>
14#include <qfileinfo.h> 14#include <qfileinfo.h>
15#include <qtextstream.h> 15#include <qtextstream.h>
16 16
17#include "debug.h" 17#include "debug.h"
18 18
19static QDict<Package> *packageListAll; 19static QDict<OipkgPackage> *packageListAll;
20static int packageListAllRefCount = 0; 20static int packageListAllRefCount = 0;
21 21
22PackageList::PackageList(QObject *parent, const char *name) 22PackageList::PackageList(QObject *parent, const char *name)
23 : QObject(parent,name), packageIter( packageList ) 23 : QObject(parent,name), packageIter( packageList )
24{ 24{
25 empty=true; 25 empty=true;
26 if (!packageListAll) packageListAll = new QDict<Package>(); 26 if (!packageListAll) packageListAll = new QDict<OipkgPackage>();
27 packageListAllRefCount++; 27 packageListAllRefCount++;
28 sections << "All"; 28 sections << "All";
29 subSections.insert("All", new QStringList() ); 29 subSections.insert("All", new QStringList() );
30 QStringList *ss = subSections["All"]; 30 QStringList *ss = subSections["All"];
31 *ss << "All"; 31 *ss << "All";
32 aktSection = "All"; 32 aktSection = "All";
33 aktSubSection = "All"; 33 aktSubSection = "All";
34} 34}
35 35
36PackageList::PackageList( PackageManagerSettings* s, QObject *parent, const char *name) 36PackageList::PackageList( PackageManagerSettings* s, QObject *parent, const char *name)
37 : QObject(parent,name), packageIter( packageList ) 37 : QObject(parent,name), packageIter( packageList )
38{ 38{
39 settings = s; 39 settings = s;
40 PackageList(parent, name); 40 PackageList(parent, name);
41} 41}
42 42
43PackageList::~PackageList() 43PackageList::~PackageList()
44{ 44{
45 if (--packageListAllRefCount < 1 ) delete packageListAll; 45 if (--packageListAllRefCount < 1 ) delete packageListAll;
46} 46}
47 47
48/** Inserts a package into the list */ 48/** Inserts a package into the list */
49void PackageList::insertPackage( Package* pack ) 49void PackageList::insertPackage( OipkgPackage* pack )
50{ 50{
51 if (!pack) return; 51 if (!pack) return;
52 Package* p = packageListAll->find( pack->name() ); 52 OipkgPackage* p = packageListAll->find( pack->name() );
53 if ( p ) 53 if ( p )
54 { 54 {
55 if ( (p->version() == pack->version()) 55 if ( (p->version() == pack->version())
56 // && (p->dest() == pack->dest()) 56 // && (p->dest() == pack->dest())
57 ) 57 )
58 { 58 {
59 p->copyValues( pack ); 59 p->copyValues( pack );
60 delete pack; 60 delete pack;
61 pack = p; 61 pack = p;
62 } else { 62 } else {
63 QDict<Package> *packver = p->getOtherVersions(); 63 QDict<OipkgPackage> *packver = p->getOtherVersions();
64 // p->setName( pack->name()+"["+p->version()+"]" ); 64 // p->setName( pack->name()+"["+p->version()+"]" );
65 if (!packver) 65 if (!packver)
66 { 66 {
67 packver = new QDict<Package>(); 67 packver = new QDict<OipkgPackage>();
68 packver->insert( pack->name(), p ); 68 packver->insert( pack->name(), p );
69 p->setOtherVersions( packver ); 69 p->setOtherVersions( packver );
70 } 70 }
71 pack->setName( pack->name() );//+"["+pack->version()+"]" ); 71 pack->setName( pack->name() );//+"["+pack->version()+"]" );
72 pack->setOtherVersions( packver ); 72 pack->setOtherVersions( packver );
73 packver->insert( pack->name(), pack ); 73 packver->insert( pack->name(), pack );
74 packageListAll->insert( pack->name(), pack ); 74 packageListAll->insert( pack->name(), pack );
75 packageList.insert( pack->name(), pack ); 75 packageList.insert( pack->name(), pack );
76 origPackageList.insert( pack->name(), pack ); 76 origPackageList.insert( pack->name(), pack );
77 } 77 }
78 }else{ 78 }else{
79 packageListAll->insert( pack->name(), pack ); 79 packageListAll->insert( pack->name(), pack );
80 packageList.insert( pack->name(), pack ); 80 packageList.insert( pack->name(), pack );
81 origPackageList.insert( pack->name(), pack ); 81 origPackageList.insert( pack->name(), pack );
82 }; 82 };
83 empty=false; 83 empty=false;
84 updateSections( pack ); 84 updateSections( pack );
85} 85}
86 86
87void PackageList::filterPackages( QString f ) 87void PackageList::filterPackages( QString f )
88 { 88 {
89 packageList.clear(); 89 packageList.clear();
90 QDictIterator<Package> filterIter( origPackageList ); 90 QDictIterator<OipkgPackage> filterIter( origPackageList );
91 filterIter.toFirst(); 91 filterIter.toFirst();
92 Package *pack= filterIter.current() ; 92 OipkgPackage *pack= filterIter.current() ;
93 while ( pack ) 93 while ( pack )
94 { 94 {
95 if ( 95 if (
96 ((aktSection=="All")||(pack->section()==aktSection)) && 96 ((aktSection=="All")||(pack->section()==aktSection)) &&
97 ((aktSubSection=="All")||(pack->subSection()==aktSubSection)) && 97 ((aktSubSection=="All")||(pack->subSection()==aktSubSection)) &&
98 pack->name().contains( f ) 98 pack->name().contains( f )
99 ) 99 )
100 { 100 {
101 packageList.insert( pack->name(), pack ); 101 packageList.insert( pack->name(), pack );
102 } 102 }
103 ++filterIter; 103 ++filterIter;
104 pack = filterIter.current(); 104 pack = filterIter.current();
105 } 105 }
106} 106}
107 107
108Package* PackageList::find( QString n ) 108OipkgPackage* PackageList::find( QString n )
109{ 109{
110 return packageList.find( n ); 110 return packageList.find( n );
111} 111}
112 112
113Package* PackageList::first() 113OipkgPackage* PackageList::first()
114 { 114 {
115 packageIter.toFirst(); 115 packageIter.toFirst();
116 return packageIter.current(); 116 return packageIter.current();
117} 117}
118 118
119Package* PackageList::next() 119OipkgPackage* PackageList::next()
120{ 120{
121 ++packageIter; 121 ++packageIter;
122 return packageIter.current(); 122 return packageIter.current();
123} 123}
124 124
125QStringList PackageList::getSections() 125QStringList PackageList::getSections()
126{ 126{
127 sections.sort(); 127 sections.sort();
128 return sections; 128 return sections;
129} 129}
130 130
131QStringList PackageList::getSubSections() 131QStringList PackageList::getSubSections()
@@ -138,25 +138,25 @@ QStringList PackageList::getSubSections()
138} 138}
139 139
140void PackageList::setSection( QString sec ) 140void PackageList::setSection( QString sec )
141{ 141{
142 aktSection = sec; 142 aktSection = sec;
143} 143}
144 144
145void PackageList::setSubSection( QString ssec ) 145void PackageList::setSubSection( QString ssec )
146{ 146{
147 aktSubSection = ssec; 147 aktSubSection = ssec;
148} 148}
149 149
150void PackageList::updateSections( Package* pack ) 150void PackageList::updateSections( OipkgPackage* pack )
151{ 151{
152 QString s = pack->section(); 152 QString s = pack->section();
153 if ( s.isEmpty() || s == "") return; 153 if ( s.isEmpty() || s == "") return;
154 if ( !sections.contains(s) ) sections += s; 154 if ( !sections.contains(s) ) sections += s;
155 QString ss = pack->subSection(); 155 QString ss = pack->subSection();
156 if ( ss.isEmpty() || ss == "" ) return; 156 if ( ss.isEmpty() || ss == "" ) return;
157 if ( !subSections[s] ) { 157 if ( !subSections[s] ) {
158 subSections.insert( s, new QStringList() ); 158 subSections.insert( s, new QStringList() );
159 QStringList *subsecs = subSections[s]; 159 QStringList *subsecs = subSections[s];
160 *subsecs += "All"; 160 *subsecs += "All";
161 } 161 }
162 QStringList *subsecs = subSections[s]; 162 QStringList *subsecs = subSections[s];
@@ -173,68 +173,68 @@ void PackageList::readFileEntries( QString filename, QString dest )
173 QStringList packEntry; 173 QStringList packEntry;
174 QFile f( filename ); 174 QFile f( filename );
175 if ( !f.open(IO_ReadOnly) ) return; 175 if ( !f.open(IO_ReadOnly) ) return;
176 QTextStream *statusStream = new QTextStream( &f ); 176 QTextStream *statusStream = new QTextStream( &f );
177 while ( !statusStream ->eof() ) 177 while ( !statusStream ->eof() )
178 { 178 {
179 QString line = statusStream->readLine(); 179 QString line = statusStream->readLine();
180 if ( line.find(QRegExp("[\n\t ]*")) || line == "" ) 180 if ( line.find(QRegExp("[\n\t ]*")) || line == "" )
181 { 181 {
182 //end of package 182 //end of package
183 if ( ! packEntry.isEmpty() ) 183 if ( ! packEntry.isEmpty() )
184 { 184 {
185 Package *p = new Package( packEntry, settings ); 185 OipkgPackage *p = new OipkgPackage( packEntry, settings );
186 if ( p ) 186 if ( p )
187 { 187 {
188 p->setDest( dest ); 188 p->setDest( dest );
189 insertPackage( p ); 189 insertPackage( p );
190 packEntry.clear(); 190 packEntry.clear();
191 } 191 }
192 } 192 }
193 }else{ 193 }else{
194 packEntry << line; 194 packEntry << line;
195 }; 195 };
196 } 196 }
197 //there might be no nl at the end of the package file 197 //there might be no nl at the end of the package file
198 if ( ! packEntry.isEmpty() ) 198 if ( ! packEntry.isEmpty() )
199 { 199 {
200 Package *p = new Package( packEntry, settings ); 200 OipkgPackage *p = new OipkgPackage( packEntry, settings );
201 if ( p ) 201 if ( p )
202 { 202 {
203 p->setDest( dest ); 203 p->setDest( dest );
204 insertPackage( p ); 204 insertPackage( p );
205 packEntry.clear(); 205 packEntry.clear();
206 } 206 }
207 } 207 }
208 delete statusStream; 208 delete statusStream;
209 return; 209 return;
210} 210}
211 211
212void PackageList::setSettings( PackageManagerSettings *s ) 212void PackageList::setSettings( PackageManagerSettings *s )
213{ 213{
214 settings = s; 214 settings = s;
215} 215}
216 216
217Package* PackageList::getByName( QString n ) 217OipkgPackage* PackageList::getByName( QString n )
218{ 218{
219 return origPackageList[n]; 219 return origPackageList[n];
220} 220}
221 221
222void PackageList::clear() 222void PackageList::clear()
223{ 223{
224 origPackageList.clear(); 224 origPackageList.clear();
225 packageList.clear(); 225 packageList.clear();
226} 226}
227 227
228void PackageList::allPackages() 228void PackageList::allPackages()
229{ 229{
230 packageList.clear(); 230 packageList.clear();
231 QDictIterator<Package> filterIter( origPackageList ); 231 QDictIterator<OipkgPackage> filterIter( origPackageList );
232 filterIter.toFirst(); 232 filterIter.toFirst();
233 Package *pack= filterIter.current() ; 233 OipkgPackage *pack= filterIter.current() ;
234 while ( pack ) 234 while ( pack )
235 { 235 {
236 packageList.insert( pack->name(), pack ); 236 packageList.insert( pack->name(), pack );
237 ++filterIter; 237 ++filterIter;
238 pack = filterIter.current(); 238 pack = filterIter.current();
239 } 239 }
240} 240}