|
a/src/qtgui/restable.cpp |
|
b/src/qtgui/restable.cpp |
|
... |
|
... |
203 |
}
|
203 |
}
|
204 |
return datebuf;
|
204 |
return datebuf;
|
205 |
}
|
205 |
}
|
206 |
|
206 |
|
207 |
// Static map to translate from internal column names to displayable ones
|
207 |
// Static map to translate from internal column names to displayable ones
|
208 |
map<string, string> RecollModel::o_displayableFields =
|
208 |
map<string, QString> RecollModel::o_displayableFields;
|
209 |
create_map<string, string>
|
|
|
210 |
("abstract", QT_TR_NOOP("Abstract"))
|
|
|
211 |
("author", QT_TR_NOOP("Author"))
|
|
|
212 |
("dbytes", QT_TR_NOOP("Document size"))
|
|
|
213 |
("dmtime", QT_TR_NOOP("Document date"))
|
|
|
214 |
("fbytes", QT_TR_NOOP("File size"))
|
|
|
215 |
("filename", QT_TR_NOOP("File name"))
|
|
|
216 |
("fmtime", QT_TR_NOOP("File date"))
|
|
|
217 |
("ipath", QT_TR_NOOP(" Ipath"))
|
|
|
218 |
("keywords", QT_TR_NOOP("Keywords"))
|
|
|
219 |
("mtype", QT_TR_NOOP("Mime type"))
|
|
|
220 |
("origcharset", QT_TR_NOOP("Original character set"))
|
|
|
221 |
("relevancyrating", QT_TR_NOOP("Relevancy rating"))
|
|
|
222 |
("title", QT_TR_NOOP("Title"))
|
|
|
223 |
("url", QT_TR_NOOP("URL"))
|
|
|
224 |
("mtime", QT_TR_NOOP("Mtime"))
|
|
|
225 |
("date", QT_TR_NOOP("Date"))
|
|
|
226 |
("datetime", QT_TR_NOOP("Date and time"))
|
|
|
227 |
;
|
|
|
228 |
|
209 |
|
229 |
FieldGetter *RecollModel::chooseGetter(const string& field)
|
210 |
FieldGetter *RecollModel::chooseGetter(const string& field)
|
230 |
{
|
211 |
{
|
231 |
if (!stringlowercmp("date", field))
|
212 |
if (!stringlowercmp("date", field))
|
232 |
return dategetter;
|
213 |
return dategetter;
|
|
... |
|
... |
247 |
}
|
228 |
}
|
248 |
|
229 |
|
249 |
RecollModel::RecollModel(const QStringList fields, QObject *parent)
|
230 |
RecollModel::RecollModel(const QStringList fields, QObject *parent)
|
250 |
: QAbstractTableModel(parent), m_ignoreSort(false)
|
231 |
: QAbstractTableModel(parent), m_ignoreSort(false)
|
251 |
{
|
232 |
{
|
|
|
233 |
// Initialize the translated map for column headers
|
|
|
234 |
o_displayableFields["abstract"] = tr("Abstract");
|
|
|
235 |
o_displayableFields["author"] = tr("Author");
|
|
|
236 |
o_displayableFields["dbytes"] = tr("Document size");
|
|
|
237 |
o_displayableFields["dmtime"] = tr("Document date");
|
|
|
238 |
o_displayableFields["fbytes"] = tr("File size");
|
|
|
239 |
o_displayableFields["filename"] = tr("File name");
|
|
|
240 |
o_displayableFields["fmtime"] = tr("File date");
|
|
|
241 |
o_displayableFields["ipath"] = tr("Ipath");
|
|
|
242 |
o_displayableFields["keywords"] = tr("Keywords");
|
|
|
243 |
o_displayableFields["mtype"] = tr("Mime type");
|
|
|
244 |
o_displayableFields["origcharset"] = tr("Original character set");
|
|
|
245 |
o_displayableFields["relevancyrating"] = tr("Relevancy rating");
|
|
|
246 |
o_displayableFields["title"] = tr("Title");
|
|
|
247 |
o_displayableFields["url"] = tr("URL");
|
|
|
248 |
o_displayableFields["mtime"] = tr("Mtime");
|
|
|
249 |
o_displayableFields["date"] = tr("Date");
|
|
|
250 |
o_displayableFields["datetime"] = tr("Date and time");
|
|
|
251 |
|
252 |
// Add dynamic "stored" fields to the full column list. This
|
252 |
// Add dynamic "stored" fields to the full column list. This
|
253 |
// could be protected to be done only once, but it's no real
|
253 |
// could be protected to be done only once, but it's no real
|
254 |
// problem
|
254 |
// problem
|
255 |
if (theconfig) {
|
255 |
if (theconfig) {
|
256 |
const set<string>& stored = theconfig->getStoredFields();
|
256 |
const set<string>& stored = theconfig->getStoredFields();
|
257 |
for (set<string>::const_iterator it = stored.begin();
|
257 |
for (set<string>::const_iterator it = stored.begin();
|
258 |
it != stored.end(); it++) {
|
258 |
it != stored.end(); it++) {
|
259 |
if (o_displayableFields.find(*it) == o_displayableFields.end()) {
|
259 |
if (o_displayableFields.find(*it) == o_displayableFields.end()) {
|
260 |
o_displayableFields[*it] = *it;
|
260 |
o_displayableFields[*it] = QString::fromUtf8(it->c_str());
|
261 |
}
|
261 |
}
|
262 |
}
|
262 |
}
|
263 |
}
|
263 |
}
|
264 |
|
264 |
|
265 |
// Construct the actual list of column names
|
265 |
// Construct the actual list of column names
|
|
... |
|
... |
342 |
if (orientation == Qt::Vertical && role == Qt::DisplayRole) {
|
342 |
if (orientation == Qt::Vertical && role == Qt::DisplayRole) {
|
343 |
return idx;
|
343 |
return idx;
|
344 |
}
|
344 |
}
|
345 |
if (orientation == Qt::Horizontal && role == Qt::DisplayRole &&
|
345 |
if (orientation == Qt::Horizontal && role == Qt::DisplayRole &&
|
346 |
idx < int(m_fields.size())) {
|
346 |
idx < int(m_fields.size())) {
|
347 |
map<string, string>::const_iterator it =
|
347 |
map<string, QString>::const_iterator it =
|
348 |
o_displayableFields.find(m_fields[idx]);
|
348 |
o_displayableFields.find(m_fields[idx]);
|
349 |
if (it == o_displayableFields.end())
|
349 |
if (it == o_displayableFields.end())
|
350 |
return QString::fromUtf8(m_fields[idx].c_str());
|
350 |
return QString::fromUtf8(m_fields[idx].c_str());
|
351 |
else
|
351 |
else
|
352 |
return QString::fromUtf8(it->second.c_str());
|
352 |
return it->second;
|
353 |
}
|
353 |
}
|
354 |
return QVariant();
|
354 |
return QVariant();
|
355 |
}
|
355 |
}
|
356 |
|
356 |
|
357 |
QVariant RecollModel::data(const QModelIndex& index, int role) const
|
357 |
QVariant RecollModel::data(const QModelIndex& index, int role) const
|
|
... |
|
... |
863 |
|
863 |
|
864 |
m_popcolumn = header->logicalIndexAt(pos);
|
864 |
m_popcolumn = header->logicalIndexAt(pos);
|
865 |
if (m_popcolumn < 0)
|
865 |
if (m_popcolumn < 0)
|
866 |
return;
|
866 |
return;
|
867 |
|
867 |
|
868 |
const map<string, string>& allfields = m_model->getAllFields();
|
868 |
const map<string, QString>& allfields = m_model->getAllFields();
|
869 |
const vector<string>& fields = m_model->getFields();
|
869 |
const vector<string>& fields = m_model->getFields();
|
870 |
QMenu *popup = new QMenu(this);
|
870 |
QMenu *popup = new QMenu(this);
|
871 |
|
871 |
|
872 |
popup->addAction(tr("&Reset sort"), this, SLOT(resetSort()));
|
872 |
popup->addAction(tr("&Reset sort"), this, SLOT(resetSort()));
|
873 |
popup->addSeparator();
|
873 |
popup->addSeparator();
|
|
... |
|
... |
877 |
|
877 |
|
878 |
popup->addAction(tr("&Delete column"), this, SLOT(deleteColumn()));
|
878 |
popup->addAction(tr("&Delete column"), this, SLOT(deleteColumn()));
|
879 |
popup->addSeparator();
|
879 |
popup->addSeparator();
|
880 |
|
880 |
|
881 |
QAction *act;
|
881 |
QAction *act;
|
882 |
for (map<string, string>::const_iterator it = allfields.begin();
|
882 |
for (map<string, QString>::const_iterator it = allfields.begin();
|
883 |
it != allfields.end(); it++) {
|
883 |
it != allfields.end(); it++) {
|
884 |
if (std::find(fields.begin(), fields.end(), it->first) != fields.end())
|
884 |
if (std::find(fields.begin(), fields.end(), it->first) != fields.end())
|
885 |
continue;
|
885 |
continue;
|
886 |
act = new QAction(tr("Add \"")+tr(it->second.c_str())+tr("\" column"),
|
886 |
act = new QAction(tr("Add \"%1\" column").arg(it->second), popup);
|
887 |
popup);
|
|
|
888 |
act->setData(QString::fromUtf8(it->first.c_str()));
|
887 |
act->setData(QString::fromUtf8(it->first.c_str()));
|
889 |
connect(act, SIGNAL(triggered(bool)), this , SLOT(addColumn()));
|
888 |
connect(act, SIGNAL(triggered(bool)), this , SLOT(addColumn()));
|
890 |
popup->addAction(act);
|
889 |
popup->addAction(act);
|
891 |
}
|
890 |
}
|
892 |
popup->popup(mapToGlobal(pos));
|
891 |
popup->popup(mapToGlobal(pos));
|