renamed SharedChannel to ChannelPtr for consistency

This commit is contained in:
fourtf 2018-01-24 13:15:41 +01:00
parent fa344deaf0
commit 2b94c4cd33
17 changed files with 46 additions and 46 deletions

View file

@ -64,6 +64,6 @@ private:
// std::shared_ptr<logging::Channel> loggingChannel; // std::shared_ptr<logging::Channel> loggingChannel;
}; };
typedef std::shared_ptr<Channel> SharedChannel; typedef std::shared_ptr<Channel> ChannelPtr;
} // namespace chatterino } // namespace chatterino

View file

@ -19,11 +19,11 @@ ChannelManager::ChannelManager()
{ {
} }
const std::vector<SharedChannel> ChannelManager::getItems() const std::vector<ChannelPtr> ChannelManager::getItems()
{ {
QMutexLocker locker(&this->channelsMutex); QMutexLocker locker(&this->channelsMutex);
std::vector<SharedChannel> items; std::vector<ChannelPtr> items;
for (auto &item : this->twitchChannels.values()) { for (auto &item : this->twitchChannels.values()) {
items.push_back(std::get<0>(item)); items.push_back(std::get<0>(item));
@ -32,7 +32,7 @@ const std::vector<SharedChannel> ChannelManager::getItems()
return items; return items;
} }
SharedChannel ChannelManager::addTwitchChannel(const QString &rawChannelName) ChannelPtr ChannelManager::addTwitchChannel(const QString &rawChannelName)
{ {
QString channelName = rawChannelName.toLower(); QString channelName = rawChannelName.toLower();
@ -63,7 +63,7 @@ SharedChannel ChannelManager::addTwitchChannel(const QString &rawChannelName)
return std::get<0>(it.value()); return std::get<0>(it.value());
} }
SharedChannel ChannelManager::getTwitchChannel(const QString &channel) ChannelPtr ChannelManager::getTwitchChannel(const QString &channel)
{ {
QMutexLocker locker(&this->channelsMutex); QMutexLocker locker(&this->channelsMutex);
@ -128,7 +128,7 @@ const std::string &ChannelManager::getUserID(const std::string &username)
return temporary; return temporary;
} }
void ChannelManager::doOnAll(std::function<void(SharedChannel)> func) void ChannelManager::doOnAll(std::function<void(ChannelPtr)> func)
{ {
for (const auto &channel : this->twitchChannels) { for (const auto &channel : this->twitchChannels) {
func(std::get<0>(channel)); func(std::get<0>(channel));

View file

@ -17,20 +17,20 @@ class ChannelManager
public: public:
static ChannelManager &getInstance(); static ChannelManager &getInstance();
const std::vector<SharedChannel> getItems(); const std::vector<ChannelPtr> getItems();
SharedChannel addTwitchChannel(const QString &channel); ChannelPtr addTwitchChannel(const QString &channel);
SharedChannel getTwitchChannel(const QString &channel); ChannelPtr getTwitchChannel(const QString &channel);
void removeTwitchChannel(const QString &channel); void removeTwitchChannel(const QString &channel);
const std::string &getUserID(const std::string &username); const std::string &getUserID(const std::string &username);
void doOnAll(std::function<void(SharedChannel)> func); void doOnAll(std::function<void(ChannelPtr)> func);
// Special channels // Special channels
const SharedChannel whispersChannel; const ChannelPtr whispersChannel;
const SharedChannel mentionsChannel; const ChannelPtr mentionsChannel;
const SharedChannel emptyChannel; const ChannelPtr emptyChannel;
private: private:
std::map<std::string, std::string> usernameToID; std::map<std::string, std::string> usernameToID;

View file

@ -88,7 +88,7 @@ QStringList CommandManager::getCommands()
return this->commandsStringList; return this->commandsStringList;
} }
QString CommandManager::execCommand(const QString &text, SharedChannel channel, QString CommandManager::execCommand(const QString &text, ChannelPtr channel,
bool dryRun) bool dryRun)
{ {
QStringList words = text.split(' ', QString::SkipEmptyParts); QStringList words = text.split(' ', QString::SkipEmptyParts);

View file

@ -391,7 +391,7 @@ void IrcManager::onConnected()
MessagePtr msg = Message::createSystemMessage("connected to chat"); MessagePtr msg = Message::createSystemMessage("connected to chat");
MessagePtr remsg = Message::createSystemMessage("reconnected to chat"); MessagePtr remsg = Message::createSystemMessage("reconnected to chat");
this->channelManager.doOnAll([msg, remsg](SharedChannel channel) { this->channelManager.doOnAll([msg, remsg](ChannelPtr channel) {
assert(channel); assert(channel);
LimitedQueueSnapshot<MessagePtr> snapshot = channel->getMessageSnapshot(); LimitedQueueSnapshot<MessagePtr> snapshot = channel->getMessageSnapshot();
@ -412,7 +412,7 @@ void IrcManager::onDisconnected()
MessagePtr msg = Message::createSystemMessage("disconnected from chat"); MessagePtr msg = Message::createSystemMessage("disconnected from chat");
msg->addFlags(Message::DisconnectedMessage); msg->addFlags(Message::DisconnectedMessage);
this->channelManager.doOnAll([msg](SharedChannel channel) { this->channelManager.doOnAll([msg](ChannelPtr channel) {
assert(channel); assert(channel);
channel->addMessage(msg); channel->addMessage(msg);
}); });

View file

@ -159,7 +159,7 @@ void TwitchChannel::refreshLiveStatus()
std::weak_ptr<Channel> weak = this->shared_from_this(); std::weak_ptr<Channel> weak = this->shared_from_this();
util::twitch::get2(url, QThread::currentThread(), false, [weak](const rapidjson::Document &d) { util::twitch::get2(url, QThread::currentThread(), false, [weak](const rapidjson::Document &d) {
SharedChannel shared = weak.lock(); ChannelPtr shared = weak.lock();
if (!shared) { if (!shared) {
return; return;
@ -220,7 +220,7 @@ void TwitchChannel::fetchRecentMessages()
std::weak_ptr<Channel> weak = this->shared_from_this(); std::weak_ptr<Channel> weak = this->shared_from_this();
util::twitch::get(genericURL.arg(roomID), QThread::currentThread(), [weak](QJsonObject obj) { util::twitch::get(genericURL.arg(roomID), QThread::currentThread(), [weak](QJsonObject obj) {
SharedChannel shared = weak.lock(); ChannelPtr shared = weak.lock();
if (!shared) { if (!shared) {
return; return;

View file

@ -18,7 +18,7 @@
namespace chatterino { namespace chatterino {
namespace widgets { namespace widgets {
AccountPopupWidget::AccountPopupWidget(SharedChannel _channel) AccountPopupWidget::AccountPopupWidget(ChannelPtr _channel)
: BaseWindow() : BaseWindow()
, ui(new Ui::AccountPopup) , ui(new Ui::AccountPopup)
, channel(_channel) , channel(_channel)
@ -172,7 +172,7 @@ void AccountPopupWidget::setName(const QString &name)
this->popupWidgetUser.refreshUserType(this->channel, false); this->popupWidgetUser.refreshUserType(this->channel, false);
} }
void AccountPopupWidget::User::refreshUserType(const SharedChannel &channel, bool loggedInUser) void AccountPopupWidget::User::refreshUserType(const ChannelPtr &channel, bool loggedInUser)
{ {
if (channel->name == this->username) { if (channel->name == this->username) {
this->userType = UserType::Owner; this->userType = UserType::Owner;
@ -183,7 +183,7 @@ void AccountPopupWidget::User::refreshUserType(const SharedChannel &channel, boo
} }
} }
void AccountPopupWidget::setChannel(SharedChannel _channel) void AccountPopupWidget::setChannel(ChannelPtr _channel)
{ {
this->channel = _channel; this->channel = _channel;
} }

View file

@ -23,10 +23,10 @@ class AccountPopupWidget : public BaseWindow
{ {
Q_OBJECT Q_OBJECT
public: public:
AccountPopupWidget(SharedChannel _channel); AccountPopupWidget(ChannelPtr _channel);
void setName(const QString &name); void setName(const QString &name);
void setChannel(SharedChannel _channel); void setChannel(ChannelPtr _channel);
public slots: public slots:
void actuallyRefreshButtons(); void actuallyRefreshButtons();
@ -52,7 +52,7 @@ private:
enum class UserType { User, Mod, Owner }; enum class UserType { User, Mod, Owner };
SharedChannel channel; ChannelPtr channel;
QPixmap avatar; QPixmap avatar;
@ -63,7 +63,7 @@ private:
QString userID; QString userID;
UserType userType = UserType::User; UserType userType = UserType::User;
void refreshUserType(const SharedChannel &channel, bool loggedInUser); void refreshUserType(const ChannelPtr &channel, bool loggedInUser);
}; };
User loggedInUser; User loggedInUser;

View file

@ -32,7 +32,7 @@ EmotePopup::EmotePopup(singletons::ThemeManager &themeManager)
this->loadEmojis(); this->loadEmojis();
} }
void EmotePopup::loadChannel(SharedChannel _channel) void EmotePopup::loadChannel(ChannelPtr _channel)
{ {
TwitchChannel *channel = dynamic_cast<TwitchChannel *>(_channel.get()); TwitchChannel *channel = dynamic_cast<TwitchChannel *>(_channel.get());
@ -40,7 +40,7 @@ void EmotePopup::loadChannel(SharedChannel _channel)
return; return;
} }
SharedChannel emoteChannel(new Channel("")); ChannelPtr emoteChannel(new Channel(""));
auto addEmotes = [&](util::EmoteMap &map, const QString &title, const QString &emoteDesc) { auto addEmotes = [&](util::EmoteMap &map, const QString &title, const QString &emoteDesc) {
// TITLE // TITLE
@ -81,7 +81,7 @@ void EmotePopup::loadEmojis()
{ {
util::EmoteMap &emojis = singletons::EmoteManager::getInstance().getEmojis(); util::EmoteMap &emojis = singletons::EmoteManager::getInstance().getEmojis();
SharedChannel emojiChannel(new Channel("")); ChannelPtr emojiChannel(new Channel(""));
// title // title
messages::MessageBuilder builder1; messages::MessageBuilder builder1;

View file

@ -12,7 +12,7 @@ class EmotePopup : public BaseWindow
public: public:
explicit EmotePopup(singletons::ThemeManager &); explicit EmotePopup(singletons::ThemeManager &);
void loadChannel(SharedChannel channel); void loadChannel(ChannelPtr channel);
void loadEmojis(); void loadEmojis();
private: private:

View file

@ -293,7 +293,7 @@ messages::LimitedQueueSnapshot<MessageLayoutPtr> ChannelView::getMessagesSnapsho
return this->snapshot; return this->snapshot;
} }
void ChannelView::setChannel(SharedChannel newChannel) void ChannelView::setChannel(ChannelPtr newChannel)
{ {
if (this->channel) { if (this->channel) {
this->detachChannel(); this->detachChannel();

View file

@ -41,7 +41,7 @@ public:
void pause(int msecTimeout); void pause(int msecTimeout);
void updateLastReadMessage(); void updateLastReadMessage();
void setChannel(SharedChannel channel); void setChannel(ChannelPtr channel);
messages::LimitedQueueSnapshot<messages::MessageLayoutPtr> getMessagesSnapshot(); messages::LimitedQueueSnapshot<messages::MessageLayoutPtr> getMessagesSnapshot();
void layoutMessages(); void layoutMessages();
@ -84,7 +84,7 @@ private:
void setSelection(const messages::SelectionItem &start, const messages::SelectionItem &end); void setSelection(const messages::SelectionItem &start, const messages::SelectionItem &end);
messages::MessageElement::Flags getFlags() const; messages::MessageElement::Flags getFlags() const;
SharedChannel channel; ChannelPtr channel;
Scrollbar scrollBar; Scrollbar scrollBar;
RippleEffectLabel *goToBottom; RippleEffectLabel *goToBottom;

View file

@ -58,7 +58,7 @@ void SearchPopup::initLayout()
} }
} }
void SearchPopup::setChannel(SharedChannel channel) void SearchPopup::setChannel(ChannelPtr channel)
{ {
this->snapshot = channel->getMessageSnapshot(); this->snapshot = channel->getMessageSnapshot();
this->performSearch(); this->performSearch();
@ -70,7 +70,7 @@ void SearchPopup::performSearch()
{ {
QString text = searchInput->text(); QString text = searchInput->text();
SharedChannel channel(new Channel("search")); ChannelPtr channel(new Channel("search"));
for (size_t i = 0; i < this->snapshot.getLength(); i++) { for (size_t i = 0; i < this->snapshot.getLength(); i++) {
messages::MessagePtr message = this->snapshot[i]; messages::MessagePtr message = this->snapshot[i];

View file

@ -93,7 +93,7 @@ void SplitHeader::addDropdownItems(RippleEffectButton *label)
this->dropdownMenu.addSeparator(); this->dropdownMenu.addSeparator();
#ifdef USEWEBENGINE #ifdef USEWEBENGINE
this->dropdownMenu.addAction("Start watching", this, [this]{ this->dropdownMenu.addAction("Start watching", this, [this]{
SharedChannel _channel = this->split->getChannel(); ChannelPtr _channel = this->split->getChannel();
twitch::TwitchChannel *tc = dynamic_cast<twitch::TwitchChannel *>(_channel.get()); twitch::TwitchChannel *tc = dynamic_cast<twitch::TwitchChannel *>(_channel.get());
if (tc != nullptr) { if (tc != nullptr) {
@ -180,7 +180,7 @@ void SplitHeader::updateModerationModeIcon()
: resourceManager.moderationmode_disabled->getPixmap()); : resourceManager.moderationmode_disabled->getPixmap());
bool modButtonVisible = false; bool modButtonVisible = false;
SharedChannel channel = this->split->getChannel(); ChannelPtr channel = this->split->getChannel();
twitch::TwitchChannel *tc = dynamic_cast<twitch::TwitchChannel *>(channel.get()); twitch::TwitchChannel *tc = dynamic_cast<twitch::TwitchChannel *>(channel.get());

View file

@ -132,17 +132,17 @@ const std::string &Split::getUUID() const
return this->uuid; return this->uuid;
} }
SharedChannel Split::getChannel() const ChannelPtr Split::getChannel() const
{ {
return this->channel; return this->channel;
} }
SharedChannel &Split::getChannelRef() ChannelPtr &Split::getChannelRef()
{ {
return this->channel; return this->channel;
} }
void Split::setChannel(SharedChannel _newChannel) void Split::setChannel(ChannelPtr _newChannel)
{ {
this->view.setChannel(_newChannel); this->view.setChannel(_newChannel);
@ -355,7 +355,7 @@ void Split::doClearChat()
void Split::doOpenChannel() void Split::doOpenChannel()
{ {
SharedChannel _channel = this->channel; ChannelPtr _channel = this->channel;
twitch::TwitchChannel *tc = dynamic_cast<twitch::TwitchChannel *>(_channel.get()); twitch::TwitchChannel *tc = dynamic_cast<twitch::TwitchChannel *>(_channel.get());
if (tc != nullptr) { if (tc != nullptr) {
@ -365,7 +365,7 @@ void Split::doOpenChannel()
void Split::doOpenPopupPlayer() void Split::doOpenPopupPlayer()
{ {
SharedChannel _channel = this->channel; ChannelPtr _channel = this->channel;
twitch::TwitchChannel *tc = dynamic_cast<twitch::TwitchChannel *>(_channel.get()); twitch::TwitchChannel *tc = dynamic_cast<twitch::TwitchChannel *>(_channel.get());
if (tc != nullptr) { if (tc != nullptr) {

View file

@ -55,8 +55,8 @@ public:
} }
const std::string &getUUID() const; const std::string &getUUID() const;
SharedChannel getChannel() const; ChannelPtr getChannel() const;
SharedChannel &getChannelRef(); ChannelPtr &getChannelRef();
void setFlexSizeX(double x); void setFlexSizeX(double x);
double getFlexSizeX(); double getFlexSizeX();
void setFlexSizeY(double y); void setFlexSizeY(double y);
@ -83,7 +83,7 @@ protected:
private: private:
SplitContainer &parentPage; SplitContainer &parentPage;
SharedChannel channel; ChannelPtr channel;
QVBoxLayout vbox; QVBoxLayout vbox;
SplitHeader header; SplitHeader header;
@ -97,7 +97,7 @@ private:
boost::signals2::connection channelIDChangedConnection; boost::signals2::connection channelIDChangedConnection;
boost::signals2::connection usermodeChangedConnection; boost::signals2::connection usermodeChangedConnection;
void setChannel(SharedChannel newChannel); void setChannel(ChannelPtr newChannel);
void doOpenAccountPopupWidget(AccountPopupWidget *widget, QString user); void doOpenAccountPopupWidget(AccountPopupWidget *widget, QString user);
void channelNameUpdated(const std::string &newChannelName); void channelNameUpdated(const std::string &newChannelName);
void handleModifiers(QEvent *event, Qt::KeyboardModifiers modifiers); void handleModifiers(QEvent *event, Qt::KeyboardModifiers modifiers);

View file

@ -11,7 +11,7 @@
namespace chatterino { namespace chatterino {
namespace widgets { namespace widgets {
StreamView::StreamView(SharedChannel channel, QUrl url) StreamView::StreamView(ChannelPtr channel, QUrl url)
{ {
util::LayoutCreator<StreamView> layoutCreator(this); util::LayoutCreator<StreamView> layoutCreator(this);