mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 20:53:50 +00:00
turned the global class into a general purpose table subview class
This commit is contained in:
parent
0a8b7602d3
commit
8e93bfa607
8 changed files with 69 additions and 45 deletions
|
@ -9,7 +9,7 @@ set (OPENCS_SRC
|
|||
|
||||
view/doc/viewmanager.cpp view/doc/view.cpp view/doc/operations.cpp view/doc/operation.cpp
|
||||
|
||||
view/world/subview.cpp view/world/table.cpp view/world/globals.cpp
|
||||
view/world/subview.cpp view/world/table.cpp view/world/tablesubview.cpp
|
||||
)
|
||||
|
||||
set (OPENCS_HDR
|
||||
|
@ -23,7 +23,7 @@ set (OPENCS_HDR
|
|||
|
||||
view/doc/viewmanager.hpp view/doc/view.hpp view/doc/operations.hpp view/doc/operation.hpp
|
||||
|
||||
view/world/subview.hpp view/world/table.hpp view/world/globals.hpp
|
||||
view/world/subview.hpp view/world/table.hpp view/world/tablesubview.hpp
|
||||
)
|
||||
|
||||
set (OPENCS_US
|
||||
|
|
|
@ -10,8 +10,7 @@
|
|||
|
||||
#include "../../model/doc/document.hpp"
|
||||
|
||||
#include "../world/subview.hpp"
|
||||
#include "../world/globals.hpp"
|
||||
#include "../world/tablesubview.hpp"
|
||||
|
||||
#include "viewmanager.hpp"
|
||||
#include "operations.hpp"
|
||||
|
@ -122,7 +121,7 @@ CSVDoc::View::View (ViewManager& viewManager, CSMDoc::Document *document, int to
|
|||
setupUi();
|
||||
|
||||
mSubViewFactories.insert (std::make_pair (CSMWorld::UniversalId (CSMWorld::UniversalId::Type_Globals),
|
||||
new CSVWorld::SubViewFactory<CSVWorld::Globals>()));
|
||||
new CSVWorld::SubViewFactoryWithCreateFlag<CSVWorld::TableSubView> (true)));
|
||||
}
|
||||
|
||||
CSVDoc::View::~View()
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
|
||||
#include "globals.hpp"
|
||||
|
||||
#include "table.hpp"
|
||||
|
||||
CSVWorld::Globals::Globals (const CSMWorld::UniversalId& id, CSMWorld::Data& data, QUndoStack& undoStack)
|
||||
: SubView (id)
|
||||
{
|
||||
setWidget (mTable = new Table (id, data, undoStack, true));
|
||||
}
|
||||
|
||||
void CSVWorld::Globals::setEditLock (bool locked)
|
||||
{
|
||||
mTable->setEditLock (locked);
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
#ifndef CSV_WORLD_GLOBALS_H
|
||||
#define CSV_WORLD_GLOBALS_H
|
||||
|
||||
#include "subview.hpp"
|
||||
|
||||
class QUndoStack;
|
||||
|
||||
namespace CSVWorld
|
||||
{
|
||||
class Table;
|
||||
|
||||
class Globals : public SubView
|
||||
{
|
||||
Table *mTable;
|
||||
|
||||
public:
|
||||
|
||||
Globals (const CSMWorld::UniversalId& id, CSMWorld::Data& data, QUndoStack& undoStack);
|
||||
|
||||
virtual void setEditLock (bool locked);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
|
@ -51,6 +51,29 @@ namespace CSVWorld
|
|||
{
|
||||
return new SubViewT (id, data, undoStack);
|
||||
}
|
||||
|
||||
template<class SubViewT>
|
||||
struct SubViewFactoryWithCreateFlag : public SubViewFactoryBase
|
||||
{
|
||||
bool mCreateAndDelete;
|
||||
|
||||
SubViewFactoryWithCreateFlag (bool createAndDelete);
|
||||
|
||||
virtual SubView *makeSubView (const CSMWorld::UniversalId& id, CSMWorld::Data& data, QUndoStack& undoStack);
|
||||
};
|
||||
|
||||
template<class SubViewT>
|
||||
SubViewFactoryWithCreateFlag<SubViewT>::SubViewFactoryWithCreateFlag (bool createAndDelete)
|
||||
: mCreateAndDelete (createAndDelete)
|
||||
{}
|
||||
|
||||
template<class SubViewT>
|
||||
SubView *SubViewFactoryWithCreateFlag<SubViewT>::makeSubView (const CSMWorld::UniversalId& id,
|
||||
CSMWorld::Data& data,
|
||||
QUndoStack& undoStack)
|
||||
{
|
||||
return new SubViewT (id, data, undoStack, mCreateAndDelete);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -145,7 +145,7 @@ CSVWorld::Table::Table (const CSMWorld::UniversalId& id, CSMWorld::Data& data, Q
|
|||
|
||||
if (createAndDelete)
|
||||
{
|
||||
mCreateAction = new QAction (tr ("CreateRecord"), this);
|
||||
mCreateAction = new QAction (tr ("Add Record"), this);
|
||||
connect (mCreateAction, SIGNAL (triggered()), this, SLOT (createRecord()));
|
||||
addAction (mCreateAction);
|
||||
}
|
||||
|
|
16
apps/opencs/view/world/tablesubview.cpp
Normal file
16
apps/opencs/view/world/tablesubview.cpp
Normal file
|
@ -0,0 +1,16 @@
|
|||
|
||||
#include "tablesubview.hpp"
|
||||
|
||||
#include "table.hpp"
|
||||
|
||||
CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMWorld::Data& data, QUndoStack& undoStack,
|
||||
bool createAndDelete)
|
||||
: SubView (id)
|
||||
{
|
||||
setWidget (mTable = new Table (id, data, undoStack, createAndDelete));
|
||||
}
|
||||
|
||||
void CSVWorld::TableSubView::setEditLock (bool locked)
|
||||
{
|
||||
mTable->setEditLock (locked);
|
||||
}
|
25
apps/opencs/view/world/tablesubview.hpp
Normal file
25
apps/opencs/view/world/tablesubview.hpp
Normal file
|
@ -0,0 +1,25 @@
|
|||
#ifndef CSV_WORLD_TABLESUBVIEW_H
|
||||
#define CSV_WORLD_TABLESUBVIEW_H
|
||||
|
||||
#include "subview.hpp"
|
||||
|
||||
class QUndoStack;
|
||||
|
||||
namespace CSVWorld
|
||||
{
|
||||
class Table;
|
||||
|
||||
class TableSubView : public SubView
|
||||
{
|
||||
Table *mTable;
|
||||
|
||||
public:
|
||||
|
||||
TableSubView (const CSMWorld::UniversalId& id, CSMWorld::Data& data, QUndoStack& undoStack,
|
||||
bool createAndDelete);
|
||||
|
||||
virtual void setEditLock (bool locked);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue