kplato

kptconfig.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2004 Dag Andersen <danders@get2net.dk>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation;
7 version 2 of the License.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#include "kptconfig.h"
21
22#include "kptfactory.h"
23
24#include <tdeconfig.h>
25#include <kdebug.h>
26
27namespace KPlato
28{
29
30Config::Config()
31{
32 m_readWrite = true;
33}
34
35Config::~Config()
36{
37}
38
39void Config::load() {
40 //kdDebug()<<k_funcinfo<<endl;
41 TDEConfig *config = Factory::global()->config();
42
43/* if( config->hasGroup("Behavior"))
44 {
45 config->setGroup("Behavior");
46 m_behavior.calculationMode = config->readNumEntry("CalculationMode",m_behavior.calculationMode);
47 m_behavior.allowOverbooking = config->readBoolEntry("AllowOverbooking",m_behavior.allowOverbooking);
48 }*/
49 if( config->hasGroup("Task defaults"))
50 {
51 config->setGroup("Task defaults");
52 m_taskDefaults.setLeader(config->readEntry("Leader"));
53 m_taskDefaults.setDescription(config->readEntry("Description"));
54 m_taskDefaults.setConstraint((Node::ConstraintType)config->readNumEntry("ConstraintType"));
55 m_taskDefaults.setConstraintStartTime(config->readDateTimeEntry("ConstraintStartTime"));
56 m_taskDefaults.setConstraintEndTime(config->readDateTimeEntry("ConstraintEndTime"));
57 m_taskDefaults.effort()->setType((Effort::Type)config->readNumEntry("EffortType"));
58 m_taskDefaults.effort()->set(Duration((TQ_INT64)config->readNumEntry("ExpectedEffort")));
59 m_taskDefaults.effort()->setPessimisticRatio(config->readNumEntry("PessimisticEffort"));
60 m_taskDefaults.effort()->setOptimisticRatio(config->readNumEntry("OptimisticEffort"));
61 }
62}
63
64void Config::save() {
65 //kdDebug()<<k_funcinfo<<m_readWrite<<endl;
66 if (!m_readWrite)
67 return;
68
69 TDEConfig *config = Factory::global()->config();
70
71// config->setGroup( "Behavior" );
72// config->writeEntry("CalculationMode",m_behavior.calculationMode);
73// config->writeEntry("AllowOverbooking",m_behavior.allowOverbooking);
74
75 config->setGroup("Task defaults");
76 config->writeEntry("Leader", m_taskDefaults.leader());
77 config->writeEntry("Description", m_taskDefaults.description());
78 config->writeEntry("ConstraintType", m_taskDefaults.constraint());
79 config->writeEntry("ConstraintStartTime", m_taskDefaults.constraintStartTime());
80 config->writeEntry("ConstraintEndTime", m_taskDefaults.constraintEndTime());
81 config->writeEntry("EffortType", m_taskDefaults.effort()->type());
82 config->writeEntry("ExpectedEffort", m_taskDefaults.effort()->expected().seconds()); //FIXME
83 config->writeEntry("PessimisticEffort", m_taskDefaults.effort()->pessimisticRatio());
84 config->writeEntry("OptimisticEffort", m_taskDefaults.effort()->optimisticRatio());
85}
86
87} //KPlato namespace