Changeset 105000 in vbox
- Timestamp:
- Jun 24, 2024 2:55:48 PM (5 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPortForwardingTable.cpp
r104585 r105000 843 843 bool fHoldPosition /* = false */) 844 844 { 845 /* Remember last chosen item: */ 845 /* Store last chosen item: */ 846 QString strPreviousName; 846 847 const QModelIndex currentIndex = m_pTableView->currentIndex(); 847 QITableViewRow *pCurrentItem = currentIndex.isValid() ? m_pTableModel->childItem(currentIndex.row()) : 0; 848 const QString strCurrentName = pCurrentItem ? pCurrentItem->childItem(0)->text() : QString(); 848 if (currentIndex.isValid()) 849 { 850 const int iCurrentRow = currentIndex.row(); 851 const QModelIndex firstCurrentIndex = m_pTableModel->index(iCurrentRow, 0); 852 if (firstCurrentIndex.isValid()) 853 strPreviousName = m_pTableModel->data(firstCurrentIndex, Qt::DisplayRole).toString(); 854 } 849 855 850 856 /* Update the list of rules: */ … … 854 860 855 861 /* Restore last chosen item: */ 856 if (fHoldPosition && !str CurrentName.isEmpty())857 { 858 for (int i = 0; i < m_pTableModel-> childCount(); ++i)862 if (fHoldPosition && !strPreviousName.isEmpty()) 863 { 864 for (int i = 0; i < m_pTableModel->rowCount(); ++i) 859 865 { 860 QITableViewRow *pItem = m_pTableModel->childItem(i); 861 const QString strName = pItem ? pItem->childItem(0)->text() : QString(); 862 if (strName == strCurrentName) 863 m_pTableView->setCurrentIndex(m_pTableModel->index(i, 0)); 866 const QModelIndex firstIteratedIndex = m_pTableModel->index(i, 0); 867 if (firstIteratedIndex.isValid()) 868 { 869 const QString strName = m_pTableModel->data(firstIteratedIndex, Qt::DisplayRole).toString(); 870 if (strName == strPreviousName) 871 m_pTableView->setCurrentIndex(m_pTableModel->index(i, 0)); 872 } 864 873 } 865 874 }
Note:
See TracChangeset
for help on using the changeset viewer.