Skip to content

Commit

Permalink
re #9868 regex filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
NickDraper committed Aug 19, 2014
1 parent 203d0e8 commit 3f36947
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Code/Mantid/MantidPlot/src/Mantid/MantidDock.cpp
Expand Up @@ -65,7 +65,9 @@ MantidDockWidget::MantidDockWidget(MantidUI *mui, ApplicationWindow *parent) :
buttonLayout->addWidget(m_sortButton);

m_workspaceFilter = new MantidQt::MantidWidgets::LineEditWithClear();
m_workspaceFilter->setPlaceholderText("Search Workspaces");
m_workspaceFilter->setPlaceholderText("Filter Workspaces");
m_workspaceFilter->setToolTip("Type here to filter the workspaces");

connect(m_workspaceFilter, SIGNAL(textChanged(const QString&)), this, SLOT(filterWorkspaceTree(const QString&)));

QVBoxLayout * layout = new QVBoxLayout();
Expand Down Expand Up @@ -660,6 +662,7 @@ void MantidDockWidget::addClearMenuItems(QMenu* menu, const QString& wsName)
void MantidDockWidget::filterWorkspaceTree(const QString &text)
{
const QString filterText = text.stripWhiteSpace();
QRegExp filterRegEx (filterText,false);

//show all items
QTreeWidgetItemIterator it(m_tree);
Expand All @@ -685,7 +688,7 @@ void MantidDockWidget::filterWorkspaceTree(const QString &text)
if (workspace)
{
//I am a workspace
if (item->text(0).contains(filterText,false))
if (item->text(0).contains(filterRegEx))
{
//my name does match the filter
if(auto group = boost::dynamic_pointer_cast<WorkspaceGroup>(workspace))
Expand Down Expand Up @@ -747,7 +750,7 @@ void MantidDockWidget::filterWorkspaceTree(const QString &text)
//display a message if items are hidden
if (hiddenCount > 0)
{
QString headerString = QString("Workspaces (%1 hidden)").arg(QString::number(hiddenCount));
QString headerString = QString("Workspaces (%1 filtered)").arg(QString::number(hiddenCount));
m_tree->headerItem()->setText(0,headerString);
}
else
Expand Down

0 comments on commit 3f36947

Please sign in to comment.