34 lines
735 B
C++
34 lines
735 B
C++
#include "gridpreview.h"
|
|
|
|
GridPreview::GridPreview(QWidget *parent)
|
|
: QWidget{parent}
|
|
{}
|
|
|
|
void GridPreview::setSize(int newWidth, int newHeight)
|
|
{
|
|
width = newWidth;
|
|
height = newHeight;
|
|
}
|
|
|
|
void GridPreview::addLine(Line &line)
|
|
{
|
|
lines.push_back(line);
|
|
}
|
|
|
|
void GridPreview::removeLine(int index)
|
|
{
|
|
lines.removeAt(index);
|
|
}
|
|
|
|
QString GridPreview::toLuaTable()
|
|
{
|
|
QString output(tableTemplate.arg(width).arg(height));
|
|
QString linesSubTable = "";
|
|
for(auto iter = lines.begin(); iter != lines.end(); iter++ )
|
|
{
|
|
linesSubTable += QString(" %1,\n").arg(iter->toLuaTable());
|
|
}
|
|
linesSubTable.removeLast(); // \n
|
|
linesSubTable.removeLast(); // ,
|
|
return output.arg(linesSubTable);
|
|
}
|