summaryrefslogtreecommitdiff
path: root/plugins/Oculars/src/Lens.cpp
blob: 64f7916f419a7a03c08f7152b57f16a72a06371b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
 * Copyright (C) 2009 Timothy Reaves
 * Copyright (C) 2013 Pawel Stolowski
 * Copyright (C) 2013 Alexander Wolf
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA  02110-1335, USA.
 */

#include "Lens.hpp"
#include <QSettings>

Lens::Lens()
	: m_multipler(1.)
{
}

Lens::Lens(const QObject& other)
	: m_name(other.property("name").toString())
	, m_multipler(other.property("multipler").toDouble())
{
}

Lens::~Lens()
{
}

static QMap<int, QString> mapping;
QMap<int, QString> Lens::propertyMap()
{
	if(mapping.isEmpty()) {
		mapping = {
			{0, "name"     },
			{1, "multipler"}};
	}
	return mapping;
}

const QString Lens::getName() const
{
	return m_name;
}

void Lens::setName(const QString& theValue)
{
	m_name = theValue;
}

double Lens::getMultipler() const
{
	return m_multipler;
}

void Lens::setMultipler(double theValue)
{
	m_multipler = theValue;
}

void Lens::writeToSettings(QSettings * settings, const int index)
{
	QString prefix = "lens/" + QVariant(index).toString() + "/";
	settings->setValue(prefix + "name", this->getName());
	settings->setValue(prefix + "multipler", this->getMultipler());
}

/* ********************************************************************* */
#if 0
#pragma mark -
#pragma mark Static Methods
#endif
/* ********************************************************************* */

Lens* Lens:: lensFromSettings(QSettings* theSettings, int lensIndex)
{
	Lens* lens = new Lens();
	QString prefix = "lens/" + QVariant(lensIndex).toString() + "/";

	lens->setName(theSettings->value(prefix + "name", "").toString());
	lens->setMultipler(theSettings->value(prefix + "multipler", "1").toDouble());

	return lens;
}

Lens* Lens::lensModel()
{
	Lens* model = new Lens();
	model->setName("My Lens");
	model->setMultipler(2.0);
	return model;
}