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