116 lines
4.1 KiB
C++
Executable File
116 lines
4.1 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* Preprocess symbols of Filemanagement
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
*/
|
|
#pragma once
|
|
|
|
// Own
|
|
|
|
|
|
// Qt
|
|
#include <QHash>
|
|
#include <QString>
|
|
#include <QImage>
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
namespace AdvancedSymbology
|
|
{
|
|
|
|
|
|
class FlmSymbolProxy : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
class SymbolData
|
|
{
|
|
public:
|
|
|
|
SymbolData() = default;
|
|
|
|
SymbolData(const QString &name, const QImage &image, const QColor &colorToBeReplaced = QColor())
|
|
: m_name(name), m_image(image), m_colorToBeReplaced(colorToBeReplaced), m_xmlContent()
|
|
{}
|
|
|
|
SymbolData(const QString &name, const QString &operatorName, qint64 lastModified, const QByteArray &xmlContent)
|
|
: m_name(name), m_operatorName(operatorName), m_lastModified(lastModified), m_image(), m_colorToBeReplaced(), m_xmlContent(QString::fromUtf8(xmlContent))
|
|
{}
|
|
|
|
QString name() const { return m_name; }
|
|
void setName(const QString &name) { m_name = name; }
|
|
|
|
QString operatorName() const { return m_operatorName; }
|
|
void setOperatorName(const QString &operatorName) { m_operatorName = operatorName; }
|
|
|
|
qint64 lastModified() const { return m_lastModified; }
|
|
void setLastModified(qint64 lastModified) { m_lastModified = lastModified; }
|
|
|
|
|
|
QImage image() const { return m_image; }
|
|
void setImage(const QImage &image) { m_image = image; if (!image.isNull()) m_xmlContent.clear(); }
|
|
|
|
QColor colorToBeReplaced() const { return m_colorToBeReplaced; }
|
|
void setColorToBeReplaced(const QColor &colorToBeReplaced) { m_colorToBeReplaced = colorToBeReplaced; }
|
|
|
|
QString xmlContent() const { return m_xmlContent; }
|
|
void setXmlContent(const QString &xmlContent) { m_xmlContent = xmlContent; }
|
|
|
|
bool isXmlSymbol() const { return (!m_xmlContent.isEmpty()); }
|
|
|
|
QStringList usrTags() const { return m_usrTags; }
|
|
|
|
void setUsrTags(const QStringList &usrTags) { m_usrTags = usrTags; }
|
|
void addUsrTag(const QString &tag) { m_usrTags << tag; }
|
|
void addUsrTag(const char *tag) { m_usrTags << QLatin1String(tag); }
|
|
|
|
void clearUsrTags() { m_usrTags.clear(); }
|
|
|
|
protected:
|
|
|
|
QString m_name; // file name of symbol from file mamangement service
|
|
QString m_operatorName;
|
|
qint64 m_lastModified = 0;
|
|
QImage m_image; // m_image is defined in case of ETS symbols
|
|
QColor m_colorToBeReplaced; // by concrete partyColor (context of ETS symbols)
|
|
QString m_xmlContent; // in case of XML symbols image is empty and the m_xmlContent holds the xml description of the symbol
|
|
QStringList m_usrTags; // List of tags to look for while searching symbols in dictionary
|
|
};
|
|
|
|
|
|
|
|
/*! \name Construction, Destruction */
|
|
//@{
|
|
explicit FlmSymbolProxy(QObject *parent = nullptr);
|
|
|
|
FlmSymbolProxy(const FlmSymbolProxy &other) = delete;
|
|
FlmSymbolProxy &operator=(const FlmSymbolProxy &other) = delete;
|
|
//@}
|
|
|
|
bool isEmpty() const { return m_imageMap.isEmpty(); }
|
|
bool containsSymbol(qint32 fileContentId) const { return m_imageMap.contains(fileContentId); }
|
|
const QHash<qint32, SymbolData> &getMap() const { return m_imageMap; }
|
|
|
|
bool setSymbol(int32_t fileContentId, const SymbolData &symbolData);
|
|
bool removeSymbol(qint32 fileContentId);
|
|
|
|
|
|
Q_SIGNALS:
|
|
void etsSymbolAdded(qint32 fileContentId, const QString &name, const QImage &image, const QColor &colorToBeReplaced, const QStringList &usrTags);
|
|
void etsSymbolRemoved(qint32 fileContentId, const QString &name);
|
|
|
|
void xmlSymbolAdded(qint32 fileContentId, const QString & operatorName, qint64 lastModified, const QString &name, const QString &xmlContent, const QStringList &usrTags);
|
|
void xmlSymbolRemoved(qint32 fileContentId);
|
|
|
|
private:
|
|
QHash<qint32, SymbolData> m_imageMap; // fileContentId -> image
|
|
};
|
|
|
|
} // namespace AdvancedSymbology
|
|
|
|
|