1
//MountManager - the program for easy mounting of storage devices in Linux
2
//Copyright (C) 2007-2008 Tikhonov Sergey
4
//This file is part of MountManager Core
6
//This program is free software; you can redistribute it and/or
7
//modify it under the terms of the GNU General Public License
8
//as published by the Free Software Foundation; either version 2
9
//of the License, or (at your option) any later version.
11
//This program is distributed in the hope that it will be useful,
12
//but WITHOUT ANY WARRANTY; without even the implied warranty of
13
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
//GNU General Public License for more details.
16
//You should have received a copy of the GNU General Public License
17
//along with this program; if not, write to the Free Software
18
//Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
#include <QXmlInputSource>
21
#include <QXmlSimpleReader>
23
#include "diskoptionsparser.h"
24
#include "diskoptionscenter.h"
25
#include "../gui/const.h"
27
DiskOptionsCenter::DiskOptionsCenter(const QString &fileSystem,QString lang) {
29
optionsReader = new QXmlSimpleReader;
30
optionsParser = new DiskOptionsParser(lang);
32
optionsReader->setContentHandler(optionsParser);
33
optionsReader->setErrorHandler(optionsParser);
35
inputFile = new QFile;
36
inputSource = new QXmlInputSource(inputFile);
38
if (!fileSystem.isEmpty()) setSourcePath(QString(OPTIONS_PATH) + fileSystem + ".xml");
41
DiskOptionsCenter::~DiskOptionsCenter() {
48
void DiskOptionsCenter::setSourcePath(const QString& sourcePath) {
49
inputFile->setFileName(sourcePath);
50
optionsReader->parse(inputSource);
52
if (optionsParser->isValid())
53
qDebug() << "[G] Parsing of " << sourcePath << " was successful";
55
qDebug() << "[W] Parsing of " << sourcePath << " was unsuccsessful";
58
void DiskOptionsCenter::setLanguage(const QString& language) {
59
optionsParser->setLanguage(language);
62
QString& DiskOptionsCenter::language() {
63
return optionsParser->language();
66
const QString& DiskOptionsCenter::language() const {
67
return optionsParser->language();
70
const QList<Option *>& DiskOptionsCenter::fileSystemOptions(const QString& fileSystem) {
71
if (fileSystem.isEmpty())
73
if (!cache.keys().contains(fileSystem)) {
74
setSourcePath(QString(OPTIONS_PATH) + fileSystem + ".xml");
75
cache[fileSystem] = optionsParser->options();
77
return cache[fileSystem];