added open-ended field name handling

This commit is contained in:
dockes
2007-06-19 08:36:24 +00:00
parent c4b099e8d3
commit 0c74bd6e36
15 changed files with 176 additions and 176 deletions
+11 -7
View File
@@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: preview_w.cpp,v 1.20 2007-06-12 13:31:38 dockes Exp $ (C) 2005 J.F.Dockes";
static char rcsid[] = "@(#$Id: preview_w.cpp,v 1.21 2007-06-19 08:36:24 dockes Exp $ (C) 2005 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@@ -400,8 +400,12 @@ QTextEdit *Preview::addEditorTab()
void Preview::setCurTabProps(const string &fn, const Rcl::Doc &doc,
int docnum)
{
QString title = QString::fromUtf8(doc.title.c_str(),
doc.title.length());
QString title;
map<string,string>::const_iterator meta_it;
if ((meta_it = doc.meta.find("title")) != doc.meta.end()) {
title = QString::fromUtf8(meta_it->second.c_str(),
meta_it->second.length());
}
if (title.length() > 20) {
title = title.left(10) + "..." + title.right(10);
}
@@ -421,8 +425,8 @@ void Preview::setCurTabProps(const string &fn, const Rcl::Doc &doc,
printableUrl(doc.url, url);
string tiptxt = url + string("\n");
tiptxt += doc.mimetype + " " + string(datebuf) + "\n";
if (!doc.title.empty())
tiptxt += doc.title + "\n";
if (meta_it != doc.meta.end() && !meta_it->second.empty())
tiptxt += meta_it->second + "\n";
pvTab->setTabToolTip(w,QString::fromUtf8(tiptxt.c_str(), tiptxt.length()));
for (list<TabData>::iterator it = tabData.begin();
@@ -607,8 +611,8 @@ bool Preview::loadFileInCurrentTab(string fn, size_t sz, const Rcl::Doc &idoc,
Rcl::Doc doc = idoc;
bool cancel = false;
if (doc.title.empty())
doc.title = path_getsimple(doc.url);
if (doc.meta["title"].empty())
doc.meta["title"] = path_getsimple(doc.url);
setCurTabProps(fn, doc, docnum);
+8 -8
View File
@@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: reslist.cpp,v 1.26 2007-06-13 17:03:23 dockes Exp $ (C) 2005 J.F.Dockes";
static char rcsid[] = "@(#$Id: reslist.cpp,v 1.27 2007-06-19 08:36:24 dockes Exp $ (C) 2005 J.F.Dockes";
#endif
#include <time.h>
@@ -399,7 +399,7 @@ void ResList::resultPageNext()
if (percent == -1) {
percent = 0;
// Document not available, maybe other further, will go on.
doc.abstract = string(tr("Unavailable document").utf8());
doc.meta["abstract"] = string(tr("Unavailable document").utf8());
}
// Determine icon to display if any
@@ -426,8 +426,8 @@ void ResList::resultPageNext()
printableUrl(doc.url, url);
// Make title out of file name if none yet
if (doc.title.empty()) {
doc.title = path_getsimple(url);
if (doc.meta["title"].empty()) {
doc.meta["title"] = path_getsimple(url);
}
// Result number
@@ -469,7 +469,7 @@ void ResList::resultPageNext()
(doc.syntabs || prefs.queryReplaceAbstract)) {
abstract = m_docSource->getAbstract(doc);
} else {
abstract = doc.abstract;
abstract = doc.meta["abstract"];
}
// No need to call escapeHtml(), plaintorich handles it
string richabst;
@@ -505,14 +505,14 @@ void ResList::resultPageNext()
map<char,string> subs;
subs['A'] = !richabst.empty() ? richabst + "<br>" : "";
subs['D'] = datebuf;
subs['K'] = !doc.keywords.empty() ? escapeHtml(doc.keywords) + "<br>"
: "";
subs['K'] = !doc.meta["keywords"].empty() ?
escapeHtml(doc.meta["keywords"]) + "<br>" : "";
subs['L'] = linksbuf;
subs['N'] = numbuf;
subs['M'] = doc.mimetype;
subs['R'] = perbuf;
subs['S'] = sizebuf;
subs['T'] = escapeHtml(doc.title);
subs['T'] = escapeHtml(doc.meta["title"]);
subs['U'] = url;
string formatted;