Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in / Register
Toggle navigation
J
jami-client-windows
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Security & Compliance
Security & Compliance
Dependency List
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
savoirfairelinux
jami-client-windows
Commits
6b5ad3e2
Commit
6b5ad3e2
authored
Jan 02, 2019
by
Andreas Traczyk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
callwidget: fix handling of smartlist for calls
Change-Id: If360b3f73a22f8cdfc140f1be2716390bfb9ccb0
parent
3fc824d7
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
125 additions
and
95 deletions
+125
-95
callwidget.cpp
callwidget.cpp
+70
-79
callwidget.h
callwidget.h
+2
-2
callwidget.ui
callwidget.ui
+6
-0
conversationitemdelegate.cpp
conversationitemdelegate.cpp
+8
-2
smartlistmodel.cpp
smartlistmodel.cpp
+19
-10
smartlistmodel.h
smartlistmodel.h
+4
-2
utils.cpp
utils.cpp
+15
-0
utils.h
utils.h
+1
-0
No files found.
callwidget.cpp
View file @
6b5ad3e2
This diff is collapsed.
Click to expand it.
callwidget.h
View file @
6b5ad3e2
...
...
@@ -133,8 +133,7 @@ private:
void
setConversationFilter
(
lrc
::
api
::
profile
::
Type
filter
);
void
updateConversationsFilterWidget
();
void
updateComboBox
();
const
std
::
string
&
selectedAccountId
();
const
std
::
string
&
selectedConvUid
();
void
connectAccount
(
const
std
::
string
&
accId
);
QMenu
*
menu_
;
...
...
@@ -166,5 +165,6 @@ private:
QMetaObject
::
Connection
smartlistSelectionConnection_
;
QMetaObject
::
Connection
interactionRemovedConnection_
;
QMetaObject
::
Connection
contactAddedConnection_
;
QMetaObject
::
Connection
callStatusChangedConnection_
;
};
callwidget.ui
View file @
6b5ad3e2
...
...
@@ -381,6 +381,12 @@
<attribute
name=
"headerVisible"
>
<bool>
false
</bool>
</attribute>
<attribute
name=
"headerDefaultSectionSize"
>
<number>
0
</number>
</attribute>
<attribute
name=
"headerMinimumSectionSize"
>
<number>
0
</number>
</attribute>
</widget>
</item>
</layout>
...
...
conversationitemdelegate.cpp
View file @
6b5ad3e2
...
...
@@ -62,9 +62,15 @@ ConversationItemDelegate::paint(QPainter* painter
// menu is open
auto
rowHighlight
=
highlightMap_
.
find
(
index
.
row
());
if
(
selected
)
{
painter
->
fillRect
(
option
.
rect
,
RingTheme
::
smartlistSelection_
);
painter
->
fillRect
(
option
.
rect
,
RingTheme
::
smartlistSelection_
);
}
else
if
(
rowHighlight
!=
highlightMap_
.
end
()
&&
(
*
rowHighlight
).
second
)
{
painter
->
fillRect
(
option
.
rect
,
RingTheme
::
smartlistHighlight_
);
painter
->
fillRect
(
option
.
rect
,
RingTheme
::
smartlistHighlight_
);
}
auto
convUid
=
index
.
data
(
static_cast
<
int
>
(
SmartListModel
::
Role
::
UID
)).
value
<
QString
>
().
toStdString
();
auto
conversation
=
Utils
::
getConversationFromUid
(
convUid
,
*
LRCInstance
::
getCurrentConversationModel
());
if
(
LRCInstance
::
getCurrentCallModel
()
->
hasCall
(
conversation
->
callId
))
{
auto
color
=
QColor
(
RingTheme
::
blue_
.
lighter
(
180
));
color
.
setAlpha
(
128
);
painter
->
fillRect
(
option
.
rect
,
color
);
}
QRect
&
rect
=
opt
.
rect
;
...
...
smartlistmodel.cpp
View file @
6b5ad3e2
...
...
@@ -30,17 +30,19 @@
// Client
#include "pixbufmanipulator.h"
#include "utils.h"
#include "lrcinstance.h"
SmartListModel
::
SmartListModel
(
const
lrc
::
api
::
account
::
Info
&
acc
,
QObject
*
parent
)
SmartListModel
::
SmartListModel
(
const
std
::
string
&
accId
,
QObject
*
parent
)
:
QAbstractItemModel
(
parent
),
acc
_
(
acc
)
acc
Id_
(
accId
)
{
}
int
SmartListModel
::
rowCount
(
const
QModelIndex
&
parent
)
const
{
if
(
!
parent
.
isValid
())
{
return
acc_
.
conversationModel
->
allFilteredConversations
().
size
();
auto
&
accInfo
=
LRCInstance
::
accountModel
().
getAccountInfo
(
accId_
);
return
accInfo
.
conversationModel
->
allFilteredConversations
().
size
();
}
return
0
;
// A valid QModelIndex returns 0 as no entry has sub-elements
}
...
...
@@ -57,32 +59,33 @@ QVariant SmartListModel::data(const QModelIndex &index, int role) const
return
QVariant
();
}
const
auto
&
item
=
acc_
.
conversationModel
->
filteredConversation
(
index
.
row
());
auto
&
accInfo
=
LRCInstance
::
accountModel
().
getAccountInfo
(
accId_
);
const
auto
&
item
=
accInfo
.
conversationModel
->
filteredConversation
(
index
.
row
());
if
(
item
.
participants
.
size
()
>
0
)
{
try
{
switch
(
role
)
{
case
Role
:
:
Picture
:
case
Qt
:
:
DecorationRole
:
return
GlobalInstances
::
pixmapManipulator
().
decorationRole
(
item
,
acc
_
);
return
GlobalInstances
::
pixmapManipulator
().
decorationRole
(
item
,
acc
Info
);
case
Role
:
:
DisplayName
:
case
Qt
:
:
DisplayRole
:
{
auto
&
contact
=
acc
_
.
contactModel
->
getContact
(
item
.
participants
[
0
]);
auto
&
contact
=
acc
Info
.
contactModel
->
getContact
(
item
.
participants
[
0
]);
return
QVariant
(
QString
::
fromStdString
(
Utils
::
bestNameForContact
(
contact
)));
}
case
Role
:
:
DisplayID
:
{
auto
&
contact
=
acc
_
.
contactModel
->
getContact
(
item
.
participants
[
0
]);
auto
&
contact
=
acc
Info
.
contactModel
->
getContact
(
item
.
participants
[
0
]);
return
QVariant
(
QString
::
fromStdString
(
Utils
::
bestIdForContact
(
contact
)));
}
case
Role
:
:
Presence
:
{
auto
&
contact
=
acc
_
.
contactModel
->
getContact
(
item
.
participants
[
0
]);
auto
&
contact
=
acc
Info
.
contactModel
->
getContact
(
item
.
participants
[
0
]);
return
QVariant
(
contact
.
isPresent
);
}
case
Role
:
:
URI
:
{
auto
&
contact
=
acc
_
.
contactModel
->
getContact
(
item
.
participants
[
0
]);
auto
&
contact
=
acc
Info
.
contactModel
->
getContact
(
item
.
participants
[
0
]);
return
QVariant
(
QString
::
fromStdString
(
contact
.
profileInfo
.
uri
));
}
case
Role
:
:
UnreadMessagesCount
:
...
...
@@ -98,7 +101,7 @@ QVariant SmartListModel::data(const QModelIndex &index, int role) const
return
QVariant
(
Utils
::
toUnderlyingValue
(
item
.
interactions
.
at
(
item
.
lastMessageUid
).
type
));
case
Role
:
:
ContactType
:
{
auto
&
contact
=
acc
_
.
contactModel
->
getContact
(
item
.
participants
[
0
]);
auto
&
contact
=
acc
Info
.
contactModel
->
getContact
(
item
.
participants
[
0
]);
return
QVariant
(
Utils
::
toUnderlyingValue
(
contact
.
profileInfo
.
type
));
}
case
Role
:
:
UID
:
...
...
@@ -144,3 +147,9 @@ Qt::ItemFlags SmartListModel::flags(const QModelIndex &index) const
}
return
flags
;
}
void
SmartListModel
::
setAccount
(
const
std
::
string
&
accId
)
{
accId_
=
accId
;
}
smartlistmodel.h
View file @
6b5ad3e2
...
...
@@ -51,7 +51,7 @@ public:
ContextMenuOpen
};
explicit
SmartListModel
(
const
lrc
::
api
::
account
::
Info
&
acc
,
QObject
*
parent
=
0
);
explicit
SmartListModel
(
const
std
::
string
&
accId
,
QObject
*
parent
=
0
);
// QAbstractItemModel
int
rowCount
(
const
QModelIndex
&
parent
=
QModelIndex
())
const
override
;
...
...
@@ -61,9 +61,11 @@ public:
QModelIndex
parent
(
const
QModelIndex
&
child
)
const
;
Qt
::
ItemFlags
flags
(
const
QModelIndex
&
index
)
const
;
void
setAccount
(
const
std
::
string
&
accId
);
// hack for context menu highlight retention
bool
isContextMenuOpen
{
false
};
private:
const
AccountInfo
&
acc
_
;
std
::
string
accId
_
;
};
utils.cpp
View file @
6b5ad3e2
...
...
@@ -42,6 +42,7 @@
#include "pixbufmanipulator.h"
#include "globalsystemtray.h"
#include "lrcinstance.h"
bool
Utils
::
CreateStartupLink
()
...
...
@@ -428,4 +429,18 @@ Utils::generateTintedPixmap(const QString& filename, QColor color)
}
}
return
QPixmap
::
fromImage
(
tmpImage
);
}
std
::
string
Utils
::
getConversationFromCallId
(
const
std
::
string
&
callId
)
{
auto
convModel
=
LRCInstance
::
getCurrentConversationModel
();
auto
conversations
=
convModel
->
allFilteredConversations
();
std
::
string
convUid
;
for
(
auto
conversation
:
conversations
)
{
if
(
conversation
.
callId
==
callId
)
{
return
conversation
.
uid
;
}
}
return
""
;
}
\ No newline at end of file
utils.h
View file @
6b5ad3e2
...
...
@@ -78,6 +78,7 @@ namespace Utils
QImage
conversationPhoto
(
const
std
::
string
&
convUid
,
const
lrc
::
api
::
account
::
Info
&
accountInfo
);
QByteArray
QByteArrayFromFile
(
const
QString
&
filename
);
QPixmap
generateTintedPixmap
(
const
QString
&
filename
,
QColor
color
);
std
::
string
getConversationFromCallId
(
const
std
::
string
&
callId
);
template
<
typename
E
>
constexpr
inline
typename
std
::
enable_if
<
std
::
is_enum
<
E
>::
value
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment