Aufgrund einer Wartung wird GitLab am 28.09. zwischen 10:00 und 11:00 Uhr kurzzeitig nicht zur Verfügung stehen. / Due to maintenance, GitLab will be temporarily unavailable on 28.09. between 10:00 and 11:00 am.

Commit df4cc5c1 authored by Leander Schulten's avatar Leander Schulten

UX: You can now search in the lists of the first four tabs

parent 9fc898b2
Pipeline #191842 passed with stage
in 4 minutes and 50 seconds
......@@ -38,6 +38,64 @@ ModelView{
sortPropertyName: "prototype.name"
}
}
searchHelpText: "You can search by text and by dmx channel:\nUse '(>|>=|<|<=|=) x' or 'x - y' to search for a range"
property int minDisplayedChannel: 0
property int maxDisplayedChannel: 100000
property bool checkChannels: false
// to allow e.g. 'Scanner > 80'
property string additionalSearchString
onCurrentSearchTextChanged: {
checkChannels = false
additionalSearchString = "";
const string = currentSearchText.replace(/ +/g, '');
// detect not completed >, >=, ...
if(/[<>=]{1,2}[a-zA-Z ]*$/.exec(string)!==null){
checkChannels = true;
}
// find additional string, like 'Scanner >= 80'
const str = /[a-zA-Z ]+/.exec(string);
if(str !== null){
console.log(str)
additionalSearchString = str[0];
}
// search for ranges: x-y
const range = /(\d+)-(\d+)/.exec(string);
if(range !== null){
checkChannels = true;
minDisplayedChannel = Math.min(range[1], range[2]);
maxDisplayedChannel = Math.max(range[1], range[2]);
return
}
minDisplayedChannel = 0;
maxDisplayedChannel = 10000;
const gt = />(=)?(\d+)/.exec(string);
if(gt !== null){
checkChannels = true;
minDisplayedChannel = Number(gt[2]) + (gt[1] === undefined ? 1 : 0);
}
const lt = /<(=)?(\d+)/.exec(string);
if(lt !== null){
checkChannels = true;
maxDisplayedChannel = Number(lt[2]) - (lt[1] === undefined ? 1 : 0);
}
if(!checkChannels){
const eq = /=(\d+)/.exec(string);
if(eq !== null){
checkChannels = true;
minDisplayedChannel = maxDisplayedChannel = eq[1];
}
}
if(!checkChannels){
additionalSearchString = currentSearchText.trim();
}
}
searchFilter: (device, text) => {
if(checkChannels){
return device.startDMXChannel + device.prototype.numberOfChannels > minDisplayedChannel && device.startDMXChannel <= maxDisplayedChannel && text.indexOf(additionalSearchString) !== -1
}else{
return text.indexOf(additionalSearchString) !== -1;
}
}
Label{
Layout.row: 2
......
......@@ -26,7 +26,10 @@ GridLayout{
property alias descriptionInputEnabled: textDescription.enabled
property alias listView : listView
property var nameFunction: null
// a filter function used for searching. The first parameter ist the search string, the second the modelData and the third the displayed string
property var searchFilter: (modelData, text) => text.indexOf(currentSearchText) !== -1
property string searchHelpText;
property string currentSearchText;
ListView{
Layout.fillHeight: true
......@@ -44,7 +47,8 @@ GridLayout{
width: parent.width
text: nameFunction ? nameFunction(modelData) : modelData.name +"("+modelData.description+")"
onClicked: listView.currentIndex = index
visible: root.searchFilter === null || root.currentSearchText.length === 0 || root.searchFilter(modelItemData, text)
height: visible ? implicitHeight : 0
}
headerPositioning: ListView.OverlayHeader
Component{
......@@ -55,12 +59,19 @@ GridLayout{
}
width: listView.width
implicitHeight: sortRow.implicitHeight + (searchRow.implicitHeight - 4 - (36-Material.buttonHeight) * 2) * searchRow.visible + 12
height: implicitHeight
topPadding: 6
bottomPadding: 6
z: 2
Material.elevation: 4
RowLayout {
anchors.fill: parent
id: sortRow
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
anchors.bottom: searchRow.top
implicitHeight: sortCommboBox.implicitHeight
spacing: 8
Label{
text: "Sort by:"
......@@ -83,7 +94,46 @@ GridLayout{
icon.source: sortedView.sortOrder === Qt.DescendingOrder ? "../icons/sort_order/sort-reverse-alphabetical-order.svg" : "../icons/sort_order/sort-by-alphabet.svg"
onClicked: sortedView.sortOrder = sortedView.sortOrder === Qt.DescendingOrder ? Qt.AscendingOrder : Qt.DescendingOrder;
}
} // RowLayout
RowLayout{
id: searchRow
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.top: sortRow.bottom
visible: root.filter !== null
spacing: 8
Label{
text: "Search:"
}
TextInputField{
id: searchInput
Layout.fillWidth: true
onTextChanged: currentSearchText = text
Keys.onEscapePressed: text = ""
}
Button{
Layout.preferredWidth: root.searchHelpText.length !== 0 ? implicitWidth / 2 - 4 : implicitWidth
flat: true
text: "X"
onClicked: searchInput.text = ""
}
Button{
Layout.preferredWidth: implicitWidth / 2 - 4
flat: true
text: "?"
visible: root.searchHelpText.length !== 0
ToolTip.visible: hovered
ToolTip.text: root.searchHelpText
}
Shortcut{
enabled: root.SwipeView.isCurrentItem
sequence: StandardKey.Find
onActivated: searchInput.forceActiveFocus()
}
} // RowLayout
}
}
......
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