aerothemeplasma/plasma/plasmoids/io.gitgud.wackyideas.SevenStart/contents/ui/SearchView.qml

105 lines
3.3 KiB
QML
Raw Permalink Normal View History

2023-09-27 17:50:10 +00:00
/*
Copyright (C) 2011 Martin Gräßlin <mgraesslin@kde.org>
Copyright (C) 2012 Gregor Taetzner <gregor@freenet.de>
Copyright (C) 2015-2018 Eike Hein <hein@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) any later version.
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, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
import QtQuick 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.extras 2.0 as PlasmaExtras
2024-08-09 01:20:25 +00:00
import org.kde.plasma.components 3.0 as PlasmaComponents
import org.kde.plasma.plasmoid 2.0
2023-09-27 17:50:10 +00:00
2024-08-09 01:20:25 +00:00
import org.kde.plasma.private.kicker as Kicker
import org.kde.kirigami as Kirigami
2023-09-27 17:50:10 +00:00
Item {
id: searchViewContainer
2024-08-09 01:20:25 +00:00
property Item itemGrid: runnerGrid
property bool queryFinished: false
property int repeaterModelIndex: 0
2023-09-27 17:50:10 +00:00
2024-08-09 01:20:25 +00:00
function activateCurrentIndex() {
runnerGrid.tryActivate();
}
2023-09-27 17:50:10 +00:00
function decrementCurrentIndex() {
2024-08-09 01:20:25 +00:00
var listView = runnerGrid.flickableItem;
if(listView.currentIndex-1 < 0) {
listView.currentIndex = listView.count - 1;
} else {
listView.currentIndex--;
}
2023-09-27 17:50:10 +00:00
}
function incrementCurrentIndex() {
2024-08-09 01:20:25 +00:00
var listView = runnerGrid.flickableItem;
if(listView.currentIndex+1 >= listView.count) {
listView.currentIndex = 0;
} else {
listView.currentIndex++;
}
2023-09-27 17:50:10 +00:00
}
2024-08-09 01:20:25 +00:00
function onQueryChanged() {
queryFinished = false;
runnerModel.query = searchField.text;
if (!searchField.text) {
if (runnerModel.model)
runnerModel.model = null;
}
2023-09-27 17:50:10 +00:00
}
function openContextMenu() {
runnerModel.currentItem.openActionMenu();
}
function resetCurrentIndex() {
runnerModel.currentIndex = -1;
}
2024-08-09 01:20:25 +00:00
/*function setCurrentIndex() {
runnerGrid.modelIndex = 0;
}*/
2023-09-27 17:50:10 +00:00
2024-08-09 01:20:25 +00:00
objectName: "SearchView"
2023-09-27 17:50:10 +00:00
Connections {
function onCountChanged() {
if (runnerModel.count && !runnerGrid.model) {
2024-08-09 01:20:25 +00:00
runnerGrid.model = runnerModel.modelForRow(0);
2023-09-27 17:50:10 +00:00
}
}
2024-08-09 01:20:25 +00:00
function onQueryFinished() {
if (runnerModel.count) {
runnerGrid.model = null;
runnerGrid.model = runnerModel.modelForRow(0);
queryFinished = true;
var listView = runnerGrid.flickableItem;
if(listView.count > 0) listView.currentIndex = 0;
//console.log(runnerModel.modelForRow(0).modelForRow(0))
}
}
target: runnerModel
2023-09-27 17:50:10 +00:00
}
2024-08-09 01:20:25 +00:00
NavGrid {
id: runnerGrid
anchors.fill: parent
property alias model: runnerGrid.triggerModel
triggerModel: kicker.runnerModel.count ? kicker.runnerModel.modelForRow(0) : null
}
2023-09-27 17:50:10 +00:00
}