-
Notifications
You must be signed in to change notification settings - Fork 182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[mon_gui] Change font for new topics in mon_gui #1879
base: master
Are you sure you want to change the base?
Changes from 4 commits
8a5a078
075508f
f46b45c
bb01fec
eed92e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -17,6 +17,8 @@ | |||||
* ========================= eCAL LICENSE ================================= | ||||||
*/ | ||||||
|
||||||
#include <QFont> | ||||||
|
||||||
#include "topic_tree_model.h" | ||||||
#include "tree_item_type.h" | ||||||
#include "item_data_roles.h" | ||||||
|
@@ -49,7 +51,6 @@ QVariant TopicTreeModel::headerData(int section, Qt::Orientation orientation, in | |||||
return QAbstractTreeModel::headerData(section, orientation, role); | ||||||
} | ||||||
|
||||||
|
||||||
int TopicTreeModel::mapColumnToItem(int model_column, int tree_item_type) const | ||||||
{ | ||||||
switch ((TreeItemType)tree_item_type) | ||||||
|
@@ -70,7 +71,7 @@ void TopicTreeModel::monitorUpdated(const eCAL::pb::Monitoring& monitoring_pb) | |||||
{ | ||||||
// Create a list of all topics to check if we have to remove them | ||||||
std::map<std::string, bool> topic_still_existing; | ||||||
for(const auto& topic : topic_tree_item_map_) | ||||||
for (const auto& topic : topic_tree_item_map_) | ||||||
{ | ||||||
topic_still_existing[topic.first] = false; | ||||||
} | ||||||
|
@@ -84,12 +85,35 @@ void TopicTreeModel::monitorUpdated(const eCAL::pb::Monitoring& monitoring_pb) | |||||
// Got a new topic | ||||||
TopicTreeItem* topic_tree_item = new TopicTreeItem(topic); | ||||||
insertItemIntoGroups(topic_tree_item); | ||||||
topic_tree_item_map_[topic_id] = topic_tree_item; | ||||||
STopicTreeEntry tree_entry; | ||||||
tree_entry.tree_item = topic_tree_item; | ||||||
topic_tree_item_map_[topic_id] = tree_entry; | ||||||
auto fontrole = topic_tree_item->data(1, Qt::ItemDataRole::FontRole); | ||||||
auto font = qvariant_cast<QFont>(fontrole); | ||||||
font.setBold(true); | ||||||
topic_tree_item->setFont(font); | ||||||
} | ||||||
else | ||||||
{ | ||||||
auto& tree_entry = topic_tree_item_map_.at(topic_id); | ||||||
auto topic_tree_item = tree_entry.tree_item; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: 'auto topic_tree_item' can be declared as 'auto *topic_tree_item' [readability-qualified-auto]
Suggested change
|
||||||
if (tree_entry.tree_item_counter < 20) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe instead of item counter, you could make it independend of the calls with a time, as the user can specify how fast the monitoring app updates the content. |
||||||
{ | ||||||
tree_entry.tree_item_counter++; | ||||||
} | ||||||
else | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These statements can get united together. |
||||||
{ | ||||||
if (!tree_entry.default_font) | ||||||
{ | ||||||
auto fontrole = topic_tree_item->data(1, Qt::ItemDataRole::FontRole); | ||||||
auto font = qvariant_cast<QFont>(fontrole); | ||||||
font.setBold(false); | ||||||
topic_tree_item->setFont(font); | ||||||
tree_entry.default_font = true; | ||||||
} | ||||||
} | ||||||
// Update an existing topic | ||||||
topic_tree_item_map_.at(topic_id)->update(topic); | ||||||
topic_tree_item->update(topic); | ||||||
topic_still_existing[topic_id] = true; | ||||||
} | ||||||
} | ||||||
|
@@ -99,25 +123,26 @@ void TopicTreeModel::monitorUpdated(const eCAL::pb::Monitoring& monitoring_pb) | |||||
{ | ||||||
if (!topic.second) | ||||||
{ | ||||||
removeItemFromGroups(topic_tree_item_map_.at(topic.first)); | ||||||
removeItemFromGroups(topic_tree_item_map_.at(topic.first).tree_item); | ||||||
topic_tree_item_map_.erase(topic.first); | ||||||
} | ||||||
} | ||||||
|
||||||
updateAll(); | ||||||
} | ||||||
|
||||||
QVector<QPair<int, QString>> TopicTreeModel::getTreeItemColumnNameMapping() const | ||||||
|
||||||
QVector<QPair<int, QVariant>> TopicTreeModel::getTreeItemColumnNameMapping() const | ||||||
{ | ||||||
QVector<QPair<int, QString>> column_name_mapping; | ||||||
QVector<QPair<int, QVariant>> column_name_mapping; | ||||||
|
||||||
for (int i = 0; i < columnCount(); i++) | ||||||
{ | ||||||
int column = mapColumnToItem(i, (int)TreeItemType::Topic); | ||||||
if (column >= 0) | ||||||
{ | ||||||
QString name = headerData(i, Qt::Orientation::Horizontal, Qt::ItemDataRole::DisplayRole).toString(); | ||||||
column_name_mapping.push_back(QPair<int, QString>(column, name)); | ||||||
QVariant name = headerData(i, Qt::Orientation::Horizontal, Qt::ItemDataRole::DisplayRole); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: variable 'name' of type 'QVariant' can be declared 'const' [misc-const-correctness]
Suggested change
|
||||||
column_name_mapping.push_back(QPair<int, QVariant>(column, name)); | ||||||
} | ||||||
} | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe don't remove the logic completely. Instead set set and unset the member font varible and return it here.