Serial Studio 1.1.6
A dashboard software for your embedded projects
JSON::Editor Class Reference

The Editor class. More...

#include <Editor.h>

Inheritance diagram for JSON::Editor:
Inheritance graph
Collaboration diagram for JSON::Editor:
Collaboration graph

Public Slots

void newJsonFile ()
 
void openJsonFile ()
 
void openJsonFile (const QString &path)
 
void setTitle (const QString &title)
 
void setSeparator (const QString &separator)
 
void setFrameEndSequence (const QString &sequence)
 
void setFrameStartSequence (const QString &sequence)
 
void addGroup ()
 
void deleteGroup (const int group)
 
void moveGroupUp (const int group)
 
void moveGroupDown (const int group)
 
void setGroupTitle (const int group, const QString &title)
 
void setGroupWidgetData (const int group, const QString &widget)
 
void addDataset (const int group)
 
void deleteDataset (const int group, const int dataset)
 
void setDatasetWidget (const int group, const int dataset, const int widgetId)
 
void setDatasetTitle (const int group, const int dataset, const QString &title)
 
void setDatasetUnits (const int group, const int dataset, const QString &units)
 
void setDatasetIndex (const int group, const int dataset, const int frameIndex)
 
void setDatasetLED (const int group, const int dataset, const bool generateLED)
 
void setDatasetGraph (const int group, const int dataset, const bool generateGraph)
 
void setDatasetFftPlot (const int group, const int dataset, const bool generateFft)
 
void setDatasetLogPlot (const int group, const int dataset, const bool generateLog)
 
void setDatasetWidgetMin (const int group, const int dataset, const QString &minimum)
 
void setDatasetWidgetMax (const int group, const int dataset, const QString &maximum)
 
void setDatasetWidgetData (const int group, const int dataset, const QString &widget)
 
void setDatasetWidgetAlarm (const int group, const int dataset, const QString &alarm)
 
void setDatasetFFTSamples (const int group, const int dataset, const QString &samples)
 

Signals

void titleChanged ()
 
void jsonFileChanged ()
 
void modifiedChanged ()
 
void separatorChanged ()
 
void groupCountChanged ()
 
void groupOrderChanged ()
 
void frameEndSequenceChanged ()
 
void frameStartSequenceChanged ()
 
void groupChanged (const int group)
 
void datasetChanged (const int group, const int dataset)
 

Public Member Functions

Q_INVOKABLE StringList availableGroupLevelWidgets ()
 
Q_INVOKABLE StringList availableDatasetLevelWidgets ()
 
QString jsonProjectsPath () const
 
QString title () const
 
QString separator () const
 
QString frameEndSequence () const
 
QString frameStartSequence () const
 
bool modified () const
 
int groupCount () const
 
QString jsonFilePath () const
 
QString jsonFileName () const
 
Q_INVOKABLE bool askSave ()
 
Q_INVOKABLE bool saveJsonFile ()
 
Q_INVOKABLE int datasetCount (const int group) const
 
Q_INVOKABLE const GroupgetGroup (const int index) const
 
Q_INVOKABLE const JSON::DatasetgetDataset (const int group, const int index) const
 
Q_INVOKABLE QString groupTitle (const int group) const
 
Q_INVOKABLE QString groupWidget (const int group) const
 
Q_INVOKABLE int groupWidgetIndex (const int group) const
 
Q_INVOKABLE int datasetIndex (const int group, const int dataset) const
 
Q_INVOKABLE bool datasetLED (const int group, const int dataset) const
 
Q_INVOKABLE bool datasetGraph (const int group, const int dataset) const
 
Q_INVOKABLE bool datasetFftPlot (const int group, const int dataset) const
 
Q_INVOKABLE bool datasetLogPlot (const int group, const int dataset) const
 
Q_INVOKABLE QString datasetTitle (const int group, const int dataset) const
 
Q_INVOKABLE QString datasetUnits (const int group, const int dataset) const
 
Q_INVOKABLE QString datasetWidget (const int group, const int dataset) const
 
Q_INVOKABLE int datasetWidgetIndex (const int group, const int dataset) const
 
Q_INVOKABLE QString datasetWidgetMin (const int group, const int dataset) const
 
Q_INVOKABLE QString datasetWidgetMax (const int group, const int dataset) const
 
Q_INVOKABLE QString datasetFFTSamples (const int group, const int dataset) const
 
Q_INVOKABLE QString datasetWidgetAlarm (const int group, const int dataset) const
 
Q_INVOKABLE bool setGroupWidget (const int group, const int widgetId)
 

Static Public Member Functions

static Editorinstance ()
 

Properties

int groupCount
 
bool modified
 
QString title
 
QString separator
 
QString frameEndSequence
 
QString frameStartSequence
 
QString jsonFilePath
 
QString jsonFileName
 

Private Slots

void onJsonLoaded ()
 
void onModelChanged ()
 
void onGroupChanged (const int group)
 
void setModified (const bool modified)
 
void onDatasetChanged (const int group, const int dataset)
 

Private Member Functions

 Editor ()
 
 Editor (Editor &&)=delete
 
 Editor (const Editor &)=delete
 
Editoroperator= (Editor &&)=delete
 
Editoroperator= (const Editor &)=delete
 
int nextDatasetIndex ()
 

Private Attributes

QString m_title
 
QString m_separator
 
QString m_frameEndSequence
 
QString m_frameStartSequence
 
bool m_modified
 
QString m_filePath
 
QVector< Groupm_groups
 

Detailed Description

The Editor class.

The editor class allows the representation of a Serial Studio JSON project file in the graphical user interface.

Additionaly, the class facilitates the modificiation of a project file or the creation of new JSON project files.

Constructor & Destructor Documentation

◆ Editor() [1/3]

JSON::Editor::Editor ( )
explicitprivate

Constructor function. Initializes internal members and configures the signals/slots so that the editor can know if the user modified the JSON document. Finally, the constructor configures signals/slots with the JSON Generator to share the same JSON document file.

◆ Editor() [2/3]

JSON::Editor::Editor ( Editor &&  )
privatedelete

◆ Editor() [3/3]

JSON::Editor::Editor ( const Editor )
privatedelete

Member Function Documentation

◆ addDataset

void JSON::Editor::addDataset ( const int  group)
slot

Adds a new dataset to the given group & increments the frame index counter (to avoid having datasets that pull data from the same position in the MCU frame).

◆ addGroup

void JSON::Editor::addGroup ( )
slot

Adds a new group to the C++ model that represents the JSON project file.

◆ askSave()

bool JSON::Editor::askSave ( )

Checks if the current project has been modified and prompts the user to save his/her changes.

◆ availableDatasetLevelWidgets()

StringList JSON::Editor::availableDatasetLevelWidgets ( )

Returns a list with the available dataset-level widgets. This list is used by the user interface to allow the user to build gauge, bar & compass widgets directly from the UI.

◆ availableGroupLevelWidgets()

StringList JSON::Editor::availableGroupLevelWidgets ( )

Returns a list with the available group-level widgets. This list is used by the user interface to allow the user to build accelerometer, gyro & map widgets directly from the UI.

◆ datasetChanged

void JSON::Editor::datasetChanged ( const int  group,
const int  dataset 
)
signal

◆ datasetCount()

int JSON::Editor::datasetCount ( const int  group) const

Returns the number of datasets contained by the given group index.

◆ datasetFftPlot()

bool JSON::Editor::datasetFftPlot ( const int  group,
const int  dataset 
) const

Returns true if Serial Studio should graph the data of the given dataset (which is contained by the specified group).

Parameters
groupindex of the group in which the dataset belongs
datasetindex of the dataset

◆ datasetFFTSamples()

QString JSON::Editor::datasetFFTSamples ( const int  group,
const int  dataset 
) const

Returns the maximum FFT frequency value of the specified dataset.

Parameters
groupindex of the group in which the dataset belongs
datasetindex of the dataset

◆ datasetGraph()

bool JSON::Editor::datasetGraph ( const int  group,
const int  dataset 
) const

Returns true if Serial Studio should graph the data of the given dataset (which is contained by the specified group).

Parameters
groupindex of the group in which the dataset belongs
datasetindex of the dataset

◆ datasetIndex()

int JSON::Editor::datasetIndex ( const int  group,
const int  dataset 
) const

Returns the position in the frame that holds the value for the given dataset (which is contained by the specified group).

Parameters
groupindex of the group in which the dataset belongs
datasetindex of the dataset

◆ datasetLED()

bool JSON::Editor::datasetLED ( const int  group,
const int  dataset 
) const

Returns true if Serial Studio should generate a LED with the given dataset (which is contained by the specified group).

Parameters
groupindex of the group in which the dataset belongs
datasetindex of the dataset

◆ datasetLogPlot()

bool JSON::Editor::datasetLogPlot ( const int  group,
const int  dataset 
) const

Returns true if Serial Studio should graph the data of the given dataset (which is contained by the specified group) with a logarithmic scale.

Parameters
groupindex of the group in which the dataset belongs
datasetindex of the dataset

◆ datasetTitle()

QString JSON::Editor::datasetTitle ( const int  group,
const int  dataset 
) const

Returns the title of the specified dataset.

Parameters
groupindex of the group in which the dataset belongs
datasetindex of the dataset

◆ datasetUnits()

QString JSON::Editor::datasetUnits ( const int  group,
const int  dataset 
) const

Returns the measurement units of the specified dataset.

Parameters
groupindex of the group in which the dataset belongs
datasetindex of the dataset

◆ datasetWidget()

QString JSON::Editor::datasetWidget ( const int  group,
const int  dataset 
) const

Returns the widget string of the specified dataset.

Parameters
groupindex of the group in which the dataset belongs
datasetindex of the dataset

◆ datasetWidgetAlarm()

QString JSON::Editor::datasetWidgetAlarm ( const int  group,
const int  dataset 
) const

Returns the widget alarm value of the specified dataset. This option is used by the bar & gauge widgets.

Parameters
groupindex of the group in which the dataset belongs
datasetindex of the dataset

◆ datasetWidgetIndex()

int JSON::Editor::datasetWidgetIndex ( const int  group,
const int  dataset 
) const

Returns the widget ID of the specified dataset. The widget ID corresponds to the list returned by the availableDatasetLevelWidgets() function.

Parameters
groupindex of the group in which the dataset belongs
datasetindex of the dataset

◆ datasetWidgetMax()

QString JSON::Editor::datasetWidgetMax ( const int  group,
const int  dataset 
) const

Returns the maximum widget value of the specified dataset. This option is used by the bar & gauge widgets.

Parameters
groupindex of the group in which the dataset belongs
datasetindex of the dataset

◆ datasetWidgetMin()

QString JSON::Editor::datasetWidgetMin ( const int  group,
const int  dataset 
) const

Returns the minimum widget value of the specified dataset. This option is used by the bar & gauge widgets.

Parameters
groupindex of the group in which the dataset belongs
datasetindex of the dataset

◆ deleteDataset

void JSON::Editor::deleteDataset ( const int  group,
const int  dataset 
)
slot

Removes the given dataset from the specified group.

Parameters
groupindex of the group in which the dataset belongs
datasetindex of the dataset

◆ deleteGroup

void JSON::Editor::deleteGroup ( const int  group)
slot

Removes the given group from the C++ model that represents the JSON project file.

◆ frameEndSequence()

QString JSON::Editor::frameEndSequence ( ) const

Returns the frame end sequence for the current project.

◆ frameEndSequenceChanged

void JSON::Editor::frameEndSequenceChanged ( )
signal

◆ frameStartSequence()

QString JSON::Editor::frameStartSequence ( ) const

Returns the frame start sequence for the current project.

◆ frameStartSequenceChanged

void JSON::Editor::frameStartSequenceChanged ( )
signal

◆ getDataset()

const JSON::Dataset & JSON::Editor::getDataset ( const int  group,
const int  index 
) const

Returns a pointer to the dataset object contained by the group at the given index

◆ getGroup()

const JSON::Group & JSON::Editor::getGroup ( const int  index) const

Returns a pointer to the group object positioned at the given index

◆ groupChanged

void JSON::Editor::groupChanged ( const int  group)
signal

◆ groupCount()

int JSON::Editor::groupCount ( ) const

Returns the number of groups contained in the current JSON project.

◆ groupCountChanged

void JSON::Editor::groupCountChanged ( )
signal

◆ groupOrderChanged

void JSON::Editor::groupOrderChanged ( )
signal

◆ groupTitle()

QString JSON::Editor::groupTitle ( const int  group) const

Returns the title of the given group.

◆ groupWidget()

QString JSON::Editor::groupWidget ( const int  group) const

Returns the widget of the given group.

◆ groupWidgetIndex()

int JSON::Editor::groupWidgetIndex ( const int  group) const

Returns the widget ID of the given group. The widget ID is a number that represents a group-level widget. The ID depends on the widget type and the order of the widgets returned by the availableGroupLevelWidgets() function.

◆ instance()

JSON::Editor & JSON::Editor::instance ( )
static

Returns a pointer to the only instance of the editor class.

◆ jsonFileChanged

void JSON::Editor::jsonFileChanged ( )
signal

◆ jsonFileName()

QString JSON::Editor::jsonFileName ( ) const

Returns the simplified file name of the current JSON project file. This is used to change the title of the Editor window.

◆ jsonFilePath()

QString JSON::Editor::jsonFilePath ( ) const

Returns the full path of the current JSON project file.

◆ jsonProjectsPath()

QString JSON::Editor::jsonProjectsPath ( ) const

Returns the default path for saving JSON project files

◆ modified()

bool JSON::Editor::modified ( ) const

Returns true if the user modified the current project. This is used to know if Serial Studio shall prompt the user to save his/her modifications before closing the editor window.

◆ modifiedChanged

void JSON::Editor::modifiedChanged ( )
signal

◆ moveGroupDown

void JSON::Editor::moveGroupDown ( const int  group)
slot

Changes the position of the given group in the C++ model.

◆ moveGroupUp

void JSON::Editor::moveGroupUp ( const int  group)
slot

Changes the position of the given group in the C++ model.

◆ newJsonFile

void JSON::Editor::newJsonFile ( )
slot

Resets the C++ model used to represent the JSON project file.

◆ nextDatasetIndex()

int JSON::Editor::nextDatasetIndex ( )
private

Gets the number of datasets registered in the projects and adds 1 to the result.

This function is used when registering new datasets, so that the user does not need to manually specify dataset indexes.

◆ onDatasetChanged

void JSON::Editor::onDatasetChanged ( const int  group,
const int  dataset 
)
privateslot

Sets the modified flag to true when the user modifies the properties of one of the datasets contained in the JSON project.

Parameters
groupindex of the group in which the dataset belongs
datasetindex of the dataset

◆ onGroupChanged

void JSON::Editor::onGroupChanged ( const int  group)
privateslot

Sets the modified flag to true when the user changes the title or the widget of one of the groups contained in the JSON project.

◆ onJsonLoaded

void JSON::Editor::onJsonLoaded ( )
privateslot

Ensures that the JSON project file is the same as the one used by the JSON Generator class.

◆ onModelChanged

void JSON::Editor::onModelChanged ( )
privateslot

Sets the modified flag to true when the user adds/removes/moves one of the groups contained in the JSON project.

◆ openJsonFile [1/2]

void JSON::Editor::openJsonFile ( )
slot

Prompts the user to select a JSON project file & generates the appropiate C++ model that represents the JSON document.

◆ openJsonFile [2/2]

void JSON::Editor::openJsonFile ( const QString &  path)
slot

Opens the JSON document at the given path & generates the appropiate C++ model that represents the JSON document.

◆ operator=() [1/2]

Editor & JSON::Editor::operator= ( const Editor )
privatedelete

◆ operator=() [2/2]

Editor & JSON::Editor::operator= ( Editor &&  )
privatedelete

◆ saveJsonFile()

bool JSON::Editor::saveJsonFile ( )

Validates the configuration of the current JSON project and saves the JSON document on the hard disk.

◆ separator()

QString JSON::Editor::separator ( ) const

Returns the data separator sequence for the current project.

◆ separatorChanged

void JSON::Editor::separatorChanged ( )
signal

◆ setDatasetFftPlot

void JSON::Editor::setDatasetFftPlot ( const int  group,
const int  dataset,
const bool  generateFft 
)
slot

Updates the generateFft flag of the given dataset.

Parameters
groupindex of the group in which the dataset belongs
datasetindex of the dataset

◆ setDatasetFFTSamples

void JSON::Editor::setDatasetFFTSamples ( const int  group,
const int  dataset,
const QString &  samples 
)
slot

Updates the samples used for FFT plotting.

Parameters
groupindex of the group in which the dataset belongs
datasetindex of the dataset

◆ setDatasetGraph

void JSON::Editor::setDatasetGraph ( const int  group,
const int  dataset,
const bool  generateGraph 
)
slot

Updates the generateGraph flag of the given dataset.

Parameters
groupindex of the group in which the dataset belongs
datasetindex of the dataset

◆ setDatasetIndex

void JSON::Editor::setDatasetIndex ( const int  group,
const int  dataset,
const int  frameIndex 
)
slot

Updates the frameIndex of the given dataset.

Parameters
groupindex of the group in which the dataset belongs
datasetindex of the dataset

◆ setDatasetLED

void JSON::Editor::setDatasetLED ( const int  group,
const int  dataset,
const bool  generateLED 
)
slot

Updates the generateLED flag of the given dataset.

Parameters
groupindex of the group in which the dataset belongs
datasetindex of the dataset

◆ setDatasetLogPlot

void JSON::Editor::setDatasetLogPlot ( const int  group,
const int  dataset,
const bool  generateLog 
)
slot

Updates the generateLog flag of the given dataset.

Parameters
groupindex of the group in which the dataset belongs
datasetindex of the dataset

◆ setDatasetTitle

void JSON::Editor::setDatasetTitle ( const int  group,
const int  dataset,
const QString &  title 
)
slot

Updates the title of the given dataset.

Parameters
groupindex of the group in which the dataset belongs
datasetindex of the dataset

◆ setDatasetUnits

void JSON::Editor::setDatasetUnits ( const int  group,
const int  dataset,
const QString &  units 
)
slot

Updates the measurement units of the given dataset.

Parameters
groupindex of the group in which the dataset belongs
datasetindex of the dataset

◆ setDatasetWidget

void JSON::Editor::setDatasetWidget ( const int  group,
const int  dataset,
const int  widgetId 
)
slot

Updates the widgetId of the given dataset. The widget ID is dependent on the order of the widgets returned by the availableDatasetLevelWidgets() function.

Parameters
groupindex of the group in which the dataset belongs
datasetindex of the dataset

◆ setDatasetWidgetAlarm

void JSON::Editor::setDatasetWidgetAlarm ( const int  group,
const int  dataset,
const QString &  alarm 
)
slot

Updates the alarm value used by the bar & gauge widgets for the given dataset. The value is specified in a QString to facilitate integration with the QML user interface.

Parameters
groupindex of the group in which the dataset belongs
datasetindex of the dataset

◆ setDatasetWidgetData

void JSON::Editor::setDatasetWidgetData ( const int  group,
const int  dataset,
const QString &  widget 
)
slot

Updates the widget string of the given dataset.

Parameters
groupindex of the group in which the dataset belongs
datasetindex of the dataset

◆ setDatasetWidgetMax

void JSON::Editor::setDatasetWidgetMax ( const int  group,
const int  dataset,
const QString &  maximum 
)
slot

Updates the maximum value used by the bar & gauge widgets for the given dataset. The value is specified in a QString to facilitate integration with the QML user interface.

Parameters
groupindex of the group in which the dataset belongs
datasetindex of the dataset

◆ setDatasetWidgetMin

void JSON::Editor::setDatasetWidgetMin ( const int  group,
const int  dataset,
const QString &  minimum 
)
slot

Updates the minimum value used by the bar & gauge widgets for the given dataset. The value is specified in a QString to facilitate integration with the QML user interface.

Parameters
groupindex of the group in which the dataset belongs
datasetindex of the dataset

◆ setFrameEndSequence

void JSON::Editor::setFrameEndSequence ( const QString &  sequence)
slot

Changes the frame end sequence of the JSON project file.

◆ setFrameStartSequence

void JSON::Editor::setFrameStartSequence ( const QString &  sequence)
slot

Changes the frame start sequence of the JSON project file.

◆ setGroupTitle

void JSON::Editor::setGroupTitle ( const int  group,
const QString &  title 
)
slot

Changes the title for the given group in the C++ model

◆ setGroupWidget()

bool JSON::Editor::setGroupWidget ( const int  group,
const int  widgetId 
)

Changes the group-level widget for the specified group. If necessary, this function shall generate the appropiate datasets needed to implement the widget (e.g. x,y,z for accelerometer widgets).

◆ setGroupWidgetData

void JSON::Editor::setGroupWidgetData ( const int  group,
const QString &  widget 
)
slot

Changes the widget for the given group in the C++ model

◆ setModified

void JSON::Editor::setModified ( const bool  modified)
privateslot

Updates the modified flag of the current JSON project. This flag is used to know if we should ask the user to save his/her modifications to the project file.

◆ setSeparator

void JSON::Editor::setSeparator ( const QString &  separator)
slot

Changes the data separator sequence of the JSON project file.

◆ setTitle

void JSON::Editor::setTitle ( const QString &  title)
slot

Changes the title of the JSON project file.

◆ title()

QString JSON::Editor::title ( ) const

Returns the title of the current project

◆ titleChanged

void JSON::Editor::titleChanged ( )
signal

Member Data Documentation

◆ m_filePath

QString JSON::Editor::m_filePath
private

◆ m_frameEndSequence

QString JSON::Editor::m_frameEndSequence
private

◆ m_frameStartSequence

QString JSON::Editor::m_frameStartSequence
private

◆ m_groups

QVector<Group> JSON::Editor::m_groups
private

◆ m_modified

bool JSON::Editor::m_modified
private

◆ m_separator

QString JSON::Editor::m_separator
private

◆ m_title

QString JSON::Editor::m_title
private

Property Documentation

◆ frameEndSequence

QString JSON::Editor::frameEndSequence
readwrite

◆ frameStartSequence

QString JSON::Editor::frameStartSequence
readwrite

◆ groupCount

int JSON::Editor::groupCount
read

◆ jsonFileName

QString JSON::Editor::jsonFileName
read

◆ jsonFilePath

QString JSON::Editor::jsonFilePath
read

◆ modified

bool JSON::Editor::modified
read

◆ separator

QString JSON::Editor::separator
readwrite

◆ title

QString JSON::Editor::title
readwrite

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