qt: Disable bus channels that are currently in use

This commit is contained in:
cold-brewed
2024-03-24 12:07:58 -04:00
parent 955297b9c4
commit 373fe0f258
10 changed files with 126 additions and 5 deletions

View File

@@ -263,6 +263,7 @@ SettingsFloppyCDROM::onCDROMRowChanged(const QModelIndex &current)
ui->comboBoxSpeed->setCurrentIndex(speed == 0 ? 7 : speed - 1);
ui->comboBoxCDROMType->setCurrentIndex(type);
enableCurrentlySelectedChannel();
}
void
@@ -288,6 +289,13 @@ SettingsFloppyCDROM::on_comboBoxFloppyType_activated(int index)
ui->tableViewFloppy->selectionModel()->currentIndex(), index);
}
void SettingsFloppyCDROM::reloadBusChannels() {
auto selected = ui->comboBoxChannel->currentIndex();
Harddrives::populateBusChannels(ui->comboBoxChannel->model(), ui->comboBoxBus->currentData().toInt(), Harddrives::busTrackClass);
ui->comboBoxChannel->setCurrentIndex(selected);
enableCurrentlySelectedChannel();
}
void
SettingsFloppyCDROM::on_comboBoxBus_currentIndexChanged(int index)
{
@@ -298,7 +306,7 @@ SettingsFloppyCDROM::on_comboBoxBus_currentIndexChanged(int index)
ui->comboBoxSpeed->setEnabled((bus == CDROM_BUS_MITSUMI) ? 0 : enabled);
ui->comboBoxCDROMType->setEnabled((bus == CDROM_BUS_MITSUMI) ? 0 : enabled);
Harddrives::populateBusChannels(ui->comboBoxChannel->model(), bus);
Harddrives::populateBusChannels(ui->comboBoxChannel->model(), bus, Harddrives::busTrackClass);
}
}
@@ -362,6 +370,17 @@ SettingsFloppyCDROM::on_comboBoxBus_activated(int)
ui->comboBoxCDROMType->currentData().toUInt());
}
void
SettingsFloppyCDROM::enableCurrentlySelectedChannel()
{
const auto *item_model = qobject_cast<QStandardItemModel*>(ui->comboBoxChannel->model());
const auto index = ui->comboBoxChannel->currentIndex();
auto *item = item_model->item(index);
if(item) {
item->setEnabled(true);
}
}
void
SettingsFloppyCDROM::on_comboBoxChannel_activated(int)
{
@@ -376,6 +395,7 @@ SettingsFloppyCDROM::on_comboBoxChannel_activated(int)
Harddrives::busTrackClass->device_track(1, DEV_CDROM, ui->tableViewCDROM->model()->data(i,
Qt::UserRole).toInt(), ui->tableViewCDROM->model()->data(i,
Qt::UserRole + 1).toInt());
emit cdromChannelChanged();
}
void