- Timestamp:
- Oct 30, 2012 12:31:49 PM (12 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemGroup.cpp
r43620 r43776 248 248 bool UIGChooserItemGroup::isContainsLockedMachine() 249 249 { 250 /* For each machine 250 /* For each machine-item: */ 251 251 foreach (UIGChooserItem *pItem, items(UIGChooserItemType_Machine)) 252 252 if (pItem->toMachineItem()->isLockedMachine()) 253 253 return true; 254 /* For each group 254 /* For each group-item: */ 255 255 foreach (UIGChooserItem *pItem, items(UIGChooserItemType_Group)) 256 256 if (pItem->toGroupItem()->isContainsLockedMachine()) … … 518 518 } 519 519 520 void UIGChooserItemGroup::prepare() 521 { 522 /* Non root item only: */ 523 if (!isRoot()) 524 { 525 /* Setup toggle-button: */ 526 m_pToggleButton = new UIGraphicsRotatorButton(this, "additionalHeight", opened()); 527 connect(m_pToggleButton, SIGNAL(sigRotationStart()), this, SLOT(sltGroupToggleStart())); 528 connect(m_pToggleButton, SIGNAL(sigRotationFinish(bool)), this, SLOT(sltGroupToggleFinish(bool))); 529 m_pToggleButton->hide(); 530 531 /* Setup enter-button: */ 532 m_pEnterButton = new UIGraphicsButton(this, UIGraphicsButtonType_DirectArrow); 533 connect(m_pEnterButton, SIGNAL(sigButtonClicked()), this, SLOT(sltIndentRoot())); 534 m_pEnterButton->hide(); 535 536 /* Setup name-editor: */ 537 m_pNameEditorWidget = new UIGroupRenameEditor(m_strName, this); 538 m_pNameEditorWidget->setFont(data(GroupItemData_NameFont).value<QFont>()); 539 connect(m_pNameEditorWidget, SIGNAL(sigEditingFinished()), this, SLOT(sltNameEditingFinished())); 540 m_pNameEditor = new QGraphicsProxyWidget(this); 541 m_pNameEditor->setWidget(m_pNameEditorWidget); 542 m_pNameEditor->hide(); 543 } 544 /* Root item but non main: */ 545 if (!isMainRoot()) 546 { 547 /* Setup exit-button: */ 548 m_pExitButton = new UIGraphicsButton(this, UIGraphicsButtonType_DirectArrow); 549 connect(m_pExitButton, SIGNAL(sigButtonClicked()), this, SLOT(sltUnindentRoot())); 550 QSizeF sh = m_pExitButton->minimumSizeHint(); 551 m_pExitButton->setTransformOriginPoint(sh.width() / 2, sh.height() / 2); 552 m_pExitButton->setRotation(180); 553 m_pExitButton->hide(); 554 } 555 } 556 557 /* static */ 558 void UIGChooserItemGroup::copyContent(UIGChooserItemGroup *pFrom, UIGChooserItemGroup *pTo) 559 { 560 /* Copy group items: */ 561 foreach (UIGChooserItem *pGroupItem, pFrom->items(UIGChooserItemType_Group)) 562 new UIGChooserItemGroup(pTo, pGroupItem->toGroupItem()); 563 /* Copy machine items: */ 564 foreach (UIGChooserItem *pMachineItem, pFrom->items(UIGChooserItemType_Machine)) 565 new UIGChooserItemMachine(pTo, pMachineItem->toMachineItem()); 566 } 567 520 568 void UIGChooserItemGroup::retranslateUi() 521 569 { … … 622 670 case UIGChooserItemType_Group: 623 671 { 624 AssertMsg(!m_groupItems.contains(pItem), ("Group 672 AssertMsg(!m_groupItems.contains(pItem), ("Group-item already added!")); 625 673 if (iPosition < 0 || iPosition >= m_groupItems.size()) 626 674 m_groupItems.append(pItem); … … 632 680 case UIGChooserItemType_Machine: 633 681 { 634 AssertMsg(!m_machineItems.contains(pItem), ("Machine 682 AssertMsg(!m_machineItems.contains(pItem), ("Machine-item already added!")); 635 683 if (iPosition < 0 || iPosition >= m_machineItems.size()) 636 684 m_machineItems.append(pItem); … … 657 705 case UIGChooserItemType_Group: 658 706 { 659 AssertMsg(m_groupItems.contains(pItem), ("Group 707 AssertMsg(m_groupItems.contains(pItem), ("Group-item was not found!")); 660 708 scene()->removeItem(pItem); 661 709 m_groupItems.removeAt(m_groupItems.indexOf(pItem)); … … 664 712 case UIGChooserItemType_Machine: 665 713 { 666 AssertMsg(m_machineItems.contains(pItem), ("Machine 714 AssertMsg(m_machineItems.contains(pItem), ("Machine-item was not found!")); 667 715 scene()->removeItem(pItem); 668 716 m_machineItems.removeAt(m_machineItems.indexOf(pItem)); … … 963 1011 int iProposedWidth = 0; 964 1012 965 /* Simple group 1013 /* Simple group-item have 2 margins - left and right: */ 966 1014 iProposedWidth += 2 * iHorizontalMargin; 967 1015 /* And full header width to take into account: */ … … 995 1043 int iProposedHeight = 0; 996 1044 997 /* Simple group 1045 /* Simple group-item have 2 margins - top and bottom: */ 998 1046 iProposedHeight += 2 * iVerticalMargin; 999 1047 /* And full header height to take into account: */ … … 1046 1094 /* Else call to base-class: */ 1047 1095 return UIGChooserItem::sizeHint(which, constraint); 1096 } 1097 1098 void UIGChooserItemGroup::updateToggleButtonToolTip() 1099 { 1100 /* Is toggle-button created? */ 1101 if (!m_pToggleButton) 1102 return; 1103 1104 /* Update toggle-button tool-tip: */ 1105 m_pToggleButton->setToolTip(opened() ? tr("Collapse group") : tr("Expand group")); 1048 1106 } 1049 1107 … … 1074 1132 if (pMimeData->hasFormat(UIGChooserItemGroup::className())) 1075 1133 { 1076 /* Get passed group 1134 /* Get passed group-item: */ 1077 1135 const UIGChooserItemMimeData *pCastedMimeData = qobject_cast<const UIGChooserItemMimeData*>(pMimeData); 1078 1136 AssertMsg(pCastedMimeData, ("Can't cast passed mime-data to UIGChooserItemMimeData!")); … … 1097 1155 else if (pMimeData->hasFormat(UIGChooserItemMachine::className())) 1098 1156 { 1099 /* Get passed machine 1157 /* Get passed machine-item: */ 1100 1158 const UIGChooserItemMimeData *pCastedMimeData = qobject_cast<const UIGChooserItemMimeData*>(pMimeData); 1101 1159 AssertMsg(pCastedMimeData, ("Can't cast passed mime-data to UIGChooserItemMimeData!")); … … 1138 1196 UIGChooserModel *pModel = model(); 1139 1197 1140 /* Get passed group 1198 /* Get passed group-item: */ 1141 1199 const UIGChooserItemMimeData *pCastedMime = qobject_cast<const UIGChooserItemMimeData*>(pMime); 1142 1200 AssertMsg(pCastedMime, ("Can't cast passed mime-data to UIGChooserItemMimeData!")); … … 1210 1268 } 1211 1269 1212 /* Copy passed machine 1270 /* Copy passed machine-item into this group: */ 1213 1271 UIGChooserItem *pNewMachineItem = new UIGChooserItemMachine(this, pItem->toMachineItem(), iPosition); 1214 1272 if (closed()) … … 1581 1639 } 1582 1640 1583 void UIGChooserItemGroup::prepare()1584 {1585 /* Non root item only: */1586 if (!isRoot())1587 {1588 /* Setup toggle-button: */1589 m_pToggleButton = new UIGraphicsRotatorButton(this, "additionalHeight", opened());1590 connect(m_pToggleButton, SIGNAL(sigRotationStart()), this, SLOT(sltGroupToggleStart()));1591 connect(m_pToggleButton, SIGNAL(sigRotationFinish(bool)), this, SLOT(sltGroupToggleFinish(bool)));1592 m_pToggleButton->hide();1593 1594 /* Setup enter-button: */1595 m_pEnterButton = new UIGraphicsButton(this, UIGraphicsButtonType_DirectArrow);1596 connect(m_pEnterButton, SIGNAL(sigButtonClicked()), this, SLOT(sltIndentRoot()));1597 m_pEnterButton->hide();1598 1599 /* Setup name-editor: */1600 m_pNameEditorWidget = new UIGroupRenameEditor(m_strName, this);1601 m_pNameEditorWidget->setFont(data(GroupItemData_NameFont).value<QFont>());1602 connect(m_pNameEditorWidget, SIGNAL(sigEditingFinished()), this, SLOT(sltNameEditingFinished()));1603 m_pNameEditor = new QGraphicsProxyWidget(this);1604 m_pNameEditor->setWidget(m_pNameEditorWidget);1605 m_pNameEditor->hide();1606 }1607 /* Root item but non main: */1608 if (!isMainRoot())1609 {1610 /* Setup exit-button: */1611 m_pExitButton = new UIGraphicsButton(this, UIGraphicsButtonType_DirectArrow);1612 connect(m_pExitButton, SIGNAL(sigButtonClicked()), this, SLOT(sltUnindentRoot()));1613 QSizeF sh = m_pExitButton->minimumSizeHint();1614 m_pExitButton->setTransformOriginPoint(sh.width() / 2, sh.height() / 2);1615 m_pExitButton->setRotation(180);1616 m_pExitButton->hide();1617 }1618 }1619 1620 /* static */1621 void UIGChooserItemGroup::copyContent(UIGChooserItemGroup *pFrom, UIGChooserItemGroup *pTo)1622 {1623 /* Copy group items: */1624 foreach (UIGChooserItem *pGroupItem, pFrom->items(UIGChooserItemType_Group))1625 new UIGChooserItemGroup(pTo, pGroupItem->toGroupItem());1626 /* Copy machine items: */1627 foreach (UIGChooserItem *pMachineItem, pFrom->items(UIGChooserItemType_Machine))1628 new UIGChooserItemMachine(pTo, pMachineItem->toMachineItem());1629 }1630 1631 void UIGChooserItemGroup::updateToggleButtonToolTip()1632 {1633 /* Is toggle-button created? */1634 if (!m_pToggleButton)1635 return;1636 1637 /* Update toggle-button tool-tip: */1638 m_pToggleButton->setToolTip(opened() ? tr("Collapse group") : tr("Expand group"));1639 }1640 1641 1641 UIGroupRenameEditor::UIGroupRenameEditor(const QString &strName, UIGChooserItem *pParent) 1642 1642 : m_pParent(pParent) -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemGroup.h
r43620 r43776 28 28 /* Forward declarations: */ 29 29 class QGraphicsScene; 30 class QGraphicsProxyWidget; 31 class QLineEdit; 30 32 class UIGraphicsButton; 31 33 class UIGraphicsRotatorButton; 32 class QLineEdit;33 class QGraphicsProxyWidget;34 34 class UIGroupRenameEditor; 35 35 36 /* Graphics group 36 /* Graphics group-item 37 37 * for graphics selector model/view architecture: */ 38 38 class UIGChooserItemGroup : public UIGChooserItem … … 61 61 bool fMainRoot); 62 62 UIGChooserItemGroup(UIGChooserItem *pParent, const QString &strName, 63 bool fOpened = false , int iPosition = -1);63 bool fOpened = false, int iPosition = -1); 64 64 UIGChooserItemGroup(UIGChooserItem *pParent, UIGChooserItemGroup *pCopyFrom, 65 int iPosition = -1);65 int iPosition = -1); 66 66 ~UIGChooserItemGroup(); 67 67 … … 82 82 private slots: 83 83 84 /* Handler: Group name editing: */84 /* Handler: Name editing stuff: */ 85 85 void sltNameEditingFinished(); 86 86 87 /* Handler: Collapse/expandstuff: */87 /* Handler: Toggle stuff: */ 88 88 void sltGroupToggleStart(); 89 89 void sltGroupToggleFinish(bool fToggled); 90 90 91 /* Handler : Indent root stuff: */91 /* Handlers: Indent root stuff: */ 92 92 void sltIndentRoot(); 93 93 void sltUnindentRoot(); … … 130 130 QVariant data(int iKey) const; 131 131 132 /* Helpers: Prepare stuff: */ 133 void prepare(); 134 static void copyContent(UIGChooserItemGroup *pFrom, UIGChooserItemGroup *pTo); 135 132 136 /* Helper: Translate stuff: */ 133 137 void retranslateUi(); … … 162 166 QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const; 163 167 164 /* Helpers: Drag and drop stuff: */ 168 /* Helper: Collapse/expand stuff: */ 169 void updateToggleButtonToolTip(); 170 171 /* Helpers: Drag&drop stuff: */ 165 172 QPixmap toPixmap(); 166 173 bool isDropAllowed(QGraphicsSceneDragDropEvent *pEvent, DragToken where) const; … … 169 176 QMimeData* createMimeData(); 170 177 171 /* Event handlers: */178 /* Helper: Event handling stuff: */ 172 179 void hoverMoveEvent(QGraphicsSceneHoverEvent *pEvent); 173 180 … … 184 191 int additionalHeight() const; 185 192 186 /* Helpers: Prepare stuff: */187 void prepare();188 static void copyContent(UIGChooserItemGroup *pFrom, UIGChooserItemGroup *pTo);189 190 193 /* Helper: Color stuff: */ 191 194 int blackoutDarkness() const { return m_iBlackoutDarkness; } 192 193 /* Helper: Collapse/expand stuff: */194 void updateToggleButtonToolTip();195 195 196 196 /* Variables: */
Note:
See TracChangeset
for help on using the changeset viewer.