Qmmp
Loading...
Searching...
No Matches
commandlinehandler.h
1/***************************************************************************
2 * Copyright (C) 2008-2022 by Ilya Kotov *
3 * forkotov02@ya.ru *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
20#ifndef COMMANDLINEHANDLER_H
21#define COMMANDLINEHANDLER_H
22
23#include <QString>
24#include <QMap>
25#include <QStringList>
26#include <QtPlugin>
27#include <QFlags>
28#include "qmmpui_export.h"
29
33class QMMPUI_EXPORT CommandLineHandler
34{
35public:
43 virtual void registerOprions() = 0;
48 virtual QString shortName() const = 0;
53 virtual QString translation() const = 0;
61 virtual QString executeCommand(int id, const QStringList &args) = 0;
65 QStringList helpString() const;
71 QString helpString(int id) const;
77 int identify(const QString &name) const;
83 {
84 HiddenFromHelp = 0x1,
85 NoStart = 0x2
86 };
87 Q_DECLARE_FLAGS(OptionFlags, OptionFlag)
92 CommandLineHandler::OptionFlags flags(int id) const;
93
94protected:
102 void registerOption(int id, const QString &name, const QString &helpString, const QStringList &values = QStringList());
110 void registerOption(int id, const QStringList &names, const QString &helpString, const QStringList &values = QStringList());
116 void setOptionFlags(int id, OptionFlags flags);
117
118private:
119 struct CommandLineOption
120 {
121 QStringList names;
122 QStringList values;
123 QString helpString;
124 OptionFlags flags;
125
126 inline bool operator == (const CommandLineOption &opt) const
127 {
128 return names == opt.names &&
129 values == opt.values &&
130 helpString == opt.helpString &&
131 flags == opt.flags;
132 }
133 };
134
135 QMap<int, CommandLineOption> m_options;
136};
137
138Q_DECLARE_OPERATORS_FOR_FLAGS(CommandLineHandler::OptionFlags)
139Q_DECLARE_INTERFACE(CommandLineHandler,"CommandLineHandlerInterface/1.0")
140
141#endif
Abstract base class of the command line plugins.
Definition commandlinehandler.h:34
virtual QString translation() const =0
virtual QString shortName() const =0
virtual void registerOprions()=0
virtual QString executeCommand(int id, const QStringList &args)=0
OptionFlag
Definition commandlinehandler.h:83
virtual ~CommandLineHandler()
Definition commandlinehandler.h:39
int identify(const QString &name) const
QString helpString(int id) const
QStringList helpString() const