Fix reversed return value logic in QJsonModel::load methods
This commit is contained in:
parent
931009bc38
commit
cd6fac3950
@ -66,10 +66,10 @@ CheckOptions:
|
||||
- { key: readability-identifier-naming.PrivateMemberCase, value: camelBack }
|
||||
|
||||
# Constants and Enum Values
|
||||
- { key: readability-identifier-naming.ConstantPrefix, value: 'k' }
|
||||
- { key: readability-identifier-naming.ConstantPrefix, value: 'k_' }
|
||||
- { key: readability-identifier-naming.ConstantCase, value: CamelBack }
|
||||
|
||||
- { key: readability-identifier-naming.EnumConstantPrefix, value: '' }
|
||||
- { key: readability-identifier-naming.EnumConstantPrefix, value: 'k' }
|
||||
- { key: readability-identifier-naming.EnumConstantCase, value: CamelCase }
|
||||
|
||||
# Constant Expression
|
||||
|
@ -32,7 +32,9 @@
|
||||
#include <QFont>
|
||||
|
||||
namespace {
|
||||
|
||||
using FieldPermissions = QJsonModel::FieldPermissions;
|
||||
using ErrorFlag = QJsonModel::ErrorFlag;
|
||||
|
||||
constexpr int kKeyColumn = 0;
|
||||
constexpr int kValueColumn = 1;
|
||||
@ -86,27 +88,28 @@ QJsonModel::~QJsonModel()
|
||||
delete rootItem;
|
||||
}
|
||||
|
||||
bool QJsonModel::load(const QString& fileName)
|
||||
ErrorFlag QJsonModel::load(const QString& fileName)
|
||||
{
|
||||
QFile file(fileName);
|
||||
bool success = false;
|
||||
ErrorFlag result = false;
|
||||
|
||||
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
success = load(&file);
|
||||
result = load(&file);
|
||||
file.close();
|
||||
} else {
|
||||
success = false;
|
||||
result = true;
|
||||
}
|
||||
|
||||
return success;
|
||||
return result;
|
||||
}
|
||||
|
||||
bool QJsonModel::load(QIODevice* device)
|
||||
ErrorFlag QJsonModel::load(QIODevice* device)
|
||||
{
|
||||
QTextStream content(device);
|
||||
return loadJson(content.readAll().toUtf8());
|
||||
}
|
||||
|
||||
bool QJsonModel::loadJson(const QByteArray& json)
|
||||
ErrorFlag QJsonModel::loadJson(const QByteArray& json)
|
||||
{
|
||||
auto const& jdoc = QJsonDocument::fromJson(json);
|
||||
|
||||
|
@ -69,9 +69,10 @@ class QJsonModel : public QAbstractItemModel {
|
||||
|
||||
~QJsonModel() override;
|
||||
|
||||
bool load(const QString& fileName);
|
||||
bool load(QIODevice* file);
|
||||
bool loadJson(const QByteArray& json);
|
||||
using ErrorFlag = bool;
|
||||
ErrorFlag load(const QString& fileName);
|
||||
ErrorFlag load(QIODevice* file);
|
||||
ErrorFlag loadJson(const QByteArray& json);
|
||||
QVariant data(const QModelIndex& index, int role) const override;
|
||||
bool setData(
|
||||
const QModelIndex& index, const QVariant& value,
|
||||
|
Loading…
Reference in New Issue
Block a user