Changeset 73954 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Aug 29, 2018 2:53:36 PM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGlobal.cpp
r73927 r73954 21 21 22 22 /* Qt includes: */ 23 # include <QGraphicsSceneMouseEvent> 23 24 # include <QPainter> 24 25 # include <QStyleOptionGraphicsItem> 25 # include <QGraphicsSceneMouseEvent>26 26 27 27 /* GUI includes: */ … … 30 30 # include "UIChooserModel.h" 31 31 # include "UIIconPool.h" 32 //# include "UIImageTools.h"33 32 # include "UIVirtualBoxManager.h" 34 33 … … 39 38 int iPosition /* = -1 */) 40 39 : UIChooserItem(pParent, pParent->isTemporary()) 40 , m_iHoverLightness(0) 41 , m_iHighlightLightness(0) 42 , m_iHoverHighlightLightness(0) 43 , m_iMinimumNameWidth(0) 44 , m_iMaximumNameWidth(0) 41 45 { 42 46 /* Prepare: */ … … 63 67 int iPosition /* = -1 */) 64 68 : UIChooserItem(pParent, pParent->isTemporary()) 69 , m_iHoverLightness(0) 70 , m_iHighlightLightness(0) 71 , m_iHoverHighlightLightness(0) 72 , m_iMinimumNameWidth(0) 73 , m_iMaximumNameWidth(0) 65 74 { 66 75 /* Prepare: */ … … 109 118 } 110 119 111 QString UIChooserItemGlobal::name() const112 {113 return m_strName;114 }115 116 QString UIChooserItemGlobal::description() const117 {118 return m_strDescription;119 }120 121 QString UIChooserItemGlobal::fullName() const122 {123 return m_strName;124 }125 126 QString UIChooserItemGlobal::definition() const127 {128 return QString("n=%1").arg(name());129 }130 131 void UIChooserItemGlobal::sltHandleWindowRemapped()132 {133 updatePixmap();134 }135 136 QVariant UIChooserItemGlobal::data(int iKey) const137 {138 /* Provide other members with required data: */139 switch (iKey)140 {141 /* Layout hints: */142 case GlobalItemData_Margin: return QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) / 4;143 case GlobalItemData_Spacing: return QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) / 2;144 145 /* Default: */146 default: break;147 }148 return QVariant();149 }150 151 void UIChooserItemGlobal::updatePixmap()152 {153 /* Acquire new metric, then compose pixmap-size: */154 const int iMetric = QApplication::style()->pixelMetric(QStyle::PM_LargeIconSize);155 const QSize pixmapSize = QSize(iMetric, iMetric);156 157 /* Create new icon, then acquire pixmap: */158 const QIcon icon = UIIconPool::iconSet(":/tools_global_32px.png");159 const QPixmap pixmap = icon.pixmap(gpManager->windowHandle(), pixmapSize);160 161 /* Update linked values: */162 if (m_pixmapSize != pixmapSize)163 {164 m_pixmapSize = pixmapSize;165 updateMaximumNameWidth();166 updateGeometry();167 }168 if (m_pixmap.toImage() != pixmap.toImage())169 {170 m_pixmap = pixmap;171 update();172 }173 }174 175 void UIChooserItemGlobal::updateMinimumNameWidth()176 {177 /* Calculate new minimum name width: */178 QPaintDevice *pPaintDevice = model()->paintDevice();179 const QFontMetrics fm(m_nameFont, pPaintDevice);180 const int iMinimumNameWidth = fm.width(compressText(m_nameFont, pPaintDevice, m_strName, textWidth(m_nameFont, pPaintDevice, 15)));181 182 /* Is there something changed? */183 if (m_iMinimumNameWidth == iMinimumNameWidth)184 return;185 186 /* Update linked values: */187 m_iMinimumNameWidth = iMinimumNameWidth;188 updateGeometry();189 }190 191 void UIChooserItemGlobal::updateMaximumNameWidth()192 {193 /* Prepare variables: */194 const int iMargin = data(GlobalItemData_Margin).toInt();195 const int iSpacing = data(GlobalItemData_Spacing).toInt();196 197 /* Calculate new maximum name width: */198 int iMaximumNameWidth = (int)geometry().width();199 iMaximumNameWidth -= iMargin; /* left margin */200 iMaximumNameWidth -= m_pixmapSize.width(); /* pixmap width */201 iMaximumNameWidth -= iSpacing; /* spacing between pixmap and name */202 iMaximumNameWidth -= iMargin; /* right margin */203 204 /* Is there something changed? */205 if (m_iMaximumNameWidth == iMaximumNameWidth)206 return;207 208 /* Update linked values: */209 m_iMaximumNameWidth = iMaximumNameWidth;210 updateVisibleName();211 }212 213 void UIChooserItemGlobal::updateVisibleName()214 {215 /* Prepare variables: */216 QPaintDevice *pPaintDevice = model()->paintDevice();217 218 /* Calculate new visible name and name-size: */219 const QString strVisibleName = compressText(m_nameFont, pPaintDevice, m_strName, m_iMaximumNameWidth);220 const QSize visibleNameSize = textSize(m_nameFont, pPaintDevice, strVisibleName);221 222 /* Update linked values: */223 if (m_visibleNameSize != visibleNameSize)224 {225 m_visibleNameSize = visibleNameSize;226 updateGeometry();227 }228 if (m_strVisibleName != strVisibleName)229 {230 m_strVisibleName = strVisibleName;231 update();232 }233 }234 235 120 void UIChooserItemGlobal::retranslateUi() 236 121 { … … 247 132 } 248 133 134 void UIChooserItemGlobal::showEvent(QShowEvent *pEvent) 135 { 136 /* Call to base-class: */ 137 UIChooserItem::showEvent(pEvent); 138 139 /* Update pixmaps: */ 140 updatePixmap(); 141 } 142 143 void UIChooserItemGlobal::resizeEvent(QGraphicsSceneResizeEvent *pEvent) 144 { 145 /* Call to base-class: */ 146 UIChooserItem::resizeEvent(pEvent); 147 148 /* What is the new geometry? */ 149 const QRectF newGeometry = geometry(); 150 151 /* Should we update visible name? */ 152 if (previousGeometry().width() != newGeometry.width()) 153 updateMaximumNameWidth(); 154 155 /* Remember the new geometry: */ 156 setPreviousGeometry(newGeometry); 157 } 158 159 void UIChooserItemGlobal::mousePressEvent(QGraphicsSceneMouseEvent *pEvent) 160 { 161 /* Call to base-class: */ 162 UIChooserItem::mousePressEvent(pEvent); 163 /* No drag at all: */ 164 pEvent->ignore(); 165 } 166 167 void UIChooserItemGlobal::paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, QWidget * /* pWidget = 0 */) 168 { 169 /* Setup: */ 170 pPainter->setRenderHint(QPainter::Antialiasing); 171 172 /* Paint decorations: */ 173 paintDecorations(pPainter, pOption); 174 175 /* Paint global info: */ 176 paintGlobalInfo(pPainter, pOption); 177 } 178 249 179 void UIChooserItemGlobal::startEditing() 250 180 { … … 257 187 } 258 188 259 void UIChooserItemGlobal::addItem(UIChooserItem*, int) 189 QString UIChooserItemGlobal::name() const 190 { 191 return m_strName; 192 } 193 194 QString UIChooserItemGlobal::description() const 195 { 196 return m_strDescription; 197 } 198 199 QString UIChooserItemGlobal::fullName() const 200 { 201 return m_strName; 202 } 203 204 QString UIChooserItemGlobal::definition() const 205 { 206 return QString("n=%1").arg(name()); 207 } 208 209 void UIChooserItemGlobal::addItem(UIChooserItem *, int) 260 210 { 261 211 AssertMsgFailed(("Global graphics item do NOT support children!")); 262 212 } 263 213 264 void UIChooserItemGlobal::removeItem(UIChooserItem *)214 void UIChooserItemGlobal::removeItem(UIChooserItem *) 265 215 { 266 216 AssertMsgFailed(("Global graphics item do NOT support children!")); 267 217 } 268 218 269 void UIChooserItemGlobal::setItems(const QList<UIChooserItem*> &, UIChooserItemType)219 void UIChooserItemGlobal::setItems(const QList<UIChooserItem*> &, UIChooserItemType) 270 220 { 271 221 AssertMsgFailed(("Global graphics item do NOT support children!")); … … 321 271 { 322 272 AssertMsgFailed(("Global graphics item do NOT support children!")); 273 } 274 275 void UIChooserItemGlobal::updateLayout() 276 { 277 // Just do nothing .. 278 } 279 280 QSizeF UIChooserItemGlobal::sizeHint(Qt::SizeHint which, const QSizeF &constraint /* = QSizeF() */) const 281 { 282 /* If Qt::MinimumSize requested: */ 283 if (which == Qt::MinimumSize) 284 return QSizeF(minimumWidthHint(), minimumHeightHint()); 285 /* Else call to base-class: */ 286 return UIChooserItem::sizeHint(which, constraint); 323 287 } 324 288 … … 358 322 /* Return result: */ 359 323 return iProposedHeight; 360 }361 362 QSizeF UIChooserItemGlobal::sizeHint(Qt::SizeHint which, const QSizeF &constraint /* = QSizeF() */) const363 {364 /* If Qt::MinimumSize requested: */365 if (which == Qt::MinimumSize)366 return QSizeF(minimumWidthHint(), minimumHeightHint());367 /* Else call to base-class: */368 return UIChooserItem::sizeHint(which, constraint);369 324 } 370 325 … … 403 358 } 404 359 405 void UIChooserItemGlobal::showEvent(QShowEvent *pEvent) 406 { 407 /* Call to base-class: */ 408 UIChooserItem::showEvent(pEvent); 409 410 /* Update pixmaps: */ 360 void UIChooserItemGlobal::sltHandleWindowRemapped() 361 { 411 362 updatePixmap(); 412 363 } 413 364 414 void UIChooserItemGlobal::resizeEvent(QGraphicsSceneResizeEvent *pEvent) 415 { 416 /* Call to base-class: */ 417 UIChooserItem::resizeEvent(pEvent); 418 419 /* What is the new geometry? */ 420 const QRectF newGeometry = geometry(); 421 422 /* Should we update visible name? */ 423 if (previousGeometry().width() != newGeometry.width()) 365 void UIChooserItemGlobal::prepare() 366 { 367 /* Colors: */ 368 #ifdef VBOX_WS_MAC 369 m_iHighlightLightness = 115; 370 m_iHoverLightness = 110; 371 m_iHoverHighlightLightness = 120; 372 #else /* VBOX_WS_MAC */ 373 m_iHighlightLightness = 130; 374 m_iHoverLightness = 155; 375 m_iHoverHighlightLightness = 175; 376 #endif /* !VBOX_WS_MAC */ 377 378 /* Fonts: */ 379 m_nameFont = font(); 380 m_nameFont.setWeight(QFont::Bold); 381 382 /* Sizes: */ 383 m_iMinimumNameWidth = 0; 384 m_iMaximumNameWidth = 0; 385 } 386 387 QVariant UIChooserItemGlobal::data(int iKey) const 388 { 389 /* Provide other members with required data: */ 390 switch (iKey) 391 { 392 /* Layout hints: */ 393 case GlobalItemData_Margin: return QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) / 4; 394 case GlobalItemData_Spacing: return QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) / 2; 395 396 /* Default: */ 397 default: break; 398 } 399 return QVariant(); 400 } 401 402 void UIChooserItemGlobal::updatePixmap() 403 { 404 /* Acquire new metric, then compose pixmap-size: */ 405 const int iMetric = QApplication::style()->pixelMetric(QStyle::PM_LargeIconSize); 406 const QSize pixmapSize = QSize(iMetric, iMetric); 407 408 /* Create new icon, then acquire pixmap: */ 409 const QIcon icon = UIIconPool::iconSet(":/tools_global_32px.png"); 410 const QPixmap pixmap = icon.pixmap(gpManager->windowHandle(), pixmapSize); 411 412 /* Update linked values: */ 413 if (m_pixmapSize != pixmapSize) 414 { 415 m_pixmapSize = pixmapSize; 424 416 updateMaximumNameWidth(); 425 426 /* Remember the new geometry: */ 427 setPreviousGeometry(newGeometry); 428 } 429 430 void UIChooserItemGlobal::mousePressEvent(QGraphicsSceneMouseEvent *pEvent) 431 { 432 /* Call to base-class: */ 433 UIChooserItem::mousePressEvent(pEvent); 434 /* No drag at all: */ 435 pEvent->ignore(); 436 } 437 438 void UIChooserItemGlobal::paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, QWidget * /* pWidget = 0 */) 439 { 440 /* Setup: */ 441 pPainter->setRenderHint(QPainter::Antialiasing); 442 443 /* Paint decorations: */ 444 paintDecorations(pPainter, pOption); 445 446 /* Paint machine info: */ 447 paintMachineInfo(pPainter, pOption); 417 updateGeometry(); 418 } 419 if (m_pixmap.toImage() != pixmap.toImage()) 420 { 421 m_pixmap = pixmap; 422 update(); 423 } 424 } 425 426 void UIChooserItemGlobal::updateMinimumNameWidth() 427 { 428 /* Calculate new minimum name width: */ 429 QPaintDevice *pPaintDevice = model()->paintDevice(); 430 const QFontMetrics fm(m_nameFont, pPaintDevice); 431 const int iMinimumNameWidth = fm.width(compressText(m_nameFont, pPaintDevice, m_strName, textWidth(m_nameFont, pPaintDevice, 15))); 432 433 /* Is there something changed? */ 434 if (m_iMinimumNameWidth == iMinimumNameWidth) 435 return; 436 437 /* Update linked values: */ 438 m_iMinimumNameWidth = iMinimumNameWidth; 439 updateGeometry(); 440 } 441 442 void UIChooserItemGlobal::updateMaximumNameWidth() 443 { 444 /* Prepare variables: */ 445 const int iMargin = data(GlobalItemData_Margin).toInt(); 446 const int iSpacing = data(GlobalItemData_Spacing).toInt(); 447 448 /* Calculate new maximum name width: */ 449 int iMaximumNameWidth = (int)geometry().width(); 450 iMaximumNameWidth -= iMargin; /* left margin */ 451 iMaximumNameWidth -= m_pixmapSize.width(); /* pixmap width */ 452 iMaximumNameWidth -= iSpacing; /* spacing between pixmap and name */ 453 iMaximumNameWidth -= iMargin; /* right margin */ 454 455 /* Is there something changed? */ 456 if (m_iMaximumNameWidth == iMaximumNameWidth) 457 return; 458 459 /* Update linked values: */ 460 m_iMaximumNameWidth = iMaximumNameWidth; 461 updateVisibleName(); 462 } 463 464 void UIChooserItemGlobal::updateVisibleName() 465 { 466 /* Prepare variables: */ 467 QPaintDevice *pPaintDevice = model()->paintDevice(); 468 469 /* Calculate new visible name and name-size: */ 470 const QString strVisibleName = compressText(m_nameFont, pPaintDevice, m_strName, m_iMaximumNameWidth); 471 const QSize visibleNameSize = textSize(m_nameFont, pPaintDevice, strVisibleName); 472 473 /* Update linked values: */ 474 if (m_visibleNameSize != visibleNameSize) 475 { 476 m_visibleNameSize = visibleNameSize; 477 updateGeometry(); 478 } 479 if (m_strVisibleName != strVisibleName) 480 { 481 m_strVisibleName = strVisibleName; 482 update(); 483 } 448 484 } 449 485 … … 512 548 } 513 549 514 void UIChooserItemGlobal::paint MachineInfo(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption)550 void UIChooserItemGlobal::paintGlobalInfo(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption) 515 551 { 516 552 /* Prepare variables: */ … … 581 617 } 582 618 } 583 584 void UIChooserItemGlobal::prepare()585 {586 /* Colors: */587 #ifdef VBOX_WS_MAC588 m_iHighlightLightness = 115;589 m_iHoverLightness = 110;590 m_iHoverHighlightLightness = 120;591 #else /* VBOX_WS_MAC */592 m_iHighlightLightness = 130;593 m_iHoverLightness = 155;594 m_iHoverHighlightLightness = 175;595 #endif /* !VBOX_WS_MAC */596 597 /* Fonts: */598 m_nameFont = font();599 m_nameFont.setWeight(QFont::Bold);600 601 /* Sizes: */602 m_iMinimumNameWidth = 0;603 m_iMaximumNameWidth = 0;604 } -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGlobal.h
r73927 r73954 16 16 */ 17 17 18 #ifndef __ UIChooserItemGlobal_h__19 #define __ UIChooserItemGlobal_h__18 #ifndef ___UIChooserItemGlobal_h___ 19 #define ___UIChooserItemGlobal_h___ 20 20 21 21 /* GUI includes: */ … … 23 23 24 24 /* Forward declarations: */ 25 class QMimeData; 26 class QPainter; 27 class QStyleOptionGraphicsItem; 25 28 class UIGraphicsToolBar; 26 29 class UIGraphicsZoomButton; 27 30 28 /* Machine-item enumeration flags: */ 29 enum UIChooserItemGlobalEnumerationFlag 30 { 31 UIChooserItemGlobalEnumerationFlag_Unique = RT_BIT(0), 32 UIChooserItemGlobalEnumerationFlag_Inaccessible = RT_BIT(1) 33 }; 34 35 /* Graphics global-item 36 * for graphics selector model/view architecture: */ 31 /** UIChooserItem extension implementing global item. */ 37 32 class UIChooserItemGlobal : public UIChooserItem 38 33 { … … 41 36 public: 42 37 43 /* Graphics-item type:*/38 /** RTTI item type. */ 44 39 enum { Type = UIChooserItemType_Global }; 45 int type() const { return Type; } 46 47 /* Constructor (new item): */ 40 41 /** Constructs item with specified @a iPosition, passing @a pParent to the base-class. */ 48 42 UIChooserItemGlobal(UIChooserItem *pParent, int iPosition = -1); 49 /* Constructor (new item copy):*/43 /** Constructs temporary item with specified @a iPosition as a @a pCopyFrom, passing @a pParent to the base-class. */ 50 44 UIChooserItemGlobal(UIChooserItem *pParent, UIChooserItemGlobal *pCopyFrom, int iPosition = -1); 51 /* Destructor: */ 52 ~UIChooserItemGlobal(); 53 54 /* API: Basic stuff: */ 55 QString name() const; 56 QString description() const; 57 QString fullName() const; 58 QString definition() const; 45 /** Destructs global item. */ 46 virtual ~UIChooserItemGlobal() /* override */; 47 48 protected: 49 50 /** @name Event-handling stuff. 51 * @{ */ 52 /** Handles translation event. */ 53 virtual void retranslateUi() /* override */; 54 55 /** Handles show @a pEvent. */ 56 virtual void showEvent(QShowEvent *pEvent) /* override */; 57 58 /** Handles resize @a pEvent. */ 59 virtual void resizeEvent(QGraphicsSceneResizeEvent *pEvent) /* override */; 60 61 /** Handles mouse press @a pEvent. */ 62 virtual void mousePressEvent(QGraphicsSceneMouseEvent *pEvent) /* override */; 63 64 /** Performs painting using passed @a pPainter, @a pOptions and optionally specified @a pWidget. */ 65 virtual void paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOptions, QWidget *pWidget = 0) /* override */; 66 /** @} */ 67 68 /** @name Item stuff. 69 * @{ */ 70 /** Returns RTTI item type. */ 71 virtual int type() const /* override */ { return Type; } 72 73 /** Starts item editing. */ 74 virtual void startEditing() /* override */; 75 76 /** Updates item tool-tip. */ 77 virtual void updateToolTip() /* override */; 78 79 /** Returns item name. */ 80 virtual QString name() const /* override */; 81 /** Returns item description. */ 82 virtual QString description() const /* override */; 83 /** Returns item full-name. */ 84 virtual QString fullName() const /* override */; 85 /** Returns item definition. */ 86 virtual QString definition() const /* override */; 87 /** @} */ 88 89 /** @name Children stuff. 90 * @{ */ 91 /** Adds child @a pItem to certain @a iPosition. */ 92 virtual void addItem(UIChooserItem *pItem, int iPosition) /* override */; 93 /** Removes child @a pItem. */ 94 virtual void removeItem(UIChooserItem *pItem) /* override */; 95 96 /** Replaces children @a items of certain @a enmType. */ 97 virtual void setItems(const QList<UIChooserItem*> &items, UIChooserItemType enmType) /* override */; 98 /** Returns children items of certain @a enmType. */ 99 virtual QList<UIChooserItem*> items(UIChooserItemType enmType = UIChooserItemType_Any) const /* override */; 100 /** Returns whether there are children items of certain @a enmType. */ 101 virtual bool hasItems(UIChooserItemType enmType = UIChooserItemType_Any) const /* override */; 102 /** Clears children items of certain @a enmType. */ 103 virtual void clearItems(UIChooserItemType enmType = UIChooserItemType_Any) /* override */; 104 105 /** Updates all children items with specified @a strId. */ 106 virtual void updateAllItems(const QString &strId) /* override */; 107 /** Removes all children items with specified @a strId. */ 108 virtual void removeAllItems(const QString &strId) /* override */; 109 110 /** Searches for a first child item answering to specified @a strSearchTag and @a iItemSearchFlags. */ 111 virtual UIChooserItem *searchForItem(const QString &strSearchTag, int iItemSearchFlags) /* override */; 112 113 /** Searches for a first machine child item. */ 114 virtual UIChooserItem *firstMachineItem() /* override */; 115 116 /** Sorts children items. */ 117 virtual void sortItems() /* override */; 118 /** @} */ 119 120 /** @name Layout stuff. 121 * @{ */ 122 /** Updates layout. */ 123 virtual void updateLayout() /* override */; 124 125 /** Returns minimum width-hint. */ 126 virtual int minimumWidthHint() const /* override */; 127 /** Returns minimum height-hint. */ 128 virtual int minimumHeightHint() const /* override */; 129 130 /** Returns size-hint. 131 * @param enmWhich Brings size-hint type. 132 * @param constraint Brings size constraint. */ 133 virtual QSizeF sizeHint(Qt::SizeHint enmWhich, const QSizeF &constraint = QSizeF()) const /* override */; 134 /** @} */ 135 136 /** @name Navigation stuff. 137 * @{ */ 138 /** Returns pixmap item representation. */ 139 virtual QPixmap toPixmap() /* override */; 140 141 /** Returns whether item drop is allowed. 142 * @param pEvent Brings information about drop event. 143 * @param enmPlace Brings the place of drag token to the drop moment. */ 144 virtual bool isDropAllowed(QGraphicsSceneDragDropEvent *pEvent, DragToken where) const /* override */; 145 /** Processes item drop. 146 * @param pEvent Brings information about drop event. 147 * @param pFromWho Brings the item according to which we choose drop position. 148 * @param enmPlace Brings the place of drag token to the drop moment (according to item mentioned above). */ 149 virtual void processDrop(QGraphicsSceneDragDropEvent *pEvent, UIChooserItem *pFromWho, DragToken where) /* override */; 150 /** Reset drag token. */ 151 virtual void resetDragToken() /* override */; 152 153 /** Returns D&D mime data. */ 154 virtual QMimeData *createMimeData() /* override */; 155 /** @} */ 59 156 60 157 private slots: 61 158 62 /** Handles top-level window remaps. */ 63 void sltHandleWindowRemapped(); 159 /** @name Item stuff. 160 * @{ */ 161 /** Handles top-level window remaps. */ 162 void sltHandleWindowRemapped(); 163 /** @} */ 64 164 65 165 private: 66 166 67 /* Data enumerator:*/167 /** Data field types. */ 68 168 enum GlobalItemData 69 169 { … … 73 173 }; 74 174 75 /* Data provider: */ 76 QVariant data(int iKey) const; 77 78 /* Helpers: Update stuff: */ 79 void updatePixmap(); 80 void updateMinimumNameWidth(); 81 void updateMaximumNameWidth(); 82 void updateVisibleName(); 83 84 /* Helper: Translate stuff: */ 85 void retranslateUi(); 86 87 /* Helpers: Basic stuff: */ 88 void startEditing(); 89 void updateToolTip(); 90 91 /* Helpers: Children stuff: */ 92 void addItem(UIChooserItem *pItem, int iPosition); 93 void removeItem(UIChooserItem *pItem); 94 void setItems(const QList<UIChooserItem*> &items, UIChooserItemType type); 95 QList<UIChooserItem*> items(UIChooserItemType type) const; 96 bool hasItems(UIChooserItemType type) const; 97 void clearItems(UIChooserItemType type); 98 void updateAllItems(const QString &strId); 99 void removeAllItems(const QString &strId); 100 UIChooserItem *searchForItem(const QString &strSearchTag, int iItemSearchFlags); 101 UIChooserItem *firstMachineItem(); 102 void sortItems(); 103 104 /* Helpers: Layout stuff: */ 105 void updateLayout() {} 106 int minimumWidthHint() const; 107 int minimumHeightHint() const; 108 QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const; 109 110 /* Helpers: Drag and drop stuff: */ 111 QPixmap toPixmap(); 112 bool isDropAllowed(QGraphicsSceneDragDropEvent *pEvent, DragToken where) const; 113 void processDrop(QGraphicsSceneDragDropEvent *pEvent, UIChooserItem *pFromWho, DragToken where); 114 void resetDragToken(); 115 QMimeData *createMimeData(); 116 117 /** Handles show @a pEvent. */ 118 virtual void showEvent(QShowEvent *pEvent) /* override */; 119 120 /* Handler: Resize handling stuff: */ 121 void resizeEvent(QGraphicsSceneResizeEvent *pEvent); 122 123 /* Handler: Mouse handling stuff: */ 124 void mousePressEvent(QGraphicsSceneMouseEvent *pEvent); 125 126 /* Helpers: Paint stuff: */ 127 void paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, QWidget *pWidget = 0); 128 void paintDecorations(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption); 129 void paintBackground(QPainter *pPainter, const QRect &rect); 130 void paintFrameRectangle(QPainter *pPainter, const QRect &rect); 131 void paintMachineInfo(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption); 132 133 /* Helpers: Prepare stuff: */ 134 void prepare(); 135 136 /* Helper: Machine-item enumeration stuff: */ 137 static bool contains(const QList<UIChooserItemGlobal*> &list, 138 UIChooserItemGlobal *pItem); 139 140 /* Variables: */ 141 int m_iHighlightLightness; 142 int m_iHoverLightness; 143 int m_iHoverHighlightLightness; 144 /* Cached values: */ 145 QFont m_nameFont; 146 QPixmap m_pixmap; 147 QString m_strName; 148 QString m_strDescription; 149 QString m_strVisibleName; 150 QSize m_pixmapSize; 151 QSize m_visibleNameSize; 152 int m_iMinimumNameWidth; 153 int m_iMaximumNameWidth; 175 /** @name Prepare/cleanup cascade. 176 * @{ */ 177 /** Prepares all. */ 178 void prepare(); 179 /** @} */ 180 181 /** @name Item stuff. 182 * @{ */ 183 /** Returns abstractly stored data value for certain @a iKey. */ 184 QVariant data(int iKey) const; 185 /** @} */ 186 187 /** @name Layout stuff. 188 * @{ */ 189 /** Updates pixmap. */ 190 void updatePixmap(); 191 /** Updates minimum name width. */ 192 void updateMinimumNameWidth(); 193 /** Updates maximum name width. */ 194 void updateMaximumNameWidth(); 195 /** Updates visible name. */ 196 void updateVisibleName(); 197 /** @} */ 198 199 /** @name Painting stuff. 200 * @{ */ 201 /** Paints decorations using specified @a pPainter and certain @a pOptions. */ 202 void paintDecorations(QPainter *pPainter, const QStyleOptionGraphicsItem *pOptions); 203 /** Paints background using specified @a pPainter and certain @a rect. */ 204 void paintBackground(QPainter *pPainter, const QRect &rect); 205 /** Paints frame rectangle using specified @a pPainter and certain @a rect. */ 206 void paintFrameRectangle(QPainter *pPainter, const QRect &rect); 207 /** Paints global info using specified @a pPainter and certain @a pOptions. */ 208 void paintGlobalInfo(QPainter *pPainter, const QStyleOptionGraphicsItem *pOptions); 209 /** @} */ 210 211 /** @name Item stuff. 212 * @{ */ 213 /** Holds item hover lightness. */ 214 int m_iHoverLightness; 215 /** Holds item highlight lightness. */ 216 int m_iHighlightLightness; 217 /** Holds item hover highlight lightness. */ 218 int m_iHoverHighlightLightness; 219 220 /** Holds item pixmap. */ 221 QPixmap m_pixmap; 222 223 /** Holds item name. */ 224 QString m_strName; 225 /** Holds item description. */ 226 QString m_strDescription; 227 /** Holds item visible name. */ 228 QString m_strVisibleName; 229 230 /** Holds item name font. */ 231 QFont m_nameFont; 232 /** @} */ 233 234 /** @name Layout stuff. 235 * @{ */ 236 /** Holds pixmap size. */ 237 QSize m_pixmapSize; 238 /** Holds visible name size. */ 239 QSize m_visibleNameSize; 240 241 /** Holds minimum name width. */ 242 int m_iMinimumNameWidth; 243 /** Holds maximum name width. */ 244 int m_iMaximumNameWidth; 245 /** @} */ 154 246 }; 155 247 156 #endif /* __UIChooserItemGlobal_h__ */248 #endif /* !___UIChooserItemGlobal_h___ */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGroup.h
r73948 r73954 61 61 enum { Type = UIChooserItemType_Group }; 62 62 63 /** Constructs main-root item passing pScene to the base-class. */63 /** Constructs main-root item, passing pScene to the base-class. */ 64 64 UIChooserItemGroup(QGraphicsScene *pScene); 65 /** Constructs temporary @a fMainRoot item as a @a pCopyFrom passing pScene to the base-class. */65 /** Constructs temporary @a fMainRoot item as a @a pCopyFrom, passing pScene to the base-class. */ 66 66 UIChooserItemGroup(QGraphicsScene *pScene, UIChooserItemGroup *pCopyFrom, bool fMainRoot); 67 /** Constructs non-root item with specified @a strName and @a iPosition, @a fOpened if requested . */67 /** Constructs non-root item with specified @a strName and @a iPosition, @a fOpened if requested, passing pParent to the base-class. */ 68 68 UIChooserItemGroup(UIChooserItem *pParent, const QString &strName, bool fOpened = false, int iPosition = -1); 69 /** Constructs temporary non-root item with specified @a iPosition as a @a pCopyFrom . */69 /** Constructs temporary non-root item with specified @a iPosition as a @a pCopyFrom, passing pParent to the base-class. */ 70 70 UIChooserItemGroup(UIChooserItem *pParent, UIChooserItemGroup *pCopyFrom, int iPosition = -1); 71 71 /** Destructs group item. */ 72 ~UIChooserItemGroup();72 virtual ~UIChooserItemGroup() /* override */; 73 73 74 74 /** @name Item stuff.
Note:
See TracChangeset
for help on using the changeset viewer.