Skip to content

Commit

Permalink
add QSFP to hide empty rows in eventmodel
Browse files Browse the repository at this point in the history
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
lievenhey committed Oct 4, 2023
1 parent 16be5f0 commit 505cf1e
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/models/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ add_library(
disassemblymodel.cpp
disassemblyoutput.cpp
eventmodel.cpp
eventmodelproxy.cpp
filterandzoomstack.cpp
frequencymodel.cpp
highlighter.cpp
Expand Down
21 changes: 21 additions & 0 deletions src/models/eventmodelproxy.cpp
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
*/

#include "eventmodelproxy.h"

EventModelProxy::EventModelProxy(QObject* parent)
: QSortFilterProxyModel(parent)
{
}

EventModelProxy::~EventModelProxy() = default;

bool EventModelProxy::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
{
Q_UNUSED(source_row);
return source_parent.isValid();
}
22 changes: 22 additions & 0 deletions src/models/eventmodelproxy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
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:
public:
EventModelProxy(QObject* parent);
~EventModelProxy() override;

protected:
bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override;
};
3 changes: 2 additions & 1 deletion src/timelinewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include "filterandzoomstack.h"
#include "models/eventmodel.h"
#include "models/eventmodelproxy.h"
#include "resultsutil.h"
#include "timelinedelegate.h"

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

auto* eventModel = new EventModel(this);
auto* timeLineProxy = new QSortFilterProxyModel(this);
auto* timeLineProxy = new EventModelProxy(this);
timeLineProxy->setRecursiveFilteringEnabled(true);
timeLineProxy->setSourceModel(eventModel);
timeLineProxy->setSortRole(EventModel::SortRole);
Expand Down

0 comments on commit 505cf1e

Please sign in to comment.