OpenCurves
0.9
|
Manages and edits current expressions. More...
#include <expressionsview.h>
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 Expressions * | expressions () 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 | |
PlotExpression * | parseExpression (const QString &text, QStringList &errors) const |
Parses the text expression text returning a compiled PlotExpression . More... | |
PlotExpression * | addExpression () |
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... | |
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.
|
explicit |
Constructor.
expressions | Details the Expressions to view and edit. |
parent | The parent widget. |
|
protectedslot |
Handler for add button presses.
Maps through to 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.
|
protected |
Create a list widget for expression
.
expression | The expression of interest. |
expression
.
|
protectedslot |
Handles changes in the current expression selection, updating the editor text.
current | The current/new selection. |
previous | The previous/old selection. |
|
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.
|
protectedslot |
Handles additions to the Expressions
object, adding the expression to the display list.
expression | The new expression object. |
|
protectedslot |
Handles removal from the Expressions
object, removing the corresponding expression from the display list.
expression | The removed expression object. |
|
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
.
text | The expression string to parse. | |
[in,out] | errors | Populated with any parsing errors encountered. |
|
protected |
Remove the expression associated with item
.
item | The list item to remove the expression for. |
void ExpressionsView::setExpressions | ( | Expressions * | expressions | ) |
Sets the Expressions
object to view and edit.
The UI is updated to reflect the content of Expressions
.
expressions | The object to view and edit. May be null. |
|
protected |
Clears and repopulates the expressions display list.
Uses createItem()
for each display entry.
|
protectedslot |
Attempts to update the currently selected expression with the current UI editor text.