mirror of https://github.com/OpenMW/openmw.git
added specialised Creator for referenceable records
parent
34c825ce52
commit
57be764cce
@ -0,0 +1,43 @@
|
||||
|
||||
#include "referenceablecreator.hpp"
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QLabel>
|
||||
|
||||
#include "../../model/world/universalid.hpp"
|
||||
#include "../../model/world/commands.hpp"
|
||||
|
||||
void CSVWorld::ReferenceableCreator::configureCreateCommand (CSMWorld::CreateCommand& command) const
|
||||
{
|
||||
command.setType (
|
||||
static_cast<CSMWorld::UniversalId::Type> (mType->itemData (mType->currentIndex()).toInt()));
|
||||
}
|
||||
|
||||
CSVWorld::ReferenceableCreator::ReferenceableCreator (CSMWorld::Data& data, QUndoStack& undoStack,
|
||||
const CSMWorld::UniversalId& id)
|
||||
: GenericCreator (data, undoStack, id)
|
||||
{
|
||||
QLabel *label = new QLabel ("Type", this);
|
||||
insertBeforeButtons (label, false);
|
||||
|
||||
std::vector<CSMWorld::UniversalId::Type> types = CSMWorld::UniversalId::listReferenceableTypes();
|
||||
|
||||
mType = new QComboBox (this);
|
||||
|
||||
for (std::vector<CSMWorld::UniversalId::Type>::const_iterator iter (types.begin());
|
||||
iter!=types.end(); ++iter)
|
||||
{
|
||||
CSMWorld::UniversalId id (*iter, "");
|
||||
|
||||
mType->addItem (QIcon (id.getIcon().c_str()), id.getTypeName().c_str(),
|
||||
static_cast<int> (id.getType()));
|
||||
}
|
||||
|
||||
insertBeforeButtons (mType, false);
|
||||
}
|
||||
|
||||
void CSVWorld::ReferenceableCreator::reset()
|
||||
{
|
||||
mType->setCurrentIndex (0);
|
||||
GenericCreator::reset();
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
#ifndef CSV_WORLD_REFERENCEABLECREATOR_H
|
||||
#define CSV_WORLD_REFERENCEABLECREATOR_H
|
||||
|
||||
class QComboBox;
|
||||
|
||||
#include "genericcreator.hpp"
|
||||
|
||||
namespace CSVWorld
|
||||
{
|
||||
class ReferenceableCreator : public GenericCreator
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
QComboBox *mType;
|
||||
|
||||
private:
|
||||
|
||||
virtual void configureCreateCommand (CSMWorld::CreateCommand& command) const;
|
||||
|
||||
public:
|
||||
|
||||
ReferenceableCreator (CSMWorld::Data& data, QUndoStack& undoStack,
|
||||
const CSMWorld::UniversalId& id);
|
||||
|
||||
virtual void reset();
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue