1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-06-19 13:41:32 +00:00

Resolved compile issues, but not fully working.

This commit is contained in:
cc9cii 2015-03-06 14:36:13 +11:00
parent fb2ba7610c
commit 6d6ff8c6a4
5 changed files with 51 additions and 51 deletions

View file

@ -31,7 +31,7 @@ int CSMWorld::IdTable::columnCount (const QModelIndex & parent) const
{ {
return dynamic_cast<NestedCollection*>(mIdCollection)->getNestedColumnsCount(parent.row(), parent.column()); return dynamic_cast<NestedCollection*>(mIdCollection)->getNestedColumnsCount(parent.row(), parent.column());
} }
return mIdCollection->getColumns(); return mIdCollection->getColumns();
} }
@ -72,7 +72,7 @@ QVariant CSMWorld::IdTable::headerData (int section,
{ {
return mIdCollection->getColumn (section).mDisplayType; return mIdCollection->getColumn (section).mDisplayType;
} }
return QVariant(); return QVariant();
} }
@ -104,7 +104,7 @@ bool CSMWorld::IdTable::setData (const QModelIndex &index, const QVariant &value
const std::pair<int, int>& parentAdress(unfoldIndexAdress(index.internalId())); const std::pair<int, int>& parentAdress(unfoldIndexAdress(index.internalId()));
dynamic_cast<NestedCollection*>(mIdCollection)->setNestedData(parentAdress.first, parentAdress.second, value, index.row(), index.column()); dynamic_cast<NestedCollection*>(mIdCollection)->setNestedData(parentAdress.first, parentAdress.second, value, index.row(), index.column());
emit dataChanged (CSMWorld::IdTable::index (parentAdress.first, 0), emit dataChanged (CSMWorld::IdTable::index (parentAdress.first, 0),
CSMWorld::IdTable::index (parentAdress.second, mIdCollection->getColumns()-1)); CSMWorld::IdTable::index (parentAdress.second, mIdCollection->getColumns()-1));
@ -114,17 +114,17 @@ bool CSMWorld::IdTable::setData (const QModelIndex &index, const QVariant &value
return false; return false;
} }
} }
if (mIdCollection->getColumn (index.column()).isEditable() && role==Qt::EditRole) if (mIdCollection->getColumn (index.column()).isEditable() && role==Qt::EditRole)
{ {
mIdCollection->setData (index.row(), index.column(), value); mIdCollection->setData (index.row(), index.column(), value);
emit dataChanged (CSMWorld::IdTable::index (index.row(), 0), emit dataChanged (CSMWorld::IdTable::index (index.row(), 0),
CSMWorld::IdTable::index (index.row(), mIdCollection->getColumns()-1)); CSMWorld::IdTable::index (index.row(), mIdCollection->getColumns()-1));
return true; return true;
} }
return false; return false;
} }
@ -177,7 +177,7 @@ void CSMWorld::IdTable::addNestedRow(const QModelIndex& parent, int position)
dynamic_cast<NestedCollection*>(mIdCollection)->addNestedRow(row, parent.column(), position); dynamic_cast<NestedCollection*>(mIdCollection)->addNestedRow(row, parent.column(), position);
endInsertRows(); endInsertRows();
emit dataChanged (CSMWorld::IdTable::index (row, 0), emit dataChanged (CSMWorld::IdTable::index (row, 0),
CSMWorld::IdTable::index (row, mIdCollection->getColumns()-1)); CSMWorld::IdTable::index (row, mIdCollection->getColumns()-1));
} }
@ -353,7 +353,7 @@ std::pair< int, int > CSMWorld::IdTable::unfoldIndexAdress (unsigned int id) con
--id; --id;
int row = id / this->columnCount(); int row = id / this->columnCount();
int column = id - row * this->columnCount(); int column = id - row * this->columnCount();
return std::make_pair<int, int>(row, column); return std::make_pair (row, column);
} }
bool CSMWorld::IdTable::hasChildren(const QModelIndex& index) const bool CSMWorld::IdTable::hasChildren(const QModelIndex& index) const
@ -370,14 +370,14 @@ void CSMWorld::IdTable::setNestedTable(const QModelIndex& index, const CSMWorld:
{ {
throw std::logic_error("Tried to set nested table, but index has no children"); throw std::logic_error("Tried to set nested table, but index has no children");
} }
bool removeRowsMode = false; bool removeRowsMode = false;
if (nestedTable.size() != this->nestedTable(index)->size()) if (nestedTable.size() != this->nestedTable(index)->size())
{ {
emit resetStart(this->index(index.row(), 0).data().toString()); emit resetStart(this->index(index.row(), 0).data().toString());
removeRowsMode = true; removeRowsMode = true;
} }
dynamic_cast<NestedCollection*>(mIdCollection)->setNestedTable(index.row(), index.column(), nestedTable); dynamic_cast<NestedCollection*>(mIdCollection)->setNestedTable(index.row(), index.column(), nestedTable);
emit dataChanged (CSMWorld::IdTable::index (index.row(), 0), emit dataChanged (CSMWorld::IdTable::index (index.row(), 0),
@ -395,6 +395,6 @@ CSMWorld::NestedTableWrapperBase* CSMWorld::IdTable::nestedTable(const QModelInd
{ {
throw std::logic_error("Tried to retrive nested table, but index has no children"); throw std::logic_error("Tried to retrive nested table, but index has no children");
} }
return dynamic_cast<NestedCollection*>(mIdCollection)->nestedTable(index.row(), index.column()); return dynamic_cast<NestedCollection*>(mIdCollection)->nestedTable(index.row(), index.column());
} }

View file

@ -281,7 +281,7 @@ QWidget* CSVWorld::DialogueDelegateDispatcher::makeEditor(CSMWorld::ColumnBase::
connect(proxy, SIGNAL(tableMimeDataDropped(QWidget*, const QModelIndex&, const CSMWorld::UniversalId&, const CSMDoc::Document*)), connect(proxy, SIGNAL(tableMimeDataDropped(QWidget*, const QModelIndex&, const CSMWorld::UniversalId&, const CSMDoc::Document*)),
this, SIGNAL(tableMimeDataDropped(QWidget*, const QModelIndex&, const CSMWorld::UniversalId&, const CSMDoc::Document*))); this, SIGNAL(tableMimeDataDropped(QWidget*, const QModelIndex&, const CSMWorld::UniversalId&, const CSMDoc::Document*)));
skip = true; //skip = true;
} }
else if (qobject_cast<QCheckBox*>(editor)) else if (qobject_cast<QCheckBox*>(editor))
{ {
@ -298,7 +298,7 @@ QWidget* CSVWorld::DialogueDelegateDispatcher::makeEditor(CSMWorld::ColumnBase::
else if (qobject_cast<QAbstractSpinBox*>(editor)) else if (qobject_cast<QAbstractSpinBox*>(editor))
{ {
connect(editor, SIGNAL(editingFinished()), proxy, SLOT(editorDataCommited())); connect(editor, SIGNAL(editingFinished()), proxy, SLOT(editorDataCommited()));
} //lisp cond pairs would be nice in the C++ }
connect(proxy, SIGNAL(editorDataCommited(QWidget*, const QModelIndex&, CSMWorld::ColumnBase::Display)), connect(proxy, SIGNAL(editorDataCommited(QWidget*, const QModelIndex&, CSMWorld::ColumnBase::Display)),
this, SLOT(editorDataCommited(QWidget*, const QModelIndex&, CSMWorld::ColumnBase::Display))); this, SLOT(editorDataCommited(QWidget*, const QModelIndex&, CSMWorld::ColumnBase::Display)));
@ -328,8 +328,8 @@ CSVWorld::EditWidget::~EditWidget()
} }
} }
CSVWorld::EditWidget::EditWidget(QWidget *parent, int row, CSMWorld::IdTable* table, QUndoStack& undoStack, bool createAndDelete) : CSVWorld::EditWidget::EditWidget(QWidget *parent, int row, CSMWorld::IdTable* table, CSMDoc::Document& document, bool createAndDelete) :
mDispatcher(this, table, undoStack), mDispatcher(this, table, document),
QScrollArea(parent), QScrollArea(parent),
mWidgetMapper(NULL), mWidgetMapper(NULL),
mMainWidget(NULL), mMainWidget(NULL),
@ -338,7 +338,7 @@ mTable(table)
{ {
remake (row); remake (row);
connect(&mDispatcher, SIGNAL(tableMimeDataDropped(QWidget*, const QModelIndex&, const CSMWorld::UniversalId&, const CSMDoc::Document*)), connect(&mDispatcher, SIGNAL(tableMimeDataDropped(QWidget*, const QModelIndex&, const CSMWorld::UniversalId&, const CSMDoc::Document*)),
this, SIGNAL(tableMimeDataDropped(QWidget*, const QModelIndex&, const CSMWorld::UniversalId&, const CSMDoc::Document*))); this, SIGNAL(tableMimeDataDropped(QWidget*, const QModelIndex&, const CSMWorld::UniversalId&, const CSMDoc::Document*)));
} }
@ -349,7 +349,7 @@ void CSVWorld::EditWidget::remake(int row)
delete mNestedModels[i]; delete mNestedModels[i];
} }
mNestedModels.clear(); mNestedModels.clear();
if (mMainWidget) if (mMainWidget)
{ {
delete mMainWidget; delete mMainWidget;
@ -401,8 +401,8 @@ void CSVWorld::EditWidget::remake(int row)
if (mTable->hasChildren(mTable->index(row, i))) if (mTable->hasChildren(mTable->index(row, i)))
{ {
mNestedModels.push_back(new CSMWorld::NestedTableModel (mTable->index(row, i), display, mTable)); mNestedModels.push_back(new CSMWorld::NestedTableModel (mTable->index(row, i), display, mTable));
NestedTable* table = new NestedTable(mUndoStack, *(mNestedModels.rbegin()), this); NestedTable* table = new NestedTable(mDocument, *(mNestedModels.rbegin()), this);
tablesLayout->addWidget(table); tablesLayout->addWidget(table);
} else } else
@ -517,7 +517,7 @@ CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id, CSM
mMainLayout = new QVBoxLayout(mainWidget); mMainLayout = new QVBoxLayout(mainWidget);
mEditWidget = new EditWidget(mainWidget, mTable->getModelIndex(mCurrentId, 0).row(), mTable, mUndoStack, false); mEditWidget = new EditWidget(mainWidget, mTable->getModelIndex(mCurrentId, 0).row(), mTable, document, false);
connect(mEditWidget, SIGNAL(tableMimeDataDropped(QWidget*, const QModelIndex&, const CSMWorld::UniversalId&, const CSMDoc::Document*)), connect(mEditWidget, SIGNAL(tableMimeDataDropped(QWidget*, const QModelIndex&, const CSMWorld::UniversalId&, const CSMDoc::Document*)),
this, SLOT(tableMimeDataDropped(QWidget*, const QModelIndex&, const CSMWorld::UniversalId&, const CSMDoc::Document*))); this, SLOT(tableMimeDataDropped(QWidget*, const QModelIndex&, const CSMWorld::UniversalId&, const CSMDoc::Document*)));
@ -570,7 +570,7 @@ void CSVWorld::DialogueSubView::prevId ()
setUniversalId(CSMWorld::UniversalId (static_cast<CSMWorld::UniversalId::Type> (mTable->data (mTable->index (newRow, 2)).toInt()), setUniversalId(CSMWorld::UniversalId (static_cast<CSMWorld::UniversalId::Type> (mTable->data (mTable->index (newRow, 2)).toInt()),
mTable->data (mTable->index (newRow, 0)).toString().toUtf8().constData())); mTable->data (mTable->index (newRow, 0)).toString().toUtf8().constData()));
changeCurrentId(std::string(mTable->data (mTable->index (newRow, 0)).toString().toUtf8().constData())); changeCurrentId(std::string(mTable->data (mTable->index (newRow, 0)).toString().toUtf8().constData()));
mEditWidget->setDisabled(mLocked); mEditWidget->setDisabled(mLocked);
@ -604,9 +604,9 @@ void CSVWorld::DialogueSubView::nextId ()
mEditWidget->remake(newRow); mEditWidget->remake(newRow);
setUniversalId(CSMWorld::UniversalId (static_cast<CSMWorld::UniversalId::Type> (mTable->data (mTable->index (newRow, 2)).toInt()), setUniversalId(CSMWorld::UniversalId (static_cast<CSMWorld::UniversalId::Type> (mTable->data (mTable->index (newRow, 2)).toInt()),
mTable->data (mTable->index (newRow, 0)).toString().toUtf8().constData())); mTable->data (mTable->index (newRow, 0)).toString().toUtf8().constData()));
changeCurrentId(std::string(mTable->data (mTable->index (newRow, 0)).toString().toUtf8().constData())); changeCurrentId(std::string(mTable->data (mTable->index (newRow, 0)).toString().toUtf8().constData()));
mEditWidget->setDisabled(mLocked); mEditWidget->setDisabled(mLocked);
@ -623,11 +623,11 @@ void CSVWorld::DialogueSubView::setEditLock (bool locked)
if (currentIndex.isValid()) if (currentIndex.isValid())
{ {
CSMWorld::RecordBase::State state = static_cast<CSMWorld::RecordBase::State>(mTable->data (mTable->index (currentIndex.row(), 1)).toInt()); CSMWorld::RecordBase::State state = static_cast<CSMWorld::RecordBase::State>(mTable->data (mTable->index (currentIndex.row(), 1)).toInt());
mEditWidget->setDisabled (state==CSMWorld::RecordBase::State_Deleted || locked); mEditWidget->setDisabled (state==CSMWorld::RecordBase::State_Deleted || locked);
mCommandDispatcher.setEditLock (locked); mCommandDispatcher.setEditLock (locked);
} }
} }
@ -640,14 +640,14 @@ void CSVWorld::DialogueSubView::dataChanged (const QModelIndex & index)
{ {
CSMWorld::RecordBase::State state = static_cast<CSMWorld::RecordBase::State>(mTable->data (mTable->index (currentIndex.row(), 1)).toInt()); CSMWorld::RecordBase::State state = static_cast<CSMWorld::RecordBase::State>(mTable->data (mTable->index (currentIndex.row(), 1)).toInt());
mEditWidget->setDisabled (state==CSMWorld::RecordBase::State_Deleted || mLocked); mEditWidget->setDisabled (state==CSMWorld::RecordBase::State_Deleted || mLocked);
} }
} }
void CSVWorld::DialogueSubView::tableMimeDataDropped (QWidget* editor, void CSVWorld::DialogueSubView::tableMimeDataDropped (QWidget* editor,
const QModelIndex& index, const QModelIndex& index,
const CSMWorld::UniversalId& id, const CSMWorld::UniversalId& id,
const CSMDoc::Document* document) const CSMDoc::Document* document)
{ {
if (document == &mDocument) if (document == &mDocument)
{ {
@ -672,10 +672,10 @@ void CSVWorld::DialogueSubView::showPreview ()
QModelIndex currentIndex(mTable->getModelIndex(mCurrentId, 0)); QModelIndex currentIndex(mTable->getModelIndex(mCurrentId, 0));
if (currentIndex.isValid() && if (currentIndex.isValid() &&
mTable->getFeatures() & CSMWorld::IdTable::Feature_Preview && mTable->getFeatures() & CSMWorld::IdTable::Feature_Preview &&
currentIndex.row() < mTable->rowCount()) currentIndex.row() < mTable->rowCount())
{ {
emit focusId(CSMWorld::UniversalId(CSMWorld::UniversalId::Type_Preview, mCurrentId), ""); emit focusId(CSMWorld::UniversalId(CSMWorld::UniversalId::Type_Preview, mCurrentId), "");
} }
} }
@ -684,7 +684,7 @@ void CSVWorld::DialogueSubView::viewRecord ()
QModelIndex currentIndex(mTable->getModelIndex (mCurrentId, 0)); QModelIndex currentIndex(mTable->getModelIndex (mCurrentId, 0));
if (currentIndex.isValid() && if (currentIndex.isValid() &&
currentIndex.row() < mTable->rowCount()) currentIndex.row() < mTable->rowCount())
{ {
std::pair<CSMWorld::UniversalId, std::string> params = mTable->view (currentIndex.row()); std::pair<CSMWorld::UniversalId, std::string> params = mTable->view (currentIndex.row());

View file

@ -118,12 +118,12 @@ namespace CSVWorld
NotEditableSubDelegate mNotEditableDelegate; NotEditableSubDelegate mNotEditableDelegate;
std::vector<DialogueDelegateDispatcherProxy*> mProxys; std::vector<DialogueDelegateDispatcherProxy*> mProxys;
//once we move to the C++11 we should use unique_ptr //once we move to the C++11 we should use unique_ptr
public: public:
DialogueDelegateDispatcher(QObject* parent, DialogueDelegateDispatcher(QObject* parent,
CSMWorld::IdTable* table, CSMWorld::IdTable* table,
QUndoStack& undoStack); CSMDoc::Document& document);
~DialogueDelegateDispatcher(); ~DialogueDelegateDispatcher();
@ -175,10 +175,10 @@ namespace CSVWorld
public: public:
EditWidget (QWidget *parent, int row, CSMWorld::IdTable* table, EditWidget (QWidget *parent, int row, CSMWorld::IdTable* table,
QUndoStack& undoStack, bool createAndDelete = false); CSMDoc::Document& document, bool createAndDelete = false);
virtual ~EditWidget(); virtual ~EditWidget();
void remake(int row); void remake(int row);
signals: signals:

View file

@ -9,11 +9,11 @@
#include <QMenu> #include <QMenu>
#include <QDebug> #include <QDebug>
CSVWorld::NestedTable::NestedTable(QUndoStack& undoStack, CSVWorld::NestedTable::NestedTable(CSMDoc::Document& document,
CSMWorld::NestedTableModel* model, CSMWorld::NestedTableModel* model,
QWidget* parent) QWidget* parent)
: QTableView(parent), : QTableView(parent),
mUndoStack(undoStack), mUndoStack(document.getUndoStack()),
mModel(model) mModel(model)
{ {
@ -31,9 +31,9 @@ CSVWorld::NestedTable::NestedTable(QUndoStack& undoStack,
model->headerData (i, Qt::Horizontal, CSMWorld::ColumnBase::Role_Display).toInt()); model->headerData (i, Qt::Horizontal, CSMWorld::ColumnBase::Role_Display).toInt());
CommandDelegate *delegate = CommandDelegateFactoryCollection::get().makeDelegate(display, CommandDelegate *delegate = CommandDelegateFactoryCollection::get().makeDelegate(display,
undoStack, document,
this); this);
setItemDelegateForColumn(i, delegate); setItemDelegateForColumn(i, delegate);
} }

View file

@ -29,23 +29,23 @@ namespace CSVWorld
QAction *mRemoveRowAction; QAction *mRemoveRowAction;
QUndoStack& mUndoStack; QUndoStack& mUndoStack;
CSMWorld::NestedTableModel* mModel; CSMWorld::NestedTableModel* mModel;
public: public:
NestedTable(QUndoStack& undoStack, NestedTable(CSMDoc::Document& document,
CSMWorld::NestedTableModel* model, CSMWorld::NestedTableModel* model,
QWidget* parent = NULL); QWidget* parent = NULL);
protected: protected:
void dragEnterEvent(QDragEnterEvent *event); void dragEnterEvent(QDragEnterEvent *event);
void dragMoveEvent(QDragMoveEvent *event); void dragMoveEvent(QDragMoveEvent *event);
private: private:
void contextMenuEvent (QContextMenuEvent *event); void contextMenuEvent (QContextMenuEvent *event);
private slots: private slots:
void removeRowActionTriggered(); void removeRowActionTriggered();
void addNewRowActionTriggered(); void addNewRowActionTriggered();
}; };
} }