HAL
grouping_proxy_model.cpp
Go to the documentation of this file.
1 
2 
3 
4 
6 
7 #include "gui/gui_globals.h"
8 
9 namespace hal
10 {
12  {
13 
14  }
15 
16  bool GroupingProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const
17  {
18  return checkRow(sourceRow, sourceParent, 0, 2);
19  }
20 
21  bool GroupingProxyModel::lessThan(const QModelIndex& source_left, const QModelIndex& source_right) const
22  {
23  // FILTERKEYCOLUMN SHOULD BE EITHER 0 OR 1
24 
25  if (filterKeyColumn() == 0)
26  {
27  QString name_left = source_left.data().toString();
28  QString name_right = source_right.data().toString();
29 
31  {
32  name_left = name_left.toLower();
33  name_right = name_right.toLower();
34  }
35 
36  return gui_utility::compare(mSortMechanism, name_left, name_right);
37  }
38  else
39  return source_left.data().toInt() < source_right.data().toInt();
40 
41  }
42 
44  {
45  return mSortMechanism;
46  }
47 
49  {
50  mSortMechanism = sortMechanism;
51  invalidate();
52  }
53  void GroupingProxyModel::startSearch(QString text, int options)
54  {
55  mSearchString = text;
56  mSearchOptions = SearchOptions(options);
58  }
59 }
void setSortMechanism(gui_utility::mSortMechanism sortMechanism)
void startSearch(QString text, int options) override
gui_utility::mSortMechanism sortMechanism()
GroupingProxyModel(QObject *parent=nullptr)
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override
SearchOptions mSearchOptions
bool checkRow(int sourceRow, const QModelIndex &sourceParent, int startIndex, int endIndex, int offset=0) const
Should be called inside filterAcceptsRow function and returns true if the source_row,...
int compare(mSortMechanism mechanism, QString a, QString b)
Definition: sort.cpp:153
QVariant data(int role) const const
QString toLower() const const
CaseInsensitive
int toInt(bool *ok) const const
QString toString() const const