#include <openwithactionfactory.h>
Public Types | |
enum | HandlerType { NoHandler = -1, ExecutableHandler = 0, RpcHandler } |
![]() | |
enum | Flag { ContextItem = 0x1 } |
Public Member Functions | |
OpenWithActionFactory () | |
OpenWithActionFactory (const OpenWithActionFactory &other) | |
OpenWithActionFactory & | operator= (OpenWithActionFactory other) |
bool | isValidForJob (const Job &job) const |
void | clearJobs () |
bool | useMenu () const |
QString | menuText () const |
QList< QAction * > | createActions () |
unsigned int | usefulness () const |
void | setRpcDetails (const QString &myRpcServer, const QString &myRpcMethod) |
QString | rpcServer () const |
QString | rpcMethod () const |
void | readSettings (QSettings &settings) |
void | writeSettings (QSettings &settings) const |
QString | name () const |
void | setName (const QString &n) |
void | setHandlerType (HandlerType type) |
HandlerType | handlerType () const |
void | setExecutable (const QString &exec) |
QString | executable () const |
QList< QRegExp > | filePatterns () const |
QList< QRegExp > & | filePatternsRef () |
const QList< QRegExp > & | filePatternsRef () const |
void | setFilePatterns (const QList< QRegExp > &patterns) |
![]() | |
JobActionFactory (const JobActionFactory &other) | |
JobActionFactory & | operator= (const JobActionFactory &other) |
void | setServer (Server *s) |
Server * | server () const |
virtual bool | isMultiJob () const |
virtual bool | addJobIfValid (const Job &job) |
virtual bool | hasValidActions () const |
virtual Flags | flags () const |
virtual void | setFlags (Flags f) |
Additional Inherited Members | |
![]() | |
unsigned int | m_attemptedJobAdditions |
bool | m_isMultiJob |
Server * | m_server |
QList< Job > | m_jobs |
Flags | m_flags |
The OpenWithActionFactory class provides a generic mechanism for performing an action on a file in a job's directory. It is configured to process a file by calling an external executable or sending RPC requests.
<molequeue/jobactionfactories/openwithactionfactory.h> The OpenWithActionFactory allows arbitrary actions to be performed on files in a job's directory. A list of QRegExp objects is used to filter filenames so that the factory only produces actions for files that match one of the filePatterns().
The actions will either call an external executable() to handle the file, or send a request (rpcMethod()) to a JSON-RPC 2.0 server (rpcServer()). The executable will be run as:
RPC requests will be of the form:
Use setExecutable() to set the actions to use an executable, or setRpcDetails() to use RPC calls. The type of file handler can be checked with handlerType().
enum HandlerType |
The HandlerType enum identifies types of file handling strategies.
Enumerator | |
---|---|
NoHandler |
No handler specified. |
ExecutableHandler |
Open the file with an external executable.
|
RpcHandler |
Open the file with a JSON-RPC request.
|
Construct a new, uninitialized OpenWithActionFactory.
OpenWithActionFactory | ( | const OpenWithActionFactory & | other | ) |
Construct a copy of the OpenWithActionFactory other.
OpenWithActionFactory& operator= | ( | OpenWithActionFactory | other | ) |
Copy the OpenWithActionFactory other into this.
|
virtual |
Save/restore state.
Reimplemented from JobActionFactory.
|
virtual |
Save/restore state.
Reimplemented from JobActionFactory.
|
virtual |
The user-friendly GUI name of this action. Used to set the action menu text to "Open '[job description]' with '[name()]'".
Implements JobActionFactory.
void setName | ( | const QString & | n | ) |
The user-friendly GUI name of this action. Used to set the action menu text to "Open '[job description]' with '[name()]'".
|
virtual |
Implements JobActionFactory.
|
virtual |
Clear m_jobs and reset m_attemptedJobAdditions
Reimplemented from JobActionFactory.
|
virtual |
Reimplemented from JobActionFactory.
|
virtual |
Reimplemented from JobActionFactory.
|
virtual |
Create actions that operate on the Job objects in m_jobs. The caller is responsible for managing the lifetime of the actions (passing them to a QMenu or similar is usually sufficient).
Implements JobActionFactory.
|
virtual |
The "usefulness" of the actions produced by this factory, used to order actions in generated menus, etc. Lower value means higher usefulness.
Implements JobActionFactory.
void setHandlerType | ( | HandlerType | type | ) |
The type of file handling strategy to use.
HandlerType handlerType | ( | ) | const |
The type of file handling strategy to use.
void setExecutable | ( | const QString & | exec | ) |
Produce actions that execute @a exec on the selected file as:
@note Calling setExecutable() erases the rpcServer() and rpcMethod() values.
QString executable | ( | ) | const |
Produce actions that execute @a exec on the selected file as:
@note Calling setExecutable() erases the rpcServer() and rpcMethod() values.
void setRpcDetails | ( | const QString & | myRpcServer, |
const QString & | myRpcMethod | ||
) |
Produce actions that set JSON-RPC 2.0 requests to a local socket server named @a myRpcServer of the form:
QString rpcServer | ( | ) | const |
QString rpcMethod | ( | ) | const |
QList<QRegExp> filePatterns | ( | ) | const |
A list of QRegExp objects that match files supported by the file handler. An action will be produce for each file that matches any of these QRegExps.
QList<QRegExp>& filePatternsRef | ( | ) |
A list of QRegExp objects that match files supported by the file handler. An action will be produce for each file that matches any of these QRegExps.
const QList<QRegExp>& filePatternsRef | ( | ) | const |
A list of QRegExp objects that match files supported by the file handler. An action will be produce for each file that matches any of these QRegExps.
void setFilePatterns | ( | const QList< QRegExp > & | patterns | ) |
A list of QRegExp objects that match files supported by the file handler. An action will be produce for each file that matches any of these QRegExps.