Normalize line endings in already existing files
This commit is contained in:
@@ -1,31 +1,31 @@
|
||||
#include "Command.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
// command
|
||||
Command::Command(const QString &_text)
|
||||
{
|
||||
int index = _text.indexOf(' ');
|
||||
|
||||
if (index == -1)
|
||||
{
|
||||
this->name = _text;
|
||||
return;
|
||||
}
|
||||
|
||||
this->name = _text.mid(0, index).trimmed();
|
||||
this->func = _text.mid(index + 1).trimmed();
|
||||
}
|
||||
|
||||
Command::Command(const QString &_name, const QString &_func)
|
||||
: name(_name.trimmed())
|
||||
, func(_func.trimmed())
|
||||
{
|
||||
}
|
||||
|
||||
QString Command::toString() const
|
||||
{
|
||||
return this->name + " " + this->func;
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
#include "Command.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
// command
|
||||
Command::Command(const QString &_text)
|
||||
{
|
||||
int index = _text.indexOf(' ');
|
||||
|
||||
if (index == -1)
|
||||
{
|
||||
this->name = _text;
|
||||
return;
|
||||
}
|
||||
|
||||
this->name = _text.mid(0, index).trimmed();
|
||||
this->func = _text.mid(index + 1).trimmed();
|
||||
}
|
||||
|
||||
Command::Command(const QString &_name, const QString &_func)
|
||||
: name(_name.trimmed())
|
||||
, func(_func.trimmed())
|
||||
{
|
||||
}
|
||||
|
||||
QString Command::toString() const
|
||||
{
|
||||
return this->name + " " + this->func;
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -1,67 +1,67 @@
|
||||
#pragma once
|
||||
|
||||
#include "util/RapidjsonHelpers.hpp"
|
||||
|
||||
#include <QString>
|
||||
#include <pajlada/serialize.hpp>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
struct Command {
|
||||
QString name;
|
||||
QString func;
|
||||
|
||||
Command() = default;
|
||||
explicit Command(const QString &text);
|
||||
Command(const QString &name, const QString &func);
|
||||
|
||||
QString toString() const;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
namespace pajlada {
|
||||
|
||||
template <>
|
||||
struct Serialize<chatterino::Command> {
|
||||
static rapidjson::Value get(const chatterino::Command &value,
|
||||
rapidjson::Document::AllocatorType &a)
|
||||
{
|
||||
rapidjson::Value ret(rapidjson::kObjectType);
|
||||
|
||||
chatterino::rj::set(ret, "name", value.name, a);
|
||||
chatterino::rj::set(ret, "func", value.func, a);
|
||||
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Deserialize<chatterino::Command> {
|
||||
static chatterino::Command get(const rapidjson::Value &value,
|
||||
bool *error = nullptr)
|
||||
{
|
||||
chatterino::Command command;
|
||||
|
||||
if (!value.IsObject())
|
||||
{
|
||||
PAJLADA_REPORT_ERROR(error);
|
||||
return command;
|
||||
}
|
||||
|
||||
if (!chatterino::rj::getSafe(value, "name", command.name))
|
||||
{
|
||||
PAJLADA_REPORT_ERROR(error);
|
||||
return command;
|
||||
}
|
||||
if (!chatterino::rj::getSafe(value, "func", command.func))
|
||||
{
|
||||
PAJLADA_REPORT_ERROR(error);
|
||||
return command;
|
||||
}
|
||||
|
||||
return command;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace pajlada
|
||||
#pragma once
|
||||
|
||||
#include "util/RapidjsonHelpers.hpp"
|
||||
|
||||
#include <QString>
|
||||
#include <pajlada/serialize.hpp>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
struct Command {
|
||||
QString name;
|
||||
QString func;
|
||||
|
||||
Command() = default;
|
||||
explicit Command(const QString &text);
|
||||
Command(const QString &name, const QString &func);
|
||||
|
||||
QString toString() const;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
namespace pajlada {
|
||||
|
||||
template <>
|
||||
struct Serialize<chatterino::Command> {
|
||||
static rapidjson::Value get(const chatterino::Command &value,
|
||||
rapidjson::Document::AllocatorType &a)
|
||||
{
|
||||
rapidjson::Value ret(rapidjson::kObjectType);
|
||||
|
||||
chatterino::rj::set(ret, "name", value.name, a);
|
||||
chatterino::rj::set(ret, "func", value.func, a);
|
||||
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Deserialize<chatterino::Command> {
|
||||
static chatterino::Command get(const rapidjson::Value &value,
|
||||
bool *error = nullptr)
|
||||
{
|
||||
chatterino::Command command;
|
||||
|
||||
if (!value.IsObject())
|
||||
{
|
||||
PAJLADA_REPORT_ERROR(error);
|
||||
return command;
|
||||
}
|
||||
|
||||
if (!chatterino::rj::getSafe(value, "name", command.name))
|
||||
{
|
||||
PAJLADA_REPORT_ERROR(error);
|
||||
return command;
|
||||
}
|
||||
if (!chatterino::rj::getSafe(value, "func", command.func))
|
||||
{
|
||||
PAJLADA_REPORT_ERROR(error);
|
||||
return command;
|
||||
}
|
||||
|
||||
return command;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace pajlada
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,56 +1,56 @@
|
||||
#pragma once
|
||||
|
||||
#include "common/ChatterinoSetting.hpp"
|
||||
#include "common/SignalVector.hpp"
|
||||
#include "common/Singleton.hpp"
|
||||
#include "controllers/commands/Command.hpp"
|
||||
|
||||
#include <QMap>
|
||||
#include <pajlada/settings.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
class Settings;
|
||||
class Paths;
|
||||
class Channel;
|
||||
|
||||
class CommandModel;
|
||||
|
||||
class CommandController final : public Singleton
|
||||
{
|
||||
public:
|
||||
UnsortedSignalVector<Command> items_;
|
||||
|
||||
QString execCommand(const QString &text, std::shared_ptr<Channel> channel,
|
||||
bool dryRun);
|
||||
QStringList getDefaultTwitchCommandList();
|
||||
|
||||
virtual void initialize(Settings &, Paths &paths) override;
|
||||
virtual void save() override;
|
||||
|
||||
CommandModel *createModel(QObject *parent);
|
||||
|
||||
private:
|
||||
void load(Paths &paths);
|
||||
|
||||
QMap<QString, Command> commandsMap_;
|
||||
int maxSpaces_ = 0;
|
||||
|
||||
std::mutex mutex_;
|
||||
|
||||
std::shared_ptr<pajlada::Settings::SettingManager> sm_;
|
||||
// Because the setting manager is not initialized until the initialize
|
||||
// function is called (and not in the constructor), we have to
|
||||
// late-initialize the setting, which is why we're storing it as a
|
||||
// unique_ptr
|
||||
std::unique_ptr<pajlada::Settings::Setting<std::vector<Command>>>
|
||||
commandsSetting_;
|
||||
|
||||
QString execCustomCommand(const QStringList &words, const Command &command,
|
||||
bool dryRun);
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
#pragma once
|
||||
|
||||
#include "common/ChatterinoSetting.hpp"
|
||||
#include "common/SignalVector.hpp"
|
||||
#include "common/Singleton.hpp"
|
||||
#include "controllers/commands/Command.hpp"
|
||||
|
||||
#include <QMap>
|
||||
#include <pajlada/settings.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
class Settings;
|
||||
class Paths;
|
||||
class Channel;
|
||||
|
||||
class CommandModel;
|
||||
|
||||
class CommandController final : public Singleton
|
||||
{
|
||||
public:
|
||||
UnsortedSignalVector<Command> items_;
|
||||
|
||||
QString execCommand(const QString &text, std::shared_ptr<Channel> channel,
|
||||
bool dryRun);
|
||||
QStringList getDefaultTwitchCommandList();
|
||||
|
||||
virtual void initialize(Settings &, Paths &paths) override;
|
||||
virtual void save() override;
|
||||
|
||||
CommandModel *createModel(QObject *parent);
|
||||
|
||||
private:
|
||||
void load(Paths &paths);
|
||||
|
||||
QMap<QString, Command> commandsMap_;
|
||||
int maxSpaces_ = 0;
|
||||
|
||||
std::mutex mutex_;
|
||||
|
||||
std::shared_ptr<pajlada::Settings::SettingManager> sm_;
|
||||
// Because the setting manager is not initialized until the initialize
|
||||
// function is called (and not in the constructor), we have to
|
||||
// late-initialize the setting, which is why we're storing it as a
|
||||
// unique_ptr
|
||||
std::unique_ptr<pajlada::Settings::Setting<std::vector<Command>>>
|
||||
commandsSetting_;
|
||||
|
||||
QString execCustomCommand(const QStringList &words, const Command &command,
|
||||
bool dryRun);
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
#include "CommandModel.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
// commandmodel
|
||||
CommandModel::CommandModel(QObject *parent)
|
||||
: SignalVectorModel<Command>(2, parent)
|
||||
{
|
||||
}
|
||||
|
||||
// turn a vector item into a model row
|
||||
Command CommandModel::getItemFromRow(std::vector<QStandardItem *> &row,
|
||||
const Command &original)
|
||||
{
|
||||
return Command(row[0]->data(Qt::EditRole).toString(),
|
||||
row[1]->data(Qt::EditRole).toString());
|
||||
}
|
||||
|
||||
// turns a row in the model into a vector item
|
||||
void CommandModel::getRowFromItem(const Command &item,
|
||||
std::vector<QStandardItem *> &row)
|
||||
{
|
||||
row[0]->setData(item.name, Qt::DisplayRole);
|
||||
row[0]->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable |
|
||||
Qt::ItemIsEditable);
|
||||
row[1]->setData(item.func, Qt::DisplayRole);
|
||||
row[1]->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable |
|
||||
Qt::ItemIsEditable);
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
#include "CommandModel.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
// commandmodel
|
||||
CommandModel::CommandModel(QObject *parent)
|
||||
: SignalVectorModel<Command>(2, parent)
|
||||
{
|
||||
}
|
||||
|
||||
// turn a vector item into a model row
|
||||
Command CommandModel::getItemFromRow(std::vector<QStandardItem *> &row,
|
||||
const Command &original)
|
||||
{
|
||||
return Command(row[0]->data(Qt::EditRole).toString(),
|
||||
row[1]->data(Qt::EditRole).toString());
|
||||
}
|
||||
|
||||
// turns a row in the model into a vector item
|
||||
void CommandModel::getRowFromItem(const Command &item,
|
||||
std::vector<QStandardItem *> &row)
|
||||
{
|
||||
row[0]->setData(item.name, Qt::DisplayRole);
|
||||
row[0]->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable |
|
||||
Qt::ItemIsEditable);
|
||||
row[1]->setData(item.func, Qt::DisplayRole);
|
||||
row[1]->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable |
|
||||
Qt::ItemIsEditable);
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "common/SignalVectorModel.hpp"
|
||||
#include "controllers/commands/Command.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
class CommandController;
|
||||
|
||||
class CommandModel : public SignalVectorModel<Command>
|
||||
{
|
||||
explicit CommandModel(QObject *parent);
|
||||
|
||||
protected:
|
||||
// turn a vector item into a model row
|
||||
virtual Command getItemFromRow(std::vector<QStandardItem *> &row,
|
||||
const Command &command) override;
|
||||
|
||||
// turns a row in the model into a vector item
|
||||
virtual void getRowFromItem(const Command &item,
|
||||
std::vector<QStandardItem *> &row) override;
|
||||
|
||||
friend class CommandController;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "common/SignalVectorModel.hpp"
|
||||
#include "controllers/commands/Command.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
class CommandController;
|
||||
|
||||
class CommandModel : public SignalVectorModel<Command>
|
||||
{
|
||||
explicit CommandModel(QObject *parent);
|
||||
|
||||
protected:
|
||||
// turn a vector item into a model row
|
||||
virtual Command getItemFromRow(std::vector<QStandardItem *> &row,
|
||||
const Command &command) override;
|
||||
|
||||
// turns a row in the model into a vector item
|
||||
virtual void getRowFromItem(const Command &item,
|
||||
std::vector<QStandardItem *> &row) override;
|
||||
|
||||
friend class CommandController;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
Reference in New Issue
Block a user