1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 18:19:55 +00:00

More consistency nit pick.

This commit is contained in:
cc9cii 2015-03-30 16:41:55 +11:00
parent 29ef08bb75
commit 619b5206cd
8 changed files with 54 additions and 51 deletions

View file

@ -19,7 +19,7 @@ opencs_hdrs_noqt (model/doc
opencs_units (model/world
idtable idtableproxymodel regionmap data commanddispatcher
idtablebase resourcetable nestedtablemodel
idtablebase resourcetable nestedtableproxymodel
)

View file

@ -51,7 +51,9 @@ QVariant CSMWorld::IdTable::data (const QModelIndex & index, int role) const
parentAdress.second,
index.row(),
index.column());
} else {
}
else
{
return mIdCollection->getData (index.row(), index.column());
}
}
@ -110,7 +112,8 @@ bool CSMWorld::IdTable::setData (const QModelIndex &index, const QVariant &value
CSMWorld::IdTable::index (parentAdress.second, mIdCollection->getColumns()-1));
return true;
} else
}
else
{
return false;
}
@ -149,7 +152,8 @@ bool CSMWorld::IdTable::removeRows (int row, int count, const QModelIndex& paren
{
dynamic_cast<NestedCollection*>(mIdCollection)->removeNestedRows(parent.row(), parent.column(), row+i);
}
} else
}
else
{
beginRemoveRows (parent, row, row+count-1);

View file

@ -1,9 +1,9 @@
#include "nestedtablemodel.hpp"
#include "nestedtableproxymodel.hpp"
#include <cassert>
#include "idtable.hpp"
CSMWorld::NestedTableModel::NestedTableModel(const QModelIndex& parent,
CSMWorld::NestedTableProxyModel::NestedTableProxyModel(const QModelIndex& parent,
ColumnBase::Display columnId,
CSMWorld::IdTable* parentModel)
: mParentColumn(parent.column()),
@ -14,10 +14,10 @@ CSMWorld::NestedTableModel::NestedTableModel(const QModelIndex& parent,
mId = std::string(parentModel->index(parentRow, 0).data().toString().toUtf8());
QAbstractProxyModel::setSourceModel(parentModel);
connect(mMainModel, SIGNAL(rowsAboutToBeInserted(const QModelIndex &, int, int)),
this, SLOT(forwardRowsAboutToInserted(const QModelIndex &, int, int)));
connect(mMainModel, SIGNAL(rowsInserted(const QModelIndex &, int, int)),
this, SLOT(forwardRowsInserted(const QModelIndex &, int, int)));
@ -26,7 +26,7 @@ CSMWorld::NestedTableModel::NestedTableModel(const QModelIndex& parent,
connect(mMainModel, SIGNAL(rowsRemoved(const QModelIndex &, int, int)),
this, SLOT(forwardRowsRemoved(const QModelIndex &, int, int)));
connect(mMainModel, SIGNAL(resetStart(const QString&)),
this, SLOT(forwardResetStart(const QString&)));
@ -34,7 +34,7 @@ CSMWorld::NestedTableModel::NestedTableModel(const QModelIndex& parent,
this, SLOT(forwardResetEnd(const QString&)));
}
QModelIndex CSMWorld::NestedTableModel::mapFromSource(const QModelIndex& sourceIndex) const
QModelIndex CSMWorld::NestedTableProxyModel::mapFromSource(const QModelIndex& sourceIndex) const
{
const QModelIndex& testedParent = mMainModel->parent(sourceIndex);
const QModelIndex& parent = mMainModel->getModelIndex (mId, mParentColumn);
@ -46,30 +46,29 @@ QModelIndex CSMWorld::NestedTableModel::mapFromSource(const QModelIndex& sourceI
{
return QModelIndex();
}
}
QModelIndex CSMWorld::NestedTableModel::mapToSource(const QModelIndex& proxyIndex) const
QModelIndex CSMWorld::NestedTableProxyModel::mapToSource(const QModelIndex& proxyIndex) const
{
const QModelIndex& parent = mMainModel->getModelIndex (mId, mParentColumn);
return mMainModel->index(proxyIndex.row(), proxyIndex.column(), parent);
}
int CSMWorld::NestedTableModel::rowCount(const QModelIndex& index) const
int CSMWorld::NestedTableProxyModel::rowCount(const QModelIndex& index) const
{
assert (!index.isValid());
return mMainModel->rowCount(mMainModel->getModelIndex(mId, mParentColumn));
}
int CSMWorld::NestedTableModel::columnCount(const QModelIndex& parent) const
int CSMWorld::NestedTableProxyModel::columnCount(const QModelIndex& parent) const
{
assert (!parent.isValid());
return mMainModel->columnCount(mMainModel->getModelIndex(mId, mParentColumn));
}
QModelIndex CSMWorld::NestedTableModel::index(int row, int column, const QModelIndex& parent) const
QModelIndex CSMWorld::NestedTableProxyModel::index(int row, int column, const QModelIndex& parent) const
{
assert (!parent.isValid());
@ -87,12 +86,12 @@ QModelIndex CSMWorld::NestedTableModel::index(int row, int column, const QModelI
return createIndex(row, column);
}
QModelIndex CSMWorld::NestedTableModel::parent(const QModelIndex& index) const
QModelIndex CSMWorld::NestedTableProxyModel::parent(const QModelIndex& index) const
{
return QModelIndex();
}
QVariant CSMWorld::NestedTableModel::headerData(int section,
QVariant CSMWorld::NestedTableProxyModel::headerData(int section,
Qt::Orientation orientation,
int role) const
{
@ -100,32 +99,32 @@ QVariant CSMWorld::NestedTableModel::headerData(int section,
}
bool CSMWorld::NestedTableModel::setData ( const QModelIndex & index, const QVariant & value, int role)
bool CSMWorld::NestedTableProxyModel::setData ( const QModelIndex & index, const QVariant & value, int role)
{
return mMainModel->setData(mapToSource(index), value, role);
}
Qt::ItemFlags CSMWorld::NestedTableModel::flags(const QModelIndex& index) const
Qt::ItemFlags CSMWorld::NestedTableProxyModel::flags(const QModelIndex& index) const
{
return mMainModel->flags(mMainModel->index(0, mParentColumn));
}
std::string CSMWorld::NestedTableModel::getParentId() const
std::string CSMWorld::NestedTableProxyModel::getParentId() const
{
return mId;
}
int CSMWorld::NestedTableModel::getParentColumn() const
int CSMWorld::NestedTableProxyModel::getParentColumn() const
{
return mParentColumn;
}
CSMWorld::IdTable* CSMWorld::NestedTableModel::model() const
CSMWorld::IdTable* CSMWorld::NestedTableProxyModel::model() const
{
return mMainModel;
}
void CSMWorld::NestedTableModel::forwardRowsAboutToInserted(const QModelIndex& parent, int first, int last)
void CSMWorld::NestedTableProxyModel::forwardRowsAboutToInserted(const QModelIndex& parent, int first, int last)
{
if (indexIsParent(parent))
{
@ -133,7 +132,7 @@ void CSMWorld::NestedTableModel::forwardRowsAboutToInserted(const QModelIndex& p
}
}
void CSMWorld::NestedTableModel::forwardRowsInserted(const QModelIndex& parent, int first, int last)
void CSMWorld::NestedTableProxyModel::forwardRowsInserted(const QModelIndex& parent, int first, int last)
{
if (indexIsParent(parent))
{
@ -141,14 +140,14 @@ void CSMWorld::NestedTableModel::forwardRowsInserted(const QModelIndex& parent,
}
}
bool CSMWorld::NestedTableModel::indexIsParent(const QModelIndex& index)
bool CSMWorld::NestedTableProxyModel::indexIsParent(const QModelIndex& index)
{
return (index.isValid() &&
index.column() == mParentColumn &&
mMainModel->data(mMainModel->index(index.row(), 0)).toString().toUtf8().constData() == mId);
}
void CSMWorld::NestedTableModel::forwardRowsAboutToRemoved(const QModelIndex& parent, int first, int last)
void CSMWorld::NestedTableProxyModel::forwardRowsAboutToRemoved(const QModelIndex& parent, int first, int last)
{
if (indexIsParent(parent))
{
@ -156,7 +155,7 @@ void CSMWorld::NestedTableModel::forwardRowsAboutToRemoved(const QModelIndex& pa
}
}
void CSMWorld::NestedTableModel::forwardRowsRemoved(const QModelIndex& parent, int first, int last)
void CSMWorld::NestedTableProxyModel::forwardRowsRemoved(const QModelIndex& parent, int first, int last)
{
if (indexIsParent(parent))
{
@ -164,13 +163,13 @@ void CSMWorld::NestedTableModel::forwardRowsRemoved(const QModelIndex& parent, i
}
}
void CSMWorld::NestedTableModel::forwardResetStart(const QString& id)
void CSMWorld::NestedTableProxyModel::forwardResetStart(const QString& id)
{
if (id.toUtf8() == mId.c_str())
beginResetModel();
}
void CSMWorld::NestedTableModel::forwardResetEnd(const QString& id)
void CSMWorld::NestedTableProxyModel::forwardResetEnd(const QString& id)
{
if (id.toUtf8() == mId.c_str())
endResetModel();

View file

@ -1,5 +1,5 @@
#ifndef CSM_WOLRD_NESTEDTABLEMODEL_H
#define CSM_WOLRD_NESTEDTABLEMODEL_H
#ifndef CSM_WOLRD_NESTEDTABLEPROXYMODEL_H
#define CSM_WOLRD_NESTEDTABLEPROXYMODEL_H
#include <vector>
@ -19,7 +19,7 @@ namespace CSMWorld
class RecordBase;
class IdTable;
class NestedTableModel : public QAbstractProxyModel
class NestedTableProxyModel : public QAbstractProxyModel
{
Q_OBJECT
@ -28,15 +28,15 @@ namespace CSMWorld
std::string mId;
public:
NestedTableModel(const QModelIndex& parent,
NestedTableProxyModel(const QModelIndex& parent,
ColumnBase::Display displayType,
IdTable* parentModel);
//parent is the parent of columns to work with. Columnid provides information about the column
std::string getParentId() const;
int getParentColumn() const;
CSMWorld::IdTable* model() const;
virtual QModelIndex mapFromSource(const QModelIndex& sourceIndex) const;
@ -52,27 +52,27 @@ namespace CSMWorld
virtual QModelIndex parent(const QModelIndex& index) const;
virtual QVariant headerData ( int section, Qt::Orientation orientation, int role ) const;
virtual bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole );
virtual Qt::ItemFlags flags(const QModelIndex& index) const;
private:
void setupHeaderVectors(ColumnBase::Display columnId);
bool indexIsParent(const QModelIndex& index);
private slots:
void forwardRowsAboutToInserted(const QModelIndex & parent, int first, int last);
void forwardRowsInserted(const QModelIndex & parent, int first, int last);
void forwardRowsAboutToRemoved(const QModelIndex & parent, int first, int last);
void forwardRowsRemoved(const QModelIndex & parent, int first, int last);
void forwardResetStart(const QString& id);
void forwardResetEnd(const QString& id);
};
}

View file

@ -23,7 +23,7 @@
#include <QHeaderView>
#include <QDebug>
#include "../../model/world/nestedtablemodel.hpp"
#include "../../model/world/nestedtableproxymodel.hpp"
#include "../../model/world/columnbase.hpp"
#include "../../model/world/idtable.hpp"
#include "../../model/world/columns.hpp"
@ -422,7 +422,7 @@ void CSVWorld::EditWidget::remake(int row)
if (mTable->hasChildren(mTable->index(row, i)))
{
mNestedModels.push_back(new CSMWorld::NestedTableModel (mTable->index(row, i), display, mTable));
mNestedModels.push_back(new CSMWorld::NestedTableProxyModel (mTable->index(row, i), display, mTable));
NestedTable* table = new NestedTable(mDocument, mNestedModels.back(), this);

View file

@ -21,7 +21,7 @@ class QVBoxLayout;
namespace CSMWorld
{
class IdTable;
class NestedTableModel;
class NestedTableProxyModel;
}
namespace CSMDoc
@ -165,7 +165,7 @@ namespace CSVWorld
QWidget* mMainWidget;
CSMWorld::IdTable* mTable;
CSMDoc::Document& mDocument;
std::vector<CSMWorld::NestedTableModel*> mNestedModels; //Plain, raw C pointers, deleted in the dtor
std::vector<CSMWorld::NestedTableProxyModel*> mNestedModels; //Plain, raw C pointers, deleted in the dtor
public:

View file

@ -1,5 +1,5 @@
#include "nestedtable.hpp"
#include "../../model/world/nestedtablemodel.hpp"
#include "../../model/world/nestedtableproxymodel.hpp"
#include "../../model/world/universalid.hpp"
#include "../../model/world/commands.hpp"
#include "util.hpp"
@ -10,7 +10,7 @@
#include <QDebug>
CSVWorld::NestedTable::NestedTable(CSMDoc::Document& document,
CSMWorld::NestedTableModel* model,
CSMWorld::NestedTableProxyModel* model,
QWidget* parent)
: QTableView(parent),
mUndoStack(document.getUndoStack()),

View file

@ -10,7 +10,7 @@ class QContextMenuEvent;
namespace CSMWorld
{
class NestedTableModel;
class NestedTableProxyModel;
class UniversalId;
}
@ -28,11 +28,11 @@ namespace CSVWorld
QAction *mAddNewRowAction;
QAction *mRemoveRowAction;
QUndoStack& mUndoStack;
CSMWorld::NestedTableModel* mModel;
CSMWorld::NestedTableProxyModel* mModel;
public:
NestedTable(CSMDoc::Document& document,
CSMWorld::NestedTableModel* model,
CSMWorld::NestedTableProxyModel* model,
QWidget* parent = NULL);
protected: