2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
|
** Contact: http://www.qt.io/licensing
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-10-02 09:12:39 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2008-12-02 14:09:21 +01:00
|
|
|
|
2012-02-14 16:43:51 +01:00
|
|
|
#ifndef IDOCUMENT_H
|
|
|
|
|
#define IDOCUMENT_H
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
#include "core_global.h"
|
2014-12-21 21:54:30 +02:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QObject>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2015-02-26 13:38:54 +01:00
|
|
|
namespace Utils { class FileName; }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2015-02-26 13:38:54 +01:00
|
|
|
namespace Core {
|
|
|
|
|
class Id;
|
2011-05-06 12:48:44 +02:00
|
|
|
class InfoBar;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2015-01-11 23:32:51 +02:00
|
|
|
namespace Internal {
|
|
|
|
|
class IDocumentPrivate;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-14 16:43:51 +01:00
|
|
|
class CORE_EXPORT IDocument : public QObject
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2015-06-04 15:21:02 +02:00
|
|
|
enum class OpenResult {
|
|
|
|
|
Success,
|
|
|
|
|
ReadError,
|
|
|
|
|
CannotHandle
|
|
|
|
|
};
|
|
|
|
|
|
2009-07-13 15:00:20 +02:00
|
|
|
// This enum must match the indexes of the reloadBehavior widget
|
|
|
|
|
// in generalsettings.ui
|
2010-03-19 10:28:05 +01:00
|
|
|
enum ReloadSetting {
|
|
|
|
|
AlwaysAsk = 0,
|
2009-07-13 15:00:20 +02:00
|
|
|
ReloadUnmodified = 1,
|
2010-03-19 10:28:05 +01:00
|
|
|
IgnoreAll = 2
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum ChangeTrigger {
|
|
|
|
|
TriggerInternal,
|
|
|
|
|
TriggerExternal
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum ChangeType {
|
|
|
|
|
TypeContents,
|
|
|
|
|
TypePermissions,
|
|
|
|
|
TypeRemoved
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum ReloadBehavior {
|
|
|
|
|
BehaviorAsk,
|
|
|
|
|
BehaviorSilent
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum ReloadFlag {
|
|
|
|
|
FlagReload,
|
|
|
|
|
FlagIgnore
|
2009-07-13 15:00:20 +02:00
|
|
|
};
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-02-14 16:43:51 +01:00
|
|
|
IDocument(QObject *parent = 0);
|
|
|
|
|
virtual ~IDocument();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-11-16 10:52:41 +02:00
|
|
|
void setId(Id id);
|
|
|
|
|
Id id() const;
|
2014-03-05 15:58:12 +01:00
|
|
|
|
2015-06-02 17:14:48 +02:00
|
|
|
// required to be re-implemented for documents of IEditors
|
2015-06-04 15:21:02 +02:00
|
|
|
virtual OpenResult open(QString *errorString, const QString &fileName, const QString &realFileName);
|
2015-06-02 17:14:48 +02:00
|
|
|
|
2011-05-10 20:43:03 +02:00
|
|
|
virtual bool save(QString *errorString, const QString &fileName = QString(), bool autoSave = false) = 0;
|
2013-07-15 15:14:10 +02:00
|
|
|
virtual bool setContents(const QByteArray &contents);
|
|
|
|
|
|
2015-02-27 12:59:35 +02:00
|
|
|
const Utils::FileName &filePath() const;
|
2014-12-21 21:54:30 +02:00
|
|
|
virtual void setFilePath(const Utils::FileName &filePath);
|
2013-07-04 22:25:15 +02:00
|
|
|
QString displayName() const;
|
2015-02-25 14:36:03 +02:00
|
|
|
void setPreferredDisplayName(const QString &name);
|
|
|
|
|
QString plainDisplayName() const;
|
|
|
|
|
void setUniqueDisplayName(const QString &name);
|
2013-07-04 22:25:15 +02:00
|
|
|
|
2012-02-14 16:43:51 +01:00
|
|
|
virtual bool isFileReadOnly() const;
|
2013-07-12 15:36:29 +02:00
|
|
|
bool isTemporary() const;
|
|
|
|
|
void setTemporary(bool temporary);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
virtual QString defaultPath() const = 0;
|
|
|
|
|
virtual QString suggestedFileName() const = 0;
|
2014-06-26 02:15:34 +02:00
|
|
|
|
2015-01-11 23:32:51 +02:00
|
|
|
QString mimeType() const;
|
2014-06-26 02:15:34 +02:00
|
|
|
void setMimeType(const QString &mimeType);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-05-10 20:43:03 +02:00
|
|
|
virtual bool shouldAutoSave() const;
|
2008-12-02 12:01:29 +01:00
|
|
|
virtual bool isModified() const = 0;
|
|
|
|
|
virtual bool isSaveAsAllowed() const = 0;
|
|
|
|
|
|
2011-04-15 11:53:46 +02:00
|
|
|
virtual ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
|
2011-04-04 15:24:13 +02:00
|
|
|
virtual bool reload(QString *errorString, ReloadFlag flag, ChangeType type) = 0;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-04-15 11:49:11 +02:00
|
|
|
virtual void checkPermissions();
|
2009-05-08 15:48:00 +02:00
|
|
|
|
2013-07-04 13:30:26 +02:00
|
|
|
bool autoSave(QString *errorString, const QString &filePath);
|
2011-05-10 20:43:03 +02:00
|
|
|
void setRestoredFrom(const QString &name);
|
|
|
|
|
void removeAutoSaveFile();
|
|
|
|
|
|
2015-01-11 23:32:51 +02:00
|
|
|
bool hasWriteWarning() const;
|
|
|
|
|
void setWriteWarning(bool has);
|
2011-05-06 12:48:44 +02:00
|
|
|
|
|
|
|
|
InfoBar *infoBar();
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
signals:
|
|
|
|
|
void changed();
|
2014-06-26 02:15:34 +02:00
|
|
|
void mimeTypeChanged();
|
2010-05-28 14:06:57 +02:00
|
|
|
|
|
|
|
|
void aboutToReload();
|
2013-06-20 12:49:19 +02:00
|
|
|
void reloadFinished(bool success);
|
|
|
|
|
|
2014-12-21 21:54:30 +02:00
|
|
|
void filePathChanged(const Utils::FileName &oldName, const Utils::FileName &newName);
|
2011-05-06 12:48:44 +02:00
|
|
|
|
|
|
|
|
private:
|
2015-01-11 23:32:51 +02:00
|
|
|
Internal::IDocumentPrivate *d;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
2008-12-02 14:09:21 +01:00
|
|
|
} // namespace Core
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-02-14 16:43:51 +01:00
|
|
|
#endif // IDOCUMENT_H
|