2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
2011-09-12 16:52:54 +02:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2011-09-12 16:52:54 +02:00
|
|
|
|
2020-06-17 09:14:47 +02:00
|
|
|
#include "core_global.h"
|
2011-09-12 16:52:54 +02:00
|
|
|
|
2020-06-26 13:59:38 +02:00
|
|
|
#include <utils/id.h>
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QList>
|
2020-06-26 13:59:38 +02:00
|
|
|
#include <QSharedDataPointer>
|
2011-09-12 16:52:54 +02:00
|
|
|
|
2021-07-14 16:49:42 +02:00
|
|
|
namespace Utils { class FilePath; }
|
|
|
|
|
|
2011-09-12 16:52:54 +02:00
|
|
|
namespace Core {
|
|
|
|
|
class GeneratedFilePrivate;
|
|
|
|
|
|
|
|
|
|
class CORE_EXPORT GeneratedFile
|
|
|
|
|
{
|
|
|
|
|
public:
|
2020-03-24 09:44:38 +01:00
|
|
|
enum Attribute {
|
|
|
|
|
// Open this file in editor
|
|
|
|
|
OpenEditorAttribute = 0x01,
|
|
|
|
|
// Open project
|
|
|
|
|
OpenProjectAttribute = 0x02,
|
|
|
|
|
// File is generated by external scripts, do not write out, see BaseFileWizard::writeFiles()
|
|
|
|
|
CustomGeneratorAttribute = 0x4,
|
|
|
|
|
// File exists and the user indicated that he wants to keep it
|
|
|
|
|
KeepExistingFileAttribute = 0x8,
|
|
|
|
|
// Force overwriting of a file without asking the user to keep it
|
|
|
|
|
ForceOverwrite = 0x10,
|
|
|
|
|
// Mark the document temporary after opening the file
|
|
|
|
|
TemporaryFile = 0x20
|
|
|
|
|
};
|
2011-09-12 16:52:54 +02:00
|
|
|
Q_DECLARE_FLAGS(Attributes, Attribute)
|
|
|
|
|
|
|
|
|
|
GeneratedFile();
|
2021-08-27 12:25:31 +02:00
|
|
|
explicit GeneratedFile(const Utils::FilePath &path);
|
2011-09-12 16:52:54 +02:00
|
|
|
GeneratedFile(const GeneratedFile &);
|
|
|
|
|
GeneratedFile &operator=(const GeneratedFile &);
|
|
|
|
|
~GeneratedFile();
|
|
|
|
|
|
|
|
|
|
// Full path of the file should be created, or the suggested file name
|
2021-08-27 12:25:31 +02:00
|
|
|
void setFilePath(const Utils::FilePath &p);
|
2021-07-14 16:49:42 +02:00
|
|
|
Utils::FilePath filePath() const;
|
2011-09-12 16:52:54 +02:00
|
|
|
|
|
|
|
|
// Contents of the file (UTF8)
|
|
|
|
|
QString contents() const;
|
|
|
|
|
void setContents(const QString &c);
|
|
|
|
|
|
|
|
|
|
QByteArray binaryContents() const;
|
|
|
|
|
void setBinaryContents(const QByteArray &c);
|
|
|
|
|
|
|
|
|
|
// Defaults to false (Text file).
|
|
|
|
|
bool isBinary() const;
|
|
|
|
|
void setBinary(bool b);
|
|
|
|
|
|
|
|
|
|
// Id of editor to open the file with
|
2020-06-26 13:59:38 +02:00
|
|
|
Utils::Id editorId() const;
|
|
|
|
|
void setEditorId(Utils::Id id);
|
2011-09-12 16:52:54 +02:00
|
|
|
|
|
|
|
|
bool write(QString *errorMessage) const;
|
|
|
|
|
|
|
|
|
|
Attributes attributes() const;
|
|
|
|
|
void setAttributes(Attributes a);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QSharedDataPointer<GeneratedFilePrivate> m_d;
|
2021-09-02 14:35:41 +03:00
|
|
|
|
|
|
|
|
friend CORE_EXPORT QDebug &operator<<(QDebug &debug, const Core::GeneratedFile &file);
|
2011-09-12 16:52:54 +02:00
|
|
|
};
|
|
|
|
|
|
2021-09-02 14:35:41 +03:00
|
|
|
CORE_EXPORT QDebug &operator<<(QDebug &debug, const Core::GeneratedFile &file);
|
|
|
|
|
|
2018-07-21 21:11:46 +02:00
|
|
|
using GeneratedFiles = QList<GeneratedFile>;
|
2011-09-12 16:52:54 +02:00
|
|
|
|
|
|
|
|
} // namespace Core
|