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;
|
||||
}
|
||||
|
||||
// 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.
|
||||
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
|
||||
// backend (if ever).
|
||||
string backend;
|
||||
map<string, string>::const_iterator it;
|
||||
if ((it = idoc.meta.find(Rcl::Doc::keybcknd)) != idoc.meta.end())
|
||||
backend = it->second;
|
||||
idoc.getmeta(Rcl::Doc::keybcknd, &backend);
|
||||
|
||||
if (backend.empty() || !backend.compare("FS")) {
|
||||
// Filesystem document. Intern from file.
|
||||
@ -412,16 +410,14 @@ FileInterner::FileInterner(const Rcl::Doc& idoc, RclConfig *cnf,
|
||||
}
|
||||
init(fn, &st, cnf, flags, &idoc.mimetype);
|
||||
} else if (!backend.compare("BGL")) {
|
||||
string data;
|
||||
Rcl::Doc dotdoc;
|
||||
map<string,string>::const_iterator it =
|
||||
idoc.meta.find(Rcl::Doc::keyudi);
|
||||
if (it == idoc.meta.end() || it->second.empty()) {
|
||||
string udi;
|
||||
if (!idoc.getmeta(Rcl::Doc::keyudi, &udi) || udi.empty()) {
|
||||
LOGERR(("FileInterner:: no udi in idoc\n"));
|
||||
return;
|
||||
}
|
||||
string udi = it->second;
|
||||
|
||||
string data;
|
||||
Rcl::Doc dotdoc;
|
||||
{
|
||||
PTMutexLocker locker(o_beagler_mutex);
|
||||
// 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"));
|
||||
QString title;
|
||||
map<string,string>::const_iterator meta_it;
|
||||
if ((meta_it = doc.meta.find(Rcl::Doc::keytt)) != doc.meta.end()
|
||||
&& !meta_it->second.empty()) {
|
||||
title = QString::fromUtf8(meta_it->second.c_str(),
|
||||
meta_it->second.length());
|
||||
string ctitle;
|
||||
if (doc.getmeta(Rcl::Doc::keytt, &ctitle)) {
|
||||
title = QString::fromUtf8(ctitle.c_str(), ctitle.length());
|
||||
} else {
|
||||
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);
|
||||
string tiptxt = url + string("\n");
|
||||
tiptxt += doc.mimetype + " " + string(datebuf) + "\n";
|
||||
if (meta_it != doc.meta.end() && !meta_it->second.empty())
|
||||
tiptxt += meta_it->second + "\n";
|
||||
if (!ctitle.empty())
|
||||
tiptxt += ctitle + "\n";
|
||||
pvTab->setTabToolTip(curidx,
|
||||
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
|
||||
map<string,string>::const_iterator udit = idoc.meta.find(Rcl::Doc::keyudi);
|
||||
if (udit != idoc.meta.end())
|
||||
historyEnterDoc(g_dynconf, udit->second);
|
||||
string udi;
|
||||
if (idoc.getmeta(Rcl::Doc::keyudi, &udi)) {
|
||||
historyEnterDoc(g_dynconf, udi);
|
||||
}
|
||||
|
||||
editor->setFocus();
|
||||
emit(previewExposed(this, m_searchId, docnum));
|
||||
|
||||
@ -1213,9 +1213,7 @@ void RclMain::startNativeViewer(Rcl::Doc doc)
|
||||
cmdplusattr = theconfig->getMimeViewerDef("application/x-all", "");
|
||||
} else {
|
||||
string apptag;
|
||||
map<string,string>::const_iterator it;
|
||||
if ((it = doc.meta.find(Rcl::Doc::keyapptg)) != doc.meta.end())
|
||||
apptag = it->second;
|
||||
doc.getmeta(Rcl::Doc::keyapptg, &apptag);
|
||||
cmdplusattr = theconfig->getMimeViewerDef(doc.mimetype, apptag);
|
||||
}
|
||||
|
||||
|
||||
@ -206,9 +206,7 @@ void ResListPager::displayDoc(RclConfig *config,
|
||||
}
|
||||
|
||||
string apptag;
|
||||
map<string,string>::const_iterator it;
|
||||
if ((it = doc.meta.find(Rcl::Doc::keyapptg)) != doc.meta.end())
|
||||
apptag = it->second;
|
||||
doc.getmeta(Rcl::Doc::keyapptg, &apptag);
|
||||
|
||||
if (!config->getMimeViewerDef(doc.mimetype, apptag).empty()) {
|
||||
linksbuf << "<a href=\"E" << docnumforlinks << "\">"
|
||||
|
||||
@ -134,6 +134,19 @@ class Doc {
|
||||
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;
|
||||
|
||||
// The official names for recoll native fields when used in a text
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user