23 #include "cfgfilepaths.h"
24 #include "ui_cfgfilepaths.h"
25 #include "configuration/doomseekerconfig.h"
26 #include "pathfinder/filesearchpath.h"
27 #include <QFileDialog>
28 #include <QStandardItem>
30 const int COL_PATH = 0;
31 const int COL_RECURSE = 1;
33 DClass<CFGFilePaths> :
public Ui::CFGFilePaths
44 QStandardItemModel* model =
new QStandardItemModel(
this);
45 d->lstIwadAndPwadPaths->setModel(model);
48 labels << tr(
"Path") << tr(
"Recurse");
49 model->setHorizontalHeaderLabels(labels);
51 QHeaderView* header = d->lstIwadAndPwadPaths->horizontalHeader();
52 header->setResizeMode(COL_PATH, QHeaderView::Stretch);
53 header->setResizeMode(COL_RECURSE, QHeaderView::ResizeToContents);
55 connect(d->btnAddWadPath, SIGNAL( clicked() ),
this, SLOT( btnAddWadPath_Click()) );
56 connect(d->btnRemoveWadPath, SIGNAL( clicked() ),
this, SLOT( btnRemoveWadPath_Click()) );
59 CFGFilePaths::~CFGFilePaths()
65 if (fileSearchPath.isValid())
70 QStandardItemModel* model =
static_cast<QStandardItemModel*
>(d->lstIwadAndPwadPaths->model());
72 if (!isPathAlreadyDefined(fileSearchPath.path()))
74 QStandardItem* path =
new QStandardItem(fileSearchPath.path());
75 path->setData(fileSearchPath.path(), Qt::ToolTipRole);
76 QStandardItem* recurse =
new QStandardItem();
77 recurse->setCheckable(
true);
78 recurse->setCheckState(fileSearchPath.isRecursive() ? Qt::Checked : Qt::Unchecked);
79 recurse->setData(Qt::AlignCenter, Qt::TextAlignmentRole);
80 QList<QStandardItem*> items;
83 model->appendRow(items);
84 d->lstIwadAndPwadPaths->resizeRowsToContents();
88 void CFGFilePaths::btnAddWadPath_Click()
90 QString strDir = QFileDialog::getExistingDirectory(
this, tr(
"Doomseeker - Add wad path"));
94 void CFGFilePaths::btnRemoveWadPath_Click()
96 QItemSelectionModel* selModel = d->lstIwadAndPwadPaths->selectionModel();
97 QModelIndexList indexList = selModel->selectedRows();
100 QStandardItemModel* model =
static_cast<QStandardItemModel*
>(d->lstIwadAndPwadPaths->model());
101 QList<QStandardItem*> itemList;
102 for (
int i = 0; i < indexList.count(); ++i)
104 itemList << model->itemFromIndex(indexList[i]);
107 for (
int i = 0; i < itemList.count(); ++i)
109 QModelIndex index = model->indexFromItem(itemList[i]);
110 model->removeRow(index.row());
116 return QApplication::style()->standardIcon(QStyle::SP_DirOpenIcon);
119 bool CFGFilePaths::isPathAlreadyDefined(
const QString& path)
121 QStandardItemModel* model =
static_cast<QStandardItemModel*
>(d->lstIwadAndPwadPaths->model());
123 Qt::CaseSensitivity caseSensitivity;
126 caseSensitivity = Qt::CaseInsensitive;
128 caseSensitivity = Qt::CaseSensitive;
131 for(
int i = 0; i < model->rowCount(); ++i)
133 QStandardItem* item = model->item(i);
134 QString dir = item->text();
136 if (dir.compare(path, caseSensitivity) == 0)
147 const QList<FileSearchPath>& wadPaths = gConfig.doomseeker.wadPaths;
148 for (
int i = 0; i < wadPaths.count(); ++i)
150 addPath(wadPaths[i]);
153 d->cbTellMeWhereAreMyWads->setChecked(gConfig.doomseeker.bTellMeWhereAreTheWADsWhenIHoverCursorOverWADSColumn);
158 QList<FileSearchPath> wadPaths;
160 QStandardItemModel* model =
static_cast<QStandardItemModel*
>(d->lstIwadAndPwadPaths->model());
162 for(
int i = 0; i < model->rowCount(); ++i)
164 QStandardItem* itemPath = model->item(i, COL_PATH);
165 QStandardItem* itemRecurse = model->item(i, COL_RECURSE);
167 fileSearchPath.setRecursive(itemRecurse->checkState() == Qt::Checked);
168 wadPaths << fileSearchPath;
172 gConfig.doomseeker.wadPaths = wadPaths;
173 gConfig.doomseeker.bTellMeWhereAreTheWADsWhenIHoverCursorOverWADSColumn = d->cbTellMeWhereAreMyWads->isChecked();
void saveSettings()
Reimplement this to write settings to config from widgets.
QIcon icon() const
Reimplement this to return a displayable icon for the ConfigurationBaseBox.
void readSettings()
Reimplement this to read settings from config into widgets.
Base class for configuration pages.