summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2016-06-20 20:46:01 +0200
committerMontel Laurent <[email protected]>2016-06-20 20:46:01 +0200
commit2be63c0d9155354ff0dcfe60af6f382236f593e9 (patch)
tree963003c1459bcfbe52c57dee2d5298e251b1fd5a
parent702f6e1d43191d734195b139663df2ed16e1684c (diff)
Add custom combobox
-rw-r--r--autotests/categorytypecomboboxtest.cpp3
-rw-r--r--src/categorytypecombobox.cpp10
-rw-r--r--src/categorytypecombobox.h2
-rw-r--r--src/configurecustomsettingwidget.cpp2
-rw-r--r--src/kdeapplicationtreelistwidget.cpp2
5 files changed, 12 insertions, 7 deletions
diff --git a/autotests/categorytypecomboboxtest.cpp b/autotests/categorytypecomboboxtest.cpp
index e92668c..ee93dda 100644
--- a/autotests/categorytypecomboboxtest.cpp
+++ b/autotests/categorytypecomboboxtest.cpp
@@ -35,7 +35,8 @@ CategoryTypeComboBoxTest::~CategoryTypeComboBoxTest()
void CategoryTypeComboBoxTest::shouldHaveDefaultValue()
{
- CategoryTypeComboBox w;
+ //FIXME test custom or not type
+ CategoryTypeComboBox w(true);
QCOMPARE(w.count(), 5);
}
diff --git a/src/categorytypecombobox.cpp b/src/categorytypecombobox.cpp
index 7b9ef5f..c858821 100644
--- a/src/categorytypecombobox.cpp
+++ b/src/categorytypecombobox.cpp
@@ -22,15 +22,19 @@
#include <KLocalizedString>
-CategoryTypeComboBox::CategoryTypeComboBox(QWidget *parent)
+CategoryTypeComboBox::CategoryTypeComboBox(bool customType, QWidget *parent)
: QComboBox(parent)
{
- addItem(i18n("All"), QVariant::fromValue(LoggingCategory::All));
+ if (!customType) {
+ addItem(i18n("All"), QVariant::fromValue(LoggingCategory::All));
+ }
addItem(i18n("Info"), QVariant::fromValue(LoggingCategory::Info));
addItem(i18n("Debug"), QVariant::fromValue(LoggingCategory::Debug));
addItem(i18n("Warning"), QVariant::fromValue(LoggingCategory::Warning));
addItem(i18n("Critical"), QVariant::fromValue(LoggingCategory::Critical));
- addItem(i18n("Off"), QVariant::fromValue(LoggingCategory::Off));
+ if (!customType) {
+ addItem(i18n("Off"), QVariant::fromValue(LoggingCategory::Off));
+ }
}
CategoryTypeComboBox::~CategoryTypeComboBox()
diff --git a/src/categorytypecombobox.h b/src/categorytypecombobox.h
index ddf4daa..ac66bdc 100644
--- a/src/categorytypecombobox.h
+++ b/src/categorytypecombobox.h
@@ -28,7 +28,7 @@ class CategoryTypeComboBox : public QComboBox
{
Q_OBJECT
public:
- explicit CategoryTypeComboBox(QWidget *parent = Q_NULLPTR);
+ explicit CategoryTypeComboBox(bool customType, QWidget *parent = Q_NULLPTR);
~CategoryTypeComboBox();
LoggingCategory::LoggingType type() const;
diff --git a/src/configurecustomsettingwidget.cpp b/src/configurecustomsettingwidget.cpp
index 4b249c0..4610f81 100644
--- a/src/configurecustomsettingwidget.cpp
+++ b/src/configurecustomsettingwidget.cpp
@@ -51,7 +51,7 @@ ConfigureCustomSettingWidget::ConfigureCustomSettingWidget(QWidget *parent)
lab->setObjectName(QStringLiteral("categorytype_label"));
categoryLayout->addWidget(lab);
- mCategoryType = new CategoryTypeComboBox;
+ mCategoryType = new CategoryTypeComboBox(true, this);
mCategoryType->setObjectName(QStringLiteral("categorytype_combobox"));
categoryLayout->addWidget(mCategoryType);
diff --git a/src/kdeapplicationtreelistwidget.cpp b/src/kdeapplicationtreelistwidget.cpp
index 8f48e8b..6c8f7c8 100644
--- a/src/kdeapplicationtreelistwidget.cpp
+++ b/src/kdeapplicationtreelistwidget.cpp
@@ -26,7 +26,7 @@ KDEApplicationTreeListWidgetItem::KDEApplicationTreeListWidgetItem(const QString
: QTreeWidgetItem(parent),
mCategory(category)
{
- mCategoryTypeCombobox = new CategoryTypeComboBox;
+ mCategoryTypeCombobox = new CategoryTypeComboBox(false);
treeWidget()->setItemWidget(this, CategoryType, mCategoryTypeCombobox);
}