Changeset 77013 in vbox
- Timestamp:
- Jan 28, 2019 8:24:12 AM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/medium
- Files:
-
- 2 edited
-
UIMediumSearchWidget.cpp (modified) (2 diffs)
-
UIMediumSearchWidget.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumSearchWidget.cpp
r77009 r77013 155 155 if (!m_matchedItemList.isEmpty()) 156 156 { 157 m_iScrollToIndex = 0;158 pTreeWidget->scrollTo(pTreeWidget->itemIndex(m_matchedItemList[m_iScrollToIndex]), QAbstractItemView::PositionAtCenter);157 m_iScrollToIndex = -1; 158 goToNextPrevious(true); 159 159 } 160 160 } … … 195 195 font.setBold(fMark); 196 196 pMediumItem->setFont(0, font); 197 } 197 198 if (!fMark) 199 setUnderlineItemText(pMediumItem, false); 200 } 201 } 202 203 void UIMediumSearchWidget::setUnderlineItemText(QTreeWidgetItem* pItem, bool fUnderline) 204 { 205 if (!pItem) 206 return; 207 QFont font = pItem->font(0); 208 font.setUnderline(fUnderline); 209 pItem->setFont(0, font); 210 } 211 212 void UIMediumSearchWidget::goToNextPrevious(bool fNext) 213 { 214 if (!m_pTreeWidget || m_matchedItemList.isEmpty()) 215 return; 216 217 if (m_iScrollToIndex >= 0 && m_iScrollToIndex < m_matchedItemList.size()) 218 setUnderlineItemText(m_matchedItemList[m_iScrollToIndex], false); 219 220 if (fNext) 221 ++m_iScrollToIndex; 222 else 223 --m_iScrollToIndex; 224 225 if (m_iScrollToIndex >= m_matchedItemList.size()) 226 m_iScrollToIndex = 0; 227 if (m_iScrollToIndex < 0) 228 m_iScrollToIndex = m_matchedItemList.size() - 1; 229 230 setUnderlineItemText(m_matchedItemList[m_iScrollToIndex], true); 231 m_pTreeWidget->scrollTo(m_pTreeWidget->itemIndex(m_matchedItemList[m_iScrollToIndex]), QAbstractItemView::PositionAtCenter); 232 198 233 } 199 234 200 235 void UIMediumSearchWidget::sltShowNextMatchingItem() 201 236 { 202 if (!m_pTreeWidget) 203 return; 204 if (++m_iScrollToIndex >= m_matchedItemList.size()) 205 m_iScrollToIndex = 0; 206 if (!m_matchedItemList[m_iScrollToIndex]) 207 return; 208 m_pTreeWidget->scrollTo(m_pTreeWidget->itemIndex(m_matchedItemList[m_iScrollToIndex]), QAbstractItemView::PositionAtCenter); 237 if (m_matchedItemList.isEmpty()) 238 return; 239 goToNextPrevious(true); 209 240 } 210 241 211 242 void UIMediumSearchWidget::sltShowPreviousMatchingItem() 212 243 { 213 if (!m_pTreeWidget) 214 return; 215 if (--m_iScrollToIndex <= 0) 216 m_iScrollToIndex = m_matchedItemList.size() - 1; 217 if (!m_matchedItemList[m_iScrollToIndex]) 218 return; 219 m_pTreeWidget->scrollTo(m_pTreeWidget->itemIndex(m_matchedItemList[m_iScrollToIndex]), QAbstractItemView::PositionAtCenter); 220 221 } 244 goToNextPrevious(false); 245 } -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumSearchWidget.h
r77006 r77013 76 76 void prepareWidgets(); 77 77 void markUnmarkItems(QList<QTreeWidgetItem*> &itemList, bool fMark); 78 78 void setUnderlineItemText(QTreeWidgetItem* pItem, bool fUnderline); 79 /** Increases (or decreases if @p fNext is false) the m_iScrollToIndex and 80 * takes care of the necessary decoration changes to mark the current item. */ 81 void goToNextPrevious(bool fNext); 79 82 QIComboBox *m_pSearchComboxBox; 80 83 QLineEdit *m_pSearchTermLineEdit;
Note:
See TracChangeset
for help on using the changeset viewer.

