Merge branch 'master' of https://vcs.maemo.org/git/gpssportsniffer
[gpssportsniffer] / settings.cpp
1 /****************************************************************************
2 **
3 **  Copyright (C) 2011  Tito Eritja Real <jtitoo@gmail.com>
4 **
5 **  This program is free software: you can redistribute it and/or modify
6 **  it under the terms of the GNU General Public License as published by
7 **  the Free Software Foundation, either version 3 of the License, or
8 **  (at your option) any later version.
9 **
10 **  This program is distributed in the hope that it will be useful,
11 **  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 **  GNU General Public License for more details.
14 **
15 **  You should have received a copy of the GNU General Public License
16 **  along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 **
18 ****************************************************************************/
19
20 #include "settings.h"
21
22 Settings::Settings(Log *log)
23     :servicesStarted(false),isConfigured(false),log(log),autosaveInterval(5){
24
25     horizontalAccuracy=ACCURACY_H_MIN; //200
26     verticalAccuracy=ACCURACY_V_MIN;   //100
27     trackToSniffColor="#ff0000";
28     trackColor="#5bff24";
29 }
30
31 Settings::Settings(const Settings& set, Log *log):
32     activity(set.activity),gpsInterval(set.gpsInterval),mapType(set.mapType),isOnline(set.isOnline)
33   ,xmlFile(set.xmlFile),servicesStarted(set.servicesStarted),isConfigured(set.isConfigured),log(log){
34     log->debug("--Settings 2n constuctor ---");
35     log->debug("isConfigured:" + isConfigured);
36     horizontalAccuracy=ACCURACY_H_MIN;
37     verticalAccuracy=ACCURACY_V_MIN;
38     trackToSniffColor="#ff0000";
39     trackColor="#5bff24";
40 }
41
42
43
44 QString Settings::toString(){
45
46     return activity;
47 }
48
49 Settings& Settings::operator= (const Settings &set){
50     activity=set.activity;
51     gpsInterval=set.gpsInterval;
52     mapType=set.mapType;
53     isOnline=set.isOnline;
54     xmlFile=set.xmlFile;
55     servicesStarted=set.servicesStarted;
56
57     return(*this);
58 }
59
60 int operator== (const Settings& a, const Settings& b)
61 {
62 if (a.activity==b.activity&&a.gpsInterval==b.gpsInterval&&a.mapType==b.mapType&&a.isOnline==b.isOnline&&a.xmlFile==b.xmlFile &&a.servicesStarted==b.servicesStarted)
63     return 1;
64 else
65     return 0;
66 }
67
68 int operator!= (const Settings& a, const Settings& b)
69 {
70 if (a.activity!=b.activity||a.gpsInterval!=b.gpsInterval||a.mapType!=b.mapType||a.isOnline!=b.isOnline||a.xmlFile!=b.xmlFile || a.servicesStarted!=b.servicesStarted)
71     return 1;
72 else
73     return 0;
74 }
75
76 QDataStream& operator << (QDataStream &stream, const Settings &a)
77 {
78     QString settings = QString("Settings{latitude=%1, longitude=%2}").arg(a.activity).arg(a.gpsInterval);
79
80     stream << settings;
81     return stream;
82 }