transmission/qt/tracker-model-filter.cc

37 lines
991 B
C++
Raw Normal View History

/*
* This file Copyright (C) 2010-2014 Mnemosyne LLC
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* $Id$
*/
#include "tracker-model.h"
#include "tracker-model-filter.h"
2013-09-14 22:45:04 +00:00
TrackerModelFilter :: TrackerModelFilter (QObject * parent):
QSortFilterProxyModel (parent),
myShowBackups (false)
{
}
void
2013-09-14 22:45:04 +00:00
TrackerModelFilter :: setShowBackupTrackers (bool b)
{
2013-09-14 22:45:04 +00:00
myShowBackups = b;
invalidateFilter ();
}
bool
2013-09-14 22:45:04 +00:00
TrackerModelFilter :: filterAcceptsRow (int sourceRow,
const QModelIndex & sourceParent) const
{
2013-09-14 22:45:04 +00:00
QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
const TrackerInfo trackerInfo = index.data(TrackerModel::TrackerRole).value<TrackerInfo>();
return myShowBackups || !trackerInfo.st.isBackup;
}