# HG changeset patch # User sheepluva # Date 1319308883 -7200 # Node ID 59ff93c0ae2d30c8f9708195f004970c22fc0799 # Parent 255aff92216d2c2a10266ac885c02676504b5ba2 * adding destructors to my line edit subclasses + case-insensitive sorting for suggested nicknames diff -r 255aff92216d -r 59ff93c0ae2d QTfrontend/ui/widget/HistoryLineEdit.cpp --- a/QTfrontend/ui/widget/HistoryLineEdit.cpp Sat Oct 22 19:37:39 2011 +0200 +++ b/QTfrontend/ui/widget/HistoryLineEdit.cpp Sat Oct 22 20:41:23 2011 +0200 @@ -35,6 +35,12 @@ } +HistoryLineEdit::~HistoryLineEdit() +{ + delete m_history; +} + + void HistoryLineEdit::rememberCurrentText() { m_historyMutex.lock(); diff -r 255aff92216d -r 59ff93c0ae2d QTfrontend/ui/widget/HistoryLineEdit.h --- a/QTfrontend/ui/widget/HistoryLineEdit.h Sat Oct 22 19:37:39 2011 +0200 +++ b/QTfrontend/ui/widget/HistoryLineEdit.h Sat Oct 22 20:41:23 2011 +0200 @@ -25,8 +25,10 @@ #ifndef HEDGEWARS_HISTORYLINEEDIT #define HEDGEWARS_HISTORYLINEEDIT +#include +#include + #include -#include #include @@ -56,6 +58,11 @@ HistoryLineEdit(QWidget * parent = 0, int maxHistorySize = 64); /** + * @brief Class destructor. + */ + ~HistoryLineEdit(); + + /** * @brief Appends current text to history (if not only whitespaces); */ void rememberCurrentText(); diff -r 255aff92216d -r 59ff93c0ae2d QTfrontend/ui/widget/SmartLineEdit.cpp --- a/QTfrontend/ui/widget/SmartLineEdit.cpp Sat Oct 22 19:37:39 2011 +0200 +++ b/QTfrontend/ui/widget/SmartLineEdit.cpp Sat Oct 22 20:41:23 2011 +0200 @@ -31,6 +31,7 @@ m_cmds = new QStringList(); m_nicks = new QStringList(); + m_sorted_nicks = new QMap(); resetAutoCompletionStatus(); @@ -42,6 +43,14 @@ } +SmartLineEdit::~SmartLineEdit() +{ + delete m_cmds; + delete m_nicks; + delete m_sorted_nicks; +} + + void SmartLineEdit::addCommands(const QStringList & commands) { m_keywordMutex.lock(); @@ -69,6 +78,7 @@ { m_keywordMutex.lock(); + m_sorted_nicks->insert(name.toLower(), name); m_nicks->append(name); m_keywordMutex.unlock(); @@ -79,6 +89,7 @@ { m_keywordMutex.lock(); + m_sorted_nicks->remove(name.toLower()); m_nicks->removeAll(name); m_keywordMutex.unlock(); @@ -91,6 +102,7 @@ m_keywordMutex.lock(); m_cmds->clear(); + m_sorted_nicks->clear(); m_nicks->clear(); resetAutoCompletionStatus(); @@ -163,7 +175,7 @@ { m_keywordMutex.lock(); m_cmds->sort(); - m_nicks->sort(); + m_nicks = new QStringList(m_sorted_nicks->values()); m_keywordMutex.unlock(); int cp = cursorPosition(); diff -r 255aff92216d -r 59ff93c0ae2d QTfrontend/ui/widget/SmartLineEdit.h --- a/QTfrontend/ui/widget/SmartLineEdit.h Sat Oct 22 19:37:39 2011 +0200 +++ b/QTfrontend/ui/widget/SmartLineEdit.h Sat Oct 22 20:41:23 2011 +0200 @@ -25,9 +25,13 @@ #ifndef HEDGEWARS_SMARTLINEEDIT_H #define HEDGEWARS_SMARTLINEEDIT_H +#include +#include #include #include +#include + #include #include "HistoryLineEdit.h" @@ -59,6 +63,11 @@ SmartLineEdit(QWidget * parent = 0, int maxHistorySize = 64); /** + * @brief Class destructor. + */ + ~SmartLineEdit(); + + /** * @brief Adds commands to the auto-completion feature. * @param commands list of commands to be added. */ @@ -116,6 +125,8 @@ QStringList * m_cmds; ///< list of recognized commands QStringList * m_nicks; ///< list of recognized nicknames + /// list of recognized commands, sorted case-insensitive + QMap * m_sorted_nicks; // these variables contain information about the last replacement // they get reset whenever cursor is moved or text is changed