forked from mirror/openmw-tes3mp
added Creator class for filters
This commit is contained in:
parent
0944338c27
commit
f6226e4859
5 changed files with 123 additions and 7 deletions
|
@ -111,6 +111,10 @@ opencs_hdrs_noqt (model/filter
|
||||||
filter
|
filter
|
||||||
)
|
)
|
||||||
|
|
||||||
|
opencs_units (view/filter
|
||||||
|
filtercreator
|
||||||
|
)
|
||||||
|
|
||||||
set (OPENCS_US
|
set (OPENCS_US
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -11,15 +11,15 @@ namespace CSMFilter
|
||||||
/// \brief Wrapper for Filter record
|
/// \brief Wrapper for Filter record
|
||||||
struct Filter : public ESM::Filter
|
struct Filter : public ESM::Filter
|
||||||
{
|
{
|
||||||
enum scope
|
enum Scope
|
||||||
{
|
{
|
||||||
Global = 0,
|
Scope_Global = 0, // per user
|
||||||
Local = 1,
|
Scope_Project = 1, // per project
|
||||||
Session = 2,
|
Scope_Session = 2, // exists only for one editing session; not saved
|
||||||
Content = 3
|
Scope_Content = 3 // embedded in the edited content file
|
||||||
};
|
};
|
||||||
|
|
||||||
scope mScope;
|
Scope mScope;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
65
apps/opencs/view/filter/filtercreator.cpp
Normal file
65
apps/opencs/view/filter/filtercreator.cpp
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
|
||||||
|
#include "filtercreator.hpp"
|
||||||
|
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QLabel>
|
||||||
|
|
||||||
|
#include "../../model/filter/filter.hpp"
|
||||||
|
|
||||||
|
std::string CSVFilter::FilterCreator::getNamespace() const
|
||||||
|
{
|
||||||
|
switch (mScope->currentIndex())
|
||||||
|
{
|
||||||
|
case CSMFilter::Filter::Scope_Global: return "global::";
|
||||||
|
case CSMFilter::Filter::Scope_Project: return "project::";
|
||||||
|
case CSMFilter::Filter::Scope_Session: return "session::";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVFilter::FilterCreator::update()
|
||||||
|
{
|
||||||
|
mNamespace->setText (QString::fromUtf8 (getNamespace().c_str()));
|
||||||
|
GenericCreator::update();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string CSVFilter::FilterCreator::getId() const
|
||||||
|
{
|
||||||
|
return getNamespace() + GenericCreator::getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
CSVFilter::FilterCreator::FilterCreator (CSMWorld::Data& data, QUndoStack& undoStack,
|
||||||
|
const CSMWorld::UniversalId& id)
|
||||||
|
: GenericCreator (data, undoStack, id)
|
||||||
|
{
|
||||||
|
mNamespace = new QLabel ("::", this);
|
||||||
|
insertAtBeginning (mNamespace, false);
|
||||||
|
|
||||||
|
mScope = new QComboBox (this);
|
||||||
|
|
||||||
|
mScope->addItem ("Global");
|
||||||
|
mScope->addItem ("Project");
|
||||||
|
mScope->addItem ("Session");
|
||||||
|
/// \ŧodo re-enable for OpenMW 1.1
|
||||||
|
// mScope->addItem ("Content");
|
||||||
|
|
||||||
|
connect (mScope, SIGNAL (currentIndexChanged (int)), this, SLOT (setScope (int)));
|
||||||
|
|
||||||
|
insertAtBeginning (mScope, false);
|
||||||
|
|
||||||
|
QLabel *label = new QLabel ("Scope", this);
|
||||||
|
insertAtBeginning (label, false);
|
||||||
|
|
||||||
|
mScope->setCurrentIndex (2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVFilter::FilterCreator::reset()
|
||||||
|
{
|
||||||
|
GenericCreator::reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVFilter::FilterCreator::setScope (int index)
|
||||||
|
{
|
||||||
|
update();
|
||||||
|
}
|
41
apps/opencs/view/filter/filtercreator.hpp
Normal file
41
apps/opencs/view/filter/filtercreator.hpp
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
#ifndef CSV_FILTER_FILTERCREATOR_H
|
||||||
|
#define CSV_FILTER_FILTERCREATOR_H
|
||||||
|
|
||||||
|
class QComboBox;
|
||||||
|
class QLabel;
|
||||||
|
|
||||||
|
#include "../world/genericcreator.hpp"
|
||||||
|
|
||||||
|
namespace CSVFilter
|
||||||
|
{
|
||||||
|
class FilterCreator : public CSVWorld::GenericCreator
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
QComboBox *mScope;
|
||||||
|
QLabel *mNamespace;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
std::string getNamespace() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
void update();
|
||||||
|
|
||||||
|
virtual std::string getId() const;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
FilterCreator (CSMWorld::Data& data, QUndoStack& undoStack,
|
||||||
|
const CSMWorld::UniversalId& id);
|
||||||
|
|
||||||
|
virtual void reset();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
void setScope (int index);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
#include "../doc/subviewfactoryimp.hpp"
|
#include "../doc/subviewfactoryimp.hpp"
|
||||||
|
|
||||||
|
#include "../filter/filtercreator.hpp"
|
||||||
|
|
||||||
#include "tablesubview.hpp"
|
#include "tablesubview.hpp"
|
||||||
#include "dialoguesubview.hpp"
|
#include "dialoguesubview.hpp"
|
||||||
#include "scriptsubview.hpp"
|
#include "scriptsubview.hpp"
|
||||||
|
@ -33,7 +35,6 @@ void CSVWorld::addSubViewFactories (CSVDoc::SubViewFactoryManager& manager)
|
||||||
CSMWorld::UniversalId::Type_Regions,
|
CSMWorld::UniversalId::Type_Regions,
|
||||||
CSMWorld::UniversalId::Type_Birthsigns,
|
CSMWorld::UniversalId::Type_Birthsigns,
|
||||||
CSMWorld::UniversalId::Type_Spells,
|
CSMWorld::UniversalId::Type_Spells,
|
||||||
CSMWorld::UniversalId::Type_Filters,
|
|
||||||
|
|
||||||
CSMWorld::UniversalId::Type_None // end marker
|
CSMWorld::UniversalId::Type_None // end marker
|
||||||
};
|
};
|
||||||
|
@ -56,4 +57,9 @@ void CSVWorld::addSubViewFactories (CSVDoc::SubViewFactoryManager& manager)
|
||||||
|
|
||||||
// Other stuff (combined record tables)
|
// Other stuff (combined record tables)
|
||||||
manager.add (CSMWorld::UniversalId::Type_RegionMap, new CSVDoc::SubViewFactory<RegionMapSubView>);
|
manager.add (CSMWorld::UniversalId::Type_RegionMap, new CSVDoc::SubViewFactory<RegionMapSubView>);
|
||||||
|
|
||||||
|
manager.add (CSMWorld::UniversalId::Type_Filters,
|
||||||
|
new CSVDoc::SubViewFactoryWithCreator<TableSubView,
|
||||||
|
CreatorFactory<CSVFilter::FilterCreator> >);
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue