-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvqbschemaform.cpp
More file actions
131 lines (106 loc) · 3.16 KB
/
Copy pathvqbschemaform.cpp
File metadata and controls
131 lines (106 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#include "vqbschemaform.h"
#include "vqbmainwindow.h"
#include "ui_vqbform.h"
#include "sparqlhighlighter.h"
#include "subjecttree.h"
#include "constraint.h"
#include <QMainWindow>
#include <QLayout>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QGridLayout>
#include <QComboBox>
#include <QLineEdit>
#include <QTextEdit>
#include <QPushButton>
#include <QListWidget>
#include <QListWidgetItem>
#include <QProcess>
#include <kdebug.h>
#include <kstandardaction.h>
#include <kaction.h>
#include <KPushButton>
#include <KIcon>
#include <KIconLoader>
#include <KStandardGuiItem>
class VqbSchemaForm::Private
{
public:
QPushButton *btnAdd;
QVBoxLayout *topLayout;//holds the query trees
QStringList queryTreeStrings;
QList<SubjectTree*> queryTrees;
};
/************* CONSTR, DESTR, INIT ****************/
VqbSchemaForm::VqbSchemaForm(VqbMainWindow *parent)
: VqbForm(parent), d(new Private)
{
init();
}
void VqbSchemaForm::init()
{
/* Layouts and visual elements */
d->btnAdd = new QPushButton("New Query Tree"); // add button
d->btnAdd->setStatusTip("Adds a new query tree");
d->btnAdd->setBaseSize(100, 50);
connect(d->btnAdd, SIGNAL(clicked()), this, SLOT(addQueryTree()));
QHBoxLayout *qhbl = new QHBoxLayout; //button's layout
qhbl->setDirection(QBoxLayout::RightToLeft);
qhbl->addWidget(d->btnAdd, 1);
qhbl->addStretch(10);
QVBoxLayout* layout = new QVBoxLayout();
setLayout(layout);
d->topLayout = new QVBoxLayout; //the top QueryTree stack
layout->addLayout(d->topLayout, 1);
layout->addLayout(qhbl, 1); //the bottom layout (holding the button)
layout->addStretch(5);
addQueryTree();
}
VqbSchemaForm::~VqbSchemaForm()
{
delete d;
}
/************* PUBLIC SLOTS ****************/
void VqbSchemaForm::queryTreeChanged(int index, QString queryTreeString)
{
//kDebug() << "Subject tree " << index << " has changed:" << queryTreeString;
if (index < d->queryTreeStrings.count()) {
d->queryTreeStrings[index] = queryTreeString;
}
emitQueryChanged();
}
void VqbSchemaForm::queryTreeDeleted(int treeNumber)
{
int i;
for(i=treeNumber; i<d->queryTrees.size()-1; i++) {
d->queryTrees[i] = d->queryTrees[i+1];
d->queryTrees[i]->setTreeNumber(i);
d->queryTreeStrings[i] = d->queryTreeStrings[i+1];
}
kDebug() << i << ", " << d->queryTrees.size();
if (i < d->queryTrees.size()) {
d->queryTrees.removeAt(i);
d->queryTreeStrings.removeAt(i);
}
emitQueryChanged();
}
void VqbSchemaForm::addQueryTree()
{
if (d->topLayout) {
SubjectTree *qt = new SubjectTree(d->queryTrees.count(), this);
d->topLayout->addWidget(qt);
d->queryTrees.append(qt);
d->queryTreeStrings.append("");
connect(qt, SIGNAL(queryTreeChanged(int,QString)), this, SLOT(queryTreeChanged(int, QString)));
connect(qt, SIGNAL(queryTreeDeleted(int)), this, SLOT(queryTreeDeleted(int)));
}
}
void VqbSchemaForm::emitQueryChanged()
{
QString query;
foreach(QString s, d->queryTreeStrings) {
query.append(s);
}
emit queryChanged(query);
}
#include "vqbschemaform.moc"