[network/ruqola] src/widgets/room: Clean up class

Laurent Montel <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 64a30071448e48176f1408449e4d7f5b15b1a421 by Laurent Montel.
Committed on 30/07/2026 at 06:03.
Pushed by mlaurent into branch 'master'.

Clean up class

M  +1    -7    src/widgets/room/messagelistview.cpp
M  +5    -3    src/widgets/room/messagelistview.h

https://invent.kde.org/network/ruqola/-/commit/64a30071448e48176f1408449e4d7f5b15b1a421

diff --git a/src/widgets/room/messagelistview.cpp b/src/widgets/room/messagelistview.cpp
index 47fea831b8..5b01fcd3c0 100644
--- a/src/widgets/room/messagelistview.cpp
+++ b/src/widgets/room/messagelistview.cpp
@@ -76,6 +76,7 @@ MessageListView::MessageListView(RocketChatAccount *account, Mode mode, QWidget
     , mMessageListDelegate(new MessageListDelegate(account, this))
     , mCurrentRocketChatAccount(account)
     , mActionButtonsGenerator(new ActionButtonsGenerator(this))
+    , mNewMessageIndicator(new NewMessageIndicator(viewport()))
 {
     if (mCurrentRocketChatAccount) {
         mMessageListDelegate->setRocketChatAccount(mCurrentRocketChatAccount);
@@ -83,7 +84,6 @@ MessageListView::MessageListView(RocketChatAccount *account, Mode mode, QWidget
     }
     connect(mActionButtonsGenerator, &ActionButtonsGenerator::uiInteractionRequested, this, &MessageListView::uiInteractionRequested);
 
-    mNewMessageIndicator = new NewMessageIndicator(viewport());
     mNewMessageIndicator->hide();
 
     mMessageListDelegate->setShowThreadContext(mMode != Mode::ThreadEditing);
@@ -200,9 +200,6 @@ void MessageListView::slotVerticalScrollbarChanged(int value)
 
 void MessageListView::updateNewMessageIndicatorVisibility()
 {
-    if (!mNewMessageIndicator) {
-        return;
-    }
     const auto *vbar = verticalScrollBar();
     const bool notAtBottom = vbar->value() < vbar->maximum();
     const bool hasUnread = mRoom && (mRoom->unread() > 0);
@@ -221,9 +218,6 @@ void MessageListView::updateNewMessageIndicatorVisibility()
 void MessageListView::repositionNewMessageIndicator()
 {
     qCDebug(RUQOLA_NEWMESSAGEINDICATOR_WIDGETS_LOG) << "MessageListView::repositionNewMessageIndicator";
-    if (!mNewMessageIndicator) {
-        return;
-    }
     mNewMessageIndicator->adjustSize();
     const QSize vSize = viewport()->size();
     const QSize iSize = mNewMessageIndicator->sizeHint();
diff --git a/src/widgets/room/messagelistview.h b/src/widgets/room/messagelistview.h
index 22f625a1ba..19fae4263f 100644
--- a/src/widgets/room/messagelistview.h
+++ b/src/widgets/room/messagelistview.h
@@ -74,6 +74,10 @@ Q_SIGNALS:
     void replyInThreadRequested(const QByteArray &messageId, const QString &text);
     void uiInteractionRequested(const QJsonObject &obj);
 
+protected:
+    [[nodiscard]] QString selectedText(const QModelIndex &index) override;
+    [[nodiscard]] bool hasSelection() const override;
+
 private:
     LIBRUQOLAWIDGETS_NO_EXPORT void slotEditMessage(const QModelIndex &index);
     LIBRUQOLAWIDGETS_NO_EXPORT void slotDeleteMessage(const QModelIndex &index);
@@ -104,8 +108,6 @@ private:
     LIBRUQOLAWIDGETS_NO_EXPORT void createTranslorMenu();
     LIBRUQOLAWIDGETS_NO_EXPORT void slotShowReportInfo(const ModerationReportInfos &info);
     LIBRUQOLAWIDGETS_NO_EXPORT void slotForwardMessage(const QModelIndex &index);
-    [[nodiscard]] LIBRUQOLAWIDGETS_NO_EXPORT QString selectedText(const QModelIndex &index) override;
-    [[nodiscard]] LIBRUQOLAWIDGETS_NO_EXPORT bool hasSelection() const override;
     LIBRUQOLAWIDGETS_NO_EXPORT void createEmojiWidgetAction(QMenu *menu, const QModelIndex &index);
     LIBRUQOLAWIDGETS_NO_EXPORT void slotShowGeneratedMessage(const QModelIndex &index);
     LIBRUQOLAWIDGETS_NO_EXPORT void slotReadReceiptsMessage(const QModelIndex &index);
@@ -117,5 +119,5 @@ private:
     TextTranslator::TranslatorMenu *mTranslatorMenu = nullptr;
     QPointer<RocketChatAccount> mCurrentRocketChatAccount;
     ActionButtonsGenerator *const mActionButtonsGenerator;
-    NewMessageIndicator *mNewMessageIndicator = nullptr;
+    NewMessageIndicator *const mNewMessageIndicator;
 };
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.