523 } |
523 } |
524 else |
524 else |
525 return nullptr; |
525 return nullptr; |
526 } |
526 } |
527 |
527 |
|
528 IndexGenerator Model::indices() const |
|
529 { |
|
530 return {this}; |
|
531 } |
|
532 |
528 int Model::rowCount(const QModelIndex&) const |
533 int Model::rowCount(const QModelIndex&) const |
529 { |
534 { |
530 return this->objects().size(); |
535 return this->objects().size(); |
531 } |
536 } |
532 |
537 |
533 QVariant Model::data(const QModelIndex& index, int role) const |
538 QVariant Model::data(const QModelIndex& index, int role) const |
534 { |
539 { |
|
540 if (index.row() < 0 or index.row() >= size()) |
|
541 return {}; |
|
542 |
535 LDObject* object = this->objects()[index.row()]; |
543 LDObject* object = this->objects()[index.row()]; |
536 |
544 |
537 switch (role) |
545 switch (role) |
538 { |
546 { |
539 case Qt::DisplayRole: |
547 case Qt::DisplayRole: |
564 object->isColored() |
572 object->isColored() |
565 and object->color().isValid() |
573 and object->color().isValid() |
566 and object->color() != MainColor |
574 and object->color() != MainColor |
567 and object->color() != EdgeColor |
575 and object->color() != EdgeColor |
568 ) { |
576 ) { |
569 // If the object isn't in the main or edge color, draw this list entry in that color. |
577 // If the object isn't in the main or edge color, draw this list |
|
578 // entry in that color. |
570 return object->color().faceColor(); |
579 return object->color().faceColor(); |
571 } |
580 } |
572 else |
581 else |
573 { |
582 { |
574 return {}; |
583 return {}; |