| Line |
Branch |
Exec |
Source |
| 1 |
|
|
/***************************************************************************** |
| 2 |
|
|
* |
| 3 |
|
|
* Copyright (C) 2009 - 2024 Bjarne von Horn <vh@igh.de> |
| 4 |
|
|
* |
| 5 |
|
|
* This file is part of the QtPdCom library. |
| 6 |
|
|
* |
| 7 |
|
|
* The QtPdCom library is free software: you can redistribute it and/or modify |
| 8 |
|
|
* it under the terms of the GNU Lesser General Public License as published by |
| 9 |
|
|
* the Free Software Foundation, either version 3 of the License, or (at your |
| 10 |
|
|
* option) any later version. |
| 11 |
|
|
* |
| 12 |
|
|
* The QtPdCom library is distributed in the hope that it will be useful, but |
| 13 |
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 14 |
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public |
| 15 |
|
|
* License for more details. |
| 16 |
|
|
* |
| 17 |
|
|
* You should have received a copy of the GNU Lesser General Public License |
| 18 |
|
|
* along with the QtPdCom Library. If not, see <http://www.gnu.org/licenses/>. |
| 19 |
|
|
* |
| 20 |
|
|
****************************************************************************/ |
| 21 |
|
|
|
| 22 |
|
|
#include "MessageModelFilter.h" |
| 23 |
|
|
#include "MessageModel.h" |
| 24 |
|
|
|
| 25 |
|
|
namespace QtPdCom { |
| 26 |
|
|
|
| 27 |
|
✗ |
class MessageModelFilterPrivate |
| 28 |
|
|
{ |
| 29 |
|
|
public: |
| 30 |
|
|
bool showOnlyActiveMessages = false; |
| 31 |
|
|
}; |
| 32 |
|
|
} // namespace QtPdCom |
| 33 |
|
|
|
| 34 |
|
|
using QtPdCom::MessageModelFilter; |
| 35 |
|
|
|
| 36 |
|
|
/****************************************************************************/ |
| 37 |
|
|
|
| 38 |
|
✗ |
MessageModelFilter::MessageModelFilter(QObject *parent): |
| 39 |
|
|
QSortFilterProxyModel(parent), |
| 40 |
|
✗ |
d_ptr(new QtPdCom::MessageModelFilterPrivate()) |
| 41 |
|
|
{} |
| 42 |
|
|
|
| 43 |
|
|
/****************************************************************************/ |
| 44 |
|
|
|
| 45 |
|
|
MessageModelFilter::~MessageModelFilter() = default; |
| 46 |
|
|
|
| 47 |
|
|
/****************************************************************************/ |
| 48 |
|
|
|
| 49 |
|
✗ |
bool MessageModelFilter::getShowOnlyActiveMessages() const |
| 50 |
|
|
{ |
| 51 |
|
✗ |
const Q_D(MessageModelFilter); |
| 52 |
|
✗ |
return d->showOnlyActiveMessages; |
| 53 |
|
|
} |
| 54 |
|
|
|
| 55 |
|
|
/****************************************************************************/ |
| 56 |
|
|
|
| 57 |
|
✗ |
void MessageModelFilter::setShowOnlyActiveMessages(bool value) |
| 58 |
|
|
{ |
| 59 |
|
✗ |
Q_D(MessageModelFilter); |
| 60 |
|
✗ |
d->showOnlyActiveMessages = value; |
| 61 |
|
✗ |
invalidateFilter(); |
| 62 |
|
|
} |
| 63 |
|
|
|
| 64 |
|
|
/****************************************************************************/ |
| 65 |
|
|
|
| 66 |
|
✗ |
bool MessageModelFilter::filterAcceptsRow( |
| 67 |
|
|
int sourceRow, |
| 68 |
|
|
const QModelIndex &sourceParent) const |
| 69 |
|
|
{ |
| 70 |
|
✗ |
Q_ASSERT(sourceModel()); |
| 71 |
|
✗ |
const Q_D(MessageModelFilter); |
| 72 |
|
✗ |
const auto idx = sourceModel()->index(sourceRow, 0, sourceParent); |
| 73 |
|
✗ |
return !d->showOnlyActiveMessages |
| 74 |
|
✗ |
|| sourceModel() |
| 75 |
|
✗ |
->data(idx, MessageModel::ResetTimeStringRole) |
| 76 |
|
✗ |
.toString() |
| 77 |
|
✗ |
.isEmpty(); |
| 78 |
|
|
} |
| 79 |
|
|
|
| 80 |
|
|
/****************************************************************************/ |
| 81 |
|
|
|