Commit 7dd898a1 authored by Ulf Hermann's avatar Ulf Hermann

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: default avatarhjk <hjk@theqtcompany.com>
parent b5717a53
......@@ -56,6 +56,7 @@ public:
WarningType = 0x04,
ErrorType = 0x08,
InputType = 0x10,
AllTypes = DefaultType | DebugType | WarningType | ErrorType | InputType
};
Q_DECLARE_FLAGS(ItemTypes, ItemType)
......
......@@ -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)
......
......@@ -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);
......
......@@ -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,
......
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