genericproject.cpp 18.1 KB
Newer Older
Roberto Raggi's avatar
Roberto Raggi committed
1 2 3 4
/**************************************************************************
**
** This file is part of Qt Creator
**
con's avatar
con committed
5
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
Roberto Raggi's avatar
Roberto Raggi committed
6
**
hjk's avatar
hjk committed
7
** Contact: Nokia Corporation (info@qt.nokia.com)
Roberto Raggi's avatar
Roberto Raggi committed
8 9 10 11
**
**
** GNU Lesser General Public License Usage
**
hjk's avatar
hjk committed
12 13 14 15 16 17
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
Roberto Raggi's avatar
Roberto Raggi committed
18
**
con's avatar
con committed
19
** In addition, as a special exception, Nokia gives you certain additional
hjk's avatar
hjk committed
20
** rights. These rights are described in the Nokia Qt LGPL Exception
con's avatar
con committed
21 22
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
23 24 25 26 27
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
con's avatar
con committed
28
** If you have questions regarding the use of this file, please contact
Tobias Hunger's avatar
Tobias Hunger committed
29
** Nokia at info@qt.nokia.com.
Roberto Raggi's avatar
Roberto Raggi committed
30 31 32 33
**
**************************************************************************/

#include "genericproject.h"
Tobias Hunger's avatar
Tobias Hunger committed
34

dt's avatar
dt committed
35
#include "genericbuildconfiguration.h"
Tobias Hunger's avatar
Tobias Hunger committed
36 37
#include "genericprojectconstants.h"
#include "generictarget.h"
Roberto Raggi's avatar
Roberto Raggi committed
38

39
#include <projectexplorer/buildenvironmentwidget.h>
40
#include <projectexplorer/headerpath.h>
41
#include <projectexplorer/customexecutablerunconfiguration.h>
42
#include <projectexplorer/toolchainmanager.h>
Roberto Raggi's avatar
Roberto Raggi committed
43
#include <projectexplorer/projectexplorerconstants.h>
44
#include <cplusplus/ModelManagerInterface.h>
Roberto Raggi's avatar
Roberto Raggi committed
45
#include <extensionsystem/pluginmanager.h>
46
#include <utils/pathchooser.h>
hjk's avatar
hjk committed
47
#include <utils/qtcassert.h>
48
#include <utils/fileutils.h>
Roberto Raggi's avatar
Roberto Raggi committed
49
#include <coreplugin/icore.h>
50
#include <coreplugin/icontext.h>
Roberto Raggi's avatar
Roberto Raggi committed
51

52
#include <QtCore/QDir>
53
#include <QtCore/QProcessEnvironment>
Roberto Raggi's avatar
Roberto Raggi committed
54

55 56 57
#include <QtGui/QFormLayout>
#include <QtGui/QMainWindow>
#include <QtGui/QComboBox>
Roberto Raggi's avatar
Roberto Raggi committed
58 59 60

using namespace GenericProjectManager;
using namespace GenericProjectManager::Internal;
61
using namespace ProjectExplorer;
Roberto Raggi's avatar
Roberto Raggi committed
62

63
namespace {
64
const char * const TOOLCHAIN_KEY("GenericProjectManager.GenericProject.Toolchain");
65 66
} // end of anonymous namespace

67 68 69 70
////////////////////////////////////////////////////////////////////////////////////
// GenericProject
////////////////////////////////////////////////////////////////////////////////////

Roberto Raggi's avatar
Roberto Raggi committed
71
GenericProject::GenericProject(Manager *manager, const QString &fileName)
72 73 74
    : m_manager(manager),
      m_fileName(fileName),
      m_toolChain(0)
Roberto Raggi's avatar
Roberto Raggi committed
75
{
76 77 78
    setProjectContext(Core::Context(GenericProjectManager::Constants::PROJECTCONTEXT));
    setProjectLanguage(Core::Context(ProjectExplorer::Constants::LANG_CXX));

79
    QFileInfo fileInfo(m_fileName);
80 81
    QDir dir = fileInfo.dir();

82
    m_projectName      = fileInfo.completeBaseName();
83 84 85
    m_filesFileName    = QFileInfo(dir, m_projectName + QLatin1String(".files")).absoluteFilePath();
    m_includesFileName = QFileInfo(dir, m_projectName + QLatin1String(".includes")).absoluteFilePath();
    m_configFileName   = QFileInfo(dir, m_projectName + QLatin1String(".config")).absoluteFilePath();
86

87 88
    m_file = new GenericProjectFile(this, fileName);
    m_rootNode = new GenericProjectNode(this, m_file);
89

90
    m_manager->registerProject(this);
Roberto Raggi's avatar
Roberto Raggi committed
91 92 93 94
}

GenericProject::~GenericProject()
{
95
    m_codeModelFuture.cancel();
96
    m_manager->unregisterProject(this);
97

98
    delete m_rootNode;
99
    // do not delete m_toolChain
Roberto Raggi's avatar
Roberto Raggi committed
100 101
}

Tobias Hunger's avatar
Tobias Hunger committed
102
GenericTarget *GenericProject::activeTarget() const
103
{
Tobias Hunger's avatar
Tobias Hunger committed
104
    return static_cast<GenericTarget *>(Project::activeTarget());
105 106
}

107
QString GenericProject::filesFileName() const
hjk's avatar
hjk committed
108 109 110
{
    return m_filesFileName;
}
111 112

QString GenericProject::includesFileName() const
hjk's avatar
hjk committed
113 114 115
{
    return m_includesFileName;
}
116 117

QString GenericProject::configFileName() const
hjk's avatar
hjk committed
118 119 120
{
    return m_configFileName;
}
121

122
static QStringList readLines(const QString &absoluteFileName)
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
{
    QStringList lines;

    QFile file(absoluteFileName);
    if (file.open(QFile::ReadOnly)) {
        QTextStream stream(&file);

        forever {
            QString line = stream.readLine();
            if (line.isNull())
                break;

            lines.append(line);
        }
    }

    return lines;
}

142
bool GenericProject::saveRawFileList(const QStringList &rawFileList)
143
{
144
    // Make sure we can open the file for writing
145 146 147 148 149 150 151 152
    Utils::FileSaver saver(filesFileName(), QIODevice::Text);
    if (!saver.hasError()) {
        QTextStream stream(saver.file());
        foreach (const QString &filePath, rawFileList)
            stream << filePath << QLatin1Char('\n');
        saver.setResult(&stream);
    }
    if (!saver.finalize(Core::ICore::instance()->mainWindow()))
153 154 155
        return false;
    refresh(GenericProject::Files);
    return true;
156
}
157

158 159
bool GenericProject::addFiles(const QStringList &filePaths)
{
160 161 162 163 164
    QStringList newList = m_rawFileList;

    QDir baseDir(QFileInfo(m_fileName).dir());
    foreach (const QString &filePath, filePaths)
        newList.append(baseDir.relativeFilePath(filePath));
165

166
    return saveRawFileList(newList);
167 168 169 170
}

bool GenericProject::removeFiles(const QStringList &filePaths)
{
171
    QStringList newList = m_rawFileList;
172

173 174 175 176
    foreach (const QString &filePath, filePaths) {
        QHash<QString, QString>::iterator i = m_rawListEntries.find(filePath);
        if (i != m_rawListEntries.end())
            newList.removeOne(i.value());
177
    }
178

179
    return saveRawFileList(newList);
180 181
}

182
void GenericProject::parseProject(RefreshOptions options)
Roberto Raggi's avatar
Roberto Raggi committed
183
{
184 185 186
    if (options & Files) {
        m_rawListEntries.clear();
        m_rawFileList = readLines(filesFileName());
187
        m_files = processEntries(m_rawFileList, &m_rawListEntries);
188
    }
189

190
    if (options & Configuration) {
191
        m_projectIncludePaths = processEntries(readLines(includesFileName()));
192

193 194
        // TODO: Possibly load some configuration from the project file
        //QSettings projectInfo(m_fileName, QSettings::IniFormat);
Roberto Raggi's avatar
Roberto Raggi committed
195

196
        m_defines.clear();
Roberto Raggi's avatar
Roberto Raggi committed
197

198 199 200 201
        QFile configFile(configFileName());
        if (configFile.open(QFile::ReadOnly))
            m_defines = configFile.readAll();
    }
202

203 204
    if (options & Files)
        emit fileListChanged();
Roberto Raggi's avatar
Roberto Raggi committed
205 206
}

207
void GenericProject::refresh(RefreshOptions options)
Roberto Raggi's avatar
Roberto Raggi committed
208
{
209 210 211
    QSet<QString> oldFileList;
    if (!(options & Configuration))
        oldFileList = m_files.toSet();
212

213 214 215 216
    parseProject(options);

    if (options & Files)
        m_rootNode->refresh();
Roberto Raggi's avatar
Roberto Raggi committed
217

218
    CPlusPlus::CppModelManagerInterface *modelManager =
219
        CPlusPlus::CppModelManagerInterface::instance();
Roberto Raggi's avatar
Roberto Raggi committed
220

221
    if (modelManager) {
222
        CPlusPlus::CppModelManagerInterface::ProjectInfo pinfo = modelManager->projectInfo(this);
Roberto Raggi's avatar
Roberto Raggi committed
223

224 225 226
        if (m_toolChain) {
            pinfo.defines = m_toolChain->predefinedMacros();
            pinfo.defines += '\n';
Roberto Raggi's avatar
Roberto Raggi committed
227

228 229 230 231 232 233
            foreach (const HeaderPath &headerPath, m_toolChain->systemHeaderPaths()) {
                if (headerPath.kind() == HeaderPath::FrameworkHeaderPath)
                    pinfo.frameworkPaths.append(headerPath.path());
                else
                    pinfo.includePaths.append(headerPath.path());
            }
Roberto Raggi's avatar
Roberto Raggi committed
234 235
        }

236 237
        pinfo.includePaths += allIncludePaths();
        pinfo.defines += m_defines;
Roberto Raggi's avatar
Roberto Raggi committed
238 239

        // ### add _defines.
Roberto Raggi's avatar
Roberto Raggi committed
240 241
        pinfo.sourceFiles = files();
        pinfo.sourceFiles += generated();
Roberto Raggi's avatar
Roberto Raggi committed
242

243 244 245 246 247
        QStringList filesToUpdate;

        if (options & Configuration) {
            filesToUpdate = pinfo.sourceFiles;
            filesToUpdate.append(QLatin1String("<configuration>")); // XXX don't hardcode configuration file name
248 249
            // Full update, if there's a code model update, cancel it
            m_codeModelFuture.cancel();
250 251 252 253 254 255
        } else if (options & Files) {
            // Only update files that got added to the list
            QSet<QString> newFileList = m_files.toSet();
            newFileList.subtract(oldFileList);
            filesToUpdate.append(newFileList.toList());
        }
256

Roberto Raggi's avatar
Roberto Raggi committed
257
        modelManager->updateProjectInfo(pinfo);
258
        m_codeModelFuture = modelManager->updateSourceFiles(filesToUpdate);
Roberto Raggi's avatar
Roberto Raggi committed
259 260 261
    }
}

262
/**
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284
 * Expands environment variables in the given \a string when they are written
 * like $$(VARIABLE).
 */
static void expandEnvironmentVariables(const QProcessEnvironment &env, QString &string)
{
    const static QRegExp candidate(QLatin1String("\\$\\$\\((.+)\\)"));

    int index = candidate.indexIn(string);
    while (index != -1) {
        const QString value = env.value(candidate.cap(1));

        string.replace(index, candidate.matchedLength(), value);
        index += value.length();

        index = candidate.indexIn(string, index);
    }
}

/**
 * Expands environment variables and converts the path from relative to the
 * project to an absolute path.
 *
285
 * The \a map variable is an optional argument that will map the returned
286
 * absolute paths back to their original \a entries.
287
 */
288 289
QStringList GenericProject::processEntries(const QStringList &paths,
                                           QHash<QString, QString> *map) const
Roberto Raggi's avatar
Roberto Raggi committed
290
{
291
    const QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
292
    const QDir projectDir(QFileInfo(m_fileName).dir());
293

Roberto Raggi's avatar
Roberto Raggi committed
294
    QStringList absolutePaths;
295
    foreach (const QString &path, paths) {
296 297
        QString trimmedPath = path.trimmed();
        if (trimmedPath.isEmpty())
298 299
            continue;

300 301 302
        expandEnvironmentVariables(env, trimmedPath);

        const QString absPath = QFileInfo(projectDir, trimmedPath).absoluteFilePath();
303 304
        absolutePaths.append(absPath);
        if (map)
305
            map->insert(absPath, trimmedPath);
Roberto Raggi's avatar
Roberto Raggi committed
306 307 308 309 310
    }
    absolutePaths.removeDuplicates();
    return absolutePaths;
}

Roberto Raggi's avatar
Roberto Raggi committed
311 312 313
QStringList GenericProject::allIncludePaths() const
{
    QStringList paths;
314 315
    paths += m_includePaths;
    paths += m_projectIncludePaths;
Roberto Raggi's avatar
Roberto Raggi committed
316 317 318 319 320
    paths.removeDuplicates();
    return paths;
}

QStringList GenericProject::projectIncludePaths() const
hjk's avatar
hjk committed
321 322 323
{
    return m_projectIncludePaths;
}
Roberto Raggi's avatar
Roberto Raggi committed
324

Roberto Raggi's avatar
Roberto Raggi committed
325
QStringList GenericProject::files() const
hjk's avatar
hjk committed
326 327 328
{
    return m_files;
}
Roberto Raggi's avatar
Roberto Raggi committed
329 330

QStringList GenericProject::generated() const
hjk's avatar
hjk committed
331 332 333
{
    return m_generated;
}
Roberto Raggi's avatar
Roberto Raggi committed
334 335

QStringList GenericProject::includePaths() const
hjk's avatar
hjk committed
336 337 338
{
    return m_includePaths;
}
Roberto Raggi's avatar
Roberto Raggi committed
339 340

void GenericProject::setIncludePaths(const QStringList &includePaths)
hjk's avatar
hjk committed
341 342 343
{
    m_includePaths = includePaths;
}
Roberto Raggi's avatar
Roberto Raggi committed
344

Roberto Raggi's avatar
Roberto Raggi committed
345
QByteArray GenericProject::defines() const
hjk's avatar
hjk committed
346 347 348
{
    return m_defines;
}
Roberto Raggi's avatar
Roberto Raggi committed
349

350
void GenericProject::setToolChain(ToolChain *tc)
Roberto Raggi's avatar
Roberto Raggi committed
351
{
352 353
    if (m_toolChain == tc)
        return;
Roberto Raggi's avatar
Roberto Raggi committed
354

355
    m_toolChain = tc;
356 357
    refresh(Configuration);

358
    emit toolChainChanged(m_toolChain);
Roberto Raggi's avatar
Roberto Raggi committed
359 360
}

361
ToolChain *GenericProject::toolChain() const
362 363 364 365
{
    return m_toolChain;
}

366
QString GenericProject::displayName() const
Roberto Raggi's avatar
Roberto Raggi committed
367
{
368
    return m_projectName;
Roberto Raggi's avatar
Roberto Raggi committed
369 370
}

Tobias Hunger's avatar
Tobias Hunger committed
371 372
QString GenericProject::id() const
{
Tobias Hunger's avatar
Tobias Hunger committed
373
    return QLatin1String(Constants::GENERICPROJECT_ID);
Tobias Hunger's avatar
Tobias Hunger committed
374 375
}

Roberto Raggi's avatar
Roberto Raggi committed
376 377
Core::IFile *GenericProject::file() const
{
378
    return m_file;
Roberto Raggi's avatar
Roberto Raggi committed
379 380
}

381
IProjectManager *GenericProject::projectManager() const
Roberto Raggi's avatar
Roberto Raggi committed
382
{
383
    return m_manager;
Roberto Raggi's avatar
Roberto Raggi committed
384 385
}

386
QList<Project *> GenericProject::dependsOn()
Roberto Raggi's avatar
Roberto Raggi committed
387 388 389 390
{
    return QList<Project *>();
}

391
QList<BuildConfigWidget*> GenericProject::subConfigWidgets()
Roberto Raggi's avatar
Roberto Raggi committed
392
{
393
    QList<BuildConfigWidget*> list;
394 395
    list << new BuildEnvironmentWidget;
    return list;
Roberto Raggi's avatar
Roberto Raggi committed
396 397
}

398
GenericProjectNode *GenericProject::rootProjectNode() const
Roberto Raggi's avatar
Roberto Raggi committed
399
{
400
    return m_rootNode;
Roberto Raggi's avatar
Roberto Raggi committed
401 402 403 404
}

QStringList GenericProject::files(FilesMode fileMode) const
{
405
    Q_UNUSED(fileMode)
406
    return m_files; // ### TODO: handle generated files here.
Roberto Raggi's avatar
Roberto Raggi committed
407 408
}

Tobias Hunger's avatar
Tobias Hunger committed
409
QStringList GenericProject::buildTargets() const
Roberto Raggi's avatar
Roberto Raggi committed
410 411 412 413 414 415 416
{
    QStringList targets;
    targets.append(QLatin1String("all"));
    targets.append(QLatin1String("clean"));
    return targets;
}

417
QVariantMap GenericProject::toMap() const
Roberto Raggi's avatar
Roberto Raggi committed
418
{
419
    QVariantMap map(Project::toMap());
420
    map.insert(QLatin1String(TOOLCHAIN_KEY), m_toolChain ? m_toolChain->id() : QString());
421 422 423 424 425 426 427
    return map;
}

bool GenericProject::fromMap(const QVariantMap &map)
{
    if (!Project::fromMap(map))
        return false;
Roberto Raggi's avatar
Roberto Raggi committed
428

429 430 431 432 433 434 435 436 437
    // Sanity check: We need both a buildconfiguration and a runconfiguration!
    QList<Target *> targetList = targets();
    foreach (Target *t, targetList) {
        if (!t->activeBuildConfiguration()) {
            removeTarget(t);
            delete t;
            continue;
        }
        if (!t->activeRunConfiguration())
438
            t->addRunConfiguration(new CustomExecutableRunConfiguration(t));
439 440 441
    }

    // Add default setup:
442 443 444 445 446
    if (targets().isEmpty()) {
        GenericTargetFactory *factory =
                ExtensionSystem::PluginManager::instance()->getObject<GenericTargetFactory>();
        addTarget(factory->create(this, QLatin1String(GENERIC_DESKTOP_TARGET_ID)));
    }
447

448
    QString id = map.value(QLatin1String(TOOLCHAIN_KEY)).toString();
449 450
    const ToolChainManager *toolChainManager = ToolChainManager::instance();

451
    if (!id.isNull()) {
452
        setToolChain(toolChainManager->findToolChain(id));
453
    } else {
454 455 456 457
        ProjectExplorer::Abi abi = ProjectExplorer::Abi::hostAbi();
        abi = ProjectExplorer::Abi(abi.architecture(), abi.os(),  ProjectExplorer::Abi::UnknownFlavor,
                                   abi.binaryFormat(), abi.wordWidth() == 32 ? 32 : 0);
        QList<ToolChain *> tcs = toolChainManager->findToolChains(abi);
458
        if (tcs.isEmpty())
459
            tcs = toolChainManager->toolChains();
460 461 462
        if (!tcs.isEmpty())
            setToolChain(tcs.at(0));
    }
Roberto Raggi's avatar
Roberto Raggi committed
463 464

    setIncludePaths(allIncludePaths());
465

466
    refresh(Everything);
dt's avatar
dt committed
467
    return true;
468 469
}

Roberto Raggi's avatar
Roberto Raggi committed
470 471 472
////////////////////////////////////////////////////////////////////////////////////
// GenericBuildSettingsWidget
////////////////////////////////////////////////////////////////////////////////////
473

474
GenericBuildSettingsWidget::GenericBuildSettingsWidget(GenericTarget *target)
475
    : m_target(target), m_toolChainChooser(0), m_buildConfiguration(0)
Roberto Raggi's avatar
Roberto Raggi committed
476 477
{
    QFormLayout *fl = new QFormLayout(this);
478 479
    fl->setContentsMargins(0, -1, 0, -1);
    fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
480 481

    // build directory
482
    m_pathChooser = new Utils::PathChooser(this);
483
    m_pathChooser->setEnabled(true);
484
    m_pathChooser->setBaseDirectory(m_target->genericProject()->projectDirectory());
485
    fl->addRow(tr("Build directory:"), m_pathChooser);
con's avatar
con committed
486
    connect(m_pathChooser, SIGNAL(changed(QString)), this, SLOT(buildDirectoryChanged()));
487

488
    // tool chain
489 490 491 492 493 494 495 496
    m_toolChainChooser = new QComboBox;
    m_toolChainChooser->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    updateToolChainList();

    fl->addRow(tr("Tool chain:"), m_toolChainChooser);
    connect(m_toolChainChooser, SIGNAL(activated(int)), this, SLOT(toolChainSelected(int)));
    connect(m_target->genericProject(), SIGNAL(toolChainChanged(ProjectExplorer::ToolChain*)),
            this, SLOT(toolChainChanged(ProjectExplorer::ToolChain*)));
497
    connect(ProjectExplorer::ToolChainManager::instance(), SIGNAL(toolChainAdded(ProjectExplorer::ToolChain*)),
498
            this, SLOT(updateToolChainList()));
499
    connect(ProjectExplorer::ToolChainManager::instance(), SIGNAL(toolChainRemoved(ProjectExplorer::ToolChain*)),
500
            this, SLOT(updateToolChainList()));
Roberto Raggi's avatar
Roberto Raggi committed
501 502 503 504 505 506 507 508
}

GenericBuildSettingsWidget::~GenericBuildSettingsWidget()
{ }

QString GenericBuildSettingsWidget::displayName() const
{ return tr("Generic Manager"); }

dt's avatar
dt committed
509
void GenericBuildSettingsWidget::init(BuildConfiguration *bc)
Roberto Raggi's avatar
Roberto Raggi committed
510
{
511
    m_buildConfiguration = static_cast<GenericBuildConfiguration *>(bc);
512
    m_pathChooser->setPath(m_buildConfiguration->rawBuildDirectory());
Roberto Raggi's avatar
Roberto Raggi committed
513 514 515 516
}

void GenericBuildSettingsWidget::buildDirectoryChanged()
{
517
    m_buildConfiguration->setBuildDirectory(m_pathChooser->rawPath());
Roberto Raggi's avatar
Roberto Raggi committed
518 519
}

520 521 522 523
void GenericBuildSettingsWidget::toolChainSelected(int index)
{
    using namespace ProjectExplorer;

524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544
    ToolChain *tc = static_cast<ToolChain *>(m_toolChainChooser->itemData(index).value<void *>());
    m_target->genericProject()->setToolChain(tc);
}

void GenericBuildSettingsWidget::toolChainChanged(ProjectExplorer::ToolChain *tc)
{
    for (int i = 0; i < m_toolChainChooser->count(); ++i) {
        ToolChain * currentTc = static_cast<ToolChain *>(m_toolChainChooser->itemData(i).value<void *>());
        if (currentTc != tc)
            continue;
        m_toolChainChooser->setCurrentIndex(i);
        return;
    }
}

void GenericBuildSettingsWidget::updateToolChainList()
{
    m_toolChainChooser->clear();

    QList<ToolChain *> tcs = ToolChainManager::instance()->toolChains();
    if (!m_target->genericProject()->toolChain()) {
545
        m_toolChainChooser->addItem(tr("<Invalid tool chain>"), qVariantFromValue(static_cast<void *>(0)));
546 547 548 549 550 551 552 553
        m_toolChainChooser->setCurrentIndex(0);
    }
    foreach (ToolChain *tc, tcs) {
        m_toolChainChooser->addItem(tc->displayName(), qVariantFromValue(static_cast<void *>(tc)));
        if (m_target->genericProject()->toolChain()
                && m_target->genericProject()->toolChain()->id() == tc->id())
            m_toolChainChooser->setCurrentIndex(m_toolChainChooser->count() - 1);
    }
554 555
}

Roberto Raggi's avatar
Roberto Raggi committed
556 557 558
////////////////////////////////////////////////////////////////////////////////////
// GenericProjectFile
////////////////////////////////////////////////////////////////////////////////////
559

Roberto Raggi's avatar
Roberto Raggi committed
560 561
GenericProjectFile::GenericProjectFile(GenericProject *parent, QString fileName)
    : Core::IFile(parent),
562 563
      m_project(parent),
      m_fileName(fileName)
Roberto Raggi's avatar
Roberto Raggi committed
564 565 566 567 568
{ }

GenericProjectFile::~GenericProjectFile()
{ }

569
bool GenericProjectFile::save(QString *, const QString &)
Roberto Raggi's avatar
Roberto Raggi committed
570 571 572 573 574 575
{
    return false;
}

QString GenericProjectFile::fileName() const
{
576
    return m_fileName;
Roberto Raggi's avatar
Roberto Raggi committed
577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608
}

QString GenericProjectFile::defaultPath() const
{
    return QString();
}

QString GenericProjectFile::suggestedFileName() const
{
    return QString();
}

QString GenericProjectFile::mimeType() const
{
    return Constants::GENERICMIMETYPE;
}

bool GenericProjectFile::isModified() const
{
    return false;
}

bool GenericProjectFile::isReadOnly() const
{
    return true;
}

bool GenericProjectFile::isSaveAsAllowed() const
{
    return false;
}

dt's avatar
dt committed
609 610 611 612
void GenericProjectFile::rename(const QString &newName)
{
    // Can't happen
    Q_UNUSED(newName);
hjk's avatar
hjk committed
613
    QTC_ASSERT(false, /**/);
dt's avatar
dt committed
614 615
}

616
Core::IFile::ReloadBehavior GenericProjectFile::reloadBehavior(ChangeTrigger state, ChangeType type) const
Roberto Raggi's avatar
Roberto Raggi committed
617
{
618 619 620 621 622
    Q_UNUSED(state)
    Q_UNUSED(type)
    return BehaviorSilent;
}

623
bool GenericProjectFile::reload(QString *errorString, ReloadFlag flag, ChangeType type)
624
{
625
    Q_UNUSED(errorString)
626 627
    Q_UNUSED(flag)
    Q_UNUSED(type)
628
    return true;
Roberto Raggi's avatar
Roberto Raggi committed
629
}