File indexing completed on 2024-04-21 04:03:03

0001 /***************************************************************************
0002                           ctimer.cpp  -  description
0003                              -------------------
0004     begin                : St maj 8 2003
0005     copyright            : (C) 2003 by Tomas Mecir
0006     email                : kmuddy@kmuddy.com
0007  ***************************************************************************/
0008 
0009 /***************************************************************************
0010  *                                                                         *
0011  *   This program is free software; you can redistribute it and/or modify  *
0012  *   it under the terms of the GNU General Public License as published by  *
0013  *   the Free Software Foundation; either version 2 of the License, or     *
0014  *   (at your option) any later version.                                   *
0015  *                                                                         *
0016  ***************************************************************************/
0017 
0018 #include "ctimer.h"
0019 
0020 #include "cactionmanager.h"
0021 
0022 #include <kconfig.h>
0023 #include <kconfiggroup.h>
0024 
0025 cTimer::cTimer (int _sess) : sess(_sess)
0026 {
0027   _interval = 60;
0028   _singleshot = false;
0029   _active = false;
0030   _command = QString();
0031 
0032 }
0033 
0034 cTimer::~cTimer ()
0035 {
0036 
0037 }
0038 
0039 cSaveableField *cTimer::newInstance ()
0040 {
0041   return new cTimer (sess);
0042 }
0043 
0044 void cTimer::load (KConfig *config, const QString &group)
0045 {
0046   KConfigGroup g = config->group (group);
0047 
0048   setInterval (g.readEntry ("Interval", 60));
0049   setSingleShot (g.readEntry ("Single shot", false));
0050   setActive (g.readEntry ("Active", false));
0051   setCommand (g.readEntry ("Command", QString()));
0052 }
0053 
0054 void cTimer::setInterval (int what)
0055 {
0056   if (what >= 1)  //only positive intervals are allowed
0057     _interval = what;
0058 }
0059