File indexing completed on 2024-05-05 04:48:48

0001 /****************************************************************************************
0002  * Copyright (c) 2008-2010 Soren Harward <stharward@gmail.com>                          *
0003  *                                                                                      *
0004  * This program is free software; you can redistribute it and/or modify it under        *
0005  * the terms of the GNU General Public License as published by the Free Software        *
0006  * Foundation; either version 2 of the License, or (at your option) any later           *
0007  * version.                                                                             *
0008  *                                                                                      *
0009  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0010  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0011  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0012  *                                                                                      *
0013  * You should have received a copy of the GNU General Public License along with         *
0014  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0015  ****************************************************************************************/
0016 
0017 #ifndef APG_TREEMODEL
0018 #define APG_TREEMODEL
0019 
0020 #include "core/meta/forward_declarations.h"
0021 
0022 #include <QAbstractItemModel>
0023 #include <QModelIndex>
0024 #include <QVariant>
0025 
0026 class ConstraintNode;
0027 
0028 namespace APG {
0029     class TreeModel : public QAbstractItemModel
0030     {
0031         Q_OBJECT
0032 
0033         public:
0034             explicit TreeModel( ConstraintNode*, QObject* parent = nullptr );
0035             ~TreeModel() override;
0036 
0037             QVariant data( const QModelIndex& index, int role ) const override;
0038             Qt::ItemFlags flags( const QModelIndex& index ) const override;
0039             QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override;
0040             QModelIndex index( int row, int column, const QModelIndex& parent = QModelIndex() ) const override;
0041             QModelIndex parent( const QModelIndex& child ) const override;
0042             int rowCount( const QModelIndex& parent = QModelIndex() ) const override;
0043             int columnCount( const QModelIndex& parent = QModelIndex() ) const override { Q_UNUSED( parent ); return 1; }
0044             bool removeNode( const QModelIndex& );
0045             QModelIndex insertGroup( const QModelIndex& );
0046             QModelIndex insertConstraint( const QModelIndex&, const QString& );
0047 
0048         private Q_SLOTS:
0049             void slotConstraintDataChanged();
0050 
0051         private:
0052             ConstraintNode* m_rootNode;
0053 
0054             void connectDCSlotToNode( ConstraintNode* );
0055     };
0056 }
0057 #endif