2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2009-04-22 15:21:04 +02:00
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2009-04-22 15:21:04 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2009-04-22 15:21:04 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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.
|
2009-04-22 15:21:04 +02:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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.
|
2009-04-22 15:21:04 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2009-04-22 15:21:04 +02:00
|
|
|
|
2010-01-15 17:20:03 +01:00
|
|
|
#ifndef QMLJSEDITOR_H
|
|
|
|
|
#define QMLJSEDITOR_H
|
2009-04-22 15:21:04 +02:00
|
|
|
|
2010-07-08 11:34:51 +02:00
|
|
|
#include "qmljseditor_global.h"
|
|
|
|
|
|
2010-01-18 16:15:23 +01:00
|
|
|
#include <qmljs/qmljsscanner.h>
|
2012-04-12 15:51:56 +02:00
|
|
|
#include <qmljstools/qmljssemanticinfo.h>
|
2009-04-22 15:21:04 +02:00
|
|
|
#include <texteditor/basetexteditor.h>
|
2010-09-16 12:57:07 +02:00
|
|
|
#include <texteditor/quickfix.h>
|
2012-04-26 14:17:42 +02:00
|
|
|
#include <texteditor/texteditorconstants.h>
|
2014-08-20 01:47:42 +02:00
|
|
|
#include <utils/uncommentselection.h>
|
2009-05-14 14:09:00 +02:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QModelIndex>
|
2010-02-16 10:36:09 +01:00
|
|
|
|
2009-04-22 15:21:04 +02:00
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
class QComboBox;
|
|
|
|
|
class QTimer;
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
2010-06-09 15:56:03 +02:00
|
|
|
namespace QmlJS {
|
|
|
|
|
class ModelManagerInterface;
|
2010-07-07 13:09:30 +02:00
|
|
|
class IContextPane;
|
2014-02-11 21:55:42 +02:00
|
|
|
namespace AST { class UiObjectMember; }
|
2010-06-09 15:56:03 +02:00
|
|
|
}
|
2009-09-04 16:51:11 +02:00
|
|
|
|
2010-06-09 15:56:03 +02:00
|
|
|
namespace QmlJSEditor {
|
2014-08-20 01:47:42 +02:00
|
|
|
|
2014-02-07 13:45:51 +01:00
|
|
|
class QmlJSEditorDocument;
|
2010-09-24 14:05:34 +02:00
|
|
|
class FindReferences;
|
2009-09-04 16:51:11 +02:00
|
|
|
|
2009-04-22 15:21:04 +02:00
|
|
|
namespace Internal {
|
2014-02-07 14:21:58 +01:00
|
|
|
|
2014-08-25 20:01:46 +02:00
|
|
|
class QmlJSEditorWidget : public TextEditor::BaseTextEditorWidget
|
2009-04-22 15:21:04 +02:00
|
|
|
{
|
2009-09-22 17:25:18 +02:00
|
|
|
Q_OBJECT
|
2009-04-22 15:21:04 +02:00
|
|
|
|
|
|
|
|
public:
|
2014-08-23 00:19:48 +02:00
|
|
|
QmlJSEditorWidget();
|
|
|
|
|
|
|
|
|
|
void finalizeInitialization();
|
2009-04-22 15:21:04 +02:00
|
|
|
|
2014-02-07 13:45:51 +01:00
|
|
|
QmlJSEditorDocument *qmlJsEditorDocument() const;
|
2014-01-30 17:18:35 +01:00
|
|
|
|
2010-07-12 16:40:15 +02:00
|
|
|
QModelIndex outlineModelIndex();
|
2010-07-08 11:34:51 +02:00
|
|
|
|
2011-04-15 16:19:23 +02:00
|
|
|
TextEditor::IAssistInterface *createAssistInterface(TextEditor::AssistKind assistKind,
|
|
|
|
|
TextEditor::AssistReason reason) const;
|
2009-04-22 15:21:04 +02:00
|
|
|
public slots:
|
2010-09-24 14:05:34 +02:00
|
|
|
void findUsages();
|
2011-07-11 12:53:05 +02:00
|
|
|
void renameUsages();
|
2010-08-04 13:50:15 +02:00
|
|
|
void showContextPane();
|
2009-04-22 15:21:04 +02:00
|
|
|
|
2010-07-01 11:09:47 +02:00
|
|
|
signals:
|
2010-07-12 14:45:22 +02:00
|
|
|
void outlineModelIndexChanged(const QModelIndex &index);
|
2012-05-10 17:06:29 +02:00
|
|
|
void selectedElementsChanged(QList<QmlJS::AST::UiObjectMember*> offsets,
|
|
|
|
|
const QString &wordAtCursor);
|
2009-04-22 15:21:04 +02:00
|
|
|
private slots:
|
2010-04-16 12:42:12 +02:00
|
|
|
void modificationChanged(bool);
|
2009-09-04 16:51:11 +02:00
|
|
|
|
2010-07-13 11:24:16 +02:00
|
|
|
void jumpToOutlineElement(int index);
|
|
|
|
|
void updateOutlineIndexNow();
|
2014-01-30 15:48:24 +01:00
|
|
|
void updateContextPane();
|
2010-08-13 13:59:41 +02:00
|
|
|
void showTextMarker();
|
2009-04-22 15:21:04 +02:00
|
|
|
|
2010-01-14 16:30:48 +01:00
|
|
|
void updateUses();
|
|
|
|
|
|
2014-01-24 16:53:16 +01:00
|
|
|
void semanticInfoUpdated(const QmlJSTools::SemanticInfo &semanticInfo);
|
2010-02-16 10:36:09 +01:00
|
|
|
|
2010-09-16 12:57:07 +02:00
|
|
|
void performQuickFix(int index);
|
2014-01-24 16:53:16 +01:00
|
|
|
void updateCodeWarnings(QmlJS::Document::Ptr doc);
|
2010-09-16 12:57:07 +02:00
|
|
|
|
2009-04-22 15:21:04 +02:00
|
|
|
protected:
|
2009-09-22 17:25:18 +02:00
|
|
|
void contextMenuEvent(QContextMenuEvent *e);
|
2010-07-07 13:09:30 +02:00
|
|
|
bool event(QEvent *e);
|
|
|
|
|
void wheelEvent(QWheelEvent *event);
|
2010-07-20 15:01:06 +02:00
|
|
|
void resizeEvent(QResizeEvent *event);
|
|
|
|
|
void scrollContentsBy(int dx, int dy);
|
2014-01-21 11:26:39 +01:00
|
|
|
void applyFontSettings();
|
2011-02-21 16:02:26 +01:00
|
|
|
TextEditor::BaseTextEditor *createEditor();
|
2014-08-19 00:54:45 +02:00
|
|
|
void createToolBar();
|
2013-07-04 20:11:10 +02:00
|
|
|
TextEditor::BaseTextEditorWidget::Link findLinkAt(const QTextCursor &cursor,
|
|
|
|
|
bool resolveTarget = true,
|
|
|
|
|
bool inNextSplit = false);
|
2011-09-14 22:16:28 +02:00
|
|
|
QString foldReplacementText(const QTextBlock &block) const;
|
2014-08-22 14:43:29 +03:00
|
|
|
void onRefactorMarkerClicked(const TextEditor::RefactorMarker &marker);
|
2009-04-22 15:21:04 +02:00
|
|
|
|
|
|
|
|
private:
|
2010-01-19 12:54:17 +01:00
|
|
|
bool isClosingBrace(const QList<QmlJS::Token> &tokens) const;
|
2009-04-22 15:21:04 +02:00
|
|
|
|
2010-07-27 11:57:06 +02:00
|
|
|
void setSelectedElements();
|
2009-09-22 17:25:18 +02:00
|
|
|
QString wordUnderCursor() const;
|
2009-05-05 15:33:39 +02:00
|
|
|
|
2010-07-12 14:45:22 +02:00
|
|
|
QModelIndex indexForPosition(unsigned cursorPosition, const QModelIndex &rootIndex = QModelIndex()) const;
|
2010-07-20 15:01:06 +02:00
|
|
|
bool hideContextPane();
|
2010-02-16 10:36:09 +01:00
|
|
|
|
2014-02-07 13:45:51 +01:00
|
|
|
QmlJSEditorDocument *m_qmlJsEditorDocument;
|
2014-01-29 13:53:08 +01:00
|
|
|
QTimer *m_updateUsesTimer; // to wait for multiple text cursor position changes
|
2010-07-13 11:24:16 +02:00
|
|
|
QTimer *m_updateOutlineIndexTimer;
|
2014-01-30 15:48:24 +01:00
|
|
|
QTimer *m_contextPaneTimer;
|
2010-07-13 11:24:16 +02:00
|
|
|
QComboBox *m_outlineCombo;
|
2010-07-12 14:45:22 +02:00
|
|
|
QModelIndex m_outlineModelIndex;
|
2010-06-09 15:56:03 +02:00
|
|
|
QmlJS::ModelManagerInterface *m_modelManager;
|
2010-01-25 14:18:53 +01:00
|
|
|
|
2010-09-16 12:57:07 +02:00
|
|
|
QList<TextEditor::QuickFixOperation::Ptr> m_quickFixes;
|
|
|
|
|
|
2010-07-07 13:09:30 +02:00
|
|
|
QmlJS::IContextPane *m_contextPane;
|
2010-07-13 11:25:45 +02:00
|
|
|
int m_oldCursorPosition;
|
2010-09-24 14:05:34 +02:00
|
|
|
|
|
|
|
|
FindReferences *m_findReferences;
|
2009-04-22 15:21:04 +02:00
|
|
|
};
|
|
|
|
|
|
2014-08-20 01:47:42 +02:00
|
|
|
|
|
|
|
|
class QmlJSEditor : public TextEditor::BaseTextEditor
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
QmlJSEditor();
|
|
|
|
|
|
|
|
|
|
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
|
|
|
|
|
bool isDesignModePreferred() const;
|
2014-08-23 00:19:48 +02:00
|
|
|
void finalizeInitialization();
|
2014-08-20 01:47:42 +02:00
|
|
|
};
|
|
|
|
|
|
2014-08-23 00:19:48 +02:00
|
|
|
class QmlJSEditorFactory : public TextEditor::BaseTextEditorFactory
|
2014-08-20 01:47:42 +02:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
QmlJSEditorFactory();
|
|
|
|
|
};
|
|
|
|
|
|
2014-02-07 14:21:58 +01:00
|
|
|
} // namespace Internal
|
2010-01-15 17:20:03 +01:00
|
|
|
} // namespace QmlJSEditor
|
2009-04-22 15:21:04 +02:00
|
|
|
|
2010-01-15 17:20:03 +01:00
|
|
|
#endif // QMLJSEDITOR_H
|