From b5717a5315fb40b03f3d0b6b274a563381eb1ec0 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 21 Aug 2015 17:33:53 +0200 Subject: QmlJS: Lazy-load console items to allow for recursion Using Utils:TreeView automatically gives us the capability for loading item as they are expanded. This way we can show recursive structure in the console as well as load data from the debug server on demand. Also, properly print error messages received from unsuccessful command evaluations. Task-number: QTCREATORBUG-14931 Change-Id: I66d440eedd9723b04670169b27db1ee18f3f2891 Reviewed-by: hjk --- src/plugins/qmljstools/qmlconsoleview.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/plugins/qmljstools/qmlconsoleview.cpp') diff --git a/src/plugins/qmljstools/qmlconsoleview.cpp b/src/plugins/qmljstools/qmlconsoleview.cpp index ee374f0f00..5c0f054a42 100644 --- a/src/plugins/qmljstools/qmlconsoleview.cpp +++ b/src/plugins/qmljstools/qmlconsoleview.cpp @@ -147,9 +147,9 @@ void QmlConsoleView::mousePressEvent(QMouseEvent *event) QModelIndex index = indexAt(pos); if (index.isValid()) { ConsoleItem::ItemType type = (ConsoleItem::ItemType)index.data( - QmlConsoleItemModel::TypeRole).toInt(); + ConsoleItem::TypeRole).toInt(); bool handled = false; - if (type == ConsoleItem::UndefinedType) { + if (type == ConsoleItem::DefaultType) { bool showTypeIcon = index.parent() == QModelIndex(); ConsoleItemPositions positions(visualRect(index), viewOptions().font, showTypeIcon, true); @@ -222,14 +222,14 @@ void QmlConsoleView::onRowActivated(const QModelIndex &index) return; // See if we have file and line Info - QString filePath = model()->data(index, QmlConsoleItemModel::FileRole).toString(); + 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, QmlConsoleItemModel::LineRole).toInt(); + int line = model()->data(index, ConsoleItem::LineRole).toInt(); Core::EditorManager::openEditorAt(fi.canonicalFilePath(), line); } } @@ -240,15 +240,15 @@ void QmlConsoleView::copyToClipboard(const QModelIndex &index) if (!index.isValid()) return; - QString contents = model()->data(index, QmlConsoleItemModel::ExpressionRole).toString(); + QString contents = model()->data(index, ConsoleItem::ExpressionRole).toString(); // See if we have file and line Info - QString filePath = model()->data(index, QmlConsoleItemModel::FileRole).toString(); + 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, QmlConsoleItemModel::LineRole).toString()); + model()->data(index, ConsoleItem::LineRole).toString()); } QClipboard *cb = QApplication::clipboard(); cb->setText(contents); @@ -260,7 +260,7 @@ bool QmlConsoleView::canShowItemInTextEditor(const QModelIndex &index) return false; // See if we have file and line Info - QString filePath = model()->data(index, QmlConsoleItemModel::FileRole).toString(); + QString filePath = model()->data(index, ConsoleItem::FileRole).toString(); const QUrl fileUrl = QUrl(filePath); if (fileUrl.isLocalFile()) filePath = fileUrl.toLocalFile(); -- cgit v1.2.1