musredit 1.0.0
Loading...
Searching...
No Matches
PChangeDefaultPathsDialog.h
Go to the documentation of this file.
1/****************************************************************************
2
3 PChangeDefaultPathsDialog.h
4
5 Author: Andreas Suter
6 e-mail: andreas.suter@psi.ch
7
8*****************************************************************************/
9
10/***************************************************************************
11 * Copyright (C) 2010-2026 by Andreas Suter *
12 * andreas.suter@psi.ch *
13 * *
14 * This program is free software; you can redistribute it and/or modify *
15 * it under the terms of the GNU General Public License as published by *
16 * the Free Software Foundation; either version 2 of the License, or *
17 * (at your option) any later version. *
18 * *
19 * This program is distributed in the hope that it will be useful, *
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
22 * GNU General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU General Public License *
25 * along with this program; if not, write to the *
26 * Free Software Foundation, Inc., *
27 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
28 ***************************************************************************/
29
50
51#ifndef _PCHANGEDEFAULTPATHSDIALOG_H_
52#define _PCHANGEDEFAULTPATHSDIALOG_H_
53
54#include <memory>
55
56#include <QDialog>
57#include <QMessageBox>
58#include <QXmlStreamReader>
59#include <QIODevice>
60
61#include "ui_PChangeDefaultPathsDialog.h"
62
63class PDefaultPaths;
64
65//---------------------------------------------------------------------------
84{
85 public:
86 PDefaultPathsXMLParser(const QString &fln, PDefaultPaths *defaultPaths);
87
92
97 virtual bool isValid() { return fValid; }
98
99 private:
108
109 bool parse(QIODevice *device);
110 bool startDocument();
111 bool startElement();
112 bool endElement();
113 bool characters();
114 bool endDocument();
115
116 QXmlStreamReader fXml;
117 bool fValid;
120};
121
122//---------------------------------------------------------------------------
140class PDefaultPaths : public QObject
141{
142 public:
144
148 virtual ~PDefaultPaths() {}
149
154 virtual bool isValid() { return fValid; }
155
160 virtual void appendDefaultPath(QString str) { fDefaultPath << str; }
161
166 virtual QStringList *getDefaultPathList() { return &fDefaultPath; }
167
172 virtual QString getPrefPathName() { return fPrefPathName; }
173
174 private:
176
177 bool fValid;
179 QStringList fDefaultPath;
180};
181
182//---------------------------------------------------------------------------
209class PChangeDefaultPathsDialog : public QDialog, private Ui::PChangeDefaultPathsDialog
210{
211 Q_OBJECT
212
213 public:
215
216 private slots:
220 void deleteItem();
221
225 void addItem();
226
230 void saveDefaultPathList();
231
232 private:
233 std::unique_ptr<PDefaultPaths> fDefaultPath;
234};
235
236#endif // _PCHANGEDEFAULTPATHSDIALOG_H_
void addItem()
Add a new directory path via file browser dialog.
PChangeDefaultPathsDialog()
Constructs the default paths dialog.
std::unique_ptr< PDefaultPaths > fDefaultPath
Manages the default paths data.
void saveDefaultPathList()
Save the modified path list to the configuration file.
void deleteItem()
Remove the currently selected path from the list.
virtual bool isValid()
Check if the XML file was parsed successfully.
QXmlStreamReader fXml
Qt XML stream reader for parsing.
PDefaultPathsXMLParser(const QString &fln, PDefaultPaths *defaultPaths)
Constructs an XML parser for reading default data paths.
bool startElement()
Handler called when an XML start element is encountered.
bool characters()
Handler for XML element character content.
bool endDocument()
Handler called at the end of XML document parsing.
virtual ~PDefaultPathsXMLParser()
Virtual destructor.
EAdminKeyWords
Keywords for identifying XML elements during parsing.
@ eDataPath
Processing a <data_path> element.
@ eEmpty
No element currently being processed.
bool startDocument()
Handler called at the start of XML document parsing.
bool fValid
Flag indicating successful parsing.
PDefaultPaths * fDefaultPaths
Pointer to the object storing parsed paths.
bool parse(QIODevice *device)
Parse the XML configuration file for data paths.
bool endElement()
Handler called when an XML end element is encountered.
EAdminKeyWords fKeyWord
Current element type being processed.
Container class for managing default data file search paths.
friend class PDefaultPathsXMLParser
Allow parser to access private members.
virtual QStringList * getDefaultPathList()
Get the list of default search paths.
virtual bool isValid()
Check if the configuration was loaded successfully.
virtual void appendDefaultPath(QString str)
Add a new path to the default paths list.
virtual QString getPrefPathName()
Get the path to the configuration file being used.
QStringList fDefaultPath
List of default data file search directories.
QString fPrefPathName
Full path to the active configuration file.
PDefaultPaths()
Constructs a PDefaultPaths object and loads paths from configuration.
bool fValid
Flag indicating if configuration loaded successfully.
virtual ~PDefaultPaths()
Virtual destructor.