/usr/include/qgis/qgsattributeaction.h is in libqgis-dev 1.7.4+1.7.5~20120320-1.1+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | /***************************************************************************
qgsattributeaction.h
These classes store and control the managment and execution of actions
associated with particulay Qgis layers. Actions are defined to be
external programs that are run with user-specified inputs that can
depend on the contents of layer attributes.
-------------------
begin : Oct 24 2004
copyright : (C) 2004 by Gavin Macaulay
email : gavin at macaulay dot co dot nz
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
/* $Id$ */
#ifndef QGSATTRIBUTEACTION_H
#define QGSATTRIBUTEACTION_H
#include <QString>
#include <QObject>
#include <qgsfeature.h>
class QDomNode;
class QDomDocument;
class QgsPythonUtils;
class QgsVectorLayer;
/** \ingroup core
* Utility class that encapsulates an action based on vector attributes.
*/
class CORE_EXPORT QgsAction
{
public:
enum ActionType
{
Generic,
GenericPython,
Mac,
Windows,
Unix,
};
QgsAction( ActionType type, QString name, QString action, bool capture ) :
mType( type ), mName( name ), mAction( action ), mCaptureOutput( capture ) {}
//! The name of the action
QString name() const { return mName; }
//! The action
QString action() const { return mAction; }
//! The action type
ActionType type() const { return mType; }
//! Whether to capture output for display when this action is run
bool capture() const { return mCaptureOutput; }
//! Whether the action is runable on the current platform
bool runable() const
{
return mType == Generic ||
mType == GenericPython ||
#if defined(Q_OS_WIN)
mType == Windows
#elif defined(Q_OS_MAC)
mType == Mac
#else
mType == Unix
#endif
;
}
private:
ActionType mType;
QString mName;
QString mAction;
bool mCaptureOutput;
};
/*! \class QgsAttributeAction
* \brief Storage and management of actions associated with Qgis layer
* attributes.
*/
class CORE_EXPORT QgsAttributeAction
{
public:
//! Constructor
QgsAttributeAction( QgsVectorLayer *layer ) : mLayer( layer ) {}
//! Destructor
virtual ~QgsAttributeAction() {}
//! Add an action with the given name and action details.
// Will happily have duplicate names and actions. If
// capture is true, when running the action using doAction(),
// any stdout from the process will be captured and displayed in a
// dialog box.
void addAction( QgsAction::ActionType type, QString name, QString action, bool capture = false );
//! Does the action using the given values. defaultValueIndex is an
// index into values which indicates which value in the values vector
// is to be used if the action has a default placeholder.
// @note parameter executePython deprecated (and missing in python binding)
void doAction( int index,
const QgsAttributeMap &attributes,
int defaultValueIndex = 0,
void ( *executePython )( const QString & ) = 0 );
//! Removes all actions
void clearActions() { mActions.clear(); }
//! Expands the given action, replacing all %'s with the value as
// given.
QString expandAction( QString action,
const QgsAttributeMap &attributes,
uint defaultValueIndex );
//! Writes the actions out in XML format
bool writeXML( QDomNode& layer_node, QDomDocument& doc ) const;
//! Reads the actions in in XML format
bool readXML( const QDomNode& layer_node );
int size() const { return mActions.size(); }
QgsAction &at( int idx ) { return mActions[idx]; }
QgsAction &operator[]( int idx ) { return mActions[idx]; }
static void setPythonExecute( void ( * )( const QString & ) );
private:
QList<QgsAction> mActions;
QgsVectorLayer *mLayer;
static void ( *smPythonExecute )( const QString & );
};
#endif
|