MoleQueue  0.8.0
 All Classes Functions Variables Enumerations Enumerator Pages
Public Types | Public Member Functions | List of all members
OpenWithActionFactory Class Reference

#include <openwithactionfactory.h>

Inheritance diagram for OpenWithActionFactory:
JobActionFactory

Public Types

enum  HandlerType {
  NoHandler = -1,
  ExecutableHandler = 0,
  RpcHandler
}
 
- Public Types inherited from JobActionFactory
enum  Flag { ContextItem = 0x1 }
 

Public Member Functions

 OpenWithActionFactory ()
 
 OpenWithActionFactory (const OpenWithActionFactory &other)
 
OpenWithActionFactoryoperator= (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)
 
- Public Member Functions inherited from JobActionFactory
 JobActionFactory (const JobActionFactory &other)
 
JobActionFactoryoperator= (const JobActionFactory &other)
 
void setServer (Server *s)
 
Serverserver () 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

- Protected Attributes inherited from JobActionFactory
unsigned int m_attemptedJobAdditions
 
bool m_isMultiJob
 
Serverm_server
 
QList< Jobm_jobs
 
Flags m_flags
 

Detailed Description

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:

executable /absolute/path/to/selected/fileName

RPC requests will be of the form:

{
"jsonrpc": "2.0",
"method": "rpcMethod",
"params": {
"fileName": "/absolute/path/to/selected/fileName"
}
},
"id": "XXX"
}

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().

Member Enumeration Documentation

The HandlerType enum identifies types of file handling strategies.

See Also
handlerType()
Enumerator
NoHandler 

No handler specified.

ExecutableHandler 

Open the file with an external executable.

See Also
setExecutable().
RpcHandler 

Open the file with a JSON-RPC request.

See Also
setRpcDetails().

Constructor & Destructor Documentation

Construct a new, uninitialized OpenWithActionFactory.

Construct a copy of the OpenWithActionFactory other.

Member Function Documentation

Copy the OpenWithActionFactory other into this.

void readSettings ( QSettings &  settings)
virtual

Save/restore state.

Reimplemented from JobActionFactory.

void writeSettings ( QSettings &  settings) const
virtual

Save/restore state.

Reimplemented from JobActionFactory.

QString name ( ) const
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()]'".

bool isValidForJob ( const Job job) const
virtual
Returns
true if the factory's actions are appropriate for job.

Implements JobActionFactory.

void clearJobs ( )
virtual

Clear m_jobs and reset m_attemptedJobAdditions

Reimplemented from JobActionFactory.

bool useMenu ( ) const
virtual
Returns
true if this factory's actions should be placed in a submenu. Use menuText() to get the menu name.

Reimplemented from JobActionFactory.

QString menuText ( ) const
virtual
Returns
The text to be used for a submenu containing this factory's items. Call useMenu() to see if this is required.

Reimplemented from JobActionFactory.

QList<QAction *> createActions ( )
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).

See Also
hasValidActions()
addJobIfValid
clearJobs

Implements JobActionFactory.

unsigned int usefulness ( ) const
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.

See Also
HandlerType
setExecutable() setRpcDetails()
HandlerType handlerType ( ) const

The type of file handling strategy to use.

See Also
HandlerType
setExecutable() setRpcDetails()
void setExecutable ( const QString &  exec)
 Produce actions that execute @a exec on the selected file as:
executable /absolute/path/to/selected/fileName
 @note Calling setExecutable() erases the rpcServer() and rpcMethod()
 values.
QString executable ( ) const
 Produce actions that execute @a exec on the selected file as:
executable /absolute/path/to/selected/fileName
 @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:
{
"jsonrpc": "2.0",
"method": "myRpcMethod",
"params": {
"fileName": "/absolute/path/to/selected/fileName"
}
},
"id": "XXX"
}
Note
This method erases the executable() value.
QString rpcServer ( ) const
Returns
The target JSON-RPC server socket name.
QString rpcMethod ( ) const
Returns
The method to use in JSON-RPC requests.
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.


The documentation for this class was generated from the following file: