Skip to content

Commit

Permalink
Go To respects current row numbering setting
Browse files Browse the repository at this point in the history
Closes #1
  • Loading branch information
kambala-decapitator committed Nov 4, 2019
1 parent c3f8c92 commit ff5d450
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
12 changes: 9 additions & 3 deletions gotorowdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@
#include <QSettings>


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);

Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions gotorowdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -22,7 +22,7 @@ private slots:

private:
Ui::GoToRowDialog ui;
int _maxRow;
int _minRow, _maxRow;
};

#endif // GOTOROWDIALOG_H
2 changes: 1 addition & 1 deletion qtbleditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit ff5d450

Please sign in to comment.