2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2012-02-27 20:55:36 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2012-02-27 20:55:36 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2012-02-27 20:55:36 +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.
|
2012-02-27 20:55:36 +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.
|
2012-02-27 20:55:36 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2012-02-27 20:55:36 +01:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2012-02-27 20:55:36 +01:00
|
|
|
|
|
|
|
|
#include "texteditor_global.h"
|
|
|
|
|
|
2015-04-17 12:46:28 +02:00
|
|
|
#include <coreplugin/id.h>
|
|
|
|
|
#include <utils/theme/theme.h>
|
|
|
|
|
|
2012-02-27 20:55:36 +01:00
|
|
|
#include <QIcon>
|
|
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
class QPainter;
|
|
|
|
|
class QRect;
|
|
|
|
|
class QTextBlock;
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
|
|
|
|
namespace TextEditor {
|
|
|
|
|
|
2014-07-23 19:10:38 +02:00
|
|
|
class BaseTextEditor;
|
2014-09-22 18:43:31 +02:00
|
|
|
class TextDocument;
|
2012-02-27 20:55:36 +01:00
|
|
|
|
2014-07-19 11:27:28 +02:00
|
|
|
namespace Internal { class TextMarkRegistry; }
|
|
|
|
|
|
|
|
|
|
class TEXTEDITOR_EXPORT TextMark
|
2012-02-27 20:55:36 +01:00
|
|
|
{
|
|
|
|
|
public:
|
2015-04-17 12:46:28 +02:00
|
|
|
TextMark(const QString &fileName, int lineNumber, Core::Id category);
|
2014-07-19 11:27:28 +02:00
|
|
|
virtual ~TextMark();
|
2012-02-27 20:55:36 +01:00
|
|
|
|
|
|
|
|
// determine order on markers on the same line.
|
|
|
|
|
enum Priority
|
|
|
|
|
{
|
|
|
|
|
LowPriority,
|
|
|
|
|
NormalPriority,
|
|
|
|
|
HighPriority // shown on top.
|
|
|
|
|
};
|
|
|
|
|
|
2014-07-19 11:27:28 +02:00
|
|
|
QString fileName() const;
|
2012-02-27 20:55:36 +01:00
|
|
|
int lineNumber() const;
|
2014-07-19 11:27:28 +02:00
|
|
|
|
2012-02-27 20:55:36 +01:00
|
|
|
virtual void paint(QPainter *painter, const QRect &rect) const;
|
2014-07-19 11:27:28 +02:00
|
|
|
/// called if the filename of the document changed
|
|
|
|
|
virtual void updateFileName(const QString &fileName);
|
2012-02-27 20:55:36 +01:00
|
|
|
virtual void updateLineNumber(int lineNumber);
|
|
|
|
|
virtual void updateBlock(const QTextBlock &block);
|
2014-07-09 17:18:03 +03:00
|
|
|
virtual void move(int line);
|
2012-02-27 20:55:36 +01:00
|
|
|
virtual void removedFromEditor();
|
2012-10-09 14:02:52 +02:00
|
|
|
virtual bool isClickable() const;
|
2012-05-02 13:10:14 +02:00
|
|
|
virtual void clicked();
|
2012-10-09 22:32:44 +02:00
|
|
|
virtual bool isDraggable() const;
|
|
|
|
|
virtual void dragToLine(int lineNumber);
|
2012-05-02 13:10:14 +02:00
|
|
|
|
2015-04-17 12:46:28 +02:00
|
|
|
static Utils::Theme::Color categoryColor(Core::Id category);
|
2015-05-27 14:32:44 +02:00
|
|
|
static bool categoryHasColor(Core::Id category);
|
2015-04-17 12:46:28 +02:00
|
|
|
static void setCategoryColor(Core::Id category, Utils::Theme::Color color);
|
2012-02-27 20:55:36 +01:00
|
|
|
void setIcon(const QIcon &icon);
|
2012-03-30 11:40:31 +02:00
|
|
|
// call this if the icon has changed.
|
|
|
|
|
void updateMarker();
|
2012-02-27 20:55:36 +01:00
|
|
|
Priority priority() const;
|
|
|
|
|
void setPriority(Priority prioriy);
|
2012-10-09 14:02:52 +02:00
|
|
|
bool isVisible() const;
|
|
|
|
|
void setVisible(bool isVisible);
|
2015-04-17 12:46:28 +02:00
|
|
|
Core::Id category() const;
|
2012-05-02 13:10:14 +02:00
|
|
|
double widthFactor() const;
|
|
|
|
|
void setWidthFactor(double factor);
|
2012-02-27 20:55:36 +01:00
|
|
|
|
2014-09-22 18:43:31 +02:00
|
|
|
TextDocument *baseTextDocument() const;
|
|
|
|
|
void setBaseTextDocument(TextDocument *baseTextDocument);
|
2014-07-18 15:29:04 +02:00
|
|
|
|
2016-07-19 11:58:15 +02:00
|
|
|
QString toolTip() const;
|
|
|
|
|
void setToolTip(const QString &toolTip);
|
|
|
|
|
|
2012-02-27 20:55:36 +01:00
|
|
|
private:
|
2014-07-19 11:27:28 +02:00
|
|
|
Q_DISABLE_COPY(TextMark)
|
|
|
|
|
friend class Internal::TextMarkRegistry;
|
|
|
|
|
|
2014-09-22 18:43:31 +02:00
|
|
|
TextDocument *m_baseTextDocument;
|
2014-07-19 11:27:28 +02:00
|
|
|
QString m_fileName;
|
2012-02-27 20:55:36 +01:00
|
|
|
int m_lineNumber;
|
|
|
|
|
Priority m_priority;
|
2012-05-02 13:10:14 +02:00
|
|
|
bool m_visible;
|
2013-02-18 18:47:54 +01:00
|
|
|
QIcon m_icon;
|
2015-04-17 12:46:28 +02:00
|
|
|
QColor m_color;
|
|
|
|
|
Core::Id m_category;
|
2013-02-18 18:47:54 +01:00
|
|
|
double m_widthFactor;
|
2016-07-19 11:58:15 +02:00
|
|
|
QString m_toolTip;
|
2012-02-27 20:55:36 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace TextEditor
|