Changeset 67260 in vbox for trunk/src/VBox
- Timestamp:
- Jun 5, 2017 4:08:22 PM (8 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/selector
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.cpp
r67246 r67260 94 94 95 95 /** Returns whether this is the "current state" item. */ 96 bool isCurrentStateItem() const ;96 bool isCurrentStateItem() const { return m_fCurrentStateItem; } 97 97 98 98 /** Calculates and returns the current item level. */ … … 113 113 114 114 /** Returns current machine state. */ 115 KMachineState getCurrentState() const; 116 117 /** Recaches current machine state. */ 118 void updateCurrentState(KMachineState enmState); 115 KMachineState machineState() const; 116 /** Defines current machine @a enmState. */ 117 void setMachineState(KMachineState enmState); 119 118 120 119 /** Updates item age. */ … … 132 131 133 132 /** Holds the pointer to the snapshot-widget this item belongs to. */ 134 QPointer<UISnapshotPane> m_pSnapshotWidget;133 QPointer<UISnapshotPane> m_pSnapshotWidget; 135 134 136 135 /** Holds whether this is a "current state" item. */ 137 bool m_fCurrentState;136 bool m_fCurrentStateItem; 138 137 139 138 /** Holds the snapshot COM wrapper. */ 140 CSnapshot 139 CSnapshot m_comSnapshot; 141 140 /** Holds the machine COM wrapper. */ 142 CMachine 141 CMachine m_comMachine; 143 142 144 143 /** Holds the current snapshot ID. */ 145 QString 144 QString m_strSnapshotID; 146 145 /** Holds whether the current snapshot is online one. */ 147 bool 146 bool m_fOnline; 148 147 149 148 /** Holds the item timestamp. */ 150 QDateTime 149 QDateTime m_timestamp; 151 150 152 151 /** Holds whether the current state is modified. */ 153 bool 152 bool m_fCurrentStateModified; 154 153 /** Holds the cached machine state. */ 155 KMachineState 154 KMachineState m_enmMachineState; 156 155 }; 157 156 … … 200 199 : QITreeWidgetItem(pTreeWidget) 201 200 , m_pSnapshotWidget(pSnapshotWidget) 202 , m_fCurrentState (false)201 , m_fCurrentStateItem(false) 203 202 , m_comSnapshot(comSnapshot) 204 203 { … … 208 207 : QITreeWidgetItem(pRootItem) 209 208 , m_pSnapshotWidget(pSnapshotWidget) 210 , m_fCurrentState (false)209 , m_fCurrentStateItem(false) 211 210 , m_comSnapshot(comSnapshot) 212 211 { … … 216 215 : QITreeWidgetItem(pTreeWidget) 217 216 , m_pSnapshotWidget(pSnapshotWidget) 218 , m_fCurrentState (true)217 , m_fCurrentStateItem(true) 219 218 , m_comMachine(comMachine) 220 219 { 221 220 /* Fetch current machine state: */ 222 updateCurrentState(m_comMachine.GetState());221 setMachineState(m_comMachine.GetState()); 223 222 } 224 223 … … 226 225 : QITreeWidgetItem(pRootItem) 227 226 , m_pSnapshotWidget(pSnapshotWidget) 228 , m_fCurrentState (true)227 , m_fCurrentStateItem(true) 229 228 , m_comMachine(comMachine) 230 229 { 231 230 /* Fetch current machine state: */ 232 updateCurrentState(m_comMachine.GetState());231 setMachineState(m_comMachine.GetState()); 233 232 } 234 233 … … 240 239 { 241 240 /* Call to base-class for "current state" item, compose ourselves otherwise: */ 242 return m_fCurrentState ? QTreeWidgetItem::data(iColumn, iRole) :243 QString("%1%2")244 .arg(QTreeWidgetItem::data(iColumn, Qt::DisplayRole).toString())245 .arg(QTreeWidgetItem::data(iColumn, Qt::UserRole).toString());241 return m_fCurrentStateItem ? QTreeWidgetItem::data(iColumn, iRole) 242 : QString("%1%2") 243 .arg(QTreeWidgetItem::data(iColumn, Qt::DisplayRole).toString()) 244 .arg(QTreeWidgetItem::data(iColumn, Qt::UserRole).toString()); 246 245 } 247 246 case Qt::SizeHintRole: … … 271 270 } 272 271 273 bool UISnapshotItem::isCurrentStateItem() const274 {275 return m_comSnapshot.isNull();276 }277 278 272 int UISnapshotItem::level() const 279 273 { … … 323 317 { 324 318 /* For "current state" item: */ 325 if (m_fCurrentState )319 if (m_fCurrentStateItem) 326 320 { 327 321 /* Fetch machine information: */ 328 AssertReturnVoid( !m_comMachine.isNull());322 AssertReturnVoid(m_comMachine.isNotNull()); 329 323 m_fCurrentStateModified = m_comMachine.GetCurrentStateModified(); 330 m_strName = m_fCurrentStateModified ?331 UISnapshotPane::tr("Current State (changed)", "Current State (Modified)") :332 324 m_strName = m_fCurrentStateModified 325 ? UISnapshotPane::tr("Current State (changed)", "Current State (Modified)") 326 : UISnapshotPane::tr("Current State", "Current State (Unmodified)"); 333 327 setText(0, m_strName); 334 m_strDescription = m_fCurrentStateModified ?335 UISnapshotPane::tr("The current state differs from the state stored in the current snapshot") :336 QTreeWidgetItem::parent() != 0 ?337 UISnapshotPane::tr("The current state is identical to the state stored in the current snapshot") :338 339 } 340 /* For others: */328 m_strDescription = m_fCurrentStateModified 329 ? UISnapshotPane::tr("The current state differs from the state stored in the current snapshot") 330 : QTreeWidgetItem::parent() != 0 331 ? UISnapshotPane::tr("The current state is identical to the state stored in the current snapshot") 332 : QString(); 333 } 334 /* For snapshot item: */ 341 335 else 342 336 { 343 337 /* Fetch snapshot information: */ 344 AssertReturnVoid( !m_comSnapshot.isNull());338 AssertReturnVoid(m_comSnapshot.isNotNull()); 345 339 m_strSnapshotID = m_comSnapshot.GetId(); 346 340 m_strName = m_comSnapshot.GetName(); … … 359 353 } 360 354 361 KMachineState UISnapshotItem:: getCurrentState() const355 KMachineState UISnapshotItem::machineState() const 362 356 { 363 357 /* Make sure machine is valid: */ … … 369 363 } 370 364 371 void UISnapshotItem:: updateCurrentState(KMachineState enmState)365 void UISnapshotItem::setMachineState(KMachineState enmState) 372 366 { 373 367 /* Make sure machine is valid: */ … … 375 369 return; 376 370 377 /* Set corresponding icon: */378 setIcon(0, gpConverter->toIcon(enmState));379 371 /* Cache new state: */ 380 372 m_enmMachineState = enmState; 373 /* Set corresponding icon: */ 374 setIcon(0, gpConverter->toIcon(m_enmMachineState)); 381 375 /* Update timestamp: */ 382 376 m_timestamp.setTime_t(m_comMachine.GetLastStateChange() / 1000); … … 452 446 453 447 /* Compose date time: */ 454 QString strDateTime = fDateTimeToday ?455 m_timestamp.time().toString(Qt::LocalDate) :456 448 QString strDateTime = fDateTimeToday 449 ? m_timestamp.time().toString(Qt::LocalDate) 450 : m_timestamp.toString(Qt::LocalDate); 457 451 458 452 /* Prepare details: */ 459 453 QString strDetails; 460 454 455 /* For "current state" item: */ 456 if (m_fCurrentStateItem) 457 { 458 strDateTime = UISnapshotPane::tr("%1 since %2", "Current State (time or date + time)") 459 .arg(gpConverter->toString(m_enmMachineState)).arg(strDateTime); 460 } 461 461 /* For snapshot item: */ 462 if (!m_comSnapshot.isNull())462 else 463 463 { 464 464 /* The current snapshot is always bold: */ … … 477 477 else 478 478 strDateTime = UISnapshotPane::tr("Taken on %1", "Snapshot (date + time)").arg(strDateTime); 479 }480 /* For "current state" item: */481 else482 {483 strDateTime = UISnapshotPane::tr("%1 since %2", "Current State (time or date + time)")484 .arg(gpConverter->toString(m_enmMachineState)).arg(strDateTime);485 479 } 486 480 … … 644 638 /* Recache current item data and machine-state: */ 645 639 currentStateItem()->recache(); 646 currentStateItem()-> updateCurrentState(enmState);640 currentStateItem()->setMachineState(enmState); 647 641 } 648 642 … … 766 760 KMachineState enmState = KMachineState_Null; 767 761 if (currentStateItem()) 768 enmState = currentStateItem()-> getCurrentState();762 enmState = currentStateItem()->machineState(); 769 763 770 764 /* Whether taking or deleting snapshots is possible right now: */ -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.h
r67160 r67260 69 69 protected: 70 70 71 /** Handles translation event. */ 72 virtual void retranslateUi() /* override */; 71 /** @name Event-handling stuff. 72 * @{ */ 73 /** Handles translation event. */ 74 virtual void retranslateUi() /* override */; 75 /** @} */ 73 76 74 77 private slots:
Note:
See TracChangeset
for help on using the changeset viewer.