2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://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
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2008-12-02 15:08:31 +01:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-09-26 09:14:03 +02:00
|
|
|
#include <texteditor/textdocument.h>
|
2016-10-20 14:45:15 +02:00
|
|
|
#include <utils/guard.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QPointer>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
class QDesignerFormWindowInterface;
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
|
|
|
|
namespace Designer {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2014-09-03 16:03:35 +02:00
|
|
|
class ResourceHandler;
|
|
|
|
|
|
2014-09-22 18:43:31 +02:00
|
|
|
class FormWindowFile : public TextEditor::TextDocument
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2010-03-10 10:21:52 +01:00
|
|
|
explicit FormWindowFile(QDesignerFormWindowInterface *form, QObject *parent = 0);
|
2015-06-02 09:24:27 +02:00
|
|
|
~FormWindowFile() override { }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-02-14 16:43:51 +01:00
|
|
|
// IDocument
|
2015-06-04 15:21:02 +02:00
|
|
|
OpenResult open(QString *errorString, const QString &fileName,
|
|
|
|
|
const QString &realFileName) override;
|
2015-06-02 09:24:27 +02:00
|
|
|
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
|
2016-01-15 15:29:51 +01:00
|
|
|
QByteArray contents() const override;
|
2015-06-02 09:24:27 +02:00
|
|
|
bool setContents(const QByteArray &contents) override;
|
|
|
|
|
bool shouldAutoSave() const override;
|
2016-10-20 08:34:55 +00:00
|
|
|
bool isModified() const override;
|
2015-06-02 09:24:27 +02:00
|
|
|
bool isSaveAsAllowed() const override;
|
|
|
|
|
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
|
2016-01-14 14:45:01 +01:00
|
|
|
QString fallbackSaveAsFileName() const override;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
// Internal
|
2016-01-14 14:45:01 +01:00
|
|
|
void setFallbackSaveAsFileName(const QString &fileName);
|
2010-03-09 15:48:01 +01:00
|
|
|
|
2011-03-30 13:45:16 +02:00
|
|
|
bool writeFile(const QString &fileName, QString *errorString) const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-03-09 15:48:01 +01:00
|
|
|
QDesignerFormWindowInterface *formWindow() const;
|
2013-07-15 15:14:10 +02:00
|
|
|
void syncXmlFromFormWindow();
|
|
|
|
|
QString formWindowContents() const;
|
2014-09-03 16:03:35 +02:00
|
|
|
ResourceHandler *resourceHandler() const;
|
2010-03-09 15:48:01 +01:00
|
|
|
|
2015-06-02 09:24:27 +02:00
|
|
|
void setFilePath(const Utils::FileName &) override;
|
2011-05-10 20:43:03 +02:00
|
|
|
void setShouldAutoSave(bool sad = true) { m_shouldAutoSave = sad; }
|
2013-07-04 22:25:15 +02:00
|
|
|
void updateIsModified();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2017-03-18 23:25:06 +02:00
|
|
|
private:
|
2010-04-08 15:38:03 +02:00
|
|
|
void slotFormWindowRemoved(QDesignerFormWindowInterface *w);
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
QString m_suggestedName;
|
2015-06-01 17:00:02 +02:00
|
|
|
bool m_shouldAutoSave = false;
|
2010-03-09 15:48:01 +01:00
|
|
|
// Might actually go out of scope before the IEditor due
|
|
|
|
|
// to deleting the WidgetHost which owns it.
|
|
|
|
|
QPointer<QDesignerFormWindowInterface> m_formWindow;
|
2016-10-20 08:34:55 +00:00
|
|
|
bool m_isModified = false;
|
2015-06-01 17:00:02 +02:00
|
|
|
ResourceHandler *m_resourceHandler = nullptr;
|
2016-10-20 14:45:15 +02:00
|
|
|
Utils::Guard m_modificationChangedGuard;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Designer
|