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 "../../item/TextGridModel.h"
38 #include "../../core/pattern/singleton/Context.h"
41 #include <QTextDocument>
42 #include <QTextCursor>
43 #include <QTextTableCell>
78 QImage img = createImage();
79 QPointF pp = scenePos();
80 te::gm::Envelope box(pp.x(), pp.y(), pp.x() + img.widthMM(), pp.y() + img.heightMM());
85 int countRows = m_table->rows();
86 int countColumns = m_table->columns();
89 for(
int i = 1 ; i < countRows ; ++i)
91 QTextTableCell cellOne = m_table->cellAt(i, 0);
92 QTextCursor cellCursorOne = cellOne.firstCursorPosition();
93 std::string txtOne = cellCursorOne.block().text().toStdString();
98 for(
int j = 0 ; j < countColumns ; ++j)
100 QTextTableCell cellTwo = m_table->cellAt(0, j);
101 QTextCursor cellCursorTwo = cellTwo.firstCursorPosition();
102 std::string txtTwo = cellCursorTwo.block().text().toStdString();
107 for (
int i = 1 ; i < countRows ; ++i)
109 for(
int j = 1 ; j < countColumns ; ++j)
111 QTextTableCell cellThree = m_table->cellAt(i, j);
112 QTextCursor cellCursorThree = cellThree.firstCursorPosition();
113 std::string txtThree = cellCursorThree.block().text().toStdString();
128 QTextDocument* doc = document();
130 QTextCursor cursor(doc);
133 QBrush blackBrush(Qt::SolidPattern);
135 QTextTableFormat tableFormat;
136 tableFormat.setAlignment(Qt::AlignLeft);
137 tableFormat.setBorderBrush(blackBrush);
138 tableFormat.setBorder(0.5);
143 tableFormat.setCellSpacing(3);
144 tableFormat.setCellPadding(3);
145 tableFormat.setHeaderRowCount(1);
147 m_table = cursor.insertTable(rows, columns, tableFormat);
149 int countRows = m_table->rows();
150 int countColumns = m_table->columns();
153 for(
int i = 1 ; i < countRows ; ++i)
155 QTextTableCell cellOne = m_table->cellAt(i, 0);
156 QTextCharFormat fmtOne = cellOne.format();
157 fmtOne.setBackground(Qt::gray);
159 cellOne.setFormat(fmtOne);
163 for(
int j = 0 ; j < countColumns ; ++j)
165 QTextTableCell cellTwo = m_table->cellAt(0, j);
166 QTextCharFormat fmtTwo = cellTwo.format();
167 fmtTwo.setBackground(Qt::gray);
169 cellTwo.setFormat(fmtTwo);
Abstract class to represent an observable. "Model" part of MVC component.
virtual int getNumberColumns()
virtual void refreshDocument()
Abstract class to represent a controller. "Controller" part of MVC component. All classes representin...
Class that represents a "Model" part of TextGrid MVC component. Its coordinate system is the same of ...
An Envelope defines a 2D rectangular region.
virtual int getNumberRows()
virtual void updateDocument()
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...
Class daughter of te::layout::TitleItem representing a grid with cells which can be inserted texts...
virtual ~TextGridItem()
Destructor.
virtual void setBox(te::gm::Envelope box)
Change the bounding rectangle.
TextGridItem(ItemController *controller, Observable *o)
Constructor.