- Timestamp:
- Mar 30, 2015 6:40:16 PM (10 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIAddDiskEncryptionPasswordDialog.cpp
r55015 r55016 26 26 # include <QTableView> 27 27 # include <QHeaderView> 28 # include <QPushButton> 28 29 # include <QItemEditorFactory> 29 30 # include <QAbstractTableModel> … … 105 106 EncryptionPasswordMap encryptionPasswords() const { return m_encryptionPasswords; } 106 107 108 /** Returns whether the model is valid. */ 109 bool isValid() const; 110 107 111 /** Returns the row count, taking optional @a parent instead of root if necessary. */ 108 112 virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; … … 145 149 Q_OBJECT; 146 150 151 signals: 152 153 /** Notifies listeners about data change. */ 154 void sigDataChanged(); 155 147 156 public: 148 157 … … 154 163 * acquired from the UIEncryptionDataModel instance. */ 155 164 EncryptionPasswordMap encryptionPasswords() const; 165 166 /** Returns whether the table is valid. */ 167 bool isValid() const; 156 168 157 169 private: … … 198 210 /* Prepare: */ 199 211 prepare(); 212 } 213 214 bool UIEncryptionDataModel::isValid() const 215 { 216 /* Check whether the model contains invalid passwords: */ 217 foreach (const bool &fValue, m_encryptionPasswordStatus.values()) 218 if (!fValue) 219 return false; 220 /* Valid by default: */ 221 return true; 200 222 } 201 223 … … 402 424 } 403 425 426 bool UIEncryptionDataTable::isValid() const 427 { 428 AssertPtrReturn(m_pModelEncryptionData, false); 429 return m_pModelEncryptionData->isValid(); 430 } 431 404 432 void UIEncryptionDataTable::prepare() 405 433 { … … 410 438 /* Assign configured model to table: */ 411 439 setModel(m_pModelEncryptionData); 440 /* Configure encryption-data model: */ 441 connect(m_pModelEncryptionData, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), 442 this, SIGNAL(sigDataChanged())); 412 443 } 413 444 … … 459 490 , m_pLabelDescription(0) 460 491 , m_pTableEncryptionData(0) 492 , m_pButtonBox(0) 461 493 { 462 494 /* Prepare: */ … … 464 496 /* Translate: */ 465 497 retranslateUi(); 498 /* Validate: */ 499 revalidate(); 466 500 } 467 501 … … 496 530 AssertPtrReturnVoid(m_pTableEncryptionData); 497 531 { 532 /* Configure encryption-data table: */ 533 connect(m_pTableEncryptionData, SIGNAL(sigDataChanged()), 534 this, SLOT(sltDataChanged())); 498 535 /* Add label into layout: */ 499 536 pInputLayout->addWidget(m_pTableEncryptionData); … … 503 540 } 504 541 /* Create button-box: */ 505 QIDialogButtonBox *pButtonBox = new QIDialogButtonBox;506 AssertPtrReturnVoid( pButtonBox);542 m_pButtonBox = new QIDialogButtonBox; 543 AssertPtrReturnVoid(m_pButtonBox); 507 544 { 508 545 /* Configure button-box: */ 509 pButtonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);510 connect( pButtonBox, SIGNAL(accepted()), this, SLOT(accept()));511 connect( pButtonBox, SIGNAL(rejected()), this, SLOT(reject()));546 m_pButtonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); 547 connect(m_pButtonBox, SIGNAL(accepted()), this, SLOT(accept())); 548 connect(m_pButtonBox, SIGNAL(rejected()), this, SLOT(reject())); 512 549 /* Add button-box into layout: */ 513 pMainLayout->addWidget( pButtonBox);550 pMainLayout->addWidget(m_pButtonBox); 514 551 } 515 552 } … … 533 570 } 534 571 572 void UIAddDiskEncryptionPasswordDialog::revalidate() 573 { 574 /* Validate: */ 575 AssertPtrReturnVoid(m_pButtonBox); 576 m_pButtonBox->button(QDialogButtonBox::Ok)->setEnabled(m_pTableEncryptionData->isValid()); 577 } 578 535 579 #include "UIAddDiskEncryptionPasswordDialog.moc" 536 580 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIAddDiskEncryptionPasswordDialog.h
r55015 r55016 28 28 /* Forward declarations: */ 29 29 class UIEncryptionDataTable; 30 class QIDialogButtonBox; 30 31 class QLabel; 31 32 … … 53 54 EncryptionPasswordMap encryptionPasswords() const; 54 55 56 private slots: 57 58 /** Handles the data change. */ 59 void sltDataChanged() { revalidate(); } 60 55 61 private: 56 62 … … 60 66 /** Translation routine. */ 61 67 void retranslateUi(); 68 69 /** Validation routine. */ 70 void revalidate(); 62 71 63 72 /** Holds the name of the machine we show this dialog for. */ … … 71 80 /** Holds the encryption-data table instance. */ 72 81 UIEncryptionDataTable *m_pTableEncryptionData; 82 /** Holds the button-box instance. */ 83 QIDialogButtonBox *m_pButtonBox; 73 84 }; 74 85
Note:
See TracChangeset
for help on using the changeset viewer.