-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add QSFP to hide empty rows in eventmodel
The favourites and tracepoint patches include some rows in the model that may be empty. To keep the code simple an readable all rows will be shown. Then a proxy model is put ontop to remove empty rows.
- Loading branch information
Showing
5 changed files
with
79 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
SPDX-FileCopyrightText: Lieven Hey <[email protected]> | ||
SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company, [email protected] | ||
SPDX-License-Identifier: GPL-2.0-or-later | ||
*/ | ||
|
||
#include "eventmodelproxy.h" | ||
#include "eventmodel.h" | ||
|
||
EventModelProxy::EventModelProxy(QObject* parent) | ||
: QSortFilterProxyModel(parent) | ||
{ | ||
setRecursiveFilteringEnabled(true); | ||
setSortRole(EventModel::SortRole); | ||
setFilterKeyColumn(EventModel::ThreadColumn); | ||
setFilterRole(Qt::DisplayRole); | ||
} | ||
|
||
EventModelProxy::~EventModelProxy() = default; | ||
|
||
bool EventModelProxy::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const | ||
{ | ||
// index is invalid -> we are at the root node | ||
if (!source_parent.isValid()) { | ||
const auto model = sourceModel(); | ||
return model->rowCount(model->index(source_row, 0)); | ||
} | ||
|
||
return true; | ||
} |
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,21 @@ | ||
/* | ||
SPDX-FileCopyrightText: Lieven Hey <[email protected]> | ||
SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company, [email protected] | ||
SPDX-License-Identifier: GPL-2.0-or-later | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <QSortFilterProxyModel> | ||
|
||
class EventModelProxy : public QSortFilterProxyModel | ||
{ | ||
Q_OBJECT | ||
public: | ||
EventModelProxy(QObject* parent = nullptr); | ||
~EventModelProxy() override; | ||
|
||
protected: | ||
bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override; | ||
}; |
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