Commit da972262 authored by Harald Sitter's avatar Harald Sitter 🏡

use slightly easier to edit tagging system

tags are now rendered in a listview rather than a long line of text
parent e6929679
/*
Copyright © 2018 Harald Sitter <sitter@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License or (at your option) version 3 or any later version
accepted by the membership of KDE e.V. (or its successor approved
by the membership of KDE e.V.), which shall act as a proxy
defined in Section 14 of version 3 of the license.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.7
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
Rectangle {
property alias text: textField.text
signal remove
implicitWidth: layout.width
implicitHeight: layout.height
radius: fontMetrics.height / 4
color: "lightgrey"
RowLayout {
id: layout
Text {
id: textField
Layout.leftMargin: fontMetrics.height / 4
elide: Text.ElideMiddle
}
Rectangle { Layout.fillWidth: true }
AbstractButton {
id: removeButton
height: textField.contentHeight
implicitWidth: height
contentItem: Image {
source: "file:///usr/share/icons/breeze/actions/22/list-remove.svg"
}
onClicked: remove()
}
}
}
...@@ -106,10 +106,19 @@ ApplicationWindow { ...@@ -106,10 +106,19 @@ ApplicationWindow {
Selector { model: selectorModel } Selector { model: selectorModel }
} }
FontMetrics {
id: fontMetrics
}
RowLayout { RowLayout {
anchors.fill: parent anchors.fill: parent
ColumnLayout { ColumnLayout {
Text { text: "Properties"; color: palette.text } Layout.margins: fontMetrics.height / 4
// TODO: I do not know how properties work, they maybe should be
// presented like tags - sitter
Label { text: "Properties" }
TextArea { TextArea {
placeholderText: "..." placeholderText: "..."
// wrapMode: TextEdit.Wrap // wrapMode: TextEdit.Wrap
...@@ -118,13 +127,40 @@ ApplicationWindow { ...@@ -118,13 +127,40 @@ ApplicationWindow {
// would need async timer or something // would need async timer or something
onTextChanged: { selectorModel.properties = text.split(',') } onTextChanged: { selectorModel.properties = text.split(',') }
} }
Text { text: "Tags"; color: palette.text }
TextArea { Label { text: "Tags" }
placeholderText: "..." TextField {
// wrapMode: TextEdit.Wrap Layout.fillWidth: true
text: selectorModel.tags.join(',') placeholderText: "Add New Tag..."
onTextChanged: { selectorModel.tags = text.split(',') } selectByMouse: true
onAccepted: {
// FIXME: should probably move to model var[] doesn't propagate
// push or slice to the view for reloading
selectorModel.tags.push(text)
selectorModel.tags = selectorModel.tags // Reassign to trigger reload
clear()
}
} }
ListView {
Layout.preferredHeight: contentHeight
Layout.fillWidth: true
clip: true
model: selectorModel.tags
ScrollBar.vertical: ScrollBar { }
delegate: Tag {
text: modelData
width: ListView.view.width
onRemove: {
selectorModel.tags.splice(index, 1)
selectorModel.tags = selectorModel.tags // Reassign to trigger reload
}
}
}
Item { Layout.fillHeight: true }
RowLayout { RowLayout {
Button { Button {
text: "Save" text: "Save"
......
...@@ -4,5 +4,6 @@ ...@@ -4,5 +4,6 @@
<file>qml/RectangleTwiddler.qml</file> <file>qml/RectangleTwiddler.qml</file>
<file>qml/Twiddler.qml</file> <file>qml/Twiddler.qml</file>
<file>qml/Selector.qml</file> <file>qml/Selector.qml</file>
<file>qml/Tag.qml</file>
</qresource> </qresource>
</RCC> </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