mirror-chatterino2/channel.cpp

40 lines
1,001 B
C++
Raw Normal View History

#include "channel.h"
2017-01-05 16:07:20 +01:00
#include "message.h"
#include "windows.h"
2017-01-11 01:08:20 +01:00
#include <memory>
Channel::Channel(const QString &channel)
2017-01-13 18:59:11 +01:00
: m_messages()
, m_name((channel.length() > 0 && channel[0] == '#') ? channel.mid(1)
2017-01-11 18:52:09 +01:00
: channel)
2017-01-07 20:43:55 +01:00
, m_bttvChannelEmotes()
, m_ffzChannelEmotes()
, m_messageMutex()
2017-01-11 18:52:09 +01:00
, m_subLink("https://www.twitch.tv/" + m_name +
"/subscribe?ref=in_chat_subscriber_link")
2017-01-07 20:43:55 +01:00
, m_channelLink("https://twitch.tv/" + m_name)
, m_popoutPlayerLink("https://player.twitch.tv/?channel=" + m_name)
{
2017-01-07 20:43:55 +01:00
}
2017-01-05 16:07:20 +01:00
2017-01-11 18:52:09 +01:00
QVector<std::shared_ptr<Message>>
Channel::getMessagesClone()
2017-01-05 16:07:20 +01:00
{
2017-01-07 20:43:55 +01:00
m_messageMutex.lock();
2017-01-11 01:08:20 +01:00
QVector<std::shared_ptr<Message>> M(m_messages);
M.detach();
2017-01-07 20:43:55 +01:00
m_messageMutex.unlock();
2017-01-05 16:07:20 +01:00
return M;
}
2017-01-11 18:52:09 +01:00
void
Channel::addMessage(std::shared_ptr<Message> message)
2017-01-05 16:07:20 +01:00
{
2017-01-07 20:43:55 +01:00
m_messageMutex.lock();
2017-01-11 01:08:20 +01:00
m_messages.append(message);
2017-01-07 20:43:55 +01:00
m_messageMutex.unlock();
Windows::repaintVisibleChatWidgets();
2017-01-05 16:07:20 +01:00
}