forked from qt-creator/qt-creator
ProjectExplorer: Fix copying filtered-out text
Invisible blocks must be excluded. Fixes: QTCREATORBUG-23425 Change-Id: I93a253bd47820d6eb6feea90056c76091e376070 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -33,6 +33,8 @@
|
|||||||
#include <utils/synchronousprocess.h>
|
#include <utils/synchronousprocess.h>
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
|
#include <QCursor>
|
||||||
|
#include <QMimeData>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
@@ -512,6 +514,33 @@ bool OutputWindow::isScrollbarAtBottom() const
|
|||||||
return verticalScrollBar()->value() == verticalScrollBar()->maximum();
|
return verticalScrollBar()->value() == verticalScrollBar()->maximum();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QMimeData *OutputWindow::createMimeDataFromSelection() const
|
||||||
|
{
|
||||||
|
const auto mimeData = new QMimeData;
|
||||||
|
QString content;
|
||||||
|
const int selStart = textCursor().selectionStart();
|
||||||
|
const int selEnd = textCursor().selectionEnd();
|
||||||
|
const QTextBlock firstBlock = document()->findBlock(selStart);
|
||||||
|
const QTextBlock lastBlock = document()->findBlock(selEnd);
|
||||||
|
for (QTextBlock curBlock = firstBlock; curBlock != lastBlock; curBlock = curBlock.next()) {
|
||||||
|
if (!curBlock.isVisible())
|
||||||
|
continue;
|
||||||
|
if (curBlock == firstBlock)
|
||||||
|
content += curBlock.text().mid(selStart - firstBlock.position());
|
||||||
|
else
|
||||||
|
content += curBlock.text();
|
||||||
|
content += '\n';
|
||||||
|
}
|
||||||
|
if (lastBlock.isValid() && lastBlock.isVisible()) {
|
||||||
|
if (firstBlock == lastBlock)
|
||||||
|
content = textCursor().selectedText();
|
||||||
|
else
|
||||||
|
content += lastBlock.text().mid(0, selEnd - lastBlock.position());
|
||||||
|
}
|
||||||
|
mimeData->setText(content);
|
||||||
|
return mimeData;
|
||||||
|
}
|
||||||
|
|
||||||
void OutputWindow::clear()
|
void OutputWindow::clear()
|
||||||
{
|
{
|
||||||
d->enforceNewline = false;
|
d->enforceNewline = false;
|
||||||
|
@@ -66,8 +66,6 @@ public:
|
|||||||
void grayOutOldContent();
|
void grayOutOldContent();
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
void showEvent(QShowEvent *) override;
|
|
||||||
|
|
||||||
void scrollToBottom();
|
void scrollToBottom();
|
||||||
|
|
||||||
void setMaxCharCount(int count);
|
void setMaxCharCount(int count);
|
||||||
@@ -94,14 +92,16 @@ public slots:
|
|||||||
protected:
|
protected:
|
||||||
bool isScrollbarAtBottom() const;
|
bool isScrollbarAtBottom() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QMimeData *createMimeDataFromSelection() const override;
|
||||||
|
void keyPressEvent(QKeyEvent *ev) override;
|
||||||
void mousePressEvent(QMouseEvent *e) override;
|
void mousePressEvent(QMouseEvent *e) override;
|
||||||
void mouseReleaseEvent(QMouseEvent *e) override;
|
void mouseReleaseEvent(QMouseEvent *e) override;
|
||||||
void mouseMoveEvent(QMouseEvent *e) override;
|
void mouseMoveEvent(QMouseEvent *e) override;
|
||||||
void resizeEvent(QResizeEvent *e) override;
|
void resizeEvent(QResizeEvent *e) override;
|
||||||
void keyPressEvent(QKeyEvent *ev) override;
|
void showEvent(QShowEvent *) override;
|
||||||
void wheelEvent(QWheelEvent *e) override;
|
void wheelEvent(QWheelEvent *e) override;
|
||||||
|
|
||||||
private:
|
|
||||||
using QPlainTextEdit::setFont; // call setBaseFont instead, which respects the zoom factor
|
using QPlainTextEdit::setFont; // call setBaseFont instead, which respects the zoom factor
|
||||||
QTimer m_scrollTimer;
|
QTimer m_scrollTimer;
|
||||||
QElapsedTimer m_lastMessage;
|
QElapsedTimer m_lastMessage;
|
||||||
|
Reference in New Issue
Block a user