Skip to content
Snippets Groups Projects
Commit 995046c4 authored by Edward Brown's avatar Edward Brown
Browse files

Added QtFilterLeafNodes from batch_widget_prototype branch.

Re #22263
parent 0166f454
No related branches found
No related tags found
No related merge requests found
...@@ -84,6 +84,7 @@ set ( SRC_FILES ...@@ -84,6 +84,7 @@ set ( SRC_FILES
src/Batch/JobTreeView.cpp src/Batch/JobTreeView.cpp
src/Batch/JobTreeViewSignalAdapter.cpp src/Batch/JobTreeViewSignalAdapter.cpp
src/Batch/QtStandardItemTreeAdapter.cpp src/Batch/QtStandardItemTreeAdapter.cpp
src/Batch/QtFilterLeafNodes.cpp
src/Batch/QtTreeCursorNavigation.cpp src/Batch/QtTreeCursorNavigation.cpp
src/Batch/CellDelegate.cpp src/Batch/CellDelegate.cpp
src/Batch/BuildSubtree.cpp src/Batch/BuildSubtree.cpp
...@@ -399,6 +400,7 @@ set ( INC_FILES ...@@ -399,6 +400,7 @@ set ( INC_FILES
inc/MantidQtWidgets/Common/FindFilesWorker.h inc/MantidQtWidgets/Common/FindFilesWorker.h
inc/MantidQtWidgets/Common/Batch/QtStandardItemTreeAdapter.h inc/MantidQtWidgets/Common/Batch/QtStandardItemTreeAdapter.h
inc/MantidQtWidgets/Common/Batch/QtTreeCursorNavigation.h inc/MantidQtWidgets/Common/Batch/QtTreeCursorNavigation.h
inc/MantidQtWidgets/Common/Batch/QtFilterLeafNodes.h
inc/MantidQtWidgets/Common/Batch/RowLocation.h inc/MantidQtWidgets/Common/Batch/RowLocation.h
inc/MantidQtWidgets/Common/Batch/Row.h inc/MantidQtWidgets/Common/Batch/Row.h
inc/MantidQtWidgets/Common/Batch/CellDelegate.h inc/MantidQtWidgets/Common/Batch/CellDelegate.h
......
#ifndef MANTIDQTMANTIDWIDGETS_FILTERLEAFNODES_H_
#define MANTIDQTMANTIDWIDGETS_FILTERLEAFNODES_H_
#include <QSortFilterProxyModel>
namespace MantidQt {
namespace MantidWidgets {
namespace Batch {
class QtFilterLeafNodes : public QSortFilterProxyModel {
public:
QtFilterLeafNodes(QObject *parent = nullptr);
protected:
bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
};
}
}
}
#endif // MANTIDQTMANTIDWIDGETS_FILTERLEAFNODES_H_
#include "MantidQtWidgets/Common/Batch/QtFilterLeafNodes.h"
namespace MantidQt {
namespace MantidWidgets {
namespace Batch {
QtFilterLeafNodes::QtFilterLeafNodes(QObject *parent)
: QSortFilterProxyModel(parent){}
bool QtFilterLeafNodes::filterAcceptsRow(int row,
const QModelIndex &parent) const {
auto index = sourceModel()->index(row, 0, parent);
if (index.isValid()) {
if (index.data().toString().contains(filterRegExp()))
return true;
int rows = sourceModel()->rowCount(index);
for (auto r = 0; r < rows; r++)
if (filterAcceptsRow(r, index))
return true;
return false;
} else {
return false;
}
}
}
}
}
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