Code Documentation 3.6
Social Network Visualizer
Loading...
Searching...
No Matches
GraphTableWidget Class Reference

A QWidget containing a QTabWidget with two tabs — Nodes and Edges — each backed by a sortable, searchable table view. More...

#include <widgets/graphtablewidget.h>

Inheritance diagram for GraphTableWidget:
Collaboration diagram for GraphTableWidget:

Public Slots

void refresh (Graph *graph)
 Repopulates both the node and edge models from graph.
void syncNodeSelection (const QList< int > &nodeNumbers)
 Highlights the rows in the Nodes tab that match nodeNumbers.
void syncEdgeSelection (const QList< SocNetV::SelectedEdge > &edges)
 Highlights the rows in the Edges tab that match edges.
void showNodesTab ()
void showEdgesTab ()
void exportNodesCSV ()
void exportNodesJSON ()
void exportEdgesCSV ()
void exportEdgesJSON ()
void importNodesCSV ()
void importNodesJSON ()
void importEdgesCSV ()
void importEdgesJSON ()

Signals

void nodeSelected (int number)
void edgeSelected (int source, int target)
void exportStatusMessage (const QString &message)
void importStatusMessage (const QString &message)

Public Member Functions

 GraphTableWidget (QWidget *parent=nullptr)
 Constructs the GraphTableWidget.
QAbstractItemModel * nodeModel () const
QAbstractItemModel * edgeModel () const
void setNodeShapeLists (const QStringList &shapes, const QStringList &icons)
 Supplies the node shape list and icon paths so the bulk-edit dialog can offer Shape as a property option for nodes.

Private Slots

void onNodeRowClicked (const QModelIndex &proxyIndex)
 Maps the proxy index to a source index and emits nodeSelected().
void onEdgeRowClicked (const QModelIndex &proxyIndex)
 Maps the proxy index to source/target columns and emits edgeSelected().
void onNodeSetPropertyClicked ()
void onNodeRemoveAttributeClicked ()
void onNodeAddAttributeClicked ()
void onEdgeSetPropertyClicked ()
void onEdgeRemoveAttributeClicked ()
void onEdgeAddAttributeClicked ()

Private Member Functions

void doExport (QAbstractItemModel *proxyModel, const QString &defaultName, bool csv)
 Opens a save dialog and writes proxyModel via TableExport.
void doImport (bool forNodes, bool csv)
 Opens DialogImportAttributes and, on acceptance, calls the appropriate Graph import method then refreshes the table.
QList< int > resolveNodeTargets () const
 Returns the node numbers for the table's current node selection, or for all visible proxy rows if nothing is selected.
QList< SocNetV::SelectedEdge > resolveEdgeTargets () const
 Returns (source, target) pairs for the table's current edge selection, or all visible proxy rows if nothing is selected.

Private Attributes

Graphm_graph = nullptr
QTabWidget * m_tabs
QTableView * m_nodeView
QTableView * m_edgeView
NodeTableModelm_nodeModel
EdgeTableModelm_edgeModel
QSortFilterProxyModel * m_nodeProxy
QSortFilterProxyModel * m_edgeProxy
QLineEdit * m_nodeSearch
QLineEdit * m_edgeSearch
QStringList m_nodeShapeList
QStringList m_iconPathList

Detailed Description

A QWidget containing a QTabWidget with two tabs — Nodes and Edges — each backed by a sortable, searchable table view.

Call refresh() whenever the graph data changes and the panel is visible. The widget itself does not auto-refresh; the caller controls when to rebuild the cache.

Constructor & Destructor Documentation

◆ GraphTableWidget()

GraphTableWidget::GraphTableWidget ( QWidget * parent = nullptr)
explicit

Constructs the GraphTableWidget.

Builds both tabs (Nodes, Edges) with search bar, Refresh button, and a sortable/searchable QTableView backed by a QSortFilterProxyModel.

Member Function Documentation

◆ doExport()

void GraphTableWidget::doExport ( QAbstractItemModel * proxyModel,
const QString & defaultName,
bool csv )
private

Opens a save dialog and writes proxyModel via TableExport.

defaultName is used to suggest a filename ("nodes" or "edges"). csv selects CSV (true) or JSON (false) format.

◆ doImport()

void GraphTableWidget::doImport ( bool forNodes,
bool csv )
private

Opens DialogImportAttributes and, on acceptance, calls the appropriate Graph import method then refreshes the table.

forNodes true → import node attributes; false → import edge attributes. csv true → CSV format; false → JSON format.

◆ edgeModel()

QAbstractItemModel * GraphTableWidget::edgeModel ( ) const

Returns the raw (unfiltered) edge source model.

◆ edgeSelected

void GraphTableWidget::edgeSelected ( int source,
int target )
signal

Emitted when the user clicks a row in the Edges tab.

◆ exportEdgesCSV

void GraphTableWidget::exportEdgesCSV ( )
slot

Prompts for a file path and exports visible edge rows as CSV.

◆ exportEdgesJSON

void GraphTableWidget::exportEdgesJSON ( )
slot

Prompts for a file path and exports visible edge rows as JSON.

◆ exportNodesCSV

void GraphTableWidget::exportNodesCSV ( )
slot

Prompts for a file path and exports visible node rows as CSV.

◆ exportNodesJSON

void GraphTableWidget::exportNodesJSON ( )
slot

Prompts for a file path and exports visible node rows as JSON.

◆ exportStatusMessage

void GraphTableWidget::exportStatusMessage ( const QString & message)
signal

Emitted with a status message after an export attempt.

◆ importEdgesCSV

void GraphTableWidget::importEdgesCSV ( )
slot

Opens the column-mapping dialog and imports edge attributes from a CSV.

◆ importEdgesJSON

void GraphTableWidget::importEdgesJSON ( )
slot

Opens the column-mapping dialog and imports edge attributes from a JSON.

◆ importNodesCSV

void GraphTableWidget::importNodesCSV ( )
slot

Opens the column-mapping dialog and imports node attributes from a CSV.

◆ importNodesJSON

void GraphTableWidget::importNodesJSON ( )
slot

Opens the column-mapping dialog and imports node attributes from a JSON.

◆ importStatusMessage

void GraphTableWidget::importStatusMessage ( const QString & message)
signal

Emitted with a status message after an import attempt.

◆ nodeModel()

QAbstractItemModel * GraphTableWidget::nodeModel ( ) const

Returns the raw (unfiltered) node source model.

◆ nodeSelected

void GraphTableWidget::nodeSelected ( int number)
signal

Emitted when the user clicks a row in the Nodes tab.

◆ onEdgeAddAttributeClicked

void GraphTableWidget::onEdgeAddAttributeClicked ( )
privateslot

◆ onEdgeRemoveAttributeClicked

void GraphTableWidget::onEdgeRemoveAttributeClicked ( )
privateslot

◆ onEdgeRowClicked

void GraphTableWidget::onEdgeRowClicked ( const QModelIndex & proxyIndex)
privateslot

Maps the proxy index to source/target columns and emits edgeSelected().

◆ onEdgeSetPropertyClicked

void GraphTableWidget::onEdgeSetPropertyClicked ( )
privateslot

◆ onNodeAddAttributeClicked

void GraphTableWidget::onNodeAddAttributeClicked ( )
privateslot

◆ onNodeRemoveAttributeClicked

void GraphTableWidget::onNodeRemoveAttributeClicked ( )
privateslot

◆ onNodeRowClicked

void GraphTableWidget::onNodeRowClicked ( const QModelIndex & proxyIndex)
privateslot

Maps the proxy index to a source index and emits nodeSelected().

◆ onNodeSetPropertyClicked

void GraphTableWidget::onNodeSetPropertyClicked ( )
privateslot

◆ refresh

void GraphTableWidget::refresh ( Graph * graph)
slot

Repopulates both the node and edge models from graph.

Repopulates both models from graph and resizes columns.

Stores a pointer to graph for subsequent Refresh button clicks.

Also re-syncs the table selection from the graph's current selection state, because beginResetModel/endResetModel clears all view selections.

◆ resolveEdgeTargets()

QList< SocNetV::SelectedEdge > GraphTableWidget::resolveEdgeTargets ( ) const
private

Returns (source, target) pairs for the table's current edge selection, or all visible proxy rows if nothing is selected.

Returns (source,target) pairs for selected rows, or all visible rows if none selected.

◆ resolveNodeTargets()

QList< int > GraphTableWidget::resolveNodeTargets ( ) const
private

Returns the node numbers for the table's current node selection, or for all visible proxy rows if nothing is selected.

Returns node numbers for selected rows, or all visible rows if none selected.

◆ setNodeShapeLists()

void GraphTableWidget::setNodeShapeLists ( const QStringList & shapes,
const QStringList & icons )

Supplies the node shape list and icon paths so the bulk-edit dialog can offer Shape as a property option for nodes.

◆ showEdgesTab

void GraphTableWidget::showEdgesTab ( )
slot

Switches the tab widget to the Edges tab.

◆ showNodesTab

void GraphTableWidget::showNodesTab ( )
slot

Switches the tab widget to the Nodes tab.

◆ syncEdgeSelection

void GraphTableWidget::syncEdgeSelection ( const QList< SocNetV::SelectedEdge > & edges)
slot

Highlights the rows in the Edges tab that match edges.

Pre-selects the rows in the Edges tab matching edges (source, target pairs).

Each SelectedEdge is a (source, target) pair. O(model_rows + selected).

◆ syncNodeSelection

void GraphTableWidget::syncNodeSelection ( const QList< int > & nodeNumbers)
slot

Highlights the rows in the Nodes tab that match nodeNumbers.

Pre-selects the rows in the Nodes tab whose node number is in nodeNumbers.

Rows not in the list are deselected. Skips nodes that are filtered out by the current search. O(model_rows + selected).

Rows filtered out by the current search are silently skipped. Selection is cleared first; unmatched rows are left unselected.

Member Data Documentation

◆ m_edgeModel

EdgeTableModel* GraphTableWidget::m_edgeModel
private

◆ m_edgeProxy

QSortFilterProxyModel* GraphTableWidget::m_edgeProxy
private

◆ m_edgeSearch

QLineEdit* GraphTableWidget::m_edgeSearch
private

◆ m_edgeView

QTableView* GraphTableWidget::m_edgeView
private

◆ m_graph

Graph* GraphTableWidget::m_graph = nullptr
private

◆ m_iconPathList

QStringList GraphTableWidget::m_iconPathList
private

◆ m_nodeModel

NodeTableModel* GraphTableWidget::m_nodeModel
private

◆ m_nodeProxy

QSortFilterProxyModel* GraphTableWidget::m_nodeProxy
private

◆ m_nodeSearch

QLineEdit* GraphTableWidget::m_nodeSearch
private

◆ m_nodeShapeList

QStringList GraphTableWidget::m_nodeShapeList
private

◆ m_nodeView

QTableView* GraphTableWidget::m_nodeView
private

◆ m_tabs

QTabWidget* GraphTableWidget::m_tabs
private

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