Clean QT HDD UI
This commit is contained in:
@@ -49,9 +49,8 @@ static void
|
|||||||
normalize_hd_list()
|
normalize_hd_list()
|
||||||
{
|
{
|
||||||
hard_disk_t ihdd[HDD_NUM];
|
hard_disk_t ihdd[HDD_NUM];
|
||||||
int j;
|
int j = 0;
|
||||||
|
|
||||||
j = 0;
|
|
||||||
memset(ihdd, 0x00, HDD_NUM * sizeof(hard_disk_t));
|
memset(ihdd, 0x00, HDD_NUM * sizeof(hard_disk_t));
|
||||||
|
|
||||||
for (uint8_t i = 0; i < HDD_NUM; i++) {
|
for (uint8_t i = 0; i < HDD_NUM; i++) {
|
||||||
@@ -75,8 +74,8 @@ static void
|
|||||||
addRow(QAbstractItemModel *model, hard_disk_t *hd)
|
addRow(QAbstractItemModel *model, hard_disk_t *hd)
|
||||||
{
|
{
|
||||||
const QString userPath = usr_path;
|
const QString userPath = usr_path;
|
||||||
|
|
||||||
int row = model->rowCount();
|
int row = model->rowCount();
|
||||||
|
|
||||||
model->insertRow(row);
|
model->insertRow(row);
|
||||||
|
|
||||||
QString busName = Harddrives::BusChannelName(hd->bus_type, hd->channel);
|
QString busName = Harddrives::BusChannelName(hd->bus_type, hd->channel);
|
||||||
@@ -88,11 +87,11 @@ addRow(QAbstractItemModel *model, hard_disk_t *hd)
|
|||||||
model->setData(model->index(row, ColumnBus), hd->channel, DataBusChannelPrevious);
|
model->setData(model->index(row, ColumnBus), hd->channel, DataBusChannelPrevious);
|
||||||
Harddrives::busTrackClass->device_track(1, DEV_HDD, hd->bus_type, hd->channel);
|
Harddrives::busTrackClass->device_track(1, DEV_HDD, hd->bus_type, hd->channel);
|
||||||
QString fileName = hd->fn;
|
QString fileName = hd->fn;
|
||||||
if (fileName.startsWith(userPath, Qt::CaseInsensitive)) {
|
if (fileName.startsWith(userPath, Qt::CaseInsensitive))
|
||||||
model->setData(model->index(row, ColumnFilename), fileName.mid(userPath.size()));
|
model->setData(model->index(row, ColumnFilename), fileName.mid(userPath.size()));
|
||||||
} else {
|
else
|
||||||
model->setData(model->index(row, ColumnFilename), fileName);
|
model->setData(model->index(row, ColumnFilename), fileName);
|
||||||
}
|
|
||||||
model->setData(model->index(row, ColumnFilename), fileName, Qt::UserRole);
|
model->setData(model->index(row, ColumnFilename), fileName, Qt::UserRole);
|
||||||
|
|
||||||
model->setData(model->index(row, ColumnCylinders), hd->tracks);
|
model->setData(model->index(row, ColumnCylinders), hd->tracks);
|
||||||
@@ -120,10 +119,9 @@ SettingsHarddisks::SettingsHarddisks(QWidget *parent)
|
|||||||
ui->tableView->setModel(model);
|
ui->tableView->setModel(model);
|
||||||
|
|
||||||
for (int i = 0; i < HDD_NUM; i++) {
|
for (int i = 0; i < HDD_NUM; i++) {
|
||||||
if (hdd[i].bus_type > 0) {
|
if (hdd[i].bus_type > 0)
|
||||||
addRow(model, &hdd[i]);
|
addRow(model, &hdd[i]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (model->rowCount() == HDD_NUM) {
|
if (model->rowCount() == HDD_NUM) {
|
||||||
ui->pushButtonNew->setEnabled(false);
|
ui->pushButtonNew->setEnabled(false);
|
||||||
ui->pushButtonExisting->setEnabled(false);
|
ui->pushButtonExisting->setEnabled(false);
|
||||||
@@ -176,9 +174,8 @@ void SettingsHarddisks::reloadBusChannels() {
|
|||||||
void
|
void
|
||||||
SettingsHarddisks::on_comboBoxBus_currentIndexChanged(int index)
|
SettingsHarddisks::on_comboBoxBus_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
if (index < 0) {
|
if (index < 0)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
buschangeinprogress = true;
|
buschangeinprogress = true;
|
||||||
auto idx = ui->tableView->selectionModel()->currentIndex();
|
auto idx = ui->tableView->selectionModel()->currentIndex();
|
||||||
@@ -226,9 +223,8 @@ SettingsHarddisks::on_comboBoxBus_currentIndexChanged(int index)
|
|||||||
void
|
void
|
||||||
SettingsHarddisks::on_comboBoxChannel_currentIndexChanged(int index)
|
SettingsHarddisks::on_comboBoxChannel_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
if (index < 0) {
|
if (index < 0)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
auto idx = ui->tableView->selectionModel()->currentIndex();
|
auto idx = ui->tableView->selectionModel()->currentIndex();
|
||||||
if (idx.isValid()) {
|
if (idx.isValid()) {
|
||||||
@@ -250,17 +246,15 @@ SettingsHarddisks::enableCurrentlySelectedChannel()
|
|||||||
const auto *item_model = qobject_cast<QStandardItemModel*>(ui->comboBoxChannel->model());
|
const auto *item_model = qobject_cast<QStandardItemModel*>(ui->comboBoxChannel->model());
|
||||||
const auto index = ui->comboBoxChannel->currentIndex();
|
const auto index = ui->comboBoxChannel->currentIndex();
|
||||||
auto *item = item_model->item(index);
|
auto *item = item_model->item(index);
|
||||||
if(item) {
|
if(item)
|
||||||
item->setEnabled(true);
|
item->setEnabled(true);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SettingsHarddisks::on_comboBoxSpeed_currentIndexChanged(int index)
|
SettingsHarddisks::on_comboBoxSpeed_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
if (index < 0) {
|
if (index < 0)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
auto idx = ui->tableView->selectionModel()->currentIndex();
|
auto idx = ui->tableView->selectionModel()->currentIndex();
|
||||||
if (idx.isValid()) {
|
if (idx.isValid()) {
|
||||||
@@ -288,20 +282,19 @@ SettingsHarddisks::onTableRowChanged(const QModelIndex ¤t)
|
|||||||
|
|
||||||
auto *model = ui->comboBoxBus->model();
|
auto *model = ui->comboBoxBus->model();
|
||||||
auto match = model->match(model->index(0, 0), Qt::UserRole, bus);
|
auto match = model->match(model->index(0, 0), Qt::UserRole, bus);
|
||||||
if (!match.isEmpty()) {
|
if (!match.isEmpty())
|
||||||
ui->comboBoxBus->setCurrentIndex(match.first().row());
|
ui->comboBoxBus->setCurrentIndex(match.first().row());
|
||||||
}
|
|
||||||
model = ui->comboBoxChannel->model();
|
model = ui->comboBoxChannel->model();
|
||||||
match = model->match(model->index(0, 0), Qt::UserRole, busChannel);
|
match = model->match(model->index(0, 0), Qt::UserRole, busChannel);
|
||||||
if (!match.isEmpty()) {
|
if (!match.isEmpty())
|
||||||
ui->comboBoxChannel->setCurrentIndex(match.first().row());
|
ui->comboBoxChannel->setCurrentIndex(match.first().row());
|
||||||
}
|
|
||||||
|
|
||||||
model = ui->comboBoxSpeed->model();
|
model = ui->comboBoxSpeed->model();
|
||||||
match = model->match(model->index(0, 0), Qt::UserRole, speed);
|
match = model->match(model->index(0, 0), Qt::UserRole, speed);
|
||||||
if (!match.isEmpty()) {
|
if (!match.isEmpty())
|
||||||
ui->comboBoxSpeed->setCurrentIndex(match.first().row());
|
ui->comboBoxSpeed->setCurrentIndex(match.first().row());
|
||||||
}
|
|
||||||
reloadBusChannels();
|
reloadBusChannels();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -358,9 +351,8 @@ void
|
|||||||
SettingsHarddisks::on_pushButtonRemove_clicked()
|
SettingsHarddisks::on_pushButtonRemove_clicked()
|
||||||
{
|
{
|
||||||
auto idx = ui->tableView->selectionModel()->currentIndex();
|
auto idx = ui->tableView->selectionModel()->currentIndex();
|
||||||
if (!idx.isValid()) {
|
if (!idx.isValid())
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
auto *model = ui->tableView->model();
|
auto *model = ui->tableView->model();
|
||||||
const auto col = idx.siblingAtColumn(ColumnBus);
|
const auto col = idx.siblingAtColumn(ColumnBus);
|
||||||
|
|||||||
@@ -21,14 +21,13 @@ signals:
|
|||||||
void driveChannelChanged();
|
void driveChannelChanged();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void on_comboBoxBus_currentIndexChanged(int index);
|
||||||
void on_comboBoxChannel_currentIndexChanged(int index);
|
void on_comboBoxChannel_currentIndexChanged(int index);
|
||||||
void on_comboBoxSpeed_currentIndexChanged(int index);
|
void on_comboBoxSpeed_currentIndexChanged(int index);
|
||||||
|
|
||||||
private slots:
|
|
||||||
void on_pushButtonRemove_clicked();
|
|
||||||
void on_pushButtonExisting_clicked();
|
|
||||||
void on_pushButtonNew_clicked();
|
void on_pushButtonNew_clicked();
|
||||||
void on_comboBoxBus_currentIndexChanged(int index);
|
void on_pushButtonExisting_clicked();
|
||||||
|
void on_pushButtonRemove_clicked();
|
||||||
|
|
||||||
void onTableRowChanged(const QModelIndex ¤t);
|
void onTableRowChanged(const QModelIndex ¤t);
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayoutHardDisks">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="labelBus">
|
<widget class="QLabel" name="labelBus">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
|||||||
Reference in New Issue
Block a user