A better QTable for TOPPView, which supports exporting to TSV and conveniently adding data to cells and headers.
More...
#include <OpenMS/VISUAL/TableView.h>
|
| TableView (QWidget *parent=nullptr) |
| Constructor. More...
|
|
virtual | ~TableView ()=default |
| Destructor. More...
|
|
virtual void | exportEntries () |
| Export table entries as currently shown in the table in TSV format (only for visible data) More...
|
|
void | appendRow () |
| adds a new row to the bottom More...
|
|
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) More...
|
|
QTableWidgetItem * | setAtBottomRow (QTableWidgetItem *item, size_t column_index, const QColor &background, const QColor &foreground) |
| create a custom item (if above methods are not sufficient) More...
|
|
void | setHeaders (const QStringList &headers) |
| sets the visible headers (and the number of columns) More...
|
|
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. More...
|
|
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. More...
|
|
QString | getHeaderExportName (const int header_column) |
| Gets the export-name of a column. More...
|
|
QString | getHeaderName (const int header_column) |
|
A better QTable for TOPPView, which supports exporting to TSV and conveniently adding data to cells and headers.
◆ TableView()
◆ ~TableView()
◆ appendRow()
adds a new row to the bottom
◆ exportEntries()
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, ...).
◆ getHeaderExportName()
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
-
header_column | Index of column |
- Exceptions
-
◆ getHeaderName()
QString getHeaderName |
( |
const int |
header_column | ) |
|
get the displayed name of the header in column with index header_column
- Exceptions
-
◆ getHeaderNames()
QStringList getHeaderNames |
( |
const WidgetHeader |
which, |
|
|
bool |
use_export_name = false |
|
) |
| |
Obtain header names, either from all, or only the visible columns.
Headers can be obtained as shown (use_export_name
= false) or for exporting to CSV where the alternative export name is preferred (if exists). See setHeaderExportName().
- Parameters
-
which | With or without invisible columns? |
use_export_name | If column has a hidden export name, use that instead of the displayed name |
- Returns
- List of header names
◆ headerContextMenu_
void headerContextMenu_ |
( |
const QPoint & |
| ) |
|
|
protectedslot |
Display header context menu; allows to show/hide columns.
◆ hideColumns()
void hideColumns |
( |
const QStringList & |
header_names | ) |
|
hides columns with the given names
- Exceptions
-
◆ resized
emitted when the widget is resized
◆ resizeEvent()
void resizeEvent |
( |
QResizeEvent * |
event | ) |
|
|
overrideprotected |
◆ setAtBottomRow() [1/6]
QTableWidgetItem* setAtBottomRow |
( |
const bool |
selected, |
|
|
size_t |
column_index, |
|
|
const QColor & |
background, |
|
|
const QColor & |
foreground = QColor("SomeInvalidColor") |
|
) |
| |
create a checkbox item (with no text)
◆ setAtBottomRow() [2/6]
QTableWidgetItem* setAtBottomRow |
( |
const char * |
text, |
|
|
size_t |
column_index, |
|
|
const QColor & |
background, |
|
|
const QColor & |
foreground = QColor("SomeInvalidColor") |
|
) |
| |
◆ setAtBottomRow() [3/6]
QTableWidgetItem* setAtBottomRow |
( |
const double |
d, |
|
|
size_t |
column_index, |
|
|
const QColor & |
background, |
|
|
const QColor & |
foreground = QColor("SomeInvalidColor") |
|
) |
| |
◆ setAtBottomRow() [4/6]
QTableWidgetItem* setAtBottomRow |
( |
const int |
i, |
|
|
size_t |
column_index, |
|
|
const QColor & |
background, |
|
|
const QColor & |
foreground = QColor("SomeInvalidColor") |
|
) |
| |
◆ setAtBottomRow() [5/6]
QTableWidgetItem* setAtBottomRow |
( |
const QString & |
text, |
|
|
size_t |
column_index, |
|
|
const QColor & |
background, |
|
|
const QColor & |
foreground = QColor("SomeInvalidColor") |
|
) |
| |
◆ setAtBottomRow() [6/6]
QTableWidgetItem* setAtBottomRow |
( |
QTableWidgetItem * |
item, |
|
|
size_t |
column_index, |
|
|
const QColor & |
background, |
|
|
const QColor & |
foreground |
|
) |
| |
create a custom item (if above methods are not sufficient)
◆ setHeaderExportName()
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
-
header_column | Index of column |
export_name | New export name to set |
- Exceptions
-
◆ setHeaders()
void setHeaders |
( |
const QStringList & |
headers | ) |
|
sets the visible headers (and the number of columns)
◆ updateCheckBoxItem()
static void updateCheckBoxItem |
( |
QTableWidgetItem * |
item | ) |
|
|
static |
if the item is purely a checkbox (e.g. added with setAtBottomRow(const bool selected, ...)), we set its DisplayRole to either '' or ' ', depending on checked state, to allow for row sorting This function should be called whenever the check-state of the item changes