F:/KPlato/koffice/kplato/kptconfig.cc

Aller à la documentation de ce fichier.
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 #include <kinstance.h>
00027 
00028 namespace KPlato
00029 {
00030 
00031 Config::Config()
00032 {
00033     m_readWrite = true;
00034 }
00035 
00036 Config::~Config()
00037 {
00038 }
00039 
00040 void Config::load() {
00041     //kDebug()<<k_funcinfo<<endl;
00042     KConfig *config = Factory::global()->config();
00043 
00044 /*    if( config->hasGroup("Behavior"))
00045     {
00046         config->setGroup("Behavior");
00047         m_behavior.calculationMode = config->readEntry("CalculationMode",m_behavior.calculationMode);
00048         m_behavior.allowOverbooking =  config->readEntry("AllowOverbooking",m_behavior.allowOverbooking);
00049     }*/
00050     if( config->hasGroup("Task defaults"))
00051     {
00052         config->setGroup("Task defaults");
00053         m_taskDefaults.setLeader(config->readEntry("Leader"));
00054         m_taskDefaults.setDescription(config->readEntry("Description"));
00055         m_taskDefaults.setConstraint((Node::ConstraintType)config->readEntry("ConstraintType",0));
00056         m_taskDefaults.setConstraintStartTime(config->readEntry("ConstraintStartTime",QDateTime()));
00057         m_taskDefaults.setConstraintEndTime(config->readEntry("ConstraintEndTime",QDateTime()));
00058         m_taskDefaults.effort()->setType((Effort::Type)config->readEntry("EffortType",0));
00059         m_taskDefaults.effort()->set(Duration((qint64)config->readEntry("ExpectedEffort",0)));
00060         m_taskDefaults.effort()->setPessimisticRatio(config->readEntry("PessimisticEffort",0));
00061         m_taskDefaults.effort()->setOptimisticRatio(config->readEntry("OptimisticEffort",0));
00062     }
00063 }
00064 
00065 void Config::save() {
00066     //kDebug()<<k_funcinfo<<m_readWrite<<endl;
00067     if (!m_readWrite)
00068         return;
00069 
00070     KConfig *config = Factory::global()->config();
00071 
00072 //     config->setGroup( "Behavior" );
00073 //     config->writeEntry("CalculationMode",m_behavior.calculationMode);
00074 //     config->writeEntry("AllowOverbooking",m_behavior.allowOverbooking);
00075 
00076     config->setGroup("Task defaults");
00077     config->writeEntry("Leader", m_taskDefaults.leader());
00078     config->writeEntry("Description", m_taskDefaults.description());
00079     config->writeEntry("ConstraintType", (int)m_taskDefaults.constraint());
00080     config->writeEntry("ConstraintStartTime", (QDateTime)m_taskDefaults.constraintStartTime());
00081     config->writeEntry("ConstraintEndTime", (QDateTime)m_taskDefaults.constraintEndTime());
00082     config->writeEntry("EffortType", (int)m_taskDefaults.effort()->type());
00083     config->writeEntry("ExpectedEffort", m_taskDefaults.effort()->expected().seconds()); //FIXME
00084     config->writeEntry("PessimisticEffort", m_taskDefaults.effort()->pessimisticRatio());
00085     config->writeEntry("OptimisticEffort", m_taskDefaults.effort()->optimisticRatio());
00086 }
00087 
00088 }  //KPlato namespace

Généré le Wed Nov 22 23:40:56 2006 pour KPlato par  doxygen 1.5.1-p1