![]() |
Code Documentation 3.7
Social Network Visualizer
|
Free functions that serialise any QAbstractItemModel to CSV or JSON. More...
Functions | |
| QString | csvQuote (const QString &value) |
Returns a CSV-safe quoted field: wraps value in double-quotes if it contains a comma, double-quote, or newline; embedded double-quotes are escaped as "". | |
| bool | toCSV (QAbstractItemModel *model, const QString &filePath) |
Writes model to an RFC 4180 CSV file at filePath. | |
| bool | toJSON (QAbstractItemModel *model, const QString &filePath) |
Writes model to a JSON file at filePath. | |
Free functions that serialise any QAbstractItemModel to CSV or JSON.
Both functions operate on whatever rows and columns the model exposes — pass a QSortFilterProxyModel to export only the currently visible rows, or the raw source model to export everything.
Constraint: QtCore only — no widgets, no UI signals.
| QString TableExport::csvQuote | ( | const QString & | value | ) |
Returns a CSV-safe quoted field: wraps value in double-quotes if it contains a comma, double-quote, or newline; embedded double-quotes are escaped as "".
Exposed so other CSV writers outside this module (e.g. Graph's report writers, which build rows from data that never passes through a QAbstractItemModel) can reuse the same escaping rules instead of reimplementing them.
| bool TableExport::toCSV | ( | QAbstractItemModel * | model, |
| const QString & | filePath ) |
Writes model to an RFC 4180 CSV file at filePath.
The first row is the column headers from headerData(). Each subsequent row is one model row. Fields containing commas, double-quotes, or newlines are enclosed in double-quotes; embedded double-quotes are escaped as "".
| bool TableExport::toJSON | ( | QAbstractItemModel * | model, |
| const QString & | filePath ) |
Writes model to a JSON file at filePath.
Produces a top-level JSON array of objects. Each object has one key per column, taken from headerData(), with the display-role cell value as the string value.