Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mport QtQuick 2.10
- import QtQuick.Window 2.10
- import QtQuick.Controls 2.3
- import QtQuick.Layouts 1.3
- Window {
- visible: true
- width: 340
- height: 280
- title: qsTr("")
- Connections {
- target: bdconnect // Указываем целевое соединение
- /* Объявляем и реализуем функцию, как параметр
- * объекта и с имененем похожим на название сигнала
- * Разница в том, что добавляем в начале on и далее пишем
- * с заглавной буквы
- * */
- onSendToQml: {
- //console.debug("txtNote")
- textArea.text = txtNote
- myModel.updateModel() // И обновляем модель данных с новой записью
- }
- }
- GridLayout {
- id: gridLayout
- anchors.fill: parent
- anchors.margins: 20
- rowSpacing: 20
- columnSpacing: 20
- Row {
- spacing: 2
- Layout.fillWidth: true
- Layout.fillHeight: true
- Rectangle {
- id:textzone
- color: "white"
- anchors.left: parent.left
- width: parent.width/2
- height: parent.height
- border.width: 1
- border.color: "black"
- radius: 3
- ScrollView {
- id: view
- anchors.fill: parent
- TextArea {
- id: textArea
- text: qsTr("")
- property var checktxt:textArea.text
- anchors.fill: textzone
- wrapMode: TextEdit.WordWrap
- onTextChanged:{
- if (textArea.text !== checktxt && checktxt !== "" && textArea.text !== ""){
- console.debug("new = |"+textArea.text+ "| " + "old= |" + checktxt +"|")
- bdconnect.updateBD(textArea.text,list_view1.currentItem.idNote)
- }
- }
- }
- }
- }
- Rectangle {
- id:listzone
- color: "white";
- anchors.left: textzone.right
- anchors.leftMargin: 5
- width: (parent.width - textzone.width)/2
- height: parent.height
- border.width: 1
- border.color: "black"
- radius: 3
- ListView {
- id: list_view1
- anchors.fill: parent
- clip: true //при соварчивании области списка. текст в списке уходит за границу
- highlight: Rectangle {
- anchors.margins: 1
- color: "skyblue"
- focus: true
- radius: 3
- }
- highlightFollowsCurrentItem: true
- model:myModel
- delegate: Item {
- id:deleg
- //anchors.left: parent.left
- width: list_view1.width
- height: 12
- property var idNote: id
- property var strNote: fNote
- Item {
- id: row1
- anchors.fill: parent
- anchors.margins: 1
- Text {
- text: " "+ strNote
- //anchors.verticalCenter: parent.verticalCenter
- font.bold: true
- }
- }
- MouseArea {
- id: mousearea2
- anchors.fill: deleg //растяжениево всю площадь родителя
- onClicked: {
- list_view1.currentIndex = index //получение индекса элемента под курсором
- }
- onDoubleClicked:{
- list_view1.currentIndex = index
- console.debug(list_view1.currentIndex)
- textArea.clear()
- bdconnect.selectBD(list_view1.currentItem.idNote)
- }
- }
- }
- }
- }
- Rectangle {
- id:buttonzone
- color: "white";
- anchors.right: parent.right
- anchors.leftMargin: 5
- width: ((parent.width - textzone.width)/2)-10
- height: parent.height/3
- Button {
- id: btnnew
- text: qsTr("New")
- anchors.right: buttonzone.top
- width: buttonzone.width
- height: buttonzone.height/3
- background: Rectangle {
- border.color: "black"
- color: btnnew.down ? "#DCDCDC":"#FFFFFF"
- border.width: 1
- radius: 5
- }
- onClicked: {
- textArea.clear()
- console.debug(list_view1.currentIndex)
- }
- }
- Button {
- id: btnsave
- x: 0
- text: qsTr("Save")
- anchors.topMargin: 0
- anchors.top: btnnew.bottom
- width: buttonzone.width
- height: buttonzone.height/3
- background: Rectangle {
- border.color: "black"
- color: btnsave.down ? "#DCDCDC":"#FFFFFF"
- border.width: 1
- radius: 5
- }
- onClicked: {
- //отправим данные в слот ядра приложения
- bdconnect.insertBD(textArea.text)
- myModel.updateModel() // И обновляем модель данных с новой записью
- console.debug("save= "+list_view1.currentItem.idNote)
- }
- }
- Button {
- id: btndel
- text: qsTr("Del")
- anchors.top: btnsave.bottom
- width: buttonzone.width
- height: buttonzone.height/3
- background: Rectangle {
- border.color: "black"
- color: btndel.down ? "#DCDCDC":"#FFFFFF"
- border.width: 1
- radius: 5
- }
- onClicked: {
- console.debug(list_view1.currentItem.idNote)
- bdconnect.deleteNote(list_view1.currentItem.idNote)
- myModel.updateModel()
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement