From: Carsten Niehaus Date: Thu, 19 Oct 2006 17:09:45 +0000 (+0000) Subject: * Remove strange code and Qt4-ify it X-Git-Tag: v3.80.2~6 X-Git-Url: https://git.rmz.fi/?a=commitdiff_plain;h=5d45557411bf63e26f4c3d41e51fbdcf1c0b3baf;p=libqmvoc.git * Remove strange code and Qt4-ify it * One leak less (in the parser) * one more qDebugAll svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=597227 --- diff --git a/kdeeduui/kdeeduglossary.cpp b/kdeeduui/kdeeduglossary.cpp index 952a06f..0b991fa 100644 --- a/kdeeduui/kdeeduglossary.cpp +++ b/kdeeduui/kdeeduglossary.cpp @@ -44,10 +44,7 @@ Glossary::Glossary() Glossary::~Glossary() { - foreach ( GlossaryItem * item, m_itemlist ) { - delete item; - item = 0; - } + qDeleteAll(m_itemlist); } void Glossary::init( const KUrl& url, const QString& path ) diff --git a/libscience/moleculeparser.cpp b/libscience/moleculeparser.cpp index 614cbb8..f565763 100644 --- a/libscience/moleculeparser.cpp +++ b/libscience/moleculeparser.cpp @@ -87,11 +87,9 @@ ElementCountMap::add(Element *_element, int _count) void ElementCountMap::multiply(int _factor) { - Iterator it = begin(); - Iterator itEnd = end(); - - for (; it != itEnd; ++it) - (*it)->multiply(_factor); + foreach (ElementCount * count, m_map) { + count->multiply(_factor); + } } @@ -114,7 +112,7 @@ MoleculeParser::MoleculeParser(const QString& _str) MoleculeParser::~MoleculeParser() { - //Parser::~Parser(); + qDeleteAll(m_elementList); } diff --git a/libscience/moleculeparser.h b/libscience/moleculeparser.h index 3b39a21..2f07e3b 100644 --- a/libscience/moleculeparser.h +++ b/libscience/moleculeparser.h @@ -104,7 +104,9 @@ class EDUSCIENCE_EXPORT ElementCountMap /** * Clear the map of ElementCount pointers */ - void clear() { m_map.clear(); } + void clear(){ + m_map.clear(); + } /** * @param _element the searched Element @@ -135,20 +137,9 @@ class EDUSCIENCE_EXPORT ElementCountMap */ void multiply(int _factor); - /** - * typedef - */ - typedef QList::Iterator Iterator; - - /** - * - */ - Iterator begin() { return m_map.begin(); } - - /** - * - */ - Iterator end() { return m_map.end(); } + QList map(){ + return m_map; + } private: QList m_map;