extracted latest messages logic into its own method

This commit is contained in:
TranRed 2019-07-20 22:42:01 +02:00
parent f417006d6a
commit 94ffc66b2a
2 changed files with 21 additions and 16 deletions

View file

@ -204,9 +204,9 @@ UserInfoPopup::UserInfoPopup()
}
// fourth line (last messages)
this->lastMessages_ = new ChannelView();
this->lastMessages_->setScaleIndependantHeight(150);
layout.append(this->lastMessages_);
this->latestMessages_ = new ChannelView();
this->latestMessages_->setScaleIndependantHeight(150);
layout.append(this->latestMessages_);
this->setStyleSheet("font-size: 11pt;");
@ -347,18 +347,7 @@ void UserInfoPopup::setData(const QString &name, const ChannelPtr &channel)
this->userStateChanged_.invoke();
LimitedQueueSnapshot<MessagePtr> snapshot = this->channel_->getMessageSnapshot();
ChannelPtr channelPtr(new Channel("search", Channel::Type::None));
for (size_t i = 0; i < snapshot.size(); i++)
{
MessagePtr message = snapshot[i];
if ( message->loginName.compare(this->userName_, Qt::CaseInsensitive) == 0)
{
channelPtr->addMessage(message);
}
}
this->lastMessages_->setChannel(channelPtr);
this->fillLatestMessages();
}
void UserInfoPopup::updateUserData()
@ -625,4 +614,19 @@ void UserInfoPopup::TimeoutWidget::paintEvent(QPaintEvent *)
// / 2);
}
void UserInfoPopup::fillLatestMessages(){
LimitedQueueSnapshot<MessagePtr> snapshot = this->channel_->getMessageSnapshot();
ChannelPtr channelPtr(new Channel("search", Channel::Type::None));
for (size_t i = 0; i < snapshot.size(); i++)
{
MessagePtr message = snapshot[i];
if ( message->loginName.compare(this->userName_, Qt::CaseInsensitive) == 0)
{
channelPtr->addMessage(message);
}
}
this->latestMessages_->setChannel(channelPtr);
}
} // namespace chatterino

View file

@ -28,6 +28,7 @@ protected:
private:
void installEvents();
void updateUserData();
void fillLatestMessages();
void loadAvatar(const QUrl &url);
void loadProfileBanner(const QUrl &url);
@ -37,7 +38,7 @@ private:
QString userName_;
QString userId_;
ChannelPtr channel_;
ChannelView* lastMessages_;
ChannelView* latestMessages_;
pajlada::Signals::NoArgSignal userStateChanged_;