summaryrefslogtreecommitdiff
path: root/src/plugins/vcsbase
diff options
context:
space:
mode:
authorcon <qtc-commiter@nokia.com>2008-12-02 12:01:29 +0100
committercon <qtc-commiter@nokia.com>2008-12-02 12:01:29 +0100
commit05c35356abc31549c5db6eba31fb608c0365c2a0 (patch)
treebe044530104267afaff13f8943889cb97f8c8bad /src/plugins/vcsbase
downloadqt-creator-05c35356abc31549c5db6eba31fb608c0365c2a0.tar.gz
Initial import
Diffstat (limited to 'src/plugins/vcsbase')
-rw-r--r--src/plugins/vcsbase/README.txt6
-rw-r--r--src/plugins/vcsbase/VCSBase.mimetypes.xml39
-rw-r--r--src/plugins/vcsbase/VCSBase.pluginspec12
-rw-r--r--src/plugins/vcsbase/baseannotationhighlighter.cpp102
-rw-r--r--src/plugins/vcsbase/baseannotationhighlighter.h76
-rw-r--r--src/plugins/vcsbase/basevcseditorfactory.cpp106
-rw-r--r--src/plugins/vcsbase/basevcseditorfactory.h121
-rw-r--r--src/plugins/vcsbase/basevcssubmiteditorfactory.cpp89
-rw-r--r--src/plugins/vcsbase/basevcssubmiteditorfactory.h100
-rw-r--r--src/plugins/vcsbase/diffhighlighter.cpp119
-rw-r--r--src/plugins/vcsbase/diffhighlighter.h91
-rw-r--r--src/plugins/vcsbase/submiteditorfile.cpp71
-rw-r--r--src/plugins/vcsbase/submiteditorfile.h77
-rw-r--r--src/plugins/vcsbase/vcsbase.pri3
-rw-r--r--src/plugins/vcsbase/vcsbase.pro31
-rw-r--r--src/plugins/vcsbase/vcsbase.qrc5
-rw-r--r--src/plugins/vcsbase/vcsbase_dependencies.pri4
-rw-r--r--src/plugins/vcsbase/vcsbase_global.h57
-rw-r--r--src/plugins/vcsbase/vcsbaseconstants.h46
-rw-r--r--src/plugins/vcsbase/vcsbaseeditor.cpp486
-rw-r--r--src/plugins/vcsbase/vcsbaseeditor.h173
-rw-r--r--src/plugins/vcsbase/vcsbaseplugin.cpp81
-rw-r--r--src/plugins/vcsbase/vcsbaseplugin.h64
-rw-r--r--src/plugins/vcsbase/vcsbasesubmiteditor.cpp281
-rw-r--r--src/plugins/vcsbase/vcsbasesubmiteditor.h146
-rw-r--r--src/plugins/vcsbase/vcsbasetextdocument.cpp53
-rw-r--r--src/plugins/vcsbase/vcsbasetextdocument.h55
27 files changed, 2494 insertions, 0 deletions
diff --git a/src/plugins/vcsbase/README.txt b/src/plugins/vcsbase/README.txt
new file mode 100644
index 0000000000..7b60a23110
--- /dev/null
+++ b/src/plugins/vcsbase/README.txt
@@ -0,0 +1,6 @@
+TODO:
+
+When diffing:
+- Use code from current editor or
+- else from project or
+- System codec
diff --git a/src/plugins/vcsbase/VCSBase.mimetypes.xml b/src/plugins/vcsbase/VCSBase.mimetypes.xml
new file mode 100644
index 0000000000..1c97052174
--- /dev/null
+++ b/src/plugins/vcsbase/VCSBase.mimetypes.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0"?>
+<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
+ <mime-type type="text/x-patch">
+ <sub-class-of type="text/plain"/>
+ <comment>Differences between files</comment>
+ <glob pattern="*.diff"/> <comment xml:lang="bg">Разлики между файлове</comment>
+ <comment xml:lang="ca">diferències entre fitxers</comment>
+ <comment xml:lang="cs">Rozdíly mezi soubory</comment>
+ <comment xml:lang="da">forskel mellem filer</comment>
+ <comment xml:lang="de">Unterschied zwischen Dateien</comment>
+ <comment xml:lang="el">διαφορές μεταξύ αρχείων</comment>
+ <comment xml:lang="eo">diferencoj inter dosieroj</comment>
+ <comment xml:lang="es">diferencias entre ficheros</comment>
+ <comment xml:lang="eu">fitxategien arteko ezberdintasunak</comment>
+ <comment xml:lang="fi">tiedostojen väliset erot</comment>
+ <comment xml:lang="fr">différences entre fichiers</comment>
+ <comment xml:lang="hu">diff-különbségfájl</comment>
+ <comment xml:lang="it">Differenze tra file</comment>
+ <comment xml:lang="ja">ファイル間差分</comment>
+ <comment xml:lang="ko">파일사이의 바뀐점</comment>
+ <comment xml:lang="lt">skirtumai tarp rinkmenų</comment>
+ <comment xml:lang="ms">Perbezaan antara fail</comment>
+ <comment xml:lang="nb">forskjeller mellom filer</comment>
+ <comment xml:lang="nl">verschillen tussen bestanden</comment>
+ <comment xml:lang="nn">skilnader mellom filer</comment>
+ <comment xml:lang="pl">różnica pomiędzy plikami</comment>
+ <comment xml:lang="pt">diferenças entre ficheiros</comment>
+ <comment xml:lang="pt_BR">Diferenças entre arquivos</comment>
+ <comment xml:lang="ru">различия между файлами</comment>
+ <comment xml:lang="sq">diferenca midis files</comment>
+ <comment xml:lang="sr">разлике међу датотекама</comment>
+ <comment xml:lang="sv">skillnader mellan filer</comment>
+ <comment xml:lang="uk">різниця між файлами</comment>
+ <comment xml:lang="vi">khác biệt giữa nhiều tập tin</comment>
+ <comment xml:lang="zh_CN">文件的区别</comment>
+ <comment xml:lang="zh_TW">檔案內容差異</comment>
+ <glob pattern="*.patch"/>
+ </mime-type>
+</mime-info>
diff --git a/src/plugins/vcsbase/VCSBase.pluginspec b/src/plugins/vcsbase/VCSBase.pluginspec
new file mode 100644
index 0000000000..da0b618d26
--- /dev/null
+++ b/src/plugins/vcsbase/VCSBase.pluginspec
@@ -0,0 +1,12 @@
+<plugin name="VCSBase" version="0.9.1" compatVersion="0.9.1">
+ <vendor>Nokia Corporation</vendor>
+ <copyright>(C) 2008 Nokia Corporation</copyright>
+ <license>Nokia Technology Preview License Agreement</license>
+ <description>Version Control System Base Plugin</description>
+ <url>http://www.trolltech.com/</url>
+ <dependencyList>
+ <dependency name="Core" version="0.9.1"/>
+ <dependency name="TextEditor" version="0.9.1"/>
+ <dependency name="ProjectExplorer" version="0.9.1"/>
+ </dependencyList>
+</plugin>
diff --git a/src/plugins/vcsbase/baseannotationhighlighter.cpp b/src/plugins/vcsbase/baseannotationhighlighter.cpp
new file mode 100644
index 0000000000..e287718d71
--- /dev/null
+++ b/src/plugins/vcsbase/baseannotationhighlighter.cpp
@@ -0,0 +1,102 @@
+/***************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+**
+** Non-Open Source Usage
+**
+** Licensees may use this file in accordance with the Qt Beta Version
+** License Agreement, Agreement version 2.2 provided with the Software or,
+** alternatively, in accordance with the terms contained in a written
+** agreement between you and Nokia.
+**
+** GNU General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the packaging
+** of this file. Please review the following information to ensure GNU
+** General Public Licensing requirements will be met:
+**
+** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt GPL Exception version
+** 1.2, included in the file GPL_EXCEPTION.txt in this package.
+**
+***************************************************************************/
+#include "baseannotationhighlighter.h"
+
+#include <math.h>
+#include <QtCore/QSet>
+#include <QtCore/QDebug>
+#include <QtGui/QColor>
+#include <QtGui/QTextDocument>
+#include <QtGui/QTextEdit>
+#include <QtGui/QTextCharFormat>
+
+typedef QMap<QString, QTextCharFormat> ChangeNumberFormatMap;
+
+namespace VCSBase {
+
+struct BaseAnnotationHighlighterPrivate {
+ ChangeNumberFormatMap m_changeNumberMap;
+};
+
+BaseAnnotationHighlighter::BaseAnnotationHighlighter(const ChangeNumbers &changeNumbers,
+ QTextDocument *document) :
+ QSyntaxHighlighter(document),
+ m_d(new BaseAnnotationHighlighterPrivate)
+{
+ setChangeNumbers(changeNumbers);
+}
+
+BaseAnnotationHighlighter::~BaseAnnotationHighlighter()
+{
+ delete m_d;
+}
+
+void BaseAnnotationHighlighter::setChangeNumbers(const ChangeNumbers &changeNumbers)
+{
+ m_d->m_changeNumberMap.clear();
+ if (!changeNumbers.isEmpty()) {
+ // Assign a color gradient to annotation change numbers. Give
+ // each change number a unique color.
+ const double oneThird = 1.0 / 3.0;
+ const int step = qRound(ceil(pow(changeNumbers.count(), oneThird)));
+ QList<QColor> colors;
+ const int factor = 255 / step;
+ for (int i=0; i<step; ++i)
+ for (int j=0; j<step; ++j)
+ for (int k=0; k<step; ++k)
+ colors.append(QColor(i*factor, j*factor, k*factor));
+
+ int m = 0;
+ const int cstep = colors.count() / changeNumbers.count();
+ const ChangeNumbers::const_iterator cend = changeNumbers.constEnd();
+ for (ChangeNumbers::const_iterator it = changeNumbers.constBegin(); it != cend; ++it) {
+ QTextCharFormat format;
+ format.setForeground(colors.at(m));
+ m_d->m_changeNumberMap.insert(*it, format);
+ m += cstep;
+ }
+ }
+}
+
+void BaseAnnotationHighlighter::highlightBlock(const QString &text)
+{
+ if (text.isEmpty() || m_d->m_changeNumberMap.empty())
+ return;
+ const QString change = changeNumber(text);
+ const ChangeNumberFormatMap::const_iterator it = m_d->m_changeNumberMap.constFind(change);
+ if (it != m_d->m_changeNumberMap.constEnd())
+ setFormat(0, text.length(), it.value());
+}
+
+}
+
diff --git a/src/plugins/vcsbase/baseannotationhighlighter.h b/src/plugins/vcsbase/baseannotationhighlighter.h
new file mode 100644
index 0000000000..ee5808b7b0
--- /dev/null
+++ b/src/plugins/vcsbase/baseannotationhighlighter.h
@@ -0,0 +1,76 @@
+/***************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+**
+** Non-Open Source Usage
+**
+** Licensees may use this file in accordance with the Qt Beta Version
+** License Agreement, Agreement version 2.2 provided with the Software or,
+** alternatively, in accordance with the terms contained in a written
+** agreement between you and Nokia.
+**
+** GNU General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the packaging
+** of this file. Please review the following information to ensure GNU
+** General Public Licensing requirements will be met:
+**
+** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt GPL Exception version
+** 1.2, included in the file GPL_EXCEPTION.txt in this package.
+**
+***************************************************************************/
+#ifndef BASEANNOTATIONHIGHLIGHTER_H
+#define BASEANNOTATIONHIGHLIGHTER_H
+
+#include "vcsbase_global.h"
+
+#include <QtCore/QMap>
+#include <QtCore/QSet>
+#include <QtGui/QSyntaxHighlighter>
+#include <QtGui/QTextCharFormat>
+
+namespace VCSBase {
+
+struct BaseAnnotationHighlighterPrivate;
+
+// Base for a highlighter for annotation lines of the form
+// 'changenumber:XXXX'. The change numbers are assigned a color gradient.
+// Example:
+// 112: text1 <color 1>
+// 113: text2 <color 2>
+// 112: text3 <color 1>
+class VCSBASE_EXPORT BaseAnnotationHighlighter : public QSyntaxHighlighter
+{
+ Q_OBJECT
+public:
+ typedef QSet<QString> ChangeNumbers;
+
+ explicit BaseAnnotationHighlighter(const ChangeNumbers &changeNumbers,
+ QTextDocument *document = 0);
+ virtual ~BaseAnnotationHighlighter();
+
+ void setChangeNumbers(const ChangeNumbers &changeNumbers);
+
+ virtual void highlightBlock(const QString &text);
+
+private:
+ // Implement this to return the change number of a line
+ virtual QString changeNumber(const QString &block) const = 0;
+
+ BaseAnnotationHighlighterPrivate *m_d;
+};
+
+} //namespace Internal
+
+#endif
diff --git a/src/plugins/vcsbase/basevcseditorfactory.cpp b/src/plugins/vcsbase/basevcseditorfactory.cpp
new file mode 100644
index 0000000000..459a6683e6
--- /dev/null
+++ b/src/plugins/vcsbase/basevcseditorfactory.cpp
@@ -0,0 +1,106 @@
+/***************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+**
+** Non-Open Source Usage
+**
+** Licensees may use this file in accordance with the Qt Beta Version
+** License Agreement, Agreement version 2.2 provided with the Software or,
+** alternatively, in accordance with the terms contained in a written
+** agreement between you and Nokia.
+**
+** GNU General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the packaging
+** of this file. Please review the following information to ensure GNU
+** General Public Licensing requirements will be met:
+**
+** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt GPL Exception version
+** 1.2, included in the file GPL_EXCEPTION.txt in this package.
+**
+***************************************************************************/
+#include "basevcseditorfactory.h"
+#include "vcsbaseplugin.h"
+#include "vcsbaseeditor.h"
+
+#include <coreplugin/icore.h>
+#include <coreplugin/editormanager/editormanager.h>
+#include <texteditor/fontsettings.h>
+#include <texteditor/texteditoractionhandler.h>
+#include <texteditor/texteditorsettings.h>
+
+namespace VCSBase {
+
+struct BaseVCSEditorFactoryPrivate {
+ BaseVCSEditorFactoryPrivate(const VCSBaseEditorParameters *t, Core::ICore *core);
+
+ const VCSBaseEditorParameters *m_type;
+ const QString m_kind;
+ const QStringList m_mimeTypes;
+ Core::ICore *m_core;
+ TextEditor::TextEditorActionHandler *m_editorHandler;
+};
+
+BaseVCSEditorFactoryPrivate::BaseVCSEditorFactoryPrivate(const VCSBaseEditorParameters *t, Core::ICore *core) :
+ m_type(t),
+ m_kind(QLatin1String(t->kind)),
+ m_mimeTypes(QStringList(QLatin1String(t->mimeType))),
+ m_core(core),
+ m_editorHandler(new TextEditor::TextEditorActionHandler(core, t->kind))
+{
+}
+
+BaseVCSEditorFactory::BaseVCSEditorFactory(const VCSBaseEditorParameters *t,
+ Core::ICore *core) :
+ m_d(new BaseVCSEditorFactoryPrivate(t, core))
+{
+}
+
+BaseVCSEditorFactory::~BaseVCSEditorFactory()
+{
+ delete m_d;
+}
+
+QStringList BaseVCSEditorFactory::mimeTypes() const
+{
+ return m_d->m_mimeTypes;
+}
+
+QString BaseVCSEditorFactory::kind() const
+{
+ return m_d->m_kind;
+}
+
+Core::IFile *BaseVCSEditorFactory::open(const QString &fileName)
+{
+ Core::IEditor *iface = m_d->m_core->editorManager()->openEditor(fileName, kind());
+ return iface ? iface->file() : 0;
+}
+
+Core::IEditor *BaseVCSEditorFactory::createEditor(QWidget *parent)
+{
+ VCSBaseEditor *vcsEditor = createVCSBaseEditor(m_d->m_type, parent);
+
+ vcsEditor ->setMimeType(m_d->m_mimeTypes.front());
+ m_d->m_editorHandler->setupActions(vcsEditor);
+
+ // Wire font settings and set initial values
+ TextEditor::TextEditorSettings *settings = TextEditor::TextEditorSettings::instance();
+ connect(settings, SIGNAL(fontSettingsChanged(TextEditor::FontSettings)),
+ vcsEditor, SLOT(setFontSettings(TextEditor::FontSettings)));
+ vcsEditor->setFontSettings(settings->fontSettings());
+ return vcsEditor->editableInterface();
+}
+
+} // namespace VCSBase
diff --git a/src/plugins/vcsbase/basevcseditorfactory.h b/src/plugins/vcsbase/basevcseditorfactory.h
new file mode 100644
index 0000000000..1fb9408c8c
--- /dev/null
+++ b/src/plugins/vcsbase/basevcseditorfactory.h
@@ -0,0 +1,121 @@
+/***************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+**
+** Non-Open Source Usage
+**
+** Licensees may use this file in accordance with the Qt Beta Version
+** License Agreement, Agreement version 2.2 provided with the Software or,
+** alternatively, in accordance with the terms contained in a written
+** agreement between you and Nokia.
+**
+** GNU General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the packaging
+** of this file. Please review the following information to ensure GNU
+** General Public Licensing requirements will be met:
+**
+** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt GPL Exception version
+** 1.2, included in the file GPL_EXCEPTION.txt in this package.
+**
+***************************************************************************/
+#ifndef BASEVCSEDITORFACTORY_H
+#define BASEVCSEDITORFACTORY_H
+
+#include "vcsbase_global.h"
+#include "vcsbaseeditor.h"
+
+#include <coreplugin/editormanager/ieditorfactory.h>
+
+#include <QtCore/QStringList>
+
+namespace TextEditor {
+ class TextEditorActionHandler;
+}
+
+namespace Core {
+ class ICore;
+}
+
+namespace VCSBase {
+struct BaseVCSEditorFactoryPrivate;
+
+// Base class for editor factories creating instances of VCSBaseEditor
+// subclasses.
+class VCSBASE_EXPORT BaseVCSEditorFactory : public Core::IEditorFactory
+{
+ Q_OBJECT
+public:
+ explicit BaseVCSEditorFactory(const VCSBaseEditorParameters *type,
+ Core::ICore *core);
+ virtual ~BaseVCSEditorFactory();
+
+ virtual QStringList mimeTypes() const;
+ // IEditorFactory
+
+ virtual QString kind() const;
+ virtual Core::IFile *open(const QString &fileName);
+ virtual Core::IEditor *createEditor(QWidget *parent);
+
+private:
+ // Implement to create and initialize (call init()) a
+ // VCSBaseEditor subclass
+ virtual VCSBaseEditor *createVCSBaseEditor(const VCSBaseEditorParameters *type,
+ QWidget *parent) = 0;
+
+ BaseVCSEditorFactoryPrivate *m_d;
+};
+
+// Utility template to create an editor.
+template <class Editor>
+class VCSEditorFactory : public BaseVCSEditorFactory
+{
+public:
+ explicit VCSEditorFactory(const VCSBaseEditorParameters *type,
+ Core::ICore *core,
+ QObject *describeReceiver = 0,
+ const char *describeSlot = 0);
+
+private:
+ virtual VCSBaseEditor *createVCSBaseEditor(const VCSBaseEditorParameters *type,
+ QWidget *parent);
+ QObject *m_describeReceiver;
+ const char *m_describeSlot;
+};
+
+template <class Editor>
+VCSEditorFactory<Editor>::VCSEditorFactory(const VCSBaseEditorParameters *type,
+ Core::ICore *core,
+ QObject *describeReceiver,
+ const char *describeSlot) :
+ BaseVCSEditorFactory(type, core),
+ m_describeReceiver(describeReceiver),
+ m_describeSlot(describeSlot)
+{
+}
+
+template <class Editor>
+VCSBaseEditor *VCSEditorFactory<Editor>::createVCSBaseEditor(const VCSBaseEditorParameters *type,
+ QWidget *parent)
+{
+ VCSBaseEditor *rc = new Editor(type, parent);
+ rc->init();
+ if (m_describeReceiver)
+ connect(rc, SIGNAL(describeRequested(QString,QString)), m_describeReceiver, m_describeSlot);
+ return rc;
+
+}
+}
+#endif
+
diff --git a/src/plugins/vcsbase/basevcssubmiteditorfactory.cpp b/src/plugins/vcsbase/basevcssubmiteditorfactory.cpp
new file mode 100644
index 0000000000..4aff7347fa
--- /dev/null
+++ b/src/plugins/vcsbase/basevcssubmiteditorfactory.cpp
@@ -0,0 +1,89 @@
+/***************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+**
+** Non-Open Source Usage
+**
+** Licensees may use this file in accordance with the Qt Beta Version
+** License Agreement, Agreement version 2.2 provided with the Software or,
+** alternatively, in accordance with the terms contained in a written
+** agreement between you and Nokia.
+**
+** GNU General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the packaging
+** of this file. Please review the following information to ensure GNU
+** General Public Licensing requirements will be met:
+**
+** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt GPL Exception version
+** 1.2, included in the file GPL_EXCEPTION.txt in this package.
+**
+***************************************************************************/
+#include "basevcssubmiteditorfactory.h"
+#include "vcsbasesubmiteditor.h"
+
+#include <coreplugin/icore.h>
+#include <coreplugin/editormanager/editormanager.h>
+
+namespace VCSBase {
+
+struct BaseVCSSubmitEditorFactoryPrivate {
+ BaseVCSSubmitEditorFactoryPrivate(const VCSBaseSubmitEditorParameters *parameters);
+
+ const VCSBaseSubmitEditorParameters *m_parameters;
+ const QString m_kind;
+ const QStringList m_mimeTypes;
+};
+
+BaseVCSSubmitEditorFactoryPrivate::BaseVCSSubmitEditorFactoryPrivate(const VCSBaseSubmitEditorParameters *parameters) :
+ m_parameters(parameters),
+ m_kind(QLatin1String(parameters->kind)),
+ m_mimeTypes(QLatin1String(parameters->mimeType))
+{
+}
+
+BaseVCSSubmitEditorFactory::BaseVCSSubmitEditorFactory(const VCSBaseSubmitEditorParameters *parameters) :
+ m_d(new BaseVCSSubmitEditorFactoryPrivate(parameters))
+{
+}
+
+BaseVCSSubmitEditorFactory::~BaseVCSSubmitEditorFactory()
+{
+ delete m_d;
+}
+
+Core::IEditor *BaseVCSSubmitEditorFactory::createEditor(QWidget *parent)
+{
+ return createBaseSubmitEditor(m_d->m_parameters, parent);
+}
+
+QString BaseVCSSubmitEditorFactory::kind() const
+{
+ return m_d->m_kind;
+}
+
+QStringList BaseVCSSubmitEditorFactory::mimeTypes() const
+{
+ return m_d->m_mimeTypes;
+}
+
+Core::IFile *BaseVCSSubmitEditorFactory::open(const QString &fileName)
+{
+ Core::ICore *core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>();
+ if (Core::IEditor *iface = core->editorManager()->openEditor(fileName, kind()))
+ return iface->file();
+ return 0;
+}
+
+}
diff --git a/src/plugins/vcsbase/basevcssubmiteditorfactory.h b/src/plugins/vcsbase/basevcssubmiteditorfactory.h
new file mode 100644
index 0000000000..d258e30571
--- /dev/null
+++ b/src/plugins/vcsbase/basevcssubmiteditorfactory.h
@@ -0,0 +1,100 @@
+/***************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+**
+** Non-Open Source Usage
+**
+** Licensees may use this file in accordance with the Qt Beta Version
+** License Agreement, Agreement version 2.2 provided with the Software or,
+** alternatively, in accordance with the terms contained in a written
+** agreement between you and Nokia.
+**
+** GNU General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the packaging
+** of this file. Please review the following information to ensure GNU
+** General Public Licensing requirements will be met:
+**
+** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt GPL Exception version
+** 1.2, included in the file GPL_EXCEPTION.txt in this package.
+**
+***************************************************************************/
+#ifndef VCSBaseBASEEDITORFACTORY_H
+#define VCSBaseBASEEDITORFACTORY_H
+
+#include "vcsbase_global.h"
+
+#include <coreplugin/editormanager/ieditorfactory.h>
+
+namespace VCSBase {
+
+class VCSBaseSubmitEditor;
+struct VCSBaseSubmitEditorParameters;
+struct BaseVCSSubmitEditorFactoryPrivate;
+
+// Parametrizable base class for editor factories creating instances of
+// VCSBaseSubmitEditor subclasses.
+class VCSBASE_EXPORT BaseVCSSubmitEditorFactory : public Core::IEditorFactory
+{
+ Q_OBJECT
+
+protected:
+ explicit BaseVCSSubmitEditorFactory(const VCSBaseSubmitEditorParameters *parameters);
+
+public:
+ virtual ~BaseVCSSubmitEditorFactory();
+
+ virtual Core::IEditor *createEditor(QWidget *parent);
+ virtual QString kind() const;
+ virtual QStringList mimeTypes() const;
+ Core::IFile *open(const QString &fileName);
+
+private:
+ virtual VCSBaseSubmitEditor
+ *createBaseSubmitEditor(const VCSBaseSubmitEditorParameters *parameters,
+ QWidget *parent) = 0;
+
+ BaseVCSSubmitEditorFactoryPrivate *m_d;
+};
+
+// Utility template to create an editor that has a constructor taking the
+// parameter struct and a parent widget.
+
+template <class Editor>
+class VCSSubmitEditorFactory : public BaseVCSSubmitEditorFactory
+{
+public:
+ explicit VCSSubmitEditorFactory(const VCSBaseSubmitEditorParameters *parameters);
+
+private:
+ virtual VCSBaseSubmitEditor
+ *createBaseSubmitEditor(const VCSBaseSubmitEditorParameters *parameters,
+ QWidget *parent);
+};
+
+template <class Editor>
+VCSSubmitEditorFactory<Editor>::VCSSubmitEditorFactory(const VCSBaseSubmitEditorParameters *parameters) :
+ BaseVCSSubmitEditorFactory(parameters)
+{
+}
+
+template <class Editor>
+VCSBaseSubmitEditor *VCSSubmitEditorFactory<Editor>::createBaseSubmitEditor(const VCSBaseSubmitEditorParameters *parameters,
+ QWidget *parent)
+{
+ return new Editor(parameters, parent);
+}
+}
+
+#endif // VCSBaseBASEEDITOR_H
diff --git a/src/plugins/vcsbase/diffhighlighter.cpp b/src/plugins/vcsbase/diffhighlighter.cpp
new file mode 100644
index 0000000000..7da9f6df91
--- /dev/null
+++ b/src/plugins/vcsbase/diffhighlighter.cpp
@@ -0,0 +1,119 @@
+/***************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+**
+** Non-Open Source Usage
+**
+** Licensees may use this file in accordance with the Qt Beta Version
+** License Agreement, Agreement version 2.2 provided with the Software or,
+** alternatively, in accordance with the terms contained in a written
+** agreement between you and Nokia.
+**
+** GNU General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the packaging
+** of this file. Please review the following information to ensure GNU
+** General Public Licensing requirements will be met:
+**
+** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt GPL Exception version
+** 1.2, included in the file GPL_EXCEPTION.txt in this package.
+**
+***************************************************************************/
+#include "diffhighlighter.h"
+
+#include <QtCore/QDebug>
+#include <QtCore/QtAlgorithms>
+#include <QtCore/QRegExp>
+
+namespace VCSBase {
+
+// Formats used by DiffHighlighter
+enum DiffFormats {
+ DiffTextFormat,
+ DiffInFormat,
+ DiffOutFormat,
+ DiffFileFormat,
+ DiffLocationFormat,
+ NumDiffFormats
+};
+
+// --- DiffHighlighterPrivate
+struct DiffHighlighterPrivate {
+ DiffHighlighterPrivate(const QRegExp &filePattern);
+ inline DiffFormats analyzeLine(const QString &block) const;
+
+ const QRegExp m_filePattern;
+ const QString m_locationIndicator;
+ const QChar m_diffInIndicator;
+ const QChar m_diffOutIndicator;
+ QTextCharFormat m_formats[NumDiffFormats];
+};
+
+DiffHighlighterPrivate::DiffHighlighterPrivate(const QRegExp &filePattern) :
+ m_filePattern(filePattern),
+ m_locationIndicator(QLatin1String("@@")),
+ m_diffInIndicator(QLatin1Char('+')),
+ m_diffOutIndicator(QLatin1Char('-'))
+{
+ Q_ASSERT(filePattern.isValid());
+}
+
+DiffFormats DiffHighlighterPrivate::analyzeLine(const QString &text) const
+{
+ // Do not match on git "--- a/" as a deleted line, check
+ // file first
+ if (m_filePattern.exactMatch(text))
+ return DiffFileFormat;
+ if (text.startsWith(m_diffInIndicator))
+ return DiffInFormat;
+ if (text.startsWith(m_diffOutIndicator))
+ return DiffOutFormat;
+ if (text.startsWith(m_locationIndicator))
+ return DiffLocationFormat;
+ return DiffTextFormat;
+}
+
+// --- DiffHighlighter
+DiffHighlighter::DiffHighlighter(const QRegExp &filePattern,
+ QTextDocument *document) :
+ QSyntaxHighlighter(document),
+ m_d(new DiffHighlighterPrivate(filePattern))
+{
+}
+
+DiffHighlighter::~DiffHighlighter()
+{
+ delete m_d;
+}
+
+void DiffHighlighter::highlightBlock(const QString &text)
+{
+ if (text.isEmpty())
+ return;
+
+ const DiffFormats format = m_d->analyzeLine(text);
+ if (format != DiffTextFormat)
+ setFormat(0, text.length(), m_d->m_formats[format]);
+}
+
+void DiffHighlighter::setFormats(const QVector<QTextCharFormat> &s)
+{
+ if (s.size() == NumDiffFormats) {
+ qCopy(s.constBegin(), s.constEnd(), m_d->m_formats);
+ } else {
+ qWarning("%s: insufficient setting size: %d", Q_FUNC_INFO, s.size());
+ }
+}
+
+} // namespace VCSBase
diff --git a/src/plugins/vcsbase/diffhighlighter.h b/src/plugins/vcsbase/diffhighlighter.h
new file mode 100644
index 0000000000..eae25797bb
--- /dev/null
+++ b/src/plugins/vcsbase/diffhighlighter.h
@@ -0,0 +1,91 @@
+/***************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+**
+** Non-Open Source Usage
+**
+** Licensees may use this file in accordance with the Qt Beta Version
+** License Agreement, Agreement version 2.2 provided with the Software or,
+** alternatively, in accordance with the terms contained in a written
+** agreement between you and Nokia.
+**
+** GNU General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the packaging
+** of this file. Please review the following information to ensure GNU
+** General Public Licensing requirements will be met:
+**
+** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt GPL Exception version
+** 1.2, included in the file GPL_EXCEPTION.txt in this package.
+**
+***************************************************************************/
+#ifndef DIFFHIGHLIGHTER_H
+#define DIFFHIGHLIGHTER_H
+
+#include "vcsbase_global.h"
+
+#include <QtGui/QSyntaxHighlighter>
+#include <QtGui/QTextCharFormat>
+#include <QtCore/QVector>
+
+QT_BEGIN_NAMESPACE
+class QRegExp;
+QT_END_NAMESPACE
+
+namespace Core {
+ class ICore;
+}
+namespace TextEditor {
+ class FontSettingsPage;
+}
+
+namespace VCSBase {
+
+struct DiffHighlighterPrivate;
+
+/* A highlighter for diffs. Parametrizable by the file indicator,
+ * which is for example '^====' in case of p4:
+ * \code
+ ==== //depot/research/main/qdynamicmainwindow3/qdynamicdockwidgetlayout_p.h#34 (text) ====
+ * \endcode
+ * Or '--- a/|'+++ b/' in case of git:
+ * \code
+ diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro
+ index 9401ee7..ef35c3b 100644
+ --- a/src/plugins/plugins.pro
+ +++ b/src/plugins/plugins.pro
+ @@ -10,6 +10,7 @@ SUBDIRS = plugin_coreplugin \
+ * \endcode
+ * */
+
+class VCSBASE_EXPORT DiffHighlighter : public QSyntaxHighlighter
+{
+ Q_OBJECT
+public:
+ explicit DiffHighlighter(const QRegExp &filePattern,
+ QTextDocument *document = 0);
+ virtual ~DiffHighlighter();
+
+ virtual void highlightBlock(const QString &text);
+
+ // Set formats from a sequence of type QTextCharFormat
+ void setFormats(const QVector<QTextCharFormat> &s);
+
+private:
+ DiffHighlighterPrivate *m_d;
+};
+
+} //namespace VCSBase
+
+#endif // DIFFHIGHLIGHTER_H
diff --git a/src/plugins/vcsbase/submiteditorfile.cpp b/src/plugins/vcsbase/submiteditorfile.cpp
new file mode 100644
index 0000000000..adb8273207
--- /dev/null
+++ b/src/plugins/vcsbase/submiteditorfile.cpp
@@ -0,0 +1,71 @@
+/***************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+**
+** Non-Open Source Usage
+**
+** Licensees may use this file in accordance with the Qt Beta Version
+** License Agreement, Agreement version 2.2 provided with the Software or,
+** alternatively, in accordance with the terms contained in a written
+** agreement between you and Nokia.
+**
+** GNU General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the packaging
+** of this file. Please review the following information to ensure GNU
+** General Public Licensing requirements will be met:
+**
+** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt GPL Exception version
+** 1.2, included in the file GPL_EXCEPTION.txt in this package.
+**
+***************************************************************************/
+#include "submiteditorfile.h"
+
+namespace VCSBase {
+namespace Internal {
+
+SubmitEditorFile::SubmitEditorFile(const QString &mimeType,
+ QObject *parent) :
+ Core::IFile(parent),
+ m_mimeType(mimeType),
+ m_modified(false)
+{
+}
+
+void SubmitEditorFile::setFileName(const QString name)
+{
+ m_fileName = name;
+}
+
+void SubmitEditorFile::setModified(bool modified)
+{
+ if (m_modified == modified)
+ return;
+ m_modified = modified;
+ emit changed();
+}
+
+bool SubmitEditorFile::save(const QString &fileName)
+{
+ emit saveMe(fileName);
+ return true;
+}
+
+QString SubmitEditorFile::mimeType() const
+{
+ return m_mimeType;
+}
+
+}
+}
diff --git a/src/plugins/vcsbase/submiteditorfile.h b/src/plugins/vcsbase/submiteditorfile.h
new file mode 100644
index 0000000000..f1f2183fce
--- /dev/null
+++ b/src/plugins/vcsbase/submiteditorfile.h
@@ -0,0 +1,77 @@
+/***************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+**
+** Non-Open Source Usage
+**
+** Licensees may use this file in accordance with the Qt Beta Version
+** License Agreement, Agreement version 2.2 provided with the Software or,
+** alternatively, in accordance with the terms contained in a written
+** agreement between you and Nokia.
+**
+** GNU General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the packaging
+** of this file. Please review the following information to ensure GNU
+** General Public Licensing requirements will be met:
+**
+** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt GPL Exception version
+** 1.2, included in the file GPL_EXCEPTION.txt in this package.
+**
+***************************************************************************/
+#ifndef SUBMITEDITORFILE_H
+#define SUBMITEDITORFILE_H
+
+#include <coreplugin/ifile.h>
+
+namespace VCSBase {
+namespace Internal {
+
+// A non-saveable IFile for submit editor files.
+class SubmitEditorFile : public Core::IFile
+{
+ Q_OBJECT
+public:
+ explicit SubmitEditorFile(const QString &mimeType,
+ QObject *parent = 0);
+
+ QString fileName() const { return m_fileName; }
+ QString defaultPath() const { return QString(); }
+ QString suggestedFileName() const { return QString(); }
+
+ bool isModified() const { return m_modified; }
+ virtual QString mimeType() const;
+ bool isReadOnly() const { return false; }
+ bool isSaveAsAllowed() const { return false; }
+ bool save(const QString &fileName);
+ void modified(ReloadBehavior * /*behavior*/) { return; }
+
+ void setFileName(const QString name);
+ void setModified(bool modified = true);
+
+signals:
+ void changed();
+ void saveMe(const QString &fileName);
+
+private:
+ const QString m_mimeType;
+ bool m_modified;
+ QString m_fileName;
+};
+
+
+} // namespace Internal
+}
+
+#endif // SUBMITEDITORFILE_H
diff --git a/src/plugins/vcsbase/vcsbase.pri b/src/plugins/vcsbase/vcsbase.pri
new file mode 100644
index 0000000000..56f7418c66
--- /dev/null
+++ b/src/plugins/vcsbase/vcsbase.pri
@@ -0,0 +1,3 @@
+include(vcsbase_dependencies.pri)
+
+LIBS *= -l$$qtLibraryTarget(VCSBase)
diff --git a/src/plugins/vcsbase/vcsbase.pro b/src/plugins/vcsbase/vcsbase.pro
new file mode 100644
index 0000000000..329e27b068
--- /dev/null
+++ b/src/plugins/vcsbase/vcsbase.pro
@@ -0,0 +1,31 @@
+TEMPLATE = lib
+TARGET = VCSBase
+
+DEFINES += VCSBASE_LIBRARY
+
+include(../../qworkbenchplugin.pri)
+include(vcsbase_dependencies.pri)
+
+HEADERS += vcsbase_global.h \
+vcsbaseconstants.h \
+vcsbaseplugin.h \
+baseannotationhighlighter.h \
+diffhighlighter.h \
+vcsbasetextdocument.h \
+vcsbaseeditor.h \
+vcsbasesubmiteditor.h \
+basevcseditorfactory.h \
+submiteditorfile.h \
+basevcssubmiteditorfactory.h
+
+SOURCES += vcsbaseplugin.cpp \
+baseannotationhighlighter.cpp \
+diffhighlighter.cpp \
+vcsbasetextdocument.cpp \
+vcsbaseeditor.cpp \
+vcsbasesubmiteditor.cpp \
+basevcseditorfactory.cpp \
+submiteditorfile.cpp \
+basevcssubmiteditorfactory.cpp
+
+RESOURCES=vcsbase.qrc
diff --git a/src/plugins/vcsbase/vcsbase.qrc b/src/plugins/vcsbase/vcsbase.qrc
new file mode 100644
index 0000000000..648425980a
--- /dev/null
+++ b/src/plugins/vcsbase/vcsbase.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/trolltech.vcsbase" >
+ <file>VCSBase.mimetypes.xml</file>
+ </qresource>
+</RCC>
diff --git a/src/plugins/vcsbase/vcsbase_dependencies.pri b/src/plugins/vcsbase/vcsbase_dependencies.pri
new file mode 100644
index 0000000000..3a68ac9600
--- /dev/null
+++ b/src/plugins/vcsbase/vcsbase_dependencies.pri
@@ -0,0 +1,4 @@
+include(../../plugins/coreplugin/coreplugin.pri)
+include(../../plugins/texteditor/texteditor.pri)
+include(../../plugins/projectexplorer/projectexplorer.pri)
+include(../../plugins/find/find.pri)
diff --git a/src/plugins/vcsbase/vcsbase_global.h b/src/plugins/vcsbase/vcsbase_global.h
new file mode 100644
index 0000000000..191587af6f
--- /dev/null
+++ b/src/plugins/vcsbase/vcsbase_global.h
@@ -0,0 +1,57 @@
+/***************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+**
+** Non-Open Source Usage
+**
+** Licensees may use this file in accordance with the Qt Beta Version
+** License Agreement, Agreement version 2.2 provided with the Software or,
+** alternatively, in accordance with the terms contained in a written
+** agreement between you and Nokia.
+**
+** GNU General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the packaging
+** of this file. Please review the following information to ensure GNU
+** General Public Licensing requirements will be met:
+**
+** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt GPL Exception version
+** 1.2, included in the file GPL_EXCEPTION.txt in this package.
+**
+***************************************************************************/
+/****************************************************************************
+**
+** Copyright (C) 1992-$THISYEAR$ Trolltech AS. All rights reserved.
+**
+** This file is part of the $MODULE$ of the Qt Toolkit.
+**
+** $LICENSE$
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+****************************************************************************/
+
+#ifndef VCSBASEGLOBAL_H
+#define VCSBASEGLOBAL_H
+
+#include <QtCore/qglobal.h>
+
+#if defined(VCSBASE_LIBRARY)
+# define VCSBASE_EXPORT Q_DECL_EXPORT
+#else
+# define VCSBASE_EXPORT Q_DECL_IMPORT
+#endif
+
+#endif // VCSBASEGLOBAL_H
diff --git a/src/plugins/vcsbase/vcsbaseconstants.h b/src/plugins/vcsbase/vcsbaseconstants.h
new file mode 100644
index 0000000000..bbe6003ed1
--- /dev/null
+++ b/src/plugins/vcsbase/vcsbaseconstants.h
@@ -0,0 +1,46 @@
+/***************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+**
+** Non-Open Source Usage
+**
+** Licensees may use this file in accordance with the Qt Beta Version
+** License Agreement, Agreement version 2.2 provided with the Software or,
+** alternatively, in accordance with the terms contained in a written
+** agreement between you and Nokia.
+**
+** GNU General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the packaging
+** of this file. Please review the following information to ensure GNU
+** General Public Licensing requirements will be met:
+**
+** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt GPL Exception version
+** 1.2, included in the file GPL_EXCEPTION.txt in this package.
+**
+***************************************************************************/
+#ifndef VCSBaseCONSTANTS_H
+#define VCSBaseCONSTANTS_H
+
+namespace VCSBase {
+ namespace Constants {
+
+ namespace Internal {
+
+ enum { debug = 0 };
+ } // namespace Internal
+ } // namespace Constants
+} // VCSBase
+
+#endif // VCSBaseCONSTANTS_H
diff --git a/src/plugins/vcsbase/vcsbaseeditor.cpp b/src/plugins/vcsbase/vcsbaseeditor.cpp
new file mode 100644
index 0000000000..9dfc9b12db
--- /dev/null
+++ b/src/plugins/vcsbase/vcsbaseeditor.cpp
@@ -0,0 +1,486 @@
+/***************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+**
+** Non-Open Source Usage
+**
+** Licensees may use this file in accordance with the Qt Beta Version
+** License Agreement, Agreement version 2.2 provided with the Software or,
+** alternatively, in accordance with the terms contained in a written
+** agreement between you and Nokia.
+**
+** GNU General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the packaging
+** of this file. Please review the following information to ensure GNU
+** General Public Licensing requirements will be met:
+**
+** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt GPL Exception version
+** 1.2, included in the file GPL_EXCEPTION.txt in this package.
+**
+***************************************************************************/
+#include "vcsbaseeditor.h"
+#include "diffhighlighter.h"
+#include "baseannotationhighlighter.h"
+#include "vcsbasetextdocument.h"
+#include "vcsbaseconstants.h"
+
+#include <coreplugin/icore.h>
+#include <coreplugin/uniqueidmanager.h>
+#include <coreplugin/editormanager/editormanager.h>
+#include <texteditor/fontsettings.h>
+#include <texteditor/texteditorconstants.h>
+
+#include <projectexplorer/projectexplorer.h>
+#include <projectexplorer/session.h>
+#include <projectexplorer/editorconfiguration.h>
+
+#include <QtCore/QFileInfo>
+#include <QtCore/QTextStream>
+#include <QtCore/QSet>
+#include <QtCore/QRegExp>
+#include <QtCore/QDebug>
+#include <QtCore/QTextCodec>
+#include <QtGui/QKeyEvent>
+#include <QtGui/QLayout>
+#include <QtGui/QTextEdit>
+#include <QtGui/QMenu>
+#include <QtGui/QAction>
+#include <QtGui/QTextCursor>
+#include <QtCore/QProcess>
+
+namespace VCSBase {
+
+// VCSBaseEditorEditable: An editable with no support for duplicates
+class VCSBaseEditorEditable : public TextEditor::BaseTextEditorEditable
+{
+public:
+ VCSBaseEditorEditable(VCSBaseEditor *,
+ const VCSBaseEditorParameters *type,
+ Core::ICore *);
+ QList<int> context() const;
+
+ bool duplicateSupported() const { return false; }
+ Core::IEditor *duplicate(QWidget * /*parent*/) { return 0; }
+ const char *kind() const { return m_kind; }
+
+private:
+ const char *m_kind;
+ QList<int> m_context;
+
+};
+
+VCSBaseEditorEditable::VCSBaseEditorEditable(VCSBaseEditor *editor,
+ const VCSBaseEditorParameters *type,
+ Core::ICore *core) :
+ BaseTextEditorEditable(editor),
+ m_kind(type->kind)
+{
+ m_context << core->uniqueIDManager()->uniqueIdentifier(QLatin1String(type->context))
+ << core->uniqueIDManager()->uniqueIdentifier(QLatin1String(TextEditor::Constants::C_TEXTEDITOR));
+
+}
+
+QList<int> VCSBaseEditorEditable::context() const
+{
+ return m_context;
+}
+
+// ----------- VCSBaseEditorPrivate
+
+struct VCSBaseEditorPrivate {
+ VCSBaseEditorPrivate(const VCSBaseEditorParameters *type, QObject *parent);
+
+ const VCSBaseEditorParameters *m_parameters;
+ QAction *m_describeAction;
+ QString m_currentChange;
+ Core::ICore *m_core;
+ QString m_source;
+};
+
+VCSBaseEditorPrivate::VCSBaseEditorPrivate(const VCSBaseEditorParameters *type, QObject *parent) :
+ m_parameters(type),
+ m_describeAction(new QAction(parent)),
+ m_core(ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>())
+{
+}
+
+// ------------ VCSBaseEditor
+VCSBaseEditor::VCSBaseEditor(const VCSBaseEditorParameters *type,
+ QWidget *parent) :
+ BaseTextEditor(parent),
+ m_d(new VCSBaseEditorPrivate(type, this))
+{
+ if (VCSBase::Constants::Internal::debug)
+ qDebug() << "VCSBaseEditor::VCSBaseEditor" << type->type << type->kind;
+
+ setReadOnly(true);
+
+ connect(m_d->m_describeAction, SIGNAL(triggered()), this, SLOT(describe()));
+
+ viewport()->setMouseTracking(true);
+
+ setBaseTextDocument(new Internal::VCSBaseTextDocument);
+
+ setMimeType(QLatin1String(m_d->m_parameters->mimeType));
+}
+
+void VCSBaseEditor::init()
+{
+ switch (m_d->m_parameters->type) {
+ case RegularCommandOutput:
+ case LogOutput:
+ case AnnotateOutput:
+ // Annotation highlighting depends on contents, which is set later on
+ connect(this, SIGNAL(textChanged()), this, SLOT(slotActivateAnnotation()));
+ break;
+ case DiffOutput:
+ baseTextDocument()->setSyntaxHighlighter(createDiffHighlighter());
+ break;
+ }
+}
+
+VCSBaseEditor::~VCSBaseEditor()
+{
+ delete m_d;
+}
+
+QString VCSBaseEditor::source() const
+{
+ return m_d->m_source;
+}
+
+void VCSBaseEditor::setSource(const QString &source)
+{
+ m_d->m_source = source;
+}
+
+QTextCodec *VCSBaseEditor::codec() const
+{
+ return baseTextDocument()->codec();
+}
+
+void VCSBaseEditor::setCodec(QTextCodec *c)
+{
+ if (c) {
+ baseTextDocument()->setCodec(c);
+ } else {
+ qWarning("%s: Attempt to set 0 codec.", Q_FUNC_INFO);
+ }
+}
+
+EditorContentType VCSBaseEditor::contentType() const
+{
+ return m_d->m_parameters->type;
+}
+
+bool VCSBaseEditor::isModified() const
+{
+ return false;
+}
+
+TextEditor::BaseTextEditorEditable *VCSBaseEditor::createEditableInterface()
+{
+ return new VCSBaseEditorEditable(this, m_d->m_parameters, m_d->m_core);
+}
+
+void VCSBaseEditor::contextMenuEvent(QContextMenuEvent *e)
+{
+ QMenu *menu = createStandardContextMenu();
+ // 'click on change-interaction'
+ if (m_d->m_parameters->type == LogOutput || m_d->m_parameters->type == AnnotateOutput) {
+ m_d->m_currentChange = changeUnderCursor(cursorForPosition(e->pos()));
+ if (!m_d->m_currentChange.isEmpty()) {
+ m_d->m_describeAction->setText(tr("Describe change %1").arg(m_d->m_currentChange));
+ menu->addSeparator();
+ menu->addAction(m_d->m_describeAction);
+ }
+ }
+ menu->exec(e->globalPos());
+ delete menu;
+}
+
+void VCSBaseEditor::mouseMoveEvent(QMouseEvent *e)
+{
+ if (m_d->m_parameters->type == LogOutput || m_d->m_parameters->type == AnnotateOutput) {
+ // Link emulation behaviour for 'click on change-interaction'
+ QTextCursor cursor = cursorForPosition(e->pos());
+ QString change = changeUnderCursor(cursor);
+ if (!change.isEmpty()) {
+ QTextEdit::ExtraSelection sel;
+ sel.cursor = cursor;
+ sel.cursor.select(QTextCursor::WordUnderCursor);
+ sel.format.setFontUnderline(true);
+ change = changeUnderCursor(cursor);
+ sel.format.setProperty(QTextFormat::UserProperty, change);
+ bool found = false;
+ foreach (QTextEdit::ExtraSelection es, extraSelections()) {
+ if (es.format.stringProperty(QTextFormat::UserProperty) == sel.format.stringProperty(QTextFormat::UserProperty)) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ setExtraSelections(QList<QTextEdit::ExtraSelection>() << sel);
+ viewport()->setCursor(Qt::PointingHandCursor);
+ }
+ } else {
+ if (!extraSelections().isEmpty()) {
+ setExtraSelections(QList<QTextEdit::ExtraSelection>());
+ viewport()->setCursor(Qt::IBeamCursor);
+ }
+ }
+ }
+ TextEditor::BaseTextEditor::mouseMoveEvent(e);
+}
+
+void VCSBaseEditor::mouseReleaseEvent(QMouseEvent *e)
+{
+ if (m_d->m_parameters->type == LogOutput || m_d->m_parameters->type == AnnotateOutput) {
+ if (e->button() == Qt::LeftButton &&!(e->modifiers() & Qt::ShiftModifier)) {
+ QTextCursor cursor = cursorForPosition(e->pos());
+ m_d->m_currentChange = changeUnderCursor(cursor);
+ if (!m_d->m_currentChange.isEmpty()) {
+ describe();
+ e->accept();
+ return;
+ }
+ }
+ }
+ TextEditor::BaseTextEditor::mouseReleaseEvent(e);
+}
+
+void VCSBaseEditor::mouseDoubleClickEvent(QMouseEvent *e)
+{
+ if (m_d->m_parameters->type == DiffOutput) {
+ if (e->button() == Qt::LeftButton &&!(e->modifiers() & Qt::ShiftModifier)) {
+ QTextCursor cursor = cursorForPosition(e->pos());
+ jumpToChangeFromDiff(cursor);
+ }
+ }
+ TextEditor::BaseTextEditor::mouseDoubleClickEvent(e);
+}
+
+void VCSBaseEditor::keyPressEvent(QKeyEvent *e)
+{
+ if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return) {
+ jumpToChangeFromDiff(textCursor());
+ return;
+ }
+ BaseTextEditor::keyPressEvent(e);
+}
+
+void VCSBaseEditor::describe()
+{
+ if (VCSBase::Constants::Internal::debug)
+ qDebug() << "VCSBaseEditor::describe" << m_d->m_currentChange;
+ if (!m_d->m_currentChange.isEmpty())
+ emit describeRequested(m_d->m_source, m_d->m_currentChange);
+}
+
+void VCSBaseEditor::slotActivateAnnotation()
+{
+ // The annotation highlighting depends on contents (change number
+ // set with assigned colors)
+ if (m_d->m_parameters->type != AnnotateOutput)
+ return;
+
+ const QSet<QString> changes = annotationChanges();
+ if (changes.isEmpty())
+ return;
+ if (VCSBase::Constants::Internal::debug)
+ qDebug() << "VCSBaseEditor::slotActivateAnnotation(): #" << changes.size();
+
+ disconnect(this, SIGNAL(textChanged()), this, SLOT(slotActivateAnnotation()));
+
+ if (BaseAnnotationHighlighter *ah = qobject_cast<BaseAnnotationHighlighter *>(baseTextDocument()->syntaxHighlighter())) {
+ ah->setChangeNumbers(changes);
+ ah->rehighlight();
+ } else {
+ baseTextDocument()->setSyntaxHighlighter(createAnnotationHighlighter(changes));
+ }
+}
+
+// Check for a change chunk "@@ -91,7 +95,7 @@" and return
+// the modified line number (95).
+// Note that git appends stuff after " @@" (function names, etc.).
+static inline bool checkChunkLine(const QString &line, int *modifiedLineNumber)
+{
+ if (!line.startsWith(QLatin1String("@@ ")))
+ return false;
+ const int endPos = line.indexOf(QLatin1String(" @@"), 3);
+ if (endPos == -1)
+ return false;
+ // the first chunk range applies to the original file, the second one to
+ // the modified file, the one we're interested int
+ const int plusPos = line.indexOf(QLatin1Char('+'), 3);
+ if (plusPos == -1 || plusPos > endPos)
+ return false;
+ const int lineNumberPos = plusPos + 1;
+ const int commaPos = line.indexOf(QLatin1Char(','), lineNumberPos);
+ if (commaPos == -1 || commaPos > endPos)
+ return false;
+ const QString lineNumberStr = line.mid(lineNumberPos, commaPos - lineNumberPos);
+ bool ok;
+ *modifiedLineNumber = lineNumberStr.toInt(&ok);
+ return ok;
+}
+
+void VCSBaseEditor::jumpToChangeFromDiff(QTextCursor cursor)
+{
+ int chunkStart = 0;
+ int lineCount = -1;
+ const QChar deletionIndicator = QLatin1Char('-');
+ // find nearest change hunk
+ QTextBlock block = cursor.block();
+ for ( ; block.isValid() ; block = block.previous()) {
+ const QString line = block.text();
+ if (checkChunkLine(line, &chunkStart)) {
+ break;
+ } else {
+ if (!line.startsWith(deletionIndicator))
+ ++lineCount;
+ }
+ }
+
+ if (VCSBase::Constants::Internal::debug)
+ qDebug() << "VCSBaseEditor::jumpToChangeFromDiff()1" << chunkStart << lineCount;
+
+ if (chunkStart == -1 || lineCount < 0 || !block.isValid())
+ return;
+
+ // find the filename in previous line, map depot name back
+ block = block.previous();
+ if (!block.isValid())
+ return;
+ const QString fileName = fileNameFromDiffSpecification(block);
+
+ const bool exists = fileName.isEmpty() ? false : QFile::exists(fileName);
+
+ if (VCSBase::Constants::Internal::debug)
+ qDebug() << "VCSBaseEditor::jumpToChangeFromDiff()2" << fileName << "ex=" << exists << "line" << chunkStart << lineCount;
+
+ if (!exists)
+ return;
+
+ Core::IEditor *ediface = m_d->m_core->editorManager()->openEditor(fileName);
+ m_d->m_core->editorManager()->ensureEditorManagerVisible();
+ if (TextEditor::ITextEditor *editor = qobject_cast<TextEditor::ITextEditor *>(ediface))
+ editor->gotoLine(chunkStart + lineCount);
+}
+
+void VCSBaseEditor::setPlainTextData(const QByteArray &data)
+{
+ setPlainText(codec()->toUnicode(data));
+}
+
+void VCSBaseEditor::setFontSettings(const TextEditor::FontSettings &fs)
+{
+ TextEditor::BaseTextEditor::setFontSettings(fs);
+ if (m_d->m_parameters->type == DiffOutput) {
+ if (DiffHighlighter *highlighter = qobject_cast<DiffHighlighter*>(baseTextDocument()->syntaxHighlighter())) {
+ static QVector<QString> categories;
+ if (categories.isEmpty()) {
+ categories << QLatin1String(TextEditor::Constants::C_TEXT)
+ << QLatin1String(TextEditor::Constants::C_ADDED_LINE)
+ << QLatin1String(TextEditor::Constants::C_REMOVED_LINE)
+ << QLatin1String(TextEditor::Constants::C_DIFF_FILE)
+ << QLatin1String(TextEditor::Constants::C_DIFF_LOCATION);
+ }
+ highlighter->setFormats(fs.toTextCharFormats(categories));
+ highlighter->rehighlight();
+ }
+ }
+}
+
+const VCSBaseEditorParameters *VCSBaseEditor::findType(const VCSBaseEditorParameters *array,
+ int arraySize,
+ EditorContentType et)
+{
+ for (int i = 0; i < arraySize; i++)
+ if (array[i].type == et)
+ return array + i;
+ return 0;
+}
+
+// Find the codec used for a file querying the editor.
+static QTextCodec *findFileCodec(const Core::ICore *core, const QString &source)
+{
+ typedef QList<Core::IEditor *> EditorList;
+
+ const EditorList editors = core->editorManager()->editorsForFileName(source);
+ if (!editors.empty()) {
+ const EditorList::const_iterator ecend = editors.constEnd();
+ for (EditorList::const_iterator it = editors.constBegin(); it != ecend; ++it)
+ if (const TextEditor::BaseTextEditorEditable *be = qobject_cast<const TextEditor::BaseTextEditorEditable *>(*it)) {
+ QTextCodec *codec = be->editor()->textCodec();
+ if (VCSBase::Constants::Internal::debug)
+ qDebug() << Q_FUNC_INFO << source << codec->name();
+ return codec;
+ }
+ }
+ if (VCSBase::Constants::Internal::debug)
+ qDebug() << Q_FUNC_INFO << source << "not found";
+ return 0;
+}
+
+// Find the codec by checking the projects (root dir of project file)
+static QTextCodec *findProjectCodec(const QString &dir)
+{
+ typedef QList<ProjectExplorer::Project*> ProjectList;
+ // Try to find a project under which file tree the file is.
+ const ProjectExplorer::SessionManager *sm = ProjectExplorer::ProjectExplorerPlugin::instance()->session();
+ const ProjectList projects = sm->projects();
+ if (!projects.empty()) {
+ const ProjectList::const_iterator pcend = projects.constEnd();
+ for (ProjectList::const_iterator it = projects.constBegin(); it != pcend; ++it)
+ if (const Core::IFile *file = (*it)->file())
+ if (file->fileName().startsWith(dir)) {
+ QTextCodec *codec = (*it)->editorConfiguration()->defaultTextCodec();
+ if (VCSBase::Constants::Internal::debug)
+ qDebug() << Q_FUNC_INFO << dir << (*it)->name() << codec->name();
+ return codec;
+ }
+ }
+ if (VCSBase::Constants::Internal::debug)
+ qDebug() << Q_FUNC_INFO << dir << "not found";
+ return 0;
+}
+
+QTextCodec *VCSBaseEditor::getCodec(const Core::ICore *core, const QString &source)
+{
+ if (!source.isEmpty()) {
+ // Check file
+ const QFileInfo sourceFi(source);
+ if (sourceFi.isFile())
+ if (QTextCodec *fc = findFileCodec(core, source))
+ return fc;
+ // Find by project via directory
+ if (QTextCodec *pc = findProjectCodec(sourceFi.isFile() ? sourceFi.absolutePath() : source))
+ return pc;
+ }
+ QTextCodec *sys = QTextCodec::codecForLocale();
+ if (VCSBase::Constants::Internal::debug)
+ qDebug() << Q_FUNC_INFO << source << "defaulting to " << sys->name();
+ return sys;
+}
+
+VCSBaseEditor *VCSBaseEditor::getVcsBaseEditor(const Core::IEditor *editor)
+{
+ if (const TextEditor::BaseTextEditorEditable *be = qobject_cast<const TextEditor::BaseTextEditorEditable *>(editor))
+ return qobject_cast<VCSBaseEditor *>(be->editor());
+ return 0;
+}
+
+}
diff --git a/src/plugins/vcsbase/vcsbaseeditor.h b/src/plugins/vcsbase/vcsbaseeditor.h
new file mode 100644
index 0000000000..364a9fb7e9
--- /dev/null
+++ b/src/plugins/vcsbase/vcsbaseeditor.h
@@ -0,0 +1,173 @@
+/***************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+**
+** Non-Open Source Usage
+**
+** Licensees may use this file in accordance with the Qt Beta Version
+** License Agreement, Agreement version 2.2 provided with the Software or,
+** alternatively, in accordance with the terms contained in a written
+** agreement between you and Nokia.
+**
+** GNU General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the packaging
+** of this file. Please review the following information to ensure GNU
+** General Public Licensing requirements will be met:
+**
+** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt GPL Exception version
+** 1.2, included in the file GPL_EXCEPTION.txt in this package.
+**
+***************************************************************************/
+#ifndef VCSBaseBASEEDITOR_H
+#define VCSBaseBASEEDITOR_H
+
+#include "vcsbase_global.h"
+
+#include <texteditor/basetexteditor.h>
+
+#include <QtCore/QSet>
+
+QT_BEGIN_NAMESPACE
+class QAction;
+class QTextCodec;
+class QTextCursor;
+QT_END_NAMESPACE
+
+namespace Core {
+class ICore;
+}
+
+namespace VCSBase {
+
+struct VCSBaseEditorPrivate;
+class DiffHighlighter;
+class BaseAnnotationHighlighter;
+
+// Contents of a VCSBaseEditor
+enum EditorContentType {
+ // No special handling.
+ RegularCommandOutput,
+ // Log of a file under revision control. Provide 'click on change'
+ // description.
+ LogOutput,
+ // <change description>: file line
+ // Color per change number and provide 'click on change' description.
+ AnnotateOutput,
+ // Diff output. Might includes describe output, which consists of a
+ // header and diffs. Interaction is 'double click in hunk' which
+ // opens the file
+ DiffOutput
+};
+
+// Helper struct used to parametrize an editor with mime type, context
+// and kind. The extension is currently only a suggestion when running
+// VCS commands with redirection.
+struct VCSBASE_EXPORT VCSBaseEditorParameters {
+ EditorContentType type;
+ const char *kind;
+ const char *context;
+ const char *mimeType;
+ const char *extension;
+};
+
+// Base class for editors showing version control system output
+// of the type enumerated by EditorContentType.
+// The source property should contain the file or directory the log
+// refers to and will be emitted with describeRequested().
+// This is for VCS that need a current directory.
+class VCSBASE_EXPORT VCSBaseEditor : public TextEditor::BaseTextEditor
+{
+ Q_PROPERTY(QString source READ source WRITE setSource);
+ Q_PROPERTY(QTextCodec *codec READ codec WRITE setCodec);
+ Q_OBJECT
+protected:
+ // Initialization requires calling init() (which in turns calls
+ // virtual functions).
+ explicit VCSBaseEditor(const VCSBaseEditorParameters *type,
+ QWidget *parent);
+public:
+ void init();
+
+ virtual ~VCSBaseEditor();
+
+ QString source() const;
+ void setSource(const QString &source);
+
+ QTextCodec *codec() const;
+ void setCodec(QTextCodec *);
+
+ bool isModified() const;
+
+ EditorContentType contentType() const;
+
+ // Utility to find a parameter set by type in an array.
+ static const VCSBaseEditorParameters *
+ findType(const VCSBaseEditorParameters *array, int arraySize, EditorContentType et);
+
+ // Utility to find the codec for a source (file or directory), querying
+ // the editor manager and the project managers (defaults to system codec).
+ // The codec should be set on editors displaying diff or annotation
+ // output.
+ static QTextCodec *getCodec(const Core::ICore *core, const QString &source);
+
+ // Utility to return the editor from the IEditor returned by the editor
+ // manager which is a BaseTextEditable.
+ static VCSBaseEditor *getVcsBaseEditor(const Core::IEditor *editor);
+
+signals:
+ void describeRequested(const QString &source, const QString &change);
+
+public slots:
+ // Convenience slot to set data read from stdout, will use the
+ // documents' codec to decode
+ void setPlainTextData(const QByteArray &data);
+
+protected:
+ virtual TextEditor::BaseTextEditorEditable *createEditableInterface();
+
+ void contextMenuEvent(QContextMenuEvent *e);
+ void mouseMoveEvent(QMouseEvent *e);
+ void mouseReleaseEvent(QMouseEvent *e);
+ void mouseDoubleClickEvent(QMouseEvent *e);
+ void keyPressEvent(QKeyEvent *);
+
+public slots:
+ void setFontSettings(const TextEditor::FontSettings &);
+
+private slots:
+ void describe();
+ void slotActivateAnnotation();
+
+private:
+ // Implement to return a set of change identifiers in
+ // annotation mode
+ virtual QSet<QString> annotationChanges() const = 0;
+ // Implement to identify a change number at the cursor position
+ virtual QString changeUnderCursor(const QTextCursor &) const = 0;
+ // Factory functions for highlighters
+ virtual DiffHighlighter *createDiffHighlighter() const = 0;
+ virtual BaseAnnotationHighlighter *createAnnotationHighlighter(const QSet<QString> &changes) const = 0;
+ // Implement to return a local file name from the diff file specification
+ // (text cursor at position above change hunk)
+ virtual QString fileNameFromDiffSpecification(const QTextBlock &diffFileSpec) const = 0;
+
+ void jumpToChangeFromDiff(QTextCursor cursor);
+
+ VCSBaseEditorPrivate *m_d;
+};
+
+} // namespace Internal
+
+#endif // VCSBaseBASEEDITOR_H
diff --git a/src/plugins/vcsbase/vcsbaseplugin.cpp b/src/plugins/vcsbase/vcsbaseplugin.cpp
new file mode 100644
index 0000000000..7337ba5d31
--- /dev/null
+++ b/src/plugins/vcsbase/vcsbaseplugin.cpp
@@ -0,0 +1,81 @@
+/***************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+**
+** Non-Open Source Usage
+**
+** Licensees may use this file in accordance with the Qt Beta Version
+** License Agreement, Agreement version 2.2 provided with the Software or,
+** alternatively, in accordance with the terms contained in a written
+** agreement between you and Nokia.
+**
+** GNU General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the packaging
+** of this file. Please review the following information to ensure GNU
+** General Public Licensing requirements will be met:
+**
+** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt GPL Exception version
+** 1.2, included in the file GPL_EXCEPTION.txt in this package.
+**
+***************************************************************************/
+#include "vcsbaseplugin.h"
+#include "diffhighlighter.h"
+
+#include <extensionsystem/pluginmanager.h>
+#include <coreplugin/icore.h>
+#include <coreplugin/coreconstants.h>
+#include <coreplugin/uniqueidmanager.h>
+#include <coreplugin/mimedatabase.h>
+
+#include <QtCore/qplugin.h>
+
+namespace VCSBase {
+namespace Internal {
+
+VCSBasePlugin *VCSBasePlugin::m_instance = 0;
+
+VCSBasePlugin::VCSBasePlugin()
+{
+ m_instance = this;
+}
+
+VCSBasePlugin::~VCSBasePlugin()
+{
+ m_instance = 0;
+}
+
+bool VCSBasePlugin::initialize(const QStringList & /*arguments*/, QString *errorMessage)
+{
+ Core::ICore *core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>();
+
+ if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":/trolltech.vcsbase/VCSBase.mimetypes.xml"), errorMessage))
+ return false;
+
+ return true;
+}
+
+void VCSBasePlugin::extensionsInitialized()
+{
+}
+
+VCSBasePlugin *VCSBasePlugin::instance()
+{
+ return m_instance;
+}
+
+} // namespace Internal
+} // namespace VCSBase
+
+Q_EXPORT_PLUGIN(VCSBase::Internal::VCSBasePlugin)
diff --git a/src/plugins/vcsbase/vcsbaseplugin.h b/src/plugins/vcsbase/vcsbaseplugin.h
new file mode 100644
index 0000000000..c10616ad93
--- /dev/null
+++ b/src/plugins/vcsbase/vcsbaseplugin.h
@@ -0,0 +1,64 @@
+/***************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+**
+** Non-Open Source Usage
+**
+** Licensees may use this file in accordance with the Qt Beta Version
+** License Agreement, Agreement version 2.2 provided with the Software or,
+** alternatively, in accordance with the terms contained in a written
+** agreement between you and Nokia.
+**
+** GNU General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the packaging
+** of this file. Please review the following information to ensure GNU
+** General Public Licensing requirements will be met:
+**
+** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt GPL Exception version
+** 1.2, included in the file GPL_EXCEPTION.txt in this package.
+**
+***************************************************************************/
+#ifndef VCSBASEPLUGIN_H
+#define VCSBASEPLUGIN_H
+
+#include <extensionsystem/iplugin.h>
+
+#include <QtCore/QObject>
+
+namespace VCSBase {
+namespace Internal {
+
+class VCSBasePlugin : public ExtensionSystem::IPlugin
+{
+ Q_OBJECT
+
+public:
+ VCSBasePlugin();
+ ~VCSBasePlugin();
+
+ bool initialize(const QStringList &arguments, QString *error_message);
+
+ void extensionsInitialized();
+
+ static VCSBasePlugin *instance();
+
+private:
+ static VCSBasePlugin *m_instance;
+};
+
+} // namespace Internal
+} // namespace VCSBase
+
+#endif // VCSBASEPLUGIN_H
diff --git a/src/plugins/vcsbase/vcsbasesubmiteditor.cpp b/src/plugins/vcsbase/vcsbasesubmiteditor.cpp
new file mode 100644
index 0000000000..6d271910e6
--- /dev/null
+++ b/src/plugins/vcsbase/vcsbasesubmiteditor.cpp
@@ -0,0 +1,281 @@
+/***************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+**
+** Non-Open Source Usage
+**
+** Licensees may use this file in accordance with the Qt Beta Version
+** License Agreement, Agreement version 2.2 provided with the Software or,
+** alternatively, in accordance with the terms contained in a written
+** agreement between you and Nokia.
+**
+** GNU General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the packaging
+** of this file. Please review the following information to ensure GNU
+** General Public Licensing requirements will be met:
+**
+** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt GPL Exception version
+** 1.2, included in the file GPL_EXCEPTION.txt in this package.
+**
+***************************************************************************/
+#include "vcsbasesubmiteditor.h"
+#include "submiteditorfile.h"
+
+#include <coreplugin/ifile.h>
+#include <coreplugin/icore.h>
+#include <coreplugin/uniqueidmanager.h>
+#include <coreplugin/actionmanager/actionmanagerinterface.h>
+
+#include <utils/submiteditorwidget.h>
+#include <find/basetextfind.h>
+
+#include <QtGui/QToolBar>
+#include <QtGui/QStyle>
+#include <QtCore/QPointer>
+#include <QtCore/QFileInfo>
+#include <QtCore/QFile>
+#include <QtCore/QTextStream>
+#include <QtCore/QDebug>
+
+enum { debug = 0 };
+
+static inline QAction *actionFromId(const Core::ICore *core, const char *id)
+{
+ QAction *rc = 0;
+ if (id)
+ if (const Core::ICommand *cmd = core->actionManager()->command(id))
+ rc = cmd->action();
+ if (debug)
+ qDebug() << Q_FUNC_INFO << id << rc;
+ return rc;
+}
+
+namespace VCSBase {
+
+struct VCSBaseSubmitEditorPrivate {
+ VCSBaseSubmitEditorPrivate(const VCSBaseSubmitEditorParameters *parameters,
+ Core::Utils::SubmitEditorWidget *editorWidget,
+ QObject *q);
+
+ Core::ICore *m_core;
+ Core::Utils::SubmitEditorWidget *m_widget;
+ QToolBar *m_toolWidget;
+ const VCSBaseSubmitEditorParameters *m_parameters;
+ QString m_displayName;
+ VCSBase::Internal::SubmitEditorFile *m_file;
+ QList<int> m_contexts;
+
+ QPointer<QAction> m_undoAction;
+ QPointer<QAction> m_redoAction;
+ QPointer<QAction> m_submitAction;
+ QPointer<QAction> m_diffAction;
+};
+
+VCSBaseSubmitEditorPrivate::VCSBaseSubmitEditorPrivate(const VCSBaseSubmitEditorParameters *parameters,
+ Core::Utils::SubmitEditorWidget *editorWidget,
+ QObject *q) :
+ m_core(ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>()),
+ m_widget(editorWidget),
+ m_toolWidget(0),
+ m_parameters(parameters),
+ m_file(new VCSBase::Internal::SubmitEditorFile(QLatin1String(m_parameters->mimeType), q)),
+ m_undoAction(actionFromId(m_core, m_parameters->undoActionId)),
+ m_redoAction(actionFromId(m_core, m_parameters->redoActionId)),
+ m_submitAction(actionFromId(m_core, m_parameters->submitActionId)),
+ m_diffAction(actionFromId(m_core, m_parameters->diffActionId))
+{
+ m_contexts << m_core->uniqueIDManager()->uniqueIdentifier(m_parameters->context);
+}
+
+VCSBaseSubmitEditor::VCSBaseSubmitEditor(const VCSBaseSubmitEditorParameters *parameters,
+ Core::Utils::SubmitEditorWidget *editorWidget) :
+ m_d(new VCSBaseSubmitEditorPrivate(parameters, editorWidget, this))
+{
+ m_d->m_file->setModified(false);
+ // We are always clean to prevent the editor manager from asking to save.
+ connect(m_d->m_file, SIGNAL(saveMe(QString)), this, SLOT(save(QString)));
+
+ m_d->m_widget->registerActions(m_d->m_undoAction, m_d->m_redoAction, m_d->m_submitAction, m_d->m_diffAction);
+ connect(m_d->m_widget, SIGNAL(diffSelected(QStringList)), this, SLOT(slotDiffSelectedVCSFiles(QStringList)));
+ connect(m_d->m_widget->descriptionEdit(), SIGNAL(textChanged()), this, SLOT(slotDescriptionChanged()));
+
+ Aggregation::Aggregate *aggregate = new Aggregation::Aggregate;
+ aggregate->add(new Find::BaseTextFind(m_d->m_widget->descriptionEdit()));
+ aggregate->add(this);
+}
+
+VCSBaseSubmitEditor::~VCSBaseSubmitEditor()
+{
+ delete m_d->m_toolWidget;
+ delete m_d->m_widget;
+ delete m_d;
+}
+
+void VCSBaseSubmitEditor::slotDescriptionChanged()
+{
+}
+
+bool VCSBaseSubmitEditor::createNew(const QString &contents)
+{
+ setFileContents(contents);
+ return true;
+}
+
+bool VCSBaseSubmitEditor::open(const QString &fileName)
+{
+ if (fileName.isEmpty())
+ return false;
+
+ const QFileInfo fi(fileName);
+ if (!fi.isFile() || !fi.isReadable())
+ return false;
+
+ QFile file(fileName);
+ if (!file.open(QIODevice::ReadOnly|QIODevice::Text)) {
+ qWarning("Unable to open %s: %s", qPrintable(fileName), qPrintable(file.errorString()));
+ return false;
+ }
+
+ const QString text = QString::fromLocal8Bit(file.readAll());
+ if (!createNew(text))
+ return false;
+
+ m_d->m_file->setFileName(fi.absoluteFilePath());
+ return true;
+}
+
+Core::IFile *VCSBaseSubmitEditor::file()
+{
+ return m_d->m_file;
+}
+
+QString VCSBaseSubmitEditor::displayName() const
+{
+ return m_d->m_displayName;
+}
+
+void VCSBaseSubmitEditor::setDisplayName(const QString &title)
+{
+ m_d->m_displayName = title;
+}
+
+bool VCSBaseSubmitEditor::duplicateSupported() const
+{
+ return false;
+}
+
+Core::IEditor *VCSBaseSubmitEditor::duplicate(QWidget * /*parent*/)
+{
+ return 0;
+}
+
+const char *VCSBaseSubmitEditor::kind() const
+{
+ return m_d->m_parameters->kind;
+}
+
+QToolBar *VCSBaseSubmitEditor::toolBar()
+{
+ if (m_d->m_toolWidget)
+ return m_d->m_toolWidget;
+
+ if (!m_d->m_diffAction && !m_d->m_submitAction)
+ return 0;
+
+ // Create
+ QToolBar *toolBar = new QToolBar;
+ toolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
+ const int size = m_d->m_widget->style()->pixelMetric(QStyle::PM_SmallIconSize);
+ toolBar->setIconSize(QSize(size, size));
+ toolBar->addSeparator();
+
+ if (m_d->m_submitAction)
+ toolBar->addAction(m_d->m_submitAction);
+ if (m_d->m_diffAction)
+ toolBar->addAction(m_d->m_diffAction);
+ m_d->m_toolWidget = toolBar;
+ return toolBar;
+}
+
+QList<int> VCSBaseSubmitEditor::context() const
+{
+ return m_d->m_contexts;
+}
+
+QWidget *VCSBaseSubmitEditor::widget()
+{
+ return m_d->m_widget;
+}
+
+QByteArray VCSBaseSubmitEditor::saveState() const
+{
+ return QByteArray();
+}
+
+bool VCSBaseSubmitEditor::restoreState(const QByteArray &/*state*/)
+{
+ return true;
+}
+
+QStringList VCSBaseSubmitEditor::checkedFiles() const
+{
+ return vcsFileListToFileList(m_d->m_widget->checkedFiles());
+}
+
+void VCSBaseSubmitEditor::setFileList(const QStringList &l)
+{
+ m_d->m_widget->setFileList(l);
+}
+
+void VCSBaseSubmitEditor::addFiles(const QStringList& list, bool checked, bool userCheckable)
+{
+ m_d->m_widget->addFiles(list, checked, userCheckable);
+}
+
+void VCSBaseSubmitEditor::slotDiffSelectedVCSFiles(const QStringList &rawList)
+{
+ emit diffSelectedFiles(vcsFileListToFileList(rawList));
+}
+
+bool VCSBaseSubmitEditor::save(const QString &fileName)
+{
+ const QString fName = fileName.isEmpty() ? m_d->m_file->fileName() : fileName;
+ QFile file(fName);
+ if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) {
+ qWarning("Unable to open %s: %s", qPrintable(fName), qPrintable(file.errorString()));
+ return false;
+ }
+ file.write(fileContents().toLocal8Bit());
+ if (!file.flush())
+ return false;
+ file.close();
+ const QFileInfo fi(fName);
+ m_d->m_file->setFileName(fi.absoluteFilePath());
+ m_d->m_file->setModified(false);
+ return true;
+}
+
+QString VCSBaseSubmitEditor::fileContents() const
+{
+ return m_d->m_widget->trimmedDescriptionText();
+}
+
+bool VCSBaseSubmitEditor::setFileContents(const QString &contents)
+{
+ m_d->m_widget->setDescriptionText(contents);
+ return true;
+}
+
+}
diff --git a/src/plugins/vcsbase/vcsbasesubmiteditor.h b/src/plugins/vcsbase/vcsbasesubmiteditor.h
new file mode 100644
index 0000000000..f2ba36b0c9
--- /dev/null
+++ b/src/plugins/vcsbase/vcsbasesubmiteditor.h
@@ -0,0 +1,146 @@
+/***************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+**
+** Non-Open Source Usage
+**
+** Licensees may use this file in accordance with the Qt Beta Version
+** License Agreement, Agreement version 2.2 provided with the Software or,
+** alternatively, in accordance with the terms contained in a written
+** agreement between you and Nokia.
+**
+** GNU General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the packaging
+** of this file. Please review the following information to ensure GNU
+** General Public Licensing requirements will be met:
+**
+** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt GPL Exception version
+** 1.2, included in the file GPL_EXCEPTION.txt in this package.
+**
+***************************************************************************/
+#ifndef VCSBaseSUBMITEDITOR_H
+#define VCSBaseSUBMITEDITOR_H
+
+#include "vcsbase_global.h"
+
+#include <coreplugin/editormanager/ieditor.h>
+
+#include <QtCore/QList>
+
+namespace Core {
+ namespace Utils {
+ class SubmitEditorWidget;
+ }
+}
+
+namespace VCSBase {
+
+struct VCSBaseSubmitEditorPrivate;
+
+/* Utility struct to parametrize a VCSBaseSubmitEditor. */
+struct VCSBASE_EXPORT VCSBaseSubmitEditorParameters {
+ const char *mimeType;
+ const char *kind;
+ const char *context;
+ const char *undoActionId;
+ const char *redoActionId;
+ const char *submitActionId;
+ const char *diffActionId;
+};
+
+/* Base class for a submit editor based on the Core::Utils::SubmitEditorWidget
+ * that presents the commit message in a text editor and an
+ * checkable list of modified files in a list window. The user can delete
+ * files from the list by pressing unchecking them or diff the selection
+ * by doubleclicking.
+ *
+ * The action matching the the ids (unless 0) of the parameter struct will be
+ * registered with the EditorWidget and submit/diff actions will be added to
+ * a toolbar.
+ *
+ * For the given context, there must be only one instance of the editor
+ * active.
+ * To start a submit, set the submit template on the editor and the output
+ * of the VCS status command listing the modified files as fileList and open
+ * it.
+ * The submit process is started by listening on the editor close
+ * signal and then asking the IFile interface of the editor to save the file
+ * within a IFileManager::blockFileChange() section
+ * and to launch the submit process. In addition, the action registered
+ * for submit should be connected to a slot triggering the close of the
+ * current editor in the editor manager. */
+
+class VCSBASE_EXPORT VCSBaseSubmitEditor : public Core::IEditor
+{
+ Q_OBJECT
+public:
+ typedef QList<int> Context;
+
+protected:
+ explicit VCSBaseSubmitEditor(const VCSBaseSubmitEditorParameters *parameters,
+ Core::Utils::SubmitEditorWidget *editorWidget);
+
+public:
+ virtual ~VCSBaseSubmitEditor();
+
+ // Core::IEditor
+ virtual bool createNew(const QString &contents);
+ virtual bool open(const QString &fileName);
+ virtual Core::IFile *file();
+ virtual QString displayName() const;
+ virtual void setDisplayName(const QString &title);
+ virtual bool duplicateSupported() const;
+ virtual Core::IEditor *duplicate(QWidget * parent);
+ virtual const char *kind() const;
+
+ virtual QToolBar *toolBar();
+ virtual QList<int> context() const;
+ virtual QWidget *widget();
+
+ virtual QByteArray saveState() const;
+ virtual bool restoreState(const QByteArray &state);
+
+ QStringList checkedFiles() const;
+
+ void setFileList(const QStringList&);
+ void addFiles(const QStringList&, bool checked = true, bool userCheckable = true);
+
+signals:
+ void diffSelectedFiles(const QStringList &files);
+
+private slots:
+ void slotDiffSelectedVCSFiles(const QStringList &rawList);
+ bool save(const QString &fileName);
+ void slotDescriptionChanged();
+
+protected:
+ /* Implemented this to extract the real file list from the status
+ * output of the versioning system as displayed in the file list
+ * for example "M foo.cpp" -> "foo.cpp". */
+ virtual QStringList vcsFileListToFileList(const QStringList &) const = 0;
+
+ /* These hooks allow for modifying the contents that goes to
+ * the file. The default implementation uses the text
+ * of the description editor. */
+ virtual QString fileContents() const;
+ virtual bool setFileContents(const QString &contents);
+
+private:
+ VCSBaseSubmitEditorPrivate *m_d;
+};
+
+}
+
+#endif // VCSBaseSUBMITEDITOR_H
diff --git a/src/plugins/vcsbase/vcsbasetextdocument.cpp b/src/plugins/vcsbase/vcsbasetextdocument.cpp
new file mode 100644
index 0000000000..2e52e56ea0
--- /dev/null
+++ b/src/plugins/vcsbase/vcsbasetextdocument.cpp
@@ -0,0 +1,53 @@
+/***************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+**
+** Non-Open Source Usage
+**
+** Licensees may use this file in accordance with the Qt Beta Version
+** License Agreement, Agreement version 2.2 provided with the Software or,
+** alternatively, in accordance with the terms contained in a written
+** agreement between you and Nokia.
+**
+** GNU General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the packaging
+** of this file. Please review the following information to ensure GNU
+** General Public Licensing requirements will be met:
+**
+** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt GPL Exception version
+** 1.2, included in the file GPL_EXCEPTION.txt in this package.
+**
+***************************************************************************/
+#include "vcsbasetextdocument.h"
+
+namespace VCSBase {
+namespace Internal {
+
+VCSBaseTextDocument::VCSBaseTextDocument()
+{
+}
+
+bool VCSBaseTextDocument::isReadOnly() const
+{
+ return true;
+}
+
+bool VCSBaseTextDocument::isModified() const
+{
+ return false;
+}
+
+}
+}
diff --git a/src/plugins/vcsbase/vcsbasetextdocument.h b/src/plugins/vcsbase/vcsbasetextdocument.h
new file mode 100644
index 0000000000..9c2b2c66c6
--- /dev/null
+++ b/src/plugins/vcsbase/vcsbasetextdocument.h
@@ -0,0 +1,55 @@
+/***************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+**
+** Non-Open Source Usage
+**
+** Licensees may use this file in accordance with the Qt Beta Version
+** License Agreement, Agreement version 2.2 provided with the Software or,
+** alternatively, in accordance with the terms contained in a written
+** agreement between you and Nokia.
+**
+** GNU General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the packaging
+** of this file. Please review the following information to ensure GNU
+** General Public Licensing requirements will be met:
+**
+** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt GPL Exception version
+** 1.2, included in the file GPL_EXCEPTION.txt in this package.
+**
+***************************************************************************/
+#ifndef VCSBASETEXTDOCUMENT_H
+#define VCSBASETEXTDOCUMENT_H
+
+#include <texteditor/basetextdocument.h>
+
+namespace VCSBase {
+namespace Internal {
+
+// A read-only text document.
+class VCSBaseTextDocument : public TextEditor::BaseTextDocument
+{
+ Q_OBJECT
+public:
+ VCSBaseTextDocument();
+
+ bool isReadOnly() const;
+ bool isModified() const;
+};
+
+} // namespace Internal
+} // namespace VCSBase
+
+#endif // VCSBASETEXTDOCUMENT_H