Engauge Digitizer  2
SettingsForGraph.cpp
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 
13 {
14 }
15 
16 QString SettingsForGraph::groupNameForNthCurve (int indexOneBased) const
17 {
18  ENGAUGE_ASSERT (indexOneBased != 0); // Make sure index is one-based versus zero-based
19 
20  QString groupNameWithPlaceholder = SETTINGS_GROUP_CURVE_GRAPH;
21  QString groupName = groupNameWithPlaceholder.replace (SETTINGS_GROUP_CURVE_GRAPH_PLACEHOLDER,
22  QString::number (indexOneBased));
23 
24  return groupName;
25 }
26 
27 QString SettingsForGraph::defaultCurveName (int indexOneBased,
28  const QString &defaultName) const
29 {
30  QString groupName = groupNameForNthCurve (indexOneBased);
31 
32  QSettings settings (SETTINGS_ENGAUGE, SETTINGS_DIGITIZER);
33  settings.beginGroup (groupName);
34 
35  return settings.value (SETTINGS_CURVE_NAME,
36  defaultName).toString();
37 }
SettingsForGraph()
Single constructor.
QString groupNameForNthCurve(int indexOneBased) const
Return the group name, that appears in the settings file/registry, for the specified curve index...
QString defaultCurveName(int indexOneBased, const QString &defaultName) const
Default graph name for the specified curve index.