-rw-r--r-- | noncore/unsupported/oipkg/packagelist.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/noncore/unsupported/oipkg/packagelist.cpp b/noncore/unsupported/oipkg/packagelist.cpp index 844f43f..998dae9 100644 --- a/noncore/unsupported/oipkg/packagelist.cpp +++ b/noncore/unsupported/oipkg/packagelist.cpp @@ -131,100 +131,111 @@ QStringList PackageList::getSections() QStringList PackageList::getSubSections() { QStringList ss; if ( !subSections[aktSection] ) return ss; ss = *subSections[aktSection]; ss.sort(); return ss; } void PackageList::setSection( QString sec ) { aktSection = sec; } void PackageList::setSubSection( QString ssec ) { aktSubSection = ssec; } void PackageList::updateSections( Package* pack ) { QString s = pack->section(); if ( s.isEmpty() || s == "") return; if ( sections.contains(s) ) return; sections += s; QString ss = pack->subSection(); if ( ss.isEmpty() || ss == "" ) return; if ( !subSections[s] ) { subSections.insert( s, new QStringList() ); QStringList *subsecs = subSections[s]; *subsecs += "All"; } QStringList *subsecs = subSections[s]; *subsecs += ss; if ( !subSections["All"] ) subSections.insert( "All", new QStringList() ); subsecs = subSections["All"]; *subsecs += ss; } void PackageList::readFileEntries( QString filename, QString dest ) { pvDebug(5,"PackageList::readFileEntries "+filename+" dest "+dest); QStringList packEntry; QFile f( filename ); if ( !f.open(IO_ReadOnly) ) return; QTextStream *statusStream = new QTextStream( &f ); while ( !statusStream ->eof() ) - { + { QString line = statusStream->readLine(); if ( line.find(QRegExp("[\n\t ]*")) || line == "" ) { //end of package if ( ! packEntry.isEmpty() ) { Package *p = new Package( packEntry, settings ); if ( p ) { p->setDest( dest ); insertPackage( p ); packEntry.clear(); } } }else{ packEntry << line; }; } + //there might be no nl at the end of the package file + if ( ! packEntry.isEmpty() ) + { + Package *p = new Package( packEntry, settings ); + if ( p ) + { + p->setDest( dest ); + insertPackage( p ); + packEntry.clear(); + } + } delete statusStream; return; } void PackageList::setSettings( PackageManagerSettings *s ) { settings = s; } Package* PackageList::getByName( QString n ) { return origPackageList[n]; } void PackageList::clear() { origPackageList.clear(); packageList.clear(); } void PackageList::allPackages() { packageList.clear(); QDictIterator<Package> filterIter( origPackageList ); filterIter.toFirst(); Package *pack= filterIter.current() ; while ( pack ) { packageList.insert( pack->name(), pack ); ++filterIter; pack = filterIter.current(); } } |