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 #include "TreeController.h" 0018 0019 #include "ConstraintNode.h" 0020 #include "TreeModel.h" 0021 #include "PresetModel.h" 0022 0023 #include "core/support/Debug.h" 0024 0025 #include <QComboBox> 0026 #include <QLabel> 0027 #include <QLayout> 0028 #include <QObject> 0029 #include <QTreeView> 0030 0031 APG::TreeController::TreeController( TreeModel* m, QTreeView* v, QWidget* p ) 0032 : QObject( p ) 0033 , m_model( m ) 0034 , m_view( v ) 0035 { 0036 DEBUG_BLOCK 0037 } 0038 0039 APG::TreeController::~TreeController() 0040 { 0041 DEBUG_BLOCK 0042 } 0043 0044 void 0045 APG::TreeController::addGroup() const 0046 { 0047 QModelIndex newidx = m_model->insertGroup( m_view->currentIndex() ); 0048 m_view->expandAll(); 0049 m_view->setCurrentIndex( newidx ); 0050 } 0051 0052 void 0053 APG::TreeController::addConstraint( const QString& constraintName ) const 0054 { 0055 QModelIndex newidx = m_model->insertConstraint( m_view->currentIndex(), constraintName ); 0056 m_view->setCurrentIndex( newidx ); 0057 } 0058 0059 void 0060 APG::TreeController::removeNode() const 0061 { 0062 bool r = m_model->removeNode( m_view->currentIndex() ); 0063 if ( !r ) 0064 error() << "for some reason, the node could not be removed"; 0065 0066 // force re-selection of root index 0067 if ( m_view->currentIndex() == QModelIndex() ) { 0068 debug() << "deleted root index"; 0069 m_view->setCurrentIndex( m_model->index( 0, 0 ) ); 0070 } 0071 }