23 #include "cfgwadseekersites.h"
24 #include "ui_cfgwadseekersites.h"
25 #include "configuration/doomseekerconfig.h"
26 #include "wadseeker/wadseeker.h"
30 #include <QFileDialog>
31 #include <QMessageBox>
32 #include <QStandardItemModel>
35 DClass<CFGWadseekerSites> :
public Ui::CFGWadseekerSites
46 d->lstUrls->setModel(
new QStandardItemModel());
48 connect(d->btnUrlAdd, SIGNAL( clicked() ),
this, SLOT( btnUrlAddClicked() ) );
49 connect(d->btnUrlDefault, SIGNAL( clicked() ),
this, SLOT( btnUrlDefaultClicked() ) );
50 connect(d->btnUrlRemove, SIGNAL( clicked() ),
this, SLOT( btnUrlRemoveClicked() ) );
51 connect(d->leUrl, SIGNAL(returnPressed()),
this, SLOT(btnUrlAddClicked()));
54 CFGWadseekerSites::~CFGWadseekerSites()
58 void CFGWadseekerSites::btnUrlAddClicked()
60 insertUrl(d->leUrl->text());
63 void CFGWadseekerSites::btnUrlDefaultClicked()
65 for (
int i = 0; !Wadseeker::defaultSites[i].isEmpty(); ++i)
67 insertUrl(Wadseeker::defaultSites[i]);
71 void CFGWadseekerSites::btnUrlRemoveClicked()
73 QItemSelectionModel* selModel = d->lstUrls->selectionModel();
74 QModelIndexList indexList = selModel->selectedIndexes();
77 QStandardItemModel* model =
static_cast<QStandardItemModel*
>(d->lstUrls->model());
78 QList<QStandardItem*> itemList;
79 for (
int i = 0; i < indexList.count(); ++i)
81 itemList << model->itemFromIndex(indexList[i]);
84 for (
int i = 0; i < itemList.count(); ++i)
86 QModelIndex index = model->indexFromItem(itemList[i]);
87 model->removeRow(index.row());
91 void CFGWadseekerSites::insertUrl(
const QUrl& url)
99 QStandardItemModel* model =
static_cast<QStandardItemModel*
>(d->lstUrls->model());
100 for (
int i = 0; i < model->rowCount(); ++i)
102 QUrl existingUrl( model->item(i)->text() );
103 if (existingUrl == url)
109 QStandardItem* it =
new QStandardItem(url.toString());
111 it->setDragEnabled(
true);
112 it->setDropEnabled(
false);
113 it->setToolTip(url.toString());
115 model->appendRow(it);
120 const QStringList& urlList = gConfig.wadseeker.searchURLs;
121 foreach (
const QString& url, urlList)
123 this->insertUrl(url);
130 QStandardItemModel* model =
static_cast<QStandardItemModel*
>(d->lstUrls->model());
131 for (
int i = 0; i < model->rowCount(); ++i)
133 QUrl existingUrl( model->item(i)->text() );
134 urlList << existingUrl.toString();
137 gConfig.wadseeker.searchURLs = urlList;
void saveSettings()
Reimplement this to write settings to config from widgets.
void readSettings()
Reimplement this to read settings from config into widgets.
Base class for configuration pages.