Files
qt-creator/src/plugins/duieditor/duieditor.h

159 lines
3.9 KiB
C
Raw Normal View History

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).
**
** 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>
#include "qmljsastfwd_p.h"
#include "qmljsengine_p.h"
#include "duidocument.h"
2009-04-22 15:21:04 +02:00
QT_BEGIN_NAMESPACE
class QComboBox;
class QTimer;
QT_END_NAMESPACE
namespace Core {
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
{
Q_OBJECT
2009-05-06 15:45:19 +02:00
2009-04-22 15:21:04 +02:00
public:
ScriptEditorEditable(ScriptEditor *, const QList<int> &);
QList<int> context() const;
2009-04-22 15:21:04 +02:00
bool duplicateSupported() const { return true; }
Core::IEditor *duplicate(QWidget *parent);
const char *kind() const;
bool isTemporary() const { return false; }
2009-04-22 15:21:04 +02:00
private:
QList<int> m_context;
2009-04-22 15:21:04 +02:00
};
struct Declaration
{
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
{
Q_OBJECT
2009-04-22 15:21:04 +02:00
public:
typedef QList<int> Context;
2009-04-22 15:21:04 +02:00
ScriptEditor(const Context &context,
QWidget *parent = 0);
~ScriptEditor();
2009-04-22 15:21:04 +02:00
QList<Declaration> declarations() const;
QStringList words() const;
QStringList keywords() const;
2009-04-22 15:21:04 +02:00
QList<QmlJS::DiagnosticMessage> diagnosticMessages() const
{ return m_diagnosticMessages; }
2009-05-06 15:45:19 +02:00
virtual void unCommentSelection();
DuiDocument::Ptr duiDocument() const { return m_document; }
2009-04-22 15:21:04 +02:00
public slots:
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);
void updateDocument();
void updateDocumentNow();
void jumpToMethod(int index);
void updateMethodBoxIndex();
void updateMethodBoxToolTip();
void updateFileName();
2009-04-22 15:21:04 +02:00
// refactoring ops
void renameIdUnderCursor();
2009-05-05 15:33:39 +02:00
2009-04-22 15:21:04 +02:00
protected:
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:
virtual bool isElectricCharacter(const QChar &ch) const;
virtual void indentBlock(QTextDocument *doc, QTextBlock block, QChar typedChar);
2009-04-22 15:21:04 +02:00
QString wordUnderCursor() const;
2009-05-05 15:33:39 +02:00
const Context m_context;
2009-04-22 15:21:04 +02:00
QTimer *m_updateDocumentTimer;
QComboBox *m_methodCombo;
QList<Declaration> m_declarations;
QStringList m_words;
QMap<QString, QList<QmlJS::AST::SourceLocation> > m_ids; // ### use QMultiMap
QList<QmlJS::DiagnosticMessage> m_diagnosticMessages;
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