UI: Optimize several Settings pages to reduce the amount of iterations and repeated calls to functions where multiple there are multiple instances of the same device type, should further speed up te opening of the Settings dialog.
This commit is contained in:
@@ -137,54 +137,63 @@ SettingsNetwork::onCurrentMachineChanged(int machineId)
|
||||
{
|
||||
this->machineId = machineId;
|
||||
|
||||
int c = 0;
|
||||
int selectedRow = 0;
|
||||
int c = 0;
|
||||
int selectedRow = 0;
|
||||
|
||||
for (int i = 0; i < NET_CARD_MAX; ++i) {
|
||||
auto *cbox = findChild<QComboBox *>(QString("comboBoxNIC%1").arg(i + 1));
|
||||
auto *model = cbox->model();
|
||||
auto removeRows = model->rowCount();
|
||||
c = 0;
|
||||
selectedRow = 0;
|
||||
// Network Card
|
||||
QComboBox * cbox_[NET_CARD_MAX] = { 0 };
|
||||
QAbstractItemModel *models[NET_CARD_MAX] = { 0 };
|
||||
int removeRows_[NET_CARD_MAX] = { 0 };
|
||||
int selectedRows[NET_CARD_MAX] = { 0 };
|
||||
int m_has_net = machine_has_flags(machineId, MACHINE_NIC);
|
||||
|
||||
while (true) {
|
||||
/* Skip "internal" if machine doesn't have it or this is not the primary card. */
|
||||
if ((c == 1) && ((i > 0) || (machine_has_flags(machineId, MACHINE_NIC) == 0))) {
|
||||
c++;
|
||||
continue;
|
||||
}
|
||||
for (uint8_t i = 0; i < NET_CARD_MAX; ++i) {
|
||||
cbox_[i] = findChild<QComboBox *>(QString("comboBoxNIC%1").arg(i + 1));
|
||||
models[i] = cbox_[i]->model();
|
||||
removeRows_[i] = models[i]->rowCount();
|
||||
}
|
||||
|
||||
auto name = DeviceConfig::DeviceName(network_card_getdevice(c), network_card_get_internal_name(c), 1);
|
||||
if (name.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
c = 0;
|
||||
while (true) {
|
||||
const QString name = DeviceConfig::DeviceName(network_card_getdevice(c),
|
||||
network_card_get_internal_name(c), 1);
|
||||
|
||||
if (network_card_available(c) && device_is_valid(network_card_getdevice(c), machineId)) {
|
||||
int row = Models::AddEntry(model, name, c);
|
||||
if (c == net_cards_conf[i].device_num) {
|
||||
selectedRow = row - removeRows;
|
||||
if (name.isEmpty())
|
||||
break;
|
||||
|
||||
if (network_card_available(c)) {
|
||||
if (device_is_valid(network_card_getdevice(c), machineId)) {
|
||||
for (uint8_t i = 0; i < NET_CARD_MAX; ++i) {
|
||||
if ((c != 1) || ((i == 0) && m_has_net)) {
|
||||
int row = Models::AddEntry(models[i], name, c);
|
||||
|
||||
if (c == net_cards_conf[i].device_num)
|
||||
selectedRows[i] = row - removeRows_[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
c++;
|
||||
}
|
||||
|
||||
model->removeRows(0, removeRows);
|
||||
cbox->setEnabled(model->rowCount() > 0);
|
||||
cbox->setCurrentIndex(-1);
|
||||
cbox->setCurrentIndex(selectedRow);
|
||||
c++;
|
||||
}
|
||||
|
||||
cbox = findChild<QComboBox *>(QString("comboBoxNet%1").arg(i + 1));
|
||||
model = cbox->model();
|
||||
removeRows = model->rowCount();
|
||||
for (uint8_t i = 0; i < NET_CARD_MAX; ++i) {
|
||||
models[i]->removeRows(0, removeRows_[i]);
|
||||
cbox_[i]->setEnabled(models[i]->rowCount() > 1);
|
||||
cbox_[i]->setCurrentIndex(-1);
|
||||
cbox_[i]->setCurrentIndex(selectedRows[i]);
|
||||
|
||||
auto cbox = findChild<QComboBox *>(QString("comboBoxNet%1").arg(i + 1));
|
||||
auto model = cbox->model();
|
||||
auto removeRows = model->rowCount();
|
||||
Models::AddEntry(model, tr("Null Driver"), NET_TYPE_NONE);
|
||||
Models::AddEntry(model, "SLiRP", NET_TYPE_SLIRP);
|
||||
|
||||
if (network_ndev > 1) {
|
||||
if (network_ndev > 1)
|
||||
Models::AddEntry(model, "PCap", NET_TYPE_PCAP);
|
||||
}
|
||||
if (network_devmap.has_vde) {
|
||||
|
||||
if (network_devmap.has_vde)
|
||||
Models::AddEntry(model, "VDE", NET_TYPE_VDE);
|
||||
}
|
||||
|
||||
model->removeRows(0, removeRows);
|
||||
cbox->setCurrentIndex(cbox->findData(net_cards_conf[i].net_type));
|
||||
@@ -205,6 +214,7 @@ SettingsNetwork::onCurrentMachineChanged(int machineId)
|
||||
model->removeRows(0, removeRows);
|
||||
cbox->setCurrentIndex(selectedRow);
|
||||
}
|
||||
|
||||
if (net_cards_conf[i].net_type == NET_TYPE_VDE) {
|
||||
QString currentVdeSocket = net_cards_conf[i].host_dev_name;
|
||||
auto editline = findChild<QLineEdit *>(QString("socketVDENIC%1").arg(i+1));
|
||||
|
||||
@@ -83,31 +83,45 @@ SettingsOtherPeripherals::onCurrentMachineChanged(int machineId)
|
||||
ui->comboBoxRTC->setCurrentIndex(selectedRow);
|
||||
ui->pushButtonConfigureRTC->setEnabled((isartc_type != 0) && isartc_has_config(isartc_type) && machineHasIsa);
|
||||
|
||||
for (int c = 0; c < ISAMEM_MAX; c++) {
|
||||
auto *cbox = findChild<QComboBox *>(QString("comboBoxCard%1").arg(c + 1));
|
||||
model = cbox->model();
|
||||
d = 0;
|
||||
selectedRow = 0;
|
||||
while (true) {
|
||||
QString name = DeviceConfig::DeviceName(isamem_get_device(d), isamem_get_internal_name(d), 0);
|
||||
if (name.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
// ISA Memory Expansion Card
|
||||
QComboBox * cbox[ISAMEM_MAX] = { 0 };
|
||||
QAbstractItemModel *models[ISAMEM_MAX] = { 0 };
|
||||
int removeRows_[ISAMEM_MAX] = { 0 };
|
||||
int selectedRows[ISAMEM_MAX] = { 0 };
|
||||
|
||||
if (!device_is_valid(isamem_get_device(d), machineId)) {
|
||||
break;
|
||||
}
|
||||
for (uint8_t c = 0; c < ISAMEM_MAX; ++c) {
|
||||
cbox[c] = findChild<QComboBox *>(QString("comboBoxCard%1").arg(c + 1));
|
||||
models[c] = cbox[c]->model();
|
||||
removeRows_[c] = models[c]->rowCount();
|
||||
}
|
||||
|
||||
int row = Models::AddEntry(model, name, d);
|
||||
if (d == isamem_type[c]) {
|
||||
selectedRow = row;
|
||||
d = 0;
|
||||
while (true) {
|
||||
const QString name = DeviceConfig::DeviceName(isamem_get_device(d),
|
||||
isamem_get_internal_name(d), 0);
|
||||
|
||||
if (name.isEmpty())
|
||||
break;
|
||||
|
||||
if (device_is_valid(isamem_get_device(d), machineId)) {
|
||||
for (uint8_t c = 0; c < ISAMEM_MAX; ++c) {
|
||||
int row = Models::AddEntry(models[c], name, d);
|
||||
|
||||
if (d == isamem_type[c])
|
||||
selectedRows[c] = row - removeRows_[c];
|
||||
}
|
||||
++d;
|
||||
}
|
||||
cbox->setCurrentIndex(-1);
|
||||
cbox->setCurrentIndex(selectedRow);
|
||||
cbox->setEnabled(machineHasIsa);
|
||||
findChild<QPushButton *>(QString("pushButtonConfigureCard%1").arg(c + 1))->setEnabled((isamem_type[c] != 0) && isamem_has_config(isamem_type[c]) && machineHasIsa);
|
||||
|
||||
d++;
|
||||
}
|
||||
|
||||
for (uint8_t c = 0; c < ISAMEM_MAX; ++c) {
|
||||
models[c]->removeRows(0, removeRows_[c]);
|
||||
cbox[c]->setEnabled(models[c]->rowCount() > 1);
|
||||
cbox[c]->setCurrentIndex(-1);
|
||||
cbox[c]->setCurrentIndex(selectedRows[c]);
|
||||
findChild<QPushButton *>(QString("pushButtonConfigureCard%1").arg(c + 1))->setEnabled((isamem_type[c] != 0) &&
|
||||
isamem_has_config(isamem_type[c]) && machineHasIsa);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -73,34 +73,49 @@ SettingsPorts::onCurrentMachineChanged(int machineId)
|
||||
{
|
||||
this->machineId = machineId;
|
||||
|
||||
for (int i = 0; i < PARALLEL_MAX; i++) {
|
||||
auto *cbox = findChild<QComboBox *>(QString("comboBoxLpt%1").arg(i + 1));
|
||||
auto *model = cbox->model();
|
||||
const auto removeRows = model->rowCount();
|
||||
int c = 0;
|
||||
int selectedRow = 0;
|
||||
while (true) {
|
||||
const char *lptName = lpt_device_get_name(c);
|
||||
if (lptName == nullptr) {
|
||||
break;
|
||||
}
|
||||
int c = 0;
|
||||
|
||||
int row = Models::AddEntry(model, tr(lptName), c);
|
||||
if (c == lpt_ports[i].device) {
|
||||
selectedRow = row - removeRows;
|
||||
}
|
||||
c++;
|
||||
// LPT Device
|
||||
QComboBox * cbox[PARALLEL_MAX] = { 0 };
|
||||
QAbstractItemModel *models[PARALLEL_MAX] = { 0 };
|
||||
int removeRows_[PARALLEL_MAX] = { 0 };
|
||||
int selectedRows[PARALLEL_MAX] = { 0 };
|
||||
|
||||
for (uint8_t i = 0; i < PARALLEL_MAX; ++i) {
|
||||
cbox[i] = findChild<QComboBox *>(QString("comboBoxLpt%1").arg(i + 1));
|
||||
models[i] = cbox[i]->model();
|
||||
removeRows_[i] = models[i]->rowCount();
|
||||
}
|
||||
|
||||
while (true) {
|
||||
const char *lptName = lpt_device_get_name(c);
|
||||
|
||||
if (lptName == nullptr)
|
||||
break;
|
||||
|
||||
const QString name = tr(lptName);
|
||||
|
||||
for (uint8_t i = 0; i < PARALLEL_MAX; ++i) {
|
||||
int row = Models::AddEntry(models[i], name, c);
|
||||
|
||||
if (c == lpt_ports[i].device)
|
||||
selectedRows[i] = row - removeRows_[i];
|
||||
}
|
||||
model->removeRows(0, removeRows);
|
||||
cbox->setEnabled(model->rowCount() > 0);
|
||||
cbox->setCurrentIndex(-1);
|
||||
cbox->setCurrentIndex(selectedRow);
|
||||
|
||||
c++;
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < PARALLEL_MAX; ++i) {
|
||||
models[i]->removeRows(0, removeRows_[i]);
|
||||
cbox[i]->setEnabled(models[i]->rowCount() > 1);
|
||||
cbox[i]->setCurrentIndex(-1);
|
||||
cbox[i]->setCurrentIndex(selectedRows[i]);
|
||||
|
||||
auto *checkBox = findChild<QCheckBox *>(QString("checkBoxParallel%1").arg(i + 1));
|
||||
if (checkBox != NULL)
|
||||
checkBox->setChecked(lpt_ports[i].enabled > 0);
|
||||
if (cbox != NULL)
|
||||
cbox->setEnabled(lpt_ports[i].enabled > 0);
|
||||
if (cbox[i] != NULL)
|
||||
cbox[i]->setEnabled(lpt_ports[i].enabled > 0);
|
||||
}
|
||||
|
||||
for (int i = 0; i < SERIAL_MAX; i++) {
|
||||
|
||||
@@ -73,46 +73,51 @@ SettingsSound::onCurrentMachineChanged(const int machineId)
|
||||
{
|
||||
this->machineId = machineId;
|
||||
|
||||
int c;
|
||||
int selectedRow;
|
||||
int c;
|
||||
int selectedRow;
|
||||
|
||||
// Sound Card
|
||||
QComboBox * cbox[SOUND_CARD_MAX] = { 0 };
|
||||
QAbstractItemModel *models[SOUND_CARD_MAX] = { 0 };
|
||||
int removeRows_[SOUND_CARD_MAX] = { 0 };
|
||||
int selectedRows[SOUND_CARD_MAX] = { 0 };
|
||||
int m_has_snd = machine_has_flags(machineId, MACHINE_SOUND);
|
||||
|
||||
for (uint8_t i = 0; i < SOUND_CARD_MAX; ++i) {
|
||||
QComboBox *cbox = findChild<QComboBox *>(QString("comboBoxSoundCard%1").arg(i + 1));
|
||||
c = 0;
|
||||
auto model = cbox->model();
|
||||
auto removeRows = model->rowCount();
|
||||
selectedRow = 0;
|
||||
cbox[i] = findChild<QComboBox *>(QString("comboBoxSoundCard%1").arg(i + 1));
|
||||
models[i] = cbox[i]->model();
|
||||
removeRows_[i] = models[i]->rowCount();
|
||||
}
|
||||
|
||||
while (true) {
|
||||
/* Skip "internal" if machine doesn't have it or this is not the primary card. */
|
||||
if ((c == 1) && ((i > 0) || (machine_has_flags(machineId, MACHINE_SOUND) == 0))) {
|
||||
c++;
|
||||
continue;
|
||||
}
|
||||
c = 0;
|
||||
while (true) {
|
||||
const QString name = DeviceConfig::DeviceName(sound_card_getdevice(c),
|
||||
sound_card_get_internal_name(c), 1);
|
||||
|
||||
const QString name = DeviceConfig::DeviceName(sound_card_getdevice(c), sound_card_get_internal_name(c), 1);
|
||||
if (name.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
if (name.isEmpty())
|
||||
break;
|
||||
|
||||
if (sound_card_available(c)) {
|
||||
const device_t *sound_dev = sound_card_getdevice(c);
|
||||
if (device_is_valid(sound_dev, machineId)) {
|
||||
int row = Models::AddEntry(model, name, c);
|
||||
if (c == sound_card_current[i]) {
|
||||
selectedRow = row - removeRows;
|
||||
if (sound_card_available(c)) {
|
||||
if (device_is_valid(sound_card_getdevice(c), machineId)) {
|
||||
for (uint8_t i = 0; i < SOUND_CARD_MAX; ++i) {
|
||||
if ((c != 1) || ((i == 0) && m_has_snd)) {
|
||||
int row = Models::AddEntry(models[i], name, c);
|
||||
|
||||
if (c == sound_card_current[i])
|
||||
selectedRows[i] = row - removeRows_[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
c++;
|
||||
}
|
||||
|
||||
model->removeRows(0, removeRows);
|
||||
cbox->setEnabled(model->rowCount() > 0);
|
||||
cbox->setCurrentIndex(-1);
|
||||
cbox->setCurrentIndex(selectedRow);
|
||||
c++;
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < SOUND_CARD_MAX; ++i) {
|
||||
models[i]->removeRows(0, removeRows_[i]);
|
||||
cbox[i]->setEnabled(models[i]->rowCount() > 1);
|
||||
cbox[i]->setCurrentIndex(-1);
|
||||
cbox[i]->setCurrentIndex(selectedRows[i]);
|
||||
}
|
||||
|
||||
// Midi Out
|
||||
|
||||
@@ -171,35 +171,48 @@ SettingsStorageControllers::onCurrentMachineChanged(int machineId)
|
||||
ui->comboBoxCDInterface->setCurrentIndex(-1);
|
||||
ui->comboBoxCDInterface->setCurrentIndex(selectedRow);
|
||||
|
||||
// SCSI Card
|
||||
QComboBox * cbox[SCSI_CARD_MAX] = { 0 };
|
||||
QAbstractItemModel *models[SCSI_CARD_MAX] = { 0 };
|
||||
int removeRows_[SCSI_CARD_MAX] = { 0 };
|
||||
int selectedRows[SCSI_CARD_MAX] = { 0 };
|
||||
int m_has_scsi = machine_has_flags(machineId, MACHINE_SCSI);
|
||||
|
||||
for (uint8_t i = 0; i < SCSI_CARD_MAX; ++i) {
|
||||
QComboBox *cbox = findChild<QComboBox *>(QString("comboBoxSCSI%1").arg(i + 1));
|
||||
c = 0;
|
||||
model = cbox->model();
|
||||
removeRows = model->rowCount();
|
||||
selectedRow = 0;
|
||||
cbox[i] = findChild<QComboBox *>(QString("comboBoxSCSI%1").arg(i + 1));
|
||||
models[i] = cbox[i]->model();
|
||||
removeRows_[i] = models[i]->rowCount();
|
||||
}
|
||||
|
||||
while (true) {
|
||||
QString name = DeviceConfig::DeviceName(scsi_card_getdevice(c), scsi_card_get_internal_name(c), 1);
|
||||
if (name.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
c = 0;
|
||||
while (true) {
|
||||
const QString name = DeviceConfig::DeviceName(scsi_card_getdevice(c),
|
||||
scsi_card_get_internal_name(c), 1);
|
||||
|
||||
if (scsi_card_available(c)) {
|
||||
const device_t *scsi_dev = scsi_card_getdevice(c);
|
||||
if (device_is_valid(scsi_dev, machineId)) {
|
||||
int row = Models::AddEntry(model, name, c);
|
||||
if (c == scsi_card_current[i]) {
|
||||
selectedRow = row - removeRows;
|
||||
if (name.isEmpty())
|
||||
break;
|
||||
|
||||
if (scsi_card_available(c)) {
|
||||
if (device_is_valid(scsi_card_getdevice(c), machineId)) {
|
||||
for (uint8_t i = 0; i < SCSI_CARD_MAX; ++i) {
|
||||
if ((c != 1) || ((i == 0) && m_has_scsi)) {
|
||||
int row = Models::AddEntry(models[i], name, c);
|
||||
|
||||
if (c == scsi_card_current[i])
|
||||
selectedRows[i] = row - removeRows_[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
c++;
|
||||
}
|
||||
|
||||
model->removeRows(0, removeRows);
|
||||
cbox->setEnabled(model->rowCount() > 0);
|
||||
cbox->setCurrentIndex(-1);
|
||||
cbox->setCurrentIndex(selectedRow);
|
||||
c++;
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < SCSI_CARD_MAX; ++i) {
|
||||
models[i]->removeRows(0, removeRows_[i]);
|
||||
cbox[i]->setEnabled(models[i]->rowCount() > 1);
|
||||
cbox[i]->setCurrentIndex(-1);
|
||||
cbox[i]->setCurrentIndex(selectedRows[i]);
|
||||
}
|
||||
|
||||
int is_at = IS_AT(machineId);
|
||||
|
||||
Reference in New Issue
Block a user