mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 10:23:51 +00:00
fixed segfault
This commit is contained in:
parent
dd755a00e4
commit
e1a4b64efb
6 changed files with 98 additions and 43 deletions
|
@ -444,3 +444,8 @@ CSMWorld::ColumnBase::Display CSMWorld::TableMimeData::convertEnums (CSMWorld::U
|
||||||
return CSMWorld::ColumnBase::Display_None;
|
return CSMWorld::ColumnBase::Display_None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const CSMDoc::Document* CSMWorld::TableMimeData::getDocumentPtr() const
|
||||||
|
{
|
||||||
|
return &mDocument;
|
||||||
|
}
|
|
@ -48,6 +48,8 @@ namespace CSMWorld
|
||||||
|
|
||||||
UniversalId returnMatching(UniversalId::Type type) const;
|
UniversalId returnMatching(UniversalId::Type type) const;
|
||||||
|
|
||||||
|
const CSMDoc::Document* getDocumentPtr() const;
|
||||||
|
|
||||||
UniversalId returnMatching(CSMWorld::ColumnBase::Display type) const;
|
UniversalId returnMatching(CSMWorld::ColumnBase::Display type) const;
|
||||||
|
|
||||||
static CSMWorld::UniversalId::Type convertEnums(CSMWorld::ColumnBase::Display type);
|
static CSMWorld::UniversalId::Type convertEnums(CSMWorld::ColumnBase::Display type);
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "../../model/world/columns.hpp"
|
#include "../../model/world/columns.hpp"
|
||||||
#include "../../model/world/record.hpp"
|
#include "../../model/world/record.hpp"
|
||||||
#include "../../model/world/tablemimedata.hpp"
|
#include "../../model/world/tablemimedata.hpp"
|
||||||
|
#include "../../model/doc/document.hpp"
|
||||||
|
|
||||||
#include "recordstatusdelegate.hpp"
|
#include "recordstatusdelegate.hpp"
|
||||||
#include "util.hpp"
|
#include "util.hpp"
|
||||||
|
@ -114,7 +115,7 @@ QWidget* CSVWorld::DialogueDelegateDispatcherProxy::getEditor() const
|
||||||
return mEditor;
|
return mEditor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::DialogueDelegateDispatcherProxy::tableMimeDataDropped(const std::vector<CSMWorld::UniversalId>& data)
|
void CSVWorld::DialogueDelegateDispatcherProxy::tableMimeDataDropped(const std::vector<CSMWorld::UniversalId>& data, const CSMDoc::Document* document)
|
||||||
{
|
{
|
||||||
for (unsigned i = 0; i < data.size(); ++i)
|
for (unsigned i = 0; i < data.size(); ++i)
|
||||||
{
|
{
|
||||||
|
@ -123,8 +124,7 @@ void CSVWorld::DialogueDelegateDispatcherProxy::tableMimeDataDropped(const std::
|
||||||
QLineEdit* lineEdit = qobject_cast<QLineEdit*>(mEditor);
|
QLineEdit* lineEdit = qobject_cast<QLineEdit*>(mEditor);
|
||||||
if (lineEdit && mIndexWrapper.get())
|
if (lineEdit && mIndexWrapper.get())
|
||||||
{
|
{
|
||||||
lineEdit->setText(data[i].getId().c_str());
|
emit tableMimeDataDropped(mEditor, mIndexWrapper->mIndex, data[i], document);
|
||||||
emit editorDataCommited(mEditor, mIndexWrapper->mIndex, mDisplay);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -237,7 +237,10 @@ QWidget* CSVWorld::DialogueDelegateDispatcher::makeEditor(CSMWorld::ColumnBase::
|
||||||
if (qobject_cast<DropLineEdit*>(editor))
|
if (qobject_cast<DropLineEdit*>(editor))
|
||||||
{
|
{
|
||||||
connect(editor, SIGNAL(editingFinished()), proxy, SLOT(editorDataCommited()));
|
connect(editor, SIGNAL(editingFinished()), proxy, SLOT(editorDataCommited()));
|
||||||
connect(editor, SIGNAL(tableMimeDataDropped(const std::vector<CSMWorld::UniversalId>&)), proxy, SLOT(tableMimeDataDropped(const std::vector<CSMWorld::UniversalId>&)));
|
connect(editor, SIGNAL(tableMimeDataDropped(const std::vector<CSMWorld::UniversalId>&, const CSMDoc::Document*)),
|
||||||
|
proxy, SLOT(tableMimeDataDropped(const std::vector<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*)));
|
||||||
skip = true;
|
skip = true;
|
||||||
}
|
}
|
||||||
if(!skip && qobject_cast<QCheckBox*>(editor))
|
if(!skip && qobject_cast<QCheckBox*>(editor))
|
||||||
|
@ -288,6 +291,7 @@ mUndoStack(undoStack),
|
||||||
mTable(table)
|
mTable(table)
|
||||||
{
|
{
|
||||||
remake (row);
|
remake (row);
|
||||||
|
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*)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::EditWidget::remake(int row)
|
void CSVWorld::EditWidget::remake(int row)
|
||||||
|
@ -376,7 +380,8 @@ CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id, CSM
|
||||||
mUndoStack(document.getUndoStack()),
|
mUndoStack(document.getUndoStack()),
|
||||||
mTable(dynamic_cast<CSMWorld::IdTable*>(document.getData().getTableModel(id))),
|
mTable(dynamic_cast<CSMWorld::IdTable*>(document.getData().getTableModel(id))),
|
||||||
mRow (-1),
|
mRow (-1),
|
||||||
mLocked(false)
|
mLocked(false),
|
||||||
|
mDocument(document)
|
||||||
|
|
||||||
{
|
{
|
||||||
connect(mTable, SIGNAL(dataChanged ( const QModelIndex &, const QModelIndex &)), this, SLOT(dataChanged()));
|
connect(mTable, SIGNAL(dataChanged ( const QModelIndex &, const QModelIndex &)), this, SLOT(dataChanged()));
|
||||||
|
@ -394,6 +399,10 @@ CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id, CSM
|
||||||
mMainLayout = new QVBoxLayout(mainWidget);
|
mMainLayout = new QVBoxLayout(mainWidget);
|
||||||
|
|
||||||
mEditWidget = new EditWidget(mainWidget, mRow, mTable, mUndoStack, false);
|
mEditWidget = new EditWidget(mainWidget, mRow, mTable, mUndoStack, false);
|
||||||
|
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*)));
|
||||||
|
|
||||||
|
|
||||||
mMainLayout->addLayout(buttonsLayout);
|
mMainLayout->addLayout(buttonsLayout);
|
||||||
mMainLayout->addWidget(mEditWidget);
|
mMainLayout->addWidget(mEditWidget);
|
||||||
mEditWidget->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
|
mEditWidget->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
|
||||||
|
@ -410,6 +419,8 @@ void CSVWorld::DialogueSubView::prevId()
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
while (newRow >= 0)
|
||||||
|
{
|
||||||
QModelIndex newIndex(mTable->index(newRow, 0));
|
QModelIndex newIndex(mTable->index(newRow, 0));
|
||||||
|
|
||||||
if (!newIndex.isValid())
|
if (!newIndex.isValid())
|
||||||
|
@ -418,29 +429,30 @@ void CSVWorld::DialogueSubView::prevId()
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMWorld::RecordBase::State state = static_cast<CSMWorld::RecordBase::State>(mTable->data (mTable->index (newRow, 1)).toInt());
|
CSMWorld::RecordBase::State state = static_cast<CSMWorld::RecordBase::State>(mTable->data (mTable->index (newRow, 1)).toInt());
|
||||||
if (state == CSMWorld::RecordBase::State_Deleted || state == CSMWorld::RecordBase::State_Erased)
|
if (!(state == CSMWorld::RecordBase::State_Deleted || state == CSMWorld::RecordBase::State_Erased))
|
||||||
{
|
{
|
||||||
prevId();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
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().toStdString()));
|
mTable->data (mTable->index (newRow, 0)).toString().toStdString()));
|
||||||
mRow = newRow;
|
mRow = newRow;
|
||||||
mEditWidget->setDisabled(mLocked);
|
mEditWidget->setDisabled(mLocked);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
--newRow;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::DialogueSubView::nextId()
|
void CSVWorld::DialogueSubView::nextId()
|
||||||
{
|
{
|
||||||
int newRow = mRow + 1;
|
int newRow = mRow + 1;
|
||||||
|
|
||||||
if (newRow > mTable->rowCount())
|
if (newRow >= mTable->rowCount())
|
||||||
{
|
{
|
||||||
std::cout<<"test"<<std::endl;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (newRow < mTable->rowCount())
|
||||||
|
{
|
||||||
QModelIndex newIndex(mTable->index(newRow, 0));
|
QModelIndex newIndex(mTable->index(newRow, 0));
|
||||||
|
|
||||||
if (!newIndex.isValid())
|
if (!newIndex.isValid())
|
||||||
|
@ -449,17 +461,17 @@ void CSVWorld::DialogueSubView::nextId()
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMWorld::RecordBase::State state = static_cast<CSMWorld::RecordBase::State>(mTable->data (mTable->index (newRow, 1)).toInt());
|
CSMWorld::RecordBase::State state = static_cast<CSMWorld::RecordBase::State>(mTable->data (mTable->index (newRow, 1)).toInt());
|
||||||
if (state == CSMWorld::RecordBase::State_Deleted || state == CSMWorld::RecordBase::State_Erased)
|
if (!(state == CSMWorld::RecordBase::State_Deleted || state == CSMWorld::RecordBase::State_Erased))
|
||||||
{
|
{
|
||||||
nextId();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
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().toStdString()));
|
mTable->data (mTable->index (newRow, 0)).toString().toStdString()));
|
||||||
mRow = newRow;
|
mRow = newRow;
|
||||||
mEditWidget->setDisabled(mLocked);
|
mEditWidget->setDisabled(mLocked);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
++newRow;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::DialogueSubView::setEditLock (bool locked)
|
void CSVWorld::DialogueSubView::setEditLock (bool locked)
|
||||||
|
@ -479,3 +491,14 @@ void CSVWorld::DialogueSubView::dataChanged()
|
||||||
mEditWidget->setDisabled(mLocked);
|
mEditWidget->setDisabled(mLocked);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVWorld::DialogueSubView::tableMimeDataDropped(QWidget* editor,
|
||||||
|
const QModelIndex& index,
|
||||||
|
const CSMWorld::UniversalId& id,
|
||||||
|
const CSMDoc::Document* document)
|
||||||
|
{
|
||||||
|
if (document == &mDocument)
|
||||||
|
{
|
||||||
|
qobject_cast<DropLineEdit*>(editor)->setText(id.getId().c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -77,10 +77,15 @@ namespace CSVWorld
|
||||||
public slots:
|
public slots:
|
||||||
void editorDataCommited();
|
void editorDataCommited();
|
||||||
void setIndex(const QModelIndex& index);
|
void setIndex(const QModelIndex& index);
|
||||||
void tableMimeDataDropped(const std::vector<CSMWorld::UniversalId>& data);
|
void tableMimeDataDropped(const std::vector<CSMWorld::UniversalId>& data, const CSMDoc::Document* document);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void editorDataCommited(QWidget* editor, const QModelIndex& index, CSMWorld::ColumnBase::Display display);
|
void editorDataCommited(QWidget* editor, const QModelIndex& index, CSMWorld::ColumnBase::Display display);
|
||||||
|
|
||||||
|
void tableMimeDataDropped(QWidget* editor, const QModelIndex& index,
|
||||||
|
const CSMWorld::UniversalId& id,
|
||||||
|
const CSMDoc::Document* document);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class DialogueDelegateDispatcher : public QAbstractItemDelegate
|
class DialogueDelegateDispatcher : public QAbstractItemDelegate
|
||||||
|
@ -121,10 +126,17 @@ namespace CSVWorld
|
||||||
private slots:
|
private slots:
|
||||||
void editorDataCommited(QWidget* editor, const QModelIndex& index, CSMWorld::ColumnBase::Display display);
|
void editorDataCommited(QWidget* editor, const QModelIndex& index, CSMWorld::ColumnBase::Display display);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void tableMimeDataDropped(QWidget* editor, const QModelIndex& index,
|
||||||
|
const CSMWorld::UniversalId& id,
|
||||||
|
const CSMDoc::Document* document);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class EditWidget : public QScrollArea
|
class EditWidget : public QScrollArea
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
QDataWidgetMapper *mWidgetMapper;
|
QDataWidgetMapper *mWidgetMapper;
|
||||||
DialogueDelegateDispatcher mDispatcher;
|
DialogueDelegateDispatcher mDispatcher;
|
||||||
QWidget* mMainWidget;
|
QWidget* mMainWidget;
|
||||||
|
@ -136,6 +148,11 @@ namespace CSVWorld
|
||||||
EditWidget (QWidget *parent, int row, CSMWorld::IdTable* table, QUndoStack& undoStack, bool createAndDelete = false);
|
EditWidget (QWidget *parent, int row, CSMWorld::IdTable* table, QUndoStack& undoStack, bool createAndDelete = false);
|
||||||
|
|
||||||
void remake(int row);
|
void remake(int row);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void tableMimeDataDropped(QWidget* editor, const QModelIndex& index,
|
||||||
|
const CSMWorld::UniversalId& id,
|
||||||
|
const CSMDoc::Document* document);
|
||||||
};
|
};
|
||||||
|
|
||||||
class DialogueSubView : public CSVDoc::SubView
|
class DialogueSubView : public CSVDoc::SubView
|
||||||
|
@ -148,6 +165,7 @@ namespace CSVWorld
|
||||||
QUndoStack& mUndoStack;
|
QUndoStack& mUndoStack;
|
||||||
int mRow;
|
int mRow;
|
||||||
bool mLocked;
|
bool mLocked;
|
||||||
|
const CSMDoc::Document& mDocument;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -163,6 +181,10 @@ namespace CSVWorld
|
||||||
|
|
||||||
void dataChanged();
|
void dataChanged();
|
||||||
///\brief we need to care for deleting currently edited record
|
///\brief we need to care for deleting currently edited record
|
||||||
|
|
||||||
|
void tableMimeDataDropped(QWidget* editor, const QModelIndex& index,
|
||||||
|
const CSMWorld::UniversalId& id,
|
||||||
|
const CSMDoc::Document* document);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -254,6 +254,8 @@ void CSVWorld::DropLineEdit::dragMoveEvent(QDragMoveEvent *event)
|
||||||
|
|
||||||
void CSVWorld::DropLineEdit::dropEvent(QDropEvent *event)
|
void CSVWorld::DropLineEdit::dropEvent(QDropEvent *event)
|
||||||
{
|
{
|
||||||
emit tableMimeDataDropped(dynamic_cast<const CSMWorld::TableMimeData*> (event->mimeData())->getData());
|
const CSMWorld::TableMimeData* data(dynamic_cast<const CSMWorld::TableMimeData*>(event->mimeData()));
|
||||||
|
emit tableMimeDataDropped(data->getData(), data->getDocumentPtr());
|
||||||
|
emit editingFinished ();
|
||||||
//WIP
|
//WIP
|
||||||
}
|
}
|
|
@ -8,6 +8,7 @@
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
|
|
||||||
#include "../../model/world/columnbase.hpp"
|
#include "../../model/world/columnbase.hpp"
|
||||||
|
#include "../../model/doc/document.hpp"
|
||||||
|
|
||||||
class QUndoStack;
|
class QUndoStack;
|
||||||
|
|
||||||
|
@ -101,7 +102,7 @@ namespace CSVWorld
|
||||||
void dropEvent(QDropEvent *event);
|
void dropEvent(QDropEvent *event);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void tableMimeDataDropped(const std::vector<CSMWorld::UniversalId>& data);
|
void tableMimeDataDropped(const std::vector<CSMWorld::UniversalId>& data, const CSMDoc::Document* document);
|
||||||
};
|
};
|
||||||
|
|
||||||
///< \brief Use commands instead of manipulating the model directly
|
///< \brief Use commands instead of manipulating the model directly
|
||||||
|
|
Loading…
Reference in a new issue