RhythmGame 1.4.3
Loading...
Searching...
No Matches
Lr2SelectBarModel.h
Go to the documentation of this file.
1#pragma once
2
5
6#include <QAbstractListModel>
7#include <QMetaObject>
8#include <QPointer>
9#include <QVariantList>
10#include <QtQml/qqmlregistration.h>
11
13
14class Lr2SelectBarModel : public QAbstractListModel {
15 Q_OBJECT
16 QML_ELEMENT
20 Q_PROPERTY(int centerRow READ centerRow WRITE setCenterRow NOTIFY centerRowChanged)
23 Q_PROPERTY(int slotOffset READ slotOffset NOTIFY slotOffsetChanged)
24 Q_PROPERTY(QVariantList cells READ cells NOTIFY cellsChanged)
25
26public:
50 Q_ENUM(Roles)
51
52 explicit Lr2SelectBarModel(QObject* parent = nullptr);
53
54 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
55 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
56 QHash<int, QByteArray> roleNames() const override;
57
60
61 int logicalCount() const;
62 void setLogicalCount(int count);
63
64 int rowCountLimit() const;
65 void setRowCountLimit(int count);
66
67 int centerRow() const;
68 void setCenterRow(int row);
69
70 int currentIndex() const;
71 void setCurrentIndex(int index);
72
75
76 int slotOffset() const;
77 QVariantList cells() const;
78
79 Q_INVOKABLE void rebuild();
80 Q_INVOKABLE void scrollBy(int delta);
81
82signals:
91
92private:
93 struct BarRow {
94 int visualRow = 0;
95 int sourceRow = 0;
96 int slot = 0;
97 };
98
99 QVariant sourceData(const BarRow& row, int sourceRole) const;
100 QVariant roleData(const BarRow& row, int role) const;
101 int sourceCount() const;
102 int normalizedSourceRow(int row) const;
103 int sourceRowForVisualRow(int visualRow) const;
104 int slotForRow(int row) const;
105 void disconnectSourceModel();
106 void connectSourceModel();
107 void rebuildRows();
108 void emitAllRowsChanged();
109 void ensureCellList(int count);
110 void setSlotOffsetValue(int offset);
111 void syncRowSlots();
112 void updateCellAtSlot(int slot, const BarRow& row);
113 void updateCellForVisualRow(int row);
114 void updateCellsForSourceRows(int first, int last);
115 void updateAllCells();
116 void disconnectVisualState();
117 void connectVisualState();
118 void syncCurrentIndexFromVisualState();
119
120 QPointer<Lr2SelectItemModel> m_sourceModel;
121 QPointer<Lr2SelectVisualState> m_visualState;
122 QList<QMetaObject::Connection> m_sourceConnections;
123 QMetaObject::Connection m_visualStateConnection;
124 QList<BarRow> m_rows;
125 QList<QPointer<Lr2SelectBarCell>> m_cellObjects;
126 QVariantList m_cellValues;
127 int m_logicalCount = 0;
128 int m_rowCountLimit = 0;
129 int m_centerRow = 0;
130 int m_currentIndex = 0;
131 int m_slotOffset = 0;
132};
QByteArray data
Definition Lr2FontCache.cpp:25
int count
Definition Lr2SkinParser.cpp:1067
zip_uint64_t index
Definition SongAssetStore.cpp:436
Definition Lr2SelectBarCell.h:8
Definition Lr2SelectBarModel.h:14
void currentIndexChanged()
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition Lr2SelectBarModel.cpp:24
int slotOffset
Definition Lr2SelectBarModel.h:23
Roles
Definition Lr2SelectBarModel.h:27
@ EntryKeyRole
Definition Lr2SelectBarModel.h:31
@ TextRole
Definition Lr2SelectBarModel.h:32
@ RowRole
Definition Lr2SelectBarModel.h:28
@ KeymodeRole
Definition Lr2SelectBarModel.h:37
@ SlotRole
Definition Lr2SelectBarModel.h:29
@ SourceRowRole
Definition Lr2SelectBarModel.h:30
@ RankRole
Definition Lr2SelectBarModel.h:43
@ DifficultyRole
Definition Lr2SelectBarModel.h:36
@ TitleTypeRole
Definition Lr2SelectBarModel.h:33
@ LabelMaskRole
Definition Lr2SelectBarModel.h:44
@ FolderLikeRole
Definition Lr2SelectBarModel.h:40
@ PlayLevelRole
Definition Lr2SelectBarModel.h:35
@ LampRole
Definition Lr2SelectBarModel.h:42
@ GraphRanksRole
Definition Lr2SelectBarModel.h:46
@ ChartLikeRole
Definition Lr2SelectBarModel.h:38
@ EntryLikeRole
Definition Lr2SelectBarModel.h:39
@ BodyTypeRole
Definition Lr2SelectBarModel.h:34
@ RawItemRole
Definition Lr2SelectBarModel.h:47
@ RankingRole
Definition Lr2SelectBarModel.h:41
@ ArenaAvailabilityRole
Definition Lr2SelectBarModel.h:48
@ GraphLampsRole
Definition Lr2SelectBarModel.h:45
void setCurrentIndex(int index)
Definition Lr2SelectBarModel.cpp:123
QHash< int, QByteArray > roleNames() const override
Definition Lr2SelectBarModel.cpp:35
void slotOffsetChanged()
Q_INVOKABLE void scrollBy(int delta)
Definition Lr2SelectBarModel.cpp:184
void rowCountLimitChanged()
void sourceModelChanged()
Q_INVOKABLE void rebuild()
Definition Lr2SelectBarModel.cpp:180
void visualStateChanged()
QML_ELEMENTLr2SelectItemModel * sourceModel
Definition Lr2SelectBarModel.h:17
int rowCountLimit
Definition Lr2SelectBarModel.h:19
int logicalCount
Definition Lr2SelectBarModel.h:18
void logicalCountChanged()
void setVisualState(Lr2SelectVisualState *state)
Definition Lr2SelectBarModel.cpp:161
void setCenterRow(int row)
Definition Lr2SelectBarModel.cpp:110
Lr2SelectVisualState * visualState
Definition Lr2SelectBarModel.h:22
QVariantList cells
Definition Lr2SelectBarModel.h:24
void setSourceModel(Lr2SelectItemModel *model)
Definition Lr2SelectBarModel.cpp:65
void setRowCountLimit(int count)
Definition Lr2SelectBarModel.cpp:96
int centerRow
Definition Lr2SelectBarModel.h:20
void setLogicalCount(int count)
Definition Lr2SelectBarModel.cpp:80
int currentIndex
Definition Lr2SelectBarModel.h:21
Definition Lr2SelectItemModel.h:16
Definition Lr2SelectVisualState.h:6