X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fclient%2Fmessagemodel.h;h=63772822cb1700e001b0d2124a1e13522ef81a3d;hb=6eefdfc697067d184a589fc8a231b16316c09106;hp=e26455d551b7a59a2a8175b91dd19c567c5dc4f0;hpb=6a63070246d89aa2a2474e3a9a1035fa889ad77e;p=quassel.git diff --git a/src/client/messagemodel.h b/src/client/messagemodel.h index e26455d5..63772822 100644 --- a/src/client/messagemodel.h +++ b/src/client/messagemodel.h @@ -18,8 +18,9 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ -#ifndef MESSAGEMODEL_H_ -#define MESSAGEMODEL_H_ +#pragma once + +#include "client-export.h" #include #include @@ -31,7 +32,7 @@ class MessageModelItem; struct MsgId; -class MessageModel : public QAbstractItemModel +class CLIENT_EXPORT MessageModel : public QAbstractItemModel { Q_OBJECT @@ -58,13 +59,13 @@ public: MessageModel(QObject *parent); - inline QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; - inline QModelIndex parent(const QModelIndex &) const { return QModelIndex(); } - inline int rowCount(const QModelIndex &parent = QModelIndex()) const { return parent.isValid() ? 0 : messageCount(); } - inline int columnCount(const QModelIndex & /*parent*/ = QModelIndex()) const { return 3; } + inline QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; + inline QModelIndex parent(const QModelIndex &) const override { return {}; } + inline int rowCount(const QModelIndex &parent = QModelIndex()) const override { return parent.isValid() ? 0 : messageCount(); } + inline int columnCount(const QModelIndex & /*parent*/ = QModelIndex()) const override { return 3; } - virtual QVariant data(const QModelIndex &index, int role) const; - virtual bool setData(const QModelIndex &index, const QVariant &value, int role); + QVariant data(const QModelIndex &index, int role) const override; + bool setData(const QModelIndex &index, const QVariant &value, int role) override; //virtual Qt::ItemFlags flags(const QModelIndex &index) const; @@ -99,7 +100,7 @@ protected: virtual void removeAllMessages() = 0; virtual Message takeMessageAt(int i) = 0; - virtual void customEvent(QEvent *event); + void customEvent(QEvent *event) override; private slots: void changeOfDay(); @@ -125,7 +126,7 @@ private: QModelIndex MessageModel::index(int row, int column, const QModelIndex &parent) const { if (row < 0 || row >= rowCount(parent) || column < 0 || column >= columnCount(parent)) - return QModelIndex(); + return {}; return createIndex(row, column); } @@ -134,16 +135,15 @@ QModelIndex MessageModel::index(int row, int column, const QModelIndex &parent) // ************************************************** // MessageModelItem // ************************************************** -class MessageModelItem +//! Creates a MessageModelItem from a Message object. +/** This baseclass implementation takes care of all Message data *except* the stylable strings. + * Subclasses need to provide Qt::DisplayRole at least, which should describe the plaintext + * strings without formattings (e.g. for searching purposes). + */ +class CLIENT_EXPORT MessageModelItem { public: - //! Creates a MessageModelItem from a Message object. - /** This baseclass implementation takes care of all Message data *except* the stylable strings. - * Subclasses need to provide Qt::DisplayRole at least, which should describe the plaintext - * strings without formattings (e.g. for searching purposes). - */ - MessageModelItem() {} - inline virtual ~MessageModelItem() {} + inline virtual ~MessageModelItem() = default; virtual QVariant data(int column, int role) const; virtual bool setData(int column, const QVariant &value, int role); @@ -168,5 +168,3 @@ private: QDebug operator<<(QDebug dbg, const MessageModelItem &msgItem); - -#endif