Update CMakeLists.txt - play with openssl
[novacoin.git] / src / qt / rpcconsole.cpp
index 1738d0f..4f7c923 100644 (file)
@@ -14,6 +14,7 @@
 #include <QUrl>
 #include <QScrollBar>
 #include <QStringList>
+#include <QAbstractItemView>
 
 #include <openssl/crypto.h>
 #include <db_cxx.h>
@@ -244,6 +245,14 @@ bool RPCConsole::eventFilter(QObject* obj, QEvent *event)
                 return true;
             }
             break;
+        case Qt::Key_Return:
+        case Qt::Key_Enter:
+            // forward these events to lineEdit
+            if(obj == (QObject*)autoCompleter->popup()) {
+                QApplication::postEvent(ui->lineEdit, new QKeyEvent(*keyevt));
+                return true;
+            }
+            break;
         default:
             // Typing in messages widget brings focus to line edit, and redirects key there
             // Exclude most combinations and keys that emit no text, except paste shortcuts
@@ -254,6 +263,7 @@ bool RPCConsole::eventFilter(QObject* obj, QEvent *event)
             {
                 ui->lineEdit->setFocus();
                 QApplication::postEvent(ui->lineEdit, new QKeyEvent(*keyevt));
+                autoCompleter->popup()->hide();
                 return true;
             }
         }
@@ -290,12 +300,18 @@ void RPCConsole::setClientModel(ClientModel *model)
         for (size_t i = 0; i < commandList.size(); ++i)
         {
             wordList << commandList[i].c_str();
+            wordList << ("help " + commandList[i]).c_str();
         }
 
+        wordList.sort();
         autoCompleter = new QCompleter(wordList, this);
+        autoCompleter->setModelSorting(QCompleter::CaseSensitivelySortedModel);
+        // ui->lineEdit is initially disabled because running commands is only
+        // possible from now on.
+        ui->lineEdit->setEnabled(true);
         ui->lineEdit->setCompleter(autoCompleter);
-
-        }
+        autoCompleter->popup()->installEventFilter(this);
+    }
 }
 
 static QString categoryClass(int category)