From a543ac89aec7782d5a36241f9e2e2db11e9ba8ab Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Sat, 27 Oct 2018 23:46:55 +0200 Subject: [PATCH] Status message model with tooltip --- src/blackgui/models/statusmessagelistmodel.cpp | 11 +++++++++++ src/blackgui/models/statusmessagelistmodel.h | 5 ++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/blackgui/models/statusmessagelistmodel.cpp b/src/blackgui/models/statusmessagelistmodel.cpp index 04d58f876..0d4e3ccc1 100644 --- a/src/blackgui/models/statusmessagelistmodel.cpp +++ b/src/blackgui/models/statusmessagelistmodel.cpp @@ -67,5 +67,16 @@ namespace BlackGui break; } } + + QVariant CStatusMessageListModel::data(const QModelIndex &index, int role) const + { + if (role == Qt::ToolTipRole) + { + // the underlying model object as summary + const CStatusMessage msg(this->at(index)); + return msg.toHtml(); + } + return CListModelTimestampObjects::data(index, role); + } } // namespace } // namespace diff --git a/src/blackgui/models/statusmessagelistmodel.h b/src/blackgui/models/statusmessagelistmodel.h index 2952b56fd..c30b4c830 100644 --- a/src/blackgui/models/statusmessagelistmodel.h +++ b/src/blackgui/models/statusmessagelistmodel.h @@ -40,10 +40,13 @@ namespace BlackGui explicit CStatusMessageListModel(QObject *parent = nullptr); //! Destructor - virtual ~CStatusMessageListModel() {} + virtual ~CStatusMessageListModel() override {} //! Set mode void setMode(Mode mode); + + //! \copydoc QAbstractItemModel::data + virtual QVariant data(const QModelIndex &index, int role) const override; }; } // ns } // ns