/*************************************************************************** knutupsdata.cpp - description ------------------- begin : Tue Aug 21 2001 copyright : (C) 2001 by Daniel Prynych email : Daniel.Prynych@alo.cz ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "knutupsdata.h" #include "knutvardata.h" #include KNutUpsData::KNutUpsData() { // vytvori seznam UPS listRecords.clear(); countMembers = 0; } KNutUpsData::~KNutUpsData() { listRecords.clear(); } void KNutUpsData::add (const upsRecord upsMember) { // vlozime ups na konec countMembers++; listRecords.append(upsMember); } void KNutUpsData::put (const int index, const upsRecord upsMember ) { if ((index > -1 ) && (index < countMembers)) { listRecords[index] = (upsMember); } } void KNutUpsData::get (const int index, upsRecord& upsMember ) { if ((index > -1 ) && (index < countMembers)) upsMember=listRecords[index]; } QString KNutUpsData::getName (const int index) { if ((index > -1 ) && (index < countMembers)) return listRecords[index].name; else return 0L; } void KNutUpsData::deleteName (const int index) { if ((index > -1 ) && (index < countMembers)) { QValueList::Iterator it = listRecords.begin(); for (int i =0; i < index; i++) it++; listRecords.remove(it); countMembers--; } } int KNutUpsData::getCount ( void ) { return countMembers; } upsRecord* KNutUpsData::findName (const QString name) { QValueList::Iterator it; for (it = listRecords.begin(); it != listRecords.end(); it++) { if ((*it).name == name) { return &(*it); // vratime adresu } } return 0l; }