summaryrefslogtreecommitdiffstats
path: root/examples/charts/chartsgallery/barmodelmappermodel.h
diff options
context:
space:
mode:
Diffstat (limited to 'examples/charts/chartsgallery/barmodelmappermodel.h')
-rw-r--r--examples/charts/chartsgallery/barmodelmappermodel.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/examples/charts/chartsgallery/barmodelmappermodel.h b/examples/charts/chartsgallery/barmodelmappermodel.h
new file mode 100644
index 00000000..84d4664e
--- /dev/null
+++ b/examples/charts/chartsgallery/barmodelmappermodel.h
@@ -0,0 +1,35 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef BARMODELMAPPERMODEL_H
+#define BARMODELMAPPERMODEL_H
+
+#include <QAbstractTableModel>
+#include <QMultiHash>
+#include <QRect>
+
+class BarModelMapperModel : public QAbstractTableModel
+{
+ Q_OBJECT
+public:
+ explicit BarModelMapperModel(QObject *parent = nullptr);
+ virtual ~BarModelMapperModel();
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+ QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+
+ void addMapping(QString color, QRect area);
+ void clearMapping() { m_mapping.clear(); }
+
+private:
+ QList<QList<qreal> *> m_data;
+ QMultiHash<QString, QRect> m_mapping;
+ int m_columnCount;
+ int m_rowCount;
+};
+
+#endif