forked from qt-creator/qt-creator
BinEditor: Code cosmetics
Change-Id: I59836b26094d86699dc36e36167b025fadb7ca37 Reviewed-by: Christian Kandeler <christian.kandeler@digia.com> Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
@@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
#include <texteditor/fontsettings.h>
|
#include <texteditor/fontsettings.h>
|
||||||
#include <texteditor/texteditorconstants.h>
|
#include <texteditor/texteditorconstants.h>
|
||||||
|
#include <texteditor/texteditorsettings.h>
|
||||||
#include <coreplugin/editormanager/ieditor.h>
|
#include <coreplugin/editormanager/ieditor.h>
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
@@ -106,6 +107,13 @@ BinEditorWidget::BinEditorWidget(QWidget *parent)
|
|||||||
m_canRequestNewWindow = false;
|
m_canRequestNewWindow = false;
|
||||||
setFocusPolicy(Qt::WheelFocus);
|
setFocusPolicy(Qt::WheelFocus);
|
||||||
setFrameStyle(QFrame::Plain);
|
setFrameStyle(QFrame::Plain);
|
||||||
|
|
||||||
|
// Font settings
|
||||||
|
TextEditor::TextEditorSettings *settings = TextEditor::TextEditorSettings::instance();
|
||||||
|
setFontSettings(settings->fontSettings());
|
||||||
|
connect(settings, SIGNAL(fontSettingsChanged(TextEditor::FontSettings)),
|
||||||
|
this, SLOT(setFontSettings(TextEditor::FontSettings)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BinEditorWidget::~BinEditorWidget()
|
BinEditorWidget::~BinEditorWidget()
|
||||||
|
@@ -62,6 +62,7 @@ class BinEditorWidget : public QAbstractScrollArea
|
|||||||
Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly DESIGNABLE false)
|
Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly DESIGNABLE false)
|
||||||
Q_PROPERTY(QList<BINEditor::Markup> markup READ markup WRITE setMarkup DESIGNABLE false)
|
Q_PROPERTY(QList<BINEditor::Markup> markup READ markup WRITE setMarkup DESIGNABLE false)
|
||||||
Q_PROPERTY(bool newWindowRequestAllowed READ newWindowRequestAllowed WRITE setNewWindowRequestAllowed DESIGNABLE false)
|
Q_PROPERTY(bool newWindowRequestAllowed READ newWindowRequestAllowed WRITE setNewWindowRequestAllowed DESIGNABLE false)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BinEditorWidget(QWidget *parent = 0);
|
BinEditorWidget(QWidget *parent = 0);
|
||||||
~BinEditorWidget();
|
~BinEditorWidget();
|
||||||
|
@@ -58,8 +58,6 @@
|
|||||||
#include <coreplugin/mimedatabase.h>
|
#include <coreplugin/mimedatabase.h>
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
#include <find/ifindsupport.h>
|
#include <find/ifindsupport.h>
|
||||||
#include <texteditor/fontsettings.h>
|
|
||||||
#include <texteditor/texteditorsettings.h>
|
|
||||||
#include <utils/reloadpromptutils.h>
|
#include <utils/reloadpromptutils.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
@@ -77,9 +75,10 @@ public:
|
|||||||
m_widget = widget;
|
m_widget = widget;
|
||||||
m_incrementalStartPos = m_contPos = -1;
|
m_incrementalStartPos = m_contPos = -1;
|
||||||
}
|
}
|
||||||
~BinEditorFind() {}
|
|
||||||
|
|
||||||
bool supportsReplace() const { return false; }
|
bool supportsReplace() const { return false; }
|
||||||
|
QString currentFindString() const { return QString(); }
|
||||||
|
QString completedFindString() const { return QString(); }
|
||||||
|
|
||||||
Find::FindFlags supportedFindFlags() const
|
Find::FindFlags supportedFindFlags() const
|
||||||
{
|
{
|
||||||
@@ -96,12 +95,13 @@ public:
|
|||||||
m_widget->highlightSearchResults(txt.toLatin1(), Find::textDocumentFlagsForFindFlags(findFlags));
|
m_widget->highlightSearchResults(txt.toLatin1(), Find::textDocumentFlagsForFindFlags(findFlags));
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearResults() { m_widget->highlightSearchResults(QByteArray()); }
|
void clearResults()
|
||||||
QString currentFindString() const { return QString(); }
|
{
|
||||||
QString completedFindString() const { return QString(); }
|
m_widget->highlightSearchResults(QByteArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
int find(const QByteArray &pattern, int pos, Find::FindFlags findFlags)
|
||||||
int find(const QByteArray &pattern, int pos, Find::FindFlags findFlags) {
|
{
|
||||||
if (pattern.isEmpty()) {
|
if (pattern.isEmpty()) {
|
||||||
m_widget->setCursorPosition(pos);
|
m_widget->setCursorPosition(pos);
|
||||||
return pos;
|
return pos;
|
||||||
@@ -341,13 +341,15 @@ public:
|
|||||||
m_toolBar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
m_toolBar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||||
m_toolBar->addWidget(w);
|
m_toolBar->addWidget(w);
|
||||||
|
|
||||||
connect(m_widget, SIGNAL(cursorPositionChanged(int)), this,
|
widget->setEditor(this);
|
||||||
SLOT(updateCursorPosition(int)));
|
|
||||||
connect(m_file, SIGNAL(changed()), this, SIGNAL(changed()));
|
connect(m_widget, SIGNAL(cursorPositionChanged(int)), SLOT(updateCursorPosition(int)));
|
||||||
connect(m_addressEdit, SIGNAL(editingFinished()), this,
|
connect(m_file, SIGNAL(changed()), SIGNAL(changed()));
|
||||||
SLOT(jumpToAddress()));
|
connect(m_addressEdit, SIGNAL(editingFinished()), SLOT(jumpToAddress()));
|
||||||
|
connect(m_widget, SIGNAL(modificationChanged(bool)), SIGNAL(changed()));
|
||||||
updateCursorPosition(m_widget->cursorPosition());
|
updateCursorPosition(m_widget->cursorPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
~BinEditor() {
|
~BinEditor() {
|
||||||
delete m_widget;
|
delete m_widget;
|
||||||
}
|
}
|
||||||
@@ -411,8 +413,10 @@ QString BinEditorFactory::displayName() const
|
|||||||
Core::IEditor *BinEditorFactory::createEditor(QWidget *parent)
|
Core::IEditor *BinEditorFactory::createEditor(QWidget *parent)
|
||||||
{
|
{
|
||||||
BinEditorWidget *widget = new BinEditorWidget(parent);
|
BinEditorWidget *widget = new BinEditorWidget(parent);
|
||||||
|
BinEditor *editor = new BinEditor(widget);
|
||||||
|
|
||||||
m_owner->initializeEditor(widget);
|
m_owner->initializeEditor(widget);
|
||||||
return widget->editor();
|
return editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList BinEditorFactory::mimeTypes() const
|
QStringList BinEditorFactory::mimeTypes() const
|
||||||
@@ -471,10 +475,6 @@ QAction *BinEditorPlugin::registerNewAction(Core::Id id,
|
|||||||
|
|
||||||
void BinEditorPlugin::initializeEditor(BinEditorWidget *widget)
|
void BinEditorPlugin::initializeEditor(BinEditorWidget *widget)
|
||||||
{
|
{
|
||||||
BinEditor *editor = new BinEditor(widget);
|
|
||||||
QObject::connect(widget, SIGNAL(modificationChanged(bool)), editor, SIGNAL(changed()));
|
|
||||||
widget->setEditor(editor);
|
|
||||||
|
|
||||||
m_context.add(Constants::C_BINEDITOR);
|
m_context.add(Constants::C_BINEDITOR);
|
||||||
if (!m_undoAction) {
|
if (!m_undoAction) {
|
||||||
m_undoAction = registerNewAction(Core::Constants::UNDO, this, SLOT(undoAction()), tr("&Undo"));
|
m_undoAction = registerNewAction(Core::Constants::UNDO, this, SLOT(undoAction()), tr("&Undo"));
|
||||||
@@ -483,12 +483,6 @@ void BinEditorPlugin::initializeEditor(BinEditorWidget *widget)
|
|||||||
m_selectAllAction = registerNewAction(Core::Constants::SELECTALL, this, SLOT(selectAllAction()));
|
m_selectAllAction = registerNewAction(Core::Constants::SELECTALL, this, SLOT(selectAllAction()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Font settings
|
|
||||||
TextEditor::TextEditorSettings *settings = TextEditor::TextEditorSettings::instance();
|
|
||||||
widget->setFontSettings(settings->fontSettings());
|
|
||||||
connect(settings, SIGNAL(fontSettingsChanged(TextEditor::FontSettings)),
|
|
||||||
widget, SLOT(setFontSettings(TextEditor::FontSettings)));
|
|
||||||
|
|
||||||
QObject::connect(widget, SIGNAL(undoAvailable(bool)), this, SLOT(updateActions()));
|
QObject::connect(widget, SIGNAL(undoAvailable(bool)), this, SLOT(updateActions()));
|
||||||
QObject::connect(widget, SIGNAL(redoAvailable(bool)), this, SLOT(updateActions()));
|
QObject::connect(widget, SIGNAL(redoAvailable(bool)), this, SLOT(updateActions()));
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user