cleaned up the missing helper storage class

This commit is contained in:
Jean-Francois Dockes 2012-10-28 16:43:19 +01:00
parent f9aff8fecc
commit b8963db4b1
4 changed files with 38 additions and 39 deletions

View File

@ -496,54 +496,43 @@ void FileInterner::checkExternalMissing(const string& msg, const string& mt)
it++;
if (*it == "HELPERNOTFOUND") {
it++;
for (; it < verr.end(); it++) {
m_missingdatap->m_missingExternal.insert(*it);
m_missingdatap->m_typesForMissing[*it].insert(mt);
for (; it != verr.end(); it++) {
m_missingdatap->addMissing(*it, mt);
}
}
}
}
}
void FileInterner::getMissingExternal(FIMissingStore *st, string& out)
void FIMissingStore::getMissingExternal(string& out)
{
if (st)
stringsToString(st->m_missingExternal, out);
for (map<string, set<string> >::const_iterator it =
m_typesForMissing.begin(); it != m_typesForMissing.end(); it++) {
out += string(" ") + it->first;
}
trimstring(out);
}
void FileInterner::getMissingDescription(FIMissingStore *st, string& out)
void FIMissingStore::getMissingDescription(string& out)
{
if (st == 0)
return;
out.erase();
for (set<string>::const_iterator it =
st->m_missingExternal.begin();
it != st->m_missingExternal.end(); it++) {
out += *it;
map<string, set<string> >::const_iterator it2;
it2 = st->m_typesForMissing.find(*it);
if (it2 != st->m_typesForMissing.end()) {
out += " (";
set<string>::const_iterator it3;
for (it3 = it2->second.begin();
it3 != it2->second.end(); it3++) {
out += *it3;
out += string(" ");
}
trimstring(out);
out += ")";
}
for (map<string, set<string> >::const_iterator it =
m_typesForMissing.begin(); it != m_typesForMissing.end(); it++) {
out += it->first + " (";
set<string>::const_iterator it3;
for (it3 = it->second.begin();
it3 != it->second.end(); it3++) {
out += *it3 + " ";
}
trimstring(out);
out += ")";
out += "\n";
}
}
void FileInterner::getMissingFromDescription(FIMissingStore *st, const string& in)
FIMissingStore::FIMissingStore(const string& in)
{
if (st == 0)
return;
// The "missing" file is text. Each line defines a missing filter
// and the list of mime types actually encountered that needed it
// (see method getMissingDescription())
@ -575,10 +564,9 @@ void FileInterner::getMissingFromDescription(FIMissingStore *st, const string& i
if (filter.empty())
continue;
st->m_missingExternal.insert(filter);
for (vector<string>::const_iterator itt = mtypes.begin();
itt != mtypes.end(); itt++) {
st->m_typesForMissing[filter].insert(*itt);
m_typesForMissing[filter].insert(*itt);
}
}
}

View File

@ -34,7 +34,7 @@ using std::set;
class RclConfig;
namespace Rcl {
class Doc;
class Doc;
}
struct stat;
@ -47,8 +47,19 @@ struct stat;
*/
class FIMissingStore {
public:
FIMissingStore() {}
FIMissingStore(const string& in);
virtual ~FIMissingStore() {}
virtual void addMissing(const string& prog, const string& mt)
{
m_typesForMissing[prog].insert(mt);
}
// Get simple progs list string
virtual void getMissingExternal(string& out);
// Get progs + assoc mtypes description string
virtual void getMissingDescription(string& out);
// Missing external programs
set<string> m_missingExternal;
map<string, set<string> > m_typesForMissing;
};

View File

@ -766,7 +766,7 @@ class LoadThread : public QThread {
imgtmp = interner.get_imgtmp();
} else {
out.mimetype = interner.getMimetype();
interner.getMissingExternal(&mst, missing);
mst.getMissingExternal(missing);
*statusp = -1;
}
} catch (CancelExcept) {

View File

@ -1127,11 +1127,11 @@ void RclMain::showActiveTypes()
mtypesfromdbconf.insert(*it);
}
// Substract the types for missing helpers (the docs are indexed by name only):
// Substract the types for missing helpers (the docs are indexed
// by name only):
string miss = theconfig->getMissingHelperDesc();
if (!miss.empty()) {
FIMissingStore st;
FileInterner::getMissingFromDescription(&st, miss);
FIMissingStore st(miss);
map<string, set<string> >::const_iterator it;
for (it = st.m_typesForMissing.begin();
it != st.m_typesForMissing.end(); it++) {