kplato

kptconfig.cc

00001 /* This file is part of the KDE project
00002    Copyright (C) 2004 Dag Andersen <danders@get2net.dk>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation;
00007    version 2 of the License.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #include "kptconfig.h"
00021 
00022 #include "kptfactory.h"
00023 
00024 #include <kconfig.h>
00025 #include <kdebug.h>
00026 
00027 namespace KPlato
00028 {
00029 
00030 Config::Config()
00031 {
00032     m_readWrite = true;
00033 }
00034 
00035 Config::~Config()
00036 {
00037 }
00038 
00039 void Config::load() {
00040     //kdDebug()<<k_funcinfo<<endl;
00041     KConfig *config = Factory::global()->config();
00042     
00043 /*    if( config->hasGroup("Behavior"))
00044     {
00045         config->setGroup("Behavior");
00046         m_behavior.calculationMode = config->readNumEntry("CalculationMode",m_behavior.calculationMode);
00047         m_behavior.allowOverbooking =  config->readBoolEntry("AllowOverbooking",m_behavior.allowOverbooking);
00048     }*/
00049     if( config->hasGroup("Task defaults"))
00050     {
00051         config->setGroup("Task defaults");
00052         m_taskDefaults.setLeader(config->readEntry("Leader"));
00053         m_taskDefaults.setDescription(config->readEntry("Description"));
00054         m_taskDefaults.setConstraint((Node::ConstraintType)config->readNumEntry("ConstraintType"));
00055         m_taskDefaults.setConstraintStartTime(config->readDateTimeEntry("ConstraintStartTime"));
00056         m_taskDefaults.setConstraintEndTime(config->readDateTimeEntry("ConstraintEndTime"));
00057         m_taskDefaults.effort()->setType((Effort::Type)config->readNumEntry("EffortType"));
00058         m_taskDefaults.effort()->set(Duration((Q_INT64)config->readNumEntry("ExpectedEffort")));
00059         m_taskDefaults.effort()->setPessimisticRatio(config->readNumEntry("PessimisticEffort"));
00060         m_taskDefaults.effort()->setOptimisticRatio(config->readNumEntry("OptimisticEffort"));
00061     }
00062 }
00063 
00064 void Config::save() {
00065     //kdDebug()<<k_funcinfo<<m_readWrite<<endl;
00066     if (!m_readWrite)
00067         return;
00068         
00069     KConfig *config = Factory::global()->config();
00070     
00071 //     config->setGroup( "Behavior" );
00072 //     config->writeEntry("CalculationMode",m_behavior.calculationMode);
00073 //     config->writeEntry("AllowOverbooking",m_behavior.allowOverbooking);
00074 
00075     config->setGroup("Task defaults");
00076     config->writeEntry("Leader", m_taskDefaults.leader());
00077     config->writeEntry("Description", m_taskDefaults.description());
00078     config->writeEntry("ConstraintType", m_taskDefaults.constraint());
00079     config->writeEntry("ConstraintStartTime", m_taskDefaults.constraintStartTime());
00080     config->writeEntry("ConstraintEndTime", m_taskDefaults.constraintEndTime());
00081     config->writeEntry("EffortType", m_taskDefaults.effort()->type());
00082     config->writeEntry("ExpectedEffort", m_taskDefaults.effort()->expected().seconds()); //FIXME
00083     config->writeEntry("PessimisticEffort", m_taskDefaults.effort()->pessimisticRatio());
00084     config->writeEntry("OptimisticEffort", m_taskDefaults.effort()->optimisticRatio());
00085 }
00086 
00087 }  //KPlato namespace
KDE Home | KDE Accessibility Home | Description of Access Keys