A better QTable for TOPPView, which supports exporting to TSV and conveniently adding data to cells and headers.
More...
|
| | TableView (QWidget *parent=nullptr) |
| | Constructor.
|
| |
| | ~TableView () override=default |
| | Destructor.
|
| |
| virtual void | exportEntries () |
| | Export table entries as currently shown in the table in TSV format (only for visible data)
|
| |
| void | appendRow () |
| | adds a new row to the bottom
|
| |
| QTableWidgetItem * | setAtBottomRow (const QString &text, size_t column_index, const QColor &background, const QColor &foreground=QColor("SomeInvalidColor")) |
| |
| QTableWidgetItem * | setAtBottomRow (const char *text, size_t column_index, const QColor &background, const QColor &foreground=QColor("SomeInvalidColor")) |
| |
| QTableWidgetItem * | setAtBottomRow (const int i, size_t column_index, const QColor &background, const QColor &foreground=QColor("SomeInvalidColor")) |
| |
| QTableWidgetItem * | setAtBottomRow (const double d, size_t column_index, const QColor &background, const QColor &foreground=QColor("SomeInvalidColor")) |
| |
| QTableWidgetItem * | setAtBottomRow (const bool selected, size_t column_index, const QColor &background, const QColor &foreground=QColor("SomeInvalidColor")) |
| | create a checkbox item (with no text)
|
| |
| QTableWidgetItem * | setAtBottomRow (QTableWidgetItem *item, size_t column_index, const QColor &background, const QColor &foreground) |
| | create a custom item (if above methods are not sufficient)
|
| |
| void | setHeaders (const QStringList &headers) |
| | sets the visible headers (and the number of columns)
|
| |
| void | hideColumns (const QStringList &header_names) |
| |
| QStringList | getHeaderNames (const WidgetHeader which, bool use_export_name=false) |
| | Obtain header names, either from all, or only the visible columns.
|
| |
| void | setHeaderExportName (const int header_column, const QString &export_name) |
| | Set the export-name of a column, which will be returned in getHeaderNames() when use_export_name it true.
|
| |
| QString | getHeaderExportName (const int header_column) |
| | Gets the export-name of a column.
|
| |
| QString | getHeaderName (const int header_column) |
| |
| void | setMandatoryExportColumns (QStringList &cols) |
| | Set the mandatory export columns cols which get exported even if the user decided to hide them.
|
| |
A better QTable for TOPPView, which supports exporting to TSV and conveniently adding data to cells and headers.
| virtual void exportEntries |
( |
| ) |
|
|
virtual |
Export table entries as currently shown in the table in TSV format (only for visible data)
A filename will be queried using a dialog, before exporting.
Headers will be exported using their export name (if available, see setHeaderExportName()).
All cells will be queried for their Qt::UserRole, then for Qt::DisplayRole and last for Qt::CheckStateRole. The first item to return data will be used! Thus, to export data which differs from the visible (==DisplayRole), use QTableWidgetItem::setData(Qt::UserRole, ...).
Note: to force export of hidden columns use setMandatoryExportColumns()
| QString getHeaderExportName |
( |
const int |
header_column | ) |
|
Gets the export-name of a column.
Export names are useful when exporting the table to CSV (see exportEntries()), and the column header should be a bit more verbose.
Internally, this queries the Qt::UserRole's data to get the value. If the export name was not set (using setHeaderExportName()), it returns the display name.
- Parameters
-
| [in] | header_column | Index of column |
- Exceptions
-
| Exception::ElementNotFound | if header at index header_column is not valid |
| void setHeaderExportName |
( |
const int |
header_column, |
|
|
const QString & |
export_name |
|
) |
| |
Set the export-name of a column, which will be returned in getHeaderNames() when use_export_name it true.
Export names are useful when exporting the table to CSV (see exportEntries()), and the column header should be a bit more verbose.
Internally, this uses the Qt::UserRole's data to store the value.
- Parameters
-
| [in] | header_column | Index of column |
| [in] | export_name | New export name to set |
- Exceptions
-
| Exception::ElementNotFound | if header at index header_column is not valid |