2009-04-22 15:21:04 +02:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
|
|
|
|
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
|
|
|
**
|
2009-06-17 00:01:27 +10:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2009-04-22 15:21:04 +02:00
|
|
|
**
|
|
|
|
|
** Commercial Usage
|
|
|
|
|
**
|
|
|
|
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
|
|
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Nokia.
|
|
|
|
|
**
|
|
|
|
|
** 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.
|
|
|
|
|
**
|
|
|
|
|
** If you are unsure which license is appropriate for your use, please
|
2009-08-14 09:30:56 +02:00
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
2009-04-22 15:21:04 +02:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
#ifndef DUIDITORW_H
|
|
|
|
|
#define DUIDITORW_H
|
|
|
|
|
|
|
|
|
|
#include <texteditor/basetexteditor.h>
|
2009-05-14 14:09:00 +02:00
|
|
|
|
2009-06-11 11:22:26 +02:00
|
|
|
#include "qmljsastfwd_p.h"
|
|
|
|
|
#include "qmljsengine_p.h"
|
2009-05-14 14:09:00 +02:00
|
|
|
#include "duidocument.h"
|
2009-04-22 15:21:04 +02:00
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
class QComboBox;
|
|
|
|
|
class QTimer;
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
|
|
|
|
namespace Core {
|
2009-05-26 12:10:24 +02:00
|
|
|
class ICore;
|
2009-04-22 15:21:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace DuiEditor {
|
2009-09-04 16:51:11 +02:00
|
|
|
|
|
|
|
|
class DuiModelManagerInterface;
|
|
|
|
|
|
2009-04-22 15:21:04 +02:00
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
class DuiHighlighter;
|
|
|
|
|
|
|
|
|
|
class ScriptEditor;
|
|
|
|
|
|
|
|
|
|
class ScriptEditorEditable : public TextEditor::BaseTextEditorEditable
|
|
|
|
|
{
|
2009-05-26 12:10:24 +02:00
|
|
|
Q_OBJECT
|
2009-05-06 15:45:19 +02:00
|
|
|
|
2009-04-22 15:21:04 +02:00
|
|
|
public:
|
2009-05-26 12:10:24 +02:00
|
|
|
ScriptEditorEditable(ScriptEditor *, const QList<int> &);
|
|
|
|
|
QList<int> context() const;
|
2009-04-22 15:21:04 +02:00
|
|
|
|
2009-05-26 12:10:24 +02:00
|
|
|
bool duplicateSupported() const { return true; }
|
|
|
|
|
Core::IEditor *duplicate(QWidget *parent);
|
|
|
|
|
const char *kind() const;
|
2009-06-04 12:02:19 +02:00
|
|
|
bool isTemporary() const { return false; }
|
2009-04-22 15:21:04 +02:00
|
|
|
|
|
|
|
|
private:
|
2009-05-26 12:10:24 +02:00
|
|
|
QList<int> m_context;
|
2009-04-22 15:21:04 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct Declaration
|
|
|
|
|
{
|
2009-05-26 12:10:24 +02:00
|
|
|
QString text;
|
|
|
|
|
int startLine;
|
|
|
|
|
int startColumn;
|
|
|
|
|
int endLine;
|
|
|
|
|
int endColumn;
|
|
|
|
|
|
|
|
|
|
Declaration()
|
|
|
|
|
: startLine(0),
|
|
|
|
|
startColumn(0),
|
|
|
|
|
endLine(0),
|
|
|
|
|
endColumn(0)
|
|
|
|
|
{ }
|
2009-04-22 15:21:04 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class ScriptEditor : public TextEditor::BaseTextEditor
|
|
|
|
|
{
|
2009-05-26 12:10:24 +02:00
|
|
|
Q_OBJECT
|
2009-04-22 15:21:04 +02:00
|
|
|
|
|
|
|
|
public:
|
2009-05-26 12:10:24 +02:00
|
|
|
typedef QList<int> Context;
|
2009-04-22 15:21:04 +02:00
|
|
|
|
2009-05-26 12:10:24 +02:00
|
|
|
ScriptEditor(const Context &context,
|
|
|
|
|
QWidget *parent = 0);
|
|
|
|
|
~ScriptEditor();
|
2009-04-22 15:21:04 +02:00
|
|
|
|
2009-05-26 12:10:24 +02:00
|
|
|
QList<Declaration> declarations() const;
|
|
|
|
|
QStringList words() const;
|
|
|
|
|
QStringList keywords() const;
|
2009-04-22 15:21:04 +02:00
|
|
|
|
2009-06-11 11:22:26 +02:00
|
|
|
QList<QmlJS::DiagnosticMessage> diagnosticMessages() const
|
2009-05-26 12:10:24 +02:00
|
|
|
{ return m_diagnosticMessages; }
|
2009-05-06 15:45:19 +02:00
|
|
|
|
2009-05-26 12:10:24 +02:00
|
|
|
virtual void unCommentSelection();
|
2009-05-14 16:37:17 +02:00
|
|
|
|
2009-07-06 16:29:44 +02:00
|
|
|
DuiDocument::Ptr duiDocument() const { return m_document; }
|
|
|
|
|
|
2009-04-22 15:21:04 +02:00
|
|
|
public slots:
|
2009-05-26 12:10:24 +02:00
|
|
|
virtual void setFontSettings(const TextEditor::FontSettings &);
|
2009-04-22 15:21:04 +02:00
|
|
|
|
|
|
|
|
private slots:
|
2009-09-04 16:51:11 +02:00
|
|
|
void onDocumentUpdated(DuiDocument::Ptr doc);
|
|
|
|
|
|
2009-05-26 12:10:24 +02:00
|
|
|
void updateDocument();
|
|
|
|
|
void updateDocumentNow();
|
|
|
|
|
void jumpToMethod(int index);
|
|
|
|
|
void updateMethodBoxIndex();
|
|
|
|
|
void updateMethodBoxToolTip();
|
|
|
|
|
void updateFileName();
|
2009-04-22 15:21:04 +02:00
|
|
|
|
2009-05-26 12:10:24 +02:00
|
|
|
// refactoring ops
|
|
|
|
|
void renameIdUnderCursor();
|
2009-05-05 15:33:39 +02:00
|
|
|
|
2009-04-22 15:21:04 +02:00
|
|
|
protected:
|
2009-05-26 12:10:24 +02:00
|
|
|
void contextMenuEvent(QContextMenuEvent *e);
|
|
|
|
|
TextEditor::BaseTextEditorEditable *createEditableInterface();
|
|
|
|
|
void createToolBar(ScriptEditorEditable *editable);
|
2009-09-11 14:42:50 +02:00
|
|
|
TextEditor::BaseTextEditor::Link findLinkAt(const QTextCursor &cursor, bool resolveTarget = true);
|
|
|
|
|
virtual void reformat(QTextDocument *doc, QTextBlock block);
|
2009-04-22 15:21:04 +02:00
|
|
|
|
|
|
|
|
private:
|
2009-05-26 12:10:24 +02:00
|
|
|
virtual bool isElectricCharacter(const QChar &ch) const;
|
|
|
|
|
virtual void indentBlock(QTextDocument *doc, QTextBlock block, QChar typedChar);
|
2009-04-22 15:21:04 +02:00
|
|
|
|
2009-05-26 12:10:24 +02:00
|
|
|
QString wordUnderCursor() const;
|
2009-05-05 15:33:39 +02:00
|
|
|
|
2009-05-26 12:10:24 +02:00
|
|
|
const Context m_context;
|
2009-04-22 15:21:04 +02:00
|
|
|
|
2009-05-26 12:10:24 +02:00
|
|
|
QTimer *m_updateDocumentTimer;
|
|
|
|
|
QComboBox *m_methodCombo;
|
|
|
|
|
QList<Declaration> m_declarations;
|
|
|
|
|
QStringList m_words;
|
2009-06-11 11:22:26 +02:00
|
|
|
QMap<QString, QList<QmlJS::AST::SourceLocation> > m_ids; // ### use QMultiMap
|
|
|
|
|
QList<QmlJS::DiagnosticMessage> m_diagnosticMessages;
|
2009-05-26 12:10:24 +02:00
|
|
|
DuiDocument::Ptr m_document;
|
2009-09-04 16:51:11 +02:00
|
|
|
DuiModelManagerInterface *m_modelManager;
|
2009-04-22 15:21:04 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace DuiEditor
|
|
|
|
|
|
|
|
|
|
#endif // DUIDITORW_H
|