Skip to content

Commit d7c11bd

Browse files
author
Paweł Salawa
committed
#5692 Select first inserted row after inserting multiple rows in Grid View.
1 parent b016b80 commit d7c11bd

6 files changed

Lines changed: 15 additions & 7 deletions

File tree

ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
- BUGFIX: #5609 Fixed SQL syntax highlighter for multi-line comments with empty linies inside.
114114
- BUGFIX: #5628 Fixed PDF export bugs (first page size too small, occasional table overlapping, page numbers cut off).
115115
- BUGFIX: #5691 Fixed tooltip in Database Dialog with Wayland under Linux.
116+
- BUGFIX: #5692 Select first inserted row after inserting multiple rows in Grid View.
116117

117118
### 3.4.21
118119
- ADDED: #5466 Support foreign keys with implicit columns (proper values in FK combobox columns).

Letos/gui/datagrid/sqlquerymodel.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2017,18 +2017,20 @@ void SqlQueryModel::addNewRow()
20172017
emit commitStatusChanged(true);
20182018
}
20192019

2020-
void SqlQueryModel::addMultipleRows()
2020+
int SqlQueryModel::addMultipleRows()
20212021
{
20222022
bool ok;
20232023
int rows = QInputDialog::getInt(view, tr("Insert multiple rows"), tr("Number of rows to insert:"), 1, 1, 10000, 1, &ok);
20242024
if (!ok)
2025-
return;
2025+
return -1;
20262026

2027-
int row = getInsertRowIndex();
2027+
int initialRow = getInsertRowIndex();
2028+
int row = initialRow;
20282029
for (int i = 0; i < rows; i++)
20292030
addNewRowInternal(row++);
20302031

20312032
emit commitStatusChanged(true);
2033+
return initialRow;
20322034
}
20332035

20342036
void SqlQueryModel::deleteSelectedRows()

Letos/gui/datagrid/sqlquerymodel.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,11 @@ class GUI_API_EXPORT SqlQueryModel : public QStandardItemModel
559559
void reload();
560560
void updateSelectiveCommitRollbackActions(const QItemSelection& selected, const QItemSelection& deselected);
561561
void addNewRow();
562-
void addMultipleRows();
562+
563+
/**
564+
* @return row index of first inserted row
565+
*/
566+
int addMultipleRows();
563567
void deleteSelectedRows();
564568
void handlePossibleTableModification(Db* modDb, const QString& database, const QString& objName);
565569
void handlePossibleTableRename(Db* modDb, const QString& database, const QString& oldName, const QString& newName);

Letos/gui/datagrid/sqlqueryview.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,7 @@ void SqlQueryView::closeEditor(QWidget* editor, QAbstractItemDelegate::EndEditHi
11491149

11501150
void SqlQueryView::scrollTo(const QModelIndex& index, ScrollHint hint)
11511151
{
1152-
if (index.column() > 0)
1152+
if (index.column() >= 0)
11531153
QTableView::scrollTo(index, hint);
11541154
}
11551155

Letos/gui/dataview.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1108,7 +1108,8 @@ void DataView::insertMultipleRows()
11081108
if (!model->features().testFlag(SqlQueryModel::INSERT_ROW))
11091109
return;
11101110

1111-
model->addMultipleRows();
1111+
int firstInsertedRow = model->addMultipleRows();
1112+
gridView->setCurrentRow(firstInsertedRow);
11121113
formView->updateFromGrid();
11131114
updateCurrentFormViewRow();
11141115
formViewFocusFirstEditor();

Letos/gui/uiconfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ CFG_UI_CATEGORIES(Ui,
162162
CFG_ENTRY(int, StatusFieldMsgFadingMode, Cfg::StatusFieldFadingMode::GRAY_OUT)
163163
CFG_ENTRY(Cfg::DataEditorsOrder, DataEditorsOrder, Cfg::DataEditorsOrder())
164164
CFG_ENTRY(Cfg::DataRenderers, DataRenderers, Cfg::DataRenderers())
165-
CFG_ENTRY(bool, DataEditAutoAdvanceOnEnter, false)
165+
CFG_ENTRY(bool, DataEditAutoAdvanceOnEnter, true)
166166
CFG_ENTRY(bool, DataEditAutoAdvanceEdit, false, CFG_DEP(DataEditAutoAdvanceOnEnter))
167167
CFG_ENTRY(QString, FileDialogLastPath, QString())
168168
CFG_ENTRY(int, MaxInitialColumnWith, 600)

0 commit comments

Comments
 (0)