00001 /****************************************************************************** 00002 * This file is part of the Gluon Development Platform 00003 * Copyright (c) 2010 Arjen Hiemstra <ahiemstra@heimr.nl> 00004 * Copyright (c) 2010 Dan Leinir Turthra Jensen <admin@leinir.dk> 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2.1 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00019 */ 00020 00021 #include "componentsdock.h" 00022 #include "models/componentmodel.h" 00023 #include "models/modeltest.h" 00024 00025 #include <QtGui/QTreeView> 00026 00027 #include <KDebug> 00028 00029 #include <core/gluonobjectfactory.h> 00030 #include <core/gluonobject.h> 00031 #include <core/debughelper.h> 00032 #include <engine/component.h> 00033 00034 using namespace GluonCreator; 00035 00036 class ComponentsDock::ComponentsDockPrivate 00037 { 00038 public: 00039 ComponentsDockPrivate() 00040 : view( 0 ) 00041 , model( 0 ) 00042 { }; 00043 00044 QTreeView* view; 00045 ComponentModel* model; 00046 }; 00047 00048 ComponentsDock::ComponentsDock( const QString& title, QWidget* parent, Qt::WindowFlags flags ) 00049 : QDockWidget( title, parent, flags ) 00050 { 00051 setObjectName( "ComponentsDock" ); 00052 00053 d = new ComponentsDockPrivate(); 00054 00055 d->view = new QTreeView( this ); 00056 d->view->setSelectionMode( QAbstractItemView::SingleSelection ); 00057 d->view->setDragEnabled( true ); 00058 d->view->setAcceptDrops( false ); 00059 d->view->setDropIndicatorShown( false ); 00060 d->view->setHeaderHidden( true ); 00061 d->view->setIndentation( 0 ); 00062 d->view->setRootIsDecorated( false ); 00063 QString style( "QTreeView::item:has-children {" 00064 "color: palette(button-text);" 00065 "background-color: palette(button);" 00066 "border: 1px solid palette(dark);" 00067 "border-radius: 2px;" 00068 "}" ); 00069 d->view->setStyleSheet( style ); 00070 00071 d->model = new ComponentModel( this ); 00072 d->view->setModel( d->model ); 00073 d->view->expandAll(); 00074 00075 new ModelTest( d->model, this ); 00076 00077 setWidget( d->view ); 00078 } 00079 00080 ComponentsDock::~ComponentsDock() 00081 { 00082 delete d; 00083 }