[libraries/ktextaddons] textautogeneratetext/widgets/promptswidget: Fill combobox

Laurent Montel <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 6f2c96de7027c317265b19d28d2286211564fce7 by Laurent Montel.
Committed on 10/08/2026 at 06:19.
Pushed by mlaurent into branch 'master'.

Fill combobox

M  +22   -0    textautogeneratetext/widgets/promptswidget/textautogeneratepromptcombobox.cpp
M  +7    -0    textautogeneratetext/widgets/promptswidget/textautogeneratepromptcombobox.h

https://invent.kde.org/libraries/ktextaddons/-/commit/6f2c96de7027c317265b19d28d2286211564fce7

diff --git a/textautogeneratetext/widgets/promptswidget/textautogeneratepromptcombobox.cpp b/textautogeneratetext/widgets/promptswidget/textautogeneratepromptcombobox.cpp
index 8da1a4324..2a6fa7448 100644
--- a/textautogeneratetext/widgets/promptswidget/textautogeneratepromptcombobox.cpp
+++ b/textautogeneratetext/widgets/promptswidget/textautogeneratepromptcombobox.cpp
@@ -4,11 +4,33 @@
   SPDX-License-Identifier: GPL-2.0-or-later
 */
 #include "textautogeneratepromptcombobox.h"
+#include <KLocalizedString>
 
 using namespace TextAutoGenerateText;
 TextAutoGeneratePromptComboBox::TextAutoGeneratePromptComboBox(QWidget *parent)
     : QComboBox(parent)
 {
+    fill();
 }
 
 TextAutoGeneratePromptComboBox::~TextAutoGeneratePromptComboBox() = default;
+
+void TextAutoGeneratePromptComboBox::fill()
+{
+    addItem(i18n("Code"), QVariant::fromValue(TextAutoGeneratePrompt::Category::Code));
+    addItem(i18n("Misc"), QVariant::fromValue(TextAutoGeneratePrompt::Category::Misc));
+    addItem(i18n("Travel"), QVariant::fromValue(TextAutoGeneratePrompt::Category::Travel));
+}
+
+TextAutoGeneratePrompt::Category TextAutoGeneratePromptComboBox::category() const
+{
+    return currentData().value<TextAutoGeneratePrompt::Category>();
+}
+
+void TextAutoGeneratePromptComboBox::setCategory(TextAutoGeneratePrompt::Category type)
+{
+    const int index = findData(QVariant::fromValue(type));
+    if (index != -1) {
+        setCurrentIndex(index);
+    }
+}
diff --git a/textautogeneratetext/widgets/promptswidget/textautogeneratepromptcombobox.h b/textautogeneratetext/widgets/promptswidget/textautogeneratepromptcombobox.h
index 20ade4ef9..784067253 100644
--- a/textautogeneratetext/widgets/promptswidget/textautogeneratepromptcombobox.h
+++ b/textautogeneratetext/widgets/promptswidget/textautogeneratepromptcombobox.h
@@ -4,6 +4,7 @@
   SPDX-License-Identifier: GPL-2.0-or-later
 */
 #pragma once
+#include "core/prompts/textautogenerateprompt.h"
 #include "textautogeneratetext_private_export.h"
 #include <QComboBox>
 namespace TextAutoGenerateText
@@ -14,5 +15,11 @@ class TEXTAUTOGENERATETEXT_TESTS_EXPORT TextAutoGeneratePromptComboBox : public
 public:
     explicit TextAutoGeneratePromptComboBox(QWidget *parent = nullptr);
     ~TextAutoGeneratePromptComboBox() override;
+
+    [[nodiscard]] TextAutoGeneratePrompt::Category category() const;
+    void setCategory(TextAutoGeneratePrompt::Category type);
+
+private:
+    TEXTAUTOGENERATETEXT_NO_EXPORT void fill();
 };
 }
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.