2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2010-11-01 16:29:45 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2010-11-01 16:29:45 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2010-11-01 16:29:45 +01: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.
|
2010-11-01 16:29:45 +01: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.
|
2010-12-17 17:14:20 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2010-11-01 16:29:45 +01:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2010-07-02 13:47:14 +02:00
|
|
|
|
2010-11-01 16:29:45 +01:00
|
|
|
#include "texteditor_global.h"
|
2010-09-16 14:59:05 +02:00
|
|
|
|
2020-06-26 13:59:38 +02:00
|
|
|
#include <utils/id.h>
|
2019-01-24 06:39:20 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QTextCursor>
|
|
|
|
|
#include <QIcon>
|
2010-07-02 13:47:14 +02:00
|
|
|
|
|
|
|
|
namespace TextEditor {
|
2014-09-26 11:37:54 +02:00
|
|
|
class TextEditorWidget;
|
2010-07-02 13:47:14 +02:00
|
|
|
|
2019-01-24 06:39:20 +01:00
|
|
|
struct TEXTEDITOR_EXPORT RefactorMarker;
|
|
|
|
|
using RefactorMarkers = QList<RefactorMarker>;
|
|
|
|
|
|
|
|
|
|
struct TEXTEDITOR_EXPORT RefactorMarker {
|
2010-07-02 13:47:14 +02:00
|
|
|
inline bool isValid() const { return !cursor.isNull(); }
|
|
|
|
|
QTextCursor cursor;
|
|
|
|
|
QString tooltip;
|
|
|
|
|
QIcon icon;
|
|
|
|
|
mutable QRect rect; // used to cache last drawing positin in document coordinates
|
2019-01-24 06:39:20 +01:00
|
|
|
std::function<void(TextEditor::TextEditorWidget *)> callback;
|
2020-06-26 13:59:38 +02:00
|
|
|
Utils::Id type;
|
2010-07-02 13:47:14 +02:00
|
|
|
QVariant data;
|
2019-01-24 06:39:20 +01:00
|
|
|
|
2020-06-26 13:59:38 +02:00
|
|
|
static RefactorMarkers filterOutType(const RefactorMarkers &markers, const Utils::Id &type);
|
2010-07-02 13:47:14 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TEXTEDITOR_EXPORT RefactorOverlay : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2014-09-26 11:37:54 +02:00
|
|
|
explicit RefactorOverlay(TextEditor::TextEditorWidget *editor);
|
2010-07-02 13:47:14 +02:00
|
|
|
|
|
|
|
|
bool isEmpty() const { return m_markers.isEmpty(); }
|
|
|
|
|
void paint(QPainter *painter, const QRect &clip);
|
|
|
|
|
|
|
|
|
|
void setMarkers(const RefactorMarkers &markers) { m_markers = markers; }
|
|
|
|
|
RefactorMarkers markers() const { return m_markers; }
|
|
|
|
|
|
|
|
|
|
void clear() { m_markers.clear(); }
|
|
|
|
|
|
|
|
|
|
RefactorMarker markerAt(const QPoint &pos) const;
|
|
|
|
|
|
|
|
|
|
private:
|
2010-07-05 12:45:56 +02:00
|
|
|
void paintMarker(const RefactorMarker& marker, QPainter *painter, const QRect &clip);
|
2010-07-02 13:47:14 +02:00
|
|
|
RefactorMarkers m_markers;
|
2014-09-26 11:37:54 +02:00
|
|
|
TextEditorWidget *m_editor;
|
2010-07-02 13:47:14 +02:00
|
|
|
int m_maxWidth;
|
2010-11-01 16:29:45 +01:00
|
|
|
const QIcon m_icon;
|
2010-07-02 13:47:14 +02:00
|
|
|
};
|
|
|
|
|
|
2010-11-01 16:29:45 +01:00
|
|
|
} // namespace TextEditor
|