diff options
Diffstat (limited to 'src/plugins/texteditor/texteditoroverlay.h')
-rw-r--r-- | src/plugins/texteditor/texteditoroverlay.h | 54 |
1 files changed, 35 insertions, 19 deletions
diff --git a/src/plugins/texteditor/texteditoroverlay.h b/src/plugins/texteditor/texteditoroverlay.h index 2f1502c2c5..17045e521a 100644 --- a/src/plugins/texteditor/texteditoroverlay.h +++ b/src/plugins/texteditor/texteditoroverlay.h @@ -34,37 +34,34 @@ #ifndef TEXTEDITOROVERLAY_H #define TEXTEDITOROVERLAY_H -#include <QtGui/QWidget> -#include "basetexteditor.h" +#include <QtCore/QObject> +#include <QtCore/QList> +#include <QtCore/QVector> +#include <QtGui/QTextCursor> +#include <QtGui/QColor> + +QT_FORWARD_DECLARE_CLASS(QWidget) namespace TextEditor { +class BaseTextEditor; + namespace Internal { -struct TEXTEDITOR_EXPORT OverlaySelection { +struct OverlaySelection +{ OverlaySelection():m_fixedLength(-1), m_dropShadow(false){} + QTextCursor m_cursor_begin; QTextCursor m_cursor_end; QColor m_fg; QColor m_bg; int m_fixedLength; bool m_dropShadow; - }; +}; -class TEXTEDITOR_EXPORT TextEditorOverlay : public QObject +class TextEditorOverlay : public QObject { -Q_OBJECT -BaseTextEditor *m_editor; -QWidget *m_viewport; - -public: -QList<OverlaySelection> m_selections; -private: - -bool m_visible; -int m_borderWidth; -int m_dropShadowWidth; -bool m_alpha; - + Q_OBJECT public: TextEditorOverlay(BaseTextEditor *editor); @@ -97,17 +94,36 @@ public: void addOverlaySelection(int begin, int end, const QColor &fg, const QColor &bg, uint overlaySelectionFlags = 0); + const QList<OverlaySelection> &selections() const { return m_selections; } + inline bool isEmpty() const { return m_selections.isEmpty(); } inline int dropShadowWidth() const { return m_dropShadowWidth; } bool hasCursorInSelection(const QTextCursor &cursor) const; + void mapEquivalentSelections(); + void updateEquivalentSelections(const QTextCursor &cursor); + + bool hasFirstSelectionBeginMoved() const; + private: QPainterPath createSelectionPath(const QTextCursor &begin, const QTextCursor &end, const QRect& clip); void paintSelection(QPainter *painter, const OverlaySelection &selection); void fillSelection(QPainter *painter, const OverlaySelection &selection, const QColor &color); - + int selectionIndexForCursor(const QTextCursor &cursor) const; + QString selectionText(int selectionIndex) const; + QTextCursor assembleCursorForSelection(int selectionIndex) const; + + bool m_visible; + int m_borderWidth; + int m_dropShadowWidth; + bool m_alpha; + int m_firstSelectionOriginalBegin; + BaseTextEditor *m_editor; + QWidget *m_viewport; + QList<OverlaySelection> m_selections; + QVector<QList<int> > m_equivalentSelections; }; } // namespace Internal |