File indexing completed on 2024-12-01 06:51:39
0001 // 0002 // C++ Implementation: cstatusvar 0003 // 0004 // Description: One variable entry in the status bar 0005 // 0006 /* 0007 Copyright 2004-2011 Tomas Mecir <kmuddy@kmuddy.com> 0008 0009 This program is free software; you can redistribute it and/or 0010 modify it under the terms of the GNU General Public License as 0011 published by the Free Software Foundation; either version 2 of 0012 the License, or (at your option) any later version. 0013 0014 This program is distributed in the hope that it will be useful, 0015 but WITHOUT ANY WARRANTY; without even the implied warranty of 0016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0017 GNU General Public License for more details. 0018 0019 You should have received a copy of the GNU General Public License 0020 along with this program. If not, see <http://www.gnu.org/licenses/>. 0021 */ 0022 0023 #include "cstatusvar.h" 0024 0025 #include <kconfig.h> 0026 #include <kconfiggroup.h> 0027 0028 cStatusVar::cStatusVar (int _sess): sess(_sess) 0029 { 0030 varvalue = maxvarvalue = 0; 0031 _hidden = false; 0032 _percentage = false; 0033 } 0034 0035 cStatusVar::~cStatusVar() 0036 { 0037 } 0038 0039 cSaveableField *cStatusVar::newInstance () 0040 { 0041 return new cStatusVar (sess); 0042 } 0043 0044 void cStatusVar::setVariable (const QString &val) 0045 { 0046 _variable = val; 0047 if (!_variable.isEmpty() && _variable[0] == '$') 0048 _variable = _variable.remove (0, 1); 0049 varvalue = 0; 0050 } 0051 0052 void cStatusVar::setMaxVariable (const QString &val) 0053 { 0054 _maxvariable = val; 0055 if (!_maxvariable.isEmpty() && _maxvariable[0] == '$') 0056 _maxvariable = _variable.remove (0, 1); 0057 } 0058 0059 void cStatusVar::setCaption (const QString &val) 0060 { 0061 _caption = val; 0062 } 0063 0064 void cStatusVar::setPercentage (bool percent) 0065 { 0066 _percentage = percent; 0067 } 0068 0069 void cStatusVar::setHidden (bool h) 0070 { 0071 _hidden = h; 0072 } 0073 0074 void cStatusVar::load (KConfig *config, const QString &group) 0075 { 0076 KConfigGroup g = config->group (group); 0077 0078 setVariable (g.readEntry ("Variable", QString())); 0079 setMaxVariable (g.readEntry ("Max variable", QString())); 0080 setCaption (g.readEntry ("Caption", QString())); 0081 setPercentage (g.readEntry ("Percentage", false)); 0082 setHidden (g.readEntry ("Hidden", false)); 0083 } 0084