hdt 3.1.1 → 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.
- package/README.md +31 -0
- package/deps/hdt-it/.cproject +42 -0
- package/deps/hdt-it/.project +27 -0
- package/deps/hdt-it/Camera.cpp +249 -0
- package/deps/hdt-it/Camera.h +77 -0
- package/deps/hdt-it/Color.cpp +157 -0
- package/deps/hdt-it/Color.h +49 -0
- package/deps/hdt-it/Info.plist +58 -0
- package/deps/hdt-it/StopWatch.cpp +170 -0
- package/deps/hdt-it/StopWatch.hpp +61 -0
- package/deps/hdt-it/abouthdt.cpp +14 -0
- package/deps/hdt-it/abouthdt.hpp +22 -0
- package/deps/hdt-it/abouthdt.ui +173 -0
- package/deps/hdt-it/colors.hpp +29 -0
- package/deps/hdt-it/constants.h +39 -0
- package/deps/hdt-it/createdmg.sh +72 -0
- package/deps/hdt-it/dictionarysuggestions.cpp +186 -0
- package/deps/hdt-it/dictionarysuggestions.hpp +39 -0
- package/deps/hdt-it/doc/hdtit.png +0 -0
- package/deps/hdt-it/doc/manual.html +88 -0
- package/deps/hdt-it/doc/matrix.png +0 -0
- package/deps/hdt-it/editreset.png +0 -0
- package/deps/hdt-it/hdt-it.pro +135 -0
- package/deps/hdt-it/hdt-it_es.qm +0 -0
- package/deps/hdt-it/hdt-it_es.ts +906 -0
- package/deps/hdt-it/hdtcachedinfo.cpp +155 -0
- package/deps/hdt-it/hdtcachedinfo.hpp +38 -0
- package/deps/hdt-it/hdtcontroller.cpp +369 -0
- package/deps/hdt-it/hdtcontroller.hpp +103 -0
- package/deps/hdt-it/hdtico.icns +0 -0
- package/deps/hdt-it/hdtico.rc +1 -0
- package/deps/hdt-it/hdtit.cpp +400 -0
- package/deps/hdt-it/hdtit.hpp +78 -0
- package/deps/hdt-it/hdtit.ui +875 -0
- package/deps/hdt-it/hdtoperation.cpp +284 -0
- package/deps/hdt-it/hdtoperation.hpp +71 -0
- package/deps/hdt-it/hdtresources.qrc +7 -0
- package/deps/hdt-it/hdtspecform.cpp +180 -0
- package/deps/hdt-it/hdtspecform.hpp +38 -0
- package/deps/hdt-it/hdtspecform.ui +361 -0
- package/deps/hdt-it/hdtsummarygenerator.cpp +109 -0
- package/deps/hdt-it/hdtsummarygenerator.hpp +15 -0
- package/deps/hdt-it/hdtwinico.ico +0 -0
- package/deps/hdt-it/hdtwinico2.ico +0 -0
- package/deps/hdt-it/headermodel.cpp +174 -0
- package/deps/hdt-it/headermodel.hpp +38 -0
- package/deps/hdt-it/loading.gif +0 -0
- package/deps/hdt-it/logo-hdt.png +0 -0
- package/deps/hdt-it/logo-hdt2.png +0 -0
- package/deps/hdt-it/main.cpp +39 -0
- package/deps/hdt-it/matrixviewwidget.cpp +501 -0
- package/deps/hdt-it/matrixviewwidget.hpp +81 -0
- package/deps/hdt-it/myapplication.cpp +45 -0
- package/deps/hdt-it/myapplication.hpp +24 -0
- package/deps/hdt-it/predicatestatus.cpp +97 -0
- package/deps/hdt-it/predicatestatus.hpp +39 -0
- package/deps/hdt-it/qclearlineedit.cpp +48 -0
- package/deps/hdt-it/qclearlineedit.hpp +30 -0
- package/deps/hdt-it/regexmodel.cpp +132 -0
- package/deps/hdt-it/regexmodel.hpp +37 -0
- package/deps/hdt-it/resultcounter.cpp +47 -0
- package/deps/hdt-it/resultcounter.hpp +30 -0
- package/deps/hdt-it/searchresultsmodel.cpp +179 -0
- package/deps/hdt-it/searchresultsmodel.hpp +39 -0
- package/deps/hdt-it/sparqlform.cpp +27 -0
- package/deps/hdt-it/sparqlform.hpp +28 -0
- package/deps/hdt-it/sparqlform.ui +112 -0
- package/deps/hdt-it/sparqlmodel.cpp +155 -0
- package/deps/hdt-it/sparqlmodel.hpp +32 -0
- package/deps/hdt-it/stringutils.cpp +48 -0
- package/deps/hdt-it/stringutils.hpp +18 -0
- package/deps/hdt-it/triplecomponentmodel.cpp +146 -0
- package/deps/hdt-it/triplecomponentmodel.hpp +33 -0
- package/deps/libcds/Doxyfile +307 -0
- package/deps/libcds/tutorial/tutorial.pdf +0 -0
- package/deps/libhdt/.cproject +304 -0
- package/deps/libhdt/Doxyfile +1630 -0
- package/deps/libhdt/src/util/StopWatch.cpp +1 -1
- package/lib/HdtDocument.cc +140 -0
- package/lib/HdtDocument.h +4 -0
- package/lib/hdt.js +79 -0
- package/package.json +12 -3
- package/.eslintrc +0 -178
- package/.github/workflows/ci.yml +0 -72
- package/.gitmodules +0 -4
- package/.jshintignore +0 -1
- package/.jshintrc +0 -10
- package/deps/libcds/README +0 -12
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#ifndef JOINFORM_HPP
|
|
2
|
+
#define JOINFORM_HPP
|
|
3
|
+
|
|
4
|
+
#include <QMainWindow>
|
|
5
|
+
|
|
6
|
+
#include "sparqlmodel.hpp"
|
|
7
|
+
|
|
8
|
+
namespace Ui {
|
|
9
|
+
class SparqlForm;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
class SparqlForm : public QMainWindow
|
|
13
|
+
{
|
|
14
|
+
Q_OBJECT
|
|
15
|
+
|
|
16
|
+
public:
|
|
17
|
+
explicit SparqlForm(QWidget *parent = 0);
|
|
18
|
+
~SparqlForm();
|
|
19
|
+
|
|
20
|
+
private slots:
|
|
21
|
+
void on_pushButton_clicked();
|
|
22
|
+
|
|
23
|
+
private:
|
|
24
|
+
Ui::SparqlForm *ui;
|
|
25
|
+
SparqlModel *sparqlModel;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
#endif // JOINFORM_HPP
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<ui version="4.0">
|
|
3
|
+
<class>SparqlForm</class>
|
|
4
|
+
<widget class="QMainWindow" name="SparqlForm">
|
|
5
|
+
<property name="geometry">
|
|
6
|
+
<rect>
|
|
7
|
+
<x>0</x>
|
|
8
|
+
<y>0</y>
|
|
9
|
+
<width>603</width>
|
|
10
|
+
<height>664</height>
|
|
11
|
+
</rect>
|
|
12
|
+
</property>
|
|
13
|
+
<property name="windowTitle">
|
|
14
|
+
<string>SPARQL Search</string>
|
|
15
|
+
</property>
|
|
16
|
+
<widget class="QWidget" name="centralwidget">
|
|
17
|
+
<property name="sizePolicy">
|
|
18
|
+
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
|
19
|
+
<horstretch>0</horstretch>
|
|
20
|
+
<verstretch>0</verstretch>
|
|
21
|
+
</sizepolicy>
|
|
22
|
+
</property>
|
|
23
|
+
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
|
24
|
+
<item>
|
|
25
|
+
<widget class="QSplitter" name="splitter_2">
|
|
26
|
+
<property name="orientation">
|
|
27
|
+
<enum>Qt::Vertical</enum>
|
|
28
|
+
</property>
|
|
29
|
+
<widget class="QGroupBox" name="groupBox">
|
|
30
|
+
<property name="sizePolicy">
|
|
31
|
+
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
|
32
|
+
<horstretch>0</horstretch>
|
|
33
|
+
<verstretch>0</verstretch>
|
|
34
|
+
</sizepolicy>
|
|
35
|
+
</property>
|
|
36
|
+
<property name="title">
|
|
37
|
+
<string>SPARQL</string>
|
|
38
|
+
</property>
|
|
39
|
+
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
40
|
+
<item>
|
|
41
|
+
<widget class="QTextEdit" name="sparqlTextEdit">
|
|
42
|
+
<property name="sizePolicy">
|
|
43
|
+
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
|
44
|
+
<horstretch>0</horstretch>
|
|
45
|
+
<verstretch>1</verstretch>
|
|
46
|
+
</sizepolicy>
|
|
47
|
+
</property>
|
|
48
|
+
<property name="html">
|
|
49
|
+
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
|
50
|
+
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
|
51
|
+
p, li { white-space: pre-wrap; }
|
|
52
|
+
</style></head><body style=" font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;">
|
|
53
|
+
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">SELECT ?x ?y ?z WHERE {?x ?y ?z . }</p></body></html></string>
|
|
54
|
+
</property>
|
|
55
|
+
</widget>
|
|
56
|
+
</item>
|
|
57
|
+
<item>
|
|
58
|
+
<widget class="QPushButton" name="pushButton">
|
|
59
|
+
<property name="text">
|
|
60
|
+
<string>Search</string>
|
|
61
|
+
</property>
|
|
62
|
+
</widget>
|
|
63
|
+
</item>
|
|
64
|
+
</layout>
|
|
65
|
+
</widget>
|
|
66
|
+
<widget class="QSplitter" name="splitter">
|
|
67
|
+
<property name="orientation">
|
|
68
|
+
<enum>Qt::Horizontal</enum>
|
|
69
|
+
</property>
|
|
70
|
+
<widget class="QTableView" name="sparqlResultTable">
|
|
71
|
+
<property name="sizePolicy">
|
|
72
|
+
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
|
73
|
+
<horstretch>0</horstretch>
|
|
74
|
+
<verstretch>4</verstretch>
|
|
75
|
+
</sizepolicy>
|
|
76
|
+
</property>
|
|
77
|
+
<property name="alternatingRowColors">
|
|
78
|
+
<bool>true</bool>
|
|
79
|
+
</property>
|
|
80
|
+
<property name="textElideMode">
|
|
81
|
+
<enum>Qt::ElideMiddle</enum>
|
|
82
|
+
</property>
|
|
83
|
+
<attribute name="horizontalHeaderDefaultSectionSize">
|
|
84
|
+
<number>300</number>
|
|
85
|
+
</attribute>
|
|
86
|
+
<attribute name="horizontalHeaderMinimumSectionSize">
|
|
87
|
+
<number>50</number>
|
|
88
|
+
</attribute>
|
|
89
|
+
<attribute name="verticalHeaderDefaultSectionSize">
|
|
90
|
+
<number>20</number>
|
|
91
|
+
</attribute>
|
|
92
|
+
</widget>
|
|
93
|
+
</widget>
|
|
94
|
+
</widget>
|
|
95
|
+
</item>
|
|
96
|
+
</layout>
|
|
97
|
+
</widget>
|
|
98
|
+
<widget class="QMenuBar" name="menubar">
|
|
99
|
+
<property name="geometry">
|
|
100
|
+
<rect>
|
|
101
|
+
<x>0</x>
|
|
102
|
+
<y>0</y>
|
|
103
|
+
<width>603</width>
|
|
104
|
+
<height>22</height>
|
|
105
|
+
</rect>
|
|
106
|
+
</property>
|
|
107
|
+
</widget>
|
|
108
|
+
<widget class="QStatusBar" name="statusbar"/>
|
|
109
|
+
</widget>
|
|
110
|
+
<resources/>
|
|
111
|
+
<connections/>
|
|
112
|
+
</ui>
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
#include "sparqlmodel.hpp"
|
|
2
|
+
#include <sstream>
|
|
3
|
+
|
|
4
|
+
#include <SingleTriple.hpp>
|
|
5
|
+
|
|
6
|
+
#include <QFont>
|
|
7
|
+
|
|
8
|
+
SparqlModel::SparqlModel(HDTController *controller) :
|
|
9
|
+
hdtController(controller),
|
|
10
|
+
binding(NULL),
|
|
11
|
+
currentIndex(0),
|
|
12
|
+
numresults(0)
|
|
13
|
+
{
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
void SparqlModel::find(unsigned int index) {
|
|
17
|
+
if(currentIndex>index) {
|
|
18
|
+
currentIndex=0;
|
|
19
|
+
binding->goToStart();
|
|
20
|
+
binding->findNext();
|
|
21
|
+
}
|
|
22
|
+
while(currentIndex<index) {
|
|
23
|
+
if(binding->findNext()) {
|
|
24
|
+
currentIndex++;
|
|
25
|
+
} else {
|
|
26
|
+
numresults = currentIndex+1;
|
|
27
|
+
emit layoutChanged();
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
SparqlModel::~SparqlModel()
|
|
34
|
+
{
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
class SparqlQuery {
|
|
39
|
+
public:
|
|
40
|
+
set<string> vars;
|
|
41
|
+
vector<hdt::TripleString> patterns;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
SparqlQuery parseSparql(string query) {
|
|
45
|
+
struct SparqlQuery output;
|
|
46
|
+
string word;
|
|
47
|
+
unsigned int phase = 0;
|
|
48
|
+
vector<string> pattern;
|
|
49
|
+
|
|
50
|
+
stringstream in(query, ios::in);
|
|
51
|
+
|
|
52
|
+
while(in >> word) {
|
|
53
|
+
cout << word << endl;
|
|
54
|
+
if(word.size()==0) {
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
if(phase==0) {
|
|
58
|
+
if(word.at(0)=='?') {
|
|
59
|
+
output.vars.insert(word);
|
|
60
|
+
} else if(word=="WHERE") {
|
|
61
|
+
phase++;
|
|
62
|
+
}
|
|
63
|
+
} else {
|
|
64
|
+
if(word.at(0)=='.') {
|
|
65
|
+
if(pattern.size()!=3) {
|
|
66
|
+
throw "Pattern should have 3 components";
|
|
67
|
+
}
|
|
68
|
+
hdt::TripleString trip(pattern[0], pattern[1], pattern[2]);
|
|
69
|
+
output.patterns.push_back(trip);
|
|
70
|
+
pattern.clear();
|
|
71
|
+
} else {
|
|
72
|
+
if(word.at(0)=='{') {
|
|
73
|
+
|
|
74
|
+
} else if(word.at(0)!='.'){
|
|
75
|
+
cout << "**"<< word << "**" << endl;
|
|
76
|
+
pattern.push_back(word);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return output;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
void SparqlModel::setQuery(QString queryTxt)
|
|
85
|
+
{
|
|
86
|
+
throw "Not implemented";
|
|
87
|
+
#if 0
|
|
88
|
+
SparqlQuery query = parseSparql(string(queryTxt.toAscii()));
|
|
89
|
+
|
|
90
|
+
if(binding) {
|
|
91
|
+
delete binding;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
binding = hdtManager->getHDT()->searchJoin(query.patterns, query.vars);
|
|
95
|
+
binding->findNext();
|
|
96
|
+
numresults = binding->estimatedNumResults();
|
|
97
|
+
currentIndex = 0;
|
|
98
|
+
|
|
99
|
+
emit layoutChanged();
|
|
100
|
+
#endif
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
int SparqlModel::rowCount(const QModelIndex &parent) const {
|
|
104
|
+
return numresults;
|
|
105
|
+
}
|
|
106
|
+
int SparqlModel::columnCount(const QModelIndex &parent) const {
|
|
107
|
+
if(binding==NULL) {
|
|
108
|
+
return 0;
|
|
109
|
+
}
|
|
110
|
+
return binding->getNumVars();
|
|
111
|
+
}
|
|
112
|
+
QVariant SparqlModel::data(const QModelIndex &index, int role) const {
|
|
113
|
+
if(binding == NULL) {
|
|
114
|
+
return QVariant();
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
switch(role) {
|
|
118
|
+
case Qt::ToolTipRole:
|
|
119
|
+
case Qt::DisplayRole:
|
|
120
|
+
{
|
|
121
|
+
// Compiler complains that by calling findTriple we are modifying internal
|
|
122
|
+
// state, which is illegal due to this function being const. But we need to
|
|
123
|
+
// modify the currentIndex and currentTriple, so we can avoid it.
|
|
124
|
+
SparqlModel *noConstThis = const_cast<SparqlModel *>(this);
|
|
125
|
+
noConstThis->find(index.row());
|
|
126
|
+
|
|
127
|
+
return binding->getVar(index.column()).c_str();
|
|
128
|
+
}
|
|
129
|
+
case Qt::FontRole:
|
|
130
|
+
{
|
|
131
|
+
static QFont font;
|
|
132
|
+
font.setPointSize(10);
|
|
133
|
+
return font;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
}
|
|
137
|
+
return QVariant();
|
|
138
|
+
}
|
|
139
|
+
QVariant SparqlModel::headerData(int section, Qt::Orientation orientation, int role) const {
|
|
140
|
+
if(binding==NULL) {
|
|
141
|
+
return QVariant();
|
|
142
|
+
}
|
|
143
|
+
switch(role) {
|
|
144
|
+
case Qt::DisplayRole:
|
|
145
|
+
{
|
|
146
|
+
if(orientation == Qt::Horizontal) {
|
|
147
|
+
return binding->getVarName(section);
|
|
148
|
+
} else {
|
|
149
|
+
return QString::number(section+1);
|
|
150
|
+
}
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return QVariant();
|
|
155
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#ifndef JOINMODEL_HPP
|
|
2
|
+
#define JOINMODEL_HPP
|
|
3
|
+
|
|
4
|
+
#include <QAbstractTableModel>
|
|
5
|
+
|
|
6
|
+
#include <SingleTriple.hpp>
|
|
7
|
+
|
|
8
|
+
#include "hdtcontroller.hpp"
|
|
9
|
+
|
|
10
|
+
class SparqlModel : public QAbstractTableModel {
|
|
11
|
+
Q_OBJECT
|
|
12
|
+
private:
|
|
13
|
+
HDTController *hdtController;
|
|
14
|
+
|
|
15
|
+
hdt::VarBindingString *binding;
|
|
16
|
+
unsigned int currentIndex;
|
|
17
|
+
unsigned int numresults;
|
|
18
|
+
void find(unsigned int index);
|
|
19
|
+
public:
|
|
20
|
+
SparqlModel(HDTController *controller);
|
|
21
|
+
virtual ~SparqlModel();
|
|
22
|
+
|
|
23
|
+
void setQuery(QString query);
|
|
24
|
+
|
|
25
|
+
int rowCount(const QModelIndex &parent = QModelIndex()) const ;
|
|
26
|
+
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
|
27
|
+
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
|
28
|
+
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
|
29
|
+
signals:
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
#endif // JOINMODEL_HPP
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#include <QRegExp>
|
|
2
|
+
|
|
3
|
+
#include <StopWatch.hpp>
|
|
4
|
+
#include "stringutils.hpp"
|
|
5
|
+
|
|
6
|
+
QString stringutils::sizeHuman(unsigned long long size)
|
|
7
|
+
{
|
|
8
|
+
static const char *sizes[] = { "EB", "PB", "TB", "GB", "MB", "KB", "B" };
|
|
9
|
+
static const quint64 exbibytes = 1024ULL * 1024ULL * 1024ULL * 1024ULL * 1024ULL * 1024ULL;
|
|
10
|
+
|
|
11
|
+
quint64 multiplier = exbibytes;
|
|
12
|
+
|
|
13
|
+
if(size==0) {
|
|
14
|
+
return QString("0");
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
for (unsigned int i = 0; i < 7; i++, multiplier /= 1024)
|
|
18
|
+
{
|
|
19
|
+
if (size < multiplier) {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return QString("%1 %2")
|
|
24
|
+
.arg(QString::number((double)size / multiplier, 'f', 1))
|
|
25
|
+
.arg(sizes[i]);
|
|
26
|
+
}
|
|
27
|
+
return QString("0");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
QString stringutils::toQString(const char *str)
|
|
31
|
+
{
|
|
32
|
+
|
|
33
|
+
QString out = QString::fromUtf8(str);
|
|
34
|
+
|
|
35
|
+
return out;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
QString stringutils::escapeHTML(QString in)
|
|
39
|
+
{
|
|
40
|
+
return in.replace("<", "<").replace(">", ">");
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
void stringutils::cut(QString &in, int size)
|
|
44
|
+
{
|
|
45
|
+
if(in.length()>size) {
|
|
46
|
+
in = in.left(size)+"...";
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#ifndef STRINGUTILS_HPP
|
|
2
|
+
#define STRINGUTILS_HPP
|
|
3
|
+
|
|
4
|
+
#include <QString>
|
|
5
|
+
#include <string>
|
|
6
|
+
|
|
7
|
+
class stringutils
|
|
8
|
+
{
|
|
9
|
+
public:
|
|
10
|
+
static QString sizeHuman(unsigned long long size);
|
|
11
|
+
static QString toQString(const char *str);
|
|
12
|
+
static QString escapeHTML(QString in);
|
|
13
|
+
static void cut(QString &in, int size);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
#endif // STRINGUTILS_HPP
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
|
|
2
|
+
#include <QFont>
|
|
3
|
+
|
|
4
|
+
#include "triplecomponentmodel.hpp"
|
|
5
|
+
|
|
6
|
+
#include "stringutils.hpp"
|
|
7
|
+
|
|
8
|
+
TripleComponentModel::TripleComponentModel(HDTController *view, hdt::TripleComponentRole compRole) :
|
|
9
|
+
hdtController(view), tripleComponentRole(compRole)
|
|
10
|
+
{
|
|
11
|
+
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
int TripleComponentModel::rowCount(const QModelIndex &parent) const
|
|
15
|
+
{
|
|
16
|
+
size_t numResults = 0;
|
|
17
|
+
|
|
18
|
+
Q_UNUSED(parent);
|
|
19
|
+
if(hdtController->getHDT() != NULL) {
|
|
20
|
+
hdt::Dictionary *dict = hdtController->getHDT()->getDictionary();
|
|
21
|
+
switch(tripleComponentRole) {
|
|
22
|
+
case hdt::SUBJECT:
|
|
23
|
+
numResults = dict->getNsubjects();
|
|
24
|
+
break;
|
|
25
|
+
case hdt::PREDICATE:
|
|
26
|
+
numResults = dict->getNpredicates();
|
|
27
|
+
break;
|
|
28
|
+
case hdt::OBJECT:
|
|
29
|
+
numResults = dict->getNobjects();
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// FIXME: QTableView crashes when returning more than 100 Million rows :(
|
|
35
|
+
return (int)(numResults > 100000000 ? 100000000 : numResults);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
int TripleComponentModel::columnCount(const QModelIndex &parent) const
|
|
39
|
+
{
|
|
40
|
+
return 1;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
QVariant TripleComponentModel::data(const QModelIndex &index, int role) const
|
|
44
|
+
{
|
|
45
|
+
if(!hdtController->hasHDT()) {
|
|
46
|
+
return QVariant();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
switch(role) {
|
|
50
|
+
case Qt::ToolTipRole:
|
|
51
|
+
case Qt::DisplayRole:
|
|
52
|
+
{
|
|
53
|
+
//cerr << "Data: " << index.row() << " role: " << role << " type: " << tripleComponentRole << endl;
|
|
54
|
+
hdt::Dictionary *d = hdtController->getHDT()->getDictionary();
|
|
55
|
+
try {
|
|
56
|
+
return stringutils::toQString(d->idToString(index.row()+1, tripleComponentRole).c_str());
|
|
57
|
+
} catch (char *e) {
|
|
58
|
+
cerr << "Error accessing dictionary: " << e << endl;
|
|
59
|
+
} catch (const char *e) {
|
|
60
|
+
cerr << "Error accessing dictionary: " << e << endl;
|
|
61
|
+
}
|
|
62
|
+
return QVariant();
|
|
63
|
+
}
|
|
64
|
+
case Qt::FontRole:
|
|
65
|
+
{
|
|
66
|
+
QFont font;
|
|
67
|
+
font.setPointSize(10);
|
|
68
|
+
return font;
|
|
69
|
+
}
|
|
70
|
+
case Qt::CheckStateRole:
|
|
71
|
+
if(tripleComponentRole==hdt::PREDICATE) {
|
|
72
|
+
return hdtController->getPredicateStatus()->isPredicateActive(index.row()) ? Qt::Checked : Qt::Unchecked;
|
|
73
|
+
}
|
|
74
|
+
break;
|
|
75
|
+
case Qt::DecorationRole:
|
|
76
|
+
if(tripleComponentRole==hdt::PREDICATE) {
|
|
77
|
+
HDTCachedInfo *info = hdtController->getHDTCachedInfo();
|
|
78
|
+
Color *color = info->getPredicateColor(index.row());
|
|
79
|
+
return color->asQColor();
|
|
80
|
+
}
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
return QVariant();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
bool TripleComponentModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
|
87
|
+
{
|
|
88
|
+
if(hdtController->getHDT() == NULL) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
switch(role) {
|
|
93
|
+
case Qt::CheckStateRole:
|
|
94
|
+
if(tripleComponentRole==hdt::PREDICATE) {
|
|
95
|
+
hdtController->getPredicateStatus()->setPredicateActive(index.row(), value.toBool());
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
QVariant TripleComponentModel::headerData(int section, Qt::Orientation orientation, int role) const
|
|
102
|
+
{
|
|
103
|
+
|
|
104
|
+
switch(role) {
|
|
105
|
+
case Qt::DisplayRole:
|
|
106
|
+
{
|
|
107
|
+
if(orientation == Qt::Horizontal) {
|
|
108
|
+
switch(tripleComponentRole) {
|
|
109
|
+
case hdt::SUBJECT:
|
|
110
|
+
return tr("Subject");
|
|
111
|
+
case hdt::PREDICATE:
|
|
112
|
+
return tr("Predicate");
|
|
113
|
+
case hdt::OBJECT:
|
|
114
|
+
return tr("Object");
|
|
115
|
+
}
|
|
116
|
+
} else {
|
|
117
|
+
return QString::number(section+1);
|
|
118
|
+
}
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return QVariant();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
Qt::ItemFlags TripleComponentModel::flags(const QModelIndex &index) const
|
|
127
|
+
{
|
|
128
|
+
Q_UNUSED(index);
|
|
129
|
+
if(tripleComponentRole == hdt::PREDICATE) {
|
|
130
|
+
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable;
|
|
131
|
+
} else {
|
|
132
|
+
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
void TripleComponentModel::itemsChanged(unsigned int ini, unsigned int fin)
|
|
137
|
+
{
|
|
138
|
+
QModelIndex first = createIndex(ini, 1);
|
|
139
|
+
QModelIndex last = createIndex(fin, 1);
|
|
140
|
+
emit dataChanged(first, last);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
void TripleComponentModel::notifyLayoutChanged()
|
|
144
|
+
{
|
|
145
|
+
emit layoutChanged();
|
|
146
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#ifndef TRIPLECOMPONENTMODEL_HPP
|
|
2
|
+
#define TRIPLECOMPONENTMODEL_HPP
|
|
3
|
+
|
|
4
|
+
#include <QAbstractTableModel>
|
|
5
|
+
|
|
6
|
+
#include <HDTEnums.hpp>
|
|
7
|
+
|
|
8
|
+
#include "hdtcontroller.hpp"
|
|
9
|
+
|
|
10
|
+
class HDTController;
|
|
11
|
+
|
|
12
|
+
class TripleComponentModel : public QAbstractTableModel {
|
|
13
|
+
Q_OBJECT
|
|
14
|
+
private:
|
|
15
|
+
HDTController *hdtController;
|
|
16
|
+
hdt::TripleComponentRole tripleComponentRole;
|
|
17
|
+
public:
|
|
18
|
+
TripleComponentModel(HDTController *view, hdt::TripleComponentRole compRole);
|
|
19
|
+
|
|
20
|
+
int rowCount(const QModelIndex &parent = QModelIndex()) const ;
|
|
21
|
+
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
|
22
|
+
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
|
23
|
+
bool setData(const QModelIndex & index, const QVariant & value, int role);
|
|
24
|
+
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
|
25
|
+
Qt::ItemFlags flags(const QModelIndex &index) const;
|
|
26
|
+
|
|
27
|
+
public slots:
|
|
28
|
+
void itemsChanged(unsigned int ini, unsigned int fin);
|
|
29
|
+
void notifyLayoutChanged();
|
|
30
|
+
signals:
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
#endif // TRIPLECOMPONENTMODEL_HPP
|