restable.cpp (recoll-1.27.11) | : | restable.cpp (recoll-1.27.12) | ||
---|---|---|---|---|
skipping to change at line 73 | skipping to change at line 73 | |||
// of text in cells | // of text in cells | |||
static const int ROWHEIGHTPAD = 2; | static const int ROWHEIGHTPAD = 2; | |||
static const int TEXTINCELLVTRANS = -4; | static const int TEXTINCELLVTRANS = -4; | |||
// Adjust font size from prefs, display is slightly different here | // Adjust font size from prefs, display is slightly different here | |||
static const int fsadjustdetail = 1; | static const int fsadjustdetail = 1; | |||
static const int fsadjusttable = 1; | static const int fsadjusttable = 1; | |||
static PlainToRichQtReslist g_hiliter; | static PlainToRichQtReslist g_hiliter; | |||
static const char *settingskey_fieldlist="/Recoll/prefs/query/restableFields"; | ||||
static const char *settingskey_fieldwiths="/Recoll/prefs/query/restableWidths"; | ||||
static const char *settingskey_splittersizes="resTableSplitterSizes"; | ||||
////////////////////////////////////////////////////////////////////////// | ////////////////////////////////////////////////////////////////////////// | |||
// Restable "pager". We use it to print details for a document in the | // Restable "pager". We use it to print details for a document in the | |||
// detail area | // detail area | |||
/// | /// | |||
class ResTablePager : public ResListPager { | class ResTablePager : public ResListPager { | |||
public: | public: | |||
ResTablePager(ResTable *p) | ResTablePager(ResTable *p) | |||
: ResListPager(1, prefs.alwaysSnippets), m_parent(p) | : ResListPager(1, prefs.alwaysSnippets), m_parent(p) | |||
{} | {} | |||
virtual bool append(const string& data) override; | virtual bool append(const string& data) override; | |||
skipping to change at line 569 | skipping to change at line 573 | |||
prefs.reslistfontsize : prefs.reslistfontsize - fsadjusttable; | prefs.reslistfontsize : prefs.reslistfontsize - fsadjusttable; | |||
if (fs > 0) | if (fs > 0) | |||
font.setPointSize(fs); | font.setPointSize(fs); | |||
QFontMetrics fm(font); | QFontMetrics fm(font); | |||
header->setDefaultSectionSize(fm.height() + ROWHEIGHTPAD); | header->setDefaultSectionSize(fm.height() + ROWHEIGHTPAD); | |||
} | } | |||
} | } | |||
void ResTable::init() | void ResTable::init() | |||
{ | { | |||
if (!(m_model = new RecollModel(prefs.restableFields, this))) | QSettings settings; | |||
auto restableFields = settings.value(settingskey_fieldlist).toStringList(); | ||||
if (restableFields.empty()) { | ||||
restableFields.push_back("date"); | ||||
restableFields.push_back("title"); | ||||
restableFields.push_back("filename"); | ||||
restableFields.push_back("author"); | ||||
restableFields.push_back("url"); | ||||
} | ||||
if (!(m_model = new RecollModel(restableFields, this))) | ||||
return; | return; | |||
tableView->setModel(m_model); | tableView->setModel(m_model); | |||
tableView->setMouseTracking(true); | tableView->setMouseTracking(true); | |||
tableView->setSelectionBehavior(QAbstractItemView::SelectRows); | tableView->setSelectionBehavior(QAbstractItemView::SelectRows); | |||
tableView->setItemDelegate(new ResTableDelegate(this)); | tableView->setItemDelegate(new ResTableDelegate(this)); | |||
tableView->setContextMenuPolicy(Qt::CustomContextMenu); | tableView->setContextMenuPolicy(Qt::CustomContextMenu); | |||
new QShortcut(QKeySequence("Ctrl+o"), this, SLOT(menuEdit())); | new QShortcut(QKeySequence("Ctrl+o"), this, SLOT(menuEdit())); | |||
new QShortcut(QKeySequence("Ctrl+Shift+o"), this, SLOT(menuEditAndQuit())); | new QShortcut(QKeySequence("Ctrl+Shift+o"), this, SLOT(menuEditAndQuit())); | |||
new QShortcut(QKeySequence("Ctrl+d"), this, SLOT(menuPreview())); | new QShortcut(QKeySequence("Ctrl+d"), this, SLOT(menuPreview())); | |||
new QShortcut(QKeySequence("Ctrl+e"), this, SLOT(menuShowSnippets())); | new QShortcut(QKeySequence("Ctrl+e"), this, SLOT(menuShowSnippets())); | |||
connect(tableView, SIGNAL(customContextMenuRequested(const QPoint&)), | connect(tableView, SIGNAL(customContextMenuRequested(const QPoint&)), | |||
this, SLOT(createPopupMenu(const QPoint&))); | this, SLOT(createPopupMenu(const QPoint&))); | |||
QHeaderView *header = tableView->horizontalHeader(); | QHeaderView *header = tableView->horizontalHeader(); | |||
if (header) { | if (header) { | |||
if (int(prefs.restableColWidths.size()) == header->count()) { | QString qw = settings.value(settingskey_fieldwiths).toString(); | |||
vector<string> vw; | ||||
stringToStrings(qs2utf8s(qw), vw); | ||||
vector<int> restableColWidths; | ||||
for (const auto& w : vw) { | ||||
restableColWidths.push_back(atoi(w.c_str())); | ||||
} | ||||
if (int(restableColWidths.size()) == header->count()) { | ||||
for (int i = 0; i < header->count(); i++) { | for (int i = 0; i < header->count(); i++) { | |||
header->resizeSection(i, prefs.restableColWidths[i]); | header->resizeSection(i, restableColWidths[i]); | |||
} | } | |||
} | } | |||
header->setSortIndicatorShown(true); | header->setSortIndicatorShown(true); | |||
header->setSortIndicator(-1, Qt::AscendingOrder); | header->setSortIndicator(-1, Qt::AscendingOrder); | |||
header->setContextMenuPolicy(Qt::CustomContextMenu); | header->setContextMenuPolicy(Qt::CustomContextMenu); | |||
header->setStretchLastSection(1); | header->setStretchLastSection(1); | |||
connect(header, SIGNAL(sectionResized(int,int,int)), | connect(header, SIGNAL(sectionResized(int,int,int)), | |||
this, SLOT(saveColState())); | this, SLOT(saveColState())); | |||
connect(header, SIGNAL(customContextMenuRequested(const QPoint&)), | connect(header, SIGNAL(customContextMenuRequested(const QPoint&)), | |||
this, SLOT(createHeaderPopupMenu(const QPoint&))); | this, SLOT(createHeaderPopupMenu(const QPoint&))); | |||
skipping to change at line 619 | skipping to change at line 639 | |||
connect(sc, SIGNAL(activated()), tableView->selectionModel(), SLOT(clear())) ; | connect(sc, SIGNAL(activated()), tableView->selectionModel(), SLOT(clear())) ; | |||
connect(tableView->selectionModel(), | connect(tableView->selectionModel(), | |||
SIGNAL(currentChanged(const QModelIndex&, const QModelIndex &)), | SIGNAL(currentChanged(const QModelIndex&, const QModelIndex &)), | |||
this, SLOT(onTableView_currentChanged(const QModelIndex&))); | this, SLOT(onTableView_currentChanged(const QModelIndex&))); | |||
connect(tableView, SIGNAL(doubleClicked(const QModelIndex&)), | connect(tableView, SIGNAL(doubleClicked(const QModelIndex&)), | |||
this, SLOT(onDoubleClick(const QModelIndex&))); | this, SLOT(onDoubleClick(const QModelIndex&))); | |||
m_pager = new ResTablePager(this); | m_pager = new ResTablePager(this); | |||
m_pager->setHighLighter(&g_hiliter); | m_pager->setHighLighter(&g_hiliter); | |||
QSettings settings; | ||||
QVariant saved = settings.value("resTableSplitterSizes"); | ||||
if (saved != QVariant()) { | ||||
splitter->restoreState(saved.toByteArray()); | ||||
} else { | ||||
QList<int> sizes; | ||||
sizes << 355 << 125; | ||||
splitter->setSizes(sizes); | ||||
} | ||||
deleteZ(textBrowser); | deleteZ(textBrowser); | |||
m_detail = new ResTableDetailArea(this); | m_detail = new ResTableDetailArea(this); | |||
m_detail->setReadOnly(true); | m_detail->setReadOnly(true); | |||
m_detail->setUndoRedoEnabled(false); | m_detail->setUndoRedoEnabled(false); | |||
m_detail->setOpenLinks(false); | m_detail->setOpenLinks(false); | |||
m_detail->init(); | m_detail->init(); | |||
// signals and slots connections | // signals and slots connections | |||
connect(m_detail, SIGNAL(anchorClicked(const QUrl &)), | connect(m_detail, SIGNAL(anchorClicked(const QUrl &)), | |||
this, SLOT(linkWasClicked(const QUrl &))); | this, SLOT(linkWasClicked(const QUrl &))); | |||
splitter->addWidget(m_detail); | splitter->addWidget(m_detail); | |||
splitter->setOrientation(Qt::Vertical); | splitter->setOrientation(Qt::Vertical); | |||
QVariant saved = settings.value(settingskey_splittersizes); | ||||
if (saved != QVariant()) { | ||||
splitter->restoreState(saved.toByteArray()); | ||||
} else { | ||||
QList<int> sizes; | ||||
sizes << 355 << 125; | ||||
splitter->setSizes(sizes); | ||||
} | ||||
installEventFilter(this); | installEventFilter(this); | |||
} | } | |||
bool ResTable::eventFilter(QObject* obj, QEvent* event) | bool ResTable::eventFilter(QObject* obj, QEvent* event) | |||
{ | { | |||
if (event->type() == QEvent::KeyPress) { | if (event->type() == QEvent::KeyPress) { | |||
QKeyEvent* key = static_cast<QKeyEvent*>(event); | QKeyEvent* key = static_cast<QKeyEvent*>(event); | |||
if ((key->key() == Qt::Key_Enter) || (key->key() == Qt::Key_Return)) { | if ((key->key() == Qt::Key_Enter) || (key->key() == Qt::Key_Return)) { | |||
menuEdit(); | menuEdit(); | |||
return true; | return true; | |||
skipping to change at line 721 | skipping to change at line 739 | |||
m_detail->init(); | m_detail->init(); | |||
m_detaildocnum = -1; | m_detaildocnum = -1; | |||
} | } | |||
// This is called by rclmain_w prior to exiting | // This is called by rclmain_w prior to exiting | |||
void ResTable::saveColState() | void ResTable::saveColState() | |||
{ | { | |||
if (!m_ismainres) | if (!m_ismainres) | |||
return; | return; | |||
QSettings settings; | QSettings settings; | |||
settings.setValue("resTableSplitterSizes", splitter->saveState()); | settings.setValue(settingskey_splittersizes, splitter->saveState()); | |||
QHeaderView *header = tableView->horizontalHeader(); | QHeaderView *header = tableView->horizontalHeader(); | |||
const vector<string>& vf = m_model->getFields(); | const vector<string>& vf = m_model->getFields(); | |||
if (!header) { | if (!header) { | |||
LOGERR("ResTable::saveColState: no table header ??\n"); | LOGERR("ResTable::saveColState: no table header ??\n"); | |||
return; | return; | |||
} | } | |||
// Remember the current column order. Walk in visual order and | // Remember the current column order. Walk in visual order and | |||
// create new list | // create new list | |||
QStringList newfields; | QStringList newfields; | |||
vector<int> newwidths; | QString newwidths; | |||
for (int vi = 0; vi < header->count(); vi++) { | for (int vi = 0; vi < header->count(); vi++) { | |||
int li = header->logicalIndex(vi); | int li = header->logicalIndex(vi); | |||
if (li < 0 || li >= int(vf.size())) { | if (li < 0 || li >= int(vf.size())) { | |||
LOGERR("saveColState: logical index beyond list size!\n"); | LOGERR("saveColState: logical index beyond list size!\n"); | |||
continue; | continue; | |||
} | } | |||
newfields.push_back(QString::fromUtf8(vf[li].c_str())); | newfields.push_back(u8s2qs(vf[li])); | |||
newwidths.push_back(header->sectionSize(li)); | newwidths += QString().setNum(header->sectionSize(li)) + QString(" "); | |||
} | } | |||
prefs.restableFields = newfields; | settings.setValue(settingskey_fieldlist, newfields); | |||
prefs.restableColWidths = newwidths; | settings.setValue(settingskey_fieldwiths, newwidths); | |||
} | } | |||
void ResTable::onTableView_currentChanged(const QModelIndex& index) | void ResTable::onTableView_currentChanged(const QModelIndex& index) | |||
{ | { | |||
LOGDEB2("ResTable::onTableView_currentChanged(" << index.row() << ", " << | LOGDEB2("ResTable::onTableView_currentChanged(" << index.row() << ", " << | |||
index.column() << ")\n"); | index.column() << ")\n"); | |||
if (!m_model || !m_model->getDocSource()) | if (!m_model || !m_model->getDocSource()) | |||
return; | return; | |||
Rcl::Doc doc; | Rcl::Doc doc; | |||
End of changes. 10 change blocks. | ||||
19 lines changed or deleted | 37 lines changed or added |