Changeset 77627 in vbox
- Timestamp:
- Mar 9, 2019 2:45:05 PM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGroup.cpp
r77620 r77627 44 44 UIChooserItemGroup::UIChooserItemGroup(QGraphicsScene *pScene) 45 45 : UIChooserItem(0, false /* favorite? */) 46 , m_pScene(pScene) 47 , m_pItemToCopy(0) 48 , m_iPosition(0) 46 49 , m_fClosed(false) 47 50 , m_iAdditionalHeight(0) … … 60 63 , m_pLayoutMachine(0) 61 64 { 62 /* Prepare: */63 65 prepare(); 64 65 /* Add item to the scene: */66 AssertMsg(pScene, ("Incorrect scene passed!"));67 pScene->addItem(this);68 69 /* Apply language settings: */70 retranslateUi();71 72 /* Prepare connections: */73 connect(this, &UIChooserItemGroup::sigMinimumWidthHintChanged,74 model(), &UIChooserModel::sigRootItemMinimumWidthHintChanged);75 66 } 76 67 … … 80 71 int iPosition /* = -1 */) 81 72 : UIChooserItem(pParent, pParent->isFavorite()) 73 , m_pScene(0) 74 , m_pItemToCopy(0) 75 , m_iPosition(iPosition) 82 76 , m_strName(strName) 83 77 , m_fClosed(!fOpened) … … 97 91 , m_pLayoutMachine(0) 98 92 { 99 /* Prepare: */100 93 prepare(); 101 102 /* Add item to the parent: */103 AssertMsg(parentItem(), ("Incorrect parent passed!"));104 parentItem()->addItem(this, false, iPosition);105 connect(this, &UIChooserItemGroup::sigToggleStarted,106 model(), &UIChooserModel::sigToggleStarted);107 connect(this, &UIChooserItemGroup::sigToggleFinished,108 model(), &UIChooserModel::sigToggleFinished,109 Qt::QueuedConnection);110 connect(gpManager, &UIVirtualBoxManager::sigWindowRemapped,111 this, &UIChooserItemGroup::sltHandleWindowRemapped);112 113 /* Apply language settings: */114 retranslateUi();115 116 /* Init: */117 updatePixmaps();118 updateItemCountInfo();119 updateVisibleName();120 updateToolTip();121 122 /* Prepare connections: */123 connect(this, &UIChooserItemGroup::sigMinimumWidthHintChanged,124 model(), &UIChooserModel::sigRootItemMinimumWidthHintChanged);125 94 } 126 95 … … 129 98 int iPosition /* = -1 */) 130 99 : UIChooserItem(pParent, pParent->isFavorite()) 100 , m_pScene(0) 101 , m_pItemToCopy(pCopiedItem) 102 , m_iPosition(iPosition) 131 103 , m_strName(pCopiedItem->name()) 132 104 , m_fClosed(pCopiedItem->isClosed()) … … 146 118 , m_pLayoutMachine(0) 147 119 { 148 /* Prepare: */149 120 prepare(); 150 151 /* Add item to the parent: */152 AssertMsg(parentItem(), ("Incorrect parent passed!"));153 parentItem()->addItem(this, false, iPosition);154 connect(this, &UIChooserItemGroup::sigToggleStarted,155 model(), &UIChooserModel::sigToggleStarted);156 connect(this, &UIChooserItemGroup::sigToggleFinished,157 model(), &UIChooserModel::sigToggleFinished);158 connect(gpManager, &UIVirtualBoxManager::sigWindowRemapped,159 this, &UIChooserItemGroup::sltHandleWindowRemapped);160 161 /* Copy content to 'this': */162 copyContent(pCopiedItem, this);163 164 /* Apply language settings: */165 retranslateUi();166 167 /* Init: */168 updatePixmaps();169 updateItemCountInfo();170 updateVisibleName();171 updateToolTip();172 121 } 173 122 174 123 UIChooserItemGroup::~UIChooserItemGroup() 175 124 { 176 /* Delete group name editor: */ 177 delete m_pNameEditorWidget; 178 m_pNameEditorWidget = 0; 179 180 /* Delete all the items: */ 181 clearItems(); 182 183 /* If that item is focused: */ 184 if (model()->focusItem() == this) 185 { 186 /* Unset the focus: */ 187 model()->setFocusItem(0); 188 } 189 /* If that item is in selection list: */ 190 if (model()->currentItems().contains(this)) 191 { 192 /* Remove item from the selection list: */ 193 model()->removeFromCurrentItems(this); 194 } 195 /* If that item is in navigation list: */ 196 if (model()->navigationList().contains(this)) 197 { 198 /* Remove item from the navigation list: */ 199 model()->removeFromNavigationList(this); 200 } 201 202 /* Remove item from the parent: */ 203 if (parentItem()) 204 parentItem()->removeItem(this); 125 cleanup(); 205 126 } 206 127 … … 1361 1282 } 1362 1283 } 1284 1285 /* Add item directly to the scene (if passed): */ 1286 if (m_pScene) 1287 m_pScene->addItem(this); 1288 /* Add item to the parent instead (if passed), 1289 * it will be added to the scene indirectly: */ 1290 else if (parentItem()) 1291 parentItem()->addItem(this, isFavorite(), m_iPosition); 1292 /* Otherwise sombody forgot to pass scene or parent. */ 1293 else 1294 AssertFailedReturnVoid(); 1295 1296 /* Copy item contents if any: */ 1297 if (m_pItemToCopy) 1298 copyContent(m_pItemToCopy, this); 1299 1300 /* Apply language settings: */ 1301 retranslateUi(); 1302 1303 /* Initialize non-root items: */ 1304 if (!isRoot()) 1305 { 1306 updatePixmaps(); 1307 updateItemCountInfo(); 1308 updateVisibleName(); 1309 updateToolTip(); 1310 } 1311 1312 /* Configure connections: */ 1313 connect(this, &UIChooserItemGroup::sigMinimumWidthHintChanged, 1314 model(), &UIChooserModel::sigRootItemMinimumWidthHintChanged); 1315 if (!isRoot()) 1316 { 1317 /* Non-root items can be toggled: */ 1318 connect(this, &UIChooserItemGroup::sigToggleStarted, 1319 model(), &UIChooserModel::sigToggleStarted); 1320 connect(this, &UIChooserItemGroup::sigToggleFinished, 1321 model(), &UIChooserModel::sigToggleFinished, 1322 Qt::QueuedConnection); 1323 /* Non-root items requires pixmap updates: */ 1324 connect(gpManager, &UIVirtualBoxManager::sigWindowRemapped, 1325 this, &UIChooserItemGroup::sltHandleWindowRemapped); 1326 } 1327 } 1328 1329 void UIChooserItemGroup::cleanup() 1330 { 1331 /* Delete group name editor: */ 1332 delete m_pNameEditorWidget; 1333 m_pNameEditorWidget = 0; 1334 1335 /* Delete all the items: */ 1336 clearItems(); 1337 1338 /* If that item is focused: */ 1339 if (model()->focusItem() == this) 1340 { 1341 /* Unset the focus: */ 1342 model()->setFocusItem(0); 1343 } 1344 /* If that item is in selection list: */ 1345 if (model()->currentItems().contains(this)) 1346 { 1347 /* Remove item from the selection list: */ 1348 model()->removeFromCurrentItems(this); 1349 } 1350 /* If that item is in navigation list: */ 1351 if (model()->navigationList().contains(this)) 1352 { 1353 /* Remove item from the navigation list: */ 1354 model()->removeFromNavigationList(this); 1355 } 1356 1357 /* Remove item from the parent: */ 1358 if (parentItem()) 1359 parentItem()->removeItem(this); 1363 1360 } 1364 1361 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGroup.h
r77621 r77627 251 251 /** Prepares all. */ 252 252 void prepare(); 253 /** Cleanups all. */ 254 void cleanup(); 253 255 /** @} */ 254 256 … … 317 319 /** @name Item stuff. 318 320 * @{ */ 321 /** Holds the graphics scene reference. */ 322 QGraphicsScene *m_pScene; 323 /** Holds the copied chooser item reference. */ 324 UIChooserItemGroup *m_pItemToCopy; 325 /** Holds the item position. */ 326 const int m_iPosition; 327 319 328 /** Holds the cached name. */ 320 329 QString m_strName;
Note:
See TracChangeset
for help on using the changeset viewer.