forked from mrkite/minutor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproperties.cpp
More file actions
54 lines (45 loc) · 1.42 KB
/
properties.cpp
File metadata and controls
54 lines (45 loc) · 1.42 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
/** Copyright 2014 Rian Shelley */
#include <QRegularExpression>
#include <QVector3D>
#include "./properties.h"
#include "./ui_properties.h"
Properties::Properties(QWidget *parent) : QDialog(parent),
ui(new Ui::Properties) {
ui->setupUi(this);
}
Properties::~Properties() {
delete ui;
}
void Properties::DisplayProperties(QVariant p) {
// get current property
QString propertyName;
QTreeWidgetItem* item = ui->propertyView->currentItem();
if (item) {
propertyName = item->data(0, Qt::DisplayRole).toString();
}
ui->propertyView->clear();
// only support QVariantMap or QVariantHash at this level
switch (p.type()) {
case QMetaType::QVariantMap:
treeCreator.ParseIterable(ui->propertyView->invisibleRootItem(), p.toMap());
break;
case QMetaType::QVariantHash:
treeCreator.ParseIterable(ui->propertyView->invisibleRootItem(), p.toHash());
break;
case QMetaType::QVariantList:
treeCreator.ParseList(ui->propertyView->invisibleRootItem(), p.toList());
break;
default:
qWarning("Trying to display scalar value as a property");
break;
}
// expand at least the first level
ui->propertyView->expandToDepth(0);
if (propertyName.size() != 0) {
// try to restore the path
QList<QTreeWidgetItem*> items =
ui->propertyView->findItems(propertyName, Qt::MatchRecursive);
if (items.size())
items.front()->setSelected(true);
}
}