Changeset 77434 in vbox
- Timestamp:
- Feb 22, 2019 3:06:41 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 128997
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItem.cpp
r77366 r77434 199 199 , m_fFavorite(fFavorite) 200 200 , m_fTemporary(fTemporary) 201 , m_fRoot(!pParent)202 201 , m_iLevel(-1) 203 202 , m_fHovered(false) … … 353 352 } 354 353 355 void UIChooserItem::setRoot(bool fRoot)356 {357 m_fRoot = fRoot;358 handleRootStatusChange();359 }360 361 bool UIChooserItem::isRoot() const362 {363 return m_fRoot;364 }365 366 354 void UIChooserItem::setHovered(bool fHovered) 367 355 { … … 533 521 } 534 522 535 void UIChooserItem::handleRootStatusChange()536 {537 /* Reset minimum size hints for non-root items: */538 if (!isRoot())539 m_iPreviousMinimumWidthHint = 0;540 }541 542 523 /* static */ 543 524 QSize UIChooserItem::textSize(const QFont &font, QPaintDevice *pPaintDevice, const QString &strText) -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItem.h
r77366 r77434 122 122 virtual void setFavorite(bool fFavorite); 123 123 124 /** Returns whether item is root. */ 125 bool isRoot() const { return !m_pParent; } 126 124 127 /** Casts item to group one. */ 125 128 UIChooserItemGroup *toGroupItem(); … … 153 156 /** Returns item definition. */ 154 157 virtual QString definition() const = 0; 155 156 /** Defines whether item is @a fRoot. */157 void setRoot(bool fRoot);158 /** Returns whether item is root. */159 bool isRoot() const;160 158 161 159 /** Defines whether item is @a fHovered. */ … … 266 264 /** @name Item stuff. 267 265 * @{ */ 268 /** Handles root status change. */269 virtual void handleRootStatusChange();270 271 266 /** Defines item's default animation @a iValue. */ 272 267 void setDefaultValue(int iValue) { m_iDefaultValue = iValue; update(); } … … 340 335 bool m_fTemporary; 341 336 342 /** Holds whether item is root. */343 bool m_fRoot;344 337 /** Holds the item level according to root. */ 345 338 int m_iLevel; -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGroup.cpp
r77430 r77434 46 46 UIChooserItemGroup::UIChooserItemGroup(QGraphicsScene *pScene) 47 47 : UIChooserItem(0, false /* favorite? */, false /* temporary? */) 48 , m_fMainRoot(true)49 48 , m_fClosed(false) 50 49 , m_iAdditionalHeight(0) … … 78 77 } 79 78 80 UIChooserItemGroup::UIChooserItemGroup(QGraphicsScene *pScene, 79 UIChooserItemGroup::UIChooserItemGroup(UIChooserItem *pParent, 80 const QString &strName, 81 bool fOpened /* = false */, 82 int iPosition /* = -1 */) 83 : UIChooserItem(pParent, pParent->isFavorite(), pParent->isTemporary()) 84 , m_fClosed(!fOpened) 85 , m_iAdditionalHeight(0) 86 , m_iHeaderDarkness(110) 87 , m_strName(strName) 88 , m_pToggleButton(0) 89 , m_pEnterButton(0) 90 , m_pExitButton(0) 91 , m_pNameEditorWidget(0) 92 , m_pContainerFavorite(0) 93 , m_pLayoutFavorite(0) 94 , m_pScrollArea(0) 95 , m_pContainer(0) 96 , m_pLayout(0) 97 , m_pLayoutGlobal(0) 98 , m_pLayoutGroup(0) 99 , m_pLayoutMachine(0) 100 { 101 /* Prepare: */ 102 prepare(); 103 104 /* Add item to the parent: */ 105 AssertMsg(parentItem(), ("Incorrect parent passed!")); 106 parentItem()->addItem(this, false, iPosition); 107 connect(this, &UIChooserItemGroup::sigToggleStarted, 108 model(), &UIChooserModel::sigToggleStarted); 109 connect(this, &UIChooserItemGroup::sigToggleFinished, 110 model(), &UIChooserModel::sigToggleFinished, 111 Qt::QueuedConnection); 112 connect(gpManager, &UIVirtualBoxManager::sigWindowRemapped, 113 this, &UIChooserItemGroup::sltHandleWindowRemapped); 114 115 /* Apply language settings: */ 116 retranslateUi(); 117 118 /* Init: */ 119 updatePixmaps(); 120 updateItemCountInfo(); 121 updateVisibleName(); 122 updateToolTip(); 123 124 /* Prepare connections: */ 125 connect(this, &UIChooserItemGroup::sigMinimumWidthHintChanged, 126 model(), &UIChooserModel::sigRootItemMinimumWidthHintChanged); 127 } 128 129 UIChooserItemGroup::UIChooserItemGroup(UIChooserItem *pParent, 81 130 UIChooserItemGroup *pCopyFrom, 82 bool fMainRoot) 83 : UIChooserItem(0, false /* favorite? */, true /* temporary? */) 84 , m_fMainRoot(fMainRoot) 131 int iPosition /* = -1 */) 132 : UIChooserItem(pParent, pParent->isFavorite(), pParent->isTemporary()) 85 133 , m_fClosed(pCopyFrom->isClosed()) 86 134 , m_iAdditionalHeight(0) … … 103 151 prepare(); 104 152 105 /* Add item to the scene: */106 AssertMsg(pScene, ("Incorrect scene passed!"));107 pScene->addItem(this);108 109 /* Copy content to 'this': */110 copyContent(pCopyFrom, this);111 112 /* Apply language settings: */113 retranslateUi();114 115 /* Init: */116 updateItemCountInfo();117 updateVisibleName();118 updateToolTip();119 }120 121 UIChooserItemGroup::UIChooserItemGroup(UIChooserItem *pParent,122 const QString &strName,123 bool fOpened /* = false */,124 int iPosition /* = -1 */)125 : UIChooserItem(pParent, pParent->isFavorite(), pParent->isTemporary())126 , m_fMainRoot(false)127 , m_fClosed(!fOpened)128 , m_iAdditionalHeight(0)129 , m_iHeaderDarkness(110)130 , m_strName(strName)131 , m_pToggleButton(0)132 , m_pEnterButton(0)133 , m_pExitButton(0)134 , m_pNameEditorWidget(0)135 , m_pContainerFavorite(0)136 , m_pLayoutFavorite(0)137 , m_pScrollArea(0)138 , m_pContainer(0)139 , m_pLayout(0)140 , m_pLayoutGlobal(0)141 , m_pLayoutGroup(0)142 , m_pLayoutMachine(0)143 {144 /* Prepare: */145 prepare();146 147 /* Add item to the parent: */148 AssertMsg(parentItem(), ("Incorrect parent passed!"));149 parentItem()->addItem(this, false, iPosition);150 connect(this, &UIChooserItemGroup::sigToggleStarted,151 model(), &UIChooserModel::sigToggleStarted);152 connect(this, &UIChooserItemGroup::sigToggleFinished,153 model(), &UIChooserModel::sigToggleFinished,154 Qt::QueuedConnection);155 connect(gpManager, &UIVirtualBoxManager::sigWindowRemapped,156 this, &UIChooserItemGroup::sltHandleWindowRemapped);157 158 /* Apply language settings: */159 retranslateUi();160 161 /* Init: */162 updatePixmaps();163 updateItemCountInfo();164 updateVisibleName();165 updateToolTip();166 167 /* Prepare connections: */168 connect(this, &UIChooserItemGroup::sigMinimumWidthHintChanged,169 model(), &UIChooserModel::sigRootItemMinimumWidthHintChanged);170 }171 172 UIChooserItemGroup::UIChooserItemGroup(UIChooserItem *pParent,173 UIChooserItemGroup *pCopyFrom,174 int iPosition /* = -1 */)175 : UIChooserItem(pParent, pParent->isFavorite(), pParent->isTemporary())176 , m_fMainRoot(false)177 , m_fClosed(pCopyFrom->isClosed())178 , m_iAdditionalHeight(0)179 , m_iHeaderDarkness(110)180 , m_strName(pCopyFrom->name())181 , m_pToggleButton(0)182 , m_pEnterButton(0)183 , m_pExitButton(0)184 , m_pNameEditorWidget(0)185 , m_pContainerFavorite(0)186 , m_pLayoutFavorite(0)187 , m_pScrollArea(0)188 , m_pContainer(0)189 , m_pLayout(0)190 , m_pLayoutGlobal(0)191 , m_pLayoutGroup(0)192 , m_pLayoutMachine(0)193 {194 /* Prepare: */195 prepare();196 197 153 /* Add item to the parent: */ 198 154 AssertMsg(parentItem(), ("Incorrect parent passed!")); … … 468 424 void UIChooserItemGroup::updateToolTip() 469 425 { 470 /* Not for main root: */471 if (is MainRoot())426 /* Not for root item: */ 427 if (isRoot()) 472 428 return; 473 429 … … 531 487 QString UIChooserItemGroup::fullName() const 532 488 { 533 /* Return "/" for main root-item: */534 if (is MainRoot())489 /* Return "/" for root item: */ 490 if (isRoot()) 535 491 return "/"; 492 536 493 /* Get full parent name, append with '/' if not yet appended: */ 537 494 AssertMsg(parentItem(), ("Incorrect parent set!")); … … 546 503 { 547 504 return QString("g=%1").arg(name()); 548 }549 550 void UIChooserItemGroup::handleRootStatusChange()551 {552 /* Call to base-class: */553 UIChooserItem::handleRootStatusChange();554 555 /* Update linked values: */556 updateVisibleName();557 updateMinimumHeaderSize();558 505 } 559 506 … … 858 805 const QGraphicsView *pView = model()->scene()->views().first(); 859 806 807 #if 0 860 808 /* Header (non-main root-item): */ 861 809 if (!isMainRoot()) … … 884 832 iPreviousVerticalIndent = iVerticalMargin + iFullHeaderHeight + iVerticalMargin; 885 833 } 834 #endif 886 835 887 836 /* Adjust scroll-view geometry: */ … … 1307 1256 this, &UIChooserItemGroup::sltGroupToggleFinish); 1308 1257 m_pToggleButton->hide(); 1258 m_toggleButtonSize = m_pToggleButton ? m_pToggleButton->minimumSizeHint().toSize() : QSize(0, 0); 1309 1259 1310 1260 /* Setup enter-button: */ … … 1313 1263 this, &UIChooserItemGroup::sltIndentRoot); 1314 1264 m_pEnterButton->hide(); 1265 m_enterButtonSize = m_pEnterButton ? m_pEnterButton->minimumSizeHint().toSize() : QSize(0, 0); 1315 1266 1316 1267 /* Setup name-editor: */ … … 1320 1271 this, &UIChooserItemGroup::sltNameEditingFinished); 1321 1272 } 1273 1274 #if 0 1322 1275 /* Items except main root: */ 1323 1276 if (!isMainRoot()) … … 1330 1283 m_pExitButton->setTransformOriginPoint(sh.width() / 2, sh.height() / 2); 1331 1284 m_pExitButton->hide(); 1332 } 1333 1334 /* Button sizes: */ 1335 m_toggleButtonSize = m_pToggleButton ? m_pToggleButton->minimumSizeHint().toSize() : QSize(0, 0); 1336 m_enterButtonSize = m_pEnterButton ? m_pEnterButton->minimumSizeHint().toSize() : QSize(0, 0); 1337 m_exitButtonSize = m_pExitButton ? m_pExitButton->minimumSizeHint().toSize() : QSize(0, 0); 1285 m_exitButtonSize = m_pExitButton ? m_pExitButton->minimumSizeHint().toSize() : QSize(0, 0); 1286 } 1287 #endif 1338 1288 1339 1289 /* Prepare favorite children container: */ … … 1495 1445 void UIChooserItemGroup::updateItemCountInfo() 1496 1446 { 1497 /* Not for main root: */1498 if (is MainRoot())1447 /* Not for root item: */ 1448 if (isRoot()) 1499 1449 return; 1500 1450 … … 1540 1490 int iProposedWidth = 0; 1541 1491 1542 /* Main root-item: */1543 if (is MainRoot())1492 /* For root item: */ 1493 if (isRoot()) 1544 1494 { 1545 1495 /* Main root-item always takes body into account: */ … … 1551 1501 } 1552 1502 } 1553 /* Other items, including temporary roots: */1503 /* For other items: */ 1554 1504 else 1555 1505 { … … 1582 1532 int iProposedHeight = 0; 1583 1533 1584 /* Main root-item: */1585 if (is MainRoot())1534 /* For root item: */ 1535 if (isRoot()) 1586 1536 { 1587 1537 /* Main root-item always takes body into account: */ … … 1593 1543 } 1594 1544 } 1595 /* Other items, including temporary roots: */1545 /* For other items: */ 1596 1546 else 1597 1547 { … … 1628 1578 void UIChooserItemGroup::updateVisibleName() 1629 1579 { 1630 /* Not for main root: */1631 if (is MainRoot())1580 /* Not for root item: */ 1581 if (isRoot()) 1632 1582 return; 1633 1583 … … 1700 1650 void UIChooserItemGroup::updateMinimumHeaderSize() 1701 1651 { 1702 /* Not for main root: */1703 if (is MainRoot())1652 /* Not for root item: */ 1653 if (isRoot()) 1704 1654 return; 1705 1655 … … 1791 1741 if (isRoot()) 1792 1742 { 1743 #if 0 1793 1744 /* Non-main root-item: */ 1794 1745 if (!isMainRoot()) … … 1805 1756 pPainter->fillRect(headerRect, headerGradient); 1806 1757 } 1758 #endif 1807 1759 } 1808 1760 /* Non-root-item: */ … … 1892 1844 void UIChooserItemGroup::paintHeader(QPainter *pPainter, const QRect &rect) 1893 1845 { 1894 /* Not for main root: */1895 if (is MainRoot())1846 /* Not for root item: */ 1847 if (isRoot()) 1896 1848 return; 1897 1849 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGroup.h
r77366 r77434 67 67 /** Constructs main-root item, passing pScene to the base-class. */ 68 68 UIChooserItemGroup(QGraphicsScene *pScene); 69 /** Constructs temporary @a fMainRoot item as a @a pCopyFrom, passing pScene to the base-class. */70 UIChooserItemGroup(QGraphicsScene *pScene, UIChooserItemGroup *pCopyFrom, bool fMainRoot);71 69 /** Constructs non-root item with specified @a strName and @a iPosition, @a fOpened if requested, passing pParent to the base-class. */ 72 70 UIChooserItemGroup(UIChooserItem *pParent, const QString &strName, bool fOpened = false, int iPosition = -1); … … 151 149 /** Returns item definition. */ 152 150 virtual QString definition() const /* override */; 153 154 /** Handles root status change. */155 virtual void handleRootStatusChange() /* override */;156 151 /** @} */ 157 152 … … 275 270 QVariant data(int iKey) const; 276 271 277 /** Returns whether group is main-root. */278 bool isMainRoot() const { return m_fMainRoot; }279 280 272 /** Returns item's header darkness. */ 281 273 int headerDarkness() const { return m_iHeaderDarkness; } … … 334 326 /** @name Item stuff. 335 327 * @{ */ 336 /** Holds whether group is main-root. */337 const bool m_fMainRoot;338 339 328 /** Holds whether group is closed. */ 340 329 bool m_fClosed;
Note:
See TracChangeset
for help on using the changeset viewer.