refactor/reformat. remove useless common.h

This commit is contained in:
Rasmus Karlsson 2017-06-07 10:09:24 +02:00
parent b66dc479e6
commit 5b2b2e3e19
76 changed files with 148 additions and 264 deletions

View file

@ -96,7 +96,6 @@ HEADERS += \
src/asyncexec.h \
src/channel.h \
src/colorscheme.h \
src/common.h \
src/concurrentmap.h \
src/emojis.h \
src/ircmanager.h \

View file

@ -1,5 +1,4 @@
#ifndef ACCOUNTMANAGER_H
#define ACCOUNTMANAGER_H
#pragma once
#include "twitch/twitchuser.h"
@ -35,5 +34,3 @@ private:
};
} // namespace chatterino
#endif // ACCOUNTMANAGER_H

View file

@ -1,8 +1,7 @@
#ifndef APPDATAPATH_H
#define APPDATAPATH_H
#pragma once
#include <QString>
#include <atomic>
#include <mutex>
class Path
@ -14,5 +13,3 @@ private:
static QString appdataPath;
static std::mutex appdataPathMutex;
};
#endif // APPDATAPATH_H

View file

@ -1,15 +1,16 @@
#ifndef ASYNCEXEC_H
#define ASYNCEXEC_H
#pragma once
#include "qcoreapplication.h"
#include <QCoreApplication>
#include <QRunnable>
#include <QThreadPool>
#include <functional>
#define async_exec(a) QThreadPool::globalInstance()->start(new LambdaRunnable(a));
class LambdaRunnable : public QRunnable {
class LambdaRunnable : public QRunnable
{
public:
LambdaRunnable(std::function<void()> action)
{
@ -24,5 +25,3 @@ public:
private:
std::function<void()> action;
};
#endif // ASYNCEXEC_H

View file

@ -1,5 +1,4 @@
#ifndef CHANNEL_H
#define CHANNEL_H
#pragma once
#include "concurrentmap.h"
#include "logging/loggingchannel.h"
@ -11,6 +10,7 @@
#include <QString>
#include <QVector>
#include <boost/signals2.hpp>
#include <memory>
namespace chatterino {
@ -78,5 +78,3 @@ private:
};
} // namespace chatterino
#endif // CHANNEL_H

View file

@ -1,5 +1,4 @@
#ifndef CHANNELS_H
#define CHANNELS_H
#pragma once
#include "channel.h"
@ -37,5 +36,3 @@ private:
};
} // namespace chatterino
#endif // CHANNELS_H

View file

@ -171,4 +171,5 @@ void ColorScheme::normalizeColor(QColor &color)
// color.setHslF(color.hueF(), s, newL);
}
} // namespace chatterino

View file

@ -1,5 +1,4 @@
#ifndef COLORSCHEME_H
#define COLORSCHEME_H
#pragma once
#include <QBrush>
#include <QColor>
@ -89,6 +88,5 @@ private:
void fillLookupTableValues(qreal (&array)[360], qreal from, qreal to, qreal fromValue,
qreal toValue);
};
}
#endif // COLORSCHEME_H
} // namespace chatterino

View file

@ -1,17 +0,0 @@
#include <QString>
#ifndef COMMON_H
#define COMMON_H
#define STRINGISE_IMPL(x) #x
#define STRINGISE(x) STRINGISE_IMPL(x)
// Use: #pragma message WARN("My message")
#if _MSC_VER
#define FILE_LINE_LINK __FILE__ "(" STRINGISE(__LINE__) ") : "
#define WARN(exp) (FILE_LINE_LINK "WARNING: " exp)
#else //__GNUC__ - may need other defines for different compilers
#define WARN(exp) ("WARNING: " exp)
#endif
#endif // COMMON_H

View file

@ -1,5 +1,4 @@
#ifndef CONCURRENTMAP_H
#define CONCURRENTMAP_H
#pragma once
#include <QMap>
#include <QMutex>
@ -66,5 +65,3 @@ private:
};
} // namespace chatterino
#endif // CONCURRENTMAP_H

View file

@ -114,4 +114,5 @@ void Emojis::loadEmojis()
QMap<QString, QString>{{emoji.second.value, emoji.second.code}});
}
}
}
} // namespace chatterino

View file

@ -1,5 +1,4 @@
#ifndef EMOJIS_H
#define EMOJIS_H
#pragma once
#include "concurrentmap.h"
#include "messages/lazyloadedimage.h"
@ -7,6 +6,7 @@
#include <QObject>
#include <QRegularExpression>
#include <QString>
#include <unordered_map>
namespace chatterino {
@ -39,6 +39,5 @@ private:
{
}
};
}
#endif // EMOJIS_H
} // namespace chatterino

View file

@ -9,6 +9,7 @@
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <memory>
#define TWITCH_EMOTE_TEMPLATE "https://static-cdn.jtvnw.net/emoticons/v1/{id}/{scale}.0"

View file

@ -1,5 +1,4 @@
#ifndef EMOTES_H
#define EMOTES_H
#pragma once
#define GIF_FRAME_LENGTH 33
@ -94,5 +93,3 @@ private:
};
} // namespace chatterino
#endif // EMOTES_H

View file

@ -59,4 +59,5 @@ QFontMetrics &FontManager::getFontMetrics(Type type)
return *_metricsMedium;
}
}
} // namespace chatterino

View file

@ -1,5 +1,4 @@
#ifndef FONTS_H
#define FONTS_H
#pragma once
#include <QFont>
#include <QFontMetrics>
@ -50,6 +49,5 @@ private:
int _generation;
};
}
#endif // FONTS_H
} // namespace chatterino

View file

@ -30,4 +30,5 @@ const QString &IrcUser2::getPassword() const
{
return _password;
}
}
} // namespace chatterino

View file

@ -1,5 +1,4 @@
#ifndef IRCUSER_H
#define IRCUSER_H
#pragma once
#include <QString>
@ -24,5 +23,3 @@ private:
};
} // namespace chatterino
#endif // IRCUSER_H

View file

@ -217,7 +217,6 @@ void IrcManager::joinChannel(const QString &channelName)
this->connectionMutex.unlock();
}
void IrcManager::partChannel(const QString &channelName)
{
this->connectionMutex.lock();

View file

@ -1,5 +1,4 @@
#ifndef LOGGINGCHANNEL_H
#define LOGGINGCHANNEL_H
#pragma once
#include "messages/message.h"
@ -35,5 +34,3 @@ private:
} // namespace logging
} // namespace chatterino
#endif // LOGGINGCHANNEL_H

View file

@ -1,5 +1,4 @@
#ifndef LOGGINGMANAGER_H
#define LOGGINGMANAGER_H
#pragma once
#include "loggingchannel.h"
@ -13,5 +12,3 @@ std::shared_ptr<Channel> get(const QString &channelName);
} // namespace logging
} // namespace chatterino
#endif // LOGGINGMANAGER_H

View file

@ -1,6 +1,5 @@
#include "channelmanager.h"
#include "colorscheme.h"
#include "common.h"
#include "emojis.h"
#include "emotemanager.h"
#include "ircmanager.h"

View file

@ -1,5 +1,4 @@
#ifndef LIMITEDQUEUE_H
#define LIMITEDQUEUE_H
#pragma once
#include "messages/limitedqueuesnapshot.h"
@ -96,5 +95,3 @@ private:
} // namespace messages
} // namespace chatterino
#endif // LIMITEDQUEUE_H

View file

@ -1,5 +1,4 @@
#ifndef LIMITEDQUEUESNAPSHOT_H
#define LIMITEDQUEUESNAPSHOT_H
#pragma once
#include <memory>
#include <vector>
@ -34,7 +33,6 @@ private:
int _offset;
int _length;
};
} // namespace messages
} // namespace chatterino
#endif // LIMITEDQUEUESNAPSHOT_H

View file

@ -14,5 +14,6 @@ Link::Link(Type type, const QString &value)
, value(value)
{
}
}
}
} // namespace messages
} // namespace chatterino

View file

@ -1,5 +1,4 @@
#ifndef LINK_H
#define LINK_H
#pragma once
#include <QString>
@ -42,7 +41,6 @@ private:
Type type;
QString value;
};
}
}
#endif // LINK_H
} // namespace messages
} // namespace chatterino

View file

@ -12,6 +12,7 @@
#include <QObjectUserData>
#include <QStringList>
#include <ctime>
#include <list>
#include <tuple>

View file

@ -1,5 +1,4 @@
#ifndef MESSAGE_H
#define MESSAGE_H
#pragma once
#include "messages/message.h"
#include "messages/messageparseargs.h"
@ -67,5 +66,3 @@ private:
} // namespace messages
} // namespace chatterino
#endif // MESSAGE_H

View file

@ -1,5 +1,4 @@
#ifndef MESSAGEPARSEARGS_H
#define MESSAGEPARSEARGS_H
#pragma once
namespace chatterino {
namespace messages {
@ -11,7 +10,6 @@ public:
bool isSentWhisper = false;
bool includeChannelName = false;
};
}
}
#endif // MESSAGEPARSEARGS_H
} // namespace messages
} // namespace chatterino

View file

@ -1,9 +1,9 @@
#ifndef MESSAGEREF_H
#define MESSAGEREF_H
#pragma once
#include "messages/message.h"
#include <QPixmap>
#include <memory>
namespace chatterino {
@ -50,5 +50,3 @@ private:
} // namespace messages
} // namespace chatterino
#endif // MESSAGEREF_H

View file

@ -130,5 +130,6 @@ std::vector<short> &Word::getCharacterWidthCache() const
{
return _characterWidthCache;
}
} // namespace messages
} // namespace chatterino

View file

@ -1,5 +1,4 @@
#ifndef WORD_H
#define WORD_H
#pragma once
#include "fontmanager.h"
#include "messages/lazyloadedimage.h"
@ -116,5 +115,3 @@ private:
} // namespace messages
} // namespace chatterino
#endif // WORD_H

View file

@ -102,5 +102,6 @@ int WordPart::getLineNumber()
{
return _lineNumber;
}
}
}
} // namespace messages
} // namespace chatterino

View file

@ -1,5 +1,4 @@
#ifndef WORDPART_H
#define WORDPART_H
#pragma once
#include <QRect>
#include <QString>
@ -48,7 +47,6 @@ private:
bool _trailingSpace;
};
}
}
#endif // WORDPART_H
} // namespace messages
} // namespace chatterino

View file

@ -56,4 +56,5 @@ void Resources::load()
Resources::buttonTimeout =
new messages::LazyLoadedImage(new QPixmap(":/images/button_timeout.png"), 0.25);
}
}
} // namespace chatterino

View file

@ -1,5 +1,4 @@
#ifndef RESOURCES_H
#define RESOURCES_H
#pragma once
#include "messages/lazyloadedimage.h"
@ -108,6 +107,5 @@ private:
static messages::LazyLoadedImage *buttonBan;
static messages::LazyLoadedImage *buttonTimeout;
};
} // namespace chatterino
#endif // RESOURCES_H
} // namespace chatterino

View file

@ -1,5 +1,4 @@
#ifndef SETTING_H
#define SETTING_H
#pragma once
#include <QSettings>
#include <QString>
@ -73,5 +72,3 @@ private:
};
} // namespace chatterino
#endif // SETTING_H

View file

@ -1,5 +1,4 @@
#ifndef APPSETTINGS_H
#define APPSETTINGS_H
#pragma once
#include "messages/word.h"
#include "setting.h"
@ -82,5 +81,3 @@ private:
};
} // namespace chatterino
#endif // APPSETTINGS_H

View file

@ -1,5 +1,4 @@
#ifndef SETTINGSSNAPSHOT_H
#define SETTINGSSNAPSHOT_H
#pragma once
#include "setting.h"
@ -28,6 +27,5 @@ public:
private:
std::vector<std::pair<std::reference_wrapper<BaseSetting>, QVariant>> _items;
};
} // namespace chatterino
#endif // SETTINGSSNAPSHOT_H
} // namespace chatterino

View file

@ -1,5 +1,4 @@
#ifndef TWITCHEMOTEVALUE_H
#define TWITCHEMOTEVALUE_H
#pragma once
#include "QString"
@ -28,7 +27,6 @@ private:
int _id;
QString _channelName;
};
}
}
#endif // TWITCHEMOTEVALUE_H
} // namespace twitch
} // namespace chatterino

View file

@ -9,6 +9,7 @@ using namespace chatterino::messages;
namespace chatterino {
namespace twitch {
TwitchMessageBuilder::TwitchMessageBuilder()
: MessageBuilder()
, messageId()
@ -345,5 +346,6 @@ SharedMessage TwitchMessageBuilder::parse(const Communi::IrcPrivateMessage *ircM
//{
// return a.first < b.first;
//}
}
}
} // namespace twitch
} // namespace chatterino

View file

@ -1,5 +1,4 @@
#ifndef TWITCHMESSAGEBUILDER_H
#define TWITCHMESSAGEBUILDER_H
#pragma once
#include "channel.h"
#include "messages/messagebuilder.h"
@ -26,6 +25,6 @@ public:
// const std::pair<long int, messages::LazyLoadedImage *> &a,
// const std::pair<long int, messages::LazyLoadedImage *> &b);
};
}
}
#endif // TWITCHMESSAGEBUILDER_H
} // namespace twitch
} // namespace chatterino

View file

@ -2,6 +2,7 @@
namespace chatterino {
namespace twitch {
TwitchUser::TwitchUser(const QString &username, const QString &oauthToken,
const QString &oauthClient)
: IrcUser2(username, username, username, "oauth:" + oauthToken)
@ -24,5 +25,6 @@ bool TwitchUser::isAnon() const
{
return IrcUser2::getNickName().startsWith("justinfan");
}
}
}
} // namespace twitch
} // namespace chatterino

View file

@ -1,5 +1,4 @@
#ifndef ACCOUNT_H
#define ACCOUNT_H
#pragma once
#include "ircaccount.h"
@ -25,5 +24,3 @@ private:
} // namespace twitch
} // namespace chatterino
#endif // ACCOUNT_H

View file

@ -1,5 +1,4 @@
#ifndef DISTANCEBETWEENPOINTS_H
#define DISTANCEBETWEENPOINTS_H
#pragma once
#include <math.h>
@ -16,7 +15,6 @@ static float distanceBetweenPoints(const QPointF &p1, const QPointF &p2)
return sqrt(distance);
}
}
}
#endif // DISTANCEBETWEENPOINTS_H
} // namespace util
} // namespace chatterino

View file

@ -1,5 +1,4 @@
#ifndef USERPOPUPWIDGET_H
#define USERPOPUPWIDGET_H
#pragma once
#include <QWidget>
@ -31,5 +30,3 @@ private:
} // namespace widgets
} // namespace chatterino
#endif // USERPOPUPWIDGET_H

View file

@ -1,5 +1,4 @@
#ifndef CHATWIDGET_H
#define CHATWIDGET_H
#pragma once
#include "channel.h"
#include "messages/limitedqueuesnapshot.h"
@ -65,5 +64,3 @@ public:
} // namespace widgets
} // namespace chatterino
#endif // CHATWIDGET_H

View file

@ -195,5 +195,6 @@ void ChatWidgetHeader::menuManualReconnect()
void ChatWidgetHeader::menuShowChangelog()
{
}
}
}
} // namespace widgets
} // namespace chatterino

View file

@ -1,5 +1,4 @@
#ifndef CHATWIDGETHEADER_H
#define CHATWIDGETHEADER_H
#pragma once
#include "signallabel.h"
#include "widgets/chatwidgetheaderbutton.h"
@ -69,7 +68,6 @@ private slots:
void menuManualReconnect();
void menuShowChangelog();
};
}
}
#endif // CHATWIDGETHEADER_H
} // namespace widgets
} // namespace chatterino

View file

@ -23,8 +23,7 @@ ChatWidgetHeaderButton::ChatWidgetHeaderButton(int spacing)
_hbox.addWidget(&_label);
_hbox.addSpacing(spacing);
QObject::connect(&_label, &SignalLabel::mouseUp, this,
&ChatWidgetHeaderButton::labelMouseUp);
QObject::connect(&_label, &SignalLabel::mouseUp, this, &ChatWidgetHeaderButton::labelMouseUp);
QObject::connect(&_label, &SignalLabel::mouseDown, this,
&ChatWidgetHeaderButton::labelMouseDown);
}
@ -94,5 +93,6 @@ void ChatWidgetHeaderButton::labelMouseDown()
update();
}
}
}
} // namespace widgets
} // namespace chatterino

View file

@ -1,5 +1,4 @@
#ifndef CHATWIDGETHEADERBUTTON_H
#define CHATWIDGETHEADERBUTTON_H
#pragma once
#include "widgets/signallabel.h"
@ -45,7 +44,6 @@ private:
void labelMouseUp();
void labelMouseDown();
};
}
}
#endif // CHATWIDGETHEADERBUTTON_H
} // namespace widgets
} // namespace chatterino

View file

@ -137,5 +137,6 @@ void ChatWidgetInput::resizeEvent(QResizeEvent *)
_edit.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
}
}
}
}
} // namespace widgets
} // namespace chatterino

View file

@ -1,5 +1,4 @@
#ifndef CHATWIDGETINPUT_H
#define CHATWIDGETINPUT_H
#pragma once
#include "resizingtextedit.h"
#include "widgets/chatwidgetheaderbutton.h"
@ -49,7 +48,6 @@ private slots:
void editTextChanged();
// void editKeyPressed(QKeyEvent *event);
};
} // namespace widgets
} // namespace chatterino
#endif // CHATWIDGETINPUT_H

View file

@ -137,5 +137,6 @@ void FancyButton::onMouseEffectTimeout()
update();
}
}
}
}
} // namespace widgets
} // namespace chatterino

View file

@ -1,5 +1,4 @@
#ifndef FANCYBUTTON_H
#define FANCYBUTTON_H
#pragma once
#include <QMouseEvent>
#include <QPainter>
@ -9,6 +8,7 @@
namespace chatterino {
namespace widgets {
class FancyButton : public QWidget
{
struct ClickEffect {
@ -49,7 +49,6 @@ private:
void onMouseEffectTimeout();
};
}
}
#endif // FANCYBUTTON_H
} // namespace widgets
} // namespace chatterino

View file

@ -150,5 +150,6 @@ Notebook &MainWindow::getNotebook()
{
return _notebook;
}
} // namespace widgets
} // namespace chatterino

View file

@ -1,5 +1,4 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#pragma once
#include "widgets/notebook.h"
#include "widgets/titlebar.h"
@ -42,5 +41,3 @@ private:
} // namespace widgets
} // namespace chatterino
#endif // MAINWINDOW_H

View file

@ -1,5 +1,4 @@
#ifndef NOTEBOOK_H
#define NOTEBOOK_H
#pragma once
#include "widgets/notebookbutton.h"
#include "widgets/notebookpage.h"
@ -63,5 +62,3 @@ public:
} // namespace widgets
} // namespace chatterino
#endif // NOTEBOOK_H

View file

@ -102,5 +102,6 @@ void NotebookButton::mouseReleaseEvent(QMouseEvent *event)
FancyButton::mouseReleaseEvent(event);
}
}
}
} // namespace widgets
} // namespace chatterino

View file

@ -1,5 +1,4 @@
#ifndef NOTEBOOKBUTTON_H
#define NOTEBOOKBUTTON_H
#pragma once
#include "fancybutton.h"
@ -36,5 +35,3 @@ private:
} // namespace widgets
} // namespace chatterino
#endif // NOTEBOOKBUTTON_H

View file

@ -49,8 +49,7 @@ NotebookTab *NotebookPage::getTab() const
return _tab;
}
void
NotebookPage::addChat(bool openChannelNameDialog)
void NotebookPage::addChat(bool openChannelNameDialog)
{
ChatWidget *w = new ChatWidget();

View file

@ -1,5 +1,4 @@
#ifndef NOTEBOOKPAGE_H
#define NOTEBOOKPAGE_H
#pragma once
#include "widgets/chatwidget.h"
#include "widgets/notebookpage.h"
@ -82,5 +81,3 @@ public:
} // namespace widgets
} // namespace chatterino
#endif // NOTEBOOKPAGE_H

View file

@ -50,5 +50,6 @@ void NotebookPageDropPreview::setBounds(const QRect &rect)
animate = true;
}
}
}
} // namespace widgets
} // namespace chatterino

View file

@ -1,5 +1,4 @@
#ifndef NOTEBOOKPAGEDROPPREVIEW_H
#define NOTEBOOKPAGEDROPPREVIEW_H
#pragma once
#include <QPropertyAnimation>
#include <QWidget>
@ -23,7 +22,6 @@ protected:
QRect desiredGeometry;
bool animate;
};
} // namespace widgets
} // namespace chatterino
#endif // NOTEBOOKPAGEDROPPREVIEW_H

View file

@ -1,5 +1,4 @@
#ifndef NOTEBOOKTAB_H
#define NOTEBOOKTAB_H
#pragma once
#include <QPropertyAnimation>
#include <QWidget>
@ -83,5 +82,3 @@ public:
} // namespace widgets
} // namespace chatterino
#endif // NOTEBOOKTAB_H

View file

@ -1,5 +1,4 @@
#ifndef RESIZINGTEXTEDIT_H
#define RESIZINGTEXTEDIT_H
#pragma once
#include <QKeyEvent>
#include <QTextEdit>
@ -50,5 +49,3 @@ protected:
}
}
};
#endif // RESIZINGTEXTEDIT_H

View file

@ -1,5 +1,4 @@
#ifndef SCROLLBARHIGHLIGHT_H
#define SCROLLBARHIGHLIGHT_H
#pragma once
#include "QString"
@ -45,5 +44,3 @@ private:
} // namespace widgets
} // namespace chatterino
#endif // SCROLLBARHIGHLIGHT_H

View file

@ -1,5 +1,4 @@
#ifndef SETTINGSDIALOG_H
#define SETTINGSDIALOG_H
#pragma once
#include "settingsmanager.h"
#include "settingssnapshot.h"
@ -54,5 +53,3 @@ private:
} // namespace widgets
} // namespace chatterino
#endif // SETTINGSDIALOG_H

View file

@ -71,5 +71,6 @@ void SettingsDialogTab::mousePressEvent(QMouseEvent *event)
_dialog->select(this);
}
} // namespace widgets
} // namespace chatterino

View file

@ -1,5 +1,4 @@
#ifndef SETTINGSNOTEBOOKTAB_H
#define SETTINGSNOTEBOOKTAB_H
#pragma once
#include <QPaintEvent>
#include <QWidget>
@ -37,7 +36,6 @@ private:
bool _selected;
};
} // namespace widgets
} // namespace chatterino
#endif // SETTINGSNOTEBOOKTAB_H

View file

@ -1,5 +1,4 @@
#ifndef SIGNALLABEL_H
#define SIGNALLABEL_H
#pragma once
#include <QFlags>
#include <QLabel>
@ -52,5 +51,3 @@ protected:
event->ignore();
}
};
#endif // SIGNALLABEL_H

View file

@ -38,5 +38,6 @@ void TextInputDialog::cancelButtonClicked()
reject();
close();
}
}
}
} // namespace widgets
} // namespace chatterino

View file

@ -1,5 +1,4 @@
#ifndef TEXTINPUTDIALOG_H
#define TEXTINPUTDIALOG_H
#pragma once
#include <QDialog>
#include <QHBoxLayout>
@ -39,7 +38,6 @@ private slots:
void okButtonClicked();
void cancelButtonClicked();
};
}
}
#endif // TEXTINPUTDIALOG_H
} // namespace widgets
} // namespace chatterino

View file

@ -2,10 +2,12 @@
namespace chatterino {
namespace widgets {
TitleBar::TitleBar(QWidget *parent)
: QWidget(parent)
{
setFixedHeight(32);
}
}
}
} // namespace widgets
} // namespace chatterino

View file

@ -1,16 +1,15 @@
#ifndef TITLEBAR_H
#define TITLEBAR_H
#pragma once
#include <QWidget>
namespace chatterino {
namespace widgets {
class TitleBar : public QWidget
{
public:
TitleBar(QWidget *parent = nullptr);
};
}
}
#endif // TITLEBAR_H
} // namespace widgets
} // namespace chatterino

View file

@ -1,5 +1,4 @@
#ifndef WINDOWS_H
#define WINDOWS_H
#pragma once
#include "widgets/mainwindow.h"
@ -35,5 +34,3 @@ private:
};
} // namespace chatterino
#endif // WINDOWS_H