Changeset 63852 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Sep 15, 2016 11:08:19 AM (8 years ago)
- svn:sync-xref-src-repo-rev:
- 110702
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/selector
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.cpp
r63851 r63852 55 55 56 56 /** QTreeWidgetItem subclass for snapshots items. */ 57 class SnapshotWgtItem : public QTreeWidgetItem57 class UISnapshotItem : public QTreeWidgetItem 58 58 { 59 59 public: 60 60 61 /** Item type for SnapshotWgtItem. */61 /** Item type for UISnapshotItem. */ 62 62 enum { ItemType = QTreeWidgetItem::UserType + 1 }; 63 63 64 64 /** Constructs normal snapshot item (child of tree-widget). */ 65 SnapshotWgtItem(UISnapshotPane *pSnapshotWidget, QTreeWidget *pTreeWidget, const CSnapshot &comSnapshot);65 UISnapshotItem(UISnapshotPane *pSnapshotWidget, QTreeWidget *pTreeWidget, const CSnapshot &comSnapshot); 66 66 /** Constructs normal snapshot item (child of tree-widget-item). */ 67 SnapshotWgtItem(UISnapshotPane *pSnapshotWidget, QTreeWidgetItem *pRootItem, const CSnapshot &comSnapshot);67 UISnapshotItem(UISnapshotPane *pSnapshotWidget, QTreeWidgetItem *pRootItem, const CSnapshot &comSnapshot); 68 68 69 69 /** Constructs "current state" item (child of tree-widget). */ 70 SnapshotWgtItem(UISnapshotPane *pSnapshotWidget, QTreeWidget *pTreeWidget, const CMachine &comMachine);70 UISnapshotItem(UISnapshotPane *pSnapshotWidget, QTreeWidget *pTreeWidget, const CMachine &comMachine); 71 71 /** Constructs "current state" item (child of tree-widget-item). */ 72 SnapshotWgtItem(UISnapshotPane *pSnapshotWidget, QTreeWidgetItem *pRootItem, const CMachine &comMachine);72 UISnapshotItem(UISnapshotPane *pSnapshotWidget, QTreeWidgetItem *pRootItem, const CMachine &comMachine); 73 73 74 74 /** Returns item machine. */ … … 164 164 165 165 /********************************************************************************************************************************* 166 * Class SnapshotWgtItem implementation.*166 * Class UISnapshotItem implementation. * 167 167 *********************************************************************************************************************************/ 168 168 169 SnapshotWgtItem::SnapshotWgtItem(UISnapshotPane *pSnapshotWidget, QTreeWidget *pTreeWidget, const CSnapshot &comSnapshot)169 UISnapshotItem::UISnapshotItem(UISnapshotPane *pSnapshotWidget, QTreeWidget *pTreeWidget, const CSnapshot &comSnapshot) 170 170 : QTreeWidgetItem(pTreeWidget, ItemType) 171 171 , m_pSnapshotWidget(pSnapshotWidget) … … 175 175 } 176 176 177 SnapshotWgtItem::SnapshotWgtItem(UISnapshotPane *pSnapshotWidget, QTreeWidgetItem *pRootItem, const CSnapshot &comSnapshot)177 UISnapshotItem::UISnapshotItem(UISnapshotPane *pSnapshotWidget, QTreeWidgetItem *pRootItem, const CSnapshot &comSnapshot) 178 178 : QTreeWidgetItem(pRootItem, ItemType) 179 179 , m_pSnapshotWidget(pSnapshotWidget) … … 183 183 } 184 184 185 SnapshotWgtItem::SnapshotWgtItem(UISnapshotPane *pSnapshotWidget, QTreeWidget *pTreeWidget, const CMachine &comMachine)185 UISnapshotItem::UISnapshotItem(UISnapshotPane *pSnapshotWidget, QTreeWidget *pTreeWidget, const CMachine &comMachine) 186 186 : QTreeWidgetItem(pTreeWidget, ItemType) 187 187 , m_pSnapshotWidget(pSnapshotWidget) … … 193 193 } 194 194 195 SnapshotWgtItem::SnapshotWgtItem(UISnapshotPane *pSnapshotWidget, QTreeWidgetItem *pRootItem, const CMachine &comMachine)195 UISnapshotItem::UISnapshotItem(UISnapshotPane *pSnapshotWidget, QTreeWidgetItem *pRootItem, const CMachine &comMachine) 196 196 : QTreeWidgetItem(pRootItem, ItemType) 197 197 , m_pSnapshotWidget(pSnapshotWidget) … … 203 203 } 204 204 205 QVariant SnapshotWgtItem::data(int iColumn, int iRole) const205 QVariant UISnapshotItem::data(int iColumn, int iRole) const 206 206 { 207 207 switch (iRole) … … 236 236 } 237 237 238 QString SnapshotWgtItem::text(int iColumn) const238 QString UISnapshotItem::text(int iColumn) const 239 239 { 240 240 return QTreeWidgetItem::data(iColumn, Qt::DisplayRole).toString(); 241 241 } 242 242 243 bool SnapshotWgtItem::isCurrentStateItem() const243 bool UISnapshotItem::isCurrentStateItem() const 244 244 { 245 245 return m_comSnapshot.isNull(); 246 246 } 247 247 248 int SnapshotWgtItem::level() const248 int UISnapshotItem::level() const 249 249 { 250 250 const QTreeWidgetItem *pItem = this; … … 258 258 } 259 259 260 bool SnapshotWgtItem::bold() const260 bool UISnapshotItem::bold() const 261 261 { 262 262 return font(0).bold(); 263 263 } 264 264 265 void SnapshotWgtItem::setBold(bool fBold)265 void UISnapshotItem::setBold(bool fBold) 266 266 { 267 267 /* Update font: */ … … 274 274 } 275 275 276 bool SnapshotWgtItem::italic() const276 bool UISnapshotItem::italic() const 277 277 { 278 278 return font(0).italic(); 279 279 } 280 280 281 void SnapshotWgtItem::setItalic(bool fItalic)281 void UISnapshotItem::setItalic(bool fItalic) 282 282 { 283 283 /* Update font: */ … … 290 290 } 291 291 292 void SnapshotWgtItem::recache()292 void UISnapshotItem::recache() 293 293 { 294 294 /* For "current state" item: */ … … 327 327 } 328 328 329 KMachineState SnapshotWgtItem::getCurrentState() const329 KMachineState UISnapshotItem::getCurrentState() const 330 330 { 331 331 /* Make sure machine is valid: */ … … 337 337 } 338 338 339 void SnapshotWgtItem::updateCurrentState(KMachineState enmState)339 void UISnapshotItem::updateCurrentState(KMachineState enmState) 340 340 { 341 341 /* Make sure machine is valid: */ … … 351 351 } 352 352 353 SnapshotAgeFormat SnapshotWgtItem::updateAge()353 SnapshotAgeFormat UISnapshotItem::updateAge() 354 354 { 355 355 /* Prepare age: */ … … 395 395 } 396 396 397 void SnapshotWgtItem::adjustText()397 void UISnapshotItem::adjustText() 398 398 { 399 399 /* Make sure item is initialised: */ … … 414 414 } 415 415 416 void SnapshotWgtItem::recacheToolTip()416 void UISnapshotItem::recacheToolTip() 417 417 { 418 418 /* Is the saved date today? */ … … 644 644 { 645 645 /* Acquire corresponding snapshot item: */ 646 const SnapshotWgtItem *pSnapshotItem = toSnapshotItem(pItem);646 const UISnapshotItem *pSnapshotItem = toSnapshotItem(pItem); 647 647 648 648 /* Make the selected item visible: */ … … 712 712 713 713 /* Acquire corresponding snapshot item: */ 714 const SnapshotWgtItem *pSnapshotItem = toSnapshotItem(pItem);714 const UISnapshotItem *pSnapshotItem = toSnapshotItem(pItem); 715 715 AssertReturnVoid(pSnapshotItem); 716 716 … … 745 745 746 746 /* Acquire corresponding snapshot item: */ 747 const SnapshotWgtItem *pSnapshotItem = toSnapshotItem(pItem);747 const UISnapshotItem *pSnapshotItem = toSnapshotItem(pItem); 748 748 AssertReturnVoid(pSnapshotItem); 749 749 … … 760 760 { 761 761 /* Acquire corresponding snapshot item: */ 762 const SnapshotWgtItem *pSnapshotItem = toSnapshotItem(pItem);762 const UISnapshotItem *pSnapshotItem = toSnapshotItem(pItem); 763 763 AssertReturnVoid(pSnapshotItem); 764 764 … … 870 870 while (*iterator) 871 871 { 872 QString strSnapshot = static_cast< SnapshotWgtItem*>(*iterator)->text(0);872 QString strSnapshot = static_cast<UISnapshotItem*>(*iterator)->text(0); 873 873 int iPos = regExp.indexIn(strSnapshot); 874 874 if (iPos != -1) … … 933 933 { 934 934 /* Acquire currently chosen snapshot item: */ 935 const SnapshotWgtItem *pSnapshotItem = toSnapshotItem(m_pSnapshotTree->currentItem());935 const UISnapshotItem *pSnapshotItem = toSnapshotItem(m_pSnapshotTree->currentItem()); 936 936 AssertPtr(pSnapshotItem); 937 937 if (!pSnapshotItem) … … 1008 1008 { 1009 1009 /* Acquire currently chosen snapshot item: */ 1010 const SnapshotWgtItem *pSnapshotItem = toSnapshotItem(m_pSnapshotTree->currentItem());1010 const UISnapshotItem *pSnapshotItem = toSnapshotItem(m_pSnapshotTree->currentItem()); 1011 1011 AssertPtr(pSnapshotItem); 1012 1012 if (!pSnapshotItem) … … 1078 1078 { 1079 1079 /* Acquire currently chosen snapshot item: */ 1080 const SnapshotWgtItem *pSnapshotItem = toSnapshotItem(m_pSnapshotTree->currentItem());1080 const UISnapshotItem *pSnapshotItem = toSnapshotItem(m_pSnapshotTree->currentItem()); 1081 1081 AssertReturnVoid(pSnapshotItem); 1082 1082 … … 1097 1097 { 1098 1098 /* Acquire currently chosen snapshot item: */ 1099 const SnapshotWgtItem *pSnapshotItem = toSnapshotItem(m_pSnapshotTree->currentItem());1099 const UISnapshotItem *pSnapshotItem = toSnapshotItem(m_pSnapshotTree->currentItem()); 1100 1100 AssertReturnVoid(pSnapshotItem); 1101 1101 … … 1135 1135 /* Remember the selected item and it's first child: */ 1136 1136 QString strSelectedItem, strFirstChildOfSelectedItem; 1137 const SnapshotWgtItem *pSnapshotItem = toSnapshotItem(m_pSnapshotTree->currentItem());1137 const UISnapshotItem *pSnapshotItem = toSnapshotItem(m_pSnapshotTree->currentItem()); 1138 1138 if (pSnapshotItem) 1139 1139 { … … 1158 1158 1159 1159 /* Add the "current state" item as a child to current snapshot item: */ 1160 SnapshotWgtItem *pCsi = new SnapshotWgtItem(this, m_pCurrentSnapshotItem, m_comMachine);1160 UISnapshotItem *pCsi = new UISnapshotItem(this, m_pCurrentSnapshotItem, m_comMachine); 1161 1161 pCsi->setBold(true); 1162 1162 pCsi->recache(); 1163 1163 1164 1164 /* Search for a previously selected item: */ 1165 SnapshotWgtItem *pCurrentItem = findItem(strSelectedItem);1165 UISnapshotItem *pCurrentItem = findItem(strSelectedItem); 1166 1166 if (pCurrentItem == 0) 1167 1167 pCurrentItem = findItem(strFirstChildOfSelectedItem); … … 1181 1181 1182 1182 /* Add the "current state" item as a child of snapshot tree: */ 1183 SnapshotWgtItem *pCsi = new SnapshotWgtItem(this, m_pSnapshotTree, m_comMachine);1183 UISnapshotItem *pCsi = new UISnapshotItem(this, m_pSnapshotTree, m_comMachine); 1184 1184 pCsi->setBold(true); 1185 1185 pCsi->recache(); … … 1200 1200 { 1201 1201 /* Create a child of passed item: */ 1202 SnapshotWgtItem *pSnapshotItem = pItem ? new SnapshotWgtItem(this, pItem, comSnapshot) :1203 new SnapshotWgtItem(this, m_pSnapshotTree, comSnapshot);1202 UISnapshotItem *pSnapshotItem = pItem ? new UISnapshotItem(this, pItem, comSnapshot) : 1203 new UISnapshotItem(this, m_pSnapshotTree, comSnapshot); 1204 1204 /* And recache it's content: */ 1205 1205 pSnapshotItem->recache(); … … 1223 1223 } 1224 1224 1225 SnapshotWgtItem *UISnapshotPane::findItem(const QString &strSnapshotID) const1225 UISnapshotItem *UISnapshotPane::findItem(const QString &strSnapshotID) const 1226 1226 { 1227 1227 /* Search for the first item with required ID: */ … … 1229 1229 while (*it) 1230 1230 { 1231 SnapshotWgtItem *pSnapshotItem = toSnapshotItem(*it);1231 UISnapshotItem *pSnapshotItem = toSnapshotItem(*it); 1232 1232 if (pSnapshotItem->snapshotID() == strSnapshotID) 1233 1233 return pSnapshotItem; … … 1239 1239 } 1240 1240 1241 SnapshotWgtItem *UISnapshotPane::currentStateItem() const1241 UISnapshotItem *UISnapshotPane::currentStateItem() const 1242 1242 { 1243 1243 /* Last child of the current snapshot item if any or first child of invisible root item otherwise: */ … … 1245 1245 m_pCurrentSnapshotItem->child(m_pCurrentSnapshotItem->childCount() - 1) : 1246 1246 m_pSnapshotTree->invisibleRootItem()->child(0); 1247 return static_cast< SnapshotWgtItem*>(pCsi);1247 return static_cast<UISnapshotItem*>(pCsi); 1248 1248 } 1249 1249 … … 1251 1251 { 1252 1252 /* Acquire corresponding snapshot item: */ 1253 SnapshotWgtItem *pSnapshotItem = toSnapshotItem(pItem);1253 UISnapshotItem *pSnapshotItem = toSnapshotItem(pItem); 1254 1254 1255 1255 /* Fetch the snapshot age of the root if it's valid: */ … … 1270 1270 1271 1271 /* static */ 1272 SnapshotWgtItem *UISnapshotPane::toSnapshotItem(QTreeWidgetItem *pItem)1273 { 1274 /* Make sure alive SnapshotWgtItem passed: */1275 if (!pItem || pItem->type() != SnapshotWgtItem::ItemType)1272 UISnapshotItem *UISnapshotPane::toSnapshotItem(QTreeWidgetItem *pItem) 1273 { 1274 /* Make sure alive UISnapshotItem passed: */ 1275 if (!pItem || pItem->type() != UISnapshotItem::ItemType) 1276 1276 return 0; 1277 1277 1278 /* Return casted SnapshotWgtItem then: */1279 return static_cast< SnapshotWgtItem*>(pItem);1278 /* Return casted UISnapshotItem then: */ 1279 return static_cast<UISnapshotItem*>(pItem); 1280 1280 } 1281 1281 1282 1282 /* static */ 1283 const SnapshotWgtItem *UISnapshotPane::toSnapshotItem(const QTreeWidgetItem *pItem)1284 { 1285 /* Make sure alive SnapshotWgtItem passed: */1286 if (!pItem || pItem->type() != SnapshotWgtItem::ItemType)1283 const UISnapshotItem *UISnapshotPane::toSnapshotItem(const QTreeWidgetItem *pItem) 1284 { 1285 /* Make sure alive UISnapshotItem passed: */ 1286 if (!pItem || pItem->type() != UISnapshotItem::ItemType) 1287 1287 return 0; 1288 1288 1289 /* Return casted SnapshotWgtItem then: */1290 return static_cast<const SnapshotWgtItem*>(pItem);1289 /* Return casted UISnapshotItem then: */ 1290 return static_cast<const UISnapshotItem*>(pItem); 1291 1291 } 1292 1292 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.h
r63851 r63852 33 33 /* Forward declarations: */ 34 34 class UISnapshotTree; 35 class UISnapshotItem; 35 36 class QTreeWidgetItem; 36 class SnapshotWgtItem;37 37 38 38 … … 135 135 136 136 /** Searches for an item with corresponding @a strSnapshotID. */ 137 SnapshotWgtItem *findItem(const QString &strSnapshotID) const;137 UISnapshotItem *findItem(const QString &strSnapshotID) const; 138 138 /** Returns the "current state" item. */ 139 SnapshotWgtItem *currentStateItem() const;139 UISnapshotItem *currentStateItem() const; 140 140 141 141 /** Searches for smallest snapshot age starting with @a pItem as parent. */ 142 142 SnapshotAgeFormat traverseSnapshotAge(QTreeWidgetItem *pItem) const; 143 143 144 /** Casts QTreeWidgetItem to SnapshotWgtItem if possible. */145 static SnapshotWgtItem *toSnapshotItem(QTreeWidgetItem *pItem);146 /** Casts const QTreeWidgetItem to const SnapshotWgtItem if possible. */147 static const SnapshotWgtItem *toSnapshotItem(const QTreeWidgetItem *pItem);144 /** Casts QTreeWidgetItem to UISnapshotItem if possible. */ 145 static UISnapshotItem *toSnapshotItem(QTreeWidgetItem *pItem); 146 /** Casts const QTreeWidgetItem to const UISnapshotItem if possible. */ 147 static const UISnapshotItem *toSnapshotItem(const QTreeWidgetItem *pItem); 148 148 149 149 /** Holds the machine COM wrapper. */ … … 154 154 KSessionState m_enmSessionState; 155 155 /** Holds the current snapshot item reference. */ 156 SnapshotWgtItem*m_pCurrentSnapshotItem;156 UISnapshotItem *m_pCurrentSnapshotItem; 157 157 /** Holds the snapshot item editing protector. */ 158 158 QReadWriteLock m_lockReadWrite;
Note:
See TracChangeset
for help on using the changeset viewer.