Add missing #pragma once + missing include * speeds up incremental builds as changes to a header will not always need the full mocs_compilation.cpp for all the target's headers rebuild, while having a moc file sourced into a source file only adds minor extra costs, due to small own code and the used headers usually already covered by the source file, being for the same class/struct * seems to not slow down clean builds, due to empty mocs_compilation.cpp resulting in those quickly processed, while the minor extra cost of the sourced moc files does not outweigh that in summary. Measured times actually improved by some percent points. (ideally CMake would just skip empty mocs_compilation.cpp & its object file one day) * enables compiler to see all methods of a class in same compilation unit to do some sanity checks * potentially more inlining in general, due to more in the compilation unit * allows to keep using more forward declarations in the header, as with the moc code being sourced into the cpp file there definitions can be ensured and often are already for the needs of the normal class methods
54 lines
1.4 KiB
C++
54 lines
1.4 KiB
C++
// SPDX-FileCopyrightText: 2023 Tobias Fella <tobias.fella@kde.org>
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#pragma once
|
|
|
|
#include <QSortFilterProxyModel>
|
|
|
|
/**
|
|
* @class EmoticonFilterModel
|
|
*
|
|
* This class creates a custom QSortFilterProxyModel for filtering a emoticon by type
|
|
* (Sticker or Emoji).
|
|
*/
|
|
class EmoticonFilterModel : public QSortFilterProxyModel
|
|
{
|
|
Q_OBJECT
|
|
|
|
/**
|
|
* @brief Whether stickers should be shown
|
|
*/
|
|
Q_PROPERTY(bool showStickers READ showStickers WRITE setShowStickers NOTIFY showStickersChanged)
|
|
|
|
/**
|
|
* @brief Whether emojis show be shown
|
|
*/
|
|
Q_PROPERTY(bool showEmojis READ showEmojis WRITE setShowEmojis NOTIFY showEmojisChanged)
|
|
|
|
public:
|
|
explicit EmoticonFilterModel(QObject *parent = nullptr);
|
|
|
|
/**
|
|
* @brief Custom filter function checking the type of emoticon
|
|
*
|
|
* @note The filter cannot be modified and will always use the same filter properties.
|
|
*/
|
|
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
|
|
|
|
[[nodiscard]] bool showStickers() const;
|
|
void setShowStickers(bool showStickers);
|
|
|
|
[[nodiscard]] bool showEmojis() const;
|
|
void setShowEmojis(bool showEmojis);
|
|
|
|
Q_SIGNALS:
|
|
void showStickersChanged();
|
|
void showEmojisChanged();
|
|
|
|
private:
|
|
bool m_showStickers = false;
|
|
bool m_showEmojis = false;
|
|
int m_stickerRole = 0;
|
|
int m_emojiRole = 0;
|
|
};
|