Skip to content

Commit

Permalink
Fix issues with selections on Masternode tab (#2170)
Browse files Browse the repository at this point in the history
Preserve selection on "My Masternodes" sub-tab, disable selections on "All Masternodes" sub-tab.
  • Loading branch information
UdjinM6 committed Jul 7, 2018
1 parent 2474d9c commit 7b9919d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/qt/forms/masternodelist.ui
Expand Up @@ -228,6 +228,9 @@
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::NoSelection</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
Expand Down
7 changes: 6 additions & 1 deletion src/qt/masternodelist.cpp
Expand Up @@ -242,6 +242,11 @@ void MasternodeList::updateMyNodeList(bool fForce)
if(nSecondsTillUpdate > 0 && !fForce) return;
nTimeMyListUpdated = GetTime();

// Find selected row
QItemSelectionModel* selectionModel = ui->tableWidgetMyMasternodes->selectionModel();
QModelIndexList selected = selectionModel->selectedRows();
int nSelectedRow = selected.count() ? selected.at(0).row() : 0;

ui->tableWidgetMyMasternodes->setSortingEnabled(false);
for (const auto& mne : masternodeConfig.getEntries()) {
int32_t nOutputIndex = 0;
Expand All @@ -251,7 +256,7 @@ void MasternodeList::updateMyNodeList(bool fForce)

updateMyMasternodeInfo(QString::fromStdString(mne.getAlias()), QString::fromStdString(mne.getIp()), COutPoint(uint256S(mne.getTxHash()), nOutputIndex));
}
ui->tableWidgetMyMasternodes->selectRow(0);
ui->tableWidgetMyMasternodes->selectRow(nSelectedRow);
ui->tableWidgetMyMasternodes->setSortingEnabled(true);

// reset "timer"
Expand Down

0 comments on commit 7b9919d

Please sign in to comment.