-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
closes #37
- Loading branch information
Showing
4 changed files
with
69 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include "diffviewproxy.h" | ||
#include "treemodel.h" | ||
|
||
DiffViewProxy::DiffViewProxy(QObject* parent) | ||
: QSortFilterProxyModel(parent) | ||
{ | ||
setRecursiveFilteringEnabled(true); | ||
} | ||
|
||
void DiffViewProxy::setThreshhold(double threshhold) | ||
{ | ||
m_threshhold = threshhold; | ||
invalidateFilter(); | ||
} | ||
|
||
bool DiffViewProxy::filterAcceptsRow(int source_row, const QModelIndex& parent) const | ||
{ | ||
Q_UNUSED(parent); | ||
|
||
const auto model = qobject_cast<DiffViewModel*>(sourceModel()); | ||
|
||
const auto cost = | ||
model->data(model->index(source_row, DiffViewModel::NUM_BASE_COLUMNS), DiffViewModel::SortRole).toLongLong(); | ||
const auto t = std::abs(cost / 10'000.f); | ||
|
||
return t > m_threshhold; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#ifndef DIFFVIEWPROXY_H | ||
#define DIFFVIEWPROXY_H | ||
|
||
#include <QSortFilterProxyModel> | ||
|
||
class DiffViewProxy : public QSortFilterProxyModel | ||
{ | ||
public: | ||
explicit DiffViewProxy(QObject* parent = nullptr); | ||
|
||
void setThreshhold(double threshhold); | ||
|
||
protected: | ||
bool filterAcceptsRow(int source_row, const QModelIndex& parent) const override; | ||
|
||
private: | ||
double m_threshhold = 0.01; | ||
}; | ||
|
||
#endif // DIFFVIEWPROXY_H |