Changeset 37470 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Jun 15, 2011 2:43:55 PM (13 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/VBoxMediaManagerDlg.cpp
r37445 r37470 205 205 , mShowDiffs (true) 206 206 , mSetupMode (false) 207 , m_previousMediumType(KMediumType_Normal) 208 , m_fParentMediumType(true) 207 209 { 208 210 /* Apply UI decorations */ … … 283 285 connect (mTwFD->header(), SIGNAL (sectionResized (int, int, int)), 284 286 this, SLOT (makeRequestForAdjustTable())); 287 288 /* Setup information pane: */ 289 qRegisterMetaType<KMediumType>(); 290 connect(m_pTypeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(sltCurrentMediumTypeChanged())); 285 291 286 292 /* Context menu composing */ … … 652 658 if (mTwHD->model()->rowCount() || mTwCD->model()->rowCount() || mTwFD->model()->rowCount()) 653 659 refreshAll(); 660 661 /* Translate medium type combo: */ 662 repopulateMediumTypeCombo(); 663 } 664 665 void VBoxMediaManagerDlg::repopulateMediumTypeCombo() 666 { 667 /* Block signals: */ 668 m_pTypeCombo->blockSignals(true); 669 670 /* Remember current index: */ 671 int iCurrentIndex = m_pTypeCombo->currentIndex(); 672 673 /* Repopulate medium types: */ 674 m_pTypeCombo->clear(); 675 676 /* Check parent mode: */ 677 if (m_fParentMediumType) 678 { 679 /* Populate possible types for parent disks: */ 680 m_pTypeCombo->insertItem(0, vboxGlobal().toString(KMediumType_Normal), QVariant::fromValue(KMediumType_Normal)); 681 m_pTypeCombo->insertItem(1, vboxGlobal().toString(KMediumType_Immutable), QVariant::fromValue(KMediumType_Immutable)); 682 m_pTypeCombo->insertItem(2, vboxGlobal().toString(KMediumType_Writethrough), QVariant::fromValue(KMediumType_Writethrough)); 683 m_pTypeCombo->insertItem(3, vboxGlobal().toString(KMediumType_Shareable), QVariant::fromValue(KMediumType_Shareable)); 684 m_pTypeCombo->insertItem(4, vboxGlobal().toString(KMediumType_MultiAttach), QVariant::fromValue(KMediumType_MultiAttach)); 685 } 686 else 687 { 688 /* Just one 'differencing' type for children disks: */ 689 m_pTypeCombo->insertItem(0, vboxGlobal().differencingMediumTypeName()); 690 } 691 692 /* Choose current index again if still possible: */ 693 if (iCurrentIndex >= 0 && iCurrentIndex < m_pTypeCombo->count()) 694 m_pTypeCombo->setCurrentIndex(iCurrentIndex); 695 else 696 m_pTypeCombo->setCurrentIndex(0); 697 698 /* Unblock signals: */ 699 m_pTypeCombo->blockSignals(false); 654 700 } 655 701 … … 1437 1483 if (item->treeWidget() == mTwHD) 1438 1484 { 1439 mIpHD1->setText (formatPaneText (item->location(), true, "end")); 1440 mIpHD2->setText (formatPaneText (QString ("%1 (%2)").arg (item->hardDiskType()) 1441 .arg (item->hardDiskFormat()), false)); 1442 mIpHD3->setText (details); 1443 mIpHD4->setText (usage); 1485 /* Update parent mode: */ 1486 m_fParentMediumType = !item->medium().parent(); 1487 /* Repopulate combo: */ 1488 repopulateMediumTypeCombo(); 1489 1490 /* Block signals: */ 1491 m_pTypeCombo->blockSignals(true); 1492 /* Choose the correct one medium type: */ 1493 int iIndexOfType = m_pTypeCombo->findText(item->hardDiskType()); 1494 AssertMsg(iIndexOfType != -1, ("Incorrect medium type: %s\n", item->hardDiskType().toLatin1().constData())); 1495 m_pTypeCombo->setCurrentIndex(iIndexOfType); 1496 /* Remember new medium type: */ 1497 m_previousMediumType = m_pTypeCombo->itemData(m_pTypeCombo->currentIndex()).value<KMediumType>(); 1498 /* Unblock signals: */ 1499 m_pTypeCombo->blockSignals(false); 1500 1501 /* Other panes: */ 1502 m_pLocationPane->setText(formatPaneText(item->location(), true, "end")); 1503 m_pFormatPane->setText(item->hardDiskFormat()); 1504 m_pDetailsPane->setText(details); 1505 m_pUsagePane->setText(usage); 1444 1506 } 1445 1507 else if (item->treeWidget() == mTwCD) … … 1533 1595 if (widgetList [i]->header()->sectionSize (0) != size0) 1534 1596 widgetList [i]->header()->resizeSection (0, size0); 1597 } 1598 } 1599 1600 void VBoxMediaManagerDlg::sltCurrentMediumTypeChanged() 1601 { 1602 /* Get new medium type: */ 1603 KMediumType newMediumType = m_pTypeCombo->itemData(m_pTypeCombo->currentIndex()).value<KMediumType>(); 1604 1605 /* Check that new type exists and differs from the old one: */ 1606 if (newMediumType == m_previousMediumType) 1607 return; 1608 1609 MediaItem *pMediumItem = toMediaItem(currentTreeWidget()->currentItem()); 1610 CMedium medium = pMediumItem->medium().medium(); 1611 medium.SetType(newMediumType); 1612 if (!medium.isOk()) 1613 { 1614 /* Revert medium type: */ 1615 m_pTypeCombo->blockSignals(true); 1616 int iPreviousIndex = m_pTypeCombo->findText(vboxGlobal().toString(m_previousMediumType)); 1617 m_pTypeCombo->setCurrentIndex(iPreviousIndex); 1618 m_pTypeCombo->blockSignals(false); 1619 /* Show warning: */ 1620 vboxProblem().cannotChangeMediumType(this, medium, m_previousMediumType, newMediumType); 1621 } 1622 else 1623 { 1624 /* Remember new medium type: */ 1625 m_previousMediumType = m_pTypeCombo->itemData(m_pTypeCombo->currentIndex()).value<KMediumType>(); 1626 /* Refresh related VMM item: */ 1627 pMediumItem->refreshAll(); 1535 1628 } 1536 1629 } … … 1814 1907 void VBoxMediaManagerDlg::clearInfoPanes() 1815 1908 { 1816 m IpHD1->clear(); mIpHD2->clear(); mIpHD3->clear(); mIpHD4->clear();1909 m_pTypeCombo->setCurrentIndex(-1); m_pLocationPane->clear(); m_pFormatPane->clear(); m_pDetailsPane->clear(); m_pUsagePane->clear(); 1817 1910 mIpCD1->clear(); mIpCD2->clear(); 1818 1911 mIpFD1->clear(); mIpFD2->clear(); -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxMediaManagerDlg.h
r37406 r37470 70 70 71 71 void retranslateUi(); 72 void repopulateMediumTypeCombo(); 72 73 virtual void closeEvent (QCloseEvent *aEvent); 73 74 virtual bool eventFilter (QObject *aObject, QEvent *aEvent); … … 100 101 void makeRequestForAdjustTable(); 101 102 void performTablesAdjustment(); 103 104 void sltCurrentMediumTypeChanged(); 102 105 103 106 private: … … 145 148 bool mSetupMode : 1; 146 149 150 /* Medium type related variables: */ 151 KMediumType m_previousMediumType; 152 bool m_fParentMediumType; 153 147 154 /* Icon definitions */ 148 155 QIcon mHardDiskIcon; -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxMediaManagerDlg.ui
r37374 r37470 97 97 </property> 98 98 <item row="0" column="0" > 99 <widget class="QLabel" name="mLbHD1" > 99 <widget class="QLabel" name="m_pTypeLabel" > 100 <property name="text" > 101 <string>Type:</string> 102 </property> 103 </widget> 104 </item> 105 <item row="0" column="1" > 106 <widget class="QComboBox" name="m_pTypeCombo" > 107 <property name="sizePolicy" > 108 <sizepolicy vsizetype="Preferred" hsizetype="MinimumExpanding" > 109 <horstretch>0</horstretch> 110 <verstretch>0</verstretch> 111 </sizepolicy> 112 </property> 113 </widget> 114 </item> 115 <item row="1" column="0" > 116 <widget class="QLabel" name="m_pLocationLabel" > 100 117 <property name="text" > 101 118 <string>Location:</string> … … 103 120 </widget> 104 121 </item> 105 <item row="0" column="1" >106 <widget class="QILabel" name="mIpHD1" >107 <property name="sizePolicy" >108 <sizepolicy vsizetype="Preferred" hsizetype="MinimumExpanding" >109 <horstretch>0</horstretch>110 <verstretch>0</verstretch>111 </sizepolicy>112 </property>113 </widget>114 </item>115 <item row="1" column="0" >116 <widget class="QLabel" name="mLbHD2" >117 <property name="text" >118 <string>Type (Format):</string>119 </property>120 </widget>121 </item>122 122 <item row="1" column="1" > 123 <widget class="QILabel" name="m IpHD2" >123 <widget class="QILabel" name="m_pLocationPane" > 124 124 <property name="sizePolicy" > 125 125 <sizepolicy vsizetype="Preferred" hsizetype="MinimumExpanding" > … … 131 131 </item> 132 132 <item row="2" column="0" > 133 <widget class="QLabel" name="mLbHD3" > 133 <widget class="QLabel" name="m_pFormatLabel" > 134 <property name="text" > 135 <string>Format:</string> 136 </property> 137 </widget> 138 </item> 139 <item row="2" column="1" > 140 <widget class="QILabel" name="m_pFormatPane" > 141 <property name="sizePolicy" > 142 <sizepolicy vsizetype="Preferred" hsizetype="MinimumExpanding" > 143 <horstretch>0</horstretch> 144 <verstretch>0</verstretch> 145 </sizepolicy> 146 </property> 147 </widget> 148 </item> 149 <item row="3" column="0" > 150 <widget class="QLabel" name="m_pDetailsLabel" > 134 151 <property name="text" > 135 152 <string>Storage details:</string> … … 137 154 </widget> 138 155 </item> 139 <item row=" 2" column="1" >140 <widget class="QILabel" name="m IpHD3" >141 <property name="sizePolicy" > 142 <sizepolicy vsizetype="Preferred" hsizetype="MinimumExpanding" > 143 <horstretch>0</horstretch> 144 <verstretch>0</verstretch> 145 </sizepolicy> 146 </property> 147 </widget> 148 </item> 149 <item row=" 3" column="0" >150 <widget class="QLabel" name="m LbHD4" >156 <item row="3" column="1" > 157 <widget class="QILabel" name="m_pDetailsPane" > 158 <property name="sizePolicy" > 159 <sizepolicy vsizetype="Preferred" hsizetype="MinimumExpanding" > 160 <horstretch>0</horstretch> 161 <verstretch>0</verstretch> 162 </sizepolicy> 163 </property> 164 </widget> 165 </item> 166 <item row="4" column="0" > 167 <widget class="QLabel" name="m_pUsageLabel" > 151 168 <property name="text" > 152 169 <string>Attached to:</string> … … 154 171 </widget> 155 172 </item> 156 <item row=" 3" column="1" >157 <widget class="QILabel" name="m IpHD4" >173 <item row="4" column="1" > 174 <widget class="QILabel" name="m_pUsagePane" > 158 175 <property name="sizePolicy" > 159 176 <sizepolicy vsizetype="Preferred" hsizetype="MinimumExpanding" > -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h
r37374 r37470 315 315 return mDiskTypes.value (t); 316 316 } 317 QString differencingMediumTypeName() const { return mDiskTypes_Differencing; } 317 318 318 319 QString toString(KMediumVariant mediumVariant) const; -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.cpp
r37468 r37470 1230 1230 } 1231 1231 1232 void VBoxProblemReporter::cannotChangeMediumType(QWidget *pParent, const CMedium &medium, KMediumType oldMediumType, KMediumType newMediumType) 1233 { 1234 message(pParent ? pParent : mainWindowShown(), Error, 1235 tr("<p>Error changing medium type from <b>%1</b> to <b>%2</b>.</p>") 1236 .arg(vboxGlobal().toString(oldMediumType)).arg(vboxGlobal().toString(newMediumType)), 1237 formatErrorInfo(medium)); 1238 } 1239 1232 1240 bool VBoxProblemReporter::confirmReleaseMedium (QWidget *aParent, 1233 1241 const VBoxMedium &aMedium, -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.h
r37468 r37470 250 250 bool confirmDiscardSavedState (const CMachine &machine); 251 251 252 void cannotChangeMediumType(QWidget *pParent, const CMedium &medium, KMediumType oldMediumType, KMediumType newMediumType); 253 252 254 bool confirmReleaseMedium (QWidget *aParent, const VBoxMedium &aMedium, 253 255 const QString &aUsage);
Note:
See TracChangeset
for help on using the changeset viewer.