summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-09-16 14:26:37 (GMT)
committerMontel Laurent <montel@kde.org>2016-09-16 14:26:37 (GMT)
commitb813820faf2fecbb8df703a23b7e4393fddccbf9 (patch)
tree05eaa7a1f68a11f3e6f97ee11172e4f8e2d63a83
parent66f4e32c6537a876f912e0ba255188f41ddea2fd (diff)
add method to load renamecategories files
-rw-r--r--autotests/CMakeLists.txt14
-rw-r--r--src/kdebugsettingsutil.cpp22
-rw-r--r--src/kdebugsettingsutil.h2
3 files changed, 30 insertions, 8 deletions
diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt
index 2379e36..a3f9abf 100644
--- a/autotests/CMakeLists.txt
+++ b/autotests/CMakeLists.txt
@@ -42,14 +42,14 @@ endmacro ()
add_unittest( kdebugsettingsdialogtest.cpp "${full_source_file}")
add_unittest( kdeapplicationdebugsettingpagetest.cpp "../src/kdeloggingcategory.cpp;../src/loggingcategory.cpp;../src/kdebugsettings_debug.cpp;../src/kdeapplicationdebugsettingpage.cpp;../src/kdeapplicationtreelistwidget.cpp;../src/categorytypecombobox.cpp")
-add_unittest( customdebugsettingspagetest.cpp "../src/kdeloggingcategory.cpp;../src/loggingcategory.cpp;../src/kdebugsettings_debug.cpp;../src/categorytypecombobox.cpp;../src/customdebugsettingspage.cpp;../src/configurecustomsettingdialog.cpp;../src/configurecustomsettingwidget.cpp;../src/kdebugsettingsutil.cpp")
-add_unittest( configurecustomsettingdialogtest.cpp "../src/kdeloggingcategory.cpp;../src/loggingcategory.cpp;../src/kdebugsettings_debug.cpp;../src/categorytypecombobox.cpp;../src/configurecustomsettingdialog.cpp;../src/configurecustomsettingwidget.cpp;../src/kdebugsettingsutil.cpp")
-add_unittest( configurecustomsettingwidgettest.cpp "../src/kdeloggingcategory.cpp;../src/loggingcategory.cpp;../src/kdebugsettings_debug.cpp;../src/categorytypecombobox.cpp;../src/configurecustomsettingwidget.cpp;../src/kdebugsettingsutil.cpp")
-add_unittest( environmentsettingsrulespagetest.cpp "../src/kdeloggingcategory.cpp;../src/loggingcategory.cpp;../src/environmentsettingsrulespage.cpp;../src/environmentplaintextedit.cpp")
-add_unittest( kdebugsettingutiltest.cpp "../src/kdeloggingcategory.cpp;../src/loggingcategory.cpp;../src/kdebugsettings_debug.cpp;../src/kdebugsettingsutil.cpp")
+add_unittest( customdebugsettingspagetest.cpp "../src/renamecategory.cpp;../src/kdeloggingcategory.cpp;../src/loggingcategory.cpp;../src/kdebugsettings_debug.cpp;../src/categorytypecombobox.cpp;../src/customdebugsettingspage.cpp;../src/configurecustomsettingdialog.cpp;../src/configurecustomsettingwidget.cpp;../src/kdebugsettingsutil.cpp")
+add_unittest( configurecustomsettingdialogtest.cpp "../src/renamecategory.cpp;../src/kdeloggingcategory.cpp;../src/loggingcategory.cpp;../src/kdebugsettings_debug.cpp;../src/categorytypecombobox.cpp;../src/configurecustomsettingdialog.cpp;../src/configurecustomsettingwidget.cpp;../src/kdebugsettingsutil.cpp")
+add_unittest( configurecustomsettingwidgettest.cpp "../src/renamecategory.cpp;../src/kdeloggingcategory.cpp;../src/loggingcategory.cpp;../src/kdebugsettings_debug.cpp;../src/categorytypecombobox.cpp;../src/configurecustomsettingwidget.cpp;../src/kdebugsettingsutil.cpp")
+add_unittest( environmentsettingsrulespagetest.cpp "../src/renamecategory.cpp;../src/kdeloggingcategory.cpp;../src/loggingcategory.cpp;../src/environmentsettingsrulespage.cpp;../src/environmentplaintextedit.cpp")
+add_unittest( kdebugsettingutiltest.cpp "../src/renamecategory.cpp;../src/kdeloggingcategory.cpp;../src/loggingcategory.cpp;../src/kdebugsettings_debug.cpp;../src/kdebugsettingsutil.cpp")
add_unittest( categorytypecomboboxtest.cpp "../src/loggingcategory.cpp;../src/categorytypecombobox.cpp")
-add_unittest( kdeapplicationtreelistwidgettest.cpp "../src/loggingcategory.cpp;../src/kdeapplicationtreelistwidget.cpp;../src/categorytypecombobox.cpp")
+add_unittest( kdeapplicationtreelistwidgettest.cpp "../src/renamecategory.cpp;../src/loggingcategory.cpp;../src/kdeapplicationtreelistwidget.cpp;../src/categorytypecombobox.cpp")
add_unittest( categorywarningtest.cpp "../src/categorywarning.cpp")
add_unittest( loggingcategorytest.cpp "../src/loggingcategory.cpp")
-add_unittest( loadcategoriesjobtest.cpp "../src/loadcategoriesjob.cpp;../src/loggingcategory.cpp;../src/kdeloggingcategory.cpp;../src/kdebugsettings_debug.cpp;../src/kdebugsettingsutil.cpp")
+add_unittest( loadcategoriesjobtest.cpp "../src/renamecategory.cpp;../src/loadcategoriesjob.cpp;../src/loggingcategory.cpp;../src/kdeloggingcategory.cpp;../src/kdebugsettings_debug.cpp;../src/kdebugsettingsutil.cpp")
add_unittest( renamecategorytest.cpp "../src/renamecategory.cpp;../src/kdebugsettingsutil.cpp;../src/kdeloggingcategory.cpp;../src/kdebugsettings_debug.cpp")
diff --git a/src/kdebugsettingsutil.cpp b/src/kdebugsettingsutil.cpp
index 03c3b25..076a691 100644
--- a/src/kdebugsettingsutil.cpp
+++ b/src/kdebugsettingsutil.cpp
@@ -49,6 +49,28 @@ RenameCategory KDebugSettingsUtil::parseRenameCategories(QString line)
return category;
}
+RenameCategory::List KDebugSettingsUtil::readRenameCategories(const QString &filename)
+{
+ RenameCategory::List insertCategories;
+
+ QFile file(filename);
+ if (!file.open(QIODevice::ReadOnly)) {
+ qCWarning(KDEBUGSETTINGS_LOG) << "Couldn't open" << filename;
+ } else {
+ QString data;
+ QTextStream ts(&file);
+ ts.setCodec("ISO-8859-1");
+ while (!ts.atEnd()) {
+ data = ts.readLine().simplified();
+ const RenameCategory category = parseRenameCategories(data);
+ if (category.isValid()) {
+ insertCategories.append(category);
+ }
+ }
+ }
+ return insertCategories;
+}
+
KdeLoggingCategory KDebugSettingsUtil::parseLineKdeLoggingCategory(QString line)
{
KdeLoggingCategory category;
diff --git a/src/kdebugsettingsutil.h b/src/kdebugsettingsutil.h
index a412605..7cbf640 100644
--- a/src/kdebugsettingsutil.h
+++ b/src/kdebugsettingsutil.h
@@ -110,7 +110,7 @@ KdeLoggingCategory::List readLoggingCategoriesForInserting(const QString &filena
QList<LoadLoggingCategory> readLoggingQtCategories(const QString &filename);
KDebugSettingsUtil::LineLoggingQtCategory parseLineLoggingQtCategory(const QString &line);
RenameCategory parseRenameCategories(QString line);
-
+RenameCategory::List readRenameCategories(const QString &filename);
}
Q_DECLARE_METATYPE(KDebugSettingsUtil::LoadLoggingCategory::LogType)