Files
pilotclient/src/blackmisc/network/role.h
Klaus Basan 54b1234f7f refs #649, refs #658 fixed includes to new subfolders "db"
some style changes in same step
2016-06-08 18:20:23 +02:00

93 lines
2.7 KiB
C++

/* 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_NETWORK_ROLE_H
#define BLACKMISC_NETWORK_ROLE_H
#include "blackmisc/blackmiscexport.h"
#include "blackmisc/db/datastore.h"
#include "blackmisc/metaclass.h"
#include "blackmisc/propertyindex.h"
#include "blackmisc/valueobject.h"
#include "blackmisc/variant.h"
#include <QJsonObject>
#include <QMetaType>
#include <QString>
namespace BlackMisc
{
namespace Network
{
/*!
* Role
*/
class BLACKMISC_EXPORT CRole :
public CValueObject<CRole>,
public BlackMisc::Db::IDatastoreObjectWithIntegerKey
{
public:
//! Properties by index
enum ColumnIndex
{
IndexName = BlackMisc::CPropertyIndex::GlobalIndexCRole,
IndexDescription
};
//! Constructor
CRole() = default;
//! Constructor
CRole(const QString &name, const QString &description);
//! Name
const QString &getName() const { return m_name; }
//! Name
void setName(const QString &name) { m_name = name.trimmed().toUpper(); }
//! Description
const QString &getDescription() const { return m_description; }
//! Description
void setDescription(const QString &description) { m_description = description.trimmed(); }
//! \copydoc BlackMisc::Mixin::String::toQString
QString convertToQString(bool i18n = false) const;
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const CVariant &variant);
//! Role from DB JSON
static CRole fromDatabaseJson(const QJsonObject &json);
private:
QString m_name;
QString m_description;
BLACK_METACLASS(
CRole,
BLACK_METAMEMBER(dbKey),
BLACK_METAMEMBER(name),
BLACK_METAMEMBER(description)
);
};
} // ns
} // ns
Q_DECLARE_METATYPE(BlackMisc::Network::CRole)
#endif // guard