Changeset 55015 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Mar 30, 2015 5:56:27 PM (10 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIAddDiskEncryptionPasswordDialog.cpp
r54936 r55015 31 31 32 32 /* GUI includes: */ 33 # include "UIMedium.h" 34 # include "UIIconPool.h" 35 # include "VBoxGlobal.h" 33 36 # include "QIDialogButtonBox.h" 34 37 # include "QIWithRetranslateUI.h" … … 44 47 enum UIEncryptionDataTableSection 45 48 { 49 UIEncryptionDataTableSection_Status, 46 50 UIEncryptionDataTableSection_Id, 47 51 UIEncryptionDataTableSection_Password, … … 99 103 100 104 /** Returns the shallow copy of the encryption password map instance. */ 101 EncryptionPassword sMap encryptionPasswords() const { return m_encryptionPasswords; }105 EncryptionPasswordMap encryptionPasswords() const { return m_encryptionPasswords; } 102 106 103 107 /** Returns the row count, taking optional @a parent instead of root if necessary. */ … … 122 126 void prepare(); 123 127 128 /** Returns whether passed @a strPassword is valid for medium with passed @a strMediumId. */ 129 bool isPasswordValid(const QString strMediumId, const QString strPassword); 130 124 131 /** Holds the encrypted medium map reference. */ 125 132 const EncryptedMediumMap &m_encryptedMediums; 126 133 127 134 /** Holds the encryption password map instance. */ 128 EncryptionPasswordsMap m_encryptionPasswords; 135 EncryptionPasswordMap m_encryptionPasswords; 136 /** Holds the encryption password status map instance. */ 137 EncryptionPasswordStatusMap m_encryptionPasswordStatus; 129 138 }; 130 139 … … 144 153 /** Returns the shallow copy of the encryption password map 145 154 * acquired from the UIEncryptionDataModel instance. */ 146 EncryptionPassword sMap encryptionPasswords() const;155 EncryptionPasswordMap encryptionPasswords() const; 147 156 148 157 private: … … 211 220 switch (index.column()) 212 221 { 222 case UIEncryptionDataTableSection_Status: return Qt::ItemIsEnabled | Qt::ItemIsSelectable; 213 223 case UIEncryptionDataTableSection_Id: return Qt::ItemIsEnabled | Qt::ItemIsSelectable; 214 224 case UIEncryptionDataTableSection_Password: return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable; … … 227 237 switch (iSection) 228 238 { 229 case UIEncryptionDataTableSection_Id: return tr("Password ID"); 230 case UIEncryptionDataTableSection_Password: return tr("Password"); 239 case UIEncryptionDataTableSection_Status: return tr("Status", "password table field"); 240 case UIEncryptionDataTableSection_Id: return tr("ID", "password table field"); 241 case UIEncryptionDataTableSection_Password: return tr("Password", "password table field"); 231 242 default: break; 232 243 } … … 243 254 switch (iRole) 244 255 { 256 case Qt::DecorationRole: 257 { 258 /* Depending on column index: */ 259 switch (index.column()) 260 { 261 case UIEncryptionDataTableSection_Status: 262 return m_encryptionPasswordStatus.value(m_encryptionPasswordStatus.keys().at(index.row())) ? 263 UIIconPool::iconSet(":/status_check_16px.png") : UIIconPool::iconSet(":/status_error_16px.png"); 264 default: 265 return QVariant(); 266 } 267 break; 268 } 245 269 case Qt::DisplayRole: 246 270 { … … 312 336 switch (index.column()) 313 337 { 314 case UIEncryptionDataTableSection_Password: m_encryptionPasswords[m_encryptionPasswords.keys().at(index.row())] = value.toString(); break; 315 default: break; 338 case UIEncryptionDataTableSection_Password: 339 { 340 /* Update password: */ 341 const int iRow = index.row(); 342 const QString strPassword = value.toString(); 343 const QString strKey = m_encryptionPasswords.keys().at(iRow); 344 m_encryptionPasswords[strKey] = strPassword; 345 /* Update password status: */ 346 const QString strMediumId = m_encryptedMediums.values(strKey).first(); 347 const bool fPasswordStatus = isPasswordValid(strMediumId, strPassword); 348 m_encryptionPasswordStatus[strKey] = fPasswordStatus; 349 /* Initiate explicit password status update: */ 350 const QModelIndex statusIndex = createIndex(iRow, UIEncryptionDataTableSection_Status); 351 emit dataChanged(statusIndex, statusIndex); 352 break; 353 } 354 default: 355 break; 316 356 } 317 357 /* Nothing to set by default: */ … … 321 361 void UIEncryptionDataModel::prepare() 322 362 { 323 /* Populate the map of passwords . */363 /* Populate the map of passwords and statuses. */ 324 364 foreach (const QString &strPasswordId, m_encryptedMediums.keys()) 365 { 325 366 m_encryptionPasswords.insert(strPasswordId, QString()); 367 m_encryptionPasswordStatus.insert(strPasswordId, false); 368 } 369 } 370 371 bool UIEncryptionDataModel::isPasswordValid(const QString strMediumId, const QString strPassword) 372 { 373 /* Look for the medium with passed ID: */ 374 const UIMedium uimedium = vboxGlobal().medium(strMediumId); 375 if (!uimedium.isNull()) 376 { 377 /* Check wrapped medium for validity: */ 378 const CMedium medium = uimedium.medium(); 379 if (!medium.isNull()) 380 { 381 /* Check whether the password is suitable for that medium. */ 382 medium.CheckEncryptionPassword(strPassword); 383 return medium.isOk(); 384 } 385 } 386 /* False by default: */ 387 return false; 326 388 } 327 389 … … 334 396 } 335 397 336 EncryptionPassword sMap UIEncryptionDataTable::encryptionPasswords() const337 { 338 AssertPtrReturn(m_pModelEncryptionData, EncryptionPassword sMap());398 EncryptionPasswordMap UIEncryptionDataTable::encryptionPasswords() const 399 { 400 AssertPtrReturn(m_pModelEncryptionData, EncryptionPasswordMap()); 339 401 return m_pModelEncryptionData->encryptionPasswords(); 340 402 } … … 384 446 verticalHeader()->setDefaultSectionSize((int)(verticalHeader()->minimumSectionSize() * 1.33)); 385 447 horizontalHeader()->setStretchLastSection(false); 448 horizontalHeader()->setResizeMode(UIEncryptionDataTableSection_Status, QHeaderView::ResizeToContents); 386 449 horizontalHeader()->setResizeMode(UIEncryptionDataTableSection_Id, QHeaderView::Interactive); 387 450 horizontalHeader()->setResizeMode(UIEncryptionDataTableSection_Password, QHeaderView::Stretch); … … 403 466 } 404 467 405 EncryptionPassword sMap UIAddDiskEncryptionPasswordDialog::encryptionPasswords() const406 { 407 AssertPtrReturn(m_pTableEncryptionData, EncryptionPassword sMap());468 EncryptionPasswordMap UIAddDiskEncryptionPasswordDialog::encryptionPasswords() const 469 { 470 AssertPtrReturn(m_pTableEncryptionData, EncryptionPasswordMap()); 408 471 return m_pTableEncryptionData->encryptionPasswords(); 409 472 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIAddDiskEncryptionPasswordDialog.h
r54754 r55015 32 32 /* Type definitions: */ 33 33 typedef QMultiMap<QString, QString> EncryptedMediumMap; 34 typedef QMap<QString, QString> EncryptionPasswordsMap; 34 typedef QMap<QString, QString> EncryptionPasswordMap; 35 typedef QMap<QString, bool> EncryptionPasswordStatusMap; 35 36 36 37 /** QDialog reimplementation used to … … 50 51 /** Returns the shallow copy of the encryption password map 51 52 * acquired from the UIEncryptionDataTable instance. */ 52 EncryptionPassword sMap encryptionPasswords() const;53 EncryptionPasswordMap encryptionPasswords() const; 53 54 54 55 private: -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r55006 r55015 2437 2437 2438 2438 /* Ask for the disk encryption passwords if necessary: */ 2439 EncryptionPassword sMap encryptionPasswords;2439 EncryptionPasswordMap encryptionPasswords; 2440 2440 if (!encryptedMediums.isEmpty()) 2441 2441 { -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsGeneral.cpp
r54956 r55015 314 314 /* Get the maps of encrypted mediums and their passwords: */ 315 315 const EncryptedMediumMap &encryptedMedium = generalData.m_encryptedMediums; 316 const EncryptionPassword sMap &encryptionPasswords = generalData.m_encryptionPasswords;316 const EncryptionPasswordMap &encryptionPasswords = generalData.m_encryptionPasswords; 317 317 /* Enumerate attachments: */ 318 318 foreach (const CMediumAttachment &attachment, m_machine.GetMediumAttachments()) -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsGeneral.h
r54953 r55015 92 92 EncryptedMediumMap m_encryptedMediums; 93 93 /** Holds the encryption passwords. */ 94 EncryptionPassword sMap m_encryptionPasswords;94 EncryptionPasswordMap m_encryptionPasswords; 95 95 }; 96 96 typedef UISettingsCache<UIDataSettingsMachineGeneral> UICacheSettingsMachineGeneral;
Note:
See TracChangeset
for help on using the changeset viewer.