]> Shamusworld >> Repos - architektonas/blob - src/base/variable.cpp
Fixed thumbnail rendering in LibraryWidget and DXF detection.
[architektonas] / src / base / variable.cpp
1 // variable.cpp
2 //
3 // Part of the Architektonas Project
4 // Originally part of QCad Community Edition by Andrew Mustun
5 // Extensively rewritten and refactored by James L. Hammons
6 // Portions copyright (C) 2001-2003 RibbonSoft
7 // Copyright (C) 2010 Underground Software
8 // See the README and GPLv2 files for licensing and warranty information
9 //
10 // JLH = James L. Hammons <jlhamm@acm.org>
11 //
12 // Who  When        What
13 // ---  ----------  -----------------------------------------------------------
14 // JLH  05/07/2010  Moved implementation from header to this file. :-)
15 //
16
17 // We probably could replace all this crap with QVariant...
18 #include "variable.h"
19
20 RS_Variable::RS_Variable()
21 {
22         type = RS2::VariableVoid;
23         code = 0;
24 }
25
26 RS_Variable::RS_Variable(const Vector & v, int c)
27 {
28         setVector(v);
29         code = c;
30 }
31
32 RS_Variable::RS_Variable(const QString & v, int c)
33 {
34         setString(v);
35         code = c;
36 }
37
38 RS_Variable::RS_Variable(int v, int c)
39 {
40         setInt(v);
41         code = c;
42 }
43
44 RS_Variable::RS_Variable(double v, int c)
45 {
46         setDouble(v);
47         code = c;
48 }
49
50 /*virtual*/ RS_Variable::~RS_Variable()
51 {
52 }
53
54 void RS_Variable::setString(const QString & str)
55 {
56         contents.s = str;
57         type = RS2::VariableString;
58 }
59
60 void RS_Variable::setInt(int i)
61 {
62         contents.i = i;
63         type = RS2::VariableInt;
64 }
65
66 void RS_Variable::setDouble(double d)
67 {
68         contents.d = d;
69         type = RS2::VariableDouble;
70 }
71
72 void RS_Variable::setVector(const Vector & v)
73 {
74         contents.v = v;
75         type = RS2::VariableVector;
76 }
77
78 QString RS_Variable::getString()
79 {
80         return contents.s;
81 }
82
83 int RS_Variable::getInt()
84 {
85         return contents.i;
86 }
87
88 double RS_Variable::getDouble()
89 {
90         return contents.d;
91 }
92
93 Vector RS_Variable::getVector()
94 {
95         return contents.v;
96 }
97
98 RS2::VariableType RS_Variable::getType()
99 {
100         return type;
101 }
102
103 int RS_Variable::getCode()
104 {
105         return code;
106 }