QtPdCom  1.3.3
Classes | Public Slots | Signals | Public Member Functions | Properties | Private Slots | Private Attributes | List of all members
QtPdCom::TableModel Class Reference

Table model. More...

#include <TableModel.h>

Inheritance diagram for QtPdCom::TableModel:
Inheritance graph
[legend]
Collaboration diagram for QtPdCom::TableModel:
Collaboration graph
[legend]

Classes

struct  Exception
 Exception type. More...
 
class  Impl
 Table model. More...
 

Public Slots

void commit ()
 Commits all edited data. More...
 
void revert ()
 Reverts all edited data. More...
 
void addRow ()
 updates the visibleRowCount variable. More...
 
void addRowAndCopyLast ()
 updates the visibleRowCount variable with initialization. More...
 
void remRow ()
 

Signals

void editingChanged (bool)
 

Public Member Functions

 TableModel (QObject *parent=nullptr)
 Constructor. More...
 
 ~TableModel ()
 Destructor. More...
 
void addColumn (TableColumn *)
 Adds a column. More...
 
void insertColumn (TableColumn *, int position)
 
void removeColumn (TableColumn *)
 
void clearColumns ()
 Clears the Columns. More...
 
bool isEditing () const
 
unsigned int getRowCapacity () const
 
bool hasVisibleRowsVariable () const
 
virtual int rowCount (const QModelIndex &) const
 Implements the model interface. More...
 
virtual int columnCount (const QModelIndex &) const
 Implements the model interface. More...
 
virtual QVariant data (const QModelIndex &, int) const
 Implements the Model interface. More...
 
virtual QVariant headerData (int, Qt::Orientation, int) const
 Implements the Model interface. More...
 
virtual Qt::ItemFlags flags (const QModelIndex &) const
 Implements the Model interface. More...
 
virtual bool setData (const QModelIndex &, const QVariant &, int)
 
bool insertRows (int position, int count=1, const QModelIndex &parent={}) override
 updates the visibleRowCount variable. More...
 
bool removeRows (int row, int count, const QModelIndex &parent={}) override
 
void setHighlightRowVariable (PdCom::Variable, const PdCom::Selector &={}, const Transmission &=QtPdCom::event_mode)
 Subscribe to a process variable for highlighting a row. More...
 
void setHighlightRowVariable (PdCom::Process *, const QString &, const PdCom::Selector &={}, const Transmission &=QtPdCom::event_mode)
 Subscribe to a process variable for highlighting a row. More...
 
void clearHighlightRowVariable ()
 
Q_INVOKABLE QString toCsv (bool includeHeader, QChar seperator=QChar(','), const QLocale &locale=QLocale::c()) const
 Export table as CSV file. More...
 
Q_INVOKABLE int fromCsv (QString csvData, QChar seperator=QChar(','), int startRow=0, int startColumn=0, const QLocale &locale=QLocale::c())
 Import CSV file. More...
 
void setVisibleRowsVariable (PdCom::Variable pv, const PdCom::Selector &={}, const Transmission &=QtPdCom::event_mode)
 Subscribe to a process variable for setting the visible rows of the Table, this is most often a parameter which also gets updated if the Table row count gets changed by editing. More...
 
void setVisibleRowsVariable (PdCom::Process *, const QString &, const PdCom::Selector &={}, const Transmission &=QtPdCom::event_mode)
 Subscribe to a process variable for setting the visible rows of the Table, this is most often a parameter which also gets updated if the Table row count gets changed by editing. More...
 
void clearVisibleRowsVariable ()
 
void setHighlightColor (QColor, int=-1)
 
void setDisabledColor (QColor, int=-1)
 
QHash< int, QByteArray > roleNames () const override
 

Properties

bool editing
 

Private Slots

void dimensionChanged ()
 Reacts on process variable dimension changes. More...
 
void columnHeaderChanged ()
 Reacts on header data changes. More...
 
void valueChanged ()
 Reacts on process variable changes. More...
 
void highlightRowChanged ()
 
void visibleRowCountChanged ()
 

Private Attributes

class Q_DECL_HIDDEN Impl
 
std::unique_ptr< Implimpl
 

Detailed Description

Table model.

See also
TableColumn.

Constructor & Destructor Documentation

◆ TableModel()

TableModel::TableModel ( QObject *  parent = nullptr)

◆ ~TableModel()

TableModel::~TableModel ( )

Destructor.

References clearColumns(), and impl.

Member Function Documentation

◆ addColumn()

void TableModel::addColumn ( TableColumn column)

Adds a column.

References insertColumn().

◆ addRow

void TableModel::addRow ( )
slot

updates the visibleRowCount variable.

References impl.

Referenced by addRowAndCopyLast().

◆ addRowAndCopyLast

void TableModel::addRowAndCopyLast ( )
slot

updates the visibleRowCount variable with initialization.

if value is a scalar all columns will be initialized with the same value otherwise must be a QVariantList

References addRow(), editingChanged(), impl, and isEditing().

◆ clearColumns()

void TableModel::clearColumns ( )

Clears the Columns.

References columnHeaderChanged(), dimensionChanged(), impl, and valueChanged().

Referenced by ~TableModel().

◆ clearHighlightRowVariable()

void TableModel::clearHighlightRowVariable ( )

References impl.

Referenced by setHighlightRowVariable().

◆ clearVisibleRowsVariable()

void TableModel::clearVisibleRowsVariable ( )

References impl.

Referenced by setVisibleRowsVariable().

◆ columnCount()

int TableModel::columnCount ( const QModelIndex &  index) const
virtual

Implements the model interface.

Returns
Number of columns.

References impl.

◆ columnHeaderChanged

void TableModel::columnHeaderChanged ( )
privateslot

Reacts on header data changes.

References impl.

Referenced by clearColumns(), and insertColumn().

◆ commit

void TableModel::commit ( )
slot

Commits all edited data.

References editingChanged(), and impl.

◆ data()

QVariant TableModel::data ( const QModelIndex &  index,
int  role 
) const
virtual

Implements the Model interface.

References impl.

◆ dimensionChanged

void TableModel::dimensionChanged ( )
privateslot

Reacts on process variable dimension changes.

References impl.

Referenced by clearColumns(), and insertColumn().

◆ editingChanged

void QtPdCom::TableModel::editingChanged ( bool  )
signal

◆ flags()

Qt::ItemFlags TableModel::flags ( const QModelIndex &  index) const
virtual

Implements the Model interface.

References impl.

◆ fromCsv()

int TableModel::fromCsv ( QString  csvData,
QChar  seperator = QChar(','),
int  startRow = 0,
int  startColumn = 0,
const QLocale &  locale = QLocale::c() 
)

Import CSV file.

Also switch to edit mode. Numbers are expected to be formatted in Posix ("C") format, lines are separated by unix newlines .

Parameters
separatorColumn separator character, default , .
startRowFirst row to import, default 0.
startColumnFirst Column to import, default 0.
localeLocale for string conversion, default C Locale.
Returns
Number of imported rows, < 0 on error.

References editingChanged(), impl, isEditing(), and rowCount().

◆ getRowCapacity()

unsigned int TableModel::getRowCapacity ( ) const

References impl.

◆ hasVisibleRowsVariable()

bool TableModel::hasVisibleRowsVariable ( ) const

References impl.

Referenced by insertRows(), and removeRows().

◆ headerData()

QVariant TableModel::headerData ( int  section,
Qt::Orientation  o,
int  role 
) const
virtual

Implements the Model interface.

References impl.

◆ highlightRowChanged

void TableModel::highlightRowChanged ( )
privateslot

References impl.

Referenced by TableModel().

◆ insertColumn()

void TableModel::insertColumn ( TableColumn col,
int  position 
)

◆ insertRows()

bool TableModel::insertRows ( int  position,
int  count = 1,
const QModelIndex &  parent = {} 
)
override

updates the visibleRowCount variable.

References editingChanged(), hasVisibleRowsVariable(), impl, and isEditing().

◆ isEditing()

bool TableModel::isEditing ( ) const

◆ removeColumn()

void QtPdCom::TableModel::removeColumn ( TableColumn column)

◆ removeRows()

bool TableModel::removeRows ( int  row,
int  count,
const QModelIndex &  parent = {} 
)
override

References hasVisibleRowsVariable(), and impl.

Referenced by remRow().

◆ remRow

void TableModel::remRow ( )
slot

References impl, and removeRows().

◆ revert

void TableModel::revert ( )
slot

Reverts all edited data.

References editingChanged(), and impl.

◆ roleNames()

QHash< int, QByteArray > TableModel::roleNames ( ) const
override

◆ rowCount()

int TableModel::rowCount ( const QModelIndex &  index) const
virtual

Implements the model interface.

Returns
Number of rows.

References impl.

Referenced by fromCsv(), and toCsv().

◆ setData()

bool TableModel::setData ( const QModelIndex &  index,
const QVariant &  value,
int  role 
)
virtual

References editingChanged(), impl, and isEditing().

◆ setDisabledColor()

void TableModel::setDisabledColor ( QColor  dc,
int  idx = -1 
)

References impl.

◆ setHighlightColor()

void TableModel::setHighlightColor ( QColor  hc,
int  idx = -1 
)

References impl.

◆ setHighlightRowVariable() [1/2]

void TableModel::setHighlightRowVariable ( PdCom::Variable  pv,
const PdCom::Selector &  selector = {},
const Transmission transmission = QtPdCom::event_mode 
)

Subscribe to a process variable for highlighting a row.

The variable value determines the highlighted row.

Parameters
pvProcess variable.
selectorSelector.
transmissionTransmission.

References clearHighlightRowVariable(), and impl.

◆ setHighlightRowVariable() [2/2]

void TableModel::setHighlightRowVariable ( PdCom::Process *  process,
const QString &  path,
const PdCom::Selector &  selector = {},
const Transmission transmission = QtPdCom::event_mode 
)

Subscribe to a process variable for highlighting a row.

The variable value determines the highlighted row.

Parameters
processProcess variable.
pathVariable path.
selectorSelector.
transmissionTransmission.

References clearHighlightRowVariable(), and impl.

◆ setVisibleRowsVariable() [1/2]

void TableModel::setVisibleRowsVariable ( PdCom::Variable  pv,
const PdCom::Selector &  selector = {},
const Transmission transmission = QtPdCom::event_mode 
)

Subscribe to a process variable for setting the visible rows of the Table, this is most often a parameter which also gets updated if the Table row count gets changed by editing.

Parameters
pvProcess variable.
selectorSelector.
transmissionTransmission.

References clearVisibleRowsVariable(), and impl.

◆ setVisibleRowsVariable() [2/2]

void TableModel::setVisibleRowsVariable ( PdCom::Process *  process,
const QString &  path,
const PdCom::Selector &  selector = {},
const Transmission transmission = QtPdCom::event_mode 
)

Subscribe to a process variable for setting the visible rows of the Table, this is most often a parameter which also gets updated if the Table row count gets changed by editing.

Parameters
processProcess variable.
pathVariable path.
selectorSelector.
transmissionTransmission.

References clearVisibleRowsVariable(), and impl.

◆ toCsv()

QString TableModel::toCsv ( bool  includeHeader,
QChar  seperator = QChar(','),
const QLocale &  locale = QLocale::c() 
) const

Export table as CSV file.

Parameters
includeHeaderUse column headers as first row.
separatorSeparator character, default ,
localeLocale for string conversion, default C Locale.
Returns
QString which contains the table data in CSV format.

References impl, and rowCount().

◆ valueChanged

void TableModel::valueChanged ( )
privateslot

Reacts on process variable changes.

References QtPdCom::TableColumn::getRows(), and impl.

Referenced by clearColumns(), insertColumn(), and TableModel().

◆ visibleRowCountChanged

void TableModel::visibleRowCountChanged ( )
privateslot

References impl, and isEditing().

Referenced by TableModel().

Member Data Documentation

◆ Impl

class Q_DECL_HIDDEN QtPdCom::TableModel::Impl
private

◆ impl

std::unique_ptr<Impl> QtPdCom::TableModel::impl
private

Property Documentation

◆ editing

bool QtPdCom::TableModel::editing
read

Referenced by isEditing().


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