+ don't suggest ignored nicknames
authorsheepluva
Tue, 18 Oct 2011 15:34:40 +0200
changeset 6149 0b92341adb6a
parent 6148 726daa066fea
child 6150 1d98752c1fba
+ don't suggest ignored nicknames * whipe data properly when lobby is left
QTfrontend/ui/widget/SmartLineEdit.cpp
QTfrontend/ui/widget/SmartLineEdit.h
QTfrontend/ui/widget/chatwidget.cpp
--- a/QTfrontend/ui/widget/SmartLineEdit.cpp	Tue Oct 18 09:09:49 2011 -0400
+++ b/QTfrontend/ui/widget/SmartLineEdit.cpp	Tue Oct 18 15:34:40 2011 +0200
@@ -29,11 +29,13 @@
     m_cmds  = new QStringList();
     m_nicks = new QStringList();
 
-    reset();
+    resetAutoCompletionStatus();
 
-    // reset when cursor is moved or content is changed
-    connect(this, SIGNAL(cursorPositionChanged(int, int)), this, SLOT(reset()));
-    connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(reset()));
+    // reset autocompletion status when cursor is moved or content is changed
+    connect(this, SIGNAL(cursorPositionChanged(int, int)),
+            this, SLOT(resetAutoCompletionStatus()));
+    connect(this, SIGNAL(textChanged(const QString&)),
+            this, SLOT(resetAutoCompletionStatus()));
 }
 
 
@@ -79,6 +81,18 @@
     m_mutex.unlock();
 }
 
+void SmartLineEdit::forgetEverything()
+{
+    m_mutex.lock();
+
+    m_cmds->clear();
+    m_nicks->clear();
+
+    m_mutex.unlock();
+
+    resetAutoCompletionStatus();
+}
+
 bool SmartLineEdit::event(QEvent * event)
 {
     // we only want special treatment for key press events
@@ -237,7 +251,7 @@
     }
 }
 
-void SmartLineEdit::reset()
+void SmartLineEdit::resetAutoCompletionStatus()
 {
     m_beforeMatch = "";
     m_hasJustMatched = false;
--- a/QTfrontend/ui/widget/SmartLineEdit.h	Tue Oct 18 09:09:49 2011 -0400
+++ b/QTfrontend/ui/widget/SmartLineEdit.h	Tue Oct 18 15:34:40 2011 +0200
@@ -75,6 +75,11 @@
      */
     void removeNickname(const QString & nickname);
 
+    /**
+     * Forget all keywords and input history.
+     */
+    void forgetEverything();
+
 
 protected:
     /**
@@ -114,14 +119,16 @@
     QMutex m_mutex; // make all the QStringList action thread-safe
 
     /**
-     * Autocompletes the contents based on the known commands and/or names
+     * Autocompletes the contents based on the known commands and/or names.
      */
     void autoComplete();
 
 
 private slots:
-    // resets the information about the last match and text replacement
-    void reset();
+    /**
+     * Resets the information about the last match and text replacement.
+     */
+    void resetAutoCompletionStatus();
 };
 
 
--- a/QTfrontend/ui/widget/chatwidget.cpp	Tue Oct 18 09:09:49 2011 -0400
+++ b/QTfrontend/ui/widget/chatwidget.cpp	Tue Oct 18 15:34:40 2011 +0200
@@ -414,12 +414,14 @@
 
 void HWChatWidget::nickAdded(const QString& nick, bool notifyNick)
 {
-    chatEditLine->addNickname(nick);
-
-    QListWidgetItem * item = new ListWidgetNickItem(nick, friendsList.contains(nick, Qt::CaseInsensitive), ignoreList.contains(nick, Qt::CaseInsensitive));
+    bool isIgnored = ignoreList.contains(nick, Qt::CaseInsensitive);
+    QListWidgetItem * item = new ListWidgetNickItem(nick, friendsList.contains(nick, Qt::CaseInsensitive), isIgnored);
     updateNickItem(item);
     chatNicks->addItem(item);
 
+    if (!isIgnored)
+        chatEditLine->addNickname(nick);
+
     emit nickCountUpdate(chatNicks->count());
 
     if(notifyNick && notify && gameSettings->value("frontend/sound", true).toBool()) {
@@ -439,6 +441,7 @@
 
 void HWChatWidget::clear()
 {
+    chatEditLine->forgetEverything();
     chatText->clear();
     chatStrings.clear();
     chatNicks->clear();
@@ -481,6 +484,7 @@
     if(ignoreList.contains(curritem->text(), Qt::CaseInsensitive)) // already on list - remove him
     {
         ignoreList.removeAll(curritem->text().toLower());
+        chatEditLine->addNickname(curritem->text());
         onChatString(HWChatWidget::tr("%1 *** %2 has been removed from your ignore list").arg('\x03').arg(curritem->text()));
     }
     else // not on list - add
@@ -494,6 +498,7 @@
             chatNicks->scrollToBottom();
 
         ignoreList << curritem->text().toLower();
+        chatEditLine->removeNickname(curritem->text());
         onChatString(HWChatWidget::tr("%1 *** %2 has been added to your ignore list").arg('\x03').arg(curritem->text()));
     }
     updateNickItem(curritem); // update icon/sort order/etc