qskinny/src/common/QskLabelData.h

92 lines
1.9 KiB
C
Raw Normal View History

2023-03-09 14:30:40 +00:00
/******************************************************************************
2024-01-17 13:31:45 +00:00
* QSkinny - Copyright (C) The authors
2023-04-06 07:23:37 +00:00
* SPDX-License-Identifier: BSD-3-Clause
2023-03-09 14:30:40 +00:00
*****************************************************************************/
#ifndef QSK_LABEL_DATA_H
#define QSK_LABEL_DATA_H
#include "QskGlobal.h"
#include "QskIcon.h"
#include <qstring.h>
2023-03-10 15:31:26 +00:00
#include <qstringlist.h>
2023-03-10 11:46:19 +00:00
#include <qvector.h>
2023-03-09 14:30:40 +00:00
#include <qmetatype.h>
#include <qdebug.h>
class QSK_EXPORT QskLabelData
{
Q_GADGET
Q_PROPERTY( QString text READ text WRITE setText )
Q_PROPERTY( QUrl iconSource READ iconSource WRITE setIconSource )
public:
QskLabelData() = default;
2023-03-09 16:59:54 +00:00
QskLabelData( const char* );
2023-03-09 14:30:40 +00:00
QskLabelData( const QString& );
QskLabelData( const QskIcon& );
QskLabelData( const QString&, const QskIcon& );
bool operator==( const QskLabelData& ) const noexcept;
bool operator!=( const QskLabelData& ) const noexcept;
void setText( const QString& );
QString text() const noexcept;
void setIconSource( const QUrl& );
QUrl iconSource() const noexcept;
void setIcon( const QskIcon& );
QskIcon icon() const noexcept;
2023-05-15 11:42:19 +00:00
bool isEmpty() const;
2023-03-09 14:30:40 +00:00
QskHashValue hash( QskHashValue ) const;
private:
QString m_text;
QskIcon m_icon;
};
Q_DECLARE_METATYPE( QskLabelData )
inline QString QskLabelData::text() const noexcept
{
return m_text;
}
inline QskIcon QskLabelData::icon() const noexcept
{
return m_icon;
}
inline QUrl QskLabelData::iconSource() const noexcept
{
return m_icon.source();
}
inline bool QskLabelData::operator!=( const QskLabelData& other ) const noexcept
{
return ( !( *this == other ) );
}
2023-05-15 11:42:19 +00:00
inline bool QskLabelData::isEmpty() const
{
return m_text.isEmpty() && m_icon.isNull();
}
2023-03-10 15:31:26 +00:00
QSK_EXPORT QVector< QskLabelData > qskCreateLabelData( const QStringList& );
2023-03-10 11:46:19 +00:00
2023-03-09 14:30:40 +00:00
#ifndef QT_NO_DEBUG_STREAM
class QDebug;
QSK_EXPORT QDebug operator<<( QDebug, const QskLabelData& );
#endif
#endif