|
|
|
@ -64,16 +64,24 @@ void CSVWorld::NotEditableSubDelegate::setEditorData (QWidget* editor, const QMo
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CSMWorld::Columns::ColumnId columnId = static_cast<CSMWorld::Columns::ColumnId> (
|
|
|
|
|
mTable->getColumnId (index.column()));
|
|
|
|
|
|
|
|
|
|
if (QVariant::String == v.type())
|
|
|
|
|
{
|
|
|
|
|
label->setText(v.toString());
|
|
|
|
|
}
|
|
|
|
|
else //else we are facing enums
|
|
|
|
|
else if (CSMWorld::Columns::hasEnums (columnId))
|
|
|
|
|
{
|
|
|
|
|
int data = v.toInt();
|
|
|
|
|
std::vector<std::string> enumNames (CSMWorld::Columns::getEnums (static_cast<CSMWorld::Columns::ColumnId> (mTable->getColumnId (index.column()))));
|
|
|
|
|
std::vector<std::string> enumNames (CSMWorld::Columns::getEnums (columnId));
|
|
|
|
|
|
|
|
|
|
label->setText(QString::fromUtf8(enumNames.at(data).c_str()));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
label->setText (v.toString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSVWorld::NotEditableSubDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const
|
|
|
|
@ -548,12 +556,38 @@ void CSVWorld::EditWidget::remake(int row)
|
|
|
|
|
this->setWidgetResizable(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
==============================DialogueSubView==========================================
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document,
|
|
|
|
|
const CreatorFactoryBase& creatorFactory, bool sorting) :
|
|
|
|
|
QVBoxLayout& CSVWorld::SimpleDialogueSubView::getMainLayout()
|
|
|
|
|
{
|
|
|
|
|
return *mMainLayout;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CSMWorld::IdTable& CSVWorld::SimpleDialogueSubView::getTable()
|
|
|
|
|
{
|
|
|
|
|
return *mTable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CSMWorld::CommandDispatcher& CSVWorld::SimpleDialogueSubView::getCommandDispatcher()
|
|
|
|
|
{
|
|
|
|
|
return mCommandDispatcher;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string CSVWorld::SimpleDialogueSubView::getCurrentId() const
|
|
|
|
|
{
|
|
|
|
|
return mCurrentId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CSVWorld::EditWidget& CSVWorld::SimpleDialogueSubView::getEditWidget()
|
|
|
|
|
{
|
|
|
|
|
return *mEditWidget;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CSVWorld::SimpleDialogueSubView::isLocked() const
|
|
|
|
|
{
|
|
|
|
|
return mLocked;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CSVWorld::SimpleDialogueSubView::SimpleDialogueSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document) :
|
|
|
|
|
SubView (id),
|
|
|
|
|
mEditWidget(0),
|
|
|
|
|
mMainLayout(NULL),
|
|
|
|
@ -570,42 +604,150 @@ CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id, CSM
|
|
|
|
|
|
|
|
|
|
QWidget *mainWidget = new QWidget(this);
|
|
|
|
|
|
|
|
|
|
mMainLayout = new QVBoxLayout(mainWidget);
|
|
|
|
|
setWidget (mainWidget);
|
|
|
|
|
|
|
|
|
|
mEditWidget = new EditWidget(mainWidget,
|
|
|
|
|
mTable->getModelIndex(mCurrentId, 0).row(), mTable, mCommandDispatcher, document, false);
|
|
|
|
|
|
|
|
|
|
mMainLayout->addWidget(mEditWidget);
|
|
|
|
|
mEditWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
|
|
|
|
|
|
|
|
|
dataChanged(mTable->getModelIndex (mCurrentId, 0));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSVWorld::SimpleDialogueSubView::setEditLock (bool locked)
|
|
|
|
|
{
|
|
|
|
|
if (!mEditWidget) // hack to indicate that mCurrentId is no longer valid
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
mLocked = locked;
|
|
|
|
|
QModelIndex currentIndex(mTable->getModelIndex(mCurrentId, 0));
|
|
|
|
|
|
|
|
|
|
if (currentIndex.isValid())
|
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
mCommandDispatcher.setEditLock (locked);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSVWorld::SimpleDialogueSubView::dataChanged (const QModelIndex & index)
|
|
|
|
|
{
|
|
|
|
|
QModelIndex currentIndex(mTable->getModelIndex(mCurrentId, 0));
|
|
|
|
|
|
|
|
|
|
if (currentIndex.isValid() &&
|
|
|
|
|
(index.parent().isValid() ? index.parent().row() : index.row()) == currentIndex.row())
|
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
// Check if the changed data should force refresh (rebuild) the dialogue subview
|
|
|
|
|
int flags = 0;
|
|
|
|
|
if (index.parent().isValid()) // TODO: check that index is topLeft
|
|
|
|
|
{
|
|
|
|
|
flags = static_cast<CSMWorld::IdTree *>(mTable)->nestedHeaderData (index.parent().column(),
|
|
|
|
|
index.column(), Qt::Horizontal, CSMWorld::ColumnBase::Role_Flags).toInt();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
flags = mTable->headerData (index.column(),
|
|
|
|
|
Qt::Horizontal, CSMWorld::ColumnBase::Role_Flags).toInt();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (flags & CSMWorld::ColumnBase::Flag_Dialogue_Refresh)
|
|
|
|
|
{
|
|
|
|
|
int y = mEditWidget->verticalScrollBar()->value();
|
|
|
|
|
mEditWidget->remake (index.parent().isValid() ? index.parent().row() : index.row());
|
|
|
|
|
mEditWidget->verticalScrollBar()->setValue(y);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSVWorld::SimpleDialogueSubView::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
|
|
|
|
|
{
|
|
|
|
|
QModelIndex currentIndex(mTable->getModelIndex(mCurrentId, 0));
|
|
|
|
|
|
|
|
|
|
if (currentIndex.isValid() && currentIndex.row() >= start && currentIndex.row() <= end)
|
|
|
|
|
{
|
|
|
|
|
if(mEditWidget)
|
|
|
|
|
{
|
|
|
|
|
delete mEditWidget;
|
|
|
|
|
mEditWidget = 0;
|
|
|
|
|
}
|
|
|
|
|
emit closeRequest(this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSVWorld::SimpleDialogueSubView::requestFocus (const std::string& id)
|
|
|
|
|
{
|
|
|
|
|
changeCurrentId(id);
|
|
|
|
|
|
|
|
|
|
mEditWidget->remake(mTable->getModelIndex (id, 0).row());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSVWorld::SimpleDialogueSubView::changeCurrentId (const std::string& newId)
|
|
|
|
|
{
|
|
|
|
|
std::vector<std::string> selection;
|
|
|
|
|
mCurrentId = std::string(newId);
|
|
|
|
|
|
|
|
|
|
selection.push_back(mCurrentId);
|
|
|
|
|
mCommandDispatcher.setSelection(selection);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id,
|
|
|
|
|
CSMDoc::Document& document, const CreatorFactoryBase& creatorFactory, bool sorting)
|
|
|
|
|
: SimpleDialogueSubView (id, document)
|
|
|
|
|
{
|
|
|
|
|
// bottom box
|
|
|
|
|
getMainLayout().addWidget (mBottom = new TableBottomBox (creatorFactory, document, id, this));
|
|
|
|
|
|
|
|
|
|
mBottom->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
|
|
|
|
|
|
|
|
|
|
connect(mBottom, SIGNAL(requestFocus(const std::string&)), this, SLOT(requestFocus(const std::string&)));
|
|
|
|
|
|
|
|
|
|
// buttons
|
|
|
|
|
QHBoxLayout *buttonsLayout = new QHBoxLayout;
|
|
|
|
|
QToolButton* prevButton = new QToolButton(mainWidget);
|
|
|
|
|
QToolButton* prevButton = new QToolButton (this);
|
|
|
|
|
prevButton->setIcon(QIcon(":/go-previous.png"));
|
|
|
|
|
prevButton->setToolTip ("Switch to previous record");
|
|
|
|
|
QToolButton* nextButton = new QToolButton(mainWidget);
|
|
|
|
|
QToolButton* nextButton = new QToolButton (this);
|
|
|
|
|
nextButton->setIcon(QIcon(":/go-next.png"));
|
|
|
|
|
nextButton->setToolTip ("Switch to next record");
|
|
|
|
|
buttonsLayout->addWidget(prevButton, 0);
|
|
|
|
|
buttonsLayout->addWidget(nextButton, 1);
|
|
|
|
|
buttonsLayout->addStretch(2);
|
|
|
|
|
|
|
|
|
|
QToolButton* cloneButton = new QToolButton(mainWidget);
|
|
|
|
|
QToolButton* cloneButton = new QToolButton (this);
|
|
|
|
|
cloneButton->setIcon(QIcon(":/edit-clone.png"));
|
|
|
|
|
cloneButton->setToolTip ("Clone record");
|
|
|
|
|
QToolButton* addButton = new QToolButton(mainWidget);
|
|
|
|
|
QToolButton* addButton = new QToolButton (this);
|
|
|
|
|
addButton->setIcon(QIcon(":/add.png"));
|
|
|
|
|
addButton->setToolTip ("Add new record");
|
|
|
|
|
QToolButton* deleteButton = new QToolButton(mainWidget);
|
|
|
|
|
QToolButton* deleteButton = new QToolButton (this);
|
|
|
|
|
deleteButton->setIcon(QIcon(":/edit-delete.png"));
|
|
|
|
|
deleteButton->setToolTip ("Delete record");
|
|
|
|
|
QToolButton* revertButton = new QToolButton(mainWidget);
|
|
|
|
|
QToolButton* revertButton = new QToolButton (this);
|
|
|
|
|
revertButton->setIcon(QIcon(":/edit-undo.png"));
|
|
|
|
|
revertButton->setToolTip ("Revert record");
|
|
|
|
|
|
|
|
|
|
if (mTable->getFeatures() & CSMWorld::IdTable::Feature_Preview)
|
|
|
|
|
if (getTable().getFeatures() & CSMWorld::IdTable::Feature_Preview)
|
|
|
|
|
{
|
|
|
|
|
QToolButton* previewButton = new QToolButton(mainWidget);
|
|
|
|
|
QToolButton* previewButton = new QToolButton (this);
|
|
|
|
|
previewButton->setIcon(QIcon(":/edit-preview.png"));
|
|
|
|
|
previewButton->setToolTip ("Open a preview of this record");
|
|
|
|
|
buttonsLayout->addWidget(previewButton);
|
|
|
|
|
connect(previewButton, SIGNAL(clicked()), this, SLOT(showPreview()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mTable->getFeatures() & CSMWorld::IdTable::Feature_View)
|
|
|
|
|
if (getTable().getFeatures() & CSMWorld::IdTable::Feature_View)
|
|
|
|
|
{
|
|
|
|
|
QToolButton* viewButton = new QToolButton(mainWidget);
|
|
|
|
|
QToolButton* viewButton = new QToolButton (this);
|
|
|
|
|
viewButton->setIcon(QIcon(":/cell.png"));
|
|
|
|
|
viewButton->setToolTip ("Open a scene view of the cell this record is located in");
|
|
|
|
|
buttonsLayout->addWidget(viewButton);
|
|
|
|
@ -620,22 +762,8 @@ CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id, CSM
|
|
|
|
|
connect(nextButton, SIGNAL(clicked()), this, SLOT(nextId()));
|
|
|
|
|
connect(prevButton, SIGNAL(clicked()), this, SLOT(prevId()));
|
|
|
|
|
connect(cloneButton, SIGNAL(clicked()), this, SLOT(cloneRequest()));
|
|
|
|
|
connect(revertButton, SIGNAL(clicked()), &mCommandDispatcher, SLOT(executeRevert()));
|
|
|
|
|
connect(deleteButton, SIGNAL(clicked()), &mCommandDispatcher, SLOT(executeDelete()));
|
|
|
|
|
|
|
|
|
|
mMainLayout = new QVBoxLayout(mainWidget);
|
|
|
|
|
|
|
|
|
|
mEditWidget = new EditWidget(mainWidget,
|
|
|
|
|
mTable->getModelIndex(mCurrentId, 0).row(), mTable, mCommandDispatcher, document, false);
|
|
|
|
|
|
|
|
|
|
mMainLayout->addWidget(mEditWidget);
|
|
|
|
|
mEditWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
|
|
|
|
|
|
|
|
|
mMainLayout->addWidget (mBottom = new TableBottomBox (creatorFactory, document, id, this));
|
|
|
|
|
|
|
|
|
|
mBottom->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
|
|
|
|
|
|
|
|
|
|
connect(mBottom, SIGNAL(requestFocus(const std::string&)), this, SLOT(requestFocus(const std::string&)));
|
|
|
|
|
connect(revertButton, SIGNAL(clicked()), &getCommandDispatcher(), SLOT(executeRevert()));
|
|
|
|
|
connect(deleteButton, SIGNAL(clicked()), &getCommandDispatcher(), SLOT(executeDelete()));
|
|
|
|
|
|
|
|
|
|
connect(addButton, SIGNAL(clicked()), mBottom, SLOT(createRequest()));
|
|
|
|
|
|
|
|
|
@ -646,14 +774,19 @@ CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id, CSM
|
|
|
|
|
deleteButton->setDisabled (true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dataChanged(mTable->getModelIndex (mCurrentId, 0));
|
|
|
|
|
mMainLayout->addLayout (buttonsLayout);
|
|
|
|
|
setWidget (mainWidget);
|
|
|
|
|
getMainLayout().addLayout (buttonsLayout);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSVWorld::DialogueSubView::prevId ()
|
|
|
|
|
void CSVWorld::DialogueSubView::cloneRequest()
|
|
|
|
|
{
|
|
|
|
|
int newRow = mTable->getModelIndex(mCurrentId, 0).row() - 1;
|
|
|
|
|
mBottom->cloneRequest (getCurrentId(),
|
|
|
|
|
static_cast<CSMWorld::UniversalId::Type> (getTable().
|
|
|
|
|
data (getTable().getModelIndex(getCurrentId(), 2)).toInt()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSVWorld::DialogueSubView::prevId()
|
|
|
|
|
{
|
|
|
|
|
int newRow = getTable().getModelIndex (getCurrentId(), 0).row() - 1;
|
|
|
|
|
|
|
|
|
|
if (newRow < 0)
|
|
|
|
|
{
|
|
|
|
@ -661,26 +794,26 @@ void CSVWorld::DialogueSubView::prevId ()
|
|
|
|
|
}
|
|
|
|
|
while (newRow >= 0)
|
|
|
|
|
{
|
|
|
|
|
QModelIndex newIndex(mTable->index(newRow, 0));
|
|
|
|
|
QModelIndex newIndex (getTable().index(newRow, 0));
|
|
|
|
|
|
|
|
|
|
if (!newIndex.isValid())
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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> (getTable().data (getTable().index (newRow, 1)).toInt());
|
|
|
|
|
if (!(state == CSMWorld::RecordBase::State_Deleted || state == CSMWorld::RecordBase::State_Erased))
|
|
|
|
|
{
|
|
|
|
|
mEditWidget->remake(newRow);
|
|
|
|
|
getEditWidget().remake (newRow);
|
|
|
|
|
|
|
|
|
|
setUniversalId(CSMWorld::UniversalId (static_cast<CSMWorld::UniversalId::Type> (mTable->data (mTable->index (newRow, 2)).toInt()),
|
|
|
|
|
mTable->data (mTable->index (newRow, 0)).toString().toUtf8().constData()));
|
|
|
|
|
setUniversalId(CSMWorld::UniversalId (static_cast<CSMWorld::UniversalId::Type> (getTable().data (getTable().index (newRow, 2)).toInt()),
|
|
|
|
|
getTable().data (getTable().index (newRow, 0)).toString().toUtf8().constData()));
|
|
|
|
|
|
|
|
|
|
changeCurrentId(std::string(mTable->data (mTable->index (newRow, 0)).toString().toUtf8().constData()));
|
|
|
|
|
changeCurrentId(std::string (getTable().data (getTable().index (newRow, 0)).toString().toUtf8().constData()));
|
|
|
|
|
|
|
|
|
|
mEditWidget->setDisabled(mLocked);
|
|
|
|
|
getEditWidget().setDisabled (isLocked());
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
--newRow;
|
|
|
|
|
}
|
|
|
|
@ -688,150 +821,63 @@ void CSVWorld::DialogueSubView::prevId ()
|
|
|
|
|
|
|
|
|
|
void CSVWorld::DialogueSubView::nextId ()
|
|
|
|
|
{
|
|
|
|
|
int newRow = mTable->getModelIndex(mCurrentId, 0).row() + 1;
|
|
|
|
|
int newRow = getTable().getModelIndex (getCurrentId(), 0).row() + 1;
|
|
|
|
|
|
|
|
|
|
if (newRow >= mTable->rowCount())
|
|
|
|
|
if (newRow >= getTable().rowCount())
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (newRow < mTable->rowCount())
|
|
|
|
|
while (newRow < getTable().rowCount())
|
|
|
|
|
{
|
|
|
|
|
QModelIndex newIndex(mTable->index(newRow, 0));
|
|
|
|
|
QModelIndex newIndex (getTable().index(newRow, 0));
|
|
|
|
|
|
|
|
|
|
if (!newIndex.isValid())
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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> (getTable().data (getTable().index (newRow, 1)).toInt());
|
|
|
|
|
if (!(state == CSMWorld::RecordBase::State_Deleted))
|
|
|
|
|
{
|
|
|
|
|
mEditWidget->remake(newRow);
|
|
|
|
|
getEditWidget().remake(newRow);
|
|
|
|
|
|
|
|
|
|
setUniversalId(CSMWorld::UniversalId (static_cast<CSMWorld::UniversalId::Type> (mTable->data (mTable->index (newRow, 2)).toInt()),
|
|
|
|
|
mTable->data (mTable->index (newRow, 0)).toString().toUtf8().constData()));
|
|
|
|
|
setUniversalId(CSMWorld::UniversalId (static_cast<CSMWorld::UniversalId::Type> (getTable().data (getTable().index (newRow, 2)).toInt()),
|
|
|
|
|
getTable().data (getTable().index (newRow, 0)).toString().toUtf8().constData()));
|
|
|
|
|
|
|
|
|
|
changeCurrentId(std::string(mTable->data (mTable->index (newRow, 0)).toString().toUtf8().constData()));
|
|
|
|
|
changeCurrentId(std::string (getTable().data (getTable().index (newRow, 0)).toString().toUtf8().constData()));
|
|
|
|
|
|
|
|
|
|
mEditWidget->setDisabled(mLocked);
|
|
|
|
|
getEditWidget().setDisabled (isLocked());
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
++newRow;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSVWorld::DialogueSubView::setEditLock (bool locked)
|
|
|
|
|
{
|
|
|
|
|
if (!mEditWidget) // hack to indicate that mCurrentId is no longer valid
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
mLocked = locked;
|
|
|
|
|
QModelIndex currentIndex(mTable->getModelIndex(mCurrentId, 0));
|
|
|
|
|
|
|
|
|
|
if (currentIndex.isValid())
|
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
mCommandDispatcher.setEditLock (locked);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSVWorld::DialogueSubView::dataChanged (const QModelIndex & index)
|
|
|
|
|
{
|
|
|
|
|
QModelIndex currentIndex(mTable->getModelIndex(mCurrentId, 0));
|
|
|
|
|
|
|
|
|
|
if (currentIndex.isValid() &&
|
|
|
|
|
(index.parent().isValid() ? index.parent().row() : index.row()) == currentIndex.row())
|
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
// Check if the changed data should force refresh (rebuild) the dialogue subview
|
|
|
|
|
int flags = 0;
|
|
|
|
|
if (index.parent().isValid()) // TODO: check that index is topLeft
|
|
|
|
|
{
|
|
|
|
|
flags = static_cast<CSMWorld::IdTree *>(mTable)->nestedHeaderData (index.parent().column(),
|
|
|
|
|
index.column(), Qt::Horizontal, CSMWorld::ColumnBase::Role_Flags).toInt();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
flags = mTable->headerData (index.column(),
|
|
|
|
|
Qt::Horizontal, CSMWorld::ColumnBase::Role_Flags).toInt();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (flags & CSMWorld::ColumnBase::Flag_Dialogue_Refresh)
|
|
|
|
|
{
|
|
|
|
|
int y = mEditWidget->verticalScrollBar()->value();
|
|
|
|
|
mEditWidget->remake (index.parent().isValid() ? index.parent().row() : index.row());
|
|
|
|
|
mEditWidget->verticalScrollBar()->setValue(y);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSVWorld::DialogueSubView::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
|
|
|
|
|
{
|
|
|
|
|
QModelIndex currentIndex(mTable->getModelIndex(mCurrentId, 0));
|
|
|
|
|
|
|
|
|
|
if (currentIndex.isValid() && currentIndex.row() >= start && currentIndex.row() <= end)
|
|
|
|
|
{
|
|
|
|
|
if(mEditWidget)
|
|
|
|
|
{
|
|
|
|
|
delete mEditWidget;
|
|
|
|
|
mEditWidget = 0;
|
|
|
|
|
}
|
|
|
|
|
emit closeRequest(this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSVWorld::DialogueSubView::requestFocus (const std::string& id)
|
|
|
|
|
{
|
|
|
|
|
changeCurrentId(id);
|
|
|
|
|
|
|
|
|
|
mEditWidget->remake(mTable->getModelIndex (id, 0).row());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSVWorld::DialogueSubView::cloneRequest ()
|
|
|
|
|
{
|
|
|
|
|
mBottom->cloneRequest(mCurrentId, static_cast<CSMWorld::UniversalId::Type>(mTable->data(mTable->getModelIndex(mCurrentId, 2)).toInt()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSVWorld::DialogueSubView::showPreview ()
|
|
|
|
|
{
|
|
|
|
|
QModelIndex currentIndex(mTable->getModelIndex(mCurrentId, 0));
|
|
|
|
|
QModelIndex currentIndex (getTable().getModelIndex (getCurrentId(), 0));
|
|
|
|
|
|
|
|
|
|
if (currentIndex.isValid() &&
|
|
|
|
|
mTable->getFeatures() & CSMWorld::IdTable::Feature_Preview &&
|
|
|
|
|
currentIndex.row() < mTable->rowCount())
|
|
|
|
|
getTable().getFeatures() & CSMWorld::IdTable::Feature_Preview &&
|
|
|
|
|
currentIndex.row() < getTable().rowCount())
|
|
|
|
|
{
|
|
|
|
|
emit focusId(CSMWorld::UniversalId(CSMWorld::UniversalId::Type_Preview, mCurrentId), "");
|
|
|
|
|
emit focusId(CSMWorld::UniversalId(CSMWorld::UniversalId::Type_Preview, getCurrentId()), "");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSVWorld::DialogueSubView::viewRecord ()
|
|
|
|
|
{
|
|
|
|
|
QModelIndex currentIndex(mTable->getModelIndex (mCurrentId, 0));
|
|
|
|
|
QModelIndex currentIndex (getTable().getModelIndex (getCurrentId(), 0));
|
|
|
|
|
|
|
|
|
|
if (currentIndex.isValid() &&
|
|
|
|
|
currentIndex.row() < mTable->rowCount())
|
|
|
|
|
currentIndex.row() < getTable().rowCount())
|
|
|
|
|
{
|
|
|
|
|
std::pair<CSMWorld::UniversalId, std::string> params = mTable->view (currentIndex.row());
|
|
|
|
|
std::pair<CSMWorld::UniversalId, std::string> params = getTable().view (currentIndex.row());
|
|
|
|
|
|
|
|
|
|
if (params.first.getType()!=CSMWorld::UniversalId::Type_None)
|
|
|
|
|
emit focusId (params.first, params.second);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSVWorld::DialogueSubView::changeCurrentId (const std::string& newId)
|
|
|
|
|
{
|
|
|
|
|
std::vector<std::string> selection;
|
|
|
|
|
mCurrentId = std::string(newId);
|
|
|
|
|
|
|
|
|
|
selection.push_back(mCurrentId);
|
|
|
|
|
mCommandDispatcher.setSelection(selection);
|
|
|
|
|
}
|
|
|
|
|