Skip to content

Commit

Permalink
Demodialog now pre-selects the iwad and files that have already been …
Browse files Browse the repository at this point in the history
…found
  • Loading branch information
Pedro-Beirao committed May 25, 2024
1 parent 5be9ac2 commit 59e135b
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/demodialog.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "demodialog.h"
#include "mainwindow.h"
#include <mainwindow.h>

demodialog::demodialog(QString missing_iwad, QStringList missing_files, QWidget *parent) : QDialog(parent)
{
Expand All @@ -22,11 +22,12 @@ demodialog::demodialog(QString missing_iwad, QStringList missing_files, QWidget
mainLayout->addWidget(iwad_label, 1, 0);

iwad_comboBox = new QComboBox();
QFileInfoList IWADs = findIwads();
for (int i = 0; i < IWADs.count(); i++)
for (int i = 0; i < MainWindow::pMainWindow->iwad_comboBox()->count(); i++)
{
iwad_comboBox->addItem(IWADs[i].baseName().toLower());
iwad_comboBox->addItem(MainWindow::pMainWindow->iwad_comboBox()->itemText(i));
iwad_comboBox->setItemData(iwad_comboBox->count() - 1, MainWindow::pMainWindow->iwad_comboBox()->itemData(i, Qt::ToolTipRole), Qt::ToolTipRole);
}
iwad_comboBox->setCurrentIndex(MainWindow::pMainWindow->iwad_comboBox()->currentIndex());
mainLayout->addWidget(iwad_comboBox, 1, 1, 1, 2);

QLabel *files_label = new QLabel("Files:");
Expand All @@ -44,6 +45,7 @@ demodialog::demodialog(QString missing_iwad, QStringList missing_files, QWidget
files_listWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
files_listWidget->verticalHeader()->setSectionResizeMode(QHeaderView::Stretch);
files_listWidget->resizeColumnsToContents();
files_listWidget->setSelectionMode(QAbstractItemView::MultiSelection);

for (int j = 0; j < 2; j++)
{
Expand All @@ -59,16 +61,24 @@ demodialog::demodialog(QString missing_iwad, QStringList missing_files, QWidget
newItem->setToolTip(files[i + j * (files.size() / 2)].absoluteFilePath());
newItem->setFlags(newItem->flags() & ~Qt::ItemIsEditable);
files_listWidget->setItem(i, j, newItem);

for (int a = 0; a < MainWindow::pMainWindow->wads_listWidget()->count(); a++)
{
if (MainWindow::pMainWindow->wads_listWidget()->item(a)->data(Qt::ToolTipRole) == newItem->data(Qt::ToolTipRole))
{
newItem->setSelected(true);
}
}
}
}

files_listWidget->setSelectionMode(QAbstractItemView::MultiSelection);
connect(files_listWidget, &QTableWidget::itemSelectionChanged, this, &demodialog::update_selected_count);
mainLayout->addWidget(files_listWidget, 3, 0, 1, 3);

selected_count = new QLabel("0 files selected");
mainLayout->addWidget(selected_count, 4, 0, 1, 3);

update_selected_count();
connect(files_listWidget, &QTableWidget::itemSelectionChanged, this, &demodialog::update_selected_count);

QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
Expand Down

0 comments on commit 59e135b

Please sign in to comment.