Changeset View
Changeset View
Standalone View
Standalone View
plasmacalendarintegration/HolidaysConfig.qml
Show All 13 Lines | |||||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | 16 | * GNU General Public License for more details. | ||
17 | * | 17 | * | ||
18 | * You should have received a copy of the GNU General Public License | 18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program. If not, see <http://www.gnu.org/licenses/> | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/> | ||
20 | */ | 20 | */ | ||
21 | 21 | | |||
22 | import QtQuick 2.0 | 22 | import QtQuick 2.5 | ||
23 | import QtQuick.Controls 1.2 as QtControls | 23 | import QtQuick.Controls 1.4 as QQC1 | ||
24 | import QtQuick.Layouts 1.0 | 24 | import QtQuick.Controls 2.5 as QQC2 | ||
25 | import QtQuick.Layouts 1.3 | ||||
25 | import QtQuick.Dialogs 1.1 | 26 | import QtQuick.Dialogs 1.1 | ||
26 | 27 | | |||
27 | import org.kde.plasma.core 2.1 as PlasmaCore | 28 | import org.kde.plasma.core 2.1 as PlasmaCore | ||
28 | import org.kde.plasma.components 2.0 as PlasmaComponents | 29 | import org.kde.plasma.components 2.0 as PlasmaComponents | ||
29 | import org.kde.kholidays 1.0 as KHolidays | 30 | import org.kde.kholidays 1.0 as KHolidays | ||
30 | import org.kde.holidayeventshelperplugin 1.0 | 31 | import org.kde.holidayeventshelperplugin 1.0 | ||
31 | 32 | | |||
32 | Item { | 33 | ColumnLayout { | ||
33 | id: holidaysConfig | 34 | id: holidaysConfig | ||
34 | width: parent.width | 35 | anchors.left: parent.left | ||
35 | height: parent.height | 36 | anchors.right: parent.right | ||
36 | 37 | | |||
37 | signal configurationChanged | 38 | signal configurationChanged | ||
38 | 39 | | |||
39 | function saveConfig() | 40 | function saveConfig() | ||
40 | { | 41 | { | ||
41 | configHelper.saveConfig(); | 42 | configHelper.saveConfig(); | ||
42 | } | 43 | } | ||
43 | 44 | | |||
44 | // This is just for getting the column width | 45 | // This is just for getting the column width | ||
45 | QtControls.CheckBox { | 46 | QQC2.CheckBox { | ||
46 | id: checkbox | 47 | id: checkbox | ||
47 | visible: false | 48 | visible: false | ||
48 | } | 49 | } | ||
49 | 50 | | |||
50 | QmlConfigHelper { | 51 | QmlConfigHelper { | ||
51 | id: configHelper | 52 | id: configHelper | ||
52 | } | 53 | } | ||
53 | 54 | | |||
54 | ColumnLayout { | 55 | QQC2.TextField { | ||
55 | anchors.fill: parent | | |||
56 | | ||||
57 | QtControls.TextField { | | |||
58 | id: filter | 56 | id: filter | ||
59 | Layout.fillWidth: true | 57 | Layout.fillWidth: true | ||
60 | placeholderText: i18nd("kholidays_calendar_plugin", "Search Holiday Regions") | 58 | placeholderText: i18nd("kholidays_calendar_plugin", "Search...") | ||
61 | } | 59 | } | ||
62 | 60 | | |||
63 | QtControls.TableView { | 61 | // Still QQC1 bevcause there's no QQC2 TableView | ||
62 | QQC1.TableView { | ||||
64 | id: holidaysView | 63 | id: holidaysView | ||
65 | 64 | | |||
66 | signal toggleCurrent | 65 | signal toggleCurrent | ||
67 | 66 | | |||
68 | Layout.fillWidth: true | 67 | Layout.fillWidth: true | ||
69 | Layout.fillHeight: true | 68 | Layout.fillHeight: true | ||
70 | 69 | | |||
71 | Keys.onSpacePressed: toggleCurrent() | 70 | Keys.onSpacePressed: toggleCurrent() | ||
72 | 71 | | |||
73 | model: PlasmaCore.SortFilterModel { | 72 | model: PlasmaCore.SortFilterModel { | ||
74 | sourceModel: KHolidays.HolidayRegionsModel { | 73 | sourceModel: KHolidays.HolidayRegionsModel { | ||
75 | id: holidaysModel | 74 | id: holidaysModel | ||
76 | } | 75 | } | ||
77 | // SortFilterModel doesn't have a case-sensitivity option... | 76 | // SortFilterModel doesn't have a case-sensitivity option... | ||
78 | // but filterRegExp always causes case-insensitive sorting | 77 | // but filterRegExp always causes case-insensitive sorting | ||
79 | filterRegExp: filter.text | 78 | filterRegExp: filter.text | ||
80 | filterRole: "name" | 79 | filterRole: "name" | ||
81 | } | 80 | } | ||
82 | 81 | | |||
83 | QtControls.TableViewColumn { | 82 | QQC1.TableViewColumn { | ||
84 | width: checkbox.width | 83 | width: checkbox.width | ||
85 | delegate: QtControls.CheckBox { | 84 | delegate: QQC2.CheckBox { | ||
86 | id: checkBox | 85 | id: checkBox | ||
87 | anchors.centerIn: parent | 86 | anchors.centerIn: parent | ||
88 | checked: model ? configHelper.selectedRegions.indexOf(model.region) !== -1 : false | 87 | checked: model ? configHelper.selectedRegions.indexOf(model.region) !== -1 : false | ||
89 | activeFocusOnTab: false // only let the TableView as a whole get focus | 88 | activeFocusOnTab: false // only let the TableView as a whole get focus | ||
90 | onClicked: { | 89 | onClicked: { | ||
91 | //needed for model's setData to be called | 90 | //needed for model's setData to be called | ||
92 | if (checked) { | 91 | if (checked) { | ||
93 | configHelper.addRegion(model.region); | 92 | configHelper.addRegion(model.region); | ||
94 | } else { | 93 | } else { | ||
95 | configHelper.removeRegion(model.region); | 94 | configHelper.removeRegion(model.region); | ||
96 | } | 95 | } | ||
97 | holidaysConfig.configurationChanged(); | 96 | holidaysConfig.configurationChanged(); | ||
98 | } | 97 | } | ||
99 | } | 98 | } | ||
100 | 99 | | |||
101 | resizable: false | 100 | resizable: false | ||
102 | movable: false | 101 | movable: false | ||
103 | } | 102 | } | ||
104 | QtControls.TableViewColumn { | 103 | QQC1.TableViewColumn { | ||
105 | role: "region" | 104 | role: "region" | ||
106 | title: i18nd("kholidays_calendar_plugin", "Region") | 105 | title: i18nd("kholidays_calendar_plugin", "Region") | ||
107 | } | 106 | } | ||
108 | QtControls.TableViewColumn { | 107 | QQC1.TableViewColumn { | ||
109 | role: "name" | 108 | role: "name" | ||
110 | title: i18nd("kholidays_calendar_plugin", "Name") | 109 | title: i18nd("kholidays_calendar_plugin", "Name") | ||
111 | } | 110 | } | ||
112 | QtControls.TableViewColumn { | 111 | QQC1.TableViewColumn { | ||
113 | role: "description" | 112 | role: "description" | ||
114 | title: i18nd("kholidays_calendar_plugin", "Description") | 113 | title: i18nd("kholidays_calendar_plugin", "Description") | ||
115 | } | 114 | } | ||
116 | } | 115 | } | ||
117 | } | 116 | } | ||
118 | } | |