3
3
4
4
#include < QObject>
5
5
#include < json/json.h>
6
- #include " controls/jaspcontrol.h"
7
6
#include " appinfo.h"
7
+ #include " utilities/qutils.h"
8
+ #include " columntype.h"
8
9
9
- class AnalysisForm ;
10
+ class AnalysisFormBase ;
10
11
11
12
class AnalysisBase : public QObject
12
13
{
@@ -15,62 +16,72 @@ class AnalysisBase : public QObject
15
16
Q_PROPERTY (QString qmlError READ qmlError WRITE setQmlError NOTIFY qmlErrorChanged )
16
17
17
18
public:
18
- explicit AnalysisBase (QObject *parent = nullptr , Version moduleVersion = AppInfo::version);
19
+ struct ParentKey
20
+ {
21
+ std::string name, key;
22
+ stringvec value;
23
+ ParentKey (const std::string & _name, const std::string & _key, const stringvec & _value)
24
+ : name(_name), key(_key), value(_value) {}
25
+ };
26
+
27
+ explicit AnalysisBase (QObject *parent = nullptr , Version moduleVersion = AppInfo::version, const QString& moduleName = " " , const QString& analysisName = " " , const QString& qmlFileName = " " );
19
28
AnalysisBase (QObject *parent, AnalysisBase* duplicateMe);
20
29
21
- virtual bool isOwnComputedColumn (const std::string &col) const { return false ; }
22
- virtual void refresh () {}
23
- virtual void run () {}
24
- virtual void reloadForm () {}
25
- virtual void exportResults () {}
26
- virtual bool isDuplicate () const { return false ; }
27
- virtual bool wasUpgraded () const { return false ; }
28
- virtual bool needsRefresh () const { return false ; }
29
- virtual const std::string & module () const { return emptyString; }
30
- virtual const std::string & name () const { return emptyString; }
31
- virtual const std::string & title () const { return emptyString; }
32
- virtual void setTitle (const std::string& titel) {}
33
- virtual void preprocessMarkdownHelp (const QString& md) const {}
34
- virtual QString helpFile () { return " " ; }
35
- virtual const stringvec & upgradeMsgsForOption (const std::string& name) const { return emptyStringVec; }
36
- virtual const Json::Value & resultsMeta () const { return Json::Value::null; }
37
- virtual const Json::Value & getRSource (const std::string& name) const { return Json::Value::null; }
38
- virtual void initialized (AnalysisForm* form, bool isNewAnalysis) {}
39
- virtual std::string qmlFormPath (bool addFileProtocol = true ,
40
- bool ignoreReadyForUse = false ) const ;
41
- virtual Q_INVOKABLE QString helpFile () const { return " " ; }
42
- virtual Q_INVOKABLE void createForm (QQuickItem* parentItem=nullptr );
43
- virtual void destroyForm ();
44
- virtual bool isColumnFreeOrMine (const QString & columnName) const { return false ; }
45
-
46
- const Json::Value & boundValues () const { return _boundValues; }
47
- const Json::Value & orgBoundValues () const { return _orgBoundValues; }
48
- const Json::Value & boundValue (const std::string& name,
49
- const QVector<JASPControl::ParentKey>& parentKeys = {});
50
-
51
- void setBoundValue (const std::string& name, const Json::Value& value, const Json::Value& meta, const QVector<JASPControl::ParentKey>& parentKeys = {});
52
- void setBoundValues (const Json::Value& boundValues);
53
- void setOrgBoundValues (const Json::Value& orgBoundValues) { _orgBoundValues = orgBoundValues; }
54
- const Json::Value optionsMeta () const { return _boundValues.get (" .meta" , Json::nullValue); }
55
- void clearOptions () { _boundValues.clear (); }
56
-
57
- const Version & moduleVersion () const { return _moduleVersion; }
58
-
59
- QQuickItem * formItem () const ;
60
-
61
- const QString & qmlError () const ;
62
- void setQmlError (const QString &newQmlError);
63
- void sendRScript (const QString & script, const QString & controlName, bool whiteListedVersion) { emit sendRScriptSignal (script, controlName, whiteListedVersion, tq (module ())); }
64
- void sendFilter ( const QString & name) { emit sendFilterSignal (name, tq (module ())); }
65
-
30
+ virtual bool isOwnComputedColumn (const std::string &col) const { return false ; }
31
+ virtual void refresh () {}
32
+ virtual void run () {}
33
+ virtual void reloadForm () {}
34
+ virtual void exportResults () {}
35
+ virtual bool isDuplicate () const { return false ; }
36
+ virtual bool wasUpgraded () const { return false ; }
37
+ virtual bool needsRefresh () const { return false ; }
38
+ virtual const std::string & module () const { return _moduleName; }
39
+ virtual const std::string & name () const { return _analysisName; }
40
+ virtual const std::string & qmlFileName () const { return _qmlFileName; }
41
+ virtual const std::string & title () const { return emptyString; }
42
+ virtual void setTitle (const std::string& titel) {}
43
+ virtual void preprocessMarkdownHelp (const QString& md) const {}
44
+ virtual QString helpFile () { return " " ; }
45
+ virtual const stringvec & upgradeMsgsForOption (const std::string& name) const { return emptyStringVec; }
46
+ virtual const Json::Value & resultsMeta () const { return Json::Value::null; }
47
+ virtual const Json::Value & getRSource (const std::string& name) const { return Json::Value::null; }
48
+ virtual void initialized (AnalysisFormBase* form, bool isNewAnalysis) {}
49
+ virtual std::string qmlFormPath (bool addFileProtocol = true ,
50
+ bool ignoreReadyForUse = false ) const ;
51
+
52
+ virtual Q_INVOKABLE QString helpFile () const { return " " ; }
53
+ virtual Q_INVOKABLE void createForm (QQuickItem* parentItem=nullptr );
54
+ virtual void destroyForm ();
55
+ virtual bool isColumnFreeOrMine (const QString & columnName) const { return false ; }
56
+
57
+ const Json::Value& boundValues () const { return _boundValues; }
58
+ const Json::Value& orgBoundValues () const { return _orgBoundValues; }
59
+ const Json::Value& boundValue (const std::string& name,
60
+ const QVector<AnalysisBase::ParentKey>& parentKeys = {});
61
+
62
+ void setBoundValue (const std::string& name, const Json::Value& value, const Json::Value& meta, const QVector<AnalysisBase::ParentKey>& parentKeys = {});
63
+ void setBoundValues (const Json::Value& boundValues);
64
+ void setOrgBoundValues (const Json::Value& orgBoundValues) { _orgBoundValues = orgBoundValues; }
65
+ const Json::Value optionsMeta () const { return _boundValues.get (" .meta" , Json::nullValue); }
66
+ void clearOptions () { _boundValues.clear (); }
67
+
68
+ const Version & moduleVersion () const { return _moduleVersion; }
69
+
70
+ QQuickItem * formItem () const ;
71
+
72
+ const QString & qmlError () const ;
73
+ void setQmlError (const QString &newQmlError);
74
+
75
+ void sendRScript (const QString & script, const QString & controlName, bool whiteListedVersion) { emit sendRScriptSignal (script, controlName, whiteListedVersion, tq (module ())); }
76
+ void sendFilter ( const QString & name) { emit sendFilterSignal (name, tq (module ())); }
66
77
67
78
public slots:
68
79
virtual void boundValueChangedHandler () {}
69
80
virtual void requestColumnCreationHandler ( const std::string & columnName, columnType colType) {}
70
81
virtual void requestComputedColumnCreationHandler ( const std::string & columnName) {}
71
82
virtual void requestComputedColumnDestructionHandler (const std::string & columnName) {}
72
83
virtual void onUsedVariablesChanged () {}
73
-
84
+
74
85
75
86
signals:
76
87
void sendRScriptSignal (QString script, QString controlName, bool whiteListedVersion, QString module);
@@ -81,24 +92,26 @@ public slots:
81
92
82
93
83
94
protected:
84
- Json::Value& _getParentBoundValue (const QVector<JASPControl::ParentKey> & parentKeys, QVector<std::string>& parentNames, bool & found, bool createAnyway = false );
85
- std::string _displayParentKeys (const QVector<JASPControl::ParentKey> & parentKeys) const ;
86
-
95
+ Json::Value& _getParentBoundValue (const QVector<AnalysisBase::ParentKey> & parentKeys, QVector<std::string>& parentNames, bool & found, bool createAnyway = false );
96
+ std::string _displayParentKeys (const QVector<AnalysisBase::ParentKey> & parentKeys) const ;
87
97
88
- AnalysisForm* _analysisForm = nullptr ;
89
- QQuickItem * _parentItem = nullptr ;
90
- QString _qmlError;
91
- Version _moduleVersion;
98
+ AnalysisFormBase* _analysisForm = nullptr ;
99
+ QQuickItem * _parentItem = nullptr ;
100
+ QString _qmlError;
101
+ Version _moduleVersion;
102
+ std::string _qmlFileName,
103
+ _analysisName,
104
+ _moduleName;
92
105
93
106
private:
94
- Json::Value _boundValues = Json::objectValue,
95
- _orgBoundValues = Json::objectValue;
107
+ Json::Value _boundValues = Json::objectValue,
108
+ _orgBoundValues = Json::objectValue;
96
109
97
110
98
111
99
112
protected:
100
- static const std::string emptyString; // /< Otherwise we return references to a temporary object (std::string(""))
101
- static const stringvec emptyStringVec;
113
+ static const std::string emptyString; // /< Otherwise we return references to a temporary object (std::string(""))
114
+ static const stringvec emptyStringVec;
102
115
};
103
116
104
117
#endif // ANALYSISBASE_H
0 commit comments