Commit b0854e3c authored by Aurindam Jana's avatar Aurindam Jana Committed by Kai Koehne
Browse files

QmlConsole: Fix bug: Jump to location in editor

Since the file path starts with file:///

 use QUrl to
get local file name.

Task-number: QTCREATORBUG-9337
Change-Id: Icf591fdcab8cb626cfbf844c451a2c87c07b853a
Reviewed-by: default avatarKai Koehne <kai.koehne@digia.com>
parent 25dd9480
......@@ -33,6 +33,7 @@
#include <QPainter>
#include <QTreeView>
#include <QScrollBar>
#include <QUrl>
const char CONSOLE_LOG_BACKGROUND_COLOR[] = "#E8EEF2";
const char CONSOLE_WARNING_BACKGROUND_COLOR[] = "#F6F4EB";
......@@ -215,6 +216,9 @@ void QmlConsoleItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem
if (showFileLineInfo) {
// Check for file info
QString file = index.data(QmlConsoleItemModel::FileRole).toString();
const QUrl fileUrl = QUrl(file);
if (fileUrl.isLocalFile())
file = fileUrl.toLocalFile();
if (!file.isEmpty()) {
QFontMetrics fm(option.font);
// Paint FileArea
......
......@@ -226,8 +226,10 @@ 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, QmlConsoleItemModel::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()) {
......@@ -245,6 +247,9 @@ void QmlConsoleView::copyToClipboard(const QModelIndex &index)
QString contents = model()->data(index, QmlConsoleItemModel::ExpressionRole).toString();
// See if we have file and line Info
QString filePath = model()->data(index, QmlConsoleItemModel::FileRole).toString();
const QUrl fileUrl = QUrl(filePath);
if (fileUrl.isLocalFile())
filePath = fileUrl.toLocalFile();
if (!filePath.isEmpty()) {
contents = QString(QLatin1String("%1 %2: %3")).arg(contents).arg(filePath).arg(
model()->data(index, QmlConsoleItemModel::LineRole).toString());
......@@ -260,6 +265,9 @@ bool QmlConsoleView::canShowItemInTextEditor(const QModelIndex &index)
// See if we have file and line Info
QString filePath = model()->data(index, QmlConsoleItemModel::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())
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment