Ref T472, style

This commit is contained in:
Klaus Basan
2019-01-31 22:29:56 +01:00
committed by Mat Sutcliffe
parent d713e8a264
commit bada0c2f59
5 changed files with 31 additions and 43 deletions

View File

@@ -33,6 +33,7 @@
#include <QNetworkReply>
#include <QReadLocker>
#include <QUrl>
#include <QStringBuilder>
#include <QWriteLocker>
using namespace BlackMisc;
@@ -47,7 +48,7 @@ namespace BlackCore
namespace Db
{
CDatabaseReader::CDatabaseReader(QObject *owner, const CDatabaseReaderConfigList &config, const QString &name) :
BlackCore::CThreadedReader(owner, name), m_config(config)
CThreadedReader(owner, name), m_config(config)
{ }
void CDatabaseReader::readInBackgroundThread(CEntityFlags::Entity entities, const QDateTime &newerThan)
@@ -724,7 +725,7 @@ namespace BlackCore
QString CDatabaseReader::queryLatestTimestamp(const QDateTime &ts)
{
if (!ts.isValid()) return {};
const QString q = parameterLatestTimestamp() + "=" + dateTimeToDbLatestTs(ts);
const QString q = parameterLatestTimestamp() % u"=" % dateTimeToDbLatestTs(ts);
return q;
}

View File

@@ -131,10 +131,10 @@ namespace BlackMisc
const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
case IndexName: return m_name.compare(compareValue.getName(), Qt::CaseInsensitive);
case IndexPath: return m_description.compare(compareValue.getPath(), Qt::CaseInsensitive);
case IndexName: return m_name.compare(compareValue.getName(), Qt::CaseInsensitive);
case IndexPath: return m_description.compare(compareValue.getPath(), Qt::CaseInsensitive);
case IndexDescription: return m_path.compare(compareValue.getDescription(), Qt::CaseInsensitive);
case IndexAssignable: return Compare::compare(this->isAssignable(), compareValue.isAssignable());
case IndexAssignable: return Compare::compare(this->isAssignable(), compareValue.isAssignable());
default: return CValueObject::comparePropertyByIndex(index, *this);
}
Q_ASSERT_X(false, Q_FUNC_INFO, "No comparison");

View File

@@ -13,8 +13,8 @@
#define BLACKMISC_AVIATION_AIRCRAFTCATEGORYLIST_H
#include "aircraftcategory.h"
#include "blackmisc/collection.h"
#include "blackmisc/db/datastoreobjectlist.h"
#include "blackmisc/collection.h"
#include "blackmisc/sequence.h"
#include "blackmisc/variant.h"
#include "blackmisc/blackmiscexport.h"

View File

@@ -9,7 +9,7 @@
#include "dbinfo.h"
#include "blackmisc/comparefunctions.h"
#include <QPainter>
#include <QStringBuilder>
using namespace BlackMisc::Network;
@@ -22,17 +22,17 @@ namespace BlackMisc
m_tableName(tableName.trimmed().toLower()), m_entries(entries)
{
this->setEntity(this->getEntity());
Q_ASSERT_X(tableName.isEmpty() || this->m_entity != CEntityFlags::NoEntity, Q_FUNC_INFO, "Wrong entity");
Q_ASSERT_X(tableName.isEmpty() || m_entity != CEntityFlags::NoEntity, Q_FUNC_INFO, "Wrong entity");
}
bool CDbInfo::isValid() const
{
return this->m_entity != CEntityFlags::NoEntity && !this->m_tableName.isEmpty();
return m_entity != CEntityFlags::NoEntity && !m_tableName.isEmpty();
}
CEntityFlags::Entity CDbInfo::getEntity() const
{
if (this->m_entity != CEntityFlags::NoEntity) { return this->m_entity; }
if (m_entity != CEntityFlags::NoEntity) { return m_entity; }
const QString tn(this->getTableName());
return CEntityFlags::singleEntityByName(tn);
}
@@ -51,7 +51,7 @@ namespace BlackMisc
void CDbInfo::setEntity(CEntityFlags::Entity entity)
{
this->m_entity = entity;
m_entity = entity;
}
bool CDbInfo::matchesEntity(CEntityFlags::Entity entity) const
@@ -62,27 +62,24 @@ namespace BlackMisc
void CDbInfo::setTableName(const QString &tableName)
{
m_tableName = tableName.trimmed().toLower();
this->m_entity = this->getEntity();
m_entity = this->getEntity();
}
QString CDbInfo::convertToQString(bool i18n) const
{
Q_UNUSED(i18n);
return QStringLiteral("Table %1 with entries %1").arg(this->m_tableName).arg(this->m_entries);
return QStringLiteral("Table %1 with entries %1").arg(m_tableName).arg(m_entries);
}
CVariant CDbInfo::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
{
if (index.isMyself()) { return CVariant::from(*this); }
ColumnIndex i = index.frontCasted<ColumnIndex>();
const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
case IndexTableName:
return CVariant::fromValue(m_tableName);
case IndexEntries:
return CVariant::fromValue(m_entries);
case IndexEntity:
return CVariant::fromValue(m_entity);
case IndexTableName: return CVariant::fromValue(m_tableName);
case IndexEntries: return CVariant::fromValue(m_entries);
case IndexEntity: return CVariant::fromValue(m_entity);
default:
return (IDatastoreObjectWithIntegerKey::canHandleIndex(index)) ?
IDatastoreObjectWithIntegerKey::propertyByIndex(index) :
@@ -93,18 +90,12 @@ namespace BlackMisc
void CDbInfo::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
{
if (index.isMyself()) { (*this) = variant.to<CDbInfo>(); return; }
ColumnIndex i = index.frontCasted<ColumnIndex>();
const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
case IndexTableName:
this->setTableName(variant.toQString());
break;
case IndexEntries:
this->setTableName(variant.toQString());
break;
case IndexEntity:
this->setEntity(static_cast<CEntityFlags::Entity>(variant.toInt()));
break;
case IndexTableName: this->setTableName(variant.toQString()); break;
case IndexEntries: this->setTableName(variant.toQString()); break;
case IndexEntity: this->setEntity(static_cast<CEntityFlags::Entity>(variant.toInt())); break;
default:
if (IDatastoreObjectWithIntegerKey::canHandleIndex(index))
{
@@ -122,15 +113,12 @@ namespace BlackMisc
{
if (index.isMyself()) { return getTableName().compare(compareValue.getTableName(), Qt::CaseInsensitive); }
if (IDatastoreObjectWithIntegerKey::canHandleIndex(index)) { return IDatastoreObjectWithIntegerKey::comparePropertyByIndex(index, compareValue);}
ColumnIndex i = index.frontCasted<ColumnIndex>();
const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
case IndexTableName:
return getTableName().compare(compareValue.getTableName(), Qt::CaseInsensitive);
case IndexEntries:
return Compare::compare(this->getEntries(), compareValue.getEntries());
case IndexEntity:
return Compare::compare(this->getEntity(), compareValue.getEntity());
case IndexTableName: return this->getTableName().compare(compareValue.getTableName(), Qt::CaseInsensitive);
case IndexEntries: return Compare::compare(this->getEntries(), compareValue.getEntries());
case IndexEntity: return Compare::compare(this->getEntity(), compareValue.getEntity());
default:
Q_ASSERT_X(false, Q_FUNC_INFO, "No comparison possible");
}
@@ -144,9 +132,9 @@ namespace BlackMisc
// when using relationship, this can be null
return CDbInfo();
}
const int id(json.value(prefix + "id").toInt());
const int entries(json.value(prefix + "entries").toInt());
const QString tableName(json.value(prefix + "tablename").toString());
const int id(json.value(prefix % u"id").toInt());
const int entries(json.value(prefix % u"entries").toInt());
const QString tableName(json.value(prefix % u"tablename").toString());
CDbInfo dbInfo(id, tableName, entries);
dbInfo.setKeyVersionTimestampFromDatabaseJson(json, prefix);
return dbInfo;

View File

@@ -16,7 +16,6 @@
#include "blackmisc/network/entityflags.h"
#include "blackmisc/valueobject.h"
#include "blackmisc/blackmiscexport.h"
#include <QColor>
namespace BlackMisc
{
@@ -33,7 +32,7 @@ namespace BlackMisc
//! Properties by index
enum ColumnIndex
{
IndexTableName = BlackMisc::CPropertyIndex::GlobalIndexCDbInfo,
IndexTableName = CPropertyIndex::GlobalIndexCDbInfo,
IndexEntries,
IndexEntity
};
@@ -107,7 +106,7 @@ namespace BlackMisc
private:
QString m_tableName; //!< table name
int m_entries; //!< number of entries
BlackMisc::Network::CEntityFlags::Entity m_entity = BlackMisc::Network::CEntityFlags::NoEntity; //!< lazy initialized entity
Network::CEntityFlags::Entity m_entity = Network::CEntityFlags::NoEntity; //!< lazy initialized entity
BLACK_METACLASS(
CDbInfo,