AronTreeWidgetItem.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <QTreeWidget>
4
5
#include <
ArmarXCore/core/system/ImportExportComponent.h
>
6
7
#include <
ArmarXGui/libraries/ArmarXGuiBase/ArmarXComponentWidgetController.h
>
8
#include <
ArmarXGui/libraries/ArmarXGuiBase/ArmarXGuiPlugin.h
>
9
10
#include <
RobotAPI/libraries/aron/core/type/variant/Variant.h
>
11
12
#include "
Data.h
"
13
14
namespace
armarx::skills::gui
15
{
16
// Internal derived QtTreeWidgetItem class. Contains additional information to compare its data agains aron types.
17
// It contains 3 columns: Key ; Value ; Type
18
// The key can only be edited if the parent object is a dict
19
class
AronTreeWidgetItem
:
public
QObject,
public
QTreeWidgetItem
20
{
21
Q_OBJECT
22
public
:
23
AronTreeWidgetItem
(
bool
editKey,
bool
editVal, QString key,
aron::type::VariantPtr
type);
24
25
using
QTreeWidgetItem::QTreeWidgetItem;
26
27
static
AronTreeWidgetItem
*
DynamicCast
(QTreeWidgetItem*);
28
static
AronTreeWidgetItem
*
DynamicCastAndCheck
(QTreeWidgetItem*);
29
30
aron::type::VariantPtr
aronType
;
31
// if editing the first column should be allowed
32
const
bool
col0Editable
=
false
;
33
// if editing the second column should be allowed
34
const
bool
col1Editable
=
false
;
35
36
bool
isValueErrorneous
();
37
// marks the gui in a specific color. Also stores if there is currently an error.
38
// the only way to reset the color back to normal is with resetError() (error is sticky)
39
void
setValueErrorState
(
bool
isErrorSource,
bool
isTransitiveError);
40
void
setKeyErrorState
(
bool
hasError);
41
// reset error storage that influences coloring for this and all children
42
void
resetError
();
43
44
// Checks if the children of a dict are unique
45
// should not be called on other types! (does nothing then)
46
void
checkKeyValidityOfChildren
();
47
48
// main logic on changes. Gets called from the onTreeWidgetItemChanged() slot in AronTreeWidgetController.
49
// (This class cannot directly consume this signal, at least I did not find a nice way...)
50
void
onUserChange
(
int
changedColumn);
51
52
private
:
53
// because the editable keyword counts for all columns, it is possible to TAB into uneditable keys.
54
// We do not want those to change, so just change them back once they finished editing.
55
void
preventIllegalKeyChange();
56
57
bool
itemValueError =
false
;
58
bool
transitiveValueError =
false
;
59
bool
keyValueError =
false
;
60
// hacky storage of previous key value for items that usually should not be editable.
61
// Problem: Dict-keys are editable, one can tab from that to any other value field and edit it.
62
// Fix: Once the change is commited, the AronTreeWidgetController notices the change and checks if it was allowed.
63
QString unchangeableKey =
""
;
64
};
65
}
// namespace armarx::skills::gui
armarx::aron::type::VariantPtr
std::shared_ptr< Variant > VariantPtr
Definition:
forward_declarations.h:11
armarx::skills::gui::AronTreeWidgetItem::col0Editable
const bool col0Editable
Definition:
AronTreeWidgetItem.h:32
armarx::skills::gui::AronTreeWidgetItem::checkKeyValidityOfChildren
void checkKeyValidityOfChildren()
Definition:
AronTreeWidgetItem.cpp:90
armarx::skills::gui::AronTreeWidgetItem::setKeyErrorState
void setKeyErrorState(bool hasError)
Definition:
AronTreeWidgetItem.cpp:64
armarx::skills::gui::AronTreeWidgetItem::col1Editable
const bool col1Editable
Definition:
AronTreeWidgetItem.h:34
armarx::skills::gui::AronTreeWidgetItem::onUserChange
void onUserChange(int changedColumn)
Definition:
AronTreeWidgetItem.cpp:150
armarx::skills::gui::AronTreeWidgetItem::setValueErrorState
void setValueErrorState(bool isErrorSource, bool isTransitiveError)
Definition:
AronTreeWidgetItem.cpp:39
armarx::skills::gui::AronTreeWidgetItem::resetError
void resetError()
Definition:
AronTreeWidgetItem.cpp:76
armarx::skills::gui::AronTreeWidgetItem::aronType
aron::type::VariantPtr aronType
Definition:
AronTreeWidgetItem.h:30
armarx::skills::gui::AronTreeWidgetItem::AronTreeWidgetItem
AronTreeWidgetItem(bool editKey, bool editVal, QString key, aron::type::VariantPtr type)
Definition:
AronTreeWidgetItem.cpp:186
armarx::skills::gui::AronTreeWidgetItem::DynamicCast
static AronTreeWidgetItem * DynamicCast(QTreeWidgetItem *)
Definition:
AronTreeWidgetItem.cpp:15
ArmarXGuiPlugin.h
Variant.h
ArmarXComponentWidgetController.h
armarx::skills::gui
Definition:
PeriodicUpdateWidget.cpp:11
Data.h
armarx::skills::gui::AronTreeWidgetItem::isValueErrorneous
bool isValueErrorneous()
Definition:
AronTreeWidgetItem.cpp:33
armarx::skills::gui::AronTreeWidgetItem
Definition:
AronTreeWidgetItem.h:19
armarx::skills::gui::AronTreeWidgetItem::DynamicCastAndCheck
static AronTreeWidgetItem * DynamicCastAndCheck(QTreeWidgetItem *)
Definition:
AronTreeWidgetItem.cpp:21
ImportExportComponent.h
RobotAPI
libraries
skills_gui
aron_tree_widget
AronTreeWidgetItem.h
Generated on Sat Oct 12 2024 09:14:07 for armarx_documentation by
1.8.17