Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attempt to support hiding search, timeline and fstab devices #4

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})

find_package(KF5Plasma)

plasma_install_package(package org.kde.placesWidget)
kpackage_install_bundled_package(package org.kde.placesWidget)
8 changes: 7 additions & 1 deletion package/contents/config/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@
<entry name="showHidden" type="bool">
<default>false</default>
</entry>
<entry name="showDevices" type="bool">
<entry name="showTimeline" type="bool">
<default>true</default>
</entry>
<entry name="showSearch" type="bool">
<default>true</default>
</entry>
<entry name="showDevices" type="int">
<default>0</default>
</entry>
<entry name="widgetWidth" type="int">
<default>250</default>
</entry>
Expand Down
91 changes: 73 additions & 18 deletions package/contents/ui/FullRepresentation.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
import QtQuick 2.5
import QtQuick.Layouts 1.1
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.core 2.1 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.extras 2.0 as PlasmaExtras

Expand All @@ -41,38 +41,93 @@ Item {
}

PlasmaCore.SortFilterModel {
id: placesHiddenFilterModel
id: placesNoHidden
sourceModel: placesSource.models.places
filterRole: 'hidden'
filterRegExp: 'false'
}

property var placesMaybeHidden : {
if (showHidden) {
return placesSource.models.places
} else {
return placesNoHidden
}
}

PlasmaCore.SortFilterModel {
id: placesDeviceFilterModel
sourceModel: placesSource.models.places
filterRole: 'isDevice'
filterRegExp: 'false'
id: placesNoTimeline
sourceModel: placesMaybeHidden
filterRole: 'url'
filterRegExp: '^(?!timeline:).*$'
}


property var placesMaybeTimeline : {
if (showTimeline) {
return placesMaybeHidden
} else {
return placesNoTimeline
}
}

PlasmaCore.SortFilterModel {
id: placesNoSearch
sourceModel: placesMaybeTimeline
filterRole: 'url'
filterRegExp: '^(?!search:).*$'
}

property var placesMaybeSearch : {
if (showSearch) {
return placesMaybeTimeline
} else {
return placesNoSearch
}
}


PlasmaCore.SortFilterModel {
id: placesHiddenDevicesFilterModel
sourceModel: placesHiddenFilterModel
id: placesNoDevice
sourceModel: placesMaybeSearch
filterRole: 'isDevice'
filterRegExp: 'false'
}

property var currentModel: {
if (!showHidden && !showDevices) {
return placesHiddenDevicesFilterModel
} else if (!showHidden) {
return placesHiddenFilterModel
} else if (!showDevices) {
return placesDeviceFilterModel

PlasmaCore.SortFilterModel {
id: placesNoFstabDevice
sourceModel: placesMaybeSearch
filterRole : 'path'
filterCallback:
function pasFstab(source_row, value) {
var idx = sourceModel.index(source_row, 0);
/*return source_row["isDevice"] == "false"
|| source_row["setupNeeded"] == "true"
|| source_row["fixedDevice"] == "false"
|| source_row["path"].substring(0, 7) != "/media/";*/
return sourceModel.data(idx, sourceModel.role("isDevice")) == "false"
|| sourceModel.data(idx, sourceModel.role("setupNeeded")) == "true"
|| sourceModel.data(idx, sourceModel.role("fixedDevice")) == "false"
|| sourceModel.data(idx, sourceModel.role("path")).substring(0, 7) == "/media/";
}
}

property var placesMaybeDevice : {
if (showDevices == 1) {
return placesNoDevice
} else {
return placesSource.models.places
if (showDevices == 2) {
return placesNoFstabDevice
} else {
return placesMaybeSearch
}
}
}


property var currentModel: {
return placesMaybeDevice
}

PlasmaExtras.ScrollArea {
anchors.fill: parent

Expand Down
25 changes: 21 additions & 4 deletions package/contents/ui/config/ConfigGeneral.qml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ import QtQuick.Layouts 1.1

Item {
property alias cfg_showHidden: showHidden.checked
property alias cfg_showDevices: showDevices.checked
property alias cfg_showTimeline: showTimeline.checked
property alias cfg_showSearch: showSearch.checked
property alias cfg_showDevices: showDevices.currentIndex
property alias cfg_widgetWidth: widgetWidth.value

property var mediumSpacing: 1.5*units.smallSpacing
Expand All @@ -33,13 +35,28 @@ Item {
text: i18n('Show hidden places')
Layout.columnSpan: 2
}

CheckBox {
id: showDevices
text: i18n('Show devices')
id: showTimeline
text: i18n('Show Timeline places')
Layout.columnSpan: 2
}

CheckBox {
id: showSearch
text: i18n('Show Search places')
Layout.columnSpan: 2
}

Label {
text: i18n('Show devices')
}

ComboBox {
id: showDevices
model: [{text: i18n('All'), value:0}, {text: i18n('None'), value:1}, {text: i18n('Only those not present in fstab'), value:2}]
}

Label {
text: i18n('Widget width:')
}
Expand Down
4 changes: 3 additions & 1 deletion package/contents/ui/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ import org.kde.plasma.core 2.0 as PlasmaCore

Item {
property bool showHidden: plasmoid.configuration.showHidden
property bool showDevices: plasmoid.configuration.showDevices
property bool showTimeline: plasmoid.configuration.showTimeline
property bool showSearch: plasmoid.configuration.showSearch
property int showDevices: plasmoid.configuration.showDevices
property int widgetWidth: plasmoid.configuration.widgetWidth

Plasmoid.compactRepresentation: PlasmaCore.IconItem {
Expand Down
6 changes: 3 additions & 3 deletions package/metadata.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ Name=Places Widget
Comment=Gives access to user places
Type=Service
X-KDE-ParentApp=
X-KDE-PluginInfo-Author=Daniel Faust
X-KDE-PluginInfo-Author=Daniel Faust & Yann Salmon
[email protected]
X-KDE-PluginInfo-License=GPL2
X-KDE-PluginInfo-Name=org.kde.placesWidget
X-KDE-PluginInfo-Version=1.2
X-KDE-PluginInfo-Website=https://github.com/dfaust/plasma-applet-places-widget
X-KDE-PluginInfo-Version=1.3
X-KDE-PluginInfo-Website=https://github.com/yannsalmon/plasma-applet-places-widget
X-KDE-ServiceTypes=Plasma/Applet
X-Plasma-API=declarativeappletscript
X-Plasma-MainScript=ui/main.qml
Expand Down