Skip to content

Commit

Permalink
Fixed stranger messages in chat
Browse files Browse the repository at this point in the history
Fixed compile error on msvc2010
  • Loading branch information
alekseysidorov committed Feb 1, 2013
1 parent a0e6d0b commit 72dc426
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/api/messagemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,9 @@ void MessageListModel::setClient(Client *client)
auto longPoll = d->client.data()->longPoll();
connect(longPoll, SIGNAL(messageFlagsReplaced(int, int, int)), SLOT(replaceMessageFlags(int, int, int)));
connect(longPoll, SIGNAL(messageFlagsReseted(int,int,int)), SLOT(resetMessageFlags(int,int)));
connect(longPoll, SIGNAL(messageAdded(Vreen::Message)), SLOT(addMessage(Vreen::Message)));
}
if (client)
client->disconnect(this);
}
}

Expand Down
10 changes: 9 additions & 1 deletion src/qml/src/dialogsmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,15 @@ DialogsModel::DialogsModel(QObject *parent) :
m_unreadCount(0)
{
setSortOrder(Qt::DescendingOrder);
connect(this, SIGNAL(clientChanged(Vreen::Client*)), SLOT(onClientChanged(Vreen::Client*)));
}
void DialogsModel::setUnreadCount(int count)
{
m_unreadCount = count;
emit unreadCountChanged(count);
}

Vreen::Reply *DialogsModel::getDialogs(int offset, int count, int previewLength)
Vreen::Reply *DialogsModel::getDialogs(int count, int offset, int previewLength)
{
if (!client()) {
qWarning("Dialog model must have a client!");
Expand All @@ -78,6 +79,13 @@ void DialogsModel::onDialogsReceived(const QVariant &dialogs)
}
}

void DialogsModel::onClientChanged(Vreen::Client *client)
{
if (client) {
connect(client->longPoll(), SIGNAL(messageAdded(Vreen::Message)), SLOT(addMessage(Vreen::Message)));
}
}

int DialogsModel::unreadCount() const
{
return m_unreadCount;
Expand Down
4 changes: 2 additions & 2 deletions src/qml/src/dialogsmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ class DialogsModel : public Vreen::MessageListModel
void setUnreadCount(int count);
int unreadCount() const;
public slots:
Vreen::Reply *getDialogs(int offset = 0, int count = 25, int previewLength = -1);
Vreen::Reply *getDialogs(int count = 25, int offset = 0, int previewLength = -1);
signals:
void clientChanged(QObject*);
void unreadCountChanged(int count);
protected:
virtual void doReplaceMessage(int index, const::Vreen::Message &message);
virtual void doInsertMessage(int index, const::Vreen::Message &message);
virtual void doRemoveMessage(int index);
private slots:
void onDialogsReceived(const QVariant &dialogs);
void onClientChanged(Vreen::Client *client);
private:
int m_unreadCount;
};
Expand Down
2 changes: 1 addition & 1 deletion src/qml/src/newsfeedmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ static bool newsItemMoreThan(const Vreen::NewsItem &a, const Vreen::NewsItem &b)

void NewsFeedModel::onNewsRecieved(const Vreen::NewsItemList &items)
{
for (auto item : items) {
foreach (auto item, items) {
if (findNews(item.postId()) == -1) {
auto index = Vreen::lowerBound(m_newsList, item, newsItemMoreThan);
insertNews(index, item);
Expand Down

0 comments on commit 72dc426

Please sign in to comment.