Code Documentation 3.5
Social Network Visualizer
Loading...
Searching...
No Matches
edgetablemodel.h
Go to the documentation of this file.
1
13#pragma once
14
15#include <QAbstractTableModel>
16#include <QBrush>
17#include <QColor>
18#include <QStringList>
19
20class Graph;
21
29class EdgeTableModel : public QAbstractTableModel
30{
31 Q_OBJECT
32public:
33 explicit EdgeTableModel(QObject *parent = nullptr);
34
40 void populate(Graph *graph);
41
42 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
43 int columnCount(const QModelIndex &parent = QModelIndex()) const override;
44 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
45 QVariant headerData(int section, Qt::Orientation orientation,
46 int role = Qt::DisplayRole) const override;
47 Qt::ItemFlags flags(const QModelIndex &index) const override;
48 bool setData(const QModelIndex &index, const QVariant &value,
49 int role = Qt::EditRole) override;
50
51private:
52 struct EdgeRow {
53 int source;
54 int target;
55 QString relation;
56 qreal weight;
57 QString label;
58 QString color;
59 QList<QString> attrValues;
60 };
61
62 Graph *m_graph = nullptr;
63 QList<EdgeRow> m_rows;
64 QStringList m_attrKeys;
65
66 static constexpr int FIXED_COLS = 6;
67
68 // Column index constants
69 static constexpr int COL_SOURCE = 0;
70 static constexpr int COL_TARGET = 1;
71 static constexpr int COL_RELATION = 2;
72 static constexpr int COL_WEIGHT = 3;
73 static constexpr int COL_LABEL = 4;
74 static constexpr int COL_COLOR = 5;
75};
Table model that caches edge data for the current relation from Graph and writes back via the Graph A...
Definition edgetablemodel.h:30
QStringList m_attrKeys
Definition edgetablemodel.h:64
static constexpr int COL_COLOR
Definition edgetablemodel.h:74
static constexpr int COL_RELATION
Definition edgetablemodel.h:71
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition edgetablemodel.cpp:91
Graph * m_graph
Definition edgetablemodel.h:62
static constexpr int COL_TARGET
Definition edgetablemodel.h:70
static constexpr int FIXED_COLS
Definition edgetablemodel.h:66
static constexpr int COL_SOURCE
Definition edgetablemodel.h:69
Qt::ItemFlags flags(const QModelIndex &index) const override
Definition edgetablemodel.cpp:179
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Definition edgetablemodel.cpp:194
void populate(Graph *graph)
Rebuilds the internal cache from graph (current relation only).
Definition edgetablemodel.cpp:32
static constexpr int COL_WEIGHT
Definition edgetablemodel.h:72
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Definition edgetablemodel.cpp:105
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Definition edgetablemodel.cpp:153
QList< EdgeRow > m_rows
Definition edgetablemodel.h:63
static constexpr int COL_LABEL
Definition edgetablemodel.h:73
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Definition edgetablemodel.cpp:98
The Graph class This is the main class for a Graph, used in conjuction with GraphVertex,...
Definition graph.h:74
Definition edgetablemodel.h:52
QString relation
Definition edgetablemodel.h:55
QList< QString > attrValues
parallel to m_attrKeys
Definition edgetablemodel.h:59
int target
Definition edgetablemodel.h:54
qreal weight
Definition edgetablemodel.h:56
int source
Definition edgetablemodel.h:53
QString label
Definition edgetablemodel.h:57
QString color
Definition edgetablemodel.h:58