mirror-chatterino2/src/channel.hpp

64 lines
1.8 KiB
C++
Raw Normal View History

#pragma once
2017-06-11 09:31:45 +02:00
#include "logging/loggingchannel.hpp"
#include "messages/lazyloadedimage.hpp"
#include "messages/limitedqueue.hpp"
2017-12-31 22:58:35 +01:00
#include "util/concurrentmap.hpp"
2017-01-07 20:43:55 +01:00
#include <QMap>
#include <QMutex>
2017-01-11 18:52:09 +01:00
#include <QString>
2017-01-07 20:43:55 +01:00
#include <QVector>
2017-02-02 20:35:12 +01:00
#include <boost/signals2.hpp>
2017-01-11 01:08:20 +01:00
#include <memory>
#include <set>
2017-01-05 16:07:20 +01:00
2017-04-14 17:52:22 +02:00
namespace chatterino {
namespace messages {
2017-01-05 16:07:20 +01:00
class Message;
2017-01-18 21:30:23 +01:00
}
class Channel : public std::enable_shared_from_this<Channel>
{
public:
explicit Channel(const QString &_name);
2017-01-07 20:43:55 +01:00
2017-04-12 17:46:44 +02:00
boost::signals2::signal<void(messages::SharedMessage &)> messageRemovedFromStart;
boost::signals2::signal<void(messages::SharedMessage &)> messageAppended;
boost::signals2::signal<void(std::vector<messages::SharedMessage> &)> messagesAddedAtStart;
2018-01-05 23:14:55 +01:00
boost::signals2::signal<void(size_t index, messages::SharedMessage &)> messageReplaced;
2017-02-02 20:35:12 +01:00
virtual bool isEmpty() const;
2017-04-12 17:46:44 +02:00
messages::LimitedQueueSnapshot<messages::SharedMessage> getMessageSnapshot();
2017-01-05 20:49:33 +01:00
2017-04-12 17:46:44 +02:00
void addMessage(messages::SharedMessage message);
void addMessagesAtStart(std::vector<messages::SharedMessage> &messages);
2018-01-05 23:14:55 +01:00
void replaceMessage(messages::SharedMessage message, messages::SharedMessage replacement);
void addRecentChatter(const std::shared_ptr<messages::Message> &message);
struct NameOptions {
QString displayName;
QString localizedName;
};
std::vector<NameOptions> getUsernamesForCompletions();
QString name;
QStringList modList;
// Key = login name
std::map<QString, NameOptions> recentChatters;
std::mutex recentChattersMutex;
virtual bool canSendMessage() const;
virtual void sendMessage(const QString &message);
private:
2017-09-21 12:15:01 +02:00
messages::LimitedQueue<messages::SharedMessage> messages;
2017-09-21 12:15:01 +02:00
// std::shared_ptr<logging::Channel> loggingChannel;
};
2017-04-14 17:52:22 +02:00
} // namespace chatterino