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 name = 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"))].description; | ||
gvgeo: if (description) | |||||
37 | var length = Math.min(itemLength, name.length) | ||||
38 | if (currentPort.description.substring(0, length) === name.substring(0, length)) { | ||||
39 | return i18nc("label of device items", "%1 (%2)", currentPort.description, Description); | ||||
40 | } | ||||
38 | } | 41 | } | ||
39 | } | 42 | } | ||
43 | return currentPort.description; | ||||
44 | } else { | ||||
45 | return Description; | ||||
46 | } | ||||
40 | } | 47 | } | ||
41 | labelOpacity: onlyOne ? 1 : 0.6 | | |||
42 | icon: Icon.formFactorIcon(FormFactor) || IconName | | |||
43 | } | 48 | } |
if (description)