Add autocomplete to bitcoin-qt's console window.
Removed externs Added listCommands() to CRPCTable Move autocomplete init to RPCConsole::setClientModel() Closes #742
This commit is contained in:
parent
eaf57b3fb7
commit
4ce2b0214b
@ -33,6 +33,7 @@
|
||||
#include <QThread>
|
||||
#include <QTime>
|
||||
#include <QTimer>
|
||||
#include <QStringList>
|
||||
|
||||
#if QT_VERSION < 0x050000
|
||||
#include <QUrl>
|
||||
@ -461,6 +462,18 @@ void RPCConsole::setClientModel(ClientModel *model)
|
||||
ui->buildDate->setText(model->formatBuildDate());
|
||||
ui->startupTime->setText(model->formatClientStartupTime());
|
||||
ui->networkName->setText(QString::fromStdString(Params().NetworkIDString()));
|
||||
|
||||
//Setup autocomplete and attach it
|
||||
QStringList wordList;
|
||||
std::vector<std::string> commandList = tableRPC.listCommands();
|
||||
for (size_t i = 0; i < commandList.size(); ++i)
|
||||
{
|
||||
wordList << commandList[i].c_str();
|
||||
}
|
||||
|
||||
autoCompleter = new QCompleter(wordList, this);
|
||||
ui->lineEdit->setCompleter(autoCompleter);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "net.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QCompleter>
|
||||
|
||||
class ClientModel;
|
||||
class PlatformStyle;
|
||||
@ -150,6 +151,7 @@ private:
|
||||
RPCTimerInterface *rpcTimerInterface;
|
||||
QMenu *peersTableContextMenu;
|
||||
QMenu *banTableContextMenu;
|
||||
QCompleter *autoCompleter;
|
||||
};
|
||||
|
||||
#endif // BITCOIN_QT_RPCCONSOLE_H
|
||||
|
@ -554,6 +554,17 @@ UniValue CRPCTable::execute(const std::string &strMethod, const UniValue ¶ms
|
||||
g_rpcSignals.PostCommand(*pcmd);
|
||||
}
|
||||
|
||||
std::vector<std::string> CRPCTable::listCommands() const
|
||||
{
|
||||
std::vector<std::string> commandList;
|
||||
typedef std::map<std::string, const CRPCCommand*> commandMap;
|
||||
|
||||
std::transform( mapCommands.begin(), mapCommands.end(),
|
||||
std::back_inserter(commandList),
|
||||
boost::bind(&commandMap::value_type::first,_1) );
|
||||
return commandList;
|
||||
}
|
||||
|
||||
std::string HelpExampleCli(const std::string& methodname, const std::string& args)
|
||||
{
|
||||
return "> dash-cli " + methodname + " " + args + "\n";
|
||||
|
@ -142,6 +142,12 @@ public:
|
||||
* @throws an exception (UniValue) when an error happens.
|
||||
*/
|
||||
UniValue execute(const std::string &method, const UniValue ¶ms) const;
|
||||
|
||||
/**
|
||||
* Returns a list of registered commands
|
||||
* @returns List of registered commands.
|
||||
*/
|
||||
std::vector<std::string> listCommands() const;
|
||||
};
|
||||
|
||||
extern const CRPCTable tableRPC;
|
||||
|
Loading…
Reference in New Issue
Block a user