clone and create buttons work

actorid
Marek Kochanowicz 11 years ago
parent 95afca0558
commit db774b02d7

@ -31,6 +31,7 @@
#include "recordstatusdelegate.hpp"
#include "util.hpp"
#include "tablebottombox.hpp"
/*
==============================NotEditableSubDelegate==========================================
*/
@ -379,7 +380,7 @@ void CSVWorld::EditWidget::remake(int row)
*/
CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document,
bool createAndDelete) :
const CreatorFactoryBase& creatorFactory, bool sorting) :
SubView (id),
mEditWidget(0),
@ -416,7 +417,7 @@ 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()), this, SLOT(revertRecord()));
connect(deleteButton, SIGNAL(clicked()), this, SLOT(deleteRecord()));
@ -428,7 +429,21 @@ CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id, CSM
mMainLayout->addLayout(buttonsLayout);
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));
setWidget(mainWidget);
@ -567,7 +582,10 @@ void CSVWorld::DialogueSubView::revertRecord()
void CSVWorld::DialogueSubView::deleteRecord()
{
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()));
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
{
class CommandDelegate;
class CreatorFactoryBase;
class TableBottomBox;
class NotEditableSubDelegate : public QAbstractItemDelegate
{
@ -166,10 +168,14 @@ namespace CSVWorld
int mRow;
bool mLocked;
const CSMDoc::Document& mDocument;
TableBottomBox* mBottom;
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);
@ -182,12 +188,16 @@ namespace CSVWorld
void revertRecord();
void deleteRecord();
void cloneRequest();
void dataChanged(const QModelIndex & index);
///\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);
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_Region, new CSVDoc::SubViewFactory<DialogueSubView>);
manager.add(CSMWorld::UniversalId::Type_Spell, new CSVDoc::SubViewFactory<DialogueSubView>);
manager.add(CSMWorld::UniversalId::Type_Referenceable, new CSVDoc::SubViewFactory<DialogueSubView>);
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_Gmst, new CSVDoc::SubViewFactory<DialogueSubView>);
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_Reference, new CSVDoc::SubViewFactory<DialogueSubView>);
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_Sound, new CSVDoc::SubViewFactory<DialogueSubView>);
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_JournalInfo, new CSVDoc::SubViewFactory<DialogueSubView>);
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_Journal, new CSVDoc::SubViewFactory<DialogueSubView>);
//edit subviews
manager.add (CSMWorld::UniversalId::Type_Region,
new CSVDoc::SubViewFactoryWithCreator<DialogueSubView, CreatorFactory<GenericCreator> > (false));
manager.add (CSMWorld::UniversalId::Type_Spell,
new CSVDoc::SubViewFactoryWithCreator<DialogueSubView, CreatorFactory<GenericCreator> > (false));
manager.add (CSMWorld::UniversalId::Type_Referenceable,
new CSVDoc::SubViewFactoryWithCreator<DialogueSubView, CreatorFactory<GenericCreator> > (false));
manager.add (CSMWorld::UniversalId::Type_Birthsign,
new CSVDoc::SubViewFactoryWithCreator<DialogueSubView, CreatorFactory<GenericCreator> > (false));
manager.add (CSMWorld::UniversalId::Type_Global,
new CSVDoc::SubViewFactoryWithCreator<DialogueSubView, CreatorFactory<GenericCreator> > (false));
manager.add (CSMWorld::UniversalId::Type_Gmst,
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…
Cancel
Save