LCOV - code coverage report
Current view: top level - src - object.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 84.4 % 32 27
Test Date: 2025-07-25 14:54:22 Functions: 83.3 % 6 5

            Line data    Source code
       1              : #include "object.h"
       2              : 
       3            7 : Object::Object(QWidget *parent): QWidget(parent)
       4              : {
       5            7 :     QString path = QCoreApplication::applicationDirPath();
       6            7 :     speed50_path = QDir(path).filePath("../fonts_icon/speed50.png");
       7            7 :     speed50_path = QDir::cleanPath(speed50_path);
       8            7 :     speed80_path = QDir(path).filePath("../fonts_icon/speed80.png");
       9            7 :     speed80_path = QDir::cleanPath(speed80_path);
      10            7 :     set_object(2);
      11           14 : }
      12              : 
      13            4 : void Object::paintEvent(QPaintEvent *event)
      14              : {
      15            4 :     QPainter painter(this);
      16            4 :     painter.setRenderHint(QPainter::Antialiasing);
      17            4 :     QPixmap pixmap;
      18            4 :     if (object == 1) {
      19            0 :         pixmap.load(speed50_path);
      20            4 :     } else if (object == 2) {
      21            4 :         pixmap.load(speed80_path);
      22              :     }
      23            4 :     if (!pixmap.isNull()) {
      24            4 :         QPixmap scaled = pixmap.scaled(60, 60, Qt::KeepAspectRatio, Qt::SmoothTransformation);
      25            4 :         painter.drawPixmap(0, 0, scaled);  //  margin
      26            4 :     }
      27              :     else {
      28            0 :         std::cout << "Object: no image found" << std::endl;
      29              :     }
      30            8 : }
      31              : 
      32              : //parsing
      33            7 : void Object::set_object(int i)
      34              : {
      35            7 :     if (object == i or (i != 1 && i != 2))
      36            0 :         return;
      37            7 :     object = i;
      38            7 :     update();
      39              : }
      40              : 
      41            0 : int Object::get_object()
      42              : {
      43            0 :     return object;
      44              : }
      45              : 
      46           14 : Object::~Object()
      47              : {
      48            7 :     std::cout << "Remove Object" << std::endl;
      49           14 : }
        

Generated by: LCOV version 2.0-1