Changeset 36930 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- May 3, 2011 12:50:20 PM (14 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/settings/machine
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsParallel.cpp
r36519 r36930 61 61 void UIMachineSettingsParallel::polishTab() 62 62 { 63 /* Polish port page: */ 64 ulong uIRQ, uIOBase; 65 bool fStd = vboxGlobal().toCOMPortNumbers(mCbNumber->currentText(), uIRQ, uIOBase); 63 66 mGbParallel->setEnabled(m_pParent->isMachineOffline()); 64 67 mLbNumber->setEnabled(m_pParent->isMachineOffline()); 65 68 mCbNumber->setEnabled(m_pParent->isMachineOffline()); 66 69 mLbIRQ->setEnabled(m_pParent->isMachineOffline()); 67 mLeIRQ->setEnabled( m_pParent->isMachineOffline());70 mLeIRQ->setEnabled(!fStd && m_pParent->isMachineOffline()); 68 71 mLbIOPort->setEnabled(m_pParent->isMachineOffline()); 69 mLeIOPort->setEnabled( m_pParent->isMachineOffline());72 mLeIOPort->setEnabled(!fStd && m_pParent->isMachineOffline()); 70 73 mLbPath->setEnabled(m_pParent->isMachineOffline()); 71 74 mLePath->setEnabled(m_pParent->isMachineOffline()); 72 75 } 73 76 74 void UIMachineSettingsParallel::fetchPortData(const UIParallelPortData &data) 75 { 76 /* Load port slot number: */ 77 m_iSlot = data.m_iSlot; 78 79 /* Fetch port data: */ 80 mGbParallel->setChecked(data.m_fPortEnabled); 81 mCbNumber->setCurrentIndex(mCbNumber->findText(vboxGlobal().toCOMPortName(data.m_uIRQ, data.m_uIOBase))); 82 mLeIRQ->setText(QString::number(data.m_uIRQ)); 83 mLeIOPort->setText("0x" + QString::number(data.m_uIOBase, 16).toUpper()); 84 mLePath->setText(data.m_strPath); 77 void UIMachineSettingsParallel::fetchPortData(const UICacheSettingsMachineParallelPort &portCache) 78 { 79 /* Get port data: */ 80 const UIDataSettingsMachineParallelPort &portData = portCache.base(); 81 82 /* Load port number: */ 83 m_iSlot = portData.m_iSlot; 84 85 /* Load port data: */ 86 mGbParallel->setChecked(portData.m_fPortEnabled); 87 mCbNumber->setCurrentIndex(mCbNumber->findText(vboxGlobal().toCOMPortName(portData.m_uIRQ, portData.m_uIOBase))); 88 mLeIRQ->setText(QString::number(portData.m_uIRQ)); 89 mLeIOPort->setText("0x" + QString::number(portData.m_uIOBase, 16).toUpper()); 90 mLePath->setText(portData.m_strPath); 85 91 86 92 /* Ensure everything is up-to-date */ … … 88 94 } 89 95 90 void UIMachineSettingsParallel::uploadPortData(UIParallelPortData &data) 91 { 92 /* Upload port data: */ 93 data.m_fPortEnabled = mGbParallel->isChecked(); 94 data.m_uIRQ = mLeIRQ->text().toULong(NULL, 0); 95 data.m_uIOBase = mLeIOPort->text().toULong(NULL, 0); 96 data.m_strPath = QDir::toNativeSeparators(mLePath->text()); 96 void UIMachineSettingsParallel::uploadPortData(UICacheSettingsMachineParallelPort &portCache) 97 { 98 /* Prepare port data: */ 99 UIDataSettingsMachineParallelPort portData = portCache.base(); 100 101 /* Save port data: */ 102 portData.m_fPortEnabled = mGbParallel->isChecked(); 103 portData.m_uIRQ = mLeIRQ->text().toULong(NULL, 0); 104 portData.m_uIOBase = mLeIOPort->text().toULong(NULL, 0); 105 portData.m_strPath = QDir::toNativeSeparators(mLePath->text()); 106 107 /* Cache port data: */ 108 portCache.cacheCurrentData(portData); 97 109 } 98 110 … … 172 184 layout->setContentsMargins (0, 5, 0, 5); 173 185 layout->addWidget (mTabWidget); 186 187 /* How many ports to display: */ 188 ulong uCount = vboxGlobal().virtualBox().GetSystemProperties().GetParallelPortCount(); 189 /* Add corresponding tab pages to parent tab widget: */ 190 for (ulong uPort = 0; uPort < uCount; ++uPort) 191 { 192 /* Creating port page: */ 193 UIMachineSettingsParallel *pPage = new UIMachineSettingsParallel(this); 194 mTabWidget->addTab(pPage, pPage->pageTitle()); 195 } 174 196 } 175 197 … … 181 203 UISettingsPageMachine::fetchData(data); 182 204 183 /* Load port data: */ 184 ulong uCount = vboxGlobal().virtualBox().GetSystemProperties().GetParallelPortCount(); 185 for (ulong uSlot = 0; uSlot < uCount; ++uSlot) 186 { 187 /* Get port: */ 188 const CParallelPort &port = m_machine.GetParallelPort(uSlot); 189 190 /* Prepare port's data container: */ 191 UIParallelPortData data; 192 193 /* Load options: */ 194 data.m_iSlot = uSlot; 195 data.m_fPortEnabled = port.GetEnabled(); 196 data.m_uIRQ = port.GetIRQ(); 197 data.m_uIOBase = port.GetIOBase(); 198 data.m_strPath = port.GetPath(); 199 200 /* Append adapter's data container: */ 201 m_cache.m_items << data; 205 /* For each parallel port: */ 206 for (int iSlot = 0; iSlot < mTabWidget->count(); ++iSlot) 207 { 208 /* Prepare port data: */ 209 UIDataSettingsMachineParallelPort portData; 210 211 /* Check if port is valid: */ 212 const CParallelPort &port = m_machine.GetParallelPort(iSlot); 213 if (!port.isNull()) 214 { 215 /* Gather options: */ 216 portData.m_iSlot = iSlot; 217 portData.m_fPortEnabled = port.GetEnabled(); 218 portData.m_uIRQ = port.GetIRQ(); 219 portData.m_uIOBase = port.GetIOBase(); 220 portData.m_strPath = port.GetPath(); 221 } 222 223 /* Cache port data: */ 224 m_cache.child(iSlot).cacheInitialData(portData); 202 225 } 203 226 … … 210 233 void UIMachineSettingsParallelPage::getFromCache() 211 234 { 235 /* Setup tab order: */ 212 236 Assert(firstWidget()); 213 237 setTabOrder(firstWidget(), mTabWidget->focusProxy()); 214 238 QWidget *pLastFocusWidget = mTabWidget->focusProxy(); 215 239 216 /* Apply internal variables data to QWidget(s): */ 217 for (int iSlot = 0; iSlot < m_cache.m_items.size(); ++iSlot) 218 { 219 /* Creating port's page: */ 220 UIMachineSettingsParallel *pPage = new UIMachineSettingsParallel(this); 221 222 /* Loading port's data into page: */ 223 pPage->fetchPortData(m_cache.m_items[iSlot]); 224 225 /* Attach port's page to Tab Widget: */ 226 mTabWidget->addTab(pPage, pPage->pageTitle()); 240 /* For each parallel port: */ 241 for (int iPort = 0; iPort < mTabWidget->count(); ++iPort) 242 { 243 /* Get port page: */ 244 UIMachineSettingsParallel *pPage = qobject_cast<UIMachineSettingsParallel*>(mTabWidget->widget(iPort)); 245 246 /* Load port data to page: */ 247 pPage->fetchPortData(m_cache.child(iPort)); 227 248 228 249 /* Setup page validation: */ … … 244 265 void UIMachineSettingsParallelPage::putToCache() 245 266 { 246 /* Gather internal variables data from QWidget(s): */247 for (int i Slot = 0; iSlot < m_cache.m_items.size(); ++iSlot)248 { 249 /* Getting adapter'spage: */250 UIMachineSettingsParallel *pPage = qobject_cast<UIMachineSettingsParallel*>(mTabWidget->widget(i Slot));251 252 /* Loading Adapter's data from page: */253 pPage->uploadPortData(m_cache. m_items[iSlot]);267 /* For each parallel port: */ 268 for (int iPort = 0; iPort < mTabWidget->count(); ++iPort) 269 { 270 /* Getting port page: */ 271 UIMachineSettingsParallel *pPage = qobject_cast<UIMachineSettingsParallel*>(mTabWidget->widget(iPort)); 272 273 /* Gather & cache port data: */ 274 pPage->uploadPortData(m_cache.child(iPort)); 254 275 } 255 276 } … … 262 283 UISettingsPageMachine::fetchData(data); 263 284 264 if (isMachineOffline()) 265 { 266 /* Gather corresponding values from internal variables: */ 267 for (int iSlot = 0; iSlot < m_cache.m_items.size(); ++iSlot) 285 /* Check if ports data was changed: */ 286 if (m_cache.wasChanged()) 287 { 288 /* For each parallel port: */ 289 for (int iPort = 0; iPort < mTabWidget->count(); ++iPort) 268 290 { 269 /* Get adapter: */ 270 CParallelPort port = m_machine.GetParallelPort(iSlot); 271 272 /* Get cached data for this slot: */ 273 const UIParallelPortData &data = m_cache.m_items[iSlot]; 274 275 /* Save options: */ 276 port.SetIRQ(data.m_uIRQ); 277 port.SetIOBase(data.m_uIOBase); 278 port.SetPath(data.m_strPath); 279 port.SetEnabled(data.m_fPortEnabled); 291 /* Check if port data was changed: */ 292 const UICacheSettingsMachineParallelPort &portCache = m_cache.child(iPort); 293 if (portCache.wasChanged()) 294 { 295 /* Check if port still valid: */ 296 CParallelPort port = m_machine.GetParallelPort(iPort); 297 if (!port.isNull()) 298 { 299 /* Get port data from cache: */ 300 const UIDataSettingsMachineParallelPort &portData = portCache.data(); 301 302 /* Store adapter data: */ 303 if (isMachineOffline()) 304 { 305 port.SetIRQ(portData.m_uIRQ); 306 port.SetIOBase(portData.m_uIOBase); 307 port.SetPath(portData.m_strPath); 308 port.SetEnabled(portData.m_fPortEnabled); 309 } 310 } 311 } 280 312 } 281 313 } … … 352 384 { 353 385 /* Get the count of parallel port tabs: */ 354 for (int i TabIndex = 0; iTabIndex < mTabWidget->count(); ++iTabIndex)355 { 356 mTabWidget->setTabEnabled(i TabIndex,386 for (int iPort = 0; iPort < mTabWidget->count(); ++iPort) 387 { 388 mTabWidget->setTabEnabled(iPort, 357 389 isMachineOffline() || 358 (isMachineInValidMode() && m_cache.m_items[iTabIndex].m_fPortEnabled)); 359 UIMachineSettingsParallel *pTab = qobject_cast<UIMachineSettingsParallel*>(mTabWidget->widget(iTabIndex)); 360 Assert(pTab); 390 (isMachineInValidMode() && m_cache.child(iPort).base().m_fPortEnabled)); 391 UIMachineSettingsParallel *pTab = qobject_cast<UIMachineSettingsParallel*>(mTabWidget->widget(iPort)); 361 392 pTab->polishTab(); 362 393 } -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsParallel.h
r36357 r36930 28 28 class QITabWidget; 29 29 30 struct UIParallelPortData 30 /* Machine settings / Parallel page / Port data: */ 31 struct UIDataSettingsMachineParallelPort 31 32 { 33 /* Default constructor: */ 34 UIDataSettingsMachineParallelPort() 35 : m_iSlot(-1) 36 , m_fPortEnabled(false) 37 , m_uIRQ(0) 38 , m_uIOBase(0) 39 , m_strPath(QString()) {} 40 /* Functions: */ 41 bool equal(const UIDataSettingsMachineParallelPort &other) const 42 { 43 return (m_iSlot == other.m_iSlot) && 44 (m_fPortEnabled == other.m_fPortEnabled) && 45 (m_uIRQ == other.m_uIRQ) && 46 (m_uIOBase == other.m_uIOBase) && 47 (m_strPath == other.m_strPath); 48 } 49 /* Operators: */ 50 bool operator==(const UIDataSettingsMachineParallelPort &other) const { return equal(other); } 51 bool operator!=(const UIDataSettingsMachineParallelPort &other) const { return !equal(other); } 52 /* Variables: */ 32 53 int m_iSlot; 33 54 bool m_fPortEnabled; … … 36 57 QString m_strPath; 37 58 }; 59 typedef UISettingsCache<UIDataSettingsMachineParallelPort> UICacheSettingsMachineParallelPort; 38 60 39 /* Machine settings / Parallel page / Cache: */40 struct UI SettingsCacheMachineParallel61 /* Machine settings / Parallel page / Ports data: */ 62 struct UIDataSettingsMachineParallel 41 63 { 42 QList<UIParallelPortData> m_items; 64 /* Default constructor: */ 65 UIDataSettingsMachineParallel() {} 66 /* Operators: */ 67 bool operator==(const UIDataSettingsMachineParallel& /* other */) const { return true; } 68 bool operator!=(const UIDataSettingsMachineParallel& /* other */) const { return false; } 43 69 }; 70 typedef UISettingsCachePool<UIDataSettingsMachineParallel, UICacheSettingsMachineParallelPort> UICacheSettingsMachineParallel; 44 71 45 72 class UIMachineSettingsParallel : public QIWithRetranslateUI<QWidget>, … … 54 81 void polishTab(); 55 82 56 void fetchPortData(const UI ParallelPortData &data);57 void uploadPortData(UI ParallelPortData &data);83 void fetchPortData(const UICacheSettingsMachineParallelPort &portCache); 84 void uploadPortData(UICacheSettingsMachineParallelPort &portCache); 58 85 59 86 void setValidator (QIWidgetValidator *aVal); … … 117 144 QITabWidget *mTabWidget; 118 145 119 /* Internals: */120 UI SettingsCacheMachineParallel m_cache;146 /* Cache: */ 147 UICacheSettingsMachineParallel m_cache; 121 148 }; 122 149
Note:
See TracChangeset
for help on using the changeset viewer.