QtMvvm  1.1.0
A mvvm oriented library for Qt, to create Projects for Widgets and Quick in parallel
NetworkExchangeView.qml
1 import QtQuick 2.10
2 import QtQuick.Controls 2.3
3 import QtQuick.Layouts 1.3
4 import de.skycoder42.QtDataSync 4.0
5 import de.skycoder42.QtMvvm.Core 1.1
6 import de.skycoder42.QtMvvm.Quick 1.1
9 
19 Page {
20  id: _networkExchangeView
21 
33  property NetworkExchangeViewModel viewModel: null
34 
35  header: ContrastToolBar {
36  ToolBarLabel {
37  id: _titleLabel
38  anchors.fill: parent
39  text: qsTr("Network Exchange")
40  }
41  }
42 
43  Pane {
44  anchors.fill: parent
45 
46  ColorHelper {
47  id: helper
48  }
49 
50  ColumnLayout {
51  id: _layout
52  anchors.fill: parent
53 
54  DecorLabel {
55  text: qsTr("Port:")
56  Layout.fillWidth: true
57  edit: _portEdit
58  }
59 
60  SpinBox {
61  id: _portEdit
62  Layout.fillWidth: true
63  editable: true
64  from: 0
65  to: 65535
66 
67  MvvmBinding {
68  viewModel: _networkExchangeView.viewModel
69  viewModelProperty: "port"
70  view: _portEdit
71  viewProperty: "value"
72  }
73  }
74 
75  DecorLabel {
76  text: qsTr("Name:")
77  Layout.fillWidth: true
78  edit: _nameEdit
79  }
80 
81  TextField {
82  id: _nameEdit
83  Layout.fillWidth: true
84 
85  MvvmBinding {
86  viewModel: _networkExchangeView.viewModel
87  viewModelProperty: "deviceName"
88  view: _nameEdit
89  viewProperty: "text"
90  }
91  }
92 
93  Rectangle {
94  Layout.fillWidth: true
95  Layout.minimumHeight: 1
96  Layout.maximumHeight: 1
97  color: helper.text
98  }
99 
100  Switch {
101  id: _exchangeSwitch
102  text: qsTr("Exchange active:")
103 
104  MvvmBinding {
105  viewModel: _networkExchangeView.viewModel
106  viewModelProperty: "active"
107  view: _exchangeSwitch
108  viewProperty: "checked"
109  }
110  }
111 
112  ScrollView {
113  id: _exchangeScrollView
114 
115  Layout.fillWidth: true
116  Layout.fillHeight: true
117  clip: true
118 
119  ListView {
120  id: _exchangeList
121 
122  model: viewModel.sortedModel
123  delegate: ItemDelegate {
124  width: _exchangeScrollView.width
125 
126  contentItem: ColumnLayout {
127  id: _delegateLayout
128  spacing: 8
129 
130  Label {
131  id: _nameLabel
132  Layout.fillWidth: true
133  text: name
134  }
135 
136  Label {
137  id: _addressLabel
138  font.pointSize: _nameLabel.font.pointSize * 0.8
139  Layout.fillWidth: true
140  Layout.leftMargin: 8
141  text: address
142  opacity: 0.75
143  }
144  }
145 
146  onClicked: viewModel.exportTo(index)
147  }
148  }
149  }
150  }
151  }
152 }
A QML class to create a local mvvm multiway binding.
The QML import for the QtMvvmDataSyncCore QML module.
An extension of the ToolBar for better appearance.
An extension of the Label for better appearance when used in FormLayouts.
Definition: DecorLabel.qml:16
The QML import for the QtMvvmCore QML module.
Definition: qqmlcoreapp.h:9
A helper class to get style-dependant colors.
Definition: ColorHelper.qml:17
An extension of the Label for better appearance when used in a toolbar.
The QML import for the QtMvvmQuick QML module.
Definition: ActionButton.qml:4
QObject viewModel
The object in the role of a viewmodel.
The QML import for the QtMvvmDataSyncQuick QML module.