Commit 651458ec authored by Thomas BOUTROUE's avatar Thomas BOUTROUE

Make table delegates lighter (no more timer inside)

parent af29121c
......@@ -4,7 +4,7 @@ import QtQmlTricks.SmartDataModels 2.0;
import QtCAN.CanTestBench 2.0;
MouseArea {
id: delegatePhyValTable;
id: base;
height: implicitHeight;
visible: shouldBeVisible;
hoverEnabled: true;
......@@ -12,15 +12,12 @@ MouseArea {
ExtraAnchors.horizontalFill: parent;
onCurrentChanged: {
if (current) {
timerEnsureVisible.restart ();
editValPhy.forceActiveFocus ();
needVisible (base);
}
}
Component.onCompleted: {
Shared.manager.setDelegateForPath (phyVal.path, delegatePhyValTable);
if (current) {
timerEnsureVisible.restart ();
}
Shared.manager.setDelegateForPath (phyVal.path, base);
}
property PhysicalValue phyVal : null;
......@@ -33,13 +30,6 @@ MouseArea {
signal needVisible (Item item);
signal valueEdited (real value);
Timer {
id: timerEnsureVisible;
repeat: false;
running: false;
interval: 10;
onTriggered: { needVisible (base); }
}
Rectangle {
color: Style.colorSecondary;
opacity: 0.15;
......@@ -51,7 +41,7 @@ MouseArea {
}
Rectangle {
color: Style.opacify (Style.colorHighlight, 0.35);
visible: delegatePhyValTable.containsMouse;
visible: base.containsMouse;
anchors.fill: parent;
}
StretchRowContainer {
......@@ -62,13 +52,13 @@ MouseArea {
ExtraAnchors.horizontalFill: parent;
TextLabel {
text: delegatePhyValTable.phyVal.uid;
text: base.phyVal.uid;
anchors.verticalCenter: parent.verticalCenter;
Rectangle {
z: -1;
color: Style.colorHighlight;
visible: delegatePhyValTable.current;
visible: base.current;
anchors {
fill: parent;
margins: -Style.spacingSmall;
......@@ -81,24 +71,24 @@ MouseArea {
anchors.verticalCenter: parent.verticalCenter;
}
TextLabel {
text: delegatePhyValTable.phyVal.val.toFixed (2);
visible: !delegatePhyValTable.editable;
text: base.phyVal.val.toFixed (2);
visible: !base.editable;
anchors.verticalCenter: parent.verticalCenter;
}
NumberBox {
id: editValPhy;
padding: Style.spacingSmall;
visible: delegatePhyValTable.editable;
visible: base.editable;
decimals: 2;
minValue: delegatePhyValTable.phyVal.min;
maxValue: delegatePhyValTable.phyVal.max;
minValue: base.phyVal.min;
maxValue: base.phyVal.max;
anchors.verticalCenter: parent.verticalCenter;
onEdited: {
delegatePhyValTable.valueEdited (value);
value = delegatePhyValTable.phyVal.val;
base.valueEdited (value);
value = base.phyVal.val;
}
Binding on value { value: delegatePhyValTable.phyVal.val; }
Binding on value { value: base.phyVal.val; }
}
}
}
......@@ -23,6 +23,7 @@ Window {
highlightIO = null;
highlightSensor = null;
highlightActuator = null;
highlightPhyVal = null;
}
else {
if (network.hideSensorsPanel) {
......@@ -66,24 +67,34 @@ Window {
if (highlightIO !== null) {
tabsView.currentTab = tabElecNodes;
areaNodes.contentZoom = 2.0; // zoom in before
areaNodes.ensureVisible (Shared.manager.dict.getDelegate (highlightIO.path));
singleShot (50, function () {
areaNodes.ensureVisible (Shared.manager.dict.getDelegate (highlightIO.path));
});
}
}
onHighlightSensorChanged: {
if (highlightSensor !== null) {
scrollerSensors.ensureVisible (Shared.manager.dict.getDelegate (highlightSensor.path));
panelSensors.expand ();
singleShot (50, function () {
scrollerSensors.ensureVisible (Shared.manager.dict.getDelegate (highlightSensor.path));
});
}
}
onHighlightActuatorChanged: {
if (highlightActuator !== null) {
scrollerActuators.ensureVisible (Shared.manager.dict.getDelegate (highlightActuator.path));
panelActuators.expand ();
singleShot (50, function () {
scrollerActuators.ensureVisible (Shared.manager.dict.getDelegate (highlightActuator.path));
});
}
}
onHighlightPhyValChanged: {
if (highlightPhyVal !== null) {
tabsView.currentTab = tabDatasheet;
comboTable.selectByKey (ObjectFamily.VALUE);
scrollerTables.ensureVisible (Shared.manager.dict.getDelegate (highlightPhyVal.path));
singleShot (50, function () {
scrollerTables.ensureVisible (Shared.manager.dict.getDelegate (highlightPhyVal.path));
});
}
}
onVisibleChanged: {
......@@ -121,6 +132,12 @@ Window {
var tmp = (intToFloat (val, decimals)).toFixed (decimals);
return (unit ? tmp + " " + unit : tmp);
}
function singleShot (delay, callback) {
compoSingleShot.createObject (window, {
"interval" : delay,
"callback" : callback,
});
}
WindowIconHelper {
iconPath: ":/vcan_testbench_logo.svg";
......@@ -128,6 +145,20 @@ Window {
QtObject {
property Window subWinCodeEditor : WindowCodeEditor { id: windowEditor; }
}
Component {
id: compoSingleShot;
Timer {
repeat: false;
running: true;
onTriggered: {
callback ();
destroy ();
}
property var callback : function () { }
}
}
Component { id: compoSymbolPlug; SymbolPlug { } }
Component { id: compoDelegateAin; DelegateControlAin { } }
Component { id: compoDelegateAout; DelegateControlAout { } }
......@@ -876,12 +907,6 @@ Window {
default: return ({});
}
}
Connections {
target: creator.instance;
ignoreUnknownSignals: true;
onNeedVisible: { scrollerTables.ensureVisible (item); }
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment