TreeFrogFramework  1.18
tprototypeajaxhelper.h
Go to the documentation of this file.
1 #ifndef TPROTOTYPEAJAXHELPER_H
2 #define TPROTOTYPEAJAXHELPER_H
3 
4 #include <QStringList>
5 #include <QUrl>
6 #include <QVariant>
7 #include <TGlobal>
8 #include <TOption>
9 #include <THtmlAttribute>
10 #include <TJavaScriptObject>
11 
12 class TActionView;
13 
14 
16 {
17 public:
19  Replace = 0, // Replace the element
20  InsertBefore, // Insert before the element
21  InsertAfter, // Insert after the element
22  InsertAtTopOfContent, // Insert at the top of the content of the element
23  InsertAtBottomOfContent, // Insert at the bottom of the content of the element
24  };
25 
26  virtual ~TPrototypeAjaxHelper() { }
27 
28  QString requestFunction(const QUrl &url, const TOption &options,
29  const QString &jsCondition = QString()) const;
30 
31  QString updateFunction(const QUrl &url, const QString &id,
32  UpdateBehavior behavior = Replace,
33  const TOption &options = TOption(),
34  bool evalScripts = false,
35  const QString &jsCondition = QString()) const;
36 
37  QString periodicalUpdateFunction(const QUrl &url, const QString &id,
38  UpdateBehavior behavior = Replace,
39  const TOption &options = TOption(),
40  bool evalScripts = false,
41  int frequency = 2, int decay = 1,
42  const QString &jsCondition = QString()) const;
43 
44  QString linkToRequest(const QString &text, const QUrl &url, const TOption &options,
45  const QString &jsCondition = QString(),
46  const THtmlAttribute &attributes = THtmlAttribute()) const;
47 
48  QString linkToUpdate(const QString &text, const QUrl &url, const QString &id,
49  UpdateBehavior behavior = Replace,
50  const TOption &options = TOption(),
51  bool evalScripts = false, const QString &jsCondition = QString(),
52  const THtmlAttribute &attributes = THtmlAttribute()) const;
53 
54  QString linkToPeriodicalUpdate(const QString &text, const QUrl &url, const QString &id,
55  UpdateBehavior behavior = Replace,
56  const TOption &options = TOption(),
57  bool evalScripts = false, int frequency = 2,
58  int decay = 1, const QString &jsCondition = QString(),
59  const THtmlAttribute &attributes = THtmlAttribute()) const;
60 
61  TOption o(int key, const QVariant &value) const;
62  TOption o() const { return TOption(); }
63  QVariantMap o(const QString &key, const TJavaScriptObject &value) const;
64  QVariantMap o(const QString &key, const QVariant &value) const;
65 
66 protected:
67  virtual const TActionView *actionView() const = 0;
68  QString optionsToString(const TOption &options) const;
69 };
70 
71 
72 inline TOption TPrototypeAjaxHelper::o(int key, const QVariant &value) const
73 {
74  TOption option;
75  option.insert(key, value);
76  return option;
77 }
78 
79 inline QVariantMap TPrototypeAjaxHelper::o(const QString &key, const TJavaScriptObject &value) const
80 {
81  QVariantMap map;
82  QVariant v;
83  v.setValue(value);
84  map.insert(key, v);
85  return map;
86 }
87 
88 inline QVariantMap TPrototypeAjaxHelper::o(const QString &key, const QVariant &value) const
89 {
90  QVariantMap map;
91  map.insert(key, value);
92  return map;
93 }
94 
95 #endif // TAJAXHELPER_H
#define T_CORE_EXPORT
Definition: tglobal.h:81
Definition: tprototypeajaxhelper.h:20
UpdateBehavior
Definition: tprototypeajaxhelper.h:18
TOption o() const
Definition: tprototypeajaxhelper.h:62
virtual ~TPrototypeAjaxHelper()
Definition: tprototypeajaxhelper.h:26
Definition: tprototypeajaxhelper.h:21
Definition: tprototypeajaxhelper.h:22
The TActionView class is the abstract base class of views, providing functionality common to view...
Definition: tactionview.h:17
The THtmlAttribute class represents HTML attributes for customizing web elements. ...
Definition: thtmlattribute.h:9
The TPrototypeAjaxHelper provides some functionality for Ajax of Prototype JavaScript framework...
Definition: tprototypeajaxhelper.h:15
QMap< int, QVariant > TOption
Definition: toption.h:8
Definition: tprototypeajaxhelper.h:23