made FilterCreator redundant by generalising GenericCreator
parent
35803bc9b6
commit
a54efbcfa0
@ -1,77 +0,0 @@
|
||||
|
||||
#include "filtercreator.hpp"
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QLabel>
|
||||
|
||||
#include "../../model/filter/filter.hpp"
|
||||
|
||||
#include "../../model/world/data.hpp"
|
||||
#include "../../model/world/commands.hpp"
|
||||
#include "../../model/world/columns.hpp"
|
||||
#include "../../model/world/idtable.hpp"
|
||||
|
||||
std::string CSVFilter::FilterCreator::getNamespace() const
|
||||
{
|
||||
switch (mScope->currentIndex())
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
void CSVFilter::FilterCreator::configureCreateCommand (CSMWorld::CreateCommand& command) const
|
||||
{
|
||||
int index =
|
||||
dynamic_cast<CSMWorld::IdTable&> (*getData().getTableModel (getCollectionId())).
|
||||
findColumnIndex (CSMWorld::Columns::ColumnId_Scope);
|
||||
|
||||
command.addValue (index, mScope->currentIndex());
|
||||
}
|
||||
|
||||
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 ("Project");
|
||||
mScope->addItem ("Session");
|
||||
/// \todo re-enable for OpenMW 1.1
|
||||
// mScope->addItem ("Content");
|
||||
|
||||
connect (mScope, SIGNAL (currentIndexChanged (int)), this, SLOT (setScope2 (int)));
|
||||
|
||||
insertAtBeginning (mScope, false);
|
||||
|
||||
QLabel *label = new QLabel ("Scope", this);
|
||||
insertAtBeginning (label, false);
|
||||
|
||||
mScope->setCurrentIndex (1);
|
||||
}
|
||||
|
||||
void CSVFilter::FilterCreator::reset()
|
||||
{
|
||||
GenericCreator::reset();
|
||||
}
|
||||
|
||||
void CSVFilter::FilterCreator::setScope2 (int index)
|
||||
{
|
||||
update();
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
#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;
|
||||
|
||||
virtual void configureCreateCommand (CSMWorld::CreateCommand& command) const;
|
||||
|
||||
public:
|
||||
|
||||
FilterCreator (CSMWorld::Data& data, QUndoStack& undoStack,
|
||||
const CSMWorld::UniversalId& id);
|
||||
|
||||
virtual void reset();
|
||||
|
||||
private slots:
|
||||
|
||||
void setScope2 (int index);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue