OpenMW
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
genericcreator.hpp
Go to the documentation of this file.
1 #ifndef CSV_WORLD_GENERICCREATOR_H
2 #define CSV_WORLD_GENERICCREATOR_H
3 
4 #include <memory>
5 
6 #include "../../model/world/universalid.hpp"
7 
8 #include "creator.hpp"
9 
10 class QString;
11 class QPushButton;
12 class QLineEdit;
13 class QHBoxLayout;
14 class QComboBox;
15 class QLabel;
16 class QUndoStack;
17 
18 namespace CSMWorld
19 {
20  class CreateCommand;
21  class Data;
22 }
23 
24 namespace CSVWorld
25 {
26  class IdValidator;
27 
28  class GenericCreator : public Creator
29  {
30  Q_OBJECT
31 
33  QUndoStack& mUndoStack;
35  QPushButton *mCreate;
36  QPushButton *mCancel;
37  QLineEdit *mId;
38  std::string mErrors;
39  QHBoxLayout *mLayout;
40  bool mLocked;
41  std::string mClonedId;
43  unsigned int mScopes;
44  QComboBox *mScope;
45  QLabel *mScopeLabel;
47 
48  protected:
49  bool mCloneMode;
50 
51  protected:
52 
53  void update();
54 
55  virtual void setManualEditing (bool enabled);
57 
58  void insertAtBeginning (QWidget *widget, bool stretched);
59 
63  void insertBeforeButtons (QWidget *widget, bool stretched);
64 
65  virtual std::string getId() const;
66 
67  virtual std::string getIdValidatorResult() const;
68 
70  virtual void configureCreateCommand (CSMWorld::CreateCommand& command) const;
71 
74  virtual void pushCommand (std::auto_ptr<CSMWorld::CreateCommand> command,
75  const std::string& id);
76 
77  CSMWorld::Data& getData() const;
78 
79  QUndoStack& getUndoStack();
80 
82 
83  std::string getNamespace() const;
84 
85  private:
86 
87  void updateNamespace();
88 
89  void addScope (const QString& name, CSMWorld::Scope scope,
90  const QString& tooltip);
91 
92  public:
93 
94  GenericCreator (CSMWorld::Data& data, QUndoStack& undoStack,
95  const CSMWorld::UniversalId& id, bool relaxedIdRules = false);
96 
97  virtual void setEditLock (bool locked);
98 
99  virtual void reset();
100 
101  virtual void toggleWidgets (bool active = true);
102 
103  virtual void cloneMode(const std::string& originId,
104  const CSMWorld::UniversalId::Type type);
105 
106  virtual std::string getErrors() const;
109 
110  virtual void setScope (unsigned int scope);
111 
113  virtual void focus();
114 
115  private slots:
116 
117  void textChanged (const QString& text);
118 
120  void inputReturnPressed();
121 
122  void create();
123 
124  void scopeChanged (int index);
125 
126  void dataIdListChanged();
127  };
128 }
129 
130 #endif
Record creator UI base class.
Definition: creator.hpp:21
QUndoStack & getUndoStack()
Definition: genericcreator.cpp:77
virtual std::string getId() const
Definition: genericcreator.cpp:49
virtual void focus()
Focus main input widget.
Definition: genericcreator.cpp:261
virtual void setEditLock(bool locked)
Definition: genericcreator.cpp:182
const CSMWorld::UniversalId & getCollectionId() const
Definition: genericcreator.cpp:82
Definition: commands.hpp:48
Definition: idvalidator.hpp:10
QLabel * mScopeLabel
Definition: genericcreator.hpp:45
IdValidator * mValidator
Definition: genericcreator.hpp:46
std::string mClonedId
Definition: genericcreator.hpp:41
CSMWorld::Data & mData
Definition: genericcreator.hpp:32
std::string mErrors
Definition: genericcreator.hpp:38
void insertAtBeginning(QWidget *widget, bool stretched)
Definition: genericcreator.cpp:35
virtual void toggleWidgets(bool active=true)
Definition: genericcreator.cpp:257
unsigned int mScopes
Definition: genericcreator.hpp:43
Type
Definition: universalid.hpp:40
void textChanged(const QString &text)
Definition: genericcreator.cpp:208
bool mLocked
Definition: genericcreator.hpp:40
CSMWorld::Data & getData() const
Definition: genericcreator.cpp:72
void scopeChanged(int index)
Definition: genericcreator.cpp:313
virtual void setManualEditing(bool enabled)
Enable/disable manual ID editing (enabled by default).
Definition: genericcreator.cpp:30
QPushButton * mCancel
Definition: genericcreator.hpp:36
void create()
Definition: genericcreator.cpp:221
QUndoStack & mUndoStack
Definition: genericcreator.hpp:33
virtual void setScope(unsigned int scope)
Default implementation: Throw an exception if scope!=Scope_Content.
Definition: genericcreator.cpp:266
QHBoxLayout * mLayout
Definition: genericcreator.hpp:39
Scope
Definition: scope.hpp:8
GenericCreator(CSMWorld::Data &data, QUndoStack &undoStack, const CSMWorld::UniversalId &id, bool relaxedIdRules=false)
Definition: genericcreator.cpp:143
std::string getNamespace() const
Definition: genericcreator.cpp:87
Definition: data.hpp:77
void dataIdListChanged()
Definition: genericcreator.cpp:319
void update()
Definition: genericcreator.cpp:20
QPushButton * mCreate
Definition: genericcreator.hpp:35
Definition: genericcreator.hpp:28
QComboBox * mScope
Definition: genericcreator.hpp:44
void addScope(const QString &name, CSMWorld::Scope scope, const QString &tooltip)
Definition: genericcreator.cpp:136
void updateNamespace()
Definition: genericcreator.cpp:113
virtual std::string getErrors() const
Definition: genericcreator.cpp:196
CSMWorld::UniversalId mListId
Definition: genericcreator.hpp:34
QLineEdit * mId
Definition: genericcreator.hpp:37
virtual void reset()
Definition: genericcreator.cpp:188
virtual void cloneMode(const std::string &originId, const CSMWorld::UniversalId::Type type)
Definition: genericcreator.cpp:249
virtual void pushCommand(std::auto_ptr< CSMWorld::CreateCommand > command, const std::string &id)
Definition: genericcreator.cpp:66
CSMWorld::UniversalId::Type mClonedType
Definition: genericcreator.hpp:42
void insertBeforeButtons(QWidget *widget, bool stretched)
Insert given widget before Create and Cancel buttons.
Definition: genericcreator.cpp:40
bool mCloneMode
Definition: genericcreator.hpp:49
void inputReturnPressed()
Create record if able to after Return key is pressed on input.
Definition: genericcreator.cpp:213
virtual void configureCreateCommand(CSMWorld::CreateCommand &command) const
Allow subclasses to add additional data to command.
Definition: genericcreator.cpp:64
virtual std::string getIdValidatorResult() const
Definition: genericcreator.cpp:54
const char * name
Definition: crashcatcher.cpp:59
Definition: universalid.hpp:12