Changeset 74039 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Sep 3, 2018 10:22:39 AM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/manager/details
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsItem.cpp
r73424 r74039 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 … … 23 23 # include <QAccessibleObject> 24 24 # include <QApplication> 25 # include <QGraphicsScene> 25 26 # include <QPainter> 26 # include <QGraphicsScene>27 27 # include <QStyleOptionGraphicsItem> 28 28 29 29 /* GUI includes: */ 30 30 # include "UIGraphicsTextPane.h" 31 # include "UIDetails.h" 32 # include "UIDetailsElement.h" 31 33 # include "UIDetailsGroup.h" 34 # include "UIDetailsModel.h" 32 35 # include "UIDetailsSet.h" 33 # include "UIDetailsElement.h"34 # include "UIDetailsModel.h"35 36 # include "UIDetailsView.h" 36 # include "UIDetails.h"37 37 38 38 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ … … 193 193 194 194 195 /********************************************************************************************************************************* 196 * Class UIDetailsItem implementation. * 197 *********************************************************************************************************************************/ 198 195 199 UIDetailsItem::UIDetailsItem(UIDetailsItem *pParent) 196 200 : QIWithRetranslateUI4<QIGraphicsWidget>(pParent) … … 214 218 215 219 /* Setup connections: */ 216 connect(this, SIGNAL(sigBuildStep(QString, int)), 217 this, SLOT(sltBuildStep(QString, int)), Qt::QueuedConnection); 218 } 219 220 UIDetailsGroup* UIDetailsItem::toGroup() 220 connect(this, &UIDetailsItem::sigBuildStep, 221 this, &UIDetailsItem::sltBuildStep, 222 Qt::QueuedConnection); 223 } 224 225 UIDetailsGroup *UIDetailsItem::toGroup() 221 226 { 222 227 UIDetailsGroup *pItem = qgraphicsitem_cast<UIDetailsGroup*>(this); … … 225 230 } 226 231 227 UIDetailsSet *UIDetailsItem::toSet()232 UIDetailsSet *UIDetailsItem::toSet() 228 233 { 229 234 UIDetailsSet *pItem = qgraphicsitem_cast<UIDetailsSet*>(this); … … 232 237 } 233 238 234 UIDetailsElement *UIDetailsItem::toElement()239 UIDetailsElement *UIDetailsItem::toElement() 235 240 { 236 241 UIDetailsElement *pItem = qgraphicsitem_cast<UIDetailsElement*>(this); … … 239 244 } 240 245 241 UIDetailsModel *UIDetailsItem::model() const246 UIDetailsModel *UIDetailsItem::model() const 242 247 { 243 248 UIDetailsModel *pModel = qobject_cast<UIDetailsModel*>(QIGraphicsWidget::scene()->parent()); 244 249 AssertMsg(pModel, ("Incorrect graphics scene parent set!")); 245 250 return pModel; 246 }247 248 UIDetailsItem* UIDetailsItem::parentItem() const249 {250 return m_pParent;251 251 } 252 252 … … 278 278 /* static */ 279 279 void UIDetailsItem::configurePainterShape(QPainter *pPainter, 280 const QStyleOptionGraphicsItem *pOption,281 280 const QStyleOptionGraphicsItem *pOptions, 281 int iRadius) 282 282 { 283 283 /* Rounded corners? */ … … 286 286 /* Setup clipping: */ 287 287 QPainterPath roundedPath; 288 roundedPath.addRoundedRect(pOption ->rect, iRadius, iRadius);288 roundedPath.addRoundedRect(pOptions->rect, iRadius, iRadius); 289 289 pPainter->setRenderHint(QPainter::Antialiasing); 290 290 pPainter->setClipPath(roundedPath); … … 314 314 /* static */ 315 315 void UIDetailsItem::paintText(QPainter *pPainter, QPoint point, 316 317 316 const QFont &font, QPaintDevice *pPaintDevice, 317 const QString &strText, const QColor &color) 318 318 { 319 319 /* Prepare variables: */ … … 329 329 } 330 330 331 332 /********************************************************************************************************************************* 333 * Class UIPrepareStep implementation. * 334 *********************************************************************************************************************************/ 335 331 336 UIPrepareStep::UIPrepareStep(QObject *pParent, QObject *pBuildObject, const QString &strStepId, int iStepNumber) 332 337 : QObject(pParent) … … 334 339 , m_iStepNumber(iStepNumber) 335 340 { 336 /* Prepare connections: */ 337 connect(pBuildObject, SIGNAL(sigBuildDone()), this, SLOT(sltStepDone()), Qt::QueuedConnection); 338 connect(this, SIGNAL(sigStepDone(QString, int)), pParent, SLOT(sltBuildStep(QString, int)), Qt::QueuedConnection); 341 /* Prepare connections (old style, polymorph): */ 342 connect(pBuildObject, SIGNAL(sigBuildDone()), 343 this, SLOT(sltStepDone()), 344 Qt::QueuedConnection); 345 connect(this, SIGNAL(sigStepDone(QString, int)), 346 pParent, SLOT(sltBuildStep(QString, int)), 347 Qt::QueuedConnection); 339 348 } 340 349 … … 343 352 emit sigStepDone(m_strStepId, m_iStepNumber); 344 353 } 345 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsItem.h
r73424 r74039 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 __ UIDetailsItem_h__19 #define __ UIDetailsItem_h__18 #ifndef ___UIDetailsItem_h___ 19 #define ___UIDetailsItem_h___ 20 20 21 21 /* GUI includes: */ … … 24 24 25 25 /* Forward declaration: */ 26 class UIDetailsModel;27 26 class QGraphicsSceneHoverEvent; 28 27 class QGraphicsSceneMouseEvent; 28 class UIDetailsElement; 29 29 class UIDetailsGroup; 30 class UIDetailsModel; 30 31 class UIDetailsSet; 31 class UIDetailsElement;32 32 33 /* UIDetailsItem types: */ 33 34 /** UIDetailsItem types. */ 34 35 enum UIDetailsItemType 35 36 { 36 37 UIDetailsItemType_Any = QGraphicsItem::UserType, 37 UIDetailsItemType_Group = QGraphicsItem::UserType + 1,38 UIDetailsItemType_Set = QGraphicsItem::UserType + 2,39 UIDetailsItemType_Element = QGraphicsItem::UserType + 3,40 UIDetailsItemType_Preview = QGraphicsItem::UserType + 1038 UIDetailsItemType_Group, 39 UIDetailsItemType_Set, 40 UIDetailsItemType_Element, 41 UIDetailsItemType_Preview 41 42 }; 42 43 43 /* Details item interface 44 * for graphics details model/view architecture: */ 44 45 /** QIGraphicsWidget extension used as interface 46 * for graphics details model/view architecture. */ 45 47 class UIDetailsItem : public QIWithRetranslateUI4<QIGraphicsWidget> 46 48 { … … 49 51 signals: 50 52 51 /* Notifiers: Build stuff: */ 52 void sigBuildStep(QString strStepId, int iStepNumber); 53 void sigBuildDone(); 53 /** @name Item stuff. 54 * @{ */ 55 /** Notifies listeners about step build should be started. 56 * @param strStepId Brings the step ID. 57 * @param iStepNumber Brings the step number. */ 58 void sigBuildStep(QString strStepId, int iStepNumber); 59 /** Notifies listeners about step build complete. */ 60 void sigBuildDone(); 61 /** @} */ 54 62 55 63 public: 56 64 57 /* Constructor:*/65 /** Constructs item passing @a pParent to the base-class. */ 58 66 UIDetailsItem(UIDetailsItem *pParent); 59 67 60 /* API: Cast stuff: */61 UIDetailsGroup* toGroup();62 UIDetailsSet* toSet();63 UIDetailsElement* toElement();68 /** @name Item stuff. 69 * @{ */ 70 /** Returns parent reference. */ 71 UIDetailsItem *parentItem() const { return m_pParent; } 64 72 65 /* API: Model stuff: */ 66 UIDetailsModel* model() const; 73 /** Casts item to group one. */ 74 UIDetailsGroup *toGroup(); 75 /** Casts item to set one. */ 76 UIDetailsSet *toSet(); 77 /** Casts item to element one. */ 78 UIDetailsElement *toElement(); 67 79 68 /* API: Parent stuff:*/69 UIDetailsItem* parentItem() const;80 /** Returns model reference. */ 81 UIDetailsModel *model() const; 70 82 71 /** Returns the description of the item. */ 72 virtual QString description() const = 0; 83 /** Returns the description of the item. */ 84 virtual QString description() const = 0; 85 /** @} */ 73 86 74 /* API: Children stuff: */75 virtual void addItem(UIDetailsItem *pItem) = 0;76 virtual void removeItem(UIDetailsItem *pItem) = 0;77 virtual QList<UIDetailsItem*> items(UIDetailsItemType type = UIDetailsItemType_Any) const= 0;78 virtual bool hasItems(UIDetailsItemType type = UIDetailsItemType_Any) const = 0;79 virtual void clearItems(UIDetailsItemType type = UIDetailsItemType_Any) = 0;87 /** @name Children stuff. 88 * @{ */ 89 /** Adds child @a pItem. */ 90 virtual void addItem(UIDetailsItem *pItem) = 0; 91 /** Removes child @a pItem. */ 92 virtual void removeItem(UIDetailsItem *pItem) = 0; 80 93 81 /* API: Layout stuff: */ 82 void updateGeometry(); 83 virtual int minimumWidthHint() const = 0; 84 virtual int minimumHeightHint() const = 0; 85 QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const; 86 virtual void updateLayout() = 0; 94 /** Returns children items of certain @a enmType. */ 95 virtual QList<UIDetailsItem*> items(UIDetailsItemType enmType = UIDetailsItemType_Any) const = 0; 96 /** Returns whether there are children items of certain @a enmType. */ 97 virtual bool hasItems(UIDetailsItemType enmType = UIDetailsItemType_Any) const = 0; 98 /** Clears children items of certain @a enmType. */ 99 virtual void clearItems(UIDetailsItemType enmType = UIDetailsItemType_Any) = 0; 100 /** @} */ 101 102 /** @name Layout stuff. 103 * @{ */ 104 /** Updates geometry. */ 105 void updateGeometry(); 106 107 /** Updates layout. */ 108 virtual void updateLayout() = 0; 109 110 /** Returns minimum width-hint. */ 111 virtual int minimumWidthHint() const = 0; 112 /** Returns minimum height-hint. */ 113 virtual int minimumHeightHint() const = 0; 114 115 /** Returns size-hint. 116 * @param enmWhich Brings size-hint type. 117 * @param constraint Brings size constraint. */ 118 QSizeF sizeHint(Qt::SizeHint enmWhich, const QSizeF &constraint = QSizeF()) const; 119 /** @} */ 87 120 88 121 protected slots: 89 122 90 /* Handler: Build stuff: */ 123 /** @name Item stuff. 124 * @{ */ 125 /** Handles request about starting step build. 126 * @param strStepId Brings the step ID. 127 * @param iStepNumber Brings the step number. */ 128 /** @} */ 91 129 virtual void sltBuildStep(QString strStepId, int iStepNumber); 92 130 93 131 protected: 94 132 95 /* Helper: Translate stuff: */ 96 void retranslateUi() {} 133 /** @name Event-handling stuff. 134 * @{ */ 135 /** Handles translation event. */ 136 virtual void retranslateUi() /* override */ {} 137 /** @} */ 97 138 98 /* Helpers: Paint stuff: */ 99 static void configurePainterShape(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, int iRadius); 100 static void paintFrameRect(QPainter *pPainter, const QRect &rect, int iRadius); 101 static void paintPixmap(QPainter *pPainter, const QRect &rect, const QPixmap &pixmap); 102 static void paintText(QPainter *pPainter, QPoint point, 103 const QFont &font, QPaintDevice *pPaintDevice, 104 const QString &strText, const QColor &color); 139 /** @name Painting stuff. 140 * @{ */ 141 /** Configures painting shape using passed @a pPainter, @a pOptions and spified @a iRadius. */ 142 static void configurePainterShape(QPainter *pPainter, const QStyleOptionGraphicsItem *pOptions, int iRadius); 143 /** Paints frame @a rect using passed @a pPainter and spified @a iRadius. */ 144 static void paintFrameRect(QPainter *pPainter, const QRect &rect, int iRadius); 145 /** Paints @a pixmap using passed @a pPainter and spified @a rect. */ 146 static void paintPixmap(QPainter *pPainter, const QRect &rect, const QPixmap &pixmap); 147 /** Paints @a strText using passed @a pPainter, @a font, @a color, @a pPaintDevice and spified @a point. */ 148 static void paintText(QPainter *pPainter, QPoint point, 149 const QFont &font, QPaintDevice *pPaintDevice, 150 const QString &strText, const QColor &color); 151 /** @} */ 105 152 106 153 private: 107 154 108 /* Variables:*/155 /** Holds the parent item reference. */ 109 156 UIDetailsItem *m_pParent; 110 157 }; 111 158 112 /* Allows to build item content synchronously: */ 159 160 /** QObject extension used to prepare details steps. */ 113 161 class UIPrepareStep : public QObject 114 162 { … … 117 165 signals: 118 166 119 /* Notifier: Build stuff: */ 167 /** Notifies listeners about step preparing is complete. 168 * @param strStepId Brings the step ID. 169 * @param iStepNumber Brings the step number. */ 120 170 void sigStepDone(QString strStepId, int iStepNumber); 121 171 122 172 public: 123 173 124 /* Constructor: */ 174 /** Constructs step preparing object passing @a pParent to the base-class. 175 * @param pBuildObject Brings the build object reference. 176 * @param strStepId Brings the step ID. 177 * @param iStepNumber Brings the step number.*/ 125 178 UIPrepareStep(QObject *pParent, QObject *pBuildObject, const QString &strStepId, int iStepNumber); 126 179 127 180 private slots: 128 181 129 /* Handler: Build stuff:*/182 /** Handles step prepare completion. */ 130 183 void sltStepDone(); 131 184 132 185 private: 133 186 134 /* Variables: */ 135 QString m_strStepId; 136 int m_iStepNumber; 187 /** Holds the step ID. */ 188 QString m_strStepId; 189 /** Holds the step number. */ 190 int m_iStepNumber; 137 191 }; 138 192 139 #endif /* __UIDetailsItem_h__ */140 193 194 #endif /* !___UIDetailsItem_h___ */
Note:
See TracChangeset
for help on using the changeset viewer.