- Timestamp:
- Mar 28, 2019 12:42:50 PM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserHandlerKeyboard.cpp
r77933 r77934 88 88 { 89 89 /* Determine current-item position: */ 90 int iPosition = model()->navigation List().indexOf(model()->currentItem());90 int iPosition = model()->navigationItems().indexOf(model()->currentItem()); 91 91 /* Determine 'previous' item: */ 92 92 UIChooserItem *pPreviousItem = 0; … … 94 94 { 95 95 if (pEvent->key() == Qt::Key_Up) 96 pPreviousItem = model()->navigation List().at(iPosition - 1);96 pPreviousItem = model()->navigationItems().at(iPosition - 1); 97 97 else if (pEvent->key() == Qt::Key_Home) 98 pPreviousItem = model()->navigation List().first();98 pPreviousItem = model()->navigationItems().first(); 99 99 } 100 100 if (pPreviousItem) … … 104 104 /* Calculate positions: */ 105 105 UIChooserItem *pFirstItem = model()->firstSelectedItem(); 106 int iFirstPosition = model()->navigation List().indexOf(pFirstItem);107 int iPreviousPosition = model()->navigation List().indexOf(pPreviousItem);106 int iFirstPosition = model()->navigationItems().indexOf(pFirstItem); 107 int iPreviousPosition = model()->navigationItems().indexOf(pPreviousItem); 108 108 /* Populate list of items from 'first' to 'previous': */ 109 109 QList<UIChooserItem*> items; 110 110 if (iFirstPosition <= iPreviousPosition) 111 111 for (int i = iFirstPosition; i <= iPreviousPosition; ++i) 112 items << model()->navigation List().at(i);112 items << model()->navigationItems().at(i); 113 113 else 114 114 for (int i = iFirstPosition; i >= iPreviousPosition; --i) 115 items << model()->navigation List().at(i);115 items << model()->navigationItems().at(i); 116 116 /* Set that list as selected: */ 117 117 model()->setSelectedItems(items); … … 131 131 { 132 132 /* Determine current-item position: */ 133 int iPosition = model()->navigation List().indexOf(model()->currentItem());133 int iPosition = model()->navigationItems().indexOf(model()->currentItem()); 134 134 /* Determine 'previous' item: */ 135 135 UIChooserItem *pPreviousItem = 0; … … 137 137 { 138 138 if (pEvent->key() == Qt::Key_Up) 139 pPreviousItem = model()->navigation List().at(iPosition - 1);139 pPreviousItem = model()->navigationItems().at(iPosition - 1); 140 140 else if (pEvent->key() == Qt::Key_Home) 141 pPreviousItem = model()->navigation List().first();141 pPreviousItem = model()->navigationItems().first(); 142 142 } 143 143 if (pPreviousItem) … … 181 181 { 182 182 /* Determine current-item position: */ 183 int iPosition = model()->navigation List().indexOf(model()->currentItem());183 int iPosition = model()->navigationItems().indexOf(model()->currentItem()); 184 184 /* Determine 'next' item: */ 185 185 UIChooserItem *pNextItem = 0; 186 if (iPosition < model()->navigation List().size() - 1)186 if (iPosition < model()->navigationItems().size() - 1) 187 187 { 188 188 if (pEvent->key() == Qt::Key_Down) 189 pNextItem = model()->navigation List().at(iPosition + 1);189 pNextItem = model()->navigationItems().at(iPosition + 1); 190 190 else if (pEvent->key() == Qt::Key_End) 191 pNextItem = model()->navigation List().last();191 pNextItem = model()->navigationItems().last(); 192 192 } 193 193 if (pNextItem) … … 197 197 /* Calculate positions: */ 198 198 UIChooserItem *pFirstItem = model()->firstSelectedItem(); 199 int iFirstPosition = model()->navigation List().indexOf(pFirstItem);200 int iNextPosition = model()->navigation List().indexOf(pNextItem);199 int iFirstPosition = model()->navigationItems().indexOf(pFirstItem); 200 int iNextPosition = model()->navigationItems().indexOf(pNextItem); 201 201 /* Populate list of items from 'first' to 'next': */ 202 202 QList<UIChooserItem*> items; 203 203 if (iFirstPosition <= iNextPosition) 204 204 for (int i = iFirstPosition; i <= iNextPosition; ++i) 205 items << model()->navigation List().at(i);205 items << model()->navigationItems().at(i); 206 206 else 207 207 for (int i = iFirstPosition; i >= iNextPosition; --i) 208 items << model()->navigation List().at(i);208 items << model()->navigationItems().at(i); 209 209 /* Set that list as selected: */ 210 210 model()->setSelectedItems(items); … … 224 224 { 225 225 /* Determine current-item position: */ 226 int iPosition = model()->navigation List().indexOf(model()->currentItem());226 int iPosition = model()->navigationItems().indexOf(model()->currentItem()); 227 227 /* Determine 'next' item: */ 228 228 UIChooserItem *pNextItem = 0; 229 if (iPosition < model()->navigation List().size() - 1)229 if (iPosition < model()->navigationItems().size() - 1) 230 230 { 231 231 if (pEvent->key() == Qt::Key_Down) 232 pNextItem = model()->navigation List().at(iPosition + 1);232 pNextItem = model()->navigationItems().at(iPosition + 1); 233 233 else if (pEvent->key() == Qt::Key_End) 234 pNextItem = model()->navigation List().last();234 pNextItem = model()->navigationItems().last(); 235 235 } 236 236 if (pNextItem) … … 388 388 /* Update model: */ 389 389 model()->wipeOutEmptyGroups(); 390 model()->updateNavigation ();390 model()->updateNavigationItemList(); 391 391 model()->updateLayout(); 392 392 model()->setSelectedItem(pShiftedItem); -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserHandlerMouse.cpp
r77933 r77934 111 111 /* Calculate positions: */ 112 112 UIChooserItem *pFirstItem = model()->firstSelectedItem(); 113 int iFirstPosition = model()->navigation List().indexOf(pFirstItem);114 int iClickedPosition = model()->navigation List().indexOf(pClickedItem);113 int iFirstPosition = model()->navigationItems().indexOf(pFirstItem); 114 int iClickedPosition = model()->navigationItems().indexOf(pClickedItem); 115 115 /* Populate list of items from 'first' to 'clicked': */ 116 116 QList<UIChooserItem*> items; 117 117 if (iFirstPosition <= iClickedPosition) 118 118 for (int i = iFirstPosition; i <= iClickedPosition; ++i) 119 items << model()->navigation List().at(i);119 items << model()->navigationItems().at(i); 120 120 else 121 121 for (int i = iFirstPosition; i >= iClickedPosition; --i) 122 items << model()->navigation List().at(i);122 items << model()->navigationItems().at(i); 123 123 /* Make that list selected: */ 124 124 model()->setSelectedItems(items); -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGlobal.cpp
r77933 r77934 380 380 } 381 381 /* If that item is in navigation list: */ 382 if (model()->navigation List().contains(this))382 if (model()->navigationItems().contains(this)) 383 383 { 384 384 /* Remove item from the navigation list: */ 385 model()->removeFromNavigation List(this);385 model()->removeFromNavigationItems(this); 386 386 } 387 387 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGroup.cpp
r77933 r77934 834 834 /* Update model: */ 835 835 pModel->wipeOutEmptyGroups(); 836 pModel->updateNavigation ();836 pModel->updateNavigationItemList(); 837 837 pModel->updateLayout(); 838 838 pModel->setSelectedItem(pNewGroupItem); … … 888 888 /* Update model: */ 889 889 pModel->wipeOutEmptyGroups(); 890 pModel->updateNavigation ();890 pModel->updateNavigationItemList(); 891 891 pModel->updateLayout(); 892 892 pModel->setSelectedItem(pNewMachineItem); … … 977 977 updateGeometry(); 978 978 /* Update navigation: */ 979 model()->updateNavigation ();979 model()->updateNavigationItemList(); 980 980 /* Relayout model: */ 981 981 model()->updateLayout(); … … 994 994 updateGeometry(); 995 995 /* Update navigation: */ 996 model()->updateNavigation ();996 model()->updateNavigationItemList(); 997 997 /* Relayout model: */ 998 998 model()->updateLayout(); … … 1217 1217 } 1218 1218 /* If that item is in navigation list: */ 1219 if (model()->navigation List().contains(this))1219 if (model()->navigationItems().contains(this)) 1220 1220 { 1221 1221 /* Remove item from the navigation list: */ 1222 model()->removeFromNavigation List(this);1222 model()->removeFromNavigationItems(this); 1223 1223 } 1224 1224 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemMachine.cpp
r77933 r77934 442 442 /* Update model: */ 443 443 pModel->wipeOutEmptyGroups(); 444 pModel->updateNavigation ();444 pModel->updateNavigationItemList(); 445 445 pModel->updateLayout(); 446 446 pModel->setSelectedItem(pNewGroupItem); … … 544 544 } 545 545 /* If that item is in navigation list: */ 546 if (model()->navigation List().contains(this))546 if (model()->navigationItems().contains(this)) 547 547 { 548 548 /* Remove item from the navigation list: */ 549 model()->removeFromNavigation List(this);549 model()->removeFromNavigationItems(this); 550 550 } 551 551 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp
r77933 r77934 82 82 /* Build tree for main root: */ 83 83 buildTreeForMainRoot(); 84 updateNavigation ();84 updateNavigationItemList(); 85 85 updateLayout(); 86 86 … … 174 174 { 175 175 /* Add item to current selected-item list if navigation list contains it: */ 176 if (pItem && navigation List().contains(pItem))176 if (pItem && navigationItems().contains(pItem)) 177 177 m_selectedItems << pItem; 178 178 else … … 240 240 241 241 /* Make sure found item is in navigation list: */ 242 if (!pItem || !navigation List().contains(pItem))242 if (!pItem || !navigationItems().contains(pItem)) 243 243 return; 244 244 … … 358 358 if (pItem) 359 359 { 360 int idxBefore = navigation List().indexOf(pItem) - 1;360 int idxBefore = navigationItems().indexOf(pItem) - 1; 361 361 int idxAfter = idxBefore + 2; 362 while (idxBefore >= 0 || idxAfter < navigation List().size())362 while (idxBefore >= 0 || idxAfter < navigationItems().size()) 363 363 { 364 364 if (idxBefore >= 0) 365 365 { 366 pItem = navigation List().at(idxBefore);366 pItem = navigationItems().at(idxBefore); 367 367 if (!selectedItems().contains(pItem) && pItem->type() == UIChooserItemType_Machine) 368 368 return pItem; 369 369 --idxBefore; 370 370 } 371 if (idxAfter < navigation List().size())371 if (idxAfter < navigationItems().size()) 372 372 { 373 pItem = navigation List().at(idxAfter);373 pItem = navigationItems().at(idxAfter); 374 374 if (!selectedItems().contains(pItem) && pItem->type() == UIChooserItemType_Machine) 375 375 return pItem; … … 422 422 } 423 423 424 const QList<UIChooserItem*> &UIChooserModel::navigation List() const425 { 426 return m_navigation List;427 } 428 429 void UIChooserModel::removeFromNavigation List(UIChooserItem *pItem)424 const QList<UIChooserItem*> &UIChooserModel::navigationItems() const 425 { 426 return m_navigationItems; 427 } 428 429 void UIChooserModel::removeFromNavigationItems(UIChooserItem *pItem) 430 430 { 431 431 AssertMsg(pItem, ("Passed item is invalid!")); 432 m_navigation List.removeAll(pItem);433 } 434 435 void UIChooserModel::updateNavigation ()436 { 437 m_navigation List.clear();438 m_navigation List = createNavigationList(root());432 m_navigationItems.removeAll(pItem); 433 } 434 435 void UIChooserModel::updateNavigationItemList() 436 { 437 m_navigationItems.clear(); 438 m_navigationItems = createNavigationItemList(root()); 439 439 } 440 440 … … 596 596 { 597 597 /* Walk thrugh all the items of navigation list: */ 598 foreach (UIChooserItem *pItem, navigation List())598 foreach (UIChooserItem *pItem, navigationItems()) 599 599 { 600 600 /* And for each global item: */ … … 665 665 { 666 666 /* Update tree for main root: */ 667 updateNavigation ();667 updateNavigationItemList(); 668 668 updateLayout(); 669 669 670 670 /* Make sure selected-item present, if possible: */ 671 if (!firstSelectedItem() && !navigation List().isEmpty())672 setSelectedItem(navigation List().first());671 if (!firstSelectedItem() && !navigationItems().isEmpty()) 672 setSelectedItem(navigationItems().first()); 673 673 /* Make sure current-item present, if possible: */ 674 674 else if (!currentItem() && firstSelectedItem()) … … 685 685 /* Rebuild tree for main root: */ 686 686 buildTreeForMainRoot(); 687 updateNavigation ();687 updateNavigationItemList(); 688 688 updateLayout(); 689 689 … … 707 707 /* Rebuild tree for main root: */ 708 708 buildTreeForMainRoot(); 709 updateNavigation ();709 updateNavigationItemList(); 710 710 updateLayout(); 711 711 … … 719 719 { 720 720 /* Make sure at least one item selected after that: */ 721 if (!firstSelectedItem() && !navigation List().isEmpty())722 setSelectedItem(navigation List().first());721 if (!firstSelectedItem() && !navigationItems().isEmpty()) 722 setSelectedItem(navigationItems().first()); 723 723 } 724 724 … … 759 759 /* Rebuild tree for main root: */ 760 760 buildTreeForMainRoot(); 761 updateNavigation ();761 updateNavigationItemList(); 762 762 updateLayout(); 763 763 } … … 849 849 850 850 /* And update model: */ 851 updateNavigation ();851 updateNavigationItemList(); 852 852 updateLayout(); 853 853 if (!copiedItems.isEmpty()) … … 857 857 } 858 858 else 859 setSelectedItem(navigation List().first());859 setSelectedItem(navigationItems().first()); 860 860 saveGroupSettings(); 861 861 } … … 956 956 /* Update model: */ 957 957 wipeOutEmptyGroups(); 958 updateNavigation ();958 updateNavigationItemList(); 959 959 updateLayout(); 960 960 setSelectedItem(pNewGroupItem); … … 977 977 /* Rebuild tree for main root: */ 978 978 buildTreeForMainRoot(); 979 updateNavigation ();979 updateNavigationItemList(); 980 980 updateLayout(); 981 981 } … … 1299 1299 /* Load last selected-item (choose first if unable to load): */ 1300 1300 setSelectedItem(gEDataManager->selectorWindowLastItemChosen()); 1301 if (!firstSelectedItem() && !navigation List().isEmpty())1302 setSelectedItem(navigation List().first());1301 if (!firstSelectedItem() && !navigationItems().isEmpty()) 1302 setSelectedItem(navigationItems().first()); 1303 1303 } 1304 1304 … … 1463 1463 } 1464 1464 1465 QList<UIChooserItem*> UIChooserModel::createNavigation List(UIChooserItem *pItem)1465 QList<UIChooserItem*> UIChooserModel::createNavigationItemList(UIChooserItem *pItem) 1466 1466 { 1467 1467 /* Prepare navigation list: */ … … 1476 1476 navigationItems << pGroupItem; 1477 1477 if (pGroupItem->toGroupItem()->isOpened()) 1478 navigationItems << createNavigation List(pGroupItem);1478 navigationItems << createNavigationItemList(pGroupItem); 1479 1479 } 1480 1480 /* Iterate over all the machine-items: */ … … 1515 1515 /* And update model: */ 1516 1516 wipeOutEmptyGroups(); 1517 updateNavigation ();1517 updateNavigationItemList(); 1518 1518 updateLayout(); 1519 if (!navigation List().isEmpty())1520 setSelectedItem(navigation List().first());1519 if (!navigationItems().isEmpty()) 1520 setSelectedItem(navigationItems().first()); 1521 1521 else 1522 1522 clearSelectedItems(); -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.h
r77933 r77934 170 170 /** @name Navigation stuff. 171 171 * @{ */ 172 /** Returns navigation item list. */173 const QList<UIChooserItem*> &navigation List() const;172 /** Returns a list of navigation-items. */ 173 const QList<UIChooserItem*> &navigationItems() const; 174 174 /** Removes @a pItem from navigation list. */ 175 void removeFromNavigation List(UIChooserItem *pItem);175 void removeFromNavigationItems(UIChooserItem *pItem); 176 176 /** Updates navigation list. */ 177 void updateNavigation ();177 void updateNavigationItemList(); 178 178 /** @} */ 179 179 … … 331 331 * @{ */ 332 332 /** Creates navigation list for passed root @a pItem. */ 333 QList<UIChooserItem*> createNavigation List(UIChooserItem *pItem);333 QList<UIChooserItem*> createNavigationItemList(UIChooserItem *pItem); 334 334 /** @} */ 335 335 … … 390 390 QPointer<UIChooserItem> m_pRoot; 391 391 392 /** Holds the navigation list. */393 QList<UIChooserItem*> m_navigation List;392 /** Holds the navigation-items. */ 393 QList<UIChooserItem*> m_navigationItems; 394 394 /** Holds the selected-items. */ 395 395 QList<UIChooserItem*> m_selectedItems;
Note:
See TracChangeset
for help on using the changeset viewer.