AronTreeWidgetItem.h
Go to the documentation of this file.
1#pragma once
2
3#include <QTreeWidget>
4
6
9
11
12#include "Data.h"
13
14namespace armarx
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
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)
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
AronTreeWidgetItem(bool editKey, bool editVal, QString key, aron::type::VariantPtr type)
aron::type::VariantPtr aronType
void setValueErrorState(bool isErrorSource, bool isTransitiveError)
void onUserChange(int changedColumn)
void setKeyErrorState(bool hasError)
static AronTreeWidgetItem * DynamicCast(QTreeWidgetItem *)
static AronTreeWidgetItem * DynamicCastAndCheck(QTreeWidgetItem *)
std::shared_ptr< Variant > VariantPtr
This file offers overloads of toIce() and fromIce() functions for STL container types.