forked from qt-creator/qt-creator
QmlJSEditor: some Qt5-ification
Change-Id: I494ec29e0e9c09192f30c80945725276cc03b531 Reviewed-by: Christian Stenger <christian.stenger@digia.com>
This commit is contained in:
@@ -122,16 +122,16 @@ void QmlJSEditorWidget::finalizeInitialization()
|
|||||||
{
|
{
|
||||||
m_qmlJsEditorDocument = static_cast<QmlJSEditorDocument *>(textDocument());
|
m_qmlJsEditorDocument = static_cast<QmlJSEditorDocument *>(textDocument());
|
||||||
|
|
||||||
m_updateUsesTimer = new QTimer(this);
|
m_updateUsesTimer.setInterval(UPDATE_USES_DEFAULT_INTERVAL);
|
||||||
m_updateUsesTimer->setInterval(UPDATE_USES_DEFAULT_INTERVAL);
|
m_updateUsesTimer.setSingleShot(true);
|
||||||
m_updateUsesTimer->setSingleShot(true);
|
connect(&m_updateUsesTimer, &QTimer::timeout, this, &QmlJSEditorWidget::updateUses);
|
||||||
connect(m_updateUsesTimer, SIGNAL(timeout()), this, SLOT(updateUses()));
|
connect(this, &QPlainTextEdit::cursorPositionChanged,
|
||||||
connect(this, SIGNAL(cursorPositionChanged()), m_updateUsesTimer, SLOT(start()));
|
&m_updateUsesTimer, static_cast<void (QTimer::*)()>(&QTimer::start));
|
||||||
|
|
||||||
m_updateOutlineIndexTimer = new QTimer(this);
|
m_updateOutlineIndexTimer.setInterval(UPDATE_OUTLINE_INTERVAL);
|
||||||
m_updateOutlineIndexTimer->setInterval(UPDATE_OUTLINE_INTERVAL);
|
m_updateOutlineIndexTimer.setSingleShot(true);
|
||||||
m_updateOutlineIndexTimer->setSingleShot(true);
|
connect(&m_updateOutlineIndexTimer, &QTimer::timeout,
|
||||||
connect(m_updateOutlineIndexTimer, SIGNAL(timeout()), this, SLOT(updateOutlineIndexNow()));
|
this, &QmlJSEditorWidget::updateOutlineIndexNow);
|
||||||
|
|
||||||
textDocument()->setCodec(QTextCodec::codecForName("UTF-8")); // qml files are defined to be utf-8
|
textDocument()->setCodec(QTextCodec::codecForName("UTF-8")); // qml files are defined to be utf-8
|
||||||
|
|
||||||
@@ -140,20 +140,22 @@ void QmlJSEditorWidget::finalizeInitialization()
|
|||||||
|
|
||||||
m_modelManager->activateScan();
|
m_modelManager->activateScan();
|
||||||
|
|
||||||
m_contextPaneTimer = new QTimer(this);
|
m_contextPaneTimer.setInterval(UPDATE_OUTLINE_INTERVAL);
|
||||||
m_contextPaneTimer->setInterval(UPDATE_OUTLINE_INTERVAL);
|
m_contextPaneTimer.setSingleShot(true);
|
||||||
m_contextPaneTimer->setSingleShot(true);
|
connect(&m_contextPaneTimer, &QTimer::timeout, this, &QmlJSEditorWidget::updateContextPane);
|
||||||
connect(m_contextPaneTimer, SIGNAL(timeout()), this, SLOT(updateContextPane()));
|
|
||||||
if (m_contextPane) {
|
if (m_contextPane) {
|
||||||
connect(this, SIGNAL(cursorPositionChanged()), m_contextPaneTimer, SLOT(start()));
|
connect(this, &QmlJSEditorWidget::cursorPositionChanged,
|
||||||
connect(m_contextPane, SIGNAL(closed()), this, SLOT(showTextMarker()));
|
&m_contextPaneTimer, static_cast<void (QTimer::*)()>(&QTimer::start));
|
||||||
|
connect(m_contextPane, &IContextPane::closed, this, &QmlJSEditorWidget::showTextMarker);
|
||||||
}
|
}
|
||||||
m_oldCursorPosition = -1;
|
m_oldCursorPosition = -1;
|
||||||
|
|
||||||
connect(this->document(), SIGNAL(modificationChanged(bool)), this, SLOT(modificationChanged(bool)));
|
connect(this->document(), &QTextDocument::modificationChanged,
|
||||||
|
this, &QmlJSEditorWidget::modificationChanged);
|
||||||
|
|
||||||
connect(m_qmlJsEditorDocument, SIGNAL(updateCodeWarnings(QmlJS::Document::Ptr)),
|
connect(m_qmlJsEditorDocument, SIGNAL(updateCodeWarnings(QmlJS::Document::Ptr)),
|
||||||
this, SLOT(updateCodeWarnings(QmlJS::Document::Ptr)));
|
this, SLOT(updateCodeWarnings(QmlJS::Document::Ptr)));
|
||||||
|
|
||||||
connect(m_qmlJsEditorDocument, SIGNAL(semanticInfoUpdated(QmlJSTools::SemanticInfo)),
|
connect(m_qmlJsEditorDocument, SIGNAL(semanticInfoUpdated(QmlJSTools::SemanticInfo)),
|
||||||
this, SLOT(semanticInfoUpdated(QmlJSTools::SemanticInfo)));
|
this, SLOT(semanticInfoUpdated(QmlJSTools::SemanticInfo)));
|
||||||
|
|
||||||
@@ -257,7 +259,7 @@ void QmlJSEditorWidget::updateOutlineIndexNow()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_qmlJsEditorDocument->outlineModel()->document()->editorRevision() != document()->revision()) {
|
if (m_qmlJsEditorDocument->outlineModel()->document()->editorRevision() != document()->revision()) {
|
||||||
m_updateOutlineIndexTimer->start();
|
m_updateOutlineIndexTimer.start();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -561,7 +563,8 @@ void QmlJSEditorWidget::createToolBar()
|
|||||||
connect(m_qmlJsEditorDocument->outlineModel(), SIGNAL(updated()),
|
connect(m_qmlJsEditorDocument->outlineModel(), SIGNAL(updated()),
|
||||||
this, SLOT(updateOutlineIndexNow()));
|
this, SLOT(updateOutlineIndexNow()));
|
||||||
|
|
||||||
connect(this, SIGNAL(cursorPositionChanged()), m_updateOutlineIndexTimer, SLOT(start()));
|
connect(this, &QmlJSEditorWidget::cursorPositionChanged,
|
||||||
|
&m_updateOutlineIndexTimer, static_cast<void (QTimer::*)()>(&QTimer::start));
|
||||||
|
|
||||||
insertExtraToolBarWidget(BaseTextEditorWidget::Left, m_outlineCombo);
|
insertExtraToolBarWidget(BaseTextEditorWidget::Left, m_outlineCombo);
|
||||||
}
|
}
|
||||||
@@ -795,7 +798,7 @@ void QmlJSEditorWidget::semanticInfoUpdated(const SemanticInfo &semanticInfo)
|
|||||||
Node *newNode = semanticInfo.declaringMemberNoProperties(position());
|
Node *newNode = semanticInfo.declaringMemberNoProperties(position());
|
||||||
if (newNode) {
|
if (newNode) {
|
||||||
m_contextPane->apply(editor(), semanticInfo.document, 0, newNode, true);
|
m_contextPane->apply(editor(), semanticInfo.document, 0, newNode, true);
|
||||||
m_contextPaneTimer->start(); //update text marker
|
m_contextPaneTimer.start(); //update text marker
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,10 +40,10 @@
|
|||||||
#include <utils/uncommentselection.h>
|
#include <utils/uncommentselection.h>
|
||||||
|
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QComboBox;
|
class QComboBox;
|
||||||
class QTimer;
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace QmlJS {
|
namespace QmlJS {
|
||||||
@@ -123,9 +123,9 @@ private:
|
|||||||
bool hideContextPane();
|
bool hideContextPane();
|
||||||
|
|
||||||
QmlJSEditorDocument *m_qmlJsEditorDocument;
|
QmlJSEditorDocument *m_qmlJsEditorDocument;
|
||||||
QTimer *m_updateUsesTimer; // to wait for multiple text cursor position changes
|
QTimer m_updateUsesTimer; // to wait for multiple text cursor position changes
|
||||||
QTimer *m_updateOutlineIndexTimer;
|
QTimer m_updateOutlineIndexTimer;
|
||||||
QTimer *m_contextPaneTimer;
|
QTimer m_contextPaneTimer;
|
||||||
QComboBox *m_outlineCombo;
|
QComboBox *m_outlineCombo;
|
||||||
QModelIndex m_outlineModelIndex;
|
QModelIndex m_outlineModelIndex;
|
||||||
QmlJS::ModelManagerInterface *m_modelManager;
|
QmlJS::ModelManagerInterface *m_modelManager;
|
||||||
|
|||||||
Reference in New Issue
Block a user