Skip to content

Commit 505cf1e

Browse files
committed
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.
1 parent 16be5f0 commit 505cf1e

File tree

4 files changed

+46
-1
lines changed

4 files changed

+46
-1
lines changed

src/models/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ add_library(
1010
disassemblymodel.cpp
1111
disassemblyoutput.cpp
1212
eventmodel.cpp
13+
eventmodelproxy.cpp
1314
filterandzoomstack.cpp
1415
frequencymodel.cpp
1516
highlighter.cpp

src/models/eventmodelproxy.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
SPDX-FileCopyrightText: Lieven Hey <lieven.hey@kdab.com>
3+
SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
4+
5+
SPDX-License-Identifier: GPL-2.0-or-later
6+
*/
7+
8+
#include "eventmodelproxy.h"
9+
10+
EventModelProxy::EventModelProxy(QObject* parent)
11+
: QSortFilterProxyModel(parent)
12+
{
13+
}
14+
15+
EventModelProxy::~EventModelProxy() = default;
16+
17+
bool EventModelProxy::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
18+
{
19+
Q_UNUSED(source_row);
20+
return source_parent.isValid();
21+
}

src/models/eventmodelproxy.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
SPDX-FileCopyrightText: Lieven Hey <lieven.hey@kdab.com>
3+
SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
4+
5+
SPDX-License-Identifier: GPL-2.0-or-later
6+
*/
7+
8+
#pragma once
9+
10+
#include <QSortFilterProxyModel>
11+
12+
class EventModelProxy : public QSortFilterProxyModel
13+
{
14+
Q_OBJECT
15+
public:
16+
public:
17+
EventModelProxy(QObject* parent);
18+
~EventModelProxy() override;
19+
20+
protected:
21+
bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override;
22+
};

src/timelinewidget.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include "filterandzoomstack.h"
1111
#include "models/eventmodel.h"
12+
#include "models/eventmodelproxy.h"
1213
#include "resultsutil.h"
1314
#include "timelinedelegate.h"
1415

@@ -61,7 +62,7 @@ TimeLineWidget::TimeLineWidget(PerfParser* parser, QMenu* filterMenu, FilterAndZ
6162
ui->setupUi(this);
6263

6364
auto* eventModel = new EventModel(this);
64-
auto* timeLineProxy = new QSortFilterProxyModel(this);
65+
auto* timeLineProxy = new EventModelProxy(this);
6566
timeLineProxy->setRecursiveFilteringEnabled(true);
6667
timeLineProxy->setSourceModel(eventModel);
6768
timeLineProxy->setSortRole(EventModel::SortRole);

0 commit comments

Comments
 (0)