File indexing completed on 2024-04-21 05:44:09
0001 /* 0002 SPDX-FileCopyrightText: 2001-2004 Otto Bruggeman <otto.bruggeman@home.nl> 0003 SPDX-FileCopyrightText: 2007 Kevin Kofler <kevin.kofler@chello.at> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #include "diffsettings.h" 0009 0010 // KF 0011 #include <KConfig> 0012 #include <KConfigGroup> 0013 // Qt 0014 #include <QWidget> 0015 0016 namespace KompareDiff2 0017 { 0018 0019 DiffSettings::DiffSettings() 0020 : m_linesOfContext(0) 0021 , m_format(Unified) 0022 , m_largeFiles(false) 0023 , m_ignoreWhiteSpace(false) 0024 , m_ignoreAllWhiteSpace(false) 0025 , m_ignoreEmptyLines(false) 0026 , m_ignoreChangesDueToTabExpansion(false) 0027 , m_createSmallerDiff(false) 0028 , m_ignoreChangesInCase(false) 0029 , m_showCFunctionChange(false) 0030 , m_convertTabsToSpaces(false) 0031 , m_ignoreRegExp(false) 0032 , m_recursive(false) 0033 , m_newFiles(false) 0034 , m_excludeFilePattern(false) 0035 , m_excludeFilesFile(false) 0036 { 0037 } 0038 0039 DiffSettings::~DiffSettings() = default; 0040 0041 void DiffSettings::loadSettings(KConfig *config) 0042 { 0043 KConfigGroup group(config, QStringLiteral("Diff Options")); 0044 // clang-format off 0045 m_diffProgram = group.readEntry("DiffProgram", QString()); 0046 m_linesOfContext = group.readEntry("LinesOfContext", 3); 0047 m_largeFiles = group.readEntry("LargeFiles", true); 0048 m_ignoreWhiteSpace = group.readEntry("IgnoreWhiteSpace", false); 0049 m_ignoreAllWhiteSpace = group.readEntry("IgnoreAllWhiteSpace", false); 0050 m_ignoreEmptyLines = group.readEntry("IgnoreEmptyLines", false); 0051 m_ignoreChangesDueToTabExpansion = group.readEntry("IgnoreChangesDueToTabExpansion", false); 0052 m_ignoreChangesInCase = group.readEntry("IgnoreChangesInCase", false); 0053 m_ignoreRegExp = group.readEntry("IgnoreRegExp", false); 0054 m_ignoreRegExpText = group.readEntry("IgnoreRegExpText", QString()); 0055 m_ignoreRegExpTextHistory = group.readEntry("IgnoreRegExpTextHistory", QStringList()); 0056 m_createSmallerDiff = group.readEntry("CreateSmallerDiff", true); 0057 m_convertTabsToSpaces = group.readEntry("ConvertTabsToSpaces", false); 0058 m_showCFunctionChange = group.readEntry("ShowCFunctionChange", false); 0059 m_recursive = group.readEntry("CompareRecursively", true); 0060 m_newFiles = group.readEntry("NewFiles", true); 0061 // clang-format on 0062 0063 m_format = static_cast<Format>(group.readEntry("Format", static_cast<int>(Unified))); 0064 0065 KConfigGroup group2(config, QStringLiteral("Exclude File Options")); 0066 // clang-format off 0067 m_excludeFilePattern = group2.readEntry("Pattern", false); 0068 m_excludeFilePatternList = group2.readEntry("PatternList", QStringList()); 0069 m_excludeFilesFile = group2.readEntry("File", false); 0070 m_excludeFilesFileURL = group2.readEntry("FileURL", QString()); 0071 m_excludeFilesFileHistoryList = group2.readEntry("FileHistoryList", QStringList()); 0072 // clang-format on 0073 } 0074 0075 void DiffSettings::saveSettings(KConfig *config) 0076 { 0077 KConfigGroup group(config, QStringLiteral("Diff Options")); 0078 // clang-format off 0079 group.writeEntry("DiffProgram", m_diffProgram); 0080 group.writeEntry("LinesOfContext", m_linesOfContext); 0081 group.writeEntry("Format", (int)m_format); 0082 group.writeEntry("LargeFiles", m_largeFiles); 0083 group.writeEntry("IgnoreWhiteSpace", m_ignoreWhiteSpace); 0084 group.writeEntry("IgnoreAllWhiteSpace", m_ignoreAllWhiteSpace); 0085 group.writeEntry("IgnoreEmptyLines", m_ignoreEmptyLines); 0086 group.writeEntry("IgnoreChangesInCase", m_ignoreChangesInCase); 0087 group.writeEntry("IgnoreChangesDueToTabExpansion", m_ignoreChangesDueToTabExpansion); 0088 group.writeEntry("IgnoreRegExp", m_ignoreRegExp); 0089 group.writeEntry("IgnoreRegExpText", m_ignoreRegExpText); 0090 group.writeEntry("IgnoreRegExpTextHistory", m_ignoreRegExpTextHistory); 0091 group.writeEntry("CreateSmallerDiff", m_createSmallerDiff); 0092 group.writeEntry("ConvertTabsToSpaces", m_convertTabsToSpaces); 0093 group.writeEntry("ShowCFunctionChange", m_showCFunctionChange); 0094 group.writeEntry("CompareRecursively", m_recursive); 0095 group.writeEntry("NewFiles", m_newFiles); 0096 // clang-format on 0097 0098 KConfigGroup group2(config, QStringLiteral("Exclude File Options")); 0099 // clang-format off 0100 group2.writeEntry("Pattern", m_excludeFilePattern); 0101 group2.writeEntry("PatternList", m_excludeFilePatternList); 0102 group2.writeEntry("File", m_excludeFilesFile); 0103 group2.writeEntry("FileURL", m_excludeFilesFileURL); 0104 group2.writeEntry("FileHistoryList", m_excludeFilesFileHistoryList); 0105 // clang-format on 0106 0107 config->sync(); 0108 } 0109 0110 }