KDevelop API Documentation

trollprojectwidget.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2001 by Bernd Gehrmann                                  *
00003  *   bernd@kdevelop.org                                                    *
00004  *   Copyright (C) 2000-2001 by Trolltech AS.                              *
00005  *   info@trolltech.com                                                    *
00006  *   Copyright (C) 2002 by Jakob Simon-Gaarde                              *
00007  *   jakob@jsg.dk                                                          *
00008  *   Copyright (C) 2002-2003 by Alexander Dymo                             *
00009  *   cloudtemple@mksat.net                                                 *
00010  *   Copyright (C) 2003 by Thomas Hasart                                   *
00011  *   thasart@gmx.de                                                        *
00012  *                                                                         *
00013  *   Part of this file is taken from Qt Designer.                          *
00014  *                                                                         *
00015  *   This program is free software; you can redistribute it and/or modify  *
00016  *   it under the terms of the GNU General Public License as published by  *
00017  *   the Free Software Foundation; either version 2 of the License, or     *
00018  *   (at your option) any later version.                                   *
00019  *                                                                         *
00020  ***************************************************************************/
00021 
00022 #include "trollprojectwidget.h"
00023 
00024 #include <config.h>
00025 
00026 #include <qfile.h>
00027 #include <qfileinfo.h>
00028 #include <qheader.h>
00029 #include <qsplitter.h>
00030 #include <qptrstack.h>
00031 #include <qtextstream.h>
00032 #include <qcombobox.h>
00033 #include <qprocess.h>
00034 #include <qtimer.h>
00035 #include <qdir.h>
00036 #include <qregexp.h>
00037 #include <qinputdialog.h>
00038 #include <qwhatsthis.h>
00039 #include <kfiledialog.h>
00040 #include <qtooltip.h>
00041 #include <kdebug.h>
00042 #include <klistview.h>
00043 #include <kmessagebox.h>
00044 #include <kpopupmenu.h>
00045 #include <kregexp.h>
00046 #include <kurl.h>
00047 #include <qmessagebox.h>
00048 #include <iostream>
00049 #include <kparts/part.h>
00050 #include <kaction.h>
00051 #include <kprocess.h>
00052 #include <kinputdialog.h>
00053 #include <kdeversion.h>
00054 #include <kurlrequesterdlg.h>
00055 #include <kurlrequester.h>
00056 #include <kio/netaccess.h>
00057 
00058 #include "kdevcore.h"
00059 #include "kdevpartcontroller.h"
00060 #include "kdevmainwindow.h"
00061 #include "trollprojectpart.h"
00062 #include "kdevappfrontend.h"
00063 #include "kdevmakefrontend.h"
00064 #include "kdevlanguagesupport.h"
00065 #include "kdevcreatefile.h"
00066 #include "subclassesdlg.h"
00067 #include "addfilesdialog.h"
00068 #include "urlutil.h"
00069 #include "pathutil.h"
00070 #include "trolllistview.h"
00071 
00072 #define VALUES_PER_ROW  1
00073 
00074 /*
00075  * Class qProjectItem
00076  */
00077 
00078 qProjectItem::qProjectItem(Type type, QListView *parent, const QString &text)
00079     : QListViewItem(parent, text), typ(type)
00080 {}
00081 
00082 
00083 qProjectItem::qProjectItem(Type type, qProjectItem *parent, const QString &text)
00084     : QListViewItem(parent, text), typ(type)
00085 {}
00086 
00087 
00088 
00089 
00090 /*
00091  * Class SubqmakeprojectItem
00092  */
00093 
00094 SubqmakeprojectItem::SubqmakeprojectItem(QListView *parent, const QString &text, const QString &scopeString)
00095     : qProjectItem(Subproject, parent, text)
00096 {
00097     this->scopeString=scopeString;
00098     configuration.m_template = QTMP_APPLICATION;
00099     init();
00100 }
00101 
00102 
00103 SubqmakeprojectItem::SubqmakeprojectItem(SubqmakeprojectItem *parent, const QString &text,const QString &scopeString)
00104     : qProjectItem(Subproject, parent, text)
00105 {
00106     this->scopeString=scopeString;
00107     init();
00108 }
00109 
00110 SubqmakeprojectItem::~SubqmakeprojectItem()
00111 {
00112 }
00113 QString SubqmakeprojectItem::getRelativPath()
00114 {
00115   if(this->parent()==NULL||this->parent()->parent()==NULL) return("/"+configuration.m_subdirName);
00116   else return(((SubqmakeprojectItem*)this->parent())->getRelativPath()+"/"+configuration.m_subdirName);
00117 }
00118 QString SubqmakeprojectItem::getDownDirs()
00119 {
00120     SubqmakeprojectItem* pItem=this;
00121     while (pItem->parent())
00122         pItem=(SubqmakeprojectItem*)pItem->parent();
00123     return getRelativePath(QDir::cleanDirPath(this->path),QDir::cleanDirPath(pItem->path));
00124 }
00125 QString SubqmakeprojectItem::getSharedLibAddObject(QString downDirs)
00126 {
00127   if(configuration.m_requirements & QD_SHARED)
00128   {
00129     QString tmpPath;
00130     if(configuration.m_destdir!="")
00131     {
00132       if (QDir::isRelativePath(configuration.m_destdir))
00133         tmpPath=downDirs+this->getRelativPath()+"/"+configuration.m_destdir;
00134       else
00135         tmpPath=configuration.m_destdir;
00136     }else{
00137       tmpPath=downDirs+this->getRelativPath()+"/";
00138     }
00139 
00140     tmpPath=QDir::cleanDirPath(tmpPath);
00141 
00142     QString libString;
00143     if(configuration.m_target!="")
00144     {
00145       libString = tmpPath+"/lib"+this->configuration.m_target+".so";
00146 
00147     }else{
00148       libString = tmpPath+"/lib"+this->configuration.m_subdirName.section('/',-1,-1,QString::SectionSkipEmpty)+".so";
00149 
00150     }
00151     return(libString);
00152   }
00153   return "";
00154 }
00155 QString SubqmakeprojectItem::getApplicationObject( QString downDirs )
00156 {
00157   QString tmpPath;
00158   if(configuration.m_destdir!="")
00159   {
00160       if (QDir::isRelativePath(configuration.m_destdir))
00161         tmpPath=downDirs+this->getRelativPath()+"/"+configuration.m_destdir;
00162       else
00163         tmpPath=configuration.m_destdir;
00164   }else{
00165     tmpPath=downDirs+this->getRelativPath()+"/";
00166   }
00167 
00168   tmpPath=QDir::cleanDirPath(tmpPath);
00169 
00170   if (configuration.m_target.isEmpty())
00171     return tmpPath + "/" + configuration.m_subdirName.section('/',-1,-1,QString::SectionSkipEmpty);
00172   else
00173     return tmpPath + "/" + configuration.m_target;
00174 }
00175 QString SubqmakeprojectItem::getLibAddObject(QString downDirs)
00176 {
00177   if(configuration.m_requirements & QD_SHARED)
00178   {
00179     if(configuration.m_target!="")
00180     {
00181       return("-l"+configuration.m_target);
00182     }else{
00183       return("-l"+this->subdir);
00184     }
00185   }else if(configuration.m_requirements & QD_STATIC)
00186   {
00187     QString tmpPath;
00188     if(configuration.m_destdir!="")
00189     {
00190       if (QDir::isRelativePath(configuration.m_destdir))
00191         tmpPath=downDirs+this->getRelativPath()+"/"+configuration.m_destdir;
00192       else
00193         tmpPath=configuration.m_destdir;
00194     }else{
00195       tmpPath=downDirs+this->getRelativPath()+"/";
00196     }
00197 
00198     tmpPath=QDir::cleanDirPath(tmpPath);
00199 
00200     QString libString;
00201     if(configuration.m_target!="")
00202     {
00203       libString = tmpPath+"/lib"+this->configuration.m_target+".a";
00204 
00205     }else{
00206       libString = tmpPath+"/lib"+this->configuration.m_subdirName.section('/',-1,-1,QString::SectionSkipEmpty)+".a";
00207 
00208     }
00209     return(libString);
00210   }
00211 
00212   return("");
00213 }
00214 QString SubqmakeprojectItem::getLibAddPath(QString downDirs)
00215 {
00216 
00217   //PATH only add if shared lib
00218   if(!(configuration.m_requirements & QD_SHARED))return("");
00219 
00220     QString tmpPath;
00221     if(configuration.m_destdir!="")
00222     {
00223       if (QDir::isRelativePath(configuration.m_destdir))
00224         tmpPath=downDirs+this->getRelativPath()+"/"+configuration.m_destdir;
00225       else
00226         tmpPath=configuration.m_destdir;
00227     }else{
00228       tmpPath=downDirs+this->getRelativPath()+"/";
00229     }
00230 
00231     tmpPath=QDir::cleanDirPath(tmpPath);
00232 
00233   return(tmpPath);
00234 
00235 }
00236 QString SubqmakeprojectItem::getIncAddPath(QString downDirs)
00237 {
00238   QString tmpPath=downDirs+this->getRelativPath();
00239   tmpPath=QDir::cleanDirPath(tmpPath);
00240 
00241   return(tmpPath);
00242 }
00243 
00244 void SubqmakeprojectItem::init()
00245 {
00246   configuration.m_template = QTMP_APPLICATION;
00247   configuration.m_warnings = QWARN_ON;
00248   configuration.m_buildMode = QBM_RELEASE;
00249   configuration.m_requirements = QD_QT;
00250   groups.setAutoDelete(true);
00251   if (scopeString.isEmpty())
00252   {
00253     isScope = false;
00254   }
00255   else
00256   {
00257     isScope = true;
00258     setPixmap(0, SmallIcon("qmake_scope"));
00259   }
00260 }
00261 
00262 
00263 /*
00264  * Class GroupItem
00265  */
00266 
00267 GroupItem::GroupItem(QListView *lv, GroupType type, const QString &text, const QString &scopeString)
00268     : qProjectItem(Group, lv, text)
00269 {
00270     this->scopeString = scopeString;
00271     groupType = type;
00272     files.setAutoDelete(true);
00273     setPixmap(0, SmallIcon("tar"));
00274 }
00275 
00276 
00277 
00278 GroupItem::GroupType GroupItem::groupTypeForExtension(const QString &ext)
00279 {
00280     if (ext == "cpp" || ext == "cc" || ext == "c" || ext == "C" || ext == "c++" || ext == "cxx")
00281         return Sources;
00282     else if (ext == "hpp" || ext == "h" || ext == "hxx" || ext == "hh" || ext == "h++" || ext == "H")
00283         return Headers;
00284     else if (ext == "ui")
00285         return Forms;
00286     else if (ext == "idl")
00287         return IDLs;
00288     else if (ext == "l" || ext == "ll" || ext == "lxx" || ext == "l++" )
00289         return Lexsources;
00290     else if (ext == "y" || ext == "yy" || ext == "yxx" || ext == "y++" )
00291         return Yaccsources;
00292     else if (ext == "ts")
00293         return Translations;
00294     else
00295         return NoType;
00296 }
00297 
00298 /*
00299  * Class FileItem
00300  */
00301 
00302 FileItem::FileItem(QListView *lv, const QString &text, bool exclude/*=false*/)
00303     : qProjectItem(File, lv, text)
00304 {
00305     // if excluded is set the file is excluded in the subproject/project.
00306     // by default excluded is set to false, thus file is included
00307     excluded = exclude;
00308     setPixmap(0, SmallIcon("document"));
00309 }
00310 
00311 
00312 TrollProjectWidget::TrollProjectWidget(TrollProjectPart *part)
00313     : QVBox(0, "troll project widget")
00314 {
00315     QSplitter *splitter = new QSplitter(Vertical, this);
00316 
00318     // PROJECT VIEW //
00320 
00321     overviewContainer = new QVBox(splitter,"Projects");
00322     overviewContainer->setMargin ( 2 );
00323     overviewContainer->setSpacing ( 2 );
00324     projectTools = new QHBox(overviewContainer,"Project buttons");
00325     projectTools->setMargin ( 2 );
00326     projectTools->setSpacing ( 2 );
00327     // Add subdir
00328     addSubdirButton = new QToolButton ( projectTools, "Add subproject button" );
00329     addSubdirButton->setPixmap ( SmallIcon ( "folder_new" ) );
00330     addSubdirButton->setSizePolicy ( QSizePolicy ( ( QSizePolicy::SizeType ) 0, ( QSizePolicy::SizeType) 0, 0, 0, addSubdirButton->sizePolicy().hasHeightForWidth() ) );
00331     addSubdirButton->setEnabled ( true );
00332     QToolTip::add( addSubdirButton, i18n( "Add subproject" ) );
00333     QWhatsThis::add(addSubdirButton, i18n("<b>Add subproject</b><p>Creates a <i>new</i> or adds an <i>existing</i> subproject to a currently selected subproject. "
00334         "This action is allowed only if a type of the subproject is 'subdirectories'. The type of the subproject can be "
00335         "defined in <b>Subproject Settings</b> dialog (open it from the subproject context menu)."));
00336     // Create scope
00337     createScopeButton = new QToolButton ( projectTools, "Create scope button" );
00338     createScopeButton->setPixmap ( SmallIcon ( "qmake_scopenew" ) );
00339     createScopeButton->setSizePolicy ( QSizePolicy ( ( QSizePolicy::SizeType ) 0, ( QSizePolicy::SizeType) 0, 0, 0, createScopeButton->sizePolicy().hasHeightForWidth() ) );
00340     createScopeButton->setEnabled ( true );
00341     QToolTip::add( createScopeButton, i18n( "Create scope" ) );
00342     QWhatsThis::add(createScopeButton, i18n("<b>Create scope</b><p>Creates QMake scope in the project file in case the subproject is selected or creates nested scope in case the scope is selected."));
00343     // build selected file
00344     buildFileButton = new QToolButton ( projectTools, "Make file button" );
00345     buildFileButton->setPixmap ( SmallIcon ( "compfile" ) );
00346     buildFileButton->setSizePolicy ( QSizePolicy ( ( QSizePolicy::SizeType ) 0, ( QSizePolicy::SizeType) 0, 0, 0, buildFileButton->sizePolicy().hasHeightForWidth() ) );
00347     buildFileButton->setEnabled ( true );
00348     QToolTip::add( buildFileButton, i18n( "Compile file" ) );
00349     QWhatsThis::add(buildFileButton, i18n("<b>Compile file</b><p>Runs <b>make filename.o</b> command from the directory where 'filename' is the name of currently opened file.<br>"
00350                               "Environment variables and make arguments can be specified "
00351                               "in the project settings dialog, <b>Make Options</b> tab."));
00352     // build
00353     buildProjectButton = new QToolButton ( projectTools, "Make button" );
00354     buildProjectButton->setPixmap ( SmallIcon ( "make_kdevelop" ) );
00355     buildProjectButton->setSizePolicy ( QSizePolicy ( ( QSizePolicy::SizeType ) 0, ( QSizePolicy::SizeType) 0, 0, 0, buildProjectButton->sizePolicy().hasHeightForWidth() ) );
00356     buildProjectButton->setEnabled ( true );
00357     QToolTip::add( buildProjectButton, i18n( "Build project" ) );
00358     QWhatsThis::add(buildProjectButton, i18n("<b>Build project</b><p>Runs <b>make</b> from the project directory.<br>"
00359                               "Environment variables and make arguments can be specified "
00360                               "in the project settings dialog, <b>Make Options</b> tab."));
00361     // rebuild
00362     rebuildProjectButton = new QToolButton ( projectTools, "Rebuild button" );
00363     rebuildProjectButton->setPixmap ( SmallIcon ( "rebuild" ) );
00364     rebuildProjectButton->setSizePolicy ( QSizePolicy ( ( QSizePolicy::SizeType ) 0, ( QSizePolicy::SizeType) 0, 0, 0, rebuildProjectButton->sizePolicy().hasHeightForWidth() ) );
00365     rebuildProjectButton->setEnabled ( true );
00366     QToolTip::add( rebuildProjectButton, i18n( "Rebuild project" ) );
00367     QWhatsThis::add(rebuildProjectButton, i18n("<b>Rebuild project</b><p>Runs <b>make clean</b> and then <b>make</b> from the project directory.<br>"
00368                               "Environment variables and make arguments can be specified "
00369                               "in the project settings dialog, <b>Make Options</b> tab."));
00370     // run
00371     executeProjectButton = new QToolButton ( projectTools, "Run button" );
00372     executeProjectButton->setPixmap ( SmallIcon ( "exec" ) );
00373     executeProjectButton->setSizePolicy ( QSizePolicy ( ( QSizePolicy::SizeType ) 0, ( QSizePolicy::SizeType) 0, 0, 0, executeProjectButton->sizePolicy().hasHeightForWidth() ) );
00374     executeProjectButton->setEnabled ( true );
00375     QToolTip::add( executeProjectButton, i18n( "Execute main program" ) );
00376     QWhatsThis::add(executeProjectButton, i18n("<b>Execute main program</b><p>Executes the main program specified in project settings, <b>Run Options</b> tab."));
00377     // spacer
00378     QWidget *spacer = new QWidget(projectTools);
00379     projectTools->setStretchFactor(spacer, 1);
00380     // Project configuration
00381     projectconfButton = new QToolButton ( projectTools, "Project configuration button" );
00382     projectconfButton->setPixmap ( SmallIcon ( "configure" ) );
00383     projectconfButton->setSizePolicy ( QSizePolicy ( ( QSizePolicy::SizeType ) 0, ( QSizePolicy::SizeType) 0, 0, 0, projectconfButton->sizePolicy().hasHeightForWidth() ) );
00384     projectconfButton->setEnabled ( true );
00385     QToolTip::add( projectconfButton, i18n( "Subproject settings" ) );
00386     QWhatsThis::add(projectconfButton, i18n("<b>Subproject settings</b><p>Opens <b>QMake Subproject Configuration</b> dialog for the currently selected subproject. "
00387         "It provides settings for:<br>subproject type and configuration,<br>include and library paths,<br>lists of dependencies and "
00388         "external libraries,<br>build order,<br>intermediate files locations,<br>compiler options."));
00389 
00390     // Project button connections
00391     connect ( addSubdirButton, SIGNAL ( clicked () ), this, SLOT ( slotAddSubdir () ) );
00392     connect ( createScopeButton, SIGNAL ( clicked () ), this, SLOT ( slotCreateScope () ) );
00393     connect ( buildFileButton, SIGNAL ( clicked () ), this, SLOT ( slotBuildFile () ) );
00394 
00395     connect ( buildProjectButton, SIGNAL ( clicked () ), this, SLOT ( slotBuildProject () ) );
00396     connect ( rebuildProjectButton, SIGNAL ( clicked () ), this, SLOT ( slotRebuildProject () ) );
00397     connect ( executeProjectButton, SIGNAL ( clicked () ), this, SLOT ( slotExecuteProject () ) );
00398 
00399 
00400 
00401     connect ( projectconfButton, SIGNAL ( clicked () ), this, SLOT ( slotConfigureProject () ) );
00402 
00403     // Project tree
00404     overview = new TrollListView(this, overviewContainer, SubprojectView, "project overview widget");
00405     overview->setResizeMode(QListView::LastColumn);
00406     overview->setSorting(-1);
00407     overview->header()->hide();
00408     overview->addColumn(QString::null);
00409 
00410     // Project tree connections
00411     connect( overview, SIGNAL(selectionChanged(QListViewItem*)),
00412              this, SLOT(slotOverviewSelectionChanged(QListViewItem*)) );
00413     connect( overview, SIGNAL(contextMenu(KListView*, QListViewItem*, const QPoint&)),
00414              this, SLOT(slotOverviewContextMenu(KListView*, QListViewItem*, const QPoint&)) );
00415 
00416 
00418     // DETAIL VIEW //
00420 
00421     // Details tree
00422     detailContainer = new QVBox(splitter,"Details");
00423     detailContainer->setMargin ( 2 );
00424     detailContainer->setSpacing ( 2 );
00425 
00426     // Details Toolbar
00427     fileTools = new QHBox(detailContainer,"Detail buttons");
00428     fileTools->setMargin ( 2 );
00429     fileTools->setSpacing ( 2 );
00430 
00431     // Add new file button
00432     newfileButton = new QToolButton ( fileTools, "Create new file" );
00433     newfileButton->setPixmap ( SmallIcon ( "filenew" ) );
00434     newfileButton->setSizePolicy ( QSizePolicy ( ( QSizePolicy::SizeType ) 0, ( QSizePolicy::SizeType) 0, 0, 0, newfileButton->sizePolicy().hasHeightForWidth() ) );
00435     newfileButton->setEnabled ( true );
00436     QToolTip::add( newfileButton, i18n( "Create new file" ) );
00437     QWhatsThis::add(newfileButton, i18n("<b>Create new file</b><p>Creates a new file and adds it to a currently selected group."));
00438 
00439     // Add existing files button
00440     addfilesButton = new QToolButton ( fileTools, "Add existing files" );
00441     addfilesButton->setPixmap ( SmallIcon ( "fileimport" ) );
00442     addfilesButton->setSizePolicy ( QSizePolicy ( ( QSizePolicy::SizeType ) 0, ( QSizePolicy::SizeType) 0, 0, 0, addfilesButton->sizePolicy().hasHeightForWidth() ) );
00443     addfilesButton->setEnabled ( true );
00444     QToolTip::add( addfilesButton, i18n( "Add existing files" ) );
00445     QWhatsThis::add(addfilesButton, i18n("<b>Add existing files</b><p>Adds existing files to a currently selected group. It is "
00446             "possible to copy files to a current subproject directory, create symbolic links or "
00447             "add them with the relative path."));
00448 
00449     // remove file button
00450     removefileButton = new QToolButton ( fileTools, "Remove file" );
00451     removefileButton->setPixmap ( SmallIcon ( "button_cancel" ) );
00452     removefileButton->setSizePolicy ( QSizePolicy ( ( QSizePolicy::SizeType ) 0, ( QSizePolicy::SizeType) 0, 0, 0, removefileButton->sizePolicy().hasHeightForWidth() ) );
00453     removefileButton->setEnabled ( true );
00454     QToolTip::add( removefileButton, i18n( "Remove file" ) );
00455     QWhatsThis::add(removefileButton, i18n("<b>Remove file</b><p>Removes file from a current group. Does not remove file from disk."));
00456 
00457     // build
00458     buildTargetButton = new QToolButton ( fileTools, "Make sp button" );
00459     buildTargetButton->setPixmap ( SmallIcon ( "make_kdevelop" ) );
00460     buildTargetButton->setSizePolicy ( QSizePolicy ( ( QSizePolicy::SizeType ) 0, ( QSizePolicy::SizeType) 0, 0, 0, buildTargetButton->sizePolicy().hasHeightForWidth() ) );
00461     buildTargetButton->setEnabled ( true );
00462     QToolTip::add( buildTargetButton, i18n( "Build subproject" ) );
00463     QWhatsThis::add(buildTargetButton, i18n("<b>Build subproject</b><p>Runs <b>make</b> from the current subproject directory. "
00464                               "Current subproject is a subproject selected in <b>QMake manager</b> 'overview' window.<br>"
00465                               "Environment variables and make arguments can be specified "
00466                               "in the project settings dialog, <b>Make Options</b> tab."));
00467     // rebuild
00468     rebuildTargetButton = new QToolButton ( fileTools, "Rebuild sp button" );
00469     rebuildTargetButton->setPixmap ( SmallIcon ( "rebuild" ) );
00470     rebuildTargetButton->setSizePolicy ( QSizePolicy ( ( QSizePolicy::SizeType ) 0, ( QSizePolicy::SizeType) 0, 0, 0, rebuildTargetButton->sizePolicy().hasHeightForWidth() ) );
00471     rebuildTargetButton->setEnabled ( true );
00472     QToolTip::add( rebuildTargetButton, i18n( "Rebuild subproject" ) );
00473     QWhatsThis::add(rebuildTargetButton, i18n("<b>Rebuild subproject</b><p>Runs <b>make clean</b> and then <b>make</b> from the current subproject directory. "
00474                               "Current subproject is a subproject selected in <b>QMake manager</b> 'overview' window.<br>"
00475                               "Environment variables and make arguments can be specified "
00476                               "in the project settings dialog, <b>Make Options</b> tab."));
00477     // run
00478     executeTargetButton = new QToolButton ( fileTools, "Run sp button" );
00479     executeTargetButton->setPixmap ( SmallIcon ( "exec" ) );
00480     executeTargetButton->setSizePolicy ( QSizePolicy ( ( QSizePolicy::SizeType ) 0, ( QSizePolicy::SizeType) 0, 0, 0, executeTargetButton->sizePolicy().hasHeightForWidth() ) );
00481     executeTargetButton->setEnabled ( true );
00482     QToolTip::add( executeTargetButton, i18n( "Execute subproject" ) );
00483     QWhatsThis::add(executeTargetButton, i18n("<b>Execute subproject</b><p>Executes the target program for the currently selected subproject. "
00484         "This action is allowed only if a type of the subproject is 'application'. The type of the subproject can be "
00485         "defined in <b>Subproject Settings</b> dialog (open it from the subproject context menu)."));
00486 
00487 
00488     // spacer
00489     spacer = new QWidget(fileTools);
00490     projectTools->setStretchFactor(spacer, 1);
00491 
00492     // Configure file button
00493     configurefileButton = new QToolButton ( fileTools, "Configure file" );
00494     configurefileButton->setPixmap ( SmallIcon ( "configure_file" ) );
00495     configurefileButton->setSizePolicy ( QSizePolicy ( ( QSizePolicy::SizeType ) 0, ( QSizePolicy::SizeType) 0, 0, 0, configurefileButton->sizePolicy().hasHeightForWidth() ) );
00496     configurefileButton->setEnabled ( true );
00497     QToolTip::add( configurefileButton, i18n( "Configure file" ) );
00498     QWhatsThis::add(configurefileButton, i18n("<b>Configure file</b><p>Opens <b>File Properties</b> dialog that allows a file to be excluded from specified scopes."));
00499 
00500     // detail tree
00501     details = new TrollListView(this, detailContainer, DetailsView, "details widget");
00502     details->setRootIsDecorated(true);
00503     details->setResizeMode(QListView::LastColumn);
00504     details->setSorting(-1);
00505     details->header()->hide();
00506     details->addColumn(QString::null);
00507 
00508     // Detail button connections
00509     connect ( addfilesButton, SIGNAL ( clicked () ), this, SLOT ( slotAddFiles () ) );
00510     connect ( newfileButton, SIGNAL ( clicked () ), this, SLOT ( slotNewFile () ) );
00511     connect ( removefileButton, SIGNAL ( clicked () ), this, SLOT ( slotRemoveFile () ) );
00512     connect ( configurefileButton, SIGNAL ( clicked () ), this, SLOT ( slotConfigureFile () ) );
00513 
00514     // Detail tree connections
00515     connect( details, SIGNAL(selectionChanged(QListViewItem*)),
00516              this, SLOT(slotDetailsSelectionChanged(QListViewItem*)) );
00517     connect( details, SIGNAL(executed(QListViewItem*)),
00518              this, SLOT(slotDetailsExecuted(QListViewItem*)) );
00519     connect( details, SIGNAL(contextMenu(KListView*, QListViewItem*, const QPoint&)),
00520              this, SLOT(slotDetailsContextMenu(KListView*, QListViewItem*, const QPoint&)) );
00521 
00522     connect ( buildTargetButton, SIGNAL ( clicked () ), this, SLOT ( slotBuildTarget () ) );
00523     connect ( rebuildTargetButton, SIGNAL ( clicked () ), this, SLOT ( slotRebuildTarget () ) );
00524     connect ( executeTargetButton, SIGNAL ( clicked () ), this, SLOT ( slotExecuteTarget () ) );
00525     buildTargetButton->setEnabled(false);
00526     rebuildTargetButton->setEnabled(false);
00527     executeTargetButton->setEnabled(false);
00528 
00529 
00530 
00531     m_part = part;
00532     m_shownSubproject = 0;
00533     m_rootSubproject = 0;
00534 }
00535 
00536 
00537 TrollProjectWidget::~TrollProjectWidget()
00538 {}
00539 
00540 
00541 void TrollProjectWidget::openProject(const QString &dirName)
00542 {
00543     QDomDocument &dom = *(m_part->projectDom());
00544     m_subclasslist = DomUtil::readPairListEntry(dom,"/kdevtrollproject/subclassing" ,
00545                                                     "subclass","sourcefile", "uifile");
00546     SubqmakeprojectItem *item = new SubqmakeprojectItem(overview, "/","");
00547     item->subdir = dirName.right(dirName.length()-dirName.findRev('/')-1);
00548     item->path = dirName;
00549     item->m_RootBuffer = &(item->m_FileBuffer);
00550     parse(item);
00551     item->setOpen(true);
00552     m_rootSubproject = item;
00553     overview->setSelected(item, true);
00554 }
00555 
00556 
00557 void TrollProjectWidget::closeProject()
00558 {
00559     m_rootSubproject = 0;
00560     overview->clear();
00561     details->clear();
00562 }
00563 
00564 
00565 QStringList TrollProjectWidget::allSubprojects()
00566 {
00567     int prefixlen = projectDirectory().length()+1;
00568     QStringList res;
00569 
00570     QListViewItemIterator it(overview);
00571     for (; it.current(); ++it) {
00572         if (it.current() == overview->firstChild())
00573             continue;
00574         QString path = static_cast<SubqmakeprojectItem*>(it.current())->path;
00575         res.append(path.mid(prefixlen));
00576     }
00577 
00578     return res;
00579 }
00580 
00581 
00582 QStringList TrollProjectWidget::allFiles()
00583 {
00584     QPtrStack<QListViewItem> s;
00585     QStringList res;
00586 
00587     for ( QListViewItem *item = overview->firstChild(); item;
00588           item = item->nextSibling()? item->nextSibling() : s.pop() ) {
00589         if (item->firstChild())
00590             s.push(item->firstChild());
00591 
00592         SubqmakeprojectItem *spitem = static_cast<SubqmakeprojectItem*>(item);
00593         QString path = spitem->path;
00594 
00595         for (QPtrListIterator<GroupItem> tit(spitem->groups); tit.current(); ++tit) {
00596             GroupItem::GroupType type = (*tit)->groupType;
00597 
00598             if (type == GroupItem::Sources || type == GroupItem::Headers || type == GroupItem::Forms || type == GroupItem::Images ||
00599             type ==  GroupItem::Lexsources || type ==  GroupItem::Yaccsources || type == GroupItem::Distfiles ||
00600         type ==  GroupItem::Translations || type ==  GroupItem::IDLs || type ==  GroupItem::InstallObject  ) {
00601         for (QPtrListIterator<FileItem> fit(tit.current()->files); fit.current(); ++fit){
00602             QString filePath = path.mid( projectDirectory().length() + 1 );
00603 
00604             if( !filePath.isEmpty() && !filePath.endsWith("/") )
00605             filePath += "/";
00606                     res.append( filePath + (*fit)->name);
00607         }
00608             }
00609         }
00610     }
00611 
00612     return res;
00613 }
00614 
00615 QString TrollProjectWidget::projectDirectory()
00616 {
00617     if (!overview->firstChild())
00618         return QString::null; //confused
00619 
00620     return static_cast<SubqmakeprojectItem*>(overview->firstChild())->path;
00621 }
00622 
00623 
00624 QString TrollProjectWidget::subprojectDirectory()
00625 {
00626     if (!m_shownSubproject)
00627         return QString::null;
00628 
00629     return m_shownSubproject->path;
00630 }
00631 
00632 void TrollProjectWidget::setupContext()
00633 {
00634     if (!m_shownSubproject)
00635       return;
00636     bool buildable = true;
00637     bool runable = true;
00638     bool projectconfigurable = true;
00639     bool fileconfigurable = true;
00640     bool hasSourceFiles = true;
00641     bool hasSubdirs = false;
00642 
00643 
00644     if (m_shownSubproject->configuration.m_template==QTMP_LIBRARY)
00645     {
00646       runable = false;
00647     }
00648     else if (m_shownSubproject->configuration.m_template==QTMP_SUBDIRS)
00649     {
00650       hasSubdirs = true;
00651       addSubdirButton->setEnabled(true);
00652       runable = false;
00653       hasSourceFiles = false;
00654       fileconfigurable = false;
00655     }
00656     if (m_shownSubproject->isScope)
00657     {
00658       runable = false;
00659       projectconfigurable = false;
00660       buildable = false;
00661     }
00662 
00663 
00664     // Setup toolbars according to context
00665     addSubdirButton->setEnabled(hasSubdirs);
00666     buildTargetButton->setEnabled(buildable);
00667     m_part->actionCollection()->action("build_build_target")->setEnabled(buildable);
00668 
00669     rebuildTargetButton->setEnabled(buildable);
00670     m_part->actionCollection()->action("build_rebuild_target")->setEnabled(buildable);
00671 
00672     executeTargetButton->setEnabled(runable);
00673     m_part->actionCollection()->action("build_execute_target")->setEnabled(runable);
00674 
00675 
00676     projectconfButton->setEnabled(projectconfigurable);
00677 
00678     configurefileButton->setEnabled(false);
00679     newfileButton->setEnabled(true);
00680     removefileButton->setEnabled(false);
00681     addfilesButton->setEnabled(true);
00682 
00683     details->setEnabled(hasSourceFiles);
00684 }
00685 
00686 void TrollProjectWidget::slotOverviewSelectionChanged(QListViewItem *item)
00687 {
00688     if (!item)
00689         return;
00690     cleanDetailView(m_shownSubproject);
00691     m_shownSubproject = static_cast<SubqmakeprojectItem*>(item);
00692     setupContext();
00693     buildProjectDetailTree(m_shownSubproject,details);
00694 
00695     QString subProjPath = m_shownSubproject->path;
00696     QString relpath = subProjPath.remove(0,projectDirectory().length()+1);
00697     QDomDocument &dom = *(m_part->projectDom());
00698     DomUtil::writeEntry(dom, "/kdevtrollproject/general/activedir",relpath);
00699 
00700 }
00701 
00702 QString TrollProjectWidget::getCurrentTarget()
00703 {
00704   if (!m_shownSubproject)
00705     return "";
00706   if (m_shownSubproject->configuration.m_destdir.isEmpty() ||
00707       m_shownSubproject->configuration.m_destdir[ m_shownSubproject->configuration.m_destdir.length()-1 ] == '/' )
00708     return m_shownSubproject->configuration.m_destdir+m_shownSubproject->configuration.m_target;
00709   else
00710     return m_shownSubproject->configuration.m_destdir+'/'+m_shownSubproject->configuration.m_target;
00711 }
00712 
00713 QString TrollProjectWidget::getCurrentDestDir()
00714 {
00715   if (!m_shownSubproject)
00716     return "";
00717   return m_shownSubproject->configuration.m_destdir;
00718 }
00719 
00720 QString TrollProjectWidget::getCurrentOutputFilename()
00721 {
00722   if (!m_shownSubproject)
00723     return "";
00724   if (m_shownSubproject->configuration.m_target.isEmpty())
00725   {
00726     QString exe = m_shownSubproject->pro_file;
00727     return exe.replace(QRegExp("\\.pro$"), "");
00728   }
00729   else
00730     return m_shownSubproject->configuration.m_target;
00731 }
00732 
00733 void TrollProjectWidget::cleanDetailView(SubqmakeprojectItem *item)
00734 {
00735   // If no children in detailview
00736   // it is a subdir template
00737   if (item && details->childCount())
00738   {
00739 //    if (item->configuration.m_template == QTMP_SUBDIRS)
00740 //      return;
00741     // Remove all GroupItems and all of their children from the view
00742 //    QPtrListIterator<SubqmakeprojectItem> it(item->scopes);
00743 //    for (; it.current(); ++it)
00744 //    {
00745 //      cleanDetailView(*it);
00746 //      details->takeItem(*it);
00747 //    }
00748     QPtrListIterator<GroupItem> it1(item->groups);
00749     for (; it1.current(); ++it1) {
00750       // After AddTargetDialog, it can happen that an
00751       // item is not yet in the list view, so better check...
00752       if (it1.current()->parent())
00753         while ((*it1)->firstChild())
00754           (*it1)->takeItem((*it1)->firstChild());
00755       details->takeItem(*it1);
00756     }
00757   }
00758 }
00759 
00760 void TrollProjectWidget::buildProjectDetailTree(SubqmakeprojectItem *item,KListView *listviewControl)
00761 {
00762 //  if (item->configuration.m_template == QTMP_SUBDIRS)
00763 //    return;
00764 
00765   // Insert all GroupItems and all of their children into the view
00766   if (listviewControl)
00767   {
00768 //    QPtrListIterator<SubqmakeprojectItem> it1(item->scopes);
00769 //    for (; it1.current(); ++it1)
00770 //    {
00771 //      listviewControl->insertItem(*it1);
00772 //      buildProjectDetailTree(*it1,NULL);
00773 //    }
00774     QPtrListIterator<GroupItem> it2(item->groups);
00775     for (; it2.current(); ++it2)
00776     {
00777         listviewControl->insertItem(*it2);
00778         if ((*it2)->groupType==GroupItem::InstallRoot)
00779         {
00780           QPtrListIterator<GroupItem> it3((*it2)->installs);
00781           for (; it3.current(); ++it3)
00782           {
00783               (*it2)->insertItem(*it3);
00784               QPtrListIterator<FileItem> it4((*it3)->files);
00785               for (; it4.current(); ++it4)
00786                   (*it3)->insertItem(*it4);
00787               (*it3)->setOpen(true);
00788               (*it3)->sortChildItems(0,true);
00789           }
00790           (*it2)->setOpen(true);
00791           (*it2)->sortChildItems(0,true);
00792         }
00793         else
00794         {
00795           QPtrListIterator<FileItem> it3((*it2)->files);
00796           for (; it3.current(); ++it3)
00797               (*it2)->insertItem(*it3);
00798           (*it2)->setOpen(true);
00799           (*it2)->sortChildItems(0,true);
00800         }
00801     }
00802   }
00803   else
00804   {
00805 //    QPtrListIterator<SubqmakeprojectItem> it1(item->scopes);
00806 //    for (; it1.current(); ++it1)
00807 //    {
00808 //      item->insertItem(*it1);
00809 //      buildProjectDetailTree(*it1,NULL);
00810 //    }
00811     QPtrListIterator<GroupItem> it2(item->groups);
00812     for (; it2.current(); ++it2)
00813     {
00814         item->insertItem(*it2);
00815         QPtrListIterator<FileItem> it3((*it2)->files);
00816         for (; it3.current(); ++it3)
00817             (*it2)->insertItem(*it3);
00818         (*it2)->setOpen(true);
00819         (*it2)->sortChildItems(0,true);
00820     }
00821   }
00822 }
00823 
00824 void TrollProjectWidget::slotDetailsExecuted(QListViewItem *item)
00825 {
00826     if (!item)
00827         return;
00828 
00829     // We assume here that ALL items in both list views
00830     // are qProjectItem's
00831     qProjectItem *pvitem = static_cast<qProjectItem*>(item);
00832     if (pvitem->type() != qProjectItem::File)
00833         return;
00834 
00835     QString dirName = m_shownSubproject->path;
00836     FileItem *fitem = static_cast<FileItem*>(pvitem);
00837 
00838     bool isUiFile = QFileInfo(fitem->name).extension() == "ui";
00839     if( m_part->isTMakeProject() && isUiFile ){
00840     // start designer in your PATH
00841     KShellProcess proc;
00842         proc << "designer" << (dirName + "/" + QString(fitem->name));
00843         proc.start( KProcess::DontCare, KProcess::NoCommunication );
00844 
00845     } else
00846     m_part->partController()->editDocument(KURL(dirName + "/" + QString(fitem->name)));
00847 }
00848 
00849 
00850 void TrollProjectWidget::slotConfigureProject()
00851 {
00852 //  ProjectOptionsDlg *d = new ProjectOptionsDlg(m_part,this);
00853 //  d->exec();
00854 
00855   ProjectConfigurationDlg *dlg = new ProjectConfigurationDlg(m_shownSubproject,overview);
00856   if (dlg->exec() == QDialog::Accepted)
00857   {
00858     updateProjectConfiguration(m_shownSubproject);
00859     setupContext();
00860   }
00861 }
00862 
00863 void TrollProjectWidget::slotExecuteTarget()
00864 {
00865   //m_part->slotExecute();
00866 
00867   // no subproject selected
00868   if (!m_shownSubproject)
00869     return;
00870 
00871   // can't build from scope
00872   if (m_shownSubproject->isScope)
00873     return;
00874 
00875 
00876   // Only run application projects
00877   if (m_shownSubproject->configuration.m_template!=QTMP_APPLICATION)
00878     return;
00879 
00880   QString dircmd = "cd "+KProcess::quote(subprojectDirectory() + "/" + getCurrentDestDir()) + " && ";
00881   QString program = KProcess::quote("./" + getCurrentOutputFilename());
00882 
00883     // Build environment variables to prepend to the executable path
00884     QString runEnvVars = QString::null;
00885     DomUtil::PairList list =
00886         DomUtil::readPairListEntry( *(m_part->projectDom()), "/kdevtrollproject/run/envvars", "envvar", "name", "value" );
00887 
00888     DomUtil::PairList::ConstIterator it;
00889     for (it = list.begin(); it != list.end(); ++it) {
00890         const DomUtil::Pair &pair = (*it);
00891         if ( (!pair.first.isEmpty()) && (!pair.second.isEmpty()) )
00892             runEnvVars += pair.first + "=" + pair.second + " ";
00893     }
00894     program.prepend(runEnvVars);
00895 
00896     program.append(" " + DomUtil::readEntry( *(m_part->projectDom()), "/kdevtrollproject/run/programargs" ) + " ");
00897 //  std::cerr<<dircmd + "./"+program<<std::endl;
00898 //  m_part->execute(dircmd + "./"+program);
00899 //  m_part->appFrontend()->startAppCommand(dircmd +"./"+program,true);
00900 
00901   bool inTerminal = DomUtil::readBoolEntry(*m_part->projectDom(), "/kdevtrollproject/run/terminal");
00902   m_part->appFrontend()->startAppCommand(subprojectDirectory() + "/" + getCurrentDestDir(), program, inTerminal );
00903 
00904 }
00905 
00906 void TrollProjectWidget::slotBuildProject()
00907 {
00908   m_part->partController()->saveAllFiles();
00909   QString dir = projectDirectory();
00910 
00911   if (!m_rootSubproject)
00912     return;
00913 
00914   createMakefileIfMissing(dir, m_rootSubproject);
00915 
00916   m_part->mainWindow()->raiseView(m_part->makeFrontend()->widget());
00917   QString dircmd = "cd "+KProcess::quote(dir) + " && " ;
00918   QString buildcmd = constructMakeCommandLine(m_rootSubproject->configuration.m_makefile);
00919   m_part->queueCmd(dir,dircmd + buildcmd);
00920 }
00921 void TrollProjectWidget::slotBuildTarget()
00922 {
00923   // no subproject selected
00924   m_part->partController()->saveAllFiles();
00925   if (!m_shownSubproject)
00926     return;
00927   // can't build from scope
00928   if (m_shownSubproject->isScope)
00929     return;
00930   QString dir = subprojectDirectory();
00931   createMakefileIfMissing(dir, m_shownSubproject);
00932 
00933   m_part->mainWindow()->raiseView(m_part->makeFrontend()->widget());
00934   QString dircmd = "cd "+KProcess::quote(dir) + " && " ;
00935   QString buildcmd = constructMakeCommandLine(m_shownSubproject->configuration.m_makefile);
00936   m_part->queueCmd(dir,dircmd + buildcmd);
00937 }
00938 
00939 void TrollProjectWidget::slotRebuildProject()
00940 {
00941   m_part->partController()->saveAllFiles();
00942   QString dir = this->  projectDirectory();
00943 
00944   if (!m_rootSubproject)
00945     return;
00946 
00947   createMakefileIfMissing(dir, m_rootSubproject);
00948 
00949   m_part->mainWindow()->raiseView(m_part->makeFrontend()->widget());
00950   QString dircmd = "cd "+KProcess::quote(dir) + " && " ;
00951   QString rebuildcmd = constructMakeCommandLine(m_rootSubproject->configuration.m_makefile) + " clean && " + constructMakeCommandLine(m_rootSubproject->configuration.m_makefile);
00952   m_part->queueCmd(dir,dircmd + rebuildcmd);
00953 }
00954 
00955 void TrollProjectWidget::slotRebuildTarget()
00956 {
00957   // no subproject selected
00958   m_part->partController()->saveAllFiles();
00959   if (!m_shownSubproject)
00960     return;
00961   // can't build from scope
00962   if (m_shownSubproject->isScope)
00963     return;
00964 
00965   QString dir = subprojectDirectory();
00966   createMakefileIfMissing(dir, m_shownSubproject);
00967 
00968   m_part->mainWindow()->raiseView(m_part->makeFrontend()->widget());
00969   QString dircmd = "cd "+KProcess::quote(dir) + " && " ;
00970   QString rebuildcmd = constructMakeCommandLine(m_shownSubproject->configuration.m_makefile) + " clean && " + constructMakeCommandLine(m_shownSubproject->configuration.m_makefile);
00971   m_part->queueCmd(dir,dircmd + rebuildcmd);
00972 }
00973 
00974 void TrollProjectWidget::slotCreateScope(SubqmakeprojectItem *spitem)
00975 {
00976   if (spitem==0 && m_shownSubproject==0)
00977     return;
00978   else
00979     spitem = m_shownSubproject;
00980   bool ok = FALSE;
00981   QString scopename = KInputDialog::getText(
00982                       i18n( "Create Scope" ),
00983                       i18n( "Please enter a name for the new scope:" ),
00984                       QString::null, &ok, this );
00985   if ( ok && !scopename.isEmpty() )
00986   {
00987     QString newScopeString;
00988     if (!spitem->scopeString.isEmpty())
00989       newScopeString = spitem->scopeString + ":" + scopename;
00990     else
00991       newScopeString = scopename;
00992 
00993     spitem->m_RootBuffer->makeScope(newScopeString);
00994     parseScope(spitem,newScopeString,spitem->m_RootBuffer);
00995     updateProjectFile(spitem);
00996   }
00997   else
00998     return;
00999 }
01000 
01001 void TrollProjectWidget::slotAddSubdir(SubqmakeprojectItem *spitem)
01002 {
01003   if (spitem==0 && m_shownSubproject==0)
01004     return;
01005   else
01006     spitem = m_shownSubproject;
01007   QString relpath = spitem->path.mid(projectDirectory().length());
01008 
01009   KURLRequesterDlg dialog(i18n( "Add Subdirectory" ), i18n( "Please enter a name for the subdirectory: " ), this, 0);
01010   dialog.urlRequester()->setMode(KFile::Directory);
01011   dialog.urlRequester()->setURL(QString::null);
01012 
01013   if ( dialog.exec() == QDialog::Accepted && !dialog.urlRequester()->url().isEmpty() )
01014   {
01015     QString subdirname;
01016     if ( !QDir::isRelativePath(dialog.urlRequester()->url()) )
01017     subdirname = getRelativePath( m_shownSubproject->path, dialog.urlRequester()->url() );
01018     else
01019     subdirname = dialog.urlRequester()->url();
01020 
01021     QDir dir(projectDirectory()+relpath);
01022     if (!dir.exists(subdirname))
01023     {
01024      if (!dir.mkdir(subdirname))
01025      {
01026        KMessageBox::error(this,i18n("Failed to create subdirectory. "
01027                                     "Do you have write permission "
01028                                     "in the project folder?" ));
01029        return;
01030      }
01031     }
01032     spitem->subdirs.append(subdirname);
01033     updateProjectFile(spitem);
01034     SubqmakeprojectItem *newitem = new SubqmakeprojectItem(spitem, subdirname,"");
01035     newitem->subdir = subdirname;
01036     newitem->m_RootBuffer = &(newitem->m_FileBuffer);
01037     newitem->path = spitem->path + "/" + subdirname;
01038     newitem->relpath = newitem->path;
01039     newitem->relpath.remove(0,projectDirectory().length());
01040 
01041     parse(newitem);
01042   }
01043   else
01044     return;
01045 }
01046 
01047 void TrollProjectWidget::slotRemoveSubproject(SubqmakeprojectItem *spitem)
01048 {
01049   if (spitem==0 && m_shownSubproject==0)
01050     return;
01051   else
01052   {
01053     if ( ( spitem = dynamic_cast<SubqmakeprojectItem *>(m_shownSubproject->parent()) ) != NULL  )
01054     {
01055     QString subdirname = m_shownSubproject->subdir;
01056     spitem->subdirs.remove(subdirname);
01057     delete m_shownSubproject;
01058     m_shownSubproject = spitem;
01059     updateProjectFile(spitem);
01060     overview->setCurrentItem(m_shownSubproject);
01061     overview->setSelected(m_shownSubproject, true);
01062     }
01063   }
01064 }
01065 
01066 void TrollProjectWidget::slotOverviewContextMenu(KListView *, QListViewItem *item, const QPoint &p)
01067 {
01068     if (!item)
01069         return;
01070 
01071     SubqmakeprojectItem *spitem = static_cast<SubqmakeprojectItem*>(item);
01072 
01073     KPopupMenu popup(this);
01074     popup.insertTitle(i18n("Subproject %1").arg(item->text(0)));
01075 
01076     int idBuild = -2;
01077     int idQmake = -2;
01078     int idProjectConfiguration = -2;
01079     int idAddSubproject = -2;
01080     int idRemoveSubproject = -2;
01081     int idRemoveScope = -2;
01082     int idAddScope = -2;
01083 
01084 
01085     if (!spitem->isScope)
01086     {
01087       idBuild = popup.insertItem(SmallIcon("make_kdevelop"),i18n("Build"));
01088       popup.setWhatsThis(idBuild, i18n("<b>Build</b><p>Runs <b>make</b> from the selected subproject directory.<br>"
01089                               "Environment variables and make arguments can be specified "
01090                               "in the project settings dialog, <b>Make Options</b> tab."));
01091       idQmake = popup.insertItem(SmallIcon("qmakerun"),i18n("Run qmake"));
01092       popup.setWhatsThis(idQmake, i18n("<b>Run qmake</b><p>Runs <b>qmake</b> from the selected subproject directory. This creates or regenerates Makefile."));
01093       popup.insertSeparator();
01094       idAddSubproject = popup.insertItem(SmallIcon("folder_new"),i18n("Add Subproject..."));
01095       popup.setWhatsThis(idAddSubproject, i18n("<b>Add subproject</b><p>Creates a <i>new</i> or adds an <i>existing</i> subproject to a currently selected subproject. "
01096         "This action is allowed only if a type of the subproject is 'subdirectories'. The type of the subproject can be "
01097         "defined in <b>Subproject Settings</b> dialog (open it from the subproject context menu)."));
01098       if (spitem->configuration.m_template != QTMP_SUBDIRS)
01099         popup.setItemEnabled(idAddSubproject, false);
01100       idRemoveSubproject = popup.insertItem(SmallIcon("remove_subdir"),i18n("Remove Subproject..."));
01101       popup.setWhatsThis(idRemoveSubproject, i18n("<b>Remove subproject</b><p>Removes currently selected subproject. Does not delete any file from disk. Deleted subproject can be later added by calling 'Add Subproject' action."));
01102       if (spitem->parent() == NULL)
01103         popup.setItemEnabled(idRemoveSubproject, false);
01104       idAddScope = popup.insertItem(SmallIcon("qmake_scopenew"),i18n("Create Scope..."));
01105       popup.setWhatsThis(idAddScope, i18n("<b>Create scope</b><p>Creates QMake scope in the project file of the currently selected subproject."));
01106       popup.insertSeparator();
01107       idProjectConfiguration = popup.insertItem(SmallIcon("configure"),i18n("Subproject Settings"));
01108       popup.setWhatsThis(idProjectConfiguration, i18n("<b>Subproject settings</b><p>Opens <b>QMake Subproject Configuration</b> dialog. "
01109         "It provides settings for:<br>subproject type and configuration,<br>include and library paths,<br>lists of dependencies and "
01110         "external libraries,<br>build order,<br>intermediate files locations,<br>compiler options."));
01111     }
01112     else
01113     {
01114       idAddScope = popup.insertItem(SmallIcon("qmake_scopenew"),i18n("Create Scope..."));
01115       popup.setWhatsThis(idAddScope, i18n("<b>Create Scope</b><p>Creates QMake scope in the currently selected scope."));
01116       idRemoveScope = popup.insertItem(SmallIcon("editdelete"),i18n("Remove Scope"));
01117       popup.setWhatsThis(idRemoveScope, i18n("<b>Remove Scope</b><p>Removes currently selected scope."));
01118     }
01119 
01120     int r = popup.exec(p);
01121 
01122     QString relpath = spitem->path.mid(projectDirectory().length());
01123     if (r == idAddSubproject)
01124     {
01125       slotAddSubdir(spitem);
01126     }
01127     if (r == idRemoveSubproject)
01128     {
01129       slotRemoveSubproject(spitem);
01130     }
01131     if (r == idAddScope)
01132     {
01133       slotCreateScope(spitem);
01134     }
01135     else if (r == idRemoveScope)
01136     {
01137       slotRemoveScope(spitem);
01138     }
01139     else if (r == idBuild)
01140     {
01141         slotBuildTarget();
01142 //        m_part->startMakeCommand(projectDirectory() + relpath, QString::fromLatin1(""));
01143     }
01144     else if (r == idQmake)
01145     {
01146         m_part->startQMakeCommand(projectDirectory() + relpath);
01147     }
01148     else if (r == idProjectConfiguration)
01149     {
01150       ProjectConfigurationDlg *dlg = new ProjectConfigurationDlg(spitem,overview);
01151       if (dlg->exec() == QDialog::Accepted)
01152         updateProjectConfiguration(spitem);
01153     }
01154 }
01155 
01156 void TrollProjectWidget::updateProjectConfiguration(SubqmakeprojectItem *item)
01157 //=======================================================================
01158 {
01159   updateProjectFile(item); //for update buildorder
01160 
01161   FileBuffer *Buffer = &(item->m_FileBuffer);
01162   QString relpath = item->path.mid(projectDirectory().length());
01163   // Template variable
01164   Buffer->removeValues("TEMPLATE");
01165   if (item->configuration.m_template == QTMP_APPLICATION)
01166     Buffer->setValues("TEMPLATE",QString("app"),FileBuffer::VSM_RESET);
01167   if (item->configuration.m_template == QTMP_LIBRARY) {
01168     Buffer->setValues("TEMPLATE",QString("lib"),FileBuffer::VSM_RESET);
01169     Buffer->removeValues("VERSION");
01170     Buffer->setValues("VERSION",item->configuration.m_libraryversion,FileBuffer::VSM_RESET);
01171   }
01172   if (item->configuration.m_template == QTMP_SUBDIRS)
01173     Buffer->setValues("TEMPLATE",QString("subdirs"),FileBuffer::VSM_RESET);
01174 
01175   Buffer->removeValues("IDL_COMPILER");
01176   Buffer->setValues("IDL_COMPILER",item->configuration.idl_compiler,FileBuffer::VSM_RESET);
01177 
01178   Buffer->removeValues("IDL_OPTIONS");
01179   Buffer->setValues("IDL_OPTIONS",item->configuration.idl_options,FileBuffer::VSM_RESET);
01180 
01181 
01182   //building idl targets
01183   QStringList::Iterator it=item->idls.begin();
01184   for(;it!=item->idls.end();++it){
01185     QString target=(*it)+".target";
01186     QString command=(*it)+".commands";
01187     QString commandStr="$$IDL_COMPILER $$IDL_OPTIONS $$"+target;
01188 
01189     Buffer->removeValues(target);
01190     Buffer->setValues(target,*it,FileBuffer::VSM_RESET);
01191 
01192     Buffer->removeValues(command);
01193     Buffer->setValues(command,commandStr,FileBuffer::VSM_RESET);
01194 
01195   }
01196 
01197 
01198 
01199 
01200 
01201   // Config variable
01202   Buffer->removeValues("CONFIG");
01203   QStringList configList;
01204   if (item->configuration.m_buildMode == QBM_RELEASE)
01205     configList.append("release");
01206   else if (item->configuration.m_buildMode == QBM_DEBUG)
01207     configList.append("debug");
01208   if (item->configuration.m_warnings == QWARN_ON)
01209     configList.append("warn_on");
01210   else if (item->configuration.m_warnings == QWARN_OFF)
01211     configList.append("warn_off");
01212   if (item->configuration.m_requirements & QD_QT)
01213     configList.append("qt");
01214   if (item->configuration.m_requirements & QD_OPENGL)
01215     configList.append("opengl");
01216   if (item->configuration.m_requirements & QD_THREAD)
01217     configList.append("thread");
01218   if (item->configuration.m_requirements & QD_X11)
01219     configList.append("x11");
01220   if (item->configuration.m_requirements & QD_STATIC)
01221     configList.append("staticlib");
01222   if (item->configuration.m_requirements & QD_SHARED)
01223     configList.append("dll");
01224   if (item->configuration.m_requirements & QD_PLUGIN)
01225     configList.append("plugin");
01226   if (item->configuration.m_requirements & QD_EXCEPTIONS)
01227     configList.append("exceptions");
01228   if (item->configuration.m_requirements & QD_STL)
01229     configList.append("stl");
01230   if (item->configuration.m_requirements & QD_RTTI)
01231     configList.append("rtti");
01232   if (item->configuration.m_requirements & QD_ORDERED)
01233     configList.append("ordered");
01234   if (item->configuration.m_inheritconfig == true)
01235     Buffer->setValues("CONFIG",configList,FileBuffer::VSM_APPEND,VALUES_PER_ROW);
01236   else
01237     Buffer->setValues("CONFIG",configList,FileBuffer::VSM_RESET,VALUES_PER_ROW);
01238 
01239   // Config strings
01240   Buffer->removeValues("DESTDIR");
01241   if (!item->configuration.m_destdir.simplifyWhiteSpace().isEmpty())
01242     Buffer->setValues("DESTDIR",QString(item->configuration.m_destdir),FileBuffer::VSM_RESET,VALUES_PER_ROW);
01243   Buffer->removeValues("TARGET");
01244   if (!item->configuration.m_target.simplifyWhiteSpace().isEmpty())
01245     Buffer->setValues("TARGET",QString(item->configuration.m_target),FileBuffer::VSM_RESET,VALUES_PER_ROW);
01246   Buffer->removeValues("INCLUDEPATH");
01247   if (item->configuration.m_includepath.count())
01248       Buffer->setValues("INCLUDEPATH",item->configuration.m_includepath,FileBuffer::VSM_RESET,VALUES_PER_ROW);
01249   Buffer->removeValues("DEFINES");
01250   if (item->configuration.m_defines.count())
01251     Buffer->setValues("DEFINES",item->configuration.m_defines,FileBuffer::VSM_RESET,VALUES_PER_ROW);
01252   Buffer->removeValues("QMAKE_CXXFLAGS_DEBUG");
01253   if (item->configuration.m_cxxflags_debug.count())
01254     Buffer->setValues("QMAKE_CXXFLAGS_DEBUG",item->configuration.m_cxxflags_debug,FileBuffer::VSM_APPEND,VALUES_PER_ROW);
01255   Buffer->removeValues("QMAKE_CXXFLAGS_RELEASE");
01256   if (item->configuration.m_cxxflags_release.count())
01257     Buffer->setValues("QMAKE_CXXFLAGS_RELEASE",item->configuration.m_cxxflags_release,FileBuffer::VSM_APPEND,VALUES_PER_ROW);
01258   Buffer->removeValues("QMAKE_LFLAGS_DEBUG");
01259   if (item->configuration.m_lflags_debug.count())
01260     Buffer->setValues("QMAKE_LFLAGS_DEBUG",item->configuration.m_lflags_debug,FileBuffer::VSM_RESET,VALUES_PER_ROW);
01261   Buffer->removeValues("QMAKE_LFLAGS_RELEASE");
01262   if (item->configuration.m_lflags_release.count())
01263     Buffer->setValues("QMAKE_LFLAGS_RELEASE",item->configuration.m_lflags_release,FileBuffer::VSM_RESET,VALUES_PER_ROW);
01264   Buffer->removeValues("QMAKE_LIBDIR");
01265   if (item->configuration.m_librarypath.count())
01266     Buffer->setValues("QMAKE_LIBDIR",item->configuration.m_librarypath,FileBuffer::VSM_RESET,VALUES_PER_ROW);
01267   Buffer->removeValues("OBJECTS_DIR");
01268   if (!item->configuration.m_objectpath.simplifyWhiteSpace().isEmpty())
01269     Buffer->setValues("OBJECTS_DIR",QString(item->configuration.m_objectpath),FileBuffer::VSM_RESET,VALUES_PER_ROW);
01270   Buffer->removeValues("UI_DIR");
01271   if (!item->configuration.m_uipath.simplifyWhiteSpace().isEmpty())
01272     Buffer->setValues("UI_DIR",QString(item->configuration.m_uipath),FileBuffer::VSM_RESET,VALUES_PER_ROW);
01273   Buffer->removeValues("MOC_DIR");
01274   if (!item->configuration.m_mocpath.simplifyWhiteSpace().isEmpty())
01275     Buffer->setValues("MOC_DIR",QString(item->configuration.m_mocpath),FileBuffer::VSM_RESET,VALUES_PER_ROW);
01276   Buffer->removeValues("MAKEFILE");
01277   if (!item->configuration.m_makefile.simplifyWhiteSpace().isEmpty())
01278     Buffer->setValues("MAKEFILE", item->configuration.m_makefile,FileBuffer::VSM_RESET,VALUES_PER_ROW);
01279 
01280 
01281 
01282   Buffer->removeValues("INCLUDEPATH");
01283   if (item->configuration.m_incadd.count()>0)
01284     Buffer->setValues("INCLUDEPATH",item->configuration.m_incadd,FileBuffer::VSM_RESET,VALUES_PER_ROW);
01285 
01286   Buffer->removeValues("LIBS");
01287   if (item->configuration.m_libadd.count()>0)
01288     Buffer->setValues("LIBS",item->configuration.m_libadd,FileBuffer::VSM_APPEND,VALUES_PER_ROW);
01289 
01290   Buffer->removeValues("TARGETDEPS");
01291 //  if (item->configuration.m_libadd.count()>0)
01292   Buffer->setValues("TARGETDEPS",item->configuration.m_prjdeps,FileBuffer::VSM_APPEND,VALUES_PER_ROW);
01293 
01294   updateInstallObjects(item,Buffer);
01295 
01296 
01297   // Write to .pro file
01298 //  Buffer->saveBuffer(projectDirectory()+relpath+"/"+m_shownSubproject->subdir+".pro",getHeader());
01299   Buffer->saveBuffer(projectDirectory()+relpath+"/"+m_shownSubproject->pro_file,getHeader());
01300 }
01301 
01302 SubqmakeprojectItem* TrollProjectWidget::getScope(SubqmakeprojectItem *baseItem,const QString &scopeString)
01303 //===============================================================================================
01304 {
01305   QStringList baseScopeParts = QStringList::split(':',baseItem->scopeString);
01306   QStringList subScopeParts = QStringList::split(':',scopeString);
01307   kdDebug(9024) << "baseitem" << baseItem->scopeString << endl;
01308   // Stop if baseItem not an ansister
01309   if (baseScopeParts.count() > subScopeParts.count())
01310     return NULL;
01311   uint i;
01312   for (i=0; i<baseScopeParts.count(); i++)
01313   {
01314     // Stop if baseItem in wrong treepart
01315     kdDebug(9024) << "baseScopeParts[i]" << "!=" << subScopeParts[i] << endl;
01316     if (baseScopeParts[i] != subScopeParts[i])
01317       return NULL;
01318   }
01319   // if all scopeparts matched and the amount of parts are equal this must be it
01320   if (baseScopeParts.count() == subScopeParts.count())
01321     return baseItem;
01322   // process next step of recursive function
01323   QString nextScopePart = subScopeParts[i];
01324   QPtrListIterator<SubqmakeprojectItem> spit(baseItem->scopes);
01325   for (; spit.current(); ++spit)
01326   {
01327     SubqmakeprojectItem *spitem = spit;
01328     kdDebug(9024) << spitem->text(0) << "==" << nextScopePart << endl;
01329     if (spitem->text(0)==nextScopePart)
01330     {
01331       return getScope(spit,scopeString);
01332       break;
01333     }
01334   }
01335   return NULL;
01336 }
01337 
01338 void TrollProjectWidget::updateProjectFile(QListViewItem *item)
01339 {
01340   SubqmakeprojectItem *spitem = static_cast<SubqmakeprojectItem*>(item);
01341   QString relpath = m_shownSubproject->path.mid(projectDirectory().length());
01342   FileBuffer *subBuffer=m_shownSubproject->m_RootBuffer->getSubBuffer(spitem->scopeString);
01343   subBuffer->removeValues("SUBDIRS");
01344   subBuffer->setValues("SUBDIRS",spitem->subdirs,FileBuffer::VSM_APPEND,VALUES_PER_ROW);
01345   subBuffer->removeValues("SOURCES");
01346   subBuffer->setValues("SOURCES",spitem->sources,FileBuffer::VSM_APPEND,VALUES_PER_ROW);
01347   subBuffer->setValues("SOURCES",spitem->sources_exclude,FileBuffer::VSM_EXCLUDE,VALUES_PER_ROW);
01348   subBuffer->removeValues("HEADERS");
01349   subBuffer->setValues("HEADERS",spitem->headers,FileBuffer::VSM_APPEND,VALUES_PER_ROW);
01350   subBuffer->setValues("HEADERS",spitem->headers_exclude,FileBuffer::VSM_EXCLUDE,VALUES_PER_ROW);
01351 //  subBuffer->removeValues("FORMS");
01352 //  subBuffer->setValues("FORMS",spitem->forms,FileBuffer::VSM_APPEND,VALUES_PER_ROW);
01353 //  subBuffer->setValues("FORMS",spitem->forms_exclude,FileBuffer::VSM_EXCLUDE,VALUES_PER_ROW);
01354 
01355   subBuffer->removeValues("IDLS");
01356   subBuffer->setValues("IDLS",spitem->idls,FileBuffer::VSM_APPEND,VALUES_PER_ROW);
01357   subBuffer->setValues("IDLS",spitem->idls_exclude,FileBuffer::VSM_EXCLUDE,VALUES_PER_ROW);
01358 
01359   subBuffer->removeValues("IMAGES");
01360   subBuffer->setValues("IMAGES",spitem->images,FileBuffer::VSM_APPEND,VALUES_PER_ROW);
01361   subBuffer->setValues("IMAGES",spitem->images_exclude,FileBuffer::VSM_EXCLUDE,VALUES_PER_ROW);
01362 
01363   subBuffer->removeValues("DISTFILES");
01364   subBuffer->setValues("DISTFILES",spitem->distfiles,FileBuffer::VSM_APPEND,VALUES_PER_ROW);
01365   subBuffer->setValues("DISTFILES",spitem->distfiles_exclude,FileBuffer::VSM_EXCLUDE,VALUES_PER_ROW);
01366 
01367   subBuffer->removeValues("LEXSOURCES");
01368   subBuffer->setValues("LEXSOURCES",spitem->lexsources,FileBuffer::VSM_APPEND,VALUES_PER_ROW);
01369   subBuffer->setValues("LEXSOURCES",spitem->lexsources_exclude,FileBuffer::VSM_EXCLUDE,VALUES_PER_ROW);
01370 
01371   subBuffer->removeValues("YACCSOURCES");
01372   subBuffer->setValues("YACCSOURCES",spitem->yaccsources,FileBuffer::VSM_APPEND,VALUES_PER_ROW);
01373   subBuffer->setValues("YACCSOURCES",spitem->yaccsources_exclude,FileBuffer::VSM_EXCLUDE,VALUES_PER_ROW);
01374 
01375 
01376   subBuffer->removeValues("TRANSLATIONS");
01377   subBuffer->setValues("TRANSLATIONS",spitem->translations,FileBuffer::VSM_APPEND,VALUES_PER_ROW);
01378   subBuffer->setValues("TRANSLATIONS",spitem->translations_exclude,FileBuffer::VSM_EXCLUDE,VALUES_PER_ROW);
01379 
01380 
01381   if( m_part->isTMakeProject() ) {
01382       subBuffer->removeValues("INTERFACES");
01383       subBuffer->setValues("INTERFACES",spitem->forms,FileBuffer::VSM_APPEND,VALUES_PER_ROW);
01384       subBuffer->setValues("INTERFACES",spitem->forms_exclude,FileBuffer::VSM_EXCLUDE,VALUES_PER_ROW);
01385   } else {
01386       subBuffer->removeValues("FORMS");
01387       subBuffer->setValues("FORMS",spitem->forms,FileBuffer::VSM_APPEND,VALUES_PER_ROW);
01388       subBuffer->setValues("FORMS",spitem->forms_exclude,FileBuffer::VSM_EXCLUDE,VALUES_PER_ROW);
01389   }
01390 
01391   updateInstallObjects(spitem,subBuffer);
01392 //  m_shownSubproject->m_RootBuffer->saveBuffer(projectDirectory()+relpath+"/"+m_shownSubproject->subdir+".pro",getHeader());
01393   m_shownSubproject->m_RootBuffer->saveBuffer(projectDirectory()+relpath+"/"+m_shownSubproject->pro_file,getHeader());
01394 }
01395 
01396 void TrollProjectWidget::updateInstallObjects(SubqmakeprojectItem* item, FileBuffer* subBuffer)
01397 {
01398   // Install objects
01399   GroupItem* instroot = getInstallRoot(item);
01400   QPtrListIterator<GroupItem> it(instroot->installs);
01401   QStringList instobjects;
01402 
01403   for (;it.current();++it)
01404   {
01405     GroupItem* iobj = *it;
01406     subBuffer->removeValues(iobj->install_objectname+".path");
01407     subBuffer->removeValues(iobj->install_objectname+".files");
01408 
01409     if (!iobj->str_files.isEmpty() ||
01410         !iobj->str_files_exclude.isEmpty())
01411     {
01412       instobjects.append(iobj->install_objectname);
01413       subBuffer->setValues(iobj->install_objectname+".path",iobj->install_path,FileBuffer::VSM_RESET,VALUES_PER_ROW);
01414       subBuffer->setValues(iobj->install_objectname+".files",iobj->str_files,FileBuffer::VSM_APPEND,VALUES_PER_ROW);
01415       subBuffer->setValues(iobj->install_objectname+".files",iobj->str_files_exclude,FileBuffer::VSM_EXCLUDE,VALUES_PER_ROW);
01416     }
01417   }
01418 
01419   if (!item->configuration.m_target_install_path.isEmpty() &&
01420       item->configuration.m_target_install)
01421   {
01422     instobjects.append("target");
01423     subBuffer->removeValues("target.path");
01424     subBuffer->setValues("target.path",item->configuration.m_target_install_path,FileBuffer::VSM_RESET,VALUES_PER_ROW);
01425     subBuffer->setValues("INSTALLS",QString("target"),FileBuffer::VSM_APPEND,VALUES_PER_ROW);
01426   }
01427 
01428   subBuffer->removeValues("INSTALLS");
01429   subBuffer->setValues("INSTALLS",instobjects,FileBuffer::VSM_APPEND,VALUES_PER_ROW);
01430 
01431 
01432 }
01433 
01434 QString TrollProjectWidget::getHeader()
01435 {
01436   QString header,templateString,targetString;
01437   QString relpath = "."+m_shownSubproject->path.mid(projectDirectory().length());
01438   if (m_shownSubproject->configuration.m_template==QTMP_APPLICATION)
01439   {
01440     templateString = i18n("an application: ");
01441     targetString = m_shownSubproject->configuration.m_target;
01442   }
01443   if (m_shownSubproject->configuration.m_template==QTMP_LIBRARY)
01444   {
01445     templateString = i18n("a library: ");
01446     targetString = m_shownSubproject->configuration.m_target;
01447   }
01448   if (m_shownSubproject->configuration.m_template==QTMP_SUBDIRS)
01449     templateString = i18n("a subdirs project");
01450   header.sprintf(m_part->getQMakeHeader().latin1(),
01451                  relpath.ascii(),
01452                  templateString.ascii(),
01453                  targetString.ascii());
01454   return header;
01455 }
01456 
01457 
01458 void TrollProjectWidget::addFileToCurrentSubProject(GroupItem *titem,const QString &filename)
01459 {
01460   QPtrListIterator<FileItem> it( titem->files );
01461   while ( it.current() != 0 )
01462   {
01463      if(it.current()->name == filename) //File already exists in this subproject
01464        return;
01465      ++it;
01466   }
01467 
01468   FileItem *fitem = createFileItem(filename);
01469 
01470   fitem->uiFileLink = getUiFileLink(titem->owner->relpath+"/",filename);
01471   if (titem->groupType != GroupItem::InstallObject)
01472     titem->files.append(fitem);
01473   switch (titem->groupType)
01474   {
01475     case GroupItem::Sources:
01476       titem->owner->sources.append(filename);
01477       break;
01478     case GroupItem::Headers:
01479       titem->owner->headers.append(filename);
01480       break;
01481     case GroupItem::Forms:
01482       titem->owner->forms.append(filename);
01483     case GroupItem::IDLs:
01484       titem->owner->idls.append(filename);
01485       break;
01486     case GroupItem::Lexsources:
01487       titem->owner->lexsources.append(filename);
01488       break;
01489     case GroupItem::Yaccsources:
01490       titem->owner->yaccsources.append(filename);
01491       break;
01492     case GroupItem::Images:
01493       titem->owner->images.append(filename);
01494       break;
01495     case GroupItem::Distfiles:
01496       titem->owner->distfiles.append(filename);
01497       break;
01498     case GroupItem::Translations:
01499       titem->owner->translations.append(filename);
01500       break;
01501     case GroupItem::InstallObject:
01502       titem->str_files.append(filename);
01503       titem->files.append(fitem);
01504       break;
01505     default:
01506       break;
01507   }
01508 }
01509 
01510 void TrollProjectWidget::addFileToCurrentSubProject(GroupItem::GroupType gtype,const QString &filename)
01511 {
01512   if (!m_shownSubproject)
01513     return;
01514   FileItem *fitem = createFileItem(filename);
01515   GroupItem *gitem = 0;
01516 
01517   QPtrListIterator<GroupItem> it(m_shownSubproject->groups);
01518   for (; it.current(); ++it)
01519   {
01520     if ((*it)->groupType == gtype)
01521     {
01522       gitem = *it;
01523        QPtrListIterator<FileItem> it( gitem->files );
01524        while ( it.current() != 0 )
01525        {
01526         if(it.current()->name == filename) //File already exists in this subproject
01527           return;
01528         ++it;
01529        }
01530       break;
01531     }
01532   }
01533   if (!gitem)
01534     return;
01535   fitem->uiFileLink = getUiFileLink(gitem->owner->relpath+"/",filename);
01536   gitem->files.append(fitem);
01537   switch (gtype)
01538   {
01539     case GroupItem::Sources:
01540       m_shownSubproject->sources.append(filename);
01541       break;
01542     case GroupItem::Headers:
01543       m_shownSubproject->headers.append(filename);
01544       break;
01545     case GroupItem::Forms:
01546       m_shownSubproject->forms.append(filename);
01547       break;
01548     case GroupItem::IDLs:
01549       m_shownSubproject->idls.append(filename);
01550       break;
01551     case GroupItem::Lexsources:
01552       m_shownSubproject->lexsources.append(filename);
01553       break;
01554     case GroupItem::Yaccsources:
01555       m_shownSubproject->yaccsources.append(filename);
01556       break;
01557     case GroupItem::Translations:
01558       m_shownSubproject->translations.append(filename);
01559       break;
01560     case GroupItem::Images:
01561       m_shownSubproject->images.append(filename);
01562     case GroupItem::Distfiles:
01563       m_shownSubproject->distfiles.append(filename);
01564       break;
01565     /*
01566     case GroupItem::InstallObject:
01567       GroupItem *gitem = 0;
01568 
01569       QPtrListIterator<GroupItem> it(m_shownSubproject->groups);
01570       for (; it.current(); ++it)
01571       {
01572         if ((*it)->groupType == GroupItem::InstallRoot)
01573         {
01574           gitem = *it;
01575           break;
01576         }
01577       }
01578       QPtrListIterator<GroupItem> it2(gitem->installs);
01579       for (; it2.current(); ++it2)
01580       {
01581         if ((*it2)->install_objectname == )
01582         {
01583           if ();
01584         }
01585       }
01586 
01587       m_shownSubproject->files.append(fitem);
01588       break;
01589     */
01590     default:
01591       break;
01592   }
01593 }
01594 
01599 void TrollProjectWidget::addFiles( QStringList &files, bool noPathTruncate)
01600 {
01601   if (!m_shownSubproject)
01602     return;
01603 
01604   QString newPath;
01605 
01606   for ( QStringList::Iterator it = files.begin(); it != files.end(); ++it )
01607   {
01608     QString fileName = *it;
01609 
01610     QString origFileName = noPathTruncate ? fileName : QFileInfo(fileName).fileName();
01611     QString origFilePath = noPathTruncate ? QDir::cleanDirPath(m_shownSubproject->path + "/" + fileName) : fileName;
01612     if (m_shownSubproject->configuration.m_template == QTMP_SUBDIRS)
01613     {
01614         ChooseSubprojectDlg dlg(this);
01615         if (dlg.exec() == QDialog::Accepted)
01616         {
01617             if (dlg.selectedSubproject())
01618             {
01619                 overview->setCurrentItem(dlg.selectedSubproject());
01620                 newPath = dlg.selectedSubproject()->path;
01621             }
01622         }
01623         else
01624             return;
01625     }
01626 
01627     if (!newPath.isEmpty())
01628     {
01629         //move file to it's new location
01630         KURL source;
01631         KURL dest;
01632         kdDebug() << "  orig: " << origFilePath << "  dest: " << QDir::cleanDirPath(newPath + "/" + origFileName) << endl;
01633         source.setPath(origFilePath);
01634         dest.setPath(QDir::cleanDirPath(newPath + "/" + origFileName));
01635         if (KIO::NetAccess::copy(source, dest, (QWidget*)0))
01636             KIO::NetAccess::del(source, (QWidget*)0);
01637         *it = QDir::cleanDirPath(newPath + "/" + origFileName);
01638         fileName = *it;
01639     }
01640 
01641     QFileInfo info(fileName);
01642     QString ext = info.extension(false).simplifyWhiteSpace();
01643     QString noPathFileName;
01644     if (noPathTruncate)
01645         noPathFileName = fileName;
01646     else
01647         noPathFileName = info.fileName();
01648 
01649     GroupItem *gitem = 0;
01650     QPtrListIterator<GroupItem> it(m_shownSubproject->groups);
01651     for (; it.current(); ++it)
01652     {
01653         if ((*it)->groupType == GroupItem::groupTypeForExtension(ext))
01654         {
01655             gitem = *it;
01656             break;
01657         }
01658     }
01659     if (gitem && !noPathTruncate)
01660     {
01661         QString addName;
01662         if (fileName.startsWith("/"))
01663             addName = URLUtil::relativePath(gitem->owner->path, fileName);
01664         else
01665             addName = URLUtil::relativePath(gitem->owner->relpath, "/" + fileName);
01666         if (!addName.isEmpty())
01667         {
01668             if (addName[0] == '/')
01669                 addName = addName.mid(1);
01670             noPathFileName = addName;
01671         }
01672     }
01673 
01674     addFileToCurrentSubProject(GroupItem::groupTypeForExtension(ext), noPathFileName);
01675     updateProjectFile(m_shownSubproject);
01676     slotOverviewSelectionChanged(m_shownSubproject);
01677     emitAddedFile ( fileName.mid(m_part->projectDirectory().length()+1) );
01678   }
01679 
01680 
01681 /*  QStringList splitFile = QStringList::split('.',fileName);
01682   QString ext = splitFile[splitFile.count()-1];
01683   splitFile = QStringList::split('/',fileName);
01684   QString fileWithNoSlash = splitFile[splitFile.count()-1];
01685   ext = ext.simplifyWhiteSpace();
01686   if (QString("cpp cc c").find(ext)>-1)
01687     addFileToCurrentSubProject(GroupItem::Sources,fileWithNoSlash);
01688   else if (QString("hpp h").find(ext)>-1)
01689     addFileToCurrentSubProject(GroupItem::Headers,fileWithNoSlash);
01690   else if (QString("ui").find(ext)>-1)
01691     addFileToCurrentSubProject(GroupItem::Forms,fileWithNoSlash);
01692   else if (QString("idl").find(ext)>-1)
01693     addFileToCurrentSubProject(GroupItem::IDLs,fileWithNoSlash);
01694   else if (QString("jpg png xpm").find(ext)>-1)
01695     addFileToCurrentSubProject(GroupItem::Images,fileWithNoSlash);
01696   else if (QString("ts").find(ext)>-1)
01697     addFileToCurrentSubProject(GroupItem::Translations,fileWithNoSlash);
01698   else
01699     addFileToCurrentSubProject(GroupItem::NoType,fileWithNoSlash);*/
01700 
01701 }
01702 
01703 
01704 void TrollProjectWidget::slotAddFiles()
01705 {
01706   QString cleanSubprojectDir = QDir::cleanDirPath(m_shownSubproject->path);
01707   QString  filter = "*.cpp *.cc *.c *.hpp *.h *.ui|" + i18n("Source Files");
01708   filter += "\n*|" + i18n("All Files");
01709 #if KDE_VERSION >= 310
01710   AddFilesDialog *dialog = new AddFilesDialog(cleanSubprojectDir,
01711                                         filter,
01712                                         this,
01713                                         "Insert existing files",
01714                                         true, new QComboBox(false));
01715 #else
01716   AddFilesDialog *dialog = new AddFilesDialog(cleanSubprojectDir,
01717                                         filter,
01718                                         this,
01719                                         i18n("Insert Existing Files").ascii(),
01720                                         true);
01721 #endif
01722   dialog->setMode(KFile::Files | KFile::ExistingOnly | KFile::LocalOnly);
01723   dialog->exec();
01724   QStringList files = dialog->selectedFiles();
01725   for (unsigned int i=0;i<files.count();i++)
01726   {
01727     switch (dialog->mode())
01728     {
01729       case AddFilesDialog::Copy:
01730         {
01731         // Copy selected files to current subproject folder
01732         QProcess *proc = new QProcess( this );
01733         proc->addArgument( "cp" );
01734         proc->addArgument( "-f" );
01735         proc->addArgument( files[i] );
01736         proc->addArgument( cleanSubprojectDir );
01737         proc->start();
01738         QString filename = files[i].right(files[i].length()-files[i].findRev('/')-1);
01739         // and add them to the filelist
01740         QFile testExist(cleanSubprojectDir+"/"+filename);
01741         if (testExist.exists())
01742         {
01743           QStringList files(filename);
01744           addFiles(files);
01745         }
01746         }
01747         break;
01748 
01749       case AddFilesDialog::Link:
01750         {
01751         // Link selected files to current subproject folder
01752         QProcess *proc = new QProcess( this );
01753         proc->addArgument( "ln" );
01754         proc->addArgument( "-s" );
01755         proc->addArgument( files[i] );
01756         proc->addArgument( cleanSubprojectDir );
01757         proc->start();
01758         QString filename = files[i].right(files[i].length()-files[i].findRev('/')-1);
01759         // and add them to the filelist
01760         QFile testExist(cleanSubprojectDir+"/"+filename);
01761         if (testExist.exists())
01762         {
01763           QStringList files(filename);
01764           addFiles(files);
01765         }
01766         }
01767         break;
01768 
01769       case AddFilesDialog::Relative:
01770         // Form relative path to current subproject folder
01771         QStringList files(URLUtil::relativePathToFile(cleanSubprojectDir , files[i]));
01772         addFiles(files, true);
01773         break;
01774     }
01775   }
01776 }
01777 
01778 GroupItem* TrollProjectWidget::getInstallRoot(SubqmakeprojectItem* item)
01779 {
01780   QPtrListIterator<GroupItem> it(item->groups);
01781   for (;it.current();++it)
01782   {
01783     if ((*it)->groupType == GroupItem::InstallRoot)
01784       return *it;
01785   }
01786   return 0;
01787 }
01788 
01789 GroupItem* TrollProjectWidget::getInstallObject(SubqmakeprojectItem* item, const QString& objectname)
01790 {
01791   GroupItem* instroot = getInstallRoot(item);
01792   if (!instroot)
01793     return 0;
01794   QPtrListIterator<GroupItem> it(instroot->installs);
01795   for (;it.current();++it)
01796   {
01797     if ((*it)->groupType == GroupItem::InstallObject &&
01798         (*it)->install_objectname == objectname )
01799       return *it;
01800   }
01801   return 0;
01802 
01803 }
01804 
01805 void TrollProjectWidget::slotNewFile()
01806 {
01807     GroupItem *gitem = static_cast<GroupItem*>(details->currentItem());
01808     if (gitem)
01809     {
01810       if (gitem->groupType == GroupItem::InstallObject)
01811       {
01812           // QString relpath = m_shownSubproject->path.mid(projectDirectory().length());
01813           bool ok = FALSE;
01814           QString filepattern = KInputDialog::getText(
01815                               i18n( "Insert New Filepattern" ),
01816                               i18n( "Please enter a filepattern relative the current "
01817                                     "subproject (example docs/*.html):" ),
01818                               QString::null, &ok, this );
01819           if ( ok && !filepattern.isEmpty() )
01820           {
01821             addFileToCurrentSubProject(gitem,filepattern);
01822             updateProjectFile(gitem->owner);
01823             slotOverviewSelectionChanged(m_shownSubproject);
01824           }
01825           return;
01826       }
01827       if (gitem->groupType == GroupItem::InstallRoot)
01828       {
01829 //          QString relpath = m_shownSubproject->path.mid(projectDirectory().length());
01830           bool ok = FALSE;
01831           QString install_obj = KInputDialog::getText(
01832                               i18n( "Insert New Install Object" ),
01833                               i18n( "Please enter a name for the new object:" ),
01834                               QString::null, &ok, this );
01835           if ( ok && !install_obj.isEmpty() )
01836           {
01837             GroupItem* institem = createGroupItem(GroupItem::InstallObject, install_obj ,gitem->scopeString);
01838             institem->owner = m_shownSubproject;
01839             institem->install_objectname = install_obj;
01840             gitem->installs.append(institem);
01841             slotOverviewSelectionChanged(m_shownSubproject);
01842           }
01843           return;
01844       }
01845 
01846     }
01847     KDevCreateFile * createFileSupport = m_part->createFileSupport();
01848     if (createFileSupport)
01849     {
01850         KDevCreateFile::CreatedFile crFile =
01851             createFileSupport->createNewFile(QString::null, projectDirectory()+m_shownSubproject->path.mid(projectDirectory().length()));
01852     } else {
01853         bool ok = FALSE;
01854         QString relpath = m_shownSubproject->path.mid(projectDirectory().length());
01855         QString filename = KInputDialog::getText(
01856                             i18n( "Insert New File"),
01857                             i18n( "Please enter a name for the new file:" ),
01858                             QString::null, &ok, this );
01859         if ( ok && !filename.isEmpty() )
01860         {
01861             QFile newfile(projectDirectory()+relpath+'/'+filename);
01862             if (!newfile.open(IO_WriteOnly))
01863             {
01864             KMessageBox::error(this,i18n("Failed to create new file. "
01865                                         "Do you have write permission "
01866                                         "in the project folder?" ));
01867             return;
01868             }
01869             newfile.close();
01870             QStringList files(relpath+'/'+filename);
01871             addFiles(files);
01872         }
01873     }
01874 }
01875 
01876 void TrollProjectWidget::slotRemoveFile()
01877 {
01878   QListViewItem *selectedItem = details->currentItem();
01879   if (!selectedItem)
01880     return;
01881   qProjectItem *pvitem = static_cast<qProjectItem*>(selectedItem);
01882   // Check that it is a file (just in case)
01883   if (pvitem->type() != qProjectItem::File)
01884     return;
01885   FileItem *fitem = static_cast<FileItem*>(pvitem);
01886   removeFile(m_shownSubproject, fitem);
01887 }
01888 
01889 void TrollProjectWidget::slotConfigureFile()
01890 {
01891   QListViewItem *selectedItem = details->currentItem();
01892   if (!selectedItem)
01893     return;
01894   qProjectItem *pvitem = static_cast<qProjectItem*>(selectedItem);
01895   // Check that it is a file (just in case)
01896   if (pvitem->type() != qProjectItem::File)
01897     return;
01898   FileItem *fitem = static_cast<FileItem*>(pvitem);
01899 
01900   GroupItem *gitem = static_cast<GroupItem*>(fitem->parent());
01901   if (!gitem)
01902     return;
01903   QStringList dirtyScopes;
01904   FilePropertyDlg *propdlg = new FilePropertyDlg(m_shownSubproject,gitem->groupType,fitem,dirtyScopes);
01905   SubqmakeprojectItem *scope;
01906   propdlg->exec();
01907 
01908   for (uint i=0; i<dirtyScopes.count();i++)
01909   {
01910     scope = getScope(m_shownSubproject,dirtyScopes[i]);
01911     if (gitem->groupType == GroupItem::InstallObject)
01912     {
01913       GroupItem* instroot = getInstallRoot(scope);
01914       GroupItem* instobj = getInstallObject(scope,gitem->install_objectname);
01915       if (!instobj)
01916       {
01917         GroupItem* institem = createGroupItem(GroupItem::InstallObject, gitem->install_objectname ,scope->scopeString);
01918         institem->owner = scope;
01919         institem->install_objectname = gitem->install_objectname;
01920         instroot->installs.append(institem);
01921         instobj = institem;
01922       }
01923       // Using the boolean nature of this operation I can append or remove the file from the excludelist
01924       if (instobj->str_files_exclude.join(":").find(fitem->name) >= 0)
01925       {
01926         instobj->str_files_exclude.remove(fitem->name);
01927       }
01928       else
01929       {
01930         instobj->str_files_exclude.append(fitem->name);
01931       }
01932     }
01933     if (scope)
01934       updateProjectFile(scope);
01935   }
01936 }
01937 
01938 void TrollProjectWidget::slotDetailsSelectionChanged(QListViewItem *item)
01939 {
01940     if (!item)
01941     {
01942 //        addfilesButton->setEnabled(false);
01943 //        newfileButton->setEnabled(false);
01944         removefileButton->setEnabled(false);
01945         configurefileButton->setEnabled(false);
01946         return;
01947     }
01948 //    addfilesButton->setEnabled(false);
01949 //    newfileButton->setEnabled(false);
01950     removefileButton->setEnabled(false);
01951     configurefileButton->setEnabled(false);
01952 /*    buildTargetButton->setEnabled(false);
01953     rebuildTargetButton->setEnabled(false);
01954     executeTargetButton->setEnabled(false);*/
01955 
01956     qProjectItem *pvitem = static_cast<qProjectItem*>(item);
01957     if (pvitem->type() == qProjectItem::Group)
01958     {
01959       GroupItem* gitem = static_cast<GroupItem*>(item);
01960       if (gitem->groupType == GroupItem::InstallObject)
01961       {
01962         configurefileButton->setEnabled(true);
01963         newfileButton->setEnabled(true);
01964       }
01965       else if (gitem->groupType == GroupItem::InstallRoot)
01966       {
01967         newfileButton->setEnabled(true);
01968       }
01969       else
01970       {
01971         addfilesButton->setEnabled(true);
01972         newfileButton->setEnabled(true);
01973       }
01974 
01975 
01976     }
01977     else if (pvitem->type() == qProjectItem::File)
01978     {
01979         removefileButton->setEnabled(true);
01980         configurefileButton->setEnabled(true);
01981 /*        buildTargetButton->setEnabled(true);
01982         rebuildTargetButton->setEnabled(true);
01983         executeTargetButton->setEnabled(true);*/
01984     }
01985 }
01986 
01987 void TrollProjectWidget::slotDetailsContextMenu(KListView *, QListViewItem *item, const QPoint &p)
01988 {
01989     if (!item)
01990         return;
01991 
01992     qProjectItem *pvitem = static_cast<qProjectItem*>(item);
01993     if (pvitem->type() == qProjectItem::Group) {
01994         GroupItem *titem = static_cast<GroupItem*>(pvitem);
01995         QString title,ext;
01996         switch (titem->groupType) {
01997         case GroupItem::Sources:
01998             title = i18n("Sources");
01999             ext = "*.cpp *.c";
02000             break;
02001         case GroupItem::Headers:
02002             title = i18n("Headers");
02003             ext = "*.h *.hpp";
02004             break;
02005         case GroupItem::Forms:
02006             title = i18n("Forms");
02007             ext = "*.ui";
02008             break;
02009         case GroupItem::IDLs:
02010             title = i18n("Corba IDLs");
02011             ext = "*.idl *.kidl";
02012             break;
02013         case GroupItem::Lexsources:
02014             title = i18n("Lexsources");
02015             ext = "*.l *.ll *.lxx *.l++";
02016             break;
02017         case GroupItem::Yaccsources:
02018             title = i18n("Yaccsources");
02019             ext = "*.y *.yy *.yxx *.y++";
02020             break;
02021         case GroupItem::Images:
02022             title = i18n("Images");
02023             ext = "*.jpg *.png *.xpm *.gif";
02024             break;
02025         case GroupItem::Distfiles:
02026             title = i18n("Distfiles");
02027             ext = "*";
02028             break;
02029         case GroupItem::Translations:
02030             title = i18n("Translations");
02031             ext = "*.ts";
02032             break;
02033         case GroupItem::InstallRoot:
02034             title = i18n("Installs");
02035             break;
02036         case GroupItem::InstallObject:
02037             title = i18n("Install object");
02038             break;
02039 
02040         default: ;
02041         }
02042 
02043         KPopupMenu popup(this);
02044     popup.insertTitle(title);
02045 
02046         int idInsExistingFile = -2;
02047     int idInsNewFile = -2;
02048     int idInsInstallObject = -2;
02049     int idInsNewFilepatternItem = -2;
02050     int idSetInstObjPath = -2;
02051     int idLUpdate = -2;
02052     int idLRelease = -2;
02053 
02054  //       int idFileProperties = popup.insertItem(SmallIconSet("filenew"),i18n("Properties..."));
02055         if (titem->groupType == GroupItem::InstallRoot)
02056         {
02057       idInsInstallObject = popup.insertItem(SmallIconSet("fileopen"),i18n("Add Install Object..."));
02058             popup.setWhatsThis(idInsInstallObject, i18n("<b>Add install object</b><p>Creates QMake install object. "
02059                 "It is possible to define a list of files to install and installation locations for each object. Warning! "
02060                 "Install objects without path specified will not be saved to a project file."));
02061         }
02062         else if (titem->groupType == GroupItem::InstallObject)
02063         {
02064       idSetInstObjPath = popup.insertItem(SmallIconSet("fileopen"),i18n("Install Path..."));
02065             popup.setWhatsThis(idSetInstObjPath, i18n("<b>Install path</b><p>Allows to choose the installation path for the current install object."));
02066       idInsNewFilepatternItem = popup.insertItem(SmallIconSet("fileopen"),i18n("Add Pattern of Files to Install..."));
02067             popup.setWhatsThis(idInsNewFilepatternItem, i18n("<b>Add pattern of files to install</b><p>Defines the pattern to match files which will be installed. "
02068                 "It is possible to use wildcards and relative paths like <i>docs/*</i>."));
02069         }
02070         else if(titem->groupType == GroupItem::Translations)
02071         {
02072       idInsNewFile = popup.insertItem(SmallIconSet("filenew"),i18n("Create New File..."));
02073             popup.setWhatsThis(idInsNewFile, i18n("<b>Create new file</b><p>Creates a new translation file and adds it to a currently selected TRANSLATIONS group."));
02074       idInsExistingFile = popup.insertItem(SmallIconSet("fileopen"),i18n("Add Existing Files..."));
02075             popup.setWhatsThis(idInsExistingFile, i18n("<b>Add existing files</b><p>Adds existing translation (*.ts) files to a currently selected TRANSLATIONS group. It is "
02076             "possible to copy files to a current subproject directory, create symbolic links or "
02077             "add them with the relative path."));
02078       idLUpdate = popup.insertItem(SmallIconSet("konsole"),i18n("Update Translation Files"));
02079             popup.setWhatsThis(idLUpdate, i18n("<b>Update Translation Files</b><p>Runs <b>lupdate</b> command from the current subproject directory. It collects translatable "
02080                 "messages and saves them into translation files."));
02081       idLRelease = popup.insertItem(SmallIconSet("konsole"),i18n("Release Binary Translations"));
02082             popup.setWhatsThis(idLRelease, i18n("<b>Release Binary Translations</b><p>Runs <b>lrelease</b> command from the current subproject directory. It creates binary "
02083                 "translation files that are ready to be loaded at program execution."));
02084         }
02085         else // File group containing files
02086         {
02087       idInsNewFile = popup.insertItem(SmallIconSet("filenew"),i18n("Create New File..."));
02088             popup.setWhatsThis(idInsNewFile, i18n("<b>Create new file</b><p>Creates a new file and adds it to a currently selected group."));
02089       idInsExistingFile = popup.insertItem(SmallIconSet("fileopen"),i18n("Add Existing Files..."));
02090             popup.setWhatsThis(idInsExistingFile, i18n("<b>Add existing files</b><p>Adds existing files to a currently selected group. It is "
02091             "possible to copy files to a current subproject directory, create symbolic links or "
02092             "add them with the relative path."));
02093         }
02094         int r = popup.exec(p);
02095         QString cleanSubprojectPath = QDir::cleanDirPath(m_shownSubproject->path);
02096 
02097         if (r == idSetInstObjPath)
02098         {
02099           KURLRequesterDlg dialog(i18n( "Choose Install Path" ), i18n( "Enter a path "
02100                                     "(example /usr/local/share/... ):" ), this, 0);
02101           dialog.urlRequester()->setMode(KFile::Directory);
02102           dialog.urlRequester()->setURL(titem->install_path);
02103           if (dialog.exec() == QDialog::Accepted)
02104           {
02105             titem->install_path = dialog.urlRequester()->url();
02106             updateProjectFile(titem->owner);
02107           }
02108         }
02109         else if (r == idInsNewFilepatternItem)
02110         {
02111           bool ok = FALSE;
02112           QString filepattern = KInputDialog::getText(
02113                               i18n( "Add Pattern of Files to Install" ),
02114                               i18n( "Enter a pattern relative to the current "
02115                                     "subproject (example docs/*.html):" ),
02116                               QString::null, &ok, this );
02117           if ( ok && !filepattern.isEmpty() )
02118           {
02119             addFileToCurrentSubProject(titem,filepattern);
02120             updateProjectFile(titem->owner);
02121             slotOverviewSelectionChanged(m_shownSubproject);
02122           }
02123         }
02124         else if (r == idInsExistingFile)
02125         {
02126 #if KDE_VERSION >= 310
02127           AddFilesDialog *dialog = new AddFilesDialog(cleanSubprojectPath,
02128                                                 ext + "|" + title + " (" + ext + ")",
02129                                                 this,
02130                                                 "Add existing files",
02131                                                 true, new QComboBox(false));
02132 #else
02133           AddFilesDialog *dialog = new AddFilesDialog(cleanSubprojectPath,
02134                                                 ext + "|" + title + " (" + ext + ")",
02135                                                 this,
02136                                                 "Add existing files",
02137                                                 true);
02138 #endif
02139           dialog->setMode(KFile::Files | KFile::ExistingOnly | KFile::LocalOnly);
02140           if ( dialog->exec() == QDialog::Rejected )
02141             return;
02142           QStringList files = dialog->selectedFiles();
02143           for (unsigned int i=0;i<files.count();++i)
02144           {
02145             switch (dialog->mode())
02146             {
02147             case AddFilesDialog::Copy:
02148                 {
02149                 // Copy selected files to current subproject folder
02150                 QProcess *proc = new QProcess( this );
02151                 proc->addArgument( "cp" );
02152                 proc->addArgument( "-f" );
02153                 proc->addArgument( files[i] );
02154                 proc->addArgument( cleanSubprojectPath );
02155                 proc->start();
02156                 QString filename = files[i].right(files[i].length()-files[i].findRev('/')-1);
02157                 // and add them to the filelist
02158                 addFileToCurrentSubProject(titem,filename);
02159 
02160                 QString fileNameToAdd = m_shownSubproject->relpath + "/" + filename;
02161                 if (fileNameToAdd.startsWith("/"))
02162                     fileNameToAdd = fileNameToAdd.mid(1);
02163                 QStringList fileList(fileNameToAdd);
02164                 emit m_part->addedFilesToProject(fileList);
02165                 }
02166                 break;
02167 
02168             case AddFilesDialog::Link:
02169                 {
02170                 // Link selected files to current subproject folder
02171                 QProcess *proc = new QProcess( this );
02172                 proc->addArgument( "ln" );
02173                 proc->addArgument( "-s" );
02174                 proc->addArgument( files[i] );
02175                 proc->addArgument( cleanSubprojectPath );
02176                 proc->start();
02177                 QString filename = files[i].right(files[i].length()-files[i].findRev('/')-1);
02178                 // and add them to the filelist
02179                 addFileToCurrentSubProject(titem,filename);
02180 
02181                 QString fileNameToAdd = m_shownSubproject->relpath + "/" + filename;
02182                 if (fileNameToAdd.startsWith("/"))
02183                     fileNameToAdd = fileNameToAdd.mid(1);
02184                 QStringList fileList(fileNameToAdd);
02185                 emit m_part->addedFilesToProject(fileList);
02186                 }
02187                 break;
02188 
02189             case AddFilesDialog::Relative:
02190                 // Form relative path to current subproject folder
02191                 addFileToCurrentSubProject(titem,URLUtil::relativePathToFile(cleanSubprojectPath , files[i]));
02192 
02193                 QString fileNameToAdd = URLUtil::canonicalPath(m_shownSubproject->path + "/" + URLUtil::relativePathToFile(cleanSubprojectPath , files[i]));
02194                 fileNameToAdd = fileNameToAdd.mid(m_part->projectDirectory().length() + 1);
02195                 if (fileNameToAdd.startsWith("/"))
02196                     fileNameToAdd = fileNameToAdd.mid(1);
02197                 QStringList fileList(fileNameToAdd);
02198                 emit m_part->addedFilesToProject(fileList);
02199                 break;
02200             }
02201           }
02202           // Update project file
02203           if ( titem && titem->owner )
02204             updateProjectFile(titem->owner);
02205           // Update subprojectview
02206           slotOverviewSelectionChanged(m_shownSubproject);
02207         }
02208         else if (r == idInsNewFile)
02209         {
02210             KDevCreateFile * createFileSupport = m_part->createFileSupport();
02211             if (createFileSupport)
02212             {
02213                 QString fcext;
02214                 switch (titem->groupType) {
02215                 case GroupItem::Sources:
02216                     fcext = "cpp";
02217                     break;
02218                 case GroupItem::Headers:
02219                     fcext = "h";
02220                     break;
02221                 case GroupItem::Forms:
02222                     fcext = "ui-widget";
02223                     break;
02224                 case GroupItem::Translations:
02225                     fcext = "ts";
02226                     break;
02227                 case GroupItem::Lexsources:
02228                     fcext = "l";
02229                     break;
02230                 case GroupItem::Yaccsources:
02231                     fcext = "y";
02232                     break;
02233                 default:
02234                     fcext = QString::null;
02235                 }
02236                 KDevCreateFile::CreatedFile crFile =
02237                     createFileSupport->createNewFile(fcext, cleanSubprojectPath);
02238             } else {
02239                 bool ok = FALSE;
02240                 QString filename = KInputDialog::getText(
02241                                     i18n( "Create New File"),
02242                                     i18n( "Enter a name for the new file:" ),
02243                                     QString::null, &ok, this );
02244                 if ( ok && !filename.isEmpty() )
02245                 {
02246                     QFile newfile(cleanSubprojectPath+'/'+filename);
02247                     if (!newfile.open(IO_WriteOnly))
02248                     {
02249                     KMessageBox::error(this,i18n("Failed to create new file. "
02250                                                 "Do you have write permission "
02251                                                 "in the project folder?" ));
02252                     return;
02253                     }
02254                     newfile.close();
02255                     addFileToCurrentSubProject(titem,filename);
02256                     updateProjectFile(titem->owner);
02257                     slotOverviewSelectionChanged(m_shownSubproject);
02258 
02259                     QStringList files(m_shownSubproject->path + "/" + filename);
02260                     emit m_part->addedFilesToProject(files);
02261                 }
02262             }
02263         }
02264         else if (r == idInsInstallObject)
02265         {
02266           bool ok = FALSE;
02267           QString install_obj = KInputDialog::getText(
02268                               i18n( "Add Install Object" ),
02269                               i18n( "Enter a name for the new object:" ),
02270                               QString::null, &ok, this );
02271           if ( ok && !install_obj.isEmpty() )
02272           {
02273             GroupItem* institem = createGroupItem(GroupItem::InstallObject, install_obj ,titem->scopeString);
02274             institem->owner = m_shownSubproject;
02275             institem->install_objectname = install_obj;
02276             titem->installs.append(institem);
02277             slotOverviewSelectionChanged(m_shownSubproject);
02278           }
02279         }
02280     else if (r == idLUpdate)
02281         {
02282        QString cmd = "lupdate ";
02283            cmd += m_shownSubproject->pro_file;
02284            m_part->appFrontend()->startAppCommand(m_shownSubproject->path,cmd,false);
02285         }
02286         else if (r == idLRelease)
02287         {
02288        QString cmd = "lrelease ";
02289            cmd += m_shownSubproject->pro_file;
02290            m_part->appFrontend()->startAppCommand(m_shownSubproject->path,cmd,false);
02291         }
02292     } else if (pvitem->type() == qProjectItem::File) {
02293 
02294         removefileButton->setEnabled(true);
02295         FileItem *fitem = static_cast<FileItem*>(pvitem);
02296     GroupItem::GroupType gtype = static_cast<GroupItem*>(item->parent())->groupType;
02297 
02298     KPopupMenu popup(this);
02299     if (!(gtype == GroupItem::InstallObject))
02300         popup.insertTitle(i18n("File: %1").arg(fitem->name));
02301     else
02302         popup.insertTitle(i18n("Pattern: %1").arg(fitem->name));
02303 
02304         int idRemoveFile = -2;
02305     int idSubclassWidget = -2;
02306     int idUpdateWidgetclass = -2;
02307     int idUISubclasses = -2;
02308     int idViewUIH = -2;
02309     int idFileProperties = -2;
02310     int idEditInstallPattern = -2;
02311 
02312         if (!fitem->uiFileLink.isEmpty())
02313         {
02314           idUpdateWidgetclass = popup.insertItem(SmallIconSet("qmake_subclass"),i18n("Edit ui-Subclass..."));
02315           popup.setWhatsThis(idUpdateWidgetclass, i18n("<b>Edit ui-subclass</b><p>Launches <b>Subclassing</b> wizard "
02316                            "and prompts to implement missing in childclass slots and functions."));
02317         }
02318         if(fitem->name.contains(".ui"))
02319         {
02320       idSubclassWidget = popup.insertItem(SmallIconSet("qmake_subclass"),i18n("Subclassing Wizard..."));
02321           popup.setWhatsThis(idSubclassWidget, i18n("<b>Subclass widget</b><p>Launches <b>Subclassing</b> wizard. "
02322                            "It allows to create a subclass from the class defined in .ui file. "
02323                            "There is also possibility to implement slots and functions defined in the base class."));
02324       idViewUIH = popup.insertItem(SmallIconSet("qmake_ui_h"),i18n("Open ui.h File"));
02325           popup.setWhatsThis(idViewUIH, i18n("<b>Open ui.h file</b><p>Opens .ui.h file associated with the selected .ui."));
02326       idUISubclasses = popup.insertItem(SmallIconSet("qmake_subclass"),i18n("List of Subclasses..."));
02327           popup.setWhatsThis(idUISubclasses, i18n("<b>List of subclasses</b><p>Shows subclasses list editor. "
02328                            "There is possibility to add or remove subclasses from the list."));
02329         }
02330     if(!(gtype == GroupItem::InstallObject))
02331     {
02332       idRemoveFile = popup.insertItem(SmallIconSet("editdelete"),i18n("Remove File"));
02333             popup.setWhatsThis(idRemoveFile, i18n("<b>Remove file</b><p>Removes file from a current group. Does not remove file from disk."));
02334       idFileProperties = popup.insertItem(SmallIconSet("configure_file"),i18n("Properties..."));
02335             popup.setWhatsThis(idFileProperties, i18n("<b>Properties</b><p>Opens <b>File Properties</b> dialog that allows to exclude file from specified scopes."));
02336     }
02337     else
02338     {
02339       idEditInstallPattern = popup.insertItem(SmallIconSet("configure_file"),i18n("Edit Pattern"));
02340             popup.setWhatsThis(idEditInstallPattern, i18n("<b>Edit pattern</b><p>Allows to edit install files pattern."));
02341       idRemoveFile = popup.insertItem(SmallIconSet("editdelete"),i18n("Remove Pattern"));
02342             popup.setWhatsThis(idRemoveFile, i18n("<b>Remove pattern</b><p>Removes install files pattern from the current install object."));
02343     }
02344     if(!(gtype == GroupItem::InstallObject))
02345     {
02346         FileContext context(m_shownSubproject->path + "/" + fitem->name, false);
02347         m_part->core()->fillContextMenu(&popup, &context);
02348     }
02349 
02350         int r = popup.exec(p);
02351         if (r == idRemoveFile)
02352             removeFile(m_shownSubproject, fitem);
02353         // Fileproperties
02354         else if (r == idFileProperties)
02355         {
02356         /*
02357           GroupItem *gitem = static_cast<GroupItem*>(fitem->parent());
02358           if (!gitem)
02359             return;
02360           QStringList dirtyScopes;
02361           FilePropertyDlg *propdlg = new FilePropertyDlg(m_shownSubproject,gitem->groupType,fitem,dirtyScopes);
02362           SubqmakeprojectItem *scope;
02363           propdlg->exec();
02364           for (uint i=0; i<dirtyScopes.count();i++)
02365           {
02366             scope = getScope(m_shownSubproject,dirtyScopes[i]);
02367             if (scope)
02368                updateProjectFile(scope);
02369           }
02370         */
02371           slotConfigureFile();
02372         }
02373         else if(r == idViewUIH) {
02374           m_part->partController()->editDocument(KURL(m_shownSubproject->path + "/" +
02375              QString(fitem->name + ".h")));
02376 
02377         }
02378         else if (r == idSubclassWidget)
02379         {
02380             QStringList newFileNames;
02381             newFileNames = m_part->languageSupport()->subclassWidget(m_shownSubproject->path + "/" + fitem->name);
02382             if (!newFileNames.empty())
02383             {
02384                 QDomDocument &dom = *(m_part->projectDom());
02385                 for (uint i=0; i<newFileNames.count(); ++i)
02386                 {
02387                     QString srcfile_relpath = newFileNames[i].remove(0,projectDirectory().length());
02388                     QString uifile_relpath = QString(m_shownSubproject->path + "/" + fitem->name).remove(0,projectDirectory().length());
02389                     DomUtil::PairList list = DomUtil::readPairListEntry(dom,"/kdevtrollproject/subclassing" ,
02390                                                             "subclass","sourcefile", "uifile");
02391 
02392                     list << DomUtil::Pair(srcfile_relpath,uifile_relpath);
02393                     DomUtil::writePairListEntry(dom, "/kdevtrollproject/subclassing", "subclass", "sourcefile", "uifile", list);
02394 //                    newFileNames[i] = newFileNames[i].replace(QRegExp(projectDirectory()+"/"),"");
02395                     newFileNames[i] = projectDirectory() + newFileNames[i];
02396                     qWarning("new file: %s", newFileNames[i].latin1());
02397                 }
02398                 m_subclasslist = DomUtil::readPairListEntry(dom,"/kdevtrollproject/subclassing" ,
02399                                                                 "subclass","sourcefile", "uifile");
02400 
02401                 m_part->addFiles(newFileNames);
02402             }
02403         }
02404         else if (r == idUpdateWidgetclass)
02405         {
02406           QString noext = m_shownSubproject->path + "/" + fitem->name;
02407           if (noext.findRev('.')>-1)
02408             noext = noext.left(noext.findRev('.'));
02409           QStringList dummy;
02410           QString uifile = fitem->uiFileLink;
02411           if (uifile.findRev('/')>-1)
02412           {
02413             QStringList uisplit = QStringList::split('/',uifile);
02414             uifile=uisplit[uisplit.count()-1];
02415           }
02416           m_part->languageSupport()->updateWidget(m_shownSubproject->path + "/" + uifile, noext);
02417         }
02418         else if (r == idUISubclasses)
02419         {
02420             QDomDocument &dom = *(m_part->projectDom());
02421             DomUtil::PairList list = DomUtil::readPairListEntry(dom,"/kdevtrollproject/subclassing" ,
02422                                                     "subclass","sourcefile", "uifile");
02423             SubclassesDlg *sbdlg = new SubclassesDlg( QString(m_shownSubproject->path + "/" + fitem->name).remove(0,projectDirectory().length()),
02424                 list, projectDirectory());
02425 
02426             if (sbdlg->exec())
02427             {
02428                 QDomElement el = DomUtil::elementByPath( dom,  "/kdevtrollproject");
02429                 QDomElement el2 = DomUtil::elementByPath( dom,  "/kdevtrollproject/subclassing");
02430                 if ( (!el.isNull()) && (!el2.isNull()) )
02431                 {
02432                     el.removeChild(el2);
02433                 }
02434 
02435                 DomUtil::writePairListEntry(dom, "/kdevtrollproject/subclassing", "subclass", "sourcefile", "uifile", list);
02436 
02437                 m_subclasslist = DomUtil::readPairListEntry(dom,"/kdevtrollproject/subclassing" ,
02438                     "subclass","sourcefile", "uifile");
02439             }
02440         }
02441         else if (r == idEditInstallPattern)
02442         {
02443     GroupItem *titem = static_cast<GroupItem*>(item->parent());
02444 
02445           bool ok = FALSE;
02446           QString filepattern = KInputDialog::getText(
02447                               i18n( "Edit Pattern" ),
02448                               i18n( "Enter a pattern relative to the current "
02449                                     "subproject (example docs/*.html):" ),
02450                               fitem->name , &ok, this );
02451           if ( ok && !filepattern.isEmpty() )
02452           {
02453         removeFile(m_shownSubproject, fitem);
02454             addFileToCurrentSubProject(titem,filepattern);
02455             updateProjectFile(titem->owner);
02456             slotOverviewSelectionChanged(m_shownSubproject);
02457           }
02458         }
02459     }
02460 }
02461 
02462 
02463 void TrollProjectWidget::removeFile(SubqmakeprojectItem *spitem, FileItem *fitem)
02464 {
02465     GroupItem *gitem = static_cast<GroupItem*>(fitem->parent());
02466 
02467     if(gitem->groupType != GroupItem::InstallObject)
02468     {
02469         QString removedFileName = spitem->relpath + "/" + fitem->text(0);
02470         if (removedFileName.startsWith("/"))
02471             removedFileName = removedFileName.mid(1);
02472         emitRemovedFile(removedFileName);
02473     }
02474 
02475 
02476     //remove subclassing info
02477     QDomDocument &dom = *(m_part->projectDom());
02478     DomUtil::PairList list = DomUtil::readPairListEntry(dom,"/kdevtrollproject/subclassing" ,
02479                                             "subclass","sourcefile", "uifile");
02480     QPtrList<DomUtil::Pair> pairsToRemove;
02481     DomUtil::PairList::iterator it;
02482     QString file = QString(spitem->path + "/" + fitem->name).remove(0,projectDirectory().length());
02483     for ( it = list.begin(); it != list.end(); ++it )
02484     {
02485         if ( ((*it).first == file) || ((*it).second == file) )
02486         {
02487             pairsToRemove.append(&(*it));
02488         }
02489     }
02490     DomUtil::Pair *pair;
02491     for ( pair = pairsToRemove.first(); pair; pair = pairsToRemove.next() )
02492     {
02493         list.remove(*pair);
02494     }
02495     QDomElement el = DomUtil::elementByPath( dom,  "/kdevtrollproject");
02496     QDomElement el2 = DomUtil::elementByPath( dom,  "/kdevtrollproject/subclassing");
02497     if ( (!el.isNull()) && (!el2.isNull()) )
02498     {
02499         el.removeChild(el2);
02500     }
02501     DomUtil::writePairListEntry(dom, "/kdevtrollproject/subclassing", "subclass", "sourcefile", "uifile", list);
02502 
02503 
02504 
02505     switch (gitem->groupType)
02506     {
02507       case GroupItem::Sources:
02508         spitem->sources.remove(fitem->text(0));
02509         break;
02510       case GroupItem::Headers:
02511         spitem->headers.remove(fitem->text(0));
02512         break;
02513       case GroupItem::Forms:
02514         spitem->forms.remove(fitem->text(0));
02515         break;
02516       case GroupItem::Lexsources:
02517         spitem->lexsources.remove(fitem->text(0));
02518         break;
02519       case GroupItem::Yaccsources:
02520         spitem->yaccsources.remove(fitem->text(0));
02521         break;
02522       case GroupItem::Images:
02523         spitem->images.remove(fitem->text(0));
02524         break;
02525       case GroupItem::Distfiles:
02526         spitem->distfiles.remove(fitem->text(0));
02527         break;
02528       case GroupItem::Translations:
02529         spitem->translations.remove(fitem->text(0));
02530         break;
02531       case GroupItem::IDLs:
02532         spitem->idls.remove(fitem->text(0));
02533         break;
02534       case GroupItem::InstallObject:
02535     gitem->str_files.remove(fitem->text(0));
02536     break;
02537       default: ;
02538     }
02539     gitem->files.remove(fitem);
02540     updateProjectFile(m_shownSubproject);
02541 }
02542 
02543 
02544 GroupItem *TrollProjectWidget::createGroupItem(GroupItem::GroupType groupType, const QString &name,const QString &scopeString)
02545 {
02546     // Workaround because for QListView not being able to create
02547     // items without actually inserting them
02548     GroupItem *titem = new GroupItem(overview, groupType, name,scopeString);
02549     overview->takeItem(titem);
02550 
02551     return titem;
02552 }
02553 
02554 
02555 FileItem *TrollProjectWidget::createFileItem(const QString &name)
02556 {
02557     FileItem *fitem = new FileItem(overview, name);
02558     overview->takeItem(fitem);
02559     fitem->name = name;
02560 
02561     return fitem;
02562 }
02563 
02564 void TrollProjectWidget::emitAddedFile(const QString &fileName)
02565 {
02566     QStringList fileList;
02567     fileList.append ( fileName );
02568     emit m_part->addedFilesToProject(fileList);
02569 }
02570 
02571 
02572 void TrollProjectWidget::emitRemovedFile(const QString &fileName)
02573 {
02574     QStringList fileList;
02575     fileList.append ( fileName );
02576     emit m_part->removedFilesFromProject(fileList);
02577 }
02578 
02579 
02580 QString TrollProjectWidget::getUiFileLink(const QString &relpath, const QString& filename)
02581 {
02582   DomUtil::PairList::iterator it;
02583   for (it=m_subclasslist.begin();it != m_subclasslist.end(); ++it)
02584   {
02585     if ((*it).first==relpath+filename)
02586       return (*it).second;
02587   }
02588   return "";
02589 }
02590 
02591 void TrollProjectWidget::parseScope(SubqmakeprojectItem *item, QString scopeString, FileBuffer *buffer)
02592 {
02593     if (!scopeString.isEmpty())
02594     {
02595       QStringList scopeNames = QStringList::split(':',scopeString);
02596       SubqmakeprojectItem *sitem;
02597       sitem = new SubqmakeprojectItem(item, scopeNames[scopeNames.count()-1],scopeString);
02598       sitem->path = item->path;
02599       sitem->m_RootBuffer = buffer;
02600       sitem->subdir = item->subdir;
02601       sitem->pro_file = item->pro_file;
02602       item->scopes.append(sitem);
02603       item=sitem;
02604     }
02605 
02606     item->relpath = item->path;
02607     item->relpath.remove(0,projectDirectory().length());
02608 
02609     QStringList minusListDummy;
02610     FileBuffer *subBuffer = buffer->getSubBuffer(scopeString);
02611     if( m_part->isTMakeProject() )
02612     subBuffer->getValues("INTERFACES",item->forms,item->forms_exclude);
02613     else
02614     subBuffer->getValues("FORMS",item->forms,item->forms_exclude);
02615 
02616     subBuffer->getValues("SOURCES",item->sources,item->sources_exclude);
02617     subBuffer->getValues("HEADERS",item->headers,item->headers_exclude);
02618     subBuffer->getValues("LEXSOURCES",item->lexsources,item->lexsources_exclude);
02619     subBuffer->getValues("YACCSOURCES",item->yaccsources,item->yaccsources_exclude);
02620     subBuffer->getValues("IMAGES",item->images,item->images_exclude);
02621     subBuffer->getValues("DISTFILES",item->distfiles,item->distfiles_exclude);
02622     subBuffer->getValues("TRANSLATIONS",item->translations,item->translations_exclude);
02623     subBuffer->getValues("IDLS",item->idls,item->idls_exclude);
02624     QStringList installs,installs_exclude;
02625     subBuffer->getValues("INSTALLS",installs,installs_exclude);
02626 
02627     // Create list view items
02628 
02629     GroupItem * titem = createGroupItem(GroupItem::InstallRoot, "INSTALLS",scopeString);
02630     titem->owner = item;
02631     item->groups.append(titem);
02632     if (!installs.isEmpty())
02633     {
02634       QStringList::iterator it = installs.begin();
02635       for (;it!=installs.end();it++)
02636       {
02637         if ((*it)=="target")
02638           continue;
02639         QStringList path,path_excl;
02640         QString path_str;
02641         subBuffer->getValues((*it)+".path",path,path_excl);
02642         if (!path.isEmpty())
02643           path_str = path[0];
02644 
02645         GroupItem* institem = createGroupItem(GroupItem::InstallObject, (*it)  ,scopeString);
02646         subBuffer->getValues((*it)+".files",institem->str_files,institem->str_files_exclude);
02647         institem->install_path = path_str;
02648         institem->install_objectname = *it;
02649         institem->owner = item;
02650         titem->installs.append(institem);
02651 
02652         if (!institem->str_files.isEmpty())
02653         {
02654           QStringList::iterator it2 = institem->str_files.begin();
02655           for (;it2!=institem->str_files.end();it2++)
02656           {
02657             FileItem *fitem = createFileItem(*it2);
02658             institem->files.append(fitem);
02659           }
02660         }
02661 
02662 
02663       }
02664     }
02665 
02666 
02667     titem = createGroupItem(GroupItem::Lexsources, "LEXSOURCES",scopeString);
02668     titem->owner = item;
02669     item->groups.append(titem);
02670     if (!item->lexsources.isEmpty()) {
02671         QStringList l = item->lexsources;
02672         QStringList::Iterator it;
02673         for (it = l.begin(); it != l.end(); ++it) {
02674             FileItem *fitem = createFileItem(*it);
02675             fitem->uiFileLink = getUiFileLink(item->relpath+"/",*it);
02676             titem->files.append(fitem);
02677         }
02678     }
02679     titem = createGroupItem(GroupItem::Yaccsources, "YACCSOURCES",scopeString);
02680     titem->owner = item;
02681     item->groups.append(titem);
02682     if (!item->yaccsources.isEmpty()) {
02683         QStringList l = item->yaccsources;
02684         QStringList::Iterator it;
02685         for (it = l.begin(); it != l.end(); ++it) {
02686             FileItem *fitem = createFileItem(*it);
02687             fitem->uiFileLink = getUiFileLink(item->relpath+"/",*it);
02688             titem->files.append(fitem);
02689         }
02690     }
02691     titem = createGroupItem(GroupItem::Distfiles, "DISTFILES",scopeString);
02692     titem->owner = item;
02693     item->groups.append(titem);
02694     if (!item->distfiles.isEmpty()) {
02695         QStringList l = item->distfiles;
02696         QStringList::Iterator it;
02697         for (it = l.begin(); it != l.end(); ++it) {
02698             FileItem *fitem = createFileItem(*it);
02699             fitem->uiFileLink = getUiFileLink(item->relpath+"/",*it);
02700             titem->files.append(fitem);
02701         }
02702     }
02703     titem = createGroupItem(GroupItem::Images, "IMAGES",scopeString);
02704     titem->owner = item;
02705     item->groups.append(titem);
02706     if (!item->images.isEmpty()) {
02707         QStringList l = item->images;
02708         QStringList::Iterator it;
02709         for (it = l.begin(); it != l.end(); ++it) {
02710             FileItem *fitem = createFileItem(*it);
02711             fitem->uiFileLink = getUiFileLink(item->relpath+"/",*it);
02712             titem->files.append(fitem);
02713         }
02714     }
02715     titem = createGroupItem(GroupItem::Translations, "TRANSLATIONS",scopeString);
02716     titem->owner = item;
02717     item->groups.append(titem);
02718     if (!item->translations.isEmpty()) {
02719         QStringList l = item->translations;
02720         QStringList::Iterator it;
02721         for (it = l.begin(); it != l.end(); ++it) {
02722             FileItem *fitem = createFileItem(*it);
02723             fitem->uiFileLink = getUiFileLink(item->relpath+"/",*it);
02724             titem->files.append(fitem);
02725         }
02726     }
02727     titem = createGroupItem(GroupItem::IDLs, "Corba IDL",scopeString);
02728     titem->owner = item;
02729     item->groups.append(titem);
02730     if (!item->idls.isEmpty()) {
02731         QStringList l = item->idls;
02732         QStringList::Iterator it;
02733         for (it = l.begin(); it != l.end(); ++it) {
02734             FileItem *fitem = createFileItem(*it);
02735             fitem->uiFileLink = getUiFileLink(item->relpath+"/",*it);
02736             titem->files.append(fitem);
02737         }
02738     }
02739 
02740 
02741 //    titem = createGroupItem(GroupItem::Forms, "FORMS",scopeString);
02742     titem = createGroupItem(GroupItem::Forms,
02743                        (m_part->isTMakeProject() ? "INTERFACES" : "FORMS"),
02744                        scopeString);
02745 
02746     item->groups.append(titem);
02747     titem->owner = item;
02748     if (!item->forms.isEmpty()) {
02749         QStringList l = item->forms;
02750         QStringList::Iterator it;
02751         for (it = l.begin(); it != l.end(); ++it) {
02752             FileItem *fitem = createFileItem(*it);
02753             titem->files.append(fitem);
02754         }
02755     }
02756     titem = createGroupItem(GroupItem::Sources, "SOURCES",scopeString);
02757     item->groups.append(titem);
02758     titem->owner = item;
02759     if (!item->sources.isEmpty()) {
02760         QStringList l = item->sources;
02761         QStringList::Iterator it;
02762         for (it = l.begin(); it != l.end(); ++it) {
02763             getUiFileLink(item->relpath+"/",*it);
02764             FileItem *fitem = createFileItem(*it);
02765             fitem->uiFileLink = getUiFileLink(item->relpath+"/",*it);
02766             titem->files.append(fitem);
02767         }
02768     }
02769     titem = createGroupItem(GroupItem::Headers, "HEADERS",scopeString);
02770     titem->owner = item;
02771     item->groups.append(titem);
02772     if (!item->headers.isEmpty()) {
02773         QStringList l = item->headers;
02774         QStringList::Iterator it;
02775         for (it = l.begin(); it != l.end(); ++it) {
02776             FileItem *fitem = createFileItem(*it);
02777             fitem->uiFileLink = getUiFileLink(item->relpath+"/",*it);
02778             titem->files.append(fitem);
02779         }
02780     }
02781     QStringList childScopes = subBuffer->getChildScopeNames();
02782     for (unsigned int i=0; i<childScopes.count();i++)
02783       parseScope(item,scopeString+(!scopeString.isEmpty() ? ":" : "")+childScopes[i],buffer);
02784 }
02785 
02786 void TrollProjectWidget::parse(SubqmakeprojectItem *item)
02787 {
02788     QFileInfo fi(item->path);
02789 //    QString proname = item->path + "/" + fi.baseName() + ".pro";
02790     QDir dir(item->path);
02791     QStringList l = dir.entryList("*.pro");
02792 
02793     item->pro_file = l.count()?l[0]:(fi.baseName() + ".pro");
02794     QString proname = item->path + "/" + item->pro_file;
02795 
02796     kdDebug(9024) << "Parsing " << proname << endl;
02797 
02798 
02799     item->m_FileBuffer.bufferFile(proname);
02800     item->m_FileBuffer.handleScopes();
02801 
02802     parseScope(item,"",&(item->m_FileBuffer));
02803     QStringList minusListDummy;
02804     QStringList lst;
02805 
02806     item->configuration.m_subdirName = item->subdir;
02807     // set defaults
02808     item->configuration.m_template = QTMP_APPLICATION;
02809     item->configuration.m_buildMode = QBM_RELEASE;
02810     item->configuration.m_warnings = QWARN_ON;
02811     item->configuration.m_requirements = 0;
02812     item->setPixmap(0,SmallIcon("qmake_app"));
02813 
02814     // retrieve the project configuration
02815     item->m_FileBuffer.getValues("TEMPLATE",lst,minusListDummy);
02816     if (lst.count())
02817     {
02818       if (lst[0] == "app")
02819         item->configuration.m_template = QTMP_APPLICATION;
02820       if (lst[0] == "lib")
02821       {
02822         item->setPixmap(0,SmallIcon("qmake_lib"));
02823         item->configuration.m_template = QTMP_LIBRARY;
02824       }
02825       if (lst[0] == "subdirs")
02826       {
02827         item->setPixmap(0,SmallIcon("qmake_sub"));
02828         item->configuration.m_template = QTMP_SUBDIRS;
02829       }
02830     }
02831     item->m_FileBuffer.getValues("VERSION",lst,minusListDummy);
02832     if(lst.count())
02833       item->configuration.m_libraryversion = lst[0];
02834 
02835     item->configuration.m_inheritconfig = true;
02836     QPtrList<FileBuffer::ValueSetMode> configvaluesetmodes;
02837     item->m_FileBuffer.getVariableValueSetModes("CONFIG",configvaluesetmodes);
02838 
02839     FileBuffer::ValueSetMode* ConfigSetMode = NULL;
02840     for(ConfigSetMode = configvaluesetmodes.first(); ConfigSetMode; ConfigSetMode = configvaluesetmodes.next())
02841     {
02842       if(ConfigSetMode != NULL)
02843       {
02844         if(ConfigSetMode[0] == FileBuffer::VSM_RESET)
02845         {
02846           item->configuration.m_inheritconfig = false;
02847       break;
02848     }
02849       }
02850     }
02851 
02852     item->m_FileBuffer.getValues("CONFIG",lst,minusListDummy);
02853     if (lst.count())
02854     {
02855       // config debug/release
02856       if (lst.find("debug")!=lst.end())
02857         item->configuration.m_buildMode = QBM_DEBUG;
02858       if (lst.find("release")!=lst.end())
02859         item->configuration.m_buildMode = QBM_RELEASE;
02860       // config warnings on/off
02861       if (lst.find("warn_on")!=lst.end())
02862         item->configuration.m_warnings = QWARN_ON;
02863       if (lst.find("warn_off")!=lst.end())
02864         item->configuration.m_warnings = QWARN_OFF;
02865       // config requerments
02866       if (lst.find("qt")!=lst.end())
02867         item->configuration.m_requirements += QD_QT;
02868       if (lst.find("x11")!=lst.end())
02869         item->configuration.m_requirements += QD_X11;
02870       if (lst.find("thread")!=lst.end())
02871         item->configuration.m_requirements += QD_THREAD;
02872       if (lst.find("opengl")!=lst.end())
02873         item->configuration.m_requirements += QD_OPENGL;
02874       // config lib mode
02875       if (lst.find("staticlib")!=lst.end())
02876         item->configuration.m_requirements += QD_STATIC;
02877       if (lst.find("dll")!=lst.end())
02878         item->configuration.m_requirements += QD_SHARED;
02879       if (lst.find("plugin")!=lst.end())
02880         item->configuration.m_requirements += QD_PLUGIN;
02881       if (lst.find("exceptions")!=lst.end())
02882         item->configuration.m_requirements += QD_EXCEPTIONS;
02883       if (lst.find("stl")!=lst.end())
02884         item->configuration.m_requirements += QD_STL;
02885       if (lst.find("rtti")!=lst.end())
02886         item->configuration.m_requirements += QD_RTTI;
02887       if (lst.find("ordered")!=lst.end())
02888         item->configuration.m_requirements += QD_ORDERED;
02889     }
02890     item->m_FileBuffer.getValues("DESTDIR",lst,minusListDummy);
02891     if (lst.count())
02892       item->configuration.m_destdir = lst[0];
02893     item->m_FileBuffer.getValues("INCLUDEPATH",lst,minusListDummy);
02894     if (lst.count())
02895       item->configuration.m_incadd = lst;
02896     item->m_FileBuffer.getValues("LIBS",lst,minusListDummy);
02897     if (lst.count())
02898       item->configuration.m_libadd = lst;
02899 
02900     item->m_FileBuffer.getValues("TARGET",lst,minusListDummy);
02901     if (lst.count())
02902       item->configuration.m_target = lst[0];
02903 
02904     item->m_FileBuffer.getValues("TARGETDEPS",lst,minusListDummy);
02905     if (lst.count())
02906       item->configuration.m_prjdeps = lst;
02907     item->m_FileBuffer.getValues("DEFINES",lst,minusListDummy);
02908     item->configuration.m_defines = lst;
02909     item->m_FileBuffer.getValues("QMAKE_CXXFLAGS_DEBUG",lst,minusListDummy);
02910     item->configuration.m_cxxflags_debug = lst;
02911     item->m_FileBuffer.getValues("QMAKE_CXXFLAGS_RELEASE",lst,minusListDummy);
02912     item->configuration.m_cxxflags_release = lst;
02913     item->m_FileBuffer.getValues("QMAKE_LFLAGS_DEBUG",lst,minusListDummy);
02914     item->configuration.m_lflags_debug = lst;
02915     item->m_FileBuffer.getValues("QMAKE_LFLAGS_RELEASE",lst,minusListDummy);
02916     item->configuration.m_lflags_release = lst;
02917     item->m_FileBuffer.getValues("QMAKE_LIBDIR",lst,minusListDummy);
02918     item->configuration.m_librarypath = lst;
02919     item->m_FileBuffer.getValues("OBJECTS_DIR",lst,minusListDummy);
02920     if (lst.count())
02921       item->configuration.m_objectpath = lst[0];
02922     item->m_FileBuffer.getValues("UI_DIR",lst,minusListDummy);
02923     if (lst.count())
02924       item->configuration.m_uipath = lst[0];
02925     item->m_FileBuffer.getValues("MOC_DIR",lst,minusListDummy);
02926     if (lst.count())
02927       item->configuration.m_mocpath = lst[0];
02928     item->m_FileBuffer.getValues("MAKEFILE",lst,minusListDummy);
02929     if (lst.count())
02930       item->configuration.m_makefile = lst[0];
02931 
02932     // Install path
02933     item->m_FileBuffer.getValues("target.path",lst,minusListDummy);
02934     if (lst.count())
02935       item->configuration.m_target_install_path = lst[0];
02936     item->m_FileBuffer.getValues("INSTALLS",lst,minusListDummy);
02937     if (lst.count())
02938     {
02939       QStringList::iterator it = lst.begin();
02940       for (;it!=lst.end();it++)
02941       {
02942         if (*it == "target")
02943         {
02944           item->configuration.m_target_install = true;
02945           break;
02946         }
02947       }
02948     }
02949 
02950 
02951 
02952     // Handle "subdirs" project
02953     if (item->configuration.m_template == QTMP_SUBDIRS)
02954     {
02955       item->m_FileBuffer.getValues("SUBDIRS",lst,minusListDummy);
02956       item->subdirs = lst;
02957       QStringList::Iterator it;
02958       for (it = lst.begin(); it != lst.end(); ++it)
02959       {
02960         SubqmakeprojectItem *newitem = new SubqmakeprojectItem(item, (*it),"");
02961         newitem->subdir = *it;
02962         newitem->m_RootBuffer = &(newitem->m_FileBuffer);
02963         newitem->path = item->path + "/" + (*it);
02964         parse(newitem);
02965       }
02966     }
02967 }
02968 void TrollProjectWidget::slotBuildFile()
02969 {
02970     KParts::ReadWritePart *part = dynamic_cast<KParts::ReadWritePart*>(m_part->partController()->activePart());
02971     if (!part || !part->url().isLocalFile())
02972         return;
02973 
02974     QString fileName = part->url().path();
02975     QFileInfo fi(fileName);
02976     QString sourceDir = fi.dirPath();
02977     QString baseName = fi.baseName(true);
02978     kdDebug(9020) << "Compiling " << fileName
02979                   << "in dir " << sourceDir
02980                   << " with baseName " << baseName << endl;
02981 
02982     QString projectDir = projectDirectory();
02983     if (!sourceDir.startsWith(projectDir)) {
02984         KMessageBox::sorry(this, i18n("Can only compile files in directories which belong to the project."));
02985         return;
02986     }
02987 
02988     QString buildDir = sourceDir;
02989     QString target = baseName + ".o";
02990     kdDebug(9020) << "builddir " << buildDir << ", target " << target << endl;
02991 
02992     m_part->mainWindow()->raiseView(m_part->makeFrontend()->widget());
02993 //    m_part->startMakeCommand(buildDir, target);
02994 
02995     kdDebug(9020) << "searching for the subproject" << endl;
02996     QPtrList<SubqmakeprojectItem> list = findSubprojectForFile(fi);
02997     kdDebug(9020) << "searching for the subproject: success" << endl;
02998 
02999     SubqmakeprojectItem *spitem;
03000     for ( spitem = list.first(); spitem; spitem = list.next() )
03001     {
03002         QString buildcmd = constructMakeCommandLine(spitem->configuration.m_makefile);
03003         QString dircmd = "cd " + KProcess::quote(spitem->path) + " && " ;
03004         kdDebug(9020) << "builddir " << spitem->path << ", cmd " << dircmd + buildcmd + " " + target << endl;
03005         m_part->queueCmd(spitem->path, dircmd + buildcmd + " " + target);
03006     }
03007 
03008 //    startMakeCommand(buildDir, target);
03009 
03010 }
03011 
03012 
03013 void TrollProjectWidget::slotExecuteProject()
03014 {
03015     QString program = m_part->mainProgram();
03016     if (!program.startsWith("/"))
03017         program.prepend("./");
03018 
03019     if ( program.isEmpty() ) {
03020         KMessageBox::sorry(this, i18n("Please specify the executable name in the "
03021             "project options dialog first."), i18n("No Executable Name Given"));
03022         return;
03023     }
03024 
03025     // Build environment variables to prepend to the executable path
03026     QString runEnvVars = QString::null;
03027     DomUtil::PairList list =
03028         DomUtil::readPairListEntry( *(m_part->projectDom()), "/kdevtrollproject/run/envvars", "envvar", "name", "value" );
03029 
03030     DomUtil::PairList::ConstIterator it;
03031     for (it = list.begin(); it != list.end(); ++it) {
03032         const DomUtil::Pair &pair = (*it);
03033         if ( (!pair.first.isEmpty()) && (!pair.second.isEmpty()) )
03034             runEnvVars += pair.first + "=" + pair.second + " ";
03035     }
03036     program.prepend(runEnvVars);
03037     program.append(" " + DomUtil::readEntry( *(m_part->projectDom()), "/kdevtrollproject/run/programargs" ) + " ");
03038 
03039     QString dircmd = "cd "+KProcess::quote(this->projectDirectory()) + " && " ;
03040 
03041     bool inTerminal = DomUtil::readBoolEntry(*(m_part->projectDom()), "/kdevtrollproject/run/terminal");
03042 //    m_part->appFrontend()->startAppCommand(dircmd + program, inTerminal);
03043 //    m_part->execute(this->projectDirectory(), "./"+program );
03044     m_part->appFrontend()->startAppCommand(this->projectDirectory(), program,inTerminal );
03045 }
03046 
03047 
03048 void TrollProjectWidget::slotCleanProject()
03049 {
03050   QString dir = this->  projectDirectory();
03051   if (!m_rootSubproject)
03052     return;
03053 
03054   createMakefileIfMissing(dir, m_rootSubproject);
03055 
03056   m_part->mainWindow()->raiseView(m_part->makeFrontend()->widget());
03057   QString dircmd = "cd "+KProcess::quote(dir) + " && " ;
03058   QString rebuildcmd = constructMakeCommandLine(m_rootSubproject->configuration.m_makefile) + " clean";
03059   m_part->queueCmd(dir,dircmd + rebuildcmd);
03060 }
03061 
03062 void TrollProjectWidget::slotCleanTarget()
03063 {
03064   // no subproject selected
03065   m_part->partController()->saveAllFiles();
03066   if (!m_shownSubproject)
03067     return;
03068   // can't build from scope
03069   if (m_shownSubproject->isScope)
03070     return;
03071 
03072   QString dir = subprojectDirectory();
03073   createMakefileIfMissing(dir, m_shownSubproject);
03074 
03075   m_part->mainWindow()->raiseView(m_part->makeFrontend()->widget());
03076   QString dircmd = "cd "+KProcess::quote(dir) + " && " ;
03077   QString rebuildcmd = constructMakeCommandLine(m_shownSubproject->configuration.m_makefile) + " clean";
03078   m_part->queueCmd(dir,dircmd + rebuildcmd);
03079 }
03080 
03081 QString TrollProjectWidget::constructMakeCommandLine(const QString makeFileName )
03082 {
03083     QDomDocument &dom = *(m_part->projectDom());
03084 
03085     QString cmdline = DomUtil::readEntry(dom, "/kdevtrollproject/make/makebin");
03086     if (cmdline.isEmpty())
03087         cmdline = MAKE_COMMAND;
03088     if (!makeFileName.isEmpty())
03089     {
03090         cmdline += " -f " + makeFileName;
03091     }
03092     if (!DomUtil::readBoolEntry(dom, "/kdevtrollproject/make/abortonerror"))
03093         cmdline += " -k";
03094     int jobs = DomUtil::readIntEntry(dom, "/kdevtrollproject/make/numberofjobs");
03095     if (jobs != 0) {
03096         cmdline += " -j";
03097         cmdline += QString::number(jobs);
03098     }
03099     if (DomUtil::readBoolEntry(dom, "/kdevtrollproject/make/dontact"))
03100         cmdline += " -n";
03101 
03102     cmdline += " ";
03103     cmdline.prepend(m_part->makeEnvironment());
03104 
03105     return cmdline;
03106 }
03107 /*
03108 QString TrollProjectWidget::makeEnvironment()
03109 {
03110     // Get the make environment variables pairs into the environstr string
03111     // in the form of: "ENV_VARIABLE=ENV_VALUE"
03112     // Note that we quote the variable value due to the possibility of
03113     // embedded spaces
03114     DomUtil::PairList envvars =
03115         DomUtil::readPairListEntry(*(m_part->projectDom()), "/kdevtrollproject/make/envvars", "envvar", "name", "value");
03116 
03117     QString environstr;
03118     DomUtil::PairList::ConstIterator it;
03119     for (it = envvars.begin(); it != envvars.end(); ++it) {
03120         environstr += (*it).first;
03121         environstr += "=";
03122 #if (KDE_VERSION > 305)
03123         environstr += KProcess::quote((*it).second);
03124 #else
03125         environstr += KShellProcess::quote((*it).second);
03126 #endif
03127         environstr += " ";
03128     }
03129     return environstr;
03130 }
03131 */
03132 void TrollProjectWidget::startMakeCommand( const QString & dir, const QString & target )
03133 {
03134     m_part->partController()->saveAllFiles();
03135 
03136 /*    QFileInfo fi;
03137     QFileInfo fi2;
03138     if (m_rootSubproject->configuration.m_makefile.isEmpty())
03139     {
03140         fi.setFile(dir + "/Makefile");
03141         fi2.setFile(dir + "/makefile");
03142     }
03143     else
03144     {
03145         fi.setFile(m_rootSubproject->configuration.m_makefile);
03146         fi2.setFile(dir + "/" + m_rootSubproject->configuration.m_makefile);
03147     }
03148     if (!fi.exists() && !fi2.exists()) {
03149         int r = KMessageBox::questionYesNo(this, i18n("There is no Makefile in this directory. Run qmake first?"));
03150         if (r == KMessageBox::No)
03151             return;
03152         m_part->startQMakeCommand(dir);
03153     }
03154 */
03155     QDomDocument &dom = *(m_part->projectDom());
03156 
03157     if (target=="clean")
03158     {
03159       QString cmdline = DomUtil::readEntry(dom, "/kdevtrollproject/make/makebin");
03160       if (cmdline.isEmpty())
03161           cmdline = MAKE_COMMAND;
03162       cmdline += " clean";
03163       QString dircmd = "cd " + KProcess::quote(dir) + " && ";
03164       cmdline.prepend(m_part->makeEnvironment());
03165       m_part->makeFrontend()->queueCommand(dir, dircmd + cmdline);
03166     }
03167 
03168     QString cmdline = constructMakeCommandLine() + " " + target;
03169 
03170     QString dircmd = "cd " + KProcess::quote(dir) + " && ";
03171 
03172     cmdline.prepend(m_part->makeEnvironment());
03173     m_part->makeFrontend()->queueCommand(dir, dircmd + cmdline);
03174 }
03175 
03176 void TrollProjectWidget::createMakefileIfMissing(const QString &dir, SubqmakeprojectItem *item)
03177 {
03178   QFileInfo fi;
03179   QFileInfo fi2;
03180   if (item->configuration.m_makefile.isEmpty())
03181   {
03182     fi.setFile(dir + "/Makefile");
03183     fi2.setFile(dir + "/makefile");
03184   }
03185   else
03186   {
03187     fi.setFile(item->configuration.m_makefile);
03188     fi2.setFile(dir + "/" + item->configuration.m_makefile);
03189   }
03190   if (!fi.exists() && !fi2.exists()) {
03191       int r = KMessageBox::questionYesNo(this, i18n("There is no Makefile in this directory. Run qmake first?"));
03192       if (r == KMessageBox::No)
03193           return;
03194       m_part->startQMakeCommand(dir);
03195   }
03196 }
03197 
03198 QPtrList<SubqmakeprojectItem> TrollProjectWidget::findSubprojectForFile( QFileInfo fi )
03199 {
03200     QPtrList<SubqmakeprojectItem> list;
03201     findSubprojectForFile(list, m_rootSubproject, fi.absFilePath());
03202     return list;
03203 }
03204 
03205 void TrollProjectWidget::findSubprojectForFile( QPtrList<SubqmakeprojectItem> &list, SubqmakeprojectItem * item, QString absFilePath )
03206 {
03207     QDir d(item->path);
03208     kdDebug(9020) << "searching withing subproject: " << item->path << endl;
03209 
03210     for (QStringList::Iterator it = item->sources.begin(); it != item->sources.end(); ++it )
03211     {
03212         QFileInfo fi2(d, *it);
03213         kdDebug(9020) << "subproject item: key: " << absFilePath << " value:" << fi2.absFilePath() << endl;
03214         if (absFilePath == fi2.absFilePath())
03215             list.append(item);
03216     }
03217 
03218     for (QStringList::Iterator it = item->headers.begin(); it != item->headers.end(); ++it )
03219     {
03220         QFileInfo fi2(d, *it);
03221         kdDebug(9020) << "subproject item: key: " << absFilePath << " value:" << fi2.absFilePath() << endl;
03222         if (absFilePath == fi2.absFilePath())
03223             list.append(item);
03224     }
03225 
03226     QListViewItem * child = item->firstChild();
03227     while( child )
03228     {
03229         SubqmakeprojectItem *spitem = dynamic_cast<SubqmakeprojectItem*>(child);
03230 
03231         if (spitem)
03232         {
03233             kdDebug(9020) << "next subproject item with profile = " << spitem->pro_file << endl;
03234             findSubprojectForFile(list, spitem, absFilePath);
03235         }
03236 
03237         child = child->nextSibling();
03238     }
03239 
03240 /*    QListViewItemIterator it( item );
03241     while ( it.current() )
03242     {
03243         SubqmakeprojectItem *spitem = dynamic_cast<SubqmakeprojectItem*>(it.current());
03244 
03245         if (spitem)
03246         {
03247             kdDebug(9020) << "next subproject item with profile = " << spitem->pro_file << endl;
03248             findSubprojectForFile(list, spitem, absFilePath);
03249         }
03250 
03251         ++it;
03252     }*/
03253 }
03254 
03255 //check or uncheck dependency to currently checked or unchecked library
03256 void InsideCheckListItem::stateChange( bool state )
03257 {
03258     if (listView() == m_config->insidelib_listview)
03259     {
03260         QListViewItemIterator it( m_config->intDeps_view );
03261         while ( it.current() ) {
03262             InsideCheckListItem *chi = dynamic_cast<InsideCheckListItem*>(it.current());
03263             if (chi)
03264                 if ( chi->prjItem == prjItem )
03265                     chi->setOn(state);
03266             ++it;
03267         }
03268     }
03269 }
03270 
03271 void TrollProjectWidget::slotRemoveScope( SubqmakeprojectItem * spitem )
03272 {
03273   if (spitem==0 && m_shownSubproject==0)
03274     return;
03275   else
03276   {
03277     if ( ( spitem = dynamic_cast<SubqmakeprojectItem *>(m_shownSubproject->parent()) ) != NULL  )
03278     {
03279     spitem->m_RootBuffer->removeScope(m_shownSubproject->scopeString, m_shownSubproject->scopeString);
03280     spitem->scopes.remove(m_shownSubproject);
03281     delete m_shownSubproject;
03282     m_shownSubproject = spitem;
03283     updateProjectFile(spitem);
03284     overview->setCurrentItem(m_shownSubproject);
03285     overview->setSelected(m_shownSubproject, true);
03286     }
03287   }
03288 }
03289 
03290 SubqmakeprojectItem * TrollProjectWidget::findSubprojectForScope( SubqmakeprojectItem * scope )
03291 {
03292     if ((scope == 0) || (scope->parent() == 0))
03293         return 0;
03294     if (!scope->isScope)
03295         return scope;
03296     return findSubprojectForScope(dynamic_cast<SubqmakeprojectItem *>(scope->parent()));
03297 }
03298 
03299 void TrollProjectWidget::focusInEvent( QFocusEvent */*e*/ )
03300 {
03301     switch (m_lastFocusedView)
03302     {
03303         case DetailsView:
03304             details->setFocus();
03305             break;
03306         case SubprojectView:
03307         default:
03308             overview->setFocus();
03309     }
03310 }
03311 
03312 void TrollProjectWidget::setLastFocusedView( TrollProjectView view )
03313 {
03314     m_lastFocusedView = view;
03315 }
03316 
03317 
03318 #include "trollprojectwidget.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:41 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003