Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chat
RocketChatMobileEngine
Commits
7a3ee436
Commit
7a3ee436
authored
Feb 22, 2019
by
armin
Browse files
Merge branch 'anotherFix' into 'master'
asd See merge request
!128
parents
01713517
c1f0fa7b
Changes
2
Hide whitespace changes
Inline
Side-by-side
CustomModels/channelmodel.cpp
View file @
7a3ee436
...
...
@@ -38,103 +38,105 @@ QVariant ChannelModel::data( const QModelIndex &index, int role ) const
auto
currentChannel
=
channelList
.
at
(
row
);
auto
roleType
=
static_cast
<
ChannelRoles
>
(
role
);
if
(
!
currentChannel
.
isNull
()
)
{
auto
roleType
=
static_cast
<
ChannelRoles
>
(
role
);
switch
(
roleType
)
{
case
ChannelRoles
::
name
:
return
currentChannel
->
getName
();
switch
(
roleType
)
{
case
ChannelRoles
::
name
:
return
currentChannel
->
getName
();
case
ChannelRoles
::
roomId
:
return
currentChannel
->
getRoomId
();
case
ChannelRoles
::
roomId
:
return
currentChannel
->
getRoomId
();
case
ChannelRoles
::
lastMessageText
:
{
auto
channel
=
channelList
.
at
(
row
);
auto
message
=
channel
->
getYoungestMessage
();
case
ChannelRoles
::
lastMessageText
:
{
auto
channel
=
channelList
.
at
(
row
);
auto
message
=
channel
->
getYoungestMessage
();
if
(
message
.
isNull
()
)
{
return
""
;
}
if
(
message
.
isNull
()
)
{
return
""
;
}
if
(
message
->
getMessageType
()
==
QStringLiteral
(
"file"
)
||
message
->
getMessageType
()
==
QStringLiteral
(
"image"
)
||
message
->
getMessageType
()
==
QStringLiteral
(
"audio"
)
)
{
return
tr
(
QByteArrayLiteral
(
"file upload"
)
);
}
if
(
message
->
getMessageType
()
==
QStringLiteral
(
"file"
)
||
message
->
getMessageType
()
==
QStringLiteral
(
"image"
)
||
message
->
getMessageType
()
==
QStringLiteral
(
"audio"
)
)
{
return
tr
(
QByteArrayLiteral
(
"file upload"
)
);
auto
messageText
=
message
->
getMessageString
();
messageText
=
messageText
.
replace
(
"<img height='20' width='20'"
,
"<img height='10' width='10'"
);
return
messageText
;
}
auto
messageText
=
message
->
getMessageString
();
messageText
=
messageText
.
replace
(
"<img height='20' width='20'"
,
"<img height='10' width='10'"
);
return
messageText
;
}
case
ChannelRoles
::
channelType
:
return
currentChannel
->
getType
();
case
ChannelRoles
::
channelType
:
return
currentChannel
->
get
Type
();
case
ChannelRoles
::
unreadMessages
:
return
currentChannel
->
get
UnreadMessages
();
case
ChannelRoles
::
un
read
Messages
:
return
currentChannel
->
get
UnreadMessages
();
case
ChannelRoles
::
read
only
:
return
currentChannel
->
get
ReadOnly
()
||
currentChannel
->
getArchived
()
||
currentChannel
->
getBlocked
();
case
ChannelRoles
::
readonly
:
return
currentChannel
->
get
ReadOnly
()
||
currentChannel
->
getArchived
()
||
currentChannel
->
getBlocke
d
();
case
ChannelRoles
::
ownerId
:
return
currentChannel
->
get
OwnerI
d
();
case
ChannelRoles
::
ownerI
d
:
return
currentChannel
->
get
OwnerI
d
();
case
ChannelRoles
::
archive
d
:
return
currentChannel
->
get
Archive
d
();
case
ChannelRoles
::
archiv
ed
:
return
currentChannel
->
get
Archiv
ed
();
case
ChannelRoles
::
block
ed
:
return
currentChannel
->
get
Block
ed
();
case
ChannelRoles
::
blocked
:
return
currentChannel
->
get
Blocked
();
case
ChannelRoles
::
username
:
return
currentChannel
->
get
Username
();
case
ChannelRoles
::
username
:
return
currentChannel
->
getUsername
();
case
ChannelRoles
::
userStatus
:
{
int
status
=
0
;
auto
partner
=
currentChannel
->
getChatPartner
();
case
ChannelRoles
::
userStatus
:
{
int
status
=
0
;
auto
partner
=
currentChannel
->
getChatPartner
();
if
(
!
partner
.
isNull
()
)
{
switch
(
partner
->
getStatus
()
)
{
case
RocketChatUser
::
status
::
ONLINE
:
status
=
0
;
break
;
if
(
!
partner
.
isNull
()
)
{
switch
(
partner
->
getStatus
()
)
{
case
RocketChatUser
::
status
::
ONLINE
:
status
=
0
;
break
;
case
RocketChatUser
::
status
::
AWAY
:
status
=
1
;
break
;
case
RocketChatUser
::
status
::
AWAY
:
status
=
1
;
break
;
case
RocketChatUser
::
status
::
OFFLINE
:
status
=
2
;
break
;
case
RocketChatUser
::
status
::
OFFLINE
:
status
=
2
;
break
;
case
RocketChatUser
::
status
::
BUSY
:
status
=
3
;
break
;
}
case
RocketChatUser
::
status
::
BUSY
:
status
=
3
;
break
;
}
return
status
;
}
return
status
;
}
case
ChannelRoles
::
deleted
:
return
currentChannel
->
getDeleted
();
case
ChannelRoles
::
deleted
:
return
currentChannel
->
getDeleted
();
case
ChannelRoles
::
ownerName
:
return
currentChannel
->
getOwnerName
();
case
ChannelRoles
::
ownerName
:
return
currentChannel
->
getOwnerName
();
case
ChannelRoles
::
avatarImg
:
{
auto
avatarImg
=
currentChannel
->
getAvatarImg
();
case
ChannelRoles
::
avatarImg
:
{
auto
avatarImg
=
currentChannel
->
getAvatarImg
();
if
(
!
avatarImg
.
isNull
()
)
{
auto
path
=
Utils
::
getPathPrefix
()
+
avatarImg
->
getFilePath
();
if
(
!
avatarImg
.
isNull
()
)
{
auto
path
=
Utils
::
getPathPrefix
()
+
avatarImg
->
getFilePath
();
if
(
path
.
endsWith
(
"svg"
)
)
{
return
"qrc:res/user-identity.svg"
;
if
(
path
.
endsWith
(
"svg"
)
)
{
return
"qrc:res/user-identity.svg"
;
}
else
{
return
path
;
}
}
else
{
return
path
;
return
""
;
}
}
else
{
return
""
;
}
}
}
}
return
QVariant
();
...
...
@@ -174,6 +176,8 @@ bool ChannelModel::addChannelsSlot( const QList<QSharedPointer<RocketChatChannel
int
from
=
-
1
;
int
to
=
-
1
;
beginResetModel
();
for
(
const
auto
&
channel
:
pChannels
)
{
if
(
!
channel
.
isNull
()
&&
!
channel
->
getRoomId
().
isEmpty
()
&&
!
duplicateCheck
.
contains
(
channel
->
getRoomId
()
)
)
{
//connect( channel.data(), &RocketChatChannel::messageAdded, this, &ChannelModel::onNewerMessage, Qt::UniqueConnection );
...
...
@@ -197,9 +201,9 @@ bool ChannelModel::addChannelsSlot( const QList<QSharedPointer<RocketChatChannel
}
}
beginInsertRows
(
QModelIndex
(),
from
,
to
);
endInsertRows
();
//
endResetModel();
//
beginInsertRows( QModelIndex(), from, to );
//
endInsertRows();
endResetModel
();
return
true
;
}
...
...
services/rocketchatchannelservice.cpp
View file @
7a3ee436
...
...
@@ -113,7 +113,7 @@ QList<QSharedPointer<RocketChatChannel> > RocketChatChannelService::processChann
qint64
updatedAt
=
-
1
;
//don't ask ...
if
(
currentChannelObject
.
contains
(
QStringLiteral
(
"_updatedAt"
)
)
)
{
if
(
currentChannelObject
.
contains
(
QStringLiteral
(
"_updatedAt"
)
)
&&
!
currentChannelObject
.
contains
(
QStringLiteral
(
"ls"
)
)
)
{
auto
updatedObj
=
currentChannelObject
[
QStringLiteral
(
"_updatedAt"
)].
toObject
();
updatedAt
=
static_cast
<
qint64
>
(
updatedObj
[
QStringLiteral
(
"$date"
)].
toDouble
()
);
}
...
...
Write
Preview
Supports
Markdown
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