Changeset 75017 in vbox
- Timestamp:
- Oct 23, 2018 8:18:51 PM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.cpp
r74871 r75017 216 216 const char *UIExtraDataDefs::GUI_LogViewerShowLineNumbersDisabled = "showLineNumbersDisabled"; 217 217 const char *UIExtraDataDefs::GUI_LogViewerNoFontStyleName = "noFontStyleName"; 218 219 220 bool UIToolStuff::isTypeOfClass(UIToolType enmType, UIToolClass enmClass) 221 { 222 switch (enmClass) 223 { 224 case UIToolClass_Global: 225 { 226 switch (enmType) 227 { 228 case UIToolType_Welcome: 229 case UIToolType_Media: 230 case UIToolType_Network: 231 case UIToolType_Cloud: 232 return true; 233 default: 234 break; 235 } 236 break; 237 } 238 case UIToolClass_Machine: 239 { 240 switch (enmType) 241 { 242 case UIToolType_Details: 243 case UIToolType_Snapshots: 244 case UIToolType_Logs: 245 return true; 246 default: 247 break; 248 } 249 break; 250 } 251 default: 252 break; 253 } 254 return false; 255 } -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h
r75016 r75017 686 686 687 687 688 /** Contains stuff related to tools handling. */ 689 namespace UIToolStuff 690 { 691 /** Returns whether passed @a enmType is of passed @a enmClass. */ 692 SHARED_LIBRARY_STUFF bool isTypeOfClass(UIToolType enmType, UIToolClass enmClass); 693 } 694 695 688 696 /** Selector UI: Details-element types. */ 689 697 enum DetailsElementType -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp
r75016 r75017 2737 2737 } 2738 2738 2739 QString UIExtraDataManager::toolsPaneLastItemsChosen() 2740 { 2741 return extraDataString(GUI_Tools_LastItemsSelected); 2742 } 2743 2744 void UIExtraDataManager::setToolsPaneLastItemsChosen(const QString &strSet) 2745 { 2746 setExtraDataString(GUI_Tools_LastItemsSelected, strSet); 2739 QList<UIToolType> UIExtraDataManager::toolsPaneLastItemsChosen() 2740 { 2741 /* Parse loaded data: */ 2742 QList<UIToolType> result; 2743 foreach (const QString &strValue, extraDataStringList(GUI_Tools_LastItemsSelected)) 2744 { 2745 const UIToolType enmType = gpConverter->fromInternalString<UIToolType>(strValue); 2746 if (enmType != UIToolType_Invalid) 2747 result << enmType; 2748 } 2749 2750 /* Return result: */ 2751 return result; 2752 } 2753 2754 void UIExtraDataManager::setToolsPaneLastItemsChosen(const QList<UIToolType> &set) 2755 { 2756 /* Serialize passed values: */ 2757 QStringList data; 2758 foreach (const UIToolType &enmType, set) 2759 data << gpConverter->toInternalString(enmType); 2760 2761 /* Re-cache corresponding extra-data: */ 2762 setExtraDataStringList(GUI_Tools_LastItemsSelected, data); 2747 2763 } 2748 2764 -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h
r75016 r75017 311 311 312 312 /** Returns last selected tool set of VirtualBox Manager. */ 313 Q StringtoolsPaneLastItemsChosen();314 /** Defines last selected tool @a s trSet of VirtualBox Manager. */315 void setToolsPaneLastItemsChosen(const Q String &strSet);313 QList<UIToolType> toolsPaneLastItemsChosen(); 314 /** Defines last selected tool @a set of VirtualBox Manager. */ 315 void setToolsPaneLastItemsChosen(const QList<UIToolType> &set); 316 316 317 317 /** Returns whether selector-window status-bar visible. */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UIToolsModel.cpp
r75016 r75017 510 510 { 511 511 /* Load selected items data: */ 512 const QString strData = gEDataManager->toolsPaneLastItemsChosen(); 513 514 /* Split serialized data to pair of values: */ 515 const QStringList values = strData.split(","); 512 const QList<UIToolType> data = gEDataManager->toolsPaneLastItemsChosen(); 516 513 517 514 /* First of them is current global class item definition: */ 518 UIToolType enmTypeGlobal = typeFromString(values.value(0));519 if (! isTypeOfClass(enmTypeGlobal, UIToolClass_Global))515 UIToolType enmTypeGlobal = data.value(0); 516 if (!UIToolStuff::isTypeOfClass(enmTypeGlobal, UIToolClass_Global)) 520 517 enmTypeGlobal = UIToolType_Welcome; 521 518 foreach (UIToolsItem *pItem, items()) … … 525 522 526 523 /* Second of them is current machine class item definition: */ 527 UIToolType enmTypeMachine = typeFromString(values.value(1));528 if (! isTypeOfClass(enmTypeMachine, UIToolClass_Machine))524 UIToolType enmTypeMachine = data.value(1); 525 if (!UIToolStuff::isTypeOfClass(enmTypeMachine, UIToolClass_Machine)) 529 526 enmTypeMachine = UIToolType_Details; 530 527 foreach (UIToolsItem *pItem, items()) … … 537 534 { 538 535 /* Prepare selected items data: */ 539 const QString strData = QString("%1,%2") 540 .arg(typeToString(m_pLastItemGlobal->itemType())) 541 .arg(typeToString(m_pLastItemMachine->itemType())); 536 const QList<UIToolType> set = QList<UIToolType>() << m_pLastItemGlobal->itemType() << m_pLastItemMachine->itemType(); 542 537 543 538 /* Save selected items data: */ 544 gEDataManager->setToolsPaneLastItemsChosen(s trData);539 gEDataManager->setToolsPaneLastItemsChosen(set); 545 540 } 546 541 … … 590 585 return QVariant(); 591 586 } 592 593 /* static */594 QString UIToolsModel::typeToString(UIToolType enmType)595 {596 QMap<UIToolType, QString> values;597 /* Global classes: */598 values[UIToolType_Welcome] = "Welcome";599 values[UIToolType_Media] = "Media";600 values[UIToolType_Network] = "Network";601 values[UIToolType_Cloud] = "Cloud";602 /* Machine classes: */603 values[UIToolType_Details] = "Details";604 values[UIToolType_Snapshots] = "Snapshots";605 values[UIToolType_Logs] = "Logs";606 /* Return value, null-string by default: */607 return values.value(enmType, QString());608 }609 610 /* static */611 UIToolType UIToolsModel::typeFromString(const QString &strType)612 {613 QMap<QString, UIToolType> values;614 /* Global classes: */615 values["Welcome"] = UIToolType_Welcome;616 values["Media"] = UIToolType_Media;617 values["Network"] = UIToolType_Network;618 values["Cloud"] = UIToolType_Cloud;619 /* Machine classes: */620 values["Details"] = UIToolType_Details;621 values["Snapshots"] = UIToolType_Snapshots;622 values["Logs"] = UIToolType_Logs;623 /* Return value, UIToolType_Invalid by default: */624 return values.value(strType, UIToolType_Invalid);625 }626 627 /* static */628 bool UIToolsModel::isTypeOfClass(UIToolType enmType, UIToolClass enmClass)629 {630 switch (enmClass)631 {632 case UIToolClass_Global:633 {634 switch (enmType)635 {636 case UIToolType_Welcome:637 case UIToolType_Media:638 case UIToolType_Network:639 case UIToolType_Cloud:640 return true;641 default:642 break;643 }644 break;645 }646 case UIToolClass_Machine:647 {648 switch (enmType)649 {650 case UIToolType_Details:651 case UIToolType_Snapshots:652 case UIToolType_Logs:653 return true;654 default:655 break;656 }657 break;658 }659 default:660 break;661 }662 return false;663 } -
trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UIToolsModel.h
r75016 r75017 227 227 /** Returns abstractly stored data value for certain @a iKey. */ 228 228 QVariant data(int iKey) const; 229 230 /** Returns @a enmType string representation.231 * @todo move to UIConverter one day .. */232 static QString typeToString(UIToolType enmType);233 /** Returns @a strType converted to corresponding UIToolType.234 * @todo move to UIConverter one day .. */235 static UIToolType typeFromString(const QString &strType);236 237 /** Returns whether passed @a enmType is of passed @a enmClass. */238 static bool isTypeOfClass(UIToolType enmType, UIToolClass enmClass);239 229 /** @} */ 240 230
Note:
See TracChangeset
for help on using the changeset viewer.