forked from microsoft/AdaptiveCards
-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathCollectionItemModel.h
More file actions
55 lines (42 loc) · 1.59 KB
/
CollectionItemModel.h
File metadata and controls
55 lines (42 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#pragma once
#include <QAbstractListModel>
#include <SharedAdaptiveCard.h>
#include <TextBlock.h>
#include <Image.h>
#include "Enums.h"
class TextBlockModel;
class ImageModel;
#include "RichTextBlock.h"
#include "NumberInput.h"
#include "Enums.h"
class TextBlockModel;
class RichTextBlockModel;
class NumberInputModel;
class CollectionItemModel : public QAbstractListModel
{
Q_OBJECT
enum CollectionModelRole
{
DelegateType = Qt::UserRole + 1,
TextBlockRole,
ImageRole,
RichTextBlockRole,
NumberInputRole,
FillHeightRole
};
public:
using RowContent = std::unordered_map<int, QVariant>;
explicit CollectionItemModel(std::vector<std::shared_ptr<AdaptiveCards::BaseCardElement>> elements, QObject* parent = nullptr);
~CollectionItemModel();
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:
std::vector<RowContent> mRows;
private:
void populateRowData(std::shared_ptr<AdaptiveCards::BaseCardElement> element);
void populateTextBlockModel(std::shared_ptr<AdaptiveCards::TextBlock> textBlock, RowContent& rowContent);
void populateImageModel(std::shared_ptr<AdaptiveCards::Image> image, RowContent& rowContent);
void populateRichTextBlockModel(std::shared_ptr<AdaptiveCards::RichTextBlock> rightTextBlock, RowContent& rowContent);
void populateNumberInputModel(std::shared_ptr<AdaptiveCards::NumberInput> numberInput, RowContent& rowContent);
};