2010-07-28 14:43:47 +00:00
|
|
|
/*
|
2015-06-10 21:27:11 +00:00
|
|
|
* This file Copyright (C) 2010-2015 Mnemosyne LLC
|
2010-07-28 14:43:47 +00:00
|
|
|
*
|
2014-12-21 23:49:39 +00:00
|
|
|
* It may be used under the GNU GPL versions 2 or 3
|
2014-01-19 01:09:44 +00:00
|
|
|
* or any future license endorsed by Mnemosyne LLC.
|
2010-07-28 14:43:47 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2015-06-10 21:27:11 +00:00
|
|
|
#include "TrackerModel.h"
|
|
|
|
#include "TrackerModelFilter.h"
|
2010-07-28 14:43:47 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
TrackerModelFilter::TrackerModelFilter(QObject* parent) :
|
2020-05-27 21:53:12 +00:00
|
|
|
QSortFilterProxyModel(parent)
|
2010-07-28 14:43:47 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void TrackerModelFilter::setShowBackupTrackers(bool b)
|
2010-07-28 14:43:47 +00:00
|
|
|
{
|
2020-05-27 21:53:12 +00:00
|
|
|
show_backups_ = b;
|
2017-04-19 12:04:45 +00:00
|
|
|
invalidateFilter();
|
2010-07-28 14:43:47 +00:00
|
|
|
}
|
|
|
|
|
2020-05-27 21:53:12 +00:00
|
|
|
bool TrackerModelFilter::filterAcceptsRow(int source_row, QModelIndex const& source_parent) const
|
2010-07-28 14:43:47 +00:00
|
|
|
{
|
2020-05-27 21:53:12 +00:00
|
|
|
QModelIndex index = sourceModel()->index(source_row, 0, source_parent);
|
2020-06-05 19:02:11 +00:00
|
|
|
auto const tracker_info = index.data(TrackerModel::TrackerRole).value<TrackerInfo>();
|
|
|
|
return show_backups_ || !tracker_info.st.is_backup;
|
2010-07-28 14:43:47 +00:00
|
|
|
}
|