-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgridmodel.h
More file actions
31 lines (24 loc) · 1.59 KB
/
Copy pathgridmodel.h
File metadata and controls
31 lines (24 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef GRIDMODEL_H
#define GRIDMODEL_H
#include <QAbstractListModel>
#include <QVector>
class GridModel : public QAbstractListModel
{
Q_OBJECT
public:
enum Roles { ColorRole = Qt::UserRole + 1 };
explicit GridModel(QObject *parent = nullptr);
// Функція малювання: приймає рядок, маску комп'ютера, маску гравця та довжину слова
void populateDate(const QString &binaryString, int challengeMask, int playerMask, int dataLength);
int rowCount(const QModelIndex &parent = QModelIndex()) const override; // Повертає кількість елементів
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; // Повертає значення для елемента
QHash<int, QByteArray> roleNames() const override;
private:
QVector<int> m_gridData; // Одномірний вектор для зберігання кольорів сітки (21x21 = 441 елемент)
void setPixel(int row, int col, int value); // Встановлення значення конкретної клітини
void drawFinderPattern(int startRow, int startCol); // Відрисовка великих квадратів
void drawStaticScaffolding(int color); // Відрисовка службових ліній
bool isReserved(int row, int col); // Перевірка, чи належить клітина до службових зон
bool getMaskCondition(int maskId, int r, int c); // Математика масок в одному місці
};
#endif // GRIDMODEL_H