Result list: if a thumbnail exists for the result, display it instead of the file type icon
This commit is contained in:
parent
4cd65b9898
commit
2a091e874c
@ -84,8 +84,10 @@ src/sampleconf/rclmon.sh
|
|||||||
src/sampleconf/recoll.conf
|
src/sampleconf/recoll.conf
|
||||||
tests/config/aspdict.en.rws
|
tests/config/aspdict.en.rws
|
||||||
tests/config/history
|
tests/config/history
|
||||||
|
tests/config/idxstatus.txt
|
||||||
tests/config/index.pid
|
tests/config/index.pid
|
||||||
tests/config/missing
|
tests/config/missing
|
||||||
tests/config/xapiandb
|
tests/config/xapiandb
|
||||||
|
tests/indexedmimetypes/idxstatus.txt
|
||||||
tests/indexedmimetypes/index.pid
|
tests/indexedmimetypes/index.pid
|
||||||
website/usermanual/*
|
website/usermanual/*
|
||||||
|
|||||||
@ -37,7 +37,7 @@ RclDynConf *g_dynconf;
|
|||||||
// introducing blank space.
|
// introducing blank space.
|
||||||
const char *PrefsPack::dfltResListFormat =
|
const char *PrefsPack::dfltResListFormat =
|
||||||
#if 1
|
#if 1
|
||||||
"<table><tr><td><img src='%I'></td>"
|
"<table><tr><td><img src='%I' width='64'></td>"
|
||||||
"<td>%R %S %L <b>%T</b><br>"
|
"<td>%R %S %L <b>%T</b><br>"
|
||||||
"%M %D <i>%U</i><br>"
|
"%M %D <i>%U</i><br>"
|
||||||
"%A %K</td></tr></table>"
|
"%A %K</td></tr></table>"
|
||||||
@ -49,10 +49,10 @@ const char *PrefsPack::dfltResListFormat =
|
|||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
|
|
||||||
const char *v114reslistformat = "<img src=\"%I\" align=\"left\">"
|
const char* v162reslistformat="<table><tr><td><img src='%I'></td>"
|
||||||
"%R %S %L <b>%T</b><br>"
|
"<td>%R %S %L <b>%T</b><br>"
|
||||||
"%M %D <i>%U</i> %i<br>"
|
"%M %D <i>%U</i><br>"
|
||||||
"%A %K";
|
"%A %K</td></tr></table>";
|
||||||
|
|
||||||
|
|
||||||
// The global preferences structure
|
// The global preferences structure
|
||||||
@ -151,7 +151,7 @@ void rwSettings(bool writing)
|
|||||||
// If the current value of the format is the default for the
|
// If the current value of the format is the default for the
|
||||||
// previous version, replace it with the new default. We
|
// previous version, replace it with the new default. We
|
||||||
// should have a flag to say if it was changed instead
|
// should have a flag to say if it was changed instead
|
||||||
if (!prefs.creslistformat.compare(v114reslistformat)) {
|
if (!prefs.creslistformat.compare(v162reslistformat)) {
|
||||||
LOGDEB(("Replacing old default format\n"));
|
LOGDEB(("Replacing old default format\n"));
|
||||||
prefs.reslistformat = rlfDflt;
|
prefs.reslistformat = rlfDflt;
|
||||||
prefs.creslistformat = (const char*)prefs.reslistformat.toUtf8();
|
prefs.creslistformat = (const char*)prefs.reslistformat.toUtf8();
|
||||||
|
|||||||
@ -49,6 +49,7 @@
|
|||||||
#include "plaintorich.h"
|
#include "plaintorich.h"
|
||||||
#include "refcntr.h"
|
#include "refcntr.h"
|
||||||
#include "internfile.h"
|
#include "internfile.h"
|
||||||
|
#include "indexer.h"
|
||||||
|
|
||||||
#include "reslist.h"
|
#include "reslist.h"
|
||||||
#include "moc_reslist.cpp"
|
#include "moc_reslist.cpp"
|
||||||
@ -75,9 +76,9 @@ public:
|
|||||||
virtual string nextUrl();
|
virtual string nextUrl();
|
||||||
virtual string prevUrl();
|
virtual string prevUrl();
|
||||||
virtual string pageTop();
|
virtual string pageTop();
|
||||||
virtual string iconPath(const string& mt);
|
|
||||||
virtual void suggest(const vector<string>uterms, vector<string>&sugg);
|
virtual void suggest(const vector<string>uterms, 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);
|
||||||
private:
|
private:
|
||||||
ResList *m_parent;
|
ResList *m_parent;
|
||||||
};
|
};
|
||||||
@ -161,12 +162,6 @@ string QtGuiResListPager::pageTop()
|
|||||||
return string();
|
return string();
|
||||||
}
|
}
|
||||||
|
|
||||||
string QtGuiResListPager::iconPath(const string& mtype)
|
|
||||||
{
|
|
||||||
string iconpath;
|
|
||||||
theconfig->getMimeIconName(mtype, &iconpath);
|
|
||||||
return iconpath;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtGuiResListPager::suggest(const vector<string>uterms, vector<string>&sugg)
|
void QtGuiResListPager::suggest(const vector<string>uterms, vector<string>&sugg)
|
||||||
{
|
{
|
||||||
@ -200,6 +195,24 @@ void QtGuiResListPager::suggest(const vector<string>uterms, vector<string>&sugg)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string QtGuiResListPager::iconUrl(RclConfig *config, Rcl::Doc& doc)
|
||||||
|
{
|
||||||
|
if (doc.ipath.empty()) {
|
||||||
|
vector<Rcl::Doc> docs;
|
||||||
|
docs.push_back(doc);
|
||||||
|
vector<string> paths;
|
||||||
|
ConfIndexer::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);
|
||||||
|
}
|
||||||
|
|
||||||
/////// /////// End reslistpager methods
|
/////// /////// End reslistpager methods
|
||||||
|
|
||||||
class PlainToRichQtReslist : public PlainToRich {
|
class PlainToRichQtReslist : public PlainToRich {
|
||||||
|
|||||||
@ -45,6 +45,7 @@
|
|||||||
#include "reslist.h"
|
#include "reslist.h"
|
||||||
#include "rclconfig.h"
|
#include "rclconfig.h"
|
||||||
#include "plaintorich.h"
|
#include "plaintorich.h"
|
||||||
|
#include "indexer.h"
|
||||||
|
|
||||||
// Compensate for the default and somewhat bizarre vertical placement
|
// Compensate for the default and somewhat bizarre vertical placement
|
||||||
// of text in cells
|
// of text in cells
|
||||||
@ -77,8 +78,8 @@ public:
|
|||||||
virtual bool append(const string& data, int idx, const Rcl::Doc& doc);
|
virtual bool append(const string& data, int idx, const Rcl::Doc& doc);
|
||||||
virtual string trans(const string& in);
|
virtual string trans(const string& in);
|
||||||
virtual const string &parFormat();
|
virtual const string &parFormat();
|
||||||
virtual string iconPath(const string& mt);
|
|
||||||
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;
|
||||||
};
|
};
|
||||||
@ -102,11 +103,21 @@ const string& ResTablePager::parFormat()
|
|||||||
return prefs.creslistformat;
|
return prefs.creslistformat;
|
||||||
}
|
}
|
||||||
|
|
||||||
string ResTablePager::iconPath(const string& mtype)
|
string ResTablePager::iconUrl(RclConfig *config, Rcl::Doc& doc)
|
||||||
{
|
{
|
||||||
string iconpath;
|
if (doc.ipath.empty()) {
|
||||||
theconfig->getMimeIconName(mtype, &iconpath);
|
vector<Rcl::Doc> docs;
|
||||||
return iconpath;
|
docs.push_back(doc);
|
||||||
|
vector<string> paths;
|
||||||
|
ConfIndexer::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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@ -138,7 +138,7 @@ void ResListPager::displayDoc(RclConfig *config,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Determine icon to display if any
|
// Determine icon to display if any
|
||||||
string iconpath = iconPath(config, doc.mimetype);
|
string iconurl = iconUrl(config, doc);
|
||||||
|
|
||||||
// Printable url: either utf-8 if transcoding succeeds, or url-encoded
|
// Printable url: either utf-8 if transcoding succeeds, or url-encoded
|
||||||
string url;
|
string url;
|
||||||
@ -225,7 +225,7 @@ void ResListPager::displayDoc(RclConfig *config,
|
|||||||
map<string,string> subs;
|
map<string,string> subs;
|
||||||
subs["A"] = !richabst.empty() ? richabst : "";
|
subs["A"] = !richabst.empty() ? richabst : "";
|
||||||
subs["D"] = datebuf;
|
subs["D"] = datebuf;
|
||||||
subs["I"] = iconpath;
|
subs["I"] = iconurl;
|
||||||
subs["i"] = doc.ipath;
|
subs["i"] = doc.ipath;
|
||||||
subs["K"] = !doc.meta[Rcl::Doc::keykw].empty() ?
|
subs["K"] = !doc.meta[Rcl::Doc::keykw].empty() ?
|
||||||
string("[") + escapeHtml(doc.meta[Rcl::Doc::keykw]) + "]" : "";
|
string("[") + escapeHtml(doc.meta[Rcl::Doc::keykw]) + "]" : "";
|
||||||
@ -379,12 +379,12 @@ string ResListPager::prevUrl()
|
|||||||
return "p-1";
|
return "p-1";
|
||||||
}
|
}
|
||||||
|
|
||||||
string ResListPager::iconPath(RclConfig *config, const string& mtype)
|
string ResListPager::iconUrl(RclConfig *config, Rcl::Doc& doc)
|
||||||
{
|
{
|
||||||
string iconpath;
|
string iconurl;
|
||||||
config->getMimeIconName(mtype, &iconpath);
|
config->getMimeIconName(doc.mimetype, &iconurl);
|
||||||
iconpath = cstr_fileu + iconpath;
|
iconurl = cstr_fileu + iconurl;
|
||||||
return iconpath;
|
return iconurl;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ResListPager::append(const string& data)
|
bool ResListPager::append(const string& data)
|
||||||
|
|||||||
@ -110,7 +110,7 @@ public:
|
|||||||
virtual string nextUrl();
|
virtual string nextUrl();
|
||||||
virtual string prevUrl();
|
virtual string prevUrl();
|
||||||
virtual string pageTop() {return string();}
|
virtual string pageTop() {return string();}
|
||||||
virtual string iconPath(RclConfig *, const string& mtype);
|
virtual string iconUrl(RclConfig *, Rcl::Doc& doc);
|
||||||
virtual void suggest(const vector<string>, vector<string>&sugg) {
|
virtual void suggest(const vector<string>, vector<string>&sugg) {
|
||||||
sugg.clear();
|
sugg.clear();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -58,6 +58,7 @@ using std::stack;
|
|||||||
#include "pathut.h"
|
#include "pathut.h"
|
||||||
#include "transcode.h"
|
#include "transcode.h"
|
||||||
#include "wipedir.h"
|
#include "wipedir.h"
|
||||||
|
#include "md5.h"
|
||||||
|
|
||||||
bool fsocc(const string &path, int *pc, long *blocks)
|
bool fsocc(const string &path, int *pc, long *blocks)
|
||||||
{
|
{
|
||||||
@ -559,6 +560,47 @@ int Pidfile::remove()
|
|||||||
return unlink(m_path.c_str());
|
return unlink(m_path.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Freedesktop standard paths for thumbnails
|
||||||
|
|
||||||
|
// Place for 256x256 files
|
||||||
|
static const string thmbdirlarge = ".thumbnails/large";
|
||||||
|
// 128x128
|
||||||
|
static const string thmbdirnormal = ".thumbnails/normal";
|
||||||
|
|
||||||
|
static void thumbname(const string& url, string& name)
|
||||||
|
{
|
||||||
|
string digest;
|
||||||
|
MD5String(url, digest);
|
||||||
|
MD5HexPrint(digest, name);
|
||||||
|
name += ".png";
|
||||||
|
}
|
||||||
|
|
||||||
|
bool thumbPathForUrl(const string& url, int size, string& path)
|
||||||
|
{
|
||||||
|
string name;
|
||||||
|
thumbname(url, name);
|
||||||
|
if (size <= 128) {
|
||||||
|
path = path_cat(path_home(), thmbdirnormal);
|
||||||
|
path = path_cat(path, name);
|
||||||
|
if (access(path.c_str(), R_OK) == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
path = path_cat(path_home(), thmbdirlarge);
|
||||||
|
path = path_cat(path, name);
|
||||||
|
if (access(path.c_str(), R_OK) == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// File does not exist. Path corresponds to the large version at this point,
|
||||||
|
// fix it if needed.
|
||||||
|
if (size <= 128) {
|
||||||
|
path = path_cat(path_home(), thmbdirnormal);
|
||||||
|
path = path_cat(path, name);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
#else // TEST_PATHUT
|
#else // TEST_PATHUT
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -645,7 +687,7 @@ int main(int argc, const char **argv)
|
|||||||
printf("pc %d, megabytes %ld\n", pc, blocks);
|
printf("pc %d, megabytes %ld\n", pc, blocks);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 1
|
#if 0
|
||||||
Pidfile pidfile("/tmp/pathutpidfile");
|
Pidfile pidfile("/tmp/pathutpidfile");
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
if ((pid = pidfile.open()) != 0) {
|
if ((pid = pidfile.open()) != 0) {
|
||||||
@ -659,6 +701,35 @@ int main(int argc, const char **argv)
|
|||||||
pidfile.remove();
|
pidfile.remove();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
if (argc != 2) {
|
||||||
|
fprintf(stderr, "Usage: thumbpath <filepath> <size>\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
string input = *argv++;
|
||||||
|
int size = atoi(*argv++);
|
||||||
|
|
||||||
|
if (input.empty()) {
|
||||||
|
fprintf(stderr, "Usage: thumbpath <filepath> <size>\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make absolute path if needed
|
||||||
|
if (input[0] != '/') {
|
||||||
|
input = path_absolute(input);
|
||||||
|
}
|
||||||
|
input = string("file://") + path_canon(input);
|
||||||
|
string path;
|
||||||
|
if (thumbPathForUrl(input, size, path)) {
|
||||||
|
cout << "Thumbnail for [" << input << "] [" << path << "]" << endl;
|
||||||
|
} else {
|
||||||
|
cout << "No thumbnail for [" << input << "] path [" << path << "]" <<endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
exit(0);
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -129,4 +129,11 @@ private:
|
|||||||
int flopen();
|
int flopen();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Freedesktop thumbnail standard path routine
|
||||||
|
// On return, path will have the appropriate value in all cases,
|
||||||
|
// returns true if the file already exists
|
||||||
|
extern bool thumbPathForUrl(const string& url, int size, string& path);
|
||||||
|
|
||||||
#endif /* _PATHUT_H_INCLUDED_ */
|
#endif /* _PATHUT_H_INCLUDED_ */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user