hdt 3.2.0 → 3.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/deps/hdt-it/.cproject +42 -0
  2. package/deps/hdt-it/.project +27 -0
  3. package/deps/hdt-it/Camera.cpp +249 -0
  4. package/deps/hdt-it/Camera.h +77 -0
  5. package/deps/hdt-it/Color.cpp +157 -0
  6. package/deps/hdt-it/Color.h +49 -0
  7. package/deps/hdt-it/Info.plist +58 -0
  8. package/deps/hdt-it/LICENSE +280 -0
  9. package/deps/hdt-it/README.md +73 -0
  10. package/deps/hdt-it/StopWatch.cpp +170 -0
  11. package/deps/hdt-it/StopWatch.hpp +61 -0
  12. package/deps/hdt-it/abouthdt.cpp +14 -0
  13. package/deps/hdt-it/abouthdt.hpp +22 -0
  14. package/deps/hdt-it/abouthdt.ui +173 -0
  15. package/deps/hdt-it/colors.hpp +29 -0
  16. package/deps/hdt-it/constants.h +39 -0
  17. package/deps/hdt-it/createdmg.sh +72 -0
  18. package/deps/hdt-it/dictionarysuggestions.cpp +186 -0
  19. package/deps/hdt-it/dictionarysuggestions.hpp +39 -0
  20. package/deps/hdt-it/doc/hdtit.png +0 -0
  21. package/deps/hdt-it/doc/manual.html +88 -0
  22. package/deps/hdt-it/doc/matrix.png +0 -0
  23. package/deps/hdt-it/editreset.png +0 -0
  24. package/deps/hdt-it/hdt-it.pro +135 -0
  25. package/deps/hdt-it/hdt-it_es.qm +0 -0
  26. package/deps/hdt-it/hdt-it_es.ts +906 -0
  27. package/deps/hdt-it/hdtcachedinfo.cpp +155 -0
  28. package/deps/hdt-it/hdtcachedinfo.hpp +38 -0
  29. package/deps/hdt-it/hdtcontroller.cpp +369 -0
  30. package/deps/hdt-it/hdtcontroller.hpp +103 -0
  31. package/deps/hdt-it/hdtico.icns +0 -0
  32. package/deps/hdt-it/hdtico.rc +1 -0
  33. package/deps/hdt-it/hdtit.cpp +400 -0
  34. package/deps/hdt-it/hdtit.hpp +78 -0
  35. package/deps/hdt-it/hdtit.ui +875 -0
  36. package/deps/hdt-it/hdtoperation.cpp +284 -0
  37. package/deps/hdt-it/hdtoperation.hpp +71 -0
  38. package/deps/hdt-it/hdtresources.qrc +7 -0
  39. package/deps/hdt-it/hdtspecform.cpp +180 -0
  40. package/deps/hdt-it/hdtspecform.hpp +38 -0
  41. package/deps/hdt-it/hdtspecform.ui +361 -0
  42. package/deps/hdt-it/hdtsummarygenerator.cpp +109 -0
  43. package/deps/hdt-it/hdtsummarygenerator.hpp +15 -0
  44. package/deps/hdt-it/hdtwinico.ico +0 -0
  45. package/deps/hdt-it/hdtwinico2.ico +0 -0
  46. package/deps/hdt-it/headermodel.cpp +174 -0
  47. package/deps/hdt-it/headermodel.hpp +38 -0
  48. package/deps/hdt-it/loading.gif +0 -0
  49. package/deps/hdt-it/logo-hdt.png +0 -0
  50. package/deps/hdt-it/logo-hdt2.png +0 -0
  51. package/deps/hdt-it/main.cpp +39 -0
  52. package/deps/hdt-it/matrixviewwidget.cpp +501 -0
  53. package/deps/hdt-it/matrixviewwidget.hpp +81 -0
  54. package/deps/hdt-it/myapplication.cpp +45 -0
  55. package/deps/hdt-it/myapplication.hpp +24 -0
  56. package/deps/hdt-it/predicatestatus.cpp +97 -0
  57. package/deps/hdt-it/predicatestatus.hpp +39 -0
  58. package/deps/hdt-it/qclearlineedit.cpp +48 -0
  59. package/deps/hdt-it/qclearlineedit.hpp +30 -0
  60. package/deps/hdt-it/regexmodel.cpp +132 -0
  61. package/deps/hdt-it/regexmodel.hpp +37 -0
  62. package/deps/hdt-it/resultcounter.cpp +47 -0
  63. package/deps/hdt-it/resultcounter.hpp +30 -0
  64. package/deps/hdt-it/searchresultsmodel.cpp +179 -0
  65. package/deps/hdt-it/searchresultsmodel.hpp +39 -0
  66. package/deps/hdt-it/sparqlform.cpp +27 -0
  67. package/deps/hdt-it/sparqlform.hpp +28 -0
  68. package/deps/hdt-it/sparqlform.ui +112 -0
  69. package/deps/hdt-it/sparqlmodel.cpp +155 -0
  70. package/deps/hdt-it/sparqlmodel.hpp +32 -0
  71. package/deps/hdt-it/stringutils.cpp +48 -0
  72. package/deps/hdt-it/stringutils.hpp +18 -0
  73. package/deps/hdt-it/triplecomponentmodel.cpp +146 -0
  74. package/deps/hdt-it/triplecomponentmodel.hpp +33 -0
  75. package/deps/libcds/Doxyfile +307 -0
  76. package/deps/libcds/tutorial/tutorial.pdf +0 -0
  77. package/deps/libhdt/.cproject +304 -0
  78. package/deps/libhdt/Doxyfile +1630 -0
  79. package/package.json +7 -1
  80. package/.eslintrc +0 -178
  81. package/.github/workflows/ci.yml +0 -73
  82. package/.gitmodules +0 -4
  83. package/.idea/codeStyles/Project.xml +0 -38
  84. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  85. package/.idea/hdt.iml +0 -12
  86. package/.idea/inspectionProfiles/Project_Default.xml +0 -7
  87. package/.idea/jsLinters/jshint.xml +0 -16
  88. package/.idea/modules.xml +0 -8
  89. package/.idea/vcs.xml +0 -7
  90. package/.jshintignore +0 -1
  91. package/.jshintrc +0 -10
  92. package/perf/run.js +0 -43
  93. package/replace-in-file.json +0 -5
@@ -0,0 +1,361 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <ui version="4.0">
3
+ <class>HDTSpecForm</class>
4
+ <widget class="QDialog" name="HDTSpecForm">
5
+ <property name="windowModality">
6
+ <enum>Qt::WindowModal</enum>
7
+ </property>
8
+ <property name="enabled">
9
+ <bool>true</bool>
10
+ </property>
11
+ <property name="geometry">
12
+ <rect>
13
+ <x>0</x>
14
+ <y>0</y>
15
+ <width>470</width>
16
+ <height>533</height>
17
+ </rect>
18
+ </property>
19
+ <property name="windowTitle">
20
+ <string>Import RDF File to HDT</string>
21
+ </property>
22
+ <layout class="QVBoxLayout" name="verticalLayout_2">
23
+ <item>
24
+ <layout class="QVBoxLayout" name="verticalLayout">
25
+ <item>
26
+ <widget class="QGroupBox" name="groupBox">
27
+ <property name="title">
28
+ <string>InputRDF file name or URI</string>
29
+ </property>
30
+ <layout class="QHBoxLayout" name="horizontalLayout">
31
+ <item>
32
+ <widget class="QLineEdit" name="rdfInputFile">
33
+ <property name="text">
34
+ <string/>
35
+ </property>
36
+ </widget>
37
+ </item>
38
+ <item>
39
+ <widget class="QPushButton" name="inputFileButton">
40
+ <property name="text">
41
+ <string>...</string>
42
+ </property>
43
+ </widget>
44
+ </item>
45
+ <item>
46
+ <widget class="QComboBox" name="rdfInputCombo">
47
+ <item>
48
+ <property name="text">
49
+ <string>NTRIPLES</string>
50
+ </property>
51
+ </item>
52
+ <item>
53
+ <property name="text">
54
+ <string>N3</string>
55
+ </property>
56
+ </item>
57
+ <item>
58
+ <property name="text">
59
+ <string>TURTLE</string>
60
+ </property>
61
+ </item>
62
+ <item>
63
+ <property name="text">
64
+ <string>RDF-XML</string>
65
+ </property>
66
+ </item>
67
+ </widget>
68
+ </item>
69
+ </layout>
70
+ </widget>
71
+ </item>
72
+ <item>
73
+ <widget class="QGroupBox" name="baseUriGroup">
74
+ <property name="title">
75
+ <string>Base URI for the dataset</string>
76
+ </property>
77
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
78
+ <item>
79
+ <widget class="QLineEdit" name="baseUriText">
80
+ <property name="text">
81
+ <string/>
82
+ </property>
83
+ </widget>
84
+ </item>
85
+ </layout>
86
+ </widget>
87
+ </item>
88
+ <item>
89
+ <widget class="QGroupBox" name="headerBox">
90
+ <property name="title">
91
+ <string>Header</string>
92
+ </property>
93
+ <layout class="QGridLayout" name="gridLayout_3">
94
+ <item row="1" column="1">
95
+ <widget class="QComboBox" name="headerTypeCombo">
96
+ <item>
97
+ <property name="text">
98
+ <string>Plain</string>
99
+ </property>
100
+ </item>
101
+ </widget>
102
+ </item>
103
+ <item row="1" column="0">
104
+ <widget class="QLabel" name="headerTypeLabel">
105
+ <property name="text">
106
+ <string>Type:</string>
107
+ </property>
108
+ </widget>
109
+ </item>
110
+ </layout>
111
+ </widget>
112
+ </item>
113
+ <item>
114
+ <widget class="QGroupBox" name="dictionaryBox">
115
+ <property name="title">
116
+ <string>Dictionary</string>
117
+ </property>
118
+ <layout class="QGridLayout" name="gridLayout_2">
119
+ <item row="0" column="0">
120
+ <widget class="QLabel" name="labelDictionaryType">
121
+ <property name="sizePolicy">
122
+ <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
123
+ <horstretch>0</horstretch>
124
+ <verstretch>0</verstretch>
125
+ </sizepolicy>
126
+ </property>
127
+ <property name="text">
128
+ <string>Type:</string>
129
+ </property>
130
+ </widget>
131
+ </item>
132
+ <item row="0" column="1">
133
+ <widget class="QComboBox" name="dictionaryTypeCombo">
134
+ <property name="sizePolicy">
135
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
136
+ <horstretch>0</horstretch>
137
+ <verstretch>0</verstretch>
138
+ </sizepolicy>
139
+ </property>
140
+ <item>
141
+ <property name="text">
142
+ <string>Plain Front Coding</string>
143
+ </property>
144
+ </item>
145
+ <item>
146
+ <property name="text">
147
+ <string>Plain</string>
148
+ </property>
149
+ </item>
150
+ </widget>
151
+ </item>
152
+ </layout>
153
+ </widget>
154
+ </item>
155
+ <item>
156
+ <widget class="QGroupBox" name="triplesBox">
157
+ <property name="title">
158
+ <string>Triples</string>
159
+ </property>
160
+ <layout class="QGridLayout" name="gridLayout">
161
+ <item row="0" column="0">
162
+ <widget class="QLabel" name="triplesTypeLabel">
163
+ <property name="text">
164
+ <string>Type:</string>
165
+ </property>
166
+ </widget>
167
+ </item>
168
+ <item row="0" column="1">
169
+ <widget class="QComboBox" name="triplesTypeCombo">
170
+ <item>
171
+ <property name="text">
172
+ <string>BitmapTriples</string>
173
+ </property>
174
+ </item>
175
+ <item>
176
+ <property name="text">
177
+ <string>TriplesList</string>
178
+ </property>
179
+ </item>
180
+ <item>
181
+ <property name="text">
182
+ <string>PlainTriples</string>
183
+ </property>
184
+ </item>
185
+ </widget>
186
+ </item>
187
+ <item row="1" column="1">
188
+ <widget class="QComboBox" name="triplesOrderCombo">
189
+ <item>
190
+ <property name="text">
191
+ <string>SPO</string>
192
+ </property>
193
+ </item>
194
+ <item>
195
+ <property name="text">
196
+ <string>SOP</string>
197
+ </property>
198
+ </item>
199
+ <item>
200
+ <property name="text">
201
+ <string>PSO</string>
202
+ </property>
203
+ </item>
204
+ <item>
205
+ <property name="text">
206
+ <string>POS</string>
207
+ </property>
208
+ </item>
209
+ <item>
210
+ <property name="text">
211
+ <string>OSP</string>
212
+ </property>
213
+ </item>
214
+ <item>
215
+ <property name="text">
216
+ <string>OPS</string>
217
+ </property>
218
+ </item>
219
+ </widget>
220
+ </item>
221
+ <item row="1" column="0">
222
+ <widget class="QLabel" name="triplesOrderLabel">
223
+ <property name="text">
224
+ <string>Order</string>
225
+ </property>
226
+ </widget>
227
+ </item>
228
+ <item row="2" column="1">
229
+ <widget class="QComboBox" name="streamXcombo">
230
+ <property name="enabled">
231
+ <bool>false</bool>
232
+ </property>
233
+ <item>
234
+ <property name="text">
235
+ <string>LogStream</string>
236
+ </property>
237
+ </item>
238
+ <item>
239
+ <property name="text">
240
+ <string>IntegerStream</string>
241
+ </property>
242
+ </item>
243
+ <item>
244
+ <property name="text">
245
+ <string>HuffmanStream</string>
246
+ </property>
247
+ </item>
248
+ </widget>
249
+ </item>
250
+ <item row="3" column="1">
251
+ <widget class="QComboBox" name="streamYcombo">
252
+ <item>
253
+ <property name="text">
254
+ <string>LogStream</string>
255
+ </property>
256
+ </item>
257
+ <item>
258
+ <property name="text">
259
+ <string>IntegerStream</string>
260
+ </property>
261
+ </item>
262
+ <item>
263
+ <property name="text">
264
+ <string>HuffmanStream</string>
265
+ </property>
266
+ </item>
267
+ </widget>
268
+ </item>
269
+ <item row="4" column="1">
270
+ <widget class="QComboBox" name="streamZcombo">
271
+ <item>
272
+ <property name="text">
273
+ <string>LogStream</string>
274
+ </property>
275
+ </item>
276
+ <item>
277
+ <property name="text">
278
+ <string>IntegerStream</string>
279
+ </property>
280
+ </item>
281
+ <item>
282
+ <property name="text">
283
+ <string>HuffmanStream</string>
284
+ </property>
285
+ </item>
286
+ </widget>
287
+ </item>
288
+ <item row="2" column="0">
289
+ <widget class="QLabel" name="streamXlabel">
290
+ <property name="text">
291
+ <string>StreamX:</string>
292
+ </property>
293
+ </widget>
294
+ </item>
295
+ <item row="3" column="0">
296
+ <widget class="QLabel" name="streamYlabel">
297
+ <property name="text">
298
+ <string>StreamY:</string>
299
+ </property>
300
+ </widget>
301
+ </item>
302
+ <item row="4" column="0">
303
+ <widget class="QLabel" name="streamZlabel">
304
+ <property name="text">
305
+ <string>StreamZ:</string>
306
+ </property>
307
+ </widget>
308
+ </item>
309
+ </layout>
310
+ </widget>
311
+ </item>
312
+ </layout>
313
+ </item>
314
+ <item>
315
+ <widget class="QDialogButtonBox" name="buttonBox">
316
+ <property name="orientation">
317
+ <enum>Qt::Horizontal</enum>
318
+ </property>
319
+ <property name="standardButtons">
320
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
321
+ </property>
322
+ </widget>
323
+ </item>
324
+ </layout>
325
+ </widget>
326
+ <resources/>
327
+ <connections>
328
+ <connection>
329
+ <sender>buttonBox</sender>
330
+ <signal>accepted()</signal>
331
+ <receiver>HDTSpecForm</receiver>
332
+ <slot>accept()</slot>
333
+ <hints>
334
+ <hint type="sourcelabel">
335
+ <x>248</x>
336
+ <y>254</y>
337
+ </hint>
338
+ <hint type="destinationlabel">
339
+ <x>157</x>
340
+ <y>274</y>
341
+ </hint>
342
+ </hints>
343
+ </connection>
344
+ <connection>
345
+ <sender>buttonBox</sender>
346
+ <signal>rejected()</signal>
347
+ <receiver>HDTSpecForm</receiver>
348
+ <slot>reject()</slot>
349
+ <hints>
350
+ <hint type="sourcelabel">
351
+ <x>316</x>
352
+ <y>260</y>
353
+ </hint>
354
+ <hint type="destinationlabel">
355
+ <x>286</x>
356
+ <y>274</y>
357
+ </hint>
358
+ </hints>
359
+ </connection>
360
+ </connections>
361
+ </ui>
@@ -0,0 +1,109 @@
1
+ #include "hdtsummarygenerator.hpp"
2
+
3
+ #include <hdtcontroller.hpp>
4
+
5
+ #include <HDTVocabulary.hpp>
6
+ #include <HDTEnums.hpp>
7
+ #include <QLocale>
8
+ #include <QDateTime>
9
+
10
+ #include "stringutils.hpp"
11
+
12
+ QString HDTSummaryGenerator::getSummary(HDTController *hdtController)
13
+ {
14
+ hdt::HDT *hdt = hdtController->getHDT();
15
+ if(!hdt) {
16
+ return tr("No open file.");
17
+ }
18
+
19
+ hdt::Header *head = hdt->getHeader();
20
+ hdt::Dictionary *dict = hdt->getDictionary();
21
+ hdt::Triples *triples = hdt->getTriples();
22
+ QString output;
23
+ QLocale loc = QLocale::system();
24
+
25
+ output.append(tr("<h3>Dataset:</h3>"));
26
+ QString fileName = hdtController->getFileName();
27
+ output.append(tr("<b>File name</b>: <small>"));
28
+ output.append(fileName);
29
+ output.append("</small><br/>");
30
+
31
+ try {
32
+ QString baseUri = stringutils::escapeHTML(head->getSubject(hdt::HDTVocabulary::RDF_TYPE.c_str(), hdt::HDTVocabulary::HDT_DATASET.c_str()).c_str());
33
+ output.append(tr("<b>Dataset base URI</b>: <small>"));
34
+ output.append(baseUri);
35
+ output.append("</small><br/>");
36
+ } catch (const char *e) {
37
+ }
38
+
39
+ quint64 originalSize=0;
40
+ quint64 hdtSize=0;
41
+ try {
42
+ originalSize = head->getPropertyLong("_:statistics", hdt::HDTVocabulary::ORIGINAL_SIZE.c_str());
43
+ output.append(tr("<b>Original Size</b>: "));
44
+ output.append(stringutils::sizeHuman(originalSize));
45
+ output.append("<br/>");
46
+ } catch (const char *e) {
47
+ }
48
+
49
+ try {
50
+ hdtSize = head->getPropertyLong("_:statistics", hdt::HDTVocabulary::HDT_SIZE.c_str());
51
+ output.append(tr("<b>HDT Size</b>: "));
52
+ output.append(stringutils::sizeHuman(hdtSize));
53
+ output.append("<br/>");
54
+ } catch (const char *e) {
55
+ }
56
+
57
+ if(originalSize!=0 && hdtSize!=0) {
58
+ output.append(tr("<b>Compression ratio</b>: "));
59
+ output.append(QString::number(hdtSize*100.0/originalSize, 'f', 2));
60
+ output.append("%<br/>");
61
+ }
62
+
63
+ try {
64
+ string issued = head->getProperty("_:publicationInformation", hdt::HDTVocabulary::DUBLIN_CORE_ISSUED.c_str());
65
+ QString qissued =QString(issued.c_str()).replace("\"", "");
66
+ int idx;
67
+ if((idx = qissued.lastIndexOf("+"))!=-1) {
68
+ qissued = qissued.left(idx);
69
+ }
70
+ QDateTime date = QDateTime::fromString(qissued, Qt::ISODate);
71
+ if(date.isValid()) {
72
+ output.append(QString(tr("<b>Issued</b>: %1<br/>")).arg(loc.toString(date.date())));
73
+ }
74
+ } catch (const char *e) {
75
+ }
76
+
77
+
78
+ #if 0
79
+ output.append(tr("<h3>Header:</h3>"));
80
+ output.append(QString(tr("<b>Number of triples</b>: %1<br/>").arg(loc.toString(head->getNumberOfElements())));
81
+ #endif
82
+
83
+ output.append(tr("<h3>Dictionary:</h3>"));
84
+ output.append(QString(tr("<b>Number of entries</b>: %1<br/>")).arg(loc.toString((quint64)dict->getNumberOfElements())));
85
+ output.append(QString(tr("<b>Different subjects</b>: %1<br/>")).arg(loc.toString(dict->getNsubjects())));
86
+ output.append(QString(tr("<b>Different predicates</b>: %1<br/>")).arg(loc.toString(dict->getNpredicates())));
87
+ output.append(QString(tr("<b>Different objects</b>: %1<br/>")).arg(loc.toString(dict->getNobjects())));
88
+ output.append(QString(tr("<b>Shared area</b>: %1<br/>")).arg(loc.toString(dict->getNshared())));
89
+ output.append(QString(tr("<b>Type</b>: <small>%1</small><br/>")).arg(stringutils::escapeHTML(dict->getType().c_str())));
90
+
91
+ output.append(tr("<b>Dictionary Size</b>: "));
92
+ output.append(stringutils::sizeHuman(dict->size()));
93
+ output.append(tr("<br/>"));
94
+
95
+ output.append(tr("<h3>Triples:</h3>"));
96
+ output.append(QString(tr("<b>Number of triples</b>: %1<br/>")).arg(loc.toString((quint64)triples->getNumberOfElements())));
97
+
98
+ output.append(QString(tr("<b>Type</b>: <small>%1</small><br/>")).arg(stringutils::escapeHTML(triples->getType().c_str())));
99
+
100
+ output.append(tr("<b>Triples Size</b>: "));
101
+ output.append(stringutils::sizeHuman(triples->size()));
102
+ output.append(tr("<br/>"));
103
+
104
+ output.append(tr("<b>Triples Order</b>: "));
105
+ output.append(hdt::getOrderStr(triples->getOrder()));
106
+ output.append("<br/>");
107
+
108
+ return output;
109
+ }
@@ -0,0 +1,15 @@
1
+ #ifndef HDTSUMMARYGENERATOR_HPP
2
+ #define HDTSUMMARYGENERATOR_HPP
3
+
4
+ #include <QObject>
5
+ #include <QString>
6
+ #include "hdtcontroller.hpp"
7
+
8
+ class HDTSummaryGenerator : public QObject
9
+ {
10
+ Q_OBJECT
11
+ public:
12
+ static QString getSummary(HDTController *hdtController);
13
+ };
14
+
15
+ #endif // HDTSUMMARYGENERATOR_HPP
Binary file
Binary file
@@ -0,0 +1,174 @@
1
+ #include "headermodel.hpp"
2
+ #include <QFont>
3
+
4
+ HeaderModel::HeaderModel(HDTController *view) : hdtController(view), triples(NULL)
5
+ {
6
+ this->updateDatasetChanged();
7
+ }
8
+
9
+ HeaderModel::~HeaderModel()
10
+ {
11
+ if(triples!=NULL) {
12
+ delete triples;
13
+ triples = NULL;
14
+ }
15
+ }
16
+
17
+ int HeaderModel::rowCount(const QModelIndex &parent) const
18
+ {
19
+ if(hdtController->hasHDT()) {
20
+ return (int)hdtController->getHDT()->getHeader()->getNumberOfElements();
21
+ }
22
+ return 0;
23
+ }
24
+
25
+ int HeaderModel::columnCount(const QModelIndex &parent) const
26
+ {
27
+ return 3;
28
+ }
29
+
30
+ QVariant HeaderModel::data(const QModelIndex &index, int role) const
31
+ {
32
+ if(triples == NULL) {
33
+ return QVariant();
34
+ }
35
+
36
+ switch(role) {
37
+ case Qt::EditRole:
38
+ case Qt::ToolTipRole:
39
+ case Qt::DisplayRole:
40
+ {
41
+ //cout << "HeaderModel.data " << index.row() << "," << index.column() << endl;
42
+ // Compiler complains that by calling findTriple we are modifying internal
43
+ // state, which is illegal due to this function being const. But we need to
44
+ // modify the currentIndex and currentTriple, so we can avoid it.
45
+ HeaderModel *noConstThis = const_cast<HeaderModel *>(this);
46
+ noConstThis->findTriple(index.row());
47
+
48
+ switch(index.column()) {
49
+ case 0:
50
+ return currentTriple->getSubject().c_str();
51
+ case 1:
52
+ return currentTriple->getPredicate().c_str();
53
+ case 2:
54
+ return currentTriple->getObject().c_str();
55
+ }
56
+
57
+ return QVariant();
58
+ }
59
+ case Qt::FontRole:
60
+ {
61
+ static QFont font;
62
+ font.setPointSize(10);
63
+ return font;
64
+ }
65
+
66
+ }
67
+ return QVariant();
68
+ }
69
+
70
+
71
+ QVariant HeaderModel::headerData(int section, Qt::Orientation orientation, int role) const
72
+ {
73
+
74
+ switch(role) {
75
+ case Qt::DisplayRole:
76
+ {
77
+ if(orientation == Qt::Horizontal) {
78
+ switch(section) {
79
+ case 0:
80
+ return tr("Subject");
81
+ case 1:
82
+ return tr("Predicate");
83
+ case 2:
84
+ return tr("Object");
85
+ }
86
+ } else {
87
+ return QString::number(section+1);
88
+ }
89
+ break;
90
+ }
91
+ }
92
+
93
+ return QVariant();
94
+ }
95
+
96
+ void HeaderModel::updateDatasetChanged() {
97
+ if(triples!=NULL) {
98
+ delete triples;
99
+ triples = NULL;
100
+ }
101
+
102
+ if(hdtController->hasHDT()) {
103
+ triples = hdtController->getHDT()->getHeader()->search("","","");
104
+ if(triples->hasNext()) {
105
+ currentTriple = triples->next();
106
+ }
107
+ } else {
108
+ triples = NULL;
109
+ currentTriple = NULL;
110
+ }
111
+ currentIndex = 0;
112
+
113
+ emit layoutChanged();
114
+ }
115
+
116
+
117
+ void HeaderModel::findTriple(unsigned int index)
118
+ {
119
+ if(triples == NULL) {
120
+ return;
121
+ }
122
+
123
+ if(currentIndex > index) {
124
+ currentIndex = 0;
125
+ triples->goToStart();
126
+ if(triples->hasNext()) {
127
+ currentTriple = triples->next();
128
+ }
129
+ }
130
+
131
+ while(currentIndex < index && triples->hasNext()) {
132
+ currentTriple = triples->next();
133
+ currentIndex++;
134
+ }
135
+
136
+ //cout << "Access " << currentIndex << " => " << *currentTriple << endl;
137
+ }
138
+
139
+ Qt::ItemFlags HeaderModel::flags(const QModelIndex &index) const
140
+ {
141
+ return Qt::ItemIsEnabled | Qt::ItemIsSelectable /*| Qt::ItemIsEditable*/;
142
+ }
143
+
144
+ bool HeaderModel::setData(const QModelIndex &index, const QVariant &value, int role)
145
+ {
146
+ if (index.isValid() && role == Qt::EditRole) {
147
+
148
+ HeaderModel *noConstThis = const_cast<HeaderModel *>(this);
149
+ noConstThis->findTriple(index.row());
150
+
151
+ string str(value.toString().toLatin1());
152
+ switch(index.column()) {
153
+ case 0:
154
+ currentTriple->setSubject(str);
155
+ break;
156
+ case 1:
157
+ currentTriple->setPredicate(str);
158
+ break;
159
+ case 2:
160
+ currentTriple->setObject(str);
161
+ break;
162
+ }
163
+
164
+ emit dataChanged(index, index);
165
+ return true;
166
+ }
167
+ return false;
168
+ }
169
+
170
+
171
+
172
+
173
+
174
+
@@ -0,0 +1,38 @@
1
+ #ifndef HEADERMODEL_HPP
2
+ #define HEADERMODEL_HPP
3
+
4
+ #include <QAbstractTableModel>
5
+
6
+ #include <SingleTriple.hpp>
7
+
8
+ #include "hdtcontroller.hpp"
9
+
10
+ class HDTController;
11
+
12
+ class HeaderModel : public QAbstractTableModel {
13
+ Q_OBJECT
14
+ private:
15
+ HDTController *hdtController;
16
+ hdt::IteratorTripleString *triples;
17
+ hdt::TripleString *currentTriple;
18
+ unsigned int currentIndex;
19
+
20
+ void findTriple(unsigned int index);
21
+
22
+ public:
23
+ HeaderModel(HDTController *view);
24
+ ~HeaderModel();
25
+
26
+ int rowCount(const QModelIndex &parent = QModelIndex()) const ;
27
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
28
+ Qt::ItemFlags flags(const QModelIndex &index) const;
29
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const;
30
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
31
+ bool setData(const QModelIndex & index, const QVariant & value, int role);
32
+
33
+ void updateDatasetChanged();
34
+ signals:
35
+ };
36
+
37
+
38
+ #endif // HEADERMODEL_HPP