GUI restable: fix sorting by file and doc size

This commit is contained in:
"Jean-Francois Dockes ext:(%22)
2011-07-20 10:44:04 +02:00
parent 6b04fe7f2c
commit 48e86c99b5
5 changed files with 48 additions and 13 deletions
+16
View File
@@ -154,6 +154,16 @@ static string gengetter(const string& fld, const Rcl::Doc& doc)
return it->second;
}
static string sizegetter(const string& fld, const Rcl::Doc& doc)
{
map<string, string>::const_iterator it = doc.meta.find(fld);
if (it == doc.meta.end()) {
return string();
}
off_t size = atoll(it->second.c_str());
return displayableBytes(size) + " (" + it->second + ")";
}
static string dategetter(const string&, const Rcl::Doc& doc)
{
char datebuf[100];
@@ -162,7 +172,11 @@ static string dategetter(const string&, const Rcl::Doc& doc)
time_t mtime = doc.dmtime.empty() ?
atol(doc.fmtime.c_str()) : atol(doc.dmtime.c_str());
struct tm *tm = localtime(&mtime);
#ifndef sun
strftime(datebuf, 99, "%Y-%m-%d", tm);
#else
strftime(datebuf, 99, "%x", tm);
#endif
}
return datebuf;
}
@@ -212,6 +226,8 @@ FieldGetter *RecollModel::chooseGetter(const string& field)
return dategetter;
else if (!stringlowercmp("datetime", field))
return datetimegetter;
else if (!stringlowercmp("bytes", field.substr(1)))
return sizegetter;
else
return gengetter;
}