TreeFrogFramework  1.18
tabstractcontroller.h
Go to the documentation of this file.
1 #ifndef TABSTRACTCONTROLLER_H
2 #define TABSTRACTCONTROLLER_H
3 
4 #include <QVariant>
5 #include <TGlobal>
6 
7 class TFormValidator;
8 
9 
11 {
12 public:
14  virtual ~TAbstractController() { }
15  virtual QString name() const = 0;
16  virtual QString activeAction() const = 0;
17 
18 protected:
19  QVariant variant(const QString &name) const;
20  void exportVariant(const QString &name, const QVariant &value, bool overwrite = true);
21  void exportValidationErrors(const TFormValidator &validator, const QString &prefix = QString("err_"));
22  bool hasVariant(const QString &name) const;
23  void exportVariants(const QVariantMap &map);
24  const QVariantMap &allVariants() const { return exportVars; }
25  QString viewClassName(const QString &action = QString()) const;
26  QString viewClassName(const QString &contoller, const QString &action) const;
27 
28 private:
29  QVariantMap exportVars;
32 };
33 
34 
35 inline QVariant TAbstractController::variant(const QString &name) const
36 {
37  return exportVars.value(name);
38 }
39 
40 inline bool TAbstractController::hasVariant(const QString &name) const
41 {
42  return exportVars.contains(name);
43 }
44 
45 #endif // TABSTRACTCONTROLLER_H
#define T_CORE_EXPORT
Definition: tglobal.h:81
The TAbstractController class is the abstract base class of controllers, providing functionality comm...
Definition: tabstractcontroller.h:10
virtual ~TAbstractController()
Definition: tabstractcontroller.h:14
#define T_DISABLE_COPY(Class)
Definition: tglobal.h:137
bool hasVariant(const QString &name) const
Returns true if a variable with the name is exported for views; otherwise returns false...
Definition: tabstractcontroller.h:40
#define T_DISABLE_MOVE(Class)
Definition: tglobal.h:141
QVariant variant(const QString &name) const
Returns the exported variable with the value associated with the name.
Definition: tabstractcontroller.h:35
The TFormValidator class provides form validation for a map-table-based dictionary.
Definition: tformvalidator.h:11
const QVariantMap & allVariants() const
Returns all the exported variables.
Definition: tabstractcontroller.h:24