|
From: <cn...@us...> - 2020-10-25 04:20:07
|
Revision: 1061
http://sourceforge.net/p/seq/svn/1061
Author: cn187
Date: 2020-10-25 04:20:02 +0000 (Sun, 25 Oct 2020)
Log Message:
-----------
Replace Q3Dict with QHash
Modified Paths:
--------------
showeq/branches/pre_6_0_beta/src/db3conv.cpp
showeq/branches/pre_6_0_beta/src/db3conv.h
showeq/branches/pre_6_0_beta/src/guildlist.cpp
showeq/branches/pre_6_0_beta/src/guildshell.cpp
showeq/branches/pre_6_0_beta/src/guildshell.h
showeq/branches/pre_6_0_beta/src/packetinfo.cpp
showeq/branches/pre_6_0_beta/src/packetinfo.h
showeq/branches/pre_6_0_beta/src/xmlpreferences.cpp
showeq/branches/pre_6_0_beta/src/xmlpreferences.h
Modified: showeq/branches/pre_6_0_beta/src/db3conv.cpp
===================================================================
--- showeq/branches/pre_6_0_beta/src/db3conv.cpp 2020-10-25 04:19:50 UTC (rev 1060)
+++ showeq/branches/pre_6_0_beta/src/db3conv.cpp 2020-10-25 04:20:02 UTC (rev 1061)
@@ -417,7 +417,7 @@
void DB3Convenience::Shutdown()
{
// create an iterator over the dictionary of DB's
- Q3DictIterator<Db> it(m_dbDict);
+ QHashIterator<QString, Db*> it(m_dbDict);
// attempt to get the DB from the cache
Db* db;
@@ -425,9 +425,11 @@
int ret;
// iterate over the cached databases, shutting them down 1 at a time
- while ((db = it.current()) != NULL)
+ while (it.hasNext())
{
- dbName = it.currentKey();
+ it.next();
+ db = it.value();
+ dbName = it.key();
#if 0
fprintf(stderr, "Closing database '%s', db = %08.8x\n",
Modified: showeq/branches/pre_6_0_beta/src/db3conv.h
===================================================================
--- showeq/branches/pre_6_0_beta/src/db3conv.h 2020-10-25 04:19:50 UTC (rev 1060)
+++ showeq/branches/pre_6_0_beta/src/db3conv.h 2020-10-25 04:20:02 UTC (rev 1061)
@@ -36,7 +36,7 @@
#include <db_cxx.h>
-#include <Q3Dict>
+#include <QHash>
#include <QString>
#include "dbcommon.h"
@@ -88,7 +88,7 @@
Db* GetDatabase(QString dbName);
DbEnv* m_dbEnv;
- Q3Dict<Db> m_dbDict;
+ QHash<QString, Db*> m_dbDict;
// declare friend
friend class DB3Iterator;
Modified: showeq/branches/pre_6_0_beta/src/guildlist.cpp
===================================================================
--- showeq/branches/pre_6_0_beta/src/guildlist.cpp 2020-10-25 04:19:50 UTC (rev 1060)
+++ showeq/branches/pre_6_0_beta/src/guildlist.cpp 2020-10-25 04:20:02 UTC (rev 1061)
@@ -500,8 +500,10 @@
GuildMemberDictIterator it(m_guildShell->members());
// iterate over all the members
- while ((member = it.current()))
+ while (it.hasNext())
{
+ it.next();
+ member = it.value();
// increment members on count for each member on
if (member->zoneId())
{
@@ -528,8 +530,7 @@
m_guildListItemDict.insert((void*)member, memberItem);
}
- ++it;
- }
+ }
// make sure the guild list is sorted
m_guildList->sort();
Modified: showeq/branches/pre_6_0_beta/src/guildshell.cpp
===================================================================
--- showeq/branches/pre_6_0_beta/src/guildshell.cpp 2020-10-25 04:19:50 UTC (rev 1060)
+++ showeq/branches/pre_6_0_beta/src/guildshell.cpp 2020-10-25 04:20:02 UTC (rev 1061)
@@ -177,11 +177,12 @@
m_maxNameLength(0),
m_zoneMgr(zoneMgr)
{
- m_members.setAutoDelete(true);
}
GuildShell::~GuildShell()
{
+ qDeleteAll(m_members);
+ m_members.clear();
}
QString GuildShell::zoneString(uint16_t zoneid) const
@@ -225,8 +226,11 @@
out << " Public Note" << endl;
QString zone;
- while ((member = it.current()))
+ while (it.hasNext())
{
+ it.next();
+ member = it.value();
+
dt.setTime_t(member->lastOn());
zone = zoneString(member->zoneId());
if (member->zoneInstance())
@@ -241,7 +245,6 @@
.arg(zone, -18);
out << " " << member->publicNote() << endl;
- ++it;
}
}
@@ -250,6 +253,7 @@
{
// clear out any existing member data
emit cleared();
+ qDeleteAll(m_members);
m_members.clear();
m_maxNameLength = 0;
Modified: showeq/branches/pre_6_0_beta/src/guildshell.h
===================================================================
--- showeq/branches/pre_6_0_beta/src/guildshell.h 2020-10-25 04:19:50 UTC (rev 1060)
+++ showeq/branches/pre_6_0_beta/src/guildshell.h 2020-10-25 04:20:02 UTC (rev 1061)
@@ -29,7 +29,7 @@
#include <QString>
#include <QObject>
-#include <Q3Dict>
+#include <QHash>
#include <Q3TextStream>
//----------------------------------------------------------------------
@@ -88,8 +88,8 @@
//----------------------------------------------------------------------
// GuildMemberDict
-typedef Q3Dict<GuildMember> GuildMemberDict;
-typedef Q3DictIterator<GuildMember> GuildMemberDictIterator;
+typedef QHash<QString, GuildMember*> GuildMemberDict;
+typedef QHashIterator<QString, GuildMember*> GuildMemberDictIterator;
//----------------------------------------------------------------------
// GuildShell
Modified: showeq/branches/pre_6_0_beta/src/packetinfo.cpp
===================================================================
--- showeq/branches/pre_6_0_beta/src/packetinfo.cpp 2020-10-25 04:19:50 UTC (rev 1060)
+++ showeq/branches/pre_6_0_beta/src/packetinfo.cpp 2020-10-25 04:20:02 UTC (rev 1061)
@@ -278,11 +278,13 @@
: m_opcodes(size)
{
m_opcodes.setAutoDelete(true);
- m_opcodesByName.setAutoDelete(false);
}
EQPacketOPCodeDB::~EQPacketOPCodeDB()
{
+ while(!m_opcodesByName.isEmpty()) {
+ remove(m_opcodesByName.begin().key());
+ }
}
bool EQPacketOPCodeDB::load(const EQPacketTypeDB& typeDB,
Modified: showeq/branches/pre_6_0_beta/src/packetinfo.h
===================================================================
--- showeq/branches/pre_6_0_beta/src/packetinfo.h 2020-10-25 04:19:50 UTC (rev 1060)
+++ showeq/branches/pre_6_0_beta/src/packetinfo.h 2020-10-25 04:20:02 UTC (rev 1061)
@@ -36,7 +36,6 @@
#include <Q3CString>
#include <Q3StrList>
#include <QStringList>
-#include <Q3Dict>
#include <Q3TextStream>
//----------------------------------------------------------------------
@@ -290,7 +289,7 @@
protected:
Q3IntDict<EQPacketOPCode> m_opcodes;
- Q3Dict<EQPacketOPCode> m_opcodesByName;
+ QHash<QString, EQPacketOPCode*> m_opcodesByName;
};
inline void EQPacketOPCodeDB::clear(void)
@@ -308,7 +307,7 @@
inline EQPacketOPCode* EQPacketOPCodeDB::edit(const QString& name)
{
// attempt to find the opcode object
- return m_opcodesByName.find(name);
+ return m_opcodesByName.value(name, nullptr);
}
inline const EQPacketOPCode* EQPacketOPCodeDB::find(uint16_t opcode) const
@@ -320,7 +319,7 @@
inline const EQPacketOPCode* EQPacketOPCodeDB::find(const QString& opcode) const
{
// attempt to find the opcode object
- return m_opcodesByName.find(opcode);
+ return m_opcodesByName.value(opcode, nullptr);
}
inline const Q3IntDict<EQPacketOPCode> EQPacketOPCodeDB::opcodes() const
Modified: showeq/branches/pre_6_0_beta/src/xmlpreferences.cpp
===================================================================
--- showeq/branches/pre_6_0_beta/src/xmlpreferences.cpp 2020-10-25 04:19:50 UTC (rev 1060)
+++ showeq/branches/pre_6_0_beta/src/xmlpreferences.cpp 2020-10-25 04:20:02 UTC (rev 1061)
@@ -42,8 +42,6 @@
const float seqPrefVersion = 1.0;
const char* seqPrefName = "seqpreferences";
const char* seqPrefSysId = "seqpref.dtd";
-const int sectionHashSize = 31; // must be a prime number
-const int preferenceHashSize = 31; // must be a prime number
XMLPreferences::XMLPreferences(const QString& defaultsFileName,
const QString& inFileName)
@@ -50,9 +48,9 @@
: m_defaultsFilename(defaultsFileName),
m_filename(inFileName),
m_modified(0),
- m_runtimeSections(sectionHashSize),
- m_userSections(sectionHashSize),
- m_defaultsSections(preferenceHashSize)
+ m_runtimeSections(),
+ m_userSections(),
+ m_defaultsSections()
{
m_templateDoc.sprintf("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<!DOCTYPE %s SYSTEM \"%s\">\n"
@@ -61,11 +59,6 @@
"</seqpreferences>\n",
seqPrefName, seqPrefSysId, seqPrefVersion);
- // automatically delete removed sections
- m_userSections.setAutoDelete(true);
- m_defaultsSections.setAutoDelete(true);
- m_commentSections.setAutoDelete(true);
-
// load the preferences
load();
}
@@ -72,8 +65,11 @@
XMLPreferences::~XMLPreferences()
{
+ qDeleteAll(m_userSections);
m_userSections.clear();
+ qDeleteAll(m_defaultsSections);
m_defaultsSections.clear();
+ qDeleteAll(m_commentSections);
m_commentSections.clear();
}
@@ -100,9 +96,11 @@
void XMLPreferences::revert()
{
// clear out all default preferecnes
+ qDeleteAll(m_defaultsSections);
m_defaultsSections.clear();
// clear out all user preferences
+ qDeleteAll(m_userSections);
m_userSections.clear();
// load the default preferences
@@ -165,33 +163,27 @@
sectionName = section.attribute("name");
// see if the section exists in the dictionary
- sectionDict = dict.find(sectionName);
+ sectionDict = dict.value(sectionName, nullptr);
// if not, then create it
if (sectionDict == NULL)
{
// create the new preference dictionary
- sectionDict = new PreferenceDict(preferenceHashSize);
+ sectionDict = new PreferenceDict();
- // make sure the dictionary deletes removed properties
- sectionDict->setAutoDelete(true);
-
// insert the preference dictionary into the section
dict.insert(sectionName, sectionDict);
}
// see if comment section exists in the dictionary
- commentSectionDict = m_commentSections.find(sectionName);
+ commentSectionDict = m_commentSections.value(sectionName, nullptr);
// if not, then create it
if (commentSectionDict == NULL)
{
// create the new preference dictionary
- commentSectionDict = new CommentDict(preferenceHashSize);
+ commentSectionDict = new CommentDict();
- // make sure the dictionary deletes removed properties
- commentSectionDict->setAutoDelete(true);
-
// insert the preference dictionary into the section
m_commentSections.insert(sectionName, commentSectionDict);
}
@@ -229,7 +221,7 @@
// if there is a comment, cache it
if (!comment.isEmpty())
{
- commentVal = commentSectionDict->find(propertyName);
+ commentVal = commentSectionDict->value(propertyName, nullptr);
if (commentVal != NULL)
*commentVal = comment;
@@ -337,12 +329,14 @@
sectionList = docElem.elementsByTagName("section");
- Q3DictIterator<PreferenceDict> sdit(dict);
- for (; sdit.current(); ++sdit)
+ QHashIterator<QString, PreferenceDict*> sdit(dict);
+ while (sdit.hasNext())
{
+ sdit.next();
+
QDomElement section;
- sectionName = sdit.currentKey();
- sectionDict = sdit.current();
+ sectionName = sdit.key();
+ sectionDict = sdit.value();
// iterate over all the sections in the document
for (uint i = 0; i < sectionList.length(); i++)
@@ -379,12 +373,14 @@
}
// iterate over all the properties in the section
- Q3DictIterator<QVariant> pdit(*sectionDict);
- for (; pdit.current(); ++pdit)
+ QHashIterator<QString, QVariant*> pdit(*sectionDict);
+ while (pdit.hasNext())
{
+ pdit.next();
+
QDomElement property;
- propertyName = pdit.currentKey();
- propertyValue = pdit.current();
+ propertyName = pdit.key();
+ propertyValue = pdit.value();
// get all the property elements in the section
propertyList = section.elementsByTagName("property");
@@ -501,12 +497,12 @@
if (pers & Runtime)
{
// see if the section exists in the dictionary
- sectionDict = m_runtimeSections.find(inSection);
+ sectionDict = m_runtimeSections.value(inSection, nullptr);
// if so, then see if the preference exists
if (sectionDict != NULL)
{
- preference = sectionDict->find(inName);
+ preference = sectionDict->value(inName, nullptr);
if (preference != NULL)
return preference;
}
@@ -515,12 +511,12 @@
if (pers & User)
{
// see if the section exists in the dictionary
- sectionDict = m_userSections.find(inSection);
+ sectionDict = m_userSections.value(inSection, nullptr);
// if so, then see if the preference exists
if (sectionDict != NULL)
{
- preference = sectionDict->find(inName);
+ preference = sectionDict->value(inName, nullptr);
if (preference != NULL)
return preference;
}
@@ -529,12 +525,12 @@
if (pers & Defaults)
{
// see if the section exists in the defaults dictionary
- sectionDict = m_defaultsSections.find(inSection);
+ sectionDict = m_defaultsSections.value(inSection, nullptr);
// if so, then see if the preferences exists
if (sectionDict != NULL)
{
- preference = sectionDict->find(inName);
+ preference = sectionDict->value(inName, nullptr);
if (preference != NULL)
return preference;
}
@@ -565,22 +561,19 @@
QVariant* preference;
// see if the section exists in the dictionary
- sectionDict = dict.find(inSection);
+ sectionDict = dict.value(inSection, nullptr);
// if not, then create it
if (sectionDict == NULL)
{
// create the new preference dictionary
- sectionDict = new PreferenceDict(preferenceHashSize);
+ sectionDict = new PreferenceDict();
- // make sure the dictionary deletes removed properties
- sectionDict->setAutoDelete(true);
-
// insert the preference dictionary into the section
dict.insert(inSection, sectionDict);
}
- preference = sectionDict->find(inName);
+ preference = sectionDict->value(inName, nullptr);
// if preference exists, change it, otherwise create it
if (preference != NULL)
@@ -594,12 +587,12 @@
CommentDict* commentSectionDict;
// see if comment section exists in the dictionary
- commentSectionDict = m_commentSections.find(inSection);
+ commentSectionDict = m_commentSections.value(inSection, nullptr);
if (commentSectionDict == NULL)
return QString("");
- QString* comment = commentSectionDict->find(inName);
+ QString* comment = commentSectionDict->value(inName, nullptr);
if (comment != NULL)
return *comment;
@@ -615,7 +608,7 @@
if (pers & Runtime)
{
// see if the section exists in the dictionary
- sectionDict = m_runtimeSections.find(inSection);
+ sectionDict = m_runtimeSections.value(inSection, nullptr);
// if so, then see if the preference exists
if (sectionDict != NULL)
@@ -625,7 +618,7 @@
if (pers & User)
{
// see if the section exists in the dictionary
- sectionDict = m_userSections.find(inSection);
+ sectionDict = m_userSections.value(inSection, nullptr);
// if so, then see if the preference exists
if (sectionDict != NULL)
@@ -635,7 +628,7 @@
if (pers & Defaults)
{
// see if the section exists in the defaults dictionary
- sectionDict = m_defaultsSections.find(inSection);
+ sectionDict = m_defaultsSections.value(inSection, nullptr);
// if so, then see if the preferences exists
if (sectionDict != NULL)
Modified: showeq/branches/pre_6_0_beta/src/xmlpreferences.h
===================================================================
--- showeq/branches/pre_6_0_beta/src/xmlpreferences.h 2020-10-25 04:19:50 UTC (rev 1060)
+++ showeq/branches/pre_6_0_beta/src/xmlpreferences.h 2020-10-25 04:20:02 UTC (rev 1061)
@@ -37,7 +37,7 @@
#include <QObject>
#include <QString>
#include <QVariant>
-#include <Q3Dict>
+#include <QHash>
#include <QColor>
#include <QPen>
#include <QBrush>
@@ -61,11 +61,11 @@
// TRUE value overrides this. This is usefull for command line args
// which should override config file prefs but not overwrite them
-typedef Q3Dict<QVariant> PreferenceDict;
-typedef Q3Dict<PreferenceDict> PrefSectionDict;
+typedef QHash<QString, QVariant*> PreferenceDict;
+typedef QHash<QString, PreferenceDict*> PrefSectionDict;
-typedef Q3Dict<QString> CommentDict;
-typedef Q3Dict<CommentDict> CommentSectionDict;
+typedef QHash<QString, QString*> CommentDict;
+typedef QHash<QString, CommentDict*> CommentSectionDict;
// PreferenceFile
// A File comprised of NameValuePair Items
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|