Remoto - VFS: VFS_iframe.cpp Source File
Remoto - VFS
VFS_iframe.cpp
Go to the documentation of this file.
1 
2 #include "VFS.h"
3 #include "VFS_base/VFS_icons.h"
4 //#include "utilities/rutils.h"
5 
6 #include "VFS_iframe.h"
7 
28 VFS_iframe::VFS_iframe(QString url, QString label, QString icon)
29 : VFS_node()
30 , _label(label)
31 , _icon(icon.toUtf8())
32 , _url(url)
33 {
34 }
35 
37 {
38 }
39 
45 QByteArray VFS_iframe::icon()
46 {
47  if (!_icon.isEmpty())
48  return _icon;
49 
50  return VFS_icons::get("application");
51 }
52 
57 {
58  return _url;
59 }
60 
75 {
76  QJsonObject o;
77 
78  o["url"] = _url;
79 
80  r->_data.setObject(o);
81  r->_success = true;
82 }
83 
88 {
90 
91  r->_metadata["type"] = "iframe";
92 
93  if (!_label.isEmpty())
94  r->_metadata["label"] = _label;
95 
96  if (r->_success)
97  {
98  QJsonObject a;
99  a["type"] = "openLayout";
100  r->_metadata["action"] = a;
101 
102  QJsonObject l;
103  l["name"] = "@sourcefile@";
104  l["type"] = "pane";
105  l["path"] = "@sourcepath@/@sourcefile@";
106  l["icon"] = "@icon@";
107  QJsonObject t;
108  t["openLayout"] = l;
109 
110  r->_metadata["template"] = t;
111  r->_metadata["where"] = "nearest";
112  }
113 }
static char * get(QString which="")
Fetch an icon from the library.
Definition: VFS_icons.cpp:34
QString _url
The url to report to the iframe.
Definition: VFS_iframe.h:33
virtual QString reportDetails()
Reports the current url value.
Definition: VFS_iframe.cpp:56
virtual void read(VFS_request *r)
Read the contents of this node, which will contain its url.
Definition: VFS_iframe.cpp:74
QString _label
The label to use.
Definition: VFS_iframe.h:19
virtual ~VFS_iframe()
Definition: VFS_iframe.cpp:36
virtual QByteArray icon()
The icon for the button.
Definition: VFS_iframe.cpp:45
Q_INVOKABLE VFS_iframe(QString url, QString label=QString(), QString icon=QString())
Definition: VFS_iframe.cpp:28
virtual void metadata(VFS_request *r)
Return the metadata needed to create an iframe pane in the nearest available tab in the layout.
Definition: VFS_iframe.cpp:87
QByteArray _icon
The icon to use. Will default to "application" from VFS_icons if missing.
Definition: VFS_iframe.h:20
VFS_node is the base class from which all other VFS_node classes derive.
Definition: VFS_node.h:143
virtual void metadata(VFS_request *r)
Fetch the metadata of this node.
Definition: VFS_node.cpp:797
The base class for all requests between nodes.
Definition: VFS_node.h:54
bool _success
if the request was successfully completed
Definition: VFS_node.h:107
QJsonDocument _data
the request payload
Definition: VFS_node.h:102
QJsonObject _metadata
the request payload
Definition: VFS_node.h:101
url(value, options)