| 27 | constexpr int y_margin = 20; |
| 28 | |
| 29 | static void drawGrid(QPainter &painter, QSize size) |
| 30 | { |
| 31 | |
| 32 | const int cell_w = 100; |
| 33 | const int cell_h = 100; |
| 34 | |
| 35 | { |
| 36 | QPen pen = painter.pen(); |
| 37 | pen.setWidth(1); |
| 38 | pen.setStyle(Qt::DotLine); |
| 39 | painter.setPen(pen); |
| 40 | } |
| 41 | |
| 42 | const auto columns = std::ceil(static_cast<float>(size.width()) / cell_w); |
| 43 | const auto rows = std::ceil(static_cast<float>(size.height()) / cell_h); |
| 44 | |
| 45 | for (auto row = 0; row < rows; ++row) |
| 46 | { |
| 47 | for (auto col = 0; col < columns; ++col) |
| 48 | { |
| 49 | auto x = col * cell_w; |
| 50 | auto y = row * cell_h; |
| 51 | painter.drawRect(x, y, cell_w, cell_w); |
| 52 | } |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | void TreeScrollArea::paintEvent(QPaintEvent *event) |
| 57 | { |