23 #include "iwadpicker.h" 24 #include "ui_iwadpicker.h" 26 #include "configuration/doomseekerconfig.h" 27 #include "pathfinder/pathfinder.h" 28 #include "pathfinder/wadpathfinder.h" 29 #include "strings.hpp" 30 #include <QFileDialog> 33 DClass<IwadPicker> :
public Ui::IwadPicker
46 IwadPicker::~IwadPicker()
50 void IwadPicker::addIwad(
const QString &path)
52 if (path.trimmed().isEmpty())
55 for (
int i = 0; i < d->cboIwad->count(); ++i)
57 if (d->cboIwad->itemText(i).compare(path) == 0)
59 d->cboIwad->setCurrentIndex(i);
65 d->cboIwad->setCurrentIndex(d->cboIwad->count() - 1);
68 void IwadPicker::browse()
70 QString dialogDir = gConfig.doomseeker.previousCreateServerWadDir;
71 QString strFile = QFileDialog::getOpenFileName(
this, tr(
"Doomseeker - select IWAD"), dialogDir);
73 if (!strFile.isEmpty())
75 QFileInfo fi(strFile);
76 gConfig.doomseeker.previousCreateServerWadDir = fi.absolutePath();
82 QString IwadPicker::currentIwad()
const 84 return d->cboIwad->currentText();
87 void IwadPicker::loadIwads()
89 const QString iwads[] = {
90 "doom.wad",
"doom1.wad",
"doom2.wad",
91 "tnt.wad",
"plutonia.wad",
"heretic.wad",
92 "hexen.wad",
"freedoom.wad",
"freedm.wad",
93 "freedoom1.wad",
"freedoom2.wad",
"strife1.wad",
"" 96 QString currentSelection = d->cboIwad->currentText();
98 for (
int i = 0; !iwads[i].isEmpty(); ++i)
102 QString path = wadPathFinder.find(iwads[i]).path();
104 d->cboIwad->addItem(path);
106 if (!currentSelection.isEmpty())
108 int selectionIdx = d->cboIwad->findText(currentSelection);
109 if (selectionIdx >= 0)
110 d->cboIwad->setCurrentIndex(selectionIdx);
112 d->cboIwad->setEditText(currentSelection);
116 void IwadPicker::setIwadByName(
const QString &iwad)
118 for (
int i = 0; i < d->cboIwad->count(); ++i)
120 QFileInfo fi(d->cboIwad->itemText(i));
121 if (fi.fileName().compare(iwad, Qt::CaseInsensitive) == 0)
123 d->cboIwad->setCurrentIndex(i);
129 QString path = pathFinder.
findFile(iwad);
132 d->cboIwad->addItem(path);
133 d->cboIwad->setCurrentIndex(d->cboIwad->count() - 1);
Performs a case-insensitive (OS independent) file searches.
void setAllowAliases(bool allowed)
Can disable WAD aliasing for contexts where only specific WADs should be found.
static QString normalizePath(QString path)
Creates a clean path.
Wrapper for PathFinder that specializes in findings WADs.
QString findFile(const QString &fileName) const
Performs a search for a single file.