Changeset 73600 in vbox for trunk/src/VBox
- Timestamp:
- Aug 9, 2018 6:02:16 PM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 13 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r73492 r73600 761 761 src/manager/chooser/UIChooserItem.h \ 762 762 src/manager/chooser/UIChooserItemGroup.h \ 763 src/manager/chooser/UIChooserItemGlobal.h \ 763 764 src/manager/chooser/UIChooserItemMachine.h \ 764 765 src/manager/details/UIDetails.h \ … … 1438 1439 src/manager/chooser/UIChooserItem.cpp \ 1439 1440 src/manager/chooser/UIChooserItemGroup.cpp \ 1441 src/manager/chooser/UIChooserItemGlobal.cpp \ 1440 1442 src/manager/chooser/UIChooserItemMachine.cpp \ 1441 1443 src/manager/details/UIDetails.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooser.cpp
r73492 r73600 72 72 } 73 73 74 UIVirtualMachineItem* UIChooser::currentItem() const 74 bool UIChooser::isGlobalItemSelected() const 75 { 76 return m_pChooserModel->isGlobalItemSelected(); 77 } 78 79 bool UIChooser::isMachineItemSelected() const 80 { 81 return m_pChooserModel->isMachineItemSelected(); 82 } 83 84 UIVirtualMachineItem *UIChooser::currentItem() const 75 85 { 76 86 return m_pChooserModel->currentMachineItem(); -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooser.h
r73492 r73600 71 71 72 72 /* API: Current-item stuff: */ 73 UIVirtualMachineItem* currentItem() const; 73 bool isGlobalItemSelected() const; 74 bool isMachineItemSelected() const; 75 UIVirtualMachineItem *currentItem() const; 74 76 QList<UIVirtualMachineItem*> currentItems() const; 75 77 bool isSingleGroupSelected() const; -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserHandlerKeyboard.cpp
r73424 r73600 268 268 { 269 269 case UIChooserItemType_Group: 270 case UIChooserItemType_Global: 270 271 case UIChooserItemType_Machine: 271 272 { -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserHandlerMouse.cpp
r73424 r73600 27 27 # include "UIChooserModel.h" 28 28 # include "UIChooserItemGroup.h" 29 # include "UIChooserItemGlobal.h" 29 30 # include "UIChooserItemMachine.h" 30 31 … … 73 74 if (UIChooserItemGroup *pGroupItem = qgraphicsitem_cast<UIChooserItemGroup*>(pItemUnderMouse)) 74 75 pClickedItem = pGroupItem; 76 /* Or a global one? */ 77 else if (UIChooserItemGlobal *pGlobalItem = qgraphicsitem_cast<UIChooserItemGlobal*>(pItemUnderMouse)) 78 pClickedItem = pGlobalItem; 75 79 /* Or a machine one? */ 76 80 else if (UIChooserItemMachine *pMachineItem = qgraphicsitem_cast<UIChooserItemMachine*>(pItemUnderMouse)) … … 128 132 if (UIChooserItemGroup *pGroupItem = qgraphicsitem_cast<UIChooserItemGroup*>(pItemUnderMouse)) 129 133 pClickedItem = pGroupItem; 134 /* Or a global one? */ 135 else if (UIChooserItemGlobal *pGlobalItem = qgraphicsitem_cast<UIChooserItemGlobal*>(pItemUnderMouse)) 136 pClickedItem = pGlobalItem; 130 137 /* Or a machine one? */ 131 138 else if (UIChooserItemMachine *pMachineItem = qgraphicsitem_cast<UIChooserItemMachine*>(pItemUnderMouse)) … … 211 218 else if (pItemUnderMouse->type() == UIChooserItemType_Machine) 212 219 { 213 /* Activate machine 220 /* Activate machine-item: */ 214 221 model()->activateMachineItem(); 215 222 } -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItem.cpp
r73424 r73600 39 39 # include "UIChooserModel.h" 40 40 # include "UIChooserItemGroup.h" 41 # include "UIChooserItemGlobal.h" 41 42 # include "UIChooserItemMachine.h" 42 43 … … 265 266 } 266 267 268 UIChooserItemGlobal* UIChooserItem::toGlobalItem() 269 { 270 UIChooserItemGlobal *pItem = qgraphicsitem_cast<UIChooserItemGlobal*>(this); 271 AssertMsg(pItem, ("Trying to cast invalid item type to UIChooserItemGlobal!")); 272 return pItem; 273 } 274 267 275 UIChooserItemMachine* UIChooserItem::toMachineItem() 268 276 { -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItem.h
r73424 r73600 21 21 /* Qt includes: */ 22 22 #include <QMimeData> 23 #include <QString> 23 24 24 25 /* GUI includes: */ … … 33 34 class UIChooserModel; 34 35 class UIChooserItemGroup; 36 class UIChooserItemGlobal; 35 37 class UIChooserItemMachine; 36 38 class QGraphicsSceneHoverEvent; … … 43 45 enum UIChooserItemType 44 46 { 45 UIChooserItemType_Any = QGraphicsItem::UserType, 46 UIChooserItemType_Group = QGraphicsItem::UserType + 1, 47 UIChooserItemType_Machine = QGraphicsItem::UserType + 2 47 UIChooserItemType_Any = QGraphicsItem::UserType, 48 UIChooserItemType_Group, 49 UIChooserItemType_Global, 50 UIChooserItemType_Machine 48 51 }; 49 52 … … 52 55 { 53 56 UIChooserItemSearchFlag_Machine = RT_BIT(0), 54 UIChooserItemSearchFlag_Group = RT_BIT(1), 55 UIChooserItemSearchFlag_ExactName = RT_BIT(2) 57 UIChooserItemSearchFlag_Global = RT_BIT(1), 58 UIChooserItemSearchFlag_Group = RT_BIT(2), 59 UIChooserItemSearchFlag_ExactName = RT_BIT(3) 56 60 }; 57 61 … … 82 86 83 87 /* API: Cast stuff: */ 84 UIChooserItemGroup* toGroupItem(); 85 UIChooserItemMachine* toMachineItem(); 88 UIChooserItemGroup *toGroupItem(); 89 UIChooserItemGlobal *toGlobalItem(); 90 UIChooserItemMachine *toMachineItem(); 86 91 87 92 /* API: Model stuff: */ … … 118 123 virtual void removeAll(const QString &strId) = 0; 119 124 virtual UIChooserItem* searchForItem(const QString &strSearchTag, int iItemSearchFlags) = 0; 120 virtual UIChooserItem Machine* firstMachineItem() = 0;125 virtual UIChooserItem* firstMachineItem() = 0; 121 126 virtual void sortItems() = 0; 122 127 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGlobal.cpp
r73555 r73600 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UIChooserItem Machineclass implementation.3 * VBox Qt GUI - UIChooserItemGlobal class implementation. 4 4 */ 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 … … 27 27 /* GUI includes: */ 28 28 # include "VBoxGlobal.h" 29 # include "UIChooserItemGroup.h" 30 # include "UIChooserItemMachine.h" 29 # include "UIChooserItemGlobal.h" 31 30 # include "UIChooserModel.h" 32 # include "UIGraphicsToolBar.h"33 # include "UIActionPoolSelector.h"34 # include "UIGraphicsZoomButton.h"35 31 # include "UIIconPool.h" 36 # include "UIImageTools.h"32 //# include "UIImageTools.h" 37 33 # include "UIVirtualBoxManager.h" 38 34 39 /* COM includes: */40 # include "COMEnums.h"41 # include "CMachine.h"42 43 35 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 44 36 45 37 46 /* static */ 47 QString UIChooserItemMachine::className() { return "UIChooserItemMachine"; } 48 49 UIChooserItemMachine::UIChooserItemMachine(UIChooserItem *pParent, 50 const CMachine &machine, 51 int iPosition /* = -1 */) 38 UIChooserItemGlobal::UIChooserItemGlobal(UIChooserItem *pParent, 39 int iPosition /* = -1 */) 52 40 : UIChooserItem(pParent, pParent->isTemporary()) 53 , UIVirtualMachineItem(machine)54 41 { 55 42 /* Prepare: */ … … 57 44 58 45 /* Add item to the parent: */ 59 AssertMsg(parentItem(), ("No parent set for machine-item!"));46 AssertMsg(parentItem(), ("No parent set for global-item!")); 60 47 parentItem()->addItem(this, iPosition); 61 48 setZValue(parentItem()->zValue() + 1); … … 63 50 /* Configure connections: */ 64 51 connect(gpManager, &UIVirtualBoxManager::sigWindowRemapped, 65 this, &UIChooserItem Machine::sltHandleWindowRemapped);52 this, &UIChooserItemGlobal::sltHandleWindowRemapped); 66 53 67 54 /* Init: */ 68 updatePixmaps(); 69 updateName(); 70 updateSnapshotName(); 55 updatePixmap(); 71 56 72 57 /* Translate finally: */ … … 74 59 } 75 60 76 UIChooserItem Machine::UIChooserItemMachine(UIChooserItem *pParent,77 UIChooserItemMachine *pCopyFrom,78 61 UIChooserItemGlobal::UIChooserItemGlobal(UIChooserItem *pParent, 62 UIChooserItemGlobal * , 63 int iPosition /* = -1 */) 79 64 : UIChooserItem(pParent, pParent->isTemporary()) 80 , UIVirtualMachineItem(pCopyFrom->machine())81 65 { 82 66 /* Prepare: */ … … 84 68 85 69 /* Add item to the parent: */ 86 AssertMsg(parentItem(), ("No parent set for machine-item!"));70 AssertMsg(parentItem(), ("No parent set for global-item!")); 87 71 parentItem()->addItem(this, iPosition); 88 72 setZValue(parentItem()->zValue() + 1); … … 90 74 /* Configure connections: */ 91 75 connect(gpManager, &UIVirtualBoxManager::sigWindowRemapped, 92 this, &UIChooserItem Machine::sltHandleWindowRemapped);76 this, &UIChooserItemGlobal::sltHandleWindowRemapped); 93 77 94 78 /* Init: */ 95 updatePixmaps(); 96 updateName(); 97 updateSnapshotName(); 79 updatePixmap(); 98 80 99 81 /* Translate finally: */ … … 101 83 } 102 84 103 UIChooserItem Machine::~UIChooserItemMachine()85 UIChooserItemGlobal::~UIChooserItemGlobal() 104 86 { 105 87 /* If that item is focused: */ … … 123 105 124 106 /* Remove item from the parent: */ 125 AssertMsg(parentItem(), ("No parent set for machine-item!"));107 AssertMsg(parentItem(), ("No parent set for global-item!")); 126 108 parentItem()->removeItem(this); 127 109 } 128 110 129 QString UIChooserItem Machine::name() const130 { 131 return UIVirtualMachineItem::name();132 } 133 134 QString UIChooserItem Machine::description() const111 QString UIChooserItemGlobal::name() const 112 { 113 return m_strName; 114 } 115 116 QString UIChooserItemGlobal::description() const 135 117 { 136 118 return m_strDescription; 137 119 } 138 120 139 QString UIChooserItemMachine::fullName() const 140 { 141 /* Get full parent name, append with '/' if not yet appended: */ 142 AssertMsg(parentItem(), ("Incorrect parent set!")); 143 QString strFullParentName = parentItem()->fullName(); 144 if (!strFullParentName.endsWith('/')) 145 strFullParentName.append('/'); 146 /* Return full item name based on parent prefix: */ 147 return strFullParentName + name(); 148 } 149 150 QString UIChooserItemMachine::definition() const 151 { 152 return QString("m=%1").arg(name()); 153 } 154 155 bool UIChooserItemMachine::isLockedMachine() const 156 { 157 KMachineState state = machineState(); 158 return state != KMachineState_PoweredOff && 159 state != KMachineState_Saved && 160 state != KMachineState_Teleported && 161 state != KMachineState_Aborted; 162 } 163 164 /* static */ 165 void UIChooserItemMachine::enumerateMachineItems(const QList<UIChooserItem*> &il, 166 QList<UIChooserItemMachine*> &ol, 167 int iEnumerationFlags /* = 0 */) 168 { 169 /* Enumerate all the passed items: */ 170 foreach (UIChooserItem *pItem, il) 171 { 172 /* If that is machine-item: */ 173 if (pItem->type() == UIChooserItemType_Machine) 174 { 175 /* Get the iterated machine-item: */ 176 UIChooserItemMachine *pMachineItem = pItem->toMachineItem(); 177 /* Skip if exactly this item is already enumerated: */ 178 if (ol.contains(pMachineItem)) 179 continue; 180 /* Skip if item with same ID is already enumerated but we need unique: */ 181 if ((iEnumerationFlags & UIChooserItemMachineEnumerationFlag_Unique) && 182 contains(ol, pMachineItem)) 183 continue; 184 /* Skip if this item is accessible and we no need it: */ 185 if ((iEnumerationFlags & UIChooserItemMachineEnumerationFlag_Inaccessible) && 186 pMachineItem->accessible()) 187 continue; 188 /* Add it: */ 189 ol << pMachineItem; 190 } 191 /* If that is group-item: */ 192 else if (pItem->type() == UIChooserItemType_Group) 193 { 194 /* Enumerate all the machine-items recursively: */ 195 enumerateMachineItems(pItem->items(UIChooserItemType_Machine), ol, iEnumerationFlags); 196 /* Enumerate all the group-items recursively: */ 197 enumerateMachineItems(pItem->items(UIChooserItemType_Group), ol, iEnumerationFlags); 198 } 199 } 200 } 201 202 void UIChooserItemMachine::sltHandleWindowRemapped() 203 { 204 /* Recache and update pixmaps: */ 205 recachePixmap(); 206 updatePixmaps(); 207 } 208 209 QVariant UIChooserItemMachine::data(int iKey) const 121 QString UIChooserItemGlobal::fullName() const 122 { 123 return m_strName; 124 } 125 126 QString UIChooserItemGlobal::definition() const 127 { 128 return QString("n=%1").arg(name()); 129 } 130 131 void UIChooserItemGlobal::sltHandleWindowRemapped() 132 { 133 updatePixmap(); 134 } 135 136 QVariant UIChooserItemGlobal::data(int iKey) const 210 137 { 211 138 /* Provide other members with required data: */ … … 213 140 { 214 141 /* Layout hints: */ 215 case MachineItemData_Margin: return QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) / 4; 216 case MachineItemData_MajorSpacing: return QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) / 2; 217 case MachineItemData_MinorSpacing: return QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) / 4; 218 case MachineItemData_TextSpacing: return 0; 219 220 /* Pixmaps: */ 221 case MachineItemData_SettingsButtonPixmap: return UIIconPool::iconSet(":/vm_settings_16px.png"); 222 case MachineItemData_StartButtonPixmap: return UIIconPool::iconSet(":/vm_start_16px.png"); 223 case MachineItemData_PauseButtonPixmap: return UIIconPool::iconSet(":/vm_pause_16px.png"); 224 case MachineItemData_CloseButtonPixmap: return UIIconPool::iconSet(":/exit_16px.png"); 225 226 /* Sizes: */ 227 case MachineItemData_ToolBarSize: return m_pToolBar ? m_pToolBar->minimumSizeHint().toSize() : QSize(0, 0); 142 case GlobalItemData_Margin: return QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) / 4; 143 case GlobalItemData_Spacing: return QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) / 2; 228 144 229 145 /* Default: */ … … 233 149 } 234 150 235 void UIChooserItemMachine::updatePixmaps() 236 { 237 /* Update pixmap: */ 238 updatePixmap(); 239 240 /* Update state-pixmap: */ 241 updateStatePixmap(); 242 } 243 244 void UIChooserItemMachine::updatePixmap() 245 { 246 /* Get new pixmap and pixmap-size: */ 247 QSize pixmapSize; 248 QPixmap pixmap = osPixmap(&pixmapSize); 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 249 161 /* Update linked values: */ 250 162 if (m_pixmapSize != pixmapSize) 251 163 { 252 164 m_pixmapSize = pixmapSize; 253 update FirstRowMaximumWidth();165 updateMaximumNameWidth(); 254 166 updateGeometry(); 255 167 } … … 261 173 } 262 174 263 void UIChooserItemMachine::updateStatePixmap() 264 { 265 /* Determine the icon metric: */ 266 const QStyle *pStyle = QApplication::style(); 267 const int iIconMetric = pStyle->pixelMetric(QStyle::PM_SmallIconSize); 268 /* Get new state-pixmap and state-pixmap size: */ 269 const QIcon stateIcon = machineStateIcon(); 270 AssertReturnVoid(!stateIcon.isNull()); 271 const QSize statePixmapSize = QSize(iIconMetric, iIconMetric); 272 const QPixmap statePixmap = stateIcon.pixmap(gpManager->windowHandle(), statePixmapSize); 273 /* Update linked values: */ 274 if (m_statePixmapSize != statePixmapSize) 275 { 276 m_statePixmapSize = statePixmapSize; 277 updateGeometry(); 278 } 279 if (m_statePixmap.toImage() != statePixmap.toImage()) 280 { 281 m_statePixmap = statePixmap; 282 update(); 283 } 284 } 285 286 void UIChooserItemMachine::updateName() 287 { 288 /* Get new name: */ 289 QString strName = name(); 290 291 /* Is there something changed? */ 292 if (m_strName == strName) 293 return; 294 295 /* Update linked values: */ 296 m_strName = strName; 297 updateMinimumNameWidth(); 298 updateVisibleName(); 299 } 300 301 void UIChooserItemMachine::updateSnapshotName() 302 { 303 /* Get new snapshot-name: */ 304 QString strSnapshotName = snapshotName(); 305 306 /* Is there something changed? */ 307 if (m_strSnapshotName == strSnapshotName) 308 return; 309 310 /* Update linked values: */ 311 m_strSnapshotName = strSnapshotName; 312 updateMinimumSnapshotNameWidth(); 313 updateVisibleSnapshotName(); 314 } 315 316 void UIChooserItemMachine::updateFirstRowMaximumWidth() 317 { 318 /* Prepare variables: */ 319 int iMargin = data(MachineItemData_Margin).toInt(); 320 int iMajorSpacing = data(MachineItemData_MajorSpacing).toInt(); 321 int iToolBarWidth = data(MachineItemData_ToolBarSize).toSize().width(); 322 323 /* Calculate new maximum width for the first row: */ 324 int iFirstRowMaximumWidth = (int)geometry().width(); 325 iFirstRowMaximumWidth -= iMargin; /* left margin */ 326 iFirstRowMaximumWidth -= m_pixmapSize.width(); /* pixmap width */ 327 iFirstRowMaximumWidth -= iMajorSpacing; /* spacing between pixmap and name(s) */ 328 if (m_pToolBar) 329 { 330 iFirstRowMaximumWidth -= iMajorSpacing; /* spacing before toolbar */ 331 iFirstRowMaximumWidth -= iToolBarWidth; /* toolbar width */ 332 } 333 iFirstRowMaximumWidth -= iMargin; /* right margin */ 334 335 /* Is there something changed? */ 336 if (m_iFirstRowMaximumWidth == iFirstRowMaximumWidth) 337 return; 338 339 /* Update linked values: */ 340 m_iFirstRowMaximumWidth = iFirstRowMaximumWidth; 341 updateMaximumNameWidth(); 342 updateMaximumSnapshotNameWidth(); 343 } 344 345 void UIChooserItemMachine::updateMinimumNameWidth() 175 void UIChooserItemGlobal::updateMinimumNameWidth() 346 176 { 347 177 /* Calculate new minimum name width: */ 348 178 QPaintDevice *pPaintDevice = model()->paintDevice(); 349 QFontMetrics fm(m_nameFont, pPaintDevice);350 int iMinimumNameWidth = fm.width(compressText(m_nameFont, pPaintDevice, m_strName, textWidth(m_nameFont, pPaintDevice, 15)));179 const QFontMetrics fm(m_nameFont, pPaintDevice); 180 const int iMinimumNameWidth = fm.width(compressText(m_nameFont, pPaintDevice, m_strName, textWidth(m_nameFont, pPaintDevice, 15))); 351 181 352 182 /* Is there something changed? */ … … 359 189 } 360 190 361 void UIChooserItemMachine::updateMinimumSnapshotNameWidth() 362 { 363 /* Calculate new minimum snapshot-name width: */ 364 int iMinimumSnapshotNameWidth = 0; 365 /* Is there any snapshot exists? */ 366 if (!m_strSnapshotName.isEmpty()) 367 { 368 QFontMetrics fm(m_snapshotNameFont, model()->paintDevice()); 369 int iBracketWidth = fm.width("()"); /* bracket width */ 370 int iActualTextWidth = fm.width(m_strSnapshotName); /* snapshot-name width */ 371 int iMinimumTextWidth = fm.width("..."); /* ellipsis width */ 372 iMinimumSnapshotNameWidth = iBracketWidth + qMin(iActualTextWidth, iMinimumTextWidth); 373 } 374 375 /* Is there something changed? */ 376 if (m_iMinimumSnapshotNameWidth == iMinimumSnapshotNameWidth) 377 return; 378 379 /* Update linked values: */ 380 m_iMinimumSnapshotNameWidth = iMinimumSnapshotNameWidth; 381 updateMaximumNameWidth(); 382 updateGeometry(); 383 } 384 385 void UIChooserItemMachine::updateMaximumNameWidth() 386 { 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 387 197 /* Calculate new maximum name width: */ 388 int iMaximumNameWidth = m_iFirstRowMaximumWidth; 389 /* Do we have a minimum snapshot-name width? */ 390 if (m_iMinimumSnapshotNameWidth != 0) 391 { 392 /* Prepare variables: */ 393 int iMinorSpacing = data(MachineItemData_MinorSpacing).toInt(); 394 /* Take spacing and snapshot-name into account: */ 395 iMaximumNameWidth -= (iMinorSpacing + m_iMinimumSnapshotNameWidth); 396 } 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 */ 397 203 398 204 /* Is there something changed? */ … … 405 211 } 406 212 407 void UIChooserItemMachine::updateMaximumSnapshotNameWidth() 408 { 409 /* Prepare variables: */ 410 int iMinorSpacing = data(MachineItemData_MinorSpacing).toInt(); 411 412 /* Calculate new maximum snapshot-name width: */ 413 int iMaximumSnapshotNameWidth = m_iFirstRowMaximumWidth; 414 iMaximumSnapshotNameWidth -= (iMinorSpacing + m_visibleNameSize.width()); 415 416 /* Is there something changed? */ 417 if (m_iMaximumSnapshotNameWidth == iMaximumSnapshotNameWidth) 418 return; 419 420 /* Update linked values: */ 421 m_iMaximumSnapshotNameWidth = iMaximumSnapshotNameWidth; 422 updateVisibleSnapshotName(); 423 } 424 425 void UIChooserItemMachine::updateVisibleName() 213 void UIChooserItemGlobal::updateVisibleName() 426 214 { 427 215 /* Prepare variables: */ … … 429 217 430 218 /* Calculate new visible name and name-size: */ 431 QString strVisibleName = compressText(m_nameFont, pPaintDevice, m_strName, m_iMaximumNameWidth);432 QSize visibleNameSize = textSize(m_nameFont, pPaintDevice, strVisibleName);219 const QString strVisibleName = compressText(m_nameFont, pPaintDevice, m_strName, m_iMaximumNameWidth); 220 const QSize visibleNameSize = textSize(m_nameFont, pPaintDevice, strVisibleName); 433 221 434 222 /* Update linked values: */ … … 436 224 { 437 225 m_visibleNameSize = visibleNameSize; 438 updateMaximumSnapshotNameWidth();439 226 updateGeometry(); 440 227 } … … 446 233 } 447 234 448 void UIChooserItemMachine::updateVisibleSnapshotName() 449 { 450 /* Prepare variables: */ 451 QPaintDevice *pPaintDevice = model()->paintDevice(); 452 453 /* Calculate new visible snapshot-name: */ 454 int iBracketWidth = QFontMetrics(m_snapshotNameFont, pPaintDevice).width("()"); 455 QString strVisibleSnapshotName = compressText(m_snapshotNameFont, pPaintDevice, m_strSnapshotName, 456 m_iMaximumSnapshotNameWidth - iBracketWidth); 457 strVisibleSnapshotName = QString("(%1)").arg(strVisibleSnapshotName); 458 QSize visibleSnapshotNameSize = textSize(m_snapshotNameFont, pPaintDevice, strVisibleSnapshotName); 235 void UIChooserItemGlobal::retranslateUi() 236 { 237 /* Update description: */ 238 m_strName = tr("Global Tools"); 239 m_strDescription = m_strName; 459 240 460 241 /* Update linked values: */ 461 if (m_visibleSnapshotNameSize != visibleSnapshotNameSize) 462 { 463 m_visibleSnapshotNameSize = visibleSnapshotNameSize; 464 updateGeometry(); 465 } 466 if (m_strVisibleSnapshotName != strVisibleSnapshotName) 467 { 468 m_strVisibleSnapshotName = strVisibleSnapshotName; 469 update(); 470 } 471 } 472 473 void UIChooserItemMachine::updateStateText() 474 { 475 /* Get new state-text and state-text size: */ 476 QString strStateText = machineStateName(); 477 QSize stateTextSize = textSize(m_stateTextFont, model()->paintDevice(), m_strStateText); 478 479 /* Update linked values: */ 480 if (m_stateTextSize != stateTextSize) 481 { 482 m_stateTextSize = stateTextSize; 483 updateGeometry(); 484 } 485 if (m_strStateText != strStateText) 486 { 487 m_strStateText = strStateText; 488 update(); 489 } 490 } 491 492 void UIChooserItemMachine::retranslateUi() 493 { 494 /* Update description: */ 495 m_strDescription = tr("Virtual Machine"); 496 497 /* Update state text: */ 498 updateStateText(); 499 500 /* Update machine tool-tip: */ 242 updateMinimumNameWidth(); 243 updateVisibleName(); 244 245 /* Update tool-tip: */ 501 246 updateToolTip(); 502 247 } 503 248 504 void UIChooserItemMachine::startEditing() 505 { 506 AssertMsgFailed(("Machine graphics item do NOT support editing yet!")); 507 } 508 509 void UIChooserItemMachine::updateToolTip() 510 { 511 setToolTip(toolTipText()); 512 } 513 514 void UIChooserItemMachine::addItem(UIChooserItem*, int) 515 { 516 AssertMsgFailed(("Machine graphics item do NOT support children!")); 517 } 518 519 void UIChooserItemMachine::removeItem(UIChooserItem*) 520 { 521 AssertMsgFailed(("Machine graphics item do NOT support children!")); 522 } 523 524 void UIChooserItemMachine::setItems(const QList<UIChooserItem*>&, UIChooserItemType) 525 { 526 AssertMsgFailed(("Machine graphics item do NOT support children!")); 527 } 528 529 QList<UIChooserItem*> UIChooserItemMachine::items(UIChooserItemType) const 530 { 531 AssertMsgFailed(("Machine graphics item do NOT support children!")); 532 return QList<UIChooserItem*>(); 533 } 534 535 bool UIChooserItemMachine::hasItems(UIChooserItemType) const 536 { 537 AssertMsgFailed(("Machine graphics item do NOT support children!")); 538 return false; 539 } 540 541 void UIChooserItemMachine::clearItems(UIChooserItemType) 542 { 543 AssertMsgFailed(("Machine graphics item do NOT support children!")); 544 } 545 546 void UIChooserItemMachine::updateAll(const QString &strId) 547 { 548 /* Skip other ids: */ 549 if (id() != strId) 550 return; 551 552 /* Update this machine-item: */ 553 recache(); 554 updatePixmaps(); 555 updateName(); 556 updateSnapshotName(); 557 updateStateText(); 249 void UIChooserItemGlobal::startEditing() 250 { 251 AssertMsgFailed(("Global graphics item do NOT support editing yet!")); 252 } 253 254 void UIChooserItemGlobal::updateToolTip() 255 { 256 // setToolTip(toolTipText()); 257 } 258 259 void UIChooserItemGlobal::addItem(UIChooserItem*, int) 260 { 261 AssertMsgFailed(("Global graphics item do NOT support children!")); 262 } 263 264 void UIChooserItemGlobal::removeItem(UIChooserItem*) 265 { 266 AssertMsgFailed(("Global graphics item do NOT support children!")); 267 } 268 269 void UIChooserItemGlobal::setItems(const QList<UIChooserItem*>&, UIChooserItemType) 270 { 271 AssertMsgFailed(("Global graphics item do NOT support children!")); 272 } 273 274 QList<UIChooserItem*> UIChooserItemGlobal::items(UIChooserItemType) const 275 { 276 AssertMsgFailedReturn(("Global graphics item do NOT support children!"), QList<UIChooserItem*>()); 277 } 278 279 bool UIChooserItemGlobal::hasItems(UIChooserItemType) const 280 { 281 AssertMsgFailedReturn(("Global graphics item do NOT support children!"), false); 282 } 283 284 void UIChooserItemGlobal::clearItems(UIChooserItemType) 285 { 286 AssertMsgFailed(("Global graphics item do NOT support children!")); 287 } 288 289 void UIChooserItemGlobal::updateAll(const QString &) 290 { 291 /* Update this global-item: */ 292 updatePixmap(); 558 293 updateToolTip(); 559 294 … … 563 298 } 564 299 565 void UIChooserItemMachine::removeAll(const QString &strId) 566 { 567 /* Skip wrong id: */ 568 if (id() != strId) 569 return; 570 571 /* Exclude itself from the current items: */ 572 if (model()->currentItems().contains(this)) 573 model()->removeFromCurrentItems(this); 574 /* Move the focus item to the first available current after that: */ 575 if (model()->focusItem() == this && !model()->currentItems().isEmpty()) 576 model()->setFocusItem(model()->currentItems().first()); 577 578 /* Remove item: */ 579 delete this; 580 } 581 582 UIChooserItem* UIChooserItemMachine::searchForItem(const QString &strSearchTag, int iItemSearchFlags) 583 { 584 /* Ignoring if we are not searching for the machine-item? */ 585 if (!(iItemSearchFlags & UIChooserItemSearchFlag_Machine)) 300 void UIChooserItemGlobal::removeAll(const QString &) 301 { 302 AssertMsgFailed(("Global graphics item do NOT support deleting!")); 303 } 304 305 UIChooserItem *UIChooserItemGlobal::searchForItem(const QString &, int iItemSearchFlags) 306 { 307 /* Ignoring if we are not searching for the global-item? */ 308 if (!(iItemSearchFlags & UIChooserItemSearchFlag_Global)) 586 309 return 0; 587 588 /* Are we searching by the exact name? */589 if (iItemSearchFlags & UIChooserItemSearchFlag_ExactName)590 {591 /* Exact name doesn't match? */592 if (name() != strSearchTag)593 return 0;594 }595 /* Are we searching by the few first symbols? */596 else597 {598 /* Name doesn't start with passed symbols? */599 if (!name().startsWith(strSearchTag, Qt::CaseInsensitive))600 return 0;601 }602 310 603 311 /* Returning this: */ … … 605 313 } 606 314 607 UIChooserItemMachine* UIChooserItemMachine::firstMachineItem() 608 { 609 return this; 610 } 611 612 void UIChooserItemMachine::sortItems() 613 { 614 AssertMsgFailed(("Machine graphics item do NOT support children!")); 615 } 616 617 void UIChooserItemMachine::updateLayout() 618 { 619 /* Update tool-bar: */ 620 if (m_pToolBar) 621 { 622 /* Prepare variables: */ 623 QSize size = geometry().size().toSize(); 624 625 /* Prepare variables: */ 626 int iMachineItemWidth = size.width(); 627 int iMachineItemHeight = size.height(); 628 int iToolBarHeight = data(MachineItemData_ToolBarSize).toSize().height(); 629 630 /* Configure tool-bar: */ 631 QSize toolBarSize = m_pToolBar->minimumSizeHint().toSize(); 632 int iToolBarX = iMachineItemWidth - 1 - toolBarSize.width(); 633 int iToolBarY = (iMachineItemHeight - iToolBarHeight) / 2; 634 m_pToolBar->setPos(iToolBarX, iToolBarY); 635 m_pToolBar->resize(toolBarSize); 636 m_pToolBar->updateLayout(); 637 638 /* Configure buttons: */ 639 m_pStartButton->updateAnimation(); 640 m_pSettingsButton->updateAnimation(); 641 m_pCloseButton->updateAnimation(); 642 m_pPauseButton->updateAnimation(); 643 } 644 } 645 646 int UIChooserItemMachine::minimumWidthHint() const 315 UIChooserItem *UIChooserItemGlobal::firstMachineItem() 316 { 317 return 0; 318 } 319 320 void UIChooserItemGlobal::sortItems() 321 { 322 AssertMsgFailed(("Global graphics item do NOT support children!")); 323 } 324 325 int UIChooserItemGlobal::minimumWidthHint() const 647 326 { 648 327 /* Prepare variables: */ 649 int iMargin = data(MachineItemData_Margin).toInt(); 650 int iMajorSpacing = data(MachineItemData_MajorSpacing).toInt(); 651 int iMinorSpacing = data(MachineItemData_MinorSpacing).toInt(); 652 int iToolBarWidth = data(MachineItemData_ToolBarSize).toSize().width(); 328 int iMargin = data(GlobalItemData_Margin).toInt(); 329 int iSpacing = data(GlobalItemData_Spacing).toInt(); 653 330 654 331 /* Calculating proposed width: */ … … 657 334 /* Two margins: */ 658 335 iProposedWidth += 2 * iMargin; 659 /* And machine-item content to take into account: */ 660 int iTopLineWidth = m_iMinimumNameWidth; 661 if (!m_strSnapshotName.isEmpty()) 662 iTopLineWidth += (iMinorSpacing + 663 m_iMinimumSnapshotNameWidth); 664 int iBottomLineWidth = m_statePixmapSize.width() + 665 iMinorSpacing + 666 m_stateTextSize.width(); 667 int iRightColumnWidth = qMax(iTopLineWidth, iBottomLineWidth); 668 int iMachineItemWidth = m_pixmapSize.width() + 669 iMajorSpacing + 670 iRightColumnWidth; 671 if (m_pToolBar) 672 iMachineItemWidth += (iMajorSpacing + iToolBarWidth); 673 iProposedWidth += iMachineItemWidth; 336 /* And global-item content to take into account: */ 337 iProposedWidth += (m_pixmapSize.width() + 338 iSpacing + 339 m_iMinimumNameWidth); 674 340 675 341 /* Return result: */ … … 677 343 } 678 344 679 int UIChooserItem Machine::minimumHeightHint() const345 int UIChooserItemGlobal::minimumHeightHint() const 680 346 { 681 347 /* Prepare variables: */ 682 int iMargin = data(MachineItemData_Margin).toInt(); 683 int iMachineItemTextSpacing = data(MachineItemData_TextSpacing).toInt(); 684 int iToolBarHeight = data(MachineItemData_ToolBarSize).toSize().height(); 348 int iMargin = data(GlobalItemData_Margin).toInt(); 685 349 686 350 /* Calculating proposed height: */ … … 689 353 /* Two margins: */ 690 354 iProposedHeight += 2 * iMargin; 691 /* And machine-item content to take into account: */ 692 int iTopLineHeight = qMax(m_visibleNameSize.height(), m_visibleSnapshotNameSize.height()); 693 int iBottomLineHeight = qMax(m_statePixmapSize.height(), m_stateTextSize.height()); 694 int iRightColumnHeight = iTopLineHeight + 695 iMachineItemTextSpacing + 696 iBottomLineHeight; 697 QList<int> heights; 698 heights << m_pixmapSize.height() << iRightColumnHeight << iToolBarHeight; 699 int iMaxHeight = 0; 700 foreach (int iHeight, heights) 701 iMaxHeight = qMax(iMaxHeight, iHeight); 702 iProposedHeight += iMaxHeight; 355 /* And global-item content to take into account: */ 356 iProposedHeight += qMax(m_pixmapSize.height(), m_visibleNameSize.height()); 703 357 704 358 /* Return result: */ … … 706 360 } 707 361 708 QSizeF UIChooserItem Machine::sizeHint(Qt::SizeHint which, const QSizeF &constraint /* = QSizeF() */) const362 QSizeF UIChooserItemGlobal::sizeHint(Qt::SizeHint which, const QSizeF &constraint /* = QSizeF() */) const 709 363 { 710 364 /* If Qt::MinimumSize requested: */ … … 715 369 } 716 370 717 QPixmap UIChooserItem Machine::toPixmap()371 QPixmap UIChooserItemGlobal::toPixmap() 718 372 { 719 373 /* Ask item to paint itself into pixmap: */ 720 QSize minimumSize = minimumSizeHint().toSize();374 const QSize minimumSize = minimumSizeHint().toSize(); 721 375 QPixmap pixmap(minimumSize); 722 376 QPainter painter(&pixmap); … … 727 381 } 728 382 729 bool UIChooserItemMachine::isDropAllowed(QGraphicsSceneDragDropEvent *pEvent, DragToken where) const 730 { 731 /* No drops while saving groups: */ 732 if (model()->isGroupSavingInProgress()) 733 return false; 734 /* No drops for immutable item: */ 735 if (isLockedMachine()) 736 return false; 737 /* Get mime: */ 738 const QMimeData *pMimeData = pEvent->mimeData(); 739 /* If drag token is shown, its up to parent to decide: */ 740 if (where != DragToken_Off) 741 return parentItem()->isDropAllowed(pEvent); 742 /* Else we should make sure machine is accessible: */ 743 if (!accessible()) 744 return false; 745 /* Else we should try to cast mime to known classes: */ 746 if (pMimeData->hasFormat(UIChooserItemMachine::className())) 747 { 748 /* Make sure passed item id is not ours: */ 749 const UIChooserItemMimeData *pCastedMimeData = qobject_cast<const UIChooserItemMimeData*>(pMimeData); 750 AssertMsg(pCastedMimeData, ("Can't cast passed mime-data to UIChooserItemMimeData!")); 751 UIChooserItem *pItem = pCastedMimeData->item(); 752 UIChooserItemMachine *pMachineItem = pItem->toMachineItem(); 753 /* Make sure passed machine is mutable: */ 754 if (pMachineItem->isLockedMachine()) 755 return false; 756 return pMachineItem->id() != id(); 757 } 758 /* That was invalid mime: */ 383 bool UIChooserItemGlobal::isDropAllowed(QGraphicsSceneDragDropEvent *, DragToken) const 384 { 385 /* No drops at all: */ 759 386 return false; 760 387 } 761 388 762 void UIChooserItemMachine::processDrop(QGraphicsSceneDragDropEvent *pEvent, UIChooserItem *pFromWho, DragToken where) 763 { 764 /* Get mime: */ 765 const QMimeData *pMime = pEvent->mimeData(); 766 /* Make sure this handler called by this item (not by children): */ 767 AssertMsg(!pFromWho && where == DragToken_Off, ("Machine graphics item do NOT support children!")); 768 Q_UNUSED(pFromWho); 769 Q_UNUSED(where); 770 if (pMime->hasFormat(UIChooserItemMachine::className())) 771 { 772 switch (pEvent->proposedAction()) 773 { 774 case Qt::MoveAction: 775 case Qt::CopyAction: 776 { 777 /* Remember scene: */ 778 UIChooserModel *pModel = model(); 779 780 /* Get passed item: */ 781 const UIChooserItemMimeData *pCastedMime = qobject_cast<const UIChooserItemMimeData*>(pMime); 782 AssertMsg(pCastedMime, ("Can't cast passed mime-data to UIChooserItemMimeData!")); 783 UIChooserItem *pItem = pCastedMime->item(); 784 785 /* Group passed item with current item into the new group: */ 786 UIChooserItemGroup *pNewGroupItem = new UIChooserItemGroup(parentItem(), 787 UIChooserModel::uniqueGroupName(parentItem()), 788 true); 789 new UIChooserItemMachine(pNewGroupItem, this); 790 new UIChooserItemMachine(pNewGroupItem, pItem->toMachineItem()); 791 792 /* If proposed action is 'move': */ 793 if (pEvent->proposedAction() == Qt::MoveAction) 794 { 795 /* Delete passed item: */ 796 delete pItem; 797 } 798 /* Delete this item: */ 799 delete this; 800 801 /* Update model: */ 802 pModel->cleanupGroupTree(); 803 pModel->updateNavigation(); 804 pModel->updateLayout(); 805 pModel->setCurrentItem(pNewGroupItem); 806 pModel->saveGroupSettings(); 807 break; 808 } 809 default: 810 break; 811 } 812 } 813 } 814 815 void UIChooserItemMachine::resetDragToken() 816 { 817 /* Reset drag token for this item: */ 818 if (dragTokenPlace() != DragToken_Off) 819 { 820 setDragTokenPlace(DragToken_Off); 821 update(); 822 } 823 } 824 825 QMimeData* UIChooserItemMachine::createMimeData() 826 { 827 return new UIChooserItemMimeData(this); 828 } 829 830 void UIChooserItemMachine::showEvent(QShowEvent *pEvent) 389 void UIChooserItemGlobal::processDrop(QGraphicsSceneDragDropEvent *, UIChooserItem *, DragToken) 390 { 391 /* Nothing to process: */ 392 } 393 394 void UIChooserItemGlobal::resetDragToken() 395 { 396 /* Nothing to process: */ 397 } 398 399 QMimeData *UIChooserItemGlobal::createMimeData() 400 { 401 /* Nothing to return: */ 402 return 0; 403 } 404 405 void UIChooserItemGlobal::showEvent(QShowEvent *pEvent) 831 406 { 832 407 /* Call to base-class: */ 833 408 UIChooserItem::showEvent(pEvent); 834 409 835 /* Recache and update pixmaps: */ 836 recachePixmap(); 837 updatePixmaps(); 838 } 839 840 void UIChooserItemMachine::resizeEvent(QGraphicsSceneResizeEvent *pEvent) 410 /* Update pixmaps: */ 411 updatePixmap(); 412 } 413 414 void UIChooserItemGlobal::resizeEvent(QGraphicsSceneResizeEvent *pEvent) 841 415 { 842 416 /* Call to base-class: */ … … 844 418 845 419 /* What is the new geometry? */ 846 QRectF newGeometry = geometry();420 const QRectF newGeometry = geometry(); 847 421 848 422 /* Should we update visible name? */ 849 423 if (previousGeometry().width() != newGeometry.width()) 850 update FirstRowMaximumWidth();424 updateMaximumNameWidth(); 851 425 852 426 /* Remember the new geometry: */ … … 854 428 } 855 429 856 void UIChooserItem Machine::mousePressEvent(QGraphicsSceneMouseEvent *pEvent)430 void UIChooserItemGlobal::mousePressEvent(QGraphicsSceneMouseEvent *pEvent) 857 431 { 858 432 /* Call to base-class: */ 859 433 UIChooserItem::mousePressEvent(pEvent); 860 /* No drag for inaccessible: */ 861 if (!accessible()) 862 pEvent->ignore(); 863 } 864 865 void UIChooserItemMachine::paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, QWidget* /* pWidget = 0 */) 434 /* No drag at all: */ 435 pEvent->ignore(); 436 } 437 438 void UIChooserItemGlobal::paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, QWidget * /* pWidget = 0 */) 866 439 { 867 440 /* Setup: */ … … 875 448 } 876 449 877 void UIChooserItem Machine::paintDecorations(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption)450 void UIChooserItemGlobal::paintDecorations(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption) 878 451 { 879 452 /* Prepare variables: */ … … 887 460 } 888 461 889 void UIChooserItem Machine::paintBackground(QPainter *pPainter, const QRect &rect)462 void UIChooserItemGlobal::paintBackground(QPainter *pPainter, const QRect &rect) 890 463 { 891 464 /* Save painter: */ … … 893 466 894 467 /* Prepare color: */ 895 QPalette pal = palette();468 const QPalette pal = palette(); 896 469 897 470 /* Selection background: */ … … 918 491 } 919 492 920 /* Paint drag token UP? */921 if (dragTokenPlace() != DragToken_Off)922 {923 /* Window color: */924 QColor base = pal.color(QPalette::Active, model()->currentItems().contains(this) ?925 QPalette::Highlight : QPalette::Window);926 QLinearGradient dragTokenGradient;927 QRect dragTokenRect = rect;928 if (dragTokenPlace() == DragToken_Up)929 {930 dragTokenRect.setHeight(5);931 dragTokenGradient.setStart(dragTokenRect.bottomLeft());932 dragTokenGradient.setFinalStop(dragTokenRect.topLeft());933 }934 else if (dragTokenPlace() == DragToken_Down)935 {936 dragTokenRect.setTopLeft(dragTokenRect.bottomLeft() - QPoint(0, 5));937 dragTokenGradient.setStart(dragTokenRect.topLeft());938 dragTokenGradient.setFinalStop(dragTokenRect.bottomLeft());939 }940 dragTokenGradient.setColorAt(0, base.darker(dragTokenDarkness()));941 dragTokenGradient.setColorAt(1, base.darker(dragTokenDarkness() + 40));942 pPainter->fillRect(dragTokenRect, dragTokenGradient);943 }944 945 493 /* Restore painter: */ 946 494 pPainter->restore(); 947 495 } 948 496 949 void UIChooserItem Machine::paintFrameRectangle(QPainter *pPainter, const QRect &rect)497 void UIChooserItemGlobal::paintFrameRectangle(QPainter *pPainter, const QRect &rect) 950 498 { 951 499 /* Only chosen and/or hovered item should have a frame: */ … … 955 503 /* Simple frame: */ 956 504 pPainter->save(); 957 QPalette pal = palette();505 const QPalette pal = palette(); 958 506 QColor strokeColor = pal.color(QPalette::Active, 959 507 model()->currentItems().contains(this) ? … … 964 512 } 965 513 966 void UIChooserItem Machine::paintMachineInfo(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption)514 void UIChooserItemGlobal::paintMachineInfo(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption) 967 515 { 968 516 /* Prepare variables: */ 969 QRect fullRect = pOption->rect; 970 int iFullHeight = fullRect.height(); 971 int iMargin = data(MachineItemData_Margin).toInt(); 972 int iMajorSpacing = data(MachineItemData_MajorSpacing).toInt(); 973 int iMinorSpacing = data(MachineItemData_MinorSpacing).toInt(); 974 int iMachineItemTextSpacing = data(MachineItemData_TextSpacing).toInt(); 517 const QRect fullRect = pOption->rect; 518 const int iFullHeight = fullRect.height(); 519 const int iMargin = data(GlobalItemData_Margin).toInt(); 520 const int iSpacing = data(GlobalItemData_Spacing).toInt(); 975 521 976 522 /* Selected item foreground: */ 977 523 if (model()->currentItems().contains(this)) 978 524 { 979 QPalette pal = palette();525 const QPalette pal = palette(); 980 526 pPainter->setPen(pal.color(QPalette::HighlightedText)); 981 527 } … … 984 530 { 985 531 /* Prepare color: */ 986 QPalette pal = palette();987 QColor highlight = pal.color(QPalette::Active, QPalette::Highlight);988 QColor hhl = highlight.lighter(m_iHoverHighlightLightness);532 const QPalette pal = palette(); 533 const QColor highlight = pal.color(QPalette::Active, QPalette::Highlight); 534 const QColor hhl = highlight.lighter(m_iHoverHighlightLightness); 989 535 if (hhl.value() - hhl.saturation() > 0) 990 536 pPainter->setPen(pal.color(QPalette::Active, QPalette::Text)); … … 999 545 { 1000 546 /* Prepare variables: */ 1001 int iMachinePixmapX = iLeftColumnIndent; 1002 int iMachinePixmapY = (iFullHeight - m_pixmap.height() / m_pixmap.devicePixelRatio()) / 2; 547 const int iGlobalPixmapX = iLeftColumnIndent; 548 const int iGlobalPixmapY = (iFullHeight - m_pixmap.height() / m_pixmap.devicePixelRatio()) / 2; 549 1003 550 /* Paint pixmap: */ 1004 551 paintPixmap(/* Painter: */ 1005 552 pPainter, 1006 553 /* Point to paint in: */ 1007 QPoint(i MachinePixmapX, iMachinePixmapY),554 QPoint(iGlobalPixmapX, iGlobalPixmapY), 1008 555 /* Pixmap to paint: */ 1009 556 m_pixmap); … … 1011 558 1012 559 /* Calculate indents: */ 1013 int iRightColumnIndent = iLeftColumnIndent +1014 m_pixmapSize.width() +1015 iMajorSpacing;560 const int iRightColumnIndent = iLeftColumnIndent + 561 m_pixmapSize.width() + 562 iSpacing; 1016 563 1017 564 /* Paint right column: */ 1018 565 { 1019 /* Calculate indents: */ 1020 int iTopLineHeight = qMax(m_visibleNameSize.height(), m_visibleSnapshotNameSize.height()); 1021 int iBottomLineHeight = qMax(m_statePixmapSize.height(), m_stateTextSize.height()); 1022 int iRightColumnHeight = iTopLineHeight + iMachineItemTextSpacing + iBottomLineHeight; 1023 int iTopLineIndent = (iFullHeight - iRightColumnHeight) / 2; 1024 1025 /* Paint top line: */ 1026 { 1027 /* Paint left element: */ 1028 { 1029 /* Prepare variables: */ 1030 int iNameX = iRightColumnIndent; 1031 int iNameY = iTopLineIndent; 1032 /* Paint name: */ 1033 paintText(/* Painter: */ 1034 pPainter, 1035 /* Point to paint in: */ 1036 QPoint(iNameX, iNameY), 1037 /* Font to paint text: */ 1038 m_nameFont, 1039 /* Paint device: */ 1040 model()->paintDevice(), 1041 /* Text to paint: */ 1042 m_strVisibleName); 1043 } 1044 1045 /* Calculate indents: */ 1046 int iSnapshotNameIndent = iRightColumnIndent + 1047 m_visibleNameSize.width() + 1048 iMinorSpacing; 1049 1050 /* Paint right element: */ 1051 if (!snapshotName().isEmpty()) 1052 { 1053 /* Prepare variables: */ 1054 int iSnapshotNameX = iSnapshotNameIndent; 1055 int iSnapshotNameY = iTopLineIndent; 1056 /* Paint snapshot-name: */ 1057 paintText(/* Painter: */ 1058 pPainter, 1059 /* Point to paint in: */ 1060 QPoint(iSnapshotNameX, iSnapshotNameY), 1061 /* Font to paint text: */ 1062 m_snapshotNameFont, 1063 /* Paint device: */ 1064 model()->paintDevice(), 1065 /* Text to paint: */ 1066 m_strVisibleSnapshotName); 1067 } 1068 } 1069 1070 /* Calculate indents: */ 1071 int iBottomLineIndent = iTopLineIndent + iTopLineHeight; 1072 1073 /* Paint bottom line: */ 1074 { 1075 /* Paint left element: */ 1076 { 1077 /* Prepare variables: */ 1078 int iMachineStatePixmapX = iRightColumnIndent; 1079 int iMachineStatePixmapY = iBottomLineIndent; 1080 /* Paint state pixmap: */ 1081 paintPixmap(/* Painter: */ 1082 pPainter, 1083 /* Point to paint in: */ 1084 QPoint(iMachineStatePixmapX, iMachineStatePixmapY), 1085 /* Pixmap to paint: */ 1086 m_statePixmap); 1087 } 1088 1089 /* Calculate indents: */ 1090 int iMachineStateTextIndent = iRightColumnIndent + 1091 m_statePixmapSize.width() + 1092 iMinorSpacing; 1093 1094 /* Paint right element: */ 1095 { 1096 /* Prepare variables: */ 1097 int iMachineStateTextX = iMachineStateTextIndent; 1098 int iMachineStateTextY = iBottomLineIndent; 1099 /* Paint state text: */ 1100 paintText(/* Painter: */ 1101 pPainter, 1102 /* Point to paint in: */ 1103 QPoint(iMachineStateTextX, iMachineStateTextY), 1104 /* Font to paint text: */ 1105 m_stateTextFont, 1106 /* Paint device: */ 1107 model()->paintDevice(), 1108 /* Text to paint: */ 1109 m_strStateText); 1110 } 1111 } 1112 } 1113 1114 /* Tool-bar: */ 1115 if (m_pToolBar) 1116 { 1117 /* Show/hide tool-bar: */ 1118 if (isHovered()) 1119 { 1120 if (!m_pToolBar->isVisible()) 1121 m_pToolBar->show(); 1122 } 1123 else 1124 { 1125 if (m_pToolBar->isVisible()) 1126 m_pToolBar->hide(); 1127 } 1128 } 1129 } 1130 1131 void UIChooserItemMachine::prepare() 1132 { 1133 /* Tool-bar/buttons: */ 1134 m_pToolBar = 0; 1135 m_pSettingsButton = 0; 1136 m_pStartButton = 0; 1137 m_pPauseButton = 0; 1138 m_pCloseButton = 0; 1139 566 /* Prepare variables: */ 567 const int iNameX = iRightColumnIndent; 568 const int iNameY = (iFullHeight - m_visibleNameSize.height()) / 2; 569 570 /* Paint name: */ 571 paintText(/* Painter: */ 572 pPainter, 573 /* Point to paint in: */ 574 QPoint(iNameX, iNameY), 575 /* Font to paint text: */ 576 m_nameFont, 577 /* Paint device: */ 578 model()->paintDevice(), 579 /* Text to paint: */ 580 m_strVisibleName); 581 } 582 } 583 584 void UIChooserItemGlobal::prepare() 585 { 1140 586 /* Colors: */ 1141 587 #ifdef VBOX_WS_MAC … … 1152 598 m_nameFont = font(); 1153 599 m_nameFont.setWeight(QFont::Bold); 1154 m_snapshotNameFont = font();1155 m_stateTextFont = font();1156 600 1157 601 /* Sizes: */ 1158 m_iFirstRowMaximumWidth = 0;1159 602 m_iMinimumNameWidth = 0; 1160 603 m_iMaximumNameWidth = 0; 1161 m_iMinimumSnapshotNameWidth = 0; 1162 m_iMaximumSnapshotNameWidth = 0; 1163 1164 /* Other things disabled for now: */ 1165 return; 1166 1167 #if 0 /* disabled for now */ 1168 /* Create tool-bar: */ 1169 m_pToolBar = new UIGraphicsToolBar(this, 2, 2); 1170 1171 /* Create buttons: */ 1172 m_pSettingsButton = new UIGraphicsZoomButton(m_pToolBar, 1173 data(MachineItemData_SettingsButtonPixmap).value<QIcon>(), 1174 UIGraphicsZoomDirection_Top | UIGraphicsZoomDirection_Left); 1175 m_pSettingsButton->setIndent(m_pToolBar->toolBarMargin() - 1); 1176 m_pToolBar->insertItem(m_pSettingsButton, 0, 0); 1177 1178 m_pStartButton = new UIGraphicsZoomButton(m_pToolBar, 1179 data(MachineItemData_StartButtonPixmap).value<QIcon>(), 1180 UIGraphicsZoomDirection_Top | UIGraphicsZoomDirection_Right); 1181 m_pStartButton->setIndent(m_pToolBar->toolBarMargin() - 1); 1182 m_pToolBar->insertItem(m_pStartButton, 0, 1); 1183 1184 m_pPauseButton = new UIGraphicsZoomButton(m_pToolBar, 1185 data(MachineItemData_PauseButtonPixmap).value<QIcon>(), 1186 UIGraphicsZoomDirection_Bottom | UIGraphicsZoomDirection_Left); 1187 m_pPauseButton->setIndent(m_pToolBar->toolBarMargin() - 1); 1188 m_pToolBar->insertItem(m_pPauseButton, 1, 0); 1189 1190 m_pCloseButton = new UIGraphicsZoomButton(m_pToolBar, 1191 data(MachineItemData_CloseButtonPixmap).value<QIcon>(), 1192 UIGraphicsZoomDirection_Bottom | UIGraphicsZoomDirection_Right); 1193 m_pCloseButton->setIndent(m_pToolBar->toolBarMargin() - 1); 1194 m_pToolBar->insertItem(m_pCloseButton, 1, 1); 1195 1196 connect(m_pSettingsButton, SIGNAL(sigButtonClicked()), 1197 actionPool()->action(UIActionIndexST_M_Machine_S_Settings), SLOT(trigger()), 1198 Qt::QueuedConnection); 1199 connect(m_pStartButton, SIGNAL(sigButtonClicked()), 1200 actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow), SLOT(trigger()), 1201 Qt::QueuedConnection); 1202 connect(m_pPauseButton, SIGNAL(sigButtonClicked()), 1203 actionPool()->action(UIActionIndexST_M_Machine_T_Pause), SLOT(trigger()), 1204 Qt::QueuedConnection); 1205 connect(m_pCloseButton, SIGNAL(sigButtonClicked()), 1206 actionPool()->action(UIActionIndexST_M_Machine_M_Close_S_PowerOff), SLOT(trigger()), 1207 Qt::QueuedConnection); 1208 #endif /* disabled for now */ 1209 } 1210 1211 /* static */ 1212 bool UIChooserItemMachine::contains(const QList<UIChooserItemMachine*> &list, UIChooserItemMachine *pItem) 1213 { 1214 /* Check if passed list contains passed machine-item id: */ 1215 foreach (UIChooserItemMachine *pIteratedItem, list) 1216 if (pIteratedItem->id() == pItem->id()) 1217 return true; 1218 /* Found nothing? */ 1219 return false; 1220 } 1221 604 } -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGlobal.h
r73555 r73600 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UIChooserItem Machineclass declaration.3 * VBox Qt GUI - UIChooserItemGlobal class declaration. 4 4 */ 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 Machine_h__19 #define __UIChooserItem Machine_h__18 #ifndef __UIChooserItemGlobal_h__ 19 #define __UIChooserItemGlobal_h__ 20 20 21 21 /* GUI includes: */ 22 #include "UIVirtualMachineItem.h"23 22 #include "UIChooserItem.h" 24 23 25 24 /* Forward declarations: */ 26 class CMachine;27 25 class UIGraphicsToolBar; 28 26 class UIGraphicsZoomButton; 29 27 30 28 /* Machine-item enumeration flags: */ 31 enum UIChooserItem MachineEnumerationFlag29 enum UIChooserItemGlobalEnumerationFlag 32 30 { 33 UIChooserItem MachineEnumerationFlag_Unique = RT_BIT(0),34 UIChooserItem MachineEnumerationFlag_Inaccessible = RT_BIT(1)31 UIChooserItemGlobalEnumerationFlag_Unique = RT_BIT(0), 32 UIChooserItemGlobalEnumerationFlag_Inaccessible = RT_BIT(1) 35 33 }; 36 34 37 /* Graphics machineitem35 /* Graphics global-item 38 36 * for graphics selector model/view architecture: */ 39 class UIChooserItem Machine : public UIChooserItem, public UIVirtualMachineItem37 class UIChooserItemGlobal : public UIChooserItem 40 38 { 41 39 Q_OBJECT; … … 43 41 public: 44 42 45 /* Class-name used for drag&drop mime-data format: */46 static QString className();47 48 43 /* Graphics-item type: */ 49 enum { Type = UIChooserItemType_ Machine};44 enum { Type = UIChooserItemType_Global }; 50 45 int type() const { return Type; } 51 46 52 47 /* Constructor (new item): */ 53 UIChooserItem Machine(UIChooserItem *pParent, const CMachine &machine, int iPosition = -1);48 UIChooserItemGlobal(UIChooserItem *pParent, int iPosition = -1); 54 49 /* Constructor (new item copy): */ 55 UIChooserItem Machine(UIChooserItem *pParent, UIChooserItemMachine*pCopyFrom, int iPosition = -1);50 UIChooserItemGlobal(UIChooserItem *pParent, UIChooserItemGlobal *pCopyFrom, int iPosition = -1); 56 51 /* Destructor: */ 57 ~UIChooserItem Machine();52 ~UIChooserItemGlobal(); 58 53 59 54 /* API: Basic stuff: */ … … 62 57 QString fullName() const; 63 58 QString definition() const; 64 bool isLockedMachine() const;65 66 /* API: Machine-item enumeration stuff: */67 static void enumerateMachineItems(const QList<UIChooserItem*> &il,68 QList<UIChooserItemMachine*> &ol,69 int iEnumerationFlags = 0);70 59 71 60 private slots: … … 77 66 78 67 /* Data enumerator: */ 79 enum MachineItemData68 enum GlobalItemData 80 69 { 81 70 /* Layout hints: */ 82 MachineItemData_Margin, 83 MachineItemData_MajorSpacing, 84 MachineItemData_MinorSpacing, 85 MachineItemData_TextSpacing, 86 /* Pixmaps: */ 87 MachineItemData_SettingsButtonPixmap, 88 MachineItemData_StartButtonPixmap, 89 MachineItemData_PauseButtonPixmap, 90 MachineItemData_CloseButtonPixmap, 91 /* Sizes: */ 92 MachineItemData_ToolBarSize 71 GlobalItemData_Margin, 72 GlobalItemData_Spacing, 93 73 }; 94 74 … … 97 77 98 78 /* Helpers: Update stuff: */ 99 void updatePixmaps();100 79 void updatePixmap(); 101 void updateStatePixmap();102 void updateName();103 void updateSnapshotName();104 void updateFirstRowMaximumWidth();105 80 void updateMinimumNameWidth(); 106 void updateMinimumSnapshotNameWidth();107 81 void updateMaximumNameWidth(); 108 void updateMaximumSnapshotNameWidth();109 82 void updateVisibleName(); 110 void updateVisibleSnapshotName();111 void updateStateText();112 83 113 84 /* Helper: Translate stuff: */ … … 127 98 void updateAll(const QString &strId); 128 99 void removeAll(const QString &strId); 129 UIChooserItem *searchForItem(const QString &strSearchTag, int iItemSearchFlags);130 UIChooserItem Machine*firstMachineItem();100 UIChooserItem *searchForItem(const QString &strSearchTag, int iItemSearchFlags); 101 UIChooserItem *firstMachineItem(); 131 102 void sortItems(); 132 103 133 104 /* Helpers: Layout stuff: */ 134 void updateLayout() ;105 void updateLayout() {} 135 106 int minimumWidthHint() const; 136 107 int minimumHeightHint() const; … … 142 113 void processDrop(QGraphicsSceneDragDropEvent *pEvent, UIChooserItem *pFromWho, DragToken where); 143 114 void resetDragToken(); 144 QMimeData *createMimeData();115 QMimeData *createMimeData(); 145 116 146 117 /** Handles show @a pEvent. */ … … 164 135 165 136 /* Helper: Machine-item enumeration stuff: */ 166 static bool contains(const QList<UIChooserItem Machine*> &list,167 UIChooserItem Machine*pItem);137 static bool contains(const QList<UIChooserItemGlobal*> &list, 138 UIChooserItemGlobal *pItem); 168 139 169 140 /* Variables: */ 170 UIGraphicsToolBar *m_pToolBar;171 UIGraphicsZoomButton *m_pSettingsButton;172 UIGraphicsZoomButton *m_pStartButton;173 UIGraphicsZoomButton *m_pPauseButton;174 UIGraphicsZoomButton *m_pCloseButton;175 141 int m_iHighlightLightness; 176 142 int m_iHoverLightness; … … 178 144 /* Cached values: */ 179 145 QFont m_nameFont; 180 QFont m_snapshotNameFont;181 QFont m_stateTextFont;182 146 QPixmap m_pixmap; 183 QPixmap m_statePixmap;184 147 QString m_strName; 185 148 QString m_strDescription; 186 149 QString m_strVisibleName; 187 QString m_strSnapshotName;188 QString m_strVisibleSnapshotName;189 QString m_strStateText;190 150 QSize m_pixmapSize; 191 QSize m_statePixmapSize;192 151 QSize m_visibleNameSize; 193 QSize m_visibleSnapshotNameSize;194 QSize m_stateTextSize;195 int m_iFirstRowMaximumWidth;196 152 int m_iMinimumNameWidth; 197 153 int m_iMaximumNameWidth; 198 int m_iMinimumSnapshotNameWidth;199 int m_iMaximumSnapshotNameWidth;200 154 }; 201 155 202 #endif /* __UIChooserItemMachine_h__ */ 203 156 #endif /* __UIChooserItemGlobal_h__ */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGroup.cpp
r73424 r73600 31 31 /* GUI includes: */ 32 32 # include "UIChooserItemGroup.h" 33 # include "UIChooserItemGlobal.h" 33 34 # include "UIChooserItemMachine.h" 34 35 # include "UIChooserModel.h" … … 470 471 foreach (UIChooserItem *pGroupItem, pFrom->items(UIChooserItemType_Group)) 471 472 new UIChooserItemGroup(pTo, pGroupItem->toGroupItem()); 473 /* Copy global-items: */ 474 foreach (UIChooserItem *pGlobalItem, pFrom->items(UIChooserItemType_Global)) 475 new UIChooserItemGlobal(pTo, pGlobalItem->toGlobalItem()); 472 476 /* Copy machine-items: */ 473 477 foreach (UIChooserItem *pMachineItem, pFrom->items(UIChooserItemType_Machine)) … … 807 811 break; 808 812 } 813 case UIChooserItemType_Global: 814 { 815 AssertMsg(!m_globalItems.contains(pItem), ("Global-item already added!")); 816 if (iPosition < 0 || iPosition >= m_globalItems.size()) 817 m_globalItems.append(pItem); 818 else 819 m_globalItems.insert(iPosition, pItem); 820 scene()->addItem(pItem); 821 break; 822 } 809 823 case UIChooserItemType_Machine: 810 824 { … … 842 856 break; 843 857 } 858 case UIChooserItemType_Global: 859 { 860 AssertMsg(m_globalItems.contains(pItem), ("Global-item was not found!")); 861 scene()->removeItem(pItem); 862 m_globalItems.removeAt(m_globalItems.indexOf(pItem)); 863 break; 864 } 844 865 case UIChooserItemType_Machine: 845 866 { … … 868 889 { 869 890 case UIChooserItemType_Group: m_groupItems = items; break; 891 case UIChooserItemType_Global: m_globalItems = items; break; 870 892 case UIChooserItemType_Machine: m_machineItems = items; break; 871 893 default: AssertMsgFailed(("Invalid item type!")); break; … … 882 904 switch (type) 883 905 { 884 case UIChooserItemType_Any: return items(UIChooserItemType_G roup) + items(UIChooserItemType_Machine);906 case UIChooserItemType_Any: return items(UIChooserItemType_Global) + items(UIChooserItemType_Group) + items(UIChooserItemType_Machine); 885 907 case UIChooserItemType_Group: return m_groupItems; 908 case UIChooserItemType_Global: return m_globalItems; 886 909 case UIChooserItemType_Machine: return m_machineItems; 887 910 default: break; … … 895 918 { 896 919 case UIChooserItemType_Any: 897 return hasItems(UIChooserItemType_G roup) || hasItems(UIChooserItemType_Machine);920 return hasItems(UIChooserItemType_Global) || hasItems(UIChooserItemType_Group) || hasItems(UIChooserItemType_Machine); 898 921 case UIChooserItemType_Group: 899 922 return !m_groupItems.isEmpty(); 923 case UIChooserItemType_Global: 924 return !m_globalItems.isEmpty(); 900 925 case UIChooserItemType_Machine: 901 926 return !m_machineItems.isEmpty(); … … 911 936 { 912 937 clearItems(UIChooserItemType_Group); 938 clearItems(UIChooserItemType_Global); 913 939 clearItems(UIChooserItemType_Machine); 914 940 break; … … 918 944 while (!m_groupItems.isEmpty()) { delete m_groupItems.last(); } 919 945 AssertMsg(m_groupItems.isEmpty(), ("Group items cleanup failed!")); 946 break; 947 } 948 case UIChooserItemType_Global: 949 { 950 while (!m_globalItems.isEmpty()) { delete m_globalItems.last(); } 951 AssertMsg(m_globalItems.isEmpty(), ("Global items cleanup failed!")); 920 952 break; 921 953 } … … 971 1003 /* Search among all the children, but machines first: */ 972 1004 foreach (UIChooserItem *pItem, items(UIChooserItemType_Machine)) 1005 if (UIChooserItem *pFoundItem = pItem->searchForItem(strSearchTag, iItemSearchFlags)) 1006 return pFoundItem; 1007 foreach (UIChooserItem *pItem, items(UIChooserItemType_Global)) 973 1008 if (UIChooserItem *pFoundItem = pItem->searchForItem(strSearchTag, iItemSearchFlags)) 974 1009 return pFoundItem; … … 981 1016 } 982 1017 983 UIChooserItem Machine*UIChooserItemGroup::firstMachineItem()1018 UIChooserItem *UIChooserItemGroup::firstMachineItem() 984 1019 { 985 1020 /* If this group-item have at least one machine-item: */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGroup.h
r73424 r73600 145 145 void updateAll(const QString &strId); 146 146 void removeAll(const QString &strId); 147 UIChooserItem *searchForItem(const QString &strSearchTag, int iItemSearchFlags);148 UIChooserItem Machine*firstMachineItem();147 UIChooserItem *searchForItem(const QString &strSearchTag, int iItemSearchFlags); 148 UIChooserItem *firstMachineItem(); 149 149 void sortItems(); 150 150 … … 203 203 QGraphicsProxyWidget *m_pNameEditor; 204 204 QList<UIChooserItem*> m_groupItems; 205 QList<UIChooserItem*> m_globalItems; 205 206 QList<UIChooserItem*> m_machineItems; 206 207 int m_iAdditionalHeight; -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemMachine.cpp
r73424 r73600 605 605 } 606 606 607 UIChooserItem Machine*UIChooserItemMachine::firstMachineItem()607 UIChooserItem *UIChooserItemMachine::firstMachineItem() 608 608 { 609 609 return this; -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemMachine.h
r73424 r73600 35 35 }; 36 36 37 /* Graphics machine 37 /* Graphics machine-item 38 38 * for graphics selector model/view architecture: */ 39 39 class UIChooserItemMachine : public UIChooserItem, public UIVirtualMachineItem … … 127 127 void updateAll(const QString &strId); 128 128 void removeAll(const QString &strId); 129 UIChooserItem *searchForItem(const QString &strSearchTag, int iItemSearchFlags);130 UIChooserItem Machine*firstMachineItem();129 UIChooserItem *searchForItem(const QString &strSearchTag, int iItemSearchFlags); 130 UIChooserItem *firstMachineItem(); 131 131 void sortItems(); 132 132 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp
r73492 r73600 37 37 # include "UIChooserModel.h" 38 38 # include "UIChooserItemGroup.h" 39 # include "UIChooserItemGlobal.h" 39 40 # include "UIChooserItemMachine.h" 40 41 # include "UIExtraDataDefs.h" … … 207 208 } 208 209 210 bool UIChooserModel::isGlobalItemSelected() const 211 { 212 return currentItem() && currentItem()->type() == UIChooserItemType_Global; 213 } 214 215 bool UIChooserModel::isMachineItemSelected() const 216 { 217 return currentItem() && currentItem()->type() == UIChooserItemType_Machine; 218 } 219 209 220 UIVirtualMachineItem* UIChooserModel::currentMachineItem() const 210 221 { 211 222 /* Return first machine-item of the current-item: */ 212 return currentItem() ? currentItem()->firstMachineItem() : 0; 223 return currentItem() && currentItem()->firstMachineItem() 224 ? currentItem()->firstMachineItem()->toMachineItem() 225 : 0; 213 226 } 214 227 … … 218 231 QList<UIChooserItemMachine*> currentMachineItemList; 219 232 UIChooserItemMachine::enumerateMachineItems(currentItems(), currentMachineItemList, 220 233 UIChooserItemMachineEnumerationFlag_Unique); 221 234 222 235 /* Reintegrate machine-items into valid format: */ … … 982 995 /* Add name to busy: */ 983 996 busyMachineNames << pItem->name(); 984 /* Copy or move machine 997 /* Copy or move machine-item: */ 985 998 new UIChooserItemMachine(pNewGroupItem, pItem->toMachineItem()); 986 999 delete pItem; … … 1451 1464 navigationItems << createNavigationList(pGroupItem); 1452 1465 } 1466 /* Iterate over all the global-items: */ 1467 foreach (UIChooserItem *pGlobalItem, pItem->items(UIChooserItemType_Global)) 1468 navigationItems << pGlobalItem; 1453 1469 /* Iterate over all the machine-items: */ 1454 1470 foreach (UIChooserItem *pMachineItem, pItem->items(UIChooserItemType_Machine)) … … 1750 1766 void UIChooserModel::loadGroupTree() 1751 1767 { 1768 /* Create Global item: */ 1769 createGlobalItem(mainRoot()); 1770 1752 1771 /* Add all the approved machines we have into the group-tree: */ 1753 1772 LogRelFlow(("UIChooserModel: Loading VMs...\n")); … … 1960 1979 void UIChooserModel::createMachineItem(const CMachine &machine, UIChooserItem *pParentItem) 1961 1980 { 1962 /* Create corresponding item: */ 1963 new UIChooserItemMachine(/* Parent item and corresponding machine: */ 1964 pParentItem, machine, 1965 /* Which position new group-item should be placed in? */ 1966 getDesiredPosition(pParentItem, UIChooserItemType_Machine, machine.GetId())); 1981 /* Create machine-item: */ 1982 new UIChooserItemMachine(pParentItem, machine, getDesiredPosition(pParentItem, UIChooserItemType_Machine, machine.GetId())); 1983 } 1984 1985 void UIChooserModel::createGlobalItem(UIChooserItem *pParentItem) 1986 { 1987 /* Create global-item: */ 1988 new UIChooserItemGlobal(pParentItem, 0); 1967 1989 } 1968 1990 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.h
r73424 r73600 110 110 111 111 /* API: Current-item stuff: */ 112 UIVirtualMachineItem* currentMachineItem() const; 112 bool isGlobalItemSelected() const; 113 bool isMachineItemSelected() const; 114 UIVirtualMachineItem *currentMachineItem() const; 113 115 QList<UIVirtualMachineItem*> currentMachineItems() const; 114 116 UIChooserItem* currentItem() const; … … 265 267 int positionFromDefinitions(UIChooserItem *pParentItem, UIChooserItemType type, const QString &strName); 266 268 void createMachineItem(const CMachine &machine, UIChooserItem *pParentItem); 269 void createGlobalItem(UIChooserItem *pParentItem); 267 270 268 271 /* Helpers: Saving stuff: */
Note:
See TracChangeset
for help on using the changeset viewer.