Changeset View
Changeset View
Standalone View
Standalone View
applet/contents/ui/DeviceListItem.qml
Show All 18 Lines | |||||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | import QtQuick 2.0 | 21 | import QtQuick 2.0 | ||
22 | 22 | | |||
23 | import "../code/icon.js" as Icon | 23 | import "../code/icon.js" as Icon | ||
24 | 24 | | |||
25 | ListItemBase { | 25 | ListItemBase { | ||
26 | readonly property var currentPort: Ports[ActivePortIndex] | 26 | readonly property var currentPort: Ports[ActivePortIndex] | ||
27 | property bool onlyOne: false | | |||
28 | 27 | | |||
29 | draggable: false | 28 | draggable: false | ||
30 | label: { | 29 | label: { | ||
31 | if (!currentPort) { | 30 | if (currentPort) { | ||
32 | return Description | 31 | var model = type === "sink" ? paSinkModel : paSourceModel; | ||
33 | } else { | 32 | var itemLength = currentPort.description.length; | ||
34 | if (onlyOne) { | 33 | for (var i = 0; i < model.rowCount(); i++) { | ||
35 | return currentPort.description | 34 | if (i !== index) { | ||
36 | } else { | 35 | var port = model.data(model.index(i, 0), model.role("Ports")) | ||
37 | return i18nc("label of device items", "%1 (%2)", currentPort.description, Description) | 36 | [model.data(model.index(i, 0), model.role("ActivePortIndex"))]; | ||
gvgeo: if (description) | |||||
37 | if (port.description) { | ||||
38 | var length = Math.min(itemLength, port.description.length) | ||||
39 | if (currentPort.description.substring(0, length) === port.description.substring(0, length)) { | ||||
40 | return i18nc("label of device items", "%1 (%2)", currentPort.description, Description); | ||||
41 | } | ||||
38 | } | 42 | } | ||
39 | } | 43 | } | ||
40 | } | 44 | } | ||
41 | labelOpacity: onlyOne ? 1 : 0.6 | 45 | return currentPort.description; | ||
42 | icon: Icon.formFactorIcon(FormFactor) || IconName | 46 | } else { | ||
47 | return Description; | ||||
48 | } | ||||
49 | } | ||||
43 | } | 50 | } |
if (description)