forked from mirror/openmw-tes3mp
Removed some leftover files and more testing
This commit is contained in:
parent
96e7df36e5
commit
fbdc10f0b0
5 changed files with 128 additions and 200 deletions
|
@ -1,14 +1,10 @@
|
|||
set(LAUNCHER
|
||||
datafilesdialog.cpp
|
||||
datafilesmodel.cpp
|
||||
datafilesitem.cpp
|
||||
lineedit.cpp
|
||||
main.cpp
|
||||
maindialog.cpp
|
||||
settingsdialog.cpp
|
||||
datafilesdialog.h
|
||||
datafilesmodel.h
|
||||
datafilesitem.h
|
||||
lineedit.h
|
||||
maindialog.h
|
||||
settingsdialog.h
|
||||
|
@ -16,8 +12,6 @@ set(LAUNCHER
|
|||
|
||||
SET(MOC_HDRS
|
||||
datafilesdialog.h
|
||||
datafilesmodel.h
|
||||
datafilesitem.h
|
||||
lineedit.h
|
||||
maindialog.h
|
||||
settingsdialog.h
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include <components/esm/esm_reader.hpp>
|
||||
|
||||
#include "datafilesdialog.h"
|
||||
//#include "pluginitemmodel.h"
|
||||
//#include "datafilesmodel.h"
|
||||
//#include "datafilesitem.h"
|
||||
|
||||
|
@ -14,6 +15,28 @@ DataFilesDialog::DataFilesDialog()
|
|||
mastertable = new QTableView(this);
|
||||
plugintable = new QTableView(this);
|
||||
|
||||
/* listtest
|
||||
QTableWidget *pluginlist = new QTableWidget(this);
|
||||
|
||||
pluginlist->horizontalHeader()->setStretchLastSection(true);
|
||||
pluginlist->insertColumn(0);
|
||||
|
||||
for (unsigned int i=0; i<6; ++i) {
|
||||
pluginlist->insertRow(i);
|
||||
QTableWidgetItem *item = new QTableWidgetItem(QString("Plugin %0").arg(i));
|
||||
item->setFlags(item->flags() & ~(Qt::ItemIsDropEnabled));
|
||||
pluginlist->setItem(i, 0, item);
|
||||
}
|
||||
|
||||
pluginlist->insertRow(6);
|
||||
pluginlist->setSelectionMode(QAbstractItemView::SingleSelection); // single item can be draged or droped
|
||||
pluginlist->setDragEnabled(true);
|
||||
pluginlist->setDragDropMode(QAbstractItemView::InternalMove);
|
||||
pluginlist->viewport()->setAcceptDrops(true);
|
||||
|
||||
pluginlist->setDropIndicatorShown(true);
|
||||
*/
|
||||
|
||||
splitter->setOrientation(Qt::Vertical);
|
||||
splitter->addWidget(tree);
|
||||
splitter->addWidget(mastertable);
|
||||
|
@ -63,6 +86,7 @@ DataFilesDialog::DataFilesDialog()
|
|||
// Add the masters to mastersmodel
|
||||
foreach (const QString ¤tmaster, masters) {
|
||||
QStandardItem *item = new QStandardItem(currentmaster);
|
||||
item->setFlags(item->flags() & ~(Qt::ItemIsDropEnabled));
|
||||
|
||||
QList<QStandardItem*> foundmasters = mastersmodel->findItems(currentmaster);
|
||||
|
||||
|
@ -74,7 +98,9 @@ DataFilesDialog::DataFilesDialog()
|
|||
|
||||
// Add the masters to datafilesmodel
|
||||
QStandardItem *item = new QStandardItem(masters.join(","));
|
||||
item->setFlags(item->flags() & ~(Qt::ItemIsDropEnabled));
|
||||
QStandardItem *child = new QStandardItem(currentfile);
|
||||
child->setFlags(child->flags() & ~(Qt::ItemIsDropEnabled));
|
||||
|
||||
QList<QStandardItem*> masteritems = datafilesmodel->findItems(masters.join(","));
|
||||
|
||||
|
@ -84,6 +110,7 @@ DataFilesDialog::DataFilesDialog()
|
|||
datafilesmodel->appendRow(item);
|
||||
} else {
|
||||
foreach (QStandardItem *currentitem, masteritems) {
|
||||
currentitem->setFlags(currentitem->flags() & ~(Qt::ItemIsDropEnabled));
|
||||
currentitem->appendRow(child);
|
||||
}
|
||||
}
|
||||
|
@ -106,7 +133,12 @@ DataFilesDialog::DataFilesDialog()
|
|||
|
||||
|
||||
pluginsmodel = new QStandardItemModel(0, 1);
|
||||
pluginsmodel->setSupportedDragActions(Qt::MoveAction);
|
||||
pluginsmodel->invisibleRootItem()->setFlags(Qt::ItemIsDropEnabled);
|
||||
|
||||
|
||||
masterselectmodel = new QItemSelectionModel(mastersmodel);
|
||||
pluginselectmodel = new QItemSelectionModel(pluginsmodel);
|
||||
|
||||
tree->setModel(datafilesmodel);
|
||||
tree->header()->hide();
|
||||
|
@ -121,13 +153,25 @@ DataFilesDialog::DataFilesDialog()
|
|||
mastertable->horizontalHeader()->hide();
|
||||
|
||||
plugintable->setModel(pluginsmodel);
|
||||
plugintable->setSelectionModel(pluginselectmodel);
|
||||
plugintable->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
plugintable->setSelectionMode(QAbstractItemView::MultiSelection);
|
||||
plugintable->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
plugintable->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||
plugintable->horizontalHeader()->setStretchLastSection(true);
|
||||
plugintable->horizontalHeader()->hide();
|
||||
|
||||
plugintable->setDragEnabled(true);
|
||||
plugintable->setDragDropMode(QAbstractItemView::InternalMove);
|
||||
plugintable->setDropIndicatorShown(true);
|
||||
plugintable->setDragDropOverwriteMode(false);
|
||||
plugintable->viewport()->setAcceptDrops(true);
|
||||
|
||||
plugintable->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
|
||||
|
||||
connect(masterselectmodel, SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), this, SLOT(masterSelectionChanged(const QItemSelection&, const QItemSelection&)));
|
||||
connect(plugintable, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showContextMenu(const QPoint&)));
|
||||
connect(plugintable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setCheckstate(QModelIndex)));
|
||||
|
||||
// Adjust the dialog width
|
||||
setMinimumWidth(500);
|
||||
|
@ -150,6 +194,8 @@ void DataFilesDialog::appendPlugins(const QModelIndex &masterindex)
|
|||
{
|
||||
// Plugin not yet in the pluginsmodel, add it
|
||||
QStandardItem *item = new QStandardItem(QVariant(datafilesmodel->data(childindex)).toString());
|
||||
item->setFlags(item->flags() & ~(Qt::ItemIsDropEnabled));
|
||||
item->setCheckable(true);
|
||||
pluginsmodel->appendRow(item);
|
||||
}
|
||||
}
|
||||
|
@ -238,6 +284,78 @@ void DataFilesDialog::masterSelectionChanged(const QItemSelection &selected, con
|
|||
}
|
||||
}
|
||||
|
||||
void DataFilesDialog::showContextMenu(const QPoint &point)
|
||||
{
|
||||
qDebug() << "Show me the money!";
|
||||
|
||||
|
||||
|
||||
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 *action3 = new QAction(QIcon::fromTheme("arrow-up"), tr("Move Up"), this);
|
||||
QAction *action4 = new QAction(QIcon::fromTheme("arrow-down"), tr("Move Down"), this);
|
||||
QAction *action5 = new QAction(this);
|
||||
|
||||
QModelIndex index = plugintable->indexAt(point);
|
||||
|
||||
if (index.isValid()) { // Should be valid!
|
||||
const QStandardItem *item = pluginsmodel->itemFromIndex(index);
|
||||
|
||||
if (item->checkState() == Qt::Checked) {
|
||||
action5->setText("Uncheck Item");
|
||||
} else if (item->checkState() == Qt::Unchecked) {
|
||||
action5->setText("Check Item");
|
||||
}
|
||||
}
|
||||
|
||||
connect(action5, SIGNAL(triggered()), this, SLOT(actionCheckstate()));
|
||||
|
||||
QMenu menu(this);
|
||||
menu.addAction(action1);
|
||||
menu.addAction(action2);
|
||||
menu.addSeparator();
|
||||
menu.addAction(action3);
|
||||
menu.addAction(action4);
|
||||
menu.addSeparator();
|
||||
menu.addAction(action5);
|
||||
|
||||
menu.exec(plugintable->viewport()->mapToGlobal(point));
|
||||
|
||||
}
|
||||
|
||||
void DataFilesDialog::actionCheckstate()
|
||||
{
|
||||
qDebug() << "actionCheckstate";
|
||||
|
||||
const QModelIndexList selectedindexes = pluginselectmodel->selectedIndexes();
|
||||
|
||||
// Should only be one index selected
|
||||
foreach (const QModelIndex ¤tindex, selectedindexes) {
|
||||
setCheckstate(currentindex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void DataFilesDialog::setCheckstate(QModelIndex index)
|
||||
{
|
||||
// No check if index is valid: doubleclicked() always returns
|
||||
// a valid index when emitted
|
||||
|
||||
//index = QModelIndex(sortModel->mapToSource(index)); // Get a valid index
|
||||
index = index.sibling(index.row(), 0); // reset index to first column
|
||||
// because that's where te checkbox is; makes it possible to doubleclick whole row
|
||||
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
||||
if (pluginsmodel->data(index, Qt::CheckStateRole) == Qt::Checked) {
|
||||
// Selected row is checked, uncheck it
|
||||
pluginsmodel->setData(index, Qt::Unchecked, Qt::CheckStateRole);
|
||||
} else {
|
||||
pluginsmodel->setData(index, Qt::Checked, Qt::CheckStateRole);
|
||||
}
|
||||
}
|
||||
|
||||
void DataFilesDialog::readConfig()
|
||||
{
|
||||
/* QString filename;
|
||||
|
@ -407,3 +525,4 @@ void DataFilesDialog::restoreDefaults()
|
|||
* /
|
||||
}
|
||||
*/
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ class QSortFilterProxyModel;
|
|||
#include <QDialog>
|
||||
#include <QModelIndex>
|
||||
|
||||
class PluginItemModel;
|
||||
class QTreeView;
|
||||
class QTableView;
|
||||
class QStandardItemModel;
|
||||
|
@ -48,6 +49,7 @@ private:
|
|||
QStandardItemModel *pluginsmodel;
|
||||
|
||||
QItemSelectionModel *masterselectmodel;
|
||||
QItemSelectionModel *pluginselectmodel;
|
||||
|
||||
QTreeView *tree;
|
||||
|
||||
|
@ -63,11 +65,14 @@ public slots:
|
|||
void restoreDefaults();
|
||||
void readConfig();
|
||||
void writeConfig();
|
||||
void showContextMenu(const QPoint &point);
|
||||
|
||||
void actionCheckstate();
|
||||
//void setupView();
|
||||
|
||||
void masterSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
|
||||
//void setFilter();
|
||||
//void setCheckstate(QModelIndex index);
|
||||
void setCheckstate(QModelIndex index);
|
||||
// void doubleClicked(QModelIndex index);
|
||||
|
||||
};
|
||||
|
|
|
@ -1,155 +0,0 @@
|
|||
#include <QtGui>
|
||||
|
||||
#include "datafilesitem.h"
|
||||
#include "datafilesmodel.h"
|
||||
|
||||
//DataFilesModel::DataFilesModel(const QString &data, QObject *parent)
|
||||
DataFilesModel::DataFilesModel(QObject *parent)
|
||||
: QAbstractItemModel(parent)
|
||||
{
|
||||
QList<QVariant> rootData;
|
||||
rootData << " ";
|
||||
//rootItem = new DataFilesItem(rootData);
|
||||
rootItem = new DataFilesItem(rootData);
|
||||
//setupModelData(data.split(QString("\n")), rootItem);
|
||||
}
|
||||
|
||||
DataFilesModel::~DataFilesModel()
|
||||
{
|
||||
delete rootItem;
|
||||
}
|
||||
|
||||
int DataFilesModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
if (parent.isValid())
|
||||
return static_cast<DataFilesItem*>(parent.internalPointer())->columnCount();
|
||||
else
|
||||
return rootItem->columnCount();
|
||||
}
|
||||
|
||||
QVariant DataFilesModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
||||
if (role != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
|
||||
DataFilesItem *item = static_cast<DataFilesItem*>(index.internalPointer());
|
||||
|
||||
return item->data(index.column());
|
||||
}
|
||||
|
||||
Qt::ItemFlags DataFilesModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return 0;
|
||||
|
||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||
}
|
||||
|
||||
QVariant DataFilesModel::headerData(int section, Qt::Orientation orientation,
|
||||
int role) const
|
||||
{
|
||||
if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
|
||||
return rootItem->data(section);
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QModelIndex DataFilesModel::index(int row, int column, const QModelIndex &parent)
|
||||
const
|
||||
{
|
||||
if (!hasIndex(row, column, parent))
|
||||
return QModelIndex();
|
||||
|
||||
DataFilesItem *parentItem;
|
||||
|
||||
if (!parent.isValid())
|
||||
parentItem = rootItem;
|
||||
else
|
||||
parentItem = static_cast<DataFilesItem*>(parent.internalPointer());
|
||||
|
||||
DataFilesItem *childItem = parentItem->child(row);
|
||||
if (childItem)
|
||||
return createIndex(row, column, childItem);
|
||||
else
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
QModelIndex DataFilesModel::parent(const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QModelIndex();
|
||||
|
||||
DataFilesItem *childItem = static_cast<DataFilesItem*>(index.internalPointer());
|
||||
DataFilesItem *parentItem = childItem->parent();
|
||||
|
||||
if (parentItem == rootItem)
|
||||
return QModelIndex();
|
||||
|
||||
return createIndex(parentItem->row(), 0, parentItem);
|
||||
}
|
||||
|
||||
int DataFilesModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
DataFilesItem *parentItem;
|
||||
if (parent.column() > 0)
|
||||
return 0;
|
||||
|
||||
if (!parent.isValid())
|
||||
parentItem = rootItem;
|
||||
else
|
||||
parentItem = static_cast<DataFilesItem*>(parent.internalPointer());
|
||||
|
||||
return parentItem->childCount();
|
||||
}
|
||||
|
||||
/*void DataFilesModel::setupModelData(const QStringList &lines, DataFilesItem *parent)
|
||||
{
|
||||
QList<DataFilesItem*> parents;
|
||||
QList<int> indentations;
|
||||
parents << parent;
|
||||
indentations << 0;
|
||||
|
||||
int number = 0;
|
||||
|
||||
while (number < lines.count()) {
|
||||
int position = 0;
|
||||
while (position < lines[number].length()) {
|
||||
if (lines[number].mid(position, 1) != " ")
|
||||
break;
|
||||
position++;
|
||||
}
|
||||
|
||||
QString lineData = lines[number].mid(position).trimmed();
|
||||
|
||||
if (!lineData.isEmpty()) {
|
||||
// Read the column data from the rest of the line.
|
||||
QStringList columnStrings = lineData.split("\t", QString::SkipEmptyParts);
|
||||
QList<QVariant> columnData;
|
||||
for (int column = 0; column < columnStrings.count(); ++column)
|
||||
columnData << columnStrings[column];
|
||||
|
||||
if (position > indentations.last()) {
|
||||
// The last child of the current parent is now the new parent
|
||||
// unless the current parent has no children.
|
||||
|
||||
if (parents.last()->childCount() > 0) {
|
||||
parents << parents.last()->child(parents.last()->childCount()-1);
|
||||
indentations << position;
|
||||
}
|
||||
} else {
|
||||
while (position < indentations.last() && parents.count() > 0) {
|
||||
parents.pop_back();
|
||||
indentations.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
// Append a new item to the current parent's list of children.
|
||||
parents.last()->appendChild(new DataFilesItem(columnData, parents.last()));
|
||||
}
|
||||
|
||||
number++;
|
||||
}
|
||||
}*/
|
|
@ -1,35 +0,0 @@
|
|||
#ifndef DATAFILESMODEL_H
|
||||
#define DATAFILESMODEL_H
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <QModelIndex>
|
||||
#include <QVariant>
|
||||
|
||||
class DataFilesItem;
|
||||
|
||||
class DataFilesModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//DataFilesModel(const QString &data, QObject *parent = 0);
|
||||
DataFilesModel(QObject *parent = 0);
|
||||
~DataFilesModel();
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
QVariant headerData(int section, Qt::Orientation orientation,
|
||||
int role = Qt::DisplayRole) const;
|
||||
QModelIndex index(int row, int column,
|
||||
const QModelIndex &parent = QModelIndex()) const;
|
||||
QModelIndex parent(const QModelIndex &index) const;
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
|
||||
private:
|
||||
//void setupModelData(const QStringList &lines, TreeItem *parent);
|
||||
|
||||
DataFilesItem *rootItem;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue