| digiKam Developer Documentation Professional Photo Management with the Power of Open Source

Loading...
Searching...
No Matches
Public Types | Signals | Public Member Functions | Static Public Member Functions | Protected Slots | Protected Member Functions | List of all members
Digikam::Rule Class Referenceabstract
Inheritance diagram for Digikam::Rule:

## Public Types
enum | IconType { Action = 0 , Dialog }

## Signals
void | signalTokenTriggered (const QString &)

## Public Member Functions
| Rule (const QString &name)
| Rule (const QString &name, const QString &icon)
QString | description () const
QPixmap | icon (Rule::IconType type=Rule::Action) const
bool | isValid () const
| Checks the validity of the parse object.
ParseResults | parse (ParseSettings &settings)
QRegularExpression & | regExp () const
| TODO: This is probably not needed anymore.
QPushButton * | registerButton (QWidget *parent)
| Register a button in the parent object.
QAction * | registerMenu (QMenu *parent)
| Register a menu action in the parent object.
virtual void | reset ()
| Resets the parser to its initial state.
TokenList & | tokens () const
bool | useTokenMenu () const
| Returns true if a token menu is used.

## Static Public Member Functions
static QString | escapeToken (const QString &token)
| Escape the token characters to make them work in regular expressions.

## Protected Slots
virtual void | slotTokenTriggered (const QString &)

## Protected Member Functions
bool | addToken (const QString &id, const QString &description, const QString &actionName=QString())
| add a token to the parser, every parser should at least assign one token object
QWidget * | getParentWidget () const
virtual QString | parseOperation (ParseSettings &settings, const QRegularExpressionMatch &match)=0
| TODO: describe me.
void | setDescription (const QString &desc)
void | setIcon (const QString &pixmap)
void | setParentWidget (QWidget *const widget)
| Set and get parent widget for the dialogs.
void | setRegExp (const QRegularExpression &regExp)
void | setUseTokenMenu (bool value)
| If multiple tokens have been assigned to a rule, a menu will be created.

## Member Function Documentation

## ◆ addToken()

bool Digikam::Rule::addToken | ( | const QString & | id,
|  | const QString & | description,
|  | const QString & | actionName = `QString()`
| ) |  |
| protected

Parameters

  id | the token id string (used for parsing)
  description | the description of the token (used for example in the tooltip)
  actionName | [optional] the name of the token action (only used when the token menu is displayed)

Returns

## ◆ escapeToken()

QString Digikam::Rule::escapeToken | ( | const QString & | token | ) |
| static

Parameters

  token | the token to be escaped

Returns
  A token with escaped characters. This token can then be used in a regular expression

## ◆ isValid()

bool Digikam::Rule::isValid | ( |  | ) | const

Returns
  true if valid

## ◆ parseOperation()

virtual QString Digikam::Rule::parseOperation | ( | ParseSettings & | settings,
|  | const QRegularExpressionMatch & | match
| ) |  |
| protected pure virtual

Parameters

  settings | contains settings
  match | result of the regular expression match done in Option::parse()

Returns

Implemented in Digikam::CaseModifier, Digikam::DateFormatModifier, Digikam::DefaultValueModifier, Digikam::RangeModifier, Digikam::RemoveDoublesModifier, Digikam::ReplaceModifier, Digikam::TrimmedModifier, Digikam::UniqueModifier, Digikam::CameraNameOption, Digikam::DatabaseOption, Digikam::DateOption, Digikam::DirectoryNameOption, Digikam::FilePropertiesOption, Digikam::MetadataOption, Digikam::SequenceNumberOption, Digikam::Modifier, and Digikam::Option.

## ◆ regExp()

QRegularExpression & Digikam::Rule::regExp | ( |  | ) | const

Find out. returns the currently assigned regExp object. Note that it is returned as a const ref, meaning that if you use it in your custom parse operation, the main parse method has already searched for the pattern and filled in the results of this search, so that you can use QRegularExpressionMatch::captured() immediately, you don't have to search on your own.

For example when implementing the Option::parseOperation() method, get the regExp object with

     const QRegularExpression& reg = regExp();

and immediately fetch possible matches with

     const QString& param1 = reg.captured(1);

See also
  Option
  Modifier

Returns
  a const ref to the assigned regexp object

## ◆ registerButton()

QPushButton * Digikam::Rule::registerButton | ( | QWidget * | parent | ) |

By calling this method, a new button for the parser object will be created and all necessary connections will be setup.

Parameters

  parent | the parent object the button will be registered for

Returns
  a pointer to the newly created button

## ◆ registerMenu()

QAction * Digikam::Rule::registerMenu | ( | QMenu * | parent | ) |

By calling this method, a new action for the parser object will be created and all necessary connections will be setup.

Parameters

  parent | the parent object the action will be registered for

Returns
  a pointer to the newly created action

## ◆ reset()

void Digikam::Rule::reset | ( |  | ) |
| virtual

Reimplemented in Digikam::UniqueModifier.

## ◆ setParentWidget()

void Digikam::Rule::setParentWidget | ( | QWidget *const | widget | ) |
| protected

Parameters

  widget | QWidget pointer from parent widget

## ◆ setUseTokenMenu()

void Digikam::Rule::setUseTokenMenu | ( | bool | value | ) |
| protected

If you want to display a menu for every defined token, set this method to 'true' and re-implement the

See also
  slotTokenTriggered method.

Parameters

  value | boolean parameter to set token menu usage

## ◆ tokens()

TokenList & Digikam::Rule::tokens | ( |  | ) | const

Returns
  a list of all registered tokens