Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-client-qt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
savoirfairelinux
jami-client-qt
Commits
82c876c0
Commit
82c876c0
authored
4 months ago
by
Andreas Hatziiliou
Browse files
Options
Downloads
Patches
Plain Diff
message_search: remake component
GitLab:
#1827
Change-Id: I877d8a6d15e56c6a8a40ffaa5768ba2812c86d39
parent
83765dce
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/app/mainview/components/MessagesResearchView.qml
+41
-14
41 additions, 14 deletions
src/app/mainview/components/MessagesResearchView.qml
with
41 additions
and
14 deletions
src/app/mainview/components/MessagesResearchView.qml
+
41
−
14
View file @
82c876c0
...
...
@@ -49,6 +49,12 @@ ListView {
MessagesAdapter
.
startSearch
(
prompt
,
false
);
}
onVisibleChanged
:
{
if
(
visible
)
{
MessagesAdapter
.
startSearch
(
prompt
,
true
);
}
}
Connections
{
target
:
researchTabBar
function
onFilterTabChange
()
{
...
...
@@ -56,6 +62,27 @@ ListView {
}
}
// This function will take a filtered message and further format it to fit
// into the research panel in a coherent way. Find the first occurence of the search term in the message
// highlight it and wrap it with numChars characters on either side.
function
formatMessage
(
searchTerm
,
message
,
numChars
)
{
var
index
=
message
.
toLowerCase
().
indexOf
(
searchTerm
.
toLowerCase
());
if
(
index
===
-
1
)
return
message
;
var
prefix
=
message
.
substring
(
Math
.
max
(
0
,
index
-
numChars
),
index
);
var
suffix
=
message
.
substring
(
index
+
searchTerm
.
length
,
Math
.
min
(
index
+
searchTerm
.
length
+
numChars
,
message
.
length
));
var
before
=
(
Math
.
max
(
0
,
index
-
numChars
)
===
0
);
var
after
=
(
Math
.
min
(
index
+
searchTerm
.
length
+
numChars
,
message
.
length
)
===
message
.
length
);
var
highlightedTerm
=
'
<span style="background-color: #48ffff00">
'
+
message
.
substring
(
index
,
index
+
searchTerm
.
length
)
+
"
</span>
"
;
var
result
=
""
;
if
(
!
before
)
result
+=
"
...
"
;
result
+=
prefix
+
highlightedTerm
+
suffix
;
if
(
!
after
)
result
+=
"
...
"
;
return
result
;
}
delegate
:
Item
{
width
:
root
.
width
height
:
msgLayout
.
height
...
...
@@ -75,7 +102,6 @@ ListView {
id
:
timestampItem
showDay
:
true
showTime
:
true
formattedTime
:
MessagesAdapter
.
getFormattedTime
(
Timestamp
)
formattedDay
:
MessagesAdapter
.
getFormattedDay
(
Timestamp
)
}
...
...
@@ -94,55 +120,56 @@ ListView {
showPresenceIndicator
:
false
mode
:
contentRow
.
isMe
?
Avatar
.
Mode
.
Account
:
Avatar
.
Mode
.
Contact
Layout.leftMargin
:
10
Layout.alignment
:
Qt
.
AlignTop
}
ColumnLayout
{
Text
{
text
:
contentRow
.
isMe
?
CurrentAccount
.
bestName
:
UtilsAdapter
.
getBestNameForUri
(
CurrentAccount
.
id
,
Author
)
+
"
:
"
Layout.preferredWidth
:
myText
.
width
Layout.rightMargin
:
10
Layout.leftMargin
:
10
font.pixelSize
:
0
color
:
JamiTheme
.
chatviewSecondaryInformationColor
font.bold
:
true
}
Text
{
Text
Area
{
id
:
myText
text
:
Body
text
:
formatMessage
(
prompt
,
Body
,
100
)
readOnly
:
true
background
:
Rectangle
{
radius
:
5
color
:
JamiTheme
.
messageInBgColor
}
color
:
JamiTheme
.
textColor
Layout.
preferredWidth
:
msgLayout
.
width
-
avatar
.
width
-
30
-
10
eli
de
:
Text
.
ElideRight
Layout.
fillWidth
:
true
wrapMo
de
:
Text
.
Wrap
Layout.rightMargin
:
10
Layout.leftMargin
:
10
textFormat
:
TextEdit
.
MarkdownText
font.pixelSize
:
IsEmojiOnly
?
JamiTheme
.
chatviewEmojiSize
:
JamiTheme
.
chatviewFontSize
Layout.alignment
:
Qt
.
Align
HCenter
Layout.alignment
:
Qt
.
Align
Left
}
}
}
}
Button
{
id
:
buttonJumpTo
visible
:
msgHover
.
hovered
||
hovered
anchors.top
:
msgLayout
.
top
anchors.right
:
msgLayout
.
right
anchors.rightMargin
:
20
anchors.topMargin
:
timestampItem
.
height
-
2
0
anchors.topMargin
:
timestampItem
.
height
-
2
1
width
:
buttonJumpText
.
width
+
10
height
:
buttonJumpText
.
height
+
10
background.visible
:
false
onClicked
:
{
CurrentConversation
.
scrollToMsg
(
Id
);
}
Text
{
id
:
buttonJumpText
text
:
JamiStrings
.
jumpTo
color
:
buttonJumpTo
.
hovered
?
JamiTheme
.
blueLinkColor
:
JamiTheme
.
chatviewSecondaryInformationColor
font.underline
:
buttonJumpTo
.
hovered
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment