mirror-chatterino2/src/channel.hpp

68 lines
1.8 KiB
C++
Raw Normal View History

#pragma once
#include "messages/image.hpp"
2017-06-11 09:31:45 +02:00
#include "messages/limitedqueue.hpp"
#include "messages/message.hpp"
#include "util/completionmodel.hpp"
2017-12-31 22:58:35 +01:00
#include "util/concurrentmap.hpp"
2017-01-07 20:43:55 +01:00
2017-01-11 18:52:09 +01:00
#include <QString>
2018-03-30 13:50:43 +02:00
#include <QTimer>
#include <pajlada/signals/signal.hpp>
2017-01-11 01:08:20 +01:00
#include <memory>
2017-01-05 16:07:20 +01:00
2017-04-14 17:52:22 +02:00
namespace chatterino {
namespace messages {
2018-01-28 03:29:42 +01:00
struct Message;
} // namespace messages
class Channel : public std::enable_shared_from_this<Channel>
{
2018-03-30 13:50:43 +02:00
QTimer *clearCompletionModelTimer;
public:
explicit Channel(const QString &_name);
2018-02-05 15:11:50 +01:00
virtual ~Channel();
pajlada::Signals::Signal<const QString &, const QString &> sendMessageSignal;
2017-01-07 20:43:55 +01:00
pajlada::Signals::Signal<messages::MessagePtr &> messageRemovedFromStart;
pajlada::Signals::Signal<messages::MessagePtr &> messageAppended;
pajlada::Signals::Signal<std::vector<messages::MessagePtr> &> messagesAddedAtStart;
pajlada::Signals::Signal<size_t, messages::MessagePtr &> messageReplaced;
2018-02-05 15:11:50 +01:00
pajlada::Signals::NoArgSignal destroyed;
2017-02-02 20:35:12 +01:00
virtual bool isEmpty() const;
messages::LimitedQueueSnapshot<messages::MessagePtr> getMessageSnapshot();
2017-01-05 20:49:33 +01:00
void addMessage(messages::MessagePtr message);
void addMessagesAtStart(std::vector<messages::MessagePtr> &messages);
void replaceMessage(messages::MessagePtr message, messages::MessagePtr replacement);
virtual void addRecentChatter(const std::shared_ptr<messages::Message> &message);
QString name;
QStringList modList;
virtual bool canSendMessage() const;
virtual void sendMessage(const QString &message);
virtual bool isMod() const
{
return false;
}
2018-02-05 15:11:50 +01:00
static std::shared_ptr<Channel> getEmpty();
CompletionModel completionModel;
2018-02-05 15:11:50 +01:00
protected:
virtual void onConnected();
private:
messages::LimitedQueue<messages::MessagePtr> messages;
};
2018-03-30 12:37:00 +02:00
using ChannelPtr = std::shared_ptr<Channel>;
2017-04-14 17:52:22 +02:00
} // namespace chatterino