Changeset 43539 in vbox
- Timestamp:
- Oct 4, 2012 12:41:57 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 81140
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserHandlerKeyboard.cpp
r43054 r43539 116 116 model()->setFocusItem(pPreviousItem); 117 117 /* Calculate positions: */ 118 UIGChooserItem *pFirstItem = model()-> selectionList().first();118 UIGChooserItem *pFirstItem = model()->currentItem(); 119 119 int iFirstPosition = model()->navigationList().indexOf(pFirstItem); 120 120 int iPreviousPosition = model()->navigationList().indexOf(pPreviousItem); … … 124 124 if (iFirstPosition <= iPreviousPosition) 125 125 for (int i = iFirstPosition; i <= iPreviousPosition; ++i) 126 model()->addTo SelectionList(model()->navigationList().at(i));126 model()->addToCurrentItems(model()->navigationList().at(i)); 127 127 else 128 128 for (int i = iFirstPosition; i >= iPreviousPosition; --i) 129 model()->addTo SelectionList(model()->navigationList().at(i));129 model()->addToCurrentItems(model()->navigationList().at(i)); 130 130 /* Notify selection changed: */ 131 model()->notify SelectionChanged();131 model()->notifyCurrentItemChanged(); 132 132 /* Filter-out this event: */ 133 133 return true; … … 160 160 /* Move selection to 'previous' item: */ 161 161 model()->clearSelectionList(); 162 model()->addTo SelectionList(pPreviousItem);162 model()->addToCurrentItems(pPreviousItem); 163 163 /* Notify selection changed: */ 164 model()->notify SelectionChanged();164 model()->notifyCurrentItemChanged(); 165 165 /* Filter-out this event: */ 166 166 return true; … … 232 232 model()->setFocusItem(pNextItem); 233 233 /* Calculate positions: */ 234 UIGChooserItem *pFirstItem = model()-> selectionList().first();234 UIGChooserItem *pFirstItem = model()->currentItem(); 235 235 int iFirstPosition = model()->navigationList().indexOf(pFirstItem); 236 236 int iNextPosition = model()->navigationList().indexOf(pNextItem); … … 240 240 if (iFirstPosition <= iNextPosition) 241 241 for (int i = iFirstPosition; i <= iNextPosition; ++i) 242 model()->addTo SelectionList(model()->navigationList().at(i));242 model()->addToCurrentItems(model()->navigationList().at(i)); 243 243 else 244 244 for (int i = iFirstPosition; i >= iNextPosition; --i) 245 model()->addTo SelectionList(model()->navigationList().at(i));245 model()->addToCurrentItems(model()->navigationList().at(i)); 246 246 /* Notify selection changed: */ 247 model()->notify SelectionChanged();247 model()->notifyCurrentItemChanged(); 248 248 /* Filter-out this event: */ 249 249 return true; … … 276 276 /* Move selection to 'next' item: */ 277 277 model()->clearSelectionList(); 278 model()->addTo SelectionList(pNextItem);278 model()->addToCurrentItems(pNextItem); 279 279 /* Notify selection changed: */ 280 model()->notify SelectionChanged();280 model()->notifyCurrentItemChanged(); 281 281 /* Filter-out this event: */ 282 282 return true; -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserHandlerMouse.cpp
r43154 r43539 75 75 { 76 76 /* Old selection list: */ 77 QList<UIGChooserItem*> oldSelectionList = model()-> selectionList();77 QList<UIGChooserItem*> oldSelectionList = model()->currentItems(); 78 78 /* Move focus to clicked item: */ 79 79 model()->setFocusItem(pClickedItem); … … 82 82 { 83 83 /* Calculate positions: */ 84 UIGChooserItem *pFirstItem = model()-> selectionList().first();84 UIGChooserItem *pFirstItem = model()->currentItem(); 85 85 int iFirstPosition = model()->navigationList().indexOf(pFirstItem); 86 86 int iClickedPosition = model()->navigationList().indexOf(pClickedItem); … … 90 90 if (iFirstPosition <= iClickedPosition) 91 91 for (int i = iFirstPosition; i <= iClickedPosition; ++i) 92 model()->addTo SelectionList(model()->navigationList().at(i));92 model()->addToCurrentItems(model()->navigationList().at(i)); 93 93 else 94 94 for (int i = iFirstPosition; i >= iClickedPosition; --i) 95 model()->addTo SelectionList(model()->navigationList().at(i));95 model()->addToCurrentItems(model()->navigationList().at(i)); 96 96 } 97 97 /* Was 'control' modifier pressed? */ … … 99 99 { 100 100 /* Select clicked item, inverting if necessary: */ 101 if (model()-> selectionList().contains(pClickedItem))102 model()->removeFrom SelectionList(pClickedItem);101 if (model()->currentItems().contains(pClickedItem)) 102 model()->removeFromCurrentItems(pClickedItem); 103 103 else 104 model()->addTo SelectionList(pClickedItem);104 model()->addToCurrentItems(pClickedItem); 105 105 } 106 106 /* Was no modifiers pressed? */ … … 109 109 /* Move selection to clicked item: */ 110 110 model()->clearSelectionList(); 111 model()->addTo SelectionList(pClickedItem);111 model()->addToCurrentItems(pClickedItem); 112 112 } 113 113 /* Selection list changed?: */ 114 if (oldSelectionList != model()-> selectionList())115 model()->notify SelectionChanged();114 if (oldSelectionList != model()->currentItems()) 115 model()->notifyCurrentItemChanged(); 116 116 } 117 117 break; … … 135 135 { 136 136 /* Is clicked item in selection list: */ 137 bool fIsClickedItemInSelectionList = contains(model()-> selectionList(), pClickedItem);137 bool fIsClickedItemInSelectionList = contains(model()->currentItems(), pClickedItem); 138 138 /* Move focus to clicked item (with selection if not selected yet): */ 139 139 model()->setFocusItem(pClickedItem, !fIsClickedItemInSelectionList); -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemGroup.cpp
r43505 r43539 169 169 } 170 170 /* If that item is NOT focused, but selected: */ 171 else if (model()-> selectionList().contains(this))171 else if (model()->currentItems().contains(this)) 172 172 { 173 173 /* Remove item from the selection list: */ 174 model()->removeFrom SelectionList(this);174 model()->removeFromCurrentItems(this); 175 175 } 176 176 /* Remove item from the navigation list: */ … … 1207 1207 QPalette pal = palette(); 1208 1208 QColor windowColor = pal.color(QPalette::Active, 1209 model()-> selectionList().contains(this) ?1209 model()->currentItems().contains(this) ? 1210 1210 QPalette::Highlight : QPalette::Window); 1211 1211 … … 1333 1333 1334 1334 /* Update palette: */ 1335 if (model()-> selectionList().contains(this))1335 if (model()->currentItems().contains(this)) 1336 1336 { 1337 1337 QPalette pal = palette(); … … 1341 1341 /* Update buttons: */ 1342 1342 if (m_pToggleButton) 1343 m_pToggleButton->setParentSelected(model()-> selectionList().contains(this));1343 m_pToggleButton->setParentSelected(model()->currentItems().contains(this)); 1344 1344 if (m_pEnterButton) 1345 m_pEnterButton->setParentSelected(model()-> selectionList().contains(this));1345 m_pEnterButton->setParentSelected(model()->currentItems().contains(this)); 1346 1346 if (m_pExitButton) 1347 m_pExitButton->setParentSelected(model()-> selectionList().contains(this));1347 m_pExitButton->setParentSelected(model()->currentItems().contains(this)); 1348 1348 1349 1349 /* Paint name: */ -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.cpp
r43447 r43539 116 116 } 117 117 /* If that item is NOT focused, but selected: */ 118 else if (model()-> selectionList().contains(this))118 else if (model()->currentItems().contains(this)) 119 119 { 120 120 /* Remove item from the selection list: */ 121 model()->removeFrom SelectionList(this);121 model()->removeFromCurrentItems(this); 122 122 } 123 123 /* Remove item from the navigation list: */ … … 595 595 596 596 /* Selection background: */ 597 if (model()-> selectionList().contains(this))597 if (model()->currentItems().contains(this)) 598 598 { 599 599 /* Prepare color: */ … … 622 622 { 623 623 /* Window color: */ 624 QColor base = pal.color(QPalette::Active, model()-> selectionList().contains(this) ?624 QColor base = pal.color(QPalette::Active, model()->currentItems().contains(this) ? 625 625 QPalette::Highlight : QPalette::Window); 626 626 QLinearGradient dragTokenGradient; … … 650 650 { 651 651 /* Only chosen and/or hovered item should have a frame: */ 652 if (!model()-> selectionList().contains(this) && !isHovered())652 if (!model()->currentItems().contains(this) && !isHovered()) 653 653 return; 654 654 … … 657 657 QPalette pal = palette(); 658 658 QColor hc = pal.color(QPalette::Active, QPalette::Highlight); 659 if (model()-> selectionList().contains(this))659 if (model()->currentItems().contains(this)) 660 660 hc = hc.darker(strokeDarkness()); 661 661 pPainter->setPen(hc); … … 680 680 681 681 /* Update palette: */ 682 if (model()-> selectionList().contains(this))682 if (model()->currentItems().contains(this)) 683 683 { 684 684 QPalette pal = palette(); -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.cpp
r43536 r43539 189 189 { 190 190 /* Search for the first selected machine: */ 191 return searchCurrentItem( selectionList());191 return searchCurrentItem(currentItems()); 192 192 } 193 193 … … 199 199 200 200 /* Get first selected item: */ 201 UIGChooserItem *pSelectedItem = selectionList().isEmpty() ? 0 : selectionList().first();201 UIGChooserItem *pSelectedItem = currentItem(); 202 202 /* Item exists? */ 203 203 if (pSelectedItem) … … 220 220 { 221 221 /* Populate list of selected machines: */ 222 QList<UIVMItem*> currentItemList; 223 enumerateCurrentItems(selectionList(), currentItemList); 224 return currentItemList; 225 } 226 227 const QList<UIGChooserItem*>& UIGChooserModel::selectionList() const 228 { 229 return m_selectionList; 222 QList<UIVMItem*> currentMachineItemList; 223 enumerateCurrentItems(currentItems(), currentMachineItemList); 224 return currentMachineItemList; 225 } 226 227 UIGChooserItem* UIGChooserModel::currentItem() const 228 { 229 /* Return first of current items, if any: */ 230 return currentItems().isEmpty() ? 0 : currentItems().first(); 231 } 232 233 const QList<UIGChooserItem*>& UIGChooserModel::currentItems() const 234 { 235 return m_currentItems; 230 236 } 231 237 … … 309 315 } 310 316 311 void UIGChooserModel::addTo SelectionList(UIGChooserItem *pItem)317 void UIGChooserModel::addToCurrentItems(UIGChooserItem *pItem) 312 318 { 313 319 AssertMsg(pItem, ("Passed item is invalid!")); 314 m_ selectionList<< pItem;320 m_currentItems << pItem; 315 321 pItem->update(); 316 322 } 317 323 318 void UIGChooserModel::removeFrom SelectionList(UIGChooserItem *pItem)324 void UIGChooserModel::removeFromCurrentItems(UIGChooserItem *pItem) 319 325 { 320 326 AssertMsg(pItem, ("Passed item is invalid!")); 321 m_ selectionList.removeAll(pItem);327 m_currentItems.removeAll(pItem); 322 328 pItem->update(); 323 329 } … … 325 331 void UIGChooserModel::clearSelectionList() 326 332 { 327 QList<UIGChooserItem*> old SelectedList = m_selectionList;328 m_ selectionList.clear();329 foreach (UIGChooserItem *pItem, old SelectedList)333 QList<UIGChooserItem*> oldCurrentItems = m_currentItems; 334 m_currentItems.clear(); 335 foreach (UIGChooserItem *pItem, oldCurrentItems) 330 336 pItem->update(); 331 337 } 332 338 333 void UIGChooserModel::notify SelectionChanged()339 void UIGChooserModel::notifyCurrentItemChanged() 334 340 { 335 341 /* Make sure selection item list is never empty 336 342 * if at least one item (for example 'focus') present: */ 337 if ( selectionList().isEmpty() && focusItem())338 addTo SelectionList(focusItem());343 if (currentItems().isEmpty() && focusItem()) 344 addToCurrentItems(focusItem()); 339 345 /* Notify listeners about selection change: */ 340 346 emit sigSelectionChanged(); … … 348 354 bool UIGChooserModel::isSingleGroupSelected() const 349 355 { 350 return selectionList().size() == 1 &&351 selectionList().first()->type() == UIGChooserItemType_Group;356 return currentItems().size() == 1 && 357 currentItem()->type() == UIGChooserItemType_Group; 352 358 } 353 359 … … 355 361 { 356 362 /* Make sure at least on item selected: */ 357 if ( selectionList().isEmpty())363 if (currentItems().isEmpty()) 358 364 return false; 359 365 360 366 /* Determine the parent group of the first item: */ 361 UIGChooserItem *pFirstParent = selectionList().first()->parentItem();367 UIGChooserItem *pFirstParent = currentItem()->parentItem(); 362 368 363 369 /* Make sure this parent is not main root item: */ … … 365 371 return false; 366 372 367 /* Enumerate selectedset: */368 QSet<UIGChooserItem*> selectedSet;369 foreach (UIGChooserItem *p SelectedItem, selectionList())370 selectedSet << pSelectedItem;373 /* Enumerate current-item set: */ 374 QSet<UIGChooserItem*> currentItemSet; 375 foreach (UIGChooserItem *pCurrentItem, currentItems()) 376 currentItemSet << pCurrentItem; 371 377 372 378 /* Enumerate first parent children set: */ 373 QSet<UIGChooserItem*> firstParent Set;374 foreach (UIGChooserItem *p SelectedItem, pFirstParent->items())375 firstParent Set << pSelectedItem;379 QSet<UIGChooserItem*> firstParentItemSet; 380 foreach (UIGChooserItem *pFirstParentItem, pFirstParent->items()) 381 firstParentItemSet << pFirstParentItem; 376 382 377 383 /* Check if both sets contains the same: */ 378 return selectedSet == firstParentSet;384 return currentItemSet == firstParentItemSet; 379 385 } 380 386 … … 404 410 /* Add focus item into selection (if any): */ 405 411 if (m_pFocusItem) 406 addTo SelectionList(m_pFocusItem);412 addToCurrentItems(m_pFocusItem); 407 413 /* Notify selection changed: */ 408 notify SelectionChanged();414 notifyCurrentItemChanged(); 409 415 } 410 416 … … 711 717 QStringList busyGroupNames; 712 718 QStringList busyMachineNames; 713 QList<UIGChooserItem*> selectedItems = selectionList();719 QList<UIGChooserItem*> selectedItems = currentItems(); 714 720 foreach (UIGChooserItem *pItem, selectedItems) 715 721 { … … 762 768 763 769 /* Start editing group name: */ 764 selectionList().first()->startEditing();770 currentItem()->startEditing(); 765 771 } 766 772 … … 768 774 { 769 775 if (isSingleGroupSelected()) 770 sortItems( selectionList().first());776 sortItems(currentItem()); 771 777 } 772 778 … … 851 857 UIGChooserItem *pGroup = 0; 852 858 if (isSingleGroupSelected()) 853 pGroup = selectionList().first();854 else if (! selectionList().isEmpty())855 pGroup = selectionList().first()->parentItem();859 pGroup = currentItem(); 860 else if (!currentItems().isEmpty()) 861 pGroup = currentItem()->parentItem(); 856 862 QString strGroupName; 857 863 if (pGroup) … … 888 894 void UIGChooserModel::sltSortParentGroup() 889 895 { 890 if (! selectionList().isEmpty())891 sortItems( selectionList().first()->parentItem());896 if (!currentItems().isEmpty()) 897 sortItems(currentItem()->parentItem()); 892 898 } 893 899 … … 896 902 /* Gather list of chosen inaccessible VMs: */ 897 903 QList<UIGChooserItem*> inaccessibleItems; 898 enumerateInaccessibleItems( selectionList(), inaccessibleItems);904 enumerateInaccessibleItems(currentItems(), inaccessibleItems); 899 905 900 906 /* For each inaccessible item: */ … … 928 934 { 929 935 /* Enumerate all the selected machine items: */ 930 QList<UIGChooserItem*> selectedMachineItemList = gatherMachineItems( selectionList());936 QList<UIGChooserItem*> selectedMachineItemList = gatherMachineItems(currentItems()); 931 937 /* Enumerate all the existing machine items: */ 932 938 QList<UIGChooserItem*> existingMachineItemList = gatherMachineItems(mainRoot()->items()); … … 1603 1609 updateNavigation(); 1604 1610 updateLayout(); 1605 if ( mainRoot()->hasItems())1611 if (!navigationList().isEmpty()) 1606 1612 setCurrentItem(0); 1607 1613 else … … 1679 1685 return false; 1680 1686 /* Is this group item only the one selected? */ 1681 if ( selectionList().contains(pGroupItem) && selectionList().size() == 1)1687 if (currentItems().contains(pGroupItem) && currentItems().size() == 1) 1682 1688 { 1683 1689 /* Group context menu in that case: */ … … 1701 1707 { 1702 1708 /* Get first selected item: */ 1703 if (UIGChooserItem *pItem = selectionList().first())1709 if (UIGChooserItem *pItem = currentItem()) 1704 1710 { 1705 1711 /* If this item of known type? */ … … 1709 1715 { 1710 1716 /* Is this group item only the one selected? */ 1711 if ( selectionList().size() == 1)1717 if (currentItems().size() == 1) 1712 1718 { 1713 1719 /* Group context menu in that case: */ -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.h
r43536 r43539 113 113 QString currentItemDefinition() const; 114 114 QList<UIVMItem*> currentMachineItems() const; 115 const QList<UIGChooserItem*>& selectionList() const; 115 UIGChooserItem* currentItem() const; 116 const QList<UIGChooserItem*>& currentItems() const; 116 117 void setCurrentItem(int iItemIndex); 117 118 void setCurrentItem(UIGChooserItem *pItem); 118 119 void setCurrentItemDefinition(const QString &strDefinition); 119 120 void unsetCurrentItem(); 120 void addTo SelectionList(UIGChooserItem *pItem);121 void removeFrom SelectionList(UIGChooserItem *pItem);121 void addToCurrentItems(UIGChooserItem *pItem); 122 void removeFromCurrentItems(UIGChooserItem *pItem); 122 123 void clearSelectionList(); 123 void notify SelectionChanged();124 void notifyCurrentItemChanged(); 124 125 void activate(); 125 126 bool isSingleGroupSelected() const; … … 302 303 QMap<QString, QStringList> m_groups; 303 304 QList<UIGChooserItem*> m_navigationList; 304 QList<UIGChooserItem*> m_ selectionList;305 QList<UIGChooserItem*> m_currentItems; 305 306 UIGChooserHandlerMouse *m_pMouseHandler; 306 307 UIGChooserHandlerKeyboard *m_pKeyboardHandler;
Note:
See TracChangeset
for help on using the changeset viewer.