mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 20:15:35 +08:00
refs #452, adjusted aircraft/aviation classes
* support for loading from datastore * improved timestamp handling * new color and country classes * new attributes * updates for missing parts in CUser
This commit is contained in:
committed by
Mathew Sutcliffe
parent
c5f7179588
commit
ae24700299
104
src/blackmisc/country.h
Normal file
104
src/blackmisc/country.h
Normal file
@@ -0,0 +1,104 @@
|
||||
/* Copyright (C) 2015
|
||||
* Swift Project Community / Contributors
|
||||
*
|
||||
* This file is part of Swift Project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKMISC_COUNTRY_H
|
||||
#define BLACKMISC_COUNTRY_H
|
||||
|
||||
#include "blackmiscexport.h"
|
||||
#include "datastore.h"
|
||||
#include "valueobject.h"
|
||||
#include <QColor>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
/*!
|
||||
* Color
|
||||
*/
|
||||
class BLACKMISC_EXPORT CCountry :
|
||||
public CValueObject<CCountry>,
|
||||
public IDatastoreObjectWithStringKey
|
||||
{
|
||||
public:
|
||||
//! Properties by index
|
||||
enum ColumnIndex
|
||||
{
|
||||
IndexIsoCode = BlackMisc::CPropertyIndex::GlobalIndexCountry,
|
||||
IndexName,
|
||||
IndexNameIso,
|
||||
IndexIsoName
|
||||
};
|
||||
|
||||
//! Constructor
|
||||
CCountry() = default;
|
||||
|
||||
//! Constructor
|
||||
CCountry(const QString &iso, const QString &name);
|
||||
|
||||
//! Valid?
|
||||
bool isValid() const;
|
||||
|
||||
//! Representing icon
|
||||
CIcon toIcon() const;
|
||||
|
||||
//! DB ISO code
|
||||
const QString &getIsoCode() const { return m_dbKey; }
|
||||
|
||||
//! Country ISO code (US, DE, GB, PL)
|
||||
void setIsoCode(const QString &iso);
|
||||
|
||||
//! ISO code?
|
||||
bool hasIsoCode() const;
|
||||
|
||||
//! Country name
|
||||
const QString &getName() const { return m_name; }
|
||||
|
||||
//! Combined string ISO/name
|
||||
QString getCombinedStringIsoName() const;
|
||||
|
||||
//! Combined string name/ISO
|
||||
QString getCombinedStringNameIso() const;
|
||||
|
||||
//! Set country name
|
||||
void setName(const QString &countryName);
|
||||
|
||||
//! Matches country name
|
||||
bool matchesCountryName(const QString &name) const;
|
||||
|
||||
//! \copydoc CValueObject::convertToQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
//! \copydoc CValueObject::propertyByIndex
|
||||
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
||||
|
||||
//! \copydoc CValueObject::setPropertyByIndex
|
||||
void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index);
|
||||
|
||||
//! From our database JSON format
|
||||
static CCountry fromDatabaseJson(const QJsonObject &json, const QString &prefix = QString());
|
||||
|
||||
//! Valid country iso code
|
||||
static bool isValidIsoCode(const QString &isoCode);
|
||||
|
||||
private:
|
||||
BLACK_ENABLE_TUPLE_CONVERSION(CCountry)
|
||||
QString m_name; //!< country name
|
||||
|
||||
};
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::CCountry)
|
||||
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::CCountry, (
|
||||
attr(o.m_dbKey),
|
||||
attr(o.m_timestampMSecsSinceEpoch),
|
||||
attr(o.m_name)
|
||||
))
|
||||
|
||||
#endif // guard
|
||||
Reference in New Issue
Block a user