Changeset View
Changeset View
Standalone View
Standalone View
containments/desktop/package/contents/ui/ConfigFilter.qml
Show All 39 Lines | 38 | PlasmaCore.SortFilterModel { | |||
---|---|---|---|---|---|
40 | 40 | | |||
41 | sourceModel: Folder.MimeTypesModel { | 41 | sourceModel: Folder.MimeTypesModel { | ||
42 | id: mimeTypesModel | 42 | id: mimeTypesModel | ||
43 | } | 43 | } | ||
44 | 44 | | |||
45 | // SortFilterModel doesn't have a case-sensitivity option | 45 | // SortFilterModel doesn't have a case-sensitivity option | ||
46 | // but filterRegExp always causes case-insensitive sorting. | 46 | // but filterRegExp always causes case-insensitive sorting. | ||
47 | filterRegExp: mimeFilter.text | 47 | filterRegExp: mimeFilter.text | ||
48 | filterRole: "display" | 48 | filterRole: "name" | ||
49 | | ||||
50 | sortRole: mimeTypesView.getColumn(mimeTypesView.sortIndicatorColumn).role | ||||
51 | sortOrder: mimeTypesView.sortIndicatorOrder | ||||
49 | } | 52 | } | ||
50 | 53 | | |||
51 | ColumnLayout { | 54 | ColumnLayout { | ||
52 | width: parent.width | 55 | width: parent.width | ||
53 | height: parent.height | 56 | height: parent.height | ||
54 | 57 | | |||
55 | ComboBox { | 58 | ComboBox { | ||
56 | id: filterMode | 59 | id: filterMode | ||
Show All 32 Lines | 86 | TextField { | |||
89 | 92 | | |||
90 | placeholderText: i18n("Search file type...") | 93 | placeholderText: i18n("Search file type...") | ||
91 | } | 94 | } | ||
92 | 95 | | |||
93 | RowLayout { | 96 | RowLayout { | ||
94 | Layout.fillWidth: true | 97 | Layout.fillWidth: true | ||
95 | Layout.fillHeight: true | 98 | Layout.fillHeight: true | ||
96 | 99 | | |||
97 | ScrollView { | 100 | CheckBox { // Purely for metrics. | ||
101 | id: metricsCheckBox | ||||
102 | visible: false | ||||
103 | } | ||||
104 | | ||||
105 | TableView { | ||||
106 | id: mimeTypesView | ||||
107 | | ||||
108 | // Signal the delegates listen to when user presses space to toggle current row. | ||||
109 | signal toggleCurrent | ||||
110 | | ||||
98 | Layout.fillWidth: true | 111 | Layout.fillWidth: true | ||
99 | Layout.fillHeight: true | 112 | Layout.fillHeight: true | ||
100 | 113 | | |||
101 | frameVisible: true | | |||
102 | | ||||
103 | enabled: (filterMode.currentIndex > 0) | 114 | enabled: (filterMode.currentIndex > 0) | ||
104 | 115 | | |||
105 | ListView { | | |||
106 | model: filderedMimeTypesModel | 116 | model: filderedMimeTypesModel | ||
107 | 117 | | |||
108 | delegate: RowLayout { | 118 | sortIndicatorVisible: true | ||
109 | CheckBox { | 119 | sortIndicatorColumn: 2 // Default to sort by "File type". | ||
110 | Layout.maximumWidth: 18 // FIXME HACK: Use actual radio button width. | | |||
111 | 120 | | |||
112 | checked: model.checked | 121 | onSortIndicatorColumnChanged: { // Disallow sorting by icon. | ||
113 | onCheckedChanged: model.checked = checked | 122 | if (sortIndicatorColumn === 1) { | ||
123 | sortIndicatorColumn = 2; | ||||
124 | } | ||||
114 | } | 125 | } | ||
115 | 126 | | |||
116 | PlasmaCore.IconItem { | 127 | Keys.onSpacePressed: toggleCurrent() | ||
117 | anchors.verticalCenter: parent.verticalCenter | | |||
118 | 128 | | |||
119 | width: units.iconSizes.small | 129 | function adjustColumns() { | ||
120 | height: units.iconSizes.small | 130 | // Resize description column to take whatever space is left. | ||
131 | var width = viewport.width; | ||||
132 | for (var i = 0; i < columnCount - 1; ++i) { | ||||
133 | width -= getColumn(i).width; | ||||
134 | } | ||||
135 | descriptionColumn.width = width; | ||||
136 | } | ||||
137 | | ||||
138 | onWidthChanged: adjustColumns() | ||||
139 | // Component.onCompleted is too early to do this... | ||||
140 | onRowCountChanged: adjustColumns() | ||||
141 | | ||||
142 | TableViewColumn { | ||||
143 | role: "checked" | ||||
144 | width: metricsCheckBox.width | ||||
145 | resizable: false | ||||
146 | movable: false | ||||
121 | 147 | | |||
122 | Layout.maximumWidth: width | 148 | delegate: CheckBox { | ||
123 | Layout.maximumHeight: height | 149 | id: checkBox | ||
124 | 150 | | |||
125 | source: model.decoration | 151 | checked: styleData.value | ||
152 | activeFocusOnTab: false // only let the TableView as a whole get focus | ||||
153 | onClicked: { | ||||
154 | model.checked = checked | ||||
155 | // Clicking it breaks the binding to the model value which becomes | ||||
156 | // an issue during sorting as TableView re-uses delegates. | ||||
157 | checked = Qt.binding(function() { | ||||
158 | return styleData.value; | ||||
159 | }); | ||||
126 | } | 160 | } | ||
127 | 161 | | |||
128 | Label { | 162 | Connections { | ||
129 | Layout.fillWidth: true | 163 | target: mimeTypesView | ||
164 | onToggleCurrent: { | ||||
165 | if (styleData.row === mimeTypesView.currentRow) { | ||||
166 | model.checked = !checkBox.checked | ||||
167 | } | ||||
168 | } | ||||
169 | } | ||||
170 | } | ||||
171 | } | ||||
172 | | ||||
173 | TableViewColumn { | ||||
174 | role: "decoration" | ||||
175 | width: units.iconSizes.small | ||||
176 | resizable: false | ||||
177 | movable: false | ||||
130 | 178 | | |||
131 | text: model.display | 179 | delegate: PlasmaCore.IconItem { | ||
180 | width: units.iconSizes.small | ||||
181 | height: units.iconSizes.small | ||||
182 | animated: false // TableView re-uses delegates, avoid animation when sorting/filtering. | ||||
183 | source: styleData.value | ||||
132 | } | 184 | } | ||
133 | } | 185 | } | ||
186 | | ||||
187 | TableViewColumn { | ||||
188 | id: nameColumn | ||||
189 | role: "name" | ||||
190 | title: i18n("File type") | ||||
191 | width: units.gridUnit * 10 // Assume somewhat reasonable default for mime type name. | ||||
192 | onWidthChanged: mimeTypesView.adjustColumns() | ||||
193 | movable: false | ||||
194 | } | ||||
195 | TableViewColumn { | ||||
196 | id: descriptionColumn | ||||
197 | role: "comment" | ||||
198 | title: i18n("Description") | ||||
199 | movable: false | ||||
200 | resizable: false | ||||
134 | } | 201 | } | ||
135 | } | 202 | } | ||
136 | 203 | | |||
137 | ColumnLayout { | 204 | ColumnLayout { | ||
138 | Layout.alignment: Qt.AlignTop | 205 | Layout.alignment: Qt.AlignTop | ||
206 | // Need to explicitly base the size off the button's implicitWidth | ||||
207 | // to avoid the column from growing way too wide due to fillWidth... | ||||
208 | Layout.maximumWidth: Math.max(selectAllButton.implicitWidth, deselectAllButton.implicitWidth) | ||||
139 | 209 | | |||
140 | Button { | 210 | Button { | ||
211 | id: selectAllButton | ||||
141 | Layout.fillWidth: true | 212 | Layout.fillWidth: true | ||
142 | 213 | | |||
143 | enabled: (filterMode.currentIndex > 0) | 214 | enabled: (filterMode.currentIndex > 0) | ||
144 | 215 | | |||
145 | text: i18n("Select All") | 216 | text: i18n("Select All") | ||
146 | 217 | | |||
147 | onClicked: { | 218 | onClicked: { | ||
148 | mimeTypesModel.checkAll(); | 219 | mimeTypesModel.checkAll(); | ||
149 | } | 220 | } | ||
150 | } | 221 | } | ||
151 | 222 | | |||
152 | Button { | 223 | Button { | ||
224 | id: deselectAllButton | ||||
153 | Layout.fillWidth: true | 225 | Layout.fillWidth: true | ||
154 | 226 | | |||
155 | enabled: (filterMode.currentIndex > 0) | 227 | enabled: (filterMode.currentIndex > 0) | ||
156 | 228 | | |||
157 | text: i18n("Deselect All") | 229 | text: i18n("Deselect All") | ||
158 | 230 | | |||
159 | onClicked: { | 231 | onClicked: { | ||
160 | mimeTypesModel.checkedTypes = ""; | 232 | mimeTypesModel.checkedTypes = ""; | ||
161 | } | 233 | } | ||
162 | } | 234 | } | ||
163 | } | 235 | } | ||
164 | } | 236 | } | ||
165 | } | 237 | } | ||
166 | } | 238 | } |