[pim/messagelib] /: Prepare to remove duplicate code
Laurent Montel <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 2aea8347e55b03d691a7f3c9ae1530f65cada5cc by Laurent Montel.
Committed on 20/07/2026 at 05:59.
Pushed by mlaurent into branch 'master'.
Prepare to remove duplicate code
M +4 -0 CMakeLists.txt
M +1 -0 messagelist/src/config-messagelist.h.in
M +14 -1 messagelist/src/core/widgets/searchlinecommandflowlayout.cpp
M +16 -0 messagelist/src/core/widgets/searchlinecommandflowlayout.h
https://invent.kde.org/pim/messagelib/-/commit/2aea8347e55b03d691a7f3c9ae1530f65cada5cc
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 173e88b5b..3fc104a66 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -293,6 +293,10 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
)
+if(${KF6TextAddonsWidgets_VERSION} VERSION_GREATER_EQUAL 2.1.41)
+ set(HAVE_TEXTADDONSWIDGETS_FLOWLAYOUT TRUE)
+endif()
+
add_subdirectory(mimetreeparser)
add_subdirectory(messageviewer)
add_subdirectory(templateparser)
diff --git a/messagelist/src/config-messagelist.h.in b/messagelist/src/config-messagelist.h.in
index 967e5d78f..1cce83e98 100644
--- a/messagelist/src/config-messagelist.h.in
+++ b/messagelist/src/config-messagelist.h.in
@@ -1,2 +1,3 @@
#cmakedefine KDEPIM_FOLDEROPEN_PROFILE 1
#cmakedefine01 FORCE_DISABLE_AKONADI_SEARCH
+#cmakedefine01 HAVE_TEXTADDONSWIDGETS_FLOWLAYOUT
diff --git a/messagelist/src/core/widgets/searchlinecommandflowlayout.cpp b/messagelist/src/core/widgets/searchlinecommandflowlayout.cpp
index bbfdc9917..f07b3f28c 100644
--- a/messagelist/src/core/widgets/searchlinecommandflowlayout.cpp
+++ b/messagelist/src/core/widgets/searchlinecommandflowlayout.cpp
@@ -10,6 +10,19 @@
#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) {
@@ -197,5 +210,5 @@ int SearchLineCommandFlowLayout::doFlow(QRect rect, bool effective) const
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
index 2b4149286..ab985fe42 100644
--- a/messagelist/src/core/widgets/searchlinecommandflowlayout.h
+++ b/messagelist/src/core/widgets/searchlinecommandflowlayout.h
@@ -4,9 +4,24 @@
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
@@ -47,3 +62,4 @@ private:
int mVerticalSpacing = -1;
};
}
+#endif