Changeset View
Changeset View
Standalone View
Standalone View
addons/externaltools/kateexternaltool.cpp
- This file was added.
1 | /* This file is part of the KDE project | ||||
---|---|---|---|---|---|
2 | * | ||||
3 | * Copyright 2019 Dominik Haumann <dhaumann@kde.org> | ||||
4 | * | ||||
5 | * This library is free software; you can redistribute it and/or | ||||
6 | * modify it under the terms of the GNU Library General Public | ||||
7 | * License as published by the Free Software Foundation; either | ||||
8 | * version 2 of the License, or (at your option) any later version. | ||||
9 | * | ||||
10 | * This library is distributed in the hope that it will be useful, | ||||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
13 | * Library General Public License for more details. | ||||
14 | * | ||||
15 | * You should have received a copy of the GNU Library General Public License | ||||
16 | * along with this library; see the file COPYING.LIB. If not, write to | ||||
17 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||||
18 | * Boston, MA 02110-1301, USA. | ||||
19 | */ | ||||
20 | #include "kateexternaltool.h" | ||||
21 | | ||||
22 | #include <KConfigGroup> | ||||
23 | #include <QStandardPaths> | ||||
24 | | ||||
25 | bool KateExternalTool::checkExec() const | ||||
26 | { | ||||
27 | return !QStandardPaths::findExecutable(executable).isEmpty(); | ||||
28 | } | ||||
29 | | ||||
30 | bool KateExternalTool::matchesMimetype(const QString& mt) const | ||||
31 | { | ||||
32 | return mimetypes.isEmpty() || mimetypes.contains(mt); | ||||
33 | } | ||||
34 | | ||||
35 | void KateExternalTool::load(const KConfigGroup& cg) | ||||
36 | { | ||||
37 | category = cg.readEntry("category", ""); | ||||
38 | name = cg.readEntry("name", ""); | ||||
39 | icon = cg.readEntry("icon", ""); | ||||
40 | executable = cg.readEntry("executable", ""); | ||||
41 | arguments = cg.readEntry("arguments", ""); | ||||
42 | input = cg.readEntry("input", ""); | ||||
43 | workingDir = cg.readEntry("workingDir", ""); | ||||
44 | mimetypes = cg.readEntry("mimetypes", QStringList()); | ||||
45 | actionName = cg.readEntry("actionName"); | ||||
46 | cmdname = cg.readEntry("cmdname"); | ||||
47 | saveMode = static_cast<KateExternalTool::SaveMode>(cg.readEntry("save", 0)); | ||||
48 | reload = cg.readEntry("reload", false); | ||||
49 | outputMode = static_cast<KateExternalTool::OutputMode>(cg.readEntry("output", 0)); | ||||
50 | includeStderr = cg.readEntry("includeStderr", false); | ||||
51 | | ||||
52 | hasexec = checkExec(); | ||||
53 | } | ||||
54 | | ||||
55 | void KateExternalTool::save(KConfigGroup& cg) const | ||||
56 | { | ||||
57 | cg.writeEntry("category", category); | ||||
58 | cg.writeEntry("name", name); | ||||
59 | cg.writeEntry("icon", icon); | ||||
60 | cg.writeEntry("executable", executable); | ||||
61 | cg.writeEntry("arguments", arguments); | ||||
62 | cg.writeEntry("input", input); | ||||
63 | cg.writeEntry("workingDir", workingDir); | ||||
64 | cg.writeEntry("mimetypes", mimetypes); | ||||
65 | cg.writeEntry("actionName", actionName); | ||||
66 | cg.writeEntry("cmdname", cmdname); | ||||
67 | cg.writeEntry("save", static_cast<int>(saveMode)); | ||||
68 | cg.writeEntry("reload", reload); | ||||
69 | cg.writeEntry("output", static_cast<int>(outputMode)); | ||||
70 | cg.writeEntry("includeStderr", includeStderr); | ||||
71 | } | ||||
72 | | ||||
73 | bool operator==(const KateExternalTool & lhs, const KateExternalTool & rhs) | ||||
74 | { | ||||
75 | return lhs.category == rhs.category | ||||
76 | && lhs.name == rhs.name | ||||
77 | && lhs.icon == rhs.icon | ||||
78 | && lhs.executable == rhs.executable | ||||
79 | && lhs.arguments == rhs.arguments | ||||
80 | && lhs.input == rhs.input | ||||
81 | && lhs.workingDir == rhs.workingDir | ||||
82 | && lhs.mimetypes == rhs.mimetypes | ||||
83 | && lhs.actionName == rhs.actionName | ||||
84 | && lhs.cmdname == rhs.cmdname | ||||
85 | && lhs.saveMode == rhs.saveMode | ||||
86 | && lhs.reload == rhs.reload | ||||
87 | && lhs.outputMode == rhs.outputMode | ||||
88 | && lhs.includeStderr == rhs.includeStderr; | ||||
89 | } | ||||
90 | | ||||
91 | // kate: space-indent on; indent-width 4; replace-tabs on; |