From 7dd898a1b1c8db8dcf7b9ffeaf7a26e1c3266479 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 25 Aug 2015 15:26:48 +0200 Subject: [PATCH] QmlJSTools: Fix glitches in QML console Half of the widget height is a particularly bad estimate for the default height of a console item. Focusing editable items should be done by explicitly transferring focus. Also, this only "worked" if an editable or formerly editable row was the very first line in the view, which rarely happens. By default, if no settings are present, all log categories are enabled now. Otherwise we might miss the error messages resulting from failed evaluations. Repeatedly setting the filter regexp to the same thing doesn't signal a filter change, which is what we actually want when changing the filter. Change-Id: Ibe33b0438d92e777bdceaf9af032fc5117ba4041 Reviewed-by: hjk --- src/libs/qmljs/consoleitem.h | 1 + .../qmljstools/qmlconsoleitemdelegate.cpp | 2 -- src/plugins/qmljstools/qmlconsolepane.cpp | 3 +++ .../qmljstools/qmlconsoleproxymodel.cpp | 18 ++++++++++-------- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/libs/qmljs/consoleitem.h b/src/libs/qmljs/consoleitem.h index b6def3db74f..01254d413f7 100644 --- a/src/libs/qmljs/consoleitem.h +++ b/src/libs/qmljs/consoleitem.h @@ -56,6 +56,7 @@ public: WarningType = 0x04, ErrorType = 0x08, InputType = 0x10, + AllTypes = DefaultType | DebugType | WarningType | ErrorType | InputType }; Q_DECLARE_FLAGS(ItemTypes, ItemType) diff --git a/src/plugins/qmljstools/qmlconsoleitemdelegate.cpp b/src/plugins/qmljstools/qmlconsoleitemdelegate.cpp index 1bc78325da2..208be88e7a7 100644 --- a/src/plugins/qmljstools/qmlconsoleitemdelegate.cpp +++ b/src/plugins/qmljstools/qmlconsoleitemdelegate.cpp @@ -269,8 +269,6 @@ QSize QmlConsoleItemDelegate::sizeHint(const QStyleOptionViewItem &option, level++; } int width = view->width() - level * view->indentation() - view->verticalScrollBar()->width(); - if (index.flags() & Qt::ItemIsEditable) - return QSize(width, view->height() * 1/2); const bool selected = (view->selectionModel()->currentIndex() == index); if (!selected && option.font == m_cachedFont && m_cachedHeight > 0) diff --git a/src/plugins/qmljstools/qmlconsolepane.cpp b/src/plugins/qmljstools/qmlconsolepane.cpp index 8b660d9c405..7111eb6a935 100644 --- a/src/plugins/qmljstools/qmlconsolepane.cpp +++ b/src/plugins/qmljstools/qmlconsolepane.cpp @@ -111,6 +111,7 @@ QmlConsolePane::QmlConsolePane(QObject *parent) 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(QIcon(QLatin1String(Core::Constants::ICON_INFO))); connect(m_showDebugButtonAction, &Utils::SavedAction::toggled, m_proxyModel, &QmlConsoleProxyModel::setShowLogs); @@ -124,6 +125,7 @@ QmlConsolePane::QmlConsolePane(QObject *parent) 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(QIcon(QLatin1String(Core::Constants::ICON_WARNING))); connect(m_showWarningButtonAction, &Utils::SavedAction::toggled, m_proxyModel, &QmlConsoleProxyModel::setShowWarnings); @@ -137,6 +139,7 @@ QmlConsolePane::QmlConsolePane(QObject *parent) 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(QIcon(QLatin1String(Core::Constants::ICON_ERROR))); connect(m_showErrorButtonAction, &Utils::SavedAction::toggled, m_proxyModel, &QmlConsoleProxyModel::setShowErrors); m_showErrorButton->setDefaultAction(m_showErrorButtonAction); diff --git a/src/plugins/qmljstools/qmlconsoleproxymodel.cpp b/src/plugins/qmljstools/qmlconsoleproxymodel.cpp index 5ab1fdb9550..7a66670862a 100644 --- a/src/plugins/qmljstools/qmlconsoleproxymodel.cpp +++ b/src/plugins/qmljstools/qmlconsoleproxymodel.cpp @@ -38,27 +38,29 @@ namespace Internal { QmlConsoleProxyModel::QmlConsoleProxyModel(QObject *parent) : QSortFilterProxyModel(parent), - m_filter(ConsoleItem::DefaultType | ConsoleItem::InputType) + m_filter(ConsoleItem::AllTypes) { } void QmlConsoleProxyModel::setShowLogs(bool show) { - m_filter = show ? m_filter | ConsoleItem::DebugType : m_filter & ~ConsoleItem::DebugType; - setFilterRegExp(QString()); + 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; - setFilterRegExp(QString()); + 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; - setFilterRegExp(QString()); + m_filter = show ? (m_filter | ConsoleItem::ErrorType) + : (m_filter & ~ConsoleItem::ErrorType); + invalidateFilter(); } void QmlConsoleProxyModel::selectEditableRow(const QModelIndex &index,