mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 19:08:58 +03:00
Improve sorting and sizing of completions a bit
This commit is contained in:
parent
b82c11bd79
commit
1961312b15
53 changed files with 95 additions and 121 deletions
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import "./ui"
|
import "./ui"
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import "./ui"
|
import "./ui"
|
||||||
|
@ -62,18 +61,17 @@ Popup {
|
||||||
}
|
}
|
||||||
|
|
||||||
function finishCompletion() {
|
function finishCompletion() {
|
||||||
if(popup.completerName == "room") {
|
if (popup.completerName == "room")
|
||||||
popup.completionSelected(listView.itemAtIndex(currentIndex).modelData.roomid)
|
popup.completionSelected(listView.itemAtIndex(currentIndex).modelData.roomid);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onCompleterNameChanged: {
|
onCompleterNameChanged: {
|
||||||
if (completerName) {
|
if (completerName) {
|
||||||
if (completerName == "user") {
|
if (completerName == "user")
|
||||||
completer = TimelineManager.completerFor(completerName, TimelineManager.timeline.roomId());
|
completer = TimelineManager.completerFor(completerName, TimelineManager.timeline.roomId());
|
||||||
} else {
|
else
|
||||||
completer = TimelineManager.completerFor(completerName);
|
completer = TimelineManager.completerFor(completerName);
|
||||||
}
|
|
||||||
completer.setSearchString("");
|
completer.setSearchString("");
|
||||||
} else {
|
} else {
|
||||||
completer = undefined;
|
completer = undefined;
|
||||||
|
@ -99,10 +97,11 @@ Popup {
|
||||||
pixelAligned: true
|
pixelAligned: true
|
||||||
|
|
||||||
delegate: Rectangle {
|
delegate: Rectangle {
|
||||||
|
property variant modelData: model
|
||||||
|
|
||||||
color: model.index == popup.currentIndex ? colors.highlight : colors.base
|
color: model.index == popup.currentIndex ? colors.highlight : colors.base
|
||||||
height: chooser.childrenRect.height + 2 * popup.rowMargin
|
height: chooser.childrenRect.height + 2 * popup.rowMargin
|
||||||
implicitWidth: fullWidth ? popup.width : chooser.childrenRect.width + 4
|
implicitWidth: fullWidth ? popup.width : chooser.childrenRect.width + 4
|
||||||
property variant modelData: model
|
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: mouseArea
|
id: mouseArea
|
||||||
|
@ -111,10 +110,10 @@ Popup {
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
onPositionChanged: popup.currentIndex = model.index
|
onPositionChanged: popup.currentIndex = model.index
|
||||||
onClicked: {
|
onClicked: {
|
||||||
popup.completionClicked(completer.completionAt(model.index))
|
popup.completionClicked(completer.completionAt(model.index));
|
||||||
if(popup.completerName == "room") {
|
if (popup.completerName == "room")
|
||||||
popup.completionSelected(model.roomid)
|
popup.completionSelected(model.roomid);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ripple {
|
Ripple {
|
||||||
|
@ -200,8 +199,8 @@ Popup {
|
||||||
width: popup.avatarWidth
|
width: popup.avatarWidth
|
||||||
url: model.avatarUrl.replace("mxc://", "image://MxcImage/")
|
url: model.avatarUrl.replace("mxc://", "image://MxcImage/")
|
||||||
onClicked: {
|
onClicked: {
|
||||||
popup.completionClicked(completer.completionAt(model.index))
|
popup.completionClicked(completer.completionAt(model.index));
|
||||||
popup.completionSelected(model.roomid)
|
popup.completionSelected(model.roomid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import QtQuick 2.12
|
import QtQuick 2.12
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import "./ui"
|
import "./ui"
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import QtQuick 2.5
|
import QtQuick 2.5
|
||||||
|
|
|
@ -1,56 +1,62 @@
|
||||||
import QtQuick 2.13
|
import QtQuick 2.13
|
||||||
import QtQuick.Layouts 1.13
|
|
||||||
import QtQuick.Controls 2.13
|
import QtQuick.Controls 2.13
|
||||||
|
import QtQuick.Layouts 1.13
|
||||||
|
|
||||||
TextField {
|
TextField {
|
||||||
id: input
|
id: input
|
||||||
palette: colors
|
|
||||||
|
|
||||||
background: Rectangle {
|
palette: colors
|
||||||
color: colors.base
|
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: blueBar
|
id: blueBar
|
||||||
|
|
||||||
anchors.top: parent.bottom
|
anchors.top: parent.bottom
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
|
||||||
color: colors.highlight
|
color: colors.highlight
|
||||||
height: 1
|
height: 1
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: blackBar
|
id: blackBar
|
||||||
|
|
||||||
anchors.verticalCenter: blueBar.verticalCenter
|
anchors.verticalCenter: blueBar.verticalCenter
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
height: parent.height + 1
|
||||||
height: parent.height+1
|
|
||||||
width: 0
|
width: 0
|
||||||
color: colors.text
|
color: colors.text
|
||||||
|
|
||||||
states: State {
|
states: State {
|
||||||
name: "focused"; when: input.activeFocus == true
|
name: "focused"
|
||||||
|
when: input.activeFocus == true
|
||||||
|
|
||||||
PropertyChanges {
|
PropertyChanges {
|
||||||
target: blackBar
|
target: blackBar
|
||||||
width: blueBar.width
|
width: blueBar.width
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
transitions: Transition {
|
transitions: Transition {
|
||||||
from: ""
|
from: ""
|
||||||
to: "focused"
|
to: "focused"
|
||||||
reversible: true
|
reversible: true
|
||||||
|
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
target: blackBar
|
target: blackBar
|
||||||
properties: "width"
|
properties: "width"
|
||||||
duration: 500
|
duration: 500
|
||||||
easing.type: Easing.InOutQuad
|
easing.type: Easing.InOutQuad
|
||||||
alwaysRunToEnd: true
|
alwaysRunToEnd: true
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
background: Rectangle {
|
||||||
|
color: colors.base
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import "./voip"
|
import "./voip"
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import "./delegates"
|
import "./delegates"
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import QtQuick 2.9
|
import QtQuick 2.9
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import QtGraphicalEffects 1.0
|
import QtGraphicalEffects 1.0
|
||||||
|
|
|
@ -5,19 +5,31 @@ import im.nheko 1.0
|
||||||
Popup {
|
Popup {
|
||||||
id: quickSwitcher
|
id: quickSwitcher
|
||||||
|
|
||||||
property int textHeight: 32
|
property int textHeight: Math.round(Qt.application.font.pixelSize * 2.4)
|
||||||
property int textMargin: 8
|
property int textMargin: Math.round(textHeight / 8)
|
||||||
|
|
||||||
x: parent.width / 2 - width / 2
|
function delay(delayTime, cb) {
|
||||||
y: parent.height / 4 - height / 2
|
timer.interval = delayTime;
|
||||||
width: parent.width / 2
|
timer.repeat = false;
|
||||||
|
timer.triggered.connect(cb);
|
||||||
|
timer.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
width: Math.round(parent.width / 2)
|
||||||
|
x: Math.round(parent.width / 2 - width / 2)
|
||||||
|
y: Math.round(parent.height / 4 - height / 2)
|
||||||
modal: true
|
modal: true
|
||||||
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
|
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
|
||||||
parent: Overlay.overlay
|
parent: Overlay.overlay
|
||||||
palette: colors
|
palette: colors
|
||||||
|
onOpened: {
|
||||||
Overlay.modal: Rectangle {
|
completerPopup.open();
|
||||||
color: "#aa1E1E1E"
|
delay(200, function() {
|
||||||
|
roomTextInput.forceActiveFocus();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
onClosed: {
|
||||||
|
completerPopup.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
MatrixTextField {
|
MatrixTextField {
|
||||||
|
@ -27,11 +39,9 @@ Popup {
|
||||||
font.pixelSize: Math.ceil(quickSwitcher.textHeight * 0.6)
|
font.pixelSize: Math.ceil(quickSwitcher.textHeight * 0.6)
|
||||||
padding: textMargin
|
padding: textMargin
|
||||||
color: colors.text
|
color: colors.text
|
||||||
|
|
||||||
onTextEdited: {
|
onTextEdited: {
|
||||||
completerPopup.completer.setSearchString(text)
|
completerPopup.completer.searchString = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
Keys.onPressed: {
|
Keys.onPressed: {
|
||||||
if (event.key == Qt.Key_Up && completerPopup.opened) {
|
if (event.key == Qt.Key_Up && completerPopup.opened) {
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
|
@ -40,7 +50,7 @@ Popup {
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
completerPopup.down();
|
completerPopup.down();
|
||||||
} else if (event.matches(StandardKey.InsertParagraphSeparator)) {
|
} else if (event.matches(StandardKey.InsertParagraphSeparator)) {
|
||||||
completerPopup.finishCompletion()
|
completerPopup.finishCompletion();
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,36 +60,30 @@ Popup {
|
||||||
id: completerPopup
|
id: completerPopup
|
||||||
|
|
||||||
x: roomTextInput.x
|
x: roomTextInput.x
|
||||||
y: roomTextInput.y + roomTextInput.height + textMargin
|
y: roomTextInput.y + quickSwitcher.textHeight + quickSwitcher.textMargin
|
||||||
|
visible: roomTextInput.length > 0
|
||||||
width: parent.width
|
width: parent.width
|
||||||
completerName: "room"
|
completerName: "room"
|
||||||
bottomToTop: false
|
bottomToTop: false
|
||||||
fullWidth: true
|
fullWidth: true
|
||||||
avatarHeight: textHeight
|
avatarHeight: quickSwitcher.textHeight
|
||||||
avatarWidth: textHeight
|
avatarWidth: quickSwitcher.textHeight
|
||||||
centerRowContent: false
|
centerRowContent: false
|
||||||
rowMargin: 8
|
rowMargin: Math.round(quickSwitcher.textMargin / 2)
|
||||||
rowSpacing: 6
|
rowSpacing: quickSwitcher.textMargin
|
||||||
|
|
||||||
closePolicy: Popup.NoAutoClose
|
closePolicy: Popup.NoAutoClose
|
||||||
}
|
}
|
||||||
|
|
||||||
onOpened: {
|
|
||||||
completerPopup.open()
|
|
||||||
delay(200, function() {
|
|
||||||
roomTextInput.forceActiveFocus()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
onClosed: {
|
|
||||||
completerPopup.close()
|
|
||||||
}
|
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
onCompletionSelected: {
|
onCompletionSelected: {
|
||||||
TimelineManager.setHistoryView(id)
|
TimelineManager.setHistoryView(id);
|
||||||
TimelineManager.highlightRoom(id)
|
TimelineManager.highlightRoom(id);
|
||||||
quickSwitcher.close()
|
quickSwitcher.close();
|
||||||
|
}
|
||||||
|
onCountChanged: {
|
||||||
|
if (completerPopup.count > 0 && (completerPopup.currentIndex < 0 || completerPopup.currentIndex >= completerPopup.count))
|
||||||
|
completerPopup.currentIndex = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
target: completerPopup
|
target: completerPopup
|
||||||
}
|
}
|
||||||
|
@ -88,10 +92,8 @@ Popup {
|
||||||
id: timer
|
id: timer
|
||||||
}
|
}
|
||||||
|
|
||||||
function delay(delayTime, cb) {
|
Overlay.modal: Rectangle {
|
||||||
timer.interval = delayTime;
|
color: "#aa1E1E1E"
|
||||||
timer.repeat = false;
|
|
||||||
timer.triggered.connect(cb);
|
|
||||||
timer.start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import QtQuick 2.6
|
import QtQuick 2.6
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import "./delegates/"
|
import "./delegates/"
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import Qt.labs.platform 1.1 as Platform
|
import Qt.labs.platform 1.1 as Platform
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
// Copyright (C) 2016 Michael Bohlender, <michael.bohlender@kdemail.net>
|
// Copyright (C) 2016 Michael Bohlender, <michael.bohlender@kdemail.net>
|
||||||
// Copyright (C) 2017 Christian Mollekopf, <mollekopf@kolabsystems.com>
|
// Copyright (C) 2017 Christian Mollekopf, <mollekopf@kolabsystems.com>
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Shamelessly stolen from:
|
* Shamelessly stolen from:
|
||||||
* https://cgit.kde.org/kube.git/tree/framework/qml/ScrollHelper.qml
|
* https://cgit.kde.org/kube.git/tree/framework/qml/ScrollHelper.qml
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import QtQuick 2.5
|
import QtQuick 2.5
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import "./delegates"
|
import "./delegates"
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import "./delegates"
|
import "./delegates"
|
||||||
|
@ -77,13 +76,14 @@ Page {
|
||||||
|
|
||||||
QuickSwitcher {
|
QuickSwitcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Shortcut {
|
Shortcut {
|
||||||
sequence: "Ctrl+K"
|
sequence: "Ctrl+K"
|
||||||
onActivated: {
|
onActivated: {
|
||||||
var quickSwitch = quickSwitcherComponent.createObject(timelineRoot);
|
var quickSwitch = quickSwitcherComponent.createObject(timelineRoot);
|
||||||
TimelineManager.focusTimeline()
|
TimelineManager.focusTimeline();
|
||||||
quickSwitch.open();
|
quickSwitch.open();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import QtQuick 2.5
|
import QtQuick 2.5
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import QtQuick 2.9
|
import QtQuick 2.9
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import QtQuick 2.9
|
import QtQuick 2.9
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import "./device-verification"
|
import "./device-verification"
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import QtQuick 2.12
|
import QtQuick 2.12
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import QtQuick 2.12
|
import QtQuick 2.12
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import QtQuick 2.6
|
import QtQuick 2.6
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
TextMessage {
|
TextMessage {
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import QtQuick 2.5
|
import QtQuick 2.5
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import ".."
|
import ".."
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import QtMultimedia 5.6
|
import QtMultimedia 5.6
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import QtQuick 2.12
|
import QtQuick 2.12
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import ".."
|
import ".."
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import QtQuick 2.3
|
import QtQuick 2.3
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import QtQuick 2.10
|
import QtQuick 2.10
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import QtQuick 2.3
|
import QtQuick 2.3
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import QtQuick 2.3
|
import QtQuick 2.3
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import QtQuick 2.3
|
import QtQuick 2.3
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import QtQuick 2.3
|
import QtQuick 2.3
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import QtQuick 2.3
|
import QtQuick 2.3
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import QtQuick 2.3
|
import QtQuick 2.3
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import QtQuick 2.3
|
import QtQuick 2.3
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import "../"
|
import "../"
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import "../"
|
import "../"
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import QtGraphicalEffects 1.0
|
import QtGraphicalEffects 1.0
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import "../"
|
import "../"
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import QtQuick 2.9
|
import QtQuick 2.9
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import "../"
|
import "../"
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import "../"
|
import "../"
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import QtQuick 2.9
|
import QtQuick 2.9
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import "../"
|
import "../"
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import "../"
|
import "../"
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import QtQuick 2.9
|
import QtQuick 2.9
|
||||||
|
|
|
@ -19,6 +19,7 @@ CompletionProxyModel::CompletionProxyModel(QAbstractItemModel *model,
|
||||||
setSourceModel(model);
|
setSourceModel(model);
|
||||||
QRegularExpression splitPoints("\\s+|-");
|
QRegularExpression splitPoints("\\s+|-");
|
||||||
|
|
||||||
|
// insert all the full texts
|
||||||
for (int i = 0; i < sourceModel()->rowCount(); i++) {
|
for (int i = 0; i < sourceModel()->rowCount(); i++) {
|
||||||
if (i < 7)
|
if (i < 7)
|
||||||
mapping.push_back(i);
|
mapping.push_back(i);
|
||||||
|
@ -29,6 +30,19 @@ CompletionProxyModel::CompletionProxyModel(QAbstractItemModel *model,
|
||||||
.toLower();
|
.toLower();
|
||||||
trie_.insert(string1.toUcs4(), i);
|
trie_.insert(string1.toUcs4(), i);
|
||||||
|
|
||||||
|
auto string2 = sourceModel()
|
||||||
|
->data(sourceModel()->index(i, 0), CompletionModel::SearchRole2)
|
||||||
|
.toString()
|
||||||
|
.toLower();
|
||||||
|
}
|
||||||
|
|
||||||
|
// insert the partial matches
|
||||||
|
for (int i = 0; i < sourceModel()->rowCount(); i++) {
|
||||||
|
auto string1 = sourceModel()
|
||||||
|
->data(sourceModel()->index(i, 0), CompletionModel::SearchRole)
|
||||||
|
.toString()
|
||||||
|
.toLower();
|
||||||
|
|
||||||
for (const auto &e : string1.split(splitPoints)) {
|
for (const auto &e : string1.split(splitPoints)) {
|
||||||
if (!e.isEmpty()) // NOTE(Nico): Use Qt::SkipEmptyParts in Qt 5.14
|
if (!e.isEmpty()) // NOTE(Nico): Use Qt::SkipEmptyParts in Qt 5.14
|
||||||
trie_.insert(e.toUcs4(), i);
|
trie_.insert(e.toUcs4(), i);
|
||||||
|
@ -40,7 +54,6 @@ CompletionProxyModel::CompletionProxyModel(QAbstractItemModel *model,
|
||||||
.toLower();
|
.toLower();
|
||||||
|
|
||||||
if (!string2.isEmpty()) {
|
if (!string2.isEmpty()) {
|
||||||
trie_.insert(string2.toUcs4(), i);
|
|
||||||
for (const auto &e : string2.split(splitPoints)) {
|
for (const auto &e : string2.split(splitPoints)) {
|
||||||
if (!e.isEmpty()) // NOTE(Nico): Use Qt::SkipEmptyParts in Qt 5.14
|
if (!e.isEmpty()) // NOTE(Nico): Use Qt::SkipEmptyParts in Qt 5.14
|
||||||
trie_.insert(e.toUcs4(), i);
|
trie_.insert(e.toUcs4(), i);
|
||||||
|
@ -55,7 +68,7 @@ CompletionProxyModel::CompletionProxyModel(QAbstractItemModel *model,
|
||||||
[this](QString s) {
|
[this](QString s) {
|
||||||
s.remove(":");
|
s.remove(":");
|
||||||
s.remove("@");
|
s.remove("@");
|
||||||
searchString = s.toLower();
|
searchString_ = s.toLower();
|
||||||
invalidate();
|
invalidate();
|
||||||
},
|
},
|
||||||
Qt::QueuedConnection);
|
Qt::QueuedConnection);
|
||||||
|
@ -64,7 +77,7 @@ CompletionProxyModel::CompletionProxyModel(QAbstractItemModel *model,
|
||||||
void
|
void
|
||||||
CompletionProxyModel::invalidate()
|
CompletionProxyModel::invalidate()
|
||||||
{
|
{
|
||||||
auto key = searchString.toUcs4();
|
auto key = searchString_.toUcs4();
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
mapping = trie_.search(key, 7, maxMistakes_);
|
mapping = trie_.search(key, 7, maxMistakes_);
|
||||||
endResetModel();
|
endResetModel();
|
||||||
|
|
|
@ -135,7 +135,8 @@ struct trie
|
||||||
class CompletionProxyModel : public QAbstractProxyModel
|
class CompletionProxyModel : public QAbstractProxyModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(
|
||||||
|
QString searchString READ searchString WRITE setSearchString NOTIFY newSearchString)
|
||||||
public:
|
public:
|
||||||
CompletionProxyModel(QAbstractItemModel *model,
|
CompletionProxyModel(QAbstractItemModel *model,
|
||||||
int max_mistakes = 2,
|
int max_mistakes = 2,
|
||||||
|
@ -159,12 +160,13 @@ public slots:
|
||||||
QVariant completionAt(int i) const;
|
QVariant completionAt(int i) const;
|
||||||
|
|
||||||
void setSearchString(QString s);
|
void setSearchString(QString s);
|
||||||
|
QString searchString() const { return searchString_; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void newSearchString(QString);
|
void newSearchString(QString);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString searchString;
|
QString searchString_;
|
||||||
trie<uint, int> trie_;
|
trie<uint, int> trie_;
|
||||||
std::vector<int> mapping;
|
std::vector<int> mapping;
|
||||||
int maxMistakes_;
|
int maxMistakes_;
|
||||||
|
|
Loading…
Reference in a new issue