Changeset 99178 in vbox
- Timestamp:
- Mar 24, 2023 3:54:10 PM (21 months ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/settings/editors
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIUSBFilterDetailsEditor.cpp
r99177 r99178 30 30 #include <QGridLayout> 31 31 #include <QLabel> 32 #include <QPushButton> 32 33 #include <QRegularExpressionValidator> 33 34 … … 234 235 } 235 236 237 void UIUSBFilterDetailsEditor::sltRevalidate() 238 { 239 /* Cast sender to editor: */ 240 QILineEdit *pEditor = qobject_cast<QILineEdit*>(sender()); 241 AssertPtrReturnVoid(pEditor); 242 243 /* Performs sender's validation: */ 244 revalidate(pEditor); 245 } 246 236 247 void UIUSBFilterDetailsEditor::prepare() 237 248 { … … 270 281 m_pEditorName->setMinimumWidthByText(QString().fill('0', 32)); 271 282 m_pEditorName->setValidator(new QRegularExpressionValidator(QRegularExpression(".+"), this)); 283 connect(m_pEditorName, &QLineEdit::textChanged, 284 this, &UIUSBFilterDetailsEditor::sltRevalidate); 272 285 pLayout->addWidget(m_pEditorName, 0, 1); 273 286 } … … 288 301 m_pEditorVendorID->setMinimumWidthByText(QString().fill('0', 8)); 289 302 m_pEditorVendorID->setValidator(new QRegularExpressionValidator(QRegularExpression("[0-9a-fA-F]{0,4}"), this)); 303 connect(m_pEditorVendorID, &QLineEdit::textChanged, 304 this, &UIUSBFilterDetailsEditor::sltRevalidate); 290 305 pLayout->addWidget(m_pEditorVendorID, 1, 1); 291 306 } … … 306 321 m_pEditorProductID->setMinimumWidthByText(QString().fill('0', 8)); 307 322 m_pEditorProductID->setValidator(new QRegularExpressionValidator(QRegularExpression("[0-9a-fA-F]{0,4}"), this)); 323 connect(m_pEditorProductID, &QLineEdit::textChanged, 324 this, &UIUSBFilterDetailsEditor::sltRevalidate); 308 325 pLayout->addWidget(m_pEditorProductID, 2, 1); 309 326 } … … 324 341 m_pEditorRevision->setMinimumWidthByText(QString().fill('0', 8)); 325 342 m_pEditorRevision->setValidator(new QRegularExpressionValidator(QRegularExpression("[0-9a-fA-F]{0,4}"), this)); 343 connect(m_pEditorRevision, &QLineEdit::textChanged, 344 this, &UIUSBFilterDetailsEditor::sltRevalidate); 326 345 pLayout->addWidget(m_pEditorRevision, 3, 1); 327 346 } … … 393 412 m_pEditorPort->setMinimumWidthByText(QString().fill('0', 8)); 394 413 m_pEditorPort->setValidator(new QRegularExpressionValidator(QRegularExpression("(0[xX])?[0-9a-fA-F]{0,4}"), this)); 414 connect(m_pEditorPort, &QLineEdit::textChanged, 415 this, &UIUSBFilterDetailsEditor::sltRevalidate); 395 416 pLayout->addWidget(m_pEditorPort, 7, 1); 396 417 } … … 436 457 } 437 458 459 void UIUSBFilterDetailsEditor::revalidate(QILineEdit *pEditor) 460 { 461 /* Acquire current validator: */ 462 const QValidator *pValidator = pEditor->validator(); 463 AssertPtrReturnVoid(pValidator); 464 465 /* Validate current text: */ 466 QString strText = pEditor->text(); 467 int iPos = 0; 468 const QValidator::State enmState = pValidator->validate(strText, iPos); 469 470 /* Store current validation verdict: */ 471 m_valid[pEditor] = enmState == QValidator::Acceptable; 472 473 /* Calculate overall validation result: */ 474 bool fValid = true; 475 foreach (bool fValidOne, m_valid.values()) 476 if (!fValidOne) 477 { 478 fValid = false; 479 break; 480 } 481 482 /* Enable/disable button-box Ok button accordingly: */ 483 m_pButtonBox->button(QDialogButtonBox::Ok)->setEnabled(fValid); 484 } 485 438 486 /* static */ 439 487 QString UIUSBFilterDetailsEditor::wiped(const QString &strString) -
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIUSBFilterDetailsEditor.h
r99177 r99178 102 102 virtual void retranslateUi() RT_OVERRIDE; 103 103 104 private slots: 105 106 /** Performs validation for connected sender. */ 107 void sltRevalidate(); 108 104 109 private: 105 110 … … 111 116 void prepareConnections(); 112 117 118 /** Performs validation for @a pEditor. */ 119 void revalidate(QILineEdit *pEditor); 120 113 121 /** Wipes out @a strString if it's empty. */ 114 122 static QString wiped(const QString &strString); 123 124 /** Holds whether editors currently valid. */ 125 QMap<QILineEdit*, bool> m_valid; 115 126 116 127 /** @name Widgets
Note:
See TracChangeset
for help on using the changeset viewer.