AbstractColumn

A description for AbstractColumn.

class AbstractColumn : public AbstractAspect

Interface definition for data with column logic.

This is an abstract base class for column-based data, i.e. mathematically a vector or technically a 1D array or list. It only defines the interface but has no data members itself.

Classes derived from this are typically table columns or outputs of filters which can be chained between table columns and plots. From the point of view of the plot functions there will be no difference between a table column and a filter output since both use this interface.

Classes derived from this will either store a vector with entries of one certain data type, e.g. double, QString, QDateTime, or generate such values on demand. To determine the data type of a class derived from this, use the columnMode() function. AbstractColumn defines all access functions for all supported data types but only those corresponding to the return value of columnMode() will return a meaningful value. Calling functions not belonging to the data type of the column is safe, but will do nothing (writing function) or return some default value (reading functions).

This class also defines all signals which indicate a data change. Any class whose output values are subject to change over time must emit the according signals. These signals notify any object working with the column before and after a change of the column. In some cases it will be necessary for a class using the column to connect aboutToBeDestroyed(), to react to a column’s deletion, e.g. a filter’s reaction to a table deletion.

All writing functions have a “do nothing” standard implementation to make deriving a read-only class very easy without bothering about the writing interface.

Subclassed by Column, ColumnStringIO, SimpleFilterColumn

type specific functions

virtual QString textAt(int row) const

Return the content of row ‘row’.

Use this only when columnMode() is Text

virtual void setTextAt(int row, const QString &new_value)

Set the content of row ‘row’.

Use this only when columnMode() is Text

virtual void replaceTexts(int first, const QVector<QString> &new_values)

Replace a range of values.

Use this only when columnMode() is Text

virtual int dictionaryIndex(int row) const

Return the position/index in the dictionary for the text value at.

Use this only when columnMode() is Text

Parameters:

row

virtual QDate dateAt(int row) const

Return the date part of row ‘row’.

Use this only when columnMode() is DateTime, Month or Day

virtual void setDateAt(int row, QDate new_value)

Set the content of row ‘row’.

Use this only when columnMode() is DateTime, Month or Day

virtual QTime timeAt(int row) const

Return the time part of row ‘row’.

Use this only when columnMode() is DateTime, Month or Day

virtual void setTimeAt(int row, QTime new_value)

Set the content of row ‘row’.

Use this only when columnMode() is DateTime, Month or Day

virtual QDateTime dateTimeAt(int row) const

Return the QDateTime in row ‘row’.

Use this only when columnMode() is DateTime, Month or Day

virtual void setDateTimeAt(int row, const QDateTime &new_value)

Set the content of row ‘row’.

Use this only when columnMode() is DateTime, Month or Day

virtual void replaceDateTimes(int first, const QVector<QDateTime> &new_values)

Replace a range of values.

Use this only when columnMode() is DateTime, Month or Day

virtual double doubleAt(int row) const

Return the double value in row ‘row’.

Use this only when columnMode() is Numeric

virtual double valueAt(int row) const

Return the double value in row ‘row’ independent of the column mode.

Integer and big integer values are converted to double, NAN is returned for other modes.

virtual void setValueAt(int row, double new_value)

Set the content of row ‘row’.

Use this only when columnMode() is Numeric

virtual void replaceValues(int first, const QVector<double> &new_values)

Replace a range of values.

Use this only when columnMode() is Numeric

virtual int integerAt(int row) const

Return the integer value in row ‘row’.

Use this only when columnMode() is Integer

virtual void setIntegerAt(int row, int new_value)

Set the content of row ‘row’.

Use this only when columnMode() is Integer

virtual void replaceInteger(int first, const QVector<int> &new_values)

Replace a range of values.

Use this only when columnMode() is Integer

virtual qint64 bigIntAt(int row) const

Return the bigint value in row ‘row’.

Use this only when columnMode() is BigInt

virtual void setBigIntAt(int row, qint64 new_value)

Set the content of row ‘row’.

Use this only when columnMode() is BigInt

virtual void replaceBigInt(int first, const QVector<qint64> &new_values)

Replace a range of values.

Use this only when columnMode() is BigInt

virtual Properties properties() const

Returns the properties hold by this column (no, constant, monotonic increasing, monotonic decreasing,…) Is used in XYCurve to improve the search velocity for the y value for a specific x value

void plotDesignationAboutToChange(const AbstractColumn *source)

Column plot designation will be changed.

‘source’ is always the this pointer of the column that emitted this signal. This way it’s easier to use one handler for lots of columns.

void plotDesignationChanged(const AbstractColumn *source)

Column plot designation changed.

‘source’ is always the this pointer of the column that emitted this signal. This way it’s easier to use one handler for lots of columns.

void modeAboutToChange(const AbstractColumn *source)

Column mode (possibly also the data type) will be changed.

‘source’ is always the this pointer of the column that emitted this signal. This way it’s easier to use one handler for lots of columns.

void modeChanged(const AbstractColumn *source)

Column mode (possibly also the data type) changed.

‘source’ is always the this pointer of the column that emitted this signal. This way it’s easier to use one handler for lots of columns.

void dataAboutToChange(const AbstractColumn *source)

Data of the column will be changed.

‘source’ is always the this pointer of the column that emitted this signal. This way it’s easier to use one handler for lots of columns.

void dataChanged(const AbstractColumn *source)

Data of the column has changed.

Important: When data has changed also the number of rows in the column may have changed without any other signal emission. ‘source’ is always the this pointer of the column that emitted this signal. This way it’s easier to use one handler for lots of columns.

void rowsAboutToBeInserted(const AbstractColumn *source, int before, int count)

rowsAboutToBeInserted

Rows will be inserted.

Parameters:
  • source

  • before – Old number of rows

  • count – Number of rows added

  • source – the column that emitted the signal

  • before – the row to insert before

  • count – the number of rows to be inserted

void rowsInserted(const AbstractColumn *source, int before, int count)

rowsInserted

Rows have been inserted.

Parameters:
  • source

  • before – Old number of rows

  • count – Number of rows added

  • source – the column that emitted the signal

  • before – the row to insert before

  • count – the number of rows to be inserted

void rowsAboutToBeRemoved(const AbstractColumn *source, int first, int count)

rowsAboutToBeRemoved

Rows will be deleted.

Parameters:
  • source

  • first – Old number of rows

  • count – Number of rows removed

  • source – the column that emitted the signal

  • first – the first row to be deleted

  • count – the number of rows to be deleted

void rowsRemoved(const AbstractColumn *source, int first, int count)

rowsRemoved

Rows have been deleted.

Parameters:
  • source

  • first – Old number of rows

  • count – Number of rows removed

  • source – the column that emitted the signal

  • first – the first row that was deleted

  • count – the number of deleted rows

void maskingAboutToChange(const AbstractColumn *source)

Rows are about to be masked or unmasked.

void maskingChanged(const AbstractColumn *source)

Rows have been masked or unmasked.

void aboutToBeDestroyed(const AbstractColumn *source)

Emitted shortl before this column is deleted.

This is needed by AbstractFilter.

Parameters:

source – the object emitting this signal

bool isMasked(int row) const

Return whether a certain row is masked.

bool isMasked(const Interval<int> &i) const

Return whether a certain interval of rows is fully masked.

QVector<Interval<int>> maskedIntervals() const

Return all intervals of masked rows.

void clearMasks()

Clear all masking information.

void setMasked(const Interval<int> &i, bool mask = true)

Set an interval masked.

Parameters:
  • i – the interval

  • mask – true: mask, false: unmask

void setMasked(int row, bool mask = true)

Overloaded function for convenience.

virtual QString formula(int row) const

Return the formula associated with row ‘row’.

virtual QVector<Interval<int>> formulaIntervals() const

Return the intervals that have associated formulas.

This can be used to make a list of formulas with their intervals. Here is some example code:

QStringList list;
QVector< Interval<int> > intervals = my_column.formulaIntervals();
foreach(Interval<int> interval, intervals)
    list << QString(interval.toString() + ": " + my_column.formula(interval.start()));
virtual void setFormula(const Interval<int> &i, const QString &formula)

Set a formula string for an interval of rows.

virtual void setFormula(int row, const QString &formula)

Overloaded function for convenience.

virtual void clearFormulas()

Clear all formulas.

void reset()

resets the connections for the dependent objects like plots and formulas in other columns to the dataChanged signal in the current column.

void setChanged()

invalidates the internal properties of the columns and emits the signal dataChanged().

call this function if the data of the column was changed directly via the data()-pointer and not via the setValueAt() or when multiple cells are being notified and the signal dataChanged() is suppressed for performance reasons and this function needs to be called after all cells were modified.

void setSuppressDataChangedSignal(const bool)

suppresses the dataChanged signal if value is true, enables it otherwise.

used when multiple cells are being modified and the signal needs to be suppressed for performance reasons,

See also

setChanged().

Public Functions

AbstractColumn(const QString &name, AspectType type)

Ctor.

Parameters:

name – the column name (= aspect name)

inline virtual bool isReadOnly() const

Return whether the object is read-only.

virtual ColumnMode columnMode() const = 0

Return the column mode.

This function is most used by tables but can also be used by plots. The column mode specifies how to interpret the values in the column additional to the data type.

virtual void setColumnMode(AbstractColumn::ColumnMode)

Set the column mode.

This sets the column mode and, if necessary, converts it to another datatype.

virtual PlotDesignation plotDesignation() const = 0

Return the column plot designation.

virtual void setPlotDesignation(AbstractColumn::PlotDesignation)

Set the column plot designation.

virtual bool copy(const AbstractColumn *source)

Copy another column of the same type.

This function will return false if the data type of ‘other’ is not the same as the type of ‘this’. Use a filter to convert a column to another type.

virtual bool copy(const AbstractColumn *source, int source_start, int dest_start, int num_rows)

Copies part of another column of the same type.

This function will return false if the data type of ‘other’ is not the same as the type of ‘this’.

Parameters:
  • source – pointer to the column to copy

  • source_start – first row to copy in the column to copy

  • destination_start – first row to copy in

  • num_rows – the number of rows to copy

virtual int rowCount() const = 0

Return the data vector size.

virtual int availableRowCount(int max = -1) const = 0

Return the number of available data rows.

void insertRows(int before, int count)

Insert some empty (or initialized with invalid values) rows.

void removeRows(int first, int count)

Remove ‘count’ rows starting from row ‘first’.

virtual void clear()

Clear the whole column.

bool isValid(int row) const

Convenience method for mode-independent testing of validity.

Public Static Functions

static QString timeUnitString(TimeUnit)

Convenience method for getting time unit string translated since used in UI.

static QString plotDesignationString(PlotDesignation, bool withBrackets = true)

Convenience method for getting plot designation string translated since used in UI.

static QString columnModeString(ColumnMode)

Convenience method for getting mode string translated since used in UI.

static QIcon modeIcon(ColumnMode)

Convenience method for mode-dependent icon.

struct ColumnStatistics
struct HeatmapFormat