Move QmlConsole to Debugger

Now it is closer to its only user and possibly reusable for no-QML uses
there.  We also drop the QML/JS syntax checker. The application being
debugged can already tell us about syntax errors. There is no need to
duplicate that functionality.

Change-Id: I2ba151f9f4c854c6119ba5462c21be40bddcebf9
Reviewed-by: Ulf Hermann <ulf.hermann@theqtcompany.com>
Reviewed-by: hjk <hjk@theqtcompany.com>
This commit is contained in:
hjk
2015-11-10 16:59:02 +01:00
committed by Ulf Hermann
parent 0e76b99108
commit 33651877d8
41 changed files with 381 additions and 804 deletions

View File

@@ -1,168 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** 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 The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** 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 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "qmlconsoleedit.h"
#include "qmlconsoleitemmodel.h"
#include "qmlconsolemodel.h"
#include <utils/qtcassert.h>
#include <QUrl>
#include <QMenu>
#include <QKeyEvent>
using namespace QmlJS;
namespace QmlJSTools {
namespace Internal {
///////////////////////////////////////////////////////////////////////
//
// QmlConsoleEdit
//
///////////////////////////////////////////////////////////////////////
QmlConsoleEdit::QmlConsoleEdit(const QModelIndex &index, QWidget *parent) :
QTextEdit(parent),
m_historyIndex(index)
{
setFrameStyle(QFrame::NoFrame);
setUndoRedoEnabled(false);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
ensureCursorVisible();
setTextInteractionFlags(Qt::TextEditorInteraction);
}
void QmlConsoleEdit::keyPressEvent(QKeyEvent *e)
{
bool keyConsumed = false;
switch (e->key()) {
case Qt::Key_Return:
case Qt::Key_Enter: {
QString currentScript = getCurrentScript();
if (m_interpreter.canEvaluate(currentScript)) {
QmlConsoleModel::evaluate(currentScript);
emit editingFinished();
}
keyConsumed = true;
break;
}
case Qt::Key_Up:
handleUpKey();
keyConsumed = true;
break;
case Qt::Key_Down:
handleDownKey();
keyConsumed = true;
break;
default:
break;
}
if (!keyConsumed)
QTextEdit::keyPressEvent(e);
}
void QmlConsoleEdit::focusOutEvent(QFocusEvent * /*e*/)
{
emit editingFinished();
}
void QmlConsoleEdit::handleUpKey()
{
QTC_ASSERT(m_historyIndex.isValid(), return);
int currentRow = m_historyIndex.row();
const QAbstractItemModel *model = m_historyIndex.model();
if (currentRow == model->rowCount() - 1)
m_cachedScript = getCurrentScript();
while (currentRow) {
currentRow--;
if (model->hasIndex(currentRow, 0)) {
QModelIndex index = model->index(currentRow, 0);
if (ConsoleItem::InputType == (ConsoleItem::ItemType)model->data(
index, ConsoleItem::TypeRole).toInt()) {
m_historyIndex = index;
replaceCurrentScript(
model->data(index, ConsoleItem::ExpressionRole).toString());
break;
}
}
}
}
void QmlConsoleEdit::handleDownKey()
{
QTC_ASSERT(m_historyIndex.isValid(), return);
int currentRow = m_historyIndex.row();
const QAbstractItemModel *model = m_historyIndex.model();
while (currentRow < model->rowCount() - 1) {
currentRow++;
if (model->hasIndex(currentRow, 0)) {
QModelIndex index = model->index(currentRow, 0);
if (ConsoleItem::InputType == (ConsoleItem::ItemType)model->data(
index, ConsoleItem::TypeRole).toInt()) {
m_historyIndex = index;
if (currentRow == model->rowCount() - 1) {
replaceCurrentScript(m_cachedScript);
} else {
replaceCurrentScript(
model->data(index, ConsoleItem::ExpressionRole).toString());
}
break;
}
}
}
}
QString QmlConsoleEdit::getCurrentScript() const
{
QTextCursor cursor = textCursor();
cursor.setPosition(0);
cursor.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
return cursor.selectedText();
}
void QmlConsoleEdit::replaceCurrentScript(const QString &script)
{
QTextCursor cursor = textCursor();
cursor.setPosition(0);
cursor.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
cursor.removeSelectedText();
cursor.insertText(script);
setTextCursor(cursor);
}
} // Internal
} // QmlJSTools

View File

@@ -1,72 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** 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 The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** 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 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef QMLCONSOLEEDIT_H
#define QMLCONSOLEEDIT_H
#include "qmljsinterpreter.h"
#include <QTextEdit>
#include <QModelIndex>
namespace QmlJSTools {
namespace Internal {
class QmlConsoleEdit : public QTextEdit
{
Q_OBJECT
public:
QmlConsoleEdit(const QModelIndex &index, QWidget *parent);
QString getCurrentScript() const;
protected:
void keyPressEvent(QKeyEvent *e);
void focusOutEvent(QFocusEvent *e);
signals:
void editingFinished();
protected:
void handleUpKey();
void handleDownKey();
void replaceCurrentScript(const QString &script);
private:
QModelIndex m_historyIndex;
QString m_cachedScript;
QmlJSInterpreter m_interpreter;
};
} // QmlJSTools
} // Internal
#endif // QMLCONSOLEEDIT_H

View File

@@ -1,392 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** 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 The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** 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 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "qmlconsoleitemdelegate.h"
#include "qmlconsoleedit.h"
#include <coreplugin/coreconstants.h>
#include <coreplugin/coreicons.h>
#include <QPainter>
#include <QTreeView>
#include <QScrollBar>
#include <QTextLayout>
#include <QUrl>
const char CONSOLE_LOG_BACKGROUND_COLOR[] = "#E8EEF2";
const char CONSOLE_WARNING_BACKGROUND_COLOR[] = "#F6F4EB";
const char CONSOLE_ERROR_BACKGROUND_COLOR[] = "#F6EBE7";
const char CONSOLE_EDITOR_BACKGROUND_COLOR[] = "#F7F7F7";
const char CONSOLE_LOG_BACKGROUND_SELECTED_COLOR[] = "#CDDEEA";
const char CONSOLE_WARNING_BACKGROUND_SELECTED_COLOR[] = "#F3EED1";
const char CONSOLE_ERROR_BACKGROUND_SELECTED_COLOR[] = "#F5D4CB";
const char CONSOLE_EDITOR_BACKGROUND_SELECTED_COLOR[] = "#DEDEDE";
const char CONSOLE_LOG_TEXT_COLOR[] = "#333333";
const char CONSOLE_WARNING_TEXT_COLOR[] = "#666666";
const char CONSOLE_ERROR_TEXT_COLOR[] = "#1D5B93";
const char CONSOLE_EDITOR_TEXT_COLOR[] = "#000000";
const char CONSOLE_BORDER_COLOR[] = "#C9C9C9";
const int ELLIPSIS_GRADIENT_WIDTH = 16;
using namespace QmlJS;
namespace QmlJSTools {
namespace Internal {
///////////////////////////////////////////////////////////////////////
//
// QmlConsoleItemDelegate
//
///////////////////////////////////////////////////////////////////////
QmlConsoleItemDelegate::QmlConsoleItemDelegate(QObject *parent) :
QStyledItemDelegate(parent),
m_logIcon(Core::Icons::INFO.icon()),
m_warningIcon(Core::Icons::WARNING.icon()),
m_errorIcon(Core::Icons::ERROR.icon()),
m_expandIcon(QLatin1String(":/qmljstools/images/expand.png")),
m_collapseIcon(QLatin1String(":/qmljstools/images/collapse.png")),
m_prompt(QLatin1String(":/qmljstools/images/prompt.png")),
m_cachedHeight(0)
{
}
void QmlConsoleItemDelegate::emitSizeHintChanged(const QModelIndex &index)
{
emit sizeHintChanged(index);
}
QColor QmlConsoleItemDelegate::drawBackground(QPainter *painter, const QRect &rect,
const QModelIndex &index,
bool selected) const
{
painter->save();
ConsoleItem::ItemType itemType = (ConsoleItem::ItemType)index.data(
ConsoleItem::TypeRole).toInt();
QColor backgroundColor;
switch (itemType) {
case ConsoleItem::DebugType:
backgroundColor = selected ? QColor(CONSOLE_LOG_BACKGROUND_SELECTED_COLOR) :
QColor(CONSOLE_LOG_BACKGROUND_COLOR);
break;
case ConsoleItem::WarningType:
backgroundColor = selected ? QColor(CONSOLE_WARNING_BACKGROUND_SELECTED_COLOR) :
QColor(CONSOLE_WARNING_BACKGROUND_COLOR);
break;
case ConsoleItem::ErrorType:
backgroundColor = selected ? QColor(CONSOLE_ERROR_BACKGROUND_SELECTED_COLOR) :
QColor(CONSOLE_ERROR_BACKGROUND_COLOR);
break;
case ConsoleItem::InputType:
default:
backgroundColor = selected ? QColor(CONSOLE_EDITOR_BACKGROUND_SELECTED_COLOR) :
QColor(CONSOLE_EDITOR_BACKGROUND_COLOR);
break;
}
if (!(index.flags() & Qt::ItemIsEditable))
painter->setBrush(backgroundColor);
painter->setPen(Qt::NoPen);
painter->drawRect(rect);
// Separator lines
painter->setPen(QColor(CONSOLE_BORDER_COLOR));
if (!(index.flags() & Qt::ItemIsEditable))
painter->drawLine(0, rect.bottom(), rect.right(),
rect.bottom());
painter->restore();
return backgroundColor;
}
void QmlConsoleItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
QStyleOptionViewItemV4 opt = option;
initStyleOption(&opt, index);
painter->save();
// Set Colors
QColor textColor;
QIcon taskIcon;
ConsoleItem::ItemType type = (ConsoleItem::ItemType)index.data(
ConsoleItem::TypeRole).toInt();
switch (type) {
case ConsoleItem::DebugType:
textColor = QColor(CONSOLE_LOG_TEXT_COLOR);
taskIcon = m_logIcon;
break;
case ConsoleItem::WarningType:
textColor = QColor(CONSOLE_WARNING_TEXT_COLOR);
taskIcon = m_warningIcon;
break;
case ConsoleItem::ErrorType:
textColor = QColor(CONSOLE_ERROR_TEXT_COLOR);
taskIcon = m_errorIcon;
break;
case ConsoleItem::InputType:
textColor = QColor(CONSOLE_EDITOR_TEXT_COLOR);
taskIcon = m_prompt;
break;
default:
textColor = QColor(CONSOLE_EDITOR_TEXT_COLOR);
break;
}
// Paint background
QColor backgroundColor = drawBackground(painter, opt.rect, index,
bool(opt.state & QStyle::State_Selected));
// Calculate positions
const QTreeView *view = qobject_cast<const QTreeView *>(opt.widget);
int level = 0;
QModelIndex idx(index);
while (idx.parent() != QModelIndex()) {
idx = idx.parent();
level++;
}
int width = view->width() - level * view->indentation() - view->verticalScrollBar()->width();
bool showTypeIcon = index.parent() == QModelIndex();
bool showExpandableIcon = type == ConsoleItem::DefaultType;
QRect rect(opt.rect.x(), opt.rect.top(), width, opt.rect.height());
ConsoleItemPositions positions(rect, opt.font, showTypeIcon, showExpandableIcon);
// Paint TaskIconArea:
if (showTypeIcon)
painter->drawPixmap(positions.adjustedLeft(), positions.adjustedTop(),
taskIcon.pixmap(positions.typeIconWidth(),
positions.typeIconHeight()));
// Set Text Color
painter->setPen(textColor);
// Paint TextArea:
// Layout the description
QString str = index.data(Qt::DisplayRole).toString();
bool showFileLineInfo = true;
// show complete text if selected
if (view->selectionModel()->currentIndex() == index) {
QTextLayout tl(str, opt.font);
layoutText(tl, positions.textAreaWidth(), &showFileLineInfo);
tl.draw(painter, QPoint(positions.textAreaLeft(), positions.adjustedTop()));
} else {
QFontMetrics fm(opt.font);
painter->drawText(positions.textArea(), fm.elidedText(str, Qt::ElideRight,
positions.textAreaWidth()));
}
// skip if area is editable
if (showExpandableIcon) {
// Paint ExpandableIconArea:
QIcon expandCollapseIcon;
if (index.model()->rowCount(index) || index.model()->canFetchMore(index)) {
if (view->isExpanded(index))
expandCollapseIcon = m_collapseIcon;
else
expandCollapseIcon = m_expandIcon;
}
painter->drawPixmap(positions.expandCollapseIconLeft(), positions.adjustedTop(),
expandCollapseIcon.pixmap(positions.expandCollapseIconWidth(),
positions.expandCollapseIconHeight()));
}
if (showFileLineInfo) {
// Check for file info
QString file = index.data(ConsoleItem::FileRole).toString();
const QUrl fileUrl = QUrl(file);
if (fileUrl.isLocalFile())
file = fileUrl.toLocalFile();
if (!file.isEmpty()) {
QFontMetrics fm(option.font);
// Paint FileArea
const int pos = file.lastIndexOf(QLatin1Char('/'));
if (pos != -1)
file = file.mid(pos +1);
const int realFileWidth = fm.width(file);
painter->setClipRect(positions.fileArea());
painter->drawText(positions.fileAreaLeft(), positions.adjustedTop() + fm.ascent(),
file);
if (realFileWidth > positions.fileAreaWidth()) {
// draw a gradient to mask the text
int gradientStart = positions.fileAreaLeft() - 1;
QLinearGradient lg(gradientStart + ELLIPSIS_GRADIENT_WIDTH, 0, gradientStart, 0);
lg.setColorAt(0, Qt::transparent);
lg.setColorAt(1, backgroundColor);
painter->fillRect(gradientStart, positions.adjustedTop(),
ELLIPSIS_GRADIENT_WIDTH, positions.lineHeight(), lg);
}
// Paint LineArea
QString lineText = index.data(ConsoleItem::LineRole).toString();
painter->setClipRect(positions.lineArea());
const int realLineWidth = fm.width(lineText);
painter->drawText(positions.lineAreaRight() - realLineWidth,
positions.adjustedTop() + fm.ascent(), lineText);
}
}
painter->setClipRect(opt.rect);
painter->restore();
}
QSize QmlConsoleItemDelegate::sizeHint(const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
QStyleOptionViewItemV4 opt = option;
initStyleOption(&opt, index);
const QTreeView *view = qobject_cast<const QTreeView *>(opt.widget);
int level = 0;
QModelIndex idx(index);
while (idx.parent() != QModelIndex()) {
idx = idx.parent();
level++;
}
int width = view->width() - level * view->indentation() - view->verticalScrollBar()->width();
const bool selected = (view->selectionModel()->currentIndex() == index);
if (!selected && option.font == m_cachedFont && m_cachedHeight > 0)
return QSize(width, m_cachedHeight);
ConsoleItem::ItemType type = (ConsoleItem::ItemType)index.data(
ConsoleItem::TypeRole).toInt();
bool showTypeIcon = index.parent() == QModelIndex();
bool showExpandableIcon = type == ConsoleItem::DefaultType;
QRect rect(level * view->indentation(), 0, width, 0);
ConsoleItemPositions positions(rect, opt.font, showTypeIcon, showExpandableIcon);
QFontMetrics fm(option.font);
qreal height = fm.height();
if (selected) {
QString str = index.data(Qt::DisplayRole).toString();
QTextLayout tl(str, option.font);
height = layoutText(tl, positions.textAreaWidth());
}
height += 2 * ConsoleItemPositions::ITEM_PADDING;
if (height < positions.minimumHeight())
height = positions.minimumHeight();
if (!selected) {
m_cachedHeight = height;
m_cachedFont = option.font;
}
return QSize(width, height);
}
QWidget *QmlConsoleItemDelegate::createEditor(QWidget *parent,
const QStyleOptionViewItem &/*option*/,
const QModelIndex &index) const
{
QmlConsoleEdit *editor = new QmlConsoleEdit(index, parent);
// Fiddle the prompt into the margin so that we don't have to put it into the text.
// Apparently you can have both background-image and background-color, which conveniently
// prevents the painted text from shining through.
editor->setStyleSheet(QLatin1String("QTextEdit {"
"margin-left: 24px;"
"margin-top: 4px;"
"background-color: white;"
"background-image: url(:/qmljstools/images/prompt.png);"
"background-position: baseline left;"
"background-origin: margin;"
"background-repeat: none;"
"}"));
connect(editor, &QmlConsoleEdit::editingFinished,
this, &QmlConsoleItemDelegate::commitAndCloseEditor);
return editor;
}
void QmlConsoleItemDelegate::setEditorData(QWidget *editor,
const QModelIndex &index) const
{
QmlConsoleEdit *edtr = qobject_cast<QmlConsoleEdit *>(editor);
edtr->insertPlainText(index.data(ConsoleItem::ExpressionRole).toString());
}
void QmlConsoleItemDelegate::setModelData(QWidget *editor,
QAbstractItemModel *model,
const QModelIndex &index) const
{
QmlConsoleEdit *edtr = qobject_cast<QmlConsoleEdit *>(editor);
model->setData(index, edtr->getCurrentScript(), ConsoleItem::ExpressionRole);
model->setData(index, ConsoleItem::InputType, ConsoleItem::TypeRole);
}
void QmlConsoleItemDelegate::updateEditorGeometry(QWidget *editor,
const QStyleOptionViewItem &option,
const QModelIndex &/*index*/) const
{
QStyleOptionViewItemV4 opt = option;
editor->setGeometry(QRect(opt.rect.x(), opt.rect.top(), opt.rect.width(), opt.rect.bottom()));
}
void QmlConsoleItemDelegate::currentChanged(const QModelIndex &current,
const QModelIndex &previous)
{
emit sizeHintChanged(current);
emit sizeHintChanged(previous);
}
void QmlConsoleItemDelegate::commitAndCloseEditor()
{
QmlConsoleEdit *editor = qobject_cast<QmlConsoleEdit *>(sender());
emit commitData(editor);
emit closeEditor(editor);
}
qreal QmlConsoleItemDelegate::layoutText(QTextLayout &tl, int width,
bool *showFileLineInfo) const
{
qreal height = 0;
tl.beginLayout();
while (true) {
QTextLine line = tl.createLine();
if (!line.isValid())
break;
line.setLeadingIncluded(true);
line.setLineWidth(width);
if (width < line.naturalTextWidth() && showFileLineInfo)
*showFileLineInfo = false;
line.setPosition(QPoint(0, height));
height += line.height();
}
tl.endLayout();
return height;
}
} // Internal
} // QmlJSTools

View File

@@ -1,183 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** 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 The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** 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 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef QMLCONSOLEITEMDELEGATE_H
#define QMLCONSOLEITEMDELEGATE_H
#include "qmlconsoleitemmodel.h"
#include "qmlconsolemodel.h"
#include <QStyledItemDelegate>
QT_FORWARD_DECLARE_CLASS(QTextLayout)
namespace QmlJSTools {
namespace Internal {
class QmlConsoleItemDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
QmlConsoleItemDelegate(QObject *parent);
void emitSizeHintChanged(const QModelIndex &index);
QColor drawBackground(QPainter *painter, const QRect &rect, const QModelIndex &index,
bool selected) const;
public slots:
void currentChanged(const QModelIndex &current, const QModelIndex &previous);
protected:
void paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const;
QSize sizeHint(const QStyleOptionViewItem &option,
const QModelIndex &index) const;
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
const QModelIndex &index) const;
void setEditorData(QWidget *editor, const QModelIndex &index) const;
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
const QModelIndex &index) const;
private slots:
void commitAndCloseEditor();
private:
qreal layoutText(QTextLayout &tl, int width, bool *success = 0) const;
private:
const QIcon m_logIcon;
const QIcon m_warningIcon;
const QIcon m_errorIcon;
const QIcon m_expandIcon;
const QIcon m_collapseIcon;
const QIcon m_prompt;
mutable int m_cachedHeight;
mutable QFont m_cachedFont;
};
/*
+----------------------------------------------------------------------------+
| TYPEICONAREA EXPANDABLEICONAREA TEXTAREA FILEAREA LINEAREA |
+----------------------------------------------------------------------------+
*/
/*
+----------------------------------------------------------------------------+
| PROMPTAREA EDITABLEAREA |
+----------------------------------------------------------------------------+
*/
class ConsoleItemPositions
{
public:
ConsoleItemPositions(const QRect &rect, const QFont &font, bool showTaskIconArea,
bool showExpandableIconArea)
: m_x(rect.x()),
m_width(rect.width()),
m_top(rect.top()),
m_bottom(rect.bottom()),
m_maxFileLength(0),
m_maxLineLength(0),
m_showTaskIconArea(showTaskIconArea),
m_showExpandableIconArea(showExpandableIconArea)
{
m_fontHeight = QFontMetrics(font).height();
QmlConsoleItemModel *model = QmlConsoleModel::qmlConsoleItemModel();
m_maxFileLength = model->sizeOfFile(font);
m_maxLineLength = model->sizeOfLineNumber(font);
}
int adjustedTop() const { return m_top + ITEM_PADDING; }
int adjustedLeft() const { return m_x + ITEM_PADDING; }
int adjustedRight() const { return m_width - ITEM_PADDING; }
int adjustedBottom() const { return m_bottom; }
int lineHeight() const { return m_fontHeight + 1; }
int minimumHeight() const { return typeIconHeight() + 2 * ITEM_PADDING; }
// PROMPTAREA is same as TYPEICONAREA
int typeIconLeft() const { return adjustedLeft(); }
int typeIconWidth() const { return TASK_ICON_SIZE; }
int typeIconHeight() const { return TASK_ICON_SIZE; }
int typeIconRight() const { return m_showTaskIconArea ? typeIconLeft() + typeIconWidth()
: adjustedLeft(); }
QRect typeIcon() const { return QRect(typeIconLeft(), adjustedTop(), typeIconWidth(),
typeIconHeight()); }
int expandCollapseIconLeft() const { return typeIconRight() + ITEM_SPACING; }
int expandCollapseIconWidth() const { return TASK_ICON_SIZE; }
int expandCollapseIconHeight() const { return TASK_ICON_SIZE; }
int expandCollapseIconRight() const { return m_showExpandableIconArea ?
expandCollapseIconLeft() + expandCollapseIconWidth() : typeIconRight(); }
QRect expandCollapseIcon() const { return QRect(expandCollapseIconLeft(), adjustedTop(),
expandCollapseIconWidth(),
expandCollapseIconHeight()); }
int textAreaLeft() const { return expandCollapseIconRight() + ITEM_SPACING; }
int textAreaWidth() const { return textAreaRight() - textAreaLeft(); }
int textAreaRight() const { return fileAreaLeft() - ITEM_SPACING; }
QRect textArea() const { return QRect(textAreaLeft(), adjustedTop(), textAreaWidth(),
lineHeight()); }
int fileAreaLeft() const { return fileAreaRight() - fileAreaWidth(); }
int fileAreaWidth() const { return m_maxFileLength; }
int fileAreaRight() const { return lineAreaLeft() - ITEM_SPACING; }
QRect fileArea() const { return QRect(fileAreaLeft(), adjustedTop(), fileAreaWidth(),
lineHeight()); }
int lineAreaLeft() const { return lineAreaRight() - lineAreaWidth(); }
int lineAreaWidth() const { return m_maxLineLength; }
int lineAreaRight() const { return adjustedRight() - ITEM_SPACING; }
QRect lineArea() const { return QRect(lineAreaLeft(), adjustedTop(), lineAreaWidth(),
lineHeight()); }
private:
int m_x;
int m_width;
int m_top;
int m_bottom;
int m_fontHeight;
int m_maxFileLength;
int m_maxLineLength;
bool m_showTaskIconArea;
bool m_showExpandableIconArea;
public:
static const int TASK_ICON_SIZE = 16;
static const int ITEM_PADDING = 8;
static const int ITEM_SPACING = 4;
};
} // namespace Internal
} // namespace QmlJSTools
#endif // QMLCONSOLEITEMDELEGATE_H

View File

@@ -1,114 +0,0 @@
/**************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** 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 The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** 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 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "qmlconsoleitemmodel.h"
#include <QFontMetrics>
#include <QFont>
using namespace QmlJS;
namespace QmlJSTools {
namespace Internal {
///////////////////////////////////////////////////////////////////////
//
// QmlConsoleItemModel
//
///////////////////////////////////////////////////////////////////////
QmlConsoleItemModel::QmlConsoleItemModel(QObject *parent) :
Utils::TreeModel(new ConsoleItem, parent),
m_maxSizeOfFileName(0)
{
clear();
}
void QmlConsoleItemModel::clear()
{
Utils::TreeModel::clear();
appendItem(new ConsoleItem(ConsoleItem::InputType));
emit selectEditableRow(index(0, 0, QModelIndex()), QItemSelectionModel::ClearAndSelect);
}
void QmlConsoleItemModel::appendItem(ConsoleItem *item, int position)
{
if (position < 0)
position = rootItem()->childCount() - 1; // append before editable row
if (position < 0)
position = 0;
rootItem()->insertChild(position, item);
}
void QmlConsoleItemModel::appendMessage(ConsoleItem::ItemType itemType,
const QString &message, int position)
{
appendItem(new ConsoleItem(itemType, message), position);
}
void QmlConsoleItemModel::shiftEditableRow()
{
int position = rootItem()->childCount();
Q_ASSERT(position > 0);
// Disable editing for old editable row
rootItem()->lastChild()->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
appendItem(new ConsoleItem(ConsoleItem::InputType), position);
emit selectEditableRow(index(position, 0, QModelIndex()), QItemSelectionModel::ClearAndSelect);
}
int QmlConsoleItemModel::sizeOfFile(const QFont &font)
{
int lastReadOnlyRow = rootItem()->childCount();
lastReadOnlyRow -= 2; // skip editable row
if (lastReadOnlyRow < 0)
return 0;
QString filename = static_cast<ConsoleItem *>(rootItem()->child(lastReadOnlyRow))->file();
const int pos = filename.lastIndexOf(QLatin1Char('/'));
if (pos != -1)
filename = filename.mid(pos + 1);
QFontMetrics fm(font);
m_maxSizeOfFileName = qMax(m_maxSizeOfFileName, fm.width(filename));
return m_maxSizeOfFileName;
}
int QmlConsoleItemModel::sizeOfLineNumber(const QFont &font)
{
QFontMetrics fm(font);
return fm.width(QLatin1String("88888"));
}
} // Internal
} // QmlJSTools

View File

@@ -1,73 +0,0 @@
/**************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** 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 The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** 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 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef QMLCONSOLEITEMMODEL_H
#define QMLCONSOLEITEMMODEL_H
#include <qmljs/consoleitem.h>
#include <utils/treemodel.h>
#include <QItemSelectionModel>
QT_FORWARD_DECLARE_CLASS(QFont)
namespace QmlJSTools {
namespace Internal {
class QmlConsoleItemModel : public Utils::TreeModel
{
Q_OBJECT
public:
explicit QmlConsoleItemModel(QObject *parent = 0);
void shiftEditableRow();
void appendItem(QmlJS::ConsoleItem *item, int position = -1);
void appendMessage(QmlJS::ConsoleItem::ItemType itemType, const QString &message,
int position = -1);
int sizeOfFile(const QFont &font);
int sizeOfLineNumber(const QFont &font);
public slots:
void clear();
signals:
void selectEditableRow(const QModelIndex &index, QItemSelectionModel::SelectionFlags flags);
private:
int m_maxSizeOfFileName;
};
} // Internal
} // QmlJSTools
#endif // QMLCONSOLEITEMMODEL_H

View File

@@ -1,146 +0,0 @@
/**************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** 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 The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** 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 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "qmlconsolemanager.h"
#include "qmlconsolepane.h"
#include "qmlconsoleitemmodel.h"
#include "qmlconsolemodel.h"
#include <extensionsystem/pluginmanager.h>
#include <qmljs/iscriptevaluator.h>
#include <QVariant>
#include <QCoreApplication>
using namespace QmlJS;
namespace QmlJSTools {
class QmlConsoleManagerPrivate
{
public:
Internal::QmlConsoleItemModel *qmlConsoleItemModel;
Internal::QmlConsolePane *qmlConsolePane;
IScriptEvaluator *scriptEvaluator;
};
QmlConsoleManager::QmlConsoleManager(QObject *parent)
: ConsoleManagerInterface(parent),
d(new QmlConsoleManagerPrivate)
{
d->qmlConsoleItemModel = new Internal::QmlConsoleItemModel(this);
d->qmlConsolePane = new Internal::QmlConsolePane(this);
d->scriptEvaluator = 0;
ExtensionSystem::PluginManager::addObject(d->qmlConsolePane);
}
QmlConsoleManager::~QmlConsoleManager()
{
if (d->qmlConsolePane)
ExtensionSystem::PluginManager::removeObject(d->qmlConsolePane);
delete d;
}
void QmlConsoleManager::showConsolePane()
{
if (d->qmlConsolePane)
d->qmlConsolePane->popup(Core::IOutputPane::ModeSwitch);
}
void QmlConsoleManager::setScriptEvaluator(IScriptEvaluator *scriptEvaluator)
{
d->scriptEvaluator = scriptEvaluator;
if (!scriptEvaluator)
setContext(QString());
}
void QmlConsoleManager::setContext(const QString &context)
{
d->qmlConsolePane->setContext(context);
}
void QmlConsoleManager::printToConsolePane(ConsoleItem::ItemType itemType,
const QString &text, bool bringToForeground)
{
if (!d->qmlConsolePane)
return;
if (itemType == ConsoleItem::ErrorType)
bringToForeground = true;
if (bringToForeground)
d->qmlConsolePane->popup(Core::IOutputPane::ModeSwitch);
d->qmlConsoleItemModel->appendMessage(itemType, text);
if (itemType == ConsoleItem::WarningType)
d->qmlConsolePane->flash();
}
void QmlConsoleManager::printToConsolePane(ConsoleItem *item, bool bringToForeground)
{
if (!d->qmlConsolePane)
return;
if (item->itemType() == ConsoleItem::ErrorType)
bringToForeground = true;
if (bringToForeground)
d->qmlConsolePane->popup(Core::IOutputPane::ModeSwitch);
d->qmlConsoleItemModel->appendItem(item);
}
namespace Internal {
QmlConsoleItemModel *QmlConsoleModel::qmlConsoleItemModel()
{
QmlConsoleManager *manager = qobject_cast<QmlConsoleManager *>(QmlConsoleManager::instance());
if (manager)
return manager->d->qmlConsoleItemModel;
return 0;
}
void QmlConsoleModel::evaluate(const QString &expression)
{
QmlConsoleManager *manager = qobject_cast<QmlConsoleManager *>(QmlConsoleManager::instance());
if (manager) {
if (manager->d->scriptEvaluator) {
QmlConsoleModel::qmlConsoleItemModel()->shiftEditableRow();
manager->d->scriptEvaluator->evaluateScript(expression);
} else {
ConsoleItem *item = new ConsoleItem(
ConsoleItem::ErrorType, QCoreApplication::translate(
"QmlJSTools::Internal::QmlConsoleModel",
"Can only evaluate during a QML debug session."));
if (item) {
QmlConsoleModel::qmlConsoleItemModel()->shiftEditableRow();
manager->printToConsolePane(item);
}
}
}
}
} // Internal
} // QmlJSTools

View File

@@ -1,69 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** 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 The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** 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 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef QMLCONSOLEMANAGER_H
#define QMLCONSOLEMANAGER_H
#include "qmljstools_global.h"
#include <qmljs/consolemanagerinterface.h>
#include <QObject>
namespace QmlJS { class IScriptEvaluator; }
namespace QmlJSTools {
namespace Internal { class QmlConsoleModel; }
class QmlConsoleManagerPrivate;
class QMLJSTOOLS_EXPORT QmlConsoleManager : public QmlJS::ConsoleManagerInterface
{
Q_OBJECT
public:
QmlConsoleManager(QObject *parent);
~QmlConsoleManager();
void showConsolePane();
void setScriptEvaluator(QmlJS::IScriptEvaluator *scriptEvaluator);
void setContext(const QString &context);
void printToConsolePane(QmlJS::ConsoleItem::ItemType itemType, const QString &text,
bool bringToForeground = false);
void printToConsolePane(QmlJS::ConsoleItem *item, bool bringToForeground = false);
private:
QmlConsoleManagerPrivate *d;
friend class Internal::QmlConsoleModel;
};
} // namespace QmlJSTools
#endif // QMLCONSOLEMANAGER_H

View File

@@ -1,51 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** 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 The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** 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 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef QMLCONSOLEMODEL_H
#define QMLCONSOLEMODEL_H
#include <QString>
namespace QmlJSTools {
namespace Internal {
class QmlConsoleItemModel;
class QmlConsoleModel
{
public:
static QmlConsoleItemModel *qmlConsoleItemModel();
static void evaluate(const QString &expression);
};
} // namespace Internal
} // namespace QmlJSTools
#endif // QMLCONSOLEMODEL_H

View File

@@ -1,253 +0,0 @@
/**************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** 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 The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** 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 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "qmlconsolepane.h"
#include "qmlconsoleview.h"
#include "qmlconsoleproxymodel.h"
#include "qmlconsoleitemdelegate.h"
#include <coreplugin/coreconstants.h>
#include <coreplugin/coreicons.h>
#include <coreplugin/icore.h>
#include <coreplugin/findplaceholder.h>
#include <utils/savedaction.h>
#include <aggregation/aggregate.h>
#include <coreplugin/find/itemviewfind.h>
#include <QToolButton>
#include <QLabel>
#include <QVBoxLayout>
static const char CONSOLE[] = "Console";
static const char SHOW_LOG[] = "showLog";
static const char SHOW_WARNING[] = "showWarning";
static const char SHOW_ERROR[] = "showError";
namespace QmlJSTools {
namespace Internal {
/////////////////////////////////////////////////////////////////////
//
// QmlConsolePane
//
/////////////////////////////////////////////////////////////////////
QmlConsolePane::QmlConsolePane(QObject *parent)
: Core::IOutputPane(parent)
{
m_consoleWidget = new QWidget;
m_consoleWidget->setWindowTitle(displayName());
m_consoleWidget->setEnabled(true);
QVBoxLayout *vbox = new QVBoxLayout(m_consoleWidget);
vbox->setMargin(0);
vbox->setSpacing(0);
m_consoleView = new QmlConsoleView(m_consoleWidget);
m_proxyModel = new QmlConsoleProxyModel(this);
m_proxyModel->setSourceModel(QmlConsoleModel::qmlConsoleItemModel());
connect(QmlConsoleModel::qmlConsoleItemModel(),
&QmlConsoleItemModel::selectEditableRow,
m_proxyModel,
&QmlConsoleProxyModel::selectEditableRow);
//Scroll to bottom when rows matching current filter settings are inserted
//Not connecting rowsRemoved as the only way to remove rows is to clear the
//model which will automatically reset the view.
connect(QmlConsoleModel::qmlConsoleItemModel(), &QAbstractItemModel::rowsInserted,
m_proxyModel, &QmlConsoleProxyModel::onRowsInserted);
m_consoleView->setModel(m_proxyModel);
connect(m_proxyModel,
SIGNAL(setCurrentIndex(QModelIndex,QItemSelectionModel::SelectionFlags)),
m_consoleView->selectionModel(),
SLOT(setCurrentIndex(QModelIndex,QItemSelectionModel::SelectionFlags)));
connect(m_proxyModel, &QmlConsoleProxyModel::scrollToBottom,
m_consoleView, &QmlConsoleView::onScrollToBottom);
m_itemDelegate = new QmlConsoleItemDelegate(this);
connect(m_consoleView->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
m_itemDelegate, SLOT(currentChanged(QModelIndex,QModelIndex)));
m_consoleView->setItemDelegate(m_itemDelegate);
Aggregation::Aggregate *aggregate = new Aggregation::Aggregate();
aggregate->add(m_consoleView);
aggregate->add(new Core::ItemViewFind(m_consoleView));
vbox->addWidget(m_consoleView);
vbox->addWidget(new Core::FindToolBarPlaceHolder(m_consoleWidget));
m_showDebugButton = new QToolButton(m_consoleWidget);
m_showDebugButton->setAutoRaise(true);
m_showDebugButtonAction = new Utils::SavedAction(this);
m_showDebugButtonAction->setDefaultValue(true);
m_showDebugButtonAction->setSettingsKey(QLatin1String(CONSOLE), QLatin1String(SHOW_LOG));
m_showDebugButtonAction->setToolTip(tr("Show debug, log, and info messages."));
m_showDebugButtonAction->setCheckable(true);
m_showDebugButtonAction->setChecked(true);
m_showDebugButtonAction->setIcon(Core::Icons::INFO_TOOLBAR.icon());
connect(m_showDebugButtonAction, &Utils::SavedAction::toggled,
m_proxyModel, &QmlConsoleProxyModel::setShowLogs);
m_showDebugButton->setDefaultAction(m_showDebugButtonAction);
m_showWarningButton = new QToolButton(m_consoleWidget);
m_showWarningButton->setAutoRaise(true);
m_showWarningButtonAction = new Utils::SavedAction(this);
m_showWarningButtonAction->setDefaultValue(true);
m_showWarningButtonAction->setSettingsKey(QLatin1String(CONSOLE), QLatin1String(SHOW_WARNING));
m_showWarningButtonAction->setToolTip(tr("Show warning messages."));
m_showWarningButtonAction->setCheckable(true);
m_showWarningButtonAction->setChecked(true);
m_showWarningButtonAction->setIcon(Core::Icons::WARNING_TOOLBAR.icon());
connect(m_showWarningButtonAction, &Utils::SavedAction::toggled,
m_proxyModel, &QmlConsoleProxyModel::setShowWarnings);
m_showWarningButton->setDefaultAction(m_showWarningButtonAction);
m_showErrorButton = new QToolButton(m_consoleWidget);
m_showErrorButton->setAutoRaise(true);
m_showErrorButtonAction = new Utils::SavedAction(this);
m_showErrorButtonAction->setDefaultValue(true);
m_showErrorButtonAction->setSettingsKey(QLatin1String(CONSOLE), QLatin1String(SHOW_ERROR));
m_showErrorButtonAction->setToolTip(tr("Show error messages."));
m_showErrorButtonAction->setCheckable(true);
m_showErrorButtonAction->setChecked(true);
m_showErrorButtonAction->setIcon(Core::Icons::ERROR_TOOLBAR.icon());
connect(m_showErrorButtonAction, &Utils::SavedAction::toggled, m_proxyModel, &QmlConsoleProxyModel::setShowErrors);
m_showErrorButton->setDefaultAction(m_showErrorButtonAction);
m_spacer = new QWidget(m_consoleWidget);
m_spacer->setMinimumWidth(30);
m_statusLabel = new QLabel(m_consoleWidget);
readSettings();
connect(Core::ICore::instance(), SIGNAL(saveSettingsRequested()), SLOT(writeSettings()));
}
QmlConsolePane::~QmlConsolePane()
{
writeSettings();
delete m_consoleWidget;
}
QWidget *QmlConsolePane::outputWidget(QWidget *)
{
return m_consoleWidget;
}
QList<QWidget *> QmlConsolePane::toolBarWidgets() const
{
return QList<QWidget *>() << m_showDebugButton << m_showWarningButton << m_showErrorButton
<< m_spacer << m_statusLabel;
}
int QmlConsolePane::priorityInStatusBar() const
{
return 20;
}
void QmlConsolePane::clearContents()
{
QmlConsoleModel::qmlConsoleItemModel()->clear();
}
void QmlConsolePane::visibilityChanged(bool /*visible*/)
{
}
bool QmlConsolePane::canFocus() const
{
return true;
}
bool QmlConsolePane::hasFocus() const
{
for (QWidget *widget = m_consoleWidget->window()->focusWidget(); widget != 0;
widget = widget->parentWidget()) {
if (widget == m_consoleWidget)
return true;
}
return false;
}
void QmlConsolePane::setFocus()
{
m_consoleView->setFocus();
}
bool QmlConsolePane::canNext() const
{
return false;
}
bool QmlConsolePane::canPrevious() const
{
return false;
}
void QmlConsolePane::goToNext()
{
}
void QmlConsolePane::goToPrev()
{
}
bool QmlConsolePane::canNavigate() const
{
return false;
}
void QmlConsolePane::readSettings()
{
QSettings *settings = Core::ICore::settings();
m_showDebugButtonAction->readSettings(settings);
m_showWarningButtonAction->readSettings(settings);
m_showErrorButtonAction->readSettings(settings);
}
void QmlConsolePane::setContext(const QString &context)
{
m_statusLabel->setText(context);
}
void QmlConsolePane::writeSettings() const
{
QSettings *settings = Core::ICore::settings();
m_showDebugButtonAction->writeSettings(settings);
m_showWarningButtonAction->writeSettings(settings);
m_showErrorButtonAction->writeSettings(settings);
}
} // Internal
} // QmlJSTools

View File

@@ -1,99 +0,0 @@
/**************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** 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 The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** 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 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef QMLCONSOLEPANE_H
#define QMLCONSOLEPANE_H
#include <coreplugin/ioutputpane.h>
QT_BEGIN_NAMESPACE
class QToolButton;
class QLabel;
QT_END_NAMESPACE
namespace Utils { class SavedAction; }
namespace QmlJSTools {
namespace Internal {
class QmlConsoleView;
class QmlConsoleItemDelegate;
class QmlConsoleProxyModel;
class QmlConsoleItemModel;
class QmlConsolePane : public Core::IOutputPane
{
Q_OBJECT
public:
QmlConsolePane(QObject *parent);
~QmlConsolePane();
QWidget *outputWidget(QWidget *);
QList<QWidget *> toolBarWidgets() const;
QString displayName() const { return tr("QML/JS Console"); }
int priorityInStatusBar() const;
void clearContents();
void visibilityChanged(bool visible);
bool canFocus() const;
bool hasFocus() const;
void setFocus();
bool canNext() const;
bool canPrevious() const;
void goToNext();
void goToPrev();
bool canNavigate() const;
void readSettings();
void setContext(const QString &context);
public slots:
void writeSettings() const;
private:
QToolButton *m_showDebugButton;
QToolButton *m_showWarningButton;
QToolButton *m_showErrorButton;
Utils::SavedAction *m_showDebugButtonAction;
Utils::SavedAction *m_showWarningButtonAction;
Utils::SavedAction *m_showErrorButtonAction;
QWidget *m_spacer;
QLabel *m_statusLabel;
QmlConsoleView *m_consoleView;
QmlConsoleItemDelegate *m_itemDelegate;
QmlConsoleProxyModel *m_proxyModel;
QWidget *m_consoleWidget;
};
} // namespace Internal
} // namespace QmlJSTools
#endif // QMLCONSOLEPANE_H

View File

@@ -1,92 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** 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 The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** 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 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "qmlconsoleproxymodel.h"
#include "qmlconsoleitemmodel.h"
using namespace QmlJS;
namespace QmlJSTools {
namespace Internal {
QmlConsoleProxyModel::QmlConsoleProxyModel(QObject *parent) :
QSortFilterProxyModel(parent),
m_filter(ConsoleItem::AllTypes)
{
}
void QmlConsoleProxyModel::setShowLogs(bool show)
{
m_filter = show ? (m_filter | ConsoleItem::DebugType)
: (m_filter & ~ConsoleItem::DebugType);
invalidateFilter();
}
void QmlConsoleProxyModel::setShowWarnings(bool show)
{
m_filter = show ? (m_filter | ConsoleItem::WarningType)
: (m_filter & ~ConsoleItem::WarningType);
invalidateFilter();
}
void QmlConsoleProxyModel::setShowErrors(bool show)
{
m_filter = show ? (m_filter | ConsoleItem::ErrorType)
: (m_filter & ~ConsoleItem::ErrorType);
invalidateFilter();
}
void QmlConsoleProxyModel::selectEditableRow(const QModelIndex &index,
QItemSelectionModel::SelectionFlags command)
{
emit setCurrentIndex(mapFromSource(index), command);
}
bool QmlConsoleProxyModel::filterAcceptsRow(int sourceRow,
const QModelIndex &sourceParent) const
{
QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
return m_filter.testFlag((ConsoleItem::ItemType)sourceModel()->data(
index, ConsoleItem::TypeRole).toInt());
}
void QmlConsoleProxyModel::onRowsInserted(const QModelIndex &index, int start, int end)
{
int rowIndex = end;
do {
if (filterAcceptsRow(rowIndex, index)) {
emit scrollToBottom();
break;
}
} while (--rowIndex >= start);
}
} // Internal
} // QmlJSTools

View File

@@ -1,71 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** 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 The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** 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 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef QMLCONSOLEPROXYMODEL_H
#define QMLCONSOLEPROXYMODEL_H
#include <qmljs/consoleitem.h>
#include <QSortFilterProxyModel>
#include <QItemSelectionModel>
namespace QmlJSTools {
namespace Internal {
class QmlConsoleProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
explicit QmlConsoleProxyModel(QObject *parent);
public slots:
void setShowLogs(bool show);
void setShowWarnings(bool show);
void setShowErrors(bool show);
void selectEditableRow(const QModelIndex &index,
QItemSelectionModel::SelectionFlags command);
void onRowsInserted(const QModelIndex &index, int start, int end);
signals:
void scrollToBottom();
void setCurrentIndex(const QModelIndex &index,
QItemSelectionModel::SelectionFlags command);
protected:
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
private:
QFlags<QmlJS::ConsoleItem::ItemType> m_filter;
};
} // Internal
} // QmlJSTools
#endif // QMLCONSOLEPROXYMODEL_H

View File

@@ -1,280 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** 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 The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** 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 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "qmlconsoleview.h"
#include "qmlconsoleitemdelegate.h"
#include "qmlconsoleitemmodel.h"
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/manhattanstyle.h>
#include <utils/hostosinfo.h>
#include <QAction>
#include <QMenu>
#include <QMouseEvent>
#include <QPainter>
#include <QApplication>
#include <QClipboard>
#include <QAbstractProxyModel>
#include <QFileInfo>
#include <QScrollBar>
#include <QStyleFactory>
#include <QString>
#include <QUrl>
using namespace QmlJS;
namespace QmlJSTools {
namespace Internal {
class QmlConsoleViewStyle : public ManhattanStyle
{
public:
QmlConsoleViewStyle(const QString &baseStyleName) : ManhattanStyle(baseStyleName) {}
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter,
const QWidget *widget = 0) const
{
if (element != QStyle::PE_PanelItemViewRow)
ManhattanStyle::drawPrimitive(element, option, painter, widget);
}
int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0,
QStyleHintReturn *returnData = 0) const {
if (hint == SH_ItemView_ShowDecorationSelected)
return 0;
else
return ManhattanStyle::styleHint(hint, option, widget, returnData);
}
};
///////////////////////////////////////////////////////////////////////
//
// QmlConsoleView
//
///////////////////////////////////////////////////////////////////////
QmlConsoleView::QmlConsoleView(QWidget *parent) :
Utils::TreeView(parent)
{
setFrameStyle(QFrame::NoFrame);
setHeaderHidden(true);
setRootIsDecorated(false);
setUniformRowHeights(true);
setEditTriggers(QAbstractItemView::AllEditTriggers);
setStyleSheet(QLatin1String("QTreeView::branch:has-siblings:!adjoins-item {"
"border-image: none;"
"image: none; }"
"QTreeView::branch:has-siblings:adjoins-item {"
"border-image: none;"
"image: none; }"
"QTreeView::branch:!has-children:!has-siblings:adjoins-item {"
"border-image: none;"
"image: none; }"
"QTreeView::branch:has-children:!has-siblings:closed,"
"QTreeView::branch:closed:has-children:has-siblings {"
"border-image: none;"
"image: none; }"
"QTreeView::branch:open:has-children:!has-siblings,"
"QTreeView::branch:open:has-children:has-siblings {"
"border-image: none;"
"image: none; }"));
QString baseName = QApplication::style()->objectName();
if (Utils::HostOsInfo::isAnyUnixHost() && !Utils::HostOsInfo::isMacHost()
&& baseName == QLatin1String("windows")) {
// Sometimes we get the standard windows 95 style as a fallback
if (QStyleFactory::keys().contains(QLatin1String("Fusion"))) {
baseName = QLatin1String("fusion"); // Qt5
} else { // Qt4
// e.g. if we are running on a KDE4 desktop
QByteArray desktopEnvironment = qgetenv("DESKTOP_SESSION");
if (desktopEnvironment == "kde")
baseName = QLatin1String("plastique");
else
baseName = QLatin1String("cleanlooks");
}
}
QmlConsoleViewStyle *style = new QmlConsoleViewStyle(baseName);
setStyle(style);
style->setParent(this);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
horizontalScrollBar()->setSingleStep(20);
verticalScrollBar()->setSingleStep(20);
connect(this, &QmlConsoleView::activated, this, &QmlConsoleView::onRowActivated);
}
void QmlConsoleView::onScrollToBottom()
{
// Keep scrolling to bottom if scroll bar is not at maximum()
if (verticalScrollBar()->value() != verticalScrollBar()->maximum())
scrollToBottom();
}
void QmlConsoleView::mousePressEvent(QMouseEvent *event)
{
QPoint pos = event->pos();
QModelIndex index = indexAt(pos);
if (index.isValid()) {
ConsoleItem::ItemType type = (ConsoleItem::ItemType)index.data(
ConsoleItem::TypeRole).toInt();
bool handled = false;
if (type == ConsoleItem::DefaultType) {
bool showTypeIcon = index.parent() == QModelIndex();
ConsoleItemPositions positions(visualRect(index), viewOptions().font, showTypeIcon,
true);
if (positions.expandCollapseIcon().contains(pos)) {
if (isExpanded(index))
setExpanded(index, false);
else
setExpanded(index, true);
handled = true;
}
}
if (!handled)
Utils::TreeView::mousePressEvent(event);
}
}
void QmlConsoleView::resizeEvent(QResizeEvent *e)
{
static_cast<QmlConsoleItemDelegate *>(itemDelegate())->emitSizeHintChanged(
selectionModel()->currentIndex());
Utils::TreeView::resizeEvent(e);
}
void QmlConsoleView::drawBranches(QPainter *painter, const QRect &rect,
const QModelIndex &index) const
{
static_cast<QmlConsoleItemDelegate *>(itemDelegate())->drawBackground(painter, rect, index,
false);
Utils::TreeView::drawBranches(painter, rect, index);
}
void QmlConsoleView::contextMenuEvent(QContextMenuEvent *event)
{
QModelIndex itemIndex = indexAt(event->pos());
QMenu menu;
QAction *copy = new QAction(tr("&Copy"), this);
copy->setEnabled(itemIndex.isValid());
menu.addAction(copy);
QAction *show = new QAction(tr("&Show in Editor"), this);
show->setEnabled(canShowItemInTextEditor(itemIndex));
menu.addAction(show);
menu.addSeparator();
QAction *clear = new QAction(tr("C&lear"), this);
menu.addAction(clear);
QAction *a = menu.exec(event->globalPos());
if (a == 0)
return;
if (a == copy) {
copyToClipboard(itemIndex);
} else if (a == show) {
onRowActivated(itemIndex);
} else if (a == clear) {
QAbstractProxyModel *proxyModel = qobject_cast<QAbstractProxyModel *>(model());
QmlConsoleItemModel *handler = qobject_cast<QmlConsoleItemModel *>(
proxyModel->sourceModel());
handler->clear();
}
}
void QmlConsoleView::focusInEvent(QFocusEvent *event)
{
Q_UNUSED(event);
selectionModel()->setCurrentIndex(model()->index(model()->rowCount() - 1, 0),
QItemSelectionModel::ClearAndSelect);
}
void QmlConsoleView::onRowActivated(const QModelIndex &index)
{
if (!index.isValid())
return;
// See if we have file and line Info
QString filePath = model()->data(index, ConsoleItem::FileRole).toString();
const QUrl fileUrl = QUrl(filePath);
if (fileUrl.isLocalFile())
filePath = fileUrl.toLocalFile();
if (!filePath.isEmpty()) {
QFileInfo fi(filePath);
if (fi.exists() && fi.isFile() && fi.isReadable()) {
int line = model()->data(index, ConsoleItem::LineRole).toInt();
Core::EditorManager::openEditorAt(fi.canonicalFilePath(), line);
}
}
}
void QmlConsoleView::copyToClipboard(const QModelIndex &index)
{
if (!index.isValid())
return;
QString contents = model()->data(index, ConsoleItem::ExpressionRole).toString();
// See if we have file and line Info
QString filePath = model()->data(index, ConsoleItem::FileRole).toString();
const QUrl fileUrl = QUrl(filePath);
if (fileUrl.isLocalFile())
filePath = fileUrl.toLocalFile();
if (!filePath.isEmpty()) {
contents = QString::fromLatin1("%1 %2: %3").arg(contents).arg(filePath).arg(
model()->data(index, ConsoleItem::LineRole).toString());
}
QClipboard *cb = QApplication::clipboard();
cb->setText(contents);
}
bool QmlConsoleView::canShowItemInTextEditor(const QModelIndex &index)
{
if (!index.isValid())
return false;
// See if we have file and line Info
QString filePath = model()->data(index, ConsoleItem::FileRole).toString();
const QUrl fileUrl = QUrl(filePath);
if (fileUrl.isLocalFile())
filePath = fileUrl.toLocalFile();
if (!filePath.isEmpty()) {
QFileInfo fi(filePath);
if (fi.exists() && fi.isFile() && fi.isReadable())
return true;
}
return false;
}
} // Internal
} // QmlJSTools

View File

@@ -1,67 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** 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 The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** 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 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef QMLCONSOLEVIEW_H
#define QMLCONSOLEVIEW_H
#include <utils/itemviews.h>
namespace QmlJSTools {
namespace Internal {
class QmlConsoleView : public Utils::TreeView
{
Q_OBJECT
public:
QmlConsoleView(QWidget *parent);
public slots:
void onScrollToBottom();
protected:
void mousePressEvent(QMouseEvent *event);
void resizeEvent(QResizeEvent *e);
void drawBranches(QPainter *painter, const QRect &rect,
const QModelIndex &index) const;
void contextMenuEvent(QContextMenuEvent *event);
void focusInEvent(QFocusEvent *event);
private slots:
void onRowActivated(const QModelIndex &index);
private:
void copyToClipboard(const QModelIndex &index);
bool canShowItemInTextEditor(const QModelIndex &index);
};
} // Internal
} // QmlJSTools
#endif // QMLCONSOLEVIEW_H

View File

@@ -20,16 +20,7 @@ HEADERS += \
$$PWD/qmljsindenter.h \
$$PWD/qmljscodestylesettingspage.h \
$$PWD/qmljssemanticinfo.h \
$$PWD/qmljstools_global.h \
$$PWD/qmlconsolemanager.h \
$$PWD/qmlconsoleitemmodel.h \
$$PWD/qmlconsolemodel.h \
$$PWD/qmlconsolepane.h \
$$PWD/qmlconsoleview.h \
$$PWD/qmlconsoleitemdelegate.h \
$$PWD/qmlconsoleedit.h \
$$PWD/qmljsinterpreter.h \
$$PWD/qmlconsoleproxymodel.h
$$PWD/qmljstools_global.h
SOURCES += \
$$PWD/qmljsbundleprovider.cpp \
@@ -43,15 +34,7 @@ SOURCES += \
$$PWD/qmljslocatordata.cpp \
$$PWD/qmljsindenter.cpp \
$$PWD/qmljscodestylesettingspage.cpp \
$$PWD/qmljssemanticinfo.cpp \
$$PWD/qmlconsolemanager.cpp \
$$PWD/qmlconsoleitemmodel.cpp \
$$PWD/qmlconsolepane.cpp \
$$PWD/qmlconsoleview.cpp \
$$PWD/qmlconsoleitemdelegate.cpp \
$$PWD/qmlconsoleedit.cpp \
$$PWD/qmljsinterpreter.cpp \
$$PWD/qmlconsoleproxymodel.cpp
$$PWD/qmljssemanticinfo.cpp
RESOURCES += \
qmljstools.qrc

View File

@@ -44,22 +44,6 @@ QtcPlugin {
"qmljstoolsplugin.h",
"qmljstoolssettings.cpp",
"qmljstoolssettings.h",
"qmlconsolemanager.cpp",
"qmlconsolemanager.h",
"qmlconsoleitemmodel.cpp",
"qmlconsoleitemmodel.h",
"qmlconsolepane.cpp",
"qmlconsolepane.h",
"qmlconsoleview.cpp",
"qmlconsoleview.h",
"qmlconsoleitemdelegate.cpp",
"qmlconsoleitemdelegate.h",
"qmlconsoleedit.cpp",
"qmlconsoleedit.h",
"qmlconsoleproxymodel.cpp",
"qmlconsoleproxymodel.h",
"qmljsinterpreter.cpp",
"qmljsinterpreter.h",
"qmljstools.qrc"
]

View File

@@ -35,7 +35,6 @@
#include "qmljscodestylesettingspage.h"
#include "qmljstoolsconstants.h"
#include "qmljstoolssettings.h"
#include "qmlconsolemanager.h"
#include "qmljsbundleprovider.h"
#include <coreplugin/icontext.h>
@@ -67,7 +66,6 @@ QmlJSToolsPlugin::~QmlJSToolsPlugin()
{
m_instance = 0;
m_modelManager = 0; // deleted automatically
m_consoleManager = 0; // deleted automatically
}
bool QmlJSToolsPlugin::initialize(const QStringList &arguments, QString *error)
@@ -81,7 +79,6 @@ bool QmlJSToolsPlugin::initialize(const QStringList &arguments, QString *error)
// Objects
m_modelManager = new ModelManager(this);
m_consoleManager = new QmlConsoleManager(this);
// VCSManager *vcsManager = core->vcsManager();
// DocumentManager *fileManager = core->fileManager();

View File

@@ -43,7 +43,6 @@ QT_END_NAMESPACE
namespace QmlJSTools {
class QmlJSToolsSettings;
class QmlConsoleManager;
namespace Internal {
@@ -75,7 +74,6 @@ private slots:
private:
ModelManager *m_modelManager;
QmlConsoleManager *m_consoleManager;
QmlJSToolsSettings *m_settings;
QAction *m_resetCodeModelAction;