2013-05-07 14:02:08 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
|
** Contact: http://www.qt.io/licensing
|
2013-05-07 14:02:08 +02:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** 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.
|
2013-05-07 14:02:08 +02:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
** 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.
|
2013-05-07 14:02:08 +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
|
2013-05-07 14:02:08 +02:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2014-01-30 13:31:11 +01:00
|
|
|
#ifndef DIFFEDITORDOCUMENT_H
|
|
|
|
|
#define DIFFEDITORDOCUMENT_H
|
2013-05-07 14:02:08 +02:00
|
|
|
|
2015-01-30 16:59:25 +01:00
|
|
|
#include "diffutils.h"
|
|
|
|
|
|
2014-06-30 15:04:36 +02:00
|
|
|
#include <coreplugin/textdocument.h>
|
2013-05-07 14:02:08 +02:00
|
|
|
|
2015-03-10 14:19:38 +01:00
|
|
|
QT_FORWARD_DECLARE_CLASS(QMenu)
|
|
|
|
|
|
2013-05-07 14:02:08 +02:00
|
|
|
namespace DiffEditor {
|
|
|
|
|
|
2014-01-31 09:01:49 +01:00
|
|
|
class DiffEditorController;
|
|
|
|
|
|
2015-01-30 14:33:39 +01:00
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
class DiffEditorDocument : public Core::BaseTextDocument
|
2013-05-07 14:02:08 +02:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2014-11-13 09:11:56 +01:00
|
|
|
Q_PROPERTY(QString plainText READ plainText STORED false) // For access by code pasters
|
2013-05-07 14:02:08 +02:00
|
|
|
public:
|
2015-01-30 11:18:08 +01:00
|
|
|
DiffEditorDocument();
|
2014-01-31 09:01:49 +01:00
|
|
|
|
2014-02-11 13:00:35 +01:00
|
|
|
DiffEditorController *controller() const;
|
2013-05-07 14:02:08 +02:00
|
|
|
|
2015-01-30 16:59:25 +01:00
|
|
|
QString makePatch(int fileIndex, int chunkIndex, bool revert, bool addPrefix = false) const;
|
|
|
|
|
|
2015-08-20 16:45:30 +03:00
|
|
|
void setDiffFiles(const QList<FileData> &data, const QString &directory,
|
|
|
|
|
const QString &startupFile = QString());
|
2015-01-30 16:59:25 +01:00
|
|
|
QList<FileData> diffFiles() const;
|
|
|
|
|
QString baseDirectory() const;
|
2015-08-20 16:45:30 +03:00
|
|
|
QString startupFile() const;
|
2015-01-30 16:59:25 +01:00
|
|
|
|
|
|
|
|
void setDescription(const QString &description);
|
|
|
|
|
QString description() const;
|
|
|
|
|
|
|
|
|
|
void setContextLineCount(int lines);
|
|
|
|
|
int contextLineCount() const;
|
|
|
|
|
void forceContextLineCount(int lines);
|
|
|
|
|
bool isContextLineCountForced() const;
|
|
|
|
|
void setIgnoreWhitespace(bool ignore);
|
|
|
|
|
bool ignoreWhitespace() const;
|
|
|
|
|
|
2015-06-04 15:54:10 +02:00
|
|
|
bool setContents(const QByteArray &contents) override;
|
2016-01-14 14:45:01 +01:00
|
|
|
QString fallbackSaveAsPath() const override;
|
|
|
|
|
QString fallbackSaveAsFileName() const override;
|
2013-05-07 14:02:08 +02:00
|
|
|
|
2015-06-04 15:54:10 +02:00
|
|
|
bool isModified() const override { return false; }
|
|
|
|
|
bool isSaveAsAllowed() const override { return true; }
|
|
|
|
|
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
|
2015-01-30 16:59:25 +01:00
|
|
|
void reload();
|
2015-06-04 15:54:10 +02:00
|
|
|
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
|
|
|
|
|
OpenResult open(QString *errorString, const QString &fileName,
|
|
|
|
|
const QString &realFileName) override;
|
2013-05-07 14:02:08 +02:00
|
|
|
|
2014-11-13 09:11:56 +01:00
|
|
|
QString plainText() const;
|
|
|
|
|
|
2015-01-30 16:59:25 +01:00
|
|
|
signals:
|
|
|
|
|
void temporaryStateChanged();
|
|
|
|
|
void documentChanged();
|
|
|
|
|
void descriptionChanged();
|
|
|
|
|
void chunkActionsRequested(QMenu *menu, int diffFileIndex, int chunkIndex);
|
|
|
|
|
void requestMoreInformation();
|
|
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
void beginReload();
|
|
|
|
|
void endReload(bool success);
|
|
|
|
|
|
2013-05-07 14:02:08 +02:00
|
|
|
private:
|
2015-01-30 16:59:25 +01:00
|
|
|
void setController(DiffEditorController *controller);
|
|
|
|
|
|
|
|
|
|
DiffEditorController *m_controller;
|
|
|
|
|
QList<FileData> m_diffFiles;
|
|
|
|
|
QString m_baseDirectory;
|
2015-08-20 16:45:30 +03:00
|
|
|
QString m_startupFile;
|
2015-01-30 16:59:25 +01:00
|
|
|
QString m_description;
|
|
|
|
|
int m_contextLineCount;
|
|
|
|
|
bool m_isContextLineCountForced;
|
|
|
|
|
bool m_ignoreWhitespace;
|
|
|
|
|
|
|
|
|
|
friend class ::DiffEditor::DiffEditorController;
|
2013-05-07 14:02:08 +02:00
|
|
|
};
|
|
|
|
|
|
2015-01-30 14:33:39 +01:00
|
|
|
} // namespace Internal
|
2013-05-07 14:02:08 +02:00
|
|
|
} // namespace DiffEditor
|
|
|
|
|
|
2014-01-30 13:31:11 +01:00
|
|
|
#endif // DIFFEDITORDOCUMENT_H
|