Engauge Digitizer
2
Toggle main menu visibility
Loading...
Searching...
No Matches
Settings
SettingsForGraph.cpp
Go to the documentation of this file.
1
/******************************************************************************************************
2
* (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3
* under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4
* LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5
******************************************************************************************************/
6
7
#include "
EngaugeAssert.h
"
8
#include <QSettings>
9
#include "
Settings.h
"
10
#include "
SettingsForGraph.h
"
11
12
SettingsForGraph::SettingsForGraph
()
13
{
14
}
15
16
QString
SettingsForGraph::defaultCurveName
(
int
indexOneBased,
17
const
QString &defaultName)
const
18
{
19
QString groupName =
groupNameForNthCurve
(indexOneBased);
20
21
QSettings settings (
SETTINGS_ENGAUGE
,
SETTINGS_DIGITIZER
);
22
settings.beginGroup (groupName);
23
24
QString curveName = settings.value (
SETTINGS_CURVE_NAME
,
25
defaultName).toString();
26
27
settings.endGroup ();
28
29
return
curveName;
30
}
31
32
QString
SettingsForGraph::groupNameForNthCurve
(
int
indexOneBased)
const
33
{
34
ENGAUGE_ASSERT
(indexOneBased != 0);
// Make sure index is one-based versus zero-based
35
36
QString groupNameWithPlaceholder =
SETTINGS_GROUP_CURVE_GRAPH
;
37
QString groupName = groupNameWithPlaceholder.replace (
SETTINGS_GROUP_CURVE_GRAPH_PLACEHOLDER
,
38
QString::number (indexOneBased));
39
40
return
groupName;
41
}
42
43
int
SettingsForGraph::numberOfCurvesForImport
()
const
44
{
45
const
QString EMPTY_CURVE_NAME;
46
47
// Loop until the configuration file returns an empty string
48
int
indexOneBased = 1;
49
while
(
defaultCurveName
(indexOneBased + 1, EMPTY_CURVE_NAME) != EMPTY_CURVE_NAME) {
50
++indexOneBased;
51
}
52
53
return
indexOneBased;
54
}
EngaugeAssert.h
ENGAUGE_ASSERT
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT.
Definition
EngaugeAssert.h:17
SettingsForGraph.h
Settings.h
SETTINGS_ENGAUGE
const QString SETTINGS_ENGAUGE
SETTINGS_GROUP_CURVE_GRAPH
const QString SETTINGS_GROUP_CURVE_GRAPH
SETTINGS_GROUP_CURVE_GRAPH_PLACEHOLDER
const QString SETTINGS_GROUP_CURVE_GRAPH_PLACEHOLDER
SETTINGS_DIGITIZER
const QString SETTINGS_DIGITIZER
SETTINGS_CURVE_NAME
const QString SETTINGS_CURVE_NAME
SettingsForGraph::groupNameForNthCurve
QString groupNameForNthCurve(int indexOneBased) const
Return the group name, that appears in the settings file/registry, for the specified curve index.
Definition
SettingsForGraph.cpp:32
SettingsForGraph::defaultCurveName
QString defaultCurveName(int indexOneBased, const QString &defaultName) const
Default graph name for the specified curve index.
Definition
SettingsForGraph.cpp:16
SettingsForGraph::numberOfCurvesForImport
int numberOfCurvesForImport() const
Return the number of curve names to be generated. Value is maximum of 1 and the number in the configu...
Definition
SettingsForGraph.cpp:43
SettingsForGraph::SettingsForGraph
SettingsForGraph()
Single constructor.
Definition
SettingsForGraph.cpp:12
Generated on
for Engauge Digitizer by
1.17.0