2024-01-16 09:49:52 +00:00
|
|
|
#pragma once
|
|
|
|
|
2023-12-21 15:06:52 +00:00
|
|
|
#include <QAbstractListModel>
|
|
|
|
|
|
|
|
class TestModel : public QAbstractListModel {
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit TestModel(QList<QPair<QString, QVariantList>> data);
|
|
|
|
explicit TestModel(QList<QString> roles);
|
|
|
|
|
2024-02-22 13:49:33 +00:00
|
|
|
int rowCount(const QModelIndex& parent = {}) const override;
|
2023-12-21 15:06:52 +00:00
|
|
|
QHash<int, QByteArray> roleNames() const override;
|
|
|
|
QVariant data(const QModelIndex& index, int role) const override;
|
|
|
|
|
|
|
|
void insert(int index, QVariantList row);
|
|
|
|
void update(int index, int role, QVariant value);
|
|
|
|
void remove(int index);
|
|
|
|
|
2024-02-22 13:49:33 +00:00
|
|
|
// inverts order of items, emits layoutAboutToBeChanged / layoutChanged
|
|
|
|
void invert();
|
|
|
|
|
2024-04-09 12:12:15 +00:00
|
|
|
// removes every second item from the model but doesn't emit
|
|
|
|
// rowsAboutToBeRemoved/rowsRemoved. The update is notified via
|
|
|
|
// layoutAboutToBeChanged/layoutChanged. It's useful for testing proxy
|
|
|
|
// models against that scenario, which may occur in some circumstances, e.g.
|
|
|
|
// during SFPM initialization where initial filtering is notified this way.
|
|
|
|
void removeEverySecond();
|
|
|
|
|
2024-05-06 11:04:41 +00:00
|
|
|
// emits modelAboutToBeReset/modelReset, content remains the same
|
|
|
|
void reset();
|
|
|
|
|
2024-07-01 10:54:34 +00:00
|
|
|
// emits modelAboutToBeReset/modelReset, content is removed
|
|
|
|
void resetAndClear();
|
|
|
|
|
2023-12-21 15:06:52 +00:00
|
|
|
private:
|
|
|
|
void initRoles();
|
|
|
|
|
|
|
|
QList<QPair<QString, QVariantList>> m_data;
|
|
|
|
QHash<int, QByteArray> m_roles;
|
|
|
|
};
|