##// END OF EJS Templates
Added back AMDA plugin, but Python impl this time :)...
jeandet -
r1496:7c6302eee778
parent child
Show More
@@ -0,0 +1,124
1 import traceback
2 import os
3 from datetime import datetime, timedelta, timezone
4 from SciQLopBindings import PyDataProvider, Product, VectorTimeSerie, ScalarTimeSerie, DataSeriesType
5 import numpy as np
6 import requests
7 import copy
8 from spwc.amda import AMDA
9
10 amda = AMDA()
11
12 def amda_make_scalar(var=None):
13 if var is None:
14 return ((np.array(), np.array()), DataSeriesType.SCALAR)
15 else:
16 return ((var.time.copy(),var.data.copy()), DataSeriesType.SCALAR)
17
18 def amda_make_vector(var=None):
19 if var is None:
20 return ((np.array(), np.array()), DataSeriesType.VECTOR)
21 else:
22 return ((var.time.copy(),var.data.copy()), DataSeriesType.VECTOR)
23
24 def amda_make_multi_comp(var=None):
25 if var is None:
26 return ((np.array(), np.array()), DataSeriesType.MULTICOMPONENT)
27 else:
28 return ((var.time.copy(),var.data.copy()), DataSeriesType.MULTICOMPONENT)
29
30 def amda_make_spectro(var=None):
31 if var is None:
32 return ((np.array(), np.array()), DataSeriesType.SPECTROGRAM)
33 else:
34 min_sampling = float(var.meta.get("DATASET_MIN_SAMPLING","nan"))
35 max_sampling = float(var.meta.get("DATASET_MAX_SAMPLING","nan"))
36 if "PARAMETER_TABLE_MIN_VALUES[1]" in var.meta:
37 min_v = np.array([ float(v) for v in var.meta["PARAMETER_TABLE_MIN_VALUES[1]"].split(',') ])
38 max_v = np.array([ float(v) for v in var.meta["PARAMETER_TABLE_MAX_VALUES[1]"].split(',') ])
39 y = (max_v + min_v)/2.
40 elif "PARAMETER_TABLE_MIN_VALUES[0]" in var.meta:
41 min_v = np.array([ float(v) for v in var.meta["PARAMETER_TABLE_MIN_VALUES[0]"].split(',') ])
42 max_v = np.array([ float(v) for v in var.meta["PARAMETER_TABLE_MAX_VALUES[0]"].split(',') ])
43 y = (max_v + min_v)/2.
44 else:
45 y = np.logspace(1,3,var.data.shape[1])[::-1]
46 return ((var.time.copy(),var.data.copy()), DataSeriesType.SPECTROGRAM)
47 #return pysciqlopcore.SpectrogramTimeSerie(var.time,y,var.data,min_sampling,max_sampling,True)
48
49 def amda_get_sample(metadata,start,stop):
50 ts_type = amda_make_scalar
51 try:
52 param_id = None
53 for key,value in metadata:
54 if key == 'xml:id':
55 param_id = value
56 elif key == 'type':
57 if value == 'vector':
58 ts_type = amda_make_vector
59 elif value == 'multicomponent':
60 ts_type = amda_make_multi_comp
61 elif value == 'spectrogram':
62 ts_type = amda_make_spectro
63 tstart=datetime.fromtimestamp(start, tz=timezone.utc)
64 tend=datetime.fromtimestamp(stop, tz=timezone.utc)
65 var = amda.get_parameter(start_time=tstart, stop_time=tend, parameter_id=param_id, method="REST")
66 return ts_type(var)
67 except Exception as e:
68 print(traceback.format_exc())
69 print("Error in amda.py ",str(e))
70 return ts_type()
71
72
73 class AmdaProvider(PyDataProvider):
74 def __init__(self):
75 super(AmdaProvider,self).__init__()
76 if len(amda.component) is 0:
77 amda.update_inventory()
78 parameters = copy.deepcopy(amda.parameter)
79 for name,component in amda.component.items():
80 if 'components' in parameters[component['parameter']]:
81 parameters[component['parameter']]['components'].append(component)
82 else:
83 parameters[component['parameter']]['components']=[component]
84
85 products = []
86 for key,parameter in parameters.items():
87 path = f"/AMDA/{parameter['mission']}/{parameter.get('observatory','')}/{parameter['instrument']}/{parameter['dataset']}/{parameter['name']}"
88 components = [component['name'] for component in parameter.get('components',[])]
89 metadata = { key:item for key,item in parameter.items() if key is not 'components' }
90 n_components = parameter.get('size',0)
91 if n_components == '3':
92 metadata["type"]="vector"
93 elif parameter.get('display_type','')=="spectrogram":
94 metadata["type"]="spectrogram"
95 elif n_components !=0:
96 metadata["type"]="multicomponent"
97 else:
98 metadata["type"]="scalar"
99 products.append( Product(path, components, metadata))
100 self.register_products(products)
101 for mission in amda.mission:
102 self.set_icon(f'/AMDA/{mission}','satellite')
103
104 def get_data(self,metadata,start,stop):
105 ts_type = amda_make_scalar
106 try:
107 param_id = metadata['xml:id']
108 ts_type_str = metadata['type']
109 if ts_type_str == 'vector':
110 ts_type = amda_make_vector
111 elif ts_type_str == 'multicomponent':
112 ts_type = amda_make_multi_comp
113 elif ts_type_str == 'spectrogram':
114 ts_type = amda_make_spectro
115 tstart=datetime.fromtimestamp(start, tz=timezone.utc)
116 tend=datetime.fromtimestamp(stop, tz=timezone.utc)
117 var = amda.get_parameter(start_time=tstart, stop_time=tend, parameter_id=param_id, method="REST")
118 return ts_type(var)
119 except Exception as e:
120 print(traceback.format_exc())
121 print("Error in amda.py ",str(e))
122 return ts_type()
123
124 _amda = AmdaProvider()
@@ -0,0 +1,260
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!-- Created with Inkscape (http://www.inkscape.org/) -->
3
4 <svg
5 xmlns:dc="http://purl.org/dc/elements/1.1/"
6 xmlns:cc="http://creativecommons.org/ns#"
7 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
8 xmlns:svg="http://www.w3.org/2000/svg"
9 xmlns="http://www.w3.org/2000/svg"
10 xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
11 xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
12 id="svg4437"
13 version="1.1"
14 inkscape:version="0.92.4 (unknown)"
15 width="307"
16 height="158"
17 sodipodi:docname="satellite.svg">
18 <metadata
19 id="metadata4443">
20 <rdf:RDF>
21 <cc:Work
22 rdf:about="">
23 <dc:format>image/svg+xml</dc:format>
24 <dc:type
25 rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
26 <dc:title></dc:title>
27 </cc:Work>
28 </rdf:RDF>
29 </metadata>
30 <defs
31 id="defs4441" />
32 <sodipodi:namedview
33 pagecolor="#ffffff"
34 bordercolor="#666666"
35 borderopacity="1"
36 objecttolerance="10"
37 gridtolerance="10"
38 guidetolerance="10"
39 inkscape:pageopacity="0"
40 inkscape:pageshadow="2"
41 inkscape:window-width="2560"
42 inkscape:window-height="1376"
43 id="namedview4439"
44 showgrid="false"
45 inkscape:zoom="2.0064155"
46 inkscape:cx="404.11031"
47 inkscape:cy="175.13214"
48 inkscape:window-x="2560"
49 inkscape:window-y="27"
50 inkscape:window-maximized="1"
51 inkscape:current-layer="svg4437">
52 <inkscape:grid
53 type="xygrid"
54 id="grid4959" />
55 </sodipodi:namedview>
56 <g
57 inkscape:groupmode="layer"
58 id="layer1"
59 inkscape:label="Layer 1"
60 transform="translate(0,-242)">
61 <path
62 style="fill:#000000;fill-opacity:1;stroke:none"
63 d="m 115.77577,336.08354 17.81454,-48.43596 24.69555,-3.13086 11.31724,3.2219 20.68325,19.13803 -17.60732,50.11469 -23.51037,9.49468 -22.92646,-7.97442 z"
64 id="path4448"
65 inkscape:connector-curvature="0"
66 sodipodi:nodetypes="ccccccccc" />
67 </g>
68 <g
69 inkscape:groupmode="layer"
70 id="layer2"
71 inkscape:label="Layer2"
72 transform="translate(0,-242)">
73 <path
74 style="fill:#000000;fill-opacity:1;stroke:none"
75 d="m 121.6147,377.93505 10.57545,-18.33761 11.59408,3.95814 -2.84607,20.97636 z"
76 id="path4961"
77 inkscape:connector-curvature="0" />
78 </g>
79 <g
80 id="g4978"
81 transform="rotate(-18.168185,-166.03465,383.32882)"
82 style="fill:#000000;fill-opacity:1;stroke:none;stroke-opacity:1">
83 <path
84 sodipodi:nodetypes="ssssssssssssssssss"
85 inkscape:connector-curvature="0"
86 id="path4963"
87 d="m 290.03125,131.375 c -5.12246,0 -15.85135,7.26238 -18.87486,12.80548 -3.02351,5.5431 -5.16493,8.80227 -5.16493,17.05217 0,8.2499 1.78899,12.21393 4.8125,17.75703 3.02351,5.5431 14.10483,13.51032 19.22729,13.51032 5.12246,0 9.50774,-3.73815 12.53125,-9.28125 3.02351,-5.5431 4.84375,-13.03135 4.84375,-21.28125 0,-8.2499 -1.82024,-15.73815 -4.84375,-21.28125 -3.02351,-5.5431 -7.40879,-9.28125 -12.53125,-9.28125 z m 0,3 c 3.63625,0 7.18992,2.73881 9.90625,7.71875 2.71633,4.97994 4.46875,12.03603 4.46875,19.84375 0,7.80772 -1.75242,14.86381 -4.46875,19.84375 -2.71633,4.97994 -6.27,7.71875 -9.90625,7.71875 -3.63625,0 -7.15867,-2.73881 -9.875,-7.71875 -2.71633,-4.97994 -4.46875,-12.03603 -4.46875,-19.84375 0,-7.80772 1.75242,-14.86381 4.46875,-19.84375 2.71633,-4.97994 6.23875,-7.71875 9.875,-7.71875 z"
88 style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:Sans;-inkscape-font-specification:Sans;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;baseline-shift:baseline;text-anchor:start;display:inline;overflow:visible;visibility:visible;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:3;marker:none;enable-background:accumulate" />
89 <rect
90 ry="0.23655923"
91 y="143.4912"
92 x="269.29535"
93 height="0.7551648"
94 width="33.616547"
95 id="rect4969"
96 style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none"
97 transform="matrix(0.99806914,0.06211281,0.07469932,0.9972061,0,0)" />
98 <ellipse
99 transform="matrix(0.77587022,0,0,0.80357988,69.860721,32.761382)"
100 id="path4975"
101 style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.0940001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
102 cx="314.44934"
103 cy="161.4097"
104 rx="2.5550661"
105 ry="2.4669604" />
106 </g>
107 <rect
108 style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none"
109 id="rect4983"
110 width="3.7996066"
111 height="23.331676"
112 x="150.11719"
113 y="-98.335892"
114 ry="0.40695283"
115 transform="matrix(0.72487381,0.68888167,-0.71868209,0.69533881,0,0)" />
116 <rect
117 style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.0940001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
118 id="rect4985"
119 width="23.964754"
120 height="23.612339"
121 x="48.285038"
122 y="26.776302"
123 ry="0"
124 transform="rotate(19.88622)" />
125 <rect
126 ry="0"
127 y="-1.7701057"
128 x="48.285038"
129 height="23.612339"
130 width="23.964754"
131 id="rect4987"
132 style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.0940001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
133 transform="rotate(19.88622)" />
134 <rect
135 ry="0"
136 y="26.776302"
137 x="77.183228"
138 height="23.612339"
139 width="23.964754"
140 id="rect4991"
141 style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.0940001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
142 transform="rotate(19.88622)" />
143 <rect
144 style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.0940001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
145 id="rect4993"
146 width="23.964754"
147 height="23.612339"
148 x="77.183228"
149 y="-1.7701057"
150 ry="0"
151 transform="rotate(19.88622)" />
152 <rect
153 style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.0940001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
154 id="rect4995"
155 width="23.964754"
156 height="23.612339"
157 x="19.034573"
158 y="26.423878"
159 ry="0"
160 transform="rotate(19.88622)" />
161 <rect
162 ry="0"
163 y="-1.7701057"
164 x="19.386967"
165 height="23.612339"
166 width="23.964754"
167 id="rect4997"
168 style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.0940001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
169 transform="rotate(19.88622)" />
170 <rect
171 ry="0"
172 y="26.776302"
173 x="106.78786"
174 height="23.612339"
175 width="23.964754"
176 id="rect4999"
177 style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.0940001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
178 transform="rotate(19.88622)" />
179 <rect
180 style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.0940001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
181 id="rect5001"
182 width="23.964754"
183 height="23.612339"
184 x="106.78786"
185 y="-1.7701057"
186 ry="0"
187 transform="rotate(19.88622)" />
188 <rect
189 transform="rotate(19.88622)"
190 ry="0"
191 y="27.104183"
192 x="242.16132"
193 height="23.612339"
194 width="23.964754"
195 id="rect5003"
196 style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.0940001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
197 <rect
198 transform="rotate(19.88622)"
199 style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.0940001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
200 id="rect5005"
201 width="23.964754"
202 height="23.612339"
203 x="242.16132"
204 y="-1.4422622"
205 ry="0" />
206 <rect
207 transform="rotate(19.88622)"
208 style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.0940001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
209 id="rect5007"
210 width="23.964754"
211 height="23.612339"
212 x="271.05969"
213 y="27.104183"
214 ry="0" />
215 <rect
216 transform="rotate(19.88622)"
217 ry="0"
218 y="-1.4422622"
219 x="271.05969"
220 height="23.612339"
221 width="23.964754"
222 id="rect5009"
223 style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.0940001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
224 <rect
225 transform="rotate(19.88622)"
226 ry="0"
227 y="26.751751"
228 x="212.91084"
229 height="23.612339"
230 width="23.964754"
231 id="rect5011"
232 style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.0940001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
233 <rect
234 transform="rotate(19.88622)"
235 style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.0940001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
236 id="rect5013"
237 width="23.964754"
238 height="23.612339"
239 x="213.26323"
240 y="-1.4422622"
241 ry="0" />
242 <rect
243 transform="rotate(19.88622)"
244 style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.0940001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
245 id="rect5015"
246 width="23.964754"
247 height="23.612339"
248 x="300.66321"
249 y="27.104183"
250 ry="0" />
251 <rect
252 transform="rotate(19.88622)"
253 ry="0"
254 y="-1.4422622"
255 x="300.66321"
256 height="23.612339"
257 width="23.964754"
258 id="rect5017"
259 style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.0940001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
260 </svg>
@@ -1,130 +1,134
1 1 #pragma once
2 2 #include <Data/DataProviderParameters.h>
3 3 #include <Data/DataSeriesType.h>
4 4 #include <Data/IDataProvider.h>
5 5 #include <DataSource/DataSourceItem.h>
6 6 #include <DataSource/DataSourceItemAction.h>
7 7 #include <DataSource/datasources.h>
8 8
9 9 #include <QPair>
10 10 #include <SqpApplication.h>
11 11 // must be included last because of Python/Qt definition of slots
12 12 #include "numpy_wrappers.h"
13 13
14 14 struct Product
15 15 {
16 16 QString path;
17 17 std::vector<std::string> components;
18 18 QMap<QString, QString> metadata;
19 19 Product() = default;
20 20 explicit Product(const QString& path, const std::vector<std::string>& components,
21 21 const QMap<QString, QString>& metadata)
22 22 : path { path }, components { components }, metadata { metadata }
23 23 {
24 24 }
25 25 ~Product() = default;
26 26 };
27 27
28 28 template <typename T>
29 29 ScalarTimeSerie* make_scalar(T& t, T& y)
30 30 {
31 31 return new ScalarTimeSerie { std::move(t.data), std::move(y.data) };
32 32 }
33 33
34 34 template <typename T>
35 35 VectorTimeSerie* make_vector(T& t, T& y)
36 36 {
37 37 return new VectorTimeSerie { std::move(t.data), y.to_std_vect_vect() };
38 38 }
39 39
40 40 template <typename T>
41 41 MultiComponentTimeSerie* make_multi_comp(T& t, T& y)
42 42 {
43 43 auto y_size = y.flat_size();
44 44 auto t_size = t.flat_size();
45 45 if (t_size && (y_size % t_size) == 0)
46 46 {
47 47 return new MultiComponentTimeSerie { std::move(t.data), std::move(y.data),
48 48 { t_size, y_size / t_size } };
49 49 }
50 50 return nullptr;
51 51 }
52 52
53 53 template <typename T>
54 54 SpectrogramTimeSerie* make_spectro(T& t, T& y)
55 55 {
56 56 auto y_size = y.flat_size();
57 57 auto t_size = t.flat_size();
58 58 if (t_size && (y_size % t_size) == 0)
59 59 {
60 60 return new SpectrogramTimeSerie { std::move(t.data), std::move(y.data),
61 61 { t_size, y_size / t_size } };
62 62 }
63 63 return nullptr;
64 64 }
65 65
66 66
67 67 class PyDataProvider : public IDataProvider
68 68 {
69 69 public:
70 70 PyDataProvider()
71 71 {
72 72 auto& dataSources = sqpApp->dataSources();
73 73 dataSources.addProvider(this);
74 74 }
75 75
76 76 virtual ~PyDataProvider() {}
77 77
78 78 virtual QPair<QPair<NpArray, NpArray>, DataSeriesType> get_data(
79 79 const QMap<QString, QString>& key, double start_time, double stop_time)
80 80 {
81 81 (void)key, (void)start_time, (void)stop_time;
82 82 return {};
83 83 }
84 84
85 85 virtual TimeSeries::ITimeSerie* getData(const DataProviderParameters& parameters) override
86 86 {
87 87 TimeSeries::ITimeSerie* ts = nullptr;
88 88 if (parameters.m_Data.contains("name"))
89 89 {
90 90 QMap<QString, QString> metadata;
91 91 std::for_each(parameters.m_Data.constKeyValueBegin(),
92 92 parameters.m_Data.constKeyValueEnd(),
93 93 [&metadata](const auto& item) { metadata[item.first] = item.second.toString(); });
94 94 auto [data, type]
95 95 = get_data(metadata, parameters.m_Range.m_TStart, parameters.m_Range.m_TEnd);
96 96
97 97 auto& [t, y] = data;
98 98 switch (type)
99 99 {
100 100 case DataSeriesType::SCALAR:
101 101 ts = make_scalar(t, y);
102 102 break;
103 103 case DataSeriesType::VECTOR:
104 104 ts = make_vector(t, y);
105 105 break;
106 106 case DataSeriesType::MULTICOMPONENT:
107 107 ts = make_multi_comp(t, y);
108 108 break;
109 109 case DataSeriesType::SPECTROGRAM:
110 110 ts = make_spectro(t, y);
111 111 break;
112 112 default:
113 113 break;
114 114 }
115 115 }
116 116 return ts;
117 117 }
118 118
119 inline void set_icon(const QString& path, const QString& name)
120 {
121 sqpApp->dataSources().setIcon(path, name);
122 }
119 123
120 124 inline void register_products(const QVector<Product*>& products)
121 125 {
122 126 auto& dataSources = sqpApp->dataSources();
123 127 auto id = this->id();
124 128 auto data_source_name = this->name();
125 129 std::for_each(std::cbegin(products), std::cend(products),
126 130 [&id, &dataSources](const Product* product) {
127 131 dataSources.addDataSourceItem(id, product->path, product->metadata);
128 132 });
129 133 }
130 134 };
@@ -1,2 +1,3
1 1
2 2 configure_file(input:'TestPlugin.py', output:'TestPlugin.py', copy:true)
3 configure_file(input:'SPWC-Amda.py', output:'SPWC-Amda.py', copy:true)
@@ -1,32 +1,33
1 1 <RCC>
2 2 <qresource prefix="/">
3 3 <file>icones/dataSourceComponent.png</file>
4 4 <file>icones/dataSourceNode.png</file>
5 5 <file>icones/dataSourceProduct.png</file>
6 6 <file>icones/dataSourceRoot.png</file>
7 7 <file>icones/delete.png</file>
8 8 <file>icones/down.png</file>
9 9 <file>icones/openInspector.png</file>
10 10 <file>icones/next.png</file>
11 11 <file>icones/plot.png</file>
12 12 <file>icones/previous.png</file>
13 13 <file>icones/unplot.png</file>
14 14 <file>icones/up.png</file>
15 15 <file>icones/time.png</file>
16 16 <file>icones/zoom.png</file>
17 17 <file>icones/rectangle.png</file>
18 18 <file>icones/drag.png</file>
19 19 <file>icones/cursor.png</file>
20 20 <file>icones/pointer.png</file>
21 21 <file>icones/catalogue.png</file>
22 22 <file>icones/add.png</file>
23 23 <file>icones/remove.png</file>
24 24 <file>icones/chart.png</file>
25 25 <file>icones/allEvents.png</file>
26 26 <file>icones/trash.png</file>
27 27 <file>icones/database.png</file>
28 28 <file>icones/save.png</file>
29 29 <file>icones/discard.png</file>
30 30 <file>icones/Simple_icon_time.svg</file>
31 <file>icones/satellite.svg</file>
31 32 </qresource>
32 33 </RCC>
@@ -1,42 +1,42
1 1 #include <DataSource/DataSourceWidget.h>
2 2
3 3 #include <ui_DataSourceWidget.h>
4 4
5 5 #include <DataSource/datasources.h>
6 6
7 7 #include <SqpApplication.h>
8 8
9 9
10 10 namespace
11 11 {
12 12
13 13 /// Number of columns displayed in the tree
14 14 const auto TREE_NB_COLUMNS = 1;
15 15
16 16 /// Header labels for the tree
17 17 const auto TREE_HEADER_LABELS = QStringList { QObject::tr("Name") };
18 18
19 19 } // namespace
20 20
21 21 DataSourceWidget::DataSourceWidget(QWidget* parent)
22 22 : QWidget { parent }
23 23 , ui { new Ui::DataSourceWidget }
24 24 {
25 25 ui->setupUi(this);
26 26 m_model_proxy.setSourceModel(&(sqpApp->dataSources()));
27 27 ui->treeView->setModel(&m_model_proxy);
28 28 ui->treeView->setDragEnabled(true);
29 29 m_model_proxy.setFilterRole(Qt::ToolTipRole);
30 30 m_model_proxy.setRecursiveFilteringEnabled(true);
31 31
32 32 // Connection to filter tree
33 33 connect(ui->filterLineEdit, &QLineEdit::textChanged, &m_model_proxy, static_cast<void (QSortFilterProxyModel::*)(const QString&)>(
34 34 &QSortFilterProxyModel::setFilterRegExp));
35
35 sqpApp->dataSources().addIcon("satellite",QVariant(QIcon(":/icones/satellite.svg")));
36 36 }
37 37
38 38 DataSourceWidget::~DataSourceWidget() noexcept
39 39 {
40 40 delete ui;
41 41 }
42 42
General Comments 0
You need to be logged in to leave comments. Login now