From dd828df46a661fbd0a24fbe540a4a585360be005 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 18 May 2013 17:02:13 +0300 Subject: add named commands with enum. use some named commands from popupmenu. --- src/commandhandler.cpp | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'src/commandhandler.cpp') diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index fc7d6dff8..a9b5672ee 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -34,7 +34,11 @@ CommandHandler::CommandHandler() : { const int sz = sizeof(commands) / sizeof(CommandInfo); for (int f = 0; f < sz; f ++) - mCommands[commands[f].name] = commands[f].func; + { + const std::string name = commands[f].name; + if (!name.empty()) + mCommands[name] = commands[f].func; + } } void CommandHandler::handleCommands(const std::string &command, @@ -75,3 +79,39 @@ void CommandHandler::invokeCommand(const std::string &type, } } } + +void CommandHandler::invokeCommand(const int type, + const bool warn) +{ + if (type < 0 || type >= END_COMMANDS) + return; + (commands[type].func)("", nullptr); +} + +void CommandHandler::invokeCommand(const int type, + ChatTab *const tab, + const bool warn) +{ + if (type < 0 || type >= END_COMMANDS) + return; + (commands[type].func)("", tab); +} + +void CommandHandler::invokeCommand(const int type, + const std::string &args, + const bool warn) +{ + if (type < 0 || type >= END_COMMANDS) + return; + (commands[type].func)(args, nullptr); +} + +void CommandHandler::invokeCommand(const int type, + const std::string &args, + ChatTab *const tab, + const bool warn) +{ + if (type < 0 || type >= END_COMMANDS) + return; + (commands[type].func)(args, tab); +} -- cgit v1.2.3-70-g09d2