2013-07-26 10:34:30 +00:00
|
|
|
#ifndef CSV_WORLD_GENERICCREATOR_H
|
|
|
|
#define CSV_WORLD_GENERICCREATOR_H
|
|
|
|
|
2014-09-16 11:28:11 +00:00
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
#include "../../model/world/universalid.hpp"
|
|
|
|
|
|
|
|
#include "creator.hpp"
|
|
|
|
|
2014-01-19 10:44:47 +00:00
|
|
|
class QString;
|
2013-07-28 11:43:16 +00:00
|
|
|
class QPushButton;
|
|
|
|
class QLineEdit;
|
2013-07-28 16:08:57 +00:00
|
|
|
class QHBoxLayout;
|
2014-08-10 16:46:32 +00:00
|
|
|
class QComboBox;
|
|
|
|
class QLabel;
|
2015-06-18 19:59:40 +00:00
|
|
|
class QUndoStack;
|
2013-07-28 11:43:16 +00:00
|
|
|
|
2013-07-30 08:27:17 +00:00
|
|
|
namespace CSMWorld
|
|
|
|
{
|
|
|
|
class CreateCommand;
|
2015-06-18 19:59:40 +00:00
|
|
|
class Data;
|
2013-07-30 08:27:17 +00:00
|
|
|
}
|
|
|
|
|
2013-07-26 10:34:30 +00:00
|
|
|
namespace CSVWorld
|
|
|
|
{
|
2014-08-14 12:21:34 +00:00
|
|
|
class IdValidator;
|
|
|
|
|
2013-07-26 10:34:30 +00:00
|
|
|
class GenericCreator : public Creator
|
|
|
|
{
|
2013-07-26 19:09:23 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
2013-07-28 11:43:16 +00:00
|
|
|
CSMWorld::Data& mData;
|
|
|
|
QUndoStack& mUndoStack;
|
|
|
|
CSMWorld::UniversalId mListId;
|
|
|
|
QPushButton *mCreate;
|
|
|
|
QLineEdit *mId;
|
|
|
|
std::string mErrors;
|
2013-07-28 16:08:57 +00:00
|
|
|
QHBoxLayout *mLayout;
|
2013-07-28 12:51:47 +00:00
|
|
|
bool mLocked;
|
2014-01-19 10:44:47 +00:00
|
|
|
std::string mClonedId;
|
|
|
|
CSMWorld::UniversalId::Type mClonedType;
|
2014-08-10 16:46:32 +00:00
|
|
|
unsigned int mScopes;
|
|
|
|
QComboBox *mScope;
|
|
|
|
QLabel *mScopeLabel;
|
2014-08-14 12:21:34 +00:00
|
|
|
IdValidator *mValidator;
|
2014-01-27 18:40:05 +00:00
|
|
|
|
2014-01-23 15:17:04 +00:00
|
|
|
protected:
|
|
|
|
bool mCloneMode;
|
2014-01-27 18:40:05 +00:00
|
|
|
|
2013-07-28 16:08:57 +00:00
|
|
|
protected:
|
2013-07-28 11:43:16 +00:00
|
|
|
|
|
|
|
void update();
|
|
|
|
|
2013-07-28 16:08:57 +00:00
|
|
|
virtual void setManualEditing (bool enabled);
|
|
|
|
///< Enable/disable manual ID editing (enabled by default).
|
|
|
|
|
|
|
|
void insertAtBeginning (QWidget *widget, bool stretched);
|
|
|
|
|
2013-07-30 08:27:17 +00:00
|
|
|
void insertBeforeButtons (QWidget *widget, bool stretched);
|
|
|
|
|
2013-07-28 16:08:57 +00:00
|
|
|
virtual std::string getId() const;
|
|
|
|
|
2015-09-29 12:44:25 +00:00
|
|
|
virtual std::string getIdValidatorResult() const;
|
|
|
|
|
2014-09-20 10:37:25 +00:00
|
|
|
/// Allow subclasses to add additional data to \a command.
|
2013-07-30 08:27:17 +00:00
|
|
|
virtual void configureCreateCommand (CSMWorld::CreateCommand& command) const;
|
2014-01-27 18:40:05 +00:00
|
|
|
|
2014-09-20 10:37:25 +00:00
|
|
|
/// Allow subclasses to wrap the create command together with additional commands
|
|
|
|
/// into a macro.
|
|
|
|
virtual void pushCommand (std::auto_ptr<CSMWorld::CreateCommand> command,
|
2014-09-16 11:28:11 +00:00
|
|
|
const std::string& id);
|
|
|
|
|
2013-08-08 10:49:30 +00:00
|
|
|
CSMWorld::Data& getData() const;
|
2013-07-30 10:53:03 +00:00
|
|
|
|
2014-09-18 10:25:17 +00:00
|
|
|
QUndoStack& getUndoStack();
|
|
|
|
|
2013-08-08 10:49:30 +00:00
|
|
|
const CSMWorld::UniversalId& getCollectionId() const;
|
2013-07-30 10:53:03 +00:00
|
|
|
|
2014-08-10 16:46:32 +00:00
|
|
|
std::string getNamespace() const;
|
|
|
|
|
2014-08-14 12:21:34 +00:00
|
|
|
private:
|
|
|
|
|
|
|
|
void updateNamespace();
|
|
|
|
|
2014-10-13 12:24:27 +00:00
|
|
|
void addScope (const QString& name, CSMWorld::Scope scope,
|
|
|
|
const QString& tooltip);
|
|
|
|
|
2013-07-26 10:34:30 +00:00
|
|
|
public:
|
2013-07-26 19:09:23 +00:00
|
|
|
|
2013-07-28 11:43:16 +00:00
|
|
|
GenericCreator (CSMWorld::Data& data, QUndoStack& undoStack,
|
2013-10-22 09:08:37 +00:00
|
|
|
const CSMWorld::UniversalId& id, bool relaxedIdRules = false);
|
2013-07-26 19:09:23 +00:00
|
|
|
|
2013-07-28 12:51:47 +00:00
|
|
|
virtual void setEditLock (bool locked);
|
|
|
|
|
2013-07-26 19:09:23 +00:00
|
|
|
virtual void reset();
|
2014-01-27 18:47:54 +00:00
|
|
|
|
2014-01-23 15:00:44 +00:00
|
|
|
virtual void toggleWidgets (bool active = true);
|
2013-07-28 11:43:16 +00:00
|
|
|
|
2014-08-10 16:46:32 +00:00
|
|
|
virtual void cloneMode(const std::string& originId,
|
2014-01-27 12:08:14 +00:00
|
|
|
const CSMWorld::UniversalId::Type type);
|
2014-01-27 18:47:54 +00:00
|
|
|
|
2013-07-28 11:43:16 +00:00
|
|
|
virtual std::string getErrors() const;
|
|
|
|
///< Return formatted error descriptions for the current state of the creator. if an empty
|
|
|
|
/// string is returned, there is no error.
|
|
|
|
|
2014-08-10 16:46:32 +00:00
|
|
|
virtual void setScope (unsigned int scope);
|
|
|
|
|
2015-05-02 11:20:42 +00:00
|
|
|
/// Focus main input widget
|
|
|
|
virtual void focus();
|
|
|
|
|
2013-07-28 11:43:16 +00:00
|
|
|
private slots:
|
|
|
|
|
|
|
|
void textChanged (const QString& text);
|
|
|
|
|
|
|
|
void create();
|
2014-08-10 16:46:32 +00:00
|
|
|
|
|
|
|
void scopeChanged (int index);
|
2015-06-27 09:26:19 +00:00
|
|
|
|
|
|
|
void dataIdListChanged();
|
2013-07-26 10:34:30 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2015-03-11 14:54:45 +00:00
|
|
|
#endif
|