2024-11-24 09:48:52 +00:00
|
|
|
#include "mainwindow.h"
|
|
|
|
#include "./ui_mainwindow.h"
|
2024-11-28 08:02:59 +00:00
|
|
|
#include "sensorlayout.h"
|
2024-11-28 18:34:00 +00:00
|
|
|
#include "sensorwidget.h"
|
|
|
|
#include "httpclient.h"
|
2024-11-24 09:48:52 +00:00
|
|
|
|
2024-11-28 18:34:00 +00:00
|
|
|
#include <QComboBox>
|
2024-11-24 21:46:29 +00:00
|
|
|
#include <QGridLayout>
|
|
|
|
#include <QResizeEvent>
|
2024-11-28 08:02:59 +00:00
|
|
|
#include <QScrollArea>
|
|
|
|
|
|
|
|
#include <QDebug>
|
2024-11-24 21:46:29 +00:00
|
|
|
|
2024-11-24 09:48:52 +00:00
|
|
|
MainWindow::MainWindow(QWidget *parent)
|
|
|
|
: QMainWindow(parent)
|
|
|
|
, ui(new Ui::MainWindow)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
2024-11-28 08:02:59 +00:00
|
|
|
|
|
|
|
// Создаем QScrollArea для прокрутки
|
2024-11-28 18:34:00 +00:00
|
|
|
QScrollArea *scrollArea = new QScrollArea(this);
|
2024-11-28 08:02:59 +00:00
|
|
|
scrollArea->setStyleSheet("background: transparent; border: 0;");
|
2024-11-28 18:34:00 +00:00
|
|
|
SensorLayout *sl = new SensorLayout(scrollArea);
|
|
|
|
scrollArea->setLayout(sl); // Устанавливаем контейнер
|
|
|
|
scrollArea->setWidgetResizable(true); // Контейнер будет растягиваться по области просмотра
|
2024-11-28 08:02:59 +00:00
|
|
|
scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
|
|
|
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
|
|
|
|
|
|
|
// Добавляем QScrollArea в основной layout
|
|
|
|
ui->SensorsTabLayout->addWidget(scrollArea);
|
|
|
|
|
|
|
|
// Добавляем виджеты в SensorLayout
|
2024-11-28 18:34:00 +00:00
|
|
|
int rows = 3; // Количество строк
|
|
|
|
int columns = 3; // Количество столбцов
|
2024-11-28 08:02:59 +00:00
|
|
|
|
|
|
|
for (int row = 0; row < rows; ++row) {
|
|
|
|
for (int col = 0; col < columns; ++col) {
|
|
|
|
const QString a = QString::number(row);
|
|
|
|
const QString b = QString::number(col);
|
|
|
|
const QString c = QString::number(row + col);
|
2024-11-28 18:34:00 +00:00
|
|
|
SensorWidget *sensor = new SensorWidget(nullptr, a, b, c);
|
2024-11-28 08:02:59 +00:00
|
|
|
sl->addWidget(sensor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-11-28 18:34:00 +00:00
|
|
|
HttpClient httpClient;
|
|
|
|
for (int i = 0; i < 10; ++i) {
|
|
|
|
QJsonObject getResult = httpClient.get("http://raspberrypi.lan:8080/data/getDevices");
|
|
|
|
qDebug() << "GET Response:" << getResult;
|
|
|
|
}
|
2024-11-24 09:48:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MainWindow::~MainWindow()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
2024-11-24 21:46:29 +00:00
|
|
|
|
2024-11-28 18:34:00 +00:00
|
|
|
void MainWindow::ResizeEvent(QResizeEvent *event) {}
|
2024-11-24 21:46:29 +00:00
|
|
|
|
2024-11-28 18:34:00 +00:00
|
|
|
void MainWindow::SetupTabs() {}
|
2024-11-24 21:46:29 +00:00
|
|
|
|
2024-11-28 18:34:00 +00:00
|
|
|
void MainWindow::SetupSensorTab(QWidget *tab, QVBoxLayout *mainLayout) {}
|
2024-11-24 21:46:29 +00:00
|
|
|
|
2024-11-28 18:34:00 +00:00
|
|
|
void MainWindow::SetupIncidentTab(QWidget *tab, QVBoxLayout *mainLayout) {}
|
2024-11-24 21:46:29 +00:00
|
|
|
|
2024-11-28 18:34:00 +00:00
|
|
|
void MainWindow::SetupStatisticsTab(QWidget *tab, QVBoxLayout *mainLayout) {}
|
2024-11-24 21:46:29 +00:00
|
|
|
|
2024-11-28 18:34:00 +00:00
|
|
|
void MainWindow::SetupJournalTab(QWidget *tab, QVBoxLayout *mainLayout) {}
|
2024-11-24 21:46:29 +00:00
|
|
|
|
2024-11-28 18:34:00 +00:00
|
|
|
void MainWindow::SetupSettingsTab(QWidget *tab, QVBoxLayout *mainLayout) {}
|