HAL
selection_tree_proxy.cpp
Go to the documentation of this file.
3 
4 #include "gui/gui_globals.h"
5 
6 namespace hal
7 {
9  : SearchProxyModel(parent), mSortMechanism(gui_utility::mSortMechanism::lexical), mGraphicsBusy(0)
10  {
12  }
13 
14  bool SelectionTreeProxyModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
15  {
16  return checkRowRecursion(source_row, source_parent, 0, 2);
17  }
18 
19  bool SelectionTreeProxyModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const
20  {
21  QString name_left = source_left.data().toString();
22  QString name_right = source_right.data().toString();
24  {
25  name_left = name_left.toLower();
26  name_right = name_right.toLower();
27  }
28 
29  bool comparison = gui_utility::compare(mSortMechanism, name_left, name_right);
30 
31  // if left element is a structure element (these must be handled specially)
32  // (right element must then also be a structure element)
33  if (source_left.data(Qt::UserRole).toBool())
34  {
35  // forces "Gates" to be before "Nets" regardless of sort order
36  comparison ^= (sortOrder() == Qt::AscendingOrder);
37  }
38 
39  return comparison;
40  }
41 
42  /*void SelectionTreeProxyModel::applyFilterOnGraphics()
43  {
44  if (isGraphicsBusy()) return;
45  ++ mGraphicsBusy;
46  QList<u32> modIds;
47  QList<u32> gatIds;
48  QList<u32> netIds;
49  static_cast<const SelectionTreeModel*>(sourceModel())->suppressedByFilter(modIds, gatIds, netIds, mFilterExpression);
50  gSelectionRelay->suppressedByFilter(modIds, gatIds, netIds);
51  -- mGraphicsBusy;
52  }*/
53 
54  /*void SelectionTreeProxyModel::handleFilterTextChanged(const QString& filter_text)
55  {
56  mFilterExpression.setPattern(filter_text);
57  invalidateFilter();
58  applyFilterOnGraphics();
59  }*/
60 
62  {
63  return mSortMechanism;
64  }
65 
67  {
68  mSortMechanism = sortMechanism;
69  invalidate();
70  }
71 
73  {
74  mSearchString = text;
75  mSearchOptions = SearchOptions(options);
77  }
78 
79 }
SearchOptions mSearchOptions
virtual bool checkRowRecursion(int sourceRow, const QModelIndex &sourceParent, int startIndex, int endIndex, int offset=0) const
void setSortMechanism(gui_utility::mSortMechanism sortMechanism)
void startSearch(QString text, int options) override
gui_utility::mSortMechanism sortMechanism()
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
SelectionTreeProxyModel(QObject *parent=nullptr)
int compare(mSortMechanism mechanism, QString a, QString b)
Definition: sort.cpp:153
QVariant data(int role) const const
void setPatternOptions(QRegularExpression::PatternOptions options)
Qt::SortOrder sortOrder() const const
QString toLower() const const
CaseInsensitive
UserRole
AscendingOrder
bool toBool() const const
QString toString() const const