From 515a1723150c48becd8dca94a9e1d1f9f8b38131 Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Mon, 24 Dec 2018 21:25:49 +0000 Subject: changed command line plugin api git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@8530 90c681e8-e032-0410-971d-27865f9a5e38 --- src/qmmpui/commandlinemanager.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'src/qmmpui/commandlinemanager.cpp') diff --git a/src/qmmpui/commandlinemanager.cpp b/src/qmmpui/commandlinemanager.cpp index f2571839f..f91510f5e 100644 --- a/src/qmmpui/commandlinemanager.cpp +++ b/src/qmmpui/commandlinemanager.cpp @@ -34,15 +34,15 @@ using namespace std; -QList *CommandLineManager::m_options = 0; -QHash *CommandLineManager::m_files = 0; +QList *CommandLineManager::m_options = 0; +QHash *CommandLineManager::m_files = 0; void CommandLineManager::checkOptions() { if (!m_options) { - m_options = new QList; - m_files = new QHash; + m_options = new QList; + m_files = new QHash; foreach (QString filePath, Qmmp::findPlugins("CommandLineOptions")) { @@ -53,9 +53,9 @@ void CommandLineManager::checkOptions() else qWarning("CommandLineManager: %s", qPrintable(loader.errorString ())); - CommandLineOption *option = 0; + CommandLineHandler *option = 0; if (plugin) - option = qobject_cast(plugin); + option = qobject_cast(plugin); if (option) { @@ -72,7 +72,7 @@ void CommandLineManager::checkOptions() } } -QString CommandLineManager::executeCommand(const QString& opt_str, const QStringList &args) +QString CommandLineManager::executeCommand(const QString &name, const QStringList &args) { checkOptions(); if(!UiHelper::instance() || !SoundCore::instance() || !MediaPlayer::instance()) @@ -80,11 +80,12 @@ QString CommandLineManager::executeCommand(const QString& opt_str, const QString qWarning("CommandLineManager: player objects are not created"); return QString(); } - foreach(CommandLineOption *opt, *m_options) + foreach(CommandLineHandler *opt, *m_options) { - if (opt->identify(opt_str)) + int id = opt->identify(name); + if(id >= 0) { - return opt->executeCommand(opt_str, args); + return opt->executeCommand(id, args); } } return QString(); @@ -93,9 +94,9 @@ QString CommandLineManager::executeCommand(const QString& opt_str, const QString bool CommandLineManager::hasOption(const QString &opt_str) { checkOptions(); - foreach(CommandLineOption *opt, *m_options) + foreach(CommandLineHandler *opt, *m_options) { - if (opt->identify(opt_str)) + if (opt->identify(opt_str) >= 0) return true; } return false; @@ -104,9 +105,9 @@ bool CommandLineManager::hasOption(const QString &opt_str) void CommandLineManager::printUsage() { checkOptions(); - foreach(CommandLineOption *opt, *m_options) + foreach(CommandLineHandler *opt, *m_options) { - foreach(QString line, opt->properties().helpString) + foreach(QString line, opt->helpString()) { QString str = formatHelpString(line); if(!str.isEmpty()) -- cgit v1.2.3-13-gbd6f