File indexing completed on 2024-09-01 13:34:00
0001 // 0002 // C++ Implementation: cgenericlist 0003 // 0004 // Description: A generic list that can only store data. 0005 // 0006 /* 0007 Copyright 2008-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 "cgenericlist.h" 0024 0025 #include "cgenericitem.h" 0026 0027 #include <QFile> 0028 #include <QXmlStreamWriter> 0029 #include <QDebug> 0030 0031 cGenericList::cGenericList () : 0032 cList ("generic") 0033 { 0034 } 0035 0036 cGenericList::~cGenericList () 0037 { 0038 } 0039 0040 0041 cListObject *cGenericList::newObject () 0042 { 0043 return new cGenericItem (this); 0044 } 0045 0046 void cGenericList::init () 0047 { 0048 initRootGroup (); 0049 } 0050 0051 bool cGenericList::saveList (const QString &file) 0052 { 0053 // save the list contents 0054 QFile f (file); 0055 if (!f.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) { 0056 qDebug() << "Unable to open " << file << " for writing."; 0057 return false; // problem 0058 } 0059 0060 QXmlStreamWriter *writer = new QXmlStreamWriter (&f); 0061 save (writer); 0062 0063 f.close (); 0064 delete writer; 0065 return true; 0066 } 0067 0068 void cGenericList::intProperty (const QString &name, int defaultValue) 0069 { 0070 addIntProperty (name, QString(), defaultValue); 0071 } 0072 0073 void cGenericList::stringProperty (const QString &name, QString defaultValue) 0074 { 0075 addStringProperty (name, QString(), defaultValue); 0076 } 0077 0078 void cGenericList::boolProperty (const QString &name, bool defaultValue) 0079 { 0080 addBoolProperty (name, QString(), defaultValue); 0081 } 0082 0083 0084