mupp 1.1.0
Loading...
Searching...
No Matches
PmuppAdmin.h
Go to the documentation of this file.
1/****************************************************************************
2
3 PmuppAdmin.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
55
56#ifndef _PMUPPADMIN_H_
57#define _PMUPPADMIN_H_
58
59#include <QString>
60#include <QVector>
61#include <QMap>
62#include <QXmlStreamReader>
63
64#include "mupp.h"
65
66class PmuppAdmin;
67
68//---------------------------------------------------------------------------
84 public:
88 PmuppColor();
89
93 virtual ~PmuppColor() {}
94
99 QString getName() { return fName; }
100
107 void getRGB(int &r, int &g, int &b) { r=fRed; g=fGreen; b=fBlue; }
108
113 void setName(const QString name) { fName = name; }
114
121 void setRGB(const int r, const int g, const int b);
122
123 private:
124 QString fName;
125 int fRed;
126 int fGreen;
127 int fBlue;
128};
129
130//---------------------------------------------------------------------------
146 public:
150 PmuppMarker() { fMarker = 20; fMarkerSize = 1.0; }
151
157 PmuppMarker(int marker, double size) : fMarker(marker), fMarkerSize(size) {}
158
162 virtual ~PmuppMarker() {}
163
169 void getMarker(int &marker, double &size) { marker = fMarker; size = fMarkerSize; }
170
175 int getMarker() { return fMarker; }
176
181 double getMarkerSize() { return fMarkerSize; }
182
187 void setMarker(int marker) { fMarker = marker; }
188
193 void setMarkerSize(double size) { fMarkerSize = size; }
194
195 private:
197 double fMarkerSize;
198};
199
200//---------------------------------------------------------------------------
223{
224 public:
230 PmuppAdminXMLParser(const QString &fln, PmuppAdmin*);
231
236
241 virtual bool isValid() { return fValid; }
242
243 private:
256
262 bool parse(QIODevice *device);
263
268 bool startDocument();
269
274 bool startElement();
275
280 bool endElement();
281
286 bool characters();
287
292 bool endDocument();
293
294 QXmlStreamReader fXml;
295 bool fValid;
298};
299
300//---------------------------------------------------------------------------
323class PmuppAdmin : public QObject
324{
325 public:
329 PmuppAdmin();
330
334 virtual ~PmuppAdmin();
335
340 void addRecentFile(const QString str);
341
346 int getNumRecentFiles() { return fRecentFile.size(); }
347
353 QString getRecentFile(int idx);
354
359 int getNoOfMarkers() { return fMarker.size(); }
360
365 QVector<PmuppMarker> getMarkers() { return fMarker; }
366
372 PmuppMarker getMarker(int idx);
373
378 int getNoOfColors() { return fColor.size(); }
379
384 QVector<PmuppColor> getColors() { return fColor; }
385
393 void getColor(QString name, int &r, int &g, int &b);
394
402 void getColor(int idx, int &r, int &g, int &b);
403
409
415
421
426 void setIgnoreThemeAutoDetection(const bool theme) { fIgnoreThemeAutoDetection = theme; }
427
432 void setThemeIconsMenu(const bool theme) { fDarkThemeIconsMenu = theme; }
433
438 void setThemeIconsToolbar(const bool theme) { fDarkThemeIconsToolbar = theme; }
439
445 void setMarker(const int marker, const double size);
446
454 void setColor(const int r, const int g, const int b, QString name="");
455
456 private:
458
459 QVector<QString> fRecentFile;
460
464 QVector<PmuppMarker> fMarker;
465 QVector<PmuppColor> fColor;
466
473 void saveRecentFiles();
474
482};
483
484#endif // _PMUPPADMIN_H_
bool startDocument()
Handler for XML document start.
PmuppAdmin * fAdmin
pointer to the admin object being populated
Definition PmuppAdmin.h:297
bool parse(QIODevice *device)
Main parsing method that processes the XML document.
virtual ~PmuppAdminXMLParser()
Destructor.
Definition PmuppAdmin.h:235
EAdminKeyWords fKeyWord
current element type being processed
Definition PmuppAdmin.h:296
QXmlStreamReader fXml
Qt XML stream reader object for parsing.
Definition PmuppAdmin.h:294
virtual bool isValid()
Checks if the XML parsing was successful.
Definition PmuppAdmin.h:241
PmuppAdminXMLParser(const QString &fln, PmuppAdmin *)
Constructor that parses the XML configuration file.
bool fValid
flag indicating successful XML parsing
Definition PmuppAdmin.h:295
bool characters()
Handler for XML element text content.
bool startElement()
Handler for XML element opening tags.
EAdminKeyWords
Enumeration of recognized XML element types.
Definition PmuppAdmin.h:249
@ eIgnoreThemeAutoDetection
theme auto-detection override
Definition PmuppAdmin.h:251
@ eEmpty
no specific element being processed
Definition PmuppAdmin.h:249
@ eDarkThemeIconsMenu
menu icon theme setting
Definition PmuppAdmin.h:252
@ eDarkThemeIconsToolbar
toolbar icon theme setting
Definition PmuppAdmin.h:253
@ eRecentFile
recent file path element
Definition PmuppAdmin.h:250
@ eMarker
marker definition element
Definition PmuppAdmin.h:254
bool endElement()
Handler for XML element closing tags.
bool endDocument()
Handler for XML document end.
Main administration class for mupp configuration management.
Definition PmuppAdmin.h:324
void addRecentFile(const QString str)
Adds a file to the recent files list.
void setMarker(const int marker, const double size)
Adds a marker definition to the configuration.
QVector< PmuppMarker > getMarkers()
Gets all markers.
Definition PmuppAdmin.h:365
QVector< PmuppColor > fColor
vector of configured plot colors
Definition PmuppAdmin.h:465
PmuppAdmin()
Constructor. Loads configuration from mupp_startup.xml.
int getNumRecentFiles()
Gets the number of recent files.
Definition PmuppAdmin.h:346
bool getIgnoreThemeAutoDetection()
Checks if theme auto-detection should be ignored.
Definition PmuppAdmin.h:408
int getNoOfColors()
Gets the number of configured colors.
Definition PmuppAdmin.h:378
void setThemeIconsToolbar(const bool theme)
Sets the toolbar icon theme preference.
Definition PmuppAdmin.h:438
virtual ~PmuppAdmin()
Destructor. Saves recent files list before destruction.
int getNoOfMarkers()
Gets the number of configured markers.
Definition PmuppAdmin.h:359
QVector< PmuppMarker > fMarker
vector of configured plot markers
Definition PmuppAdmin.h:464
QString getRecentFile(int idx)
Gets a recent file path by index.
friend class PmuppAdminXMLParser
Definition PmuppAdmin.h:457
QVector< PmuppColor > getColors()
Gets all colors.
Definition PmuppAdmin.h:384
bool fDarkThemeIconsMenu
flag for dark theme menu icons
Definition PmuppAdmin.h:462
void setThemeIconsMenu(const bool theme)
Sets the menu icon theme preference.
Definition PmuppAdmin.h:432
void setColor(const int r, const int g, const int b, QString name="")
Adds a color definition to the configuration.
bool fIgnoreThemeAutoDetection
flag to override automatic theme detection
Definition PmuppAdmin.h:461
void createMuppStartupFile()
Creates a default mupp_startup.xml configuration file.
bool getDarkThemeIconsToolbarFlag()
Checks if dark theme icons should be used for toolbars.
Definition PmuppAdmin.h:420
void saveRecentFiles()
Saves the recent files list to the configuration file.
QVector< QString > fRecentFile
ring buffer of recent file paths (max MAX_RECENT_FILES)
Definition PmuppAdmin.h:459
void getColor(QString name, int &r, int &g, int &b)
Gets a color by name.
PmuppMarker getMarker(int idx)
Gets a marker definition by index.
bool getDarkThemeIconsMenuFlag()
Checks if dark theme icons should be used for menus.
Definition PmuppAdmin.h:414
bool fDarkThemeIconsToolbar
flag for dark theme toolbar icons
Definition PmuppAdmin.h:463
void setIgnoreThemeAutoDetection(const bool theme)
Sets the theme auto-detection preference.
Definition PmuppAdmin.h:426
virtual ~PmuppColor()
Destructor.
Definition PmuppAdmin.h:93
int fBlue
blue component (0-255)
Definition PmuppAdmin.h:127
int fRed
red component (0-255)
Definition PmuppAdmin.h:125
QString getName()
Gets the color name.
Definition PmuppAdmin.h:99
void getRGB(int &r, int &g, int &b)
Gets the RGB values of the color.
Definition PmuppAdmin.h:107
PmuppColor()
Default constructor. Initializes color with undefined values.
QString fName
optional name identifier for the color
Definition PmuppAdmin.h:124
int fGreen
green component (0-255)
Definition PmuppAdmin.h:126
void setName(const QString name)
Sets the color name.
Definition PmuppAdmin.h:113
void setRGB(const int r, const int g, const int b)
Sets the RGB values with validation.
Represents a plot marker style and size.
Definition PmuppAdmin.h:145
void setMarker(int marker)
Sets the marker code.
Definition PmuppAdmin.h:187
void getMarker(int &marker, double &size)
Gets both marker code and size.
Definition PmuppAdmin.h:169
PmuppMarker(int marker, double size)
Constructor with specified marker properties.
Definition PmuppAdmin.h:157
PmuppMarker()
Default constructor. Initializes with marker code 20 and size 1.0.
Definition PmuppAdmin.h:150
double fMarkerSize
size multiplier (1.0 = default size)
Definition PmuppAdmin.h:197
double getMarkerSize()
Gets the marker size multiplier.
Definition PmuppAdmin.h:181
virtual ~PmuppMarker()
Destructor.
Definition PmuppAdmin.h:162
void setMarkerSize(double size)
Sets the marker size multiplier.
Definition PmuppAdmin.h:193
int getMarker()
Gets the marker code.
Definition PmuppAdmin.h:175
int fMarker
marker code (1-49, ROOT style)
Definition PmuppAdmin.h:196
Header file for mupp (muon parameter plotter) main application.