Aeon Engine c550894
AeonGames Open Source Game Engine
Loading...
Searching...
No Matches
ComponentListModel.cpp
1/*
2Copyright (C) 2018,2019,2025 Rodrigo Jose Hernandez Cordoba
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17#include "ComponentListModel.h"
18#include "aeongames/Scene.hpp"
19#include "aeongames/Node.hpp"
20#include "aeongames/StringId.hpp"
21
22namespace AeonGames
23{
25 ListModel ( parent ) {}
26
28
29 QVariant ComponentListModel::headerData ( int section, Qt::Orientation orientation, int role ) const
30 {
31 if ( ( orientation == Qt::Horizontal ) && ( role == Qt::DisplayRole ) )
32 {
33 switch ( section )
34 {
35 case 0:
36 return QString ( "Node Data" );
37 default:
38 return QVariant();
39 }
40 }
41 return QVariant();
42 }
43
44 int ComponentListModel::rowCount ( const QModelIndex & index ) const
45 {
46 if ( !mNode || index.isValid() )
47 {
48 return 0;
49 }
50 return static_cast<int> ( mNode->GetComponentCount() );
51 }
52
53 QVariant ComponentListModel::data ( const QModelIndex & index, int role ) const
54 {
55 if ( !mNode || !index.isValid() )
56 {
57 return QVariant();
58 }
59 if ( role == Qt::DisplayRole )
60 {
61 return QString ( mNode->GetComponentByIndex ( index.row() )->GetId().GetString() );
62 }
63 return QVariant();
64 }
65}
Header for the Scene class.
int rowCount(const QModelIndex &index=QModelIndex()) const override
Return the number of rows under the given parent.
ComponentListModel(QObject *parent=nullptr)
Construct the component list model.
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Return the data for the given index and role.
virtual ~ComponentListModel()
Destructor.
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Return the header data for the given section, orientation, and role.
Node * mNode
Pointer to the associated node.
Definition ListModel.h:67
ListModel(QObject *parent=nullptr)
Construct the list model.
Definition ListModel.cpp:30
<- This is here just for the literals
Definition AABB.hpp:31