-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpropertyeditor.cpp
More file actions
54 lines (50 loc) · 1.77 KB
/
Copy pathpropertyeditor.cpp
File metadata and controls
54 lines (50 loc) · 1.77 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
#include "propertyeditor.h"
#include <QVBoxLayout>
#include "collapsible.h"
#include "nodeproperties.h"
#include "mainctrl.h"
PropertyEditor::PropertyEditor(QWidget * parent): QScrollArea(parent),
m_mainCtrl(nullptr)
{
// setup the scroll area
setFrameShape(QFrame::NoFrame);
setWidgetResizable(true);
setMaximumWidth(Collapsible::getMaximumWidth() + 4);
// set up the view widget
QWidget *
viewWidget = new QWidget(this);
setWidget(viewWidget);
// ... and the layout of the view widget
m_layout = new QVBoxLayout(viewWidget);
m_layout->setContentsMargins(QMargins(4, 0, 0, 0));
m_layout->addStretch();
}
void PropertyEditor::showNodes(const QList < relarank::NodeHandle > &selection)
{
Q_ASSERT(m_mainCtrl);
// collect all collapsibles to remove
QVector < relarank::NodeHandle > removed;
for (QHash < relarank::NodeHandle, Collapsible * >::iterator i =
m_nodes.begin(); i != m_nodes.end(); ++i) {
if (!selection.contains(i.key())) {
m_layout->removeWidget(i.value());
removed.append(i.key());
}
}
// ... and remove them after the iteration has finished
for (relarank::NodeHandle node : removed) {
m_nodes.take(node)->deleteLater();
}
// then create the new collapsibles
for (relarank::NodeHandle node : selection) {
if (!m_nodes.contains(node)) {
Collapsible *collapsible = new Collapsible(this);
collapsible->
setWidget(new
NodeProperties(m_mainCtrl->getCtrlForHandle(node),
collapsible));
m_layout->insertWidget(0, collapsible); // insert the new Collapsible at the top
m_nodes.insert(node, collapsible);
}
}
}