NpyDatasetPreviewModel
NpyDatasetPreviewModel
Lazy-loading table model for NumPy .npy file preview. More…
#include <NpyDatasetPreviewModel.hpp>
Inherits from QAbstractTableModel
Public Signals
| Name | |
|---|---|
| void | loadError(QString const & message) Emitted when file loading fails. |
| void | fileLoaded(qint64 num_rows, int num_cols) Emitted when file is successfully loaded. |
Public Functions
| Name | |
|---|---|
| NpyDatasetPreviewModel(QObject * parent =[nullptr]) | |
| ~NpyDatasetPreviewModel() override | |
| bool | loadFile(QString const & file_path) Load a .npy file for preview. |
| void | clear() Clear the current file. |
| bool | hasData() const Check if a file is currently loaded. |
| NpyFileInfo const & | fileInfo() const Get the parsed file metadata. |
| qint64 | totalElements() const Get the total number of elements in the array. |
| int | chunkSize() const Get the chunk size used for lazy loading. |
| void | setChunkSize(int size) Set the chunk size for lazy loading. |
| int | rowCount(QModelIndex const & parent =QModelIndex()) const override |
| int | columnCount(QModelIndex const & parent =QModelIndex()) const override |
| QVariant | data(QModelIndex const & index, int role =Qt::DisplayRole) const override |
| QVariant | headerData(int section, Qt::Orientation orientation, int role =Qt::DisplayRole) const override |
Detailed Description
class NpyDatasetPreviewModel;Lazy-loading table model for NumPy .npy file preview.
This model presents .npy array data in a table format:
- 1D arrays: Single column with index as row
- 2D arrays: Rows and columns map directly
- ND arrays: First dimension is rows, remaining dimensions flattened to columns
Data is loaded in chunks (default 100 rows) and cached using QCache to provide smooth scrolling while minimizing memory usage.
Public Signals Documentation
signal loadError
void loadError(
QString const & message
)Emitted when file loading fails.
Parameters:
- message Error message
signal fileLoaded
void fileLoaded(
qint64 num_rows,
int num_cols
)Emitted when file is successfully loaded.
Parameters:
- num_rows Number of rows in the view
- num_cols Number of columns in the view
Public Functions Documentation
function NpyDatasetPreviewModel
explicit NpyDatasetPreviewModel(
QObject * parent =nullptr
)function ~NpyDatasetPreviewModel
~NpyDatasetPreviewModel() overridefunction loadFile
bool loadFile(
QString const & file_path
)Load a .npy file for preview.
Parameters:
- file_path Path to the .npy file
Return: true if file was loaded successfully
function clear
void clear()Clear the current file.
function hasData
inline bool hasData() constCheck if a file is currently loaded.
function fileInfo
inline NpyFileInfo const & fileInfo() constGet the parsed file metadata.
function totalElements
inline qint64 totalElements() constGet the total number of elements in the array.
function chunkSize
inline int chunkSize() constGet the chunk size used for lazy loading.
function setChunkSize
void setChunkSize(
int size
)Set the chunk size for lazy loading.
Parameters:
- size Number of rows to load at once (minimum 10)
function rowCount
int rowCount(
QModelIndex const & parent =QModelIndex()
) const overridefunction columnCount
int columnCount(
QModelIndex const & parent =QModelIndex()
) const overridefunction data
QVariant data(
QModelIndex const & index,
int role =Qt::DisplayRole
) const overridefunction headerData
QVariant headerData(
int section,
Qt::Orientation orientation,
int role =Qt::DisplayRole
) const overrideUpdated on 2026-11-13 at 20:25:40 +0000