forked from mirror/openmw-tes3mp
Removed whitespace
This commit is contained in:
parent
a747bfb575
commit
c17eed26f3
8 changed files with 219 additions and 219 deletions
|
@ -14,26 +14,26 @@ DataFilesDialog::DataFilesDialog()
|
||||||
|
|
||||||
/* listtest
|
/* listtest
|
||||||
QTableWidget *pluginlist = new QTableWidget(this);
|
QTableWidget *pluginlist = new QTableWidget(this);
|
||||||
|
|
||||||
pluginlist->horizontalHeader()->setStretchLastSection(true);
|
pluginlist->horizontalHeader()->setStretchLastSection(true);
|
||||||
pluginlist->insertColumn(0);
|
pluginlist->insertColumn(0);
|
||||||
|
|
||||||
for (unsigned int i=0; i<6; ++i) {
|
for (unsigned int i=0; i<6; ++i) {
|
||||||
pluginlist->insertRow(i);
|
pluginlist->insertRow(i);
|
||||||
QTableWidgetItem *item = new QTableWidgetItem(QString("Plugin %0").arg(i));
|
QTableWidgetItem *item = new QTableWidgetItem(QString("Plugin %0").arg(i));
|
||||||
item->setFlags(item->flags() & ~(Qt::ItemIsDropEnabled));
|
item->setFlags(item->flags() & ~(Qt::ItemIsDropEnabled));
|
||||||
pluginlist->setItem(i, 0, item);
|
pluginlist->setItem(i, 0, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
pluginlist->insertRow(6);
|
pluginlist->insertRow(6);
|
||||||
pluginlist->setSelectionMode(QAbstractItemView::SingleSelection); // single item can be draged or droped
|
pluginlist->setSelectionMode(QAbstractItemView::SingleSelection); // single item can be draged or droped
|
||||||
pluginlist->setDragEnabled(true);
|
pluginlist->setDragEnabled(true);
|
||||||
pluginlist->setDragDropMode(QAbstractItemView::InternalMove);
|
pluginlist->setDragDropMode(QAbstractItemView::InternalMove);
|
||||||
pluginlist->viewport()->setAcceptDrops(true);
|
pluginlist->viewport()->setAcceptDrops(true);
|
||||||
|
|
||||||
pluginlist->setDropIndicatorShown(true);
|
pluginlist->setDropIndicatorShown(true);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
splitter->setOrientation(Qt::Vertical);
|
splitter->setOrientation(Qt::Vertical);
|
||||||
splitter->addWidget(tree);
|
splitter->addWidget(tree);
|
||||||
splitter->addWidget(mastertable);
|
splitter->addWidget(mastertable);
|
||||||
|
@ -43,7 +43,7 @@ DataFilesDialog::DataFilesDialog()
|
||||||
QList<int> sizelist;
|
QList<int> sizelist;
|
||||||
sizelist << 100 << 200 << 400;
|
sizelist << 100 << 200 << 400;
|
||||||
splitter->setSizes(sizelist);
|
splitter->setSizes(sizelist);
|
||||||
|
|
||||||
QVBoxLayout *dialogLayout = new QVBoxLayout(this);
|
QVBoxLayout *dialogLayout = new QVBoxLayout(this);
|
||||||
dialogLayout->addWidget(splitter);
|
dialogLayout->addWidget(splitter);
|
||||||
//dialogLayout->addWidget(plugintable);
|
//dialogLayout->addWidget(plugintable);
|
||||||
|
@ -57,55 +57,55 @@ DataFilesDialog::DataFilesDialog()
|
||||||
|
|
||||||
QStringList acceptedfiles = (QStringList() << "*.esp");
|
QStringList acceptedfiles = (QStringList() << "*.esp");
|
||||||
QStringList files;
|
QStringList files;
|
||||||
|
|
||||||
datafilesdir.setNameFilters(acceptedfiles);
|
datafilesdir.setNameFilters(acceptedfiles);
|
||||||
files = datafilesdir.entryList();
|
files = datafilesdir.entryList();
|
||||||
|
|
||||||
|
|
||||||
//foreach (const QString ¤tfile, datafiles) {
|
//foreach (const QString ¤tfile, datafiles) {
|
||||||
for (int i=0; i<files.count(); ++i)
|
for (int i=0; i<files.count(); ++i)
|
||||||
{
|
{
|
||||||
ESMReader datafile;
|
ESMReader datafile;
|
||||||
QString currentfile = files.at(i);
|
QString currentfile = files.at(i);
|
||||||
|
|
||||||
QStringList masters;
|
QStringList masters;
|
||||||
QString path = QString("data/").append(currentfile);
|
QString path = QString("data/").append(currentfile);
|
||||||
datafile.open(path.toStdString());
|
datafile.open(path.toStdString());
|
||||||
|
|
||||||
ESMReader::MasterList mlist = datafile.getMasters();
|
ESMReader::MasterList mlist = datafile.getMasters();
|
||||||
|
|
||||||
for (unsigned int i = 0; i < mlist.size(); ++i) {// Add each master file
|
for (unsigned int i = 0; i < mlist.size(); ++i) {// Add each master file
|
||||||
masters.append(QString::fromStdString(mlist[i].name));
|
masters.append(QString::fromStdString(mlist[i].name));
|
||||||
}
|
}
|
||||||
|
|
||||||
masters.sort(); // Sort the masters alphabetically
|
masters.sort(); // Sort the masters alphabetically
|
||||||
|
|
||||||
// Add the masters to mastersmodel
|
// Add the masters to mastersmodel
|
||||||
foreach (const QString ¤tmaster, masters) {
|
foreach (const QString ¤tmaster, masters) {
|
||||||
QStandardItem *item = new QStandardItem(currentmaster);
|
QStandardItem *item = new QStandardItem(currentmaster);
|
||||||
item->setFlags(item->flags() & ~(Qt::ItemIsDropEnabled));
|
item->setFlags(item->flags() & ~(Qt::ItemIsDropEnabled));
|
||||||
|
|
||||||
QList<QStandardItem*> foundmasters = mastersmodel->findItems(currentmaster);
|
QList<QStandardItem*> foundmasters = mastersmodel->findItems(currentmaster);
|
||||||
|
|
||||||
if (foundmasters.isEmpty()) {
|
if (foundmasters.isEmpty()) {
|
||||||
// Current master is not found in the master, add it
|
// Current master is not found in the master, add it
|
||||||
mastersmodel->appendRow(item);
|
mastersmodel->appendRow(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the masters to datafilesmodel
|
// Add the masters to datafilesmodel
|
||||||
QStandardItem *item = new QStandardItem(masters.join(","));
|
QStandardItem *item = new QStandardItem(masters.join(","));
|
||||||
item->setFlags(item->flags() & ~(Qt::ItemIsDropEnabled));
|
item->setFlags(item->flags() & ~(Qt::ItemIsDropEnabled));
|
||||||
QStandardItem *child = new QStandardItem(currentfile);
|
QStandardItem *child = new QStandardItem(currentfile);
|
||||||
child->setFlags(child->flags() & ~(Qt::ItemIsDropEnabled));
|
child->setFlags(child->flags() & ~(Qt::ItemIsDropEnabled));
|
||||||
|
|
||||||
QList<QStandardItem*> masteritems = datafilesmodel->findItems(masters.join(","));
|
QList<QStandardItem*> masteritems = datafilesmodel->findItems(masters.join(","));
|
||||||
|
|
||||||
|
|
||||||
if (masteritems.isEmpty()) {
|
if (masteritems.isEmpty()) {
|
||||||
item->appendRow(child);
|
item->appendRow(child);
|
||||||
datafilesmodel->appendRow(item);
|
datafilesmodel->appendRow(item);
|
||||||
} else {
|
} else {
|
||||||
foreach (QStandardItem *currentitem, masteritems) {
|
foreach (QStandardItem *currentitem, masteritems) {
|
||||||
currentitem->setFlags(currentitem->flags() & ~(Qt::ItemIsDropEnabled));
|
currentitem->setFlags(currentitem->flags() & ~(Qt::ItemIsDropEnabled));
|
||||||
currentitem->appendRow(child);
|
currentitem->appendRow(child);
|
||||||
|
@ -132,17 +132,17 @@ DataFilesDialog::DataFilesDialog()
|
||||||
pluginsmodel = new QStandardItemModel(0, 1);
|
pluginsmodel = new QStandardItemModel(0, 1);
|
||||||
pluginsmodel->setSupportedDragActions(Qt::MoveAction);
|
pluginsmodel->setSupportedDragActions(Qt::MoveAction);
|
||||||
pluginsmodel->invisibleRootItem()->setFlags(Qt::ItemIsDropEnabled);
|
pluginsmodel->invisibleRootItem()->setFlags(Qt::ItemIsDropEnabled);
|
||||||
|
|
||||||
|
|
||||||
masterselectmodel = new QItemSelectionModel(mastersmodel);
|
masterselectmodel = new QItemSelectionModel(mastersmodel);
|
||||||
pluginselectmodel = new QItemSelectionModel(pluginsmodel);
|
pluginselectmodel = new QItemSelectionModel(pluginsmodel);
|
||||||
|
|
||||||
tree->setModel(datafilesmodel);
|
tree->setModel(datafilesmodel);
|
||||||
tree->header()->hide();
|
tree->header()->hide();
|
||||||
|
|
||||||
mastertable->setModel(mastersmodel);
|
mastertable->setModel(mastersmodel);
|
||||||
mastertable->setSelectionModel(masterselectmodel);
|
mastertable->setSelectionModel(masterselectmodel);
|
||||||
|
|
||||||
mastertable->setSelectionBehavior(QAbstractItemView::SelectRows);
|
mastertable->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||||
mastertable->setSelectionMode(QAbstractItemView::MultiSelection);
|
mastertable->setSelectionMode(QAbstractItemView::MultiSelection);
|
||||||
mastertable->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
mastertable->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||||
|
@ -156,13 +156,13 @@ DataFilesDialog::DataFilesDialog()
|
||||||
plugintable->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
plugintable->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||||
plugintable->horizontalHeader()->setStretchLastSection(true);
|
plugintable->horizontalHeader()->setStretchLastSection(true);
|
||||||
plugintable->horizontalHeader()->hide();
|
plugintable->horizontalHeader()->hide();
|
||||||
|
|
||||||
plugintable->setDragEnabled(true);
|
plugintable->setDragEnabled(true);
|
||||||
plugintable->setDragDropMode(QAbstractItemView::InternalMove);
|
plugintable->setDragDropMode(QAbstractItemView::InternalMove);
|
||||||
plugintable->setDropIndicatorShown(true);
|
plugintable->setDropIndicatorShown(true);
|
||||||
plugintable->setDragDropOverwriteMode(false);
|
plugintable->setDragDropOverwriteMode(false);
|
||||||
plugintable->viewport()->setAcceptDrops(true);
|
plugintable->viewport()->setAcceptDrops(true);
|
||||||
|
|
||||||
plugintable->setContextMenuPolicy(Qt::CustomContextMenu);
|
plugintable->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ DataFilesDialog::DataFilesDialog()
|
||||||
connect(plugintable, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showContextMenu(const QPoint&)));
|
connect(plugintable, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showContextMenu(const QPoint&)));
|
||||||
connect(plugintable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setCheckstate(QModelIndex)));
|
connect(plugintable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setCheckstate(QModelIndex)));
|
||||||
connect(pluginsmodel, SIGNAL(rowsAboutToBeMoved(const QModelIndex&, int, int, const QModelIndex&, int)), this, SLOT(test()));
|
connect(pluginsmodel, SIGNAL(rowsAboutToBeMoved(const QModelIndex&, int, int, const QModelIndex&, int)), this, SLOT(test()));
|
||||||
|
|
||||||
// Adjust the dialog width
|
// Adjust the dialog width
|
||||||
setMinimumWidth(500);
|
setMinimumWidth(500);
|
||||||
}
|
}
|
||||||
|
@ -179,13 +179,13 @@ void DataFilesDialog::test()
|
||||||
{
|
{
|
||||||
qDebug() << "Breaky Breaky!";
|
qDebug() << "Breaky Breaky!";
|
||||||
/*QModelIndexList deselectedindexes = deselected.indexes();
|
/*QModelIndexList deselectedindexes = deselected.indexes();
|
||||||
|
|
||||||
if (!deselectedindexes.isEmpty()) {
|
if (!deselectedindexes.isEmpty()) {
|
||||||
foreach (const QModelIndex ¤tindex, deselectedindexes) {
|
foreach (const QModelIndex ¤tindex, deselectedindexes) {
|
||||||
qDebug() << "Data is: " << currentindex.data();
|
qDebug() << "Data is: " << currentindex.data();
|
||||||
qDebug() << "Row is: "<< currentindex.row();
|
qDebug() << "Row is: "<< currentindex.row();
|
||||||
QList<QStandardItem *> itemlist = pluginsmodel->findItems(QVariant(currentindex.data()).toString());
|
QList<QStandardItem *> itemlist = pluginsmodel->findItems(QVariant(currentindex.data()).toString());
|
||||||
|
|
||||||
if (!itemlist.isEmpty())
|
if (!itemlist.isEmpty())
|
||||||
{
|
{
|
||||||
foreach (const QStandardItem *currentitem, itemlist) {
|
foreach (const QStandardItem *currentitem, itemlist) {
|
||||||
|
@ -201,14 +201,14 @@ void DataFilesDialog::appendPlugins(const QModelIndex &masterindex)
|
||||||
// Find the plugins in the datafilesmodel and append them to the pluginsmodel
|
// Find the plugins in the datafilesmodel and append them to the pluginsmodel
|
||||||
if (!masterindex.isValid())
|
if (!masterindex.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int r=0; r<datafilesmodel->rowCount(masterindex); ++r ) {
|
for (int r=0; r<datafilesmodel->rowCount(masterindex); ++r ) {
|
||||||
QModelIndex childindex = masterindex.child(r, 0);
|
QModelIndex childindex = masterindex.child(r, 0);
|
||||||
|
|
||||||
if (childindex.isValid()) {
|
if (childindex.isValid()) {
|
||||||
// Now we see if the pluginsmodel already contains this plugin
|
// Now we see if the pluginsmodel already contains this plugin
|
||||||
QList<QStandardItem *> itemlist = pluginsmodel->findItems(QVariant(datafilesmodel->data(childindex)).toString());
|
QList<QStandardItem *> itemlist = pluginsmodel->findItems(QVariant(datafilesmodel->data(childindex)).toString());
|
||||||
|
|
||||||
if (itemlist.isEmpty())
|
if (itemlist.isEmpty())
|
||||||
{
|
{
|
||||||
// Plugin not yet in the pluginsmodel, add it
|
// Plugin not yet in the pluginsmodel, add it
|
||||||
|
@ -218,22 +218,22 @@ void DataFilesDialog::appendPlugins(const QModelIndex &masterindex)
|
||||||
pluginsmodel->appendRow(item);
|
pluginsmodel->appendRow(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataFilesDialog::removePlugins(const QModelIndex &masterindex)
|
void DataFilesDialog::removePlugins(const QModelIndex &masterindex)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!masterindex.isValid())
|
if (!masterindex.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int r=0; r<datafilesmodel->rowCount(masterindex); ++r) {
|
for (int r=0; r<datafilesmodel->rowCount(masterindex); ++r) {
|
||||||
QModelIndex childindex = masterindex.child(r, 0);
|
QModelIndex childindex = masterindex.child(r, 0);
|
||||||
|
|
||||||
QList<QStandardItem *> itemlist = pluginsmodel->findItems(QVariant(childindex.data()).toString());
|
QList<QStandardItem *> itemlist = pluginsmodel->findItems(QVariant(childindex.data()).toString());
|
||||||
|
|
||||||
if (!itemlist.isEmpty()) {
|
if (!itemlist.isEmpty()) {
|
||||||
foreach (const QStandardItem *currentitem, itemlist) {
|
foreach (const QStandardItem *currentitem, itemlist) {
|
||||||
qDebug() << "Remove plugin:" << currentitem->data(Qt::DisplayRole).toString();
|
qDebug() << "Remove plugin:" << currentitem->data(Qt::DisplayRole).toString();
|
||||||
|
@ -241,32 +241,32 @@ void DataFilesDialog::removePlugins(const QModelIndex &masterindex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataFilesDialog::masterSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
|
void DataFilesDialog::masterSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
|
||||||
{
|
{
|
||||||
if (masterselectmodel->hasSelection()) { // Not exactly necessary to check
|
if (masterselectmodel->hasSelection()) { // Not exactly necessary to check
|
||||||
const QModelIndexList selectedindexes = masterselectmodel->selectedIndexes();
|
const QModelIndexList selectedindexes = masterselectmodel->selectedIndexes();
|
||||||
|
|
||||||
QStringList masters;
|
QStringList masters;
|
||||||
QString masterstr;
|
QString masterstr;
|
||||||
|
|
||||||
// Create a QStringList containing all the masters
|
// Create a QStringList containing all the masters
|
||||||
foreach (const QModelIndex ¤tindex, selectedindexes) {
|
foreach (const QModelIndex ¤tindex, selectedindexes) {
|
||||||
masters.append(currentindex.data().toString());
|
masters.append(currentindex.data().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
masters.sort();
|
masters.sort();
|
||||||
masterstr = masters.join(","); // Make a comma-separated QString
|
masterstr = masters.join(","); // Make a comma-separated QString
|
||||||
|
|
||||||
qDebug() << "Masters" << masterstr;
|
qDebug() << "Masters" << masterstr;
|
||||||
|
|
||||||
// Iterate over all masters in the datafilesmodel to see if they are selected
|
// Iterate over all masters in the datafilesmodel to see if they are selected
|
||||||
for (int r=0; r<datafilesmodel->rowCount(); ++r) {
|
for (int r=0; r<datafilesmodel->rowCount(); ++r) {
|
||||||
QModelIndex currentindex = datafilesmodel->index(r, 0);
|
QModelIndex currentindex = datafilesmodel->index(r, 0);
|
||||||
QString master = currentindex.data().toString();
|
QString master = currentindex.data().toString();
|
||||||
|
|
||||||
if (currentindex.isValid()) {
|
if (currentindex.isValid()) {
|
||||||
// See if the current master is in the string with selected masters
|
// See if the current master is in the string with selected masters
|
||||||
if (masterstr.contains(master))
|
if (masterstr.contains(master))
|
||||||
|
@ -277,10 +277,10 @@ void DataFilesDialog::masterSelectionChanged(const QItemSelection &selected, con
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// See what plugins to remove
|
// See what plugins to remove
|
||||||
QModelIndexList deselectedindexes = deselected.indexes();
|
QModelIndexList deselectedindexes = deselected.indexes();
|
||||||
|
|
||||||
if (!deselectedindexes.isEmpty()) {
|
if (!deselectedindexes.isEmpty()) {
|
||||||
foreach (const QModelIndex ¤tindex, deselectedindexes) {
|
foreach (const QModelIndex ¤tindex, deselectedindexes) {
|
||||||
|
|
||||||
|
@ -288,15 +288,15 @@ void DataFilesDialog::masterSelectionChanged(const QItemSelection &selected, con
|
||||||
master.prepend("*");
|
master.prepend("*");
|
||||||
master.append("*");
|
master.append("*");
|
||||||
QList<QStandardItem *> itemlist = datafilesmodel->findItems(master, Qt::MatchWildcard);
|
QList<QStandardItem *> itemlist = datafilesmodel->findItems(master, Qt::MatchWildcard);
|
||||||
|
|
||||||
if (itemlist.isEmpty())
|
if (itemlist.isEmpty())
|
||||||
qDebug() << "Empty as shit";
|
qDebug() << "Empty as shit";
|
||||||
|
|
||||||
foreach (const QStandardItem *currentitem, itemlist) {
|
foreach (const QStandardItem *currentitem, itemlist) {
|
||||||
|
|
||||||
QModelIndex index = currentitem->index();
|
QModelIndex index = currentitem->index();
|
||||||
qDebug() << "Master to remove plugins of:" << index.data().toString();
|
qDebug() << "Master to remove plugins of:" << index.data().toString();
|
||||||
|
|
||||||
removePlugins(index);
|
removePlugins(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -306,29 +306,29 @@ void DataFilesDialog::masterSelectionChanged(const QItemSelection &selected, con
|
||||||
void DataFilesDialog::showContextMenu(const QPoint &point)
|
void DataFilesDialog::showContextMenu(const QPoint &point)
|
||||||
{
|
{
|
||||||
qDebug() << "Show me the money!";
|
qDebug() << "Show me the money!";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QAction *action1 = new QAction(QIcon::fromTheme("arrow-up-double"), tr("Move to Top"), this);
|
QAction *action1 = new QAction(QIcon::fromTheme("arrow-up-double"), tr("Move to Top"), this);
|
||||||
QAction *action2 = new QAction(QIcon::fromTheme("arrow-down-double"), tr("Move to Bottom"), this);
|
QAction *action2 = new QAction(QIcon::fromTheme("arrow-down-double"), tr("Move to Bottom"), this);
|
||||||
QAction *action3 = new QAction(QIcon::fromTheme("arrow-up"), tr("Move Up"), this);
|
QAction *action3 = new QAction(QIcon::fromTheme("arrow-up"), tr("Move Up"), this);
|
||||||
QAction *action4 = new QAction(QIcon::fromTheme("arrow-down"), tr("Move Down"), this);
|
QAction *action4 = new QAction(QIcon::fromTheme("arrow-down"), tr("Move Down"), this);
|
||||||
QAction *action5 = new QAction(this);
|
QAction *action5 = new QAction(this);
|
||||||
|
|
||||||
QModelIndex index = plugintable->indexAt(point);
|
QModelIndex index = plugintable->indexAt(point);
|
||||||
|
|
||||||
if (index.isValid()) { // Should be valid!
|
if (index.isValid()) { // Should be valid!
|
||||||
const QStandardItem *item = pluginsmodel->itemFromIndex(index);
|
const QStandardItem *item = pluginsmodel->itemFromIndex(index);
|
||||||
|
|
||||||
if (item->checkState() == Qt::Checked) {
|
if (item->checkState() == Qt::Checked) {
|
||||||
action5->setText("Uncheck Item");
|
action5->setText("Uncheck Item");
|
||||||
} else if (item->checkState() == Qt::Unchecked) {
|
} else if (item->checkState() == Qt::Unchecked) {
|
||||||
action5->setText("Check Item");
|
action5->setText("Check Item");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(action5, SIGNAL(triggered()), this, SLOT(actionCheckstate()));
|
connect(action5, SIGNAL(triggered()), this, SLOT(actionCheckstate()));
|
||||||
|
|
||||||
QMenu menu(this);
|
QMenu menu(this);
|
||||||
menu.addAction(action1);
|
menu.addAction(action1);
|
||||||
menu.addAction(action2);
|
menu.addAction(action2);
|
||||||
|
@ -337,7 +337,7 @@ void DataFilesDialog::showContextMenu(const QPoint &point)
|
||||||
menu.addAction(action4);
|
menu.addAction(action4);
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
menu.addAction(action5);
|
menu.addAction(action5);
|
||||||
|
|
||||||
menu.exec(plugintable->viewport()->mapToGlobal(point));
|
menu.exec(plugintable->viewport()->mapToGlobal(point));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -345,14 +345,14 @@ void DataFilesDialog::showContextMenu(const QPoint &point)
|
||||||
void DataFilesDialog::actionCheckstate()
|
void DataFilesDialog::actionCheckstate()
|
||||||
{
|
{
|
||||||
qDebug() << "actionCheckstate";
|
qDebug() << "actionCheckstate";
|
||||||
|
|
||||||
const QModelIndexList selectedindexes = pluginselectmodel->selectedIndexes();
|
const QModelIndexList selectedindexes = pluginselectmodel->selectedIndexes();
|
||||||
|
|
||||||
// Should only be one index selected
|
// Should only be one index selected
|
||||||
foreach (const QModelIndex ¤tindex, selectedindexes) {
|
foreach (const QModelIndex ¤tindex, selectedindexes) {
|
||||||
setCheckstate(currentindex);
|
setCheckstate(currentindex);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataFilesDialog::setCheckstate(QModelIndex index)
|
void DataFilesDialog::setCheckstate(QModelIndex index)
|
||||||
|
@ -376,16 +376,16 @@ void DataFilesDialog::setCheckstate(QModelIndex index)
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataFilesDialog::readConfig()
|
void DataFilesDialog::readConfig()
|
||||||
{
|
{
|
||||||
/* QString filename;
|
/* QString filename;
|
||||||
QString path = "data/"; // TODO: Should be global
|
QString path = "data/"; // TODO: Should be global
|
||||||
|
|
||||||
QFile file("openmw.cfg"); // Specify filepath later
|
QFile file("openmw.cfg"); // Specify filepath later
|
||||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
qDebug() << "error open";
|
qDebug() << "error open";
|
||||||
close(); // File cannot be opened or created TODO: throw error
|
close(); // File cannot be opened or created TODO: throw error
|
||||||
}
|
}
|
||||||
|
|
||||||
QTextStream in(&file);
|
QTextStream in(&file);
|
||||||
|
|
||||||
QStringList datafiles;
|
QStringList datafiles;
|
||||||
|
@ -393,27 +393,27 @@ void DataFilesDialog::readConfig()
|
||||||
// Add each data file read from the config file to a QStringList
|
// Add each data file read from the config file to a QStringList
|
||||||
while (!in.atEnd()) {
|
while (!in.atEnd()) {
|
||||||
QString line = in.readLine();
|
QString line = in.readLine();
|
||||||
|
|
||||||
if (line.contains("master")) {
|
if (line.contains("master")) {
|
||||||
filename = line.remove("master=");
|
filename = line.remove("master=");
|
||||||
filename.prepend(path);
|
filename.prepend(path);
|
||||||
|
|
||||||
datafiles << filename << "\n";
|
datafiles << filename << "\n";
|
||||||
|
|
||||||
} else if (line.contains("plugin")) {
|
} else if (line.contains("plugin")) {
|
||||||
filename = line.remove("plugin=");
|
filename = line.remove("plugin=");
|
||||||
filename.prepend(path);
|
filename.prepend(path);
|
||||||
|
|
||||||
datafiles << filename << "\n";
|
datafiles << filename << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
// Check if the files are in the model, set to checked if found
|
// Check if the files are in the model, set to checked if found
|
||||||
foreach(const QString ¤tfile, datafiles) {
|
foreach(const QString ¤tfile, datafiles) {
|
||||||
QModelIndex index = dataFilesModel->index(currentfile, 0);
|
QModelIndex index = dataFilesModel->index(currentfile, 0);
|
||||||
|
|
||||||
if (index.isValid()) {
|
if (index.isValid()) {
|
||||||
// File is found in model, set it to checked
|
// File is found in model, set it to checked
|
||||||
dataFilesModel->setData(index, Qt::Checked, Qt::CheckStateRole);
|
dataFilesModel->setData(index, Qt::Checked, Qt::CheckStateRole);
|
||||||
|
@ -430,14 +430,14 @@ void DataFilesDialog::writeConfig()
|
||||||
//QString sectionname = "[Game Files]";
|
//QString sectionname = "[Game Files]";
|
||||||
QString filename;
|
QString filename;
|
||||||
QFileInfo datafile;
|
QFileInfo datafile;
|
||||||
|
|
||||||
// Sort the items so that master files end up on top
|
// Sort the items so that master files end up on top
|
||||||
foreach (const QString ¤titem, checkeditems) {
|
foreach (const QString ¤titem, checkeditems) {
|
||||||
if(currentitem.endsWith(QString(".esm"), Qt::CaseInsensitive)) {
|
if(currentitem.endsWith(QString(".esm"), Qt::CaseInsensitive)) {
|
||||||
checkeditems.move(checkeditems.indexOf(currentitem), 0);
|
checkeditems.move(checkeditems.indexOf(currentitem), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QFile file("openmw.cfg"); // Specify filepath later
|
QFile file("openmw.cfg"); // Specify filepath later
|
||||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||||
close(); // File cannot be opened or created TODO: throw error
|
close(); // File cannot be opened or created TODO: throw error
|
||||||
|
@ -453,7 +453,7 @@ void DataFilesDialog::writeConfig()
|
||||||
QString line = in.readLine();
|
QString line = in.readLine();
|
||||||
//if (!line.contains("GameFile") && line != "[Game Files]") {
|
//if (!line.contains("GameFile") && line != "[Game Files]") {
|
||||||
if (!line.contains("master") && !line.contains("plugin")) {
|
if (!line.contains("master") && !line.contains("plugin")) {
|
||||||
buffer += line += "\n";
|
buffer += line += "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -465,16 +465,16 @@ void DataFilesDialog::writeConfig()
|
||||||
|
|
||||||
file.write(buffer);
|
file.write(buffer);
|
||||||
QTextStream out(&file);
|
QTextStream out(&file);
|
||||||
|
|
||||||
// Write the section name to the config file before we write out the data files
|
// Write the section name to the config file before we write out the data files
|
||||||
//out << sectionname << endl;
|
//out << sectionname << endl;
|
||||||
|
|
||||||
// Write the list of game files to the config
|
// Write the list of game files to the config
|
||||||
for (int i = 0; i < checkeditems.size(); ++i) {
|
for (int i = 0; i < checkeditems.size(); ++i) {
|
||||||
//filename = dataFilesModel->fileName(checkeditems.at(i));
|
//filename = dataFilesModel->fileName(checkeditems.at(i));
|
||||||
filename = checkeditems.at(i);
|
filename = checkeditems.at(i);
|
||||||
datafile = QFileInfo(filename);
|
datafile = QFileInfo(filename);
|
||||||
|
|
||||||
if (datafile.exists()) {
|
if (datafile.exists()) {
|
||||||
if (filename.endsWith(QString(".esm"), Qt::CaseInsensitive)) {
|
if (filename.endsWith(QString(".esm"), Qt::CaseInsensitive)) {
|
||||||
out << "master=" << datafile.fileName() << endl;
|
out << "master=" << datafile.fileName() << endl;
|
||||||
|
|
|
@ -13,87 +13,87 @@ DataFilesPage::DataFilesPage(QWidget *parent) : QWidget(parent)
|
||||||
{
|
{
|
||||||
mDataFilesModel = new QStandardItemModel(); // Contains all plugins with masters
|
mDataFilesModel = new QStandardItemModel(); // Contains all plugins with masters
|
||||||
mPluginsModel = new QStandardItemModel(); // Contains selectable plugins
|
mPluginsModel = new QStandardItemModel(); // Contains selectable plugins
|
||||||
|
|
||||||
mPluginsSelectModel = new QItemSelectionModel(mPluginsModel);
|
mPluginsSelectModel = new QItemSelectionModel(mPluginsModel);
|
||||||
|
|
||||||
//QPushButton *deselectButton = new QPushButton(tr("Deselect All"));
|
//QPushButton *deselectButton = new QPushButton(tr("Deselect All"));
|
||||||
QLabel *filterLabel = new QLabel(tr("Filter:"), this);
|
QLabel *filterLabel = new QLabel(tr("Filter:"), this);
|
||||||
LineEdit *filterLineEdit = new LineEdit(this);
|
LineEdit *filterLineEdit = new LineEdit(this);
|
||||||
|
|
||||||
QHBoxLayout *topLayout = new QHBoxLayout();
|
QHBoxLayout *topLayout = new QHBoxLayout();
|
||||||
QSpacerItem *hSpacer1 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
QSpacerItem *hSpacer1 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||||
|
|
||||||
topLayout->addItem(hSpacer1);
|
topLayout->addItem(hSpacer1);
|
||||||
topLayout->addWidget(filterLabel);
|
topLayout->addWidget(filterLabel);
|
||||||
topLayout->addWidget(filterLineEdit);
|
topLayout->addWidget(filterLineEdit);
|
||||||
|
|
||||||
mMastersWidget = new QTableWidget(this); // Contains the available masters
|
mMastersWidget = new QTableWidget(this); // Contains the available masters
|
||||||
mPluginsTable = new QTableView(this);
|
mPluginsTable = new QTableView(this);
|
||||||
|
|
||||||
// Add both tables to a splitter
|
// Add both tables to a splitter
|
||||||
QSplitter *splitter = new QSplitter(this);
|
QSplitter *splitter = new QSplitter(this);
|
||||||
splitter->setOrientation(Qt::Horizontal);
|
splitter->setOrientation(Qt::Horizontal);
|
||||||
|
|
||||||
splitter->addWidget(mMastersWidget);
|
splitter->addWidget(mMastersWidget);
|
||||||
splitter->addWidget(mPluginsTable);
|
splitter->addWidget(mPluginsTable);
|
||||||
|
|
||||||
// Adjust the default widget widths inside the splitter
|
// Adjust the default widget widths inside the splitter
|
||||||
QList<int> sizeList;
|
QList<int> sizeList;
|
||||||
sizeList << 100 << 300;
|
sizeList << 100 << 300;
|
||||||
splitter->setSizes(sizeList);
|
splitter->setSizes(sizeList);
|
||||||
|
|
||||||
// Bottom part with profile options
|
// Bottom part with profile options
|
||||||
QLabel *profileLabel = new QLabel(tr("Current Profile:"), this);
|
QLabel *profileLabel = new QLabel(tr("Current Profile:"), this);
|
||||||
|
|
||||||
// TEST
|
// TEST
|
||||||
mProfileModel = new QStringListModel();
|
mProfileModel = new QStringListModel();
|
||||||
QStringList profileList;
|
QStringList profileList;
|
||||||
profileList << "Default" << "New" << "Yeah" << "Cool story bro!";
|
profileList << "Default" << "New" << "Yeah" << "Cool story bro!";
|
||||||
mProfileModel->setStringList(profileList);
|
mProfileModel->setStringList(profileList);
|
||||||
|
|
||||||
mProfileComboBox = new QComboBox(this);
|
mProfileComboBox = new QComboBox(this);
|
||||||
mProfileComboBox->setModel(mProfileModel);
|
mProfileComboBox->setModel(mProfileModel);
|
||||||
|
|
||||||
mProfileComboBox->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
|
mProfileComboBox->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
|
||||||
mProfileComboBox->setInsertPolicy(QComboBox::InsertAtBottom);
|
mProfileComboBox->setInsertPolicy(QComboBox::InsertAtBottom);
|
||||||
//mProfileComboBox->addItem(QString("New Profile"));
|
//mProfileComboBox->addItem(QString("New Profile"));
|
||||||
|
|
||||||
QToolButton *NewProfileToolButton = new QToolButton(this);
|
QToolButton *NewProfileToolButton = new QToolButton(this);
|
||||||
NewProfileToolButton->setIcon(QIcon::fromTheme("document-new"));
|
NewProfileToolButton->setIcon(QIcon::fromTheme("document-new"));
|
||||||
|
|
||||||
QToolButton *CopyProfileToolButton = new QToolButton(this);
|
QToolButton *CopyProfileToolButton = new QToolButton(this);
|
||||||
CopyProfileToolButton->setIcon(QIcon::fromTheme("edit-copy"));
|
CopyProfileToolButton->setIcon(QIcon::fromTheme("edit-copy"));
|
||||||
|
|
||||||
QToolButton *DeleteProfileToolButton = new QToolButton(this);
|
QToolButton *DeleteProfileToolButton = new QToolButton(this);
|
||||||
DeleteProfileToolButton->setIcon(QIcon::fromTheme("document-close"));
|
DeleteProfileToolButton->setIcon(QIcon::fromTheme("document-close"));
|
||||||
|
|
||||||
QHBoxLayout *bottomLayout = new QHBoxLayout();
|
QHBoxLayout *bottomLayout = new QHBoxLayout();
|
||||||
|
|
||||||
bottomLayout->addWidget(profileLabel);
|
bottomLayout->addWidget(profileLabel);
|
||||||
bottomLayout->addWidget(mProfileComboBox);
|
bottomLayout->addWidget(mProfileComboBox);
|
||||||
bottomLayout->addWidget(NewProfileToolButton);
|
bottomLayout->addWidget(NewProfileToolButton);
|
||||||
bottomLayout->addWidget(CopyProfileToolButton);
|
bottomLayout->addWidget(CopyProfileToolButton);
|
||||||
bottomLayout->addWidget(DeleteProfileToolButton);
|
bottomLayout->addWidget(DeleteProfileToolButton);
|
||||||
|
|
||||||
QVBoxLayout *pageLayout = new QVBoxLayout(this);
|
QVBoxLayout *pageLayout = new QVBoxLayout(this);
|
||||||
// Add some space above and below the page items
|
// Add some space above and below the page items
|
||||||
QSpacerItem *vSpacer1 = new QSpacerItem(5, 5, QSizePolicy::Minimum, QSizePolicy::Minimum);
|
QSpacerItem *vSpacer1 = new QSpacerItem(5, 5, QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||||
QSpacerItem *vSpacer2 = new QSpacerItem(5, 5, QSizePolicy::Minimum, QSizePolicy::Minimum);
|
QSpacerItem *vSpacer2 = new QSpacerItem(5, 5, QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||||
QSpacerItem *vSpacer3 = new QSpacerItem(5, 5, QSizePolicy::Minimum, QSizePolicy::Minimum);
|
QSpacerItem *vSpacer3 = new QSpacerItem(5, 5, QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||||
|
|
||||||
//pageLayout->addItem(vSpacer1);
|
//pageLayout->addItem(vSpacer1);
|
||||||
pageLayout->addLayout(topLayout);
|
pageLayout->addLayout(topLayout);
|
||||||
pageLayout->addItem(vSpacer2);
|
pageLayout->addItem(vSpacer2);
|
||||||
pageLayout->addWidget(splitter);
|
pageLayout->addWidget(splitter);
|
||||||
pageLayout->addLayout(bottomLayout);
|
pageLayout->addLayout(bottomLayout);
|
||||||
pageLayout->addItem(vSpacer3);
|
pageLayout->addItem(vSpacer3);
|
||||||
|
|
||||||
setupDataFiles();
|
setupDataFiles();
|
||||||
|
|
||||||
connect(mMastersWidget->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), this, SLOT(masterSelectionChanged(const QItemSelection&, const QItemSelection&)));
|
connect(mMastersWidget->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), this, SLOT(masterSelectionChanged(const QItemSelection&, const QItemSelection&)));
|
||||||
connect(mPluginsTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setCheckstate(QModelIndex)));
|
connect(mPluginsTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setCheckstate(QModelIndex)));
|
||||||
connect(mPluginsModel, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), this, SLOT(resizeRows()));
|
connect(mPluginsModel, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), this, SLOT(resizeRows()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataFilesPage::setupDataFiles()
|
void DataFilesPage::setupDataFiles()
|
||||||
|
@ -106,7 +106,7 @@ void DataFilesPage::setupDataFiles()
|
||||||
mMastersWidget->horizontalHeader()->hide();
|
mMastersWidget->horizontalHeader()->hide();
|
||||||
mMastersWidget->verticalHeader()->hide();
|
mMastersWidget->verticalHeader()->hide();
|
||||||
mMastersWidget->insertColumn(0);
|
mMastersWidget->insertColumn(0);
|
||||||
|
|
||||||
mPluginsTable->setModel(mPluginsModel);
|
mPluginsTable->setModel(mPluginsModel);
|
||||||
mPluginsTable->setSelectionModel(mPluginsSelectModel);
|
mPluginsTable->setSelectionModel(mPluginsSelectModel);
|
||||||
mPluginsTable->setSelectionBehavior(QAbstractItemView::SelectRows);
|
mPluginsTable->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||||
|
@ -115,45 +115,45 @@ void DataFilesPage::setupDataFiles()
|
||||||
mPluginsTable->setAlternatingRowColors(true);
|
mPluginsTable->setAlternatingRowColors(true);
|
||||||
mPluginsTable->horizontalHeader()->setStretchLastSection(true);
|
mPluginsTable->horizontalHeader()->setStretchLastSection(true);
|
||||||
mPluginsTable->horizontalHeader()->hide();
|
mPluginsTable->horizontalHeader()->hide();
|
||||||
|
|
||||||
|
|
||||||
mPluginsTable->setDragEnabled(true);
|
mPluginsTable->setDragEnabled(true);
|
||||||
mPluginsTable->setDragDropMode(QAbstractItemView::InternalMove);
|
mPluginsTable->setDragDropMode(QAbstractItemView::InternalMove);
|
||||||
mPluginsTable->setDropIndicatorShown(true);
|
mPluginsTable->setDropIndicatorShown(true);
|
||||||
mPluginsTable->setDragDropOverwriteMode(false);
|
mPluginsTable->setDragDropOverwriteMode(false);
|
||||||
mPluginsTable->viewport()->setAcceptDrops(true);
|
mPluginsTable->viewport()->setAcceptDrops(true);
|
||||||
|
|
||||||
mPluginsTable->setContextMenuPolicy(Qt::CustomContextMenu);
|
mPluginsTable->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
|
||||||
// Some testing TODO TODO TODO
|
// Some testing TODO TODO TODO
|
||||||
|
|
||||||
QDir dataFilesDir("data/");
|
QDir dataFilesDir("data/");
|
||||||
|
|
||||||
if (!dataFilesDir.exists())
|
if (!dataFilesDir.exists())
|
||||||
qWarning("Cannot find the plugin directory");
|
qWarning("Cannot find the plugin directory");
|
||||||
|
|
||||||
dataFilesDir.setNameFilters((QStringList() << "*.esp")); // Only load plugins
|
dataFilesDir.setNameFilters((QStringList() << "*.esp")); // Only load plugins
|
||||||
|
|
||||||
QStringList dataFiles = dataFilesDir.entryList();
|
QStringList dataFiles = dataFilesDir.entryList();
|
||||||
|
|
||||||
for (int i=0; i<dataFiles.count(); ++i)
|
for (int i=0; i<dataFiles.count(); ++i)
|
||||||
{
|
{
|
||||||
ESMReader fileReader;
|
ESMReader fileReader;
|
||||||
QString currentFile = dataFiles.at(i);
|
QString currentFile = dataFiles.at(i);
|
||||||
QStringList availableMasters; // Will contain all found masters
|
QStringList availableMasters; // Will contain all found masters
|
||||||
|
|
||||||
QString path = QString("data/").append(currentFile);
|
QString path = QString("data/").append(currentFile);
|
||||||
fileReader.open(path.toStdString());
|
fileReader.open(path.toStdString());
|
||||||
|
|
||||||
// First we fill the availableMasters and the mMastersWidget
|
// First we fill the availableMasters and the mMastersWidget
|
||||||
ESMReader::MasterList mlist = fileReader.getMasters();
|
ESMReader::MasterList mlist = fileReader.getMasters();
|
||||||
|
|
||||||
for (unsigned int i = 0; i < mlist.size(); ++i) {
|
for (unsigned int i = 0; i < mlist.size(); ++i) {
|
||||||
const QString currentMaster = QString::fromStdString(mlist[i].name);
|
const QString currentMaster = QString::fromStdString(mlist[i].name);
|
||||||
availableMasters.append(currentMaster);
|
availableMasters.append(currentMaster);
|
||||||
|
|
||||||
QList<QTableWidgetItem*> itemList = mMastersWidget->findItems(currentMaster, Qt::MatchExactly);
|
QList<QTableWidgetItem*> itemList = mMastersWidget->findItems(currentMaster, Qt::MatchExactly);
|
||||||
|
|
||||||
if (itemList.isEmpty()) // Master is not yet in the widget
|
if (itemList.isEmpty()) // Master is not yet in the widget
|
||||||
{
|
{
|
||||||
mMastersWidget->insertRow(i);
|
mMastersWidget->insertRow(i);
|
||||||
|
@ -161,16 +161,16 @@ void DataFilesPage::setupDataFiles()
|
||||||
mMastersWidget->setItem(i, 0, item);
|
mMastersWidget->setItem(i, 0, item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
availableMasters.sort(); // Sort the masters alphabetically
|
availableMasters.sort(); // Sort the masters alphabetically
|
||||||
|
|
||||||
// Now we put the currentFile in the mDataFilesModel under its masters
|
// Now we put the currentFile in the mDataFilesModel under its masters
|
||||||
QStandardItem *parent = new QStandardItem(availableMasters.join(","));
|
QStandardItem *parent = new QStandardItem(availableMasters.join(","));
|
||||||
QStandardItem *child = new QStandardItem(currentFile);
|
QStandardItem *child = new QStandardItem(currentFile);
|
||||||
|
|
||||||
QList<QStandardItem*> masterList = mDataFilesModel->findItems(availableMasters.join(","));
|
QList<QStandardItem*> masterList = mDataFilesModel->findItems(availableMasters.join(","));
|
||||||
|
|
||||||
|
|
||||||
if (masterList.isEmpty()) { // Masters node not yet in the mDataFilesModel
|
if (masterList.isEmpty()) { // Masters node not yet in the mDataFilesModel
|
||||||
parent->appendRow(child);
|
parent->appendRow(child);
|
||||||
mDataFilesModel->appendRow(parent);
|
mDataFilesModel->appendRow(parent);
|
||||||
|
@ -187,25 +187,25 @@ void DataFilesPage::masterSelectionChanged(const QItemSelection &selected, const
|
||||||
{
|
{
|
||||||
if (mMastersWidget->selectionModel()->hasSelection()) {
|
if (mMastersWidget->selectionModel()->hasSelection()) {
|
||||||
const QModelIndexList selectedIndexes = mMastersWidget->selectionModel()->selectedIndexes();
|
const QModelIndexList selectedIndexes = mMastersWidget->selectionModel()->selectedIndexes();
|
||||||
|
|
||||||
QStringList masters;
|
QStringList masters;
|
||||||
QString masterstr;
|
QString masterstr;
|
||||||
|
|
||||||
// Create a QStringList containing all the masters
|
// Create a QStringList containing all the masters
|
||||||
foreach (const QModelIndex &index, selectedIndexes) {
|
foreach (const QModelIndex &index, selectedIndexes) {
|
||||||
masters.append(index.data().toString());
|
masters.append(index.data().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
masters.sort();
|
masters.sort();
|
||||||
masterstr = masters.join(","); // Make a comma-separated QString
|
masterstr = masters.join(","); // Make a comma-separated QString
|
||||||
|
|
||||||
qDebug() << "Masters" << masterstr;
|
qDebug() << "Masters" << masterstr;
|
||||||
|
|
||||||
// Iterate over all masters in the datafilesmodel to see if they are selected
|
// Iterate over all masters in the datafilesmodel to see if they are selected
|
||||||
for (int r=0; r<mDataFilesModel->rowCount(); ++r) {
|
for (int r=0; r<mDataFilesModel->rowCount(); ++r) {
|
||||||
QModelIndex currentIndex = mDataFilesModel->index(r, 0);
|
QModelIndex currentIndex = mDataFilesModel->index(r, 0);
|
||||||
QString master = currentIndex.data().toString();
|
QString master = currentIndex.data().toString();
|
||||||
|
|
||||||
if (currentIndex.isValid()) {
|
if (currentIndex.isValid()) {
|
||||||
// See if the current master is in the string with selected masters
|
// See if the current master is in the string with selected masters
|
||||||
if (masterstr.contains(master))
|
if (masterstr.contains(master))
|
||||||
|
@ -217,10 +217,10 @@ void DataFilesPage::masterSelectionChanged(const QItemSelection &selected, const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// See what plugins to remove
|
// See what plugins to remove
|
||||||
QModelIndexList deselectedIndexes = deselected.indexes();
|
QModelIndexList deselectedIndexes = deselected.indexes();
|
||||||
|
|
||||||
if (!deselectedIndexes.isEmpty()) {
|
if (!deselectedIndexes.isEmpty()) {
|
||||||
foreach (const QModelIndex ¤tIndex, deselectedIndexes) {
|
foreach (const QModelIndex ¤tIndex, deselectedIndexes) {
|
||||||
|
|
||||||
|
@ -228,15 +228,15 @@ void DataFilesPage::masterSelectionChanged(const QItemSelection &selected, const
|
||||||
master.prepend("*");
|
master.prepend("*");
|
||||||
master.append("*");
|
master.append("*");
|
||||||
QList<QStandardItem *> itemList = mDataFilesModel->findItems(master, Qt::MatchWildcard);
|
QList<QStandardItem *> itemList = mDataFilesModel->findItems(master, Qt::MatchWildcard);
|
||||||
|
|
||||||
if (itemList.isEmpty())
|
if (itemList.isEmpty())
|
||||||
qDebug() << "Empty as shit";
|
qDebug() << "Empty as shit";
|
||||||
|
|
||||||
foreach (const QStandardItem *currentItem, itemList) {
|
foreach (const QStandardItem *currentItem, itemList) {
|
||||||
|
|
||||||
QModelIndex index = currentItem->index();
|
QModelIndex index = currentItem->index();
|
||||||
qDebug() << "Master to remove plugins of:" << index.data().toString();
|
qDebug() << "Master to remove plugins of:" << index.data().toString();
|
||||||
|
|
||||||
removePlugins(index);
|
removePlugins(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -248,15 +248,15 @@ void DataFilesPage::addPlugins(const QModelIndex &index)
|
||||||
// Find the plugins in the datafilesmodel and append them to the pluginsmodel
|
// Find the plugins in the datafilesmodel and append them to the pluginsmodel
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int r=0; r<mDataFilesModel->rowCount(index); ++r ) {
|
for (int r=0; r<mDataFilesModel->rowCount(index); ++r ) {
|
||||||
QModelIndex childIndex = index.child(r, 0);
|
QModelIndex childIndex = index.child(r, 0);
|
||||||
const QString childIndexData = QVariant(mDataFilesModel->data(childIndex)).toString();
|
const QString childIndexData = QVariant(mDataFilesModel->data(childIndex)).toString();
|
||||||
|
|
||||||
if (childIndex.isValid()) {
|
if (childIndex.isValid()) {
|
||||||
// Now we see if the pluginsmodel already contains this plugin
|
// Now we see if the pluginsmodel already contains this plugin
|
||||||
QList<QStandardItem *> itemList = mPluginsModel->findItems(childIndexData);
|
QList<QStandardItem *> itemList = mPluginsModel->findItems(childIndexData);
|
||||||
|
|
||||||
if (itemList.isEmpty())
|
if (itemList.isEmpty())
|
||||||
{
|
{
|
||||||
// Plugin not yet in the pluginsmodel, add it
|
// Plugin not yet in the pluginsmodel, add it
|
||||||
|
@ -267,31 +267,31 @@ void DataFilesPage::addPlugins(const QModelIndex &index)
|
||||||
mPluginsModel->appendRow(item);
|
mPluginsModel->appendRow(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataFilesPage::removePlugins(const QModelIndex &index)
|
void DataFilesPage::removePlugins(const QModelIndex &index)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int r=0; r<mDataFilesModel->rowCount(index); ++r) {
|
for (int r=0; r<mDataFilesModel->rowCount(index); ++r) {
|
||||||
QModelIndex childIndex = index.child(r, 0);
|
QModelIndex childIndex = index.child(r, 0);
|
||||||
|
|
||||||
QList<QStandardItem *> itemList = mPluginsModel->findItems(QVariant(childIndex.data()).toString());
|
QList<QStandardItem *> itemList = mPluginsModel->findItems(QVariant(childIndex.data()).toString());
|
||||||
|
|
||||||
if (!itemList.isEmpty()) {
|
if (!itemList.isEmpty()) {
|
||||||
foreach (const QStandardItem *currentItem, itemList) {
|
foreach (const QStandardItem *currentItem, itemList) {
|
||||||
qDebug() << "Remove plugin:" << currentItem->data(Qt::DisplayRole).toString();
|
qDebug() << "Remove plugin:" << currentItem->data(Qt::DisplayRole).toString();
|
||||||
|
|
||||||
mPluginsModel->removeRow(currentItem->row());
|
mPluginsModel->removeRow(currentItem->row());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataFilesPage::setCheckstate(QModelIndex index)
|
void DataFilesPage::setCheckstate(QModelIndex index)
|
||||||
|
|
|
@ -30,16 +30,16 @@ public slots:
|
||||||
private:
|
private:
|
||||||
QTableWidget *mMastersWidget;
|
QTableWidget *mMastersWidget;
|
||||||
QTableView *mPluginsTable;
|
QTableView *mPluginsTable;
|
||||||
|
|
||||||
QStandardItemModel *mDataFilesModel;
|
QStandardItemModel *mDataFilesModel;
|
||||||
QStandardItemModel *mPluginsModel;
|
QStandardItemModel *mPluginsModel;
|
||||||
|
|
||||||
QItemSelectionModel *mPluginsSelectModel;
|
QItemSelectionModel *mPluginsSelectModel;
|
||||||
|
|
||||||
void setupDataFiles();
|
void setupDataFiles();
|
||||||
void addPlugins(const QModelIndex &index);
|
void addPlugins(const QModelIndex &index);
|
||||||
void removePlugins(const QModelIndex &index);
|
void removePlugins(const QModelIndex &index);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ public:
|
||||||
MainDialog();
|
MainDialog();
|
||||||
|
|
||||||
//QStringListModel *mProfileModel;
|
//QStringListModel *mProfileModel;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void changePage(QListWidgetItem *current, QListWidgetItem *previous);
|
void changePage(QListWidgetItem *current, QListWidgetItem *previous);
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ private:
|
||||||
|
|
||||||
QListWidget *mIconWidget;
|
QListWidget *mIconWidget;
|
||||||
QStackedWidget *mPagesWidget;
|
QStackedWidget *mPagesWidget;
|
||||||
|
|
||||||
PlayPage *mPlayPage;
|
PlayPage *mPlayPage;
|
||||||
DataFilesPage *mDataFilesPage;
|
DataFilesPage *mDataFilesPage;
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,9 +12,9 @@ class PlayPage : public QWidget
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PlayPage(QWidget *parent = 0);
|
PlayPage(QWidget *parent = 0);
|
||||||
|
|
||||||
QComboBox *mProfileComboBox;
|
QComboBox *mProfileComboBox;
|
||||||
QStringListModel *mProfileModel;
|
QStringListModel *mProfileModel;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -3,120 +3,120 @@
|
||||||
#include "settingsdialog.h"
|
#include "settingsdialog.h"
|
||||||
|
|
||||||
SettingsDialog::SettingsDialog()
|
SettingsDialog::SettingsDialog()
|
||||||
{
|
{
|
||||||
QTabWidget *tabWidget = new QTabWidget(this);
|
QTabWidget *tabWidget = new QTabWidget(this);
|
||||||
QWidget *graphicsTab = new QWidget();
|
QWidget *graphicsTab = new QWidget();
|
||||||
|
|
||||||
// Render group
|
// Render group
|
||||||
QGroupBox *groupRender = new QGroupBox(tr("Renderer"), graphicsTab);
|
QGroupBox *groupRender = new QGroupBox(tr("Renderer"), graphicsTab);
|
||||||
groupRender->setMinimumWidth(450);
|
groupRender->setMinimumWidth(450);
|
||||||
|
|
||||||
QVBoxLayout *groupRenderLayout = new QVBoxLayout(groupRender);
|
QVBoxLayout *groupRenderLayout = new QVBoxLayout(groupRender);
|
||||||
QVBoxLayout *dialogLayout = new QVBoxLayout(this);
|
QVBoxLayout *dialogLayout = new QVBoxLayout(this);
|
||||||
QVBoxLayout *pageLayout = new QVBoxLayout(graphicsTab);
|
QVBoxLayout *pageLayout = new QVBoxLayout(graphicsTab);
|
||||||
|
|
||||||
QGridLayout *renderLayout = new QGridLayout();
|
QGridLayout *renderLayout = new QGridLayout();
|
||||||
|
|
||||||
QLabel *labelRender = new QLabel(tr("Rendering Subsystem:"), groupRender);
|
QLabel *labelRender = new QLabel(tr("Rendering Subsystem:"), groupRender);
|
||||||
comboRender = new QComboBox(groupRender);
|
comboRender = new QComboBox(groupRender);
|
||||||
|
|
||||||
QLabel *labelRTT = new QLabel(tr("Preferred RTT Mode:"), groupRender);
|
QLabel *labelRTT = new QLabel(tr("Preferred RTT Mode:"), groupRender);
|
||||||
comboRTT = new QComboBox(groupRender);
|
comboRTT = new QComboBox(groupRender);
|
||||||
|
|
||||||
QLabel *labelAA = new QLabel(tr("Antialiasing:"), groupRender);
|
QLabel *labelAA = new QLabel(tr("Antialiasing:"), groupRender);
|
||||||
comboAA = new QComboBox(groupRender);
|
comboAA = new QComboBox(groupRender);
|
||||||
|
|
||||||
renderLayout->addWidget(labelRender, 0, 0, 1, 1);
|
renderLayout->addWidget(labelRender, 0, 0, 1, 1);
|
||||||
renderLayout->addWidget(comboRender, 0, 1, 1, 1);
|
renderLayout->addWidget(comboRender, 0, 1, 1, 1);
|
||||||
|
|
||||||
QSpacerItem *vSpacer1 = new QSpacerItem(20, 10, QSizePolicy::Minimum, QSizePolicy::Minimum);
|
QSpacerItem *vSpacer1 = new QSpacerItem(20, 10, QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||||
renderLayout->addItem(vSpacer1, 1, 1, 1, 1);
|
renderLayout->addItem(vSpacer1, 1, 1, 1, 1);
|
||||||
|
|
||||||
renderLayout->addWidget(labelRTT, 2, 0, 1, 1);
|
renderLayout->addWidget(labelRTT, 2, 0, 1, 1);
|
||||||
renderLayout->addWidget(comboRTT, 2, 1, 1, 1);
|
renderLayout->addWidget(comboRTT, 2, 1, 1, 1);
|
||||||
renderLayout->addWidget(labelAA, 3, 0, 1, 1);
|
renderLayout->addWidget(labelAA, 3, 0, 1, 1);
|
||||||
renderLayout->addWidget(comboAA, 3, 1, 1, 1);
|
renderLayout->addWidget(comboAA, 3, 1, 1, 1);
|
||||||
|
|
||||||
QSpacerItem *vSpacer2 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
QSpacerItem *vSpacer2 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
||||||
|
|
||||||
groupRenderLayout->addLayout(renderLayout);
|
groupRenderLayout->addLayout(renderLayout);
|
||||||
groupRenderLayout->addItem(vSpacer2);
|
groupRenderLayout->addItem(vSpacer2);
|
||||||
|
|
||||||
pageLayout->addWidget(groupRender);
|
pageLayout->addWidget(groupRender);
|
||||||
|
|
||||||
// Display group
|
// Display group
|
||||||
QGroupBox *groupDisplay = new QGroupBox(tr("Display"), graphicsTab);
|
QGroupBox *groupDisplay = new QGroupBox(tr("Display"), graphicsTab);
|
||||||
QVBoxLayout *groupDisplayLayout = new QVBoxLayout(groupDisplay);
|
QVBoxLayout *groupDisplayLayout = new QVBoxLayout(groupDisplay);
|
||||||
|
|
||||||
QGridLayout *displayLayout = new QGridLayout();
|
QGridLayout *displayLayout = new QGridLayout();
|
||||||
|
|
||||||
QLabel *labelResolution = new QLabel(tr("Resolution:"), groupDisplay);
|
QLabel *labelResolution = new QLabel(tr("Resolution:"), groupDisplay);
|
||||||
comboResolution = new QComboBox(groupDisplay);
|
comboResolution = new QComboBox(groupDisplay);
|
||||||
|
|
||||||
QLabel *labelFrequency = new QLabel(tr("Display Frequency:"), groupDisplay);
|
QLabel *labelFrequency = new QLabel(tr("Display Frequency:"), groupDisplay);
|
||||||
comboFrequency = new QComboBox(groupDisplay);
|
comboFrequency = new QComboBox(groupDisplay);
|
||||||
|
|
||||||
checkVSync = new QCheckBox(tr("Vertical Sync"), groupDisplay);
|
checkVSync = new QCheckBox(tr("Vertical Sync"), groupDisplay);
|
||||||
checkGamma = new QCheckBox(tr("sRGB Gamma Conversion"), groupDisplay);
|
checkGamma = new QCheckBox(tr("sRGB Gamma Conversion"), groupDisplay);
|
||||||
checkFullScreen = new QCheckBox(tr("Full Screen"), groupDisplay);
|
checkFullScreen = new QCheckBox(tr("Full Screen"), groupDisplay);
|
||||||
|
|
||||||
displayLayout->addWidget(labelResolution, 0, 0, 1, 1);
|
displayLayout->addWidget(labelResolution, 0, 0, 1, 1);
|
||||||
displayLayout->addWidget(comboResolution, 0, 1, 1, 1);
|
displayLayout->addWidget(comboResolution, 0, 1, 1, 1);
|
||||||
displayLayout->addWidget(labelFrequency, 1, 0, 1, 1);
|
displayLayout->addWidget(labelFrequency, 1, 0, 1, 1);
|
||||||
displayLayout->addWidget(comboFrequency, 1, 1, 1, 1);
|
displayLayout->addWidget(comboFrequency, 1, 1, 1, 1);
|
||||||
|
|
||||||
QSpacerItem *vSpacer3 = new QSpacerItem(20, 10, QSizePolicy::Minimum, QSizePolicy::Minimum);
|
QSpacerItem *vSpacer3 = new QSpacerItem(20, 10, QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||||
displayLayout->addItem(vSpacer3, 2, 1, 1, 1);
|
displayLayout->addItem(vSpacer3, 2, 1, 1, 1);
|
||||||
|
|
||||||
displayLayout->addWidget(checkVSync, 3, 0, 1, 1);
|
displayLayout->addWidget(checkVSync, 3, 0, 1, 1);
|
||||||
displayLayout->addWidget(checkGamma, 3, 1, 1, 1);
|
displayLayout->addWidget(checkGamma, 3, 1, 1, 1);
|
||||||
displayLayout->addWidget(checkFullScreen, 6, 0, 1, 1);
|
displayLayout->addWidget(checkFullScreen, 6, 0, 1, 1);
|
||||||
|
|
||||||
QSpacerItem *vSpacer4 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
QSpacerItem *vSpacer4 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
||||||
|
|
||||||
groupDisplayLayout->addLayout(displayLayout);
|
groupDisplayLayout->addLayout(displayLayout);
|
||||||
groupDisplayLayout->addItem(vSpacer4);
|
groupDisplayLayout->addItem(vSpacer4);
|
||||||
|
|
||||||
pageLayout->addWidget(groupDisplay);
|
pageLayout->addWidget(groupDisplay);
|
||||||
|
|
||||||
|
|
||||||
tabWidget->addTab(graphicsTab, QString(tr("Graphics")));
|
tabWidget->addTab(graphicsTab, QString(tr("Graphics")));
|
||||||
tabWidget->setCurrentIndex(0);
|
tabWidget->setCurrentIndex(0);
|
||||||
|
|
||||||
dialogLayout->addWidget(tabWidget);
|
dialogLayout->addWidget(tabWidget);
|
||||||
|
|
||||||
QDialogButtonBox *buttonBox = new QDialogButtonBox(this);
|
QDialogButtonBox *buttonBox = new QDialogButtonBox(this);
|
||||||
buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
|
buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
|
||||||
|
|
||||||
dialogLayout->addWidget(buttonBox);
|
dialogLayout->addWidget(buttonBox);
|
||||||
|
|
||||||
setWindowTitle(tr("Settings"));
|
setWindowTitle(tr("Settings"));
|
||||||
setWindowIcon(QIcon::fromTheme("preferences-other"));
|
setWindowIcon(QIcon::fromTheme("preferences-other"));
|
||||||
|
|
||||||
// Ogre Settings
|
// Ogre Settings
|
||||||
// TODO: Find out a way to do this nice and platform-independent
|
// TODO: Find out a way to do this nice and platform-independent
|
||||||
QString filepath = QDir::homePath();
|
QString filepath = QDir::homePath();
|
||||||
filepath.append("/.config/openmw/ogre.cfg");
|
filepath.append("/.config/openmw/ogre.cfg");
|
||||||
|
|
||||||
ogreConfig = new QSettings(filepath, QSettings::IniFormat);
|
ogreConfig = new QSettings(filepath, QSettings::IniFormat);
|
||||||
|
|
||||||
// Signals and slots
|
// Signals and slots
|
||||||
connect(comboRender, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(rendererChanged(const QString&)));
|
connect(comboRender, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(rendererChanged(const QString&)));
|
||||||
connect(buttonBox, SIGNAL(accepted()), this, SLOT(writeConfig()));
|
connect(buttonBox, SIGNAL(accepted()), this, SLOT(writeConfig()));
|
||||||
connect(buttonBox, SIGNAL(rejected()), this, SLOT(close()));
|
connect(buttonBox, SIGNAL(rejected()), this, SLOT(close()));
|
||||||
|
|
||||||
// Ogre stuff
|
// Ogre stuff
|
||||||
root = new Ogre::Root("plugins.cfg");
|
root = new Ogre::Root("plugins.cfg");
|
||||||
|
|
||||||
// Get the available renderers and put them in the combobox
|
// Get the available renderers and put them in the combobox
|
||||||
const Ogre::RenderSystemList &renderers = root->getAvailableRenderers();
|
const Ogre::RenderSystemList &renderers = root->getAvailableRenderers();
|
||||||
|
|
||||||
for (Ogre::RenderSystemList::const_iterator r = renderers.begin(); r != renderers.end(); ++r) {
|
for (Ogre::RenderSystemList::const_iterator r = renderers.begin(); r != renderers.end(); ++r) {
|
||||||
comboRender->addItem((*r)->getName().c_str());
|
comboRender->addItem((*r)->getName().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
int index = comboRender->findText(getConfigValue("Render System"));
|
int index = comboRender->findText(getConfigValue("Render System"));
|
||||||
|
|
||||||
if ( index != -1) {
|
if ( index != -1) {
|
||||||
comboRender->setCurrentIndex(index);
|
comboRender->setCurrentIndex(index);
|
||||||
}
|
}
|
||||||
|
@ -126,10 +126,10 @@ SettingsDialog::SettingsDialog()
|
||||||
QStringList SettingsDialog::getAvailableOptions(const QString& key)
|
QStringList SettingsDialog::getAvailableOptions(const QString& key)
|
||||||
{
|
{
|
||||||
QStringList result;
|
QStringList result;
|
||||||
|
|
||||||
uint row = 0;
|
uint row = 0;
|
||||||
Ogre::ConfigOptionMap options = mSelectedRenderSystem->getConfigOptions();
|
Ogre::ConfigOptionMap options = mSelectedRenderSystem->getConfigOptions();
|
||||||
|
|
||||||
for (Ogre::ConfigOptionMap::iterator i = options.begin (); i != options.end (); i++, row++)
|
for (Ogre::ConfigOptionMap::iterator i = options.begin (); i != options.end (); i++, row++)
|
||||||
{
|
{
|
||||||
Ogre::StringVector::iterator opt_it;
|
Ogre::StringVector::iterator opt_it;
|
||||||
|
@ -137,64 +137,64 @@ QStringList SettingsDialog::getAvailableOptions(const QString& key)
|
||||||
for (opt_it = i->second.possibleValues.begin ();
|
for (opt_it = i->second.possibleValues.begin ();
|
||||||
opt_it != i->second.possibleValues.end (); opt_it++, idx++)
|
opt_it != i->second.possibleValues.end (); opt_it++, idx++)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (strcmp (key.toStdString().c_str(), i->first.c_str()) == 0)
|
if (strcmp (key.toStdString().c_str(), i->first.c_str()) == 0)
|
||||||
result << (*opt_it).c_str();
|
result << (*opt_it).c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsDialog::rendererChanged(const QString& renderer)
|
void SettingsDialog::rendererChanged(const QString& renderer)
|
||||||
{
|
{
|
||||||
// Set the render system to the selected one
|
// Set the render system to the selected one
|
||||||
mSelectedRenderSystem = root->getRenderSystemByName(renderer.toStdString().c_str());
|
mSelectedRenderSystem = root->getRenderSystemByName(renderer.toStdString().c_str());
|
||||||
|
|
||||||
comboRTT->addItems(getAvailableOptions("RTT Preferred Mode"));
|
comboRTT->addItems(getAvailableOptions("RTT Preferred Mode"));
|
||||||
comboAA->addItems(getAvailableOptions("FSAA"));
|
comboAA->addItems(getAvailableOptions("FSAA"));
|
||||||
comboResolution->addItems(getAvailableOptions("Video Mode"));
|
comboResolution->addItems(getAvailableOptions("Video Mode"));
|
||||||
comboFrequency->addItems(getAvailableOptions("Display Frequency"));
|
comboFrequency->addItems(getAvailableOptions("Display Frequency"));
|
||||||
|
|
||||||
// Get the value for the option the config file, find if it's in the combobox.
|
// Get the value for the option the config file, find if it's in the combobox.
|
||||||
// If it's found, set the current index to that value, otherwise: ignore.
|
// If it's found, set the current index to that value, otherwise: ignore.
|
||||||
|
|
||||||
int index = comboRTT->findText(getConfigValue("RTT Preferred Mode"));
|
int index = comboRTT->findText(getConfigValue("RTT Preferred Mode"));
|
||||||
if ( index != -1)
|
if ( index != -1)
|
||||||
comboRTT->setCurrentIndex(index);
|
comboRTT->setCurrentIndex(index);
|
||||||
|
|
||||||
index = comboAA->findText(getConfigValue("FSAA"));
|
index = comboAA->findText(getConfigValue("FSAA"));
|
||||||
if ( index != -1)
|
if ( index != -1)
|
||||||
comboAA->setCurrentIndex(index);
|
comboAA->setCurrentIndex(index);
|
||||||
|
|
||||||
index = comboResolution->findText(getConfigValue("Video Mode"));
|
index = comboResolution->findText(getConfigValue("Video Mode"));
|
||||||
if ( index != -1)
|
if ( index != -1)
|
||||||
comboResolution->setCurrentIndex(index);
|
comboResolution->setCurrentIndex(index);
|
||||||
|
|
||||||
index = comboFrequency->findText(getConfigValue("Display Frequency"));
|
index = comboFrequency->findText(getConfigValue("Display Frequency"));
|
||||||
if ( index != -1)
|
if ( index != -1)
|
||||||
comboFrequency->setCurrentIndex(index);
|
comboFrequency->setCurrentIndex(index);
|
||||||
|
|
||||||
// Now we do the same for the checkboxes
|
// Now we do the same for the checkboxes
|
||||||
if (QString::compare(getConfigValue("VSync"), QString("Yes")) == 0) {
|
if (QString::compare(getConfigValue("VSync"), QString("Yes")) == 0) {
|
||||||
checkVSync->setCheckState(Qt::Checked);
|
checkVSync->setCheckState(Qt::Checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (QString::compare(getConfigValue("sRGB Gamma Conversion"), QString("Yes")) == 0) {
|
if (QString::compare(getConfigValue("sRGB Gamma Conversion"), QString("Yes")) == 0) {
|
||||||
checkGamma->setCheckState(Qt::Checked);
|
checkGamma->setCheckState(Qt::Checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (QString::compare(getConfigValue("Full Screen"), QString("Yes")) == 0) {
|
if (QString::compare(getConfigValue("Full Screen"), QString("Yes")) == 0) {
|
||||||
checkFullScreen->setCheckState(Qt::Checked);
|
checkFullScreen->setCheckState(Qt::Checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SettingsDialog::getConfigValue(const QString& key)
|
QString SettingsDialog::getConfigValue(const QString& key)
|
||||||
{
|
{
|
||||||
QString result;
|
QString result;
|
||||||
|
|
||||||
ogreConfig->beginGroup(mSelectedRenderSystem->getName().c_str());
|
ogreConfig->beginGroup(mSelectedRenderSystem->getName().c_str());
|
||||||
result = ogreConfig->value(key).toString();
|
result = ogreConfig->value(key).toString();
|
||||||
ogreConfig->endGroup();
|
ogreConfig->endGroup();
|
||||||
|
@ -205,22 +205,22 @@ QString SettingsDialog::getConfigValue(const QString& key)
|
||||||
void SettingsDialog::writeConfig()
|
void SettingsDialog::writeConfig()
|
||||||
{
|
{
|
||||||
// Get the values from the GUI elements and write them to the config file
|
// Get the values from the GUI elements and write them to the config file
|
||||||
|
|
||||||
// Custom write method: We cannot use QSettings because it does not accept spaces
|
// Custom write method: We cannot use QSettings because it does not accept spaces
|
||||||
|
|
||||||
QString keyName;
|
QString keyName;
|
||||||
QString fileName;
|
QString fileName;
|
||||||
|
|
||||||
QFile file(ogreConfig->fileName());
|
QFile file(ogreConfig->fileName());
|
||||||
|
|
||||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate))
|
if (!file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate))
|
||||||
// File could not be opened, TODO error
|
// File could not be opened, TODO error
|
||||||
close();
|
close();
|
||||||
|
|
||||||
QTextStream out(&file);
|
QTextStream out(&file);
|
||||||
|
|
||||||
out << "Render System=" << mSelectedRenderSystem->getName().c_str() << endl << endl;
|
out << "Render System=" << mSelectedRenderSystem->getName().c_str() << endl << endl;
|
||||||
|
|
||||||
// add brackets to the renderer's name
|
// add brackets to the renderer's name
|
||||||
QString renderer = mSelectedRenderSystem->getName().c_str();
|
QString renderer = mSelectedRenderSystem->getName().c_str();
|
||||||
renderer.prepend("[");
|
renderer.prepend("[");
|
||||||
|
@ -229,21 +229,21 @@ void SettingsDialog::writeConfig()
|
||||||
|
|
||||||
out << "Display Frequency=" << comboFrequency->currentText() << endl;
|
out << "Display Frequency=" << comboFrequency->currentText() << endl;
|
||||||
out << "FSAA=" << comboAA->currentText() << endl;
|
out << "FSAA=" << comboAA->currentText() << endl;
|
||||||
|
|
||||||
if (checkFullScreen->checkState() == Qt::Checked) {
|
if (checkFullScreen->checkState() == Qt::Checked) {
|
||||||
out << "Full Screen=Yes" << endl;
|
out << "Full Screen=Yes" << endl;
|
||||||
} else {
|
} else {
|
||||||
out << "Full Screen=No" << endl;
|
out << "Full Screen=No" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
out << "RTT Preferred Mode=" << comboRTT->currentText() << endl;
|
out << "RTT Preferred Mode=" << comboRTT->currentText() << endl;
|
||||||
|
|
||||||
if (checkVSync->checkState() == Qt::Checked) {
|
if (checkVSync->checkState() == Qt::Checked) {
|
||||||
out << "VSync=Yes" << endl;
|
out << "VSync=Yes" << endl;
|
||||||
} else {
|
} else {
|
||||||
out << "VSync=No" << endl;
|
out << "VSync=No" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
out << "Video Mode=" << comboResolution->currentText() << endl;
|
out << "Video Mode=" << comboResolution->currentText() << endl;
|
||||||
|
|
||||||
if (checkGamma->checkState() == Qt::Checked) {
|
if (checkGamma->checkState() == Qt::Checked) {
|
||||||
|
@ -251,9 +251,9 @@ void SettingsDialog::writeConfig()
|
||||||
} else {
|
} else {
|
||||||
out << "sRGB Gamma Conversion=No" << endl;
|
out << "sRGB Gamma Conversion=No" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
close(); // Exit dialog
|
close(); // Exit dialog
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue