Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libdap-qt-ui-qml
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cellframe
libdap-qt-ui-qml
Merge requests
!23
Features 3048
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Features 3048
features-3048
into
develop
Overview
0
Commits
10
Pipelines
0
Changes
4
Merged
tatiana.novikova
requested to merge
features-3048
into
develop
5 years ago
Overview
0
Commits
10
Pipelines
0
Changes
4
Expand
[*] Change DapText interface and logic
👍
0
👎
0
Merge request reports
Compare
develop
develop (base)
and
latest version
latest version
8a2a6fa2
10 commits,
5 years ago
4 files
+
305
−
119
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
4
Search (e.g. *.vue) (Ctrl+P)
widgets/DapComboBox.qml
+
183
−
41
Options
@@ -3,6 +3,7 @@ import QtQuick.Controls 2.0
DapComboBoxForm
{
delegate
:
ItemDelegate
{
@@ -29,64 +30,119 @@ DapComboBoxForm
//Text item
contentItem
:
Text
Rectangle
{
id
:
textDelegateComboBox
id
:
rectTextComboBox
anchors.fill
:
parent
anchors.topMargin
:
paddingTopItemDelegate
anchors.leftMargin
:
popup
.
visible
?
sidePaddingActive
:
sidePaddingNormal
anchors.rightMargin
:
popup
.
visible
?
sidePaddingActive
:
sidePaddingNormal
font
:
fontComboBox
color
:
"
transparent
"
width
:
(
index
!==
currentIndex
)
?
widthPopupComboBoxNormal
-
2
*
sidePaddingActive
-
endRowPadding
:
widthPopupComboBoxNormal
-
indicatorWidth
-
indicatorLeftInterval
-
2
*
sidePaddingActive
//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
id
:
comboBoxFontMetric
font
:
fontComboBox
}
text
:
property
int
comboBoxIndex
:
index
property
int
comboBoxCurrentIndex
:
currentIndex
Row
{
spacing
:
roleInterval
Repeater
{
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
model
:
comboBoxTextRole
.
length
Text
{
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
""
;
id
:
textDelegateComboBox
font
:
fontComboBox
color
:
hovered
?
hilightColorText
:
normalColorText
horizontalAlignment
:
{
if
(
index
===
0
)
return
Text
.
AlignLeft
;
if
(
index
===
comboBoxTextRole
.
length
-
1
)
return
Text
.
AlignRight
;
return
Text
.
AlignHCenter
;
}
width
:
(
rectTextComboBox
.
width
-
roleInterval
*
(
comboBoxTextRole
.
length
-
1
))
/
comboBoxTextRole
.
length
/*{
if(index === 0)
setModelDataWidth(rectTextComboBox.comboBoxIndex, comboBoxFontMetric, rectTextComboBox.width);
console.log("comboBoxIndex", rectTextComboBox.comboBoxIndex, "index", index, "comboBoxTextRole", comboBoxTextRole[index])
return comboBoxTextRoleWidth[index];
}*/
TextMetrics
{
id
:
comboBoxTextMetric
font
:
fontComboBox
elide
:
Text
.
ElideRight
text
:
getModelData
(
rectTextComboBox
.
comboBoxIndex
,
comboBoxTextRole
[
index
])
elideWidth
:
textDelegateComboBox
.
width
}
/*Component.onCompleted:
{
setModelDataWidth(rectTextComboBox.comboBoxIndex, comboBoxFontMetric, rectTextComboBox.width);
textDelegateComboBox.width = comboBoxTextRoleWidth[index];
}*/
text
:
{
if
(
rectTextComboBox
.
comboBoxIndex
!=
rectTextComboBox
.
comboBoxCurrentIndex
)
{
if
(
comboBoxTextMetric
.
elideWidth
<
comboBoxFontMetric
.
tightBoundingRect
(
comboBoxTextMetric
.
text
).
width
)
return
checkElidedText
(
comboBoxFontMetric
,
comboBoxTextMetric
);
else
if
(
comboBoxTextMetric
.
elideWidth
===
comboBoxFontMetric
.
tightBoundingRect
(
comboBoxTextMetric
.
text
).
width
)
return
comboBoxTextMetric
.
text
;
else
return
comboBoxTextMetric
.
elidedText
.
replace
(
'
…
'
,
'
..
'
);
}
else
{
if
(
popup
.
visible
)
{
if
(
comboBoxTextMetric
.
elideWidth
<
comboBoxFontMetric
.
tightBoundingRect
(
comboBoxTextMetric
.
text
).
width
)
mainLineText
[
index
]
=
checkElidedText
(
comboBoxFontMetric
,
comboBoxTextMetric
);
else
{
if
(
comboBoxTextMetric
.
elideWidth
===
comboBoxFontMetric
.
tightBoundingRect
(
comboBoxTextMetric
.
text
).
width
)
mainLineText
[
index
]
=
comboBoxTextMetric
.
text
;
else
mainLineText
[
index
]
=
comboBoxTextMetric
.
elidedText
.
replace
(
'
…
'
,
'
..
'
);
}
}
else
{
if
(
index
===
0
)
mainLineText
[
index
]
=
comboBoxFontMetric
.
elidedText
(
getModelData
(
rectTextComboBox
.
comboBoxIndex
,
comboBoxTextRole
[
index
]),
Text
.
ElideRight
,
(
widthPopupComboBoxNormal
-
indicatorWidth
-
indicatorLeftInterval
),
Qt
.
TextShowMnemonic
).
replace
(
'
…
'
,
'
..
'
);
}
console
.
log
(
"
mainLineText[index]
"
,
"
index
"
,
mainLineText
[
index
],
index
)
return
""
;
}
}
}
}
color
:
hovered
?
hilightColorText
:
normalColorText
Rectangle
{
id
:
endRowRectangle
height
:
parent
.
height
width
:
endRowPadding
color
:
"
transparent
"
}
}
}
//Indent from the bottom edge or the next line that will not stand out when you hover over the mouse
background
:
Rectangle
@@ -108,4 +164,90 @@ DapComboBoxForm
}
highlighted
:
parent
.
highlightedIndex
===
index
}
function
checkElidedText
(
fontMetric
,
textMetric
)
{
return
textMetric
.
elidedText
.
substring
(
0
,
textMetric
.
elidedText
.
length
-
1
)
+
((
fontMetric
.
tightBoundingRect
(
textMetric
.
elidedText
.
substring
(
0
,
textMetric
.
elidedText
.
length
-
1
)).
width
+
fontMetric
.
tightBoundingRect
(
textMetric
.
text
.
charAt
(
textMetric
.
elidedText
.
length
-
1
)
+
'
..
'
).
width
)
<
textMetric
.
elideWidth
?
(
textMetric
.
text
.
charAt
(
textMetric
.
elidedText
.
length
-
1
)
+
'
..
'
)
:
'
..
'
);
}
function
getModelData
(
rowIndex
,
modelRole
)
{
return
model
.
get
(
rowIndex
)[
modelRole
];
}
function
setModelDataWidth
(
rowIndex
,
fontMetric
,
rowWidth
)
{
comboBoxTextRoleWidth
=
[
0
];
mainLineText
=
[
""
];
var
neededWidth
=
0
;
for
(
var
i
=
0
;
i
<
comboBoxTextRole
.
length
;
i
++
)
{
mainLineText
[
i
]
=
""
;
comboBoxTextRoleWidth
[
i
]
=
fontMetric
.
tightBoundingRect
(
getModelData
(
rowIndex
,
comboBoxTextRole
[
i
])).
width
;
neededWidth
+=
comboBoxTextRoleWidth
[
i
];
}
neededWidth
+=
roleInterval
*
(
comboBoxTextRole
.
length
-
1
);
console
.
log
(
"
neededWidth
"
,
neededWidth
,
"
rowWidth
"
,
rowWidth
);
var
oneIndex
=
0
;
if
(
neededWidth
>
rowWidth
)
{
oneIndex
=
comboBoxTextRole
.
indexOf
(
mainLineRole
);
if
(
oneIndex
===
-
1
)
{
oneIndex
=
comboBoxTextRole
.
indexOf
(
"
text
"
);
if
(
oneIndex
===
-
1
)
{
oneIndex
=
comboBoxTextRole
.
indexOf
(
"
name
"
);
if
(
oneIndex
===
-
1
)
oneIndex
=
0
;
}
}
if
(
comboBoxTextRoleWidth
[
oneIndex
]
<
neededWidth
-
rowWidth
)
{
comboBoxTextRoleWidth
[
oneIndex
]
=
rowWidth
/
(
comboBoxTextRole
.
length
);
var
maxWidth
=
0
;
var
maxIndex
=
0
;
while
(
neededWidth
>
rowWidth
)
{
maxWidth
=
comboBoxTextRoleWidth
[
0
];
maxIndex
=
0
;
for
(
i
=
0
;
i
<
comboBoxTextRoleWidth
.
length
;
i
++
)
{
if
(
maxWidth
<
comboBoxTextRoleWidth
[
i
])
{
maxWidth
=
comboBoxTextRoleWidth
[
i
];
maxIndex
=
i
;
}
}
comboBoxTextRoleWidth
[
maxIndex
]
-=
10
*
pt
;
neededWidth
=
0
;
for
(
i
=
0
;
i
<
comboBoxTextRoleWidth
.
length
;
i
++
)
neededWidth
+=
comboBoxTextRoleWidth
[
i
];
}
}
return
true
;
}
if
(
neededWidth
<
rowWidth
)
{
oneIndex
=
comboBoxTextRole
.
indexOf
(
mainLineRole
);
if
(
oneIndex
===
-
1
)
{
oneIndex
=
comboBoxTextRole
.
indexOf
(
"
text
"
);
if
(
oneIndex
===
-
1
)
{
oneIndex
=
comboBoxTextRole
.
indexOf
(
"
name
"
);
if
(
oneIndex
===
-
1
)
oneIndex
=
0
;
}
}
comboBoxTextRoleWidth
[
oneIndex
]
+=
rowWidth
-
neededWidth
;
return
true
;
}
return
false
;
}
}
Loading