Changeset 72447 in vbox for trunk/src/VBox
- Timestamp:
- Jun 5, 2018 10:09:26 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumSelector.cpp
r72444 r72447 32 32 # include "QIMessageBox.h" 33 33 # include "QITabWidget.h" 34 # include "QIToolButton.h" 34 35 # include "VBoxGlobal.h" 35 36 # include "UIDesktopWidgetWatchdog.h" … … 55 56 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 56 57 58 /********************************************************************************************************************************* 59 * UISearchLineEdit definition. * 60 *********************************************************************************************************************************/ 61 62 class UISearchLineEdit : public QILineEdit 63 { 64 Q_OBJECT; 65 66 signals: 67 68 void sigFilterTermRemoved(QString removedString); 69 void sigClearAll(); 70 71 public: 72 73 UISearchLineEdit(QWidget *parent = 0); 74 75 protected: 76 77 // /* Delete mouseDoubleClick and mouseMoveEvent implementations of the base class */ 78 // virtual void mouseDoubleClickEvent(QMouseEvent *) /* override */{} 79 // virtual void mouseMoveEvent(QMouseEvent *) /* override */{} 80 // /* Override the mousePressEvent to control how selection is done: */ 81 // virtual void mousePressEvent(QMouseEvent * event) /* override */; 82 // virtual void mouseReleaseEvent(QMouseEvent *){} 83 virtual void paintEvent(QPaintEvent *event) /* override */; 84 85 private slots: 86 87 /* The whole content is removed. Listeners are notified: */ 88 void sltClearAll(); 89 90 private: 91 92 void createButtons(); 93 QIToolButton *m_pClearAllButton; 94 }; 95 57 96 class UIMediumSearchWidget : public QWidget 58 97 { … … 82 121 83 122 void prepareWidgets(); 84 QIComboBox *m_pSearchComboxBox;85 QILineEdit *m_pSearchTermLineEdit;123 QIComboBox *m_pSearchComboxBox; 124 UISearchLineEdit *m_pSearchTermLineEdit; 86 125 }; 126 127 128 /********************************************************************************************************************************* 129 * UISearchLineEdit implementation. * 130 *********************************************************************************************************************************/ 131 132 UISearchLineEdit::UISearchLineEdit(QWidget *parent /*= 0*/) 133 :QILineEdit(parent) 134 , m_pClearAllButton(0) 135 { 136 createButtons(); 137 } 138 139 void UISearchLineEdit::paintEvent(QPaintEvent *event) 140 { 141 QLineEdit::paintEvent(event); 142 143 if (!m_pClearAllButton) 144 createButtons(); 145 int clearButtonSize = height(); 146 m_pClearAllButton->setGeometry(width() - clearButtonSize, 0, clearButtonSize, clearButtonSize); 147 } 148 149 void UISearchLineEdit::sltClearAll() 150 { 151 /* Check if we have some text to avoid recursive calls: */ 152 if (text().isEmpty()) 153 return; 154 155 clear(); 156 emit sigClearAll(); 157 } 158 159 void UISearchLineEdit::createButtons() 160 { 161 if (!m_pClearAllButton) 162 { 163 m_pClearAllButton = new QIToolButton(this); 164 if (m_pClearAllButton) 165 { 166 m_pClearAllButton->setIcon(m_pClearAllButton->style()->standardIcon(QStyle::SP_LineEditClearButton)); 167 connect(m_pClearAllButton, &QIToolButton::clicked, this, &UISearchLineEdit::sltClearAll); 168 } 169 } 170 } 171 172 173 /********************************************************************************************************************************* 174 * UIMediumSearchWidget implementation. * 175 *********************************************************************************************************************************/ 87 176 88 177 UIMediumSearchWidget::UIMediumSearchWidget(QWidget *pParent) … … 105 194 { 106 195 m_pSearchComboxBox->setEditable(false); 107 m_pSearchComboxBox->insertItem(SearchByName, " By Name");108 m_pSearchComboxBox->insertItem(SearchByUUID, " By UUID");196 m_pSearchComboxBox->insertItem(SearchByName, "Search By Name"); 197 m_pSearchComboxBox->insertItem(SearchByUUID, "Search By UUID"); 109 198 pLayout->addWidget(m_pSearchComboxBox); 110 199 … … 114 203 } 115 204 116 m_pSearchTermLineEdit = new QILineEdit;205 m_pSearchTermLineEdit = new UISearchLineEdit; 117 206 if (pLayout) 118 207 { … … 154 243 configure(); 155 244 finalize(); 156 //setAttribute(Qt::WA_DeleteOnClose);157 245 } 158 246 … … 401 489 m_pTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection); 402 490 m_pMainLayout->addWidget(m_pTreeWidget); 403 404 491 m_pTreeWidget->setAlternatingRowColors(true); 405 492 int iColumnCount = (m_enmMediumType == UIMediumType_HardDisk) ? 3 : 2; 493 m_pTreeWidget->setColumnCount(iColumnCount); 494 m_pTreeWidget->setSortingEnabled(true); 495 m_pTreeWidget->sortItems(0, Qt::AscendingOrder); 406 496 } 407 497 … … 537 627 if (!m_pTreeWidget) 538 628 return; 539 540 629 /* Cache the currently selected items: */ 541 630 QList<QTreeWidgetItem*> selectedItems = m_pTreeWidget->selectedItems(); … … 591 680 if (m_pNotAttachedSubTreeRoot) 592 681 m_pTreeWidget->expandItem(m_pNotAttachedSubTreeRoot); 682 683 m_pTreeWidget->resizeColumnToContents(0); 684 performMediumSearch(); 593 685 } 594 686 … … 645 737 for (int i = 0; i < m_mediumItemList.size(); ++i) 646 738 { 647 m_mediumItemList[i]->setData(0, Qt::ForegroundRole, m_defaultItemForeground); 739 for (int j = 0; j < m_pTreeWidget->columnCount(); ++j) 740 m_mediumItemList[i]->setData(j, Qt::ForegroundRole, m_defaultItemForeground); 648 741 } 649 742 … … 671 764 { 672 765 // mark the item 673 m_mediumItemList[i]->setData(0, Qt::ForegroundRole, QBrush(QColor(255, 0, 0))); 766 for (int j = 0; j < m_pTreeWidget->columnCount(); ++j) 767 m_mediumItemList[i]->setData(j, Qt::ForegroundRole, QBrush(QColor(255, 0, 0))); 674 768 } 675 769 }
Note:
See TracChangeset
for help on using the changeset viewer.