SMTK  @SMTK_VERSION@
Simulation Modeling Tool Kit
Public Types | Public Member Functions | Protected Slots | Protected Member Functions | Protected Attributes | List of all members
smtk::extension::qtDiagramLegend Class Reference

An interactive legend to control what is displayed in a qtDiagram. More...

#include <qtDiagramLegend.h>

Inheritance diagram for smtk::extension::qtDiagramLegend:
[legend]
Collaboration diagram for smtk::extension::qtDiagramLegend:
[legend]

Public Types

enum  Column { Group, Symbol, Description }
 An enumerant describing the columns of the legend's model. More...
 
using EntriesByType = std::unordered_map< smtk::string::Token, qtDiagramLegendEntry * >
 
using GroupedEntries = std::unordered_map< smtk::string::Token, EntriesByType >
 

Public Member Functions

 smtkSuperclassMacro (QGroupBox)
 
 qtDiagramLegend (const QString &title, qtDiagram *parent=nullptr)
 
const EntriesByType & typesInGroup (smtk::string::Token group) const
 
bool addEntry (qtDiagramLegendEntry *entry)
 Add an entry to the legend.
 
bool removeEntry (qtDiagramLegendEntry *entry)
 Remove an entry from the legend.
 
qtDiagramdiagram () const
 Return the diagram this summary widget belongs to.
 

Protected Slots

void legendUpdated ()
 This is called when model changes or user interactions requires a relayout. More...
 

Protected Member Functions

void eraseIndex (qtDiagramLegendEntry *entry)
 Called by removeEntry() to update m_index so entry is no longer indexed.
 

Protected Attributes

QPointer< qtDiagramm_diagram
 Watch m_view's mouse events to tell m_symbolDelegate where to draw controls for visibility. More...
 
QStandardItemModel * m_keys { nullptr }
 The unsorted model, in order of insertion.
 
QSortFilterProxyModel * m_sortModel { nullptr }
 A sorted version of m_keys.
 
QTableView * m_view { nullptr }
 The view of m_sortModel.
 
GroupedEntries m_index
 An index of legend entries.
 
qtLegendDelegatem_symbolDelegate
 The delegate used to render the Symbol column of m_view.
 

Detailed Description

An interactive legend to control what is displayed in a qtDiagram.

Each qtDiagramGenerator may add entries to the legend for the types of nodes and arcs it presents. Users may then toggle the visibility of these via the legend.

Member Enumeration Documentation

◆ Column

An enumerant describing the columns of the legend's model.

Enumerator
Group 

The group (arc, node, etc.) of a type in the diagram.

Symbol 

The visual appearance of a type in the diagram.

Description 

A text description of a type in the diagram.

Member Function Documentation

◆ legendUpdated

void smtk::extension::qtDiagramLegend::legendUpdated ( )
protectedslot

This is called when model changes or user interactions requires a relayout.

Specifically, when (1) rows are inserted, (2) rows are modified, or (3) the user changes a column width, this method is invoked. This method calls resizeRowsToContents() so that word-wrapping is performed and re-sorts the model as needed. Note that we do not display the horizontal header (with its sort indicators) because we always sort by two columns (description then group) so that entries for the same types of things (arcs, nodes, etc.) are kept together.

Member Data Documentation

◆ m_diagram

QPointer<qtDiagram> smtk::extension::qtDiagramLegend::m_diagram
protected

Watch m_view's mouse events to tell m_symbolDelegate where to draw controls for visibility.

The parent qtResourceDiagram


The documentation for this class was generated from the following files: