Spreadsheet
A description for Spreadsheet.
-
class Spreadsheet : public AbstractDataSource
Aspect providing a spreadsheet table with column logic.
Spreadsheet is a container object for columns with no data of its own. By definition, it’s columns are all of its children inheriting from class Column. Thus, the basic API is already defined by AbstractAspect (managing the list of columns, notification of column insertion/removal) and Column (changing and monitoring state of the actual data).
Spreadsheet is a data container for related columns to be treated as a single entity.
Spreadsheet stores a pointer to its primary view of class SpreadsheetView. SpreadsheetView calls the Spreadsheet API but Spreadsheet only notifies SpreadsheetView by signals without calling its API directly. This ensures a maximum independence of UI and backend. SpreadsheetView can be easily replaced by a different class. User interaction is completely handled in SpreadsheetView and translated into Spreadsheet API calls (e.g., when a user edits a cell this will be handled by the delegate of SpreadsheetView and Spreadsheet will not know whether a script or a user changed the data.). All actions, menus etc. for the user interaction are handled SpreadsheetView, e.g., via a context menu. Selections are also handled by SpreadsheetView. The view itself is created by the first call to view();
Subclassed by LiveDataSource, MQTTTopic, StatisticsSpreadsheet
Public Functions
-
explicit Spreadsheet(const QString &name, bool loading = false, AspectType type = AspectType::Spreadsheet)
Constructor.
Constructs a Spreadsheet with default 2 columns each with 100 rows.
- Parameters:
name – The Spreadsheet name.
-
~Spreadsheet() override
Destructor.
Destroys the Spreadsheet and its child columns.
-
virtual QIcon icon() const override
Returns an icon to be used for decorating my views.
-
virtual QMenu *createContextMenu() override
Returns a new context menu. The caller takes ownership of the menu.
-
virtual QWidget *view() const override
Constructs a primary view on me. This method may be called multiple times during the life time of an Aspect, or it might not get called at all. Aspects must not depend on the existence of a view for their operation.
-
StatisticsSpreadsheet *statisticsSpreadsheet() const
Returns a pointer to the StatisticsSpreadsheet for the current Spreadsheet if exists or nullptr.
See also
See also
- Returns:
StatisticsSpreadsheet* or nullptr
-
virtual QVector<AspectType> pasteTypes() const override
return the list of all aspect types that can be copy&pasted into the current aspect. returns an empty list on default, needs to be re-implemented in all derived classes that want to allow other aspects to be pasted into.
-
void updateHorizontalHeader()
Called when the application settings were changed. adjusts the appearance of the spreadsheet header.
-
void updateLocale()
Updates locale for all columns from QLocale.
-
int columnCount() const
Returns the number of columns in the Spreadsheet.
- Returns:
The number of columns in the Spreadsheet.
-
int columnCount(AbstractColumn::PlotDesignation) const
Returns the number of columns in the
Spreadsheetmatching the plot designation.- Parameters:
pd – The plot designation the columns are matched against.
- Returns:
The number of columns in the
Spreadsheetmatching the passed plot designation.
-
int rowCount() const
Returns the number of rows in the
Spreadsheet.- Returns:
The number of rows in the
Spreadsheet.
-
void removeRows(int first, int count)
Removes
countrows starting from thefirstrow index in the spreadsheet.- Parameters:
count – The number of rows to remove.
first – The row index to start removing rows from.
-
void insertRows(int before, int count)
Inserts
countrows before thebeforerow index in the spreadsheet.- Parameters:
count – The number of rows to insert.
before – The row index before which the rows are inserted.
-
void removeColumns(int first, int count)
Removes
countcolumns starting from thefirstcolumn index in the spreadsheet.- Parameters:
count – The number of columns to remove.
first – The column index to start removing column from.
-
void insertColumns(int before, int count)
Inserts
countcolumns before thebeforecolumn index in the spreadsheet.- Parameters:
count – The number of columns to insert.
before – The column index before which the columns are inserted.
-
QString text(int row, int col) const
Returns a text representation of the data in cell at
rowindex andcolindex.- Parameters:
row – The cell row.
col – The cell column.
- Returns:
Text representation of the data in cell.
-
virtual void save(QXmlStreamWriter*) const override
Saves as XML.
-
virtual bool load(XmlStreamReader*, bool preview) override
Loads from XML.
-
void setColumnSelectedInView(int index, bool selected)
Emits the signal to select or to deselect the column number
indexin the project explorer, ifselected=trueorselected=false, respectively. The signal is handled inAspectTreeModeland forwarded to the tree view inProjectExplorer. This function is called inSpreadsheetViewupon selection changes.
-
int resize(AbstractFileFilter::ImportMode, const QStringList &colNameList, int cols)
resize data source to cols columns returns column offset depending on import mode
Public Slots
-
void appendRows(int)
Inserts
countrows before the last row index in the spreadsheet.- Parameters:
count – The number of rows to insert.
-
void appendRow()
Inserts a row before the last row index in the spreadsheet.
-
void removeEmptyRows()
Removes all rows in the spreadsheet in which the value of one or more of its columns is missing/empty.
-
void maskEmptyRows()
Masks all rows in the spreadsheet in which the value of one or more of its columns is missing/empty.
-
void appendColumns(int)
Inserts
countcolumns before the last column index in the spreadsheet.- Parameters:
count – The number of columns to insert.
-
void appendColumn()
Inserts a column before the last column index in the spreadsheet.
-
void prependColumns(int)
Inserts
countcolumns before the first column index in the spreadsheet.- Parameters:
count – The number of columns to insert.
-
void setColumnCount(int)
Grows/shrinks the number of columns in the spreadsheet to
new_size.- Parameters:
new_size – The new number of columns in the spreadsheet.
-
void setRowCount(int)
Grows/shrinks the number of rows in the spreadsheet to
new_size.- Parameters:
new_size – The new number of rows in the spreadsheet.
-
void clear()
Clears all values in the spreadsheet.
-
void clear(const QVector<Column*>&)
Clears all values in the specified
columns.- Parameters:
columns – The columns in the spreadsheet to clear.
-
void clearMasks()
Clears all masks in the spreadsheet.
-
void moveColumn(int from, int to)
Move column at
fromindex totoindex.- Parameters:
from – The current index of the column.
to – The future index of the column.
-
void sortColumns(Column *leading, const QVector<Column*>&, bool ascending)
Clears all values in the specified columns.
- Parameters:
cols – The columns in the spreadsheet to clear.
-
void toggleStatisticsSpreadsheet(bool)
Toggles the StatisticsSpreadsheet for the current spreadsheet.
- Parameters:
on – Enable/disable the StatisticsSpreadsheet if true/false.
-
struct Linking
-
explicit Spreadsheet(const QString &name, bool loading = false, AspectType type = AspectType::Spreadsheet)