30 #include "../../core/pattern/mvc/ItemController.h"
31 #include "../../core/AbstractScene.h"
32 #include "../../core/pattern/mvc/Observable.h"
33 #include "../../../color/RGBAColor.h"
34 #include "../../../qt/widgets/Utils.h"
35 #include "../../../geometry/Envelope.h"
36 #include "../../../common/STLUtils.h"
37 #include "../../core/Font.h"
38 #include "../../core/pattern/singleton/Context.h"
39 #include "../../item/TitleModel.h"
40 #include "../../core/Utils.h"
43 #include <QTextDocument>
45 #include <QTextCursor>
46 #include <QTextTableCell>
47 #include <QTextTableFormat>
48 #include <QTextLength>
49 #include <QTextCharFormat>
103 QTextDocument* doc = document();
105 QTextCursor cursor(doc);
108 QBrush blackBrush(Qt::SolidPattern);
110 QTextTableFormat tableFormat;
111 tableFormat.setAlignment(Qt::AlignLeft);
113 QVector<QTextLength> constraints;
115 for(
int c = 0 ; c < 2 ; ++c)
117 constraints << QTextLength(QTextLength::PercentageLength, 100);
120 tableFormat.setColumnWidthConstraints(constraints);
122 tableFormat.setHeaderRowCount(1);
124 m_table = cursor.insertTable(2, 1, tableFormat);
126 QTextCharFormat format = cursor.charFormat();
130 QColor qHeaderVtrColor(headerVtrColor.
getRed(), headerVtrColor.
getGreen(),
134 QColor qHeaderHrzColor(headerHrzColor.getRed(), headerHrzColor.getGreen(),
135 headerHrzColor.getBlue(), headerHrzColor.getAlpha());
138 QColor qBorderColor(borderColor.getRed(), borderColor.getGreen(),
139 borderColor.getBlue(), borderColor.getAlpha());
142 QColor qEvenRowColor(evenRowColor.getRed(), evenRowColor.getGreen(),
143 evenRowColor.getBlue(), evenRowColor.getAlpha());
146 QColor qOddRowColor(oddRowColor.getRed(), oddRowColor.getGreen(),
147 oddRowColor.getBlue(), oddRowColor.getAlpha());
150 QBrush headerVrt(qHeaderVtrColor);
151 QTextTableCell cellTwo = m_table->cellAt(0, 0);
152 QTextCharFormat fmtTwo = cellTwo.format();
153 fmtTwo.setBackground(headerVrt);
154 cellTwo.setFormat(fmtTwo);
155 QTextCursor cellCursorTwo = cellTwo.firstCursorPosition();
156 std::string title = model->
getTitle();
157 cellCursorTwo.insertText(title.c_str(), format);
160 QBrush headerHrz(qHeaderHrzColor);
161 QTextTableCell cellOne = m_table->cellAt(1, 0);
162 QTextCharFormat fmtOne = cellOne.format();
163 fmtOne.setBackground(headerHrz);
164 cellOne.setFormat(fmtOne);
165 std::string txt = model->
getText();
166 QTextCursor cellCursorOne = cellOne.firstCursorPosition();
167 cellCursorOne.insertText(txt.c_str(), format);
180 QImage img = createImage();
181 QPointF pp = scenePos();
182 te::gm::Envelope box(pp.x(), pp.y(), pp.x() + img.widthMM(), pp.y() + img.heightMM());
189 QTextTableCell cellOne = m_table->cellAt(0, 0);
190 QTextCursor cellCursorOne = cellOne.firstCursorPosition();
191 std::string txtOne = cellCursorOne.block().text().toStdString();
195 QTextTableCell cellTwo = m_table->cellAt(1, 0);
196 QTextCursor cellCursorTwo = cellTwo.firstCursorPosition();
197 std::string txtTwo = cellCursorTwo.block().text().toStdString();
Abstract class to represent an observable. "Model" part of MVC component.
Class responsible for maintaining the drawing context of a MVC component. It is always used by the "M...
virtual void setText(std::string txt)
virtual te::color::RGBAColor getEvenRow()
int getRed() const
It returns the red component color value (a value from 0 to 255).
virtual te::color::RGBAColor getOddRow()
int getPointSize()
Returns point size of the font.
int getBlue() const
It returns the blue component color value (a value from 0 to 255).
int getGreen() const
It returns the green component color value (a value from 0 to 255).
virtual std::string getText()
virtual void updateDocument()
Abstract class to represent a controller. "Controller" part of MVC component. All classes representin...
virtual void updateObserver(ContextItem context)
Reimplemented from TextItem.
virtual te::color::RGBAColor getBorderGridColor()
virtual ~TitleItem()
Destructor.
An Envelope defines a 2D rectangular region.
int getAlpha() const
It returns the alpha component color value (a value from 0 to 255).
virtual void setTitle(std::string title)
Class that represents a "Model" part of Title MVC component. Its coordinate system is the same of sce...
Class daughter of te::layout::TextItem representing a grid with two cells which can be inserted texts...
virtual te::color::RGBAColor getHeaderVerticalColor()
virtual std::string getTitle()
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
TitleItem(ItemController *controller, Observable *o)
Constructor.
virtual void setBox(te::gm::Envelope box)
Change the bounding rectangle.
virtual void refreshDocument()
virtual te::color::RGBAColor getHeaderHorizontalColor()
Class that represents text. This object is of type QGraphicsTextItem. He is directly editable via use...