#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include "flowlayout.h"
#include "sensorwidget.h"
#include "sensorservice.h"
#include "httpclient.h"

#include <QMainWindow>
#include <QPixmap>
#include <QVBoxLayout>

#ifdef Q_OS_WIN
#include <Qlabel>
#elif defined(Q_OS_LINUX)
#include <QLabel>
#endif

QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE

struct TabImageData
{
    QLabel *label;
    QPixmap pixmap;
    QSize originalSize;
};

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private:
    Ui::MainWindow *ui;

private:
    HttpClient *httpClient;
    QWidget *widgetContainer;
    FlowLayout *layout;
    SensorService *sensorService;


private:
    //dialog windows
    void showSensorDialog(SensorWidget *sensor);
    void onSensorDialogFinished(int result);
    //api requests
    void loadSensors(const QString& group);
    void loadSensorGroups();
    //update sensor widgets
    void updateDisplayedWidgets();
    void onSearchTextChanged(const QString &text);
    void onGroupSelected(int index);
    void onShowHiddenSelected(int index);
    //sensor tab utility
    void startSensorTabRefreshTimer();
    void SetupSensorTab();

};
#endif // MAINWINDOW_H
