Fix issues with selections on Masternode tab (#2170)

Preserve selection on "My Masternodes" sub-tab, disable selections on "All Masternodes" sub-tab.
This commit is contained in:
UdjinM6 2018-07-08 00:20:15 +03:00 committed by GitHub
parent 2474d9cb8c
commit 7b9919d182
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -228,6 +228,9 @@
<property name="selectionBehavior"> <property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum> <enum>QAbstractItemView::SelectRows</enum>
</property> </property>
<property name="selectionMode">
<enum>QAbstractItemView::NoSelection</enum>
</property>
<property name="sortingEnabled"> <property name="sortingEnabled">
<bool>true</bool> <bool>true</bool>
</property> </property>

View File

@ -242,6 +242,11 @@ void MasternodeList::updateMyNodeList(bool fForce)
if(nSecondsTillUpdate > 0 && !fForce) return; if(nSecondsTillUpdate > 0 && !fForce) return;
nTimeMyListUpdated = GetTime(); 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); ui->tableWidgetMyMasternodes->setSortingEnabled(false);
for (const auto& mne : masternodeConfig.getEntries()) { for (const auto& mne : masternodeConfig.getEntries()) {
int32_t nOutputIndex = 0; int32_t nOutputIndex = 0;
@ -251,7 +256,7 @@ void MasternodeList::updateMyNodeList(bool fForce)
updateMyMasternodeInfo(QString::fromStdString(mne.getAlias()), QString::fromStdString(mne.getIp()), COutPoint(uint256S(mne.getTxHash()), nOutputIndex)); 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); ui->tableWidgetMyMasternodes->setSortingEnabled(true);
// reset "timer" // reset "timer"