2021-09-29 17:10:18 +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
|
|
|
|
import org.kde.plasma.components 2.0 as PlasmaComponents
|
|
|
|
|
|
|
|
import org.kde.plasma.private.kicker 0.1 as Kicker
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: searchViewContainer
|
|
|
|
|
|
|
|
objectName: "SearchView"
|
|
|
|
|
2024-01-20 02:08:06 +00:00
|
|
|
function decrementCurrentIndex() {
|
|
|
|
runnerGrid.modelIndex--;
|
2021-09-29 17:10:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function incrementCurrentIndex() {
|
2024-01-20 02:08:06 +00:00
|
|
|
runnerGrid.modelIndex++;
|
2021-09-29 17:10:18 +00:00
|
|
|
}
|
|
|
|
|
2024-01-20 02:08:06 +00:00
|
|
|
function activateCurrentIndex() {
|
|
|
|
runnerGrid.tryActivate();
|
|
|
|
//runnerModel.currentItem.activate();
|
2021-09-29 17:10:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function openContextMenu() {
|
2022-08-28 21:48:51 +00:00
|
|
|
runnerModel.currentItem.openActionMenu();
|
2021-09-29 17:10:18 +00:00
|
|
|
}
|
2023-08-24 22:32:11 +00:00
|
|
|
function setCurrentIndex() {
|
2024-01-20 02:08:06 +00:00
|
|
|
runnerGrid.modelIndex = 0;
|
2023-08-24 22:32:11 +00:00
|
|
|
}
|
|
|
|
function resetCurrentIndex() {
|
|
|
|
runnerModel.currentIndex = -1;
|
|
|
|
}
|
2021-09-29 17:10:18 +00:00
|
|
|
function onQueryChanged() {
|
2024-01-20 02:08:06 +00:00
|
|
|
queryFinished = false;
|
2021-09-29 17:10:18 +00:00
|
|
|
runnerModel.query = searchField.text;
|
|
|
|
|
|
|
|
if (!searchField.text) {
|
2023-08-24 22:32:11 +00:00
|
|
|
repeaterModelIndex = 0;
|
|
|
|
runnerGrid.repeater.currentModelIndex = 0;
|
2023-09-22 22:51:26 +00:00
|
|
|
if(runnerModel.model) runnerModel.model = null;
|
2023-08-24 22:32:11 +00:00
|
|
|
} else {
|
|
|
|
if(runnerGrid.count != 0) {
|
|
|
|
runnerGrid.repeater.currentModelIndex = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-01-20 02:08:06 +00:00
|
|
|
property bool queryFinished: false
|
2023-08-24 22:32:11 +00:00
|
|
|
property int repeaterModelIndex: 0
|
|
|
|
onFocusChanged: {
|
|
|
|
|
|
|
|
if(runnerGrid.count != 0) {
|
|
|
|
if(!focus) repeaterModelIndex = runnerGrid.repeater.currentModelIndex;
|
|
|
|
else {
|
|
|
|
runnerGrid.repeater.currentModelIndex = repeaterModelIndex;
|
2021-09-29 17:10:18 +00:00
|
|
|
}
|
2023-08-24 22:32:11 +00:00
|
|
|
}
|
2021-09-29 17:10:18 +00:00
|
|
|
}
|
2023-08-24 22:32:11 +00:00
|
|
|
property Item itemGrid: runnerGrid
|
|
|
|
|
2021-09-29 17:10:18 +00:00
|
|
|
|
|
|
|
Kicker.RunnerModel {
|
|
|
|
id: runnerModel
|
|
|
|
appletInterface: plasmoid
|
2022-08-28 21:48:51 +00:00
|
|
|
mergeResults: false
|
2021-09-29 17:10:18 +00:00
|
|
|
favoritesModel: globalFavorites
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: runnerModel
|
|
|
|
|
2024-01-20 02:08:06 +00:00
|
|
|
/*function onQueryFinished() {
|
|
|
|
if (runnerModel.count) {
|
|
|
|
runnerGrid.model = null;
|
|
|
|
runnerGrid.model = runnerModel;
|
|
|
|
queryFinished = true;
|
|
|
|
}
|
2022-08-28 21:48:51 +00:00
|
|
|
|
2024-01-20 02:08:06 +00:00
|
|
|
}*/
|
|
|
|
/*function onCountChanged() {
|
2022-08-28 21:48:51 +00:00
|
|
|
if (runnerModel.count && !runnerGrid.model) {
|
|
|
|
runnerGrid.model = runnerModel;
|
2021-09-29 17:10:18 +00:00
|
|
|
}
|
2024-01-20 02:08:06 +00:00
|
|
|
}*/
|
2021-09-29 17:10:18 +00:00
|
|
|
}
|
|
|
|
|
2022-08-28 21:48:51 +00:00
|
|
|
ItemMultiGridView {
|
2023-08-24 22:32:11 +00:00
|
|
|
id: runnerGrid
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.leftMargin: units.smallSpacing;
|
|
|
|
z: 9999
|
|
|
|
aCellWidth: parent.width - units.smallSpacing*2
|
2024-01-20 02:08:06 +00:00
|
|
|
aCellHeight: units.iconSizes.small + units.smallSpacing + units.smallSpacing/2
|
2023-08-24 22:32:11 +00:00
|
|
|
|
|
|
|
enabled: searchField.text
|
|
|
|
isSquare: false
|
|
|
|
model: runnerModel
|
2024-01-20 02:08:06 +00:00
|
|
|
//grabFocus: true
|
2023-08-24 22:32:11 +00:00
|
|
|
}
|
2021-09-29 17:10:18 +00:00
|
|
|
|
|
|
|
}
|