summaryrefslogtreecommitdiff
path: root/noncore/unsupported/oipkg/packagelist.cpp
Unidiff
Diffstat (limited to 'noncore/unsupported/oipkg/packagelist.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/unsupported/oipkg/packagelist.cpp46
1 files changed, 32 insertions, 14 deletions
diff --git a/noncore/unsupported/oipkg/packagelist.cpp b/noncore/unsupported/oipkg/packagelist.cpp
index 944bb83..035ec81 100644
--- a/noncore/unsupported/oipkg/packagelist.cpp
+++ b/noncore/unsupported/oipkg/packagelist.cpp
@@ -61,26 +61,26 @@ void PackageList::insertPackage( Package* pack )
61 updateSections( pack ); 61 updateSections( pack );
62} 62}
63 63
64void PackageList::filterPackages( QString f ) 64void PackageList::filterPackages( QString f )
65 { 65 {
66 packageList.clear(); 66 packageList.clear();
67 QDictIterator<Package> filterIter( origPackageList ); 67 QDictIterator<Package> filterIter( origPackageList );
68 filterIter.toFirst(); 68 filterIter.toFirst();
69 Package *pack= filterIter.current() ; 69 Package *pack= filterIter.current() ;
70 while ( pack ) 70 while ( pack )
71 { 71 {
72 if ( 72 if (
73 ((aktSection=="All")||(pack->getSection()==aktSection)) && 73 ((aktSection=="All")||(pack->section()==aktSection)) &&
74 ((aktSubSection=="All")||(pack->getSubSection()==aktSubSection)) && 74 ((aktSubSection=="All")||(pack->subSection()==aktSubSection)) &&
75 pack->name().contains( f ) 75 pack->name().contains( f )
76 ) 76 )
77 { 77 {
78 packageList.insert( pack->name(), pack ); 78 packageList.insert( pack->name(), pack );
79 } 79 }
80 ++filterIter; 80 ++filterIter;
81 pack = filterIter.current(); 81 pack = filterIter.current();
82 } 82 }
83} 83}
84 84
85Package* PackageList::find( QString n ) 85Package* PackageList::find( QString n )
86{ 86{
@@ -117,107 +117,125 @@ QStringList PackageList::getSubSections()
117void PackageList::setSection( QString sec ) 117void PackageList::setSection( QString sec )
118{ 118{
119 aktSection = sec; 119 aktSection = sec;
120} 120}
121 121
122void PackageList::setSubSection( QString ssec ) 122void PackageList::setSubSection( QString ssec )
123{ 123{
124 aktSubSection = ssec; 124 aktSubSection = ssec;
125} 125}
126 126
127void PackageList::updateSections( Package* pack ) 127void PackageList::updateSections( Package* pack )
128{ 128{
129 QString s = pack->getSection(); 129 QString s = pack->section();
130 if ( s.isEmpty() || s == "") return; 130 if ( s.isEmpty() || s == "") return;
131 if ( sections.contains(s) ) return; 131 if ( sections.contains(s) ) return;
132 sections += s; 132 sections += s;
133 QString ss = pack->getSubSection(); 133 QString ss = pack->subSection();
134 if ( ss.isEmpty() || ss == "" ) return; 134 if ( ss.isEmpty() || ss == "" ) return;
135 if ( !subSections[s] ) { 135 if ( !subSections[s] ) {
136 subSections.insert( s, new QStringList() ); 136 subSections.insert( s, new QStringList() );
137 QStringList *subsecs = subSections[s]; 137 QStringList *subsecs = subSections[s];
138 *subsecs += "All"; 138 *subsecs += "All";
139 } 139 }
140 QStringList *subsecs = subSections[s]; 140 QStringList *subsecs = subSections[s];
141 *subsecs += ss; 141 *subsecs += ss;
142 if ( !subSections["All"] ) subSections.insert( "All", new QStringList() ); 142 if ( !subSections["All"] ) subSections.insert( "All", new QStringList() );
143 subsecs = subSections["All"]; 143 subsecs = subSections["All"];
144 *subsecs += ss; 144 *subsecs += ss;
145} 145}
146 146
147 147
148 148
149/** No descriptions */ 149/** No descriptions */
150void PackageList::parseStatus() 150void PackageList::parseStatus()
151{ 151{
152 QStringList dests = settings->getDestinationUrls(); 152 QStringList dests = settings->getDestinationUrls();
153 for ( QStringList::Iterator it = dests.begin(); it != dests.end(); ++it ) 153 QStringList destnames = settings->getDestinationNames();
154 QStringList::Iterator name = destnames.begin();
155 for ( QStringList::Iterator dir = dests.begin(); dir != dests.end(); ++dir )
154 { 156 {
155 pvDebug( 2,"Status Dir: "+*it+statusDir+"/status"); 157 pvDebug( 2,"Status: "+*dir+statusDir+"/status");
156 readFileEntries( *it+statusDir+"/status" ); 158 readFileEntries( *dir+statusDir+"/status", *name );
159 ++name;
157 }; 160 };
158} 161}
159 162
160void PackageList::parseList() 163void PackageList::parseList()
161{ 164{
162 QStringList srvs = settings->getActiveServers(); 165 QStringList srvs = settings->getActiveServers();
163 166
164 for ( QStringList::Iterator it = srvs.begin(); it != srvs.end(); ++it ) 167 for ( QStringList::Iterator it = srvs.begin(); it != srvs.end(); ++it )
165 { 168 {
166 pvDebug( 2, "List Dir: "+listsDir+"/"+*it); 169 pvDebug( 2, "List: "+listsDir+"/"+*it);
167 readFileEntries( listsDir+"/"+*it ); 170 readFileEntries( listsDir+"/"+*it, "" );
168 } 171 }
169} 172}
170 173
171void PackageList::readFileEntries( QString filename ) 174void PackageList::readFileEntries( QString filename, QString dest )
172 { 175 {
173 QStringList packEntry; 176 QStringList packEntry;
174 QFile f( filename ); 177 QFile f( filename );
175 if ( !f.open(IO_ReadOnly) ) return; 178 if ( !f.open(IO_ReadOnly) ) return;
176 QTextStream *statusStream = new QTextStream( &f ); 179 QTextStream *statusStream = new QTextStream( &f );
177 while ( !statusStream ->eof() ) 180 while ( !statusStream ->eof() )
178 { 181 {
179 QString line = statusStream->readLine(); 182 QString line = statusStream->readLine();
180 if ( line.find(QRegExp("[\n\t ]*")) || line == "" ) 183 if ( line.find(QRegExp("[\n\t ]*")) || line == "" )
181 { 184 {
182 //end of package 185 //end of package
183 if ( ! packEntry.isEmpty() ) 186 if ( ! packEntry.isEmpty() )
184 { 187 {
185 Package *p = new Package( packEntry ); 188 Package *p = new Package( packEntry, settings );
189 p->setDest( dest );
186 if ( p ) 190 if ( p )
187 { 191 {
188 insertPackage( p ); 192 insertPackage( p );
189 packEntry.clear(); 193 packEntry.clear();
190 } 194 }
191 } 195 }
192 }else{ 196 }else{
193 packEntry << line; 197 packEntry << line;
194 }; 198 };
195 } 199 }
196 return; 200 return;
197} 201}
198 202
199 203
200void PackageList::update() 204void PackageList::update()
201{ 205{
202 pvDebug( 3, "parseStatus"); 206 pvDebug( 2, "parseStatus");
203 parseStatus(); 207 parseStatus();
204 pvDebug( 3, "parseList"); 208 pvDebug( 2, "parseList");
205 parseList(); 209 parseList();
206 pvDebug( 3, "finished parsing"); 210 pvDebug( 2, "finished parsing");
207} 211}
208 212
209void PackageList::setSettings( PackageManagerSettings *s ) 213void PackageList::setSettings( PackageManagerSettings *s )
210{ 214{
211 settings = s; 215 settings = s;
212} 216}
213 217
214Package* PackageList::getByName( QString n ) 218Package* PackageList::getByName( QString n )
215{ 219{
216 origPackageList[n]; 220 origPackageList[n];
217} 221}
218 222
219void PackageList::clear() 223void PackageList::clear()
220{ 224{
221 origPackageList.clear(); 225 origPackageList.clear();
222 packageList.clear(); 226 packageList.clear();
223} 227}
228
229void PackageList::allPackages()
230{
231 packageList.clear();
232 QDictIterator<Package> filterIter( origPackageList );
233 filterIter.toFirst();
234 Package *pack= filterIter.current() ;
235 while ( pack )
236 {
237 packageList.insert( pack->name(), pack );
238 ++filterIter;
239 pack = filterIter.current();
240 }
241}