Skip to content
Snippets Groups Projects
Commit 06fc76e8 authored by Peterson, Peter's avatar Peterson, Peter
Browse files

Re #7099. Adding hiding and showing columns to PeaksWorkspaceWidget.

This a step towards having the visible columns settable.
parent 26d4a956
No related branches found
No related tags found
No related merge requests found
......@@ -15,6 +15,8 @@ namespace SliceViewer
Q_OBJECT
public:
PeaksWorkspaceWidget(Mantid::API::IPeaksWorkspace_const_sptr ws, const std::string& coordinateSystem, const QColor& defaultForegroundColour, const QColor& defaultBackgroundColour, QWidget *parent = 0);
std::set<QString> getShownColumns();
void setShownColumns(std::set<QString> & cols);
virtual ~PeaksWorkspaceWidget();
signals:
void peakColourChanged(Mantid::API::IPeaksWorkspace_const_sptr, QColor);
......
......@@ -71,6 +71,7 @@ namespace MantidQt
typedef std::map<ColumnNameType, bool> ColumnNameSortableMap;
typedef std::map<int, ColumnNameType> ColumnIndexNameMap;
public:
/// Label for run number column
static const QString RUNNUMBER;
/// Label for detector id column
......@@ -112,6 +113,7 @@ namespace MantidQt
/// Label for Q-vector in the sample column
static const QString QSAMPLE;
private:
/// Index for run number column
static const int COL_RUNNUMBER;
/// Index for detector id column
......
......@@ -45,6 +45,30 @@ namespace MantidQt
populate();
}
std::set<QString> PeaksWorkspaceWidget::getShownColumns()
{
std::set<QString> result;
auto numCols = ui.tblPeaks->model()->columnCount();
for (auto i = 0; i < numCols; ++i)
{
if (!ui.tblPeaks->isColumnHidden(i))
result.insert(ui.tblPeaks->model()->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString());
}
return result;
}
void PeaksWorkspaceWidget::setShownColumns(std::set<QString> & cols)
{
auto numCols = ui.tblPeaks->model()->columnCount();
for (auto i = 0; i < numCols; ++i)
{
const QString name = ui.tblPeaks->model()->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString();
bool hide(cols.find(name) == cols.end());
ui.tblPeaks->setColumnHidden(i, hide);
}
}
/**
Populate controls with data ready for rendering.
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment