Changeset 77844 in vbox
- Timestamp:
- Mar 22, 2019 10:41:16 AM (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/UIChooserHandlerKeyboard.cpp
r77752 r77844 23 23 #include "UIChooserModel.h" 24 24 #include "UIChooserItemGroup.h" 25 #include "UIChooserItemMachine.h" 26 #include "UIChooserNodeGroup.h" 27 #include "UIChooserNodeMachine.h" 25 28 26 29 … … 327 330 } 328 331 329 void UIChooserHandlerKeyboard::shift(UIItemShiftDirection direction, UIItemShiftSize size) const 330 { 331 Q_UNUSED(direction); 332 Q_UNUSED(size); 333 /// @todo implement item shifting 334 335 #if 0 336 /* Get focus-item and his parent: */ 337 UIChooserItem *pFocusItem = model()->focusItem(); 338 UIChooserItem *pParentItem = pFocusItem->parentItem(); 339 /* Get the list of focus-item neighbours: */ 340 UIChooserItemType type = (UIChooserItemType)pFocusItem->type(); 341 QList<UIChooserItem*> items = pParentItem->items(type); 342 /* Get focus-item position: */ 343 int iFocusPosition = items.indexOf(pFocusItem); 344 345 /* Depending on direction: */ 346 switch (direction) 332 void UIChooserHandlerKeyboard::shift(UIItemShiftDirection enmDirection, UIItemShiftType enmShiftType) const 333 { 334 /* Get focus-node and its parent: */ 335 UIChooserNode *pFocusNode = model()->focusItem()->node(); 336 UIChooserNode *pParentNode = pFocusNode->parentNode(); 337 /* Get focus-node position: */ 338 const int iFocusNodePosition = pFocusNode->position(); 339 340 /* Calculate new position: */ 341 int iNewFocusNodePosition = -1; 342 switch (enmDirection) 347 343 { 348 344 case UIItemShiftDirection_Up: 349 345 { 350 /* Is focus-item shiftable? */ 351 if (iFocusPosition == 0) 352 return; 353 /* Shift item: */ 354 switch (size) 355 { 356 case UIItemShiftSize_Item: items.move(iFocusPosition, iFocusPosition - 1); break; 357 case UIItemShiftSize_Full: items.move(iFocusPosition, 0); break; 358 default: break; 359 } 346 if (iFocusNodePosition > 0) 347 switch (enmShiftType) 348 { 349 case UIItemShiftSize_Item: iNewFocusNodePosition = iFocusNodePosition - 1; break; 350 case UIItemShiftSize_Full: iNewFocusNodePosition = 0; break; 351 default: break; 352 } 360 353 break; 361 354 } 362 355 case UIItemShiftDirection_Down: 363 356 { 364 /* Is focus-item shiftable? */ 365 if (iFocusPosition == items.size() - 1) 366 return; 367 /* Shift item: */ 368 switch (size) 369 { 370 case UIItemShiftSize_Item: items.move(iFocusPosition, iFocusPosition + 1); break; 371 case UIItemShiftSize_Full: items.move(iFocusPosition, items.size() - 1); break; 372 default: break; 373 } 357 if (iFocusNodePosition < pParentNode->nodes(pFocusNode->type()).size() - 1) 358 switch (enmShiftType) 359 { 360 case UIItemShiftSize_Item: iNewFocusNodePosition = iFocusNodePosition + 2; break; 361 case UIItemShiftSize_Full: iNewFocusNodePosition = pParentNode->nodes(pFocusNode->type()).size(); break; 362 default: break; 363 } 374 364 break; 375 365 } … … 377 367 break; 378 368 } 379 380 /* Reassign items: */ 381 pParentItem->setItems(items, type); 369 /* Filter out invalid requests: */ 370 if (iNewFocusNodePosition == -1) 371 return; 372 373 /* Create shifted node/item: */ 374 UIChooserItem *pShiftedItem = 0; 375 switch (pFocusNode->type()) 376 { 377 case UIChooserItemType_Group: 378 { 379 UIChooserNodeGroup *pNewNode = new UIChooserNodeGroup(pParentNode, pFocusNode->toGroupNode(), iNewFocusNodePosition); 380 pShiftedItem = new UIChooserItemGroup(pParentNode->item(), pNewNode); 381 break; 382 } 383 case UIChooserItemType_Machine: 384 { 385 UIChooserNodeMachine *pNewNode = new UIChooserNodeMachine(pParentNode, pFocusNode->toMachineNode(), iNewFocusNodePosition); 386 pShiftedItem = new UIChooserItemMachine(pParentNode->item(), pNewNode); 387 break; 388 } 389 default: 390 break; 391 } 392 393 /* Delete old node/item: */ 394 delete pFocusNode; 395 382 396 /* Update model: */ 397 model()->wipeOutEmptyGroups(); 383 398 model()->updateNavigation(); 384 399 model()->updateLayout(); 385 #endif 386 } 400 model()->setCurrentItem(pShiftedItem); 401 model()->saveGroupSettings(); 402 } -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserHandlerKeyboard.h
r76581 r77844 44 44 }; 45 45 46 /* Item shift size:*/47 enum UIItemShift Size46 /** Item shift types. */ 47 enum UIItemShiftType 48 48 { 49 49 UIItemShiftSize_Item, … … 74 74 75 75 /* Helper: Item shift delegate: */ 76 void shift(UIItemShiftDirection direction, UIItemShiftSize size) const;76 void shift(UIItemShiftDirection enmDirection, UIItemShiftType enmShiftType) const; 77 77 78 78 /* Variables: */ 79 79 UIChooserModel *m_pModel; 80 QMap<int, UIItemShift Size> m_shiftMap;80 QMap<int, UIItemShiftType> m_shiftMap; 81 81 }; 82 82
Note:
See TracChangeset
for help on using the changeset viewer.