Changeset 73927 in vbox
- Timestamp:
- Aug 28, 2018 11:40:48 AM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItem.cpp
r73600 r73927 5 5 6 6 /* 7 * Copyright (C) 2012-201 7Oracle Corporation7 * Copyright (C) 2012-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 195 195 196 196 197 /********************************************************************************************************************************* 198 * Class UIChooserItem implementation. * 199 *********************************************************************************************************************************/ 200 197 201 UIChooserItem::UIChooserItem(UIChooserItem *pParent, bool fTemporary) 198 : m_ fRoot(!pParent)202 : m_pParent(pParent) 199 203 , m_fTemporary(fTemporary) 200 , m_pParent(pParent) 201 , m_iPreviousMinimumWidthHint(0) 202 , m_iPreviousMinimumHeightHint(0) 203 , m_dragTokenPlace(DragToken_Off) 204 , m_fRoot(!pParent) 204 205 , m_fHovered(false) 205 206 , m_pHighlightMachine(0) … … 210 211 , m_iHighlightDarkness(90) 211 212 , m_iAnimationDarkness(m_iDefaultDarkness) 213 , m_iPreviousMinimumWidthHint(0) 214 , m_iPreviousMinimumHeightHint(0) 215 , m_enmDragTokenPlace(DragToken_Off) 212 216 , m_iDragTokenDarkness(110) 213 217 { … … 259 263 } 260 264 261 UIChooserItemGroup *UIChooserItem::toGroupItem()265 UIChooserItemGroup *UIChooserItem::toGroupItem() 262 266 { 263 267 UIChooserItemGroup *pItem = qgraphicsitem_cast<UIChooserItemGroup*>(this); … … 266 270 } 267 271 268 UIChooserItemGlobal *UIChooserItem::toGlobalItem()272 UIChooserItemGlobal *UIChooserItem::toGlobalItem() 269 273 { 270 274 UIChooserItemGlobal *pItem = qgraphicsitem_cast<UIChooserItemGlobal*>(this); … … 273 277 } 274 278 275 UIChooserItemMachine *UIChooserItem::toMachineItem()279 UIChooserItemMachine *UIChooserItem::toMachineItem() 276 280 { 277 281 UIChooserItemMachine *pItem = qgraphicsitem_cast<UIChooserItemMachine*>(this); … … 280 284 } 281 285 282 UIChooserModel *UIChooserItem::model() const286 UIChooserModel *UIChooserItem::model() const 283 287 { 284 288 UIChooserModel *pModel = qobject_cast<UIChooserModel*>(QIGraphicsWidget::scene()->parent()); … … 287 291 } 288 292 289 UIActionPool *UIChooserItem::actionPool() const293 UIActionPool *UIChooserItem::actionPool() const 290 294 { 291 295 return model()->actionPool(); 292 }293 294 UIChooserItem* UIChooserItem::parentItem() const295 {296 return m_pParent;297 296 } 298 297 … … 318 317 { 319 318 return m_fRoot; 320 }321 322 bool UIChooserItem::isHovered() const323 {324 return m_fHovered;325 319 } 326 320 … … 334 328 } 335 329 330 bool UIChooserItem::isHovered() const 331 { 332 return m_fHovered; 333 } 334 336 335 void UIChooserItem::updateGeometry() 337 336 { … … 382 381 } 383 382 384 void UIChooserItem::setDragTokenPlace(DragToken where)383 void UIChooserItem::setDragTokenPlace(DragToken enmPlace) 385 384 { 386 385 /* Something changed? */ 387 if (m_ dragTokenPlace != where)388 { 389 m_ dragTokenPlace = where;386 if (m_enmDragTokenPlace != enmPlace) 387 { 388 m_enmDragTokenPlace = enmPlace; 390 389 update(); 391 390 } … … 394 393 DragToken UIChooserItem::dragTokenPlace() const 395 394 { 396 return m_dragTokenPlace; 397 } 398 399 400 bool UIChooserItem::isTemporary() const 401 { 402 return m_fTemporary; 403 } 404 405 void UIChooserItem::hoverMoveEvent(QGraphicsSceneHoverEvent*) 395 return m_enmDragTokenPlace; 396 } 397 398 void UIChooserItem::hoverMoveEvent(QGraphicsSceneHoverEvent *) 406 399 { 407 400 if (!m_fHovered) … … 413 406 } 414 407 415 void UIChooserItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *)408 void UIChooserItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *) 416 409 { 417 410 if (m_fHovered) … … 478 471 } 479 472 480 void UIChooserItem::dragLeaveEvent(QGraphicsSceneDragDropEvent *)473 void UIChooserItem::dragLeaveEvent(QGraphicsSceneDragDropEvent *) 481 474 { 482 475 resetDragToken(); … … 511 504 m_iPreviousMinimumHeightHint = 0; 512 505 } 513 }514 515 /* static */516 void UIChooserItem::configurePainterShape(QPainter *pPainter,517 const QStyleOptionGraphicsItem *pOption,518 int iRadius)519 {520 /* Rounded corners? */521 if (iRadius)522 {523 /* Setup clipping: */524 QPainterPath roundedPath;525 roundedPath.addRoundedRect(pOption->rect, iRadius, iRadius);526 pPainter->setClipPath(roundedPath);527 }528 }529 530 /* static */531 void UIChooserItem::paintFrameRect(QPainter *pPainter, const QRect &rect, bool fIsSelected, int iRadius)532 {533 pPainter->save();534 QPalette pal = QApplication::palette();535 QColor base = pal.color(QPalette::Active, fIsSelected ? QPalette::Highlight : QPalette::Window);536 pPainter->setPen(base.darker(160));537 if (iRadius)538 pPainter->drawRoundedRect(rect, iRadius, iRadius);539 else540 pPainter->drawRect(rect);541 pPainter->restore();542 }543 544 /* static */545 void UIChooserItem::paintPixmap(QPainter *pPainter, const QPoint &point, const QPixmap &pixmap)546 {547 pPainter->drawPixmap(point, pixmap);548 }549 550 /* static */551 void UIChooserItem::paintText(QPainter *pPainter, QPoint point,552 const QFont &font, QPaintDevice *pPaintDevice,553 const QString &strText)554 {555 /* Prepare variables: */556 QFontMetrics fm(font, pPaintDevice);557 point += QPoint(0, fm.ascent());558 559 /* Draw text: */560 pPainter->save();561 pPainter->setFont(font);562 pPainter->drawText(point, strText);563 pPainter->restore();564 506 } 565 507 … … 606 548 } 607 549 550 /* static */ 551 void UIChooserItem::configurePainterShape(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, int iRadius) 552 { 553 /* Rounded corners? */ 554 if (iRadius) 555 { 556 /* Setup clipping: */ 557 QPainterPath roundedPath; 558 roundedPath.addRoundedRect(pOption->rect, iRadius, iRadius); 559 pPainter->setClipPath(roundedPath); 560 } 561 } 562 563 /* static */ 564 void UIChooserItem::paintFrameRect(QPainter *pPainter, bool fIsSelected, int iRadius, 565 const QRect &rectangle) 566 { 567 pPainter->save(); 568 QPalette pal = QApplication::palette(); 569 QColor base = pal.color(QPalette::Active, fIsSelected ? QPalette::Highlight : QPalette::Window); 570 pPainter->setPen(base.darker(160)); 571 if (iRadius) 572 pPainter->drawRoundedRect(rectangle, iRadius, iRadius); 573 else 574 pPainter->drawRect(rectangle); 575 pPainter->restore(); 576 } 577 578 /* static */ 579 void UIChooserItem::paintPixmap(QPainter *pPainter, const QPoint &point, 580 const QPixmap &pixmap) 581 { 582 pPainter->drawPixmap(point, pixmap); 583 } 584 585 /* static */ 586 void UIChooserItem::paintText(QPainter *pPainter, QPoint point, 587 const QFont &font, QPaintDevice *pPaintDevice, 588 const QString &strText) 589 { 590 /* Prepare variables: */ 591 QFontMetrics fm(font, pPaintDevice); 592 point += QPoint(0, fm.ascent()); 593 594 /* Draw text: */ 595 pPainter->save(); 596 pPainter->setFont(font); 597 pPainter->drawText(point, strText); 598 pPainter->restore(); 599 } 600 601 602 /********************************************************************************************************************************* 603 * Class UIChooserItemMimeData implementation. * 604 *********************************************************************************************************************************/ 605 608 606 UIChooserItemMimeData::UIChooserItemMimeData(UIChooserItem *pItem) 609 607 : m_pItem(pItem) … … 617 615 return false; 618 616 } 619 620 UIChooserItem* UIChooserItemMimeData::item() const621 {622 return m_pItem;623 }624 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItem.h
r73600 r73927 5 5 6 6 /* 7 * Copyright (C) 2012-201 7Oracle Corporation7 * Copyright (C) 2012-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 16 16 */ 17 17 18 #ifndef __ UIChooserItem_h__19 #define __ UIChooserItem_h__18 #ifndef ___UIChooserItem_h___ 19 #define ___UIChooserItem_h___ 20 20 21 21 /* Qt includes: */ 22 22 #include <QMimeData> 23 #include <QRectF> 23 24 #include <QString> 24 25 … … 31 32 32 33 /* Forward declaration: */ 34 class QGraphicsSceneHoverEvent; 35 class QGraphicsSceneMouseEvent; 36 class QGraphicsSceneDragDropEvent; 37 class QPropertyAnimation; 38 class QStateMachine; 33 39 class UIActionPool; 34 class UIChooserModel;35 40 class UIChooserItemGroup; 36 41 class UIChooserItemGlobal; 37 42 class UIChooserItemMachine; 38 class QGraphicsSceneHoverEvent; 39 class QGraphicsSceneMouseEvent; 40 class QGraphicsSceneDragDropEvent; 41 class QStateMachine; 42 class QPropertyAnimation; 43 44 /* UIChooserItem types: */ 43 class UIChooserModel; 44 45 46 /** UIChooserItem types. */ 45 47 enum UIChooserItemType 46 48 { 47 UIChooserItemType_Any = QGraphicsItem::UserType,49 UIChooserItemType_Any = QGraphicsItem::UserType, 48 50 UIChooserItemType_Group, 49 51 UIChooserItemType_Global, … … 51 53 }; 52 54 53 /* Item search flags: */ 55 56 /** UIChooserItem search flags. */ 54 57 enum UIChooserItemSearchFlag 55 58 { … … 60 63 }; 61 64 62 /* Drag token placement: */ 63 enum DragToken { DragToken_Off, DragToken_Up, DragToken_Down }; 64 65 /* Graphics item interface 66 * for graphics selector model/view architecture: */ 65 66 /** Drag token placement types. */ 67 enum DragToken 68 { 69 DragToken_Off, 70 DragToken_Up, 71 DragToken_Down 72 }; 73 74 75 /** QIGraphicsWidget extension used as interface 76 * for graphics chooser model/view architecture. */ 67 77 class UIChooserItem : public QIWithRetranslateUI4<QIGraphicsWidget> 68 78 { … … 72 82 signals: 73 83 74 /* Notifiers: Size-hint stuff: */ 75 void sigMinimumWidthHintChanged(int iMinimumWidthHint); 76 void sigMinimumHeightHintChanged(int iMinimumHeightHint); 77 78 /* Notifiers: Hover stuff: */ 79 void sigHoverEnter(); 80 void sigHoverLeave(); 84 /** @name Basic stuff. 85 * @{ */ 86 /** Notifies listeners about hover enter. */ 87 void sigHoverEnter(); 88 /** Notifies listeners about hover leave. */ 89 void sigHoverLeave(); 90 /** @} */ 91 92 /** @name Layout stuff. 93 * @{ */ 94 /** Notifies listeners about @a iMinimumWidthHint change. */ 95 void sigMinimumWidthHintChanged(int iMinimumWidthHint); 96 /** Notifies listeners about @a iMinimumHeightHint change. */ 97 void sigMinimumHeightHintChanged(int iMinimumHeightHint); 98 /** @} */ 81 99 82 100 public: 83 101 84 /* Constructor: */ 102 /** Constructs item passing @a pParent to the base-class. 103 * @param fTemporary Brings whether this item created for temporary needs. */ 85 104 UIChooserItem(UIChooserItem *pParent, bool fTemporary); 86 105 87 /* API: Cast stuff: */ 88 UIChooserItemGroup *toGroupItem(); 89 UIChooserItemGlobal *toGlobalItem(); 90 UIChooserItemMachine *toMachineItem(); 91 92 /* API: Model stuff: */ 93 UIChooserModel* model() const; 94 95 /** Returns the action-pool reference. */ 96 UIActionPool* actionPool() const; 97 98 /* API: Parent stuff: */ 99 UIChooserItem* parentItem() const; 100 101 /* API: Basic stuff: */ 102 virtual void show(); 103 virtual void hide(); 104 virtual void startEditing() = 0; 105 virtual void updateToolTip() = 0; 106 virtual QString name() const = 0; 107 virtual QString description() const = 0; 108 virtual QString fullName() const = 0; 109 virtual QString definition() const = 0; 110 void setRoot(bool fRoot); 111 bool isRoot() const; 112 bool isHovered() const; 113 void setHovered(bool fHovered); 114 115 /* API: Children stuff: */ 116 virtual void addItem(UIChooserItem *pItem, int iPosition) = 0; 117 virtual void removeItem(UIChooserItem *pItem) = 0; 118 virtual void setItems(const QList<UIChooserItem*> &items, UIChooserItemType type) = 0; 119 virtual QList<UIChooserItem*> items(UIChooserItemType type = UIChooserItemType_Any) const = 0; 120 virtual bool hasItems(UIChooserItemType type = UIChooserItemType_Any) const = 0; 121 virtual void clearItems(UIChooserItemType type = UIChooserItemType_Any) = 0; 122 virtual void updateAll(const QString &strId) = 0; 123 virtual void removeAll(const QString &strId) = 0; 124 virtual UIChooserItem* searchForItem(const QString &strSearchTag, int iItemSearchFlags) = 0; 125 virtual UIChooserItem* firstMachineItem() = 0; 126 virtual void sortItems() = 0; 127 128 /* API: Layout stuff: */ 129 void updateGeometry(); 130 virtual void updateLayout() = 0; 131 virtual int minimumWidthHint() const = 0; 132 virtual int minimumHeightHint() const = 0; 133 134 /* API: Navigation stuff: */ 135 virtual void makeSureItsVisible(); 136 137 /* API: Drag and drop stuff: */ 138 virtual QPixmap toPixmap() = 0; 139 virtual bool isDropAllowed(QGraphicsSceneDragDropEvent *pEvent, DragToken where = DragToken_Off) const = 0; 140 virtual void processDrop(QGraphicsSceneDragDropEvent *pEvent, UIChooserItem *pFromWho = 0, DragToken where = DragToken_Off) = 0; 141 virtual void resetDragToken() = 0; 142 void setDragTokenPlace(DragToken where); 143 DragToken dragTokenPlace() const; 144 145 /* API: Toggle stuff: */ 146 bool isTemporary() const; 106 /** @name Item stuff. 107 * @{ */ 108 /** Returns parent reference. */ 109 UIChooserItem *parentItem() const { return m_pParent; } 110 /** Returns whether item is temporary. */ 111 bool isTemporary() const { return m_fTemporary; } 112 113 /** Casts item to group one. */ 114 UIChooserItemGroup *toGroupItem(); 115 /** Casts item to global one. */ 116 UIChooserItemGlobal *toGlobalItem(); 117 /** Casts item to machine one. */ 118 UIChooserItemMachine *toMachineItem(); 119 120 /** Returns model reference. */ 121 UIChooserModel *model() const; 122 /** Returns action-pool reference. */ 123 UIActionPool *actionPool() const; 124 125 /** Shows item. */ 126 virtual void show(); 127 /** Hides item. */ 128 virtual void hide(); 129 130 /** Starts item editing. */ 131 virtual void startEditing() = 0; 132 133 /** Updates item tool-tip. */ 134 virtual void updateToolTip() = 0; 135 136 /** Returns item name. */ 137 virtual QString name() const = 0; 138 /** Returns item description. */ 139 virtual QString description() const = 0; 140 /** Returns item full-name. */ 141 virtual QString fullName() const = 0; 142 /** Returns item definition. */ 143 virtual QString definition() const = 0; 144 145 /** Defines whether item is @a fRoot. */ 146 void setRoot(bool fRoot); 147 /** Returns whether item is root. */ 148 bool isRoot() const; 149 150 /** Defines whether item is @a fHovered. */ 151 void setHovered(bool fHovered); 152 /** Returns whether item is hovered. */ 153 bool isHovered() const; 154 /** @} */ 155 156 /** @name Children stuff. 157 * @{ */ 158 /** Adds child @a pItem to certain @a iPosition. */ 159 virtual void addItem(UIChooserItem *pItem, int iPosition) = 0; 160 /** Removes child @a pItem. */ 161 virtual void removeItem(UIChooserItem *pItem) = 0; 162 163 /** Replaces children @a items of certain @a enmType. */ 164 virtual void setItems(const QList<UIChooserItem*> &items, UIChooserItemType enmType) = 0; 165 /** Returns children items of certain @a enmType. */ 166 virtual QList<UIChooserItem*> items(UIChooserItemType enmType = UIChooserItemType_Any) const = 0; 167 /** Returns whether there are children items of certain @a enmType. */ 168 virtual bool hasItems(UIChooserItemType enmType = UIChooserItemType_Any) const = 0; 169 /** Clears children items of certain @a enmType. */ 170 virtual void clearItems(UIChooserItemType enmType = UIChooserItemType_Any) = 0; 171 172 /** Updates all children items with specified @a strId. */ 173 virtual void updateAllItems(const QString &strId) = 0; 174 /** Removes all children items with specified @a strId. */ 175 virtual void removeAllItems(const QString &strId) = 0; 176 177 /** Searches for a first child item answering to specified @a strSearchTag and @a iItemSearchFlags. */ 178 virtual UIChooserItem *searchForItem(const QString &strSearchTag, int iItemSearchFlags) = 0; 179 180 /** Searches for a first machine child item. */ 181 virtual UIChooserItem *firstMachineItem() = 0; 182 183 /** Sorts children items. */ 184 virtual void sortItems() = 0; 185 /** @} */ 186 187 /** @name Layout stuff. 188 * @{ */ 189 /** Updates geometry. */ 190 void updateGeometry(); 191 192 /** Updates layout. */ 193 virtual void updateLayout() = 0; 194 195 /** Returns minimum width-hint. */ 196 virtual int minimumWidthHint() const = 0; 197 /** Returns minimum height-hint. */ 198 virtual int minimumHeightHint() const = 0; 199 /** @} */ 200 201 /** @name Navigation stuff. 202 * @{ */ 203 /** Makes sure item is visible. */ 204 virtual void makeSureItsVisible(); 205 206 /** Returns pixmap item representation. */ 207 virtual QPixmap toPixmap() = 0; 208 209 /** Returns whether item drop is allowed. 210 * @param pEvent Brings information about drop event. 211 * @param enmPlace Brings the place of drag token to the drop moment. */ 212 virtual bool isDropAllowed(QGraphicsSceneDragDropEvent *pEvent, DragToken enmPlace = DragToken_Off) const = 0; 213 /** Processes item drop. 214 * @param pEvent Brings information about drop event. 215 * @param pFromWho Brings the item according to which we choose drop position. 216 * @param enmPlace Brings the place of drag token to the drop moment (according to item mentioned above). */ 217 virtual void processDrop(QGraphicsSceneDragDropEvent *pEvent, UIChooserItem *pFromWho = 0, DragToken enmPlace = DragToken_Off) = 0; 218 /** Reset drag token. */ 219 virtual void resetDragToken() = 0; 220 221 /** Defines drag token @a enmPlace. */ 222 void setDragTokenPlace(DragToken enmPlace); 223 /** Returns drag token place. */ 224 DragToken dragTokenPlace() const; 225 /** @} */ 147 226 148 227 protected: 149 228 150 /* Hover-enter event: */ 151 void hoverMoveEvent(QGraphicsSceneHoverEvent *pEvent); 152 /* Hover-leave event: */ 153 void hoverLeaveEvent(QGraphicsSceneHoverEvent *pEvent); 154 /* Mouse-press event: */ 155 void mousePressEvent(QGraphicsSceneMouseEvent *pEvent); 156 /* Mouse-move event: */ 157 void mouseMoveEvent(QGraphicsSceneMouseEvent *pEvent); 158 /* Drag-move event: */ 159 void dragMoveEvent(QGraphicsSceneDragDropEvent *pEvent); 160 /* Drag-leave event: */ 161 void dragLeaveEvent(QGraphicsSceneDragDropEvent *pEvent); 162 /* Drop event: */ 163 void dropEvent(QGraphicsSceneDragDropEvent *pEvent); 164 165 /* Helper: Update stuff: */ 166 virtual void handleRootStatusChange(); 167 void setPreviousGeometry(const QRectF &previousGeometry) { m_previousGeometry = previousGeometry; } 168 const QRectF& previousGeometry() const { return m_previousGeometry; } 169 170 /* Static paint stuff: */ 171 static void configurePainterShape(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, int iRadius); 172 static void paintFrameRect(QPainter *pPainter, const QRect &rect, bool fIsSelected, int iRadius); 173 static void paintPixmap(QPainter *pPainter, const QPoint &point, const QPixmap &pixmap); 174 static void paintText(QPainter *pPainter, QPoint point, 175 const QFont &font, QPaintDevice *pPaintDevice, 176 const QString &strText); 177 178 /* Helpers: Drag and drop stuff: */ 179 virtual QMimeData* createMimeData() = 0; 180 181 /* Hover stuff: */ 182 int defaultDarkness() const { return m_iDefaultDarkness; } 183 int highlightDarkness() const { return m_iHighlightDarkness; } 184 int animationDarkness() const { return m_iAnimationDarkness; } 185 void setDefaultDarkness(int iDefaultDarkness) { m_iDefaultDarkness = iDefaultDarkness; update(); } 186 void setHighlightDarkness(int iHighlightDarkness) { m_iHighlightDarkness = iHighlightDarkness; update(); } 187 void setAnimationDarkness(int iAnimationDarkness) { m_iAnimationDarkness = iAnimationDarkness; update(); } 188 189 /* Other color stuff: */ 190 int dragTokenDarkness() const { return m_iDragTokenDarkness; } 191 192 /* Helpers: Text processing stuff: */ 193 static QSize textSize(const QFont &font, QPaintDevice *pPaintDevice, const QString &strText); 194 static int textWidth(const QFont &font, QPaintDevice *pPaintDevice, int iCount); 195 static QString compressText(const QFont &font, QPaintDevice *pPaintDevice, QString strText, int iWidth); 229 /** @name Event-processing stuff. 230 * @{ */ 231 /** Handles hover enter @a event. */ 232 void hoverMoveEvent(QGraphicsSceneHoverEvent *pEvent); 233 /** Handles hover leave @a event. */ 234 void hoverLeaveEvent(QGraphicsSceneHoverEvent *pEvent); 235 236 /** Handles mouse press @a event. */ 237 void mousePressEvent(QGraphicsSceneMouseEvent *pEvent); 238 /** Handles mouse move @a event. */ 239 void mouseMoveEvent(QGraphicsSceneMouseEvent *pEvent); 240 241 /** Handles drag move @a event. */ 242 void dragMoveEvent(QGraphicsSceneDragDropEvent *pEvent); 243 /** Handles drag leave @a event. */ 244 void dragLeaveEvent(QGraphicsSceneDragDropEvent *pEvent); 245 /** Handles drop @a event. */ 246 void dropEvent(QGraphicsSceneDragDropEvent *pEvent); 247 /** @} */ 248 249 /** @name Item stuff. 250 * @{ */ 251 /** Handles root status change. */ 252 virtual void handleRootStatusChange(); 253 254 /** Defines item's @a iDefaultDarkness. */ 255 void setDefaultDarkness(int iDefaultDarkness) { m_iDefaultDarkness = iDefaultDarkness; update(); } 256 /** Returns default item darkness. */ 257 int defaultDarkness() const { return m_iDefaultDarkness; } 258 259 /** Defines item's @a iHighlightDarkness. */ 260 void setHighlightDarkness(int iHighlightDarkness) { m_iHighlightDarkness = iHighlightDarkness; update(); } 261 /** Returns highlight item darkness. */ 262 int highlightDarkness() const { return m_iHighlightDarkness; } 263 264 /** Defines item's @a iAnimationDarkness. */ 265 void setAnimationDarkness(int iAnimationDarkness) { m_iAnimationDarkness = iAnimationDarkness; update(); } 266 /** Returns animation item darkness. */ 267 int animationDarkness() const { return m_iAnimationDarkness; } 268 /** @} */ 269 270 /** @name Layout stuff. 271 * @{ */ 272 /** Defines previous @a geometry. */ 273 void setPreviousGeometry(const QRectF &geometry) { m_previousGeometry = geometry; } 274 /** Returns previous geometry. */ 275 const QRectF &previousGeometry() const { return m_previousGeometry; } 276 277 /** Returns @a strText size calculated on the basis of certain @a font and @a pPaintDevice. */ 278 static QSize textSize(const QFont &font, QPaintDevice *pPaintDevice, const QString &strText); 279 /** Returns a width of line containing @a iCount of chars calculated on the basis of certain @a font and @a pPaintDevice. */ 280 static int textWidth(const QFont &font, QPaintDevice *pPaintDevice, int iCount); 281 /** Compresses @a strText to @a iWidth on the basis of certain @a font and @a pPaintDevice. */ 282 static QString compressText(const QFont &font, QPaintDevice *pPaintDevice, QString strText, int iWidth); 283 /** @} */ 284 285 /** @name Navigation stuff. 286 * @{ */ 287 /** Returns D&D mime data. */ 288 virtual QMimeData *createMimeData() = 0; 289 290 /** Returns drag token darkness. */ 291 int dragTokenDarkness() const { return m_iDragTokenDarkness; } 292 /** @} */ 293 294 /** @name Painting stuff. 295 * @{ */ 296 /** Configures @a pPainter shape with certain @a pOptions and specified @a iRadius. */ 297 static void configurePainterShape(QPainter *pPainter, const QStyleOptionGraphicsItem *pOptions, int iRadius); 298 299 /** Paints frame @a rectangle using passed @a pPainter. 300 * @param fIsSelected Brings whether this rectangle should be filled. 301 * @param iRadius Brings the radius of rounded corners. */ 302 static void paintFrameRect(QPainter *pPainter, bool fIsSelected, int iRadius, 303 const QRect &rectangle); 304 /** Paints @a pixmap using passed @a pPainter putting its upper-left corner to specified @a point. */ 305 static void paintPixmap(QPainter *pPainter, const QPoint &point, 306 const QPixmap &pixmap); 307 /** Paints @a strText using passed @a pPainter putting its upper-left corner to specified @a point. 308 * @param font Brings the text font. 309 * @param pPaintDevice Brings the paint-device reference to initilize painting from. */ 310 static void paintText(QPainter *pPainter, QPoint point, 311 const QFont &font, QPaintDevice *pPaintDevice, 312 const QString &strText); 313 /** @} */ 196 314 197 315 private: 198 316 199 /* Variables: */ 200 bool m_fRoot; 201 bool m_fTemporary; 202 UIChooserItem *m_pParent; 203 QRectF m_previousGeometry; 204 int m_iPreviousMinimumWidthHint; 205 int m_iPreviousMinimumHeightHint; 206 DragToken m_dragTokenPlace; 207 208 /* Highlight animation stuff: */ 209 bool m_fHovered; 210 QStateMachine *m_pHighlightMachine; 211 QPropertyAnimation *m_pForwardAnimation; 212 QPropertyAnimation *m_pBackwardAnimation; 213 int m_iAnimationDuration; 214 int m_iDefaultDarkness; 215 int m_iHighlightDarkness; 216 int m_iAnimationDarkness; 217 int m_iDragTokenDarkness; 218 }; 219 220 /* Mime-data for graphics item interface: */ 317 /** @name Item stuff. 318 * @{ */ 319 /** Holds the item's parent item. */ 320 UIChooserItem *m_pParent; 321 /** Holds whether item is temporary. */ 322 bool m_fTemporary; 323 324 /** Holds whether item is root. */ 325 bool m_fRoot; 326 /** Holds whether item is hovered. */ 327 bool m_fHovered; 328 329 /** Holds item highlight machine instance. */ 330 QStateMachine *m_pHighlightMachine; 331 332 /** Holds item forward animation instance. */ 333 QPropertyAnimation *m_pForwardAnimation; 334 /** Holds item backward animation instance. */ 335 QPropertyAnimation *m_pBackwardAnimation; 336 337 /** Holds item animation duration. */ 338 int m_iAnimationDuration; 339 340 /** Holds default item darkness. */ 341 int m_iDefaultDarkness; 342 /** Holds highlight item darkness. */ 343 int m_iHighlightDarkness; 344 /** Holds animation item darkness. */ 345 int m_iAnimationDarkness; 346 /** @} */ 347 348 /** @name Layout stuff. 349 * @{ */ 350 /** Holds previous geometry. */ 351 QRectF m_previousGeometry; 352 353 /** Holds previous minimum width hint. */ 354 int m_iPreviousMinimumWidthHint; 355 /** Holds previous minimum height hint. */ 356 int m_iPreviousMinimumHeightHint; 357 /** @} */ 358 359 /** @name Navigation stuff. 360 * @{ */ 361 /** Holds drag token place. */ 362 DragToken m_enmDragTokenPlace; 363 364 /** Holds drag token darkness. */ 365 int m_iDragTokenDarkness; 366 /** @} */ 367 }; 368 369 370 /** QMimeData for graphics item interface. */ 221 371 class UIChooserItemMimeData : public QMimeData 222 372 { … … 225 375 public: 226 376 227 /* Constructor:*/377 /** Constructs mime-data on the basis of passed @a pItem. */ 228 378 UIChooserItemMimeData(UIChooserItem *pItem); 229 379 230 /* API: Format checker:*/231 bool hasFormat(const QString &strMimeType) const;232 233 /* API: Item getter:*/234 UIChooserItem* item() const;380 /** Returns cached item. */ 381 UIChooserItem *item() const { return m_pItem; } 382 383 /** Constructs mime-data on the basis of passed @a pItem. */ 384 virtual bool hasFormat(const QString &strMimeType) const /* override */; 235 385 236 386 private: 237 387 238 /* Variables:*/388 /** Holds the cached item. */ 239 389 UIChooserItem *m_pItem; 240 390 }; 241 391 242 #endif /* __UIChooserItem_h__ */ 243 392 393 #endif /* !___UIChooserItem_h___ */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGlobal.cpp
r73658 r73927 287 287 } 288 288 289 void UIChooserItemGlobal::updateAll (const QString &)289 void UIChooserItemGlobal::updateAllItems(const QString &) 290 290 { 291 291 /* Update this global-item: */ … … 298 298 } 299 299 300 void UIChooserItemGlobal::removeAll (const QString &)300 void UIChooserItemGlobal::removeAllItems(const QString &) 301 301 { 302 302 // Just do nothing .. -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGlobal.h
r73600 r73927 96 96 bool hasItems(UIChooserItemType type) const; 97 97 void clearItems(UIChooserItemType type); 98 void updateAll (const QString &strId);99 void removeAll (const QString &strId);98 void updateAllItems(const QString &strId); 99 void removeAllItems(const QString &strId); 100 100 UIChooserItem *searchForItem(const QString &strSearchTag, int iItemSearchFlags); 101 101 UIChooserItem *firstMachineItem(); -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGroup.cpp
r73600 r73927 966 966 } 967 967 968 void UIChooserItemGroup::updateAll (const QString &strId)968 void UIChooserItemGroup::updateAllItems(const QString &strId) 969 969 { 970 970 /* Update all the required items recursively: */ 971 971 foreach (UIChooserItem *pItem, items()) 972 pItem->updateAll (strId);973 } 974 975 void UIChooserItemGroup::removeAll (const QString &strId)972 pItem->updateAllItems(strId); 973 } 974 975 void UIChooserItemGroup::removeAllItems(const QString &strId) 976 976 { 977 977 /* Remove all the required items recursively: */ 978 978 foreach (UIChooserItem *pItem, items()) 979 pItem->removeAll (strId);979 pItem->removeAllItems(strId); 980 980 } 981 981 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGroup.h
r73600 r73927 143 143 bool hasItems(UIChooserItemType type = UIChooserItemType_Any) const; 144 144 void clearItems(UIChooserItemType type = UIChooserItemType_Any); 145 void updateAll (const QString &strId);146 void removeAll (const QString &strId);145 void updateAllItems(const QString &strId); 146 void removeAllItems(const QString &strId); 147 147 UIChooserItem *searchForItem(const QString &strSearchTag, int iItemSearchFlags); 148 148 UIChooserItem *firstMachineItem(); -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemMachine.cpp
r73600 r73927 544 544 } 545 545 546 void UIChooserItemMachine::updateAll (const QString &strId)546 void UIChooserItemMachine::updateAllItems(const QString &strId) 547 547 { 548 548 /* Skip other ids: */ … … 563 563 } 564 564 565 void UIChooserItemMachine::removeAll (const QString &strId)565 void UIChooserItemMachine::removeAllItems(const QString &strId) 566 566 { 567 567 /* Skip wrong id: */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemMachine.h
r73600 r73927 125 125 bool hasItems(UIChooserItemType type) const; 126 126 void clearItems(UIChooserItemType type); 127 void updateAll (const QString &strId);128 void removeAll (const QString &strId);127 void updateAllItems(const QString &strId); 128 void removeAllItems(const QString &strId); 129 129 UIChooserItem *searchForItem(const QString &strSearchTag, int iItemSearchFlags); 130 130 UIChooserItem *firstMachineItem(); -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp
r73926 r73927 699 699 { 700 700 /* Update machine-items with passed id: */ 701 mainRoot()->updateAll (strId);701 mainRoot()->updateAllItems(strId); 702 702 } 703 703 … … 705 705 { 706 706 /* Update machine-items with passed id: */ 707 mainRoot()->updateAll (strId);707 mainRoot()->updateAllItems(strId); 708 708 } 709 709 … … 736 736 { 737 737 /* Remove machine-items with passed id: */ 738 mainRoot()->removeAll (strId);738 mainRoot()->removeAllItems(strId); 739 739 /* Update model: */ 740 740 cleanupGroupTree(); … … 755 755 { 756 756 /* Update machine-items with passed id: */ 757 mainRoot()->updateAll (strId);757 mainRoot()->updateAllItems(strId); 758 758 } 759 759 … … 761 761 { 762 762 /* Update machine-items with passed id: */ 763 mainRoot()->updateAll (strId);763 mainRoot()->updateAllItems(strId); 764 764 } 765 765 … … 1018 1018 { 1019 1019 /* Remove all the items first: */ 1020 mainRoot()->removeAll (strId);1020 mainRoot()->removeAllItems(strId); 1021 1021 /* Wipe out empty groups: */ 1022 1022 cleanupGroupTree();
Note:
See TracChangeset
for help on using the changeset viewer.