Skip to content

Commit

Permalink
Refs #19533: Add filter to status layout properly
Browse files Browse the repository at this point in the history
Signed-off-by: JesusPoderoso <[email protected]>
  • Loading branch information
JesusPoderoso committed Nov 2, 2023
1 parent 43c396d commit 713f38c
Show file tree
Hide file tree
Showing 15 changed files with 353 additions and 80 deletions.
3 changes: 3 additions & 0 deletions include/fastdds_monitor/Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,9 @@ public slots:
//! Data Model for Fast DDS Monitor problem view. Collects all entities problems detected by the monitor service
models::ProblemTreeModel* problem_model_;

//! Display and allow to filter Model for Fast DDS Monitor problem view.
models::ProblemTreeModel* problem_proxy_model_;

//! TODO
models::ListModel* source_entity_id_model_;

Expand Down
4 changes: 2 additions & 2 deletions include/fastdds_monitor/backend/Listener.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ class Listener : public PhysicalListener
EntityId datawriter_id,
const Status& status) override;

//! Callback when a problem is reported
void on_problem_reported(
//! Callback when a status problem is reported
void on_status_reported(
EntityId domain_id,
EntityId entity_id,
StatusKind data_kind) override;
Expand Down
4 changes: 4 additions & 0 deletions include/fastdds_monitor/backend/SyncBackendConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ class SyncBackendConnection
std::string get_name(
backend::EntityId id);

//! Get the status level of an entity from the Backend by calling \c get_status
StatusLevel get_status(
backend::EntityId id);

//! Get the alive status of an entity from the Backend by calling \c is_active
bool get_alive(
backend::EntityId id);
Expand Down
11 changes: 11 additions & 0 deletions include/fastdds_monitor/model/tree/ProblemTreeItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,17 @@ class ProblemTreeItem

backend::StatusKind kind();

bool is_error();

void is_error(
bool val);

std::string name_str();

std::string value_str();

std::string description_str();

//! Increases the issues counter of a top level entity item
int recalculate_entity_counter();

Expand Down
27 changes: 27 additions & 0 deletions include/fastdds_monitor/model/tree/ProblemTreeModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ class ProblemTreeModel : public QAbstractItemModel
const QVariant& value,
int role = Qt::EditRole) override;

bool removeRow(
int row,
const QModelIndex &index = QModelIndex());

QHash<int, QByteArray> roleNames() const override;

public:
Expand Down Expand Up @@ -144,6 +148,10 @@ class ProblemTreeModel : public QAbstractItemModel
ProblemTreeItem* parent,
ProblemTreeItem* child);

// Returns the child in the given position
ProblemTreeItem* child(
int row);

// Check if default empty value is the only element
bool is_empty();

Expand All @@ -156,13 +164,32 @@ class ProblemTreeModel : public QAbstractItemModel
const bool& is_error,
const std::string& description);

void set_source_model(
ProblemTreeModel* source_model);

/*!
* Filters the model if it is defined as proxy
*/
Q_INVOKABLE void filter_proxy(
const QVariant& entity_id);

private:
ProblemTreeItem* internalPointer(
const QModelIndex& index) const;

ProblemTreeItem* copy(
ProblemTreeItem* source,
const backend::EntityId entity_id);

void filter(
const backend::EntityId entity_id);

private:
ProblemTreeModel* source_model_;
ProblemTreeItem* root_item_;
bool is_empty_;

backend::EntityId current_filter_;
};

} // namespace models
Expand Down
2 changes: 1 addition & 1 deletion mock/complex_mock/database/Database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ void Database::callback_listener_thread_()
}

// add status callback
listener_->on_problem_reported(std::get<2>(entity), std::get<0>(entity), StatusKind::PROXY);
listener_->on_status_reported(std::get<2>(entity), std::get<0>(entity), StatusKind::PROXY);
}
}

Expand Down
1 change: 0 additions & 1 deletion qml/DomainGraphLayout.qml
Original file line number Diff line number Diff line change
Expand Up @@ -1384,7 +1384,6 @@ Item
"topic":new_model["hosts"][host]["users"][user]["processes"][process]["participants"][participant]["endpoints"][endpoint]["topic"],
"accum_y":accum_y
}
accum_y += endpoint_height_ + elements_spacing_
}
accum_y += endpoint_height_ + elements_spacing_
pending_endpoints_[pending_endpoints_.length] = endpoint
Expand Down
55 changes: 37 additions & 18 deletions qml/ProblemTreeView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ Flickable {
Arrow
}

signal problem_focused()
signal clean_filter()
property int current_filter_: -2 // backend::ID_ALL
signal problem_filtered()

property int handleStyle: ProblemTreeView.Handle.TriangleSmallOutline

Expand All @@ -98,6 +98,18 @@ Flickable {
boundsBehavior: Flickable.StopAtBounds
ScrollBar.vertical: ScrollBar {}

Component.onCompleted:{
root.clean_filter()
}

Connections
{
target: root.model
function onLayoutChanged() {
root.filter_model()
}
}

Connections { function onCurrentIndexChanged() { if(currentIndex) currentData = model.data(currentIndex) } }

ProblemTreeViewItem {
Expand All @@ -116,18 +128,12 @@ Flickable {
defaultIndicator: indicatorToString(handleStyle)
z: 1

onToggled: {
root.clean_filter()
}

Connections {
target: root.model
ignoreUnknownSignals: true
function onLayoutChanged() {
tree.childCount = root.model ? root.model.rowCount(tree.parentIndex) : 0
}


}
}

Expand Down Expand Up @@ -160,16 +166,29 @@ Flickable {
}
}

function focus_entity(entityId) {
var found = false
for (var i = 0; i< model.rowCount(); i++){
if (model.data(model.index(i,0),ProblemTreeViewItem.Role.Id) == entityId) {
tree.focus(entityId)
found = true
}
}
if (found){
root.problem_focused()

function clean_filter()
{
root.filter_model()
model.filter_proxy(-2)
tree.unfilter()
}

function filter_model()
{
var filter_all = -2 // backend::ID_ALL

if (current_filter_ != filter_all)
{
current_filter_ = filter_all
root.filter_model_by_id(current_filter_)
}
}

function filter_model_by_id(entityId)
{
model.filter_proxy(entityId)
root.problem_filtered()
tree.filter(entityId)
}
}
27 changes: 17 additions & 10 deletions qml/ProblemTreeViewItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ Item {
signal toggled()

// private (internal) signals
signal focus_(int entityId)
signal filter_(int entityId)
signal unfilter_()

implicitWidth: parent.width
implicitHeight: childrenRect.height
Expand Down Expand Up @@ -115,7 +116,6 @@ Item {
property Component contentItem: Item {
id: contentData


IconSVG {
id: status_icon
visible: !(currentRow.currentId === "all" && currentRow.currentKind === "INVALID")
Expand Down Expand Up @@ -157,8 +157,8 @@ Item {
anchors.verticalCenter: parent.verticalCenter
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignRight
height: parent.height
elide: Text.ElideRight
height: parent.height

color:currentRow.currentAlive ? currentRow.isSelectedIndex ? root.selectedItemColor : root.color : root.inactive
text: currentRow.currentId != "all" && currentRow.currentKind === "INVALID" ?
Expand Down Expand Up @@ -212,7 +212,7 @@ Item {
property var currentDescription: root.model.data(currentIndex, ProblemTreeViewItem.Role.Description)
property var currentAlive: root.model.data(currentIndex, ProblemTreeViewItem.Role.Alive)
property Item currentItem: repeater.itemAt(index)
property bool expanded: false
property bool expanded: true
property bool selected: false
property int itemChildCount: root.model.rowCount(currentIndex)
readonly property int depth: root.model.depth(currentIndex)
Expand Down Expand Up @@ -254,13 +254,16 @@ Item {

Connections {
target: root
function onFocus_(entityId){
if(parseInt(_prop.currentId) === parseInt(entityId)){
function onFilter_(entityId) {
if (_prop.currentId == entityId)
{
_prop.expanded = true
} else {
_prop.expanded = false
}
}

function onUnfilter_(){
_prop.expanded = false
}
}

Item {
Expand Down Expand Up @@ -408,7 +411,11 @@ Item {
}
}

function focus (entityId) {
root.focus_(entityId)
function filter (entityId) {
root.filter_(entityId)
}

function unfilter() {
root.unfilter_()
}
}
57 changes: 37 additions & 20 deletions qml/StatusLayout.qml
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,19 @@ Item

model: problemModel

onProblem_focused:{
onProblem_filtered:{
collapse_status_layout()
}

onClean_filter: {
statusLayout.clean_filter_()
}

Connections {
target: statusLayout

function onClean_filter_() {
status_tree_view.clean_filter()
}

function onFocus_entity_(entityId) {
status_tree_view.focus_entity(entityId)
status_tree_view.filter_model_by_id(entityId)
}
}
}
Expand Down Expand Up @@ -178,25 +178,38 @@ Item
}
}

IconSVG {
id: filter_empty_icon
visible: !statusLayout.filter_visible_
Rectangle {
id: filter_rect
anchors.right: rect.left
anchors.rightMargin: elements_spacing_ *2
anchors.verticalCenter: parent.verticalCenter
name: "filter_empty"
size: parent.height - elements_spacing_
}
height: parent.height - elements_spacing_
width: parent.height - elements_spacing_
color: "transparent"

IconSVG {
id: filter_full_icon
visible: statusLayout.filter_visible_
anchors.right: rect.left
anchors.rightMargin: elements_spacing_ *2
anchors.verticalCenter: parent.verticalCenter
name: "filter_full"
size: parent.height - elements_spacing_
IconSVG {
id: filter_empty_icon
visible: !statusLayout.filter_visible_
anchors.centerIn: parent
name: "filter_empty"
size: parent.width
}

IconSVG {
id: filter_full_icon
visible: statusLayout.filter_visible_
anchors.centerIn: parent
name: "filter_full"
size: parent.width
}

MouseArea {
id: filter_btn
anchors.fill: parent
onClicked: statusLayout.clean_filter_()
}
}

Connections {
target: statusLayout

Expand Down Expand Up @@ -302,4 +315,8 @@ Item
function filter_problem_log(entityId) {
statusLayout.focus_entity_(entityId)
}
function clean_filter()
{
statusLayout.clean_filter_()
}
}
Loading

0 comments on commit 713f38c

Please sign in to comment.