genericproject.cpp 17.5 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
**
7
** Contact: Nokia Corporation (qt-info@nokia.com)
Roberto Raggi's avatar
Roberto Raggi committed
8
**
con's avatar
con committed
9
** No Commercial Usage
Roberto Raggi's avatar
Roberto Raggi committed
10
**
con's avatar
con committed
11 12 13 14
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
Roberto Raggi's avatar
Roberto Raggi committed
15 16 17 18 19 20 21 22 23 24
**
** GNU Lesser General Public License Usage
**
** Alternatively, 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.
**
con's avatar
con committed
25 26 27 28 29 30
** In addition, as a special exception, Nokia gives you certain additional
** rights.  These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
Roberto Raggi's avatar
Roberto Raggi committed
31 32 33 34
**
**************************************************************************/

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

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

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

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

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

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

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

66 67 68 69
////////////////////////////////////////////////////////////////////////////////////
// GenericProject
////////////////////////////////////////////////////////////////////////////////////

Roberto Raggi's avatar
Roberto Raggi committed
70
GenericProject::GenericProject(Manager *manager, const QString &fileName)
71 72 73
    : m_manager(manager),
      m_fileName(fileName),
      m_toolChain(0)
Roberto Raggi's avatar
Roberto Raggi committed
74
{
75
    QFileInfo fileInfo(m_fileName);
76 77
    QDir dir = fileInfo.dir();

78
    m_projectName      = fileInfo.completeBaseName();
79 80 81
    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();
82

83 84
    m_file = new GenericProjectFile(this, fileName);
    m_rootNode = new GenericProjectNode(this, m_file);
85

86
    m_manager->registerProject(this);
Roberto Raggi's avatar
Roberto Raggi committed
87 88 89 90
}

GenericProject::~GenericProject()
{
91
    m_codeModelFuture.cancel();
92
    m_manager->unregisterProject(this);
93

94
    delete m_rootNode;
95
    // do not delete m_toolChain
Roberto Raggi's avatar
Roberto Raggi committed
96 97
}

Tobias Hunger's avatar
Tobias Hunger committed
98
GenericTarget *GenericProject::activeTarget() const
99
{
Tobias Hunger's avatar
Tobias Hunger committed
100
    return static_cast<GenericTarget *>(Project::activeTarget());
101 102
}

103
QString GenericProject::filesFileName() const
hjk's avatar
hjk committed
104 105 106
{
    return m_filesFileName;
}
107 108

QString GenericProject::includesFileName() const
hjk's avatar
hjk committed
109 110 111
{
    return m_includesFileName;
}
112 113

QString GenericProject::configFileName() const
hjk's avatar
hjk committed
114 115 116
{
    return m_configFileName;
}
117

118
static QStringList readLines(const QString &absoluteFileName)
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
{
    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;
}

138
bool GenericProject::saveRawFileList(const QStringList &rawFileList)
139
{
140
    // Make sure we can open the file for writing
141
    QFile file(filesFileName());
142 143 144 145
    if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
        return false;

    QTextStream stream(&file);
146 147
    foreach (const QString &filePath, rawFileList)
        stream << filePath << QLatin1Char('\n');
148 149 150 151

    file.close();
    refresh(GenericProject::Files);
    return true;
152
}
153

154 155
bool GenericProject::addFiles(const QStringList &filePaths)
{
156 157 158 159 160
    QStringList newList = m_rawFileList;

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

162
    return saveRawFileList(newList);
163 164 165 166
}

bool GenericProject::removeFiles(const QStringList &filePaths)
{
167
    QStringList newList = m_rawFileList;
168

169 170 171 172
    foreach (const QString &filePath, filePaths) {
        QHash<QString, QString>::iterator i = m_rawListEntries.find(filePath);
        if (i != m_rawListEntries.end())
            newList.removeOne(i.value());
173
    }
174

175
    return saveRawFileList(newList);
176 177
}

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

186
    if (options & Configuration) {
187
        m_projectIncludePaths = processEntries(readLines(includesFileName()));
188

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

192
        m_defines.clear();
Roberto Raggi's avatar
Roberto Raggi committed
193

194 195 196 197
        QFile configFile(configFileName());
        if (configFile.open(QFile::ReadOnly))
            m_defines = configFile.readAll();
    }
198

199 200
    if (options & Files)
        emit fileListChanged();
Roberto Raggi's avatar
Roberto Raggi committed
201 202
}

203
void GenericProject::refresh(RefreshOptions options)
Roberto Raggi's avatar
Roberto Raggi committed
204
{
205 206 207
    QSet<QString> oldFileList;
    if (!(options & Configuration))
        oldFileList = m_files.toSet();
208

209 210 211 212
    parseProject(options);

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

214
    CPlusPlus::CppModelManagerInterface *modelManager =
215
        CPlusPlus::CppModelManagerInterface::instance();
Roberto Raggi's avatar
Roberto Raggi committed
216

217
    if (modelManager) {
218
        CPlusPlus::CppModelManagerInterface::ProjectInfo pinfo = modelManager->projectInfo(this);
Roberto Raggi's avatar
Roberto Raggi committed
219

220 221 222
        if (m_toolChain) {
            pinfo.defines = m_toolChain->predefinedMacros();
            pinfo.defines += '\n';
Roberto Raggi's avatar
Roberto Raggi committed
223

224 225 226 227 228 229
            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
230 231
        }

232 233
        pinfo.includePaths += allIncludePaths();
        pinfo.defines += m_defines;
Roberto Raggi's avatar
Roberto Raggi committed
234 235

        // ### add _defines.
Roberto Raggi's avatar
Roberto Raggi committed
236 237
        pinfo.sourceFiles = files();
        pinfo.sourceFiles += generated();
Roberto Raggi's avatar
Roberto Raggi committed
238

239 240 241 242 243
        QStringList filesToUpdate;

        if (options & Configuration) {
            filesToUpdate = pinfo.sourceFiles;
            filesToUpdate.append(QLatin1String("<configuration>")); // XXX don't hardcode configuration file name
244 245
            // Full update, if there's a code model update, cancel it
            m_codeModelFuture.cancel();
246 247 248 249 250 251
        } 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());
        }
252

Roberto Raggi's avatar
Roberto Raggi committed
253
        modelManager->updateProjectInfo(pinfo);
254
        m_codeModelFuture = modelManager->updateSourceFiles(filesToUpdate);
Roberto Raggi's avatar
Roberto Raggi committed
255 256 257
    }
}

258
/**
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280
 * 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.
 *
281
 * The \a map variable is an optional argument that will map the returned
282
 * absolute paths back to their original \a entries.
283
 */
284 285
QStringList GenericProject::processEntries(const QStringList &paths,
                                           QHash<QString, QString> *map) const
Roberto Raggi's avatar
Roberto Raggi committed
286
{
287
    const QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
288
    const QDir projectDir(QFileInfo(m_fileName).dir());
289

Roberto Raggi's avatar
Roberto Raggi committed
290
    QStringList absolutePaths;
291
    foreach (const QString &path, paths) {
292 293
        QString trimmedPath = path.trimmed();
        if (trimmedPath.isEmpty())
294 295
            continue;

296 297 298
        expandEnvironmentVariables(env, trimmedPath);

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

Roberto Raggi's avatar
Roberto Raggi committed
307 308 309
QStringList GenericProject::allIncludePaths() const
{
    QStringList paths;
310 311
    paths += m_includePaths;
    paths += m_projectIncludePaths;
Roberto Raggi's avatar
Roberto Raggi committed
312 313 314 315 316
    paths.removeDuplicates();
    return paths;
}

QStringList GenericProject::projectIncludePaths() const
hjk's avatar
hjk committed
317 318 319
{
    return m_projectIncludePaths;
}
Roberto Raggi's avatar
Roberto Raggi committed
320

Roberto Raggi's avatar
Roberto Raggi committed
321
QStringList GenericProject::files() const
hjk's avatar
hjk committed
322 323 324
{
    return m_files;
}
Roberto Raggi's avatar
Roberto Raggi committed
325 326

QStringList GenericProject::generated() const
hjk's avatar
hjk committed
327 328 329
{
    return m_generated;
}
Roberto Raggi's avatar
Roberto Raggi committed
330 331

QStringList GenericProject::includePaths() const
hjk's avatar
hjk committed
332 333 334
{
    return m_includePaths;
}
Roberto Raggi's avatar
Roberto Raggi committed
335 336

void GenericProject::setIncludePaths(const QStringList &includePaths)
hjk's avatar
hjk committed
337 338 339
{
    m_includePaths = includePaths;
}
Roberto Raggi's avatar
Roberto Raggi committed
340

Roberto Raggi's avatar
Roberto Raggi committed
341
QByteArray GenericProject::defines() const
hjk's avatar
hjk committed
342 343 344
{
    return m_defines;
}
Roberto Raggi's avatar
Roberto Raggi committed
345

346
void GenericProject::setToolChain(ToolChain *tc)
Roberto Raggi's avatar
Roberto Raggi committed
347
{
348 349
    if (m_toolChain == tc)
        return;
Roberto Raggi's avatar
Roberto Raggi committed
350

351
    m_toolChain = tc;
352 353
    refresh(Configuration);

354
    emit toolChainChanged(m_toolChain);
Roberto Raggi's avatar
Roberto Raggi committed
355 356
}

357
ToolChain *GenericProject::toolChain() const
358 359 360 361
{
    return m_toolChain;
}

362
QString GenericProject::displayName() const
Roberto Raggi's avatar
Roberto Raggi committed
363
{
364
    return m_projectName;
Roberto Raggi's avatar
Roberto Raggi committed
365 366
}

Tobias Hunger's avatar
Tobias Hunger committed
367 368
QString GenericProject::id() const
{
Tobias Hunger's avatar
Tobias Hunger committed
369
    return QLatin1String(Constants::GENERICPROJECT_ID);
Tobias Hunger's avatar
Tobias Hunger committed
370 371
}

Roberto Raggi's avatar
Roberto Raggi committed
372 373
Core::IFile *GenericProject::file() const
{
374
    return m_file;
Roberto Raggi's avatar
Roberto Raggi committed
375 376
}

377
IProjectManager *GenericProject::projectManager() const
Roberto Raggi's avatar
Roberto Raggi committed
378
{
379
    return m_manager;
Roberto Raggi's avatar
Roberto Raggi committed
380 381
}

382
QList<Project *> GenericProject::dependsOn()
Roberto Raggi's avatar
Roberto Raggi committed
383 384 385 386
{
    return QList<Project *>();
}

387
QList<BuildConfigWidget*> GenericProject::subConfigWidgets()
Roberto Raggi's avatar
Roberto Raggi committed
388
{
389
    QList<BuildConfigWidget*> list;
390 391
    list << new BuildEnvironmentWidget;
    return list;
Roberto Raggi's avatar
Roberto Raggi committed
392 393
}

394
GenericProjectNode *GenericProject::rootProjectNode() const
Roberto Raggi's avatar
Roberto Raggi committed
395
{
396
    return m_rootNode;
Roberto Raggi's avatar
Roberto Raggi committed
397 398 399 400
}

QStringList GenericProject::files(FilesMode fileMode) const
{
401
    Q_UNUSED(fileMode)
402
    return m_files; // ### TODO: handle generated files here.
Roberto Raggi's avatar
Roberto Raggi committed
403 404
}

Tobias Hunger's avatar
Tobias Hunger committed
405
QStringList GenericProject::buildTargets() const
Roberto Raggi's avatar
Roberto Raggi committed
406 407 408 409 410 411 412
{
    QStringList targets;
    targets.append(QLatin1String("all"));
    targets.append(QLatin1String("clean"));
    return targets;
}

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

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

425 426 427 428 429 430 431 432 433
    // 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())
434
            t->addRunConfiguration(new CustomExecutableRunConfiguration(t));
435 436 437
    }

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

444
    QString id = map.value(QLatin1String(TOOLCHAIN_KEY)).toString();
445 446
    const ToolChainManager *toolChainManager = ToolChainManager::instance();

447
    if (!id.isNull()) {
448
        setToolChain(toolChainManager->findToolChain(id));
449
    } else {
450
        QList<ToolChain *> tcs = toolChainManager->findToolChains(Abi::hostAbi());
451
        if (tcs.isEmpty())
452
            tcs = toolChainManager->toolChains();
453 454 455
        if (!tcs.isEmpty())
            setToolChain(tcs.at(0));
    }
Roberto Raggi's avatar
Roberto Raggi committed
456 457

    setIncludePaths(allIncludePaths());
458

459
    refresh(Everything);
dt's avatar
dt committed
460
    return true;
461 462
}

Roberto Raggi's avatar
Roberto Raggi committed
463 464 465
////////////////////////////////////////////////////////////////////////////////////
// GenericBuildSettingsWidget
////////////////////////////////////////////////////////////////////////////////////
466

467
GenericBuildSettingsWidget::GenericBuildSettingsWidget(GenericTarget *target)
468
    : m_target(target), m_toolChainChooser(0), m_buildConfiguration(0)
Roberto Raggi's avatar
Roberto Raggi committed
469 470
{
    QFormLayout *fl = new QFormLayout(this);
471 472
    fl->setContentsMargins(0, -1, 0, -1);
    fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
473 474

    // build directory
475
    m_pathChooser = new Utils::PathChooser(this);
476
    m_pathChooser->setEnabled(true);
477
    m_pathChooser->setBaseDirectory(m_target->genericProject()->projectDirectory());
478
    fl->addRow(tr("Build directory:"), m_pathChooser);
con's avatar
con committed
479
    connect(m_pathChooser, SIGNAL(changed(QString)), this, SLOT(buildDirectoryChanged()));
480

481
    // tool chain
482 483 484 485 486 487 488 489
    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*)));
490
    connect(ProjectExplorer::ToolChainManager::instance(), SIGNAL(toolChainAdded(ProjectExplorer::ToolChain*)),
491
            this, SLOT(updateToolChainList()));
492
    connect(ProjectExplorer::ToolChainManager::instance(), SIGNAL(toolChainRemoved(ProjectExplorer::ToolChain*)),
493
            this, SLOT(updateToolChainList()));
Roberto Raggi's avatar
Roberto Raggi committed
494 495 496 497 498 499 500 501
}

GenericBuildSettingsWidget::~GenericBuildSettingsWidget()
{ }

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

dt's avatar
dt committed
502
void GenericBuildSettingsWidget::init(BuildConfiguration *bc)
Roberto Raggi's avatar
Roberto Raggi committed
503
{
504
    m_buildConfiguration = static_cast<GenericBuildConfiguration *>(bc);
505
    m_pathChooser->setPath(m_buildConfiguration->rawBuildDirectory());
Roberto Raggi's avatar
Roberto Raggi committed
506 507 508 509
}

void GenericBuildSettingsWidget::buildDirectoryChanged()
{
510
    m_buildConfiguration->setBuildDirectory(m_pathChooser->rawPath());
Roberto Raggi's avatar
Roberto Raggi committed
511 512
}

513 514 515 516
void GenericBuildSettingsWidget::toolChainSelected(int index)
{
    using namespace ProjectExplorer;

517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537
    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()) {
538
        m_toolChainChooser->addItem(tr("<Invalid tool chain>"), qVariantFromValue(static_cast<void *>(0)));
539 540 541 542 543 544 545 546
        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);
    }
547 548
}

Roberto Raggi's avatar
Roberto Raggi committed
549 550 551
////////////////////////////////////////////////////////////////////////////////////
// GenericProjectFile
////////////////////////////////////////////////////////////////////////////////////
552

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

GenericProjectFile::~GenericProjectFile()
{ }

bool GenericProjectFile::save(const QString &)
{
    return false;
}

QString GenericProjectFile::fileName() const
{
569
    return m_fileName;
Roberto Raggi's avatar
Roberto Raggi committed
570 571 572 573 574 575 576 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
}

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
602 603 604 605
void GenericProjectFile::rename(const QString &newName)
{
    // Can't happen
    Q_UNUSED(newName);
hjk's avatar
hjk committed
606
    QTC_ASSERT(false, /**/);
dt's avatar
dt committed
607 608
}

609
Core::IFile::ReloadBehavior GenericProjectFile::reloadBehavior(ChangeTrigger state, ChangeType type) const
Roberto Raggi's avatar
Roberto Raggi committed
610
{
611 612 613 614 615 616 617 618 619
    Q_UNUSED(state)
    Q_UNUSED(type)
    return BehaviorSilent;
}

void GenericProjectFile::reload(ReloadFlag flag, ChangeType type)
{
    Q_UNUSED(flag)
    Q_UNUSED(type)
Roberto Raggi's avatar
Roberto Raggi committed
620
}