mirror of
https://github.com/fergalmoran/flameshot.git
synced 2025-12-22 17:59:25 +00:00
reformatted to Mozilla code style
This commit is contained in:
committed by
borgmanJeremy
parent
c0e2e48db4
commit
c8d15205be
@@ -17,96 +17,124 @@
|
||||
|
||||
#include "commandoption.h"
|
||||
|
||||
CommandOption::CommandOption(const QString &name, const QString &description,
|
||||
const QString &valueName,
|
||||
const QString &defaultValue) :
|
||||
m_names(name), m_description(description), m_valueName(valueName),
|
||||
m_value(defaultValue)
|
||||
CommandOption::CommandOption(const QString& name,
|
||||
const QString& description,
|
||||
const QString& valueName,
|
||||
const QString& defaultValue)
|
||||
: m_names(name)
|
||||
, m_description(description)
|
||||
, m_valueName(valueName)
|
||||
, m_value(defaultValue)
|
||||
{
|
||||
m_checker = [](QString const&){ return true; };
|
||||
m_checker = [](QString const&) { return true; };
|
||||
}
|
||||
|
||||
CommandOption::CommandOption(const QStringList &names,
|
||||
const QString &description,
|
||||
const QString &valueName,
|
||||
const QString &defaultValue) :
|
||||
m_names(names), m_description(description), m_valueName(valueName),
|
||||
m_value(defaultValue)
|
||||
CommandOption::CommandOption(const QStringList& names,
|
||||
const QString& description,
|
||||
const QString& valueName,
|
||||
const QString& defaultValue)
|
||||
: m_names(names)
|
||||
, m_description(description)
|
||||
, m_valueName(valueName)
|
||||
, m_value(defaultValue)
|
||||
{
|
||||
m_checker = [](QString const&) -> bool { return true; };
|
||||
m_checker = [](QString const&) -> bool { return true; };
|
||||
}
|
||||
|
||||
void CommandOption::setName(const QString &name) {
|
||||
m_names = QStringList() << name;
|
||||
}
|
||||
|
||||
void CommandOption::setNames(const QStringList &names) {
|
||||
m_names = names;
|
||||
}
|
||||
|
||||
QStringList CommandOption::names() const {
|
||||
return m_names;
|
||||
}
|
||||
|
||||
QStringList CommandOption::dashedNames() const {
|
||||
QStringList dashedNames;
|
||||
for (const QString &name: m_names) {
|
||||
// prepend "-" to single character options, and "--" to the others
|
||||
QString dashedName = (name.length() == 1) ?
|
||||
QStringLiteral("-%1").arg(name) :
|
||||
QStringLiteral("--%1").arg(name);
|
||||
dashedNames << dashedName;
|
||||
}
|
||||
return dashedNames;
|
||||
}
|
||||
|
||||
void CommandOption::setValueName(const QString &name) {
|
||||
m_valueName = name;
|
||||
}
|
||||
|
||||
QString CommandOption::valueName() const {
|
||||
return m_valueName;
|
||||
}
|
||||
|
||||
void CommandOption::setValue(const QString &value) {
|
||||
if (m_valueName.isEmpty()) {
|
||||
m_valueName = QLatin1String("value");
|
||||
}
|
||||
m_value = value;
|
||||
}
|
||||
|
||||
QString CommandOption::value() const {
|
||||
return m_value;
|
||||
}
|
||||
|
||||
void CommandOption::addChecker(const function<bool (const QString &)> checker,
|
||||
const QString &errMsg)
|
||||
void
|
||||
CommandOption::setName(const QString& name)
|
||||
{
|
||||
m_checker = checker;
|
||||
m_errorMsg = errMsg;
|
||||
m_names = QStringList() << name;
|
||||
}
|
||||
|
||||
bool CommandOption::checkValue(const QString &value) const {
|
||||
return m_checker(value);
|
||||
}
|
||||
|
||||
QString CommandOption::description() const
|
||||
void
|
||||
CommandOption::setNames(const QStringList& names)
|
||||
{
|
||||
return m_description;
|
||||
m_names = names;
|
||||
}
|
||||
|
||||
void CommandOption::setDescription(const QString &description)
|
||||
QStringList
|
||||
CommandOption::names() const
|
||||
{
|
||||
m_description = description;
|
||||
return m_names;
|
||||
}
|
||||
|
||||
QString CommandOption::errorMsg() const {
|
||||
return m_errorMsg;
|
||||
}
|
||||
|
||||
bool CommandOption::operator ==(const CommandOption &option) const
|
||||
QStringList
|
||||
CommandOption::dashedNames() const
|
||||
{
|
||||
return m_description == option.m_description
|
||||
&& m_names == option.m_names
|
||||
&& m_valueName == option.m_valueName;
|
||||
QStringList dashedNames;
|
||||
for (const QString& name : m_names) {
|
||||
// prepend "-" to single character options, and "--" to the others
|
||||
QString dashedName = (name.length() == 1)
|
||||
? QStringLiteral("-%1").arg(name)
|
||||
: QStringLiteral("--%1").arg(name);
|
||||
dashedNames << dashedName;
|
||||
}
|
||||
return dashedNames;
|
||||
}
|
||||
|
||||
void
|
||||
CommandOption::setValueName(const QString& name)
|
||||
{
|
||||
m_valueName = name;
|
||||
}
|
||||
|
||||
QString
|
||||
CommandOption::valueName() const
|
||||
{
|
||||
return m_valueName;
|
||||
}
|
||||
|
||||
void
|
||||
CommandOption::setValue(const QString& value)
|
||||
{
|
||||
if (m_valueName.isEmpty()) {
|
||||
m_valueName = QLatin1String("value");
|
||||
}
|
||||
m_value = value;
|
||||
}
|
||||
|
||||
QString
|
||||
CommandOption::value() const
|
||||
{
|
||||
return m_value;
|
||||
}
|
||||
|
||||
void
|
||||
CommandOption::addChecker(const function<bool(const QString&)> checker,
|
||||
const QString& errMsg)
|
||||
{
|
||||
m_checker = checker;
|
||||
m_errorMsg = errMsg;
|
||||
}
|
||||
|
||||
bool
|
||||
CommandOption::checkValue(const QString& value) const
|
||||
{
|
||||
return m_checker(value);
|
||||
}
|
||||
|
||||
QString
|
||||
CommandOption::description() const
|
||||
{
|
||||
return m_description;
|
||||
}
|
||||
|
||||
void
|
||||
CommandOption::setDescription(const QString& description)
|
||||
{
|
||||
m_description = description;
|
||||
}
|
||||
|
||||
QString
|
||||
CommandOption::errorMsg() const
|
||||
{
|
||||
return m_errorMsg;
|
||||
}
|
||||
|
||||
bool
|
||||
CommandOption::operator==(const CommandOption& option) const
|
||||
{
|
||||
return m_description == option.m_description && m_names == option.m_names &&
|
||||
m_valueName == option.m_valueName;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user