diff options
author | Jarek Kobus <jaroslaw.kobus@nokia.com> | 2014-01-30 17:04:54 +0100 |
---|---|---|
committer | Jarek Kobus <jaroslaw.kobus@digia.com> | 2014-01-30 19:13:48 +0100 |
commit | edac8f082d5f15fc293425311e6ab24db7252969 (patch) | |
tree | a2d45e58e35f383e9848914cb99a14dec55ecb91 /src/plugins | |
parent | 3798552beb148b87d8124d80ede15adc8933b817 (diff) | |
download | qt-creator-edac8f082d5f15fc293425311e6ab24db7252969.tar.gz |
Get rid of DiffShowEditor.
Made DiffEditor customizable instead
Change-Id: If92799d47c7e731febb45197384c082eb3af55df
Reviewed-by: Jarek Kobus <jaroslaw.kobus@digia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/diffeditor/diffeditor.cpp | 151 | ||||
-rw-r--r-- | src/plugins/diffeditor/diffeditor.h | 15 | ||||
-rw-r--r-- | src/plugins/diffeditor/diffeditor.pro | 4 | ||||
-rw-r--r-- | src/plugins/diffeditor/diffeditor.qbs | 4 | ||||
-rw-r--r-- | src/plugins/diffeditor/diffeditorconstants.h | 2 | ||||
-rw-r--r-- | src/plugins/diffeditor/diffeditorcontroller.cpp | 47 | ||||
-rw-r--r-- | src/plugins/diffeditor/diffeditorcontroller.h | 12 | ||||
-rw-r--r-- | src/plugins/diffeditor/diffeditorplugin.cpp | 3 | ||||
-rw-r--r-- | src/plugins/diffeditor/diffshoweditor.cpp | 176 | ||||
-rw-r--r-- | src/plugins/diffeditor/diffshoweditor.h | 73 | ||||
-rw-r--r-- | src/plugins/diffeditor/diffshoweditorfactory.cpp | 59 | ||||
-rw-r--r-- | src/plugins/diffeditor/diffshoweditorfactory.h | 56 | ||||
-rw-r--r-- | src/plugins/git/gitclient.cpp | 12 |
13 files changed, 221 insertions, 393 deletions
diff --git a/src/plugins/diffeditor/diffeditor.cpp b/src/plugins/diffeditor/diffeditor.cpp index 96c2e7e355..ee0edccaf8 100644 --- a/src/plugins/diffeditor/diffeditor.cpp +++ b/src/plugins/diffeditor/diffeditor.cpp @@ -34,6 +34,11 @@ #include <coreplugin/icore.h> #include <coreplugin/coreconstants.h> +#include <coreplugin/minisplitter.h> + +#include <texteditor/basetexteditor.h> +#include <texteditor/texteditorsettings.h> +#include <texteditor/displaysettings.h> #include <QToolButton> #include <QSpinBox> @@ -44,23 +49,110 @@ #include <QComboBox> #include <QFileInfo> +using namespace TextEditor; + namespace DiffEditor { +namespace Internal { + +class DescriptionEditor : public BaseTextEditor +{ + Q_OBJECT +public: + DescriptionEditor(BaseTextEditorWidget *editorWidget) : BaseTextEditor(editorWidget) {} + + Core::Id id() const { return "DescriptionEditor"; } +}; + +class DescriptionEditorWidget : public BaseTextEditorWidget +{ + Q_OBJECT +public: + DescriptionEditorWidget(QWidget *parent = 0); + virtual QSize sizeHint() const; + +public slots: + void setDisplaySettings(const DisplaySettings &ds); + +protected: + BaseTextEditor *createEditor() { return new DescriptionEditor(this); } + +private: +}; + +DescriptionEditorWidget::DescriptionEditorWidget(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 DescriptionEditorWidget::sizeHint() const +{ + QSize size = BaseTextEditorWidget::sizeHint(); + size.setHeight(size.height() / 5); + return size; +} + +void DescriptionEditorWidget::setDisplaySettings(const DisplaySettings &ds) +{ + DisplaySettings settings = displaySettings(); + settings.m_visualizeWhitespace = ds.m_visualizeWhitespace; + BaseTextEditorWidget::setDisplaySettings(settings); +} + +} // namespace Internal + ///////////////////////////////// DiffEditor ////////////////////////////////// DiffEditor::DiffEditor(SideBySideDiffEditorWidget *editorWidget) : IEditor(0) , m_toolWidget(0) , m_document(new Internal::DiffEditorDocument(QLatin1String(Constants::DIFF_EDITOR_MIMETYPE), this)) - , m_editorWidget(editorWidget) + , m_diffWidget(editorWidget) , m_diffEditorController(0) , m_entriesComboBox(0) + , m_toggleDescriptionAction(0) { - setWidget(editorWidget); + QSplitter *splitter = new Core::MiniSplitter(Qt::Vertical); + m_descriptionWidget = new Internal::DescriptionEditorWidget(splitter); + m_descriptionWidget->setReadOnly(true); + splitter->addWidget(m_descriptionWidget); + splitter->addWidget(editorWidget); + setWidget(splitter); + + connect(TextEditorSettings::instance(), SIGNAL(displaySettingsChanged(TextEditor::DisplaySettings)), + m_descriptionWidget, SLOT(setDisplaySettings(TextEditor::DisplaySettings))); + connect(TextEditorSettings::instance(), SIGNAL(fontSettingsChanged(TextEditor::FontSettings)), + m_descriptionWidget->baseTextDocument(), SLOT(setFontSettings(TextEditor::FontSettings))); + m_descriptionWidget->setDisplaySettings(TextEditorSettings::displaySettings()); + m_descriptionWidget->setCodeStyle(TextEditorSettings::codeStyle()); + m_descriptionWidget->baseTextDocument()->setFontSettings(TextEditorSettings::fontSettings()); + m_diffEditorController = editorWidget ? editorWidget->diffEditorController() : 0; if (m_diffEditorController) { connect(m_diffEditorController, SIGNAL(currentDiffFileIndexChanged(int)), this, SLOT(activateEntry(int))); + connect(m_diffEditorController, SIGNAL(descriptionChanged(QString)), + this, SLOT(slotDescriptionChanged(QString))); + connect(m_diffEditorController, SIGNAL(descriptionEnablementChanged(bool)), + this, SLOT(slotDescriptionVisibilityChanged())); + connect(m_diffEditorController, SIGNAL(descriptionVisibilityChanged(bool)), + this, SLOT(slotDescriptionVisibilityChanged())); + + slotDescriptionChanged(m_diffEditorController->description()); + slotDescriptionVisibilityChanged(); } } @@ -91,7 +183,7 @@ Core::Id DiffEditor::id() const QTextCodec *DiffEditor::codec() const { - return m_editorWidget->codec(); + return m_diffWidget->codec(); } static QToolBar *createToolBar(const QWidget *someWidget) @@ -111,7 +203,7 @@ QWidget *DiffEditor::toolBar() return m_toolWidget; // Create - m_toolWidget = createToolBar(m_editorWidget); + m_toolWidget = createToolBar(m_diffWidget); m_entriesComboBox = new QComboBox; m_entriesComboBox->setMinimumContentsLength(20); @@ -148,6 +240,13 @@ QWidget *DiffEditor::toolBar() toggleSync->setToolTip(tr("Synchronize Horizontal Scroll Bars")); m_toolWidget->addWidget(toggleSync); + QToolButton *toggleDescription = new QToolButton(m_toolWidget); + toggleDescription->setIcon(QIcon(QLatin1String(Core::Constants::ICON_TOGGLE_TOPBAR))); + toggleDescription->setCheckable(true); + toggleDescription->setChecked(true); + m_toggleDescriptionAction = m_toolWidget->addWidget(toggleDescription); + slotDescriptionVisibilityChanged(); + if (m_diffEditorController) { connect(whitespaceButton, SIGNAL(clicked(bool)), m_diffEditorController, SLOT(setIgnoreWhitespaces(bool))); @@ -155,6 +254,8 @@ QWidget *DiffEditor::toolBar() m_diffEditorController, SLOT(setContextLinesNumber(int))); connect(toggleSync, SIGNAL(clicked(bool)), m_diffEditorController, SLOT(setHorizontalScrollBarSynchronization(bool))); + connect(toggleDescription, SIGNAL(clicked(bool)), + m_diffEditorController, SLOT(setDescriptionVisible(bool))); // TODO: synchronize in opposite direction too } @@ -206,6 +307,18 @@ void DiffEditor::setDiff(const QList<DiffEditorController::DiffFilesContents> &d m_diffEditorController->setDiffContents(diffFileList, workingDirectory); } +void DiffEditor::setDescription(const QString &description) +{ + if (m_diffEditorController) + m_diffEditorController->setDescription(description); +} + +void DiffEditor::setDescriptionEnabled(bool on) +{ + if (m_diffEditorController) + m_diffEditorController->setDescriptionEnabled(on); +} + void DiffEditor::clear(const QString &message) { m_entriesComboBox->clear(); @@ -236,4 +349,34 @@ void DiffEditor::activateEntry(int index) updateEntryToolTip(); } +void DiffEditor::slotDescriptionChanged(const QString &description) +{ + m_descriptionWidget->setPlainText(description); +} + +void DiffEditor::slotDescriptionVisibilityChanged() +{ + if (!m_diffEditorController) + return; + + const bool visible = m_diffEditorController->isDescriptionVisible(); + const bool enabled = m_diffEditorController->isDescriptionEnabled(); + + m_descriptionWidget->setVisible(visible && enabled); + + if (!m_toggleDescriptionAction) + return; + + QWidget *toggle = m_toolWidget->widgetForAction(m_toggleDescriptionAction); + if (visible) + toggle->setToolTip(tr("Hide Change Description")); + else + toggle->setToolTip(tr("Show Change Description")); + + m_toggleDescriptionAction->setVisible(enabled); + +} + } // namespace DiffEditor + +#include "diffeditor.moc" diff --git a/src/plugins/diffeditor/diffeditor.h b/src/plugins/diffeditor/diffeditor.h index 14bb779dd5..f149f8e58e 100644 --- a/src/plugins/diffeditor/diffeditor.h +++ b/src/plugins/diffeditor/diffeditor.h @@ -39,14 +39,15 @@ QT_BEGIN_NAMESPACE class QToolBar; class QComboBox; +class QToolButton; QT_END_NAMESPACE +namespace TextEditor { class BaseTextEditorWidget; } + namespace DiffEditor { class SideBySideDiffEditorWidget; -namespace Internal { -class DiffEditorDocument; -} +namespace Internal { class DiffEditorDocument; } class DIFFEDITOR_EXPORT DiffEditor : public Core::IEditor { @@ -58,6 +59,8 @@ public: public: void setDiff(const QList<DiffEditorController::DiffFilesContents> &diffFileList, const QString &workingDirectory = QString()); + void setDescription(const QString &description); + void setDescriptionEnabled(bool on); void clear(const QString &message); // Core::IEditor @@ -73,6 +76,8 @@ public slots: private slots: void entryActivated(int index); + void slotDescriptionChanged(const QString &description); + void slotDescriptionVisibilityChanged(); protected: QToolBar *m_toolWidget; @@ -81,9 +86,11 @@ private: void updateEntryToolTip(); Internal::DiffEditorDocument *m_document; - SideBySideDiffEditorWidget *m_editorWidget; + TextEditor::BaseTextEditorWidget *m_descriptionWidget; + SideBySideDiffEditorWidget *m_diffWidget; DiffEditorController *m_diffEditorController; QComboBox *m_entriesComboBox; + QAction *m_toggleDescriptionAction; }; } // namespace DiffEditor diff --git a/src/plugins/diffeditor/diffeditor.pro b/src/plugins/diffeditor/diffeditor.pro index a6f655118e..38554f1c5c 100644 --- a/src/plugins/diffeditor/diffeditor.pro +++ b/src/plugins/diffeditor/diffeditor.pro @@ -9,8 +9,6 @@ HEADERS += diffeditor_global.h \ diffeditorfactory.h \ diffeditorplugin.h \ differ.h \ - diffshoweditor.h \ - diffshoweditorfactory.h \ sidebysidediffeditorwidget.h SOURCES += diffeditor.cpp \ @@ -19,8 +17,6 @@ SOURCES += diffeditor.cpp \ diffeditorfactory.cpp \ diffeditorplugin.cpp \ differ.cpp \ - diffshoweditor.cpp \ - diffshoweditorfactory.cpp \ sidebysidediffeditorwidget.cpp RESOURCES += diff --git a/src/plugins/diffeditor/diffeditor.qbs b/src/plugins/diffeditor/diffeditor.qbs index 85ec1d912a..56bd28e5fb 100644 --- a/src/plugins/diffeditor/diffeditor.qbs +++ b/src/plugins/diffeditor/diffeditor.qbs @@ -25,10 +25,6 @@ QtcPlugin { "diffeditorplugin.h", "differ.cpp", "differ.h", - "diffshoweditor.cpp", - "diffshoweditor.h", - "diffshoweditorfactory.cpp", - "diffshoweditorfactory.h", "sidebysidediffeditorwidget.cpp", "sidebysidediffeditorwidget.h", ] diff --git a/src/plugins/diffeditor/diffeditorconstants.h b/src/plugins/diffeditor/diffeditorconstants.h index 8b94624d86..6180557dbb 100644 --- a/src/plugins/diffeditor/diffeditorconstants.h +++ b/src/plugins/diffeditor/diffeditorconstants.h @@ -38,8 +38,6 @@ 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 diff --git a/src/plugins/diffeditor/diffeditorcontroller.cpp b/src/plugins/diffeditor/diffeditorcontroller.cpp index 5aa790e5a6..4f2e749d89 100644 --- a/src/plugins/diffeditor/diffeditorcontroller.cpp +++ b/src/plugins/diffeditor/diffeditorcontroller.cpp @@ -33,9 +33,12 @@ namespace DiffEditor { DiffEditorController::DiffEditorController(QObject *parent) : QObject(parent), + m_descriptionEnabled(false), + m_descriptionVisible(true), m_contextLinesNumber(3), m_ignoreWhitespaces(true), - m_syncScrollBars(true) + m_syncScrollBars(true), + m_currentDiffFileIndex(-1) { clear(); } @@ -60,6 +63,21 @@ QString DiffEditorController::workingDirectory() const return m_workingDirectory; } +QString DiffEditorController::description() const +{ + return m_description; +} + +bool DiffEditorController::isDescriptionEnabled() const +{ + return m_descriptionEnabled; +} + +bool DiffEditorController::isDescriptionVisible() const +{ + return m_descriptionVisible; +} + int DiffEditorController::contextLinesNumber() const { return m_contextLinesNumber; @@ -100,6 +118,33 @@ void DiffEditorController::setDiffContents(const QList<DiffFilesContents> &diffF emit diffContentsChanged(diffFileList, workingDirectory); } +void DiffEditorController::setDescription(const QString &description) +{ + if (m_description == description) + return; + + m_description = description; + emit descriptionChanged(description); +} + +void DiffEditorController::setDescriptionEnabled(bool on) +{ + if (m_descriptionEnabled == on) + return; + + m_descriptionEnabled = on; + emit descriptionEnablementChanged(on); +} + +void DiffEditorController::setDescriptionVisible(bool on) +{ + if (m_descriptionVisible == on) + return; + + m_descriptionVisible = on; + emit descriptionVisibilityChanged(on); +} + void DiffEditorController::setContextLinesNumber(int lines) { const int l = qMax(lines, -1); diff --git a/src/plugins/diffeditor/diffeditorcontroller.h b/src/plugins/diffeditor/diffeditorcontroller.h index a03d54052f..0367974315 100644 --- a/src/plugins/diffeditor/diffeditorcontroller.h +++ b/src/plugins/diffeditor/diffeditorcontroller.h @@ -70,7 +70,10 @@ public: QList<DiffFilesContents> diffContents() const; QString workingDirectory() const; + QString description() const; + bool isDescriptionEnabled() const; + bool isDescriptionVisible() const; int contextLinesNumber() const; bool isIgnoreWhitespaces() const; bool horizontalScrollBarSynchronization() const; @@ -80,7 +83,10 @@ public slots: void clear(); void clear(const QString &message); void setDiffContents(const QList<DiffEditorController::DiffFilesContents> &diffFileList, const QString &workingDirectory = QString()); + void setDescription(const QString &description); + void setDescriptionEnabled(bool on); + void setDescriptionVisible(bool on); void setContextLinesNumber(int lines); void setIgnoreWhitespaces(bool ignore); void setHorizontalScrollBarSynchronization(bool on); @@ -91,7 +97,10 @@ signals: void cleared(const QString message); // This sets the current diff file index to 0 (unless diffFileList is empty) void diffContentsChanged(const QList<DiffEditorController::DiffFilesContents> &diffFileList, const QString &workingDirectory); + void descriptionChanged(const QString &description); + void descriptionEnablementChanged(bool on); + void descriptionVisibilityChanged(bool on); void contextLinesNumberChanged(int lines); void ignoreWhitespacesChanged(bool ignore); void horizontalScrollBarSynchronizationChanged(bool on); @@ -102,7 +111,10 @@ private: QList<DiffFilesContents> m_diffFileList; QString m_workingDirectory; + QString m_description; + bool m_descriptionEnabled; + bool m_descriptionVisible; int m_contextLinesNumber; bool m_ignoreWhitespaces; bool m_syncScrollBars; diff --git a/src/plugins/diffeditor/diffeditorplugin.cpp b/src/plugins/diffeditor/diffeditorplugin.cpp index 812993fa81..71c3b2a024 100644 --- a/src/plugins/diffeditor/diffeditorplugin.cpp +++ b/src/plugins/diffeditor/diffeditorplugin.cpp @@ -31,8 +31,6 @@ #include "diffeditor.h" #include "diffeditorconstants.h" #include "diffeditorfactory.h" -#include "diffshoweditor.h" -#include "diffshoweditorfactory.h" #include "sidebysidediffeditorwidget.h" #include <QFileDialog> @@ -74,7 +72,6 @@ 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; } diff --git a/src/plugins/diffeditor/diffshoweditor.cpp b/src/plugins/diffeditor/diffshoweditor.cpp deleted file mode 100644 index 5da07d929d..0000000000 --- a/src/plugins/diffeditor/diffshoweditor.cpp +++ /dev/null @@ -1,176 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 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 "sidebysidediffeditorwidget.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"; } -}; - -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(SideBySideDiffEditorWidget *editorWidget) - : DiffEditor(editorWidget) -{ - document()->setDisplayName(QCoreApplication::translate("DiffShowEditor", - Constants::DIFF_SHOW_EDITOR_DISPLAY_NAME)); - 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); - - connect(TextEditorSettings::instance(), SIGNAL(displaySettingsChanged(TextEditor::DisplaySettings)), - m_diffShowWidget, SLOT(setDisplaySettings(TextEditor::DisplaySettings))); - connect(TextEditorSettings::instance(), SIGNAL(fontSettingsChanged(TextEditor::FontSettings)), - m_diffShowWidget->baseTextDocument(), SLOT(setFontSettings(TextEditor::FontSettings))); - m_diffShowWidget->setDisplaySettings(TextEditorSettings::displaySettings()); - m_diffShowWidget->setCodeStyle(TextEditorSettings::codeStyle()); - m_diffShowWidget->baseTextDocument()->setFontSettings(TextEditorSettings::fontSettings()); -} - -DiffShowEditor::~DiffShowEditor() -{ -} - -void DiffShowEditor::setDescription(const QString &description) -{ - m_diffShowWidget->setPlainText(description); -} - -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" diff --git a/src/plugins/diffeditor/diffshoweditor.h b/src/plugins/diffeditor/diffshoweditor.h deleted file mode 100644 index ff30cc3e6a..0000000000 --- a/src/plugins/diffeditor/diffshoweditor.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 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 TextEditor { class BaseTextEditorWidget; } - -namespace DiffEditor { - -class DIFFEDITOR_EXPORT DiffShowEditor : public DiffEditor -{ - Q_OBJECT -public: - explicit DiffShowEditor(SideBySideDiffEditorWidget *editorWidget); - virtual ~DiffShowEditor(); - -public: - void setDescription(const QString &description); - // Core::IEditor - Core::Id id() const; - - QWidget *toolBar(); - -private slots: - void setDescriptionVisible(bool visible); - -private: - void updateEntryToolTip(); - - TextEditor::BaseTextEditorWidget *m_diffShowWidget; - QToolButton *m_toggleDescriptionButton; -}; - -} // namespace DiffEditor - -#endif // DIFFEDITOR_H diff --git a/src/plugins/diffeditor/diffshoweditorfactory.cpp b/src/plugins/diffeditor/diffshoweditorfactory.cpp deleted file mode 100644 index f0acb1d8cf..0000000000 --- a/src/plugins/diffeditor/diffshoweditorfactory.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 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 "diffeditorconstants.h" -#include "diffshoweditorfactory.h" -#include "diffshoweditor.h" -#include "sidebysidediffeditorwidget.h" - -#include <QCoreApplication> - -namespace DiffEditor { - -namespace Internal { - -DiffShowEditorFactory::DiffShowEditorFactory(QObject *parent) - : IEditorFactory(parent) -{ - setId(Constants::DIFF_SHOW_EDITOR_ID); - setDisplayName(qApp->translate("DiffEditorFactory", Constants::DIFF_SHOW_EDITOR_DISPLAY_NAME)); - setMimeTypes(QStringList() << QLatin1String(Constants::DIFF_EDITOR_MIMETYPE)); -} - -Core::IEditor *DiffShowEditorFactory::createEditor() -{ - SideBySideDiffEditorWidget *editorWidget = new SideBySideDiffEditorWidget(); - DiffEditorController *editorController = new DiffEditorController(editorWidget); - editorWidget->setDiffEditorController(editorController); - DiffShowEditor *editor = new DiffShowEditor(editorWidget); - return editor; -} - -} // namespace Internal -} // namespace DiffEditor diff --git a/src/plugins/diffeditor/diffshoweditorfactory.h b/src/plugins/diffeditor/diffshoweditorfactory.h deleted file mode 100644 index b1823a27a9..0000000000 --- a/src/plugins/diffeditor/diffshoweditorfactory.h +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 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); - - Core::IEditor *createEditor(); -}; - -} // namespace Internal -} // namespace DiffEditor - -#endif // DIFFSHOWEDITORFACTORY_H diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp index b34d3ab0e6..a5783fa3b9 100644 --- a/src/plugins/git/gitclient.cpp +++ b/src/plugins/git/gitclient.cpp @@ -60,7 +60,6 @@ #include <vcsbase/vcsbaseplugin.h> #include <diffeditor/diffeditor.h> -#include <diffeditor/diffshoweditor.h> #include <diffeditor/diffeditorconstants.h> #include <QCoreApplication> @@ -375,11 +374,9 @@ void GitDiffHandler::slotShowDescriptionReceived(const QString &description) { if (m_editor.isNull()) return; - DiffEditor::DiffShowEditor *editor = qobject_cast<DiffEditor::DiffShowEditor *>(m_editor); - if (editor) { - editor->setDescription(GitPlugin::instance()->gitClient()-> - extendedShowDescription(m_workingDirectory, description)); - } + + m_editor->setDescription(GitPlugin::instance()->gitClient()-> + extendedShowDescription(m_workingDirectory, description)); collectFilesList(QStringList() << m_requestedRevisionRange.begin.id @@ -1446,7 +1443,8 @@ void GitClient::show(const QString &source, const QString &id, id, source, title, - DiffEditor::Constants::DIFF_SHOW_EDITOR_ID); + DiffEditor::Constants::DIFF_EDITOR_ID); + diffEditor->setDescriptionEnabled(true); } GitDiffHandler *handler = new GitDiffHandler(diffEditor, |