[pim/messagelib] /: Remove duplicate class

Laurent Montel <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 9d10d0b984e19e495b6101e3bacf2cffa3afbb0a by Laurent Montel.
Committed on 03/08/2026 at 17:44.
Pushed by mlaurent into branch 'master'.

Remove duplicate class

M  +1    -1    CMakeLists.txt
M  +0    -2    messagelist/src/CMakeLists.txt
M  +2    -2    messagelist/src/core/widgets/autotests/searchlinecommandbuttonswidgettest.cpp
M  +2    -2    messagelist/src/core/widgets/searchlinecommandbuttonswidget.cpp
D  +0    -214  messagelist/src/core/widgets/searchlinecommandflowlayout.cpp
D  +0    -65   messagelist/src/core/widgets/searchlinecommandflowlayout.h

https://invent.kde.org/pim/messagelib/-/commit/9d10d0b984e19e495b6101e3bacf2cffa3afbb0a

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8ebdbc019..63fc2b699 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -146,7 +146,7 @@ file(
 )
 ecm_check_outbound_license(LICENSES GPL-2.0-only  FILES ${ALL_SOURCE_FILES})
 
-set(KTEXTADDONS_MIN_VERSION "2.1.1")
+set(KTEXTADDONS_MIN_VERSION "2.1.2")
 
 find_package(
     Qt6
diff --git a/messagelist/src/CMakeLists.txt b/messagelist/src/CMakeLists.txt
index 4dc9dc134..cfc1f1c43 100644
--- a/messagelist/src/CMakeLists.txt
+++ b/messagelist/src/CMakeLists.txt
@@ -59,8 +59,6 @@ target_sources(
         core/widgets/searchlinecommand.cpp
         core/widgets/searchlinecommandbuttonswidget.h
         core/widgets/searchlinecommandbuttonswidget.cpp
-        core/widgets/searchlinecommandflowlayout.cpp
-        core/widgets/searchlinecommandflowlayout.h
         core/widgets/searchlinecommandwidget.h
         core/widgets/searchlinecommandwidget.cpp
         utils/aggregationcombobox.cpp
diff --git a/messagelist/src/core/widgets/autotests/searchlinecommandbuttonswidgettest.cpp b/messagelist/src/core/widgets/autotests/searchlinecommandbuttonswidgettest.cpp
index fcd4e458a..de494ca67 100644
--- a/messagelist/src/core/widgets/autotests/searchlinecommandbuttonswidgettest.cpp
+++ b/messagelist/src/core/widgets/autotests/searchlinecommandbuttonswidgettest.cpp
@@ -7,8 +7,8 @@
 #include "searchlinecommandbuttonswidgettest.h"
 
 #include "core/widgets/searchlinecommandbuttonswidget.h"
-#include "core/widgets/searchlinecommandflowlayout.h"
 #include <QTest>
+#include <TextAddonsWidgets/TextAddonsWidgetFlowLayout>
 QTEST_MAIN(SearchLineCommandButtonsWidgetTest)
 
 using namespace Qt::Literals::StringLiterals;
@@ -21,7 +21,7 @@ void SearchLineCommandButtonsWidgetTest::shouldHaveDefaultValues()
 {
     MessageList::Core::SearchLineCommandButtonsWidget w;
 
-    auto flowLayout = w.findChild<MessageList::Core::SearchLineCommandFlowLayout *>(u"flowLayout"_s);
+    auto flowLayout = w.findChild<TextAddonsWidgets::TextAddonsWidgetFlowLayout *>(u"flowLayout"_s);
     QVERIFY(flowLayout);
     QCOMPARE(flowLayout->contentsMargins(), QMargins{});
     QCOMPARE(flowLayout->spacing(), 0);
diff --git a/messagelist/src/core/widgets/searchlinecommandbuttonswidget.cpp b/messagelist/src/core/widgets/searchlinecommandbuttonswidget.cpp
index db5948cb6..21320e4ab 100644
--- a/messagelist/src/core/widgets/searchlinecommandbuttonswidget.cpp
+++ b/messagelist/src/core/widgets/searchlinecommandbuttonswidget.cpp
@@ -7,17 +7,17 @@ SPDX-License-Identifier: GPL-2.0-or-later
 #include "searchlinecommandbuttonswidget.h"
 #include "messagelist_debug.h"
 #include "searchlinecommand.h"
-#include "searchlinecommandflowlayout.h"
 #include <KLocalizedString>
 #include <QEvent>
 #include <QPushButton>
 #include <QVBoxLayout>
+#include <TextAddonsWidgets/TextAddonsWidgetFlowLayout>
 using namespace Qt::Literals::StringLiterals;
 using namespace MessageList::Core;
 SearchLineCommandButtonsWidget::SearchLineCommandButtonsWidget(QWidget *parent)
     : QFrame{parent}
 {
-    auto flowLayout = new SearchLineCommandFlowLayout(this);
+    auto flowLayout = new TextAddonsWidgets::TextAddonsWidgetFlowLayout(this);
     flowLayout->setObjectName(u"flowLayout"_s);
     flowLayout->setContentsMargins({});
     flowLayout->setSpacing(0);
diff --git a/messagelist/src/core/widgets/searchlinecommandflowlayout.cpp b/messagelist/src/core/widgets/searchlinecommandflowlayout.cpp
deleted file mode 100644
index f07b3f28c..000000000
--- a/messagelist/src/core/widgets/searchlinecommandflowlayout.cpp
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
-   SPDX-FileCopyrightText: 2020-2026 Laurent Montel <[email protected]>
-
-   SPDX-License-Identifier: LGPL-2.0-or-later
-*/
-
-#include "searchlinecommandflowlayout.h"
-
-#include <QStyle>
-#include <QWidget>
-using namespace Qt::Literals::StringLiterals;
-using namespace MessageList::Core;
-
-#if HAVE_TEXTADDONSWIDGETS_FLOWLAYOUT
-SearchLineCommandFlowLayout::SearchLineCommandFlowLayout(QWidget *parent)
-    : TextAddonsWidgets::TextAddonsWidgetFlowLayout(parent)
-{
-}
-
-SearchLineCommandFlowLayout::~SearchLineCommandFlowLayout()
-{
-    clearAndDeleteWidgets();
-}
-#else
-
-static int smartSpacing(QObject *parent, QStyle::PixelMetric pm)
-{
-    if (!parent) {
-        return -1;
-    } else if (parent->isWidgetType()) {
-        auto pw = static_cast<QWidget *>(parent);
-        return pw->style()->pixelMetric(pm, nullptr, pw);
-    } else {
-        return static_cast<QLayout *>(parent)->spacing();
-    }
-}
-
-SearchLineCommandFlowLayout::SearchLineCommandFlowLayout(QWidget *parent)
-    : QLayout(parent)
-{
-}
-
-SearchLineCommandFlowLayout::~SearchLineCommandFlowLayout()
-{
-    clear();
-}
-
-int SearchLineCommandFlowLayout::horizontalSpacing() const
-{
-    if (mHorizontalSpacing >= 0) {
-        return mHorizontalSpacing;
-    } else {
-        return smartSpacing(parent(), QStyle::PM_LayoutHorizontalSpacing);
-    }
-}
-
-void SearchLineCommandFlowLayout::setHorizontalSpacing(int horizontalSpacing)
-{
-    if (mHorizontalSpacing != horizontalSpacing) {
-        mHorizontalSpacing = horizontalSpacing;
-        invalidate();
-    }
-}
-
-int SearchLineCommandFlowLayout::verticalSpacing() const
-{
-    if (mVerticalSpacing >= 0) {
-        return mVerticalSpacing;
-    } else {
-        return smartSpacing(parent(), QStyle::PM_LayoutVerticalSpacing);
-    }
-}
-
-void SearchLineCommandFlowLayout::setVerticalSpacing(int verticalSpacing)
-{
-    if (mVerticalSpacing != verticalSpacing) {
-        mVerticalSpacing = verticalSpacing;
-        invalidate();
-    }
-}
-
-QSize SearchLineCommandFlowLayout::sizeHint() const
-{
-    return minimumSize();
-}
-
-QSize SearchLineCommandFlowLayout::minimumSize() const
-{
-    const QMargins margins = contentsMargins();
-    QSize size;
-
-    for (const QLayoutItem *item : mItems) {
-        size = size.expandedTo(item->minimumSize());
-    }
-
-    size += QSize(margins.left() + margins.right(), margins.top() + margins.bottom());
-    return size;
-}
-
-void SearchLineCommandFlowLayout::addItem(QLayoutItem *item)
-{
-    Q_ASSERT(!mItems.contains(item));
-    mItems.append(item);
-    invalidate();
-}
-
-QLayoutItem *SearchLineCommandFlowLayout::itemAt(int index) const
-{
-    if (index >= 0 && index < mItems.count()) {
-        return mItems[index];
-    }
-
-    return nullptr;
-}
-
-QLayoutItem *SearchLineCommandFlowLayout::takeAt(int index)
-{
-    if (index >= 0 && index < mItems.count()) {
-        auto *it = mItems.takeAt(index);
-        invalidate();
-        return it;
-    }
-
-    return nullptr;
-}
-
-int SearchLineCommandFlowLayout::count() const
-{
-    return mItems.count();
-}
-
-Qt::Orientations SearchLineCommandFlowLayout::expandingDirections() const
-{
-    return {};
-}
-
-bool SearchLineCommandFlowLayout::hasHeightForWidth() const
-{
-    return true;
-}
-
-int SearchLineCommandFlowLayout::heightForWidth(int width) const
-{
-    return doFlow(QRect(0, 0, width, 0), false);
-}
-
-void SearchLineCommandFlowLayout::setGeometry(const QRect &rect)
-{
-    QLayout::setGeometry(rect);
-    doFlow(rect, true);
-}
-
-void SearchLineCommandFlowLayout::clear()
-{
-    while (QLayoutItem *item = takeAt(0)) {
-        delete item;
-    }
-}
-
-void SearchLineCommandFlowLayout::clearAndDeleteWidgets()
-{
-    while (QLayoutItem *item = takeAt(0)) {
-        item->widget()->deleteLater();
-        delete item;
-    }
-}
-
-int SearchLineCommandFlowLayout::doFlow(QRect rect, bool effective) const
-{
-    const QMargins margins = contentsMargins();
-    const QRect effectiveRect = rect.adjusted(margins.left(), margins.top(), -margins.right(), -margins.bottom());
-    int x = effectiveRect.x();
-    int y = effectiveRect.y();
-    int highest = 0;
-
-    for (QLayoutItem *item : mItems) {
-        const QWidget *widget = item->widget();
-
-        if (!widget->isVisibleTo(parentWidget())) {
-            continue;
-        }
-
-        int hSpacing = horizontalSpacing();
-        int vSpacing = verticalSpacing();
-
-        if (hSpacing == -1) {
-            hSpacing = widget->style()->layoutSpacing(QSizePolicy::Frame, QSizePolicy::Frame, Qt::Horizontal);
-        }
-
-        if (vSpacing == -1) {
-            vSpacing = widget->style()->layoutSpacing(QSizePolicy::Frame, QSizePolicy::Frame, Qt::Vertical);
-        }
-
-        int widgetXPos = x + item->sizeHint().width() + hSpacing;
-
-        if (widgetXPos - hSpacing > effectiveRect.right() && highest > 0) {
-            x = effectiveRect.x();
-            y += highest + vSpacing;
-            widgetXPos = x + item->sizeHint().width() + hSpacing;
-            highest = 0;
-        }
-
-        if (effective) {
-            item->setGeometry(QRect(QPoint(x, y), item->sizeHint()));
-        }
-
-        x = widgetXPos;
-        highest = qMax(highest, item->sizeHint().height());
-    }
-
-    return y + highest - rect.y() + margins.bottom();
-}
-#endif
-#include "moc_searchlinecommandflowlayout.cpp"
diff --git a/messagelist/src/core/widgets/searchlinecommandflowlayout.h b/messagelist/src/core/widgets/searchlinecommandflowlayout.h
deleted file mode 100644
index ab985fe42..000000000
--- a/messagelist/src/core/widgets/searchlinecommandflowlayout.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
-   SPDX-FileCopyrightText: 2020-2026 Laurent Montel <[email protected]>
-
-   SPDX-License-Identifier: LGPL-2.0-or-later
-*/
-#pragma once
-#include "config-messagelist.h"
-#include "messagelist_private_export.h"
-#include <QLayout>
-#include <QList>
-#if HAVE_TEXTADDONSWIDGETS_FLOWLAYOUT
-#include <TextAddonsWidgets/TextAddonsWidgetFlowLayout>
-namespace MessageList::Core
-{
-class MESSAGELIST_TESTS_EXPORT SearchLineCommandFlowLayout : public TextAddonsWidgets::TextAddonsWidgetFlowLayout
-{
-    Q_OBJECT
-
-public:
-    explicit SearchLineCommandFlowLayout(QWidget *parent = nullptr);
-    ~SearchLineCommandFlowLayout() override;
-};
-}
-#else
-namespace MessageList::Core
-{
-class MESSAGELIST_TESTS_EXPORT SearchLineCommandFlowLayout : public QLayout
-{
-    Q_OBJECT
-
-public:
-    explicit SearchLineCommandFlowLayout(QWidget *parent = nullptr);
-    ~SearchLineCommandFlowLayout() override;
-
-    [[nodiscard]] int horizontalSpacing() const;
-    void setHorizontalSpacing(int horizontalSpacing);
-
-    [[nodiscard]] int verticalSpacing() const;
-    void setVerticalSpacing(int verticalSpacing);
-
-    [[nodiscard]] QSize sizeHint() const override;
-    [[nodiscard]] QSize minimumSize() const override;
-
-    void addItem(QLayoutItem *item) override;
-    QLayoutItem *itemAt(int index) const override;
-    QLayoutItem *takeAt(int index) override;
-    [[nodiscard]] int count() const override;
-
-    [[nodiscard]] Qt::Orientations expandingDirections() const override;
-    [[nodiscard]] bool hasHeightForWidth() const override;
-    [[nodiscard]] int heightForWidth(int width) const override;
-
-    void setGeometry(const QRect &rect) override;
-
-    void clear();
-    void clearAndDeleteWidgets();
-
-private:
-    MESSAGELIST_NO_EXPORT int doFlow(QRect rect, bool effective) const;
-    QList<QLayoutItem *> mItems;
-    int mHorizontalSpacing = -1;
-    int mVerticalSpacing = -1;
-};
-}
-#endif
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.