added getmeta() method to Rcl::Doc and use in misc places
This commit is contained in:
parent
dc3aa5d564
commit
036937e8bf
@ -369,7 +369,7 @@ void FileInterner::initcommon(RclConfig *cnf, int flags)
|
|||||||
m_targetMType = cstr_textplain;
|
m_targetMType = cstr_textplain;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We used a single beagle cache object to access beagle data. We protect it
|
// We use a single beagle cache object to access beagle data. We protect it
|
||||||
// against multiple thread access.
|
// against multiple thread access.
|
||||||
static PTMutexInit o_beagler_mutex;
|
static PTMutexInit o_beagler_mutex;
|
||||||
|
|
||||||
@ -391,9 +391,7 @@ FileInterner::FileInterner(const Rcl::Doc& idoc, RclConfig *cnf,
|
|||||||
// and use some kind of backstore object factory next time we add a
|
// and use some kind of backstore object factory next time we add a
|
||||||
// backend (if ever).
|
// backend (if ever).
|
||||||
string backend;
|
string backend;
|
||||||
map<string, string>::const_iterator it;
|
idoc.getmeta(Rcl::Doc::keybcknd, &backend);
|
||||||
if ((it = idoc.meta.find(Rcl::Doc::keybcknd)) != idoc.meta.end())
|
|
||||||
backend = it->second;
|
|
||||||
|
|
||||||
if (backend.empty() || !backend.compare("FS")) {
|
if (backend.empty() || !backend.compare("FS")) {
|
||||||
// Filesystem document. Intern from file.
|
// Filesystem document. Intern from file.
|
||||||
@ -412,16 +410,14 @@ FileInterner::FileInterner(const Rcl::Doc& idoc, RclConfig *cnf,
|
|||||||
}
|
}
|
||||||
init(fn, &st, cnf, flags, &idoc.mimetype);
|
init(fn, &st, cnf, flags, &idoc.mimetype);
|
||||||
} else if (!backend.compare("BGL")) {
|
} else if (!backend.compare("BGL")) {
|
||||||
string data;
|
string udi;
|
||||||
Rcl::Doc dotdoc;
|
if (!idoc.getmeta(Rcl::Doc::keyudi, &udi) || udi.empty()) {
|
||||||
map<string,string>::const_iterator it =
|
|
||||||
idoc.meta.find(Rcl::Doc::keyudi);
|
|
||||||
if (it == idoc.meta.end() || it->second.empty()) {
|
|
||||||
LOGERR(("FileInterner:: no udi in idoc\n"));
|
LOGERR(("FileInterner:: no udi in idoc\n"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
string udi = it->second;
|
|
||||||
|
|
||||||
|
string data;
|
||||||
|
Rcl::Doc dotdoc;
|
||||||
{
|
{
|
||||||
PTMutexLocker locker(o_beagler_mutex);
|
PTMutexLocker locker(o_beagler_mutex);
|
||||||
// Retrieve from our webcache (beagle data). The beagler
|
// Retrieve from our webcache (beagle data). The beagler
|
||||||
|
|||||||
@ -504,11 +504,9 @@ void Preview::setCurTabProps(const Rcl::Doc &doc, int docnum)
|
|||||||
{
|
{
|
||||||
LOGDEB1(("PreviewTextEdit::setCurTabProps\n"));
|
LOGDEB1(("PreviewTextEdit::setCurTabProps\n"));
|
||||||
QString title;
|
QString title;
|
||||||
map<string,string>::const_iterator meta_it;
|
string ctitle;
|
||||||
if ((meta_it = doc.meta.find(Rcl::Doc::keytt)) != doc.meta.end()
|
if (doc.getmeta(Rcl::Doc::keytt, &ctitle)) {
|
||||||
&& !meta_it->second.empty()) {
|
title = QString::fromUtf8(ctitle.c_str(), ctitle.length());
|
||||||
title = QString::fromUtf8(meta_it->second.c_str(),
|
|
||||||
meta_it->second.length());
|
|
||||||
} else {
|
} else {
|
||||||
title = QString::fromLocal8Bit(path_getsimple(doc.url).c_str());
|
title = QString::fromLocal8Bit(path_getsimple(doc.url).c_str());
|
||||||
}
|
}
|
||||||
@ -531,8 +529,8 @@ void Preview::setCurTabProps(const Rcl::Doc &doc, int docnum)
|
|||||||
printableUrl(theconfig->getDefCharset(), doc.url, url);
|
printableUrl(theconfig->getDefCharset(), doc.url, url);
|
||||||
string tiptxt = url + string("\n");
|
string tiptxt = url + string("\n");
|
||||||
tiptxt += doc.mimetype + " " + string(datebuf) + "\n";
|
tiptxt += doc.mimetype + " " + string(datebuf) + "\n";
|
||||||
if (meta_it != doc.meta.end() && !meta_it->second.empty())
|
if (!ctitle.empty())
|
||||||
tiptxt += meta_it->second + "\n";
|
tiptxt += ctitle + "\n";
|
||||||
pvTab->setTabToolTip(curidx,
|
pvTab->setTabToolTip(curidx,
|
||||||
QString::fromUtf8(tiptxt.c_str(), tiptxt.length()));
|
QString::fromUtf8(tiptxt.c_str(), tiptxt.length()));
|
||||||
|
|
||||||
@ -966,9 +964,10 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum)
|
|||||||
|
|
||||||
|
|
||||||
// Enter document in document history
|
// Enter document in document history
|
||||||
map<string,string>::const_iterator udit = idoc.meta.find(Rcl::Doc::keyudi);
|
string udi;
|
||||||
if (udit != idoc.meta.end())
|
if (idoc.getmeta(Rcl::Doc::keyudi, &udi)) {
|
||||||
historyEnterDoc(g_dynconf, udit->second);
|
historyEnterDoc(g_dynconf, udi);
|
||||||
|
}
|
||||||
|
|
||||||
editor->setFocus();
|
editor->setFocus();
|
||||||
emit(previewExposed(this, m_searchId, docnum));
|
emit(previewExposed(this, m_searchId, docnum));
|
||||||
|
|||||||
@ -1213,9 +1213,7 @@ void RclMain::startNativeViewer(Rcl::Doc doc)
|
|||||||
cmdplusattr = theconfig->getMimeViewerDef("application/x-all", "");
|
cmdplusattr = theconfig->getMimeViewerDef("application/x-all", "");
|
||||||
} else {
|
} else {
|
||||||
string apptag;
|
string apptag;
|
||||||
map<string,string>::const_iterator it;
|
doc.getmeta(Rcl::Doc::keyapptg, &apptag);
|
||||||
if ((it = doc.meta.find(Rcl::Doc::keyapptg)) != doc.meta.end())
|
|
||||||
apptag = it->second;
|
|
||||||
cmdplusattr = theconfig->getMimeViewerDef(doc.mimetype, apptag);
|
cmdplusattr = theconfig->getMimeViewerDef(doc.mimetype, apptag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -206,9 +206,7 @@ void ResListPager::displayDoc(RclConfig *config,
|
|||||||
}
|
}
|
||||||
|
|
||||||
string apptag;
|
string apptag;
|
||||||
map<string,string>::const_iterator it;
|
doc.getmeta(Rcl::Doc::keyapptg, &apptag);
|
||||||
if ((it = doc.meta.find(Rcl::Doc::keyapptg)) != doc.meta.end())
|
|
||||||
apptag = it->second;
|
|
||||||
|
|
||||||
if (!config->getMimeViewerDef(doc.mimetype, apptag).empty()) {
|
if (!config->getMimeViewerDef(doc.mimetype, apptag).empty()) {
|
||||||
linksbuf << "<a href=\"E" << docnumforlinks << "\">"
|
linksbuf << "<a href=\"E" << docnumforlinks << "\">"
|
||||||
|
|||||||
@ -134,6 +134,19 @@ class Doc {
|
|||||||
xdocid = 0;
|
xdocid = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get value for named field. If value pointer is 0, just test existence */
|
||||||
|
bool getmeta(const string& nm, string *value = 0) const
|
||||||
|
{
|
||||||
|
map<string,string>::const_iterator it = meta.find(nm);
|
||||||
|
if (it != meta.end()) {
|
||||||
|
if (value)
|
||||||
|
*value = it->second;
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void dump(bool dotext=false) const;
|
void dump(bool dotext=false) const;
|
||||||
|
|
||||||
// The official names for recoll native fields when used in a text
|
// The official names for recoll native fields when used in a text
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user