Loading...
Searching...
No Matches
JsonWidget Class Reference

The JsonWidget class provides a user interface for running external scripts. More...

`#include <jsonwidget.h>`

Inheritance diagram for JsonWidget:

## Public Slots

virtual void | updatePreviewText ()

## Public Member Functions

| JsonWidget (QWidget *parent_=nullptr)
virtual void | setMolecule (QtGui::Molecule *mol)
QJsonObject | collectOptions () const
void | applyOptions (const QJsonObject &opts)
bool | isEmpty () const

## Protected Member Functions

QString | lookupOptionType (const QString &name) const
bool | optionString (const QString &option, QString &value) const
| Search for an option named option and convert its value to a string.
QString | generateJobTitle () const
virtual void | updateOptions ()
void | buildOptionGui ()
void | combinedOptionRow (const QString &label1, const QString &label2, const QString &tr1, const QString &tr2, QJsonObject &options, bool bothLabels=false)
void | addOptionRow (const QString &key, const QString &label, const QJsonValue &option)
QWidget * | createOptionWidget (const QJsonValue &option)
QWidget * | createStringListWidget (const QJsonObject &obj)
QWidget * | createStringWidget (const QJsonObject &obj)
QWidget * | createFilePathWidget (const QJsonObject &obj)
QWidget * | createIntegerWidget (const QJsonObject &obj)
QWidget * | createFloatWidget (const QJsonObject &obj)
QWidget * | createBooleanWidget (const QJsonObject &obj)
QWidget * | createTextWidget (const QJsonObject &obj)
QWidget * | createTableWidget (const QJsonObject &obj)
void | setOptionDefaults ()
void | setOption (const QString &name, const QJsonValue &defaultValue)
void | setStringListOption (const QString &name, const QJsonValue &value)
void | setStringOption (const QString &name, const QJsonValue &value)
void | setFilePathOption (const QString &name, const QJsonValue &value)
void | setIntegerOption (const QString &name, const QJsonValue &value)
void | setFloatOption (const QString &name, const QJsonValue &value)
void | setBooleanOption (const QString &name, const QJsonValue &value)
void | setTextOption (const QString &name, const QJsonValue &value)
void | setTableOption (const QString &name, const QJsonValue &value)

## Protected Attributes

QtGui::Molecule * | m_molecule
bool | m_isTabbed
QJsonObject | m_options
QJsonObject | m_optionCache
QList< QTextEdit * > | m_dirtyTextEdits
bool | m_empty
bool | m_batchMode
QFormLayout * | m_currentLayout
QWidget * | m_centralWidget
QMap< QString, QWidget * > | m_widgets
QMap< QString, QTextEdit * > | m_textEdits

## Detailed Description

<avogadro/qtgui/jsonwidget.h>

See also
  InterfaceWidget

The JsonWidget creates a GUI to represent the options given by an script, turning JSON from the script into a form and passing the results back to the script via command-line.

It's used by a range of different scripts, including:

- Commands
- InterfaceGenerators

## Constructor & Destructor Documentation

## JsonWidget()

JsonWidget | ( | QWidget * | parent_ = nullptr | ) |

explicit

Construct a widget that dynamically generates a GUI

## Member Function Documentation

## setMolecule()

virtual void setMolecule | ( | QtGui::Molecule * | mol | ) |

virtual

Set the molecule used in the simulation.

Reimplemented in InputGeneratorWidget.

## collectOptions()

QJsonObject collectOptions | ( |  | ) | const

Collect all of the user-specified options into a JSON object, to be sent to the generator script.

## applyOptions()

void applyOptions | ( | const QJsonObject & | opts | ) |

Apply the options in the passed QJsonObject to the GUI. Any widgets changed by this method will have their signals blocked while modifying their values.

## updatePreviewText

virtual void updatePreviewText | ( |  | ) |

virtual slot

Update the preview text in the GUI. The base implementation does nothing; subclasses that have a preview area (e.g. InputGeneratorWidget) override this to regenerate their preview when options change.

## lookupOptionType()

QString lookupOptionType | ( | const QString & | name | ) | const

protected

Given the name of a user-option in m_options, return the type string. If an error occurs, an empty string will be returned.

## updateOptions()

virtual void updateOptions | ( |  | ) |

protected virtual

Used to construct the script-specific GUI.

Reimplemented in InputGeneratorWidget.

## buildOptionGui()

void buildOptionGui | ( |  | ) |

protected

Used to construct the script-specific GUI.

## combinedOptionRow()

void combinedOptionRow | ( | const QString & | label1,
|  | const QString & | label2,
|  | const QString & | tr1,
|  | const QString & | tr2,
|  | QJsonObject & | options,
|  | bool | bothLabels = false )

protected

Used to construct the script-specific GUI.

## addOptionRow()

void addOptionRow | ( | const QString & | key,
|  | const QString & | label,
|  | const QJsonValue & | option )

protected

Used to construct the script-specific GUI.

## createOptionWidget()

QWidget * createOptionWidget | ( | const QJsonValue & | option | ) |

protected

Used to construct the script-specific GUI.

## createStringListWidget()

QWidget * createStringListWidget | ( | const QJsonObject & | obj | ) |

protected

Used to construct the script-specific GUI.

## createStringWidget()

QWidget * createStringWidget | ( | const QJsonObject & | obj | ) |

protected

Used to construct the script-specific GUI.

## createFilePathWidget()

QWidget * createFilePathWidget | ( | const QJsonObject & | obj | ) |

protected

Used to construct the script-specific GUI.

## createIntegerWidget()

QWidget * createIntegerWidget | ( | const QJsonObject & | obj | ) |

protected

Used to construct the script-specific GUI.

## createFloatWidget()

QWidget * createFloatWidget | ( | const QJsonObject & | obj | ) |

protected

Used to construct the script-specific GUI.

## createBooleanWidget()

QWidget * createBooleanWidget | ( | const QJsonObject & | obj | ) |

protected

Used to construct the script-specific GUI.

## createTextWidget()

QWidget * createTextWidget | ( | const QJsonObject & | obj | ) |

protected

Used to construct the script-specific GUI.

## createTableWidget()

QWidget * createTableWidget | ( | const QJsonObject & | obj | ) |

protected

Used to construct the script-specific GUI.

## setOptionDefaults()

void setOptionDefaults | ( |  | ) |

protected

Set the simulation settings to their default values.

## setOption()

void setOption | ( | const QString & | name,
|  | const QJsonValue & | defaultValue )

protected

Set the simulation settings to their default values.

## setStringListOption()

void setStringListOption | ( | const QString & | name,
|  | const QJsonValue & | value )

protected

Set the simulation settings to their default values.

## setStringOption()

void setStringOption | ( | const QString & | name,
|  | const QJsonValue & | value )

protected

Set the simulation settings to their default values.

## setFilePathOption()

void setFilePathOption | ( | const QString & | name,
|  | const QJsonValue & | value )

protected

Set the simulation settings to their default values.

## setIntegerOption()

void setIntegerOption | ( | const QString & | name,
|  | const QJsonValue & | value )

protected

Set the simulation settings to their default values.

## setFloatOption()

void setFloatOption | ( | const QString & | name,
|  | const QJsonValue & | value )

protected

Set the simulation settings to their default values.

## setBooleanOption()

void setBooleanOption | ( | const QString & | name,
|  | const QJsonValue & | value )

protected

Set the simulation settings to their default values.

## setTextOption()

void setTextOption | ( | const QString & | name,
|  | const QJsonValue & | value )

protected

Set the simulation settings to their default values.

## setTableOption()

void setTableOption | ( | const QString & | name,
|  | const QJsonValue & | value )

protected

Set the simulation settings to their default values.

## optionString()

bool optionString | ( | const QString & | option,
|  | QString & | value ) const

protected

Parameters

  option | The name of the option.
  value | String to overwrite with option value.

Returns
  True if value is overwritten, false if the option is not found or cannot be converted to a string.

## generateJobTitle()

QString generateJobTitle | ( |  | ) | const

protected

Update the autogenerated job title in the GUI.

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

- jsonwidget.h