2 Copyright (c) 2010 Laurent Montel <montel@kde.org>
4 This library is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
9 This library is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 #include "configfile.h"
22 #include <KCMultiDialog>
24 #include <KConfigGroup>
25 #include <KLocalizedString>
26 #include <KStringHandler>
28 ConfigFile::ConfigFile(const QString
&configName
, QObject
*parent
)
33 m_config
= new KConfig(configName
);
36 ConfigFile::~ConfigFile()
41 void ConfigFile::write()
46 void ConfigFile::create()
48 Q_EMIT
info(i18n("Writing config file for %1...", m_name
));
50 foreach (const Config
&c
, m_configData
) {
51 KConfigGroup grp
= m_config
->group(c
.group
);
53 grp
.writeEntry(c
.key
, KStringHandler::obscure(c
.value
));
55 grp
.writeEntry(c
.key
, c
.value
);
65 Q_EMIT
finished(i18n("Config file for %1 is writing.", m_name
));
68 void ConfigFile::destroy()
70 Q_EMIT
info(i18n("Config file for %1 was not changed.", m_name
));
73 void ConfigFile::setName(const QString
&name
)
78 void ConfigFile::setConfig(const QString
&group
, const QString
&key
, const QString
&value
)
85 m_configData
.append(conf
);
88 void ConfigFile::setPassword(const QString
&group
, const QString
&key
, const QString
&value
)
95 m_configData
.append(conf
);
98 void ConfigFile::edit()
100 if (m_editName
.isEmpty()) {
101 Q_EMIT
error(i18n("No given name for the configuration."));
105 if (m_editName
== QLatin1String("freebusy")) {
106 KCMultiDialog
*dialog
= new KCMultiDialog();
107 dialog
->addModule(QStringLiteral("korganizer_configfreebusy.desktop"));
112 Q_EMIT
error(i18n("Unknown configuration name '%1'", m_editName
));
115 void ConfigFile::setEditName(const QString
&name
)
120 void ConfigFile::setEditMode(const bool editMode
)
122 m_editMode
= editMode
;