- Timestamp:
- Mar 26, 2019 6:02:47 PM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.cpp
r77891 r77892 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UIChooser Model class implementation.3 * VBox Qt GUI - UIChooserAbstractModel class implementation. 4 4 */ 5 5 … … 38 38 UIChooserAbstractModel:: UIChooserAbstractModel(UIChooser *pParent) 39 39 : QObject(pParent) 40 , m_pParent(pParent) 40 41 , m_pInvisibleRootNode(0) 41 42 { … … 51 52 void UIChooserAbstractModel::deinit() 52 53 { 53 /* Currently we are not saving group descriptors 54 * (which reflecting group toggle-state) on-the-fly, 55 * so, for now we are additionally save group orders 56 * when exiting application: */ 54 // WORKAROUND: 55 // Currently we are not saving group descriptors 56 // (which reflecting group toggle-state) on-the-fly, 57 // so for now we are additionally save group orders 58 // when exiting application: 57 59 saveGroupOrders(); 58 60 … … 73 75 void UIChooserAbstractModel::wipeOutEmptyGroups() 74 76 { 75 wipeOutEmptyGroups (invisibleRoot());77 wipeOutEmptyGroupsStartingFrom(invisibleRoot()); 76 78 } 77 79 … … 101 103 } 102 104 103 /* Prepare result: */105 /* Prepare/return result: */ 104 106 QString strResult = strMinimumName; 105 107 if (iMinimumPossibleNumber) … … 110 112 void UIChooserAbstractModel::saveGroupSettings() 111 113 { 112 emit sig GroupSavingStarted();114 emit sigStartGroupSaving(); 113 115 } 114 116 … … 182 184 } 183 185 184 void UIChooserAbstractModel::slt GroupSavingStart()186 void UIChooserAbstractModel::sltStartGroupSaving() 185 187 { 186 188 saveGroupDefinitions(); … … 208 210 { 209 211 /* Setup parent connections: */ 210 connect(this, SIGNAL(sigGroupSavingStateChanged()),211 parent(), SIGNAL(sigGroupSavingStateChanged()));212 connect(this, &UIChooserAbstractModel::sigGroupSavingStateChanged, 213 m_pParent, &UIChooser::sigGroupSavingStateChanged); 212 214 213 215 /* Setup global connections: */ 214 connect(gVBoxEvents, SIGNAL(sigMachineStateChange(QUuid, KMachineState)),215 this, SLOT(sltMachineStateChanged(QUuid, KMachineState)));216 connect(gVBoxEvents, SIGNAL(sigMachineDataChange(QUuid)),217 this, SLOT(sltMachineDataChanged(QUuid)));218 connect(gVBoxEvents, SIGNAL(sigMachineRegistered(QUuid, bool)),219 this, SLOT(sltMachineRegistered(QUuid, bool)));220 connect(gVBoxEvents, SIGNAL(sigSessionStateChange(QUuid, KSessionState)),221 this, SLOT(sltSessionStateChanged(QUuid, KSessionState)));222 connect(gVBoxEvents, SIGNAL(sigSnapshotTake(QUuid, QUuid)),223 this, SLOT(sltSnapshotChanged(QUuid, QUuid)));224 connect(gVBoxEvents, SIGNAL(sigSnapshotDelete(QUuid, QUuid)),225 this, SLOT(sltSnapshotChanged(QUuid, QUuid)));226 connect(gVBoxEvents, SIGNAL(sigSnapshotChange(QUuid, QUuid)),227 this, SLOT(sltSnapshotChanged(QUuid, QUuid)));228 connect(gVBoxEvents, SIGNAL(sigSnapshotRestore(QUuid, QUuid)),229 this, SLOT(sltSnapshotChanged(QUuid, QUuid)));216 connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigMachineStateChange, 217 this, &UIChooserAbstractModel::sltMachineStateChanged); 218 connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigMachineDataChange, 219 this, &UIChooserAbstractModel::sltMachineDataChanged); 220 connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigMachineRegistered, 221 this, &UIChooserAbstractModel::sltMachineRegistered); 222 connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigSessionStateChange, 223 this, &UIChooserAbstractModel::sltSessionStateChanged); 224 connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigSnapshotTake, 225 this, &UIChooserAbstractModel::sltSnapshotChanged); 226 connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigSnapshotDelete, 227 this, &UIChooserAbstractModel::sltSnapshotChanged); 228 connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigSnapshotChange, 229 this, &UIChooserAbstractModel::sltSnapshotChanged); 230 connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigSnapshotRestore, 231 this, &UIChooserAbstractModel::sltSnapshotChanged); 230 232 231 233 /* Setup group saving connections: */ 232 connect(this, &UIChooserAbstractModel::sig GroupSavingStarted,233 this, &UIChooserAbstractModel::slt GroupSavingStart,234 connect(this, &UIChooserAbstractModel::sigStartGroupSaving, 235 this, &UIChooserAbstractModel::sltStartGroupSaving, 234 236 Qt::QueuedConnection); 235 237 } … … 342 344 new UIChooserNodeGroup(pParentNode, 343 345 false /* favorite */, 344 getDesired Position(pParentNode, UIChooserItemType_Group, strSecondSubName),346 getDesiredNodePosition(pParentNode, UIChooserItemType_Group, strSecondSubName), 345 347 strSecondSubName, 346 fAllGroupsOpened || should BeGroupOpened(pParentNode, strSecondSubName));348 fAllGroupsOpened || shouldGroupNodeBeOpened(pParentNode, strSecondSubName)); 347 349 return strSecondSuffix.isEmpty() ? pNewGroupNode : getGroupNode(strFirstSuffix, pNewGroupNode, fAllGroupsOpened); 348 350 } 349 351 350 bool UIChooserAbstractModel::should BeGroupOpened(UIChooserNode *pParentNode, const QString &strName)352 bool UIChooserAbstractModel::shouldGroupNodeBeOpened(UIChooserNode *pParentNode, const QString &strName) 351 353 { 352 354 /* Read group definitions: */ … … 376 378 } 377 379 378 void UIChooserAbstractModel::wipeOutEmptyGroups (UIChooserNode *pParent)380 void UIChooserAbstractModel::wipeOutEmptyGroupsStartingFrom(UIChooserNode *pParent) 379 381 { 380 382 /* Cleanup all the group-items recursively first: */ 381 383 foreach (UIChooserNode *pNode, pParent->nodes(UIChooserItemType_Group)) 382 wipeOutEmptyGroups (pNode);384 wipeOutEmptyGroupsStartingFrom(pNode); 383 385 /* If parent has no nodes: */ 384 386 if (!pParent->hasNodes()) … … 421 423 } 422 424 423 int UIChooserAbstractModel::getDesired Position(UIChooserNode *pParentNode, UIChooserItemType enmType, const QString &strName)425 int UIChooserAbstractModel::getDesiredNodePosition(UIChooserNode *pParentNode, UIChooserItemType enmType, const QString &strName) 424 426 { 425 427 /* End of list (by default)? */ 426 428 int iNewNodeDesiredPosition = -1; 427 429 /* Which position should be new node placed by definitions: */ 428 int iNewNodeDefinitionPosition = positionFromDefinitions(pParentNode, enmType, strName);430 int iNewNodeDefinitionPosition = getDefinedNodePosition(pParentNode, enmType, strName); 429 431 /* If some position wanted: */ 430 432 if (iNewNodeDefinitionPosition != -1) … … 443 445 QString(); 444 446 AssertMsg(!strDefinitionName.isEmpty(), ("Wrong definition name!")); 445 int iNodeDefinitionPosition = positionFromDefinitions(pParentNode, enmType, strDefinitionName);447 int iNodeDefinitionPosition = getDefinedNodePosition(pParentNode, enmType, strDefinitionName); 446 448 /* If some position wanted: */ 447 449 if (iNodeDefinitionPosition != -1) … … 460 462 } 461 463 462 int UIChooserAbstractModel:: positionFromDefinitions(UIChooserNode *pParentNode, UIChooserItemType enmType, const QString &strName)464 int UIChooserAbstractModel::getDefinedNodePosition(UIChooserNode *pParentNode, UIChooserItemType enmType, const QString &strName) 463 465 { 464 466 /* Read group definitions: */ … … 509 511 new UIChooserNodeMachine(pParentNode, 510 512 false /* favorite */, 511 getDesired Position(pParentNode, UIChooserItemType_Machine, toOldStyleUuid(comMachine.GetId())),513 getDesiredNodePosition(pParentNode, UIChooserItemType_Machine, toOldStyleUuid(comMachine.GetId())), 512 514 comMachine); 513 515 } -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.h
r77891 r77892 49 49 /** @name Group saving stuff. 50 50 * @{ */ 51 /** Notifies about group saving started. */52 void sig GroupSavingStarted();51 /** Commands to start group saving. */ 52 void sigStartGroupSaving(); 53 53 /** Notifies about group saving state changed. */ 54 54 void sigGroupSavingStateChanged(); … … 115 115 * @{ */ 116 116 /** Handles request to start group saving. */ 117 void slt GroupSavingStart();117 void sltStartGroupSaving(); 118 118 /** Handles group definition saving complete. */ 119 119 void sltGroupDefinitionsSaveComplete(); … … 143 143 * @param fAllGroupsOpened Brings whether we should open all the groups till the required one. */ 144 144 UIChooserNode *getGroupNode(const QString &strName, UIChooserNode *pParentNode, bool fAllGroupsOpened); 145 /** Returns whether group with certain @a strName should be opened, searching starting from the passed @a pParentItem. */146 bool should BeGroupOpened(UIChooserNode *pParentNode, const QString &strName);145 /** Returns whether group node with certain @a strName should be opened, searching starting from the passed @a pParentItem. */ 146 bool shouldGroupNodeBeOpened(UIChooserNode *pParentNode, const QString &strName); 147 147 148 148 /** Wipes out empty groups starting from @a pParentItem. */ 149 void wipeOutEmptyGroups (UIChooserNode *pParentNode);149 void wipeOutEmptyGroupsStartingFrom(UIChooserNode *pParentNode); 150 150 151 151 /** Returns whether global node within the @a pParentNode is favorite. */ … … 153 153 154 154 /** Acquires desired position for a child of @a pParentNode with specified @a enmType and @a strName. */ 155 int getDesired Position(UIChooserNode *pParentNode, UIChooserItemType enmType, const QString &strName);156 /** Acquires saved position for a child of @a pParentNode with specified @a enmType and @a strName. */157 int positionFromDefinitions(UIChooserNode *pParentNode, UIChooserItemType enmType, const QString &strName);155 int getDesiredNodePosition(UIChooserNode *pParentNode, UIChooserItemType enmType, const QString &strName); 156 /** Acquires defined position for a child of @a pParentNode with specified @a enmType and @a strName. */ 157 int getDefinedNodePosition(UIChooserNode *pParentNode, UIChooserItemType enmType, const QString &strName); 158 158 159 159 /** Creates machine node based on certain @a comMachine as a child of specified @a pParentNode. */ … … 181 181 * @note Required for backward compatibility after QString=>QUuid change. */ 182 182 static QString toOldStyleUuid(const QUuid &uId); 183 /** @} */ 184 185 /** @name General stuff. 186 * @{ */ 187 /** Holds the parent widget reference. */ 188 UIChooser *m_pParent; 183 189 /** @} */ 184 190
Note:
See TracChangeset
for help on using the changeset viewer.