diff --git a/apps/opencs/view/world/dialoguesubview.cpp b/apps/opencs/view/world/dialoguesubview.cpp index 6bd8001c7..1692cdf80 100644 --- a/apps/opencs/view/world/dialoguesubview.cpp +++ b/apps/opencs/view/world/dialoguesubview.cpp @@ -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(mTable->data(mTable->index(mRow, 2)).toInt())); } \ No newline at end of file diff --git a/apps/opencs/view/world/dialoguesubview.hpp b/apps/opencs/view/world/dialoguesubview.hpp index bf6e70e0d..af07d28f4 100644 --- a/apps/opencs/view/world/dialoguesubview.hpp +++ b/apps/opencs/view/world/dialoguesubview.hpp @@ -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); }; } diff --git a/apps/opencs/view/world/subviews.cpp b/apps/opencs/view/world/subviews.cpp index d4d9565a4..f647a9261 100644 --- a/apps/opencs/view/world/subviews.cpp +++ b/apps/opencs/view/world/subviews.cpp @@ -79,22 +79,58 @@ void CSVWorld::addSubViewFactories (CSVDoc::SubViewFactoryManager& manager) manager.add (CSMWorld::UniversalId::Type_Scene, new CSVDoc::SubViewFactory); - manager.add(CSMWorld::UniversalId::Type_Region, new CSVDoc::SubViewFactory); - manager.add(CSMWorld::UniversalId::Type_Spell, new CSVDoc::SubViewFactory); - manager.add(CSMWorld::UniversalId::Type_Referenceable, new CSVDoc::SubViewFactory); - manager.add(CSMWorld::UniversalId::Type_Birthsign, new CSVDoc::SubViewFactory); - manager.add(CSMWorld::UniversalId::Type_Global, new CSVDoc::SubViewFactory); - manager.add(CSMWorld::UniversalId::Type_Gmst, new CSVDoc::SubViewFactory); - manager.add(CSMWorld::UniversalId::Type_Race, new CSVDoc::SubViewFactory); - manager.add(CSMWorld::UniversalId::Type_Class, new CSVDoc::SubViewFactory); - manager.add(CSMWorld::UniversalId::Type_Reference, new CSVDoc::SubViewFactory); - manager.add(CSMWorld::UniversalId::Type_Cell, new CSVDoc::SubViewFactory); - manager.add(CSMWorld::UniversalId::Type_Filter, new CSVDoc::SubViewFactory); - manager.add(CSMWorld::UniversalId::Type_Sound, new CSVDoc::SubViewFactory); - manager.add(CSMWorld::UniversalId::Type_Faction, new CSVDoc::SubViewFactory); - manager.add(CSMWorld::UniversalId::Type_Skill, new CSVDoc::SubViewFactory); - manager.add(CSMWorld::UniversalId::Type_JournalInfo, new CSVDoc::SubViewFactory); - manager.add(CSMWorld::UniversalId::Type_TopicInfo, new CSVDoc::SubViewFactory); - manager.add(CSMWorld::UniversalId::Type_Topic, new CSVDoc::SubViewFactory); - manager.add(CSMWorld::UniversalId::Type_Journal, new CSVDoc::SubViewFactory); + //edit subviews + manager.add (CSMWorld::UniversalId::Type_Region, + new CSVDoc::SubViewFactoryWithCreator > (false)); + + manager.add (CSMWorld::UniversalId::Type_Spell, + new CSVDoc::SubViewFactoryWithCreator > (false)); + + manager.add (CSMWorld::UniversalId::Type_Referenceable, + new CSVDoc::SubViewFactoryWithCreator > (false)); + + manager.add (CSMWorld::UniversalId::Type_Birthsign, + new CSVDoc::SubViewFactoryWithCreator > (false)); + + manager.add (CSMWorld::UniversalId::Type_Global, + new CSVDoc::SubViewFactoryWithCreator > (false)); + + manager.add (CSMWorld::UniversalId::Type_Gmst, + new CSVDoc::SubViewFactoryWithCreator > (false)); + + manager.add (CSMWorld::UniversalId::Type_Race, + new CSVDoc::SubViewFactoryWithCreator > (false)); + + manager.add (CSMWorld::UniversalId::Type_Class, + new CSVDoc::SubViewFactoryWithCreator > (false)); + + manager.add (CSMWorld::UniversalId::Type_Reference, + new CSVDoc::SubViewFactoryWithCreator > (false)); + + manager.add (CSMWorld::UniversalId::Type_Cell, + new CSVDoc::SubViewFactoryWithCreator > (false)); + + manager.add (CSMWorld::UniversalId::Type_Filter, + new CSVDoc::SubViewFactoryWithCreator > (false)); + + manager.add (CSMWorld::UniversalId::Type_Sound, + new CSVDoc::SubViewFactoryWithCreator > (false)); + + manager.add (CSMWorld::UniversalId::Type_Faction, + new CSVDoc::SubViewFactoryWithCreator > (false)); + + manager.add (CSMWorld::UniversalId::Type_Skill, + new CSVDoc::SubViewFactoryWithCreator > (false)); + + manager.add (CSMWorld::UniversalId::Type_JournalInfo, + new CSVDoc::SubViewFactoryWithCreator > (false)); + + manager.add (CSMWorld::UniversalId::Type_TopicInfo, + new CSVDoc::SubViewFactoryWithCreator > (false)); + + manager.add (CSMWorld::UniversalId::Type_Topic, + new CSVDoc::SubViewFactoryWithCreator > (false)); + + manager.add (CSMWorld::UniversalId::Type_Journal, + new CSVDoc::SubViewFactoryWithCreator > (false)); } \ No newline at end of file