OpenCurves  0.9
ExpressionsView Class Reference

Manages and edits current expressions. More...

#include <expressionsview.h>

Inheritance diagram for ExpressionsView:

Public Member Functions

 ExpressionsView (Expressions *expressions=nullptr, QWidget *parent=nullptr)
 Constructor. More...
 
 ~ExpressionsView ()
 Destructor.
 
void setExpressions (Expressions *expressions)
 Sets the Expressions object to view and edit. More...
 
const Expressionsexpressions () const
 Returns the Expressions object being viewed and edited.
 

Protected Slots

void addExpr ()
 Handler for add button presses. More...
 
void removeExpr ()
 Removes the currently selected expression (if any).
 
void updateExpr ()
 Attempts to update the currently selected expression with the current UI editor text. More...
 
void currentItemChanged (QListWidgetItem *current, QListWidgetItem *previous)
 Handles changes in the current expression selection, updating the editor text. More...
 
void editingDone ()
 Handles explicit completion of editing in the expression editor (i.e., the enter key). More...
 
void expressionAdded (PlotExpression *expression)
 Handles additions to the Expressions object, adding the expression to the display list. More...
 
void expressionRemoved (const PlotExpression *expression)
 Handles removal from the Expressions object, removing the corresponding expression from the display list. More...
 

Protected Member Functions

PlotExpressionparseExpression (const QString &text, QStringList &errors) const
 Parses the text expression text returning a compiled PlotExpression. More...
 
PlotExpressionaddExpression ()
 Attempts to add an expression based on the current UI state. More...
 
void showExpressions ()
 Clears and repopulates the expressions display list. More...
 
QListWidgetItem * createItem (PlotExpression *expression)
 Create a list widget for expression. More...
 
bool removeExpression (QListWidgetItem *item)
 Remove the expression associated with item. More...
 

Detailed Description

Manages and edits current expressions.

The view directly edits an Expressions object, modifying its content.

This view is designed to be used in a docking window.

Constructor & Destructor Documentation

ExpressionsView::ExpressionsView ( Expressions expressions = nullptr,
QWidget *  parent = nullptr 
)
explicit

Constructor.

Parameters
expressionsDetails the Expressions to view and edit.
parentThe parent widget.

Member Function Documentation

void ExpressionsView::addExpr ( )
protectedslot

Handler for add button presses.

Maps through to addExpression().

PlotExpression* ExpressionsView::addExpression ( )
protected

Attempts to add an expression based on the current UI state.

The expression text is taken from the UI editing component.

Note that this does not update the UI expression list directly, relying on signals from the Expressions object to do so. Parse errors are displayed in the appropriate UI component.

Returns
A valid expression object on successes, null on failure.
QListWidgetItem* ExpressionsView::createItem ( PlotExpression expression)
protected

Create a list widget for expression.

Parameters
expressionThe expression of interest.
Returns
A display widget for expression.
void ExpressionsView::currentItemChanged ( QListWidgetItem *  current,
QListWidgetItem *  previous 
)
protectedslot

Handles changes in the current expression selection, updating the editor text.

Parameters
currentThe current/new selection.
previousThe previous/old selection.
void ExpressionsView::editingDone ( )
protectedslot

Handles explicit completion of editing in the expression editor (i.e., the enter key).

This attempts to either update the current expression, or create a new one.

void ExpressionsView::expressionAdded ( PlotExpression expression)
protectedslot

Handles additions to the Expressions object, adding the expression to the display list.

Parameters
expressionThe new expression object.
void ExpressionsView::expressionRemoved ( const PlotExpression expression)
protectedslot

Handles removal from the Expressions object, removing the corresponding expression from the display list.

Parameters
expressionThe removed expression object.
PlotExpression* ExpressionsView::parseExpression ( const QString &  text,
QStringList &  errors 
) const
protected

Parses the text expression text returning a compiled PlotExpression.

Parsing is performed by a PlotExpressionParser using the PlotFunctionRegister contained in the current Expressions object. The compiled expression is returned on success. On failure, the errors list is populated with the parsing issues encountered.

If there is no current Expressions object, then the function returns null with nothing added to errors.

Parameters
textThe expression string to parse.
[in,out]errorsPopulated with any parsing errors encountered.
Returns
The compiled expression on success, null on failure.
bool ExpressionsView::removeExpression ( QListWidgetItem *  item)
protected

Remove the expression associated with item.

Parameters
itemThe list item to remove the expression for.
Returns
True on success, false if there is no associated expression.
void ExpressionsView::setExpressions ( Expressions expressions)

Sets the Expressions object to view and edit.

The UI is updated to reflect the content of Expressions.

Parameters
expressionsThe object to view and edit. May be null.
void ExpressionsView::showExpressions ( )
protected

Clears and repopulates the expressions display list.

Uses createItem() for each display entry.

void ExpressionsView::updateExpr ( )
protectedslot

Attempts to update the currently selected expression with the current UI editor text.


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