示例#1
0
void Service::invokeCommand (const QString& cmd)
{
    qDebug() << "[DesktopControl::Service::invokeCommand()] Heard " << cmd << "from the user.";
    AbstractCategory* glbl = AbstractCategory::global();
    CommandList commands = glbl->matchAllCommands (cmd);

    if (!commands.isEmpty()) {
        if (commands.count() == 1) {
            AbstractCommand* onlyCommand = commands.first();
            qDebug() << "[DesktopControl::Service::invokeCommand()] Only matched a command " << onlyCommand->id() << "matched with statements" << onlyCommand->statements();
            emit commandFound (cmd, onlyCommand);
            onlyCommand->invoke (cmd);
            return;
        }
        else {
            emit multipleCommandsFound (cmd, commands);

            Q_FOREACH (AbstractCommand * command, commands) {
                qDebug() << "[DesktopControl::Service::invokeCommand()] Command " << command->id() << "matched with statements" << command->statements();
            }
        }

    }
    else {