Changeset 101030 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Sep 6, 2023 3:00:56 PM (20 months ago)
- svn:sync-xref-src-repo-rev:
- 158987
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/settings/editors
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIEditor.cpp
r101011 r101030 26 26 */ 27 27 28 /* Qt includes: */ 29 #include <QAbstractButton> 30 #include <QLabel> 31 #include <QRegularExpression> 32 #include <QTabWidget> 33 28 34 /* GUI includes: */ 29 35 #include "UIEditor.h" … … 34 40 { 35 41 } 42 43 void UIEditor::filterOut(const QString &strFilter) 44 { 45 /* Make sure the editor is visible in case if filter is empty: */ 46 bool fVisible = strFilter.isEmpty(); 47 if (!fVisible) 48 { 49 /* Otherwise we'll have to walk through all the 50 * descriptions to check whether filter is suitable: */ 51 foreach (const QString &strDescription, description()) 52 if (strDescription.contains(strFilter, Qt::CaseInsensitive)) 53 { 54 fVisible = true; 55 break; 56 } 57 } 58 /* We'll show whole the editor if filter is suitable: */ 59 setVisible(fVisible); 60 } 61 62 QStringList UIEditor::description() const 63 { 64 QStringList result; 65 /* Clean <html> tags and &mpersands: */ 66 QRegularExpression re("<[^>]*>|&"); 67 68 /* Adding all the buddy labels we have: */ 69 foreach (QLabel *pLabel, findChildren<QLabel*>()) 70 if (pLabel && pLabel->buddy()) 71 result << pLabel->text().remove(re); 72 73 /* Adding all the button sub-types: */ 74 foreach (QAbstractButton *pButton, findChildren<QAbstractButton*>()) 75 if (pButton) 76 result << pButton->text().remove(re); 77 78 /* Adding all the tab-widget tabs: */ 79 foreach (QTabWidget *pTabWidget, findChildren<QTabWidget*>()) 80 if (pTabWidget) 81 for (int i = 0; i < pTabWidget->count(); ++i) 82 result << pTabWidget->tabText(i).remove(re); 83 84 return result; 85 } -
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIEditor.h
r101011 r101030 45 45 UIEditor(QWidget *pParent = 0); 46 46 47 /** Filters out contents with description unrelated to passed @a strFilter. */ 48 virtual void filterOut(const QString &strFilter); 49 47 50 protected: 51 52 /** Returns editor description which could be used to filter it in. */ 53 virtual QStringList description() const; 48 54 49 55 /** Holds the list of sub-editors. */
Note:
See TracChangeset
for help on using the changeset viewer.