KompareDiff2

diffsettings.cpp
1/*
2 SPDX-FileCopyrightText: 2001-2004 Otto Bruggeman <otto.bruggeman@home.nl>
3 SPDX-FileCopyrightText: 2007 Kevin Kofler <kevin.kofler@chello.at>
4
5 SPDX-License-Identifier: GPL-2.0-or-later
6*/
7
8#include "diffsettings.h"
9
10// KF
11#include <KConfig>
12#include <KConfigGroup>
13// Qt
14#include <QWidget>
15
16namespace KompareDiff2
17{
18
19DiffSettings::DiffSettings()
20 : m_linesOfContext(0)
21 , m_format(Unified)
22 , m_largeFiles(false)
23 , m_ignoreWhiteSpace(false)
24 , m_ignoreAllWhiteSpace(false)
25 , m_ignoreEmptyLines(false)
26 , m_ignoreChangesDueToTabExpansion(false)
27 , m_createSmallerDiff(false)
28 , m_ignoreChangesInCase(false)
29 , m_showCFunctionChange(false)
30 , m_convertTabsToSpaces(false)
31 , m_ignoreRegExp(false)
32 , m_recursive(false)
33 , m_newFiles(false)
34 , m_excludeFilePattern(false)
35 , m_excludeFilesFile(false)
36{
37}
38
39DiffSettings::~DiffSettings() = default;
40
41void DiffSettings::loadSettings(KConfig *config)
42{
43 KConfigGroup group(config, QStringLiteral("Diff Options"));
44 // clang-format off
45 m_diffProgram = group.readEntry("DiffProgram", QString());
46 m_linesOfContext = group.readEntry("LinesOfContext", 3);
47 m_largeFiles = group.readEntry("LargeFiles", true);
48 m_ignoreWhiteSpace = group.readEntry("IgnoreWhiteSpace", false);
49 m_ignoreAllWhiteSpace = group.readEntry("IgnoreAllWhiteSpace", false);
50 m_ignoreEmptyLines = group.readEntry("IgnoreEmptyLines", false);
51 m_ignoreChangesDueToTabExpansion = group.readEntry("IgnoreChangesDueToTabExpansion", false);
52 m_ignoreChangesInCase = group.readEntry("IgnoreChangesInCase", false);
53 m_ignoreRegExp = group.readEntry("IgnoreRegExp", false);
54 m_ignoreRegExpText = group.readEntry("IgnoreRegExpText", QString());
55 m_ignoreRegExpTextHistory = group.readEntry("IgnoreRegExpTextHistory", QStringList());
56 m_createSmallerDiff = group.readEntry("CreateSmallerDiff", true);
57 m_convertTabsToSpaces = group.readEntry("ConvertTabsToSpaces", false);
58 m_showCFunctionChange = group.readEntry("ShowCFunctionChange", false);
59 m_recursive = group.readEntry("CompareRecursively", true);
60 m_newFiles = group.readEntry("NewFiles", true);
61 // clang-format on
62
63 m_format = static_cast<Format>(group.readEntry("Format", static_cast<int>(Unified)));
64
65 KConfigGroup group2(config, QStringLiteral("Exclude File Options"));
66 // clang-format off
67 m_excludeFilePattern = group2.readEntry("Pattern", false);
68 m_excludeFilePatternList = group2.readEntry("PatternList", QStringList());
69 m_excludeFilesFile = group2.readEntry("File", false);
70 m_excludeFilesFileURL = group2.readEntry("FileURL", QString());
71 m_excludeFilesFileHistoryList = group2.readEntry("FileHistoryList", QStringList());
72 // clang-format on
73}
74
75void DiffSettings::saveSettings(KConfig *config)
76{
77 KConfigGroup group(config, QStringLiteral("Diff Options"));
78 // clang-format off
79 group.writeEntry("DiffProgram", m_diffProgram);
80 group.writeEntry("LinesOfContext", m_linesOfContext);
81 group.writeEntry("Format", (int)m_format);
82 group.writeEntry("LargeFiles", m_largeFiles);
83 group.writeEntry("IgnoreWhiteSpace", m_ignoreWhiteSpace);
84 group.writeEntry("IgnoreAllWhiteSpace", m_ignoreAllWhiteSpace);
85 group.writeEntry("IgnoreEmptyLines", m_ignoreEmptyLines);
86 group.writeEntry("IgnoreChangesInCase", m_ignoreChangesInCase);
87 group.writeEntry("IgnoreChangesDueToTabExpansion", m_ignoreChangesDueToTabExpansion);
88 group.writeEntry("IgnoreRegExp", m_ignoreRegExp);
89 group.writeEntry("IgnoreRegExpText", m_ignoreRegExpText);
90 group.writeEntry("IgnoreRegExpTextHistory", m_ignoreRegExpTextHistory);
91 group.writeEntry("CreateSmallerDiff", m_createSmallerDiff);
92 group.writeEntry("ConvertTabsToSpaces", m_convertTabsToSpaces);
93 group.writeEntry("ShowCFunctionChange", m_showCFunctionChange);
94 group.writeEntry("CompareRecursively", m_recursive);
95 group.writeEntry("NewFiles", m_newFiles);
96 // clang-format on
97
98 KConfigGroup group2(config, QStringLiteral("Exclude File Options"));
99 // clang-format off
100 group2.writeEntry("Pattern", m_excludeFilePattern);
101 group2.writeEntry("PatternList", m_excludeFilePatternList);
102 group2.writeEntry("File", m_excludeFilesFile);
103 group2.writeEntry("FileURL", m_excludeFilesFileURL);
104 group2.writeEntry("FileHistoryList", m_excludeFilesFileHistoryList);
105 // clang-format on
106
107 config->sync();
108}
109
110}
bool sync() override
KompareDiff2 namespace.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:54:52 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.