QtPdCom  1.5.2
TableModel Class Reference

Table model. More...

#include <TableModel.h>

Inheritance diagram for TableModel:
Collaboration diagram for TableModel:

Classes

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

Public Slots

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

Signals

void editingChanged (bool)

Public Member Functions

 TableModel (QObject *parent=nullptr)
 Constructor.
 ~TableModel ()
 Destructor.
void addColumn (TableColumn *)
 Adds a column.
void insertColumn (TableColumn *, int position)
void removeColumn (TableColumn *)
void clearColumns ()
 Clears the Columns.
bool isEditing () const
unsigned int getRowCapacity () const
bool hasVisibleRowsVariable () const
virtual int rowCount (const QModelIndex &) const
 Implements the model interface.
virtual int columnCount (const QModelIndex &) const
 Implements the model interface.
virtual QVariant data (const QModelIndex &, int) const
 Implements the Model interface.
virtual QVariant headerData (int, Qt::Orientation, int) const
 Implements the Model interface.
virtual Qt::ItemFlags flags (const QModelIndex &) const
 Implements the Model interface.
virtual bool setData (const QModelIndex &, const QVariant &, int)
bool insertRows (int position, int count=1, const QModelIndex &parent={}) override
 updates the visibleRowCount variable.
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.
void setHighlightRowVariable (PdCom::Process *, const QString &, const PdCom::Selector &={}, const Transmission &=QtPdCom::event_mode)
 Subscribe to a process variable for highlighting a row.
void clearHighlightRowVariable ()
Q_INVOKABLE QString toCsv (bool includeHeader, QChar seperator=QChar(','), const QLocale &locale=QLocale::c()) const
 Export table as CSV file.
Q_INVOKABLE int fromCsv (QString csvData, QChar seperator=QChar(','), int startRow=0, int startColumn=0, const QLocale &locale=QLocale::c())
 Import CSV file.
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.
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.
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.
void columnHeaderChanged ()
 Reacts on header data changes.
void valueChanged ()
 Reacts on process variable changes.
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)

Constructor.

◆ ~TableModel()

Destructor.

Member Function Documentation

◆ addColumn()

Adds a column.

◆ addRow

void TableModel::addRow ( )
slot

updates the visibleRowCount variable.

◆ addRowAndCopyLast

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

◆ clearColumns()

Clears the Columns.

◆ clearHighlightRowVariable()

◆ clearVisibleRowsVariable()

◆ columnCount()

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

Implements the model interface.

Returns
Number of columns.

◆ columnHeaderChanged

void TableModel::columnHeaderChanged ( )
privateslot

Reacts on header data changes.

◆ commit

void TableModel::commit ( )
slot

Commits all edited data.

◆ data()

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

Implements the Model interface.

◆ dimensionChanged

void TableModel::dimensionChanged ( )
privateslot

Reacts on process variable dimension changes.

◆ editingChanged

◆ flags()

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

Implements the Model interface.

◆ 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 \n .

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.

◆ getRowCapacity()

unsigned int TableModel::getRowCapacity ( ) const

◆ hasVisibleRowsVariable()

◆ headerData()

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

Implements the Model interface.

◆ highlightRowChanged

void TableModel::highlightRowChanged ( )
privateslot

◆ 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.

◆ isEditing()

bool TableModel::isEditing ( ) const

◆ removeColumn()

◆ removeRows()

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

◆ remRow

void TableModel::remRow ( )
slot

◆ revert

void TableModel::revert ( )
slot

Reverts all edited data.

◆ 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.

◆ setData()

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

◆ setDisabledColor()

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

◆ setHighlightColor()

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

◆ setHighlightRowVariable() [1/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.

◆ setHighlightRowVariable() [2/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.

◆ setVisibleRowsVariable() [1/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.

◆ setVisibleRowsVariable() [2/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.

◆ 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.

◆ valueChanged

void TableModel::valueChanged ( )
privateslot

Reacts on process variable changes.

◆ visibleRowCountChanged

void TableModel::visibleRowCountChanged ( )
privateslot

Member Data Documentation

◆ Impl

class Q_DECL_HIDDEN QtPdCom::TableModel::Impl
private

◆ impl

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

Property Documentation

◆ editing


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