Would have preferred if the command arrays were in a vector, would have prevented hardcoding of array sizes in for loop. I will probably do that in another pull request.

Would have preferred if the command arrays were in a vector, would have prevented hardcoding of array sizes in for loop. I will probably do that in another pull request.

Concept ACK.
Nice! Concept ACK. Will review/test soon.
Concept ACK. Nice!
The build without wallet failed - see https://travis-ci.org/bitcoin/bitcoin/jobs/112189472#L1844
qt/libbitcoinqt.a(qt_libbitcoinqt_a-rpcconsole.o): In function `RPCConsole::RPCConsole(PlatformStyle const*, QWidget*)':
rpcconsole.cpp:(.text+0x566a): undefined reference to `vWalletRPCCommands'
276 | @@ -274,6 +277,19 @@ RPCConsole::RPCConsole(const PlatformStyle *platformStyle, QWidget *parent) : 277 | connect(ui->fontSmallerButton, SIGNAL(clicked()), this, SLOT(fontSmaller())); 278 | connect(ui->btnClearTrafficGraph, SIGNAL(clicked()), ui->trafficGraph, SLOT(clear())); 279 | 280 | + //Setup autocomplete and attach it 281 | + QStringList wordList; 282 | + for (int i =0; i < 53; ++i)
Any reason why we are not using std::array?
You need to build the 53 dynamic by something like ARRAYLEN(vRPCCommands).
@MarcoFalke That would require C++11 which i believe at this point is not supported yet in the codebase. @jonasschnelli Apparently this is much trickier than it would seem to be. Straightforward way would be to use vector but would be kind of redundant for a const array. Will see what i can do about it.
@GamerSg Right, somehow forgot we are still waiting on travis to get c++11 rolled out.
You could take a look at src/utilstrencodings.h which has a #define ARRAYLEN(array).
283 | + { 284 | + wordList<<vRPCCommands[i].name.c_str(); 285 | + } 286 | + for (int i =0; i < 43; ++i) 287 | + { 288 | + wordList<<vWalletRPCCommands[i].name.c_str();
You'd have to guard this. Try https://github.com/bitcoin/bitcoin/blob/317462123f8e41fd7dd967ab907e59ddffb19898/src/init.cpp#L951
Concept ACK, nice idea. Perhaps this could be implemented without making vRPCCommands etc. extern? Nit: some of the spacing is a little unusual.
287 | + } 288 | + #ifdef ENABLE_WALLET 289 | + bool fDisableWallet = GetBoolArg("-disablewallet", false); 290 | + if(!fDisableWallet) 291 | + {//Only add commands if wallet is not disabled 292 | + for (int i =0; i < 43; ++i)
You need to build the 43 dynamic by something like ARRAYLEN(vWalletRPCCommands).
@GamerSg Are you still working on this? I'd like to see this merged :)
Yes. I also think this is a nice improvement. We just need to remove the magic numbers. Just tell me or Marco if on of us should continue this (without losing you commit/author name).
ARRAYLEN will not work for an external array, the information is not available at compile time. Please see my suggestion below to add a call to TableRPC.
@MarcoFalke Sorry, been busy past few days. I'll iron out any remaining issues over the weekend.
As @laanwj said, sizeof(array) does not work either, because the data is in a seperate cpp file and unavailable at compile time to other compilation units.
251 | @@ -252,7 +252,7 @@ UniValue stop(const UniValue& params, bool fHelp) 252 | /** 253 | * Call Table 254 | */ 255 | -static const CRPCCommand vRPCCommands[] = 256 | +extern const CRPCCommand vRPCCommands[] =
extern should not be required here?
I believe its a style thing, it is optional but i like to mark an extern even at the definition to make it clearer to someone reading the code that it is global.
Edit: Actually it does not compile without the extern keyword, not really sure why since i almost never use extern and from my research it appears that there are some differences in C and C++.
I don't like exposing this array using extern, it is an implementation detail. It also doesn't interoperate with commands that are added later on by modules (in this case the wallet in walletRegisterRPCCommands). Now you need to pull from everywhere...
My suggestion would be to add a ListCommands to TableRPC, that returns a std::vector<std::string> of commands, and use that.
286 | + wordList<<vRPCCommands[i].name.c_str(); 287 | + } 288 | + #ifdef ENABLE_WALLET 289 | + bool fDisableWallet = GetBoolArg("-disablewallet", false); 290 | + if(!fDisableWallet) 291 | + {//Only add commands if wallet is not disabled
No need for this comment. Also you don't have to parse the arg. Maybe try just if (pwalletMain)?
Concept ACK
Looks good to me now! utACK after squash
Sweet, utACK after style nits Refer doc/developer-notes.md for some coding style tips. Also a space after a comma, and before and after operators like = and << are always good things IMO :)
for (size_t i =0; i < commandList.size(); ++i)
{
wordList<<commandList[i].c_str();
}
autoCompleter = new QCompleter(wordList,this);
Currently, the wallet RPC commands are missing.
You need to build up your autocomplete list in RPCConsole::setClientModel() (and only if the modal exists) instead of in RPCConsole:: RPCConsole(). This is required because of the more modular creation of the tableRPC (see #7307).
@jonasschnelli good catch!
Hi all, i just find time during the weekends to work on this, so ill fix up the remaining issues tomorrow.
Removed externs
Added listCommands() to CRPCTable
Move autocomplete init to RPCConsole::setClientModel()
Moved the initialisation to setClientModel() as @jonasschnelli suggested. Squashed the commits as well.
Looks like this works just fine, now.
ACK ce7413f:

Works OK. Please fix the indentation of "}" in rpcconsole.cpp.
Tested ACK ce7413fcb7d28bd72e5ade7dc9756504de766fc2