forked from mirror/openmw-tes3mp
clone and create buttons work
This commit is contained in:
parent
95afca0558
commit
db774b02d7
3 changed files with 99 additions and 23 deletions
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
#include "recordstatusdelegate.hpp"
|
#include "recordstatusdelegate.hpp"
|
||||||
#include "util.hpp"
|
#include "util.hpp"
|
||||||
|
#include "tablebottombox.hpp"
|
||||||
/*
|
/*
|
||||||
==============================NotEditableSubDelegate==========================================
|
==============================NotEditableSubDelegate==========================================
|
||||||
*/
|
*/
|
||||||
|
@ -379,7 +380,7 @@ void CSVWorld::EditWidget::remake(int row)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document,
|
CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document,
|
||||||
bool createAndDelete) :
|
const CreatorFactoryBase& creatorFactory, bool sorting) :
|
||||||
|
|
||||||
SubView (id),
|
SubView (id),
|
||||||
mEditWidget(0),
|
mEditWidget(0),
|
||||||
|
@ -416,7 +417,7 @@ CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id, CSM
|
||||||
|
|
||||||
connect(nextButton, SIGNAL(clicked()), this, SLOT(nextId()));
|
connect(nextButton, SIGNAL(clicked()), this, SLOT(nextId()));
|
||||||
connect(prevButton, SIGNAL(clicked()), this, SLOT(prevId()));
|
connect(prevButton, SIGNAL(clicked()), this, SLOT(prevId()));
|
||||||
|
connect(cloneButton, SIGNAL(clicked()), this, SLOT(cloneRequest()));
|
||||||
connect(revertButton, SIGNAL(clicked()), this, SLOT(revertRecord()));
|
connect(revertButton, SIGNAL(clicked()), this, SLOT(revertRecord()));
|
||||||
connect(deleteButton, SIGNAL(clicked()), this, SLOT(deleteRecord()));
|
connect(deleteButton, SIGNAL(clicked()), this, SLOT(deleteRecord()));
|
||||||
|
|
||||||
|
@ -428,7 +429,21 @@ CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id, CSM
|
||||||
|
|
||||||
mMainLayout->addLayout(buttonsLayout);
|
mMainLayout->addLayout(buttonsLayout);
|
||||||
mMainLayout->addWidget(mEditWidget);
|
mMainLayout->addWidget(mEditWidget);
|
||||||
mEditWidget->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
|
mEditWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||||
|
|
||||||
|
mMainLayout->addWidget (mBottom =
|
||||||
|
new TableBottomBox (creatorFactory, document.getData(), document.getUndoStack(), id, this));
|
||||||
|
|
||||||
|
mBottom->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
|
||||||
|
connect(mBottom, SIGNAL(requestFocus(const std::string&)), this, SLOT(requestFocus(const std::string&)));
|
||||||
|
connect(addButton, SIGNAL(clicked()), mBottom, SLOT(createRequest()));
|
||||||
|
|
||||||
|
if(!mBottom->canCreateAndDelete())
|
||||||
|
{
|
||||||
|
cloneButton->setDisabled(true);
|
||||||
|
addButton->setDisabled(true);
|
||||||
|
deleteButton->setDisabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
dataChanged(mTable->index(mRow, 0));
|
dataChanged(mTable->index(mRow, 0));
|
||||||
setWidget(mainWidget);
|
setWidget(mainWidget);
|
||||||
|
@ -567,7 +582,10 @@ void CSVWorld::DialogueSubView::revertRecord()
|
||||||
void CSVWorld::DialogueSubView::deleteRecord()
|
void CSVWorld::DialogueSubView::deleteRecord()
|
||||||
{
|
{
|
||||||
int rows = mTable->rowCount();
|
int rows = mTable->rowCount();
|
||||||
if (!mLocked && mTable->columnCount() > 0 && mRow < mTable->rowCount() )
|
if (!mLocked &&
|
||||||
|
mTable->columnCount() > 0 &&
|
||||||
|
mRow < mTable->rowCount() &&
|
||||||
|
mBottom->canCreateAndDelete())
|
||||||
{
|
{
|
||||||
mUndoStack.push(new CSMWorld::DeleteCommand(*mTable, mTable->data(mTable->index (mRow, 0)).toString().toStdString()));
|
mUndoStack.push(new CSMWorld::DeleteCommand(*mTable, mTable->data(mTable->index (mRow, 0)).toString().toStdString()));
|
||||||
if (rows != mTable->rowCount())
|
if (rows != mTable->rowCount())
|
||||||
|
@ -585,4 +603,16 @@ void CSVWorld::DialogueSubView::deleteRecord()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWorld::DialogueSubView::requestFocus (const std::string& id)
|
||||||
|
{
|
||||||
|
mRow = mTable->getModelIndex (id, 0).row();
|
||||||
|
mEditWidget->remake(mRow);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWorld::DialogueSubView::cloneRequest ()
|
||||||
|
{
|
||||||
|
mBottom->cloneRequest(mTable->data(mTable->index (mRow, 0)).toString().toStdString(),
|
||||||
|
static_cast<CSMWorld::UniversalId::Type>(mTable->data(mTable->index(mRow, 2)).toInt()));
|
||||||
}
|
}
|
|
@ -29,6 +29,8 @@ namespace CSMDoc
|
||||||
namespace CSVWorld
|
namespace CSVWorld
|
||||||
{
|
{
|
||||||
class CommandDelegate;
|
class CommandDelegate;
|
||||||
|
class CreatorFactoryBase;
|
||||||
|
class TableBottomBox;
|
||||||
|
|
||||||
class NotEditableSubDelegate : public QAbstractItemDelegate
|
class NotEditableSubDelegate : public QAbstractItemDelegate
|
||||||
{
|
{
|
||||||
|
@ -166,10 +168,14 @@ namespace CSVWorld
|
||||||
int mRow;
|
int mRow;
|
||||||
bool mLocked;
|
bool mLocked;
|
||||||
const CSMDoc::Document& mDocument;
|
const CSMDoc::Document& mDocument;
|
||||||
|
TableBottomBox* mBottom;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DialogueSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document, bool createAndDelete = false);
|
DialogueSubView (const CSMWorld::UniversalId& id,
|
||||||
|
CSMDoc::Document& document,
|
||||||
|
const CreatorFactoryBase& creatorFactory,
|
||||||
|
bool sorting = false);
|
||||||
|
|
||||||
virtual void setEditLock (bool locked);
|
virtual void setEditLock (bool locked);
|
||||||
|
|
||||||
|
@ -182,12 +188,16 @@ namespace CSVWorld
|
||||||
void revertRecord();
|
void revertRecord();
|
||||||
void deleteRecord();
|
void deleteRecord();
|
||||||
|
|
||||||
|
void cloneRequest();
|
||||||
|
|
||||||
void dataChanged(const QModelIndex & index);
|
void dataChanged(const QModelIndex & index);
|
||||||
///\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,
|
void tableMimeDataDropped(QWidget* editor, const QModelIndex& index,
|
||||||
const CSMWorld::UniversalId& id,
|
const CSMWorld::UniversalId& id,
|
||||||
const CSMDoc::Document* document);
|
const CSMDoc::Document* document);
|
||||||
|
|
||||||
|
void requestFocus (const std::string& id);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,22 +79,58 @@ void CSVWorld::addSubViewFactories (CSVDoc::SubViewFactoryManager& manager)
|
||||||
|
|
||||||
manager.add (CSMWorld::UniversalId::Type_Scene, new CSVDoc::SubViewFactory<SceneSubView>);
|
manager.add (CSMWorld::UniversalId::Type_Scene, new CSVDoc::SubViewFactory<SceneSubView>);
|
||||||
|
|
||||||
manager.add(CSMWorld::UniversalId::Type_Region, new CSVDoc::SubViewFactory<DialogueSubView>);
|
//edit subviews
|
||||||
manager.add(CSMWorld::UniversalId::Type_Spell, new CSVDoc::SubViewFactory<DialogueSubView>);
|
manager.add (CSMWorld::UniversalId::Type_Region,
|
||||||
manager.add(CSMWorld::UniversalId::Type_Referenceable, new CSVDoc::SubViewFactory<DialogueSubView>);
|
new CSVDoc::SubViewFactoryWithCreator<DialogueSubView, CreatorFactory<GenericCreator> > (false));
|
||||||
manager.add(CSMWorld::UniversalId::Type_Birthsign, new CSVDoc::SubViewFactory<DialogueSubView>);
|
|
||||||
manager.add(CSMWorld::UniversalId::Type_Global, new CSVDoc::SubViewFactory<DialogueSubView>);
|
manager.add (CSMWorld::UniversalId::Type_Spell,
|
||||||
manager.add(CSMWorld::UniversalId::Type_Gmst, new CSVDoc::SubViewFactory<DialogueSubView>);
|
new CSVDoc::SubViewFactoryWithCreator<DialogueSubView, CreatorFactory<GenericCreator> > (false));
|
||||||
manager.add(CSMWorld::UniversalId::Type_Race, new CSVDoc::SubViewFactory<DialogueSubView>);
|
|
||||||
manager.add(CSMWorld::UniversalId::Type_Class, new CSVDoc::SubViewFactory<DialogueSubView>);
|
manager.add (CSMWorld::UniversalId::Type_Referenceable,
|
||||||
manager.add(CSMWorld::UniversalId::Type_Reference, new CSVDoc::SubViewFactory<DialogueSubView>);
|
new CSVDoc::SubViewFactoryWithCreator<DialogueSubView, CreatorFactory<GenericCreator> > (false));
|
||||||
manager.add(CSMWorld::UniversalId::Type_Cell, new CSVDoc::SubViewFactory<DialogueSubView>);
|
|
||||||
manager.add(CSMWorld::UniversalId::Type_Filter, new CSVDoc::SubViewFactory<DialogueSubView>);
|
manager.add (CSMWorld::UniversalId::Type_Birthsign,
|
||||||
manager.add(CSMWorld::UniversalId::Type_Sound, new CSVDoc::SubViewFactory<DialogueSubView>);
|
new CSVDoc::SubViewFactoryWithCreator<DialogueSubView, CreatorFactory<GenericCreator> > (false));
|
||||||
manager.add(CSMWorld::UniversalId::Type_Faction, new CSVDoc::SubViewFactory<DialogueSubView>);
|
|
||||||
manager.add(CSMWorld::UniversalId::Type_Skill, new CSVDoc::SubViewFactory<DialogueSubView>);
|
manager.add (CSMWorld::UniversalId::Type_Global,
|
||||||
manager.add(CSMWorld::UniversalId::Type_JournalInfo, new CSVDoc::SubViewFactory<DialogueSubView>);
|
new CSVDoc::SubViewFactoryWithCreator<DialogueSubView, CreatorFactory<GenericCreator> > (false));
|
||||||
manager.add(CSMWorld::UniversalId::Type_TopicInfo, new CSVDoc::SubViewFactory<DialogueSubView>);
|
|
||||||
manager.add(CSMWorld::UniversalId::Type_Topic, new CSVDoc::SubViewFactory<DialogueSubView>);
|
manager.add (CSMWorld::UniversalId::Type_Gmst,
|
||||||
manager.add(CSMWorld::UniversalId::Type_Journal, new CSVDoc::SubViewFactory<DialogueSubView>);
|
new CSVDoc::SubViewFactoryWithCreator<DialogueSubView, CreatorFactory<GenericCreator> > (false));
|
||||||
|
|
||||||
|
manager.add (CSMWorld::UniversalId::Type_Race,
|
||||||
|
new CSVDoc::SubViewFactoryWithCreator<DialogueSubView, CreatorFactory<GenericCreator> > (false));
|
||||||
|
|
||||||
|
manager.add (CSMWorld::UniversalId::Type_Class,
|
||||||
|
new CSVDoc::SubViewFactoryWithCreator<DialogueSubView, CreatorFactory<GenericCreator> > (false));
|
||||||
|
|
||||||
|
manager.add (CSMWorld::UniversalId::Type_Reference,
|
||||||
|
new CSVDoc::SubViewFactoryWithCreator<DialogueSubView, CreatorFactory<GenericCreator> > (false));
|
||||||
|
|
||||||
|
manager.add (CSMWorld::UniversalId::Type_Cell,
|
||||||
|
new CSVDoc::SubViewFactoryWithCreator<DialogueSubView, CreatorFactory<GenericCreator> > (false));
|
||||||
|
|
||||||
|
manager.add (CSMWorld::UniversalId::Type_Filter,
|
||||||
|
new CSVDoc::SubViewFactoryWithCreator<DialogueSubView, CreatorFactory<GenericCreator> > (false));
|
||||||
|
|
||||||
|
manager.add (CSMWorld::UniversalId::Type_Sound,
|
||||||
|
new CSVDoc::SubViewFactoryWithCreator<DialogueSubView, CreatorFactory<GenericCreator> > (false));
|
||||||
|
|
||||||
|
manager.add (CSMWorld::UniversalId::Type_Faction,
|
||||||
|
new CSVDoc::SubViewFactoryWithCreator<DialogueSubView, CreatorFactory<GenericCreator> > (false));
|
||||||
|
|
||||||
|
manager.add (CSMWorld::UniversalId::Type_Skill,
|
||||||
|
new CSVDoc::SubViewFactoryWithCreator<DialogueSubView, CreatorFactory<GenericCreator> > (false));
|
||||||
|
|
||||||
|
manager.add (CSMWorld::UniversalId::Type_JournalInfo,
|
||||||
|
new CSVDoc::SubViewFactoryWithCreator<DialogueSubView, CreatorFactory<GenericCreator> > (false));
|
||||||
|
|
||||||
|
manager.add (CSMWorld::UniversalId::Type_TopicInfo,
|
||||||
|
new CSVDoc::SubViewFactoryWithCreator<DialogueSubView, CreatorFactory<GenericCreator> > (false));
|
||||||
|
|
||||||
|
manager.add (CSMWorld::UniversalId::Type_Topic,
|
||||||
|
new CSVDoc::SubViewFactoryWithCreator<DialogueSubView, CreatorFactory<GenericCreator> > (false));
|
||||||
|
|
||||||
|
manager.add (CSMWorld::UniversalId::Type_Journal,
|
||||||
|
new CSVDoc::SubViewFactoryWithCreator<DialogueSubView, CreatorFactory<GenericCreator> > (false));
|
||||||
}
|
}
|
Loading…
Reference in a new issue