VirtualBox

Changeset 99179 in vbox for trunk


Ignore:
Timestamp:
Mar 24, 2023 3:58:10 PM (22 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10343: Adjust reg-exp rules for UIUSBFilterDetailsEditor; Integer values should support ranges now.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIUSBFilterDetailsEditor.cpp

    r99178 r99179  
    260260void UIUSBFilterDetailsEditor::prepareWidgets()
    261261{
     262    /* Name field validation: */
     263    const QRegularExpression re1(".+");
     264    /* Integer field validation, supports hex ranges: */
     265    const QString strHexValue("((0[xX])?[0-9a-fA-F]{1,4})");
     266    const QString strRange = QString("(%1|-%1|%1-|%1-%1)").arg(strHexValue);
     267    const QString strRanges = QString("(%1(,%1)*)?").arg(strRange);
     268    const QRegularExpression re2(strRanges);
     269
    262270    /* Prepare main layout: */
    263271    QGridLayout *pLayout = new QGridLayout(this);
     
    280288                m_pLabelName->setBuddy(m_pEditorName);
    281289            m_pEditorName->setMinimumWidthByText(QString().fill('0', 32));
    282             m_pEditorName->setValidator(new QRegularExpressionValidator(QRegularExpression(".+"), this));
     290            m_pEditorName->setValidator(new QRegularExpressionValidator(re1, this));
    283291            connect(m_pEditorName, &QLineEdit::textChanged,
    284292                    this, &UIUSBFilterDetailsEditor::sltRevalidate);
     
    300308                m_pLabelVendorID->setBuddy(m_pEditorVendorID);
    301309            m_pEditorVendorID->setMinimumWidthByText(QString().fill('0', 8));
    302             m_pEditorVendorID->setValidator(new QRegularExpressionValidator(QRegularExpression("[0-9a-fA-F]{0,4}"), this));
     310            m_pEditorVendorID->setValidator(new QRegularExpressionValidator(re2, this));
    303311            connect(m_pEditorVendorID, &QLineEdit::textChanged,
    304312                    this, &UIUSBFilterDetailsEditor::sltRevalidate);
     
    320328                m_pLabelProductID->setBuddy(m_pEditorProductID);
    321329            m_pEditorProductID->setMinimumWidthByText(QString().fill('0', 8));
    322             m_pEditorProductID->setValidator(new QRegularExpressionValidator(QRegularExpression("[0-9a-fA-F]{0,4}"), this));
     330            m_pEditorProductID->setValidator(new QRegularExpressionValidator(re2, this));
    323331            connect(m_pEditorProductID, &QLineEdit::textChanged,
    324332                    this, &UIUSBFilterDetailsEditor::sltRevalidate);
     
    340348                m_pLabelRevision->setBuddy(m_pEditorRevision);
    341349            m_pEditorRevision->setMinimumWidthByText(QString().fill('0', 8));
    342             m_pEditorRevision->setValidator(new QRegularExpressionValidator(QRegularExpression("[0-9a-fA-F]{0,4}"), this));
     350            m_pEditorRevision->setValidator(new QRegularExpressionValidator(re2, this));
    343351            connect(m_pEditorRevision, &QLineEdit::textChanged,
    344352                    this, &UIUSBFilterDetailsEditor::sltRevalidate);
     
    411419                m_pLabelPort->setBuddy(m_pEditorPort);
    412420            m_pEditorPort->setMinimumWidthByText(QString().fill('0', 8));
    413             m_pEditorPort->setValidator(new QRegularExpressionValidator(QRegularExpression("(0[xX])?[0-9a-fA-F]{0,4}"), this));
     421            m_pEditorPort->setValidator(new QRegularExpressionValidator(re2, this));
    414422            connect(m_pEditorPort, &QLineEdit::textChanged,
    415423                    this, &UIUSBFilterDetailsEditor::sltRevalidate);
Note: See TracChangeset for help on using the changeset viewer.

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