From ff5d450b69925126a473c3c9704d63ccee3fbb8f Mon Sep 17 00:00:00 2001 From: Andrey Filipenkov Date: Mon, 4 Nov 2019 18:02:21 +0300 Subject: [PATCH] Go To respects current row numbering setting Closes #1 --- gotorowdialog.cpp | 12 +++++++++--- gotorowdialog.h | 4 ++-- qtbleditor.cpp | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/gotorowdialog.cpp b/gotorowdialog.cpp index fc00805..a26a842 100644 --- a/gotorowdialog.cpp +++ b/gotorowdialog.cpp @@ -5,12 +5,18 @@ #include -GoToRowDialog::GoToRowDialog(QWidget *parent, int rowCount) : QDialog(parent), _maxRow(rowCount) +GoToRowDialog::GoToRowDialog(QWidget *parent, int rowCount, bool rowsStartFromZero) : QDialog(parent), _minRow(1), _maxRow(rowCount) { ui.setupUi(this); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); setFixedSize(sizeHint()); - setWindowTitle(tr("Go to row [1-%1 (0x%2)]").arg(rowCount).arg(rowCount, 0, 16)); + + if (rowsStartFromZero) + { + --_minRow; + --_maxRow; + } + setWindowTitle(tr("Go to row [%1-%2 (0x%3)]").arg(_minRow).arg(_maxRow).arg(_maxRow, 0, 16)); ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); @@ -32,7 +38,7 @@ void GoToRowDialog::changeMode(bool isHex) void GoToRowDialog::enableOkButton() { int value = row(); - ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(value >= 1 && value <= _maxRow); + ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(value >= _minRow && value <= _maxRow); } void GoToRowDialog::accept() diff --git a/gotorowdialog.h b/gotorowdialog.h index 1008513..b491729 100644 --- a/gotorowdialog.h +++ b/gotorowdialog.h @@ -9,7 +9,7 @@ class GoToRowDialog : public QDialog Q_OBJECT public: - explicit GoToRowDialog(QWidget *parent, int rowCount); + explicit GoToRowDialog(QWidget *parent, int rowCount, bool rowsStartFromZero); int row(); @@ -22,7 +22,7 @@ private slots: private: Ui::GoToRowDialog ui; - int _maxRow; + int _minRow, _maxRow; }; #endif // GOTOROWDIALOG_H diff --git a/qtbleditor.cpp b/qtbleditor.cpp index 7d5bc81..dede0b6 100644 --- a/qtbleditor.cpp +++ b/qtbleditor.cpp @@ -915,7 +915,7 @@ void QTblEditor::findNextString(const QString &query, bool isCaseSensitive, bool void QTblEditor::goTo() { - GoToRowDialog dlg(this, _currentTableWidget->rowCount()); + GoToRowDialog dlg(this, _currentTableWidget->rowCount(), ui.actionStartNumberingFrom0->isChecked()); if (dlg.exec()) _currentTableWidget->setCurrentCell(dlg.row() - 1, 1); }