result table: arrange so that jump to row through Shift+letter displays the default kind of detail content
This commit is contained in:
parent
f128909d1e
commit
5668cec4bc
@ -696,7 +696,7 @@ void ResTable::onNewShortcuts()
|
|||||||
// Set "go to row" accelerator shortcuts. letter or digit for 0-9,
|
// Set "go to row" accelerator shortcuts. letter or digit for 0-9,
|
||||||
// then letter up to 25
|
// then letter up to 25
|
||||||
std::function<void(int)> setrow =
|
std::function<void(int)> setrow =
|
||||||
std::bind(&ResTable::setCurrentRow, this, std::placeholders::_1);
|
std::bind(&ResTable::setCurrentRowFromKbd, this, std::placeholders::_1);
|
||||||
for (int i = 0; i <= 25; i++) {
|
for (int i = 0; i <= 25; i++) {
|
||||||
auto qs = QString("Ctrl+Shift+%1").arg(char('a'+i));
|
auto qs = QString("Ctrl+Shift+%1").arg(char('a'+i));
|
||||||
auto sc = new QShortcut(QKeySequence(qs2utf8s(qs).c_str()), this);
|
auto sc = new QShortcut(QKeySequence(qs2utf8s(qs).c_str()), this);
|
||||||
@ -819,8 +819,10 @@ void ResTable::onUiPrefsChanged()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResTable::setCurrentRow(int row)
|
void ResTable::setCurrentRowFromKbd(int row)
|
||||||
{
|
{
|
||||||
|
LOGDEB1("setCurrentRowFromKbd: " << row << "\n");
|
||||||
|
m_rowchangefromkbd = true;
|
||||||
tableView->setFocus(Qt::ShortcutFocusReason);
|
tableView->setFocus(Qt::ShortcutFocusReason);
|
||||||
tableView->selectionModel()->setCurrentIndex(
|
tableView->selectionModel()->setCurrentIndex(
|
||||||
m_model->index(row, 0),
|
m_model->index(row, 0),
|
||||||
@ -880,7 +882,7 @@ void ResTable::saveColState()
|
|||||||
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() << ") from kbd " << m_rowchangefromkbd << "\n");
|
||||||
|
|
||||||
if (!m_model || !m_model->getDocSource())
|
if (!m_model || !m_model->getDocSource())
|
||||||
return;
|
return;
|
||||||
@ -889,10 +891,11 @@ void ResTable::onTableView_currentChanged(const QModelIndex& index)
|
|||||||
m_detail->init();
|
m_detail->init();
|
||||||
m_detaildocnum = index.row();
|
m_detaildocnum = index.row();
|
||||||
m_detaildoc = doc;
|
m_detaildoc = doc;
|
||||||
Qt::KeyboardModifiers mods = QApplication::keyboardModifiers();
|
bool isShift = (QApplication::keyboardModifiers() & Qt::ShiftModifier) &&
|
||||||
bool showtext = (mods &= Qt::ShiftModifier);
|
!m_rowchangefromkbd;
|
||||||
showtext ^= prefs.resTableTextNoShift;
|
bool showtext = isShift ^ prefs.resTableTextNoShift;
|
||||||
if (tableView->selectionModel()->hasSelection() && showtext) {
|
if (tableView->selectionModel()->hasSelection() && showtext) {
|
||||||
|
m_rowchangefromkbd = false;
|
||||||
bool loadok = rcldb->getDocRawText(m_detaildoc);
|
bool loadok = rcldb->getDocRawText(m_detaildoc);
|
||||||
if (loadok) {
|
if (loadok) {
|
||||||
m_detail->setText(u8s2qs(m_detaildoc.text));
|
m_detail->setText(u8s2qs(m_detaildoc.text));
|
||||||
@ -1095,6 +1098,7 @@ void ResTable::onClicked(const QModelIndex& index)
|
|||||||
// If the current row is the one clicked, currentChanged is not
|
// If the current row is the one clicked, currentChanged is not
|
||||||
// called so that we would not do the text display if we did not
|
// called so that we would not do the text display if we did not
|
||||||
// call it from here
|
// call it from here
|
||||||
|
m_rowchangefromkbd = false;
|
||||||
if (index.row() == m_detaildocnum) {
|
if (index.row() == m_detaildocnum) {
|
||||||
onTableView_currentChanged(index);
|
onTableView_currentChanged(index);
|
||||||
}
|
}
|
||||||
@ -1102,6 +1106,7 @@ void ResTable::onClicked(const QModelIndex& index)
|
|||||||
|
|
||||||
void ResTable::onDoubleClick(const QModelIndex& index)
|
void ResTable::onDoubleClick(const QModelIndex& index)
|
||||||
{
|
{
|
||||||
|
m_rowchangefromkbd = false;
|
||||||
if (!m_model || !m_model->getDocSource())
|
if (!m_model || !m_model->getDocSource())
|
||||||
return;
|
return;
|
||||||
Rcl::Doc doc;
|
Rcl::Doc doc;
|
||||||
|
|||||||
@ -187,7 +187,7 @@ public slots:
|
|||||||
virtual void takeFocus();
|
virtual void takeFocus();
|
||||||
virtual void onUiPrefsChanged();
|
virtual void onUiPrefsChanged();
|
||||||
virtual void onNewShortcuts();
|
virtual void onNewShortcuts();
|
||||||
virtual void setCurrentRow(int row);
|
virtual void setCurrentRowFromKbd(int row);
|
||||||
virtual void toggleHeader();
|
virtual void toggleHeader();
|
||||||
virtual void toggleVHeader();
|
virtual void toggleVHeader();
|
||||||
|
|
||||||
@ -220,6 +220,7 @@ private:
|
|||||||
int m_popcolumn{0};
|
int m_popcolumn{0};
|
||||||
RclMain *m_rclmain{nullptr};
|
RclMain *m_rclmain{nullptr};
|
||||||
bool m_ismainres{true};
|
bool m_ismainres{true};
|
||||||
|
bool m_rowchangefromkbd{false};
|
||||||
QShortcut *m_opensc{nullptr};
|
QShortcut *m_opensc{nullptr};
|
||||||
QShortcut *m_openquitsc{nullptr};
|
QShortcut *m_openquitsc{nullptr};
|
||||||
QShortcut *m_previewsc{nullptr};
|
QShortcut *m_previewsc{nullptr};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user