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
85249a9f
Commit
85249a9f
authored
Feb 22, 2019
by
Armin Felder
Browse files
improved startup time
parent
5948f653
Changes
5
Hide whitespace changes
Inline
Side-by-side
CustomModels/channelmodel.cpp
View file @
85249a9f
...
...
@@ -143,7 +143,7 @@ QVariant ChannelModel::data( const QModelIndex &index, int role ) const
bool
ChannelModel
::
addChannel
(
const
QSharedPointer
<
RocketChatChannel
>
&
channel
)
{
if
(
!
channel
.
isNull
()
&&
channel
->
getRoomId
()
!=
""
&&
!
duplicateCheck
.
contains
(
channel
->
getRoomId
()
)
)
{
//
connect( channel.data(), &RocketChatChannel::messageAdded, this, &ChannelModel::onNewerMessage, Qt::UniqueConnection );
connect
(
channel
.
data
(),
&
RocketChatChannel
::
messageAdded
,
this
,
&
ChannelModel
::
onNewerMessage
,
Qt
::
UniqueConnection
);
connect
(
channel
.
data
(),
&
RocketChatChannel
::
unreadMessagesChanged
,
this
,
&
ChannelModel
::
onUnreadMessageChanged
,
Qt
::
UniqueConnection
);
connect
(
channel
.
data
(),
&
RocketChatChannel
::
dataChanged
,
this
,
&
ChannelModel
::
onDataChanged
,
Qt
::
UniqueConnection
);
connect
(
channel
.
data
(),
&
RocketChatChannel
::
channelDeleted
,
this
,
&
ChannelModel
::
onDeleted
,
Qt
::
UniqueConnection
);
...
...
@@ -167,7 +167,9 @@ bool ChannelModel::addChannel( const QSharedPointer<RocketChatChannel> &channel
bool
ChannelModel
::
addChannelsSlot
(
const
QVector
<
QSharedPointer
<
RocketChatChannel
>
>
&
pChannels
)
{
beginResetModel
();
// beginResetModel();
int
from
=-
1
;
int
to
=
-
1
;
for
(
const
auto
&
channel
:
pChannels
){
if
(
!
channel
.
isNull
()
&&
channel
->
getRoomId
()
!=
""
&&
!
duplicateCheck
.
contains
(
channel
->
getRoomId
()
)
)
{
//connect( channel.data(), &RocketChatChannel::messageAdded, this, &ChannelModel::onNewerMessage, Qt::UniqueConnection );
...
...
@@ -176,10 +178,22 @@ bool ChannelModel::addChannelsSlot(const QVector<QSharedPointer<RocketChatChanne
connect
(
channel
.
data
(),
&
RocketChatChannel
::
channelDeleted
,
this
,
&
ChannelModel
::
onDeleted
,
Qt
::
UniqueConnection
);
connect
(
channel
.
data
(),
&
RocketChatChannel
::
updatedChanged
,
this
,
&
ChannelModel
::
onChannelOrderChanged
);
duplicateCheck
.
insert
(
channel
->
getRoomId
()
);
channelList
.
insertSort
(
channel
);
auto
index
=
channelList
.
insertSort
(
channel
);
if
(
from
==
-
1
){
from
=
index
;
to
=
index
;
}
if
(
index
<
from
){
from
=
index
;
}
else
if
(
index
>
to
){
to
=
index
;
}
}
}
endResetModel
();
beginInsertRows
(
QModelIndex
(),
from
,
to
);
endInsertRows
();
// endResetModel();
return
true
;
}
...
...
@@ -296,6 +310,9 @@ void ChannelModel::onDeleted( const QString &pId, bool deleted )
void
ChannelModel
::
onChannelOrderChanged
(
const
QString
&
pId
,
qint64
pTimestamp
)
{
static
int
counter
=
0
;
counter
++
;
qDebug
()
<<
counter
;
beginResetModel
();
channelList
.
reOrder
();
endResetModel
();
...
...
container/sortedvector.cpp
View file @
85249a9f
...
...
@@ -35,8 +35,13 @@ int SortedVector<T>::insertSort( const QSharedPointer<T> &pointer )
return
(
*
first
)
>
(
*
second
);
}
);
row
=
std
::
distance
(
this
->
begin
(),
elementSmallerThanNew
);
this
->
insert
(
elementSmallerThanNew
,
pointer
);
row
=
elementSmallerThanNew
-
this
->
begin
();
if
(
row
<
0
||
row
>
1000
){
qDebug
()
<<
elementSmallerThanNew
;
qDebug
()
<<
"error"
;
}
}
return
row
;
...
...
container/sortedvector.h
View file @
85249a9f
...
...
@@ -25,9 +25,18 @@
#include
<QVector>
#include
<QSharedPointer>
#include
<QMutex>
struct
SortedVectorProperties
{
enum
class
sortOrder
{
asc
,
dsc
};
};
template
<
typename
T
>
class
SortedVector
:
public
QVector
<
QSharedPointer
<
T
>>
{
public:
int
insertSort
(
const
QSharedPointer
<
T
>
&
);
int
findInsertPosition
(
const
QSharedPointer
<
T
>
&
)
const
;
int
findPosition
(
const
QSharedPointer
<
T
>
&
)
const
;
...
...
repos/entities/rocketchatchannel.cpp
View file @
85249a9f
...
...
@@ -371,9 +371,9 @@ qint64 RocketChatChannel::getUpdatedAt() const
void
RocketChatChannel
::
setUpdatedAt
(
const
qint64
&
updatedAt
)
{
//skip signal the first time
if
(
mUpdatedAt
!=
updatedAt
){
if
(
mUpdatedAt
!=
-
1
){
emit
updatedChanged
(
mRoomId
,
mU
pdatedAt
);
if
(
mUpdatedAt
!=
updatedAt
&&
updatedAt
!=
-
1
){
if
(
mUpdatedAt
!=
-
1
){
emit
updatedChanged
(
mRoomId
,
u
pdatedAt
);
}
mUpdatedAt
=
updatedAt
;
}
...
...
services/rocketchatchannelservice.cpp
View file @
85249a9f
...
...
@@ -112,8 +112,8 @@ QVector<QSharedPointer<RocketChatChannel> > RocketChatChannelService::processCha
qint64
updatedAt
=
-
1
;
if
(
currentChannelObject
.
contains
(
QStringLiteral
(
"
_updatedAt
"
)
)
)
{
auto
updatedObj
=
currentChannelObject
[
QStringLiteral
(
"
_updatedAt
"
)].
toObject
();
if
(
currentChannelObject
.
contains
(
QStringLiteral
(
"
ls
"
)
)
)
{
auto
updatedObj
=
currentChannelObject
[
QStringLiteral
(
"
ls
"
)].
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