forked from blue/squawk
achive from the beginning memorizing bugfix, limitation of the requests in the model
This commit is contained in:
parent
e0ef1ef797
commit
270a32db9e
17 changed files with 62 additions and 39 deletions
|
@ -145,9 +145,9 @@ void Models::Element::changeMessage(const QString& id, const QMap<QString, QVari
|
|||
|
||||
}
|
||||
|
||||
void Models::Element::responseArchive(const std::list<Shared::Message> list)
|
||||
void Models::Element::responseArchive(const std::list<Shared::Message> list, bool last)
|
||||
{
|
||||
feed->responseArchive(list);
|
||||
feed->responseArchive(list, last);
|
||||
}
|
||||
|
||||
bool Models::Element::isRoom() const
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
void addMessage(const Shared::Message& data);
|
||||
void changeMessage(const QString& id, const QMap<QString, QVariant>& data);
|
||||
unsigned int getMessagesCount() const;
|
||||
void responseArchive(const std::list<Shared::Message> list);
|
||||
void responseArchive(const std::list<Shared::Message> list, bool last);
|
||||
bool isRoom() const;
|
||||
|
||||
signals:
|
||||
|
|
|
@ -166,6 +166,7 @@ bool Models::MessageFeed::canFetchMore(const QModelIndex& parent) const
|
|||
void Models::MessageFeed::fetchMore(const QModelIndex& parent)
|
||||
{
|
||||
if (syncState == incomplete) {
|
||||
syncState = syncing;
|
||||
emit requestStateChange(true);
|
||||
|
||||
if (storage.size() == 0) {
|
||||
|
@ -176,12 +177,9 @@ void Models::MessageFeed::fetchMore(const QModelIndex& parent)
|
|||
}
|
||||
}
|
||||
|
||||
void Models::MessageFeed::responseArchive(const std::list<Shared::Message> list)
|
||||
void Models::MessageFeed::responseArchive(const std::list<Shared::Message> list, bool last)
|
||||
{
|
||||
Storage::size_type size = storage.size();
|
||||
if (syncState == syncing) {
|
||||
emit requestStateChange(false);
|
||||
}
|
||||
|
||||
beginInsertRows(QModelIndex(), size, size + list.size() - 1);
|
||||
for (const Shared::Message& msg : list) {
|
||||
|
@ -189,6 +187,15 @@ void Models::MessageFeed::responseArchive(const std::list<Shared::Message> list)
|
|||
storage.insert(copy);
|
||||
}
|
||||
endInsertRows();
|
||||
|
||||
if (syncState == syncing) {
|
||||
if (last) {
|
||||
syncState = complete;
|
||||
} else {
|
||||
syncState = incomplete;
|
||||
}
|
||||
emit requestStateChange(false);
|
||||
}
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> Models::MessageFeed::roleNames() const
|
||||
|
|
|
@ -53,7 +53,7 @@ public:
|
|||
void fetchMore(const QModelIndex & parent) override;
|
||||
QHash<int, QByteArray> roleNames() const override;
|
||||
|
||||
void responseArchive(const std::list<Shared::Message> list);
|
||||
void responseArchive(const std::list<Shared::Message> list, bool last);
|
||||
|
||||
unsigned int unreadMessagesCount() const;
|
||||
|
||||
|
|
|
@ -965,16 +965,16 @@ void Models::Roster::onElementRequestArchive(const QString& before)
|
|||
emit requestArchive(el->getAccountName(), el->getJid(), before);
|
||||
}
|
||||
|
||||
void Models::Roster::responseArchive(const QString& account, const QString& jid, const std::list<Shared::Message>& list)
|
||||
void Models::Roster::responseArchive(const QString& account, const QString& jid, const std::list<Shared::Message>& list, bool last)
|
||||
{
|
||||
ElId id(account, jid);
|
||||
std::map<ElId, Contact*>::iterator itr = contacts.find(id);
|
||||
if (itr != contacts.end()) {
|
||||
itr->second->responseArchive(list);
|
||||
itr->second->responseArchive(list, last);
|
||||
} else {
|
||||
std::map<ElId, Room*>::const_iterator rItr = rooms.find(id);
|
||||
if (rItr != rooms.end()) {
|
||||
rItr->second->responseArchive(list);
|
||||
rItr->second->responseArchive(list, last);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ public:
|
|||
Account* getAccount(const QString& name);
|
||||
QModelIndex getAccountIndex(const QString& name);
|
||||
QModelIndex getGroupIndex(const QString& account, const QString& name);
|
||||
void responseArchive(const QString& account, const QString& jid, const std::list<Shared::Message>& list);
|
||||
void responseArchive(const QString& account, const QString& jid, const std::list<Shared::Message>& list, bool last);
|
||||
|
||||
Accounts* accountsModel;
|
||||
|
||||
|
|
|
@ -610,9 +610,9 @@ void Squawk::onConversationRequestArchive(const QString& account, const QString&
|
|||
emit requestArchive(account, jid, 20, before); //TODO amount as a settings value
|
||||
}
|
||||
|
||||
void Squawk::responseArchive(const QString& account, const QString& jid, const std::list<Shared::Message>& list)
|
||||
void Squawk::responseArchive(const QString& account, const QString& jid, const std::list<Shared::Message>& list, bool last)
|
||||
{
|
||||
rosterModel.responseArchive(account, jid, list);
|
||||
rosterModel.responseArchive(account, jid, list, last);
|
||||
}
|
||||
|
||||
void Squawk::removeAccount(const QString& account)
|
||||
|
|
|
@ -97,7 +97,7 @@ public slots:
|
|||
void removePresence(const QString& account, const QString& jid, const QString& name);
|
||||
void stateChanged(Shared::Availability state);
|
||||
void accountMessage(const QString& account, const Shared::Message& data);
|
||||
void responseArchive(const QString& account, const QString& jid, const std::list<Shared::Message>& list);
|
||||
void responseArchive(const QString& account, const QString& jid, const std::list<Shared::Message>& list, bool last);
|
||||
void addRoom(const QString& account, const QString jid, const QMap<QString, QVariant>& data);
|
||||
void changeRoom(const QString& account, const QString jid, const QMap<QString, QVariant>& data);
|
||||
void removeRoom(const QString& account, const QString jid);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue