GUI: simplify icon display by moving up the thumbnail test up to reslistpager as it was identical in restable and reslist

This commit is contained in:
Jean-Francois Dockes 2020-06-14 13:31:26 +02:00
parent f500474643
commit 1eeeba4874
3 changed files with 21 additions and 42 deletions

View File

@ -143,7 +143,6 @@ public:
virtual void suggest(const vector<string>uterms, virtual void suggest(const vector<string>uterms,
map<string, vector<string> >& sugg); map<string, vector<string> >& sugg);
virtual string absSep() {return (const char *)(prefs.abssep.toUtf8());} virtual string absSep() {return (const char *)(prefs.abssep.toUtf8());}
virtual string iconUrl(RclConfig *, Rcl::Doc& doc);
#ifdef USING_WEBENGINE #ifdef USING_WEBENGINE
virtual string linkPrefix() override {return "http://localhost/";} virtual string linkPrefix() override {return "http://localhost/";}
#endif #endif
@ -292,29 +291,6 @@ void QtGuiResListPager::suggest(const vector<string>uterms,
} }
} }
string QtGuiResListPager::iconUrl(RclConfig *config, Rcl::Doc& doc)
{
if (doc.ipath.empty()) {
vector<Rcl::Doc> docs;
docs.push_back(doc);
vector<string> paths;
Rcl::docsToPaths(docs, paths);
if (!paths.empty()) {
string path;
LOGDEB2("ResList::iconUrl: source path [" << paths[0] << "]\n");
if (thumbPathForUrl(cstr_fileu + paths[0], 128, path)) {
LOGDEB2("ResList::iconUrl: icon path [" << path << "]\n");
return cstr_fileu + path;
} else {
LOGDEB2("ResList::iconUrl: no icon: path [" << path << "]\n");
}
} else {
LOGDEB("ResList::iconUrl: docsToPaths failed\n");
}
}
return ResListPager::iconUrl(config, doc);
}
/////// /////// End reslistpager methods /////// /////// End reslistpager methods
string PlainToRichQtReslist::startMatch(unsigned int idx) string PlainToRichQtReslist::startMatch(unsigned int idx)

View File

@ -83,7 +83,6 @@ public:
virtual string trans(const string& in); virtual string trans(const string& in);
virtual const string &parFormat(); virtual const string &parFormat();
virtual string absSep() {return (const char *)(prefs.abssep.toUtf8());} virtual string absSep() {return (const char *)(prefs.abssep.toUtf8());}
virtual string iconUrl(RclConfig *, Rcl::Doc& doc);
private: private:
ResTable *m_parent; ResTable *m_parent;
}; };
@ -109,22 +108,6 @@ const string& ResTablePager::parFormat()
return prefs.creslistformat; return prefs.creslistformat;
} }
string ResTablePager::iconUrl(RclConfig *config, Rcl::Doc& doc)
{
if (doc.ipath.empty()) {
vector<Rcl::Doc> docs;
docs.push_back(doc);
vector<string> paths;
Rcl::docsToPaths(docs, paths);
if (!paths.empty()) {
string path;
if (thumbPathForUrl(cstr_fileu + paths[0], 128, path)) {
return cstr_fileu + path;
}
}
}
return ResListPager::iconUrl(config, doc);
}
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
/// Detail text area methods /// Detail text area methods

View File

@ -478,9 +478,29 @@ string ResListPager::prevUrl()
string ResListPager::iconUrl(RclConfig *config, Rcl::Doc& doc) string ResListPager::iconUrl(RclConfig *config, Rcl::Doc& doc)
{ {
// If this is a top level doc, check for a thumbnail image
if (doc.ipath.empty()) {
vector<Rcl::Doc> docs;
docs.push_back(doc);
vector<string> paths;
Rcl::docsToPaths(docs, paths);
if (!paths.empty()) {
string path;
LOGDEB2("ResList::iconUrl: source path [" << paths[0] << "]\n");
if (thumbPathForUrl(cstr_fileu + paths[0], 128, path)) {
LOGDEB2("ResList::iconUrl: icon path [" << path << "]\n");
return cstr_fileu + path;
} else {
LOGDEB2("ResList::iconUrl: no icon: path [" << path << "]\n");
}
} else {
LOGDEB("ResList::iconUrl: docsToPaths failed\n");
}
}
// No thumbnail, look for the MIME type icon.
string apptag; string apptag;
doc.getmeta(Rcl::Doc::keyapptg, &apptag); doc.getmeta(Rcl::Doc::keyapptg, &apptag);
return path_pathtofileurl(config->getMimeIconPath(doc.mimetype, apptag)); return path_pathtofileurl(config->getMimeIconPath(doc.mimetype, apptag));
} }