Applied project style to multiple files
This commit is contained in:
@@ -17,10 +17,10 @@
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
Channel::Channel(const QString &_name, Type _type)
|
||||
Channel::Channel(const QString &_name, Type type)
|
||||
: name(_name)
|
||||
, completionModel(this->name)
|
||||
, type_(_type)
|
||||
, type_(type)
|
||||
{
|
||||
QObject::connect(&this->clearCompletionModelTimer_, &QTimer::timeout, [this]() {
|
||||
this->completionModel.clearExpiredStrings(); //
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
Misc
|
||||
};
|
||||
|
||||
explicit Channel(const QString &_name, Type type_);
|
||||
explicit Channel(const QString &name, Type type);
|
||||
virtual ~Channel();
|
||||
|
||||
pajlada::Signals::Signal<const QString &, const QString &, bool &> sendMessageSignal;
|
||||
|
||||
@@ -11,14 +11,14 @@ template <typename Type>
|
||||
class ChatterinoSetting : public pajlada::Settings::Setting<Type>
|
||||
{
|
||||
public:
|
||||
ChatterinoSetting(const std::string &_path)
|
||||
: pajlada::Settings::Setting<Type>(_path)
|
||||
ChatterinoSetting(const std::string &path)
|
||||
: pajlada::Settings::Setting<Type>(path)
|
||||
{
|
||||
_registerSetting(this->data);
|
||||
}
|
||||
|
||||
ChatterinoSetting(const std::string &_path, const Type &_defaultValue)
|
||||
: pajlada::Settings::Setting<Type>(_path, _defaultValue)
|
||||
ChatterinoSetting(const std::string &path, const Type &defaultValue)
|
||||
: pajlada::Settings::Setting<Type>(path, defaultValue)
|
||||
{
|
||||
_registerSetting(this->data);
|
||||
}
|
||||
|
||||
@@ -73,8 +73,8 @@ bool CompletionModel::TaggedString::operator<(const TaggedString &that) const
|
||||
|
||||
// -- CompletionModel
|
||||
|
||||
CompletionModel::CompletionModel(const QString &_channelName)
|
||||
: channelName_(_channelName)
|
||||
CompletionModel::CompletionModel(const QString &channelName)
|
||||
: channelName_(channelName)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ class CompletionModel : public QAbstractListModel
|
||||
};
|
||||
|
||||
public:
|
||||
CompletionModel(const QString &_channelName);
|
||||
CompletionModel(const QString &channelName);
|
||||
|
||||
virtual int columnCount(const QModelIndex &) const override;
|
||||
virtual QVariant data(const QModelIndex &index, int) const override;
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
EmoteData::EmoteData(Image *_image)
|
||||
: image1x(_image)
|
||||
EmoteData::EmoteData(Image *image)
|
||||
: image1x(image)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace chatterino {
|
||||
struct EmoteData {
|
||||
EmoteData() = default;
|
||||
|
||||
EmoteData(Image *_image);
|
||||
EmoteData(Image *image);
|
||||
|
||||
// Emotes must have a 1x image to be valid
|
||||
bool isValid() const;
|
||||
|
||||
@@ -24,9 +24,9 @@ void NetworkRequest::setRequestType(RequestType newRequestType)
|
||||
this->data.requestType = newRequestType;
|
||||
}
|
||||
|
||||
void NetworkRequest::setCaller(const QObject *_caller)
|
||||
void NetworkRequest::setCaller(const QObject *caller)
|
||||
{
|
||||
this->data.caller = _caller;
|
||||
this->data.caller = caller;
|
||||
}
|
||||
|
||||
void NetworkRequest::setOnReplyCreated(std::function<void(QNetworkReply *)> f)
|
||||
|
||||
@@ -135,7 +135,7 @@ public:
|
||||
}
|
||||
|
||||
void setUseQuickLoadCache(bool value);
|
||||
void setCaller(const QObject *_caller);
|
||||
void setCaller(const QObject *caller);
|
||||
void setOnReplyCreated(std::function<void(QNetworkReply *)> f);
|
||||
void setRawHeader(const char *headerName, const char *value);
|
||||
void setRawHeader(const char *headerName, const QByteArray &value);
|
||||
|
||||
@@ -12,23 +12,23 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
Property(const T &_value)
|
||||
: value(_value)
|
||||
Property(const T &value)
|
||||
: value_(value)
|
||||
{
|
||||
}
|
||||
|
||||
T &operator=(const T &f)
|
||||
{
|
||||
return value = f;
|
||||
return value_ = f;
|
||||
}
|
||||
|
||||
operator T const &() const
|
||||
{
|
||||
return value;
|
||||
return value_;
|
||||
}
|
||||
|
||||
protected:
|
||||
T value;
|
||||
T value_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -10,9 +10,7 @@ template <>
|
||||
struct Serialize<QString> {
|
||||
static rapidjson::Value get(const QString &value, rapidjson::Document::AllocatorType &a)
|
||||
{
|
||||
rapidjson::Value ret(value.toUtf8(), a);
|
||||
|
||||
return ret;
|
||||
return rapidjson::Value(value.toUtf8(), a);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -27,10 +25,7 @@ struct Deserialize<QString> {
|
||||
}
|
||||
|
||||
try {
|
||||
const char *str = value.GetString();
|
||||
auto strLen = value.GetStringLength();
|
||||
|
||||
return QString::fromUtf8(str, strLen);
|
||||
return QString::fromUtf8(value.GetString(), value.GetStringLength());
|
||||
} catch (const std::exception &) {
|
||||
// int x = 5;
|
||||
} catch (...) {
|
||||
|
||||
+17
-17
@@ -23,10 +23,10 @@ class ReadOnlySignalVector : boost::noncopyable
|
||||
public:
|
||||
ReadOnlySignalVector()
|
||||
{
|
||||
QObject::connect(&this->itemsChangedTimer, &QTimer::timeout,
|
||||
QObject::connect(&this->itemsChangedTimer_, &QTimer::timeout,
|
||||
[this] { this->delayedItemsChanged.invoke(); });
|
||||
this->itemsChangedTimer.setInterval(100);
|
||||
this->itemsChangedTimer.setSingleShot(true);
|
||||
this->itemsChangedTimer_.setInterval(100);
|
||||
this->itemsChangedTimer_.setSingleShot(true);
|
||||
}
|
||||
virtual ~ReadOnlySignalVector() = default;
|
||||
|
||||
@@ -38,23 +38,23 @@ public:
|
||||
{
|
||||
assertInGuiThread();
|
||||
|
||||
return this->vector;
|
||||
return this->vector_;
|
||||
}
|
||||
|
||||
void invokeDelayedItemsChanged()
|
||||
{
|
||||
assertInGuiThread();
|
||||
|
||||
if (!this->itemsChangedTimer.isActive()) {
|
||||
itemsChangedTimer.start();
|
||||
if (!this->itemsChangedTimer_.isActive()) {
|
||||
this->itemsChangedTimer_.start();
|
||||
}
|
||||
}
|
||||
|
||||
virtual bool isSorted() const = 0;
|
||||
|
||||
protected:
|
||||
std::vector<TVectorItem> vector;
|
||||
QTimer itemsChangedTimer;
|
||||
std::vector<TVectorItem> vector_;
|
||||
QTimer itemsChangedTimer_;
|
||||
};
|
||||
|
||||
template <typename TVectorItem>
|
||||
@@ -68,10 +68,10 @@ public:
|
||||
void removeItem(int index, void *caller = nullptr)
|
||||
{
|
||||
assertInGuiThread();
|
||||
assert(index >= 0 && index < this->vector.size());
|
||||
assert(index >= 0 && index < this->vector_.size());
|
||||
|
||||
TVectorItem item = this->vector[index];
|
||||
this->vector.erase(this->vector.begin() + index);
|
||||
TVectorItem item = this->vector_[index];
|
||||
this->vector_.erase(this->vector_.begin() + index);
|
||||
SignalVectorItemArgs<TVectorItem> args{item, index, caller};
|
||||
this->itemRemoved.invoke(args);
|
||||
|
||||
@@ -92,12 +92,12 @@ public:
|
||||
{
|
||||
assertInGuiThread();
|
||||
if (index == -1) {
|
||||
index = this->vector.size();
|
||||
index = this->vector_.size();
|
||||
} else {
|
||||
assert(index >= 0 && index <= this->vector.size());
|
||||
assert(index >= 0 && index <= this->vector_.size());
|
||||
}
|
||||
|
||||
this->vector.insert(this->vector.begin() + index, item);
|
||||
this->vector_.insert(this->vector_.begin() + index, item);
|
||||
|
||||
SignalVectorItemArgs<TVectorItem> args{item, index, caller};
|
||||
this->itemInserted.invoke(args);
|
||||
@@ -119,9 +119,9 @@ public:
|
||||
{
|
||||
assertInGuiThread();
|
||||
|
||||
auto it = std::lower_bound(this->vector.begin(), this->vector.end(), item, Compare{});
|
||||
int index = it - this->vector.begin();
|
||||
this->vector.insert(it, item);
|
||||
auto it = std::lower_bound(this->vector_.begin(), this->vector_.end(), item, Compare{});
|
||||
int index = it - this->vector_.begin();
|
||||
this->vector_.insert(it, item);
|
||||
|
||||
SignalVectorItemArgs<TVectorItem> args{item, index, caller};
|
||||
this->itemInserted.invoke(args);
|
||||
|
||||
@@ -16,16 +16,16 @@ class SignalVectorModel : public QAbstractTableModel, pajlada::Signals::SignalHo
|
||||
public:
|
||||
SignalVectorModel(int columnCount, QObject *parent = nullptr)
|
||||
: QAbstractTableModel(parent)
|
||||
, _columnCount(columnCount)
|
||||
, columnCount_(columnCount)
|
||||
{
|
||||
for (int i = 0; i < columnCount; i++) {
|
||||
this->_headerData.emplace_back();
|
||||
this->headerData_.emplace_back();
|
||||
}
|
||||
}
|
||||
|
||||
void init(BaseSignalVector<TVectorItem> *vec)
|
||||
{
|
||||
this->vector = vec;
|
||||
this->vector_ = vec;
|
||||
|
||||
auto insert = [this](const SignalVectorItemArgs<TVectorItem> &args) {
|
||||
if (args.caller == this) {
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
}
|
||||
// get row index
|
||||
int index = this->getModelIndexFromVectorIndex(args.index);
|
||||
assert(index >= 0 && index <= this->rows.size());
|
||||
assert(index >= 0 && index <= this->rows_.size());
|
||||
|
||||
// get row items
|
||||
std::vector<QStandardItem *> row = this->createRow();
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
index = this->beforeInsert(args.item, row, index);
|
||||
|
||||
this->beginInsertRows(QModelIndex(), index, index);
|
||||
this->rows.insert(this->rows.begin() + index, Row(row, args.item));
|
||||
this->rows_.insert(this->rows_.begin() + index, Row(row, args.item));
|
||||
this->endInsertRows();
|
||||
};
|
||||
|
||||
@@ -62,13 +62,13 @@ public:
|
||||
}
|
||||
|
||||
int row = this->getModelIndexFromVectorIndex(args.index);
|
||||
assert(row >= 0 && row <= this->rows.size());
|
||||
assert(row >= 0 && row <= this->rows_.size());
|
||||
|
||||
// remove row
|
||||
std::vector<QStandardItem *> items = std::move(this->rows[row].items);
|
||||
std::vector<QStandardItem *> items = std::move(this->rows_[row].items);
|
||||
|
||||
this->beginRemoveRows(QModelIndex(), row, row);
|
||||
this->rows.erase(this->rows.begin() + row);
|
||||
this->rows_.erase(this->rows_.begin() + row);
|
||||
this->endRemoveRows();
|
||||
|
||||
this->afterRemoved(args.item, items, row);
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
|
||||
virtual ~SignalVectorModel()
|
||||
{
|
||||
for (Row &row : this->rows) {
|
||||
for (Row &row : this->rows_) {
|
||||
for (QStandardItem *item : row.items) {
|
||||
delete item;
|
||||
}
|
||||
@@ -92,28 +92,28 @@ public:
|
||||
|
||||
int rowCount(const QModelIndex &parent) const override
|
||||
{
|
||||
return this->rows.size();
|
||||
return this->rows_.size();
|
||||
}
|
||||
|
||||
int columnCount(const QModelIndex &parent) const override
|
||||
{
|
||||
return this->_columnCount;
|
||||
return this->columnCount_;
|
||||
}
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const override
|
||||
{
|
||||
int row = index.row(), column = index.column();
|
||||
assert(row >= 0 && row < this->rows.size() && column >= 0 && column < this->_columnCount);
|
||||
assert(row >= 0 && row < this->rows_.size() && column >= 0 && column < this->columnCount_);
|
||||
|
||||
return rows[row].items[column]->data(role);
|
||||
return rows_[row].items[column]->data(role);
|
||||
}
|
||||
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role) override
|
||||
{
|
||||
int row = index.row(), column = index.column();
|
||||
assert(row >= 0 && row < this->rows.size() && column >= 0 && column < this->_columnCount);
|
||||
assert(row >= 0 && row < this->rows_.size() && column >= 0 && column < this->columnCount_);
|
||||
|
||||
Row &rowItem = this->rows[row];
|
||||
Row &rowItem = this->rows_[row];
|
||||
|
||||
rowItem.items[column]->setData(value, role);
|
||||
|
||||
@@ -121,12 +121,12 @@ public:
|
||||
this->customRowSetData(rowItem.items, column, value, role);
|
||||
} else {
|
||||
int vecRow = this->getVectorIndexFromModelIndex(row);
|
||||
this->vector->removeItem(vecRow, this);
|
||||
this->vector_->removeItem(vecRow, this);
|
||||
|
||||
assert(this->rows[row].original);
|
||||
assert(this->rows_[row].original);
|
||||
TVectorItem item =
|
||||
this->getItemFromRow(this->rows[row].items, this->rows[row].original.get());
|
||||
this->vector->insertItem(item, vecRow, this);
|
||||
this->getItemFromRow(this->rows_[row].items, this->rows_[row].original.get());
|
||||
this->vector_->insertItem(item, vecRow, this);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -138,8 +138,8 @@ public:
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
auto it = this->_headerData[section].find(role);
|
||||
if (it == this->_headerData[section].end()) {
|
||||
auto it = this->headerData_[section].find(role);
|
||||
if (it == this->headerData_[section].end()) {
|
||||
return QVariant();
|
||||
} else {
|
||||
return it.value();
|
||||
@@ -153,7 +153,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
this->_headerData[section][role] = value;
|
||||
this->headerData_[section][role] = value;
|
||||
|
||||
emit this->headerDataChanged(Qt::Horizontal, section, section);
|
||||
return true;
|
||||
@@ -162,22 +162,22 @@ public:
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override
|
||||
{
|
||||
int row = index.row(), column = index.column();
|
||||
assert(row >= 0 && row < this->rows.size() && column >= 0 && column < this->_columnCount);
|
||||
assert(row >= 0 && row < this->rows_.size() && column >= 0 && column < this->columnCount_);
|
||||
|
||||
return this->rows[index.row()].items[index.column()]->flags();
|
||||
return this->rows_[index.row()].items[index.column()]->flags();
|
||||
}
|
||||
|
||||
QStandardItem *getItem(int row, int column)
|
||||
{
|
||||
assert(row >= 0 && row < this->rows.size() && column >= 0 && column < this->_columnCount);
|
||||
assert(row >= 0 && row < this->rows_.size() && column >= 0 && column < this->columnCount_);
|
||||
|
||||
return rows[row].items[column];
|
||||
return rows_[row].items[column];
|
||||
}
|
||||
|
||||
void deleteRow(int row)
|
||||
{
|
||||
int signalVectorRow = this->getVectorIndexFromModelIndex(row);
|
||||
this->vector->removeItem(signalVectorRow);
|
||||
this->vector_->removeItem(signalVectorRow);
|
||||
}
|
||||
|
||||
bool removeRows(int row, int count, const QModelIndex &parent) override
|
||||
@@ -186,10 +186,10 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
assert(row >= 0 && row < this->rows.size());
|
||||
assert(row >= 0 && row < this->rows_.size());
|
||||
|
||||
int signalVectorRow = this->getVectorIndexFromModelIndex(row);
|
||||
this->vector->removeItem(signalVectorRow);
|
||||
this->vector_->removeItem(signalVectorRow);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -223,27 +223,27 @@ protected:
|
||||
|
||||
void insertCustomRow(std::vector<QStandardItem *> row, int index)
|
||||
{
|
||||
assert(index >= 0 && index <= this->rows.size());
|
||||
assert(index >= 0 && index <= this->rows_.size());
|
||||
|
||||
this->beginInsertRows(QModelIndex(), index, index);
|
||||
this->rows.insert(this->rows.begin() + index, Row(std::move(row), true));
|
||||
this->rows_.insert(this->rows_.begin() + index, Row(std::move(row), true));
|
||||
this->endInsertRows();
|
||||
}
|
||||
|
||||
void removeCustomRow(int index)
|
||||
{
|
||||
assert(index >= 0 && index <= this->rows.size());
|
||||
assert(this->rows[index].isCustomRow);
|
||||
assert(index >= 0 && index <= this->rows_.size());
|
||||
assert(this->rows_[index].isCustomRow);
|
||||
|
||||
this->beginRemoveRows(QModelIndex(), index, index);
|
||||
this->rows.erase(this->rows.begin() + index);
|
||||
this->rows_.erase(this->rows_.begin() + index);
|
||||
this->endRemoveRows();
|
||||
}
|
||||
|
||||
std::vector<QStandardItem *> createRow()
|
||||
{
|
||||
std::vector<QStandardItem *> row;
|
||||
for (int i = 0; i < this->_columnCount; i++) {
|
||||
for (int i = 0; i < this->columnCount_; i++) {
|
||||
row.push_back(new QStandardItem());
|
||||
}
|
||||
return row;
|
||||
@@ -268,20 +268,20 @@ protected:
|
||||
{
|
||||
}
|
||||
};
|
||||
std::vector<Row> rows;
|
||||
|
||||
private:
|
||||
std::vector<QMap<int, QVariant>> _headerData;
|
||||
BaseSignalVector<TVectorItem> *vector;
|
||||
std::vector<QMap<int, QVariant>> headerData_;
|
||||
BaseSignalVector<TVectorItem> *vector_;
|
||||
std::vector<Row> rows_;
|
||||
|
||||
int _columnCount;
|
||||
int columnCount_;
|
||||
|
||||
// returns the related index of the SignalVector
|
||||
int getVectorIndexFromModelIndex(int index)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (auto &row : this->rows) {
|
||||
for (auto &row : this->rows_) {
|
||||
if (row.isCustomRow) {
|
||||
index--;
|
||||
continue;
|
||||
@@ -301,7 +301,7 @@ private:
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (auto &row : this->rows) {
|
||||
for (auto &row : this->rows_) {
|
||||
if (row.isCustomRow) {
|
||||
index++;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class SimpleSignalVector
|
||||
public:
|
||||
SimpleSignalVector &operator=(std::vector<TValue> &other)
|
||||
{
|
||||
this->data = other;
|
||||
this->data_ = other;
|
||||
|
||||
this->updated.invoke();
|
||||
|
||||
@@ -22,13 +22,13 @@ public:
|
||||
|
||||
operator std::vector<TValue> &()
|
||||
{
|
||||
return this->data;
|
||||
return this->data_;
|
||||
}
|
||||
|
||||
pajlada::Signals::NoArgSignal updated;
|
||||
|
||||
private:
|
||||
std::vector<TValue> data;
|
||||
std::vector<TValue> data_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
Reference in New Issue
Block a user