forked from qt-creator/qt-creator
Add a DiffShowEditor showing an additional info
Task-number: QTCREATORBUG-9489 Change-Id: I3ae2e59ccaf397f4236505f21e027a42e2798784 Reviewed-by: Tobias Hunger <tobias.hunger@digia.com> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@digia.com> Reviewed-by: Petar Perisin <petar.perisin@gmail.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
This commit is contained in:
@@ -27,8 +27,8 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef DIFFEDITOREDITABLE_H
|
||||
#define DIFFEDITOREDITABLE_H
|
||||
#ifndef DIFFEDITOR_H
|
||||
#define DIFFEDITOR_H
|
||||
|
||||
#include "diffeditor_global.h"
|
||||
#include "diffeditorwidget.h"
|
||||
@@ -77,16 +77,18 @@ public slots:
|
||||
private slots:
|
||||
void entryActivated(int index);
|
||||
|
||||
protected:
|
||||
QToolBar *m_toolWidget;
|
||||
|
||||
private:
|
||||
void updateEntryToolTip();
|
||||
|
||||
Internal::DiffEditorFile *m_file;
|
||||
DiffEditorWidget *m_editorWidget;
|
||||
QToolBar *m_toolWidget;
|
||||
QComboBox *m_entriesComboBox;
|
||||
mutable QString m_displayName;
|
||||
};
|
||||
|
||||
} // namespace DiffEditor
|
||||
|
||||
#endif // DIFFEDITOREDITABLE_H
|
||||
#endif // DIFFEDITOR_H
|
||||
|
||||
@@ -4,15 +4,21 @@ include(../../qtcreatorplugin.pri)
|
||||
HEADERS += diffeditor_global.h \
|
||||
diffeditorconstants.h \
|
||||
diffeditor.h \
|
||||
diffeditorfactory.h \
|
||||
diffeditorfile.h \
|
||||
diffeditorplugin.h \
|
||||
diffeditorwidget.h \
|
||||
differ.h
|
||||
differ.h \
|
||||
diffshoweditor.h \
|
||||
diffshoweditorfactory.h
|
||||
|
||||
SOURCES += diffeditor.cpp \
|
||||
diffeditorfactory.cpp \
|
||||
diffeditorfile.cpp \
|
||||
diffeditorplugin.cpp \
|
||||
diffeditorwidget.cpp \
|
||||
differ.cpp
|
||||
differ.cpp \
|
||||
diffshoweditor.cpp \
|
||||
diffshoweditorfactory.cpp
|
||||
|
||||
RESOURCES +=
|
||||
|
||||
@@ -16,6 +16,8 @@ QtcPlugin {
|
||||
"diffeditor.h",
|
||||
"diffeditor_global.h",
|
||||
"diffeditorconstants.h",
|
||||
"diffeditorfactory.cpp",
|
||||
"diffeditorfactory.h",
|
||||
"diffeditorfile.cpp",
|
||||
"diffeditorfile.h",
|
||||
"diffeditorplugin.cpp",
|
||||
@@ -24,6 +26,10 @@ QtcPlugin {
|
||||
"diffeditorwidget.h",
|
||||
"differ.cpp",
|
||||
"differ.h",
|
||||
"diffshoweditor.cpp",
|
||||
"diffshoweditor.h",
|
||||
"diffshoweditorfactory.cpp",
|
||||
"diffshoweditorfactory.h",
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,8 @@ namespace Constants {
|
||||
const char DIFF_EDITOR_ID[] = "Diff Editor";
|
||||
const char DIFF_EDITOR_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("DiffEditor", "Diff Editor");
|
||||
const char DIFF_EDITOR_MIMETYPE[] = "text/x-patch";
|
||||
const char DIFF_SHOW_EDITOR_ID[] = "Show Editor";
|
||||
const char DIFF_SHOW_EDITOR_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("ShowEditor", "Show Editor");
|
||||
const char G_TOOLS_DIFF[] = "QtCreator.Group.Tools.Options";
|
||||
|
||||
} // namespace Constants
|
||||
|
||||
70
src/plugins/diffeditor/diffeditorfactory.cpp
Normal file
70
src/plugins/diffeditor/diffeditorfactory.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** 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
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "diffeditorfactory.h"
|
||||
#include "diffeditor.h"
|
||||
#include "diffeditorwidget.h"
|
||||
#include "diffeditorconstants.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
||||
namespace DiffEditor {
|
||||
|
||||
namespace Internal {
|
||||
|
||||
DiffEditorFactory::DiffEditorFactory(QObject *parent)
|
||||
: IEditorFactory(parent),
|
||||
m_mimeTypes(QLatin1String(Constants::DIFF_EDITOR_MIMETYPE))
|
||||
{
|
||||
}
|
||||
|
||||
Core::Id DiffEditorFactory::id() const
|
||||
{
|
||||
return Constants::DIFF_EDITOR_ID;
|
||||
}
|
||||
|
||||
QString DiffEditorFactory::displayName() const
|
||||
{
|
||||
return qApp->translate("DiffEditorFactory", Constants::DIFF_EDITOR_DISPLAY_NAME);
|
||||
}
|
||||
|
||||
Core::IEditor *DiffEditorFactory::createEditor(QWidget *parent)
|
||||
{
|
||||
DiffEditorWidget *editorWidget = new DiffEditorWidget(parent);
|
||||
DiffEditor *editor = new DiffEditor(editorWidget);
|
||||
return editor;
|
||||
}
|
||||
|
||||
QStringList DiffEditorFactory::mimeTypes() const
|
||||
{
|
||||
return m_mimeTypes;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace DiffEditor
|
||||
62
src/plugins/diffeditor/diffeditorfactory.h
Normal file
62
src/plugins/diffeditor/diffeditorfactory.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** 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
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef DIFFEDITORFACTORY_H
|
||||
#define DIFFEDITORFACTORY_H
|
||||
|
||||
#include "diffeditor_global.h"
|
||||
|
||||
#include <QStringList>
|
||||
|
||||
#include <coreplugin/editormanager/ieditorfactory.h>
|
||||
|
||||
namespace DiffEditor {
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class DiffEditorFactory : public Core::IEditorFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DiffEditorFactory(QObject *parent);
|
||||
|
||||
QStringList mimeTypes() const;
|
||||
Core::IEditor *createEditor(QWidget *parent);
|
||||
Core::Id id() const;
|
||||
QString displayName() const;
|
||||
|
||||
private:
|
||||
const QStringList m_mimeTypes;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace DiffEditor
|
||||
|
||||
#endif // DIFFEDITORFACTORY_H
|
||||
@@ -29,10 +29,12 @@
|
||||
|
||||
#include "diffeditorplugin.h"
|
||||
#include "diffeditor.h"
|
||||
#include "diffeditorwidget.h"
|
||||
#include "diffeditorconstants.h"
|
||||
#include "diffeditorfactory.h"
|
||||
#include "diffeditorwidget.h"
|
||||
#include "diffshoweditor.h"
|
||||
#include "diffshoweditorfactory.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QFileDialog>
|
||||
#include <QTextCodec>
|
||||
#include <QtPlugin>
|
||||
@@ -44,40 +46,8 @@
|
||||
|
||||
namespace DiffEditor {
|
||||
|
||||
///////////////////////////////// DiffEditorFactory //////////////////////////////////
|
||||
|
||||
namespace Internal {
|
||||
|
||||
DiffEditorFactory::DiffEditorFactory(DiffEditorPlugin *owner)
|
||||
: m_mimeTypes(QLatin1String(Constants::DIFF_EDITOR_MIMETYPE)),
|
||||
m_owner(owner)
|
||||
{
|
||||
}
|
||||
|
||||
Core::Id DiffEditorFactory::id() const
|
||||
{
|
||||
return Constants::DIFF_EDITOR_ID;
|
||||
}
|
||||
|
||||
QString DiffEditorFactory::displayName() const
|
||||
{
|
||||
return qApp->translate("DiffEditorFactory", Constants::DIFF_EDITOR_DISPLAY_NAME);
|
||||
}
|
||||
|
||||
Core::IEditor *DiffEditorFactory::createEditor(QWidget *parent)
|
||||
{
|
||||
DiffEditorWidget *editorWidget = new DiffEditorWidget(parent);
|
||||
DiffEditor *editor = new DiffEditor(editorWidget);
|
||||
return editor;
|
||||
}
|
||||
|
||||
QStringList DiffEditorFactory::mimeTypes() const
|
||||
{
|
||||
return m_mimeTypes;
|
||||
}
|
||||
|
||||
///////////////////////////////// DiffEditorPlugin //////////////////////////////////
|
||||
|
||||
DiffEditorPlugin::DiffEditorPlugin()
|
||||
{
|
||||
}
|
||||
@@ -86,11 +56,6 @@ DiffEditorPlugin::~DiffEditorPlugin()
|
||||
{
|
||||
}
|
||||
|
||||
void DiffEditorPlugin::initializeEditor(DiffEditorWidget *editor)
|
||||
{
|
||||
Q_UNUSED(editor)
|
||||
}
|
||||
|
||||
bool DiffEditorPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
{
|
||||
Q_UNUSED(arguments)
|
||||
@@ -110,6 +75,7 @@ bool DiffEditorPlugin::initialize(const QStringList &arguments, QString *errorMe
|
||||
toolsContainer->addAction(diffCommand, Constants::G_TOOLS_DIFF);
|
||||
|
||||
addAutoReleasedObject(new DiffEditorFactory(this));
|
||||
addAutoReleasedObject(new DiffShowEditorFactory(this));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -33,18 +33,9 @@
|
||||
#include "diffeditor_global.h"
|
||||
|
||||
#include <extensionsystem/iplugin.h>
|
||||
#include <coreplugin/editormanager/ieditorfactory.h>
|
||||
#include <coreplugin/icontext.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
|
||||
#include <QStringList>
|
||||
|
||||
namespace Core { class IEditor; }
|
||||
|
||||
namespace DiffEditor {
|
||||
|
||||
class DiffEditorWidget;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class DiffEditorPlugin : public ExtensionSystem::IPlugin
|
||||
@@ -59,9 +50,6 @@ public:
|
||||
bool initialize(const QStringList &arguments, QString *errorMessage = 0);
|
||||
void extensionsInitialized();
|
||||
|
||||
// Connect editor to settings changed signals.
|
||||
void initializeEditor(DiffEditorWidget *editor);
|
||||
|
||||
private slots:
|
||||
void diff();
|
||||
|
||||
@@ -74,23 +62,6 @@ private:
|
||||
|
||||
};
|
||||
|
||||
class DiffEditorFactory : public Core::IEditorFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DiffEditorFactory(DiffEditorPlugin *owner);
|
||||
|
||||
QStringList mimeTypes() const;
|
||||
Core::IEditor *createEditor(QWidget *parent);
|
||||
Core::Id id() const;
|
||||
QString displayName() const;
|
||||
|
||||
private:
|
||||
const QStringList m_mimeTypes;
|
||||
DiffEditorPlugin *m_owner;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace DiffEditor
|
||||
|
||||
|
||||
189
src/plugins/diffeditor/diffshoweditor.cpp
Normal file
189
src/plugins/diffeditor/diffshoweditor.cpp
Normal file
@@ -0,0 +1,189 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** 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
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "diffshoweditor.h"
|
||||
#include "diffeditorconstants.h"
|
||||
|
||||
#include <QToolBar>
|
||||
#include <QToolButton>
|
||||
#include <QCoreApplication>
|
||||
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/minisplitter.h>
|
||||
|
||||
#include <texteditor/basetexteditor.h>
|
||||
#include <texteditor/texteditorsettings.h>
|
||||
#include <texteditor/displaysettings.h>
|
||||
|
||||
using namespace TextEditor;
|
||||
|
||||
namespace DiffEditor {
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class DiffShowEditorWidgetEditable : public BaseTextEditor
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DiffShowEditorWidgetEditable(BaseTextEditorWidget *editorWidget) : BaseTextEditor(editorWidget) {}
|
||||
|
||||
Core::Id id() const { return "DiffShowViewEditor"; }
|
||||
bool isTemporary() const { return false; }
|
||||
};
|
||||
|
||||
class DiffShowEditorWidget : public BaseTextEditorWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DiffShowEditorWidget(QWidget *parent = 0);
|
||||
virtual QSize sizeHint() const;
|
||||
|
||||
public slots:
|
||||
void setDisplaySettings(const DisplaySettings &ds);
|
||||
|
||||
protected:
|
||||
BaseTextEditor *createEditor() { return new DiffShowEditorWidgetEditable(this); }
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
DiffShowEditorWidget::DiffShowEditorWidget(QWidget *parent)
|
||||
: BaseTextEditorWidget(parent)
|
||||
{
|
||||
DisplaySettings settings = displaySettings();
|
||||
settings.m_textWrapping = false;
|
||||
settings.m_displayLineNumbers = false;
|
||||
settings.m_highlightCurrentLine = false;
|
||||
settings.m_displayFoldingMarkers = false;
|
||||
settings.m_markTextChanges = false;
|
||||
settings.m_highlightBlocks = false;
|
||||
BaseTextEditorWidget::setDisplaySettings(settings);
|
||||
|
||||
setCodeFoldingSupported(true);
|
||||
setFrameStyle(QFrame::NoFrame);
|
||||
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||
}
|
||||
|
||||
QSize DiffShowEditorWidget::sizeHint() const
|
||||
{
|
||||
QSize size = BaseTextEditorWidget::sizeHint();
|
||||
size.setHeight(size.height() / 5);
|
||||
return size;
|
||||
}
|
||||
|
||||
void DiffShowEditorWidget::setDisplaySettings(const DisplaySettings &ds)
|
||||
{
|
||||
DisplaySettings settings = displaySettings();
|
||||
settings.m_visualizeWhitespace = ds.m_visualizeWhitespace;
|
||||
BaseTextEditorWidget::setDisplaySettings(settings);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
DiffShowEditor::DiffShowEditor(DiffEditorWidget *editorWidget)
|
||||
: DiffEditor(editorWidget)
|
||||
{
|
||||
QSplitter *splitter = new Core::MiniSplitter(Qt::Vertical);
|
||||
m_diffShowWidget = new Internal::DiffShowEditorWidget(splitter);
|
||||
m_diffShowWidget->setReadOnly(true);
|
||||
splitter->addWidget(m_diffShowWidget);
|
||||
splitter->addWidget(editorWidget);
|
||||
setWidget(splitter);
|
||||
|
||||
TextEditorSettings *settings = TextEditorSettings::instance();
|
||||
connect(settings, SIGNAL(displaySettingsChanged(TextEditor::DisplaySettings)),
|
||||
m_diffShowWidget, SLOT(setDisplaySettings(TextEditor::DisplaySettings)));
|
||||
connect(settings, SIGNAL(fontSettingsChanged(TextEditor::FontSettings)),
|
||||
m_diffShowWidget, SLOT(setFontSettings(TextEditor::FontSettings)));
|
||||
m_diffShowWidget->setDisplaySettings(settings->displaySettings());
|
||||
m_diffShowWidget->setCodeStyle(settings->codeStyle());
|
||||
m_diffShowWidget->setFontSettings(settings->fontSettings());
|
||||
}
|
||||
|
||||
DiffShowEditor::~DiffShowEditor()
|
||||
{
|
||||
}
|
||||
|
||||
void DiffShowEditor::setDescription(const QString &description)
|
||||
{
|
||||
m_diffShowWidget->setPlainText(description);
|
||||
}
|
||||
|
||||
QString DiffShowEditor::displayName() const
|
||||
{
|
||||
if (m_displayName.isEmpty())
|
||||
m_displayName = QCoreApplication::translate("DiffShowEditor", Constants::DIFF_SHOW_EDITOR_DISPLAY_NAME);
|
||||
return m_displayName;
|
||||
}
|
||||
|
||||
void DiffShowEditor::setDisplayName(const QString &title)
|
||||
{
|
||||
m_displayName = title;
|
||||
emit changed();
|
||||
}
|
||||
|
||||
Core::Id DiffShowEditor::id() const
|
||||
{
|
||||
return Constants::DIFF_SHOW_EDITOR_ID;
|
||||
}
|
||||
|
||||
QWidget *DiffShowEditor::toolBar()
|
||||
{
|
||||
if (m_toolWidget)
|
||||
return m_toolWidget;
|
||||
|
||||
// Create
|
||||
DiffEditor::toolBar();
|
||||
|
||||
m_toggleDescriptionButton = new QToolButton(m_toolWidget);
|
||||
m_toggleDescriptionButton->setIcon(QIcon(QLatin1String(Core::Constants::ICON_TOGGLE_TOPBAR)));
|
||||
m_toggleDescriptionButton->setCheckable(true);
|
||||
m_toggleDescriptionButton->setChecked(true);
|
||||
connect(m_toggleDescriptionButton, SIGNAL(clicked(bool)),
|
||||
this, SLOT(setDescriptionVisible(bool)));
|
||||
m_toolWidget->addWidget(m_toggleDescriptionButton);
|
||||
setDescriptionVisible(true);
|
||||
|
||||
return m_toolWidget;
|
||||
}
|
||||
|
||||
void DiffShowEditor::setDescriptionVisible(bool visible)
|
||||
{
|
||||
if (visible) {
|
||||
m_toggleDescriptionButton->setToolTip(tr("Hide Change Description"));
|
||||
} else {
|
||||
m_toggleDescriptionButton->setToolTip(tr("Show Change Description"));
|
||||
}
|
||||
m_diffShowWidget->setVisible(visible);
|
||||
}
|
||||
|
||||
} // namespace DiffEditor
|
||||
|
||||
#include "diffshoweditor.moc"
|
||||
78
src/plugins/diffeditor/diffshoweditor.h
Normal file
78
src/plugins/diffeditor/diffshoweditor.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** 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
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef DIFFSHOWEDITOR_H
|
||||
#define DIFFSHOWEDITOR_H
|
||||
|
||||
#include "diffeditor_global.h"
|
||||
#include "diffeditor.h"
|
||||
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QToolButton;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace DiffEditor {
|
||||
|
||||
namespace Internal {
|
||||
class DiffEditorFile;
|
||||
}
|
||||
|
||||
class DIFFEDITOR_EXPORT DiffShowEditor : public DiffEditor
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DiffShowEditor(DiffEditorWidget *editorWidget);
|
||||
virtual ~DiffShowEditor();
|
||||
|
||||
public:
|
||||
void setDescription(const QString &description);
|
||||
// Core::IEditor
|
||||
QString displayName() const;
|
||||
void setDisplayName(const QString &title);
|
||||
Core::Id id() const;
|
||||
|
||||
QWidget *toolBar();
|
||||
|
||||
private slots:
|
||||
void setDescriptionVisible(bool visible);
|
||||
|
||||
private:
|
||||
void updateEntryToolTip();
|
||||
|
||||
TextEditor::BaseTextEditorWidget *m_diffShowWidget;
|
||||
mutable QString m_displayName;
|
||||
QToolButton *m_toggleDescriptionButton;
|
||||
};
|
||||
|
||||
} // namespace DiffEditor
|
||||
|
||||
#endif // DIFFEDITOR_H
|
||||
70
src/plugins/diffeditor/diffshoweditorfactory.cpp
Normal file
70
src/plugins/diffeditor/diffshoweditorfactory.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** 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
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "diffshoweditorfactory.h"
|
||||
#include "diffshoweditor.h"
|
||||
#include "diffeditorwidget.h"
|
||||
#include "diffeditorconstants.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
||||
namespace DiffEditor {
|
||||
|
||||
namespace Internal {
|
||||
|
||||
DiffShowEditorFactory::DiffShowEditorFactory(QObject *parent)
|
||||
: IEditorFactory(parent),
|
||||
m_mimeTypes(QLatin1String(Constants::DIFF_EDITOR_MIMETYPE))
|
||||
{
|
||||
}
|
||||
|
||||
Core::Id DiffShowEditorFactory::id() const
|
||||
{
|
||||
return Constants::DIFF_SHOW_EDITOR_ID;
|
||||
}
|
||||
|
||||
QString DiffShowEditorFactory::displayName() const
|
||||
{
|
||||
return qApp->translate("DiffEditorFactory", Constants::DIFF_SHOW_EDITOR_DISPLAY_NAME);
|
||||
}
|
||||
|
||||
Core::IEditor *DiffShowEditorFactory::createEditor(QWidget *parent)
|
||||
{
|
||||
DiffEditorWidget *editorWidget = new DiffEditorWidget(parent);
|
||||
DiffShowEditor *editor = new DiffShowEditor(editorWidget);
|
||||
return editor;
|
||||
}
|
||||
|
||||
QStringList DiffShowEditorFactory::mimeTypes() const
|
||||
{
|
||||
return m_mimeTypes;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace DiffEditor
|
||||
62
src/plugins/diffeditor/diffshoweditorfactory.h
Normal file
62
src/plugins/diffeditor/diffshoweditorfactory.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** 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
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef DIFFSHOWEDITORFACTORY_H
|
||||
#define DIFFSHOWEDITORFACTORY_H
|
||||
|
||||
#include "diffeditor_global.h"
|
||||
|
||||
#include <QStringList>
|
||||
|
||||
#include <coreplugin/editormanager/ieditorfactory.h>
|
||||
|
||||
namespace DiffEditor {
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class DiffShowEditorFactory : public Core::IEditorFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DiffShowEditorFactory(QObject *parent);
|
||||
|
||||
QStringList mimeTypes() const;
|
||||
Core::IEditor *createEditor(QWidget *parent);
|
||||
Core::Id id() const;
|
||||
QString displayName() const;
|
||||
|
||||
private:
|
||||
const QStringList m_mimeTypes;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace DiffEditor
|
||||
|
||||
#endif // DIFFSHOWEDITORFACTORY_H
|
||||
Reference in New Issue
Block a user