KDevelop API Documentation

kdevbuildsystem.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE project
00002    Copyright (C) 2003 Alexander Dymo <cloudtemple@mksat.net>
00003    Copyright (C) 2003 Roberto Raggi <roberto@kdevelop.org>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018    Boston, MA 02111-1307, USA.
00019 */
00020 
00021 #include <qvbox.h>
00022 #include <qtable.h>
00023 #include <qlayout.h>
00024 
00025 #include <kdialogbase.h>
00026 #include <klocale.h>
00027 #include <kdialog.h>
00028 
00029 #include "kdevbuildsystem.h"
00030 
00031 #include "propertyeditor.h"
00032 
00033 BuildBaseItem::BuildBaseItem( int type, BuildBaseItem * parent )
00034     : m_type( type ), m_parent( parent )
00035 {
00036 }
00037 
00038 BuildBaseItem::~ BuildBaseItem( )
00039 {
00040 }
00041 
00042 QString BuildBaseItem::path( )
00043 {
00044     BuildBaseItem *it = this;
00045     QString p;
00046     while (it)
00047     {
00048         if (!p.isEmpty())
00049             p.prepend("/");
00050         p.prepend(it->name());
00051         it = it->parent();
00052     }
00053     return p;
00054 }
00055 
00056 
00057 // ------------------------------------------------------------------------
00058 BuildGroupItem::BuildGroupItem( const QString & name, BuildGroupItem * parent )
00059     : BuildBaseItem( Group, parent ), m_parentGroup( parent )
00060 {
00061     m_name = name;
00062     if( m_parentGroup )
00063     m_parentGroup->insertGroup( this );
00064 }
00065 
00066 BuildGroupItem::~ BuildGroupItem( )
00067 {
00068     while( m_targets.size() ){
00069         BuildTargetItem* target = m_targets.front();
00070         m_targets.front();
00071     delete target;
00072     }
00073 
00074     while( m_subGroups.size() ){
00075         BuildGroupItem* group = m_subGroups.front();
00076     m_subGroups.pop_front();
00077     delete group;
00078     }
00079 
00080     if( m_parentGroup )
00081     m_parentGroup->takeGroup( this );
00082 }
00083 
00084 void BuildGroupItem::insertGroup( BuildGroupItem * group )
00085 {
00086     m_subGroups.append( group );
00087 }
00088 
00089 void BuildGroupItem::removeGroup( BuildGroupItem * group )
00090 {
00091     m_subGroups.remove( group );
00092     delete( group );
00093 }
00094 
00095 BuildGroupItem * BuildGroupItem::takeGroup( BuildGroupItem * group )
00096 {
00097     m_subGroups.remove( group );
00098     return group;
00099 }
00100 
00101 void BuildGroupItem::insertTarget( BuildTargetItem * target )
00102 {
00103     m_targets.append( target );
00104 }
00105 
00106 void BuildGroupItem::removeTarget( BuildTargetItem * target )
00107 {
00108     m_targets.remove( target );
00109     delete( target );
00110 }
00111 
00112 BuildTargetItem * BuildGroupItem::takeTarget( BuildTargetItem * target )
00113 {
00114     m_targets.remove( target );
00115     return target;
00116 }
00117 
00118 // ------------------------------------------------------------------------
00119 BuildTargetItem::BuildTargetItem( const QString & name, BuildGroupItem * parentGroup )
00120     : BuildBaseItem( Target, parentGroup ), m_parentGroup( parentGroup )
00121 {
00122     m_name = name;
00123     if( m_parentGroup )
00124     m_parentGroup->insertTarget( this );
00125 }
00126 
00127 BuildTargetItem::~ BuildTargetItem( )
00128 {
00129     while( m_files.size() ){
00130         BuildFileItem* file = m_files.front();
00131     m_files.pop_front();
00132     delete file;
00133     }
00134 
00135     if( m_parentGroup )
00136     m_parentGroup->takeTarget( this );
00137 }
00138 
00139 void BuildTargetItem::insertFile( BuildFileItem * file )
00140 {
00141     m_files.append( file );
00142 }
00143 
00144 void BuildTargetItem::removeFile( BuildFileItem * file )
00145 {
00146     m_files.remove( file );
00147     delete( file );
00148 }
00149 
00150 BuildFileItem * BuildTargetItem::takeFile( BuildFileItem * file )
00151 {
00152     m_files.remove( file );
00153     return file;
00154 }
00155 
00156 // ------------------------------------------------------
00157 BuildFileItem::BuildFileItem( const KURL & url, BuildTargetItem * parentTarget )
00158     : BuildBaseItem( File, parentTarget ), m_url( url ), m_parentTarget( parentTarget )
00159 {
00160     if( m_parentTarget )
00161     m_parentTarget->insertFile( this );
00162 }
00163 
00164 BuildFileItem::~ BuildFileItem( )
00165 {
00166     if( m_parentTarget )
00167         m_parentTarget->takeFile( this );
00168 }
00169 
00170 
00171 // ------------------------------------------------------
00172 
00173 
00174 void KDevBuildSystem::addDefaultBuildWidget(KDialogBase *dlg, QWidget *parent, BuildBaseItem *it )
00175 {
00176     BuildItemConfigWidget *w = new BuildItemConfigWidget(it, parent);
00177     connect( dlg, SIGNAL(okClicked()), w, SLOT(accept()) );
00178 }
00179 
00180 
00181 KDevBuildSystem::~ KDevBuildSystem( )
00182 {
00183 }
00184 
00185 KDevBuildSystem::KDevBuildSystem( QObject *parent, const char * name )
00186     :QObject(parent, name)
00187 {
00188 }
00189 
00190 void KDevBuildSystem::configureBuildItem( KDialogBase * dlg, BuildBaseItem * it)
00191 {
00192     qWarning("KDevBuildSystem::configureBuildItem");
00193     if (!dlg)
00194         return;
00195     qWarning("KDevBuildSystem::configureBuildItem: dlg exists");
00196     QVBox *vbox;
00197     vbox = dlg->addVBoxPage(i18n("Properties"));
00198     addDefaultBuildWidget(dlg, vbox, it);
00199 }
00200 
00201 void KDevBuildSystem::initProject( KDevProject * project )
00202 {
00203     m_project = project;
00204 }
00205 
00206 KDevProject * KDevBuildSystem::project( )
00207 {
00208     return m_project;
00209 }
00210 
00211 void KDevBuildSystem::updateDefaultBuildWidget( )
00212 {
00213 }
00214 
00215 
00216 
00217 
00218 // ------------------------------------------------------
00219 BuildItemConfigWidget::BuildItemConfigWidget( BuildBaseItem *it, QWidget * parent, const char * name )
00220     :QWidget(parent, name)
00221 {
00222     QVBoxLayout *l = new QVBoxLayout(this, 2, 0);
00223     PropertyLib::PropertyEditor *ed = new PropertyLib::PropertyEditor(this, "item_propeditor");
00224     ed->populateProperties(&(it->attributes()));
00225     l->addWidget(ed);
00226 }
00227 
00228 void BuildItemConfigWidget::accept( )
00229 {
00230 }
00231 
00232 
00233 
00234 
00235 // ------------------------------------------------------
00236 ProjectConfigTab::ProjectConfigTab( QWidget * parent, const char * name )
00237     :QWidget(parent, name)
00238 {
00239 }
00240 
00241 BuildFileItem * BuildTargetItem::fileByName( const QString & fileName )
00242 {
00243     for( QValueList<BuildFileItem*>::Iterator it=m_files.begin(); it!=m_files.end(); ++it )
00244     {
00245     BuildFileItem* file = *it;
00246     if( file->name() == fileName )
00247         return file;
00248     }
00249 
00250     return 0;
00251 }
00252 
00253 BuildTargetItem * BuildGroupItem::targetByName( const QString & targetName )
00254 {
00255     for( QValueList<BuildTargetItem*>::Iterator it=m_targets.begin(); it!=m_targets.end(); ++it )
00256     {
00257     BuildTargetItem* target = *it;
00258     if( target->name() == targetName )
00259         return target;
00260     }
00261 
00262     return 0;
00263 }
00264 
00265 BuildGroupItem * BuildGroupItem::groupByname( const QString & groupName )
00266 {
00267     for( QValueList<BuildGroupItem*>::Iterator it=m_subGroups.begin(); it!=m_subGroups.end(); ++it )
00268     {
00269     BuildGroupItem* group = *it;
00270     if( group->name() == groupName )
00271         return group;
00272     }
00273 
00274     return 0;
00275 }
00276 
00277 #include "kdevbuildsystem.moc"
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 23 00:03:52 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003