-
-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathglobalstate.cpp
More file actions
69 lines (57 loc) · 1.88 KB
/
globalstate.cpp
File metadata and controls
69 lines (57 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
SPDX-FileCopyrightText: 2008-2011 Erlend Hamberg <ehamberg@gmail.com>
SPDX-FileCopyrightText: 2011 Svyatoslav Kuzmich <svatoslav1@gmail.com>
SPDX-FileCopyrightText: 2012-2013 Simon St James <kdedevel@etotheipiplusone.com>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "globalstate.h"
#include "history.h"
#include "macros.h"
#include "mappings.h"
#include "registers.h"
#include <KConfigGroup>
using namespace KateVi;
GlobalState::GlobalState()
{
m_macros = new Macros();
m_mappings = new Mappings();
m_registers = new Registers();
m_searchHistory = new History();
m_replaceHistory = new History();
m_commandHistory = new History();
readConfig(config().data());
}
GlobalState::~GlobalState()
{
writeConfig(config().data());
config().data()->sync();
delete m_searchHistory;
delete m_replaceHistory;
delete m_commandHistory;
delete m_macros;
delete m_mappings;
delete m_registers;
}
void GlobalState::writeConfig(KConfig *configFile) const
{
// FIXME: use own groups instead of one big group!
KConfigGroup config(configFile, QStringLiteral("Kate Vi Input Mode Settings"));
m_macros->writeConfig(config);
m_mappings->writeConfig(config);
m_registers->writeConfig(config);
}
void GlobalState::readConfig(const KConfig *configFile)
{
// FIXME: use own groups instead of one big group!
const KConfigGroup config(configFile, QStringLiteral("Kate Vi Input Mode Settings"));
m_macros->readConfig(config);
m_mappings->readConfig(config);
m_registers->readConfig(config);
}
KSharedConfigPtr GlobalState::config()
{
// use dummy config for unit tests!
return QStandardPaths::isTestModeEnabled()
? KSharedConfig::openConfig(QStringLiteral("katevirc-unittest"), KConfig::SimpleConfig, QStandardPaths::TempLocation)
: KSharedConfig::openConfig(QStringLiteral("katevirc"));
}