Fix problem with cursor navigation in table browser

This was causing that cursor navigation in table browser did not move the
scroll or that find bar required an additional scrollTo call.

Problem was introduced in 63aabb9601

See comments in PR #2013
This commit is contained in:
mgrojo
2019-09-30 23:41:58 +02:00
parent b7f6bef398
commit 7ca90e0f7e
3 changed files with 11 additions and 6 deletions

View File

@@ -1005,3 +1005,9 @@ void ExtendedTableWidget::sortByColumns(const std::vector<sqlb::SortedColumn>& c
else
sqlite_model->sort(columns);
}
void ExtendedTableWidget::currentChanged(const QModelIndex &current, const QModelIndex &previous)
{
QTableView::currentChanged(current, previous);
emit currentIndexChanged(current, previous);
}

View File

@@ -74,8 +74,7 @@ signals:
void openFileFromDropEvent(QString);
void selectedRowsToBeDeleted();
void editCondFormats(int column);
// Make the inherited protected signal public
void currentChanged(const QModelIndex &current, const QModelIndex &previous);
void currentIndexChanged(const QModelIndex &current, const QModelIndex &previous);
private:
void copyMimeData(const QModelIndexList& fromIndices, QMimeData* mimeData, const bool withHeaders, const bool inSQL);
@@ -98,6 +97,7 @@ protected:
void dragEnterEvent(QDragEnterEvent* event) override;
void dragMoveEvent(QDragMoveEvent* event) override;
void dropEvent(QDropEvent* event) override;
void currentChanged(const QModelIndex &current, const QModelIndex &previous) override;
FilterTableHeader* m_tableHeader;
QMenu* m_contextMenu;

View File

@@ -193,7 +193,7 @@ TableBrowser::TableBrowser(QWidget* parent) :
clearAllCondFormats(column);
});
connect(ui->dataTable, &ExtendedTableWidget::currentChanged, this, [this](const QModelIndex &current, const QModelIndex &) {
connect(ui->dataTable, &ExtendedTableWidget::currentIndexChanged, this, [this](const QModelIndex &current, const QModelIndex &) {
// Get cell current format for updating the format toolbar values. Block signals, so the format change is not reapplied.
QFont font;
font.fromString(m_browseTableModel->data(current, Qt::FontRole).toString());
@@ -1389,10 +1389,9 @@ void TableBrowser::find(const QString& expr, bool forward, bool include_first)
const auto match = m_browseTableModel->nextMatch(start, column_list, expr, flags, !forward, include_first);
// Select the next match if we found one
if(match.isValid()) {
if(match.isValid())
ui->dataTable->setCurrentIndex(match);
ui->dataTable->scrollTo(match);
}
// Make the expression control red if no results were found
if(match.isValid() || expr == "")
ui->editFindExpression->setStyleSheet("");