Newer
Older

tatiana.novikova
committed
import QtQuick 2.4

tatiana.novikova
committed
delegate:
ItemDelegate
{
width: parent.width

tatiana.novikova
committed
//Adjusting the height of the line, taking into account that the second element from the end may be the last
height:
{
if(index != currentIndex)
{
if(index == (count - 2))
{
if(index+1 == currentIndex)
return heightListElement + bottomIntervalListElement
else
return heightListElement + intervalListElement
}
if (index == count - 1)
return heightListElement + bottomIntervalListElement
return heightListElement + intervalListElement
}
else return 0
}

tatiana.novikova
committed
//Text item
contentItem:
Text

tatiana.novikova
committed
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
id:textDelegateComboBox
anchors.fill: parent
anchors.topMargin: paddingTopItemDelegate
anchors.leftMargin: popup.visible ? sidePaddingActive : sidePaddingNormal
anchors.rightMargin: popup.visible ? sidePaddingActive : sidePaddingNormal
font: fontComboBox
//Calculates various properties of a given string of text for a particular font
TextMetrics
{
id: tm
font: fontComboBox
elide: Text.ElideRight
text: modelData
elideWidth:
{
if(index != currentIndex)
return widthPopupComboBoxActive - 2*sidePaddingActive;
else
return widthPopupComboBoxNormal - indicatorWidth - indicatorLeftInterval;
}
}
FontMetrics
{
id: fm
font: fontComboBox
}
text:
{
if(index != currentIndex)
{
if(tm.elidedText.length < tm.text.length)
return tm.elidedText.substring(0, tm.elidedText.length-1) +
((fm.tightBoundingRect(tm.elidedText.substring(0, tm.elidedText.length-1)).width +
fm.tightBoundingRect(tm.text.charAt(tm.elidedText.length-1) + '..').width) < tm.elideWidth ?
(tm.text.charAt(tm.elidedText.length-1) + '..')
: '..');
return tm.elidedText.replace('…', '..');
}
else
{
if(tm.elidedText.length < tm.text.length)
mainLineText = tm.elidedText.substring(0, tm.elidedText.length-1) +
((fm.tightBoundingRect(tm.elidedText.substring(0, tm.elidedText.length-1)).width +
fm.tightBoundingRect(tm.text.charAt(tm.elidedText.length-1) + '..').width) < tm.elideWidth ?
(tm.text.charAt(tm.elidedText.length-1) + '..')
: '..');
else
mainLineText = tm.elidedText.replace('…', '..');
return "";
}
}
color: hovered ? hilightColorText : normalColorText

tatiana.novikova
committed
//Indent from the bottom edge or the next line that will not stand out when you hover over the mouse
background:
Rectangle

tatiana.novikova
committed
anchors.fill: parent
anchors.bottomMargin: {
if(index == count - 2)
{
if(index+1 == currentIndex)
return bottomIntervalListElement
else
return intervalListElement
}
if (index == count - 1)
return bottomIntervalListElement
return intervalListElement
}
color: hovered ? hilightColor : normalColor

tatiana.novikova
committed
highlighted: parent.highlightedIndex === index