genericproject.cpp 17.3 KB
Newer Older
Roberto Raggi's avatar
Roberto Raggi committed
1 2 3 4
/**************************************************************************
**
** This file is part of Qt Creator
**
hjk's avatar
hjk committed
5
** Copyright (c) 2010 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 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** 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.
**
** If you are unsure which license is appropriate for your use, please
hjk's avatar
hjk committed
26
** contact the sales department at http://qt.nokia.com/contact.
Roberto Raggi's avatar
Roberto Raggi committed
27 28 29 30
**
**************************************************************************/

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

dt's avatar
dt committed
32
#include "genericbuildconfiguration.h"
Tobias Hunger's avatar
Tobias Hunger committed
33 34
#include "genericprojectconstants.h"
#include "generictarget.h"
Roberto Raggi's avatar
Roberto Raggi committed
35

36
#include <projectexplorer/buildenvironmentwidget.h>
37
#include <projectexplorer/customexecutablerunconfiguration.h>
38
#include <projectexplorer/toolchain.h>
Roberto Raggi's avatar
Roberto Raggi committed
39 40 41
#include <projectexplorer/projectexplorerconstants.h>
#include <cpptools/cppmodelmanagerinterface.h>
#include <extensionsystem/pluginmanager.h>
42
#include <utils/pathchooser.h>
Roberto Raggi's avatar
Roberto Raggi committed
43 44
#include <coreplugin/icore.h>

45
#include <QtCore/QDir>
46
#include <QtCore/QProcessEnvironment>
Roberto Raggi's avatar
Roberto Raggi committed
47

48 49 50
#include <QtGui/QFormLayout>
#include <QtGui/QMainWindow>
#include <QtGui/QComboBox>
Roberto Raggi's avatar
Roberto Raggi committed
51 52 53

using namespace GenericProjectManager;
using namespace GenericProjectManager::Internal;
54
using namespace ProjectExplorer;
Roberto Raggi's avatar
Roberto Raggi committed
55

56
namespace {
57
const char * const TOOLCHAIN_KEY("GenericProjectManager.GenericProject.Toolchain");
58 59
} // end of anonymous namespace

60 61 62 63
////////////////////////////////////////////////////////////////////////////////////
// GenericProject
////////////////////////////////////////////////////////////////////////////////////

Roberto Raggi's avatar
Roberto Raggi committed
64
GenericProject::GenericProject(Manager *manager, const QString &fileName)
65 66
    : m_manager(manager),
      m_fileName(fileName),
Tobias Hunger's avatar
Tobias Hunger committed
67
      m_targetFactory(new GenericTargetFactory(this)),
68
      m_toolChain(0)
Roberto Raggi's avatar
Roberto Raggi committed
69
{
70
    QFileInfo fileInfo(m_fileName);
71 72
    QDir dir = fileInfo.dir();

73
    m_projectName      = fileInfo.completeBaseName();
74 75 76
    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();
77

78 79
    m_file = new GenericProjectFile(this, fileName);
    m_rootNode = new GenericProjectNode(this, m_file);
80

81
    m_manager->registerProject(this);
Roberto Raggi's avatar
Roberto Raggi committed
82 83 84 85
}

GenericProject::~GenericProject()
{
86
    m_codeModelFuture.cancel();
87
    m_manager->unregisterProject(this);
88

89 90
    delete m_rootNode;
    delete m_toolChain;
Roberto Raggi's avatar
Roberto Raggi committed
91 92
}

Tobias Hunger's avatar
Tobias Hunger committed
93 94 95 96 97 98
GenericTargetFactory *GenericProject::targetFactory() const
{
    return m_targetFactory;
}

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
104
{ return m_filesFileName; }
105 106

QString GenericProject::includesFileName() const
107
{ return m_includesFileName; }
108 109

QString GenericProject::configFileName() const
110
{ return m_configFileName; }
111

112
static QStringList readLines(const QString &absoluteFileName)
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
{
    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;
}

132
bool GenericProject::saveRawFileList(const QStringList &rawFileList)
133
{
134
    // Make sure we can open the file for writing
135
    QFile file(filesFileName());
136 137 138 139
    if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
        return false;

    QTextStream stream(&file);
140 141
    foreach (const QString &filePath, rawFileList)
        stream << filePath << QLatin1Char('\n');
142 143 144 145

    file.close();
    refresh(GenericProject::Files);
    return true;
146
}
147

148 149
bool GenericProject::addFiles(const QStringList &filePaths)
{
150 151 152 153 154
    QStringList newList = m_rawFileList;

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

156
    return saveRawFileList(newList);
157 158 159 160
}

bool GenericProject::removeFiles(const QStringList &filePaths)
{
161
    QStringList newList = m_rawFileList;
162

163 164 165 166
    foreach (const QString &filePath, filePaths) {
        QHash<QString, QString>::iterator i = m_rawListEntries.find(filePath);
        if (i != m_rawListEntries.end())
            newList.removeOne(i.value());
167
    }
168

169
    return saveRawFileList(newList);
170 171
}

172
void GenericProject::parseProject(RefreshOptions options)
Roberto Raggi's avatar
Roberto Raggi committed
173
{
174 175 176
    if (options & Files) {
        m_rawListEntries.clear();
        m_rawFileList = readLines(filesFileName());
177
        m_files = processEntries(m_rawFileList, &m_rawListEntries);
178
    }
179

180
    if (options & Configuration) {
181
        m_projectIncludePaths = processEntries(readLines(includesFileName()));
182

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

186
        m_defines.clear();
Roberto Raggi's avatar
Roberto Raggi committed
187

188 189 190 191
        QFile configFile(configFileName());
        if (configFile.open(QFile::ReadOnly))
            m_defines = configFile.readAll();
    }
192

193 194
    if (options & Files)
        emit fileListChanged();
Roberto Raggi's avatar
Roberto Raggi committed
195 196
}

197
void GenericProject::refresh(RefreshOptions options)
Roberto Raggi's avatar
Roberto Raggi committed
198
{
199 200 201
    QSet<QString> oldFileList;
    if (!(options & Configuration))
        oldFileList = m_files.toSet();
202

203 204 205 206
    parseProject(options);

    if (options & Files)
        m_rootNode->refresh();
Roberto Raggi's avatar
Roberto Raggi committed
207 208 209 210

    CppTools::CppModelManagerInterface *modelManager =
        ExtensionSystem::PluginManager::instance()->getObject<CppTools::CppModelManagerInterface>();

211 212
    if (m_toolChain && modelManager) {
        const QByteArray predefinedMacros = m_toolChain->predefinedMacros();
Roberto Raggi's avatar
Roberto Raggi committed
213 214 215

        CppTools::CppModelManagerInterface::ProjectInfo pinfo = modelManager->projectInfo(this);
        pinfo.defines = predefinedMacros;
Roberto Raggi's avatar
Roberto Raggi committed
216
        pinfo.defines += '\n';
217
        pinfo.defines += m_defines;
Roberto Raggi's avatar
Roberto Raggi committed
218

219 220
        QStringList allIncludePaths;
        QStringList allFrameworkPaths;
Roberto Raggi's avatar
Roberto Raggi committed
221

222
        foreach (const ProjectExplorer::HeaderPath &headerPath, m_toolChain->systemHeaderPaths()) {
Roberto Raggi's avatar
Roberto Raggi committed
223 224 225 226 227 228
            if (headerPath.kind() == ProjectExplorer::HeaderPath::FrameworkHeaderPath)
                allFrameworkPaths.append(headerPath.path());
            else
                allIncludePaths.append(headerPath.path());
        }

Roberto Raggi's avatar
Roberto Raggi committed
229
        allIncludePaths += this->allIncludePaths();
Roberto Raggi's avatar
Roberto Raggi committed
230 231 232 233 234

        pinfo.frameworkPaths = allFrameworkPaths;
        pinfo.includePaths = allIncludePaths;

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

238 239 240 241 242
        QStringList filesToUpdate;

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

Roberto Raggi's avatar
Roberto Raggi committed
252
        modelManager->updateProjectInfo(pinfo);
253
        m_codeModelFuture = modelManager->updateSourceFiles(filesToUpdate);
Roberto Raggi's avatar
Roberto Raggi committed
254 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
 * 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.
 *
280
 * The \a map variable is an optional argument that will map the returned
281
 * absolute paths back to their original \a entries.
282
 */
283 284
QStringList GenericProject::processEntries(const QStringList &paths,
                                           QHash<QString, QString> *map) const
Roberto Raggi's avatar
Roberto Raggi committed
285
{
286
    const QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
287
    const QDir projectDir(QFileInfo(m_fileName).dir());
288

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

295 296 297
        expandEnvironmentVariables(env, trimmedPath);

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

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

QStringList GenericProject::projectIncludePaths() const
316
{ return m_projectIncludePaths; }
Roberto Raggi's avatar
Roberto Raggi committed
317

Roberto Raggi's avatar
Roberto Raggi committed
318
QStringList GenericProject::files() const
319
{ return m_files; }
Roberto Raggi's avatar
Roberto Raggi committed
320 321

QStringList GenericProject::generated() const
322
{ return m_generated; }
Roberto Raggi's avatar
Roberto Raggi committed
323 324

QStringList GenericProject::includePaths() const
325
{ return m_includePaths; }
Roberto Raggi's avatar
Roberto Raggi committed
326 327

void GenericProject::setIncludePaths(const QStringList &includePaths)
328
{ m_includePaths = includePaths; }
Roberto Raggi's avatar
Roberto Raggi committed
329

Roberto Raggi's avatar
Roberto Raggi committed
330
QByteArray GenericProject::defines() const
331
{ return m_defines; }
Roberto Raggi's avatar
Roberto Raggi committed
332

333
void GenericProject::setToolChainType(ProjectExplorer::ToolChain::ToolChainType type)
Roberto Raggi's avatar
Roberto Raggi committed
334 335 336
{
    using namespace ProjectExplorer;

337
    m_toolChainType = type;
338

339 340
    delete m_toolChain;
    m_toolChain = 0;
Roberto Raggi's avatar
Roberto Raggi committed
341

342
    if (type == ToolChain::MinGW) {
Roberto Raggi's avatar
Roberto Raggi committed
343 344 345
        const QLatin1String qmake_cxx("g++"); // ### FIXME
        const QString mingwDirectory; // ### FIXME

346
        m_toolChain = ToolChain::createMinGWToolChain(qmake_cxx, mingwDirectory);
Roberto Raggi's avatar
Roberto Raggi committed
347

348
    } else if (type == ToolChain::MSVC) {
Roberto Raggi's avatar
Roberto Raggi committed
349
        const QString msvcVersion; // ### FIXME
350
        m_toolChain = ToolChain::createMSVCToolChain(msvcVersion, false);
Roberto Raggi's avatar
Roberto Raggi committed
351

352
    } else if (type == ToolChain::WINCE) {
Roberto Raggi's avatar
Roberto Raggi committed
353
        const QString msvcVersion, wincePlatform; // ### FIXME
354
        m_toolChain = ToolChain::createWinCEToolChain(msvcVersion, wincePlatform);
dt's avatar
dt committed
355
    } else if (type == ToolChain::GCC) {
Roberto Raggi's avatar
Roberto Raggi committed
356
        const QLatin1String qmake_cxx("g++"); // ### FIXME
357
        m_toolChain = ToolChain::createGccToolChain(qmake_cxx);
dt's avatar
dt committed
358 359
    } else if (type == ToolChain::LINUX_ICC) {
        m_toolChain = ToolChain::createLinuxIccToolChain();
Roberto Raggi's avatar
Roberto Raggi committed
360 361 362
    }
}

363 364 365 366 367
ProjectExplorer::ToolChain *GenericProject::toolChain() const
{
    return m_toolChain;
}

368 369
ProjectExplorer::ToolChain::ToolChainType GenericProject::toolChainType() const
{ return m_toolChainType; }
370

371
QString GenericProject::displayName() const
Roberto Raggi's avatar
Roberto Raggi committed
372
{
373
    return m_projectName;
Roberto Raggi's avatar
Roberto Raggi committed
374 375
}

Tobias Hunger's avatar
Tobias Hunger committed
376 377
QString GenericProject::id() const
{
Tobias Hunger's avatar
Tobias Hunger committed
378
    return QLatin1String(Constants::GENERICPROJECT_ID);
Tobias Hunger's avatar
Tobias Hunger committed
379 380
}

Roberto Raggi's avatar
Roberto Raggi committed
381 382
Core::IFile *GenericProject::file() const
{
383
    return m_file;
Roberto Raggi's avatar
Roberto Raggi committed
384 385 386 387
}

ProjectExplorer::IProjectManager *GenericProject::projectManager() const
{
388
    return m_manager;
Roberto Raggi's avatar
Roberto Raggi committed
389 390 391 392 393 394 395
}

QList<ProjectExplorer::Project *> GenericProject::dependsOn()
{
    return QList<Project *>();
}

dt's avatar
dt committed
396
ProjectExplorer::BuildConfigWidget *GenericProject::createConfigWidget()
Roberto Raggi's avatar
Roberto Raggi committed
397 398 399 400
{
    return new GenericBuildSettingsWidget(this);
}

dt's avatar
dt committed
401
QList<ProjectExplorer::BuildConfigWidget*> GenericProject::subConfigWidgets()
Roberto Raggi's avatar
Roberto Raggi committed
402
{
403 404 405
    QList<ProjectExplorer::BuildConfigWidget*> list;
    list << new BuildEnvironmentWidget;
    return list;
Roberto Raggi's avatar
Roberto Raggi committed
406 407
}

408
GenericProjectNode *GenericProject::rootProjectNode() const
Roberto Raggi's avatar
Roberto Raggi committed
409
{
410
    return m_rootNode;
Roberto Raggi's avatar
Roberto Raggi committed
411 412 413 414
}

QStringList GenericProject::files(FilesMode fileMode) const
{
415
    Q_UNUSED(fileMode)
416
    return m_files; // ### TODO: handle generated files here.
Roberto Raggi's avatar
Roberto Raggi committed
417 418
}

Tobias Hunger's avatar
Tobias Hunger committed
419
QStringList GenericProject::buildTargets() const
Roberto Raggi's avatar
Roberto Raggi committed
420 421 422 423 424 425 426
{
    QStringList targets;
    targets.append(QLatin1String("all"));
    targets.append(QLatin1String("clean"));
    return targets;
}

427
QVariantMap GenericProject::toMap() const
Roberto Raggi's avatar
Roberto Raggi committed
428
{
429 430 431 432 433 434 435 436 437
    QVariantMap map(Project::toMap());
    map.insert(QLatin1String(TOOLCHAIN_KEY), static_cast<int>(m_toolChainType));
    return map;
}

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

439 440 441 442 443 444 445 446 447 448 449 450 451
    // 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())
            t->addRunConfiguration(new ProjectExplorer::CustomExecutableRunConfiguration(t));
    }

    // Add default setup:
Tobias Hunger's avatar
Tobias Hunger committed
452 453
    if (targets().isEmpty())
        addTarget(targetFactory()->create(this, QLatin1String(GENERIC_DESKTOP_TARGET_ID)));
454

455 456 457
    ToolChain::ToolChainType type =
            static_cast<ProjectExplorer::ToolChain::ToolChainType>
            (map.value(QLatin1String(TOOLCHAIN_KEY), 0).toInt());
Roberto Raggi's avatar
Roberto Raggi committed
458

459
    setToolChainType(type);
Roberto Raggi's avatar
Roberto Raggi committed
460 461

    setIncludePaths(allIncludePaths());
462

463
    refresh(Everything);
dt's avatar
dt committed
464
    return true;
465 466
}

Roberto Raggi's avatar
Roberto Raggi committed
467 468 469
////////////////////////////////////////////////////////////////////////////////////
// GenericBuildSettingsWidget
////////////////////////////////////////////////////////////////////////////////////
470

Roberto Raggi's avatar
Roberto Raggi committed
471
GenericBuildSettingsWidget::GenericBuildSettingsWidget(GenericProject *project)
dt's avatar
dt committed
472
    : m_project(project), m_buildConfiguration(0)
Roberto Raggi's avatar
Roberto Raggi committed
473 474
{
    QFormLayout *fl = new QFormLayout(this);
475 476
    fl->setContentsMargins(0, -1, 0, -1);
    fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
477 478

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

485
    // tool chain
486
    QComboBox *toolChainChooser = new QComboBox;
487
    toolChainChooser->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
488
    using namespace ProjectExplorer;
489 490
    int index = 0;
    int selectedIndex = -1;
491
    foreach (ToolChain::ToolChainType tc, ToolChain::supportedToolChains()) {
492 493 494 495
        toolChainChooser->addItem(ToolChain::toolChainName(tc), QVariant::fromValue<ToolChain::ToolChainType>(tc));
        if (m_project->toolChainType() == tc)
            selectedIndex = index;
        ++index;
496 497
    }

498
    toolChainChooser->setCurrentIndex(selectedIndex);
Leena Miettinen's avatar
Leena Miettinen committed
499
    fl->addRow(tr("Tool chain:"), toolChainChooser);
500
    connect(toolChainChooser, SIGNAL(activated(int)), this, SLOT(toolChainSelected(int)));
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 524 525 526 527 528
void GenericBuildSettingsWidget::toolChainSelected(int index)
{
    using namespace ProjectExplorer;

    QComboBox *toolChainChooser = qobject_cast<QComboBox*>(sender());
    ToolChain::ToolChainType type = toolChainChooser->itemData(index).value<ToolChain::ToolChainType>();
    m_project->setToolChainType(type);
}

Roberto Raggi's avatar
Roberto Raggi committed
529 530 531
////////////////////////////////////////////////////////////////////////////////////
// GenericProjectFile
////////////////////////////////////////////////////////////////////////////////////
532

Roberto Raggi's avatar
Roberto Raggi committed
533 534
GenericProjectFile::GenericProjectFile(GenericProject *parent, QString fileName)
    : Core::IFile(parent),
535 536
      m_project(parent),
      m_fileName(fileName)
Roberto Raggi's avatar
Roberto Raggi committed
537 538 539 540 541 542 543 544 545 546 547 548
{ }

GenericProjectFile::~GenericProjectFile()
{ }

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

QString GenericProjectFile::fileName() const
{
549
    return m_fileName;
Roberto Raggi's avatar
Roberto Raggi committed
550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581
}

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
582 583 584 585 586 587 588
void GenericProjectFile::rename(const QString &newName)
{
    // Can't happen
    Q_UNUSED(newName);
    Q_ASSERT(false);
}

589
Core::IFile::ReloadBehavior GenericProjectFile::reloadBehavior(ChangeTrigger state, ChangeType type) const
Roberto Raggi's avatar
Roberto Raggi committed
590
{
591 592 593 594 595 596 597 598 599
    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
600
}