Skip to content
Snippets Groups Projects
Commit b1d2addd authored by Ksard's avatar Ksard
Browse files

[*] Update calculating and deleting the unnecessary part of text at comboBox

parent d1852d4b
No related branches found
No related tags found
1 merge request!14Features 2603
import QtQuick 2.7
import QtQuick 2.4
import QtQuick.Controls 2.0
DapComboBoxForm
{
id:dapComboBox
//temporary variable for the calculating unnecessary part of text
property int stringSize
delegate:ItemDelegate
{
......@@ -33,6 +30,7 @@ DapComboBoxForm
anchors.fill: parent
anchors.topMargin: paddingTopItemDelegate
anchors.leftMargin: popup.visible ? sidePaddingActive : sidePaddingNormal
anchors.rightMargin: popup.visible ? sidePaddingActive : sidePaddingNormal
font:dapComboBox.font
//Calculates various properties of a given string of text for a particular font
TextMetrics
......@@ -40,19 +38,23 @@ DapComboBoxForm
id: tm
font: dapComboBox.font
elide: Text.ElideRight
elideWidth: parent.width - (popup.visible ? sidePaddingActive : sidePaddingNormal) * 2 - 8*pt
text: modelData
elideWidth:
{
if(index != currentIndex)
return widthPopupComboBoxActive - 2*sidePaddingActive;
else
return widthPopupComboBoxNormal - indicatorWidth ;
}
}
text:
{
if(index != currentIndex)
return modelData;
return tm.elidedText.replace('', '..');
else
{
stringSize = tm.elidedText.length;
if(stringSize < modelData.length)
mainLineText = tm.elidedText.substring(0, stringSize-3) + '..';
else mainLineText = modelData;
mainLineText = tm.elidedText.replace('', '..');
return "";
}
}
......
......@@ -102,7 +102,7 @@ ComboBox
Text
{
id:textTopComboBox
anchors.fill: parent
anchors.left: parent.left
anchors.leftMargin: popup.visible ? sidePaddingActive : sidePaddingNormal
text: mainLineText
font: parent.font
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment