mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-11 06:25:33 +08:00
Found during T215, rectify CIdentifier issues
* null/anonymous identifier * CIdentifier can be linked with QObject and * CIdentifier reflects name changes of QObject (UI components change name after ctor call)
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include <QByteArray>
|
||||
#include <QMetaType>
|
||||
#include <QString>
|
||||
#include <QObject>
|
||||
#include <QUuid>
|
||||
#include <QtGlobal>
|
||||
|
||||
@@ -50,11 +51,22 @@ namespace BlackMisc
|
||||
};
|
||||
|
||||
//! Constructor.
|
||||
CIdentifier(const QString &name = QString());
|
||||
//! \private use CIdentifier::anonymous() if you need an identifier without name and CIdentifier::null() for an empty identifier
|
||||
CIdentifier() : CIdentifier("") {}
|
||||
|
||||
//! Returns an anonymous identifier.
|
||||
//! Constructor.
|
||||
CIdentifier(const QString &name);
|
||||
|
||||
//! Constructor using object's name
|
||||
CIdentifier(const QString &name, QObject *object);
|
||||
|
||||
//! Returns an anonymous identifier, which is a valid identifier without name
|
||||
//! \remark same as CIdentifier()
|
||||
static const CIdentifier &anonymous();
|
||||
|
||||
//! Null (empty) identifier
|
||||
static const CIdentifier &null();
|
||||
|
||||
//! Returns a fake identifier.
|
||||
static const CIdentifier &fake();
|
||||
|
||||
@@ -70,6 +82,16 @@ namespace BlackMisc
|
||||
//! Has name
|
||||
bool hasName() const { return !m_name.isEmpty(); }
|
||||
|
||||
//! Set the name
|
||||
void setName(const QString &name) { m_name = name; }
|
||||
|
||||
//! Set name or append name
|
||||
//! \remark append makes sense if an object name changes after some time (like for UI components when the whole UI is setup)
|
||||
void appendName(const QString &name);
|
||||
|
||||
//! Reflect changes of QObject::
|
||||
void linkWithQObjectName(QObject *object);
|
||||
|
||||
//! Get machine id
|
||||
QByteArray getMachineId() const;
|
||||
|
||||
@@ -100,6 +122,9 @@ namespace BlackMisc
|
||||
//! Check if it is anonymous identifier
|
||||
bool isAnonymous() const;
|
||||
|
||||
//! Null identifier (no name, ids etc)
|
||||
bool isNull() const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user