13 |
15 |
14 Model::EditContext Model::edit() |
16 Model::EditContext Model::edit() |
15 { |
17 { |
16 return {*this}; |
18 return {*this}; |
17 } |
19 } |
|
20 |
|
21 int Model::rowCount(const QModelIndex&) const |
|
22 { |
|
23 return size(); |
|
24 } |
|
25 |
|
26 QVariant Model::data(const QModelIndex& index, int role) const |
|
27 { |
|
28 const int row = index.row(); |
|
29 modelobjects::BaseObject* object = this->body[row].get(); |
|
30 switch(role) |
|
31 { |
|
32 case Qt::DisplayRole: |
|
33 return object->textRepresentation(); |
|
34 case Qt::ForegroundRole: |
|
35 return object->textRepresentationForeground(); |
|
36 case Qt::BackgroundRole: |
|
37 return object->textRepresentationBackground(); |
|
38 case Qt::FontRole: |
|
39 return object->textRepresentationFont(); |
|
40 default: |
|
41 return {}; |
|
42 } |
|
43 } |
|
44 |
|
45 QVariant Model::getHeaderProperty(const HeaderProperty property) |
|
46 { |
|
47 switch (property) |
|
48 { |
|
49 case HeaderProperty::Name: |
|
50 return header.name; |
|
51 default: |
|
52 return {}; |
|
53 } |
|
54 } |
|
55 |
|
56 void Model::append(ModelObjectPointer&& object) |
|
57 { |
|
58 this->body.push_back(std::move(object)); |
|
59 } |