PNP_PIbd-31_Rodionov_I_A_Co.../mainwindow.h
2025-01-14 21:33:47 +04:00

95 lines
2.6 KiB
C++

#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QCloseEvent>
#include <QDialog>
#include <QButtonGroup>
#include <QScreen>
#include <QListWidget>
#include <QToolTip>
#include <QMessageBox>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QTextStream>
#include <QFile>
#include "apiclient.h"
#include "models/types.h" // IWYU pragma: keep
#include "models/filterparams.h"
#include "utils/buttonhoverwatcher.h" // IWYU pragma: keep
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr);
~MainWindow();
void setClient(ApiClient *newClient);
private:
template <typename T>
void fillTable(const QMap<int, T> &map);
void fillListWidget(const QList<Device> &devices);
void updateDevices(int entityId);
QWidget* createMessageEmptyCard();
QWidget* createDeviceCard(const Device &device);
QString normalizeTypeName(const QString &name);
void addMessageEmptyToList();
void addDeviceToList(const Device &device);
void returnToDeviceList();
void showTableWithStructureElements(const QList<DeviceStructureElement>& elements);
void showTableWithDeviceModelCharacteristics(const DeviceModel& model);
void clearSpinBoxes();
void clearFilters();
void clearDevicesOutputSettings();
int getSelectedElementId();
QMap<int, Device> getDevicesMap(const QList<Device> &devices);
private slots:
void updateTableWidget(int index);
void updateListWidget();
void showItemInfo(QListWidgetItem*);
void changeSortOrder();
void pushButtonBackClicked();
void pushButtonClearClicked();
void pushButtonSearchClicked();
void pushButtonDisregardPriceClicked();
void pushButtonApplyFiltersClicked();
void pushButtonCancelFiltersClicked();
void pushButtonStructureClicked();
void pushButtonCharacteristicsClicked();
void pushButtonDefaultClicked();
void onDevicesReceived(const QList<Device> &devices);
void onDepartmentsReceived(const QMap<int, Department> &departments);
void onDeviceModelsReceived(const QMap<int, DeviceModel> &deviceModels);
void onDeviceTypesReceived(const QMap<int, DeviceType> &deviceTypes);
void onManufacturersReceived(const QMap<int, Manufacturer> &manufacturers);
void onLocationsReceived(const QMap<int, Location> &locations);
private:
Ui::MainWindow *ui;
ApiClient *_client;
QString _searchInfo = "";
FilterParams _filterParams;
bool _initialTypesLoad = true;
int _idCard = 0;
QMap<int, QString> _deviceTypeImages;
QMap<int, Device> _mapDevices;
};
#endif // MAINWINDOW_H