VirtualBox

Changeset 101030 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Sep 6, 2023 3:00:56 PM (20 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
158987
Message:

FE/Qt: bugref:10513: Extending UIEditor with filtering stuff.

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  
    2626 */
    2727
     28/* Qt includes: */
     29#include <QAbstractButton>
     30#include <QLabel>
     31#include <QRegularExpression>
     32#include <QTabWidget>
     33
    2834/* GUI includes: */
    2935#include "UIEditor.h"
     
    3440{
    3541}
     42
     43void 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
     62QStringList 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  
    4545    UIEditor(QWidget *pParent = 0);
    4646
     47    /** Filters out contents with description unrelated to passed @a strFilter. */
     48    virtual void filterOut(const QString &strFilter);
     49
    4750protected:
     51
     52    /** Returns editor description which could be used to filter it in. */
     53    virtual QStringList description() const;
    4854
    4955    /** Holds the list of sub-editors. */
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette