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

View file

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

View file

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

View file

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

View file

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

View file

@ -18,7 +18,7 @@
namespace chatterino {
namespace widgets {
AccountPopupWidget::AccountPopupWidget(SharedChannel _channel)
AccountPopupWidget::AccountPopupWidget(ChannelPtr _channel)
: BaseWindow()
, ui(new Ui::AccountPopup)
, channel(_channel)
@ -172,7 +172,7 @@ void AccountPopupWidget::setName(const QString &name)
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) {
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;
}

View file

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

View file

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

View file

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

View file

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

View file

@ -41,7 +41,7 @@ public:
void pause(int msecTimeout);
void updateLastReadMessage();
void setChannel(SharedChannel channel);
void setChannel(ChannelPtr channel);
messages::LimitedQueueSnapshot<messages::MessageLayoutPtr> getMessagesSnapshot();
void layoutMessages();
@ -84,7 +84,7 @@ private:
void setSelection(const messages::SelectionItem &start, const messages::SelectionItem &end);
messages::MessageElement::Flags getFlags() const;
SharedChannel channel;
ChannelPtr channel;
Scrollbar scrollBar;
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->performSearch();
@ -70,7 +70,7 @@ void SearchPopup::performSearch()
{
QString text = searchInput->text();
SharedChannel channel(new Channel("search"));
ChannelPtr channel(new Channel("search"));
for (size_t i = 0; i < this->snapshot.getLength(); i++) {
messages::MessagePtr message = this->snapshot[i];

View file

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

View file

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

View file

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

View file

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