KanoopGuiQt 1.3.0
Qt GUI utility library
Loading...
Searching...
No Matches
abstracttablemodel.h
1/******************************************************************************************
2**
3** abstracttablemodel.h
4**
5** Extends AbstractItemModel to provide some table-specific functions.
6**
7** Moved from my Tesseract Engineering repo to open-source
8**
9** Author: Stephen Punak
10** Created: Wed Oct 25 14:21:04 2023
11**
12******************************************************************************************/
13#ifndef ABSTRACTTABLEMODEL_H
14#define ABSTRACTTABLEMODEL_H
15#include "abstractitemmodel.h"
16
17/**
18 * @brief AbstractItemModel specialization for tabular (row/column) models.
19 *
20 * Overrides columnCount() and data() with table-aware implementations and adds
21 * a hook for notifying when a specific cell changes.
22 */
23class LIBKANOOPGUI_EXPORT AbstractTableModel : public AbstractItemModel
24{
25 Q_OBJECT
26public:
27 /** @brief Construct with an optional parent. */
28 AbstractTableModel(QObject* parent = nullptr);
29
30 /**
31 * @brief Construct with a logging category and optional parent.
32 * @param loggingCategory Category name used for log output
33 * @param parent Optional QObject parent
34 */
35 AbstractTableModel(const QString& loggingCategory, QObject* parent = nullptr);
36
37 /**
38 * @brief Remove the row at the given index from the model.
39 * @param index Model index of the row to delete
40 */
41 void deleteRowAtIndex(const QModelIndex& index);
42
43protected:
44 // AbstractItemModel interface
45 /** @brief Return the number of columns (based on registered column headers). */
46 virtual int columnCount(const QModelIndex &parent) const override;
47 /** @brief Return the data for the given index and role. */
48 virtual QVariant data(const QModelIndex &index, int role) const override;
49
50 /**
51 * @brief Called when a specific column cell at rowIndex has changed.
52 * @param rowIndex Row index of the changed cell
53 * @param columnHeader Column header type of the changed cell
54 */
55 virtual void columnChangedAtRowIndex(const QModelIndex& rowIndex, int columnHeader);
56};
57
58#endif // ABSTRACTTABLEMODEL_H
Extended QAbstractItemModel providing EntityMetadata-based item lookup and header management.
AbstractItemModel specialization for tabular (row/column) models.
virtual QVariant data(const QModelIndex &index, int role) const override
Return the data for the given index and role.
AbstractTableModel(const QString &loggingCategory, QObject *parent=nullptr)
Construct with a logging category and optional parent.
AbstractTableModel(QObject *parent=nullptr)
Construct with an optional parent.
void deleteRowAtIndex(const QModelIndex &index)
Remove the row at the given index from the model.
virtual int columnCount(const QModelIndex &parent) const override
Return the number of columns (based on registered column headers).
virtual void columnChangedAtRowIndex(const QModelIndex &rowIndex, int columnHeader)
Called when a specific column cell at rowIndex has changed.