Commit f55c8a9c authored by Leander Schulten's avatar Leander Schulten
Browse files

Create an TextInputField for A TextField with own look and feel.

Outsource each View into an ModelView
Creates for Each Type its own specialization of the ModelView
parent 1615cf92
ModelView{
model:devicePrototypeModel
}
......@@ -2,14 +2,37 @@ import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.0
ListView{
width: 400
id:devs
model: deviceModel
anchors.fill: parent
delegate: ItemDelegate{
text: name
ModelView{
model:deviceModel
rows: 6
Text{
Layout.row: 2
Layout.column: 2
text:"startDMXChannel:"
Layout.rightMargin: 20
font.pixelSize: 15
}
TextInputField{
Layout.row: 2
Layout.column: 3
text: parent.currentItem.data.startDMXChannel
validator: IntValidator{
bottom: 0
top:512
}
onTextChanged: parent.currentItem.data.startDMXChannel = text.length?text:0
}
Text{
Layout.row: 3
Layout.column: 2
text:"DevicePrototype:"
Layout.rightMargin: 20
font.pixelSize: 15
}
Text{
Layout.row: 3
Layout.column: 3
text:parent.currentItem.data.prototype.name
font.pixelSize: 15
}
}
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.0
GridLayout{
anchors.leftMargin: 5
columnSpacing: 5
rowSpacing: 5
columns: 4
rows: 4
property alias model : listView.model
property alias currentItem : listView.currentItem
ListView{
Layout.fillHeight: true
Layout.preferredWidth: 300
Layout.columnSpan: 2
Layout.rowSpan: parent.rows-1
id:listView
delegate: ItemDelegate{
property var data: modelData
width: parent.width
text: modelData.name +"("+modelData.description+")"
onClicked: listView.currentIndex = index
}
highlight: Rectangle{
color: "blue"
opacity: 0.7
}
}
Button{
Layout.row: parent.rows-1
Layout.column: 0
Layout.preferredWidth: 150
id: buttonAdd
text:"+"
font.pixelSize: 15
}
Button{
Layout.row: parent.rows-1
Layout.column: 1
Layout.preferredWidth: 150
id: buttonRemove
text:"-"
font.pixelSize: 15
}
Text{
Layout.row: 0
Layout.column: 2
id:labelName
text:"Name:"
Layout.rightMargin: 20
font.pixelSize: 15
}
TextInputField{
Layout.row: 0
Layout.column: 3
Layout.fillWidth: true
id:textName
text: listView.currentItem.data.name
onTextChanged: listView.currentItem.data.name = text
}
Text{
Layout.row: 1
Layout.column: 2
id:labelDescription
text:"Description:"
font.pixelSize: 15
}
TextInputField{
Layout.row: 1
Layout.column: 3
Layout.fillWidth: true
id:textDescription
text: listView.currentItem.data.description
onTextChanged: listView.currentItem.data.description = text
}
}
ModelView{
model:programmPrototypeModel
}
ModelView{
model:programmModel
}
import QtQuick 2.7
import QtQuick.Controls 2.0
TextInput{
selectByMouse: true
font.pixelSize: 15
selectionColor: "lightgreen"
cursorDelegate: Rectangle{
color: "lightgreen"
x:parent.cursorRectangle.x
y:parent.cursorRectangle.y
width:parent.cursorRectangle.width+1
height:parent.cursorRectangle.height
visible: parent.cursorVisible
Behavior on x {
NumberAnimation { easing.type: Easing.OutCubic; easing.amplitude: 9; easing.period: 50.0; duration: 500 }
}
}
Rectangle{
anchors.top:parent.bottom
anchors.left:parent.left
width: parent.contentWidth+10
height: 2
radius: 1
color: "lightgreen"
Behavior on width {
NumberAnimation { easing.type: Easing.OutExpo; easing.amplitude: 5.0; easing.period: 2.0; duration: 800 }
}
}
}
......@@ -39,13 +39,16 @@ int main(int argc, char *argv[])
ApplicationData::saveData(file);
app.connect(&app,&QGuiApplication::lastWindowClosed,[&](){ApplicationData::saveData(file);});
QQmlApplicationEngine engine;
engine.rootContext()->setContextProperty("deviceModel",IDBaseDataModel<DevicePrototype>::singletone());
engine.rootContext()->setContextProperty("deviceModel",IDBaseDataModel<Device>::singletone());
engine.rootContext()->setContextProperty("devicePrototypeModel",IDBaseDataModel<DevicePrototype>::singletone());
engine.rootContext()->setContextProperty("programmModel",IDBaseDataModel<Programm>::singletone());
engine.rootContext()->setContextProperty("programmPrototypeModel",IDBaseDataModel<ProgrammPrototype>::singletone());
qDebug() << "Number of Elements : "<<IDBaseDataModel<DevicePrototype>::singletone()->rowCount()<<'\n';
engine.load(QUrl(QLatin1String("qrc:/main.qml")));
......
......@@ -30,48 +30,16 @@ ApplicationWindow {
}
SwipeView {
clip:true
id: swipeView
anchors.fill: parent
currentIndex: tabBar.currentIndex
currentIndex: tabBar.currentIndex
DeviceView{}
ListView{
id:devs
model: deviceModel
delegate: ItemDelegate{
id: dele
width: parent.width
text: name +"("+description+")"
onClicked: devs.currentIndex = index
}
highlight: Rectangle{
color: "blue"
opacity: 0.5
}
}
DevicePrototypeView{}
Page{
title: "test"
ProgrammPrototypeView{}
Rectangle{
height: 100
width: 100
anchors.centerIn: parent
color: "red"
}
}
Page {
Label {
text: qsTr("Second page")
anchors.centerIn: parent
}
Button{
contentItem: Text {
id: testwe
text: qsTr("text");
rotation: 90
}
}
}
ProgrammView{}
}
}
......@@ -4,5 +4,10 @@
<file>qtquickcontrols2.conf</file>
<file>main.qml</file>
<file>DeviceView.qml</file>
<file>TextInputField.qml</file>
<file>DevicePrototypeView.qml</file>
<file>ProgrammView.qml</file>
<file>ProgrammPrototypeView.qml</file>
<file>ModelView.qml</file>
</qresource>
</RCC>
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