2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2012-10-05 11:50:16 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2012-10-05 11:50:16 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2012-10-05 11:50:16 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2012-10-05 11:50:16 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2012-10-05 11:50:16 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2012-10-05 11:50:16 +02:00
|
|
|
|
2015-11-10 16:59:02 +01:00
|
|
|
#include "consoleitemdelegate.h"
|
|
|
|
|
#include "consoleedit.h"
|
2012-02-08 15:54:59 +01:00
|
|
|
|
2014-06-13 11:19:54 +02:00
|
|
|
#include <coreplugin/coreconstants.h>
|
2016-08-03 17:55:54 +02:00
|
|
|
|
|
|
|
|
#include <utils/utilsicons.h>
|
2017-03-16 14:25:25 +01:00
|
|
|
#include <utils/theme/theme.h>
|
2014-06-13 11:19:54 +02:00
|
|
|
|
2012-02-17 22:33:40 +02:00
|
|
|
#include <QPainter>
|
|
|
|
|
#include <QTreeView>
|
2012-02-22 11:50:05 +01:00
|
|
|
#include <QScrollBar>
|
2013-04-03 10:43:37 +02:00
|
|
|
#include <QTextLayout>
|
2013-05-24 16:31:01 +02:00
|
|
|
#include <QUrl>
|
2012-02-08 15:54:59 +01:00
|
|
|
|
2012-02-22 11:50:05 +01:00
|
|
|
const int ELLIPSIS_GRADIENT_WIDTH = 16;
|
|
|
|
|
|
2015-11-10 16:59:02 +01:00
|
|
|
namespace Debugger {
|
2012-02-08 15:54:59 +01:00
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
2015-11-10 16:59:02 +01:00
|
|
|
// ConsoleItemDelegate
|
2012-02-08 15:54:59 +01:00
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2015-11-10 16:59:02 +01:00
|
|
|
ConsoleItemDelegate::ConsoleItemDelegate(ConsoleItemModel *model, QObject *parent) :
|
2012-02-08 15:54:59 +01:00
|
|
|
QStyledItemDelegate(parent),
|
2015-11-10 16:59:02 +01:00
|
|
|
m_model(model),
|
2016-08-03 17:55:54 +02:00
|
|
|
m_logIcon(Utils::Icons::INFO.icon()),
|
|
|
|
|
m_warningIcon(Utils::Icons::WARNING.icon()),
|
2017-01-02 12:37:49 +01:00
|
|
|
m_errorIcon(Utils::Icons::CRITICAL.icon()),
|
2016-08-03 17:55:54 +02:00
|
|
|
m_expandIcon(Utils::Icons::EXPAND.icon()),
|
|
|
|
|
m_collapseIcon(Utils::Icons::COLLAPSE.icon()),
|
2017-03-16 14:25:25 +01:00
|
|
|
m_prompt(Utils::Icon({{QLatin1String(":/utils/images/next.png"),
|
|
|
|
|
Utils::Theme::TextColorNormal}}, Utils::Icon::Tint).icon()),
|
2012-05-07 11:16:03 +02:00
|
|
|
m_cachedHeight(0)
|
2012-02-08 15:54:59 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-10 16:59:02 +01:00
|
|
|
void ConsoleItemDelegate::emitSizeHintChanged(const QModelIndex &index)
|
2012-02-08 15:54:59 +01:00
|
|
|
{
|
|
|
|
|
emit sizeHintChanged(index);
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-10 16:59:02 +01:00
|
|
|
QColor ConsoleItemDelegate::drawBackground(QPainter *painter, const QRect &rect,
|
2012-10-04 14:54:59 +02:00
|
|
|
const QModelIndex &index,
|
|
|
|
|
bool selected) const
|
2012-02-08 15:54:59 +01:00
|
|
|
{
|
2017-03-16 14:25:25 +01:00
|
|
|
const Utils::Theme *theme = Utils::creatorTheme();
|
2012-02-15 12:35:43 +01:00
|
|
|
painter->save();
|
2017-03-16 14:25:25 +01:00
|
|
|
QColor backgroundColor = theme->color(selected
|
|
|
|
|
? Utils::Theme::BackgroundColorSelected
|
|
|
|
|
: Utils::Theme::BackgroundColorNormal);
|
2012-02-15 12:35:43 +01:00
|
|
|
if (!(index.flags() & Qt::ItemIsEditable))
|
|
|
|
|
painter->setBrush(backgroundColor);
|
2012-02-08 15:54:59 +01:00
|
|
|
painter->setPen(Qt::NoPen);
|
|
|
|
|
painter->drawRect(rect);
|
2012-02-15 12:35:43 +01:00
|
|
|
painter->restore();
|
2012-02-22 11:50:05 +01:00
|
|
|
return backgroundColor;
|
2012-02-08 15:54:59 +01:00
|
|
|
}
|
|
|
|
|
|
2015-11-10 16:59:02 +01:00
|
|
|
void ConsoleItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
|
2012-10-04 14:54:59 +02:00
|
|
|
const QModelIndex &index) const
|
2012-02-08 15:54:59 +01:00
|
|
|
{
|
2017-03-16 14:25:25 +01:00
|
|
|
const Utils::Theme *theme = Utils::creatorTheme();
|
2016-01-21 15:00:33 +01:00
|
|
|
QStyleOptionViewItem opt = option;
|
2012-02-08 15:54:59 +01:00
|
|
|
initStyleOption(&opt, index);
|
|
|
|
|
painter->save();
|
|
|
|
|
|
2012-10-04 14:54:59 +02:00
|
|
|
// Set Colors
|
2012-02-08 15:54:59 +01:00
|
|
|
QColor textColor;
|
|
|
|
|
QIcon taskIcon;
|
2012-10-08 13:17:10 +02:00
|
|
|
ConsoleItem::ItemType type = (ConsoleItem::ItemType)index.data(
|
2015-08-21 17:33:53 +02:00
|
|
|
ConsoleItem::TypeRole).toInt();
|
2012-02-08 15:54:59 +01:00
|
|
|
switch (type) {
|
2012-10-08 13:17:10 +02:00
|
|
|
case ConsoleItem::DebugType:
|
2017-03-16 14:25:25 +01:00
|
|
|
textColor = theme->color(Utils::Theme::OutputPanes_NormalMessageTextColor);
|
2012-02-08 15:54:59 +01:00
|
|
|
taskIcon = m_logIcon;
|
|
|
|
|
break;
|
2012-10-08 13:17:10 +02:00
|
|
|
case ConsoleItem::WarningType:
|
2017-03-16 14:25:25 +01:00
|
|
|
textColor = theme->color(Utils::Theme::OutputPanes_WarningMessageTextColor);
|
2012-02-08 15:54:59 +01:00
|
|
|
taskIcon = m_warningIcon;
|
|
|
|
|
break;
|
2012-10-08 13:17:10 +02:00
|
|
|
case ConsoleItem::ErrorType:
|
2017-03-16 14:25:25 +01:00
|
|
|
textColor = theme->color(Utils::Theme::OutputPanes_ErrorMessageTextColor);
|
2012-02-08 15:54:59 +01:00
|
|
|
taskIcon = m_errorIcon;
|
|
|
|
|
break;
|
2012-10-08 13:17:10 +02:00
|
|
|
case ConsoleItem::InputType:
|
2017-03-16 14:25:25 +01:00
|
|
|
textColor = theme->color(Utils::Theme::TextColorNormal);
|
2012-02-08 15:54:59 +01:00
|
|
|
taskIcon = m_prompt;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
2017-03-16 14:25:25 +01:00
|
|
|
textColor = theme->color(Utils::Theme::TextColorNormal);
|
2012-02-08 15:54:59 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-04 14:54:59 +02:00
|
|
|
// Paint background
|
2012-02-22 11:50:05 +01:00
|
|
|
QColor backgroundColor = drawBackground(painter, opt.rect, index,
|
2012-10-04 14:54:59 +02:00
|
|
|
bool(opt.state & QStyle::State_Selected));
|
2012-02-08 15:54:59 +01:00
|
|
|
|
2012-10-04 14:54:59 +02:00
|
|
|
// Calculate positions
|
2012-02-08 15:54:59 +01:00
|
|
|
const QTreeView *view = qobject_cast<const QTreeView *>(opt.widget);
|
|
|
|
|
int level = 0;
|
|
|
|
|
QModelIndex idx(index);
|
|
|
|
|
while (idx.parent() != QModelIndex()) {
|
|
|
|
|
idx = idx.parent();
|
|
|
|
|
level++;
|
|
|
|
|
}
|
2012-10-04 14:54:59 +02:00
|
|
|
int width = view->width() - level * view->indentation() - view->verticalScrollBar()->width();
|
2012-02-08 15:54:59 +01:00
|
|
|
bool showTypeIcon = index.parent() == QModelIndex();
|
2015-08-21 17:33:53 +02:00
|
|
|
bool showExpandableIcon = type == ConsoleItem::DefaultType;
|
2012-02-08 15:54:59 +01:00
|
|
|
|
|
|
|
|
QRect rect(opt.rect.x(), opt.rect.top(), width, opt.rect.height());
|
2015-11-10 16:59:02 +01:00
|
|
|
ConsoleItemPositions positions(m_model, rect, opt.font, showTypeIcon, showExpandableIcon);
|
2012-02-08 15:54:59 +01:00
|
|
|
|
|
|
|
|
// 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
|
2012-04-12 15:06:50 +02:00
|
|
|
QString str = index.data(Qt::DisplayRole).toString();
|
|
|
|
|
bool showFileLineInfo = true;
|
2012-05-07 11:16:03 +02:00
|
|
|
// 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);
|
2012-10-04 14:54:59 +02:00
|
|
|
painter->drawText(positions.textArea(), fm.elidedText(str, Qt::ElideRight,
|
|
|
|
|
positions.textAreaWidth()));
|
2012-05-07 11:16:03 +02:00
|
|
|
}
|
2012-10-04 14:54:59 +02:00
|
|
|
// skip if area is editable
|
2012-02-08 15:54:59 +01:00
|
|
|
if (showExpandableIcon) {
|
|
|
|
|
// Paint ExpandableIconArea:
|
|
|
|
|
QIcon expandCollapseIcon;
|
2015-08-21 17:33:53 +02:00
|
|
|
if (index.model()->rowCount(index) || index.model()->canFetchMore(index)) {
|
2012-02-08 15:54:59 +01:00
|
|
|
if (view->isExpanded(index))
|
|
|
|
|
expandCollapseIcon = m_collapseIcon;
|
|
|
|
|
else
|
|
|
|
|
expandCollapseIcon = m_expandIcon;
|
|
|
|
|
}
|
2012-10-04 14:54:59 +02:00
|
|
|
painter->drawPixmap(positions.expandCollapseIconLeft(), positions.adjustedTop(),
|
|
|
|
|
expandCollapseIcon.pixmap(positions.expandCollapseIconWidth(),
|
|
|
|
|
positions.expandCollapseIconHeight()));
|
2012-02-08 15:54:59 +01:00
|
|
|
}
|
|
|
|
|
|
2012-04-12 15:06:50 +02:00
|
|
|
if (showFileLineInfo) {
|
2012-10-04 14:54:59 +02:00
|
|
|
// Check for file info
|
2015-08-21 17:33:53 +02:00
|
|
|
QString file = index.data(ConsoleItem::FileRole).toString();
|
2013-05-24 16:31:01 +02:00
|
|
|
const QUrl fileUrl = QUrl(file);
|
|
|
|
|
if (fileUrl.isLocalFile())
|
|
|
|
|
file = fileUrl.toLocalFile();
|
2012-04-12 15:06:50 +02:00
|
|
|
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());
|
2012-10-04 14:54:59 +02:00
|
|
|
painter->drawText(positions.fileAreaLeft(), positions.adjustedTop() + fm.ascent(),
|
|
|
|
|
file);
|
2012-04-12 15:06:50 +02:00
|
|
|
if (realFileWidth > positions.fileAreaWidth()) {
|
|
|
|
|
// draw a gradient to mask the text
|
|
|
|
|
int gradientStart = positions.fileAreaLeft() - 1;
|
2012-10-04 14:54:59 +02:00
|
|
|
QLinearGradient lg(gradientStart + ELLIPSIS_GRADIENT_WIDTH, 0, gradientStart, 0);
|
2012-04-12 15:06:50 +02:00
|
|
|
lg.setColorAt(0, Qt::transparent);
|
|
|
|
|
lg.setColorAt(1, backgroundColor);
|
|
|
|
|
painter->fillRect(gradientStart, positions.adjustedTop(),
|
2012-10-04 14:54:59 +02:00
|
|
|
ELLIPSIS_GRADIENT_WIDTH, positions.lineHeight(), lg);
|
2012-04-12 15:06:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Paint LineArea
|
2015-08-21 17:33:53 +02:00
|
|
|
QString lineText = index.data(ConsoleItem::LineRole).toString();
|
2012-04-12 15:06:50 +02:00
|
|
|
painter->setClipRect(positions.lineArea());
|
|
|
|
|
const int realLineWidth = fm.width(lineText);
|
|
|
|
|
painter->drawText(positions.lineAreaRight() - realLineWidth,
|
|
|
|
|
positions.adjustedTop() + fm.ascent(), lineText);
|
2012-02-22 11:50:05 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
painter->setClipRect(opt.rect);
|
2012-02-08 15:54:59 +01:00
|
|
|
painter->restore();
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-10 16:59:02 +01:00
|
|
|
QSize ConsoleItemDelegate::sizeHint(const QStyleOptionViewItem &option,
|
2012-10-04 14:54:59 +02:00
|
|
|
const QModelIndex &index) const
|
2012-02-08 15:54:59 +01:00
|
|
|
{
|
2016-01-21 15:00:33 +01:00
|
|
|
QStyleOptionViewItem opt = option;
|
2012-02-08 15:54:59 +01:00
|
|
|
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++;
|
|
|
|
|
}
|
2012-10-04 14:54:59 +02:00
|
|
|
int width = view->width() - level * view->indentation() - view->verticalScrollBar()->width();
|
2012-02-08 15:54:59 +01:00
|
|
|
|
2012-05-07 11:16:03 +02:00
|
|
|
const bool selected = (view->selectionModel()->currentIndex() == index);
|
|
|
|
|
if (!selected && option.font == m_cachedFont && m_cachedHeight > 0)
|
|
|
|
|
return QSize(width, m_cachedHeight);
|
|
|
|
|
|
2012-10-08 13:17:10 +02:00
|
|
|
ConsoleItem::ItemType type = (ConsoleItem::ItemType)index.data(
|
2015-08-21 17:33:53 +02:00
|
|
|
ConsoleItem::TypeRole).toInt();
|
2012-02-08 15:54:59 +01:00
|
|
|
bool showTypeIcon = index.parent() == QModelIndex();
|
2015-08-21 17:33:53 +02:00
|
|
|
bool showExpandableIcon = type == ConsoleItem::DefaultType;
|
2012-02-08 15:54:59 +01:00
|
|
|
|
|
|
|
|
QRect rect(level * view->indentation(), 0, width, 0);
|
2015-11-10 16:59:02 +01:00
|
|
|
ConsoleItemPositions positions(m_model, rect, opt.font, showTypeIcon, showExpandableIcon);
|
2012-02-08 15:54:59 +01:00
|
|
|
|
2012-04-12 15:06:50 +02:00
|
|
|
QFontMetrics fm(option.font);
|
2012-05-07 11:16:03 +02:00
|
|
|
qreal height = fm.height();
|
|
|
|
|
|
|
|
|
|
if (selected) {
|
|
|
|
|
QString str = index.data(Qt::DisplayRole).toString();
|
|
|
|
|
|
|
|
|
|
QTextLayout tl(str, option.font);
|
|
|
|
|
height = layoutText(tl, positions.textAreaWidth());
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-08 15:54:59 +01:00
|
|
|
height += 2 * ConsoleItemPositions::ITEM_PADDING;
|
2012-05-07 11:16:03 +02:00
|
|
|
|
2012-02-08 15:54:59 +01:00
|
|
|
if (height < positions.minimumHeight())
|
|
|
|
|
height = positions.minimumHeight();
|
|
|
|
|
|
2012-05-07 11:16:03 +02:00
|
|
|
if (!selected) {
|
|
|
|
|
m_cachedHeight = height;
|
|
|
|
|
m_cachedFont = option.font;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-08 15:54:59 +01:00
|
|
|
return QSize(width, height);
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-10 16:59:02 +01:00
|
|
|
QWidget *ConsoleItemDelegate::createEditor(QWidget *parent,
|
2012-10-04 14:54:59 +02:00
|
|
|
const QStyleOptionViewItem &/*option*/,
|
|
|
|
|
const QModelIndex &index) const
|
2012-02-08 15:54:59 +01:00
|
|
|
|
|
|
|
|
{
|
2015-11-10 16:59:02 +01:00
|
|
|
ConsoleEdit *editor = new ConsoleEdit(index, parent);
|
2017-03-16 14:25:25 +01:00
|
|
|
// Make the background transparent so that the prompt shines through
|
2015-10-28 19:24:16 +01:00
|
|
|
editor->setStyleSheet(QLatin1String("QTextEdit {"
|
|
|
|
|
"margin-left: 24px;"
|
|
|
|
|
"margin-top: 4px;"
|
2017-03-16 14:25:25 +01:00
|
|
|
"background-color: transparent;"
|
2015-10-28 19:24:16 +01:00
|
|
|
"}"));
|
2016-05-19 12:44:27 +02:00
|
|
|
connect(editor, &ConsoleEdit::editingFinished, this, [this, editor] {
|
|
|
|
|
auto delegate = const_cast<ConsoleItemDelegate*>(this);
|
|
|
|
|
emit delegate->commitData(editor);
|
|
|
|
|
emit delegate->closeEditor(editor);
|
|
|
|
|
});
|
2012-02-08 15:54:59 +01:00
|
|
|
return editor;
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-10 16:59:02 +01:00
|
|
|
void ConsoleItemDelegate::setEditorData(QWidget *editor,
|
2012-10-04 14:54:59 +02:00
|
|
|
const QModelIndex &index) const
|
2012-02-08 15:54:59 +01:00
|
|
|
{
|
2015-11-10 16:59:02 +01:00
|
|
|
ConsoleEdit *edtr = qobject_cast<ConsoleEdit *>(editor);
|
2015-08-21 17:33:53 +02:00
|
|
|
edtr->insertPlainText(index.data(ConsoleItem::ExpressionRole).toString());
|
2012-02-08 15:54:59 +01:00
|
|
|
}
|
|
|
|
|
|
2015-11-10 16:59:02 +01:00
|
|
|
void ConsoleItemDelegate::setModelData(QWidget *editor,
|
2012-10-04 14:54:59 +02:00
|
|
|
QAbstractItemModel *model,
|
|
|
|
|
const QModelIndex &index) const
|
2012-02-08 15:54:59 +01:00
|
|
|
{
|
2015-11-10 16:59:02 +01:00
|
|
|
ConsoleEdit *edtr = qobject_cast<ConsoleEdit *>(editor);
|
2015-08-21 17:33:53 +02:00
|
|
|
model->setData(index, edtr->getCurrentScript(), ConsoleItem::ExpressionRole);
|
|
|
|
|
model->setData(index, ConsoleItem::InputType, ConsoleItem::TypeRole);
|
2012-02-08 15:54:59 +01:00
|
|
|
}
|
|
|
|
|
|
2015-11-10 16:59:02 +01:00
|
|
|
void ConsoleItemDelegate::updateEditorGeometry(QWidget *editor,
|
2012-10-04 14:54:59 +02:00
|
|
|
const QStyleOptionViewItem &option,
|
|
|
|
|
const QModelIndex &/*index*/) const
|
2012-02-08 15:54:59 +01:00
|
|
|
{
|
2016-01-21 15:00:33 +01:00
|
|
|
editor->setGeometry(QRect(option.rect.x(), option.rect.top(), option.rect.width(), option.rect.bottom()));
|
2012-02-08 15:54:59 +01:00
|
|
|
}
|
|
|
|
|
|
2015-11-10 16:59:02 +01:00
|
|
|
void ConsoleItemDelegate::currentChanged(const QModelIndex ¤t,
|
2012-10-04 14:54:59 +02:00
|
|
|
const QModelIndex &previous)
|
2012-02-08 15:54:59 +01:00
|
|
|
{
|
|
|
|
|
emit sizeHintChanged(current);
|
|
|
|
|
emit sizeHintChanged(previous);
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-10 16:59:02 +01:00
|
|
|
qreal ConsoleItemDelegate::layoutText(QTextLayout &tl, int width,
|
2012-10-04 14:54:59 +02:00
|
|
|
bool *showFileLineInfo) const
|
2012-02-08 15:54:59 +01:00
|
|
|
{
|
|
|
|
|
qreal height = 0;
|
|
|
|
|
tl.beginLayout();
|
|
|
|
|
while (true) {
|
|
|
|
|
QTextLine line = tl.createLine();
|
|
|
|
|
|
|
|
|
|
if (!line.isValid())
|
|
|
|
|
break;
|
|
|
|
|
line.setLeadingIncluded(true);
|
|
|
|
|
line.setLineWidth(width);
|
2012-04-12 15:06:50 +02:00
|
|
|
if (width < line.naturalTextWidth() && showFileLineInfo)
|
|
|
|
|
*showFileLineInfo = false;
|
2012-02-08 15:54:59 +01:00
|
|
|
line.setPosition(QPoint(0, height));
|
|
|
|
|
height += line.height();
|
|
|
|
|
}
|
|
|
|
|
tl.endLayout();
|
|
|
|
|
return height;
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-04 14:54:59 +02:00
|
|
|
} // Internal
|
2015-11-10 16:59:02 +01:00
|
|
|
} // Debugger
|