summaryrefslogtreecommitdiff
authortille <tille>2002-07-24 11:37:36 (UTC)
committer tille <tille>2002-07-24 11:37:36 (UTC)
commitadfb21cd5e2fcf750543570ab9c6427f1fba9968 (patch) (unidiff)
tree1a55eb15bd48b373cd3a88a41cb5733af9f9a4b9
parent0948a167e4e46e6d2082809ec47be6a08a5de9d7 (diff)
downloadopie-adfb21cd5e2fcf750543570ab9c6427f1fba9968.zip
opie-adfb21cd5e2fcf750543570ab9c6427f1fba9968.tar.gz
opie-adfb21cd5e2fcf750543570ab9c6427f1fba9968.tar.bz2
fix bug #116 -- subsections
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/oipkg/packagelist.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/noncore/unsupported/oipkg/packagelist.cpp b/noncore/unsupported/oipkg/packagelist.cpp
index 998dae9..edb9cc5 100644
--- a/noncore/unsupported/oipkg/packagelist.cpp
+++ b/noncore/unsupported/oipkg/packagelist.cpp
@@ -58,184 +58,183 @@ void PackageList::insertPackage( Package* pack )
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<Package> *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<Package>();
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<Package> filterIter( origPackageList );
91 filterIter.toFirst(); 91 filterIter.toFirst();
92 Package *pack= filterIter.current() ; 92 Package *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 ) 108Package* PackageList::find( QString n )
109{ 109{
110 return packageList.find( n ); 110 return packageList.find( n );
111} 111}
112 112
113Package* PackageList::first() 113Package* 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() 119Package* 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()
132{ 132{
133 QStringList ss; 133 QStringList ss;
134 if ( !subSections[aktSection] ) return ss; 134 if ( !subSections[aktSection] ) return ss;
135 ss = *subSections[aktSection]; 135 ss = *subSections[aktSection];
136 ss.sort(); 136 ss.sort();
137 return ss; 137 return ss;
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( Package* 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) ) return; 154 if ( !sections.contains(s) ) sections += s;
155 sections += s;
156 QString ss = pack->subSection(); 155 QString ss = pack->subSection();
157 if ( ss.isEmpty() || ss == "" ) return; 156 if ( ss.isEmpty() || ss == "" ) return;
158 if ( !subSections[s] ) { 157 if ( !subSections[s] ) {
159 subSections.insert( s, new QStringList() ); 158 subSections.insert( s, new QStringList() );
160 QStringList *subsecs = subSections[s]; 159 QStringList *subsecs = subSections[s];
161 *subsecs += "All"; 160 *subsecs += "All";
162 } 161 }
163 QStringList *subsecs = subSections[s]; 162 QStringList *subsecs = subSections[s];
164 *subsecs += ss; 163 if ( !subsecs->contains(ss) ) *subsecs += ss;
165 if ( !subSections["All"] ) subSections.insert( "All", new QStringList() ); 164// if ( !subSections["All"] ) subSections.insert( "All", new QStringList() );
166 subsecs = subSections["All"]; 165// subsecs = subSections["All"];
167 *subsecs += ss; 166// *subsecs += ss;
168} 167}
169 168
170 169
171void PackageList::readFileEntries( QString filename, QString dest ) 170void PackageList::readFileEntries( QString filename, QString dest )
172 { 171 {
173 pvDebug(5,"PackageList::readFileEntries "+filename+" dest "+dest); 172 pvDebug(5,"PackageList::readFileEntries "+filename+" dest "+dest);
174 QStringList packEntry; 173 QStringList packEntry;
175 QFile f( filename ); 174 QFile f( filename );
176 if ( !f.open(IO_ReadOnly) ) return; 175 if ( !f.open(IO_ReadOnly) ) return;
177 QTextStream *statusStream = new QTextStream( &f ); 176 QTextStream *statusStream = new QTextStream( &f );
178 while ( !statusStream ->eof() ) 177 while ( !statusStream ->eof() )
179 { 178 {
180 QString line = statusStream->readLine(); 179 QString line = statusStream->readLine();
181 if ( line.find(QRegExp("[\n\t ]*")) || line == "" ) 180 if ( line.find(QRegExp("[\n\t ]*")) || line == "" )
182 { 181 {
183 //end of package 182 //end of package
184 if ( ! packEntry.isEmpty() ) 183 if ( ! packEntry.isEmpty() )
185 { 184 {
186 Package *p = new Package( packEntry, settings ); 185 Package *p = new Package( packEntry, settings );
187 if ( p ) 186 if ( p )
188 { 187 {
189 p->setDest( dest ); 188 p->setDest( dest );
190 insertPackage( p ); 189 insertPackage( p );
191 packEntry.clear(); 190 packEntry.clear();
192 } 191 }
193 } 192 }
194 }else{ 193 }else{
195 packEntry << line; 194 packEntry << line;
196 }; 195 };
197 } 196 }
198 //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
199 if ( ! packEntry.isEmpty() ) 198 if ( ! packEntry.isEmpty() )
200 { 199 {
201 Package *p = new Package( packEntry, settings ); 200 Package *p = new Package( packEntry, settings );
202 if ( p ) 201 if ( p )
203 { 202 {
204 p->setDest( dest ); 203 p->setDest( dest );
205 insertPackage( p ); 204 insertPackage( p );
206 packEntry.clear(); 205 packEntry.clear();
207 } 206 }
208 } 207 }
209 delete statusStream; 208 delete statusStream;
210 return; 209 return;
211} 210}
212 211
213void PackageList::setSettings( PackageManagerSettings *s ) 212void PackageList::setSettings( PackageManagerSettings *s )
214{ 213{
215 settings = s; 214 settings = s;
216} 215}
217 216
218Package* PackageList::getByName( QString n ) 217Package* PackageList::getByName( QString n )
219{ 218{
220 return origPackageList[n]; 219 return origPackageList[n];
221} 220}
222 221
223void PackageList::clear() 222void PackageList::clear()
224{ 223{
225 origPackageList.clear(); 224 origPackageList.clear();
226 packageList.clear(); 225 packageList.clear();
227} 226}
228 227
229void PackageList::allPackages() 228void PackageList::allPackages()
230{ 229{
231 packageList.clear(); 230 packageList.clear();
232 QDictIterator<Package> filterIter( origPackageList ); 231 QDictIterator<Package> filterIter( origPackageList );
233 filterIter.toFirst(); 232 filterIter.toFirst();
234 Package *pack= filterIter.current() ; 233 Package *pack= filterIter.current() ;
235 while ( pack ) 234 while ( pack )
236 { 235 {
237 packageList.insert( pack->name(), pack ); 236 packageList.insert( pack->name(), pack );
238 ++filterIter; 237 ++filterIter;
239 pack = filterIter.current(); 238 pack = filterIter.current();
240 } 239 }
241} 240}