QTfrontend/ui/widget/SmartLineEdit.cpp
changeset 6187 59ff93c0ae2d
parent 6170 2b1748161278
child 6197 4ce7c29799b9
--- 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<QString, QString>();
 
     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();