2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@gmail.com>
3 (c) 2006 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
14 #include <QTextCharFormat>
21 virtual ~HLineExecutor() { }
22 virtual void writeChunk(const QString
&) = 0;
23 virtual void setFormat(const QTextCharFormat
&) = 0;
29 QTextCharFormat m_format
;
31 Region(int end
, QTextCharFormat format
)
33 , m_format(format
) { }
35 int end() const { return m_end
; }
36 const QTextCharFormat
& format() const { return m_format
; }
37 QTextCharFormat
& format() { return m_format
; }
39 void setEnd(int index
) { m_end
= index
; }
40 void setFormat(const QTextCharFormat
& format
) { m_format
= format
; }
43 std::pair
<bool, bool> m_bold
;
44 std::pair
<bool, bool> m_italic
;
45 std::pair
<bool, QColor
> m_color
;
47 : m_bold(false, false)
48 , m_italic(false, false)
49 , m_color(false, QColor()) { }
50 void applyTo(QTextCharFormat
& fmt
) const;
53 std::vector
<Region
> m_regions
;
56 int begin(uint index
) const;
57 uint
findRegion(int index
) const;
58 uint
splitRegion(int index
);
59 void setFormat(int begin
, int end
, const Format
&);
61 HLine(const QString
& text
, const QTextCharFormat
& baseFormat
);
62 HLine(const HLine
& other
);
64 const QTextCharFormat
& getFormat(int index
) const;
66 void setBold(int begin
, int end
, bool value
);
67 void setItalic(int begin
, int end
, bool value
);
68 void setColor(int begin
, int end
, const QColor
& color
);
69 QString
mid(int begin
, int end
) const;
70 int length() const { return m_text
.length(); }
71 HLine
* extract(int begin
, int end
) const;
72 HLine
* append(const HLine
& other
, int begin
, int end
) const;
76 void run(HLineExecutor
&) const;