QtMvvm  1.0.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.Controls.Material 2.3
4 import QtQuick.Controls.Universal 2.3
5 import QtQuick.Layouts 1.3
6 import de.skycoder42.QtDataSync 4.0
7 import de.skycoder42.QtMvvm.Core 1.0
8 import de.skycoder42.QtMvvm.Quick 1.0
10 
20 Page {
21  id: _networkExchangeView
22 
34  property NetworkExchangeViewModel viewModel: null
35 
36  header: ContrastToolBar {
37  ToolBarLabel {
38  id: _titleLabel
39  anchors.fill: parent
40  text: qsTr("Network Exchange")
41  }
42  }
43 
44  Pane {
45  anchors.fill: parent
46  ColumnLayout {
47  id: _layout
48  anchors.fill: parent
49 
50  Label {
51  text: qsTr("Port:")
52  Layout.fillWidth: true
53  color: _portEdit.focus ? _nameEdit.selectionColor : palette.text
54  opacity: _portEdit.focus ? 1 : 0.5
55  }
56 
57  SpinBox {
58  id: _portEdit
59  Layout.fillWidth: true
60  editable: true
61  from: 0
62  to: 65535
63 
64  MvvmBinding {
65  viewModel: _networkExchangeView.viewModel
66  viewModelProperty: "port"
67  view: _portEdit
68  viewProperty: "value"
69  }
70  }
71 
72  Label {
73  text: qsTr("Name:")
74  Layout.fillWidth: true
75  color: _nameEdit.focus ? _nameEdit.selectionColor : palette.text
76  opacity: _nameEdit.focus ? 1 : 0.5
77  }
78 
79  TextField {
80  id: _nameEdit
81  Layout.fillWidth: true
82 
83  MvvmBinding {
84  viewModel: _networkExchangeView.viewModel
85  viewModelProperty: "deviceName"
86  view: _nameEdit
87  viewProperty: "text"
88  }
89  }
90 
91  Rectangle {
92  Layout.fillWidth: true
93  Layout.minimumHeight: 1
94  Layout.maximumHeight: 1
95  color: {
96  if(QuickPresenter.currentStyle === "Material")
97  return Material.foreground;
98  else if(QuickPresenter.currentStyle === "Universal")
99  return Universal.foreground;
100  else
101  return "black";
102  }
103  }
104 
105  Switch {
106  id: _exchangeSwitch
107  text: qsTr("Exchange active:")
108 
109  MvvmBinding {
110  viewModel: _networkExchangeView.viewModel
111  viewModelProperty: "active"
112  view: _exchangeSwitch
113  viewProperty: "checked"
114  }
115  }
116 
117  ListView {
118  id: _exchangeList
119  Layout.fillWidth: true
120  Layout.fillHeight: true
121  clip: true
122 
123  model: viewModel.sortedModel
124 
125  ScrollBar.vertical: ScrollBar {}
126 
127  delegate: ItemDelegate {
128  width: parent.width
129 
130  contentItem: ColumnLayout {
131  id: _delegateLayout
132  spacing: 8
133 
134  Label {
135  id: _nameLabel
136  Layout.fillWidth: true
137  text: name
138  }
139 
140  Label {
141  id: _addressLabel
142  font.pointSize: _nameLabel.font.pointSize * 0.8
143  Layout.fillWidth: true
144  Layout.leftMargin: 8
145  text: address
146  opacity: 0.75
147  }
148  }
149 
150  onClicked: viewModel.exportTo(index)
151  }
152  }
153  }
154  }
155 }
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.
The QML import for the QtMvvmCore QML module.
QString currentStyle
The name of the currently active Quick Controls 2 Style.
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.
A QML singleton to access common presenter methods globally.